@cuylabs/agent-core 5.4.0 → 5.6.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/dist/agent/chat-loop/loop.d.ts.map +1 -1
- package/dist/agent/chat-loop/model-step-runner.d.ts +2 -0
- package/dist/agent/chat-loop/model-step-runner.d.ts.map +1 -1
- package/dist/{chunk-JZRLCTSD.js → chunk-2BRLPF3Z.js} +73 -2
- package/dist/{chunk-VT5FSYA2.js → chunk-NICU5N2S.js} +105 -14
- package/dist/{chunk-35A3XLI4.js → chunk-SJCAIWLZ.js} +23 -4
- package/dist/{chunk-MO7V4H4A.js → chunk-ZETYNQ35.js} +296 -16
- package/dist/dispatch/event-store.d.ts +15 -0
- package/dist/dispatch/event-store.d.ts.map +1 -0
- package/dist/dispatch/executor.d.ts.map +1 -1
- package/dist/dispatch/index.d.ts +2 -1
- package/dist/dispatch/index.d.ts.map +1 -1
- package/dist/dispatch/index.js +4 -2
- package/dist/dispatch/runtime.d.ts.map +1 -1
- package/dist/dispatch/tool-factories.d.ts.map +1 -1
- package/dist/dispatch/types.d.ts +68 -0
- package/dist/dispatch/types.d.ts.map +1 -1
- package/dist/execution/index.js +1 -1
- package/dist/execution/turn/index.d.ts +2 -2
- package/dist/execution/turn/index.d.ts.map +1 -1
- package/dist/execution/turn/index.js +3 -1
- package/dist/execution/turn/runner/index.d.ts +2 -0
- package/dist/execution/turn/runner/index.d.ts.map +1 -1
- package/dist/execution/turn/runner/live-events.d.ts +11 -0
- package/dist/execution/turn/runner/live-events.d.ts.map +1 -0
- package/dist/execution/turn/runner/stream-step.d.ts.map +1 -1
- package/dist/execution/turn/runner/tool-batch.d.ts.map +1 -1
- package/dist/execution/turn/runner/types.d.ts +4 -0
- package/dist/execution/turn/runner/types.d.ts.map +1 -1
- package/dist/index.js +57 -8
- package/dist/subagents/index.js +2 -2
- package/dist/subagents/results.d.ts.map +1 -1
- package/dist/subagents/roles/markdown-profile.d.ts.map +1 -1
- package/dist/subagents/tool-factories.d.ts.map +1 -1
- package/dist/team/coordinator/types.d.ts +2 -0
- package/dist/team/coordinator/types.d.ts.map +1 -1
- package/dist/types/events.d.ts +32 -1
- package/dist/types/events.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -236,15 +236,19 @@ Use \`check_dispatch\` to monitor progress after starting.`,
|
|
|
236
236
|
),
|
|
237
237
|
brief: z.string().describe("Detailed instructions for the dispatch target."),
|
|
238
238
|
title: z.string().optional().describe("Short title for tracking."),
|
|
239
|
-
parentSessionId: z.string().optional().describe("Parent session ID for context linking.")
|
|
239
|
+
parentSessionId: z.string().optional().describe("Parent session ID for context linking."),
|
|
240
|
+
parentTurnId: z.string().optional().describe("Parent turn ID for context linking.")
|
|
240
241
|
}),
|
|
241
|
-
execute: async (params) => {
|
|
242
|
+
execute: async (params, ctx) => {
|
|
242
243
|
try {
|
|
243
244
|
const record = await runtime.start({
|
|
244
245
|
targetType: params.targetType,
|
|
245
246
|
brief: params.brief,
|
|
246
247
|
title: params.title,
|
|
247
|
-
parentSessionId: params.parentSessionId
|
|
248
|
+
parentSessionId: params.parentSessionId ?? ctx.sessionID,
|
|
249
|
+
parentTurnId: params.parentTurnId ?? ctx.turnID,
|
|
250
|
+
abort: ctx.abort,
|
|
251
|
+
emitEvent: ctx.emitEvent
|
|
248
252
|
});
|
|
249
253
|
return formatDispatchStarted(record);
|
|
250
254
|
} catch (error) {
|
|
@@ -320,14 +324,16 @@ function createDispatchListTool(runtime) {
|
|
|
320
324
|
'Filter by status: "running", "completed", "failed", "cancelled".'
|
|
321
325
|
),
|
|
322
326
|
targetType: z.string().optional().describe("Filter by target type."),
|
|
323
|
-
parentSessionId: z.string().optional().describe("Filter by parent session.")
|
|
327
|
+
parentSessionId: z.string().optional().describe("Filter by parent session."),
|
|
328
|
+
parentTurnId: z.string().optional().describe("Filter by parent turn.")
|
|
324
329
|
}),
|
|
325
330
|
execute: async (params) => {
|
|
326
331
|
try {
|
|
327
332
|
const records = await runtime.list({
|
|
328
333
|
status: params.status,
|
|
329
334
|
targetType: params.targetType,
|
|
330
|
-
parentSessionId: params.parentSessionId
|
|
335
|
+
parentSessionId: params.parentSessionId,
|
|
336
|
+
parentTurnId: params.parentTurnId
|
|
331
337
|
});
|
|
332
338
|
return formatDispatchList(records);
|
|
333
339
|
} catch (error) {
|
|
@@ -350,6 +356,167 @@ function createDispatchTools(runtime) {
|
|
|
350
356
|
|
|
351
357
|
// src/dispatch/runtime.ts
|
|
352
358
|
import { randomUUID } from "crypto";
|
|
359
|
+
var EMPTY_DISPATCH_USAGE = {
|
|
360
|
+
inputTokens: 0,
|
|
361
|
+
outputTokens: 0,
|
|
362
|
+
totalTokens: 0
|
|
363
|
+
};
|
|
364
|
+
function dispatchEventContext(record) {
|
|
365
|
+
return {
|
|
366
|
+
dispatchId: record.id,
|
|
367
|
+
role: record.targetType,
|
|
368
|
+
title: record.title,
|
|
369
|
+
parentSessionId: record.parentSessionId,
|
|
370
|
+
parentTurnId: record.parentTurnId,
|
|
371
|
+
parentDispatchId: record.parentDispatchId,
|
|
372
|
+
depth: record.depth,
|
|
373
|
+
agentPath: record.agentPath,
|
|
374
|
+
childSessionId: record.sessionId,
|
|
375
|
+
executionId: record.executionId
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
async function emitDispatchProgress(emitEvent, event) {
|
|
379
|
+
if (!emitEvent) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
await emitEvent(event);
|
|
384
|
+
} catch {
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
async function appendDispatchEvent(options) {
|
|
388
|
+
if (!options.eventStore) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
await options.eventStore.append({
|
|
393
|
+
dispatchId: options.record.id,
|
|
394
|
+
targetType: options.record.targetType,
|
|
395
|
+
title: options.record.title,
|
|
396
|
+
parentSessionId: options.record.parentSessionId,
|
|
397
|
+
parentTurnId: options.record.parentTurnId,
|
|
398
|
+
parentDispatchId: options.record.parentDispatchId,
|
|
399
|
+
depth: options.record.depth,
|
|
400
|
+
agentPath: options.record.agentPath,
|
|
401
|
+
childSessionId: options.record.sessionId,
|
|
402
|
+
executionId: options.record.executionId,
|
|
403
|
+
createdAt: options.now(),
|
|
404
|
+
event: options.event
|
|
405
|
+
});
|
|
406
|
+
} catch {
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
async function publishDispatchProgress(options) {
|
|
410
|
+
await appendDispatchEvent({
|
|
411
|
+
eventStore: options.eventStore,
|
|
412
|
+
record: options.record,
|
|
413
|
+
event: options.event,
|
|
414
|
+
now: options.now
|
|
415
|
+
});
|
|
416
|
+
await emitDispatchProgress(options.emitEvent, options.event);
|
|
417
|
+
}
|
|
418
|
+
function shouldForwardChildEvent(event) {
|
|
419
|
+
switch (event.type) {
|
|
420
|
+
case "status":
|
|
421
|
+
case "tool-start":
|
|
422
|
+
case "tool-result":
|
|
423
|
+
case "tool-error":
|
|
424
|
+
case "approval-request":
|
|
425
|
+
case "approval-resolved":
|
|
426
|
+
case "human-input-request":
|
|
427
|
+
case "human-input-resolved":
|
|
428
|
+
case "error":
|
|
429
|
+
return true;
|
|
430
|
+
default:
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function isSubAgentProgressEvent(event) {
|
|
435
|
+
switch (event.type) {
|
|
436
|
+
case "subagent-start":
|
|
437
|
+
case "subagent-event":
|
|
438
|
+
case "subagent-complete":
|
|
439
|
+
case "subagent-error":
|
|
440
|
+
return true;
|
|
441
|
+
default:
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function joinDispatchAgentPath(parentAgentPath, dispatchId) {
|
|
446
|
+
const parent = parentAgentPath?.replace(/\/+$/g, "") ?? "";
|
|
447
|
+
const child = dispatchId.replace(/^\/+/g, "");
|
|
448
|
+
return parent ? `${parent}/${child}` : child;
|
|
449
|
+
}
|
|
450
|
+
async function cancelRunningChildDispatches(runtime, reason) {
|
|
451
|
+
if (!runtime) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const running = await runtime.list({ status: "running" });
|
|
455
|
+
await Promise.all(
|
|
456
|
+
running.map(async (record) => {
|
|
457
|
+
try {
|
|
458
|
+
await runtime.cancel(record.id, reason);
|
|
459
|
+
} catch {
|
|
460
|
+
}
|
|
461
|
+
})
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
async function runChildDispatchWithProgress(options) {
|
|
465
|
+
let response = "";
|
|
466
|
+
let usage = EMPTY_DISPATCH_USAGE;
|
|
467
|
+
const toolCalls = [];
|
|
468
|
+
const context = dispatchEventContext(options.record);
|
|
469
|
+
for await (const event of options.child.chat(
|
|
470
|
+
options.sessionId,
|
|
471
|
+
options.message,
|
|
472
|
+
{
|
|
473
|
+
abort: options.abort
|
|
474
|
+
}
|
|
475
|
+
)) {
|
|
476
|
+
if (isSubAgentProgressEvent(event)) {
|
|
477
|
+
await emitDispatchProgress(options.emitEvent, event);
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (shouldForwardChildEvent(event)) {
|
|
481
|
+
await publishDispatchProgress({
|
|
482
|
+
eventStore: options.eventStore,
|
|
483
|
+
record: options.record,
|
|
484
|
+
now: options.now,
|
|
485
|
+
emitEvent: options.emitEvent,
|
|
486
|
+
event: {
|
|
487
|
+
type: "subagent-event",
|
|
488
|
+
...context,
|
|
489
|
+
event
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
switch (event.type) {
|
|
494
|
+
case "text-delta":
|
|
495
|
+
response += event.text;
|
|
496
|
+
break;
|
|
497
|
+
case "tool-result":
|
|
498
|
+
toolCalls.push({ name: event.toolName, result: event.result });
|
|
499
|
+
break;
|
|
500
|
+
case "complete":
|
|
501
|
+
if (event.usage) {
|
|
502
|
+
usage = {
|
|
503
|
+
inputTokens: event.usage.inputTokens ?? 0,
|
|
504
|
+
outputTokens: event.usage.outputTokens ?? 0,
|
|
505
|
+
totalTokens: event.usage.totalTokens ?? 0
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
if (event.output !== void 0) {
|
|
509
|
+
response = event.output;
|
|
510
|
+
}
|
|
511
|
+
break;
|
|
512
|
+
case "error":
|
|
513
|
+
throw event.error;
|
|
514
|
+
default:
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return { response, usage, toolCalls };
|
|
519
|
+
}
|
|
353
520
|
function allowsFurtherDispatch(role) {
|
|
354
521
|
return role.allowFurtherDispatch ?? false;
|
|
355
522
|
}
|
|
@@ -415,6 +582,9 @@ function buildRoleChild(parent, role) {
|
|
|
415
582
|
if (role.model) {
|
|
416
583
|
forkOptions.model = role.model;
|
|
417
584
|
}
|
|
585
|
+
if (role.reasoningLevel) {
|
|
586
|
+
forkOptions.reasoningLevel = role.reasoningLevel;
|
|
587
|
+
}
|
|
418
588
|
if (role.maxSteps) {
|
|
419
589
|
forkOptions.maxSteps = role.maxSteps;
|
|
420
590
|
}
|
|
@@ -434,39 +604,46 @@ function createLocalDispatchRuntime(options) {
|
|
|
434
604
|
maxConcurrent = DEFAULT_LOCAL_DISPATCH_CONCURRENCY,
|
|
435
605
|
maxDepth = DEFAULT_LOCAL_DISPATCH_DEPTH,
|
|
436
606
|
currentDepth = 0,
|
|
607
|
+
parentDispatchId: runtimeParentDispatchId,
|
|
608
|
+
parentAgentPath,
|
|
437
609
|
sessionTitlePrefix = DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX,
|
|
438
610
|
now = () => (/* @__PURE__ */ new Date()).toISOString(),
|
|
439
611
|
createId = () => randomUUID(),
|
|
440
612
|
childToolIds = DEFAULT_DISPATCH_TOOL_IDS,
|
|
441
613
|
createChildTools = createDispatchTools,
|
|
442
|
-
buildChild: customBuildChild
|
|
614
|
+
buildChild: customBuildChild,
|
|
615
|
+
eventStore
|
|
443
616
|
} = options;
|
|
444
617
|
const dispatches = /* @__PURE__ */ new Map();
|
|
445
618
|
const roleIndex = new Map(roles.map((role) => [role.name, role]));
|
|
446
|
-
function buildChild(role) {
|
|
619
|
+
function buildChild(role, scope) {
|
|
447
620
|
const child = customBuildChild ? customBuildChild(parent, role) : buildRoleChild(parent, role);
|
|
448
621
|
for (const toolId of childToolIds) {
|
|
449
622
|
child.removeTool?.(toolId);
|
|
450
623
|
}
|
|
451
|
-
if (allowsFurtherDispatch(role) &&
|
|
624
|
+
if (allowsFurtherDispatch(role) && scope.childDepth < maxDepth) {
|
|
452
625
|
const childRuntime = createLocalDispatchRuntime({
|
|
453
626
|
parent: child,
|
|
454
627
|
roles,
|
|
455
628
|
maxConcurrent,
|
|
456
629
|
maxDepth,
|
|
457
|
-
currentDepth:
|
|
630
|
+
currentDepth: scope.childDepth,
|
|
631
|
+
parentDispatchId: scope.parentDispatchId,
|
|
632
|
+
parentAgentPath: scope.parentAgentPath,
|
|
458
633
|
sessionTitlePrefix,
|
|
459
634
|
now,
|
|
460
635
|
createId,
|
|
461
636
|
childToolIds,
|
|
462
637
|
createChildTools,
|
|
463
|
-
buildChild: customBuildChild
|
|
638
|
+
buildChild: customBuildChild,
|
|
639
|
+
eventStore
|
|
464
640
|
});
|
|
465
641
|
for (const tool of createChildTools(childRuntime)) {
|
|
466
642
|
child.addTool(tool);
|
|
467
643
|
}
|
|
644
|
+
return { child, childRuntime };
|
|
468
645
|
}
|
|
469
|
-
return child;
|
|
646
|
+
return { child };
|
|
470
647
|
}
|
|
471
648
|
function describeTargets() {
|
|
472
649
|
return roles.map((role) => ({
|
|
@@ -495,10 +672,17 @@ function createLocalDispatchRuntime(options) {
|
|
|
495
672
|
);
|
|
496
673
|
}
|
|
497
674
|
const id = createId();
|
|
498
|
-
const child = buildChild(role);
|
|
499
675
|
const abort = new AbortController();
|
|
500
676
|
const timestamp = now();
|
|
501
677
|
const title = input.title ?? `${sessionTitlePrefix}: ${role.name}`;
|
|
678
|
+
const depth = input.depth ?? currentDepth;
|
|
679
|
+
const parentDispatchId = input.parentDispatchId ?? runtimeParentDispatchId;
|
|
680
|
+
const agentPath = input.agentPath ?? joinDispatchAgentPath(parentAgentPath, id);
|
|
681
|
+
const { child, childRuntime } = buildChild(role, {
|
|
682
|
+
parentDispatchId: id,
|
|
683
|
+
parentAgentPath: agentPath,
|
|
684
|
+
childDepth: depth + 1
|
|
685
|
+
});
|
|
502
686
|
if (input.abort) {
|
|
503
687
|
if (input.abort.aborted) {
|
|
504
688
|
abort.abort(input.abort.reason);
|
|
@@ -525,13 +709,40 @@ function createLocalDispatchRuntime(options) {
|
|
|
525
709
|
createdAt: timestamp,
|
|
526
710
|
updatedAt: timestamp,
|
|
527
711
|
parentSessionId: input.parentSessionId,
|
|
712
|
+
parentTurnId: input.parentTurnId,
|
|
713
|
+
parentDispatchId,
|
|
714
|
+
depth,
|
|
715
|
+
agentPath,
|
|
528
716
|
sessionId,
|
|
529
717
|
executionId: id,
|
|
530
718
|
redirectCount: 0
|
|
531
719
|
};
|
|
532
720
|
const promise = (async () => {
|
|
533
721
|
try {
|
|
534
|
-
const
|
|
722
|
+
const shouldCaptureProgress = Boolean(input.emitEvent || eventStore);
|
|
723
|
+
const startEvent = {
|
|
724
|
+
type: "subagent-start",
|
|
725
|
+
...dispatchEventContext(record)
|
|
726
|
+
};
|
|
727
|
+
if (shouldCaptureProgress) {
|
|
728
|
+
await publishDispatchProgress({
|
|
729
|
+
eventStore,
|
|
730
|
+
record,
|
|
731
|
+
event: startEvent,
|
|
732
|
+
now,
|
|
733
|
+
emitEvent: input.emitEvent
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
const result = shouldCaptureProgress ? await runChildDispatchWithProgress({
|
|
737
|
+
child,
|
|
738
|
+
sessionId,
|
|
739
|
+
message: input.brief,
|
|
740
|
+
abort: abort.signal,
|
|
741
|
+
record,
|
|
742
|
+
eventStore,
|
|
743
|
+
now,
|
|
744
|
+
...input.emitEvent ? { emitEvent: input.emitEvent } : {}
|
|
745
|
+
}) : await child.send(sessionId, input.brief, {
|
|
535
746
|
abort: abort.signal
|
|
536
747
|
});
|
|
537
748
|
const active = dispatches.get(id);
|
|
@@ -547,21 +758,58 @@ function createLocalDispatchRuntime(options) {
|
|
|
547
758
|
},
|
|
548
759
|
toolCalls: result.toolCalls ?? []
|
|
549
760
|
};
|
|
761
|
+
if (shouldCaptureProgress) {
|
|
762
|
+
await publishDispatchProgress({
|
|
763
|
+
eventStore,
|
|
764
|
+
record: active.record,
|
|
765
|
+
now,
|
|
766
|
+
emitEvent: input.emitEvent,
|
|
767
|
+
event: {
|
|
768
|
+
type: "subagent-complete",
|
|
769
|
+
...dispatchEventContext(active.record),
|
|
770
|
+
output: active.record.result.response,
|
|
771
|
+
usage: active.record.result.usage,
|
|
772
|
+
toolCalls: active.record.result.toolCalls
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
}
|
|
550
776
|
}
|
|
551
777
|
} catch (error) {
|
|
552
778
|
const active = dispatches.get(id);
|
|
553
779
|
if (active && active.record.status === "running") {
|
|
554
780
|
if (abort.signal.aborted) {
|
|
555
781
|
active.record.status = "cancelled";
|
|
782
|
+
active.record.error = String(abort.signal.reason ?? "Cancelled");
|
|
556
783
|
} else {
|
|
557
784
|
active.record.status = "failed";
|
|
558
785
|
active.record.error = error instanceof Error ? error.message : String(error);
|
|
559
786
|
}
|
|
560
787
|
active.record.updatedAt = now();
|
|
788
|
+
if (input.emitEvent || eventStore) {
|
|
789
|
+
await publishDispatchProgress({
|
|
790
|
+
eventStore,
|
|
791
|
+
record: active.record,
|
|
792
|
+
now,
|
|
793
|
+
emitEvent: input.emitEvent,
|
|
794
|
+
event: {
|
|
795
|
+
type: "subagent-error",
|
|
796
|
+
...dispatchEventContext(active.record),
|
|
797
|
+
status: active.record.status,
|
|
798
|
+
error: active.record.error ?? active.record.status
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
}
|
|
561
802
|
}
|
|
562
803
|
}
|
|
563
804
|
})();
|
|
564
|
-
dispatches.set(id, {
|
|
805
|
+
dispatches.set(id, {
|
|
806
|
+
record,
|
|
807
|
+
child,
|
|
808
|
+
...childRuntime ? { childRuntime } : {},
|
|
809
|
+
abort,
|
|
810
|
+
promise,
|
|
811
|
+
...input.emitEvent ? { emitEvent: input.emitEvent } : {}
|
|
812
|
+
});
|
|
565
813
|
return { ...record };
|
|
566
814
|
}
|
|
567
815
|
async function check(id, options2) {
|
|
@@ -599,14 +847,34 @@ function createLocalDispatchRuntime(options) {
|
|
|
599
847
|
throw new Error(`No dispatch with ID "${id}".`);
|
|
600
848
|
}
|
|
601
849
|
if (active.record.status !== "running") {
|
|
850
|
+
await cancelRunningChildDispatches(
|
|
851
|
+
active.childRuntime,
|
|
852
|
+
reason ?? "Parent dispatch closed"
|
|
853
|
+
);
|
|
602
854
|
return { ...active.record };
|
|
603
855
|
}
|
|
604
|
-
active.abort.abort(reason ?? "Cancelled");
|
|
605
856
|
active.record.status = "cancelled";
|
|
606
857
|
active.record.updatedAt = now();
|
|
607
858
|
if (reason) {
|
|
608
859
|
active.record.error = reason;
|
|
609
860
|
}
|
|
861
|
+
active.abort.abort(reason ?? "Cancelled");
|
|
862
|
+
await cancelRunningChildDispatches(
|
|
863
|
+
active.childRuntime,
|
|
864
|
+
reason ?? "Parent dispatch cancelled"
|
|
865
|
+
);
|
|
866
|
+
await publishDispatchProgress({
|
|
867
|
+
eventStore,
|
|
868
|
+
record: active.record,
|
|
869
|
+
now,
|
|
870
|
+
emitEvent: active.emitEvent,
|
|
871
|
+
event: {
|
|
872
|
+
type: "subagent-error",
|
|
873
|
+
...dispatchEventContext(active.record),
|
|
874
|
+
status: "cancelled",
|
|
875
|
+
error: active.record.error ?? "Cancelled"
|
|
876
|
+
}
|
|
877
|
+
});
|
|
610
878
|
return { ...active.record };
|
|
611
879
|
}
|
|
612
880
|
async function list(options2) {
|
|
@@ -623,6 +891,17 @@ function createLocalDispatchRuntime(options) {
|
|
|
623
891
|
(r) => r.parentSessionId === options2.parentSessionId
|
|
624
892
|
);
|
|
625
893
|
}
|
|
894
|
+
if (options2?.parentTurnId) {
|
|
895
|
+
records = records.filter((r) => r.parentTurnId === options2.parentTurnId);
|
|
896
|
+
}
|
|
897
|
+
if (options2?.parentDispatchId) {
|
|
898
|
+
records = records.filter(
|
|
899
|
+
(r) => r.parentDispatchId === options2.parentDispatchId
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
if (options2?.agentPath) {
|
|
903
|
+
records = records.filter((r) => r.agentPath === options2.agentPath);
|
|
904
|
+
}
|
|
626
905
|
return records;
|
|
627
906
|
}
|
|
628
907
|
return {
|
|
@@ -631,7 +910,8 @@ function createLocalDispatchRuntime(options) {
|
|
|
631
910
|
check,
|
|
632
911
|
redirect,
|
|
633
912
|
cancel,
|
|
634
|
-
list
|
|
913
|
+
list,
|
|
914
|
+
listEvents: async (filter) => eventStore?.list(filter) ?? []
|
|
635
915
|
};
|
|
636
916
|
}
|
|
637
917
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DispatchEventFilter, DispatchEventRecord, DispatchEventRecordInput, DispatchEventStore } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory dispatch event store.
|
|
4
|
+
*
|
|
5
|
+
* Useful for tests and single-process hosts. Production hosts that need
|
|
6
|
+
* restart-safe background dispatch history should provide a durable
|
|
7
|
+
* implementation of `DispatchEventStore`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class InMemoryDispatchEventStore implements DispatchEventStore {
|
|
10
|
+
private events;
|
|
11
|
+
private sequence;
|
|
12
|
+
append(event: DispatchEventRecordInput): Promise<DispatchEventRecord>;
|
|
13
|
+
list(filter?: DispatchEventFilter): Promise<DispatchEventRecord[]>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=event-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-store.d.ts","sourceRoot":"","sources":["../../src/dispatch/event-store.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AAE,OAAO,EACf,UAAU,EAAE,WAAW,GAAG,SAAS,EACnC,WAAW,EAAE,MAAM,GAClB,OAAO,CAaT;AAyCD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,4BAA4B,GACpC,cAAc,EAAE,CA4ClB;AAED,wBAAgB,0BAA0B,CACxC,OAAO,SAAS,cAAc,GAAG,cAAc,EAC/C,WAAW,SAAS,wBAAwB,GAAG,wBAAwB,EACvE,OAAO,EAAE,2BAA2B,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,YAAY,CAqF1E;AAED,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,oCAAoC,GAC5C,YAAY,CAwBd;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,YAAY,CAYd;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,SAAS,cAAc,GAAG,cAAc,EAC/C,WAAW,SAAS,wBAAwB,GAAG,wBAAwB,EAEvE,OAAO,EAAE,kCAAkC,CAAC,OAAO,EAAE,WAAW,CAAC,GAChE,mBAAmB,CAiDrB"}
|
package/dist/dispatch/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export type { DispatchCheckOptions, DispatchListOptions, DispatchRole, DispatchRecord, DispatchResult, DispatchRuntime, DispatchStartInput, DispatchState, DispatchTarget, DispatchTargetInspection, DispatchTargetStartInput, DispatchTargetStartResult, DispatchTargetSummary, DispatchUsage, LocalDispatchRuntimeOptions, } from "./types.js";
|
|
1
|
+
export type { DispatchCheckOptions, DispatchEventFilter, DispatchEventRecord, DispatchEventRecordInput, DispatchEventStore, DispatchEventSink, DispatchListOptions, DispatchRole, DispatchRecord, DispatchResult, DispatchRuntime, DispatchStartInput, DispatchState, DispatchTarget, DispatchTargetInspection, DispatchTargetStartInput, DispatchTargetStartResult, DispatchTargetSummary, DispatchUsage, LocalDispatchRuntimeOptions, } from "./types.js";
|
|
2
2
|
export { DISPATCH_STATES, DEFAULT_DISPATCH_TOOL_IDS, DEFAULT_LOCAL_DISPATCH_CONCURRENCY, DEFAULT_LOCAL_DISPATCH_DEPTH, DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX, } from "./types.js";
|
|
3
3
|
export { createLocalDispatchRuntime } from "./runtime.js";
|
|
4
|
+
export { InMemoryDispatchEventStore } from "./event-store.js";
|
|
4
5
|
export { createDispatchTools } from "./tools.js";
|
|
5
6
|
export type { CompositeDispatchTaskExecutorOptions, DispatchExternalTaskControlOptions, DispatchTaskExecutorOptions, DispatchTaskExecutorRoute, RuntimeDispatchExecutorOptions, RuntimeDispatchTargetOptions, } from "./executor.js";
|
|
6
7
|
export { createCompositeDispatchTaskExecutor, createDispatchExternalTaskControl, createDispatchTaskExecutor, createRuntimeDispatchExecutor, createRuntimeDispatchTargets, ensureNonEmpty, mergeInspection, } from "./executor.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dispatch/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,kCAAkC,EAClC,4BAA4B,EAC5B,mCAAmC,GACpC,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EACV,oCAAoC,EACpC,kCAAkC,EAClC,2BAA2B,EAC3B,yBAAyB,EACzB,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,cAAc,EACd,eAAe,GAChB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dispatch/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,kCAAkC,EAClC,4BAA4B,EAC5B,mCAAmC,GACpC,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EACV,oCAAoC,EACpC,kCAAkC,EAClC,2BAA2B,EAC3B,yBAAyB,EACzB,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,cAAc,EACd,eAAe,GAChB,MAAM,eAAe,CAAC"}
|
package/dist/dispatch/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
InMemoryDispatchEventStore,
|
|
2
3
|
createCompositeDispatchTaskExecutor,
|
|
3
4
|
createDispatchExternalTaskControl,
|
|
4
5
|
createDispatchTaskExecutor,
|
|
@@ -6,7 +7,7 @@ import {
|
|
|
6
7
|
createRuntimeDispatchTargets,
|
|
7
8
|
ensureNonEmpty,
|
|
8
9
|
mergeInspection
|
|
9
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-2BRLPF3Z.js";
|
|
10
11
|
import {
|
|
11
12
|
DEFAULT_DISPATCH_TOOL_IDS,
|
|
12
13
|
DEFAULT_LOCAL_DISPATCH_CONCURRENCY,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
DISPATCH_STATES,
|
|
16
17
|
createDispatchTools,
|
|
17
18
|
createLocalDispatchRuntime
|
|
18
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-ZETYNQ35.js";
|
|
19
20
|
import "../chunk-EDKZOPUV.js";
|
|
20
21
|
import "../chunk-SZ2XBPTW.js";
|
|
21
22
|
import "../chunk-MJML3A2F.js";
|
|
@@ -26,6 +27,7 @@ export {
|
|
|
26
27
|
DEFAULT_LOCAL_DISPATCH_DEPTH,
|
|
27
28
|
DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX,
|
|
28
29
|
DISPATCH_STATES,
|
|
30
|
+
InMemoryDispatchEventStore,
|
|
29
31
|
createCompositeDispatchTaskExecutor,
|
|
30
32
|
createDispatchExternalTaskControl,
|
|
31
33
|
createDispatchTaskExecutor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/dispatch/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/dispatch/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,KAAK,EAQV,eAAe,EAIf,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AA4VpB;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,2BAA2B,GACnC,eAAe,CAwXjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-factories.d.ts","sourceRoot":"","sources":["../../src/dispatch/tool-factories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,YAAY,CAAC;AAmBzE,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GACvB,IAAI,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"tool-factories.d.ts","sourceRoot":"","sources":["../../src/dispatch/tool-factories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,YAAY,CAAC;AAmBzE,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GACvB,IAAI,CAAC,OAAO,CA6Cd;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GACvB,IAAI,CAAC,OAAO,CA6Bd;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,eAAe,GACvB,IAAI,CAAC,OAAO,CAkBd;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,eAAe,GACvB,IAAI,CAAC,OAAO,CAiBd;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC,OAAO,CAgC7E"}
|
package/dist/dispatch/types.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { LanguageModel } from "ai";
|
|
2
2
|
import type { Agent } from "../agent/instance/index.js";
|
|
3
3
|
import type { AgentMiddleware } from "../middleware/types.js";
|
|
4
|
+
import type { ReasoningLevel } from "../models/reasoning/index.js";
|
|
4
5
|
import type { Profile } from "../profiles/types.js";
|
|
5
6
|
import type { PromptConfig } from "../prompt/types.js";
|
|
6
7
|
import type { Tool } from "../tool/tool.js";
|
|
8
|
+
import type { AgentEvent } from "../types/events.js";
|
|
7
9
|
export declare const DISPATCH_STATES: readonly ["running", "completed", "failed", "cancelled"];
|
|
8
10
|
export type DispatchState = (typeof DISPATCH_STATES)[number];
|
|
9
11
|
export declare const DEFAULT_DISPATCH_TOOL_IDS: readonly ["start_dispatch", "check_dispatch", "redirect_dispatch", "cancel_dispatch", "list_dispatches"];
|
|
@@ -14,6 +16,7 @@ export interface DispatchRole {
|
|
|
14
16
|
systemPrompt?: string;
|
|
15
17
|
prompt?: PromptConfig;
|
|
16
18
|
model?: LanguageModel;
|
|
19
|
+
reasoningLevel?: ReasoningLevel;
|
|
17
20
|
skills?: string[];
|
|
18
21
|
maxSteps?: number;
|
|
19
22
|
additionalMiddleware?: AgentMiddleware[];
|
|
@@ -33,7 +36,12 @@ export interface DispatchTargetStartInput {
|
|
|
33
36
|
brief: string;
|
|
34
37
|
title: string;
|
|
35
38
|
parentSessionId?: string;
|
|
39
|
+
parentTurnId?: string;
|
|
40
|
+
parentDispatchId?: string;
|
|
41
|
+
depth?: number;
|
|
42
|
+
agentPath?: string;
|
|
36
43
|
sessionId?: string;
|
|
44
|
+
abort?: AbortSignal;
|
|
37
45
|
}
|
|
38
46
|
export interface DispatchTargetStartResult {
|
|
39
47
|
sessionId?: string;
|
|
@@ -52,6 +60,49 @@ export interface DispatchResult {
|
|
|
52
60
|
result: unknown;
|
|
53
61
|
}>;
|
|
54
62
|
}
|
|
63
|
+
export type DispatchEventSink = (event: AgentEvent) => void | Promise<void>;
|
|
64
|
+
/** Input accepted by a dispatch event store before it assigns identity. */
|
|
65
|
+
export interface DispatchEventRecordInput {
|
|
66
|
+
dispatchId: string;
|
|
67
|
+
targetType: string;
|
|
68
|
+
title: string;
|
|
69
|
+
parentSessionId?: string;
|
|
70
|
+
parentTurnId?: string;
|
|
71
|
+
parentDispatchId?: string;
|
|
72
|
+
depth?: number;
|
|
73
|
+
agentPath?: string;
|
|
74
|
+
childSessionId?: string;
|
|
75
|
+
executionId?: string;
|
|
76
|
+
createdAt: string;
|
|
77
|
+
event: AgentEvent;
|
|
78
|
+
}
|
|
79
|
+
/** A stored dispatch event with store-assigned identity and ordering. */
|
|
80
|
+
export interface DispatchEventRecord extends DispatchEventRecordInput {
|
|
81
|
+
id: string;
|
|
82
|
+
sequence: number;
|
|
83
|
+
}
|
|
84
|
+
/** Query filter for dispatch event history. */
|
|
85
|
+
export interface DispatchEventFilter {
|
|
86
|
+
dispatchId?: string;
|
|
87
|
+
parentSessionId?: string;
|
|
88
|
+
parentTurnId?: string;
|
|
89
|
+
parentDispatchId?: string;
|
|
90
|
+
agentPath?: string;
|
|
91
|
+
childSessionId?: string;
|
|
92
|
+
targetType?: string;
|
|
93
|
+
type?: AgentEvent["type"] | readonly AgentEvent["type"][];
|
|
94
|
+
afterSequence?: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Separate persistence surface for dispatch/subagent progress.
|
|
98
|
+
*
|
|
99
|
+
* Implementations should store UI/audit progress outside session chat history
|
|
100
|
+
* so child-agent activity does not pollute the parent model context.
|
|
101
|
+
*/
|
|
102
|
+
export interface DispatchEventStore {
|
|
103
|
+
append(event: DispatchEventRecordInput): Promise<DispatchEventRecord>;
|
|
104
|
+
list(filter?: DispatchEventFilter): Promise<DispatchEventRecord[]>;
|
|
105
|
+
}
|
|
55
106
|
export interface DispatchRecord {
|
|
56
107
|
id: string;
|
|
57
108
|
targetType: string;
|
|
@@ -61,6 +112,10 @@ export interface DispatchRecord {
|
|
|
61
112
|
createdAt: string;
|
|
62
113
|
updatedAt: string;
|
|
63
114
|
parentSessionId?: string;
|
|
115
|
+
parentTurnId?: string;
|
|
116
|
+
parentDispatchId?: string;
|
|
117
|
+
depth?: number;
|
|
118
|
+
agentPath?: string;
|
|
64
119
|
sessionId?: string;
|
|
65
120
|
executionId?: string;
|
|
66
121
|
redirectCount: number;
|
|
@@ -97,7 +152,13 @@ export interface DispatchStartInput {
|
|
|
97
152
|
brief: string;
|
|
98
153
|
title?: string;
|
|
99
154
|
parentSessionId?: string;
|
|
155
|
+
parentTurnId?: string;
|
|
156
|
+
parentDispatchId?: string;
|
|
157
|
+
depth?: number;
|
|
158
|
+
agentPath?: string;
|
|
100
159
|
abort?: AbortSignal;
|
|
160
|
+
/** Optional parent turn event sink for live child progress forwarding. */
|
|
161
|
+
emitEvent?: DispatchEventSink;
|
|
101
162
|
}
|
|
102
163
|
export interface DispatchCheckOptions {
|
|
103
164
|
waitMs?: number;
|
|
@@ -106,6 +167,9 @@ export interface DispatchListOptions {
|
|
|
106
167
|
status?: DispatchState | readonly DispatchState[];
|
|
107
168
|
targetType?: string;
|
|
108
169
|
parentSessionId?: string;
|
|
170
|
+
parentTurnId?: string;
|
|
171
|
+
parentDispatchId?: string;
|
|
172
|
+
agentPath?: string;
|
|
109
173
|
}
|
|
110
174
|
export interface DispatchRuntime {
|
|
111
175
|
describeTargets(): readonly DispatchTargetSummary[];
|
|
@@ -114,6 +178,7 @@ export interface DispatchRuntime {
|
|
|
114
178
|
redirect(id: string, message: string): Promise<DispatchRecord>;
|
|
115
179
|
cancel(id: string, reason?: string): Promise<DispatchRecord>;
|
|
116
180
|
list(options?: DispatchListOptions): Promise<DispatchRecord[]>;
|
|
181
|
+
listEvents?(filter?: DispatchEventFilter): Promise<DispatchEventRecord[]>;
|
|
117
182
|
}
|
|
118
183
|
export interface LocalDispatchRuntimeOptions {
|
|
119
184
|
parent: Agent;
|
|
@@ -121,12 +186,15 @@ export interface LocalDispatchRuntimeOptions {
|
|
|
121
186
|
maxConcurrent?: number;
|
|
122
187
|
maxDepth?: number;
|
|
123
188
|
currentDepth?: number;
|
|
189
|
+
parentDispatchId?: string;
|
|
190
|
+
parentAgentPath?: string;
|
|
124
191
|
sessionTitlePrefix?: string;
|
|
125
192
|
now?: () => string;
|
|
126
193
|
createId?: () => string;
|
|
127
194
|
childToolIds?: readonly string[];
|
|
128
195
|
createChildTools?: (runtime: DispatchRuntime) => readonly Tool.AnyInfo[];
|
|
129
196
|
buildChild?: (parent: Agent, role: DispatchRole) => Agent;
|
|
197
|
+
eventStore?: DispatchEventStore;
|
|
130
198
|
}
|
|
131
199
|
export declare const DEFAULT_LOCAL_DISPATCH_CONCURRENCY = 6;
|
|
132
200
|
export declare const DEFAULT_LOCAL_DISPATCH_DEPTH = 2;
|