@valerypopoff/rivet2-core 2.17.0 → 2.21.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 (120) hide show
  1. package/dist/cjs/bundle.cjs +3197 -1461
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/interpolationRuntime.cjs +40 -4
  4. package/dist/cjs/interpolationRuntime.cjs.map +2 -2
  5. package/dist/cjs/serialization.cjs +1880 -0
  6. package/dist/cjs/serialization.cjs.map +7 -0
  7. package/dist/cjs/webAppRuntime.cjs +168 -6
  8. package/dist/cjs/webAppRuntime.cjs.map +3 -3
  9. package/dist/esm/api/processSettings.js +1 -0
  10. package/dist/esm/exports.js +3 -0
  11. package/dist/esm/model/AgentResponseTrace.js +99 -34
  12. package/dist/esm/model/AgentResponseTracePresentation.js +130 -0
  13. package/dist/esm/model/DataValue.js +11 -2
  14. package/dist/esm/model/GlobalVariables.js +2 -1
  15. package/dist/esm/model/GraphBoundaryEffects.js +38 -1
  16. package/dist/esm/model/GraphExecutionState.js +81 -0
  17. package/dist/esm/model/GraphProcessor.js +625 -943
  18. package/dist/esm/model/GraphSchedulerBoundaryState.js +64 -0
  19. package/dist/esm/model/Nodes.js +5 -0
  20. package/dist/esm/model/ProjectBundle.js +69 -11
  21. package/dist/esm/model/ProjectBundleRuntime.js +54 -0
  22. package/dist/esm/model/ProjectGraphCallSites.js +46 -0
  23. package/dist/esm/model/SchedulerBoundaryPlanner.js +233 -0
  24. package/dist/esm/model/SubprocessorBridge.js +125 -87
  25. package/dist/esm/model/ToolCallContinuationCoordinator.js +1 -1
  26. package/dist/esm/model/chat-v2/aiSdkBridge.js +15 -12
  27. package/dist/esm/model/chat-v2/chatV2CallObserver.js +2 -4
  28. package/dist/esm/model/chat-v2/chatV2CredentialNames.js +5 -1
  29. package/dist/esm/model/chat-v2/chatV2Outputs.js +2 -2
  30. package/dist/esm/model/chat-v2/chatV2Pipeline.js +11 -1
  31. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +3 -2
  32. package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +46 -6
  33. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +7 -0
  34. package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +10 -0
  35. package/dist/esm/model/chat-v2/llmChatV2Body.js +3 -3
  36. package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +5 -2
  37. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +1 -0
  38. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +25 -15
  39. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +10 -2
  40. package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +17 -0
  41. package/dist/esm/model/chat-v2/llmModelCandidate.js +2 -1
  42. package/dist/esm/model/chat-v2/llmProfile.js +2 -1
  43. package/dist/esm/model/chat-v2/llmProfileBody.js +9 -0
  44. package/dist/esm/model/chat-v2/llmProfileFallback.js +7 -4
  45. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +1 -0
  46. package/dist/esm/model/chat-v2/llmProfileHealthStore.js +16 -3
  47. package/dist/esm/model/chat-v2/messageConverter.js +18 -16
  48. package/dist/esm/model/chat-v2/modelRegistry.js +14 -4
  49. package/dist/esm/model/chat-v2/openRouterModel.js +73 -0
  50. package/dist/esm/model/chat-v2/parallelToolCalls.js +2 -0
  51. package/dist/esm/model/chat-v2/providerOptions.js +30 -25
  52. package/dist/esm/model/classifier/credentials.js +13 -3
  53. package/dist/esm/model/classifier/limits.js +33 -3
  54. package/dist/esm/model/classifier/perplexity.js +63 -0
  55. package/dist/esm/model/classifier/profile.js +151 -0
  56. package/dist/esm/model/classifier/profileExecution.js +294 -0
  57. package/dist/esm/model/classifier/providers.js +217 -30
  58. package/dist/esm/model/classifier/state.js +4 -1
  59. package/dist/esm/model/classifier/types.js +11 -1
  60. package/dist/esm/model/nodeRunFailure.js +8 -1
  61. package/dist/esm/model/nodes/CallGraphNode.js +6 -0
  62. package/dist/esm/model/nodes/ClassifierEvaluateNode.js +257 -66
  63. package/dist/esm/model/nodes/ClassifierProfileNode.js +133 -0
  64. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +1 -1
  65. package/dist/esm/model/nodes/LLMChatV2Node.js +2 -1
  66. package/dist/esm/model/nodes/SubGraphNode.js +4 -0
  67. package/dist/esm/model/nodes/toolCallDelegation.js +5 -1
  68. package/dist/esm/model/profileSuspensionHints.js +8 -0
  69. package/dist/esm/serialization.js +2 -0
  70. package/dist/esm/utils/coerceType.js +11 -1
  71. package/dist/esm/webAppRuntime.js +1 -0
  72. package/dist/types/exports.d.ts +3 -0
  73. package/dist/types/model/AgentResponseTrace.d.ts +15 -4
  74. package/dist/types/model/AgentResponseTracePresentation.d.ts +15 -0
  75. package/dist/types/model/DataValue.d.ts +12 -8
  76. package/dist/types/model/ExecutorProtocol.d.ts +14 -2
  77. package/dist/types/model/GraphBoundaryEffects.d.ts +10 -1
  78. package/dist/types/model/GraphExecutionState.d.ts +68 -0
  79. package/dist/types/model/GraphProcessor.d.ts +1 -0
  80. package/dist/types/model/GraphSchedulerBoundaryState.d.ts +96 -0
  81. package/dist/types/model/Nodes.d.ts +7 -4
  82. package/dist/types/model/ProcessContext.d.ts +12 -3
  83. package/dist/types/model/ProjectBundle.d.ts +18 -4
  84. package/dist/types/model/ProjectBundleRuntime.d.ts +24 -0
  85. package/dist/types/model/ProjectGraphCallSites.d.ts +12 -0
  86. package/dist/types/model/RivetUIContext.d.ts +1 -1
  87. package/dist/types/model/SchedulerBoundaryPlanner.d.ts +42 -0
  88. package/dist/types/model/Settings.d.ts +1 -0
  89. package/dist/types/model/SubgraphProjectTarget.d.ts +6 -0
  90. package/dist/types/model/SubprocessorBridge.d.ts +2 -0
  91. package/dist/types/model/chat-v2/chatV2CredentialNames.d.ts +4 -0
  92. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +1 -1
  93. package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +79 -1
  94. package/dist/types/model/chat-v2/chatV2ProviderTypes.d.ts +1 -1
  95. package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +2 -0
  96. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +2 -1
  97. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +2 -0
  98. package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +2 -0
  99. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +51 -3
  100. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +9 -6
  101. package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +6 -2
  102. package/dist/types/model/chat-v2/modelRegistry.d.ts +5 -4
  103. package/dist/types/model/chat-v2/openRouterModel.d.ts +2 -0
  104. package/dist/types/model/chat-v2/providerOptions.d.ts +2 -13
  105. package/dist/types/model/classifier/credentials.d.ts +4 -0
  106. package/dist/types/model/classifier/limits.d.ts +4 -1
  107. package/dist/types/model/classifier/perplexity.d.ts +7 -0
  108. package/dist/types/model/classifier/profile.d.ts +46 -0
  109. package/dist/types/model/classifier/profileExecution.d.ts +32 -0
  110. package/dist/types/model/classifier/providers.d.ts +32 -1
  111. package/dist/types/model/classifier/types.d.ts +9 -0
  112. package/dist/types/model/nodes/ClassifierEvaluateNode.d.ts +14 -12
  113. package/dist/types/model/nodes/ClassifierProfileNode.d.ts +20 -0
  114. package/dist/types/model/nodes/SubGraphNode.d.ts +1 -1
  115. package/dist/types/model/nodes/toolCallDelegation.d.ts +3 -1
  116. package/dist/types/model/profileSuspensionHints.d.ts +8 -0
  117. package/dist/types/recording/ExecutionRecorder.d.ts +5 -1
  118. package/dist/types/serialization.d.ts +2 -0
  119. package/dist/types/webAppRuntime.d.ts +1 -0
  120. package/package.json +7 -1
