@hearsay-tools/squawk 0.19.0-pr4424.8662 → 0.19.0-pr4426.8671

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 (102) hide show
  1. package/dist/contract/index.js +46 -57
  2. package/dist/contract/repo-requests.d.ts +9 -1
  3. package/dist/contract/repo.d.ts +39 -2
  4. package/dist/contract/runs.d.ts +0 -50
  5. package/dist/contract/workspace-events.d.ts +0 -18
  6. package/dist/git-worktree.d.ts +9 -0
  7. package/dist/git-worktree.js +113 -3
  8. package/dist/git-worktree.js.map +1 -1
  9. package/dist/runs/retention.d.ts +6 -0
  10. package/dist/runs/retention.js +7 -3
  11. package/dist/runs/retention.js.map +1 -1
  12. package/dist/server/repo-routes.d.ts +40 -14
  13. package/dist/server/repo-routes.js +30 -15
  14. package/dist/server/repo-routes.js.map +1 -1
  15. package/dist/server/run-checkout.d.ts +1 -1
  16. package/dist/server/run-checkout.js +20 -7
  17. package/dist/server/run-checkout.js.map +1 -1
  18. package/dist/server/runs-routes.d.ts +0 -8
  19. package/dist/server/server.d.ts +112 -84
  20. package/dist/server/workspace-routes.d.ts +0 -8
  21. package/dist/server/worktree-size-cache.d.ts +11 -0
  22. package/dist/server/worktree-size-cache.js +3 -1
  23. package/dist/server/worktree-size-cache.js.map +1 -1
  24. package/package.json +4 -4
  25. package/web/dist/assets/{accounts-section-D18_j_dk.js → accounts-section-vKkfS7YX.js} +1 -1
  26. package/web/dist/assets/activity-motion-DQoK98JL.js +2 -0
  27. package/web/dist/assets/{activity-route-Ce9W4W-f.js → activity-route-snD0tuxO.js} +1 -1
  28. package/web/dist/assets/{agent-config-section-xix_WVUk.js → agent-config-section-DoleNTpD.js} +1 -1
  29. package/web/dist/assets/{agent-defaults-section-WuAWA5VV.js → agent-defaults-section-ysitxF4K.js} +1 -1
  30. package/web/dist/assets/{appearance-BDBv2_l3.js → appearance-DVdKOCpj.js} +1 -1
  31. package/web/dist/assets/{archive-on-merge-field-g87CG6RL.js → archive-on-merge-field-DrgP61Ey.js} +1 -1
  32. package/web/dist/assets/attention-CcwTbcYb.js +1 -0
  33. package/web/dist/assets/automations-route-FZreqZEC.js +2 -0
  34. package/web/dist/assets/commit-list-_lCNrPe9.js +1 -0
  35. package/web/dist/assets/diff-B5kvGFig.js +3 -0
  36. package/web/dist/assets/{diff-controls-BDgPvjow.js → diff-controls-BEdzHFBp.js} +1 -1
  37. package/web/dist/assets/{diff-view-9PhS8fdq.js → diff-view-Cn75jglS.js} +1 -1
  38. package/web/dist/assets/{file-preview-CP1tZNFe.js → file-preview-DOCPVTlT.js} +1 -1
  39. package/web/dist/assets/{folder-browser-DnSFycbU.js → folder-browser-DAam7eGA.js} +1 -1
  40. package/web/dist/assets/git-toolbar-CZVQtcyI.js +1 -0
  41. package/web/dist/assets/github-B4nythBc.js +1 -0
  42. package/web/dist/assets/{global-activity-route-C49d5h5u.js → global-activity-route-CRiXcL16.js} +1 -1
  43. package/web/dist/assets/image-preview-BHVPu_Ot.js +1 -0
  44. package/web/dist/assets/index-CFtjrhlQ.js +21 -0
  45. package/web/dist/assets/index-COOMjwiP.css +1 -0
  46. package/web/dist/assets/{label-o_DsEmPt.js → label-BqslTY3y.js} +1 -1
  47. package/web/dist/assets/{live-reads-Cgk2XbiP.js → live-reads-CYQJSB0x.js} +1 -1
  48. package/web/dist/assets/{markdown-BnSZEMnc.js → markdown-ZJPe40Kg.js} +1 -1
  49. package/web/dist/assets/{notifications-section-za02J1DT.js → notifications-section-BAxVmNvS.js} +1 -1
  50. package/web/dist/assets/{open-in-menu-Bzae69TK.js → open-in-menu-C8XOuvhZ.js} +1 -1
  51. package/web/dist/assets/{preview-pane-connected-BVEmmQK4.js → preview-pane-connected-o04x4ut2.js} +2 -2
  52. package/web/dist/assets/{project-location-D6riKh0Z.js → project-location-C5wL8Cmv.js} +1 -1
  53. package/web/dist/assets/{project-router-CZ89wg-5.js → project-router-Djen61eU.js} +1 -1
  54. package/web/dist/assets/{project-scope-context-DIcqj4jJ.js → project-scope-context-DBPcPWqF.js} +2 -2
  55. package/web/dist/assets/{projects-section-D9L-cFt3.js → projects-section-DjW4lZdo.js} +1 -1
  56. package/web/dist/assets/{prompt-templates-section-cncHF2ks.js → prompt-templates-section-BZ9kPTz8.js} +1 -1
  57. package/web/dist/assets/{queries-DZhNVAD_.js → queries-B27CAXOU.js} +1 -1
  58. package/web/dist/assets/{reference-chip-DSJSqjmO.js → reference-chip-BvcSKzIw.js} +1 -1
  59. package/web/dist/assets/{remote-settings-notice-CWx6h6w6.js → remote-settings-notice-B7px6Rjz.js} +1 -1
  60. package/web/dist/assets/repo-git-OhYxFr6e.js +1 -0
  61. package/web/dist/assets/{report-reader-CMPG4EK4.js → report-reader-CFDdbV9p.js} +1 -1
  62. package/web/dist/assets/reports-C_oLuf2Z.js +1 -0
  63. package/web/dist/assets/{resources-section-3lzzAec9.js → resources-section-DPKpkT00.js} +1 -1
  64. package/web/dist/assets/run-header-Cvjx6fLe.js +2 -0
  65. package/web/dist/assets/{select-DGO67nQY.js → select-DCgMFs3P.js} +1 -1
  66. package/web/dist/assets/{session-context-section-CB9rF99O.js → session-context-section-DUDyUnD6.js} +2 -2
  67. package/web/dist/assets/{settings-agent-picker-Bh4-edRr.js → settings-agent-picker-Dj9w9Rqy.js} +1 -1
  68. package/web/dist/assets/{settings-shell-DBTRfYCU.js → settings-shell-Dj0lpmcY.js} +1 -1
  69. package/web/dist/assets/{sidebar-section-hOn8GzBY.js → sidebar-section-CFausX6G.js} +1 -1
  70. package/web/dist/assets/{skills-BU854rKL.js → skills-C59hjIpW.js} +1 -1
  71. package/web/dist/assets/{tab-link-BGXFZZ_Z.js → tab-link-B7UoArdY.js} +1 -1
  72. package/web/dist/assets/task-changes-HqrNlmGK.js +1 -0
  73. package/web/dist/assets/task-commits-QHeItJLu.js +1 -0
  74. package/web/dist/assets/{task-files-SmzzmxxB.js → task-files-QFVIGaz9.js} +1 -1
  75. package/web/dist/assets/{task-github-item-iCZ0eiLZ.js → task-github-item-UKsVEOul.js} +1 -1
  76. package/web/dist/assets/{task-groups-DK0I9p71.js → task-groups-BwdcbABY.js} +1 -1
  77. package/web/dist/assets/{task-thread-Bw-PG7Ai.js → task-thread-CnGokWLH.js} +9 -9
  78. package/web/dist/assets/{tasks-table-BNFYIwtc.js → tasks-table-Y4sDrQge.js} +1 -1
  79. package/web/dist/assets/{thread-state-B5kYVb9n.js → thread-state-Cu4CGztL.js} +1 -1
  80. package/web/dist/assets/{toaster-0sM0sfWx.js → toaster-DXCOcLoK.js} +1 -1
  81. package/web/dist/assets/use-hand-to-agent-state-Cxrl8yfx.js +1 -0
  82. package/web/dist/assets/{workflows-ACB7knVY.js → workflows-Dl7hrImQ.js} +3 -3
  83. package/web/dist/assets/{workspace-tools-Bdf_pwjO.js → workspace-tools-ti_LJ2EA.js} +1 -1
  84. package/web/dist/assets/{worktrees-section-Bt7ugDds.js → worktrees-section-CpVznl7Q.js} +4 -4
  85. package/web/dist/index.html +15 -16
  86. package/web/dist/assets/activity-motion-rfh0S3Tt.js +0 -2
  87. package/web/dist/assets/attention-80jX8HhC.js +0 -1
  88. package/web/dist/assets/automations-route-xBxEBkzO.js +0 -2
  89. package/web/dist/assets/commit-list-DqQWo7ip.js +0 -1
  90. package/web/dist/assets/diff-li3FA8fd.js +0 -3
  91. package/web/dist/assets/diff-stat-U7DT4Ilj.js +0 -1
  92. package/web/dist/assets/git-toolbar-BNRvtTBV.js +0 -1
  93. package/web/dist/assets/github-BcA0SRdk.js +0 -1
  94. package/web/dist/assets/image-preview-2S3PEy8S.js +0 -1
  95. package/web/dist/assets/index-DAxuDJAo.css +0 -1
  96. package/web/dist/assets/index-yxMqB8jr.js +0 -21
  97. package/web/dist/assets/repo-git-C93L2DDG.js +0 -1
  98. package/web/dist/assets/reports-BqqlnpXb.js +0 -1
  99. package/web/dist/assets/run-header-CAik97v-.js +0 -2
  100. package/web/dist/assets/task-changes-B8QI0qnp.js +0 -1
  101. package/web/dist/assets/task-commits-DlljyZdW.js +0 -1
  102. package/web/dist/assets/use-hand-to-agent-state-BQ_gY7RN.js +0 -1
