@edspencer/paddock 0.61.1 → 0.62.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.
Files changed (92) hide show
  1. package/README.md +35 -14
  2. package/package.json +1 -1
  3. package/packages/server/dist/app.js +35 -8
  4. package/packages/server/dist/claude-credentials.d.ts +116 -0
  5. package/packages/server/dist/claude-credentials.js +103 -0
  6. package/packages/server/dist/claude-home.d.ts +102 -30
  7. package/packages/server/dist/claude-home.js +437 -97
  8. package/packages/server/dist/claude-instructions.d.ts +121 -0
  9. package/packages/server/dist/claude-instructions.js +114 -0
  10. package/packages/server/dist/claude-mcp.d.ts +146 -0
  11. package/packages/server/dist/claude-mcp.js +367 -0
  12. package/packages/server/dist/claude-settings.d.ts +159 -0
  13. package/packages/server/dist/claude-settings.js +159 -0
  14. package/packages/server/dist/cli/args.d.ts +1 -9
  15. package/packages/server/dist/cli/args.js +36 -18
  16. package/packages/server/dist/cli/paddock.js +20 -39
  17. package/packages/server/dist/config.d.ts +166 -30
  18. package/packages/server/dist/config.js +106 -26
  19. package/packages/server/dist/herdctl-agent-config.d.ts +11 -1
  20. package/packages/server/dist/herdctl-agent-config.js +53 -7
  21. package/packages/server/dist/herdctl-agent-names.d.ts +11 -0
  22. package/packages/server/dist/herdctl-agent-names.js +31 -0
  23. package/packages/server/dist/herdctl.d.ts +69 -13
  24. package/packages/server/dist/herdctl.js +70 -18
  25. package/packages/server/dist/instance-config.js +36 -0
  26. package/packages/server/dist/mcp-servers.d.ts +168 -0
  27. package/packages/server/dist/mcp-servers.js +305 -0
  28. package/packages/server/dist/routes/chats.js +10 -4
  29. package/packages/server/dist/transcripts.d.ts +61 -30
  30. package/packages/server/dist/transcripts.js +141 -46
  31. package/packages/server/package.json +1 -1
  32. package/packages/web/dist/assets/{InstanceConfigPage-BgNXqAox.js → InstanceConfigPage-Ca905oey.js} +1 -1
  33. package/packages/web/dist/assets/{MarkdownRenderer-DfD_UtqU.js → MarkdownRenderer-ChlC1ezH.js} +1 -1
  34. package/packages/web/dist/assets/{ProjectRedirect-1EXdHXmO.js → ProjectRedirect-CslqbhUb.js} +1 -1
  35. package/packages/web/dist/assets/{ProjectView-DHb5vNUp.js → ProjectView-DkNdilGo.js} +3 -3
  36. package/packages/web/dist/assets/{ProjectsGrid-Br-EhLZE.js → ProjectsGrid-BrlvLc-Y.js} +1 -1
  37. package/packages/web/dist/assets/{arc-C2Jekujs.js → arc-CGqCI5nQ.js} +1 -1
  38. package/packages/web/dist/assets/{architectureDiagram-3BPJPVTR-CflCA-em.js → architectureDiagram-3BPJPVTR-Cp4KTxE2.js} +1 -1
  39. package/packages/web/dist/assets/{blockDiagram-GPEHLZMM-Ds7GLNnC.js → blockDiagram-GPEHLZMM-yFxaTv04.js} +1 -1
  40. package/packages/web/dist/assets/{c4Diagram-AAUBKEIU-D4WyGO6I.js → c4Diagram-AAUBKEIU-59lhWjRt.js} +1 -1
  41. package/packages/web/dist/assets/channel-CZs6Z1i5.js +2 -0
  42. package/packages/web/dist/assets/{chunk-2J33WTMH-tQunO_M5.js → chunk-2J33WTMH-BrpXGnJg.js} +1 -1
  43. package/packages/web/dist/assets/{chunk-4BX2VUAB-DT5dOWd2.js → chunk-4BX2VUAB-UxBDb5pi.js} +1 -1
  44. package/packages/web/dist/assets/{chunk-55IACEB6-CfTUqUEF.js → chunk-55IACEB6-D4ZJyUHW.js} +1 -1
  45. package/packages/web/dist/assets/{chunk-727SXJPM-sK5bOAA0.js → chunk-727SXJPM-DWdPj_8E.js} +1 -1
  46. package/packages/web/dist/assets/{chunk-AQP2D5EJ-DcMgVe-P.js → chunk-AQP2D5EJ-BIpNbflY.js} +1 -1
  47. package/packages/web/dist/assets/{chunk-FMBD7UC4-In3h_-7v.js → chunk-FMBD7UC4-f6iJDfdI.js} +1 -1
  48. package/packages/web/dist/assets/{chunk-ND2GUHAM-DuaIeRaC.js → chunk-ND2GUHAM-Bz3TKIJk.js} +1 -1
  49. package/packages/web/dist/assets/{chunk-QZHKN3VN-DeT5mR5T.js → chunk-QZHKN3VN-buQmkafK.js} +1 -1
  50. package/packages/web/dist/assets/classDiagram-4FO5ZUOK-CrbEUUCd.js +2 -0
  51. package/packages/web/dist/assets/classDiagram-v2-Q7XG4LA2-CrbEUUCd.js +2 -0
  52. package/packages/web/dist/assets/{core-DgOgLvnM.js → core-TyFI6p0n.js} +1 -1
  53. package/packages/web/dist/assets/{cose-bilkent-S5V4N54A-CyO-rznJ.js → cose-bilkent-S5V4N54A-CIkdi0XF.js} +1 -1
  54. package/packages/web/dist/assets/{dagre-BM42HDAG-B_9Ihzgn.js → dagre-BM42HDAG-BnLJCfNs.js} +1 -1
  55. package/packages/web/dist/assets/{diagram-2AECGRRQ-z5mvZ5YT.js → diagram-2AECGRRQ-D0OqfDB9.js} +1 -1
  56. package/packages/web/dist/assets/{diagram-5GNKFQAL-Bsz0cgfn.js → diagram-5GNKFQAL-DQ2spGrK.js} +1 -1
  57. package/packages/web/dist/assets/{diagram-KO2AKTUF-B29k5f4q.js → diagram-KO2AKTUF-RDIVQ_S3.js} +1 -1
  58. package/packages/web/dist/assets/{diagram-LMA3HP47-CFrwsHoI.js → diagram-LMA3HP47-DKoTfh2C.js} +1 -1
  59. package/packages/web/dist/assets/{diagram-OG6HWLK6-D9Sjc2HR.js → diagram-OG6HWLK6-6k0OuSAL.js} +1 -1
  60. package/packages/web/dist/assets/{erDiagram-TEJ5UH35-C3vbkD7M.js → erDiagram-TEJ5UH35-B-oQaYAC.js} +1 -1
  61. package/packages/web/dist/assets/{flowDiagram-I6XJVG4X-DkMIgntd.js → flowDiagram-I6XJVG4X-B7qpYe9C.js} +1 -1
  62. package/packages/web/dist/assets/{format-BFDqyFuw.js → format-PHdEBNOi.js} +1 -1
  63. package/packages/web/dist/assets/{ganttDiagram-6RSMTGT7-nvHanjpW.js → ganttDiagram-6RSMTGT7-SfBsqMmx.js} +1 -1
  64. package/packages/web/dist/assets/{gitGraphDiagram-PVQCEYII-DbCNfOu7.js → gitGraphDiagram-PVQCEYII-CuM4Rl_i.js} +1 -1
  65. package/packages/web/dist/assets/{index-DGCs1YIO.js → index-D_1ogxg1.js} +2 -2
  66. package/packages/web/dist/assets/{infoDiagram-5YYISTIA-aJjH9x3D.js → infoDiagram-5YYISTIA-Dq-32Oj4.js} +1 -1
  67. package/packages/web/dist/assets/{ishikawaDiagram-YF4QCWOH-DoifwNnZ.js → ishikawaDiagram-YF4QCWOH-BLFHCj_o.js} +1 -1
  68. package/packages/web/dist/assets/{journeyDiagram-JHISSGLW-Cz9kG9HN.js → journeyDiagram-JHISSGLW-CHP-Yu63.js} +1 -1
  69. package/packages/web/dist/assets/{kanban-definition-UN3LZRKU-BoXnfr7A.js → kanban-definition-UN3LZRKU-DRuehSqn.js} +1 -1
  70. package/packages/web/dist/assets/{linear-BlTTO9yR.js → linear-Bwz2vnH7.js} +1 -1
  71. package/packages/web/dist/assets/{mermaid.core-YAG8eSPQ.js → mermaid.core-CeMMnCip.js} +4 -4
  72. package/packages/web/dist/assets/{mindmap-definition-RKZ34NQL-DtUBKfkr.js → mindmap-definition-RKZ34NQL-CEdqeoRW.js} +1 -1
  73. package/packages/web/dist/assets/{pieDiagram-4H26LBE5-B3Rwpmy0.js → pieDiagram-4H26LBE5-BdDXBx87.js} +1 -1
  74. package/packages/web/dist/assets/{quadrantDiagram-W4KKPZXB-B8eJtTyk.js → quadrantDiagram-W4KKPZXB-Bovd1Zhx.js} +1 -1
  75. package/packages/web/dist/assets/{requirementDiagram-4Y6WPE33-CpAluiY9.js → requirementDiagram-4Y6WPE33-DiyrKnJ2.js} +1 -1
  76. package/packages/web/dist/assets/{sankeyDiagram-5OEKKPKP-Cl_Rd1tN.js → sankeyDiagram-5OEKKPKP-BuX7TRVw.js} +1 -1
  77. package/packages/web/dist/assets/{sequenceDiagram-3UESZ5HK-CRpqKSGm.js → sequenceDiagram-3UESZ5HK-BjetZWJo.js} +1 -1
  78. package/packages/web/dist/assets/{stateDiagram-AJRCARHV-h3h8gXv_.js → stateDiagram-AJRCARHV-4AUBV6dF.js} +1 -1
  79. package/packages/web/dist/assets/stateDiagram-v2-BHNVJYJU-Cq84MOtb.js +2 -0
  80. package/packages/web/dist/assets/{timeline-definition-PNZ67QCA-PVr5V_pG.js → timeline-definition-PNZ67QCA-BpQ8g8Bm.js} +1 -1
  81. package/packages/web/dist/assets/{vennDiagram-CIIHVFJN-De-4NPAX.js → vennDiagram-CIIHVFJN-Cj99BWER.js} +1 -1
  82. package/packages/web/dist/assets/{wardley-L42UT6IY-Dtv10D2d.js → wardley-L42UT6IY-S7AGTOWw.js} +1 -1
  83. package/packages/web/dist/assets/{wardleyDiagram-YWT4CUSO-p2fJuQ6C.js → wardleyDiagram-YWT4CUSO-LNXkUA7S.js} +1 -1
  84. package/packages/web/dist/assets/{xychartDiagram-2RQKCTM6-DyYF-k92.js → xychartDiagram-2RQKCTM6-DGdTh4Xk.js} +1 -1
  85. package/packages/web/dist/index.html +1 -1
  86. package/packages/web/dist/sw.js +1 -1
  87. package/packages/server/dist/cli/claude-home-choice.d.ts +0 -44
  88. package/packages/server/dist/cli/claude-home-choice.js +0 -108
  89. package/packages/web/dist/assets/channel-B1K_gwAH.js +0 -2
  90. package/packages/web/dist/assets/classDiagram-4FO5ZUOK-DYQQOKrW.js +0 -2
  91. package/packages/web/dist/assets/classDiagram-v2-Q7XG4LA2-DYQQOKrW.js +0 -2
  92. package/packages/web/dist/assets/stateDiagram-v2-BHNVJYJU-BKRI9TnH.js +0 -2
