@opengeni/sdk 0.57.0 → 1.0.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 +1017 -26
- package/dist/accounts.d.ts +153 -0
- package/dist/accounts.js +307 -0
- package/dist/accounts.js.map +1 -0
- package/dist/adapters/express.d.ts +31 -0
- package/dist/adapters/express.js +87 -0
- package/dist/adapters/express.js.map +1 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +8 -0
- package/dist/adapters/hono.js.map +1 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +22 -0
- package/dist/adapters/next.js.map +1 -0
- package/dist/allowance-refusal.d.ts +2 -0
- package/dist/allowance-refusal.js +50 -0
- package/dist/allowance-refusal.js.map +1 -0
- package/dist/artifact-catalog.d.ts +31 -0
- package/dist/artifact-client.d.ts +23 -11
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +7 -5
- package/dist/automations-client.d.ts +17 -0
- package/dist/automations.d.ts +3 -0
- package/dist/automations.js +84 -0
- package/dist/automations.js.map +1 -0
- package/dist/browser.d.ts +11 -0
- package/dist/browser.js +47 -0
- package/dist/browser.js.map +1 -0
- package/dist/chat/fold.d.ts +75 -0
- package/dist/chat/handler.d.ts +41 -0
- package/dist/chat/http.d.ts +67 -0
- package/dist/chat/ids.d.ts +34 -0
- package/dist/chat/index.d.ts +9 -0
- package/dist/chat/index.js +1694 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/openai.d.ts +30 -0
- package/dist/chat/opengeni.d.ts +128 -0
- package/dist/chat/types.d.ts +207 -0
- package/dist/chat/vercel.d.ts +49 -0
- package/dist/chats.d.ts +8 -0
- package/dist/{chunk-JDLDDRNE.js → chunk-2UXZUCEZ.js} +291 -34
- package/dist/chunk-2UXZUCEZ.js.map +1 -0
- package/dist/chunk-4SMEOV3P.js +246 -0
- package/dist/chunk-4SMEOV3P.js.map +1 -0
- package/dist/{chunk-JRPFWI6T.js → chunk-AH5D5Q5V.js} +31 -35
- package/dist/chunk-AH5D5Q5V.js.map +1 -0
- package/dist/chunk-APXVSSSY.js +301 -0
- package/dist/chunk-APXVSSSY.js.map +1 -0
- package/dist/chunk-DUVIYER4.js +639 -0
- package/dist/chunk-DUVIYER4.js.map +1 -0
- package/dist/{chunk-PKQ377ED.js → chunk-FG3OO5LM.js} +2686 -611
- package/dist/chunk-FG3OO5LM.js.map +1 -0
- package/dist/chunk-GZYZT22T.js +260 -0
- package/dist/chunk-GZYZT22T.js.map +1 -0
- package/dist/chunk-HMGADJGZ.js +150 -0
- package/dist/chunk-HMGADJGZ.js.map +1 -0
- package/dist/{chunk-YKZME56C.js → chunk-KWADQ227.js} +3 -3
- package/dist/{chunk-YKZME56C.js.map → chunk-KWADQ227.js.map} +1 -1
- package/dist/chunk-LY2K6ELJ.js +126 -0
- package/dist/chunk-LY2K6ELJ.js.map +1 -0
- package/dist/chunk-MOTJYIYL.js +340 -0
- package/dist/chunk-MOTJYIYL.js.map +1 -0
- package/dist/{chunk-ST5DDKJP.js → chunk-NC57YMUO.js} +121 -3
- package/dist/chunk-NC57YMUO.js.map +1 -0
- package/dist/chunk-RWKB6YZG.js +1270 -0
- package/dist/chunk-RWKB6YZG.js.map +1 -0
- package/dist/chunk-U6CV2SXO.js +195 -0
- package/dist/chunk-U6CV2SXO.js.map +1 -0
- package/dist/chunk-UM4ZXXJR.js +9 -0
- package/dist/chunk-UM4ZXXJR.js.map +1 -0
- package/dist/chunk-V6GIY62B.js +229 -0
- package/dist/chunk-V6GIY62B.js.map +1 -0
- package/dist/chunk-WU6GQG25.js +268 -0
- package/dist/chunk-WU6GQG25.js.map +1 -0
- package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
- package/dist/chunk-XNG7YGR3.js.map +1 -0
- package/dist/{chunk-HJ3HHUT5.js → chunk-YIKA2QT4.js} +33 -2
- package/dist/chunk-YIKA2QT4.js.map +1 -0
- package/dist/chunk-ZKPY6YAJ.js +135 -0
- package/dist/chunk-ZKPY6YAJ.js.map +1 -0
- package/dist/client.d.ts +740 -94
- package/dist/codex-realtime-controller.d.ts +3 -0
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/codex-realtime-v3.d.ts +13 -2
- package/dist/company-brain.d.ts +22 -0
- package/dist/company-profile.d.ts +14 -1
- package/dist/core.d.ts +9 -3
- package/dist/core.js +25 -6
- package/dist/deprecation.d.ts +47 -0
- package/dist/document-authority-client.d.ts +51 -0
- package/dist/document-authority.d.ts +2 -0
- package/dist/document-authority.js +12 -0
- package/dist/document-authority.js.map +1 -0
- 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 +6 -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 +240 -121
- package/dist/editable-artifacts.js.map +1 -1
- package/dist/embedding-client.d.ts +129 -0
- package/dist/errors.d.ts +36 -1
- package/dist/feedback.d.ts +23 -0
- package/dist/gateway-realtime-transport.js +1 -1
- package/dist/github-repositories.d.ts +10 -0
- package/dist/github-repositories.js +36 -0
- package/dist/github-repositories.js.map +1 -0
- package/dist/index.d.ts +56 -11
- package/dist/index.js +242 -125
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +84 -1
- package/dist/interaction.js +6 -1
- package/dist/knowledge.d.ts +7 -0
- package/dist/knowledge.js +20 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/message-links.d.ts +68 -0
- package/dist/model-context.d.ts +68 -0
- package/dist/model-display.d.ts +2 -0
- package/dist/model-display.js +15 -0
- package/dist/model-display.js.map +1 -0
- package/dist/model-picker-order.d.ts +1 -0
- package/dist/model-picker-order.js +10 -0
- package/dist/model-picker-order.js.map +1 -0
- package/dist/organization-integration-policy.d.ts +26 -0
- package/dist/organization-integration-policy.js +26 -0
- package/dist/organization-integration-policy.js.map +1 -0
- 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/organization-user-setup.d.ts +8 -0
- package/dist/organization-user-setup.js +16 -0
- package/dist/organization-user-setup.js.map +1 -0
- package/dist/pr-review-client.d.ts +16 -0
- package/dist/pr-review.d.ts +4 -0
- package/dist/pr-review.js +62 -0
- package/dist/pr-review.js.map +1 -0
- package/dist/preference-registry.d.ts +9 -1
- package/dist/proxy.d.ts +7 -5
- package/dist/realtime.d.ts +3 -1
- package/dist/realtime.js +6 -6
- package/dist/realtime.js.map +1 -1
- package/dist/retained-artifacts.d.ts +5 -1
- package/dist/session-history-import.d.ts +22 -0
- package/dist/session-history-import.js +36 -0
- package/dist/session-history-import.js.map +1 -0
- package/dist/session-list-entries.d.ts +1 -0
- package/dist/session-list-entries.js +7 -0
- package/dist/session-list-entries.js.map +1 -0
- package/dist/session-message-search.d.ts +53 -0
- package/dist/session-proxy-client.d.ts +24 -0
- package/dist/session-proxy.d.ts +245 -0
- package/dist/session-proxy.js +24 -0
- package/dist/session-proxy.js.map +1 -0
- package/dist/session-titles.d.ts +2 -0
- package/dist/site-browser-entry.d.ts +1 -0
- package/dist/site-browser-runtime.gen.d.ts +1 -0
- package/dist/site-document.d.ts +5 -0
- package/dist/site-document.js +20 -0
- package/dist/site-document.js.map +1 -0
- package/dist/site-document.test.d.ts +1 -0
- package/dist/site-http.d.ts +16 -0
- package/dist/site-tool-bridge.d.ts +44 -0
- package/dist/site.d.ts +101 -0
- package/dist/site.js +49 -0
- package/dist/site.js.map +1 -0
- package/dist/skills.d.ts +75 -0
- package/dist/stream.d.ts +2 -0
- package/dist/tenant-workspaces.d.ts +47 -0
- package/dist/tenant-workspaces.js +8 -0
- package/dist/tenant-workspaces.js.map +1 -0
- package/dist/tool-auth.d.ts +87 -0
- package/dist/tool-auth.js +23 -0
- package/dist/tool-auth.js.map +1 -0
- package/dist/tool-display-metadata.d.ts +3 -0
- package/dist/tools-FXBLUWAE.js +12 -0
- package/dist/tools-FXBLUWAE.js.map +1 -0
- package/dist/tools.d.ts +61 -0
- package/dist/types.d.ts +2863 -424
- package/dist/usage-allowances.d.ts +36 -0
- package/dist/usage-allowances.js +80 -0
- package/dist/usage-allowances.js.map +1 -0
- package/dist/workspace-artifacts.d.ts +33 -5
- package/dist/workspace-instruction-policies.d.ts +24 -2
- package/dist/workspace-integrations.d.ts +74 -0
- package/dist/workspace-integrations.js +65 -0
- package/dist/workspace-integrations.js.map +1 -0
- package/dist/workspace-learning.d.ts +124 -0
- package/dist/workspace-state.d.ts +8 -71
- package/package.json +108 -3
- package/src/accounts.ts +443 -0
- package/src/adapters/express.ts +136 -0
- package/src/adapters/hono.ts +18 -0
- package/src/adapters/next.ts +42 -0
- package/src/allowance-refusal.ts +5 -0
- package/src/artifact-catalog.ts +41 -0
- package/src/artifact-client.ts +43 -52
- package/src/artifacts.ts +7 -1
- package/src/automations-client.ts +124 -0
- package/src/automations.ts +15 -0
- package/src/browser.ts +54 -0
- package/src/chat/fold.ts +431 -0
- package/src/chat/handler.ts +240 -0
- package/src/chat/http.ts +257 -0
- package/src/chat/ids.ts +85 -0
- package/src/chat/index.ts +87 -0
- package/src/chat/openai.ts +439 -0
- package/src/chat/opengeni.ts +722 -0
- package/src/chat/types.ts +219 -0
- package/src/chat/vercel.ts +204 -0
- package/src/chats.ts +16 -0
- package/src/client.ts +4084 -515
- package/src/codex-realtime-controller.ts +235 -5
- package/src/codex-realtime-v3.ts +162 -31
- package/src/codex-realtime.ts +1 -1
- package/src/company-brain.ts +59 -0
- package/src/company-profile.ts +17 -1
- package/src/core.ts +23 -1
- package/src/deprecation.ts +149 -0
- package/src/document-authority-client.ts +219 -0
- package/src/document-authority.ts +17 -0
- package/src/editable-artifacts/browser-session.ts +36 -22
- package/src/editable-artifacts/controller.ts +102 -47
- 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 +6 -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/embedding-client.ts +519 -0
- package/src/errors.ts +169 -2
- package/src/feedback.ts +20 -0
- package/src/gateway-realtime-transport.ts +3 -3
- package/src/github-repositories.ts +60 -0
- package/src/index.ts +561 -41
- package/src/interaction.ts +276 -4
- package/src/knowledge.ts +72 -0
- package/src/message-links.ts +178 -0
- package/src/model-context.ts +112 -0
- package/src/model-display.ts +10 -0
- package/src/model-picker-order.ts +6 -0
- package/src/organization-integration-policy.ts +54 -0
- package/src/organization-private-session-settings.ts +33 -0
- package/src/organization-user-setup.ts +31 -0
- package/src/pr-review-client.ts +92 -0
- package/src/pr-review.ts +17 -0
- package/src/preference-registry.ts +11 -0
- package/src/proxy.ts +17 -6
- package/src/realtime.ts +1 -0
- package/src/retained-artifacts.ts +101 -0
- package/src/session-history-import.ts +84 -0
- package/src/session-list-entries.ts +1 -0
- package/src/session-message-search.ts +47 -0
- package/src/session-proxy-client.ts +64 -0
- package/src/session-proxy.ts +1473 -0
- package/src/session-titles.ts +10 -0
- package/src/site-browser-entry.ts +6 -0
- package/src/site-browser-runtime.gen.ts +2 -0
- package/src/site-document.test.ts +64 -0
- package/src/site-document.ts +18 -0
- package/src/site-http.ts +162 -0
- package/src/site-tool-bridge.ts +146 -0
- package/src/site.ts +585 -0
- package/src/skills.ts +69 -0
- package/src/sse.ts +8 -2
- package/src/stream.ts +38 -4
- package/src/tenant-workspaces.ts +148 -0
- package/src/tool-auth.ts +301 -0
- package/src/tool-display-metadata.ts +19 -0
- package/src/tools.ts +396 -0
- package/src/types.ts +3346 -501
- package/src/usage-allowances.ts +189 -0
- package/src/workspace-artifacts.ts +40 -6
- package/src/workspace-instruction-policies.ts +26 -1
- package/src/workspace-integrations.ts +402 -0
- package/src/workspace-learning.ts +138 -0
- package/src/workspace-state.ts +8 -82
- package/dist/chunk-GU6JF75T.js +0 -119
- package/dist/chunk-GU6JF75T.js.map +0 -1
- package/dist/chunk-HJ3HHUT5.js.map +0 -1
- package/dist/chunk-JDLDDRNE.js.map +0 -1
- package/dist/chunk-JRPFWI6T.js.map +0 -1
- package/dist/chunk-PKQ377ED.js.map +0 -1
- package/dist/chunk-ST5DDKJP.js.map +0 -1
- package/dist/chunk-VWE2QIVO.js.map +0 -1
|
@@ -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-YIKA2QT4.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");
|
|
@@ -1498,6 +1562,10 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1498
1562
|
this.rejectLiveWaiters(new Error("artifact sync controller closed"));
|
|
1499
1563
|
}
|
|
1500
1564
|
getView() {
|
|
1565
|
+
const blockedPending = this.allBlockedPending();
|
|
1566
|
+
const authoringBlockedReason = this.modality !== "spreadsheet" && blockedPending.length > 0 ? "pending_conflict" : this.orderedPending().some(
|
|
1567
|
+
(transaction) => transaction.replicaId !== this.writerReplicaId
|
|
1568
|
+
) ? "prior_writer" : void 0;
|
|
1501
1569
|
return {
|
|
1502
1570
|
artifactId: this.artifactId,
|
|
1503
1571
|
modality: this.modality,
|
|
@@ -1506,7 +1574,8 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1506
1574
|
headSequence: this.headSequence,
|
|
1507
1575
|
writable: this.writable,
|
|
1508
1576
|
pendingTransactions: this.pending.size,
|
|
1509
|
-
blockedPending
|
|
1577
|
+
blockedPending,
|
|
1578
|
+
authoringBlockedReason,
|
|
1510
1579
|
queuedMessages: this.liveQueue.length,
|
|
1511
1580
|
reconnectAttempt: this.reconnectAttempt,
|
|
1512
1581
|
lastError: this.lastError
|
|
@@ -1748,7 +1817,8 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1748
1817
|
try {
|
|
1749
1818
|
await this.restoreReplica(stored);
|
|
1750
1819
|
await this.replacePendingOverlay();
|
|
1751
|
-
} catch {
|
|
1820
|
+
} catch (error) {
|
|
1821
|
+
this.reportOpenFailure(error);
|
|
1752
1822
|
await this.kernel.reset();
|
|
1753
1823
|
this.replica = null;
|
|
1754
1824
|
this.retainedTailTransactions = 0;
|
|
@@ -1763,8 +1833,8 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1763
1833
|
stored.snapshot,
|
|
1764
1834
|
this.artifactId,
|
|
1765
1835
|
this.modality,
|
|
1766
|
-
|
|
1767
|
-
|
|
1836
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
1837
|
+
SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION,
|
|
1768
1838
|
this.modelSchemaVersion,
|
|
1769
1839
|
this.maxSnapshotBytes
|
|
1770
1840
|
);
|
|
@@ -1782,12 +1852,13 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1782
1852
|
let stateHash = stored.snapshot.stateHash;
|
|
1783
1853
|
let causalFrontier = stored.snapshot.modality === "spreadsheet" ? stored.snapshot.causalFrontier : null;
|
|
1784
1854
|
let nativeRevision = stored.snapshot.modality === "spreadsheet" ? null : stored.snapshot.nativeRevision;
|
|
1855
|
+
const retainedAcceptances = [];
|
|
1785
1856
|
for (const transaction of stored.tail) {
|
|
1786
|
-
validateCommittedTransaction(
|
|
1857
|
+
const embeddedPending = validateCommittedTransaction(
|
|
1787
1858
|
transaction,
|
|
1788
1859
|
this.artifactId,
|
|
1789
1860
|
this.modality,
|
|
1790
|
-
|
|
1861
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
1791
1862
|
this.maxCommittedTransactionBytes
|
|
1792
1863
|
);
|
|
1793
1864
|
if (transaction.startSequence !== cursor + 1) {
|
|
@@ -1796,6 +1867,12 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1796
1867
|
requireStateHash(transaction.priorStateHash, stateHash, "retained transaction prior state");
|
|
1797
1868
|
const applied = await this.kernel.applyRecovered(transaction);
|
|
1798
1869
|
requireStateHash(applied.stateHash, transaction.stateHash, "retained transaction");
|
|
1870
|
+
if (embeddedPending) {
|
|
1871
|
+
const pending = this.pending.get(embeddedPending.clientTransactionId);
|
|
1872
|
+
if (pending?.requestHash === embeddedPending.requestHash && bytesEqual2(pending.intentBytes, embeddedPending.intentBytes)) {
|
|
1873
|
+
retainedAcceptances.push({ transaction, pending: embeddedPending });
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1799
1876
|
cursor = transaction.endSequence;
|
|
1800
1877
|
stateHash = transaction.stateHash;
|
|
1801
1878
|
if (transaction.modality === "spreadsheet") {
|
|
@@ -1828,6 +1905,10 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1828
1905
|
this.retainedTailTransactions = stored.tail.length;
|
|
1829
1906
|
this.cursor = cursor;
|
|
1830
1907
|
this.headSequence = cursor;
|
|
1908
|
+
for (const { transaction, pending } of retainedAcceptances) {
|
|
1909
|
+
this.recordAcceptedMappingIdentity(transaction.transactionId, pending);
|
|
1910
|
+
await this.settlePending(transaction, true);
|
|
1911
|
+
}
|
|
1831
1912
|
}
|
|
1832
1913
|
async run() {
|
|
1833
1914
|
await this.initialize();
|
|
@@ -1851,6 +1932,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
1851
1932
|
delayMs = this.reconnectDelayMs;
|
|
1852
1933
|
}
|
|
1853
1934
|
const failure = asError(error);
|
|
1935
|
+
this.reportOpenFailure(failure);
|
|
1854
1936
|
this.lastError = failure;
|
|
1855
1937
|
if (failure instanceof EditableArtifactSyncError && failure.requiresSnapshot) {
|
|
1856
1938
|
this.requireSnapshot = true;
|
|
@@ -2001,11 +2083,11 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2001
2083
|
if (bootstrap.modality !== this.modality) {
|
|
2002
2084
|
throw invalidBootstrap("bootstrap modality does not match the controller");
|
|
2003
2085
|
}
|
|
2004
|
-
this.
|
|
2005
|
-
if (bootstrap.
|
|
2086
|
+
this.requireLiveProtocol(bootstrap.liveProtocolVersion);
|
|
2087
|
+
if (bootstrap.modelSchemaVersion !== this.modelSchemaVersion) {
|
|
2006
2088
|
throw new EditableArtifactSyncError(
|
|
2007
2089
|
"unsupported_protocol",
|
|
2008
|
-
`artifact
|
|
2090
|
+
`artifact schema ${bootstrap.modelSchemaVersion} is incompatible with ${this.modelSchemaVersion}`
|
|
2009
2091
|
);
|
|
2010
2092
|
}
|
|
2011
2093
|
requireSha256(bootstrap.headStateHash, "bootstrap.headStateHash");
|
|
@@ -2064,8 +2146,8 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2064
2146
|
snapshot,
|
|
2065
2147
|
this.artifactId,
|
|
2066
2148
|
this.modality,
|
|
2067
|
-
|
|
2068
|
-
|
|
2149
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2150
|
+
SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION,
|
|
2069
2151
|
this.modelSchemaVersion,
|
|
2070
2152
|
this.maxSnapshotBytes
|
|
2071
2153
|
);
|
|
@@ -2154,7 +2236,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2154
2236
|
transaction,
|
|
2155
2237
|
this.artifactId,
|
|
2156
2238
|
this.modality,
|
|
2157
|
-
|
|
2239
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2158
2240
|
this.maxCommittedTransactionBytes
|
|
2159
2241
|
);
|
|
2160
2242
|
pageBytes += estimateCommittedTransactionBytes(transaction);
|
|
@@ -2184,7 +2266,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2184
2266
|
message,
|
|
2185
2267
|
this.artifactId,
|
|
2186
2268
|
this.modality,
|
|
2187
|
-
|
|
2269
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2188
2270
|
this.maxCommittedTransactionBytes
|
|
2189
2271
|
);
|
|
2190
2272
|
bytes = estimateLiveMessageBytes(message);
|
|
@@ -2270,7 +2352,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2270
2352
|
transaction,
|
|
2271
2353
|
this.artifactId,
|
|
2272
2354
|
this.modality,
|
|
2273
|
-
|
|
2355
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2274
2356
|
this.maxCommittedTransactionBytes
|
|
2275
2357
|
);
|
|
2276
2358
|
if (embeddedPending) {
|
|
@@ -2508,7 +2590,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2508
2590
|
receipt.committed,
|
|
2509
2591
|
this.artifactId,
|
|
2510
2592
|
this.modality,
|
|
2511
|
-
|
|
2593
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
2512
2594
|
this.maxCommittedTransactionBytes
|
|
2513
2595
|
);
|
|
2514
2596
|
this.recordAcceptedMapping(receipt);
|
|
@@ -2566,7 +2648,7 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2566
2648
|
"sync ticket is not bound to the requested writer replica"
|
|
2567
2649
|
);
|
|
2568
2650
|
}
|
|
2569
|
-
this.
|
|
2651
|
+
this.requireLiveProtocol(ticket.protocolVersion);
|
|
2570
2652
|
boundedNonEmpty(ticket.token, "ticket.token", MAX_TICKET_BYTES);
|
|
2571
2653
|
const expiresAt = Date.parse(ticket.expiresAt);
|
|
2572
2654
|
if (!Number.isFinite(expiresAt)) {
|
|
@@ -2661,11 +2743,11 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2661
2743
|
(left, right) => compareCodeUnits(left.clientTransactionId, right.clientTransactionId)
|
|
2662
2744
|
);
|
|
2663
2745
|
}
|
|
2664
|
-
|
|
2665
|
-
if (actual !==
|
|
2746
|
+
requireLiveProtocol(actual) {
|
|
2747
|
+
if (actual !== EDITABLE_ARTIFACT_LIVE_WIRE_VERSION) {
|
|
2666
2748
|
throw new EditableArtifactSyncError(
|
|
2667
2749
|
"unsupported_protocol",
|
|
2668
|
-
`
|
|
2750
|
+
`live protocol ${actual} is incompatible with ${EDITABLE_ARTIFACT_LIVE_WIRE_VERSION}`
|
|
2669
2751
|
);
|
|
2670
2752
|
}
|
|
2671
2753
|
}
|
|
@@ -2691,6 +2773,14 @@ var EditableArtifactSyncControllerImpl = class {
|
|
|
2691
2773
|
for (const waiter of this.liveWaiters) waiter.reject(error);
|
|
2692
2774
|
this.liveWaiters.clear();
|
|
2693
2775
|
}
|
|
2776
|
+
reportOpenFailure(error) {
|
|
2777
|
+
const event = classifyEditableArtifactOpenFailure(error);
|
|
2778
|
+
if (event === null || this.onOpenFailure === void 0) return;
|
|
2779
|
+
try {
|
|
2780
|
+
this.onOpenFailure(event);
|
|
2781
|
+
} catch {
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2694
2784
|
fail(error) {
|
|
2695
2785
|
this.lastError = error;
|
|
2696
2786
|
this.setState("failed");
|
|
@@ -2796,7 +2886,7 @@ function bytesEqual2(left, right) {
|
|
|
2796
2886
|
}
|
|
2797
2887
|
return true;
|
|
2798
2888
|
}
|
|
2799
|
-
function validateCommittedTransaction(transaction, artifactId, modality,
|
|
2889
|
+
function validateCommittedTransaction(transaction, artifactId, modality, operationProtocolVersion, maxCommittedTransactionBytes) {
|
|
2800
2890
|
if (transaction.artifactId !== artifactId || transaction.modality !== modality) {
|
|
2801
2891
|
throw invalidSequence("transaction artifact authority mismatch");
|
|
2802
2892
|
}
|
|
@@ -2819,10 +2909,10 @@ function validateCommittedTransaction(transaction, artifactId, modality, protoco
|
|
|
2819
2909
|
throw invalidSequence("transaction committedTransactionBytes exceeds the configured bound");
|
|
2820
2910
|
}
|
|
2821
2911
|
if (transaction.modality === "spreadsheet") {
|
|
2822
|
-
if (transaction.
|
|
2912
|
+
if (transaction.operationProtocolVersion !== operationProtocolVersion) {
|
|
2823
2913
|
throw new EditableArtifactSyncError(
|
|
2824
2914
|
"unsupported_protocol",
|
|
2825
|
-
`transaction protocol ${transaction.
|
|
2915
|
+
`transaction operation protocol ${transaction.operationProtocolVersion} is incompatible with ${operationProtocolVersion}`
|
|
2826
2916
|
);
|
|
2827
2917
|
}
|
|
2828
2918
|
validateFrontier(transaction.causalFrontier, "causalFrontier");
|
|
@@ -2832,7 +2922,7 @@ function validateCommittedTransaction(transaction, artifactId, modality, protoco
|
|
|
2832
2922
|
} catch (error) {
|
|
2833
2923
|
throw invalidSequence(`invalid OGACO envelope: ${asError(error).message}`);
|
|
2834
2924
|
}
|
|
2835
|
-
if (summary2.transactionId !== transaction.transactionId || summary2.operationProtocolVersion !== transaction.
|
|
2925
|
+
if (summary2.transactionId !== transaction.transactionId || summary2.operationProtocolVersion !== transaction.operationProtocolVersion || summary2.priorStateHash !== transaction.priorStateHash || summary2.stateHash !== transaction.stateHash || !frontiersEqual2(summary2.resultingCausalFrontier, transaction.causalFrontier)) {
|
|
2836
2926
|
throw invalidSequence("committed routing fields do not exactly match the OGACO envelope");
|
|
2837
2927
|
}
|
|
2838
2928
|
return null;
|
|
@@ -2857,7 +2947,7 @@ function validateCommittedTransaction(transaction, artifactId, modality, protoco
|
|
|
2857
2947
|
intentBytes: summary.intentBytes
|
|
2858
2948
|
});
|
|
2859
2949
|
}
|
|
2860
|
-
function validateSnapshot(snapshot, artifactId, modality,
|
|
2950
|
+
function validateSnapshot(snapshot, artifactId, modality, operationProtocolVersion, snapshotVersion, modelSchemaVersion, maxSnapshotBytes) {
|
|
2861
2951
|
if (snapshot.artifactId !== artifactId || snapshot.modality !== modality) {
|
|
2862
2952
|
throw invalidBootstrap("snapshot artifact authority mismatch");
|
|
2863
2953
|
}
|
|
@@ -2868,19 +2958,19 @@ function validateSnapshot(snapshot, artifactId, modality, protocolVersion, kerne
|
|
|
2868
2958
|
positiveSafeInteger(snapshot.modelSchemaVersion, "snapshot.modelSchemaVersion");
|
|
2869
2959
|
if (snapshot.modality === "spreadsheet") {
|
|
2870
2960
|
validateFrontier(snapshot.causalFrontier, "snapshot.causalFrontier");
|
|
2871
|
-
if (snapshot.
|
|
2961
|
+
if (snapshot.operationProtocolVersion !== operationProtocolVersion || snapshot.snapshotVersion !== snapshotVersion) {
|
|
2872
2962
|
throw new EditableArtifactSyncError(
|
|
2873
2963
|
"unsupported_protocol",
|
|
2874
|
-
`snapshot
|
|
2964
|
+
`snapshot operation/state versions ${snapshot.operationProtocolVersion}/${snapshot.snapshotVersion} are incompatible with ${operationProtocolVersion}/${snapshotVersion}`
|
|
2875
2965
|
);
|
|
2876
2966
|
}
|
|
2877
2967
|
} else {
|
|
2878
2968
|
requireNativeRevision(snapshot.nativeRevision, "snapshot.nativeRevision");
|
|
2879
2969
|
}
|
|
2880
|
-
if (snapshot.
|
|
2970
|
+
if (snapshot.modelSchemaVersion !== modelSchemaVersion) {
|
|
2881
2971
|
throw new EditableArtifactSyncError(
|
|
2882
2972
|
"unsupported_protocol",
|
|
2883
|
-
`snapshot
|
|
2973
|
+
`snapshot schema ${snapshot.modelSchemaVersion} is incompatible with ${modelSchemaVersion}`
|
|
2884
2974
|
);
|
|
2885
2975
|
}
|
|
2886
2976
|
if (!(snapshot.bytes instanceof Uint8Array)) {
|
|
@@ -2909,7 +2999,7 @@ function validateFrontier(frontier, label) {
|
|
|
2909
2999
|
previous = entry.replicaId;
|
|
2910
3000
|
}
|
|
2911
3001
|
}
|
|
2912
|
-
function validateLiveMessage(message, artifactId, modality,
|
|
3002
|
+
function validateLiveMessage(message, artifactId, modality, operationProtocolVersion, maxCommittedTransactionBytes) {
|
|
2913
3003
|
if (!message || typeof message !== "object") {
|
|
2914
3004
|
throw invalidSequence("live message must be an object");
|
|
2915
3005
|
}
|
|
@@ -2918,7 +3008,7 @@ function validateLiveMessage(message, artifactId, modality, protocolVersion, max
|
|
|
2918
3008
|
message.transaction,
|
|
2919
3009
|
artifactId,
|
|
2920
3010
|
modality,
|
|
2921
|
-
|
|
3011
|
+
operationProtocolVersion,
|
|
2922
3012
|
maxCommittedTransactionBytes
|
|
2923
3013
|
);
|
|
2924
3014
|
return;
|
|
@@ -2963,7 +3053,7 @@ function estimateCommittedTransactionBytes(transaction) {
|
|
|
2963
3053
|
function requireStateHash(actual, expected, source) {
|
|
2964
3054
|
if (actual !== expected) {
|
|
2965
3055
|
throw new EditableArtifactSyncError(
|
|
2966
|
-
"
|
|
3056
|
+
"authored_causal_mismatch",
|
|
2967
3057
|
`${source} produced state hash ${actual}; expected ${expected}`,
|
|
2968
3058
|
{ retryable: true, requiresSnapshot: true }
|
|
2969
3059
|
);
|
|
@@ -2973,7 +3063,7 @@ function requireDigest(actual, expected, source) {
|
|
|
2973
3063
|
requireSha256(actual, `${source} computed digest`);
|
|
2974
3064
|
if (actual !== expected) {
|
|
2975
3065
|
throw new EditableArtifactSyncError(
|
|
2976
|
-
"
|
|
3066
|
+
"byte_corruption",
|
|
2977
3067
|
`${source} bytes produced digest ${actual}; expected ${expected}`,
|
|
2978
3068
|
{ retryable: true, requiresSnapshot: true }
|
|
2979
3069
|
);
|
|
@@ -2984,7 +3074,7 @@ function requireFrontier(actual, expected, source) {
|
|
|
2984
3074
|
(entry, index) => entry.replicaId !== expected[index]?.replicaId || entry.counter !== expected[index]?.counter
|
|
2985
3075
|
)) {
|
|
2986
3076
|
throw new EditableArtifactSyncError(
|
|
2987
|
-
"
|
|
3077
|
+
"authored_causal_mismatch",
|
|
2988
3078
|
`${source} causal frontier does not match the authoritative barrier`,
|
|
2989
3079
|
{ retryable: true, requiresSnapshot: true }
|
|
2990
3080
|
);
|
|
@@ -3111,7 +3201,7 @@ function requireNativeRevisionEqual(actual, expected, source) {
|
|
|
3111
3201
|
requireNativeRevision(expected, `${source} expected native revision`);
|
|
3112
3202
|
if (actual !== expected) {
|
|
3113
3203
|
throw new EditableArtifactSyncError(
|
|
3114
|
-
"
|
|
3204
|
+
"authored_causal_mismatch",
|
|
3115
3205
|
`${source} native revision ${actual} does not match ${expected}`,
|
|
3116
3206
|
{ retryable: true, requiresSnapshot: true }
|
|
3117
3207
|
);
|
|
@@ -3292,9 +3382,11 @@ var defaultScheduler = {
|
|
|
3292
3382
|
};
|
|
3293
3383
|
|
|
3294
3384
|
// src/editable-artifacts/browser-session.ts
|
|
3295
|
-
import {
|
|
3296
|
-
import {
|
|
3297
|
-
|
|
3385
|
+
import { EDITABLE_ARTIFACT_LIVE_WIRE_VERSION as EDITABLE_ARTIFACT_LIVE_WIRE_VERSION2 } from "@opengeni/contracts/editable-artifact-live";
|
|
3386
|
+
import {
|
|
3387
|
+
EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION as EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION2,
|
|
3388
|
+
currentEditableArtifactCompatibility as currentEditableArtifactCompatibility2
|
|
3389
|
+
} from "@opengeni/contracts/editable-artifacts";
|
|
3298
3390
|
|
|
3299
3391
|
// src/editable-artifacts/http-live-transport.ts
|
|
3300
3392
|
import {
|
|
@@ -3307,11 +3399,12 @@ import {
|
|
|
3307
3399
|
EDITABLE_ARTIFACT_COMMAND_MAX_BYTES as EDITABLE_ARTIFACT_COMMAND_MAX_BYTES3,
|
|
3308
3400
|
EDITABLE_ARTIFACT_INTENT_MAX_BYTES as EDITABLE_ARTIFACT_INTENT_MAX_BYTES3,
|
|
3309
3401
|
EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES as EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES3,
|
|
3402
|
+
currentEditableArtifactCompatibility,
|
|
3310
3403
|
hashEditableArtifactMutationIntentBytes as hashEditableArtifactMutationIntentBytes3
|
|
3311
3404
|
} from "@opengeni/contracts/editable-artifacts";
|
|
3312
3405
|
import { MAX_COMMITTED_TRANSACTION_BYTES as MAX_COMMITTED_TRANSACTION_BYTES2 } from "@opengeni/contracts/editable-artifact-committed-transaction";
|
|
3313
3406
|
var LIVE_PATH = "/v1/editable-artifacts/live";
|
|
3314
|
-
var LIVE_SUBPROTOCOL = "opengeni-artifact-
|
|
3407
|
+
var LIVE_SUBPROTOCOL = "opengeni-artifact-v2";
|
|
3315
3408
|
var DEFAULT_MAX_SERVER_FRAME_BYTES = 8 * 1024 * 1024 + 64 * 1024;
|
|
3316
3409
|
var DEFAULT_MAX_SNAPSHOT_BYTES2 = EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES3;
|
|
3317
3410
|
var DEFAULT_HANDSHAKE_TIMEOUT_MS = 2e4;
|
|
@@ -3327,9 +3420,13 @@ var HttpLiveTransport = class {
|
|
|
3327
3420
|
baseUrl;
|
|
3328
3421
|
socketUrl;
|
|
3329
3422
|
workspaceId;
|
|
3330
|
-
|
|
3423
|
+
modality;
|
|
3424
|
+
liveProtocolVersion;
|
|
3331
3425
|
kernelVersion;
|
|
3332
3426
|
modelSchemaVersion;
|
|
3427
|
+
snapshotVersion;
|
|
3428
|
+
commandProtocolVersion;
|
|
3429
|
+
committedTransactionProtocolVersion;
|
|
3333
3430
|
apiKey;
|
|
3334
3431
|
headerSource;
|
|
3335
3432
|
credentials;
|
|
@@ -3345,9 +3442,34 @@ var HttpLiveTransport = class {
|
|
|
3345
3442
|
const insecure = options.allowInsecureDevelopmentTransport ?? false;
|
|
3346
3443
|
requireTransportSecurity(this.baseUrl, this.socketUrl, insecure);
|
|
3347
3444
|
this.workspaceId = boundedString(options.workspaceId, "workspaceId", 256);
|
|
3348
|
-
|
|
3445
|
+
const current = currentEditableArtifactCompatibility(options.modality);
|
|
3446
|
+
this.modality = options.modality;
|
|
3447
|
+
this.liveProtocolVersion = exactVersion(
|
|
3448
|
+
options.liveProtocolVersion,
|
|
3449
|
+
current.liveProtocolVersion,
|
|
3450
|
+
"liveProtocolVersion"
|
|
3451
|
+
);
|
|
3349
3452
|
this.kernelVersion = boundedString(options.kernelVersion, "kernelVersion", 512);
|
|
3350
|
-
this.modelSchemaVersion =
|
|
3453
|
+
this.modelSchemaVersion = exactVersion(
|
|
3454
|
+
options.modelSchemaVersion,
|
|
3455
|
+
current.modelSchemaVersion,
|
|
3456
|
+
"modelSchemaVersion"
|
|
3457
|
+
);
|
|
3458
|
+
this.snapshotVersion = exactVersion(
|
|
3459
|
+
options.snapshotVersion,
|
|
3460
|
+
current.snapshotVersion,
|
|
3461
|
+
"snapshotVersion"
|
|
3462
|
+
);
|
|
3463
|
+
this.commandProtocolVersion = exactVersion(
|
|
3464
|
+
options.commandProtocolVersion,
|
|
3465
|
+
current.commandProtocolVersion,
|
|
3466
|
+
"commandProtocolVersion"
|
|
3467
|
+
);
|
|
3468
|
+
this.committedTransactionProtocolVersion = exactVersion(
|
|
3469
|
+
options.committedTransactionProtocolVersion,
|
|
3470
|
+
current.committedTransactionProtocolVersion,
|
|
3471
|
+
"committedTransactionProtocolVersion"
|
|
3472
|
+
);
|
|
3351
3473
|
this.apiKey = options.apiKey;
|
|
3352
3474
|
if (this.apiKey !== void 0) boundedString(this.apiKey, "apiKey", 16 * 1024);
|
|
3353
3475
|
this.headerSource = options.headers;
|
|
@@ -3395,9 +3517,13 @@ var HttpLiveTransport = class {
|
|
|
3395
3517
|
},
|
|
3396
3518
|
body: JSON.stringify({
|
|
3397
3519
|
replicaId: input.replicaId,
|
|
3398
|
-
|
|
3520
|
+
modality: this.modality,
|
|
3521
|
+
liveProtocolVersion: this.liveProtocolVersion,
|
|
3399
3522
|
kernelVersion: this.kernelVersion,
|
|
3400
|
-
modelSchemaVersion: this.modelSchemaVersion
|
|
3523
|
+
modelSchemaVersion: this.modelSchemaVersion,
|
|
3524
|
+
snapshotVersion: this.snapshotVersion,
|
|
3525
|
+
commandProtocolVersion: this.commandProtocolVersion,
|
|
3526
|
+
committedTransactionProtocolVersion: this.committedTransactionProtocolVersion
|
|
3401
3527
|
}),
|
|
3402
3528
|
signal: input.signal
|
|
3403
3529
|
});
|
|
@@ -3419,7 +3545,7 @@ var HttpLiveTransport = class {
|
|
|
3419
3545
|
);
|
|
3420
3546
|
}
|
|
3421
3547
|
const value = await readBoundedJson(response, MAX_TICKET_RESPONSE_BYTES);
|
|
3422
|
-
return validateTicket(value, input.artifactId, input.replicaId, this.
|
|
3548
|
+
return validateTicket(value, input.artifactId, input.replicaId, this.liveProtocolVersion);
|
|
3423
3549
|
}
|
|
3424
3550
|
async openLive(input) {
|
|
3425
3551
|
if (input.resume.modality !== input.ticket.modality) {
|
|
@@ -3438,6 +3564,7 @@ var HttpLiveTransport = class {
|
|
|
3438
3564
|
};
|
|
3439
3565
|
const resume = input.resume.modality === "spreadsheet" ? {
|
|
3440
3566
|
...commonResume,
|
|
3567
|
+
modality: "spreadsheet",
|
|
3441
3568
|
localCausalFrontier: cloneFrontier3(input.resume.causalFrontier)
|
|
3442
3569
|
} : {
|
|
3443
3570
|
...commonResume,
|
|
@@ -3593,7 +3720,7 @@ var HttpLiveConnection = class {
|
|
|
3593
3720
|
}
|
|
3594
3721
|
const commonBootstrap = {
|
|
3595
3722
|
artifactId: this.ticket.artifactId,
|
|
3596
|
-
|
|
3723
|
+
liveProtocolVersion: this.ticket.protocolVersion,
|
|
3597
3724
|
headSequence: boundarySequence,
|
|
3598
3725
|
headStateHash: boundaryStateHash,
|
|
3599
3726
|
kernelVersion: snapshot?.kernelVersion ?? this.kernelVersion,
|
|
@@ -3667,12 +3794,6 @@ var HttpLiveConnection = class {
|
|
|
3667
3794
|
if (pending.artifactId !== this.ticket.artifactId) {
|
|
3668
3795
|
throw new TypeError("pending transaction belongs to another artifact");
|
|
3669
3796
|
}
|
|
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
3797
|
if (pending.commandBytes.byteLength > Math.min(open.maxCommandBytes, EDITABLE_ARTIFACT_COMMAND_MAX_BYTES3)) {
|
|
3677
3798
|
throw new EditableArtifactTransportError("pending command exceeds negotiated live limit", {
|
|
3678
3799
|
code: "limit_exceeded",
|
|
@@ -3693,7 +3814,7 @@ var HttpLiveConnection = class {
|
|
|
3693
3814
|
}
|
|
3694
3815
|
const frame = encodeEditableArtifactLiveMutationWireFrame({
|
|
3695
3816
|
type: "mutation",
|
|
3696
|
-
protocolVersion:
|
|
3817
|
+
protocolVersion: this.ticket.protocolVersion,
|
|
3697
3818
|
artifactId: pending.artifactId,
|
|
3698
3819
|
streamEpoch: open.streamEpoch,
|
|
3699
3820
|
requestHash: pending.requestHash,
|
|
@@ -3850,11 +3971,9 @@ var HttpLiveConnection = class {
|
|
|
3850
3971
|
if (frame.transaction.artifactId !== this.ticket.artifactId) {
|
|
3851
3972
|
throw new TypeError("live transaction belongs to another artifact");
|
|
3852
3973
|
}
|
|
3853
|
-
if (
|
|
3974
|
+
if (frame.transaction.modality !== this.ticket.modality) {
|
|
3854
3975
|
throw new TypeError("live transaction modality mismatch");
|
|
3855
3976
|
}
|
|
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
3977
|
if (frame.transaction.committedTransactionBytes.byteLength > this.limits.maxCommittedTransactionBytes) {
|
|
3859
3978
|
throw new RangeError("live transaction exceeds negotiated committed byte limit");
|
|
3860
3979
|
}
|
|
@@ -3933,7 +4052,7 @@ var HttpLiveConnection = class {
|
|
|
3933
4052
|
if (frame.protocolVersion !== this.ticket.protocolVersion) {
|
|
3934
4053
|
throw new TypeError("live snapshot protocol mismatch");
|
|
3935
4054
|
}
|
|
3936
|
-
if (
|
|
4055
|
+
if (frame.modality !== this.ticket.modality) {
|
|
3937
4056
|
throw new TypeError("live snapshot modality mismatch");
|
|
3938
4057
|
}
|
|
3939
4058
|
if (this.snapshotAssembly === null) {
|
|
@@ -3968,7 +4087,8 @@ var HttpLiveConnection = class {
|
|
|
3968
4087
|
...commonSnapshot,
|
|
3969
4088
|
modality: "spreadsheet",
|
|
3970
4089
|
causalFrontier: cloneFrontier3(frame.causalFrontier),
|
|
3971
|
-
|
|
4090
|
+
operationProtocolVersion: frame.operationProtocolVersion,
|
|
4091
|
+
snapshotVersion: frame.snapshotVersion
|
|
3972
4092
|
}) : Object.freeze({
|
|
3973
4093
|
...commonSnapshot,
|
|
3974
4094
|
modality: requireSerializedModality(frame.modality),
|
|
@@ -4027,7 +4147,7 @@ var HttpLiveConnection = class {
|
|
|
4027
4147
|
if (frame.protocolVersion !== this.ticket.protocolVersion) {
|
|
4028
4148
|
throw new TypeError("live server frame protocol mismatch");
|
|
4029
4149
|
}
|
|
4030
|
-
if (frame.type === "open" &&
|
|
4150
|
+
if (frame.type === "open" && frame.modality !== this.ticket.modality) {
|
|
4031
4151
|
throw new TypeError("live open modality does not match its ticket");
|
|
4032
4152
|
}
|
|
4033
4153
|
if (this.openFrame && frame.streamEpoch !== this.openFrame.streamEpoch) {
|
|
@@ -4145,12 +4265,6 @@ function cloneCommitted2(transaction) {
|
|
|
4145
4265
|
committedTransactionBytes: transaction.committedTransactionBytes.slice()
|
|
4146
4266
|
};
|
|
4147
4267
|
}
|
|
4148
|
-
function transactionModality(transaction) {
|
|
4149
|
-
return transaction.modality ?? "spreadsheet";
|
|
4150
|
-
}
|
|
4151
|
-
function serverModality(value) {
|
|
4152
|
-
return value ?? "spreadsheet";
|
|
4153
|
-
}
|
|
4154
4268
|
function serializedBoundaryRevision(snapshot, resume, modality) {
|
|
4155
4269
|
if (snapshot !== null) {
|
|
4156
4270
|
if (snapshot.modality !== modality) throw new TypeError("snapshot modality mismatch");
|
|
@@ -4166,8 +4280,7 @@ function serializedBoundaryRevision(snapshot, resume, modality) {
|
|
|
4166
4280
|
return resume.localNativeRevision;
|
|
4167
4281
|
}
|
|
4168
4282
|
function snapshotChunkAuthorityEqual(frame, metadata) {
|
|
4169
|
-
|
|
4170
|
-
if (modality !== serverModality(metadata.modality)) return false;
|
|
4283
|
+
if (frame.modality !== metadata.modality) return false;
|
|
4171
4284
|
if ("causalFrontier" in frame) {
|
|
4172
4285
|
if (!("causalFrontier" in metadata)) return false;
|
|
4173
4286
|
return frontiersEqual3(frame.causalFrontier, metadata.causalFrontier);
|
|
@@ -4382,6 +4495,13 @@ function positiveU162(value, label) {
|
|
|
4382
4495
|
const number = positiveBounded(value, 65535, label);
|
|
4383
4496
|
return number;
|
|
4384
4497
|
}
|
|
4498
|
+
function exactVersion(value, expected, label) {
|
|
4499
|
+
const actual = positiveU162(value, label);
|
|
4500
|
+
if (actual !== expected) {
|
|
4501
|
+
throw new TypeError(`${label} ${actual} is incompatible with current version ${expected}`);
|
|
4502
|
+
}
|
|
4503
|
+
return actual;
|
|
4504
|
+
}
|
|
4385
4505
|
function positiveBounded(value, maximum, label) {
|
|
4386
4506
|
if (!Number.isSafeInteger(value) || value <= 0 || value > maximum) {
|
|
4387
4507
|
throw new TypeError(`${label} is invalid`);
|
|
@@ -5753,17 +5873,20 @@ function createBrowserEditableArtifactSession(options) {
|
|
|
5753
5873
|
const baseUrl = canonicalBaseUrl(options.baseUrl);
|
|
5754
5874
|
const workspaceId = boundedIdentity(options.workspaceId, "workspaceId");
|
|
5755
5875
|
assertCacheAuthority(options.storageAuthority, baseUrl, workspaceId);
|
|
5756
|
-
const protocolVersion = positiveVersion2(options.runtime.protocolVersion
|
|
5876
|
+
const protocolVersion = positiveVersion2(options.runtime.protocolVersion, "protocolVersion");
|
|
5877
|
+
if (protocolVersion !== EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION2) {
|
|
5878
|
+
throw new TypeError("protocolVersion is incompatible with the current intent protocol");
|
|
5879
|
+
}
|
|
5757
5880
|
const modelSchemaVersion = positiveVersion2(
|
|
5758
5881
|
options.runtime.modelSchemaVersion,
|
|
5759
5882
|
"modelSchemaVersion"
|
|
5760
5883
|
);
|
|
5761
5884
|
const kernelVersion = boundedIdentity(options.runtime.kernelVersion, "kernelVersion", 512);
|
|
5762
5885
|
const commandVersion = positiveVersion2(options.runtime.commandVersion, "commandVersion");
|
|
5763
|
-
const
|
|
5764
|
-
if (commandVersion !==
|
|
5886
|
+
const current = currentEditableArtifactCompatibility2(options.artifact.modality);
|
|
5887
|
+
if (modelSchemaVersion !== current.modelSchemaVersion || commandVersion !== current.commandProtocolVersion) {
|
|
5765
5888
|
throw new TypeError(
|
|
5766
|
-
`
|
|
5889
|
+
`runtime versions are incompatible with current ${options.artifact.modality} compatibility`
|
|
5767
5890
|
);
|
|
5768
5891
|
}
|
|
5769
5892
|
const {
|
|
@@ -5787,9 +5910,13 @@ function createBrowserEditableArtifactSession(options) {
|
|
|
5787
5910
|
...options.transport,
|
|
5788
5911
|
baseUrl,
|
|
5789
5912
|
workspaceId,
|
|
5790
|
-
|
|
5913
|
+
modality: options.artifact.modality,
|
|
5914
|
+
liveProtocolVersion: EDITABLE_ARTIFACT_LIVE_WIRE_VERSION2,
|
|
5791
5915
|
kernelVersion,
|
|
5792
|
-
modelSchemaVersion
|
|
5916
|
+
modelSchemaVersion,
|
|
5917
|
+
snapshotVersion: current.snapshotVersion,
|
|
5918
|
+
commandProtocolVersion: current.commandProtocolVersion,
|
|
5919
|
+
committedTransactionProtocolVersion: current.committedTransactionProtocolVersion
|
|
5793
5920
|
});
|
|
5794
5921
|
return createEditableArtifactSession({
|
|
5795
5922
|
artifactId: options.artifact.id,
|
|
@@ -5802,6 +5929,7 @@ function createBrowserEditableArtifactSession(options) {
|
|
|
5802
5929
|
modelSchemaVersion,
|
|
5803
5930
|
commandVersion,
|
|
5804
5931
|
protocolVersion,
|
|
5932
|
+
...options.onOpenFailure ? { onOpenFailure: options.onOpenFailure } : {},
|
|
5805
5933
|
...replicaId ? { writerReplicaIdFactory: () => replicaId } : {},
|
|
5806
5934
|
ownsWorker: true
|
|
5807
5935
|
});
|
|
@@ -5816,16 +5944,6 @@ function createEditableArtifactReplicaId() {
|
|
|
5816
5944
|
if (value !== "0000000000000000") return value;
|
|
5817
5945
|
}
|
|
5818
5946
|
}
|
|
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
5947
|
function canonicalBaseUrl(value) {
|
|
5830
5948
|
const url = new URL(value);
|
|
5831
5949
|
if (url.username || url.password || url.search || url.hash) {
|
|
@@ -5908,16 +6026,16 @@ var EditableArtifactSyncPool = class {
|
|
|
5908
6026
|
|
|
5909
6027
|
// src/editable-artifacts/index.ts
|
|
5910
6028
|
import {
|
|
5911
|
-
SPREADSHEET_ARTIFACT_COMMAND_VERSION as
|
|
6029
|
+
SPREADSHEET_ARTIFACT_COMMAND_VERSION as SPREADSHEET_ARTIFACT_COMMAND_VERSION2,
|
|
5912
6030
|
editableArtifactStableId as editableArtifactStableId2,
|
|
5913
6031
|
spreadsheetSheetId as spreadsheetSheetId3
|
|
5914
6032
|
} from "@opengeni/contracts/spreadsheet-artifact-commands";
|
|
5915
6033
|
import {
|
|
5916
|
-
DOCUMENT_ARTIFACT_COMMAND_VERSION as
|
|
6034
|
+
DOCUMENT_ARTIFACT_COMMAND_VERSION as DOCUMENT_ARTIFACT_COMMAND_VERSION2,
|
|
5917
6035
|
encodeDocumentArtifactCommandBatch as encodeDocumentArtifactCommandBatch2
|
|
5918
6036
|
} from "@opengeni/contracts/document-artifact-commands";
|
|
5919
6037
|
import {
|
|
5920
|
-
PRESENTATION_ARTIFACT_COMMAND_VERSION as
|
|
6038
|
+
PRESENTATION_ARTIFACT_COMMAND_VERSION as PRESENTATION_ARTIFACT_COMMAND_VERSION2,
|
|
5921
6039
|
PRESENTATION_ARTIFACT_QUERY_MAX_NODES,
|
|
5922
6040
|
PRESENTATION_ARTIFACT_QUERY_MAX_SLIDES,
|
|
5923
6041
|
PRESENTATION_ARTIFACT_QUERY_MAX_TEXT_BYTES,
|
|
@@ -5926,19 +6044,20 @@ import {
|
|
|
5926
6044
|
} from "@opengeni/contracts/presentation-artifact-commands";
|
|
5927
6045
|
export {
|
|
5928
6046
|
ArtifactWorkerClientError,
|
|
5929
|
-
|
|
6047
|
+
DOCUMENT_ARTIFACT_COMMAND_VERSION2 as DOCUMENT_ARTIFACT_COMMAND_VERSION,
|
|
5930
6048
|
EditableArtifactStorageConflictError,
|
|
5931
6049
|
EditableArtifactSyncError,
|
|
5932
6050
|
EditableArtifactSyncPool,
|
|
5933
6051
|
EditableArtifactTransportError,
|
|
5934
6052
|
IndexedDbEditableArtifactStorage,
|
|
5935
6053
|
MemoryEditableArtifactStorage,
|
|
5936
|
-
|
|
6054
|
+
PRESENTATION_ARTIFACT_COMMAND_VERSION2 as PRESENTATION_ARTIFACT_COMMAND_VERSION,
|
|
5937
6055
|
PRESENTATION_ARTIFACT_QUERY_MAX_NODES,
|
|
5938
6056
|
PRESENTATION_ARTIFACT_QUERY_MAX_SLIDES,
|
|
5939
6057
|
PRESENTATION_ARTIFACT_QUERY_MAX_TEXT_BYTES,
|
|
5940
6058
|
PRESENTATION_ARTIFACT_QUERY_RESPONSE_MAX_BYTES,
|
|
5941
|
-
|
|
6059
|
+
SPREADSHEET_ARTIFACT_COMMAND_VERSION2 as SPREADSHEET_ARTIFACT_COMMAND_VERSION,
|
|
6060
|
+
classifyEditableArtifactOpenFailure,
|
|
5942
6061
|
createBrowserEditableArtifactSession,
|
|
5943
6062
|
createBrowserEditableArtifactWorkerKernel,
|
|
5944
6063
|
createEditableArtifactHttpLiveTransport,
|