@@ -1482,20 +1482,6 @@ var continuationMessageSchema = queuedMessageSchema.extend({
1482
1482
  }).optional()
1483
1483
  });
1484
1484
 
1485
- // ../contract/src/usage-limit-hold.ts
1486
- function isUsageLimitHold(run) {
1487
- return run.status === "waiting" && run.autoResumeAt !== void 0;
1488
- }
1489
- function usageLimitHoldOf(run) {
1490
- if (!isUsageLimitHold(run)) return void 0;
1491
- return {
1492
- reason: run.autoResumeReason ?? "usage-limit",
1493
- resumeAt: run.autoResumeAt,
1494
- ...run.autoResumeAttempts === void 0 ? {} : { attempts: run.autoResumeAttempts },
1495
- ...run.error === void 0 ? {} : { error: run.error.slice(0, 2e3) }
1496
- };
1497
- }
1498
-
1499
1485
  // ../contract/src/waits.ts
1500
1486
  import { z as z21 } from "zod";
1501
1487
 
@@ -1628,6 +1614,20 @@ var ciWaitReceiptSchema = ciPrIdentitySchema.extend({
1628
1614
  phase: ciWaitSchema.shape.phase
1629
1615
  }).strict();
1630
1616
 
1617
+ // ../contract/src/usage-limit-hold.ts
1618
+ function isUsageLimitHold(run) {
1619
+ return run.status === "waiting" && run.autoResumeAt !== void 0;
1620
+ }
1621
+ function usageLimitHoldOf(run) {
1622
+ if (!isUsageLimitHold(run)) return void 0;
1623
+ return {
1624
+ reason: run.autoResumeReason ?? "usage-limit",
1625
+ resumeAt: run.autoResumeAt,
1626
+ ...run.autoResumeAttempts === void 0 ? {} : { attempts: run.autoResumeAttempts },
1627
+ ...run.error === void 0 ? {} : { error: run.error.slice(0, 2e3) }
1628
+ };
1629
+ }
1630
+
1631
1631
  // ../contract/src/wait-limits.ts
