@eigenpal/cli 0.4.12 → 0.4.14

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.
@@ -15,15 +15,12 @@ steps:
15
15
  with:
16
16
  inputs:
17
17
  text: '{{ input.text }}'
18
+ # Return-type annotation (`: { length: number; original: string }`)
19
+ # is mandatory and becomes this step's output schema.
18
20
  function: |
19
- function script(text) {
21
+ function script(text: string): { length: number; original: string } {
20
22
  return { length: text.length, original: text };
21
23
  }
22
- outputSchema:
23
- type: object
24
- properties:
25
- length: { type: number }
26
- original: { type: string }
27
24
 
28
25
  output:
29
26
  length: '{{ steps.echo.output.length }}'
@@ -109,12 +109,7 @@ one of the keys in `labels`; the harness then looks up the score.
109
109
  config:
110
110
  passThreshold: 1.0
111
111
  function: |
112
- /**
113
- * @param {Expected} expected the example's expected output
114
- * @param {Actual} actual the workflow's actual output
115
- * @returns {number} a score in [0, 1]; throws are caught and scored as 0
116
- */
117
- function scoreScript(expected, actual) {
112
+ function scoreScript(expected: Expected, actual: Actual): number {
118
113
  const a = actual.totalAmount ?? 0;
119
114
  const e = expected.totalAmount ?? 0;
120
115
  return Math.abs(a - e) <= 0.01 ? 1 : 0;
@@ -123,10 +118,11 @@ one of the keys in `labels`; the harness then looks up the score.
123
118
 
124
119
  Same WASM sandbox as `transform.script` (5s wall clock, 10 MB heap, no
125
120
  network). The YAML stores the **whole** `function scoreScript(expected,
126
- actual) { ... }` declaration verbatim — same text the dashboard editor
127
- shows. The JSDoc preamble is optional but recommended: it pulls the
128
- workflow's output schema into IntelliSense for `expected.…` /
129
- `actual.…` in the dashboard.
121
+ actual): number { ... }` declaration verbatim, same text the dashboard
122
+ editor shows. The `: number` return-type annotation is required and
123
+ enforced at parse time. `Expected` / `Actual` are in-scope type aliases
124
+ in the dashboard editor (both are the workflow's output shape); plain
125
+ `unknown` works too if you don't want them.
130
126
 
131
127
  The signature shape is **locked**:
132
128
 
@@ -271,7 +267,7 @@ _Generated from `EvalConfigYamlSchema` in `@eigenpal/types/src/eval/evaluator-co
271
267
 
272
268
  | Field | Type | Required | Default | Description |
273
269
  | --- | --- | --- | --- | --- |
274
- | `function` | string | yes | | Full JavaScript declaration of `function scoreScript(expected, actual) { ... }`. Receives `expected` (the example's expected output) and `actual` (the workflow's actual output), returns a number in [0, 1]. Throws are caught and scored as 0. |
270
+ | `function` | string | yes | | Full TypeScript declaration of `function scoreScript(expected, actual): number { ... }`. Receives `expected` (the example's expected output) and `actual` (the workflow's actual output), returns a number in [0, 1] (the `: number` annotation is required). The `: number` return-type annotation is required and enforced at parse time. Throws are caught and scored as 0. |
275
271
  | `timeoutMs` | integer | no | `5000` | Maximum wall-clock time the script can run before it's killed and the run is marked failed. |
276
272
  | `memoryLimitMb` | integer | no | `10` | Maximum memory the sandbox may allocate. Increase if the script processes large arrays or strings. |
277
273
  | `passThreshold` | number | no | `1` | Minimum script score this evaluator must reach for a run to pass. |
@@ -65,15 +65,20 @@ the catalog tells you what fields it takes.
65
65
 
66
66
  `transform.script` advantages over Liquid:
67
67
 
68
- - Explicit `inputs:` declaration → the validator knows the data deps
69
- - `outputSchema:` enforces the return shape at runtime
70
- - Real JS — `Array.prototype.reduce`, `JSON.parse`, etc.
68
+ - Explicit `inputs:` declaration; the validator knows the data deps
69
+ - Typed return annotation drives downstream autocomplete + runtime validation
70
+ - Real JS/TS (`Array.prototype.reduce`, `JSON.parse`, etc.)
71
71
  - Sandbox limits prevent infinite loops from blowing up an execution
72
72
 
73
- > Each entry in `inputs:` becomes a parameter of `function script(...)`
74
- > in declaration order. `inputs: { items, taxRate }` ⇒
75
- > `function script(items, taxRate) { … }`. The function must `return`
76
- > (or `throw`) a value.
73
+ > The function is **TypeScript**. Each `inputs:` key becomes a parameter
74
+ > in declaration order: `inputs: { items, taxRate }` ⇒
75
+ > `function script(items: ..., taxRate: ...): R { ... }`. The return-type
76
+ > annotation `R` is **required** and IS this step's output schema; there
77
+ > is no separate `outputSchema:` field. Describe what your function
78
+ > actually returns: downstream steps reference its fields via
79
+ > `{{ steps.<this>.output.<field> }}`, so a too-loose annotation (e.g.
80
+ > `unknown`) makes those references unresolvable. The function must
81
+ > `return` (or `throw`) a value.
77
82
 
78
83
  ## Reference / output paths
79
84
 
@@ -318,21 +323,20 @@ Convert XLSX spreadsheet to JSON array of row objects for use in scripts or down
318
323
 
319
324
  #### `transform.script` — Script
320
325
 
321
- Execute a JavaScript function in a QuickJS sandbox. Input keys become the function's parameter list, in declaration order: `inputs: { items, taxRate }` ⇒ `function script(items, taxRate) { … }`. Must `return` (or `throw`) a value.
326
+ Execute a TypeScript function in a QuickJS sandbox. Input keys become the function's parameter list, in declaration order, and the required `: R` return-type annotation IS this step's output schema: `inputs: { items, taxRate }` ⇒ `function script(items: …, taxRate: …): R { … }`.
322
327
 
323
328
  **Config** (in `step.with`):
324
329
 
325
330
  | Field | Type | Required | Default | Description |
326
331
  | --- | --- | --- | --- | --- |
327
- | `inputs` | record<string, string> | no | | Named inputs mapped from template expressions. Keys become the function parameter list in declaration order: `inputs: { items, taxRate }` ⇒ `function script(items, taxRate) { … }`. |
328
- | `function` | string | no | | JavaScript function declaration. Must be `function script(arg1, arg2, …) { … }` where the parameter list equals `Object.keys(inputs)` in declaration order. Must `return` (or `throw`) a value. |
329
- | `outputSchema` | record<string, unknown> | no | | JSON Schema describing the expected return value. Used for validation and type hints. |
332
+ | `inputs` | record<string, string> | no | | Named inputs mapped from template expressions. Keys become the function parameter list in declaration order: `inputs: { items, taxRate }` ⇒ `function script(items: …, taxRate: …): R { … }`. |
333
+ | `function` | string | yes | | TypeScript function declaration. Must be `function script(args): R { … }` where the parameter list equals `Object.keys(inputs)` in order and `R` is a return type annotation. The annotation IS this step's output schema. |
330
334
  | `timeout` | number | no | `5000` | Max execution time in milliseconds (default: 5000) |
331
335
  | `memoryLimit` | number | no | `10485760` | Max memory in bytes (default: 10MB) |
332
336
 
333
337
  **Output:** `unknown`
334
338
 
335
- > Value returned from script (validated against outputSchema if provided)
339
+ > Value returned from script. Validated at runtime against the JSON Schema derived from the function's return type annotation.
336
340
 
337
341
  #### `transform.text-chunker` — Text Chunker
338
342
 
@@ -149,7 +149,9 @@ Use Liquid `{{ ... }}` for one-liners:
149
149
  | Simple math | `{{ price \| times: quantity }}` |
150
150
 
151
151
  Anything more complex (array reduce/filter, multi-step calc, date
152
- arithmetic, regex) goes in `transform.script`:
152
+ arithmetic, regex) goes in `transform.script`. The function is
153
+ TypeScript; the return-type annotation IS this step's output schema
154
+ (there is no separate `outputSchema:` field):
153
155
 
154
156
  ```yaml
155
157
  - name: total
@@ -159,19 +161,24 @@ arithmetic, regex) goes in `transform.script`:
159
161
  lineItems: '{{ steps.extract.output.lineItems }}'
160
162
  taxRate: '{{ input.taxRate }}'
161
163
  function: |
162
- function script(lineItems, taxRate) {
164
+ function script(
165
+ lineItems: { price: number; qty: number }[],
166
+ taxRate: number,
167
+ ): { subtotal: number; tax: number; total: number } {
163
168
  const subtotal = lineItems.reduce((s, i) => s + i.price * i.qty, 0);
164
169
  const tax = subtotal * taxRate;
165
170
  return { subtotal, tax, total: subtotal + tax };
166
171
  }
167
- outputSchema: # optional but recommended — runtime-validated
168
- type: object
169
- properties:
170
- subtotal: { type: number }
171
- tax: { type: number }
172
- total: { type: number }
173
172
  ```
174
173
 
174
+ The `): { subtotal: number; tax: number; total: number }` annotation is
175
+ required and IS this step's output schema. Downstream steps autocomplete
176
+ against it and reference its fields via `{{ steps.<this>.output.<field> }}`,
177
+ and the worker validates the actual return value against it. Describe what
178
+ the function really returns: a too-loose annotation like `unknown` produces
179
+ an empty schema, which makes downstream `output.<field>` references
180
+ unresolvable and trips "field not found" warnings.
181
+
175
182
  The script runs in a WASM sandbox: 5s wall clock, 10 MB heap, no network,
176
183
  no filesystem. Trips show up as `script_timeout` / `script_memory_limit`
177
184
  on the step execution.
@@ -25,15 +25,13 @@ steps:
25
25
  with:
26
26
  inputs:
27
27
  text: '{{ input.text }}'
28
+ # The `: { length: number; original: string }` return-type annotation
29
+ # IS this step's output schema. Downstream steps autocomplete against
30
+ # it; the worker AJV-validates the return value against it at runtime.
28
31
  function: |
29
- function script(text) {
32
+ function script(text: string): { length: number; original: string } {
30
33
  return { length: text.length, original: text };
31
34
  }
32
- outputSchema:
33
- type: object
34
- properties:
35
- length: { type: number }
36
- original: { type: string }
37
35
 
38
36
  # `output` shapes the final return value. References any step's output.
39
37
  output:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eigenpal/cli",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
4
4
  "description": "Eigenpal CLI — author and run document workflows from your terminal. Agent-ready.",
5
5
  "keywords": [
6
6
  "eigenpal",