@edspencer/paddock 0.0.1 → 0.56.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 +69 -0
- package/install-notice.mjs +29 -0
- package/package.json +58 -5
- package/packages/server/dist/adoptable.d.ts +127 -0
- package/packages/server/dist/adoptable.js +315 -0
- package/packages/server/dist/app.d.ts +67 -0
- package/packages/server/dist/app.js +325 -0
- package/packages/server/dist/archive.d.ts +42 -0
- package/packages/server/dist/archive.js +125 -0
- package/packages/server/dist/attachments-config.d.ts +114 -0
- package/packages/server/dist/attachments-config.js +165 -0
- package/packages/server/dist/attachments-hint.d.ts +53 -0
- package/packages/server/dist/attachments-hint.js +140 -0
- package/packages/server/dist/attachments.d.ts +33 -0
- package/packages/server/dist/attachments.js +117 -0
- package/packages/server/dist/auth.d.ts +84 -0
- package/packages/server/dist/auth.js +247 -0
- package/packages/server/dist/background.d.ts +36 -0
- package/packages/server/dist/background.js +137 -0
- package/packages/server/dist/bind-safety.d.ts +56 -0
- package/packages/server/dist/bind-safety.js +51 -0
- package/packages/server/dist/brand.d.ts +44 -0
- package/packages/server/dist/brand.js +88 -0
- package/packages/server/dist/chat-dto.d.ts +210 -0
- package/packages/server/dist/chat-dto.js +308 -0
- package/packages/server/dist/cli/import-chats.d.ts +21 -0
- package/packages/server/dist/cli/import-chats.js +197 -0
- package/packages/server/dist/cli/paddock.d.ts +2 -0
- package/packages/server/dist/cli/paddock.js +247 -0
- package/packages/server/dist/concurrency.d.ts +57 -0
- package/packages/server/dist/concurrency.js +71 -0
- package/packages/server/dist/config.d.ts +512 -0
- package/packages/server/dist/config.js +593 -0
- package/packages/server/dist/curation-config.d.ts +55 -0
- package/packages/server/dist/curation-config.js +64 -0
- package/packages/server/dist/event-bus.d.ts +87 -0
- package/packages/server/dist/event-bus.js +48 -0
- package/packages/server/dist/git.d.ts +128 -0
- package/packages/server/dist/git.js +446 -0
- package/packages/server/dist/github-auth.d.ts +44 -0
- package/packages/server/dist/github-auth.js +169 -0
- package/packages/server/dist/herdctl-agent-config.d.ts +98 -0
- package/packages/server/dist/herdctl-agent-config.js +331 -0
- package/packages/server/dist/herdctl-agent-names.d.ts +172 -0
- package/packages/server/dist/herdctl-agent-names.js +228 -0
- package/packages/server/dist/herdctl-jobs-index.d.ts +65 -0
- package/packages/server/dist/herdctl-jobs-index.js +225 -0
- package/packages/server/dist/herdctl-jobs.d.ts +98 -0
- package/packages/server/dist/herdctl-jobs.js +225 -0
- package/packages/server/dist/herdctl.d.ts +572 -0
- package/packages/server/dist/herdctl.js +1218 -0
- package/packages/server/dist/hook-config.d.ts +217 -0
- package/packages/server/dist/hook-config.js +224 -0
- package/packages/server/dist/http-bytes.d.ts +24 -0
- package/packages/server/dist/http-bytes.js +52 -0
- package/packages/server/dist/index.d.ts +1 -0
- package/packages/server/dist/index.js +14 -0
- package/packages/server/dist/instance-config.d.ts +135 -0
- package/packages/server/dist/instance-config.js +345 -0
- package/packages/server/dist/localcommand.d.ts +23 -0
- package/packages/server/dist/localcommand.js +140 -0
- package/packages/server/dist/management-auth.d.ts +99 -0
- package/packages/server/dist/management-auth.js +165 -0
- package/packages/server/dist/management-config.d.ts +164 -0
- package/packages/server/dist/management-config.js +286 -0
- package/packages/server/dist/management-mcp-server.d.ts +20 -0
- package/packages/server/dist/management-mcp-server.js +95 -0
- package/packages/server/dist/management-metadata.d.ts +67 -0
- package/packages/server/dist/management-metadata.js +56 -0
- package/packages/server/dist/management-ops.d.ts +110 -0
- package/packages/server/dist/management-ops.js +449 -0
- package/packages/server/dist/management-policy.d.ts +172 -0
- package/packages/server/dist/management-policy.js +259 -0
- package/packages/server/dist/message-provenance.d.ts +112 -0
- package/packages/server/dist/message-provenance.js +260 -0
- package/packages/server/dist/models.d.ts +164 -0
- package/packages/server/dist/models.js +208 -0
- package/packages/server/dist/openapi.d.ts +66 -0
- package/packages/server/dist/openapi.js +183 -0
- package/packages/server/dist/parent-detach.d.ts +30 -0
- package/packages/server/dist/parent-detach.js +109 -0
- package/packages/server/dist/preload.d.ts +43 -0
- package/packages/server/dist/preload.js +55 -0
- package/packages/server/dist/project-files.d.ts +76 -0
- package/packages/server/dist/project-files.js +191 -0
- package/packages/server/dist/project-mime.d.ts +35 -0
- package/packages/server/dist/project-mime.js +55 -0
- package/packages/server/dist/project-paths.d.ts +88 -0
- package/packages/server/dist/project-paths.js +126 -0
- package/packages/server/dist/project-types.d.ts +316 -0
- package/packages/server/dist/project-types.js +48 -0
- package/packages/server/dist/projects.d.ts +202 -0
- package/packages/server/dist/projects.js +894 -0
- package/packages/server/dist/queued-message.d.ts +35 -0
- package/packages/server/dist/queued-message.js +116 -0
- package/packages/server/dist/read-state.d.ts +46 -0
- package/packages/server/dist/read-state.js +139 -0
- package/packages/server/dist/recovery-config.d.ts +111 -0
- package/packages/server/dist/recovery-config.js +105 -0
- package/packages/server/dist/recovery.d.ts +262 -0
- package/packages/server/dist/recovery.js +490 -0
- package/packages/server/dist/resume-drain.d.ts +122 -0
- package/packages/server/dist/resume-drain.js +158 -0
- package/packages/server/dist/route-context.d.ts +168 -0
- package/packages/server/dist/route-context.js +39 -0
- package/packages/server/dist/route-errors.d.ts +8 -0
- package/packages/server/dist/route-errors.js +13 -0
- package/packages/server/dist/routes/chats.d.ts +12 -0
- package/packages/server/dist/routes/chats.js +1406 -0
- package/packages/server/dist/routes/git.d.ts +13 -0
- package/packages/server/dist/routes/git.js +236 -0
- package/packages/server/dist/routes/mcp.d.ts +83 -0
- package/packages/server/dist/routes/mcp.js +250 -0
- package/packages/server/dist/routes/meta.d.ts +15 -0
- package/packages/server/dist/routes/meta.js +447 -0
- package/packages/server/dist/routes/projects.d.ts +25 -0
- package/packages/server/dist/routes/projects.js +736 -0
- package/packages/server/dist/routes/triggers.d.ts +21 -0
- package/packages/server/dist/routes/triggers.js +324 -0
- package/packages/server/dist/routes/workspace-mount.d.ts +48 -0
- package/packages/server/dist/routes/workspace-mount.js +32 -0
- package/packages/server/dist/routes.d.ts +26 -0
- package/packages/server/dist/routes.js +29 -0
- package/packages/server/dist/run-provenance.d.ts +109 -0
- package/packages/server/dist/run-provenance.js +206 -0
- package/packages/server/dist/runs.d.ts +92 -0
- package/packages/server/dist/runs.js +72 -0
- package/packages/server/dist/schedule-config.d.ts +68 -0
- package/packages/server/dist/schedule-config.js +75 -0
- package/packages/server/dist/schedule-session.d.ts +34 -0
- package/packages/server/dist/schedule-session.js +120 -0
- package/packages/server/dist/self-mcp-descriptions.d.ts +20 -0
- package/packages/server/dist/self-mcp-descriptions.js +145 -0
- package/packages/server/dist/self-mcp-read.d.ts +15 -0
- package/packages/server/dist/self-mcp-read.js +97 -0
- package/packages/server/dist/self-mcp-triggers.d.ts +30 -0
- package/packages/server/dist/self-mcp-triggers.js +144 -0
- package/packages/server/dist/self-mcp-types.d.ts +248 -0
- package/packages/server/dist/self-mcp-types.js +10 -0
- package/packages/server/dist/self-mcp-util.d.ts +73 -0
- package/packages/server/dist/self-mcp-util.js +157 -0
- package/packages/server/dist/self-mcp-write.d.ts +35 -0
- package/packages/server/dist/self-mcp-write.js +215 -0
- package/packages/server/dist/self-mcp.d.ts +95 -0
- package/packages/server/dist/self-mcp.js +448 -0
- package/packages/server/dist/send-file-mcp.d.ts +46 -0
- package/packages/server/dist/send-file-mcp.js +281 -0
- package/packages/server/dist/session-hub.d.ts +186 -0
- package/packages/server/dist/session-hub.js +291 -0
- package/packages/server/dist/spawn-capability.d.ts +99 -0
- package/packages/server/dist/spawn-capability.js +106 -0
- package/packages/server/dist/star.d.ts +26 -0
- package/packages/server/dist/star.js +94 -0
- package/packages/server/dist/start.d.ts +1 -0
- package/packages/server/dist/start.js +21 -0
- package/packages/server/dist/subagents.d.ts +337 -0
- package/packages/server/dist/subagents.js +626 -0
- package/packages/server/dist/sweep.d.ts +122 -0
- package/packages/server/dist/sweep.js +696 -0
- package/packages/server/dist/tooldetails.d.ts +33 -0
- package/packages/server/dist/tooldetails.js +466 -0
- package/packages/server/dist/transcribe.d.ts +69 -0
- package/packages/server/dist/transcribe.js +119 -0
- package/packages/server/dist/transcripts.d.ts +42 -0
- package/packages/server/dist/transcripts.js +164 -0
- package/packages/server/dist/trigger-config.d.ts +278 -0
- package/packages/server/dist/trigger-config.js +417 -0
- package/packages/server/dist/trigger-runtime.d.ts +94 -0
- package/packages/server/dist/trigger-runtime.js +82 -0
- package/packages/server/dist/trigger-session.d.ts +34 -0
- package/packages/server/dist/trigger-session.js +122 -0
- package/packages/server/dist/triggers.d.ts +83 -0
- package/packages/server/dist/triggers.js +124 -0
- package/packages/server/dist/trusted-proxy.d.ts +57 -0
- package/packages/server/dist/trusted-proxy.js +157 -0
- package/packages/server/dist/turn-notice.d.ts +154 -0
- package/packages/server/dist/turn-notice.js +271 -0
- package/packages/server/dist/unread.d.ts +36 -0
- package/packages/server/dist/unread.js +123 -0
- package/packages/server/dist/usage.d.ts +66 -0
- package/packages/server/dist/usage.js +243 -0
- package/packages/server/dist/wake-injection.d.ts +156 -0
- package/packages/server/dist/wake-injection.js +136 -0
- package/packages/server/dist/whisper-local.d.ts +9 -0
- package/packages/server/dist/whisper-local.js +122 -0
- package/packages/server/dist/ws-context.d.ts +158 -0
- package/packages/server/dist/ws-context.js +1 -0
- package/packages/server/dist/ws-protocol.d.ts +423 -0
- package/packages/server/dist/ws-protocol.js +251 -0
- package/packages/server/dist/ws-self-mcp.d.ts +52 -0
- package/packages/server/dist/ws-self-mcp.js +28 -0
- package/packages/server/dist/ws-triggers.d.ts +29 -0
- package/packages/server/dist/ws-triggers.js +261 -0
- package/packages/server/dist/ws-turn.d.ts +86 -0
- package/packages/server/dist/ws-turn.js +751 -0
- package/packages/server/dist/ws.d.ts +62 -0
- package/packages/server/dist/ws.js +1024 -0
- package/packages/server/package.json +6 -0
- package/packages/web/dist/assets/InstanceConfigPage-4cQGTj9Y.js +2 -0
- package/packages/web/dist/assets/MarkdownRenderer-CJZFLj_8.js +30 -0
- package/packages/web/dist/assets/ProjectRedirect-BHwVbbqB.js +2 -0
- package/packages/web/dist/assets/ProjectView-BOvuAITg.js +13 -0
- package/packages/web/dist/assets/ProjectsGrid-BCojZOGY.js +2 -0
- package/packages/web/dist/assets/arc-BVyxvnkl.js +2 -0
- package/packages/web/dist/assets/architectureDiagram-3BPJPVTR-Cd9Puqg1.js +37 -0
- package/packages/web/dist/assets/bash-I8pq0VWm.js +2 -0
- package/packages/web/dist/assets/blockDiagram-GPEHLZMM-B_AQt_Rx.js +133 -0
- package/packages/web/dist/assets/c-D2F1sQUL.js +2 -0
- package/packages/web/dist/assets/c4Diagram-AAUBKEIU-7e0TQtXB.js +11 -0
- package/packages/web/dist/assets/channel-C_1aISNn.js +2 -0
- package/packages/web/dist/assets/chunk-2J33WTMH-Dz4WZmUZ.js +2 -0
- package/packages/web/dist/assets/chunk-4BX2VUAB-DVWYldo6.js +2 -0
- package/packages/web/dist/assets/chunk-55IACEB6-BIMrizQd.js +2 -0
- package/packages/web/dist/assets/chunk-727SXJPM-CL2q9fF1.js +207 -0
- package/packages/web/dist/assets/chunk-AQP2D5EJ-BSq3HlQ9.js +232 -0
- package/packages/web/dist/assets/chunk-FMBD7UC4-Bgt64pLE.js +16 -0
- package/packages/web/dist/assets/chunk-ND2GUHAM-C8Pr2A38.js +2 -0
- package/packages/web/dist/assets/chunk-QZHKN3VN-BAOqh-MN.js +2 -0
- package/packages/web/dist/assets/classDiagram-4FO5ZUOK-B8JE7cHJ.js +2 -0
- package/packages/web/dist/assets/classDiagram-v2-Q7XG4LA2-B8JE7cHJ.js +2 -0
- package/packages/web/dist/assets/core-lJeGACQg.js +4 -0
- package/packages/web/dist/assets/cose-bilkent-S5V4N54A-BF4tameA.js +2 -0
- package/packages/web/dist/assets/cpp-Bm3ii6kY.js +2 -0
- package/packages/web/dist/assets/csharp-BNpuYZMG.js +2 -0
- package/packages/web/dist/assets/css-DazXZka4.js +2 -0
- package/packages/web/dist/assets/cytoscape.esm-CUqq0XTU.js +332 -0
- package/packages/web/dist/assets/dagre-BM42HDAG-DdsLM6ql.js +5 -0
- package/packages/web/dist/assets/defaultLocale-DX6XiGOO.js +2 -0
- package/packages/web/dist/assets/diagram-2AECGRRQ-BQ78S_RM.js +44 -0
- package/packages/web/dist/assets/diagram-5GNKFQAL-CAKE6nHE.js +11 -0
- package/packages/web/dist/assets/diagram-KO2AKTUF-fEvHRXgr.js +4 -0
- package/packages/web/dist/assets/diagram-LMA3HP47-CtWsgeSm.js +25 -0
- package/packages/web/dist/assets/diagram-OG6HWLK6-Buog8k7_.js +25 -0
- package/packages/web/dist/assets/erDiagram-TEJ5UH35-CWvVVPZS.js +86 -0
- package/packages/web/dist/assets/flowDiagram-I6XJVG4X-DsCGXtp4.js +163 -0
- package/packages/web/dist/assets/format-DamJQ9LO.js +2 -0
- package/packages/web/dist/assets/ganttDiagram-6RSMTGT7-CsdwIvvC.js +293 -0
- package/packages/web/dist/assets/gitGraphDiagram-PVQCEYII-hZvrX1sD.js +107 -0
- package/packages/web/dist/assets/go-BPx_y7j8.js +2 -0
- package/packages/web/dist/assets/graph-BlwPajkw.js +2 -0
- package/packages/web/dist/assets/index-CGbZdrm8.js +71 -0
- package/packages/web/dist/assets/index-DJDQ210-.css +1 -0
- package/packages/web/dist/assets/infoDiagram-5YYISTIA-nE_Vtz_l.js +3 -0
- package/packages/web/dist/assets/ini-B3BVgEsG.js +2 -0
- package/packages/web/dist/assets/init-Gi6I4Gst.js +2 -0
- package/packages/web/dist/assets/ishikawaDiagram-YF4QCWOH-2Nlqs0oH.js +71 -0
- package/packages/web/dist/assets/java-B5VKqtH2.js +2 -0
- package/packages/web/dist/assets/javascript-BKRaQes9.js +2 -0
- package/packages/web/dist/assets/journeyDiagram-JHISSGLW-mjU1fMc4.js +140 -0
- package/packages/web/dist/assets/json-DIYVocXf.js +2 -0
- package/packages/web/dist/assets/kanban-definition-UN3LZRKU-C_9xNaa3.js +90 -0
- package/packages/web/dist/assets/katex-C5jXJg4s.js +258 -0
- package/packages/web/dist/assets/kotlin-Cw-eF_bm.js +3 -0
- package/packages/web/dist/assets/lastTab-CU1zsF0j.js +2 -0
- package/packages/web/dist/assets/layout-Boy8vhSP.js +2 -0
- package/packages/web/dist/assets/linear-BxKd91ho.js +2 -0
- package/packages/web/dist/assets/mermaid.core-C-CuhD8I.js +310 -0
- package/packages/web/dist/assets/mindmap-definition-RKZ34NQL-Bs6yfcZv.js +97 -0
- package/packages/web/dist/assets/ordinal-Cboi1Yqb.js +2 -0
- package/packages/web/dist/assets/php-CRdd4dfS.js +3 -0
- package/packages/web/dist/assets/pieDiagram-4H26LBE5-DNdqX7O5.js +31 -0
- package/packages/web/dist/assets/python-kSlZHhJb.js +2 -0
- package/packages/web/dist/assets/quadrantDiagram-W4KKPZXB-ZMJl9OdZ.js +8 -0
- package/packages/web/dist/assets/queued-LamEU0GH.js +2 -0
- package/packages/web/dist/assets/requirementDiagram-4Y6WPE33-RmxMdm2q.js +85 -0
- package/packages/web/dist/assets/ruby-7T4ktxyv.js +2 -0
- package/packages/web/dist/assets/rust-HC3MBUhY.js +2 -0
- package/packages/web/dist/assets/sankeyDiagram-5OEKKPKP-OAAhWcfK.js +41 -0
- package/packages/web/dist/assets/scss-DZLA7YXz.js +2 -0
- package/packages/web/dist/assets/sequenceDiagram-3UESZ5HK-BWF7rCyN.js +163 -0
- package/packages/web/dist/assets/sql-BC88IN-V.js +2 -0
- package/packages/web/dist/assets/stateDiagram-AJRCARHV-M3b_zqqo.js +2 -0
- package/packages/web/dist/assets/stateDiagram-v2-BHNVJYJU-CI7saFDa.js +2 -0
- package/packages/web/dist/assets/swift-Dn8kKO_1.js +2 -0
- package/packages/web/dist/assets/timeline-definition-PNZ67QCA-BpOCh63N.js +121 -0
- package/packages/web/dist/assets/typescript-C2FFdlUC.js +2 -0
- package/packages/web/dist/assets/vennDiagram-CIIHVFJN-D_iPH45Q.js +35 -0
- package/packages/web/dist/assets/wardley-L42UT6IY-DVD9I2Om.js +174 -0
- package/packages/web/dist/assets/wardleyDiagram-YWT4CUSO-Bn1IKwjn.js +79 -0
- package/packages/web/dist/assets/xml-BXBhIUeX.js +2 -0
- package/packages/web/dist/assets/xychartDiagram-2RQKCTM6-DwtI0bkR.js +8 -0
- package/packages/web/dist/assets/yaml-drsDnIKT.js +2 -0
- package/packages/web/dist/favicon.ico +0 -0
- package/packages/web/dist/fonts/inter-latin.woff2 +0 -0
- package/packages/web/dist/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/packages/web/dist/icons/apple-touch-icon.png +0 -0
- package/packages/web/dist/icons/favicon-16.png +0 -0
- package/packages/web/dist/icons/favicon-32.png +0 -0
- package/packages/web/dist/icons/icon-192.png +0 -0
- package/packages/web/dist/icons/icon-512.png +0 -0
- package/packages/web/dist/icons/maskable-512.png +0 -0
- package/packages/web/dist/index.html +56 -0
- package/packages/web/dist/manifest.webmanifest +32 -0
- package/packages/web/dist/sw.js +139 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HerdctlService — REAL wrapper around @herdctl/core's FleetManager.
|
|
3
|
+
*
|
|
4
|
+
* This module is NOT a stub: it imports and constructs the public
|
|
5
|
+
* @herdctl/core API (paddock depends on ^5.27.0). It is the single seam between
|
|
6
|
+
* paddock and herdctl, so that any remaining gaps in the public API are isolated
|
|
7
|
+
* here. See docs/INTEGRATION.md for the verified call-by-call contract.
|
|
8
|
+
*
|
|
9
|
+
* As of @herdctl/core 5.11.0 the four prior app-layer workarounds are GONE —
|
|
10
|
+
* paddock now uses the first-class APIs:
|
|
11
|
+
*
|
|
12
|
+
* - **Runtime agents:** `fleet.addAgent({...})` / `fleet.removeAgent(name)`
|
|
13
|
+
* register/unregister a project's keeper + sweeper agents in memory. No more
|
|
14
|
+
* generate-per-agent-yaml + regenerate-herdctl.yaml + `reload()` dance. The
|
|
15
|
+
* FleetManager boots from a minimal zero-agent config (fleet + defaults only)
|
|
16
|
+
* and every agent is added programmatically. `addAgent` validates the config,
|
|
17
|
+
* deep-merges fleet `defaults`, resolves the working_directory to an absolute
|
|
18
|
+
* path, and wires it into the scheduler so it is immediately triggerable and
|
|
19
|
+
* shows up in `getFleetStatus()` / `getAgentInfo()`.
|
|
20
|
+
*
|
|
21
|
+
* - **Sessions:** `fleet.getAgentSessions(name, {limit})` and
|
|
22
|
+
* `fleet.getAgentSessionMessages(name, sessionId)` derive the agent's
|
|
23
|
+
* working_directory + Docker mode from the loaded config — no hand-rolled
|
|
24
|
+
* SessionDiscoveryService keyed on working dirs.
|
|
25
|
+
*
|
|
26
|
+
* - **Streaming:** `trigger(agent, schedule?, { onMessage, prompt, resume })`.
|
|
27
|
+
* `onMessage(msg: SDKMessage)` fires per SDK message; the returned
|
|
28
|
+
* TriggerResult carries the final `sessionId`. New chat = `resume: null`;
|
|
29
|
+
* resume = `resume: <sessionId>`. This is the `batch` drive-mode path; the
|
|
30
|
+
* default `session` mode instead drives `openChatSession`, which ALWAYS runs
|
|
31
|
+
* the SDK runtime regardless of the agent's `runtime` field (see #585).
|
|
32
|
+
*
|
|
33
|
+
* - **Delete / rename a chat:** `fleet.deleteSession(name, sessionId)` removes
|
|
34
|
+
* the transcript (and invalidates the discovery cache), and
|
|
35
|
+
* `fleet.setSessionName(name, sessionId, customName)` sets a custom name —
|
|
36
|
+
* both keyed by agent name, no deep imports.
|
|
37
|
+
*
|
|
38
|
+
* Freshness note: `fleet.getAgentSessions` uses the FleetManager's internal
|
|
39
|
+
* SessionDiscoveryService, which has a 30s directory cache. A brand-new
|
|
40
|
+
* project's transcript dir does not exist until its first turn, and the
|
|
41
|
+
* discovery service does NOT cache a missing directory — so the first session
|
|
42
|
+
* of a project surfaces immediately. `deleteSession`/`setSessionName` invalidate
|
|
43
|
+
* the cache internally. The one nuance vs. the prior code: a *second* new chat
|
|
44
|
+
* created in an already-listed project within 30s may take up to the cache TTL
|
|
45
|
+
* to appear (the prior code invalidated a private cache we can no longer reach).
|
|
46
|
+
* That last nuance is now closed too: core exposes `fleet.invalidateSessions(name)`
|
|
47
|
+
* and paddock calls it after each turn (`ws-turn.ts`) and around fork/promote.
|
|
48
|
+
*/
|
|
49
|
+
import { FleetManager, type DiscoveredSession, type ChatMessage, type SDKMessage, type TriggerResult, type AgentInfo, type FleetStatus, type SlashCommand, type InjectedMcpServerDef, type SessionWakeHandler, type ResolveInjectedMcpServers, type ScheduleTriggerHandler, type ScheduleInfo, type JobMetadata, type AdoptionPlacementMode, type AdoptSkippedSession } from "@herdctl/core";
|
|
50
|
+
import type { PaddockConfig } from "./config.js";
|
|
51
|
+
import type { Project } from "./projects.js";
|
|
52
|
+
import { type PaddockTrigger } from "./trigger-config.js";
|
|
53
|
+
import { type AdoptableSummary, type FilterReason } from "./adoptable.js";
|
|
54
|
+
/**
|
|
55
|
+
* One session an import did NOT bring in, with a reason a UI can show verbatim.
|
|
56
|
+
*
|
|
57
|
+
* A superset of the engine's own `AdoptSkippedSession`: paddock's noise filter
|
|
58
|
+
* (`./adoptable.ts`) contributes its own reasons on top of the engine's, and a
|
|
59
|
+
* caller renders the string either way rather than switching on it.
|
|
60
|
+
*/
|
|
61
|
+
export type AdoptSkipped = AdoptSkippedSession | {
|
|
62
|
+
sessionId: string;
|
|
63
|
+
reason: FilterReason;
|
|
64
|
+
detail?: string;
|
|
65
|
+
};
|
|
66
|
+
/** Options passed through to a streamed trigger. */
|
|
67
|
+
export interface ChatTurnOptions {
|
|
68
|
+
prompt: string;
|
|
69
|
+
/** Session to resume; `null` forces a fresh session; omit for agent fallback. */
|
|
70
|
+
resume?: string | null;
|
|
71
|
+
onMessage?: (msg: SDKMessage) => void | Promise<void>;
|
|
72
|
+
onJobCreated?: (jobId: string) => void;
|
|
73
|
+
triggerType?: string;
|
|
74
|
+
/**
|
|
75
|
+
* In-process MCP servers to inject for this turn (issue #112). herdctl's CLI
|
|
76
|
+
* runtime stands up a localhost HTTP bridge per server and auto-allowlists its
|
|
77
|
+
* `mcp__<key>__*` tools, so no change to the static `allowed_tools` is needed.
|
|
78
|
+
*/
|
|
79
|
+
injectedMcpServers?: Record<string, InjectedMcpServerDef>;
|
|
80
|
+
/**
|
|
81
|
+
* Gap B (session mode only): a sink for messages that arrive on the session's
|
|
82
|
+
* stream AFTER the primary turn's terminal `result` — i.e. autonomous
|
|
83
|
+
* background-completion re-invocation turns the reaper holds the session open
|
|
84
|
+
* for. When provided, {@link chatSession} keeps consuming the same stream and
|
|
85
|
+
* forwards each subsequent message here so the caller can render it live (see
|
|
86
|
+
* `consumeBackgroundTurns` in ./resume-drain.ts). Omit for no live delivery of
|
|
87
|
+
* background turns (they still persist to the transcript regardless).
|
|
88
|
+
*/
|
|
89
|
+
onBackgroundMessage?: (msg: SDKMessage) => void | Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Gap B (session mode only): called once the background stream ENDS (the reaper
|
|
92
|
+
* reaped the session). Lets the caller finalize the single hub turn it rendered
|
|
93
|
+
* background re-invocations onto (emit chat:complete + end the turn) so the
|
|
94
|
+
* streaming indicator clears. Paired with {@link onBackgroundMessage}.
|
|
95
|
+
*/
|
|
96
|
+
onBackgroundDone?: () => void | Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The name/visibility helpers + tool/model constants are pure (they only read
|
|
100
|
+
* their arguments, no fleet/cfg/session state), so they live in a sibling module
|
|
101
|
+
* for readability + isolated unit-testing (issue #403). Re-exported here so every
|
|
102
|
+
* external importer keeps resolving them via `./herdctl.js` unchanged.
|
|
103
|
+
*/
|
|
104
|
+
export { keeperAgentName, keeperSlugFromAgent, SWEEPER_PREFIX, sweeperAgentName, HOOK_AGENT_PREFIX, hookAgentName, TRIGGER_AGENT_PREFIX, triggerAgentName, visibleProjectAgentNames, BROWSER_MCP_TOOL, DENIED_TOOLS, browserMcpServers, KEEPER_MAX_CONCURRENT, KEEPER_SESSION_TIMEOUT, } from "./herdctl-agent-names.js";
|
|
105
|
+
export declare function sliceTranscriptAtUuid(raw: string, cutUuid: string, endOnCompletedAssistant?: boolean): string | null;
|
|
106
|
+
export declare class HerdctlService {
|
|
107
|
+
private readonly cfg;
|
|
108
|
+
private fleet;
|
|
109
|
+
private started;
|
|
110
|
+
/**
|
|
111
|
+
* The model currently registered for each agent (keyed by agent name). Lets
|
|
112
|
+
* `ensureAgentModel` skips a re-registration when the
|
|
113
|
+
* requested model already matches the live agent config.
|
|
114
|
+
*
|
|
115
|
+
* SINGLE-USER CAVEAT: the keeper is one shared agent per project, so the
|
|
116
|
+
* model is last-write-wins across concurrent chats of the same project — if
|
|
117
|
+
* two chats of the same project pick different models, whichever triggered
|
|
118
|
+
* last wins for both. Acceptable for paddock's single-user POC; a clean
|
|
119
|
+
* per-trigger model override is a herdctl follow-up.
|
|
120
|
+
*/
|
|
121
|
+
private agentModels;
|
|
122
|
+
/**
|
|
123
|
+
* Each agent's working directory (the keeper's cwd), recorded at
|
|
124
|
+
* registration. Used to resolve the `claude` CLI transcript for a resume so we
|
|
125
|
+
* can measure its pending async-input-queue depth (the resume self-interrupt
|
|
126
|
+
* fix's residue gate — see {@link residueDepthFor} + `./resume-drain.ts`).
|
|
127
|
+
*/
|
|
128
|
+
private agentWorkingDirs;
|
|
129
|
+
/**
|
|
130
|
+
* Live session-mode turns keyed by the synthetic turn id we hand back as the
|
|
131
|
+
* `jobId` (Paddock#111). `openChatSession` creates no herdctl job record, so
|
|
132
|
+
* there's no core `jobId` to cancel via `cancelJob`; instead we register the
|
|
133
|
+
* live {@link RuntimeSession} here and Stop → `session.interrupt()` (see
|
|
134
|
+
* {@link cancel}). Entries are removed when the turn's stream ends.
|
|
135
|
+
*/
|
|
136
|
+
private liveSessions;
|
|
137
|
+
/**
|
|
138
|
+
* Incremental index of `<stateDir>/jobs`, backing the unread-badge reads
|
|
139
|
+
* (`lastTurnCompletedAt*`) — one per service, reused across requests so a warm
|
|
140
|
+
* scan only parses records it has never seen (#529). See
|
|
141
|
+
* `./herdctl-jobs-index.ts` for the invariant it rests on and its invalidation.
|
|
142
|
+
*
|
|
143
|
+
* Built lazily on first read, like the job-record helpers it replaced: unit
|
|
144
|
+
* tests construct this service against a partial config with no `stateDir`,
|
|
145
|
+
* and must keep being able to.
|
|
146
|
+
*/
|
|
147
|
+
private jobsIndexOrNull;
|
|
148
|
+
private get jobsIndex();
|
|
149
|
+
constructor(cfg: PaddockConfig);
|
|
150
|
+
/**
|
|
151
|
+
* Construct + initialize the FleetManager against a minimal zero-agent
|
|
152
|
+
* config (fleet + defaults only). Agents are then registered programmatically
|
|
153
|
+
* via `fleet.addAgent(...)` — a keeper + sweeper for each workspace, the root
|
|
154
|
+
* included. No per-agent yaml files; no `reload()`.
|
|
155
|
+
*/
|
|
156
|
+
init(projects: Project[]): Promise<void>;
|
|
157
|
+
/** Start the scheduler (keeper agents currently have no schedules, but this
|
|
158
|
+
* keeps the fleet "running" for status + future cron curators). */
|
|
159
|
+
start(): Promise<void>;
|
|
160
|
+
stop(): Promise<void>;
|
|
161
|
+
/** Expose the raw FleetManager (events, advanced ops) to callers that need it. */
|
|
162
|
+
get manager(): FleetManager;
|
|
163
|
+
/**
|
|
164
|
+
* Is a `claude` SUBPROCESS still alive on this session at the SDK/reaper layer
|
|
165
|
+
* (issue #397)? Consults herdctl's `SessionReaper` via the fleet's session
|
|
166
|
+
* lifecycle manager: `true` while the reaper is keeping a session open for a
|
|
167
|
+
* killed background task (keepAlive) or holding it through its re-invocation
|
|
168
|
+
* grace. Paddock's recovery engine treats this as a busy signal so it never
|
|
169
|
+
* fires a COMPETING resume into a session a prior subprocess still holds live
|
|
170
|
+
* (which the SDK resolves by interrupting the in-flight turn). Null-safe: with
|
|
171
|
+
* no fleet, no session-lifecycle manager (batch mode / reaper disabled), or any
|
|
172
|
+
* error, returns `false` — the pre-#397 behaviour.
|
|
173
|
+
*/
|
|
174
|
+
isSdkSessionLive(sessionId: string): boolean;
|
|
175
|
+
fleetStatus(): Promise<FleetStatus>;
|
|
176
|
+
agents(): Promise<AgentInfo[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Register (or replace) a project's keeper + sweeper agents at runtime. Uses
|
|
179
|
+
* `fleet.addAgent` (replace: true), so a re-create or rename of the same slug
|
|
180
|
+
* is idempotent. The new agents are immediately triggerable and visible in
|
|
181
|
+
* fleet status — no yaml + reload round-trip.
|
|
182
|
+
*/
|
|
183
|
+
ensureProjectAgent(project: Project): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Register (or replace) every trigger a project declares that runs on its OWN scoped
|
|
186
|
+
* agent `trigger-<slug>-<name>` (Epic T). Idempotent (`addAgent` replace:true). Which triggers
|
|
187
|
+
* get a scoped agent is decided by {@link triggerRunsOnOwnAgent}: EVENT triggers
|
|
188
|
+
* always; SCHEDULE triggers only when they declare a non-empty `run.tools` allow-list
|
|
189
|
+
* (T2 — an unscoped schedule still rides the keeper's forwarded `schedules` block and
|
|
190
|
+
* runs as the keeper); webhook triggers are reserved (no ingress). A scoped schedule
|
|
191
|
+
* ALSO keeps its keeper `schedules` entry — that is only the cron TIMING; the fired
|
|
192
|
+
* turn executes on this scoped agent. A trigger-less project is a no-op. Called at
|
|
193
|
+
* boot ({@link init}) and on every {@link ensureProjectAgent}.
|
|
194
|
+
*/
|
|
195
|
+
registerTriggerAgents(project: Project): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Register (or replace) ONE trigger's scoped agent at runtime (Epic T) — the herdctl
|
|
198
|
+
* half of a trigger mutation (the Paddock half persists it via
|
|
199
|
+
* `ProjectStore.setTrigger`). Idempotent; immediately fireable. Consumed by
|
|
200
|
+
* {@link import("./triggers.js").TriggerService}. A no-op for a trigger that does NOT
|
|
201
|
+
* run on its own agent ({@link triggerRunsOnOwnAgent}) — an unscoped schedule arms via
|
|
202
|
+
* the keeper re-register; a webhook is reserved.
|
|
203
|
+
*/
|
|
204
|
+
ensureTriggerAgent(project: Project, name: string, trigger: PaddockTrigger): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Unregister one event trigger's agent at runtime (Epic T / T1) — the inverse of
|
|
207
|
+
* {@link ensureTriggerAgent}. Never throws if the agent is already gone.
|
|
208
|
+
*/
|
|
209
|
+
removeTriggerAgent(slug: string, name: string): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Ensure a project's keeper agent is registered at `model`, re-registering it
|
|
212
|
+
* (addAgent replace:true) only when the model actually changed. Used by the
|
|
213
|
+
* WS chat path to honor a per-chat model override before triggering.
|
|
214
|
+
*
|
|
215
|
+
* No herdctl per-trigger model API exists yet, so a model override is applied
|
|
216
|
+
* by re-registering the (single, shared) keeper agent. See the `agentModels`
|
|
217
|
+
* single-user caveat: this is last-write-wins across concurrent chats of the
|
|
218
|
+
* same project.
|
|
219
|
+
*/
|
|
220
|
+
ensureAgentModel(project: Project, model: string): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Force the FleetManager's session-discovery cache to drop its cached listing
|
|
223
|
+
* for an agent, so a brand-new chat surfaces immediately (rather than waiting
|
|
224
|
+
* out the 30s directory cache). New public API in @herdctl/core 5.12.0. No-op
|
|
225
|
+
* and never throws if the fleet isn't ready.
|
|
226
|
+
*/
|
|
227
|
+
invalidateSessions(agentName: string): void;
|
|
228
|
+
/**
|
|
229
|
+
* Detector for a project's importable native Claude Code chats, with its own
|
|
230
|
+
* mtime-keyed cache. Lazy for the same reason {@link jobsIndex} is: unit tests
|
|
231
|
+
* construct this service against a partial config.
|
|
232
|
+
*/
|
|
233
|
+
private adoptableIndexOrNull;
|
|
234
|
+
private get adoptableIndex();
|
|
235
|
+
/** What `project` could import right now (see `./adoptable.ts`). */
|
|
236
|
+
listAdoptable(project: Project): Promise<AdoptableSummary>;
|
|
237
|
+
/**
|
|
238
|
+
* Drop the cached adoptable summary for a workspace (or all of them).
|
|
239
|
+
*
|
|
240
|
+
* The workspace key may be `""` (the root), so this forwards the argument
|
|
241
|
+
* as-is — `if (!slug)` here would silently clear the WRONG thing.
|
|
242
|
+
*/
|
|
243
|
+
invalidateAdoptable(projectKey?: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* Import a project's native Claude Code chats.
|
|
246
|
+
*
|
|
247
|
+
* With `sourceCwd`, imports that one source; without, every source detection
|
|
248
|
+
* currently offers. `mode` defaults to `copy`, which never mutates the user's
|
|
249
|
+
* original `~/.claude` transcripts and preserves their mtimes; `move` and
|
|
250
|
+
* `link` exist for the CLI and nothing in the web UI should reach them.
|
|
251
|
+
*
|
|
252
|
+
* ## Honouring the noise filter
|
|
253
|
+
*
|
|
254
|
+
* Detection withholds empty and slash-command-only transcripts, but the engine
|
|
255
|
+
* adopts a whole SOURCE — it has no "adopt these ids" call. Left alone, that
|
|
256
|
+
* means the header offers 2 chats and the import brings in 4, including a
|
|
257
|
+
* zero-byte stub. So anything the engine adopted that detection had withheld is
|
|
258
|
+
* released again ({@link FleetManager.unadoptSession}) and reported in
|
|
259
|
+
* `skipped` under the filter's own reason, and — in `copy` mode only — the copy
|
|
260
|
+
* this call just placed is removed.
|
|
261
|
+
*
|
|
262
|
+
* That deletion is deliberately narrow. It happens only when all of: the mode
|
|
263
|
+
* is `copy` (in `move` the original is GONE, so the copy is the user's only
|
|
264
|
+
* remaining copy and must never be touched); the engine reported the id as
|
|
265
|
+
* newly `adopted` in THIS call, so it placed the file here and did not find one
|
|
266
|
+
* (`destination-exists` is a skip, not an adopt); and the destination path
|
|
267
|
+
* differs from the source, so an in-place adoption can never delete an
|
|
268
|
+
* original. The result is that a withheld session is left exactly as it was
|
|
269
|
+
* before the import.
|
|
270
|
+
*
|
|
271
|
+
* Afterwards the herdctl session cache, the jobs index and the adoptable cache
|
|
272
|
+
* are all dropped, so the imported chats list on the very next request — the
|
|
273
|
+
* same trio {@link promoteSession} invalidates for the same reason.
|
|
274
|
+
*/
|
|
275
|
+
adoptChats(project: Project, opts?: {
|
|
276
|
+
sourceCwd?: string;
|
|
277
|
+
mode?: AdoptionPlacementMode;
|
|
278
|
+
dryRun?: boolean;
|
|
279
|
+
}): Promise<{
|
|
280
|
+
adopted: string[];
|
|
281
|
+
skipped: AdoptSkipped[];
|
|
282
|
+
}>;
|
|
283
|
+
/**
|
|
284
|
+
* Undo the adoption of a session detection had withheld, restoring the state
|
|
285
|
+
* that existed before this import. See {@link adoptChats} for why the file
|
|
286
|
+
* removal is safe and why it is limited to `copy` mode.
|
|
287
|
+
*/
|
|
288
|
+
private releaseWithheld;
|
|
289
|
+
/**
|
|
290
|
+
* Unregister a project's keeper + sweeper (+ any event-hook) agents at runtime.
|
|
291
|
+
* Uses `fleet.removeAgent`, the inverse of ensureProjectAgent. Running jobs are
|
|
292
|
+
* unaffected; the scheduler stops triggering the removed agents. `hookNames` are
|
|
293
|
+
* the project's declared hook names (from its DTO) so their `hook-<slug>-<name>`
|
|
294
|
+
* agents are torn down too — caller passes `Object.keys(project.hooks ?? {})`.
|
|
295
|
+
*/
|
|
296
|
+
removeProjectAgent(slug: string, hookNames?: string[], triggerNames?: string[]): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Delete a single chat (session) by agent name + session id. The FleetManager
|
|
299
|
+
* resolves the agent's working directory, removes the transcript JSONL, and
|
|
300
|
+
* invalidates the discovery cache so the list reflects it immediately.
|
|
301
|
+
* Validates the sessionId (rejects path traversal). Returns true if a
|
|
302
|
+
* transcript file was removed, false if none existed.
|
|
303
|
+
*/
|
|
304
|
+
deleteSession(agentName: string, sessionId: string): Promise<boolean>;
|
|
305
|
+
/**
|
|
306
|
+
* Set (or clear) a chat's custom display name. Writes through the fleet's
|
|
307
|
+
* shared SessionMetadataStore so a subsequent getAgentSessions reflects it
|
|
308
|
+
* immediately. Pass null/empty to clear.
|
|
309
|
+
*/
|
|
310
|
+
renameSession(agentName: string, sessionId: string, name: string | null): Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Trigger an agent with a prompt and stream output via onMessage.
|
|
313
|
+
* Returns the TriggerResult (carries the final sessionId).
|
|
314
|
+
*/
|
|
315
|
+
chat(agentName: string, opts: ChatTurnOptions): Promise<TriggerResult>;
|
|
316
|
+
/**
|
|
317
|
+
* Pending async-input-queue depth of a resumed session's `claude` transcript —
|
|
318
|
+
* the residue gate for the resume self-interrupt drain (see `./resume-drain.ts`
|
|
319
|
+
* and {@link drainBacklogThenConsume}). Resolves the agent's CLI transcript from
|
|
320
|
+
* its recorded working directory. Returns 0 (→ no drain, original fast path) for
|
|
321
|
+
* an unknown agent or any read error, so a detection failure never changes turn
|
|
322
|
+
* behavior. Public so the ws.ts wake consumer can gate on it too.
|
|
323
|
+
*/
|
|
324
|
+
residueDepthFor(agentName: string, sessionId: string): Promise<number>;
|
|
325
|
+
/**
|
|
326
|
+
* Session-mode counterpart to {@link chat} (Paddock#111). Drives the turn
|
|
327
|
+
* through a persistent, herdctl-managed `openChatSession` (`manageLifecycle:
|
|
328
|
+
* true`) instead of a one-shot `trigger()`, so a `ScheduleWakeup` / `/loop` the
|
|
329
|
+
* turn leaves behind is captured by the reaper (herdctl#307) and re-fired
|
|
330
|
+
* through the scheduler — i.e. cross-turn autonomy actually works. The turn
|
|
331
|
+
* itself streams identically (same `onMessage` shape), so callers are unchanged.
|
|
332
|
+
*
|
|
333
|
+
* Contract differences from {@link chat}:
|
|
334
|
+
* - No herdctl job record exists, so the returned `jobId` is a synthetic turn
|
|
335
|
+
* id we register in {@link liveSessions}; Stop maps to `session.interrupt()`
|
|
336
|
+
* via {@link cancel}.
|
|
337
|
+
* - We do NOT `close()` the session: it's managed, so the reaper tears it down
|
|
338
|
+
* when idle (and captures its wakeups on the Stop hook). Per the core
|
|
339
|
+
* contract, the message stream ending IS the reap.
|
|
340
|
+
*/
|
|
341
|
+
chatSession(agentName: string, opts: ChatTurnOptions): Promise<TriggerResult>;
|
|
342
|
+
/**
|
|
343
|
+
* Register the consumer that drives scheduler-fired session wakes (Paddock#111
|
|
344
|
+
* gap 3). herdctl resumes the woken session (`manageLifecycle: true`) and hands
|
|
345
|
+
* it here; the handler must consume the stream onto the hub/transcript so the
|
|
346
|
+
* autonomous turn is visible even though no client is watching. A no-op if the
|
|
347
|
+
* fleet has no lifecycle manager. Safe to call before/after {@link init}.
|
|
348
|
+
*/
|
|
349
|
+
onSessionWake(handler: SessionWakeHandler | undefined): void;
|
|
350
|
+
/**
|
|
351
|
+
* Register the resolver herdctl calls to RE-ESTABLISH this session's in-process
|
|
352
|
+
* injected MCP servers when a scheduler-fired wake resumes an idle/reaped session
|
|
353
|
+
* (edspencer/herdctl#390, wired in @herdctl/core 5.22.1). The wake path drives the
|
|
354
|
+
* turn inside herdctl (a `ScheduleWakeup` / `/loop` / `CronCreate` re-fire), so it
|
|
355
|
+
* bypasses Paddock's per-turn injection — without this the resumed `claude`
|
|
356
|
+
* subprocess re-spawns with the `mcp__paddock*__*` tools "allowed" but UNBACKED,
|
|
357
|
+
* so they vanish from the catalog for the whole autonomous stretch (the "MCP flap").
|
|
358
|
+
* The resolver is SYNCHRONOUS (herdctl threads its result into `openChatSession`
|
|
359
|
+
* before the subprocess spawns) and MUST NOT throw — herdctl catches + logs a throw
|
|
360
|
+
* and degrades to no-injection, but we return `undefined` (safe no-injection default)
|
|
361
|
+
* rather than rely on that. A no-op if the fleet has no lifecycle manager; safe to
|
|
362
|
+
* call before/after {@link init}. Thin passthrough, mirroring {@link onSessionWake}.
|
|
363
|
+
*/
|
|
364
|
+
setResolveInjectedMcpServers(resolve: ResolveInjectedMcpServers | undefined): void;
|
|
365
|
+
/**
|
|
366
|
+
* Register the consumer that OWNS execution of a fired schedule (issue #265 /
|
|
367
|
+
* DD-1, herdctl#375). When set, herdctl routes every scheduler-fired trigger
|
|
368
|
+
* (interval / cron / forced "trigger now") here instead of running it headless
|
|
369
|
+
* via its built-in ScheduleExecutor — so Paddock runs the turn on its OWN hub /
|
|
370
|
+
* resume path (`startAgentTurn`), keeping the scheduled chat visible + re-attachable
|
|
371
|
+
* (and never `isSidechain`-hidden). A no-op fallback to headless applies if no
|
|
372
|
+
* handler is registered. Thin passthrough, mirroring {@link onSessionWake}.
|
|
373
|
+
*/
|
|
374
|
+
onScheduleTrigger(handler: ScheduleTriggerHandler | undefined): void;
|
|
375
|
+
/**
|
|
376
|
+
* The runtime state of a project keeper's schedules (issue #266 / D4) — the
|
|
377
|
+
* live `ScheduleInfo` herdctl tracks (status, `lastRunAt`/`nextRunAt`,
|
|
378
|
+
* `lastError`) for the schedules Paddock forwarded into the keeper agent. The
|
|
379
|
+
* D4 UI merges this with the project.yaml declaration (which carries the
|
|
380
|
+
* Paddock-only `prompt`/`promptFile`/`resume_session`) for the list view. A
|
|
381
|
+
* schedule-less keeper (or one herdctl hasn't finished arming) yields `[]`;
|
|
382
|
+
* errors are swallowed to `[]` so the settings pane degrades to the declared
|
|
383
|
+
* definitions rather than failing to render.
|
|
384
|
+
*/
|
|
385
|
+
listAgentSchedules(project: Project): Promise<ScheduleInfo[]>;
|
|
386
|
+
/**
|
|
387
|
+
* Run a slash command (e.g. `/compact`) against an agent's chat session.
|
|
388
|
+
*
|
|
389
|
+
* Unlike {@link chat}, which sends the text as a one-shot prompt via
|
|
390
|
+
* `trigger()`, this drives herdctl's streaming session (`openChatSession`) —
|
|
391
|
+
* the only mode in which the SDK dispatches slash commands and exposes control
|
|
392
|
+
* requests. The command runs against the resumed `sessionId`, so `/compact`
|
|
393
|
+
* compacts the real chat history. SDK messages stream via `onMessage` (same
|
|
394
|
+
* shape as {@link chat}); resolves when the turn completes, then closes the
|
|
395
|
+
* session. Returns the resolved session id.
|
|
396
|
+
*/
|
|
397
|
+
runCommand(agentName: string, opts: {
|
|
398
|
+
command: string;
|
|
399
|
+
resume?: string | null;
|
|
400
|
+
onMessage?: (msg: SDKMessage) => void | Promise<void>;
|
|
401
|
+
}): Promise<{
|
|
402
|
+
sessionId: string | null;
|
|
403
|
+
}>;
|
|
404
|
+
/**
|
|
405
|
+
* Cancel a running turn (Stop button → WS chat:cancel). Handles BOTH drive
|
|
406
|
+
* modes off the single id the client holds as `jobId`:
|
|
407
|
+
* - **session mode** — the id is a synthetic turn id in {@link liveSessions};
|
|
408
|
+
* interrupt the live `RuntimeSession` (there is no herdctl job to cancel).
|
|
409
|
+
* - **batch mode** — the id is a real herdctl job id; abort it via `cancelJob`
|
|
410
|
+
* (which kills the CLI subprocess / aborts the SDK query).
|
|
411
|
+
*
|
|
412
|
+
* Returns `true` if something was actually cancelled. Errors are logged rather
|
|
413
|
+
* than silently swallowed (the previous `.catch(() => undefined)` hid every
|
|
414
|
+
* failure, so a broken Stop looked like a no-op).
|
|
415
|
+
*/
|
|
416
|
+
cancel(jobId: string): Promise<boolean>;
|
|
417
|
+
/**
|
|
418
|
+
* Run a project's sweeper (curator) agent with a fresh session and the given
|
|
419
|
+
* prompt. Used OUT OF BAND by SweepService — never from the user-chat path —
|
|
420
|
+
* so a sweep can never enqueue another sweep. resume:null forces a clean
|
|
421
|
+
* session each time (the sweep is stateless).
|
|
422
|
+
*
|
|
423
|
+
* The sweeper is tool-less and returns its result as plain assistant text
|
|
424
|
+
* (the two marked sections SweepService parses), so we accumulate the
|
|
425
|
+
* assistant text deltas via @herdctl/chat's shared translator (same pattern
|
|
426
|
+
* as ws.ts) and return them alongside the TriggerResult.
|
|
427
|
+
*/
|
|
428
|
+
runSweeper(slug: string, prompt: string): Promise<{
|
|
429
|
+
result: TriggerResult;
|
|
430
|
+
text: string;
|
|
431
|
+
}>;
|
|
432
|
+
/** Recent sessions for a project's keeper agent, used to build the sweep digest. */
|
|
433
|
+
recentSessions(project: Project, limit?: number): Promise<DiscoveredSession[]>;
|
|
434
|
+
/**
|
|
435
|
+
* List a project's chats across ALL of its VISIBLE agents (Epic G / G3, GG-5):
|
|
436
|
+
* the keeper PLUS every declared event-hook agent (`hook-<slug>-<name>`), so a
|
|
437
|
+
* hook's chats show up in the sidebar alongside the keeper's. The sweeper is
|
|
438
|
+
* deliberately excluded — it's the `hideChats` case (its curation chats stay
|
|
439
|
+
* hidden, unchanged). See
|
|
440
|
+
* {@link visibleProjectAgentNames}.
|
|
441
|
+
*
|
|
442
|
+
* Sessions are keyed by working directory in core's discovery, and every one of
|
|
443
|
+
* a project's agents shares the project cwd, so `getAgentSessions` attributes each
|
|
444
|
+
* session to the specific agent that owns it (keeper vs. a hook). We query each
|
|
445
|
+
* visible agent and merge — deduping by session id defensively (attribution is
|
|
446
|
+
* per-agent, so overlap shouldn't happen) — then re-sort mtime-descending to
|
|
447
|
+
* restore the interleaved recency order a single listing would have had. Each
|
|
448
|
+
* per-agent query is fault-isolated: a hook whose agent failed to register (or was
|
|
449
|
+
* just removed) yields `[]` instead of failing the whole list.
|
|
450
|
+
*
|
|
451
|
+
* A **hook-less project** (the overwhelmingly common case) has exactly one visible
|
|
452
|
+
* agent — its keeper — so we short-circuit to the single un-merged listing: same
|
|
453
|
+
* one directory scan (and no dedup/sort work) the pre-G3 keeper-only path did, i.e.
|
|
454
|
+
* zero added cost unless the project actually declares hooks. The extra per-hook
|
|
455
|
+
* scans only kick in for a project that has hook chats to show.
|
|
456
|
+
*/
|
|
457
|
+
listSessions(project: Project): Promise<DiscoveredSession[]>;
|
|
458
|
+
/**
|
|
459
|
+
* The on-disk job-record reads (run history + the unread badge) live in
|
|
460
|
+
* `./herdctl-jobs.js` as pure functions over `<stateDir>/jobs` (issue #403);
|
|
461
|
+
* these thin wrappers thread `this.cfg.stateDir` (or, for the two unread-badge
|
|
462
|
+
* reads, this service's {@link jobsIndex}). See there for the full semantics of
|
|
463
|
+
* each (unread signal, per-project grouping, run history).
|
|
464
|
+
*/
|
|
465
|
+
lastTurnCompletedAt(): Promise<Map<string, string>>;
|
|
466
|
+
lastTurnCompletedAtByProject(): Promise<Map<string, Map<string, string>>>;
|
|
467
|
+
listProjectRuns(project: Project, limit?: number): Promise<JobMetadata[]>;
|
|
468
|
+
listRunsForAgents(agents: string[], limit?: number): Promise<JobMetadata[]>;
|
|
469
|
+
/**
|
|
470
|
+
* Promote a chat into a NEW project: re-home its transcript into that
|
|
471
|
+
* project's `.chats/` (rewriting the embedded `cwd` so the transcript reports
|
|
472
|
+
* the new project dir) and re-point the session's herdctl job records at the
|
|
473
|
+
* new keeper. After this + the cache invalidations below the chat lists and
|
|
474
|
+
* resumes under the new project with NO restart — doing the same writes from
|
|
475
|
+
* outside the process would need one, to drop the attribution-index cache.
|
|
476
|
+
*
|
|
477
|
+
* Moves one chat from one keeper's store to another's. The root is a workspace
|
|
478
|
+
* like any other, so root chats carry the promote action too.
|
|
479
|
+
*
|
|
480
|
+
* The caller MUST have already created `to` and registered its keeper
|
|
481
|
+
* (ensureProjectAgent), so its `.chats/` + transcript symlink exist. Throws if
|
|
482
|
+
* the source transcript can't be read (e.g. unknown session id).
|
|
483
|
+
*/
|
|
484
|
+
promoteSession(sessionId: string, from: Project, to: Project): Promise<void>;
|
|
485
|
+
/**
|
|
486
|
+
* Fork a project chat: eagerly duplicate `sourceSessionId`'s transcript into a
|
|
487
|
+
* brand-new session in the SAME project, so the fork exists immediately — a
|
|
488
|
+
* real, resumable chat with the full parent history visible — rather than being
|
|
489
|
+
* materialized only when the user sends a first message. The source is left
|
|
490
|
+
* untouched (this is a copy, not a move).
|
|
491
|
+
*
|
|
492
|
+
* Same mechanics as {@link promoteSession} (copy the JSONL, keep it
|
|
493
|
+
* discoverable + attributed), with two differences: a NEW session id is minted
|
|
494
|
+
* and rewritten onto every transcript line (so the copy is internally
|
|
495
|
+
* consistent with its new filename — Claude Code stamps appended lines with the
|
|
496
|
+
* file's id, and a mismatch is version-fragile), and the source file is kept.
|
|
497
|
+
* `cwd` is unchanged (the fork stays in the same project). Returns the new id.
|
|
498
|
+
*/
|
|
499
|
+
/**
|
|
500
|
+
* Whether a chat transcript exists for `sessionId` in `project`. Used by the
|
|
501
|
+
* self-management MCP write tools (#214) to validate a caller-supplied target
|
|
502
|
+
* before forking / messaging it, so a bad id yields a clean "not found" instead
|
|
503
|
+
* of a raw ENOENT (fork) or a false-positive success (send_message). Rejects a
|
|
504
|
+
* malformed id (path-traversal guard) as non-existent.
|
|
505
|
+
*/
|
|
506
|
+
sessionExists(project: Project, sessionId: string): Promise<boolean>;
|
|
507
|
+
forkSession(project: Project, sourceSessionId: string, name?: string, fromUuid?: string): Promise<string>;
|
|
508
|
+
/**
|
|
509
|
+
* Revert a chat back to an earlier message (issue #451): truncate the session's
|
|
510
|
+
* transcript at `toUuid`, in place, keeping the SAME session id — so the chat's
|
|
511
|
+
* identity/URL is preserved and the next turn continues as if the later
|
|
512
|
+
* messages never happened. The dropped tail is backed up (recoverable) to a
|
|
513
|
+
* `.reverts/` sidecar that is deliberately kept out of the discoverable
|
|
514
|
+
* `<id>.jsonl` namespace so it never lists as a chat.
|
|
515
|
+
*
|
|
516
|
+
* NOTE: this rolls back the CONVERSATION only — real-world side-effects of the
|
|
517
|
+
* reverted turns (files written, PRs opened, messages sent) are NOT undone. The
|
|
518
|
+
* caller's UI is responsible for warning about that. Returns the number of
|
|
519
|
+
* transcript records dropped.
|
|
520
|
+
*/
|
|
521
|
+
revertSession(project: Project, sessionId: string, toUuid: string): Promise<{
|
|
522
|
+
removed: number;
|
|
523
|
+
}>;
|
|
524
|
+
/**
|
|
525
|
+
* Attribute an *in-flight* session to its agent the moment its id is known —
|
|
526
|
+
* mid first turn — so a brand-new chat lists in the sidebar immediately
|
|
527
|
+
* instead of only after the first turn finishes (issue #100).
|
|
528
|
+
*
|
|
529
|
+
* The core attribution index is built from herdctl job records, and herdctl
|
|
530
|
+
* writes the resolved `session_id` into a run's own job record only on
|
|
531
|
+
* completion. While the first turn runs, that record has `session_id: null`,
|
|
532
|
+
* so the session is unattributed and {@link SessionDiscoveryService.getAgentSessions}
|
|
533
|
+
* filters it out. We close that window with the SAME synthetic-job-record
|
|
534
|
+
* trick used for fork/promote: write an adoption record keyed to the session
|
|
535
|
+
* id, then drop the discovery + attribution caches so the next list call
|
|
536
|
+
* surfaces it. Idempotent — a stable per-session job id means a repeat call
|
|
537
|
+
* just overwrites the same file, and when the real run later finalizes its own
|
|
538
|
+
* record (same session id, same agent) the attribution is unchanged.
|
|
539
|
+
*
|
|
540
|
+
* @param sessionId - The freshly-resolved session id of the running turn
|
|
541
|
+
* @param agentName - The qualified agent the session belongs to
|
|
542
|
+
*/
|
|
543
|
+
attributeRunningSession(sessionId: string, agentName: string): Promise<void>;
|
|
544
|
+
/** Read the parsed messages of a session, by agent name. */
|
|
545
|
+
sessionMessages(agentName: string, sessionId: string): Promise<ChatMessage[]>;
|
|
546
|
+
/**
|
|
547
|
+
* Slash commands available to an agent, memoized per agent name. The set is
|
|
548
|
+
* stable per project (built-ins + the project's `.claude/commands` + any
|
|
549
|
+
* MCP-provided commands) and each underlying `listAgentCommands` call spawns a
|
|
550
|
+
* short-lived `claude` streaming subprocess (open → query → close), so we
|
|
551
|
+
* cache aggressively. The cache is process-lifetime: it fills on first use and
|
|
552
|
+
* only clears on server restart — the same boot-only invalidation the fleet's
|
|
553
|
+
* agent registration already relies on. A concurrent first call is
|
|
554
|
+
* deduplicated by caching the in-flight promise, so a burst of composer fetches
|
|
555
|
+
* spawns exactly one subprocess.
|
|
556
|
+
*/
|
|
557
|
+
private commandsCache;
|
|
558
|
+
listCommands(agentName: string): Promise<SlashCommand[]>;
|
|
559
|
+
private keeperAgentConfig;
|
|
560
|
+
private sweeperAgentConfig;
|
|
561
|
+
/**
|
|
562
|
+
* Create the sweeper's own working directory (+ symlink its encoded transcript
|
|
563
|
+
* path at a `.chats/` inside it), so the tool-less curator never shares a CLI
|
|
564
|
+
* session directory with the project's keeper (issue #548). Reuses
|
|
565
|
+
* `ensureProjectChats` with the sweeper dir as both cwd and chats host, which
|
|
566
|
+
* also mkdir's the dir itself. Never throws — the helper swallows its own
|
|
567
|
+
* errors, and a missing symlink only means Claude keeps its default location.
|
|
568
|
+
*/
|
|
569
|
+
private ensureSweeperHome;
|
|
570
|
+
private triggerAgentConfig;
|
|
571
|
+
private ensureConfigFile;
|
|
572
|
+
}
|