@ironflow/browser 0.19.3 → 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 (47) hide show
  1. package/LICENSE +181 -0
  2. package/README.md +108 -6
  3. package/package.json +15 -15
  4. package/dist/client.d.ts +0 -822
  5. package/dist/client.d.ts.map +0 -1
  6. package/dist/client.js +0 -2220
  7. package/dist/client.js.map +0 -1
  8. package/dist/config-client.d.ts +0 -43
  9. package/dist/config-client.d.ts.map +0 -1
  10. package/dist/config-client.js +0 -134
  11. package/dist/config-client.js.map +0 -1
  12. package/dist/config.d.ts +0 -91
  13. package/dist/config.d.ts.map +0 -1
  14. package/dist/config.js +0 -55
  15. package/dist/config.js.map +0 -1
  16. package/dist/index.d.ts +0 -52
  17. package/dist/index.d.ts.map +0 -1
  18. package/dist/index.js +0 -53
  19. package/dist/index.js.map +0 -1
  20. package/dist/kv.d.ts +0 -79
  21. package/dist/kv.d.ts.map +0 -1
  22. package/dist/kv.js +0 -289
  23. package/dist/kv.js.map +0 -1
  24. package/dist/projection-stream.d.ts +0 -42
  25. package/dist/projection-stream.d.ts.map +0 -1
  26. package/dist/projection-stream.js +0 -48
  27. package/dist/projection-stream.js.map +0 -1
  28. package/dist/subscription.d.ts +0 -101
  29. package/dist/subscription.d.ts.map +0 -1
  30. package/dist/subscription.js +0 -442
  31. package/dist/subscription.js.map +0 -1
  32. package/dist/transport/connectrpc.d.ts +0 -74
  33. package/dist/transport/connectrpc.d.ts.map +0 -1
  34. package/dist/transport/connectrpc.js +0 -393
  35. package/dist/transport/connectrpc.js.map +0 -1
  36. package/dist/transport/index.d.ts +0 -7
  37. package/dist/transport/index.d.ts.map +0 -1
  38. package/dist/transport/index.js +0 -6
  39. package/dist/transport/index.js.map +0 -1
  40. package/dist/transport/types.d.ts +0 -69
  41. package/dist/transport/types.d.ts.map +0 -1
  42. package/dist/transport/types.js +0 -5
  43. package/dist/transport/types.js.map +0 -1
  44. package/dist/transport/websocket.d.ts +0 -38
  45. package/dist/transport/websocket.d.ts.map +0 -1
  46. package/dist/transport/websocket.js +0 -276
  47. package/dist/transport/websocket.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/README.md CHANGED
