@hearsay-tools/squawk 0.18.0-dev.8183 → 0.18.0-dev.8192

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.
package/README.md CHANGED
@@ -451,6 +451,10 @@ See [Remote access (host Squawk on a server)](docs/remote-access.md).
451
451
 
452
452
  See [Reviewing task files](docs/task-files.md).
453
453
 
454
+ ## Plugins
455
+
456
+ See [Plugins](docs/plugins.md).
457
+
454
458
  ## Configuration (optional)
455
459
 
456
460
  See [Configuration (optional)](docs/configuration.md).
@@ -7,6 +7,10 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
7
7
  }[];
8
8
  isError: boolean;
9
9
  details: {
10
+ ok: false;
11
+ code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
12
+ message: string;
13
+ } | {
10
14
  ok: true;
11
15
  task: {
12
16
  id: string;
@@ -18,10 +22,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
18
22
  url?: string | undefined;
19
23
  };
20
24
  note: string;
21
- } | {
22
- ok: false;
23
- code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
24
- message: string;
25
25
  };
26
26
  }>;
27
27
  export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof callScheduleTask>>): {
@@ -31,6 +31,10 @@ export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof
31
31
  }[];
32
32
  isError: boolean;
33
33
  details: {
34
+ ok: false;
35
+ code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
36
+ message: string;
37
+ } | {
34
38
  ok: true;
35
39
  task: {
36
40
  id: string;
@@ -42,10 +46,6 @@ export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof
42
46
  url?: string | undefined;
43
47
  };
44
48
  note: string;
45
- } | {
46
- ok: false;
47
- code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
48
- message: string;
49
49
  };
50
50
  };
51
51
  export declare function invokeScheduledTasksTool(input: unknown): Promise<{
@@ -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;
@@ -54,18 +66,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
54
66
  offset?: string | undefined;
55
67
  };
56
68
  };
57
- } | {
58
- output: {
59
- error: string;
60
- code?: "invalid_input" | undefined;
61
- };
62
- outputFormat: "json";
63
- status: 400;
64
- input: {
65
- query: {
66
- offset?: string | undefined;
67
- };
68
- };
69
69
  };
70
70
  };
