@prismer/runtime 1.9.24 → 2.0.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/CHANGELOG.md +203 -110
- package/README.md +7 -7
- package/dist/cli.cjs +4766 -1012
- package/dist/cli.js +4675 -928
- package/dist/index.cjs +4526 -887
- package/dist/index.d.cts +618 -72
- package/dist/index.d.ts +618 -72
- package/dist/index.js +4462 -833
- package/package.json +2 -1
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -28,6 +28,11 @@ interface AdapterDef {
|
|
|
28
28
|
workspaceSchema: z.ZodSchema;
|
|
29
29
|
/** Long-running: ensure the underlying service is reachable. May spawn or just connect. */
|
|
30
30
|
ensureService?(profile: AgentProfile): Promise<AdapterService>;
|
|
31
|
+
/**
|
|
32
|
+
* Optional preflight called when the daemon syncs a profile. This should
|
|
33
|
+
* prepare local profile files/config without starting a long-running service.
|
|
34
|
+
*/
|
|
35
|
+
prepareProfile?(profile: AgentProfile): Promise<void>;
|
|
31
36
|
/** Interactive: one-shot dispatch (spawn-per-task). */
|
|
32
37
|
dispatch?(profile: AgentProfile, task: TaskInput): Promise<TaskResult>;
|
|
33
38
|
/** Validate config before persisting `AgentProfile.config`. */
|
|
@@ -148,6 +153,11 @@ declare class AdapterRegistry {
|
|
|
148
153
|
* Match rules (deterministic, sorted by name):
|
|
149
154
|
* - exact: adapter declared the tag verbatim
|
|
150
155
|
* - wildcard: adapter declared `code.*` → matches `code.write`
|
|
156
|
+
*
|
|
157
|
+
* @internal — v2.0: no caller in tree uses capability-based selection;
|
|
158
|
+
* dispatch routes by `profile.adapterName` directly. Kept for tests +
|
|
159
|
+
* future use (e.g. mobile capability negotiation), but not part of the
|
|
160
|
+
* stable adapter contract surface.
|
|
151
161
|
*/
|
|
152
162
|
findByCapability(capability: string): AdapterDef[];
|
|
153
163
|
}
|
|
@@ -210,6 +220,84 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
210
220
|
nativeMirrorTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
211
221
|
/** Task authority level: executor (default) or orchestrator. */
|
|
212
222
|
taskAuthority: z.ZodDefault<z.ZodOptional<z.ZodEnum<["executor", "orchestrator"]>>>;
|
|
223
|
+
/** Human approval escalation policy. Enforcement is currently prompt/cloud-side. */
|
|
224
|
+
approvalPolicy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["strict", "auto-low-risk", "autonomous"]>>>;
|
|
225
|
+
/** Agent-level MCP tool allowlist. Empty/null means all tools. Supports exact names and trailing * wildcards. */
|
|
226
|
+
mcpAllowlist: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
227
|
+
/** Agent-level operating principles injected through /v1/runs instructions. */
|
|
228
|
+
operatingPrinciples: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
229
|
+
source: z.ZodString;
|
|
230
|
+
text: z.ZodString;
|
|
231
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
232
|
+
source: z.ZodString;
|
|
233
|
+
text: z.ZodString;
|
|
234
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
235
|
+
source: z.ZodString;
|
|
236
|
+
text: z.ZodString;
|
|
237
|
+
}, z.ZodTypeAny, "passthrough">>, "many">]>>;
|
|
238
|
+
/** Override the skills root read for dispatch-time SKILL.md injection. */
|
|
239
|
+
skillsDir: z.ZodOptional<z.ZodString>;
|
|
240
|
+
/**
|
|
241
|
+
* Role-template snapshot carried in AgentProfile.config by cloud ACP.
|
|
242
|
+
* Expected fields used here:
|
|
243
|
+
* - roleTemplate.mcpServers[].toolsAllowlist
|
|
244
|
+
* - roleTemplate.operatingPrinciples
|
|
245
|
+
*/
|
|
246
|
+
roleTemplate: z.ZodOptional<z.ZodObject<{
|
|
247
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
248
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
249
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
250
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
251
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
252
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
253
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
254
|
+
operatingPrinciples: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
255
|
+
source: z.ZodString;
|
|
256
|
+
text: z.ZodString;
|
|
257
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
258
|
+
source: z.ZodString;
|
|
259
|
+
text: z.ZodString;
|
|
260
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
261
|
+
source: z.ZodString;
|
|
262
|
+
text: z.ZodString;
|
|
263
|
+
}, z.ZodTypeAny, "passthrough">>, "many">]>>;
|
|
264
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
265
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
266
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
267
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
268
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
269
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
270
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
271
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
272
|
+
operatingPrinciples: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
273
|
+
source: z.ZodString;
|
|
274
|
+
text: z.ZodString;
|
|
275
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
276
|
+
source: z.ZodString;
|
|
277
|
+
text: z.ZodString;
|
|
278
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
279
|
+
source: z.ZodString;
|
|
280
|
+
text: z.ZodString;
|
|
281
|
+
}, z.ZodTypeAny, "passthrough">>, "many">]>>;
|
|
282
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
283
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
284
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
285
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
286
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
287
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
288
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
289
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
290
|
+
operatingPrinciples: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
291
|
+
source: z.ZodString;
|
|
292
|
+
text: z.ZodString;
|
|
293
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
294
|
+
source: z.ZodString;
|
|
295
|
+
text: z.ZodString;
|
|
296
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
297
|
+
source: z.ZodString;
|
|
298
|
+
text: z.ZodString;
|
|
299
|
+
}, z.ZodTypeAny, "passthrough">>, "many">]>>;
|
|
300
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
213
301
|
}, "strip", z.ZodTypeAny, {
|
|
214
302
|
port: number;
|
|
215
303
|
apiKey: string;
|
|
@@ -224,10 +312,36 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
224
312
|
mirrorNativeGoals: boolean;
|
|
225
313
|
nativeMirrorTimeoutMs: number;
|
|
226
314
|
taskAuthority: "executor" | "orchestrator";
|
|
315
|
+
approvalPolicy: "strict" | "auto-low-risk" | "autonomous";
|
|
227
316
|
hermesProfileName?: string | undefined;
|
|
228
317
|
prismerMcpServerPath?: string | undefined;
|
|
229
318
|
prismerProviderBaseUrl?: string | undefined;
|
|
230
319
|
hermesSourceDir?: string | undefined;
|
|
320
|
+
mcpAllowlist?: string[] | null | undefined;
|
|
321
|
+
operatingPrinciples?: string | Record<string, string> | z.objectOutputType<{
|
|
322
|
+
source: z.ZodString;
|
|
323
|
+
text: z.ZodString;
|
|
324
|
+
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
325
|
+
skillsDir?: string | undefined;
|
|
326
|
+
roleTemplate?: z.objectOutputType<{
|
|
327
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
328
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
329
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
330
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
331
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
332
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
333
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
334
|
+
operatingPrinciples: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
335
|
+
source: z.ZodString;
|
|
336
|
+
text: z.ZodString;
|
|
337
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
338
|
+
source: z.ZodString;
|
|
339
|
+
text: z.ZodString;
|
|
340
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
341
|
+
source: z.ZodString;
|
|
342
|
+
text: z.ZodString;
|
|
343
|
+
}, z.ZodTypeAny, "passthrough">>, "many">]>>;
|
|
344
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
231
345
|
}, {
|
|
232
346
|
apiKey: string;
|
|
233
347
|
hermesProfileName?: string | undefined;
|
|
@@ -246,10 +360,114 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
246
360
|
hermesSourceDir?: string | undefined;
|
|
247
361
|
nativeMirrorTimeoutMs?: number | undefined;
|
|
248
362
|
taskAuthority?: "executor" | "orchestrator" | undefined;
|
|
363
|
+
approvalPolicy?: "strict" | "auto-low-risk" | "autonomous" | undefined;
|
|
364
|
+
mcpAllowlist?: string[] | null | undefined;
|
|
365
|
+
operatingPrinciples?: string | Record<string, string> | z.objectInputType<{
|
|
366
|
+
source: z.ZodString;
|
|
367
|
+
text: z.ZodString;
|
|
368
|
+
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
369
|
+
skillsDir?: string | undefined;
|
|
370
|
+
roleTemplate?: z.objectInputType<{
|
|
371
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
372
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
373
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
374
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
375
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
376
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
377
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
378
|
+
operatingPrinciples: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
379
|
+
source: z.ZodString;
|
|
380
|
+
text: z.ZodString;
|
|
381
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
382
|
+
source: z.ZodString;
|
|
383
|
+
text: z.ZodString;
|
|
384
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
385
|
+
source: z.ZodString;
|
|
386
|
+
text: z.ZodString;
|
|
387
|
+
}, z.ZodTypeAny, "passthrough">>, "many">]>>;
|
|
388
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
249
389
|
}>;
|
|
250
390
|
type HermesProfileConfig = z.infer<typeof HermesProfileConfigSchema>;
|
|
251
391
|
declare const hermesAdapter: AdapterDef;
|
|
252
392
|
|
|
393
|
+
declare const OpenClawProfileConfigSchema: z.ZodObject<{
|
|
394
|
+
/** OpenClaw chat-completions HTTP port. */
|
|
395
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
396
|
+
/** Bearer token expected by the gateway (from gateway.auth.bearerTokens). */
|
|
397
|
+
apiKey: z.ZodString;
|
|
398
|
+
/**
|
|
399
|
+
* Model field passed to OpenClaw's /v1/chat/completions. OpenClaw
|
|
400
|
+
* intercepts this differently from a vanilla OpenAI server: the value
|
|
401
|
+
* MUST be `openclaw` (or `openclaw/<agentId>`) — it picks which
|
|
402
|
+
* OpenClaw agent answers, NOT the underlying LLM. The LLM is selected
|
|
403
|
+
* by `agents.defaults.model.primary` in openclaw.json (e.g.
|
|
404
|
+
* `prismer/us-kimi-k2.5`, set by the bootstrap).
|
|
405
|
+
*/
|
|
406
|
+
model: z.ZodDefault<z.ZodString>;
|
|
407
|
+
mcpAllowlist: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
408
|
+
approvalPolicy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["strict", "auto-low-risk", "autonomous"]>>>;
|
|
409
|
+
roleTemplate: z.ZodOptional<z.ZodObject<{
|
|
410
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
411
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
412
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
413
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
414
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
415
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
416
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
417
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
418
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
419
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
420
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
421
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
422
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
423
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
424
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
425
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
426
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
427
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
428
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
429
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
430
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
431
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
432
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
433
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
434
|
+
skillsDir: z.ZodOptional<z.ZodString>;
|
|
435
|
+
}, "strip", z.ZodTypeAny, {
|
|
436
|
+
port: number;
|
|
437
|
+
apiKey: string;
|
|
438
|
+
model: string;
|
|
439
|
+
approvalPolicy: "strict" | "auto-low-risk" | "autonomous";
|
|
440
|
+
mcpAllowlist?: string[] | null | undefined;
|
|
441
|
+
skillsDir?: string | undefined;
|
|
442
|
+
roleTemplate?: z.objectOutputType<{
|
|
443
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
444
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
445
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
446
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
447
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
448
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
449
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
450
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
451
|
+
}, {
|
|
452
|
+
apiKey: string;
|
|
453
|
+
port?: number | undefined;
|
|
454
|
+
model?: string | undefined;
|
|
455
|
+
approvalPolicy?: "strict" | "auto-low-risk" | "autonomous" | undefined;
|
|
456
|
+
mcpAllowlist?: string[] | null | undefined;
|
|
457
|
+
skillsDir?: string | undefined;
|
|
458
|
+
roleTemplate?: z.objectInputType<{
|
|
459
|
+
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
460
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
461
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
462
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
463
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
464
|
+
toolsAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
465
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
466
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
467
|
+
}>;
|
|
468
|
+
type OpenClawProfileConfig = z.infer<typeof OpenClawProfileConfigSchema>;
|
|
469
|
+
declare const openclawAdapter: AdapterDef;
|
|
470
|
+
|
|
253
471
|
interface WsClientOptions {
|
|
254
472
|
/** Cloud WS URL, e.g. `wss://cloud.prismer.dev/ws` or `ws://127.0.0.1:3000/ws`. */
|
|
255
473
|
url: string;
|
|
@@ -552,6 +770,10 @@ declare class CloudClient {
|
|
|
552
770
|
private readonly opts;
|
|
553
771
|
private readonly fetchImpl;
|
|
554
772
|
constructor(opts: CloudClientOptions);
|
|
773
|
+
/** Configured cloud base URL (no trailing slash). */
|
|
774
|
+
get baseUrl(): string;
|
|
775
|
+
/** Bearer API key used to authorize requests. Treat as a secret. */
|
|
776
|
+
get apiKey(): string;
|
|
555
777
|
/** Low-level request. Caller decides on retry; sync-worker handles backoff. */
|
|
556
778
|
request<T = unknown>(method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE', path: string, init?: {
|
|
557
779
|
body?: unknown;
|
|
@@ -643,6 +865,38 @@ declare class AssetCache {
|
|
|
643
865
|
signal?: AbortSignal;
|
|
644
866
|
assetId?: string;
|
|
645
867
|
}): Promise<CachedAsset>;
|
|
868
|
+
/**
|
|
869
|
+
* Fetch a public http(s) URL, content-hash dedup, cache locally.
|
|
870
|
+
*
|
|
871
|
+
* Mirrors `getOrFetch` (cache key = sha256 of body bytes), but the input
|
|
872
|
+
* is a URL whose hash we don't know up front. The fetcher applies:
|
|
873
|
+
*
|
|
874
|
+
* - SSRF guard (resolve hostname, reject loopback / RFC1918 / link-local
|
|
875
|
+
* / cloud-metadata / IPv6 ULA + link-local). Cross-host redirects
|
|
876
|
+
* re-validate the new host before each hop.
|
|
877
|
+
* - manual redirect handling (max 3 hops).
|
|
878
|
+
* - hard timeout (default 15 s, override via env
|
|
879
|
+
* `PRISMER_URL_FETCH_TIMEOUT_MS`).
|
|
880
|
+
* - streaming body read with abort-at-limit (default 5 MiB, override
|
|
881
|
+
* via env `PRISMER_URL_FETCH_MAX_BYTES`). Truncated bodies are NOT
|
|
882
|
+
* cached.
|
|
883
|
+
* - non-2xx → throws (caller should leave the URL in place and emit
|
|
884
|
+
* an `error` observation).
|
|
885
|
+
*
|
|
886
|
+
* On success returns { cached, finalUrl, durationMs }; the caller can
|
|
887
|
+
* pin / unpin the hash like any other asset.
|
|
888
|
+
*/
|
|
889
|
+
getOrFetchUrl(url: string, opts?: {
|
|
890
|
+
signal?: AbortSignal;
|
|
891
|
+
userAgent?: string;
|
|
892
|
+
maxBytes?: number;
|
|
893
|
+
timeoutMs?: number;
|
|
894
|
+
maxRedirects?: number;
|
|
895
|
+
}): Promise<{
|
|
896
|
+
cached: CachedAsset;
|
|
897
|
+
finalUrl: string;
|
|
898
|
+
durationMs: number;
|
|
899
|
+
}>;
|
|
646
900
|
/** Insert an already-on-disk asset into the cache (e.g., asset just produced by adapter). */
|
|
647
901
|
registerLocal(hash: string, localPath: string, mime?: string): CachedAsset;
|
|
648
902
|
/** Total bytes across all rows (incl. pinned). */
|
|
@@ -800,68 +1054,6 @@ declare class ParseClaimController {
|
|
|
800
1054
|
}): HeartbeatHandle;
|
|
801
1055
|
}
|
|
802
1056
|
|
|
803
|
-
type PrismerUriType = 'asset' | 'file';
|
|
804
|
-
interface ParsedPrismerUri {
|
|
805
|
-
/** Original full URI string. */
|
|
806
|
-
raw: string;
|
|
807
|
-
/**
|
|
808
|
-
* Owner segment for legacy `prismer://<owner>/...` form (informational,
|
|
809
|
-
* not ACL-checked). For `prismer://workspace/<wid>/...` this is the
|
|
810
|
-
* literal string 'workspace' — prefer `workspaceId` instead.
|
|
811
|
-
*/
|
|
812
|
-
owner: string;
|
|
813
|
-
type: PrismerUriType;
|
|
814
|
-
/** For type='asset': the sha256 hash. For legacy file URIs: '<wsId>/<path>'. */
|
|
815
|
-
rest: string;
|
|
816
|
-
/** Convenience parses for type='file' and for workspace-form 'asset'. */
|
|
817
|
-
workspaceId?: string;
|
|
818
|
-
filePath?: string;
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Find every recognized `prismer://...` reference in a string.
|
|
822
|
-
* Only `asset` and `file` types are recognized — other types (memory,
|
|
823
|
-
* context, conversation, evolution, task, pair) pass through untouched.
|
|
824
|
-
*/
|
|
825
|
-
declare function parseUris(text: string): ParsedPrismerUri[];
|
|
826
|
-
interface UriResolverOptions {
|
|
827
|
-
db: LocalDb;
|
|
828
|
-
cloud: CloudClient;
|
|
829
|
-
assetCache: AssetCache;
|
|
830
|
-
}
|
|
831
|
-
declare class UriResolver {
|
|
832
|
-
private readonly db;
|
|
833
|
-
private readonly cloud;
|
|
834
|
-
private readonly assetCache;
|
|
835
|
-
constructor(opts: UriResolverOptions);
|
|
836
|
-
/**
|
|
837
|
-
* Resolve a single URI to a local file path. Throws on auth/4xx;
|
|
838
|
-
* caller decides whether to leave the URI in place (best-effort) or fail.
|
|
839
|
-
*/
|
|
840
|
-
resolveOne(uri: ParsedPrismerUri, opts?: {
|
|
841
|
-
signal?: AbortSignal;
|
|
842
|
-
}): Promise<string>;
|
|
843
|
-
/**
|
|
844
|
-
* Walk a string, replace every `prismer://(asset|file)/...` with `file://<localPath>`.
|
|
845
|
-
* Unrecognized URIs pass through. Returns rewritten text + the list of pinned hashes.
|
|
846
|
-
*/
|
|
847
|
-
rewrite(text: string, opts?: {
|
|
848
|
-
pin?: boolean;
|
|
849
|
-
signal?: AbortSignal;
|
|
850
|
-
}): Promise<{
|
|
851
|
-
text: string;
|
|
852
|
-
resolvedHashes: string[];
|
|
853
|
-
}>;
|
|
854
|
-
/** Bulk-rewrite an array of strings (e.g. context entries' content). */
|
|
855
|
-
rewriteAll(texts: string[], opts?: {
|
|
856
|
-
pin?: boolean;
|
|
857
|
-
signal?: AbortSignal;
|
|
858
|
-
}): Promise<{
|
|
859
|
-
texts: string[];
|
|
860
|
-
resolvedHashes: string[];
|
|
861
|
-
}>;
|
|
862
|
-
private lookupFile;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
1057
|
type IMAgentStatus = 'online' | 'busy' | 'idle' | 'offline';
|
|
866
1058
|
interface HostedAgentDeclaration {
|
|
867
1059
|
imUserId: string;
|
|
@@ -887,6 +1079,9 @@ interface HostAckedPayload {
|
|
|
887
1079
|
[key: string]: number;
|
|
888
1080
|
};
|
|
889
1081
|
profilesToSync: string[];
|
|
1082
|
+
/** Profile IDs the daemon declared but that no longer exist on the cloud
|
|
1083
|
+
* (soft-deleted). The daemon should remove these from its local store. */
|
|
1084
|
+
profilesToDelete: string[];
|
|
890
1085
|
}
|
|
891
1086
|
interface AgentStatusChangedPayload {
|
|
892
1087
|
agentImUserId: string;
|
|
@@ -960,15 +1155,22 @@ interface TaskDispatchProgressPayload {
|
|
|
960
1155
|
detail?: Record<string, unknown>;
|
|
961
1156
|
}
|
|
962
1157
|
/** Wave-8 W1: how the daemon handled a single AssetRef. */
|
|
963
|
-
type AssetDispatchStrategy = 'inline-text' | 'inline-text-truncated' | 'uri-only' | 'error';
|
|
1158
|
+
type AssetDispatchStrategy = 'inline-text' | 'inline-text-truncated' | 'uri-only' | 'fetched-https' | 'error';
|
|
964
1159
|
interface AssetDispatchObservation {
|
|
965
|
-
assetId
|
|
1160
|
+
/** AssetRef.assetId for cloud-attached refs; undefined for L5 https fetches. */
|
|
1161
|
+
assetId?: string;
|
|
966
1162
|
contentHash: string;
|
|
967
1163
|
mime: string | null;
|
|
968
1164
|
sizeBytes: number | null;
|
|
969
1165
|
strategy: AssetDispatchStrategy;
|
|
970
1166
|
inlinedBytes?: number;
|
|
971
1167
|
error?: string;
|
|
1168
|
+
/** L5: original URL the user wrote in the prompt. */
|
|
1169
|
+
originalUrl?: string;
|
|
1170
|
+
/** L5: post-redirect URL the body was actually downloaded from. */
|
|
1171
|
+
finalUrl?: string;
|
|
1172
|
+
/** L5: end-to-end fetch duration in ms (DNS + connect + body read). */
|
|
1173
|
+
durationMs?: number;
|
|
972
1174
|
}
|
|
973
1175
|
interface TaskDispatchReplyPayload {
|
|
974
1176
|
taskId: string;
|
|
@@ -1020,6 +1222,114 @@ interface WorkspaceFileChangedPayload {
|
|
|
1020
1222
|
contentHash?: string;
|
|
1021
1223
|
version: number;
|
|
1022
1224
|
}
|
|
1225
|
+
interface AssetChangedPayload {
|
|
1226
|
+
workspaceId: string;
|
|
1227
|
+
assetId: string;
|
|
1228
|
+
operation: 'create' | 'update' | 'delete';
|
|
1229
|
+
contentHash?: string;
|
|
1230
|
+
assetIndexSeq?: number;
|
|
1231
|
+
revision?: number;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
type PrismerUriType = 'asset' | 'file';
|
|
1235
|
+
interface ParsedPrismerUri {
|
|
1236
|
+
/** Original full URI string. */
|
|
1237
|
+
raw: string;
|
|
1238
|
+
/**
|
|
1239
|
+
* Owner segment for legacy `prismer://<owner>/...` form (informational,
|
|
1240
|
+
* not ACL-checked). For `prismer://workspace/<wid>/...` this is the
|
|
1241
|
+
* literal string 'workspace' — prefer `workspaceId` instead.
|
|
1242
|
+
*/
|
|
1243
|
+
owner: string;
|
|
1244
|
+
type: PrismerUriType;
|
|
1245
|
+
/** For type='asset': the sha256 hash. For legacy file URIs: '<wsId>/<path>'. */
|
|
1246
|
+
rest: string;
|
|
1247
|
+
/** Convenience parses for type='file' and for workspace-form 'asset'. */
|
|
1248
|
+
workspaceId?: string;
|
|
1249
|
+
filePath?: string;
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Find every recognized `prismer://...` reference in a string.
|
|
1253
|
+
* Only `asset` and `file` types are recognized — other types (memory,
|
|
1254
|
+
* context, conversation, evolution, task, pair) pass through untouched.
|
|
1255
|
+
*/
|
|
1256
|
+
declare function parseUris(text: string): ParsedPrismerUri[];
|
|
1257
|
+
interface UriResolverOptions {
|
|
1258
|
+
db: LocalDb;
|
|
1259
|
+
cloud: CloudClient;
|
|
1260
|
+
assetCache: AssetCache;
|
|
1261
|
+
}
|
|
1262
|
+
declare class UriResolver {
|
|
1263
|
+
private readonly db;
|
|
1264
|
+
private readonly cloud;
|
|
1265
|
+
private readonly assetCache;
|
|
1266
|
+
constructor(opts: UriResolverOptions);
|
|
1267
|
+
/**
|
|
1268
|
+
* Resolve a single URI to a local file path. Throws on auth/4xx;
|
|
1269
|
+
* caller decides whether to leave the URI in place (best-effort) or fail.
|
|
1270
|
+
*/
|
|
1271
|
+
resolveOne(uri: ParsedPrismerUri, opts?: {
|
|
1272
|
+
signal?: AbortSignal;
|
|
1273
|
+
}): Promise<string>;
|
|
1274
|
+
/**
|
|
1275
|
+
* Walk a string, replace every `prismer://(asset|file)/...` and
|
|
1276
|
+
* `https://…` / `http://…` URL with `file://<localPath>`.
|
|
1277
|
+
*
|
|
1278
|
+
* Unrecognized URIs pass through unchanged. Returns rewritten text, the
|
|
1279
|
+
* list of pinned hashes, and one observation per http(s) URL the resolver
|
|
1280
|
+
* attempted (success + error both surface) so the dispatch can include
|
|
1281
|
+
* them in `reply.assetObservability`.
|
|
1282
|
+
*
|
|
1283
|
+
* `urlCache` lets the caller dedupe URL fetches across multiple rewrite
|
|
1284
|
+
* calls within a single dispatch (e.g. prompt + each context entry).
|
|
1285
|
+
* Pass the same Map instance to every rewrite() / rewriteAll() call.
|
|
1286
|
+
*/
|
|
1287
|
+
rewrite(text: string, opts?: {
|
|
1288
|
+
pin?: boolean;
|
|
1289
|
+
signal?: AbortSignal;
|
|
1290
|
+
/** L5: opt out of http(s) URL fetching for this string (e.g. memory/goal text). */
|
|
1291
|
+
fetchUrls?: boolean;
|
|
1292
|
+
/** L5: shared per-dispatch dedup map (originalUrl → cached resolution). */
|
|
1293
|
+
urlCache?: Map<string, UrlResolution>;
|
|
1294
|
+
/** L5: append url observations here (caller-owned array). */
|
|
1295
|
+
urlObservations?: AssetDispatchObservation[];
|
|
1296
|
+
}): Promise<{
|
|
1297
|
+
text: string;
|
|
1298
|
+
resolvedHashes: string[];
|
|
1299
|
+
}>;
|
|
1300
|
+
/** Bulk-rewrite an array of strings (e.g. context entries' content). */
|
|
1301
|
+
rewriteAll(texts: string[], opts?: {
|
|
1302
|
+
pin?: boolean;
|
|
1303
|
+
signal?: AbortSignal;
|
|
1304
|
+
fetchUrls?: boolean;
|
|
1305
|
+
urlCache?: Map<string, UrlResolution>;
|
|
1306
|
+
urlObservations?: AssetDispatchObservation[];
|
|
1307
|
+
}): Promise<{
|
|
1308
|
+
texts: string[];
|
|
1309
|
+
resolvedHashes: string[];
|
|
1310
|
+
}>;
|
|
1311
|
+
private lookupFile;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* L5: per-dispatch resolution record for a fetched http(s) URL. The same
|
|
1315
|
+
* record is reused across every reference to the URL in this dispatch
|
|
1316
|
+
* (prompt + N context entries) so we resolve once even if the URL appears
|
|
1317
|
+
* many times.
|
|
1318
|
+
*/
|
|
1319
|
+
interface UrlResolution {
|
|
1320
|
+
hash: string;
|
|
1321
|
+
localPath: string;
|
|
1322
|
+
sizeBytes: number;
|
|
1323
|
+
mime: string | null;
|
|
1324
|
+
finalUrl: string;
|
|
1325
|
+
durationMs: number;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Extract http(s) URLs from a string. Each match has trailing punctuation
|
|
1329
|
+
* stripped so callers can replace the exact match in the source text.
|
|
1330
|
+
* Duplicates are de-duped: the first occurrence wins.
|
|
1331
|
+
*/
|
|
1332
|
+
declare function extractHttpUrls(text: string): string[];
|
|
1023
1333
|
|
|
1024
1334
|
interface OutboxWatcherOptions {
|
|
1025
1335
|
/**
|
|
@@ -1212,6 +1522,7 @@ declare class AssetMetadataIndex {
|
|
|
1212
1522
|
*/
|
|
1213
1523
|
pullDelta(opts?: {
|
|
1214
1524
|
signal?: AbortSignal;
|
|
1525
|
+
force?: boolean;
|
|
1215
1526
|
}): Promise<{
|
|
1216
1527
|
applied: number;
|
|
1217
1528
|
cursor: number;
|
|
@@ -1223,6 +1534,8 @@ declare class AssetMetadataIndex {
|
|
|
1223
1534
|
search(query: string, limit?: number): AssetMetadataRow[];
|
|
1224
1535
|
/** Exact match on filename column. Returns undefined if not indexed. */
|
|
1225
1536
|
resolveByFilename(filename: string): AssetMetadataRow | undefined;
|
|
1537
|
+
resolveByAssetId(assetId: string): AssetMetadataRow | undefined;
|
|
1538
|
+
resolveByContentHash(contentHash: string): AssetMetadataRow | undefined;
|
|
1226
1539
|
/** Batch exact match — returns Map for O(1) access. */
|
|
1227
1540
|
resolveByFilenames(filenames: string[]): Map<string, AssetMetadataRow>;
|
|
1228
1541
|
}
|
|
@@ -1268,6 +1581,101 @@ declare function handleDispatch(payload: TaskDispatchRequestPayload, requestId:
|
|
|
1268
1581
|
*/
|
|
1269
1582
|
declare function composePrompt(currentPrompt: string, context: TaskDispatchContextEntry[], maxChars: number, assetBlocks?: string[]): string;
|
|
1270
1583
|
|
|
1584
|
+
type NormalizedContent = {
|
|
1585
|
+
type: 'text';
|
|
1586
|
+
text: string;
|
|
1587
|
+
} | {
|
|
1588
|
+
type: 'image';
|
|
1589
|
+
url: string;
|
|
1590
|
+
caption?: string;
|
|
1591
|
+
} | {
|
|
1592
|
+
type: 'file';
|
|
1593
|
+
url: string;
|
|
1594
|
+
fileName: string;
|
|
1595
|
+
mime: string;
|
|
1596
|
+
} | {
|
|
1597
|
+
type: 'voice';
|
|
1598
|
+
url: string;
|
|
1599
|
+
durationMs: number;
|
|
1600
|
+
} | {
|
|
1601
|
+
type: 'video';
|
|
1602
|
+
url: string;
|
|
1603
|
+
caption?: string;
|
|
1604
|
+
};
|
|
1605
|
+
interface AgentDispatchRequest {
|
|
1606
|
+
channelAccountId: string;
|
|
1607
|
+
externalUserId: string;
|
|
1608
|
+
conversationId: string;
|
|
1609
|
+
mentionedAgentImUserId: string;
|
|
1610
|
+
messageText: string;
|
|
1611
|
+
messageId: string;
|
|
1612
|
+
attachments?: NormalizedContent[];
|
|
1613
|
+
replyToken: string;
|
|
1614
|
+
replyDeadlineMs: number;
|
|
1615
|
+
}
|
|
1616
|
+
interface AgentDispatchResponse {
|
|
1617
|
+
ok: boolean;
|
|
1618
|
+
/** ISO8601 timestamp. Required when ok=true. */
|
|
1619
|
+
acceptedAt?: string;
|
|
1620
|
+
error?: {
|
|
1621
|
+
code: string;
|
|
1622
|
+
message: string;
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
type AgentDispatchReplyStatus = 'ok' | 'agent_offline' | 'timeout' | 'agent_error';
|
|
1626
|
+
interface AgentDispatchReplyAttachment {
|
|
1627
|
+
kind: 'file' | 'image';
|
|
1628
|
+
assetId: string;
|
|
1629
|
+
}
|
|
1630
|
+
interface AgentDispatchReplyPayload {
|
|
1631
|
+
replyToken: string;
|
|
1632
|
+
conversationId: string;
|
|
1633
|
+
replyToMessageId: string;
|
|
1634
|
+
agentImUserId: string;
|
|
1635
|
+
status: AgentDispatchReplyStatus;
|
|
1636
|
+
/** Required when status='ok'. */
|
|
1637
|
+
replyText?: string;
|
|
1638
|
+
attachments?: AgentDispatchReplyAttachment[];
|
|
1639
|
+
completedAt: string;
|
|
1640
|
+
/** Required when status!='ok'. */
|
|
1641
|
+
error?: {
|
|
1642
|
+
code: string;
|
|
1643
|
+
message: string;
|
|
1644
|
+
};
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
interface MessageDispatchAgent {
|
|
1648
|
+
agentImUserId: string;
|
|
1649
|
+
dispatch(input: MessageDispatchTaskInput): Promise<TaskResult>;
|
|
1650
|
+
}
|
|
1651
|
+
interface MessageDispatchTaskInput {
|
|
1652
|
+
taskId: string;
|
|
1653
|
+
prompt: string;
|
|
1654
|
+
metadata: {
|
|
1655
|
+
source: 'external-channel';
|
|
1656
|
+
channelAccountId: string;
|
|
1657
|
+
externalUserId: string;
|
|
1658
|
+
conversationId: string;
|
|
1659
|
+
messageId: string;
|
|
1660
|
+
attachments?: AgentDispatchRequest['attachments'];
|
|
1661
|
+
};
|
|
1662
|
+
timeoutMs: number;
|
|
1663
|
+
signal: AbortSignal;
|
|
1664
|
+
}
|
|
1665
|
+
interface MessageDispatchDeps {
|
|
1666
|
+
findAgent(agentImUserId: string): Promise<MessageDispatchAgent | null> | MessageDispatchAgent | null;
|
|
1667
|
+
postReply(payload: AgentDispatchReplyPayload): Promise<void> | void;
|
|
1668
|
+
now?: () => Date;
|
|
1669
|
+
setTimeout?: typeof setTimeout;
|
|
1670
|
+
clearTimeout?: typeof clearTimeout;
|
|
1671
|
+
onError?: (err: unknown, request: AgentDispatchRequest) => void;
|
|
1672
|
+
}
|
|
1673
|
+
interface MessageDispatchHandle {
|
|
1674
|
+
response: AgentDispatchResponse;
|
|
1675
|
+
done: Promise<AgentDispatchReplyPayload>;
|
|
1676
|
+
}
|
|
1677
|
+
declare function handleAgentMessageDispatch(request: AgentDispatchRequest, deps: MessageDispatchDeps): MessageDispatchHandle;
|
|
1678
|
+
|
|
1271
1679
|
declare class ServicePool {
|
|
1272
1680
|
private readonly services;
|
|
1273
1681
|
/**
|
|
@@ -1295,6 +1703,24 @@ interface LocalServerOptions {
|
|
|
1295
1703
|
* sink; tests may pass a stub.
|
|
1296
1704
|
*/
|
|
1297
1705
|
onDispatch?: (payload: DispatchPayload, runId: string) => void;
|
|
1706
|
+
/**
|
|
1707
|
+
* Optional dependencies for POST /dispatch (Release 200 §2.6 external
|
|
1708
|
+
* message → agent dispatch). When provided, LocalServer invokes
|
|
1709
|
+
* `handleAgentMessageDispatch()` internally and returns its synchronous
|
|
1710
|
+
* AgentDispatchResponse before async reply posting completes.
|
|
1711
|
+
*/
|
|
1712
|
+
messageDispatchDeps?: MessageDispatchDeps;
|
|
1713
|
+
/**
|
|
1714
|
+
* Shared HMAC secret for Cloud → daemon POST /dispatch. Production daemons
|
|
1715
|
+
* must receive this via DISPATCH_DAEMON_SECRET or this option.
|
|
1716
|
+
*/
|
|
1717
|
+
messageDispatchSecret?: string;
|
|
1718
|
+
/**
|
|
1719
|
+
* Optional direct handler for POST /dispatch. Prefer messageDispatchDeps
|
|
1720
|
+
* for the standard daemon path; this hook exists for tests and alternate
|
|
1721
|
+
* embedders that already wrap `handleAgentMessageDispatch()`.
|
|
1722
|
+
*/
|
|
1723
|
+
messageDispatchHandler?: (payload: AgentDispatchRequest) => MessageDispatchHandle;
|
|
1298
1724
|
/**
|
|
1299
1725
|
* Install or update one hosted agent/profile in the daemon's local mirror.
|
|
1300
1726
|
* The runner persists it, reloads hostedAgents, and redeclares to cloud.
|
|
@@ -1387,6 +1813,12 @@ interface InstallAgentResult {
|
|
|
1387
1813
|
}
|
|
1388
1814
|
interface LocalServerState {
|
|
1389
1815
|
daemonId: string;
|
|
1816
|
+
/**
|
|
1817
|
+
* Daemon binary version (Release 200 §5.4). Reported in /healthz so cloud
|
|
1818
|
+
* can validate image pin and graceful-degrade against pre-2.0.0 daemons.
|
|
1819
|
+
* Sourced from the runtime package.json (see runner.ts).
|
|
1820
|
+
*/
|
|
1821
|
+
daemonVersion: string;
|
|
1390
1822
|
cloudBaseUrl?: string;
|
|
1391
1823
|
workspaceId?: string | null;
|
|
1392
1824
|
pid: number;
|
|
@@ -1400,12 +1832,46 @@ interface LocalServerState {
|
|
|
1400
1832
|
runningTaskIds: string[];
|
|
1401
1833
|
observability?: {
|
|
1402
1834
|
adapters?: Record<string, unknown>;
|
|
1835
|
+
assetSync?: Record<string, unknown>;
|
|
1403
1836
|
lastTaskError?: {
|
|
1404
1837
|
taskId: string;
|
|
1405
1838
|
message: string;
|
|
1406
1839
|
at: string;
|
|
1407
1840
|
};
|
|
1408
1841
|
};
|
|
1842
|
+
/**
|
|
1843
|
+
* Adapter-level readiness snapshot (Release 200 §5.4). One entry per
|
|
1844
|
+
* registered adapter. Cloud uses this to compute Ready-AND with the
|
|
1845
|
+
* cluster-level signals (pod Running, /healthz reachable).
|
|
1846
|
+
*/
|
|
1847
|
+
adapters?: Array<{
|
|
1848
|
+
name: string;
|
|
1849
|
+
ready: boolean;
|
|
1850
|
+
version?: string;
|
|
1851
|
+
}>;
|
|
1852
|
+
/**
|
|
1853
|
+
* Resource snapshot (Release 200 §5.4 + 08 §175). v200 baseline returns
|
|
1854
|
+
* placeholder zeros — true CPU/Mem sampling lives in S5 reconciler or a
|
|
1855
|
+
* follow-up daemon iteration. Cloud should not depend on these values for
|
|
1856
|
+
* health gating yet; they are informational.
|
|
1857
|
+
* TODO(v210): wire real cgroup / process.resourceUsage() sampling.
|
|
1858
|
+
*/
|
|
1859
|
+
resources?: {
|
|
1860
|
+
cpu: {
|
|
1861
|
+
usagePct: number;
|
|
1862
|
+
};
|
|
1863
|
+
mem: {
|
|
1864
|
+
usedBytes: number;
|
|
1865
|
+
limitBytes: number;
|
|
1866
|
+
};
|
|
1867
|
+
};
|
|
1868
|
+
/**
|
|
1869
|
+
* Final per-daemon Ready signal (Release 200 §5.4). True iff every
|
|
1870
|
+
* registered adapter reports ready=true. Cloud uses this with
|
|
1871
|
+
* `status==='ok'` to gate dispatch (graceful degrade: pre-2.0.0 daemons
|
|
1872
|
+
* that omit this field are treated as ready when status==='ok').
|
|
1873
|
+
*/
|
|
1874
|
+
readyForDispatch?: boolean;
|
|
1409
1875
|
}
|
|
1410
1876
|
declare class LocalServer {
|
|
1411
1877
|
private opts;
|
|
@@ -1438,9 +1904,19 @@ declare class LocalServer {
|
|
|
1438
1904
|
*
|
|
1439
1905
|
* Body: { workspaceId, bytes (base64), filename, mime?, path?, description?, sourceAgentImUserId? }
|
|
1440
1906
|
* Response 200: { assetId, contentHash, prismerUri }
|
|
1441
|
-
* 400 on validation failure;
|
|
1907
|
+
* 400 on body validation failure; 422 on agent-output policy rejection;
|
|
1908
|
+
* 502 on cloud upstream failure; 501 if no sink wired.
|
|
1442
1909
|
*/
|
|
1443
1910
|
private handleAssetWrite;
|
|
1911
|
+
/**
|
|
1912
|
+
* POST /dispatch — external channel message → hosted agent dispatch.
|
|
1913
|
+
*
|
|
1914
|
+
* Cloud calls this with AgentDispatchRequest (Release 200 §2.6). The daemon
|
|
1915
|
+
* returns AgentDispatchResponse immediately, while the handler's `done`
|
|
1916
|
+
* promise completes later by posting AgentDispatchReplyPayload back to cloud.
|
|
1917
|
+
*/
|
|
1918
|
+
private handleMessageDispatch;
|
|
1919
|
+
private resolveMessageDispatchHandler;
|
|
1444
1920
|
/**
|
|
1445
1921
|
* POST /v1/runs — dispatch ack-only (Cloud 3 S3 Phase 1).
|
|
1446
1922
|
*
|
|
@@ -1487,6 +1963,15 @@ declare class Runner extends EventEmitter {
|
|
|
1487
1963
|
private outboxWatcher?;
|
|
1488
1964
|
private memoryWiring?;
|
|
1489
1965
|
private assetMetadataIndexes;
|
|
1966
|
+
private workspaceMirrors;
|
|
1967
|
+
private assetOriginOutbox?;
|
|
1968
|
+
private dropFolderAdapter?;
|
|
1969
|
+
private dropFolderUploadRunner?;
|
|
1970
|
+
private dropFolderTimer?;
|
|
1971
|
+
private dropFolderWorkspaceId;
|
|
1972
|
+
private dropFolderWorkspaceDir;
|
|
1973
|
+
private dropFolderTickInFlight;
|
|
1974
|
+
private readonly dropFolderStable;
|
|
1490
1975
|
private state;
|
|
1491
1976
|
private startedAt;
|
|
1492
1977
|
private workspaceId;
|
|
@@ -1507,12 +1992,52 @@ declare class Runner extends EventEmitter {
|
|
|
1507
1992
|
*/
|
|
1508
1993
|
private runShellCommand;
|
|
1509
1994
|
snapshotState(): LocalServerState;
|
|
1995
|
+
/**
|
|
1996
|
+
* Per-adapter readiness snapshot for /healthz (Release 200 §5.4).
|
|
1997
|
+
*
|
|
1998
|
+
* We synthesize this from the AdapterRegistry rather than asking each
|
|
1999
|
+
* adapter to expose a per-call health probe — calling adapter.health()
|
|
2000
|
+
* on every /healthz hit would spawn subprocess probes and slow the
|
|
2001
|
+
* cloud-side handshake. Registered adapters are considered ready;
|
|
2002
|
+
* future iteration can flip individual entries to ready=false based on
|
|
2003
|
+
* cached ensureService / dispatch failures.
|
|
2004
|
+
*/
|
|
2005
|
+
private snapshotAdapterReadiness;
|
|
2006
|
+
/**
|
|
2007
|
+
* Release 200 T11 — cgroup v2 resource sampling for /healthz.resources.
|
|
2008
|
+
*
|
|
2009
|
+
* Reads `memory.current` / `memory.max` (best-effort, single-shot) and
|
|
2010
|
+
* derives `cpu.usagePct` by diffing `cpu.stat::usage_usec` against a
|
|
2011
|
+
* baseline cached in module state. The very first call after process
|
|
2012
|
+
* start always reports 0% CPU (no baseline yet); subsequent calls
|
|
2013
|
+
* reflect wall-clock usage between probes.
|
|
2014
|
+
*
|
|
2015
|
+
* Graceful degrade: when `/sys/fs/cgroup/` is absent (mac dev host,
|
|
2016
|
+
* Kubernetes-pre-cgroup-v2 distros), all fields are returned as zero
|
|
2017
|
+
* — callers must treat sampler output as advisory, not authoritative.
|
|
2018
|
+
*/
|
|
2019
|
+
private cpuBaseline;
|
|
2020
|
+
private sampleCgroupResources;
|
|
2021
|
+
/**
|
|
2022
|
+
* Resolve daemon binary version from runtime package.json. Cached after
|
|
2023
|
+
* first resolution; falls back to constructor override → '0.0.0'.
|
|
2024
|
+
*
|
|
2025
|
+
* The path probe walks `../package.json` first (which matches the layout
|
|
2026
|
+
* produced by `tsup` — dist/runner.js sits one level inside the package)
|
|
2027
|
+
* and then `../../package.json` (source-tree layout, where this file
|
|
2028
|
+
* lives in src/daemon/runner.ts). Either path resolves to the same
|
|
2029
|
+
* runtime package.json depending on whether the runner is executing
|
|
2030
|
+
* from a build or directly under tsx in tests.
|
|
2031
|
+
*/
|
|
2032
|
+
private cachedDaemonVersion;
|
|
2033
|
+
private resolveDaemonVersion;
|
|
1510
2034
|
/**
|
|
1511
2035
|
* Re-read the local `agents` table (populated by `prismer agent register`)
|
|
1512
2036
|
* and re-populate `hostedAgents` map. Profiles per agent come from local
|
|
1513
2037
|
* `agent_profiles` table (filled by host.acked sync).
|
|
1514
2038
|
*/
|
|
1515
2039
|
loadAgentsFromDb(): void;
|
|
2040
|
+
private prepareLocalProfiles;
|
|
1516
2041
|
/**
|
|
1517
2042
|
* Register an in-process AgentProfile snapshot (called by agent CLI / sync layer).
|
|
1518
2043
|
* Used to populate the `agents` list in agent.host.declare.
|
|
@@ -1535,6 +2060,8 @@ declare class Runner extends EventEmitter {
|
|
|
1535
2060
|
private onHostAcked;
|
|
1536
2061
|
private onTaskDispatch;
|
|
1537
2062
|
private onTaskCancel;
|
|
2063
|
+
private findMessageDispatchAgent;
|
|
2064
|
+
private postMessageDispatchReply;
|
|
1538
2065
|
private onAgentChanged;
|
|
1539
2066
|
private onAgentProfileChanged;
|
|
1540
2067
|
private syncProfileFromCloud;
|
|
@@ -1543,12 +2070,31 @@ declare class Runner extends EventEmitter {
|
|
|
1543
2070
|
private onAssetChanged;
|
|
1544
2071
|
private onWorkspaceFileChanged;
|
|
1545
2072
|
private snapshotAdapterObservability;
|
|
2073
|
+
private snapshotAssetSyncObservability;
|
|
1546
2074
|
/**
|
|
1547
2075
|
* Ensure an AssetMetadataIndex exists for the given workspace and pull
|
|
1548
2076
|
* delta from cloud. Idempotent — creates the index on first call, reuses
|
|
1549
2077
|
* it on subsequent calls. Same cursor-catch-up semantics as WorkspaceMirror.
|
|
1550
2078
|
*/
|
|
1551
2079
|
private syncAssetMetadata;
|
|
2080
|
+
/**
|
|
2081
|
+
* Ensure a WorkspaceMirror exists for the workspace and pull path→asset
|
|
2082
|
+
* bindings from cloud. Cold-start daemons previously only had this table
|
|
2083
|
+
* populated by WS push or per-path URI fallback, so local asset state looked
|
|
2084
|
+
* empty even though cloud files existed.
|
|
2085
|
+
*/
|
|
2086
|
+
private syncWorkspaceFiles;
|
|
2087
|
+
private syncAssetState;
|
|
2088
|
+
/**
|
|
2089
|
+
* Desktop asset ingress: watch a user-visible local asset folder
|
|
2090
|
+
* and upload new files as IMAssets, preserving nested relative dirs in
|
|
2091
|
+
* IMAsset.folderPath. The lower-level adapter/outbox/uploader already
|
|
2092
|
+
* existed; this method wires them into the real daemon lifecycle.
|
|
2093
|
+
*/
|
|
2094
|
+
private ensureDropFolderRuntime;
|
|
2095
|
+
private stopDropFolderRuntime;
|
|
2096
|
+
private runDropFolderTick;
|
|
2097
|
+
private isDropFolderObservationStable;
|
|
1552
2098
|
/**
|
|
1553
2099
|
* SyncWorker FlushFn — pushes local writes to cloud.
|
|
1554
2100
|
*
|
|
@@ -1646,29 +2192,29 @@ declare const CCConfigSchema: z.ZodObject<{
|
|
|
1646
2192
|
cwd: string;
|
|
1647
2193
|
maxTurns: number;
|
|
1648
2194
|
route: "default" | "prismer" | "omniroute";
|
|
1649
|
-
systemPrompt?: string | undefined;
|
|
1650
|
-
allowedTools?: string[] | undefined;
|
|
1651
|
-
envVars?: Record<string, string> | undefined;
|
|
1652
2195
|
mcpServers?: {
|
|
1653
2196
|
name: string;
|
|
1654
2197
|
command: string;
|
|
1655
2198
|
env?: Record<string, string> | undefined;
|
|
1656
2199
|
args?: string[] | undefined;
|
|
1657
2200
|
}[] | undefined;
|
|
2201
|
+
systemPrompt?: string | undefined;
|
|
2202
|
+
allowedTools?: string[] | undefined;
|
|
2203
|
+
envVars?: Record<string, string> | undefined;
|
|
1658
2204
|
baseURL?: string | undefined;
|
|
1659
2205
|
apiKeyRef?: string | undefined;
|
|
1660
2206
|
}, {
|
|
1661
2207
|
cwd: string;
|
|
1662
2208
|
model?: string | undefined;
|
|
1663
|
-
systemPrompt?: string | undefined;
|
|
1664
|
-
allowedTools?: string[] | undefined;
|
|
1665
|
-
envVars?: Record<string, string> | undefined;
|
|
1666
2209
|
mcpServers?: {
|
|
1667
2210
|
name: string;
|
|
1668
2211
|
command: string;
|
|
1669
2212
|
env?: Record<string, string> | undefined;
|
|
1670
2213
|
args?: string[] | undefined;
|
|
1671
2214
|
}[] | undefined;
|
|
2215
|
+
systemPrompt?: string | undefined;
|
|
2216
|
+
allowedTools?: string[] | undefined;
|
|
2217
|
+
envVars?: Record<string, string> | undefined;
|
|
1672
2218
|
maxTurns?: number | undefined;
|
|
1673
2219
|
baseURL?: string | undefined;
|
|
1674
2220
|
apiKeyRef?: string | undefined;
|
|
@@ -1729,4 +2275,4 @@ declare const codexAdapter: AdapterDef;
|
|
|
1729
2275
|
declare function buildProgram(): Command;
|
|
1730
2276
|
declare function runCli(argv?: string[]): Promise<void>;
|
|
1731
2277
|
|
|
1732
|
-
export { type AcquireResult, type AdapterDef, type AdapterKind, AdapterRegistry, type AdapterService, type AgentChangedPayload, type AgentHostDeclarePayload, type AgentProfile, type AgentProfileChangedPayload, type AgentStatusChangedPayload, AssetCache, type AssetCacheOptions, type AssetDispatchObservation, type AssetDispatchStrategy, type AssetRef, BUILTIN_ROLE_TEMPLATES, type CachedAsset, type ClaudeCodeConfig, CloudClient, type CloudClientOptions, CloudError, type CloudResponse, type CodexConfig, type Config, type ConfigPaths, ConfigSchema, type DispatchDeps, type Envelope, type FlushFn, type FlushResult, type HealthStatus, type HermesProfileConfig, type HostAckedPayload, type HostedAgentDeclaration, type IMAgentStatus, type IMWSMessage, type LocalDb, LocalServer, type LocalServerOptions, type LocalServerState, type PairOptions, type PairResult, type ParseClaim, ParseClaimController, type ParseClaimControllerOptions, type ParsedPrismerUri, type PrismerUriType, type RoleTemplate, Runner, type RunnerOptions, ServicePool, type SyncOperation, SyncQueue, type SyncQueueRow, type SyncResourceType, type SyncStatus, SyncWorker, type SyncWorkerOptions, TARGET_SCHEMA_VERSION, type TaskCancelPayload, type TaskDispatchContextEntry, type TaskDispatchProgressPayload, type TaskDispatchReplyPayload, type TaskDispatchRequestPayload, type TaskInput, type TaskResult, UriResolver, type UriResolverOptions, type ValidationResult, WS_CLOSE, type WorkspaceChangedPayload, type WorkspaceFileBinding, type WorkspaceFileChangedPayload, WorkspaceMirror, type WorkspaceMirrorOptions, WsClient, type WsClientOptions, buildProgram, claudeCodeAdapter, codexAdapter, composePrompt, configExists, currentSchemaVersion, deriveWsUrl, envelope, getRoleTemplate, handleDispatch, hermesAdapter, isDaemonId, listRoleTemplates, loadConfig, newDaemonId, nextBackoffMs, openLocalDb, pair, parseCodexOutput, parseUris, resolvePaths, runCli, runMigrations, saveConfig };
|
|
2278
|
+
export { type AcquireResult, type AdapterDef, type AdapterKind, AdapterRegistry, type AdapterService, type AgentChangedPayload, type AgentDispatchReplyAttachment, type AgentDispatchReplyPayload, type AgentDispatchReplyStatus, type AgentDispatchRequest, type AgentDispatchResponse, type AgentHostDeclarePayload, type AgentProfile, type AgentProfileChangedPayload, type AgentStatusChangedPayload, AssetCache, type AssetCacheOptions, type AssetChangedPayload, type AssetDispatchObservation, type AssetDispatchStrategy, type AssetRef, BUILTIN_ROLE_TEMPLATES, type CachedAsset, type ClaudeCodeConfig, CloudClient, type CloudClientOptions, CloudError, type CloudResponse, type CodexConfig, type Config, type ConfigPaths, ConfigSchema, type DispatchDeps, type Envelope, type FlushFn, type FlushResult, type HealthStatus, type HermesProfileConfig, type HostAckedPayload, type HostedAgentDeclaration, type IMAgentStatus, type IMWSMessage, type LocalDb, LocalServer, type LocalServerOptions, type LocalServerState, type MessageDispatchAgent, type MessageDispatchDeps, type MessageDispatchHandle, type MessageDispatchTaskInput, type NormalizedContent, type OpenClawProfileConfig, type PairOptions, type PairResult, type ParseClaim, ParseClaimController, type ParseClaimControllerOptions, type ParsedPrismerUri, type PrismerUriType, type RoleTemplate, Runner, type RunnerOptions, ServicePool, type SyncOperation, SyncQueue, type SyncQueueRow, type SyncResourceType, type SyncStatus, SyncWorker, type SyncWorkerOptions, TARGET_SCHEMA_VERSION, type TaskCancelPayload, type TaskDispatchContextEntry, type TaskDispatchProgressPayload, type TaskDispatchReplyPayload, type TaskDispatchRequestPayload, type TaskInput, type TaskResult, UriResolver, type UriResolverOptions, type UrlResolution, type ValidationResult, WS_CLOSE, type WorkspaceChangedPayload, type WorkspaceFileBinding, type WorkspaceFileChangedPayload, WorkspaceMirror, type WorkspaceMirrorOptions, WsClient, type WsClientOptions, buildProgram, claudeCodeAdapter, codexAdapter, composePrompt, configExists, currentSchemaVersion, deriveWsUrl, envelope, extractHttpUrls, getRoleTemplate, handleAgentMessageDispatch, handleDispatch, hermesAdapter, isDaemonId, listRoleTemplates, loadConfig, newDaemonId, nextBackoffMs, openLocalDb, openclawAdapter, pair, parseCodexOutput, parseUris, resolvePaths, runCli, runMigrations, saveConfig };
|