@nodetool-ai/workflow-services 0.0.0-stage → 0.8.9-beta.1

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.
@@ -0,0 +1 @@
1
+ 2026-10-31T09:10:58.057Z
@@ -0,0 +1,3 @@
1
+ export * from "./workflow-bundle.js";
2
+ export * from "./package-asset-export.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./workflow-bundle.js";
2
+ export * from "./package-asset-export.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,83 @@
1
+ export interface WorkflowGraphLike {
2
+ nodes: Array<Record<string, unknown>>;
3
+ edges: Array<Record<string, unknown>>;
4
+ }
5
+ /** True for refs that must be materialized to ship (per-install identifiers). */
6
+ export declare function isLocalAssetUri(uri: string): boolean;
7
+ export declare function isRemoteOrFileUri(uri: string): boolean;
8
+ /** Best-effort extension for an asset, from the source URI then the ref type. */
9
+ export declare function mediaExtension(source: string, refType: unknown): string;
10
+ /**
11
+ * Clone `graph` and invoke `visit` on every media ref found under each node's
12
+ * `data` / `dynamic_properties`. The visitor mutates refs in place on the
13
+ * clone; the input graph is never modified. Returns the rewritten clone.
14
+ */
15
+ export declare function transformMediaRefs(graph: WorkflowGraphLike, visit: (ref: Record<string, unknown>) => Promise<void> | void): Promise<WorkflowGraphLike>;
16
+ export interface CollectedAsset {
17
+ /** The ref that was rewritten. */
18
+ source: string;
19
+ fileName: string;
20
+ /** The rewritten ref uri. */
21
+ uri: string;
22
+ bytes: Uint8Array;
23
+ }
24
+ export interface CollectOptions {
25
+ fetchAssetBytes: (ref: string) => Promise<Uint8Array | null>;
26
+ includeRemote?: boolean;
27
+ /** Choose a file name for a resolved asset. */
28
+ fileNameFor: (input: {
29
+ source: string;
30
+ bytes: Uint8Array;
31
+ refType: unknown;
32
+ }) => string;
33
+ /** Build the rewritten ref uri from the chosen file name. */
34
+ uriFor: (fileName: string) => string;
35
+ }
36
+ export interface CollectResult {
37
+ graph: WorkflowGraphLike;
38
+ /** Unique assets (deduped by source). */
39
+ assets: CollectedAsset[];
40
+ /** Sources that looked materializable but could not be resolved. */
41
+ skipped: string[];
42
+ }
43
+ /**
44
+ * Walk a graph, resolve each materializable asset ref to bytes, and rewrite the
45
+ * ref's `uri` (clearing `asset_id`/`temp_id`/`data`). The caller decides where
46
+ * the collected bytes are persisted. Identical sources are resolved once.
47
+ */
48
+ export declare function collectWorkflowAssets(graph: WorkflowGraphLike, options: CollectOptions): Promise<CollectResult>;
49
+ export interface MaterializeOptions {
50
+ /** Package the assets belong to, e.g. `nodetool-base`. */
51
+ packageName: string;
52
+ /** Root holding `<packageName>/<file>` constant assets on disk. */
53
+ assetsRoot: string;
54
+ /**
55
+ * Resolve the raw bytes for a referenced asset. `ref` is the original
56
+ * `uri` (or `asset://<id>` synthesized from an `asset_id`). Return `null`
57
+ * when the asset can't be resolved — the ref is then left untouched.
58
+ */
59
+ fetchAssetBytes: (ref: string) => Promise<Uint8Array | null>;
60
+ /**
61
+ * Also materialize remote (`http`/`https`) and local-file (`file://`,
62
+ * absolute path) references. Off by default — remote URLs are already
63
+ * portable and local paths are usually intentional. `asset://` and
64
+ * `/api/storage/` refs are always materialized.
65
+ */
66
+ includeRemote?: boolean;
67
+ }
68
+ export interface ExportedAsset {
69
+ /** The ref that was rewritten. */
70
+ source: string;
71
+ /** The `package://` URI it now points to. */
72
+ packageUri: string;
73
+ fileName: string;
74
+ byteLength: number;
75
+ }
76
+ export interface MaterializeResult {
77
+ graph: WorkflowGraphLike;
78
+ exported: ExportedAsset[];
79
+ /** Refs that looked materializable but could not be resolved. */
80
+ skipped: string[];
81
+ }
82
+ export declare function materializeWorkflowConstantAssets(graph: WorkflowGraphLike, options: MaterializeOptions): Promise<MaterializeResult>;
83
+ //# sourceMappingURL=package-asset-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-asset-export.d.ts","sourceRoot":"","sources":["../src/package-asset-export.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC;AAUD,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQpD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOtD;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAgBvE;AAqCD;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAC5D,OAAO,CAAC,iBAAiB,CAAC,CA+B5B;AAuBD,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,GA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D,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CA+B5B"}
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Convert a workflow into a portable template by materializing the user-local
3
+ * assets it references (uploaded inputs, generated samples) into constant
4
+ * package assets that ship with the build.
5
+ *
6
+ * User assets are addressed by per-install identifiers — `asset://<id>` or
7
+ * `/api/storage/<key>` — that resolve only on the machine that created them.
8
+ * For a workflow to work as a shipped example, those bytes must travel with it.
9
+ * This walks the graph, writes each referenced asset as a flat file under
10
+ * `<assetsRoot>/<packageName>/<file>`, and rewrites the ref's `uri` to
11
+ * `package://<packageName>/<file>` (clearing the stale `asset_id`/`temp_id`/
12
+ * inline `data`). The result resolves identically on every install via the
13
+ * `/api/assets/packages/...` route.
14
+ *
15
+ * The lower-level {@link transformMediaRefs} / {@link collectWorkflowAssets}
16
+ * primitives are shared with the `.nodetool` bundle codec (`workflow-bundle`).
17
+ */
18
+ import { mkdir, writeFile } from "node:fs/promises";
19
+ import { basename, extname, join } from "node:path";
20
+ import { buildPackageAssetUri } from "@nodetool-ai/protocol";
21
+ import { isNonEmptyString, isObjectLike, isRecord, isString } from "@nodetool-ai/protocol";
22
+ const MEDIA_TYPE_EXTENSIONS = {
23
+ image: ".png",
24
+ audio: ".mp3",
25
+ video: ".mp4",
26
+ document: ".bin",
27
+ model3d: ".glb"
28
+ };
29
+ /** True for refs that must be materialized to ship (per-install identifiers). */
30
+ export function isLocalAssetUri(uri) {
31
+ if (uri.startsWith("package://")) {
32
+ return false;
33
+ }
34
+ if (uri.startsWith("asset://")) {
35
+ return true;
36
+ }
37
+ return uri.includes("/api/storage/");
38
+ }
39
+ export function isRemoteOrFileUri(uri) {
40
+ return (/^https?:\/\//.test(uri) ||
41
+ uri.startsWith("file://") ||
42
+ uri.startsWith("/") ||
43
+ /^[A-Za-z]:[\\/]/.test(uri));
44
+ }
45
+ /** Best-effort extension for an asset, from the source URI then the ref type. */
46
+ export function mediaExtension(source, refType) {
47
+ let raw = source;
48
+ if (raw.startsWith("asset://")) {
49
+ raw = raw.slice("asset://".length);
50
+ }
51
+ else if (raw.includes("/api/storage/")) {
52
+ raw = raw.slice(raw.indexOf("/api/storage/") + "/api/storage/".length);
53
+ }
54
+ raw = raw.split("?")[0].split("#")[0];
55
+ const ext = extname(basename(raw));
56
+ if (ext) {
57
+ return ext;
58
+ }
59
+ if (isString(refType)) {
60
+ return MEDIA_TYPE_EXTENSIONS[refType] ?? ".bin";
61
+ }
62
+ return ".bin";
63
+ }
64
+ /** Strip query/fragment and return a safe flat file name for the asset. */
65
+ function deriveFileName(source, refType) {
66
+ let raw = source;
67
+ if (raw.startsWith("asset://")) {
68
+ raw = raw.slice("asset://".length);
69
+ }
70
+ else if (raw.includes("/api/storage/")) {
71
+ raw = raw.slice(raw.indexOf("/api/storage/") + "/api/storage/".length);
72
+ }
73
+ raw = raw.split("?")[0].split("#")[0];
74
+ let name = basename(raw) || raw;
75
+ // Collapse anything that isn't a safe flat filename character.
76
+ name = name.replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+/, "");
77
+ if (!name) {
78
+ name = "asset";
79
+ }
80
+ if (!extname(name)) {
81
+ name = `${name}${mediaExtension(source, refType)}`;
82
+ }
83
+ return name;
84
+ }
85
+ /**
86
+ * A media ref is a plain object carrying at least one asset locator
87
+ * (`uri`/`asset_id`/`temp_id`). We rewrite these in place.
88
+ */
89
+ function asMediaRef(value) {
90
+ if (!isRecord(value) || value instanceof Uint8Array) {
91
+ return null;
92
+ }
93
+ const obj = value;
94
+ const hasLocator = isString(obj.uri) || isString(obj.asset_id) || isString(obj.temp_id);
95
+ return hasLocator ? obj : null;
96
+ }
97
+ /**
98
+ * Clone `graph` and invoke `visit` on every media ref found under each node's
99
+ * `data` / `dynamic_properties`. The visitor mutates refs in place on the
100
+ * clone; the input graph is never modified. Returns the rewritten clone.
101
+ */
102
+ export async function transformMediaRefs(graph, visit) {
103
+ const clone = structuredClone(graph);
104
+ const walk = async (value) => {
105
+ if (Array.isArray(value)) {
106
+ for (const item of value) {
107
+ await walk(item);
108
+ }
109
+ return;
110
+ }
111
+ const ref = asMediaRef(value);
112
+ if (ref) {
113
+ await visit(ref);
114
+ }
115
+ if (isObjectLike(value)) {
116
+ for (const child of Object.values(value)) {
117
+ await walk(child);
118
+ }
119
+ }
120
+ };
121
+ for (const node of clone.nodes) {
122
+ if (node.data !== undefined) {
123
+ await walk(node.data);
124
+ }
125
+ if (node.dynamic_properties !== undefined) {
126
+ await walk(node.dynamic_properties);
127
+ }
128
+ }
129
+ return clone;
130
+ }
131
+ /** The locator to feed `fetchAssetBytes`, or null when not materializable. */
132
+ function materializableSource(ref, includeRemote) {
133
+ const uri = isString(ref.uri) ? ref.uri : "";
134
+ if (uri && isLocalAssetUri(uri)) {
135
+ return uri;
136
+ }
137
+ if (uri && includeRemote && isRemoteOrFileUri(uri)) {
138
+ return uri;
139
+ }
140
+ // No usable uri — fall back to an asset id (resolved by the fetcher).
141
+ if (!uri || uri.length === 0) {
142
+ if (isNonEmptyString(ref.asset_id)) {
143
+ return `asset://${ref.asset_id}`;
144
+ }
145
+ }
146
+ return null;
147
+ }
148
+ /**
149
+ * Walk a graph, resolve each materializable asset ref to bytes, and rewrite the
150
+ * ref's `uri` (clearing `asset_id`/`temp_id`/`data`). The caller decides where
151
+ * the collected bytes are persisted. Identical sources are resolved once.
152
+ */
153
+ export async function collectWorkflowAssets(graph, options) {
154
+ const includeRemote = options.includeRemote ?? false;
155
+ const assets = [];
156
+ const skipped = [];
157
+ const resolved = new Map();
158
+ const outGraph = await transformMediaRefs(graph, async (ref) => {
159
+ const source = materializableSource(ref, includeRemote);
160
+ if (!source) {
161
+ return;
162
+ }
163
+ let uri = resolved.get(source);
164
+ if (!uri) {
165
+ const bytes = await options.fetchAssetBytes(source);
166
+ if (!bytes) {
167
+ skipped.push(source);
168
+ return;
169
+ }
170
+ const fileName = options.fileNameFor({
171
+ source,
172
+ bytes,
173
+ refType: ref.type
174
+ });
175
+ uri = options.uriFor(fileName);
176
+ resolved.set(source, uri);
177
+ assets.push({ source, fileName, uri, bytes });
178
+ }
179
+ ref.uri = uri;
180
+ delete ref.asset_id;
181
+ delete ref.temp_id;
182
+ delete ref.data;
183
+ });
184
+ return { graph: outGraph, assets, skipped };
185
+ }
186
+ export async function materializeWorkflowConstantAssets(graph, options) {
187
+ const collectOptions = {
188
+ fetchAssetBytes: options.fetchAssetBytes,
189
+ fileNameFor: ({ source, refType }) => deriveFileName(source, refType),
190
+ uriFor: (fileName) => buildPackageAssetUri(options.packageName, fileName)
191
+ };
192
+ if (options.includeRemote) {
193
+ collectOptions.includeRemote = true;
194
+ }
195
+ const { graph: outGraph, assets, skipped } = await collectWorkflowAssets(graph, collectOptions);
196
+ const targetDir = join(options.assetsRoot, options.packageName);
197
+ if (assets.length > 0) {
198
+ await mkdir(targetDir, { recursive: true });
199
+ }
200
+ const exported = [];
201
+ for (const asset of assets) {
202
+ await writeFile(join(targetDir, asset.fileName), asset.bytes);
203
+ exported.push({
204
+ source: asset.source,
205
+ packageUri: asset.uri,
206
+ fileName: asset.fileName,
207
+ byteLength: asset.bytes.byteLength
208
+ });
209
+ }
210
+ return { graph: outGraph, exported, skipped };
211
+ }
212
+ //# sourceMappingURL=package-asset-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-asset-export.js","sourceRoot":"","sources":["../src/package-asset-export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAO/B,MAAM,qBAAqB,G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,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { type WorkflowGraphLike } from "./package-asset-export.js";
2
+ export declare const WORKFLOW_BUNDLE_SCHEME = "bundle://";
3
+ export declare const WORKFLOW_BUNDLE_FORMAT = "nodetool-workflow-bundle";
4
+ export declare const WORKFLOW_BUNDLE_VERSION = 2;
5
+ export interface WorkflowBundleManifest {
6
+ format: typeof WORKFLOW_BUNDLE_FORMAT;
7
+ version: number;
8
+ nodetool_version?: string;
9
+ created_at: string;
10
+ workflows: Array<{
11
+ file: string;
12
+ name: string;
13
+ }>;
14
+ assets: Array<{
15
+ file: string;
16
+ bytes: number;
17
+ sha256: string;
18
+ }>;
19
+ thumbnail?: string | null;
20
+ }
21
+ /** The workflow payload carried in a bundle (no per-user/db fields). */
22
+ export interface BundledWorkflow {
23
+ id?: string;
24
+ name: string;
25
+ description?: string;
26
+ tags?: string[];
27
+ run_mode?: string | null;
28
+ settings?: Record<string, unknown> | null;
29
+ graph: WorkflowGraphLike;
30
+ }
31
+ export interface PackWorkflowsBundleOptions {
32
+ workflows: BundledWorkflow[];
33
+ /** Resolve bytes for a referenced asset (`asset://`/`/api/storage/` uri). */
34
+ fetchAssetBytes: (ref: string) => Promise<Uint8Array | null>;
35
+ /** Also embed http(s) and local-file refs. Off by default. */
36
+ includeRemote?: boolean;
37
+ nodetoolVersion?: string;
38
+ thumbnail?: Uint8Array | null;
39
+ }
40
+ export interface PackBundleOptions {
41
+ workflow: BundledWorkflow;
42
+ fetchAssetBytes: (ref: string) => Promise<Uint8Array | null>;
43
+ includeRemote?: boolean;
44
+ nodetoolVersion?: string;
45
+ thumbnail?: Uint8Array | null;
46
+ }
47
+ export interface PackBundleResult {
48
+ bytes: Uint8Array;
49
+ manifest: WorkflowBundleManifest;
50
+ /** Refs that looked embeddable but could not be resolved (left as-is). */
51
+ skipped: string[];
52
+ }
53
+ /** Build a `.nodetool` zip from one or more workflows, embedding their assets. */
54
+ export declare function packWorkflowsBundle(options: PackWorkflowsBundleOptions): Promise<PackBundleResult>;
55
+ /** Convenience wrapper to bundle a single workflow. */
56
+ export declare function packWorkflowBundle(options: PackBundleOptions): Promise<PackBundleResult>;
57
+ export interface UnpackedBundle {
58
+ manifest: WorkflowBundleManifest;
59
+ workflows: BundledWorkflow[];
60
+ /** file name (without the `assets/` prefix) → bytes. */
61
+ assets: Map<string, Uint8Array>;
62
+ thumbnail: Uint8Array | null;
63
+ }
64
+ export declare function unpackWorkflowBundle(zipBytes: Uint8Array): UnpackedBundle;
65
+ /** Verify each asset's bytes against the manifest sha256. Returns mismatches. */
66
+ export declare function verifyBundleChecksums(bundle: UnpackedBundle): string[];
67
+ export interface StoreAssetInput {
68
+ bytes: Uint8Array;
69
+ fileName: string;
70
+ contentType: string;
71
+ refType?: unknown;
72
+ }
73
+ export interface ImportBundleOptions {
74
+ /**
75
+ * Persist a bundled asset and return the ref it should be addressed by
76
+ * (e.g. `asset://<id>`). `assetId`, when provided, is written back onto the
77
+ * ref so it round-trips through the asset system.
78
+ */
79
+ storeAsset: (input: StoreAssetInput) => Promise<{
80
+ uri: string;
81
+ assetId?: string;
82
+ }>;
83
+ /** Throw if any asset fails its manifest checksum. Default: false (warn). */
84
+ verifyChecksums?: boolean;
85
+ }
86
+ export interface ImportBundleResult {
87
+ workflows: BundledWorkflow[];
88
+ imported: Array<{
89
+ file: string;
90
+ uri: string;
91
+ }>;
92
+ /** `bundle://` refs whose bytes were missing from the archive. */
93
+ missing: string[];
94
+ checksumMismatches: string[];
95
+ }
96
+ /**
97
+ * Resolve a bundle's `bundle://` refs into concrete stored assets and return
98
+ * workflows ready to create. `storeAsset` decides where the bytes land; assets
99
+ * shared across workflows are stored once.
100
+ */
101
+ export declare function importWorkflowBundle(zipBytes: Uint8Array, options: ImportBundleOptions): Promise<ImportBundleResult>;
102
+ //# sourceMappingURL=workflow-bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-bundle.d.ts","sourceRoot":"","sources":["../src/workflow-bundle.ts"],"names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EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,UAAU,EAAE,CACV,KAAK,EAAE,eAAe,KACnB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,6EAA6E;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,kEAAkE;IAClE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CA6D7B"}
@@ -0,0 +1,284 @@
1
+ /**
2
+ * `.nodetool` workflow bundle codec — a self-contained, portable archive of one
3
+ * or more workflows plus the asset bytes they reference, for sharing workflows
4
+ * as templates (offline file, import-by-URL, or upload to a hosted catalog).
5
+ *
6
+ * Layout (a zip):
7
+ * manifest.json — format/version, nodetool version, workflow list,
8
+ * asset checksums
9
+ * workflows/<file>.json — one per workflow (graph refs → `bundle://<file>`)
10
+ * assets/<file> — content-addressed asset bytes (sha256 + ext), shared
11
+ * and deduped across all workflows in the bundle
12
+ * thumbnail.jpg — optional preview
13
+ *
14
+ * (v1 bundles used a single top-level `workflow.json`; `unpackWorkflowBundle`
15
+ * still reads those.)
16
+ *
17
+ * Export rewrites per-install refs (`asset://`, `/api/storage/`) into
18
+ * `bundle://<file>` and packs the bytes. Import resolves each `bundle://` ref
19
+ * back to a concrete asset via a caller-supplied `storeAsset` (which decides
20
+ * where the bytes land — user storage, a workspace, etc.) and rewrites the ref
21
+ * to the returned uri. The codec itself is storage-agnostic and dependency-light
22
+ * (fflate + node:crypto) so it can be reused server-side and, later, in the UI.
23
+ */
24
+ import { createHash } from "node:crypto";
25
+ import { strFromU8, strToU8, unzipSync, zipSync } from "fflate";
26
+ import { mimeTypeForPath } from "@nodetool-ai/protocol";
27
+ import { collectWorkflowAssets, mediaExtension, transformMediaRefs } from "./package-asset-export.js";
28
+ import { isString } from "@nodetool-ai/protocol";
29
+ export const WORKFLOW_BUNDLE_SCHEME = "bundle://";
30
+ export const WORKFLOW_BUNDLE_FORMAT = "nodetool-workflow-bundle";
31
+ export const WORKFLOW_BUNDLE_VERSION = 2;
32
+ function sha256Hex(bytes) {
33
+ return createHash("sha256").update(bytes).digest("hex");
34
+ }
35
+ function sanitizeFileBase(value) {
36
+ const cleaned = value.replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^[._]+/, "");
37
+ return cleaned || "workflow";
38
+ }
39
+ /** A unique `workflows/<file>.json` name, disambiguated against `used`. */
40
+ function uniqueWorkflowFile(workflow, index, used) {
41
+ const base = sanitizeFileBase(workflow.id || workflow.name || `workflow-${index + 1}`);
42
+ let candidate = `${base}.json`;
43
+ let n = 2;
44
+ while (used.has(candidate)) {
45
+ candidate = `${base}-${n}.json`;
46
+ n += 1;
47
+ }
48
+ return candidate;
49
+ }
50
+ /** Build a `.nodetool` zip from one or more workflows, embedding their assets. */
51
+ export async function packWorkflowsBundle(options) {
52
+ // Resolve each source at most once, even when shared across workflows.
53
+ const memo = new Map();
54
+ const fetchAssetBytes = (ref) => {
55
+ let pending = memo.get(ref);
56
+ if (!pending) {
57
+ pending = options.fetchAssetBytes(ref);
58
+ memo.set(ref, pending);
59
+ }
60
+ return pending;
61
+ };
62
+ const files = {};
63
+ const manifestAssets = [];
64
+ const manifestWorkflows = [];
65
+ const seenAssetFiles = new Set();
66
+ const usedWorkflowFiles = new Set();
67
+ const skipped = new Set();
68
+ const collectOptions = {
69
+ fetchAssetBytes,
70
+ fileNameFor: ({ source, bytes, refType }) => `${sha256Hex(bytes)}${mediaExtension(source, refType)}`,
71
+ uriFor: (fileName) => `${WORKFLOW_BUNDLE_SCHEME}${fileName}`
72
+ };
73
+ if (options.includeRemote) {
74
+ collectOptions.includeRemote = true;
75
+ }
76
+ let index = 0;
77
+ for (const workflow of options.workflows) {
78
+ const { graph, assets, skipped: workflowSkipped } = await collectWorkflowAssets(workflow.graph, collectOptions);
79
+ for (const s of workflowSkipped) {
80
+ skipped.add(s);
81
+ }
82
+ for (const asset of assets) {
83
+ if (seenAssetFiles.has(asset.fileName)) {
84
+ continue; // identical content already packed
85
+ }
86
+ seenAssetFiles.add(asset.fileName);
87
+ const zipPath = `assets/${asset.fileName}`;
88
+ files[zipPath] = asset.bytes;
89
+ manifestAssets.push({
90
+ file: zipPath,
91
+ bytes: asset.bytes.byteLength,
92
+ sha256: sha256Hex(asset.bytes)
93
+ });
94
+ }
95
+ const wfFile = uniqueWorkflowFile(workflow, index, usedWorkflowFiles);
96
+ usedWorkflowFiles.add(wfFile);
97
+ const bundled = { ...workflow, graph };
98
+ files[`workflows/${wfFile}`] = strToU8(JSON.stringify(bundled, null, 2));
99
+ manifestWorkflows.push({
100
+ file: `workflows/${wfFile}`,
101
+ name: workflow.name
102
+ });
103
+ index += 1;
104
+ }
105
+ const manifest = {
106
+ format: WORKFLOW_BUNDLE_FORMAT,
107
+ version: WORKFLOW_BUNDLE_VERSION,
108
+ created_at: new Date().toISOString(),
109
+ workflows: manifestWorkflows,
110
+ assets: manifestAssets,
111
+ thumbnail: options.thumbnail ? "thumbnail.jpg" : null
112
+ };
113
+ if (options.nodetoolVersion) {
114
+ manifest.nodetool_version = options.nodetoolVersion;
115
+ }
116
+ files["manifest.json"] = strToU8(JSON.stringify(manifest, null, 2));
117
+ if (options.thumbnail) {
118
+ files["thumbnail.jpg"] = options.thumbnail;
119
+ }
120
+ return { bytes: zipSync(files), manifest, skipped: [...skipped] };
121
+ }
122
+ /** Convenience wrapper to bundle a single workflow. */
123
+ export async function packWorkflowBundle(options) {
124
+ const { workflow, ...rest } = options;
125
+ return packWorkflowsBundle({ ...rest, workflows: [workflow] });
126
+ }
127
+ /** Max total decompressed size of a bundle — guards against zip bombs. */
128
+ const MAX_BUNDLE_UNCOMPRESSED_BYTES = 512 * 1024 * 1024; // 512 MB
129
+ /** Max number of entries in a bundle. */
130
+ const MAX_BUNDLE_ENTRIES = 10_000;
131
+ export function unpackWorkflowBundle(zipBytes) {
132
+ // Bound decompression: `unzipSync` otherwise inflates every entry into memory
133
+ // with no size limit, so a small highly-compressible upload (a deflate run of
134
+ // zeros) can expand to tens of GB and OOM the whole server (decompression
135
+ // bomb). The filter runs per entry with the header-declared uncompressed size
136
+ // before that entry is inflated, so we reject over-budget archives up front.
137
+ let totalUncompressed = 0;
138
+ let entryCount = 0;
139
+ const entries = unzipSync(zipBytes, {
140
+ filter: (file) => {
141
+ entryCount += 1;
142
+ if (entryCount > MAX_BUNDLE_ENTRIES) {
143
+ throw new Error(`Bundle rejected: too many entries (limit ${MAX_BUNDLE_ENTRIES})`);
144
+ }
145
+ totalUncompressed += file.originalSize;
146
+ if (totalUncompressed > MAX_BUNDLE_UNCOMPRESSED_BYTES) {
147
+ throw new Error(`Bundle rejected: decompressed size exceeds ${MAX_BUNDLE_UNCOMPRESSED_BYTES} bytes`);
148
+ }
149
+ return true;
150
+ }
151
+ });
152
+ const manifestEntry = entries["manifest.json"];
153
+ if (!manifestEntry) {
154
+ throw new Error("Invalid bundle: missing manifest.json");
155
+ }
156
+ const manifest = JSON.parse(strFromU8(manifestEntry));
157
+ if (manifest.format !== WORKFLOW_BUNDLE_FORMAT) {
158
+ throw new Error(`Unrecognized bundle format: ${String(manifest.format)}`);
159
+ }
160
+ if (manifest.version > WORKFLOW_BUNDLE_VERSION) {
161
+ throw new Error(`Bundle version ${manifest.version} is newer than supported (${WORKFLOW_BUNDLE_VERSION})`);
162
+ }
163
+ const parseWorkflow = (path) => {
164
+ const wf = JSON.parse(strFromU8(entries[path]));
165
+ if (!wf.graph?.nodes) {
166
+ throw new Error(`Invalid bundle: ${path} has no graph`);
167
+ }
168
+ return wf;
169
+ };
170
+ const workflows = [];
171
+ const workflowPaths = Object.keys(entries).filter((p) => p.startsWith("workflows/") && p.endsWith(".json"));
172
+ if (workflowPaths.length > 0) {
173
+ // Preserve manifest order, then append any entries the manifest omitted.
174
+ const seen = new Set();
175
+ const ordered = (manifest.workflows ?? [])
176
+ .map((w) => w.file)
177
+ .filter((f) => entries[f]);
178
+ for (const path of ordered) {
179
+ workflows.push(parseWorkflow(path));
180
+ seen.add(path);
181
+ }
182
+ for (const path of workflowPaths.sort()) {
183
+ if (!seen.has(path)) {
184
+ workflows.push(parseWorkflow(path));
185
+ }
186
+ }
187
+ }
188
+ else if (entries["workflow.json"]) {
189
+ // v1 single-workflow bundle.
190
+ workflows.push(parseWorkflow("workflow.json"));
191
+ }
192
+ if (workflows.length === 0) {
193
+ throw new Error("Invalid bundle: no workflows found");
194
+ }
195
+ const assets = new Map();
196
+ for (const [path, bytes] of Object.entries(entries)) {
197
+ if (path.startsWith("assets/")) {
198
+ assets.set(path.slice("assets/".length), bytes);
199
+ }
200
+ }
201
+ const thumbnail = entries["thumbnail.jpg"] ?? null;
202
+ return { manifest, workflows, assets, thumbnail };
203
+ }
204
+ /** Verify each asset's bytes against the manifest sha256. Returns mismatches. */
205
+ export function verifyBundleChecksums(bundle) {
206
+ const mismatches = [];
207
+ for (const entry of bundle.manifest.assets) {
208
+ const fileName = entry.file.startsWith("assets/")
209
+ ? entry.file.slice("assets/".length)
210
+ : entry.file;
211
+ const bytes = bundle.assets.get(fileName);
212
+ if (!bytes) {
213
+ mismatches.push(`${entry.file} (missing)`);
214
+ continue;
215
+ }
216
+ if (entry.sha256 && sha256Hex(bytes) !== entry.sha256) {
217
+ mismatches.push(`${entry.file} (checksum)`);
218
+ }
219
+ }
220
+ return mismatches;
221
+ }
222
+ /**
223
+ * Resolve a bundle's `bundle://` refs into concrete stored assets and return
224
+ * workflows ready to create. `storeAsset` decides where the bytes land; assets
225
+ * shared across workflows are stored once.
226
+ */
227
+ export async function importWorkflowBundle(zipBytes, options) {
228
+ const bundle = unpackWorkflowBundle(zipBytes);
229
+ const checksumMismatches = verifyBundleChecksums(bundle);
230
+ if (options.verifyChecksums && checksumMismatches.length > 0) {
231
+ throw new Error(`Bundle checksum verification failed: ${checksumMismatches.join(", ")}`);
232
+ }
233
+ const imported = [];
234
+ const missing = new Set();
235
+ const resolvedByFile = new Map();
236
+ const rewriteRef = async (ref) => {
237
+ const uri = isString(ref.uri) ? ref.uri : "";
238
+ if (!uri.startsWith(WORKFLOW_BUNDLE_SCHEME)) {
239
+ return;
240
+ }
241
+ const fileName = uri.slice(WORKFLOW_BUNDLE_SCHEME.length);
242
+ const bytes = bundle.assets.get(fileName);
243
+ if (!bytes) {
244
+ missing.add(fileName);
245
+ return;
246
+ }
247
+ let stored = resolvedByFile.get(fileName);
248
+ if (!stored) {
249
+ const result = await options.storeAsset({
250
+ bytes,
251
+ fileName,
252
+ contentType: mimeTypeForPath(fileName),
253
+ refType: ref.type
254
+ });
255
+ stored = { uri: result.uri };
256
+ if (result.assetId) {
257
+ stored.assetId = result.assetId;
258
+ }
259
+ resolvedByFile.set(fileName, stored);
260
+ imported.push({ file: fileName, uri: stored.uri });
261
+ }
262
+ ref.uri = stored.uri;
263
+ delete ref.temp_id;
264
+ delete ref.data;
265
+ if (stored.assetId) {
266
+ ref.asset_id = stored.assetId;
267
+ }
268
+ else {
269
+ delete ref.asset_id;
270
+ }
271
+ };
272
+ const workflows = [];
273
+ for (const workflow of bundle.workflows) {
274
+ const graph = await transformMediaRefs(workflow.graph, rewriteRef);
275
+ workflows.push({ ...workflow, graph });
276
+ }
277
+ return {
278
+ workflows,
279
+ imported,
280
+ missing: [...missing],
281
+ checksumMismatches
282
+ };
283
+ }
284
+ //# sourceMappingURL=workflow-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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YACN,OAAO,GAAG,CAAC,QAAQ,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,SAAS,GAAsB,EAAE,CAAC;IACxC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QACnE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,OAAO;QACL,SAAS;QACT,QAAQ;QACR,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;QACrB,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@nodetool-ai/workflow-services",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.8.9-beta.1",
4
+ "description": "Portable workflow bundles and package asset export",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "nodetool-dev": "./src/index.ts",
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./*": {
19
+ "nodetool-dev": "./src/*.ts",
20
+ "types": "./dist/*.d.ts",
21
+ "import": "./dist/*.js",
22
+ "default": "./dist/*.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "build": "node ../../scripts/build-typescript-workspace.mjs",
27
+ "lint": "node ../../scripts/run-tsc.mjs --noEmit"
28
+ },
29
+ "dependencies": {
30
+ "@nodetool-ai/protocol": "0.8.9-beta.1",
31
+ "fflate": "^0.8.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^22.0.0",
35
+ "typescript": "npm:@typescript/typescript6@6.0.2",
36
+ "vitest": "^5.0.1"
37
+ },
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/nodetool-ai/nodetool.git",
42
+ "directory": "packages/workflow-services"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "README.md"
50
+ ]
51
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
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.