@hearsay-tools/squawk 0.18.0-pr4407.8607 → 0.18.0-pr4411.8615

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 (156) hide show
  1. package/dist/automations/tools.d.ts +8 -8
  2. package/dist/delegation/routes.d.ts +65 -65
  3. package/dist/delegation/transport.d.ts +65 -65
  4. package/dist/features/mcp/cli.d.ts +14 -0
  5. package/dist/features/mcp/cli.js +87 -0
  6. package/dist/features/mcp/cli.js.map +1 -0
  7. package/dist/features/mcp/index.d.ts +9 -0
  8. package/dist/features/mcp/index.js +13 -0
  9. package/dist/features/mcp/index.js.map +1 -0
  10. package/dist/features/mcp/stdio.d.ts +10 -0
  11. package/dist/features/mcp/stdio.js +41 -0
  12. package/dist/features/mcp/stdio.js.map +1 -0
  13. package/dist/features/mcp/tools.d.ts +19 -0
  14. package/dist/features/mcp/tools.js +476 -0
  15. package/dist/features/mcp/tools.js.map +1 -0
  16. package/dist/release/stable.d.ts +8 -0
  17. package/dist/release/stable.js +12 -0
  18. package/dist/release/stable.js.map +1 -1
  19. package/dist/server/automations-routes.d.ts +150 -150
  20. package/dist/server/live-routes.d.ts +6 -6
  21. package/dist/server/project-settings-routes.d.ts +107 -107
  22. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  23. package/dist/server/runner-install-routes.d.ts +10 -10
  24. package/dist/server/runs-routes.d.ts +291 -291
  25. package/dist/server/server.d.ts +76 -76
  26. package/dist/server/workspace-live-routes.d.ts +6 -6
  27. package/dist/task-cli/cli.js +54 -221
  28. package/dist/task-cli/cli.js.map +1 -1
  29. package/dist/task-cli/discovery.d.ts +22 -1
  30. package/dist/task-cli/discovery.js +69 -17
  31. package/dist/task-cli/discovery.js.map +1 -1
  32. package/dist/task-cli/http.d.ts +15 -13
  33. package/dist/task-cli/http.js +16 -6
  34. package/dist/task-cli/http.js.map +1 -1
  35. package/dist/task-cli/operations.d.ts +156 -0
  36. package/dist/task-cli/operations.js +388 -0
  37. package/dist/task-cli/operations.js.map +1 -0
  38. package/dist/task-cli/watch.d.ts +31 -8
  39. package/dist/task-cli/watch.js +159 -91
  40. package/dist/task-cli/watch.js.map +1 -1
  41. package/package.json +4 -4
  42. package/web/dist/assets/accounts-section-COizLyTO.js +1 -0
  43. package/web/dist/assets/activity-motion-DfI5xoMG.js +2 -0
  44. package/web/dist/assets/activity-route-BQs2vBeo.js +1 -0
  45. package/web/dist/assets/agent-config-section-BwBo-HRw.js +7 -0
  46. package/web/dist/assets/agent-defaults-section-h-Gjb_gh.js +1 -0
  47. package/web/dist/assets/{appearance-rXtZGJD_.js → appearance-Bcl2amXv.js} +1 -1
  48. package/web/dist/assets/{archive-on-merge-field-C7_Fwy2A.js → archive-on-merge-field-Bm8miJjt.js} +1 -1
  49. package/web/dist/assets/attention-8bNiiAFt.js +1 -0
  50. package/web/dist/assets/automations-route-CutF-cGn.css +1 -0
  51. package/web/dist/assets/automations-route-rSezHxBp.js +2 -0
  52. package/web/dist/assets/{commit-list-yW-pZ7Bc.js → commit-list-DtEqtn9o.js} +1 -1
  53. package/web/dist/assets/{diff-CfS2Qosw.js → diff-BK789dS0.js} +2 -2
  54. package/web/dist/assets/{diff-controls-DUiipGjf.js → diff-controls-BFqQNxRu.js} +1 -1
  55. package/web/dist/assets/{diff-view-pPxrBBze.js → diff-view-BEgQ7jZV.js} +1 -1
  56. package/web/dist/assets/file-preview-CDWTFZ4P.js +2 -0
  57. package/web/dist/assets/{folder-browser-B7IbnF0d.js → folder-browser-BfclRPcX.js} +1 -1
  58. package/web/dist/assets/{git-toolbar-Dwndizit.js → git-toolbar-Pugtjt-9.js} +1 -1
  59. package/web/dist/assets/github-CvpaGHe6.js +1 -0
  60. package/web/dist/assets/global-activity-route-Di_ICsRI.js +1 -0
  61. package/web/dist/assets/{image-preview-Bvd30ghX.js → image-preview-Dx2w5oIn.js} +1 -1
  62. package/web/dist/assets/index-CGjknHnV.css +1 -0
  63. package/web/dist/assets/index-CJFT0IZP.js +21 -0
  64. package/web/dist/assets/{label-Bt8n7Spq.js → label-DEH7fJN4.js} +1 -1
  65. package/web/dist/assets/live-reads-BJ9eDISf.js +1 -0
  66. package/web/dist/assets/live-refetch-VoLPvzhe.js +1 -0
  67. package/web/dist/assets/markdown-Dv0r75AX.js +4 -0
  68. package/web/dist/assets/{nav-row-styles-DKeXbc4N.js → nav-row-styles-DqKjMToI.js} +1 -1
  69. package/web/dist/assets/{notifications-section-ALnp6W1u.js → notifications-section-DCiqPl3M.js} +1 -1
  70. package/web/dist/assets/open-in-menu-HM5l7Bwk.js +1 -0
  71. package/web/dist/assets/{preview-pane-connected-rud-axMx.js → preview-pane-connected-WV9oolnn.js} +1 -1
  72. package/web/dist/assets/project-location-CfJLc6aJ.js +1 -0
  73. package/web/dist/assets/{project-router-CLJTc7gv.js → project-router-Bii3ofOk.js} +1 -1
  74. package/web/dist/assets/project-scope-context-BdqKyBHa.js +4 -0
  75. package/web/dist/assets/projects-section-D2cACaaG.js +1 -0
  76. package/web/dist/assets/{prompt-templates-section-BQdQIVys.js → prompt-templates-section-toLPd5u2.js} +1 -1
  77. package/web/dist/assets/queries-C7VNk-nW.js +1 -0
  78. package/web/dist/assets/{reference-chip-D0v0keVC.js → reference-chip-rylFalfg.js} +1 -1
  79. package/web/dist/assets/{remote-settings-notice-DeCObYJC.js → remote-settings-notice-N9vtBTIK.js} +1 -1
  80. package/web/dist/assets/repo-git-DJym0aRY.js +1 -0
  81. package/web/dist/assets/report-reader-CjskGtxS.js +1 -0
  82. package/web/dist/assets/reports-B-G9HA48.js +1 -0
  83. package/web/dist/assets/reports-CNFNb36Z.css +1 -0
  84. package/web/dist/assets/{resources-section-B19JoAbk.js → resources-section-B88h1y0Q.js} +1 -1
  85. package/web/dist/assets/run-header-B-olCSdg.js +2 -0
  86. package/web/dist/assets/{select-CEH-C-jh.js → select-BaydzE-I.js} +1 -1
  87. package/web/dist/assets/{session-context-section-C33VjuF4.js → session-context-section-BJKRXbss.js} +2 -2
  88. package/web/dist/assets/settings-agent-picker-6xZMIC_D.js +1 -0
  89. package/web/dist/assets/settings-shell-BkTgs1S9.js +1 -0
  90. package/web/dist/assets/settings-shell-iSd4xMWS.css +1 -0
  91. package/web/dist/assets/{sidebar-section-DOTH6fiq.js → sidebar-section-B57HIEgv.js} +1 -1
  92. package/web/dist/assets/skills-pBrfwrKF.js +1 -0
  93. package/web/dist/assets/{tab-link-Bu1g-ArE.js → tab-link-B1CULYRs.js} +1 -1
  94. package/web/dist/assets/task-changes-CXldTh93.js +1 -0
  95. package/web/dist/assets/task-commits-BZ3B_GPB.js +1 -0
  96. package/web/dist/assets/task-files-BSfmCkJc.js +1 -0
  97. package/web/dist/assets/task-github-item-v2bygvdO.js +1 -0
  98. package/web/dist/assets/{task-groups-4tzKGROI.js → task-groups-BbnYlkYj.js} +1 -1
  99. package/web/dist/assets/task-thread-BPWnJ7Qx.js +9 -0
  100. package/web/dist/assets/{tasks-table-C5uoZMFs.js → tasks-table-Cx7AM7lZ.js} +1 -1
  101. package/web/dist/assets/{thread-state-_-bLdUA2.js → thread-state-R0MTvwlo.js} +1 -1
  102. package/web/dist/assets/toaster-Bo5vCbz-.js +1 -0
  103. package/web/dist/assets/use-hand-to-agent-state-B6h6kcQg.css +1 -0
  104. package/web/dist/assets/use-hand-to-agent-state-BckHuhr8.js +1 -0
  105. package/web/dist/assets/useInfiniteQuery--iQKfpUQ.js +1 -0
  106. package/web/dist/assets/useQuery-BSyhc3l3.js +1 -0
  107. package/web/dist/assets/workflows-BBc2PFDB.js +7 -0
  108. package/web/dist/assets/workflows-C6suai0L.css +1 -0
  109. package/web/dist/assets/workspace-tools-CiTG-ArW.js +1 -0
  110. package/web/dist/assets/{worktrees-section-CN78zo2m.js → worktrees-section-C07tNayi.js} +4 -4
  111. package/web/dist/index.html +18 -17
  112. package/web/dist/assets/accounts-section-DbLoty0g.js +0 -1
  113. package/web/dist/assets/activity-motion-DsIybVZn.js +0 -2
  114. package/web/dist/assets/activity-route-BXehwJ4N.js +0 -1
  115. package/web/dist/assets/agent-config-section-BKANTX-h.js +0 -7
  116. package/web/dist/assets/agent-defaults-section-D7ohQxAI.js +0 -1
  117. package/web/dist/assets/arrow-up-right-DKGzsMqY.js +0 -1
  118. package/web/dist/assets/attention-CBCeJN5w.js +0 -1
  119. package/web/dist/assets/automations-route-CzqZXK0W.css +0 -1
  120. package/web/dist/assets/automations-route-h7bwC5xx.js +0 -2
  121. package/web/dist/assets/file-preview-CGAcZe9q.js +0 -2
  122. package/web/dist/assets/github-DJ0jdSaa.js +0 -1
  123. package/web/dist/assets/global-activity-route-BV9RmVEz.js +0 -1
  124. package/web/dist/assets/html-report-BX3msvci.js +0 -3
  125. package/web/dist/assets/html-report-frame-uuqkBC0u.js +0 -1
  126. package/web/dist/assets/index-B-_22hXp.js +0 -21
  127. package/web/dist/assets/index-C69_Sk06.css +0 -1
  128. package/web/dist/assets/live-reads-Crd6fVGH.js +0 -1
  129. package/web/dist/assets/markdown-BDjWFex4.js +0 -2
  130. package/web/dist/assets/open-in-menu-BPp88ouw.js +0 -1
  131. package/web/dist/assets/page-shell-DPQBoUpR.css +0 -1
  132. package/web/dist/assets/page-shell-h8a6oznS.js +0 -1
  133. package/web/dist/assets/project-location-BRxXN249.js +0 -1
  134. package/web/dist/assets/project-scope-context-Rv6S_BXt.js +0 -4
  135. package/web/dist/assets/projects-section-BTyOG2uL.js +0 -1
  136. package/web/dist/assets/queries-qCF-eOqZ.js +0 -1
  137. package/web/dist/assets/repo-git-CegVXOtZ.js +0 -1
  138. package/web/dist/assets/report-reader-zqO4yokN.js +0 -1
  139. package/web/dist/assets/reports-CgbU2SrW.css +0 -1
  140. package/web/dist/assets/reports-DP-sxf1p.js +0 -1
  141. package/web/dist/assets/run-header-PqdYTt5O.js +0 -2
  142. package/web/dist/assets/settings-agent-picker-4PfVRtdT.js +0 -1
  143. package/web/dist/assets/settings-shell-CE1EKMmX.js +0 -1
  144. package/web/dist/assets/settings-shell-CqiAPuLq.css +0 -1
  145. package/web/dist/assets/skills-BuxDnPg-.js +0 -1
  146. package/web/dist/assets/task-changes-D8rzLeLg.js +0 -1
  147. package/web/dist/assets/task-commits-BpcYm-FY.js +0 -1
  148. package/web/dist/assets/task-files-DaaC4c18.js +0 -1
  149. package/web/dist/assets/task-github-item-D8kwUMZL.js +0 -1
  150. package/web/dist/assets/task-thread-9E6bYoV6.js +0 -9
  151. package/web/dist/assets/toaster-BXnLIU3z.js +0 -1
  152. package/web/dist/assets/use-hand-to-agent-state-B-chm1Rk.js +0 -1
  153. package/web/dist/assets/use-hand-to-agent-state-Ch0ok71s.css +0 -1
  154. package/web/dist/assets/workflows-Df3RjnXf.js +0 -7
  155. package/web/dist/assets/workflows-DsE0ExV6.css +0 -1
  156. package/web/dist/assets/workspace-tools-CAQH-2K5.js +0 -1