@@ -12,6 +12,7 @@ This is a **private npm package**. This README is the sole reference for coding
12
12
  - [Events and Subscriptions](#events-and-subscriptions)
13
13
  - [Emitting Events](#emitting-events)
14
14
  - [Workflow Operations](#workflow-operations)
15
+ - [Agents (`ironflow.agents.*`)](#agents-ironflowagents)
15
16
  - [Entity Streams (Event Sourcing)](#entity-streams-event-sourcing)
16
17
  - [Projections](#projections)
17
18
  - [KV Store](#kv-store)
@@ -442,6 +443,101 @@ console.log(output.output);
442
443
  console.log(output.patched); // Whether output was injected
443
444
  ```
444
445
 
446
+ ## Agents (`ironflow.agents.*`)
447
+
448
+ Browser helpers for `agent()` functions. Mirror the `@ironflow/node/agent` shape so the same agent runs in browser-driven UIs and server workers without divergence.
449
+
450
+ Spec: `src/agents/spec.md`. Issue #625.
451
+
452
+ ### `agents.invoke(name, payload, opts?)`
453
+
454
+ Fire-and-wait. Triggers the agent, subscribes to its run events, resolves on the terminal `system.run.{runId}.completed` event.
455
+
456
+ ```typescript
457
+ import { ironflow } from '@ironflow/browser';
458
+
459
+ const result = await ironflow.agents.invoke<{ category: string }>(
460
+ 'doc-processor',
461
+ { docId: 'doc-1', imageUrl: 'https://example.com/x.png' },
462
+ {
463
+ timeoutMs: 60_000, // default 30s
464
+ idempotencyKey: 'click-abc', // server-side dedup
465
+ signal: ac.signal, // AbortController
466
+ replay: 1000, // default; covers the race window
467
+ onRunStarted: (runId) => {}, // optional: surfaces runId before terminal
468
+ }
469
+ );
470
+ console.log(result.runId, result.output, result.durationMs);
471
+ ```
472
+
473
+ Errors:
474
+
475
+ | Throws | When |
476
+ |---|---|
477
+ | `ValidationError` | empty/oversized `name` |
478
+ | `AbortError` (DOMException) | `signal` aborts; SDK calls `cancelRun(runId)` server-side |
479
+ | `AgentInvokeTimeoutError` | local `timeoutMs` elapsed; SDK calls `cancelRun(runId)` |
480
+ | `NoRunCreatedError` | server returned empty `runIds` |
481
+ | `RunFailedError` | `system.run.{runId}.failed` |
482
+ | `RunCancelledError` | `system.run.{runId}.cancelled` |
483
+
484
+ ### `agents.subscribe(runId, callbacks)`
485
+
486
+ Typed wrapper over the broader `subscribe(pattern)` API. Dispatches by topic.
487
+
488
+ ```typescript
489
+ const sub = await ironflow.agents.subscribe(runId, {
490
+ onProgress: (e) => console.log('progress', e.topic, e.status),
491
+ onStep: (e) => console.log('step', e.stepId, e.type),
492
+ onComplete: (r) => console.log('done', r.output),
493
+ onFailed: (err) => console.warn('failed', err.message),
494
+ onCancelled: () => console.warn('cancelled'),
495
+ onError: (err) => console.error('transport', err),
496
+ });
497
+
498
+ // Unsubscribe is idempotent.
499
+ sub.unsubscribe();
500
+ ```
501
+
502
+ ### `agents.readMemory(projection, opts?)`
503
+
504
+ Typed read of an agent memory projection. Optional read-your-writes via `minSeq` from a prior `streams.append`.
505
+
506
+ ```typescript
507
+ interface DocMemory {
508
+ docs: Record<string, { status: 'ocr' | 'classified' | 'published'; category?: string }>;
509
+ }
510
+
511
+ // Read current state — eventual consistency.
512
+ const mem = await ironflow.agents.readMemory<DocMemory>('doc-processor-memory');
513
+ console.log(mem.state.docs, mem.version);
514
+
515
+ // Read-your-writes: pass the seq returned by a prior append so the
516
+ // projection has caught up before the read.
517
+ const { sequence } = await ironflow.streams.append('agent-memory:doc-1', {
518
+ name: 'DocProcessed',
519
+ data: { docId: 'doc-1', status: 'classified' },
520
+ });
521
+ const fresh = await ironflow.agents.readMemory<DocMemory>('doc-processor-memory', {
522
+ minSeq: sequence,
523
+ timeoutMs: 5_000,
524
+ });
525
+ ```
526
+
527
+ Throws `MemoryCatchupTimeoutError` if the projection cannot catch up to `minSeq` within `timeoutMs`. Throws `AbortError` on caller cancellation.
528
+
529
+ ### React example
530
+
531
+ A complete browser-driven demo lives at `examples/agents/doc-processor-agent/web/`. It exercises `agents.invoke` + `agents.subscribe` against the doc-processor agent's crash-resume flow, and `agents.readMemory` to render per-doc state.
532
+
533
+ ### Server compatibility
534
+
535
+ Requires Ironflow server with `waitForProjectionCatchup` (#473) and the unified Trigger path. Any server built from `main` after #608 (Lane D) supports the full surface.
536
+
537
+ ### Stuck or hanging?
538
+
539
+ See `docs/runbooks/runbook-browser-agent-stuck.md` for triage.
540
+
445
541
  ## Entity Streams (Event Sourcing)
446
542
 
447
543
  Entity streams store domain events per entity with optimistic concurrency control.
@@ -540,11 +636,15 @@ const result = await ironflow.getProjection<{ totalOrders: number }>('order-stat
540
636
 
541
637
  console.log(result.name); // 'order-stats'
542
638
  console.log(result.state); // { totalOrders: 42 }
543
- console.log(result.partition); // '__global__' or partition key
639
+ console.log(result.partition); // '__global__' or partition key
544
640
  console.log(result.lastEventId); // Last processed event ID
545
- console.log(result.lastEventTime); // Date
641
+ console.log(result.lastEventTime); // Date | undefined (undefined before first event)
642
+ console.log(result.lastEventSeq); // Last processed sequence number
546
643
  console.log(result.version); // Projection version
547
644
  console.log(result.mode); // 'managed' | 'external'
645
+ console.log(result.status); // 'active' | 'rebuilding' | 'paused' | 'error'
646
+ console.log(result.errorMessage); // Error string when status is 'error', else undefined
647
+ console.log(result.updatedAt); // Date
548
648
 
549
649
  // Get partitioned projection state
550
650
  const result = await ironflow.getProjection('order-stats', {
@@ -736,16 +836,18 @@ await config.delete('app-settings');
736
836
  // all reach the subscriber. Payload includes `revision`; drop events whose
737
837
  // revision is lower than the last one you applied to guard against rare
738
838
  // out-of-order deliveries under retry.
739
- const sub = await config.watch('app-settings', {
740
- onEvent: (configResponse) => {
741
- console.log('Config updated:', configResponse.data, configResponse.revision);
839
+ const watcher = await config.watch('app-settings', {
840
+ onUpdate: (event) => {
841
+ // event: ConfigWatchEvent ({ type: "config_update", name, data, revision, updatedAt })
842
+ console.log('Config updated:', event.data, event.revision);
742
843
  },
743
844
  onError: (error) => {
744
845
  console.error('Watch error:', error);
745
846
  },
746
847
  });
747
848
 
748
- sub.unsubscribe();
849
+ // `watcher` is a Subscription — call unsubscribe() to stop watching.
850
+ watcher.unsubscribe();
749
851
  ```
750
852
 
751
853
  When the tab is backgrounded long enough that the browser silently kills the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ironflow/browser",
3
- "version": "0.19.3",
3
+ "version": "0.20.2",
4
4
  "description": "Browser client for Ironflow event-driven backend platform - real-time subscriptions, workflow triggers, and event emission",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,16 +18,16 @@
18
18
  "README.md"
19
19
  ],
20
20
  "dependencies": {
21
- "@bufbuild/protobuf": "^2.5.1",
21
+ "@bufbuild/protobuf": "^2.12.0",
22
22
  "@connectrpc/connect": "^2.1.1",
23
23
  "@connectrpc/connect-web": "^2.1.1",
24
- "@ironflow/core": "^0.19.3",
25
- "zod": "^4.3.5"
24
+ "zod": "^4.4.3",
25
+ "@ironflow/core": "^0.20.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/node": "^22.14.0",
29
- "esbuild": "^0.27.2",
30
- "jsdom": "^26.0.0",
28
+ "@types/node": "^22.19.18",
29
+ "esbuild": "^0.27.7",
30
+ "jsdom": "^26.1.0",
31
31
  "typescript": "^5.9.3",
32
32
  "vitest": "^2.1.9"
33
33
  },
@@ -51,24 +51,24 @@
51
51
  "subscriptions"
52
52
  ],
53
53
  "author": "Ironflow",
54
- "license": "MIT",
54
+ "license": "LicenseRef-Ironflow-EULA",
55
55
  "repository": {
56
56
  "type": "git",
57
57
  "url": "https://github.com/ironflowapp/ironflow.git",
58
58
  "directory": "sdk/js/browser"
59
59
  },
60
60
  "publishConfig": {
61
- "access": "restricted"
61
+ "access": "public"
62
62
  },
63
63
  "scripts": {
64
- "build": "tsc",
65
- "build:bundle": "tsc && node scripts/bundle.mjs",
66
- "dev": "tsc --watch",
67
- "test": "vitest run",
64
+ "build": "tsc --build tsconfig.build.json",
65
+ "build:bundle": "tsc --build tsconfig.build.json && node scripts/bundle.mjs",
66
+ "dev": "tsc --build tsconfig.build.json --watch",
67
+ "test": "pnpm typecheck && vitest run",
68
68
  "test:watch": "vitest",
69
69
  "lint": "eslint src/",
70
- "clean": "rm -rf dist dist-bundle tsconfig.tsbuildinfo",
71
- "typecheck": "tsc --noEmit",
70
+ "clean": "rm -rf dist dist-bundle tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
71
+ "typecheck": "tsc -p tsconfig.json --noEmit",
72
72
  "pack:local": "pnpm build:bundle && cd dist-bundle && pnpm pack --pack-destination /tmp/ironflow-packs"
73
73
  }
74
74
  }