@meistrari/tela-cli 1.2.0 → 1.3.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.
Files changed (2) hide show
  1. package/dist/index.js +232 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -129552,12 +129552,13 @@ var require_generate = __commonJS({
129552
129552
  const lines = [
129553
129553
  "/* eslint-disable */",
129554
129554
  `// @generated by tela workflow codegen; catalog-metadata-hash: ${snapshot.metadataHash}`,
129555
- "import type { WorkflowCodeFileInputValue, WorkflowCodeRemoteAgentRef, WorkflowCodeRemoteExecutableRef, WorkflowCodeRemoteModelRef } from '@meistrari/workflow-code/contracts'",
129555
+ "import type { WorkflowCodeFileInputValue, WorkflowCodeRemoteAgentRef, WorkflowCodeRemoteExecutableRef, WorkflowCodeRemoteModelRef, WorkflowCodeRemoteTemplateRef } from '@meistrari/workflow-code/contracts'",
129556
129556
  "",
129557
129557
  "declare module '@meistrari/workflow-code' {",
129558
129558
  " function remote(): {",
129559
129559
  " canvas(): WorkflowCodeRemoteCatalogRegistry['canvas']",
129560
129560
  " workflow(): WorkflowCodeRemoteCatalogRegistry['workflow']",
129561
+ " template(): WorkflowCodeRemoteCatalogRegistry['template']",
129561
129562
  " agent(): WorkflowCodeRemoteCatalogRegistry['agent']",
129562
129563
  " models(): WorkflowCodeRemoteCatalogRegistry['models']",
129563
129564
  " }",
@@ -129565,6 +129566,7 @@ var require_generate = __commonJS({
129565
129566
  " interface WorkflowCodeRemoteCatalogRegistry {",
129566
129567
  ` canvas: ${renderResourceRegistry("canvas", normalizeResources(snapshot.catalogs.canvases), diagnostics)}`,
129567
129568
  ` workflow: ${renderResourceRegistry("workflow", normalizeResources(snapshot.catalogs.workflows), diagnostics)}`,
129569
+ ` template: ${renderResourceRegistry("template", normalizeResources(snapshot.catalogs.templates), diagnostics)}`,
129568
129570
  ` agent: ${renderResourceRegistry("agent", normalizeResources(snapshot.catalogs.agents), diagnostics)}`,
129569
129571
  ` models: ${renderModelRegistry(snapshot.catalogs.llmModels)}`,
129570
129572
  " }",
@@ -129576,7 +129578,7 @@ var require_generate = __commonJS({
129576
129578
  function renderResourceRegistry(kind, resources, diagnostics) {
129577
129579
  const nameTree = buildNameTree(resources.filter(hasUniquePath).map((resource) => ({ path: resource.path, value: renderResourceRef(kind, resource) })));
129578
129580
  const byId = resources.map((resource) => `byId(id: ${quote(resource.id)}): ${renderResourceRef(kind, resource)}`).join("; ");
129579
- const unknownRef = kind === "agent" ? "WorkflowCodeRemoteAgentRef<string, unknown, unknown>" : `WorkflowCodeRemoteExecutableRef<${quote(kind)}, string, unknown, unknown, {}>`;
129581
+ const unknownRef = kind === "agent" ? "WorkflowCodeRemoteAgentRef<string, unknown, unknown>" : kind === "template" ? "WorkflowCodeRemoteTemplateRef<string, unknown, unknown>" : `WorkflowCodeRemoteExecutableRef<${quote(kind)}, string, unknown, unknown, {}>`;
129580
129582
  const members = [renderTree(nameTree), byId.length > 0 ? `{ ${byId}; byId(id: string): ${unknownRef} }` : `{ byId(id: string): ${unknownRef} }`];
129581
129583
  for (const resource of resources) {
129582
129584
  if (resource.pathStatus === "ambiguous") {
@@ -129587,13 +129589,14 @@ var require_generate = __commonJS({
129587
129589
  }
129588
129590
  function renderResourceRef(kind, resource) {
129589
129591
  const input = renderInputObject(resource.inputs);
129590
- const output = isAgent(resource) ? renderAgentOutput(resource) : renderOutput(resource.output);
129591
- if (!isAgent(resource)) {
129592
- const environments = resource.targets.map((target) => quote(target.name)).sort().join(" | ") || "never";
129593
- const targets = resource.targets.map((target) => `${quote(target.name)}: { input: ${renderInputObject(target.inputs)}, output: ${renderOutput(target.output)}, hash: ${quote(target.hash)} }`).join("; ");
129594
- return `WorkflowCodeRemoteExecutableRef<${quote(kind)}, ${quote(resource.id)}, ${input}, ${output}, { ${targets} }> & { environments: ${environments} }`;
129595
- }
129596
- return `WorkflowCodeRemoteAgentRef<${quote(resource.id)}, ${input}, ${output}>`;
129592
+ if (isAgent(resource))
129593
+ return `WorkflowCodeRemoteAgentRef<${quote(resource.id)}, ${input}, ${renderAgentOutput(resource)}>`;
129594
+ const output = renderOutput(resource.output);
129595
+ if (!("targets" in resource))
129596
+ return `WorkflowCodeRemoteTemplateRef<${quote(resource.id)}, ${input}, ${output}>`;
129597
+ const environments = resource.targets.map((target) => quote(target.name)).sort().join(" | ") || "never";
129598
+ const targets = resource.targets.map((target) => `${quote(target.name)}: { input: ${renderInputObject(target.inputs)}, output: ${renderOutput(target.output)}, hash: ${quote(target.hash)} }`).join("; ");
129599
+ return `WorkflowCodeRemoteExecutableRef<${quote(kind)}, ${quote(resource.id)}, ${input}, ${output}, { ${targets} }> & { environments: ${environments} }`;
129597
129600
  }
129598
129601
  function renderModelRegistry(models) {
129599
129602
  const named = Object.fromEntries(models.map((model) => [model.id, `WorkflowCodeRemoteModelRef<${quote(model.id)}, "llm">`]));
@@ -146369,7 +146372,12 @@ var require_remote_refs = __commonJS({
146369
146372
  const catalogDiagnostics = validateAgainstSnapshot(input.mode.snapshot, input.binding, lock, input.modelUsage);
146370
146373
  if (catalogDiagnostics.length > 0)
146371
146374
  return { value: void 0, diagnostics: catalogDiagnostics };
146372
- return { value: lock.id, diagnostics: [] };
146375
+ const outputSchema = templateOutputSchema(input.mode.snapshot, input.binding, lock.id);
146376
+ return {
146377
+ value: lock.id,
146378
+ diagnostics: [],
146379
+ ...outputSchema === void 0 ? {} : { outputSchema }
146380
+ };
146373
146381
  }
146374
146382
  function findLock(locks, binding, environment) {
146375
146383
  return locks.find((lock) => lock.kind === binding.kind && (binding.explicitId === void 0 || lock.id === binding.explicitId) && (binding.path === void 0 || samePath(lock.path, binding.path)) && (environment === void 0 || lock.environmentName === environment));
@@ -146393,10 +146401,18 @@ var require_remote_refs = __commonJS({
146393
146401
  return snapshot.catalogs.canvases.find((resource) => resource.id === id);
146394
146402
  if (binding.kind === "workflow")
146395
146403
  return snapshot.catalogs.workflows.find((resource) => resource.id === id);
146404
+ if (binding.kind === "template")
146405
+ return snapshot.catalogs.templates.find((resource) => resource.id === id);
146396
146406
  if (binding.kind === "agent")
146397
146407
  return snapshot.catalogs.agents.find((resource) => resource.id === id);
146398
146408
  return snapshot.catalogs.llmModels.find((resource) => resource.id === id);
146399
146409
  }
146410
+ function templateOutputSchema(snapshot, binding, id) {
146411
+ if (binding.kind !== "template")
146412
+ return void 0;
146413
+ const output = snapshot.catalogs.templates.find((resource) => resource.id === id)?.output;
146414
+ return isRecord3(output?.schema) ? output.schema : void 0;
146415
+ }
146400
146416
  function remoteDiagnostic(code, binding, message) {
146401
146417
  return {
146402
146418
  code,
@@ -146406,6 +146422,9 @@ var require_remote_refs = __commonJS({
146406
146422
  hint: `Remote ${binding.kind} ${binding.explicitId ?? binding.path?.join(" / ") ?? "<root>"}`
146407
146423
  };
146408
146424
  }
146425
+ function isRecord3(value) {
146426
+ return typeof value === "object" && value !== null && !Array.isArray(value);
146427
+ }
146409
146428
  function rootFallbackContractHash(input) {
146410
146429
  return (0, hash_1.hashJson)(input);
146411
146430
  }
@@ -146517,8 +146536,27 @@ var require_resolve = __commonJS({
146517
146536
  contractHash: (0, remote_refs_1.agentSemanticContractHash)({ revision: agent.revision, inputs: normalizedInputsForContract(agent.inputs), ...outputHash === void 0 ? {} : { outputContractHash: outputHash } })
146518
146537
  };
146519
146538
  }
146539
+ if (ref.kind === "template")
146540
+ return lockTemplateRef(ref, resource);
146520
146541
  return lockExecutableRef(ref, resource, ref.kind);
146521
146542
  }
146543
+ function lockTemplateRef(ref, resource) {
146544
+ const outputHash = (0, remote_refs_1.outputContractHash)(resource.output);
146545
+ return {
146546
+ declarationKey: ref.declarationKey,
146547
+ kind: "template",
146548
+ ...resource.pathStatus === "unavailable" ? {} : { path: resource.path },
146549
+ id: resource.id,
146550
+ versionId: resource.versionId,
146551
+ inputHash: (0, remote_refs_1.selectedInputHash)(resource.inputs),
146552
+ ...outputHash === void 0 ? {} : { outputContractHash: outputHash },
146553
+ contractHash: (0, remote_refs_1.rootFallbackContractHash)({
146554
+ versionId: resource.versionId,
146555
+ inputs: normalizedInputsForContract(resource.inputs),
146556
+ ...outputHash === void 0 ? {} : { outputContractHash: outputHash }
146557
+ })
146558
+ };
146559
+ }
146522
146560
  function lockExecutableRef(ref, resource, kind) {
146523
146561
  const environmentName = ref.environment ?? resource.environment ?? (resource.targets.length === 1 ? resource.targets[0]?.name : void 0);
146524
146562
  const target = environmentName === void 0 ? void 0 : resource.targets.find((item) => item.name === environmentName);
@@ -146624,6 +146662,8 @@ var require_resolve = __commonJS({
146624
146662
  function selectedInputs(resource, ref, diagnostics) {
146625
146663
  if (ref.kind === "agent")
146626
146664
  return resource.inputs;
146665
+ if (ref.kind === "template")
146666
+ return resource.inputs;
146627
146667
  const executable = resource;
146628
146668
  const environmentName = ref.environment ?? executable.environment ?? (executable.targets.length === 1 ? executable.targets[0]?.name : void 0);
146629
146669
  if (environmentName === void 0)
@@ -146639,6 +146679,8 @@ var require_resolve = __commonJS({
146639
146679
  return snapshot.catalogs.canvases;
146640
146680
  if (kind === "workflow")
146641
146681
  return snapshot.catalogs.workflows;
146682
+ if (kind === "template")
146683
+ return snapshot.catalogs.templates;
146642
146684
  if (kind === "agent")
146643
146685
  return snapshot.catalogs.agents;
146644
146686
  return snapshot.catalogs.llmModels;
@@ -154668,6 +154710,7 @@ var require_remote = __commonJS({
154668
154710
  return Object.freeze({
154669
154711
  canvas: () => createRemoteRef("canvas"),
154670
154712
  workflow: () => createRemoteRef("workflow"),
154713
+ template: () => createRemoteRef("template"),
154671
154714
  agent: () => createRemoteRef("agent"),
154672
154715
  models: () => createRemoteRef("model")
154673
154716
  });
@@ -368743,6 +368786,7 @@ var require_output_schema = __commonJS({
368743
368786
  exports2.createPromptOutputJsonSchema = createPromptOutputJsonSchema;
368744
368787
  exports2.selectOutputJsonSchema = selectOutputJsonSchema;
368745
368788
  exports2.isFileCompatibleOutputJsonSchema = isFileCompatibleOutputJsonSchema;
368789
+ exports2.isStringCompatibleOutputJsonSchema = isStringCompatibleOutputJsonSchema;
368746
368790
  exports2.FILE_OUTPUT_JSON_SCHEMA = Object.freeze({
368747
368791
  type: "object",
368748
368792
  properties: Object.freeze({
@@ -368828,17 +368872,17 @@ var require_output_schema = __commonJS({
368828
368872
  if (schema.type !== "object" || !isRecord3(properties))
368829
368873
  return false;
368830
368874
  const stringFields = ["name", "fileUrl", "mimeType", "base64", "vaultReference"];
368831
- if (!stringFields.every((key) => !(key in properties) || isStringJsonSchema(properties[key])))
368875
+ if (!stringFields.every((key) => !(key in properties) || isStringCompatibleOutputJsonSchema(properties[key])))
368832
368876
  return false;
368833
- return isStringJsonSchema(properties.name) && ["fileUrl", "vaultReference", "base64"].some((key) => isStringJsonSchema(properties[key]));
368877
+ return isStringCompatibleOutputJsonSchema(properties.name) && ["fileUrl", "vaultReference", "base64"].some((key) => isStringCompatibleOutputJsonSchema(properties[key]));
368834
368878
  }
368835
368879
  function isFileArrayJsonSchema(schema) {
368836
368880
  return isRecord3(schema) && schema.type === "array" && isFileJsonSchema(schema.items);
368837
368881
  }
368838
- function isStringJsonSchema(schema) {
368882
+ function isStringCompatibleOutputJsonSchema(schema) {
368839
368883
  const variants = jsonSchemaVariants(schema);
368840
368884
  if (variants)
368841
- return variants.every(isStringJsonSchema);
368885
+ return variants.every(isStringCompatibleOutputJsonSchema);
368842
368886
  if (!isRecord3(schema))
368843
368887
  return false;
368844
368888
  if (schema.type !== void 0 && schema.type !== "string")
@@ -368853,9 +368897,10 @@ var require_output_schema = __commonJS({
368853
368897
  return schema.type === "string" || hasStringConst || hasStringEnum;
368854
368898
  }
368855
368899
  function jsonSchemaVariants(schema) {
368856
- if (!isRecord3(schema) || !Array.isArray(schema.anyOf) || schema.anyOf.length === 0)
368900
+ if (!isRecord3(schema))
368857
368901
  return void 0;
368858
- return schema.anyOf.every(isRecord3) ? schema.anyOf : void 0;
368902
+ const variants = Array.isArray(schema.anyOf) ? schema.anyOf : Array.isArray(schema.oneOf) ? schema.oneOf : void 0;
368903
+ return variants !== void 0 && variants.length > 0 && variants.every(isRecord3) ? variants : void 0;
368859
368904
  }
368860
368905
  function isRecord3(value) {
368861
368906
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -369331,7 +369376,7 @@ var require_extract3 = __commonJS({
369331
369376
  required: declaration.required
369332
369377
  }));
369333
369378
  const nodeBindings = input.builtNodes.slice(0, input.currentNodeIndex).flatMap((node) => {
369334
- const schema = input.nodeOutputSchemasByKey.get(node.key ?? node.name);
369379
+ const schema = input.nodeOutputSchemasById.get(input.nodeIdsByKey.get(node.key ?? node.name) ?? "");
369335
369380
  return schema ? [{ name: node.name, schema, required: true }] : [];
369336
369381
  });
369337
369382
  return [...inputBindings, ...nodeBindings];
@@ -370547,6 +370592,7 @@ var require_refs = __commonJS({
370547
370592
  return {
370548
370593
  reference: resolved.reference,
370549
370594
  inputType: "inputType" in resolved ? resolved.inputType : void 0,
370595
+ nodeId: "nodeId" in resolved ? resolved.nodeId : void 0,
370550
370596
  diagnostics: []
370551
370597
  };
370552
370598
  }
@@ -370578,7 +370624,7 @@ var require_refs = __commonJS({
370578
370624
  const visible = findVisibleCandidate(ref.targetKey, context);
370579
370625
  if (visible) {
370580
370626
  const reference = workflow_shared_1.ActionOutputReferenceURI.fromStepId(visible.id);
370581
- return { reference: formatPromptReference(reference, ref) };
370627
+ return { reference: formatPromptReference(reference, ref), nodeId: visible.id };
370582
370628
  }
370583
370629
  if (candidates.some((candidate) => samePath(candidate.scopePath, context.currentNode.scopePath) && candidate.sequenceIndex >= context.currentNode.sequenceIndex)) {
370584
370630
  return "forward";
@@ -370710,20 +370756,43 @@ var require_modules = __commonJS({
370710
370756
  output: (0, ids_1.defaultOutputPortId)(nodeId)
370711
370757
  };
370712
370758
  }
370713
- function collectRemoteInputFacts(values, refs, inputs) {
370759
+ function collectRemoteInputFacts(values, refs, context) {
370714
370760
  const refsByInputName = new Map((refs ?? []).map((ref) => [ref.key, ref]));
370715
- const inputsByKey = new Map(inputs.map((input) => [input.key ?? input.name, input]));
370761
+ const inputsByKey = new Map(context.builtInputs.map((input) => [input.key ?? input.name, input]));
370716
370762
  const types = {};
370717
370763
  for (const [name, value] of Object.entries(values)) {
370718
370764
  const ref = refsByInputName.get(name);
370765
+ const formattedType = ref === void 0 ? void 0 : formattedRemoteInputType(ref.format);
370719
370766
  const input = ref?.targetKind === "input" ? inputsByKey.get(ref.targetKey) : void 0;
370720
- if (input !== void 0)
370767
+ if (formattedType !== void 0) {
370768
+ types[name] = formattedType;
370769
+ } else if (input !== void 0) {
370721
370770
  types[name] = input.inputType;
370722
- else if (ref === void 0 && typeof value === "string")
370771
+ } else if (ref?.targetKind === "node") {
370772
+ const resolved = (0, refs_1.resolveWorkflowRef)(ref, context);
370773
+ const selectedSchema = (0, output_schema_1.selectOutputJsonSchema)(resolved.nodeId === void 0 ? void 0 : context.nodeOutputSchemasById.get(resolved.nodeId), ref.path ?? []);
370774
+ const type2 = inferredRemoteInputType(selectedSchema, ref.format);
370775
+ if (type2 !== void 0)
370776
+ types[name] = type2;
370777
+ } else if (ref === void 0 && typeof value === "string") {
370723
370778
  types[name] = value.startsWith("vault://") ? "file" : "text";
370779
+ }
370724
370780
  }
370725
370781
  return { names: Object.keys(values), types };
370726
370782
  }
370783
+ function inferredRemoteInputType(schema, format) {
370784
+ const formattedType = formattedRemoteInputType(format);
370785
+ if (formattedType !== void 0)
370786
+ return formattedType;
370787
+ if ((0, output_schema_1.isFileCompatibleOutputJsonSchema)(schema))
370788
+ return "file";
370789
+ return (0, output_schema_1.isStringCompatibleOutputJsonSchema)(schema) ? "text" : void 0;
370790
+ }
370791
+ function formattedRemoteInputType(format) {
370792
+ if (format === "ai-xml" || format === "string")
370793
+ return "text";
370794
+ return void 0;
370795
+ }
370727
370796
  function hasValidPromptInput(node) {
370728
370797
  const input = "input" in node ? node.input : void 0;
370729
370798
  if (!input || typeof input !== "object")
@@ -370771,7 +370840,7 @@ var require_modules = __commonJS({
370771
370840
  if (!value || typeof value !== "object")
370772
370841
  return false;
370773
370842
  const candidate = value;
370774
- return typeof candidate.token === "string" && (candidate.targetKind === "input" || candidate.targetKind === "node") && typeof candidate.targetKey === "string" && (candidate.path === void 0 || Array.isArray(candidate.path));
370843
+ return typeof candidate.token === "string" && (candidate.targetKind === "input" || candidate.targetKind === "node") && typeof candidate.targetKey === "string" && (candidate.path === void 0 || Array.isArray(candidate.path) && candidate.path.every((segment) => typeof segment === "string")) && (candidate.format === void 0 || candidate.format === "ai-xml" || candidate.format === "raw" || candidate.format === "string");
370775
370844
  }
370776
370845
  function hasValidMapInput(node) {
370777
370846
  const input = "input" in node ? node.input : void 0;
@@ -370894,7 +370963,8 @@ var require_modules = __commonJS({
370894
370963
  inputNamesByKey: context.inputNamesByKey,
370895
370964
  nodeNamesByKey: context.nodeNamesByKey,
370896
370965
  nodeIndexesByKey: context.nodeIndexesByKey,
370897
- nodeOutputSchemasByKey: context.nodeOutputSchemasByKey
370966
+ nodeOutputSchemasById: context.nodeOutputSchemasById,
370967
+ nodeIdsByKey: context.nodeIdsByKey
370898
370968
  });
370899
370969
  context.diagnostics.push(...extracted.diagnostics);
370900
370970
  if (extracted.diagnostics.some((item) => item.severity === "error"))
@@ -371155,10 +371225,12 @@ var require_modules = __commonJS({
371155
371225
  return [];
371156
371226
  return [incompatibleDocumentRefDiagnostic(file2.targetKey, targetField)];
371157
371227
  }
371158
- const targetIndex = context.nodeIndexesByKey.get(file2.targetKey);
371159
- if (targetIndex === void 0 || targetIndex >= context.nodeIndex)
371228
+ const resolved = (0, refs_1.resolveWorkflowRef)(file2, context);
371229
+ if (resolved.nodeId === void 0)
371230
+ return [];
371231
+ const selectedSchema = (0, output_schema_1.selectOutputJsonSchema)(context.nodeOutputSchemasById.get(resolved.nodeId), file2.path ?? []);
371232
+ if (selectedSchema === void 0 && context.remoteMode.kind === "symbolic" && context.remoteTemplateNodeIds.has(resolved.nodeId))
371160
371233
  return [];
371161
- const selectedSchema = (0, output_schema_1.selectOutputJsonSchema)(context.nodeOutputSchemasByKey.get(file2.targetKey), file2.path ?? []);
371162
371234
  return (0, output_schema_1.isFileCompatibleOutputJsonSchema)(selectedSchema) ? [] : [incompatibleDocumentRefDiagnostic(file2.targetKey, targetField)];
371163
371235
  }
371164
371236
  function incompatibleDocumentRefDiagnostic(targetKey, targetField) {
@@ -371195,7 +371267,7 @@ var require_modules = __commonJS({
371195
371267
  lower(node, context) {
371196
371268
  const linearPorts = defaultLinearPorts(context.nodeId);
371197
371269
  const nodeKey = node.key ?? node.name;
371198
- const inputFacts = collectRemoteInputFacts(node.input.variables, node.variableRefs, context.builtInputs);
371270
+ const inputFacts = collectRemoteInputFacts(node.input.variables, node.variableRefs, context);
371199
371271
  context.remoteRefs.push((0, remote_refs_1.collectRemoteCall)(nodeKey, "call", node.ref, node.environment, inputFacts.names, inputFacts.types));
371200
371272
  const resolvedRef = (0, remote_refs_1.resolveRemoteBinding)({ mode: context.remoteMode, binding: node.ref, nodeKey, use: "call", environment: node.environment });
371201
371273
  context.diagnostics.push(...resolvedRef.diagnostics);
@@ -371240,7 +371312,7 @@ var require_modules = __commonJS({
371240
371312
  lower(node, context) {
371241
371313
  const linearPorts = defaultLinearPorts(context.nodeId);
371242
371314
  const nodeKey = node.key ?? node.name;
371243
- const inputFacts = collectRemoteInputFacts(node.input.inputs, node.inputRefs, context.builtInputs);
371315
+ const inputFacts = collectRemoteInputFacts(node.input.inputs, node.inputRefs, context);
371244
371316
  context.remoteRefs.push((0, remote_refs_1.collectRemoteCall)(nodeKey, "call", node.ref, void 0, inputFacts.names, inputFacts.types));
371245
371317
  const resolvedRef = (0, remote_refs_1.resolveRemoteBinding)({ mode: context.remoteMode, binding: node.ref, nodeKey, use: "call" });
371246
371318
  context.diagnostics.push(...resolvedRef.diagnostics);
@@ -371284,10 +371356,102 @@ var require_modules = __commonJS({
371284
371356
  };
371285
371357
  }
371286
371358
  };
371359
+ var remoteTemplateModule = {
371360
+ kind: "remote-template",
371361
+ actionId: workflow_shared_1.WORKFLOW_ACTION_IDS.template,
371362
+ createFailedInput() {
371363
+ return { templateId: "", variables: {} };
371364
+ },
371365
+ validate(node) {
371366
+ return hasValidRemoteTemplateInput(node) ? [] : [invalidRemoteTemplateInputDiagnostic(node)];
371367
+ },
371368
+ lower(node, context) {
371369
+ if (!hasValidRemoteTemplateInput(node))
371370
+ return void 0;
371371
+ const linearPorts = defaultLinearPorts(context.nodeId);
371372
+ const nodeKey = node.key ?? node.name;
371373
+ const inputFacts = collectRemoteInputFacts(node.input.variables, node.variableRefs, context);
371374
+ context.remoteRefs.push((0, remote_refs_1.collectRemoteCall)(nodeKey, "call", node.ref, void 0, inputFacts.names, inputFacts.types));
371375
+ const resolvedRef = (0, remote_refs_1.resolveRemoteBinding)({ mode: context.remoteMode, binding: node.ref, nodeKey, use: "call" });
371376
+ context.diagnostics.push(...resolvedRef.diagnostics);
371377
+ const resolvedVariables = (0, refs_1.resolveReferenceRecordRefs)({
371378
+ values: node.input.variables,
371379
+ refs: node.variableRefs ?? [],
371380
+ inputIdsByKey: context.inputIdsByKey,
371381
+ inputTypesByKey: context.inputTypesByKey,
371382
+ nodeIdentitiesByKey: context.nodeIdentitiesByKey,
371383
+ nodesByPath: context.nodesByPath,
371384
+ currentNode: context.currentNode
371385
+ });
371386
+ context.diagnostics.push(...resolvedVariables.diagnostics);
371387
+ return {
371388
+ node: {
371389
+ id: context.nodeId,
371390
+ name: node.name,
371391
+ actionId: workflow_shared_1.WORKFLOW_ACTION_IDS.template,
371392
+ ports: [
371393
+ { id: linearPorts.input, dir: "in", type: "default" },
371394
+ { id: linearPorts.output, dir: "out", type: "default" }
371395
+ ],
371396
+ input: {
371397
+ templateId: resolvedRef.value ?? (0, remote_refs_1.symbolicRemoteMarker)(node.ref),
371398
+ variables: resolvedVariables.values,
371399
+ ...node.input.tags === void 0 ? {} : { tags: node.input.tags }
371400
+ }
371401
+ },
371402
+ linearPorts,
371403
+ ...resolvedRef.outputSchema === void 0 ? {} : { outputSchema: resolvedRef.outputSchema }
371404
+ };
371405
+ }
371406
+ };
371407
+ function hasValidRemoteTemplateInput(node) {
371408
+ const candidate = node;
371409
+ if (!isRemoteTemplateBinding(candidate.ref) || !isRecord3(candidate.input) || !isJsonRecord(candidate.input.variables))
371410
+ return false;
371411
+ return (candidate.input.tags === void 0 || Array.isArray(candidate.input.tags) && candidate.input.tags.every((tag2) => typeof tag2 === "string")) && (candidate.variableRefs === void 0 || Array.isArray(candidate.variableRefs) && candidate.variableRefs.every(isReferenceRecordRefUse));
371412
+ }
371413
+ function isRemoteTemplateBinding(value) {
371414
+ return isRecord3(value) && value.kind === "template" && (value.path === void 0 || Array.isArray(value.path) && value.path.every((item) => typeof item === "string")) && (value.explicitId === void 0 || typeof value.explicitId === "string");
371415
+ }
371416
+ function isReferenceRecordRefUse(value) {
371417
+ return isPromptRefUse(value) && typeof value.key === "string";
371418
+ }
371419
+ function isJsonRecord(value) {
371420
+ return isRecord3(value) && isJsonValue(value, /* @__PURE__ */ new Set());
371421
+ }
371422
+ function isJsonValue(value, ancestors) {
371423
+ if (value === null || typeof value === "string" || typeof value === "boolean")
371424
+ return true;
371425
+ if (typeof value === "number")
371426
+ return Number.isFinite(value);
371427
+ if (typeof value !== "object" || ancestors.has(value))
371428
+ return false;
371429
+ if (Array.isArray(value)) {
371430
+ ancestors.add(value);
371431
+ const valid2 = value.every((item) => isJsonValue(item, ancestors));
371432
+ ancestors.delete(value);
371433
+ return valid2;
371434
+ }
371435
+ const prototype2 = Object.getPrototypeOf(value);
371436
+ if (!isRecord3(value) || prototype2 !== null && Object.getPrototypeOf(prototype2) !== null)
371437
+ return false;
371438
+ ancestors.add(value);
371439
+ const valid = Object.values(value).every((item) => isJsonValue(item, ancestors));
371440
+ ancestors.delete(value);
371441
+ return valid;
371442
+ }
371443
+ function invalidRemoteTemplateInputDiagnostic(node) {
371444
+ return {
371445
+ code: "compiler.module.invalid_input",
371446
+ severity: "error",
371447
+ message: `Node ${node.name || "<unnamed>"} has invalid Template input`
371448
+ };
371449
+ }
371287
371450
  exports2.nodeModuleRegistry = /* @__PURE__ */ new Map([
371288
371451
  [llmModule.kind, llmModule],
371289
371452
  [remoteExecutableModule.kind, remoteExecutableModule],
371290
371453
  [remoteAgentModule.kind, remoteAgentModule],
371454
+ [remoteTemplateModule.kind, remoteTemplateModule],
371291
371455
  [codeModule.kind, codeModule],
371292
371456
  [mapModule.kind, mapModule],
371293
371457
  [splitterModule.kind, splitterModule],
@@ -371485,7 +371649,7 @@ var require_transpile = __commonJS({
371485
371649
  return createFailedSplitterNode(workflowKey, declaration);
371486
371650
  if (declaration.node.nodeKind === "crop")
371487
371651
  return createFailedCropNode(workflowKey, declaration);
371488
- if (declaration.node.nodeKind === "remote-executable" || declaration.node.nodeKind === "remote-agent")
371652
+ if (declaration.node.nodeKind === "remote-executable" || declaration.node.nodeKind === "remote-agent" || declaration.node.nodeKind === "remote-template")
371489
371653
  return createFailedRemoteNode(workflowKey, declaration);
371490
371654
  return createFailedPromptNode(workflowKey, declaration);
371491
371655
  }
@@ -371755,6 +371919,8 @@ var require_transpile = __commonJS({
371755
371919
  const inputNamesByKey = new Map(declarationInputs.map((declaration) => [declaration.key ?? declaration.name, declaration.name]));
371756
371920
  const nodeNamesByKey = new Map(topLevelNodes.map(({ node }) => [node.key ?? node.name, node.name]));
371757
371921
  const nodeOutputSchemasByKey = /* @__PURE__ */ new Map();
371922
+ const nodeOutputSchemasById = /* @__PURE__ */ new Map();
371923
+ const remoteTemplateNodeIds = new Set(flattenedNodes.filter(({ node }) => node.nodeKind === "remote-template").map(({ node, path: path3 }) => (0, ids_1.stableNodeId)(workflowKey, node, path3)));
371758
371924
  const buildBinding = input.declaration[contracts_1.BUILD_BINDING];
371759
371925
  const inputs = declarationInputs.map((declaration, index) => ({
371760
371926
  id: (0, ids_1.stableInputId)(workflowKey, declaration, index),
@@ -371792,6 +371958,8 @@ var require_transpile = __commonJS({
371792
371958
  inputNamesByKey,
371793
371959
  nodeNamesByKey,
371794
371960
  nodeOutputSchemasByKey,
371961
+ nodeOutputSchemasById,
371962
+ remoteTemplateNodeIds,
371795
371963
  builtInputs: declarationInputs,
371796
371964
  builtNodes: declarationNodes,
371797
371965
  source: input.source,
@@ -371802,8 +371970,10 @@ var require_transpile = __commonJS({
371802
371970
  remoteRefs,
371803
371971
  diagnostics
371804
371972
  });
371805
- if (lowered?.outputSchema !== void 0)
371973
+ if (lowered?.outputSchema !== void 0) {
371806
371974
  nodeOutputSchemasByKey.set(node.key ?? node.name, lowered.outputSchema);
371975
+ nodeOutputSchemasById.set((0, ids_1.stableNodeId)(workflowKey, node, flattened.path), lowered.outputSchema);
371976
+ }
371807
371977
  return lowered ? {
371808
371978
  ...lowered,
371809
371979
  declarationIndex: index,
@@ -373732,6 +373902,7 @@ const __workflowCodeApi = (() => {
373732
373902
  const remote = () => freeze({
373733
373903
  canvas: () => createRemoteRef('canvas'),
373734
373904
  workflow: () => createRemoteRef('workflow'),
373905
+ template: () => createRemoteRef('template'),
373735
373906
  agent: () => createRemoteRef('agent'),
373736
373907
  models: () => createRemoteRef('model'),
373737
373908
  })
@@ -373793,6 +373964,22 @@ const __workflowCodeApi = (() => {
373793
373964
  ...(renderedInputs.refs.length > 0 ? { inputRefs: renderedInputs.refs } : {}),
373794
373965
  })
373795
373966
  }
373967
+ const templateNode = (ref, options) => {
373968
+ assertNonEmptyString(options.name, 'template.name', options.__workflowCodeSource)
373969
+ const renderedVariables = renderReferenceRecord(options.input.variables, options.__workflowCodeSource)
373970
+ return freeze({
373971
+ kind: 'node',
373972
+ nodeKind: 'remote-template',
373973
+ name: options.name,
373974
+ ...(options.key !== undefined ? { key: options.key } : {}),
373975
+ ref: serializeRemoteRef(ref, 'template'),
373976
+ input: freeze({
373977
+ variables: renderedVariables.values,
373978
+ ...(options.input.tags !== undefined ? { tags: freeze([...options.input.tags]) } : {}),
373979
+ }),
373980
+ ...(renderedVariables.refs.length > 0 ? { variableRefs: renderedVariables.refs } : {}),
373981
+ })
373982
+ }
373796
373983
  const buildBindingKey = Symbol.for('@meistrari/workflow-code/build-binding')
373797
373984
  const codeBindingKey = Symbol.for('@meistrari/workflow-code/code-binding')
373798
373985
  const buildWorkflow = (workflow, options) => {
@@ -373936,6 +374123,7 @@ const __workflowCodeApi = (() => {
373936
374123
  llm: (options) => promptNode('llm', options, llmInput),
373937
374124
  map: mapNode,
373938
374125
  splitter: splitterNode,
374126
+ template: templateNode,
373939
374127
  vault: freeze({
373940
374128
  asset: (path, options = {}) => freeze({
373941
374129
  kind: 'vault-asset',
@@ -374565,8 +374753,8 @@ var require_lockfile = __commonJS({
374565
374753
  if (!validateObject(value, path3, ["declarationKey", "kind", "path", "id", "environmentName", "versionId", "revision", "inputHash", "outputContractHash", "contractHash"], diagnostics))
374566
374754
  return;
374567
374755
  validateRequiredString(value, "declarationKey", `${path3}.declarationKey`, diagnostics);
374568
- if (value.kind !== "canvas" && value.kind !== "workflow" && value.kind !== "agent" && value.kind !== "model")
374569
- pushInvalid(diagnostics, `${path3}.kind`, "kind must be canvas, workflow, agent, or model");
374756
+ if (value.kind !== "canvas" && value.kind !== "workflow" && value.kind !== "template" && value.kind !== "agent" && value.kind !== "model")
374757
+ pushInvalid(diagnostics, `${path3}.kind`, "kind must be canvas, workflow, template, agent, or model");
374570
374758
  if (value.path !== void 0)
374571
374759
  validateStringArray(value.path, `${path3}.path`, diagnostics);
374572
374760
  validateRequiredString(value, "id", `${path3}.id`, diagnostics);
@@ -377747,24 +377935,31 @@ var require_sync3 = __commonJS({
377747
377935
  const existing = await (0, state_1.readLockfile)(lockPath.value);
377748
377936
  if (!existing.ok && existing.diagnostics[0]?.code !== "state.lockfile.missing")
377749
377937
  return { ok: false, diagnostics: existing.diagnostics, compiled: item.symbolic };
377750
- const generated = (0, catalog_1.validateAndLockRemoteRefs)({
377938
+ const initialGenerated = (0, catalog_1.validateAndLockRemoteRefs)({
377751
377939
  contextId: snapshot.context.id,
377752
377940
  workspaceId: snapshot.context.workspaceId,
377753
377941
  snapshot,
377754
377942
  refs: item.symbolic.remoteRefs,
377755
377943
  existing: existing.ok ? existing.value.lockfile.generatedMetadata : void 0
377756
377944
  });
377757
- if (generated.diagnostics.some((diagnostic) => diagnostic.severity === "error"))
377758
- return { ok: false, diagnostics: [...generated.diagnostics], compiled: item.symbolic };
377945
+ if (initialGenerated.diagnostics.some((diagnostic) => diagnostic.severity === "error"))
377946
+ return { ok: false, diagnostics: [...initialGenerated.diagnostics], compiled: item.symbolic };
377759
377947
  const compiled = (0, compiler_1.transpileWorkflow)({
377760
377948
  targetName: item.name,
377761
377949
  workflowKey: item.target.workflowKey,
377762
377950
  title: item.target.title,
377763
377951
  declaration: item.source.declaration,
377764
377952
  source: item.source.source,
377765
- remote: { kind: "resolved", snapshot, locks: generated.locks.refs },
377953
+ remote: { kind: "resolved", snapshot, locks: initialGenerated.locks.refs },
377766
377954
  vaultAssets: item.vaultAssets
377767
377955
  });
377956
+ const generated = (0, catalog_1.validateAndLockRemoteRefs)({
377957
+ contextId: snapshot.context.id,
377958
+ workspaceId: snapshot.context.workspaceId,
377959
+ snapshot,
377960
+ refs: compiled.remoteRefs,
377961
+ existing: existing.ok ? existing.value.lockfile.generatedMetadata : void 0
377962
+ });
377768
377963
  const diagnostics = [...generated.diagnostics, ...compiled.diagnostics];
377769
377964
  if (diagnostics.some((diagnostic) => diagnostic.severity === "error"))
377770
377965
  return { ok: false, diagnostics, compiled };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Tela command line tools for local state and agent workflows.",
5
5
  "engines": {
6
6
  "node": ">=22"