@directive-run/ai 0.3.0 → 0.4.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/anthropic.cjs.map +1 -1
- package/dist/anthropic.d.cts +1 -1
- package/dist/anthropic.d.ts +1 -1
- package/dist/anthropic.js.map +1 -1
- package/dist/gemini.cjs.map +1 -1
- package/dist/gemini.d.cts +1 -1
- package/dist/gemini.d.ts +1 -1
- package/dist/gemini.js.map +1 -1
- package/dist/index.cjs +49 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +49 -49
- package/dist/index.js.map +1 -1
- package/dist/{multi-agent-orchestrator-CxL8ycw_.d.cts → multi-agent-orchestrator-D-WuP4jP.d.ts} +176 -101
- package/dist/{multi-agent-orchestrator-uMp8bLfV.d.ts → multi-agent-orchestrator-YFs28JsF.d.cts} +176 -101
- package/dist/ollama.cjs.map +1 -1
- package/dist/ollama.d.cts +1 -1
- package/dist/ollama.d.ts +1 -1
- package/dist/ollama.js.map +1 -1
- package/dist/openai.cjs.map +1 -1
- package/dist/openai.d.cts +1 -1
- package/dist/openai.d.ts +1 -1
- package/dist/openai.js.map +1 -1
- package/dist/testing.cjs +24 -24
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +32 -7
- package/dist/testing.d.ts +32 -7
- package/dist/testing.js +24 -24
- package/dist/testing.js.map +1 -1
- package/dist/{types-Co4BzMiH.d.cts → types-D5veI9su.d.cts} +96 -13
- package/dist/{types-Co4BzMiH.d.ts → types-D5veI9su.d.ts} +96 -13
- package/package.json +2 -2
|
@@ -29,6 +29,11 @@ interface MultiAgentCheckpointLocalState {
|
|
|
29
29
|
pendingHandoffs: unknown[];
|
|
30
30
|
handoffResults: unknown[];
|
|
31
31
|
roundRobinCounters: Record<string, number> | null;
|
|
32
|
+
/** Serialized task states (task run functions are closures, not serializable) */
|
|
33
|
+
taskStates?: Record<string, {
|
|
34
|
+
lastOutput?: string;
|
|
35
|
+
lastError?: string;
|
|
36
|
+
}>;
|
|
32
37
|
}
|
|
33
38
|
/** Union of local state types */
|
|
34
39
|
type CheckpointLocalState = SingleAgentCheckpointLocalState | MultiAgentCheckpointLocalState;
|
|
@@ -521,12 +526,14 @@ interface MultiAgentLifecycleHooks {
|
|
|
521
526
|
patternId: string;
|
|
522
527
|
nodeId: string;
|
|
523
528
|
agentId: string;
|
|
529
|
+
nodeType: "agent" | "task";
|
|
524
530
|
timestamp: number;
|
|
525
531
|
}) => void;
|
|
526
532
|
onDagNodeComplete?: (event: {
|
|
527
533
|
patternId: string;
|
|
528
534
|
nodeId: string;
|
|
529
535
|
agentId: string;
|
|
536
|
+
nodeType: "agent" | "task";
|
|
530
537
|
durationMs: number;
|
|
531
538
|
timestamp: number;
|
|
532
539
|
}) => void;
|
|
@@ -534,6 +541,7 @@ interface MultiAgentLifecycleHooks {
|
|
|
534
541
|
patternId: string;
|
|
535
542
|
nodeId: string;
|
|
536
543
|
agentId: string;
|
|
544
|
+
nodeType: "agent" | "task";
|
|
537
545
|
error: Error;
|
|
538
546
|
durationMs: number;
|
|
539
547
|
timestamp: number;
|
|
@@ -542,6 +550,7 @@ interface MultiAgentLifecycleHooks {
|
|
|
542
550
|
patternId: string;
|
|
543
551
|
nodeId: string;
|
|
544
552
|
agentId: string;
|
|
553
|
+
nodeType: "agent" | "task";
|
|
545
554
|
reason: string;
|
|
546
555
|
timestamp: number;
|
|
547
556
|
}) => void;
|
|
@@ -571,6 +580,39 @@ interface MultiAgentLifecycleHooks {
|
|
|
571
580
|
keys: string[];
|
|
572
581
|
timestamp: number;
|
|
573
582
|
}) => void;
|
|
583
|
+
/** Called when a task starts executing */
|
|
584
|
+
onTaskStart?: (event: {
|
|
585
|
+
patternId: string;
|
|
586
|
+
taskId: string;
|
|
587
|
+
label: string;
|
|
588
|
+
timestamp: number;
|
|
589
|
+
}) => void;
|
|
590
|
+
/** Called when a task completes successfully */
|
|
591
|
+
onTaskComplete?: (event: {
|
|
592
|
+
patternId: string;
|
|
593
|
+
taskId: string;
|
|
594
|
+
label: string;
|
|
595
|
+
durationMs: number;
|
|
596
|
+
timestamp: number;
|
|
597
|
+
}) => void;
|
|
598
|
+
/** Called when a task fails */
|
|
599
|
+
onTaskError?: (event: {
|
|
600
|
+
patternId: string;
|
|
601
|
+
taskId: string;
|
|
602
|
+
label: string;
|
|
603
|
+
error: Error;
|
|
604
|
+
durationMs: number;
|
|
605
|
+
timestamp: number;
|
|
606
|
+
}) => void;
|
|
607
|
+
/** Called when a task reports progress */
|
|
608
|
+
onTaskProgress?: (event: {
|
|
609
|
+
patternId: string;
|
|
610
|
+
taskId: string;
|
|
611
|
+
label: string;
|
|
612
|
+
percent: number;
|
|
613
|
+
message?: string;
|
|
614
|
+
timestamp: number;
|
|
615
|
+
}) => void;
|
|
574
616
|
/** Called when a pattern checkpoint is saved */
|
|
575
617
|
onCheckpointSave?: (event: {
|
|
576
618
|
checkpointId: string;
|
|
@@ -641,8 +683,8 @@ interface DagExecutionContext {
|
|
|
641
683
|
}
|
|
642
684
|
/** A node in a DAG execution pattern */
|
|
643
685
|
interface DagNode {
|
|
644
|
-
/** Registered
|
|
645
|
-
|
|
686
|
+
/** Registered handler ID (agent or task) to run for this node */
|
|
687
|
+
handler: string;
|
|
646
688
|
/** Upstream node IDs this node depends on */
|
|
647
689
|
deps?: string[];
|
|
648
690
|
/** Conditional edge — evaluated when deps are met. @default unconditional */
|
|
@@ -672,11 +714,10 @@ interface DagPattern<T = unknown> {
|
|
|
672
714
|
}
|
|
673
715
|
/** Debug configuration for orchestrators */
|
|
674
716
|
interface OrchestratorDebugConfig {
|
|
675
|
-
/** Include truncated input/output in timeline events for prompt/completion viewing */
|
|
676
717
|
verboseTimeline?: boolean;
|
|
677
718
|
}
|
|
678
719
|
/** All debug event types */
|
|
679
|
-
type DebugEventType = "agent_start" | "agent_complete" | "agent_error" | "agent_retry" | "guardrail_check" | "constraint_evaluate" | "resolver_start" | "resolver_complete" | "resolver_error" | "approval_request" | "approval_response" | "handoff_start" | "handoff_complete" | "pattern_start" | "pattern_complete" | "dag_node_update" | "breakpoint_hit" | "breakpoint_resumed" | "derivation_update" | "scratchpad_update" | "reflection_iteration" | "race_start" | "race_winner" | "race_cancelled" | "debate_round" | "reroute" | "checkpoint_save" | "checkpoint_restore";
|
|
720
|
+
type DebugEventType = "agent_start" | "agent_complete" | "agent_error" | "agent_retry" | "guardrail_check" | "constraint_evaluate" | "resolver_start" | "resolver_complete" | "resolver_error" | "approval_request" | "approval_response" | "handoff_start" | "handoff_complete" | "pattern_start" | "pattern_complete" | "dag_node_update" | "breakpoint_hit" | "breakpoint_resumed" | "derivation_update" | "scratchpad_update" | "reflection_iteration" | "race_start" | "race_winner" | "race_cancelled" | "debate_round" | "reroute" | "checkpoint_save" | "checkpoint_restore" | "task_start" | "task_complete" | "task_error" | "task_progress" | "goal_step";
|
|
680
721
|
/** Base debug event */
|
|
681
722
|
interface DebugEventBase {
|
|
682
723
|
id: number;
|
|
@@ -690,7 +731,7 @@ interface AgentStartEvent extends DebugEventBase {
|
|
|
690
731
|
type: "agent_start";
|
|
691
732
|
agentId: string;
|
|
692
733
|
inputLength: number;
|
|
693
|
-
/** Truncated input text (
|
|
734
|
+
/** Truncated input text (max 5000 chars) */
|
|
694
735
|
input?: string;
|
|
695
736
|
}
|
|
696
737
|
/** Agent complete event */
|
|
@@ -703,7 +744,7 @@ interface AgentCompleteEvent extends DebugEventBase {
|
|
|
703
744
|
outputTokens: number;
|
|
704
745
|
durationMs: number;
|
|
705
746
|
modelId?: string;
|
|
706
|
-
/** Truncated output text (
|
|
747
|
+
/** Truncated output text (max 5000 chars) */
|
|
707
748
|
output?: string;
|
|
708
749
|
}
|
|
709
750
|
/** Agent error event */
|
|
@@ -786,6 +827,10 @@ interface PatternStartEvent extends DebugEventBase {
|
|
|
786
827
|
type: "pattern_start";
|
|
787
828
|
patternId: string;
|
|
788
829
|
patternType: "parallel" | "sequential" | "supervisor" | "dag" | "reflect" | "race" | "debate" | "goal";
|
|
830
|
+
/** All handler IDs in this pattern (agents + tasks) */
|
|
831
|
+
handlers?: string[];
|
|
832
|
+
/** Which handler IDs are tasks (rest are agents) */
|
|
833
|
+
taskIds?: string[];
|
|
789
834
|
}
|
|
790
835
|
/** Pattern complete event */
|
|
791
836
|
interface PatternCompleteEvent extends DebugEventBase {
|
|
@@ -889,8 +934,49 @@ interface CheckpointRestoreEvent extends DebugEventBase {
|
|
|
889
934
|
patternType: string;
|
|
890
935
|
step: number;
|
|
891
936
|
}
|
|
937
|
+
/** Task start event */
|
|
938
|
+
interface TaskStartEvent extends DebugEventBase {
|
|
939
|
+
type: "task_start";
|
|
940
|
+
taskId: string;
|
|
941
|
+
label: string;
|
|
942
|
+
description?: string;
|
|
943
|
+
inputLength: number;
|
|
944
|
+
}
|
|
945
|
+
/** Task complete event */
|
|
946
|
+
interface TaskCompleteEvent extends DebugEventBase {
|
|
947
|
+
type: "task_complete";
|
|
948
|
+
taskId: string;
|
|
949
|
+
label: string;
|
|
950
|
+
durationMs: number;
|
|
951
|
+
}
|
|
952
|
+
/** Task error event */
|
|
953
|
+
interface TaskErrorEvent extends DebugEventBase {
|
|
954
|
+
type: "task_error";
|
|
955
|
+
taskId: string;
|
|
956
|
+
label: string;
|
|
957
|
+
error: string;
|
|
958
|
+
durationMs: number;
|
|
959
|
+
attempt?: number;
|
|
960
|
+
}
|
|
961
|
+
/** Task progress event */
|
|
962
|
+
interface TaskProgressEvent extends DebugEventBase {
|
|
963
|
+
type: "task_progress";
|
|
964
|
+
taskId: string;
|
|
965
|
+
label: string;
|
|
966
|
+
percent: number;
|
|
967
|
+
message?: string;
|
|
968
|
+
}
|
|
969
|
+
/** Goal step event — emitted for each agent invocation within a goal step */
|
|
970
|
+
interface GoalStepEvent extends DebugEventBase {
|
|
971
|
+
type: "goal_step";
|
|
972
|
+
agentId: string;
|
|
973
|
+
step: number;
|
|
974
|
+
nodeId: string;
|
|
975
|
+
satisfaction: number;
|
|
976
|
+
satisfactionDelta: number;
|
|
977
|
+
}
|
|
892
978
|
/** Union of all debug event types */
|
|
893
|
-
type DebugEvent = AgentStartEvent | AgentCompleteEvent | AgentErrorEvent | AgentRetryEvent | GuardrailCheckEvent | ConstraintEvaluateEvent | ResolverStartEvent | ResolverCompleteEvent | ResolverErrorEvent | ApprovalRequestEvent | ApprovalResponseEvent | HandoffStartEvent | HandoffCompleteEvent | PatternStartEvent | PatternCompleteEvent | DagNodeUpdateEvent | BreakpointHitEvent | BreakpointResumedEvent | DerivationUpdateEvent | ScratchpadUpdateEvent | ReflectionIterationEvent | RaceStartEvent | RaceWinnerEvent | RaceCancelledEvent | DebateRoundEvent | RerouteDebugEvent | CheckpointSaveEvent | CheckpointRestoreEvent;
|
|
979
|
+
type DebugEvent = AgentStartEvent | AgentCompleteEvent | AgentErrorEvent | AgentRetryEvent | GuardrailCheckEvent | ConstraintEvaluateEvent | ResolverStartEvent | ResolverCompleteEvent | ResolverErrorEvent | ApprovalRequestEvent | ApprovalResponseEvent | HandoffStartEvent | HandoffCompleteEvent | PatternStartEvent | PatternCompleteEvent | DagNodeUpdateEvent | BreakpointHitEvent | BreakpointResumedEvent | DerivationUpdateEvent | ScratchpadUpdateEvent | ReflectionIterationEvent | RaceStartEvent | RaceWinnerEvent | RaceCancelledEvent | DebateRoundEvent | RerouteDebugEvent | CheckpointSaveEvent | CheckpointRestoreEvent | TaskStartEvent | TaskCompleteEvent | TaskErrorEvent | TaskProgressEvent | GoalStepEvent;
|
|
894
980
|
/** Health state for an agent stored in facts */
|
|
895
981
|
interface AgentHealthState {
|
|
896
982
|
circuitState: "CLOSED" | "OPEN" | "HALF_OPEN";
|
|
@@ -1013,8 +1099,8 @@ interface Scratchpad<T extends Record<string, unknown> = Record<string, unknown>
|
|
|
1013
1099
|
}
|
|
1014
1100
|
/** A node in a goal execution pattern */
|
|
1015
1101
|
interface GoalNode {
|
|
1016
|
-
/**
|
|
1017
|
-
|
|
1102
|
+
/** Handler ID — agent or task registered on the orchestrator */
|
|
1103
|
+
handler: string;
|
|
1018
1104
|
/** Fact keys this node can produce */
|
|
1019
1105
|
produces: string[];
|
|
1020
1106
|
/** Fact keys this node needs (must be satisfied before running) */
|
|
@@ -1175,9 +1261,6 @@ interface CheckpointContext {
|
|
|
1175
1261
|
/** Satisfaction score 0-1 (goal only) */
|
|
1176
1262
|
satisfaction?: number;
|
|
1177
1263
|
}
|
|
1178
|
-
/**
|
|
1179
|
-
* @deprecated Use `PatternCheckpointConfig` instead. Alias kept for backward compatibility.
|
|
1180
|
-
*/
|
|
1181
1264
|
type GoalCheckpointConfig = PatternCheckpointConfig;
|
|
1182
1265
|
/** Common fields present on all pattern checkpoint states */
|
|
1183
1266
|
interface PatternCheckpointBase {
|
|
@@ -1370,4 +1453,4 @@ interface CheckpointDiff {
|
|
|
1370
1453
|
nodesCompleted?: string[];
|
|
1371
1454
|
}
|
|
1372
1455
|
|
|
1373
|
-
export { type DebateRoundEvent as $, type AgentLike as A, type BreakpointState as B, type Checkpoint as C, type DebugEvent as D, type CheckpointDiff as E, type CheckpointLocalState as F, type GuardrailFn as G, type CheckpointProgress as H, type InputGuardrailData as I, type CheckpointRestoreEvent as J, type CheckpointSaveEvent as K, type CheckpointStore as L, type Message as M, type ConstraintEvaluateEvent as N, type OutputGuardrailData as O, type CrossAgentDerivationFn as P, type CrossAgentSnapshot as Q, type RunOptions as R, type SchemaValidator as S, type ToolCallGuardrailData as T, type DagCheckpointState as U, type DagExecutionContext as V, type DagNode as W, type DagNodeStatus as X, type DagNodeUpdateEvent as Y, type DagPattern as Z, type DebateCheckpointState as _, type AdapterHooks as a,
|
|
1456
|
+
export { type DebateRoundEvent as $, type AgentLike as A, type BreakpointState as B, type Checkpoint as C, type DebugEvent as D, type CheckpointDiff as E, type CheckpointLocalState as F, type GuardrailFn as G, type CheckpointProgress as H, type InputGuardrailData as I, type CheckpointRestoreEvent as J, type CheckpointSaveEvent as K, type CheckpointStore as L, type Message as M, type ConstraintEvaluateEvent as N, type OutputGuardrailData as O, type CrossAgentDerivationFn as P, type CrossAgentSnapshot as Q, type RunOptions as R, type SchemaValidator as S, type ToolCallGuardrailData as T, type DagCheckpointState as U, type DagExecutionContext as V, type DagNode as W, type DagNodeStatus as X, type DagNodeUpdateEvent as Y, type DagPattern as Z, type DebateCheckpointState as _, type AdapterHooks as a, type TaskProgressEvent as a$, type DebugEventBase as a0, type DebugEventType as a1, type DerivationUpdateEvent as a2, type GoalCheckpointConfig as a3, type GoalCheckpointState as a4, type GoalMetrics as a5, type GoalNode as a6, type GoalPattern as a7, type GoalStepMetrics as a8, type GuardrailCheckEvent as a9, type PatternCompleteEvent as aA, type PatternStartEvent as aB, type RaceCancelledEvent as aC, type RaceStartEvent as aD, type RaceWinnerEvent as aE, type ReflectCheckpointState as aF, type ReflectionIterationEvent as aG, type RejectedRequest as aH, type RelaxationContext as aI, type RelaxationRecord as aJ, type RelaxationStrategy as aK, type RelaxationTier as aL, type RerouteDebugEvent as aM, type RerouteEvent as aN, type ResolverCompleteEvent as aO, type ResolverErrorEvent as aP, type ResolverStartEvent as aQ, type SchemaValidationResult as aR, type Scratchpad as aS, type ScratchpadUpdateEvent as aT, type SelfHealingConfig as aU, type SequentialCheckpointState as aV, type SingleAgentCheckpointLocalState as aW, type StreamingCallbackRunner as aX, type SupervisorCheckpointState as aY, type TaskCompleteEvent as aZ, type TaskErrorEvent as a_, type GuardrailContext as aa, GuardrailError as ab, type GuardrailErrorCode as ac, type GuardrailResult as ad, type GuardrailRetryConfig as ae, type GuardrailsConfig as af, type HandoffCompleteEvent as ag, type HandoffStartEvent as ah, type HealthMonitorConfig as ai, InMemoryCheckpointStore as aj, type InMemoryCheckpointStoreOptions as ak, MAX_BREAKPOINT_HISTORY as al, type MultiAgentBreakpointType as am, type MultiAgentCheckpointLocalState as an, type MultiAgentLifecycleHooks as ao, type MultiAgentSelfHealingConfig as ap, type NamedGuardrail as aq, type OrchestratorConstraint as ar, type OrchestratorDebugConfig as as, type OrchestratorLifecycleHooks as at, type OrchestratorResolver as au, type OrchestratorResolverContext as av, type OrchestratorState as aw, type PatternCheckpointBase as ax, type PatternCheckpointConfig as ay, type PatternCheckpointState as az, type AgentRunner as b, type TaskStartEvent as b0, type TokenUsage as b1, type ToolCall as b2, createBreakpointId as b3, createCheckpointId as b4, createInitialBreakpointState as b5, isGuardrailError as b6, matchBreakpoint as b7, validateCheckpoint as b8, type ApprovalState as c, type AgentState as d, type RunResult as e, type GoalResult as f, type AgentCircuitBreakerConfig as g, type AgentCompleteEvent as h, type AgentErrorEvent as i, type AgentHealthState as j, type AgentRetryConfig as k, type AgentRetryEvent as l, type AgentSelectionStrategy as m, type AgentStartEvent as n, type ApprovalRequest as o, type ApprovalRequestEvent as p, type ApprovalResponseEvent as q, type BreakpointConfig as r, type BreakpointContext as s, type BreakpointHitEvent as t, type BreakpointModifications as u, type BreakpointRequest as v, type BreakpointResumedEvent as w, type BreakpointState$1 as x, type BreakpointType as y, type CheckpointContext as z };
|
|
@@ -29,6 +29,11 @@ interface MultiAgentCheckpointLocalState {
|
|
|
29
29
|
pendingHandoffs: unknown[];
|
|
30
30
|
handoffResults: unknown[];
|
|
31
31
|
roundRobinCounters: Record<string, number> | null;
|
|
32
|
+
/** Serialized task states (task run functions are closures, not serializable) */
|
|
33
|
+
taskStates?: Record<string, {
|
|
34
|
+
lastOutput?: string;
|
|
35
|
+
lastError?: string;
|
|
36
|
+
}>;
|
|
32
37
|
}
|
|
33
38
|
/** Union of local state types */
|
|
34
39
|
type CheckpointLocalState = SingleAgentCheckpointLocalState | MultiAgentCheckpointLocalState;
|
|
@@ -521,12 +526,14 @@ interface MultiAgentLifecycleHooks {
|
|
|
521
526
|
patternId: string;
|
|
522
527
|
nodeId: string;
|
|
523
528
|
agentId: string;
|
|
529
|
+
nodeType: "agent" | "task";
|
|
524
530
|
timestamp: number;
|
|
525
531
|
}) => void;
|
|
526
532
|
onDagNodeComplete?: (event: {
|
|
527
533
|
patternId: string;
|
|
528
534
|
nodeId: string;
|
|
529
535
|
agentId: string;
|
|
536
|
+
nodeType: "agent" | "task";
|
|
530
537
|
durationMs: number;
|
|
531
538
|
timestamp: number;
|
|
532
539
|
}) => void;
|
|
@@ -534,6 +541,7 @@ interface MultiAgentLifecycleHooks {
|
|
|
534
541
|
patternId: string;
|
|
535
542
|
nodeId: string;
|
|
536
543
|
agentId: string;
|
|
544
|
+
nodeType: "agent" | "task";
|
|
537
545
|
error: Error;
|
|
538
546
|
durationMs: number;
|
|
539
547
|
timestamp: number;
|
|
@@ -542,6 +550,7 @@ interface MultiAgentLifecycleHooks {
|
|
|
542
550
|
patternId: string;
|
|
543
551
|
nodeId: string;
|
|
544
552
|
agentId: string;
|
|
553
|
+
nodeType: "agent" | "task";
|
|
545
554
|
reason: string;
|
|
546
555
|
timestamp: number;
|
|
547
556
|
}) => void;
|
|
@@ -571,6 +580,39 @@ interface MultiAgentLifecycleHooks {
|
|
|
571
580
|
keys: string[];
|
|
572
581
|
timestamp: number;
|
|
573
582
|
}) => void;
|
|
583
|
+
/** Called when a task starts executing */
|
|
584
|
+
onTaskStart?: (event: {
|
|
585
|
+
patternId: string;
|
|
586
|
+
taskId: string;
|
|
587
|
+
label: string;
|
|
588
|
+
timestamp: number;
|
|
589
|
+
}) => void;
|
|
590
|
+
/** Called when a task completes successfully */
|
|
591
|
+
onTaskComplete?: (event: {
|
|
592
|
+
patternId: string;
|
|
593
|
+
taskId: string;
|
|
594
|
+
label: string;
|
|
595
|
+
durationMs: number;
|
|
596
|
+
timestamp: number;
|
|
597
|
+
}) => void;
|
|
598
|
+
/** Called when a task fails */
|
|
599
|
+
onTaskError?: (event: {
|
|
600
|
+
patternId: string;
|
|
601
|
+
taskId: string;
|
|
602
|
+
label: string;
|
|
603
|
+
error: Error;
|
|
604
|
+
durationMs: number;
|
|
605
|
+
timestamp: number;
|
|
606
|
+
}) => void;
|
|
607
|
+
/** Called when a task reports progress */
|
|
608
|
+
onTaskProgress?: (event: {
|
|
609
|
+
patternId: string;
|
|
610
|
+
taskId: string;
|
|
611
|
+
label: string;
|
|
612
|
+
percent: number;
|
|
613
|
+
message?: string;
|
|
614
|
+
timestamp: number;
|
|
615
|
+
}) => void;
|
|
574
616
|
/** Called when a pattern checkpoint is saved */
|
|
575
617
|
onCheckpointSave?: (event: {
|
|
576
618
|
checkpointId: string;
|
|
@@ -641,8 +683,8 @@ interface DagExecutionContext {
|
|
|
641
683
|
}
|
|
642
684
|
/** A node in a DAG execution pattern */
|
|
643
685
|
interface DagNode {
|
|
644
|
-
/** Registered
|
|
645
|
-
|
|
686
|
+
/** Registered handler ID (agent or task) to run for this node */
|
|
687
|
+
handler: string;
|
|
646
688
|
/** Upstream node IDs this node depends on */
|
|
647
689
|
deps?: string[];
|
|
648
690
|
/** Conditional edge — evaluated when deps are met. @default unconditional */
|
|
@@ -672,11 +714,10 @@ interface DagPattern<T = unknown> {
|
|
|
672
714
|
}
|
|
673
715
|
/** Debug configuration for orchestrators */
|
|
674
716
|
interface OrchestratorDebugConfig {
|
|
675
|
-
/** Include truncated input/output in timeline events for prompt/completion viewing */
|
|
676
717
|
verboseTimeline?: boolean;
|
|
677
718
|
}
|
|
678
719
|
/** All debug event types */
|
|
679
|
-
type DebugEventType = "agent_start" | "agent_complete" | "agent_error" | "agent_retry" | "guardrail_check" | "constraint_evaluate" | "resolver_start" | "resolver_complete" | "resolver_error" | "approval_request" | "approval_response" | "handoff_start" | "handoff_complete" | "pattern_start" | "pattern_complete" | "dag_node_update" | "breakpoint_hit" | "breakpoint_resumed" | "derivation_update" | "scratchpad_update" | "reflection_iteration" | "race_start" | "race_winner" | "race_cancelled" | "debate_round" | "reroute" | "checkpoint_save" | "checkpoint_restore";
|
|
720
|
+
type DebugEventType = "agent_start" | "agent_complete" | "agent_error" | "agent_retry" | "guardrail_check" | "constraint_evaluate" | "resolver_start" | "resolver_complete" | "resolver_error" | "approval_request" | "approval_response" | "handoff_start" | "handoff_complete" | "pattern_start" | "pattern_complete" | "dag_node_update" | "breakpoint_hit" | "breakpoint_resumed" | "derivation_update" | "scratchpad_update" | "reflection_iteration" | "race_start" | "race_winner" | "race_cancelled" | "debate_round" | "reroute" | "checkpoint_save" | "checkpoint_restore" | "task_start" | "task_complete" | "task_error" | "task_progress" | "goal_step";
|
|
680
721
|
/** Base debug event */
|
|
681
722
|
interface DebugEventBase {
|
|
682
723
|
id: number;
|
|
@@ -690,7 +731,7 @@ interface AgentStartEvent extends DebugEventBase {
|
|
|
690
731
|
type: "agent_start";
|
|
691
732
|
agentId: string;
|
|
692
733
|
inputLength: number;
|
|
693
|
-
/** Truncated input text (
|
|
734
|
+
/** Truncated input text (max 5000 chars) */
|
|
694
735
|
input?: string;
|
|
695
736
|
}
|
|
696
737
|
/** Agent complete event */
|
|
@@ -703,7 +744,7 @@ interface AgentCompleteEvent extends DebugEventBase {
|
|
|
703
744
|
outputTokens: number;
|
|
704
745
|
durationMs: number;
|
|
705
746
|
modelId?: string;
|
|
706
|
-
/** Truncated output text (
|
|
747
|
+
/** Truncated output text (max 5000 chars) */
|
|
707
748
|
output?: string;
|
|
708
749
|
}
|
|
709
750
|
/** Agent error event */
|
|
@@ -786,6 +827,10 @@ interface PatternStartEvent extends DebugEventBase {
|
|
|
786
827
|
type: "pattern_start";
|
|
787
828
|
patternId: string;
|
|
788
829
|
patternType: "parallel" | "sequential" | "supervisor" | "dag" | "reflect" | "race" | "debate" | "goal";
|
|
830
|
+
/** All handler IDs in this pattern (agents + tasks) */
|
|
831
|
+
handlers?: string[];
|
|
832
|
+
/** Which handler IDs are tasks (rest are agents) */
|
|
833
|
+
taskIds?: string[];
|
|
789
834
|
}
|
|
790
835
|
/** Pattern complete event */
|
|
791
836
|
interface PatternCompleteEvent extends DebugEventBase {
|
|
@@ -889,8 +934,49 @@ interface CheckpointRestoreEvent extends DebugEventBase {
|
|
|
889
934
|
patternType: string;
|
|
890
935
|
step: number;
|
|
891
936
|
}
|
|
937
|
+
/** Task start event */
|
|
938
|
+
interface TaskStartEvent extends DebugEventBase {
|
|
939
|
+
type: "task_start";
|
|
940
|
+
taskId: string;
|
|
941
|
+
label: string;
|
|
942
|
+
description?: string;
|
|
943
|
+
inputLength: number;
|
|
944
|
+
}
|
|
945
|
+
/** Task complete event */
|
|
946
|
+
interface TaskCompleteEvent extends DebugEventBase {
|
|
947
|
+
type: "task_complete";
|
|
948
|
+
taskId: string;
|
|
949
|
+
label: string;
|
|
950
|
+
durationMs: number;
|
|
951
|
+
}
|
|
952
|
+
/** Task error event */
|
|
953
|
+
interface TaskErrorEvent extends DebugEventBase {
|
|
954
|
+
type: "task_error";
|
|
955
|
+
taskId: string;
|
|
956
|
+
label: string;
|
|
957
|
+
error: string;
|
|
958
|
+
durationMs: number;
|
|
959
|
+
attempt?: number;
|
|
960
|
+
}
|
|
961
|
+
/** Task progress event */
|
|
962
|
+
interface TaskProgressEvent extends DebugEventBase {
|
|
963
|
+
type: "task_progress";
|
|
964
|
+
taskId: string;
|
|
965
|
+
label: string;
|
|
966
|
+
percent: number;
|
|
967
|
+
message?: string;
|
|
968
|
+
}
|
|
969
|
+
/** Goal step event — emitted for each agent invocation within a goal step */
|
|
970
|
+
interface GoalStepEvent extends DebugEventBase {
|
|
971
|
+
type: "goal_step";
|
|
972
|
+
agentId: string;
|
|
973
|
+
step: number;
|
|
974
|
+
nodeId: string;
|
|
975
|
+
satisfaction: number;
|
|
976
|
+
satisfactionDelta: number;
|
|
977
|
+
}
|
|
892
978
|
/** Union of all debug event types */
|
|
893
|
-
type DebugEvent = AgentStartEvent | AgentCompleteEvent | AgentErrorEvent | AgentRetryEvent | GuardrailCheckEvent | ConstraintEvaluateEvent | ResolverStartEvent | ResolverCompleteEvent | ResolverErrorEvent | ApprovalRequestEvent | ApprovalResponseEvent | HandoffStartEvent | HandoffCompleteEvent | PatternStartEvent | PatternCompleteEvent | DagNodeUpdateEvent | BreakpointHitEvent | BreakpointResumedEvent | DerivationUpdateEvent | ScratchpadUpdateEvent | ReflectionIterationEvent | RaceStartEvent | RaceWinnerEvent | RaceCancelledEvent | DebateRoundEvent | RerouteDebugEvent | CheckpointSaveEvent | CheckpointRestoreEvent;
|
|
979
|
+
type DebugEvent = AgentStartEvent | AgentCompleteEvent | AgentErrorEvent | AgentRetryEvent | GuardrailCheckEvent | ConstraintEvaluateEvent | ResolverStartEvent | ResolverCompleteEvent | ResolverErrorEvent | ApprovalRequestEvent | ApprovalResponseEvent | HandoffStartEvent | HandoffCompleteEvent | PatternStartEvent | PatternCompleteEvent | DagNodeUpdateEvent | BreakpointHitEvent | BreakpointResumedEvent | DerivationUpdateEvent | ScratchpadUpdateEvent | ReflectionIterationEvent | RaceStartEvent | RaceWinnerEvent | RaceCancelledEvent | DebateRoundEvent | RerouteDebugEvent | CheckpointSaveEvent | CheckpointRestoreEvent | TaskStartEvent | TaskCompleteEvent | TaskErrorEvent | TaskProgressEvent | GoalStepEvent;
|
|
894
980
|
/** Health state for an agent stored in facts */
|
|
895
981
|
interface AgentHealthState {
|
|
896
982
|
circuitState: "CLOSED" | "OPEN" | "HALF_OPEN";
|
|
@@ -1013,8 +1099,8 @@ interface Scratchpad<T extends Record<string, unknown> = Record<string, unknown>
|
|
|
1013
1099
|
}
|
|
1014
1100
|
/** A node in a goal execution pattern */
|
|
1015
1101
|
interface GoalNode {
|
|
1016
|
-
/**
|
|
1017
|
-
|
|
1102
|
+
/** Handler ID — agent or task registered on the orchestrator */
|
|
1103
|
+
handler: string;
|
|
1018
1104
|
/** Fact keys this node can produce */
|
|
1019
1105
|
produces: string[];
|
|
1020
1106
|
/** Fact keys this node needs (must be satisfied before running) */
|
|
@@ -1175,9 +1261,6 @@ interface CheckpointContext {
|
|
|
1175
1261
|
/** Satisfaction score 0-1 (goal only) */
|
|
1176
1262
|
satisfaction?: number;
|
|
1177
1263
|
}
|
|
1178
|
-
/**
|
|
1179
|
-
* @deprecated Use `PatternCheckpointConfig` instead. Alias kept for backward compatibility.
|
|
1180
|
-
*/
|
|
1181
1264
|
type GoalCheckpointConfig = PatternCheckpointConfig;
|
|
1182
1265
|
/** Common fields present on all pattern checkpoint states */
|
|
1183
1266
|
interface PatternCheckpointBase {
|
|
@@ -1370,4 +1453,4 @@ interface CheckpointDiff {
|
|
|
1370
1453
|
nodesCompleted?: string[];
|
|
1371
1454
|
}
|
|
1372
1455
|
|
|
1373
|
-
export { type DebateRoundEvent as $, type AgentLike as A, type BreakpointState as B, type Checkpoint as C, type DebugEvent as D, type CheckpointDiff as E, type CheckpointLocalState as F, type GuardrailFn as G, type CheckpointProgress as H, type InputGuardrailData as I, type CheckpointRestoreEvent as J, type CheckpointSaveEvent as K, type CheckpointStore as L, type Message as M, type ConstraintEvaluateEvent as N, type OutputGuardrailData as O, type CrossAgentDerivationFn as P, type CrossAgentSnapshot as Q, type RunOptions as R, type SchemaValidator as S, type ToolCallGuardrailData as T, type DagCheckpointState as U, type DagExecutionContext as V, type DagNode as W, type DagNodeStatus as X, type DagNodeUpdateEvent as Y, type DagPattern as Z, type DebateCheckpointState as _, type AdapterHooks as a,
|
|
1456
|
+
export { type DebateRoundEvent as $, type AgentLike as A, type BreakpointState as B, type Checkpoint as C, type DebugEvent as D, type CheckpointDiff as E, type CheckpointLocalState as F, type GuardrailFn as G, type CheckpointProgress as H, type InputGuardrailData as I, type CheckpointRestoreEvent as J, type CheckpointSaveEvent as K, type CheckpointStore as L, type Message as M, type ConstraintEvaluateEvent as N, type OutputGuardrailData as O, type CrossAgentDerivationFn as P, type CrossAgentSnapshot as Q, type RunOptions as R, type SchemaValidator as S, type ToolCallGuardrailData as T, type DagCheckpointState as U, type DagExecutionContext as V, type DagNode as W, type DagNodeStatus as X, type DagNodeUpdateEvent as Y, type DagPattern as Z, type DebateCheckpointState as _, type AdapterHooks as a, type TaskProgressEvent as a$, type DebugEventBase as a0, type DebugEventType as a1, type DerivationUpdateEvent as a2, type GoalCheckpointConfig as a3, type GoalCheckpointState as a4, type GoalMetrics as a5, type GoalNode as a6, type GoalPattern as a7, type GoalStepMetrics as a8, type GuardrailCheckEvent as a9, type PatternCompleteEvent as aA, type PatternStartEvent as aB, type RaceCancelledEvent as aC, type RaceStartEvent as aD, type RaceWinnerEvent as aE, type ReflectCheckpointState as aF, type ReflectionIterationEvent as aG, type RejectedRequest as aH, type RelaxationContext as aI, type RelaxationRecord as aJ, type RelaxationStrategy as aK, type RelaxationTier as aL, type RerouteDebugEvent as aM, type RerouteEvent as aN, type ResolverCompleteEvent as aO, type ResolverErrorEvent as aP, type ResolverStartEvent as aQ, type SchemaValidationResult as aR, type Scratchpad as aS, type ScratchpadUpdateEvent as aT, type SelfHealingConfig as aU, type SequentialCheckpointState as aV, type SingleAgentCheckpointLocalState as aW, type StreamingCallbackRunner as aX, type SupervisorCheckpointState as aY, type TaskCompleteEvent as aZ, type TaskErrorEvent as a_, type GuardrailContext as aa, GuardrailError as ab, type GuardrailErrorCode as ac, type GuardrailResult as ad, type GuardrailRetryConfig as ae, type GuardrailsConfig as af, type HandoffCompleteEvent as ag, type HandoffStartEvent as ah, type HealthMonitorConfig as ai, InMemoryCheckpointStore as aj, type InMemoryCheckpointStoreOptions as ak, MAX_BREAKPOINT_HISTORY as al, type MultiAgentBreakpointType as am, type MultiAgentCheckpointLocalState as an, type MultiAgentLifecycleHooks as ao, type MultiAgentSelfHealingConfig as ap, type NamedGuardrail as aq, type OrchestratorConstraint as ar, type OrchestratorDebugConfig as as, type OrchestratorLifecycleHooks as at, type OrchestratorResolver as au, type OrchestratorResolverContext as av, type OrchestratorState as aw, type PatternCheckpointBase as ax, type PatternCheckpointConfig as ay, type PatternCheckpointState as az, type AgentRunner as b, type TaskStartEvent as b0, type TokenUsage as b1, type ToolCall as b2, createBreakpointId as b3, createCheckpointId as b4, createInitialBreakpointState as b5, isGuardrailError as b6, matchBreakpoint as b7, validateCheckpoint as b8, type ApprovalState as c, type AgentState as d, type RunResult as e, type GoalResult as f, type AgentCircuitBreakerConfig as g, type AgentCompleteEvent as h, type AgentErrorEvent as i, type AgentHealthState as j, type AgentRetryConfig as k, type AgentRetryEvent as l, type AgentSelectionStrategy as m, type AgentStartEvent as n, type ApprovalRequest as o, type ApprovalRequestEvent as p, type ApprovalResponseEvent as q, type BreakpointConfig as r, type BreakpointContext as s, type BreakpointHitEvent as t, type BreakpointModifications as u, type BreakpointRequest as v, type BreakpointResumedEvent as w, type BreakpointState$1 as x, type BreakpointType as y, type CheckpointContext as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directive-run/ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "AI agent orchestration, guardrails, and multi-agent coordination for Directive.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jason Comes",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/node": "^25.2.0",
|
|
77
77
|
"tsup": "^8.3.5",
|
|
78
78
|
"typescript": "^5.7.2",
|
|
79
|
-
"@directive-run/core": "0.
|
|
79
|
+
"@directive-run/core": "0.4.0"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "tsup",
|