@meistrari/tela-cli 1.4.0 → 1.5.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.
@@ -16,11 +16,13 @@ import {
16
16
  code,
17
17
  crop,
18
18
  docTemplate,
19
+ condition,
19
20
  input,
20
21
  llm,
21
22
  splitter,
22
23
  vault,
23
24
  remote,
25
+ stop,
24
26
  workflow,
25
27
  } from '@meistrari/workflow-code'
26
28
  import type { WorkflowCodeConfig } from '@meistrari/workflow-code'
@@ -43,6 +45,8 @@ import type { WorkflowCodeConfig } from '@meistrari/workflow-code'
43
45
  | [`canvas()`](#canvasremoteref-options) | Executable Canvas or Workflow refs from the remote catalog. |
44
46
  | [`agent(remoteRef, options)`](#agentremoteref-options) | Published-Agent calls from the remote catalog. |
45
47
  | [`code()`](#codeoptions) | Sandboxed runtime JavaScript/TypeScript execution. |
48
+ | [`condition()`](#conditionoptions) | Synchronous predicate branches with compiler-owned V3 branch ports. |
49
+ | [`stop()`](#stop) | Terminal leaf allowed only as the final direct node of a condition branch. |
46
50
  | [`ref()` / `paths()` / `formats()`](#references-ref-paths-and-formats) | References to workflow inputs or prior node output in prompt callbacks and code handlers. |
47
51
 
48
52
  A workflow file normally creates inputs, creates nodes, then default-exports `build(workflow(...), { inputs, nodes })`.
@@ -177,6 +181,7 @@ const normalizeInvoice = code({
177
181
  Reference rules:
178
182
 
179
183
  - References in node inputs may target workflow inputs or earlier nodes.
184
+ - `condition()` and `stop()` are compiler-owned topology nodes and do not produce output references.
180
185
  - `paths()` only accepts node declarations, not inputs.
181
186
  - Path tokens are branded; do not replace them with strings or arrays.
182
187
  - A path token must come from the same node used in `ref()`, or authoring throws `ref path source must match ref target`.
@@ -743,6 +748,38 @@ Avoid these patterns:
743
748
  - Forward references to later nodes.
744
749
  - Declaring generated-reserved names such as `execute` or `TelaInput` in extracted handler/helper/type code.
745
750
 
751
+ ### `condition(options)`
752
+
753
+ ```ts
754
+ const route = condition({
755
+ cases: {
756
+ approved: {
757
+ when: ({ ref, paths }) =>
758
+ ref(classify, paths(classify).status) === 'approved',
759
+ nodes: [approveInvoice],
760
+ },
761
+ },
762
+ default: { nodes: [manualReview] },
763
+ })
764
+ ```
765
+
766
+ Declares a Workflow V3 condition. `cases` are evaluated in authored object insertion order; array-index names like `"0"` are rejected. Each named case has a synchronous boolean `when` predicate and ordered branch `nodes`. The optional `default` has only `nodes`.
767
+
768
+ The compiler extracts predicate source without executing it, copies supported source-visible helpers and local imports, rewrites `ref()` reads to runtime inputs, and emits guarded JavaScript for the V3 condition action. V3 `steps`, branch `portId`s, node IDs, and graph edges are always compiler-owned.
769
+
770
+ ### `stop()`
771
+
772
+ ```ts
773
+ const route = condition({
774
+ cases: {
775
+ duplicate: { when: () => true, nodes: [stop()] },
776
+ },
777
+ default: { nodes: [continueProcessing] },
778
+ })
779
+ ```
780
+
781
+ Declares a terminal Workflow V3 stop node. It is valid only as the final direct node in a `condition()` case or default branch. A stopped branch does not converge to the next node; normal and empty sibling branches still converge. `stop()` at the workflow root, inside a map body, or before another direct branch node reports `compiler.stop.invalid_placement`.
782
+
746
783
  ### Config and shared types
747
784
 
748
785
  These types are exported for config files and integrations. See [Config](/docs/config) for full examples.
@@ -72,6 +72,8 @@ tela workflow init --workflow invoice-processing --yes --json
72
72
 
73
73
  **Description.** `tela workflow compile` loads config, loads dotenv files, evaluates the TypeScript entrypoint, validates declarations, and returns deterministic Workflow V3 graph, payload, hashes, and diagnostics. It does not require or validate remote `projectId`/`promptId`, write lockfiles, sync remote content, or publish.
74
74
 
75
+ `compile` stays offline. For a workflow that declares `vault.asset()`, it can lower the asset only when the active-context lockfile already contains the matching uploaded `vault://...` ref. Otherwise it reports `vault.asset.missing_lock`. Compile never reads the asset file, uploads it, refreshes the lock, or contacts Vault; run `sync` first to create or refresh that lock.
76
+
75
77
  | Prop | Type | Required | Description |
76
78
  |---|---|---:|---|
77
79
  | `target` | Positional | No | Config `workflows` key to compile. Required when more than one workflow is configured. |
@@ -132,6 +134,8 @@ tela workflow codegen --json
132
134
 
133
135
  **Description.** `tela workflow sync` compiles local source, resolves the active Tela Local context, selects the matching `projectId` and `promptId`, verifies remote content, and writes per-context lockfile state under `.tela/workflows/<workflowKey>/contexts/<context>/lock.json`.
134
136
 
137
+ For `vault.asset()` declarations, sync validates that each local path is a regular file within the project directory, hashes its content, and reuses a matching active-context asset lock when possible. New or changed assets are uploaded and recorded as `vault://...` refs before sync performs its final resolved compilation or any workflow lifecycle mutation. This makes later offline `compile` runs deterministic; a changed asset is uploaded again on the next sync.
138
+
135
139
  Sync uses a consolidated version strategy. The compiled workflow becomes the complete source of truth for the next remote version: source files, hashes, lifecycle payload, package metadata, and binding metadata are consolidated into one prompt version snapshot. When compiled content changed, sync creates a new non-draft version. The only exception is a verified no-op: if local hashes already match the active-context lockfile and fresh remote content confirms the same version, sync returns without creating a version.
136
140
 
137
141
  Consolidated versions make sync safe to repeat. A sync never edits an existing version in place, never mutates a draft, and never changes the previous consolidated version. If the workflow is currently pointing at a draft version, sync leaves that draft untouched and creates a new consolidated non-draft version for the compiled workflow instead.
@@ -26,6 +26,17 @@ src/workflows/shared.ts
26
26
  | `src/workflows/prompts.ts` | Prompt strings and small prompt helpers. |
27
27
  | `src/workflows/shared.ts` | Pure utilities reused by declarations or code handlers. |
28
28
 
29
+ ### Generate remote authoring metadata
30
+
31
+ Run `codegen` before typechecking workflow source that uses named `remote()` catalog paths. It refreshes the active Tela Local context's catalog and writes the TypeScript augmentation used for remote authoring. `codegen` is workspace-scoped: it does not take a workflow target, load `workflow-code.config.ts`, compile a workflow, or mutate Tela resources.
32
+
33
+ ```bash
34
+ pnpm exec tela workflow codegen --json > .tela/codegen-result.json
35
+ node -e "const r=require('./.tela/codegen-result.json'); if (!r.success || r.diagnostics?.some(d => d.severity === 'error')) process.exit(1)"
36
+ ```
37
+
38
+ With credentials, codegen refreshes the catalog. When that refresh is unavailable, it can use only a complete cached snapshot for the same active context and workspace; inspect its warning diagnostics and `fetchedAt` before relying on the generated names.
39
+
29
40
  ### CI compile check
30
41
 
31
42
  Use `compile --json` in CI to validate source and fail on error diagnostics before any remote lifecycle command runs.
@@ -37,7 +48,9 @@ pnpm exec tela workflow compile demo --env .env.ci --json > .tela/compile-result
37
48
  node -e "const r=require('./.tela/compile-result.json'); if (r.diagnostics?.some(d => d.severity === 'error')) process.exit(1)"
38
49
  ```
39
50
 
40
- For trusted release jobs with Tela credentials, run sync after compile:
51
+ `compile` does not upload local `vault.asset()` files. An asset workflow needs an uploaded ref in the active-context lockfile or compile reports `vault.asset.missing_lock`. Do not use a compile-only job to bootstrap those locks.
52
+
53
+ For trusted release jobs with Tela credentials, run sync. It reuses unchanged asset hashes, uploads new or changed assets, records their Vault refs in the context lockfile, then performs final resolved compilation before the workflow lifecycle mutation:
41
54
 
42
55
  ```bash
43
56
  pnpm exec tela workflow sync --env .env.ci --yes --json > .tela/sync-result.json
@@ -48,9 +61,11 @@ Commit stable context lockfiles such as `.tela/workflows/*/contexts/*/lock.json`
48
61
 
49
62
  ### Troubleshooting diagnostics
50
63
 
51
- When `compile` or `sync` fails, read diagnostic `code` and `hint` first. Most failures point to config shape, missing env files, unresolved entry paths, invalid references, `workflowKey` mismatches, unsupported `code()` extraction patterns, missing `promptId`, active-context binding mismatches, or remote divergence.
64
+ When `codegen`, `compile`, or `sync` fails, read diagnostic `code` and `hint` first. Most failures point to config shape, missing env files, unresolved entry paths, invalid references, `workflowKey` mismatches, unsupported `code()` extraction patterns, missing `promptId`, active-context binding mismatches, Vault asset locks/uploads, or remote divergence.
52
65
 
66
+ - Use `tela workflow codegen --json` to refresh remote authoring metadata or inspect matching-context cached-fallback diagnostics.
53
67
  - Use `tela workflow compile --json` for declaration and graph diagnostics.
54
68
  - Use `tela context current --json` when `sync` selects an unexpected context binding.
69
+ - Run `tela workflow sync` when `compile` reports `vault.asset.missing_lock`; sync uploads and locks the local asset before its final resolved compile.
55
70
  - Pass `--yes` only in trusted non-interactive jobs where consolidating a newer remote version is expected.
56
71
  - Keep code handlers source-visible and avoid dynamic imports, runtime-created closure values, and reserved generated names.
@@ -14,13 +14,13 @@
14
14
  "slug": "api-reference",
15
15
  "title": "API Reference",
16
16
  "file": "api-reference.md",
17
- "sha256": "380cf0c8543400f6fd311936f1b4fb984f12d27b0472213b8a2b431405f0755e"
17
+ "sha256": "f601e98f0c63812dc0979473c5476b35709f6c8ff70e6de131674503d9cfbe59"
18
18
  },
19
19
  {
20
20
  "slug": "cli",
21
21
  "title": "CLI",
22
22
  "file": "cli.md",
23
- "sha256": "759db330fd7b06859e55404f01feb0625a43bb579324fe011bc34cd92d517239"
23
+ "sha256": "ef7975ab0a915f6a57aa869713e0134478751e9814ac0b2f40d137c85f8ad581"
24
24
  },
25
25
  {
26
26
  "slug": "config",
@@ -32,7 +32,7 @@
32
32
  "slug": "guides",
33
33
  "title": "Guides",
34
34
  "file": "guides.md",
35
- "sha256": "b3f2ff1ac03f3829b6c5614ecc61229e181179dd2506684fae073075748359cb"
35
+ "sha256": "4109cef4376315b99cbee2d763c927c3148ed889b8602f958fb785faebaf8e03"
36
36
  },
37
37
  {
38
38
  "slug": "installation",