@edspencer/paddock 0.80.0 → 0.82.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 (116) hide show
  1. package/package.json +1 -1
  2. package/packages/server/dist/app.d.ts +7 -0
  3. package/packages/server/dist/app.js +1 -1
  4. package/packages/server/dist/auth.d.ts +3 -2
  5. package/packages/server/dist/auth.js +11 -0
  6. package/packages/server/dist/background-live.d.ts +17 -0
  7. package/packages/server/dist/background-live.js +24 -0
  8. package/packages/server/dist/busy.d.ts +96 -0
  9. package/packages/server/dist/busy.js +88 -0
  10. package/packages/server/dist/cli/args.d.ts +70 -29
  11. package/packages/server/dist/cli/args.js +306 -7
  12. package/packages/server/dist/cli/busy-command.d.ts +58 -0
  13. package/packages/server/dist/cli/busy-command.js +108 -0
  14. package/packages/server/dist/cli/busy.d.ts +69 -0
  15. package/packages/server/dist/cli/busy.js +150 -0
  16. package/packages/server/dist/cli/output.d.ts +52 -0
  17. package/packages/server/dist/cli/output.js +84 -0
  18. package/packages/server/dist/cli/paddock.js +65 -21
  19. package/packages/server/dist/cli/service/index.d.ts +64 -0
  20. package/packages/server/dist/cli/service/index.js +208 -7
  21. package/packages/server/dist/cli/service/launchd.d.ts +15 -1
  22. package/packages/server/dist/cli/service/launchd.js +116 -18
  23. package/packages/server/dist/cli/service/ready.d.ts +30 -0
  24. package/packages/server/dist/cli/service/ready.js +35 -0
  25. package/packages/server/dist/cli/service/systemd.js +27 -0
  26. package/packages/server/dist/cli/update/install-method.d.ts +131 -0
  27. package/packages/server/dist/cli/update/install-method.js +258 -0
  28. package/packages/server/dist/cli/update/lock.d.ts +40 -0
  29. package/packages/server/dist/cli/update/lock.js +108 -0
  30. package/packages/server/dist/cli/update/package-manager.d.ts +109 -0
  31. package/packages/server/dist/cli/update/package-manager.js +221 -0
  32. package/packages/server/dist/cli/update/registry.d.ts +89 -0
  33. package/packages/server/dist/cli/update/registry.js +145 -0
  34. package/packages/server/dist/cli/update/semver.d.ts +68 -0
  35. package/packages/server/dist/cli/update/semver.js +232 -0
  36. package/packages/server/dist/cli/update/update-check.d.ts +80 -0
  37. package/packages/server/dist/cli/update/update-check.js +116 -0
  38. package/packages/server/dist/cli/update/update.d.ts +160 -0
  39. package/packages/server/dist/cli/update/update.js +609 -0
  40. package/packages/server/dist/cli/update-command.d.ts +20 -0
  41. package/packages/server/dist/cli/update-command.js +113 -0
  42. package/packages/server/dist/herdctl.d.ts +19 -0
  43. package/packages/server/dist/herdctl.js +26 -0
  44. package/packages/server/dist/routes/meta.js +45 -0
  45. package/packages/server/dist/runtime-file.d.ts +26 -0
  46. package/packages/server/dist/runtime-file.js +91 -0
  47. package/packages/server/dist/start.d.ts +33 -0
  48. package/packages/server/dist/start.js +115 -8
  49. package/packages/server/dist/ws-context.d.ts +9 -0
  50. package/packages/server/dist/ws-turn.js +1 -0
  51. package/packages/server/package.json +1 -1
  52. package/packages/web/dist/assets/{DeleteProjectDialog-DHczLhwQ.js → DeleteProjectDialog-CphdGB3R.js} +1 -1
  53. package/packages/web/dist/assets/DiscoverPage-C4OPLNO8.js +2 -0
  54. package/packages/web/dist/assets/{DiscoverView-DtTOpTji.js → DiscoverView-B_kcF4sm.js} +1 -1
  55. package/packages/web/dist/assets/{InstanceConfigPage-BRoBh1C1.js → InstanceConfigPage-CvUK5DKW.js} +1 -1
  56. package/packages/web/dist/assets/{MarkdownRenderer-DJf8IJuk.js → MarkdownRenderer-DvZ-j_Ao.js} +1 -1
  57. package/packages/web/dist/assets/{ProjectRedirect-EioguUKW.js → ProjectRedirect-DayHvUH2.js} +1 -1
  58. package/packages/web/dist/assets/{ProjectView-BiKnGfk6.js → ProjectView-CCw83gUi.js} +3 -3
  59. package/packages/web/dist/assets/{ProjectsGrid-D6kfaIal.js → ProjectsGrid-B3Klg2H4.js} +1 -1
  60. package/packages/web/dist/assets/{RootHome-DpcyuV6e.js → RootHome-BxcDvpgI.js} +1 -1
  61. package/packages/web/dist/assets/{Surfaces-CHM29PhP.js → Surfaces-7UlhFBSG.js} +1 -1
  62. package/packages/web/dist/assets/{arc-fiqD05Hu.js → arc-DNkh5o5Q.js} +1 -1
  63. package/packages/web/dist/assets/{architectureDiagram-3BPJPVTR-BuuB2Nkf.js → architectureDiagram-3BPJPVTR-BrgN3oLF.js} +1 -1
  64. package/packages/web/dist/assets/{blockDiagram-GPEHLZMM-DQMBuzfi.js → blockDiagram-GPEHLZMM-D05XOJSk.js} +1 -1
  65. package/packages/web/dist/assets/{c4Diagram-AAUBKEIU-BKN0UxCH.js → c4Diagram-AAUBKEIU-CKaMBhMP.js} +1 -1
  66. package/packages/web/dist/assets/channel-JrEedxB8.js +2 -0
  67. package/packages/web/dist/assets/{chunk-2J33WTMH-DW37EupX.js → chunk-2J33WTMH-8hgadCQc.js} +1 -1
  68. package/packages/web/dist/assets/{chunk-4BX2VUAB-Dyv7zV_c.js → chunk-4BX2VUAB-CBfEC-pu.js} +1 -1
  69. package/packages/web/dist/assets/{chunk-55IACEB6-DzMR0dOk.js → chunk-55IACEB6-DV1eMgHk.js} +1 -1
  70. package/packages/web/dist/assets/{chunk-727SXJPM-BdZ3Sor8.js → chunk-727SXJPM-Cfgl5fxY.js} +1 -1
  71. package/packages/web/dist/assets/{chunk-AQP2D5EJ-B4i7_og0.js → chunk-AQP2D5EJ-BXhqD295.js} +1 -1
  72. package/packages/web/dist/assets/{chunk-FMBD7UC4-jcTr85it.js → chunk-FMBD7UC4-TFGOPtek.js} +1 -1
  73. package/packages/web/dist/assets/{chunk-ND2GUHAM-fgMsadqB.js → chunk-ND2GUHAM-CHFM665R.js} +1 -1
  74. package/packages/web/dist/assets/{chunk-QZHKN3VN-bJNHYS1W.js → chunk-QZHKN3VN-CqEf6MMT.js} +1 -1
  75. package/packages/web/dist/assets/classDiagram-4FO5ZUOK-CHJiQp-W.js +2 -0
  76. package/packages/web/dist/assets/classDiagram-v2-Q7XG4LA2-CHJiQp-W.js +2 -0
  77. package/packages/web/dist/assets/{core-Bk4KFrmN.js → core-DmEaKxBb.js} +1 -1
  78. package/packages/web/dist/assets/{cose-bilkent-S5V4N54A-BIqCSlQy.js → cose-bilkent-S5V4N54A-BnGI6jkr.js} +1 -1
  79. package/packages/web/dist/assets/{dagre-BM42HDAG-6nyhtVQz.js → dagre-BM42HDAG-CKoPx61E.js} +1 -1
  80. package/packages/web/dist/assets/{diagram-2AECGRRQ-CjizfipR.js → diagram-2AECGRRQ-mMmtlBl1.js} +1 -1
  81. package/packages/web/dist/assets/{diagram-5GNKFQAL-DlgB5vWb.js → diagram-5GNKFQAL-Cdz9Mtnt.js} +1 -1
  82. package/packages/web/dist/assets/{diagram-KO2AKTUF-CNC9qanV.js → diagram-KO2AKTUF-DQxM3wYj.js} +1 -1
  83. package/packages/web/dist/assets/{diagram-LMA3HP47-DSJ-s9lh.js → diagram-LMA3HP47-BWrinPsq.js} +1 -1
  84. package/packages/web/dist/assets/{diagram-OG6HWLK6-C9FoHBDg.js → diagram-OG6HWLK6-U6MYUve2.js} +1 -1
  85. package/packages/web/dist/assets/{documentTitle-Cj_AY97j.js → documentTitle-DGjRXuTP.js} +1 -1
  86. package/packages/web/dist/assets/{erDiagram-TEJ5UH35-z6gku4Yt.js → erDiagram-TEJ5UH35-xqMCsXxY.js} +1 -1
  87. package/packages/web/dist/assets/{flowDiagram-I6XJVG4X-Dl5c_FgU.js → flowDiagram-I6XJVG4X-PMfy_czF.js} +1 -1
  88. package/packages/web/dist/assets/{ganttDiagram-6RSMTGT7-CIscJ-Dt.js → ganttDiagram-6RSMTGT7-whhYYE4N.js} +1 -1
  89. package/packages/web/dist/assets/{gitGraphDiagram-PVQCEYII-CvttOXM_.js → gitGraphDiagram-PVQCEYII-C51JW4tf.js} +1 -1
  90. package/packages/web/dist/assets/{index-DN82do6Z.js → index-CHOtvlnO.js} +2 -2
  91. package/packages/web/dist/assets/{infoDiagram-5YYISTIA-dzWYdDJj.js → infoDiagram-5YYISTIA-SH8cr905.js} +1 -1
  92. package/packages/web/dist/assets/{ishikawaDiagram-YF4QCWOH-8yX9k4bo.js → ishikawaDiagram-YF4QCWOH-BjqaoU3U.js} +1 -1
  93. package/packages/web/dist/assets/{journeyDiagram-JHISSGLW-BmitzJDR.js → journeyDiagram-JHISSGLW-CBmdEVrd.js} +1 -1
  94. package/packages/web/dist/assets/{kanban-definition-UN3LZRKU-BZmIkfkW.js → kanban-definition-UN3LZRKU-U8njjMLZ.js} +1 -1
  95. package/packages/web/dist/assets/{linear-BBLXE4o7.js → linear-DF66GPs1.js} +1 -1
  96. package/packages/web/dist/assets/{mermaid.core-mSKff4yu.js → mermaid.core-CouJz7Ph.js} +4 -4
  97. package/packages/web/dist/assets/{mindmap-definition-RKZ34NQL-BWAUa4CP.js → mindmap-definition-RKZ34NQL-BYIf0oFt.js} +1 -1
  98. package/packages/web/dist/assets/{pieDiagram-4H26LBE5-VmVdiL4C.js → pieDiagram-4H26LBE5-Cm8rgg09.js} +1 -1
  99. package/packages/web/dist/assets/{quadrantDiagram-W4KKPZXB-Dybfv6NU.js → quadrantDiagram-W4KKPZXB-C3Il5kOH.js} +1 -1
  100. package/packages/web/dist/assets/{requirementDiagram-4Y6WPE33-BPnOvB7w.js → requirementDiagram-4Y6WPE33-D3PE2nTe.js} +1 -1
  101. package/packages/web/dist/assets/{sankeyDiagram-5OEKKPKP-YXIEmKw7.js → sankeyDiagram-5OEKKPKP-DdmvBM18.js} +1 -1
  102. package/packages/web/dist/assets/{sequenceDiagram-3UESZ5HK-DintIRUe.js → sequenceDiagram-3UESZ5HK-B8M_GAIq.js} +1 -1
  103. package/packages/web/dist/assets/{stateDiagram-AJRCARHV-eMsjahWp.js → stateDiagram-AJRCARHV-DZkXnK1_.js} +1 -1
  104. package/packages/web/dist/assets/stateDiagram-v2-BHNVJYJU-CjCdT9Ls.js +2 -0
  105. package/packages/web/dist/assets/{timeline-definition-PNZ67QCA-as4zRCPn.js → timeline-definition-PNZ67QCA-IHXq7rqi.js} +1 -1
  106. package/packages/web/dist/assets/{vennDiagram-CIIHVFJN-CPzvUkM0.js → vennDiagram-CIIHVFJN-Dga7tLtT.js} +1 -1
  107. package/packages/web/dist/assets/{wardley-L42UT6IY-q6moXj5g.js → wardley-L42UT6IY-CmcwnEJ-.js} +1 -1
  108. package/packages/web/dist/assets/{wardleyDiagram-YWT4CUSO-BsEEb9Gm.js → wardleyDiagram-YWT4CUSO-zHuSLrD4.js} +1 -1
  109. package/packages/web/dist/assets/{xychartDiagram-2RQKCTM6-DSgZlcZW.js → xychartDiagram-2RQKCTM6-D93MU_ic.js} +1 -1
  110. package/packages/web/dist/index.html +1 -1
  111. package/packages/web/dist/sw.js +1 -1
  112. package/packages/web/dist/assets/DiscoverPage-BSGSzTEs.js +0 -2
  113. package/packages/web/dist/assets/channel-B7yh6Su_.js +0 -2
  114. package/packages/web/dist/assets/classDiagram-4FO5ZUOK-DIlhMPgi.js +0 -2
  115. package/packages/web/dist/assets/classDiagram-v2-Q7XG4LA2-DIlhMPgi.js +0 -2
  116. package/packages/web/dist/assets/stateDiagram-v2-BHNVJYJU-CpAOGzbO.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edspencer/paddock",
