@loom-node/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 (130) hide show
  1. package/LICENSE +21 -0
  2. package/dist/__tests__/errors.test.d.ts +2 -0
  3. package/dist/__tests__/errors.test.d.ts.map +1 -0
  4. package/dist/__tests__/errors.test.js +32 -0
  5. package/dist/__tests__/errors.test.js.map +1 -0
  6. package/dist/__tests__/event-bus.test.d.ts +2 -0
  7. package/dist/__tests__/event-bus.test.d.ts.map +1 -0
  8. package/dist/__tests__/event-bus.test.js +34 -0
  9. package/dist/__tests__/event-bus.test.js.map +1 -0
  10. package/dist/__tests__/interceptor.test.d.ts +2 -0
  11. package/dist/__tests__/interceptor.test.d.ts.map +1 -0
  12. package/dist/__tests__/interceptor.test.js +38 -0
  13. package/dist/__tests__/interceptor.test.js.map +1 -0
  14. package/dist/agent/agent-loop.d.ts +23 -0
  15. package/dist/agent/agent-loop.d.ts.map +1 -0
  16. package/dist/agent/agent-loop.js +38 -0
  17. package/dist/agent/agent-loop.js.map +1 -0
  18. package/dist/agent/agent.d.ts +52 -0
  19. package/dist/agent/agent.d.ts.map +1 -0
  20. package/dist/agent/agent.js +96 -0
  21. package/dist/agent/agent.js.map +1 -0
  22. package/dist/agent/index.d.ts +5 -0
  23. package/dist/agent/index.d.ts.map +1 -0
  24. package/dist/agent/index.js +3 -0
  25. package/dist/agent/index.js.map +1 -0
  26. package/dist/agent/strategies/react.d.ts +7 -0
  27. package/dist/agent/strategies/react.d.ts.map +1 -0
  28. package/dist/agent/strategies/react.js +105 -0
  29. package/dist/agent/strategies/react.js.map +1 -0
  30. package/dist/agent/strategies/stream-helper.d.ts +8 -0
  31. package/dist/agent/strategies/stream-helper.d.ts.map +1 -0
  32. package/dist/agent/strategies/stream-helper.js +42 -0
  33. package/dist/agent/strategies/stream-helper.js.map +1 -0
  34. package/dist/agent/strategies/tool-use.d.ts +7 -0
  35. package/dist/agent/strategies/tool-use.d.ts.map +1 -0
  36. package/dist/agent/strategies/tool-use.js +100 -0
  37. package/dist/agent/strategies/tool-use.js.map +1 -0
  38. package/dist/context/context-orchestrator.d.ts +25 -0
  39. package/dist/context/context-orchestrator.d.ts.map +1 -0
  40. package/dist/context/context-orchestrator.js +82 -0
  41. package/dist/context/context-orchestrator.js.map +1 -0
  42. package/dist/errors/agent.d.ts +10 -0
  43. package/dist/errors/agent.d.ts.map +1 -0
  44. package/dist/errors/agent.js +18 -0
  45. package/dist/errors/agent.js.map +1 -0
  46. package/dist/errors/index.d.ts +4 -0
  47. package/dist/errors/index.d.ts.map +1 -0
  48. package/dist/errors/index.js +4 -0
  49. package/dist/errors/index.js.map +1 -0
  50. package/dist/errors/llm.d.ts +23 -0
  51. package/dist/errors/llm.d.ts.map +1 -0
  52. package/dist/errors/llm.js +48 -0
  53. package/dist/errors/llm.js.map +1 -0
  54. package/dist/errors/tool.d.ts +15 -0
  55. package/dist/errors/tool.d.ts.map +1 -0
  56. package/dist/errors/tool.js +27 -0
  57. package/dist/errors/tool.js.map +1 -0
  58. package/dist/events/event-bus.d.ts +89 -0
  59. package/dist/events/event-bus.d.ts.map +1 -0
  60. package/dist/events/event-bus.js +63 -0
  61. package/dist/events/event-bus.js.map +1 -0
  62. package/dist/events/index.d.ts +3 -0
  63. package/dist/events/index.d.ts.map +1 -0
  64. package/dist/events/index.js +2 -0
  65. package/dist/events/index.js.map +1 -0
  66. package/dist/index.d.ts +26 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +19 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/interceptor/index.d.ts +3 -0
  71. package/dist/interceptor/index.d.ts.map +1 -0
  72. package/dist/interceptor/index.js +2 -0
  73. package/dist/interceptor/index.js.map +1 -0
  74. package/dist/interceptor/interceptor.d.ts +17 -0
  75. package/dist/interceptor/interceptor.d.ts.map +1 -0
  76. package/dist/interceptor/interceptor.js +18 -0
  77. package/dist/interceptor/interceptor.js.map +1 -0
  78. package/dist/session/index.d.ts +3 -0
  79. package/dist/session/index.d.ts.map +1 -0
  80. package/dist/session/index.js +2 -0
  81. package/dist/session/index.js.map +1 -0
  82. package/dist/session/session.d.ts +14 -0
  83. package/dist/session/session.d.ts.map +1 -0
  84. package/dist/session/session.js +12 -0
  85. package/dist/session/session.js.map +1 -0
  86. package/dist/types/amoeba.d.ts +107 -0
  87. package/dist/types/amoeba.d.ts.map +1 -0
  88. package/dist/types/amoeba.js +2 -0
  89. package/dist/types/amoeba.js.map +1 -0
  90. package/dist/types/context.d.ts +25 -0
  91. package/dist/types/context.d.ts.map +1 -0
  92. package/dist/types/context.js +3 -0
  93. package/dist/types/context.js.map +1 -0
  94. package/dist/types/events.d.ts +53 -0
  95. package/dist/types/events.d.ts.map +1 -0
  96. package/dist/types/events.js +2 -0
  97. package/dist/types/events.js.map +1 -0
  98. package/dist/types/index.d.ts +11 -0
  99. package/dist/types/index.d.ts.map +1 -0
  100. package/dist/types/index.js +11 -0
  101. package/dist/types/index.js.map +1 -0
  102. package/dist/types/knowledge.d.ts +95 -0
  103. package/dist/types/knowledge.d.ts.map +1 -0
  104. package/dist/types/knowledge.js +2 -0
  105. package/dist/types/knowledge.js.map +1 -0
  106. package/dist/types/llm.d.ts +49 -0
  107. package/dist/types/llm.d.ts.map +1 -0
  108. package/dist/types/llm.js +2 -0
  109. package/dist/types/llm.js.map +1 -0
  110. package/dist/types/memory.d.ts +44 -0
  111. package/dist/types/memory.d.ts.map +1 -0
  112. package/dist/types/memory.js +2 -0
  113. package/dist/types/memory.js.map +1 -0
  114. package/dist/types/message.d.ts +30 -0
  115. package/dist/types/message.d.ts.map +1 -0
  116. package/dist/types/message.js +2 -0
  117. package/dist/types/message.js.map +1 -0
  118. package/dist/types/skill.d.ts +58 -0
  119. package/dist/types/skill.d.ts.map +1 -0
  120. package/dist/types/skill.js +2 -0
  121. package/dist/types/skill.js.map +1 -0
  122. package/dist/types/strategy.d.ts +25 -0
  123. package/dist/types/strategy.d.ts.map +1 -0
  124. package/dist/types/strategy.js +2 -0
  125. package/dist/types/strategy.js.map +1 -0
  126. package/dist/types/tool.d.ts +31 -0
  127. package/dist/types/tool.d.ts.map +1 -0
  128. package/dist/types/tool.js +2 -0
  129. package/dist/types/tool.js.map +1 -0
  130. package/package.json +28 -0
