@valerypopoff/rivet2-core 2.1.10 → 2.4.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 (111) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/bundle.cjs +2604 -949
  3. package/dist/cjs/bundle.cjs.map +4 -4
  4. package/dist/cjs/webAppRuntime.cjs +1549 -99
  5. package/dist/cjs/webAppRuntime.cjs.map +4 -4
  6. package/dist/esm/api/createProcessor.js +4 -0
  7. package/dist/esm/exports.js +2 -0
  8. package/dist/esm/integrations/CodeRunner.js +2 -7
  9. package/dist/esm/integrations/CodeRunnerOptions.js +7 -0
  10. package/dist/esm/model/AgentResponseTrace.js +137 -11
  11. package/dist/esm/model/GraphProcessor.js +28 -0
  12. package/dist/esm/model/NodeExclusionPolicy.js +9 -1
  13. package/dist/esm/model/ProcessContextBuilder.js +2 -1
  14. package/dist/esm/model/RecordingPlayer.js +58 -5
  15. package/dist/esm/model/SubprocessorBridge.js +2 -0
  16. package/dist/esm/model/UiGraphActionProtocol.js +47 -4
  17. package/dist/esm/model/UiGraphBrowserRuntime.js +15 -1
  18. package/dist/esm/model/UiGraphIndexedDbPersistence.js +523 -0
  19. package/dist/esm/model/UiGraphRendererStyles.js +14 -0
  20. package/dist/esm/model/WebAppBrowserStorage.js +653 -0
  21. package/dist/esm/model/WebAppBrowserStorageRpc.js +200 -0
  22. package/dist/esm/model/chat-v2/aiSdkBridge.js +146 -14
  23. package/dist/esm/model/chat-v2/chatV2CallObserver.js +3 -0
  24. package/dist/esm/model/chat-v2/chatV2CredentialNames.js +93 -0
  25. package/dist/esm/model/chat-v2/chatV2EditorCache.js +8 -38
  26. package/dist/esm/model/chat-v2/chatV2Pipeline.js +41 -4
  27. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +31 -2
  28. package/dist/esm/model/chat-v2/chatV2ResponseBodyCapture.js +10 -2
  29. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +6 -11
  30. package/dist/esm/model/chat-v2/chatV2Shared.js +1 -1
  31. package/dist/esm/model/chat-v2/chatV2Types.js +16 -0
  32. package/dist/esm/model/chat-v2/customProviderApi.js +0 -2
  33. package/dist/esm/model/chat-v2/index.js +3 -0
  34. package/dist/esm/model/chat-v2/llmChatV2Body.js +9 -1
  35. package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +5 -0
  36. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +7 -0
  37. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +95 -14
  38. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +33 -9
  39. package/dist/esm/model/chat-v2/llmChatV2OutputClone.js +42 -0
  40. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +31 -2
  41. package/dist/esm/model/chat-v2/llmModelCandidate.js +5 -1
  42. package/dist/esm/model/chat-v2/llmProfile.js +58 -0
  43. package/dist/esm/model/chat-v2/llmProfileBody.js +10 -0
  44. package/dist/esm/model/chat-v2/llmProfileFallback.js +406 -8
  45. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +7 -0
  46. package/dist/esm/model/chat-v2/llmProfileHealthStore.js +328 -0
  47. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +57 -34
  48. package/dist/esm/model/chat-v2/providerOptions.js +33 -7
  49. package/dist/esm/model/chat-v2/toolContinuation.js +27 -1
  50. package/dist/esm/model/nodes/CodeNewNode.js +5 -47
  51. package/dist/esm/model/nodes/CodeNode.js +4 -46
  52. package/dist/esm/model/nodes/ExpressionNode.js +5 -8
  53. package/dist/esm/model/nodes/LLMChatV2Node.js +31 -3
  54. package/dist/esm/model/nodes/MatchNode.js +86 -41
  55. package/dist/esm/plugins/gentrace/gentraceSdk.js +0 -1
  56. package/dist/esm/plugins/gentrace/index.js +0 -1
  57. package/dist/esm/plugins/gentrace/plugin.js +61 -179
  58. package/dist/esm/plugins.js +1 -2
  59. package/dist/esm/recording/ExecutionRecorder.js +50 -8
  60. package/dist/esm/webAppRuntime.js +5 -2
  61. package/dist/types/api/createProcessor.d.ts +5 -0
  62. package/dist/types/exports.d.ts +2 -0
  63. package/dist/types/integrations/CodeRunner.d.ts +10 -7
  64. package/dist/types/integrations/CodeRunnerOptions.d.ts +15 -0
  65. package/dist/types/model/AgentResponseTrace.d.ts +15 -1
  66. package/dist/types/model/EditorDefinition.d.ts +16 -0
  67. package/dist/types/model/ExecutorProtocol.d.ts +17 -6
  68. package/dist/types/model/GraphProcessor.d.ts +17 -5
  69. package/dist/types/model/NodeBase.d.ts +0 -10
  70. package/dist/types/model/NodeExclusionPolicy.d.ts +6 -0
  71. package/dist/types/model/Nodes.d.ts +2 -2
  72. package/dist/types/model/ProcessContext.d.ts +85 -0
  73. package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
  74. package/dist/types/model/UiGraphActionProtocol.d.ts +9 -3
  75. package/dist/types/model/UiGraphBrowserRuntime.d.ts +6 -0
  76. package/dist/types/model/UiGraphIndexedDbPersistence.d.ts +50 -0
  77. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  78. package/dist/types/model/WebAppBrowserStorage.d.ts +90 -0
  79. package/dist/types/model/WebAppBrowserStorageRpc.d.ts +85 -0
  80. package/dist/types/model/chat-v2/chatV2CredentialNames.d.ts +30 -0
  81. package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +1 -0
  82. package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +3 -0
  83. package/dist/types/model/chat-v2/chatV2ResponseBodyCapture.d.ts +8 -2
  84. package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +3 -8
  85. package/dist/types/model/chat-v2/chatV2Types.d.ts +27 -1
  86. package/dist/types/model/chat-v2/customProviderApi.d.ts +0 -1
  87. package/dist/types/model/chat-v2/index.d.ts +3 -0
  88. package/dist/types/model/chat-v2/llmChatV2CachePolicy.d.ts +1 -1
  89. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +10 -1
  90. package/dist/types/model/chat-v2/llmChatV2OutputClone.d.ts +3 -0
  91. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +5 -1
  92. package/dist/types/model/chat-v2/llmModelCandidate.d.ts +2 -0
  93. package/dist/types/model/chat-v2/llmProfile.d.ts +14 -0
  94. package/dist/types/model/chat-v2/llmProfileBody.d.ts +1 -1
  95. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +25 -2
  96. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +26 -6
  97. package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +121 -0
  98. package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +1 -1
  99. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +9 -0
  100. package/dist/types/model/chat-v2/providerOptions.d.ts +2 -0
  101. package/dist/types/model/chat-v2/toolContinuation.d.ts +14 -0
  102. package/dist/types/model/nodes/CodeNewNode.d.ts +0 -5
  103. package/dist/types/model/nodes/CodeNode.d.ts +0 -5
  104. package/dist/types/model/nodes/MatchNode.d.ts +6 -0
  105. package/dist/types/plugins/gentrace/gentraceSdk.d.ts +0 -1
  106. package/dist/types/plugins/gentrace/plugin.d.ts +55 -9
  107. package/dist/types/plugins.d.ts +1 -1
  108. package/dist/types/recording/ExecutionRecorder.d.ts +7 -1
  109. package/dist/types/recording/RecordedEvents.d.ts +11 -0
  110. package/dist/types/webAppRuntime.d.ts +8 -2
  111. package/package.json +2 -2
