@hearsay-tools/squawk 0.18.0-dev.5842 → 0.18.0-dev.5850

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 (61) hide show
  1. package/README.md +1 -1
  2. package/dist/automations/automation-cli.js +5 -0
  3. package/dist/automations/automation-cli.js.map +1 -1
  4. package/dist/automations/github-baseline.js +2 -0
  5. package/dist/automations/github-baseline.js.map +1 -1
  6. package/dist/automations/github-repository.d.ts +22 -0
  7. package/dist/automations/github-repository.js +40 -0
  8. package/dist/automations/github-repository.js.map +1 -0
  9. package/dist/automations/scheduler.d.ts +2 -3
  10. package/dist/automations/scheduler.js +31 -11
  11. package/dist/automations/scheduler.js.map +1 -1
  12. package/dist/automations/service.d.ts +4 -0
  13. package/dist/automations/task-template.js +12 -2
  14. package/dist/automations/task-template.js.map +1 -1
  15. package/dist/ci-wait/controller.d.ts +4 -4
  16. package/dist/ci-wait/tools.d.ts +4 -4
  17. package/dist/contract/automation-storage.d.ts +4 -0
  18. package/dist/contract/automations.d.ts +26 -0
  19. package/dist/contract/index.js +22 -0
  20. package/dist/delegation/routes.d.ts +13 -13
  21. package/dist/delegation/transport.d.ts +71 -71
  22. package/dist/server/forge/github-cli.d.ts +14 -0
  23. package/dist/server/forge/github-cli.js +25 -0
  24. package/dist/server/forge/github-cli.js.map +1 -0
  25. package/dist/server/forge/github-repo-handle.d.ts +42 -0
  26. package/dist/server/forge/github-repo-handle.js +160 -0
  27. package/dist/server/forge/github-repo-handle.js.map +1 -0
  28. package/dist/server/forge/github.d.ts +11 -17
  29. package/dist/server/forge/github.js +22 -139
  30. package/dist/server/forge/github.js.map +1 -1
  31. package/dist/server/live-routes.d.ts +6 -6
  32. package/dist/server/server.d.ts +1546 -1538
  33. package/dist/server/server.js +7 -11
  34. package/dist/server/server.js.map +1 -1
  35. package/dist/voice/routes.d.ts +19 -19
  36. package/dist/workflows/run/wait-engine.d.ts +72 -72
  37. package/package.json +4 -4
  38. package/web/dist/assets/{activity-motion-2nE59DAT.js → activity-motion-BdGFmrw-.js} +1 -1
  39. package/web/dist/assets/{activity-route-R9lPc2jy.js → activity-route-1OFUVP3A.js} +1 -1
  40. package/web/dist/assets/{commit-diff-panel-BJyNYmCY.js → commit-diff-panel-BiNPMHC6.js} +1 -1
  41. package/web/dist/assets/{diff-D_9MtICR.js → diff-BHwQUS2W.js} +2 -2
  42. package/web/dist/assets/{diff-view-xRPxXHXl.js → diff-view-BBhxSIlf.js} +1 -1
  43. package/web/dist/assets/{git-toolbar-D9taioU5.js → git-toolbar-BnOaO_OH.js} +1 -1
  44. package/web/dist/assets/{github-bv_pBGc5.js → github-CXc8nroh.js} +1 -1
  45. package/web/dist/assets/{global-activity-route-QxTPDyx-.js → global-activity-route-Dt83uvZc.js} +1 -1
  46. package/web/dist/assets/{index-DgU3yYUl.js → index-B5LayM4y.js} +6 -6
  47. package/web/dist/assets/{preview-pane-connected-cD-MTiVN.js → preview-pane-connected-JHeCgq7I.js} +1 -1
  48. package/web/dist/assets/{repo-git-E_4Ighvg.js → repo-git-wEXDON29.js} +1 -1
  49. package/web/dist/assets/{report-reader-XVNQsXB4.js → report-reader-DJ_0htSx.js} +1 -1
  50. package/web/dist/assets/{reports-B_PVTBzP.js → reports-BIXmTBFJ.js} +1 -1
  51. package/web/dist/assets/{run-header-wm0gSs6X.js → run-header-Bgtlx-vc.js} +1 -1
  52. package/web/dist/assets/{skills-D2RLxUIc.js → skills-BJ2nSfyr.js} +1 -1
  53. package/web/dist/assets/{task-changes-DNtkfFzQ.js → task-changes-Dz0udwrE.js} +1 -1
  54. package/web/dist/assets/{task-commits-CivO-OrN.js → task-commits-5uILgm5M.js} +1 -1
  55. package/web/dist/assets/{task-files-dczkxV_G.js → task-files-DGZjTKSS.js} +1 -1
  56. package/web/dist/assets/{task-github-item-DKV4yrcf.js → task-github-item-npfGLu9C.js} +1 -1
  57. package/web/dist/assets/{task-thread-DIaTTGEF.js → task-thread-DnpkXb5P.js} +1 -1
  58. package/web/dist/assets/{thread-state-DIozHuHb.js → thread-state-BfrO2t7g.js} +1 -1
  59. package/web/dist/assets/{use-hand-to-agent-state-D58ayxI4.js → use-hand-to-agent-state-DyVB4IBv.js} +1 -1
  60. package/web/dist/assets/{workflows-YMEsGXeB.js → workflows-ByduCwgu.js} +1 -1
  61. package/web/dist/index.html +1 -1
