Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(teamhub-cli): handle native WSL attachment paths
Codex8e841bd34865
diff --git a/apps/desktop/AGENTS.md b/apps/desktop/AGENTS.mdindex 4567f289..14702f9c 100644--- a/apps/desktop/AGENTS.md+++ b/apps/desktop/AGENTS.md@@ -452,9 +452,10 @@ home> --stop-local-models` under `ELECTRON_RUN_AS_NODE`, detached, with`node` in PATH from source. The Desktop TeamHub shell launcher uses`wslpath` and `WSLENV` when WSL starts the Windows executable, so thescript path and `ELECTRON_RUN_AS_NODE` reach that process correctly.- Arguments are forwarded unchanged: for a file flag like `--attach`,- convert the Linux path explicitly with `wslpath -w` before passing it- to Windows Node. Other arguments may be message text or remote paths.+ The CLI translates absolute Linux paths for local attachments, input files+ and Document file outputs using the invoking WSL distribution. Message text+ and remote paths stay unchanged. The same local file checks apply to the+ translated path.## Source Package and Releasediff --git a/apps/desktop/scripts/teamhub.sh b/apps/desktop/scripts/teamhub.shindex 9783f58b..e34f7282 100644--- a/apps/desktop/scripts/teamhub.sh+++ b/apps/desktop/scripts/teamhub.sh@@ -12,7 +12,7 @@ case "$app" in# explicitly listed Linux environment variables to Windows executables.if command -v wslpath >/dev/null 2>&1; thenscript=$(wslpath -w "$script") || exit 1- WSLENV="${WSLENV:+$WSLENV:}ELECTRON_RUN_AS_NODE"+ WSLENV="${WSLENV:+$WSLENV:}ELECTRON_RUN_AS_NODE:WSL_DISTRO_NAME"export WSLENVfi;;diff --git a/apps/desktop/src/main/teamhub-wsl.test.ts b/apps/desktop/src/main/teamhub-wsl.test.tsindex 62b377fb..66927d92 100644--- a/apps/desktop/src/main/teamhub-wsl.test.ts+++ b/apps/desktop/src/main/teamhub-wsl.test.ts@@ -1,6 +1,5 @@import { execFileSync, spawnSync } from "node:child_process";import {- copyFileSync,mkdirSync,mkdtempSync,readFileSync,@@ -9,6 +8,7 @@ import {} from "node:fs";import { tmpdir } from "node:os";import path from "node:path";+import { buildSync } from "esbuild";import { expect, it } from "vitest";const wslExecutable = path.join(@@ -24,53 +24,185 @@ const wslAvailable =}).status === 0;it.skipIf(!wslAvailable)(- "runs the Desktop TeamHub script through WSL with Windows paths and environment",+ "sends a native WSL attachment and saves a native WSL output with Windows Node",() => {const root = mkdtempSync(path.join(tmpdir(), "linger teamhub wsl "));- const wsl = (args: string[], env = process.env, timeout = 15_000) =>- execFileSync(wslExecutable, ["--exec", ...args], {+ const wsl = (args: string[]) =>+ execFileSync(wslExecutable, ["--cd", "/tmp", "--exec", ...args], {encoding: "utf8",- timeout,+ timeout: 30_000,windowsHide: true,- env,}).trim();+ let linuxRoot: string | undefined;+ const cli = path.join(root, "resources", "app", "dist", "teamhub-cli");+ let primaryError: unknown;try {- const cli = path.join(root, "resources", "app", "dist", "teamhub-cli");mkdirSync(cli, { recursive: true });- copyFileSync(process.execPath, path.join(root, "Linger.exe"));- writeFileSync(- path.join(cli, "teamhub"),+ const put = (name: string, text: string) => {+ writeFileSync(path.join(cli, name), text);+ };+ put("package.json", '{"type":"module"}');+ put("token", "th_agent_fixture\n");+ put(+ "config.json",+ JSON.stringify({+ version: 1,+ default_profile: "work",+ profiles: {+ work: {+ url: "https://teamhub.example",+ token_file: "token",+ scope: { kind: "room", id: "room_example" },+ },+ },+ }),+ );+ put(+ "teamhub",readFileSync(path.resolve("scripts/teamhub.sh"), "utf8").replace(/\r\n/g,"\n",),);- writeFileSync(- path.join(cli, "teamhub.js"),- `const {readFileSync} = require("node:fs");- const [message, file] = process.argv.slice(2);- process.stdout.write(JSON.stringify({node:process.env.ELECTRON_RUN_AS_NODE,message,file,attachment:readFileSync(file,"utf8")}));`,- );- const attachment = path.join(root, "attachment with spaces.txt");- writeFileSync(attachment, "attachment bytes");- const unixPath = wsl(["wslpath", "-u", path.join(cli, "teamhub")]);- const linuxAttachment = wsl(["wslpath", "-u", attachment]);- const windowsAttachment = wsl(["wslpath", "-w", linuxAttachment]);- const message = "/home/u/x.png is message text";- const result = wsl(- ["/bin/sh", unixPath, message, windowsAttachment],- { ...process.env, ELECTRON_RUN_AS_NODE: "" },- 30_000,- );- expect(JSON.parse(result)).toEqual({- node: "1",- message,- file: windowsAttachment,- attachment: "attachment bytes",+ buildSync({+ stdin: {+ resolveDir: process.cwd(),+ contents: FIXTURE,+ },+ bundle: true,+ format: "esm",+ platform: "node",+ outfile: path.join(cli, "teamhub.js"),});- } finally {- rmSync(root, { recursive: true, force: true });+ const sandbox = wsl([+ "/bin/sh",+ "-c",+ 'base=$HOME; if [ -w /home ]; then base=/home; fi; mktemp -d -- "$base/linger-teamhub.XXXXXXXX"',+ ]);+ expect(sandbox).toMatch(/^\/.*linger-teamhub\.[A-Za-z0-9]{8}$/u);+ linuxRoot = sandbox;+ const attachment = sandbox + "/attachment with spaces.txt";+ const alias = sandbox + "/alias.txt";+ const output = sandbox + "/output with spaces.png";+ const body = sandbox + "/body with spaces.md";+ const content = "/home/u/x.png is message text, including --attach";+ wsl([+ "/bin/sh",+ "-c",+ 'printf "attachment bytes" > "$1" && ln -s -- "$1" "$2" && printf "%s" "$4" > "$3"',+ "sh",+ attachment,+ alias,+ body,+ content,+ ]);+ const launcher = wsl(["wslpath", "-u", path.join(cli, "teamhub")]);+ const node = wsl(["wslpath", "-u", process.execPath]);+ const run = (...args: string[]) =>+ JSON.parse(+ wsl(["env", `LINGER_NODE=${node}`, "/bin/sh", launcher, ...args]),+ );+ const send = (...args: string[]) =>+ run("message", "send", "--content", content, ...args);+ const receipt = {+ node: "1",+ exit: 0,+ calls: [+ {+ segments: [{ type: "text", content }, { type: "document" }],+ attachment: "attachment bytes",+ },+ ],+ };+ for (const sent of [+ send("--attach", attachment),+ run(+ "message",+ "send",+ "--message",+ JSON.stringify({+ segments: [+ { type: "text", content },+ { type: "document", "content-path": attachment },+ ],+ }),+ ),+ run(+ "message",+ "send",+ "--file",+ body,+ "--attach=" + wsl(["wslpath", "-w", attachment]),+ ),+ ]) {+ expect(sent.exit, JSON.stringify(sent)).toBe(0);+ expect(sent).toMatchObject(receipt);+ }+ const rejected = send("--attach=" + alias);+ expect(rejected.exit, JSON.stringify(rejected)).not.toBe(0);+ expect(rejected.calls).toEqual([]);+ const saved = run(+ "docs",+ "image",+ "get",+ "document_example",+ "block_card",+ "--output",+ output,+ );+ expect(saved.exit, JSON.stringify(saved)).toBe(0);+ expect(wsl(["cat", output])).toBe("image fixture");+ } catch (error) {+ primaryError = error;+ }+ try {+ if (linuxRoot)+ wsl([+ "/bin/sh",+ "-c",+ 'rm -f -- "$1/attachment with spaces.txt" "$1/alias.txt" "$1/output with spaces.png" "$1/body with spaces.md" && rmdir -- "$1"',+ "sh",+ linuxRoot,+ ]);+ rmSync(root, { recursive: true, force: true, maxRetries: 8 });+ } catch (cleanupError) {+ throw primaryError === undefined+ ? cleanupError+ : new AggregateError(+ [primaryError, cleanupError],+ String(primaryError),+ );}+ if (primaryError !== undefined) throw primaryError;},- 120_000,+ 180_000,);++const FIXTURE = `+import { runCli } from "../teamhub-cli/src/cli.ts";+import path from "node:path";+const calls = [];+const configured = {+ WSL_DISTRO_NAME: process.env.WSL_DISTRO_NAME,+ SystemRoot: process.env.SystemRoot,+ TEAMHUB_CONFIG: path.join(path.dirname(process.argv[1]), "config.json"),+};+let stdout = "", stderr = "";+const exit = await runCli(process.argv.slice(2), {+ cwd: process.cwd(), env: configured,+ stdout(value) { stdout += value; }, stderr(value) { stderr += value; },+ async fetch(input, init) {+ const request = new Request(input, init);+ const fields = new URL(request.url).pathname;+ if (fields.endsWith("/files/document_example/content"))+ return Response.json({ blocks: [{ id: "block_card", type: "image", props: { url: "document-asset:asset_example" } }] });+ if (fields.endsWith("/assets/asset_example/content")) return new Response("image fixture");+ const form = await request.formData();+ const metadata = JSON.parse(form.get("metadata"));+ const uploaded = form.get("file");+ calls.push({ segments: metadata.segments, attachment: await uploaded.text() });+ return Response.json({ accepted: true, target: { type: "room", id: "room_example" }, inbox_id: "room_example", message_id: "message_example", resources: [{kind: "document", segment_index: 1, status: "published", document_id: "document_example", version_id: "version_example", name: "attachment with spaces.txt"}], duplicate_request: false });+ },+});+process.stdout.write(JSON.stringify({ exit, node: process.env.ELECTRON_RUN_AS_NODE, calls, stdout, stderr }));+`;diff --git a/apps/teamhub-cli/README.md b/apps/teamhub-cli/README.mdindex e1692a02..dcbc7d45 100644--- a/apps/teamhub-cli/README.md+++ b/apps/teamhub-cli/README.md@@ -54,6 +54,12 @@ teamhub agent create --name 'Reviewer' --description 'Checks patches' --prompt-fteamhub agent update --agent-id <actor-id> --prompt-file ./reviewer.md --json```+## Windows Subsystem for Linux++When Pi runs the Desktop TeamHub CLI from WSL, use Linux paths directly for Room message attachments (`--attach` and JSON `content-path`), command input files (`--file`, `--prompt-file`), and `docs` file and image arguments. Quote paths with spaces. Message text is passed through as text.++Connected application commands may have their own file options. For those options, convert an absolute Linux path explicitly, for example `gdrive download ... --output "$(wslpath -w /home/me/report.pdf)"`.+## Connected applicationsEight applications have dedicated commands: Gmail, Outlook, Slack, Google Calendar, Notion, Google Drive, Figma and GitHub, with 50 Connector leaf commands. `teamhub gmail --help` and `teamhub gdrive --help` discover them offline, and each command keeps its own help, examples and Composio support boundary.diff --git a/apps/teamhub-cli/src/business-commands.test.ts b/apps/teamhub-cli/src/business-commands.test.tsindex 401a5534..a24dcf0b 100644--- a/apps/teamhub-cli/src/business-commands.test.ts+++ b/apps/teamhub-cli/src/business-commands.test.ts@@ -20,6 +20,7 @@ import { personalProfileDocument } from "./test-support/command-examples.js";const reader: CommandInputReader = {cwd: "/work",+ localPath: (source) => source,text: async (source) =>source === "body.md" ? "Keep Unicode café €\n" : "file body",json: async (source) =>diff --git a/apps/teamhub-cli/src/cli.ts b/apps/teamhub-cli/src/cli.tsindex 896e5c30..254ae61b 100644--- a/apps/teamhub-cli/src/cli.ts+++ b/apps/teamhub-cli/src/cli.ts@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";import path from "node:path";import {configurationDirectory,+ createLocalPathResolver,loadConfig,withScope,type TeamHubConfig,@@ -169,6 +170,10 @@ export async function runCli("configuration_error","TEAMHUB_STATE_ROOT must be an absolute directory without control characters.",);+ const localPath = createLocalPathResolver(+ dependencies.cwd,+ dependencies.env,+ );const normalize = async (): Promise<NormalizedCommandInput & { operationId?: string }> => {@@ -176,6 +181,7 @@ export async function runCli(? dependencies.timing.measure("command_dependencies", () =>parseDomainCommand(args, {...dependencies,+ localPath,beforeNormalize: (value) => {target = value;},@@ -183,6 +189,7 @@ export async function runCli(): parseDomainCommand(args, {...dependencies,+ localPath,beforeNormalize: (value) => {target = value;},@@ -309,6 +316,7 @@ export async function runCli(return selected!.execute(input, {client,cwd: dependencies.cwd,+ localPath,stateRoot,operationId,fetch: dependencies.fetch,diff --git a/apps/teamhub-cli/src/command-definition.ts b/apps/teamhub-cli/src/command-definition.tsindex 6b794469..f7996307 100644--- a/apps/teamhub-cli/src/command-definition.ts+++ b/apps/teamhub-cli/src/command-definition.ts@@ -15,6 +15,7 @@ export interface CommandArguments {export interface CommandInputReader {readonly cwd: string;+ localPath(source: string): string;text(source: string): Promise<string>;json(source: string): Promise<unknown>;}@@ -35,6 +36,7 @@ export interface CommandExecutionContext {readonly client: TeamHubHttpClient;readonly cwd: string;readonly stateRoot: string;+ readonly localPath?: (source: string, relativeTo?: string) => string;/** Present for write commands; TeamHub deduplicates the write by it. */readonly operationId?: string;readonly timing?: CliTiming;diff --git a/apps/teamhub-cli/src/command-input.ts b/apps/teamhub-cli/src/command-input.tsindex 9ede19c3..754127a7 100644--- a/apps/teamhub-cli/src/command-input.ts+++ b/apps/teamhub-cli/src/command-input.ts@@ -143,8 +143,12 @@ export function parseJsonValue(text: string): unknown {export function createInputReader(dependencies: {cwd: string;+ localPath?: (source: string) => string;readInput?: (source: string) => Promise<string>;}): CommandInputReader {+ const localPath =+ dependencies.localPath ??+ ((source: string) => path.resolve(dependencies.cwd, source));let stdinRead = false;const text = async (source: string): Promise<string> => {if (!source || source.includes("\0"))@@ -157,8 +161,7 @@ export function createInputReader(dependencies: {throw new CliError("usage", "Only one input source may read stdin.");stdinRead = true;}- const filename =- source === "-" ? "-" : path.resolve(dependencies.cwd, source);+ const filename = source === "-" ? "-" : localPath(source);try {if (dependencies.readInput) {const result = await dependencies.readInput(filename);@@ -219,6 +222,7 @@ export function createInputReader(dependencies: {};return {cwd: dependencies.cwd,+ localPath,text,json: async (source) => parseJsonValue(await text(source)),};diff --git a/apps/teamhub-cli/src/config.ts b/apps/teamhub-cli/src/config.tsindex 0299aad1..63d50152 100644--- a/apps/teamhub-cli/src/config.ts+++ b/apps/teamhub-cli/src/config.ts@@ -1,3 +1,4 @@+import { execFileSync } from "node:child_process";import { createHash } from "node:crypto";import { constants } from "node:fs";import { lstat, open, realpath } from "node:fs/promises";@@ -24,6 +25,55 @@ export interface TeamHubConfig {readonly agentIdentityKey?: string;}+export function createLocalPathResolver(cwd: string, env: NodeJS.ProcessEnv) {+ const distro = process.platform === "win32" ? env.WSL_DISTRO_NAME : undefined;+ const wsl = path.join(env.SystemRoot ?? "C:/Windows", "System32", "wsl.exe");+ const translatedParents = new Map<string, string>();+ return (source: string, relativeTo = cwd): string => {+ if (!distro || !source.startsWith("/") || source.startsWith("//"))+ return path.resolve(relativeTo, source);+ const invalidPath = () =>+ new CliError(+ "invalid_path",+ "Could not resolve the local WSL file path.",+ );+ if (/[:\\\p{Cc}]/u.test(source)) throw invalidPath();+ const normalized = path.posix.normalize(source);+ const parent = path.posix.dirname(normalized);+ let translated = translatedParents.get(parent);+ if (translated === undefined) {+ // Translate the directory, preserving the leaf for the file checks.+ // Use the invoking distro even when a different distro is the default.+ try {+ translated = execFileSync(+ wsl,+ [+ "--distribution",+ distro,+ "--exec",+ "/usr/bin/wslpath",+ "-w",+ parent,+ ],+ {+ encoding: "utf8",+ windowsHide: true,+ timeout: 10_000,+ maxBuffer: 65_536,+ stdio: ["ignore", "pipe", "pipe"],+ },+ ).replace(/\r?\n$/u, "");+ } catch {+ throw invalidPath();+ }+ if (!path.isAbsolute(translated) || /\p{Cc}/u.test(translated))+ throw invalidPath();+ translatedParents.set(parent, translated);+ }+ return path.join(translated, path.posix.basename(normalized));+ };+}+function invalid(message: string): never {throw new CliError("configuration_error", message);}diff --git a/apps/teamhub-cli/src/document-commands.test.ts b/apps/teamhub-cli/src/document-commands.test.tsindex 1a7366b6..130f19b4 100644--- a/apps/teamhub-cli/src/document-commands.test.ts+++ b/apps/teamhub-cli/src/document-commands.test.ts@@ -4,6 +4,7 @@ import { parseArguments } from "./command-input.js";import type { CommandInputReader } from "./command-definition.js";const reader: CommandInputReader = {cwd: "/work",+ localPath: (source) => source,text: vi.fn(async () => " Body é\n"),json: vi.fn(async () => ({ thread_id: "thread_one" })),};diff --git a/apps/teamhub-cli/src/document-commands.ts b/apps/teamhub-cli/src/document-commands.tsindex 24e8892c..06ddfe02 100644--- a/apps/teamhub-cli/src/document-commands.ts+++ b/apps/teamhub-cli/src/document-commands.ts@@ -1,5 +1,4 @@import { operationHeaders, teamHubData } from "./http-client.js";-import path from "node:path";import type {CommandDefinition,NormalizedCommandInput,@@ -400,7 +399,7 @@ export const documentCommandDefinitions: readonly CommandDefinition[] = [return {input: {name,- target_path: path.resolve(reader.cwd, filename),+ target_path: reader.localPath(filename),...(format === undefined ? {} : { format }),...(option(args, "--raw") === undefined ? {} : { raw: true }),},@@ -596,7 +595,7 @@ export const documentCommandDefinitions: readonly CommandDefinition[] = [)throw inputError("Provide a tracked local working-copy path.");return target(- { document_id, file_path: path.resolve(reader.cwd, filename) },+ { document_id, file_path: reader.localPath(filename) },"document","document_id",);diff --git a/apps/teamhub-cli/src/document-image-commands.test.ts b/apps/teamhub-cli/src/document-image-commands.test.tsindex 61a90074..656fd29a 100644--- a/apps/teamhub-cli/src/document-image-commands.test.ts+++ b/apps/teamhub-cli/src/document-image-commands.test.ts@@ -21,6 +21,7 @@ const definition = (...parts: string[]) =>)!;const reader = (cwd: string): CommandInputReader => ({cwd,+ localPath: (source) => path.resolve(cwd, source),text: vi.fn(),json: vi.fn(),});diff --git a/apps/teamhub-cli/src/document-image-commands.ts b/apps/teamhub-cli/src/document-image-commands.tsindex 4613eb81..cd34faf3 100644--- a/apps/teamhub-cli/src/document-image-commands.ts+++ b/apps/teamhub-cli/src/document-image-commands.ts@@ -210,7 +210,7 @@ export const documentImageCommandDefinitions: readonly CommandDefinition[] = [throw inputError("Caption must be one line of at most 1000 characters.",);- const file = path.resolve(reader.cwd, args.positionals[1]!);+ const file = reader.localPath(args.positionals[1]!);const info = await stat(file).catch(() => undefined);if (!info?.isFile()) throw inputError("Provide a regular image file.");if (info.size < 1 || info.size > maxImageBytes)@@ -328,9 +328,7 @@ export const documentImageCommandDefinitions: readonly CommandDefinition[] = [input: {document_id: documentId,block_id: id(args.positionals[1], "block"),- ...(output === undefined- ? {}- : { output: path.resolve(reader.cwd, output) }),+ ...(output === undefined ? {} : { output: reader.localPath(output) }),},target: { type: "document", id: documentId },scope: { kind: "document", id: documentId },@@ -409,7 +407,7 @@ export const documentImageCommandDefinitions: readonly CommandDefinition[] = [const after = option(args, "--after");if (after === undefined)throw new CliError("usage", "Provide --after <block-id>.");- const file = path.resolve(reader.cwd, args.positionals[1]!);+ const file = reader.localPath(args.positionals[1]!);const info = await stat(file).catch(() => undefined);if (!info?.isFile()) throw inputError("Provide a regular file.");if (info.size < 1 || info.size > maxFileBytes)diff --git a/apps/teamhub-cli/src/domain-commands.ts b/apps/teamhub-cli/src/domain-commands.tsindex 5d2dd6e3..c9446925 100644--- a/apps/teamhub-cli/src/domain-commands.ts+++ b/apps/teamhub-cli/src/domain-commands.ts@@ -214,6 +214,7 @@ export async function parseDomainCommand(args: readonly string[],dependencies: {cwd: string;+ localPath?: (source: string) => string;readInput?: (source: string) => Promise<string>;beforeNormalize?: (target?: CommandTarget) => void;syntaxOnly?: boolean;diff --git a/apps/teamhub-cli/src/files/host-file-reader.ts b/apps/teamhub-cli/src/files/host-file-reader.tsindex fd9b12d5..b1fe433c 100644--- a/apps/teamhub-cli/src/files/host-file-reader.ts+++ b/apps/teamhub-cli/src/files/host-file-reader.ts@@ -5,6 +5,7 @@ import type { FileHandle } from "node:fs/promises";import path from "node:path";const FILE_READ_CHUNK_BYTES = 64 * 1024;+const WSL_UNC = /^\\\\(?:wsl\.localhost|wsl\$)\\/iu;export const CONTEXT_FILE_MAX_BYTES = 50 * 1024 * 1024;export type ContextRuntimeFileErrorCode =@@ -79,6 +80,13 @@ export const readExactHostFile = async (}const witness = await capturePathWitness(sourceRoot, relativePath, signal);+ if (+ process.platform === "win32" &&+ WSL_UNC.test(witness.filePath) &&+ windowsWslPathIsAlias(witness.filePath, await realpath(witness.filePath))+ ) {+ throw unavailable("Runtime file path must not contain symbolic links");+ }const handle = await open(witness.filePath,constants.O_RDONLY | constants.O_NOFOLLOW,@@ -219,6 +227,8 @@ const verifyPinnedPath = async (): Promise<void> => {signal.throwIfAborted();const resolvedFile = await realpath(witness.filePath);+ if (windowsWslPathIsAlias(witness.filePath, resolvedFile))+ throw unavailable("Runtime file path must not contain symbolic links");if (!containsHostPath(sourceRoot, resolvedFile)) {throw unavailable("Runtime file escaped its mapping source");}@@ -243,6 +253,18 @@ const verifyPinnedPath = async (// privileged swap-out-and-back between checks remains a platform residual.};+// The WSL UNC provider follows even leaf symlinks in Windows lstat.+// Compare canonical names without folding Linux path case.+export function windowsWslPathIsAlias(+ requested: string,+ canonical: string,+): boolean {+ if (process.platform !== "win32" || !WSL_UNC.test(requested)) return false;+ const normalize = (value: string) =>+ path.normalize(value).replace(WSL_UNC, "\\\\wsl.localhost\\");+ return normalize(requested) !== normalize(canonical);+}+const sameIdentity = (left: BigIntFileIdentity,right: BigIntFileIdentity,@@ -270,7 +292,7 @@ const isUnavailableFileSystemError = (): error is NodeJS.ErrnoException =>error instanceof Error &&"code" in error &&- ["EACCES", "ELOOP", "ENOENT", "ENOTDIR", "EPERM"].includes(+ ["EACCES", "EISDIR", "ELOOP", "ENOENT", "ENOTDIR", "EPERM"].includes(String(error.code),);diff --git a/apps/teamhub-cli/src/message-commands.test.ts b/apps/teamhub-cli/src/message-commands.test.tsindex 233bb299..9450e750 100644--- a/apps/teamhub-cli/src/message-commands.test.ts+++ b/apps/teamhub-cli/src/message-commands.test.ts@@ -19,6 +19,7 @@ function args(}const reader: CommandInputReader = {cwd: "/work",+ localPath: (source) => source,text: async (source) => (source === "body.md" ? "Hello\n\nworld" : source),json: async (source) => JSON.parse(source),};diff --git a/apps/teamhub-cli/src/message-send-executor.ts b/apps/teamhub-cli/src/message-send-executor.tsindex 9b40503c..3476dcab 100644--- a/apps/teamhub-cli/src/message-send-executor.ts+++ b/apps/teamhub-cli/src/message-send-executor.ts@@ -4,7 +4,10 @@ import {bundleDocumentImages,inferFileMetadata,} from "@linger/document-files";-import { readExactHostFile } from "./files/host-file-reader.js";+import {+ readExactHostFile,+ windowsWslPathIsAlias,+} from "./files/host-file-reader.js";import { isExcludedPublicationEntry } from "./files/publication-filter.js";import { agentOperationInvocationId } from "./business-routes.js";import type { CommandExecutionContext } from "./command-definition.js";@@ -172,7 +175,9 @@ async function prepare(metadata.segments.push(segment);continue;}- const absolute = path.resolve(canonicalCwd, source);+ const absolute =+ context.localPath?.(source, canonicalCwd) ??+ path.resolve(canonicalCwd, source);publicPath(absolute);if (segment.mode === "tree") {if (context.target?.type === "task")@@ -180,7 +185,10 @@ async function prepare(const rootInfo = await lstat(absolute);if (!rootInfo.isDirectory() || rootInfo.isSymbolicLink())throw invalid("Tree resources require a local directory.");- publicPath(await realpath(absolute));+ const canonical = await realpath(absolute);+ if (windowsWslPathIsAlias(absolute, canonical))+ throw invalid("Tree resources cannot be symbolic links.");+ publicPath(canonical);const root_name = path.basename(absolute);if (isExcludedPublicationEntry(root_name))throw invalid("Private directories cannot be published.");@@ -198,7 +206,12 @@ async function prepare(const child = relative ? `${relative}/${item.name}` : item.name;const full = path.join(absolute, child);const info = await lstat(full);- if (info.isSymbolicLink() || (!info.isFile() && !info.isDirectory()))+ if (+ info.isSymbolicLink() ||+ (!info.isFile() && !info.isDirectory()) ||+ (info.isDirectory() &&+ windowsWslPathIsAlias(full, await realpath(full)))+ )throw invalid("Directory trees cannot contain symlinks or special files.",);diff --git a/scripts/env-inventory.json b/scripts/env-inventory.jsonindex d384f6e9..32624bc8 100644--- a/scripts/env-inventory.json+++ b/scripts/env-inventory.json@@ -58,7 +58,7 @@},"platform": {"owner": "out-of-env",- "description": "Variables injected by the runtime environment: image build info, the teamhub-cli runtime, Computer on user machines, deployment platforms, and the Room Document E2E harness. On Linux the Computer reads the desktop session's DISPLAY and WAYLAND_DISPLAY before it opens a browser window. Not part of .env.",+ "description": "Variables injected by the runtime environment: image build info, the teamhub-cli runtime, Computer on user machines, deployment platforms, and the Room Document E2E harness. On Linux the Computer reads the desktop session's DISPLAY and WAYLAND_DISPLAY before it opens a browser window. The Desktop WSL launcher passes WSL_DISTRO_NAME to the Windows TeamHub CLI so it can resolve local attachment paths. Not part of .env.","names": ["APP_VERSION","CLAUDE_CONFIG_DIR",@@ -90,7 +90,8 @@"TEAMHUB_TOKEN","TEAMHUB_TOKEN_FILE","TEAMHUB_URL",- "WAYLAND_DISPLAY"+ "WAYLAND_DISPLAY",+ "WSL_DISTRO_NAME"]},"desktop": {