@fluidgrids/workflows 0.0.0-stage → 2026.1027.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +187 -2
  3. package/dist/assemble-BJo9TECS.d.cts +569 -0
  4. package/dist/assemble-DMOuaxRI.d.ts +569 -0
  5. package/dist/chunk-265J2FCH.cjs +33 -0
  6. package/dist/chunk-27HASETB.cjs +250 -0
  7. package/dist/chunk-4DPEGDPW.js +74 -0
  8. package/dist/chunk-5LUIDMF4.js +42 -0
  9. package/dist/chunk-AU3YW7FZ.cjs +279 -0
  10. package/dist/chunk-BWSLWF2E.js +722 -0
  11. package/dist/chunk-BYJ7QTLY.cjs +76 -0
  12. package/dist/chunk-G4UEPUGO.cjs +46 -0
  13. package/dist/chunk-GO34UHSY.js +95 -0
  14. package/dist/chunk-IZQNUNSU.cjs +931 -0
  15. package/dist/chunk-KUTMY2IO.cjs +745 -0
  16. package/dist/chunk-LMX35GNQ.js +893 -0
  17. package/dist/chunk-LRM6JXJA.cjs +181 -0
  18. package/dist/chunk-LSKSBVL4.cjs +102 -0
  19. package/dist/chunk-LUXCXFOE.cjs +269 -0
  20. package/dist/chunk-PL73GJR4.js +174 -0
  21. package/dist/chunk-REV7ZOA4.js +170 -0
  22. package/dist/chunk-RRQ5HOBF.cjs +185 -0
  23. package/dist/chunk-S34NJE3A.js +262 -0
  24. package/dist/chunk-SRQRLWOS.js +31 -0
  25. package/dist/chunk-SS4LT2IP.js +268 -0
  26. package/dist/chunk-X4HKU3MX.js +244 -0
  27. package/dist/codegen/index.cjs +18 -0
  28. package/dist/codegen/index.d.cts +15 -0
  29. package/dist/codegen/index.d.ts +15 -0
  30. package/dist/codegen/index.js +5 -0
  31. package/dist/expressions-DhHaqyar.d.cts +62 -0
  32. package/dist/expressions-DhHaqyar.d.ts +62 -0
  33. package/dist/hash-CZkTXPCX.d.cts +15 -0
  34. package/dist/hash-CZkTXPCX.d.ts +15 -0
  35. package/dist/index.cjs +117 -0
  36. package/dist/index.d.cts +27 -0
  37. package/dist/index.d.ts +27 -0
  38. package/dist/index.js +4 -0
  39. package/dist/ir/index.cjs +1244 -0
  40. package/dist/ir/index.d.cts +828 -0
  41. package/dist/ir/index.d.ts +828 -0
  42. package/dist/ir/index.js +1120 -0
  43. package/dist/lower-DcOY8ux0.d.cts +49 -0
  44. package/dist/lower-Dw5grNrI.d.ts +49 -0
  45. package/dist/manifest-Bp9ZJlav.d.ts +60 -0
  46. package/dist/manifest-Duf-gHdO.d.cts +60 -0
  47. package/dist/node-evaluator-2GTUZVPK.cjs +17 -0
  48. package/dist/node-evaluator-RMYEWCXZ.js +8 -0
  49. package/dist/quickjs/index.cjs +92 -0
  50. package/dist/quickjs/index.d.cts +18 -0
  51. package/dist/quickjs/index.d.ts +18 -0
  52. package/dist/quickjs/index.js +90 -0
  53. package/dist/roundtrip/index.cjs +1375 -0
  54. package/dist/roundtrip/index.d.cts +287 -0
  55. package/dist/roundtrip/index.d.ts +287 -0
  56. package/dist/roundtrip/index.js +1328 -0
  57. package/dist/types-Dr2Fn1Ax.d.cts +225 -0
  58. package/dist/types-Dr2Fn1Ax.d.ts +225 -0
  59. package/package.json +117 -4
  60. package/schema/ir-v2.schema.json +655 -0
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2025 Algoshred Technologies Private Limited.
2
+
3
+ All rights reserved.
4
+
5
+ This software is proprietary and confidential. Unauthorized copying, modification, distribution, or use of this software, via any medium, is strictly prohibited without the express written permission of the copyright holders.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
9
+ For licensing inquiries, please contact: legal@algoshred.com
package/README.md CHANGED
@@ -1,3 +1,188 @@
1
- # Temporary Holding Version
1
+ # @fluidgrids/workflows
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Author [FluidGrids](https://fluidgrids.ai) workflows as code. This package is
4
+ Phase A of the code-first workflows spec set (BOFF-9902 / BOFF-9904,
5
+ `fluidgrids-specs/product/specs/code-first/`):
6
+
7
+ - the workflow IR, schema version 2: types, JSON Schema 2020-12, normalisation,
8
+ validation, hashing, diff, interface derivation and the export envelope;
9
+ - the tier-1 graph builder: TypeScript that constructs a canvas workflow;
10
+ - lift (IR to TypeScript or Python) and lower (TypeScript to IR), with a
11
+ fidelity report computed by actually lowering the code;
12
+ - typed node clients generated from a node registry snapshot.
13
+
14
+ Durable (tier-2) workflow functions are Phase B and are not in this package yet.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ bun add @fluidgrids/workflows
20
+ ```
21
+
22
+ ## Entry points
23
+
24
+ | Import | Contents | Runs in |
25
+ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
26
+ | `@fluidgrids/workflows` | `defineWorkflow`, `triggers`, `nodes`, `edge`, `expr`, `and`, `or`, `op`, `trigger`, `toIR` | anywhere; also bundled into workflow code |
27
+ | `@fluidgrids/workflows/ir` | IR v2 types, `IR_V2_SCHEMA`, `normalizeDefinition`, `validate`, `irHash`, `canonicalJson`, `diffDefinitions`, `deriveInterface`, envelope helpers | anywhere, browser included |
28
+ | `@fluidgrids/workflows/roundtrip` | `liftToTypeScript`, `liftToPython`, `lower`, `exportWorkflowCode`, `checkFidelity` | Node or Bun |
29
+ | `@fluidgrids/workflows/codegen` | `generateNodeClients(manifests, 'ts' \| 'py')` | anywhere |
30
+ | `@fluidgrids/workflows/quickjs` | `createQuickJSEvaluator()` for lowering untrusted code | Node or Bun |
31
+ | `@fluidgrids/workflows/schema/ir-v2.schema.json` | the JSON Schema | data |
32
+
33
+ ## Tier 1: the graph builder
34
+
35
+ ```ts
36
+ import { defineWorkflow, expr, triggers } from '@fluidgrids/workflows';
37
+ import { nodes as n } from '../.fluidgrids/nodes';
38
+
39
+ export const leadEnrichment = defineWorkflow(
40
+ { key: 'lead-enrichment', name: 'Lead enrichment' },
41
+ (wf) => {
42
+ const inbound = wf.trigger(triggers.webhook, { id: 'inbound', args: { path: 'leads' } });
43
+ const enrich = wf.http({
44
+ id: 'enrich',
45
+ after: inbound,
46
+ connection: 'enrichment-api',
47
+ args: {
48
+ method: 'GET',
49
+ url: 'https://person.clearbit.com/v2/combined/find',
50
+ queryParams: { email: wf.json.body.email },
51
+ },
52
+ retry: { maxRetries: 3, retryDelay: 2000 },
53
+ });
54
+ const isEnterprise = wf.if({
55
+ id: 'is-enterprise',
56
+ after: enrich,
57
+ condition: enrich.output.body.company.metrics.employees.gte(500),
58
+ });
59
+ wf.step(n.slack.sendMessage, {
60
+ id: 'notify-sales',
61
+ after: isEnterprise.true,
62
+ connection: 'slack-ops',
63
+ args: {
64
+ channelId: 'C0SALES',
65
+ text: expr`New enterprise lead: ${enrich.output.body.person.name.fullName}`,
66
+ },
67
+ });
68
+ }
69
+ );
70
+ ```
71
+
72
+ The callback runs once and records a graph; `toIR(workflow, { connections, layout })`
73
+ turns the recording into IR v2. Lowering is a pure function of the builder
74
+ calls, so the same source always gives the same IR.
75
+
76
+ - Every node needs an `id` (`defineWorkflow({ autoIds: true })` derives them for quick scripts).
77
+ - References lower to the expression language the workers evaluate:
78
+ `enrich.output.a.b` becomes `{{ $node["enrich"].item.a.b }}`, `wf.json.x`
79
+ becomes `{{ $json.x }}`. Comparisons (`gte`, `eq`, `contains`, `isEmpty`, …,
80
+ `and`, `or`) become the condition tree `internal:if` evaluates.
81
+ - `connection: 'name'` resolves to a connection id when the workflow is pushed.
82
+ - Positions come from the layout sidecar `workflows/<key>.layout.json`, or the
83
+ automatic layout the AI draft generator uses.
84
+ - `edge(source, { id, type, targetHandle, label, mapping, extra })`,
85
+ `wf.connect`, `wf.edgeOrderIs` and the `extra` option on every node keep any
86
+ stored definition expressible exactly.
87
+ - References into unknown shapes use index signatures, so a project
88
+ `tsconfig.json` should leave `noPropertyAccessFromIndexSignature` and
89
+ `noUncheckedIndexedAccess` off. Declared fields of generated clients are typed
90
+ either way.
91
+
92
+ ## Lift, lower and fidelity
93
+
94
+ ```ts
95
+ import { exportWorkflowCode, lower } from '@fluidgrids/workflows/roundtrip';
96
+
97
+ const exported = await exportWorkflowCode(definition, {
98
+ format: 'TYPESCRIPT', // or 'PYTHON'
99
+ registry, // node manifests, for typed clients
100
+ connectionNames, // connectionId -> name
101
+ });
102
+ exported.files; // workflows/<key>.ts|.py, the layout sidecar, .fluidgrids/nodes.*
103
+ exported.fidelity.level; // 'lossless' when lowering the code reproduces the IR
104
+
105
+ const { buildId, workflows } = await lower(files, { connections });
106
+ ```
107
+
108
+ - **Lift** normalises the definition, plans builder calls, runs the plan through
109
+ the builder to prove each node and edge lowers back unchanged (falling back to
110
+ an exact `nodes.custom()` + `extra` form where the readable form would not),
111
+ and prints TypeScript with the pinned Prettier or Python that `ruff format`
112
+ leaves unchanged.
113
+ - **Lower** bundles the project with esbuild 0.28.2 (`format: esm`,
114
+ `platform: neutral`, `target: es2023`) from an in-memory file map, serves
115
+ `@fluidgrids/workflows` from the runtime embedded in this package, and
116
+ evaluates the bundle in an isolate. `buildId` is the SHA-256 of the bundle; it
117
+ is identical with `esbuild` and `esbuild-wasm` of the same version, so the CLI
118
+ and the service agree. Workflow code may import project files and
119
+ `@fluidgrids/workflows` only.
120
+ - **Evaluators**: the default is a fresh Node `vm` context (for the CLI, which
121
+ runs the developer's own code). Services use `createQuickJSEvaluator()` from
122
+ `@fluidgrids/workflows/quickjs` (quickjs-emscripten 0.32.0, the engine the
123
+ workers use), which bounds memory and time.
124
+ - **Fidelity** is `lossless` when `irHash(lower(lift(ir))) == irHash(ir)`. Items
125
+ report what is kept as plain strings or exact forms: `expression-verbatim`,
126
+ `legacy-syntax`, `unknown-node`, `connection-id-only`, `raw-node`, `key-added`;
127
+ `layout-omitted`, `pinned-data-omitted`, `roundtrip-mismatch` and
128
+ `lowering-failed` make an export lossy.
129
+
130
+ ## The IR
131
+
132
+ - `normalizeDefinition` rewrites the builder's legacy mirrors (`data.*`,
133
+ `config` on internal nodes) into the canonical node fields following the
134
+ executor's own reading order, so no executor-visible value changes
135
+ (`executorView` computes what the executor reads, for checking). It is pure
136
+ and idempotent. The one mirror it keeps is `data.executionSettings.runOn`,
137
+ because today's executor reads `runOn` only there.
138
+ - `irHash` is `sha256:` + the SHA-256 of the RFC 8785 canonical JSON of the
139
+ normalised definition without `authoring`.
140
+ - `validate(definition, { strict, isTaskQueueKnown })` applies the service's
141
+ structural rules and the version-2 rules of spec 01 §9. A stored version-1
142
+ definition that the service accepts never fails it; `strict` adds the
143
+ legacy-mirror, `${…}` and slug-id rules.
144
+ - `buildExportDocument` and `serializeWorkflowDocument` reproduce today's
145
+ export envelope byte for byte for definitions without version-2 fields
146
+ (envelope `schemaVersion: 1`, definition untouched); only definitions that use
147
+ version-2 fields export as `schemaVersion: 2`, normalised.
148
+
149
+ ## Node clients
150
+
151
+ ```ts
152
+ import { generateNodeClients } from '@fluidgrids/workflows/codegen';
153
+
154
+ const { path, content, registrySnapshot } = await generateNodeClients(manifests, 'ts'); // .fluidgrids/nodes.ts
155
+ ```
156
+
157
+ One property per node type, one descriptor per operation, typed from the
158
+ manifest's `input_fields` / `output_fields`; trigger operations also appear
159
+ under `triggers`. Internal nodes ship in the package as `nodes.internal.*` and
160
+ `triggers.*`.
161
+
162
+ ## Shared fixtures
163
+
164
+ `fixtures/` holds the conformance fixtures shared with the Python SDK: every
165
+ internal node type, the five spec examples, the FG-UC doctor samples and a
166
+ builder-shaped canvas definition, each with the expected TypeScript, Python,
167
+ layout and IR. See `fixtures/README.md`.
168
+
169
+ ## Development
170
+
171
+ ```bash
172
+ bun install
173
+ bun run test # vitest
174
+ bun run test:coverage # with the 85% gate
175
+ bun run lint
176
+ bun run typecheck # src, tests and the fixture projects
177
+ bun run check:fixtures # fixtures are current; add --ruff to run ruff format --check
178
+ bun run build # tsup: ESM + CJS + .d.ts
179
+ bun run sanity # everything above
180
+ ```
181
+
182
+ Releases are CalVer (`YYYY.MDD.PATCH`) through `.github/workflows/release.yml`
183
+ (the shared G60 workflow): push a CalVer tag or run the workflow from the
184
+ Actions tab.
185
+
186
+ ## License
187
+
188
+ Proprietary. Copyright (c) Algoshred Technologies Private Limited. See `LICENSE`.