@valerypopoff/rivet2-core 2.1.0 → 2.1.1

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.
@@ -6342,6 +6342,39 @@ var RIVET_WEB_APP_RENDERER_CSS = `
6342
6342
  color: var(--rivet-web-app-error-color);
6343
6343
  font-weight: 700;
6344
6344
  }
6345
+
6346
+ .rivet-web-app-modal-backdrop {
6347
+ position: fixed;
6348
+ inset: 0;
6349
+ z-index: 1000;
6350
+ display: grid;
6351
+ place-items: center;
6352
+ background: rgba(0, 0, 0, 0.46);
6353
+ background: color-mix(in srgb, var(--rivet-web-app-background) 78%, transparent);
6354
+ padding: 20px;
6355
+ }
6356
+
6357
+ .rivet-web-app-modal {
6358
+ display: grid;
6359
+ gap: 18px;
6360
+ width: min(420px, 100%);
6361
+ border: 1px solid var(--rivet-web-app-card-border);
6362
+ border-radius: 12px;
6363
+ background: var(--rivet-web-app-card-background);
6364
+ box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
6365
+ color: var(--rivet-web-app-foreground);
6366
+ padding: 22px;
6367
+ }
6368
+
6369
+ .rivet-web-app-modal-message {
6370
+ font-size: 18px;
6371
+ font-weight: 700;
6372
+ line-height: 1.3;
6373
+ }
6374
+
6375
+ .rivet-web-app-modal-button {
6376
+ justify-self: start;
6377
+ }
6345
6378
  `;
