@ariaflowagents/core 0.1.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.
Files changed (134) hide show
  1. package/README.md +39 -0
  2. package/dist/agents/Agent.d.ts +15 -0
  3. package/dist/agents/Agent.d.ts.map +1 -0
  4. package/dist/agents/Agent.js +33 -0
  5. package/dist/agents/Agent.js.map +1 -0
  6. package/dist/agents/CompositeAgent.d.ts +24 -0
  7. package/dist/agents/CompositeAgent.d.ts.map +1 -0
  8. package/dist/agents/CompositeAgent.js +59 -0
  9. package/dist/agents/CompositeAgent.js.map +1 -0
  10. package/dist/agents/FlowAgent.d.ts +11 -0
  11. package/dist/agents/FlowAgent.d.ts.map +1 -0
  12. package/dist/agents/FlowAgent.js +44 -0
  13. package/dist/agents/FlowAgent.js.map +1 -0
  14. package/dist/agents/LLMAgent.d.ts +11 -0
  15. package/dist/agents/LLMAgent.d.ts.map +1 -0
  16. package/dist/agents/LLMAgent.js +52 -0
  17. package/dist/agents/LLMAgent.js.map +1 -0
  18. package/dist/agents/TriageAgent.d.ts +11 -0
  19. package/dist/agents/TriageAgent.d.ts.map +1 -0
  20. package/dist/agents/TriageAgent.js +89 -0
  21. package/dist/agents/TriageAgent.js.map +1 -0
  22. package/dist/agents/index.d.ts +7 -0
  23. package/dist/agents/index.d.ts.map +1 -0
  24. package/dist/agents/index.js +6 -0
  25. package/dist/agents/index.js.map +1 -0
  26. package/dist/flows/AgentFlowManager.d.ts +154 -0
  27. package/dist/flows/AgentFlowManager.d.ts.map +1 -0
  28. package/dist/flows/AgentFlowManager.js +272 -0
  29. package/dist/flows/AgentFlowManager.js.map +1 -0
  30. package/dist/flows/FlowGraph.d.ts +23 -0
  31. package/dist/flows/FlowGraph.d.ts.map +1 -0
  32. package/dist/flows/FlowGraph.js +57 -0
  33. package/dist/flows/FlowGraph.js.map +1 -0
  34. package/dist/flows/FlowManager.d.ts +36 -0
  35. package/dist/flows/FlowManager.d.ts.map +1 -0
  36. package/dist/flows/FlowManager.js +256 -0
  37. package/dist/flows/FlowManager.js.map +1 -0
  38. package/dist/flows/FlowNode.d.ts +8 -0
  39. package/dist/flows/FlowNode.d.ts.map +1 -0
  40. package/dist/flows/FlowNode.js +12 -0
  41. package/dist/flows/FlowNode.js.map +1 -0
  42. package/dist/flows/index.d.ts +8 -0
  43. package/dist/flows/index.d.ts.map +1 -0
  44. package/dist/flows/index.js +6 -0
  45. package/dist/flows/index.js.map +1 -0
  46. package/dist/flows/transitions.d.ts +9 -0
  47. package/dist/flows/transitions.d.ts.map +1 -0
  48. package/dist/flows/transitions.js +15 -0
  49. package/dist/flows/transitions.js.map +1 -0
  50. package/dist/guards/StopConditions.d.ts +14 -0
  51. package/dist/guards/StopConditions.d.ts.map +1 -0
  52. package/dist/guards/StopConditions.js +161 -0
  53. package/dist/guards/StopConditions.js.map +1 -0
  54. package/dist/guards/ToolEnforcer.d.ts +11 -0
  55. package/dist/guards/ToolEnforcer.d.ts.map +1 -0
  56. package/dist/guards/ToolEnforcer.js +40 -0
  57. package/dist/guards/ToolEnforcer.js.map +1 -0
  58. package/dist/guards/index.d.ts +4 -0
  59. package/dist/guards/index.d.ts.map +1 -0
  60. package/dist/guards/index.js +4 -0
  61. package/dist/guards/index.js.map +1 -0
  62. package/dist/guards/rules.d.ts +8 -0
  63. package/dist/guards/rules.d.ts.map +1 -0
  64. package/dist/guards/rules.js +128 -0
  65. package/dist/guards/rules.js.map +1 -0
  66. package/dist/hooks/HookRunner.d.ts +30 -0
  67. package/dist/hooks/HookRunner.d.ts.map +1 -0
  68. package/dist/hooks/HookRunner.js +85 -0
  69. package/dist/hooks/HookRunner.js.map +1 -0
  70. package/dist/hooks/builtin/logging.d.ts +6 -0
  71. package/dist/hooks/builtin/logging.d.ts.map +1 -0
  72. package/dist/hooks/builtin/logging.js +99 -0
  73. package/dist/hooks/builtin/logging.js.map +1 -0
  74. package/dist/hooks/builtin/metrics.d.ts +38 -0
  75. package/dist/hooks/builtin/metrics.d.ts.map +1 -0
  76. package/dist/hooks/builtin/metrics.js +111 -0
  77. package/dist/hooks/builtin/metrics.js.map +1 -0
  78. package/dist/hooks/index.d.ts +5 -0
  79. package/dist/hooks/index.d.ts.map +1 -0
  80. package/dist/hooks/index.js +4 -0
  81. package/dist/hooks/index.js.map +1 -0
  82. package/dist/index.d.ts +30 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +23 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/runtime/InjectionQueue.d.ts +46 -0
  87. package/dist/runtime/InjectionQueue.d.ts.map +1 -0
  88. package/dist/runtime/InjectionQueue.js +128 -0
  89. package/dist/runtime/InjectionQueue.js.map +1 -0
  90. package/dist/runtime/Runtime.d.ts +24 -0
  91. package/dist/runtime/Runtime.d.ts.map +1 -0
  92. package/dist/runtime/Runtime.js +277 -0
  93. package/dist/runtime/Runtime.js.map +1 -0
  94. package/dist/runtime/WorkingMemory.d.ts +12 -0
  95. package/dist/runtime/WorkingMemory.d.ts.map +1 -0
  96. package/dist/runtime/WorkingMemory.js +29 -0
  97. package/dist/runtime/WorkingMemory.js.map +1 -0
  98. package/dist/runtime/index.d.ts +4 -0
  99. package/dist/runtime/index.d.ts.map +1 -0
  100. package/dist/runtime/index.js +4 -0
  101. package/dist/runtime/index.js.map +1 -0
  102. package/dist/session/SessionManager.d.ts +20 -0
  103. package/dist/session/SessionManager.d.ts.map +1 -0
  104. package/dist/session/SessionManager.js +134 -0
  105. package/dist/session/SessionManager.js.map +1 -0
  106. package/dist/session/SessionStore.d.ts +9 -0
  107. package/dist/session/SessionStore.d.ts.map +1 -0
  108. package/dist/session/SessionStore.js +2 -0
  109. package/dist/session/SessionStore.js.map +1 -0
  110. package/dist/session/index.d.ts +4 -0
  111. package/dist/session/index.d.ts.map +1 -0
  112. package/dist/session/index.js +3 -0
  113. package/dist/session/index.js.map +1 -0
  114. package/dist/session/stores/MemoryStore.d.ts +11 -0
  115. package/dist/session/stores/MemoryStore.d.ts.map +1 -0
  116. package/dist/session/stores/MemoryStore.js +34 -0
  117. package/dist/session/stores/MemoryStore.js.map +1 -0
  118. package/dist/tools/Tool.d.ts +10 -0
  119. package/dist/tools/Tool.d.ts.map +1 -0
  120. package/dist/tools/Tool.js +2 -0
  121. package/dist/tools/Tool.js.map +1 -0
  122. package/dist/tools/handoff.d.ts +25 -0
  123. package/dist/tools/handoff.d.ts.map +1 -0
  124. package/dist/tools/handoff.js +51 -0
  125. package/dist/tools/handoff.js.map +1 -0
  126. package/dist/tools/index.d.ts +4 -0
  127. package/dist/tools/index.d.ts.map +1 -0
  128. package/dist/tools/index.js +2 -0
  129. package/dist/tools/index.js.map +1 -0
  130. package/dist/types/index.d.ts +325 -0
  131. package/dist/types/index.d.ts.map +1 -0
  132. package/dist/types/index.js +2 -0
  133. package/dist/types/index.js.map +1 -0
  134. package/package.json +71 -0
