pilotswarm-sdk 0.3.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -4
- package/api/README.md +44 -0
- package/api/index.d.ts +86 -0
- package/api/index.js +16 -0
- package/api/src/api-client.js +363 -0
- package/api/src/http-api-transport.js +342 -0
- package/api/src/protocol.js +230 -0
- package/dist/agent-loader.d.ts +2 -0
- package/dist/agent-loader.d.ts.map +1 -1
- package/dist/agent-loader.js +7 -1
- package/dist/agent-loader.js.map +1 -1
- package/dist/client.d.ts +3 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +11 -0
- package/dist/client.js.map +1 -1
- package/dist/cms-migrations.d.ts.map +1 -1
- package/dist/cms-migrations.js +380 -1
- package/dist/cms-migrations.js.map +1 -1
- package/dist/cms.d.ts +12 -4
- package/dist/cms.d.ts.map +1 -1
- package/dist/cms.js +59 -3
- package/dist/cms.js.map +1 -1
- package/dist/index.d.ts +25 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/dist/management-client.d.ts +72 -4
- package/dist/management-client.d.ts.map +1 -1
- package/dist/management-client.js +202 -5
- package/dist/management-client.js.map +1 -1
- package/dist/session-proxy.d.ts +1 -0
- package/dist/session-proxy.d.ts.map +1 -1
- package/dist/session-proxy.js +14 -0
- package/dist/session-proxy.js.map +1 -1
- package/dist/session-store.d.ts.map +1 -1
- package/dist/session-store.js +13 -3
- package/dist/session-store.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/web/api-connection.d.ts +20 -0
- package/dist/web/api-connection.d.ts.map +1 -0
- package/dist/web/api-connection.js +23 -0
- package/dist/web/api-connection.js.map +1 -0
- package/dist/web/web-client.d.ts +92 -0
- package/dist/web/web-client.d.ts.map +1 -0
- package/dist/web/web-client.js +379 -0
- package/dist/web/web-client.js.map +1 -0
- package/dist/web/web-fact-store.d.ts +78 -0
- package/dist/web/web-fact-store.d.ts.map +1 -0
- package/dist/web/web-fact-store.js +112 -0
- package/dist/web/web-fact-store.js.map +1 -0
- package/dist/web/web-graph-store.d.ts +38 -0
- package/dist/web/web-graph-store.d.ts.map +1 -0
- package/dist/web/web-graph-store.js +68 -0
- package/dist/web/web-graph-store.js.map +1 -0
- package/dist/web/web-management-client.d.ts +125 -0
- package/dist/web/web-management-client.d.ts.map +1 -0
- package/dist/web/web-management-client.js +256 -0
- package/dist/web/web-management-client.js.map +1 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +29 -7
- package/dist/worker.js.map +1 -1
- package/package.json +17 -7
- package/plugins/mgmt/agents/agent-tuner.agent.md +6 -0
- package/plugins/mgmt/agents/facts-manager.agent.md +6 -0
- package/plugins/mgmt/agents/pilotswarm.agent.md +6 -0
- package/plugins/mgmt/agents/resourcemgr.agent.md +6 -0
- package/plugins/mgmt/agents/sweeper.agent.md +6 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { createApiClientFromOptions, webModeUnsupported, } from "./api-connection.js";
|
|
2
|
+
const WAIT_SLICE_MS = 10_000;
|
|
3
|
+
const EVENT_POLL_LIMIT = 200;
|
|
4
|
+
function createAbortError(message, reason) {
|
|
5
|
+
if (reason instanceof Error)
|
|
6
|
+
return reason;
|
|
7
|
+
const error = new Error(typeof reason === "string" && reason ? reason : message);
|
|
8
|
+
error.name = "AbortError";
|
|
9
|
+
return error;
|
|
10
|
+
}
|
|
11
|
+
function throwIfAborted(signal, message) {
|
|
12
|
+
if (signal?.aborted)
|
|
13
|
+
throw createAbortError(message, signal.reason);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* PilotSwarmClient in web mode: the same session-handle programming model as
|
|
17
|
+
* the direct client, implemented entirely over the Web API. Constructed via
|
|
18
|
+
* `new PilotSwarmClient({ apiUrl, … })`.
|
|
19
|
+
*/
|
|
20
|
+
export class WebPilotSwarmClient {
|
|
21
|
+
/** @internal */
|
|
22
|
+
_api;
|
|
23
|
+
started = false;
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this._api = createApiClientFromOptions(options);
|
|
26
|
+
}
|
|
27
|
+
async start() {
|
|
28
|
+
if (this.started)
|
|
29
|
+
return;
|
|
30
|
+
// Reset the WS lifecycle (a prior stop() latched it closed) and fail
|
|
31
|
+
// fast on unreachable/misconfigured hosts.
|
|
32
|
+
await this._api.start();
|
|
33
|
+
await this._api.health();
|
|
34
|
+
this.started = true;
|
|
35
|
+
}
|
|
36
|
+
async stop() {
|
|
37
|
+
this.started = false;
|
|
38
|
+
await this._api.stop();
|
|
39
|
+
}
|
|
40
|
+
async createSession(config) {
|
|
41
|
+
for (const key of ["sessionId", "parentSessionId", "agentId", "toolNames", "nestingLevel"]) {
|
|
42
|
+
if (config && config[key] !== undefined) {
|
|
43
|
+
throw webModeUnsupported(`createSession({ ${key} })`, "agent-bound sessions use createSessionForAgent; worker-side options are direct-mode only");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const view = await this._api.call("createSession", {
|
|
47
|
+
model: config?.model,
|
|
48
|
+
reasoningEffort: config?.reasoningEffort,
|
|
49
|
+
groupId: config?.groupId,
|
|
50
|
+
});
|
|
51
|
+
return new WebPilotSwarmSession(view.sessionId, this._api, config?.onUserInputRequest);
|
|
52
|
+
}
|
|
53
|
+
async createSessionForAgent(agentName, opts) {
|
|
54
|
+
const view = await this._api.call("createSessionForAgent", {
|
|
55
|
+
agentName,
|
|
56
|
+
model: opts?.model,
|
|
57
|
+
reasoningEffort: opts?.reasoningEffort,
|
|
58
|
+
title: opts?.title,
|
|
59
|
+
splash: opts?.splash,
|
|
60
|
+
splashMobile: opts?.splashMobile,
|
|
61
|
+
initialPrompt: opts?.initialPrompt,
|
|
62
|
+
groupId: opts?.groupId,
|
|
63
|
+
});
|
|
64
|
+
return new WebPilotSwarmSession(view.sessionId, this._api, opts?.onUserInputRequest);
|
|
65
|
+
}
|
|
66
|
+
async resumeSession(sessionId, config) {
|
|
67
|
+
const view = await this._api.call("getSession", { sessionId });
|
|
68
|
+
if (!view)
|
|
69
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
70
|
+
return new WebPilotSwarmSession(sessionId, this._api, config?.onUserInputRequest);
|
|
71
|
+
}
|
|
72
|
+
async listSessions() {
|
|
73
|
+
return this._api.call("listSessions");
|
|
74
|
+
}
|
|
75
|
+
async deleteSession(sessionId) {
|
|
76
|
+
await this._api.call("deleteSession", { sessionId });
|
|
77
|
+
}
|
|
78
|
+
async cancelPendingMessage(sessionId, clientMessageIds) {
|
|
79
|
+
await this._api.call("cancelPendingMessage", { sessionId, clientMessageIds });
|
|
80
|
+
}
|
|
81
|
+
createSystemSession() {
|
|
82
|
+
throw webModeUnsupported("createSystemSession", "system sessions are managed by the deployment");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Session handle over the Web API. Mirrors `PilotSwarmSession`:
|
|
87
|
+
* `send`/`wait`/`sendAndWait`, event subscription (`on`), and lifecycle.
|
|
88
|
+
*
|
|
89
|
+
* Turn results are observed through the same status/latest-response
|
|
90
|
+
* signals the direct client reads from the orchestration runtime — served
|
|
91
|
+
* here by `GET …/status/wait` (long poll) and `GET …/latest-response`.
|
|
92
|
+
*/
|
|
93
|
+
export class WebPilotSwarmSession {
|
|
94
|
+
sessionId;
|
|
95
|
+
api;
|
|
96
|
+
onUserInput;
|
|
97
|
+
pendingTurn = false;
|
|
98
|
+
lastSeenVersion = 0;
|
|
99
|
+
lastSeenIteration = -1;
|
|
100
|
+
lastSeenResponseVersion = 0;
|
|
101
|
+
seeded = false;
|
|
102
|
+
// Event subscription state: catch-up fetch (with live events buffered
|
|
103
|
+
// until it completes to avoid a race), then WebSocket push. On every
|
|
104
|
+
// reconnect the catch-up re-runs so events missed during the outage are
|
|
105
|
+
// replayed — the correctness mechanism behind WS acceleration.
|
|
106
|
+
handlers = new Map();
|
|
107
|
+
lastSeenSeq = 0;
|
|
108
|
+
wsUnsubscribe = null;
|
|
109
|
+
catchingUp = false;
|
|
110
|
+
liveBuffer = [];
|
|
111
|
+
/** @internal */
|
|
112
|
+
constructor(sessionId, api, onUserInput) {
|
|
113
|
+
this.sessionId = sessionId;
|
|
114
|
+
this.api = api;
|
|
115
|
+
this.onUserInput = onUserInput;
|
|
116
|
+
}
|
|
117
|
+
async send(prompt, opts) {
|
|
118
|
+
// Seed the turn-tracking cursors from the current live status before
|
|
119
|
+
// the first turn from this handle, so wait() accepts only results
|
|
120
|
+
// produced by our own prompt — not a previous turn's (on a resumed
|
|
121
|
+
// session) or a server-side bootstrap turn (createSessionForAgent
|
|
122
|
+
// with initialPrompt). Mirrors resumeSession() in the direct client.
|
|
123
|
+
await this._seedTurnCursors();
|
|
124
|
+
await this.api.call("sendMessage", {
|
|
125
|
+
sessionId: this.sessionId,
|
|
126
|
+
prompt,
|
|
127
|
+
options: opts?.clientMessageIds ? { clientMessageIds: opts.clientMessageIds } : {},
|
|
128
|
+
});
|
|
129
|
+
this.pendingTurn = true;
|
|
130
|
+
}
|
|
131
|
+
async _seedTurnCursors() {
|
|
132
|
+
if (this.seeded)
|
|
133
|
+
return;
|
|
134
|
+
this.seeded = true;
|
|
135
|
+
try {
|
|
136
|
+
const status = await this.api.call("getSessionStatus", { sessionId: this.sessionId });
|
|
137
|
+
const version = Number(status?.customStatusVersion) || 0;
|
|
138
|
+
if (version > this.lastSeenVersion)
|
|
139
|
+
this.lastSeenVersion = version;
|
|
140
|
+
const customStatus = status?.customStatus && typeof status.customStatus === "object" ? status.customStatus : null;
|
|
141
|
+
if (customStatus) {
|
|
142
|
+
if (typeof customStatus.iteration === "number")
|
|
143
|
+
this.lastSeenIteration = customStatus.iteration;
|
|
144
|
+
const responseVersion = Number(customStatus.responseVersion) || 0;
|
|
145
|
+
if (responseVersion > this.lastSeenResponseVersion)
|
|
146
|
+
this.lastSeenResponseVersion = responseVersion;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Best-effort, like the direct client: a fresh session has no
|
|
151
|
+
// status yet, and a failure here just means we start from zero.
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async sendAndWait(prompt, timeout, onIntermediateContent, opts) {
|
|
155
|
+
await this.send(prompt);
|
|
156
|
+
return this._waitForTurnResult(timeout ?? 300_000, onIntermediateContent, opts?.signal);
|
|
157
|
+
}
|
|
158
|
+
async wait(timeout, opts) {
|
|
159
|
+
if (!this.pendingTurn)
|
|
160
|
+
throw new Error("No pending turn. Call send() first.");
|
|
161
|
+
return this._waitForTurnResult(timeout ?? 300_000, undefined, opts?.signal);
|
|
162
|
+
}
|
|
163
|
+
on(eventTypeOrHandler, handler) {
|
|
164
|
+
const key = typeof eventTypeOrHandler === "function" ? null : eventTypeOrHandler;
|
|
165
|
+
const fn = typeof eventTypeOrHandler === "function" ? eventTypeOrHandler : handler;
|
|
166
|
+
if (!this.handlers.has(key))
|
|
167
|
+
this.handlers.set(key, new Set());
|
|
168
|
+
this.handlers.get(key).add(fn);
|
|
169
|
+
this._startEventDelivery();
|
|
170
|
+
return () => {
|
|
171
|
+
const set = this.handlers.get(key);
|
|
172
|
+
if (set) {
|
|
173
|
+
set.delete(fn);
|
|
174
|
+
if (set.size === 0)
|
|
175
|
+
this.handlers.delete(key);
|
|
176
|
+
}
|
|
177
|
+
if (this.handlers.size === 0)
|
|
178
|
+
this._stopEventDelivery();
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async sendEvent(eventName, data) {
|
|
182
|
+
await this.api.call("sendSessionEvent", { sessionId: this.sessionId, eventName, data });
|
|
183
|
+
}
|
|
184
|
+
async cancelPendingMessage(clientMessageIds) {
|
|
185
|
+
const ids = (clientMessageIds || []).filter((id) => typeof id === "string" && Boolean(id));
|
|
186
|
+
if (ids.length === 0)
|
|
187
|
+
return;
|
|
188
|
+
await this.api.call("cancelPendingMessage", { sessionId: this.sessionId, clientMessageIds: ids });
|
|
189
|
+
}
|
|
190
|
+
async abort() {
|
|
191
|
+
await this.api.call("cancelSession", { sessionId: this.sessionId });
|
|
192
|
+
}
|
|
193
|
+
async destroy() {
|
|
194
|
+
this._stopEventDelivery();
|
|
195
|
+
await this.api.call("deleteSession", { sessionId: this.sessionId });
|
|
196
|
+
}
|
|
197
|
+
async getMessages(limit) {
|
|
198
|
+
return this.api.call("getSessionEvents", { sessionId: this.sessionId, limit });
|
|
199
|
+
}
|
|
200
|
+
async getInfo() {
|
|
201
|
+
return this.api.call("getSession", { sessionId: this.sessionId });
|
|
202
|
+
}
|
|
203
|
+
// ─── Turn result waiting ─────────────────────────────────────────────
|
|
204
|
+
async _waitForTurnResult(timeout, onIntermediateContent, signal) {
|
|
205
|
+
const deadline = timeout > 0 ? Date.now() + timeout : Infinity;
|
|
206
|
+
const label = `WebPilotSwarmSession wait aborted (${this.sessionId})`;
|
|
207
|
+
while (Date.now() < deadline) {
|
|
208
|
+
throwIfAborted(signal, label);
|
|
209
|
+
const remaining = deadline === Infinity ? WAIT_SLICE_MS : Math.min(deadline - Date.now(), WAIT_SLICE_MS);
|
|
210
|
+
if (remaining <= 0)
|
|
211
|
+
break;
|
|
212
|
+
let status;
|
|
213
|
+
try {
|
|
214
|
+
status = await this.api.call("waitForStatusChange", {
|
|
215
|
+
sessionId: this.sessionId,
|
|
216
|
+
afterVersion: this.lastSeenVersion,
|
|
217
|
+
timeoutMs: Math.max(1_000, remaining),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
throwIfAborted(signal, label);
|
|
222
|
+
// Permanent errors (auth, bad request) must propagate — retrying
|
|
223
|
+
// them just hangs. Only transient faults (network, 5xx) fall
|
|
224
|
+
// through to a status-based recovery check.
|
|
225
|
+
const httpStatus = Number(error?.status);
|
|
226
|
+
if (httpStatus >= 400 && httpStatus < 500)
|
|
227
|
+
throw error;
|
|
228
|
+
// Transient: consult the current status so a terminal
|
|
229
|
+
// orchestration that stopped emitting is still detected
|
|
230
|
+
// (mirrors the direct client's getStatus fallback).
|
|
231
|
+
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
|
232
|
+
throwIfAborted(signal, label);
|
|
233
|
+
try {
|
|
234
|
+
status = await this.api.call("getSessionStatus", { sessionId: this.sessionId });
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
throwIfAborted(signal, label);
|
|
241
|
+
const version = Number(status?.customStatusVersion) || 0;
|
|
242
|
+
if (version < this.lastSeenVersion) {
|
|
243
|
+
// The orchestration was restarted (continue-as-new). Reset.
|
|
244
|
+
this.lastSeenIteration = -1;
|
|
245
|
+
}
|
|
246
|
+
this.lastSeenVersion = version;
|
|
247
|
+
const customStatus = status?.customStatus && typeof status.customStatus === "object"
|
|
248
|
+
? status.customStatus
|
|
249
|
+
: null;
|
|
250
|
+
if (customStatus) {
|
|
251
|
+
if (customStatus.intermediateContent && onIntermediateContent) {
|
|
252
|
+
onIntermediateContent(customStatus.intermediateContent);
|
|
253
|
+
}
|
|
254
|
+
if (customStatus.turnResult && customStatus.iteration > this.lastSeenIteration) {
|
|
255
|
+
this.lastSeenIteration = customStatus.iteration;
|
|
256
|
+
const result = customStatus.turnResult;
|
|
257
|
+
if (result.type === "completed") {
|
|
258
|
+
if (onIntermediateContent)
|
|
259
|
+
onIntermediateContent(result.content);
|
|
260
|
+
if (customStatus.status === "idle") {
|
|
261
|
+
this.pendingTurn = false;
|
|
262
|
+
return result.content;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (result.type === "input_required" && this.onUserInput) {
|
|
266
|
+
const answer = await this.onUserInput({ question: result.question, choices: result.choices, allowFreeform: result.allowFreeform }, { sessionId: this.sessionId });
|
|
267
|
+
throwIfAborted(signal, label);
|
|
268
|
+
await this.api.call("sendAnswer", { sessionId: this.sessionId, answer: answer.answer });
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const responseVersion = Number(customStatus.responseVersion) || 0;
|
|
273
|
+
if (responseVersion > this.lastSeenResponseVersion) {
|
|
274
|
+
const response = await this.api.call("getLatestResponse", {
|
|
275
|
+
sessionId: this.sessionId,
|
|
276
|
+
});
|
|
277
|
+
this.lastSeenResponseVersion = Math.max(this.lastSeenResponseVersion, response?.version ?? responseVersion);
|
|
278
|
+
if (response?.type === "completed" && response.content) {
|
|
279
|
+
if (onIntermediateContent)
|
|
280
|
+
onIntermediateContent(response.content);
|
|
281
|
+
if (customStatus.status === "idle" || customStatus.status === "completed") {
|
|
282
|
+
this.pendingTurn = false;
|
|
283
|
+
return response.content;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (response?.type === "wait" && response.content && onIntermediateContent) {
|
|
287
|
+
onIntermediateContent(response.content);
|
|
288
|
+
}
|
|
289
|
+
if (response?.type === "input_required" && response.question && this.onUserInput) {
|
|
290
|
+
const answer = await this.onUserInput({ question: response.question, choices: response.choices, allowFreeform: response.allowFreeform }, { sessionId: this.sessionId });
|
|
291
|
+
throwIfAborted(signal, label);
|
|
292
|
+
await this.api.call("sendAnswer", { sessionId: this.sessionId, answer: answer.answer });
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (status?.orchestrationStatus === "Failed") {
|
|
298
|
+
this.pendingTurn = false;
|
|
299
|
+
throw new Error("Orchestration failed");
|
|
300
|
+
}
|
|
301
|
+
if (status?.orchestrationStatus === "Completed") {
|
|
302
|
+
this.pendingTurn = false;
|
|
303
|
+
return customStatus?.turnResult?.type === "completed" ? customStatus.turnResult.content : undefined;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
throwIfAborted(signal, label);
|
|
307
|
+
throw new Error(`Timeout waiting for response (${timeout}ms)`);
|
|
308
|
+
}
|
|
309
|
+
// ─── Event delivery: catch-up fetch + WebSocket push ─────────────────
|
|
310
|
+
_startEventDelivery() {
|
|
311
|
+
if (this.wsUnsubscribe)
|
|
312
|
+
return;
|
|
313
|
+
this.wsUnsubscribe = this.api.subscribeSession(this.sessionId, (event) => this._onLiveEvent(event), () => { void this._catchUp(); });
|
|
314
|
+
void this._catchUp();
|
|
315
|
+
}
|
|
316
|
+
_onLiveEvent(event) {
|
|
317
|
+
if (!event || typeof event.seq !== "number")
|
|
318
|
+
return;
|
|
319
|
+
// Buffer live pushes while a catch-up fetch is in flight; otherwise a
|
|
320
|
+
// push could advance lastSeenSeq past history the fetch hasn't yet
|
|
321
|
+
// delivered, dropping those events.
|
|
322
|
+
if (this.catchingUp) {
|
|
323
|
+
this.liveBuffer.push(event);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
this._ingest(event);
|
|
327
|
+
}
|
|
328
|
+
_ingest(event) {
|
|
329
|
+
if (event.seq <= this.lastSeenSeq)
|
|
330
|
+
return;
|
|
331
|
+
this.lastSeenSeq = event.seq;
|
|
332
|
+
this._dispatch(event);
|
|
333
|
+
}
|
|
334
|
+
async _catchUp() {
|
|
335
|
+
if (this.catchingUp)
|
|
336
|
+
return;
|
|
337
|
+
this.catchingUp = true;
|
|
338
|
+
try {
|
|
339
|
+
const events = await this.api.call("getSessionEvents", {
|
|
340
|
+
sessionId: this.sessionId,
|
|
341
|
+
afterSeq: this.lastSeenSeq,
|
|
342
|
+
limit: EVENT_POLL_LIMIT,
|
|
343
|
+
});
|
|
344
|
+
for (const event of events || [])
|
|
345
|
+
this._ingest(event);
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
// Best-effort; a later reconnect or the live stream recovers it.
|
|
349
|
+
}
|
|
350
|
+
finally {
|
|
351
|
+
this.catchingUp = false;
|
|
352
|
+
const buffered = this.liveBuffer.sort((a, b) => a.seq - b.seq);
|
|
353
|
+
this.liveBuffer = [];
|
|
354
|
+
for (const event of buffered)
|
|
355
|
+
this._ingest(event);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
_stopEventDelivery() {
|
|
359
|
+
if (this.wsUnsubscribe) {
|
|
360
|
+
this.wsUnsubscribe();
|
|
361
|
+
this.wsUnsubscribe = null;
|
|
362
|
+
}
|
|
363
|
+
this.liveBuffer = [];
|
|
364
|
+
this.catchingUp = false;
|
|
365
|
+
}
|
|
366
|
+
_dispatch(event) {
|
|
367
|
+
const typed = this.handlers.get(event.eventType);
|
|
368
|
+
if (typed) {
|
|
369
|
+
for (const fn of typed)
|
|
370
|
+
fn(event);
|
|
371
|
+
}
|
|
372
|
+
const catchAll = this.handlers.get(null);
|
|
373
|
+
if (catchAll) {
|
|
374
|
+
for (const fn of catchAll)
|
|
375
|
+
fn(event);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
//# sourceMappingURL=web-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-client.js","sourceRoot":"","sources":["../../src/web/web-client.ts"],"names":[],"mappings":"AAOA,OAAO,EAEH,0BAA0B,EAC1B,kBAAkB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAI7B,SAAS,gBAAgB,CAAC,OAAe,EAAE,MAAgB;IACvD,IAAI,MAAM,YAAY,KAAK;QAAE,OAAO,MAAM,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACjF,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC;IAC1B,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B,EAAE,OAAe;IACpE,IAAI,MAAM,EAAE,OAAO;QAAE,MAAM,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACH,MAAM,OAA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AI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC5B,CAAC;IAEO,SAAS,CAAC,KAAmB;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,KAAK,EAAE,CAAC;YACR,KAAK,MAAM,EAAE,IAAI,KAAK;gBAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,QAAQ,EAAE,CAAC;YACX,KAAK,MAAM,EAAE,IAAI,QAAQ;gBAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ApiClient } from "pilotswarm-sdk/api";
|
|
2
|
+
import type { FactStore, EnhancedFactStore, FactRecord, StoreFactInput, StoredFactResult, ReadFactsQuery, DeleteFactInput, DeletedFactResult, DeletedFactsResult, AccessContext, FactsStatsRow, FactsTombstoneStats, SetFactsCrawledInput, ForcePurgeFactsInput, SearchOpts, SimilarOpts, SearchResult, FactsCapabilities, EmbedderStatus } from "../facts-store.js";
|
|
3
|
+
/**
|
|
4
|
+
* `FactStore` over the PilotSwarm Web API.
|
|
5
|
+
*
|
|
6
|
+
* Implements the same interface the runtime programs against, so any consumer
|
|
7
|
+
* typed as `FactStore` (the MCP server, SDK tools) works unchanged over the
|
|
8
|
+
* API — no direct database connection. Constructed via
|
|
9
|
+
* {@link createWebFactStore}, which reads `/facts/capabilities` first and
|
|
10
|
+
* returns the enhanced subclass when the deployment supports search.
|
|
11
|
+
*
|
|
12
|
+
* Access control is server-side: `AccessContext` arguments are accepted for
|
|
13
|
+
* interface compatibility but ignored on the wire — the server derives access
|
|
14
|
+
* from the authenticated principal. Crawler/sweeper methods (`readUncrawledFacts`,
|
|
15
|
+
* `setFactsCrawled`, `purgeExpiredFacts`, `deleteSessionFactsForSession`) are
|
|
16
|
+
* in-cluster machinery, not exposed over the API, and throw here.
|
|
17
|
+
*/
|
|
18
|
+
export declare class WebFactStore implements FactStore {
|
|
19
|
+
protected readonly api: ApiClient;
|
|
20
|
+
constructor(api: ApiClient);
|
|
21
|
+
initialize(): Promise<void>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
storeFact(input: StoreFactInput): Promise<StoredFactResult>;
|
|
24
|
+
storeFact(input: StoreFactInput[]): Promise<{
|
|
25
|
+
stored: number;
|
|
26
|
+
facts: StoredFactResult[];
|
|
27
|
+
}>;
|
|
28
|
+
readFacts(query: ReadFactsQuery, _access?: AccessContext): Promise<{
|
|
29
|
+
count: number;
|
|
30
|
+
facts: FactRecord[];
|
|
31
|
+
}>;
|
|
32
|
+
deleteFact(input: DeleteFactInput & {
|
|
33
|
+
pattern: true;
|
|
34
|
+
}): Promise<DeletedFactsResult>;
|
|
35
|
+
deleteFact(input: DeleteFactInput & {
|
|
36
|
+
pattern?: false | undefined;
|
|
37
|
+
}): Promise<DeletedFactResult>;
|
|
38
|
+
getSessionFactsStats(sessionId: string): Promise<FactsStatsRow[]>;
|
|
39
|
+
getFactsStatsForSessions(_sessionIds: string[]): Promise<FactsStatsRow[]>;
|
|
40
|
+
getSharedFactsStats(): Promise<FactsStatsRow[]>;
|
|
41
|
+
getFactsTombstoneStats(ttlSeconds?: number): Promise<FactsTombstoneStats>;
|
|
42
|
+
readUncrawledFacts(): Promise<{
|
|
43
|
+
count: number;
|
|
44
|
+
facts: FactRecord[];
|
|
45
|
+
}>;
|
|
46
|
+
setFactsCrawled(_input: SetFactsCrawledInput): Promise<{
|
|
47
|
+
affected: number;
|
|
48
|
+
skipped: number;
|
|
49
|
+
}>;
|
|
50
|
+
purgeExpiredFacts(): Promise<number>;
|
|
51
|
+
deleteSessionFactsForSession(): Promise<number>;
|
|
52
|
+
forcePurgeFacts(input: ForcePurgeFactsInput): Promise<number>;
|
|
53
|
+
}
|
|
54
|
+
/** Enhanced variant, present only when the deployment advertises search. */
|
|
55
|
+
export declare class WebEnhancedFactStore extends WebFactStore implements EnhancedFactStore {
|
|
56
|
+
readonly capabilities: FactsCapabilities;
|
|
57
|
+
constructor(api: ApiClient, capabilities: FactsCapabilities);
|
|
58
|
+
searchFacts(query: string, opts?: SearchOpts, _access?: AccessContext): Promise<SearchResult>;
|
|
59
|
+
similarFacts(scopeKey: string, opts?: SimilarOpts, _access?: AccessContext): Promise<SearchResult>;
|
|
60
|
+
configureEmbedder(): Promise<EmbedderStatus>;
|
|
61
|
+
startEmbedder(opts?: {
|
|
62
|
+
intervalSeconds?: number;
|
|
63
|
+
batch?: number;
|
|
64
|
+
}): Promise<EmbedderStatus>;
|
|
65
|
+
stopEmbedder(reason?: string): Promise<EmbedderStatus>;
|
|
66
|
+
embedderStatus(): Promise<EmbedderStatus>;
|
|
67
|
+
}
|
|
68
|
+
/** Facts capabilities as reported by the deployment. */
|
|
69
|
+
export interface WebFactsCapabilities extends FactsCapabilities {
|
|
70
|
+
graph: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build a `FactStore` (or `EnhancedFactStore`) over the Web API. Reads
|
|
74
|
+
* `/facts/capabilities` so `isEnhancedFactStore(store)` is accurate — the
|
|
75
|
+
* remote equivalent of the PgFactStore-vs-HorizonDBFactStore distinction.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createWebFactStore(api: ApiClient): Promise<FactStore>;
|
|
78
|
+
//# sourceMappingURL=web-fact-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-fact-store.d.ts","sourceRoot":"","sources":["../../src/web/web-fact-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACR,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAC1F,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IlD;AAED,wDAAwD;AACxD,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC3D,KAAK,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAM3E"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { EnhancedFactsUnsupportedError } from "../facts-store.js";
|
|
2
|
+
/**
|
|
3
|
+
* `FactStore` over the PilotSwarm Web API.
|
|
4
|
+
*
|
|
5
|
+
* Implements the same interface the runtime programs against, so any consumer
|
|
6
|
+
* typed as `FactStore` (the MCP server, SDK tools) works unchanged over the
|
|
7
|
+
* API — no direct database connection. Constructed via
|
|
8
|
+
* {@link createWebFactStore}, which reads `/facts/capabilities` first and
|
|
9
|
+
* returns the enhanced subclass when the deployment supports search.
|
|
10
|
+
*
|
|
11
|
+
* Access control is server-side: `AccessContext` arguments are accepted for
|
|
12
|
+
* interface compatibility but ignored on the wire — the server derives access
|
|
13
|
+
* from the authenticated principal. Crawler/sweeper methods (`readUncrawledFacts`,
|
|
14
|
+
* `setFactsCrawled`, `purgeExpiredFacts`, `deleteSessionFactsForSession`) are
|
|
15
|
+
* in-cluster machinery, not exposed over the API, and throw here.
|
|
16
|
+
*/
|
|
17
|
+
export class WebFactStore {
|
|
18
|
+
api;
|
|
19
|
+
constructor(api) {
|
|
20
|
+
this.api = api;
|
|
21
|
+
}
|
|
22
|
+
async initialize() {
|
|
23
|
+
// No-op: the server owns store lifecycle. Present for interface parity.
|
|
24
|
+
}
|
|
25
|
+
async close() {
|
|
26
|
+
// No-op: the ApiClient is owned by the caller / MCP context.
|
|
27
|
+
}
|
|
28
|
+
async storeFact(input) {
|
|
29
|
+
return this.api.call("storeFact", { input });
|
|
30
|
+
}
|
|
31
|
+
async readFacts(query, _access) {
|
|
32
|
+
return this.api.call("readFacts", { ...query });
|
|
33
|
+
}
|
|
34
|
+
async deleteFact(input) {
|
|
35
|
+
return this.api.call("deleteFact", { input });
|
|
36
|
+
}
|
|
37
|
+
async getSessionFactsStats(sessionId) {
|
|
38
|
+
const result = await this.api.call("getSessionFactsStats", { sessionId });
|
|
39
|
+
return result?.rows ?? result ?? [];
|
|
40
|
+
}
|
|
41
|
+
async getFactsStatsForSessions(_sessionIds) {
|
|
42
|
+
// No direct multi-session stats op; the tree-stats surface covers the
|
|
43
|
+
// spawn-tree case. Not needed by remote callers today.
|
|
44
|
+
throw new EnhancedFactsUnsupportedError("getFactsStatsForSessions (web)");
|
|
45
|
+
}
|
|
46
|
+
async getSharedFactsStats() {
|
|
47
|
+
const result = await this.api.call("getSharedFactsStats");
|
|
48
|
+
return result?.rows ?? result ?? [];
|
|
49
|
+
}
|
|
50
|
+
async getFactsTombstoneStats(ttlSeconds) {
|
|
51
|
+
return this.api.call("getFactsTombstoneStats", { ttlSeconds });
|
|
52
|
+
}
|
|
53
|
+
// ── Crawler/sweeper machinery — not exposed over the API ──────────
|
|
54
|
+
async readUncrawledFacts() {
|
|
55
|
+
throw new EnhancedFactsUnsupportedError("readUncrawledFacts (web)");
|
|
56
|
+
}
|
|
57
|
+
async setFactsCrawled(_input) {
|
|
58
|
+
throw new EnhancedFactsUnsupportedError("setFactsCrawled (web)");
|
|
59
|
+
}
|
|
60
|
+
async purgeExpiredFacts() {
|
|
61
|
+
throw new EnhancedFactsUnsupportedError("purgeExpiredFacts (web)");
|
|
62
|
+
}
|
|
63
|
+
async deleteSessionFactsForSession() {
|
|
64
|
+
throw new EnhancedFactsUnsupportedError("deleteSessionFactsForSession (web)");
|
|
65
|
+
}
|
|
66
|
+
// ── Admin operational (server enforces the admin role) ────────────
|
|
67
|
+
async forcePurgeFacts(input) {
|
|
68
|
+
return this.api.call("forcePurgeFacts", { input });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Enhanced variant, present only when the deployment advertises search. */
|
|
72
|
+
export class WebEnhancedFactStore extends WebFactStore {
|
|
73
|
+
capabilities;
|
|
74
|
+
constructor(api, capabilities) {
|
|
75
|
+
super(api);
|
|
76
|
+
this.capabilities = capabilities;
|
|
77
|
+
}
|
|
78
|
+
async searchFacts(query, opts, _access) {
|
|
79
|
+
return this.api.call("searchFacts", { query, opts });
|
|
80
|
+
}
|
|
81
|
+
async similarFacts(scopeKey, opts, _access) {
|
|
82
|
+
return this.api.call("similarFacts", { scopeKey, opts });
|
|
83
|
+
}
|
|
84
|
+
async configureEmbedder() {
|
|
85
|
+
// configureEmbedder carries an embedding endpoint (with secrets) and is
|
|
86
|
+
// a worker-side concern; not exposed. start/stop/status are.
|
|
87
|
+
throw new EnhancedFactsUnsupportedError("configureEmbedder (web)");
|
|
88
|
+
}
|
|
89
|
+
async startEmbedder(opts) {
|
|
90
|
+
return this.api.call("startFactsEmbedder", { intervalSeconds: opts?.intervalSeconds, batch: opts?.batch });
|
|
91
|
+
}
|
|
92
|
+
async stopEmbedder(reason) {
|
|
93
|
+
return this.api.call("stopFactsEmbedder", { reason });
|
|
94
|
+
}
|
|
95
|
+
async embedderStatus() {
|
|
96
|
+
const st = await this.api.call("getEmbedderStatus");
|
|
97
|
+
return { running: Boolean(st?.running), instanceId: st?.instanceId, status: st?.status };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Build a `FactStore` (or `EnhancedFactStore`) over the Web API. Reads
|
|
102
|
+
* `/facts/capabilities` so `isEnhancedFactStore(store)` is accurate — the
|
|
103
|
+
* remote equivalent of the PgFactStore-vs-HorizonDBFactStore distinction.
|
|
104
|
+
*/
|
|
105
|
+
export async function createWebFactStore(api) {
|
|
106
|
+
const caps = (await api.call("factsCapabilities"));
|
|
107
|
+
if (caps?.search) {
|
|
108
|
+
return new WebEnhancedFactStore(api, { search: Boolean(caps.search), embedder: Boolean(caps.embedder) });
|
|
109
|
+
}
|
|
110
|
+
return new WebFactStore(api);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=web-fact-store.js.map
|
|
@@ -0,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,CAAC,EAAE,CAAC,CAAC;IAC7G,CAAC;IACD,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ApiClient } from "pilotswarm-sdk/api";
|
|
2
|
+
import type { GraphStore, GraphNodeInput, GraphEdgeInput, GraphNodeQuery, GraphEdgeQuery, GraphNodeHit, GraphEdgeHit, GraphNodeRef, GraphEdgeRef, SubGraph, GraphNamespaceInfo, GraphNamespaceListQuery, GraphNamespaceInput, GraphNamespaceQuery, GraphNamespaceDeleteResult, GraphEvidenceRemovalResult } from "../graph-store.js";
|
|
3
|
+
import type { AccessContext } from "../facts-store.js";
|
|
4
|
+
/**
|
|
5
|
+
* `GraphStore` over the PilotSwarm Web API. Implements the runtime's graph
|
|
6
|
+
* contract so graph tools/consumers work remotely. Access is server-derived;
|
|
7
|
+
* `AccessContext` args are accepted for parity and ignored on the wire.
|
|
8
|
+
*
|
|
9
|
+
* Evidence-reconciliation methods (`removeGraphEvidence`, `mergeGraphNodes`)
|
|
10
|
+
* are in-cluster harvester machinery and are not exposed over the API.
|
|
11
|
+
*/
|
|
12
|
+
export declare class WebGraphStore implements GraphStore {
|
|
13
|
+
private readonly api;
|
|
14
|
+
constructor(api: ApiClient);
|
|
15
|
+
initialize(): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
searchGraphNodes(q: GraphNodeQuery, _access?: AccessContext): Promise<GraphNodeHit[]>;
|
|
18
|
+
searchGraphEdges(q: GraphEdgeQuery, _access?: AccessContext): Promise<GraphEdgeHit[]>;
|
|
19
|
+
graphNeighbourhood(nodeKey: string, depth: number, _access?: AccessContext, opts?: GraphNamespaceQuery): Promise<SubGraph>;
|
|
20
|
+
upsertGraphNode(n: GraphNodeInput): Promise<GraphNodeRef>;
|
|
21
|
+
upsertGraphEdge(e: GraphEdgeInput): Promise<GraphEdgeRef>;
|
|
22
|
+
deleteGraphNode(nodeKey: string, opts?: GraphNamespaceQuery): Promise<boolean>;
|
|
23
|
+
deleteGraphEdge(fromKey: string, toKey: string, predicateKey: string, opts?: GraphNamespaceQuery): Promise<boolean>;
|
|
24
|
+
mergeGraphNodes(): Promise<void>;
|
|
25
|
+
removeGraphEvidence(): Promise<GraphEvidenceRemovalResult>;
|
|
26
|
+
graphStats(opts?: GraphNamespaceQuery): Promise<{
|
|
27
|
+
nodeCount: number;
|
|
28
|
+
edgeCount: number;
|
|
29
|
+
uncrawledFacts?: number;
|
|
30
|
+
}>;
|
|
31
|
+
listGraphNamespaces(q?: GraphNamespaceListQuery): Promise<GraphNamespaceInfo[]>;
|
|
32
|
+
getGraphNamespace(namespace: string): Promise<GraphNamespaceInfo | null>;
|
|
33
|
+
upsertGraphNamespace(input: GraphNamespaceInput): Promise<GraphNamespaceInfo>;
|
|
34
|
+
deleteGraphNamespace(namespace: string): Promise<GraphNamespaceDeleteResult>;
|
|
35
|
+
}
|
|
36
|
+
/** Build a `GraphStore` over the Web API. Returns null when the deployment has no graph store. */
|
|
37
|
+
export declare function createWebGraphStore(api: ApiClient): Promise<GraphStore | null>;
|
|
38
|
+
//# sourceMappingURL=web-graph-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-graph-store.d.ts","sourceRoot":"","sources":["../../src/web/web-graph-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACR,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EACxF,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,uBAAuB,EAC/F,mBAAmB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,0BAA0B,EACnG,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;GAO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