pi-cowboy 0.17.2 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/agents/agent-assets.d.ts +0 -57
- package/dist/agents/agent-cleanup.d.ts +0 -25
- package/dist/agents/agent-discovery.d.ts +0 -15
- package/dist/agents/agent-host.d.ts +2 -121
- package/dist/agents/agent-manager.d.ts +0 -54
- package/dist/agents/agent-reviver.d.ts +0 -23
- package/dist/agents/agent-runner.d.ts +0 -24
- package/dist/agents/agent-spawn-store.d.ts +0 -26
- package/dist/agents/agent-template.d.ts +5 -9
- package/dist/agents/agent-types.d.ts +0 -22
- package/dist/agents/batch.d.ts +0 -35
- package/dist/agents/cleanup-policy.d.ts +1 -90
- package/dist/agents/cleanup-report.d.ts +0 -9
- package/dist/agents/default-agents.d.ts +0 -6
- package/dist/agents/harness/claude/index.d.ts +0 -38
- package/dist/agents/harness/claude/staging.d.ts +0 -39
- package/dist/agents/harness/codex.d.ts +0 -40
- package/dist/agents/harness/harness-registry.d.ts +8 -103
- package/dist/agents/harness/opencode/config.d.ts +0 -30
- package/dist/agents/harness/opencode/definition.d.ts +0 -12
- package/dist/agents/harness/opencode/index.d.ts +1 -31
- package/dist/agents/harness/opencode/permissions.d.ts +0 -20
- package/dist/agents/harness/opencode/staging.d.ts +0 -36
- package/dist/agents/harness/opencode/user-config.d.ts +0 -29
- package/dist/agents/harness/opencode/version.d.ts +2 -24
- package/dist/agents/harness/pane-launcher.d.ts +0 -72
- package/dist/agents/harness/pi-bolt.d.ts +0 -8
- package/dist/agents/harness/pi-compatible.d.ts +0 -39
- package/dist/agents/harness/pig.d.ts +0 -9
- package/dist/agents/harness.d.ts +26 -323
- package/dist/agents/multiplexer-registry.d.ts +0 -82
- package/dist/agents/result-file-permissions.d.ts +0 -15
- package/dist/agents/run-state.d.ts +0 -64
- package/dist/agents/schemas/cleanup-batch.schema.d.ts +0 -12
- package/dist/agents/schemas/cowboy-agents.schema.d.ts +0 -30
- package/dist/agents/schemas/merge-batch.schema.d.ts +0 -14
- package/dist/agents/schemas/steer-batch.schema.d.ts +0 -13
- package/dist/agents/schemas/stop-batch.schema.d.ts +0 -11
- package/dist/agents/spawn-defaults.d.ts +0 -37
- package/dist/agents/subagent-session.d.ts +1 -80
- package/dist/agents/tool-cleanup.d.ts +0 -24
- package/dist/agents/tool-execution.d.ts +0 -31
- package/dist/agents/tool-merge.d.ts +0 -27
- package/dist/agents/tool-result.d.ts +0 -12
- package/dist/agents/tool-steer.d.ts +1 -21
- package/dist/agents/types.d.ts +4 -58
- package/dist/availability.d.ts +0 -31
- package/dist/chunk-6YO5MFLJ.js +15 -0
- package/dist/chunk-C4LB3YEQ.js +2 -0
- package/dist/chunk-DPYRC7JC.js +10 -0
- package/dist/chunk-OBX2DB6I.js +2 -0
- package/dist/chunk-OO54ZZLJ.js +2 -0
- package/dist/chunk-VHFNXQY4.js +24 -0
- package/dist/concurrency-pools.d.ts +0 -108
- package/dist/config/concurrency-limit.d.ts +0 -8
- package/dist/config/config-io.d.ts +0 -20
- package/dist/config/config-store.d.ts +22 -93
- package/dist/config/config-validation.d.ts +0 -3
- package/dist/config/layered-config.d.ts +0 -27
- package/dist/config/types.d.ts +7 -6
- package/dist/cow-support-launch.d.ts +0 -15
- package/dist/events.d.ts +0 -7
- package/dist/extension-toggle.d.ts +0 -9
- package/dist/harness-availability-launch.d.ts +0 -37
- package/dist/host-multiplexer.d.ts +0 -36
- package/dist/index.d.ts +0 -8
- package/dist/index.js +33 -54
- package/dist/infrastructure/exec-path.d.ts +0 -11
- package/dist/infrastructure/exec-sync.d.ts +0 -17
- package/dist/infrastructure/git/cow-clone.d.ts +0 -60
- package/dist/infrastructure/git/git-materializer.d.ts +3 -109
- package/dist/infrastructure/git/git-merger.d.ts +0 -74
- package/dist/infrastructure/git/git-retention.d.ts +0 -15
- package/dist/infrastructure/git/git-runner.d.ts +0 -53
- package/dist/infrastructure/git/git-worktree.d.ts +4 -57
- package/dist/infrastructure/git/index.d.ts +0 -6
- package/dist/infrastructure/git-client.d.ts +0 -10
- package/dist/infrastructure/herdr/agent-stopper.d.ts +0 -19
- package/dist/infrastructure/herdr/agents.d.ts +0 -77
- package/dist/infrastructure/herdr/herdr-client.d.ts +0 -10
- package/dist/infrastructure/herdr/herdr-transport.d.ts +0 -33
- package/dist/infrastructure/herdr/index.d.ts +0 -8
- package/dist/infrastructure/herdr/panes.d.ts +0 -45
- package/dist/infrastructure/herdr/polling.d.ts +0 -22
- package/dist/infrastructure/herdr/worktrees.d.ts +0 -14
- package/dist/infrastructure/herdr-client.d.ts +0 -5
- package/dist/infrastructure/herdr-host.d.ts +0 -7
- package/dist/logger.d.ts +0 -4
- package/dist/menu-worktree-command-JOT3F3SK.js +3 -0
- package/dist/menus-QMIIYRHM.js +9 -0
- package/dist/model-picker-EU2MA3II.js +2 -0
- package/dist/models/foreign-model-resolver.d.ts +3 -33
- package/dist/models/model-groups.d.ts +23 -31
- package/dist/models/model-precedence.d.ts +26 -80
- package/dist/models/model-request-types.d.ts +14 -27
- package/dist/models/model-request.d.ts +3 -34
- package/dist/models/pi-model-resolver.d.ts +7 -30
- package/dist/models/thinking-offering.d.ts +19 -0
- package/dist/orchestrators/briefing-section.d.ts +0 -8
- package/dist/orchestrators/context.d.ts +0 -57
- package/dist/orchestrators/cues.d.ts +0 -19
- package/dist/orchestrators/default-orchestrators.d.ts +0 -8
- package/dist/orchestrators/orchestrator-discovery.d.ts +0 -20
- package/dist/orchestrators/orchestrator-template.d.ts +0 -10
- package/dist/orchestrators/orchestrator-types.d.ts +0 -15
- package/dist/orchestrators/protocol.d.ts +4 -74
- package/dist/orchestrators/types.d.ts +0 -10
- package/dist/paths.d.ts +0 -34
- package/dist/pi-settings.d.ts +0 -1
- package/dist/plugin/contract.d.ts +0 -43
- package/dist/plugin/discovery.d.ts +0 -47
- package/dist/plugin/index.d.ts +2 -14
- package/dist/plugin/index.js +2 -14
- package/dist/plugin/loader.d.ts +0 -36
- package/dist/plugin/manifest.d.ts +0 -20
- package/dist/predicates.d.ts +0 -16
- package/dist/prompt/prompts.d.ts +0 -21
- package/dist/prompt/skill-loader.d.ts +0 -15
- package/dist/prompt/subagent-system-prompt.d.ts +0 -30
- package/dist/registration.d.ts +0 -25
- package/dist/session-runtime.d.ts +0 -30
- package/dist/shell.d.ts +7 -84
- package/dist/spawn/cow-support.d.ts +0 -21
- package/dist/spawn/crockford-base32.d.ts +0 -12
- package/dist/spawn/herdr-launcher.d.ts +0 -14
- package/dist/spawn/repo-lock.d.ts +0 -17
- package/dist/spawn/sandbox.d.ts +0 -60
- package/dist/spawn/spawn-coordinator.d.ts +0 -45
- package/dist/spawn/spawn-id.d.ts +0 -15
- package/dist/spawn/worktree-policy.d.ts +0 -48
- package/dist/status-note.d.ts +0 -5
- package/dist/subagent/deliverable.d.ts +0 -28
- package/dist/subagent/pane-supervisor.d.ts +0 -16
- package/dist/subagent/result-artifacts.d.ts +0 -15
- package/dist/subagent/supervisor.d.ts +0 -97
- package/dist/task-registry.d.ts +0 -34
- package/dist/templates/template-files.d.ts +0 -25
- package/dist/types.d.ts +26 -127
- package/dist/ui/action-report.d.ts +0 -17
- package/dist/ui/format.d.ts +0 -8
- package/dist/ui/indicator.d.ts +0 -140
- package/dist/ui/menu/helpers.d.ts +0 -54
- package/dist/ui/menu/menu-agent-settings.d.ts +0 -6
- package/dist/ui/menu/menu-agent-status-cleanup.d.ts +0 -24
- package/dist/ui/menu/menu-agent-status.d.ts +0 -14
- package/dist/ui/menu/menu-concurrency.d.ts +1 -6
- package/dist/ui/menu/menu-model-settings.d.ts +1 -16
- package/dist/ui/menu/menu-spawn-defaults.d.ts +0 -9
- package/dist/ui/menu/menu-spawn-options.d.ts +15 -0
- package/dist/ui/menu/menu-spawn-wizard.d.ts +0 -4
- package/dist/ui/menu/menu-spawn-worktree.d.ts +0 -23
- package/dist/ui/menu/menu-system-prompt.d.ts +0 -4
- package/dist/ui/menu/menu-worktree-command.d.ts +0 -15
- package/dist/ui/menu/menus.d.ts +0 -15
- package/dist/ui/menu/model-pairing.d.ts +19 -0
- package/dist/ui/menu/model-picker.d.ts +0 -12
- package/dist/ui/menu/screen-host.d.ts +0 -50
- package/dist/ui/menu/spawn-choice.d.ts +36 -0
- package/dist/ui/menu/submenus/confirm.d.ts +0 -10
- package/dist/ui/menu/submenus/model-select.d.ts +18 -17
- package/dist/ui/menu/submenus/name-field.d.ts +0 -19
- package/dist/ui/menu/submenus/numeric-input.d.ts +0 -4
- package/dist/ui/menu/submenus/target-select.d.ts +2 -45
- package/dist/ui/menu/submenus/text-editor.d.ts +0 -21
- package/dist/ui/menu/submenus/thinking-select.d.ts +13 -0
- package/dist/ui/menu/submenus/worktree-command-name.d.ts +0 -19
- package/dist/ui/menu/submenus/worktree-name.d.ts +0 -18
- package/dist/ui/menu/wrappers/settings-list.d.ts +0 -13
- package/dist/ui/searchable-select.d.ts +0 -8
- package/dist/ui/types.d.ts +0 -1
- package/dist/utils.d.ts +3 -26
- package/package.json +5 -3
- package/dist/agents/agent-assets.js +0 -278
- package/dist/agents/agent-cleanup.js +0 -323
- package/dist/agents/agent-discovery.js +0 -118
- package/dist/agents/agent-host.js +0 -13
- package/dist/agents/agent-manager.js +0 -325
- package/dist/agents/agent-reviver.js +0 -59
- package/dist/agents/agent-runner.js +0 -321
- package/dist/agents/agent-spawn-store.js +0 -57
- package/dist/agents/agent-template.js +0 -152
- package/dist/agents/agent-types.js +0 -159
- package/dist/agents/batch.js +0 -92
- package/dist/agents/cleanup-policy.js +0 -218
- package/dist/agents/cleanup-report.js +0 -135
- package/dist/agents/default-agents.js +0 -19
- package/dist/agents/harness/claude/index.js +0 -263
- package/dist/agents/harness/claude/staging.js +0 -103
- package/dist/agents/harness/codex.js +0 -250
- package/dist/agents/harness/harness-registry.js +0 -272
- package/dist/agents/harness/opencode/config.js +0 -85
- package/dist/agents/harness/opencode/definition.js +0 -63
- package/dist/agents/harness/opencode/index.js +0 -297
- package/dist/agents/harness/opencode/permissions.js +0 -48
- package/dist/agents/harness/opencode/staging.js +0 -72
- package/dist/agents/harness/opencode/user-config.js +0 -172
- package/dist/agents/harness/opencode/version.js +0 -43
- package/dist/agents/harness/pane-launcher.js +0 -97
- package/dist/agents/harness/pi-bolt.js +0 -14
- package/dist/agents/harness/pi-compatible.js +0 -112
- package/dist/agents/harness/pig.js +0 -15
- package/dist/agents/harness.js +0 -99
- package/dist/agents/multiplexer-registry.js +0 -125
- package/dist/agents/result-file-permissions.js +0 -29
- package/dist/agents/run-state.js +0 -270
- package/dist/agents/schemas/cleanup-batch.schema.js +0 -19
- package/dist/agents/schemas/cowboy-agents.schema.js +0 -50
- package/dist/agents/schemas/merge-batch.schema.js +0 -25
- package/dist/agents/schemas/steer-batch.schema.js +0 -22
- package/dist/agents/schemas/stop-batch.schema.js +0 -18
- package/dist/agents/spawn-defaults.js +0 -113
- package/dist/agents/subagent-session.js +0 -578
- package/dist/agents/tool-cleanup.js +0 -57
- package/dist/agents/tool-execution.js +0 -132
- package/dist/agents/tool-merge.js +0 -190
- package/dist/agents/tool-result.js +0 -17
- package/dist/agents/tool-steer.js +0 -89
- package/dist/agents/types.js +0 -1
- package/dist/availability.js +0 -45
- package/dist/concurrency-pools.js +0 -272
- package/dist/config/concurrency-limit.js +0 -14
- package/dist/config/config-io.js +0 -270
- package/dist/config/config-store.js +0 -487
- package/dist/config/config-validation.js +0 -280
- package/dist/config/layered-config.js +0 -121
- package/dist/config/types.js +0 -25
- package/dist/cow-support-launch.js +0 -43
- package/dist/events.js +0 -204
- package/dist/extension-toggle.js +0 -28
- package/dist/harness-availability-launch.js +0 -85
- package/dist/host-multiplexer.js +0 -62
- package/dist/infrastructure/exec-path.js +0 -35
- package/dist/infrastructure/exec-sync.js +0 -30
- package/dist/infrastructure/git/cow-clone.js +0 -406
- package/dist/infrastructure/git/git-materializer.js +0 -342
- package/dist/infrastructure/git/git-merger.js +0 -234
- package/dist/infrastructure/git/git-retention.js +0 -43
- package/dist/infrastructure/git/git-runner.js +0 -173
- package/dist/infrastructure/git/git-worktree.js +0 -145
- package/dist/infrastructure/git/index.js +0 -11
- package/dist/infrastructure/git-client.js +0 -11
- package/dist/infrastructure/herdr/agent-stopper.js +0 -60
- package/dist/infrastructure/herdr/agents.js +0 -330
- package/dist/infrastructure/herdr/herdr-client.js +0 -36
- package/dist/infrastructure/herdr/herdr-transport.js +0 -158
- package/dist/infrastructure/herdr/index.js +0 -15
- package/dist/infrastructure/herdr/panes.js +0 -174
- package/dist/infrastructure/herdr/polling.js +0 -44
- package/dist/infrastructure/herdr/worktrees.js +0 -76
- package/dist/infrastructure/herdr-client.js +0 -6
- package/dist/infrastructure/herdr-host.js +0 -214
- package/dist/logger.js +0 -77
- package/dist/models/foreign-model-resolver.js +0 -55
- package/dist/models/model-groups.js +0 -74
- package/dist/models/model-precedence.js +0 -90
- package/dist/models/model-request-types.js +0 -46
- package/dist/models/model-request.js +0 -39
- package/dist/models/pi-model-resolver.js +0 -88
- package/dist/orchestrators/briefing-section.js +0 -14
- package/dist/orchestrators/context.js +0 -122
- package/dist/orchestrators/cues.js +0 -90
- package/dist/orchestrators/default-orchestrators.js +0 -41
- package/dist/orchestrators/orchestrator-discovery.js +0 -68
- package/dist/orchestrators/orchestrator-template.js +0 -43
- package/dist/orchestrators/orchestrator-types.js +0 -78
- package/dist/orchestrators/protocol.js +0 -325
- package/dist/orchestrators/types.js +0 -7
- package/dist/paths.js +0 -104
- package/dist/pi-settings.js +0 -7
- package/dist/plugin/contract.js +0 -17
- package/dist/plugin/discovery.js +0 -67
- package/dist/plugin/loader.js +0 -181
- package/dist/plugin/manifest.js +0 -47
- package/dist/predicates.js +0 -25
- package/dist/prompt/prompts.js +0 -110
- package/dist/prompt/skill-loader.js +0 -153
- package/dist/prompt/subagent-system-prompt.js +0 -180
- package/dist/registration.js +0 -246
- package/dist/session-runtime.js +0 -92
- package/dist/shell.js +0 -223
- package/dist/spawn/cow-support.js +0 -53
- package/dist/spawn/crockford-base32.js +0 -252
- package/dist/spawn/herdr-launcher.js +0 -80
- package/dist/spawn/repo-lock.js +0 -34
- package/dist/spawn/sandbox.js +0 -289
- package/dist/spawn/spawn-coordinator.js +0 -257
- package/dist/spawn/spawn-id.js +0 -39
- package/dist/spawn/worktree-policy.js +0 -137
- package/dist/status-note.js +0 -30
- package/dist/subagent/deliverable.js +0 -40
- package/dist/subagent/pane-supervisor.js +0 -15
- package/dist/subagent/result-artifacts.js +0 -25
- package/dist/subagent/supervisor.js +0 -317
- package/dist/task-registry.js +0 -112
- package/dist/templates/template-files.js +0 -88
- package/dist/types.js +0 -77
- package/dist/ui/action-report.js +0 -21
- package/dist/ui/format.js +0 -54
- package/dist/ui/indicator.js +0 -495
- package/dist/ui/menu/helpers.js +0 -245
- package/dist/ui/menu/menu-agent-settings.js +0 -191
- package/dist/ui/menu/menu-agent-status-cleanup.js +0 -203
- package/dist/ui/menu/menu-agent-status.js +0 -364
- package/dist/ui/menu/menu-concurrency.js +0 -410
- package/dist/ui/menu/menu-model-settings.js +0 -330
- package/dist/ui/menu/menu-spawn-defaults.js +0 -73
- package/dist/ui/menu/menu-spawn-wizard.js +0 -371
- package/dist/ui/menu/menu-spawn-worktree.js +0 -107
- package/dist/ui/menu/menu-system-prompt.js +0 -104
- package/dist/ui/menu/menu-worktree-command.js +0 -150
- package/dist/ui/menu/menus.js +0 -187
- package/dist/ui/menu/model-picker.js +0 -175
- package/dist/ui/menu/screen-host.js +0 -87
- package/dist/ui/menu/submenus/confirm.js +0 -60
- package/dist/ui/menu/submenus/model-select.js +0 -39
- package/dist/ui/menu/submenus/name-field.js +0 -43
- package/dist/ui/menu/submenus/numeric-input.js +0 -61
- package/dist/ui/menu/submenus/target-select.js +0 -129
- package/dist/ui/menu/submenus/text-editor.js +0 -49
- package/dist/ui/menu/submenus/worktree-command-name.js +0 -73
- package/dist/ui/menu/submenus/worktree-name.js +0 -53
- package/dist/ui/menu/wrappers/settings-list.js +0 -101
- package/dist/ui/searchable-select.js +0 -147
- package/dist/ui/types.js +0 -1
- package/dist/utils.js +0 -80
package/README.md
CHANGED
|
@@ -32,9 +32,9 @@ The numbers below come from a Git repository on macOS with 153,607 files in tota
|
|
|
32
32
|
|
|
33
33
|
| Method | Including untracked | Size on disk |
|
|
34
34
|
| ---------------------------------------------- | ------------------- | ------------ |
|
|
35
|
-
| Pi-cowboy's copy-on-write | yes
|
|
36
|
-
| Classic `git worktree add` | no
|
|
37
|
-
| Classic `git worktree add` + copy of untracked | yes
|
|
35
|
+
| Pi-cowboy's copy-on-write | yes ✅ | 75 MiB |
|
|
36
|
+
| Classic `git worktree add` | no ❌ | 479 MiB |
|
|
37
|
+
| Classic `git worktree add` + copy of untracked | yes ✅ | 27 GiB |
|
|
38
38
|
|
|
39
39
|
### Live visibility in Herdr
|
|
40
40
|
|
|
@@ -1,114 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-assets.ts — located-artifacts seam: locate a run's work, then act on it.
|
|
3
|
-
* AgentAssets: locate/observe/deliverable + actuators. AgentAssetsDeps: raw probes it composes.
|
|
4
|
-
* LocateResult: Located (tracked/recovered) | Ambiguous | NotFound.
|
|
5
|
-
* CleanupDeps: injected host/git actuators. PaneRef/LocatedCandidate: addresses.
|
|
6
|
-
* createAgentAssets: bind over probes. createMultiplexerAgentAssets: bind to a session's multiplexer.
|
|
7
|
-
* Authority is per-asset: provenance (worktreeManaged/paneCreated) is memory-only;
|
|
8
|
-
* addresses (workspace/pane/branch/path) are live probes (memory can be stale, not just absent).
|
|
9
|
-
* Unreadable registries degrade to memory's answer, never to absence.
|
|
10
|
-
*/
|
|
11
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
12
2
|
import type { AgentSpawn } from "../types.js";
|
|
13
3
|
import type { BranchCleanupResult, DeleteBranchOptions } from "../infrastructure/git-client.js";
|
|
14
4
|
import type { AgentMultiplexer, AgentHost, AgentHostRef, HostObservation, PlacementCatalog, PlacementRecord, PlacementWorktree } from "./agent-host.js";
|
|
15
5
|
import type { AnyHarnessId, HarnessTeardownContext } from "./harness.js";
|
|
16
6
|
import type { CleanupSource, LocatedArtifacts, RecoveredDeliverable } from "./cleanup-policy.js";
|
|
17
|
-
/**
|
|
18
|
-
* Injected host/git actuators. Host ops take the run's address (bound to release/close, never stop); git ops stay path-based (the host never destroys filesystem state).
|
|
19
|
-
* Function-typed properties, not methods: these are bare injected functions, and callers hand them on as values (`deps.isWorktreeDirty`).
|
|
20
|
-
*/
|
|
21
7
|
export interface CleanupDeps {
|
|
22
|
-
/** Dirty/unverifiable retention probe. */
|
|
23
8
|
isWorktreeDirty: (worktreePath: string) => Promise<boolean | undefined>;
|
|
24
|
-
/** Filesystem probe (injected; this module never touches the filesystem). */
|
|
25
9
|
worktreeExists: (worktreePath: string) => Promise<boolean>;
|
|
26
|
-
/** Drop the worktree association, returning true only when confirmed gone. */
|
|
27
10
|
removeWorktree: (ref: AgentHostRef) => Promise<boolean>;
|
|
28
|
-
/** Remove a checkout that was never adopted into herdr. */
|
|
29
11
|
removeGitWorktree: (worktreePath: string, repoCwd: string) => Promise<boolean>;
|
|
30
|
-
/** Delete the branch a removed worktree carried once it is merged and unattached. */
|
|
31
12
|
deleteBranch: (options: DeleteBranchOptions) => Promise<BranchCleanupResult>;
|
|
32
|
-
/** Close a self-created placement. */
|
|
33
13
|
closePane: (ref: AgentHostRef) => Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Teardown of the harness state one ended run's pane was prepared with —
|
|
36
|
-
* ordered before any worktree dirty probe, see Harness.teardown. The bound
|
|
37
|
-
* actuator resolves the recorded harness and supplies the pi instance.
|
|
38
|
-
*/
|
|
39
14
|
harnessTeardown: (harness: AnyHarnessId, context: HarnessTeardownContext) => Promise<void>;
|
|
40
15
|
}
|
|
41
16
|
export interface PaneRef {
|
|
42
17
|
readonly paneId: string;
|
|
43
18
|
}
|
|
44
|
-
/** One artifact pair answering to a contested id (ambiguity payload). */
|
|
45
19
|
interface LocatedCandidate {
|
|
46
20
|
worktreePath: string;
|
|
47
21
|
branch: string;
|
|
48
22
|
workspaceId?: string;
|
|
49
23
|
}
|
|
50
|
-
/** The located artifacts plus where they came from. */
|
|
51
24
|
export interface Located extends LocatedArtifacts {
|
|
52
25
|
kind: "located";
|
|
53
|
-
/** `tracked` (spawn record named them) or `recovered` (discovery did). */
|
|
54
26
|
source: CleanupSource;
|
|
55
27
|
}
|
|
56
|
-
/** Two artifacts answer to one id. The caller arbitrates; cleanup refuses. */
|
|
57
28
|
export interface Ambiguous {
|
|
58
29
|
kind: "ambiguous";
|
|
59
30
|
id: string;
|
|
60
31
|
candidates: readonly LocatedCandidate[];
|
|
61
32
|
}
|
|
62
|
-
/** Nothing answers to this id (no record, worktree, or proven branch). */
|
|
63
33
|
interface NotFound {
|
|
64
34
|
kind: "not-found";
|
|
65
35
|
id: string;
|
|
66
36
|
}
|
|
67
37
|
export type LocateResult = Located | Ambiguous | NotFound;
|
|
68
|
-
/** The seam: locate an agent's artifacts, then act on them. Injected probes are function-typed properties (see CleanupDeps). */
|
|
69
38
|
export interface AgentAssets extends CleanupDeps {
|
|
70
|
-
/**
|
|
71
|
-
* The multiplexer every address this seam builds belongs to (see hostRefFor in
|
|
72
|
-
* agent-cleanup.ts). It rides here rather than on `CleanupDeps` because only
|
|
73
|
-
* the locator produces addresses; the allocation-failure path consumes them.
|
|
74
|
-
*/
|
|
75
39
|
multiplexer: AgentMultiplexer;
|
|
76
|
-
/** Run's deliverable, derived from the id alone without probing the run; reported, never deleted. */
|
|
77
40
|
deliverable: (id: string) => RecoveredDeliverable;
|
|
78
|
-
/** Locate one agent's artifacts (hint, else discovery); never stops anything — the pane is an address, not a process. */
|
|
79
41
|
locate(id: string, hint?: AgentSpawn): Promise<LocateResult>;
|
|
80
|
-
/** Raw liveness read: undefined = gone, a throw = unreadable (never evidence the run is over); no settlement verdict. */
|
|
81
42
|
observe(pane: PaneRef): Promise<HostObservation | undefined>;
|
|
82
43
|
}
|
|
83
|
-
/** Raw single-plane probes; matching/authority/ambiguity stay in this module so tests fake the planes. Injected probes are function-typed properties (see CleanupDeps). */
|
|
84
44
|
export interface AgentAssetsDeps extends CleanupDeps {
|
|
85
|
-
/** The multiplexer every address this seam builds belongs to. */
|
|
86
45
|
multiplexer: AgentMultiplexer;
|
|
87
|
-
/** Canonicalize a path the way the multiplexer spells its placements (see PlacementCatalog). */
|
|
88
46
|
canonicalizePath: (value: string) => string;
|
|
89
|
-
/** Run's deliverable and whether it exists. */
|
|
90
47
|
deliverable: (id: string) => RecoveredDeliverable;
|
|
91
|
-
/** Raw multiplexer registry read (the multiplexer's `worktree list`); a throw degrades discovery. */
|
|
92
48
|
listWorktrees: () => Promise<readonly PlacementWorktree[]>;
|
|
93
|
-
/** Raw multiplexer placement records (the multiplexer's `agent list`), nameless ones included. */
|
|
94
49
|
listPlacements: () => Promise<readonly PlacementRecord[]>;
|
|
95
|
-
/** One pane's raw state; undefined = gone, a throw = unreadable. */
|
|
96
50
|
readPane(paneId: string): Promise<HostObservation | undefined>;
|
|
97
|
-
/** The worktree root extension worktrees live under; undefined = unresolvable. */
|
|
98
51
|
worktreeRoot(): Promise<string | undefined>;
|
|
99
|
-
/** Entry names directly under `root` (the filesystem fallback). */
|
|
100
52
|
listRootEntries(root: string): Promise<readonly string[]>;
|
|
101
|
-
/** Main-checkout cwd derived from a checkout; undefined = it could not be resolved. */
|
|
102
53
|
resolveRepoCwd(worktreePath: string): Promise<string | undefined>;
|
|
103
54
|
}
|
|
104
|
-
/** Bind the seam over injected probes. */
|
|
105
55
|
export declare function createAgentAssets(deps: AgentAssetsDeps): AgentAssets;
|
|
106
|
-
/**
|
|
107
|
-
* Bind the seam to a session's multiplexer: the multiplexer's own reads come from the
|
|
108
|
-
* runtime's `PlacementCatalog` and its actuators from the runtime's `AgentHost`,
|
|
109
|
-
* so this module names no multiplexer. The rest — git, the filesystem, the config —
|
|
110
|
-
* is multiplexer-neutral and bound here. Failed repo derivation is `undefined` (never
|
|
111
|
-
* a borrowed cwd); failed pane reads throw (unreadable is not gone).
|
|
112
|
-
*/
|
|
113
56
|
export declare function createMultiplexerAgentAssets(pi: ExtensionAPI, host: AgentHost, catalog: PlacementCatalog): AgentAssets;
|
|
114
57
|
export {};
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-cleanup.ts — state-changing cleanup orchestration (policy lives in cleanup-policy.ts).
|
|
3
|
-
* createWorktreeTeardown: worktree/branch/pane removal over injected actuators.
|
|
4
|
-
* createCleanup: settled-or-recovered run cleanup over the assets seam.
|
|
5
|
-
* WorktreeTeardown/Cleanup: the two planes. WorktreeTeardownOutcome: removal result.
|
|
6
|
-
* WorktreeRemovalTarget: the address a teardown removes through.
|
|
7
|
-
* AgentCleanupRegistry: spawn lookup/drop surface.
|
|
8
|
-
* Report-gated (only ended runs are cleaned up; live runs are refused, never stopped);
|
|
9
|
-
* ordered: gate before removal, workspace before pane, branch only after confirmed checkout removal.
|
|
10
|
-
*/
|
|
11
1
|
import type { AgentSpawn, WorktreeRetentionReason } from "../types.js";
|
|
12
2
|
import type { BranchCleanupResult } from "../infrastructure/git-client.js";
|
|
13
3
|
import type { AgentHostRef } from "./agent-host.js";
|
|
14
4
|
import type { AgentAssets, CleanupDeps } from "./agent-assets.js";
|
|
15
5
|
import { type CleanupOptions, type CleanupReport, type PaneTarget, type WorktreeRemovalMechanism, type WorktreeTarget } from "./cleanup-policy.js";
|
|
16
6
|
export type { CleanupDeps } from "./agent-assets.js";
|
|
17
|
-
/** The agent-tracking surface cleanup needs — injected by the caller. */
|
|
18
7
|
export interface AgentCleanupRegistry {
|
|
19
8
|
getSpawn(id: string): AgentSpawn | undefined;
|
|
20
|
-
/** Drop a terminal spawn from tracking (after its resources are gone). */
|
|
21
9
|
dropSpawn(spawn: AgentSpawn): void;
|
|
22
10
|
}
|
|
23
11
|
export type WorktreeTeardownOutcome = {
|
|
@@ -38,20 +26,12 @@ export type WorktreeTeardownOutcome = {
|
|
|
38
26
|
path: string;
|
|
39
27
|
detail: string;
|
|
40
28
|
};
|
|
41
|
-
/** A checkout the multiplexer adopted: removal rides the host address. */
|
|
42
29
|
export type AdoptedWorktreeTarget = WorktreeTarget & {
|
|
43
30
|
workspaceId: string;
|
|
44
31
|
};
|
|
45
|
-
/** A pane the extension created: the only pane cleanup may close. */
|
|
46
32
|
type SelfCreatedPaneTarget = PaneTarget & {
|
|
47
33
|
origin: "self-created";
|
|
48
34
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Removal target: each legal case carries exactly the address it uses. A
|
|
51
|
-
* host-adopted tree removes through its ref; a git-only tree closes a
|
|
52
|
-
* self-created pane through its ref; a detached tree removes through git
|
|
53
|
-
* and carries no ref.
|
|
54
|
-
*/
|
|
55
35
|
export type WorktreeRemovalTarget = {
|
|
56
36
|
kind: "adopted";
|
|
57
37
|
worktree: AdoptedWorktreeTarget;
|
|
@@ -67,16 +47,11 @@ export type WorktreeRemovalTarget = {
|
|
|
67
47
|
worktree: WorktreeTarget;
|
|
68
48
|
pane: PaneTarget | null;
|
|
69
49
|
};
|
|
70
|
-
/** The state-changing teardown plane: worktree, then branch, then pane. */
|
|
71
50
|
interface WorktreeTeardown {
|
|
72
|
-
/** Tear down one worktree; a detached target runs only the git fallback; never stops an agent. */
|
|
73
51
|
removeWorktree(target: WorktreeRemovalTarget, opts?: CleanupOptions): Promise<WorktreeTeardownOutcome>;
|
|
74
52
|
}
|
|
75
53
|
interface Cleanup extends WorktreeTeardown {
|
|
76
|
-
/** Tear down one settled (or recovered) run's artifacts, then report. */
|
|
77
54
|
cleanupAgent(agentId: string, registry: AgentCleanupRegistry, opts?: CleanupOptions): Promise<CleanupReport>;
|
|
78
55
|
}
|
|
79
|
-
/** Bind the teardown plane over its actuators; an absent tree reports before any gate or removal runs. */
|
|
80
56
|
export declare function createWorktreeTeardown(deps: CleanupDeps): WorktreeTeardown;
|
|
81
|
-
/** Bind state-changing cleanup over the assets seam (the composition all callers use). */
|
|
82
57
|
export declare function createCleanup(assets: AgentAssets): Cleanup;
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-discovery.ts — Agent file discovery, parsing, and config merging.
|
|
3
|
-
*
|
|
4
|
-
* Scans user, shared, and project `*.toml` dirs through
|
|
5
|
-
* AgentTemplateSchema into AgentConfigs. Per-field precedence:
|
|
6
|
-
* default < user < shared < project.
|
|
7
|
-
*/
|
|
8
1
|
import { type TemplateNotify, type TemplateRefusal } from "../templates/template-files.js";
|
|
9
2
|
import { type AgentTemplate } from "./agent-template.js";
|
|
10
3
|
import type { AgentConfig } from "./types.js";
|
|
11
|
-
/** One parsed agent template. */
|
|
12
4
|
export type AgentTemplateFile = AgentTemplate;
|
|
13
|
-
/** Shape failures throw; the scanner turns that into a one-line skip warning. */
|
|
14
5
|
export declare function parseAgentFile(content: string): AgentTemplateFile;
|
|
15
|
-
/**
|
|
16
|
-
* Empty array when the directory doesn't exist. Stays shell-free: `notify` and
|
|
17
|
-
* `refuse` are injected, so the session's rules — which harness ids this
|
|
18
|
-
* session runs — are the caller's, not this module's.
|
|
19
|
-
*/
|
|
20
6
|
export declare function scanAgentFilesInDir(dirPath: string, notify?: TemplateNotify, refuse?: TemplateRefusal<AgentTemplateFile>): Promise<AgentTemplateFile[]>;
|
|
21
|
-
/** Per-field precedence: project > shared > user > extension > defaults. A set field wins; undefined falls through. */
|
|
22
7
|
export declare function mergeAgents(defaults: Map<string, AgentConfig>, userAgents: AgentTemplateFile[], sharedAgents: AgentTemplateFile[], projectAgents: AgentTemplateFile[]): Map<string, AgentConfig>;
|
|
@@ -1,212 +1,93 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-host.ts — execution-multiplexer contracts (types only).
|
|
3
|
-
* AgentHost: hostAt/start/observe/stop/release/isAttached/findAttempts/deliver.
|
|
4
|
-
* AgentView: placement presentation (focus).
|
|
5
|
-
* PaneControl: the pane-side surface a harness prepares through.
|
|
6
|
-
* PlacementCatalog: the multiplexer's own view of the placements it owns (discovery,
|
|
7
|
-
* observation, path spelling) — the multiplexer vocabulary cleanup and status read.
|
|
8
|
-
* HerdrHostRef/AgentHostRef: host address. CheckoutBinding/ViewRequest: placement input.
|
|
9
|
-
* DeliverOutcome: what a pane submit attempt did. HostObservation: live agent state.
|
|
10
|
-
* LiveAttempt: conflict identity for dedup. ExecutionRuntime: host + view + pane +
|
|
11
|
-
* placements for one parent session.
|
|
12
|
-
*/
|
|
13
1
|
import type { HostMultiplexer } from "../host-multiplexer.js";
|
|
14
|
-
/**
|
|
15
|
-
* Which multiplexer an address belongs to. The host multiplexers (see host-multiplexer.ts)
|
|
16
|
-
* are the built-in ones and autocomplete; any other string names a multiplexer a
|
|
17
|
-
* plugin registered, so the vocabulary stays open.
|
|
18
|
-
*/
|
|
19
2
|
export type AgentMultiplexer = HostMultiplexer | (string & {});
|
|
20
|
-
/** A host address as herdr models it: one pi process in one pane of one tab of one workspace. */
|
|
21
3
|
interface HerdrHostRef {
|
|
22
4
|
readonly multiplexer: AgentMultiplexer;
|
|
23
|
-
/** Stable agent identity (herdr: agent name). The tab title may differ. */
|
|
24
5
|
readonly name: string;
|
|
25
6
|
readonly paneId: string;
|
|
26
|
-
/** Hosting tab when known; absent on registry-reconstructed addresses (release/observe use pane + workspace). */
|
|
27
7
|
readonly tabId?: string;
|
|
28
8
|
readonly workspaceId: string;
|
|
29
|
-
/** False for adopted worktree placements: failed-launch cleanup must not close them. */
|
|
30
9
|
readonly paneCreated: boolean;
|
|
31
10
|
}
|
|
32
|
-
/** What the domain types against; only the herdr impl names the variant. */
|
|
33
11
|
export type AgentHostRef = HerdrHostRef;
|
|
34
|
-
|
|
35
|
-
export type DeliverOutcome =
|
|
36
|
-
/** The text and the submission keypress both reached the agent. */
|
|
37
|
-
{
|
|
12
|
+
export type DeliverOutcome = {
|
|
38
13
|
kind: "submitted";
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The agent did not take the message, and `detail` says why — the pane hosts
|
|
42
|
-
* no agent, the agent is waiting on an approval, herdr was unreachable. Nothing
|
|
43
|
-
* was submitted.
|
|
44
|
-
*/
|
|
45
|
-
| {
|
|
14
|
+
} | {
|
|
46
15
|
kind: "not-submitted";
|
|
47
16
|
detail: string;
|
|
48
17
|
};
|
|
49
|
-
/** Only pane placement exists today. */
|
|
50
18
|
type PlacementUnit = "pane";
|
|
51
|
-
/** Checkout for a placement to attach to; the multiplexer registers it, git owns it. */
|
|
52
19
|
export interface CheckoutBinding {
|
|
53
|
-
/** Worktree checkout path (the placement's cwd). */
|
|
54
20
|
path: string;
|
|
55
|
-
/** Main checkout — herdr requires this for `worktree open`. */
|
|
56
21
|
repoCwd: string;
|
|
57
|
-
/** Branch the checkout is on (`cow-<task>-<id>`). */
|
|
58
22
|
branch: string;
|
|
59
23
|
}
|
|
60
24
|
export interface ViewRequest {
|
|
61
25
|
readonly unit: PlacementUnit;
|
|
62
26
|
readonly cwd: string;
|
|
63
|
-
/** Human-facing placement title; a herdr tab's label carries the spawn marker in front of it, and it names the agent when the request names none. */
|
|
64
27
|
readonly label: string;
|
|
65
|
-
/** Stable agent identity; defaults to label, diverges on the fresh-tab path (pretty tab title, branch-derived agent name). */
|
|
66
28
|
readonly name?: string;
|
|
67
29
|
readonly checkout?: CheckoutBinding;
|
|
68
30
|
}
|
|
69
|
-
/** Presentation of a live host. Unit-specific by nature (pane focus is neighbor-relative; tab focus is by id). */
|
|
70
31
|
export interface AgentView {
|
|
71
32
|
focus(ref: AgentHostRef): Promise<void>;
|
|
72
33
|
}
|
|
73
|
-
/**
|
|
74
|
-
* The pane-side surface a harness prepares through. A harness that must type
|
|
75
|
-
* into its pane — installing a launcher, proving staged state is live — reaches
|
|
76
|
-
* the pane here, never through the multiplexer's own client, so the same harness
|
|
77
|
-
* runs under any multiplexer that offers this surface.
|
|
78
|
-
*/
|
|
79
34
|
export interface PaneControl {
|
|
80
|
-
/** How the pane is addressed; the multiplexer's own vocabulary (herdr for the built-in multiplexer). */
|
|
81
35
|
readonly kind: string;
|
|
82
|
-
/**
|
|
83
|
-
* Type one command into the pane. Fire-and-forget by contract: a multiplexer
|
|
84
|
-
* returns before the shell has evaluated the line, so a caller proves what it
|
|
85
|
-
* typed rather than trusting this call (see pane-launcher.ts).
|
|
86
|
-
*/
|
|
87
36
|
run(paneId: string, command: string): Promise<void>;
|
|
88
|
-
/** Resolve once the pane's output comes to contain `output`, or reject when the budget elapses. */
|
|
89
37
|
waitForOutput(paneId: string, output: string, timeoutMs: number): Promise<void>;
|
|
90
38
|
}
|
|
91
39
|
export interface HostObservation {
|
|
92
|
-
/** herdr's own vocabulary. */
|
|
93
40
|
readonly state: "idle" | "working" | "blocked" | "done" | "unknown";
|
|
94
41
|
}
|
|
95
|
-
/**
|
|
96
|
-
* A checkout the multiplexer knows about, as the multiplexer reports it (herdr: one
|
|
97
|
-
* `worktree list` row). `path` is already canonicalized the way this multiplexer
|
|
98
|
-
* spells its placements, so a caller compares it through
|
|
99
|
-
* `PlacementCatalog.canonicalizePath`.
|
|
100
|
-
*/
|
|
101
42
|
export interface PlacementWorktree {
|
|
102
43
|
readonly path: string;
|
|
103
|
-
/** The multiplexer's label for the checkout, when it reported one. */
|
|
104
44
|
readonly label?: string;
|
|
105
|
-
/** The branch the checkout carries, when the multiplexer reported it. */
|
|
106
45
|
readonly branch?: string;
|
|
107
|
-
/** Workspace hosting the checkout's tab; absent when the checkout is not open. */
|
|
108
46
|
readonly workspaceId?: string;
|
|
109
47
|
}
|
|
110
|
-
/**
|
|
111
|
-
* A placement the multiplexer started, as the multiplexer reports it (herdr: one `agent list`
|
|
112
|
-
* record). Nameless records are included: herdr 0.8.x usually drops the name,
|
|
113
|
-
* and `cwd` is then the durable link from a record back to its checkout.
|
|
114
|
-
*/
|
|
115
48
|
export interface PlacementRecord {
|
|
116
49
|
readonly name?: string;
|
|
117
50
|
readonly state: HostObservation["state"];
|
|
118
51
|
readonly workspaceId?: string;
|
|
119
52
|
readonly tabId?: string;
|
|
120
|
-
/** The placement's working directory, when the multiplexer reports one. */
|
|
121
53
|
readonly cwd?: string;
|
|
122
54
|
readonly paneId: string;
|
|
123
55
|
}
|
|
124
|
-
/**
|
|
125
|
-
* The multiplexer's own view of the placements it owns: what exists, how one is read
|
|
126
|
-
* back by pane, and how this multiplexer spells a path. Every method here is multiplexer
|
|
127
|
-
* vocabulary — that is exactly why it belongs to the multiplexer and not to the
|
|
128
|
-
* git/filesystem plane, so a session's cleanup and status paths read the
|
|
129
|
-
* placements of the multiplexer it is actually running rather than a multiplexer the
|
|
130
|
-
* extension picked on their behalf.
|
|
131
|
-
*/
|
|
132
56
|
export interface PlacementCatalog {
|
|
133
|
-
/** The multiplexer these placements belong to; the value a persisted address records. */
|
|
134
57
|
readonly multiplexer: AgentMultiplexer;
|
|
135
|
-
/**
|
|
136
|
-
* Canonicalize a path the way this multiplexer spells its placements, so a caller
|
|
137
|
-
* can compare a path it holds with one the catalog reported.
|
|
138
|
-
*/
|
|
139
58
|
canonicalizePath(value: string): string;
|
|
140
|
-
/** Every checkout the multiplexer knows. A failed read throws — unreadable is not empty. */
|
|
141
59
|
listWorktrees(): Promise<readonly PlacementWorktree[]>;
|
|
142
|
-
/** Every placement the multiplexer started, nameless ones included. A failed read throws. */
|
|
143
60
|
listPlacements(): Promise<readonly PlacementRecord[]>;
|
|
144
|
-
/** One placement's raw state by pane id; undefined = gone, a throw = unreadable (never evidence either way). */
|
|
145
61
|
observePane(paneId: string): Promise<HostObservation | undefined>;
|
|
146
62
|
}
|
|
147
|
-
/** Live attempt naming a task conflict; carries no stop address by design, so dedup can never end another session's work. */
|
|
148
63
|
export interface LiveAttempt {
|
|
149
|
-
/** Stable agent identity (herdr: agent name). */
|
|
150
64
|
readonly name: string;
|
|
151
65
|
}
|
|
152
|
-
/**
|
|
153
|
-
* The agent kind a host starts its process as, in the multiplexer's own vocabulary. The
|
|
154
|
-
* multiplexer matches the process it detects in the pane against the requested kind —
|
|
155
|
-
* herdr does, at `agent start` — so the kind has to be the one the launched
|
|
156
|
-
* binary is detected as. The four built-in kinds autocomplete; any other string
|
|
157
|
-
* is a kind a plugin harness launches under, as long as the multiplexer starts it.
|
|
158
|
-
*/
|
|
159
66
|
export type AgentMultiplexerKind = "pi" | "claude" | "codex" | "opencode" | (string & {});
|
|
160
67
|
export interface AgentHost {
|
|
161
|
-
/** Obtain a host address: adopts the checkout (`worktree open`) or creates a fresh placement in the current workspace. */
|
|
162
68
|
hostAt(request: ViewRequest): Promise<AgentHostRef>;
|
|
163
|
-
/**
|
|
164
|
-
* Launch the child process into the host. `piArgs` already carries
|
|
165
|
-
* `--system-prompt <file>` and the `@<task-file>` message; `agentMultiplexerKind` is the
|
|
166
|
-
* kind the multiplexer must detect the process as.
|
|
167
|
-
*/
|
|
168
69
|
start(ref: AgentHostRef, options: {
|
|
169
70
|
name: string;
|
|
170
71
|
piArgs: string[];
|
|
171
72
|
agentMultiplexerKind: AgentMultiplexerKind;
|
|
172
73
|
}): Promise<void>;
|
|
173
|
-
/** Live snapshot, or undefined when the host is gone. */
|
|
174
74
|
observe(ref: AgentHostRef): Promise<HostObservation | undefined>;
|
|
175
|
-
/** Interrupt and wait; never closes the placement (worktree removal depends on it). */
|
|
176
75
|
stop(ref: AgentHostRef, options?: {
|
|
177
76
|
interruptGraceMs?: number;
|
|
178
77
|
confirmMs?: number;
|
|
179
78
|
}): Promise<boolean>;
|
|
180
|
-
/**
|
|
181
|
-
* Undo hostAt. Destroying a placement ends its process (kill of last
|
|
182
|
-
* resort; multiplexers that cannot end it must not offer release).
|
|
183
|
-
* `placement` closes a self-created placement; `worktree-association`
|
|
184
|
-
* drops a checkout registration (the placement dies with it).
|
|
185
|
-
*/
|
|
186
79
|
release(ref: AgentHostRef, scope: "placement" | "worktree-association"): Promise<boolean>;
|
|
187
|
-
/** Whether any live host (possibly another session's) still has this checkout; guards branch deletion — a throw counts as attached. */
|
|
188
80
|
isAttached(worktreePath: string, opts?: {
|
|
189
81
|
repoCwd?: string;
|
|
190
82
|
}): Promise<boolean>;
|
|
191
|
-
/** Live attempts for a task slug (survives parent reload); a failed probe returns [] so availability never blocks spawning. */
|
|
192
83
|
findAttempts(taskSlug: string): Promise<LiveAttempt[]>;
|
|
193
|
-
/**
|
|
194
|
-
* Submit a message to the run's agent. A working agent queues it for its next
|
|
195
|
-
* model call; a settled one starts another turn. The agent surface refuses a
|
|
196
|
-
* target that hosts no agent, so there is one way in and no half-delivered
|
|
197
|
-
* state: `not-submitted` means the message was refused and `detail` says why.
|
|
198
|
-
*/
|
|
199
84
|
deliver(ref: AgentHostRef, message: string): Promise<DeliverOutcome>;
|
|
200
85
|
}
|
|
201
|
-
/** One multiplexer's host + view + pane control + placement catalog, built once per parent session. */
|
|
202
86
|
export interface ExecutionRuntime {
|
|
203
87
|
readonly host: AgentHost;
|
|
204
88
|
readonly view: AgentView;
|
|
205
|
-
/** The pane surface every harness this session launches under prepares through. */
|
|
206
89
|
readonly pane: PaneControl;
|
|
207
|
-
/** The multiplexer's view of the placements it owns (discovery, observation, path spelling). */
|
|
208
90
|
readonly placements: PlacementCatalog;
|
|
209
|
-
/** The multiplexer id this runtime was built from; the value a persisted address records. */
|
|
210
91
|
readonly multiplexer: AgentMultiplexer;
|
|
211
92
|
}
|
|
212
93
|
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-manager.ts — Fleet controller for independently running subagents.
|
|
3
|
-
* Exports AgentManager; re-exports spawn and steer types.
|
|
4
|
-
*/
|
|
5
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
2
|
import { ConcurrencyPools, type ConcurrencyConfig } from "../concurrency-pools.js";
|
|
7
3
|
import { HerdrTaskRegistry } from "../task-registry.js";
|
|
@@ -13,87 +9,37 @@ import type { CleanupOptions, CleanupReport } from "./cleanup-policy.js";
|
|
|
13
9
|
import { DISPOSE_QUEUED_MESSAGE, type SpawnOptions, type SteerOutcome } from "./subagent-session.js";
|
|
14
10
|
import type { SubagentType } from "./types.js";
|
|
15
11
|
export type { SpawnOptions, SteerOutcome } from "./subagent-session.js";
|
|
16
|
-
/**
|
|
17
|
-
* The transport a session's manager runs on: the session's runtime, which
|
|
18
|
-
* `ExecutionRuntime` builds once per parent session (agent-host.ts). The runtime is
|
|
19
|
-
* bound once here, so every spawn, every cleanup and the registry's dedup check
|
|
20
|
-
* reuse the same host, placements and pane; a multiplexer that opens a connection
|
|
21
|
-
* or starts a service in its `create` would otherwise leak one per call.
|
|
22
|
-
*/
|
|
23
12
|
export declare function createAgentManagerTransport(runtime: ExecutionRuntime): SupervisorTransport;
|
|
24
13
|
type OnAgentComplete = (spawn: AgentSpawn) => void;
|
|
25
|
-
/** A report from an agent that already settled: news beyond its recorded result. */
|
|
26
14
|
type OnAgentFollowUp = (spawn: AgentSpawn, deliverable: string) => void;
|
|
27
|
-
/** Fleet controller; each session owns exactly one lifecycle. */
|
|
28
15
|
export declare class AgentManager {
|
|
29
16
|
private readonly transport;
|
|
30
|
-
/** Live sessions by id; the spawn itself stays identity-stable. */
|
|
31
17
|
private readonly sessions;
|
|
32
18
|
private onComplete?;
|
|
33
19
|
private onFollowUp?;
|
|
34
|
-
/**
|
|
35
|
-
* Teardowns in flight, by agent id. One teardown owns an id's artifacts at a
|
|
36
|
-
* time: a cleanup that arrives while one runs waits for it instead of racing
|
|
37
|
-
* it for the same checkout.
|
|
38
|
-
*/
|
|
39
20
|
private readonly teardowns;
|
|
40
|
-
/** The resource limiter the fleet drives directly; sessions charge their capacity to it. */
|
|
41
21
|
private readonly pools;
|
|
42
|
-
/** Task identity and admission serialization; pool accounting lives in `pools`. */
|
|
43
22
|
private readonly registry;
|
|
44
23
|
constructor(pools: ConcurrencyPools, transport: SupervisorTransport);
|
|
45
24
|
getRegistry(): HerdrTaskRegistry;
|
|
46
25
|
setConcurrency(config: ConcurrencyConfig): void;
|
|
47
26
|
setOnComplete(cb: OnAgentComplete): void;
|
|
48
27
|
setOnFollowUp(cb: OnAgentFollowUp): void;
|
|
49
|
-
/**
|
|
50
|
-
* Mint a spawn id unique across every retained spawn, settled ones included:
|
|
51
|
-
* a retained spawn still owns its id, branch, worktree, and herdr name.
|
|
52
|
-
*/
|
|
53
28
|
mintSpawnId(): string;
|
|
54
29
|
spawn(pi: ExtensionAPI, ctx: ExtensionContext, type: SubagentType, prompt: string, options: SpawnOptions): string;
|
|
55
30
|
private startSession;
|
|
56
|
-
/**
|
|
57
|
-
* Route a message to the agent's session. Unknown ids are refused with the
|
|
58
|
-
* reason; settled agents revive in their session. See SubagentSession.
|
|
59
|
-
*/
|
|
60
31
|
steer(id: string, message: string): Promise<SteerOutcome>;
|
|
61
|
-
/** One spawn by id, unfiltered, so cleanup reaches settled spawns too. */
|
|
62
32
|
getSpawn(id: string): AgentSpawn | undefined;
|
|
63
|
-
/** Assets seam, built per call so probes run against the current shell. */
|
|
64
33
|
private assets;
|
|
65
|
-
/**
|
|
66
|
-
* Locate one agent's artifacts. Read-only: nothing is stopped, removed, or
|
|
67
|
-
* released. Covers ids no session tracks (a `/reload` rebuilt the store).
|
|
68
|
-
*/
|
|
69
34
|
locate(id: string): Promise<LocateResult>;
|
|
70
|
-
/**
|
|
71
|
-
* Retained spawns in the given phases (default: all), newest start first.
|
|
72
|
-
* Pass ACTIVE_AGENT_PHASES for in-flight work, ALL_AGENT_PHASES for status.
|
|
73
|
-
*/
|
|
74
35
|
listAgents(phases?: readonly AgentPhase[]): AgentSpawn[];
|
|
75
36
|
abort(id: string, initiator?: StopInitiator): Promise<boolean>;
|
|
76
37
|
private notifyComplete;
|
|
77
38
|
private notifyFollowUp;
|
|
78
|
-
/**
|
|
79
|
-
* Record why a spawn's checkout survived. The caller reports the outcome and
|
|
80
|
-
* the reason rides the spawn, so status still states it after the menu leaves.
|
|
81
|
-
*/
|
|
82
39
|
private recordRetention;
|
|
83
|
-
/**
|
|
84
|
-
* Drop runtime session and store entry for good, and with them the run's
|
|
85
|
-
* staging directory. The removal is keyed on the id, not the session: a
|
|
86
|
-
* disposal leaves a settled spawn tracked with no session at all, and only
|
|
87
|
-
* the canonical path can still name the directory that run wrote to.
|
|
88
|
-
*/
|
|
89
40
|
dropSpawn(spawn: AgentSpawn): void;
|
|
90
41
|
cleanup(id: string, opts?: CleanupOptions): Promise<CleanupReport>;
|
|
91
|
-
/** Clean one agent up, after whatever teardown for its id is already running. */
|
|
92
42
|
private runCleanup;
|
|
93
|
-
/**
|
|
94
|
-
* Dispose every runtime session. The shell-owned spawn store stays: settled
|
|
95
|
-
* spawns must stay cleanable and untracked live ones stay visible.
|
|
96
|
-
*/
|
|
97
43
|
dispose(): void;
|
|
98
44
|
}
|
|
99
45
|
export { DISPOSE_QUEUED_MESSAGE };
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-reviver.ts — Return a settled run to active. Exports reviveSettledRun.
|
|
3
|
-
*
|
|
4
|
-
* The pane still holds a live pi process, so a delivered message starts a
|
|
5
|
-
* second turn. The result dir is recreated empty first: settlement deletes it
|
|
6
|
-
* (child writes would fail ENOENT) and a stale report would settle the
|
|
7
|
-
* revive with the first run's outcome. A fresh supervisor adopts the host
|
|
8
|
-
* (one run per instance). A revive is not an admission, so the run cannot wait
|
|
9
|
-
* for room: it charges its pools immediately and can pass a limit. The promise
|
|
10
|
-
* keeps the first run's gate: it opened with the first
|
|
11
|
-
* turn's result, so the revived turn is reported through its completion message
|
|
12
|
-
* alone.
|
|
13
|
-
*/
|
|
14
1
|
import type { ProcessSupervisor, ProcessSupervisorOptions, SubagentExitOutcome } from "../subagent/supervisor.js";
|
|
15
2
|
import { type SupervisorTransport } from "../subagent/pane-supervisor.js";
|
|
16
3
|
import type { AgentLaunchState, AgentSpawn } from "../types.js";
|
|
@@ -20,19 +7,9 @@ interface AgentReviveRequest {
|
|
|
20
7
|
hostRef: AgentHostRef;
|
|
21
8
|
transport: SupervisorTransport;
|
|
22
9
|
supervisorOptions: ProcessSupervisorOptions;
|
|
23
|
-
/** Attach the adopted supervisor, and the launch the revived turn resumes, as the session's live run. */
|
|
24
10
|
attachSupervisor(supervisor: ProcessSupervisor, launch: AgentLaunchState): void;
|
|
25
|
-
/** Re-bind the parent abort signal (settlement detached it). */
|
|
26
11
|
rebindParentSignal(): void;
|
|
27
|
-
/** Feed the revived run's terminal outcome back to the session. */
|
|
28
12
|
reportOutcome(supervisor: ProcessSupervisor, outcome: SubagentExitOutcome): void;
|
|
29
13
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Reset settlement artifacts, adopt the host with a fresh supervisor, and arm
|
|
32
|
-
* the second-settlement watch. The spawn's state stays with the session: the
|
|
33
|
-
* attach seam returns the run to active, so this function writes none of it.
|
|
34
|
-
* Synchronous: the message is already delivered, so nothing here waits on
|
|
35
|
-
* the agent.
|
|
36
|
-
*/
|
|
37
14
|
export declare function reviveSettledRun(request: AgentReviveRequest): void;
|
|
38
15
|
export {};
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-runner.ts — Launch-plan building for herdr-pane subagents.
|
|
3
|
-
*
|
|
4
|
-
* Produces a `SubagentLaunchPlan`: staged prompt files and the launch
|
|
5
|
-
* context, with the argv owned by the resolved harness (prompt text compiled
|
|
6
|
-
* by `../prompt/subagent-system-prompt.js`). The child process owns extension
|
|
7
|
-
* discovery and tool validation.
|
|
8
|
-
*/
|
|
9
1
|
import { type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
10
2
|
import { type AgentWorktree, type RunTunables } from "../types.js";
|
|
11
3
|
import { buildWorktreeBranchSection } from "../prompt/subagent-system-prompt.js";
|
|
@@ -13,24 +5,12 @@ import { type AnyHarnessId, type HarnessLaunch } from "./harness.js";
|
|
|
13
5
|
import type { SubagentType } from "./types.js";
|
|
14
6
|
export { buildWorktreeBranchSection };
|
|
15
7
|
export interface SubagentLaunchPlan {
|
|
16
|
-
/** Cosmetic herdr agent name. */
|
|
17
8
|
name?: string;
|
|
18
|
-
/** Working directory for the pane (resolved worktree path or parent cwd). */
|
|
19
9
|
cwd: string;
|
|
20
|
-
/**
|
|
21
|
-
* The system prompt text itself, as written to `launch.systemPromptFile`.
|
|
22
|
-
*/
|
|
23
10
|
systemPrompt?: string;
|
|
24
|
-
/** Legacy name: the complete argv the harness built, whatever binary it launches — the supervisor and herdr seams both spell it `piArgs`. */
|
|
25
11
|
piArgs: string[];
|
|
26
|
-
/**
|
|
27
|
-
* The launch request `piArgs` was built from, and the same object a harness's
|
|
28
|
-
* `prepare` receives: one construction site, so a field the launch adds
|
|
29
|
-
* reaches both without a second copy to keep in step.
|
|
30
|
-
*/
|
|
31
12
|
launch: HarnessLaunch;
|
|
32
13
|
taskSlug?: string;
|
|
33
|
-
/** The harness that owns the pane `piArgs` launches into. */
|
|
34
14
|
harness: AnyHarnessId;
|
|
35
15
|
}
|
|
36
16
|
interface LaunchTunables extends RunTunables {
|
|
@@ -40,12 +20,8 @@ interface LaunchTunables extends RunTunables {
|
|
|
40
20
|
}
|
|
41
21
|
interface LaunchExtras {
|
|
42
22
|
description: string;
|
|
43
|
-
/** The harness the launch resolves, so the plan and the pool identity agree. */
|
|
44
23
|
harness: AnyHarnessId;
|
|
45
|
-
/** Worktree coordinates with ownership; absent for parent-cwd runs. */
|
|
46
24
|
worktree?: AgentWorktree;
|
|
47
|
-
/** The subagent-facing guidance the resolved orchestration template declares, rendered as the system prompt's final block. */
|
|
48
25
|
agentGuidance?: string;
|
|
49
26
|
}
|
|
50
|
-
/** The child pi owns extension discovery and tool validation; this only forwards configuration. */
|
|
51
27
|
export declare function buildLaunchPlan(pi: ExtensionAPI, ctx: ExtensionContext, type: SubagentType, prompt: string, options: LaunchTunables & LaunchExtras): Promise<SubagentLaunchPlan>;
|
|
@@ -1,39 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-spawn-store.ts — Shell-owned canonical AgentSpawn store.
|
|
3
|
-
* Exports AgentSpawnStore, SpawnIdCollisionError.
|
|
4
|
-
*
|
|
5
|
-
* The manager is per-session, so spawns live here in the shell: a spawn
|
|
6
|
-
* outlives its session and stays visible and cleanable. A `/reload`
|
|
7
|
-
* re-imports the extension and rebuilds this store empty. No I/O or
|
|
8
|
-
* lifecycle logic; the only scoping is the lifecycle phase, on request.
|
|
9
|
-
*/
|
|
10
1
|
import type { AgentPhase, AgentSpawn } from "../types.js";
|
|
11
|
-
/**
|
|
12
|
-
* Thrown when `add` gets an id the store already owns. Overwriting would
|
|
13
|
-
* destroy the live spawn and the stop/cleanup/steer execution it carries, so
|
|
14
|
-
* the original is left untouched.
|
|
15
|
-
*/
|
|
16
2
|
export declare class SpawnIdCollisionError extends Error {
|
|
17
3
|
readonly spawnId: string;
|
|
18
4
|
constructor(spawnId: string);
|
|
19
5
|
}
|
|
20
|
-
/** Process-lifetime spawn retention by id; drops only on explicit drop. */
|
|
21
6
|
export declare class AgentSpawnStore {
|
|
22
7
|
private spawns;
|
|
23
|
-
/**
|
|
24
|
-
* Register a spawn at creation. A duplicate id throws and leaves the
|
|
25
|
-
* original untouched; callers mint through `mint()`, so a collision is a bug.
|
|
26
|
-
*/
|
|
27
8
|
add(spawn: AgentSpawn): void;
|
|
28
|
-
/**
|
|
29
|
-
* Mint an id no registered spawn holds, settled ones included: a retained
|
|
30
|
-
* spawn still owns its id. `mint` is injectable so collisions are testable.
|
|
31
|
-
*/
|
|
32
9
|
mint(mint?: () => string): string;
|
|
33
|
-
/** Look one spawn up by id, never phase-filtered. */
|
|
34
10
|
get(id: string): AgentSpawn | undefined;
|
|
35
|
-
/** Drop a spawn once its resources are gone (cleanup success, Clear). */
|
|
36
11
|
drop(id: string): void;
|
|
37
|
-
/** Spawns in the given phases (default: all), in insertion order. */
|
|
38
12
|
list(phases?: readonly AgentPhase[]): AgentSpawn[];
|
|
39
13
|
}
|