@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/LICENSE ADDED
@@ -0,0 +1,181 @@
1
+ # Ironflow License
2
+
3
+ **Version 1.0 — 2026-05-08**
4
+
5
+ This file contains the binding legal terms under which Ironflow is offered.
6
+ A plain-English summary lives at `docs/explanation/licensing.md`. If the two
7
+ disagree, this file controls.
8
+
9
+ > **Lawyer review status:** v1 DIY-substitute. Pending counsel review before
10
+ > the first paid customer ships (issue #777). All of the following MUST be
11
+ > resolved before this license is published on the public release mirror:
12
+ >
13
+ > - `[LICENSOR_ENTITY]` placeholder filled with the legal entity name
14
+ > - `[LICENSE_EMAIL]` placeholder filled with the commercial-licensing
15
+ > contact address
16
+ > - "Personal-Use and Evaluation Carve-Out" section reviewed by counsel —
17
+ > this is supplemental to the FSL Permitted Purpose and was added to
18
+ > match the worked examples in `docs/explanation/licensing.md` per the
19
+ > plan body. JetBrains Toolbox + Postman free-tier EULAs were the
20
+ > reference for the carve-out shape, but the wording is original prose
21
+ > and has not been counsel-reviewed.
22
+ > - "Governing Law and Venue" + "Commercial Licensing" sections reviewed
23
+ > by counsel — these are original prose, not part of the FSL template.
24
+ >
25
+ > **Versioning:** revised terms apply on next install. Each release ships
26
+ > the LICENSE that was effective at the time the artifact was built.
27
+ > Continuing to use a previously installed version under its prior terms
28
+ > is permitted; upgrading to a newer release accepts the LICENSE shipped
29
+ > with that release.
30
+
31
+ ---
32
+
33
+ ## Functional Source License, Version 1.1, ALv2 Future License
34
+
35
+ ## Abbreviation
36
+
37
+ FSL-1.1-ALv2
38
+
39
+ ## Notice
40
+
41
+ Copyright 2026 [LICENSOR_ENTITY]
42
+
43
+ ## Terms and Conditions
44
+
45
+ ### Licensor ("We")
46
+
47
+ The party offering the Software under these Terms and Conditions.
48
+
49
+ ### The Software
50
+
51
+ The "Software" is each version of the software that we make available under
52
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
53
+ Conditions with the Software.
54
+
55
+ ### License Grant
56
+
57
+ Subject to your compliance with this License Grant and the Patents,
58
+ Redistribution and Trademark clauses below, we hereby grant you the right to
59
+ use, copy, modify, create derivative works, publicly perform, publicly display
60
+ and redistribute the Software for any Permitted Purpose identified below.
61
+
62
+ ### Permitted Purpose
63
+
64
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
65
+ means making the Software available to others in a commercial product or
66
+ service that:
67
+
68
+ 1. substitutes for the Software;
69
+
70
+ 2. substitutes for any other product or service we offer using the Software
71
+ that exists as of the date we make the Software available; or
72
+
73
+ 3. offers the same or substantially similar functionality as the Software.
74
+
75
+ Permitted Purposes specifically include using the Software:
76
+
77
+ 1. for your internal use and access;
78
+
79
+ 2. for non-commercial education;
80
+
81
+ 3. for non-commercial research; and
82
+
83
+ 4. in connection with professional services that you provide to a licensee
84
+ using the Software in accordance with these Terms and Conditions.
85
+
86
+ ### Patents
87
+
88
+ To the extent your use for a Permitted Purpose would necessarily infringe our
89
+ patents, the license grant above includes a license under our patents. If you
90
+ make a claim against any party that the Software infringes or contributes to
91
+ the infringement of any patent, then your patent license to the Software ends
92
+ immediately.
93
+
94
+ ### Redistribution
95
+
96
+ The Terms and Conditions apply to all copies, modifications and derivatives of
97
+ the Software.
98
+
99
+ If you redistribute any copies, modifications or derivatives of the Software,
100
+ you must include a copy of or a link to these Terms and Conditions and not
101
+ remove any copyright notices provided in or with the Software.
102
+
103
+ ### Disclaimer
104
+
105
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
106
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
107
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
108
+
109
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
110
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
111
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
112
+
113
+ ### Trademarks
114
+
115
+ Except for displaying the License Details and identifying us as the origin of
116
+ the Software, you have no right under these Terms and Conditions to use our
117
+ trademarks, trade names, service marks or product names.
118
+
119
+ ## Grant of Future License
120
+
121
+ We hereby irrevocably grant you an additional license to use the Software under
122
+ the Apache License, Version 2.0 that is effective on the second anniversary of
123
+ the date we make the Software available. On or after that date, you may use the
124
+ Software under the Apache License, Version 2.0, in which case the following
125
+ will apply:
126
+
127
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
128
+ this file except in compliance with the License.
129
+
130
+ You may obtain a copy of the License at
131
+
132
+ http://www.apache.org/licenses/LICENSE-2.0
133
+
134
+ Unless required by applicable law or agreed to in writing, software distributed
135
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
136
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
137
+ specific language governing permissions and limitations under the License.
138
+
139
+ ---
140
+
141
+ ## Personal-Use and Evaluation Carve-Out
142
+
143
+ > _Supplemental to the FSL Permitted Purpose above. Pending counsel review._
144
+
145
+ The following uses are explicitly permitted in addition to the FSL Permitted
146
+ Purposes listed above:
147
+
148
+ 1. **Personal use.** Use of the Software by a natural person for that
149
+ person's personal, non-commercial purposes — including hobby projects,
150
+ self-education, and side projects that do not generate revenue or
151
+ commercial advantage.
152
+
153
+ 2. **Evaluation.** Use of the Software by any individual or organization for
154
+ the purpose of evaluating the Software prior to a commercial purchase
155
+ decision, for a period of up to ninety (90) days from first install.
156
+ Evaluation use does not require notification.
157
+
158
+ These carve-outs are non-transferable and do not extend to redistribution,
159
+ sublicensing, or any Competing Use as defined in the FSL Permitted Purpose
160
+ section.
161
+
162
+ ---
163
+
164
+ ## Governing Law and Venue
165
+
166
+ These Terms and Conditions are governed by the laws of the State of Delaware,
167
+ United States of America, without regard to its conflict-of-laws provisions.
168
+ Any dispute arising out of or relating to these Terms and Conditions shall be
169
+ brought exclusively in the state or federal courts located in Delaware, and
170
+ you consent to the personal jurisdiction of those courts.
171
+
172
+ ## Commercial Licensing
173
+
174
+ For uses that fall outside the Permitted Purpose — including any Competing
175
+ Use, or any commercial use case for which a separate paid license is required
176
+ under our Cloud or Enterprise terms — contact `[LICENSE_EMAIL]` to discuss
177
+ a commercial license.
178
+
179
+ ## SPDX Identifier
180
+
181
+ `LicenseRef-Ironflow-EULA`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ironflow/node",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "description": "Node.js SDK for Ironflow event-driven backend platform - workers, serve handlers, and step execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -43,17 +43,17 @@
43
43
  "README.md"
44
44
  ],
