@esso0428/pi-subagents 0.17.16 → 0.17.18
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 +11 -0
- package/ROADMAP.md +87 -0
- package/docs/post-0.17.6-agents-roster-viewer-spec.md +42 -0
- package/docs/post-0.17.6-durable-history-spec.md +41 -0
- package/docs/post-0.17.6-feature-specs.md +50 -0
- package/docs/post-0.17.6-nested-agents-spec.md +38 -0
- package/docs/post-0.17.6-recovery-shutdown-spec.md +46 -0
- package/docs/post-0.17.6-ui-latency-baseline-spec.md +46 -0
- package/docs/post-0.17.6-workflow-rpc-lifecycle-spec.md +54 -0
- package/package.json +1 -1
- package/src/agent-history.ts +2 -54
- package/src/agent-manager.ts +406 -1288
- package/src/agent-runner.ts +27 -251
- package/src/agent-types.ts +32 -188
- package/src/cross-extension-rpc.ts +20 -96
- package/src/custom-agents.ts +13 -170
- package/src/index.ts +480 -1920
- package/src/invocation-config.ts +3 -118
- package/src/model-resolver.ts +0 -18
- package/src/output-file.ts +6 -61
- package/src/prompts.ts +2 -45
- package/src/schedule.ts +14 -35
- package/src/settings.ts +2 -301
- package/src/status-note.ts +1 -66
- package/src/types.ts +10 -177
- package/src/ui/agent-widget.ts +57 -278
- package/src/ui/conversation-blocks.ts +0 -6
- package/src/ui/conversation-timeline.ts +25 -139
- package/src/ui/conversation-viewer.ts +48 -212
- package/src/ui/schedule-menu.ts +8 -9
- package/src/usage.ts +2 -109
- package/src/worktree.ts +55 -69
- package/dist/abortable.d.ts +0 -13
- package/dist/abortable.d.ts.map +0 -1
- package/dist/abortable.js +0 -43
- package/dist/abortable.js.map +0 -1
- package/dist/agent-color.d.ts +0 -36
- package/dist/agent-color.d.ts.map +0 -1
- package/dist/agent-color.js +0 -124
- package/dist/agent-color.js.map +0 -1
- package/dist/agent-file-toggle.d.ts +0 -126
- package/dist/agent-file-toggle.d.ts.map +0 -1
- package/dist/agent-file-toggle.js +0 -259
- package/dist/agent-file-toggle.js.map +0 -1
- package/dist/agent-history-list.d.ts +0 -19
- package/dist/agent-history-list.d.ts.map +0 -1
- package/dist/agent-history-list.js +0 -69
- package/dist/agent-history-list.js.map +0 -1
- package/dist/agent-history.d.ts +0 -35
- package/dist/agent-history.d.ts.map +0 -1
- package/dist/agent-history.js +0 -188
- package/dist/agent-history.js.map +0 -1
- package/dist/agent-manager.d.ts +0 -503
- package/dist/agent-manager.d.ts.map +0 -1
- package/dist/agent-manager.js +0 -1572
- package/dist/agent-manager.js.map +0 -1
- package/dist/agent-recovery.d.ts +0 -37
- package/dist/agent-recovery.d.ts.map +0 -1
- package/dist/agent-recovery.js +0 -171
- package/dist/agent-recovery.js.map +0 -1
- package/dist/agent-runner.d.ts +0 -303
- package/dist/agent-runner.d.ts.map +0 -1
- package/dist/agent-runner.js +0 -1003
- package/dist/agent-runner.js.map +0 -1
- package/dist/agent-types.d.ts +0 -120
- package/dist/agent-types.d.ts.map +0 -1
- package/dist/agent-types.js +0 -301
- package/dist/agent-types.js.map +0 -1
- package/dist/child-context.d.ts +0 -3
- package/dist/child-context.d.ts.map +0 -1
- package/dist/child-context.js +0 -13
- package/dist/child-context.js.map +0 -1
- package/dist/context.d.ts +0 -13
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -57
- package/dist/context.js.map +0 -1
- package/dist/cross-extension-rpc.d.ts +0 -67
- package/dist/cross-extension-rpc.d.ts.map +0 -1
- package/dist/cross-extension-rpc.js +0 -139
- package/dist/cross-extension-rpc.js.map +0 -1
- package/dist/custom-agents.d.ts +0 -55
- package/dist/custom-agents.d.ts.map +0 -1
- package/dist/custom-agents.js +0 -309
- package/dist/custom-agents.js.map +0 -1
- package/dist/default-agents.d.ts +0 -8
- package/dist/default-agents.d.ts.map +0 -1
- package/dist/default-agents.js +0 -123
- package/dist/default-agents.js.map +0 -1
- package/dist/enabled-models.d.ts +0 -50
- package/dist/enabled-models.d.ts.map +0 -1
- package/dist/enabled-models.js +0 -146
- package/dist/enabled-models.js.map +0 -1
- package/dist/env.d.ts +0 -7
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -29
- package/dist/env.js.map +0 -1
- package/dist/group-join.d.ts +0 -33
- package/dist/group-join.d.ts.map +0 -1
- package/dist/group-join.js +0 -117
- package/dist/group-join.js.map +0 -1
- package/dist/index.d.ts +0 -51
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3687
- package/dist/index.js.map +0 -1
- package/dist/invocation-config.d.ts +0 -108
- package/dist/invocation-config.d.ts.map +0 -1
- package/dist/invocation-config.js +0 -84
- package/dist/invocation-config.js.map +0 -1
- package/dist/memory.d.ts +0 -54
- package/dist/memory.d.ts.map +0 -1
- package/dist/memory.js +0 -166
- package/dist/memory.js.map +0 -1
- package/dist/mention-clone.d.ts +0 -88
- package/dist/mention-clone.d.ts.map +0 -1
- package/dist/mention-clone.js +0 -154
- package/dist/mention-clone.js.map +0 -1
- package/dist/mention.d.ts +0 -82
- package/dist/mention.d.ts.map +0 -1
- package/dist/mention.js +0 -132
- package/dist/mention.js.map +0 -1
- package/dist/model-resolver.d.ts +0 -37
- package/dist/model-resolver.d.ts.map +0 -1
- package/dist/model-resolver.js +0 -96
- package/dist/model-resolver.js.map +0 -1
- package/dist/model-scope.d.ts +0 -50
- package/dist/model-scope.d.ts.map +0 -1
- package/dist/model-scope.js +0 -49
- package/dist/model-scope.js.map +0 -1
- package/dist/nested-tools.d.ts +0 -57
- package/dist/nested-tools.d.ts.map +0 -1
- package/dist/nested-tools.js +0 -301
- package/dist/nested-tools.js.map +0 -1
- package/dist/nico-overrides.d.ts +0 -54
- package/dist/nico-overrides.d.ts.map +0 -1
- package/dist/nico-overrides.js +0 -170
- package/dist/nico-overrides.js.map +0 -1
- package/dist/output-file.d.ts +0 -44
- package/dist/output-file.d.ts.map +0 -1
- package/dist/output-file.js +0 -156
- package/dist/output-file.js.map +0 -1
- package/dist/prompts.d.ts +0 -56
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -92
- package/dist/prompts.js.map +0 -1
- package/dist/schedule-store.d.ts +0 -39
- package/dist/schedule-store.d.ts.map +0 -1
- package/dist/schedule-store.js +0 -156
- package/dist/schedule-store.js.map +0 -1
- package/dist/schedule.d.ts +0 -110
- package/dist/schedule.d.ts.map +0 -1
- package/dist/schedule.js +0 -360
- package/dist/schedule.js.map +0 -1
- package/dist/settings.d.ts +0 -354
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js +0 -247
- package/dist/settings.js.map +0 -1
- package/dist/skill-loader.d.ts +0 -25
- package/dist/skill-loader.d.ts.map +0 -1
- package/dist/skill-loader.js +0 -94
- package/dist/skill-loader.js.map +0 -1
- package/dist/status-note.d.ts +0 -62
- package/dist/status-note.d.ts.map +0 -1
- package/dist/status-note.js +0 -86
- package/dist/status-note.js.map +0 -1
- package/dist/structured-output.d.ts +0 -62
- package/dist/structured-output.d.ts.map +0 -1
- package/dist/structured-output.js +0 -113
- package/dist/structured-output.js.map +0 -1
- package/dist/types.d.ts +0 -372
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
- package/dist/ui/agent-mention.d.ts +0 -83
- package/dist/ui/agent-mention.d.ts.map +0 -1
- package/dist/ui/agent-mention.js +0 -188
- package/dist/ui/agent-mention.js.map +0 -1
- package/dist/ui/agent-widget.d.ts +0 -241
- package/dist/ui/agent-widget.d.ts.map +0 -1
- package/dist/ui/agent-widget.js +0 -992
- package/dist/ui/agent-widget.js.map +0 -1
- package/dist/ui/ccstyle/diff/ansi-utils.d.ts +0 -11
- package/dist/ui/ccstyle/diff/ansi-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/ansi-utils.js +0 -145
- package/dist/ui/ccstyle/diff/ansi-utils.js.map +0 -1
- package/dist/ui/ccstyle/diff/diff-presentation.d.ts +0 -12
- package/dist/ui/ccstyle/diff/diff-presentation.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/diff-presentation.js +0 -48
- package/dist/ui/ccstyle/diff/diff-presentation.js.map +0 -1
- package/dist/ui/ccstyle/diff/diff-renderer.d.ts +0 -46
- package/dist/ui/ccstyle/diff/diff-renderer.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/diff-renderer.js +0 -2049
- package/dist/ui/ccstyle/diff/diff-renderer.js.map +0 -1
- package/dist/ui/ccstyle/diff/line-width-safety.d.ts +0 -12
- package/dist/ui/ccstyle/diff/line-width-safety.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/line-width-safety.js +0 -58
- package/dist/ui/ccstyle/diff/line-width-safety.js.map +0 -1
- package/dist/ui/ccstyle/diff/render-utils.d.ts +0 -6
- package/dist/ui/ccstyle/diff/render-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/render-utils.js +0 -25
- package/dist/ui/ccstyle/diff/render-utils.js.map +0 -1
- package/dist/ui/ccstyle/diff/shiki-highlight.d.ts +0 -19
- package/dist/ui/ccstyle/diff/shiki-highlight.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/shiki-highlight.js +0 -85
- package/dist/ui/ccstyle/diff/shiki-highlight.js.map +0 -1
- package/dist/ui/ccstyle/diff/types.d.ts +0 -22
- package/dist/ui/ccstyle/diff/types.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/types.js +0 -10
- package/dist/ui/ccstyle/diff/types.js.map +0 -1
- package/dist/ui/ccstyle/diff/write-display-utils.d.ts +0 -2
- package/dist/ui/ccstyle/diff/write-display-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/write-display-utils.js +0 -12
- package/dist/ui/ccstyle/diff/write-display-utils.js.map +0 -1
- package/dist/ui/ccstyle/tool-renderer.d.ts +0 -17
- package/dist/ui/ccstyle/tool-renderer.d.ts.map +0 -1
- package/dist/ui/ccstyle/tool-renderer.js +0 -74
- package/dist/ui/ccstyle/tool-renderer.js.map +0 -1
- package/dist/ui/ccstyle/tool-result.d.ts +0 -44
- package/dist/ui/ccstyle/tool-result.d.ts.map +0 -1
- package/dist/ui/ccstyle/tool-result.js +0 -423
- package/dist/ui/ccstyle/tool-result.js.map +0 -1
- package/dist/ui/conversation-blocks.d.ts +0 -46
- package/dist/ui/conversation-blocks.d.ts.map +0 -1
- package/dist/ui/conversation-blocks.js +0 -313
- package/dist/ui/conversation-blocks.js.map +0 -1
- package/dist/ui/conversation-nvim.d.ts +0 -8
- package/dist/ui/conversation-nvim.d.ts.map +0 -1
- package/dist/ui/conversation-nvim.js +0 -117
- package/dist/ui/conversation-nvim.js.map +0 -1
- package/dist/ui/conversation-role.d.ts +0 -13
- package/dist/ui/conversation-role.d.ts.map +0 -1
- package/dist/ui/conversation-role.js +0 -39
- package/dist/ui/conversation-role.js.map +0 -1
- package/dist/ui/conversation-search.d.ts +0 -39
- package/dist/ui/conversation-search.d.ts.map +0 -1
- package/dist/ui/conversation-search.js +0 -124
- package/dist/ui/conversation-search.js.map +0 -1
- package/dist/ui/conversation-timeline.d.ts +0 -102
- package/dist/ui/conversation-timeline.d.ts.map +0 -1
- package/dist/ui/conversation-timeline.js +0 -555
- package/dist/ui/conversation-timeline.js.map +0 -1
- package/dist/ui/conversation-viewer.d.ts +0 -138
- package/dist/ui/conversation-viewer.d.ts.map +0 -1
- package/dist/ui/conversation-viewer.js +0 -1175
- package/dist/ui/conversation-viewer.js.map +0 -1
- package/dist/ui/schedule-menu.d.ts +0 -17
- package/dist/ui/schedule-menu.d.ts.map +0 -1
- package/dist/ui/schedule-menu.js +0 -95
- package/dist/ui/schedule-menu.js.map +0 -1
- package/dist/ui/select-item.d.ts +0 -28
- package/dist/ui/select-item.d.ts.map +0 -1
- package/dist/ui/select-item.js +0 -35
- package/dist/ui/select-item.js.map +0 -1
- package/dist/ui/viewer-keys.d.ts +0 -21
- package/dist/ui/viewer-keys.d.ts.map +0 -1
- package/dist/ui/viewer-keys.js +0 -18
- package/dist/ui/viewer-keys.js.map +0 -1
- package/dist/ui/workflow-card.d.ts +0 -176
- package/dist/ui/workflow-card.d.ts.map +0 -1
- package/dist/ui/workflow-card.js +0 -333
- package/dist/ui/workflow-card.js.map +0 -1
- package/dist/ui/workflow-dialog.d.ts +0 -306
- package/dist/ui/workflow-dialog.d.ts.map +0 -1
- package/dist/ui/workflow-dialog.js +0 -844
- package/dist/ui/workflow-dialog.js.map +0 -1
- package/dist/ui/workflow-menu.d.ts +0 -42
- package/dist/ui/workflow-menu.d.ts.map +0 -1
- package/dist/ui/workflow-menu.js +0 -127
- package/dist/ui/workflow-menu.js.map +0 -1
- package/dist/usage.d.ts +0 -136
- package/dist/usage.d.ts.map +0 -1
- package/dist/usage.js +0 -121
- package/dist/usage.js.map +0 -1
- package/dist/workflow/collisions.d.ts +0 -96
- package/dist/workflow/collisions.d.ts.map +0 -1
- package/dist/workflow/collisions.js +0 -89
- package/dist/workflow/collisions.js.map +0 -1
- package/dist/workflow/entry.d.ts +0 -33
- package/dist/workflow/entry.d.ts.map +0 -1
- package/dist/workflow/entry.js +0 -30
- package/dist/workflow/entry.js.map +0 -1
- package/dist/workflow/host.d.ts +0 -63
- package/dist/workflow/host.d.ts.map +0 -1
- package/dist/workflow/host.js +0 -363
- package/dist/workflow/host.js.map +0 -1
- package/dist/workflow/journal.d.ts +0 -98
- package/dist/workflow/journal.d.ts.map +0 -1
- package/dist/workflow/journal.js +0 -121
- package/dist/workflow/journal.js.map +0 -1
- package/dist/workflow/json-schema.d.ts +0 -52
- package/dist/workflow/json-schema.d.ts.map +0 -1
- package/dist/workflow/json-schema.js +0 -112
- package/dist/workflow/json-schema.js.map +0 -1
- package/dist/workflow/meta.d.ts +0 -68
- package/dist/workflow/meta.d.ts.map +0 -1
- package/dist/workflow/meta.js +0 -318
- package/dist/workflow/meta.js.map +0 -1
- package/dist/workflow/progress.d.ts +0 -225
- package/dist/workflow/progress.d.ts.map +0 -1
- package/dist/workflow/progress.js +0 -362
- package/dist/workflow/progress.js.map +0 -1
- package/dist/workflow/runtime.d.ts +0 -335
- package/dist/workflow/runtime.d.ts.map +0 -1
- package/dist/workflow/runtime.js +0 -831
- package/dist/workflow/runtime.js.map +0 -1
- package/dist/workflow/saved.d.ts +0 -91
- package/dist/workflow/saved.d.ts.map +0 -1
- package/dist/workflow/saved.js +0 -204
- package/dist/workflow/saved.js.map +0 -1
- package/dist/workflow/task.d.ts +0 -137
- package/dist/workflow/task.d.ts.map +0 -1
- package/dist/workflow/task.js +0 -208
- package/dist/workflow/task.js.map +0 -1
- package/dist/workflow/tool-description.d.ts +0 -39
- package/dist/workflow/tool-description.d.ts.map +0 -1
- package/dist/workflow/tool-description.js +0 -200
- package/dist/workflow/tool-description.js.map +0 -1
- package/dist/workflow/worker-source.d.ts +0 -48
- package/dist/workflow/worker-source.d.ts.map +0 -1
- package/dist/workflow/worker-source.js +0 -779
- package/dist/workflow/worker-source.js.map +0 -1
- package/dist/worktree.d.ts +0 -53
- package/dist/worktree.d.ts.map +0 -1
- package/dist/worktree.js +0 -165
- package/dist/worktree.js.map +0 -1
- package/dist/write-execution.d.ts +0 -42
- package/dist/write-execution.d.ts.map +0 -1
- package/dist/write-execution.js +0 -138
- package/dist/write-execution.js.map +0 -1
- package/dist/xml.d.ts +0 -11
- package/dist/xml.d.ts.map +0 -1
- package/dist/xml.js +0 -13
- package/dist/xml.js.map +0 -1
- package/src/abortable.ts +0 -43
- package/src/agent-color.ts +0 -161
- package/src/agent-file-toggle.ts +0 -269
- package/src/child-context.ts +0 -15
- package/src/mention-clone.ts +0 -196
- package/src/mention.ts +0 -141
- package/src/model-scope.ts +0 -70
- package/src/nested-tools.ts +0 -424
- package/src/structured-output.ts +0 -130
- package/src/ui/agent-mention.ts +0 -216
- package/src/ui/select-item.ts +0 -45
- package/src/ui/workflow-card.ts +0 -470
- package/src/ui/workflow-dialog.ts +0 -1115
- package/src/ui/workflow-menu.ts +0 -166
- package/src/workflow/collisions.ts +0 -123
- package/src/workflow/entry.ts +0 -47
- package/src/workflow/host.ts +0 -403
- package/src/workflow/journal.ts +0 -164
- package/src/workflow/json-schema.ts +0 -128
- package/src/workflow/meta.ts +0 -325
- package/src/workflow/progress.ts +0 -550
- package/src/workflow/runtime.ts +0 -1219
- package/src/workflow/saved.ts +0 -217
- package/src/workflow/task.ts +0 -302
- package/src/workflow/tool-description.ts +0 -200
- package/src/workflow/worker-source.ts +0 -781
- package/src/xml.ts +0 -13
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-source.js","sourceRoot":"","sources":["../../src/workflow/worker-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH;;;;;;GAMG;AACH,MAAM,mBAAmB,GACvB,6BAA6B;IAC7B,oCAAoC;IACpC,gCAAgC;IAChC,gFAAgF;IAChF,+EAA+E;IAC/E,KAAK;IACL,8DAA8D;IAC9D,gEAAgE;IAChE,+CAA+C;IAC/C,0FAA0F;IAC1F,KAAK;IACL,OAAO,CAAC;AAEV,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;kBAOX,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAisBpD,CAAC"}
|
package/dist/worktree.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* worktree.ts — Git worktree isolation for agents.
|
|
3
|
-
*
|
|
4
|
-
* Creates a temporary git worktree so the agent works on an isolated copy of the repo.
|
|
5
|
-
* On completion, if no changes were made, the worktree is cleaned up.
|
|
6
|
-
* If changes exist, a branch is created and returned in the result.
|
|
7
|
-
*
|
|
8
|
-
* Every git call goes through `pi.exec` (async) rather than `execFileSync`: a
|
|
9
|
-
* worktree copy can take seconds, and a session that spawns several isolated
|
|
10
|
-
* agents at once would otherwise serialize them all on the TUI's event loop.
|
|
11
|
-
*/
|
|
12
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
13
|
-
export interface WorktreeInfo {
|
|
14
|
-
/** Absolute path to the worktree directory (the copied repo's root). */
|
|
15
|
-
path: string;
|
|
16
|
-
/** Branch name created for this worktree (if changes exist). */
|
|
17
|
-
branch: string;
|
|
18
|
-
/** Commit SHA that the worktree was created from. */
|
|
19
|
-
baseSha: string;
|
|
20
|
-
/**
|
|
21
|
-
* Where the agent should work inside the worktree: the equivalent of the
|
|
22
|
-
* cwd the worktree was created from. Equals `path` when that cwd was the
|
|
23
|
-
* repo root; points at the copied subdirectory when it was deeper (e.g. a
|
|
24
|
-
* monorepo package), so the requested scoping survives isolation.
|
|
25
|
-
*/
|
|
26
|
-
workPath: string;
|
|
27
|
-
}
|
|
28
|
-
export declare function setWorktreeIsolationEnabled(enabled: boolean): void;
|
|
29
|
-
export declare function isWorktreeIsolationEnabled(): boolean;
|
|
30
|
-
export interface WorktreeCleanupResult {
|
|
31
|
-
/** Whether changes were found in the worktree. */
|
|
32
|
-
hasChanges: boolean;
|
|
33
|
-
/** Branch name if changes were committed. */
|
|
34
|
-
branch?: string;
|
|
35
|
-
/** Worktree path if it was kept. */
|
|
36
|
-
path?: string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Create a temporary git worktree for an agent.
|
|
40
|
-
* Returns the worktree path, or undefined if not in a git repo.
|
|
41
|
-
*/
|
|
42
|
-
export declare function createWorktree(pi: ExtensionAPI, cwd: string, agentId: string): Promise<WorktreeInfo | undefined>;
|
|
43
|
-
/**
|
|
44
|
-
* Clean up a worktree after agent completion.
|
|
45
|
-
* - If no changes: remove worktree entirely.
|
|
46
|
-
* - If changes exist: create a branch, commit changes, return branch info.
|
|
47
|
-
*/
|
|
48
|
-
export declare function cleanupWorktree(pi: ExtensionAPI, cwd: string, worktree: WorktreeInfo, agentDescription: string): Promise<WorktreeCleanupResult>;
|
|
49
|
-
/**
|
|
50
|
-
* Prune any orphaned worktrees (crash recovery).
|
|
51
|
-
*/
|
|
52
|
-
export declare function pruneWorktrees(pi: ExtensionAPI, cwd: string): Promise<void>;
|
|
53
|
-
//# sourceMappingURL=worktree.d.ts.map
|
package/dist/worktree.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAcD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAElE;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmBD;;;GAGG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,YAAY,EAChB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CA6BnC;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,YAAY,EAChB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,qBAAqB,CAAC,CAoDhC;AAgBD;;GAEG;AACH,wBAAsB,cAAc,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjF"}
|
package/dist/worktree.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* worktree.ts — Git worktree isolation for agents.
|
|
3
|
-
*
|
|
4
|
-
* Creates a temporary git worktree so the agent works on an isolated copy of the repo.
|
|
5
|
-
* On completion, if no changes were made, the worktree is cleaned up.
|
|
6
|
-
* If changes exist, a branch is created and returned in the result.
|
|
7
|
-
*
|
|
8
|
-
* Every git call goes through `pi.exec` (async) rather than `execFileSync`: a
|
|
9
|
-
* worktree copy can take seconds, and a session that spawns several isolated
|
|
10
|
-
* agents at once would otherwise serialize them all on the TUI's event loop.
|
|
11
|
-
*/
|
|
12
|
-
import { randomUUID } from "node:crypto";
|
|
13
|
-
import { existsSync, realpathSync } from "node:fs";
|
|
14
|
-
import { tmpdir } from "node:os";
|
|
15
|
-
import { join, relative } from "node:path";
|
|
16
|
-
/**
|
|
17
|
-
* Project-wide switch for worktree isolation (`worktreeIsolation` in
|
|
18
|
-
* subagents.json). Default `true` — unchanged behaviour.
|
|
19
|
-
*
|
|
20
|
-
* The `"off"` isolation value gives a model a legal way to decline a worktree,
|
|
21
|
-
* but it still depends on the model choosing it. This is the deterministic half
|
|
22
|
-
* of the same fix: on a large repo where every worktree costs real time and
|
|
23
|
-
* disk (#184), turning it off means no caller can create one, whatever it
|
|
24
|
-
* passes.
|
|
25
|
-
*/
|
|
26
|
-
let worktreeIsolationEnabled = true;
|
|
27
|
-
export function setWorktreeIsolationEnabled(enabled) {
|
|
28
|
-
worktreeIsolationEnabled = enabled;
|
|
29
|
-
}
|
|
30
|
-
export function isWorktreeIsolationEnabled() {
|
|
31
|
-
return worktreeIsolationEnabled;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Run git and return its trimmed stdout, throwing on failure so callers keep
|
|
35
|
-
* the try/catch control flow `execFileSync` gave them.
|
|
36
|
-
*
|
|
37
|
-
* `pi.exec` never rejects — it reports failure in the result — and a command
|
|
38
|
-
* killed by its timeout comes back as `killed` with an exit code of 0, so both
|
|
39
|
-
* have to be checked to reproduce `execFileSync`'s "throws on anything but a
|
|
40
|
-
* clean exit".
|
|
41
|
-
*/
|
|
42
|
-
async function git(pi, cwd, args, timeout) {
|
|
43
|
-
const result = await pi.exec("git", args, { cwd, timeout });
|
|
44
|
-
if (result.killed || result.code !== 0) {
|
|
45
|
-
throw new Error(result.stderr.trim() || `git ${args.join(" ")} failed (exit ${result.code})`);
|
|
46
|
-
}
|
|
47
|
-
return result.stdout.trim();
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Create a temporary git worktree for an agent.
|
|
51
|
-
* Returns the worktree path, or undefined if not in a git repo.
|
|
52
|
-
*/
|
|
53
|
-
export async function createWorktree(pi, cwd, agentId) {
|
|
54
|
-
// Verify we're in a git repo with at least one commit (HEAD must exist)
|
|
55
|
-
let baseSha;
|
|
56
|
-
let subdir;
|
|
57
|
-
try {
|
|
58
|
-
await git(pi, cwd, ["rev-parse", "--is-inside-work-tree"], 5000);
|
|
59
|
-
baseSha = await git(pi, cwd, ["rev-parse", "HEAD"], 5000);
|
|
60
|
-
// Where cwd sits inside the repo ("" at the root): the agent must work at
|
|
61
|
-
// the same subdirectory inside the copy, or a monorepo-package cwd would
|
|
62
|
-
// silently widen to the whole repo. realpath both sides — git emits
|
|
63
|
-
// resolved paths while cwd may arrive through a symlink (macOS /tmp).
|
|
64
|
-
const topLevel = await git(pi, cwd, ["rev-parse", "--show-toplevel"], 5000);
|
|
65
|
-
subdir = relative(realpathSync(topLevel), realpathSync(cwd));
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
const branch = `pi-agent-${agentId}`;
|
|
71
|
-
const suffix = randomUUID().slice(0, 8);
|
|
72
|
-
const worktreePath = join(tmpdir(), `pi-agent-${agentId}-${suffix}`);
|
|
73
|
-
try {
|
|
74
|
-
// Create detached worktree at HEAD
|
|
75
|
-
await git(pi, cwd, ["worktree", "add", "--detach", worktreePath, "HEAD"], 30000);
|
|
76
|
-
return { path: worktreePath, branch, baseSha, workPath: subdir ? join(worktreePath, subdir) : worktreePath };
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
// If worktree creation fails, return undefined (agent runs in normal cwd)
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Clean up a worktree after agent completion.
|
|
85
|
-
* - If no changes: remove worktree entirely.
|
|
86
|
-
* - If changes exist: create a branch, commit changes, return branch info.
|
|
87
|
-
*/
|
|
88
|
-
export async function cleanupWorktree(pi, cwd, worktree, agentDescription) {
|
|
89
|
-
if (!existsSync(worktree.path)) {
|
|
90
|
-
return { hasChanges: false };
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
// Check for uncommitted changes in the worktree
|
|
94
|
-
const status = await git(pi, worktree.path, ["status", "--porcelain"], 10000);
|
|
95
|
-
if (status) {
|
|
96
|
-
// Changes exist — stage, commit, and create a branch
|
|
97
|
-
await git(pi, worktree.path, ["add", "-A"], 10000);
|
|
98
|
-
// Truncate description for commit message (no shell sanitization needed — pi.exec uses argv)
|
|
99
|
-
const safeDesc = agentDescription.slice(0, 200);
|
|
100
|
-
const commitMsg = `pi-agent: ${safeDesc}`;
|
|
101
|
-
await git(pi, worktree.path, ["commit", "--no-verify", "-m", commitMsg], 10000);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
const currentSha = await git(pi, worktree.path, ["rev-parse", "HEAD"], 5000);
|
|
105
|
-
if (currentSha === worktree.baseSha) {
|
|
106
|
-
// No changes — remove worktree
|
|
107
|
-
await removeWorktree(pi, cwd, worktree.path);
|
|
108
|
-
return { hasChanges: false };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// Create a branch pointing to the worktree's HEAD.
|
|
112
|
-
// If the branch already exists, append a suffix to avoid overwriting previous work.
|
|
113
|
-
let branchName = worktree.branch;
|
|
114
|
-
try {
|
|
115
|
-
await git(pi, worktree.path, ["branch", branchName], 5000);
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
// Branch already exists — use a unique suffix
|
|
119
|
-
branchName = `${worktree.branch}-${Date.now()}`;
|
|
120
|
-
await git(pi, worktree.path, ["branch", branchName], 5000);
|
|
121
|
-
}
|
|
122
|
-
// Update branch name in worktree info for the caller
|
|
123
|
-
worktree.branch = branchName;
|
|
124
|
-
// Remove the worktree (branch persists in main repo)
|
|
125
|
-
await removeWorktree(pi, cwd, worktree.path);
|
|
126
|
-
return {
|
|
127
|
-
hasChanges: true,
|
|
128
|
-
branch: worktree.branch,
|
|
129
|
-
path: worktree.path,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
// Best effort cleanup on error
|
|
134
|
-
try {
|
|
135
|
-
await removeWorktree(pi, cwd, worktree.path);
|
|
136
|
-
}
|
|
137
|
-
catch { /* ignore */ }
|
|
138
|
-
return { hasChanges: false };
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Force-remove a worktree.
|
|
143
|
-
*/
|
|
144
|
-
async function removeWorktree(pi, cwd, worktreePath) {
|
|
145
|
-
try {
|
|
146
|
-
await git(pi, cwd, ["worktree", "remove", "--force", worktreePath], 10000);
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
// If git worktree remove fails, try pruning
|
|
150
|
-
try {
|
|
151
|
-
await git(pi, cwd, ["worktree", "prune"], 5000);
|
|
152
|
-
}
|
|
153
|
-
catch { /* ignore */ }
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Prune any orphaned worktrees (crash recovery).
|
|
158
|
-
*/
|
|
159
|
-
export async function pruneWorktrees(pi, cwd) {
|
|
160
|
-
try {
|
|
161
|
-
await git(pi, cwd, ["worktree", "prune"], 5000);
|
|
162
|
-
}
|
|
163
|
-
catch { /* ignore */ }
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=worktree.js.map
|
package/dist/worktree.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.js","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAmB3C;;;;;;;;;GASG;AACH,IAAI,wBAAwB,GAAG,IAAI,CAAC;AAEpC,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IAC1D,wBA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ClD,CAAC;IAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
/** Maximum UTF-8 size of the durable display diff plus unified patch. */
|
|
3
|
-
export declare const MAX_DURABLE_DIFF_BYTES: number;
|
|
4
|
-
/** Avoid retaining arbitrarily large previous files in the live-only store. */
|
|
5
|
-
export declare const MAX_COMPARABLE_WRITE_BYTES = 512000;
|
|
6
|
-
export declare const MAX_WRITE_METADATA_ENTRIES = 100;
|
|
7
|
-
export interface DurableWriteDetails {
|
|
8
|
-
diff?: string;
|
|
9
|
-
patch?: string;
|
|
10
|
-
firstChangedLine?: number;
|
|
11
|
-
diffUnavailableReason?: string;
|
|
12
|
-
}
|
|
13
|
-
/** Ephemeral execution metadata used by the live renderer. Never persisted as a before/after pair. */
|
|
14
|
-
export interface WriteExecutionMeta extends DurableWriteDetails {
|
|
15
|
-
fileExistedBeforeWrite: boolean;
|
|
16
|
-
previousContent?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare class WriteExecutionMetadataStore {
|
|
19
|
-
readonly entries: Map<string, WriteExecutionMeta>;
|
|
20
|
-
set(toolCallId: string, metadata: WriteExecutionMeta): void;
|
|
21
|
-
get(toolCallId: unknown): WriteExecutionMeta | undefined;
|
|
22
|
-
delete(toolCallId: string): void;
|
|
23
|
-
clear(): void;
|
|
24
|
-
}
|
|
25
|
-
type WriteParams = {
|
|
26
|
-
path: string;
|
|
27
|
-
content: string;
|
|
28
|
-
};
|
|
29
|
-
export declare function executeWriteWithMetadata(store: WriteExecutionMetadataStore, toolCallId: string, params: WriteParams, signal: AbortSignal | undefined, cwd: string): Promise<{
|
|
30
|
-
content: Array<{
|
|
31
|
-
type: "text";
|
|
32
|
-
text: string;
|
|
33
|
-
}>;
|
|
34
|
-
details?: DurableWriteDetails;
|
|
35
|
-
}>;
|
|
36
|
-
/**
|
|
37
|
-
* A session-local write definition. It retains Pi's public schema/description
|
|
38
|
-
* and replaces only execution so the parent registry is never mutated.
|
|
39
|
-
*/
|
|
40
|
-
export declare function createTrackedWriteTool(cwd: string, store?: WriteExecutionMetadataStore): ToolDefinition<any, DurableWriteDetails>;
|
|
41
|
-
export {};
|
|
42
|
-
//# sourceMappingURL=write-execution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write-execution.d.ts","sourceRoot":"","sources":["../src/write-execution.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8F,KAAK,cAAc,EAAyB,MAAM,iCAAiC,CAAC;AAEzL,yEAAyE;AACzE,eAAO,MAAM,sBAAsB,QAAkB,CAAC;AACtD,+EAA+E;AAC/E,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,sGAAsG;AACtG,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,sBAAsB,EAAE,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,2BAA2B;IACtC,QAAQ,CAAC,OAAO,kCAAyC;IAEzD,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAU3D,GAAG,CAAC,UAAU,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS;IAIxD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIhC,KAAK,IAAI,IAAI;CAGd;AAED,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AA2ErD,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,2BAA2B,EAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAAE,CAAC,CA0B5F;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,KAAK,8BAAoC,GACxC,cAAc,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAc1C"}
|
package/dist/write-execution.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
|
-
import { createWriteToolDefinition, generateDiffString, generateUnifiedPatch, withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
/** Maximum UTF-8 size of the durable display diff plus unified patch. */
|
|
5
|
-
export const MAX_DURABLE_DIFF_BYTES = 4 * 1024 * 1024;
|
|
6
|
-
/** Avoid retaining arbitrarily large previous files in the live-only store. */
|
|
7
|
-
export const MAX_COMPARABLE_WRITE_BYTES = 512_000;
|
|
8
|
-
export const MAX_WRITE_METADATA_ENTRIES = 100;
|
|
9
|
-
export class WriteExecutionMetadataStore {
|
|
10
|
-
entries = new Map();
|
|
11
|
-
set(toolCallId, metadata) {
|
|
12
|
-
this.entries.delete(toolCallId);
|
|
13
|
-
this.entries.set(toolCallId, metadata);
|
|
14
|
-
while (this.entries.size > MAX_WRITE_METADATA_ENTRIES) {
|
|
15
|
-
const oldest = this.entries.keys().next().value;
|
|
16
|
-
if (oldest === undefined)
|
|
17
|
-
break;
|
|
18
|
-
this.entries.delete(oldest);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
get(toolCallId) {
|
|
22
|
-
return typeof toolCallId === "string" ? this.entries.get(toolCallId) : undefined;
|
|
23
|
-
}
|
|
24
|
-
delete(toolCallId) {
|
|
25
|
-
this.entries.delete(toolCallId);
|
|
26
|
-
}
|
|
27
|
-
clear() {
|
|
28
|
-
this.entries.clear();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function resolveWritePath(path, cwd) {
|
|
32
|
-
if (path === "~")
|
|
33
|
-
return process.env.HOME ?? cwd;
|
|
34
|
-
if (path.startsWith("~/") || path.startsWith("~\\")) {
|
|
35
|
-
return resolve(process.env.HOME ?? cwd, path.slice(2));
|
|
36
|
-
}
|
|
37
|
-
return isAbsolute(path) ? path : resolve(cwd, path);
|
|
38
|
-
}
|
|
39
|
-
async function capturePreviousContent(absolutePath) {
|
|
40
|
-
let info;
|
|
41
|
-
try {
|
|
42
|
-
info = await lstat(absolutePath);
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
if (error?.code === "ENOENT")
|
|
46
|
-
return { fileExistedBeforeWrite: false, previousContent: "" };
|
|
47
|
-
return {
|
|
48
|
-
fileExistedBeforeWrite: true,
|
|
49
|
-
diffUnavailableReason: "unable to inspect the previous file",
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (!info.isFile()) {
|
|
53
|
-
return {
|
|
54
|
-
fileExistedBeforeWrite: true,
|
|
55
|
-
diffUnavailableReason: "previous path is not a regular file",
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
if (info.size > MAX_COMPARABLE_WRITE_BYTES) {
|
|
59
|
-
return {
|
|
60
|
-
fileExistedBeforeWrite: true,
|
|
61
|
-
diffUnavailableReason: `previous file exceeds ${MAX_COMPARABLE_WRITE_BYTES} bytes`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
const bytes = await readFile(absolutePath);
|
|
66
|
-
if (bytes.byteLength > MAX_COMPARABLE_WRITE_BYTES) {
|
|
67
|
-
return {
|
|
68
|
-
fileExistedBeforeWrite: true,
|
|
69
|
-
diffUnavailableReason: `previous file exceeds ${MAX_COMPARABLE_WRITE_BYTES} bytes`,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const previousContent = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
73
|
-
return { fileExistedBeforeWrite: true, previousContent };
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
return {
|
|
77
|
-
fileExistedBeforeWrite: true,
|
|
78
|
-
diffUnavailableReason: "previous file is not comparable UTF-8 text",
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function durableDetails(metadata, path, content) {
|
|
83
|
-
if (metadata.diffUnavailableReason) {
|
|
84
|
-
return { diffUnavailableReason: metadata.diffUnavailableReason };
|
|
85
|
-
}
|
|
86
|
-
const previousContent = metadata.previousContent ?? "";
|
|
87
|
-
const diffResult = generateDiffString(previousContent, content);
|
|
88
|
-
const patch = generateUnifiedPatch(path, previousContent, content);
|
|
89
|
-
const totalBytes = Buffer.byteLength(diffResult.diff, "utf8") + Buffer.byteLength(patch, "utf8");
|
|
90
|
-
if (totalBytes > MAX_DURABLE_DIFF_BYTES) {
|
|
91
|
-
return { diffUnavailableReason: `durable diff exceeds ${MAX_DURABLE_DIFF_BYTES} bytes` };
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
diff: diffResult.diff,
|
|
95
|
-
patch,
|
|
96
|
-
firstChangedLine: diffResult.firstChangedLine,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
export async function executeWriteWithMetadata(store, toolCallId, params, signal, cwd) {
|
|
100
|
-
const absolutePath = resolveWritePath(params.path, cwd);
|
|
101
|
-
store.delete(toolCallId);
|
|
102
|
-
return withFileMutationQueue(absolutePath, async () => {
|
|
103
|
-
const throwIfAborted = () => {
|
|
104
|
-
if (signal?.aborted)
|
|
105
|
-
throw new Error("Operation aborted");
|
|
106
|
-
};
|
|
107
|
-
throwIfAborted();
|
|
108
|
-
const metadata = await capturePreviousContent(absolutePath);
|
|
109
|
-
throwIfAborted();
|
|
110
|
-
await mkdir(dirname(absolutePath), { recursive: true });
|
|
111
|
-
throwIfAborted();
|
|
112
|
-
await writeFile(absolutePath, params.content, "utf8");
|
|
113
|
-
throwIfAborted();
|
|
114
|
-
const details = durableDetails(metadata, params.path, params.content);
|
|
115
|
-
store.set(toolCallId, { ...metadata, ...details });
|
|
116
|
-
return {
|
|
117
|
-
content: [{ type: "text", text: `Successfully wrote to ${params.path}` }],
|
|
118
|
-
details,
|
|
119
|
-
};
|
|
120
|
-
}).catch((error) => {
|
|
121
|
-
store.delete(toolCallId);
|
|
122
|
-
throw error;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* A session-local write definition. It retains Pi's public schema/description
|
|
127
|
-
* and replaces only execution so the parent registry is never mutated.
|
|
128
|
-
*/
|
|
129
|
-
export function createTrackedWriteTool(cwd, store = new WriteExecutionMetadataStore()) {
|
|
130
|
-
const nativeWrite = createWriteToolDefinition(cwd);
|
|
131
|
-
return {
|
|
132
|
-
...nativeWrite,
|
|
133
|
-
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
134
|
-
return executeWriteWithMetadata(store, toolCallId, params, signal, ctx.cwd || cwd);
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=write-execution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write-execution.js","sourceRoot":"","sources":["../src/write-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAyB,kB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,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAW,EACX,KAAK,GAAG,IAAI,2BAA2B,EAAE;IAEzC,MAAM,WAAW,GAAG,yBAAyB,CAAC,GAAG,CAAC,CAAC;IACnD,OAAO;QACL,GAAG,WAAW;QACd,KAAK,CAAC,OAAO,CACX,UAAkB,EAClB,MAAmB,EACnB,MAA+B,EAC/B,SAAkB,EAClB,GAAqB;YAErB,OAAO,wBAAwB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;QACrF,CAAC;KAC0C,CAAC;AAChD,CAAC"}
|
package/dist/xml.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* xml.ts — escaping for the `<task-notification>` payloads.
|
|
3
|
-
*
|
|
4
|
-
* A module of its own because both notification builders need it and they sit
|
|
5
|
-
* on opposite sides of a dependency edge: the agent one lives in `index.ts`,
|
|
6
|
-
* which imports `workflow/task.ts`, so the workflow one cannot reach back for
|
|
7
|
-
* it without a cycle.
|
|
8
|
-
*/
|
|
9
|
-
/** Escape XML special characters to prevent injection in structured notifications. */
|
|
10
|
-
export declare function escapeXml(s: string): string;
|
|
11
|
-
//# sourceMappingURL=xml.d.ts.map
|
package/dist/xml.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../src/xml.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sFAAsF;AACtF,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3C"}
|
package/dist/xml.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* xml.ts — escaping for the `<task-notification>` payloads.
|
|
3
|
-
*
|
|
4
|
-
* A module of its own because both notification builders need it and they sit
|
|
5
|
-
* on opposite sides of a dependency edge: the agent one lives in `index.ts`,
|
|
6
|
-
* which imports `workflow/task.ts`, so the workflow one cannot reach back for
|
|
7
|
-
* it without a cycle.
|
|
8
|
-
*/
|
|
9
|
-
/** Escape XML special characters to prevent injection in structured notifications. */
|
|
10
|
-
export function escapeXml(s) {
|
|
11
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=xml.js.map
|
package/dist/xml.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xml.js","sourceRoot":"","sources":["../src/xml.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sFAAsF;AACtF,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC"}
|
package/src/abortable.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* abortable.ts — race a promise against an AbortSignal without cancelling the
|
|
3
|
-
* underlying work.
|
|
4
|
-
*
|
|
5
|
-
* Used by the `get_subagent_result` wait paths (top-level and nested): pressing
|
|
6
|
-
* Esc cancels only the caller's wait; the background child keeps running and its
|
|
7
|
-
* result stays unconsumed. The listener is removed on every settle path so the
|
|
8
|
-
* signal accumulates no handlers, and a late settlement of the wrapped promise
|
|
9
|
-
* after an abort is absorbed as a no-op (no unhandled rejection).
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/** Await a promise until it settles or the caller cancels, without aborting the underlying work. */
|
|
13
|
-
export function abortable<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
14
|
-
if (!signal) return promise;
|
|
15
|
-
if (signal.aborted) return Promise.reject(signal.reason);
|
|
16
|
-
|
|
17
|
-
return new Promise<T>((resolve, reject) => {
|
|
18
|
-
let settled = false;
|
|
19
|
-
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
20
|
-
const onAbort = () => {
|
|
21
|
-
if (settled) return;
|
|
22
|
-
settled = true;
|
|
23
|
-
cleanup();
|
|
24
|
-
reject(signal.reason);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
28
|
-
promise.then(
|
|
29
|
-
(value) => {
|
|
30
|
-
if (settled) return;
|
|
31
|
-
settled = true;
|
|
32
|
-
cleanup();
|
|
33
|
-
resolve(value);
|
|
34
|
-
},
|
|
35
|
-
(error: unknown) => {
|
|
36
|
-
if (settled) return;
|
|
37
|
-
settled = true;
|
|
38
|
-
cleanup();
|
|
39
|
-
reject(error);
|
|
40
|
-
},
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
}
|