@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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CompanyBrainContextReceiptPage as ContractCompanyBrainContextReceiptPage,
|
|
3
|
+
CompanyBrainKnowledgeProposalPage as ContractCompanyBrainKnowledgeProposalPage,
|
|
4
|
+
CompanyBrainOkfPackage as ContractCompanyBrainOkfPackage,
|
|
5
|
+
} from "@opengeni/contracts";
|
|
6
|
+
|
|
7
|
+
export type CompanyBrainOkfPackage = ContractCompanyBrainOkfPackage;
|
|
8
|
+
export type CompanyBrainContextReceiptPage = ContractCompanyBrainContextReceiptPage;
|
|
9
|
+
export type CompanyBrainKnowledgeProposalPage = ContractCompanyBrainKnowledgeProposalPage;
|
|
10
|
+
|
|
11
|
+
export type CompanyBrainContextReceiptListOptions = {
|
|
12
|
+
attemptId?: string;
|
|
13
|
+
cursor?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type CompanyBrainKnowledgeProposalListOptions = {
|
|
18
|
+
limit?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type CompanyBrainInspectorTransport = {
|
|
22
|
+
requestJson<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function inspectorPath(workspaceId: string, suffix: string): string {
|
|
26
|
+
return `/v1/workspaces/${workspaceId}/company-brain/${suffix}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function listCompanyBrainContextReceipts(
|
|
30
|
+
client: CompanyBrainInspectorTransport,
|
|
31
|
+
workspaceId: string,
|
|
32
|
+
options: CompanyBrainContextReceiptListOptions = {},
|
|
33
|
+
): Promise<CompanyBrainContextReceiptPage> {
|
|
34
|
+
const params = new URLSearchParams();
|
|
35
|
+
if (options.attemptId) params.set("attemptId", options.attemptId);
|
|
36
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
37
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
38
|
+
const query = params.toString();
|
|
39
|
+
return client.requestJson(
|
|
40
|
+
"GET",
|
|
41
|
+
`${inspectorPath(workspaceId, "context-receipts")}${query ? `?${query}` : ""}`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function listCompanyBrainKnowledgeProposals(
|
|
46
|
+
client: CompanyBrainInspectorTransport,
|
|
47
|
+
workspaceId: string,
|
|
48
|
+
options: CompanyBrainKnowledgeProposalListOptions = {},
|
|
49
|
+
): Promise<CompanyBrainKnowledgeProposalPage> {
|
|
50
|
+
const query =
|
|
51
|
+
options.limit === undefined ? "" : `?limit=${encodeURIComponent(String(options.limit))}`;
|
|
52
|
+
return client.requestJson("GET", `${inspectorPath(workspaceId, "knowledge-proposals")}${query}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type CompanyBrainOkfDownload = {
|
|
56
|
+
content: string;
|
|
57
|
+
contentType: string;
|
|
58
|
+
filename: string;
|
|
59
|
+
};
|
package/src/company-profile.ts
CHANGED
|
@@ -21,7 +21,10 @@ export type CompanyProfileRevision = CompanyProfileRevisionIdentity & {
|
|
|
21
21
|
accountId: string;
|
|
22
22
|
intent: "active" | "proposal";
|
|
23
23
|
profile: CompanyProfileContent;
|
|
24
|
-
provenance: {
|
|
24
|
+
provenance: {
|
|
25
|
+
source: "human" | "agent_admin" | "durable_learning" | "migration";
|
|
26
|
+
sourceId: string | null;
|
|
27
|
+
};
|
|
25
28
|
supersedesRevisionId: string | null;
|
|
26
29
|
createdBySubjectId: string;
|
|
27
30
|
createdAt: string;
|
|
@@ -79,6 +82,19 @@ export type CompanyProfileMutationResponse = {
|
|
|
79
82
|
head: CompanyProfileHead | null;
|
|
80
83
|
event: CompanyProfileActivationEvent | null;
|
|
81
84
|
};
|
|
85
|
+
export type CompanyProfileAgentPolicyMode = "off" | "suggest" | "automatic";
|
|
86
|
+
export type CompanyProfileAgentPolicy = {
|
|
87
|
+
organizationId: string;
|
|
88
|
+
mode: CompanyProfileAgentPolicyMode;
|
|
89
|
+
version: number;
|
|
90
|
+
updatedAt: string;
|
|
91
|
+
changed?: boolean;
|
|
92
|
+
};
|
|
93
|
+
export type UpdateCompanyProfileAgentPolicyRequest = {
|
|
94
|
+
mode: CompanyProfileAgentPolicyMode;
|
|
95
|
+
expectedVersion: number;
|
|
96
|
+
operationId: string;
|
|
97
|
+
};
|
|
82
98
|
export type CompanyProfileDiffRequest = { fromRevisionId: string; toRevisionId: string };
|
|
83
99
|
export type CompanyProfileDiffResponse = {
|
|
84
100
|
from: CompanyProfileRevision;
|
package/src/core.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/** Backward-compatible non-artifact client surface. */
|
|
2
|
+
export { OpenGeniDocumentAuthorityClient as OpenGeniCoreClient } from "./document-authority-client";
|
|
3
|
+
export {
|
|
4
|
+
OpenGeniToolCallError,
|
|
5
|
+
OpenGeniToolReapprovalRequiredError,
|
|
6
|
+
OpenGeniToolsClient,
|
|
7
|
+
} from "./tools";
|
|
8
|
+
export type {
|
|
9
|
+
OpenGeniGeneratedTools,
|
|
10
|
+
OpenGeniDynamicToolNode,
|
|
11
|
+
OpenGeniToolCallOptions,
|
|
12
|
+
OpenGeniToolFunction,
|
|
13
|
+
OpenGeniToolsFacade,
|
|
14
|
+
OpenGeniWorkspaceTools,
|
|
15
|
+
} from "./tools";
|
|
2
16
|
export type {
|
|
3
17
|
FetchLike,
|
|
18
|
+
FetchResponse,
|
|
19
|
+
GetSessionOptions,
|
|
4
20
|
OpenGeniClientOptions,
|
|
5
21
|
OpenGeniRequestOptions,
|
|
6
22
|
SendMessageInput,
|
|
@@ -11,9 +27,15 @@ export type {
|
|
|
11
27
|
export {
|
|
12
28
|
OpenGeniApiContractMismatchError,
|
|
13
29
|
OpenGeniApiError,
|
|
30
|
+
OpenGeniSetupError,
|
|
31
|
+
OpenGeniSecureContextRequiredError,
|
|
14
32
|
OpenGeniSessionListCursorError,
|
|
15
33
|
OpenGeniStreamError,
|
|
34
|
+
formatErrorMessage,
|
|
16
35
|
isRetryableStreamError,
|
|
17
36
|
} from "./errors";
|
|
37
|
+
export type { OpenGeniSecureContextRequiredReason } from "./errors";
|
|
38
|
+
export { parseDeprecationNotice } from "./deprecation";
|
|
39
|
+
export type { OpenGeniDeprecationHandler, OpenGeniDeprecationNotice } from "./deprecation";
|
|
18
40
|
export { resolveWorkspaceVoiceInputEnabled } from "./transcription";
|
|
19
41
|
export { OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION } from "./types";
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecation notices advertised by the OpenGeni API.
|
|
3
|
+
*
|
|
4
|
+
* Per the public API compatibility policy, a route whose behaviour is scheduled
|
|
5
|
+
* for removal answers with the standard `Deprecation` (RFC 9745) and `Sunset`
|
|
6
|
+
* (RFC 8594) headers plus `Link: <notes>; rel="deprecation"`. The client
|
|
7
|
+
* surfaces them through `OpenGeniClientOptions.onDeprecation`, or by default
|
|
8
|
+
* as a one-time `console.warn` per route, so an integrator pinned to an older
|
|
9
|
+
* SDK learns about a removal well before it happens.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type OpenGeniDeprecationNotice = {
|
|
13
|
+
/** Request method, upper case. */
|
|
14
|
+
method: string;
|
|
15
|
+
/** Request path with ids collapsed (`/v1/workspaces/:id/...`), stable per route. */
|
|
16
|
+
route: string;
|
|
17
|
+
/** Exact request path. */
|
|
18
|
+
path: string;
|
|
19
|
+
/** When the deprecation was announced, if the header carried a date. */
|
|
20
|
+
deprecatedAt: Date | null;
|
|
21
|
+
/** Earliest removal on the server, if advertised. */
|
|
22
|
+
sunset: Date | null;
|
|
23
|
+
/** Migration notes (`rel="deprecation"`), if advertised. */
|
|
24
|
+
link: string | null;
|
|
25
|
+
/** Replacement (`rel="successor-version"`), if advertised. */
|
|
26
|
+
successor: string | null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** `false` silences notices; a function receives each route's notice once per client. */
|
|
30
|
+
export type OpenGeniDeprecationHandler = (notice: OpenGeniDeprecationNotice) => void;
|
|
31
|
+
|
|
32
|
+
type HeaderBag = { get(name: string): string | null };
|
|
33
|
+
|
|
34
|
+
const ID_SEGMENT =
|
|
35
|
+
/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\d+|[A-Za-z0-9_-]{20,})$/i;
|
|
36
|
+
|
|
37
|
+
function routeKey(path: string): string {
|
|
38
|
+
return path
|
|
39
|
+
.split("/")
|
|
40
|
+
.map((segment) => (ID_SEGMENT.test(segment) ? ":id" : segment))
|
|
41
|
+
.join("/");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function parseDeprecationDate(value: string): Date | null {
|
|
45
|
+
const trimmed = value.trim();
|
|
46
|
+
// RFC 9745 structured date `@<unix seconds>`; older drafts used `true` or an HTTP-date.
|
|
47
|
+
const structured = /^@(-?\d+)$/.exec(trimmed);
|
|
48
|
+
if (structured) return new Date(Number(structured[1]) * 1000);
|
|
49
|
+
const parsed = Date.parse(trimmed);
|
|
50
|
+
return Number.isNaN(parsed) ? null : new Date(parsed);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function parseLinks(value: string | null): Map<string, string> {
|
|
54
|
+
const links = new Map<string, string>();
|
|
55
|
+
if (!value) return links;
|
|
56
|
+
for (const match of value.matchAll(/<([^>]*)>\s*((?:;\s*[^;,]+)*)/g)) {
|
|
57
|
+
const rel = /;\s*rel="?([^";,]+)"?/i.exec(match[2] ?? "")?.[1];
|
|
58
|
+
if (!rel) continue;
|
|
59
|
+
for (const name of rel.toLowerCase().split(/\s+/)) {
|
|
60
|
+
if (!links.has(name)) links.set(name, match[1]!);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return links;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Read a deprecation notice from response headers; `null` when none is advertised. */
|
|
67
|
+
export function parseDeprecationNotice(
|
|
68
|
+
method: string,
|
|
69
|
+
url: string,
|
|
70
|
+
headers: HeaderBag,
|
|
71
|
+
): OpenGeniDeprecationNotice | null {
|
|
72
|
+
const deprecation = headers.get("deprecation");
|
|
73
|
+
const sunsetHeader = headers.get("sunset");
|
|
74
|
+
if (!deprecation && !sunsetHeader) return null;
|
|
75
|
+
let path = url;
|
|
76
|
+
try {
|
|
77
|
+
path = new URL(url, "http://opengeni.invalid").pathname;
|
|
78
|
+
} catch {
|
|
79
|
+
// Keep the raw value; the notice is advisory.
|
|
80
|
+
}
|
|
81
|
+
const sunset = sunsetHeader ? Date.parse(sunsetHeader) : Number.NaN;
|
|
82
|
+
const links = parseLinks(headers.get("link"));
|
|
83
|
+
return {
|
|
84
|
+
method: method.toUpperCase(),
|
|
85
|
+
route: routeKey(path),
|
|
86
|
+
path,
|
|
87
|
+
deprecatedAt: deprecation ? parseDeprecationDate(deprecation) : null,
|
|
88
|
+
sunset: Number.isNaN(sunset) ? null : new Date(sunset),
|
|
89
|
+
link: links.get("deprecation") ?? links.get("sunset") ?? null,
|
|
90
|
+
successor: links.get("successor-version") ?? null,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const warnedRoutes = new Set<string>();
|
|
95
|
+
|
|
96
|
+
/** The default handler: one `console.warn` per route per process. */
|
|
97
|
+
export function warnDeprecationOnce(notice: OpenGeniDeprecationNotice): void {
|
|
98
|
+
const key = `${notice.method} ${notice.route}`;
|
|
99
|
+
if (warnedRoutes.has(key)) return;
|
|
100
|
+
warnedRoutes.add(key);
|
|
101
|
+
const sunset = notice.sunset ? ` and will be removed after ${notice.sunset.toISOString()}` : "";
|
|
102
|
+
const notes = notice.link ? ` Migration notes: ${notice.link}.` : "";
|
|
103
|
+
console.warn(
|
|
104
|
+
`[@opengeni/sdk] ${key} is deprecated${sunset}.${notes} Upgrade @opengeni/sdk, or pass onDeprecation to handle this notice.`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type FetchFunction<R extends { headers: HeaderBag }> = (
|
|
109
|
+
input: string | URL | Request,
|
|
110
|
+
init?: RequestInit,
|
|
111
|
+
) => Promise<R>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Wrap a fetch implementation so every response is inspected for a deprecation
|
|
115
|
+
* notice. The handler runs at most once per route for this wrapper and never
|
|
116
|
+
* affects the request: a throwing handler is swallowed.
|
|
117
|
+
*/
|
|
118
|
+
export function withDeprecationNotices<R extends { headers: HeaderBag }>(
|
|
119
|
+
fetchImpl: FetchFunction<R>,
|
|
120
|
+
handler: OpenGeniDeprecationHandler | false | undefined,
|
|
121
|
+
): FetchFunction<R> {
|
|
122
|
+
if (handler === false) return fetchImpl;
|
|
123
|
+
const notify = handler ?? warnDeprecationOnce;
|
|
124
|
+
const seen = new Set<string>();
|
|
125
|
+
return async (input, init) => {
|
|
126
|
+
const response = await fetchImpl(input, init);
|
|
127
|
+
try {
|
|
128
|
+
const headers = response.headers;
|
|
129
|
+
if (headers && (headers.get("deprecation") || headers.get("sunset"))) {
|
|
130
|
+
const method =
|
|
131
|
+
init?.method ??
|
|
132
|
+
(typeof Request !== "undefined" && input instanceof Request ? input.method : "GET");
|
|
133
|
+
const url =
|
|
134
|
+
typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
135
|
+
const notice = parseDeprecationNotice(method, url, headers);
|
|
136
|
+
if (notice) {
|
|
137
|
+
const key = `${notice.method} ${notice.route}`;
|
|
138
|
+
if (!seen.has(key)) {
|
|
139
|
+
seen.add(key);
|
|
140
|
+
notify(notice);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} catch {
|
|
145
|
+
// Deprecation notices are advisory and must never fail a request.
|
|
146
|
+
}
|
|
147
|
+
return response;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { CompanyBrainOkfDownload, CompanyBrainOkfPackage } from "./company-brain";
|
|
2
|
+
import { OpenGeniClient as OpenGeniCoreClient } from "./client";
|
|
3
|
+
import type {
|
|
4
|
+
ApiKey,
|
|
5
|
+
UpdateOrganizationApiKeyRequest,
|
|
6
|
+
Document,
|
|
7
|
+
IssueUserResourceGrantRequest,
|
|
8
|
+
UserResourceGrantMutationResponse,
|
|
9
|
+
DocumentBase,
|
|
10
|
+
FileDownloadUrlResponse,
|
|
11
|
+
DocumentAuthorityReclassification,
|
|
12
|
+
DocumentDefaultCollectionBackfill,
|
|
13
|
+
DocumentDefaultCollectionBackfillAudit,
|
|
14
|
+
GetDocumentDefaultCollectionBackfillAuditOptions,
|
|
15
|
+
ListDocumentAuthorityReclassificationsOptions,
|
|
16
|
+
ListDocumentAuthorityReclassificationsResponse,
|
|
17
|
+
ListDocumentDefaultCollectionBackfillRunsResponse,
|
|
18
|
+
ListOrganizationDocumentAuthorityReclassificationsResponse,
|
|
19
|
+
ReclassifyDocumentAuthorityRequest,
|
|
20
|
+
RunDocumentDefaultCollectionBackfillRequest,
|
|
21
|
+
} from "./types";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Operator-only authority administration and Document tenancy-backfill surface.
|
|
25
|
+
*
|
|
26
|
+
* The public root and legacy `core` clients extend this class for compatibility.
|
|
27
|
+
* Browser consoles that import `@opengeni/sdk/browser` do not retain these
|
|
28
|
+
* methods or their routes.
|
|
29
|
+
*/
|
|
30
|
+
export class OpenGeniDocumentAuthorityClient extends OpenGeniCoreClient {
|
|
31
|
+
/** Read organization-key metadata and policy; never returns the secret token. */
|
|
32
|
+
async getOrganizationApiKey(organizationId: string, apiKeyId: string): Promise<ApiKey> {
|
|
33
|
+
return await this.requestJson<ApiKey>(
|
|
34
|
+
"GET",
|
|
35
|
+
`/v1/organizations/${organizationId}/api-keys/${apiKeyId}`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Update metadata or replace the policy. Policy narrowing applies on the next request. */
|
|
40
|
+
async updateOrganizationApiKey(
|
|
41
|
+
organizationId: string,
|
|
42
|
+
apiKeyId: string,
|
|
43
|
+
request: UpdateOrganizationApiKeyRequest,
|
|
44
|
+
): Promise<ApiKey> {
|
|
45
|
+
return await this.requestJson<ApiKey>(
|
|
46
|
+
"PATCH",
|
|
47
|
+
`/v1/organizations/${organizationId}/api-keys/${apiKeyId}`,
|
|
48
|
+
request,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Issue an exact-session or standing personal-resource grant. */
|
|
53
|
+
async issueUserResourceGrant(
|
|
54
|
+
workspaceId: string,
|
|
55
|
+
authorityId: string,
|
|
56
|
+
request: IssueUserResourceGrantRequest,
|
|
57
|
+
): Promise<UserResourceGrantMutationResponse> {
|
|
58
|
+
return await this.requestJson<UserResourceGrantMutationResponse>(
|
|
59
|
+
"POST",
|
|
60
|
+
`/v1/workspaces/${workspaceId}/user-resource-authorities/${authorityId}/grants`,
|
|
61
|
+
request,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async listDocumentBases(workspaceId: string): Promise<DocumentBase[]> {
|
|
66
|
+
return await this.requestJson<DocumentBase[]>(
|
|
67
|
+
"GET",
|
|
68
|
+
`/v1/workspaces/${workspaceId}/document-bases`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* List every Document the current human can manage from this workspace,
|
|
74
|
+
* including portable personal and organization-scoped Documents whose
|
|
75
|
+
* immutable ingestion workspace is different.
|
|
76
|
+
*/
|
|
77
|
+
async listAccessibleDocuments(workspaceId: string): Promise<Document[]> {
|
|
78
|
+
return await this.requestJson<Document[]>("GET", `/v1/workspaces/${workspaceId}/documents`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Mint a source-file URL through the Document's effective authority. */
|
|
82
|
+
async createDocumentOriginalFileDownloadUrl(
|
|
83
|
+
workspaceId: string,
|
|
84
|
+
documentId: string,
|
|
85
|
+
): Promise<FileDownloadUrlResponse> {
|
|
86
|
+
return await this.requestJson<FileDownloadUrlResponse>(
|
|
87
|
+
"POST",
|
|
88
|
+
`/v1/workspaces/${workspaceId}/documents/${documentId}/original-file/download-url`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Retry indexing for a failed document. */
|
|
93
|
+
async reindexDocument(
|
|
94
|
+
workspaceId: string,
|
|
95
|
+
baseId: string,
|
|
96
|
+
documentId: string,
|
|
97
|
+
): Promise<Document> {
|
|
98
|
+
return await this.requestJson<Document>(
|
|
99
|
+
"POST",
|
|
100
|
+
`/v1/workspaces/${workspaceId}/document-bases/${baseId}/documents/${documentId}/reindex`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Permission-filtered Company Brain package with authorized guidance bodies. */
|
|
105
|
+
getCompanyBrain(workspaceId: string): Promise<CompanyBrainOkfPackage> {
|
|
106
|
+
return this.requestJson<CompanyBrainOkfPackage>(
|
|
107
|
+
"GET",
|
|
108
|
+
`/v1/workspaces/${workspaceId}/company-brain`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Download the deterministic Markdown/YAML Company Brain package. */
|
|
113
|
+
async exportCompanyBrainOkf(workspaceId: string): Promise<CompanyBrainOkfDownload> {
|
|
114
|
+
const response = await this.requestResponse(
|
|
115
|
+
"GET",
|
|
116
|
+
`/v1/workspaces/${workspaceId}/company-brain/export`,
|
|
117
|
+
);
|
|
118
|
+
const headers = response.headers;
|
|
119
|
+
return {
|
|
120
|
+
content: await response.text(),
|
|
121
|
+
contentType: headers.get("content-type") ?? "text/markdown",
|
|
122
|
+
filename: headers.get("content-disposition")?.split('"')[1] ?? "company-brain.okf.md",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Atomically reclassify a Document's authority and every indexed chunk.
|
|
128
|
+
* The operation is replay-safe and rejects a stale expected authority tuple.
|
|
129
|
+
*/
|
|
130
|
+
async reclassifyDocumentAuthority(
|
|
131
|
+
workspaceId: string,
|
|
132
|
+
documentId: string,
|
|
133
|
+
request: ReclassifyDocumentAuthorityRequest,
|
|
134
|
+
): Promise<DocumentAuthorityReclassification> {
|
|
135
|
+
return await this.requestJson<DocumentAuthorityReclassification>(
|
|
136
|
+
"POST",
|
|
137
|
+
`/v1/workspaces/${workspaceId}/documents/${documentId}/authority-reclassifications`,
|
|
138
|
+
request,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** List the current actor's durable authority-reclassification receipts. */
|
|
143
|
+
async listDocumentAuthorityReclassifications(
|
|
144
|
+
workspaceId: string,
|
|
145
|
+
documentId: string,
|
|
146
|
+
options: ListDocumentAuthorityReclassificationsOptions = {},
|
|
147
|
+
): Promise<ListDocumentAuthorityReclassificationsResponse> {
|
|
148
|
+
const params = new URLSearchParams();
|
|
149
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
150
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
151
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
152
|
+
return await this.requestJson<ListDocumentAuthorityReclassificationsResponse>(
|
|
153
|
+
"GET",
|
|
154
|
+
`/v1/workspaces/${workspaceId}/documents/${documentId}/authority-reclassifications${query}`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Advance one resumable, organization-scoped Default collection backfill.
|
|
160
|
+
* Reusing an operation ID is idempotent; keep the run ID across batches.
|
|
161
|
+
*/
|
|
162
|
+
async runDocumentDefaultCollectionBackfill(
|
|
163
|
+
workspaceId: string,
|
|
164
|
+
request: RunDocumentDefaultCollectionBackfillRequest,
|
|
165
|
+
): Promise<DocumentDefaultCollectionBackfill> {
|
|
166
|
+
return await this.requestJson<DocumentDefaultCollectionBackfill>(
|
|
167
|
+
"POST",
|
|
168
|
+
`/v1/workspaces/${workspaceId}/document-default-collection-backfills`,
|
|
169
|
+
request,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** List organization-scoped Default collection backfill runs (organization admin only). */
|
|
174
|
+
async listDocumentDefaultCollectionBackfillRuns(
|
|
175
|
+
workspaceId: string,
|
|
176
|
+
options: ListDocumentAuthorityReclassificationsOptions = {},
|
|
177
|
+
): Promise<ListDocumentDefaultCollectionBackfillRunsResponse> {
|
|
178
|
+
const params = new URLSearchParams();
|
|
179
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
180
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
181
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
182
|
+
return await this.requestJson<ListDocumentDefaultCollectionBackfillRunsResponse>(
|
|
183
|
+
"GET",
|
|
184
|
+
`/v1/workspaces/${workspaceId}/document-default-collection-backfills${query}`,
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Read bounded operation and workspace receipts for one Default-collection backfill run. */
|
|
189
|
+
async getDocumentDefaultCollectionBackfillAudit(
|
|
190
|
+
workspaceId: string,
|
|
191
|
+
runId: string,
|
|
192
|
+
options: GetDocumentDefaultCollectionBackfillAuditOptions = {},
|
|
193
|
+
): Promise<DocumentDefaultCollectionBackfillAudit> {
|
|
194
|
+
const params = new URLSearchParams();
|
|
195
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
196
|
+
if (options.operationCursor) params.set("operationCursor", options.operationCursor);
|
|
197
|
+
if (options.receiptCursor) params.set("receiptCursor", options.receiptCursor);
|
|
198
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
199
|
+
return await this.requestJson<DocumentDefaultCollectionBackfillAudit>(
|
|
200
|
+
"GET",
|
|
201
|
+
`/v1/workspaces/${workspaceId}/document-default-collection-backfills/${runId}${query}`,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** List organization-wide Document authority changes (organization admin only). */
|
|
206
|
+
async listOrganizationDocumentAuthorityReclassifications(
|
|
207
|
+
workspaceId: string,
|
|
208
|
+
options: ListDocumentAuthorityReclassificationsOptions = {},
|
|
209
|
+
): Promise<ListOrganizationDocumentAuthorityReclassificationsResponse> {
|
|
210
|
+
const params = new URLSearchParams();
|
|
211
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
212
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
213
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
214
|
+
return await this.requestJson<ListOrganizationDocumentAuthorityReclassificationsResponse>(
|
|
215
|
+
"GET",
|
|
216
|
+
`/v1/workspaces/${workspaceId}/document-authority-reclassifications${query}`,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { OpenGeniDocumentAuthorityClient } from "./document-authority-client";
|
|
2
|
+
export type {
|
|
3
|
+
DocumentAuthorityReclassification,
|
|
4
|
+
DocumentDefaultCollectionBackfill,
|
|
5
|
+
DocumentDefaultCollectionBackfillAudit,
|
|
6
|
+
DocumentDefaultCollectionBackfillOperationAudit,
|
|
7
|
+
DocumentDefaultCollectionBackfillReceiptAudit,
|
|
8
|
+
DocumentDefaultCollectionBackfillRunAudit,
|
|
9
|
+
GetDocumentDefaultCollectionBackfillAuditOptions,
|
|
10
|
+
ListDocumentAuthorityReclassificationsOptions,
|
|
11
|
+
ListDocumentAuthorityReclassificationsResponse,
|
|
12
|
+
ListDocumentDefaultCollectionBackfillRunsResponse,
|
|
13
|
+
ListOrganizationDocumentAuthorityReclassificationsResponse,
|
|
14
|
+
OrganizationDocumentAuthorityReclassification,
|
|
15
|
+
ReclassifyDocumentAuthorityRequest,
|
|
16
|
+
RunDocumentDefaultCollectionBackfillRequest,
|
|
17
|
+
} from "./types";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { EDITABLE_ARTIFACT_LIVE_WIRE_VERSION } from "@opengeni/contracts/editable-artifact-live";
|
|
2
|
+
import {
|
|
3
|
+
EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
|
|
4
|
+
currentEditableArtifactCompatibility,
|
|
5
|
+
} from "@opengeni/contracts/editable-artifacts";
|
|
4
6
|
|
|
5
7
|
import type { EditableArtifactCacheAuthority } from "./controller";
|
|
6
8
|
import {
|
|
@@ -10,6 +12,7 @@ import {
|
|
|
10
12
|
import { createEditableArtifactSession, type EditableArtifactSession } from "./session";
|
|
11
13
|
import type { EditableArtifactStoragePort } from "./storage";
|
|
12
14
|
import type { EditableArtifactModality } from "./types";
|
|
15
|
+
import type { EditableArtifactOpenFailureReporter } from "./open-failure";
|
|
13
16
|
import {
|
|
14
17
|
createBrowserEditableArtifactWorkerKernel,
|
|
15
18
|
type CreateBrowserEditableArtifactWorkerKernelOptions,
|
|
@@ -20,10 +23,11 @@ export type EditableArtifactBrowserRuntime = Omit<
|
|
|
20
23
|
"modality" | "kernelVersion" | "protocolVersion" | "modelSchemaVersion" | "commandVersion"
|
|
21
24
|
> &
|
|
22
25
|
Readonly<{
|
|
23
|
-
/** Exact
|
|
26
|
+
/** Exact package/executable build identity; the API records but does not compatibility-gate it. */
|
|
24
27
|
kernelVersion: string;
|
|
25
28
|
modelSchemaVersion: number;
|
|
26
|
-
|
|
29
|
+
/** Exact OGATX001 intent protocol version. */
|
|
30
|
+
protocolVersion: number;
|
|
27
31
|
commandVersion: number;
|
|
28
32
|
}>;
|
|
29
33
|
|
|
@@ -36,11 +40,21 @@ export type CreateBrowserEditableArtifactSessionOptions = Readonly<{
|
|
|
36
40
|
runtime: EditableArtifactBrowserRuntime;
|
|
37
41
|
transport?: Omit<
|
|
38
42
|
CreateEditableArtifactHttpLiveTransportOptions,
|
|
39
|
-
|
|
43
|
+
| "baseUrl"
|
|
44
|
+
| "workspaceId"
|
|
45
|
+
| "modality"
|
|
46
|
+
| "liveProtocolVersion"
|
|
47
|
+
| "kernelVersion"
|
|
48
|
+
| "modelSchemaVersion"
|
|
49
|
+
| "snapshotVersion"
|
|
50
|
+
| "commandProtocolVersion"
|
|
51
|
+
| "committedTransactionProtocolVersion"
|
|
40
52
|
>;
|
|
41
53
|
storage?: EditableArtifactStoragePort;
|
|
42
54
|
/** Reuse the replica used to create the artifact when opening it immediately. */
|
|
43
55
|
replicaId?: string;
|
|
56
|
+
/** Receives bounded categories/codes only; never workbook or formula content. */
|
|
57
|
+
onOpenFailure?: EditableArtifactOpenFailureReporter;
|
|
44
58
|
}>;
|
|
45
59
|
|
|
46
60
|
/**
|
|
@@ -53,17 +67,23 @@ export function createBrowserEditableArtifactSession(
|
|
|
53
67
|
const baseUrl = canonicalBaseUrl(options.baseUrl);
|
|
54
68
|
const workspaceId = boundedIdentity(options.workspaceId, "workspaceId");
|
|
55
69
|
assertCacheAuthority(options.storageAuthority, baseUrl, workspaceId);
|
|
56
|
-
const protocolVersion = positiveVersion(options.runtime.protocolVersion
|
|
70
|
+
const protocolVersion = positiveVersion(options.runtime.protocolVersion, "protocolVersion");
|
|
71
|
+
if (protocolVersion !== EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION) {
|
|
72
|
+
throw new TypeError("protocolVersion is incompatible with the current intent protocol");
|
|
73
|
+
}
|
|
57
74
|
const modelSchemaVersion = positiveVersion(
|
|
58
75
|
options.runtime.modelSchemaVersion,
|
|
59
76
|
"modelSchemaVersion",
|
|
60
77
|
);
|
|
61
78
|
const kernelVersion = boundedIdentity(options.runtime.kernelVersion, "kernelVersion", 512);
|
|
62
79
|
const commandVersion = positiveVersion(options.runtime.commandVersion, "commandVersion");
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
80
|
+
const current = currentEditableArtifactCompatibility(options.artifact.modality);
|
|
81
|
+
if (
|
|
82
|
+
modelSchemaVersion !== current.modelSchemaVersion ||
|
|
83
|
+
commandVersion !== current.commandProtocolVersion
|
|
84
|
+
) {
|
|
65
85
|
throw new TypeError(
|
|
66
|
-
`
|
|
86
|
+
`runtime versions are incompatible with current ${options.artifact.modality} compatibility`,
|
|
67
87
|
);
|
|
68
88
|
}
|
|
69
89
|
const {
|
|
@@ -87,9 +107,13 @@ export function createBrowserEditableArtifactSession(
|
|
|
87
107
|
...options.transport,
|
|
88
108
|
baseUrl,
|
|
89
109
|
workspaceId,
|
|
90
|
-
|
|
110
|
+
modality: options.artifact.modality,
|
|
111
|
+
liveProtocolVersion: EDITABLE_ARTIFACT_LIVE_WIRE_VERSION,
|
|
91
112
|
kernelVersion,
|
|
92
113
|
modelSchemaVersion,
|
|
114
|
+
snapshotVersion: current.snapshotVersion,
|
|
115
|
+
commandProtocolVersion: current.commandProtocolVersion,
|
|
116
|
+
committedTransactionProtocolVersion: current.committedTransactionProtocolVersion,
|
|
93
117
|
});
|
|
94
118
|
return createEditableArtifactSession({
|
|
95
119
|
artifactId: options.artifact.id,
|
|
@@ -102,6 +126,7 @@ export function createBrowserEditableArtifactSession(
|
|
|
102
126
|
modelSchemaVersion,
|
|
103
127
|
commandVersion,
|
|
104
128
|
protocolVersion,
|
|
129
|
+
...(options.onOpenFailure ? { onOpenFailure: options.onOpenFailure } : {}),
|
|
105
130
|
...(replicaId ? { writerReplicaIdFactory: () => replicaId } : {}),
|
|
106
131
|
ownsWorker: true,
|
|
107
132
|
});
|
|
@@ -121,17 +146,6 @@ export function createEditableArtifactReplicaId(): string {
|
|
|
121
146
|
}
|
|
122
147
|
}
|
|
123
148
|
|
|
124
|
-
function commandVersionFor(modality: EditableArtifactModality): number {
|
|
125
|
-
switch (modality) {
|
|
126
|
-
case "spreadsheet":
|
|
127
|
-
return SPREADSHEET_ARTIFACT_COMMAND_VERSION;
|
|
128
|
-
case "document":
|
|
129
|
-
return DOCUMENT_ARTIFACT_COMMAND_VERSION;
|
|
130
|
-
case "presentation":
|
|
131
|
-
return PRESENTATION_ARTIFACT_COMMAND_VERSION;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
149
|
function canonicalBaseUrl(value: string | URL): URL {
|
|
136
150
|
const url = new URL(value);
|
|
137
151
|
if (url.username || url.password || url.search || url.hash) {
|