45
45
  "dependencies": {
46
- "zod": "^4.3.5",
47
- "@ironflow/core": "^0.20.0"
46
+ "zod": "^4.4.3",
47
+ "@ironflow/core": "^0.20.2"
48
48
  },
49
49
  "optionalDependencies": {
50
- "@bufbuild/protobuf": "^2.5.1",
50
+ "@bufbuild/protobuf": "^2.12.0",
51
51
  "@connectrpc/connect": "^2.1.1",
52
52
  "@connectrpc/connect-node": "^2.1.1"
53
53
  },
54
54
  "devDependencies": {
55
- "@types/node": "^22.14.0",
56
- "esbuild": "^0.27.2",
55
+ "@types/node": "^22.19.18",
56
+ "esbuild": "^0.27.7",
57
57
  "typescript": "^5.9.3",
58
58
  "vitest": "^2.1.9"
59
59
  },
@@ -76,14 +76,14 @@
76
76
  "step-functions"
77
77
  ],
78
78
  "author": "Ironflow",
79
- "license": "MIT",
79
+ "license": "LicenseRef-Ironflow-EULA",
80
80
  "repository": {
81
81
  "type": "git",
82
82
  "url": "https://github.com/ironflowapp/ironflow.git",
83
83
  "directory": "sdk/js/node"
84
84
  },
