@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
package/dist/agent/llm.js DELETED
@@ -1,59 +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 { LLMMaxTokensError, LLMRefusalError, MaxTurnsExceededError, } from "./errors.js";
21
- /** Construct a fresh turn counter. */
22
- export function createTurnCounter() {
23
- return { value: 0 };
24
- }
25
- /**
26
- * Build an LLMClient bound to the given step + counter.
27
- *
28
- * Exported for use by agent.ts; not part of the public API surface.
29
- */
30
- export function makeLlm(step, counter, maxTurns) {
31
- return {
32
- async complete(request) {
33
- counter.value += 1;
34
- if (counter.value > maxTurns) {
35
- throw new MaxTurnsExceededError(maxTurns);
36
- }
37
- const result = await step.run(`llm.turn`, () => request.call());
38
- classifyResult(result);
39
- return result;
40
- },
41
- };
42
- }
43
- function classifyResult(result) {
44
- const reason = result.finishReason;
45
- if (!reason)
46
- return;
47
- const normalized = reason.toLowerCase();
48
- if (normalized === "refusal" || normalized === "safety" || normalized === "content_filter") {
49
- throw new LLMRefusalError(`provider refused: ${reason}`, {
50
- details: { finishReason: reason, metadata: result.metadata },
51
- });
52
- }
53
- if (normalized === "max_tokens" || normalized === "length") {
54
- throw new LLMMaxTokensError(`provider hit max_tokens (${reason})`, {
55
- details: { finishReason: reason, metadata: result.metadata },
56
- });
57
- }
58
- }
59
- //# sourceMappingURL=llm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/agent/llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAiBrB,sCAAsC;AACtC,MAAM,UAAU,iBAAiB;IAC/B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACrB,IAAgB,EAChB,OAAoB,EACpB,QAAgB;IAEhB,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,OAA2B;YACxC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;YACnB,IAAI,OAAO,CAAC,KAAK,GAAG,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAC5C,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAChE,cAAc,CAAC,MAAM,CAAC,CAAC;YACvB,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,MAAyB;IAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;IACnC,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACxC,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,gBAAgB,EAAE,CAAC;QAC3F,MAAM,IAAI,eAAe,CAAC,qBAAqB,MAAM,EAAE,EAAE;YACvD,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAC7D,CAAC,CAAC;IACL,CAAC;IACD,IAAI,UAAU,KAAK,YAAY,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;QAC3D,MAAM,IAAI,iBAAiB,CAAC,4BAA4B,MAAM,GAAG,EAAE;YACjE,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAC7D,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -1,51 +0,0 @@
1
- /**
2
- * exposeMcp() — register agent tools with Ironflow's AgentToolsService
3
- * and serve dispatched invocations over the existing serve() mount.
4
- *
5
- * Boot-time flow:
6
- *
7
- * 1. Convert each McpToolDef.input (Zod) → JSON Schema (Draft 2020-12)
8
- * via z.toJSONSchema().
9
- * 2. POST `/ironflow.v1.AgentToolsService/RegisterTool` with
10
- * {agentName, callbackUrl, tools[]}.
11
- * 3. Stash the returned HMAC secret + def closures in the local
12
- * registry so serve()'s dispatch route can validate inbound calls.
13
- *
14
- * Callback flow lives in `dispatch.ts` (HMAC verify + Zod parse + handler).
15
- *
16
- * Authoritative authorization stays server-side: scopes on McpToolDef
17
- * are advisory hints to MCP clients. The server enforces api_key.tool_scopes
18
- * superset against ToolDef.required_scopes. RegisterTool requires the
19
- * `agent:tools:register` action on the calling key.
20
- */
21
- import type { ExposeMcpConfig } from "./types.js";
22
- /**
23
- * Handle returned from exposeMcp(). `unregister()` removes the tools
24
- * from both the Ironflow server's registry and the local SDK mirror.
25
- */
26
- export interface ExposeMcpHandle {
27
- /** Server name (== agent namespace) reported to MCP clients. */
28
- readonly name: string;
29
- /** Number of tools registered with the server. */
30
- readonly toolCount: number;
31
- /** Status indicator. "active" once RegisterTool succeeds. */
32
- readonly status: "active";
33
- /** Qualified names registered (`{agentName}.{toolName}`). */
34
- readonly toolNames: ReadonlyArray<string>;
35
- /**
36
- * Remove all tools registered under this agent name. Idempotent —
37
- * server returns 200 with removed_count=0 if the agent was already
38
- * gone. Local registry entries are cleared even if the server call
39
- * fails so handler closures don't leak.
40
- */
41
- unregister(): Promise<void>;
42
- }
43
- /**
44
- * Register the supplied MCP tool definitions with the Ironflow server.
45
- *
46
- * Returns an active handle once RegisterTool succeeds. Throws on
47
- * empty tool lists, missing config (server URL / API key / callback URL),
48
- * or transport failure.
49
- */
50
- export declare function exposeMcp(config: ExposeMcpConfig): Promise<ExposeMcpHandle>;
51
- //# sourceMappingURL=mcp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/agent/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,YAAY,CAAC;AAKjE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAOD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAmGjF"}
package/dist/agent/mcp.js DELETED
@@ -1,155 +0,0 @@
1
- /**
2
- * exposeMcp() — register agent tools with Ironflow's AgentToolsService
3
- * and serve dispatched invocations over the existing serve() mount.
4
- *
5
- * Boot-time flow:
6
- *
7
- * 1. Convert each McpToolDef.input (Zod) → JSON Schema (Draft 2020-12)
8
- * via z.toJSONSchema().
9
- * 2. POST `/ironflow.v1.AgentToolsService/RegisterTool` with
10
- * {agentName, callbackUrl, tools[]}.
11
- * 3. Stash the returned HMAC secret + def closures in the local
12
- * registry so serve()'s dispatch route can validate inbound calls.
13
- *
14
- * Callback flow lives in `dispatch.ts` (HMAC verify + Zod parse + handler).
15
- *
16
- * Authoritative authorization stays server-side: scopes on McpToolDef
17
- * are advisory hints to MCP clients. The server enforces api_key.tool_scopes
18
- * superset against ToolDef.required_scopes. RegisterTool requires the
19
- * `agent:tools:register` action on the calling key.
20
- */
21
- import { IronflowError } from "@ironflow/core";
22
- import { z } from "zod";
23
- import { registerLocal, unregisterLocal, } from "./internal-registry.js";
24
- const REGISTER_PATH = "/ironflow.v1.AgentToolsService/RegisterTool";
25
- const UNREGISTER_PATH = "/ironflow.v1.AgentToolsService/UnregisterTool";
26
- /**
27
- * Register the supplied MCP tool definitions with the Ironflow server.
28
- *
29
- * Returns an active handle once RegisterTool succeeds. Throws on
30
- * empty tool lists, missing config (server URL / API key / callback URL),
31
- * or transport failure.
32
- */
33
- export async function exposeMcp(config) {
34
- if (!config.tools.length) {
35
- throw new IronflowError("exposeMcp() requires at least one tool", {
36
- code: "AGENT_MCP_NO_TOOLS",
37
- retryable: false,
38
- });
39
- }
40
- if (!config.callbackUrl) {
41
- throw new IronflowError("exposeMcp() requires callbackUrl pointing at your serve() mount", { code: "AGENT_MCP_MISSING_CALLBACK_URL", retryable: false });
42
- }
43
- const serverUrl = config.serverUrl ??
44
- process.env.IRONFLOW_URL ??
45
- process.env.IRONFLOW_SERVER_URL;
46
- if (!serverUrl) {
47
- throw new IronflowError("exposeMcp() requires serverUrl (or IRONFLOW_URL / IRONFLOW_SERVER_URL env)", { code: "AGENT_MCP_MISSING_SERVER_URL", retryable: false });
48
- }
49
- const apiKey = config.apiKey ?? process.env.IRONFLOW_API_KEY;
50
- if (!apiKey) {
51
- throw new IronflowError("exposeMcp() requires apiKey (or IRONFLOW_API_KEY env) with the agent:tools:register action", { code: "AGENT_MCP_MISSING_API_KEY", retryable: false });
52
- }
53
- const seen = new Set();
54
- const toolPayload = config.tools.map((def) => {
55
- if (seen.has(def.name)) {
56
- throw new IronflowError(`exposeMcp() received duplicate tool name "${def.name}"`, { code: "AGENT_MCP_DUPLICATE_TOOL", retryable: false });
57
- }
58
- seen.add(def.name);
59
- return toToolDefJSON(def);
60
- });
61
- const requestBody = {
62
- agentName: config.name,
63
- callbackUrl: config.callbackUrl,
64
- tools: toolPayload,
65
- };
66
- const resp = await postJSON(serverUrl, REGISTER_PATH, apiKey, requestBody);
67
- const decoded = (await readJSON(resp));
68
- if (!decoded.hmacSecret || !decoded.registeredToolNames?.length) {
69
- throw new IronflowError("RegisterTool response missing hmacSecret or registeredToolNames", { code: "AGENT_MCP_INVALID_RESPONSE", retryable: false });
70
- }
71
- const qualifiedNames = decoded.registeredToolNames;
72
- for (const def of config.tools) {
73
- const qualifiedName = `${config.name}.${def.name}`;
74
- const entry = {
75
- agentName: config.name,
76
- qualifiedName,
77
- hmacSecret: decoded.hmacSecret,
78
- def,
79
- };
80
- registerLocal(entry);
81
- }
82
- let unregistered = false;
83
- return {
84
- name: config.name,
85
- toolCount: qualifiedNames.length,
86
- status: "active",
87
- toolNames: qualifiedNames,
88
- async unregister() {
89
- if (unregistered) {
90
- return;
91
- }
92
- unregistered = true;
93
- // Always clear local entries so handler closures stop receiving
94
- // dispatches even when the server-side call fails.
95
- unregisterLocal(config.name);
96
- try {
97
- const r = await postJSON(serverUrl, UNREGISTER_PATH, apiKey, {
98
- agentName: config.name,
99
- });
100
- await readJSON(r);
101
- }
102
- catch (err) {
103
- throw new IronflowError(`unregister failed: ${err instanceof Error ? err.message : String(err)}`, { code: "AGENT_MCP_UNREGISTER_FAILED", retryable: false });
104
- }
105
- },
106
- };
107
- }
108
- function toToolDefJSON(def) {
109
- let schemaObj;
110
- try {
111
- schemaObj = z.toJSONSchema(def.input);
112
- }
113
- catch (err) {
114
- throw new IronflowError(`exposeMcp() failed to convert input schema for "${def.name}": ${err instanceof Error ? err.message : String(err)}`, { code: "AGENT_MCP_SCHEMA_CONVERSION_FAILED", retryable: false });
115
- }
116
- return {
117
- name: def.name,
118
- description: def.description,
119
- inputSchemaJson: JSON.stringify(schemaObj),
120
- requiredScopes: def.scopes ? [...def.scopes] : [],
121
- timeoutMs: 0,
122
- };
123
- }
124
- async function postJSON(serverUrl, path, apiKey, body) {
125
- const url = `${serverUrl.replace(/\/+$/, "")}${path}`;
126
- const resp = await fetch(url, {
127
- method: "POST",
128
- headers: {
129
- "Content-Type": "application/json",
130
- Authorization: `Bearer ${apiKey}`,
131
- },
132
- body: JSON.stringify(body),
133
- });
134
- if (!resp.ok) {
135
- const text = await resp.text().catch(() => "");
136
- throw new IronflowError(`POST ${path} failed: HTTP ${resp.status}${text ? ` — ${text}` : ""}`, { code: "AGENT_MCP_TRANSPORT_ERROR", retryable: false });
137
- }
138
- return resp;
139
- }
140
- async function readJSON(resp) {
141
- const text = await resp.text();
142
- if (!text) {
143
- return {};
144
- }
145
- try {
146
- return JSON.parse(text);
147
- }
148
- catch {
149
- throw new IronflowError(`response body is not valid JSON: ${text.slice(0, 256)}`, {
150
- code: "AGENT_MCP_INVALID_RESPONSE",
151
- retryable: false,
152
- });
153
- }
154
- }
155
- //# sourceMappingURL=mcp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/agent/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,CA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AAC;AAED,KAAK,UAAU,QAAQ,CAAC,IAAc;IACpC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,aAAa,CAAC,oCAAoC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE;YAChF,IAAI,EAAE,4BAA4B;YAClC,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -1,74 +0,0 @@
1
- /**
2
- * memory() — durable agent memory backed by an entity stream + projection.
3
- *
4
- * Composition:
5
- * - memory.append(eventName, data) → step.run wraps backend.appendEvent +
6
- * auto-waitForCatchup so memory.get() inside the same run sees the write.
7
- * - memory.get() → step.run wraps backend.getProjection. In-run cache
8
- * short-circuits repeated reads. Cache invalidates on append.
9
- * - memory.entityStream() — kept as NotImplementedError stub. Lands when a
10
- * concrete cross-agent peer-memory use case surfaces.
11
- *
12
- * Cross-run retry safety: append generates a deterministic idempotencyKey
13
- * (`${runId}:memory.append:${counter}`) so a replayed handler appends the
14
- * same logical event and the server dedupes server-side.
15
- *
16
- * Anti-scope: raw event replay is not exposed. Consumers must register a
17
- * projection — see MemoryProjectionRequiredError.
18
- */
19
- import type { AppendResult, ProjectionStateResult, StepClient } from "@ironflow/core";
20
- import type { MemoryClient, MemoryConfig } from "./types.js";
21
- /**
22
- * Minimal backend the memory client needs. Wraps the IronflowClient surface
23
- * so tests can substitute a fake without constructing a real client.
24
- *
25
- * Method shapes mirror the underlying client methods:
26
- * - appendEvent → client.streams.append
27
- * - getProjection → client.projections.get
28
- * - waitForCatchup → client.projections.waitForCatchup
29
- */
30
- export interface MemoryBackend {
31
- appendEvent(streamId: string, input: {
32
- name: string;
33
- data: Record<string, unknown>;
34
- entityType: string;
35
- idempotencyKey: string;
36
- metadata?: Record<string, unknown>;
37
- }): Promise<AppendResult>;
38
- getProjection<TState = unknown>(name: string): Promise<ProjectionStateResult<TState>>;
39
- waitForCatchup(name: string, opts: {
40
- minSeq: number;
41
- partition?: string;
42
- timeoutMs?: number;
43
- }): Promise<void>;
44
- }
45
- /**
46
- * Per-run in-memory cache for memory.get() reads.
47
- *
48
- * Default cache-on; invalidates on memory.append() within the same run.
49
- * Lives across step boundaries within a run, replaced fresh on replay.
50
- */
51
- export interface MemoryRuntimeCache {
52
- has: boolean;
53
- value: unknown;
54
- }
55
- export declare function createMemoryRuntimeCache(): MemoryRuntimeCache;
56
- /**
57
- * Tracks per-run append counter used for idempotency-key generation.
58
- *
59
- * Resets per run; replay on the same run reuses the counter value from
60
- * the call ordering — same sequence of memory.append calls produces the
61
- * same sequence of keys, so the server dedupes deterministically.
62
- */
63
- export interface MemoryRuntimeCounters {
64
- appendCount: number;
65
- }
66
- export declare function createMemoryRuntimeCounters(): MemoryRuntimeCounters;
67
- /**
68
- * Build a MemoryClient backed by the supplied backend.
69
- *
70
- * The backend is required when `config` is set. Tests pass a fake backend;
71
- * agent.ts constructs the default backend from a runtime IronflowClient.
72
- */
73
- export declare function makeMemory(step: StepClient, config: MemoryConfig | undefined, runId: string, cache: MemoryRuntimeCache, backend: MemoryBackend | undefined, counters?: MemoryRuntimeCounters): MemoryClient;
74
- //# sourceMappingURL=memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agent/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAEV,YAAY,EACZ,YAAY,EAEb,MAAM,YAAY,CAAC;AAgCpB;;;;;;;;GAQG;A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Composition:
5
- * - memory.append(eventName, data) → step.run wraps backend.appendEvent +
6
- * auto-waitForCatchup so memory.get() inside the same run sees the write.
7
- * - memory.get() → step.run wraps backend.getProjection. In-run cache
8
- * short-circuits repeated reads. Cache invalidates on append.
9
- * - memory.entityStream() — kept as NotImplementedError stub. Lands when a
10
- * concrete cross-agent peer-memory use case surfaces.
11
- *
12
- * Cross-run retry safety: append generates a deterministic idempotencyKey
13
- * (`${runId}:memory.append:${counter}`) so a replayed handler appends the
14
- * same logical event and the server dedupes server-side.
15
- *
16
- * Anti-scope: raw event replay is not exposed. Consumers must register a
17
- * projection — see MemoryProjectionRequiredError.
18
- */
19
- import { IronflowError } from "@ironflow/core";
20
- import { MemoryProjectionRequiredError } from "./errors.js";
21
- /**
22
- * Wait timeout for the auto-catchup after append. Stream-level minSeq is
23
- * sufficient for read-your-writes — partition param is intentionally not
24
- * passed. External projections (cursor at stream level only) reject
25
- * partition with 400; managed projections accept it but it adds nothing
26
- * for the typical single-stream agent memory pattern.
27
- */
28
- const DEFAULT_WAIT_TIMEOUT_MS = 5000;
29
- /**
30
- * Default entity type when MemoryConfig.entityType is omitted. Server-side
31
- * the field is informational; "agent" matches the typical streamId convention
32
- * and avoids surprising users who don't know about it.
33
- */
34
- const DEFAULT_ENTITY_TYPE = "agent";
35
- class NotImplementedError extends IronflowError {
36
- constructor(method) {
37
- super(`memory.${method}() is not yet implemented — entityStream lands when a concrete cross-agent peer-memory use case surfaces`, {
38
- code: "AGENT_MEMORY_NOT_IMPLEMENTED",
39
- retryable: false,
40
- details: { method },
41
- });
42
- this.name = "NotImplementedError";
43
- }
44
- }
45
- export function createMemoryRuntimeCache() {
46
- return { has: false, value: undefined };
47
- }
48
- export function createMemoryRuntimeCounters() {
49
- return { appendCount: 0 };
50
- }
51
- /**
52
- * Build a MemoryClient backed by the supplied backend.
53
- *
54
- * The backend is required when `config` is set. Tests pass a fake backend;
55
- * agent.ts constructs the default backend from a runtime IronflowClient.
56
- */
57
- export function makeMemory(step, config, runId, cache, backend, counters = createMemoryRuntimeCounters()) {
58
- return {
59
- async get(options) {
60
- assertConfigured(config);
61
- if (!options?.bypassCache && cache.has) {
62
- return cache.value;
63
- }
64
- assertBackend(backend);
65
- const result = await step.run("memory.get", () => backend.getProjection(config.projection));
66
- const state = result.state ?? undefined;
67
- cache.has = true;
68
- cache.value = state;
69
- return state;
70
- },
71
- async append(eventName, data, options) {
72
- assertConfigured(config);
73
- assertBackend(backend);
74
- const dataRecord = toAppendRecord(data);
75
- const counterIndex = counters.appendCount;
76
- counters.appendCount += 1;
77
- const idempotencyKey = `${runId}:memory.append:${counterIndex}`;
78
- const appended = await step.run("memory.append", () => backend.appendEvent(config.streamId, {
79
- name: eventName,
80
- data: dataRecord,
81
- entityType: config.entityType ?? DEFAULT_ENTITY_TYPE,
82
- idempotencyKey,
83
- metadata: options?.metadata,
84
- }));
85
- if (appended.sequence && appended.sequence > 0) {
86
- await step.run("memory.append.wait", () => backend.waitForCatchup(config.projection, {
87
- minSeq: appended.sequence,
88
- timeoutMs: DEFAULT_WAIT_TIMEOUT_MS,
89
- }));
90
- }
91
- cache.has = false;
92
- cache.value = undefined;
93
- },
94
- async entityStream(streamId, projectionName) {
95
- if (!projectionName) {
96
- throw new MemoryProjectionRequiredError(streamId);
97
- }
98
- throw new NotImplementedError("entityStream");
99
- },
100
- };
101
- }
102
- function assertConfigured(config) {
103
- if (!config) {
104
- throw new IronflowError("memory() requires AgentConfig.memory ({ streamId, projection }) to be set", { code: "AGENT_MEMORY_UNCONFIGURED", retryable: false });
105
- }
106
- }
107
- function assertBackend(backend) {
108
- if (!backend) {
109
- throw new IronflowError("memory() requires a runtime backend — set IRONFLOW_URL (or IRONFLOW_SERVER_URL) so the agent can construct an IronflowClient, or inject a backend via test harness", { code: "AGENT_MEMORY_NO_BACKEND", retryable: false });
110
- }
111
- }
112
- /**
113
- * Convert the user's data argument into the object shape AppendEvent expects.
114
- *
115
- * Rejects primitives, arrays, and null with a typed error rather than
116
- * silently wrapping them in `{ value }`. The wrap-on-write would round-trip
117
- * cleanly only if every projection reducer knows to unwrap it; rejecting
118
- * up-front avoids the silent shape mismatch.
119
- */
120
- function toAppendRecord(data) {
121
- if (data === null || typeof data !== "object" || Array.isArray(data)) {
122
- throw new IronflowError("memory.append() requires data to be a plain object — primitives and arrays must be wrapped explicitly so the projection reducer sees a stable shape", {
123
- code: "AGENT_MEMORY_INVALID_DATA",
124
- retryable: false,
125
- details: { receivedType: data === null ? "null" : Array.isArray(data) ? "array" : typeof data },
126
- });
127
- }
128
- return data;
129
- }
130
- //# sourceMappingURL=memory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/agent/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAQ5D;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAEpC,MAAM,mBAAoB,SAAQ,aAAa;IAC7C,YAAY,MAAc;QACxB,KAAK,CACH,UAAU,MAAM,0GAA0G,EAC1H;YACE,IAAI,EAAE,8BAA8B;YACpC,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,MAAM,EAAE;SACpB,CACF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AA4CD,MAAM,UAAU,wBAAwB;IACtC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC1C,CAAC;AAaD,MAAM,UAAU,2BAA2B;IACzC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,IAAgB,EAChB,MAAgC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AAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,aAAa,CACrB,qJAAqJ,EACrJ;YACE,IAAI,EAAE,2BAA2B;YACjC,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE;SAChG,CACF,CAAC;IACJ,CAAC;IACD,OAAO,IAA+B,CAAC;AACzC,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * spawn() — durable sub-agent invocation.
3
- *
4
- * Wraps step.invoke (or step.invokeAsync for fire-and-forget) so the
5
- * sub-agent run is part of the parent's durable plan. Crash-resume
6
- * applies: re-running the parent after a crash replays the cached
7
- * sub-agent output without re-invoking.
8
- *
9
- * Parent ↔ child run linkage is recorded server-side by the existing
10
- * invoke implementation. spawn() doesn't add new linkage state.
11
- */
12
- import type { StepClient } from "@ironflow/core";
13
- import type { SpawnFn } from "./types.js";
14
- /**
15
- * Build a SpawnFn bound to the given step client.
16
- *
17
- * Exported for use by agent.ts; not part of the public API surface.
18
- */
19
- export declare function makeSpawn(step: StepClient): SpawnFn;
20
- //# sourceMappingURL=spawn.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/agent/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAA6B,MAAM,YAAY,CAAC;AAErE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAkBnD"}
@@ -1,29 +0,0 @@
1
- /**
2
- * spawn() — durable sub-agent invocation.
3
- *
4
- * Wraps step.invoke (or step.invokeAsync for fire-and-forget) so the
5
- * sub-agent run is part of the parent's durable plan. Crash-resume
6
- * applies: re-running the parent after a crash replays the cached
7
- * sub-agent output without re-invoking.
8
- *
9
- * Parent ↔ child run linkage is recorded server-side by the existing
10
- * invoke implementation. spawn() doesn't add new linkage state.
11
- */
12
- /**
13
- * Build a SpawnFn bound to the given step client.
14
- *
15
- * Exported for use by agent.ts; not part of the public API surface.
16
- */
17
- export function makeSpawn(step) {
18
- return async function spawn(name, options) {
19
- const stepName = `spawn.${name}`;
20
- const shouldAwait = options.await !== false;
21
- if (shouldAwait) {
22
- const output = await step.invoke(options.functionId, options.input);
23
- return { output };
24
- }
25
- const handle = await step.run(stepName, () => step.invokeAsync(options.functionId, options.input));
26
- return { runId: handle.runId };
27
- };
28
- }
29
- //# sourceMappingURL=spawn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../src/agent/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,OAAO,KAAK,UAAU,KAAK,CACzB,IAAY,EACZ,OAA6B;QAE7B,MAAM,QAAQ,GAAG,SAAS,IAAI,EAAE,CAAC;QACjC,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC;QAE5C,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAU,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7E,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAC3C,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,CACpD,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * tool() — durable, validated, idempotent tool invocation.
3
- *
4
- * Wraps step.run with:
5
- * - Required Zod input validation (per CEO plan, JS-only)
6
- * - Idempotency strategy: "byCall" (default) or "byArgs"
7
- * - Per-tool timeout (default 60s)
8
- *
9
- * defineTool() is a pass-through factory that preserves the input/output
10
- * generic types for callers. The runtime call helper is constructed by
11
- * makeTool() and bound onto AgentContext.tool.
12
- */
13
- import type { StepClient } from "@ironflow/core";
14
- import type { AnyToolDefinition, ToolDefinition, ToolFn } from "./types.js";
15
- /**
16
- * Per-run state shared by tool() invocations.
17
- *
18
- * byArgs idempotency reuses a single in-flight or resolved promise per
19
- * (tool name, args hash) pair, so concurrent or repeat calls with the
20
- * same args fold into one durable step.
21
- */
22
- export interface ToolRuntime {
23
- readonly byArgsCache: Map<string, Promise<unknown>>;
24
- }
25
- /**
26
- * Define a tool. Pass-through factory that preserves the input/output
27
- * generic types. Tools are typically registered via AgentConfig.tools so
28
- * the agent can dispatch LLM-requested calls by name.
29
- */
30
- export declare function defineTool<TInput, TOutput>(spec: ToolDefinition<TInput, TOutput>): ToolDefinition<TInput, TOutput>;
31
- /**
32
- * Build a ToolFn closure bound to the given step client and tool registry.
33
- *
34
- * Exported for use by agent.ts; not part of the public API surface.
35
- */
36
- export declare function makeTool(step: StepClient, registry: ReadonlyMap<string, AnyToolDefinition>, runtime: ToolRuntime): ToolFn;
37
- /** Construct an empty ToolRuntime. Used by agent() per run. */
38
- export declare function createToolRuntime(): ToolRuntime;
39
- //# sourceMappingURL=tool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/agent/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAK5E;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CACrD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EACxC,IAAI,EAAE,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAChD,OAAO,EAAE,WAAW,GACnB,MAAM,CASR;AAoFD,+DAA+D;AAC/D,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C"}