@@ -646,6 +646,10 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
646
646
  };
647
647
  } | {
648
648
  output: {
649
+ ok: false;
650
+ code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
651
+ message: string;
652
+ } | {
649
653
  ok: true;
650
654
  task: {
651
655
  id: string;
@@ -657,10 +661,6 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
657
661
  url?: string | undefined;
658
662
  };
659
663
  note: string;
660
- } | {
661
- ok: false;
662
- code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
663
- message: string;
664
664
  };
665
665
  outputFormat: "json";
666
666
  status: import("hono/utils/http-status").ContentfulStatusCode;
@@ -783,6 +783,10 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
783
783
  }[];
784
784
  isError: boolean;
785
785
  details: {
786
+ ok: false;
787
+ code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
788
+ message: string;
789
+ } | {
786
790
  ok: true;
787
791
  task: {
788
792
  id: string;
@@ -794,10 +798,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
794
798
  url?: string | undefined;
795
799
  };
796
800
  note: string;
797
- } | {
798
- ok: false;
799
- code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
800
- message: string;
801
801
  };
802
802
  }>;
803
803
  export declare function invokeScheduledTasksTool(input: unknown): Promise<{
@@ -309,6 +309,8 @@ export declare const storedAutomationHistoryScanSchema: z.ZodObject<{
309
309
  }, z.core.$loose>>;
310
310
  }, z.core.$strip>;
