@opengeni/sdk 3.1.0 → 3.3.2-canary.1
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 +60 -8
- package/dist/accounts.d.ts +5 -1
- package/dist/accounts.js +13 -1
- package/dist/accounts.js.map +1 -1
- package/dist/artifacts.js +6 -6
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +6 -4
- package/dist/{chunk-C2H7HBNP.js → chunk-6NEPJ7NC.js} +2 -2
- package/dist/{chunk-TX3EIENU.js → chunk-BESZFWMU.js} +2 -2
- package/dist/{chunk-YTAWBDO2.js → chunk-E5BNEG2D.js} +2 -1
- package/dist/chunk-E5BNEG2D.js.map +1 -0
- package/dist/{chunk-7ZXBPJZP.js → chunk-GY6RQPCG.js} +282 -43
- package/dist/chunk-GY6RQPCG.js.map +1 -0
- package/dist/{chunk-C4DJPZRU.js → chunk-OO5LPTO7.js} +14 -1
- package/dist/chunk-OO5LPTO7.js.map +1 -0
- package/dist/{chunk-GW3EJ2GP.js → chunk-QTBAMHEF.js} +28 -3
- package/dist/{chunk-GW3EJ2GP.js.map → chunk-QTBAMHEF.js.map} +1 -1
- package/dist/{chunk-VUQZAB3O.js → chunk-TFCLHRZK.js} +2 -2
- package/dist/client.d.ts +47 -11
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/company-profile.d.ts +13 -0
- package/dist/core.d.ts +2 -1
- package/dist/core.js +7 -5
- package/dist/document-authority.js +5 -5
- package/dist/editable-artifacts.js +1 -1
- package/dist/errors.d.ts +12 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +219 -7
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +3 -0
- package/dist/interaction.js +4 -2
- 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/realtime.d.ts +3 -1
- package/dist/realtime.js +2 -2
- package/dist/realtime.js.map +1 -1
- package/dist/session-titles.d.ts +28 -0
- package/dist/types.d.ts +90 -3
- package/package.json +6 -2
- package/src/accounts.ts +18 -0
- package/src/browser.ts +2 -0
- package/src/client.ts +407 -35
- package/src/company-profile.ts +13 -0
- package/src/core.ts +2 -0
- package/src/errors.ts +23 -0
- package/src/index.ts +29 -0
- package/src/interaction.ts +32 -0
- package/src/model-picker-order.ts +6 -0
- package/src/realtime.ts +1 -0
- package/src/session-titles.ts +84 -0
- package/src/types.ts +105 -2
- package/dist/chunk-7ZXBPJZP.js.map +0 -1
- package/dist/chunk-C4DJPZRU.js.map +0 -1
- package/dist/chunk-YTAWBDO2.js.map +0 -1
- /package/dist/{chunk-C2H7HBNP.js.map → chunk-6NEPJ7NC.js.map} +0 -0
- /package/dist/{chunk-TX3EIENU.js.map → chunk-BESZFWMU.js.map} +0 -0
- /package/dist/{chunk-VUQZAB3O.js.map → chunk-TFCLHRZK.js.map} +0 -0
|
@@ -26,6 +26,18 @@ var OpenGeniApiError = class extends Error {
|
|
|
26
26
|
this.details = decoded?.details;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
var OpenGeniSecureContextRequiredError = class extends Error {
|
|
30
|
+
code = "secure_context_required";
|
|
31
|
+
retryable = false;
|
|
32
|
+
reason;
|
|
33
|
+
constructor(reason) {
|
|
34
|
+
super(
|
|
35
|
+
reason === "insecure_context" ? "Couldn\u2019t attach this file because OpenGeni is open over HTTP. Attachments require a secure HTTPS connection. Open the secure site or configure HTTPS for this deployment." : "Couldn\u2019t attach this file because secure browser cryptography is unavailable. Attachments require HTTPS and Web Crypto support. Open a secure site in a supported browser or configure HTTPS for this deployment."
|
|
36
|
+
);
|
|
37
|
+
this.name = "OpenGeniSecureContextRequiredError";
|
|
38
|
+
this.reason = reason;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
29
41
|
function decodeApiErrorBody(body) {
|
|
30
42
|
if (!body) return null;
|
|
31
43
|
try {
|
|
@@ -110,10 +122,11 @@ function isRetryableStreamError(error) {
|
|
|
110
122
|
|
|
111
123
|
export {
|
|
112
124
|
OpenGeniApiError,
|
|
125
|
+
OpenGeniSecureContextRequiredError,
|
|
113
126
|
OpenGeniSessionListCursorError,
|
|
114
127
|
OpenGeniApiContractMismatchError,
|
|
115
128
|
OpenGeniStreamError,
|
|
116
129
|
isAbortError,
|
|
117
130
|
isRetryableStreamError
|
|
118
131
|
};
|
|
119
|
-
//# sourceMappingURL=chunk-
|
|
132
|
+
//# sourceMappingURL=chunk-OO5LPTO7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/** Error for a non-2xx OpenGeni API response. */\nexport class OpenGeniApiError extends Error {\n readonly status: number;\n readonly code: string | undefined;\n readonly retryable: boolean;\n readonly correlationId: string | undefined;\n /** True only when an uncontrolled transport failed after a mutation may have been accepted. */\n readonly outcomeUnknown: boolean;\n readonly body: string;\n readonly details: Record<string, unknown> | undefined;\n\n constructor(\n status: number,\n body: string,\n options: {\n code?: string | undefined;\n retryable?: boolean | undefined;\n correlationId?: string | undefined;\n outcomeUnknown?: boolean | undefined;\n displayMessage?: string | undefined;\n mutation?: boolean | undefined;\n } = {},\n ) {\n const decoded = decodeApiErrorBody(body);\n const correlationId = decoded?.requestId ?? boundedCorrelationId(options.correlationId);\n const gatewayFailure = status >= 502 && status <= 504;\n const fromResponse = options.mutation !== undefined;\n const message = decoded?.message ?? (fromResponse ? \"Request failed.\" : body || \"(empty body)\");\n const displayMessage =\n options.displayMessage ??\n (gatewayFailure && fromResponse\n ? (decoded?.message ?? \"OpenGeni is temporarily unavailable — retry.\")\n : `OpenGeni API ${status}: ${message}`);\n super(correlationId ? `${displayMessage} Reference: ${correlationId}.` : displayMessage);\n this.name = \"OpenGeniApiError\";\n this.status = status;\n this.code =\n options.code ??\n decoded?.code ??\n (gatewayFailure && fromResponse ? \"upstream_unavailable\" : undefined);\n this.retryable = options.retryable ?? decoded?.retryable ?? retryableApiStatus(status);\n this.correlationId = correlationId;\n this.outcomeUnknown =\n options.outcomeUnknown ??\n decoded?.outcomeUnknown ??\n (gatewayFailure && !!options.mutation && !decoded);\n this.body = !fromResponse || decoded ? body : \"\";\n this.details = decoded?.details;\n }\n}\n\nexport type OpenGeniSecureContextRequiredReason = \"insecure_context\" | \"web_crypto_unavailable\";\n\n/**\n * A browser operation requires secure-context-only platform capabilities.\n * Callers may key UI behavior on the stable `secure_context_required` code;\n * `reason` exists only to keep the human guidance truthful.\n */\nexport class OpenGeniSecureContextRequiredError extends Error {\n readonly code = \"secure_context_required\" as const;\n readonly retryable = false;\n readonly reason: OpenGeniSecureContextRequiredReason;\n\n constructor(reason: OpenGeniSecureContextRequiredReason) {\n super(\n reason === \"insecure_context\"\n ? \"Couldn’t attach this file because OpenGeni is open over HTTP. Attachments require a secure HTTPS connection. Open the secure site or configure HTTPS for this deployment.\"\n : \"Couldn’t attach this file because secure browser cryptography is unavailable. Attachments require HTTPS and Web Crypto support. Open a secure site in a supported browser or configure HTTPS for this deployment.\",\n );\n this.name = \"OpenGeniSecureContextRequiredError\";\n this.reason = reason;\n }\n}\n\nfunction decodeApiErrorBody(body: string): {\n code: string | undefined;\n message: string | undefined;\n requestId: string | undefined;\n retryable: boolean | undefined;\n outcomeUnknown: boolean | undefined;\n details: Record<string, unknown> | undefined;\n} | null {\n if (!body) return null;\n try {\n const decoded: unknown = JSON.parse(body);\n if (!decoded || typeof decoded !== \"object\" || Array.isArray(decoded)) return null;\n const record = decoded as Record<string, unknown>;\n const nested =\n record.error && typeof record.error === \"object\" && !Array.isArray(record.error)\n ? (record.error as Record<string, unknown>)\n : record;\n const code = boundedApiField(nested.code);\n const message = boundedApiField(nested.message);\n const requestId = boundedCorrelationId(nested.requestId);\n const retryable = typeof nested.retryable === \"boolean\" ? nested.retryable : undefined;\n const outcomeUnknown =\n typeof nested.outcomeUnknown === \"boolean\" ? nested.outcomeUnknown : undefined;\n const details = boundedApiDetails(nested.details);\n if (\n !code &&\n !message &&\n !requestId &&\n retryable === undefined &&\n outcomeUnknown === undefined &&\n !details\n )\n return null;\n return {\n code,\n message,\n requestId,\n retryable,\n outcomeUnknown,\n details,\n };\n } catch {\n return null;\n }\n}\n\nfunction boundedApiDetails(value: unknown): Record<string, unknown> | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return;\n const entries = Object.entries(value as Record<string, unknown>).slice(0, 16);\n const details: Record<string, unknown> = {};\n for (const [key, entry] of entries) {\n if (!/^[a-zA-Z][\\w.-]{0,63}$/.test(key)) continue;\n if (typeof entry === \"string\") {\n const bounded = boundedApiField(entry);\n if (bounded !== undefined) details[key] = bounded;\n } else if (typeof entry === \"number\" || typeof entry === \"boolean\" || entry === null) {\n details[key] = entry;\n }\n }\n return Object.keys(details).length > 0 ? details : undefined;\n}\n\nfunction boundedApiField(value: unknown): string | undefined {\n if (typeof value !== \"string\") return;\n const bytes = new TextEncoder().encode(value);\n return bytes.byteLength <= 512 ? value : new TextDecoder().decode(bytes.slice(0, 512));\n}\n\nfunction retryableApiStatus(status: number): boolean {\n return status === 408 || status === 409 || status === 425 || status === 429 || status >= 500;\n}\n\nfunction boundedCorrelationId(value: unknown): string | undefined {\n if (typeof value !== \"string\" || value.length > 128 || !/^[\\w.:-]+$/.test(value)) {\n return;\n }\n return value;\n}\n\n/** A legacy short-lived session-list snapshot cursor can no longer be continued. */\nexport class OpenGeniSessionListCursorError extends OpenGeniApiError {}\n\n/** The browser bundle and API disagree about their state-changing wire contract. */\nexport class OpenGeniApiContractMismatchError extends Error {\n readonly expected: string;\n readonly actual: string;\n\n constructor(expected: string, actual: string) {\n super(`OpenGeni API contract mismatch: client expects ${expected}, API serves ${actual}`);\n this.name = \"OpenGeniApiContractMismatchError\";\n this.expected = expected;\n this.actual = actual;\n }\n}\n\n/** Error for an unrecoverable event-stream condition (not a transient drop). */\nexport class OpenGeniStreamError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"OpenGeniStreamError\";\n }\n}\n\nexport function isAbortError(error: unknown): boolean {\n return (\n (error instanceof DOMException && error.name === \"AbortError\") ||\n (error instanceof Error && error.name === \"AbortError\")\n );\n}\n\n/**\n * Transient conditions worth a reconnect: network-level failures (`fetch`\n * rejects with `TypeError`) and HTTP statuses that signal a temporary server\n * or contention condition. Auth/validation failures (401/403/404/...) are\n * permanent and surface to the caller instead.\n */\nexport function isRetryableStreamError(error: unknown): boolean {\n if (error instanceof OpenGeniApiError) return error.retryable;\n return error instanceof TypeError;\n}\n"],"mappings":";AACO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,QACA,MACA,UAOI,CAAC,GACL;AACA,UAAM,UAAU,mBAAmB,IAAI;AACvC,UAAM,gBAAgB,SAAS,aAAa,qBAAqB,QAAQ,aAAa;AACtF,UAAM,iBAAiB,UAAU,OAAO,UAAU;AAClD,UAAM,eAAe,QAAQ,aAAa;AAC1C,UAAM,UAAU,SAAS,YAAY,eAAe,oBAAoB,QAAQ;AAChF,UAAM,iBACJ,QAAQ,mBACP,kBAAkB,eACd,SAAS,WAAW,sDACrB,gBAAgB,MAAM,KAAK,OAAO;AACxC,UAAM,gBAAgB,GAAG,cAAc,eAAe,aAAa,MAAM,cAAc;AACvF,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OACH,QAAQ,QACR,SAAS,SACR,kBAAkB,eAAe,yBAAyB;AAC7D,SAAK,YAAY,QAAQ,aAAa,SAAS,aAAa,mBAAmB,MAAM;AACrF,SAAK,gBAAgB;AACrB,SAAK,iBACH,QAAQ,kBACR,SAAS,mBACR,kBAAkB,CAAC,CAAC,QAAQ,YAAY,CAAC;AAC5C,SAAK,OAAO,CAAC,gBAAgB,UAAU,OAAO;AAC9C,SAAK,UAAU,SAAS;AAAA,EAC1B;AACF;AASO,IAAM,qCAAN,cAAiD,MAAM;AAAA,EACnD,OAAO;AAAA,EACP,YAAY;AAAA,EACZ;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;AAC1B;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OpenGeniApiError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OO5LPTO7.js";
|
|
4
4
|
|
|
5
5
|
// src/interaction.ts
|
|
6
6
|
var INTERACTION_PROTOCOL_VERSION = 1;
|
|
@@ -601,6 +601,9 @@ var ComputerSessionResource = class {
|
|
|
601
601
|
async observe(targetId, options = {}) {
|
|
602
602
|
return await this.transport.observeComputerTarget(this.workspaceId, this.id, targetId, options);
|
|
603
603
|
}
|
|
604
|
+
async capture(targetId, options = {}) {
|
|
605
|
+
return await this.transport.captureComputerTarget(this.workspaceId, this.id, targetId, options);
|
|
606
|
+
}
|
|
604
607
|
async act(request, options = {}) {
|
|
605
608
|
return await this.transport.actInComputer(this.workspaceId, this.id, request, options);
|
|
606
609
|
}
|
|
@@ -883,6 +886,27 @@ function parseComputerFrameMetadata(value) {
|
|
|
883
886
|
}
|
|
884
887
|
return metadata;
|
|
885
888
|
}
|
|
889
|
+
function decodeComputerFrameMetadataHeader(value) {
|
|
890
|
+
if (!value || value.length > 32 * 1024 || !/^[A-Za-z0-9_-]+$/u.test(value)) {
|
|
891
|
+
throw new Error("computer frame metadata header is invalid");
|
|
892
|
+
}
|
|
893
|
+
const normalized = value.replace(/-/gu, "+").replace(/_/gu, "/");
|
|
894
|
+
const padded = normalized.padEnd(Math.ceil(normalized.length / 4) * 4, "=");
|
|
895
|
+
let decoded;
|
|
896
|
+
try {
|
|
897
|
+
decoded = atob(padded);
|
|
898
|
+
} catch {
|
|
899
|
+
throw new Error("computer frame metadata header is invalid");
|
|
900
|
+
}
|
|
901
|
+
const bytes = Uint8Array.from(decoded, (character) => character.charCodeAt(0));
|
|
902
|
+
let metadata;
|
|
903
|
+
try {
|
|
904
|
+
metadata = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
905
|
+
} catch {
|
|
906
|
+
throw new Error("computer frame metadata header is invalid");
|
|
907
|
+
}
|
|
908
|
+
return parseComputerFrameMetadata(metadata);
|
|
909
|
+
}
|
|
886
910
|
function newestRelevantBrowser(sessions, associationSessionId) {
|
|
887
911
|
const live = sessions.filter(
|
|
888
912
|
(session) => !["ending", "ended", "failed", "lost"].includes(session.lifecycle) && session.associations.some((association) => association.sessionId === associationSessionId)
|
|
@@ -1033,6 +1057,7 @@ export {
|
|
|
1033
1057
|
decodeBrowserFrameMessage,
|
|
1034
1058
|
decodeComputerFrameMessage,
|
|
1035
1059
|
parseBrowserFrameMetadata,
|
|
1036
|
-
parseComputerFrameMetadata
|
|
1060
|
+
parseComputerFrameMetadata,
|
|
1061
|
+
decodeComputerFrameMetadataHeader
|
|
1037
1062
|
};
|
|
1038
|
-
//# sourceMappingURL=chunk-
|
|
1063
|
+
//# sourceMappingURL=chunk-QTBAMHEF.js.map
|