@hearsay-tools/squawk 0.18.0-dev.7694 → 0.18.0-dev.7703
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/dist/ci-wait/controller.d.ts +4 -4
- package/dist/ci-wait/tools.d.ts +4 -4
- package/dist/core/backend-detect.d.ts +8 -0
- package/dist/core/backend-detect.js +65 -0
- package/dist/core/backend-detect.js.map +1 -1
- package/dist/delegation/routes.d.ts +14 -14
- package/dist/delegation/transport.d.ts +15 -15
- package/dist/server/backend-checks.d.ts +29 -0
- package/dist/server/backend-checks.js +53 -0
- package/dist/server/backend-checks.js.map +1 -0
- package/dist/server/forge/github-ref-status-query.d.ts +5 -0
- package/dist/server/forge/github-ref-status-query.js +11 -0
- package/dist/server/forge/github-ref-status-query.js.map +1 -0
- package/dist/server/forge/github.d.ts +9 -1
- package/dist/server/forge/github.js +11 -12
- package/dist/server/forge/github.js.map +1 -1
- package/dist/server/git-dir-stamp.d.ts +35 -0
- package/dist/server/git-dir-stamp.js +158 -0
- package/dist/server/git-dir-stamp.js.map +1 -0
- package/dist/server/git.d.ts +7 -1
- package/dist/server/git.js +70 -6
- package/dist/server/git.js.map +1 -1
- package/dist/server/server.d.ts +332 -332
- package/dist/server/server.js +13 -23
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/package.json +4 -4
|
@@ -1006,6 +1006,10 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
1006
1006
|
};
|
|
1007
1007
|
} | {
|
|
1008
1008
|
output: {
|
|
1009
|
+
ok: false;
|
|
1010
|
+
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
1011
|
+
message: string;
|
|
1012
|
+
} | {
|
|
1009
1013
|
ok: true;
|
|
1010
1014
|
task: {
|
|
1011
1015
|
id: string;
|
|
@@ -1017,10 +1021,6 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
1017
1021
|
url?: string | undefined;
|
|
1018
1022
|
};
|
|
1019
1023
|
note: string;
|
|
1020
|
-
} | {
|
|
1021
|
-
ok: false;
|
|
1022
|
-
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
1023
|
-
message: string;
|
|
1024
1024
|
};
|
|
1025
1025
|
outputFormat: "json";
|
|
1026
1026
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
package/dist/ci-wait/tools.d.ts
CHANGED
|
@@ -263,10 +263,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
263
263
|
}[];
|
|
264
264
|
isError: boolean;
|
|
265
265
|
details: {
|
|
266
|
-
ok: false;
|
|
267
|
-
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
268
|
-
message: string;
|
|
269
|
-
} | {
|
|
270
266
|
ok: true;
|
|
271
267
|
task: {
|
|
272
268
|
id: string;
|
|
@@ -278,6 +274,10 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
278
274
|
url?: string | undefined;
|
|
279
275
|
};
|
|
280
276
|
note: string;
|
|
277
|
+
} | {
|
|
278
|
+
ok: false;
|
|
279
|
+
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
280
|
+
message: string;
|
|
281
281
|
};
|
|
282
282
|
}>;
|
|
283
283
|
export declare function invokeScheduledTasksTool(input: unknown): Promise<{
|
|
@@ -14,6 +14,14 @@ export interface BackendCheck {
|
|
|
14
14
|
* shows the hints for the rest.
|
|
15
15
|
*/
|
|
16
16
|
export declare function detectEnvironment(): Promise<BackendCheck[]>;
|
|
17
|
+
/**
|
|
18
|
+
* A signature of what `detectEnvironment` would see, read from file metadata only: where each
|
|
19
|
+
* probed executable resolves on PATH and the file behind it, the `gh` login file and the dry-run
|
|
20
|
+
* switch. Installing, removing or upgrading a CLI, `gh auth login`/`logout` and a `gh` token in the
|
|
21
|
+
* environment change it. It starts no process, so a caller can check it often and probe only on a
|
|
22
|
+
* change (hearsay-tools/squawk#3658).
|
|
23
|
+
*/
|
|
24
|
+
export declare function environmentStamp(env?: NodeJS.ProcessEnv): Promise<string>;
|
|
17
25
|
/**
|
|
18
26
|
* Probe one runner's CLI, as its definition describes it (`RunnerDetection`): an override key or
|
|
19
27
|
* the PATH name, a `--version` call, and the definition's hints.
|
|
@@ -2,6 +2,10 @@ import { productIdentity } from '../home/identity.js';
|
|
|
2
2
|
import { registeredRunners } from './runner-registry.js';
|
|
3
3
|
import { productEnv } from './product-env.js';
|
|
4
4
|
import { execFile } from 'node:child_process';
|
|
5
|
+
import { createHash } from 'node:crypto';
|
|
6
|
+
import { constants } from 'node:fs';
|
|
7
|
+
import { access, realpath, stat } from 'node:fs/promises';
|
|
8
|
+
import { delimiter, isAbsolute, join } from 'node:path';
|
|
5
9
|
import { promisify } from 'node:util';
|
|
6
10
|
import { runGit } from '../git-command.js';
|
|
7
11
|
const exec = promisify(execFile);
|
|
@@ -15,6 +19,67 @@ const exec = promisify(execFile);
|
|
|
15
19
|
export async function detectEnvironment() {
|
|
16
20
|
return Promise.all([...registeredRunners().map((runner) => probeRunner(runner.id, runner.detection)), probeGh(), probeGit()]);
|
|
17
21
|
}
|
|
22
|
+
/** The executables `detectEnvironment` starts, as each probe names them. */
|
|
23
|
+
function probedBinaries() {
|
|
24
|
+
return [...registeredRunners().map(({ detection }) => detection.binOverride() ?? detection.binary), 'gh', 'git'];
|
|
25
|
+
}
|
|
26
|
+
/** The file a PATH lookup of `bin` finds, followed through symlinks, with its identity; `-` when none. */
|
|
27
|
+
async function binarySignature(bin, env) {
|
|
28
|
+
const names = process.platform === 'win32'
|
|
29
|
+
? ['', ...(env.PATHEXT ?? '.EXE;.CMD;.BAT').split(';')].map((ext) => bin + ext.toLowerCase())
|
|
30
|
+
: [bin];
|
|
31
|
+
const dirs = bin.includes('/') || isAbsolute(bin) ? [''] : (env.PATH ?? '').split(delimiter).filter(Boolean);
|
|
32
|
+
for (const dir of dirs) {
|
|
33
|
+
for (const name of names) {
|
|
34
|
+
const path = dir ? join(dir, name) : name;
|
|
35
|
+
try {
|
|
36
|
+
const s = await stat(path, { bigint: true });
|
|
37
|
+
if (!s.isFile())
|
|
38
|
+
continue;
|
|
39
|
+
// The process lookup skips a file it may not execute and goes on along PATH.
|
|
40
|
+
if (process.platform !== 'win32')
|
|
41
|
+
await access(path, constants.X_OK);
|
|
42
|
+
const target = await realpath(path);
|
|
43
|
+
const t = await stat(target, { bigint: true });
|
|
44
|
+
return `${path}>${target}:${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}:${t.mode}`;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// not here: the lookup goes on to the next PATH entry
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return '-';
|
|
52
|
+
}
|
|
53
|
+
/** The variables `gh` reads before its hosts file: tokens and the host they belong to. */
|
|
54
|
+
function ghEnv(env) {
|
|
55
|
+
return [env.GH_TOKEN, env.GITHUB_TOKEN, env.GH_ENTERPRISE_TOKEN, env.GITHUB_ENTERPRISE_TOKEN, env.GH_HOST, env.GH_CONFIG_DIR]
|
|
56
|
+
.map((value) => value ?? null);
|
|
57
|
+
}
|
|
58
|
+
/** The file `gh auth login` and `gh auth logout` rewrite. */
|
|
59
|
+
function ghHostsFile(env) {
|
|
60
|
+
if (env.GH_CONFIG_DIR)
|
|
61
|
+
return join(env.GH_CONFIG_DIR, 'hosts.yml');
|
|
62
|
+
if (env.XDG_CONFIG_HOME)
|
|
63
|
+
return join(env.XDG_CONFIG_HOME, 'gh', 'hosts.yml');
|
|
64
|
+
if (process.platform === 'win32' && env.AppData)
|
|
65
|
+
return join(env.AppData, 'GitHub CLI', 'hosts.yml');
|
|
66
|
+
return env.HOME ? join(env.HOME, '.config', 'gh', 'hosts.yml') : undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A signature of what `detectEnvironment` would see, read from file metadata only: where each
|
|
70
|
+
* probed executable resolves on PATH and the file behind it, the `gh` login file and the dry-run
|
|
71
|
+
* switch. Installing, removing or upgrading a CLI, `gh auth login`/`logout` and a `gh` token in the
|
|
72
|
+
* environment change it. It starts no process, so a caller can check it often and probe only on a
|
|
73
|
+
* change (hearsay-tools/squawk#3658).
|
|
74
|
+
*/
|
|
75
|
+
export async function environmentStamp(env = process.env) {
|
|
76
|
+
const binaries = await Promise.all(probedBinaries().map(async (bin) => `${bin}=${await binarySignature(bin, env)}`));
|
|
77
|
+
const hostsFile = ghHostsFile(env);
|
|
78
|
+
const hosts = hostsFile ? await stat(hostsFile, { bigint: true }).then((s) => `${s.dev}:${s.ino}:${s.size}:${s.mtimeNs}:${s.ctimeNs}`, () => '-') : '-';
|
|
79
|
+
// `gh` prefers these over its hosts file; only a digest enters the stamp, never a token.
|
|
80
|
+
const tokens = createHash('sha256').update(JSON.stringify(ghEnv(env))).digest('hex');
|
|
81
|
+
return [...binaries, `gh-hosts=${hosts}`, `gh-env=${tokens}`, `dry-run=${productEnv('DRY_RUN') ?? ''}`].join('\n');
|
|
82
|
+
}
|
|
18
83
|
/** Banner spelling follows the release identity; switch-off output stays stable. */
|
|
19
84
|
function dryRunVersion() {
|
|
20
85
|
return `mock (${productIdentity().envPrefix}DRY_RUN=1)`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-detect.js","sourceRoot":"","sources":["../../src/core/backend-detect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,IAAI,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I,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACpE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IAChE,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5E,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,8BAA8B;IAChC,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC;AAClD,CAAC"}
|
|
@@ -91,6 +91,16 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
91
91
|
"/discover": {
|
|
92
92
|
$post: {
|
|
93
93
|
output: {
|
|
94
|
+
scope: "host-default-account";
|
|
95
|
+
runners: {
|
|
96
|
+
requiresAccountHome?: boolean | undefined;
|
|
97
|
+
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
98
|
+
enabled?: boolean | undefined;
|
|
99
|
+
hint?: string | undefined;
|
|
100
|
+
authFailureId?: string | undefined;
|
|
101
|
+
runner: string;
|
|
102
|
+
}[];
|
|
103
|
+
} | {
|
|
94
104
|
tasks: {
|
|
95
105
|
id: string;
|
|
96
106
|
title: string;
|
|
@@ -102,16 +112,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
102
112
|
reason?: string | undefined;
|
|
103
113
|
}[];
|
|
104
114
|
nextOffset?: number | undefined;
|
|
105
|
-
} | {
|
|
106
|
-
scope: "host-default-account";
|
|
107
|
-
runners: {
|
|
108
|
-
requiresAccountHome?: boolean | undefined;
|
|
109
|
-
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
110
|
-
enabled?: boolean | undefined;
|
|
111
|
-
hint?: string | undefined;
|
|
112
|
-
authFailureId?: string | undefined;
|
|
113
|
-
runner: string;
|
|
114
|
-
}[];
|
|
115
115
|
} | {
|
|
116
116
|
runner: string;
|
|
117
117
|
models: {
|
|
@@ -232,13 +232,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
232
232
|
status: 200;
|
|
233
233
|
input: {
|
|
234
234
|
json: {
|
|
235
|
-
requestIds: string[];
|
|
236
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
237
|
-
timeoutSeconds?: number | undefined;
|
|
238
|
-
} | {
|
|
239
235
|
workerIds: string[];
|
|
240
236
|
timeoutSeconds?: number | undefined;
|
|
241
237
|
mode?: "all" | "any" | "one" | undefined;
|
|
238
|
+
} | {
|
|
239
|
+
requestIds: string[];
|
|
240
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
241
|
+
timeoutSeconds?: number | undefined;
|
|
242
242
|
} | {
|
|
243
243
|
peerIds: string[];
|
|
244
244
|
timeoutSeconds?: number | undefined;
|
|
@@ -66,17 +66,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
66
66
|
"/discover": {
|
|
67
67
|
$post: {
|
|
68
68
|
output: {
|
|
69
|
-
runner: string;
|
|
70
|
-
models: {
|
|
71
|
-
id: string;
|
|
72
|
-
label: string;
|
|
73
|
-
description: string;
|
|
74
|
-
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
75
|
-
}[];
|
|
76
|
-
source: "cache" | "live" | "unavailable";
|
|
77
|
-
stale: boolean;
|
|
78
|
-
reason?: string | undefined;
|
|
79
|
-
} | {
|
|
80
69
|
scope: "host-default-account";
|
|
81
70
|
runners: {
|
|
82
71
|
requiresAccountHome?: boolean | undefined;
|
|
@@ -98,6 +87,17 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
98
87
|
reason?: string | undefined;
|
|
99
88
|
}[];
|
|
100
89
|
nextOffset?: number | undefined;
|
|
90
|
+
} | {
|
|
91
|
+
runner: string;
|
|
92
|
+
models: {
|
|
93
|
+
id: string;
|
|
94
|
+
label: string;
|
|
95
|
+
description: string;
|
|
96
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
97
|
+
}[];
|
|
98
|
+
source: "cache" | "live" | "unavailable";
|
|
99
|
+
stale: boolean;
|
|
100
|
+
reason?: string | undefined;
|
|
101
101
|
};
|
|
102
102
|
outputFormat: "json";
|
|
103
103
|
status: 200;
|
|
@@ -207,13 +207,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
207
207
|
status: 200;
|
|
208
208
|
input: {
|
|
209
209
|
json: {
|
|
210
|
-
requestIds: string[];
|
|
211
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
212
|
-
timeoutSeconds?: number | undefined;
|
|
213
|
-
} | {
|
|
214
210
|
workerIds: string[];
|
|
215
211
|
timeoutSeconds?: number | undefined;
|
|
216
212
|
mode?: "all" | "any" | "one" | undefined;
|
|
213
|
+
} | {
|
|
214
|
+
requestIds: string[];
|
|
215
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
216
|
+
timeoutSeconds?: number | undefined;
|
|
217
217
|
} | {
|
|
218
218
|
peerIds: string[];
|
|
219
219
|
timeoutSeconds?: number | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BackendCheck } from '../core/backend-detect.ts';
|
|
2
|
+
/** How often a read may compare the environment stamp. The stamp is file metadata only. */
|
|
3
|
+
export declare const BACKEND_RECHECK_MS = 5000;
|
|
4
|
+
/**
|
|
5
|
+
* The longest a detection result is kept while its stamp holds. Most installs and upgrades change
|
|
6
|
+
* the stamp; a version manager's shim (asdf, mise) does not, because the shim file stays the same
|
|
7
|
+
* while the tool behind it changes. This ceiling bounds how long such a version string can lag.
|
|
8
|
+
*/
|
|
9
|
+
export declare const BACKEND_MAX_AGE_MS: number;
|
|
10
|
+
export interface BackendChecks {
|
|
11
|
+
/**
|
|
12
|
+
* The last detected checks. Waits for the stamp read (file metadata), never for the detection
|
|
13
|
+
* it may start: a cold read answers `[]` while the CLIs are still probed.
|
|
14
|
+
*/
|
|
15
|
+
read(): Promise<BackendCheck[]>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Host CLI availability for `/health`, detected again only when it can have changed. Detection
|
|
19
|
+
* starts one process per CLI, and each start forks the server process (hearsay-tools/squawk#3658).
|
|
20
|
+
* So a read compares `stamp()`, at most every `BACKEND_RECHECK_MS`, and detects only when the
|
|
21
|
+
* stamp changed, the last detection failed, or the result is `BACKEND_MAX_AGE_MS` old.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createBackendChecks(options: {
|
|
24
|
+
detect: () => Promise<BackendCheck[]>;
|
|
25
|
+
stamp: () => Promise<string>;
|
|
26
|
+
/** Called with new checks when a detection result differs from the last one. */
|
|
27
|
+
onChange: (checks: BackendCheck[]) => void;
|
|
28
|
+
now?: () => number;
|
|
29
|
+
}): BackendChecks;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** How often a read may compare the environment stamp. The stamp is file metadata only. */
|
|
2
|
+
export const BACKEND_RECHECK_MS = 5_000;
|
|
3
|
+
/**
|
|
4
|
+
* The longest a detection result is kept while its stamp holds. Most installs and upgrades change
|
|
5
|
+
* the stamp; a version manager's shim (asdf, mise) does not, because the shim file stays the same
|
|
6
|
+
* while the tool behind it changes. This ceiling bounds how long such a version string can lag.
|
|
7
|
+
*/
|
|
8
|
+
export const BACKEND_MAX_AGE_MS = 15 * 60_000;
|
|
9
|
+
/**
|
|
10
|
+
* Host CLI availability for `/health`, detected again only when it can have changed. Detection
|
|
11
|
+
* starts one process per CLI, and each start forks the server process (hearsay-tools/squawk#3658).
|
|
12
|
+
* So a read compares `stamp()`, at most every `BACKEND_RECHECK_MS`, and detects only when the
|
|
13
|
+
* stamp changed, the last detection failed, or the result is `BACKEND_MAX_AGE_MS` old.
|
|
14
|
+
*/
|
|
15
|
+
export function createBackendChecks(options) {
|
|
16
|
+
// Read the clock at each call, so a test's fake Date reaches a gate built before it.
|
|
17
|
+
const now = options.now ?? (() => Date.now());
|
|
18
|
+
let checks = [];
|
|
19
|
+
let checkedAt = -Infinity;
|
|
20
|
+
/** The last good detection: when it settled, and the stamp read before it started. */
|
|
21
|
+
let detected;
|
|
22
|
+
let detecting;
|
|
23
|
+
let checking;
|
|
24
|
+
const detect = (stamp) => {
|
|
25
|
+
detecting = options.detect().then((next) => {
|
|
26
|
+
detected = { stamp, at: now() };
|
|
27
|
+
const changed = JSON.stringify(next) !== JSON.stringify(checks);
|
|
28
|
+
checks = next;
|
|
29
|
+
if (changed)
|
|
30
|
+
options.onChange(next);
|
|
31
|
+
}, () => { detected = undefined; })
|
|
32
|
+
.finally(() => { checkedAt = now(); detecting = undefined; });
|
|
33
|
+
};
|
|
34
|
+
const check = async () => {
|
|
35
|
+
// Finish reading before detecting, so a change during detection gives a different stamp next time.
|
|
36
|
+
const stamp = await options.stamp().catch(() => undefined);
|
|
37
|
+
if (detected && now() - detected.at < BACKEND_MAX_AGE_MS && stamp !== undefined && stamp === detected.stamp) {
|
|
38
|
+
checkedAt = now();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
detect(stamp);
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
async read() {
|
|
45
|
+
if (!detecting && !checking && now() - checkedAt >= BACKEND_RECHECK_MS) {
|
|
46
|
+
checking = check().finally(() => { checking = undefined; });
|
|
47
|
+
}
|
|
48
|
+
await checking;
|
|
49
|
+
return checks;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=backend-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-checks.js","sourceRoot":"","sources":["../../src/server/backend-checks.ts"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACxC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC;AAU9C;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAMnC;IACC,qFAAqF;IACrF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9C,IAAI,MAAM,GAAmB,EAAE,CAAC;IAChC,IAAI,SAAS,GAAG,CAAC,QAAQ,CAAC;IAC1B,sFAAsF;IACtF,IAAI,QAA+D,CAAC;IACpE,IAAI,SAAoC,CAAC;IACzC,IAAI,QAAmC,CAAC;IAExC,MAAM,MAAM,GAAG,CAAC,KAAyB,EAAE,EAAE;QAC3C,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACzC,QAAQ,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAChE,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,OAAO;gBAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC,EAAE,GAAG,EAAE,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;aAChC,OAAO,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;QACvB,mGAAmG;QACnG,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,QAAQ,IAAI,GAAG,EAAE,GAAG,QAAQ,CAAC,EAAE,GAAG,kBAAkB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC5G,SAAS,GAAG,GAAG,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,CAAC,IAAI;YACR,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,IAAI,GAAG,EAAE,GAAG,SAAS,IAAI,kBAAkB,EAAE,CAAC;gBACvE,QAAQ,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,CAAC;YACD,MAAM,QAAQ,CAAC;YACf,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query issueOrPullRequest once per number and use __typename for the actual kind. Include
|
|
3
|
+
* branch-work and review timestamps for freshness decisions.
|
|
4
|
+
*/
|
|
5
|
+
export function refStatusQuery(numbers) {
|
|
6
|
+
const aliases = numbers
|
|
7
|
+
.map((n, i) => ` r${i}: issueOrPullRequest(number: ${n}) { __typename ... on PullRequest { url mergedAt state isDraft reviewDecision mergeable commits(last: 1) { nodes { commit { committedDate parents(first: 1) { totalCount nodes { committedDate } } statusCheckRollup { state } } } } reviews(last: 1, states: CHANGES_REQUESTED) { nodes { submittedAt } } reviewRequests(first: 20) { totalCount nodes { requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { slug } } } } timelineItems(last: 20, itemTypes: [REVIEW_REQUESTED_EVENT]) { nodes { ... on ReviewRequestedEvent { createdAt requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { slug } } } } } } ... on Issue { state stateReason } }`)
|
|
8
|
+
.join('\n');
|
|
9
|
+
return `query ($owner: String!, $name: String!) {\n repository(owner: $owner, name: $name) {\nnameWithOwner\n${aliases}\n }\n}`;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=github-ref-status-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-ref-status-query.js","sourceRoot":"","sources":["../../../src/server/forge/github-ref-status-query.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiB;IAC9C,MAAM,OAAO,GAAG,OAAO;SACpB,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,QAAQ,CAAC,gCAAgC,CAAC,6rBAA6rB,CAC1uB;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,yGAAyG,OAAO,UAAU,CAAC;AACpI,CAAC"}
|
|
@@ -359,6 +359,14 @@ export declare function fetchGithubRefStatus(repoRoot: string, input: {
|
|
|
359
359
|
issues?: number[];
|
|
360
360
|
}): Promise<GithubRefStatusData>;
|
|
361
361
|
export declare function fetchGithubComments(repoRoot: string, kind: 'issue' | 'pr', number: number, refresh?: boolean): Promise<ForgeCommentsData>;
|
|
362
|
+
/**
|
|
363
|
+
* How old an availability answer `/health` serves before it probes again. The server rebuilds
|
|
364
|
+
* health every 5 s while a client reads it, so `CACHE_MS` (60 s) started one `gh repo view` a
|
|
365
|
+
* minute, and each start forks the server process (hearsay-tools/squawk#3658). The answer depends
|
|
366
|
+
* on the network and on GitHub access, so no file change can signal it. A direct `detectGithub`
|
|
367
|
+
* call (automation discovery) still refreshes the shared slot after 60 s.
|
|
368
|
+
*/
|
|
369
|
+
export declare const HEALTH_AVAILABILITY_TTL_MS: number;
|
|
362
370
|
/**
|
|
363
371
|
* Non-blocking availability for `GET /api/health` (#major-health-latency): serves the last-known
|
|
364
372
|
* probe immediately (stale-while-revalidate) and only returns `null` on a cold start, before the
|
|
@@ -367,7 +375,7 @@ export declare function fetchGithubComments(repoRoot: string, kind: 'issue' | 'p
|
|
|
367
375
|
* "unknown until warm" is a valid answer.
|
|
368
376
|
*
|
|
369
377
|
* Serving the stale value while revalidating is what keeps the GitHub nav item from flickering:
|
|
370
|
-
* without it, every time the
|
|
378
|
+
* without it, every time the cache expired this returned `null` for one 5 s health poll,
|
|
371
379
|
* dropping `forge.available` and blinking the sidebar item out until the background probe warmed.
|
|
372
380
|
*/
|
|
373
381
|
export declare function detectGithubCached(repoRoot: string): ForgeAvailability | null;
|
|
@@ -8,6 +8,7 @@ import { matchesGithubPullRequest, mergedPullRequestObservations } from '../../m
|
|
|
8
8
|
import { randomUUID } from 'node:crypto';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { githubRequestGate } from './github-request-gate.js';
|
|
11
|
+
import { refStatusQuery } from './github-ref-status-query.js';
|
|
11
12
|
import { mergedPullRequestChunk } from './github-merged-pr-chunk.js';
|
|
12
13
|
import { gh, githubContext, parseOwnerName } from './github-cli.js';
|
|
13
14
|
import { canonicalRepoRef, discoverRepoHandle, forgetRepoHandle, forgettingNameOnMiss, resolveRepoHandle, sharedRepoHandle } from './github-repo-handle.js';
|
|
@@ -1405,16 +1406,6 @@ const ghRefStatusIssueSchema = z.object({ state: z.string(), stateReason: z.stri
|
|
|
1405
1406
|
// strips unknown keys, so a PR node matched by the issue arm would come back with `isDraft` and
|
|
1406
1407
|
// `commits` silently removed.
|
|
1407
1408
|
const ghRefStatusSchema = z.record(z.string(), z.unknown());
|
|
1408
|
-
/**
|
|
1409
|
-
* Query issueOrPullRequest once per number and use __typename for the actual kind. Include
|
|
1410
|
-
* branch-work and review timestamps for freshness decisions.
|
|
1411
|
-
*/
|
|
1412
|
-
function refStatusQuery(numbers) {
|
|
1413
|
-
const aliases = numbers
|
|
1414
|
-
.map((n, i) => ` r${i}: issueOrPullRequest(number: ${n}) { __typename ... on PullRequest { url mergedAt state isDraft reviewDecision mergeable commits(last: 1) { nodes { commit { committedDate parents(first: 1) { totalCount nodes { committedDate } } statusCheckRollup { state } } } } reviews(last: 1, states: CHANGES_REQUESTED) { nodes { submittedAt } } reviewRequests(first: 20) { totalCount nodes { requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { slug } } } } timelineItems(last: 20, itemTypes: [REVIEW_REQUESTED_EVENT]) { nodes { ... on ReviewRequestedEvent { createdAt requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { slug } } } } } } ... on Issue { state stateReason } }`)
|
|
1415
|
-
.join('\n');
|
|
1416
|
-
return `query ($owner: String!, $name: String!) {\n repository(owner: $owner, name: $name) {\nnameWithOwner\n${aliases}\n }\n}`;
|
|
1417
|
-
}
|
|
1418
1409
|
/**
|
|
1419
1410
|
* Derive whose action is pending: terminal, draft, pending checks, current requested changes,
|
|
1420
1411
|
* failing checks, review, then ready. Use dated review/work evidence; mergeability remains a
|
|
@@ -2293,6 +2284,14 @@ async function detectGithub(repoRoot) {
|
|
|
2293
2284
|
detectInflight.set(repoRoot, probe);
|
|
2294
2285
|
return probe;
|
|
2295
2286
|
}
|
|
2287
|
+
/**
|
|
2288
|
+
* How old an availability answer `/health` serves before it probes again. The server rebuilds
|
|
2289
|
+
* health every 5 s while a client reads it, so `CACHE_MS` (60 s) started one `gh repo view` a
|
|
2290
|
+
* minute, and each start forks the server process (hearsay-tools/squawk#3658). The answer depends
|
|
2291
|
+
* on the network and on GitHub access, so no file change can signal it. A direct `detectGithub`
|
|
2292
|
+
* call (automation discovery) still refreshes the shared slot after 60 s.
|
|
2293
|
+
*/
|
|
2294
|
+
export const HEALTH_AVAILABILITY_TTL_MS = 10 * 60_000;
|
|
2296
2295
|
/**
|
|
2297
2296
|
* Non-blocking availability for `GET /api/health` (#major-health-latency): serves the last-known
|
|
2298
2297
|
* probe immediately (stale-while-revalidate) and only returns `null` on a cold start, before the
|
|
@@ -2301,7 +2300,7 @@ async function detectGithub(repoRoot) {
|
|
|
2301
2300
|
* "unknown until warm" is a valid answer.
|
|
2302
2301
|
*
|
|
2303
2302
|
* Serving the stale value while revalidating is what keeps the GitHub nav item from flickering:
|
|
2304
|
-
* without it, every time the
|
|
2303
|
+
* without it, every time the cache expired this returned `null` for one 5 s health poll,
|
|
2305
2304
|
* dropping `forge.available` and blinking the sidebar item out until the background probe warmed.
|
|
2306
2305
|
*/
|
|
2307
2306
|
export function detectGithubCached(repoRoot) {
|
|
@@ -2309,7 +2308,7 @@ export function detectGithubCached(repoRoot) {
|
|
|
2309
2308
|
return { available: true };
|
|
2310
2309
|
const hit = detectCache.get(repoRoot);
|
|
2311
2310
|
const cached = hit?.result ?? null;
|
|
2312
|
-
const fresh = hit !== undefined && Date.now() - hit.at <
|
|
2311
|
+
const fresh = hit !== undefined && Date.now() - hit.at < HEALTH_AVAILABILITY_TTL_MS;
|
|
2313
2312
|
if (!fresh) {
|
|
2314
2313
|
void detectGithub(repoRoot).catch(() => { }); // revalidate off the request path
|
|
2315
2314
|
}
|