@valerypopoff/rivet2-core 2.1.5 → 2.1.6

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 (65) hide show
  1. package/dist/cjs/bundle.cjs +3154 -289
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/webAppRuntime.cjs +129 -4
  4. package/dist/cjs/webAppRuntime.cjs.map +2 -2
  5. package/dist/esm/api/createProcessor.js +1 -0
  6. package/dist/esm/exports.js +4 -0
  7. package/dist/esm/integrations/KnowledgeStore.js +1 -0
  8. package/dist/esm/integrations/KnowledgeStoreProvider.js +292 -0
  9. package/dist/esm/integrations/KnowledgeStoreValidation.js +428 -0
  10. package/dist/esm/integrations/ManagedKnowledgeStore.js +539 -0
  11. package/dist/esm/model/DataValue.js +22 -2
  12. package/dist/esm/model/GraphProcessor.js +14 -0
  13. package/dist/esm/model/Nodes.js +18 -0
  14. package/dist/esm/model/UiGraph.js +2 -2
  15. package/dist/esm/model/UiGraphBrowserRuntime.js +112 -1
  16. package/dist/esm/model/UiGraphRendererStyles.js +111 -9
  17. package/dist/esm/model/UiGraphRuntimeModel.js +26 -2
  18. package/dist/esm/model/chat/openAIChatRequest.js +8 -2
  19. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +8 -8
  20. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +3 -1
  21. package/dist/esm/model/chat-v2/parallelToolCalls.js +38 -0
  22. package/dist/esm/model/chat-v2/toolContinuation.js +39 -0
  23. package/dist/esm/model/nodes/BuildKnowledgeContextNode.js +157 -0
  24. package/dist/esm/model/nodes/GetKnowledgeSourceStatusNode.js +79 -0
  25. package/dist/esm/model/nodes/KnowledgeDocumentNode.js +88 -0
  26. package/dist/esm/model/nodes/KnowledgeSourceNode.js +94 -0
  27. package/dist/esm/model/nodes/SearchKnowledgeNode.js +127 -0
  28. package/dist/esm/model/nodes/StoredValueNodeUtils.js +10 -0
  29. package/dist/esm/model/nodes/SyncKnowledgeSourceNode.js +149 -0
  30. package/dist/esm/model/nodes/ToolNode.js +14 -0
  31. package/dist/esm/plugins/pinecone/PineconeKnowledgeStore.js +553 -0
  32. package/dist/esm/plugins/pinecone/plugin.js +32 -0
  33. package/dist/esm/utils/coerceType.js +24 -2
  34. package/dist/esm/utils/getPluginConfig.js +12 -6
  35. package/dist/esm/utils/serialization/serialization.js +4 -1
  36. package/dist/esm/utils/serialization/serializationUtils.js +59 -1
  37. package/dist/esm/webAppRuntime.js +1 -1
  38. package/dist/types/api/createProcessor.d.ts +2 -0
  39. package/dist/types/exports.d.ts +4 -0
  40. package/dist/types/integrations/KnowledgeStore.d.ts +131 -0
  41. package/dist/types/integrations/KnowledgeStoreProvider.d.ts +46 -0
  42. package/dist/types/integrations/KnowledgeStoreValidation.d.ts +16 -0
  43. package/dist/types/integrations/ManagedKnowledgeStore.d.ts +57 -0
  44. package/dist/types/model/DataValue.d.ts +10 -3
  45. package/dist/types/model/EditorDefinition.d.ts +7 -1
  46. package/dist/types/model/GraphProcessor.d.ts +2 -0
  47. package/dist/types/model/Nodes.d.ts +8 -2
  48. package/dist/types/model/ProcessContext.d.ts +3 -0
  49. package/dist/types/model/Project.d.ts +11 -0
  50. package/dist/types/model/UiGraph.d.ts +3 -1
  51. package/dist/types/model/UiGraphBrowserRuntime.d.ts +25 -1
  52. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  53. package/dist/types/model/chat-v2/parallelToolCalls.d.ts +9 -0
  54. package/dist/types/model/nodes/BuildKnowledgeContextNode.d.ts +23 -0
  55. package/dist/types/model/nodes/GetKnowledgeSourceStatusNode.d.ts +19 -0
  56. package/dist/types/model/nodes/KnowledgeDocumentNode.d.ts +26 -0
  57. package/dist/types/model/nodes/KnowledgeSourceNode.d.ts +25 -0
  58. package/dist/types/model/nodes/SearchKnowledgeNode.d.ts +25 -0
  59. package/dist/types/model/nodes/StoredValueNodeUtils.d.ts +1 -1
  60. package/dist/types/model/nodes/SyncKnowledgeSourceNode.d.ts +27 -0
  61. package/dist/types/model/nodes/ToolNode.d.ts +2 -0
  62. package/dist/types/plugins/pinecone/PineconeKnowledgeStore.d.ts +11 -0
  63. package/dist/types/utils/serialization/serializationUtils.d.ts +4 -0
  64. package/dist/types/webAppRuntime.d.ts +2 -1
  65. package/package.json +1 -1
