@howarewoo/pi-subagents 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/LICENSE +21 -0
- package/README.md +499 -2
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/docs/advanced-policies.md +78 -0
- package/docs/delegation-contract.md +297 -0
- package/docs/images/subagent-hub.svg +1 -0
- package/docs/images/subagent-profiles.svg +1 -0
- package/docs/images/subagent-widget.svg +1 -0
- package/docs/parity-inventory.md +330 -0
- package/docs/provenance.md +13 -0
- package/docs/releases.md +236 -0
- package/docs/verification.md +430 -0
- package/package.json +64 -4
- package/src/capabilities.ts +39 -0
- package/src/child-execution.ts +459 -0
- package/src/coordinator.ts +1376 -0
- package/src/delegation-types.ts +111 -0
- package/src/hub.ts +612 -0
- package/src/model-adapter.ts +77 -0
- package/src/model-policy.ts +100 -0
- package/src/outcomes.ts +110 -0
- package/src/pi-extended-subagents.ts +673 -0
- package/src/profile-viewer.ts +246 -0
- package/src/profiles.ts +225 -0
- package/src/scheduling.ts +73 -0
- package/src/subagent-widget.ts +115 -0
- package/src/supported-host.ts +26 -0
- package/src/task-input.ts +74 -0
- package/src/task-presentation.ts +165 -0
- package/src/thread.ts +268 -0
- package/src/tool-schemas.ts +165 -0
- package/src/workspace.ts +46 -0
package/src/workspace.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import type { BuiltinTool } from "./profiles.ts";
|
|
4
|
+
|
|
5
|
+
function ordinaryPath(path: string): void {
|
|
6
|
+
if (path.includes("\0") || /^[~@]/.test(path) || /[\u00a0\u202f]/.test(path))
|
|
7
|
+
throw new Error(
|
|
8
|
+
"Workspace paths must use ordinary absolute/relative spelling, not ~, @ or nonbreaking spaces",
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Existing directory only; never allocate, change process cwd, or infer project trust. */
|
|
13
|
+
export function resolveWorkspace(cwd: string | undefined, parentCwd: string): string {
|
|
14
|
+
const root = realpathSync(parentCwd);
|
|
15
|
+
if (cwd === undefined || cwd === parentCwd || cwd === root) return root;
|
|
16
|
+
const path = cwd;
|
|
17
|
+
ordinaryPath(path);
|
|
18
|
+
const directory = realpathSync(resolve(parentCwd, path));
|
|
19
|
+
ordinaryPath(directory);
|
|
20
|
+
if (!statSync(directory).isDirectory())
|
|
21
|
+
throw new Error("Delegation cwd must be an existing directory");
|
|
22
|
+
return directory;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Root hooks see the actual absolute paths/command, not a fictitious child dispatch cwd. */
|
|
26
|
+
export function workspaceArguments(
|
|
27
|
+
name: BuiltinTool,
|
|
28
|
+
args: unknown,
|
|
29
|
+
cwd: string,
|
|
30
|
+
parentCwd: string,
|
|
31
|
+
): unknown {
|
|
32
|
+
if (cwd === realpathSync(parentCwd)) return args;
|
|
33
|
+
if (!args || typeof args !== "object" || Array.isArray(args))
|
|
34
|
+
throw new Error("Expected builtin tool arguments");
|
|
35
|
+
const input = args as Record<string, unknown>;
|
|
36
|
+
if (name === "bash") {
|
|
37
|
+
if (typeof input.command !== "string") throw new Error("Expected a bash command");
|
|
38
|
+
const quoted = "'" + cwd.replaceAll("'", "'\\''") + "'";
|
|
39
|
+
// A failed cd must exit before ANY user command, including a semicolon/OR list.
|
|
40
|
+
return { ...input, command: `cd -- ${quoted} || exit $?\n${input.command}` };
|
|
41
|
+
}
|
|
42
|
+
const path = input.path ?? (["grep", "find", "ls"].includes(name) ? "." : undefined);
|
|
43
|
+
if (typeof path !== "string") throw new Error("Expected a builtin path");
|
|
44
|
+
ordinaryPath(path);
|
|
45
|
+
return { ...input, path: resolve(cwd, path) };
|
|
46
|
+
}
|