@@ -0,0 +1,7 @@
1
+ import type { AgentEvent } from '../../types/events.js';
2
+ import type { LoopStrategy, LoopContext } from '../../types/strategy.js';
3
+ export declare class ToolUseStrategy implements LoopStrategy {
4
+ readonly name = "tool-use";
5
+ execute(ctx: LoopContext): AsyncGenerator<AgentEvent>;
6
+ }
7
+ //# sourceMappingURL=tool-use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-use.d.ts","sourceRoot":"","sources":["../../../src/agent/strategies/tool-use.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAIzE,qBAAa,eAAgB,YAAW,YAAY;IAClD,QAAQ,CAAC,IAAI,cAAc;IAEpB,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAAC,UAAU,CAAC;CAwF7D"}
@@ -0,0 +1,100 @@
1
+ import { AgentAbortError, AgentMaxStepsError } from '../../errors/agent.js';
2
+ import { streamToCompletion } from './stream-helper.js';
3
+ export class ToolUseStrategy {
4
+ name = 'tool-use';
5
+ async *execute(ctx) {
6
+ const { provider, tools, maxSteps, signal, messages } = ctx;
7
+ const totalUsage = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
8
+ const startTime = Date.now();
9
+ let accumulatedContent = '';
10
+ const jsonTools = tools.map(t => ({
11
+ name: t.name, description: t.description, parameters: t.parameters.toJsonSchema(),
12
+ }));
13
+ for (let step = 0; step < maxSteps; step++) {
14
+ if (signal?.aborted) {
15
+ yield { type: 'error', error: new AgentAbortError(), recoverable: false };
16
+ return;
17
+ }
18
+ yield { type: 'step-start', step, totalSteps: maxSteps };
19
+ if (ctx.interceptors) {
20
+ await ctx.interceptors.run({ messages, metadata: { step, strategy: 'tool-use' } });
21
+ }
22
+ let result;
23
+ try {
24
+ if (ctx.streaming) {
25
+ const sr = await streamToCompletion(provider, { messages, tools: jsonTools }, signal);
26
+ result = sr.result;
27
+ for (const ev of sr.events)
28
+ yield ev;
29
+ }
30
+ else {
31
+ result = await provider.complete({ messages, tools: jsonTools });
32
+ }
33
+ }
34
+ catch (err) {
35
+ yield { type: 'error', error: err instanceof Error ? err : new Error(String(err)), recoverable: false };
36
+ return;
37
+ }
38
+ accumulateUsage(totalUsage, result.usage);
39
+ if (result.content) {
40
+ accumulatedContent += result.content;
41
+ if (!ctx.streaming)
42
+ yield { type: 'text-delta', content: result.content };
43
+ }
44
+ if (result.finishReason === 'stop' || !result.toolCalls?.length) {
45
+ yield { type: 'step-end', step, reason: 'complete' };
46
+ yield { type: 'done', content: accumulatedContent, usage: totalUsage, steps: step + 1, durationMs: Date.now() - startTime };
47
+ return;
48
+ }
49
+ messages.push({ role: 'assistant', content: result.content, toolCalls: result.toolCalls });
50
+ const toolMap = new Map(tools.map(t => [t.name, t]));
51
+ for (const call of result.toolCalls) {
52
+ const tool = toolMap.get(call.name);
53
+ const start = Date.now();
54
+ let parsed;
55
+ try {
56
+ parsed = JSON.parse(call.arguments);
57
+ }
58
+ catch {
59
+ parsed = {};
60
+ }
61
+ yield { type: 'tool-call-start', toolCallId: call.id, toolName: call.name, input: parsed };
62
+ if (!tool) {
63
+ messages.push({ role: 'tool', toolCallId: call.id, content: `Error: Unknown tool: ${call.name}` });
64
+ yield { type: 'tool-call-end', toolCallId: call.id, toolName: call.name, result: null, durationMs: 0, tokenCost: 0 };
65
+ continue;
66
+ }
67
+ try {
68
+ const validInput = tool.parameters.parse(parsed);
69
+ const timeoutMs = ctx.toolConfig?.timeoutMs ?? 30_000;
70
+ const output = await withTimeout(tool.execute(validInput, { signal, sessionId: ctx.sessionId, tenantId: ctx.tenantId }), timeoutMs);
71
+ const dur = Date.now() - start;
72
+ const text = typeof output === 'string' ? output : JSON.stringify(output);
73
+ messages.push({ role: 'tool', toolCallId: call.id, content: text });
74
+ yield { type: 'tool-call-end', toolCallId: call.id, toolName: call.name, result: output, durationMs: dur, tokenCost: 0 };
75
+ }
76
+ catch (err) {
77
+ const dur = Date.now() - start;
78
+ const msg = err instanceof Error ? err.message : String(err);
79
+ messages.push({ role: 'tool', toolCallId: call.id, content: `Error: ${msg}` });
80
+ yield { type: 'tool-call-end', toolCallId: call.id, toolName: call.name, result: null, durationMs: dur, tokenCost: 0 };
81
+ }
82
+ }
83
+ yield { type: 'step-end', step, reason: 'tool-use' };
84
+ }
85
+ yield { type: 'error', error: new AgentMaxStepsError(maxSteps, accumulatedContent), recoverable: false };
86
+ yield { type: 'done', content: accumulatedContent, usage: totalUsage, steps: maxSteps, durationMs: Date.now() - startTime };
87
+ }
88
+ }
89
+ function withTimeout(promise, ms) {
90
+ return new Promise((resolve, reject) => {
91
+ const timer = setTimeout(() => reject(new Error(`Tool timed out after ${ms}ms`)), ms);
92
+ promise.then(resolve, reject).finally(() => clearTimeout(timer));
93
+ });
94
+ }
95
+ function accumulateUsage(total, delta) {
96
+ total.promptTokens += delta.promptTokens;
97
+ total.completionTokens += delta.completionTokens;
98
+ total.totalTokens += delta.totalTokens;
99
+ }
100
+ //# sourceMappingURL=tool-use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-use.js","sourceRoot":"","sources":["../../../src/agent/strategies/tool-use.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,OAAO,eAAe;IACjB,IAAI,GAAG,UAAU,CAAC;IAE3B,KAAK,CAAC,CAAC,OAAO,CAAC,GAAgB;QAC7B,MAAM,EAAE,QAAQ,EAAE,KAA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,CAAC,YAAY,CAAC;IACzC,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,gBAAgB,CAAC;IACjD,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,CAAC;AACzC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { ContextProvider, ContextFragment, ContextOrchestrator as IContextOrchestrator, BudgetRatios, TokenBudget } from '../types/context.js';
2
+ import type { Tokenizer } from '../types/memory.js';
3
+ export interface BudgetConfig {
4
+ contextWindow: number;
5
+ outputReserveRatio?: number;
6
+ /** Optional initial ratios — if omitted, adapts from equal start */
7
+ ratios?: BudgetRatios;
8
+ tokenizer?: Tokenizer;
9
+ /** EMA smoothing factor for adaptive ratios (0-1, default 0.3) */
10
+ adaptiveAlpha?: number;
11
+ }
12
+ export declare class ContextOrchestratorImpl implements IContextOrchestrator {
13
+ private providers;
14
+ private budgetConfig?;
15
+ /** Adaptive scores per source — updated after each gather() */
16
+ private sourceScores;
17
+ constructor(budgetConfig?: BudgetConfig);
18
+ register(provider: ContextProvider): void;
19
+ /** Current adaptive ratios (read-only snapshot) */
20
+ get ratios(): Record<string, number>;
21
+ computeBudget(systemPrompt?: string): TokenBudget;
22
+ gather(query: string, totalBudget: number): Promise<ContextFragment[]>;
23
+ private updateScores;
24
+ }
25
+ //# sourceMappingURL=context-orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-orchestrator.d.ts","sourceRoot":"","sources":["../../src/context/context-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAAE,eAAe,EAChC,mBAAmB,IAAI,oBAAoB,EAC5B,YAAY,EAAE,WAAW,EACzC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oEAAoE;IACpE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,uBAAwB,YAAW,oBAAoB;IAClE,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,YAAY,CAAC,CAAe;IACpC,+DAA+D;IAC/D,OAAO,CAAC,YAAY,CAAoC;gBAE5C,YAAY,CAAC,EAAE,YAAY;IAIvC,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAQzC,mDAAmD;IACnD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKnC;IAED,aAAa,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW;IAgB3C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA+B5E,OAAO,CAAC,YAAY;CAiBrB"}
@@ -0,0 +1,82 @@
1
+ export class ContextOrchestratorImpl {
2
+ providers = [];
3
+ budgetConfig;
4
+ /** Adaptive scores per source — updated after each gather() */
5
+ sourceScores = new Map();
6
+ constructor(budgetConfig) {
7
+ this.budgetConfig = budgetConfig;
8
+ }
9
+ register(provider) {
10
+ this.providers.push(provider);
11
+ if (!this.sourceScores.has(provider.source)) {
12
+ const initial = this.budgetConfig?.ratios?.[provider.source] ?? 1;
13
+ this.sourceScores.set(provider.source, initial);
14
+ }
15
+ }
16
+ /** Current adaptive ratios (read-only snapshot) */
17
+ get ratios() {
18
+ const total = [...this.sourceScores.values()].reduce((s, v) => s + v, 0) || 1;
19
+ const out = {};
20
+ for (const [k, v] of this.sourceScores)
21
+ out[k] = v / total;
22
+ return out;
23
+ }
24
+ computeBudget(systemPrompt) {
25
+ const cfg = this.budgetConfig;
26
+ if (!cfg) {
27
+ return { total: 0, reservedOutput: 0, systemPromptTokens: 0, available: Infinity };
28
+ }
29
+ const reservedOutput = Math.floor(cfg.contextWindow * (cfg.outputReserveRatio ?? 0.25));
30
+ const sysTokens = systemPrompt && cfg.tokenizer
31
+ ? cfg.tokenizer.count(systemPrompt) : 0;
32
+ return {
33
+ total: cfg.contextWindow,
34
+ reservedOutput,
35
+ systemPromptTokens: sysTokens,
36
+ available: Math.max(0, cfg.contextWindow - reservedOutput - sysTokens),
37
+ };
38
+ }
39
+ async gather(query, totalBudget) {
40
+ if (this.providers.length === 0)
41
+ return [];
42
+ // Compute current ratios from adaptive scores
43
+ const scoreTotal = [...this.sourceScores.values()].reduce((s, v) => s + v, 0) || 1;
44
+ // Allocate budget proportionally
45
+ const results = await Promise.all(this.providers.map(p => {
46
+ const score = this.sourceScores.get(p.source) ?? 1;
47
+ const budget = Math.floor(totalBudget * (score / scoreTotal));
48
+ return p.provide(query, budget).catch(() => []);
49
+ }));
50
+ // Merge, sort by relevance, fit within budget
51
+ const all = results.flat().sort((a, b) => b.relevance - a.relevance);
52
+ const selected = [];
53
+ let used = 0;
54
+ for (const f of all) {
55
+ if (used + f.tokens > totalBudget)
56
+ continue;
57
+ selected.push(f);
58
+ used += f.tokens;
59
+ }
60
+ // Update adaptive scores based on what was actually selected
61
+ this.updateScores(selected);
62
+ return selected;
63
+ }
64
+ updateScores(selected) {
65
+ const alpha = this.budgetConfig?.adaptiveAlpha ?? 0.3;
66
+ // Compute average relevance per source from selected fragments
67
+ const bySource = new Map();
68
+ for (const f of selected) {
69
+ const acc = bySource.get(f.source) ?? { sum: 0, count: 0 };
70
+ acc.sum += f.relevance;
71
+ acc.count++;
72
+ bySource.set(f.source, acc);
73
+ }
74
+ // EMA update: score = (1-α)*old + α*avgRelevance
75
+ for (const [source, old] of this.sourceScores) {
76
+ const acc = bySource.get(source);
77
+ const avgRel = acc ? acc.sum / acc.count : 0;
78
+ this.sourceScores.set(source, (1 - alpha) * old + alpha * avgRel);
79
+ }
80
+ }
81
+ }
82
+ //# sourceMappingURL=context-orchestrator.js.map
@@ -0,0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ACZ,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;QACD,iDAAiD;QACjD,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC9C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { LoomError } from './llm.js';
2
+ export declare class AgentAbortError extends LoomError {
3
+ constructor();
4
+ }
5
+ export declare class AgentMaxStepsError extends LoomError {
6
+ readonly steps: number;
7
+ readonly partialContent: string;
8
+ constructor(steps: number, partialContent: string);
9
+ }
10
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/errors/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,qBAAa,eAAgB,SAAQ,SAAS;;CAK7C;AAED,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;gBACpB,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAMlD"}
@@ -0,0 +1,18 @@
1
+ import { LoomError } from './llm.js';
2
+ export class AgentAbortError extends LoomError {
3
+ constructor() {
4
+ super('AGENT_ABORT', 'Agent execution was aborted');
5
+ this.name = 'AgentAbortError';
6
+ }
7
+ }
8
+ export class AgentMaxStepsError extends LoomError {
9
+ steps;
10
+ partialContent;
11
+ constructor(steps, partialContent) {
12
+ super('AGENT_MAX_STEPS', `Agent reached max steps (${steps})`);
13
+ this.name = 'AgentMaxStepsError';
14
+ this.steps = steps;
15
+ this.partialContent = partialContent;
16
+ }
17
+ }
18
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/errors/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C;QACE,KAAK,CAAC,aAAa,EAAE,6BAA6B,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IACtC,KAAK,CAAS;IACd,cAAc,CAAS;IAChC,YAAY,KAAa,EAAE,cAAsB;QAC/C,KAAK,CAAC,iBAAiB,EAAE,4BAA4B,KAAK,GAAG,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { LoomError, LLMError, LLMRateLimitError, LLMAuthError, LLMStreamInterruptedError } from './llm.js';
2
+ export { ToolError, ToolTimeoutError, ToolResultTooLargeError } from './tool.js';
3
+ export { AgentAbortError, AgentMaxStepsError } from './agent.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { LoomError, LLMError, LLMRateLimitError, LLMAuthError, LLMStreamInterruptedError } from './llm.js';
2
+ export { ToolError, ToolTimeoutError, ToolResultTooLargeError } from './tool.js';
3
+ export { AgentAbortError, AgentMaxStepsError } from './agent.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare class LoomError extends Error {
2
+ readonly code: string;
3
+ readonly cause?: Error;
4
+ constructor(code: string, message: string, cause?: Error);
5
+ static from(err: unknown): LoomError;
6
+ }
7
+ export declare class LLMError extends LoomError {
8
+ readonly provider: string;
9
+ readonly statusCode?: number;
10
+ constructor(code: string, provider: string, message: string, statusCode?: number, cause?: Error);
11
+ }
12
+ export declare class LLMRateLimitError extends LLMError {
13
+ readonly retryAfterMs?: number;
14
+ constructor(provider: string, retryAfterMs?: number);
15
+ }
16
+ export declare class LLMAuthError extends LLMError {
17
+ constructor(provider: string);
18
+ }
19
+ export declare class LLMStreamInterruptedError extends LLMError {
20
+ readonly partialContent: string;
21
+ constructor(provider: string, partialContent: string, cause?: Error);
22
+ }
23
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/errors/llm.ts"],"names":[],"mappings":"AACA,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,SAAkB,KAAK,CAAC,EAAE,KAAK,CAAC;gBAEpB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAOxD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS;CAKrC;AAGD,qBAAa,QAAS,SAAQ,SAAS;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBACjB,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAMhG;AAED,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;gBACnB,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;CAIpD;AAED,qBAAa,YAAa,SAAQ,QAAQ;gBAC5B,QAAQ,EAAE,MAAM;CAG7B;AAED,qBAAa,yBAA0B,SAAQ,QAAQ;IACrD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;gBACpB,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAIpE"}
@@ -0,0 +1,48 @@
1
+ // ===== Error Base =====
2
+ export class LoomError extends Error {
3
+ code;
4
+ cause;
5
+ constructor(code, message, cause) {
6
+ super(message);
7
+ this.name = 'LoomError';
8
+ this.code = code;
9
+ this.cause = cause;
10
+ }
11
+ static from(err) {
12
+ if (err instanceof LoomError)
13
+ return err;
14
+ const e = err instanceof Error ? err : new Error(String(err));
15
+ return new LoomError('UNKNOWN', e.message, e);
16
+ }
17
+ }
18
+ // ===== LLM Errors =====
19
+ export class LLMError extends LoomError {
20
+ provider;
21
+ statusCode;
22
+ constructor(code, provider, message, statusCode, cause) {
23
+ super(code, message, cause);
24
+ this.name = 'LLMError';
25
+ this.provider = provider;
26
+ this.statusCode = statusCode;
27
+ }
28
+ }
29
+ export class LLMRateLimitError extends LLMError {
30
+ retryAfterMs;
31
+ constructor(provider, retryAfterMs) {
32
+ super('LLM_RATE_LIMIT', provider, `Rate limited by ${provider}`, 429);
33
+ this.retryAfterMs = retryAfterMs;
34
+ }
35
+ }
36
+ export class LLMAuthError extends LLMError {
37
+ constructor(provider) {
38
+ super('LLM_AUTH_ERROR', provider, `Authentication failed for ${provider}`, 401);
39
+ }
40
+ }
41
+ export class LLMStreamInterruptedError extends LLMError {
42
+ partialContent;
43
+ constructor(provider, partialContent, cause) {
44
+ super('LLM_STREAM_INTERRUPTED', provider, `Stream interrupted from ${provider}`, undefined, cause);
45
+ this.partialContent = partialContent;
46
+ }
47
+ }
48
+ //# sourceMappingURL=llm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/errors/llm.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,IAAI,CAAS;IACJ,KAAK,CAAS;IAEhC,YAAY,IAAY,EAAE,OAAe,EAAE,KAAa;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,GAAY;QACtB,IAAI,GAAG,YAAY,SAAS;YAAE,OAAO,GAAG,CAAC;QACzC,MAAM,CAAC,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IA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'./llm.js';
2
+ export declare class ToolError extends LoomError {
3
+ readonly toolName: string;
4
+ constructor(code: string, toolName: string, message: string, cause?: Error);
5
+ }
6
+ export declare class ToolTimeoutError extends ToolError {
7
+ readonly timeoutMs: number;
8
+ constructor(toolName: string, timeoutMs: number);
9
+ }
10
+ export declare class ToolResultTooLargeError extends ToolError {
11
+ readonly sizeBytes: number;
12
+ readonly limitBytes: number;
13
+ constructor(toolName: string, sizeBytes: number, limitBytes: number);
14
+ }
15
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/errors/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,qBAAa,SAAU,SAAQ,SAAS;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBACd,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAK3E;AAED,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBACf,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAIhD;AAED,qBAAa,uBAAwB,SAAQ,SAAS;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAChB,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAKpE"}
@@ -0,0 +1,27 @@
1
+ import { LoomError } from './llm.js';
2
+ // ===== Tool Errors =====
3
+ export class ToolError extends LoomError {
4
+ toolName;
5
+ constructor(code, toolName, message, cause) {
6
+ super(code, message, cause);
7
+ this.name = 'ToolError';
8
+ this.toolName = toolName;
9
+ }
10
+ }
11
+ export class ToolTimeoutError extends ToolError {
12
+ timeoutMs;
13
+ constructor(toolName, timeoutMs) {
14
+ super('TOOL_TIMEOUT', toolName, `Tool "${toolName}" timed out after ${timeoutMs}ms`);
15
+ this.timeoutMs = timeoutMs;
16
+ }
17
+ }
18
+ export class ToolResultTooLargeError extends ToolError {
19
+ sizeBytes;
20
+ limitBytes;
21
+ constructor(toolName, sizeBytes, limitBytes) {
22
+ super('TOOL_RESULT_TOO_LARGE', toolName, `Tool "${toolName}" result ${sizeBytes}B exceeds limit ${limitBytes}B`);
23
+ this.sizeBytes = sizeBytes;
24
+ this.limitBytes = limitBytes;
25
+ }
26
+ }
27
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/errors/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,0BAA0B;AAC1B,MAAM,OAAO,SAAU,SAAQ,SAAS;IAC7B,QAAQ,CAAS;IAC1B,YAAY,IAAY,EAAE,QAAgB,EAAE,OAAe,EAAE,KAAa;QACxE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IACpC,SAAS,CAAS;IAC3B,YAAY,QAAgB,EAAE,SAAiB;QAC7C,KAAK,CAAC,cAAc,EAAE,QAAQ,EAAE,SAAS,QAAQ,qBAAqB,SAAS,IAAI,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IAC3C,SAAS,CAAS;IAClB,UAAU,CAAS;IAC5B,YAAY,QAAgB,EAAE,SAAiB,EAAE,UAAkB;QACjE,KAAK,CAAC,uBAAuB,EAAE,QAAQ,EAAE,SAAS,QAAQ,YAAY,SAAS,mBAAmB,UAAU,GAAG,CAAC,CAAC;QACjH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,89 @@
1
+ type Handler<T = unknown> = (data: T) => void;
2
+ export interface AgentEventMap {
3
+ 'agent:start': {
4
+ taskId: string;
5
+ input: string;
6
+ };
7
+ 'agent:done': {
8
+ taskId: string;
9
+ output: string;
10
+ };
11
+ 'tool:call': {
12
+ name: string;
13
+ input: unknown;
14
+ };
15
+ 'tool:result': {
16
+ name: string;
17
+ output: unknown;
18
+ durationMs: number;
19
+ };
20
+ 'tool:executed': {
21
+ step: number;
22
+ results: unknown[];
23
+ };
24
+ 'memory:store': {
25
+ layer: string;
26
+ tokens: number;
27
+ };
28
+ 'llm:request': {
29
+ model: string;
30
+ tokens: number;
31
+ };
32
+ 'llm:response': {
33
+ model: string;
34
+ tokens: number;
35
+ durationMs: number;
36
+ };
37
+ 'error': {
38
+ source: string;
39
+ error: Error;
40
+ };
41
+ 'node:mitosis': {
42
+ parentId: string;
43
+ childId: string;
44
+ domain: string;
45
+ };
46
+ 'node:apoptosis': {
47
+ nodeId: string;
48
+ mergedInto?: string;
49
+ };
50
+ 'node:reward': {
51
+ nodeId: string;
52
+ domain: string;
53
+ score: number;
54
+ };
55
+ 'loop:sense': {
56
+ taskId: string;
57
+ complexity: number;
58
+ domains: string[];
59
+ method: string;
60
+ };
61
+ 'loop:match': {
62
+ taskId: string;
63
+ winnerId: string;
64
+ tier: 1 | 2 | 3;
65
+ };
66
+ 'loop:adapt': {
67
+ taskId: string;
68
+ reward: number;
69
+ evolved: boolean;
70
+ recycled: boolean;
71
+ };
72
+ }
73
+ export declare class TypedEventBus {
74
+ private handlers;
75
+ readonly nodeId: string | undefined;
76
+ private parent;
77
+ constructor(opts?: {
78
+ nodeId?: string;
79
+ parent?: TypedEventBus;
80
+ });
81
+ createChildBus(nodeId: string): TypedEventBus;
82
+ on<K extends keyof AgentEventMap>(event: K, handler: Handler<AgentEventMap[K]>): () => void;
83
+ /** Subscribe to all events matching a prefix pattern, e.g. 'tool:*' */
84
+ onPattern(pattern: string, handler: Handler<unknown>): () => void;
85
+ off<K extends keyof AgentEventMap>(event: K, handler: Handler<AgentEventMap[K]>): void;
86
+ emit<K extends keyof AgentEventMap>(event: K, data: AgentEventMap[K]): void;
87
+ }
88
+ export {};
89
+ //# sourceMappingURL=event-bus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../src/events/event-bus.ts"],"names":[],"mappings":"AACA,KAAK,OAAO,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,YAAY,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC9C,aAAa,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,eAAe,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IACtD,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,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,MAAM,EAAE,MAAM,GAAG,aAAa;IAI7C,EAAE,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAQ3F,uEAAuE;IACvE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI;IAQjE,GAAG,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAItF,IAAI,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI;CAsB5E"}
@@ -0,0 +1,63 @@
1
+ export class TypedEventBus {
2
+ handlers = new Map();
3
+ nodeId;
4
+ parent;
5
+ constructor(opts) {
6
+ this.nodeId = opts?.nodeId;
7
+ this.parent = opts?.parent;
8
+ }
9
+ createChildBus(nodeId) {
10
+ return new TypedEventBus({ nodeId, parent: this });
11
+ }
12
+ on(event, handler) {
13
+ if (!this.handlers.has(event)) {
14
+ this.handlers.set(event, new Set());
15
+ }
16
+ this.handlers.get(event).add(handler);
17
+ return () => this.off(event, handler);
18
+ }
19
+ /** Subscribe to all events matching a prefix pattern, e.g. 'tool:*' */
20
+ onPattern(pattern, handler) {
21
+ if (!this.handlers.has(pattern)) {
22
+ this.handlers.set(pattern, new Set());
23
+ }
24
+ this.handlers.get(pattern).add(handler);
25
+ return () => { this.handlers.get(pattern)?.delete(handler); };
26
+ }
27
+ off(event, handler) {
28
+ this.handlers.get(event)?.delete(handler);
29
+ }
30
+ emit(event, data) {
31
+ // Exact match handlers
32
+ this.handlers.get(event)?.forEach(h => {
33
+ try {
34
+ h(data);
35
+ }
36
+ catch { /* swallow */ }
37
+ });
38
+ // Pattern match: 'tool:*' matches 'tool:call', 'tool:result', etc.
39
+ for (const [pat, hs] of this.handlers) {
40
+ if (!pat.endsWith(':*'))
41
+ continue;
42
+ const prefix = pat.slice(0, -1); // 'tool:*' → 'tool:'
43
+ if (event.startsWith(prefix)) {
44
+ hs.forEach(h => { try {
45
+ h(data);
46
+ }
47
+ catch { /* swallow */ } });
48
+ }
49
+ }
50
+ // Wildcard '*' handlers
51
+ this.handlers.get('*')?.forEach(h => {
52
+ try {
53
+ h(data);
54
+ }
55
+ catch { /* swallow */ }
56
+ });
57
+ // Propagate to parent
58
+ if (this.parent) {
59
+ this.parent.emit(event, data);
60
+ }
61
+ }
62
+ }
63
+ //# sourceMappingURL=event-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../src/events/event-bus.ts"],"names":[],"mappings":"AAuBA,MAAM,OAAO,aAAa;IAChB,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,MAAM,CAAqB;IAC5B,MAAM,CAA4B;IAE1C,YAAY,IAAkD;QAC5D,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC;IAC7B,CAAC;IAED,cAAc,CAAC,MAAc;QAC3B,OAAO,IAAI,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,EAAE,CAAgC,KAAQ,EAAE,OAAkC;QAC5E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,OAAkB,CAAC,C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,CAAC,CAAC,qBAAqB;YACtD,IAAK,KAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;oBAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QACD,wBAAwB;QACxB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE;YAClC,IAAI,CAAC;gBAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QACH,sBAAsB;QACtB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { TypedEventBus } from './event-bus.js';
2
+ export type { AgentEventMap } from './event-bus.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { TypedEventBus } from './event-bus.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}