@@ -3062,6 +3062,12 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
3062
3062
  output: {
3063
3063
  generation: string;
3064
3064
  results: ({
3065
+ projectId: string;
3066
+ runId: string;
3067
+ type: "error" | "reset";
3068
+ status: 400 | 404 | 409 | 413 | 503;
3069
+ error: string;
3070
+ } | {
3065
3071
  projectId: string;
3066
3072
  runId: string;
3067
3073
  type: "batch";
@@ -3082,12 +3088,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
3082
3088
  cursor: string;
3083
3089
  afterSeq: number;
3084
3090
  hasMore: boolean;
3085
- } | {
3086
- projectId: string;
3087
- runId: string;
3088
- type: "error" | "reset";
3089
- status: 400 | 404 | 409 | 413 | 503;
3090
- error: string;
3091
3091
  })[];
3092
3092
  };
3093
3093
  outputFormat: "json";
@@ -8700,6 +8700,37 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
8700
8700
  } & {
8701
8701
  "/runs/:id/worker-destroy": {
8702
8702
  $post: {
8703
+ output: {
8704
+ readonly code: "capacity_limit" | "denied_scope" | "incompatible_state" | "incomplete_cleanup" | "invalid_baseline" | "invalid_input" | "unauthenticated" | "unavailable_diff" | "unavailable_transport";
8705
+ readonly error: string;
8706
+ readonly modelChoices?: {
8707
+ runner: string;
8708
+ requestedModel: string;
8709
+ availableModels: {
8710
+ id: string;
8711
+ label: string;
8712
+ description: string;
8713
+ effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
8714
+ }[];
8715
+ otherRunners: string[];
8716
+ } | undefined;
8717
+ };
8718
+ outputFormat: "json";
8719
+ status: 400 | 401 | 403 | 409 | 503;
8720
+ input: {
8721
+ query: {
8722
+ [x: string]: string | string[];
8723
+ };
8724
+ } & {
8725
+ param: {
8726
+ id: string;
8727
+ };
8728
+ } & {
8729
+ json: {
8730
+ discardWork?: true | undefined;
8731
+ };
8732
+ };
8733
+ } | {
8703
8734
  output: {
8704
8735
  error: string;
8705
8736
  code?: "invalid_input" | undefined;
@@ -8785,37 +8816,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
8785
8816
  discardWork?: true | undefined;
8786
8817
  };
8787
8818
  };
8788
- } | {
8789
- output: {
8790
- readonly code: "capacity_limit" | "denied_scope" | "incompatible_state" | "incomplete_cleanup" | "invalid_baseline" | "invalid_input" | "unauthenticated" | "unavailable_diff" | "unavailable_transport";
8791
- readonly error: string;
8792
- readonly modelChoices?: {
8793
- runner: string;
8794
- requestedModel: string;
8795
- availableModels: {
8796
- id: string;
8797
- label: string;
8798
- description: string;
8799
- effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
8800
- }[];
8801
- otherRunners: string[];
8802
- } | undefined;
8803
- };
8804
- outputFormat: "json";
8805
- status: 400 | 401 | 403 | 409 | 503;
8806
- input: {
8807
- query: {
8808
- [x: string]: string | string[];
8809
- };
8810
- } & {
8811
- param: {
8812
- id: string;
8813
- };
8814
- } & {
8815
- json: {
8816
- discardWork?: true | undefined;
8817
- };
8818
- };
8819
8819
  };
8820
8820
  };
