@ironflow/node 0.20.0 → 0.20.2

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 (146) hide show
  1. package/LICENSE +181 -0
  2. package/package.json +8 -8
  3. package/dist/agent/agent.d.ts +0 -60
  4. package/dist/agent/agent.d.ts.map +0 -1
  5. package/dist/agent/agent.js +0 -133
  6. package/dist/agent/agent.js.map +0 -1
  7. package/dist/agent/approve.d.ts +0 -23
  8. package/dist/agent/approve.d.ts.map +0 -1
  9. package/dist/agent/approve.js +0 -42
  10. package/dist/agent/approve.js.map +0 -1
  11. package/dist/agent/dispatch.d.ts +0 -63
  12. package/dist/agent/dispatch.d.ts.map +0 -1
  13. package/dist/agent/dispatch.js +0 -130
  14. package/dist/agent/dispatch.js.map +0 -1
  15. package/dist/agent/errors.d.ts +0 -90
  16. package/dist/agent/errors.d.ts.map +0 -1
  17. package/dist/agent/errors.js +0 -136
  18. package/dist/agent/errors.js.map +0 -1
  19. package/dist/agent/index.d.ts +0 -30
  20. package/dist/agent/index.d.ts.map +0 -1
  21. package/dist/agent/index.js +0 -27
  22. package/dist/agent/index.js.map +0 -1
  23. package/dist/agent/internal-registry.d.ts +0 -27
  24. package/dist/agent/internal-registry.d.ts.map +0 -1
  25. package/dist/agent/internal-registry.js +0 -36
  26. package/dist/agent/internal-registry.js.map +0 -1
  27. package/dist/agent/internal.d.ts +0 -24
  28. package/dist/agent/internal.d.ts.map +0 -1
  29. package/dist/agent/internal.js +0 -29
  30. package/dist/agent/internal.js.map +0 -1
  31. package/dist/agent/llm.d.ts +0 -39
  32. package/dist/agent/llm.d.ts.map +0 -1
  33. package/dist/agent/llm.js +0 -59
  34. package/dist/agent/llm.js.map +0 -1
  35. package/dist/agent/mcp.d.ts +0 -51
  36. package/dist/agent/mcp.d.ts.map +0 -1
  37. package/dist/agent/mcp.js +0 -155
  38. package/dist/agent/mcp.js.map +0 -1
  39. package/dist/agent/memory.d.ts +0 -74
  40. package/dist/agent/memory.d.ts.map +0 -1
  41. package/dist/agent/memory.js +0 -130
  42. package/dist/agent/memory.js.map +0 -1
  43. package/dist/agent/spawn.d.ts +0 -20
  44. package/dist/agent/spawn.d.ts.map +0 -1
  45. package/dist/agent/spawn.js +0 -29
  46. package/dist/agent/spawn.js.map +0 -1
  47. package/dist/agent/tool.d.ts +0 -39
  48. package/dist/agent/tool.d.ts.map +0 -1
  49. package/dist/agent/tool.js +0 -103
  50. package/dist/agent/tool.js.map +0 -1
  51. package/dist/agent/types.d.ts +0 -363
  52. package/dist/agent/types.d.ts.map +0 -1
  53. package/dist/agent/types.js +0 -9
  54. package/dist/agent/types.js.map +0 -1
  55. package/dist/client.d.ts +0 -942
  56. package/dist/client.d.ts.map +0 -1
  57. package/dist/client.js +0 -1557
  58. package/dist/client.js.map +0 -1
  59. package/dist/command-dedup.d.ts +0 -61
  60. package/dist/command-dedup.d.ts.map +0 -1
  61. package/dist/command-dedup.js +0 -129
  62. package/dist/command-dedup.js.map +0 -1
  63. package/dist/config-client.d.ts +0 -58
  64. package/dist/config-client.d.ts.map +0 -1
  65. package/dist/config-client.js +0 -171
  66. package/dist/config-client.js.map +0 -1
  67. package/dist/function.d.ts +0 -53
  68. package/dist/function.d.ts.map +0 -1
  69. package/dist/function.js +0 -72
  70. package/dist/function.js.map +0 -1
  71. package/dist/index.d.ts +0 -71
  72. package/dist/index.d.ts.map +0 -1
  73. package/dist/index.js +0 -70
  74. package/dist/index.js.map +0 -1
  75. package/dist/internal/assert-defined.d.ts +0 -10
  76. package/dist/internal/assert-defined.d.ts.map +0 -1
  77. package/dist/internal/assert-defined.js +0 -15
  78. package/dist/internal/assert-defined.js.map +0 -1
  79. package/dist/internal/context.d.ts +0 -142
  80. package/dist/internal/context.d.ts.map +0 -1
  81. package/dist/internal/context.js +0 -306
  82. package/dist/internal/context.js.map +0 -1
  83. package/dist/internal/errors.d.ts +0 -66
  84. package/dist/internal/errors.d.ts.map +0 -1
  85. package/dist/internal/errors.js +0 -29
  86. package/dist/internal/errors.js.map +0 -1
  87. package/dist/internal/run-context.d.ts +0 -10
  88. package/dist/internal/run-context.d.ts.map +0 -1
  89. package/dist/internal/run-context.js +0 -23
  90. package/dist/internal/run-context.js.map +0 -1
  91. package/dist/kv.d.ts +0 -86
  92. package/dist/kv.d.ts.map +0 -1
  93. package/dist/kv.js +0 -261
  94. package/dist/kv.js.map +0 -1
  95. package/dist/projection-runner.d.ts +0 -83
  96. package/dist/projection-runner.d.ts.map +0 -1
  97. package/dist/projection-runner.js +0 -498
  98. package/dist/projection-runner.js.map +0 -1
  99. package/dist/projection.d.ts +0 -36
  100. package/dist/projection.d.ts.map +0 -1
  101. package/dist/projection.js +0 -55
  102. package/dist/projection.js.map +0 -1
  103. package/dist/secrets.d.ts +0 -6
  104. package/dist/secrets.d.ts.map +0 -1
  105. package/dist/secrets.js +0 -19
  106. package/dist/secrets.js.map +0 -1
  107. package/dist/serve.d.ts +0 -71
  108. package/dist/serve.d.ts.map +0 -1
  109. package/dist/serve.js +0 -460
  110. package/dist/serve.js.map +0 -1
  111. package/dist/step.d.ts +0 -18
  112. package/dist/step.d.ts.map +0 -1
  113. package/dist/step.js +0 -581
  114. package/dist/step.js.map +0 -1
  115. package/dist/subscribe.d.ts +0 -164
  116. package/dist/subscribe.d.ts.map +0 -1
  117. package/dist/subscribe.js +0 -487
  118. package/dist/subscribe.js.map +0 -1
  119. package/dist/test/index.d.ts +0 -22
  120. package/dist/test/index.d.ts.map +0 -1
  121. package/dist/test/index.js +0 -112
  122. package/dist/test/index.js.map +0 -1
  123. package/dist/test/test-step.d.ts +0 -21
  124. package/dist/test/test-step.d.ts.map +0 -1
  125. package/dist/test/test-step.js +0 -83
  126. package/dist/test/test-step.js.map +0 -1
  127. package/dist/types.d.ts +0 -108
  128. package/dist/types.d.ts.map +0 -1
  129. package/dist/types.js +0 -5
  130. package/dist/types.js.map +0 -1
  131. package/dist/version.d.ts +0 -2
  132. package/dist/version.d.ts.map +0 -1
  133. package/dist/version.js +0 -4
  134. package/dist/version.js.map +0 -1
  135. package/dist/webhook.d.ts +0 -22
  136. package/dist/webhook.d.ts.map +0 -1
  137. package/dist/webhook.js +0 -23
  138. package/dist/webhook.js.map +0 -1
  139. package/dist/worker-streaming.d.ts +0 -17
  140. package/dist/worker-streaming.d.ts.map +0 -1
  141. package/dist/worker-streaming.js +0 -510
  142. package/dist/worker-streaming.js.map +0 -1
  143. package/dist/worker.d.ts +0 -28
  144. package/dist/worker.d.ts.map +0 -1
  145. package/dist/worker.js +0 -559
  146. package/dist/worker.js.map +0 -1
