@astralyn/pi 1.4.8 → 1.4.10
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 +68 -0
- package/dist/bundle/chunks/{chunk-I2COK45I.js → chunk-6GTUUUCJ.js} +128 -128
- package/dist/bundle/chunks/{chunk-PU2IWWXV.js → chunk-DLVLAQEG.js} +1 -1
- package/dist/bundle/chunks/{chunk-MG5XDTXV.js → chunk-LPF7HQ3S.js} +1 -1
- package/dist/bundle/chunks/{chunk-FODCTZXW.js → chunk-MF3T3ETJ.js} +4 -4
- package/dist/bundle/chunks/{chunk-RO2VH6UZ.js → chunk-R267VV5T.js} +1 -1
- package/dist/bundle/chunks/{chunk-RLNMABLM.js → chunk-RVKT7OUB.js} +1 -1
- package/dist/bundle/chunks/{chunk-5VIOGR76.js → chunk-UCH27AVQ.js} +1 -1
- package/dist/bundle/chunks/{cli-MEL7SGJD.js → cli-MBFCFGI2.js} +1 -1
- package/dist/bundle/chunks/{execute-4CWRNHPO.js → execute-FQKRO4XJ.js} +1 -1
- package/dist/bundle/chunks/{runtime-R3X67XMR.js → runtime-3RPOJS5T.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-BBLD7YLS.js → virtual-modules-6IJ6V2CG.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +34 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +99 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/isolated-session.d.ts +7 -2
- package/dist/core/isolated-session.d.ts.map +1 -1
- package/dist/core/isolated-session.js +7 -3
- package/dist/core/isolated-session.js.map +1 -1
- package/dist/core/session-manager.d.ts +17 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +29 -0
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/tasks/delivery.d.ts +42 -7
- package/dist/core/tasks/delivery.d.ts.map +1 -1
- package/dist/core/tasks/delivery.js +129 -15
- package/dist/core/tasks/delivery.js.map +1 -1
- package/dist/core/tasks/execution.d.ts +27 -14
- package/dist/core/tasks/execution.d.ts.map +1 -1
- package/dist/core/tasks/execution.js +90 -86
- package/dist/core/tasks/execution.js.map +1 -1
- package/dist/core/tasks/limits.d.ts +13 -1
- package/dist/core/tasks/limits.d.ts.map +1 -1
- package/dist/core/tasks/limits.js +14 -1
- package/dist/core/tasks/limits.js.map +1 -1
- package/dist/core/tasks/output.d.ts +9 -1
- package/dist/core/tasks/output.d.ts.map +1 -1
- package/dist/core/tasks/output.js +23 -10
- package/dist/core/tasks/output.js.map +1 -1
- package/dist/core/tasks/presentation.d.ts +1 -1
- package/dist/core/tasks/presentation.d.ts.map +1 -1
- package/dist/core/tasks/presentation.js +6 -4
- package/dist/core/tasks/presentation.js.map +1 -1
- package/dist/core/tasks/record.d.ts +41 -29
- package/dist/core/tasks/record.d.ts.map +1 -1
- package/dist/core/tasks/record.js +82 -37
- package/dist/core/tasks/record.js.map +1 -1
- package/dist/core/tasks/reminder.js +2 -2
- package/dist/core/tasks/reminder.js.map +1 -1
- package/dist/core/tasks/runtime.d.ts +17 -14
- package/dist/core/tasks/runtime.d.ts.map +1 -1
- package/dist/core/tasks/runtime.js +68 -116
- package/dist/core/tasks/runtime.js.map +1 -1
- package/dist/core/tasks/scheduler.d.ts +3 -1
- package/dist/core/tasks/scheduler.d.ts.map +1 -1
- package/dist/core/tasks/scheduler.js +16 -12
- package/dist/core/tasks/scheduler.js.map +1 -1
- package/dist/core/tasks/session.d.ts +24 -3
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +73 -9
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tasks/store.d.ts +17 -4
- package/dist/core/tasks/store.d.ts.map +1 -1
- package/dist/core/tasks/store.js +45 -48
- package/dist/core/tasks/store.js.map +1 -1
- package/dist/core/tasks/types.d.ts +72 -29
- package/dist/core/tasks/types.d.ts.map +1 -1
- package/dist/core/tasks/types.js +7 -0
- package/dist/core/tasks/types.js.map +1 -1
- package/dist/core/tasks/wait.d.ts +19 -0
- package/dist/core/tasks/wait.d.ts.map +1 -0
- package/dist/core/tasks/wait.js +45 -0
- package/dist/core/tasks/wait.js.map +1 -0
- package/dist/core/tools/shell-execution.d.ts.map +1 -1
- package/dist/core/tools/shell-execution.js +2 -1
- package/dist/core/tools/shell-execution.js.map +1 -1
- package/dist/core/tools/shell-tool.d.ts.map +1 -1
- package/dist/core/tools/shell-tool.js +20 -13
- package/dist/core/tools/shell-tool.js.map +1 -1
- package/dist/extensions/agent/activity-lines.d.ts +10 -0
- package/dist/extensions/agent/activity-lines.d.ts.map +1 -0
- package/dist/extensions/agent/activity-lines.js +76 -0
- package/dist/extensions/agent/activity-lines.js.map +1 -0
- package/dist/extensions/agent/activity.d.ts +25 -4
- package/dist/extensions/agent/activity.d.ts.map +1 -1
- package/dist/extensions/agent/activity.js +76 -21
- package/dist/extensions/agent/activity.js.map +1 -1
- package/dist/extensions/agent/artifacts.d.ts +15 -0
- package/dist/extensions/agent/artifacts.d.ts.map +1 -0
- package/dist/extensions/agent/artifacts.js +44 -0
- package/dist/extensions/agent/artifacts.js.map +1 -0
- package/dist/extensions/agent/progress.d.ts +30 -4
- package/dist/extensions/agent/progress.d.ts.map +1 -1
- package/dist/extensions/agent/progress.js +84 -11
- package/dist/extensions/agent/progress.js.map +1 -1
- package/dist/extensions/agent/render.d.ts.map +1 -1
- package/dist/extensions/agent/render.js +8 -24
- package/dist/extensions/agent/render.js.map +1 -1
- package/dist/extensions/agent/report.d.ts +11 -3
- package/dist/extensions/agent/report.d.ts.map +1 -1
- package/dist/extensions/agent/report.js +32 -7
- package/dist/extensions/agent/report.js.map +1 -1
- package/dist/extensions/agent/tool.d.ts.map +1 -1
- package/dist/extensions/agent/tool.js +20 -5
- package/dist/extensions/agent/tool.js.map +1 -1
- package/dist/extensions/agent/types.d.ts +2 -0
- package/dist/extensions/agent/types.d.ts.map +1 -1
- package/dist/extensions/agent/types.js.map +1 -1
- package/dist/extensions/agent/worker.d.ts +7 -0
- package/dist/extensions/agent/worker.d.ts.map +1 -1
- package/dist/extensions/agent/worker.js +9 -3
- package/dist/extensions/agent/worker.js.map +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/search/index.d.ts.map +1 -1
- package/dist/extensions/search/index.js +6 -7
- package/dist/extensions/search/index.js.map +1 -1
- package/dist/extensions/shell-paths/index.d.ts +8 -0
- package/dist/extensions/shell-paths/index.d.ts.map +1 -0
- package/dist/extensions/shell-paths/index.js +74 -0
- package/dist/extensions/shell-paths/index.js.map +1 -0
- package/dist/extensions/tasks/tool/actions.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/actions.js +15 -11
- package/dist/extensions/tasks/tool/actions.js.map +1 -1
- package/dist/extensions/tasks/tool/schema.d.ts +1 -1
- package/dist/extensions/tasks/tool/schema.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/schema.js +5 -5
- package/dist/extensions/tasks/tool/schema.js.map +1 -1
- package/dist/extensions/tasks/tool/types.d.ts +2 -0
- package/dist/extensions/tasks/tool/types.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/types.js.map +1 -1
- package/dist/extensions/tasks/tool.d.ts.map +1 -1
- package/dist/extensions/tasks/tool.js +3 -2
- package/dist/extensions/tasks/tool.js.map +1 -1
- package/dist/extensions/tasks/ui/completion-render.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/completion-render.js +2 -2
- package/dist/extensions/tasks/ui/completion-render.js.map +1 -1
- package/dist/extensions/tasks/ui/footer.d.ts +37 -0
- package/dist/extensions/tasks/ui/footer.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/footer.js +129 -0
- package/dist/extensions/tasks/ui/footer.js.map +1 -0
- package/dist/extensions/tasks/ui/frame.d.ts +36 -0
- package/dist/extensions/tasks/ui/frame.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/frame.js +33 -0
- package/dist/extensions/tasks/ui/frame.js.map +1 -0
- package/dist/extensions/tasks/ui/help.d.ts +6 -0
- package/dist/extensions/tasks/ui/help.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/help.js +53 -0
- package/dist/extensions/tasks/ui/help.js.map +1 -0
- package/dist/extensions/tasks/ui/inspector.d.ts +4 -3
- package/dist/extensions/tasks/ui/inspector.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/inspector.js +25 -6
- package/dist/extensions/tasks/ui/inspector.js.map +1 -1
- package/dist/extensions/tasks/ui/layout.d.ts +15 -18
- package/dist/extensions/tasks/ui/layout.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/layout.js +162 -255
- package/dist/extensions/tasks/ui/layout.js.map +1 -1
- package/dist/extensions/tasks/ui/list.d.ts +3 -1
- package/dist/extensions/tasks/ui/list.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/list.js +19 -14
- package/dist/extensions/tasks/ui/list.js.map +1 -1
- package/dist/extensions/tasks/ui/manager.d.ts +17 -5
- package/dist/extensions/tasks/ui/manager.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/manager.js +147 -90
- package/dist/extensions/tasks/ui/manager.js.map +1 -1
- package/dist/extensions/tasks/ui/model.d.ts +32 -5
- package/dist/extensions/tasks/ui/model.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/model.js +7 -7
- package/dist/extensions/tasks/ui/model.js.map +1 -1
- package/dist/extensions/tasks/ui/panes.d.ts +40 -0
- package/dist/extensions/tasks/ui/panes.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/panes.js +144 -0
- package/dist/extensions/tasks/ui/panes.js.map +1 -0
- package/dist/extensions/tasks/ui/render.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/render.js +11 -7
- package/dist/extensions/tasks/ui/render.js.map +1 -1
- package/dist/extensions/tasks/ui/viewport.d.ts +12 -4
- package/dist/extensions/tasks/ui/viewport.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/viewport.js +23 -7
- package/dist/extensions/tasks/ui/viewport.js.map +1 -1
- package/dist/extensions/tasks/ui/views.d.ts +12 -6
- package/dist/extensions/tasks/ui/views.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/views.js +39 -32
- package/dist/extensions/tasks/ui/views.js.map +1 -1
- package/dist/modes/interactive/chat-viewport.d.ts +5 -2
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -1
- package/dist/modes/interactive/chat-viewport.js +72 -12
- package/dist/modes/interactive/chat-viewport.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +11 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +43 -17
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/sticky-user-message.d.ts +23 -0
- package/dist/modes/interactive/components/sticky-user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/sticky-user-message.js +58 -0
- package/dist/modes/interactive/components/sticky-user-message.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +51 -10
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +4 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tool-view/chat.d.ts +3 -2
- package/dist/modes/interactive/tool-view/chat.d.ts.map +1 -1
- package/dist/modes/interactive/tool-view/chat.js +3 -3
- package/dist/modes/interactive/tool-view/chat.js.map +1 -1
- package/dist/modes/interactive/transcript-layout.d.ts +23 -0
- package/dist/modes/interactive/transcript-layout.d.ts.map +1 -0
- package/dist/modes/interactive/transcript-layout.js +29 -0
- package/dist/modes/interactive/transcript-layout.js.map +1 -0
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +37 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +11 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +48 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/bundled/README.md +1 -0
- package/docs/bundled/extensions/agent.md +39 -7
- package/docs/bundled/extensions/shell-paths.md +17 -0
- package/docs/bundled/tasks.md +25 -21
- package/docs/docs.json +4 -0
- package/docs/extensions.md +14 -10
- package/docs/json.md +3 -0
- package/docs/rpc.md +14 -0
- package/docs/sdk.md +11 -1
- package/docs/session-format.md +10 -4
- package/docs/sessions.md +1 -1
- package/docs/usage.md +3 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -17,6 +17,8 @@ export interface AgentActivity {
|
|
|
17
17
|
/** Short display label derived from the original arguments; args remains the full bounded form. */
|
|
18
18
|
target?: string;
|
|
19
19
|
status: AgentActivityStatus;
|
|
20
|
+
/** Epoch milliseconds when the call began, so a running call can show its elapsed time. */
|
|
21
|
+
startedAt?: number;
|
|
20
22
|
durationMs?: number;
|
|
21
23
|
error?: string;
|
|
22
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extensions/agent/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,eAAO,MAAM,wB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 -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extensions/agent/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { TaskTerminalStatus } from \"../../core/tasks/types.ts\";\n\nexport const AGENT_SETTINGS_NAMESPACE = \"agent\";\nexport const AGENT_PROMPT_BYTES = 16 * 1024;\nexport const AGENT_REPORT_BYTES = 24 * 1024;\nexport const AGENT_MAX_ACTIVITIES = 50;\nexport const AGENT_CONCURRENCY = 4;\n\nexport interface AgentSettings {\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n}\n\nexport type AgentActivityStatus = \"running\" | \"ok\" | \"error\" | \"cancelled\";\n\nexport interface AgentActivity {\n\tid: string;\n\tname: string;\n\targs: string;\n\t/** Short display label derived from the original arguments; args remains the full bounded form. */\n\ttarget?: string;\n\tstatus: AgentActivityStatus;\n\tdurationMs?: number;\n\terror?: string;\n}\n\n/**\n * Agent tool-result details. Only progress updates carry activities; the persisted result\n * keeps the transcript row's facts, and the full history lives in the task's Output.\n */\nexport type AgentToolDetails =\n\t| { version: 2; state: \"running\"; taskId: string; activities: AgentActivity[] }\n\t| { version: 2; state: \"background\"; taskId: string; byUser: boolean }\n\t| { version: 2; state: TaskTerminalStatus; taskId: string; error?: string };\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extensions/agent/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { TaskTerminalStatus } from \"../../core/tasks/types.ts\";\n\nexport const AGENT_SETTINGS_NAMESPACE = \"agent\";\nexport const AGENT_PROMPT_BYTES = 16 * 1024;\nexport const AGENT_REPORT_BYTES = 24 * 1024;\nexport const AGENT_MAX_ACTIVITIES = 50;\nexport const AGENT_CONCURRENCY = 4;\n\nexport interface AgentSettings {\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n}\n\nexport type AgentActivityStatus = \"running\" | \"ok\" | \"error\" | \"cancelled\";\n\nexport interface AgentActivity {\n\tid: string;\n\tname: string;\n\targs: string;\n\t/** Short display label derived from the original arguments; args remains the full bounded form. */\n\ttarget?: string;\n\tstatus: AgentActivityStatus;\n\t/** Epoch milliseconds when the call began, so a running call can show its elapsed time. */\n\tstartedAt?: number;\n\tdurationMs?: number;\n\terror?: string;\n}\n\n/**\n * Agent tool-result details. Only progress updates carry activities; the persisted result\n * keeps the transcript row's facts, and the full history lives in the task's Output.\n */\nexport type AgentToolDetails =\n\t| { version: 2; state: \"running\"; taskId: string; activities: AgentActivity[] }\n\t| { version: 2; state: \"background\"; taskId: string; byUser: boolean }\n\t| { version: 2; state: TaskTerminalStatus; taskId: string; error?: string };\n"]}
|
|
@@ -2,6 +2,7 @@ import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
|
2
2
|
import type { Model } from "@earendil-works/pi-ai/compat";
|
|
3
3
|
import type { ModelRuntime } from "../../core/model-runtime.ts";
|
|
4
4
|
import type { TaskCompletion, TaskControl } from "../../core/tasks/types.ts";
|
|
5
|
+
import { AgentProgress } from "./progress.ts";
|
|
5
6
|
import type { AgentToolDetails } from "./types.ts";
|
|
6
7
|
export interface AgentRequest {
|
|
7
8
|
prompt: string;
|
|
@@ -10,6 +11,12 @@ export interface AgentRequest {
|
|
|
10
11
|
thinking: ThinkingLevel;
|
|
11
12
|
modelRuntime: ModelRuntime;
|
|
12
13
|
projectTrusted: boolean;
|
|
14
|
+
/** The launching session's artifacts directory; without one (unsaved session) nothing is kept. */
|
|
15
|
+
sessionArtifactDir?: string;
|
|
16
|
+
/** The launching session file, recorded as the transcript's parent. */
|
|
17
|
+
parentSession?: string;
|
|
18
|
+
/** Receives the run's progress as soon as it exists, so a caller can render it live. */
|
|
19
|
+
onProgress?: (progress: AgentProgress) => void;
|
|
13
20
|
}
|
|
14
21
|
/** Run one delegated task in an isolated session and settle it with a self-contained report. */
|
|
15
22
|
export declare function runWorker(control: TaskControl<AgentToolDetails>, request: AgentRequest): Promise<TaskCompletion<AgentToolDetails>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/extensions/agent/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/extensions/agent/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7E,OAAO,EAAE,aAAa,EAAsB,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAInD,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,QAAQ,EAAE,aAAa,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,kGAAkG;IAClG,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wFAAwF;IACxF,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;CAC/C;AAaD,gGAAgG;AAChG,wBAAsB,SAAS,CAC9B,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,EACtC,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAkD3C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createIsolatedSession } from "../../core/isolated-session.js";
|
|
2
2
|
import { clipText } from "./activity.js";
|
|
3
|
+
import { prepareArtifacts } from "./artifacts.js";
|
|
3
4
|
import { AgentProgress, finalAssistantText } from "./progress.js";
|
|
4
5
|
import { finalReport } from "./report.js";
|
|
5
6
|
const WORKER_TOOLS = ["read", "bash", "edit", "write"];
|
|
@@ -16,14 +17,17 @@ function workerPrompt(base) {
|
|
|
16
17
|
/** Run one delegated task in an isolated session and settle it with a self-contained report. */
|
|
17
18
|
export async function runWorker(control, request) {
|
|
18
19
|
const { signal } = control;
|
|
19
|
-
const progress = new AgentProgress(control);
|
|
20
|
+
const progress = new AgentProgress(control, request.cwd);
|
|
21
|
+
request.onProgress?.(progress);
|
|
20
22
|
let session;
|
|
21
23
|
let unsubscribe;
|
|
24
|
+
let artifacts;
|
|
22
25
|
const abort = () => {
|
|
23
26
|
void session?.abort().catch(() => { });
|
|
24
27
|
};
|
|
25
28
|
signal.addEventListener("abort", abort, { once: true });
|
|
26
29
|
try {
|
|
30
|
+
artifacts = await prepareArtifacts(request.sessionArtifactDir, control.id, request.parentSession);
|
|
27
31
|
session = await createIsolatedSession({
|
|
28
32
|
cwd: request.cwd,
|
|
29
33
|
model: request.model,
|
|
@@ -32,6 +36,7 @@ export async function runWorker(control, request) {
|
|
|
32
36
|
projectTrusted: request.projectTrusted,
|
|
33
37
|
systemPrompt: workerPrompt,
|
|
34
38
|
tools: WORKER_TOOLS,
|
|
39
|
+
transcript: artifacts && { path: artifacts.transcriptPath, parentSession: artifacts.parentSession },
|
|
35
40
|
signal,
|
|
36
41
|
});
|
|
37
42
|
const worker = session;
|
|
@@ -47,7 +52,8 @@ export async function runWorker(control, request) {
|
|
|
47
52
|
signal.throwIfAborted();
|
|
48
53
|
await worker.prompt(request.prompt, { expandPromptTemplates: false });
|
|
49
54
|
const { status, error } = progress.outcome();
|
|
50
|
-
|
|
55
|
+
const report = await finalReport(control, finalAssistantText(worker.messages), error, artifacts);
|
|
56
|
+
return progress.complete(status, error, report, artifacts);
|
|
51
57
|
}
|
|
52
58
|
catch (error) {
|
|
53
59
|
const status = signal.aborted ? "cancelled" : "failed";
|
|
@@ -55,7 +61,7 @@ export async function runWorker(control, request) {
|
|
|
55
61
|
? "Agent cancelled."
|
|
56
62
|
: clipText(error instanceof Error ? error.message : String(error), 4096);
|
|
57
63
|
const report = session ? finalAssistantText(session.messages) : "";
|
|
58
|
-
return progress.complete(status, reason, await finalReport(control, report, reason));
|
|
64
|
+
return progress.complete(status, reason, await finalReport(control, report, reason, artifacts), artifacts);
|
|
59
65
|
}
|
|
60
66
|
finally {
|
|
61
67
|
signal.removeEventListener("abort", abort);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/extensions/agent/worker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/extensions/agent/worker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAuB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAiBvD,SAAS,YAAY,CAAC,IAAwB;IAC7C,OAAO;QACN,IAAI;QACJ,0VAA0V;QAC1V,ygBAAygB;QACzgB,0VAA0V;KAC1V;SACC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;SACvD,IAAI,CAAC,MAAM,CAAC,CAAC;AAChB,CAAC;AAED,gGAAgG;AAChG,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,OAAsC,EACtC,OAAqB;IAErB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,QAAQ,GAAG,IAAI,aAA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O,EAAE,KAAK,CAAC,CAAC;QAC3C,WAAW,EAAE,EAAE,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,CAAC;IACpB,CAAC;AACF,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Model } from \"@earendil-works/pi-ai/compat\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport { createIsolatedSession } from \"../../core/isolated-session.ts\";\nimport type { ModelRuntime } from \"../../core/model-runtime.ts\";\nimport type { TaskCompletion, TaskControl } from \"../../core/tasks/types.ts\";\nimport { clipText } from \"./activity.ts\";\nimport { type AgentArtifacts, prepareArtifacts } from \"./artifacts.ts\";\nimport { AgentProgress, finalAssistantText } from \"./progress.ts\";\nimport { finalReport } from \"./report.ts\";\nimport type { AgentToolDetails } from \"./types.ts\";\n\nconst WORKER_TOOLS = [\"read\", \"bash\", \"edit\", \"write\"];\n\nexport interface AgentRequest {\n\tprompt: string;\n\tcwd: string;\n\tmodel: Model<any>;\n\tthinking: ThinkingLevel;\n\tmodelRuntime: ModelRuntime;\n\tprojectTrusted: boolean;\n\t/** The launching session's artifacts directory; without one (unsaved session) nothing is kept. */\n\tsessionArtifactDir?: string;\n\t/** The launching session file, recorded as the transcript's parent. */\n\tparentSession?: string;\n\t/** Receives the run's progress as soon as it exists, so a caller can render it live. */\n\tonProgress?: (progress: AgentProgress) => void;\n}\n\nfunction workerPrompt(base: string | undefined): string {\n\treturn [\n\t\tbase,\n\t\t\"You are an Agent completing one delegated task in an isolated session. The first user message is the complete briefing from your caller. You cannot see the caller's conversation or ask it questions. If the briefing is ambiguous, choose a reasonable interpretation within scope and report it; stop only when ambiguity blocks meaningful progress.\",\n\t\t\"Use the assigned working directory and stay within the requested scope. Complete the task fully without expanding it. If the briefing asks only for investigation, do not modify files. Use read for known paths and bash for discovery, search, and shell commands. Prefer editing existing files; create new files only when the task requires them, and never create documentation or report files unless explicitly requested. Do not delegate or start background work. Run required commands in the foreground and wait for them.\",\n\t\t\"Your final message is the only output returned to the caller. Lead with the outcome, then include essential findings, files changed if any, verification actually run and its result, and blockers or remaining risks. Cite workspace-relative paths with line numbers when useful. Respect any length limit in the briefing and omit process narration.\",\n\t]\n\t\t.filter((part): part is string => Boolean(part?.trim()))\n\t\t.join(\"\\n\\n\");\n}\n\n/** Run one delegated task in an isolated session and settle it with a self-contained report. */\nexport async function runWorker(\n\tcontrol: TaskControl<AgentToolDetails>,\n\trequest: AgentRequest,\n): Promise<TaskCompletion<AgentToolDetails>> {\n\tconst { signal } = control;\n\tconst progress = new AgentProgress(control, request.cwd);\n\trequest.onProgress?.(progress);\n\tlet session: AgentSession | undefined;\n\tlet unsubscribe: (() => void) | undefined;\n\tlet artifacts: AgentArtifacts | undefined;\n\tconst abort = () => {\n\t\tvoid session?.abort().catch(() => {});\n\t};\n\tsignal.addEventListener(\"abort\", abort, { once: true });\n\ttry {\n\t\tartifacts = await prepareArtifacts(request.sessionArtifactDir, control.id, request.parentSession);\n\t\tsession = await createIsolatedSession({\n\t\t\tcwd: request.cwd,\n\t\t\tmodel: request.model,\n\t\t\tthinkingLevel: request.thinking,\n\t\t\tmodelRuntime: request.modelRuntime,\n\t\t\tprojectTrusted: request.projectTrusted,\n\t\t\tsystemPrompt: workerPrompt,\n\t\t\ttools: WORKER_TOOLS,\n\t\t\ttranscript: artifacts && { path: artifacts.transcriptPath, parentSession: artifacts.parentSession },\n\t\t\tsignal,\n\t\t});\n\t\tconst worker = session;\n\t\tunsubscribe = worker.subscribe((event) => {\n\t\t\t// Cancellation during prompt preflight can precede the run's own abort controller.\n\t\t\tif (event.type === \"agent_start\" && signal.aborted) abort();\n\t\t\telse progress.handle(event);\n\t\t});\n\t\tprogress.publish();\n\t\tcontrol.accept();\n\t\tsignal.throwIfAborted();\n\t\tawait worker.prompt(request.prompt, { expandPromptTemplates: false });\n\t\tconst { status, error } = progress.outcome();\n\t\tconst report = await finalReport(control, finalAssistantText(worker.messages), error, artifacts);\n\t\treturn progress.complete(status, error, report, artifacts);\n\t} catch (error) {\n\t\tconst status = signal.aborted ? \"cancelled\" : \"failed\";\n\t\tconst reason =\n\t\t\tstatus === \"cancelled\"\n\t\t\t\t? \"Agent cancelled.\"\n\t\t\t\t: clipText(error instanceof Error ? error.message : String(error), 4096);\n\t\tconst report = session ? finalAssistantText(session.messages) : \"\";\n\t\treturn progress.complete(status, reason, await finalReport(control, report, reason, artifacts), artifacts);\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", abort);\n\t\tunsubscribe?.();\n\t\tsession?.dispose();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAkBnE,eAAO,MAAM,iBAAiB,EAAE,eAAe,EAiB9C,CAAC"}
|
package/dist/extensions/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import providerExtension from "./provider/index.js";
|
|
|
10
10
|
import questionExtension from "./question/index.js";
|
|
11
11
|
import runSummaryExtension from "./run-summary/index.js";
|
|
12
12
|
import searchExtension from "./search/index.js";
|
|
13
|
+
import shellPathsExtension from "./shell-paths/index.js";
|
|
13
14
|
import statuslineExtension from "./statusline/index.js";
|
|
14
15
|
import tasksExtension from "./tasks/index.js";
|
|
15
16
|
import toolPresentationExtension from "./tool-presentation/index.js";
|
|
@@ -30,5 +31,6 @@ export const builtInExtensions = [
|
|
|
30
31
|
{ name: "tool-presentation", factory: toolPresentationExtension, builtin: true },
|
|
31
32
|
{ name: "tasks", factory: tasksExtension, replaceable: true, builtin: true },
|
|
32
33
|
{ name: "search", factory: searchExtension, builtin: true },
|
|
34
|
+
{ name: "shell-paths", factory: shellPathsExtension, builtin: true },
|
|
33
35
|
];
|
|
34
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,yBAAyB,MAAM,8BAA8B,CAAC;AACrE,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,yBAAyB,MAAM,8BAA8B,CAAC;AACrE,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IACnD,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5E,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAClF,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACxE,E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AI,EAAE;IACnG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7D,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACvF,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE;IACnE,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,IAAI,EAAE;IAChF,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5E,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE;IAC3D,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE;CACpE,CAAC","sourcesContent":["import \"./keybindings.ts\";\nimport type { InlineExtension } from \"../core/extensions/types.ts\";\nimport agentExtension from \"./agent/index.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport cachedCompactionExtension from \"./cached-compaction/index.ts\";\nimport codemodeExtension from \"./codemode/index.ts\";\nimport deepwikiExtension from \"./deepwiki/index.ts\";\nimport llamaExtension from \"./llama/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport providerExtension from \"./provider/index.ts\";\nimport questionExtension from \"./question/index.ts\";\nimport runSummaryExtension from \"./run-summary/index.ts\";\nimport searchExtension from \"./search/index.ts\";\nimport shellPathsExtension from \"./shell-paths/index.ts\";\nimport statuslineExtension from \"./statusline/index.ts\";\nimport tasksExtension from \"./tasks/index.ts\";\nimport toolPresentationExtension from \"./tool-presentation/index.ts\";\nimport toolSearchExtension from \"./tool-search/index.ts\";\n\nexport const builtInExtensions: InlineExtension[] = [\n\t{ name: \"Agent\", factory: agentExtension, replaceable: true, builtin: true },\n\t{ name: \"codemode\", factory: codemodeExtension, replaceable: true, builtin: true },\n\t{ name: \"mcp\", factory: mcpExtension, replaceable: true, builtin: true },\n\t{ name: \"tool-search\", factory: toolSearchExtension, replaceable: true, builtin: true },\n\t{ name: \"cached-compaction\", factory: cachedCompactionExtension, replaceable: true, builtin: true },\n\t{ name: \"llama.cpp\", factory: llamaExtension, builtin: true },\n\t{ name: \"btw\", factory: btwExtension, builtin: true },\n\t{ name: \"deepwiki\", factory: deepwikiExtension, builtin: true },\n\t{ name: \"provider\", factory: providerExtension, builtin: true },\n\t{ name: \"question\", factory: questionExtension, builtin: true },\n\t{ name: \"run-summary\", factory: runSummaryExtension, replaceable: true, builtin: true },\n\t{ name: \"statusline\", factory: statuslineExtension, builtin: true },\n\t{ name: \"tool-presentation\", factory: toolPresentationExtension, builtin: true },\n\t{ name: \"tasks\", factory: tasksExtension, replaceable: true, builtin: true },\n\t{ name: \"search\", factory: searchExtension, builtin: true },\n\t{ name: \"shell-paths\", factory: shellPathsExtension, builtin: true },\n];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/search/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAKnE,OAAO,EAAkB,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AA8CvE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAW5E;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/search/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAKnE,OAAO,EAAkB,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AA8CvE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAW5E;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CA6DrD"}
|
|
@@ -16,10 +16,10 @@ import { isInside } from "./workspace.js";
|
|
|
16
16
|
const WEB_EXCERPT_MAX_CHARS = 1500;
|
|
17
17
|
const CodeSearchParams = Type.Object({
|
|
18
18
|
query: Type.String({
|
|
19
|
-
description: "
|
|
19
|
+
description: "One behavior, flow, or error to locate, in concise English. Keep identifiers and error text verbatim. Not for a bare symbol, filename, or literal.",
|
|
20
20
|
}),
|
|
21
21
|
path: Type.Optional(Type.String({
|
|
22
|
-
description: "Subdirectory
|
|
22
|
+
description: "Subdirectory inside the working directory; set it when you know the subsystem. Defaults to the working directory.",
|
|
23
23
|
})),
|
|
24
24
|
});
|
|
25
25
|
const WebSearchParams = Type.Object({
|
|
@@ -58,12 +58,11 @@ export default function search(pi) {
|
|
|
58
58
|
pi.registerTool({
|
|
59
59
|
name: "code_search",
|
|
60
60
|
label: "Code Search",
|
|
61
|
-
description: "
|
|
62
|
-
|
|
63
|
-
promptSnippet: "Find code by describing its behavior",
|
|
61
|
+
description: "Locate code from a plain-language description of a behavior, flow, or error. Returns up to 10 candidate files with line ranges, not every match.",
|
|
62
|
+
promptSnippet: "Describe a behavior and receive candidate files with line ranges",
|
|
64
63
|
promptGuidelines: [
|
|
65
|
-
"Use `code_search`
|
|
66
|
-
"
|
|
64
|
+
"Use `code_search` primarily to orient in unfamiliar code: where a behavior or error is handled, or how a flow crosses files. When you can name the file, symbol, or literal, search for it directly.",
|
|
65
|
+
"Treat `code_search` results as a reading list; grep identifiers found there when you need every occurrence, such as all call sites.",
|
|
67
66
|
],
|
|
68
67
|
parameters: CodeSearchParams,
|
|
69
68
|
renderCall: renderCodeSearchCall,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/search/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,GAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EACV,yMAAyM;KAC1M,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,IAA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O,GAAG,MAAM,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YACvG,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;gBACnE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;aACvE,CAAC;QACH,CAAC;KACD,CAAC,CAAC;IAEH,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAC1B,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\n * Devin Search: `code_search` and `web_search`, both authenticated by one Devin sign-in.\n *\n * Both tools stay registered so `/tools` and old transcripts know them; a session without a\n * credential starts with them inactive, and signing in or out through `/search` toggles them.\n */\nimport { resolve } from \"node:path\";\nimport { type Static, Type } from \"typebox\";\nimport type { ExtensionAPI } from \"../../core/extensions/types.ts\";\nimport { truncateHead } from \"../../core/tools/truncate.ts\";\nimport { codeSearch, formatLocations } from \"./code-search.ts\";\nimport { registerSearchCommand, syncTools } from \"./command.ts\";\nimport { getCredential } from \"./credential.ts\";\nimport { DevinAuthError, type WebResult, webSearch } from \"./devin.ts\";\nimport {\n\ttype CodeSearchDetails,\n\trenderCodeSearchCall,\n\trenderCodeSearchResult,\n\trenderWebSearchCall,\n\trenderWebSearchResult,\n\ttype WebSearchDetails,\n} from \"./render.ts\";\nimport { isInside } from \"./workspace.ts\";\n\nconst WEB_EXCERPT_MAX_CHARS = 1500;\n\nconst CodeSearchParams = Type.Object({\n\tquery: Type.String({\n\t\tdescription:\n\t\t\t\"Natural-language description of the behavior, flow, error, or concept to locate, in concise English. Keep identifiers, API names, and error text verbatim. Not for a bare symbol, filename, or literal.\",\n\t}),\n\tpath: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Subdirectory to search, relative to or inside the working directory. Defaults to the working directory.\",\n\t\t}),\n\t),\n});\n\nconst WebSearchParams = Type.Object({\n\tquery: Type.String({\n\t\tdescription: \"Web search query. Be specific: product names, versions, exact error text. English matches best.\",\n\t}),\n\tmax_results: Type.Optional(Type.Integer({ minimum: 1, maximum: 10, description: \"Results to return (default 5).\" })),\n});\n\nconst SIGN_IN_HINT = \"Ask the user to run /search to sign in to Devin.\";\n\n/** Run a Devin call with the current credential; credential failures tell the model what fixes them. */\nasync function withDevin<T>(run: (apiKey: string) => Promise<T>): Promise<T> {\n\tconst credential = getCredential();\n\tif (!credential) throw new Error(`Devin Search is not signed in. ${SIGN_IN_HINT}`);\n\ttry {\n\t\treturn await run(credential.apiKey);\n\t} catch (error) {\n\t\tthrow error instanceof DevinAuthError ? new Error(`${error.message} ${SIGN_IN_HINT}`) : error;\n\t}\n}\n\nexport function formatWebResults(query: string, results: WebResult[]): string {\n\tif (!results.length) return `No web results for \"${query}\".`;\n\tconst blocks = results.map((r, i) => {\n\t\tconst lines = [`${i + 1}. ${r.title ?? r.url}`, ` ${r.url}`];\n\t\tif (r.summary) {\n\t\t\tconst excerpt = r.summary.replace(/\\n\\s*\\n+/g, \"\\n\").trim();\n\t\t\tlines.push(excerpt.length > WEB_EXCERPT_MAX_CHARS ? `${excerpt.slice(0, WEB_EXCERPT_MAX_CHARS)}…` : excerpt);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t});\n\treturn truncateHead(`Web results for \"${query}\":\\n\\n${blocks.join(\"\\n\\n\")}`).content;\n}\n\nexport default function search(pi: ExtensionAPI): void {\n\tpi.registerTool<typeof CodeSearchParams, CodeSearchDetails>({\n\t\tname: \"code_search\",\n\t\tlabel: \"Code Search\",\n\t\tdescription:\n\t\t\t\"Find where behavior lives in the local repository from a description of it. \" +\n\t\t\t\"Returns candidate files with line ranges.\",\n\t\tpromptSnippet: \"Find code by describing its behavior\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use `code_search` when you cannot name the file or symbol you need; use `read`, `grep`, or `find` when you can.\",\n\t\t\t\"Read the returned ranges before editing; the locations are candidates, not answers.\",\n\t\t],\n\t\tparameters: CodeSearchParams,\n\t\trenderCall: renderCodeSearchCall,\n\t\trenderResult: renderCodeSearchResult,\n\n\t\tasync execute(_toolCallId, params: Static<typeof CodeSearchParams>, signal, onUpdate, ctx) {\n\t\t\tconst root = resolve(ctx.cwd, params.path ?? \".\");\n\t\t\tif (!isInside(ctx.cwd, root)) throw new Error(`path must be inside the working directory (${ctx.cwd}).`);\n\t\t\tconst locations = await withDevin((apiKey) =>\n\t\t\t\tcodeSearch({\n\t\t\t\t\tapiKey,\n\t\t\t\t\tquery: params.query.trim(),\n\t\t\t\t\troot,\n\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\tsignal,\n\t\t\t\t\tonProgress: (text) => onUpdate?.({ content: [{ type: \"text\", text }], details: { locations: [] } }),\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn { content: [{ type: \"text\", text: formatLocations(locations) }], details: { locations } };\n\t\t},\n\t});\n\n\t// Pi's system prompt carries no date, so models otherwise search with their training year.\n\tconst currentMonth = new Date().toLocaleDateString(\"en-US\", { month: \"long\", year: \"numeric\" });\n\tpi.registerTool<typeof WebSearchParams, WebSearchDetails>({\n\t\tname: \"web_search\",\n\t\tlabel: \"Web Search\",\n\t\tdescription:\n\t\t\t\"Search the live web for current information. Returns titles, URLs, and the page excerpts that match the query.\",\n\t\tpromptSnippet: \"Search the live web for current information\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use `web_search` for information beyond your knowledge cutoff.\",\n\t\t\t`It is ${currentMonth}; put this year in \\`web_search\\` queries for recent releases, versions, or events, not the year your training data suggests.`,\n\t\t\t\"When an answer relies on `web_search` results, cite each result you used as a markdown link: [Title](URL).\",\n\t\t],\n\t\tparameters: WebSearchParams,\n\t\trenderCall: renderWebSearchCall,\n\t\trenderResult: renderWebSearchResult,\n\n\t\tasync execute(_toolCallId, params: Static<typeof WebSearchParams>, signal) {\n\t\t\tconst query = params.query.trim();\n\t\t\tconst results = await withDevin((apiKey) => webSearch(apiKey, query, params.max_results ?? 5, signal));\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatWebResults(query, results) }],\n\t\t\t\tdetails: { results: results.map(({ url, title }) => ({ url, title })) },\n\t\t\t};\n\t\t},\n\t});\n\n\tregisterSearchCommand(pi);\n\tpi.on(\"session_start\", async () => syncTools(pi));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/search/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,GAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IACpC,KAAK,EAA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C,EAAE,MAAM;YACxE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAClC,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YACvG,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;gBACnE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;aACvE,CAAC;QACH,CAAC;KACD,CAAC,CAAC;IAEH,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAC1B,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\n * Devin Search: `code_search` and `web_search`, both authenticated by one Devin sign-in.\n *\n * Both tools stay registered so `/tools` and old transcripts know them; a session without a\n * credential starts with them inactive, and signing in or out through `/search` toggles them.\n */\nimport { resolve } from \"node:path\";\nimport { type Static, Type } from \"typebox\";\nimport type { ExtensionAPI } from \"../../core/extensions/types.ts\";\nimport { truncateHead } from \"../../core/tools/truncate.ts\";\nimport { codeSearch, formatLocations } from \"./code-search.ts\";\nimport { registerSearchCommand, syncTools } from \"./command.ts\";\nimport { getCredential } from \"./credential.ts\";\nimport { DevinAuthError, type WebResult, webSearch } from \"./devin.ts\";\nimport {\n\ttype CodeSearchDetails,\n\trenderCodeSearchCall,\n\trenderCodeSearchResult,\n\trenderWebSearchCall,\n\trenderWebSearchResult,\n\ttype WebSearchDetails,\n} from \"./render.ts\";\nimport { isInside } from \"./workspace.ts\";\n\nconst WEB_EXCERPT_MAX_CHARS = 1500;\n\nconst CodeSearchParams = Type.Object({\n\tquery: Type.String({\n\t\tdescription:\n\t\t\t\"One behavior, flow, or error to locate, in concise English. Keep identifiers and error text verbatim. Not for a bare symbol, filename, or literal.\",\n\t}),\n\tpath: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Subdirectory inside the working directory; set it when you know the subsystem. Defaults to the working directory.\",\n\t\t}),\n\t),\n});\n\nconst WebSearchParams = Type.Object({\n\tquery: Type.String({\n\t\tdescription: \"Web search query. Be specific: product names, versions, exact error text. English matches best.\",\n\t}),\n\tmax_results: Type.Optional(Type.Integer({ minimum: 1, maximum: 10, description: \"Results to return (default 5).\" })),\n});\n\nconst SIGN_IN_HINT = \"Ask the user to run /search to sign in to Devin.\";\n\n/** Run a Devin call with the current credential; credential failures tell the model what fixes them. */\nasync function withDevin<T>(run: (apiKey: string) => Promise<T>): Promise<T> {\n\tconst credential = getCredential();\n\tif (!credential) throw new Error(`Devin Search is not signed in. ${SIGN_IN_HINT}`);\n\ttry {\n\t\treturn await run(credential.apiKey);\n\t} catch (error) {\n\t\tthrow error instanceof DevinAuthError ? new Error(`${error.message} ${SIGN_IN_HINT}`) : error;\n\t}\n}\n\nexport function formatWebResults(query: string, results: WebResult[]): string {\n\tif (!results.length) return `No web results for \"${query}\".`;\n\tconst blocks = results.map((r, i) => {\n\t\tconst lines = [`${i + 1}. ${r.title ?? r.url}`, ` ${r.url}`];\n\t\tif (r.summary) {\n\t\t\tconst excerpt = r.summary.replace(/\\n\\s*\\n+/g, \"\\n\").trim();\n\t\t\tlines.push(excerpt.length > WEB_EXCERPT_MAX_CHARS ? `${excerpt.slice(0, WEB_EXCERPT_MAX_CHARS)}…` : excerpt);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t});\n\treturn truncateHead(`Web results for \"${query}\":\\n\\n${blocks.join(\"\\n\\n\")}`).content;\n}\n\nexport default function search(pi: ExtensionAPI): void {\n\tpi.registerTool<typeof CodeSearchParams, CodeSearchDetails>({\n\t\tname: \"code_search\",\n\t\tlabel: \"Code Search\",\n\t\tdescription:\n\t\t\t\"Locate code from a plain-language description of a behavior, flow, or error. Returns up to 10 candidate files with line ranges, not every match.\",\n\t\tpromptSnippet: \"Describe a behavior and receive candidate files with line ranges\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use `code_search` primarily to orient in unfamiliar code: where a behavior or error is handled, or how a flow crosses files. When you can name the file, symbol, or literal, search for it directly.\",\n\t\t\t\"Treat `code_search` results as a reading list; grep identifiers found there when you need every occurrence, such as all call sites.\",\n\t\t],\n\t\tparameters: CodeSearchParams,\n\t\trenderCall: renderCodeSearchCall,\n\t\trenderResult: renderCodeSearchResult,\n\n\t\tasync execute(_toolCallId, params: Static<typeof CodeSearchParams>, signal, onUpdate, ctx) {\n\t\t\tconst root = resolve(ctx.cwd, params.path ?? \".\");\n\t\t\tif (!isInside(ctx.cwd, root)) throw new Error(`path must be inside the working directory (${ctx.cwd}).`);\n\t\t\tconst locations = await withDevin((apiKey) =>\n\t\t\t\tcodeSearch({\n\t\t\t\t\tapiKey,\n\t\t\t\t\tquery: params.query.trim(),\n\t\t\t\t\troot,\n\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\tsignal,\n\t\t\t\t\tonProgress: (text) => onUpdate?.({ content: [{ type: \"text\", text }], details: { locations: [] } }),\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn { content: [{ type: \"text\", text: formatLocations(locations) }], details: { locations } };\n\t\t},\n\t});\n\n\t// Pi's system prompt carries no date, so models otherwise search with their training year.\n\tconst currentMonth = new Date().toLocaleDateString(\"en-US\", { month: \"long\", year: \"numeric\" });\n\tpi.registerTool<typeof WebSearchParams, WebSearchDetails>({\n\t\tname: \"web_search\",\n\t\tlabel: \"Web Search\",\n\t\tdescription:\n\t\t\t\"Search the live web for current information. Returns titles, URLs, and the page excerpts that match the query.\",\n\t\tpromptSnippet: \"Search the live web for current information\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use `web_search` for information beyond your knowledge cutoff.\",\n\t\t\t`It is ${currentMonth}; put this year in \\`web_search\\` queries for recent releases, versions, or events, not the year your training data suggests.`,\n\t\t\t\"When an answer relies on `web_search` results, cite each result you used as a markdown link: [Title](URL).\",\n\t\t],\n\t\tparameters: WebSearchParams,\n\t\trenderCall: renderWebSearchCall,\n\t\trenderResult: renderWebSearchResult,\n\n\t\tasync execute(_toolCallId, params: Static<typeof WebSearchParams>, signal) {\n\t\t\tconst query = params.query.trim();\n\t\t\tconst results = await withDevin((apiKey) => webSearch(apiKey, query, params.max_results ?? 5, signal));\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatWebResults(query, results) }],\n\t\t\t\tdetails: { results: results.map(({ url, title }) => ({ url, title })) },\n\t\t\t};\n\t\t},\n\t});\n\n\tregisterSearchCommand(pi);\n\tpi.on(\"session_start\", async () => syncTools(pi));\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "../../core/extensions/types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Bash on Windows reports paths under its own mount table (`/tmp`, `/usr`, ...), which native file
|
|
4
|
+
* tools would otherwise resolve against the current drive root. Rewrite them to the Windows
|
|
5
|
+
* directories bash means. Drive paths such as `/c/...` stay with core path normalization.
|
|
6
|
+
*/
|
|
7
|
+
export default function shellPathsExtension(pi: ExtensionAPI): void;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/shell-paths/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAsDnE;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAuBlE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { posix, win32 } from "node:path";
|
|
3
|
+
import { normalizePath, normalizeWindowsShellPath } from "../../utils/paths.js";
|
|
4
|
+
import { getShellConfig } from "../../utils/shell.js";
|
|
5
|
+
/** Built-in tools whose `path` argument names a file or directory. */
|
|
6
|
+
const PATH_TOOLS = new Set(["read", "write", "edit", "ls", "grep", "find"]);
|
|
7
|
+
/** `<Windows path> on <mount point> type <fs> (<flags>)`, as printed by Git Bash, MSYS2, and Cygwin `mount`. */
|
|
8
|
+
const MOUNT_LINE = /^(.+?) on (\/.*) type \S+ \([^)]*\)$/;
|
|
9
|
+
const MOUNT_TIMEOUT_MS = 5000;
|
|
10
|
+
function parseMounts(output) {
|
|
11
|
+
const mounts = [];
|
|
12
|
+
for (const line of output.split(/\r?\n/)) {
|
|
13
|
+
const match = MOUNT_LINE.exec(line.trim());
|
|
14
|
+
// Native file tools reach only Windows directories, which also skips virtual mounts.
|
|
15
|
+
if (!match || !/^[a-z]:(?:[\\/]|$)/i.test(match[1]))
|
|
16
|
+
continue;
|
|
17
|
+
const [, source, point] = match;
|
|
18
|
+
mounts.push({ point, target: win32.normalize(source.length === 2 ? `${source}\\` : source) });
|
|
19
|
+
}
|
|
20
|
+
// The longest mount point wins, so /tmp is matched before /.
|
|
21
|
+
return mounts.sort((a, b) => b.point.length - a.point.length);
|
|
22
|
+
}
|
|
23
|
+
function readMounts(shellPath) {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
try {
|
|
26
|
+
const shell = getShellConfig(shellPath ? normalizePath(shellPath) : undefined);
|
|
27
|
+
// Legacy WSL bash mounts live inside Linux; core already maps its /mnt/<drive> paths.
|
|
28
|
+
if (shell.commandTransport === "stdin")
|
|
29
|
+
return resolve([]);
|
|
30
|
+
execFile(shell.shell, [...shell.args, "mount"], { timeout: MOUNT_TIMEOUT_MS, windowsHide: true }, (error, stdout) => resolve(error ? [] : parseMounts(stdout)));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
resolve([]);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function toWindowsPath(path, mounts) {
|
|
38
|
+
const normalized = posix.normalize(path);
|
|
39
|
+
const mount = mounts.find(({ point }) => point === "/" || normalized === point || normalized.startsWith(`${point}/`));
|
|
40
|
+
return mount && win32.join(mount.target, posix.relative(mount.point, normalized));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Bash on Windows reports paths under its own mount table (`/tmp`, `/usr`, ...), which native file
|
|
44
|
+
* tools would otherwise resolve against the current drive root. Rewrite them to the Windows
|
|
45
|
+
* directories bash means. Drive paths such as `/c/...` stay with core path normalization.
|
|
46
|
+
*/
|
|
47
|
+
export default function shellPathsExtension(pi) {
|
|
48
|
+
if (process.platform !== "win32")
|
|
49
|
+
return;
|
|
50
|
+
const mountsByShellPath = new Map();
|
|
51
|
+
function getMounts() {
|
|
52
|
+
const shellPath = pi.getSettings().shellPath;
|
|
53
|
+
let mounts = mountsByShellPath.get(shellPath);
|
|
54
|
+
if (!mounts) {
|
|
55
|
+
mounts = readMounts(shellPath);
|
|
56
|
+
mountsByShellPath.set(shellPath, mounts);
|
|
57
|
+
}
|
|
58
|
+
return mounts;
|
|
59
|
+
}
|
|
60
|
+
pi.on("tool_call", async (event) => {
|
|
61
|
+
if (!PATH_TOOLS.has(event.toolName))
|
|
62
|
+
return;
|
|
63
|
+
const input = event.input;
|
|
64
|
+
const path = input.path;
|
|
65
|
+
if (typeof path !== "string" || !path.startsWith("/") || path.startsWith("//"))
|
|
66
|
+
return;
|
|
67
|
+
if (normalizeWindowsShellPath(path) !== path)
|
|
68
|
+
return;
|
|
69
|
+
const windowsPath = toWindowsPath(path, await getMounts());
|
|
70
|
+
if (windowsPath)
|
|
71
|
+
input.path = windowsPath;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMapp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,CAAC,IAAI,GAAG,WAAW,CAAC;IAC3C,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { execFile } from \"node:child_process\";\nimport { posix, win32 } from \"node:path\";\nimport type { ExtensionAPI } from \"../../core/extensions/types.ts\";\nimport { normalizePath, normalizeWindowsShellPath } from \"../../utils/paths.ts\";\nimport { getShellConfig } from \"../../utils/shell.ts\";\n\n/** Built-in tools whose `path` argument names a file or directory. */\nconst PATH_TOOLS = new Set([\"read\", \"write\", \"edit\", \"ls\", \"grep\", \"find\"]);\n/** `<Windows path> on <mount point> type <fs> (<flags>)`, as printed by Git Bash, MSYS2, and Cygwin `mount`. */\nconst MOUNT_LINE = /^(.+?) on (\\/.*) type \\S+ \\([^)]*\\)$/;\nconst MOUNT_TIMEOUT_MS = 5000;\n\ninterface Mount {\n\tpoint: string;\n\ttarget: string;\n}\n\nfunction parseMounts(output: string): Mount[] {\n\tconst mounts: Mount[] = [];\n\tfor (const line of output.split(/\\r?\\n/)) {\n\t\tconst match = MOUNT_LINE.exec(line.trim());\n\t\t// Native file tools reach only Windows directories, which also skips virtual mounts.\n\t\tif (!match || !/^[a-z]:(?:[\\\\/]|$)/i.test(match[1])) continue;\n\t\tconst [, source, point] = match;\n\t\tmounts.push({ point, target: win32.normalize(source.length === 2 ? `${source}\\\\` : source) });\n\t}\n\t// The longest mount point wins, so /tmp is matched before /.\n\treturn mounts.sort((a, b) => b.point.length - a.point.length);\n}\n\nfunction readMounts(shellPath: string | undefined): Promise<Mount[]> {\n\treturn new Promise((resolve) => {\n\t\ttry {\n\t\t\tconst shell = getShellConfig(shellPath ? normalizePath(shellPath) : undefined);\n\t\t\t// Legacy WSL bash mounts live inside Linux; core already maps its /mnt/<drive> paths.\n\t\t\tif (shell.commandTransport === \"stdin\") return resolve([]);\n\t\t\texecFile(\n\t\t\t\tshell.shell,\n\t\t\t\t[...shell.args, \"mount\"],\n\t\t\t\t{ timeout: MOUNT_TIMEOUT_MS, windowsHide: true },\n\t\t\t\t(error, stdout) => resolve(error ? [] : parseMounts(stdout)),\n\t\t\t);\n\t\t} catch {\n\t\t\tresolve([]);\n\t\t}\n\t});\n}\n\nfunction toWindowsPath(path: string, mounts: readonly Mount[]): string | undefined {\n\tconst normalized = posix.normalize(path);\n\tconst mount = mounts.find(\n\t\t({ point }) => point === \"/\" || normalized === point || normalized.startsWith(`${point}/`),\n\t);\n\treturn mount && win32.join(mount.target, posix.relative(mount.point, normalized));\n}\n\n/**\n * Bash on Windows reports paths under its own mount table (`/tmp`, `/usr`, ...), which native file\n * tools would otherwise resolve against the current drive root. Rewrite them to the Windows\n * directories bash means. Drive paths such as `/c/...` stay with core path normalization.\n */\nexport default function shellPathsExtension(pi: ExtensionAPI): void {\n\tif (process.platform !== \"win32\") return;\n\tconst mountsByShellPath = new Map<string | undefined, Promise<Mount[]>>();\n\n\tfunction getMounts(): Promise<Mount[]> {\n\t\tconst shellPath = pi.getSettings().shellPath;\n\t\tlet mounts = mountsByShellPath.get(shellPath);\n\t\tif (!mounts) {\n\t\t\tmounts = readMounts(shellPath);\n\t\t\tmountsByShellPath.set(shellPath, mounts);\n\t\t}\n\t\treturn mounts;\n\t}\n\n\tpi.on(\"tool_call\", async (event) => {\n\t\tif (!PATH_TOOLS.has(event.toolName)) return;\n\t\tconst input = event.input as { path?: unknown };\n\t\tconst path = input.path;\n\t\tif (typeof path !== \"string\" || !path.startsWith(\"/\") || path.startsWith(\"//\")) return;\n\t\tif (normalizeWindowsShellPath(path) !== path) return;\n\t\tconst windowsPath = toWindowsPath(path, await getMounts());\n\t\tif (windowsPath) input.path = windowsPath;\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/actions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAIzE,OAAO,EAIN,KAAK,YAAY,EACjB,KAA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AAU,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAoBtG;AACD,wBAAgB,OAAO,CAAC,UAAU,EAAE,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAmBnF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Management only: execution and delivery belong to the session task runtime. */
|
|
2
2
|
import { runtimeLabel } from "../../../core/tasks/format.js";
|
|
3
|
-
import { clampReadBytes, clampWaitMs } from "../../../core/tasks/limits.js";
|
|
4
|
-
import { boundText } from "../../../core/tasks/output.js";
|
|
3
|
+
import { clampReadBytes, clampWaitMs, defaultReadMode } from "../../../core/tasks/limits.js";
|
|
4
|
+
import { boundText, taskReadBytes, taskReadRange } from "../../../core/tasks/output.js";
|
|
5
5
|
import { isTaskTerminal, TaskLookupError, } from "../../../core/tasks/types.js";
|
|
6
6
|
import { truncateHead } from "../../../core/tools/truncate.js";
|
|
7
7
|
import { sanitizeBinaryOutput } from "../../../utils/shell.js";
|
|
@@ -67,11 +67,10 @@ function lookupFailure(background, id, error) {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Where this slice sits in the output, so the next wait can continue from it.
|
|
70
|
-
* A wait whose new output exceeds its budget returns the newest bytes and says what it skipped.
|
|
70
|
+
* A tail wait whose new output exceeds its budget returns the newest bytes and says what it skipped.
|
|
71
71
|
*/
|
|
72
72
|
function rangeText(slice, sinceBytes) {
|
|
73
|
-
const from = slice
|
|
74
|
-
const to = from + Buffer.byteLength(slice.text);
|
|
73
|
+
const { from, to } = taskReadRange(slice);
|
|
75
74
|
const floor = sinceBytes === undefined || sinceBytes > slice.totalBytes ? 0 : sinceBytes;
|
|
76
75
|
return [
|
|
77
76
|
`bytes ${from}–${to} of ${slice.totalBytes}`,
|
|
@@ -97,13 +96,14 @@ function readText(header, slice) {
|
|
|
97
96
|
export async function runRead(background, input) {
|
|
98
97
|
const id = requireTaskId(input);
|
|
99
98
|
try {
|
|
100
|
-
const
|
|
101
|
-
|
|
99
|
+
const slice = await background.read(id, { mode: input.mode, bytes: clampReadBytes(input.bytes) });
|
|
100
|
+
// The runtime resolved an omitted mode from this same snapshot, so report what it actually used.
|
|
101
|
+
const mode = input.mode ?? defaultReadMode(slice.task);
|
|
102
102
|
return result(readText(`[${describeTaskLine(slice.task)} · ${rangeText(slice)}]`, slice), {
|
|
103
103
|
action: "read",
|
|
104
104
|
taskId: slice.task.id,
|
|
105
105
|
mode,
|
|
106
|
-
sliceBytes:
|
|
106
|
+
sliceBytes: taskReadBytes(slice),
|
|
107
107
|
totalBytes: slice.totalBytes,
|
|
108
108
|
outputPath: slice.task.outputPath ?? "",
|
|
109
109
|
kind: slice.task.kind,
|
|
@@ -124,13 +124,16 @@ function waitDetails({ outcome, waitedMs, task, read, running }) {
|
|
|
124
124
|
outcome: outcome === "closed" ? "timed_out" : outcome,
|
|
125
125
|
...(task ? { taskId: task.id, status: task.status, kind: task.kind } : {}),
|
|
126
126
|
waitedMs,
|
|
127
|
-
deltaBytes: read ?
|
|
127
|
+
deltaBytes: read ? taskReadBytes(read) : 0,
|
|
128
128
|
totalBytes: read?.totalBytes ?? 0,
|
|
129
129
|
deltaTruncated: read?.truncated ?? false,
|
|
130
|
+
...(read ? { mode: defaultReadMode(read.task) } : {}),
|
|
130
131
|
outputPath: task?.outputPath ?? "",
|
|
131
132
|
...(running ? { running: running.length } : {}),
|
|
132
133
|
};
|
|
133
134
|
}
|
|
135
|
+
/** Every expired wait ends with this, so a model that waited is told to stop rather than wait again. */
|
|
136
|
+
const WAIT_EXPIRED_NEXT = "Do not wait again: continue independent work or end your turn; each result notifies you automatically.";
|
|
134
137
|
function waitText(view, sinceBytes) {
|
|
135
138
|
const { scope, outcome, task, read, running } = view;
|
|
136
139
|
const still = stillRunningText(running ?? []);
|
|
@@ -145,7 +148,8 @@ function waitText(view, sinceBytes) {
|
|
|
145
148
|
: outcome === "timed_out"
|
|
146
149
|
? " · wait window expired; execution continues"
|
|
147
150
|
: ""}`;
|
|
148
|
-
|
|
151
|
+
const next = scope === "task" && outcome === "timed_out" ? `\n\n${WAIT_EXPIRED_NEXT}` : "";
|
|
152
|
+
return `${readText(`[${header} · ${rangeText(read, sinceBytes)}]`, read)}${still}${next}`;
|
|
149
153
|
}
|
|
150
154
|
if (scope === "task" && task) {
|
|
151
155
|
return `[${describeTaskLine(task)} · interrupted by steering; execution continues]\nRead the new input before deciding whether to wait again; the task was not stopped.`;
|
|
@@ -154,7 +158,7 @@ function waitText(view, sinceBytes) {
|
|
|
154
158
|
? "The host closed; execution state is unconfirmed."
|
|
155
159
|
: outcome === "interrupted"
|
|
156
160
|
? "New steering input ended this wait early. Read the new input before deciding what to do next; no task was stopped."
|
|
157
|
-
:
|
|
161
|
+
: `The wait window expired; running tasks continue. ${WAIT_EXPIRED_NEXT}`;
|
|
158
162
|
return `${note}${still}`;
|
|
159
163
|
}
|
|
160
164
|
function waitResult(view, sinceBytes) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/actions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EACN,cAAc,EACd,eAAe,GAKf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAG9E,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,O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AAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1F,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3C,OAAO,MAAM,CACZ,KAAK,CAAC,MAAM;QACX,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,0BAA0B,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,EAAE;QACnK,CAAC,CAAC,iFAAiF,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,EAC/H;QACC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,MAAM;QACN,GAAG,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvD,CACD,CAAC;AACH,CAAC","sourcesContent":["/** Management only: execution and delivery belong to the session task runtime. */\n\nimport type { AgentToolResult } from \"../../../core/extensions/types.ts\";\nimport { runtimeLabel } from \"../../../core/tasks/format.ts\";\nimport { clampReadBytes, clampWaitMs } from \"../../../core/tasks/limits.ts\";\nimport { boundText } from \"../../../core/tasks/output.ts\";\nimport {\n\tisTaskTerminal,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n\ttype TaskWaitOutcome,\n} from \"../../../core/tasks/types.ts\";\nimport { truncateHead } from \"../../../core/tools/truncate.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport { TASKS_LIST_FINISHED_SHOWN, TASKS_WAIT_DELTA_BYTES } from \"./constants.ts\";\nimport { clampSinceBytes, requireTaskId, type TasksInput } from \"./schema.ts\";\nimport type { TasksDetails, TasksKillDetails, TasksListDetails, TasksReadDetails, TasksWaitDetails } from \"./types.ts\";\n\nexport function boundedText(text: string): string {\n\treturn truncateHead(sanitizeBinaryOutput(text), { maxBytes: 50 * 1024, maxLines: 2000 }).content;\n}\nfunction result<T extends TasksDetails>(text: string, details: T): AgentToolResult<T> {\n\treturn { content: [{ type: \"text\", text: boundedText(text) }], details };\n}\nexport function describeTaskLine(task: TaskSnapshot, now = Date.now()): string {\n\treturn `${task.id} ${task.kind} ${task.status} (${task.mode}) ${runtimeLabel(task, now)} ${task.title.slice(0, 200)}`;\n}\n\nconst LOOKUP_LIST_LIMIT = 10;\n\n/**\n * Finished rows sort most-recent first. list() is creation-ordered, so an\n * unsorted slice would surface the oldest completions rather than the recent\n * finishes a caller is most likely looking for.\n */\nfunction recentFinishedFirst(tasks: TaskSnapshot[]): TaskSnapshot[] {\n\treturn tasks.sort((left, right) => (right.endedAt ?? 0) - (left.endedAt ?? 0));\n}\n\n/**\n * Listings cover backgrounded work only; foreground executions deliver inline\n * in the transcript, so they are counted rather than shown. Every listing\n * (tasks list output and lookup-failure messages) shares this scope.\n */\nfunction listedTasks(background: TasksContext): { tasks: TaskSnapshot[]; foregroundOmitted: number } {\n\tconst all = background.list();\n\tconst tasks = all.filter((task) => task.mode === \"background\");\n\treturn { tasks, foregroundOmitted: all.length - tasks.length };\n}\n\nfunction foregroundOmissionNote(omitted: number): string {\n\treturn omitted > 0\n\t\t? `\\n${omitted} foreground ${omitted === 1 ? \"execution\" : \"executions\"} omitted — foreground work is delivered inline in the transcript.`\n\t\t: \"\";\n}\n\n/**\n * Rewrite the service's bare lookup failure into an actionable one: an\n * unknown id gets the session's current tasks (active first, then recent\n * finishes) so the next call can use a real id without a separate list call,\n * and an ambiguous prefix gets exactly the tasks it matched — including\n * records outside the current branch, which listings hide but the prefix\n * still collides with.\n */\nfunction lookupFailure(background: TasksContext, id: string, error: unknown): Error {\n\tif (!(error instanceof TaskLookupError)) return error instanceof Error ? error : new Error(String(error));\n\tif (error.kind === \"ambiguous\") {\n\t\tconst lines = error.matches.map((task) => describeTaskLine(task)).join(\"\\n\");\n\t\treturn new Error(`Ambiguous task ID \"${id}\" matches ${error.matches.length} tasks:\\n${lines}`);\n\t}\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished].slice(0, LOOKUP_LIST_LIMIT);\n\tif (shown.length === 0) {\n\t\treturn new Error(`No task \"${id}\" in this session. No background tasks in this session.`);\n\t}\n\tconst lines = shown.map((task) => describeTaskLine(task)).join(\"\\n\");\n\treturn new Error(\n\t\t`No task \"${id}\" in this session. IDs from other sessions are not valid here.\\nCurrent background tasks:\\n${lines}${foregroundOmissionNote(foregroundOmitted)}`,\n\t);\n}\n\n/**\n * Where this slice sits in the output, so the next wait can continue from it.\n * A wait whose new output exceeds its budget returns the newest bytes and says what it skipped.\n */\nfunction rangeText(slice: TaskRead, sinceBytes?: number): string {\n\tconst from = slice.fromByte ?? 0;\n\tconst to = from + Buffer.byteLength(slice.text);\n\tconst floor = sinceBytes === undefined || sinceBytes > slice.totalBytes ? 0 : sinceBytes;\n\treturn [\n\t\t`bytes ${from}–${to} of ${slice.totalBytes}`,\n\t\tsinceBytes !== undefined && from > floor ? `skipped ${from - floor} bytes after sinceBytes ${floor}` : \"\",\n\t\t`next sinceBytes ${to}`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" · \");\n}\n\n/** Reserve space for each independent diagnostic before allowing raw output to fill the budget. */\nfunction readText(header: string, slice: TaskRead): string {\n\tconst boundedField = (text: string, maxBytes: number) =>\n\t\ttruncateHead(boundText(sanitizeBinaryOutput(text), maxBytes), { maxBytes, maxLines: 100 }).content;\n\treturn [\n\t\tboundedField(header, 4096),\n\t\tslice.task.error ? `Task error: ${boundedField(slice.task.error, 4096)}` : \"\",\n\t\tslice.readError ? `Output read error: ${boundedField(slice.readError, 4096)}` : \"\",\n\t\tboundedField(slice.task.outputPath ?? \"\", 8192),\n\t\tslice.text || \"(no output yet)\",\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\nexport async function runRead(background: TasksContext, input: TasksInput): Promise<AgentToolResult<TasksReadDetails>> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst mode = input.mode ?? \"tail\";\n\t\tconst slice = await background.read(id, { mode, bytes: clampReadBytes(input.bytes) });\n\t\treturn result(readText(`[${describeTaskLine(slice.task)} · ${rangeText(slice)}]`, slice), {\n\t\t\taction: \"read\",\n\t\t\ttaskId: slice.task.id,\n\t\t\tmode,\n\t\t\tsliceBytes: Buffer.byteLength(slice.text),\n\t\t\ttotalBytes: slice.totalBytes,\n\t\t\toutputPath: slice.task.outputPath ?? \"\",\n\t\t\tkind: slice.task.kind,\n\t\t\tstatus: slice.task.status,\n\t\t});\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nfunction stillRunningText(tasks: readonly TaskSnapshot[]): string {\n\treturn tasks.length > 0 ? `\\n\\n[still_running]\\n${tasks.map((task) => describeTaskLine(task)).join(\"\\n\")}` : \"\";\n}\n\n/** A finished observation of one task, or of the first task in a waitAny cohort to settle. */\ninterface WaitView {\n\tscope: \"task\" | \"any\";\n\toutcome: TaskWaitOutcome | \"no_tasks\";\n\twaitedMs: number;\n\ttask?: TaskSnapshot;\n\tread?: TaskRead;\n\t/** Present for waitAny: cohort members still running. */\n\trunning?: readonly TaskSnapshot[];\n}\n\nfunction waitDetails({ outcome, waitedMs, task, read, running }: WaitView): TasksWaitDetails {\n\treturn {\n\t\taction: \"wait\",\n\t\t// A closed host is told apart in the text; the stored outcome keeps its historical values.\n\t\toutcome: outcome === \"closed\" ? \"timed_out\" : outcome,\n\t\t...(task ? { taskId: task.id, status: task.status, kind: task.kind } : {}),\n\t\twaitedMs,\n\t\tdeltaBytes: read ? Buffer.byteLength(read.text) : 0,\n\t\ttotalBytes: read?.totalBytes ?? 0,\n\t\tdeltaTruncated: read?.truncated ?? false,\n\t\toutputPath: task?.outputPath ?? \"\",\n\t\t...(running ? { running: running.length } : {}),\n\t};\n}\n\nfunction waitText(view: WaitView, sinceBytes?: number): string {\n\tconst { scope, outcome, task, read, running } = view;\n\tconst still = stillRunningText(running ?? []);\n\tif (outcome === \"no_tasks\") {\n\t\treturn \"No background tasks are running, so there is nothing to wait for. Finished tasks report back via automatic notification.\";\n\t}\n\tif (read && task) {\n\t\tconst header =\n\t\t\tscope === \"any\"\n\t\t\t\t? `${describeTaskLine(task)} · waitAny settled`\n\t\t\t\t: `${describeTaskLine(task)}${\n\t\t\t\t\t\toutcome === \"closed\"\n\t\t\t\t\t\t\t? \" · host closed; execution state unconfirmed\"\n\t\t\t\t\t\t\t: outcome === \"timed_out\"\n\t\t\t\t\t\t\t\t? \" · wait window expired; execution continues\"\n\t\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t}`;\n\t\treturn `${readText(`[${header} · ${rangeText(read, sinceBytes)}]`, read)}${still}`;\n\t}\n\tif (scope === \"task\" && task) {\n\t\treturn `[${describeTaskLine(task)} · interrupted by steering; execution continues]\\nRead the new input before deciding whether to wait again; the task was not stopped.`;\n\t}\n\tconst note =\n\t\toutcome === \"closed\"\n\t\t\t? \"The host closed; execution state is unconfirmed.\"\n\t\t\t: outcome === \"interrupted\"\n\t\t\t\t? \"New steering input ended this wait early. Read the new input before deciding what to do next; no task was stopped.\"\n\t\t\t\t: \"The wait window expired; running tasks continue. Prefer other work over waiting again.\";\n\treturn `${note}${still}`;\n}\n\nfunction waitResult(view: WaitView, sinceBytes?: number): AgentToolResult<TasksWaitDetails> {\n\treturn result(waitText(view, sinceBytes), waitDetails(view));\n}\n\nexport async function runWait(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\ttoolCallId?: string,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tconst timeoutMs = clampWaitMs(input.waitMs);\n\tif (!input.taskId?.trim()) {\n\t\tif (input.sinceBytes !== undefined)\n\t\t\tthrow new Error(\"action 'wait' without 'taskId' does not accept 'sinceBytes'; offsets belong to one task.\");\n\t\tconst any = await background.waitAny({ timeoutMs, signal, toolCallId, read: { bytes: TASKS_WAIT_DELTA_BYTES } });\n\t\treturn waitResult({ scope: \"any\", ...any });\n\t}\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst sinceBytes = clampSinceBytes(input.sinceBytes);\n\t\tconst one = await background.wait(id, {\n\t\t\ttimeoutMs,\n\t\t\tsignal,\n\t\t\ttoolCallId,\n\t\t\tread: { bytes: TASKS_WAIT_DELTA_BYTES, sinceBytes },\n\t\t});\n\t\treturn waitResult({ scope: \"task\", ...one }, sinceBytes);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runKill(background: TasksContext, input: TasksInput): AgentToolResult<TasksKillDetails> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst task = background.get(id);\n\t\tconst requested = background.kill(task.id);\n\t\treturn result(\n\t\t\trequested\n\t\t\t\t? `Cancellation requested for ${task.id}. The task or whole group is stopping; cleanup may still be in progress.`\n\t\t\t\t: `No new cancellation requested for ${task.id} (${background.get(task.id).status}).`,\n\t\t\t{\n\t\t\t\taction: \"kill\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\ttitle: task.title,\n\t\t\t\trequested,\n\t\t\t\tstatus: background.get(task.id).status,\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runList(background: TasksContext): AgentToolResult<TasksListDetails> {\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished.slice(0, TASKS_LIST_FINISHED_SHOWN)].slice(0, 100);\n\tconst hidden = tasks.length - shown.length;\n\treturn result(\n\t\tshown.length\n\t\t\t? `${shown.map((task) => describeTaskLine(task)).join(\"\\n\")}${hidden > 0 ? `\\n${hidden} more records not shown.` : \"\"}${foregroundOmissionNote(foregroundOmitted)}`\n\t\t\t: `No background tasks. Start work through its owning tool with background: true.${foregroundOmissionNote(foregroundOmitted)}`,\n\t\t{\n\t\t\taction: \"list\",\n\t\t\trunning: active.length,\n\t\t\tfinished: finished.length,\n\t\t\tshown: shown.length,\n\t\t\thidden,\n\t\t\t...(foregroundOmitted > 0 ? { foregroundOmitted } : {}),\n\t\t},\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/actions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EACN,cAAc,EACd,eAAe,GAKf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,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,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,EAAE;QACnK,CAAC,CAAC,iFAAiF,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,EAC/H;QACC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,MAAM;QACN,GAAG,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvD,CACD,CAAC;AACH,CAAC","sourcesContent":["/** Management only: execution and delivery belong to the session task runtime. */\n\nimport type { AgentToolResult } from \"../../../core/extensions/types.ts\";\nimport { runtimeLabel } from \"../../../core/tasks/format.ts\";\nimport { clampReadBytes, clampWaitMs, defaultReadMode } from \"../../../core/tasks/limits.ts\";\nimport { boundText, taskReadBytes, taskReadRange } from \"../../../core/tasks/output.ts\";\nimport {\n\tisTaskTerminal,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n\ttype TaskWaitOutcome,\n} from \"../../../core/tasks/types.ts\";\nimport { truncateHead } from \"../../../core/tools/truncate.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport { TASKS_LIST_FINISHED_SHOWN, TASKS_WAIT_DELTA_BYTES } from \"./constants.ts\";\nimport { clampSinceBytes, requireTaskId, type TasksInput } from \"./schema.ts\";\nimport type { TasksDetails, TasksKillDetails, TasksListDetails, TasksReadDetails, TasksWaitDetails } from \"./types.ts\";\n\nexport function boundedText(text: string): string {\n\treturn truncateHead(sanitizeBinaryOutput(text), { maxBytes: 50 * 1024, maxLines: 2000 }).content;\n}\nfunction result<T extends TasksDetails>(text: string, details: T): AgentToolResult<T> {\n\treturn { content: [{ type: \"text\", text: boundedText(text) }], details };\n}\nexport function describeTaskLine(task: TaskSnapshot, now = Date.now()): string {\n\treturn `${task.id} ${task.kind} ${task.status} (${task.mode}) ${runtimeLabel(task, now)} ${task.title.slice(0, 200)}`;\n}\n\nconst LOOKUP_LIST_LIMIT = 10;\n\n/**\n * Finished rows sort most-recent first. list() is creation-ordered, so an\n * unsorted slice would surface the oldest completions rather than the recent\n * finishes a caller is most likely looking for.\n */\nfunction recentFinishedFirst(tasks: TaskSnapshot[]): TaskSnapshot[] {\n\treturn tasks.sort((left, right) => (right.endedAt ?? 0) - (left.endedAt ?? 0));\n}\n\n/**\n * Listings cover backgrounded work only; foreground executions deliver inline\n * in the transcript, so they are counted rather than shown. Every listing\n * (tasks list output and lookup-failure messages) shares this scope.\n */\nfunction listedTasks(background: TasksContext): { tasks: TaskSnapshot[]; foregroundOmitted: number } {\n\tconst all = background.list();\n\tconst tasks = all.filter((task) => task.mode === \"background\");\n\treturn { tasks, foregroundOmitted: all.length - tasks.length };\n}\n\nfunction foregroundOmissionNote(omitted: number): string {\n\treturn omitted > 0\n\t\t? `\\n${omitted} foreground ${omitted === 1 ? \"execution\" : \"executions\"} omitted — foreground work is delivered inline in the transcript.`\n\t\t: \"\";\n}\n\n/**\n * Rewrite the service's bare lookup failure into an actionable one: an\n * unknown id gets the session's current tasks (active first, then recent\n * finishes) so the next call can use a real id without a separate list call,\n * and an ambiguous prefix gets exactly the tasks it matched — including\n * records outside the current branch, which listings hide but the prefix\n * still collides with.\n */\nfunction lookupFailure(background: TasksContext, id: string, error: unknown): Error {\n\tif (!(error instanceof TaskLookupError)) return error instanceof Error ? error : new Error(String(error));\n\tif (error.kind === \"ambiguous\") {\n\t\tconst lines = error.matches.map((task) => describeTaskLine(task)).join(\"\\n\");\n\t\treturn new Error(`Ambiguous task ID \"${id}\" matches ${error.matches.length} tasks:\\n${lines}`);\n\t}\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished].slice(0, LOOKUP_LIST_LIMIT);\n\tif (shown.length === 0) {\n\t\treturn new Error(`No task \"${id}\" in this session. No background tasks in this session.`);\n\t}\n\tconst lines = shown.map((task) => describeTaskLine(task)).join(\"\\n\");\n\treturn new Error(\n\t\t`No task \"${id}\" in this session. IDs from other sessions are not valid here.\\nCurrent background tasks:\\n${lines}${foregroundOmissionNote(foregroundOmitted)}`,\n\t);\n}\n\n/**\n * Where this slice sits in the output, so the next wait can continue from it.\n * A tail wait whose new output exceeds its budget returns the newest bytes and says what it skipped.\n */\nfunction rangeText(slice: TaskRead, sinceBytes?: number): string {\n\tconst { from, to } = taskReadRange(slice);\n\tconst floor = sinceBytes === undefined || sinceBytes > slice.totalBytes ? 0 : sinceBytes;\n\treturn [\n\t\t`bytes ${from}–${to} of ${slice.totalBytes}`,\n\t\tsinceBytes !== undefined && from > floor ? `skipped ${from - floor} bytes after sinceBytes ${floor}` : \"\",\n\t\t`next sinceBytes ${to}`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" · \");\n}\n\n/** Reserve space for each independent diagnostic before allowing raw output to fill the budget. */\nfunction readText(header: string, slice: TaskRead): string {\n\tconst boundedField = (text: string, maxBytes: number) =>\n\t\ttruncateHead(boundText(sanitizeBinaryOutput(text), maxBytes), { maxBytes, maxLines: 100 }).content;\n\treturn [\n\t\tboundedField(header, 4096),\n\t\tslice.task.error ? `Task error: ${boundedField(slice.task.error, 4096)}` : \"\",\n\t\tslice.readError ? `Output read error: ${boundedField(slice.readError, 4096)}` : \"\",\n\t\tboundedField(slice.task.outputPath ?? \"\", 8192),\n\t\tslice.text || \"(no output yet)\",\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\nexport async function runRead(background: TasksContext, input: TasksInput): Promise<AgentToolResult<TasksReadDetails>> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst slice = await background.read(id, { mode: input.mode, bytes: clampReadBytes(input.bytes) });\n\t\t// The runtime resolved an omitted mode from this same snapshot, so report what it actually used.\n\t\tconst mode = input.mode ?? defaultReadMode(slice.task);\n\t\treturn result(readText(`[${describeTaskLine(slice.task)} · ${rangeText(slice)}]`, slice), {\n\t\t\taction: \"read\",\n\t\t\ttaskId: slice.task.id,\n\t\t\tmode,\n\t\t\tsliceBytes: taskReadBytes(slice),\n\t\t\ttotalBytes: slice.totalBytes,\n\t\t\toutputPath: slice.task.outputPath ?? \"\",\n\t\t\tkind: slice.task.kind,\n\t\t\tstatus: slice.task.status,\n\t\t});\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nfunction stillRunningText(tasks: readonly TaskSnapshot[]): string {\n\treturn tasks.length > 0 ? `\\n\\n[still_running]\\n${tasks.map((task) => describeTaskLine(task)).join(\"\\n\")}` : \"\";\n}\n\n/** A finished observation of one task, or of the first task in a waitAny cohort to settle. */\ninterface WaitView {\n\tscope: \"task\" | \"any\";\n\toutcome: TaskWaitOutcome | \"no_tasks\";\n\twaitedMs: number;\n\ttask?: TaskSnapshot;\n\tread?: TaskRead;\n\t/** Present for waitAny: cohort members still running. */\n\trunning?: readonly TaskSnapshot[];\n}\n\nfunction waitDetails({ outcome, waitedMs, task, read, running }: WaitView): TasksWaitDetails {\n\treturn {\n\t\taction: \"wait\",\n\t\t// A closed host is told apart in the text; the stored outcome keeps its historical values.\n\t\toutcome: outcome === \"closed\" ? \"timed_out\" : outcome,\n\t\t...(task ? { taskId: task.id, status: task.status, kind: task.kind } : {}),\n\t\twaitedMs,\n\t\tdeltaBytes: read ? taskReadBytes(read) : 0,\n\t\ttotalBytes: read?.totalBytes ?? 0,\n\t\tdeltaTruncated: read?.truncated ?? false,\n\t\t...(read ? { mode: defaultReadMode(read.task) } : {}),\n\t\toutputPath: task?.outputPath ?? \"\",\n\t\t...(running ? { running: running.length } : {}),\n\t};\n}\n\n/** Every expired wait ends with this, so a model that waited is told to stop rather than wait again. */\nconst WAIT_EXPIRED_NEXT =\n\t\"Do not wait again: continue independent work or end your turn; each result notifies you automatically.\";\n\nfunction waitText(view: WaitView, sinceBytes?: number): string {\n\tconst { scope, outcome, task, read, running } = view;\n\tconst still = stillRunningText(running ?? []);\n\tif (outcome === \"no_tasks\") {\n\t\treturn \"No background tasks are running, so there is nothing to wait for. Finished tasks report back via automatic notification.\";\n\t}\n\tif (read && task) {\n\t\tconst header =\n\t\t\tscope === \"any\"\n\t\t\t\t? `${describeTaskLine(task)} · waitAny settled`\n\t\t\t\t: `${describeTaskLine(task)}${\n\t\t\t\t\t\toutcome === \"closed\"\n\t\t\t\t\t\t\t? \" · host closed; execution state unconfirmed\"\n\t\t\t\t\t\t\t: outcome === \"timed_out\"\n\t\t\t\t\t\t\t\t? \" · wait window expired; execution continues\"\n\t\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t}`;\n\t\tconst next = scope === \"task\" && outcome === \"timed_out\" ? `\\n\\n${WAIT_EXPIRED_NEXT}` : \"\";\n\t\treturn `${readText(`[${header} · ${rangeText(read, sinceBytes)}]`, read)}${still}${next}`;\n\t}\n\tif (scope === \"task\" && task) {\n\t\treturn `[${describeTaskLine(task)} · interrupted by steering; execution continues]\\nRead the new input before deciding whether to wait again; the task was not stopped.`;\n\t}\n\tconst note =\n\t\toutcome === \"closed\"\n\t\t\t? \"The host closed; execution state is unconfirmed.\"\n\t\t\t: outcome === \"interrupted\"\n\t\t\t\t? \"New steering input ended this wait early. Read the new input before deciding what to do next; no task was stopped.\"\n\t\t\t\t: `The wait window expired; running tasks continue. ${WAIT_EXPIRED_NEXT}`;\n\treturn `${note}${still}`;\n}\n\nfunction waitResult(view: WaitView, sinceBytes?: number): AgentToolResult<TasksWaitDetails> {\n\treturn result(waitText(view, sinceBytes), waitDetails(view));\n}\n\nexport async function runWait(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\ttoolCallId?: string,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tconst timeoutMs = clampWaitMs(input.waitMs);\n\tif (!input.taskId?.trim()) {\n\t\tif (input.sinceBytes !== undefined)\n\t\t\tthrow new Error(\"action 'wait' without 'taskId' does not accept 'sinceBytes'; offsets belong to one task.\");\n\t\tconst any = await background.waitAny({ timeoutMs, signal, toolCallId, read: { bytes: TASKS_WAIT_DELTA_BYTES } });\n\t\treturn waitResult({ scope: \"any\", ...any });\n\t}\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst sinceBytes = clampSinceBytes(input.sinceBytes);\n\t\tconst one = await background.wait(id, {\n\t\t\ttimeoutMs,\n\t\t\tsignal,\n\t\t\ttoolCallId,\n\t\t\tread: { bytes: TASKS_WAIT_DELTA_BYTES, sinceBytes },\n\t\t});\n\t\treturn waitResult({ scope: \"task\", ...one }, sinceBytes);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runKill(background: TasksContext, input: TasksInput): AgentToolResult<TasksKillDetails> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst task = background.get(id);\n\t\tconst requested = background.kill(task.id);\n\t\treturn result(\n\t\t\trequested\n\t\t\t\t? `Cancellation requested for ${task.id}. The task or whole group is stopping; cleanup may still be in progress.`\n\t\t\t\t: `No new cancellation requested for ${task.id} (${background.get(task.id).status}).`,\n\t\t\t{\n\t\t\t\taction: \"kill\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\ttitle: task.title,\n\t\t\t\trequested,\n\t\t\t\tstatus: background.get(task.id).status,\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runList(background: TasksContext): AgentToolResult<TasksListDetails> {\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished.slice(0, TASKS_LIST_FINISHED_SHOWN)].slice(0, 100);\n\tconst hidden = tasks.length - shown.length;\n\treturn result(\n\t\tshown.length\n\t\t\t? `${shown.map((task) => describeTaskLine(task)).join(\"\\n\")}${hidden > 0 ? `\\n${hidden} more records not shown.` : \"\"}${foregroundOmissionNote(foregroundOmitted)}`\n\t\t\t: `No background tasks. Start work through its owning tool with background: true.${foregroundOmissionNote(foregroundOmitted)}`,\n\t\t{\n\t\t\taction: \"list\",\n\t\t\trunning: active.length,\n\t\t\tfinished: finished.length,\n\t\t\tshown: shown.length,\n\t\t\thidden,\n\t\t\t...(foregroundOmitted > 0 ? { foregroundOmitted } : {}),\n\t\t},\n\t);\n}\n"]}
|