3
- "version": "0.80.0",
3
+ "version": "0.82.0",
4
4
  "description": "Project-first launchpad for Claude Code: server-hosted, persistent, resumable sessions organized by project.",
5
5
  "keywords": [
6
6
  "claude",
@@ -17,6 +17,7 @@ import { GitService } from "./git.js";
17
17
  import { GithubAuth } from "./github-auth.js";
18
18
  import { type Transcriber } from "./transcribe.js";
19
19
  import type { SessionHub } from "./session-hub.js";
20
+ import type { BackgroundRegistry } from "./background-live.js";
20
21
  import { SweepService } from "./sweep.js";
21
22
  import { ArchiveStore } from "./archive.js";
22
23
  import { StarStore } from "./star.js";
@@ -57,6 +58,12 @@ export interface BuiltApp {
57
58
  * same way, via the route context).
58
59
  */
59
60
  hub: SessionHub;
61
+ /**
62
+ * The live background-work registry (#604), exposed for the same reason `hub`
63
+ * is — it is WS-layer state a non-socket caller has to read. `GET /api/busy`
64
+ * reaches it through the route context; a test reaches it here.
65
+ */
66
+ background: BackgroundRegistry;
60
67
  /** Tear down the fleet + close the server (no process.exit, for tests). */
61
68
  close: () => Promise<void>;
62
69
  }
@@ -440,5 +440,5 @@ export async function buildApp(opts = {}) {
440
440
  // `hub` rides along like every other built piece: it is the WS layer's turn
441
441
  // bookkeeping, and the only place a caller can observe or annotate a turn
442
442
  // without a live socket (see SessionHub.noteCancel).
443
- return { app, cfg, projects, herdctl, git, githubAuth, sweep, archive, star, readState, unread, parentDetach, runProvenance, queuedMessage, transcriber, events, triggers, hub: chatHandler.managementOpsContext.hub, close };
443
+ return { app, cfg, projects, herdctl, git, githubAuth, sweep, archive, star, readState, unread, parentDetach, runProvenance, queuedMessage, transcriber, events, triggers, hub: chatHandler.managementOpsContext.hub, background: chatHandler.managementOpsContext.background, close };
444
444
  }
@@ -19,8 +19,9 @@
19
19
  * rejects missing/invalid/expired tokens with 401.
20
20
  *
21
21
  * Paddock's health route (`/api/health`) is always exempt so the proxy and