@@ -107,6 +107,7 @@ var llmProfileFieldSpecs = [
107
107
  { key: "extraProviderOptions", inputId: "extraProviderOptions", valueKind: "string" },
108
108
  { key: "useExtraProviderOptionsInput", valueKind: "boolean", resolvedInputToggle: true },
109
109
  { key: "openAIReasoningEffort", valueKind: "string" },
110
+ { key: "openRouterReasoningEffort", valueKind: "string" },
110
111
  { key: "openAIReasoningSummary", valueKind: "string" },
111
112
  { key: "openAIPreviousResponseId", inputId: "previousResponseId", valueKind: "string" },
112
113
  { key: "useOpenAIPreviousResponseIdInput", valueKind: "boolean", resolvedInputToggle: true },
@@ -158,6 +159,7 @@ function sha256(value) {
158
159
  function createRivetLLMProfileHealthIdentity(params) {
159
160
  var _a;
160
161
  const profileName = (_a = params.profileName) == null ? void 0 : _a.trim();
162
+ const openRouterRouting = params.configuration.provider === "openrouter" && params.configuration.extraProviderOptions ? pickOpenRouterRouting(JSON.parse(params.configuration.extraProviderOptions)) : {};
161
163
  const routingConfiguration = {
162
164
  provider: params.configuration.provider,
163
165
  model: params.configuration.model,
@@ -165,7 +167,8 @@ function createRivetLLMProfileHealthIdentity(params) {
165
167
  customProviderApi: params.configuration.customProviderApi ?? "completions",
166
168
  customProviderBaseURL: params.configuration.customProviderBaseURL
167
169
  },
168
- headers: canonicalizeEffectiveRoutingHeaders(params.chatNodeHeaders, params.configuration.headers)
170
+ headers: canonicalizeEffectiveRoutingHeaders(params.chatNodeHeaders, params.configuration.headers),
171
+ ...Object.keys(openRouterRouting).length > 0 ? { openRouterRouting } : {}
169
172
  };
170
173
  const serialized = (0, import_safe_stable_stringify.default)({
171
174
  routingConfiguration,
@@ -193,6 +196,11 @@ function createRivetLLMProfileHealthIdentity(params) {
193
196
  configurationFingerprint
194
197
  };
195
198
  }
199
+ function pickOpenRouterRouting(options) {
200
+ return Object.fromEntries(
201
+ ["model", "provider", "models", "route"].filter((key) => options[key] !== void 0).map((key) => [key, options[key]])
202
+ );
203
+ }
196
204
  function canonicalizeEffectiveRoutingHeaders(chatNodeHeaders, profileHeaders) {
197
205
  const headers = /* @__PURE__ */ new Map();
198
206
  for (const [key, value] of Object.entries(chatNodeHeaders ?? {})) {
@@ -228,6 +236,7 @@ function createLLMChatV2NodeData() {
228
236
  extraProviderOptions: "",
229
237
  useExtraProviderOptionsInput: false,
230
238
  openAIReasoningEffort: "",
239
+ openRouterReasoningEffort: "",
231
240
  openAIReasoningSummary: "",
232
241
  openAIPreviousResponseId: "",
233
242
  useOpenAIPreviousResponseIdInput: false,
@@ -370,6 +379,10 @@ var dataTypes = exhaustiveTuple()(
370
379
  "llm-config[]",
371
380
  "fn<llm-config>",
372
381
  "fn<llm-config[]>",
382
+ "classifier-config",
383
+ "classifier-config[]",
384
+ "fn<classifier-config>",
385
+ "fn<classifier-config[]>",
373
386
  "document",
374
387
  "document[]",
375
388
  "fn<document>",
@@ -396,6 +409,7 @@ var scalarTypes = exhaustiveTuple()(
396
409
  "knowledge-document",
397
410
  "knowledge-evidence",
398
411
  "llm-config",
412
+ "classifier-config",
399
413
  "document"
400
414
  );
401
415
  function isScalarDataValue(value) {
@@ -496,6 +510,11 @@ var scalarDefaults = {
496
510
  documentId: ""
497
511
  },
498
512
  "llm-config": createDefaultLLMProfileValue(),
513
+ "classifier-config": {
514
+ version: 1,
515
+ configuration: { provider: "jev", model: "jev-latest" },
516
+ credential: {}
517
+ },
499
518
  document: {
500
519
  mediaType: "text/plain",
501
520
  data: new Uint8Array(),
@@ -706,6 +725,10 @@ var CHAT_V2_DEFAULT_CREDENTIAL_NAMES = {
706
725
  google: {
707
726
  programmaticName: "googleApiKey",
708
727
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY"
728
+ },
729
+ openrouter: {
730
+ programmaticName: "openRouterApiKey",
731
+ environmentVariableName: "OPENROUTER_API_KEY"
709
732
  }
710
733
  };
711
734
  var programmaticNamePattern = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
@@ -756,7 +779,7 @@ function normalizeChatV2CredentialNamesByProvider(value) {
756
779
  throw new Error(`Unsupported provider API key names entry: ${unsupportedProvider}.`);
757
780
  }
758
781
  const normalized = {};
759
- for (const provider of ["openai", "anthropic", "google"]) {
782
+ for (const provider of ["openai", "anthropic", "google", "openrouter"]) {
760
783
  if (raw[provider] != null) {
761
784
  normalized[provider] = normalizeChatV2CredentialNames(provider, raw[provider]);
762
785
  }
@@ -782,7 +805,7 @@ var credentialSources = /* @__PURE__ */ new Set([
782
805
  "environment",
783
806
  "none"
784
807
  ]);
785
- var profileProviders = /* @__PURE__ */ new Set(["openai", "anthropic", "google", "custom"]);
808
+ var profileProviders = /* @__PURE__ */ new Set(["openai", "anthropic", "google", "openrouter", "custom"]);
786
809
  function normalizeLLMProfileValue(value) {
787
810
  if (!isRecord2(value)) {
788
811
  throw new Error("LLM Profile input must contain an LLM profile value.");
@@ -858,6 +881,11 @@ function normalizeConfiguration(data) {
858
881
  throw new Error(`Unsupported LLM Profile API key source: ${String(data.apiKeySource)}.`);
859
882
  }
860
883
  assertEnumValue(data.openAIWebSearchContextSize, ["low", "medium", "high"], "OpenAI web search context");
884
+ assertEnumValue(
885
+ data.openRouterReasoningEffort ?? "",
886
+ ["", "none", "minimal", "low", "medium", "high", "xhigh"],
887
+ "OpenRouter reasoning effort"
888
+ );
861
889
  const customProviderApi = parseCustomProviderApi(data.customProviderApi);
862
890
  assertEnumValue(data.anthropicThinkingMode, ["", "adaptive", "enabled", "disabled"], "Anthropic thinking mode");
863
891
  assertEnumValue(data.anthropicEffort, ["", "low", "medium", "high", "max"], "Anthropic effort");
@@ -932,7 +960,7 @@ function isRecord2(value) {
932
960
 
933
961
  // src/utils/coerceType.ts
934
962
  function isValidatedObjectValueType(type) {
935
- return type === "knowledge-source" || type === "knowledge-document" || type === "knowledge-evidence" || type === "llm-config";
963
+ return type === "knowledge-source" || type === "knowledge-document" || type === "knowledge-evidence" || type === "llm-config" || type === "classifier-config";
936
964
  }
937
965
  function canAttemptGeneralCoercion(from, to) {
938
966
  return !isValidatedObjectValueType(from) || to === "object" || to === "string";
@@ -986,6 +1014,11 @@ var scalarCoercionRules = {
986
1014
  "llm-config",
987
1015
  (value) => coerceValidatedObjectValue(value, normalizeLLMProfileValue)
988
1016
  ),
1017
+ // Provider-specific validation belongs to Evaluate's bounded snapshot boundary.
1018
+ "classifier-config": sameTypeOrObjectScalarRule(
1019
+ "classifier-config",
1020
+ (value) => (value == null ? void 0 : value.value) != null && typeof value.value === "object" && !Array.isArray(value.value) ? value.value : void 0
1021
+ ),
989
1022
  document: generalScalarRule("document")
990
1023
  };
991
1024
  function coerceTypeOptional(wrapped, type) {
@@ -993,6 +1026,9 @@ function coerceTypeOptional(wrapped, type) {
993
1026
  return expectTypeOptional(wrapped, type);
994
1027
  }
995
1028
  const value = wrapped ? unwrapDataValue(wrapped) : void 0;
1029
+ if (type === "classifier-config" && (value == null ? void 0 : value.type) === "llm-config" || type === "llm-config" && (value == null ? void 0 : value.type) === "classifier-config") {
1030
+ return void 0;
1031
+ }
996
1032
  if (isArrayDataType(type) && !isArrayDataValue(value)) {
997
1033
  const coerced = coerceTypeOptional(value, getScalarTypeOf(type));
998
1034
  if (coerced === void 0) {