@intellia/workflow-sdk 0.2.0 → 0.2.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.
package/README.md CHANGED
@@ -43,10 +43,10 @@ export default defineWorkflow({
43
43
  });
44
44
  ```
45
45
 
46
- Compile it to deployable YAML with the Hutly CLI:
46
+ Compile it to deployable YAML with the Intellia CLI:
47
47
 
48
48
  ```bash
49
- hutly workflow build --entry workflow.ts
49
+ intellia workflow build --entry workflow.ts
50
50
  ```
51
51
 
52
52
  `z` is re-exported from this package so a workflow's schemas and the SDK share
@@ -1 +1 @@
1
- {"version":3,"file":"define-tool.js","sourceRoot":"","sources":["../../src/define-tool.ts"],"names":[],"mappings":";;;AA8CO,MAAM,UAAU,GAAG,CAAyC,IAKlE,EAAe,EAAE,CAAC,IAAI,CAAC;AALX,QAAA,UAAU,cAKC"}
1
+ {"version":3,"file":"define-tool.js","sourceRoot":"","sources":["../../src/define-tool.ts"],"names":[],"mappings":";;;AAgDO,MAAM,UAAU,GAAG,CAAyC,IAKlE,EAAe,EAAE,CAAC,IAAI,CAAC;AALX,QAAA,UAAU,cAKC"}
@@ -3,57 +3,85 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.artifact = exports.toJsonSchema = exports.z = void 0;
4
4
  const v4_1 = require("zod/v4");
5
5
  Object.defineProperty(exports, "z", { enumerable: true, get: function () { return v4_1.z; } });
6
- // `z.toJSONSchema` reads `.describe()`/`.meta()` metadata via `z.globalRegistry`
7
- // — a per-zod-module-instance `WeakMap`. A schema built by a DIFFERENT zod
8
- // module instance (e.g. bundled separately into a vm-executed workflow entry
9
- // — see `workflow-compiler/src/execute.ts`) has its own registry, so that
10
- // lookup silently finds nothing, even though structural fields
11
- // (type/properties/required) still convert correctly via duck-typed access.
12
- // The schema's own `.description` getter, though, is a closure bound to
13
- // whichever registry actually holds the metadata, so reading it works
14
- // regardless of which zod instance built the schema — it's a plain property
15
- // read, not an identity check. This walks the zod schema's PUBLIC, documented
16
- // shape accessors (`.def.type`, `.shape`, `.element`, `.unwrap()`) in
17
- // parallel with the JSON Schema `z.toJSONSchema` already produced, backfilling
18
- // any `description` the registry lookup missed. Covers the constructs the SDK
19
- // and the real corpus actually use (object/array/optional/default); anything
20
- // else (union, record, nullable's `anyOf` wrapping, ...) falls through
21
- // unmerged — no worse than before this existed, just not extended to those.
22
- const backfillDescriptions = (t, node) => {
23
- var _a;
24
- const description = t.description;
25
- if (node.description === undefined && typeof description === "string") {
26
- node.description = description;
6
+ // `z.toJSONSchema` finds `.meta()` through a per-zod-instance registry, so a
7
+ // schema built by another zod copy (a vm-executed workflow entry, see
8
+ // `workflow-compiler/src/execute.ts`) loses it; the schema's own no-argument
9
+ // `.meta()` still reads the right registry. This walks the zod schema beside
10
+ // the JSON node `z.toJSONSchema` emitted for it, kind by kind, and copies the
11
+ // keys every API Ajv accepts (`input` is registered there as a keyword).
12
+ const BACKFILLED_META_KEYS = ["description", "title", "examples", "deprecated", "readOnly", "writeOnly", "input"];
13
+ // Wrappers that add no JSON Schema level: the inner schema's keys land on the same node.
14
+ const SAME_NODE_WRAPPERS = new Set(["optional", "default", "prefault", "nonoptional", "readonly", "catch"]);
15
+ const asNode = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
16
+ const backfillMetadata = (t, node, seen = new Set()) => {
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
18
+ if (seen.has(t))
19
+ return;
20
+ const path = new Set(seen).add(t);
21
+ const visit = (child, childNode) => {
22
+ const n = asNode(childNode);
23
+ if (child && n)
24
+ backfillMetadata(child, n, path);
25
+ };
26
+ const meta = (_b = (_a = t).meta) === null || _b === void 0 ? void 0 : _b.call(_a);
27
+ if (typeof meta === "object" && meta !== null) {
28
+ for (const key of BACKFILLED_META_KEYS) {
29
+ // Round-tripped into plain data from this realm, not the vm's.
30
+ const json = JSON.stringify(meta[key]);
31
+ if (json !== undefined && node[key] === undefined)
32
+ node[key] = JSON.parse(json);
33
+ }
27
34
  }
28
- const kind = (_a = t.def) === null || _a === void 0 ? void 0 : _a.type;
29
- if (kind === "object" && node.properties) {
35
+ const def = ((_c = t.def) !== null && _c !== void 0 ? _c : {});
36
+ const kind = (_d = def.type) !== null && _d !== void 0 ? _d : "";
37
+ if (kind === "object") {
30
38
  const shape = t.shape;
31
- for (const [key, sub] of Object.entries(shape)) {
32
- const propNode = node.properties[key];
33
- if (propNode) {
34
- backfillDescriptions(sub, propNode);
35
- }
36
- }
39
+ for (const [key, sub] of Object.entries(shape))
40
+ visit(sub, (_e = node.properties) === null || _e === void 0 ? void 0 : _e[key]);
37
41
  }
38
- else if (kind === "array" && node.items) {
39
- const element = t.element;
40
- backfillDescriptions(element, node.items);
42
+ else if (kind === "array") {
43
+ visit(def.element, node.items);
41
44
  }
42
- else if (kind === "optional" || kind === "default" || kind === "nonoptional") {
43
- // These wrappers add no JSON Schema nesting level of their own (optional
44
- // only affects `required`; default keeps the wrapped type's shape), so
45
- // the inner schema's fields land at this SAME node.
46
- const unwrap = t.unwrap;
47
- if (typeof unwrap === "function") {
48
- backfillDescriptions(unwrap(), node);
49
- }
45
+ else if (kind === "record") {
46
+ visit(def.valueType, node.additionalProperties);
47
+ }
48
+ else if (kind === "union") {
49
+ const branches = (_g = (_f = node.anyOf) !== null && _f !== void 0 ? _f : node.oneOf) !== null && _g !== void 0 ? _g : [];
50
+ (_h = def.options) === null || _h === void 0 ? void 0 : _h.forEach((option, i) => visit(option, branches[i]));
51
+ }
52
+ else if (kind === "intersection") {
53
+ visit(def.left, (_j = node.allOf) === null || _j === void 0 ? void 0 : _j[0]);
54
+ visit(def.right, (_k = node.allOf) === null || _k === void 0 ? void 0 : _k[1]);
55
+ }
56
+ else if (kind === "tuple") {
57
+ const items = node.items;
58
+ if (Array.isArray(items))
59
+ (_l = def.items) === null || _l === void 0 ? void 0 : _l.forEach((item, i) => visit(item, items[i]));
60
+ else
61
+ (_m = def.items) === null || _m === void 0 ? void 0 : _m.forEach((item) => visit(item, items));
62
+ visit(def.rest, node.additionalItems);
63
+ }
64
+ else if (kind === "nullable") {
65
+ // `anyOf: [inner, { type: "null" }]`, or the inner node itself when it inlines.
66
+ visit(def.innerType, (_p = (_o = node.anyOf) === null || _o === void 0 ? void 0 : _o[0]) !== null && _p !== void 0 ? _p : node);
67
+ }
68
+ else if (SAME_NODE_WRAPPERS.has(kind)) {
69
+ visit(def.innerType, node);
70
+ }
71
+ else if (kind === "lazy") {
72
+ visit((_q = def.getter) === null || _q === void 0 ? void 0 : _q.call(def), node);
73
+ }
74
+ else if (kind === "pipe") {
75
+ // The node describes one side; a marker on either side keeps the field sensitive.
76
+ visit(def.out, node);
77
+ visit(def.in, node);
50
78
  }
51
79
  };
52
80
  // The repo's ajv schemas and every hand-written workflow use draft-07; zod's
53
81
  // default target is 2020-12, which ajv would reject.
54
82
  const toJsonSchema = (t) => {
55
83
  const result = v4_1.z.toJSONSchema(t, { target: "draft-7" });
56
- backfillDescriptions(t, result);
84
+ backfillMetadata(t, result);
57
85
  return result;
58
86
  };
59
87
  exports.toJsonSchema = toJsonSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAGlB,kFAHA,MAAC,OAGA;AAyCV,iFAAiF;AACjF,2EAA2E;AAC3E,6EAA6E;AAC7E,0EAA0E;AAC1E,+DAA+D;AAC/D,4EAA4E;AAC5E,wEAAwE;AACxE,sEAAsE;AACtE,4EAA4E;AAC5E,8EAA8E;AAC9E,sEAAsE;AACtE,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,uEAAuE;AACvE,4EAA4E;AAC5E,MAAM,oBAAoB,GAAG,CAAC,CAAY,EAAE,IAAgB,EAAQ,EAAE;;IACpE,MAAM,WAAW,GAAI,CAA0C,CAAC,WAAW,CAAC;IAC5E,IAAI,IAAI,CAAC,WAAW,KAAK,SAA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AC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,QAAQ,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;CAC9B,CAAC,CAAC;AAJQ,QAAA,QAAQ,YAIhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"define-tool.js","sourceRoot":"","sources":["../../src/define-tool.ts"],"names":[],"mappings":"AA8CA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAyC,IAKlE,EAAe,EAAE,CAAC,IAAI,CAAC"}
1
+ {"version":3,"file":"define-tool.js","sourceRoot":"","sources":["../../src/define-tool.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAyC,IAKlE,EAAe,EAAE,CAAC,IAAI,CAAC"}
@@ -1,56 +1,84 @@
1
1
  import { z } from "zod/v4";
2
2
  export { z };
3
- // `z.toJSONSchema` reads `.describe()`/`.meta()` metadata via `z.globalRegistry`
4
- // — a per-zod-module-instance `WeakMap`. A schema built by a DIFFERENT zod
5
- // module instance (e.g. bundled separately into a vm-executed workflow entry
6
- // — see `workflow-compiler/src/execute.ts`) has its own registry, so that
7
- // lookup silently finds nothing, even though structural fields
8
- // (type/properties/required) still convert correctly via duck-typed access.
9
- // The schema's own `.description` getter, though, is a closure bound to
10
- // whichever registry actually holds the metadata, so reading it works
11
- // regardless of which zod instance built the schema — it's a plain property
12
- // read, not an identity check. This walks the zod schema's PUBLIC, documented
13
- // shape accessors (`.def.type`, `.shape`, `.element`, `.unwrap()`) in
14
- // parallel with the JSON Schema `z.toJSONSchema` already produced, backfilling
15
- // any `description` the registry lookup missed. Covers the constructs the SDK
16
- // and the real corpus actually use (object/array/optional/default); anything
17
- // else (union, record, nullable's `anyOf` wrapping, ...) falls through
18
- // unmerged — no worse than before this existed, just not extended to those.
19
- const backfillDescriptions = (t, node) => {
20
- var _a;
21
- const description = t.description;
22
- if (node.description === undefined && typeof description === "string") {
23
- node.description = description;
24
- }
25
- const kind = (_a = t.def) === null || _a === void 0 ? void 0 : _a.type;
26
- if (kind === "object" && node.properties) {
27
- const shape = t.shape;
28
- for (const [key, sub] of Object.entries(shape)) {
29
- const propNode = node.properties[key];
30
- if (propNode) {
31
- backfillDescriptions(sub, propNode);
32
- }
3
+ // `z.toJSONSchema` finds `.meta()` through a per-zod-instance registry, so a
4
+ // schema built by another zod copy (a vm-executed workflow entry, see
5
+ // `workflow-compiler/src/execute.ts`) loses it; the schema's own no-argument
6
+ // `.meta()` still reads the right registry. This walks the zod schema beside
7
+ // the JSON node `z.toJSONSchema` emitted for it, kind by kind, and copies the
8
+ // keys every API Ajv accepts (`input` is registered there as a keyword).
9
+ const BACKFILLED_META_KEYS = ["description", "title", "examples", "deprecated", "readOnly", "writeOnly", "input"];
10
+ // Wrappers that add no JSON Schema level: the inner schema's keys land on the same node.
11
+ const SAME_NODE_WRAPPERS = new Set(["optional", "default", "prefault", "nonoptional", "readonly", "catch"]);
12
+ const asNode = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
13
+ const backfillMetadata = (t, node, seen = new Set()) => {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
15
+ if (seen.has(t))
16
+ return;
17
+ const path = new Set(seen).add(t);
18
+ const visit = (child, childNode) => {
19
+ const n = asNode(childNode);
20
+ if (child && n)
21
+ backfillMetadata(child, n, path);
22
+ };
23
+ const meta = (_b = (_a = t).meta) === null || _b === void 0 ? void 0 : _b.call(_a);
24
+ if (typeof meta === "object" && meta !== null) {
25
+ for (const key of BACKFILLED_META_KEYS) {
26
+ // Round-tripped into plain data from this realm, not the vm's.
27
+ const json = JSON.stringify(meta[key]);
28
+ if (json !== undefined && node[key] === undefined)
29
+ node[key] = JSON.parse(json);
33
30
  }
34
31
  }
35
- else if (kind === "array" && node.items) {
36
- const element = t.element;
37
- backfillDescriptions(element, node.items);
38
- }
39
- else if (kind === "optional" || kind === "default" || kind === "nonoptional") {
40
- // These wrappers add no JSON Schema nesting level of their own (optional
41
- // only affects `required`; default keeps the wrapped type's shape), so
42
- // the inner schema's fields land at this SAME node.
43
- const unwrap = t.unwrap;
44
- if (typeof unwrap === "function") {
45
- backfillDescriptions(unwrap(), node);
46
- }
32
+ const def = ((_c = t.def) !== null && _c !== void 0 ? _c : {});
33
+ const kind = (_d = def.type) !== null && _d !== void 0 ? _d : "";
34
+ if (kind === "object") {
35
+ const shape = t.shape;
36
+ for (const [key, sub] of Object.entries(shape))
37
+ visit(sub, (_e = node.properties) === null || _e === void 0 ? void 0 : _e[key]);
38
+ }
39
+ else if (kind === "array") {
40
+ visit(def.element, node.items);
41
+ }
42
+ else if (kind === "record") {
43
+ visit(def.valueType, node.additionalProperties);
44
+ }
45
+ else if (kind === "union") {
46
+ const branches = (_g = (_f = node.anyOf) !== null && _f !== void 0 ? _f : node.oneOf) !== null && _g !== void 0 ? _g : [];
47
+ (_h = def.options) === null || _h === void 0 ? void 0 : _h.forEach((option, i) => visit(option, branches[i]));
48
+ }
49
+ else if (kind === "intersection") {
50
+ visit(def.left, (_j = node.allOf) === null || _j === void 0 ? void 0 : _j[0]);
51
+ visit(def.right, (_k = node.allOf) === null || _k === void 0 ? void 0 : _k[1]);
52
+ }
53
+ else if (kind === "tuple") {
54
+ const items = node.items;
55
+ if (Array.isArray(items))
56
+ (_l = def.items) === null || _l === void 0 ? void 0 : _l.forEach((item, i) => visit(item, items[i]));
57
+ else
58
+ (_m = def.items) === null || _m === void 0 ? void 0 : _m.forEach((item) => visit(item, items));
59
+ visit(def.rest, node.additionalItems);
60
+ }
61
+ else if (kind === "nullable") {
62
+ // `anyOf: [inner, { type: "null" }]`, or the inner node itself when it inlines.
63
+ visit(def.innerType, (_p = (_o = node.anyOf) === null || _o === void 0 ? void 0 : _o[0]) !== null && _p !== void 0 ? _p : node);
64
+ }
65
+ else if (SAME_NODE_WRAPPERS.has(kind)) {
66
+ visit(def.innerType, node);
67
+ }
68
+ else if (kind === "lazy") {
69
+ visit((_q = def.getter) === null || _q === void 0 ? void 0 : _q.call(def), node);
70
+ }
71
+ else if (kind === "pipe") {
72
+ // The node describes one side; a marker on either side keeps the field sensitive.
73
+ visit(def.out, node);
74
+ visit(def.in, node);
47
75
  }
48
76
  };
49
77
  // The repo's ajv schemas and every hand-written workflow use draft-07; zod's
50
78
  // default target is 2020-12, which ajv would reject.
51
79
  export const toJsonSchema = (t) => {
52
80
  const result = z.toJSONSchema(t, { target: "draft-7" });
53
- backfillDescriptions(t, result);
81
+ backfillMetadata(t, result);
54
82
  return result;
55
83
  };
56
84
  // A pointer to bytes held out-of-band, so a large payload never rides the
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,EAAE,CAAC,EAAE,CAAC;AAyCb,iFAAiF;AACjF,2EAA2E;AAC3E,6EAA6E;AAC7E,0EAA0E;AAC1E,+DAA+D;AAC/D,4EAA4E;AAC5E,wEAAwE;AACxE,sEAAsE;AACtE,4EAA4E;AAC5E,8EAA8E;AAC9E,sEAAsE;AACtE,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,uEAAuE;AACvE,4EAA4E;AAC5E,MAAM,oBAAoB,GAAG,CAAC,CAAY,EAAE,IAAgB,EAAQ,EAAE;;IACpE,MAAM,WAAW,GAAI,CAA0C,CAAC,WAAW,CAAC;IAC5E,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACtE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,MAAM,IAAI,GAAG,MAAC,CAA4C,CAAC,GAAG,0CAAE,IAAI,CAAC;IACrE,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACzC,MAAM,KAAK,GAAI,CAAqD,CAAC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MAAA,IAAI,CAAC,KAAK,0CAAG,CAAC,CAAC,mCAAI,IAAI,CAAC,CAAC;IAChD,CAAC;SAAM,IAAI,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,KAAK,CAAC,MAAA,GAAG,CAAC,MAAM,mDAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,kFAAkF;QAClF,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrB,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACtB,CAAC;AACH,CAAC,CAAC;AAEF,6EAA6E;AAC7E,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAY,EAAc,EAAE;IACvD,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAe,CAAC;IACtE,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,0EAA0E;AAC1E,wBAAwB;AACxB,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAC3B,CAAC,CAAC,MAAM,CAAC;IACP,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;CAC9B,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -53,7 +53,7 @@ type Condition = {
53
53
  value: string | number | boolean;
54
54
  };
55
55
  type WaitForCallbackResume = {
56
- /** Stable scope for the lookup key (e.g. "concierge:signing"). */
56
+ /** Stable scope for the lookup key (e.g. "esign:completed"). */
57
57
  namespace: string;
58
58
  /** Composed at runtime via JSONata. Resumer reads the same key. */
59
59
  lookupKey: string;
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@intellia/workflow-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "license": "MIT",
5
5
  "description": "TypeScript authoring surface for Hutly workflows",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
6
9
  "main": "dist/cjs/index.js",
7
10
  "module": "dist/esm/index.js",
8
11
  "types": "dist/index.d.ts",