@valerypopoff/rivet2-core 2.19.0 → 2.22.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.
@@ -585,6 +585,7 @@ __export(src_exports, {
585
585
  liquidClassifierProvider: () => liquidClassifierProvider,
586
586
  listGraphsNode: () => listGraphsNode,
587
587
  listProjectBundleCalls: () => listProjectBundleCalls,
588
+ listProjectGraphCallSites: () => listProjectGraphCallSites,
588
589
  llmChatV2Node: () => llmChatV2Node,
589
590
  llmChatV2ProfileDataKeys: () => llmChatV2ProfileDataKeys,
590
591
  llmProfileInputIds: () => llmProfileInputIds,
@@ -1365,6 +1366,7 @@ __export(exports_exports, {
1365
1366
  liquidClassifierProvider: () => liquidClassifierProvider,
1366
1367
  listGraphsNode: () => listGraphsNode,
1367
1368
  listProjectBundleCalls: () => listProjectBundleCalls,
1369
+ listProjectGraphCallSites: () => listProjectGraphCallSites,
1368
1370
  llmChatV2Node: () => llmChatV2Node,
1369
1371
  llmChatV2ProfileDataKeys: () => llmChatV2ProfileDataKeys,
1370
1372
  llmProfileInputIds: () => llmProfileInputIds,
@@ -11985,6 +11987,7 @@ var SubGraphNodeImpl = class extends NodeImpl {
11985
11987
  if (childRecorder && recordingTarget && this.data.targetProjectId) {
11986
11988
  try {
11987
11989
  await ((_b = context.onSubgraphProjectRun) == null ? void 0 : _b.call(context, {
11990
+ createdAt: new Date(startedAt).toISOString(),
11988
11991
  target: { projectId: this.data.targetProjectId, version: this.data.targetVersion ?? "latest" },
11989
11992
  resolved: recordingTarget,
11990
11993
  graphId: this.data.graphId,
@@ -14769,7 +14772,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
14769
14772
  const visited = /* @__PURE__ */ new WeakMap();
14770
14773
  const active = /* @__PURE__ */ new WeakMap();
14771
14774
  const visit = async (owner, graphId2, depth, enteredFromOtherProject = false) => {
14772
- var _a;
14775
+ var _a, _b, _c;
14773
14776
  if (depth > 64) throw new Error("Subgraph project dependency depth exceeds 64. Check for a project cycle.");
14774
14777
  const graph = owner.graphs[graphId2];
14775
14778
  if (!graph) throw new Error(`Subgraph target graph ${graphId2} is missing from project ${owner.metadata.id}.`);
@@ -14792,17 +14795,19 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
14792
14795
  const candidate = resolveNodePrefabInstance(owner, authored);
14793
14796
  if (candidate.type !== "subGraph" || candidate.disabled) continue;
14794
14797
  const node = candidate;
14795
- if (node.data.targetScope === "other-projects" && !node.data.targetProjectId) {
14798
+ if (node.data.targetScope && !node.data.targetProjectId) {
14796
14799
  throw new Error("Select a project and graph for this Subgraph before running it.");
14797
14800
  }
14798
14801
  let childOwner = owner;
14799
14802
  if (node.data.targetProjectId) {
14800
14803
  const target = {
14801
14804
  projectId: node.data.targetProjectId,
14802
- version: node.data.targetVersion ?? "latest"
14805
+ version: node.data.targetVersion ?? "latest",
14806
+ callerProjectId: owner.metadata.id
14803
14807
  };
14804
14808
  const key = getSubgraphProjectKey(target);
14805
14809
  let resolved = this.#shared.subgraphTargetCache.get(key);
14810
+ if (resolved) await ((_c = (_b = this.#run.context.subgraphProjectLoader) == null ? void 0 : _b.validateTarget) == null ? void 0 : _c.call(_b, target));
14806
14811
  if (!resolved) {
14807
14812
  if (!this.#run.context.subgraphProjectLoader) {
14808
14813
  throw new Error(
@@ -25096,31 +25101,31 @@ function getOutputEditors() {
25096
25101
  return group("Outputs", [
25097
25102
  {
25098
25103
  type: "toggle",
25099
- label: "Output reasoning",
25104
+ label: "Reasoning",
25100
25105
  dataKey: "outputReasoning",
25101
25106
  helperMessage: "Adds a Reasoning output when the provider/model exposes reasoning or thinking text through the Vercel AI SDK. Some providers only expose token counts or summaries."
25102
25107
  },
25103
25108
  {
25104
25109
  type: "toggle",
25105
- label: "Output usage details",
25110
+ label: "Usage details",
25106
25111
  dataKey: "outputUsage",
25107
25112
  helperMessage: "Adds a Usage output built from Vercel AI SDK usage metadata: prompt, completion, total, cached, reasoning tokens, and estimated cost when available."
25108
25113
  },
25109
25114
  {
25110
25115
  type: "toggle",
25111
- label: "Output LLM attempts",
25116
+ label: "LLM attempts",
25112
25117
  dataKey: "outputLLMAttempts",
25113
25118
  helperMessage: "Adds one chronological record for every profile configuration, provider request, and response-validation attempt. Records include provider, model, retry status, and provider error details when available."
25114
25119
  },
25115
25120
  {
25116
25121
  type: "toggle",
25117
- label: "Output request body",
25122
+ label: "Request body",
25118
25123
  dataKey: "outputRequestBody",
25119
25124
  helperMessage: "Adds an LLM request body output. It can contain prompts and non-secret provider options; it never includes authorization headers or API keys."
25120
25125
  },
25121
25126
  {
25122
25127
  type: "toggle",
25123
- label: "Output response body",
25128
+ label: "Response body",
25124
25129
  dataKey: "outputResponseBody",
25125
25130
  helperMessage: "Adds the complete LLM response body captured at the provider HTTP boundary. JSON responses are parsed for inspection; other responses remain text. Rivet does not redact or truncate captured content."
25126
25131
  },
@@ -25158,14 +25163,14 @@ function getErrorBehaviorEditors() {
25158
25163
  return group("Error behavior", [
25159
25164
  {
25160
25165
  type: "toggle",
25161
- label: "Fail on non-2XX status code",
25166
+ label: "Throw exception on non-2XX status code",
25162
25167
  dataKey: "errorOnNon200",
25163
25168
  defaultValue: true,
25164
25169
  helperMessage: "After retries and profile fallback, throw on a rejected HTTP request. When disabled, return Run failed and Run error; unavailable response outputs are excluded."
25165
25170
  },
25166
25171
  {
25167
25172
  type: "toggle",
25168
- label: "Catch all failures",
25173
+ label: "Catch all exceptions",
25169
25174
  dataKey: "catchRequestFailed",
25170
25175
  helperMessage: "Return any node execution failure through Run failed and Run error instead of stopping the graph. Explicit graph cancellation is never caught."
25171
25176
  },
@@ -25400,7 +25405,7 @@ function getErrorBodyFields(data) {
25400
25405
  const cooldownMs = data.retryOnNon200CooldownMs ?? DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS;
25401
25406
  return [
25402
25407
  ...data.errorOnNon200 !== false ? [{ label: "Throw on non-2XX", value: "Enabled" }] : [],
25403
- ...data.catchRequestFailed ? [{ label: "Catch all failures", value: "Enabled" }] : [],
25408
+ ...data.catchRequestFailed ? [{ label: "Catch all exceptions", value: "Enabled" }] : [],
25404
25409
  ...data.retryOnNon200 ? [
25405
25410
  { label: "Retry on non-200", value: "Enabled" },
25406
25411
  { label: "Repeat times", value: `${repeatTimes}` },
@@ -46701,26 +46706,26 @@ var ClassifierEvaluateNodeImpl = class extends NodeImpl {
46701
46706
  editors: [
46702
46707
  {
46703
46708
  type: "toggle",
46704
- label: "Output usage details",
46709
+ label: "Usage details",
46705
46710
  dataKey: "outputUsage",
46706
46711
  helperMessage: "Adds estimated totalCost to Usage only for recognized requested/returned models. Unknown pricing is omitted. Provider-specific premiums are not included."
46707
46712
  },
46708
46713
  {
46709
46714
  type: "toggle",
46710
- label: "Output request body",
46715
+ label: "Request body",
46711
46716
  dataKey: "outputRequestBody",
46712
46717
  helperMessage: "Adds the exact classifier request JSON body sent to the provider. It excludes authorization headers and Rivet-managed API keys."
46713
46718
  },
46714
46719
  {
46715
46720
  type: "toggle",
46716
- label: "Output response body",
46721
+ label: "Response body",
46717
46722
  dataKey: "outputResponseBody",
46718
46723
  helperMessage: "Shows the provider response, including rejected or invalid responses. Non-JSON responses appear as raw text. Captured content may contain sensitive input."
46719
46724
  },
46720
- { type: "toggle", label: "Output classifier attempts", dataKey: "outputClassifierAttempts" },
46725
+ { type: "toggle", label: "Classifier attempts", dataKey: "outputClassifierAttempts" },
46721
46726
  {
46722
46727
  type: "toggle",
46723
- label: "Output classifier profile summary",
46728
+ label: "Classifier profile summary",
46724
46729
  dataKey: "outputClassifierProfileSummary",
46725
46730
  hideIf: (data) => data.configurationMode !== "profile"
46726
46731
  }
@@ -46748,14 +46753,14 @@ var ClassifierEvaluateNodeImpl = class extends NodeImpl {
46748
46753
  editors: [
46749
46754
  {
46750
46755
  type: "toggle",
46751
- label: "Fail on non-2XX status code",
46756
+ label: "Throw exception on non-2XX status code",
46752
46757
  dataKey: "errorOnNon200",
46753
46758
  defaultValue: true,
46754
- helperMessage: "After retries, throw on a rejected HTTP request. When disabled, unavailable outputs are excluded. Run failed and Run error are available only when Catch all failures is enabled."
46759
+ helperMessage: "After retries, throw on a rejected HTTP request. When disabled, unavailable outputs are excluded. Run failed and Run error are available only when Catch all exceptions is enabled."
46755
46760
  },
46756
46761
  {
46757
46762
  type: "toggle",
46758
- label: "Catch all failures",
46763
+ label: "Catch all exceptions",
46759
46764
  dataKey: "catchRequestFailed",
46760
46765
  helperMessage: "Return any node execution failure through Run failed and Run error instead of stopping the graph. Explicit graph cancellation is never caught."
46761
46766
  },
@@ -47100,7 +47105,7 @@ function getClassifierEvaluateBodySections(data) {
47100
47105
  id: "error-behavior",
47101
47106
  fields: [
47102
47107
  ...data.errorOnNon200 !== false ? [{ label: "Throw on non-2XX", value: "Enabled" }] : [],
47103
- ...data.catchRequestFailed ? [{ label: "Catch all failures", value: "Enabled" }] : [],
47108
+ ...data.catchRequestFailed ? [{ label: "Catch all exceptions", value: "Enabled" }] : [],
47104
47109
  ...data.retryOnNon200 ? [
47105
47110
  { label: "Retry on non-200", value: "Enabled" },
47106
47111
  { label: "Repeat times", value: `${normalizeClassifierNon200RetryCount(data.retryOnNon200RepeatTimes)}` },
@@ -47509,6 +47514,45 @@ function getDebuggerTransportSentinel(value) {
47509
47514
  return void 0;
47510
47515
  }
47511
47516
 
47517
+ // src/model/ProjectGraphCallSites.ts
47518
+ function listProjectGraphCallSites(project) {
47519
+ var _a;
47520
+ const calls = [];
47521
+ for (const [sourceGraphId, graph] of Object.entries(project.graphs)) {
47522
+ for (const authored of graph.nodes) {
47523
+ const node = resolveNodePrefabInstance(project, authored);
47524
+ if (node.disabled) continue;
47525
+ if (node.type === "nodePrefabInstance") continue;
47526
+ let targetProjectId;
47527
+ let targetGraphId;
47528
+ let targetVersion;
47529
+ if (node.type === "subGraph") {
47530
+ const data = node.data;
47531
+ targetProjectId = data.targetProjectId;
47532
+ targetGraphId = data.graphId;
47533
+ targetVersion = data.targetVersion ?? "latest";
47534
+ if (targetVersion !== "latest" && targetVersion !== "published") throw new Error("Invalid Subgraph version.");
47535
+ } else if (node.type === "referencedGraphAlias") {
47536
+ const data = node.data;
47537
+ targetProjectId = data.projectId;
47538
+ targetGraphId = data.graphId;
47539
+ targetVersion = "project-reference";
47540
+ } else continue;
47541
+ if (!targetProjectId || !targetGraphId) continue;
47542
+ calls.push({
47543
+ sourceGraphId,
47544
+ sourceGraphName: ((_a = graph.metadata) == null ? void 0 : _a.name) ?? sourceGraphId,
47545
+ nodeId: authored.id,
47546
+ nodeTitle: node.title || (node.type === "subGraph" ? "Subgraph" : "Referenced Graph Alias"),
47547
+ targetProjectId,
47548
+ targetGraphId,
47549
+ targetVersion
47550
+ });
47551
+ }
47552
+ }
47553
+ return calls;
47554
+ }
47555
+
47512
47556
  // src/model/ProjectBundle.ts
47513
47557
  var ProjectBundleError = class extends Error {
47514
47558
  constructor(message2, options2) {
@@ -47540,7 +47584,7 @@ function* projectSubgraphs(project) {
47540
47584
  if (data.targetProjectId) {
47541
47585
  if (data.targetVersion !== void 0 && data.targetVersion !== "latest" && data.targetVersion !== "published")
47542
47586
  throw new ProjectBundleError("Invalid Subgraph project version.");
47543
- } else if (data.targetScope === "other-projects") {
47587
+ } else if (data.targetScope) {
47544
47588
  throw new ProjectBundleError(`Subgraph ${node.title || node.id} has no selected project.`);
47545
47589
  }
47546
47590
  yield { sourceGraphId, data };
@@ -47572,6 +47616,7 @@ function validateProjectBundleProjects(manifest, projects) {
47572
47616
  const targets = new Map(manifest.targets.map((t) => [projectBundleTargetKey(t.projectId, t.version), t.artifact]));
47573
47617
  const references = new Map(manifest.references.map((r) => [r.projectId, r.artifact]));
47574
47618
  const plugins2 = new Map(manifest.plugins.map((plugin) => [plugin.id, plugin]));
47619
+ const members = manifest.workspace ? new Set(manifest.workspace.members.map((m) => m.projectId)) : void 0;
47575
47620
  const vertices = /* @__PURE__ */ new Map();
47576
47621
  const graphKey = (artifact, graph) => JSON.stringify([artifact, graph]);
47577
47622
  for (const artifact of manifest.artifacts) {
@@ -47590,6 +47635,10 @@ function validateProjectBundleProjects(manifest, projects) {
47590
47635
  for (const { sourceGraphId, data } of projectSubgraphs(project)) {
47591
47636
  let targetId = artifact.id;
47592
47637
  if (data.targetProjectId) {
47638
+ if ((members == null ? void 0 : members.has(data.targetProjectId)) && !members.has(project.metadata.id))
47639
+ throw new ProjectBundleError(
47640
+ "A project outside this bundle cannot reference a bundle member through a Subgraph node."
47641
+ );
47593
47642
  const call = {
47594
47643
  projectId: data.targetProjectId,
47595
47644
  version: data.targetVersion ?? "latest",
@@ -47630,8 +47679,8 @@ function validateProjectBundleProjects(manifest, projects) {
47630
47679
  [...vertices.values()],
47631
47680
  (v) => v.edges.map((e) => e.target)
47632
47681
  )) {
47633
- const members = new Set(component);
47634
- if (component.some((v) => v.edges.some((e) => e.crossProject && members.has(e.target))))
47682
+ const members2 = new Set(component);
47683
+ if (component.some((v) => v.edges.some((e) => e.crossProject && members2.has(e.target))))
47635
47684
  throw new ProjectBundleError("Subgraph cross-project dependency cycle in bundle.");
47636
47685
  }
47637
47686
  }
@@ -47652,11 +47701,11 @@ function validateProjectBundleManifest(value) {
47652
47701
  return { path };
47653
47702
  };
47654
47703
  const obj = object(value);
47655
- if (obj.format !== "rivet-project-bundle" || obj.schemaVersion !== 1 || obj.requiredLoaderVersion !== 1 && obj.requiredLoaderVersion !== 2 && obj.requiredLoaderVersion !== 3)
47704
+ if (obj.format !== "rivet-project-bundle" || obj.schemaVersion !== 1 || ![1, 2, 3, 4].includes(obj.requiredLoaderVersion))
47656
47705
  fail("unsupported format or loader version; update @valerypopoff/rivet2-node");
47657
47706
  const versionPolicy = obj.versionPolicy === void 0 ? void 0 : version(obj.versionPolicy);
47658
- if (versionPolicy && obj.requiredLoaderVersion !== 3) fail("version selection requires loader version 3");
47659
- if (obj.requiredLoaderVersion === 3 && !versionPolicy) fail("loader version 3 requires a version selection");
47707
+ if (versionPolicy && Number(obj.requiredLoaderVersion) < 3) fail("version selection requires loader version 3");
47708
+ if (Number(obj.requiredLoaderVersion) >= 3 && !versionPolicy) fail("loader version 3 requires a version selection");
47660
47709
  const artifacts = array(obj.artifacts).map((v) => {
47661
47710
  const a = object(v);
47662
47711
  return {
@@ -47679,6 +47728,38 @@ function validateProjectBundleManifest(value) {
47679
47728
  fail("latest version policy contains a published artifact");
47680
47729
  const rootArtifact = string(obj.rootArtifact);
47681
47730
  if (!byId.has(rootArtifact)) fail("missing root artifact");
47731
+ let workspace;
47732
+ if (obj.workspace !== void 0) {
47733
+ if (obj.requiredLoaderVersion !== 4) fail("workspace membership requires loader version 4");
47734
+ const w = object(obj.workspace);
47735
+ const safePath = (value2) => {
47736
+ const path = string(value2);
47737
+ if (/[\\:\0<>"|?*\x01-\x1f]/.test(path) || path.split("/").some((p) => !p || p === "." || p === ".." || /[. ]$/.test(p)))
47738
+ fail("unsafe workspace path");
47739
+ return path;
47740
+ };
47741
+ const folders = array(w.folders, 511).map(safePath);
47742
+ const memberIds = /* @__PURE__ */ new Set(), locations = /* @__PURE__ */ new Set();
47743
+ for (const folder of folders) {
47744
+ if (locations.has(folder.toLowerCase())) fail("duplicate workspace folder");
47745
+ locations.add(folder.toLowerCase());
47746
+ if (folder.includes("/") && !folders.includes(folder.slice(0, folder.lastIndexOf("/"))))
47747
+ fail("missing workspace parent folder");
47748
+ }
47749
+ const members = array(w.members).map((value2) => {
47750
+ const m = object(value2), projectId = string(m.projectId), relativePath = safePath(m.relativePath);
47751
+ if (!relativePath.endsWith(".rivet-project") || memberIds.has(projectId) || locations.has(relativePath.toLowerCase()) || !artifacts.some((a) => a.projectId === projectId))
47752
+ fail("invalid workspace member");
47753
+ const parent = relativePath.includes("/") ? relativePath.slice(0, relativePath.lastIndexOf("/")) : "";
47754
+ if (parent && !folders.includes(parent)) fail("missing workspace member folder");
47755
+ memberIds.add(projectId);
47756
+ locations.add(relativePath.toLowerCase());
47757
+ return { projectId, relativePath };
47758
+ });
47759
+ if (!members.length || !memberIds.has(byId.get(rootArtifact).projectId)) fail("workspace has no initial member");
47760
+ workspace = { name: string(w.name), folders, members };
47761
+ }
47762
+ if (obj.requiredLoaderVersion === 4 && !workspace) fail("loader version 4 requires workspace membership");
47682
47763
  const targetKeys = /* @__PURE__ */ new Set(), referenceIds = /* @__PURE__ */ new Set();
47683
47764
  const targets = array(obj.targets, PROJECT_BUNDLE_MAX_ARTIFACTS * 2).map((v) => {
47684
47765
  const t = object(v), projectId = string(t.projectId), selectedVersion = version(t.version), artifact = string(t.artifact);
@@ -47713,6 +47794,7 @@ function validateProjectBundleManifest(value) {
47713
47794
  format: "rivet-project-bundle",
47714
47795
  schemaVersion: 1,
47715
47796
  requiredLoaderVersion: obj.requiredLoaderVersion,
47797
+ ...workspace ? { workspace } : {},
47716
47798
  ...versionPolicy ? { versionPolicy } : {},
47717
47799
  exportingRuntimeVersion: string(obj.exportingRuntimeVersion),
47718
47800
  rootArtifact,
@@ -55575,6 +55657,7 @@ var Rivet = void 0;
55575
55657
  liquidClassifierProvider,
55576
55658
  listGraphsNode,
55577
55659
  listProjectBundleCalls,
55660
+ listProjectGraphCallSites,
55578
55661
  llmChatV2Node,
55579
55662
  llmChatV2ProfileDataKeys,
55580
55663
  llmProfileInputIds,