71
71
  } & {
@@ -652,6 +652,18 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
652
652
  } & {
653
653
  "/:workerId": {
654
654
  $get: {
655
+ output: {
656
+ error: string;
657
+ code?: "invalid_input" | undefined;
658
+ };
659
+ outputFormat: "json";
660
+ status: 400;
661
+ input: {
662
+ param: {
663
+ workerId: string;
664
+ };
665
+ };
666
+ } | {
655
667
  output: {
656
668
  workerId: string;
657
669
  settled: boolean;
@@ -776,7 +788,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
776
788
  workerId: string;
777
789
  };
778
790
  };
779
- } | {
791
+ };
792
+ };
793
+ } & {
794
+ "/:workerId/collect": {
795
+ $post: {
780
796
  output: {
781
797
  error: string;
782
798
  code?: "invalid_input" | undefined;
@@ -787,12 +803,10 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
787
803
  param: {
788
804
  workerId: string;
789
805
  };
806
+ } & {
807
+ json: Record<string, never>;
790
808
  };
791
- };
792
- };
793
- } & {
794
- "/:workerId/collect": {
795
- $post: {
809
+ } | {
796
810
  output: {
797
811
  workerId: string;
798
812
  parentRunId: string;
@@ -915,7 +929,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
915
929
  } & {
916
930
  json: Record<string, never>;
917
931
  };
918
- } | {
932
+ };
933
+ };
934
+ } & {
935
+ "/:workerId/steer": {
936
+ $post: {
919
937
  output: {
920
938
  error: string;
921
939
  code?: "invalid_input" | undefined;
@@ -927,13 +945,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
927
945
  workerId: string;
928
946
  };
929
947
  } & {
930
- json: Record<string, never>;
948
+ json: {
949
+ text: string;
950
+ };
931
951
  };
932
- };
933
- };
934
- } & {
935
- "/:workerId/steer": {
936
- $post: {
952
+ } | {
937
953
  output: {
938
954
  workerId: string;
939
955
  state: "delivered" | "queued";
@@ -949,7 +965,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
949
965
  text: string;
950
966
  };
951
967
  };
952
- } | {
968
+ };
969
+ };
970
+ } & {
971
+ "/:workerId/stop": {
972
+ $post: {
953
973
  output: {
954
974
  error: string;
955
975
  code?: "invalid_input" | undefined;
@@ -961,15 +981,9 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
961
981
  workerId: string;
962
982
  };
963
983
  } & {
964
- json: {
965
- text: string;
966
- };
984
+ json: Record<string, never>;
967
985
  };
968
- };
969
- };
970
- } & {
971
- "/:workerId/stop": {
972
- $post: {
986
+ } | {
973
987
  output: {
974
988
  workerId: string;
975
989
  state: "stopping" | "terminated";
@@ -983,7 +997,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
983
997
  } & {
984
998
  json: Record<string, never>;
985
999
  };
986
- } | {
1000
+ };
1001
+ };
1002
+ } & {
1003
+ "/:workerId/destroy": {
1004
+ $post: {
987
1005
  output: {
988
1006
  error: string;
989
1007
  code?: "invalid_input" | undefined;
@@ -995,13 +1013,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
995
1013
  workerId: string;
996
1014
  };
997
1015
  } & {
998
- json: Record<string, never>;
1016
+ json: {
1017
+ discardWork?: true | undefined;
1018
+ };
999
1019
  };
1000
- };
1001
- };
1002
- } & {
1003
- "/:workerId/destroy": {
1004
- $post: {
1020
+ } | {
1005
1021
  output: {
1006
1022
  workerId: string;
1007
1023
  state: "complete" | "incomplete";
@@ -1030,22 +1046,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
1030
1046
  discardWork?: true | undefined;
1031
1047
  };
1032
1048
  };
1033
- } | {
1034
- output: {
1035
- error: string;
1036
- code?: "invalid_input" | undefined;
1037
- };
1038
- outputFormat: "json";
1039
- status: 400;
1040
- input: {
1041
- param: {
1042
- workerId: string;
1043
- };
1044
- } & {
1045
- json: {
1046
- discardWork?: true | undefined;
1047
- };
1048
- };
1049
1049
  } | {
1050
1050
  output: {
1051
1051
  workerId: string;
@@ -1081,13 +1081,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
1081
1081
  "/:workerId/diff": {
1082
1082
  $get: {
1083
1083
  output: {
1084
- workerId: string;
1085
- baselineSha: string;
1086
- diff: string;
1087
- truncated: boolean;
1084
+ error: string;
1085
+ code?: "invalid_input" | undefined;
1088
1086
  };
1089
1087
  outputFormat: "json";
1090
- status: 200;
1088
+ status: 400;
1091
1089
  input: {
1092
1090
  param: {
1093
1091
  workerId: string;
@@ -1095,11 +1093,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
1095
1093
  };
1096
1094
  } | {
1097
1095
  output: {
1098
- error: string;
1099
- code?: "invalid_input" | undefined;
1096
+ workerId: string;
1097
+ baselineSha: string;
1098
+ diff: string;
1099
+ truncated: boolean;
1100
1100
  };
1101
1101
  outputFormat: "json";
1102
- status: 400;
1102
+ status: 200;
1103
1103
  input: {
1104
1104
  param: {
1105
1105
  workerId: string;
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ /** A requested reviewer, as either connection spells them. `login` covers `User` and `Bot`, `slug`
3
+ * covers `Team`; `reviewerKey` folds them into one comparable string. */
4
+ export declare const reviewerRefSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
5
+ __typename: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
+ login: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ slug: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ }, z.core.$strip>>>;
9
+ /** One reviewer as a comparable key, or `null` when GitHub named nobody we can match on — which
10
+ * must never compare equal to another unnamed reviewer, hence `null` rather than a shared "". */
11
+ export declare function reviewerKey(ref: z.infer<typeof reviewerRefSchema>): string | null;
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ /** A requested reviewer, as either connection spells them. `login` covers `User` and `Bot`, `slug`
3
+ * covers `Team`; `reviewerKey` folds them into one comparable string. */
4
+ export const reviewerRefSchema = z
5
+ .object({
6
+ __typename: z.string().nullish(),
7
+ login: z.string().nullish(),
8
+ slug: z.string().nullish(),
9
+ })
10
+ .nullish();
11
+ /** One reviewer as a comparable key, or `null` when GitHub named nobody we can match on — which
12
+ * must never compare equal to another unnamed reviewer, hence `null` rather than a shared "". */
13
+ export function reviewerKey(ref) {
14
+ const name = ref?.login ?? ref?.slug;
15
+ return name ? `${ref?.__typename ?? '?'}:${name}` : null;
16
+ }
17
+ //# sourceMappingURL=github-reviewer-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-reviewer-ref.js","sourceRoot":"","sources":["../../../src/server/forge/github-reviewer-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;0EAC0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAC3B,CAAC;KACD,OAAO,EAAE,CAAC;AAEb;kGACkG;AAClG,MAAM,UAAU,WAAW,CAAC,GAAsC;IAChE,MAAM,IAAI,GAAG,GAAG,EAAE,KAAK,IAAI,GAAG,EAAE,IAAI,CAAC;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC"}
@@ -10,6 +10,7 @@ import { z } from 'zod';
10
10
  import { githubRequestGate } from './github-request-gate.js';
11
11
  import { refStatusQuery } from './github-ref-status-query.js';
12
12
  import { mergedPullRequestChunk } from './github-merged-pr-chunk.js';
13
+ import { reviewerKey, reviewerRefSchema } from './github-reviewer-ref.js';
13
14
  import { gh, githubContext, parseOwnerName } from './github-cli.js';
14
15
  import { canonicalRepoRef, discoverRepoHandle, forgetRepoHandle, forgettingNameOnMiss, resolveRepoHandle, sharedRepoHandle } from './github-repo-handle.js';
15
16
  export { parseOwnerName } from './github-cli.js';
@@ -975,7 +976,7 @@ export function __clearCommentsCacheForTests() {
975
976
  // answer (an item or a confirmed absence) is cached, never an unavailable one.
976
977
  const itemCache = new Map();
977
978
  function itemCacheKey(repoRoot, kind, number) {
978
- return `${repoRoot}\0${kind}#${number}`;
979
+ return `${githubContext(repoRoot).key}\0${kind}#${number}`;
979
980
  }
980
981
  export function forgetGithubItem(repoRoot, kind, number) {
981
982
  itemCache.delete(itemCacheKey(repoRoot, kind, number));
@@ -1228,7 +1229,7 @@ function mockGithubCommentCounts(kind, numbers) {
1228
1229
  }
1229
1230
  return { available: true, counts };
1230
1231
  }
1231
- // Per-PR checks cache: keyed `repoRoot␀number`, same 60 s TTL as the list cache but BOUNDED. Lets
1232
+ // Per-PR checks cache: keyed `githubContext␀number`, same 60 s TTL as the list cache but BOUNDED. Lets
1232
1233
  // a repeated visible-window hydration within a minute serve cached glyphs instead of re-querying.
1233
1234
  const checksCache = new Map();
1234
1235
  const CHECKS_CACHE_MAX = 500;
@@ -1249,8 +1250,9 @@ export async function fetchGithubChecks(repoRoot, numbers) {
1249
1250
  const checks = {};
1250
1251
  const misses = [];
1251
1252
  const now = Date.now();
1253
+ const context = githubContext(repoRoot);
1252
1254
  for (const n of wanted) {
1253
- const hit = checksCache.get(`${repoRoot}\0${n}`);
1255
+ const hit = checksCache.get(`${context.key}\0${n}`);
1254
1256
  if (hit && now - hit.at < CACHE_MS)
1255
1257
  checks[n] = hit.glyph;
1256
1258
  else
@@ -1259,20 +1261,20 @@ export async function fetchGithubChecks(repoRoot, numbers) {
1259
1261
  if (misses.length === 0)
1260
1262
  return { available: true, checks };
1261
1263
  try {
1262
- const repoOut = await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner', '--jq', '.nameWithOwner']);
1264
+ const repoOut = await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner', '--jq', '.nameWithOwner'], undefined, undefined, context);
1263
1265
  const ownerName = parseOwnerName(repoOut);
1264
1266
  if (!ownerName)
1265
1267
  return { available: false, reason: 'repository handle unavailable' };
1266
1268
  const runGraphql = (query, variables) => {
1267
1269
  const args = ghGraphqlArgs(query, variables);
1268
- return gh(repoRoot, args);
1270
+ return gh(repoRoot, args, undefined, undefined, context);
1269
1271
  };
1270
1272
  const fetched = await fetchPrChecks(runGraphql, ownerName.owner, ownerName.name, misses);
1271
1273
  for (const n of misses) {
1272
1274
  // Absent (unknown/closed PR) caches as `null` so a nonexistent number isn't re-queried.
1273
1275
  const glyph = n in fetched ? fetched[n] : null;
1274
1276
  checks[n] = glyph;
1275
- checksCache.set(`${repoRoot}\0${n}`, { at: now, glyph });
1277
+ checksCache.set(`${context.key}\0${n}`, { at: now, glyph });
1276
1278
  }
1277
1279
  while (checksCache.size > CHECKS_CACHE_MAX) {
1278
1280
  const oldest = checksCache.keys().next().value;
@@ -1305,21 +1307,6 @@ function mockGithubChecks(numbers) {
1305
1307
  * contract rather than restated, because the cockpit caps its batches by the same number and a
1306
1308
  * client that guessed high would have every chip in a batch 400 instead of losing its tail. */
1307
1309
  export const GH_REF_STATUS_MAX = REFERENCE_STATUS_MAX;
1308
- /** A requested reviewer, as either connection spells them. `login` covers `User` and `Bot`, `slug`
1309
- * covers `Team`; `reviewerKey` folds them into one comparable string. */
1310
- const reviewerRefSchema = z
1311
- .object({
1312
- __typename: z.string().nullish(),
1313
- login: z.string().nullish(),
1314
- slug: z.string().nullish(),
1315
- })
1316
- .nullish();
1317
- /** One reviewer as a comparable key, or `null` when GitHub named nobody we can match on — which
1318
- * must never compare equal to another unnamed reviewer, hence `null` rather than a shared "". */
1319
- function reviewerKey(ref) {
1320
- const name = ref?.login ?? ref?.slug;
1321
- return name ? `${ref?.__typename ?? '?'}:${name}` : null;
1322
- }
1323
1310
  const ghRefStatusPrSchema = z
1324
1311
  .object({
1325
1312
  state: z.string(),
@@ -1949,7 +1936,7 @@ function mockGithubRefStatus(prs, issues) {
1949
1936
  */
1950
1937
  function commentsCacheKey(repoRoot, kind, number) {
1951
1938
  // NUL separator: cannot appear in a filesystem path, so roots can never alias.
1952
- return `${repoRoot}\0${kind}#${number}`;
1939
+ return `${githubContext(repoRoot).key}\0${kind}#${number}`;
1953
1940
  }
1954
1941
  function cachedGithubComments(key, refresh) {
1955
1942
  const hit = commentsCache.get(key);
@@ -2238,18 +2225,18 @@ function mockGithubComments(kind, number) {
2238
2225
  }
2239
2226
  // ---- the driver -------------------------------------------------------------
2240
2227
  /**
2241
- * Cached availability probe so `GET /api/health` never pays a full listing. Keyed by repo root:
2228
+ * Cached availability probe so `GET /api/health` never pays a full listing. Keyed by GitHub context (root, host, account):
2242
2229
  * every registered project reads its own slot, so the boot project's constant health refresh can't
2243
2230
  * evict another project's answer (a single slot made `GET /automations` flap between "still being
2244
- * checked" and available). One in-flight probe per root dedupes a burst of reads.
2231
+ * checked" and available). One in-flight probe per context dedupes a burst of reads.
2245
2232
  */
2246
2233
  const DETECT_CACHE_MAX = 64;
2247
2234
  const detectCache = new Map();
2248
2235
  const detectInflight = new Map();
2249
- async function probeGithub(repoRoot) {
2236
+ async function probeGithub(repoRoot, context) {
2250
2237
  let result;
2251
2238
  try {
2252
- await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner'], 5_000);
2239
+ await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner'], 5_000, undefined, context);
2253
2240
  result = { available: true };
2254
2241
  }
2255
2242
  catch (err) {
@@ -2261,8 +2248,8 @@ async function probeGithub(repoRoot) {
2261
2248
  : firstLine(message),
2262
2249
  };
2263
2250
  }
2264
- detectCache.delete(repoRoot); // re-insert so Map order tracks recency
2265
- detectCache.set(repoRoot, { at: Date.now(), result });
2251
+ detectCache.delete(context.key); // re-insert so Map order tracks recency
2252
+ detectCache.set(context.key, { at: Date.now(), result });
2266
2253
  while (detectCache.size > DETECT_CACHE_MAX) {
2267
2254
  const oldest = detectCache.keys().next().value;
2268
2255
  if (oldest === undefined)
@@ -2274,14 +2261,15 @@ async function probeGithub(repoRoot) {
2274
2261
  async function detectGithub(repoRoot) {
2275
2262
  if (productEnv('DRY_RUN') === '1')
2276
2263
  return { available: true };
2277
- const hit = detectCache.get(repoRoot);
2264
+ const context = githubContext(repoRoot);
2265
+ const hit = detectCache.get(context.key);
2278
2266
  if (hit && Date.now() - hit.at < CACHE_MS)
2279
2267
  return hit.result;
2280
- const pending = detectInflight.get(repoRoot);
2268
+ const pending = detectInflight.get(context.key);
2281
2269
  if (pending)
2282
2270
  return pending;
2283
- const probe = probeGithub(repoRoot).finally(() => detectInflight.delete(repoRoot));
2284
- detectInflight.set(repoRoot, probe);
2271
+ const probe = probeGithub(repoRoot, context).finally(() => detectInflight.delete(context.key));
2272
+ detectInflight.set(context.key, probe);
2285
2273
  return probe;
2286
2274
  }
2287
2275
  /**
@@ -2306,7 +2294,7 @@ export const HEALTH_AVAILABILITY_TTL_MS = 10 * 60_000;
2306
2294
  export function detectGithubCached(repoRoot) {
2307
2295
  if (productEnv('DRY_RUN') === '1')
2308
2296
  return { available: true };
2309
- const hit = detectCache.get(repoRoot);
2297
+ const hit = detectCache.get(githubContext(repoRoot).key);
2310
2298
  const cached = hit?.result ?? null;
2311
2299
  const fresh = hit !== undefined && Date.now() - hit.at < HEALTH_AVAILABILITY_TTL_MS;
2312
2300
  if (!fresh) {
@@ -2386,11 +2374,11 @@ export function evictGithubProjectCaches(repoRoot) {
2386
2374
  mergeStateCache.delete(key);
2387
2375
  });
2388
2376
  commentsCache.forEach((_value, key) => {
2389
- if (key.startsWith(`${repoRoot}\0`))
2377
+ if (key.startsWith(`${contextKey}\0`))
2390
2378
  commentsCache.delete(key);
2391
2379
  });
2392
2380
  itemCache.forEach((_value, key) => {
2393
- if (key.startsWith(`${repoRoot}\0`))
2381
+ if (key.startsWith(`${contextKey}\0`))
2394
2382
  itemCache.delete(key);
2395
2383
  });
2396
2384
  }