@@ -0,0 +1,256 @@
1
+ import { streamText, generateText } from 'ai';
2
+ import { isFlowTransition } from './transitions.js';
3
+ export class FlowManager {
4
+ config;
5
+ nodes = new Map();
6
+ transitions = new Map();
7
+ context;
8
+ currentNodeConfig = null;
9
+ initialized = false;
10
+ pendingEvents = [];
11
+ flowEnded = false;
12
+ sessionMessages;
13
+ constructor(config) {
14
+ this.config = config;
15
+ for (const node of config.flow.nodes) {
16
+ this.nodes.set(node.id, node);
17
+ }
18
+ for (const transition of config.flow.transitions ?? []) {
19
+ const existing = this.transitions.get(transition.from) ?? [];
20
+ existing.push(transition);
21
+ this.transitions.set(transition.from, existing);
22
+ }
23
+ this.context = {
24
+ currentNode: config.initialNode,
25
+ collectedData: {},
26
+ nodeHistory: [],
27
+ nodeTurnCounts: {},
28
+ messages: config.contextMessages ?? [],
29
+ };
30
+ this.sessionMessages = config.sessionMessages;
31
+ }
32
+ async *initialize() {
33
+ if (this.initialized) {
34
+ return;
35
+ }
36
+ yield* this.transitionToGenerator(this.config.initialNode);
37
+ this.initialized = true;
38
+ if (this.currentNodeConfig?.autoRespond !== false) {
39
+ yield* this.runInference();
40
+ }
41
+ }
42
+ async *process(userInput) {
43
+ if (!this.initialized) {
44
+ throw new Error('Flow not initialized. Call initialize() first.');
45
+ }
46
+ if (this.flowEnded) {
47
+ yield { type: 'error', error: 'Flow has ended' };
48
+ return;
49
+ }
50
+ if (!this.currentNodeConfig) {
51
+ yield { type: 'error', error: 'No current node' };
52
+ return;
53
+ }
54
+ this.appendMessage({ role: 'user', content: userInput });
55
+ const nodeId = this.currentNodeConfig.id;
56
+ this.context.nodeTurnCounts[nodeId] = (this.context.nodeTurnCounts[nodeId] ?? 0) + 1;
57
+ if (this.currentNodeConfig.maxTurns && this.context.nodeTurnCounts[nodeId] > this.currentNodeConfig.maxTurns) {
58
+ yield { type: 'error', error: `Max turns exceeded for node "${nodeId}"` };
59
+ return;
60
+ }
61
+ yield* this.runInference();
62
+ yield { type: 'turn-end' };
63
+ }
64
+ async transitionTo(nodeId, data) {
65
+ for await (const _part of this.transitionToGenerator(nodeId, data)) {
66
+ // consume parts
67
+ }
68
+ }
69
+ async *transitionToGenerator(nodeId, data) {
70
+ const nextNode = this.nodes.get(nodeId);
71
+ if (!nextNode) {
72
+ throw new Error(`Node "${nodeId}" not found`);
73
+ }
74
+ const previousNode = this.currentNodeConfig;
75
+ if (previousNode) {
76
+ yield* this.runActions(previousNode.postActions ?? []);
77
+ yield { type: 'node-exit', nodeName: previousNode.name ?? previousNode.id };
78
+ }
79
+ this.currentNodeConfig = nextNode;
80
+ this.context.currentNode = nodeId;
81
+ this.context.nodeHistory.push(nodeId);
82
+ if (data) {
83
+ Object.assign(this.context.collectedData, data);
84
+ }
85
+ await this.applyContextStrategy(nextNode);
86
+ yield { type: 'node-enter', nodeName: nextNode.name ?? nextNode.id };
87
+ yield* this.runActions(nextNode.preActions ?? []);
88
+ if (previousNode) {
89
+ yield { type: 'flow-transition', from: previousNode.id, to: nextNode.id };
90
+ }
91
+ }
92
+ get collectedData() {
93
+ return this.context.collectedData;
94
+ }
95
+ get currentNode() {
96
+ return this.currentNodeConfig?.id;
97
+ }
98
+ async *runInference() {
99
+ if (!this.currentNodeConfig) {
100
+ return;
101
+ }
102
+ const node = this.currentNodeConfig;
103
+ const systemPrompt = this.buildSystemPrompt(node);
104
+ const tools = {
105
+ ...(node.tools ?? {}),
106
+ };
107
+ const streamConfig = {
108
+ model: this.config.model,
109
+ system: systemPrompt,
110
+ tools,
111
+ };
112
+ if (this.context.messages.length === 0) {
113
+ streamConfig.prompt = 'Generate the greeting for this conversation.';
114
+ }
115
+ else {
116
+ streamConfig.messages = this.context.messages;
117
+ }
118
+ const result = streamText(streamConfig);
119
+ let pendingTransition = null;
120
+ for await (const chunk of result.fullStream) {
121
+ if (chunk.type === 'text-delta') {
122
+ yield { type: 'text-delta', text: chunk.text };
123
+ }
124
+ if (chunk.type === 'tool-call') {
125
+ const args = 'args' in chunk ? chunk.args : chunk.input;
126
+ yield { type: 'tool-call', toolName: chunk.toolName, args };
127
+ }
128
+ if (chunk.type === 'tool-result') {
129
+ const toolResult = 'result' in chunk ? chunk.result : chunk.output;
130
+ yield { type: 'tool-result', toolName: chunk.toolName, result: toolResult };
131
+ if (isFlowTransition(toolResult)) {
132
+ pendingTransition = {
133
+ targetNode: toolResult.targetNode,
134
+ data: toolResult.data,
135
+ };
136
+ }
137
+ }
138
+ }
139
+ const response = await result.response;
140
+ for (const message of response.messages) {
141
+ this.appendMessage(message);
142
+ }
143
+ const nextTransition = pendingTransition ?? (await this.evaluateTransitions());
144
+ if (nextTransition) {
145
+ yield* this.transitionToGenerator(nextTransition.targetNode, nextTransition.data);
146
+ if (this.currentNodeConfig?.autoRespond !== false) {
147
+ yield* this.runInference();
148
+ }
149
+ }
150
+ if (node.postActions?.some(action => action.type === 'end')) {
151
+ this.flowEnded = true;
152
+ yield { type: 'flow-end', reason: 'post-action' };
153
+ }
154
+ }
155
+ buildSystemPrompt(node) {
156
+ const rolePrompt = this.config.defaultRolePrompt ?? this.config.flow.defaultRolePrompt ?? '';
157
+ const dataKeys = Object.keys(this.context.collectedData);
158
+ const dataContext = dataKeys.length > 0
159
+ ? `\n\n## Collected Information\n${JSON.stringify(this.context.collectedData, null, 2)}`
160
+ : '';
161
+ const historyContext = this.context.nodeHistory.length > 1
162
+ ? `\n\n## Progress\n${this.context.nodeHistory.slice(0, -1).join(' -> ')} -> **${node.name ?? node.id}**`
163
+ : '';
164
+ return `${rolePrompt}
165
+
166
+ ## Current Task
167
+ ${node.prompt}${dataContext}${historyContext}
168
+
169
+ ## Instructions
170
+ - Focus only on the current task
171
+ - Use the available tools to progress the conversation
172
+ - Do not attempt tasks outside your current scope`;
173
+ }
174
+ async applyContextStrategy(node) {
175
+ const strategy = node.contextStrategy ?? this.config.flow.contextStrategy ?? 'append';
176
+ switch (strategy) {
177
+ case 'reset':
178
+ this.context.messages = [];
179
+ break;
180
+ case 'reset_with_summary':
181
+ if (this.context.messages.length > 0) {
182
+ const summary = await this.generateSummary();
183
+ this.context.messages = [
184
+ { role: 'system', content: `Previous conversation summary: ${summary}` },
185
+ ];
186
+ }
187
+ break;
188
+ case 'append':
189
+ default:
190
+ break;
191
+ }
192
+ }
193
+ async generateSummary() {
194
+ const prompt = 'Summarize the key points from this conversation in 2-3 sentences.';
195
+ const result = await generateText({
196
+ model: this.config.model,
197
+ system: prompt,
198
+ messages: this.context.messages,
199
+ });
200
+ return result.text;
201
+ }
202
+ appendMessage(message) {
203
+ this.context.messages.push(message);
204
+ if (this.sessionMessages && this.sessionMessages !== this.context.messages) {
205
+ this.sessionMessages.push(message);
206
+ }
207
+ }
208
+ async *runActions(actions) {
209
+ for (const action of actions) {
210
+ switch (action.type) {
211
+ case 'say':
212
+ yield { type: 'text-delta', text: action.text };
213
+ break;
214
+ case 'end':
215
+ this.flowEnded = true;
216
+ yield { type: 'flow-end', reason: action.reason ?? 'action' };
217
+ break;
218
+ case 'function':
219
+ await action.handler(this.context);
220
+ break;
221
+ case 'emit':
222
+ this.pendingEvents.push({ name: action.event, data: action.data });
223
+ break;
224
+ default:
225
+ break;
226
+ }
227
+ }
228
+ }
229
+ async evaluateTransitions() {
230
+ const currentNode = this.currentNodeConfig?.id;
231
+ if (!currentNode) {
232
+ return null;
233
+ }
234
+ const transitions = this.transitions.get(currentNode) ?? [];
235
+ if (this.pendingEvents.length > 0) {
236
+ for (const [index, event] of this.pendingEvents.entries()) {
237
+ const match = transitions.find(transition => transition.on === event.name);
238
+ if (match) {
239
+ this.pendingEvents.splice(index, 1);
240
+ return { targetNode: match.to, data: event.data };
241
+ }
242
+ }
243
+ }
244
+ for (const transition of transitions) {
245
+ if (!transition.condition) {
246
+ continue;
247
+ }
248
+ const shouldTransition = await transition.condition(this.context);
249
+ if (shouldTransition) {
250
+ return { targetNode: transition.to };
251
+ }
252
+ }
253
+ return null;
254
+ }
255
+ }
256
+ //# sourceMappingURL=FlowManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowManager.js","sourceRoot":"","sources":["../../src/flows/FlowManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuD,MAAM,IAAI,CAAC;AAUnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAapD,MAAM,OAAO,WAAW;IAUF;IATZ,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC1C,WAAW,GAAG,IAAI,GAAG,EAAkC,CAAC;IACxD,OAAO,CAAc;IACrB,iBAAiB,GAA0B,IAAI,CAAC;IAChD,WAAW,GAAG,KAAK,CAAC;IACpB,aAAa,GAAmB,EAAE,CAAC;IACnC,SAAS,GAAG,KAAK,CAAC;IAClB,eAAe,CAAkB;IAEzC,YAAoB,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAC3C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC;QAED,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C,EAAE,CAAC;gBAC3F,CAAC;YACH,CAAC;QACH,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;gBAC1B,SAAS;YACX,CAAC;YACD,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAClE,IAAI,gBAAgB,EAAE,CAAC;gBACrB,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { FlowNodeConfig } from '../types/index.js';
2
+ export declare class FlowNode {
3
+ readonly id: string;
4
+ readonly config: FlowNodeConfig;
5
+ constructor(config: FlowNodeConfig);
6
+ toConfig(): FlowNodeConfig;
7
+ }
8
+ //# sourceMappingURL=FlowNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowNode.d.ts","sourceRoot":"","sources":["../../src/flows/FlowNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,qBAAa,QAAQ;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;gBAEpB,MAAM,EAAE,cAAc;IAKlC,QAAQ,IAAI,cAAc;CAG3B"}
@@ -0,0 +1,12 @@
1
+ export class FlowNode {
2
+ id;
3
+ config;
4
+ constructor(config) {
5
+ this.id = config.id;
6
+ this.config = config;
7
+ }
8
+ toConfig() {
9
+ return { ...this.config };
10
+ }
11
+ }
12
+ //# sourceMappingURL=FlowNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowNode.js","sourceRoot":"","sources":["../../src/flows/FlowNode.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;IACV,EAAE,CAAS;IACX,MAAM,CAAiB;IAEhC,YAAY,MAAsB;QAChC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,QAAQ;QACN,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export { FlowManager } from './FlowManager.js';
2
+ export { FlowGraph, FlowGraphBuilder } from './FlowGraph.js';
3
+ export { FlowNode } from './FlowNode.js';
4
+ export { createFlowTransition, isFlowTransition } from './transitions.js';
5
+ export type { FlowManagerConfig } from './FlowManager.js';
6
+ export { AgentFlowManager, ContextStrategy, createCollectorTool, } from './AgentFlowManager.js';
7
+ export type { FlowManagerConfig as AgentFlowManagerConfig, FlowNodeConfig, FlowContext, FlowHooks, FlowAction, FlowStreamPart, ContextStrategyConfig, } from './AgentFlowManager.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,iBAAiB,IAAI,sBAAsB,EAC3C,cAAc,EACd,WAAW,EACX,SAAS,EACT,UAAU,EACV,cAAc,EACd,qBAAqB,GACtB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { FlowManager } from './FlowManager.js';
2
+ export { FlowGraph, FlowGraphBuilder } from './FlowGraph.js';
3
+ export { FlowNode } from './FlowNode.js';
4
+ export { createFlowTransition, isFlowTransition } from './transitions.js';
5
+ export { AgentFlowManager, ContextStrategy, createCollectorTool, } from './AgentFlowManager.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface FlowTransitionSignal {
2
+ __flow_transition: true;
3
+ targetNode: string;
4
+ data?: Record<string, unknown>;
5
+ message?: string;
6
+ }
7
+ export declare function createFlowTransition(targetNode: string, data?: Record<string, unknown>, message?: string): FlowTransitionSignal;
8
+ export declare function isFlowTransition(result: unknown): result is FlowTransitionSignal;
9
+ //# sourceMappingURL=transitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../src/flows/transitions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,iBAAiB,EAAE,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,MAAM,GACf,oBAAoB,CAOtB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,oBAAoB,CAOhF"}
@@ -0,0 +1,15 @@
1
+ export function createFlowTransition(targetNode, data, message) {
2
+ return {
3
+ __flow_transition: true,
4
+ targetNode,
5
+ data,
6
+ message,
7
+ };
8
+ }
9
+ export function isFlowTransition(result) {
10
+ return (typeof result === 'object' &&
11
+ result !== null &&
12
+ '__flow_transition' in result &&
13
+ result.__flow_transition === true);
14
+ }
15
+ //# sourceMappingURL=transitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitions.js","sourceRoot":"","sources":["../../src/flows/transitions.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,IAA8B,EAC9B,OAAgB;IAEhB,OAAO;QACL,iBAAiB,EAAE,IAAI;QACvB,UAAU;QACV,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,mBAAmB,IAAI,MAAM;QAC5B,MAAyC,CAAC,iBAAiB,KAAK,IAAI,CACtE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { RunContext, StopCondition, StopConditionResult } from '../types/index.js';
2
+ export declare function maxSteps(n: number): StopCondition;
3
+ export declare function tokenBudget(budget: number): StopCondition;
4
+ export declare function timeout(ms: number): StopCondition;
5
+ export declare function consecutiveErrors(n: number): StopCondition;
6
+ export declare function loopDetection(windowSize?: number): StopCondition;
7
+ export declare function sameToolRepetition(maxRepeats?: number): StopCondition;
8
+ export declare function maxHandoffs(n: number): StopCondition;
9
+ export declare function taskComplete(phrases: string[]): StopCondition;
10
+ export declare function anyOf(...conditions: StopCondition[]): StopCondition;
11
+ export declare function allOf(...conditions: StopCondition[]): StopCondition;
12
+ export declare const defaultStopConditions: StopCondition[];
13
+ export declare function checkStopConditions(context: RunContext, conditions: StopCondition[]): StopConditionResult;
14
+ //# sourceMappingURL=StopConditions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StopConditions.d.ts","sourceRoot":"","sources":["../../src/guards/StopConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAQjD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAUzD;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAWjD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAU1D;AAED,wBAAgB,aAAa,CAAC,UAAU,GAAE,MAAU,GAAG,aAAa,CAuBnE;AAED,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,MAAU,GAAG,aAAa,CAoBxE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAUpD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,aAAa,CAsB7D;AAED,wBAAgB,KAAK,CAAC,GAAG,UAAU,EAAE,aAAa,EAAE,GAAG,aAAa,CAanE;AAED,wBAAgB,KAAK,CAAC,GAAG,UAAU,EAAE,aAAa,EAAE,GAAG,aAAa,CAiBnE;AAED,eAAO,MAAM,qBAAqB,EAAE,aAAa,EAOhD,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,aAAa,EAAE,GAC1B,mBAAmB,CAQrB"}
@@ -0,0 +1,161 @@
1
+ export function maxSteps(n) {
2
+ return {
3
+ name: `maxSteps(${n})`,
4
+ check: (context) => ({
5
+ shouldStop: context.stepCount >= n,
6
+ reason: context.stepCount >= n ? `Reached maximum steps (${n})` : undefined,
7
+ }),
8
+ };
9
+ }
10
+ export function tokenBudget(budget) {
11
+ return {
12
+ name: `tokenBudget(${budget})`,
13
+ check: (context) => ({
14
+ shouldStop: context.totalTokens >= budget,
15
+ reason: context.totalTokens >= budget
16
+ ? `Token budget exceeded (${context.totalTokens}/${budget})`
17
+ : undefined,
18
+ }),
19
+ };
20
+ }
21
+ export function timeout(ms) {
22
+ return {
23
+ name: `timeout(${ms}ms)`,
24
+ check: (context) => {
25
+ const elapsed = Date.now() - context.startTime;
26
+ return {
27
+ shouldStop: elapsed >= ms,
28
+ reason: elapsed >= ms ? `Timeout after ${ms}ms` : undefined,
29
+ };
30
+ },
31
+ };
32
+ }
33
+ export function consecutiveErrors(n) {
34
+ return {
35
+ name: `consecutiveErrors(${n})`,
36
+ check: (context) => ({
37
+ shouldStop: context.consecutiveErrors >= n,
38
+ reason: context.consecutiveErrors >= n
39
+ ? `Too many consecutive errors (${n})`
40
+ : undefined,
41
+ }),
42
+ };
43
+ }
44
+ export function loopDetection(windowSize = 5) {
45
+ return {
46
+ name: `loopDetection(${windowSize})`,
47
+ check: (context) => {
48
+ const history = context.toolCallHistory;
49
+ if (history.length < windowSize * 2) {
50
+ return { shouldStop: false };
51
+ }
52
+ const recent = history.slice(-windowSize);
53
+ const previous = history.slice(-windowSize * 2, -windowSize);
54
+ const recentPattern = recent.map(call => `${call.toolName}:${JSON.stringify(call.args)}`).join('|');
55
+ const previousPattern = previous.map(call => `${call.toolName}:${JSON.stringify(call.args)}`).join('|');
56
+ const isLoop = recentPattern === previousPattern;
57
+ return {
58
+ shouldStop: isLoop,
59
+ reason: isLoop ? 'Detected repetitive loop pattern' : undefined,
60
+ };
61
+ },
62
+ };
63
+ }
64
+ export function sameToolRepetition(maxRepeats = 3) {
65
+ return {
66
+ name: `sameToolRepetition(${maxRepeats})`,
67
+ check: (context) => {
68
+ const history = context.toolCallHistory;
69
+ if (history.length < maxRepeats) {
70
+ return { shouldStop: false };
71
+ }
72
+ const recent = history.slice(-maxRepeats);
73
+ const allSameTool = recent.every(call => call.toolName === recent[0].toolName);
74
+ return {
75
+ shouldStop: allSameTool,
76
+ reason: allSameTool
77
+ ? `Tool "${recent[0].toolName}" called ${maxRepeats} times in a row`
78
+ : undefined,
79
+ };
80
+ },
81
+ };
82
+ }
83
+ export function maxHandoffs(n) {
84
+ return {
85
+ name: `maxHandoffs(${n})`,
86
+ check: (context) => ({
87
+ shouldStop: context.handoffStack.length >= n,
88
+ reason: context.handoffStack.length >= n
89
+ ? `Maximum handoffs exceeded (${n})`
90
+ : undefined,
91
+ }),
92
+ };
93
+ }
94
+ export function taskComplete(phrases) {
95
+ return {
96
+ name: 'taskComplete',
97
+ check: (context) => {
98
+ const lastMessage = context.session.messages[context.session.messages.length - 1];
99
+ if (!lastMessage || lastMessage.role !== 'assistant') {
100
+ return { shouldStop: false };
101
+ }
102
+ const content = typeof lastMessage.content === 'string'
103
+ ? lastMessage.content
104
+ : JSON.stringify(lastMessage.content);
105
+ const lower = content.toLowerCase();
106
+ const found = phrases.some(phrase => lower.includes(phrase.toLowerCase()));
107
+ return {
108
+ shouldStop: found,
109
+ reason: found ? 'Task completed successfully' : undefined,
110
+ };
111
+ },
112
+ };
113
+ }
114
+ export function anyOf(...conditions) {
115
+ return {
116
+ name: `anyOf(${conditions.map(condition => condition.name).join(', ')})`,
117
+ check: (context) => {
118
+ for (const condition of conditions) {
119
+ const result = condition.check(context);
120
+ if (result.shouldStop) {
121
+ return result;
122
+ }
123
+ }
124
+ return { shouldStop: false };
125
+ },
126
+ };
127
+ }
128
+ export function allOf(...conditions) {
129
+ return {
130
+ name: `allOf(${conditions.map(condition => condition.name).join(', ')})`,
131
+ check: (context) => {
132
+ const results = conditions.map(condition => condition.check(context));
133
+ const allMet = results.every(result => result.shouldStop);
134
+ if (allMet) {
135
+ return {
136
+ shouldStop: true,
137
+ reason: results.map(result => result.reason).filter(Boolean).join('; '),
138
+ };
139
+ }
140
+ return { shouldStop: false };
141
+ },
142
+ };
143
+ }
144
+ export const defaultStopConditions = [
145
+ maxSteps(20),
146
+ tokenBudget(100000),
147
+ timeout(120000),
148
+ consecutiveErrors(3),
149
+ loopDetection(5),
150
+ maxHandoffs(10),
151
+ ];
152
+ export function checkStopConditions(context, conditions) {
153
+ for (const condition of conditions) {
154
+ const result = condition.check(context);
155
+ if (result.shouldStop) {
156
+ return result;
157
+ }
158
+ }
159
+ return { shouldStop: false };
160
+ }
161
+ //# sourceMappingURL=StopConditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StopConditions.js","sourceRoot":"","sources":["../../src/guards/StopConditions.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO;QACL,IAAI,EAAE,YAAY,CAAC,GAAG;QACtB,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACnB,UAAU,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;YAClC,MAAM,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;SAC5E,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO;QACL,IAAI,EAAE,eAAe,MAAM,GAAG;QAC9B,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACnB,UAAU,EAAE,OAAO,CAAC,WAAW,IAAI,MAAM;YACzC,MAAM,EAAE,OAAO,CAAC,WAAW,IAAI,MAAM;gBACnC,CAAC,CAAC,0BAA0B,OAAO,CAAC,WAAW,IAAI,MAAM,GAAG;gBAC5D,CAAC,CAAC,SAAS;SACd,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO;QACL,IAAI,EAAE,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CAAC,IAAI,CAAC,IAAI,CAAC;iBACxE,CAAC;YACJ,CAAC;YAED,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAoB;IACpD,QAAQ,CAAC,EAAE,CAAC;IACZ,WAAW,CAAC,MAAM,CAAC;IACnB,OAAO,CAAC,MAAM,CAAC;IACf,iBAAiB,CAAC,CAAC,CAAC;IACpB,aAAa,CAAC,CAAC,CAAC;IAChB,WAAW,CAAC,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,UAAU,mBAAmB,CACjC,OAAmB,EACnB,UAA2B;IAE3B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { EnforcementContext, EnforcementResult, EnforcementRule, ToolCallRecord } from '../types/index.js';
2
+ export declare class ToolEnforcer {
3
+ private rules;
4
+ constructor(rules?: EnforcementRule[]);
5
+ addRule(rule: EnforcementRule): void;
6
+ removeRule(name: string): boolean;
7
+ check(call: ToolCallRecord, context: EnforcementContext): Promise<EnforcementResult>;
8
+ getRules(): EnforcementRule[];
9
+ }
10
+ export declare function createToolEnforcer(rules?: EnforcementRule[]): ToolEnforcer;
11
+ //# sourceMappingURL=ToolEnforcer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolEnforcer.d.ts","sourceRoot":"","sources":["../../src/guards/ToolEnforcer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAyB;gBAE1B,KAAK,GAAE,eAAe,EAAO;IAIzC,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAIpC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAS3B,KAAK,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqB1F,QAAQ,IAAI,eAAe,EAAE;CAG9B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,eAAe,EAAE,GAAG,YAAY,CAE1E"}
@@ -0,0 +1,40 @@
1
+ export class ToolEnforcer {
2
+ rules = [];
3
+ constructor(rules = []) {
4
+ this.rules = rules;
5
+ }
6
+ addRule(rule) {
7
+ this.rules.push(rule);
8
+ }
9
+ removeRule(name) {
10
+ const index = this.rules.findIndex(rule => rule.name === name);
11
+ if (index >= 0) {
12
+ this.rules.splice(index, 1);
13
+ return true;
14
+ }
15
+ return false;
16
+ }
17
+ async check(call, context) {
18
+ for (const rule of this.rules) {
19
+ if (rule.appliesTo !== '*' && !rule.appliesTo.includes(call.toolName)) {
20
+ continue;
21
+ }
22
+ const result = await Promise.resolve(rule.check(call, context));
23
+ if (!result.allowed) {
24
+ console.log(`[Enforcement] Rule "${rule.name}" blocked ${call.toolName}: ${result.reason}`);
25
+ return result;
26
+ }
27
+ if (result.reminder) {
28
+ console.log(`[Enforcement] Reminder for ${call.toolName}: ${result.reminder}`);
29
+ }
30
+ }
31
+ return { allowed: true };
32
+ }
33
+ getRules() {
34
+ return [...this.rules];
35
+ }
36
+ }
37
+ export function createToolEnforcer(rules) {
38
+ return new ToolEnforcer(rules);
39
+ }
40
+ //# sourceMappingURL=ToolEnforcer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolEnforcer.js","sourceRoot":"","sources":["../../src/guards/ToolEnforcer.ts"],"names":[],"mappings":"AAOA,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IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAyB;IAC1D,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ToolEnforcer, createToolEnforcer } from './ToolEnforcer.js';
2
+ export { maxSteps, tokenBudget, timeout, consecutiveErrors, loopDetection, sameToolRepetition, maxHandoffs, taskComplete, anyOf, allOf, defaultStopConditions, checkStopConditions, } from './StopConditions.js';
3
+ export { readBeforeEdit, createRateLimitRule, createDependencyRule, contentValidation, createSequentialLimitRule, defaultEnforcementRules, } from './rules.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,KAAK,EACL,KAAK,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ToolEnforcer, createToolEnforcer } from './ToolEnforcer.js';
2
+ export { maxSteps, tokenBudget, timeout, consecutiveErrors, loopDetection, sameToolRepetition, maxHandoffs, taskComplete, anyOf, allOf, defaultStopConditions, checkStopConditions, } from './StopConditions.js';
3
+ export { readBeforeEdit, createRateLimitRule, createDependencyRule, contentValidation, createSequentialLimitRule, defaultEnforcementRules, } from './rules.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,KAAK,EACL,KAAK,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,YAAY,CAAC"}