Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.
TypeScript agentai-agentai-agentsai-assistantandroidautomationchatgptcoding-agentcomputer-usedesktop-appelectronllmlocal-firstmcpmulti-agentollamaopenaiprivacyself-hostedtypescript
fix(windows): compare deliverable and worktree paths platform-aware
leen.zhou42c2553899af
diff --git a/packages/brain/src/runtime/continuation/named-outputs.ts b/packages/brain/src/runtime/continuation/named-outputs.tsindex 48d6cbb..ecc6522 100644--- a/packages/brain/src/runtime/continuation/named-outputs.ts+++ b/packages/brain/src/runtime/continuation/named-outputs.ts@@ -112,11 +112,22 @@ export async function attachNamedOutputs(input: {...touched.filter(named),...touched.filter(unnamedNew),]);+ // One file can arrive under two spellings (Windows case, separators); it is attached once.+ const same = (path: string) =>+ local.deps.platform === "win32" ? resolve(path).toLowerCase() : resolve(path);+ const declared = new Set(+ (input.declared ?? []).map((path) => same(resolve(place?.cwd ?? "", path))),+ );+ const alreadySent = (path: string) => {+ const key = same(path);+ for (const item of sent) if (same(item) === key) return true;+ return false;+ };let overflow: AttachmentOverflow | undefined;for (const candidate of candidates) {signal.throwIfAborted();const path = resolve(place?.cwd ?? "", candidate);- if (sent.has(path)) continue;+ if (alreadySent(path)) continue;const root = place?.boundary.writeRoots.find((entry) => {const part = relative(entry, path);return part && !part.startsWith(`..${sep}`) && part !== ".." && !isAbsolute(part);@@ -145,7 +156,7 @@ export async function attachNamedOutputs(input: {}if (unnamedNew(candidate) &&- !(input.declared ?? []).includes(candidate) &&+ !declared.has(same(path)) &&(recorded.get(path) === "modify" ||recorded.get(path) === "delete" ||(recorded.get(path) !== "add" &&diff --git a/packages/brain/src/runtime/workflows/delivery-reference.ts b/packages/brain/src/runtime/workflows/delivery-reference.tsindex ca7d879..63d823c 100644--- a/packages/brain/src/runtime/workflows/delivery-reference.ts+++ b/packages/brain/src/runtime/workflows/delivery-reference.ts@@ -118,7 +118,12 @@ export async function resolveReference(resolve(folder, path),...aliasPaths.map(({ target }) => target),];- if (path.startsWith(`${basename(root)}/`)) candidates.push(resolve(dirname(root), path));+ // A Windows reply spells the folder-name prefix with `\` as often as with `/`.+ if (+ path.startsWith(`${basename(root)}/`) ||+ (sep === "\\" && path.startsWith(`${basename(root)}\\`))+ )+ candidates.push(resolve(dirname(root), path));for (const candidate of candidates) {if (excluded.has(resolve(candidate))) continue;try {diff --git a/packages/execution/src/managed/file-checkpoint.ts b/packages/execution/src/managed/file-checkpoint.tsindex 03df8aa..ae79d8d 100644--- a/packages/execution/src/managed/file-checkpoint.ts+++ b/packages/execution/src/managed/file-checkpoint.ts@@ -46,9 +46,14 @@ export async function checkpointParents((part, index) =>!part ||part === ".." ||- // Deliverables under `.pibot/out` are user files; the rest of `.pibot` is Pi Bot's.+ // Deliverables under `.pibot/out` are user files; the rest of `.pibot` is Pi Bot's. The+ // exception folds case like the unsafe names do: Windows and macOS spell `.PiBot/Out` too.(unsafe.has(part.toLowerCase()) &&- !(part === ".pibot" && parts[index + 1] === "out" && index + 2 < parts.length)) ||+ !(+ part.toLowerCase() === ".pibot" &&+ parts[index + 1]?.toLowerCase() === "out" &&+ index + 2 < parts.length+ )) ||/^\.env(?:\.|$)/i.test(part),) ||/[\0\r\n]/.test(path)diff --git a/packages/workspaces/src/brain/groups/group-worktree-commit.ts b/packages/workspaces/src/brain/groups/group-worktree-commit.tsindex abcf5a3..224ea87 100644--- a/packages/workspaces/src/brain/groups/group-worktree-commit.ts+++ b/packages/workspaces/src/brain/groups/group-worktree-commit.ts@@ -8,6 +8,7 @@ import {type ManagedGitAuthority,type ManagedGitRepository,} from "@pibot/execution";+import { containsPath } from "@pibot/policy";import { RpcError } from "@pibot/workspaces-contract/full";import { parseStatus } from "../changes/git/changes-git.ts";@@ -65,7 +66,11 @@ export async function commitGroupWorktree(authority.signal.throwIfAborted();if (sensitiveOutputPath(path)) throw new RpcError(-32602, "group_workspace_sensitive_output");const absolute = resolve(repository.root.path, path);- if (!absolute.startsWith(`${repository.root.path}/`))+ // A native resolve() result: a `/` prefix test refused every Windows commit with changes.+ if (+ absolute === repository.root.path ||+ !containsPath(repository.root.path, absolute, local.deps.platform)+ )throw new RpcError(-32602, "group_workspace_sensitive_output");try {const info = await lstat(absolute);