@zgeoff/atc 3.3.1 → 3.4.1
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/package.json +5 -3
- package/src/agents/agent-adapter.ts +10 -0
- package/src/agents/build-agent-adapters.ts +21 -3
- package/src/agents/build-cli-argv.ts +2 -4
- package/src/agents/claude-adapter.ts +13 -3
- package/src/agents/codex-adapter.ts +31 -2
- package/src/agents/gateway-adapter.ts +20 -8
- package/src/agents/grok-adapter.ts +16 -13
- package/src/agents/load-claude-config-bundle.ts +6 -6
- package/src/agents/print-codex-hook-file.ts +7 -3
- package/src/agents/print-grok-hook-file.ts +8 -3
- package/src/agents/render-sdk-message.ts +57 -0
- package/src/agents/resolve-agent-home.ts +7 -3
- package/src/agents/resolve-claude-global-config-path.ts +4 -4
- package/src/agents/start-claude-headless-run.ts +2 -57
- package/src/agents/update-claude-project-trust.ts +41 -30
- package/src/agents/with-claude-config-lock.ts +37 -12
- package/src/agents/write-atc-bridge.ts +10 -7
- package/src/agents/write-hook-settings.ts +13 -7
- package/src/client/boot-daemon.ts +122 -39
- package/src/client/dirs.ts +4 -2
- package/src/client/index.ts +17 -1
- package/src/client/log-client-event.ts +20 -0
- package/src/client/resolve-workspace-root.ts +10 -5
- package/src/client/spawn-picker.ts +200 -121
- package/src/client/ui.ts +7 -7
- package/src/clients.ts +41 -11
- package/src/daemon/daemon.ts +143 -33
- package/src/daemon/event-signal.ts +19 -3
- package/src/daemon/make-hook-runner.ts +82 -22
- package/src/daemon/permission-registry.ts +11 -6
- package/src/daemon/restore-fleet.ts +62 -17
- package/src/daemon/run-eject-handoff.ts +20 -2
- package/src/daemon/session-runtime.ts +0 -4
- package/src/daemon/sessions.ts +6 -0
- package/src/daemon/start-tcp-listener.ts +12 -10
- package/src/federation/daemon-caller.ts +25 -4
- package/src/federation/daemon-pool.ts +3 -1
- package/src/federation/open-gateway-caller.ts +6 -1
- package/src/gateway.ts +2 -179
- package/src/grants.ts +36 -11
- package/src/hook-report.ts +17 -3
- package/src/mcp/read-report-texts.ts +11 -7
- package/src/mcp/start-mcp-http-server.ts +5 -1
- package/src/mcp-http-server.ts +88 -32
- package/src/report.ts +21 -3
- package/src/run-bridge-tap.ts +36 -7
- package/src/run-config-migrate.ts +35 -11
- package/src/run-gateway-cli.ts +327 -0
- package/src/run-gateway.ts +51 -18
- package/src/shared/build-atc-command.ts +7 -3
- package/src/shared/bun-sqlite-driver.ts +10 -0
- package/src/shared/claim-daemon-lock.ts +10 -4
- package/src/shared/collect-dir-roots.ts +6 -6
- package/src/shared/collect-hooks.ts +7 -6
- package/src/shared/config.ts +19 -9
- package/src/shared/system-clock.ts +24 -0
- package/src/sources/github/collect-github-repos.ts +1 -1
- package/src/sources/github/read-git-protocol.ts +1 -1
- package/src/sources/github/run-gh.ts +24 -9
- package/src/store/state-store.ts +57 -7
- package/src/tap.ts +44 -13
- package/src/test-utils/build-mock-agent-adapter.ts +25 -0
- package/src/test-utils/build-mock-agent-entry.ts +32 -0
- package/src/test-utils/build-mock-auth-binding.ts +28 -0
- package/src/test-utils/build-mock-auth-profile.ts +62 -0
- package/src/test-utils/build-mock-daemon-record.ts +26 -0
- package/src/test-utils/build-mock-execution-target.ts +25 -0
- package/src/test-utils/build-mock-fleet-entry.ts +33 -0
- package/src/test-utils/build-mock-gateway-config.ts +32 -0
- package/src/test-utils/build-mock-imp-identity.ts +18 -0
- package/src/test-utils/build-mock-imp-session-request.ts +53 -0
- package/src/test-utils/build-mock-key-binding-claim.ts +34 -0
- package/src/test-utils/build-mock-message-record.ts +26 -0
- package/src/test-utils/build-mock-mirror-session.ts +42 -0
- package/src/test-utils/build-mock-registry-daemon.ts +28 -0
- package/src/test-utils/build-mock-session-descriptor.ts +66 -0
- package/src/test-utils/build-mock-session.ts +43 -0
- package/src/test-utils/build-mock-sortable-session-view.ts +20 -0
- package/src/test-utils/build-mock-stored-event.ts +20 -0
- package/src/test-utils/build-mock-stored-row.ts +23 -0
- package/src/test-utils/build-stub-attention-adapter.ts +22 -0
- package/src/test-utils/build-stub-bridge-context.ts +20 -0
- package/src/test-utils/build-stub-brokered-agent-adapter.ts +96 -0
- package/src/test-utils/build-stub-brokered-gateway-adapter.ts +50 -0
- package/src/test-utils/build-stub-channel-opener.ts +45 -0
- package/src/test-utils/build-stub-claude-headless-run.ts +13 -0
- package/src/test-utils/build-stub-client-screens.ts +33 -0
- package/src/test-utils/build-stub-clock.ts +67 -0
- package/src/test-utils/build-stub-daemon-context.ts +81 -0
- package/src/test-utils/build-stub-daemon-requests.ts +103 -0
- package/src/test-utils/{fixture-dir-provider.ts → build-stub-dir-provider.ts} +20 -12
- package/src/test-utils/build-stub-execution-provider.ts +112 -0
- package/src/test-utils/build-stub-fleet-caller.ts +60 -0
- package/src/test-utils/build-stub-forking-gh.ts +10 -0
- package/src/test-utils/build-stub-gh.ts +50 -0
- package/src/test-utils/build-stub-handoff-daemon.ts +11 -0
- package/src/test-utils/build-stub-harness-relay.ts +50 -0
- package/src/test-utils/build-stub-headless-runner.ts +60 -0
- package/src/test-utils/build-stub-held-gh.ts +19 -0
- package/src/test-utils/build-stub-held-inbox-source.ts +36 -0
- package/src/test-utils/build-stub-held-provider.ts +58 -0
- package/src/test-utils/build-stub-held-zoxide.ts +13 -0
- package/src/test-utils/build-stub-host-hold.ts +31 -0
- package/src/test-utils/build-stub-host-provider.ts +26 -0
- package/src/test-utils/build-stub-log.ts +15 -0
- package/src/test-utils/build-stub-mcp-claude.ts +26 -0
- package/src/test-utils/build-stub-mcp-grok.ts +19 -0
- package/src/test-utils/build-stub-mcp-stdio-server.ts +20 -0
- package/src/test-utils/build-stub-peer-socket.ts +81 -0
- package/src/test-utils/build-stub-picker-host.ts +36 -0
- package/src/test-utils/build-stub-proxied-agent-adapter.ts +29 -0
- package/src/test-utils/build-stub-pty-provider.ts +53 -0
- package/src/test-utils/build-stub-recording-atc.ts +10 -0
- package/src/test-utils/build-stub-recording-filter.ts +9 -0
- package/src/test-utils/build-stub-recording-git.ts +8 -0
- package/src/test-utils/build-stub-signed-in-gh.ts +18 -0
- package/src/test-utils/build-stub-signed-out-gh.ts +8 -0
- package/src/test-utils/build-stub-soft-kill-provider.ts +29 -0
- package/src/test-utils/build-stub-targets.ts +58 -0
- package/src/test-utils/build-stub-terminal.ts +19 -0
- package/src/test-utils/build-stub-timeout-scheduler.ts +48 -0
- package/src/test-utils/build-stub-tui-claude.ts +47 -0
- package/src/test-utils/build-stub-tui-grok.ts +53 -0
- package/src/test-utils/build-stub-wait-clock.ts +23 -0
- package/src/test-utils/build-target-options-from-config.ts +37 -0
- package/src/test-utils/collect-process-tree.ts +75 -0
- package/src/test-utils/create-git-fixture.ts +117 -0
- package/src/test-utils/create-migrated-state-db.ts +12 -10
- package/src/test-utils/create-stub-bin.ts +19 -0
- package/src/test-utils/create-stub-claude.ts +75 -0
- package/src/test-utils/create-stub-codex.ts +31 -0
- package/src/test-utils/create-stub-composer.ts +65 -0
- package/src/test-utils/create-stub-echo-claude.ts +21 -0
- package/src/test-utils/create-stub-failing-agent-adapter.ts +111 -0
- package/src/test-utils/create-stub-grok.ts +44 -0
- package/src/test-utils/create-stub-guest-clis.ts +55 -0
- package/src/test-utils/create-stub-harness-guest.ts +35 -0
- package/src/test-utils/{fixture-imp-port.ts → create-stub-imp-port.ts} +144 -63
- package/src/test-utils/create-stub-recording-claude.ts +20 -0
- package/src/test-utils/create-stub-recording-codex.ts +20 -0
- package/src/test-utils/create-stub-shared-server-codex.ts +56 -0
- package/src/test-utils/{setup-fake-systemd.ts → create-stub-systemd.ts} +15 -9
- package/src/test-utils/get-gateway-config.ts +3 -3
- package/src/test-utils/get-only-effect-ref.ts +21 -0
- package/src/test-utils/get-only-imp-name.ts +19 -0
- package/src/test-utils/get-records.ts +20 -0
- package/src/test-utils/get-string.ts +14 -0
- package/src/test-utils/keys.ts +26 -0
- package/src/test-utils/merge-deep.ts +36 -0
- package/src/test-utils/mock-overrides.ts +13 -0
- package/src/test-utils/open-repo-step.ts +24 -0
- package/src/test-utils/read-query-plan.ts +22 -0
- package/src/test-utils/register-test-cleanup.ts +63 -0
- package/src/test-utils/resolve-atc-command.ts +13 -0
- package/src/test-utils/resolve-gateway-command.ts +13 -0
- package/src/test-utils/run-atc.ts +56 -0
- package/src/test-utils/run-legacy-daemon.ts +27 -5
- package/src/test-utils/run-listener-daemon.ts +5 -10
- package/src/test-utils/run-mcp-authorization.ts +7 -4
- package/src/test-utils/run-source-daemon.ts +2 -2
- package/src/test-utils/seed-faker.ts +7 -0
- package/src/test-utils/send-lines-before-handshake.ts +35 -0
- package/src/test-utils/send-mcp-request.ts +25 -0
- package/src/test-utils/setup-mcp-home.ts +110 -0
- package/src/test-utils/setup-mcp-http.ts +26 -30
- package/src/test-utils/setup-temp-dir.ts +7 -6
- package/src/test-utils/spawn-claude-session.ts +34 -0
- package/src/test-utils/spawn-grok-session.ts +39 -0
- package/src/test-utils/start-cut-proxy.ts +29 -8
- package/src/test-utils/start-daemon-process.ts +193 -0
- package/src/test-utils/start-git-http-server.ts +28 -4
- package/src/test-utils/start-mcp-stdio.ts +190 -0
- package/src/test-utils/start-output-capture.ts +20 -0
- package/src/test-utils/start-stub-answering-listener.ts +65 -0
- package/src/test-utils/start-stub-closing-listener.ts +31 -0
- package/src/test-utils/start-stub-dropping-daemon.ts +105 -0
- package/src/test-utils/start-stub-impd-info.ts +38 -0
- package/src/test-utils/start-stub-impd.ts +143 -0
- package/src/test-utils/start-stub-legacy-daemon.ts +171 -0
- package/src/test-utils/start-stub-mcp-server.ts +55 -0
- package/src/test-utils/start-stub-recording-listener.ts +47 -0
- package/src/test-utils/start-stub-refusing-listener.ts +43 -0
- package/src/test-utils/start-stub-reporter-socket.ts +79 -0
- package/src/test-utils/start-stub-restore-daemon.ts +59 -0
- package/src/test-utils/start-stub-session-bridge.ts +100 -0
- package/src/test-utils/start-stub-silent-server.ts +38 -0
- package/src/test-utils/start-stub-source-daemon.ts +41 -0
- package/src/test-utils/start-stub-stalled-client.ts +61 -0
- package/src/test-utils/start-stub-stalled-listener.ts +44 -0
- package/src/test-utils/start-stub-tap.ts +38 -0
- package/src/test-utils/start-stub-tcp-daemon.ts +75 -0
- package/src/test-utils/start-stub-telemetry-collector.ts +32 -0
- package/src/test-utils/start-stub-unanswering-listener.ts +41 -0
- package/src/test-utils/start-stub-unanswering-unix-listener.ts +38 -0
- package/src/test-utils/start-test-daemon.ts +229 -0
- package/src/test-utils/start-tui-harness.ts +291 -0
- package/src/test-utils/subscribe-to-socket-lines.ts +81 -14
- package/src/test-utils/try-send-request.ts +29 -0
- package/src/test-utils/wait-for-event.ts +41 -0
- package/src/test-utils/wait-for.ts +15 -3
- package/src/verify-restored-fleet.ts +30 -17
- package/src/workspace/check-repository-access.ts +4 -0
- package/src/workspace/collect-remote-refs.ts +4 -2
- package/src/workspace/run-git.ts +6 -0
- package/src/test-utils/start-legacy-daemon.ts +0 -111
|
@@ -41,13 +41,15 @@ const REMOTE_TIMEOUT_MS = 20_000;
|
|
|
41
41
|
* askpass helper for an env credential. git never prompts. A listing git
|
|
42
42
|
* cannot read is refused as `clone_failed` with git's own message, and so
|
|
43
43
|
* is one that takes longer than the time limit, 20 s unless given. git
|
|
44
|
-
* fetches only over `transports`.
|
|
44
|
+
* fetches only over `transports`. `onSpawn` is called with the pid of the
|
|
45
|
+
* listing's git as it starts.
|
|
45
46
|
*/
|
|
46
47
|
export async function collectRemoteRefs(
|
|
47
48
|
url: string,
|
|
48
49
|
credential: GitCredential | undefined,
|
|
49
50
|
transports: readonly string[],
|
|
50
51
|
timeoutMs: number = REMOTE_TIMEOUT_MS,
|
|
52
|
+
onSpawn?: (pid: number) => void,
|
|
51
53
|
): Promise<RemoteRefListing | RemoteRefRefusal> {
|
|
52
54
|
const askpass = await createGitAskpass(credential);
|
|
53
55
|
|
|
@@ -72,7 +74,7 @@ export async function collectRemoteRefs(
|
|
|
72
74
|
'refs/heads/*',
|
|
73
75
|
'refs/tags/*',
|
|
74
76
|
],
|
|
75
|
-
{ env: { ...askpass.env, ...sshEnv }, timeoutMs, transports },
|
|
77
|
+
{ env: { ...askpass.env, ...sshEnv }, timeoutMs, transports, onSpawn },
|
|
76
78
|
);
|
|
77
79
|
} finally {
|
|
78
80
|
await askpass[Symbol.asyncDispose]();
|
package/src/workspace/run-git.ts
CHANGED
|
@@ -13,6 +13,10 @@ interface GitRunOptions {
|
|
|
13
13
|
|
|
14
14
|
// The transports git may fetch over; https and ssh when unset.
|
|
15
15
|
readonly transports?: readonly string[];
|
|
16
|
+
|
|
17
|
+
// Called with the pid of the started git right after it starts; with a
|
|
18
|
+
// time limit, that pid is also its process group's id.
|
|
19
|
+
readonly onSpawn?: ((pid: number) => void) | undefined;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
interface GitRun {
|
|
@@ -84,6 +88,8 @@ export async function runGit(
|
|
|
84
88
|
detached: options.timeoutMs !== undefined,
|
|
85
89
|
});
|
|
86
90
|
|
|
91
|
+
options.onSpawn?.(proc.pid);
|
|
92
|
+
|
|
87
93
|
const finished = Promise.all([
|
|
88
94
|
new Response(proc.stdout).text(),
|
|
89
95
|
new Response(proc.stderr).text(),
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type { DaemonFeature } from '../protocol/daemon-features';
|
|
2
|
-
import {
|
|
3
|
-
MAX_CHUNK,
|
|
4
|
-
MAX_LINE,
|
|
5
|
-
PROTOCOL_V,
|
|
6
|
-
decodeMessage,
|
|
7
|
-
encodeMessage,
|
|
8
|
-
} from '../protocol/protocol';
|
|
9
|
-
|
|
10
|
-
interface ReceivedRequest {
|
|
11
|
-
readonly m: string;
|
|
12
|
-
readonly p: Readonly<Record<string, unknown>> | undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface LegacyDaemonOptions {
|
|
16
|
-
readonly features?: readonly DaemonFeature[];
|
|
17
|
-
|
|
18
|
-
// The protocol version the daemon speaks; a hello on any other version is
|
|
19
|
-
// refused with `protocol_mismatch`, as a real daemon refuses it.
|
|
20
|
-
readonly protocol?: number;
|
|
21
|
-
|
|
22
|
-
readonly replies?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* An older atc daemon listening on a unix socket and speaking the current
|
|
27
|
-
* protocol version, or the one `protocol` holds. Its `daemon.hello` announces `features` when the options
|
|
28
|
-
* hold that list, and announces none without it, as a daemon from before
|
|
29
|
-
* features did. It answers `daemon.hello`, `daemon.ping`, and each method in
|
|
30
|
-
* `replies` with that method's reply, and refuses every other method with
|
|
31
|
-
* `unknown_method`. Every request it receives is recorded in `requests`. Stop
|
|
32
|
-
* it with `stop`.
|
|
33
|
-
*/
|
|
34
|
-
export function startLegacyDaemon(socketPath: string, options: LegacyDaemonOptions = {}) {
|
|
35
|
-
const answers: Readonly<Record<string, Readonly<Record<string, unknown>>>> = {
|
|
36
|
-
'daemon.hello': {
|
|
37
|
-
daemon: 'atc/legacy-build',
|
|
38
|
-
limits: { maxLine: MAX_LINE, maxChunk: MAX_CHUNK },
|
|
39
|
-
lastUsedAgent: 'claude',
|
|
40
|
-
...(options.features === undefined ? {} : { features: options.features }),
|
|
41
|
-
},
|
|
42
|
-
'daemon.ping': {},
|
|
43
|
-
...options.replies,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const protocol = options.protocol ?? PROTOCOL_V;
|
|
47
|
-
const requests: ReceivedRequest[] = [];
|
|
48
|
-
|
|
49
|
-
const server = Bun.listen<{ buffer: string }>({
|
|
50
|
-
unix: socketPath,
|
|
51
|
-
socket: {
|
|
52
|
-
open(socket) {
|
|
53
|
-
socket.data = { buffer: '' };
|
|
54
|
-
},
|
|
55
|
-
data(socket, chunk) {
|
|
56
|
-
const lines = `${socket.data.buffer}${chunk.toString()}`.split('\n');
|
|
57
|
-
|
|
58
|
-
socket.data.buffer = lines.pop() ?? '';
|
|
59
|
-
|
|
60
|
-
for (const line of lines) {
|
|
61
|
-
const decoded = decodeMessage(line);
|
|
62
|
-
|
|
63
|
-
if (decoded.kind !== 'request') {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const req = decoded.msg;
|
|
68
|
-
|
|
69
|
-
requests.push({ m: req.m, p: req.p });
|
|
70
|
-
|
|
71
|
-
if (req.m === 'daemon.hello' && req.v !== protocol) {
|
|
72
|
-
const client = req.p?.['client'];
|
|
73
|
-
|
|
74
|
-
socket.write(
|
|
75
|
-
encodeMessage({
|
|
76
|
-
v: protocol,
|
|
77
|
-
id: req.id,
|
|
78
|
-
err: {
|
|
79
|
-
code: 'protocol_mismatch',
|
|
80
|
-
msg: `${String(client)} speaks protocol v${req.v}, daemon atc/legacy-build speaks v${protocol}; restart the daemon so both run the same build`,
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const answer = answers[req.m];
|
|
89
|
-
|
|
90
|
-
const reply =
|
|
91
|
-
answer === undefined
|
|
92
|
-
? {
|
|
93
|
-
v: protocol,
|
|
94
|
-
id: req.id,
|
|
95
|
-
err: { code: 'unknown_method' as const, msg: `unknown method '${req.m}'` },
|
|
96
|
-
}
|
|
97
|
-
: { v: protocol, id: req.id, ok: answer };
|
|
98
|
-
|
|
99
|
-
socket.write(encodeMessage(reply));
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
requests,
|
|
107
|
-
stop() {
|
|
108
|
-
server.stop(true);
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
}
|