8821
8821
  } & {
@@ -19444,9 +19444,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
19444
19444
  status: 404 | 409;
19445
19445
  input: {
19446
19446
  param: {
19447
- id: string;
19448
- } & {
19449
19447
  sha: string;
19448
+ } & {
19449
+ id: string;
19450
19450
  };
19451
19451
  };
19452
19452
  } | {
@@ -19475,9 +19475,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
19475
19475
  status: import("hono/utils/http-status").ContentfulStatusCode;
19476
19476
  input: {
19477
19477
  param: {
19478
- id: string;
19479
- } & {
19480
19478
  sha: string;
19479
+ } & {
19480
+ id: string;
19481
19481
  };
19482
19482
  };
19483
19483
  };
@@ -25469,6 +25469,37 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
25469
25469
  } & {
25470
25470
  "/runs/:id/worker-destroy": {
25471
25471
  $post: {
25472
+ output: {
25473
+ readonly code: "capacity_limit" | "denied_scope" | "incompatible_state" | "incomplete_cleanup" | "invalid_baseline" | "invalid_input" | "unauthenticated" | "unavailable_diff" | "unavailable_transport";
25474
+ readonly error: string;
25475
+ readonly modelChoices?: {
25476
+ runner: string;
25477
+ requestedModel: string;
25478
+ availableModels: {
25479
+ id: string;
25480
+ label: string;
25481
+ description: string;
25482
+ effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
25483
+ }[];
25484
+ otherRunners: string[];
25485
+ } | undefined;
25486
+ };
25487
+ outputFormat: "json";
25488
+ status: 400 | 401 | 403 | 409 | 503;
25489
+ input: {
25490
+ query: {
25491
+ [x: string]: string | string[];
25492
+ };
25493
+ } & {
25494
+ param: {
25495
+ id: string;
25496
+ };
25497
+ } & {
25498
+ json: {
25499
+ discardWork?: true | undefined;
25500
+ };
25501
+ };
25502
+ } | {
25472
25503
  output: {
25473
25504
  error: string;
25474
25505
  code?: "invalid_input" | undefined;
@@ -25554,37 +25585,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
25554
25585
  discardWork?: true | undefined;
25555
25586
  };
25556
25587
  };
25557
- } | {
25558
- output: {
25559
- readonly code: "capacity_limit" | "denied_scope" | "incompatible_state" | "incomplete_cleanup" | "invalid_baseline" | "invalid_input" | "unauthenticated" | "unavailable_diff" | "unavailable_transport";
25560
- readonly error: string;
25561
- readonly modelChoices?: {
25562
- runner: string;
25563
- requestedModel: string;
25564
- availableModels: {
25565
- id: string;
25566
- label: string;
25567
- description: string;
25568
- effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
25569
- }[];
25570
- otherRunners: string[];
25571
- } | undefined;
25572
- };
25573
- outputFormat: "json";
25574
- status: 400 | 401 | 403 | 409 | 503;
25575
- input: {
25576
- query: {
25577
- [x: string]: string | string[];
25578
- };
25579
- } & {
25580
- param: {
25581
- id: string;
25582
- };
25583
- } & {
25584
- json: {
25585
- discardWork?: true | undefined;
25586
- };
25587
- };
25588
25588
  };
25589
25589
  };