@@ -1,130 +0,0 @@
1
- /**
2
- * Inbound callback handler for Ironflow → SDK agent-tool dispatch.
3
- *
4
- * The Ironflow server's `agent_tools.Dispatcher` POSTs an HMAC-signed
5
- * request to `${callbackUrl}` (the user's serve() mount). serve() routes
6
- * `/ironflow/agent-tools/dispatch` here. We:
7
- *
8
- * 1. Verify HMAC + replay window (5min past, 1min future).
9
- * 2. Look up the qualified tool in the local registry.
10
- * 3. Validate input against the McpToolDef Zod schema.
11
- * 4. Run the handler, mapping success → {output} and any throw →
12
- * {error:{code:"HANDLER_ERROR", message}} (200 with envelope so the
13
- * Go dispatcher decodes it as a tool error instead of a transport
14
- * failure — see internal/agent_tools/dispatcher.go:182).
15
- *
16
- * server SDK serve()
17
- * │ POST /…/dispatch │
18
- * │ X-Ironflow-Timestamp: <unix> │
19
- * │ X-Ironflow-Signature: sha256=… │
20
- * │ body: {qualified_name, input} │
21
- * │ ─────────────────────────────▶│
22
- * │ │ verify HMAC
23
- * │ │ lookupLocal()
24
- * │ │ Zod parse(input)
25
- * │ │ def.handler(input)
26
- * │ │
27
- * │ 200 {output} | 200 {error} | │
28
- * │ 401 sig | 400 schema │
29
- * │ ◀───────────────────────────── │
30
- */
31
- import { createHmac, timingSafeEqual } from "node:crypto";
32
- import { lookupLocal } from "./internal-registry.js";
33
- const HEADER_SIGNATURE = "x-ironflow-signature";
34
- const HEADER_TIMESTAMP = "x-ironflow-timestamp";
35
- const SIGNATURE_PREFIX = "sha256=";
36
- const REPLAY_WINDOW_SEC = 5 * 60;
37
- const FUTURE_SKEW_SEC = 60;
38
- /** Path served on the user's serve() mount. */
39
- export const DISPATCH_PATH = "/ironflow/agent-tools/dispatch";
40
- /**
41
- * Process an inbound dispatch request. Returns status + body envelope —
42
- * the caller (serve()) is responsible for serializing.
43
- */
44
- export async function handleAgentToolDispatch(request) {
45
- const rawBody = await request.text();
46
- const sigHeader = request.headers.get(HEADER_SIGNATURE);
47
- const tsHeader = request.headers.get(HEADER_TIMESTAMP);
48
- if (!sigHeader || !tsHeader) {
49
- return errorResponse(401, "SIGNATURE_MISMATCH", "missing HMAC headers");
50
- }
51
- if (!sigHeader.startsWith(SIGNATURE_PREFIX)) {
52
- return errorResponse(401, "SIGNATURE_MISMATCH", "invalid signature format");
53
- }
54
- const ts = Number.parseInt(tsHeader, 10);
55
- if (!Number.isFinite(ts)) {
56
- return errorResponse(401, "TIMESTAMP_SKEW", "invalid timestamp");
57
- }
58
- const now = Math.floor(Date.now() / 1000);
59
- if (now - ts > REPLAY_WINDOW_SEC) {
60
- return errorResponse(401, "TIMESTAMP_SKEW", "request timestamp too old");
61
- }
62
- if (ts - now > FUTURE_SKEW_SEC) {
63
- return errorResponse(401, "TIMESTAMP_SKEW", "request timestamp too far in future");
64
- }
65
- let payload;
66
- try {
67
- payload = JSON.parse(rawBody);
68
- }
69
- catch {
70
- return errorResponse(400, "INVALID_REQUEST", "callback body is not valid JSON");
71
- }
72
- const qualifiedName = typeof payload.qualified_name === "string" ? payload.qualified_name : "";
73
- if (!qualifiedName) {
74
- return errorResponse(400, "INVALID_REQUEST", "qualified_name missing");
75
- }
76
- const entry = lookupLocal(qualifiedName);
77
- if (!entry) {
78
- console.warn(`ironflow.agent.dispatch unknown_tool qualified_name=${JSON.stringify(qualifiedName)}`);
79
- return errorResponse(401, "SIGNATURE_MISMATCH", "HMAC mismatch");
80
- }
81
- if (!verifyHmac(rawBody, ts, sigHeader.slice(SIGNATURE_PREFIX.length), entry.hmacSecret)) {
82
- return errorResponse(401, "SIGNATURE_MISMATCH", "HMAC mismatch");
83
- }
84
- const parseResult = entry.def.input.safeParse(payload.input);
85
- if (!parseResult.success) {
86
- const issues = parseResult.error.issues
87
- .map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`)
88
- .join("; ");
89
- return errorResponse(400, "INPUT_SCHEMA_INVALID", issues);
90
- }
91
- try {
92
- const output = await entry.def.handler(parseResult.data);
93
- return { status: 200, body: { output } };
94
- }
95
- catch (err) {
96
- const message = err instanceof Error ? err.message : String(err);
97
- return { status: 200, body: { error: { code: "HANDLER_ERROR", message } } };
98
- }
99
- }
100
- function errorResponse(status, code, message) {
101
- return { status, body: { error: { code, message } } };
102
- }
103
- /**
104
- * verifyHmac is exported for cross-language vector parity tests
105
- * (testdata/hmac_vectors.json, issue #595 S8). It is NOT part of the
106
- * public @ironflow/node/agent surface — production callers reach it
107
- * via handleAgentToolDispatch().
108
- */
109
- export function verifyHmac(rawBody, ts, receivedHex, secretHex) {
110
- // Buffer.from(..., "hex") silently truncates at the first non-hex char
111
- // instead of throwing. Validate explicitly so a malformed secret/sig
112
- // can't quietly produce a partial buffer that passes timingSafeEqual.
113
- if (!isHex(secretHex) || !isHex(receivedHex)) {
114
- return false;
115
- }
116
- const secretBuf = Buffer.from(secretHex, "hex");
117
- const expectedHex = createHmac("sha256", secretBuf)
118
- .update(`${ts}.${rawBody}`)
119
- .digest("hex");
120
- const receivedBuf = Buffer.from(receivedHex, "hex");
121
- const expectedBuf = Buffer.from(expectedHex, "hex");
122
- if (receivedBuf.length !== expectedBuf.length || receivedBuf.length === 0) {
123
- return false;
124
- }
125
- return timingSafeEqual(receivedBuf, expectedBuf);
126
- }
127
- function isHex(s) {
128
- return s.length > 0 && s.length % 2 === 0 && /^[0-9a-fA-F]+$/.test(s);
129
- }
130
- //# sourceMappingURL=dispatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.js","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E,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,OAAe,EACf,EAAU,EACV,WAAmB,EACnB,SAAiB;IAEjB,uEAAuE;IACvE,qEAAqE;IACrE,sEAAsE;IACtE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC;SAChD,MAAM,CAAC,GAAG,EAAE,IAAI,OAAO,EAAE,CAAC;SAC1B,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjB,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACpD,IAAI,WAAW,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,KAAK,CAAC,CAAS;IACtB,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC"}
@@ -1,90 +0,0 @@
1
- /**
2
- * Agent module error classes.
3
- *
4
- * All extend IronflowError. Codes are stable for programmatic handling.
5
- */
6
- import { IronflowError } from "@ironflow/core";
7
- /**
8
- * Thrown when an agent exceeds its configured turn budget.
9
- *
10
- * Default budget is 20 turns. Configurable via AgentConfig.maxTurns.
11
- */
12
- export declare class MaxTurnsExceededError extends IronflowError {
13
- constructor(maxTurns: number, options?: {
14
- cause?: Error;
15
- });
16
- }
17
- /**
18
- * Base class for classified LLM errors emitted by llm().
19
- */
20
- export declare class LLMError extends IronflowError {
21
- constructor(message: string, options: {
22
- code: string;
23
- retryable?: boolean;
24
- details?: Record<string, unknown>;
25
- cause?: Error;
26
- });
27
- }
28
- /**
29
- * Provider refused the request (safety, policy, etc.).
30
- */
31
- export declare class LLMRefusalError extends LLMError {
32
- constructor(message: string, options?: {
33
- details?: Record<string, unknown>;
34
- cause?: Error;
35
- });
36
- }
37
- /**
38
- * Provider returned content that failed JSON parsing when JSON was required.
39
- */
40
- export declare class LLMInvalidJSONError extends LLMError {
41
- constructor(message: string, options?: {
42
- details?: Record<string, unknown>;
43
- cause?: Error;
44
- });
45
- }
46
- /**
47
- * Provider truncated the response by hitting max_tokens.
48
- */
49
- export declare class LLMMaxTokensError extends LLMError {
50
- constructor(message: string, options?: {
51
- details?: Record<string, unknown>;
52
- cause?: Error;
53
- });
54
- }
55
- /**
56
- * Thrown when tool() input fails Zod validation.
57
- *
58
- * Distinct from generic ValidationError so callers can differentiate
59
- * agent-tool input failures from event-payload schema failures.
60
- */
61
- export declare class ToolValidationError extends IronflowError {
62
- constructor(toolName: string, issues: unknown, options?: {
63
- cause?: Error;
64
- });
65
- }
66
- /**
67
- * Thrown when AgentConfig.tools contains two or more definitions sharing
68
- * the same name. Silent overwrite would let LLM-driven dispatch route to
69
- * an unintended handler — so we fail loudly at agent construction.
70
- */
71
- export declare class DuplicateToolError extends IronflowError {
72
- constructor(toolName: string);
73
- }
74
- /**
75
- * Thrown when ctx.tool(name, args) is called with a name that isn't
76
- * registered on AgentConfig.tools.
77
- */
78
- export declare class ToolNotFoundError extends IronflowError {
79
- constructor(toolName: string);
80
- }
81
- /**
82
- * Thrown when memory.entityStream() is called without a projection.
83
- *
84
- * Per architecture decision: raw event replay is not exposed through
85
- * the agent memory API. Consumers must define a projection.
86
- */
87
- export declare class MemoryProjectionRequiredError extends IronflowError {
88
- constructor(streamId: string);
89
- }
90
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/agent/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAS1D;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAAa;gBAEvC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAKJ;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAS5F;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAS5F;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAS5F;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;gBAElD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAU9B;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;gBACvC,QAAQ,EAAE,MAAM;CAQ7B;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,QAAQ,EAAE,MAAM;CAW7B;AAED;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,aAAa;gBAClD,QAAQ,EAAE,MAAM;CAW7B"}
@@ -1,136 +0,0 @@
1
- /**
2
- * Agent module error classes.
3
- *
4
- * All extend IronflowError. Codes are stable for programmatic handling.
5
- */
6
- import { IronflowError } from "@ironflow/core";
7
- /**
8
- * Thrown when an agent exceeds its configured turn budget.
9
- *
10
- * Default budget is 20 turns. Configurable via AgentConfig.maxTurns.
11
- */
12
- export class MaxTurnsExceededError extends IronflowError {
13
- constructor(maxTurns, options) {
14
- super(`agent exceeded maxTurns (${maxTurns})`, {
15
- code: "AGENT_MAX_TURNS_EXCEEDED",
16
- retryable: false,
17
- details: { maxTurns },
18
- cause: options?.cause,
19
- });
20
- this.name = "MaxTurnsExceededError";
21
- }
22
- }
23
- /**
24
- * Base class for classified LLM errors emitted by llm().
25
- */
26
- export class LLMError extends IronflowError {
27
- constructor(message, options) {
28
- super(message, options);
29
- this.name = "LLMError";
30
- }
31
- }
32
- /**
33
- * Provider refused the request (safety, policy, etc.).
34
- */
35
- export class LLMRefusalError extends LLMError {
36
- constructor(message, options) {
37
- super(message, {
38
- code: "LLM_REFUSAL",
39
- retryable: false,
40
- details: options?.details,
41
- cause: options?.cause,
42
- });
43
- this.name = "LLMRefusalError";
44
- }
45
- }
46
- /**
47
- * Provider returned content that failed JSON parsing when JSON was required.
48
- */
49
- export class LLMInvalidJSONError extends LLMError {
50
- constructor(message, options) {
51
- super(message, {
52
- code: "LLM_INVALID_JSON",
53
- retryable: true,
54
- details: options?.details,
55
- cause: options?.cause,
56
- });
57
- this.name = "LLMInvalidJSONError";
58
- }
59
- }
60
- /**
61
- * Provider truncated the response by hitting max_tokens.
62
- */
63
- export class LLMMaxTokensError extends LLMError {
64
- constructor(message, options) {
65
- super(message, {
66
- code: "LLM_MAX_TOKENS",
67
- retryable: false,
68
- details: options?.details,
69
- cause: options?.cause,
70
- });
71
- this.name = "LLMMaxTokensError";
72
- }
73
- }
74
- /**
75
- * Thrown when tool() input fails Zod validation.
76
- *
77
- * Distinct from generic ValidationError so callers can differentiate
78
- * agent-tool input failures from event-payload schema failures.
79
- */
80
- export class ToolValidationError extends IronflowError {
81
- constructor(toolName, issues, options) {
82
- super(`tool "${toolName}" input validation failed`, {
83
- code: "AGENT_TOOL_VALIDATION",
84
- retryable: false,
85
- details: { toolName, issues },
86
- cause: options?.cause,
87
- });
88
- this.name = "ToolValidationError";
89
- }
90
- }
91
- /**
92
- * Thrown when AgentConfig.tools contains two or more definitions sharing
93
- * the same name. Silent overwrite would let LLM-driven dispatch route to
94
- * an unintended handler — so we fail loudly at agent construction.
95
- */
96
- export class DuplicateToolError extends IronflowError {
97
- constructor(toolName) {
98
- super(`duplicate tool "${toolName}" registered on AgentConfig.tools`, {
99
- code: "AGENT_DUPLICATE_TOOL",
100
- retryable: false,
101
- details: { toolName },
102
- });
103
- this.name = "DuplicateToolError";
104
- }
105
- }
106
- /**
107
- * Thrown when ctx.tool(name, args) is called with a name that isn't
108
- * registered on AgentConfig.tools.
109
- */
110
- export class ToolNotFoundError extends IronflowError {
111
- constructor(toolName) {
112
- super(`tool "${toolName}" not registered on AgentConfig.tools — register it or call by reference`, {
113
- code: "AGENT_TOOL_NOT_FOUND",
114
- retryable: false,
115
- details: { toolName },
116
- });
117
- this.name = "ToolNotFoundError";
118
- }
119
- }
120
- /**
121
- * Thrown when memory.entityStream() is called without a projection.
122
- *
123
- * Per architecture decision: raw event replay is not exposed through
124
- * the agent memory API. Consumers must define a projection.
125
- */
126
- export class MemoryProjectionRequiredError extends IronflowError {
127
- constructor(streamId) {
128
- super(`memory.entityStream("${streamId}") requires a projection — raw replay is not exposed via the agent API`, {
129
- code: "AGENT_MEMORY_PROJECTION_REQUIRED",
130
- retryable: false,
131
- details: { streamId },
132
- });
133
- this.name = "MemoryProjectionRequiredError";
134
- }
135
- }
136
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/agent/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,YAAY,QAAgB,EAAE,OAA2B;QACvD,KAAK,CAAC,4BAA4B,QAAQ,GAAG,EAAE;YAC7C,IAAI,EAAE,0BAA0B;YAChC,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,QAAQ,EAAE;YACrB,KAAK,EAAE,OAAO,EAAE,KAAK;SACtB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,aAAa;IACzC,YACE,OAAe,EACf,OAKC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe,EAAE,OAA8D;QACzF,KAAK,CAAC,OAAO,EAAE;YACb,IAAI,EA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AY,QAAgB;QAC1B,KAAK,CAAC,mBAAmB,QAAQ,mCAAmC,EAAE;YACpE,IAAI,EAAE,sBAAsB;YAC5B,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,QAAQ,EAAE;SACtB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAClD,YAAY,QAAgB;QAC1B,KAAK,CACH,SAAS,QAAQ,0EAA0E,EAC3F;YACE,IAAI,EAAE,sBAAsB;YAC5B,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,QAAQ,EAAE;SACtB,CACF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,6BAA8B,SAAQ,aAAa;IAC9D,YAAY,QAAgB;QAC1B,KAAK,CACH,wBAAwB,QAAQ,wEAAwE,EACxG;YACE,IAAI,EAAE,kCAAkC;YACxC,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,QAAQ,EAAE;SACtB,CACF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF"}
@@ -1,30 +0,0 @@
1
- /**
2
- * @ironflow/node/agent — durable agent primitives.
3
- *
4
- * The agent module is sugar over the existing step client. Each helper
5
- * (tool, llm, approve, memory, spawn) records durable steps under the
6
- * hood, so agents inherit Ironflow's crash-resume, replay, audit, and
7
- * scoped-injection semantics with no new server primitives.
8
- *
9
- * Anti-scope (locked in CEO + eng review):
10
- * - No LLM provider router. Callers bring their own provider SDK and
11
- * pass the provider call into llm() — the wrapper memoizes the result.
12
- * - No prompt templating. Reasoning frameworks (LangGraph, Claude SDK,
13
- * CrewAI) own that surface. Ironflow hosts them, not replaces them.
14
- * - No graph execution. agent() runs a plain async handler.
15
- *
16
- * Public API:
17
- *
18
- * import { agent, tool, llm, approve, memory, spawn, exposeMcp }
19
- * from "@ironflow/node/agent";
20
- *
21
- * See docs/explanation/comparison-agents.md for the layering model.
22
- */
23
- export type { AgentConfig, AgentContext, AgentHandler, ApproveFn, ApproveOptions, ApproveResult, ExposeMcpConfig, IronflowAgent, LLMClient, LLMCompleteRequest, LLMCompleteResult, McpToolDef, MemoryAppendOptions, MemoryClient, MemoryGetOptions, MemoryConfig, SpawnFn, SpawnOptions, SpawnResult, AnyToolDefinition, ToolDefinition, ToolFn, ToolIdempotency, } from "./types.js";
24
- export { DuplicateToolError, LLMError, LLMInvalidJSONError, LLMMaxTokensError, LLMRefusalError, MaxTurnsExceededError, MemoryProjectionRequiredError, ToolNotFoundError, ToolValidationError, } from "./errors.js";
25
- export { agent } from "./agent.js";
26
- export { defineTool } from "./tool.js";
27
- export { exposeMcp } from "./mcp.js";
28
- export type { ExposeMcpHandle } from "./mcp.js";
29
- export type { MemoryBackend } from "./memory.js";
30
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,YAAY,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * @ironflow/node/agent — durable agent primitives.
3
- *
4
- * The agent module is sugar over the existing step client. Each helper
5
- * (tool, llm, approve, memory, spawn) records durable steps under the
6
- * hood, so agents inherit Ironflow's crash-resume, replay, audit, and
7
- * scoped-injection semantics with no new server primitives.
8
- *
9
- * Anti-scope (locked in CEO + eng review):
10
- * - No LLM provider router. Callers bring their own provider SDK and
11
- * pass the provider call into llm() — the wrapper memoizes the result.
12
- * - No prompt templating. Reasoning frameworks (LangGraph, Claude SDK,
13
- * CrewAI) own that surface. Ironflow hosts them, not replaces them.
14
- * - No graph execution. agent() runs a plain async handler.
15
- *
16
- * Public API:
17
- *
18
- * import { agent, tool, llm, approve, memory, spawn, exposeMcp }
19
- * from "@ironflow/node/agent";
20
- *
21
- * See docs/explanation/comparison-agents.md for the layering model.
22
- */
23
- export { DuplicateToolError, LLMError, LLMInvalidJSONError, LLMMaxTokensError, LLMRefusalError, MaxTurnsExceededError, MemoryProjectionRequiredError, ToolNotFoundError, ToolValidationError, } from "./errors.js";
24
- export { agent } from "./agent.js";
25
- export { defineTool } from "./tool.js";
26
- export { exposeMcp } from "./mcp.js";
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA4BH,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Process-local registry that links exposeMcp() to serve()'s dispatch
3
- * handler. Keyed by qualified name (`{agentName}.{toolName}`).
4
- *
5
- * The Ironflow server holds the canonical registry (NATS KV in cluster
6
- * mode, in-memory in single-node). This map is the SDK's local mirror —
7
- * we need the McpToolDef closure (handler + Zod schemas) and the HMAC
8
- * secret to validate inbound dispatches.
9
- *
10
- * Single instance per Node.js process. Re-registering the same agent
11
- * name overwrites the prior entries; unregister removes them. HMR may
12
- * leave stale entries until the next exposeMcp() call rotates them —
13
- * acceptable for dev, documented in the README.
14
- */
15
- import type { AnyMcpToolDef } from "./types.js";
16
- export interface RegisteredTool {
17
- agentName: string;
18
- qualifiedName: string;
19
- hmacSecret: string;
20
- def: AnyMcpToolDef;
21
- }
22
- export declare function registerLocal(entry: RegisteredTool): void;
23
- export declare function unregisterLocal(agentName: string): string[];
24
- export declare function lookupLocal(qualifiedName: string): RegisteredTool | undefined;
25
- /** Test-only — drop all entries. */
26
- export declare function clearLocalForTests(): void;
27
- //# sourceMappingURL=internal-registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-registry.d.ts","sourceRoot":"","sources":["../../src/agent/internal-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,aAAa,CAAC;CACpB;AAID,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAEzD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAS3D;AAED,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE7E;AAED,oCAAoC;AACpC,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -1,36 +0,0 @@
1
- /**
2
- * Process-local registry that links exposeMcp() to serve()'s dispatch
3
- * handler. Keyed by qualified name (`{agentName}.{toolName}`).
4
- *
5
- * The Ironflow server holds the canonical registry (NATS KV in cluster
6
- * mode, in-memory in single-node). This map is the SDK's local mirror —
7
- * we need the McpToolDef closure (handler + Zod schemas) and the HMAC
8
- * secret to validate inbound dispatches.
9
- *
10
- * Single instance per Node.js process. Re-registering the same agent
11
- * name overwrites the prior entries; unregister removes them. HMR may
12
- * leave stale entries until the next exposeMcp() call rotates them —
13
- * acceptable for dev, documented in the README.
14
- */
15
- const registry = new Map();
16
- export function registerLocal(entry) {
17
- registry.set(entry.qualifiedName, entry);
18
- }
19
- export function unregisterLocal(agentName) {
20
- const removed = [];
21
- for (const [qualifiedName, entry] of registry) {
22
- if (entry.agentName === agentName) {
23
- registry.delete(qualifiedName);
24
- removed.push(qualifiedName);
25
- }
26
- }
27
- return removed;
28
- }
29
- export function lookupLocal(qualifiedName) {
30
- return registry.get(qualifiedName);
31
- }
32
- /** Test-only — drop all entries. */
33
- export function clearLocalForTests() {
34
- registry.clear();
35
- }
36
- //# sourceMappingURL=internal-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-registry.js","sourceRoot":"","sources":["../../src/agent/internal-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAWH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEnD,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC9C,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAClC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,aAAqB;IAC/C,OAAO,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,kBAAkB;IAChC,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Internal utilities shared by agent module wrappers.
3
- *
4
- * Not part of the public API surface — `index.ts` does not re-export.
5
- */
6
- import type { Duration } from "@ironflow/core";
7
- /**
8
- * Normalize a Duration (string | number) into the ms-suffixed string form
9
- * that step.run options.timeout expects.
10
- *
11
- * normalizeDuration("30s") → "30s"
12
- * normalizeDuration(5000) → "5000ms"
13
- * normalizeDuration(undefined) → undefined
14
- */
15
- export declare function normalizeDuration(value: Duration | undefined): string | undefined;
16
- /**
17
- * Escape a value for safe interpolation into a CEL-style match expression
18
- * (`data.field == "<value>"`). Replaces `\` and `"` with escaped forms.
19
- *
20
- * Internal IDs are unlikely to contain quotes, but defending against it
21
- * prevents broken filters if upstream ever loosens the format.
22
- */
23
- export declare function escapeMatchValue(value: string): string;
24
- //# sourceMappingURL=internal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/agent/internal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -1,29 +0,0 @@
1
- /**
2
- * Internal utilities shared by agent module wrappers.
3
- *
4
- * Not part of the public API surface — `index.ts` does not re-export.
5
- */
6
- /**
7
- * Normalize a Duration (string | number) into the ms-suffixed string form
8
- * that step.run options.timeout expects.
9
- *
10
- * normalizeDuration("30s") → "30s"
11
- * normalizeDuration(5000) → "5000ms"
12
- * normalizeDuration(undefined) → undefined
13
- */
14
- export function normalizeDuration(value) {
15
- if (value === undefined)
16
- return undefined;
17
- return typeof value === "number" ? `${value}ms` : value;
18
- }
19
- /**
20
- * Escape a value for safe interpolation into a CEL-style match expression
21
- * (`data.field == "<value>"`). Replaces `\` and `"` with escaped forms.
22
- *
23
- * Internal IDs are unlikely to contain quotes, but defending against it
24
- * prevents broken filters if upstream ever loosens the format.
25
- */
26
- export function escapeMatchValue(value) {
27
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
28
- }
29
- //# sourceMappingURL=internal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/agent/internal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA2B;IAC3D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * llm() — memoized completion sugar with classified error surface.
3
- *
4
- * The wrapper does not own a provider router. Callers pass a closure
5
- * (request.call) that talks to their provider of choice and returns a
6
- * normalized LLMCompleteResult. The wrapper:
7
- *
8
- * 1. Increments the agent turn counter and gates against maxTurns.
9
- * 2. Wraps the closure in step.run so the assistant response is
10
- * memoized for crash-resume.
11
- * 3. Inspects result.finishReason to raise classified errors:
12
- * "refusal" → LLMRefusalError
13
- * "max_tokens"/"length" → LLMMaxTokensError
14
- * JSON-parse failures must be raised by the caller, by detecting
15
- * invalid JSON in their closure and throwing LLMInvalidJSONError.
16
- *
17
- * Anti-scope: provider routing, prompt templating, and streaming all
18
- * stay out of this module. See module README.
19
- */
20
- import type { StepClient } from "@ironflow/core";
21
- import type { LLMClient } from "./types.js";
22
- /**
23
- * Turn counter shared between llm() invocations and AgentContext.turn.
24
- *
25
- * Plain mutable object so the AgentContext getter can read the live value
26
- * without callers needing a reactive abstraction.
27
- */
28
- export interface TurnCounter {
29
- value: number;
30
- }
31
- /** Construct a fresh turn counter. */
32
- export declare function createTurnCounter(): TurnCounter;
33
- /**
34
- * Build an LLMClient bound to the given step + counter.
35
- *
36
- * Exported for use by agent.ts; not part of the public API surface.
37
- */
38
- export declare function makeLlm(step: StepClient, counter: TurnCounter, maxTurns: number): LLMClient;
39
- //# sourceMappingURL=llm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/agent/llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,KAAK,EACV,SAAS,EAGV,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,sCAAsC;AACtC,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,MAAM,GACf,SAAS,CAYX"}