311
311
  export declare const storedAutomationRuntimeStateSchema: z.ZodObject<{
312
+ lastError: z.ZodOptional<z.ZodString>;
313
+ lastErrorAt: z.ZodOptional<z.ZodString>;
312
314
  revision: z.ZodOptional<z.ZodNumber>;
313
315
  baselineAt: z.ZodOptional<z.ZodString>;
314
316
  armedAt: z.ZodOptional<z.ZodString>;
@@ -351,6 +353,8 @@ export declare const storedAutomationRuntimeStateSchema: z.ZodObject<{
351
353
  export declare const storedAutomationStateFileSchema: z.ZodObject<{
352
354
  version: z.ZodDefault<z.ZodLiteral<1>>;
353
355
  states: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
356
+ lastError: z.ZodOptional<z.ZodString>;
357
+ lastErrorAt: z.ZodOptional<z.ZodString>;
354
358
  revision: z.ZodOptional<z.ZodNumber>;
355
359
  baselineAt: z.ZodOptional<z.ZodString>;
356
360
  armedAt: z.ZodOptional<z.ZodString>;
@@ -269,7 +269,16 @@ export declare const automationHistoryScanSchema: z.ZodObject<{
269
269
  tieBreaker: z.ZodOptional<z.ZodString>;
270
270
  }, z.core.$strip>>;
271
271
  }, z.core.$strip>;
272
+ /** The longest `lastError` the scheduler stores. */
273
+ export declare const AUTOMATION_LAST_ERROR_MAX = 1000;
274
+ /** `github` kind: the error of the last failed check and when it failed, until a check succeeds. */
275
+ export declare const automationLastErrorShape: {
276
+ lastError: z.ZodOptional<z.ZodString>;
277
+ lastErrorAt: z.ZodOptional<z.ZodString>;
278
+ };
272
279
  export declare const automationRuntimeStateSchema: z.ZodObject<{
280
+ lastError: z.ZodOptional<z.ZodString>;
281
+ lastErrorAt: z.ZodOptional<z.ZodString>;
273
282
  revision: z.ZodOptional<z.ZodNumber>;
274
283
  baselineAt: z.ZodOptional<z.ZodString>;
275
284
  armedAt: z.ZodOptional<z.ZodString>;
@@ -310,6 +319,17 @@ export declare const automationRuntimeStateSchema: z.ZodObject<{
310
319
  }>>;
311
320
  }, z.core.$strip>;
312
321
  export type AutomationRuntimeState = z.infer<typeof automationRuntimeStateSchema>;
322
+ /** Consecutive failed checks after which the cockpit and `hsq automation list` show the error. */
323
+ export declare const AUTOMATION_FAILURE_NOTICE_AFTER = 3;
324
+ export interface AutomationFailureNotice {
325
+ consecutiveFailures: number;
326
+ lastError: string;
327
+ lastErrorAt?: string;
328
+ /** When the scheduler tries again. */
329
+ retryAt?: string;
330
+ }
331
+ /** The failure a GitHub automation shows, or undefined while fewer checks than the threshold failed in a row. */
332
+ export declare function automationFailureNotice(state: AutomationRuntimeState | undefined): AutomationFailureNotice | undefined;
313
333
  /** What one poll decided about one candidate. `baseline` and `preview` are bookkeeping rows: no
314
334
  * task was launched and none was meant to be. */
315
335
  export declare const automationLogResultSchema: z.ZodEnum<{
@@ -490,6 +510,8 @@ export declare const automationListEntrySchema: z.ZodObject<{
490
510
  createdAt: z.ZodString;
491
511
  updatedAt: z.ZodString;
492
512
  state: z.ZodOptional<z.ZodObject<{
513
+ lastError: z.ZodOptional<z.ZodString>;
514
+ lastErrorAt: z.ZodOptional<z.ZodString>;
493
515
  revision: z.ZodOptional<z.ZodNumber>;
494
516
  baselineAt: z.ZodOptional<z.ZodString>;
495
517
  armedAt: z.ZodOptional<z.ZodString>;
@@ -717,6 +739,8 @@ export declare const automationsResponseSchema: z.ZodObject<{
717
739
  createdAt: z.ZodString;
718
740
  updatedAt: z.ZodString;
719
741
  state: z.ZodOptional<z.ZodObject<{
742
+ lastError: z.ZodOptional<z.ZodString>;
743
+ lastErrorAt: z.ZodOptional<z.ZodString>;
720
744
  revision: z.ZodOptional<z.ZodNumber>;
721
745
  baselineAt: z.ZodOptional<z.ZodString>;
722
746
  armedAt: z.ZodOptional<z.ZodString>;
@@ -1167,6 +1191,8 @@ export declare const automationDetailResponseSchema: z.ZodObject<{
1167
1191
  updatedAt: z.ZodString;
1168
1192
  }, z.core.$strip>;
1169
1193
  state: z.ZodOptional<z.ZodObject<{
1194
+ lastError: z.ZodOptional<z.ZodString>;
1195
+ lastErrorAt: z.ZodOptional<z.ZodString>;
1170
1196
  revision: z.ZodOptional<z.ZodNumber>;
1171
1197
  baselineAt: z.ZodOptional<z.ZodString>;
1172
1198
  armedAt: z.ZodOptional<z.ZodString>;
@@ -4280,6 +4280,11 @@ var automationHistoryScanSchema = z28.object({
4280
4280
  event: z28.number().int().min(0).max(1e3),
4281
4281
  cursor: automationCursorSchema.optional()
4282
4282
  });
4283
+ var AUTOMATION_LAST_ERROR_MAX = 1e3;
4284
+ var automationLastErrorShape = {
4285
+ lastError: z28.string().max(AUTOMATION_LAST_ERROR_MAX).optional(),
4286
+ lastErrorAt: z28.string().datetime().optional()
4287
+ };
4283
4288
  var automationRuntimeStateSchema = z28.object({
4284
4289
  /** The definition revision this state belongs to; activation or history-policy changes re-arm. */
4285
4290
  revision: z28.number().optional(),
@@ -4300,9 +4305,21 @@ var automationRuntimeStateSchema = z28.object({
4300
4305
  etags: z28.record(z28.string(), z28.string()).optional(),
4301
4306
  backoffUntil: z28.string().optional(),
4302
4307
  consecutiveFailures: z28.number().optional(),
4308
+ ...automationLastErrorShape,
4303
4309
  /** `once` schedules: why it stopped without a task — its launch failed, or it started past its cutoff. */
4304
4310
  onceOutcome: z28.enum(["failed", "missed"]).optional()
4305
4311
  });
4312
+ var AUTOMATION_FAILURE_NOTICE_AFTER = 3;
4313
+ function automationFailureNotice(state) {
4314
+ const failures = state?.consecutiveFailures ?? 0;
4315
+ if (failures < AUTOMATION_FAILURE_NOTICE_AFTER || !state?.lastError) return void 0;
4316
+ return {
4317
+ consecutiveFailures: failures,
4318
+ lastError: state.lastError,
4319
+ ...state.lastErrorAt ? { lastErrorAt: state.lastErrorAt } : {},
4320
+ ...state.backoffUntil ? { retryAt: state.backoffUntil } : {}
4321
+ };
4322
+ }
4306
4323
  var automationLogResultSchema = z28.enum([
4307
4324
  "launched",
4308
4325
  "no-match",
@@ -5538,6 +5555,7 @@ var storedAutomationRuntimeStateSchema = z39.object({
5538
5555
  etags: z39.record(z39.string(), z39.string()).optional(),
5539
5556
  backoffUntil: z39.string().datetime().optional(),
5540
5557
  consecutiveFailures: z39.number().int().nonnegative().optional(),
5558
+ ...automationLastErrorShape,
5541
5559
  /** once schedule: it stopped without a task — the launch failed, or it started past its cutoff. */
5542
5560
  onceOutcome: z39.enum(["failed", "missed"]).optional()
5543
5561
  }).passthrough();
@@ -5992,6 +6010,8 @@ export {
5992
6010
  ASK_LIMITS,
5993
6011
  ATTENTION_RANK,
5994
6012
  ATTENTION_RUNGS,
6013
+ AUTOMATION_FAILURE_NOTICE_AFTER,
6014
+ AUTOMATION_LAST_ERROR_MAX,
5995
6015
  CI_WAIT_LIMITATION,
5996
6016
  CI_WAIT_RECEIPT_INSTRUCTION,
5997
6017
  CONTROL_LOCATIONS,
@@ -6152,10 +6172,12 @@ export {
6152
6172
  automationDetailResponseSchema,
6153
6173
  automationEditableSchema,
6154
6174
  automationEventSchema,
6175
+ automationFailureNotice,
6155
6176
  automationFiltersSchema,
6156
6177
  automationHistoryScanSchema,
6157
6178
  automationIdOf,
6158
6179
  automationKindSchema,
6180
+ automationLastErrorShape,
6159
6181
  automationListEntrySchema,
6160
6182
  automationListQuerySchema,
6161
6183
  automationLogQuerySchema,
@@ -82,15 +82,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
82
82
  "/discover": {
83
83
  $post: {
84
84
  output: {
85
- scope: "host-default-account";
86
- runners: {
87
- status: "connected" | "disconnected" | "not-installed" | "unknown";
88
- enabled?: boolean | undefined;
89
- hint?: string | undefined;
90
- authFailureId?: string | undefined;
91
- runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
92
- }[];
93
- } | {
94
85
  tasks: {
95
86
  id: string;
96
87
  title: string;
@@ -102,6 +93,15 @@ export declare function createDelegationRoutes(service: DelegationService, crede
102
93
  reason?: string | undefined;
103
94
  }[];
104
95
  nextOffset?: number | undefined;
96
+ } | {
97
+ scope: "host-default-account";
98
+ runners: {
99
+ status: "connected" | "disconnected" | "not-installed" | "unknown";
100
+ enabled?: boolean | undefined;
101
+ hint?: string | undefined;
102
+ authFailureId?: string | undefined;
103
+ runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
104
+ }[];
105
105
  } | {
106
106
  runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
107
107
  models: {
@@ -221,13 +221,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
221
221
  status: 200;
222
222
  input: {
223
223
  json: {
224
- requestIds: string[];
225
- mode?: "all" | "any" | "one" | undefined;
226
- timeoutSeconds?: number | undefined;
227
- } | {
228
224
  workerIds: string[];
229
225
  timeoutSeconds?: number | undefined;
230
226
  mode?: "all" | "any" | "one" | undefined;
227
+ } | {
228
+ requestIds: string[];
229
+ mode?: "all" | "any" | "one" | undefined;
230
+ timeoutSeconds?: number | undefined;
231
231
  } | {
232
232
  peerIds: string[];
233
233
  timeoutSeconds?: number | undefined;
@@ -2,6 +2,18 @@ import type { DelegationRoutes } from './routes.ts';
2
2
  export declare function createDelegationApp(routes: DelegationRoutes): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema | import("hono/types").MergeSchemaPath<{
3
3
  "/list": {
4
4
  $get: {
5
+ output: {
6
+ error: string;
7
+ code?: "invalid_input" | undefined;
8
+ };
9
+ outputFormat: "json";
10
+ status: 400;
11
+ input: {
12
+ query: {
13
+ offset?: string | undefined;
14
+ };
15
+ };
16
+ } | {
5
17
  output: {
6
18
  workers: {
7
19
  workerId: string;
@@ -39,24 +51,21 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
39
51
  offset?: string | undefined;
40
52
  };
41
53
  };
42
- } | {
43
- output: {
44
- error: string;
45
- code?: "invalid_input" | undefined;
46
- };
47
- outputFormat: "json";
48
- status: 400;
49
- input: {
50
- query: {
51
- offset?: string | undefined;
52
- };
53
- };
54
54
  };
55
55
  };
56
56
  } & {
57
57
  "/discover": {
58
58
  $post: {
59
59
  output: {
60
+ scope: "host-default-account";
61
+ runners: {
62
+ status: "connected" | "disconnected" | "not-installed" | "unknown";
63
+ enabled?: boolean | undefined;
64
+ hint?: string | undefined;
65
+ authFailureId?: string | undefined;
66
+ runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
67
+ }[];
68
+ } | {
60
69
  runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
61
70
  models: {
62
71
  id: string;
@@ -67,15 +76,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
67
76
  source: "cache" | "live" | "unavailable";
68
77
  stale: boolean;
69
78
  reason?: string | undefined;
70
- } | {
71
- scope: "host-default-account";
72
- runners: {
73
- status: "connected" | "disconnected" | "not-installed" | "unknown";
74
- enabled?: boolean | undefined;
75
- hint?: string | undefined;
76
- authFailureId?: string | undefined;
77
- runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
78
- }[];
79
79
  } | {
80
80
  tasks: {
81
81
  id: string;
@@ -588,6 +588,18 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
588
588
  } & {
589
589
  "/:workerId": {
590
590
  $get: {
591
+ output: {
592
+ error: string;
593
+ code?: "invalid_input" | undefined;
594
+ };
595
+ outputFormat: "json";
596
+ status: 400;
597
+ input: {
598
+ param: {
599
+ workerId: string;
600
+ };
601
+ };
602
+ } | {
591
603
  output: {
592
604
  workerId: string;
593
605
  parentRunId: string;
@@ -691,7 +703,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
691
703
  workerId: string;
692
704
  };
693
705
  };
694
- } | {
706
+ };
707
+ };
708
+ } & {
709
+ "/:workerId/collect": {
710
+ $post: {
695
711
  output: {
696
712
  error: string;
697
713
  code?: "invalid_input" | undefined;
@@ -702,12 +718,10 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
702
718
  param: {
703
719
  workerId: string;
704
720
  };
721
+ } & {
722
+ json: Record<string, never>;
705
723
  };
706
- };
707
- };
708
- } & {
709
- "/:workerId/collect": {
710
- $post: {
724
+ } | {
711
725
  output: {
712
726
  workerId: string;
713
727
  parentRunId: string;
@@ -809,7 +823,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
809
823
  } & {
810
824
  json: Record<string, never>;
811
825
  };
812
- } | {
826
+ };
827
+ };
828
+ } & {
829
+ "/:workerId/steer": {
830
+ $post: {
813
831
  output: {
814
832
  error: string;
815
833
  code?: "invalid_input" | undefined;
@@ -821,13 +839,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
821
839
  workerId: string;
822
840
  };
823
841
  } & {
824
- json: Record<string, never>;
842
+ json: {
843
+ text: string;
844
+ };
825
845
  };
826
- };
827
- };
828
- } & {
829
- "/:workerId/steer": {
830
- $post: {
846
+ } | {
831
847
  output: {
832
848
  workerId: string;
833
849
  state: "delivered" | "queued";
@@ -843,7 +859,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
843
859
  text: string;
844
860
  };
845
861
  };
846
- } | {
862
+ };
863
+ };
864
+ } & {
865
+ "/:workerId/stop": {
866
+ $post: {
847
867
  output: {
848
868
  error: string;
849
869
  code?: "invalid_input" | undefined;
@@ -855,15 +875,9 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
855
875
  workerId: string;
856
876
  };
857
877
  } & {
858
- json: {
859
- text: string;
860
- };
878
+ json: Record<string, never>;
861
879
  };
862
- };
863
- };
864
- } & {
865
- "/:workerId/stop": {
866
- $post: {
880
+ } | {
867
881
  output: {
868
882
  workerId: string;
869
883
  state: "stopping" | "terminated";
@@ -877,7 +891,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
877
891
  } & {
878
892
  json: Record<string, never>;
879
893
  };
880
- } | {
894
+ };
895
+ };
896
+ } & {
897
+ "/:workerId/destroy": {
898
+ $post: {
881
899
  output: {
882
900
  error: string;
883
901
  code?: "invalid_input" | undefined;
@@ -891,11 +909,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
891
909
  } & {
892
910
  json: Record<string, never>;
893
911
  };
894
- };
895
- };
896
- } & {
897
- "/:workerId/destroy": {
898
- $post: {
912
+ } | {
899
913
  output: {
900
914
  workerId: string;
901
915
  state: "complete" | "incomplete";
@@ -918,20 +932,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
918
932
  } & {
919
933
  json: Record<string, never>;
920
934
  };
921
- } | {
922
- output: {
923
- error: string;
924
- code?: "invalid_input" | undefined;
925
- };
926
- outputFormat: "json";
927
- status: 400;
928
- input: {
929
- param: {
930
- workerId: string;
931
- };
932
- } & {
933
- json: Record<string, never>;
934
- };
935
935
  } | {
936
936
  output: {
937
937
  workerId: string;
@@ -961,13 +961,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
961
961
  "/:workerId/diff": {
962
962
  $get: {
963
963
  output: {
964
- workerId: string;
965
- baselineSha: string;
966
- diff: string;
967
- truncated: boolean;
964
+ error: string;
965
+ code?: "invalid_input" | undefined;
968
966
  };
969
967
  outputFormat: "json";
970
- status: 200;
968
+ status: 400;
971
969
  input: {
972
970
  param: {
973
971
  workerId: string;
@@ -975,11 +973,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
975
973
  };
976
974
  } | {
977
975
  output: {
978
- error: string;
979
- code?: "invalid_input" | undefined;
976
+ workerId: string;
977
+ baselineSha: string;
978
+ diff: string;
979
+ truncated: boolean;
980
980
  };
981
981
  outputFormat: "json";
982
- status: 400;
982
+ status: 200;
983
983
  input: {
984
984
  param: {
985
985
  workerId: string;
@@ -0,0 +1,14 @@
1
+ export declare function githubContext(repoRoot: string): {
2
+ key: string;
3
+ env: {
4
+ GH_HOST: string | undefined;
5
+ GH_CONFIG_DIR: string | undefined;
6
+ };
7
+ };
8
+ export type GithubContext = ReturnType<typeof githubContext>;
9
+ export declare function gh(repoRoot: string, args: string[], timeout?: number, signal?: AbortSignal, context?: GithubContext): Promise<string>;
10
+ /** `owner/name` → `{ owner, name }`, or null when the handle isn't a clean two-part slug. */
11
+ export declare function parseOwnerName(nameWithOwner: string): {
12
+ owner: string;
13
+ name: string;
14
+ } | null;
@@ -0,0 +1,25 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ const exec = promisify(execFile);
4
+ // Keep account-directory and host selection attached to shared work. Never key by owner/name:
5
+ // separate local roots (including different remotes/accounts) must not share results.
6
+ export function githubContext(repoRoot) {
7
+ const env = { GH_HOST: process.env.GH_HOST, GH_CONFIG_DIR: process.env.GH_CONFIG_DIR };
8
+ return { key: JSON.stringify([repoRoot, env.GH_HOST, env.GH_CONFIG_DIR]), env };
9
+ }
10
+ export async function gh(repoRoot, args, timeout = 15_000, signal, context) {
11
+ const { stdout } = await exec('gh', args, {
12
+ cwd: repoRoot,
13
+ ...(context ? { env: { ...process.env, ...context.env } } : {}),
14
+ timeout,
15
+ maxBuffer: 50 * 1024 * 1024,
16
+ ...(signal ? { signal } : {}),
17
+ });
18
+ return stdout;
19
+ }
20
+ /** `owner/name` → `{ owner, name }`, or null when the handle isn't a clean two-part slug. */
21
+ export function parseOwnerName(nameWithOwner) {
22
+ const [owner, name, ...rest] = nameWithOwner.trim().split('/');
23
+ return owner && name && rest.length === 0 ? { owner, name } : null;
24
+ }
25
+ //# sourceMappingURL=github-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-cli.js","sourceRoot":"","sources":["../../../src/server/forge/github-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEjC,8FAA8F;AAC9F,sFAAsF;AACtF,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IACvF,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;AAClF,CAAC;AAGD,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,QAAgB,EAAE,IAAc,EAAE,OAAO,GAAG,MAAM,EAAE,MAAoB,EAAE,OAAuB;IACxH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE;QACxC,GAAG,EAAE,QAAQ;QACb,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,OAAO;QACP,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;QAC3B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,cAAc,CAAC,aAAqB;IAClD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/D,OAAO,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { RepoHandleDiscovery } from './repo-handle-discovery.ts';
2
+ type RepoHandle = {
3
+ owner: string;
4
+ name: string;
5
+ } | null;
6
+ /** Each subscriber owns a lease, not the subprocess. Only the last cancellation aborts it.
7
+ * Keep the rejecting promise intact so strict callers retain gh's diagnostic. */
8
+ export declare function sharedRepoHandle(repoRoot: string, signal?: AbortSignal, context?: {
9
+ key: string;
10
+ env: {
11
+ GH_HOST: string | undefined;
12
+ GH_CONFIG_DIR: string | undefined;
13
+ };
14
+ }): Promise<RepoHandle>;
15
+ /** Test-only: drop the memoized repo handles. */
16
+ export declare function __clearRepoHandleCacheForTests(): void;
17
+ /** Drop this root's memoized names after a read that named them failed or was redirected: the
18
+ * repository may have been renamed since, and the next lookup asks GitHub again. */
19
+ export declare function forgetRepoHandle(repoRoot: string): void;
20
+ /** A GitHub answer that can mean the name is no longer the repository's. */
21
+ export declare function isRepositoryNameMiss(error: unknown): boolean;
22
+ /** Runs a read that names the repository; when GitHub no longer knows that name, the next read
23
+ * asks for the current one. The error still reaches the caller. */
24
+ export declare function forgettingNameOnMiss<T>(repoRoot: string, read: () => Promise<T>): Promise<T>;
25
+ /** Share the existing memo with ordinary discovery, but retain failure classification (#102).
26
+ * An aborted owner must never publish its late result into this shared cache. */
27
+ export declare function discoverRepoHandle(repoRoot: string, signal?: AbortSignal): Promise<RepoHandleDiscovery>;
28
+ /** Compatible fail-open lookup for existing API and cold-index callers. */
29
+ export declare function resolveRepoHandle(repoRoot: string, signal?: AbortSignal): Promise<{
30
+ owner: string;
31
+ name: string;
32
+ } | null>;
33
+ type RepoRef = {
34
+ owner: string;
35
+ repo: string;
36
+ };
37
+ /** The name to read `remote`'s repository under: GitHub's current name for that repository, or
38
+ * `remote` itself when `gh` cannot say. It names `remote` explicitly: an unqualified `gh repo
39
+ * view` follows gh's default repository, which in a fork checkout is `upstream`. Failures are not
40
+ * memoized. Null only without a remote. */
41
+ export declare function canonicalRepoRef(repoRoot: string, remote: RepoRef | null): Promise<RepoRef | null>;
42
+ export {};