@executioncontrolprotocol/jsonata 0.14.0 → 0.60.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.
package/README.md CHANGED
@@ -1,49 +1,9 @@
1
1
  # @executioncontrolprotocol/jsonata
2
2
 
3
- JSONata expression transform for ECP. Agents author expressions; workflows sequence transforms over object payloads with standard `$ref` chaining.
3
+ Optional first-party plugin. Supplies `@executioncontrolprotocol/jsonata.transform` for step-level
4
+ `expression` transforms using [JSONata](https://jsonata.org/). Not bundled with the host; install
5
+ with `ecp plugins install jsonata`.
4
6
 
5
- Runs **locally** in Node and browser (pure JS; no host hop).
6
-
7
- ## Binding
8
-
9
- ```ts
10
- import "@executioncontrolprotocol/jsonata"
11
- import { environment, extension } from "@executioncontrolprotocol/node"
12
-
13
- export default environment("jsonata-demo").withExtensions([
14
- extension("@executioncontrolprotocol/jsonata").with({}),
15
- ])
16
- ```
17
-
18
- ## Capability: `@executioncontrolprotocol/jsonata.transform`
19
-
20
- **Input:** `{ expression, payload, bindings? }`
21
-
22
- - `expression` — JSONata expression string (agent-authored)
23
- - `payload` — document to evaluate against (literal or `ref(...)`)
24
- - `bindings` — optional named variables assigned before evaluation
25
-
26
- **Output:** `{ result }` — evaluation result (any JSON-compatible value).
27
-
28
- ## Chaining
29
-
30
- ```ts
31
- step("@executioncontrolprotocol/jsonata.transform", "Project fields")
32
- .with({
33
- expression: '{ "name": name, "total": price * qty }',
34
- payload: ref("echo.echo"),
35
- })
36
- .as("projected")
37
- ```
38
-
39
- With bindings (reference assigned names as `$factor`):
40
-
41
- ```ts
42
- step("@executioncontrolprotocol/jsonata.transform", "Scale total")
43
- .with({
44
- expression: "total * $factor",
45
- payload: ref("projected.result"),
46
- bindings: { factor: 2 },
47
- })
48
- .as("scaled")
49
- ```
7
+ Each evaluation runs in a short-lived child Node.js process with a 64 MiB heap. The child is killed
8
+ when the step times out (capability `timeoutMs`, 1000 ms) or is cancelled, so a runaway or
9
+ memory-hungry expression fails the step without affecting the host.
@@ -0,0 +1,9 @@
1
+ import type { HandlerContext } from "@executioncontrolprotocol/plugin-sdk";
2
+ /**
3
+ * Evaluates the step JSONata expression on resolved input in a child process. The step signal
4
+ * (capability `timeoutMs`, or cancellation) kills the child, so evaluation never outlives the step.
5
+ * A result of `undefined` (nothing matched) becomes `null`; the host `returns` check decides if that is valid.
6
+ * @category Plugins
7
+ */
8
+ export default function handler(input: unknown, ctx: HandlerContext): Promise<unknown>;
9
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/capabilities/transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAoC1E;;;;;GAKG;AACH,wBAA8B,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAsC3F"}
@@ -0,0 +1,80 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createRequire } from "node:module";
3
+ /** Heap cap for one evaluation process. */
4
+ const CHILD_HEAP_MB = 64;
5
+ const jsonataPath = createRequire(import.meta.url).resolve("jsonata");
6
+ /**
7
+ * Child body (CommonJS, run with `node -e`). JSONata runs in its own process, not on the host's event
8
+ * loop or heap: terminating it stops a runaway expression, and running out of memory kills only the child.
9
+ * (A worker thread is not enough: V8 can abort the whole process when a worker exhausts its heap.)
10
+ */
11
+ const CHILD_SOURCE = `
12
+ process.once("message", ({ jsonataPath, expression, input }) => {
13
+ Promise.resolve()
14
+ .then(() => require(jsonataPath)(expression).evaluate(input))
15
+ .then(
16
+ (value) => process.send({ ok: true, json: value === undefined ? undefined : JSON.stringify(value) }),
17
+ (error) => process.send({
18
+ ok: false,
19
+ message: error && typeof error.message === "string" ? error.message : String(error),
20
+ position: error && typeof error.position === "number" ? error.position : undefined,
21
+ }),
22
+ )
23
+ .finally(() => process.disconnect())
24
+ })
25
+ `;
26
+ function stepError(code, message) {
27
+ return Object.assign(new Error(message), { code });
28
+ }
29
+ /**
30
+ * Evaluates the step JSONata expression on resolved input in a child process. The step signal
31
+ * (capability `timeoutMs`, or cancellation) kills the child, so evaluation never outlives the step.
32
+ * A result of `undefined` (nothing matched) becomes `null`; the host `returns` check decides if that is valid.
33
+ * @category Plugins
34
+ */
35
+ export default async function handler(input, ctx) {
36
+ const expression = ctx.expression;
37
+ if (typeof expression !== "string" || expression.trim().length === 0) {
38
+ throw stepError("ECP_STEP_FAILED", "Step expression is required for JSONata transform.");
39
+ }
40
+ if (ctx.signal.aborted)
41
+ throw stepError("ECP_STEP_TIMEOUT", "Step timed out.");
42
+ const child = spawn(process.execPath, [`--max-old-space-size=${CHILD_HEAP_MB}`, "-e", CHILD_SOURCE], {
43
+ stdio: ["ignore", "ignore", "pipe", "ipc"],
44
+ windowsHide: true,
45
+ });
46
+ let stderr = "";
47
+ child.stderr?.on("data", (chunk) => {
48
+ if (stderr.length < 4096)
49
+ stderr += chunk.toString("utf8");
50
+ });
51
+ const onAbort = () => child.kill();
52
+ ctx.signal.addEventListener("abort", onAbort, { once: true });
53
+ try {
54
+ const reply = await new Promise((resolve, reject) => {
55
+ child.once("message", (message) => resolve(message));
56
+ child.once("error", (error) => reject(stepError("ECP_STEP_FAILED", `JSONata process failed: ${error.message}`)));
57
+ child.once("exit", () => {
58
+ if (ctx.signal.aborted)
59
+ reject(stepError("ECP_STEP_TIMEOUT", "Step timed out."));
60
+ else if (/heap out of memory|heap limit/i.test(stderr)) {
61
+ reject(stepError("ECP_STEP_FAILED", "JSONata evaluation exceeded the memory limit."));
62
+ }
63
+ else
64
+ reject(stepError("ECP_STEP_FAILED", "JSONata process exited without a result."));
65
+ });
66
+ child.send({ jsonataPath, expression, input });
67
+ });
68
+ if (!reply.ok) {
69
+ const at = reply.position !== undefined && Number.isFinite(reply.position) ? ` (at position ${reply.position})` : "";
70
+ throw stepError("ECP_STEP_FAILED", `${reply.message}${at}`);
71
+ }
72
+ return reply.json === undefined ? null : JSON.parse(reply.json);
73
+ }
74
+ finally {
75
+ ctx.signal.removeEventListener("abort", onAbort);
76
+ if (child.exitCode === null && child.signalCode === null)
77
+ child.kill();
78
+ }
79
+ }
80
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/capabilities/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C,2CAA2C;AAC3C,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AAErE;;;;GAIG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;CAcpB,CAAA;AAMD,SAAS,SAAS,CAAC,IAA4C,EAAE,OAAe;IAC9E,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,OAAO,CAAC,KAAc,EAAE,GAAmB;IACvE,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAA;IACjC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrE,MAAM,SAAS,CAAC,iBAAiB,EAAE,oDAAoD,CAAC,CAAA;IAC1F,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,SAAS,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAA;IAE9E,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAA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,CAAC,SAAS,CAAC,iBAAiB,EAAE,+CAA+C,CAAC,CAAC,CAAA;gBACvF,CAAC;;oBAAM,MAAM,CAAC,SAAS,CAAC,iBAAiB,EAAE,0CAA0C,CAAC,CAAC,CAAA;YACzF,CAAC,CAAC,CAAA;YACF,KAAK,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;QAChD,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACd,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,iBAAiB,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;YACpH,MAAM,SAAS,CAAC,iBAAiB,EAAE,GAAG,KAAK,CAAC,OAAO,GAAG,EAAE,EAAE,CAAC,CAAA;QAC7D,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAa,CAAA;IAC9E,CAAC;YAAS,CAAC;QACT,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAChD,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,EAAE,CAAA;IACxE,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,15 @@
1
- import { type Registry } from "@executioncontrolprotocol/core";
2
- /** @executioncontrolprotocol/jsonata extension. @category Extensions */
3
- export declare const jsonataExtension: import("@executioncontrolprotocol/core").ExtensionDefinition;
4
- /** Register @executioncontrolprotocol/jsonata. */
5
- export declare function registerJsonataExtension(registry?: Registry): Promise<void>;
6
- export { jsonataTransformInputSchema, jsonataTransformOutputSchema, type JsonataTransformInput, type JsonataTransformOutput, } from "./schemas.js";
7
- export { runJsonataTransform } from "./transform.js";
8
- export default jsonataExtension;
1
+ import { z } from "zod";
2
+ /**
3
+ * JSONata transform capability. Step `accepts`, `returns`, and `expression` live on the execution step.
4
+ * @category Plugins
5
+ */
6
+ export declare const transform: import("@executioncontrolprotocol/plugin-sdk").CapabilityDefinition<z.ZodUnknown, z.ZodUnknown, Record<string, unknown> | undefined>;
7
+ /**
8
+ * JSONata transform plugin.
9
+ * @category Plugins
10
+ */
11
+ declare const _default: import("@executioncontrolprotocol/plugin-sdk").PluginDefinition<undefined, {
12
+ transform: import("@executioncontrolprotocol/plugin-sdk").CapabilityDefinition<z.ZodUnknown, z.ZodUnknown, Record<string, unknown> | undefined>;
13
+ }>;
14
+ export default _default;
9
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,gCAAgC,CAAA;AAQvC,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,8DAqCnB,CAAA;AAIV,kDAAkD;AAClD,wBAAsB,wBAAwB,CAC5C,QAAQ,GAAE,QAAyB,GAClC,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,eAAO,MAAM,SAAS,sIAYpB,CAAA;AAEF;;;GAGG;;;;AACH,wBAQE"}
package/dist/index.js CHANGED
@@ -1,51 +1,31 @@
1
- import { defineExtension, capabilityFor, globalRegistry, catalogExtension, } from "@executioncontrolprotocol/core";
2
- import { jsonataTransformInputSchema, jsonataTransformOutputSchema, } from "./schemas.js";
3
- import { runJsonataTransform } from "./transform.js";
4
- /** @executioncontrolprotocol/jsonata extension. @category Extensions */
5
- export const jsonataExtension = defineExtension("@executioncontrolprotocol", "jsonata")
6
- .withMetadata({
7
- summary: "Transform JSON payloads with JSONata expressions",
8
- description: "Evaluates JSONata expressions locally against workflow data for mapping, filtering, and reshaping JSON without a remote service.",
9
- useCases: [
10
- "Map API responses into workflow-friendly shapes",
11
- "Filter or aggregate arrays inside a run",
12
- ],
13
- samplePrompts: [
14
- "Transform this JSON with a JSONata expression",
15
- "Extract the items array and keep only id and title fields",
16
- ],
17
- })
18
- .withCapabilities([
19
- capabilityFor("@executioncontrolprotocol/jsonata", "transform")
20
- .withInput(jsonataTransformInputSchema)
21
- .withOutput(jsonataTransformOutputSchema)
22
- .withExecution("local")
23
- .withMetadata({
24
- summary: "Evaluate a JSONata expression on a JSON payload",
25
- description: "Compiles and runs a JSONata expression against the provided payload with optional variable bindings, returning the evaluated result.",
26
- useCases: [
27
- "Project nested fields into a flat object for the next step",
28
- "Compute derived values from workflow input or prior step output",
29
- ],
30
- samplePrompts: [
31
- "Run this JSONata expression on the payload",
32
- "Map order lines to `{ sku, qty }` objects with JSONata",
33
- ],
34
- })
35
- .withHandler(async (input) => {
36
- const parsed = input;
37
- return runJsonataTransform(parsed);
38
- }),
39
- ])
40
- .build();
41
- catalogExtension(jsonataExtension);
42
- /** Register @executioncontrolprotocol/jsonata. */
43
- export async function registerJsonataExtension(registry = globalRegistry) {
44
- if (!registry.getExtension("@executioncontrolprotocol/jsonata")) {
45
- await registry.registerExtension(jsonataExtension);
46
- }
47
- }
48
- export { jsonataTransformInputSchema, jsonataTransformOutputSchema, } from "./schemas.js";
49
- export { runJsonataTransform } from "./transform.js";
50
- export default jsonataExtension;
1
+ import { capability, definePlugin } from "@executioncontrolprotocol/plugin-sdk";
2
+ import { z } from "zod";
3
+ /**
4
+ * JSONata transform capability. Step `accepts`, `returns`, and `expression` live on the execution step.
5
+ * @category Plugins
6
+ */
7
+ export const transform = capability({
8
+ contract: "step",
9
+ code: "expression",
10
+ timeoutMs: 1000,
11
+ summary: "Evaluate a JSONata expression against resolved step input.",
12
+ description: "Compiles the step expression with JSONata, evaluates it on the resolved input object, and returns JSON for the host returns check.",
13
+ useCases: ["Project or filter fields with JSONata instead of a sandbox script"],
14
+ projections: ["Take the JSON value JSONata returns; match it to the step returns schema"],
15
+ accepts: z.unknown(),
16
+ returns: z.unknown(),
17
+ handler: () => import("./capabilities/transform.js"),
18
+ });
19
+ /**
20
+ * JSONata transform plugin.
21
+ * @category Plugins
22
+ */
23
+ export default definePlugin({
24
+ id: "@executioncontrolprotocol/jsonata",
25
+ summary: "JSONata transforms for execution steps.",
26
+ description: "Registers the optional transform capability for step-level JSONata expressions. Install separately from the host.",
27
+ capabilities: {
28
+ transform,
29
+ },
30
+ });
51
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,gBAAgB,GAEjB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAE7B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC,2BAA2B,EAAE,SAAS,CAAC;KACpF,YAAY,CAAC;IACZ,OAAO,EAAE,kDAAkD;IAC3D,WAAW,EACT,kIAAkI;IACpI,QAAQ,EAAE;QACR,iDAAiD;QACjD,yCAAyC;KAC1C;IACD,aAAa,EAAE;Q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C,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,4DAA4D;IACrE,WAAW,EACT,oIAAoI;IACtI,QAAQ,EAAE,CAAC,mEAAmE,CAAC;IAC/E,WAAW,EAAE,CAAC,0EAA0E,CAAC;IACzF,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,6BAA6B,CAAC;CACrD,CAAC,CAAA;AAEF;;;GAGG;AACH,eAAe,YAAY,CAAC;IAC1B,EAAE,EAAE,mCAAmC;IACvC,OAAO,EAAE,yCAAyC;IAClD,WAAW,EACT,mHAAmH;IACrH,YAAY,EAAE;QACZ,SAAS;KACV;CACF,CAAC,CAAA"}
@@ -0,0 +1,35 @@
1
+ {
2
+ "capabilities": [
3
+ {
4
+ "code": "expression",
5
+ "contract": "step",
6
+ "description": "Compiles the step expression with JSONata, evaluates it on the resolved input object, and returns JSON for the host returns check.",
7
+ "id": "@executioncontrolprotocol/jsonata.transform",
8
+ "name": "transform",
9
+ "projections": [
10
+ "Take the JSON value JSONata returns; match it to the step returns schema"
11
+ ],
12
+ "summary": "Evaluate a JSONata expression against resolved step input.",
13
+ "timeoutMs": 1000,
14
+ "useCases": [
15
+ "Project or filter fields with JSONata instead of a sandbox script"
16
+ ]
17
+ }
18
+ ],
19
+ "entry": "./dist/index.js",
20
+ "hash": "a04460f3eb2b66498c0d06ff7e54019578f520f983bc229bc278b64a1cdda36f",
21
+ "plugin": {
22
+ "description": "Registers the optional transform capability for step-level JSONata expressions. Install separately from the host.",
23
+ "id": "@executioncontrolprotocol/jsonata",
24
+ "package": "@executioncontrolprotocol/jsonata",
25
+ "summary": "JSONata transforms for execution steps.",
26
+ "version": "0.60.0"
27
+ },
28
+ "pluginSchema": {
29
+ "hash": "8e317e831a89e6ca6f08dea4221f31c4a92e79e71b8f999969bbe63d98a58461",
30
+ "path": "./ecp.schema.json"
31
+ },
32
+ "schema": "@executioncontrolprotocol.plugin-manifest",
33
+ "sdkVersion": "0.60.0",
34
+ "version": "2.0"
35
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$defs": {},
3
+ "$id": "ecp://plugins/@executioncontrolprotocol/jsonata/0.60.0/schema.json",
4
+ "$schema": "https://json-schema.org/draft/2020-12/schema"
5
+ }
package/package.json CHANGED
@@ -1,36 +1,47 @@
1
1
  {
2
2
  "name": "@executioncontrolprotocol/jsonata",
3
- "version": "0.14.0",
4
- "description": "JSONata expression transform extension for ECP",
5
- "license": "Apache-2.0",
3
+ "version": "0.60.0",
4
+ "description": "Optional JSONata transform capability for step-level data reshaping.",
6
5
  "type": "module",
7
- "main": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
6
+ "engines": {
7
+ "node": ">=22.12"
8
+ },
9
+ "keywords": [
10
+ "ecosystem:ecp-plugin",
11
+ "oclif-plugin"
12
+ ],
13
+ "oclif": {},
14
+ "ecp": {
15
+ "manifest": "./ecp.manifest.json",
16
+ "schema": "./ecp.schema.json"
17
+ },
9
18
  "exports": {
10
19
  ".": {
11
20
  "types": "./dist/index.d.ts",
12
21
  "import": "./dist/index.js"
13
- }
22
+ },
23
+ "./ecp.manifest.json": "./ecp.manifest.json",
24
+ "./ecp.schema.json": "./ecp.schema.json"
14
25
  },