@@ -3,7 +3,7 @@ import { hasLLMChatV2ToolResponseFormatConflict, LLM_CHAT_V2_TOOL_RESPONSE_FORMA
3
3
  import { buildLLMInvocationRunOptions, resolveLLMChatV2BaseURL } from './llmInvocationPlan.js';
4
4
  import { applyLLMProfileToNodeData } from './llmProfile.js';
5
5
  import { createResolvedChatV2Provider, resolveChatV2Credential, } from './chatV2ProviderProfile.js';
6
- import { resolveLLMChatV2BuiltInTools, resolveLLMChatV2GenerationParameters, resolveLLMChatV2Headers, resolveLLMChatV2RuntimeProviderOptions, } from './chatV2RuntimeOptions.js';
6
+ import { resolveLLMChatV2BuiltInTools, resolveLLMChatV2ExtraProviderOptions, resolveLLMChatV2GenerationParameters, resolveLLMChatV2Headers, resolveLLMChatV2RuntimeProviderOptions, } from './chatV2RuntimeOptions.js';
7
7
  import { createChatV2ResponseOutput, mergeCustomProviderResponseFormatOptions } from './chatV2ResponseFormat.js';
8
8
  import { parseCustomProviderApi } from './customProviderApi.js';
9
9
  import { parseChatV2Provider } from './providerOptions.js';
@@ -19,12 +19,14 @@ export async function resolveLLMModelCandidate(params) {
19
19
  const modelId = getInputOrData(effectiveData, plan.inputs, 'model', 'string');
20
20
  const baseURL = resolveLLMChatV2BaseURL(effectiveData, plan.inputs);
21
21
  const headers = resolveLLMChatV2Headers(effectiveData, plan.inputs);
22
+ const requestBodyOverlay = resolveLLMChatV2ExtraProviderOptions(effectiveData, plan.inputs);
22
23
  const credential = profile?.credential ??
23
24
  resolveChatV2Credential({
24
25
  provider,
25
26
  context: plan.context,
26
27
  apiKeySource: effectiveData.apiKeySource === 'input' ? 'input' : 'configured',
27
28
  inputs: plan.inputs,
29
+ providerApiKeyNames: effectiveData.providerApiKeyNames,
28
30
  customProgrammaticName: effectiveData.customProviderApiKeyProgrammaticName,
29
31
  customEnvironmentName: effectiveData.customProviderApiKeyEnvVarName,
30
32
  });
@@ -41,6 +43,7 @@ export async function resolveLLMModelCandidate(params) {
41
43
  onRequestBody: plan.requestBodies == null ? undefined : (body) => plan.requestBodies.push(body),
42
44
  onResponseBody: plan.responseBodyCapture == null ? undefined : (response) => plan.responseBodyCapture.capture(response),
43
45
  transformRequestBody,
46
+ requestBodyOverlay,
44
47
  customProviderApi,
45
48
  });
46
49
  const generationParameters = resolveLLMChatV2GenerationParameters(effectiveData, plan.inputs);
@@ -55,6 +58,7 @@ export async function resolveLLMModelCandidate(params) {
55
58
  effectiveData,
56
59
  credential,
57
60
  providerConfig: resolvedProvider.config,
61
+ requestBodyOverlay,
58
62
  runOptions: {
59
63
  ...baseRunOptions,
60
64
  provider,
@@ -2,6 +2,8 @@ import { createLLMChatV2NodeData } from './llmChatV2NodeData.js';
2
2
  import { parseCustomProviderApi } from './customProviderApi.js';
3
3
  import { llmProfileBooleanDataKeys, llmProfileOptionalNumberDataKeys, llmProfileRequiredNumberDataKeys, llmProfileResolvedInputToggleDataKeys, llmProfileStringDataKeys, } from './llmProfileFieldRegistry.js';
4
4
  import { LLM_PROFILE_VALUE_VERSION, pickLLMChatV2ProfileData } from './llmProfileTypes.js';
5
+ import { createRivetLLMProfileHealthIdentity } from './llmProfileHealthStore.js';
6
+ import { normalizeChatV2CredentialNamesByProvider } from './chatV2CredentialNames.js';
5
7
  export { applyLLMProfileToNodeData, createDefaultLLMProfileValue, createLLMProfileNodeData, LLM_PROFILE_VALUE_VERSION, pickLLMChatV2ProfileData, } from './llmProfileTypes.js';
6
8
  const credentialSources = new Set([
7
9
  'input',
@@ -35,10 +37,19 @@ export function normalizeLLMProfileValue(value) {
35
37
  provider,
36
38
  model: model.trim(),
37
39
  });
40
+ const sourceIdentity = normalizeSourceIdentity(value.healthIdentity);
41
+ const profileName = normalizeProfileName(value.profileName) ?? sourceIdentity.profileName;
38
42
  return {
39
43
  version: LLM_PROFILE_VALUE_VERSION,
40
44
  configuration,
41
45
  credential,
46
+ ...(profileName == null ? {} : { profileName }),
47
+ healthIdentity: createRivetLLMProfileHealthIdentity({
48
+ configuration,
49
+ credential,
50
+ ...sourceIdentity,
51
+ ...(profileName == null ? {} : { profileName }),
52
+ }),
42
53
  };
43
54
  }
44
55
  /**
@@ -62,6 +73,35 @@ export function normalizeLLMProfileChainInput(value) {
62
73
  }
63
74
  });
64
75
  }
76
+ /**
77
+ * Programmatic or serialized llm-config values may originate outside the
78
+ * currently executing project. Always bind health to that project before
79
+ * shared storage is consulted so copied values cannot share a circuit across
80
+ * projects. Preserve an originating profile-node identity when one exists;
81
+ * otherwise the consuming Chat node owns the identity.
82
+ */
83
+ export function scopeLLMProfileHealthIdentity(profile, fallback) {
84
+ const profileNodeId = profile.healthIdentity?.profileNodeId ?? fallback.profileNodeId;
85
+ const profileName = normalizeProfileName(profile.profileName) ?? normalizeProfileName(profile.healthIdentity?.profileName);
86
+ const healthIdentity = createRivetLLMProfileHealthIdentity({
87
+ configuration: profile.configuration,
88
+ credential: profile.credential,
89
+ chatNodeHeaders: fallback.chatNodeHeaders,
90
+ projectId: fallback.projectId,
91
+ profileNodeId,
92
+ ...(profileName == null ? {} : { profileName }),
93
+ });
94
+ if (profile.healthIdentity?.key === healthIdentity.key &&
95
+ profile.profileName === profileName &&
96
+ profile.healthIdentity?.profileName === profileName) {
97
+ return profile;
98
+ }
99
+ return {
100
+ ...profile,
101
+ ...(profileName == null ? {} : { profileName }),
102
+ healthIdentity,
103
+ };
104
+ }
65
105
  function normalizeConfiguration(data) {
66
106
  for (const field of llmProfileStringDataKeys) {
67
107
  if (typeof data[field] !== 'string') {
@@ -103,6 +143,7 @@ function normalizeConfiguration(data) {
103
143
  const resolvedData = {
104
144
  ...data,
105
145
  customProviderApi,
146
+ providerApiKeyNames: normalizeChatV2CredentialNamesByProvider(data.providerApiKeyNames),
106
147
  model: data.model.trim(),
107
148
  customProviderBaseURL: data.customProviderBaseURL.trim(),
108
149
  customProviderApiKeyProgrammaticName: data.customProviderApiKeyProgrammaticName?.trim(),
@@ -152,6 +193,23 @@ function normalizeCredential(value) {
152
193
  },
153
194
  };
154
195
  }
196
+ function normalizeSourceIdentity(value) {
197
+ if (!isRecord(value)) {
198
+ return {};
199
+ }
200
+ const profileName = normalizeProfileName(value.profileName);
201
+ return {
202
+ ...(typeof value.projectId === 'string' ? { projectId: value.projectId } : {}),
203
+ ...(typeof value.profileNodeId === 'string' ? { profileNodeId: value.profileNodeId } : {}),
204
+ ...(profileName == null ? {} : { profileName }),
205
+ };
206
+ }
207
+ function normalizeProfileName(value) {
208
+ if (typeof value !== 'string')
209
+ return undefined;
210
+ const normalized = value.trim();
211
+ return normalized === '' ? undefined : normalized;
212
+ }
155
213
  function isRecord(value) {
156
214
  return typeof value === 'object' && value != null && !Array.isArray(value);
157
215
  }
@@ -1,3 +1,4 @@
1
+ import { getNonDefaultChatV2CredentialNames } from './chatV2CredentialNames.js';
1
2
  import { getChatV2ModelInfo } from './modelRegistry.js';
2
3
  import { anthropicCacheControlTtlOptions, anthropicEffortOptions, anthropicThinkingModeOptions, getChatV2ProviderLabel, getCustomProviderApiContract, googleThinkingLevelOptions, openAIReasoningEffortOptions, openAIWebSearchContextSizeOptions, } from './providerOptions.js';
3
4
  function getOptionLabel(options, value) {
@@ -127,6 +128,7 @@ function getStopSequencesBodyField(data) {
127
128
  * in the node data and therefore cannot be rendered here.
128
129
  */
129
130
  export function getLLMProfileBodySections(data) {
131
+ const credentialNames = getNonDefaultChatV2CredentialNames(data.provider, data.providerApiKeyNames);
130
132
  const modelFields = [
131
133
  {
132
134
  label: 'Provider',
@@ -139,6 +141,12 @@ export function getLLMProfileBodySections(data) {
139
141
  : []),
140
142
  { label: 'Model', value: getModelBodyLabel(data) },
141
143
  { label: 'API key source', value: data.apiKeySource === 'input' ? 'Input port' : 'Configured key' },
144
+ ...(credentialNames != null && data.apiKeySource !== 'input'
145
+ ? [
146
+ { label: 'Programmatic API key name', value: credentialNames.programmaticName },
147
+ { label: 'API key environment variable', value: credentialNames.environmentVariableName },
148
+ ]
149
+ : []),
142
150
  ...(data.provider === 'custom' && data.apiKeySource !== 'input'
143
151
  ? [
144
152
  data.customProviderApiKeyProgrammaticName?.trim()
@@ -169,10 +177,12 @@ export function getLLMProfileBodySections(data) {
169
177
  data.extraProviderOptions.trim().length > 0
170
178
  ? { label: 'Extra provider options', text: data.extraProviderOptions }
171
179
  : undefined;
180
+ const reliabilityFields = data.enableCircuitBreaker === true ? [{ label: 'Automatic suspension', value: 'Configured' }] : [];
172
181
  const sections = [
173
182
  { id: 'model', fields: modelFields.filter((field) => field !== undefined) },
174
183
  { id: 'parameters', fields: parameterFields.filter((field) => field !== undefined) },
175
184
  { id: 'provider', fields: getProviderBodyFields(data) },
185
+ { id: 'reliability', fields: reliabilityFields },
176
186
  {
177
187
  id: 'advanced',
178
188
  fields: advancedFields.filter((field) => field !== undefined),