@usine/executor 0.2.1 → 0.3.0
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 +115 -37
- package/dist/child-command.d.ts +4 -7
- package/dist/child-command.d.ts.map +1 -1
- package/dist/child-command.js +6 -12
- package/dist/child-command.js.map +1 -1
- package/dist/claude-login-lock.d.ts +8 -0
- package/dist/claude-login-lock.d.ts.map +1 -0
- package/dist/claude-login-lock.js +9 -0
- package/dist/claude-login-lock.js.map +1 -0
- package/dist/credential-environment.d.ts +20 -0
- package/dist/credential-environment.d.ts.map +1 -0
- package/dist/credential-environment.js +20 -0
- package/dist/credential-environment.js.map +1 -0
- package/dist/durable-session.d.ts +63 -0
- package/dist/durable-session.d.ts.map +1 -0
- package/dist/durable-session.js +491 -0
- package/dist/durable-session.js.map +1 -0
- package/dist/exe-dev/commands.d.ts +23 -13
- package/dist/exe-dev/commands.d.ts.map +1 -1
- package/dist/exe-dev/commands.js +11 -57
- package/dist/exe-dev/commands.js.map +1 -1
- package/dist/exe-dev/exe-dev.d.ts +9 -3
- package/dist/exe-dev/exe-dev.d.ts.map +1 -1
- package/dist/exe-dev/exe-dev.js +53 -128
- package/dist/exe-dev/exe-dev.js.map +1 -1
- package/dist/exe-dev/grants.d.ts.map +1 -1
- package/dist/exe-dev/grants.js +35 -15
- package/dist/exe-dev/grants.js.map +1 -1
- package/dist/exe-dev/model.d.ts +15 -19
- package/dist/exe-dev/model.d.ts.map +1 -1
- package/dist/exe-dev/model.js +9 -12
- package/dist/exe-dev/model.js.map +1 -1
- package/dist/exe-dev/preflight.d.ts +8 -4
- package/dist/exe-dev/preflight.d.ts.map +1 -1
- package/dist/exe-dev/preflight.js +23 -33
- package/dist/exe-dev/preflight.js.map +1 -1
- package/dist/executor.d.ts +140 -41
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +90 -19
- package/dist/executor.js.map +1 -1
- package/dist/guard.d.ts +57 -7
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +273 -59
- package/dist/guard.js.map +1 -1
- package/dist/harness-preflight.d.ts +25 -4
- package/dist/harness-preflight.d.ts.map +1 -1
- package/dist/harness-preflight.js +25 -29
- package/dist/harness-preflight.js.map +1 -1
- package/dist/keyed-lock.d.ts +2 -3
- package/dist/keyed-lock.d.ts.map +1 -1
- package/dist/keyed-lock.js +2 -3
- package/dist/keyed-lock.js.map +1 -1
- package/dist/leftovers.d.ts +9 -0
- package/dist/leftovers.d.ts.map +1 -0
- package/dist/leftovers.js +14 -0
- package/dist/leftovers.js.map +1 -0
- package/dist/local/credentials.d.ts +21 -0
- package/dist/local/credentials.d.ts.map +1 -0
- package/dist/local/credentials.js +39 -0
- package/dist/local/credentials.js.map +1 -0
- package/dist/local/leftovers.d.ts +8 -0
- package/dist/local/leftovers.d.ts.map +1 -0
- package/dist/local/leftovers.js +23 -0
- package/dist/local/leftovers.js.map +1 -0
- package/dist/local/local.d.ts +16 -10
- package/dist/local/local.d.ts.map +1 -1
- package/dist/local/local.js +163 -129
- package/dist/local/local.js.map +1 -1
- package/dist/memory-preflight.d.ts +25 -0
- package/dist/memory-preflight.d.ts.map +1 -0
- package/dist/memory-preflight.js +83 -0
- package/dist/memory-preflight.js.map +1 -0
- package/dist/pre-push-hook.d.ts +20 -0
- package/dist/pre-push-hook.d.ts.map +1 -0
- package/dist/pre-push-hook.js +33 -0
- package/dist/pre-push-hook.js.map +1 -0
- package/dist/prepared-attempt.d.ts +33 -3
- package/dist/prepared-attempt.d.ts.map +1 -1
- package/dist/prepared-attempt.js +109 -31
- package/dist/prepared-attempt.js.map +1 -1
- package/dist/provision.d.ts +77 -14
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +357 -55
- package/dist/provision.js.map +1 -1
- package/dist/remote/commands.d.ts +51 -0
- package/dist/remote/commands.d.ts.map +1 -0
- package/dist/remote/commands.js +94 -0
- package/dist/remote/commands.js.map +1 -0
- package/dist/remote/leftovers.d.ts +14 -0
- package/dist/remote/leftovers.d.ts.map +1 -0
- package/dist/remote/leftovers.js +22 -0
- package/dist/remote/leftovers.js.map +1 -0
- package/dist/remote/liveness.d.ts +33 -0
- package/dist/remote/liveness.d.ts.map +1 -0
- package/dist/remote/liveness.js +194 -0
- package/dist/remote/liveness.js.map +1 -0
- package/dist/remote/machine.d.ts +64 -0
- package/dist/remote/machine.d.ts.map +1 -0
- package/dist/remote/machine.js +2 -0
- package/dist/remote/machine.js.map +1 -0
- package/dist/remote/remote.d.ts +24 -0
- package/dist/remote/remote.d.ts.map +1 -0
- package/dist/remote/remote.js +308 -0
- package/dist/remote/remote.js.map +1 -0
- package/dist/remote/sweep.d.ts +15 -0
- package/dist/remote/sweep.d.ts.map +1 -0
- package/dist/remote/sweep.js +116 -0
- package/dist/remote/sweep.js.map +1 -0
- package/dist/renewable-credential.d.ts +17 -0
- package/dist/renewable-credential.d.ts.map +1 -0
- package/dist/renewable-credential.js +58 -0
- package/dist/renewable-credential.js.map +1 -0
- package/dist/salvage.d.ts +30 -0
- package/dist/salvage.d.ts.map +1 -0
- package/dist/salvage.js +104 -0
- package/dist/salvage.js.map +1 -0
- package/dist/ssh/credentials.d.ts +40 -0
- package/dist/ssh/credentials.d.ts.map +1 -0
- package/dist/ssh/credentials.js +83 -0
- package/dist/ssh/credentials.js.map +1 -0
- package/dist/ssh/gateway/admin.d.ts +45 -0
- package/dist/ssh/gateway/admin.d.ts.map +1 -0
- package/dist/ssh/gateway/admin.js +129 -0
- package/dist/ssh/gateway/admin.js.map +1 -0
- package/dist/ssh/gateway/attachments.d.ts +22 -0
- package/dist/ssh/gateway/attachments.d.ts.map +1 -0
- package/dist/ssh/gateway/attachments.js +154 -0
- package/dist/ssh/gateway/attachments.js.map +1 -0
- package/dist/ssh/gateway/environment.d.ts +52 -0
- package/dist/ssh/gateway/environment.d.ts.map +1 -0
- package/dist/ssh/gateway/environment.js +78 -0
- package/dist/ssh/gateway/environment.js.map +1 -0
- package/dist/ssh/gateway/forward.d.ts +74 -0
- package/dist/ssh/gateway/forward.d.ts.map +1 -0
- package/dist/ssh/gateway/forward.js +247 -0
- package/dist/ssh/gateway/forward.js.map +1 -0
- package/dist/ssh/gateway/preflight.d.ts +28 -0
- package/dist/ssh/gateway/preflight.d.ts.map +1 -0
- package/dist/ssh/gateway/preflight.js +234 -0
- package/dist/ssh/gateway/preflight.js.map +1 -0
- package/dist/ssh/model.d.ts +65 -0
- package/dist/ssh/model.d.ts.map +1 -0
- package/dist/ssh/model.js +2 -0
- package/dist/ssh/model.js.map +1 -0
- package/dist/ssh/preflight.d.ts +16 -0
- package/dist/ssh/preflight.d.ts.map +1 -0
- package/dist/ssh/preflight.js +47 -0
- package/dist/ssh/preflight.js.map +1 -0
- package/dist/ssh/ssh.d.ts +20 -0
- package/dist/ssh/ssh.d.ts.map +1 -0
- package/dist/ssh/ssh.js +78 -0
- package/dist/ssh/ssh.js.map +1 -0
- package/dist/ssh/workers.d.ts +53 -0
- package/dist/ssh/workers.d.ts.map +1 -0
- package/dist/ssh/workers.js +173 -0
- package/dist/ssh/workers.js.map +1 -0
- package/package.json +12 -4
- package/dist/exe-dev/channel.d.ts +0 -12
- package/dist/exe-dev/channel.d.ts.map +0 -1
- package/dist/exe-dev/channel.js +0 -42
- package/dist/exe-dev/channel.js.map +0 -1
- package/dist/exe-dev/shell.d.ts +0 -12
- package/dist/exe-dev/shell.d.ts.map +0 -1
- package/dist/exe-dev/shell.js +0 -31
- package/dist/exe-dev/shell.js.map +0 -1
- package/dist/exe-dev/sweep.d.ts +0 -10
- package/dist/exe-dev/sweep.d.ts.map +0 -1
- package/dist/exe-dev/sweep.js +0 -117
- package/dist/exe-dev/sweep.js.map +0 -1
- package/dist/invalid-frame.d.ts +0 -17
- package/dist/invalid-frame.d.ts.map +0 -1
- package/dist/invalid-frame.js +0 -111
- package/dist/invalid-frame.js.map +0 -1
- package/dist/run-host-session.d.ts +0 -27
- package/dist/run-host-session.d.ts.map +0 -1
- package/dist/run-host-session.js +0 -303
- package/dist/run-host-session.js.map +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { safeSegment } from "@usine/core/repository";
|
|
2
|
+
import { Context, Effect, Equal, Exit, Option, Ref, Scope, SynchronizedRef } from "effect";
|
|
3
|
+
import { HttpClient } from "effect/unstable/http";
|
|
4
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
5
|
+
import { WorkerCapabilityError } from "../executor.js";
|
|
6
|
+
import { gatewayAdminFor } from "./gateway/admin.js";
|
|
7
|
+
import { gatewayForwardFor } from "./gateway/forward.js";
|
|
8
|
+
/** The Workers of the SSH executor, starting with `SshExecutorOptions.workers`. A reload adds and removes Workers at runtime. */
|
|
9
|
+
export class SshWorkers extends Context.Service()("@usine/executor/SshWorkers") {
|
|
10
|
+
}
|
|
11
|
+
const forwardKey = ({ destination, adminPort }) => `${destination} ${String(adminPort)}`;
|
|
12
|
+
/** Returns the SSH command for one Worker: the shared options, then its port and key. */
|
|
13
|
+
const sshCommandFor = (base, address) => ({
|
|
14
|
+
command: base.command,
|
|
15
|
+
args: [
|
|
16
|
+
...base.args,
|
|
17
|
+
...Option.match(address.port, { onNone: () => [], onSome: (port) => ["-p", String(port)] }),
|
|
18
|
+
...Option.match(address.identityFile, {
|
|
19
|
+
onNone: () => [],
|
|
20
|
+
onSome: (file) => ["-i", file, "-o", "IdentitiesOnly=yes"],
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Returns the SSH Workers' machines, which `addWorker` and `removeWorker` change at runtime and
|
|
26
|
+
* `machineFor` reads on each call. Each admin API forward runs in its own child scope and
|
|
27
|
+
* closes with its last Worker or the caller's scope.
|
|
28
|
+
*/
|
|
29
|
+
export const sshMachinesFor = Effect.fnUntraced(function* (base, commands) {
|
|
30
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
31
|
+
const http = yield* HttpClient.HttpClient;
|
|
32
|
+
const scope = yield* Scope.Scope;
|
|
33
|
+
const machines = yield* SynchronizedRef.make({
|
|
34
|
+
byWorker: new Map(),
|
|
35
|
+
forwards: new Map(),
|
|
36
|
+
});
|
|
37
|
+
const openForward = Effect.fnUntraced(function* (settings) {
|
|
38
|
+
const forwardScope = yield* Scope.fork(scope);
|
|
39
|
+
const forward = yield* gatewayForwardFor(spawner, commands.shellFor(base, settings.destination), settings.destination, settings.adminPort).pipe(Scope.provide(forwardScope));
|
|
40
|
+
return { forward, scope: forwardScope };
|
|
41
|
+
});
|
|
42
|
+
/** Returns the Gateway for `address`'s machine with the forward it shares or opens, and the updated forwards. */
|
|
43
|
+
const gatewayFor = Effect.fnUntraced(function* (current, address, settings) {
|
|
44
|
+
const key = forwardKey(settings);
|
|
45
|
+
const shared = Option.fromNullishOr(current.forwards.get(key));
|
|
46
|
+
const { forward, scope: forwardScope } = Option.isSome(shared)
|
|
47
|
+
? shared.value
|
|
48
|
+
: yield* openForward(settings);
|
|
49
|
+
const admin = yield* gatewayAdminFor(address.name, settings, forward).pipe(Effect.provideService(HttpClient.HttpClient, http));
|
|
50
|
+
const workers = Option.match(shared, {
|
|
51
|
+
onNone: () => new Set([address.name]),
|
|
52
|
+
onSome: (held) => new Set([...held.workers, address.name]),
|
|
53
|
+
});
|
|
54
|
+
const anthropicCredential = yield* Ref.make(Option.none());
|
|
55
|
+
const warnedOfUnreportedCredential = yield* Ref.make(false);
|
|
56
|
+
return {
|
|
57
|
+
gateway: {
|
|
58
|
+
settings,
|
|
59
|
+
forward,
|
|
60
|
+
admin,
|
|
61
|
+
anthropicCredential,
|
|
62
|
+
warnedOfUnreportedCredential,
|
|
63
|
+
},
|
|
64
|
+
forwards: new Map(current.forwards).set(key, { forward, scope: forwardScope, workers }),
|
|
65
|
+
opened: Option.isNone(shared),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const addWorker = Effect.fn("SshExecutor.addWorker")(function* (address) {
|
|
69
|
+
const fields = {
|
|
70
|
+
worker: address.name,
|
|
71
|
+
host: address.destination,
|
|
72
|
+
...Option.match(address.gateway, {
|
|
73
|
+
onNone: () => ({}),
|
|
74
|
+
onSome: ({ destination }) => ({ gateway: destination }),
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
77
|
+
yield* Effect.annotateCurrentSpan(fields);
|
|
78
|
+
const added = yield* SynchronizedRef.modifyEffect(machines, (current) => Effect.gen(function* () {
|
|
79
|
+
const existing = current.byWorker.get(address.name);
|
|
80
|
+
if (existing !== undefined) {
|
|
81
|
+
if (Equal.equals(existing.address, address))
|
|
82
|
+
return [Option.none(), current];
|
|
83
|
+
return yield* new WorkerCapabilityError({
|
|
84
|
+
worker: address.name,
|
|
85
|
+
capability: "machine",
|
|
86
|
+
message: `Can't change the settings of SSH worker "${address.name}" while its attempts run. Reload again after they end.`,
|
|
87
|
+
cause: new Error(`SSH worker "${address.name}" is in use at ${existing.address.destination}`),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const behind = yield* Effect.transposeOption(Option.map(address.gateway, (settings) => gatewayFor(current, address, settings)));
|
|
91
|
+
const machine = {
|
|
92
|
+
address,
|
|
93
|
+
gateway: Option.map(behind, ({ gateway }) => gateway),
|
|
94
|
+
shell: commands.shellFor(sshCommandFor(base, address), address.destination),
|
|
95
|
+
workerDirectory: `${address.root}/workers/${safeSegment(address.name)}`,
|
|
96
|
+
};
|
|
97
|
+
return [
|
|
98
|
+
Option.some(Option.exists(behind, ({ opened }) => opened)),
|
|
99
|
+
{
|
|
100
|
+
byWorker: new Map(current.byWorker).set(address.name, machine),
|
|
101
|
+
forwards: Option.match(behind, {
|
|
102
|
+
onNone: () => current.forwards,
|
|
103
|
+
onSome: ({ forwards }) => forwards,
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
}).pipe(Effect.uninterruptible));
|
|
108
|
+
yield* Option.match(added, {
|
|
109
|
+
onNone: () => Effect.logDebug("The SSH executor has this Worker with the same settings already", fields),
|
|
110
|
+
onSome: (opened) => Effect.logInfo(Option.isNone(address.gateway)
|
|
111
|
+
? "SSH Worker added to the executor"
|
|
112
|
+
: opened
|
|
113
|
+
? "SSH Worker added to the executor; it is the first behind its Gateway, so the forward to the Gateway's admin API opens"
|
|
114
|
+
: "SSH Worker added to the executor; it shares the forward to its Gateway's admin API", fields),
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const removeWorker = Effect.fn("SshExecutor.removeWorker")(function* (worker) {
|
|
118
|
+
yield* Effect.annotateCurrentSpan({ worker });
|
|
119
|
+
const removed = yield* SynchronizedRef.modify(machines, (current) => {
|
|
120
|
+
const machine = current.byWorker.get(worker);
|
|
121
|
+
if (machine === undefined)
|
|
122
|
+
return [Option.none(), current];
|
|
123
|
+
const byWorker = new Map(current.byWorker);
|
|
124
|
+
byWorker.delete(worker);
|
|
125
|
+
const forwards = new Map(current.forwards);
|
|
126
|
+
const left = Option.flatMap(machine.gateway, ({ settings }) => {
|
|
127
|
+
const key = forwardKey(settings);
|
|
128
|
+
const held = forwards.get(key);
|
|
129
|
+
if (held === undefined)
|
|
130
|
+
return Option.none();
|
|
131
|
+
const workers = new Set(held.workers);
|
|
132
|
+
workers.delete(worker);
|
|
133
|
+
if (workers.size === 0)
|
|
134
|
+
forwards.delete(key);
|
|
135
|
+
else
|
|
136
|
+
forwards.set(key, { ...held, workers });
|
|
137
|
+
return Option.some({ held, others: workers.size });
|
|
138
|
+
});
|
|
139
|
+
return [Option.some({ machine, left }), { byWorker, forwards }];
|
|
140
|
+
});
|
|
141
|
+
if (Option.isNone(removed)) {
|
|
142
|
+
yield* Effect.logDebug("The SSH executor has no Worker by this name to remove", { worker });
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const { machine, left } = removed.value;
|
|
146
|
+
const fields = { worker, host: machine.address.destination };
|
|
147
|
+
if (Option.isNone(left)) {
|
|
148
|
+
yield* Effect.logInfo("SSH Worker removed from the executor", fields);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const { held, others } = left.value;
|
|
152
|
+
const gatewayFields = { ...fields, gateway: held.forward.gateway };
|
|
153
|
+
if (others > 0) {
|
|
154
|
+
yield* Effect.logInfo("SSH Worker removed from the executor; the forward to its Gateway's admin API stays open for the other Workers behind it", { ...gatewayFields, others });
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
yield* Scope.close(held.scope, Exit.void);
|
|
158
|
+
yield* Effect.logInfo("SSH Worker removed from the executor; it was the last behind its Gateway, so the forward to the Gateway's admin API closed", gatewayFields);
|
|
159
|
+
});
|
|
160
|
+
const machineFor = Effect.fn("SshExecutor.machineFor")(function* (worker) {
|
|
161
|
+
const machine = (yield* SynchronizedRef.get(machines)).byWorker.get(worker);
|
|
162
|
+
if (machine === undefined)
|
|
163
|
+
return yield* new WorkerCapabilityError({
|
|
164
|
+
worker,
|
|
165
|
+
capability: "machine",
|
|
166
|
+
message: `No SSH worker named "${worker}" is configured`,
|
|
167
|
+
cause: new Error("SSH worker address missing"),
|
|
168
|
+
});
|
|
169
|
+
return machine;
|
|
170
|
+
});
|
|
171
|
+
return { machineFor, workers: SshWorkers.of({ addWorker, removeWorker }) };
|
|
172
|
+
});
|
|
173
|
+
//# sourceMappingURL=workers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.js","sourceRoot":"","sources":["../../src/ssh/workers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MA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CAAC;YACF,OAAO;QACT,CAAC;QACD,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CACnB,4HAA4H,EAC5H,aAAa,CACd,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAkB;QAClF,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5E,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,KAAK,CAAC,CAAC,IAAI,qBAAqB,CAAC;gBACtC,MAAM;gBACN,UAAU,EAAE,SAAS;gBACrB,OAAO,EAAE,wBAAwB,MAAM,iBAAiB;gBACxD,KAAK,EAAE,IAAI,KAAK,CAAC,4BAA4B,CAAC;aAC/C,CAAC,CAAC;QACL,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;AAC7E,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usine/executor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The usine scoped Worker contract with local
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "The usine scoped Worker contract with local, exe.dev, and SSH adapters.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"directory": "packages/executor"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
13
14
|
],
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": false,
|
|
@@ -25,13 +26,20 @@
|
|
|
25
26
|
"./local": {
|
|
26
27
|
"types": "./dist/local/local.d.ts",
|
|
27
28
|
"default": "./dist/local/local.js"
|
|
29
|
+
},
|
|
30
|
+
"./ssh": {
|
|
31
|
+
"types": "./dist/ssh/ssh.d.ts",
|
|
32
|
+
"default": "./dist/ssh/ssh.js"
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
35
|
"publishConfig": {
|
|
31
36
|
"access": "public"
|
|
32
37
|
},
|
|
33
38
|
"dependencies": {
|
|
34
|
-
"@usine/
|
|
39
|
+
"@usine/agents": "0.4.0",
|
|
40
|
+
"@usine/core": "0.4.0",
|
|
41
|
+
"@usine/durable": "0.1.0",
|
|
42
|
+
"@usine/gateway": "0.1.0"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
45
|
"@effect/vitest": "4.0.0-rc.111",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type * as AttemptChannel from "@usine/core/attempt/channel";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
4
|
-
import type { AttemptWorkspace, RunHostCommand } from "../executor.ts";
|
|
5
|
-
import type { ExeDevCommands } from "./commands.ts";
|
|
6
|
-
import type { VmState } from "./model.ts";
|
|
7
|
-
export declare const attemptChannelFor: (commands: ExeDevCommands, runHost: RunHostCommand, interruptGrace: import("effect/Duration").Input) => Effect.Effect<{
|
|
8
|
-
cancel: (attemptId: import("@usine/core/attempt").AttemptId) => Effect.Effect<void, import("../executor.ts").ExecutorError>;
|
|
9
|
-
intervene: (attemptId: import("@usine/core/attempt").AttemptId, intervention: AttemptChannel.Intervention) => Effect.Effect<void, import("@usine/core/attempt/failure").AttemptFailure>;
|
|
10
|
-
launch: (prepared: AttemptWorkspace, vm: VmState, io: AttemptChannel.Sink) => Effect.Effect<import("@usine/core/step/result").StepResult, import("@usine/core/attempt/failure").AgentFailure | import("@usine/core/attempt/failure").ChildSessionBudgetFailure | import("@usine/core/attempt/failure").DefectFailure | import("@usine/core/attempt/failure").InfraFailure | import("@usine/core/attempt/failure").RunawayFailure, never>;
|
|
11
|
-
}, never, ChildProcessSpawner.ChildProcessSpawner>;
|
|
12
|
-
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/exe-dev/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,eAAO,MAAM,iBAAiB;;;uBAkDP,gBAAgB,MAAM,OAAO,MAAM,cAAc,CAAC,IAAI;kDAG3E,CAAC"}
|
package/dist/exe-dev/channel.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Effect, Stream } from "effect";
|
|
2
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
|
3
|
-
import { runHostSessionFor } from "../run-host-session.js";
|
|
4
|
-
import { runHostShellCommand } from "./shell.js";
|
|
5
|
-
export const attemptChannelFor = Effect.fn("ExeDevExecutor.attemptChannelFor")(function* (commands, runHost, interruptGrace) {
|
|
6
|
-
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
7
|
-
const spawn = Effect.fn("ExeDevExecutor.spawnRunHost")(function* (prepared, vm, input) {
|
|
8
|
-
const attemptId = prepared.spec.attemptId;
|
|
9
|
-
yield* Effect.annotateCurrentSpan({
|
|
10
|
-
attemptId,
|
|
11
|
-
worker: prepared.worker,
|
|
12
|
-
host: vm.sshDest,
|
|
13
|
-
});
|
|
14
|
-
yield* Effect.logInfo("Launching the run host over SSH", {
|
|
15
|
-
attemptId,
|
|
16
|
-
worker: prepared.worker,
|
|
17
|
-
host: vm.sshDest,
|
|
18
|
-
worktree: prepared.worktree,
|
|
19
|
-
});
|
|
20
|
-
const handle = yield* spawner.spawn(ChildProcess.make(commands.ssh.command, [
|
|
21
|
-
...commands.ssh.args,
|
|
22
|
-
vm.sshDest,
|
|
23
|
-
"--",
|
|
24
|
-
runHostShellCommand(prepared.worktree, runHost.command, runHost.args),
|
|
25
|
-
], {
|
|
26
|
-
env: commands.environment,
|
|
27
|
-
extendEnv: false,
|
|
28
|
-
stdin: { stream: Stream.fromQueue(input), endOnDone: true },
|
|
29
|
-
}));
|
|
30
|
-
// Nothing to scrub: this process never has a secret the run host could echo,
|
|
31
|
-
// because the exe.dev integration injects credentials on the VM. If a
|
|
32
|
-
// credential ever passes through this process, scrub it here.
|
|
33
|
-
return { handle, host: vm.sshDest, scrub: (text) => text };
|
|
34
|
-
});
|
|
35
|
-
const session = yield* runHostSessionFor({ interruptGrace });
|
|
36
|
-
return {
|
|
37
|
-
cancel: session.cancel,
|
|
38
|
-
intervene: session.intervene,
|
|
39
|
-
launch: (prepared, vm, io) => session.launch(prepared, io, (input) => spawn(prepared, vm, input)),
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=channel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/exe-dev/channel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,E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AAE,QAAQ,CAAC,WAAW;YACzB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE;SAC5D,CACF,CACF,CAAC;QACF,6EAA6E;QAC7E,sEAAsE;QACtE,8DAA8D;QAC9D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,EAAE,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7D,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,CAAC,QAA0B,EAAE,EAAW,EAAE,EAAuB,EAAE,EAAE,CAC3E,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/exe-dev/shell.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Quotes a command and its arguments into one string safe for OpenSSH's remote-command boundary. */
|
|
2
|
-
export declare const shellCommand: (command: string, args: ReadonlyArray<string>) => string;
|
|
3
|
-
/** The pid file sits beside the worktree so the sweep reclaims both together. */
|
|
4
|
-
export declare const runHostPidFile: (worktree: string) => string;
|
|
5
|
-
/** The remote command that starts the run host in its worktree with the edge GitHub host selected. */
|
|
6
|
-
export declare const runHostShellCommand: (worktree: string, command: string, args: ReadonlyArray<string>) => string;
|
|
7
|
-
/**
|
|
8
|
-
* Confirms a recorded run host is dead before workspace removal: TERM, a
|
|
9
|
-
* bounded wait, then KILL. `$1` is the pid file; stdout reports the outcome.
|
|
10
|
-
*/
|
|
11
|
-
export declare const RUN_HOST_KILL_SCRIPT: string;
|
|
12
|
-
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/exe-dev/shell.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,eAAO,MAAM,YAAY,YAAa,MAAM,QAAQ,aAAa,CAAC,MAAM,CAAC,KAAG,MACzB,CAAC;AAEpD,iFAAiF;AACjF,eAAO,MAAM,cAAc,aAAc,MAAM,KAAG,MAA2B,CAAC;AAE9E,sGAAsG;AACtG,eAAO,MAAM,mBAAmB,aACpB,MAAM,WACP,MAAM,QACT,aAAa,CAAC,MAAM,CAAC,KAC1B,MAIsJ,CAAC;AAE1J;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAczB,CAAC"}
|
package/dist/exe-dev/shell.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const quote = (value) => `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
2
|
-
/** Quotes a command and its arguments into one string safe for OpenSSH's remote-command boundary. */
|
|
3
|
-
export const shellCommand = (command, args) => `exec ${[command, ...args].map(quote).join(" ")}`;
|
|
4
|
-
/** The pid file sits beside the worktree so the sweep reclaims both together. */
|
|
5
|
-
export const runHostPidFile = (worktree) => `${worktree}.pid`;
|
|
6
|
-
/** The remote command that starts the run host in its worktree with the edge GitHub host selected. */
|
|
7
|
-
export const runHostShellCommand = (worktree, command, args) =>
|
|
8
|
-
// `$$` names the remote shell that `exec` replaces with the run host, so the
|
|
9
|
-
// pid file identifies the run host itself. Cleanup uses it to confirm the
|
|
10
|
-
// process is gone before removing the worktree.
|
|
11
|
-
`cd ${quote(worktree)} && export GH_HOST=github.int.exe.xyz && printf '%s' "$$" > ${quote(runHostPidFile(worktree))} && ${shellCommand(command, args)}`;
|
|
12
|
-
/**
|
|
13
|
-
* Confirms a recorded run host is dead before workspace removal: TERM, a
|
|
14
|
-
* bounded wait, then KILL. `$1` is the pid file; stdout reports the outcome.
|
|
15
|
-
*/
|
|
16
|
-
export const RUN_HOST_KILL_SCRIPT = `
|
|
17
|
-
if test -f "$1"; then
|
|
18
|
-
pid=$(cat "$1")
|
|
19
|
-
if kill -TERM "$pid" 2>/dev/null; then
|
|
20
|
-
n=0
|
|
21
|
-
while kill -0 "$pid" 2>/dev/null && [ "$n" -lt 10 ]; do sleep 0.5; n=$((n+1)); done
|
|
22
|
-
if kill -0 "$pid" 2>/dev/null; then kill -KILL "$pid" 2>/dev/null; echo killed; else echo stopped; fi
|
|
23
|
-
else
|
|
24
|
-
echo absent
|
|
25
|
-
fi
|
|
26
|
-
rm -f "$1"
|
|
27
|
-
else
|
|
28
|
-
echo no-pidfile
|
|
29
|
-
fi
|
|
30
|
-
`.trim();
|
|
31
|
-
//# sourceMappingURL=shell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/exe-dev/shell.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;AAE/E,qGAAqG;AACrG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,IAA2B,EAAU,EAAE,CACnF,QAAQ,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEpD,iFAAiF;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,GAAG,QAAQ,MAAM,CAAC;AAE9E,sGAAsG;AACtG,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAAgB,EAChB,OAAe,EACf,IAA2B,EACnB,EAAE;AACV,6EAA6E;AAC7E,0EAA0E;AAC1E,gDAAgD;AAChD,MAAM,KAAK,CAAC,QAAQ,CAAC,+DAA+D,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,OAAO,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;AAE1J;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;CAcnC,CAAC,IAAI,EAAE,CAAC"}
|
package/dist/exe-dev/sweep.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import type { ExeDevCommands } from "./commands.ts";
|
|
3
|
-
import type { VmState } from "./model.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Reclaims crash leftovers once per Worker before this process starts work on
|
|
6
|
-
* its VM. Each removal is isolated and each failure is logged, so one immovable
|
|
7
|
-
* leftover never blocks the sweep's siblings or a future prepare.
|
|
8
|
-
*/
|
|
9
|
-
export declare const abandonedWorktreeSweepFor: (commands: ExeDevCommands) => Effect.Effect<(attemptId: string & import("effect/Brand").Brand<"AttemptId">, worker: string & import("effect/Brand").Brand<"WorkerName">, vm: VmState, root: string) => Effect.Effect<void, never, never>, never, never>;
|
|
10
|
-
//# sourceMappingURL=sweep.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sweep.d.ts","sourceRoot":"","sources":["../../src/exe-dev/sweep.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAG7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAwC1C;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,yPAiIrC,CAAC"}
|
package/dist/exe-dev/sweep.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { AttemptId } from "@usine/core/attempt";
|
|
2
|
-
import { WorkerName } from "@usine/core/worker";
|
|
3
|
-
import { Effect, Ref, Schema } from "effect";
|
|
4
|
-
import { ExecutorOperationError } from "../executor.js";
|
|
5
|
-
import { keyedLockFor } from "../keyed-lock.js";
|
|
6
|
-
const SWEEP_CONCURRENCY = 4;
|
|
7
|
-
const directChildSchema = (parent) => {
|
|
8
|
-
const prefix = `${parent}/`;
|
|
9
|
-
return Schema.String.check(Schema.makeFilter((value) => {
|
|
10
|
-
const segment = value.slice(prefix.length);
|
|
11
|
-
return (value.startsWith(prefix) &&
|
|
12
|
-
segment.length > 0 &&
|
|
13
|
-
segment !== "." &&
|
|
14
|
-
segment !== ".." &&
|
|
15
|
-
!segment.includes("/"));
|
|
16
|
-
}, { message: `Expected a direct child of ${parent}` }));
|
|
17
|
-
};
|
|
18
|
-
const directChildren = (parent, output) => Schema.decodeUnknownEffect(Schema.Array(directChildSchema(parent)))(output.split("\0").filter((value) => value.length > 0)).pipe(Effect.mapError((cause) => new ExecutorOperationError({
|
|
19
|
-
operation: "prepare",
|
|
20
|
-
message: `Worker returned an invalid path while sweeping ${parent}`,
|
|
21
|
-
cause,
|
|
22
|
-
})));
|
|
23
|
-
/**
|
|
24
|
-
* Reclaims crash leftovers once per Worker before this process starts work on
|
|
25
|
-
* its VM. Each removal is isolated and each failure is logged, so one immovable
|
|
26
|
-
* leftover never blocks the sweep's siblings or a future prepare.
|
|
27
|
-
*/
|
|
28
|
-
export const abandonedWorktreeSweepFor = Effect.fn("ExeDevExecutor.abandonedWorktreeSweepFor")(function* (commands) {
|
|
29
|
-
const locks = yield* keyedLockFor();
|
|
30
|
-
const swept = yield* Ref.make(new Set());
|
|
31
|
-
const sweep = Effect.fn("ExeDevExecutor.sweepAbandonedWorktrees")(function* (attemptId, worker, vm, root) {
|
|
32
|
-
yield* Effect.annotateCurrentSpan({ attemptId, worker, host: vm.sshDest });
|
|
33
|
-
yield* locks.withLock(worker)(Effect.gen(function* () {
|
|
34
|
-
if ((yield* Ref.get(swept)).has(worker)) {
|
|
35
|
-
yield* Effect.logDebug("exe.dev abandoned-worktree sweep was already complete", {
|
|
36
|
-
attemptId,
|
|
37
|
-
worker,
|
|
38
|
-
host: vm.sshDest,
|
|
39
|
-
});
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
// Mark the sweep done before it runs. A partial sweep must not retry in
|
|
43
|
-
// front of every prepare; the next process start reclaims what failed.
|
|
44
|
-
yield* Ref.update(swept, (current) => new Set(current).add(worker));
|
|
45
|
-
const attemptsRoot = `${root}/attempts`;
|
|
46
|
-
const reposRoot = `${root}/repos`;
|
|
47
|
-
yield* Effect.logInfo("Sweeping abandoned exe.dev Attempt worktrees", {
|
|
48
|
-
attemptId,
|
|
49
|
-
worker,
|
|
50
|
-
host: vm.sshDest,
|
|
51
|
-
});
|
|
52
|
-
yield* commands.remote("prepare", vm.sshDest, "mkdir", ["-p", attemptsRoot, reposRoot]);
|
|
53
|
-
const attempts = yield* commands
|
|
54
|
-
.remote("prepare", vm.sshDest, "find", [
|
|
55
|
-
attemptsRoot,
|
|
56
|
-
"-mindepth",
|
|
57
|
-
"1",
|
|
58
|
-
"-maxdepth",
|
|
59
|
-
"1",
|
|
60
|
-
"-print0",
|
|
61
|
-
])
|
|
62
|
-
.pipe(Effect.flatMap((output) => directChildren(attemptsRoot, output)));
|
|
63
|
-
const failures = yield* Ref.make(0);
|
|
64
|
-
yield* Effect.forEach(attempts, (worktree) => Effect.logInfo("Sweeping abandoned exe.dev Attempt worktree", {
|
|
65
|
-
attemptId,
|
|
66
|
-
worker,
|
|
67
|
-
host: vm.sshDest,
|
|
68
|
-
worktree,
|
|
69
|
-
}).pipe(Effect.andThen(commands.remote("prepare", vm.sshDest, "rm", ["-rf", worktree])), Effect.tapError((error) => Effect.logWarning("Could not remove an abandoned exe.dev worktree", {
|
|
70
|
-
attemptId,
|
|
71
|
-
worker,
|
|
72
|
-
host: vm.sshDest,
|
|
73
|
-
worktree,
|
|
74
|
-
message: error.message,
|
|
75
|
-
}).pipe(Effect.andThen(Ref.update(failures, (count) => count + 1)))), Effect.ignore), { concurrency: SWEEP_CONCURRENCY, discard: true });
|
|
76
|
-
const caches = yield* commands
|
|
77
|
-
.remote("prepare", vm.sshDest, "find", [
|
|
78
|
-
reposRoot,
|
|
79
|
-
"-mindepth",
|
|
80
|
-
"1",
|
|
81
|
-
"-maxdepth",
|
|
82
|
-
"1",
|
|
83
|
-
"-type",
|
|
84
|
-
"d",
|
|
85
|
-
"-name",
|
|
86
|
-
"*.git",
|
|
87
|
-
"-print0",
|
|
88
|
-
])
|
|
89
|
-
.pipe(Effect.flatMap((output) => directChildren(reposRoot, output)));
|
|
90
|
-
yield* Effect.forEach(caches, (cache) => commands
|
|
91
|
-
.remote("prepare", vm.sshDest, "git", ["--git-dir", cache, "worktree", "prune"])
|
|
92
|
-
.pipe(Effect.tapError((error) => Effect.logWarning("Could not prune an exe.dev cache during the sweep", {
|
|
93
|
-
attemptId,
|
|
94
|
-
worker,
|
|
95
|
-
host: vm.sshDest,
|
|
96
|
-
cache,
|
|
97
|
-
message: error.message,
|
|
98
|
-
})), Effect.ignore), { concurrency: SWEEP_CONCURRENCY, discard: true });
|
|
99
|
-
const failed = yield* Ref.get(failures);
|
|
100
|
-
yield* Effect.logInfo("exe.dev abandoned-worktree sweep completed", {
|
|
101
|
-
attemptId,
|
|
102
|
-
worker,
|
|
103
|
-
host: vm.sshDest,
|
|
104
|
-
removed: attempts.length - failed,
|
|
105
|
-
failed,
|
|
106
|
-
caches: caches.length,
|
|
107
|
-
});
|
|
108
|
-
}).pipe(Effect.tapError((error) => Effect.logWarning("exe.dev abandoned-worktree sweep failed; continuing", {
|
|
109
|
-
attemptId,
|
|
110
|
-
worker,
|
|
111
|
-
host: vm.sshDest,
|
|
112
|
-
message: error.message,
|
|
113
|
-
})), Effect.ignore));
|
|
114
|
-
});
|
|
115
|
-
return sweep;
|
|
116
|
-
});
|
|
117
|
-
//# sourceMappingURL=sweep.js.map
|
|
@@ -1 +0,0 @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,UAAU,CAAC,mDAAmD,EAAE;gBACrE,SAAS;gBACT,MAAM;gBACN,IAAI,EAAE,EAAE,CAAC,OAAO;gBAChB,KAAK;gBACL,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CACH,EACD,MAAM,CAAC,MAAM,CACd,EACL,EAAE,WAAW,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,CAClD,CAAC;YAEF,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,4CAA4C,EAAE;gBAClE,SAAS;gBACT,MAAM;gBACN,IAAI,EAAE,EAAE,CAAC,OAAO;gBAChB,OAAO,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM;gBACjC,MAAM;gBACN,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,MAAM,CAAC,UAAU,CAAC,qDAAqD,EAAE;YACvE,SAAS;YACT,MAAM;YACN,IAAI,EAAE,EAAE,CAAC,OAAO;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CACH,EACD,MAAM,CAAC,MAAM,CACd,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CACF,CAAC"}
|
package/dist/invalid-frame.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type FrameSource = "effect-log" | "json" | "non-json";
|
|
2
|
-
export interface InvalidFrameDiagnostic {
|
|
3
|
-
readonly byteLength: number;
|
|
4
|
-
readonly eventTag: string | undefined;
|
|
5
|
-
readonly issues: ReadonlyArray<{
|
|
6
|
-
readonly message: string;
|
|
7
|
-
readonly path: string;
|
|
8
|
-
}>;
|
|
9
|
-
readonly payloadTag: string | undefined;
|
|
10
|
-
readonly source: FrameSource;
|
|
11
|
-
readonly version: number | undefined;
|
|
12
|
-
}
|
|
13
|
-
/** Describes an invalid frame by shape and schema metadata only, never by its content. */
|
|
14
|
-
export declare const invalidFrameDiagnostic: (line: string, cause: unknown) => InvalidFrameDiagnostic;
|
|
15
|
-
export declare const invalidFrameMessage: (diagnostic: InvalidFrameDiagnostic) => string;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=invalid-frame.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-frame.d.ts","sourceRoot":"","sources":["../src/invalid-frame.ts"],"names":[],"mappings":"AAkEA,KAAK,WAAW,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;QAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAeD,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,SAAU,MAAM,SAAS,OAAO,KAAG,sBAgCrE,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAAgB,sBAAsB,KAAG,MAUxE,CAAC"}
|
package/dist/invalid-frame.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { Option, Schema, SchemaIssue } from "effect";
|
|
2
|
-
const encoder = new TextEncoder();
|
|
3
|
-
const SAFE_TAG_VALUES = [
|
|
4
|
-
"Started",
|
|
5
|
-
"SessionEvent",
|
|
6
|
-
"Final",
|
|
7
|
-
"Failed",
|
|
8
|
-
"Interrupted",
|
|
9
|
-
"SessionStarted",
|
|
10
|
-
"TextOutput",
|
|
11
|
-
"ToolStarted",
|
|
12
|
-
"ToolFinished",
|
|
13
|
-
"PoolRateLimitsUpdated",
|
|
14
|
-
"SessionFinished",
|
|
15
|
-
];
|
|
16
|
-
const SafeFrameTag = Schema.Literals(SAFE_TAG_VALUES);
|
|
17
|
-
const FramePreview = Schema.Struct({
|
|
18
|
-
version: Schema.optionalKey(Schema.Int),
|
|
19
|
-
payload: Schema.optionalKey(Schema.Struct({
|
|
20
|
-
_tag: Schema.optionalKey(Schema.String),
|
|
21
|
-
event: Schema.optionalKey(Schema.Struct({ _tag: Schema.optionalKey(Schema.String) })),
|
|
22
|
-
})),
|
|
23
|
-
});
|
|
24
|
-
const decodeJsonOption = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Json));
|
|
25
|
-
const decodeFramePreviewOption = Schema.decodeUnknownOption(FramePreview);
|
|
26
|
-
const decodeSafeFrameTagOption = Schema.decodeUnknownOption(SafeFrameTag);
|
|
27
|
-
const SAFE_PATH_SEGMENTS = new Set([
|
|
28
|
-
"version",
|
|
29
|
-
"attemptId",
|
|
30
|
-
"sequence",
|
|
31
|
-
"sentAt",
|
|
32
|
-
"payload",
|
|
33
|
-
"_tag",
|
|
34
|
-
"event",
|
|
35
|
-
"session",
|
|
36
|
-
"id",
|
|
37
|
-
"parentId",
|
|
38
|
-
"agent",
|
|
39
|
-
"brain",
|
|
40
|
-
"harness",
|
|
41
|
-
"model",
|
|
42
|
-
"effort",
|
|
43
|
-
"callId",
|
|
44
|
-
"tool",
|
|
45
|
-
"input",
|
|
46
|
-
"output",
|
|
47
|
-
"isError",
|
|
48
|
-
"text",
|
|
49
|
-
"pool",
|
|
50
|
-
"rateLimits",
|
|
51
|
-
"limitId",
|
|
52
|
-
"limitName",
|
|
53
|
-
"primary",
|
|
54
|
-
"secondary",
|
|
55
|
-
"usedPercent",
|
|
56
|
-
"windowDurationMinutes",
|
|
57
|
-
"resetsAt",
|
|
58
|
-
"parentModel",
|
|
59
|
-
"parentEffort",
|
|
60
|
-
"result",
|
|
61
|
-
"failure",
|
|
62
|
-
]);
|
|
63
|
-
const formatSchemaIssues = SchemaIssue.makeFormatterStandardSchemaV1();
|
|
64
|
-
const safeIssuePath = (path) => path
|
|
65
|
-
.map((segment) => {
|
|
66
|
-
const value = String(segment);
|
|
67
|
-
return SAFE_PATH_SEGMENTS.has(value) ? value : "<unexpected>";
|
|
68
|
-
})
|
|
69
|
-
.join(".");
|
|
70
|
-
/** Describes an invalid frame by shape and schema metadata only, never by its content. */
|
|
71
|
-
export const invalidFrameDiagnostic = (line, cause) => {
|
|
72
|
-
const byteLength = encoder.encode(line).byteLength;
|
|
73
|
-
const parsed = decodeJsonOption(line);
|
|
74
|
-
if (Option.isNone(parsed)) {
|
|
75
|
-
return {
|
|
76
|
-
byteLength,
|
|
77
|
-
eventTag: undefined,
|
|
78
|
-
issues: [],
|
|
79
|
-
payloadTag: undefined,
|
|
80
|
-
source: /^\[\d{2}:\d{2}:\d{2}[.\]]/u.test(line) ? "effect-log" : "non-json",
|
|
81
|
-
version: undefined,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
const preview = decodeFramePreviewOption(parsed.value);
|
|
85
|
-
const issues = Schema.isSchemaError(cause)
|
|
86
|
-
? formatSchemaIssues(cause.issue).issues.map((issue) => ({
|
|
87
|
-
message: issue.message.slice(0, 200),
|
|
88
|
-
path: safeIssuePath(issue.path ?? []),
|
|
89
|
-
}))
|
|
90
|
-
: [];
|
|
91
|
-
return {
|
|
92
|
-
byteLength,
|
|
93
|
-
eventTag: Option.flatMap(preview, ({ payload }) => decodeSafeFrameTagOption(payload?.event?._tag)).pipe(Option.getOrUndefined),
|
|
94
|
-
issues,
|
|
95
|
-
payloadTag: Option.flatMap(preview, ({ payload }) => decodeSafeFrameTagOption(payload?._tag)).pipe(Option.getOrUndefined),
|
|
96
|
-
source: "json",
|
|
97
|
-
version: Option.map(preview, ({ version }) => version).pipe(Option.getOrUndefined),
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export const invalidFrameMessage = (diagnostic) => {
|
|
101
|
-
if (diagnostic.source !== "json") {
|
|
102
|
-
return diagnostic.source === "effect-log"
|
|
103
|
-
? "The run host wrote a log line to its protocol output"
|
|
104
|
-
: "The run host emitted malformed JSON";
|
|
105
|
-
}
|
|
106
|
-
const first = diagnostic.issues[0];
|
|
107
|
-
return first === undefined
|
|
108
|
-
? "The run host emitted a schema-invalid frame"
|
|
109
|
-
: `The run host emitted a schema-invalid frame at ${first.path || "<root>"}: ${first.message}`;
|
|
110
|
-
};
|
|
111
|
-
//# sourceMappingURL=invalid-frame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-frame.js","sourceRoot":"","sources":["../src/invalid-frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,eAAe,GAAG;IACtB,SAAS;IACT,cAAc;IACd,OAAO;IACP,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,cAAc;IACd,uBAAuB;IACvB,iBAAiB;CACT,CAAC;AACX,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AACtD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QACvC,KAAK,EAAE,MA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