26
+ "types": "./dist/index.d.ts",
15
27
  "files": [
16
28
  "dist",
17
- "README.md"
29
+ "ecp.manifest.json",
30
+ "ecp.schema.json"
18
31
  ],
19
32
  "dependencies": {
20
33
  "jsonata": "^2.2.2"
21
34
  },
22
35
  "peerDependencies": {
23
- "zod": "^3.24.0",
24
- "@executioncontrolprotocol/types": "^0.14.0",
25
- "@executioncontrolprotocol/core": "^0.14.0"
36
+ "zod": "^4.0.0",
37
+ "@executioncontrolprotocol/plugin-sdk": "0.60.0"
26
38
  },
27
39
  "devDependencies": {
28
- "typescript": "^5.7.0",
29
- "zod": "^3.24.0",
30
- "@executioncontrolprotocol/types": "^0.14.0",
31
- "@executioncontrolprotocol/core": "^0.14.0"
40
+ "zod": "^4.0.0",
41
+ "@executioncontrolprotocol/plugin-sdk": "0.60.0"
32
42
  },
33
43
  "scripts": {
34
- "build": "tsc -b"
44
+ "build": "tsc -b && node ../../packages/plugin-sdk/dist/bin/ecp-plugin-manifest.js",
45
+ "check:manifest": "node ../../packages/plugin-sdk/dist/bin/ecp-plugin-manifest.js --check"
35
46
  }