22
- * monitoring can poll a server that is otherwise locked down. Only registered
23
- * routes may be exempted — see HEALTH_PATHS below for why (issue #569).
22
+ * monitoring can poll a server that is otherwise locked down, as is the CLI
23
+ * contract's `/api/busy` — which carries counts and nothing else. Only
24
+ * registered routes may be exempted — see HEALTH_PATHS below for why (#569).
24
25
  *
25
26
  * Registered in app.ts BEFORE the routes so the `onRequest` hook guards every
26
27
  * REST + WS request. The decorator + hook are added directly to the root app
@@ -16,6 +16,17 @@ import { createRemoteJWKSet, jwtVerify, } from "jose";
16
16
  */
17
17
  export const HEALTH_PATHS = new Set([
18
18
  "/api/health", // paddock's own health route (routes/meta.ts)
19
+ // The CLI contract's busy check (SPEC §4, §8). Exempt for the same reason
20
+ // health is, and safe for a reason health does not need: the answer is three
21
+ // integers and the version, with no chat title, session id or project name in
22
+ // it — SPEC §10 keeps `reasons` out until there is a way for a caller to prove
23
+ // it is local. `paddock service stop`, `paddock update` and Watchtower's
24
+ // pre-update hook all ask it with no credential to offer, and a 401 would be
25
+ // read by `cli/busy.ts` as exit 1 rather than as "not busy" — so gating it
26
+ // would fail every stop on an authenticated instance.
27
+ //
28
+ // If this answer ever grows a label, this line has to be revisited with it.
29
+ "/api/busy", // routes/meta.ts
19
30
  ]);
20
31
  /**
21
32
  * Strip the query string and trailing slash so exemption matching is robust.
@@ -110,6 +110,23 @@ export declare class BackgroundRegistry {
110
110
  }[];
111
111
  /** Does this session have live background work? The #604 predicate. */
112
112
  isBusy(sessionId: string): boolean;
113
+ /**
114
+ * How many live background tasks there are, across the sessions `keep`
115
+ * accepts.
116
+ *
117
+ * The `/api/busy` check (CLI contract SPEC §4) passes herdctl's SDK liveness
118
+ * as `keep`, for the reason the per-process caveat in the module header gives:
119
+ * nothing resets this set when a one-shot `claude` exits, so on
120
+ * `driveMode: batch` a finished turn's tasks sit here indefinitely. Filtering
121
+ * on a live session is what stops a stale entry reporting a batch instance
122
+ * busy for good — and it costs nothing in `session` mode, where the reaper
123
+ * holds a session open precisely BECAUSE it has background work.
124
+ *
125
+ * Counted rather than listed so the busy check allocates nothing per task
126
+ * (§4: in-memory, well under a second). {@link snapshot} is the one that
127
+ * builds arrays, and it is for the connect-time frame.
128
+ */
129
+ liveTaskCount(keep?: (sessionId: string) => boolean): number;
113
130
  /**
114
131
  * Forget a session's set. Called when the session's process restarts or its
115
132
  * stream ends — see the per-process caveat in the module header.
@@ -142,6 +142,30 @@ export class BackgroundRegistry {
142
142
  const e = this.bySession.get(sessionId);
143
143
  return !!e && e.tasks.size > 0;
144
144
  }
145
+ /**
146
+ * How many live background tasks there are, across the sessions `keep`
147
+ * accepts.
148
+ *
149
+ * The `/api/busy` check (CLI contract SPEC §4) passes herdctl's SDK liveness
150
+ * as `keep`, for the reason the per-process caveat in the module header gives:
151
+ * nothing resets this set when a one-shot `claude` exits, so on
152
+ * `driveMode: batch` a finished turn's tasks sit here indefinitely. Filtering
153
+ * on a live session is what stops a stale entry reporting a batch instance
154
+ * busy for good — and it costs nothing in `session` mode, where the reaper
155
+ * holds a session open precisely BECAUSE it has background work.
156
+ *
157
+ * Counted rather than listed so the busy check allocates nothing per task
158
+ * (§4: in-memory, well under a second). {@link snapshot} is the one that
159
+ * builds arrays, and it is for the connect-time frame.
160
+ */
161
+ liveTaskCount(keep = () => true) {
162
+ let n = 0;
163
+ for (const [sessionId, e] of this.bySession) {
164
+ if (e.tasks.size > 0 && keep(sessionId))
165
+ n += e.tasks.size;
166
+ }
167
+ return n;
168
+ }
145
169
  /**
146
170
  * Forget a session's set. Called when the session's process restarts or its
147
171
  * stream ends — see the per-process caveat in the module header.
@@ -0,0 +1,96 @@
1
+ /**
2
+ * What `GET /api/busy` answers (CLI contract SPEC §4, ROADMAP "Busy, per tool").
3
+ *
4
+ * ## What "busy" means here
5
+ *
6
+ * Only work **a restart would lose or cut short** — the kind someone would be
7
+ * annoyed to find killed. For Paddock that is three things, and the ROADMAP row
8
+ * names them:
9
+ *
10
+ * - **`chat`** — a chat turn running. This is the one that matters: a turn is a
11
+ * live `claude` subprocess writing a transcript, and `herdctl.stop()` ends it
12
+ * with `waitForJobs: false`. A fired trigger or a cron schedule is NOT a
13
+ * fourth kind, because every one of them runs as a first-class chat on the
14
+ * hub (`ws-triggers.ts` — one `startAgentTurn` for every trigger type), so it
15
+ * is already counted here.
16
+ * - **`background`** — background work a live SDK session is still holding
17
+ * after its turn ended (#604): a `run_in_background` shell, a sub-agent, a
18
+ * `Monitor`. These outlive the `Turn` record, so the hub cannot see them.
19
+ * - **`job`** — herdctl's scheduler running a job. Paddock routes a keeper's
20
+ * schedule fire back onto the hub, so in practice this double-counts with
21
+ * `chat` for the window where both are true; a count that is occasionally
22
+ * high by one is the right failure direction for a check whose answer is
23
+ * "wait a moment".
24
+ *
25
+ * ## What is deliberately NOT busy
26
+ *
27
+ * - **Idle live sessions.** A session the reaper is holding open with no turn
28
+ * and no background task resumes after a restart; that is the whole point of
29
+ * a resumable session.
30
+ * - **The post-turn sweeper.** It is re-runnable from its watermark, so losing
31
+ * one is a re-sweep rather than lost work. The ROADMAP row leaves it out too.
32
+ * - **Open browsers.** A page reconnects to `/ws` and replays.
33
+ *
34
+ * ## Cheap, and in-memory only
35
+ *
36
+ * §4 requires this to read in-memory state, never walk the disk, and answer in
37
+ * well under a second — it is called by Watchtower's pre-update hook and by
38
+ * every `service stop`. So each source here is a `Map.size` or a filtered
39
+ * iteration over one, and {@link collectBusy} is synchronous.
40
+ *
41
+ * That rules out the obvious source for `job`. `fleetStatus().counts.runningJobs`
42
+ * is what the ROADMAP names, and `FleetStatus` is built by `getAgentInfo()`,
43
+ * which **reads the fleet state file off disk** on every call (herdctl's
44
+ * `StatusQueries.readFleetStateSnapshot`) — the same re-parse that was 61% of
45
+ * this server's CPU once. `counts.runningJobs` reduces to
46
+ * `Σ scheduler.getRunningJobCount(agent)`, and the scheduler also publishes
47
+ * `getTotalRunningJobCount()` over the same in-memory map, so Paddock asks the
48
+ * scheduler directly for an identical number with no file read.
49
+ *
50
+ * ## No labels, ids or titles
51
+ *
52
+ * Counts only, for every caller, until SPEC §10's first question (how a CLI
53
+ * proves it is local) is designed. That is why this route needs no auth: there
54
+ * is nothing in the answer to protect. A chat's TITLE would be a different
55
+ * matter, and is exactly what `reasons` will carry once there is a way to know
56
+ * who is asking — so nothing here may grow a string field by accident.
57
+ */
58
+ /** The non-zero kinds the CLI's message names: `Paddock is busy: 2 chats are running.` */
59
+ export interface BusyCounts {
60
+ /** Chat turns running — a human turn, a fired trigger, a cron fire. */
61
+ chat: number;
62
+ /** Background tasks live sessions are still holding after their turn (#604). */
63
+ background: number;
64
+ /** herdctl scheduler jobs in flight. */
65
+ job: number;
66
+ }
67
+ /** The `/api/busy` body (SPEC §4). */
68
+ export interface BusyBody {
69
+ busy: boolean;
70
+ version: string;
71
+ counts: BusyCounts;
72
+ }
73
+ /**
74
+ * The three in-memory readings, injected so the computation is unit-testable
75
+ * without a fleet, a hub or a socket. Each must be cheap enough to call on every
76
+ * request — see the module header.
77
+ */
78
+ export interface BusySources {
79
+ /** Sessions with a running turn: `hub.runningSessions().length`. */
80
+ runningChats: () => number;
81
+ /** Live background tasks, counted only in sessions whose SDK session is live. */
82
+ backgroundTasks: () => number;
83
+ /** Scheduler jobs running right now. */
84
+ runningJobs: () => number;
85
+ }
86
+ /**
87
+ * Read the three counts and decide busy.
88
+ *
89
+ * `busy` is `counts` having any non-zero member rather than a separately
90
+ * computed predicate, so the sentence the CLI prints can never disagree with the
91
+ * boolean it printed it for. A source that throws counts as zero: a busy check
92
+ * that 500s is worse than one that under-reports, because a 500 is read by
93
+ * `busy-client.ts` as "something answered, but not as Paddock's busy check" —
94
+ * exit 1 — which fails a `service stop` outright instead of letting it proceed.
95
+ */
96
+ export declare function collectBusy(sources: BusySources, version: string): BusyBody;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * What `GET /api/busy` answers (CLI contract SPEC §4, ROADMAP "Busy, per tool").
3
+ *
4
+ * ## What "busy" means here
5
+ *
6
+ * Only work **a restart would lose or cut short** — the kind someone would be
7
+ * annoyed to find killed. For Paddock that is three things, and the ROADMAP row
8
+ * names them:
9
+ *
10
+ * - **`chat`** — a chat turn running. This is the one that matters: a turn is a
11
+ * live `claude` subprocess writing a transcript, and `herdctl.stop()` ends it
12
+ * with `waitForJobs: false`. A fired trigger or a cron schedule is NOT a
13
+ * fourth kind, because every one of them runs as a first-class chat on the
14
+ * hub (`ws-triggers.ts` — one `startAgentTurn` for every trigger type), so it
15
+ * is already counted here.
16
+ * - **`background`** — background work a live SDK session is still holding
17
+ * after its turn ended (#604): a `run_in_background` shell, a sub-agent, a
18
+ * `Monitor`. These outlive the `Turn` record, so the hub cannot see them.
19
+ * - **`job`** — herdctl's scheduler running a job. Paddock routes a keeper's
20
+ * schedule fire back onto the hub, so in practice this double-counts with
21
+ * `chat` for the window where both are true; a count that is occasionally
22
+ * high by one is the right failure direction for a check whose answer is
23
+ * "wait a moment".
24
+ *
25
+ * ## What is deliberately NOT busy
26
+ *
27
+ * - **Idle live sessions.** A session the reaper is holding open with no turn
28
+ * and no background task resumes after a restart; that is the whole point of
29
+ * a resumable session.
30
+ * - **The post-turn sweeper.** It is re-runnable from its watermark, so losing
31
+ * one is a re-sweep rather than lost work. The ROADMAP row leaves it out too.
32
+ * - **Open browsers.** A page reconnects to `/ws` and replays.
33
+ *
34
+ * ## Cheap, and in-memory only
35
+ *
36
+ * §4 requires this to read in-memory state, never walk the disk, and answer in
37
+ * well under a second — it is called by Watchtower's pre-update hook and by
38
+ * every `service stop`. So each source here is a `Map.size` or a filtered
39
+ * iteration over one, and {@link collectBusy} is synchronous.
40
+ *
41
+ * That rules out the obvious source for `job`. `fleetStatus().counts.runningJobs`
42
+ * is what the ROADMAP names, and `FleetStatus` is built by `getAgentInfo()`,
43
+ * which **reads the fleet state file off disk** on every call (herdctl's
44
+ * `StatusQueries.readFleetStateSnapshot`) — the same re-parse that was 61% of
45
+ * this server's CPU once. `counts.runningJobs` reduces to
46
+ * `Σ scheduler.getRunningJobCount(agent)`, and the scheduler also publishes
47
+ * `getTotalRunningJobCount()` over the same in-memory map, so Paddock asks the
48
+ * scheduler directly for an identical number with no file read.
49
+ *
50
+ * ## No labels, ids or titles
51
+ *
52
+ * Counts only, for every caller, until SPEC §10's first question (how a CLI
53
+ * proves it is local) is designed. That is why this route needs no auth: there
54
+ * is nothing in the answer to protect. A chat's TITLE would be a different
55
+ * matter, and is exactly what `reasons` will carry once there is a way to know
56
+ * who is asking — so nothing here may grow a string field by accident.
57
+ */
58
+ /**
59
+ * Read the three counts and decide busy.
60
+ *
61
+ * `busy` is `counts` having any non-zero member rather than a separately
62
+ * computed predicate, so the sentence the CLI prints can never disagree with the
63
+ * boolean it printed it for. A source that throws counts as zero: a busy check
64
+ * that 500s is worse than one that under-reports, because a 500 is read by
65
+ * `busy-client.ts` as "something answered, but not as Paddock's busy check" —
66
+ * exit 1 — which fails a `service stop` outright instead of letting it proceed.
67
+ */
68
+ export function collectBusy(sources, version) {
69
+ const counts = {
70
+ chat: safeCount(sources.runningChats),
71
+ background: safeCount(sources.backgroundTasks),
72
+ job: safeCount(sources.runningJobs),
73
+ };
74
+ return {
75
+ busy: counts.chat > 0 || counts.background > 0 || counts.job > 0,
76
+ version,
77
+ counts,
78
+ };
79
+ }
80
+ function safeCount(read) {
81
+ try {
82
+ const n = read();
83
+ return Number.isInteger(n) && n > 0 ? n : 0;
84
+ }
85
+ catch {
86
+ return 0;
87
+ }
88
+ }
@@ -71,6 +71,47 @@ export interface CliOptions {
71
71
  follow?: boolean;
72
72
  /** `service logs`: how many lines to print first (`-n`, default 50). */
73
73
  lines?: number;
74
+ /**
75
+ * `service stop` / `service restart`: go ahead even though the instance is
76
+ * busy (SPEC §1, §4).
77
+ *
78
+ * The refusal it skips is the only thing it skips. It does not change what the
79
+ * busy check printed — a forced stop prints the same sentence, prefixed
80
+ * `Overriding:` — and on `update` it skips the busy check and nothing else:
81
+ * the health check and the rollback still run (SPEC §1).
82
+ */
83
+ force?: boolean;
84
+ /**
85
+ * `update`: report what a new version would be, and change nothing
86
+ * (SPEC §1, §5 step 4).
87
+ *
88
+ * Named `checkOnly` rather than `check` because `check` reads as a verb in a
89
+ * bag of flags that also carries `write` and `follow`; `update-command.ts`
90
+ * maps it back to the contract's `--check` at the one seam.
91
+ */
92
+ checkOnly?: boolean;
93
+ /** `update --to <version|tag>`: the only way to move to a LOWER version. */
94
+ to?: string;
95
+ /**
96
+ * `update --yes`: do not ask.
97
+ *
98
+ * Required when there is no TTY, where a command that would have asked exits
99
+ * 2 instead of guessing (SPEC §1, §3). That asymmetry is deliberate: a
100
+ * scripted update that silently assumed yes would be a restart nobody asked
101
+ * for, and one that silently assumed no would be a no-op reported as success.
102
+ */
103
+ yes?: boolean;
104
+ /**
105
+ * `service install --refresh`: re-render the unit, keeping the settings the
106
+ * EXISTING one carries (SPEC §1, §5 step 11).
107
+ *
108
+ * This is the hand-over `update` performs: the NEW version writes the unit,
109
+ * in its own format, with the port and data dir the OLD one recorded. It
110
+ * needs an installed unit — with nothing to refresh it exits 4 rather than
111
+ * quietly performing a first install with defaults, which is how a
112
+ * `--port 9000` service comes back on 7233.
113
+ */
114
+ refresh?: boolean;
74
115
  }
75
116
  /**
76
117
  * A failure with an exit code attached (SPEC §2).
@@ -125,7 +166,7 @@ export type ConfigAction = (typeof CONFIG_ACTIONS)[number];
125
166
  * Paddock and Managers, every existing service unit's `ExecStart` names it, and
126
167
  * it is in two years of other people's scripts. They parse to the same command.
127
168
  */
128
- export declare const VERBS: readonly ["serve", "start", "service", "config"];
169
+ export declare const VERBS: readonly ["serve", "start", "service", "config", "busy", "update", "upgrade"];
129
170
  /**
130
171
  * A parsed invocation: which verb, plus the flags that followed it.
131
172
  *
@@ -144,33 +185,22 @@ export type Command = {
144
185
  verb: "config";
145
186
  action: ConfigAction | undefined;
146
187
  opts: CliOptions;
147
- };
188
+ }
189
+ /** `busy` takes no action — it is one question with one answer (SPEC §1). */
190
+ | {
191
+ verb: "busy";
192
+ opts: CliOptions;
193
+ }
148
194
  /**
149
- * Split a leading verb off the argv, then parse the rest as flags.
150
- *
151
- * The dispatch is deliberately a check on `argv[0]` alone rather than a scan for
152
- * the first non-flag token, and it happens BEFORE the flag loop. Two properties
153
- * fall out of that, both of which matter more than the flexibility given up:
154
- *
155
- * - **Bare `paddock` is untouched.** No verb means the whole argv goes to
156
- * {@link parseArgs} exactly as before, so the demo path cannot change
157
- * behaviour, and an unrecognised leading token still produces `unknown
158
- * option:` from the flag loop rather than a new and different error.
159
- * - **Flags parse after a verb**, so `paddock start --port 7299` and
160
- * `paddock service install --port 7299` both work, and the flag grammar is
161
- * the same one in every position.
162
- *
163
- * A verb is only a verb in first position: `paddock --port start` is an error
164
- * from `--port`, not a `start` invocation, and `paddock start start` is still
165
- * `unknown option`.
166
- *
167
- * That first half used to claim a *missing-value* error, which was wrong (#823):
168
- * `next()` only rejects `undefined`, so `start` was happily consumed as the port
169
- * and became `NaN` in `config.ts`. It is now a **value** error — `--port needs a
170
- * number between 1 and 65535` — which is the behaviour the claim was reaching
171
- * for. Corrected rather than deleted because the grammar it documents is real
172
- * and load-bearing; it was only the example's error that was misdescribed.
195
+ * `update` (SPEC §1, §5). `upgrade` is a HIDDEN alias: the spec requires it
196
+ * be accepted, and deliberately does not list it in the help — one name in
197
+ * the documentation, two that work, so nobody has to remember which word this
198
+ * tool chose.
173
199
  */
200
+ | {
201
+ verb: "update";
202
+ opts: CliOptions;
203
+ };
174
204
  export declare function parseCommand(argv: string[]): Command;
175
205
  export declare function parseArgs(argv: string[]): CliOptions;
176
206
  /**
@@ -196,7 +226,18 @@ export declare function explainListenError(err: unknown, host: string, port: str
196
226
  * bury the one line explaining what went wrong. The full text is one
197
227
  * `--help` away, and the last line here says so.
198
228
  */
199
- export declare const USAGE_SYNOPSIS = "Usage\n paddock [serve] [options] run the server in this terminal\n paddock service <action> [options] install|uninstall|status|start|stop|restart|logs\n paddock config <show|eject> [options] what this instance's config resolved to\n paddock -v | --version print the version and exit\n paddock -h | --help the full help";
200
- export declare const USAGE = "paddock \u2014 run a Paddock instance locally\n\nUsage\n npx @edspencer/paddock [options] run the server (the default)\n paddock serve [options] the same thing, said out loud\n (`paddock start` is a permanent alias)\n paddock service install [options] run it in the background from login\n paddock service uninstall stop it and remove the unit\n paddock service status [--json] installed? running? which version?\n paddock service start start an installed service\n paddock service stop stop it, leave it installed\n paddock service restart stop it and start it again\n paddock service logs [-f] [-n <lines>] the service's log\n (`paddock service --help`)\n paddock config show [--resolved] what this instance's config resolved\n to, and where each value came from\n paddock config eject [--write] freeze that resolution into\n paddock.config.yaml\n (`paddock config --help`)\n\nOptions\n -p, --port <port> HTTP/WS port (default 7233, or $PORT)\n --host <host> Bind address (default 127.0.0.1)\n -d, --data-dir <path> Projects + state (default ~/.paddock, or $PADDOCK_DATA_DIR)\n -o, --open Open the app in your browser once it is listening\n --verbose Show the server's own logs (quiet by default)\n -v, --version Print the Paddock version and exit\n -h, --help Show this help\n\nExit codes\n 0 done; running and answering\n 1 failed\n 2 usage: an unknown command or flag, or a bad value\n 3 not running: installed, but not running or not answering\n 4 not installed: there is no service unit\n\nOpening your own directories\n Where you run this from does not matter \u2014 the instance is decided by its data\n dir alone. Directories are added inside the app, on the Discover screen: it\n reads your Claude Code history, lists the directories you have worked in, and\n links the ones you tick as projects. A new instance opens on it.\n\n Importing a directory does not write into it. No .paddock/, no .chats/, no\n .gitignore edits, no CLAUDE.md \u2014 the project record and the copied transcripts\n both live in the data dir, and the project just points at the path. Your own\n ~/.claude transcripts are copied, never moved or deleted, so your terminal\n `claude` keeps working exactly as before.\n\nCredentials\n Paddock drives Claude Code, so it needs Claude credentials \u2014 and if you\n already use Claude Code on this machine, it uses the login you already have.\n That is a macOS Keychain entry on a Mac, or your ~/.claude/.credentials.json\n elsewhere (symlinked in, never copied). Reading a login writes nothing.\n\n Otherwise: a CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY in the environment,\n or a one-off `CLAUDE_CONFIG_DIR=<data-dir>/claude-home claude login`. With no\n login at all anywhere, run `claude setup-token`. Paddock says at startup when\n it can find none.\n\nPosture profiles\n One key picks how much Paddock shares and how much its agents may do:\n\n profile: balanced # paranoid | balanced | yolo (PADDOCK_PROFILE)\n\n paranoid shares nothing but the login and turns every capability off \u2014 the\n behaviour Paddock had before profiles existed. balanced (the default)\n inherits the CAPABILITIES your CLI already has \u2014 instructions, MCP servers,\n plugins \u2014 and adds the read-only self-management tools, while keeping your\n chat history Paddock's own. yolo turns the rest on: your transcripts, host\n hooks, the write and project tools, schedule mutation, deeper spawning, the\n browser.\n\n A profile only sets defaults \u2014 any single key still overrides it, and an\n individual key in the config file beats PADDOCK_PROFILE in the environment.\n Profiles never touch your port, bind address, auth or model list: yolo does\n NOT open the bind or relax auth, which stay a separate, explicit decision.\n\n What host actually reaches depends on the machine \u2014 a workstation has a real\n ~/.claude, a container usually has none. The profile sets the levers, the\n environment sets the blast radius.\n\n To see what your profile actually expanded to on THIS machine, with the layer\n each value came from: paddock config show --resolved\n\nSharing your Claude Code state\n Apart from that login, Paddock writes nothing outside its data dir by\n default: transcripts go to each project's .chats/, and your ~/.claude is read\n for config only. Each thing it can share is one key in\n <data-dir>/paddock.config.yaml, and each defaults to whatever your profile\n says (see Posture profiles below):\n\n claude:\n transcripts: host # own | host host on yolo only\n credentials: host # own | host host on every profile\n instructions: host # own | host own on paranoid, else host\n hooks: host # own | host host on yolo only\n mcpServers: host # own | host own on paranoid, else host\n\n transcripts: host makes a chat and a `claude --resume` in the same directory\n the same file, live in both directions; deleting such a chat in Paddock\n releases it rather than removing it, because it is your history rather than\n Paddock's copy. credentials: own is the opt-out from sharing the login above.\n\n instructions: host loads your ~/.claude CLAUDE.md, agents/, commands/ and\n plugins/. On from balanced up, so your curated CLAUDE.md does reach Paddock's\n agents; profile: paranoid or instructions: own keeps it out. Each project's\n own CLAUDE.md applies either way.\n\n hooks: host runs the shell commands your ~/.claude/settings.json binds to\n tool use. Off by default \u2014 inheriting someone's hooks is not something to\n discover after the fact. Its other keys (permissions, model, statusline)\n apply either way: under hooks: own Paddock writes its own settings.json\n carrying them with hooks dropped, regenerated at startup.\n\n mcpServers: host attaches the MCP servers declared in your ~/.claude.json \u2014\n the top-level ones, plus a project's own when its directory matches. To give\n this instance a server your machine doesn't have, declare it instead in a\n sibling mcpServers: block of the same file; use env:VAR_NAME anywhere a\n string goes so tokens stay out of it. That keeps a token out of the file, not\n out of `ps`: leave driveMode on its default (session) for a server holding\n one, since batch passes the definition to claude as a command-line argument.\n\nYour data\n Everything lives in one directory \u2014 ~/.paddock unless you pass --data-dir.\n Projects, chat transcripts and settings all persist there between runs. Move\n that directory to move your instance; delete it to start over. Nothing is\n stored anywhere else.\n\nNotes\n Binds loopback with authentication disabled, which is safe for a laptop. To\n expose it on a network, set PADDOCK_AUTH_MODE first \u2014 Paddock refuses to bind\n a routable interface wide open. See AUTH.md.\n\nDocs: https://github.com/edspencer/paddock";
201
- export declare const SERVICE_USAGE = "paddock service \u2014 keep Paddock running in the background\n\nUsage\n paddock service install [options] register it and start it now\n paddock service uninstall stop it and deregister it\n paddock service status [--json] is it registered, is it running, which\n version, where are the logs\n paddock service start start an installed service that is stopped\n paddock service stop stop it, and leave it installed\n paddock service restart stop it and start it again, re-reading config\n paddock service logs [-f] [-n <n>] the service's log (the last 50 lines)\n\nOptions (logs)\n -f, --follow keep printing what gets appended, until Ctrl-C\n -n, --lines <n> how many lines to print first (default 50)\n\nOptions (install only \u2014 recorded in the generated unit)\n -p, --port <port> HTTP/WS port (default 7233)\n --host <host> Bind address (default 127.0.0.1)\n -d, --data-dir <path> Only if you want an instance SEPARATE from your\n terminal one. Left out of the unit when you omit it\n AND `PADDOCK_DATA_DIR` is unset in this shell, so\n `paddock service` and a bare `paddock` are the same\n ~/.paddock instance reached two ways. If\n `PADDOCK_DATA_DIR` IS set here, that path is recorded\n in the unit \u2014 the service would otherwise point\n somewhere your terminal does not.\n --verbose Record the server's own logs, not just warnings\n\nAt login, not at boot\n This registers a per-USER service \u2014 a launchd LaunchAgent on macOS, a\n `systemd --user` unit on Linux \u2014 so it runs as you, with your own Claude\n login. That is not incidental: on macOS your Claude login is a Keychain item\n that only a logged-in user session can read. A boot-time system daemon has no\n such session and could not use it.\n\n So Paddock starts when you LOG IN, not when the machine boots. After a\n restart that nobody logs into, Paddock is not running. That is the design, not\n a fault.\n\n On Linux, a user service is also stopped when you log out. To keep it up:\n\n loginctl enable-linger $USER\n\nWhere it lives\n macOS ~/Library/LaunchAgents/net.edspencer.paddock.plist\n Linux ~/.config/systemd/user/paddock.service\n\n Both write stdout and stderr to ONE file, <data-dir>/logs/service.log, which\n is what `paddock service logs` reads. Not the journal on Linux: a volatile\n journal has nothing in it after the reboot you are asking about, and one file\n means one answer to \"where are the logs\" on every OS. Paddock rotates it\n itself at 8 MB, keeping three older generations beside it.\n\nExit codes\n 0 it is installed, running and answering\n 3 installed, but not running or not answering\n 4 not installed: there is no unit (status, logs, start, stop, restart)\n 1 something failed\n 2 usage: an unknown action or flag, or a bad value\n\nInstalled from npx?\n `service install` refuses. An npx cache path is hash-keyed and npm may prune\n it, so the unit would work until it silently didn't, at some future login.\n Install properly first:\n\n npm i -g @edspencer/paddock && paddock service install\n\nA note on access\n Paddock binds loopback with authentication off, which is right for a laptop.\n A service is up for as long as you are logged in rather than as long as a\n terminal tab, so that window is longer \u2014 but it is not wider: any local\n process that could reach the port could already read the same Claude login as\n you. Set PADDOCK_AUTH_MODE if you want a credential on it anyway.\n\nDocs: https://github.com/edspencer/paddock";
229
+ export declare const USAGE_SYNOPSIS = "Usage\n paddock [serve] [options] run the server in this terminal\n paddock service <action> [options] install|uninstall|status|start|stop|restart|logs\n paddock busy [--json] is the running instance busy?\n paddock update [--check] [--to <v>] install a newer Paddock\n paddock config <show|eject> [options] what this instance's config resolved to\n paddock -v | --version print the version and exit\n paddock -h | --help the full help";
230
+ export declare const USAGE = "paddock \u2014 run a Paddock instance locally\n\nUsage\n npx @edspencer/paddock [options] run the server (the default)\n paddock serve [options] the same thing, said out loud\n (`paddock start` is a permanent alias)\n paddock service install [options] run it in the background from login\n paddock service uninstall stop it and remove the unit\n paddock service status [--json] installed? running? which version?\n paddock service start start an installed service\n paddock service stop [--force] stop it, leave it installed\n paddock service restart [--force] stop it and start it again\n paddock service logs [-f] [-n <lines>] the service's log\n (`paddock service --help`)\n paddock busy [--json] is it busy? exit 0 no, 75 yes, 3\n nothing answering\n (`paddock busy --help`)\n paddock update [--check] [--to <v>] install a newer Paddock and restart\n the service\n (`paddock update --help`)\n paddock config show [--resolved] what this instance's config resolved\n to, and where each value came from\n paddock config eject [--write] freeze that resolution into\n paddock.config.yaml\n (`paddock config --help`)\n\nOptions\n -p, --port <port> HTTP/WS port (default 7233, or $PORT)\n --host <host> Bind address (default 127.0.0.1)\n -d, --data-dir <path> Projects + state (default ~/.paddock, or $PADDOCK_DATA_DIR)\n -o, --open Open the app in your browser once it is listening\n --verbose Show the server's own logs (quiet by default)\n -v, --version Print the Paddock version and exit\n -h, --help Show this help\n\nExit codes\n 0 done; running and answering; up to date; not busy\n 1 failed\n 2 usage: an unknown command or flag, or a bad value\n 3 not running: installed, but not running or not answering; nothing answers\n 4 not installed: there is no service unit\n 5 this install cannot update itself; the right command was printed (update)\n 6 the update failed and was rolled back; the old version is back (update)\n 7 the update failed and could not be rolled back; a person is needed\n 75 busy: refused, and why was printed. Try later, or use --force\n\nOpening your own directories\n Where you run this from does not matter \u2014 the instance is decided by its data\n dir alone. Directories are added inside the app, on the Discover screen: it\n reads your Claude Code history, lists the directories you have worked in, and\n links the ones you tick as projects. A new instance opens on it.\n\n Importing a directory does not write into it. No .paddock/, no .chats/, no\n .gitignore edits, no CLAUDE.md \u2014 the project record and the copied transcripts\n both live in the data dir, and the project just points at the path. Your own\n ~/.claude transcripts are copied, never moved or deleted, so your terminal\n `claude` keeps working exactly as before.\n\nCredentials\n Paddock drives Claude Code, so it needs Claude credentials \u2014 and if you\n already use Claude Code on this machine, it uses the login you already have.\n That is a macOS Keychain entry on a Mac, or your ~/.claude/.credentials.json\n elsewhere (symlinked in, never copied). Reading a login writes nothing.\n\n Otherwise: a CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY in the environment,\n or a one-off `CLAUDE_CONFIG_DIR=<data-dir>/claude-home claude login`. With no\n login at all anywhere, run `claude setup-token`. Paddock says at startup when\n it can find none.\n\nPosture profiles\n One key picks how much Paddock shares and how much its agents may do:\n\n profile: balanced # paranoid | balanced | yolo (PADDOCK_PROFILE)\n\n paranoid shares nothing but the login and turns every capability off \u2014 the\n behaviour Paddock had before profiles existed. balanced (the default)\n inherits the CAPABILITIES your CLI already has \u2014 instructions, MCP servers,\n plugins \u2014 and adds the read-only self-management tools, while keeping your\n chat history Paddock's own. yolo turns the rest on: your transcripts, host\n hooks, the write and project tools, schedule mutation, deeper spawning, the\n browser.\n\n A profile only sets defaults \u2014 any single key still overrides it, and an\n individual key in the config file beats PADDOCK_PROFILE in the environment.\n Profiles never touch your port, bind address, auth or model list: yolo does\n NOT open the bind or relax auth, which stay a separate, explicit decision.\n\n What host actually reaches depends on the machine \u2014 a workstation has a real\n ~/.claude, a container usually has none. The profile sets the levers, the\n environment sets the blast radius.\n\n To see what your profile actually expanded to on THIS machine, with the layer\n each value came from: paddock config show --resolved\n\nSharing your Claude Code state\n Apart from that login, Paddock writes nothing outside its data dir by\n default: transcripts go to each project's .chats/, and your ~/.claude is read\n for config only. Each thing it can share is one key in\n <data-dir>/paddock.config.yaml, and each defaults to whatever your profile\n says (see Posture profiles below):\n\n claude:\n transcripts: host # own | host host on yolo only\n credentials: host # own | host host on every profile\n instructions: host # own | host own on paranoid, else host\n hooks: host # own | host host on yolo only\n mcpServers: host # own | host own on paranoid, else host\n\n transcripts: host makes a chat and a `claude --resume` in the same directory\n the same file, live in both directions; deleting such a chat in Paddock\n releases it rather than removing it, because it is your history rather than\n Paddock's copy. credentials: own is the opt-out from sharing the login above.\n\n instructions: host loads your ~/.claude CLAUDE.md, agents/, commands/ and\n plugins/. On from balanced up, so your curated CLAUDE.md does reach Paddock's\n agents; profile: paranoid or instructions: own keeps it out. Each project's\n own CLAUDE.md applies either way.\n\n hooks: host runs the shell commands your ~/.claude/settings.json binds to\n tool use. Off by default \u2014 inheriting someone's hooks is not something to\n discover after the fact. Its other keys (permissions, model, statusline)\n apply either way: under hooks: own Paddock writes its own settings.json\n carrying them with hooks dropped, regenerated at startup.\n\n mcpServers: host attaches the MCP servers declared in your ~/.claude.json \u2014\n the top-level ones, plus a project's own when its directory matches. To give\n this instance a server your machine doesn't have, declare it instead in a\n sibling mcpServers: block of the same file; use env:VAR_NAME anywhere a\n string goes so tokens stay out of it. That keeps a token out of the file, not\n out of `ps`: leave driveMode on its default (session) for a server holding\n one, since batch passes the definition to claude as a command-line argument.\n\nYour data\n Everything lives in one directory \u2014 ~/.paddock unless you pass --data-dir.\n Projects, chat transcripts and settings all persist there between runs. Move\n that directory to move your instance; delete it to start over. Nothing is\n stored anywhere else.\n\nNotes\n Binds loopback with authentication disabled, which is safe for a laptop. To\n expose it on a network, set PADDOCK_AUTH_MODE first \u2014 Paddock refuses to bind\n a routable interface wide open. See AUTH.md.\n\nDocs: https://github.com/edspencer/paddock";
231
+ export declare const SERVICE_USAGE = "paddock service \u2014 keep Paddock running in the background\n\nUsage\n paddock service install [options] register it and start it now\n paddock service install --refresh re-write the unit, keeping its settings\n paddock service uninstall stop it and deregister it\n paddock service status [--json] is it registered, is it running, which\n version, where are the logs\n paddock service start start an installed service that is stopped\n paddock service stop [--force] stop it, and leave it installed\n paddock service restart [--force] stop it and start it again, re-reading config\n paddock service logs [-f] [-n <n>] the service's log (the last 50 lines)\n\nOptions (logs)\n -f, --follow keep printing what gets appended, until Ctrl-C\n -n, --lines <n> how many lines to print first (default 50)\n\nOptions (stop, restart)\n --force stop it even though it is busy\n\nOptions (install)\n --refresh Re-render the unit from the settings the EXISTING one\n carries \u2014 its port, host, data dir and verbosity \u2014\n rather than from this shell's flags and environment.\n This is what `paddock update` runs, through the new\n version's CLI, so the unit is written in the format\n that version writes. Exit 4 with nothing installed:\n there is no unit to refresh, and doing a first\n install with defaults instead is how a --port 9000\n service comes back on 7233.\n\nBusy\n `stop` and `restart` ask the running instance whether it is busy first, and\n refuse with exit 75 if it is \u2014 a chat turn in flight, a background task, a\n scheduled job. `paddock busy` asks the same question on its own.\n\n Being refused is the useful case: a restart kills a chat turn mid-sentence,\n and the turn cannot be resumed from where it was. Wait, or --force.\n\n `uninstall` does not ask. Removing the service is an explicit act, and\n someone uninstalling it has already decided.\n\nOptions (install only \u2014 recorded in the generated unit)\n -p, --port <port> HTTP/WS port (default 7233)\n --host <host> Bind address (default 127.0.0.1)\n -d, --data-dir <path> Only if you want an instance SEPARATE from your\n terminal one. Left out of the unit when you omit it\n AND `PADDOCK_DATA_DIR` is unset in this shell, so\n `paddock service` and a bare `paddock` are the same\n ~/.paddock instance reached two ways. If\n `PADDOCK_DATA_DIR` IS set here, that path is recorded\n in the unit \u2014 the service would otherwise point\n somewhere your terminal does not.\n --verbose Record the server's own logs, not just warnings\n\nAt login, not at boot\n This registers a per-USER service \u2014 a launchd LaunchAgent on macOS, a\n `systemd --user` unit on Linux \u2014 so it runs as you, with your own Claude\n login. That is not incidental: on macOS your Claude login is a Keychain item\n that only a logged-in user session can read. A boot-time system daemon has no\n such session and could not use it.\n\n So Paddock starts when you LOG IN, not when the machine boots. After a\n restart that nobody logs into, Paddock is not running. That is the design, not\n a fault.\n\n On Linux, a user service is also stopped when you log out. To keep it up:\n\n loginctl enable-linger $USER\n\nWhere it lives\n macOS ~/Library/LaunchAgents/net.edspencer.paddock.plist\n Linux ~/.config/systemd/user/paddock.service\n\n Both write stdout and stderr to ONE file, <data-dir>/logs/service.log, which\n is what `paddock service logs` reads. Not the journal on Linux: a volatile\n journal has nothing in it after the reboot you are asking about, and one file\n means one answer to \"where are the logs\" on every OS. Paddock rotates it\n itself at 8 MB, keeping three older generations beside it.\n\nExit codes\n 0 it is installed, running and answering\n 3 installed, but not running or not answering\n 4 not installed: there is no unit (status, logs, start, stop, restart)\n 1 something failed\n 2 usage: an unknown action or flag, or a bad value\n 75 busy, and --force was not given (stop, restart)\n\nInstalled from npx?\n `service install` refuses. An npx cache path is hash-keyed and npm may prune\n it, so the unit would work until it silently didn't, at some future login.\n Install properly first:\n\n npm i -g @edspencer/paddock && paddock service install\n\nA note on access\n Paddock binds loopback with authentication off, which is right for a laptop.\n A service is up for as long as you are logged in rather than as long as a\n terminal tab, so that window is longer \u2014 but it is not wider: any local\n process that could reach the port could already read the same Claude login as\n you. Set PADDOCK_AUTH_MODE if you want a credential on it anyway.\n\nDocs: https://github.com/edspencer/paddock";
232
+ export declare const BUSY_USAGE = "paddock busy \u2014 is the running instance in the middle of something?\n\nUsage\n paddock busy ask, and say so in a sentence\n paddock busy --json the same answer as one JSON document\n paddock busy -d <path> ask a particular instance\n\nExit codes \u2014 this command is FOR its exit code\n 0 not busy. Nothing a restart would cut short.\n 75 busy. What is running was printed.\n 3 nothing answered. No instance is running, so there is nothing to wait for.\n 1 something answered, but not as Paddock's busy check.\n\nOptions\n -d, --data-dir <path> Which instance to ask (default ~/.paddock, or\n $PADDOCK_DATA_DIR) \u2014 the same rule `paddock serve`\n uses, so the two always mean the same instance\n --json One JSON document on stdout: running, busy, url,\n version, counts. Prose goes to stderr\n -h, --help Show this help\n\nWhat counts as busy\n Only work a restart would LOSE or cut short:\n\n chat a chat turn running \u2014 a human turn, a fired trigger, a cron\n fire. A turn is a live claude subprocess writing a transcript,\n and it cannot be resumed from where it was interrupted.\n background a background task a live session is still holding after its\n turn ended: a background shell, a sub-agent, a Monitor.\n job a scheduled job herdctl is running.\n\n Not busy: an idle session (it resumes), an open browser tab (it reconnects),\n a pending curation sweep (it re-runs from its watermark).\n\nWhere to run it from\n From a terminal. A Paddock chat that runs this is itself one of the chat turns\n it counts, so it will always see itself as busy \u2014 and `service stop --force`\n from inside a chat stops the service that is running the chat, which does not\n come back with an explanation. That is why the refusal says so.\n\nFor scripts, containers and Watchtower\n `busy` is there for callers with no service to ask. 75 is EX_TEMPFAIL, which\n is the code Watchtower's pre-update hook reads as \"skip this one\":\n\n labels:\n com.centurylinklabs.watchtower.lifecycle.pre-update: paddock busy\n\n An Ansible task does the same thing with a retry. Nothing here contacts the\n network or the npm registry, and the question is answered from memory \u2014 it is\n cheap enough to ask in a loop.\n\nHow it finds the instance\n `<data-dir>/runtime.json`, written 0600 when the server starts listening and\n removed when it stops. There is no fallback to a default port: guessing one\n would ask whatever else happened to be listening there, and get an answer.\n\n A Paddock from before this feature shipped writes no such file, so it reads as\n not running (exit 3). Upgrade it and restart it once.\n\nDocs: https://github.com/edspencer/paddock";
202
233
  export declare const CONFIG_USAGE = "paddock config \u2014 what this instance's configuration actually resolved to\n\nUsage\n paddock config show the decisions: your profile, the keys your\n config file sets, the variables your\n environment sets\n paddock config show --resolved EVERY effective value, and which layer it\n came from\n paddock config show --json the same report as JSON, long values in\n full (sensitive ones still hidden)\n paddock config eject what freezing that resolution into\n paddock.config.yaml would write \u2014 a\n preview; writes nothing\n paddock config eject --write actually write it\n\nOptions\n -d, --data-dir <path> Which instance to inspect (default ~/.paddock, or\n $PADDOCK_DATA_DIR) \u2014 the same rule `paddock start`\n uses, so the two always read the same instance\n --resolved show: every field, not just the ones someone set\n --json show: the whole report as JSON (implies --resolved's\n scope)\n --show-sensitive show: print the values of fields marked sensitive\n --write eject: apply the plan. Without it, eject only prints\n --include-env eject: also freeze values an environment variable\n currently supplies (see below \u2014 off by default)\n -h, --help Show this help\n\nWhere a value can come from\n Config resolves in four layers, and each row of --resolved names the one that\n won:\n\n default Paddock's built-in default.\n profile (<name>) Your posture profile. The twelve levers a profile governs\n have no code default of their own any more \u2014 the profile\n IS their default \u2014 so this is a distinct answer from\n \"default\", and switching profile would change it.\n file A key in paddock.config.yaml.\n env <NAME> An environment variable, which beats the file for the\n same key.\n\n One wrinkle worth knowing, and the command shows it plainly: an individual key\n in the FILE beats PADDOCK_PROFILE in the environment. Specific beats general \u2014\n PADDOCK_PROFILE speaks for the levers you did not mention.\n\nWhy show, and not just write it all into the file\n `show` is computed by the loader the server boots with, so it cannot drift\n from what the process would actually do. A materialized file can: it stops\n inheriting improved defaults, says nothing about the variables your container\n sets on top, and no longer describes the whole surface the day a lever is\n added. That is why the thin file is the default and `show` is the answer to\n \"what am I actually running?\".\n\n `eject` is there for when you want it written down anyway \u2014 frozen, in the\n file, reviewable in git. It is a real tradeoff rather than a better `show`,\n so it prints what it would cost you and writes nothing until you pass --write.\n\nWhat eject writes, and what it leaves alone\n It writes the posture levers your profile expanded to, plus the behavioural\n settings the Config screen already round-trips through this file. It does NOT\n write:\n\n the bindings port, host, data dir, projects root, state dir, web dist.\n These resolve to absolute paths on THIS machine, and the\n data dir resolves to the directory holding the file \u2014 so\n ejecting them makes the file unportable and unmountable.\n sensitive keys transcription.endpoint can carry credentials in its URL.\n Bulk-writing a secret-shaped value to disk should not be\n one keystroke away; write that key by hand.\n env-owned keys by default. An environment variable BEATS the file, so\n writing its value in changes nothing today and everything\n the day the variable goes away \u2014 a deferred, silent change\n of provenance. eject names each one it skipped instead.\n --include-env writes them, which is the right flag if you\n are deliberately migrating from env vars to a file.\n\n It always writes `profile:` as well, even though every key that profile\n governs is now explicit. That line is what a lever added in a FUTURE release\n falls back to: without it, a new capability toggle would resolve against the\n built-in default profile rather than the posture you actually ejected from.\n\n Your comments and any keys Paddock does not manage survive \u2014 the file is\n round-tripped, not regenerated \u2014 and the write is atomic.\n\nReading nothing, writing nothing\n `show` resolves config and prints it. It starts no server, contacts nothing,\n and writes no file \u2014 including the data dir itself, which it will report as\n missing rather than create. `eject` writes exactly one file, and only with\n --write.\n\n Values are printed to a terminal that often ends up pasted into an issue, so\n fields marked sensitive are shown as (hidden). None of them is a secret \u2014\n Paddock keeps secrets out of this surface entirely, so there is no API key or\n JWT signing material here to hide or reveal.\n\nDocs: https://github.com/edspencer/paddock";
234
+ /**
235
+ * `update`'s own synopsis, printed after a usage error from it (SPEC §2).
236
+ *
237
+ * `update` has one usage error of its own — "there is no terminal to ask, so
238
+ * `--yes` is required" — and the contract says the usage follows the message.
239
+ * {@link USAGE_SYNOPSIS} is the wrong text there: it lists every command, and
240
+ * the reader's problem is one flag on the command they already typed.
241
+ */
242
+ export declare const UPDATE_SYNOPSIS = "Usage\n paddock update [--yes] install the latest release\n paddock update --check [--json] what a new version would be; changes nothing\n paddock update --to <version|tag> a particular version, or a dist-tag\n paddock update --force skip the busy check, and nothing else\n paddock update --help the full help";
243
+ export declare const UPDATE_USAGE = "paddock update \u2014 install a newer Paddock, and put the service back up\n\nUsage\n paddock update update to the latest release, asking first\n paddock update --check what a new version would be; changes nothing\n paddock update --yes do not ask (required when there is no terminal)\n paddock update --to 0.79.1 a particular version \u2014 the only way to go BACK\n paddock update --to next a dist-tag\n paddock update --json one JSON document on stdout\n\nOptions\n --check Ask the registry, report, and change nothing. Exits 0\n whether or not there is an update \u2014 scripts read\n `updateAvailable` from --json\n --to <version|tag> Install this version or dist-tag instead of latest.\n Required to move to a LOWER version: an update never\n goes backwards by accident\n --yes, -y Skip the question. Required when stdin is not a\n terminal, where a command that would have asked exits\n 2 rather than guessing\n --force Skip the busy check, and nothing else \u2014 the health\n check and the rollback still run\n --json One JSON document on stdout; all prose on stderr\n -h, --help Show this help\n\nWhat it does, in order\n 1 takes <data-dir>/update.lock, so two updates cannot interleave\n 2 works out how this copy was installed (see \"Installs that cannot update\n themselves\" below)\n 3 asks the registry for the target version and its `engines.node`\n 4 compares, and stops here with --check\n 5 checks the global folder is writable, and prints a sudo line if not.\n It never runs sudo itself\n 6 asks the running instance whether it is BUSY \u2014 before anything is stopped\n 7 asks you, unless --yes\n 8 fetches both the new and the current version into the npm cache, while\n the old version is still serving, so a rollback has its package to hand\n 9 stops the service\n 10 installs with the package manager this copy came from\n 11 hands over to the NEW CLI, which re-writes the service unit\n (`service install --refresh`) and starts it\n 12 waits for /api/health to report the version it just installed\n 13 and if any of 10\u201312 fails, puts the old version back\n\nExit codes \u2014 this command is FOR its exit code\n 0 updated, or already up to date, or --check reported\n 1 something failed, and nothing had been stopped yet\n 2 usage \u2014 including \"there is no terminal to ask, so --yes is required\"\n 5 this install cannot update itself. The right command was printed\n 6 the new version did not start; the old one is running again\n 7 the new version did not start and the old one could not be restored.\n The commands to run by hand were printed\n 75 busy: a chat turn, a background task or a scheduled job is running.\n Wait, or --force\n\nInstalls that cannot update themselves (exit 5)\n Paddock reads where it is running from, and five layouts are not ours to\n replace. Each prints the command that WOULD work:\n\n a container image docker compose pull && docker compose up -d\n a managed install whatever PADDOCK_UPDATE_HINT says\n npx / pnpm dlx npx @edspencer/paddock@latest already runs the latest\n a checkout git pull && npm install && npm run build\n a project dependency update it in that project\n a yarn classic global yarn global add @edspencer/paddock\n\n A global npm, pnpm, bun or volta install updates in place.\n\nWhere it runs from\n From a terminal, never from inside the service. An updater the service\n started \u2014 a Paddock chat, say \u2014 is in the service's own process group, so\n stopping the service kills the updater half way through step 9. The busy\n check refuses first and says so; --force from inside a chat would stop the\n service running that chat, which then never gets to report what happened.\n\nAsking the registry\n Only `update`, `update --check` and `doctor` ever contact the npm\n registry, and only when you run them. There is no background check and no\n check at startup; the server never asks. What the last check found is cached\n in <data-dir>/update-check.json, which is what `paddock service status`\n repeats \u2014 it never asks itself.\n\n The registry is `npm_config_registry`, else `npm config get registry`,\n else https://registry.npmjs.org.\n\nDocs: https://github.com/edspencer/paddock";