omp-superagent 0.1.13 → 0.1.15
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/DESIGN.md +8 -5
- package/THIRD_PARTY_NOTICES.md +6 -0
- package/assets/architecture-dark.svg +4 -4
- package/assets/architecture.ko-dark.svg +4 -4
- package/assets/architecture.ko.svg +4 -4
- package/assets/architecture.mmd +5 -5
- package/assets/architecture.svg +4 -4
- package/config.example.json +1 -0
- package/docs/OPERATIONS.en.md +59 -23
- package/docs/OPERATIONS.md +53 -18
- package/docs/design/execution.md +161 -43
- package/docs/design/messaging.md +45 -9
- package/docs/releases/0.1.15.md +13 -0
- package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
- package/gateway/bin/omp-gateway-darwin-x64 +0 -0
- package/gateway/bin/omp-gateway-linux-arm64 +0 -0
- package/gateway/bin/omp-gateway-linux-x64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
- package/package.json +6 -3
- package/scripts/prepare-worker-memory.ts +37 -0
- package/skills/head/SKILL.md +22 -47
- package/skills/head/references/routing.md +11 -12
- package/skills/head/references/supervision.md +10 -14
- package/skills/lane/SKILL.md +14 -16
- package/skills/lane/references/workflow.md +14 -27
- package/src/cli.ts +56 -56
- package/src/config/config.ts +4 -0
- package/src/contracts.ts +34 -27
- package/src/cron/cron-jobs.ts +4 -3
- package/src/cron/cron-pr-intake.ts +1 -2
- package/src/extension.ts +57 -14
- package/src/gateway/gateway-client.ts +14 -12
- package/src/group/group-runner.ts +3 -2
- package/src/group-runner-extension.ts +7 -3
- package/src/host-extension.ts +109 -2
- package/src/host-sdk-helper.ts +6 -1
- package/src/lane/decision-tool.ts +2 -3
- package/src/lane/lane-report.ts +8 -30
- package/src/lane/lane-rows.ts +1 -1
- package/src/lane/workflow.ts +44 -3
- package/src/lane-extension.ts +5 -46
- package/src/messaging/discord-context.ts +8 -6
- package/src/omp/host-protocol.ts +4 -3
- package/src/omp/host.ts +24 -7
- package/src/omp/managed-super.ts +43 -27
- package/src/omp/native-sessions.ts +12 -0
- package/src/omp/worker-memory-import.ts +410 -0
- package/src/omp/worker-memory-sdk.ts +8 -0
- package/src/operator/setup.ts +8 -13
- package/src/pr/pr-github-schema.ts +9 -0
- package/src/pr/pr-github.ts +6 -2
- package/src/pr/pr-intake-automation.ts +11 -8
- package/src/pr/pr-intake-fix.ts +2 -5
- package/src/pr/pr-intake-review.ts +7 -7
- package/src/routing/topic-history.ts +2 -2
- package/src/runtime/controller.ts +444 -408
- package/src/runtime/head-recovery.ts +7 -7
- package/src/runtime/worker-memory.ts +156 -0
- package/src/storage/deferred-routing.ts +1 -7
- package/src/storage/store.ts +441 -375
- package/src/worker/worker-host.ts +3 -2
- package/src/worker/worker-ledger.ts +20 -11
- package/src/worker/worker-memory-page.ts +83 -0
- package/src/worker/worker-memory-proofs.ts +260 -0
- package/src/worker/worker-memory-source.ts +305 -0
- package/src/worker/worker-memory-storage.ts +130 -0
- package/src/worker/worker-profile.ts +2 -0
- package/src/worker/worker-repository.ts +92 -7
- package/src/worker/worker-request.ts +1 -0
- package/src/worker/worker-service.ts +25 -8
- package/src/worker/worker-wire.ts +20 -6
|
@@ -7,6 +7,7 @@ import { boundWorkspace, enrolledRepo, privateWorkerDirectory, reserveCheckout }
|
|
|
7
7
|
import { absentWorkerHost, attestWorkerHost, inspectWorkerHost, readWorkerFiles,
|
|
8
8
|
WORKER_ATTEMPT_ENV, WORKER_SESSION_ENV, workerPaths } from "./worker-host";
|
|
9
9
|
import { WorkerLedger, type WorkerReceipt } from "./worker-ledger";
|
|
10
|
+
import { WORKER_MEMORY_WIRE_ENV } from "./worker-memory-storage";
|
|
10
11
|
import { assertWorkerGitStartup, requireWorkerStartupFlags, workerLaunchProfile, workerManagedUlwPath } from "./worker-profile";
|
|
11
12
|
import { parseWorkerPolicy, parseWorkerRequest, WorkerRefusal } from "./worker-request";
|
|
12
13
|
import type { WorkerDescription, WorkerLaneRef, WorkerLaunch, WorkerPolicy, WorkerProbe, WorkerRepo } from "./worker-wire";
|
|
@@ -95,7 +96,7 @@ class WorkerService {
|
|
|
95
96
|
async probe(ref: WorkerLaneRef, reconcile = false): Promise<WorkerProbe> {
|
|
96
97
|
const lane = this.#lane(ref);
|
|
97
98
|
const observed = this.#receipt(lane);
|
|
98
|
-
const { exitGeneration, ...probe } = await inspectWorkerHost(this.#ledger, lane.paths, observed);
|
|
99
|
+
const { exitGeneration, memorySyncVersion, ...probe } = await inspectWorkerHost(this.#ledger, lane.paths, observed);
|
|
99
100
|
// Do not claim ownership or absence for a newer generation unless the current
|
|
100
101
|
// resident was positively released and no different attempt raced this probe.
|
|
101
102
|
if (this.#receipt(lane)?.attempt !== observed?.attempt ||
|
|
@@ -103,15 +104,21 @@ class WorkerService {
|
|
|
103
104
|
return { ...probe, uncertain: true, pid: null, sessionId: null };
|
|
104
105
|
const absent = !probe.uncertain && !probe.socket && !probe.pidAlive && !probe.ownerAlive && probe.pid === null;
|
|
105
106
|
const sealed = absent && this.#ledger.confirmRelease(ref, lane.repo.cwd, { observed, reconcile });
|
|
107
|
+
const memoryLaunch = process.env[WORKER_MEMORY_WIRE_ENV] === "1" && absent && !probe.sessionFile && !sealed;
|
|
106
108
|
return { ...probe, ...(sealed && { sealedGeneration: ref.generation }),
|
|
107
|
-
...(sealed && exitGeneration === ref.generation && { exitGeneration })
|
|
109
|
+
...(sealed && exitGeneration === ref.generation && { exitGeneration }),
|
|
110
|
+
...(memoryLaunch && { memoryLaunchVersion: 1 }),
|
|
111
|
+
...(!probe.uncertain && probe.socket && observed?.generation === ref.generation
|
|
112
|
+
&& observed.privateMemoryPrepared && observed.memory?.proof && { memoryPreparedVersion: 1 }),
|
|
113
|
+
...(memorySyncVersion === 1 && observed?.generation === ref.generation && { memorySyncVersion }) };
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
async open(ref: WorkerLaneRef, launch: WorkerLaunch): Promise<{ pid: number }> {
|
|
111
117
|
const lane = this.#lane(ref);
|
|
112
118
|
const preset = launch.modelPreset;
|
|
113
119
|
const launchDigest = createHash("sha256").update(JSON.stringify([launch.model, launch.subagentConcurrency,
|
|
114
|
-
preset?.name, preset?.preset.defaultThinkingLevel, Object.entries(preset?.preset.modelRoles ?? {}).sort()
|
|
120
|
+
preset?.name, preset?.preset.defaultThinkingLevel, Object.entries(preset?.preset.modelRoles ?? {}).sort(),
|
|
121
|
+
...(launch.memorySync ? [true] : [])])).digest("hex");
|
|
115
122
|
const observed = this.#receipt(lane);
|
|
116
123
|
if (observed?.generation === ref.generation) {
|
|
117
124
|
if (observed.launchDigest !== launchDigest)
|
|
@@ -131,9 +138,15 @@ class WorkerService {
|
|
|
131
138
|
if (previous && previous.gitDir !== gitDir) throw new WorkerRefusal("Worker checkout metadata directory changed");
|
|
132
139
|
const initial = await readWorkerFiles(lane.paths);
|
|
133
140
|
if (absentWorkerHost(initial, previous).uncertain) throw new WorkerRefusal("Worker lane has an unverified socket or journal");
|
|
141
|
+
if (launch.memorySync && process.env[WORKER_MEMORY_WIRE_ENV] !== "1")
|
|
142
|
+
throw new WorkerRefusal("Worker memory is not supported by this transport");
|
|
143
|
+
if (launch.memorySync && initial.session && !previous?.memory)
|
|
144
|
+
throw new WorkerRefusal("Worker memory cannot redirect an existing native session");
|
|
145
|
+
const memoryKey = previous?.memory?.key ?? (launch.memorySync ? crypto.randomUUID() : undefined);
|
|
134
146
|
// Commit admission before reserving the checkout, publishing any session
|
|
135
147
|
// artifacts, or starting the stock OMP process.
|
|
136
|
-
const reservation = this.#ledger.reserve(ref, { repoRoot: lane.repo.cwd, gitDir, launchDigest
|
|
148
|
+
const reservation = this.#ledger.reserve(ref, { repoRoot: lane.repo.cwd, gitDir, launchDigest,
|
|
149
|
+
...(previous?.memory && { memory: previous.memory }) }, previous);
|
|
137
150
|
let cwd: string;
|
|
138
151
|
let target: ReturnType<typeof workerLaunchProfile>;
|
|
139
152
|
let managedUlwPath: string;
|
|
@@ -153,17 +166,21 @@ class WorkerService {
|
|
|
153
166
|
this.#ledger.retire(reservation);
|
|
154
167
|
throw error;
|
|
155
168
|
}
|
|
156
|
-
|
|
169
|
+
let launching = { ...reservation, phase: "launching" } as const;
|
|
157
170
|
let preparingSession = false;
|
|
158
171
|
try {
|
|
172
|
+
const { memorySync: _memorySync, ...hostLaunch } = launch;
|
|
159
173
|
const { pid } = await startHost({
|
|
160
|
-
...
|
|
174
|
+
...hostLaunch, cwd, command: [target.executable], socketPath: lane.paths.socketPath,
|
|
161
175
|
sessionFile: lane.paths.sessionFile, logPath: lane.paths.logPath,
|
|
162
176
|
extensionPath: fileURLToPath(new URL("../lane-extension.ts", import.meta.url)),
|
|
163
|
-
worker: { ...target.profile, managedUlwPath
|
|
177
|
+
worker: { ...target.profile, managedUlwPath,
|
|
178
|
+
...(memoryKey && { memory: { key: memoryKey, previous: previous?.memory,
|
|
179
|
+
checkout: { repoRoot: lane.repo.cwd, gitDir, repoId: ref.repoId, revision: ref.revision, subdir: ref.subdir } } }) },
|
|
164
180
|
env: { ...target.env, OMP_SUPERAGENT_ROLE: "lane", OMP_SUPERAGENT_LANE: launching.laneId,
|
|
165
181
|
[WORKER_ATTEMPT_ENV]: launching.attempt, [WORKER_SESSION_ENV]: launching.sessionId ?? "" },
|
|
166
|
-
},
|
|
182
|
+
}, memory => {
|
|
183
|
+
if (memory) launching = { ...launching, memory, privateMemoryPrepared: true };
|
|
167
184
|
if (!this.#ledger.transition(reservation, launching)) throw new WorkerRefusal("Worker launch reservation is no longer current");
|
|
168
185
|
preparingSession = true;
|
|
169
186
|
});
|
|
@@ -39,8 +39,14 @@ export interface WorkerProbe {
|
|
|
39
39
|
readonly sealedGeneration?: number;
|
|
40
40
|
/** Exact generation whose persisted native exit the worker verified. */
|
|
41
41
|
readonly exitGeneration?: number;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
/** The wire accepts opt-in on a fresh, absent, unsealed worker lane. */
|
|
43
|
+
readonly memoryLaunchVersion?: 1;
|
|
44
|
+
/** Private storage was prepared for this attempt; readiness can be checked after native init. */
|
|
45
|
+
readonly memoryPreparedVersion?: 1;
|
|
46
|
+
/** The exact live worker generation attests its private native memory source. */
|
|
47
|
+
readonly memorySyncVersion?: 1;
|
|
48
|
+
}
|
|
49
|
+
export type WorkerLaunch = Pick<HostOptions, "model" | "modelPreset" | "subagentConcurrency"> & { readonly memorySync?: true };
|
|
44
50
|
export const WORKER_HEADER_BYTES = 64 * 1024;
|
|
45
51
|
type Endpoint = Pick<WorkerRegistration, "destination" | "identityFile">;
|
|
46
52
|
|
|
@@ -57,6 +63,8 @@ const probe = Type.Object({
|
|
|
57
63
|
socket: Type.Boolean(), sessionFile: Type.Boolean(), pidAlive: Type.Boolean(), ownerAlive: Type.Boolean(),
|
|
58
64
|
uncertain: Type.Boolean(), pid: Type.Union([positive, Type.Null()]), sessionId: Type.Union([text, Type.Null()]),
|
|
59
65
|
sealedGeneration: Type.Optional(positive), exitGeneration: Type.Optional(positive),
|
|
66
|
+
memoryLaunchVersion: Type.Optional(Type.Literal(1)), memoryPreparedVersion: Type.Optional(Type.Literal(1)),
|
|
67
|
+
memorySyncVersion: Type.Optional(Type.Literal(1)),
|
|
60
68
|
});
|
|
61
69
|
const opened = Type.Object({ pid: positive });
|
|
62
70
|
const attached = Type.Object({ pid: positive, sessionId: text, sessionFile: absolute });
|
|
@@ -128,11 +136,12 @@ function readHeader(child: ChildProcessWithoutNullStreams): Promise<Buffer> {
|
|
|
128
136
|
});
|
|
129
137
|
}
|
|
130
138
|
|
|
131
|
-
async function exchange<S extends TSchema>(endpoint: Endpoint, request: object, schema: S, attach: boolean) {
|
|
139
|
+
async function exchange<S extends TSchema>(endpoint: Endpoint, request: object, schema: S, attach: boolean, signal?: AbortSignal) {
|
|
132
140
|
const payload = Buffer.from(`${JSON.stringify({ version: 1, ...request })}\n`);
|
|
133
141
|
if (payload.length > WORKER_HEADER_BYTES) throw new Error("Worker request exceeds header limit");
|
|
134
142
|
const { checkWorkerIdentity } = await import("./worker-registration");
|
|
135
143
|
checkWorkerIdentity(endpoint.identityFile);
|
|
144
|
+
signal?.throwIfAborted();
|
|
136
145
|
const child = startSSH(endpoint);
|
|
137
146
|
const exited = new Promise<number | null>((resolve, reject) => {
|
|
138
147
|
child.once("error", reject);
|
|
@@ -142,6 +151,8 @@ async function exchange<S extends TSchema>(endpoint: Endpoint, request: object,
|
|
|
142
151
|
// then signals detach to the stock RPC client, never native Host death.
|
|
143
152
|
void exited.catch(() => {});
|
|
144
153
|
const timer = setTimeout(() => child.kill("SIGKILL"), 60_000);
|
|
154
|
+
const cancel = () => { child.kill("SIGKILL"); };
|
|
155
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
145
156
|
try {
|
|
146
157
|
const response = readHeader(child);
|
|
147
158
|
if (attach) child.stdin.write(payload);
|
|
@@ -155,7 +166,10 @@ async function exchange<S extends TSchema>(endpoint: Endpoint, request: object,
|
|
|
155
166
|
} catch (error) {
|
|
156
167
|
child.kill();
|
|
157
168
|
throw error;
|
|
158
|
-
} finally {
|
|
169
|
+
} finally {
|
|
170
|
+
clearTimeout(timer);
|
|
171
|
+
signal?.removeEventListener("abort", cancel);
|
|
172
|
+
}
|
|
159
173
|
}
|
|
160
174
|
|
|
161
175
|
export async function workerDescribe(endpoint: Endpoint, workspace?: Pick<WorkerLaneRef, "repoId" | "revision" | "subdir">): Promise<WorkerDescription> {
|
|
@@ -184,9 +198,9 @@ export function workerRef(lane: Pick<Lane, "id" | "remote" | "generation">): Wor
|
|
|
184
198
|
return { laneId: lane.id, generation: lane.generation, repoId, revision, subdir };
|
|
185
199
|
}
|
|
186
200
|
|
|
187
|
-
export async function workerProbe(reg: WorkerRegistration, ref: WorkerLaneRef, reconcile = false): Promise<WorkerProbe> {
|
|
201
|
+
export async function workerProbe(reg: WorkerRegistration, ref: WorkerLaneRef, reconcile = false, signal?: AbortSignal): Promise<WorkerProbe> {
|
|
188
202
|
return (await exchange(reg, { op: "probe", workerId: reg.description.workerId, ref, ...(reconcile && { reconcile: true }) },
|
|
189
|
-
probe, false)).value;
|
|
203
|
+
probe, false, signal)).value;
|
|
190
204
|
}
|
|
191
205
|
|
|
192
206
|
export async function workerOpen(reg: WorkerRegistration, ref: WorkerLaneRef, launch: WorkerLaunch) {
|