@opengeni/sdk 1.0.1 → 2.3.0-canary.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.
- package/README.md +117 -2
- package/dist/artifacts.js +5 -5
- package/dist/automations-client.d.ts +17 -0
- package/dist/automations.d.ts +3 -0
- package/dist/automations.js +78 -0
- package/dist/automations.js.map +1 -0
- package/dist/{chunk-YGH5P47G.js → chunk-6IPZY27S.js} +744 -57
- package/dist/chunk-6IPZY27S.js.map +1 -0
- package/dist/{chunk-TYZ4JL4J.js → chunk-AGUKZAXR.js} +2 -2
- package/dist/{chunk-A5DC5WEM.js → chunk-C2H7HBNP.js} +22 -2
- package/dist/chunk-C2H7HBNP.js.map +1 -0
- package/dist/{chunk-GU6JF75T.js → chunk-C4DJPZRU.js} +1 -1
- package/dist/{chunk-GU6JF75T.js.map → chunk-C4DJPZRU.js.map} +1 -1
- package/dist/{chunk-ST5DDKJP.js → chunk-GW3EJ2GP.js} +52 -1
- package/dist/chunk-GW3EJ2GP.js.map +1 -0
- package/dist/{chunk-4DV37UUA.js → chunk-TW5MNHUX.js} +16 -2
- package/dist/chunk-TW5MNHUX.js.map +1 -0
- package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
- package/dist/chunk-XNG7YGR3.js.map +1 -0
- package/dist/client.d.ts +159 -26
- package/dist/codex-realtime-controller.d.ts +1 -0
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/company-brain.d.ts +32 -0
- package/dist/company-profile.d.ts +1 -1
- package/dist/core.js +4 -4
- package/dist/editable-artifacts/browser-session.d.ts +7 -3
- package/dist/editable-artifacts/controller.d.ts +4 -1
- package/dist/editable-artifacts/errors.d.ts +1 -1
- package/dist/editable-artifacts/http-live-transport.d.ts +6 -2
- package/dist/editable-artifacts/index.d.ts +2 -0
- package/dist/editable-artifacts/open-failure.d.ts +9 -0
- package/dist/editable-artifacts/types.d.ts +4 -3
- package/dist/editable-artifacts/worker/kernel-adapter.d.ts +1 -1
- package/dist/editable-artifacts-worker.js +44 -17
- package/dist/editable-artifacts-worker.js.map +1 -1
- package/dist/editable-artifacts.js +222 -119
- package/dist/editable-artifacts.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +61 -12
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +23 -0
- package/dist/interaction.js +4 -1
- package/dist/organization-private-session-settings.d.ts +6 -0
- package/dist/organization-private-session-settings.js +22 -0
- package/dist/organization-private-session-settings.js.map +1 -0
- package/dist/pr-review-client.d.ts +15 -0
- package/dist/pr-review.d.ts +4 -0
- package/dist/pr-review.js +56 -0
- package/dist/pr-review.js.map +1 -0
- package/dist/preference-registry.d.ts +8 -0
- package/dist/realtime.js +2 -2
- package/dist/retained-artifacts.d.ts +5 -1
- package/dist/types.d.ts +1023 -13
- package/dist/workspace-instruction-policies.d.ts +22 -0
- package/dist/workspace-learning.d.ts +124 -0
- package/package.json +14 -2
- package/src/automations-client.ts +118 -0
- package/src/automations.ts +15 -0
- package/src/client.ts +1049 -71
- package/src/codex-realtime-controller.ts +21 -0
- package/src/company-brain.ts +99 -0
- package/src/company-profile.ts +4 -1
- package/src/editable-artifacts/browser-session.ts +36 -22
- package/src/editable-artifacts/controller.ts +66 -45
- package/src/editable-artifacts/errors.ts +2 -0
- package/src/editable-artifacts/http-live-transport.ts +62 -37
- package/src/editable-artifacts/index.ts +6 -0
- package/src/editable-artifacts/open-failure.ts +79 -0
- package/src/editable-artifacts/storage.ts +31 -40
- package/src/editable-artifacts/types.ts +4 -3
- package/src/editable-artifacts/worker/kernel-adapter.ts +23 -7
- package/src/editable-artifacts/worker/runtime.ts +26 -13
- package/src/editable-artifacts/worker/wire-codec.ts +23 -5
- package/src/errors.ts +1 -1
- package/src/index.ts +134 -0
- package/src/interaction.ts +95 -0
- package/src/organization-private-session-settings.ts +33 -0
- package/src/pr-review-client.ts +84 -0
- package/src/pr-review.ts +15 -0
- package/src/preference-registry.ts +9 -0
- package/src/retained-artifacts.ts +101 -0
- package/src/stream.ts +13 -2
- package/src/types.ts +1174 -12
- package/src/workspace-instruction-policies.ts +24 -0
- package/src/workspace-learning.ts +138 -0
- package/dist/chunk-4DV37UUA.js.map +0 -1
- package/dist/chunk-A5DC5WEM.js.map +0 -1
- package/dist/chunk-ST5DDKJP.js.map +0 -1
- package/dist/chunk-VWE2QIVO.js.map +0 -1
- package/dist/chunk-YGH5P47G.js.map +0 -1
- /package/dist/{chunk-TYZ4JL4J.js.map → chunk-AGUKZAXR.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OPENGENI_API_CONTRACT_HEADER,
|
|
3
3
|
OPENGENI_API_CONTRACT_REVISION
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TW5MNHUX.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_ARTIFACT_WORKER_RPC_LIMITS,
|
|
7
7
|
decodeArtifactWorkerRpcMessage,
|
|
@@ -18,22 +18,26 @@ import {
|
|
|
18
18
|
encodeSnapshotMetadata,
|
|
19
19
|
ownedTransferBuffer,
|
|
20
20
|
transferListForArtifactWorkerRpcMessage
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XNG7YGR3.js";
|
|
22
22
|
|
|
23
23
|
// src/editable-artifacts/controller.ts
|
|
24
24
|
import {
|
|
25
25
|
decodeEditableArtifactMutationIntent as decodeEditableArtifactMutationIntent2,
|
|
26
26
|
EDITABLE_ARTIFACT_COMMAND_MAX_BYTES as EDITABLE_ARTIFACT_COMMAND_MAX_BYTES2,
|
|
27
27
|
EDITABLE_ARTIFACT_INTENT_MAX_BYTES as EDITABLE_ARTIFACT_INTENT_MAX_BYTES2,
|
|
28
|
+
EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
|
|
28
29
|
EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES as EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES2,
|
|
29
30
|
hashEditableArtifactMutationIntentBytes as hashEditableArtifactMutationIntentBytes2
|
|
30
31
|
} from "@opengeni/contracts/editable-artifacts";
|
|
31
32
|
import {
|
|
33
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
32
34
|
decodeCommittedTransactionSummary as decodeCommittedTransactionSummary2,
|
|
33
35
|
MAX_COMMITTED_TRANSACTION_BYTES
|
|
34
36
|
} from "@opengeni/contracts/editable-artifact-committed-transaction";
|
|
35
37
|
import { editableArtifactCodecFor as editableArtifactCodecFor2 } from "@opengeni/contracts/editable-artifact-codec-registry";
|
|
38
|
+
import { EDITABLE_ARTIFACT_LIVE_WIRE_VERSION } from "@opengeni/contracts/editable-artifact-live";
|
|
36
39
|
import { decodeEditableArtifactSerializedCommit as decodeEditableArtifactSerializedCommit2 } from "@opengeni/contracts/editable-artifact-serialized-commit";
|
|
40
|
+
import { SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION } from "@opengeni/contracts/editable-artifact-versions";
|
|
37
41
|
|
|
38
42
|
// src/editable-artifacts/errors.ts
|
|
39
43
|
var EditableArtifactSyncError = class extends Error {
|
|
@@ -61,6 +65,67 @@ var EditableArtifactTransportError = class extends Error {
|
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
|
|
68
|
+
// src/editable-artifacts/open-failure.ts
|
|
69
|
+
var BYTE_CORRUPTION_CODES = /* @__PURE__ */ new Set([
|
|
70
|
+
"byte_corruption",
|
|
71
|
+
"artifact_bad_magic",
|
|
72
|
+
"artifact_checksum_mismatch",
|
|
73
|
+
"artifact_invalid_collaboration_snapshot",
|
|
74
|
+
"artifact_invalid_snapshot",
|
|
75
|
+
"artifact_invalid_tag",
|
|
76
|
+
"artifact_invalid_utf8",
|
|
77
|
+
"artifact_non_canonical",
|
|
78
|
+
"artifact_trailing_bytes",
|
|
79
|
+
"artifact_truncated"
|
|
80
|
+
]);
|
|
81
|
+
var AUTHORED_CAUSAL_CODES = /* @__PURE__ */ new Set([
|
|
82
|
+
"artifact_state_mismatch",
|
|
83
|
+
"authored_causal_mismatch",
|
|
84
|
+
"committed_metadata_mismatch",
|
|
85
|
+
"invalid_frontier",
|
|
86
|
+
"kernel_diverged"
|
|
87
|
+
]);
|
|
88
|
+
var RUNTIME_PACKAGE_CODES = /* @__PURE__ */ new Set([
|
|
89
|
+
"artifact_runtime_incompatible",
|
|
90
|
+
"artifact_runtime_integrity",
|
|
91
|
+
"artifact_runtime_manifest_invalid",
|
|
92
|
+
"artifact_runtime_unavailable",
|
|
93
|
+
"artifact_runtime_unsupported_target",
|
|
94
|
+
"incompatible_wasm_build",
|
|
95
|
+
"runtime_identity_mismatch"
|
|
96
|
+
]);
|
|
97
|
+
function classifyEditableArtifactOpenFailure(error) {
|
|
98
|
+
const code = normalizedErrorCode(error);
|
|
99
|
+
if (code === null) return null;
|
|
100
|
+
let category = null;
|
|
101
|
+
if (code === "unsupported_protocol" || code === "artifact_unsupported_version") {
|
|
102
|
+
category = "unsupported_old_format";
|
|
103
|
+
} else if (BYTE_CORRUPTION_CODES.has(code)) {
|
|
104
|
+
category = "byte_corruption";
|
|
105
|
+
} else if (AUTHORED_CAUSAL_CODES.has(code)) {
|
|
106
|
+
category = "authored_causal_mismatch";
|
|
107
|
+
} else if (RUNTIME_PACKAGE_CODES.has(code)) {
|
|
108
|
+
category = "runtime_package_mismatch";
|
|
109
|
+
} else if (code === "artifact_runtime_projection_parity") {
|
|
110
|
+
category = "projection_parity_ci_failure";
|
|
111
|
+
}
|
|
112
|
+
return category === null ? null : Object.freeze({ category, code });
|
|
113
|
+
}
|
|
114
|
+
function normalizedErrorCode(error) {
|
|
115
|
+
if (typeof error !== "object" || error === null) return null;
|
|
116
|
+
let descriptor;
|
|
117
|
+
try {
|
|
118
|
+
descriptor = Object.getOwnPropertyDescriptor(error, "code");
|
|
119
|
+
} catch {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
if (!descriptor || !("value" in descriptor)) return null;
|
|
123
|
+
const value = descriptor.value;
|
|
124
|
+
if (typeof value !== "string") return null;
|
|
125
|
+
const code = value.toLowerCase();
|
|
126
|
+
return /^[a-z][a-z0-9_]{0,127}$/u.test(code) ? code : null;
|
|
127
|
+
}
|
|
128
|
+
|
|
64
129
|
// src/editable-artifacts/storage.ts
|
|
65
130
|
import {
|
|
66
131
|
assertCanonicalSpreadsheetArtifactCommandBytes,
|
|
@@ -111,7 +176,7 @@ var MemoryEditableArtifactStorage = class {
|
|
|
111
176
|
cursor: replica.head.cursor,
|
|
112
177
|
stateHash: replica.head.stateHash,
|
|
113
178
|
modality: replica.head.modality,
|
|
114
|
-
...replica.head.snapshot.modality === "spreadsheet" ? {
|
|
179
|
+
...replica.head.snapshot.modality === "spreadsheet" ? { operationProtocolVersion: replica.head.snapshot.operationProtocolVersion } : {}
|
|
115
180
|
},
|
|
116
181
|
input
|
|
117
182
|
);
|
|
@@ -177,7 +242,7 @@ var MemoryEditableArtifactStorage = class {
|
|
|
177
242
|
if (namespace?.size === 0) this.#pending.delete(scope.namespace);
|
|
178
243
|
}
|
|
179
244
|
};
|
|
180
|
-
var DATABASE_VERSION =
|
|
245
|
+
var DATABASE_VERSION = 4;
|
|
181
246
|
var REPLICA_HEAD_STORE = "replicas";
|
|
182
247
|
var SNAPSHOT_STORE = "snapshots";
|
|
183
248
|
var COMMITTED_STORE = "committedTransactions";
|
|
@@ -271,7 +336,7 @@ var IndexedDbEditableArtifactStorage = class {
|
|
|
271
336
|
assertStoredHeadAccounting(head, tail.length, retainedTailBytes);
|
|
272
337
|
const {
|
|
273
338
|
namespace: _headNamespace,
|
|
274
|
-
|
|
339
|
+
operationProtocolVersion: retainedOperationProtocolVersion,
|
|
275
340
|
tailCount: _tailCount,
|
|
276
341
|
tailBytes: _tailBytes,
|
|
277
342
|
...storedHead
|
|
@@ -281,11 +346,10 @@ var IndexedDbEditableArtifactStorage = class {
|
|
|
281
346
|
const normalizedTail = tail.map(
|
|
282
347
|
({ namespace: _transactionNamespace, ...value }) => normalizeStoredCommitted(value, ownedScope.modality)
|
|
283
348
|
).sort(compareCommittedTransactions);
|
|
284
|
-
|
|
285
|
-
if (headModality !== ownedScope.modality) {
|
|
349
|
+
if (head.modality !== ownedScope.modality) {
|
|
286
350
|
throw new TypeError("retained head modality does not match its storage scope");
|
|
287
351
|
}
|
|
288
|
-
if (storedSnapshot.modality === "spreadsheet" &&
|
|
352
|
+
if (storedSnapshot.modality === "spreadsheet" && retainedOperationProtocolVersion !== storedSnapshot.operationProtocolVersion)
|
|
289
353
|
throw new TypeError("retained head protocol does not match its snapshot");
|
|
290
354
|
const replica = {
|
|
291
355
|
...storedHead,
|
|
@@ -501,7 +565,11 @@ function assertStoredReplica(replica) {
|
|
|
501
565
|
assertSha256(replica.snapshot.digest, "snapshot.digest");
|
|
502
566
|
if (replica.snapshot.modality === "spreadsheet") {
|
|
503
567
|
assertFrontier(replica.snapshot.causalFrontier, "snapshot.causalFrontier");
|
|
504
|
-
assertPositiveInteger(
|
|
568
|
+
assertPositiveInteger(
|
|
569
|
+
replica.snapshot.operationProtocolVersion,
|
|
570
|
+
"snapshot.operationProtocolVersion"
|
|
571
|
+
);
|
|
572
|
+
assertPositiveInteger(replica.snapshot.snapshotVersion, "snapshot.snapshotVersion");
|
|
505
573
|
} else {
|
|
506
574
|
assertSequence(replica.snapshot.nativeRevision, "snapshot.nativeRevision");
|
|
507
575
|
}
|
|
@@ -529,7 +597,7 @@ function assertStoredReplica(replica) {
|
|
|
529
597
|
if (transaction.startSequence !== cursor + 1) {
|
|
530
598
|
throw new TypeError("stored committed tail must be contiguous after its snapshot");
|
|
531
599
|
}
|
|
532
|
-
if (transaction.modality === "spreadsheet" && replica.snapshot.modality === "spreadsheet" && transaction.
|
|
600
|
+
if (transaction.modality === "spreadsheet" && replica.snapshot.modality === "spreadsheet" && transaction.operationProtocolVersion !== replica.snapshot.operationProtocolVersion)
|
|
533
601
|
throw new TypeError("stored committed tail protocol does not match its snapshot");
|
|
534
602
|
if (transaction.modality !== "spreadsheet") {
|
|
535
603
|
if (nativeRevision !== transaction.priorNativeRevision) {
|
|
@@ -631,9 +699,9 @@ function assertCommittedTransaction(transaction, artifactId) {
|
|
|
631
699
|
}
|
|
632
700
|
if (transaction.modality === "spreadsheet") {
|
|
633
701
|
assertFrontier(transaction.causalFrontier, "causalFrontier");
|
|
634
|
-
assertPositiveInteger(transaction.
|
|
702
|
+
assertPositiveInteger(transaction.operationProtocolVersion, "operationProtocolVersion");
|
|
635
703
|
const summary2 = decodeCommittedTransactionSummary(transaction.committedTransactionBytes);
|
|
636
|
-
if (summary2.transactionId !== transaction.transactionId || summary2.operationProtocolVersion !== transaction.
|
|
704
|
+
if (summary2.transactionId !== transaction.transactionId || summary2.operationProtocolVersion !== transaction.operationProtocolVersion || summary2.priorStateHash !== transaction.priorStateHash || summary2.stateHash !== transaction.stateHash || !frontiersEqual(summary2.resultingCausalFrontier, transaction.causalFrontier))
|
|
637
705
|
throw new TypeError("committed fields do not exactly match their OGACO envelope");
|
|
638
706
|
return;
|
|
639
707
|
}
|
|
@@ -701,13 +769,12 @@ function assertAppendCanApply(head, input) {
|
|
|
701
769
|
`artifact ${input.artifactId} retained head no longer matches append expectation`
|
|
702
770
|
);
|
|
703
771
|
}
|
|
704
|
-
|
|
705
|
-
if (input.transaction.modality !== headModality) {
|
|
772
|
+
if (input.transaction.modality !== head.modality) {
|
|
706
773
|
throw new EditableArtifactStorageConflictError(
|
|
707
774
|
`artifact ${input.artifactId} append modality does not match retained snapshot`
|
|
708
775
|
);
|
|
709
776
|
}
|
|
710
|
-
if (input.transaction.modality === "spreadsheet" && input.transaction.
|
|
777
|
+
if (input.transaction.modality === "spreadsheet" && input.transaction.operationProtocolVersion !== head.operationProtocolVersion) {
|
|
711
778
|
throw new EditableArtifactStorageConflictError(
|
|
712
779
|
`artifact ${input.artifactId} append protocol does not match retained snapshot`
|
|
713
780
|
);
|
|
@@ -746,7 +813,7 @@ function pendingTransactionsEqual(left, right) {
|
|
|
746
813
|
return left.artifactId === right.artifactId && left.modality === right.modality && left.clientTransactionId === right.clientTransactionId && left.requestHash === right.requestHash && left.protocolVersion === right.protocolVersion && left.modelSchemaVersion === right.modelSchemaVersion && left.commandVersion === right.commandVersion && left.replicaId === right.replicaId && left.replicaCounter === right.replicaCounter && left.previousLocalTransactionId === right.previousLocalTransactionId && left.observedHeadSequence === right.observedHeadSequence && left.createdAt === right.createdAt && (left.modality === "spreadsheet" && right.modality === "spreadsheet" ? frontiersEqual(left.causalBase, right.causalBase) && identifiersEqual(left.selectiveUndoTargets, right.selectiveUndoTargets) : left.modality !== "spreadsheet" && right.modality !== "spreadsheet" && left.observedNativeRevision === right.observedNativeRevision) && bytesEqual(left.commandBytes, right.commandBytes) && bytesEqual(left.intentBytes, right.intentBytes);
|
|
747
814
|
}
|
|
748
815
|
function committedTransactionsEqual(left, right) {
|
|
749
|
-
return left.artifactId === right.artifactId && left.modality === right.modality && left.transactionId === right.transactionId && left.requestHash === right.requestHash && left.startSequence === right.startSequence && left.endSequence === right.endSequence && left.priorStateHash === right.priorStateHash && left.stateHash === right.stateHash && (left.modality === "spreadsheet" && right.modality === "spreadsheet" ? left.
|
|
816
|
+
return left.artifactId === right.artifactId && left.modality === right.modality && left.transactionId === right.transactionId && left.requestHash === right.requestHash && left.startSequence === right.startSequence && left.endSequence === right.endSequence && left.priorStateHash === right.priorStateHash && left.stateHash === right.stateHash && (left.modality === "spreadsheet" && right.modality === "spreadsheet" ? left.operationProtocolVersion === right.operationProtocolVersion && frontiersEqual(left.causalFrontier, right.causalFrontier) : left.modality !== "spreadsheet" && right.modality !== "spreadsheet" && left.priorNativeRevision === right.priorNativeRevision && left.nativeRevision === right.nativeRevision && left.commitProtocolVersion === right.commitProtocolVersion) && bytesEqual(left.committedTransactionBytes, right.committedTransactionBytes);
|
|
750
817
|
}
|
|
751
818
|
function frontiersEqual(left, right) {
|
|
752
819
|
return left.length === right.length && left.every(
|
|
@@ -790,22 +857,19 @@ function assertScopeModality(scope, modality) {
|
|
|
790
857
|
}
|
|
791
858
|
}
|
|
792
859
|
function normalizeStoredSnapshot(snapshot, modality) {
|
|
793
|
-
|
|
794
|
-
if (retainedModality !== modality) {
|
|
860
|
+
if (snapshot.modality !== modality) {
|
|
795
861
|
throw new TypeError("retained snapshot modality does not match its storage scope");
|
|
796
862
|
}
|
|
797
863
|
return { ...snapshot, modality };
|
|
798
864
|
}
|
|
799
865
|
function normalizeStoredCommitted(transaction, modality) {
|
|
800
|
-
|
|
801
|
-
if (retainedModality !== modality) {
|
|
866
|
+
if (transaction.modality !== modality) {
|
|
802
867
|
throw new TypeError("retained transaction modality does not match its storage scope");
|
|
803
868
|
}
|
|
804
869
|
return { ...transaction, modality };
|
|
805
870
|
}
|
|
806
871
|
function normalizeStoredPending(transaction, modality) {
|
|
807
|
-
|
|
808
|
-
if (retainedModality !== modality) {
|
|
872
|
+
if (transaction.modality !== modality) {
|
|
809
873
|
throw new TypeError("retained pending modality does not match its storage scope");
|
|
810
874
|
}
|
|
811
875
|
return { ...transaction, modality };
|
|
@@ -912,14 +976,10 @@ function openDatabase(factory, databaseName) {
|
|
|
912
976
|
};
|
|
913
977
|
request.onupgradeneeded = (event) => {
|
|
914
978
|
const database = request.result;
|
|
915
|
-
if (event.oldVersion <
|
|
979
|
+
if (event.oldVersion < DATABASE_VERSION) {
|
|
916
980
|
for (const name of [REPLICA_HEAD_STORE, SNAPSHOT_STORE, PENDING_STORE, COMMITTED_STORE]) {
|
|
917
981
|
if (database.objectStoreNames.contains(name)) database.deleteObjectStore(name);
|
|
918
982
|
}
|
|
919
|
-
} else if (event.oldVersion < 3) {
|
|
920
|
-
for (const name of [REPLICA_HEAD_STORE, SNAPSHOT_STORE, COMMITTED_STORE]) {
|
|
921
|
-
if (database.objectStoreNames.contains(name)) database.deleteObjectStore(name);
|
|
922
|
-
}
|
|
923
983
|
}
|
|
924
984
|
if (!database.objectStoreNames.contains(REPLICA_HEAD_STORE)) {
|
|
925
985
|
database.createObjectStore(REPLICA_HEAD_STORE, {
|
|
@@ -1001,7 +1061,9 @@ function replaceIndexedDbReplica(database, scope, replica, expectedHead) {
|
|
|
1001
1061
|
stateHash: replica.stateHash,
|
|
1002
1062
|
updatedAt: replica.updatedAt,
|
|
1003
1063
|
modality: replica.modality,
|
|
1004
|
-
...replica.snapshot.modality === "spreadsheet" ? {
|
|
1064
|
+
...replica.snapshot.modality === "spreadsheet" ? {
|
|
1065
|
+
operationProtocolVersion: replica.snapshot.operationProtocolVersion
|
|
1066
|
+
} : {},
|
|
1005
1067
|
tailCount: replica.tail.length,
|
|
1006
1068
|
tailBytes: committedTailBytes(replica.tail)
|
|
1007
1069
|
};
|
|
@@ -1283,7 +1345,6 @@ function putIndexedDbPending(database, scope, value) {
|
|
|
1283
1345
|
}
|
|
1284
1346
|
|
|
1285
1347
|
// src/editable-artifacts/controller.ts
|
|
1286
|
-
var DEFAULT_PROTOCOL_VERSION = 1;
|
|
1287
1348
|
var DEFAULT_REPLAY_PAGE_SIZE = 256;
|
|
1288
1349
|
var DEFAULT_MAX_QUEUE_MESSAGES = 512;
|
|
1289
1350
|
var DEFAULT_MAX_QUEUE_BYTES = 8 * 1024 * 1024;
|
|
@@ -1330,6 +1391,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1330
1391
|
maxReconnectAttempts;
|
|
1331
1392
|
scheduler;
|
|
1332
1393
|
clientTransactionIdFactory;
|
|
1394
|
+
onOpenFailure;
|
|
1333
1395
|
abortController = new AbortController();
|
|
1334
1396
|
listeners = /* @__PURE__ */ new Set();
|
|
1335
1397
|
liveWaiters = /* @__PURE__ */ new Set();
|
|
@@ -1396,10 +1458,10 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1396
1458
|
);
|
|
1397
1459
|
this.modelSchemaVersion = positiveSafeInteger(options.modelSchemaVersion, "modelSchemaVersion");
|
|
1398
1460
|
this.commandVersion = positiveSafeInteger(options.commandVersion, "commandVersion");
|
|
1399
|
-
this.protocolVersion = positiveSafeInteger(
|
|
1400
|
-
|
|
1401
|
-
"protocolVersion"
|
|
1402
|
-
|
|
1461
|
+
this.protocolVersion = positiveSafeInteger(options.protocolVersion, "protocolVersion");
|
|
1462
|
+
if (this.protocolVersion !== EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION) {
|
|
1463
|
+
throw new TypeError("protocolVersion is incompatible with the current intent protocol");
|
|
1464
|
+
}
|
|
1403
1465
|
this.replayPageSize = positiveSafeInteger(
|
|
1404
1466
|
options.replayPageSize ?? DEFAULT_REPLAY_PAGE_SIZE,
|
|
1405
1467
|
"replayPageSize"
|
|
@@ -1458,12 +1520,14 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1458
1520
|
this.maxReconnectAttempts = options.maxReconnectAttempts === void 0 ? Number.POSITIVE_INFINITY : nonNegativeSafeInteger(options.maxReconnectAttempts, "maxReconnectAttempts");
|
|
1459
1521
|
this.scheduler = options.scheduler ?? defaultScheduler;
|
|
1460
1522
|
this.clientTransactionIdFactory = options.clientTransactionIdFactory ?? (() => crypto.randomUUID());
|
|
1523
|
+
this.onOpenFailure = options.onOpenFailure;
|
|
1461
1524
|
}
|
|
1462
1525
|
start() {
|
|
1463
1526
|
if (this.runTask || this.state === "closed") return;
|
|
1464
1527
|
this.runTask = this.run().catch((error) => {
|
|
1465
1528
|
if (this.abortController.signal.aborted) return;
|
|
1466
1529
|
const failure = asError(error);
|
|
1530
|
+
this.reportOpenFailure(failure);
|
|
1467
1531
|
if (failure instanceof EditableArtifactSyncError && failure.code === "unsupported_protocol") {
|
|
1468
1532
|
this.lastError = failure;
|
|
1469
1533
|
this.setState("unsupported");
|
|
@@ -1748,7 +1812,8 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1748
1812
|
try {
|
|
1749
1813
|
await this.restoreReplica(stored);
|
|
1750
1814
|
await this.replacePendingOverlay();
|
|
1751
|
-
} catch {
|
|
1815
|
+
} catch (error) {
|
|
1816
|
+
this.reportOpenFailure(error);
|
|
1752
1817
|
await this.kernel.reset();
|
|
1753
1818
|
this.replica = null;
|
|
1754
1819
|
this.retainedTailTransactions = 0;
|
|
@@ -1763,8 +1828,8 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1763
1828
|
stored.snapshot,
|
|
1764
1829
|
this.artifactId,
|
|
1765
1830
|
this.modality,
|
|
1766
|
-
|
|
1767
|
-
|
|
1831
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
1832
|
+
SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION,
|
|
1768
1833
|
this.modelSchemaVersion,
|
|
1769
1834
|
this.maxSnapshotBytes
|
|
1770
1835
|
);
|
|
@@ -1787,7 +1852,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1787
1852
|
transaction,
|
|
1788
1853
|
this.artifactId,
|
|
1789
1854
|
this.modality,
|
|
1790
|
-
|
|
1855
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
1791
1856
|
this.maxCommittedTransactionBytes
|
|
1792
1857
|
);
|
|
1793
1858
|
if (transaction.startSequence !== cursor + 1) {
|
|
@@ -1851,6 +1916,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1851
1916
|
delayMs = this.reconnectDelayMs;
|
|
1852
1917
|
}
|
|
1853
1918
|
const failure = asError(error);
|
|
1919
|
+
this.reportOpenFailure(failure);
|
|
1854
1920
|
this.lastError = failure;
|
|
1855
1921
|
if (failure instanceof EditableArtifactSyncError && failure.requiresSnapshot) {
|
|
1856
1922
|
this.requireSnapshot = true;
|
|
@@ -2001,11 +2067,11 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2001
2067
|
if (bootstrap.modality !== this.modality) {
|
|
2002
2068
|
throw invalidBootstrap("bootstrap modality does not match the controller");
|
|
2003
2069
|
}
|
|
2004
|
-
this.
|
|
2005
|
-
if (bootstrap.
|
|
2070
|
+
this.requireLiveProtocol(bootstrap.liveProtocolVersion);
|
|
2071
|
+
if (bootstrap.modelSchemaVersion !== this.modelSchemaVersion) {
|
|
2006
2072
|
throw new EditableArtifactSyncError(
|
|
2007
2073
|
"unsupported_protocol",
|
|
2008
|
-
`artifact
|
|
2074
|
+
`artifact schema ${bootstrap.modelSchemaVersion} is incompatible with ${this.modelSchemaVersion}`
|
|
2009
2075
|
);
|
|
2010
2076
|
}
|
|
2011
2077
|
requireSha256(bootstrap.headStateHash, "bootstrap.headStateHash");
|
|
@@ -2064,8 +2130,8 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2064
2130
|
snapshot,
|
|
2065
2131
|
this.artifactId,
|
|
2066
2132
|
this.modality,
|
|
2067
|
-
|
|
2068
|
-
|
|
2133
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2134
|
+
SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION,
|
|
2069
2135
|
this.modelSchemaVersion,
|
|
2070
2136
|
this.maxSnapshotBytes
|
|
2071
2137
|
);
|
|
@@ -2154,7 +2220,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2154
2220
|
transaction,
|
|
2155
2221
|
this.artifactId,
|
|
2156
2222
|
this.modality,
|
|
2157
|
-
|
|
2223
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2158
2224
|
this.maxCommittedTransactionBytes
|
|
2159
2225
|
);
|
|
2160
2226
|
pageBytes += estimateCommittedTransactionBytes(transaction);
|
|
@@ -2184,7 +2250,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2184
2250
|
message,
|
|
2185
2251
|
this.artifactId,
|
|
2186
2252
|
this.modality,
|
|
2187
|
-
|
|
2253
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2188
2254
|
this.maxCommittedTransactionBytes
|
|
2189
2255
|
);
|
|
2190
2256
|
bytes = estimateLiveMessageBytes(message);
|
|
@@ -2270,7 +2336,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2270
2336
|
transaction,
|
|
2271
2337
|
this.artifactId,
|
|
2272
2338
|
this.modality,
|
|
2273
|
-
|
|
2339
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2274
2340
|
this.maxCommittedTransactionBytes
|
|
2275
2341
|
);
|
|
2276
2342
|
if (embeddedPending) {
|
|
@@ -2508,7 +2574,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2508
2574
|
receipt.committed,
|
|
2509
2575
|
this.artifactId,
|
|
2510
2576
|
this.modality,
|
|
2511
|
-
|
|
2577
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2512
2578
|
this.maxCommittedTransactionBytes
|
|
2513
2579
|
);
|
|
2514
2580
|
this.recordAcceptedMapping(receipt);
|
|
@@ -2566,7 +2632,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2566
2632
|
"sync ticket is not bound to the requested writer replica"
|
|
2567
2633
|
);
|
|
2568
2634
|
}
|
|
2569
|
-
this.
|
|
2635
|
+
this.requireLiveProtocol(ticket.protocolVersion);
|
|
2570
2636
|
boundedNonEmpty(ticket.token, "ticket.token", MAX_TICKET_BYTES);
|
|
2571
2637
|
const expiresAt = Date.parse(ticket.expiresAt);
|
|
2572
2638
|
if (!Number.isFinite(expiresAt)) {
|
|
@@ -2661,11 +2727,11 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2661
2727
|
(left, right) => compareCodeUnits(left.clientTransactionId, right.clientTransactionId)
|
|
2662
2728
|
);
|
|
2663
2729
|
}
|
|
2664
|
-
|
|
2665
|
-
if (actual !==
|
|
2730
|
+
requireLiveProtocol(actual) {
|
|
2731
|
+
if (actual !== EDITABLE_ARTIFACT_LIVE_WIRE_VERSION) {
|
|
2666
2732
|
throw new EditableArtifactSyncError(
|
|
2667
2733
|
"unsupported_protocol",
|
|
2668
|
-
`
|
|
2734
|
+
`live protocol ${actual} is incompatible with ${EDITABLE_ARTIFACT_LIVE_WIRE_VERSION}`
|
|
2669
2735
|
);
|
|
2670
2736
|
}
|
|
2671
2737
|
}
|
|
@@ -2691,6 +2757,14 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2691
2757
|
for (const waiter of this.liveWaiters) waiter.reject(error);
|
|
2692
2758
|
this.liveWaiters.clear();
|
|
2693
2759
|
}
|
|
2760
|
+
reportOpenFailure(error) {
|
|
2761
|
+
const event = classifyEditableArtifactOpenFailure(error);
|
|
2762
|
+
if (event === null || this.onOpenFailure === void 0) return;
|
|
2763
|
+
try {
|
|
2764
|
+
this.onOpenFailure(event);
|
|
2765
|
+
} catch {
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2694
2768
|
fail(error) {
|
|
2695
2769
|
this.lastError = error;
|
|
2696
2770
|
this.setState("failed");
|
|
@@ -2796,7 +2870,7 @@ function bytesEqual2(left, right) {
|
|
|
2796
2870
|
}
|
|
2797
2871
|
return true;
|
|
2798
2872
|
}
|
|
2799
|
-
function validateCommittedTransaction(transaction, artifactId, modality,
|
|
2873
|
+
function validateCommittedTransaction(transaction, artifactId, modality, operationProtocolVersion, maxCommittedTransactionBytes) {
|
|
2800
2874
|
if (transaction.artifactId !== artifactId || transaction.modality !== modality) {
|
|
2801
2875
|
throw invalidSequence("transaction artifact authority mismatch");
|
|
2802
2876
|
}
|
|
@@ -2819,10 +2893,10 @@ function validateCommittedTransaction(transaction, artifactId, modality, protoco
|
|
|
2819
2893
|
throw invalidSequence("transaction committedTransactionBytes exceeds the configured bound");
|
|
2820
2894
|
}
|
|
2821
2895
|
if (transaction.modality === "spreadsheet") {
|
|
2822
|
-
if (transaction.
|
|
2896
|
+
if (transaction.operationProtocolVersion !== operationProtocolVersion) {
|
|
2823
2897
|
throw new EditableArtifactSyncError(
|
|
2824
2898
|
"unsupported_protocol",
|
|
2825
|
-
`transaction protocol ${transaction.
|
|
2899
|
+
`transaction operation protocol ${transaction.operationProtocolVersion} is incompatible with ${operationProtocolVersion}`
|
|
2826
2900
|
);
|
|
2827
2901
|
}
|
|
2828
2902
|
validateFrontier(transaction.causalFrontier, "causalFrontier");
|
|
@@ -2832,7 +2906,7 @@ function validateCommittedTransaction(transaction, artifactId, modality, protoco
|
|
|
2832
2906
|
} catch (error) {
|
|
2833
2907
|
throw invalidSequence(`invalid OGACO envelope: ${asError(error).message}`);
|
|
2834
2908
|
}
|
|
2835
|
-
if (summary2.transactionId !== transaction.transactionId || summary2.operationProtocolVersion !== transaction.
|
|
2909
|
+
if (summary2.transactionId !== transaction.transactionId || summary2.operationProtocolVersion !== transaction.operationProtocolVersion || summary2.priorStateHash !== transaction.priorStateHash || summary2.stateHash !== transaction.stateHash || !frontiersEqual2(summary2.resultingCausalFrontier, transaction.causalFrontier)) {
|
|
2836
2910
|
throw invalidSequence("committed routing fields do not exactly match the OGACO envelope");
|
|
2837
2911
|
}
|
|
2838
2912
|
return null;
|
|
@@ -2857,7 +2931,7 @@ function validateCommittedTransaction(transaction, artifactId, modality, protoco
|
|
|
2857
2931
|
intentBytes: summary.intentBytes
|
|
2858
2932
|
});
|
|
2859
2933
|
}
|
|
2860
|
-
function validateSnapshot(snapshot, artifactId, modality,
|
|
2934
|
+
function validateSnapshot(snapshot, artifactId, modality, operationProtocolVersion, snapshotVersion, modelSchemaVersion, maxSnapshotBytes) {
|
|
2861
2935
|
if (snapshot.artifactId !== artifactId || snapshot.modality !== modality) {
|
|
2862
2936
|
throw invalidBootstrap("snapshot artifact authority mismatch");
|
|
2863
2937
|
}
|
|
@@ -2868,19 +2942,19 @@ function validateSnapshot(snapshot, artifactId, modality, protocolVersion, kerne
|
|
|
2868
2942
|
positiveSafeInteger(snapshot.modelSchemaVersion, "snapshot.modelSchemaVersion");
|
|
2869
2943
|
if (snapshot.modality === "spreadsheet") {
|
|
2870
2944
|
validateFrontier(snapshot.causalFrontier, "snapshot.causalFrontier");
|
|
2871
|
-
if (snapshot.
|
|
2945
|
+
if (snapshot.operationProtocolVersion !== operationProtocolVersion || snapshot.snapshotVersion !== snapshotVersion) {
|
|
2872
2946
|
throw new EditableArtifactSyncError(
|
|
2873
2947
|
"unsupported_protocol",
|
|
2874
|
-
`snapshot
|
|
2948
|
+
`snapshot operation/state versions ${snapshot.operationProtocolVersion}/${snapshot.snapshotVersion} are incompatible with ${operationProtocolVersion}/${snapshotVersion}`
|
|
2875
2949
|
);
|
|
2876
2950
|
}
|
|
2877
2951
|
} else {
|
|
2878
2952
|
requireNativeRevision(snapshot.nativeRevision, "snapshot.nativeRevision");
|
|
2879
2953
|
}
|
|
2880
|
-
if (snapshot.
|
|
2954
|
+
if (snapshot.modelSchemaVersion !== modelSchemaVersion) {
|
|
2881
2955
|
throw new EditableArtifactSyncError(
|
|
2882
2956
|
"unsupported_protocol",
|
|
2883
|
-
`snapshot
|
|
2957
|
+
`snapshot schema ${snapshot.modelSchemaVersion} is incompatible with ${modelSchemaVersion}`
|
|
2884
2958
|
);
|
|
2885
2959
|
}
|
|
2886
2960
|
if (!(snapshot.bytes instanceof Uint8Array)) {
|
|
@@ -2909,7 +2983,7 @@ function validateFrontier(frontier, label) {
|
|
|
2909
2983
|
previous = entry.replicaId;
|
|
2910
2984
|
}
|
|
2911
2985
|
}
|
|
2912
|
-
function validateLiveMessage(message, artifactId, modality,
|
|
2986
|
+
function validateLiveMessage(message, artifactId, modality, operationProtocolVersion, maxCommittedTransactionBytes) {
|
|
2913
2987
|
if (!message || typeof message !== "object") {
|
|
2914
2988
|
throw invalidSequence("live message must be an object");
|
|
2915
2989
|
}
|
|
@@ -2918,7 +2992,7 @@ function validateLiveMessage(message, artifactId, modality, protocolVersion, max
|
|
|
2918
2992
|
message.transaction,
|
|
2919
2993
|
artifactId,
|
|
2920
2994
|
modality,
|
|
2921
|
-
|
|
2995
|
+
operationProtocolVersion,
|
|
2922
2996
|
maxCommittedTransactionBytes
|
|
2923
2997
|
);
|
|
2924
2998
|
return;
|
|
@@ -2963,7 +3037,7 @@ function estimateCommittedTransactionBytes(transaction) {
|
|
|
2963
3037
|
function requireStateHash(actual, expected, source) {
|
|
2964
3038
|
if (actual !== expected) {
|
|
2965
3039
|
throw new EditableArtifactSyncError(
|
|
2966
|
-
"
|
|
3040
|
+
"authored_causal_mismatch",
|
|
2967
3041
|
`${source} produced state hash ${actual}; expected ${expected}`,
|
|
2968
3042
|
{ retryable: true, requiresSnapshot: true }
|
|
2969
3043
|
);
|
|
@@ -2973,7 +3047,7 @@ function requireDigest(actual, expected, source) {
|
|
|
2973
3047
|
requireSha256(actual, `${source} computed digest`);
|
|
2974
3048
|
if (actual !== expected) {
|
|
2975
3049
|
throw new EditableArtifactSyncError(
|
|
2976
|
-
"
|
|
3050
|
+
"byte_corruption",
|
|
2977
3051
|
`${source} bytes produced digest ${actual}; expected ${expected}`,
|
|
2978
3052
|
{ retryable: true, requiresSnapshot: true }
|
|
2979
3053
|
);
|
|
@@ -2984,7 +3058,7 @@ function requireFrontier(actual, expected, source) {
|
|
|
2984
3058
|
(entry, index) => entry.replicaId !== expected[index]?.replicaId || entry.counter !== expected[index]?.counter
|
|
2985
3059
|
)) {
|
|
2986
3060
|
throw new EditableArtifactSyncError(
|
|
2987
|
-
"
|
|
3061
|
+
"authored_causal_mismatch",
|
|
2988
3062
|
`${source} causal frontier does not match the authoritative barrier`,
|
|
2989
3063
|
{ retryable: true, requiresSnapshot: true }
|
|
2990
3064
|
);
|
|
@@ -3111,7 +3185,7 @@ function requireNativeRevisionEqual(actual, expected, source) {
|
|
|
3111
3185
|
requireNativeRevision(expected, `${source} expected native revision`);
|
|
3112
3186
|
if (actual !== expected) {
|
|
3113
3187
|
throw new EditableArtifactSyncError(
|
|
3114
|
-
"
|
|
3188
|
+
"authored_causal_mismatch",
|
|
3115
3189
|
`${source} native revision ${actual} does not match ${expected}`,
|
|
3116
3190
|
{ retryable: true, requiresSnapshot: true }
|
|
3117
3191
|
);
|
|
@@ -3292,9 +3366,11 @@ var defaultScheduler = {
|
|
|
3292
3366
|
};
|
|
3293
3367
|
|
|
3294
3368
|
// src/editable-artifacts/browser-session.ts
|
|
3295
|
-
import {
|
|
3296
|
-
import {
|
|
3297
|
-
|
|
3369
|
+
import { EDITABLE_ARTIFACT_LIVE_WIRE_VERSION as EDITABLE_ARTIFACT_LIVE_WIRE_VERSION2 } from "@opengeni/contracts/editable-artifact-live";
|
|
3370
|
+
import {
|
|
3371
|
+
EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION as EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION2,
|
|
3372
|
+
currentEditableArtifactCompatibility as currentEditableArtifactCompatibility2
|
|
3373
|
+
} from "@opengeni/contracts/editable-artifacts";
|
|
3298
3374
|
|
|
3299
3375
|
// src/editable-artifacts/http-live-transport.ts
|
|
3300
3376
|
import {
|
|
@@ -3307,11 +3383,12 @@ import {
|
|
|
3307
3383
|
EDITABLE_ARTIFACT_COMMAND_MAX_BYTES as EDITABLE_ARTIFACT_COMMAND_MAX_BYTES3,
|
|
3308
3384
|
EDITABLE_ARTIFACT_INTENT_MAX_BYTES as EDITABLE_ARTIFACT_INTENT_MAX_BYTES3,
|
|
3309
3385
|
EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES as EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES3,
|
|
3386
|
+
currentEditableArtifactCompatibility,
|
|
3310
3387
|
hashEditableArtifactMutationIntentBytes as hashEditableArtifactMutationIntentBytes3
|
|
3311
3388
|
} from "@opengeni/contracts/editable-artifacts";
|
|
3312
3389
|
import { MAX_COMMITTED_TRANSACTION_BYTES as MAX_COMMITTED_TRANSACTION_BYTES2 } from "@opengeni/contracts/editable-artifact-committed-transaction";
|
|
3313
3390
|
var LIVE_PATH = "/v1/editable-artifacts/live";
|
|
3314
|
-
var LIVE_SUBPROTOCOL = "opengeni-artifact-
|
|
3391
|
+
var LIVE_SUBPROTOCOL = "opengeni-artifact-v2";
|
|
3315
3392
|
var DEFAULT_MAX_SERVER_FRAME_BYTES = 8 * 1024 * 1024 + 64 * 1024;
|
|
3316
3393
|
var DEFAULT_MAX_SNAPSHOT_BYTES2 = EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES3;
|
|
3317
3394
|
var DEFAULT_HANDSHAKE_TIMEOUT_MS = 2e4;
|
|
@@ -3327,9 +3404,13 @@ var HttpLiveTransport = class {
|
|
|
3327
3404
|
baseUrl;
|
|
3328
3405
|
socketUrl;
|
|
3329
3406
|
workspaceId;
|
|
3330
|
-
|
|
3407
|
+
modality;
|
|
3408
|
+
liveProtocolVersion;
|
|
3331
3409
|
kernelVersion;
|
|
3332
3410
|
modelSchemaVersion;
|
|
3411
|
+
snapshotVersion;
|
|
3412
|
+
commandProtocolVersion;
|
|
3413
|
+
committedTransactionProtocolVersion;
|
|
3333
3414
|
apiKey;
|
|
3334
3415
|
headerSource;
|
|
3335
3416
|
credentials;
|
|
@@ -3345,9 +3426,34 @@ var HttpLiveTransport = class {
|
|
|
3345
3426
|
const insecure = options.allowInsecureDevelopmentTransport ?? false;
|
|
3346
3427
|
requireTransportSecurity(this.baseUrl, this.socketUrl, insecure);
|
|
3347
3428
|
this.workspaceId = boundedString(options.workspaceId, "workspaceId", 256);
|
|
3348
|
-
|
|
3429
|
+
const current = currentEditableArtifactCompatibility(options.modality);
|
|
3430
|
+
this.modality = options.modality;
|
|
3431
|
+
this.liveProtocolVersion = exactVersion(
|
|
3432
|
+
options.liveProtocolVersion,
|
|
3433
|
+
current.liveProtocolVersion,
|
|
3434
|
+
"liveProtocolVersion"
|
|
3435
|
+
);
|
|
3349
3436
|
this.kernelVersion = boundedString(options.kernelVersion, "kernelVersion", 512);
|
|
3350
|
-
this.modelSchemaVersion =
|
|
3437
|
+
this.modelSchemaVersion = exactVersion(
|
|
3438
|
+
options.modelSchemaVersion,
|
|
3439
|
+
current.modelSchemaVersion,
|
|
3440
|
+
"modelSchemaVersion"
|
|
3441
|
+
);
|
|
3442
|
+
this.snapshotVersion = exactVersion(
|
|
3443
|
+
options.snapshotVersion,
|
|
3444
|
+
current.snapshotVersion,
|
|
3445
|
+
"snapshotVersion"
|
|
3446
|
+
);
|
|
3447
|
+
this.commandProtocolVersion = exactVersion(
|
|
3448
|
+
options.commandProtocolVersion,
|
|
3449
|
+
current.commandProtocolVersion,
|
|
3450
|
+
"commandProtocolVersion"
|
|
3451
|
+
);
|
|
3452
|
+
this.committedTransactionProtocolVersion = exactVersion(
|
|
3453
|
+
options.committedTransactionProtocolVersion,
|
|
3454
|
+
current.committedTransactionProtocolVersion,
|
|
3455
|
+
"committedTransactionProtocolVersion"
|
|
3456
|
+
);
|
|
3351
3457
|
this.apiKey = options.apiKey;
|
|
3352
3458
|
if (this.apiKey !== void 0) boundedString(this.apiKey, "apiKey", 16 * 1024);
|
|
3353
3459
|
this.headerSource = options.headers;
|
|
@@ -3395,9 +3501,13 @@ var HttpLiveTransport = class {
|
|
|
3395
3501
|
},
|
|
3396
3502
|
body: JSON.stringify({
|
|
3397
3503
|
replicaId: input.replicaId,
|
|
3398
|
-
|
|
3504
|
+
modality: this.modality,
|
|
3505
|
+
liveProtocolVersion: this.liveProtocolVersion,
|
|
3399
3506
|
kernelVersion: this.kernelVersion,
|
|
3400
|
-
modelSchemaVersion: this.modelSchemaVersion
|
|
3507
|
+
modelSchemaVersion: this.modelSchemaVersion,
|
|
3508
|
+
snapshotVersion: this.snapshotVersion,
|
|
3509
|
+
commandProtocolVersion: this.commandProtocolVersion,
|
|
3510
|
+
committedTransactionProtocolVersion: this.committedTransactionProtocolVersion
|
|
3401
3511
|
}),
|
|
3402
3512
|
signal: input.signal
|
|
3403
3513
|
});
|
|
@@ -3419,7 +3529,7 @@ var HttpLiveTransport = class {
|
|
|
3419
3529
|
);
|
|
3420
3530
|
}
|
|
3421
3531
|
const value = await readBoundedJson(response, MAX_TICKET_RESPONSE_BYTES);
|
|
3422
|
-
return validateTicket(value, input.artifactId, input.replicaId, this.
|
|
3532
|
+
return validateTicket(value, input.artifactId, input.replicaId, this.liveProtocolVersion);
|
|
3423
3533
|
}
|
|
3424
3534
|
async openLive(input) {
|
|
3425
3535
|
if (input.resume.modality !== input.ticket.modality) {
|
|
@@ -3438,6 +3548,7 @@ var HttpLiveTransport = class {
|
|
|
3438
3548
|
};
|
|
3439
3549
|
const resume = input.resume.modality === "spreadsheet" ? {
|
|
3440
3550
|
...commonResume,
|
|
3551
|
+
modality: "spreadsheet",
|
|
3441
3552
|
localCausalFrontier: cloneFrontier3(input.resume.causalFrontier)
|
|
3442
3553
|
} : {
|
|
3443
3554
|
...commonResume,
|
|
@@ -3593,7 +3704,7 @@ var HttpLiveConnection = class {
|
|
|
3593
3704
|
}
|
|
3594
3705
|
const commonBootstrap = {
|
|
3595
3706
|
artifactId: this.ticket.artifactId,
|
|
3596
|
-
|
|
3707
|
+
liveProtocolVersion: this.ticket.protocolVersion,
|
|
3597
3708
|
headSequence: boundarySequence,
|
|
3598
3709
|
headStateHash: boundaryStateHash,
|
|
3599
3710
|
kernelVersion: snapshot?.kernelVersion ?? this.kernelVersion,
|
|
@@ -3667,12 +3778,6 @@ var HttpLiveConnection = class {
|
|
|
3667
3778
|
if (pending.artifactId !== this.ticket.artifactId) {
|
|
3668
3779
|
throw new TypeError("pending transaction belongs to another artifact");
|
|
3669
3780
|
}
|
|
3670
|
-
if (pending.protocolVersion !== this.ticket.protocolVersion) {
|
|
3671
|
-
throw new EditableArtifactTransportError("pending protocol does not match live stream", {
|
|
3672
|
-
code: "unsupported",
|
|
3673
|
-
retryable: false
|
|
3674
|
-
});
|
|
3675
|
-
}
|
|
3676
3781
|
if (pending.commandBytes.byteLength > Math.min(open.maxCommandBytes, EDITABLE_ARTIFACT_COMMAND_MAX_BYTES3)) {
|
|
3677
3782
|
throw new EditableArtifactTransportError("pending command exceeds negotiated live limit", {
|
|
3678
3783
|
code: "limit_exceeded",
|
|
@@ -3693,7 +3798,7 @@ var HttpLiveConnection = class {
|
|
|
3693
3798
|
}
|
|
3694
3799
|
const frame = encodeEditableArtifactLiveMutationWireFrame({
|
|
3695
3800
|
type: "mutation",
|
|
3696
|
-
protocolVersion:
|
|
3801
|
+
protocolVersion: this.ticket.protocolVersion,
|
|
3697
3802
|
artifactId: pending.artifactId,
|
|
3698
3803
|
streamEpoch: open.streamEpoch,
|
|
3699
3804
|
requestHash: pending.requestHash,
|
|
@@ -3850,11 +3955,9 @@ var HttpLiveConnection = class {
|
|
|
3850
3955
|
if (frame.transaction.artifactId !== this.ticket.artifactId) {
|
|
3851
3956
|
throw new TypeError("live transaction belongs to another artifact");
|
|
3852
3957
|
}
|
|
3853
|
-
if (
|
|
3958
|
+
if (frame.transaction.modality !== this.ticket.modality) {
|
|
3854
3959
|
throw new TypeError("live transaction modality mismatch");
|
|
3855
3960
|
}
|
|
3856
|
-
if ((frame.transaction.modality === void 0 || frame.transaction.modality === "spreadsheet") && frame.transaction.protocolVersion !== this.ticket.protocolVersion)
|
|
3857
|
-
throw new TypeError("live transaction protocol mismatch");
|
|
3858
3961
|
if (frame.transaction.committedTransactionBytes.byteLength > this.limits.maxCommittedTransactionBytes) {
|
|
3859
3962
|
throw new RangeError("live transaction exceeds negotiated committed byte limit");
|
|
3860
3963
|
}
|
|
@@ -3933,7 +4036,7 @@ var HttpLiveConnection = class {
|
|
|
3933
4036
|
if (frame.protocolVersion !== this.ticket.protocolVersion) {
|
|
3934
4037
|
throw new TypeError("live snapshot protocol mismatch");
|
|
3935
4038
|
}
|
|
3936
|
-
if (
|
|
4039
|
+
if (frame.modality !== this.ticket.modality) {
|
|
3937
4040
|
throw new TypeError("live snapshot modality mismatch");
|
|
3938
4041
|
}
|
|
3939
4042
|
if (this.snapshotAssembly === null) {
|
|
@@ -3968,7 +4071,8 @@ var HttpLiveConnection = class {
|
|
|
3968
4071
|
...commonSnapshot,
|
|
3969
4072
|
modality: "spreadsheet",
|
|
3970
4073
|
causalFrontier: cloneFrontier3(frame.causalFrontier),
|
|
3971
|
-
|
|
4074
|
+
operationProtocolVersion: frame.operationProtocolVersion,
|
|
4075
|
+
snapshotVersion: frame.snapshotVersion
|
|
3972
4076
|
}) : Object.freeze({
|
|
3973
4077
|
...commonSnapshot,
|
|
3974
4078
|
modality: requireSerializedModality(frame.modality),
|
|
@@ -4027,7 +4131,7 @@ var HttpLiveConnection = class {
|
|
|
4027
4131
|
if (frame.protocolVersion !== this.ticket.protocolVersion) {
|
|
4028
4132
|
throw new TypeError("live server frame protocol mismatch");
|
|
4029
4133
|
}
|
|
4030
|
-
if (frame.type === "open" &&
|
|
4134
|
+
if (frame.type === "open" && frame.modality !== this.ticket.modality) {
|
|
4031
4135
|
throw new TypeError("live open modality does not match its ticket");
|
|
4032
4136
|
}
|
|
4033
4137
|
if (this.openFrame && frame.streamEpoch !== this.openFrame.streamEpoch) {
|
|
@@ -4145,12 +4249,6 @@ function cloneCommitted2(transaction) {
|
|
|
4145
4249
|
committedTransactionBytes: transaction.committedTransactionBytes.slice()
|
|
4146
4250
|
};
|
|
4147
4251
|
}
|
|
4148
|
-
function transactionModality(transaction) {
|
|
4149
|
-
return transaction.modality ?? "spreadsheet";
|
|
4150
|
-
}
|
|
4151
|
-
function serverModality(value) {
|
|
4152
|
-
return value ?? "spreadsheet";
|
|
4153
|
-
}
|
|
4154
4252
|
function serializedBoundaryRevision(snapshot, resume, modality) {
|
|
4155
4253
|
if (snapshot !== null) {
|
|
4156
4254
|
if (snapshot.modality !== modality) throw new TypeError("snapshot modality mismatch");
|
|
@@ -4166,8 +4264,7 @@ function serializedBoundaryRevision(snapshot, resume, modality) {
|
|
|
4166
4264
|
return resume.localNativeRevision;
|
|
4167
4265
|
}
|
|
4168
4266
|
function snapshotChunkAuthorityEqual(frame, metadata) {
|
|
4169
|
-
|
|
4170
|
-
if (modality !== serverModality(metadata.modality)) return false;
|
|
4267
|
+
if (frame.modality !== metadata.modality) return false;
|
|
4171
4268
|
if ("causalFrontier" in frame) {
|
|
4172
4269
|
if (!("causalFrontier" in metadata)) return false;
|
|
4173
4270
|
return frontiersEqual3(frame.causalFrontier, metadata.causalFrontier);
|
|
@@ -4382,6 +4479,13 @@ function positiveU162(value, label) {
|
|
|
4382
4479
|
const number = positiveBounded(value, 65535, label);
|
|
4383
4480
|
return number;
|
|
4384
4481
|
}
|
|
4482
|
+
function exactVersion(value, expected, label) {
|
|
4483
|
+
const actual = positiveU162(value, label);
|
|
4484
|
+
if (actual !== expected) {
|
|
4485
|
+
throw new TypeError(`${label} ${actual} is incompatible with current version ${expected}`);
|
|
4486
|
+
}
|
|
4487
|
+
return actual;
|
|
4488
|
+
}
|
|
4385
4489
|
function positiveBounded(value, maximum, label) {
|
|
4386
4490
|
if (!Number.isSafeInteger(value) || value <= 0 || value > maximum) {
|
|
4387
4491
|
throw new TypeError(`${label} is invalid`);
|
|
@@ -5753,17 +5857,20 @@ function createBrowserEditableArtifactSession(options) {
|
|
|
5753
5857
|
const baseUrl = canonicalBaseUrl(options.baseUrl);
|
|
5754
5858
|
const workspaceId = boundedIdentity(options.workspaceId, "workspaceId");
|
|
5755
5859
|
assertCacheAuthority(options.storageAuthority, baseUrl, workspaceId);
|
|
5756
|
-
const protocolVersion = positiveVersion2(options.runtime.protocolVersion
|
|
5860
|
+
const protocolVersion = positiveVersion2(options.runtime.protocolVersion, "protocolVersion");
|
|
5861
|
+
if (protocolVersion !== EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION2) {
|
|
5862
|
+
throw new TypeError("protocolVersion is incompatible with the current intent protocol");
|
|
5863
|
+
}
|
|
5757
5864
|
const modelSchemaVersion = positiveVersion2(
|
|
5758
5865
|
options.runtime.modelSchemaVersion,
|
|
5759
5866
|
"modelSchemaVersion"
|
|
5760
5867
|
);
|
|
5761
5868
|
const kernelVersion = boundedIdentity(options.runtime.kernelVersion, "kernelVersion", 512);
|
|
5762
5869
|
const commandVersion = positiveVersion2(options.runtime.commandVersion, "commandVersion");
|
|
5763
|
-
const
|
|
5764
|
-
if (commandVersion !==
|
|
5870
|
+
const current = currentEditableArtifactCompatibility2(options.artifact.modality);
|
|
5871
|
+
if (modelSchemaVersion !== current.modelSchemaVersion || commandVersion !== current.commandProtocolVersion) {
|
|
5765
5872
|
throw new TypeError(
|
|
5766
|
-
`
|
|
5873
|
+
`runtime versions are incompatible with current ${options.artifact.modality} compatibility`
|
|
5767
5874
|
);
|
|
5768
5875
|
}
|
|
5769
5876
|
const {
|
|
@@ -5787,9 +5894,13 @@ function createBrowserEditableArtifactSession(options) {
|
|
|
5787
5894
|
...options.transport,
|
|
5788
5895
|
baseUrl,
|
|
5789
5896
|
workspaceId,
|
|
5790
|
-
|
|
5897
|
+
modality: options.artifact.modality,
|
|
5898
|
+
liveProtocolVersion: EDITABLE_ARTIFACT_LIVE_WIRE_VERSION2,
|
|
5791
5899
|
kernelVersion,
|
|
5792
|
-
modelSchemaVersion
|
|
5900
|
+
modelSchemaVersion,
|
|
5901
|
+
snapshotVersion: current.snapshotVersion,
|
|
5902
|
+
commandProtocolVersion: current.commandProtocolVersion,
|
|
5903
|
+
committedTransactionProtocolVersion: current.committedTransactionProtocolVersion
|
|
5793
5904
|
});
|
|
5794
5905
|
return createEditableArtifactSession({
|
|
5795
5906
|
artifactId: options.artifact.id,
|
|
@@ -5802,6 +5913,7 @@ function createBrowserEditableArtifactSession(options) {
|
|
|
5802
5913
|
modelSchemaVersion,
|
|
5803
5914
|
commandVersion,
|
|
5804
5915
|
protocolVersion,
|
|
5916
|
+
...options.onOpenFailure ? { onOpenFailure: options.onOpenFailure } : {},
|
|
5805
5917
|
...replicaId ? { writerReplicaIdFactory: () => replicaId } : {},
|
|
5806
5918
|
ownsWorker: true
|
|
5807
5919
|
});
|
|
@@ -5816,16 +5928,6 @@ function createEditableArtifactReplicaId() {
|
|
|
5816
5928
|
if (value !== "0000000000000000") return value;
|
|
5817
5929
|
}
|
|
5818
5930
|
}
|
|
5819
|
-
function commandVersionFor(modality) {
|
|
5820
|
-
switch (modality) {
|
|
5821
|
-
case "spreadsheet":
|
|
5822
|
-
return SPREADSHEET_ARTIFACT_COMMAND_VERSION2;
|
|
5823
|
-
case "document":
|
|
5824
|
-
return DOCUMENT_ARTIFACT_COMMAND_VERSION2;
|
|
5825
|
-
case "presentation":
|
|
5826
|
-
return PRESENTATION_ARTIFACT_COMMAND_VERSION2;
|
|
5827
|
-
}
|
|
5828
|
-
}
|
|
5829
5931
|
function canonicalBaseUrl(value) {
|
|
5830
5932
|
const url = new URL(value);
|
|
5831
5933
|
if (url.username || url.password || url.search || url.hash) {
|
|
@@ -5908,16 +6010,16 @@ var EditableArtifactSyncPool = class {
|
|
|
5908
6010
|
|
|
5909
6011
|
// src/editable-artifacts/index.ts
|
|
5910
6012
|
import {
|
|
5911
|
-
SPREADSHEET_ARTIFACT_COMMAND_VERSION as
|
|
6013
|
+
SPREADSHEET_ARTIFACT_COMMAND_VERSION as SPREADSHEET_ARTIFACT_COMMAND_VERSION2,
|
|
5912
6014
|
editableArtifactStableId as editableArtifactStableId2,
|
|
5913
6015
|
spreadsheetSheetId as spreadsheetSheetId3
|
|
5914
6016
|
} from "@opengeni/contracts/spreadsheet-artifact-commands";
|
|
5915
6017
|
import {
|
|
5916
|
-
DOCUMENT_ARTIFACT_COMMAND_VERSION as
|
|
6018
|
+
DOCUMENT_ARTIFACT_COMMAND_VERSION as DOCUMENT_ARTIFACT_COMMAND_VERSION2,
|
|
5917
6019
|
encodeDocumentArtifactCommandBatch as encodeDocumentArtifactCommandBatch2
|
|
5918
6020
|
} from "@opengeni/contracts/document-artifact-commands";
|
|
5919
6021
|
import {
|
|
5920
|
-
PRESENTATION_ARTIFACT_COMMAND_VERSION as
|
|
6022
|
+
PRESENTATION_ARTIFACT_COMMAND_VERSION as PRESENTATION_ARTIFACT_COMMAND_VERSION2,
|
|
5921
6023
|
PRESENTATION_ARTIFACT_QUERY_MAX_NODES,
|
|
5922
6024
|
PRESENTATION_ARTIFACT_QUERY_MAX_SLIDES,
|
|
5923
6025
|
PRESENTATION_ARTIFACT_QUERY_MAX_TEXT_BYTES,
|
|
@@ -5926,19 +6028,20 @@ import {
|
|
|
5926
6028
|
} from "@opengeni/contracts/presentation-artifact-commands";
|
|
5927
6029
|
export {
|
|
5928
6030
|
ArtifactWorkerClientError,
|
|
5929
|
-
|
|
6031
|
+
DOCUMENT_ARTIFACT_COMMAND_VERSION2 as DOCUMENT_ARTIFACT_COMMAND_VERSION,
|
|
5930
6032
|
EditableArtifactStorageConflictError,
|
|
5931
6033
|
EditableArtifactSyncError,
|
|
5932
6034
|
EditableArtifactSyncPool,
|
|
5933
6035
|
EditableArtifactTransportError,
|
|
5934
6036
|
IndexedDbEditableArtifactStorage,
|
|
5935
6037
|
MemoryEditableArtifactStorage,
|
|
5936
|
-
|
|
6038
|
+
PRESENTATION_ARTIFACT_COMMAND_VERSION2 as PRESENTATION_ARTIFACT_COMMAND_VERSION,
|
|
5937
6039
|
PRESENTATION_ARTIFACT_QUERY_MAX_NODES,
|
|
5938
6040
|
PRESENTATION_ARTIFACT_QUERY_MAX_SLIDES,
|
|
5939
6041
|
PRESENTATION_ARTIFACT_QUERY_MAX_TEXT_BYTES,
|
|
5940
6042
|
PRESENTATION_ARTIFACT_QUERY_RESPONSE_MAX_BYTES,
|
|
5941
|
-
|
|
6043
|
+
SPREADSHEET_ARTIFACT_COMMAND_VERSION2 as SPREADSHEET_ARTIFACT_COMMAND_VERSION,
|
|
6044
|
+
classifyEditableArtifactOpenFailure,
|
|
5942
6045
|
createBrowserEditableArtifactSession,
|
|
5943
6046
|
createBrowserEditableArtifactWorkerKernel,
|
|
5944
6047
|
createEditableArtifactHttpLiveTransport,
|