pi-forge 1.2.5 → 1.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 +1 -1
- package/dist/client/assets/{CodeMirrorEditor-DXmxwE2Z.js → CodeMirrorEditor-BuLFJjB1.js} +13 -13
- package/dist/client/assets/CodeMirrorEditor-BuLFJjB1.js.map +1 -0
- package/dist/client/assets/index-CEqSkIuy.css +1 -0
- package/dist/client/assets/index-GubcPYw6.js +375 -0
- package/dist/client/assets/index-GubcPYw6.js.map +1 -0
- package/dist/client/assets/{workbox-window.prod.es5-Cch4wiA5.js → workbox-window.prod.es5-Bd17z0YL.js} +2 -2
- package/dist/client/assets/{workbox-window.prod.es5-Cch4wiA5.js.map → workbox-window.prod.es5-Bd17z0YL.js.map} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.map +1 -1
- package/dist/server/git-clone.js +364 -0
- package/dist/server/git-clone.js.map +1 -0
- package/dist/server/index.js +22 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/orchestration/config.js +61 -0
- package/dist/server/orchestration/config.js.map +1 -0
- package/dist/server/orchestration/event-bridge.js +93 -0
- package/dist/server/orchestration/event-bridge.js.map +1 -0
- package/dist/server/orchestration/inbox.js +199 -0
- package/dist/server/orchestration/inbox.js.map +1 -0
- package/dist/server/orchestration/init.js +39 -0
- package/dist/server/orchestration/init.js.map +1 -0
- package/dist/server/orchestration/store.js +352 -0
- package/dist/server/orchestration/store.js.map +1 -0
- package/dist/server/orchestration/tools.js +769 -0
- package/dist/server/orchestration/tools.js.map +1 -0
- package/dist/server/orchestration/types.js +57 -0
- package/dist/server/orchestration/types.js.map +1 -0
- package/dist/server/processes/manager.js +23 -1
- package/dist/server/processes/manager.js.map +1 -1
- package/dist/server/project-manager.js +46 -32
- package/dist/server/project-manager.js.map +1 -1
- package/dist/server/routes/control.js +9 -0
- package/dist/server/routes/control.js.map +1 -1
- package/dist/server/routes/health.js +14 -1
- package/dist/server/routes/health.js.map +1 -1
- package/dist/server/routes/orchestration.js +464 -0
- package/dist/server/routes/orchestration.js.map +1 -0
- package/dist/server/routes/projects.js +239 -14
- package/dist/server/routes/projects.js.map +1 -1
- package/dist/server/routes/sessions.js +53 -34
- package/dist/server/routes/sessions.js.map +1 -1
- package/dist/server/routes/webhooks.js +362 -0
- package/dist/server/routes/webhooks.js.map +1 -0
- package/dist/server/session-registry.js +226 -3
- package/dist/server/session-registry.js.map +1 -1
- package/dist/server/sse-bridge.js +85 -14
- package/dist/server/sse-bridge.js.map +1 -1
- package/dist/server/webhooks/dispatcher.js +254 -0
- package/dist/server/webhooks/dispatcher.js.map +1 -0
- package/dist/server/webhooks/event-bridge.js +185 -0
- package/dist/server/webhooks/event-bridge.js.map +1 -0
- package/dist/server/webhooks/init.js +55 -0
- package/dist/server/webhooks/init.js.map +1 -0
- package/dist/server/webhooks/store.js +394 -0
- package/dist/server/webhooks/store.js.map +1 -0
- package/dist/server/webhooks/types.js +32 -0
- package/dist/server/webhooks/types.js.map +1 -0
- package/package.json +4 -4
- package/dist/client/assets/CodeMirrorEditor-DXmxwE2Z.js.map +0 -1
- package/dist/client/assets/index-CMSjnWtF.js +0 -365
- package/dist/client/assets/index-CMSjnWtF.js.map +0 -1
- package/dist/client/assets/index-Cp8qEy7Q.css +0 -1
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { disposeSession, findProjectIdForSession, getSession, rebuildAgentSessionForTools, resumeSessionById, } from "../session-registry.js";
|
|
2
|
+
import { isOrchestrationEnabled, maxWorkersPerSupervisor, orchestrationDisabledReason, } from "../orchestration/config.js";
|
|
3
|
+
import { disableSupervisor, enableSupervisor, getWorkerIds, getWorkerRecord, isSupervisor, isWorker, OrchestrationError, unregisterWorker, } from "../orchestration/store.js";
|
|
4
|
+
import { clearInbox, pendingInboxCount, readAllInbox } from "../orchestration/store.js";
|
|
5
|
+
import { MAX_DEPTH } from "../orchestration/types.js";
|
|
6
|
+
import { errorSchema } from "./_schemas.js";
|
|
7
|
+
function gate(reply) {
|
|
8
|
+
if (isOrchestrationEnabled())
|
|
9
|
+
return undefined;
|
|
10
|
+
const reason = orchestrationDisabledReason();
|
|
11
|
+
const message = reason === "minimal_ui_disabled"
|
|
12
|
+
? "Session orchestration is disabled under MINIMAL_UI."
|
|
13
|
+
: "Session orchestration is disabled. Set ORCHESTRATION_ENABLED=true to enable.";
|
|
14
|
+
return reply.code(403).send({ error: reason, message });
|
|
15
|
+
}
|
|
16
|
+
function handleStoreError(reply, err) {
|
|
17
|
+
if (err instanceof OrchestrationError) {
|
|
18
|
+
// Map specific codes to HTTP — depth_limit and validation
|
|
19
|
+
// failures are 400s (client mistake); supervisor_not_found
|
|
20
|
+
// is a 404 only when the SESSION exists but isn't a supervisor,
|
|
21
|
+
// which is its own thing. We rely on the code field.
|
|
22
|
+
if (err.code === "depth_limit_exceeded" || err.code === "worker_already_linked") {
|
|
23
|
+
return reply.code(400).send({ error: err.code, message: err.message });
|
|
24
|
+
}
|
|
25
|
+
if (err.code === "supervisor_not_found") {
|
|
26
|
+
return reply.code(404).send({ error: err.code, message: err.message });
|
|
27
|
+
}
|
|
28
|
+
return reply.code(400).send({ error: err.code, message: err.message });
|
|
29
|
+
}
|
|
30
|
+
reply.log.error({ err }, "orchestration route error");
|
|
31
|
+
return reply.code(500).send({ error: "internal_error" });
|
|
32
|
+
}
|
|
33
|
+
const sessionLinkSchema = {
|
|
34
|
+
type: "object",
|
|
35
|
+
required: ["sessionId", "role"],
|
|
36
|
+
properties: {
|
|
37
|
+
sessionId: { type: "string" },
|
|
38
|
+
role: { type: "string", enum: ["supervisor", "worker", "standalone"] },
|
|
39
|
+
supervisorId: { type: "string" },
|
|
40
|
+
workerIds: { type: "array", items: { type: "string" } },
|
|
41
|
+
pendingInbox: { type: "integer", minimum: 0 },
|
|
42
|
+
enabledAt: { type: "string" },
|
|
43
|
+
spawnedAt: { type: "string" },
|
|
44
|
+
spawnedFrom: {
|
|
45
|
+
type: "object",
|
|
46
|
+
required: ["sessionId", "mode"],
|
|
47
|
+
properties: {
|
|
48
|
+
sessionId: { type: "string" },
|
|
49
|
+
mode: { type: "string", enum: ["fresh", "summary"] },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const workerSummarySchema = {
|
|
55
|
+
type: "object",
|
|
56
|
+
required: ["workerId", "isLive"],
|
|
57
|
+
properties: {
|
|
58
|
+
workerId: { type: "string" },
|
|
59
|
+
isLive: { type: "boolean" },
|
|
60
|
+
isStreaming: { type: "boolean" },
|
|
61
|
+
name: { type: "string" },
|
|
62
|
+
state: { type: "string", enum: ["streaming", "idle", "cold"] },
|
|
63
|
+
lastActivityAt: { type: "string" },
|
|
64
|
+
messageCount: { type: "integer", minimum: 0 },
|
|
65
|
+
projectId: { type: "string" },
|
|
66
|
+
spawnedAt: { type: "string" },
|
|
67
|
+
spawnedFrom: {
|
|
68
|
+
type: "object",
|
|
69
|
+
properties: {
|
|
70
|
+
sessionId: { type: "string" },
|
|
71
|
+
mode: { type: "string" },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
const inboxItemSchema = {
|
|
77
|
+
type: "object",
|
|
78
|
+
required: ["id", "type", "workerId", "occurredAt", "data", "delivered"],
|
|
79
|
+
properties: {
|
|
80
|
+
id: { type: "string" },
|
|
81
|
+
type: { type: "string" },
|
|
82
|
+
workerId: { type: "string" },
|
|
83
|
+
occurredAt: { type: "string" },
|
|
84
|
+
data: { type: "object", additionalProperties: true },
|
|
85
|
+
delivered: { type: "boolean" },
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
export const orchestrationRoutes = async (fastify) => {
|
|
89
|
+
fastify.get("/orchestration/config", {
|
|
90
|
+
schema: {
|
|
91
|
+
description: "Return whether orchestration is enabled on this instance plus the " +
|
|
92
|
+
"current caps. Always available (no auth surface beyond the standard " +
|
|
93
|
+
"API auth gate); the UI uses this to decide whether to render the " +
|
|
94
|
+
"supervisor toggle and Workers panel.",
|
|
95
|
+
tags: ["orchestration"],
|
|
96
|
+
response: {
|
|
97
|
+
200: {
|
|
98
|
+
type: "object",
|
|
99
|
+
required: ["enabled", "maxWorkersPerSupervisor", "maxDepth", "disabledReason"],
|
|
100
|
+
properties: {
|
|
101
|
+
enabled: { type: "boolean" },
|
|
102
|
+
maxWorkersPerSupervisor: { type: "integer", minimum: 1 },
|
|
103
|
+
maxDepth: { type: "integer", minimum: 1 },
|
|
104
|
+
disabledReason: {
|
|
105
|
+
type: "string",
|
|
106
|
+
enum: ["", "minimal_ui_disabled", "orchestration_disabled"],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
}, async () => {
|
|
113
|
+
const enabled = isOrchestrationEnabled();
|
|
114
|
+
return {
|
|
115
|
+
enabled,
|
|
116
|
+
maxWorkersPerSupervisor: maxWorkersPerSupervisor(),
|
|
117
|
+
maxDepth: MAX_DEPTH,
|
|
118
|
+
disabledReason: enabled ? "" : orchestrationDisabledReason(),
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
fastify.get("/orchestration/sessions/:id", {
|
|
122
|
+
schema: {
|
|
123
|
+
description: "Return the orchestration role of a session: 'supervisor', 'worker', " +
|
|
124
|
+
"or 'standalone'. For supervisors, includes the worker list + pending " +
|
|
125
|
+
"inbox count; for workers, includes the supervisor id + handoff lineage.",
|
|
126
|
+
tags: ["orchestration"],
|
|
127
|
+
params: {
|
|
128
|
+
type: "object",
|
|
129
|
+
required: ["id"],
|
|
130
|
+
properties: { id: { type: "string" } },
|
|
131
|
+
},
|
|
132
|
+
response: {
|
|
133
|
+
200: sessionLinkSchema,
|
|
134
|
+
403: errorSchema,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
}, async (req, reply) => {
|
|
138
|
+
const g = gate(reply);
|
|
139
|
+
if (g !== undefined)
|
|
140
|
+
return g;
|
|
141
|
+
const sessionId = req.params.id;
|
|
142
|
+
if (await isSupervisor(sessionId)) {
|
|
143
|
+
const workerIds = await getWorkerIds(sessionId);
|
|
144
|
+
const pending = await pendingInboxCount(sessionId);
|
|
145
|
+
return {
|
|
146
|
+
sessionId,
|
|
147
|
+
role: "supervisor",
|
|
148
|
+
workerIds,
|
|
149
|
+
pendingInbox: pending,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (await isWorker(sessionId)) {
|
|
153
|
+
const rec = await getWorkerRecord(sessionId);
|
|
154
|
+
const out = {
|
|
155
|
+
sessionId,
|
|
156
|
+
role: "worker",
|
|
157
|
+
};
|
|
158
|
+
if (rec !== undefined) {
|
|
159
|
+
out.supervisorId = rec.supervisorId;
|
|
160
|
+
out.spawnedAt = rec.spawnedAt;
|
|
161
|
+
if (rec.spawnedFrom !== undefined)
|
|
162
|
+
out.spawnedFrom = rec.spawnedFrom;
|
|
163
|
+
}
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
return { sessionId, role: "standalone" };
|
|
167
|
+
});
|
|
168
|
+
fastify.post("/orchestration/sessions/:id/enable", {
|
|
169
|
+
schema: {
|
|
170
|
+
description: "Mark the session as a supervisor AND rebuild its live agent " +
|
|
171
|
+
"session in-place so the orchestrate_* tools become available " +
|
|
172
|
+
"immediately. The SDK only builds its tool list at " +
|
|
173
|
+
"AgentSession-creation time, so an enable without rebuild would " +
|
|
174
|
+
"leave a running session toolless until the user manually closed " +
|
|
175
|
+
"and reopened it. The rebuild keeps the SSE attached — the " +
|
|
176
|
+
"browser sees no reconnect, the new tools just appear on the " +
|
|
177
|
+
"next turn.",
|
|
178
|
+
tags: ["orchestration"],
|
|
179
|
+
params: {
|
|
180
|
+
type: "object",
|
|
181
|
+
required: ["id"],
|
|
182
|
+
properties: { id: { type: "string" } },
|
|
183
|
+
},
|
|
184
|
+
response: {
|
|
185
|
+
200: sessionLinkSchema,
|
|
186
|
+
400: errorSchema,
|
|
187
|
+
403: errorSchema,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
}, async (req, reply) => {
|
|
191
|
+
const g = gate(reply);
|
|
192
|
+
if (g !== undefined)
|
|
193
|
+
return g;
|
|
194
|
+
try {
|
|
195
|
+
const rec = await enableSupervisor(req.params.id);
|
|
196
|
+
// Rebuild AFTER the store write so the new AgentSession's
|
|
197
|
+
// `customTools` resolution sees the supervisor flag and
|
|
198
|
+
// adds the orchestrate_* tools. Best-effort — if the
|
|
199
|
+
// session isn't live (browser opened a cold session, never
|
|
200
|
+
// attached SSE), there's nothing to rebuild and the next
|
|
201
|
+
// resume will pick up the tools naturally.
|
|
202
|
+
try {
|
|
203
|
+
await rebuildAgentSessionForTools(req.params.id);
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
req.log.warn({ err, sessionId: req.params.id }, "orchestration enable: rebuild failed (non-fatal — next resume will pick up tools)");
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
sessionId: req.params.id,
|
|
210
|
+
role: "supervisor",
|
|
211
|
+
workerIds: rec.workerIds,
|
|
212
|
+
enabledAt: rec.enabledAt,
|
|
213
|
+
pendingInbox: 0,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
return handleStoreError(reply, err);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
fastify.post("/orchestration/sessions/:id/disable", {
|
|
221
|
+
schema: {
|
|
222
|
+
description: "Remove supervisor mode. Detaches every linked worker (they survive " +
|
|
223
|
+
"as standalone sessions), clears the supervisor's inbox, AND " +
|
|
224
|
+
"rebuilds the supervisor's live agent session in-place so the " +
|
|
225
|
+
"orchestrate_* tools disappear immediately. Same rebuild rationale " +
|
|
226
|
+
"as /enable — the SDK's tool list is fixed at agent-session " +
|
|
227
|
+
"creation time, so the tools would otherwise linger until the " +
|
|
228
|
+
"session was reloaded.",
|
|
229
|
+
tags: ["orchestration"],
|
|
230
|
+
params: {
|
|
231
|
+
type: "object",
|
|
232
|
+
required: ["id"],
|
|
233
|
+
properties: { id: { type: "string" } },
|
|
234
|
+
},
|
|
235
|
+
response: {
|
|
236
|
+
204: { type: "null" },
|
|
237
|
+
403: errorSchema,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
}, async (req, reply) => {
|
|
241
|
+
const g = gate(reply);
|
|
242
|
+
if (g !== undefined)
|
|
243
|
+
return g;
|
|
244
|
+
await disableSupervisor(req.params.id);
|
|
245
|
+
await clearInbox(req.params.id);
|
|
246
|
+
try {
|
|
247
|
+
await rebuildAgentSessionForTools(req.params.id);
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
req.log.warn({ err, sessionId: req.params.id }, "orchestration disable: rebuild failed (non-fatal — next resume drops the tools)");
|
|
251
|
+
}
|
|
252
|
+
return reply.code(204).send();
|
|
253
|
+
});
|
|
254
|
+
fastify.get("/orchestration/sessions/:id/workers", {
|
|
255
|
+
schema: {
|
|
256
|
+
description: "Return the worker list for a supervisor with live state (streaming/" +
|
|
257
|
+
"idle/cold) and metadata. The UI renders this as the supervisor's " +
|
|
258
|
+
"Workers side panel.",
|
|
259
|
+
tags: ["orchestration"],
|
|
260
|
+
params: {
|
|
261
|
+
type: "object",
|
|
262
|
+
required: ["id"],
|
|
263
|
+
properties: { id: { type: "string" } },
|
|
264
|
+
},
|
|
265
|
+
response: {
|
|
266
|
+
200: {
|
|
267
|
+
type: "object",
|
|
268
|
+
required: ["workers"],
|
|
269
|
+
properties: { workers: { type: "array", items: workerSummarySchema } },
|
|
270
|
+
},
|
|
271
|
+
403: errorSchema,
|
|
272
|
+
404: errorSchema,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
}, async (req, reply) => {
|
|
276
|
+
const g = gate(reply);
|
|
277
|
+
if (g !== undefined)
|
|
278
|
+
return g;
|
|
279
|
+
if (!(await isSupervisor(req.params.id))) {
|
|
280
|
+
return reply.code(404).send({ error: "not_a_supervisor" });
|
|
281
|
+
}
|
|
282
|
+
const ids = await getWorkerIds(req.params.id);
|
|
283
|
+
const workers = await Promise.all(ids.map(async (workerId) => {
|
|
284
|
+
const rec = await getWorkerRecord(workerId);
|
|
285
|
+
const live = getSession(workerId);
|
|
286
|
+
const base = { workerId, isLive: live !== undefined };
|
|
287
|
+
if (rec !== undefined) {
|
|
288
|
+
base.spawnedAt = rec.spawnedAt;
|
|
289
|
+
if (rec.spawnedFrom !== undefined)
|
|
290
|
+
base.spawnedFrom = rec.spawnedFrom;
|
|
291
|
+
}
|
|
292
|
+
if (live !== undefined) {
|
|
293
|
+
base.isStreaming = live.session.isStreaming;
|
|
294
|
+
base.state = live.session.isStreaming ? "streaming" : "idle";
|
|
295
|
+
base.name = live.session.sessionName ?? undefined;
|
|
296
|
+
base.messageCount = live.session.messages.length;
|
|
297
|
+
base.lastActivityAt = live.lastActivityAt.toISOString();
|
|
298
|
+
base.projectId = live.projectId;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
base.state = "cold";
|
|
302
|
+
const projectId = await findProjectIdForSession(workerId);
|
|
303
|
+
if (projectId !== undefined)
|
|
304
|
+
base.projectId = projectId;
|
|
305
|
+
}
|
|
306
|
+
return base;
|
|
307
|
+
}));
|
|
308
|
+
return { workers };
|
|
309
|
+
});
|
|
310
|
+
fastify.get("/orchestration/sessions/:id/inbox", {
|
|
311
|
+
schema: {
|
|
312
|
+
description: "Return the supervisor's inbox history — every event the bridge " +
|
|
313
|
+
"captured (delivered + pending), newest first. Capped at 200 items " +
|
|
314
|
+
"per supervisor via FIFO eviction.",
|
|
315
|
+
tags: ["orchestration"],
|
|
316
|
+
params: {
|
|
317
|
+
type: "object",
|
|
318
|
+
required: ["id"],
|
|
319
|
+
properties: { id: { type: "string" } },
|
|
320
|
+
},
|
|
321
|
+
response: {
|
|
322
|
+
200: {
|
|
323
|
+
type: "object",
|
|
324
|
+
required: ["items"],
|
|
325
|
+
properties: { items: { type: "array", items: inboxItemSchema } },
|
|
326
|
+
},
|
|
327
|
+
403: errorSchema,
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
}, async (req, reply) => {
|
|
331
|
+
const g = gate(reply);
|
|
332
|
+
if (g !== undefined)
|
|
333
|
+
return g;
|
|
334
|
+
const items = await readAllInbox(req.params.id);
|
|
335
|
+
return { items };
|
|
336
|
+
});
|
|
337
|
+
fastify.post("/orchestration/sessions/:id/inbox/clear", {
|
|
338
|
+
schema: {
|
|
339
|
+
description: "Wipe the supervisor's inbox (history + pending).",
|
|
340
|
+
tags: ["orchestration"],
|
|
341
|
+
params: {
|
|
342
|
+
type: "object",
|
|
343
|
+
required: ["id"],
|
|
344
|
+
properties: { id: { type: "string" } },
|
|
345
|
+
},
|
|
346
|
+
response: {
|
|
347
|
+
204: { type: "null" },
|
|
348
|
+
403: errorSchema,
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
}, async (req, reply) => {
|
|
352
|
+
const g = gate(reply);
|
|
353
|
+
if (g !== undefined)
|
|
354
|
+
return g;
|
|
355
|
+
await clearInbox(req.params.id);
|
|
356
|
+
return reply.code(204).send();
|
|
357
|
+
});
|
|
358
|
+
fastify.post("/orchestration/sessions/:id/workers/:wid/detach", {
|
|
359
|
+
schema: {
|
|
360
|
+
description: "UI control: drop the supervisor→worker link without killing the " +
|
|
361
|
+
"worker. The worker continues running as a standalone session. " +
|
|
362
|
+
"Refuses if the worker isn't linked to this supervisor.",
|
|
363
|
+
tags: ["orchestration"],
|
|
364
|
+
params: {
|
|
365
|
+
type: "object",
|
|
366
|
+
required: ["id", "wid"],
|
|
367
|
+
properties: { id: { type: "string" }, wid: { type: "string" } },
|
|
368
|
+
},
|
|
369
|
+
response: {
|
|
370
|
+
204: { type: "null" },
|
|
371
|
+
403: errorSchema,
|
|
372
|
+
404: errorSchema,
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
}, async (req, reply) => {
|
|
376
|
+
const g = gate(reply);
|
|
377
|
+
if (g !== undefined)
|
|
378
|
+
return g;
|
|
379
|
+
const rec = await getWorkerRecord(req.params.wid);
|
|
380
|
+
if (rec === undefined || rec.supervisorId !== req.params.id) {
|
|
381
|
+
return reply.code(404).send({ error: "worker_not_linked" });
|
|
382
|
+
}
|
|
383
|
+
await unregisterWorker(req.params.wid);
|
|
384
|
+
return reply.code(204).send();
|
|
385
|
+
});
|
|
386
|
+
fastify.post("/orchestration/sessions/:id/workers/:wid/kill", {
|
|
387
|
+
schema: {
|
|
388
|
+
description: "UI control: dispose the worker session AND unregister it from this " +
|
|
389
|
+
"supervisor. Does NOT delete the .jsonl from disk — use DELETE " +
|
|
390
|
+
"/sessions/:id for that.",
|
|
391
|
+
tags: ["orchestration"],
|
|
392
|
+
params: {
|
|
393
|
+
type: "object",
|
|
394
|
+
required: ["id", "wid"],
|
|
395
|
+
properties: { id: { type: "string" }, wid: { type: "string" } },
|
|
396
|
+
},
|
|
397
|
+
response: {
|
|
398
|
+
200: {
|
|
399
|
+
type: "object",
|
|
400
|
+
required: ["wasLive"],
|
|
401
|
+
properties: { wasLive: { type: "boolean" } },
|
|
402
|
+
},
|
|
403
|
+
403: errorSchema,
|
|
404
|
+
404: errorSchema,
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
}, async (req, reply) => {
|
|
408
|
+
const g = gate(reply);
|
|
409
|
+
if (g !== undefined)
|
|
410
|
+
return g;
|
|
411
|
+
const rec = await getWorkerRecord(req.params.wid);
|
|
412
|
+
if (rec === undefined || rec.supervisorId !== req.params.id) {
|
|
413
|
+
return reply.code(404).send({ error: "worker_not_linked" });
|
|
414
|
+
}
|
|
415
|
+
const wasLive = await disposeSession(req.params.wid);
|
|
416
|
+
await unregisterWorker(req.params.wid);
|
|
417
|
+
return { wasLive };
|
|
418
|
+
});
|
|
419
|
+
// Used by the UI "Resume worker" button when the worker is cold.
|
|
420
|
+
// No body — just a hint to the registry to load the session from
|
|
421
|
+
// disk so subsequent UI calls (read transcript, send message) hit
|
|
422
|
+
// a live session.
|
|
423
|
+
fastify.post("/orchestration/sessions/:id/workers/:wid/resume", {
|
|
424
|
+
schema: {
|
|
425
|
+
description: "Force-resume a cold worker into the live registry. Idempotent on " +
|
|
426
|
+
"already-live workers.",
|
|
427
|
+
tags: ["orchestration"],
|
|
428
|
+
params: {
|
|
429
|
+
type: "object",
|
|
430
|
+
required: ["id", "wid"],
|
|
431
|
+
properties: { id: { type: "string" }, wid: { type: "string" } },
|
|
432
|
+
},
|
|
433
|
+
response: {
|
|
434
|
+
200: {
|
|
435
|
+
type: "object",
|
|
436
|
+
required: ["resumed"],
|
|
437
|
+
properties: { resumed: { type: "boolean" } },
|
|
438
|
+
},
|
|
439
|
+
403: errorSchema,
|
|
440
|
+
404: errorSchema,
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
}, async (req, reply) => {
|
|
444
|
+
const g = gate(reply);
|
|
445
|
+
if (g !== undefined)
|
|
446
|
+
return g;
|
|
447
|
+
const rec = await getWorkerRecord(req.params.wid);
|
|
448
|
+
if (rec === undefined || rec.supervisorId !== req.params.id) {
|
|
449
|
+
return reply.code(404).send({ error: "worker_not_linked" });
|
|
450
|
+
}
|
|
451
|
+
const existing = getSession(req.params.wid);
|
|
452
|
+
if (existing !== undefined)
|
|
453
|
+
return { resumed: false };
|
|
454
|
+
try {
|
|
455
|
+
await resumeSessionById(req.params.wid);
|
|
456
|
+
}
|
|
457
|
+
catch (err) {
|
|
458
|
+
req.log.warn({ err, workerId: req.params.wid }, "resume worker failed");
|
|
459
|
+
return reply.code(404).send({ error: "resume_failed" });
|
|
460
|
+
}
|
|
461
|
+
return { resumed: true };
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
//# sourceMappingURL=orchestration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration.js","sourceRoot":"","sources":["../../src/routes/orchestration.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,UAAU,EACV,2B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