85
85
  "publishConfig": {
86
- "access": "restricted"
86
+ "access": "public"
87
87
  },
88
88
  "scripts": {
89
89
  "prebuild": "node scripts/sync-version.mjs",
@@ -1,60 +0,0 @@
1
- /**
2
- * agent() — entrypoint for durable AI agents.
3
- *
4
- * Wraps createFunction() with an extended handler context that carries
5
- * agent-shaped primitives (tool, llm, approve, memory, spawn). The
6
- * returned value is a plain IronflowFunction so existing serve() and
7
- * createWorker() register agents with zero changes.
8
- *
9
- * Runtime shape:
10
- * - Per-run turn counter (drives ctx.turn + maxTurns enforcement).
11
- * - Per-run tool registry built from AgentConfig.tools (drives by-name
12
- * dispatch in ctx.tool(name, args) for LLM-driven tool calls).
13
- * - Per-run byArgs idempotency cache for ctx.tool().
14
- * - Per-run in-memory cache for memory.get() reads.
15
- *
16
- * All wrappers compose over ctx.step — agents inherit Ironflow's
17
- * crash-resume, replay, and audit semantics from the existing runtime.
18
- */
19
- import type { z } from "zod";
20
- import type { AgentConfig, AgentHandler, IronflowAgent } from "./types.js";
21
- /**
22
- * Define a durable agent.
23
- *
24
- * When `config.memory` is set, the runtime constructs an IronflowClient
25
- * from `process.env.IRONFLOW_URL` (or `IRONFLOW_SERVER_URL`) plus
26
- * `IRONFLOW_API_KEY` for the memory backend. Workers that pass
27
- * `serverUrl` explicitly to `serve()` / `createWorker()` should also
28
- * export the matching env vars so memory operations resolve correctly.
29
- *
30
- * @example
31
- * ```ts
32
- * import { agent, defineTool } from "@ironflow/node/agent";
33
- * import { z } from "zod";
34
- *
35
- * const fetchDiff = defineTool({
36
- * name: "fetch-diff",
37
- * input: z.object({ pr: z.number() }),
38
- * handler: async ({ pr }) => api.diff(pr),
39
- * });
40
- *
41
- * export const reviewAgent = agent(
42
- * {
43
- * id: "code-review",
44
- * triggers: [{ event: "pr.opened" }],
45
- * tools: [fetchDiff],
46
- * },
47
- * async ({ step, tool, llm, approve }) => {
48
- * const diff = await tool(fetchDiff, { pr: event.data.prNumber });
49
- * const findings = await llm.complete({
50
- * messages: [{ role: "user", content: `Review:\n${diff}` }],
51
- * call: () => myProvider.complete(...),
52
- * });
53
- * const decision = await approve("ship-it", { ttl: "24h", payload: findings });
54
- * return { approved: decision.approved };
55
- * }
56
- * );
57
- * ```
58
- */
59
- export declare function agent<TEventSchema extends z.ZodType = z.ZodType<unknown>, TResult = unknown>(config: AgentConfig<TEventSchema>, handler: AgentHandler<z.infer<TEventSchema>, TResult>): IronflowAgent<z.infer<TEventSchema>, TResult>;
60
- //# sourceMappingURL=agent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAc7B,OAAO,KAAK,EACV,WAAW,EAEX,YAAY,EAEZ,aAAa,EACd,MAAM,YAAY,CAAC;AAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,KAAK,CAAC,YAAY,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,EAC1F,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,EACjC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,GACpD,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAoC/C"}
@@ -1,133 +0,0 @@
1
- /**
2
- * agent() — entrypoint for durable AI agents.
3
- *
4
- * Wraps createFunction() with an extended handler context that carries
5
- * agent-shaped primitives (tool, llm, approve, memory, spawn). The
6
- * returned value is a plain IronflowFunction so existing serve() and
7
- * createWorker() register agents with zero changes.
8
- *
9
- * Runtime shape:
10
- * - Per-run turn counter (drives ctx.turn + maxTurns enforcement).
11
- * - Per-run tool registry built from AgentConfig.tools (drives by-name
12
- * dispatch in ctx.tool(name, args) for LLM-driven tool calls).
13
- * - Per-run byArgs idempotency cache for ctx.tool().
14
- * - Per-run in-memory cache for memory.get() reads.
15
- *
16
- * All wrappers compose over ctx.step — agents inherit Ironflow's
17
- * crash-resume, replay, and audit semantics from the existing runtime.
18
- */
19
- import { IronflowClient } from "../client.js";
20
- import { createFunction } from "../function.js";
21
- import { makeApprove } from "./approve.js";
22
- import { DuplicateToolError } from "./errors.js";
23
- import { createTurnCounter, makeLlm } from "./llm.js";
24
- import { createMemoryRuntimeCache, createMemoryRuntimeCounters, makeMemory, } from "./memory.js";
25
- import { makeSpawn } from "./spawn.js";
26
- import { createToolRuntime, makeTool } from "./tool.js";
27
- /** Default agent turn budget. Configurable via AgentConfig.maxTurns. */
28
- const DEFAULT_MAX_TURNS = 20;
29
- /**
30
- * Define a durable agent.
31
- *
32
- * When `config.memory` is set, the runtime constructs an IronflowClient
33
- * from `process.env.IRONFLOW_URL` (or `IRONFLOW_SERVER_URL`) plus
34
- * `IRONFLOW_API_KEY` for the memory backend. Workers that pass
35
- * `serverUrl` explicitly to `serve()` / `createWorker()` should also
36
- * export the matching env vars so memory operations resolve correctly.
37
- *
38
- * @example
39
- * ```ts
40
- * import { agent, defineTool } from "@ironflow/node/agent";
41
- * import { z } from "zod";
42
- *
43
- * const fetchDiff = defineTool({
44
- * name: "fetch-diff",
45
- * input: z.object({ pr: z.number() }),
46
- * handler: async ({ pr }) => api.diff(pr),
47
- * });
48
- *
49
- * export const reviewAgent = agent(
50
- * {
51
- * id: "code-review",
52
- * triggers: [{ event: "pr.opened" }],
53
- * tools: [fetchDiff],
54
- * },
55
- * async ({ step, tool, llm, approve }) => {
56
- * const diff = await tool(fetchDiff, { pr: event.data.prNumber });
57
- * const findings = await llm.complete({
58
- * messages: [{ role: "user", content: `Review:\n${diff}` }],
59
- * call: () => myProvider.complete(...),
60
- * });
61
- * const decision = await approve("ship-it", { ttl: "24h", payload: findings });
62
- * return { approved: decision.approved };
63
- * }
64
- * );
65
- * ```
66
- */
67
- export function agent(config, handler) {
68
- const maxTurns = config.maxTurns ?? DEFAULT_MAX_TURNS;
69
- const registry = buildRegistry(config.tools);
70
- return createFunction(config, async (ctx) => {
71
- const counter = createTurnCounter();
72
- const toolRuntime = createToolRuntime();
73
- const memoryCache = createMemoryRuntimeCache();
74
- const memoryCounters = createMemoryRuntimeCounters();
75
- const memoryBackend = config.memory ? createDefaultMemoryBackend() : undefined;
76
- const agentCtx = {
77
- event: ctx.event,
78
- step: ctx.step,
79
- run: ctx.run,
80
- logger: ctx.logger,
81
- secrets: ctx.secrets,
82
- tool: makeTool(ctx.step, registry, toolRuntime),
83
- llm: makeLlm(ctx.step, counter, maxTurns),
84
- approve: makeApprove(ctx.step, ctx.run.id),
85
- memory: makeMemory(ctx.step, config.memory, ctx.run.id, memoryCache, memoryBackend, memoryCounters),
86
- spawn: makeSpawn(ctx.step),
87
- get turn() {
88
- return counter.value;
89
- },
90
- };
91
- return handler(agentCtx);
92
- });
93
- }
94
- /**
95
- * Construct the default MemoryBackend from environment variables.
96
- *
97
- * Reads IRONFLOW_URL / IRONFLOW_SERVER_URL for the server endpoint and
98
- * IRONFLOW_API_KEY for auth. Returns undefined when no URL is set so
99
- * makeMemory() can surface a clear "no backend" error on first use.
100
- */
101
- function createDefaultMemoryBackend() {
102
- const serverUrl = process.env.IRONFLOW_URL ?? process.env.IRONFLOW_SERVER_URL;
103
- if (!serverUrl)
104
- return undefined;
105
- const client = new IronflowClient({
106
- serverUrl,
107
- apiKey: process.env.IRONFLOW_API_KEY,
108
- });
109
- return {
110
- appendEvent: (streamId, input) => client.streams.append(streamId, { name: input.name, data: input.data, entityType: input.entityType }, { idempotencyKey: input.idempotencyKey, metadata: input.metadata }),
111
- getProjection: (name) => client.projections.get(name),
112
- waitForCatchup: async (name, opts) => {
113
- await client.projections.waitForCatchup(name, {
114
- minSeq: opts.minSeq,
115
- partition: opts.partition,
116
- timeoutMs: opts.timeoutMs,
117
- });
118
- },
119
- };
120
- }
121
- function buildRegistry(tools) {
122
- const map = new Map();
123
- if (!tools)
124
- return map;
125
- for (const def of tools) {
126
- if (map.has(def.name)) {
127
- throw new DuplicateToolError(def.name);
128
- }
129
- map.set(def.name, def);
130
- }
131
- return map;
132
- }
133
- //# sourceMappingURL=agent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAEL,wBAAwB,EACxB,2BAA2B,EAC3B,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AASxD,wEAAwE;AACxE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,KAAK,CACnB,MAAiC,EACjC,OAAqD;IAErD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACtD,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC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GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,23 +0,0 @@
1
- /**
2
- * approve() — durable human-approval gate.
3
- *
4
- * Wraps step.waitForEvent on a deterministic event name derived from the
5
- * agent run + approval name. The default behavior on TTL elapse is to
6
- * resolve with approved=false, reason="timeout" — explicit rejection vs
7
- * timeout is observable to the caller via the returned reason field.
8
- *
9
- * Approval events follow the convention:
10
- * name: "agent.approve.{name}"
11
- * filter: runId === ctx.run.id
12
- * data shape:
13
- * { approved: boolean, approver?: string, payload?, reason? }
14
- */
15
- import type { StepClient } from "@ironflow/core";
16
- import type { ApproveFn } from "./types.js";
17
- /**
18
- * Build an ApproveFn bound to the given step + run.
19
- *
20
- * Exported for use by agent.ts; not part of the public API surface.
21
- */
22
- export declare function makeApprove(step: StepClient, runId: string): ApproveFn;
23
- //# sourceMappingURL=approve.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"approve.d.ts","sourceRoot":"","sources":["../../src/agent/approve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAiC,MAAM,YAAY,CAAC;AAI3E;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CA4BtE"}
@@ -1,42 +0,0 @@
1
- /**
2
- * approve() — durable human-approval gate.
3
- *
4
- * Wraps step.waitForEvent on a deterministic event name derived from the
5
- * agent run + approval name. The default behavior on TTL elapse is to
6
- * resolve with approved=false, reason="timeout" — explicit rejection vs
7
- * timeout is observable to the caller via the returned reason field.
8
- *
9
- * Approval events follow the convention:
10
- * name: "agent.approve.{name}"
11
- * filter: runId === ctx.run.id
12
- * data shape:
13
- * { approved: boolean, approver?: string, payload?, reason? }
14
- */
15
- import { escapeMatchValue, normalizeDuration } from "./internal.js";
16
- const APPROVE_EVENT_PREFIX = "agent.approve.";
17
- /**
18
- * Build an ApproveFn bound to the given step + run.
19
- *
20
- * Exported for use by agent.ts; not part of the public API surface.
21
- */
22
- export function makeApprove(step, runId) {
23
- return async function approve(name, options) {
24
- const eventName = APPROVE_EVENT_PREFIX + name;
25
- const event = await step.waitForEvent(`approve.${name}`, {
26
- event: eventName,
27
- timeout: normalizeDuration(options.ttl),
28
- match: `data.runId == "${escapeMatchValue(runId)}"`,
29
- });
30
- if (event === null || event === undefined) {
31
- return { approved: false, reason: "timeout" };
32
- }
33
- const data = event.data;
34
- return {
35
- approved: Boolean(data?.approved),
36
- approver: data?.approver,
37
- payload: data?.payload,
38
- reason: data?.reason,
39
- };
40
- };
41
- }
42
- //# sourceMappingURL=approve.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"approve.js","sourceRoot":"","sources":["../../src/agent/approve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGpE,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,KAAa;IACzD,OAAO,KAAK,UAAU,OAAO,CAC3B,IAAY,EACZ,OAAiC;QAEjC,MAAM,SAAS,GAAG,oBAAoB,GAAG,IAAI,CAAC;QAE9C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CACnC,WAAW,IAAI,EAAE,EACjB;YACE,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC;YACvC,KAAK,EAAE,kBAAkB,gBAAgB,CAAC,KAAK,CAAC,GAAG;SACpD,CACF,CAAC;QAEF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAChD,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,OAAO;YACL,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;YACjC,QAAQ,EAAE,IAAI,EAAE,QAAQ;YACxB,OAAO,EAAE,IAAI,EAAE,OAAO;YACtB,MAAM,EAAE,IAAI,EAAE,MAAM;SACrB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,63 +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
- /** Path served on the user's serve() mount. */
32
- export declare const DISPATCH_PATH = "/ironflow/agent-tools/dispatch";
33
- interface DispatchEnvelope {
34
- output?: unknown;
35
- error?: {
36
- code: string;
37
- message: string;
38
- };
39
- }
40
- interface DispatchResult {
41
- status: number;
42
- body: DispatchEnvelope;
43
- }
44
- interface MinimalRequest {
45
- text(): Promise<string>;
46
- headers: {
47
- get(name: string): string | null;
48
- };
49
- }
50
- /**
51
- * Process an inbound dispatch request. Returns status + body envelope —
52
- * the caller (serve()) is responsible for serializing.
53
- */
54
- export declare function handleAgentToolDispatch(request: MinimalRequest): Promise<DispatchResult>;
55
- /**
56
- * verifyHmac is exported for cross-language vector parity tests
57
- * (testdata/hmac_vectors.json, issue #595 S8). It is NOT part of the
58
- * public @ironflow/node/agent surface — production callers reach it
59
- * via handleAgentToolDispatch().
60
- */
61
- export declare function verifyHmac(rawBody: string, ts: number, receivedHex: string, secretHex: string): boolean;
62
- export {};
63
- //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/agent/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAYH,+CAA+C;AAC/C,eAAO,MAAM,aAAa,mCAAmC,CAAC;AAE9D,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAOD,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,UAAU,cAAc;IACtB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC/C;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CAgEzB;AAMD;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAkBT"}