@treestructuredplanning/gateway 0.3.2 → 0.3.4
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 +31 -6
- package/dist/cli.js +45 -81
- package/dist/gateway-schema.json +84 -0
- package/dist/{shared-SSP3A5QQ.js → shared-IDNTQEWS.js} +959 -241
- package/package.json +1 -1
|
@@ -1,7 +1,59 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
+
// package.json
|
|
4
|
+
var package_default = {
|
|
5
|
+
name: "@treestructuredplanning/gateway",
|
|
6
|
+
version: "0.3.4",
|
|
7
|
+
description: "Outbound local harness gateway for Tree-Structured Planning",
|
|
8
|
+
type: "module",
|
|
9
|
+
engines: {
|
|
10
|
+
node: ">=22"
|
|
11
|
+
},
|
|
12
|
+
bin: {
|
|
13
|
+
"tsp-gateway": "dist/cli.js"
|
|
14
|
+
},
|
|
15
|
+
files: [
|
|
16
|
+
"dist/cli.js",
|
|
17
|
+
"dist/shared-*.js",
|
|
18
|
+
"dist/vendor.js",
|
|
19
|
+
"dist/gateway-schema.json",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
scripts: {
|
|
23
|
+
build: "node scripts/build.mjs",
|
|
24
|
+
prepack: "pnpm build",
|
|
25
|
+
test: "pnpm build && node --test --test-concurrency=3 --test-timeout=120000 --test-force-exit test/*.test.mjs",
|
|
26
|
+
"measure:launch": "pnpm build && node scripts/measure-launch.mjs",
|
|
27
|
+
typecheck: "tsc --noEmit",
|
|
28
|
+
lint: "eslint src --report-unused-disable-directives --max-warnings 0",
|
|
29
|
+
check: "pnpm typecheck && pnpm lint && pnpm format:check && pnpm test",
|
|
30
|
+
"format:check": 'prettier --check "src/**/*.ts" "test/*.mjs" "scripts/*.mjs" README.md package.json tsconfig.json',
|
|
31
|
+
"test:coverage": 'pnpm build && node --test-concurrency=3 --test-timeout=120000 --test-force-exit --experimental-test-coverage --test-coverage-lines=80 --test --test-coverage-include="dist/*.js" --test-coverage-exclude="dist/vendor.js" test/*.test.mjs'
|
|
32
|
+
},
|
|
33
|
+
devDependencies: {
|
|
34
|
+
"@tsp/shared": "workspace:*",
|
|
35
|
+
"@types/node": "^24.10.9",
|
|
36
|
+
esbuild: "0.25.12",
|
|
37
|
+
typescript: "^5.7.2"
|
|
38
|
+
},
|
|
39
|
+
license: "MIT",
|
|
40
|
+
dependencies: {
|
|
41
|
+
"@napi-rs/keyring": "2.1.2",
|
|
42
|
+
"smol-toml": "1.6.0",
|
|
43
|
+
ws: "8.21.0"
|
|
44
|
+
},
|
|
45
|
+
publishConfig: {
|
|
46
|
+
access: "public"
|
|
47
|
+
},
|
|
48
|
+
repository: {
|
|
49
|
+
type: "git",
|
|
50
|
+
url: "git+https://github.com/WebifyServices/tsp.git",
|
|
51
|
+
directory: "packages/tsp-gateway"
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
3
55
|
// ../tsp-shared/src/generated/constants.ts
|
|
4
|
-
var GATEWAY_PACKAGE_VERSION = "0.3.
|
|
56
|
+
var GATEWAY_PACKAGE_VERSION = "0.3.4";
|
|
5
57
|
var GATEWAY_PROTOCOL_VERSION = 3;
|
|
6
58
|
var SESSION_ACTIVITY_COUNT_MAX = 1e6;
|
|
7
59
|
var AGENT_SESSION_STATE = {
|
|
@@ -14,12 +66,34 @@ var AGENT_SESSION_STATE = {
|
|
|
14
66
|
ENDED: "ended",
|
|
15
67
|
UNKNOWN: "unknown"
|
|
16
68
|
};
|
|
69
|
+
var GATEWAY_CLOSE_CODE = {
|
|
70
|
+
/** Observed transport loss only; RFC 6455 forbids sending this code. */
|
|
71
|
+
ABNORMAL_CLOSURE: 1006,
|
|
72
|
+
/** Terminal: re-pair the machine. */
|
|
73
|
+
MACHINE_REVOKED: 4501,
|
|
74
|
+
/** Terminal: re-pair with the owning account. */
|
|
75
|
+
MACHINE_NOT_OWNED: 4502,
|
|
76
|
+
/** Keep running; retry hourly until the gateway or hub is updated. */
|
|
77
|
+
PROTOCOL_OUTDATED: 4503,
|
|
78
|
+
/** Refresh once and reconnect; failed refresh is terminal and requires re-pair. */
|
|
79
|
+
TOKEN_EXPIRED_OR_INVALID: 4505,
|
|
80
|
+
/** Back off only if still the running daemon; otherwise exit. */
|
|
81
|
+
SUPERSEDED: 4506,
|
|
82
|
+
/** Reconnect with jittered backoff after server restart. */
|
|
83
|
+
SERVER_RESTARTING: 4507,
|
|
84
|
+
/** Reconnect with jittered backoff after heartbeat loss. */
|
|
85
|
+
HEARTBEAT_TIMEOUT: 4508
|
|
86
|
+
};
|
|
17
87
|
var GATEWAY_CLOSE_DISPOSITION = {
|
|
18
88
|
TERMINAL: "terminal",
|
|
19
89
|
TOKEN: "token",
|
|
20
90
|
OUTDATED: "outdated",
|
|
21
91
|
RECONNECTABLE: "reconnectable"
|
|
22
92
|
};
|
|
93
|
+
var GATEWAY_INSTALL = {
|
|
94
|
+
GLOBAL: "global",
|
|
95
|
+
NPX: "npx"
|
|
96
|
+
};
|
|
23
97
|
var HARNESS_KIND = {
|
|
24
98
|
CLAUDE_CODE: "claude_code",
|
|
25
99
|
CODEX: "codex",
|
|
@@ -53,6 +127,7 @@ var LAUNCH_REFUSAL_REASON = {
|
|
|
53
127
|
LAUNCH_SUPERSEDED: "launch_superseded",
|
|
54
128
|
LAUNCH_EXPIRED: "launch_expired",
|
|
55
129
|
LAUNCH_WITHDRAWN: "launch_withdrawn",
|
|
130
|
+
LAUNCH_DISMISSED: "launch_dismissed",
|
|
56
131
|
CONTROL_EXPIRED: "control_expired",
|
|
57
132
|
CONTROL_WITHDRAWN: "control_withdrawn"
|
|
58
133
|
};
|
|
@@ -72,6 +147,85 @@ var SESSION_ACTIVITY_KIND = {
|
|
|
72
147
|
/** Any other tool: the web, a skill, another MCP server. */
|
|
73
148
|
USING_TOOL: "using_tool"
|
|
74
149
|
};
|
|
150
|
+
var WS_CLOSE_CODE = {
|
|
151
|
+
/**
|
|
152
|
+
* A clean end. The frontend sends it when it unmounts or rotates a token, and a
|
|
153
|
+
* locally closed socket is not reconnected. A peer's Close frame ends only the
|
|
154
|
+
* transport, so clients reconnect with backoff. The server's own closes carry
|
|
155
|
+
* a more specific code.
|
|
156
|
+
*/
|
|
157
|
+
NORMAL_CLOSURE: 1e3,
|
|
158
|
+
/**
|
|
159
|
+
* The peer is leaving, as a browser does when it navigates away. Like
|
|
160
|
+
* `NORMAL_CLOSURE` it ends the transport; clients reconnect with backoff
|
|
161
|
+
* unless they have locally disposed the socket.
|
|
162
|
+
*/
|
|
163
|
+
GOING_AWAY: 1001,
|
|
164
|
+
/**
|
|
165
|
+
* The transport vanished without a Close frame. RFC 6455 forbids sending
|
|
166
|
+
* it; `FastAPIChannel.recv` raises it internally so pycrdt's receive loop
|
|
167
|
+
* ends the way Starlette reports a dropped peer.
|
|
168
|
+
*/
|
|
169
|
+
ABNORMAL_CLOSURE: 1006,
|
|
170
|
+
/** The per-IP connection rate limit rejected the socket. */
|
|
171
|
+
POLICY_VIOLATION: 1008,
|
|
172
|
+
/**
|
|
173
|
+
* A transient infrastructure failure (plan, membership or branch lookup)
|
|
174
|
+
* refused the socket. Clients reconnect with backoff instead of treating it
|
|
175
|
+
* as a permanent access refusal. Generation and plan events share a bounded
|
|
176
|
+
* retry budget; y-websocket owns the Yjs retry loop.
|
|
177
|
+
*/
|
|
178
|
+
INTERNAL_ERROR: 1011,
|
|
179
|
+
/**
|
|
180
|
+
* The ASGI server is restarting (uvicorn sends this during shutdown).
|
|
181
|
+
* Clients reconnect with backoff.
|
|
182
|
+
*/
|
|
183
|
+
SERVICE_RESTART: 1012,
|
|
184
|
+
/**
|
|
185
|
+
* The Yjs room's previous session left a rejected document the registry
|
|
186
|
+
* could not discard, so serving it would hand the client edits storage
|
|
187
|
+
* refuses. Transient: the next connect retries the discard. Nothing latches
|
|
188
|
+
* it, and the socket is accepted before it is closed, so y-websocket resets
|
|
189
|
+
* its backoff and retries about every 100 ms until the room is servable.
|
|
190
|
+
*/
|
|
191
|
+
TRY_AGAIN_LATER: 1013,
|
|
192
|
+
/**
|
|
193
|
+
* No usable credential: missing, expired, invalid, MCP-only or
|
|
194
|
+
* invalidated token. Recoverable with a fresh token: the generation hook
|
|
195
|
+
* refreshes it and retries, Yjs refreshes once until a successful sync, and
|
|
196
|
+
* plan events reopens when it rotates. An invalidated refresh credential
|
|
197
|
+
* cannot restore the session; sign-in is required.
|
|
198
|
+
*/
|
|
199
|
+
AUTH_FAILED: 4001,
|
|
200
|
+
/**
|
|
201
|
+
* The token is valid but its `email_verified` claim is false. A token
|
|
202
|
+
* minted before the account verified keeps the claim until it is refreshed.
|
|
203
|
+
* Generation and Yjs attempt a bounded refresh and stop if verification is
|
|
204
|
+
* still required; local edits are preserved. Plan events follows rotation.
|
|
205
|
+
*/
|
|
206
|
+
EMAIL_NOT_VERIFIED: 4002,
|
|
207
|
+
/**
|
|
208
|
+
* A live socket was closed because its workspace membership was removed or
|
|
209
|
+
* demoted below `COLLAB_ROLES` (`tsp_api.transports.yjs.revocation`, #1274). Distinct
|
|
210
|
+
* from `ACCESS_DENIED`, which refuses a connect (#1256), so the frontend
|
|
211
|
+
* branches on `CloseEvent.code` instead of parsing `CloseEvent.reason`.
|
|
212
|
+
*/
|
|
213
|
+
PERMISSION_REVOKED: 4003,
|
|
214
|
+
/** At connect: the plan is not the tenant's, or the membership is missing. Retrying cannot change the answer. */
|
|
215
|
+
ACCESS_DENIED: 4403,
|
|
216
|
+
/**
|
|
217
|
+
* At connect: the plan has no such branch. A branch lookup that itself
|
|
218
|
+
* fails closes `INTERNAL_ERROR` instead, so a storage blip never reads as a
|
|
219
|
+
* deleted branch.
|
|
220
|
+
*/
|
|
221
|
+
BRANCH_NOT_FOUND: 4404,
|
|
222
|
+
/**
|
|
223
|
+
* At connect: an authenticated workspace member lacks a collaboration
|
|
224
|
+
* role. Stop the socket without refreshing the workspace session or hiding
|
|
225
|
+
* the REST-readable plan. Retrying cannot change the membership role.
|
|
226
|
+
*/
|
|
227
|
+
INSUFFICIENT_ROLE: 4405
|
|
228
|
+
};
|
|
75
229
|
var GATEWAY_CLOSE_DISPOSITION_BY_CODE = {
|
|
76
230
|
"1006": "reconnectable",
|
|
77
231
|
"4501": "terminal",
|
|
@@ -92,9 +246,9 @@ function contains(folder, path) {
|
|
|
92
246
|
}
|
|
93
247
|
async function realLocation(path) {
|
|
94
248
|
let current = parse(path).root;
|
|
95
|
-
const
|
|
96
|
-
for (let index = 0; index <
|
|
97
|
-
const part =
|
|
249
|
+
const parts2 = path.slice(current.length).split(sep);
|
|
250
|
+
for (let index = 0; index < parts2.length; index++) {
|
|
251
|
+
const part = parts2[index];
|
|
98
252
|
if (part === "" || part === ".") continue;
|
|
99
253
|
if (part === "..") {
|
|
100
254
|
current = dirname(current);
|
|
@@ -104,7 +258,7 @@ async function realLocation(path) {
|
|
|
104
258
|
try {
|
|
105
259
|
current = await realpath(next);
|
|
106
260
|
} catch {
|
|
107
|
-
return resolve(next, ...
|
|
261
|
+
return resolve(next, ...parts2.slice(index + 1));
|
|
108
262
|
}
|
|
109
263
|
}
|
|
110
264
|
return current;
|
|
@@ -381,6 +535,10 @@ function decodeRegistration(value) {
|
|
|
381
535
|
throw new Error("Invalid machine hub path");
|
|
382
536
|
return registration;
|
|
383
537
|
}
|
|
538
|
+
function decodeRelease(value) {
|
|
539
|
+
if (!matches(requiredSchema("GatewayRelease"), value)) throw new Error("Invalid release");
|
|
540
|
+
return value;
|
|
541
|
+
}
|
|
384
542
|
function parseJson(text5) {
|
|
385
543
|
return JSON.parse(text5);
|
|
386
544
|
}
|
|
@@ -496,52 +654,6 @@ async function observedState(session, signedIn) {
|
|
|
496
654
|
}
|
|
497
655
|
}
|
|
498
656
|
|
|
499
|
-
// src/checkout-roots.ts
|
|
500
|
-
import { homedir } from "node:os";
|
|
501
|
-
import { isAbsolute as isAbsolute3, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
502
|
-
var UNRESOLVED_WORKTREE_ROOT = "<clone>/.tsp/worktrees";
|
|
503
|
-
function inside(parent, child) {
|
|
504
|
-
const path = relative2(parent, child);
|
|
505
|
-
return path === "" || !path.startsWith(`..${sep2}`) && path !== ".." && !isAbsolute3(path);
|
|
506
|
-
}
|
|
507
|
-
function decodeWorktreeRoot(value, clone) {
|
|
508
|
-
if (value === null) return null;
|
|
509
|
-
if (typeof value !== "string" || !value.trim() || value.includes("\0"))
|
|
510
|
-
throw new Error("Invalid worktree root");
|
|
511
|
-
if (value.startsWith("~") && !value.startsWith("~/")) throw new Error("Invalid worktree root");
|
|
512
|
-
const expanded = value.startsWith("~/") ? resolve2(homedir(), value.slice(2)) : value;
|
|
513
|
-
if (clone && inside(resolve2(clone, expanded), resolve2(clone)))
|
|
514
|
-
throw new Error("Worktree root must not contain the clone");
|
|
515
|
-
if (isAbsolute3(expanded) && resolve2(expanded) === resolve2(expanded, ".."))
|
|
516
|
-
throw new Error("Worktree root must not contain the clone");
|
|
517
|
-
if (!clone && !isAbsolute3(expanded) && inside(resolve2("/clone", expanded), "/clone"))
|
|
518
|
-
throw new Error("Worktree root must not contain the clone");
|
|
519
|
-
return value;
|
|
520
|
-
}
|
|
521
|
-
function worktreeSetting(clone, config) {
|
|
522
|
-
const registered2 = Object.values(config.repositories).find((row) => row.folder === clone);
|
|
523
|
-
if (registered2?.worktreeRoot != null) return "repository";
|
|
524
|
-
return config.worktrees.root != null ? "machine" : null;
|
|
525
|
-
}
|
|
526
|
-
function worktreeRoot(clone, config, top = clone) {
|
|
527
|
-
const registered2 = Object.values(config.repositories).find((row) => row.folder === clone);
|
|
528
|
-
const configured = registered2?.worktreeRoot ?? config.worktrees.root;
|
|
529
|
-
decodeWorktreeRoot(configured, clone);
|
|
530
|
-
const folder = configured === null ? resolve2(top, ".tsp/worktrees") : resolve2(
|
|
531
|
-
clone,
|
|
532
|
-
configured.startsWith("~/") ? resolve2(homedir(), configured.slice(2)) : configured
|
|
533
|
-
);
|
|
534
|
-
return configured === null ? { folder, location: "in_clone", setting: null } : { folder, location: "custom", setting: worktreeSetting(clone, config) };
|
|
535
|
-
}
|
|
536
|
-
function worktreeFolder(root, attemptId) {
|
|
537
|
-
if (!/^att_[0-9a-f]{12}$/.test(attemptId)) throw new Error("Invalid attempt identity");
|
|
538
|
-
return resolve2(root.folder, attemptId);
|
|
539
|
-
}
|
|
540
|
-
function excludeLine(clone, root) {
|
|
541
|
-
if (!inside(clone, root.folder)) return null;
|
|
542
|
-
return root.location === "in_clone" ? "/.tsp/" : `/${relative2(clone, root.folder).split(sep2).map((segment) => segment.replace(/[\\*?[\]]/g, "\\$&")).join("/")}/`;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
657
|
// src/process.ts
|
|
546
658
|
import { spawn } from "node:child_process";
|
|
547
659
|
function execute(file, args, env, cwd, { timeoutMs = 3e4 } = {}) {
|
|
@@ -590,7 +702,7 @@ function pidAlive(pid) {
|
|
|
590
702
|
import { constants } from "node:fs";
|
|
591
703
|
import { access, stat } from "node:fs/promises";
|
|
592
704
|
import { userInfo } from "node:os";
|
|
593
|
-
import { basename, isAbsolute as
|
|
705
|
+
import { basename, isAbsolute as isAbsolute3 } from "node:path";
|
|
594
706
|
var posix = {
|
|
595
707
|
flags: ["-l", "-i", "-c"],
|
|
596
708
|
command: 'cd /; cd -- "$5" || { "$1" -e "$6" "$3" "$5"; exit 125; }; "$1" -e "$2" "$3" "$4" || exit; cd /; cd -- "$5" || { "$1" -e "$6" "" "$5"; exit 125; }; shift 6; exec "$@"',
|
|
@@ -620,7 +732,7 @@ var strategies = /* @__PURE__ */ new Map([
|
|
|
620
732
|
["xonsh", null]
|
|
621
733
|
]);
|
|
622
734
|
async function executable(path) {
|
|
623
|
-
if (!
|
|
735
|
+
if (!isAbsolute3(path)) return false;
|
|
624
736
|
try {
|
|
625
737
|
await access(path, constants.X_OK);
|
|
626
738
|
return (await stat(path)).isFile();
|
|
@@ -1010,6 +1122,127 @@ function launchRepositoryKey(repository) {
|
|
|
1010
1122
|
return repositoryKey(repository);
|
|
1011
1123
|
}
|
|
1012
1124
|
|
|
1125
|
+
// src/trust-cache.ts
|
|
1126
|
+
import { stat as stat2 } from "node:fs/promises";
|
|
1127
|
+
var TRUST_CACHE_MAX_AGE_MS = 5 * 6e4;
|
|
1128
|
+
async function stampOf(path) {
|
|
1129
|
+
try {
|
|
1130
|
+
const info = await stat2(path, { bigint: true });
|
|
1131
|
+
return `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}`;
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
const code = error.code;
|
|
1134
|
+
return code === "ENOENT" || code === "ENOTDIR" ? "absent" : `unreadable:${code ?? "?"}`;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
var TrustCache = class {
|
|
1138
|
+
constructor(clock = Date.now, maxAgeMs = TRUST_CACHE_MAX_AGE_MS) {
|
|
1139
|
+
this.clock = clock;
|
|
1140
|
+
this.maxAgeMs = maxAgeMs;
|
|
1141
|
+
}
|
|
1142
|
+
entries = /* @__PURE__ */ new Map();
|
|
1143
|
+
/** Forgets every answer, for a change no file stamp or key shows, such as the launch configuration. */
|
|
1144
|
+
clear() {
|
|
1145
|
+
this.entries.clear();
|
|
1146
|
+
}
|
|
1147
|
+
/** One facts check's reads: each file is stamped once, and each key read at most once. */
|
|
1148
|
+
pass(read) {
|
|
1149
|
+
return new TrustCachePass(this.entries, this.clock, this.maxAgeMs, read);
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
var TrustCachePass = class {
|
|
1153
|
+
constructor(entries, clock, maxAgeMs, read) {
|
|
1154
|
+
this.entries = entries;
|
|
1155
|
+
this.clock = clock;
|
|
1156
|
+
this.maxAgeMs = maxAgeMs;
|
|
1157
|
+
this.read = read;
|
|
1158
|
+
}
|
|
1159
|
+
stamps = /* @__PURE__ */ new Map();
|
|
1160
|
+
answers = /* @__PURE__ */ new Map();
|
|
1161
|
+
/**
|
|
1162
|
+
* The answer for `key`: the cached one while its files' stamps are unchanged and it is younger
|
|
1163
|
+
* than the maximum age, otherwise `full`, which names each file it reads through `watch`.
|
|
1164
|
+
*/
|
|
1165
|
+
get(key, full) {
|
|
1166
|
+
let answer = this.answers.get(key);
|
|
1167
|
+
if (!answer) {
|
|
1168
|
+
answer = this.answer(key, full);
|
|
1169
|
+
this.answers.set(key, answer);
|
|
1170
|
+
}
|
|
1171
|
+
return answer;
|
|
1172
|
+
}
|
|
1173
|
+
async answer(key, full) {
|
|
1174
|
+
const entry2 = this.entries.get(key);
|
|
1175
|
+
if (this.read === "cached" && entry2 && await this.current(entry2)) return entry2.value;
|
|
1176
|
+
const readAt = this.clock();
|
|
1177
|
+
const files = /* @__PURE__ */ new Map();
|
|
1178
|
+
const value = await full(async (path) => {
|
|
1179
|
+
files.set(path, await this.stamp(path));
|
|
1180
|
+
});
|
|
1181
|
+
this.entries.set(key, { files, readAt, value });
|
|
1182
|
+
return value;
|
|
1183
|
+
}
|
|
1184
|
+
async current(entry2) {
|
|
1185
|
+
if (this.clock() - entry2.readAt >= this.maxAgeMs) return false;
|
|
1186
|
+
for (const [path, stamp] of entry2.files)
|
|
1187
|
+
if (await this.stamp(path) !== stamp) return false;
|
|
1188
|
+
return true;
|
|
1189
|
+
}
|
|
1190
|
+
stamp(path) {
|
|
1191
|
+
let stamp = this.stamps.get(path);
|
|
1192
|
+
if (!stamp) {
|
|
1193
|
+
stamp = stampOf(path);
|
|
1194
|
+
this.stamps.set(path, stamp);
|
|
1195
|
+
}
|
|
1196
|
+
return stamp;
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
// src/checkout-roots.ts
|
|
1201
|
+
import { homedir } from "node:os";
|
|
1202
|
+
import { isAbsolute as isAbsolute4, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
1203
|
+
var UNRESOLVED_WORKTREE_ROOT = "<clone>/.tsp/worktrees";
|
|
1204
|
+
function inside(parent, child) {
|
|
1205
|
+
const path = relative2(parent, child);
|
|
1206
|
+
return path === "" || !path.startsWith(`..${sep2}`) && path !== ".." && !isAbsolute4(path);
|
|
1207
|
+
}
|
|
1208
|
+
function decodeWorktreeRoot(value, clone) {
|
|
1209
|
+
if (value === null) return null;
|
|
1210
|
+
if (typeof value !== "string" || !value.trim() || value.includes("\0"))
|
|
1211
|
+
throw new Error("Invalid worktree root");
|
|
1212
|
+
if (value.startsWith("~") && !value.startsWith("~/")) throw new Error("Invalid worktree root");
|
|
1213
|
+
const expanded = value.startsWith("~/") ? resolve2(homedir(), value.slice(2)) : value;
|
|
1214
|
+
if (clone && inside(resolve2(clone, expanded), resolve2(clone)))
|
|
1215
|
+
throw new Error("Worktree root must not contain the clone");
|
|
1216
|
+
if (isAbsolute4(expanded) && resolve2(expanded) === resolve2(expanded, ".."))
|
|
1217
|
+
throw new Error("Worktree root must not contain the clone");
|
|
1218
|
+
if (!clone && !isAbsolute4(expanded) && inside(resolve2("/clone", expanded), "/clone"))
|
|
1219
|
+
throw new Error("Worktree root must not contain the clone");
|
|
1220
|
+
return value;
|
|
1221
|
+
}
|
|
1222
|
+
function worktreeSetting(clone, config) {
|
|
1223
|
+
const registered2 = Object.values(config.repositories).find((row) => row.folder === clone);
|
|
1224
|
+
if (registered2?.worktreeRoot != null) return "repository";
|
|
1225
|
+
return config.worktrees.root != null ? "machine" : null;
|
|
1226
|
+
}
|
|
1227
|
+
function worktreeRoot(clone, config, top = clone) {
|
|
1228
|
+
const registered2 = Object.values(config.repositories).find((row) => row.folder === clone);
|
|
1229
|
+
const configured = registered2?.worktreeRoot ?? config.worktrees.root;
|
|
1230
|
+
decodeWorktreeRoot(configured, clone);
|
|
1231
|
+
const folder = configured === null ? resolve2(top, ".tsp/worktrees") : resolve2(
|
|
1232
|
+
clone,
|
|
1233
|
+
configured.startsWith("~/") ? resolve2(homedir(), configured.slice(2)) : configured
|
|
1234
|
+
);
|
|
1235
|
+
return configured === null ? { folder, location: "in_clone", setting: null } : { folder, location: "custom", setting: worktreeSetting(clone, config) };
|
|
1236
|
+
}
|
|
1237
|
+
function worktreeFolder(root, attemptId) {
|
|
1238
|
+
if (!/^att_[0-9a-f]{12}$/.test(attemptId)) throw new Error("Invalid attempt identity");
|
|
1239
|
+
return resolve2(root.folder, attemptId);
|
|
1240
|
+
}
|
|
1241
|
+
function excludeLine(clone, root) {
|
|
1242
|
+
if (!inside(clone, root.folder)) return null;
|
|
1243
|
+
return root.location === "in_clone" ? "/.tsp/" : `/${relative2(clone, root.folder).split(sep2).map((segment) => segment.replace(/[\\*?[\]]/g, "\\$&")).join("/")}/`;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1013
1246
|
// src/acp-driver.ts
|
|
1014
1247
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
1015
1248
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -1468,6 +1701,56 @@ var AcpSession = class {
|
|
|
1468
1701
|
}
|
|
1469
1702
|
};
|
|
1470
1703
|
|
|
1704
|
+
// src/acp-trust.ts
|
|
1705
|
+
var AcpTrust = class {
|
|
1706
|
+
/**
|
|
1707
|
+
* `ask` is the agent's own trust read, which names each file it reads through `watch`.
|
|
1708
|
+
* `revision` counts launch-configuration changes: the agent finds its trust files through
|
|
1709
|
+
* that configuration, so an answer read under one is never reused under another.
|
|
1710
|
+
*/
|
|
1711
|
+
constructor(harness, ask, revision = () => 0, cache = new TrustCache()) {
|
|
1712
|
+
this.harness = harness;
|
|
1713
|
+
this.ask = ask;
|
|
1714
|
+
this.revision = revision;
|
|
1715
|
+
this.cache = cache;
|
|
1716
|
+
this.seen = revision();
|
|
1717
|
+
}
|
|
1718
|
+
seen;
|
|
1719
|
+
/** The folder's trust read now, uncached, as a launch needs it. */
|
|
1720
|
+
read(folder) {
|
|
1721
|
+
return this.ask(folder);
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* One facts check's reads. A cached answer stands while every file the agent named is
|
|
1725
|
+
* unchanged, and for at most TRUST_CACHE_MAX_AGE_MS, since an agent may decide trust from
|
|
1726
|
+
* something no file stamp shows.
|
|
1727
|
+
*/
|
|
1728
|
+
reads(read) {
|
|
1729
|
+
const revision = this.revision();
|
|
1730
|
+
if (revision !== this.seen) {
|
|
1731
|
+
this.cache.clear();
|
|
1732
|
+
this.seen = revision;
|
|
1733
|
+
}
|
|
1734
|
+
const pass = this.cache.pass(read);
|
|
1735
|
+
return (folder) => pass.get(folder, (watch2) => this.ask(folder, watch2));
|
|
1736
|
+
}
|
|
1737
|
+
/** Each registered folder's trust row in slug order, with what `extra` reads in that folder first. */
|
|
1738
|
+
async rows(folders, read, extra) {
|
|
1739
|
+
const trust = this.reads(read);
|
|
1740
|
+
return Promise.all(
|
|
1741
|
+
Object.entries(folders).sort(([a], [b]) => a.localeCompare(b)).map(async ([slug, folder]) => {
|
|
1742
|
+
const found = await extra(folder);
|
|
1743
|
+
return {
|
|
1744
|
+
harness: this.harness,
|
|
1745
|
+
repository: repositoryFromKey(slug),
|
|
1746
|
+
trust: await trust(folder),
|
|
1747
|
+
...found
|
|
1748
|
+
};
|
|
1749
|
+
})
|
|
1750
|
+
);
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1471
1754
|
// src/acp-driver.ts
|
|
1472
1755
|
var ACP_TIMEOUTS = { startupMs: 1e4, requestMs: 3e4 };
|
|
1473
1756
|
var CANCEL_GRACE_MS = 2e3;
|
|
@@ -1483,6 +1766,11 @@ var AcpDriver = class {
|
|
|
1483
1766
|
this.executor = executor;
|
|
1484
1767
|
this.timeouts = timeouts;
|
|
1485
1768
|
this.groups = groups;
|
|
1769
|
+
this.trustRecord = new AcpTrust(
|
|
1770
|
+
agent.harness,
|
|
1771
|
+
agent.trust.bind(agent, executor),
|
|
1772
|
+
() => executor.configurationRevision
|
|
1773
|
+
);
|
|
1486
1774
|
this.displayName = agent.displayName;
|
|
1487
1775
|
this.signInStep = agent.signInStep;
|
|
1488
1776
|
this.installStep = agent.installStep;
|
|
@@ -1500,6 +1788,7 @@ var AcpDriver = class {
|
|
|
1500
1788
|
hold;
|
|
1501
1789
|
loadSession = false;
|
|
1502
1790
|
probedVersion = null;
|
|
1791
|
+
trustRecord;
|
|
1503
1792
|
/**
|
|
1504
1793
|
* Derived from what the agent advertised at its last probe: Resume needs `session/load`. No
|
|
1505
1794
|
* terminal can join a live ACP session, so `attach_hint` is never advertised: the canvas
|
|
@@ -1555,7 +1844,7 @@ var AcpDriver = class {
|
|
|
1555
1844
|
}
|
|
1556
1845
|
}
|
|
1557
1846
|
async requireTrusted(folder) {
|
|
1558
|
-
if (await this.
|
|
1847
|
+
if (await this.trustRecord.read(folder) !== "trusted")
|
|
1559
1848
|
throw new HarnessRefusal("workspace_untrusted");
|
|
1560
1849
|
}
|
|
1561
1850
|
register(id, name, folder) {
|
|
@@ -1754,19 +2043,14 @@ var AcpDriver = class {
|
|
|
1754
2043
|
attachHint(id) {
|
|
1755
2044
|
return { harness: this.agent.harness, session_ref: id };
|
|
1756
2045
|
}
|
|
1757
|
-
|
|
1758
|
-
return
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
available: detection.available,
|
|
1766
|
-
signed_in: detection.signed_in ?? null
|
|
1767
|
-
};
|
|
1768
|
-
})
|
|
1769
|
-
);
|
|
2046
|
+
repositories(folders, read = "fresh") {
|
|
2047
|
+
return this.trustRecord.rows(folders, read, async (folder) => {
|
|
2048
|
+
const detection = await this.probe(folder);
|
|
2049
|
+
return { available: detection.available, signed_in: detection.signed_in ?? null };
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
trust(folders, read) {
|
|
2053
|
+
return this.trustRecord.rows(folders, read, async () => ({}));
|
|
1770
2054
|
}
|
|
1771
2055
|
/** Ends agent process groups a gateway killed outright left behind, once at startup. */
|
|
1772
2056
|
async reap() {
|
|
@@ -2059,7 +2343,7 @@ var AcpGroupLedger = class {
|
|
|
2059
2343
|
};
|
|
2060
2344
|
|
|
2061
2345
|
// src/claude-transcript.ts
|
|
2062
|
-
import { open as open2, readdir, stat as
|
|
2346
|
+
import { open as open2, readdir, stat as stat3 } from "node:fs/promises";
|
|
2063
2347
|
import { join as join4 } from "node:path";
|
|
2064
2348
|
var TRANSCRIPT_READ_BYTES = 1 << 20;
|
|
2065
2349
|
var LINE_LIMIT_BYTES = 8 << 20;
|
|
@@ -2116,7 +2400,7 @@ var ClaudeTranscripts = class {
|
|
|
2116
2400
|
if (!cursor.path) return null;
|
|
2117
2401
|
let size;
|
|
2118
2402
|
try {
|
|
2119
|
-
size = (await
|
|
2403
|
+
size = (await stat3(cursor.path)).size;
|
|
2120
2404
|
} catch {
|
|
2121
2405
|
this.cursors.set(conversationId, this.fresh(null));
|
|
2122
2406
|
return null;
|
|
@@ -2251,7 +2535,7 @@ function toolResult(tally, edits, block, at) {
|
|
|
2251
2535
|
}
|
|
2252
2536
|
async function exists(path) {
|
|
2253
2537
|
try {
|
|
2254
|
-
return (await
|
|
2538
|
+
return (await stat3(path)).isFile();
|
|
2255
2539
|
} catch {
|
|
2256
2540
|
return false;
|
|
2257
2541
|
}
|
|
@@ -2263,22 +2547,27 @@ import { homedir as homedir4 } from "node:os";
|
|
|
2263
2547
|
import { join as join5 } from "node:path";
|
|
2264
2548
|
var MAX_CONFIG_BYTES = 4 * 1024 * 1024;
|
|
2265
2549
|
var ClaudeTrust = class {
|
|
2266
|
-
constructor(environment = process.env, home = homedir4()) {
|
|
2550
|
+
constructor(environment = process.env, home = homedir4(), cache = new TrustCache()) {
|
|
2267
2551
|
this.environment = environment;
|
|
2268
2552
|
this.home = home;
|
|
2553
|
+
this.cache = cache;
|
|
2269
2554
|
}
|
|
2270
2555
|
observed = /* @__PURE__ */ new Map();
|
|
2271
2556
|
paths = /* @__PURE__ */ new Map();
|
|
2272
2557
|
mark(folder, trust) {
|
|
2273
2558
|
this.observed.set(folder, trust);
|
|
2274
2559
|
}
|
|
2275
|
-
async
|
|
2560
|
+
async path(folder) {
|
|
2561
|
+
const env = typeof this.environment === "function" ? await this.environment(folder) : this.environment;
|
|
2562
|
+
const path = join5(env["CLAUDE_CONFIG_DIR"] ?? env["HOME"] ?? this.home, ".claude.json");
|
|
2563
|
+
const previous = this.paths.get(folder);
|
|
2564
|
+
if (previous !== void 0 && path !== previous) this.observed.delete(folder);
|
|
2565
|
+
this.paths.set(folder, path);
|
|
2566
|
+
return path;
|
|
2567
|
+
}
|
|
2568
|
+
async projects(path, watch2) {
|
|
2276
2569
|
try {
|
|
2277
|
-
|
|
2278
|
-
const path = join5(env["CLAUDE_CONFIG_DIR"] ?? env["HOME"] ?? this.home, ".claude.json");
|
|
2279
|
-
const previous = this.paths.get(folder);
|
|
2280
|
-
if (previous !== void 0 && path !== previous) this.observed.delete(folder);
|
|
2281
|
-
this.paths.set(folder, path);
|
|
2570
|
+
await watch2(path);
|
|
2282
2571
|
const handle = await open3(path, "r");
|
|
2283
2572
|
try {
|
|
2284
2573
|
const info = await handle.stat();
|
|
@@ -2306,10 +2595,17 @@ var ClaudeTrust = class {
|
|
|
2306
2595
|
return null;
|
|
2307
2596
|
}
|
|
2308
2597
|
}
|
|
2309
|
-
async repositories(registry) {
|
|
2598
|
+
async repositories(registry, read = "fresh") {
|
|
2599
|
+
const pass = this.cache.pass(read);
|
|
2310
2600
|
return Promise.all(
|
|
2311
2601
|
Object.entries(registry).sort(([a], [b]) => a.localeCompare(b)).map(async ([slug, folder]) => {
|
|
2312
|
-
|
|
2602
|
+
let projects;
|
|
2603
|
+
try {
|
|
2604
|
+
const path = await this.path(folder);
|
|
2605
|
+
projects = await pass.get(path, (watch2) => this.projects(path, watch2));
|
|
2606
|
+
} catch {
|
|
2607
|
+
projects = null;
|
|
2608
|
+
}
|
|
2313
2609
|
const project = projects && Object.hasOwn(projects, folder) ? field(projects, folder) : null;
|
|
2314
2610
|
const accepted = isObject(project) ? field(project, "hasTrustDialogAccepted") : null;
|
|
2315
2611
|
if (typeof accepted === "boolean") this.observed.delete(folder);
|
|
@@ -2342,14 +2638,20 @@ var HarnessExecutor = class {
|
|
|
2342
2638
|
home;
|
|
2343
2639
|
captures = /* @__PURE__ */ new Map();
|
|
2344
2640
|
revision;
|
|
2641
|
+
invalidations = 0;
|
|
2345
2642
|
lastPath;
|
|
2346
2643
|
/** The most recent successful capture in any folder, for a folder with none of its own. */
|
|
2347
2644
|
latest;
|
|
2645
|
+
/** Counts launch-configuration changes, so nothing read under one configuration is reused under another. */
|
|
2646
|
+
get configurationRevision() {
|
|
2647
|
+
return this.invalidations;
|
|
2648
|
+
}
|
|
2348
2649
|
invalidate() {
|
|
2349
2650
|
this.captures.clear();
|
|
2350
2651
|
this.latest = void 0;
|
|
2351
2652
|
this.revision = void 0;
|
|
2352
2653
|
this.lastPath = void 0;
|
|
2654
|
+
this.invalidations += 1;
|
|
2353
2655
|
}
|
|
2354
2656
|
async configuration() {
|
|
2355
2657
|
const config = await this.options.config?.() ?? defaultLaunchConfig();
|
|
@@ -2581,7 +2883,7 @@ function slowShell(error) {
|
|
|
2581
2883
|
}
|
|
2582
2884
|
|
|
2583
2885
|
// src/claude-driver.ts
|
|
2584
|
-
import { stat as
|
|
2886
|
+
import { stat as stat4 } from "node:fs/promises";
|
|
2585
2887
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
2586
2888
|
|
|
2587
2889
|
// src/claude-config.ts
|
|
@@ -2598,9 +2900,9 @@ var ClaudeDriver = class {
|
|
|
2598
2900
|
this.executable = executable2;
|
|
2599
2901
|
this.executor = executor;
|
|
2600
2902
|
this.transcripts = transcripts;
|
|
2601
|
-
this.
|
|
2903
|
+
this.trustRecord = trust ?? new ClaudeTrust((folder) => this.executor.environment(false, folder));
|
|
2602
2904
|
}
|
|
2603
|
-
|
|
2905
|
+
trustRecord;
|
|
2604
2906
|
repositorySetup(folder) {
|
|
2605
2907
|
return {
|
|
2606
2908
|
instruction: "Run claude in the repository's folder once and accept its trust prompt.",
|
|
@@ -2668,19 +2970,25 @@ var ClaudeDriver = class {
|
|
|
2668
2970
|
"launch",
|
|
2669
2971
|
seeding
|
|
2670
2972
|
);
|
|
2973
|
+
const id = /backgrounded\s*·\s*([A-Za-z0-9_-]+)(?=\s*(?:·|$))/m.exec(result.stdout)?.[1];
|
|
2974
|
+
if (id) {
|
|
2975
|
+
const sessionId = opaque(id);
|
|
2976
|
+
this.trustRecord.mark(folder, "trusted");
|
|
2977
|
+
if (result.code !== 0)
|
|
2978
|
+
console.error(
|
|
2979
|
+
`Claude Code background launch exited with code ${result.code}; tracking returned session`
|
|
2980
|
+
);
|
|
2981
|
+
return sessionId;
|
|
2982
|
+
}
|
|
2671
2983
|
if (result.code !== 0) {
|
|
2672
2984
|
if (/Workspace not trusted/i.test(result.stdout + result.stderr)) {
|
|
2673
|
-
this.
|
|
2985
|
+
this.trustRecord.mark(folder, "untrusted");
|
|
2674
2986
|
throw new HarnessRefusal("workspace_untrusted");
|
|
2675
2987
|
}
|
|
2676
2988
|
if (await this.signedIn(folder) === false) throw new HarnessRefusal("not_signed_in");
|
|
2677
2989
|
throw new HarnessRefusal("harness_exited");
|
|
2678
2990
|
}
|
|
2679
|
-
|
|
2680
|
-
if (!id) throw new Error("Uncertain launch result; inspect local harness");
|
|
2681
|
-
const sessionId = opaque(id);
|
|
2682
|
-
this.trust.mark(folder, "trusted");
|
|
2683
|
-
return sessionId;
|
|
2991
|
+
throw new Error("Uncertain launch result; inspect local harness");
|
|
2684
2992
|
}
|
|
2685
2993
|
async list(folder, _requireLive, query) {
|
|
2686
2994
|
return (await this.readSessions(folder, query, false)).map((row) => row.session);
|
|
@@ -2690,7 +2998,7 @@ var ClaudeDriver = class {
|
|
|
2690
2998
|
const fallback = [];
|
|
2691
2999
|
for (const folder of new Set(folders)) {
|
|
2692
3000
|
try {
|
|
2693
|
-
if (!(await
|
|
3001
|
+
if (!(await stat4(folder)).isDirectory())
|
|
2694
3002
|
throw new Error("Session folder unavailable");
|
|
2695
3003
|
const env = await this.executor.environment(false, folder);
|
|
2696
3004
|
const configDir = claudeConfigDirectory(env);
|
|
@@ -2831,7 +3139,10 @@ var ClaudeDriver = class {
|
|
|
2831
3139
|
attachHint(id) {
|
|
2832
3140
|
return { harness: HARNESS_KIND.CLAUDE_CODE, session_ref: opaque(id) };
|
|
2833
3141
|
}
|
|
2834
|
-
|
|
3142
|
+
trust(folders, read) {
|
|
3143
|
+
return this.trustRecord.repositories(folders, read);
|
|
3144
|
+
}
|
|
3145
|
+
async repositories(folders, read = "fresh") {
|
|
2835
3146
|
const readiness = new Map(
|
|
2836
3147
|
await Promise.all(
|
|
2837
3148
|
[...new Set(Object.values(folders))].map(async (folder) => {
|
|
@@ -2850,7 +3161,7 @@ var ClaudeDriver = class {
|
|
|
2850
3161
|
})
|
|
2851
3162
|
)
|
|
2852
3163
|
);
|
|
2853
|
-
return (await this.
|
|
3164
|
+
return (await this.trustRecord.repositories(folders, read)).map((row) => {
|
|
2854
3165
|
const detection = readiness.get(folders[repositoryKey(row.repository)]);
|
|
2855
3166
|
return {
|
|
2856
3167
|
...row,
|
|
@@ -3125,13 +3436,40 @@ import { homedir as homedir7 } from "node:os";
|
|
|
3125
3436
|
import { basename as basename3, dirname as dirname3, join as join7, resolve as resolve5 } from "node:path";
|
|
3126
3437
|
import { parseToml } from "./vendor.js";
|
|
3127
3438
|
var MAX_CONFIG_BYTES2 = 4 * 1024 * 1024;
|
|
3439
|
+
var configPath = (env) => join7(env["CODEX_HOME"] ?? join7(env["HOME"] ?? homedir7(), ".codex"), "config.toml");
|
|
3440
|
+
var IGNORE = async () => {
|
|
3441
|
+
};
|
|
3128
3442
|
var CodexTrust = class {
|
|
3129
|
-
constructor(executor) {
|
|
3443
|
+
constructor(executor, cache = new TrustCache()) {
|
|
3130
3444
|
this.executor = executor;
|
|
3445
|
+
this.cache = cache;
|
|
3446
|
+
}
|
|
3447
|
+
/** The folder's trust read now, uncached, as a launch needs it. */
|
|
3448
|
+
read(folder) {
|
|
3449
|
+
return this.full(folder, IGNORE);
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* One facts check's reads. A cached answer stands while `config.toml` is unchanged, which
|
|
3453
|
+
* skips the three git commands too: a folder that becomes a repository, or a worktree that
|
|
3454
|
+
* moves, under an unchanged config is seen at the next fresh read (a recheck, a reconnect)
|
|
3455
|
+
* or once the answer reaches TRUST_CACHE_MAX_AGE_MS.
|
|
3456
|
+
*/
|
|
3457
|
+
reads(read) {
|
|
3458
|
+
const pass = this.cache.pass(read);
|
|
3459
|
+
return async (folder) => {
|
|
3460
|
+
try {
|
|
3461
|
+
const path = configPath(await this.executor.environment(false, folder));
|
|
3462
|
+
return await pass.get(`${folder}\0${path}`, (watch2) => this.full(folder, watch2));
|
|
3463
|
+
} catch {
|
|
3464
|
+
return "unknown";
|
|
3465
|
+
}
|
|
3466
|
+
};
|
|
3131
3467
|
}
|
|
3132
|
-
async
|
|
3468
|
+
async full(folder, watch2) {
|
|
3133
3469
|
try {
|
|
3134
3470
|
const env = await this.executor.environment(false, folder);
|
|
3471
|
+
const path = configPath(env);
|
|
3472
|
+
await watch2(path);
|
|
3135
3473
|
const root = await this.executor.execute(
|
|
3136
3474
|
"git",
|
|
3137
3475
|
["rev-parse", "--show-toplevel"],
|
|
@@ -3151,17 +3489,13 @@ var CodexTrust = class {
|
|
|
3151
3489
|
folder
|
|
3152
3490
|
);
|
|
3153
3491
|
if (root.code !== 0 || prefix.code !== 0) return "unknown";
|
|
3154
|
-
const
|
|
3492
|
+
const canonical3 = await realpath4(root.stdout.trim());
|
|
3155
3493
|
const commonDir = common.code === 0 ? common.stdout.trim() : "";
|
|
3156
|
-
const main = basename3(commonDir) === ".git" ? await realpath4(dirname3(commonDir)) :
|
|
3494
|
+
const main = basename3(commonDir) === ".git" ? await realpath4(dirname3(commonDir)) : canonical3;
|
|
3157
3495
|
let given = resolve5(folder);
|
|
3158
3496
|
for (const part of prefix.stdout.trim().split("/").filter(Boolean)) {
|
|
3159
3497
|
if (part) given = dirname3(given);
|
|
3160
3498
|
}
|
|
3161
|
-
const path = join7(
|
|
3162
|
-
env["CODEX_HOME"] ?? join7(env["HOME"] ?? homedir7(), ".codex"),
|
|
3163
|
-
"config.toml"
|
|
3164
|
-
);
|
|
3165
3499
|
const file = await open4(path, "r");
|
|
3166
3500
|
let contents;
|
|
3167
3501
|
try {
|
|
@@ -3185,7 +3519,7 @@ var CodexTrust = class {
|
|
|
3185
3519
|
}
|
|
3186
3520
|
const projects = parseToml(contents)["projects"];
|
|
3187
3521
|
if (!isObject(projects)) return "unknown";
|
|
3188
|
-
for (const spelling of /* @__PURE__ */ new Set([
|
|
3522
|
+
for (const spelling of /* @__PURE__ */ new Set([canonical3, given, main])) {
|
|
3189
3523
|
const project = Object.hasOwn(projects, spelling) ? field(projects, spelling) : null;
|
|
3190
3524
|
const trust = isObject(project) ? field(project, "trust_level") : null;
|
|
3191
3525
|
if (trust === "trusted" || trust === "untrusted") return trust;
|
|
@@ -3539,9 +3873,9 @@ async function listCodexSessions(server, folder, query, activity) {
|
|
|
3539
3873
|
// src/codex-driver.ts
|
|
3540
3874
|
var MINIMUM_CODEX_VERSION = "0.162.1";
|
|
3541
3875
|
function supportedCodexVersion(version) {
|
|
3542
|
-
const
|
|
3876
|
+
const parts2 = (text5) => (text5.split(/[-+]/)[0] ?? "").split(".").map(Number);
|
|
3543
3877
|
if (!version) return true;
|
|
3544
|
-
const found =
|
|
3878
|
+
const found = parts2(version), minimum = parts2(MINIMUM_CODEX_VERSION);
|
|
3545
3879
|
for (const [index, part] of minimum.entries()) {
|
|
3546
3880
|
const value = found[index] ?? 0;
|
|
3547
3881
|
if (value !== part) return value > part;
|
|
@@ -3580,7 +3914,7 @@ var CodexDriver = class {
|
|
|
3580
3914
|
constructor(env, executable2 = "codex", executor = new HarnessExecutor(env), timeouts = {}) {
|
|
3581
3915
|
this.executable = executable2;
|
|
3582
3916
|
this.executor = executor;
|
|
3583
|
-
this.
|
|
3917
|
+
this.trustRecord = new CodexTrust(executor);
|
|
3584
3918
|
this.timeouts = { ...CODEX_TIMEOUTS, ...timeouts };
|
|
3585
3919
|
}
|
|
3586
3920
|
repositorySetup(folder) {
|
|
@@ -3605,7 +3939,7 @@ var CodexDriver = class {
|
|
|
3605
3939
|
answer_input: false,
|
|
3606
3940
|
stop_starting: true
|
|
3607
3941
|
};
|
|
3608
|
-
|
|
3942
|
+
trustRecord;
|
|
3609
3943
|
activity = new CodexActivity();
|
|
3610
3944
|
timeouts;
|
|
3611
3945
|
async detect(folder) {
|
|
@@ -3644,7 +3978,7 @@ var CodexDriver = class {
|
|
|
3644
3978
|
return detection;
|
|
3645
3979
|
}
|
|
3646
3980
|
async requireTrusted(folder) {
|
|
3647
|
-
if (await this.
|
|
3981
|
+
if (await this.trustRecord.read(folder) !== "trusted")
|
|
3648
3982
|
throw new HarnessRefusal("workspace_untrusted");
|
|
3649
3983
|
}
|
|
3650
3984
|
async open(folder, requireLive) {
|
|
@@ -3822,20 +4156,31 @@ var CodexDriver = class {
|
|
|
3822
4156
|
attachHint(id) {
|
|
3823
4157
|
return { harness: HARNESS_KIND.CODEX, session_ref: codexId(id) };
|
|
3824
4158
|
}
|
|
3825
|
-
async repositories(folders) {
|
|
4159
|
+
async repositories(folders, read = "fresh") {
|
|
4160
|
+
const trust = this.trustRecord.reads(read);
|
|
3826
4161
|
return Promise.all(
|
|
3827
4162
|
Object.entries(folders).sort(([a], [b]) => a.localeCompare(b)).map(async ([slug, folder]) => {
|
|
3828
4163
|
const detection = await this.probe(folder);
|
|
3829
4164
|
return {
|
|
3830
4165
|
harness: HARNESS_KIND.CODEX,
|
|
3831
4166
|
repository: repositoryFromKey(slug),
|
|
3832
|
-
trust: await
|
|
4167
|
+
trust: await trust(folder),
|
|
3833
4168
|
available: detection.available,
|
|
3834
4169
|
signed_in: detection.signed_in ?? null
|
|
3835
4170
|
};
|
|
3836
4171
|
})
|
|
3837
4172
|
);
|
|
3838
4173
|
}
|
|
4174
|
+
async trust(folders, read) {
|
|
4175
|
+
const trust = this.trustRecord.reads(read);
|
|
4176
|
+
return Promise.all(
|
|
4177
|
+
Object.entries(folders).sort(([a], [b]) => a.localeCompare(b)).map(async ([slug, folder]) => ({
|
|
4178
|
+
harness: HARNESS_KIND.CODEX,
|
|
4179
|
+
repository: repositoryFromKey(slug),
|
|
4180
|
+
trust: await trust(folder)
|
|
4181
|
+
}))
|
|
4182
|
+
);
|
|
4183
|
+
}
|
|
3839
4184
|
};
|
|
3840
4185
|
|
|
3841
4186
|
// src/cursor-agent.ts
|
|
@@ -3845,9 +4190,9 @@ import { basename as basename4, dirname as dirname4, join as join8 } from "node:
|
|
|
3845
4190
|
var MINIMUM_CURSOR_VERSION = "2026.10.19";
|
|
3846
4191
|
var MAX_RECORD_BYTES = 64 * 1024;
|
|
3847
4192
|
function supportedVersion(version) {
|
|
3848
|
-
const
|
|
4193
|
+
const parts2 = (text5) => (text5.split(/[-+]/)[0] ?? "").split(".").map(Number);
|
|
3849
4194
|
if (!version) return true;
|
|
3850
|
-
const found =
|
|
4195
|
+
const found = parts2(version), minimum = parts2(MINIMUM_CURSOR_VERSION);
|
|
3851
4196
|
for (const [index, part] of minimum.entries()) {
|
|
3852
4197
|
const value = found[index] ?? 0;
|
|
3853
4198
|
if (value !== part) return value > part;
|
|
@@ -3891,14 +4236,20 @@ var CursorAgent = class {
|
|
|
3891
4236
|
* The folder's own record, then, for a linked worktree, its main repository's: the
|
|
3892
4237
|
* gateway's attempt worktrees are new folders no one can have trusted ahead of time.
|
|
3893
4238
|
*/
|
|
3894
|
-
async trust(executor, folder) {
|
|
4239
|
+
async trust(executor, folder, watch2 = async () => {
|
|
4240
|
+
}) {
|
|
3895
4241
|
try {
|
|
3896
4242
|
const env = await executor.environment(false, folder);
|
|
3897
4243
|
const root = env["CURSOR_CONFIG_DIR"] ?? join8(env["HOME"] ?? homedir8(), ".cursor");
|
|
3898
4244
|
const trusted = async (spelling) => {
|
|
3899
|
-
const
|
|
3900
|
-
|
|
4245
|
+
const path = join8(
|
|
4246
|
+
root,
|
|
4247
|
+
"projects",
|
|
4248
|
+
cursorProjectKey(spelling),
|
|
4249
|
+
".workspace-trusted"
|
|
3901
4250
|
);
|
|
4251
|
+
await watch2(path);
|
|
4252
|
+
const record = await readRecord(path);
|
|
3902
4253
|
return isObject(record) && field(record, "workspacePath") === spelling;
|
|
3903
4254
|
};
|
|
3904
4255
|
for (const spelling of /* @__PURE__ */ new Set([await realpath7(folder), folder]))
|
|
@@ -3968,6 +4319,10 @@ var HarnessRegistry = class {
|
|
|
3968
4319
|
([harness, driver]) => ({ harness, ...driver.repositorySetup(folder) })
|
|
3969
4320
|
);
|
|
3970
4321
|
}
|
|
4322
|
+
/** Every harness this gateway drives. */
|
|
4323
|
+
kinds() {
|
|
4324
|
+
return Object.keys(this.drivers);
|
|
4325
|
+
}
|
|
3971
4326
|
async detect() {
|
|
3972
4327
|
return Promise.all(Object.values(this.drivers).map((driver) => driver.detect()));
|
|
3973
4328
|
}
|
|
@@ -3977,11 +4332,16 @@ var HarnessRegistry = class {
|
|
|
3977
4332
|
async dispose() {
|
|
3978
4333
|
await Promise.all(Object.values(this.drivers).map((driver) => driver.dispose?.()));
|
|
3979
4334
|
}
|
|
3980
|
-
|
|
4335
|
+
/** Each registered folder's readiness for `harnesses`, every harness unless named. */
|
|
4336
|
+
async repositories(folders, harnesses = this.kinds(), read = "fresh") {
|
|
3981
4337
|
return (await Promise.all(
|
|
3982
|
-
|
|
4338
|
+
harnesses.map((harness) => this.get(harness).repositories(folders, read))
|
|
3983
4339
|
)).flat();
|
|
3984
4340
|
}
|
|
4341
|
+
/** Each registered folder's trust for `harnesses`, with no harness command. */
|
|
4342
|
+
async trust(folders, harnesses, read) {
|
|
4343
|
+
return (await Promise.all(harnesses.map((harness) => this.get(harness).trust(folders, read)))).flat();
|
|
4344
|
+
}
|
|
3985
4345
|
};
|
|
3986
4346
|
|
|
3987
4347
|
// src/builtin-harnesses.ts
|
|
@@ -4574,6 +4934,89 @@ async function createBranch(git, context, requireLive) {
|
|
|
4574
4934
|
return !local && !prior;
|
|
4575
4935
|
}
|
|
4576
4936
|
|
|
4937
|
+
// src/invocation.ts
|
|
4938
|
+
import { accessSync, constants as constants5, realpathSync, statSync } from "node:fs";
|
|
4939
|
+
import { posix as posix3, win32 } from "node:path";
|
|
4940
|
+
import { fileURLToPath } from "node:url";
|
|
4941
|
+
var PACKAGE = "@treestructuredplanning/gateway";
|
|
4942
|
+
var INSTALLED = "tsp-gateway";
|
|
4943
|
+
var NPX_LATEST = `npx -y ${PACKAGE}@latest`;
|
|
4944
|
+
function launchedByNpx(entry2) {
|
|
4945
|
+
return entry2.split(/[\\/]/).includes("_npx");
|
|
4946
|
+
}
|
|
4947
|
+
function gatewayInstall(entry2, env = process.env, platform = process.platform) {
|
|
4948
|
+
const command2 = commandPath(entry2, env, platform);
|
|
4949
|
+
return command2.onPath && command2.matches ? GATEWAY_INSTALL.GLOBAL : GATEWAY_INSTALL.NPX;
|
|
4950
|
+
}
|
|
4951
|
+
var RUNNER = {
|
|
4952
|
+
[GATEWAY_INSTALL.GLOBAL]: INSTALLED,
|
|
4953
|
+
[GATEWAY_INSTALL.NPX]: NPX_LATEST
|
|
4954
|
+
};
|
|
4955
|
+
function invocation(entry2, env = process.env, platform = process.platform) {
|
|
4956
|
+
return RUNNER[gatewayInstall(entry2, env, platform)];
|
|
4957
|
+
}
|
|
4958
|
+
var REFRESHES = /* @__PURE__ */ new Set(["connect", "start", "update"]);
|
|
4959
|
+
function gateway(args, entry2, version = package_default.version, env = process.env, platform = process.platform) {
|
|
4960
|
+
const install2 = entry2 === void 0 ? OWN_INSTALL : gatewayInstall(entry2, env, platform);
|
|
4961
|
+
const runner = install2 === GATEWAY_INSTALL.NPX && !REFRESHES.has(args.split(/\s/)[0] ?? "") ? `npx -y ${PACKAGE}@${version}` : RUNNER[install2];
|
|
4962
|
+
return `${runner} ${args}`;
|
|
4963
|
+
}
|
|
4964
|
+
var GLOBAL_TAIL = ["node_modules", ...PACKAGE.split("/"), "dist", "cli.js"];
|
|
4965
|
+
function globalCommandFolder(entry2, platform) {
|
|
4966
|
+
const parts2 = realPath(entry2).split(/[\\/]/);
|
|
4967
|
+
const head = parts2.length - GLOBAL_TAIL.length;
|
|
4968
|
+
if (head < 1 || GLOBAL_TAIL.some((part, index) => parts2[head + index] !== part)) return null;
|
|
4969
|
+
if (platform === "win32") return parts2.slice(0, head).join("\\");
|
|
4970
|
+
if (parts2[head - 1] !== "lib") return null;
|
|
4971
|
+
return [...parts2.slice(0, head - 1), "bin"].join("/");
|
|
4972
|
+
}
|
|
4973
|
+
function realPath(value) {
|
|
4974
|
+
try {
|
|
4975
|
+
return realpathSync(value);
|
|
4976
|
+
} catch {
|
|
4977
|
+
return value;
|
|
4978
|
+
}
|
|
4979
|
+
}
|
|
4980
|
+
function canonical(value, platform) {
|
|
4981
|
+
const path = platform === "win32" ? win32 : posix3;
|
|
4982
|
+
const real = realPath(path.resolve(value));
|
|
4983
|
+
return platform === "win32" ? real.toLowerCase() : real;
|
|
4984
|
+
}
|
|
4985
|
+
function commandPath(entry2, env, platform) {
|
|
4986
|
+
const folder = globalCommandFolder(entry2, platform);
|
|
4987
|
+
if (folder === null) return { folder, onPath: false, matches: false };
|
|
4988
|
+
const path = platform === "win32" ? win32 : posix3;
|
|
4989
|
+
const wanted = canonical(folder, platform);
|
|
4990
|
+
const extensions = platform === "win32" ? (env["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD").split(";") : [""];
|
|
4991
|
+
let onPath = false;
|
|
4992
|
+
let found = false;
|
|
4993
|
+
let matches2 = false;
|
|
4994
|
+
for (const candidate of (env["PATH"] ?? env["Path"])?.split(path.delimiter) ?? []) {
|
|
4995
|
+
const directory = (platform === "win32" ? candidate.replace(/^"(.*)"$/, "$1") : candidate) || ".";
|
|
4996
|
+
if (canonical(directory, platform) === wanted) onPath = true;
|
|
4997
|
+
if (found) continue;
|
|
4998
|
+
for (const extension of extensions) {
|
|
4999
|
+
const command2 = path.join(directory, `${INSTALLED}${extension}`);
|
|
5000
|
+
try {
|
|
5001
|
+
if (!statSync(command2).isFile()) continue;
|
|
5002
|
+
accessSync(command2, platform === "win32" ? constants5.F_OK : constants5.X_OK);
|
|
5003
|
+
found = true;
|
|
5004
|
+
matches2 = canonical(directory, platform) === wanted && (platform === "win32" || canonical(command2, platform) === canonical(entry2, platform));
|
|
5005
|
+
break;
|
|
5006
|
+
} catch {
|
|
5007
|
+
continue;
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
}
|
|
5011
|
+
return { folder, onPath, matches: matches2 };
|
|
5012
|
+
}
|
|
5013
|
+
async function commandFolderOffPath(entry2, env, platform) {
|
|
5014
|
+
const command2 = commandPath(entry2, env, platform);
|
|
5015
|
+
return command2.onPath ? null : command2.folder;
|
|
5016
|
+
}
|
|
5017
|
+
var OWN_ENTRY = fileURLToPath(new URL("./cli.js", import.meta.url));
|
|
5018
|
+
var OWN_INSTALL = gatewayInstall(OWN_ENTRY);
|
|
5019
|
+
|
|
4577
5020
|
// src/cli-output.ts
|
|
4578
5021
|
import { styleText } from "node:util";
|
|
4579
5022
|
var MARKS = {
|
|
@@ -4651,7 +5094,7 @@ var ActionableError = class extends Error {
|
|
|
4651
5094
|
};
|
|
4652
5095
|
var UsageError = class extends Error {
|
|
4653
5096
|
constructor(usage) {
|
|
4654
|
-
super(`Usage: ${usage}`);
|
|
5097
|
+
super(`Usage: ${gateway(usage)}`);
|
|
4655
5098
|
this.usage = usage;
|
|
4656
5099
|
this.name = "UsageError";
|
|
4657
5100
|
}
|
|
@@ -4660,8 +5103,8 @@ function errorLines(error) {
|
|
|
4660
5103
|
if (error instanceof UsageError)
|
|
4661
5104
|
return [
|
|
4662
5105
|
marked("fail", "That command takes different arguments. Usage:"),
|
|
4663
|
-
command(error.usage, 2),
|
|
4664
|
-
note("
|
|
5106
|
+
command(gateway(error.usage), 2),
|
|
5107
|
+
note(`${gateway("--help")} lists every command.`, 1)
|
|
4665
5108
|
];
|
|
4666
5109
|
const message = error instanceof Error ? error.message : "Gateway could not complete the command";
|
|
4667
5110
|
return [
|
|
@@ -4720,14 +5163,14 @@ async function printWorktreeRoots(config, executor, print = (lines) => writeLine
|
|
|
4720
5163
|
function connectWorktreeArgs(args) {
|
|
4721
5164
|
if (args.length <= 2) return args[1] ? { folder: args[1] } : {};
|
|
4722
5165
|
if (args.length !== 4 || args[2] !== "--worktrees-root")
|
|
4723
|
-
throw new UsageError("
|
|
5166
|
+
throw new UsageError("connect [folder] [--worktrees-root <path>]");
|
|
4724
5167
|
const root = decodeWorktreeRoot(args[3], resolve11(args[1]));
|
|
4725
5168
|
if (root === null) throw new Error("A worktree root is required");
|
|
4726
5169
|
return { folder: args[1], root };
|
|
4727
5170
|
}
|
|
4728
5171
|
async function setWorktreeRoot(config, path, args) {
|
|
4729
5172
|
if (args[1] !== "worktrees-root" || !(args.length === 3 && !args[2].startsWith("--repo") || args.length === 5 && args[2] === "--repo"))
|
|
4730
|
-
throw new UsageError("
|
|
5173
|
+
throw new UsageError("config worktrees-root [--repo <folder>] <path|--reset>");
|
|
4731
5174
|
const value = args.at(-1);
|
|
4732
5175
|
const root = value === "--reset" ? null : value;
|
|
4733
5176
|
if (args.length === 5) {
|
|
@@ -4735,7 +5178,7 @@ async function setWorktreeRoot(config, path, args) {
|
|
|
4735
5178
|
const entry2 = Object.values(config.repositories).find((entry3) => entry3.folder === folder);
|
|
4736
5179
|
if (!entry2)
|
|
4737
5180
|
throw new Error(
|
|
4738
|
-
|
|
5181
|
+
`Repository folder is not registered. Run ${gateway("add <folder>")} first.`
|
|
4739
5182
|
);
|
|
4740
5183
|
entry2.worktreeRoot = decodeWorktreeRoot(root, folder);
|
|
4741
5184
|
} else config.worktrees.root = decodeWorktreeRoot(root);
|
|
@@ -4753,7 +5196,7 @@ async function worktreesCommand({
|
|
|
4753
5196
|
args
|
|
4754
5197
|
}) {
|
|
4755
5198
|
if (args[0] === "config") await setWorktreeRoot(config, paths.config, args);
|
|
4756
|
-
else if (args.length !== 1) throw new UsageError("
|
|
5199
|
+
else if (args.length !== 1) throw new UsageError("worktrees");
|
|
4757
5200
|
await printWorktreeRoots(config, executor);
|
|
4758
5201
|
}
|
|
4759
5202
|
|
|
@@ -5114,10 +5557,10 @@ function absoluteFolder(value) {
|
|
|
5114
5557
|
}
|
|
5115
5558
|
|
|
5116
5559
|
// src/journal.ts
|
|
5117
|
-
function
|
|
5118
|
-
if (Array.isArray(value)) return `[${value.map((item) =>
|
|
5560
|
+
function canonical2(value) {
|
|
5561
|
+
if (Array.isArray(value)) return `[${value.map((item) => canonical2(item)).join(",")}]`;
|
|
5119
5562
|
if (isObject(value))
|
|
5120
|
-
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${
|
|
5563
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical2(field(value, key))}`).join(",")}}`;
|
|
5121
5564
|
return JSON.stringify(value);
|
|
5122
5565
|
}
|
|
5123
5566
|
function commandDigest(command2) {
|
|
@@ -5126,7 +5569,7 @@ function commandDigest(command2) {
|
|
|
5126
5569
|
ttl_ms: null,
|
|
5127
5570
|
...command2.kind === "resume" ? { text: command2.text ?? null } : {}
|
|
5128
5571
|
};
|
|
5129
|
-
return createHash("sha256").update(
|
|
5572
|
+
return createHash("sha256").update(canonical2(identity2)).digest("hex");
|
|
5130
5573
|
}
|
|
5131
5574
|
var Journal = class {
|
|
5132
5575
|
constructor(path) {
|
|
@@ -5366,9 +5809,9 @@ async function observeSessions(drivers, contexts, activity = false) {
|
|
|
5366
5809
|
}))
|
|
5367
5810
|
);
|
|
5368
5811
|
for (const folder of listing.folders) {
|
|
5369
|
-
const
|
|
5812
|
+
const canonical3 = await realLocation(folder);
|
|
5370
5813
|
folders.set(folder, {
|
|
5371
|
-
sessions: canonicalSessions.filter((row) => row.folder ===
|
|
5814
|
+
sessions: canonicalSessions.filter((row) => row.folder === canonical3).map((row) => row.session),
|
|
5372
5815
|
listed: listing.listed
|
|
5373
5816
|
});
|
|
5374
5817
|
}
|
|
@@ -5836,7 +6279,7 @@ var Commands = class {
|
|
|
5836
6279
|
};
|
|
5837
6280
|
|
|
5838
6281
|
// src/config-watch.ts
|
|
5839
|
-
import { statSync, watch } from "node:fs";
|
|
6282
|
+
import { statSync as statSync2, watch } from "node:fs";
|
|
5840
6283
|
import { basename as basename5, dirname as dirname8 } from "node:path";
|
|
5841
6284
|
var watchDirectory = (directory, listener) => watch(directory, (_, filename) => listener(filename));
|
|
5842
6285
|
function watchConfig(path, changed, options = {}) {
|
|
@@ -5872,18 +6315,18 @@ function watchConfig(path, changed, options = {}) {
|
|
|
5872
6315
|
};
|
|
5873
6316
|
}
|
|
5874
6317
|
function identity(path) {
|
|
5875
|
-
const
|
|
5876
|
-
return
|
|
6318
|
+
const stat6 = statSync2(path, { bigint: true, throwIfNoEntry: false });
|
|
6319
|
+
return stat6 === void 0 ? "absent" : `${stat6.ino}:${stat6.mtimeNs}:${stat6.size}`;
|
|
5877
6320
|
}
|
|
5878
6321
|
|
|
5879
6322
|
// src/connection-state.ts
|
|
5880
6323
|
var START = {
|
|
5881
6324
|
instruction: "Start the gateway now and at login",
|
|
5882
|
-
command: "
|
|
6325
|
+
command: gateway("start")
|
|
5883
6326
|
};
|
|
5884
6327
|
var CONNECT = {
|
|
5885
6328
|
instruction: "Connect this computer again",
|
|
5886
|
-
command: "
|
|
6329
|
+
command: gateway("connect")
|
|
5887
6330
|
};
|
|
5888
6331
|
var CONNECTION = {
|
|
5889
6332
|
connected: { message: "Connected", text: "Connected to TSP", mark: "pass" },
|
|
@@ -5897,31 +6340,28 @@ var CONNECTION = {
|
|
|
5897
6340
|
notRunning: { message: "Not running", text: "Not running", mark: "fail", next: START },
|
|
5898
6341
|
stopped: { message: "Stopped", text: "Not running", mark: "fail", next: START },
|
|
5899
6342
|
refreshFailed: {
|
|
5900
|
-
message: "Token refresh failed
|
|
6343
|
+
message: "Token refresh failed",
|
|
5901
6344
|
text: "TSP no longer accepts this computer's credential",
|
|
5902
6345
|
mark: "fail",
|
|
5903
6346
|
next: CONNECT
|
|
5904
6347
|
},
|
|
5905
6348
|
tokenRejected: {
|
|
5906
|
-
message: "Token rejected after refresh
|
|
6349
|
+
message: "Token rejected after refresh",
|
|
5907
6350
|
text: "TSP rejected this computer's credential",
|
|
5908
6351
|
mark: "fail",
|
|
5909
6352
|
next: CONNECT
|
|
5910
6353
|
},
|
|
5911
6354
|
accessEnded: {
|
|
5912
|
-
message: "Machine access ended
|
|
6355
|
+
message: "Machine access ended",
|
|
5913
6356
|
text: "This computer's access to TSP ended",
|
|
5914
6357
|
mark: "fail",
|
|
5915
6358
|
next: CONNECT
|
|
5916
6359
|
},
|
|
5917
6360
|
outdated: {
|
|
5918
|
-
message: "This gateway is outdated
|
|
6361
|
+
message: "This gateway is outdated",
|
|
5919
6362
|
text: "This gateway is outdated",
|
|
5920
6363
|
mark: "fail",
|
|
5921
|
-
next: {
|
|
5922
|
-
instruction: "Update it",
|
|
5923
|
-
command: "npx -y @treestructuredplanning/gateway@latest update"
|
|
5924
|
-
}
|
|
6364
|
+
next: { instruction: "Update it", command: gateway("update") }
|
|
5925
6365
|
}
|
|
5926
6366
|
};
|
|
5927
6367
|
function connectionState(message) {
|
|
@@ -5981,10 +6421,201 @@ var LaunchPermits = class {
|
|
|
5981
6421
|
}
|
|
5982
6422
|
};
|
|
5983
6423
|
|
|
6424
|
+
// src/sign-in-schedule.ts
|
|
6425
|
+
var SIGN_IN_SCHEDULE = {
|
|
6426
|
+
closeWaitsMs: [5e3, 5e3, 1e4, 2e4, 4e4],
|
|
6427
|
+
easedWaitMs: 6e4,
|
|
6428
|
+
limitMs: 5 * 6e4
|
|
6429
|
+
};
|
|
6430
|
+
function nextSignInCheck(checks, schedule = SIGN_IN_SCHEDULE) {
|
|
6431
|
+
let elapsed = 0;
|
|
6432
|
+
for (let made = 0; made <= checks; made++) {
|
|
6433
|
+
const wait = schedule.closeWaitsMs[made] ?? schedule.easedWaitMs;
|
|
6434
|
+
if (elapsed + wait > schedule.limitMs) return null;
|
|
6435
|
+
if (made === checks) return wait;
|
|
6436
|
+
elapsed += wait;
|
|
6437
|
+
}
|
|
6438
|
+
return null;
|
|
6439
|
+
}
|
|
6440
|
+
function signInCheckAfter(checks, schedule = SIGN_IN_SCHEDULE) {
|
|
6441
|
+
return checks < schedule.closeWaitsMs.length && nextSignInCheck(checks, schedule) !== null ? "close" : "eased";
|
|
6442
|
+
}
|
|
6443
|
+
var SignInChecks = class {
|
|
6444
|
+
constructor(due, schedule = SIGN_IN_SCHEDULE) {
|
|
6445
|
+
this.due = due;
|
|
6446
|
+
this.schedule = schedule;
|
|
6447
|
+
}
|
|
6448
|
+
tracked = /* @__PURE__ */ new Map();
|
|
6449
|
+
/** Follows a full detection: checks each harness newly found signed out, and forgets the rest. */
|
|
6450
|
+
observe(capabilities) {
|
|
6451
|
+
const signedOut = new Set(
|
|
6452
|
+
capabilities.filter((row) => row.available && row.signed_in === false).map((row) => row.harness)
|
|
6453
|
+
);
|
|
6454
|
+
for (const harness of [...this.tracked.keys()])
|
|
6455
|
+
if (!signedOut.has(harness)) this.forget(harness);
|
|
6456
|
+
for (const harness of signedOut) if (!this.tracked.has(harness)) this.start(harness);
|
|
6457
|
+
}
|
|
6458
|
+
/** Checks closely again from the top: one tracked harness, or every one. */
|
|
6459
|
+
restart(harness) {
|
|
6460
|
+
for (const kind of harness === void 0 ? [...this.tracked.keys()] : [harness]) {
|
|
6461
|
+
if (!this.tracked.has(kind)) continue;
|
|
6462
|
+
this.forget(kind);
|
|
6463
|
+
this.start(kind);
|
|
6464
|
+
}
|
|
6465
|
+
}
|
|
6466
|
+
/** Records a check of `harness` and schedules the next, or stops. */
|
|
6467
|
+
checked(harness) {
|
|
6468
|
+
const entry2 = this.tracked.get(harness);
|
|
6469
|
+
if (!entry2) return;
|
|
6470
|
+
entry2.checks += 1;
|
|
6471
|
+
this.arm(harness, entry2);
|
|
6472
|
+
}
|
|
6473
|
+
tracks(harness) {
|
|
6474
|
+
return this.tracked.has(harness);
|
|
6475
|
+
}
|
|
6476
|
+
/** Checking this harness has stopped, so nothing reads its sign-in until something asks. */
|
|
6477
|
+
stopped(harness) {
|
|
6478
|
+
const entry2 = this.tracked.get(harness);
|
|
6479
|
+
return entry2 !== void 0 && nextSignInCheck(entry2.checks, this.schedule) === null;
|
|
6480
|
+
}
|
|
6481
|
+
/** How closely a tracked harness is being checked, for its advertisement. */
|
|
6482
|
+
check(harness) {
|
|
6483
|
+
const entry2 = this.tracked.get(harness);
|
|
6484
|
+
return entry2 && signInCheckAfter(entry2.checks, this.schedule);
|
|
6485
|
+
}
|
|
6486
|
+
dispose() {
|
|
6487
|
+
for (const harness of [...this.tracked.keys()]) this.forget(harness);
|
|
6488
|
+
}
|
|
6489
|
+
start(harness) {
|
|
6490
|
+
const entry2 = { checks: 0, timer: void 0 };
|
|
6491
|
+
this.tracked.set(harness, entry2);
|
|
6492
|
+
this.arm(harness, entry2);
|
|
6493
|
+
}
|
|
6494
|
+
arm(harness, entry2) {
|
|
6495
|
+
clearTimeout(entry2.timer);
|
|
6496
|
+
const wait = nextSignInCheck(entry2.checks, this.schedule);
|
|
6497
|
+
entry2.timer = wait === null ? void 0 : setTimeout(() => {
|
|
6498
|
+
entry2.timer = void 0;
|
|
6499
|
+
this.due(harness);
|
|
6500
|
+
}, wait);
|
|
6501
|
+
}
|
|
6502
|
+
forget(harness) {
|
|
6503
|
+
clearTimeout(this.tracked.get(harness)?.timer);
|
|
6504
|
+
this.tracked.delete(harness);
|
|
6505
|
+
}
|
|
6506
|
+
};
|
|
6507
|
+
|
|
6508
|
+
// src/machine-facts.ts
|
|
6509
|
+
function machineFacts(options, send, enqueue, state) {
|
|
6510
|
+
let lastAdvertisement;
|
|
6511
|
+
const harnesses = /* @__PURE__ */ new Map();
|
|
6512
|
+
let repositories = [];
|
|
6513
|
+
const publish = (kind) => {
|
|
6514
|
+
const advertisement = {
|
|
6515
|
+
protocol_version: GATEWAY_PROTOCOL_VERSION,
|
|
6516
|
+
gateway_version: options.version,
|
|
6517
|
+
harnesses: [...harnesses.values()].map((row) => {
|
|
6518
|
+
const check = checks.check(row.harness);
|
|
6519
|
+
return check ? { ...row, sign_in_check: check } : row;
|
|
6520
|
+
}),
|
|
6521
|
+
repositories,
|
|
6522
|
+
gateway_install: options.install
|
|
6523
|
+
};
|
|
6524
|
+
const encoded = JSON.stringify(advertisement);
|
|
6525
|
+
if (kind === "hello" || encoded !== lastAdvertisement) {
|
|
6526
|
+
send({ ...advertisement, protocol_version: GATEWAY_PROTOCOL_VERSION, kind });
|
|
6527
|
+
lastAdvertisement = encoded;
|
|
6528
|
+
}
|
|
6529
|
+
};
|
|
6530
|
+
const withTrust = async (quiet, read) => (await options.trust(quiet, read)).map((row) => {
|
|
6531
|
+
const known = repositories.find(
|
|
6532
|
+
(before) => before.harness === row.harness && repositoryKey(before.repository) === repositoryKey(row.repository)
|
|
6533
|
+
);
|
|
6534
|
+
const capability = harnesses.get(row.harness);
|
|
6535
|
+
return {
|
|
6536
|
+
...row,
|
|
6537
|
+
available: known?.available ?? capability?.available ?? false,
|
|
6538
|
+
signed_in: known ? known.signed_in : capability?.signed_in ?? null
|
|
6539
|
+
};
|
|
6540
|
+
});
|
|
6541
|
+
const advertise = async (kind, read = "cached") => {
|
|
6542
|
+
const kinds = options.drivers.kinds();
|
|
6543
|
+
const fresh = kinds.filter((harness) => !checks.stopped(harness));
|
|
6544
|
+
const stopped = kinds.filter((harness) => checks.stopped(harness));
|
|
6545
|
+
for (const row of await Promise.all(
|
|
6546
|
+
fresh.map((harness) => options.drivers.get(harness).detect())
|
|
6547
|
+
))
|
|
6548
|
+
harnesses.set(row.harness, row);
|
|
6549
|
+
const found = await options.repositories(fresh, read);
|
|
6550
|
+
const quiet = stopped.length > 0 ? await withTrust(stopped, read) : [];
|
|
6551
|
+
repositories = kinds.flatMap(
|
|
6552
|
+
(harness) => (fresh.includes(harness) ? found : quiet).filter((row) => row.harness === harness)
|
|
6553
|
+
);
|
|
6554
|
+
checks.observe([...harnesses.values()]);
|
|
6555
|
+
publish(kind);
|
|
6556
|
+
};
|
|
6557
|
+
const refreshFolders = async (harness) => {
|
|
6558
|
+
const rows = await options.repositories([harness], "fresh");
|
|
6559
|
+
repositories = options.drivers.kinds().flatMap(
|
|
6560
|
+
(kind) => (kind === harness ? rows : repositories).filter((row) => row.harness === kind)
|
|
6561
|
+
);
|
|
6562
|
+
};
|
|
6563
|
+
let refreshing = false;
|
|
6564
|
+
let refreshPending = false;
|
|
6565
|
+
const refresh = () => {
|
|
6566
|
+
if (!state.ready()) return;
|
|
6567
|
+
refreshPending = true;
|
|
6568
|
+
if (refreshing) return;
|
|
6569
|
+
refreshing = true;
|
|
6570
|
+
enqueue(async () => {
|
|
6571
|
+
try {
|
|
6572
|
+
refreshPending = false;
|
|
6573
|
+
await advertise("advertise");
|
|
6574
|
+
} finally {
|
|
6575
|
+
refreshing = false;
|
|
6576
|
+
if (refreshPending && state.live()) refresh();
|
|
6577
|
+
}
|
|
6578
|
+
});
|
|
6579
|
+
};
|
|
6580
|
+
const detectSignIn = async (harness, read) => {
|
|
6581
|
+
const detection = await options.drivers.get(harness).detect();
|
|
6582
|
+
harnesses.set(harness, detection);
|
|
6583
|
+
if (!detection.available || detection.signed_in !== false) {
|
|
6584
|
+
checks.observe([...harnesses.values()]);
|
|
6585
|
+
await advertise("advertise", read);
|
|
6586
|
+
return;
|
|
6587
|
+
}
|
|
6588
|
+
if (read === "fresh") await refreshFolders(harness);
|
|
6589
|
+
publish("advertise");
|
|
6590
|
+
};
|
|
6591
|
+
const checks = new SignInChecks((harness) => {
|
|
6592
|
+
enqueue(async () => {
|
|
6593
|
+
if (!checks.tracks(harness)) return;
|
|
6594
|
+
checks.checked(harness);
|
|
6595
|
+
await detectSignIn(harness, "cached");
|
|
6596
|
+
});
|
|
6597
|
+
}, options.signInSchedule);
|
|
6598
|
+
const recheck = (harness) => {
|
|
6599
|
+
enqueue(async () => {
|
|
6600
|
+
checks.restart(harness);
|
|
6601
|
+
if (checks.tracks(harness)) await detectSignIn(harness, "fresh");
|
|
6602
|
+
else await advertise("advertise", "fresh");
|
|
6603
|
+
});
|
|
6604
|
+
};
|
|
6605
|
+
return {
|
|
6606
|
+
advertise,
|
|
6607
|
+
refresh,
|
|
6608
|
+
recheck,
|
|
6609
|
+
restartChecks: () => checks.restart(),
|
|
6610
|
+
stop: () => checks.dispose()
|
|
6611
|
+
};
|
|
6612
|
+
}
|
|
6613
|
+
|
|
5984
6614
|
// src/hub-connection.ts
|
|
5985
6615
|
var STABLE_CONNECTION_MS = 3e4;
|
|
5986
6616
|
var HANDOVER_MS = 2e3;
|
|
5987
6617
|
var REFRESH_LEAD_MS = 15e3;
|
|
6618
|
+
var FACTS_CHECK_MS = 3e4;
|
|
5988
6619
|
function authenticatedSocket(pairing, token) {
|
|
5989
6620
|
const url = new URL(pairing.hub_path, pairing.origin);
|
|
5990
6621
|
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -6051,40 +6682,6 @@ function commandProcessor(commands, permits, retries, send) {
|
|
|
6051
6682
|
for (const result of results) send(result);
|
|
6052
6683
|
};
|
|
6053
6684
|
}
|
|
6054
|
-
function machineFacts(options, send, enqueue, state) {
|
|
6055
|
-
let lastAdvertisement;
|
|
6056
|
-
const advertise = async (kind) => {
|
|
6057
|
-
const advertisement = {
|
|
6058
|
-
protocol_version: GATEWAY_PROTOCOL_VERSION,
|
|
6059
|
-
gateway_version: options.version,
|
|
6060
|
-
harnesses: await options.drivers.detect(),
|
|
6061
|
-
repositories: await options.repositories()
|
|
6062
|
-
};
|
|
6063
|
-
const encoded = JSON.stringify(advertisement);
|
|
6064
|
-
if (kind === "hello" || encoded !== lastAdvertisement) {
|
|
6065
|
-
send({ ...advertisement, protocol_version: GATEWAY_PROTOCOL_VERSION, kind });
|
|
6066
|
-
lastAdvertisement = encoded;
|
|
6067
|
-
}
|
|
6068
|
-
};
|
|
6069
|
-
let refreshing = false;
|
|
6070
|
-
let refreshPending = false;
|
|
6071
|
-
const refresh = () => {
|
|
6072
|
-
if (!state.ready()) return;
|
|
6073
|
-
refreshPending = true;
|
|
6074
|
-
if (refreshing) return;
|
|
6075
|
-
refreshing = true;
|
|
6076
|
-
enqueue(async () => {
|
|
6077
|
-
try {
|
|
6078
|
-
refreshPending = false;
|
|
6079
|
-
await advertise("advertise");
|
|
6080
|
-
} finally {
|
|
6081
|
-
refreshing = false;
|
|
6082
|
-
if (refreshPending && state.live()) refresh();
|
|
6083
|
-
}
|
|
6084
|
-
});
|
|
6085
|
-
};
|
|
6086
|
-
return { advertise, refresh };
|
|
6087
|
-
}
|
|
6088
6685
|
function openConnection(options, setup) {
|
|
6089
6686
|
const socket = authenticatedSocket(options.pairing, setup.credential.token);
|
|
6090
6687
|
let isOpen = true;
|
|
@@ -6140,11 +6737,12 @@ async function serve(options, socket, setup, refreshDue) {
|
|
|
6140
6737
|
});
|
|
6141
6738
|
};
|
|
6142
6739
|
const processCommand = commandProcessor(options.commands, permits, retries, send);
|
|
6143
|
-
const
|
|
6740
|
+
const facts = machineFacts(options, send, enqueue, {
|
|
6144
6741
|
ready: () => ready,
|
|
6145
6742
|
live: () => active && !options.signal.aborted
|
|
6146
6743
|
});
|
|
6147
|
-
const
|
|
6744
|
+
const { advertise, refresh } = facts;
|
|
6745
|
+
const factsInterval = setInterval(refresh, options.advertiseMs ?? FACTS_CHECK_MS);
|
|
6148
6746
|
const unwatch = options.watchFacts?.(refresh);
|
|
6149
6747
|
const polling = sessionPolling(
|
|
6150
6748
|
options,
|
|
@@ -6170,7 +6768,7 @@ async function serve(options, socket, setup, refreshDue) {
|
|
|
6170
6768
|
if (options.signal.aborted) abort();
|
|
6171
6769
|
socket.addEventListener("open", () => {
|
|
6172
6770
|
enqueue(async () => {
|
|
6173
|
-
await advertise("hello");
|
|
6771
|
+
await advertise("hello", "fresh");
|
|
6174
6772
|
clearTimeout(timeout);
|
|
6175
6773
|
for (const receipt of options.commands.durableReceipts()) send(receipt);
|
|
6176
6774
|
await predecessor?.handOver();
|
|
@@ -6199,6 +6797,10 @@ async function serve(options, socket, setup, refreshDue) {
|
|
|
6199
6797
|
});
|
|
6200
6798
|
return;
|
|
6201
6799
|
}
|
|
6800
|
+
if (message.kind === "recheck_sign_in") {
|
|
6801
|
+
facts.recheck(message.harness);
|
|
6802
|
+
return;
|
|
6803
|
+
}
|
|
6202
6804
|
if (message.kind === "permit" || message.kind === "retire") {
|
|
6203
6805
|
permits.receive(message);
|
|
6204
6806
|
if (message.kind === "permit") {
|
|
@@ -6215,7 +6817,10 @@ async function serve(options, socket, setup, refreshDue) {
|
|
|
6215
6817
|
if (message.kind === "retire") {
|
|
6216
6818
|
retries.retire(message.action_id);
|
|
6217
6819
|
await options.commands.retire(message.action_id);
|
|
6218
|
-
} else
|
|
6820
|
+
} else {
|
|
6821
|
+
await processCommand(message);
|
|
6822
|
+
facts.restartChecks();
|
|
6823
|
+
}
|
|
6219
6824
|
await polling.poll();
|
|
6220
6825
|
await advertise("advertise");
|
|
6221
6826
|
});
|
|
@@ -6235,6 +6840,7 @@ async function serve(options, socket, setup, refreshDue) {
|
|
|
6235
6840
|
);
|
|
6236
6841
|
polling.stop();
|
|
6237
6842
|
clearInterval(factsInterval);
|
|
6843
|
+
facts.stop();
|
|
6238
6844
|
unwatch?.();
|
|
6239
6845
|
clearTimeout(expiry);
|
|
6240
6846
|
clearTimeout(timeout);
|
|
@@ -6292,12 +6898,12 @@ async function tokenExchange(endpoint, form) {
|
|
|
6292
6898
|
throw new TokenAccessDenied(error.message);
|
|
6293
6899
|
throw error;
|
|
6294
6900
|
}
|
|
6295
|
-
const
|
|
6901
|
+
const access4 = requiredText(value, "access_token");
|
|
6296
6902
|
if (!isObject(value)) throw new Error("Invalid OAuth token");
|
|
6297
6903
|
const expiry = field(value, "expires_in"), refresh = field(value, "refresh_token");
|
|
6298
6904
|
if (typeof expiry !== "number" || !Number.isFinite(expiry) || expiry <= 0 || !(refresh === void 0 || typeof refresh === "string"))
|
|
6299
6905
|
throw new Error("Invalid OAuth token lifetime");
|
|
6300
|
-
return { access:
|
|
6906
|
+
return { access: access4, refresh: refresh ?? null, expires: Date.now() + expiry * 1e3 };
|
|
6301
6907
|
}
|
|
6302
6908
|
var OAuthTokens = class {
|
|
6303
6909
|
constructor(pairing, store) {
|
|
@@ -6309,7 +6915,7 @@ var OAuthTokens = class {
|
|
|
6309
6915
|
if (!force && this.current && this.current.expiresAt > Date.now() + 3e4)
|
|
6310
6916
|
return this.current;
|
|
6311
6917
|
const refresh = await this.store.get();
|
|
6312
|
-
if (!refresh) throw new TokenAccessDenied(
|
|
6918
|
+
if (!refresh) throw new TokenAccessDenied(`No gateway token. Run ${gateway("connect")}.`);
|
|
6313
6919
|
const endpoints = await discover(this.pairing.origin);
|
|
6314
6920
|
const tokens = await tokenExchange(
|
|
6315
6921
|
endpoints.token,
|
|
@@ -6430,9 +7036,9 @@ async function pair(origin, store, openBrowser, report = () => {
|
|
|
6430
7036
|
}
|
|
6431
7037
|
async function unpair(pairing, store) {
|
|
6432
7038
|
const tokens = new OAuthTokens(pairing, store);
|
|
6433
|
-
let
|
|
7039
|
+
let access4;
|
|
6434
7040
|
try {
|
|
6435
|
-
|
|
7041
|
+
access4 = await tokens.access();
|
|
6436
7042
|
} catch (error) {
|
|
6437
7043
|
if (!(error instanceof TokenAccessDenied))
|
|
6438
7044
|
throw new Error("Could not access TSP; pairing retained for retry", { cause: error });
|
|
@@ -6443,7 +7049,7 @@ async function unpair(pairing, store) {
|
|
|
6443
7049
|
`${pairing.origin}/api/v1/gateway/machines/${pairing.machine_id}`,
|
|
6444
7050
|
{
|
|
6445
7051
|
method: "DELETE",
|
|
6446
|
-
headers: { Authorization: `Bearer ${
|
|
7052
|
+
headers: { Authorization: `Bearer ${access4.token}` },
|
|
6447
7053
|
redirect: "error",
|
|
6448
7054
|
signal: AbortSignal.timeout(2e4)
|
|
6449
7055
|
}
|
|
@@ -6538,6 +7144,12 @@ var IntentRetries = class {
|
|
|
6538
7144
|
|
|
6539
7145
|
// src/daemon.ts
|
|
6540
7146
|
var OUTDATED_RETRY_MS = 60 * 60 * 1e3;
|
|
7147
|
+
var RESTART_RETRY_MS = 1e3;
|
|
7148
|
+
var RESTART_RETRY_WINDOW_MS = 45e3;
|
|
7149
|
+
var RESTART_CLOSE_CODES = /* @__PURE__ */ new Set([
|
|
7150
|
+
WS_CLOSE_CODE.SERVICE_RESTART,
|
|
7151
|
+
GATEWAY_CLOSE_CODE.SERVER_RESTARTING
|
|
7152
|
+
]);
|
|
6541
7153
|
function reconnectDelay(attempt, random = Math.random) {
|
|
6542
7154
|
return Math.floor(Math.min(3e4, 500 * 2 ** Math.min(attempt, 6)) * (0.5 + random() * 0.5));
|
|
6543
7155
|
}
|
|
@@ -6557,24 +7169,30 @@ function reconnectState(options) {
|
|
|
6557
7169
|
if (!options.signal.aborted) throw new Error("Reconnect wait failed");
|
|
6558
7170
|
}
|
|
6559
7171
|
};
|
|
7172
|
+
const now = options.now ?? (() => performance.now());
|
|
6560
7173
|
const state = {
|
|
6561
7174
|
attempt: 0,
|
|
6562
7175
|
force: false,
|
|
6563
7176
|
rejectedToken: false,
|
|
6564
7177
|
closeCode: null,
|
|
6565
7178
|
closeDisposition: null,
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
options.now ?? (() => performance.now()),
|
|
6569
|
-
options.random ?? Math.random
|
|
6570
|
-
),
|
|
7179
|
+
restartRetryUntil: Number.NEGATIVE_INFINITY,
|
|
7180
|
+
retries: new IntentRetries(options.commands, now, options.random ?? Math.random),
|
|
6571
7181
|
status: (connected, message) => options.status({
|
|
6572
7182
|
connected,
|
|
6573
7183
|
message,
|
|
6574
7184
|
close_code: state.closeCode,
|
|
6575
7185
|
close_disposition: state.closeDisposition
|
|
6576
7186
|
}),
|
|
6577
|
-
backoff: () =>
|
|
7187
|
+
backoff: () => {
|
|
7188
|
+
const delay5 = reconnectDelay(state.attempt++, options.random);
|
|
7189
|
+
return pause(
|
|
7190
|
+
now() < state.restartRetryUntil ? Math.min(delay5, RESTART_RETRY_MS) : delay5
|
|
7191
|
+
);
|
|
7192
|
+
},
|
|
7193
|
+
restarted: () => {
|
|
7194
|
+
state.restartRetryUntil = now() + RESTART_RETRY_WINDOW_MS;
|
|
7195
|
+
},
|
|
6578
7196
|
pause
|
|
6579
7197
|
};
|
|
6580
7198
|
return state;
|
|
@@ -6639,6 +7257,7 @@ async function afterClose(options, state, result, handover) {
|
|
|
6639
7257
|
const recovery = disposition(result.code);
|
|
6640
7258
|
state.closeCode = result.code;
|
|
6641
7259
|
state.closeDisposition = recovery;
|
|
7260
|
+
if (RESTART_CLOSE_CODES.has(result.code)) state.restarted();
|
|
6642
7261
|
const reconnect = !options.signal.aborted && recovery !== "terminal" && !(recovery === "token" && state.rejectedToken);
|
|
6643
7262
|
console.error(
|
|
6644
7263
|
`TSP gateway socket closed: code=${result.code} disposition=${recovery} reconnect=${reconnect}`
|
|
@@ -6759,7 +7378,7 @@ async function daemonLock(state) {
|
|
|
6759
7378
|
}
|
|
6760
7379
|
|
|
6761
7380
|
// src/gateway-status.ts
|
|
6762
|
-
import { readFile as readFile6, stat as
|
|
7381
|
+
import { readFile as readFile6, stat as stat5 } from "node:fs/promises";
|
|
6763
7382
|
var GatewayStatus = class {
|
|
6764
7383
|
constructor(path, executor) {
|
|
6765
7384
|
this.path = path;
|
|
@@ -6789,7 +7408,7 @@ var GatewayStatus = class {
|
|
|
6789
7408
|
};
|
|
6790
7409
|
async function daemonConnection(statusPath, since = 0) {
|
|
6791
7410
|
try {
|
|
6792
|
-
const [text5, info] = await Promise.all([readFile6(statusPath, "utf8"),
|
|
7411
|
+
const [text5, info] = await Promise.all([readFile6(statusPath, "utf8"), stat5(statusPath)]);
|
|
6793
7412
|
if (info.mtimeMs < since) return null;
|
|
6794
7413
|
const status = parseJson(text5);
|
|
6795
7414
|
if (!isObject(status)) return null;
|
|
@@ -6818,7 +7437,7 @@ function readLaunchObservation(value) {
|
|
|
6818
7437
|
// src/installer.ts
|
|
6819
7438
|
import { readFile as readFile7, rm as rm2 } from "node:fs/promises";
|
|
6820
7439
|
import { homedir as homedir9, userInfo as userInfo2 } from "node:os";
|
|
6821
|
-
import { dirname as dirname9, isAbsolute as isAbsolute10, join as join10, win32 } from "node:path";
|
|
7440
|
+
import { dirname as dirname9, isAbsolute as isAbsolute10, join as join10, win32 as win322 } from "node:path";
|
|
6822
7441
|
var label = "com.treestructuredplanning.tsp-gateway";
|
|
6823
7442
|
function xml(value) {
|
|
6824
7443
|
return value.replace(
|
|
@@ -6835,7 +7454,7 @@ function quoted(value) {
|
|
|
6835
7454
|
}
|
|
6836
7455
|
function installDefinition(platform, spec) {
|
|
6837
7456
|
if (![spec.node, spec.entry, spec.config, spec.state].every(
|
|
6838
|
-
platform === "win32" ? (value) =>
|
|
7457
|
+
platform === "win32" ? (value) => win322.isAbsolute(value) || isAbsolute10(value) : isAbsolute10
|
|
6839
7458
|
) || /[\r\n\0]/.test(Object.values(spec).join("")))
|
|
6840
7459
|
throw new Error("Installer requires absolute paths and single-line values");
|
|
6841
7460
|
const args = [
|
|
@@ -6879,7 +7498,7 @@ WantedBy=default.target
|
|
|
6879
7498
|
`;
|
|
6880
7499
|
if (platform === "win32")
|
|
6881
7500
|
return `<?xml version="1.0" encoding="UTF-16"?>
|
|
6882
|
-
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"><RegistrationInfo><Description>TSP gateway ${xml(spec.version)}</Description></RegistrationInfo><Triggers><LogonTrigger><Enabled>true</Enabled><UserId>${xml(spec.user ?? userInfo2().username)}</UserId></LogonTrigger></Triggers><Principals><Principal id="Author"><UserId>${xml(spec.user ?? userInfo2().username)}</UserId><LogonType>InteractiveToken</LogonType><RunLevel>LeastPrivilege</RunLevel></Principal></Principals><Settings><MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy><DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries><StopIfGoingOnBatteries>false</StopIfGoingOnBatteries><ExecutionTimeLimit>PT0S</ExecutionTimeLimit><RestartOnFailure><Interval>PT1M</Interval><Count>3</Count></RestartOnFailure></Settings><Actions Context="Author"><Exec><Command>${xml(spec.node)}</Command><Arguments>${xml(args.slice(1).map(quoted).join(" "))}</Arguments><WorkingDirectory>${xml(
|
|
7501
|
+
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"><RegistrationInfo><Description>TSP gateway ${xml(spec.version)}</Description></RegistrationInfo><Triggers><LogonTrigger><Enabled>true</Enabled><UserId>${xml(spec.user ?? userInfo2().username)}</UserId></LogonTrigger></Triggers><Principals><Principal id="Author"><UserId>${xml(spec.user ?? userInfo2().username)}</UserId><LogonType>InteractiveToken</LogonType><RunLevel>LeastPrivilege</RunLevel></Principal></Principals><Settings><MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy><DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries><StopIfGoingOnBatteries>false</StopIfGoingOnBatteries><ExecutionTimeLimit>PT0S</ExecutionTimeLimit><RestartOnFailure><Interval>PT1M</Interval><Count>3</Count></RestartOnFailure></Settings><Actions Context="Author"><Exec><Command>${xml(spec.node)}</Command><Arguments>${xml(args.slice(1).map(quoted).join(" "))}</Arguments><WorkingDirectory>${xml(win322.isAbsolute(spec.entry) ? win322.dirname(spec.entry) : dirname9(spec.entry))}</WorkingDirectory></Exec></Actions></Task>
|
|
6883
7502
|
`;
|
|
6884
7503
|
throw new Error("Login items support macOS, Linux and Windows");
|
|
6885
7504
|
}
|
|
@@ -7018,7 +7637,7 @@ function keychain(account) {
|
|
|
7018
7637
|
}
|
|
7019
7638
|
|
|
7020
7639
|
// src/setup.ts
|
|
7021
|
-
import { readFile as readFile8 } from "node:fs/promises";
|
|
7640
|
+
import { access as access3, readFile as readFile8 } from "node:fs/promises";
|
|
7022
7641
|
import { dirname as dirname10, join as join11 } from "node:path";
|
|
7023
7642
|
async function pairMachine(host, config) {
|
|
7024
7643
|
const pairing = await pair(
|
|
@@ -7067,37 +7686,78 @@ async function installLoginItem(host, config, refresh = "always") {
|
|
|
7067
7686
|
function notConnected() {
|
|
7068
7687
|
return new ActionableError("This computer isn't connected to TSP yet.", {
|
|
7069
7688
|
instruction: "Connect it",
|
|
7070
|
-
command: "
|
|
7689
|
+
command: gateway("connect")
|
|
7071
7690
|
});
|
|
7072
7691
|
}
|
|
7073
7692
|
var PACKAGE_INSTALL_TIMEOUT_MS = 6e5;
|
|
7693
|
+
async function packageVersion(folder) {
|
|
7694
|
+
const manifest = await readFile8(join11(folder, "package.json"), "utf8").then(parseJson).catch(() => null);
|
|
7695
|
+
const version = isObject(manifest) ? field(manifest, "version") : null;
|
|
7696
|
+
return typeof version === "string" && version ? version : null;
|
|
7697
|
+
}
|
|
7698
|
+
async function installedGateway(root) {
|
|
7699
|
+
const printed = root?.code === 0 ? root.stdout.trim() : "";
|
|
7700
|
+
if (!printed) return null;
|
|
7701
|
+
const folder = join11(printed, ...PACKAGE.split("/"));
|
|
7702
|
+
const version = await packageVersion(folder);
|
|
7703
|
+
if (!version) return null;
|
|
7704
|
+
const entry2 = join11(folder, "dist", "cli.js");
|
|
7705
|
+
if (!await access3(entry2).then(
|
|
7706
|
+
() => true,
|
|
7707
|
+
() => false
|
|
7708
|
+
))
|
|
7709
|
+
return null;
|
|
7710
|
+
return { version, entry: entry2 };
|
|
7711
|
+
}
|
|
7712
|
+
async function recoverLoginItem(host, config) {
|
|
7713
|
+
if (!await access3(host.entry).then(
|
|
7714
|
+
() => true,
|
|
7715
|
+
() => false
|
|
7716
|
+
)) {
|
|
7717
|
+
await removeLoginItem(host);
|
|
7718
|
+
return "The gateway's files are missing, so its start at login was turned off.";
|
|
7719
|
+
}
|
|
7720
|
+
const version = await packageVersion(dirname10(dirname10(host.entry)));
|
|
7721
|
+
if (!version) {
|
|
7722
|
+
await removeLoginItem(host);
|
|
7723
|
+
return "The gateway's version couldn't be read, so its start at login was turned off.";
|
|
7724
|
+
}
|
|
7725
|
+
await installLoginItem({ ...host, version }, config, "when-changed");
|
|
7726
|
+
return launchedByNpx(host.entry) ? `It still runs through npx, now at ${version}.` : version !== host.version ? `The gateway now runs the installed copy at ${version}.` : "The gateway keeps its pairing and folders.";
|
|
7727
|
+
}
|
|
7074
7728
|
async function updateGateway(host, config, run2 = execute) {
|
|
7075
7729
|
if (!config.pairing) throw notConnected();
|
|
7076
|
-
let latest = host;
|
|
7077
7730
|
const npm = host.platform === "win32" ? host.node : "npm";
|
|
7078
7731
|
const npmArgs = host.platform === "win32" ? [join11(dirname10(host.node), "node_modules", "npm", "bin", "npm-cli.js")] : [];
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7732
|
+
const install2 = ["install", "--global", `${PACKAGE}@latest`];
|
|
7733
|
+
host.report([marked("wait", "Installing the latest gateway with npm\u2026")]);
|
|
7734
|
+
const installed = await run2(npm, [...npmArgs, ...install2], host.env, void 0, {
|
|
7735
|
+
timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS
|
|
7736
|
+
}).catch(() => null);
|
|
7737
|
+
if (installed?.code !== 0) {
|
|
7738
|
+
const byHand = {
|
|
7739
|
+
instruction: `Install it yourself, then run ${INSTALLED} update`,
|
|
7740
|
+
command: ["npm", ...install2].join(" ")
|
|
7741
|
+
};
|
|
7742
|
+
const recovery = await recoverLoginItem(host, config);
|
|
7743
|
+
throw new ActionableError(`npm couldn't install the latest gateway. ${recovery}`, byHand);
|
|
7744
|
+
}
|
|
7745
|
+
const located = await installedGateway(
|
|
7746
|
+
await run2(npm, [...npmArgs, "root", "--global"], host.env).catch(() => null)
|
|
7747
|
+
);
|
|
7748
|
+
if (!located) {
|
|
7749
|
+
const recovery = await recoverLoginItem(host, config);
|
|
7750
|
+
throw new ActionableError(
|
|
7751
|
+
`npm installed the latest gateway but couldn't find its files. ${recovery}`,
|
|
7752
|
+
{
|
|
7753
|
+
instruction: "Install it yourself, then run tsp-gateway start",
|
|
7754
|
+
command: ["npm", ...install2].join(" ")
|
|
7755
|
+
}
|
|
7087
7756
|
);
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
const folder = join11(root.stdout.trim(), "@treestructuredplanning", "gateway");
|
|
7093
|
-
const manifest = parseJson(await readFile8(join11(folder, "package.json"), "utf8"));
|
|
7094
|
-
const version = isObject(manifest) ? field(manifest, "version") : null;
|
|
7095
|
-
if (typeof version !== "string" || !version)
|
|
7096
|
-
throw new Error("Updated gateway has no version.");
|
|
7097
|
-
latest = { ...host, entry: join11(folder, "dist", "cli.js"), version };
|
|
7098
|
-
}
|
|
7099
|
-
await installLoginItem(latest, config);
|
|
7100
|
-
return latest.version;
|
|
7757
|
+
}
|
|
7758
|
+
const { version, entry: entry2 } = located;
|
|
7759
|
+
await installLoginItem({ ...host, entry: entry2, version }, config);
|
|
7760
|
+
return { version, entry: entry2 };
|
|
7101
7761
|
}
|
|
7102
7762
|
async function removeLoginItem(host) {
|
|
7103
7763
|
return await uninstall(host.paths.state, host.platform, host.home) ? "removed" : "absent";
|
|
@@ -7116,10 +7776,9 @@ async function pairingUsable(host, pairing) {
|
|
|
7116
7776
|
return true;
|
|
7117
7777
|
} catch (error) {
|
|
7118
7778
|
if (error instanceof TokenAccessDenied) return false;
|
|
7119
|
-
throw new Error(
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
);
|
|
7779
|
+
throw new Error("Could not reach TSP to check this computer's pairing. Try again.", {
|
|
7780
|
+
cause: error
|
|
7781
|
+
});
|
|
7123
7782
|
}
|
|
7124
7783
|
}
|
|
7125
7784
|
async function connectFolder(host, config, folder) {
|
|
@@ -7129,18 +7788,23 @@ async function connectFolder(host, config, folder) {
|
|
|
7129
7788
|
} catch (error) {
|
|
7130
7789
|
if (Object.keys(config.repositories).length > 0) return null;
|
|
7131
7790
|
throw new Error(
|
|
7132
|
-
|
|
7791
|
+
`Run ${gateway("connect")} inside a clone of a GitHub repository, or pass its folder.`,
|
|
7133
7792
|
{ cause: error }
|
|
7134
7793
|
);
|
|
7135
7794
|
}
|
|
7136
7795
|
}
|
|
7137
7796
|
async function connect(host, config, folder) {
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7797
|
+
try {
|
|
7798
|
+
const target = await connectFolder(host, config, folder);
|
|
7799
|
+
const kept = config.pairing !== null && await pairingUsable(host, config.pairing);
|
|
7800
|
+
if (!kept) await pairMachine(host, config);
|
|
7801
|
+
const repository = target ? await saveRepository(host, config, target) : null;
|
|
7802
|
+
const loginItem = await installLoginItem(host, config, kept ? "when-changed" : "always");
|
|
7803
|
+
return { pairing: kept ? "kept" : "paired", repository, loginItem };
|
|
7804
|
+
} catch (error) {
|
|
7805
|
+
if (config.pairing) await recoverLoginItem(host, config);
|
|
7806
|
+
throw error;
|
|
7807
|
+
}
|
|
7144
7808
|
}
|
|
7145
7809
|
async function disconnect(host, config) {
|
|
7146
7810
|
const loginItem = await removeLoginItem(host);
|
|
@@ -7209,7 +7873,7 @@ var REASONS = {
|
|
|
7209
7873
|
};
|
|
7210
7874
|
var CONNECT_HERE = {
|
|
7211
7875
|
instruction: "Run this inside a clone of a GitHub repository to register it",
|
|
7212
|
-
command: "
|
|
7876
|
+
command: gateway("connect")
|
|
7213
7877
|
};
|
|
7214
7878
|
function list(names) {
|
|
7215
7879
|
return names.length < 3 ? names.join(" and ") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
@@ -7260,7 +7924,7 @@ function registeredLines(registered2, drivers) {
|
|
|
7260
7924
|
1
|
|
7261
7925
|
),
|
|
7262
7926
|
...nextLines(
|
|
7263
|
-
{ instruction: "Start the gateway now and at login", command: "
|
|
7927
|
+
{ instruction: "Start the gateway now and at login", command: gateway("start") },
|
|
7264
7928
|
1
|
|
7265
7929
|
)
|
|
7266
7930
|
];
|
|
@@ -7271,7 +7935,7 @@ function gatewayLines(view) {
|
|
|
7271
7935
|
return [
|
|
7272
7936
|
...lines,
|
|
7273
7937
|
marked("fail", "Not paired", 1),
|
|
7274
|
-
...nextLines({ instruction: "Pair this computer", command: "
|
|
7938
|
+
...nextLines({ instruction: "Pair this computer", command: gateway("connect") }, 2)
|
|
7275
7939
|
];
|
|
7276
7940
|
const current = connectionState(view.connection);
|
|
7277
7941
|
const last = view.lastMessage !== null && view.lastMessage !== view.connection ? connectionState(view.lastMessage) : null;
|
|
@@ -7281,7 +7945,14 @@ function gatewayLines(view) {
|
|
|
7281
7945
|
marked("pass", `Paired as ${view.machineId}`, 1),
|
|
7282
7946
|
marked(current.mark, current.text, 1),
|
|
7283
7947
|
...last ? [note(`Last report: ${last.text}`, 2)] : [],
|
|
7284
|
-
...next ? nextLines(next, 2) : []
|
|
7948
|
+
...next ? nextLines(next, 2) : [],
|
|
7949
|
+
...!view.update ? [] : nextLines(
|
|
7950
|
+
{
|
|
7951
|
+
instruction: `Gateway ${view.update} is available. To update, run`,
|
|
7952
|
+
command: gateway("update")
|
|
7953
|
+
},
|
|
7954
|
+
1
|
|
7955
|
+
)
|
|
7285
7956
|
];
|
|
7286
7957
|
}
|
|
7287
7958
|
function verdictLines(view, setups) {
|
|
@@ -7301,7 +7972,7 @@ function verdictLines(view, setups) {
|
|
|
7301
7972
|
"wait",
|
|
7302
7973
|
`Ready to build in ${list(ready)} once the gateway connects. Check with:`
|
|
7303
7974
|
),
|
|
7304
|
-
command("
|
|
7975
|
+
command(gateway("status"), 2)
|
|
7305
7976
|
];
|
|
7306
7977
|
return [marked("pass", `Ready to build in ${list(ready)}.`)];
|
|
7307
7978
|
}
|
|
@@ -7315,10 +7986,18 @@ function connectLines(view, setups, name) {
|
|
|
7315
7986
|
blank,
|
|
7316
7987
|
...verdictLines(view, setups),
|
|
7317
7988
|
note(
|
|
7318
|
-
"
|
|
7989
|
+
`${gateway("stop")}, start and update manage the background gateway. Pairing and folders stay.`
|
|
7319
7990
|
)
|
|
7320
7991
|
];
|
|
7321
7992
|
}
|
|
7993
|
+
async function commandPathLines(entry2, env, platform) {
|
|
7994
|
+
const folder = await commandFolderOffPath(entry2, env, platform);
|
|
7995
|
+
if (folder === null) return [];
|
|
7996
|
+
return [
|
|
7997
|
+
marked("wait", `${INSTALLED} isn't on your PATH yet`),
|
|
7998
|
+
note(`npm put it in ${folder}. Add that folder to your PATH to run it by name.`, 1)
|
|
7999
|
+
];
|
|
8000
|
+
}
|
|
7322
8001
|
function statusLines(view, setups, name) {
|
|
7323
8002
|
const reason = REASONS[view.launch.reason] ?? view.launch.reason;
|
|
7324
8003
|
return [
|
|
@@ -7340,7 +8019,32 @@ function statusLines(view, setups, name) {
|
|
|
7340
8019
|
];
|
|
7341
8020
|
}
|
|
7342
8021
|
|
|
8022
|
+
// src/release-check.ts
|
|
8023
|
+
var RELEASE = /^(\d+)\.(\d+)\.(\d+)$/u;
|
|
8024
|
+
function parts(version) {
|
|
8025
|
+
const match = RELEASE.exec(version);
|
|
8026
|
+
return match ? match.slice(1).map(Number) : null;
|
|
8027
|
+
}
|
|
8028
|
+
async function shippedRelease(origin, fetcher = fetch, timeoutMs = 3e3) {
|
|
8029
|
+
try {
|
|
8030
|
+
const response = await fetcher(`${origin}/api/v1/gateway/release`, {
|
|
8031
|
+
redirect: "error",
|
|
8032
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
8033
|
+
});
|
|
8034
|
+
return response.ok ? decodeRelease(await response.json()).version : null;
|
|
8035
|
+
} catch {
|
|
8036
|
+
return null;
|
|
8037
|
+
}
|
|
8038
|
+
}
|
|
8039
|
+
function newerRelease(running3, shipped) {
|
|
8040
|
+
const have = parts(running3), offered = shipped === null ? null : parts(shipped);
|
|
8041
|
+
if (!have || !offered) return null;
|
|
8042
|
+
const at = have.findIndex((part, index) => part !== offered[index]);
|
|
8043
|
+
return at !== -1 && have[at] < offered[at] ? shipped : null;
|
|
8044
|
+
}
|
|
8045
|
+
|
|
7343
8046
|
export {
|
|
8047
|
+
package_default,
|
|
7344
8048
|
GATEWAY_CLOSE_DISPOSITION,
|
|
7345
8049
|
decodeReporting,
|
|
7346
8050
|
toWire,
|
|
@@ -7351,14 +8055,16 @@ export {
|
|
|
7351
8055
|
decodeHub,
|
|
7352
8056
|
parseJson,
|
|
7353
8057
|
sanitizeWaiting,
|
|
7354
|
-
worktreeRoot,
|
|
7355
|
-
worktreeFolder,
|
|
7356
|
-
excludeLine,
|
|
7357
8058
|
execute,
|
|
7358
8059
|
resolveLaunchPath,
|
|
7359
8060
|
HarnessRefusal,
|
|
7360
8061
|
repositoryKey,
|
|
7361
8062
|
parseRepositoryRemote,
|
|
8063
|
+
TRUST_CACHE_MAX_AGE_MS,
|
|
8064
|
+
TrustCache,
|
|
8065
|
+
worktreeRoot,
|
|
8066
|
+
worktreeFolder,
|
|
8067
|
+
excludeLine,
|
|
7362
8068
|
AcpDriver,
|
|
7363
8069
|
defaultLaunchConfig,
|
|
7364
8070
|
decodeLaunchConfig,
|
|
@@ -7387,6 +8093,11 @@ export {
|
|
|
7387
8093
|
CheckoutPreparer,
|
|
7388
8094
|
previewWorktreeRoot,
|
|
7389
8095
|
checkoutReport,
|
|
8096
|
+
PACKAGE,
|
|
8097
|
+
INSTALLED,
|
|
8098
|
+
gatewayInstall,
|
|
8099
|
+
invocation,
|
|
8100
|
+
gateway,
|
|
7390
8101
|
heading,
|
|
7391
8102
|
marked,
|
|
7392
8103
|
text4 as text,
|
|
@@ -7414,6 +8125,10 @@ export {
|
|
|
7414
8125
|
CONNECTION,
|
|
7415
8126
|
connectionState,
|
|
7416
8127
|
LaunchPermits,
|
|
8128
|
+
SIGN_IN_SCHEDULE,
|
|
8129
|
+
nextSignInCheck,
|
|
8130
|
+
signInCheckAfter,
|
|
8131
|
+
SignInChecks,
|
|
7417
8132
|
HANDOVER_MS,
|
|
7418
8133
|
REFRESH_LEAD_MS,
|
|
7419
8134
|
OAuthTokens,
|
|
@@ -7446,6 +8161,9 @@ export {
|
|
|
7446
8161
|
setupLines,
|
|
7447
8162
|
registeredLines,
|
|
7448
8163
|
connectLines,
|
|
7449
|
-
|
|
8164
|
+
commandPathLines,
|
|
8165
|
+
statusLines,
|
|
8166
|
+
shippedRelease,
|
|
8167
|
+
newerRelease
|
|
7450
8168
|
};
|
|
7451
|
-
//# sourceMappingURL=shared-
|
|
8169
|
+
//# sourceMappingURL=shared-IDNTQEWS.js.map
|