25590
25590
  } & {
@@ -36213,9 +36213,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
36213
36213
  status: 404 | 409;
36214
36214
  input: {
36215
36215
  param: {
36216
- id: string;
36217
- } & {
36218
36216
  sha: string;
36217
+ } & {
36218
+ id: string;
36219
36219
  };
36220
36220
  };
36221
36221
  } | {
@@ -36244,9 +36244,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
36244
36244
  status: import("hono/utils/http-status").ContentfulStatusCode;
36245
36245
  input: {
36246
36246
  param: {
36247
- id: string;
36248
- } & {
36249
36247
  sha: string;
36248
+ } & {
36249
+ id: string;
36250
36250
  };
36251
36251
  };
36252
36252
  };
@@ -7,12 +7,6 @@ export declare function createWorkspaceLiveRoutes(live: Parameters<typeof create
7
7
  output: {
8
8
  generation: string;
9
9
  results: ({
10
- projectId: string;
11
- runId: string;
12
- type: "error" | "reset";
13
- status: 400 | 404 | 409 | 413 | 503;
14
- error: string;
15
- } | {
16
10
  projectId: string;
17
11
  runId: string;
18
12
  type: "batch";
@@ -33,6 +27,12 @@ export declare function createWorkspaceLiveRoutes(live: Parameters<typeof create
33
27
  cursor: string;
34
28
  afterSeq: number;
35
29
  hasMore: boolean;
30
+ } | {
31
+ projectId: string;
32
+ runId: string;
33
+ type: "error" | "reset";
34
+ status: 400 | 404 | 409 | 413 | 503;
35
+ error: string;
36
36
  })[];
37
37
  };
38
38
  outputFormat: "json";
@@ -1,25 +1,17 @@
1
1
  import { commandText } from '../home/command.js';
2
2
  import { productEnv } from '../core/product-env.js';
3
- import { randomUUID } from 'node:crypto';
4
3
  import { open as openFile } from 'node:fs/promises';
5
4
  import { resolve } from 'node:path';
6
5
  import { parseArgs } from 'node:util';
7
6
  import { controlLocation } from '../contract/index.js';
8
- import { apiRunSchema, archiveFinishedResponseSchema, cancelResponseSchema, finishResponseSchema, messageResponseSchema, runRecordSchema, runStatusSchema, } from '../contract/index.js';
9
- import { changesPayloadSchema } from '../contract/index.js';
10
- import { pendingAskOf } from '../contract/index.js';
11
- import { asksQuestion } from '../contract/index.js';
12
- import { runHistoryContextSchema } from '../contract/index.js';
13
- import { runnerSkillListSchema } from '../contract/index.js';
14
- import { runnerSchema } from '../contract/index.js';
15
- import { runnersResponseSchema } from '../contract/index.js';
7
+ import { runStatusSchema } from '../contract/index.js';
16
8
  import { openUrl } from '../open-url.js';
17
9
  import { knownRunnerIds } from '../core/runner-registry.js';
18
- import { runnerFlag, skillFlagIssue, skillTaskSteps } from '../workflows/types.js';
10
+ import { runnerFlag, skillFlagIssue } from '../workflows/types.js';
19
11
  import { discoverCockpit } from './discovery.js';
20
- import { fetchJson, handoffUrl, invalidResponse, refuse, request, TaskCliError, threadUrl } from './http.js';
21
- import { projectListRow, projectStatus } from './projections.js';
22
- import { DEFAULT_WAIT_UNTIL, readLog, requestRunSummaries, waitForRuns } from './watch.js';
12
+ import { TaskCliError, threadUrl } from './http.js';
13
+ import { archiveFinishedTasks, archiveTask, finishTask, getRun, getTaskDiff, getTaskStatus, listTasks, sendTaskMessage, setTaskNotify, startTask, stopTask, waitForTasks, workerParent, } from './operations.js';
14
+ import { DEFAULT_WAIT_UNTIL, readLog } from './watch.js';
23
15
  /**
24
16
  * `cez task` — start, watch and steer cockpit tasks from a terminal or a bot (#504, spec
25
17
  * 2026-09-24-cez-task-cli). A thin JSON client over the cockpit's own run routes: one JSON
@@ -419,41 +411,12 @@ function validateFlags(name, values) {
419
411
  if (name === 'wait' || name === 'log' || values.wait)
420
412
  timeoutMs(values);
421
413
  }
422
- async function getRun(cockpit, id) {
423
- const result = await request(cockpit, `/runs/${encodeURIComponent(id)}`);
424
- if (result.status !== 200)
425
- refuse(result);
426
- const run = apiRunSchema.safeParse(result.data);
427
- return run.success ? run.data : invalidResponse('run');
428
- }
429
- /** `list --full` prints contract `ApiRun` rows, so it alone still reads every full record. */
430
- async function listRuns(cockpit) {
431
- const result = await request(cockpit, '/runs');
432
- if (result.status !== 200)
433
- refuse(result);
434
- const runs = apiRunSchema.array().safeParse(result.data);
435
- return runs.success ? runs.data : invalidResponse('run list');
436
- }
437
- /**
438
- * Workers are steer targets of their parent, not tasks ops follows (#635): the list leaves them
439
- * out, and subscribing one to the webhook is refused with the parent to subscribe instead. Every
440
- * other id-addressed operation still reaches a worker.
441
- */
442
- function workerParent(run) {
443
- return run.delegation?.role === 'worker' ? run.delegation.parentRunId : undefined;
444
- }
445
414
  async function refuseWorkerNotify(cockpit, id) {
446
415
  const parentId = workerParent(await getRun(cockpit, id));
447
416
  if (parentId !== undefined) {
448
417
  usageError(commandText(`task ${id} is a worker of task ${parentId}; notify the parent instead: cez task notify ${parentId}`), { parentId });
449
418
  }
450
419
  }
451
- /** The latest valid unanswered question, from the same derivation the cockpit renders. */
452
- async function pendingQuestion(cockpit, id) {
453
- const result = await request(cockpit, `/runs/${encodeURIComponent(id)}/history-context`);
454
- const context = runHistoryContextSchema.safeParse(result.data);
455
- return result.status === 200 && context.success ? pendingAskOf(context.data.contextEvents) : undefined;
456
- }
457
420
  /** The boolean start flags, each sent only when given, so an absent flag keeps the server default. */
458
421
  function startToggles(values) {
459
422
  return {
@@ -465,143 +428,63 @@ function startToggles(values) {
465
428
  ...(values['no-messaging'] ? { allowMessaging: false } : {}),
466
429
  };
467
430
  }
468
- /**
469
- * The project's default runner as the server runs it. A stored id no runner registered names the
470
- * first registered runner, as the server's `resolveRunnerId` does (hearsay-tools/squawk#4200). When
471
- * the runners list cannot be read, the stored id is used as it is.
472
- */
473
- async function defaultRunnerFor(cockpit) {
474
- const config = await request(cockpit, '/config');
475
- const stored = config.status === 200 && config.data && typeof config.data === 'object' ? runnerSchema.safeParse(Reflect.get(config.data, 'defaultRunner')) : undefined;
476
- if (!stored?.success)
477
- return undefined;
478
- const runners = await fetchJson(`${cockpit.origin}/api/v1/runners`);
479
- const registered = runners.status === 200 ? runnersResponseSchema.safeParse(runners.data) : undefined;
480
- if (!registered?.success)
481
- return stored.data;
482
- const ids = registered.data.runners.map((entry) => entry.id);
483
- return ids.includes(stored.data) ? stored.data : ids[0] ?? stored.data;
484
- }
485
- async function skillWarning(cockpit, skill, runner) {
486
- let warning;
487
- // Discovery is advisory: the catalog can change before a queued run executes. The server
488
- // fails a step with a missing skill, and idempotent retries still go to POST /runs.
489
- const unverified = `could not check whether skill "${skill}" is available; a missing id fails the step`;
490
- try {
491
- const selectedRunner = runner ?? await defaultRunnerFor(cockpit);
492
- const catalog = selectedRunner ? await request(cockpit, `/runner-skills?runner=${encodeURIComponent(selectedRunner)}`) : undefined;
493
- if (catalog?.status === 200) {
494
- const skills = runnerSkillListSchema.safeParse(catalog.data);
495
- warning = skills.success
496
- ? skills.data.skills.some((entry) => entry.id === skill)
497
- ? undefined
498
- : `skill "${skill}" is not currently available; a missing id fails the step`
499
- : unverified;
500
- }
501
- else {
502
- warning = unverified;
503
- }
504
- }
505
- catch {
506
- warning = unverified;
507
- }
508
- return warning;
509
- }
510
431
  async function start(cockpit, io, values, task, print) {
511
432
  const waitMs = values.wait ? timeoutMs(values) : undefined;
512
- const requestId = values['request-id'] ?? randomUUID();
513
- const skill = values.skill;
514
433
  const { runner } = runnerFlag({ runner: values.runner, backend: values.backend });
515
434
  // The webhook is opt-in: only `--notify` subscribes the task, and the server refuses it on a
516
435
  // project with no webhook (400 with a hint). `--no-notify` stays accepted for older scripts.
517
436
  const notify = values['no-notify'] ? false : values.notify ? true : undefined;
518
- const warning = skill === undefined ? undefined : await skillWarning(cockpit, skill, runner);
519
- const result = await request(cockpit, '/runs', {
520
- body: {
521
- task,
522
- ...(skill === undefined
523
- ? { workflow: values.workflow ?? 'quick-task' }
524
- : { steps: skillTaskSteps(skill) }),
525
- runner,
526
- model: values.model,
527
- effort: values.effort,
528
- ...startToggles(values),
529
- notify,
530
- clientRequestId: requestId,
531
- },
437
+ const started = await startTask(cockpit, {
438
+ task,
439
+ requestId: values['request-id'],
440
+ workflow: values.workflow,
441
+ skill: values.skill,
442
+ runner,
443
+ model: values.model,
444
+ effort: values.effort,
445
+ ...startToggles(values),
446
+ notify,
532
447
  });
533
- if (result.status !== 200 && result.status !== 201)
534
- refuse(result);
535
- const run = runRecordSchema.safeParse(result.data);
536
- if (!run.success)
537
- invalidResponse('start');
538
- const started = {
539
- id: run.data.id,
540
- url: threadUrl(cockpit, run.data.id),
541
- status: run.data.status,
542
- created: result.status === 201,
543
- requestId,
544
- notify: run.data.notify === true,
545
- warning,
546
- branch: run.data.branch,
547
- };
548
448
  if (waitMs === undefined) {
549
449
  print(started);
550
450
  return EXIT.ok;
551
451
  }
552
- const waited = await waitForRuns(cockpit, [run.data.id], { mode: 'all', until: waitUntil(values), timeoutMs: waitMs, pollMs: io.pollMs });
452
+ const waited = await waitForTasks(cockpit, {
453
+ ids: [started.id],
454
+ mode: 'all',
455
+ until: waitUntil(values),
456
+ timeoutMs: waitMs,
457
+ pollMs: io.pollMs,
458
+ });
553
459
  const final = waited.runs[0];
554
460
  print({ ...started, ...final, until: waited.until, timedOut: waited.timedOut });
555
461
  return waited.exitCode;
556
462
  }
557
- async function setNotify(cockpit, id, notify, message) {
558
- const result = await request(cockpit, `/runs/${encodeURIComponent(id)}/notify`, {
559
- body: { notify, message },
560
- });
561
- if (result.status !== 200)
562
- refuse(result);
563
- const run = runRecordSchema.safeParse(result.data);
564
- return run.success ? run.data : invalidResponse('notify');
565
- }
566
463
  async function send(cockpit, values, id, text, print) {
567
- const path = `/runs/${encodeURIComponent(id)}`;
568
464
  if (values.notify)
569
465
  await refuseWorkerNotify(cockpit, id);
570
466
  // Before the message, so the status change it causes is already reported.
571
- const notified = values.notify ? { notify: (await setNotify(cockpit, id, true, undefined)).notify === true } : {};
572
- const delivered = await request(cockpit, `${path}/messages`, { body: { text } });
573
- if (delivered.status === 200) {
574
- const answer = messageResponseSchema.safeParse(delivered.data);
575
- if (!answer.success)
576
- invalidResponse('message');
577
- const delivery = 'delivered' in answer.data ? 'delivered' : 'queued' in answer.data ? 'queued' : 'deferred';
578
- print({ id, delivery, ...notified });
579
- return EXIT.ok;
580
- }
581
- const closed = delivered.status === 409 && delivered.data?.error === 'session closed';
582
- if (!closed)
583
- refuse(delivered);
584
- if (!values.resume) {
585
- print({ id, delivery: 'not-delivered', reason: 'session closed', next: commandText(`cez task send ${id} '…' --resume`), ...notified });
586
- return EXIT.failed;
587
- }
588
- const resumed = await request(cockpit, `${path}/continue`, { body: { text } });
589
- if (resumed.status !== 200)
590
- refuse(resumed);
591
- print({ id, delivery: 'resumed', ...notified });
592
- return EXIT.ok;
467
+ const notified = values.notify ? { notify: (await setTaskNotify(cockpit, id, true, undefined)).notify === true } : {};
468
+ const result = await sendTaskMessage(cockpit, { id, text, resume: values.resume === true }, { closedHintStyle: 'cli' });
469
+ print({ ...result, ...notified });
470
+ return result.delivery === 'not-delivered' ? EXIT.failed : EXIT.ok;
593
471
  }
594
472
  async function notify(cockpit, id, values, text, print) {
595
473
  // --off stays open so a subscription made before this guard can still be undone.
596
474
  if (!values.off)
597
475
  await refuseWorkerNotify(cockpit, id);
598
- const run = await setNotify(cockpit, id, !values.off, text);
476
+ const run = await setTaskNotify(cockpit, id, !values.off, text);
599
477
  print({ id, notify: run.notify === true, ...(text === undefined ? {} : { message: true }) });
600
478
  return EXIT.ok;
601
479
  }
602
480
  async function wait(cockpit, io, values, positionals, print) {
603
- const mode = waitMode(values);
604
- const waited = await waitForRuns(cockpit, positionals, { mode, until: waitUntil(values), timeoutMs: timeoutMs(values), pollMs: io.pollMs });
481
+ const waited = await waitForTasks(cockpit, {
482
+ ids: positionals,
483
+ mode: waitMode(values),
484
+ until: waitUntil(values),
485
+ timeoutMs: timeoutMs(values),
486
+ pollMs: io.pollMs,
487
+ });
605
488
  print({ until: waited.until, runs: waited.runs, timedOut: waited.timedOut });
606
489
  return waited.exitCode;
607
490
  }
@@ -617,85 +500,36 @@ async function log(cockpit, id, io, values) {
617
500
  });
618
501
  }
619
502
  async function status(cockpit, id, values, print) {
620
- const run = await getRun(cockpit, id);
621
- if (values.full) {
622
- print(run);
623
- return EXIT.ok;
624
- }
625
- const question = asksQuestion(run) ? await pendingQuestion(cockpit, id) : undefined;
626
- print({ ...projectStatus(run, threadUrl(cockpit, id), question), handoffUrl: handoffUrl(cockpit, id) });
503
+ print(await getTaskStatus(cockpit, { id, full: values.full === true }));
627
504
  return EXIT.ok;
628
505
  }
629
506
  async function list(cockpit, values, print) {
630
- const wanted = statuses(values.status);
631
- const limit = listLimit(values);
632
- const listed = (runs) => runs
633
- .filter((run) => workerParent(run) === undefined)
634
- .filter((run) => values.all || !run.archived)
635
- .filter((run) => !wanted || wanted.has(run.status))
636
- .sort((a, b) => b.createdAt.localeCompare(a.createdAt));
637
- // Without --all, archived runs are dropped above, so the windowed list (#864) has every row
638
- // this prints; --all needs every archived run there is.
639
- const summaries = () => requestRunSummaries(cockpit, undefined, values.all ? {} : { archived: 'recent' });
640
- const runs = values.full ? listed(await listRuns(cockpit)) : listed(await summaries());
641
- print({ runs: runs.slice(0, limit).map((run) => (values.full ? run : projectListRow(run))), total: runs.length });
507
+ print(await listTasks(cockpit, {
508
+ statuses: statuses(values.status),
509
+ limit: listLimit(values),
510
+ all: values.all === true,
511
+ full: values.full === true,
512
+ }));
642
513
  return EXIT.ok;
643
514
  }
644
- async function stop(cockpit, path, id, print) {
645
- const result = await request(cockpit, `${path}/cancel`, { body: {} });
646
- const answer = cancelResponseSchema.safeParse(result.data);
647
- if (result.status !== 200)
648
- refuse(result);
649
- if (!answer.success)
650
- invalidResponse('cancel');
651
- print({ id, cancelled: answer.data.cancelled });
515
+ async function stop(cockpit, id, print) {
516
+ print(await stopTask(cockpit, id));
652
517
  return EXIT.ok;
653
518
  }
654
- async function finish(cockpit, path, id, print) {
655
- const result = await request(cockpit, `${path}/finish`, { body: {} });
656
- if (result.status !== 200)
657
- refuse(result);
658
- if (!finishResponseSchema.safeParse(result.data).success)
659
- invalidResponse('finish');
660
- print({ id, finished: true });
519
+ async function finish(cockpit, id, print) {
520
+ print(await finishTask(cockpit, id));
661
521
  return EXIT.ok;
662
522
  }
663
- async function archive(cockpit, path, name, id, print) {
664
- const archived = name === 'archive';
665
- const result = await request(cockpit, `${path}/archive`, { body: { archived } });
666
- if (result.status !== 200)
667
- refuse(result);
668
- const run = runRecordSchema.safeParse(result.data);
669
- if (!run.success)
670
- invalidResponse('archive');
671
- print({ id: run.data.id, archived: run.data.archived === true });
523
+ async function archive(cockpit, name, id, print) {
524
+ print(await archiveTask(cockpit, id, name === 'archive'));
672
525
  return EXIT.ok;
673
526
  }
674
527
  async function archiveFinished(cockpit, print) {
675
- const result = await request(cockpit, '/runs/archive-finished', { method: 'POST' });
676
- if (result.status !== 200)
677
- refuse(result);
678
- const answer = archiveFinishedResponseSchema.safeParse(result.data);
679
- if (!answer.success)
680
- invalidResponse('archive-finished');
681
- print(answer.data);
528
+ print(await archiveFinishedTasks(cockpit));
682
529
  return EXIT.ok;
683
530
  }
684
- async function diff(cockpit, path, id, values, print) {
685
- if (values.stat) {
686
- const result = await request(cockpit, `${path}/changes`);
687
- if (result.status !== 200)
688
- refuse(result);
689
- const changes = changesPayloadSchema.safeParse(result.data);
690
- if (!changes.success)
691
- invalidResponse('changes');
692
- print({ id, stat: changes.data.stat, files: changes.data.files.map((file) => ({ path: file.path, status: file.status, adds: file.adds, dels: file.dels })) });
693
- return EXIT.ok;
694
- }
695
- const result = await request(cockpit, `${path}/diff`);
696
- if (result.status !== 200)
697
- refuse(result);
698
- print({ id, diff: typeof result.data === 'string' ? result.data : invalidResponse('diff') });
531
+ async function diff(cockpit, id, values, print) {
532
+ print(await getTaskDiff(cockpit, { id, stat: values.stat === true }));
699
533
  return EXIT.ok;
700
534
  }
701
535
  async function open(cockpit, io, id, values, print) {
@@ -709,7 +543,6 @@ async function open(cockpit, io, id, values, print) {
709
543
  /** One helper per operation, so this switch stays a dispatcher under the complexity limit. */
710
544
  async function execute(name, cockpit, io, values, positionals, text, print) {
711
545
  const id = positionals[0];
712
- const path = `/runs/${encodeURIComponent(id)}`;
713
546
  switch (name) {
714
547
  case 'start':
715
548
  return start(cockpit, io, values, text, print);
@@ -726,16 +559,16 @@ async function execute(name, cockpit, io, values, positionals, text, print) {
726
559
  case 'list':
727
560
  return list(cockpit, values, print);
728
561
  case 'stop':
729
- return stop(cockpit, path, id, print);
562
+ return stop(cockpit, id, print);
730
563
  case 'finish':
731
- return finish(cockpit, path, id, print);
564
+ return finish(cockpit, id, print);
732
565
  case 'archive':
733
566
  case 'unarchive':
734
- return archive(cockpit, path, name, id, print);
567
+ return archive(cockpit, name, id, print);
735
568
  case 'archive-finished':
736
569
  return archiveFinished(cockpit, print);
737
570
  case 'diff':
738
- return diff(cockpit, path, id, values, print);
571
+ return diff(cockpit, id, values, print);
739
572
  case 'open':
740
573
  return open(cockpit, io, id, values, print);
741
574
  default: