agent-framework-js 0.1.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.
Files changed (156) hide show
  1. package/AGENT_USAGE.md +207 -0
  2. package/LICENSE +21 -0
  3. package/README.md +99 -0
  4. package/dist/agents/index.cjs +35 -0
  5. package/dist/agents/index.cjs.map +1 -0
  6. package/dist/agents/index.d.cts +8 -0
  7. package/dist/agents/index.d.ts +8 -0
  8. package/dist/agents/index.js +10 -0
  9. package/dist/agents/index.js.map +1 -0
  10. package/dist/chunk-5M6ER4ZX.cjs +4 -0
  11. package/dist/chunk-5M6ER4ZX.cjs.map +1 -0
  12. package/dist/chunk-5PDJOBTD.js +38 -0
  13. package/dist/chunk-5PDJOBTD.js.map +1 -0
  14. package/dist/chunk-7ZXUIHLH.js +18 -0
  15. package/dist/chunk-7ZXUIHLH.js.map +1 -0
  16. package/dist/chunk-ACBIHS5H.js +30 -0
  17. package/dist/chunk-ACBIHS5H.js.map +1 -0
  18. package/dist/chunk-DEABART4.js +54 -0
  19. package/dist/chunk-DEABART4.js.map +1 -0
  20. package/dist/chunk-FOTCUNP5.cjs +34 -0
  21. package/dist/chunk-FOTCUNP5.cjs.map +1 -0
  22. package/dist/chunk-FSDMBWQV.cjs +20 -0
  23. package/dist/chunk-FSDMBWQV.cjs.map +1 -0
  24. package/dist/chunk-GYDY3KX5.cjs +72 -0
  25. package/dist/chunk-GYDY3KX5.cjs.map +1 -0
  26. package/dist/chunk-HGEPXJDG.js +129 -0
  27. package/dist/chunk-HGEPXJDG.js.map +1 -0
  28. package/dist/chunk-IJASUMIQ.cjs +57 -0
  29. package/dist/chunk-IJASUMIQ.cjs.map +1 -0
  30. package/dist/chunk-IU3LS5FC.cjs +10 -0
  31. package/dist/chunk-IU3LS5FC.cjs.map +1 -0
  32. package/dist/chunk-IUKD54F7.js +8 -0
  33. package/dist/chunk-IUKD54F7.js.map +1 -0
  34. package/dist/chunk-IXV4UIF5.js +79 -0
  35. package/dist/chunk-IXV4UIF5.js.map +1 -0
  36. package/dist/chunk-KEI3EALJ.cjs +10 -0
  37. package/dist/chunk-KEI3EALJ.cjs.map +1 -0
  38. package/dist/chunk-LMN75W3W.cjs +87 -0
  39. package/dist/chunk-LMN75W3W.cjs.map +1 -0
  40. package/dist/chunk-MCLVWCOB.js +3 -0
  41. package/dist/chunk-MCLVWCOB.js.map +1 -0
  42. package/dist/chunk-MQ2XTH3S.cjs +87 -0
  43. package/dist/chunk-MQ2XTH3S.cjs.map +1 -0
  44. package/dist/chunk-QJ5XHA6S.cjs +95 -0
  45. package/dist/chunk-QJ5XHA6S.cjs.map +1 -0
  46. package/dist/chunk-RD5YUB2E.js +190 -0
  47. package/dist/chunk-RD5YUB2E.js.map +1 -0
  48. package/dist/chunk-RZ43WNHR.js +8 -0
  49. package/dist/chunk-RZ43WNHR.js.map +1 -0
  50. package/dist/chunk-RZP2ZUUX.cjs +252 -0
  51. package/dist/chunk-RZP2ZUUX.cjs.map +1 -0
  52. package/dist/chunk-T2GHJ5R4.js +241 -0
  53. package/dist/chunk-T2GHJ5R4.js.map +1 -0
  54. package/dist/chunk-TAMJ5HSR.cjs +137 -0
  55. package/dist/chunk-TAMJ5HSR.cjs.map +1 -0
  56. package/dist/chunk-TLACSVEZ.cjs +201 -0
  57. package/dist/chunk-TLACSVEZ.cjs.map +1 -0
  58. package/dist/chunk-UVWQWOLO.js +196 -0
  59. package/dist/chunk-UVWQWOLO.js.map +1 -0
  60. package/dist/chunk-V472N2PK.js +91 -0
  61. package/dist/chunk-V472N2PK.js.map +1 -0
  62. package/dist/chunk-V6O6SYAN.cjs +43 -0
  63. package/dist/chunk-V6O6SYAN.cjs.map +1 -0
  64. package/dist/chunk-VLSVL5N2.js +48 -0
  65. package/dist/chunk-VLSVL5N2.js.map +1 -0
  66. package/dist/chunk-WSMYH2IN.cjs +86 -0
  67. package/dist/chunk-WSMYH2IN.cjs.map +1 -0
  68. package/dist/chunk-XPXTXOYQ.js +81 -0
  69. package/dist/chunk-XPXTXOYQ.js.map +1 -0
  70. package/dist/chunk-YBFLWRO5.cjs +194 -0
  71. package/dist/chunk-YBFLWRO5.cjs.map +1 -0
  72. package/dist/chunk-YCBDEEAV.js +82 -0
  73. package/dist/chunk-YCBDEEAV.js.map +1 -0
  74. package/dist/chunk-YH5746OF.js +69 -0
  75. package/dist/chunk-YH5746OF.js.map +1 -0
  76. package/dist/chunk-YKZJRE32.cjs +50 -0
  77. package/dist/chunk-YKZJRE32.cjs.map +1 -0
  78. package/dist/declarative/index.cjs +19 -0
  79. package/dist/declarative/index.cjs.map +1 -0
  80. package/dist/declarative/index.d.cts +60 -0
  81. package/dist/declarative/index.d.ts +60 -0
  82. package/dist/declarative/index.js +10 -0
  83. package/dist/declarative/index.js.map +1 -0
  84. package/dist/errors-CjVz4W_5.d.cts +68 -0
  85. package/dist/errors-CjVz4W_5.d.ts +68 -0
  86. package/dist/index-C2vzfbBz.d.cts +57 -0
  87. package/dist/index-C2vzfbBz.d.ts +57 -0
  88. package/dist/index-D7-znzrc.d.ts +153 -0
  89. package/dist/index-DdYZeNIu.d.cts +153 -0
  90. package/dist/index.cjs +236 -0
  91. package/dist/index.cjs.map +1 -0
  92. package/dist/index.d.cts +51 -0
  93. package/dist/index.d.ts +51 -0
  94. package/dist/index.js +19 -0
  95. package/dist/index.js.map +1 -0
  96. package/dist/mcp/index.cjs +19 -0
  97. package/dist/mcp/index.cjs.map +1 -0
  98. package/dist/mcp/index.d.cts +72 -0
  99. package/dist/mcp/index.d.ts +72 -0
  100. package/dist/mcp/index.js +6 -0
  101. package/dist/mcp/index.js.map +1 -0
  102. package/dist/middleware/index.cjs +17 -0
  103. package/dist/middleware/index.cjs.map +1 -0
  104. package/dist/middleware/index.d.cts +29 -0
  105. package/dist/middleware/index.d.ts +29 -0
  106. package/dist/middleware/index.js +4 -0
  107. package/dist/middleware/index.js.map +1 -0
  108. package/dist/observability/index.cjs +29 -0
  109. package/dist/observability/index.cjs.map +1 -0
  110. package/dist/observability/index.d.cts +1 -0
  111. package/dist/observability/index.d.ts +1 -0
  112. package/dist/observability/index.js +4 -0
  113. package/dist/observability/index.js.map +1 -0
  114. package/dist/persistence/index.cjs +24 -0
  115. package/dist/persistence/index.cjs.map +1 -0
  116. package/dist/persistence/index.d.cts +51 -0
  117. package/dist/persistence/index.d.ts +51 -0
  118. package/dist/persistence/index.js +7 -0
  119. package/dist/persistence/index.js.map +1 -0
  120. package/dist/provider-CMAymr1b.d.cts +82 -0
  121. package/dist/provider-osAtfZ7x.d.ts +82 -0
  122. package/dist/providers/index.cjs +26 -0
  123. package/dist/providers/index.cjs.map +1 -0
  124. package/dist/providers/index.d.cts +107 -0
  125. package/dist/providers/index.d.ts +107 -0
  126. package/dist/providers/index.js +5 -0
  127. package/dist/providers/index.js.map +1 -0
  128. package/dist/registry-CpO0yH5v.d.ts +57 -0
  129. package/dist/registry-D4fThGiN.d.cts +57 -0
  130. package/dist/skill-DfNChtJN.d.cts +45 -0
  131. package/dist/skill-DfNChtJN.d.ts +45 -0
  132. package/dist/skills/index.cjs +20 -0
  133. package/dist/skills/index.cjs.map +1 -0
  134. package/dist/skills/index.d.cts +30 -0
  135. package/dist/skills/index.d.ts +30 -0
  136. package/dist/skills/index.js +3 -0
  137. package/dist/skills/index.js.map +1 -0
  138. package/dist/thread-CWVzTyti.d.ts +51 -0
  139. package/dist/thread-Dfo9LLf7.d.cts +51 -0
  140. package/dist/tool-BZg_znMZ.d.cts +50 -0
  141. package/dist/tool-CSCC87OD.d.ts +50 -0
  142. package/dist/tools/index.cjs +27 -0
  143. package/dist/tools/index.cjs.map +1 -0
  144. package/dist/tools/index.d.cts +21 -0
  145. package/dist/tools/index.d.ts +21 -0
  146. package/dist/tools/index.js +6 -0
  147. package/dist/tools/index.js.map +1 -0
  148. package/dist/types-Cn1g9Tg4.d.cts +63 -0
  149. package/dist/types-Cn1g9Tg4.d.ts +63 -0
  150. package/dist/workflows/index.cjs +50 -0
  151. package/dist/workflows/index.cjs.map +1 -0
  152. package/dist/workflows/index.d.cts +182 -0
  153. package/dist/workflows/index.d.ts +182 -0
  154. package/dist/workflows/index.js +5 -0
  155. package/dist/workflows/index.js.map +1 -0
  156. package/package.json +145 -0
