@femtomc/mu-server 26.2.69 → 26.2.71
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 +7 -3
- package/dist/api/activities.d.ts +2 -0
- package/dist/api/activities.js +160 -0
- package/dist/api/config.d.ts +2 -0
- package/dist/api/config.js +45 -0
- package/dist/api/control_plane.d.ts +2 -0
- package/dist/api/control_plane.js +28 -0
- package/dist/api/cron.d.ts +2 -0
- package/dist/api/cron.js +182 -0
- package/dist/api/events.js +77 -19
- package/dist/api/forum.js +52 -18
- package/dist/api/heartbeats.d.ts +2 -0
- package/dist/api/heartbeats.js +211 -0
- package/dist/api/identities.d.ts +2 -0
- package/dist/api/identities.js +103 -0
- package/dist/api/issues.js +120 -33
- package/dist/api/runs.d.ts +2 -0
- package/dist/api/runs.js +207 -0
- package/dist/cli.js +58 -3
- package/dist/config.d.ts +4 -21
- package/dist/config.js +24 -75
- package/dist/control_plane.d.ts +7 -114
- package/dist/control_plane.js +238 -654
- package/dist/control_plane_bootstrap_helpers.d.ts +16 -0
- package/dist/control_plane_bootstrap_helpers.js +85 -0
- package/dist/control_plane_contract.d.ts +176 -0
- package/dist/control_plane_contract.js +1 -0
- package/dist/control_plane_reload.d.ts +63 -0
- package/dist/control_plane_reload.js +525 -0
- package/dist/control_plane_run_outbox.d.ts +7 -0
- package/dist/control_plane_run_outbox.js +52 -0
- package/dist/control_plane_run_queue_coordinator.d.ts +48 -0
- package/dist/control_plane_run_queue_coordinator.js +327 -0
- package/dist/control_plane_telegram_generation.d.ts +27 -0
- package/dist/control_plane_telegram_generation.js +520 -0
- package/dist/control_plane_wake_delivery.d.ts +50 -0
- package/dist/control_plane_wake_delivery.js +123 -0
- package/dist/cron_request.d.ts +8 -0
- package/dist/cron_request.js +65 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -1
- package/dist/run_queue.d.ts +95 -0
- package/dist/run_queue.js +817 -0
- package/dist/run_supervisor.d.ts +20 -0
- package/dist/run_supervisor.js +25 -1
- package/dist/server.d.ts +12 -49
- package/dist/server.js +365 -2128
- package/dist/server_program_orchestration.d.ts +38 -0
- package/dist/server_program_orchestration.js +254 -0
- package/dist/server_routing.d.ts +31 -0
- package/dist/server_routing.js +230 -0
- package/dist/server_runtime.d.ts +30 -0
- package/dist/server_runtime.js +43 -0
- package/dist/server_types.d.ts +3 -0
- package/dist/server_types.js +16 -0
- package/dist/session_lifecycle.d.ts +11 -0
- package/dist/session_lifecycle.js +149 -0
- package/package.json +7 -6
package/dist/run_supervisor.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export type ControlPlaneRunSnapshot = {
|
|
|
18
18
|
exit_code: number | null;
|
|
19
19
|
pid: number | null;
|
|
20
20
|
last_progress: string | null;
|
|
21
|
+
queue_id?: string;
|
|
22
|
+
queue_state?: "queued" | "active" | "waiting_review" | "refining" | "done" | "failed" | "cancelled";
|
|
21
23
|
};
|
|
22
24
|
export type ControlPlaneRunTrace = {
|
|
23
25
|
run: ControlPlaneRunSnapshot;
|
|
@@ -65,19 +67,37 @@ export type ControlPlaneRunSupervisorOpts = {
|
|
|
65
67
|
maxHistory?: number;
|
|
66
68
|
onEvent?: (event: ControlPlaneRunEvent) => void | Promise<void>;
|
|
67
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Process execution boundary for orchestration runs.
|
|
72
|
+
*
|
|
73
|
+
* Contract with the durable queue/reconcile layer:
|
|
74
|
+
* - this supervisor executes already-selected work; it does not decide inter-root scheduling policy
|
|
75
|
+
* - sequential/parallel root policy is enforced by queue leasing before launch
|
|
76
|
+
* - compatibility adapters may call launch directly during migration, but the default path is queue-first
|
|
77
|
+
*/
|
|
68
78
|
export declare class ControlPlaneRunSupervisor {
|
|
69
79
|
#private;
|
|
70
80
|
constructor(opts: ControlPlaneRunSupervisorOpts);
|
|
81
|
+
/**
|
|
82
|
+
* Compatibility adapter entrypoint for run-start intent.
|
|
83
|
+
* Default architecture should enqueue first, then call this after lease acquisition.
|
|
84
|
+
*/
|
|
71
85
|
launchStart(opts: {
|
|
72
86
|
prompt: string;
|
|
73
87
|
maxSteps?: number;
|
|
74
88
|
command?: CommandRecord | null;
|
|
89
|
+
commandId?: string | null;
|
|
75
90
|
source?: "command" | "api";
|
|
76
91
|
}): Promise<ControlPlaneRunSnapshot>;
|
|
92
|
+
/**
|
|
93
|
+
* Compatibility adapter entrypoint for run-resume intent.
|
|
94
|
+
* No feature-flag branch: queue-first reconcile remains the canonical path.
|
|
95
|
+
*/
|
|
77
96
|
launchResume(opts: {
|
|
78
97
|
rootIssueId: string;
|
|
79
98
|
maxSteps?: number;
|
|
80
99
|
command?: CommandRecord | null;
|
|
100
|
+
commandId?: string | null;
|
|
81
101
|
source?: "command" | "api";
|
|
82
102
|
}): Promise<ControlPlaneRunSnapshot>;
|
|
83
103
|
list(opts?: {
|
package/dist/run_supervisor.js
CHANGED
|
@@ -97,6 +97,14 @@ function describeRun(snapshot) {
|
|
|
97
97
|
const root = snapshot.root_issue_id ?? snapshot.job_id;
|
|
98
98
|
return `${snapshot.mode} ${root}`;
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Process execution boundary for orchestration runs.
|
|
102
|
+
*
|
|
103
|
+
* Contract with the durable queue/reconcile layer:
|
|
104
|
+
* - this supervisor executes already-selected work; it does not decide inter-root scheduling policy
|
|
105
|
+
* - sequential/parallel root policy is enforced by queue leasing before launch
|
|
106
|
+
* - compatibility adapters may call launch directly during migration, but the default path is queue-first
|
|
107
|
+
*/
|
|
100
108
|
export class ControlPlaneRunSupervisor {
|
|
101
109
|
#repoRoot;
|
|
102
110
|
#nowMs;
|
|
@@ -212,6 +220,12 @@ export class ControlPlaneRunSupervisor {
|
|
|
212
220
|
this.#emit("run_progress", job, `📈 ${line.trim()}`);
|
|
213
221
|
}
|
|
214
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Executes one queue-activated run job.
|
|
225
|
+
*
|
|
226
|
+
* Queue contract expectation: caller has already persisted/activated the queue item and associated
|
|
227
|
+
* this launch with exactly one root slot under the active inter-root policy.
|
|
228
|
+
*/
|
|
215
229
|
async #launch(opts) {
|
|
216
230
|
const nowMs = Math.trunc(this.#nowMs());
|
|
217
231
|
const process = this.#spawnProcess({ argv: opts.argv, cwd: this.#repoRoot });
|
|
@@ -222,7 +236,7 @@ export class ControlPlaneRunSupervisor {
|
|
|
222
236
|
prompt: opts.prompt,
|
|
223
237
|
root_issue_id: opts.rootIssueId,
|
|
224
238
|
max_steps: opts.maxSteps,
|
|
225
|
-
command_id: opts.command?.command_id ?? null,
|
|
239
|
+
command_id: opts.command?.command_id ?? opts.commandId ?? null,
|
|
226
240
|
source: opts.source,
|
|
227
241
|
started_at_ms: nowMs,
|
|
228
242
|
updated_at_ms: nowMs,
|
|
@@ -298,6 +312,10 @@ export class ControlPlaneRunSupervisor {
|
|
|
298
312
|
})();
|
|
299
313
|
return this.#snapshot(job);
|
|
300
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Compatibility adapter entrypoint for run-start intent.
|
|
317
|
+
* Default architecture should enqueue first, then call this after lease acquisition.
|
|
318
|
+
*/
|
|
301
319
|
async launchStart(opts) {
|
|
302
320
|
const prompt = opts.prompt.trim();
|
|
303
321
|
if (prompt.length === 0) {
|
|
@@ -312,9 +330,14 @@ export class ControlPlaneRunSupervisor {
|
|
|
312
330
|
maxSteps,
|
|
313
331
|
argv,
|
|
314
332
|
command: opts.command ?? null,
|
|
333
|
+
commandId: opts.commandId ?? null,
|
|
315
334
|
source: opts.source ?? "api",
|
|
316
335
|
});
|
|
317
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Compatibility adapter entrypoint for run-resume intent.
|
|
339
|
+
* No feature-flag branch: queue-first reconcile remains the canonical path.
|
|
340
|
+
*/
|
|
318
341
|
async launchResume(opts) {
|
|
319
342
|
const rootIssueId = normalizeIssueId(opts.rootIssueId);
|
|
320
343
|
if (!rootIssueId) {
|
|
@@ -329,6 +352,7 @@ export class ControlPlaneRunSupervisor {
|
|
|
329
352
|
maxSteps,
|
|
330
353
|
argv,
|
|
331
354
|
command: opts.command ?? null,
|
|
355
|
+
commandId: opts.commandId ?? null,
|
|
332
356
|
source: opts.source ?? "api",
|
|
333
357
|
});
|
|
334
358
|
}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
import { GenerationTelemetryRecorder
|
|
1
|
+
import { GenerationTelemetryRecorder } from "@femtomc/mu-control-plane";
|
|
2
2
|
import type { EventEnvelope, JsonlStore } from "@femtomc/mu-core";
|
|
3
3
|
import { EventLog } from "@femtomc/mu-core/node";
|
|
4
4
|
import { ForumStore } from "@femtomc/mu-forum";
|
|
5
5
|
import { IssueStore } from "@femtomc/mu-issue";
|
|
6
6
|
import { ControlPlaneActivitySupervisor } from "./activity_supervisor.js";
|
|
7
7
|
import { type MuConfig } from "./config.js";
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import { HeartbeatProgramRegistry } from "./heartbeat_programs.js";
|
|
8
|
+
import type { ControlPlaneHandle, ControlPlaneSessionLifecycle } from "./control_plane_contract.js";
|
|
9
|
+
import { type ConfigReader, type ConfigWriter, type ControlPlaneReloader, type ControlPlaneReloadResult, type ControlPlaneSummary } from "./control_plane_reload.js";
|
|
11
10
|
import { ActivityHeartbeatScheduler } from "./heartbeat_scheduler.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
type ShellCommandRunner = (command: string) => Promise<ShellCommandResult>;
|
|
18
|
-
export declare function createProcessSessionLifecycle(opts: {
|
|
19
|
-
repoRoot: string;
|
|
20
|
-
runShellCommand?: ShellCommandRunner;
|
|
21
|
-
}): ControlPlaneSessionLifecycle;
|
|
22
|
-
type ControlPlaneReloader = (opts: {
|
|
23
|
-
repoRoot: string;
|
|
24
|
-
previous: ControlPlaneHandle | null;
|
|
25
|
-
config: ControlPlaneConfig;
|
|
26
|
-
generation: ReloadableGenerationIdentity;
|
|
27
|
-
}) => Promise<ControlPlaneHandle | null>;
|
|
28
|
-
type ConfigReader = (repoRoot: string) => Promise<MuConfig>;
|
|
29
|
-
type ConfigWriter = (repoRoot: string, config: MuConfig) => Promise<string>;
|
|
11
|
+
import { createProcessSessionLifecycle } from "./session_lifecycle.js";
|
|
12
|
+
import type { ServerRuntime } from "./server_runtime.js";
|
|
13
|
+
export { createProcessSessionLifecycle };
|
|
14
|
+
export type { ConfigReader, ConfigWriter, ControlPlaneReloader, ControlPlaneReloadResult, ControlPlaneSummary, };
|
|
30
15
|
export type ServerOptions = {
|
|
31
16
|
repoRoot?: string;
|
|
32
17
|
port?: number;
|
|
@@ -41,15 +26,7 @@ export type ServerOptions = {
|
|
|
41
26
|
configReader?: ConfigReader;
|
|
42
27
|
configWriter?: ConfigWriter;
|
|
43
28
|
sessionLifecycle?: ControlPlaneSessionLifecycle;
|
|
44
|
-
|
|
45
|
-
export type ServerRuntimeOptions = {
|
|
46
|
-
repoRoot?: string;
|
|
47
|
-
controlPlane?: ControlPlaneHandle | null;
|
|
48
|
-
heartbeatScheduler?: ActivityHeartbeatScheduler;
|
|
49
|
-
generationTelemetry?: GenerationTelemetryRecorder;
|
|
50
|
-
config?: MuConfig;
|
|
51
|
-
configReader?: ConfigReader;
|
|
52
|
-
sessionLifecycle?: ControlPlaneSessionLifecycle;
|
|
29
|
+
initiateShutdown?: () => Promise<void>;
|
|
53
30
|
};
|
|
54
31
|
export type ServerInstanceOptions = Omit<ServerOptions, "repoRoot" | "controlPlane" | "heartbeatScheduler" | "generationTelemetry" | "config" | "sessionLifecycle">;
|
|
55
32
|
export type ServerContext = {
|
|
@@ -60,28 +37,14 @@ export type ServerContext = {
|
|
|
60
37
|
eventsStore: JsonlStore<EventEnvelope>;
|
|
61
38
|
};
|
|
62
39
|
export declare function createContext(repoRoot: string): ServerContext;
|
|
63
|
-
export type ServerRuntimeCapabilities
|
|
64
|
-
|
|
65
|
-
control_plane_bootstrapped: boolean;
|
|
66
|
-
control_plane_adapters: string[];
|
|
67
|
-
};
|
|
68
|
-
export type ServerRuntime = {
|
|
69
|
-
repoRoot: string;
|
|
70
|
-
config: MuConfig;
|
|
71
|
-
heartbeatScheduler: ActivityHeartbeatScheduler;
|
|
72
|
-
generationTelemetry: GenerationTelemetryRecorder;
|
|
73
|
-
sessionLifecycle: ControlPlaneSessionLifecycle;
|
|
74
|
-
controlPlane: ControlPlaneHandle | null;
|
|
75
|
-
capabilities: ServerRuntimeCapabilities;
|
|
76
|
-
};
|
|
77
|
-
export declare function composeServerRuntime(options?: ServerRuntimeOptions): Promise<ServerRuntime>;
|
|
40
|
+
export type { ServerRuntime, ServerRuntimeCapabilities, ServerRuntimeOptions } from "./server_runtime.js";
|
|
41
|
+
export { composeServerRuntime } from "./server_runtime.js";
|
|
78
42
|
export declare function createServerFromRuntime(runtime: ServerRuntime, options?: ServerInstanceOptions): {
|
|
79
43
|
port: number;
|
|
80
44
|
fetch: (request: Request) => Promise<Response>;
|
|
81
45
|
hostname: string;
|
|
82
46
|
controlPlane: ControlPlaneHandle;
|
|
83
47
|
activitySupervisor: ControlPlaneActivitySupervisor;
|
|
84
|
-
heartbeatPrograms: HeartbeatProgramRegistry;
|
|
85
|
-
cronPrograms: CronProgramRegistry;
|
|
48
|
+
heartbeatPrograms: import("./heartbeat_programs.js").HeartbeatProgramRegistry;
|
|
49
|
+
cronPrograms: import("./cron_programs.js").CronProgramRegistry;
|
|
86
50
|
};
|
|
87
|
-
export {};
|