1632
1632
  var WAIT_LIMIT = 16;
1633
1633
  var LAST_WAITS_LIMIT = 16;
@@ -2419,10 +2419,6 @@ var apiRunSchema = runRecordSchema.extend({
2419
2419
  cliHandoff: z23.literal(false).optional(),
2420
2420
  usage: processUsageSchema.optional()
2421
2421
  });
2422
- var runStatePreviewSchema = z23.object({
2423
- kind: z23.enum(["ask", "permission", "review", "error"]),
2424
- text: z23.string().min(1).max(240)
2425
- });
2426
2422
  var runSummarySchema = z23.object({
2427
2423
  id: z23.string(),
2428
2424
  title: z23.string(),
@@ -2525,8 +2521,6 @@ var runSummarySchema = z23.object({
2525
2521
  * labels a delegated peer by the agent actually running it, which can differ from `runner`. */
2526
2522
  currentStepBackend: runnerSchema.optional(),
2527
2523
  error: z23.string().optional(),
2528
- /** Concise 1-line ask, permission, review, or error preview for urgent/failed task rows. */
2529
- statePreview: runStatePreviewSchema.optional(),
2530
2524
  /** Present while the run's isolated worktree exists — the breadcrumb says "Isolated worktree". */
2531
2525
  worktreePath: z23.string().optional()
2532
2526
  });
@@ -2568,37 +2562,6 @@ var SUMMARY_OPTIONAL_KEYS = [
2568
2562
  "error",
2569
2563
  "worktreePath"
2570
2564
  ];
2571
- var STATE_PREVIEW_MAX = 240;
2572
- function oneLinePreview(raw) {
2573
- if (typeof raw !== "string") return "";
2574
- const collapsed = raw.replace(/\s+/g, " ").trim();
2575
- if (collapsed.length <= STATE_PREVIEW_MAX) return collapsed;
2576
- return `${collapsed.slice(0, STATE_PREVIEW_MAX - 1).trimEnd()}\u2026`;
2577
- }
2578
- function deriveRunStatePreview(run, waitingOn) {
2579
- if (!run.archived) {
2580
- if (run.hasPendingPermission) return { kind: "permission", text: "Permission requested" };
2581
- if (waitingOn?.kind === "human") {
2582
- const openHuman = (Array.isArray(run.waits) ? run.waits : []).filter(
2583
- (wait) => Boolean(wait) && typeof wait === "object" && wait.phase === "open" && wait.kind === "human"
2584
- );
2585
- const question = openHuman.find((wait) => Array.isArray(wait.questions) && wait.questions.length > 0)?.questions?.[0]?.question;
2586
- const text = oneLinePreview(question);
2587
- if (text) return { kind: "ask", text };
2588
- const budget = openHuman.some((wait) => wait.via === "budget");
2589
- return { kind: "ask", text: budget ? "Automatic wakes used up" : "Waiting for your reply" };
2590
- }
2591
- if (run.status === "review") {
2592
- const text = oneLinePreview(run.doneAccepted?.summary);
2593
- return { kind: "review", text: text || "Ready for review" };
2594
- }
2595
- }
2596
- if (run.status === "failed" && !isUsageLimitHold(run)) {
2597
- const text = oneLinePreview(run.error);
2598
- if (text) return { kind: "error", text };
2599
- }
2600
- return void 0;
2601
- }
2602
2565
  function toRunSummary(run) {
2603
2566
  const summary = {
2604
2567
  id: run.id,
@@ -2620,8 +2583,6 @@ function toRunSummary(run) {
2620
2583
  }
2621
2584
  const waitingOn = computeWaitingOn({ ...run, delegation: withRootLedger(summary.delegation, run.delegation) });
2622
2585
  if (waitingOn) summary.waitingOn = waitingOn;
2623
- const statePreview = deriveRunStatePreview(run, waitingOn);
2624
- if (statePreview) summary.statePreview = statePreview;
2625
2586
  if (hasResolvedWait(run)) summary.waitWakePending = true;
2626
2587
  if (run.usage) summary.usage = run.usage;
2627
2588
  const automationId = automationIdOf(run);
@@ -3106,6 +3067,22 @@ var worktreeEntrySchema = z24.discriminatedUnion("type", [
3106
3067
  content: z24.string().optional()
3107
3068
  })
3108
3069
  ]);
3070
+ var worktreeReclaimBlockerSchema = z24.discriminatedUnion("kind", [
3071
+ z24.object({
3072
+ kind: z24.literal("dirty"),
3073
+ uncommittedFiles: z24.number().int().min(1),
3074
+ detachedHead: z24.boolean()
3075
+ }),
3076
+ z24.object({
3077
+ kind: z24.literal("detached-head")
3078
+ }),
3079
+ z24.object({
3080
+ kind: z24.literal("submodules")
3081
+ }),
3082
+ z24.object({
3083
+ kind: z24.literal("invalid")
3084
+ })
3085
+ ]);
3109
3086
  var worktreeInfoSchema = z24.object({
3110
3087
  runId: z24.string(),
3111
3088
  title: z24.string(),
@@ -3114,7 +3091,8 @@ var worktreeInfoSchema = z24.object({
3114
3091
  sizeBytes: z24.number().nullable(),
3115
3092
  finishedAt: z24.string().nullable(),
3116
3093
  reclaimable: z24.boolean(),
3117
- pastKeep: z24.boolean()
3094
+ pastKeep: z24.boolean(),
3095
+ reclaimBlocker: worktreeReclaimBlockerSchema.nullable()
3118
3096
  });
3119
3097
  var worktreesResponseSchema = z24.object({
3120
3098
  worktrees: z24.array(worktreeInfoSchema),
@@ -6184,7 +6162,18 @@ import { z as z52 } from "zod";
6184
6162
  var gitCommitSchema = z52.object({
6185
6163
  message: z52.string().trim().min(1, "must not be empty").max(5e3)
6186
6164
  });
6187
- var reclaimBodySchema = z52.object({}).passthrough();
6165
+ var reclaimWorktreeBodySchema = z52.object({
6166
+ discardWork: z52.boolean().optional()
6167
+ });
6168
+ var reclaimBodySchema = z52.union([
6169
+ z52.object({
6170
+ discardWork: z52.literal(true),
6171
+ runIds: z52.array(z52.string().min(1)).min(1)
6172
+ }),
6173
+ z52.object({
6174
+ discardWork: z52.literal(false).optional()
6175
+ })
6176
+ ]);
6188
6177
  var repoBranchSchema = z52.object({
6189
6178
  name: z52.string().trim().min(1).max(200),
6190
6179
  from: z52.string().trim().min(1).max(200).optional()
@@ -6646,7 +6635,6 @@ export {
6646
6635
  deleteRunResponseSchema,
6647
6636
  deleteWorkflowResponseSchema,
6648
6637
  deriveAttention,
6649
- deriveRunStatePreview,
6650
6638
  deriveWebhookState,
6651
6639
  diffStatSchema,
6652
6640
  discoveredRunnerSchema,
@@ -6875,6 +6863,7 @@ export {
6875
6863
  queuedMessageSchema,
6876
6864
  reclaimBodySchema,
6877
6865
  reclaimRunParamsSchema,
6866
+ reclaimWorktreeBodySchema,
6878
6867
  reclaimWorktreeResponseSchema,
6879
6868
  reclaimWorktreesResponseSchema,
6880
6869
  refNumberFromUrl,
@@ -6936,7 +6925,6 @@ export {
6936
6925
  runPullRequestSchema,
6937
6926
  runRecordSchema,
6938
6927
  runRelationshipsSchema,
6939
- runStatePreviewSchema,
6940
6928
  runStatusSchema,
6941
6929
  runSummariesQuerySchema,
6942
6930
  runSummarySchema,
@@ -7142,6 +7130,7 @@ export {
7142
7130
  worktreeEntrySchema,
7143
7131
  worktreeFilesQuerySchema,
7144
7132
  worktreeInfoSchema,
7133
+ worktreeReclaimBlockerSchema,
7145
7134
  worktreeSetupConfigSchema,
7146
7135
  worktreesResponseSchema,
7147
7136
  writableAutomationTask,
@@ -2,7 +2,15 @@ import { z } from 'zod';
2
2
  export declare const gitCommitSchema: z.ZodObject<{
3
3
  message: z.ZodString;
4
4
  }, z.core.$strip>;
5
- export declare const reclaimBodySchema: z.ZodObject<{}, z.core.$loose>;
5
+ export declare const reclaimWorktreeBodySchema: z.ZodObject<{
6
+ discardWork: z.ZodOptional<z.ZodBoolean>;
7
+ }, z.core.$strip>;
8
+ export declare const reclaimBodySchema: z.ZodUnion<readonly [z.ZodObject<{
9
+ discardWork: z.ZodLiteral<true>;
10
+ runIds: z.ZodArray<z.ZodString>;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ discardWork: z.ZodOptional<z.ZodLiteral<false>>;
13
+ }, z.core.$strip>]>;
6
14
  export declare const repoBranchSchema: z.ZodObject<{
7
15
  name: z.ZodString;
8
16
  from: z.ZodOptional<z.ZodString>;
@@ -453,10 +453,25 @@ export declare const worktreeEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
453
453
  content: z.ZodOptional<z.ZodString>;
454
454
  }, z.core.$strip>], "type">;
455
455
  export type WorktreeEntry = z.infer<typeof worktreeEntrySchema>;
456
+ /** Why a finished worktree cannot be reclaimed cleanly without discarding work. */
457
+ export declare const worktreeReclaimBlockerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
458
+ kind: z.ZodLiteral<"dirty">;
459
+ uncommittedFiles: z.ZodNumber;
460
+ detachedHead: z.ZodBoolean;
461
+ }, z.core.$strip>, z.ZodObject<{
462
+ kind: z.ZodLiteral<"detached-head">;
463
+ }, z.core.$strip>, z.ZodObject<{
464
+ kind: z.ZodLiteral<"submodules">;
465
+ }, z.core.$strip>, z.ZodObject<{
466
+ kind: z.ZodLiteral<"invalid">;
467
+ }, z.core.$strip>], "kind">;
468
+ export type WorktreeReclaimBlocker = z.infer<typeof worktreeReclaimBlockerSchema>;
456
469
  /** One materialized task worktree in the management panel (#483). `sizeBytes` is null when `du`
457
470
  * is unavailable (Windows / missing). `reclaimable` = finished, has a directory, not yet
458
- * reclaimed (retention's rule). `pastKeep` = reclaimable AND outside the newest `keep`, i.e.
459
- * exactly the rows a "Reclaim now" would take; a reclaimable row that is not past it is kept. */
471
+ * reclaimed (retention's rule). `pastKeep` = reclaimable AND outside the newest `keep`.
472
+ * `reclaimBlocker` is non-null when a clean reclaim would refuse the checkout (uncommitted files,
473
+ * detached HEAD with no keeping ref, or an unregistered/broken directory); explicit discard can
474
+ * still reclaim its directory while keeping the branch. */
460
475
  export declare const worktreeInfoSchema: z.ZodObject<{
461
476
  runId: z.ZodString;
462
477
  title: z.ZodString;
@@ -474,6 +489,17 @@ export declare const worktreeInfoSchema: z.ZodObject<{
474
489
  finishedAt: z.ZodNullable<z.ZodString>;
475
490
  reclaimable: z.ZodBoolean;
476
491
  pastKeep: z.ZodBoolean;
492
+ reclaimBlocker: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
493
+ kind: z.ZodLiteral<"dirty">;
494
+ uncommittedFiles: z.ZodNumber;
495
+ detachedHead: z.ZodBoolean;
496
+ }, z.core.$strip>, z.ZodObject<{
497
+ kind: z.ZodLiteral<"detached-head">;
498
+ }, z.core.$strip>, z.ZodObject<{
499
+ kind: z.ZodLiteral<"submodules">;
500
+ }, z.core.$strip>, z.ZodObject<{
501
+ kind: z.ZodLiteral<"invalid">;
502
+ }, z.core.$strip>], "kind">>;
477
503
  }, z.core.$strip>;
478
504
  export type WorktreeInfo = z.infer<typeof worktreeInfoSchema>;
479
505
  /** `GET /api/v1/worktrees` (#483): the worktrees on disk, their total size (null when any
@@ -496,6 +522,17 @@ export declare const worktreesResponseSchema: z.ZodObject<{
496
522
  finishedAt: z.ZodNullable<z.ZodString>;
497
523
  reclaimable: z.ZodBoolean;
498
524
  pastKeep: z.ZodBoolean;
525
+ reclaimBlocker: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
526
+ kind: z.ZodLiteral<"dirty">;
527
+ uncommittedFiles: z.ZodNumber;
528
+ detachedHead: z.ZodBoolean;
529
+ }, z.core.$strip>, z.ZodObject<{
530
+ kind: z.ZodLiteral<"detached-head">;
531
+ }, z.core.$strip>, z.ZodObject<{
532
+ kind: z.ZodLiteral<"submodules">;
533
+ }, z.core.$strip>, z.ZodObject<{
534
+ kind: z.ZodLiteral<"invalid">;
535
+ }, z.core.$strip>], "kind">>;
499
536
  }, z.core.$strip>>;
500
537
  totalBytes: z.ZodNullable<z.ZodNumber>;
501
538
  keep: z.ZodNumber;
@@ -1,5 +1,4 @@
1
1
  import { z } from 'zod';
2
- import { type WaitingOn } from './waits.ts';
3
2
  export { runStatusSchema, type RunStatus, stepStatusSchema, type StepStatus, stepKindSchema, type StepKind } from './run-status.ts';
4
3
  /**
5
4
  * The RUNS family of `/api/v1` — a task's record, its lifecycle mutations, and the artifacts
@@ -4326,17 +4325,6 @@ export type ApiRun = z.infer<typeof apiRunSchema>;
4326
4325
  * `toRunSummary` below is the only projection from a record to this shape. The route, the index
4327
4326
  * and the cockpit's stream patches all go through it, so a list and its stream cannot disagree.
4328
4327
  */
4329
- /** Concise 1-line urgent or outcome preview carried on list summaries (hearsay-tools/squawk#4377). */
4330
- export declare const runStatePreviewSchema: z.ZodObject<{
4331
- kind: z.ZodEnum<{
4332
- ask: "ask";
4333
- error: "error";
4334
- permission: "permission";
4335
- review: "review";
4336
- }>;
4337
- text: z.ZodString;
4338
- }, z.core.$strip>;
4339
- export type RunStatePreview = z.infer<typeof runStatePreviewSchema>;
4340
4328
  export declare const runSummarySchema: z.ZodObject<{
4341
4329
  id: z.ZodString;
4342
4330
  title: z.ZodString;
@@ -4491,15 +4479,6 @@ export declare const runSummarySchema: z.ZodObject<{
4491
4479
  currentStepId: z.ZodOptional<z.ZodString>;
4492
4480
  currentStepBackend: z.ZodOptional<z.ZodString>;
4493
4481
  error: z.ZodOptional<z.ZodString>;
4494
- statePreview: z.ZodOptional<z.ZodObject<{
4495
- kind: z.ZodEnum<{
4496
- ask: "ask";
4497
- error: "error";
4498
- permission: "permission";
4499
- review: "review";
4500
- }>;
4501
- text: z.ZodString;
4502
- }, z.core.$strip>>;
4503
4482
  worktreePath: z.ZodOptional<z.ZodString>;
4504
4483
  }, z.core.$strip>;
4505
4484
  export type RunSummary = z.infer<typeof runSummarySchema>;
@@ -4662,21 +4641,10 @@ export declare const runIndexEntrySchema: z.ZodObject<{
4662
4641
  currentStepId: z.ZodOptional<z.ZodString>;
4663
4642
  currentStepBackend: z.ZodOptional<z.ZodString>;
4664
4643
  error: z.ZodOptional<z.ZodString>;
4665
- statePreview: z.ZodOptional<z.ZodObject<{
4666
- kind: z.ZodEnum<{
4667
- ask: "ask";
4668
- error: "error";
4669
- permission: "permission";
4670
- review: "review";
4671
- }>;
4672
- text: z.ZodString;
4673
- }, z.core.$strip>>;
4674
4644
  worktreePath: z.ZodOptional<z.ZodString>;
4675
4645
  projectId: z.ZodString;
4676
4646
  }, z.core.$strip>;
4677
4647
  export type RunIndexEntry = z.infer<typeof runIndexEntrySchema>;
4678
- /** Derive a concise 1-line preview for urgent (`Needs you`) or failed runs without reading transcripts. */
4679
- export declare function deriveRunStatePreview(run: Pick<RunRecord, 'status' | 'archived' | 'hasPendingPermission' | 'waits' | 'doneAccepted' | 'error' | 'autoResumeAt'>, waitingOn: WaitingOn | undefined): RunStatePreview | undefined;
4680
4648
  /**
4681
4649
  * The one projection from a run record to its list row (#817). Optional keys are copied only when
4682
4650
  * present, so the wire never carries an `undefined` the schema calls absent; `delegation` goes
@@ -4914,15 +4882,6 @@ export declare const archivedRunsResponseSchema: z.ZodObject<{
4914
4882
  currentStepId: z.ZodOptional<z.ZodString>;
4915
4883
  currentStepBackend: z.ZodOptional<z.ZodString>;
4916
4884
  error: z.ZodOptional<z.ZodString>;
4917
- statePreview: z.ZodOptional<z.ZodObject<{
4918
- kind: z.ZodEnum<{
4919
- ask: "ask";
4920
- error: "error";
4921
- permission: "permission";
4922
- review: "review";
4923
- }>;
4924
- text: z.ZodString;
4925
- }, z.core.$strip>>;
4926
4885
  worktreePath: z.ZodOptional<z.ZodString>;
4927
4886
  }, z.core.$strip>>;
4928
4887
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -5092,15 +5051,6 @@ export declare const runsSearchResponseSchema: z.ZodObject<{
5092
5051
  currentStepId: z.ZodOptional<z.ZodString>;
5093
5052
  currentStepBackend: z.ZodOptional<z.ZodString>;
5094
5053
  error: z.ZodOptional<z.ZodString>;
5095
- statePreview: z.ZodOptional<z.ZodObject<{
5096
- kind: z.ZodEnum<{
5097
- ask: "ask";
5098
- error: "error";
5099
- permission: "permission";
5100
- review: "review";
5101
- }>;
5102
- text: z.ZodString;
5103
- }, z.core.$strip>>;
5104
5054
  worktreePath: z.ZodOptional<z.ZodString>;
5105
5055
  projectId: z.ZodString;
5106
5056
  }, z.core.$strip>>;
@@ -177,15 +177,6 @@ export declare const workspaceRunSummaryEventSchema: z.ZodObject<{
177
177
  currentStepId: z.ZodOptional<z.ZodString>;
178
178
  currentStepBackend: z.ZodOptional<z.ZodString>;
179
179
  error: z.ZodOptional<z.ZodString>;
180
- statePreview: z.ZodOptional<z.ZodObject<{
181
- kind: z.ZodEnum<{
182
- ask: "ask";
183
- error: "error";
184
- permission: "permission";
185
- review: "review";
186
- }>;
187
- text: z.ZodString;
188
- }, z.core.$strip>>;
189
180
  worktreePath: z.ZodOptional<z.ZodString>;
190
181
  }, z.core.$strip>;
191
182
  relationships: z.ZodString;
@@ -376,15 +367,6 @@ export declare const runsIndexResponseSchema: z.ZodObject<{
376
367
  currentStepId: z.ZodOptional<z.ZodString>;
377
368
  currentStepBackend: z.ZodOptional<z.ZodString>;
378
369
  error: z.ZodOptional<z.ZodString>;
379
- statePreview: z.ZodOptional<z.ZodObject<{
380
- kind: z.ZodEnum<{
381
- ask: "ask";
382
- error: "error";
383
- permission: "permission";
384
- review: "review";
385
- }>;
386
- text: z.ZodString;
387
- }, z.core.$strip>>;
388
370
  worktreePath: z.ZodOptional<z.ZodString>;
389
371
  projectId: z.ZodString;
390
372
  }, z.core.$strip>>;
@@ -1,3 +1,4 @@
1
+ import type { WorktreeReclaimBlocker } from './contract/index.js';
1
2
  import { type LiveIndexCheck, type DiffRefusal } from './git-private-index.ts';
2
3
  import { type WorktreeGitResult } from './git-worktree-lock.ts';
3
4
  /** One worktree per task (spec 006). Only createWorktree throws; its caller reports failure. */
@@ -55,6 +56,14 @@ export type RemoveWorktreeOptions = {
55
56
  assertCurrent?: () => void;
56
57
  };
57
58
  export declare function removeWorktree(repoRoot: string, worktreePath: string, branch?: string, opts?: RemoveWorktreeOptions): Promise<void>;
59
+ /**
60
+ * Inspect whether a finished worktree directory would be refused by a clean reclaim
61
+ * (`removeCleanWorktree`): uncommitted files, a detached HEAD with no branch/remote ref holding
62
+ * its commit, initialized submodules, or an unregistered/broken directory (missing `.git`).
63
+ * Returns `null` when clean and ref-backed (or when the directory no longer exists).
64
+ * Best-effort: never throws.
65
+ */
66
+ export declare function inspectWorktreeReclaimBlocker(repoRoot: string, worktreePath: string): Promise<WorktreeReclaimBlocker | null>;
58
67
  /**
59
68
  * Whole-branch committed, uncommitted and untracked diff against the merge-base. Preserve this
60
69
  * anchor for the protected text endpoint and conservative settlement checks.
@@ -3,7 +3,7 @@ import { projectPaths, isFallbackProjectPath } from './project-paths.js';
3
3
  import { git } from './git-command.js';
4
4
  import { ownedWorkspaceSchema } from './contract/index.js';
5
5
  import { existsSync, realpathSync } from 'node:fs';
6
- import { lstat, mkdir, readdir, readFile, rm, rmdir } from 'node:fs/promises';
6
+ import { chmod, lstat, mkdir, readdir, readFile, rm, rmdir } from 'node:fs/promises';
7
7
  import { basename, dirname, join, resolve } from 'node:path';
8
8
  import { resolveTaskDiffBase } from './git-diff-base.js';
9
9
  import { withPrivateIndex } from './git-private-index.js';
@@ -406,7 +406,117 @@ async function runBeforeWorktreeRemove(opts) {
406
406
  await opts?.beforeRemove?.().catch(() => undefined);
407
407
  opts?.assertCurrent?.();
408
408
  }
409
+ /** Count entries in `git status --porcelain=v1 -z` output, skipping rename/copy source paths. */
410
+ function countPorcelainEntries(stdout) {
411
+ const fields = stdout.split('\0');
412
+ let files = 0;
413
+ for (let i = 0; i < fields.length; i++) {
414
+ const entry = fields[i];
415
+ if (entry.length < 4)
416
+ continue;
417
+ files++;
418
+ if (/[RC]/.test(entry.slice(0, 2)))
419
+ i++;
420
+ }
421
+ return files;
422
+ }
423
+ /** True only when `worktreePath` is its own Git worktree root (not walking up to `repoRoot`). */
424
+ async function isWorktreeRoot(worktreePath, runGitFn) {
425
+ const top = await runGitFn(worktreePath, ['rev-parse', '--show-toplevel']);
426
+ return top.ok && canonicalPath(top.stdout.trim()) === canonicalPath(worktreePath);
427
+ }
428
+ /** True when Git's unforced `worktree remove` would refuse this worktree for submodules:
429
+ * either the worktree's admin `modules` directory exists (even after `git submodule deinit`,
430
+ * matching Git's `validate_no_submodules`) or a tracked gitlink (`160000`) directory is non-empty. */
431
+ async function hasWorktreeSubmodules(worktreePath) {
432
+ const modules = await git(worktreePath, ['rev-parse', '--path-format=absolute', '--git-path', 'modules']);
433
+ if (modules.ok && modules.stdout.trim()) {
434
+ const info = await lstat(modules.stdout.trim()).catch(() => undefined);
435
+ if (info?.isDirectory())
436
+ return true;
437
+ }
438
+ const listed = await git(worktreePath, ['--no-optional-locks', 'ls-files', '-s', '-z']);
439
+ if (!listed.ok)
440
+ return false;
441
+ for (const entry of listed.stdout.split('\0')) {
442
+ if (!entry.startsWith('160000 '))
443
+ continue;
444
+ const tab = entry.indexOf('\t');
445
+ if (tab < 0)
446
+ continue;
447
+ const contents = await readdir(join(worktreePath, entry.slice(tab + 1))).catch(() => []);
448
+ if (contents.length > 0)
449
+ return true;
450
+ }
451
+ return false;
452
+ }
453
+ /**
454
+ * Inspect whether a finished worktree directory would be refused by a clean reclaim
455
+ * (`removeCleanWorktree`): uncommitted files, a detached HEAD with no branch/remote ref holding
456
+ * its commit, initialized submodules, or an unregistered/broken directory (missing `.git`).
457
+ * Returns `null` when clean and ref-backed (or when the directory no longer exists).
458
+ * Best-effort: never throws.
459
+ */
460
+ export async function inspectWorktreeReclaimBlocker(repoRoot, worktreePath) {
461
+ if (!existsSync(worktreePath))
462
+ return null;
463
+ if (!(await isWorktreeRoot(worktreePath, git)))
464
+ return { kind: 'invalid' };
465
+ const head = await git(worktreePath, ['rev-parse', '--verify', '--quiet', 'HEAD^{commit}']);
466
+ const sha = head.stdout.trim();
467
+ if (!head.ok || !sha)
468
+ return { kind: 'invalid' };
469
+ const status = await git(worktreePath, ['--no-optional-locks', 'status', '--porcelain=v1', '-z', '--untracked-files=normal']);
470
+ if (!status.ok)
471
+ return { kind: 'invalid' };
472
+ const uncommittedFiles = countPorcelainEntries(status.stdout);
473
+ const sym = await git(worktreePath, ['symbolic-ref', '-q', 'HEAD']);
474
+ let detachedHead = false;
475
+ if (!sym.ok || !sym.stdout.trim().startsWith('refs/heads/')) {
476
+ const kept = await git(repoRoot, ['for-each-ref', '--contains', sha, '--count=1', '--format=%(refname)', 'refs/heads', 'refs/remotes']);
477
+ if (!kept.ok)
478
+ return { kind: 'invalid' };
479
+ detachedHead = kept.stdout.trim() === '';
480
+ }
481
+ if (uncommittedFiles > 0)
482
+ return { kind: 'dirty', uncommittedFiles, detachedHead };
483
+ if (detachedHead)
484
+ return { kind: 'detached-head' };
485
+ if (await hasWorktreeSubmodules(worktreePath))
486
+ return { kind: 'submodules' };
487
+ return null;
488
+ }
489
+ /** Make directories writable so POSIX unlink can remove entries inside read-only fixtures.
490
+ * Never chmod regular files: hard-linked files (such as pnpm node_modules) share their inode
491
+ * mode with paths outside this worktree. */
492
+ async function makeTreeWritable(dir) {
493
+ await chmod(dir, 0o700).catch(() => undefined);
494
+ const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
495
+ for (const entry of entries) {
496
+ if (entry.isSymbolicLink())
497
+ continue;
498
+ if (entry.isDirectory())
499
+ await makeTreeWritable(join(dir, entry.name));
500
+ }
501
+ }
502
+ async function removeTreeAllowingReadOnly(worktreePath) {
503
+ try {
504
+ await rm(worktreePath, { recursive: true, force: true });
505
+ }
506
+ catch (err) {
507
+ const code = err?.code;
508
+ if (code !== 'EACCES' && code !== 'EPERM')
509
+ return;
510
+ const info = await lstat(worktreePath).catch(() => undefined);
511
+ if (!info || info.isSymbolicLink() || !info.isDirectory())
512
+ return;
513
+ await makeTreeWritable(worktreePath);
514
+ await rm(worktreePath, { recursive: true, force: true }).catch(() => undefined);
515
+ }
516
+ }
409
517
  async function removeCleanWorktree(repoRoot, worktreePath, protection, git, beforeRemove) {
518
+ if (!(await isWorktreeRoot(worktreePath, git)))
519
+ return;
410
520
  const head = await git(worktreePath, ['rev-parse', '--verify', '--quiet', 'HEAD^{commit}']);
411
521
  const sha = head.stdout.trim();
412
522
  if (!head.ok || !sha)
@@ -430,14 +540,14 @@ async function removeCleanWorktree(repoRoot, worktreePath, protection, git, befo
430
540
  }
431
541
  async function forceRemoveWorktree(repoRoot, worktreePath, branch, reclaimOwnedDirectory, protection, git, beforeRemove) {
432
542
  await beforeRemove();
433
- await git(repoRoot, ['worktree', 'remove', '--force', worktreePath]);
543
+ await git(repoRoot, ['worktree', 'remove', '--force', '--force', worktreePath]);
434
544
  // Owned-path reclaim must not `rm` a receipt path that is no longer a git
435
545
  // worktree — the directory may have been replaced with unrelated files.
436
546
  // For owned resources Git already removed the exact checkout. Never recursively delete a
437
547
  // path recreated after that operation (possibly by another execution/controller).
438
548
  if (reclaimOwnedDirectory && protection.paths.has(worktreePath))
439
549
  return;
440
- await rm(worktreePath, { recursive: true, force: true }).catch(() => undefined);
550
+ await removeTreeAllowingReadOnly(worktreePath);
441
551
  if (protection.paths.size === 0)
442
552
  await git(repoRoot, ['worktree', 'prune']);
443
553
  if (branch)