@@ -0,0 +1,182 @@
1
+ import { A as Agent } from '../index-DdYZeNIu.cjs';
2
+ import '../types-Cn1g9Tg4.cjs';
3
+ import '../errors-CjVz4W_5.cjs';
4
+ import '../provider-CMAymr1b.cjs';
5
+ import '../tool-BZg_znMZ.cjs';
6
+ import '../skill-DfNChtJN.cjs';
7
+ import '../thread-Dfo9LLf7.cjs';
8
+ import '../registry-D4fThGiN.cjs';
9
+
10
+ /**
11
+ * Bounded-concurrency execution with a configurable failure policy for concurrent
12
+ * workflows. Fail-soft (default) aggregates partial results; fail-fast cancels
13
+ * remaining work on the first failure. (FR-019b, FR-019c)
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ /** How concurrent branches react to a failure. */
18
+ type FailurePolicy = "fail-soft" | "fail-fast";
19
+ /** Per-branch outcome under fail-soft. */
20
+ interface BranchResult<T> {
21
+ index: number;
22
+ value?: T;
23
+ error?: Error;
24
+ }
25
+ /**
26
+ * Run `tasks` with at most `maxConcurrency` in flight (-1 = unlimited).
27
+ *
28
+ * - `fail-soft`: every branch runs; failures are captured per-branch.
29
+ * - `fail-fast`: the first failure rejects and remaining branches are abandoned.
30
+ *
31
+ * @returns Per-branch results (always, including under fail-fast where the failing
32
+ * branch carries the error). Under fail-fast this throws on first failure.
33
+ */
34
+ declare function runBounded<T>(tasks: Array<() => Promise<T>>, maxConcurrency: number, policy: FailurePolicy): Promise<Array<BranchResult<T>>>;
35
+
36
+ /**
37
+ * Orchestration patterns: sequential, concurrent, handoff, and group collaboration.
38
+ * Each pattern advances a {@link WorkflowContext} by one round and reports whether
39
+ * the workflow is complete. (FR-019)
40
+ *
41
+ * @packageDocumentation
42
+ */
43
+
44
+ /** Supported orchestration patterns. */
45
+ type WorkflowPattern = "sequential" | "concurrent" | "handoff" | "group";
46
+ /** Mutable state threaded through pattern execution. */
47
+ interface WorkflowContext {
48
+ /** Latest combined output. */
49
+ output: string;
50
+ /** Per-agent latest outputs (by agent name). */
51
+ outputs: Record<string, string>;
52
+ /** Current round (0-based). */
53
+ round: number;
54
+ /** Index of the next agent (handoff/sequential). */
55
+ cursor: number;
56
+ /** Names of agents that errored this run (fail-soft). */
57
+ errors: Record<string, string>;
58
+ }
59
+ /** Hooks customizing pattern behavior. */
60
+ interface PatternHooks {
61
+ /** Returns true when an output signals the workflow is complete. (FR-019a) */
62
+ isComplete?: (output: string, ctx: WorkflowContext) => boolean;
63
+ /** For handoff: choose the next agent name from the latest output (or null to stop). */
64
+ selectNext?: (output: string, ctx: WorkflowContext) => string | null;
65
+ maxConcurrency?: number;
66
+ failurePolicy?: FailurePolicy;
67
+ }
68
+ /** One step's result. */
69
+ interface StepResult {
70
+ complete: boolean;
71
+ }
72
+ /** Advance a sequential workflow by one agent. */
73
+ declare function stepSequential(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
74
+ /** Run all agents concurrently on the same input and aggregate outputs. */
75
+ declare function stepConcurrent(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
76
+ /** Advance a handoff workflow: the current agent may delegate to another. */
77
+ declare function stepHandoff(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
78
+ /** Group collaboration: every agent contributes each round until complete. */
79
+ declare function stepGroup(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
80
+
81
+ /**
82
+ * Workflow checkpointing. A checkpoint is a serializable snapshot enabling resume.
83
+ * Restore fails closed: corrupt or version-mismatched data yields a typed
84
+ * {@link CheckpointError} with no partial restore. (FR-022, FR-022a)
85
+ *
86
+ * @packageDocumentation
87
+ */
88
+ /** Current checkpoint schema version. */
89
+ declare const CHECKPOINT_VERSION = "1";
90
+ /** A serializable workflow snapshot. */
91
+ interface Checkpoint {
92
+ version: string;
93
+ id: string;
94
+ /** Opaque workflow state (round, messages, pending node, etc.). */
95
+ state: Record<string, unknown>;
96
+ }
97
+ /** Create a checkpoint with the current schema version. */
98
+ declare function createCheckpoint(id: string, state: Record<string, unknown>): Checkpoint;
99
+ /** Serialize a checkpoint to a string. */
100
+ declare function serializeCheckpoint(cp: Checkpoint): string;
101
+ /**
102
+ * Restore a checkpoint from its serialized form or object. Fails closed.
103
+ *
104
+ * @throws {CheckpointError} `corrupt` if the data cannot be parsed/validated.
105
+ * @throws {CheckpointError} `version-mismatch` if the schema version differs.
106
+ */
107
+ declare function restoreCheckpoint(input: string | Checkpoint): Checkpoint;
108
+
109
+ /**
110
+ * The workflow engine: composes agents under an orchestration pattern with a
111
+ * completion signal and a configurable max-rounds safety cap, bounded concurrency,
112
+ * a failure policy, streaming, human-in-the-loop yield/resume, and checkpointing.
113
+ * (FR-018, FR-019, FR-019a, FR-019b, FR-019c, FR-020, FR-021, FR-021a, FR-021b, FR-022)
114
+ *
115
+ * @packageDocumentation
116
+ */
117
+
118
+ /** Lifecycle status of a workflow run, observable by the host. (FR-021b) */
119
+ type WorkflowStatus = "running" | "awaiting-input" | "completed" | "failed";
120
+ /** Configuration for {@link createWorkflow}. */
121
+ interface WorkflowConfig {
122
+ pattern: WorkflowPattern;
123
+ agents: Agent[];
124
+ /** Max rounds; -1 = unlimited. Default 16. (FR-019a) */
125
+ maxRounds?: number;
126
+ /** Concurrent failure policy. Default fail-soft. (FR-019b) */
127
+ failurePolicy?: FailurePolicy;
128
+ /** Max parallel agent calls; -1 = unlimited. Default 4. (FR-019c) */
129
+ maxConcurrency?: number;
130
+ /** Completion signal: end the workflow when this returns true. (FR-019a) */
131
+ isComplete?: (output: string, ctx: WorkflowContext) => boolean;
132
+ /** Handoff target selector. */
133
+ selectNext?: (output: string, ctx: WorkflowContext) => string | null;
134
+ /** Human-in-the-loop gate: when it returns a prompt, the workflow yields. (FR-021) */
135
+ humanInputGate?: (ctx: WorkflowContext) => string | null;
136
+ }
137
+ /** Serializable result/handle of a workflow run. (FR-021a, FR-022) */
138
+ interface WorkflowState {
139
+ status: WorkflowStatus;
140
+ output: string;
141
+ /** Present when status is `awaiting-input`. */
142
+ awaiting?: {
143
+ prompt: string;
144
+ };
145
+ /** Error message when status is `failed`. */
146
+ error?: string;
147
+ /** Snapshot enabling resume. */
148
+ checkpoint: Checkpoint;
149
+ }
150
+ /** Streamed workflow event. (FR-020) */
151
+ type WorkflowEvent = {
152
+ type: "round";
153
+ round: number;
154
+ output: string;
155
+ } | {
156
+ type: "awaiting-input";
157
+ prompt: string;
158
+ state: WorkflowState;
159
+ } | {
160
+ type: "done";
161
+ state: WorkflowState;
162
+ };
163
+ /** A runnable multi-agent workflow. */
164
+ interface Workflow {
165
+ run(input: string): Promise<WorkflowState>;
166
+ runStream(input: string): AsyncIterable<WorkflowEvent>;
167
+ resume(state: WorkflowState, humanInput?: string): Promise<WorkflowState>;
168
+ status(): WorkflowStatus;
169
+ }
170
+ /**
171
+ * Create a workflow.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * const wf = createWorkflow({ pattern: "sequential", agents: [researcher, summarizer] });
176
+ * let state = await wf.run("Summarize the notes.");
177
+ * if (state.status === "awaiting-input") state = await wf.resume(state, "approved");
178
+ * ```
179
+ */
180
+ declare function createWorkflow(config: WorkflowConfig): Workflow;
181
+
182
+ export { type BranchResult, CHECKPOINT_VERSION, type Checkpoint, type FailurePolicy, type PatternHooks, type StepResult, type Workflow, type WorkflowConfig, type WorkflowContext, type WorkflowEvent, type WorkflowPattern, type WorkflowState, type WorkflowStatus, createCheckpoint, createWorkflow, restoreCheckpoint, runBounded, serializeCheckpoint, stepConcurrent, stepGroup, stepHandoff, stepSequential };
@@ -0,0 +1,182 @@
1
+ import { A as Agent } from '../index-D7-znzrc.js';
2
+ import '../types-Cn1g9Tg4.js';
3
+ import '../errors-CjVz4W_5.js';
4
+ import '../provider-osAtfZ7x.js';
5
+ import '../tool-CSCC87OD.js';
6
+ import '../skill-DfNChtJN.js';
7
+ import '../thread-CWVzTyti.js';
8
+ import '../registry-CpO0yH5v.js';
9
+
10
+ /**
11
+ * Bounded-concurrency execution with a configurable failure policy for concurrent
12
+ * workflows. Fail-soft (default) aggregates partial results; fail-fast cancels
13
+ * remaining work on the first failure. (FR-019b, FR-019c)
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ /** How concurrent branches react to a failure. */
18
+ type FailurePolicy = "fail-soft" | "fail-fast";
19
+ /** Per-branch outcome under fail-soft. */
20
+ interface BranchResult<T> {
21
+ index: number;
22
+ value?: T;
23
+ error?: Error;
24
+ }
25
+ /**
26
+ * Run `tasks` with at most `maxConcurrency` in flight (-1 = unlimited).
27
+ *
28
+ * - `fail-soft`: every branch runs; failures are captured per-branch.
29
+ * - `fail-fast`: the first failure rejects and remaining branches are abandoned.
30
+ *
31
+ * @returns Per-branch results (always, including under fail-fast where the failing
32
+ * branch carries the error). Under fail-fast this throws on first failure.
33
+ */
34
+ declare function runBounded<T>(tasks: Array<() => Promise<T>>, maxConcurrency: number, policy: FailurePolicy): Promise<Array<BranchResult<T>>>;
35
+
36
+ /**
37
+ * Orchestration patterns: sequential, concurrent, handoff, and group collaboration.
38
+ * Each pattern advances a {@link WorkflowContext} by one round and reports whether
39
+ * the workflow is complete. (FR-019)
40
+ *
41
+ * @packageDocumentation
42
+ */
43
+
44
+ /** Supported orchestration patterns. */
45
+ type WorkflowPattern = "sequential" | "concurrent" | "handoff" | "group";
46
+ /** Mutable state threaded through pattern execution. */
47
+ interface WorkflowContext {
48
+ /** Latest combined output. */
49
+ output: string;
50
+ /** Per-agent latest outputs (by agent name). */
51
+ outputs: Record<string, string>;
52
+ /** Current round (0-based). */
53
+ round: number;
54
+ /** Index of the next agent (handoff/sequential). */
55
+ cursor: number;
56
+ /** Names of agents that errored this run (fail-soft). */
57
+ errors: Record<string, string>;
58
+ }
59
+ /** Hooks customizing pattern behavior. */
60
+ interface PatternHooks {
61
+ /** Returns true when an output signals the workflow is complete. (FR-019a) */
62
+ isComplete?: (output: string, ctx: WorkflowContext) => boolean;
63
+ /** For handoff: choose the next agent name from the latest output (or null to stop). */
64
+ selectNext?: (output: string, ctx: WorkflowContext) => string | null;
65
+ maxConcurrency?: number;
66
+ failurePolicy?: FailurePolicy;
67
+ }
68
+ /** One step's result. */
69
+ interface StepResult {
70
+ complete: boolean;
71
+ }
72
+ /** Advance a sequential workflow by one agent. */
73
+ declare function stepSequential(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
74
+ /** Run all agents concurrently on the same input and aggregate outputs. */
75
+ declare function stepConcurrent(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
76
+ /** Advance a handoff workflow: the current agent may delegate to another. */
77
+ declare function stepHandoff(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
78
+ /** Group collaboration: every agent contributes each round until complete. */
79
+ declare function stepGroup(agents: Agent[], ctx: WorkflowContext, input: string, hooks: PatternHooks): Promise<StepResult>;
80
+
81
+ /**
82
+ * Workflow checkpointing. A checkpoint is a serializable snapshot enabling resume.
83
+ * Restore fails closed: corrupt or version-mismatched data yields a typed
84
+ * {@link CheckpointError} with no partial restore. (FR-022, FR-022a)
85
+ *
86
+ * @packageDocumentation
87
+ */
88
+ /** Current checkpoint schema version. */
89
+ declare const CHECKPOINT_VERSION = "1";
90
+ /** A serializable workflow snapshot. */
91
+ interface Checkpoint {
92
+ version: string;
93
+ id: string;
94
+ /** Opaque workflow state (round, messages, pending node, etc.). */
95
+ state: Record<string, unknown>;
96
+ }
97
+ /** Create a checkpoint with the current schema version. */
98
+ declare function createCheckpoint(id: string, state: Record<string, unknown>): Checkpoint;
99
+ /** Serialize a checkpoint to a string. */
100
+ declare function serializeCheckpoint(cp: Checkpoint): string;
101
+ /**
102
+ * Restore a checkpoint from its serialized form or object. Fails closed.
103
+ *
104
+ * @throws {CheckpointError} `corrupt` if the data cannot be parsed/validated.
105
+ * @throws {CheckpointError} `version-mismatch` if the schema version differs.
106
+ */
107
+ declare function restoreCheckpoint(input: string | Checkpoint): Checkpoint;
108
+
109
+ /**
110
+ * The workflow engine: composes agents under an orchestration pattern with a
111
+ * completion signal and a configurable max-rounds safety cap, bounded concurrency,
112
+ * a failure policy, streaming, human-in-the-loop yield/resume, and checkpointing.
113
+ * (FR-018, FR-019, FR-019a, FR-019b, FR-019c, FR-020, FR-021, FR-021a, FR-021b, FR-022)
114
+ *
115
+ * @packageDocumentation
116
+ */
117
+
118
+ /** Lifecycle status of a workflow run, observable by the host. (FR-021b) */
119
+ type WorkflowStatus = "running" | "awaiting-input" | "completed" | "failed";
120
+ /** Configuration for {@link createWorkflow}. */
121
+ interface WorkflowConfig {
122
+ pattern: WorkflowPattern;
123
+ agents: Agent[];
124
+ /** Max rounds; -1 = unlimited. Default 16. (FR-019a) */
125
+ maxRounds?: number;
126
+ /** Concurrent failure policy. Default fail-soft. (FR-019b) */
127
+ failurePolicy?: FailurePolicy;
128
+ /** Max parallel agent calls; -1 = unlimited. Default 4. (FR-019c) */
129
+ maxConcurrency?: number;
130
+ /** Completion signal: end the workflow when this returns true. (FR-019a) */
131
+ isComplete?: (output: string, ctx: WorkflowContext) => boolean;
132
+ /** Handoff target selector. */
133
+ selectNext?: (output: string, ctx: WorkflowContext) => string | null;
134
+ /** Human-in-the-loop gate: when it returns a prompt, the workflow yields. (FR-021) */
135
+ humanInputGate?: (ctx: WorkflowContext) => string | null;
136
+ }
137
+ /** Serializable result/handle of a workflow run. (FR-021a, FR-022) */
138
+ interface WorkflowState {
139
+ status: WorkflowStatus;
140
+ output: string;
141
+ /** Present when status is `awaiting-input`. */
142
+ awaiting?: {
143
+ prompt: string;
144
+ };
145
+ /** Error message when status is `failed`. */
146
+ error?: string;
147
+ /** Snapshot enabling resume. */
148
+ checkpoint: Checkpoint;
149
+ }
150
+ /** Streamed workflow event. (FR-020) */
151
+ type WorkflowEvent = {
152
+ type: "round";
153
+ round: number;
154
+ output: string;
155
+ } | {
156
+ type: "awaiting-input";
157
+ prompt: string;
158
+ state: WorkflowState;
159
+ } | {
160
+ type: "done";
161
+ state: WorkflowState;
162
+ };
163
+ /** A runnable multi-agent workflow. */
164
+ interface Workflow {
165
+ run(input: string): Promise<WorkflowState>;
166
+ runStream(input: string): AsyncIterable<WorkflowEvent>;
167
+ resume(state: WorkflowState, humanInput?: string): Promise<WorkflowState>;
168
+ status(): WorkflowStatus;
169
+ }
170
+ /**
171
+ * Create a workflow.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * const wf = createWorkflow({ pattern: "sequential", agents: [researcher, summarizer] });
176
+ * let state = await wf.run("Summarize the notes.");
177
+ * if (state.status === "awaiting-input") state = await wf.resume(state, "approved");
178
+ * ```
179
+ */
180
+ declare function createWorkflow(config: WorkflowConfig): Workflow;
181
+
182
+ export { type BranchResult, CHECKPOINT_VERSION, type Checkpoint, type FailurePolicy, type PatternHooks, type StepResult, type Workflow, type WorkflowConfig, type WorkflowContext, type WorkflowEvent, type WorkflowPattern, type WorkflowState, type WorkflowStatus, createCheckpoint, createWorkflow, restoreCheckpoint, runBounded, serializeCheckpoint, stepConcurrent, stepGroup, stepHandoff, stepSequential };
@@ -0,0 +1,5 @@
1
+ export { CHECKPOINT_VERSION, createCheckpoint, createWorkflow, restoreCheckpoint, runBounded, serializeCheckpoint, stepConcurrent, stepGroup, stepHandoff, stepSequential } from '../chunk-T2GHJ5R4.js';
2
+ import '../chunk-IXV4UIF5.js';
3
+ import '../chunk-DEABART4.js';
4
+ //# sourceMappingURL=index.js.map
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json ADDED
@@ -0,0 +1,145 @@
1
+ {
2
+ "name": "agent-framework-js",
3
+ "version": "0.1.1",
4
+ "description": "Modular, tree-shakeable JavaScript/TypeScript agent framework for no-backend deployments (browser, edge, Node). Agents, tools, MCP, skills, multi-agent workflows, middleware, persistence, and OpenTelemetry observability.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Varun Anand Patkar",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Varun-Patkar/agent-framework-js.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/Varun-Patkar/agent-framework-js/issues"
14
+ },
15
+ "homepage": "https://github.com/Varun-Patkar/agent-framework-js#readme",
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "provenance": true
19
+ },
20
+ "sideEffects": false,
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "main": "./dist/index.cjs",
25
+ "module": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "require": "./dist/index.cjs"
32
+ },
33
+ "./agents": {
34
+ "types": "./dist/agents/index.d.ts",
35
+ "import": "./dist/agents/index.js",
36
+ "require": "./dist/agents/index.cjs"
37
+ },
38
+ "./providers": {
39
+ "types": "./dist/providers/index.d.ts",
40
+ "import": "./dist/providers/index.js",
41
+ "require": "./dist/providers/index.cjs"
42
+ },
43
+ "./tools": {
44
+ "types": "./dist/tools/index.d.ts",
45
+ "import": "./dist/tools/index.js",
46
+ "require": "./dist/tools/index.cjs"
47
+ },
48
+ "./mcp": {
49
+ "types": "./dist/mcp/index.d.ts",
50
+ "import": "./dist/mcp/index.js",
51
+ "require": "./dist/mcp/index.cjs"
52
+ },
53
+ "./skills": {
54
+ "types": "./dist/skills/index.d.ts",
55
+ "import": "./dist/skills/index.js",
56
+ "require": "./dist/skills/index.cjs"
57
+ },
58
+ "./workflows": {
59
+ "types": "./dist/workflows/index.d.ts",
60
+ "import": "./dist/workflows/index.js",
61
+ "require": "./dist/workflows/index.cjs"
62
+ },
63
+ "./middleware": {
64
+ "types": "./dist/middleware/index.d.ts",
65
+ "import": "./dist/middleware/index.js",
66
+ "require": "./dist/middleware/index.cjs"
67
+ },
68
+ "./persistence": {
69
+ "types": "./dist/persistence/index.d.ts",
70
+ "import": "./dist/persistence/index.js",
71
+ "require": "./dist/persistence/index.cjs"
72
+ },
73
+ "./observability": {
74
+ "types": "./dist/observability/index.d.ts",
75
+ "import": "./dist/observability/index.js",
76
+ "require": "./dist/observability/index.cjs"
77
+ },
78
+ "./declarative": {
79
+ "types": "./dist/declarative/index.d.ts",
80
+ "import": "./dist/declarative/index.js",
81
+ "require": "./dist/declarative/index.cjs"
82
+ }
83
+ },
84
+ "files": [
85
+ "dist",
86
+ "README.md",
87
+ "AGENT_USAGE.md",
88
+ "LICENSE"
89
+ ],
90
+ "scripts": {
91
+ "build": "tsup",
92
+ "typecheck": "tsc --noEmit",
93
+ "test": "vitest run",
94
+ "test:watch": "vitest",
95
+ "lint": "eslint .",
96
+ "format": "prettier --write .",
97
+ "audit": "npm audit --audit-level=high",
98
+ "prepublishOnly": "npm run lint && npm run typecheck && npm test && npm run build"
99
+ },
100
+ "keywords": [
101
+ "agent",
102
+ "agents",
103
+ "ai",
104
+ "llm",
105
+ "mcp",
106
+ "orchestration",
107
+ "workflows",
108
+ "openai",
109
+ "copilot",
110
+ "no-backend",
111
+ "edge"
112
+ ],
113
+ "dependencies": {
114
+ "ajv": "^8.17.1"
115
+ },
116
+ "peerDependencies": {
117
+ "@modelcontextprotocol/sdk": "^1.0.0",
118
+ "@opentelemetry/api": "^1.9.0",
119
+ "yaml": "^2.5.0"
120
+ },
121
+ "peerDependenciesMeta": {
122
+ "@modelcontextprotocol/sdk": {
123
+ "optional": true
124
+ },
125
+ "@opentelemetry/api": {
126
+ "optional": true
127
+ },
128
+ "yaml": {
129
+ "optional": true
130
+ }
131
+ },
132
+ "devDependencies": {
133
+ "@modelcontextprotocol/sdk": "^1.0.0",
134
+ "@opentelemetry/api": "^1.9.0",
135
+ "@types/node": "^20.14.0",
136
+ "@typescript-eslint/eslint-plugin": "^7.16.0",
137
+ "@typescript-eslint/parser": "^7.16.0",
138
+ "eslint": "^8.57.0",
139
+ "prettier": "^3.3.0",
140
+ "tsup": "^8.2.0",
141
+ "typescript": "^5.5.0",
142
+ "vitest": "^2.0.0",
143
+ "yaml": "^2.5.0"
144
+ }
145
+ }