@@ -32,8 +32,10 @@ __export(webAppRuntime_exports, {
32
32
  createUiGraphChatSubmissionStatePatch: () => createUiGraphChatSubmissionStatePatch,
33
33
  createUiGraphInteractionController: () => createUiGraphInteractionController,
34
34
  downloadUiGraphJsonOutput: () => downloadUiGraphJsonOutput,
35
+ enhanceUiGraphChatJsonCodeBlocks: () => enhanceUiGraphChatJsonCodeBlocks,
35
36
  getUiGraphActionState: () => getUiGraphActionState,
36
37
  getUiGraphChatDraftStateKey: () => getUiGraphChatDraftStateKey,
38
+ getUiGraphChatMessagePresentations: () => getUiGraphChatMessagePresentations,
37
39
  getUiGraphChatMessagesStateKey: () => getUiGraphChatMessagesStateKey,
38
40
  getUiGraphChatPersistentState: () => getUiGraphChatPersistentState,
39
41
  getUiGraphChatStorageKey: () => getUiGraphChatStorageKey,
@@ -128,7 +130,7 @@ function createUiGraphChatHistoryFlushStatePatch(componentId) {
128
130
  [getUiGraphChatPinsStateKey(componentId)]: []
129
131
  };
130
132
  }
131
- function createUiGraphChatSubmissionStatePatch(componentId, state) {
133
+ function createUiGraphChatSubmissionStatePatch(componentId, state, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
132
134
  const draftStateKey = getUiGraphChatDraftStateKey(componentId);
133
135
  const content = `${state[draftStateKey] ?? ""}`.trim();
134
136
  if (!content) {
@@ -138,7 +140,7 @@ function createUiGraphChatSubmissionStatePatch(componentId, state) {
138
140
  [draftStateKey]: "",
139
141
  [getUiGraphChatMessagesStateKey(componentId)]: [
140
142
  ...getUiGraphChatMessages(componentId, state),
141
- { role: "user", content }
143
+ { role: "user", content, timestamp }
142
144
  ]
143
145
  };
144
146
  }
@@ -390,6 +392,27 @@ function createUiGraphInteractionController(initialUiGraph, options = {}) {
390
392
  }
391
393
  }
392
394
  };
395
+ const stampChatResponseAtBrowserReceipt = (component, statePatch) => {
396
+ if (component.type !== "chat" || !statePatch) {
397
+ return statePatch;
398
+ }
399
+ const messagesStateKey = getUiGraphChatMessagesStateKey(component.id);
400
+ const messages = statePatch[messagesStateKey];
401
+ if (!Array.isArray(messages) || messages.length === 0) {
402
+ return statePatch;
403
+ }
404
+ const lastMessage = messages[messages.length - 1];
405
+ if (!lastMessage || typeof lastMessage !== "object" || lastMessage.role !== "assistant" || typeof lastMessage.content !== "string") {
406
+ return statePatch;
407
+ }
408
+ return {
409
+ ...statePatch,
410
+ [messagesStateKey]: [
411
+ ...messages.slice(0, -1),
412
+ { ...lastMessage, timestamp: (/* @__PURE__ */ new Date()).toISOString() }
413
+ ]
414
+ };
415
+ };
393
416
  updateSnapshot();
394
417
  return {
395
418
  abortActions() {
@@ -448,7 +471,10 @@ function createUiGraphInteractionController(initialUiGraph, options = {}) {
448
471
  if (!actionController.isCurrent(execution)) {
449
472
  return;
450
473
  }
451
- const statePatch = actionController.resolveStatePatch(execution, result.statePatch);
474
+ const statePatch = actionController.resolveStatePatch(
475
+ execution,
476
+ stampChatResponseAtBrowserReceipt(component, result.statePatch)
477
+ );
452
478
  if (statePatch) {
453
479
  const nextState = applyUiGraphStatePatch(state, statePatch);
454
480
  expandOutputsForUpdatedState(Object.keys(statePatch), nextState);
@@ -892,6 +918,53 @@ var getDefaultUiGraphStorageLocation = () => {
892
918
  return void 0;
893
919
  }
894
920
  };
921
+ function getUiGraphChatMessagePresentations(messages, options = {}) {
922
+ const { locales, timeZone } = options;
923
+ const timeFormatter = new Intl.DateTimeFormat(locales, {
924
+ hour: "2-digit",
925
+ hourCycle: "h23",
926
+ minute: "2-digit",
927
+ ...timeZone ? { timeZone } : {}
928
+ });
929
+ const dateFormatter = new Intl.DateTimeFormat(locales, {
930
+ day: "numeric",
931
+ month: "long",
932
+ year: "numeric",
933
+ ...timeZone ? { timeZone } : {}
934
+ });
935
+ const dateKeyFormatter = new Intl.DateTimeFormat("en-CA", {
936
+ day: "2-digit",
937
+ month: "2-digit",
938
+ year: "numeric",
939
+ ...timeZone ? { timeZone } : {}
940
+ });
941
+ const entries = messages.map((message) => {
942
+ const timestamp = parseUiGraphChatTimestamp(message.timestamp);
943
+ if (!timestamp) return void 0;
944
+ return {
945
+ dateKey: dateKeyFormatter.format(timestamp),
946
+ dateTime: timestamp.toISOString(),
947
+ dateLabel: dateFormatter.format(timestamp),
948
+ timeLabel: timeFormatter.format(timestamp)
949
+ };
950
+ });
951
+ const hasMultipleDates = new Set(entries.flatMap((entry) => entry ? [entry.dateKey] : [])).size > 1;
952
+ let previousDateKey;
953
+ return entries.map((entry) => {
954
+ if (!entry) return {};
955
+ const dateSeparator = hasMultipleDates && previousDateKey != null && previousDateKey !== entry.dateKey ? { dateTime: entry.dateTime, label: entry.dateLabel } : void 0;
956
+ previousDateKey = entry.dateKey;
957
+ return {
958
+ ...dateSeparator ? { dateSeparator } : {},
959
+ timestamp: { dateTime: entry.dateTime, label: entry.timeLabel }
960
+ };
961
+ });
962
+ }
963
+ var parseUiGraphChatTimestamp = (value) => {
964
+ if (typeof value !== "string") return void 0;
965
+ const timestamp = new Date(value);
966
+ return Number.isNaN(timestamp.getTime()) ? void 0 : timestamp;
967
+ };
895
968
  function getUiGraphChatStorageKey(uiGraph, location = getDefaultUiGraphStorageLocation()) {
896
969
  if (!(location == null ? void 0 : location.origin)) {
897
970
  return void 0;
@@ -1107,6 +1180,56 @@ function downloadUiGraphJsonOutput(value, appName) {
1107
1180
  globalThis.setTimeout(() => URL.revokeObjectURL(url), 0);
1108
1181
  }
1109
1182
  }
1183
+ function enhanceUiGraphChatJsonCodeBlocks(root, appName) {
1184
+ var _a;
1185
+ const codeBlocks = root.querySelectorAll("pre > code.language-json");
1186
+ root.classList.toggle("rivet-web-app-chat-markdown-has-json", codeBlocks.length > 0);
1187
+ for (const code of codeBlocks) {
1188
+ const pre = code.parentElement;
1189
+ const existingWrapper = pre == null ? void 0 : pre.parentElement;
1190
+ if (!pre) {
1191
+ continue;
1192
+ }
1193
+ if (existingWrapper == null ? void 0 : existingWrapper.classList.contains("rivet-web-app-chat-json-block")) {
1194
+ existingWrapper.dataset.rivetChatJsonAppName = appName;
1195
+ continue;
1196
+ }
1197
+ const value = code.textContent ?? "";
1198
+ const document2 = root.ownerDocument;
1199
+ const wrapper = document2.createElement("div");
1200
+ wrapper.className = "rivet-web-app-chat-json-block";
1201
+ wrapper.dataset.rivetChatJsonAppName = appName;
1202
+ const actions = document2.createElement("div");
1203
+ actions.className = "rivet-web-app-chat-json-actions";
1204
+ actions.dataset.rivetChatSearchIgnore = "true";
1205
+ const copyButton = document2.createElement("button");
1206
+ copyButton.type = "button";
1207
+ copyButton.className = "rivet-web-app-output-action-button rivet-web-app-output-copy-button";
1208
+ copyButton.title = "Copy JSON";
1209
+ copyButton.setAttribute("aria-label", "Copy JSON");
1210
+ copyButton.addEventListener("click", (event) => {
1211
+ event.stopPropagation();
1212
+ void copyUiGraphText(value);
1213
+ });
1214
+ const downloadButton = document2.createElement("button");
1215
+ downloadButton.type = "button";
1216
+ downloadButton.className = "rivet-web-app-output-action-button rivet-web-app-output-download-button";
1217
+ downloadButton.title = "Download JSON";
1218
+ downloadButton.setAttribute("aria-label", "Download JSON");
1219
+ downloadButton.addEventListener("click", (event) => {
1220
+ event.stopPropagation();
1221
+ downloadUiGraphJsonOutput(value, wrapper.dataset.rivetChatJsonAppName ?? appName);
1222
+ });
1223
+ actions.append(copyButton, downloadButton);
1224
+ pre.replaceWith(wrapper);
1225
+ wrapper.append(pre, actions);
1226
+ const syncScrollableState = () => {
1227
+ wrapper.classList.toggle("rivet-web-app-chat-json-block-scrollable", pre.scrollHeight > pre.clientHeight);
1228
+ };
1229
+ syncScrollableState();
1230
+ (_a = root.ownerDocument.defaultView) == null ? void 0 : _a.requestAnimationFrame(syncScrollableState);
1231
+ }
1232
+ }
1110
1233
  function highlightUiGraphChatSearchMatches(messagesElement, query, requestedActiveIndex = 0) {
1111
1234
  var _a, _b;
1112
1235
  clearUiGraphChatSearchMatches(messagesElement);
@@ -1119,7 +1242,7 @@ function highlightUiGraphChatSearchMatches(messagesElement, query, requestedActi
1119
1242
  const walker = document2.createTreeWalker(messagesElement, 4);
1120
1243
  let node = walker.nextNode();
1121
1244
  while (node) {
1122
- if ((_a = node.parentElement) == null ? void 0 : _a.closest("script, style, textarea")) {
1245
+ if ((_a = node.parentElement) == null ? void 0 : _a.closest("script, style, textarea, [data-rivet-chat-search-ignore]")) {
1123
1246
  node = walker.nextNode();
1124
1247
  continue;
1125
1248
  }
@@ -1191,8 +1314,10 @@ var revealUiGraphChatSearchMatch = revealUiGraphChatElement;
1191
1314
  createUiGraphChatSubmissionStatePatch,
1192
1315
  createUiGraphInteractionController,
1193
1316
  downloadUiGraphJsonOutput,
1317
+ enhanceUiGraphChatJsonCodeBlocks,
1194
1318
  getUiGraphActionState,
1195
1319
  getUiGraphChatDraftStateKey,
1320
+ getUiGraphChatMessagePresentations,
1196
1321
  getUiGraphChatMessagesStateKey,
1197
1322
  getUiGraphChatPersistentState,
1198
1323
  getUiGraphChatStorageKey,