36
47
  }
package/dist/schemas.d.ts DELETED
@@ -1,32 +0,0 @@
1
- import { z } from "zod";
2
- /** Input for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
3
- export declare const jsonataTransformInputSchema: z.ZodObject<{
4
- /** JSONata expression (agent-authored). */
5
- expression: z.ZodString;
6
- /** Document to evaluate against (literal or ref-resolved). */
7
- payload: z.ZodUnknown;
8
- /** Optional named bindings assigned before evaluation (reference as `$name` in the expression). */
9
- bindings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
10
- }, "strip", z.ZodTypeAny, {
11
- expression: string;
12
- payload?: unknown;
13
- bindings?: Record<string, unknown> | undefined;
14
- }, {
15
- expression: string;
16
- payload?: unknown;
17
- bindings?: Record<string, unknown> | undefined;
18
- }>;
19
- /** Output for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
20
- export declare const jsonataTransformOutputSchema: z.ZodObject<{
21
- /** Evaluation result (any JSON-compatible value). */
22
- result: z.ZodUnknown;
23
- }, "strip", z.ZodTypeAny, {
24
- result?: unknown;
25
- }, {
26
- result?: unknown;
27
- }>;
28
- /** Inferred input type for jsonata.transform. @category Extensions */
29
- export type JsonataTransformInput = z.infer<typeof jsonataTransformInputSchema>;
30
- /** Inferred output type for jsonata.transform. @category Extensions */
31
- export type JsonataTransformOutput = z.infer<typeof jsonataTransformOutputSchema>;
32
- //# sourceMappingURL=schemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,4FAA4F;AAC5F,eAAO,MAAM,2BAA2B;IACtC,2CAA2C;;IAE3C,8DAA8D;;IAE9D,mGAAmG;;;;;;;;;;EAEnG,CAAA;AAEF,6FAA6F;AAC7F,eAAO,MAAM,4BAA4B;IACvC,qDAAqD;;;;;;EAErD,CAAA;AAEF,sEAAsE;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E,uEAAuE;AACvE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA"}
package/dist/schemas.js DELETED
@@ -1,16 +0,0 @@
1
- import { z } from "zod";
2
- /** Input for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
3
- export const jsonataTransformInputSchema = z.object({
4
- /** JSONata expression (agent-authored). */
5
- expression: z.string().min(1),
6
- /** Document to evaluate against (literal or ref-resolved). */
7
- payload: z.unknown(),
8
- /** Optional named bindings assigned before evaluation (reference as `$name` in the expression). */
9
- bindings: z.record(z.string(), z.unknown()).optional(),
10
- });
11
- /** Output for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
12
- export const jsonataTransformOutputSchema = z.object({
13
- /** Evaluation result (any JSON-compatible value). */
14
- result: z.unknown(),
15
- });
16
- //# sourceMappingURL=schemas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,2CAA2C;IAC3C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,8DAA8D;IAC9D,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,mGAAmG;IACnG,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CACvD,CAAC,CAAA;AAEF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,qDAAqD;IACrD,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;CACpB,CAAC,CAAA"}
@@ -1,7 +0,0 @@
1
- import type { JsonataTransformInput, JsonataTransformOutput } from "./schemas.js";
2
- /**
3
- * Compile and evaluate a JSONata expression against a payload.
4
- * @category Extensions
5
- */
6
- export declare function runJsonataTransform(input: JsonataTransformInput): Promise<JsonataTransformOutput>;
7
- //# sourceMappingURL=transform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAEjF;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC,CAsBjC"}
package/dist/transform.js DELETED
@@ -1,29 +0,0 @@
1
- import jsonata from "jsonata";
2
- /**
3
- * Compile and evaluate a JSONata expression against a payload.
4
- * @category Extensions
5
- */
6
- export async function runJsonataTransform(input) {
7
- let expr;
8
- try {
9
- expr = jsonata(input.expression);
10
- }
11
- catch (err) {
12
- const message = err instanceof Error ? err.message : String(err);
13
- throw new Error(`Invalid JSONata expression: ${message}`);
14
- }
15
- if (input.bindings) {
16
- for (const [name, value] of Object.entries(input.bindings)) {
17
- expr.assign(name, value);
18
- }
19
- }
20
- try {
21
- const result = await expr.evaluate(input.payload);
22
- return { result };
23
- }
24
- catch (err) {
25
- const message = err instanceof Error ? err.message : String(err);
26
- throw new Error(`JSONata evaluation failed: ${message}`);
27
- }
28
- }
29
- //# sourceMappingURL=transform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAA4B;IAE5B,IAAI,IAAI,CAAA;IACR,IAAI,CAAC;QACH,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChE,MAAM,IAAI,KAAK,CAAC,+BAA+B,OAAO,EAAE,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjD,OAAO,EAAE,MAAM,EAAE,CAAA;IACnB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChE,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC"}