6346
6379
  var RIVET_WEB_APP_DOCUMENT_CSS = `
6347
6380
  html,
@@ -9043,7 +9076,7 @@ function createChatV2CommonNodeData(overrides = {}) {
9043
9076
  useModelInput: false,
9044
9077
  temperature: 0.5,
9045
9078
  useTemperatureInput: false,
9046
- topP: 1,
9079
+ topP: void 0,
9047
9080
  useTopPInput: false,
9048
9081
  topK: void 0,
9049
9082
  useTopKInput: false,
@@ -10005,6 +10038,57 @@ function openAIBaseURLToEndpoint(baseURL) {
10005
10038
  return `${normalizedBaseURL}/chat/completions`;
10006
10039
  }
10007
10040
  }
10041
+ function parseBodyText(text) {
10042
+ try {
10043
+ return JSON.parse(text);
10044
+ } catch {
10045
+ return text;
10046
+ }
10047
+ }
10048
+ function parseFetchBody(body) {
10049
+ if (body == null) {
10050
+ return void 0;
10051
+ }
10052
+ if (typeof body === "string") {
10053
+ return parseBodyText(body);
10054
+ }
10055
+ if (body instanceof URLSearchParams) {
10056
+ return Object.fromEntries(body.entries());
10057
+ }
10058
+ if (body instanceof ArrayBuffer) {
10059
+ return parseBodyText(new TextDecoder().decode(body));
10060
+ }
10061
+ if (ArrayBuffer.isView(body)) {
10062
+ return parseBodyText(new TextDecoder().decode(body));
10063
+ }
10064
+ return void 0;
10065
+ }
10066
+ function cloneCapturedRequestBody(body) {
10067
+ if (typeof structuredClone === "function") {
10068
+ try {
10069
+ return structuredClone(body);
10070
+ } catch {
10071
+ }
10072
+ }
10073
+ try {
10074
+ return JSON.parse(JSON.stringify(body));
10075
+ } catch {
10076
+ return body;
10077
+ }
10078
+ }
10079
+ function createRequestBodyCapturingFetch(onRequestBody) {
10080
+ return async (input, init2) => {
10081
+ const body = parseFetchBody(init2 == null ? void 0 : init2.body);
10082
+ if (body !== void 0) {
10083
+ onRequestBody(cloneCapturedRequestBody(body));
10084
+ }
10085
+ const nativeFetch = globalThis.fetch;
10086
+ return nativeFetch(input, init2);
10087
+ };
10088
+ }
10089
+ function maybeCreateRequestBodyCapturingFetch(options2) {
10090
+ return options2.onRequestBody == null ? void 0 : createRequestBodyCapturingFetch(options2.onRequestBody);
10091
+ }
10008
10092
  async function resolveChatV2ProviderConfig(provider, modelId, context, options2 = {}) {
10009
10093
  var _a;
10010
10094
  const headers = cleanHeaders({
@@ -10058,7 +10142,8 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
10058
10142
  apiKey: options2.apiKey || context.settings.openAiKey || void 0,
10059
10143
  organization: context.settings.openAiOrganization || void 0,
10060
10144
  baseURL: options2.baseURL || void 0,
10061
- headers: options2.headers
10145
+ headers: options2.headers,
10146
+ fetch: maybeCreateRequestBodyCapturingFetch(options2)
10062
10147
  });
10063
10148
  return providerInstance.responses(modelId);
10064
10149
  }
@@ -10066,7 +10151,8 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
10066
10151
  const providerInstance = (0, import_anthropic2.createAnthropic)({
10067
10152
  apiKey: options2.apiKey || context.getPluginConfig("anthropicApiKey") || void 0,
10068
10153
  baseURL: options2.baseURL || context.getPluginConfig("anthropicApiEndpoint") || void 0,
10069
- headers: options2.headers
10154
+ headers: options2.headers,
10155
+ fetch: maybeCreateRequestBodyCapturingFetch(options2)
10070
10156
  });
10071
10157
  return providerInstance.messages(modelId);
10072
10158
  }
@@ -10074,7 +10160,8 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
10074
10160
  const providerInstance = (0, import_google2.createGoogleGenerativeAI)({
10075
10161
  apiKey: options2.apiKey || context.getPluginConfig("googleApiKey") || void 0,
10076
10162
  baseURL: options2.baseURL || void 0,
10077
- headers: options2.headers
10163
+ headers: options2.headers,
10164
+ fetch: maybeCreateRequestBodyCapturingFetch(options2)
10078
10165
  });
10079
10166
  return providerInstance.chat(modelId);
10080
10167
  }
@@ -10087,7 +10174,8 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
10087
10174
  apiKey: options2.apiKey,
10088
10175
  baseURL: options2.baseURL,
10089
10176
  headers: options2.headers,
10090
- includeUsage: true
10177
+ includeUsage: false,
10178
+ fetch: maybeCreateRequestBodyCapturingFetch(options2)
10091
10179
  });
10092
10180
  const model = providerInstance.chatModel(modelId);
10093
10181
  model.supportsStructuredOutputs = true;
@@ -10399,7 +10487,7 @@ function getResponseFormatEditors() {
10399
10487
  options: [
10400
10488
  { value: "", label: "Default" },
10401
10489
  { value: "text", label: "Text" },
10402
- { value: "json", label: "JSON" },
10490
+ { value: "json", label: "JSON object" },
10403
10491
  { value: "json_schema", label: "JSON schema" }
10404
10492
  ],
10405
10493
  defaultValue: "",
@@ -10411,7 +10499,7 @@ function getResponseFormatEditors() {
10411
10499
  dataKey: "responseSchemaName",
10412
10500
  useInputToggleDataKey: "useResponseSchemaNameInput",
10413
10501
  placeholder: "response_schema",
10414
- helperMessage: "Optional name passed to the provider for JSON or JSON schema responses.",
10502
+ helperMessage: "Optional name passed to the provider for JSON object or JSON schema responses.",
10415
10503
  hideIf: (data) => data.responseFormat !== "json" && data.responseFormat !== "json_schema"
10416
10504
  },
10417
10505
  {
@@ -10419,7 +10507,7 @@ function getResponseFormatEditors() {
10419
10507
  label: "Schema description",
10420
10508
  dataKey: "responseSchemaDescription",
10421
10509
  useInputToggleDataKey: "useResponseSchemaDescriptionInput",
10422
- helperMessage: "Optional description passed to the provider for JSON or JSON schema responses.",
10510
+ helperMessage: "Optional description passed to the provider for JSON object or JSON schema responses.",
10423
10511
  hideIf: (data) => data.responseFormat !== "json" && data.responseFormat !== "json_schema"
10424
10512
  }
10425
10513
  ]);
@@ -10558,9 +10646,9 @@ function getTechnicalDetailsEditors() {
10558
10646
  },
10559
10647
  {
10560
10648
  type: "toggle",
10561
- label: "Output request status",
10649
+ label: "Output request details",
10562
10650
  dataKey: "outputRequestStatus",
10563
- helperMessage: "Adds Response Status and Response Error outputs. Retry mode changes them to per-attempt arrays."
10651
+ helperMessage: "Adds Response Status, Response Error, and LLM request body outputs. Retry mode changes status/error to per-attempt arrays, and LLM request body becomes an array when multiple provider calls are made."
10564
10652
  }
10565
10653
  ]);
10566
10654
  }
@@ -10709,7 +10797,7 @@ function resolveChatV2ResponseFormatParameters(data, inputs) {
10709
10797
  schemaDescription
10710
10798
  };
10711
10799
  }
10712
- function createChatV2ResponseOutput(parameters) {
10800
+ function createChatV2ResponseOutput(parameters, provider) {
10713
10801
  if (parameters == null) {
10714
10802
  return void 0;
10715
10803
  }
@@ -10717,6 +10805,9 @@ function createChatV2ResponseOutput(parameters) {
10717
10805
  return import_ai.Output.text();
10718
10806
  }
10719
10807
  if (parameters.responseFormat === "json") {
10808
+ if (provider === "custom") {
10809
+ return void 0;
10810
+ }
10720
10811
  return import_ai.Output.json({
10721
10812
  name: parameters.schemaName,
10722
10813
  description: parameters.schemaDescription
@@ -10770,7 +10861,7 @@ var LLM_CHAT_V2_TOOL_RESPONSE_FORMAT_CONFLICT_COPY = {
10770
10861
  title: '"Tool use" conflicts with "Structured outputs"',
10771
10862
  paragraphs: [
10772
10863
  '"Tool use" and "Structured outputs" cannot be used at the same time.',
10773
- 'Use "Tool use" with Default/Text response format, or turn "Tool use" off before choosing JSON/JSON schema.'
10864
+ 'Use "Tool use" with Default/Text response format, or turn "Tool use" off before choosing JSON object/JSON schema.'
10774
10865
  ]
10775
10866
  };
10776
10867
  function isLLMChatV2StructuredResponseFormat(responseFormat) {
@@ -11134,11 +11225,16 @@ async function resolveLLMChatV2RuntimeConfig(params) {
11134
11225
  const baseURL = resolveLLMChatV2BaseURL(data, inputs);
11135
11226
  const nodeHeaders = resolveLLMChatV2Headers(data, inputs);
11136
11227
  const apiKey = resolveLLMChatV2ApiKey(data, inputs, context);
11228
+ const requestBodies = data.outputRequestStatus ? [] : void 0;
11137
11229
  const providerConfig = await resolveChatV2ProviderConfig(provider, modelId, context, {
11138
11230
  baseURL,
11139
11231
  headers: nodeHeaders
11140
11232
  });
11141
- const model = createChatV2Model(provider, modelId, context, { ...providerConfig, apiKey });
11233
+ const model = createChatV2Model(provider, modelId, context, {
11234
+ ...providerConfig,
11235
+ apiKey,
11236
+ onRequestBody: requestBodies == null ? void 0 : (body) => requestBodies.push(body)
11237
+ });
11142
11238
  const prompt = inputs["prompt"];
11143
11239
  const systemPrompt = inputs["systemPrompt"];
11144
11240
  const functions = data.useToolCalling && inputs["functions"] != null ? coerceTypeOptional(inputs["functions"], "gpt-function[]") : void 0;
@@ -11159,7 +11255,7 @@ async function resolveLLMChatV2RuntimeConfig(params) {
11159
11255
  functions,
11160
11256
  additionalTools: resolveLLMChatV2BuiltInTools(data, context, providerConfig, apiKey),
11161
11257
  ...generationParameters,
11162
- responseOutput: createChatV2ResponseOutput(responseFormatParameters),
11258
+ responseOutput: createChatV2ResponseOutput(responseFormatParameters, provider),
11163
11259
  responseFormat: responseFormatParameters == null ? void 0 : responseFormatParameters.responseFormat,
11164
11260
  outputUsage: data.outputUsage,
11165
11261
  outputReasoning: data.outputReasoning,
@@ -11169,6 +11265,7 @@ async function resolveLLMChatV2RuntimeConfig(params) {
11169
11265
  providerOptions,
11170
11266
  toolChoice,
11171
11267
  anthropicCacheControlTtl: provider === "anthropic" ? data.anthropicCacheControlTtl || void 0 : void 0,
11268
+ requestBodies,
11172
11269
  retryOnNon200: data.retryOnNon200,
11173
11270
  retryOnNon200RepeatTimes: data.retryOnNon200RepeatTimes,
11174
11271
  retryOnNon200CooldownMs: data.retryOnNon200CooldownMs,
@@ -11938,6 +12035,7 @@ function normalizeChatV2ProviderError(error, context) {
11938
12035
  // src/model/chat-v2/chatV2Outputs.ts
11939
12036
  var CHAT_V2_REQUEST_STATUS_PORT_ID = "requestStatus";
11940
12037
  var CHAT_V2_REQUEST_ERROR_PORT_ID = "requestError";
12038
+ var CHAT_V2_REQUEST_BODY_PORT_ID = "requestBody";
11941
12039
  function toFunctionCallOutputValue(functionCall) {
11942
12040
  let argumentsValue = functionCall.lastParsedArguments;
11943
12041
  if (argumentsValue == null) {
@@ -12006,6 +12104,12 @@ function createChatV2ReasoningOutput(reasoning) {
12006
12104
  value: reasoningText
12007
12105
  } : createControlFlowExcludedOutput();
12008
12106
  }
12107
+ function createChatV2RequestBodyOutput(requestBodies) {
12108
+ if (requestBodies == null || requestBodies.length === 0) {
12109
+ return createControlFlowExcludedOutput();
12110
+ }
12111
+ return inferType(requestBodies.length === 1 ? requestBodies[0] : requestBodies);
12112
+ }
12009
12113
  function createChatV2RetryAttemptOutput(type, values2) {
12010
12114
  return values2.length > 0 ? {
12011
12115
  type,
@@ -12023,6 +12127,7 @@ function createChatV2CommonOutputs({
12023
12127
  responseError,
12024
12128
  requestStatuses,
12025
12129
  requestErrors,
12130
+ requestBodies,
12026
12131
  outputUsage,
12027
12132
  outputReasoning,
12028
12133
  outputRequestStatus,
@@ -12080,6 +12185,7 @@ function createChatV2CommonOutputs({
12080
12185
  value: responseError
12081
12186
  } : createControlFlowExcludedOutput();
12082
12187
  }
12188
+ outputs[CHAT_V2_REQUEST_BODY_PORT_ID] = createChatV2RequestBodyOutput(requestBodies);
12083
12189
  }
12084
12190
  return outputs;
12085
12191
  }
@@ -12089,6 +12195,7 @@ function createChatV2ProviderFailureOutputs({
12089
12195
  responseError,
12090
12196
  requestStatuses,
12091
12197
  requestErrors,
12198
+ requestBodies,
12092
12199
  outputUsage,
12093
12200
  outputReasoning,
12094
12201
  includeFunctionCalls,
@@ -12117,6 +12224,7 @@ function createChatV2ProviderFailureOutputs({
12117
12224
  },
12118
12225
  ["responseTokens"]: createControlFlowExcludedOutput()
12119
12226
  };
12227
+ outputs[CHAT_V2_REQUEST_BODY_PORT_ID] = createChatV2RequestBodyOutput(requestBodies);
12120
12228
  if (includeFunctionCalls) {
12121
12229
  outputs["function-calls"] = createControlFlowExcludedOutput();
12122
12230
  }
@@ -12217,6 +12325,7 @@ function buildProviderFailureResult(requestMessages, options2, normalizedError,
12217
12325
  responseError,
12218
12326
  requestStatuses: retryRequestStatuses,
12219
12327
  requestErrors: retryRequestErrors,
12328
+ requestBodies: options2.requestBodies,
12220
12329
  outputUsage: options2.outputUsage,
12221
12330
  outputReasoning: options2.outputReasoning,
12222
12331
  includeFunctionCalls: options2.includeFunctionCalls,
@@ -12288,6 +12397,7 @@ async function runChatV2Pipeline(options2) {
12288
12397
  responseError: void 0,
12289
12398
  requestStatuses: [],
12290
12399
  requestErrors: [],
12400
+ requestBodies: void 0,
12291
12401
  outputUsage: false,
12292
12402
  outputReasoning: false,
12293
12403
  outputRequestStatus: false,
@@ -12342,6 +12452,7 @@ async function runChatV2Pipeline(options2) {
12342
12452
  responseError,
12343
12453
  requestStatuses,
12344
12454
  requestErrors,
12455
+ requestBodies: options2.requestBodies,
12345
12456
  outputUsage: options2.outputUsage,
12346
12457
  outputReasoning: options2.outputReasoning,
12347
12458
  outputRequestStatus: options2.outputRequestStatus,
@@ -12812,6 +12923,11 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
12812
12923
  id: "requestError",
12813
12924
  title: "Response Error",
12814
12925
  dataType: this.data.retryOnNon200 ? "string[]" : "string"
12926
+ },
12927
+ {
12928
+ id: "requestBody",
12929
+ title: "LLM request body",
12930
+ dataType: ["object", "object[]", "string", "string[]", "any", "any[]"]
12815
12931
  }
12816
12932
  );
12817
12933
  }
@@ -24894,13 +25010,13 @@ var NodePrefabInstanceNodeImpl = class extends NodeImpl {
24894
25010
  return [];
24895
25011
  }
24896
25012
  async process(_inputData) {
24897
- throw new Error("Library node is missing. Open the Node Library and reconnect this linked node.");
25013
+ throw new Error("Library node is missing. Open the Node library and reconnect this linked node.");
24898
25014
  }
24899
25015
  static getUIData() {
24900
25016
  return {
24901
25017
  contextMenuTitle: "Linked node",
24902
25018
  infoBoxTitle: "Linked node",
24903
- infoBoxBody: "Runs a node from the project Node Library.",
25019
+ infoBoxBody: "Runs a node from the project Node library.",
24904
25020
  group: "Advanced"
24905
25021
  };
24906
25022
  }