@@ -50,6 +50,7 @@ import { FleetManager, type DiscoveredSession, type ChatMessage, type SDKMessage
50
50
  import type { PaddockConfig } from "./config.js";
51
51
  import type { Project } from "./projects.js";
52
52
  import { type PaddockTrigger } from "./trigger-config.js";
53
+ import { type McpSources } from "./claude-mcp.js";
53
54
  import { type AdoptableSummary, type FilterReason } from "./adoptable.js";
54
55
  /**
55
56
  * One session an import did NOT bring in, with a reason a UI can show verbatim.
@@ -63,6 +64,20 @@ export type AdoptSkipped = AdoptSkippedSession | {
63
64
  reason: FilterReason;
64
65
  detail?: string;
65
66
  };
67
+ /**
68
+ * Outcome of deleting a chat (#689).
69
+ *
70
+ * Two fields rather than one boolean because "the transcript is gone" and "the
71
+ * chat is no longer listed here" stopped being the same thing: in a home paddock
72
+ * does not own, the file belongs to the user's terminal `claude` and is released
73
+ * rather than removed. See {@link HerdctlService.deleteSession}.
74
+ */
75
+ export interface ChatDeletion {
76
+ /** A transcript file was unlinked. False when none existed, or when retained. */
77
+ removed: boolean;
78
+ /** The transcript was deliberately left on disk because it is not paddock's. */
79
+ retained: boolean;
80
+ }
66
81
  /** Options passed through to a streamed trigger. */
67
82
  export interface ChatTurnOptions {
68
83
  prompt: string;
@@ -105,6 +120,7 @@ export { keeperAgentName, keeperSlugFromAgent, SWEEPER_PREFIX, sweeperAgentName,
105
120
  export declare function sliceTranscriptAtUuid(raw: string, cutUuid: string, endOnCompletedAssistant?: boolean): string | null;
106
121
  export declare class HerdctlService {
107
122
  private readonly cfg;
123
+ private readonly mcpSources;
108
124
  private fleet;
109
125
  private started;
110
126
  /**
@@ -164,13 +180,27 @@ export declare class HerdctlService {
164
180
  */
165
181
  private jobsIndexOrNull;
166
182
  private get jobsIndex();
167
- constructor(cfg: PaddockConfig);
168
183
  /**
169
- * The Claude home every transcript symlink is planted in, plus whether paddock
170
- * owns it (#620). One accessor, so no call site can quietly take a default and
171
- * land in a different home than the FleetManager was built with — the bug
172
- * `ensureSweeperHome` had, which put the sweeper's symlink in `~/.claude` while
173
- * every other agent's went to the configured home.
184
+ * The external MCP servers every keeper gets: the user's own under
185
+ * `claude.mcpServers: host` (#691 step 5, read once at boot by
186
+ * `loadHostMcpSource`) plus the ones this instance declares in its own
187
+ * `mcpServers:` block (step 6, resolved during config load). Both are merged
188
+ * into one value by `buildApp` and handed in here.
189
+ *
190
+ * A constructor argument rather than something this service reads for itself,
191
+ * for the same reason `ensureClaudeHome` runs in `buildApp`: the read has
192
+ * notices an operator needs to see in the boot log, and it must not happen at
193
+ * all under `mcpServers: own`. Defaults to empty so every existing caller —
194
+ * including the several tests that construct this with `{} as PaddockConfig` —
195
+ * keeps meaning "isolated".
196
+ */
197
+ constructor(cfg: PaddockConfig, mcpSources?: McpSources);
198
+ /**
199
+ * The Claude home every transcript symlink is planted in, plus where those
200
+ * symlinks point (#620, #691). One accessor, so no call site can quietly take
201
+ * a default and land in a different home than the FleetManager was built with
202
+ * — the bug `ensureSweeperHome` had, which put the sweeper's symlink in
203
+ * `~/.claude` while every other agent's went to the configured home.
174
204
  */
175
205
  private get claudeHomeTarget();
176
206
  /**
@@ -421,13 +451,39 @@ export declare class HerdctlService {
421
451
  */
422
452
  removeProjectAgent(slug: string, hookNames?: string[], triggerNames?: string[]): Promise<void>;
423
453
  /**
424
- * Delete a single chat (session) by agent name + session id. The FleetManager
425
- * resolves the agent's working directory, removes the transcript JSONL, and
426
- * invalidates the discovery cache so the list reflects it immediately.
427
- * Validates the sessionId (rejects path traversal). Returns true if a
428
- * transcript file was removed, false if none existed.
429
- */
430
- deleteSession(agentName: string, sessionId: string): Promise<boolean>;
454
+ * Delete a single chat (session) by agent name + session id.
455
+ *
456
+ * Under `claude.transcripts: own`, this removes the transcript JSONL: the file
457
+ * lives in paddock's own tree (via the project's `.chats/` symlink), so it is
458
+ * ours to delete. The FleetManager resolves the agent's working directory,
459
+ * unlinks the file, validates the sessionId against traversal, and invalidates
460
+ * the discovery cache so the list reflects it immediately.
461
+ *
462
+ * Under `claude.transcripts: host`, it **releases the session instead** (#689).
463
+ * There is no copy to delete there: the symlink points OUT at
464
+ * `~/.claude/projects/<encoded-cwd>/`, so the transcript the agent reads and
465
+ * writes is the user's own — for an adopted chat, literally their terminal
466
+ * history. `rm`-ing it destroys history paddock never owned, which is the same
467
+ * class of mistake #682 was, pointed the other way: that one claimed where
468
+ * future sessions get written, this one deletes the past ones.
469
+ *
470
+ * `undoImport` already draws exactly this line ("A session adopted in place has
471
+ * no copy, and its transcript is the user's own — removing it would destroy
472
+ * history rather than restore it"); the invariant simply never reached here.
473
+ *
474
+ * The discriminator changed with #691 and the meaning did not. It used to be
475
+ * `ownsClaudeHome` — "is this home ours?" — which is now always true; the
476
+ * question that survives is "is this transcript ours?", and that is exactly
477
+ * what `transcripts` says. Deliberately NOT narrowed to "only adopted chats":
478
+ * under `host` a chat paddock started itself is in the user's tree too, and
479
+ * distinguishing them well enough to risk an `rm` is not worth the failure mode
480
+ * of getting it wrong. The cost is a transcript left behind, which the caller
481
+ * is told about; the alternative cost is somebody's history.
482
+ *
483
+ * The chat leaves paddock's list either way — which is what the user asked for
484
+ * — so `retained` is how a caller tells "gone" from "no longer shown here".
485
+ */
486
+ deleteSession(agentName: string, sessionId: string): Promise<ChatDeletion>;
431
487
  /**
432
488
  * Set (or clear) a chat's custom display name. Writes through the fleet's
433
489
  * shared SessionMetadataStore so a subsequent getAgentSessions reflects it
@@ -56,6 +56,7 @@ import { DEFAULT_MODEL } from "./models.js";
56
56
  import { ensureProjectChats, projectChatsDir } from "./transcripts.js";
57
57
  import { triggerRunsOnOwnAgent, isCuratorTrigger, } from "./trigger-config.js";
58
58
  import { buildAgentConfig, buildSweeperConfig, sweeperWorkingDir, buildTriggerConfig, ensureConfigFile as writeBootConfigFile, } from "./herdctl-agent-config.js";
59
+ import { EMPTY_MCP_SOURCES } from "./claude-mcp.js";
59
60
  import * as jobs from "./herdctl-jobs.js";
60
61
  import { JobsDirIndex } from "./herdctl-jobs-index.js";
61
62
  import { AdoptableIndex } from "./adoptable.js";
@@ -162,6 +163,7 @@ export function sliceTranscriptAtUuid(raw, cutUuid, endOnCompletedAssistant = fa
162
163
  }
163
164
  export class HerdctlService {
164
165
  cfg;
166
+ mcpSources;
165
167
  fleet = null;
166
168
  started = false;
167
169
  /**
@@ -223,18 +225,37 @@ export class HerdctlService {
223
225
  get jobsIndex() {
224
226
  return (this.jobsIndexOrNull ??= new JobsDirIndex(this.cfg.stateDir));
225
227
  }
226
- constructor(cfg) {
228
+ /**
229
+ * The external MCP servers every keeper gets: the user's own under
230
+ * `claude.mcpServers: host` (#691 step 5, read once at boot by
231
+ * `loadHostMcpSource`) plus the ones this instance declares in its own
232
+ * `mcpServers:` block (step 6, resolved during config load). Both are merged
233
+ * into one value by `buildApp` and handed in here.
234
+ *
235
+ * A constructor argument rather than something this service reads for itself,
236
+ * for the same reason `ensureClaudeHome` runs in `buildApp`: the read has
237
+ * notices an operator needs to see in the boot log, and it must not happen at
238
+ * all under `mcpServers: own`. Defaults to empty so every existing caller —
239
+ * including the several tests that construct this with `{} as PaddockConfig` —
240
+ * keeps meaning "isolated".
241
+ */
242
+ constructor(cfg, mcpSources = EMPTY_MCP_SOURCES) {
227
243
  this.cfg = cfg;
244
+ this.mcpSources = mcpSources;
228
245
  }
229
246
  /**
230
- * The Claude home every transcript symlink is planted in, plus whether paddock
231
- * owns it (#620). One accessor, so no call site can quietly take a default and
232
- * land in a different home than the FleetManager was built with — the bug
233
- * `ensureSweeperHome` had, which put the sweeper's symlink in `~/.claude` while
234
- * every other agent's went to the configured home.
247
+ * The Claude home every transcript symlink is planted in, plus where those
248
+ * symlinks point (#620, #691). One accessor, so no call site can quietly take
249
+ * a default and land in a different home than the FleetManager was built with
250
+ * — the bug `ensureSweeperHome` had, which put the sweeper's symlink in
251
+ * `~/.claude` while every other agent's went to the configured home.
235
252
  */
236
253
  get claudeHomeTarget() {
237
- return { path: this.cfg.claudeHome, owned: this.cfg.ownsClaudeHome };
254
+ return {
255
+ path: this.cfg.claudeHome,
256
+ transcripts: this.cfg.claude.transcripts,
257
+ userHome: this.cfg.legacyClaudeHome,
258
+ };
238
259
  }
239
260
  /**
240
261
  * The environment system prompt to append to a keeper turn (issue #635), or
@@ -309,10 +330,10 @@ export class HerdctlService {
309
330
  allowScheduleMutation: this.cfg.scheduleMutationEnabled,
310
331
  // Hand the engine the SAME Claude home paddock resolved (#588). Omitting
311
332
  // it makes the engine fall back to `os.homedir()/.claude` while paddock
312
- // honours `CLAUDE_HOME`, so discovery, adoption and paddock's `.chats/`
313
- // symlinks would resolve against different directories — sessions list
314
- // from one home and open empty from the other. Masked whenever the two
315
- // coincide, which is why it must be explicit.
333
+ // uses its own, so discovery, adoption and paddock's transcript symlinks
334
+ // would resolve against different directories — sessions list from one
335
+ // home and open empty from the other. Masked whenever the two coincide,
336
+ // which is why it must be explicit.
316
337
  claudeHomePath: this.cfg.claudeHome,
317
338
  });
318
339
  await this.fleet.initialize();
@@ -763,14 +784,45 @@ export class HerdctlService {
763
784
  }
764
785
  }
765
786
  /**
766
- * Delete a single chat (session) by agent name + session id. The FleetManager
767
- * resolves the agent's working directory, removes the transcript JSONL, and
768
- * invalidates the discovery cache so the list reflects it immediately.
769
- * Validates the sessionId (rejects path traversal). Returns true if a
770
- * transcript file was removed, false if none existed.
787
+ * Delete a single chat (session) by agent name + session id.
788
+ *
789
+ * Under `claude.transcripts: own`, this removes the transcript JSONL: the file
790
+ * lives in paddock's own tree (via the project's `.chats/` symlink), so it is
791
+ * ours to delete. The FleetManager resolves the agent's working directory,
792
+ * unlinks the file, validates the sessionId against traversal, and invalidates
793
+ * the discovery cache so the list reflects it immediately.
794
+ *
795
+ * Under `claude.transcripts: host`, it **releases the session instead** (#689).
796
+ * There is no copy to delete there: the symlink points OUT at
797
+ * `~/.claude/projects/<encoded-cwd>/`, so the transcript the agent reads and
798
+ * writes is the user's own — for an adopted chat, literally their terminal
799
+ * history. `rm`-ing it destroys history paddock never owned, which is the same
800
+ * class of mistake #682 was, pointed the other way: that one claimed where
801
+ * future sessions get written, this one deletes the past ones.
802
+ *
803
+ * `undoImport` already draws exactly this line ("A session adopted in place has
804
+ * no copy, and its transcript is the user's own — removing it would destroy
805
+ * history rather than restore it"); the invariant simply never reached here.
806
+ *
807
+ * The discriminator changed with #691 and the meaning did not. It used to be
808
+ * `ownsClaudeHome` — "is this home ours?" — which is now always true; the
809
+ * question that survives is "is this transcript ours?", and that is exactly
810
+ * what `transcripts` says. Deliberately NOT narrowed to "only adopted chats":
811
+ * under `host` a chat paddock started itself is in the user's tree too, and
812
+ * distinguishing them well enough to risk an `rm` is not worth the failure mode
813
+ * of getting it wrong. The cost is a transcript left behind, which the caller
814
+ * is told about; the alternative cost is somebody's history.
815
+ *
816
+ * The chat leaves paddock's list either way — which is what the user asked for
817
+ * — so `retained` is how a caller tells "gone" from "no longer shown here".
771
818
  */
772
819
  async deleteSession(agentName, sessionId) {
773
- return this.manager.deleteSession(agentName, sessionId);
820
+ if (this.cfg.claude.transcripts === "own") {
821
+ return { removed: await this.manager.deleteSession(agentName, sessionId), retained: false };
822
+ }
823
+ await this.manager.unadoptSession(agentName, sessionId).catch(() => undefined);
824
+ this.invalidateSessions(agentName);
825
+ return { removed: false, retained: true };
774
826
  }
775
827
  /**
776
828
  * Set (or clear) a chat's custom display name. Writes through the fleet's
@@ -1456,7 +1508,7 @@ export class HerdctlService {
1456
1508
  // existing unit-test seams (which reach `sweeperAgentConfig`/`ensureConfigFile`
1457
1509
  // via a cast) and internal callers keep working.
1458
1510
  keeperAgentConfig(project, modelOverride) {
1459
- return buildAgentConfig(this.cfg, project, modelOverride);
1511
+ return buildAgentConfig(this.cfg, project, modelOverride, this.mcpSources);
1460
1512
  }
1461
1513
  sweeperAgentConfig(project) {
1462
1514
  return buildSweeperConfig(this.cfg, project);
@@ -36,6 +36,11 @@ import { DEFAULT_RECOVERY } from "./recovery-config.js";
36
36
  import { DEFAULT_ATTACHMENTS, sanitizeAllowedTypes } from "./attachments-config.js";
37
37
  import { DEFAULT_CURATION } from "./curation-config.js";
38
38
  import { DEFAULT_ENVIRONMENT_PROMPT } from "./environment-prompt.js";
39
+ import { DEFAULT_TRANSCRIPTS_MODE } from "./transcripts.js";
40
+ import { DEFAULT_CREDENTIALS_MODE } from "./claude-credentials.js";
41
+ import { DEFAULT_INSTRUCTIONS_MODE } from "./claude-instructions.js";
42
+ import { DEFAULT_HOOKS_MODE } from "./claude-settings.js";
43
+ import { DEFAULT_MCP_SERVERS_MODE } from "./claude-mcp.js";
39
44
  /** Groups the Settings screen renders, in display order. */
40
45
  export const GROUPS = [
41
46
  { id: "curation", label: "Curation", description: "Per-file token budgets the post-turn sweeper keeps its curated files under." },
@@ -219,6 +224,37 @@ export const FIELDS = [
219
224
  { key: "stateDir", group: "advanced", label: "State dir", type: "string", envVars: ["PADDOCK_STATE_DIR"], default: null, editable: false },
220
225
  { key: "herdctlConfigPath", group: "advanced", label: "herdctl config path", type: "string", envVars: ["PADDOCK_HERDCTL_CONFIG"], default: null, editable: false },
221
226
  { key: "webDist", group: "advanced", label: "Web dist", type: "string", envVars: ["PADDOCK_WEB_DIST"], default: null, editable: false },
227
+ // What this instance shares with the host's Claude Code (#691). READ-ONLY on
228
+ // purpose: `host` means paddock writes to the user's real transcript files,
229
+ // and the symlinks that implement it are planted at agent-registration time —
230
+ // a toggle that silently does nothing until the next boot would be worse than
231
+ // no toggle. It is surfaced because "what is this instance sharing?" should be
232
+ // answerable without reading a YAML file.
233
+ { key: "claude.transcripts", group: "advanced", label: "Transcripts", help: "own = Paddock's own, in each project's .chats/; host = your ~/.claude transcripts, shared live.", type: "string", envVars: ["PADDOCK_CLAUDE_TRANSCRIPTS"], default: DEFAULT_TRANSCRIPTS_MODE, editable: false },
234
+ // Read-only for the same reason, plus one of its own: the secure-storage
235
+ // variable it sets is read by Claude Code when a turn's process starts, so a
236
+ // live toggle would apply to some turns and not others.
237
+ { key: "claude.credentials", group: "advanced", label: "Credentials", help: "host = this machine's Claude Code login (macOS Keychain, or your ~/.claude/.credentials.json); own = only a login of this instance's.", type: "string", envVars: ["PADDOCK_CLAUDE_CREDENTIALS"], default: DEFAULT_CREDENTIALS_MODE, editable: false },
238
+ // Read-only for the same reasons. `hooks` is the one worth finding here even
239
+ // though it cannot be changed here: "does this instance run the shell commands
240
+ // my ~/.claude/settings.json binds to tool use?" is a question with a security
241
+ // answer, and it should be readable without opening a YAML file.
242
+ { key: "claude.instructions", group: "advanced", label: "Instructions", help: "own = this instance's own only; host = your ~/.claude CLAUDE.md, agents/, commands/ and plugins/ as well.", type: "string", envVars: ["PADDOCK_CLAUDE_INSTRUCTIONS"], default: DEFAULT_INSTRUCTIONS_MODE, editable: false },
243
+ { key: "claude.hooks", group: "advanced", label: "Hooks", help: "own = your ~/.claude/settings.json hooks do NOT run here (its other keys still apply); host = they do.", type: "string", envVars: ["PADDOCK_CLAUDE_HOOKS"], default: DEFAULT_HOOKS_MODE, editable: false },
244
+ // The fifth lever, which step 5 shipped without surfacing here. Read-only like
245
+ // its four siblings, and worth the row for the same reason `hooks` is: an MCP
246
+ // server is a process this instance spawns, so "is this instance running my
247
+ // machine's MCP servers?" should be answerable without opening a YAML file.
248
+ //
249
+ // NOTE what is deliberately absent: the top-level `mcpServers:` block (#691
250
+ // step 6), which declares servers rather than borrowing them. Its values hold
251
+ // resolved credentials — an MCP server's `env` is where a stdio server's API
252
+ // token lives — and every field in this table is serialised verbatim into the
253
+ // GET response, so a row for it would publish tokens to any authenticated UI
254
+ // user. There is no redacting variant of `FieldSpec`, and inventing one to
255
+ // display a server list is not worth the leak surface: the boot log already
256
+ // names every declared server, secret-free, via `describeServer`.
257
+ { key: "claude.mcpServers", group: "advanced", label: "MCP servers", help: "own = only the servers Paddock provides itself; host = the ones declared in your ~/.claude.json as well.", type: "string", envVars: ["PADDOCK_CLAUDE_MCP_SERVERS"], default: DEFAULT_MCP_SERVERS_MODE, editable: false },
222
258
  // Auth: read-only in v1 (misconfig can lock everyone out — issue #385). Only
223
259
  // the mode is surfaced; JWT/JWKS internals stay out of the API.
224
260
  { key: "auth.mode", group: "advanced", label: "Auth mode", type: "string", envVars: ["PADDOCK_AUTH_MODE"], default: "none", editable: false, sensitive: true },
@@ -0,0 +1,168 @@
1
+ /**
2
+ * The top-level `mcpServers:` block of `paddock.config.yaml` (#691 step 6):
3
+ * MCP servers a user declares **to paddock itself**.
4
+ *
5
+ * ## Why this is not another `claude:` key
6
+ *
7
+ * The five `claude:` levers all answer one question — *whose X does this instance
8
+ * use?* — and every one of them has a `host` side that borrows something the
9
+ * machine already has. `claude.mcpServers: host` therefore only helps a user who
10
+ * has already run `claude mcp add` on this box. Someone standing up paddock in a
11
+ * container, who wants Notion inside it, has nothing to borrow; the question they
12
+ * are asking is *"this instance should have this server"*, which is a declaration
13
+ * rather than an inheritance. So it is a sibling of `claude:`, not a member.
14
+ *
15
+ * ## Everything below the parse is shared with step 5
16
+ *
17
+ * `claude-mcp.ts` already built the hard half: the shape herdctl can carry, the
18
+ * per-working-directory merge, and — the trap — widening the keeper's
19
+ * `allowed_tools` by one `mcp__<name>__*` pattern per server, without which an
20
+ * attached server has every call auto-denied with no prompt and no log line. A
21
+ * declared server needs all of it identically, so this module produces
22
+ * {@link McpServerDefs} and hands them to {@link McpSources.declared}. The only
23
+ * thing that is genuinely new here is validation and secrets.
24
+ *
25
+ * ## Precedence
26
+ *
27
+ * `host` < declared < paddock's own. A name declared here beats the same name
28
+ * inherited from `~/.claude.json`, because this file is a statement about THIS
29
+ * instance and the other is ambient machine state. Paddock's own servers
30
+ * (`send_file`, the self-management tools, the browser server) still win, for the
31
+ * reason they already won over `host`: their configuration is box-specific and
32
+ * they are wired up by a different mechanism entirely. A collision with the
33
+ * browser server is warned about by name at boot rather than being silent; a
34
+ * collision with an INJECTED server is refused outright, because those are
35
+ * materialised as an HTTP bridge under the same `mcp__<name>__*` namespace and
36
+ * two servers claiming one namespace has no defined winner.
37
+ *
38
+ * ## Secrets, which is the real work here
39
+ *
40
+ * This is the first place in #691 where a user types a credential into paddock's
41
+ * own config file, and that file is git-tracked (and readable through the
42
+ * Settings screen's config path). So this module borrows the rule
43
+ * `management-config.ts` already sets for management tokens: **`env:VAR_NAME` is
44
+ * a reference, resolved from the environment at boot.** Here it is accepted
45
+ * anywhere a string is (`command`, each `args` entry, each `env` value, `url`),
46
+ * so there is one rule to learn rather than a list of blessed fields.
47
+ *
48
+ * Unlike a management token, an MCP `env` entry is not necessarily secret
49
+ * (`NOTION_VERSION: "2022-06-28"` is not), so an inline value is a WARNING and
50
+ * not an error — but the warning is emitted for any key that looks like a
51
+ * credential, and nothing in this module ever prints a value. Every diagnostic
52
+ * names keys, variable names and server names only; a `url` is reported with its
53
+ * query string and userinfo stripped, because that is where an API key rides.
54
+ * {@link describeServer} is the single place a server is rendered for a human,
55
+ * so there is one function to audit rather than a scattering of template strings.
56
+ *
57
+ * The resolved values do land in the frozen `PaddockConfig` (as management tokens
58
+ * already do). They must never reach an API response: `instance-config.ts`
59
+ * publishes only the fields in its own `FIELDS` table, and this block is
60
+ * deliberately absent from it.
61
+ *
62
+ * ## Validation is strict, and drops rather than degrades
63
+ *
64
+ * Step 5 passes a host server it cannot carry faithfully, with a warning, on the
65
+ * grounds that a user who declared a server elsewhere should get it plus a
66
+ * warning rather than nothing plus a warning. That reasoning inverts here,
67
+ * because the user typed this file: an unusable declaration is a mistake they can
68
+ * fix, and a `headers:` block that is silently dropped is an authentication
69
+ * failure that looks like a broken server. So anything that cannot be carried is
70
+ * an ERROR and that server is not attached — including an unknown key, which is
71
+ * how a typo (`arg:` for `args:`) otherwise becomes a server that starts wrong.
72
+ *
73
+ * Never a boot failure, though: one bad server drops itself and the rest attach,
74
+ * matching `resolveManagementApiConfig`. A typo in a capability must not take an
75
+ * instance down.
76
+ */
77
+ import type { McpServerDefs, McpServerDef } from "./claude-mcp.js";
78
+ /** On-disk shape of one entry of the `mcpServers:` block. Every field optional. */
79
+ export interface McpServerConfigFile {
80
+ /** Executable for a stdio server. Mutually exclusive with {@link url}. */
81
+ command?: string;
82
+ /** Arguments for {@link command}. */
83
+ args?: string[];
84
+ /** Environment for the server process. Values may be `env:VAR_NAME`. */
85
+ env?: Record<string, string>;
86
+ /** Endpoint for a streamable-HTTP server. Mutually exclusive with {@link command}. */
87
+ url?: string;
88
+ /** Accepted only as `stdio`/`http`, and only when it agrees with the above. */
89
+ type?: string;
90
+ /** Present only in a MISCONFIGURED file: the engine cannot carry headers. */
91
+ headers?: Record<string, string>;
92
+ }
93
+ /** On-disk shape of the whole block: a map of server name → declaration. */
94
+ export type McpServersConfigFile = Record<string, McpServerConfigFile | null | undefined>;
95
+ /** Outcome of resolving the block, with everything worth telling the operator. */
96
+ export interface DeclaredMcpResolution {
97
+ /** The servers that will be attached to every keeper. */
98
+ servers: McpServerDefs;
99
+ /** Declarations that could not be carried (logged at error level, server dropped). */
100
+ errors: string[];
101
+ /** Advice and fail-closed drops (logged at warn level). */
102
+ warnings: string[];
103
+ }
104
+ /**
105
+ * The prefix that makes a string an environment reference rather than a literal.
106
+ * Same spelling as `managementApi.clients.<id>.auth.ref`, deliberately: an
107
+ * operator should have to learn it once.
108
+ */
109
+ export declare const ENV_REF_PREFIX = "env:";
110
+ /**
111
+ * Server names paddock materialises itself, which a declaration may not take.
112
+ *
113
+ * Kept as literals rather than imported from `send-file-mcp.ts`/`self-mcp.ts` so
114
+ * config resolution stays free of the runtime modules — `mcp-servers-reserved`
115
+ * in the unit tests asserts the two spellings still agree.
116
+ */
117
+ export declare const RESERVED_MCP_SERVER_NAMES: readonly string[];
118
+ /**
119
+ * A URL with everything credential-shaped removed — no query string, no
120
+ * fragment, no `user:pass@`. Used for every log line that mentions a `url`,
121
+ * because a remote MCP endpoint's API key is conventionally a query parameter.
122
+ * An unparseable URL is reported as its scheme only rather than echoed.
123
+ */
124
+ export declare function redactUrl(raw: string): string;
125
+ /**
126
+ * A server rendered for a human, carrying no secret. THE chokepoint: every
127
+ * notice, warning and error about a declared server goes through here, so
128
+ * auditing "can a token reach a log line?" is auditing one function.
129
+ *
130
+ * Args and env values are counted, never printed — an API key is as likely to be
131
+ * `--token=…` in `args` as it is to be an `env` value. The command is reduced to
132
+ * its basename for the same reason, which the leak test in
133
+ * `test/unit/mcp-servers.test.ts` is what forced: a full path is more useful in a
134
+ * log, but the rule "nothing from the block is echoed" is only worth having if it
135
+ * has no exceptions to remember. The server's own name is printed alongside and
136
+ * is what actually identifies it.
137
+ */
138
+ export declare function describeServer(name: string, def: McpServerDef): string;
139
+ /**
140
+ * Resolve the whole `mcpServers:` block against `env`.
141
+ *
142
+ * Never throws. A declaration paddock cannot carry is reported and dropped so one
143
+ * typo cannot take an instance down — the same posture as
144
+ * `resolveManagementApiConfig`, and for the same reason: this is a capability,
145
+ * and losing a capability is better than losing the instance.
146
+ */
147
+ export declare function resolveDeclaredMcpServers(file: McpServersConfigFile | undefined, env: Record<string, string | undefined>): DeclaredMcpResolution;
148
+ /** A line for the boot log, at a level (mirrors `HostMcpNotice`). */
149
+ export interface DeclaredMcpNotice {
150
+ level: "info" | "warn";
151
+ message: string;
152
+ }
153
+ /**
154
+ * What to say at boot about the declared servers — the answer to "what does this
155
+ * instance actually have?", which should be readable off the log rather than
156
+ * inferred from a YAML file plus an environment.
157
+ *
158
+ * Takes the already-resolved servers, so it cannot see a raw declaration and
159
+ * therefore cannot leak one; every line it produces goes through
160
+ * {@link describeServer}.
161
+ */
162
+ export declare function declaredMcpNotices(opts: {
163
+ servers: McpServerDefs;
164
+ /** Names inherited from `~/.claude.json`, for the shadowing notice. */
165
+ hostNames?: readonly string[];
166
+ /** Whether paddock's own browser server is attached (it wins a name clash). */
167
+ browserMcp?: boolean;
168
+ }): DeclaredMcpNotice[];