@valerypopoff/rivet2-core 2.32.0 → 2.34.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.
@@ -30,12 +30,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/serialization.ts
31
31
  var serialization_exports = {};
32
32
  __export(serialization_exports, {
33
+ bindSharedReplayProjectId: () => bindSharedReplayProjectId,
33
34
  deserializeDatasets: () => deserializeDatasets,
34
35
  deserializeGraph: () => deserializeGraph,
35
36
  deserializeProject: () => deserializeProject,
36
37
  serializeDatasets: () => serializeDatasets,
37
38
  serializeGraph: () => serializeGraph,
38
- serializeProject: () => serializeProject
39
+ serializeProject: () => serializeProject,
40
+ serializeSharedReplayProject: () => serializeSharedReplayProject
39
41
  });
40
42
  module.exports = __toCommonJS(serialization_exports);
41
43
 
@@ -1409,6 +1411,7 @@ function getError(error) {
1409
1411
 
1410
1412
  // src/utils/serialization/serialization_v4.ts
1411
1413
  var import_lodash_es2 = require("lodash");
1414
+ var import_safe_stable_stringify3 = __toESM(require("safe-stable-stringify"), 1);
1412
1415
 
1413
1416
  // src/model/chat-v2/llmChatV2NodeMigration.ts
1414
1417
  function normalizeSerializedLLMTemperatureData(nodeType, data) {
@@ -1459,6 +1462,27 @@ function graphV4Deserializer(data) {
1459
1462
  return fromSerializedGraph2(serializedGraph);
1460
1463
  }
1461
1464
  function projectV4Serializer(project, attachedData) {
1465
+ return wrapInYamlEnvelope(4, prepareSerializedProject(project, attachedData));
1466
+ }
1467
+ var replayProjectHeader = '{"version":4,"data":{"metadata":{"id":';
1468
+ function serializeSharedReplayProject(project, attachedData) {
1469
+ const {
1470
+ metadata: { id, ...metadata },
1471
+ ...data
1472
+ } = prepareSerializedProject(project, attachedData);
1473
+ const metadataJson = (0, import_safe_stable_stringify3.default)(metadata);
1474
+ const dataJson = (0, import_safe_stable_stringify3.default)(data);
1475
+ const metadataTail = metadataJson === "{}" ? "}" : "," + metadataJson.slice(1);
1476
+ return replayProjectHeader + JSON.stringify(id) + metadataTail + "," + dataJson.slice(1) + "}";
1477
+ }
1478
+ function bindSharedReplayProjectId(snapshot, sourceId, recordingId) {
1479
+ const sourceHeader = replayProjectHeader + JSON.stringify(sourceId);
1480
+ const afterId = snapshot[sourceHeader.length];
1481
+ if (!snapshot.startsWith(sourceHeader) || afterId !== "," && afterId !== "}")
1482
+ throw new Error("Shared replay project has an invalid source identity.");
1483
+ return replayProjectHeader + JSON.stringify(recordingId) + snapshot.slice(sourceHeader.length);
1484
+ }
1485
+ function prepareSerializedProject(project, attachedData) {
1462
1486
  if (!isValidProjectStaticData(project.data)) {
1463
1487
  throw new Error("Project data must be a record of static-data strings");
1464
1488
  }
@@ -1472,7 +1496,7 @@ function projectV4Serializer(project, attachedData) {
1472
1496
  path: void 0
1473
1497
  }
1474
1498
  };
1475
- return wrapInYamlEnvelope(4, toSerializedProject(filteredProject, attachedData));
1499
+ return toSerializedProject(filteredProject, attachedData);
1476
1500
  }
1477
1501
  function graphV4Serializer(graph) {
1478
1502
  return wrapInYamlEnvelope(4, toSerializedGraph(graph));
@@ -1873,11 +1897,13 @@ function deserializeDatasets(serializedDatasets) {
1873
1897
  }
1874
1898
  // Annotate the CommonJS export names for ESM import in node:
1875
1899
  0 && (module.exports = {
1900
+ bindSharedReplayProjectId,
1876
1901
  deserializeDatasets,
1877
1902
  deserializeGraph,
1878
1903
  deserializeProject,
1879
1904
  serializeDatasets,
1880
1905
  serializeGraph,
1881
- serializeProject
1906
+ serializeProject,
1907
+ serializeSharedReplayProject
1882
1908
  });
1883
1909
  //# sourceMappingURL=serialization.cjs.map