@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
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/proxy.ts","../src/mcp-output.ts","../src/desktop.ts","../src/terminal.ts","../src/workspace-instruction-policies.ts","../src/company-profile.ts","../src/preference-registry.ts"],"sourcesContent":["import type { OpenGeniClient } from \"./client\";\nimport type { StreamSessionEventsOptions } from \"./stream\";\nimport type { SessionEvent } from \"./types\";\n\n/**\n * Proxy-through-your-own-API helpers.\n *\n * The intended pattern: a customer's server consumes the OpenGeni event\n * stream with its own API key (`client.streamEvents(...)`) and re-emits it to\n * its browser clients over its own authenticated endpoint — the OpenGeni key\n * never reaches the browser. The re-emitted wire format is identical to\n * OpenGeni's own SSE stream (`id: <sequence>`, `event: <type>`,\n * `data: <event JSON>`), so the browser side can consume it with this same\n * SDK's streaming core (or a plain `EventSource`), including resume via\n * `?after=` / `Last-Event-ID`.\n */\n\n/** Format one event exactly as OpenGeni's API emits it over SSE. */\nexport function formatSseEvent(event: SessionEvent): string {\n return `id: ${event.sequence}\\nevent: ${event.type}\\ndata: ${JSON.stringify(event)}\\n\\n`;\n}\n\nexport type SseReStreamOptions = {\n /**\n * Emit `: ping` comment lines at this interval, keeping intermediaries from\n * idling the connection out. Disabled when omitted.\n */\n heartbeatMs?: number;\n /**\n * Called when the downstream consumer cancels (e.g. the browser\n * disconnected). Use it to abort the upstream OpenGeni stream — an async\n * iterator that is mid-`await` cannot be interrupted by `return()` alone.\n */\n onCancel?: () => void;\n};\n\n/**\n * Re-emit a stream of session events as an SSE byte stream. Pull-based, so\n * upstream consumption follows downstream demand; cancelling the returned\n * stream fires `onCancel` and ends the upstream iterator.\n */\nexport function sessionEventsToSseStream(\n events: AsyncIterable<SessionEvent>,\n options: SseReStreamOptions = {},\n): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n const iterator = events[Symbol.asyncIterator]();\n let heartbeat: ReturnType<typeof setInterval> | undefined;\n let cancelled = false;\n\n const stopHeartbeat = (): void => {\n if (heartbeat !== undefined) {\n clearInterval(heartbeat);\n heartbeat = undefined;\n }\n };\n\n return new ReadableStream<Uint8Array>({\n start: (controller) => {\n if (options.heartbeatMs !== undefined) {\n heartbeat = setInterval(() => {\n try {\n controller.enqueue(encoder.encode(\": ping\\n\\n\"));\n } catch {\n stopHeartbeat();\n }\n }, options.heartbeatMs);\n }\n },\n pull: async (controller) => {\n let result: IteratorResult<SessionEvent, unknown>;\n try {\n result = await iterator.next();\n } catch (error) {\n stopHeartbeat();\n throw error;\n }\n if (cancelled) {\n return;\n }\n if (result.done) {\n stopHeartbeat();\n controller.close();\n return;\n }\n controller.enqueue(encoder.encode(formatSseEvent(result.value)));\n },\n cancel: () => {\n cancelled = true;\n stopHeartbeat();\n options.onCancel?.();\n // Fire-and-forget: if the iterator is suspended mid-await, return()\n // settles only after onCancel unblocks it; cancel must not hang on it.\n void Promise.resolve(iterator.return?.(undefined)).then(\n () => undefined,\n () => undefined,\n );\n },\n });\n}\n\n/** Wrap an event stream in a ready-to-return SSE `Response`. */\nexport function sessionEventsToSseResponse(\n events: AsyncIterable<SessionEvent>,\n options: SseReStreamOptions = {},\n): Response {\n return new Response(sessionEventsToSseStream(events, options), {\n headers: {\n \"Content-Type\": \"text/event-stream; charset=utf-8\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n },\n });\n}\n\n/**\n * Read the resume cursor a reconnecting SSE client sent: the `after` query\n * parameter, or the standard `Last-Event-ID` header (the re-emitted stream\n * sets `id:` to the sequence). Returns 0 (full replay) when absent.\n */\nexport function resumeSequenceFromRequest(request: Request): number {\n const url = new URL(request.url);\n const raw = url.searchParams.get(\"after\") ?? request.headers.get(\"Last-Event-ID\");\n const parsed = raw === null ? 0 : Number(raw);\n return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : 0;\n}\n\nexport type ProxySessionEventStreamOptions = Omit<StreamSessionEventsOptions, \"after\"> & {\n /**\n * Resume cursor. Pass a number, or the incoming browser `Request` to\n * honor its `?after=` / `Last-Event-ID` automatically.\n */\n after?: number | Request;\n /** See {@link SseReStreamOptions.heartbeatMs}. */\n heartbeatMs?: number;\n};\n\n/**\n * One-call proxy: consume the OpenGeni stream server-side and return an SSE\n * `Response` for your own browser clients. Works anywhere WHATWG `Response`\n * is the handler return type (Hono, Next.js route handlers, Bun.serve,\n * Cloudflare Workers, ...).\n *\n * The upstream OpenGeni connection is torn down when the downstream client\n * disconnects, and also when `options.signal` (e.g. the incoming request's\n * signal) aborts.\n */\nexport function proxySessionEventStream(\n client: OpenGeniClient,\n workspaceId: string,\n sessionId: string,\n options: ProxySessionEventStreamOptions = {},\n): Response {\n const { after, heartbeatMs, signal, ...streamOptions } = options;\n const upstream = new AbortController();\n if (signal?.aborted) {\n upstream.abort();\n } else {\n signal?.addEventListener(\"abort\", () => upstream.abort(), { once: true });\n }\n const resolvedAfter = after instanceof Request ? resumeSequenceFromRequest(after) : (after ?? 0);\n const events = client.streamEvents(workspaceId, sessionId, {\n ...streamOptions,\n after: resolvedAfter,\n signal: upstream.signal,\n });\n return sessionEventsToSseResponse(events, {\n ...(heartbeatMs !== undefined ? { heartbeatMs } : {}),\n onCancel: () => upstream.abort(),\n });\n}\n","/**\n * A transport-tolerant MCP tool result.\n *\n * `value` is the canonical machine-readable payload after recognized MCP/JSON\n * envelopes are removed. `text` is the best presentation string without\n * discarding structured data. `raw` always retains the original evidence.\n */\nexport type NormalizedMcpOutput = Readonly<{\n raw: unknown;\n value: unknown;\n text: string;\n isError: boolean;\n}>;\n\nconst MAX_MCP_OUTPUT_DEPTH = 8;\nconst RESULT_ENVELOPE_KEYS = new Set([\"result\", \"isError\", \"jsonrpc\", \"id\", \"_meta\"]);\n\n/** Normalize common direct, JSON, and standard MCP result envelopes without throwing. */\nexport function normalizeMcpOutput(output: unknown): NormalizedMcpOutput {\n const normalized = normalizeValue(output, 0, new Set<object>());\n return {\n raw: output,\n value: normalized.value,\n text: normalized.text,\n isError: normalized.isError,\n };\n}\n\ntype NormalizedValue = Omit<NormalizedMcpOutput, \"raw\">;\n\nfunction normalizeValue(value: unknown, depth: number, ancestors: Set<object>): NormalizedValue {\n if (value === null || value === undefined) {\n return { value, text: \"\", isError: false };\n }\n if (typeof value === \"string\") {\n return normalizeText(value, depth, ancestors);\n }\n if (typeof value !== \"object\") {\n return { value, text: String(value), isError: false };\n }\n if (depth >= MAX_MCP_OUTPUT_DEPTH || ancestors.has(value)) {\n return { value, text: safeStringify(value), isError: false };\n }\n\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n return { value, text: safeStringify(value), isError: false };\n }\n\n const record = value as Record<string, unknown>;\n const envelopeError = record.isError === true;\n\n if (record.type === \"text\" && typeof record.text === \"string\") {\n const normalized = normalizeText(record.text, depth + 1, ancestors);\n return {\n value: normalized.value,\n text: record.text,\n isError: envelopeError || normalized.isError,\n };\n }\n\n if (\"structuredContent\" in record) {\n const normalized = normalizeValue(record.structuredContent, depth + 1, ancestors);\n return {\n value: normalized.value,\n text: firstMcpText(record.content) ?? normalized.text,\n isError: envelopeError || normalized.isError,\n };\n }\n\n if (isMcpContent(record.content)) {\n const text = firstMcpText(record.content);\n if (text !== null) {\n const normalized = normalizeText(text, depth + 1, ancestors);\n return {\n value: normalized.value,\n text,\n isError: envelopeError || normalized.isError,\n };\n }\n return {\n value,\n text: safeStringify(value),\n isError: envelopeError,\n };\n }\n\n if (isResultEnvelope(record)) {\n const normalized = normalizeValue(record.result, depth + 1, ancestors);\n return {\n value: normalized.value,\n text: normalized.text,\n isError: envelopeError || normalized.isError,\n };\n }\n\n return {\n value,\n text: safeStringify(value),\n isError: envelopeError,\n };\n } finally {\n ancestors.delete(value);\n }\n}\n\nfunction normalizeText(text: string, depth: number, ancestors: Set<object>): NormalizedValue {\n try {\n const parsed: unknown = JSON.parse(text);\n const normalized = normalizeValue(parsed, depth + 1, ancestors);\n return {\n value: normalized.value,\n text,\n isError: normalized.isError,\n };\n } catch {\n return { value: text, text, isError: false };\n }\n}\n\nfunction isMcpContent(value: unknown): value is readonly Record<string, unknown>[] {\n return (\n Array.isArray(value) &&\n value.some(\n (part) =>\n part !== null &&\n typeof part === \"object\" &&\n typeof (part as { type?: unknown }).type === \"string\",\n )\n );\n}\n\nfunction firstMcpText(value: unknown): string | null {\n if (!Array.isArray(value)) {\n return null;\n }\n for (const part of value) {\n if (\n part !== null &&\n typeof part === \"object\" &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n }\n return null;\n}\n\nfunction isResultEnvelope(record: Record<string, unknown>): boolean {\n return \"result\" in record && Object.keys(record).every((key) => RESULT_ENVELOPE_KEYS.has(key));\n}\n\nfunction safeStringify(value: unknown): string {\n try {\n return JSON.stringify(value) ?? \"\";\n } catch {\n return String(value);\n }\n}\n","// Zero-dependency desktop (noVNC) transport contract.\n//\n// The actual `@novnc/novnc` RFB import is a browser-only DOM dependency and\n// lives in `@opengeni/react` (lazily imported, SSR-safe). The framework-agnostic\n// SDK ships only the transport CONTRACT: a URL assembler, the minimal RFB\n// surface the component drives, the connection state machine, and the\n// rotation/fence reducers — all pure and unit-testable, with no DOM and no deps.\n//\n// Channel A (terminal-as-events, files, git) needs NO new transport here: those\n// are event projections + the synchronous fs/git/terminal point queries on\n// `OpenGeniClient`. Only the desktop pixel plane (Channel B, direct-to-provider)\n// needs this.\n\nimport type { DesktopStreamCapability, StreamUrlRotatedPayload } from \"./types\";\n\n/**\n * Translate the negotiated desktop capability into the WebSocket URL the noVNC\n * RFB client connects to. The scoped provider token is ALREADY embedded in the\n * minted `url` (Modal tunnel host, Blaxel `bl_preview_token`, Daytona signed\n * preview) by `session.resolveExposedPort(6080)` — we do NOT append `cap.token`\n * as a query param (that double-auth was an adversarial-review bug: the box runs\n * `-nopw` in v1, so the RFB password is meaningless and the real auth is the\n * tunnel token in the host). We only normalize the scheme to `ws`/`wss` and, when\n * the minted URL points at a `vnc.html` viewer page, rewrite it to the\n * websockify socket path noVNC actually dials.\n */\nexport function desktopSocketUrl(cap: Pick<DesktopStreamCapability, \"url\">): string {\n if (!cap.url) {\n throw new Error(\"desktop capability has no url (transport is null)\");\n }\n const u = new URL(cap.url);\n // https → wss, http → ws (noVNC dials a WebSocket, not the HTTP viewer page).\n if (u.protocol === \"https:\") {\n u.protocol = \"wss:\";\n } else if (u.protocol === \"http:\") {\n u.protocol = \"ws:\";\n }\n // A minted `…/vnc.html` (or `…/vnc_lite.html`) viewer page → the websockify\n // socket the page itself would open (`…/websockify`). A bare host/path with no\n // viewer page is already the socket path; leave it untouched.\n if (/\\/vnc(_lite)?\\.html$/.test(u.pathname)) {\n u.pathname = u.pathname.replace(/\\/vnc(_lite)?\\.html$/, \"/websockify\");\n u.search = \"\";\n u.hash = \"\";\n }\n return u.toString();\n}\n\n/**\n * The minimal RFB surface the React component drives. Lets tests (and 3rd\n * parties swapping noVNC for a WebRTC client in v3) provide a fake without the\n * DOM. Matches `@novnc/novnc`'s RFB constructor + lifecycle.\n */\nexport interface DesktopRfbLike {\n viewOnly: boolean;\n scaleViewport: boolean;\n /**\n * 1:1 viewport clipping. We always drive this FALSE: with clipping on, noVNC\n * paints the framebuffer pixel-for-pixel and scrolls/crops to the container\n * (the \"zoomed in\" look). FALSE lets `scaleViewport` shrink the 1280x800 frame\n * to fit the panel (aspect-preserved). Declared so the hook can pin it instead\n * of relying on noVNC's default — `scaleViewport=true` forces clip off\n * internally, but a stale/partial state on reconnect could leave it on.\n */\n clipViewport: boolean;\n addEventListener(\n type: \"connect\" | \"disconnect\" | \"securityfailure\",\n cb: (e?: unknown) => void,\n ): void;\n removeEventListener?: (\n type: \"connect\" | \"disconnect\" | \"securityfailure\",\n cb: (e?: unknown) => void,\n ) => void;\n /** Send clipboard text over the already-open RFB connection. */\n clipboardPasteFrom?(text: string): void;\n /** Send one RFB key event. A missing `down` emits a complete key press. */\n sendKey?(keysym: number, code: string, down?: boolean): void;\n /** Focus or release the RFB keyboard sink without reconnecting. */\n focus?(options?: FocusOptions): void;\n blur?(): void;\n disconnect(): void;\n}\n\nexport type DesktopRfbFactory = (\n target: HTMLElement,\n url: string,\n opts: {\n credentials?: { password?: string | undefined } | undefined;\n wsProtocols?: string[] | undefined;\n },\n) => DesktopRfbLike;\n\nexport type DesktopConnectionState =\n | \"idle\"\n | \"negotiating\"\n | \"connecting\"\n | \"connected\"\n | \"rotating\"\n | \"reconnecting\"\n | \"error\"\n | \"ended\";\n\nexport type DesktopStreamEvent =\n | { type: \"negotiated\" }\n | { type: \"connected\" }\n | { type: \"disconnected\" }\n | { type: \"rotate\" }\n | { type: \"fail\" }\n | { type: \"abort\" };\n\n/**\n * Pure reducer for the desktop connection lifecycle. The component owns the RFB\n * object + DOM; this owns the transitions so they are unit-testable. Mirrors the\n * Channel-A stream reducer discipline.\n */\nexport function nextDesktopState(\n current: DesktopConnectionState,\n ev: DesktopStreamEvent,\n): DesktopConnectionState {\n switch (ev.type) {\n case \"negotiated\":\n return \"connecting\";\n case \"connected\":\n return \"connected\";\n case \"rotate\":\n return current === \"connected\" ? \"rotating\" : current;\n case \"disconnected\":\n // A deliberate teardown (ended) stays ended; everything else reconnects.\n return current === \"ended\" ? \"ended\" : \"reconnecting\";\n case \"fail\":\n return \"error\";\n case \"abort\":\n return \"ended\";\n default:\n return current;\n }\n}\n\n// `DesktopStreamCapability` is the desktop cell of `SessionCapabilities`; alias\n// it for the rotation reducer below without depending on the whole doc.\nexport type DesktopStreamCapabilityLike = {\n url: string | null;\n token: string | null;\n expiresAt: string | null;\n};\n\n/**\n * Apply a `stream.url.rotated` event onto a desktop capability, fencing on\n * leaseEpoch (split-brain). A rotation minted under an epoch the client has\n * already advanced PAST is from a superseded owner and is dropped (returns\n * null); otherwise the fresh url/token/expiresAt are folded in.\n */\nexport function applyUrlRotation<T extends DesktopStreamCapabilityLike>(\n cap: T,\n payload: StreamUrlRotatedPayload,\n knownEpoch: number,\n): T | null {\n if (payload.leaseEpoch < knownEpoch) {\n return null;\n }\n return { ...cap, url: payload.url, token: payload.token, expiresAt: payload.expiresAt };\n}\n","// Zero-dependency interactive-terminal (ttyd PTY-over-websocket) transport\n// contract. Symmetric with `desktop.ts`: the SDK ships only the pure transport\n// CONTRACT (a URL assembler + the ttyd wire-protocol frame codec), with no DOM\n// and no deps. The actual WebSocket open + xterm attach lives in `@opengeni/react`\n// (`use-terminal-stream.ts`).\n//\n// The interactive terminal is a REAL PTY streamed over the SAME Modal raw-TLS\n// tunnel as the desktop noVNC, with the SAME scoped stream-token mechanism. The\n// box bakes `ttyd` on `TERMINAL_STREAM_PORT` (7681); `session.resolveExposedPort`\n// mints the tunnel URL. The Terminal capability cell carries transport \"pty-ws\" +\n// that url + the scoped token when the box is warm and a viewer is attached.\n\nimport type { TerminalCapability } from \"./types\";\n\n/**\n * Translate the negotiated `pty-ws` Terminal capability into the WebSocket URL\n * the ttyd client dials. The scoped provider token is ALREADY embedded in the\n * minted `url` (the Modal tunnel host) by `session.resolveExposedPort(7681)` —\n * we do NOT append `cap.token` (identical posture to the desktop: the gate is the\n * unguessable short-TTL tunnel URL + the server-recorded scoped stream token; ttyd\n * runs `--writable` with no `-c` credential in v1). We only normalize the scheme\n * to `ws`/`wss`; a bare host is already the ttyd websocket endpoint.\n */\nexport function terminalSocketUrl(cap: Pick<TerminalCapability, \"url\">): string {\n if (!cap.url) {\n throw new Error(\"terminal capability has no url (transport is not pty-ws)\");\n }\n const u = new URL(cap.url);\n // https → wss, http → ws (ttyd is dialed as a WebSocket, not an HTTP page).\n if (u.protocol === \"https:\") {\n u.protocol = \"wss:\";\n } else if (u.protocol === \"http:\") {\n u.protocol = \"ws:\";\n }\n return u.toString();\n}\n\n// ── ttyd wire protocol ───────────────────────────────────────────────────────\n// ttyd frames are a single ASCII command char + payload. These mirror ttyd's\n// `protocol.h` Command enum. Client→server and server→client share the byte 0/1/2\n// values but mean different things per direction (see below).\n\n/** ttyd subprotocol — REQUIRED on the WebSocket handshake or ttyd refuses it. */\nexport const TTYD_SUBPROTOCOL = \"tty\";\n\n/** Client→server command bytes (the first char of each outbound text frame). */\nexport const TtydClientCommand = {\n /** stdin: \"0\" + raw input bytes. */\n INPUT: \"0\",\n /** window resize: \"1\" + JSON.stringify({ columns, rows }). */\n RESIZE: \"1\",\n /** flow-control pause (back-pressure): \"2\". */\n PAUSE: \"2\",\n /** flow-control resume: \"3\". */\n RESUME: \"3\",\n} as const;\n\n/** Server→client command bytes (the first char of each inbound frame). */\nexport const TtydServerCommand = {\n /** stdout/stderr: \"0\" + raw output bytes (write the rest into xterm). */\n OUTPUT: \"0\",\n /** set the window title: \"1\" + title string. */\n SET_WINDOW_TITLE: \"1\",\n /** ttyd client preferences JSON: \"2\" + json (ignored by us). */\n SET_PREFERENCES: \"2\",\n} as const;\n\n/**\n * The ttyd handshake's first frame: an auth message. ttyd expects\n * `JSON.stringify({ AuthToken })` as the FIRST text frame on the socket. We send\n * an empty token — our gate is the tunnel URL + scoped stream token, NOT a ttyd\n * `-c` basic-auth credential (which the box does not set in v1). Optional ttyd\n * `columns`/`rows` can ride this frame to seed the PTY size before the first\n * resize. Pure (string-building only) so it stays unit-testable in the SDK.\n */\nexport function ttydAuthFrame(opts?: { columns?: number; rows?: number }): string {\n const frame: { AuthToken: string; columns?: number; rows?: number } = { AuthToken: \"\" };\n if (opts?.columns && opts.columns > 0) frame.columns = opts.columns;\n if (opts?.rows && opts.rows > 0) frame.rows = opts.rows;\n return JSON.stringify(frame);\n}\n\n/** Build a client→server INPUT (stdin) frame: \"0\" + data. */\nexport function ttydInputFrame(data: string): string {\n return TtydClientCommand.INPUT + data;\n}\n\n/** Build a client→server RESIZE frame: \"1\" + JSON.stringify({ columns, rows }). */\nexport function ttydResizeFrame(columns: number, rows: number): string {\n return TtydClientCommand.RESIZE + JSON.stringify({ columns, rows });\n}\n","export const WORKSPACE_INSTRUCTION_POLICY_CONTENT_MAX_CHARS = 262_144;\n\nexport type WorkspaceInstructionPolicyKind = \"charter\" | \"policy\";\nexport type WorkspaceInstructionPolicyScope = \"global\" | \"role\";\nexport type WorkspaceInstructionPolicyProvenanceSource =\n | \"human\"\n | \"onboarding\"\n | \"knowledge_proposal\"\n | \"legacy_import\";\nexport type WorkspaceInstructionPolicyDraftProvenanceSource = Exclude<\n WorkspaceInstructionPolicyProvenanceSource,\n \"legacy_import\"\n>;\nexport type WorkspaceInstructionPolicyActivationType = \"activate\" | \"rollback\";\n\nexport function normalizeWorkspaceInstructionPolicyRoleKey(value: string): string {\n return value.normalize(\"NFKC\").trim().toLowerCase().replace(/\\s+/gu, \"-\").replace(/-+/g, \"-\");\n}\n\nexport type WorkspaceInstructionPolicyTarget = {\n kind: WorkspaceInstructionPolicyKind;\n scope: WorkspaceInstructionPolicyScope;\n roleKey: string | null;\n};\n\nexport type WorkspaceInstructionPolicyRevisionIdentity = {\n id: string;\n revision: number;\n contentHash: string;\n};\n\nexport type WorkspaceInstructionPolicyRevision = WorkspaceInstructionPolicyRevisionIdentity &\n WorkspaceInstructionPolicyTarget & {\n operationId: string;\n accountId: string;\n workspaceId: string;\n content: string;\n provenance: {\n source: WorkspaceInstructionPolicyProvenanceSource;\n sourceId: string | null;\n };\n supersedesRevisionId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n };\n\nexport type WorkspaceInstructionPolicyHead = WorkspaceInstructionPolicyTarget & {\n workspaceId: string;\n revisionId: string;\n revision: number;\n contentHash: string;\n activationVersion: number;\n activatedAt: string;\n};\n\nexport type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPolicyTarget & {\n id: string;\n operationId: string;\n accountId: string;\n workspaceId: string;\n type: WorkspaceInstructionPolicyActivationType;\n activationVersion: number;\n oldRevision: WorkspaceInstructionPolicyRevisionIdentity | null;\n newRevision: WorkspaceInstructionPolicyRevisionIdentity;\n actorSubjectId: string;\n reason: string;\n createdAt: string;\n};\n\nexport type CreateWorkspaceInstructionPolicyDraftRequest = WorkspaceInstructionPolicyTarget & {\n operationId?: string;\n content: string;\n provenanceSource?: WorkspaceInstructionPolicyDraftProvenanceSource;\n provenanceSourceId?: string | null;\n supersedesRevisionId?: string | null;\n};\n\nexport type ImportLegacyWorkspaceInstructionPolicyDraftRequest = {\n operationId?: string;\n supersedesRevisionId?: string | null;\n};\n\nexport type WorkspaceInstructionPolicyListOptions = {\n kind?: WorkspaceInstructionPolicyKind;\n scope?: WorkspaceInstructionPolicyScope;\n roleKey?: string;\n afterRevision?: number;\n limit?: number;\n};\n\nexport type WorkspaceInstructionPolicyListResponse = {\n revisions: WorkspaceInstructionPolicyRevision[];\n activeHeads: WorkspaceInstructionPolicyHead[];\n activationEvents: WorkspaceInstructionPolicyActivationEvent[];\n nextAfterRevision: number | null;\n};\n\nexport type WorkspaceInstructionPolicyDiffRequest = {\n fromRevisionId: string;\n toRevisionId: string;\n};\n\nexport type WorkspaceInstructionPolicyDiffResponse = {\n from: WorkspaceInstructionPolicyRevision;\n to: WorkspaceInstructionPolicyRevision;\n format: \"unified\";\n diff: string;\n};\n\nexport type ActivateWorkspaceInstructionPolicyRequest = {\n operationId?: string;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion?: number;\n reason: string;\n};\n\nexport type RollbackWorkspaceInstructionPolicyRequest = {\n operationId?: string;\n targetRevisionId: string;\n expectedCurrentRevisionId: string;\n expectedActivationVersion?: number;\n reason: string;\n};\n\nexport type WorkspaceInstructionPolicyActivationResponse = {\n head: WorkspaceInstructionPolicyHead;\n event: WorkspaceInstructionPolicyActivationEvent;\n};\n\nexport type WorkspaceInstructionPolicyConflictResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_CONFLICT\";\n message: string;\n currentHead: WorkspaceInstructionPolicyHead | null;\n};\n\nexport type WorkspaceInstructionPolicyOperationReuseResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_OPERATION_REUSED\";\n message: string;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalSource = {\n id: string;\n version: string;\n confidenceBps: number;\n};\n\nexport type CreateWorkspaceInstructionPolicyOnboardingProposalRequest =\n WorkspaceInstructionPolicyTarget & {\n operationId?: string;\n content: string;\n sourceId: string;\n sourceVersion: string;\n confidenceBps: number;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion: number;\n };\n\nexport type WorkspaceInstructionPolicyOnboardingProposal = WorkspaceInstructionPolicyTarget & {\n id: string;\n operationId: string;\n accountId: string;\n workspaceId: string;\n source: WorkspaceInstructionPolicyOnboardingProposalSource;\n baseline: WorkspaceInstructionPolicyHead | null;\n draft: WorkspaceInstructionPolicyRevision;\n status: \"proposed\";\n createdBySubjectId: string;\n createdAt: string;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalListOptions = {\n limit?: number;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalListResponse = {\n proposals: WorkspaceInstructionPolicyOnboardingProposal[];\n truncated: boolean;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalContentErrorResponse = {\n code:\n | \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_EMPTY\"\n | \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_OVERSIZED\";\n message: string;\n maxChars: number;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalStaleResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_STALE\";\n message: string;\n currentHead: WorkspaceInstructionPolicyHead | null;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalConflictResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_CONFLICT\";\n message: string;\n existingProposalId: string;\n existingDraftRevisionId: string;\n};\n","export const COMPANY_PROFILE_SCALAR_MAX_CHARS = 2_048;\nexport const COMPANY_PROFILE_ENTRY_MAX_CHARS = 1_024;\nexport const COMPANY_PROFILE_ENTRY_MAX_COUNT = 16;\n\nexport type CompanyProfileEntry = { key: string; content: string };\nexport type CompanyProfileContent = {\n identity: string | null;\n mission: string | null;\n products: CompanyProfileEntry[];\n customers: CompanyProfileEntry[];\n goals: CompanyProfileEntry[];\n constraints: CompanyProfileEntry[];\n};\nexport type CompanyProfileRevisionIdentity = {\n id: string;\n revision: number;\n contentHash: string;\n};\nexport type CompanyProfileRevision = CompanyProfileRevisionIdentity & {\n operationId: string;\n accountId: string;\n intent: \"active\" | \"proposal\";\n profile: CompanyProfileContent;\n provenance: { source: \"human\" | \"durable_learning\" | \"migration\"; sourceId: string | null };\n supersedesRevisionId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n};\nexport type CompanyProfileHead = {\n accountId: string;\n revisionId: string;\n revision: number;\n contentHash: string;\n activationVersion: number;\n activatedAt: string;\n};\nexport type CompanyProfileActivationEvent = {\n id: string;\n operationId: string;\n accountId: string;\n type: \"activate\" | \"rollback\";\n activationVersion: number;\n oldRevision: CompanyProfileRevisionIdentity | null;\n newRevision: CompanyProfileRevisionIdentity | null;\n actorSubjectId: string;\n reason: string;\n createdAt: string;\n};\nexport type CompanyProfileListOptions = { afterRevision?: number; limit?: number };\nexport type CompanyProfileListResponse = {\n current: CompanyProfileHead | null;\n activeRevision: CompanyProfileRevision | null;\n revisions: CompanyProfileRevision[];\n activationEvents: CompanyProfileActivationEvent[];\n nextAfterRevision: number | null;\n};\nexport type UpdateCompanyProfileRequest = {\n operationId?: string;\n profile: CompanyProfileContent;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion: number;\n reason: string;\n};\nexport type ActivateCompanyProfileRevisionRequest = {\n operationId?: string;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion: number;\n reason: string;\n};\nexport type RollbackCompanyProfileRequest = {\n operationId?: string;\n targetRevisionId: string;\n expectedCurrentRevisionId: string;\n expectedActivationVersion: number;\n reason: string;\n};\nexport type CompanyProfileMutationResponse = {\n revision: CompanyProfileRevision | null;\n head: CompanyProfileHead | null;\n event: CompanyProfileActivationEvent | null;\n};\nexport type CompanyProfileDiffRequest = { fromRevisionId: string; toRevisionId: string };\nexport type CompanyProfileDiffResponse = {\n from: CompanyProfileRevision;\n to: CompanyProfileRevision;\n format: \"unified_json\";\n diff: string;\n};\n\nexport function normalizeCompanyProfileStableKey(value: string): string {\n return value.normalize(\"NFKC\").trim().toLowerCase().replace(/\\s+/gu, \"-\").replace(/-+/g, \"-\");\n}\n","export type PreferenceRegistryScope = \"organization\" | \"workspace\" | \"user\";\nexport type PreferenceRegistryStatus =\n | \"proposed\"\n | \"active\"\n | \"inactive\"\n | \"rejected\"\n | \"superseded\"\n | \"expired\";\nexport type PreferenceRegistryProvenanceSource =\n | \"human\"\n | \"onboarding\"\n | \"knowledge_proposal\"\n | \"imported_document\"\n | \"slack\"\n | \"meeting_transcript\"\n | \"call_transcript\";\nexport type PreferenceRegistryTrust =\n | \"untrusted_proposal\"\n | \"personal\"\n | \"workspace_managed\"\n | \"organization_managed\";\nexport type PreferenceRegistryConflictStrategy = \"override\" | \"merge\" | \"reject\" | \"inform\";\n\nexport function normalizePreferenceRegistryStableKey(value: string): string {\n return value.normalize(\"NFKC\").trim().toLowerCase().replace(/\\s+/gu, \"-\").replace(/-+/g, \"-\");\n}\n\nexport type PreferenceRegistryScopeTarget = {\n scope: PreferenceRegistryScope;\n workspaceId: string | null;\n subjectId: string | null;\n};\n\nexport type PreferenceRegistryPrecedence = {\n tier: PreferenceRegistryScope;\n rank: number;\n conflictStrategy: PreferenceRegistryConflictStrategy;\n conflictsWith: string[];\n};\n\nexport type PreferenceRegistryRevisionSummary = {\n id: string;\n preferenceId: string;\n revision: number;\n contentHash: string;\n title: string;\n description: string;\n precedence: PreferenceRegistryPrecedence;\n provenance: {\n source: PreferenceRegistryProvenanceSource;\n sourceId: string | null;\n trust: PreferenceRegistryTrust;\n };\n expiresAt: string | null;\n correctsRevisionId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n};\n\nexport type PreferenceRegistryDescriptorProvenance = {\n source: PreferenceRegistryProvenanceSource;\n sourceIdHash: string | null;\n trust: PreferenceRegistryTrust;\n};\n\nexport type PreferenceRegistryRecord = {\n id: string;\n accountId: string;\n stableKey: string;\n target: PreferenceRegistryScopeTarget;\n status: PreferenceRegistryStatus;\n scopeVersion: number;\n activationVersion: number;\n activeRevision: PreferenceRegistryRevisionSummary | null;\n supersededByPreferenceId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n updatedAt: string;\n};\n\nexport type PreferenceRegistryEvent = {\n id: string;\n accountId: string;\n preferenceId: string;\n type:\n | \"proposal_created\"\n | \"activated\"\n | \"corrected\"\n | \"rejected\"\n | \"deactivated\"\n | \"superseded\"\n | \"scope_changed\";\n version: number;\n oldRevisionId: string | null;\n newRevisionId: string | null;\n oldTarget: PreferenceRegistryScopeTarget | null;\n newTarget: PreferenceRegistryScopeTarget | null;\n relatedPreferenceId: string | null;\n actorSubjectId: string;\n reason: string;\n createdAt: string;\n};\n\nexport type PreferenceRegistryDescriptor = {\n id: string;\n stableKey: string;\n title: string;\n description: string;\n scope: PreferenceRegistryScope;\n activeVersion: number;\n revisionId: string;\n contentHash: string;\n precedence: PreferenceRegistryPrecedence;\n provenance: PreferenceRegistryDescriptorProvenance;\n expiresAt: string | null;\n retrievalHandle: string;\n};\n\nexport type PreferenceRegistrySnapshot = {\n id: string;\n workspaceId: string;\n sessionId: string;\n turnId: string;\n attemptId: string;\n executionGeneration: number;\n initiatingHumanSubjectId: string;\n descriptorHash: string;\n descriptors: PreferenceRegistryDescriptor[];\n truncated: boolean;\n createdAt: string;\n};\n\nexport type PreferenceRegistryFullContent = {\n descriptor: PreferenceRegistryDescriptor;\n content: string;\n};\n\nexport type CreatePreferenceRegistryProposalRequest = {\n stableKey: string;\n scope: PreferenceRegistryScope;\n title: string;\n description: string;\n content: string;\n precedenceRank?: number;\n conflictStrategy?: PreferenceRegistryConflictStrategy;\n conflictsWith?: string[];\n expiresAt?: string | null;\n provenanceSource?: PreferenceRegistryProvenanceSource;\n provenanceSourceId?: string | null;\n};\n\nexport type ActivatePreferenceRegistryRevisionRequest = {\n revisionId: string;\n expectedCurrentRevisionId: string | null;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type CorrectPreferenceRegistryRequest = {\n expectedCurrentRevisionId: string;\n expectedScopeVersion: number;\n title: string;\n description: string;\n content: string;\n precedenceRank?: number;\n conflictStrategy?: PreferenceRegistryConflictStrategy;\n conflictsWith?: string[];\n expiresAt?: string | null;\n reason: string;\n};\n\nexport type DeactivatePreferenceRegistryRequest = {\n expectedCurrentRevisionId: string;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type ChangePreferenceRegistryScopeRequest = {\n scope: PreferenceRegistryScope;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type SupersedePreferenceRegistryRequest = {\n replacementPreferenceId: string;\n expectedCurrentRevisionId: string;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type RejectPreferenceRegistryProposalRequest = {\n revisionId: string;\n expectedScopeVersion: number;\n reason: string;\n};\nexport type PreferenceRegistryListOptions = {\n scope?: PreferenceRegistryScope;\n status?: PreferenceRegistryStatus;\n limit?: number;\n};\nexport type PreferenceRegistryListResponse = { preferences: PreferenceRegistryRecord[] };\nexport type PreferenceRegistryDetailResponse = {\n preference: PreferenceRegistryRecord;\n revisions: PreferenceRegistryRevisionSummary[];\n events: PreferenceRegistryEvent[];\n};\nexport type PreferenceRegistryMutationResponse = {\n preference: PreferenceRegistryRecord;\n event: PreferenceRegistryEvent;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,eAAe,OAA6B;AAC1D,SAAO,OAAO,MAAM,QAAQ;AAAA,SAAY,MAAM,IAAI;AAAA,QAAW,KAAK,UAAU,KAAK,CAAC;AAAA;AAAA;AACpF;AAqBO,SAAS,yBACd,QACA,UAA8B,CAAC,GACH;AAC5B,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,WAAW,OAAO,OAAO,aAAa,EAAE;AAC9C,MAAI;AACJ,MAAI,YAAY;AAEhB,QAAM,gBAAgB,MAAY;AAChC,QAAI,cAAc,QAAW;AAC3B,oBAAc,SAAS;AACvB,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAO,IAAI,eAA2B;AAAA,IACpC,OAAO,CAAC,eAAe;AACrB,UAAI,QAAQ,gBAAgB,QAAW;AACrC,oBAAY,YAAY,MAAM;AAC5B,cAAI;AACF,uBAAW,QAAQ,QAAQ,OAAO,YAAY,CAAC;AAAA,UACjD,QAAQ;AACN,0BAAc;AAAA,UAChB;AAAA,QACF,GAAG,QAAQ,WAAW;AAAA,MACxB;AAAA,IACF;AAAA,IACA,MAAM,OAAO,eAAe;AAC1B,UAAI;AACJ,UAAI;AACF,iBAAS,MAAM,SAAS,KAAK;AAAA,MAC/B,SAAS,OAAO;AACd,sBAAc;AACd,cAAM;AAAA,MACR;AACA,UAAI,WAAW;AACb;AAAA,MACF;AACA,UAAI,OAAO,MAAM;AACf,sBAAc;AACd,mBAAW,MAAM;AACjB;AAAA,MACF;AACA,iBAAW,QAAQ,QAAQ,OAAO,eAAe,OAAO,KAAK,CAAC,CAAC;AAAA,IACjE;AAAA,IACA,QAAQ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AC;AACpE;;;AC1FO,IAAM,iDAAiD;AAevD,SAAS,2CAA2C,OAAuB;AAChF,SAAO,MAAM,UAAU,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,GAAG;AAC9F;;;ACjBO,IAAM,mCAAmC;AACzC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AAuFxC,SAAS,iCAAiC,OAAuB;AACtE,SAAO,MAAM,UAAU,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,GAAG;AAC9F;;;ACpEO,SAAS,qCAAqC,OAAuB;AAC1E,SAAO,MAAM,UAAU,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,GAAG;AAC9F;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../contracts/src/mcp-endpoint.ts","../src/tool-display-metadata.ts","../src/mcp-output.ts","../src/desktop.ts","../src/terminal.ts","../src/workspace-instruction-policies.ts","../src/company-profile.ts","../src/company-brain.ts","../src/preference-registry.ts"],"sourcesContent":["/** Exact endpoint identity: normalize URL syntax, preserve paths and query parameters. */\nexport function mcpEndpointIdentity(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n const url = new URL(value);\n if (![\"https:\", \"http:\"].includes(url.protocol) || url.username || url.password) return null;\n url.hash = \"\";\n return url.href;\n } catch {\n return null;\n }\n}\n\nexport function pluginMcpUnavailableReason(server: {\n endpoint: string | null;\n transport?: string;\n requiresConfiguration?: boolean;\n}): string | null {\n if (server.transport === \"stdio\" || !server.endpoint) return \"Requires a local runtime\";\n if (\n server.transport &&\n ![\"http\", \"streamable-http\", \"streamable_http\"].includes(server.transport)\n )\n return \"Unsupported transport: \" + server.transport;\n if (server.requiresConfiguration || server.endpoint.includes(\"{\"))\n return \"Requires custom connection configuration\";\n const endpoint = mcpEndpointIdentity(server.endpoint);\n if (!endpoint?.startsWith(\"https://\")) return \"Requires a valid HTTPS endpoint\";\n return null;\n}\n","import type { ToolDisplayMetadata } from \"@opengeni/contracts\";\n\n/** Browser/native-safe event projection; do not import server schema runtimes. */\nexport function parseToolDisplayMetadata(value: unknown): ToolDisplayMetadata | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const item = value as Record<string, unknown>;\n if (Object.keys(item).some((key) => ![\"toolName\", \"title\", \"accountLabel\"].includes(key)))\n return undefined;\n const text = (v: unknown, max: number): v is string =>\n typeof v === \"string\" && v.length > 0 && v.length <= max;\n if (!text(item.toolName, 512) || /[\\u0000-\\u001f\\u007f]/u.test(item.toolName)) return undefined;\n if (item.title !== undefined && !text(item.title, 512)) return undefined;\n if (item.accountLabel !== undefined && !text(item.accountLabel, 1024)) return undefined;\n return {\n toolName: item.toolName,\n ...(item.title !== undefined ? { title: item.title as string } : {}),\n ...(item.accountLabel !== undefined ? { accountLabel: item.accountLabel as string } : {}),\n };\n}\n","/**\n * A transport-tolerant MCP tool result.\n *\n * `value` is the canonical machine-readable payload after recognized MCP/JSON\n * envelopes are removed. `text` is the best presentation string without\n * discarding structured data. `raw` always retains the original evidence.\n */\nexport type NormalizedMcpOutput = Readonly<{\n raw: unknown;\n value: unknown;\n text: string;\n isError: boolean;\n}>;\n\nconst MAX_MCP_OUTPUT_DEPTH = 8;\nconst RESULT_ENVELOPE_KEYS = new Set([\"result\", \"isError\", \"jsonrpc\", \"id\", \"_meta\"]);\n\n/** Normalize common direct, JSON, and standard MCP result envelopes without throwing. */\nexport function normalizeMcpOutput(output: unknown): NormalizedMcpOutput {\n const normalized = normalizeValue(output, 0, new Set<object>());\n return {\n raw: output,\n value: normalized.value,\n text: normalized.text,\n isError: normalized.isError,\n };\n}\n\ntype NormalizedValue = Omit<NormalizedMcpOutput, \"raw\">;\n\nfunction normalizeValue(value: unknown, depth: number, ancestors: Set<object>): NormalizedValue {\n if (value === null || value === undefined) {\n return { value, text: \"\", isError: false };\n }\n if (typeof value === \"string\") {\n return normalizeText(value, depth, ancestors);\n }\n if (typeof value !== \"object\") {\n return { value, text: String(value), isError: false };\n }\n if (depth >= MAX_MCP_OUTPUT_DEPTH || ancestors.has(value)) {\n return { value, text: safeStringify(value), isError: false };\n }\n\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n return { value, text: safeStringify(value), isError: false };\n }\n\n const record = value as Record<string, unknown>;\n const envelopeError = record.isError === true;\n\n if (record.type === \"text\" && typeof record.text === \"string\") {\n const normalized = normalizeText(record.text, depth + 1, ancestors);\n return {\n value: normalized.value,\n text: record.text,\n isError: envelopeError || normalized.isError,\n };\n }\n\n if (\"structuredContent\" in record) {\n const normalized = normalizeValue(record.structuredContent, depth + 1, ancestors);\n return {\n value: normalized.value,\n text: firstMcpText(record.content) ?? normalized.text,\n isError: envelopeError || normalized.isError,\n };\n }\n\n if (isMcpContent(record.content)) {\n const text = firstMcpText(record.content);\n if (text !== null) {\n const normalized = normalizeText(text, depth + 1, ancestors);\n return {\n value: normalized.value,\n text,\n isError: envelopeError || normalized.isError,\n };\n }\n return {\n value,\n text: safeStringify(value),\n isError: envelopeError,\n };\n }\n\n if (isResultEnvelope(record)) {\n const normalized = normalizeValue(record.result, depth + 1, ancestors);\n return {\n value: normalized.value,\n text: normalized.text,\n isError: envelopeError || normalized.isError,\n };\n }\n\n return {\n value,\n text: safeStringify(value),\n isError: envelopeError,\n };\n } finally {\n ancestors.delete(value);\n }\n}\n\nfunction normalizeText(text: string, depth: number, ancestors: Set<object>): NormalizedValue {\n try {\n const parsed: unknown = JSON.parse(text);\n const normalized = normalizeValue(parsed, depth + 1, ancestors);\n return {\n value: normalized.value,\n text,\n isError: normalized.isError,\n };\n } catch {\n return { value: text, text, isError: false };\n }\n}\n\nfunction isMcpContent(value: unknown): value is readonly Record<string, unknown>[] {\n return (\n Array.isArray(value) &&\n value.some(\n (part) =>\n part !== null &&\n typeof part === \"object\" &&\n typeof (part as { type?: unknown }).type === \"string\",\n )\n );\n}\n\nfunction firstMcpText(value: unknown): string | null {\n if (!Array.isArray(value)) {\n return null;\n }\n for (const part of value) {\n if (\n part !== null &&\n typeof part === \"object\" &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n }\n return null;\n}\n\nfunction isResultEnvelope(record: Record<string, unknown>): boolean {\n return \"result\" in record && Object.keys(record).every((key) => RESULT_ENVELOPE_KEYS.has(key));\n}\n\nfunction safeStringify(value: unknown): string {\n try {\n return JSON.stringify(value) ?? \"\";\n } catch {\n return String(value);\n }\n}\n","// Zero-dependency desktop (noVNC) transport contract.\n//\n// The actual `@novnc/novnc` RFB import is a browser-only DOM dependency and\n// lives in `@opengeni/react` (lazily imported, SSR-safe). The framework-agnostic\n// SDK ships only the transport CONTRACT: a URL assembler, the minimal RFB\n// surface the component drives, the connection state machine, and the\n// rotation/fence reducers — all pure and unit-testable, with no DOM and no deps.\n//\n// Channel A (terminal-as-events, files, git) needs NO new transport here: those\n// are event projections + the synchronous fs/git/terminal point queries on\n// `OpenGeniClient`. Only the desktop pixel plane (Channel B, direct-to-provider)\n// needs this.\n\nimport type { DesktopStreamCapability, StreamUrlRotatedPayload } from \"./types\";\n\n/**\n * Translate the negotiated desktop capability into the WebSocket URL the noVNC\n * RFB client connects to. The scoped provider token is ALREADY embedded in the\n * minted `url` (Modal tunnel host, Blaxel `bl_preview_token`, Daytona signed\n * preview) by `session.resolveExposedPort(6080)` — we do NOT append `cap.token`\n * as a query param (that double-auth was an adversarial-review bug: the box runs\n * `-nopw` in v1, so the RFB password is meaningless and the real auth is the\n * tunnel token in the host). We only normalize the scheme to `ws`/`wss` and, when\n * the minted URL points at a `vnc.html` viewer page, rewrite it to the\n * websockify socket path noVNC actually dials.\n */\nexport function desktopSocketUrl(cap: Pick<DesktopStreamCapability, \"url\">): string {\n if (!cap.url) {\n throw new Error(\"desktop capability has no url (transport is null)\");\n }\n const u = new URL(cap.url);\n // https → wss, http → ws (noVNC dials a WebSocket, not the HTTP viewer page).\n if (u.protocol === \"https:\") {\n u.protocol = \"wss:\";\n } else if (u.protocol === \"http:\") {\n u.protocol = \"ws:\";\n }\n // A minted `…/vnc.html` (or `…/vnc_lite.html`) viewer page → the websockify\n // socket the page itself would open (`…/websockify`). A bare host/path with no\n // viewer page is already the socket path; leave it untouched.\n if (/\\/vnc(_lite)?\\.html$/.test(u.pathname)) {\n u.pathname = u.pathname.replace(/\\/vnc(_lite)?\\.html$/, \"/websockify\");\n u.search = \"\";\n u.hash = \"\";\n }\n return u.toString();\n}\n\n/**\n * The minimal RFB surface the React component drives. Lets tests (and 3rd\n * parties swapping noVNC for a WebRTC client in v3) provide a fake without the\n * DOM. Matches `@novnc/novnc`'s RFB constructor + lifecycle.\n */\nexport interface DesktopRfbLike {\n viewOnly: boolean;\n scaleViewport: boolean;\n /**\n * 1:1 viewport clipping. We always drive this FALSE: with clipping on, noVNC\n * paints the framebuffer pixel-for-pixel and scrolls/crops to the container\n * (the \"zoomed in\" look). FALSE lets `scaleViewport` shrink the 1280x800 frame\n * to fit the panel (aspect-preserved). Declared so the hook can pin it instead\n * of relying on noVNC's default — `scaleViewport=true` forces clip off\n * internally, but a stale/partial state on reconnect could leave it on.\n */\n clipViewport: boolean;\n addEventListener(\n type: \"connect\" | \"disconnect\" | \"securityfailure\",\n cb: (e?: unknown) => void,\n ): void;\n removeEventListener?: (\n type: \"connect\" | \"disconnect\" | \"securityfailure\",\n cb: (e?: unknown) => void,\n ) => void;\n /** Send clipboard text over the already-open RFB connection. */\n clipboardPasteFrom?(text: string): void;\n /** Send one RFB key event. A missing `down` emits a complete key press. */\n sendKey?(keysym: number, code: string, down?: boolean): void;\n /** Focus or release the RFB keyboard sink without reconnecting. */\n focus?(options?: FocusOptions): void;\n blur?(): void;\n disconnect(): void;\n}\n\nexport type DesktopRfbFactory = (\n target: HTMLElement,\n url: string,\n opts: {\n credentials?: { password?: string | undefined } | undefined;\n wsProtocols?: string[] | undefined;\n },\n) => DesktopRfbLike;\n\nexport type DesktopConnectionState =\n | \"idle\"\n | \"negotiating\"\n | \"connecting\"\n | \"connected\"\n | \"rotating\"\n | \"reconnecting\"\n | \"error\"\n | \"ended\";\n\nexport type DesktopStreamEvent =\n | { type: \"negotiated\" }\n | { type: \"connected\" }\n | { type: \"disconnected\" }\n | { type: \"rotate\" }\n | { type: \"fail\" }\n | { type: \"abort\" };\n\n/**\n * Pure reducer for the desktop connection lifecycle. The component owns the RFB\n * object + DOM; this owns the transitions so they are unit-testable. Mirrors the\n * Channel-A stream reducer discipline.\n */\nexport function nextDesktopState(\n current: DesktopConnectionState,\n ev: DesktopStreamEvent,\n): DesktopConnectionState {\n switch (ev.type) {\n case \"negotiated\":\n return \"connecting\";\n case \"connected\":\n return \"connected\";\n case \"rotate\":\n return current === \"connected\" ? \"rotating\" : current;\n case \"disconnected\":\n // A deliberate teardown (ended) stays ended; everything else reconnects.\n return current === \"ended\" ? \"ended\" : \"reconnecting\";\n case \"fail\":\n return \"error\";\n case \"abort\":\n return \"ended\";\n default:\n return current;\n }\n}\n\n// `DesktopStreamCapability` is the desktop cell of `SessionCapabilities`; alias\n// it for the rotation reducer below without depending on the whole doc.\nexport type DesktopStreamCapabilityLike = {\n url: string | null;\n token: string | null;\n expiresAt: string | null;\n};\n\n/**\n * Apply a `stream.url.rotated` event onto a desktop capability, fencing on\n * leaseEpoch (split-brain). A rotation minted under an epoch the client has\n * already advanced PAST is from a superseded owner and is dropped (returns\n * null); otherwise the fresh url/token/expiresAt are folded in.\n */\nexport function applyUrlRotation<T extends DesktopStreamCapabilityLike>(\n cap: T,\n payload: StreamUrlRotatedPayload,\n knownEpoch: number,\n): T | null {\n if (payload.leaseEpoch < knownEpoch) {\n return null;\n }\n return { ...cap, url: payload.url, token: payload.token, expiresAt: payload.expiresAt };\n}\n","// Zero-dependency interactive-terminal (ttyd PTY-over-websocket) transport\n// contract. Symmetric with `desktop.ts`: the SDK ships only the pure transport\n// CONTRACT (a URL assembler + the ttyd wire-protocol frame codec), with no DOM\n// and no deps. The actual WebSocket open + xterm attach lives in `@opengeni/react`\n// (`use-terminal-stream.ts`).\n//\n// The interactive terminal is a REAL PTY streamed over the SAME Modal raw-TLS\n// tunnel as the desktop noVNC, with the SAME scoped stream-token mechanism. The\n// box bakes `ttyd` on `TERMINAL_STREAM_PORT` (7681); `session.resolveExposedPort`\n// mints the tunnel URL. The Terminal capability cell carries transport \"pty-ws\" +\n// that url + the scoped token when the box is warm and a viewer is attached.\n\nimport type { TerminalCapability } from \"./types\";\n\n/**\n * Translate the negotiated `pty-ws` Terminal capability into the WebSocket URL\n * the ttyd client dials. The scoped provider token is ALREADY embedded in the\n * minted `url` (the Modal tunnel host) by `session.resolveExposedPort(7681)` —\n * we do NOT append `cap.token` (identical posture to the desktop: the gate is the\n * unguessable short-TTL tunnel URL + the server-recorded scoped stream token; ttyd\n * runs `--writable` with no `-c` credential in v1). We only normalize the scheme\n * to `ws`/`wss`; a bare host is already the ttyd websocket endpoint.\n */\nexport function terminalSocketUrl(cap: Pick<TerminalCapability, \"url\">): string {\n if (!cap.url) {\n throw new Error(\"terminal capability has no url (transport is not pty-ws)\");\n }\n const u = new URL(cap.url);\n // https → wss, http → ws (ttyd is dialed as a WebSocket, not an HTTP page).\n if (u.protocol === \"https:\") {\n u.protocol = \"wss:\";\n } else if (u.protocol === \"http:\") {\n u.protocol = \"ws:\";\n }\n return u.toString();\n}\n\n// ── ttyd wire protocol ───────────────────────────────────────────────────────\n// ttyd frames are a single ASCII command char + payload. These mirror ttyd's\n// `protocol.h` Command enum. Client→server and server→client share the byte 0/1/2\n// values but mean different things per direction (see below).\n\n/** ttyd subprotocol — REQUIRED on the WebSocket handshake or ttyd refuses it. */\nexport const TTYD_SUBPROTOCOL = \"tty\";\n\n/** Client→server command bytes (the first char of each outbound text frame). */\nexport const TtydClientCommand = {\n /** stdin: \"0\" + raw input bytes. */\n INPUT: \"0\",\n /** window resize: \"1\" + JSON.stringify({ columns, rows }). */\n RESIZE: \"1\",\n /** flow-control pause (back-pressure): \"2\". */\n PAUSE: \"2\",\n /** flow-control resume: \"3\". */\n RESUME: \"3\",\n} as const;\n\n/** Server→client command bytes (the first char of each inbound frame). */\nexport const TtydServerCommand = {\n /** stdout/stderr: \"0\" + raw output bytes (write the rest into xterm). */\n OUTPUT: \"0\",\n /** set the window title: \"1\" + title string. */\n SET_WINDOW_TITLE: \"1\",\n /** ttyd client preferences JSON: \"2\" + json (ignored by us). */\n SET_PREFERENCES: \"2\",\n} as const;\n\n/**\n * The ttyd handshake's first frame: an auth message. ttyd expects\n * `JSON.stringify({ AuthToken })` as the FIRST text frame on the socket. We send\n * an empty token — our gate is the tunnel URL + scoped stream token, NOT a ttyd\n * `-c` basic-auth credential (which the box does not set in v1). Optional ttyd\n * `columns`/`rows` can ride this frame to seed the PTY size before the first\n * resize. Pure (string-building only) so it stays unit-testable in the SDK.\n */\nexport function ttydAuthFrame(opts?: { columns?: number; rows?: number }): string {\n const frame: { AuthToken: string; columns?: number; rows?: number } = { AuthToken: \"\" };\n if (opts?.columns && opts.columns > 0) frame.columns = opts.columns;\n if (opts?.rows && opts.rows > 0) frame.rows = opts.rows;\n return JSON.stringify(frame);\n}\n\n/** Build a client→server INPUT (stdin) frame: \"0\" + data. */\nexport function ttydInputFrame(data: string): string {\n return TtydClientCommand.INPUT + data;\n}\n\n/** Build a client→server RESIZE frame: \"1\" + JSON.stringify({ columns, rows }). */\nexport function ttydResizeFrame(columns: number, rows: number): string {\n return TtydClientCommand.RESIZE + JSON.stringify({ columns, rows });\n}\n","export const WORKSPACE_INSTRUCTION_POLICY_CONTENT_MAX_CHARS = 262_144;\n\nexport type WorkspaceInstructionPolicyKind = \"charter\" | \"policy\";\nexport type WorkspaceInstructionPolicyScope = \"global\" | \"role\";\nexport type WorkspaceInstructionPolicyProvenanceSource =\n | \"human\"\n | \"onboarding\"\n | \"agent_learning\"\n | \"knowledge_proposal\"\n | \"legacy_import\";\nexport type WorkspaceInstructionPolicyDraftProvenanceSource = Exclude<\n WorkspaceInstructionPolicyProvenanceSource,\n \"legacy_import\" | \"agent_learning\"\n>;\nexport type WorkspaceInstructionPolicyActivationType = \"activate\" | \"rollback\";\n\nexport function normalizeWorkspaceInstructionPolicyRoleKey(value: string): string {\n return value.normalize(\"NFKC\").trim().toLowerCase().replace(/\\s+/gu, \"-\").replace(/-+/g, \"-\");\n}\n\nexport type WorkspaceInstructionPolicyTarget = {\n kind: WorkspaceInstructionPolicyKind;\n scope: WorkspaceInstructionPolicyScope;\n roleKey: string | null;\n};\n\nexport type WorkspaceInstructionPolicyRevisionIdentity = {\n id: string;\n revision: number;\n contentHash: string;\n};\n\nexport type WorkspaceInstructionPolicyRevision = WorkspaceInstructionPolicyRevisionIdentity &\n WorkspaceInstructionPolicyTarget & {\n operationId: string;\n accountId: string;\n workspaceId: string;\n content: string;\n provenance: {\n source: WorkspaceInstructionPolicyProvenanceSource;\n sourceId: string | null;\n };\n supersedesRevisionId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n };\n\nexport type WorkspaceInstructionPolicyHead = WorkspaceInstructionPolicyTarget & {\n workspaceId: string;\n revisionId: string;\n revision: number;\n contentHash: string;\n activationVersion: number;\n activatedAt: string;\n};\n\nexport type WorkspaceInstructionPolicyInactiveHead = WorkspaceInstructionPolicyTarget & {\n workspaceId: string;\n activationVersion: number;\n deactivatedAt: string;\n};\n\nexport type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPolicyTarget & {\n id: string;\n operationId: string;\n accountId: string;\n workspaceId: string;\n type: WorkspaceInstructionPolicyActivationType;\n activationVersion: number;\n oldRevision: WorkspaceInstructionPolicyRevisionIdentity | null;\n newRevision: WorkspaceInstructionPolicyRevisionIdentity;\n actorSubjectId: string;\n reason: string;\n createdAt: string;\n};\n\nexport type WorkspaceInstructionPolicyDeactivationEvent = WorkspaceInstructionPolicyTarget & {\n id: string;\n operationId: string;\n accountId: string;\n workspaceId: string;\n type: \"automatic_deactivate\";\n activationVersion: number;\n oldRevision: WorkspaceInstructionPolicyRevisionIdentity;\n actorSubjectId: string;\n reason: string;\n createdAt: string;\n};\n\nexport type CreateWorkspaceInstructionPolicyDraftRequest = WorkspaceInstructionPolicyTarget & {\n operationId?: string;\n content: string;\n provenanceSource?: WorkspaceInstructionPolicyDraftProvenanceSource;\n provenanceSourceId?: string | null;\n supersedesRevisionId?: string | null;\n};\n\nexport type ImportLegacyWorkspaceInstructionPolicyDraftRequest = {\n operationId?: string;\n supersedesRevisionId?: string | null;\n};\n\nexport type WorkspaceInstructionPolicyListOptions = {\n kind?: WorkspaceInstructionPolicyKind;\n scope?: WorkspaceInstructionPolicyScope;\n roleKey?: string;\n afterRevision?: number;\n limit?: number;\n};\n\nexport type WorkspaceInstructionPolicyListResponse = {\n revisions: WorkspaceInstructionPolicyRevision[];\n activeHeads: WorkspaceInstructionPolicyHead[];\n /** Additive current inactive target boundaries; absent on pre-controller servers. */\n inactiveHeads?: WorkspaceInstructionPolicyInactiveHead[];\n inactiveHeadsTruncated?: boolean;\n activationEvents: WorkspaceInstructionPolicyActivationEvent[];\n /** Additive lifecycle history; absent on pre-controller servers. */\n deactivationEvents?: WorkspaceInstructionPolicyDeactivationEvent[];\n nextAfterRevision: number | null;\n};\n\nexport type WorkspaceInstructionPolicyDiffRequest = {\n fromRevisionId: string;\n toRevisionId: string;\n};\n\nexport type WorkspaceInstructionPolicyDiffResponse = {\n from: WorkspaceInstructionPolicyRevision;\n to: WorkspaceInstructionPolicyRevision;\n format: \"unified\";\n diff: string;\n};\n\nexport type ActivateWorkspaceInstructionPolicyRequest = {\n operationId?: string;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion?: number;\n reason: string;\n};\n\nexport type RollbackWorkspaceInstructionPolicyRequest = {\n operationId?: string;\n targetRevisionId: string;\n expectedCurrentRevisionId: string;\n expectedActivationVersion?: number;\n reason: string;\n};\n\nexport type WorkspaceInstructionPolicyActivationResponse = {\n head: WorkspaceInstructionPolicyHead;\n event: WorkspaceInstructionPolicyActivationEvent;\n};\n\nexport type WorkspaceInstructionPolicyConflictResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_CONFLICT\";\n message: string;\n currentHead: WorkspaceInstructionPolicyHead | null;\n};\n\nexport type WorkspaceInstructionPolicyOperationReuseResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_OPERATION_REUSED\";\n message: string;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalSource = {\n id: string;\n version: string;\n confidenceBps: number;\n};\n\nexport type CreateWorkspaceInstructionPolicyOnboardingProposalRequest =\n WorkspaceInstructionPolicyTarget & {\n operationId?: string;\n content: string;\n sourceId: string;\n sourceVersion: string;\n confidenceBps: number;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion: number;\n };\n\nexport type WorkspaceInstructionPolicyOnboardingProposal = WorkspaceInstructionPolicyTarget & {\n id: string;\n operationId: string;\n accountId: string;\n workspaceId: string;\n source: WorkspaceInstructionPolicyOnboardingProposalSource;\n baseline: WorkspaceInstructionPolicyHead | null;\n draft: WorkspaceInstructionPolicyRevision;\n status: \"proposed\";\n createdBySubjectId: string;\n createdAt: string;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalListOptions = {\n limit?: number;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalListResponse = {\n proposals: WorkspaceInstructionPolicyOnboardingProposal[];\n truncated: boolean;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalContentErrorResponse = {\n code:\n | \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_EMPTY\"\n | \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_OVERSIZED\";\n message: string;\n maxChars: number;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalStaleResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_STALE\";\n message: string;\n currentHead: WorkspaceInstructionPolicyHead | null;\n};\n\nexport type WorkspaceInstructionPolicyOnboardingProposalConflictResponse = {\n code: \"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_CONFLICT\";\n message: string;\n existingProposalId: string;\n existingDraftRevisionId: string;\n};\n","export const COMPANY_PROFILE_SCALAR_MAX_CHARS = 2_048;\nexport const COMPANY_PROFILE_ENTRY_MAX_CHARS = 1_024;\nexport const COMPANY_PROFILE_ENTRY_MAX_COUNT = 16;\n\nexport type CompanyProfileEntry = { key: string; content: string };\nexport type CompanyProfileContent = {\n identity: string | null;\n mission: string | null;\n products: CompanyProfileEntry[];\n customers: CompanyProfileEntry[];\n goals: CompanyProfileEntry[];\n constraints: CompanyProfileEntry[];\n};\nexport type CompanyProfileRevisionIdentity = {\n id: string;\n revision: number;\n contentHash: string;\n};\nexport type CompanyProfileRevision = CompanyProfileRevisionIdentity & {\n operationId: string;\n accountId: string;\n intent: \"active\" | \"proposal\";\n profile: CompanyProfileContent;\n provenance: {\n source: \"human\" | \"agent_admin\" | \"durable_learning\" | \"migration\";\n sourceId: string | null;\n };\n supersedesRevisionId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n};\nexport type CompanyProfileHead = {\n accountId: string;\n revisionId: string;\n revision: number;\n contentHash: string;\n activationVersion: number;\n activatedAt: string;\n};\nexport type CompanyProfileActivationEvent = {\n id: string;\n operationId: string;\n accountId: string;\n type: \"activate\" | \"rollback\";\n activationVersion: number;\n oldRevision: CompanyProfileRevisionIdentity | null;\n newRevision: CompanyProfileRevisionIdentity | null;\n actorSubjectId: string;\n reason: string;\n createdAt: string;\n};\nexport type CompanyProfileListOptions = { afterRevision?: number; limit?: number };\nexport type CompanyProfileListResponse = {\n current: CompanyProfileHead | null;\n activeRevision: CompanyProfileRevision | null;\n revisions: CompanyProfileRevision[];\n activationEvents: CompanyProfileActivationEvent[];\n nextAfterRevision: number | null;\n};\nexport type UpdateCompanyProfileRequest = {\n operationId?: string;\n profile: CompanyProfileContent;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion: number;\n reason: string;\n};\nexport type ActivateCompanyProfileRevisionRequest = {\n operationId?: string;\n expectedCurrentRevisionId: string | null;\n expectedActivationVersion: number;\n reason: string;\n};\nexport type RollbackCompanyProfileRequest = {\n operationId?: string;\n targetRevisionId: string;\n expectedCurrentRevisionId: string;\n expectedActivationVersion: number;\n reason: string;\n};\nexport type CompanyProfileMutationResponse = {\n revision: CompanyProfileRevision | null;\n head: CompanyProfileHead | null;\n event: CompanyProfileActivationEvent | null;\n};\nexport type CompanyProfileAgentPolicyMode = \"off\" | \"suggest\" | \"automatic\";\nexport type CompanyProfileAgentPolicy = {\n organizationId: string;\n mode: CompanyProfileAgentPolicyMode;\n version: number;\n updatedAt: string;\n changed?: boolean;\n};\nexport type UpdateCompanyProfileAgentPolicyRequest = {\n mode: CompanyProfileAgentPolicyMode;\n expectedVersion: number;\n operationId: string;\n};\nexport type CompanyProfileDiffRequest = { fromRevisionId: string; toRevisionId: string };\nexport type CompanyProfileDiffResponse = {\n from: CompanyProfileRevision;\n to: CompanyProfileRevision;\n format: \"unified_json\";\n diff: string;\n};\n\nexport function normalizeCompanyProfileStableKey(value: string): string {\n return value.normalize(\"NFKC\").trim().toLowerCase().replace(/\\s+/gu, \"-\").replace(/-+/g, \"-\");\n}\n","import type {\n CompanyBrainContextReceiptPage as ContractCompanyBrainContextReceiptPage,\n CompanyBrainKnowledgeProposalPage as ContractCompanyBrainKnowledgeProposalPage,\n CompanyBrainOkfPackage as ContractCompanyBrainOkfPackage,\n} from \"@opengeni/contracts\";\n\nexport type CompanyBrainOkfPackage = ContractCompanyBrainOkfPackage;\nexport type CompanyBrainContextReceiptPage = ContractCompanyBrainContextReceiptPage;\nexport type CompanyBrainKnowledgeProposalPage = ContractCompanyBrainKnowledgeProposalPage;\n\nexport type CompanyBrainContextReceiptListOptions = {\n attemptId?: string;\n cursor?: string;\n limit?: number;\n};\n\nexport type CompanyBrainKnowledgeProposalListOptions = {\n limit?: number;\n};\n\nexport type CompanyBrainInspectorTransport = {\n requestJson<T>(method: string, path: string, body?: unknown): Promise<T>;\n};\n\nfunction inspectorPath(workspaceId: string, suffix: string): string {\n return `/v1/workspaces/${workspaceId}/company-brain/${suffix}`;\n}\n\nexport function listCompanyBrainContextReceipts(\n client: CompanyBrainInspectorTransport,\n workspaceId: string,\n options: CompanyBrainContextReceiptListOptions = {},\n): Promise<CompanyBrainContextReceiptPage> {\n const params = new URLSearchParams();\n if (options.attemptId) params.set(\"attemptId\", options.attemptId);\n if (options.cursor) params.set(\"cursor\", options.cursor);\n if (options.limit !== undefined) params.set(\"limit\", String(options.limit));\n const query = params.toString();\n return client.requestJson(\n \"GET\",\n `${inspectorPath(workspaceId, \"context-receipts\")}${query ? `?${query}` : \"\"}`,\n );\n}\n\nexport function listCompanyBrainKnowledgeProposals(\n client: CompanyBrainInspectorTransport,\n workspaceId: string,\n options: CompanyBrainKnowledgeProposalListOptions = {},\n): Promise<CompanyBrainKnowledgeProposalPage> {\n const query =\n options.limit === undefined ? \"\" : `?limit=${encodeURIComponent(String(options.limit))}`;\n return client.requestJson(\"GET\", `${inspectorPath(workspaceId, \"knowledge-proposals\")}${query}`);\n}\n\nexport type CompanyBrainOkfDownload = {\n content: string;\n contentType: string;\n filename: string;\n};\n","export type PreferenceRegistryScope = \"organization\" | \"workspace\" | \"user\";\nexport type PreferenceRegistryStatus =\n | \"proposed\"\n | \"active\"\n | \"inactive\"\n | \"rejected\"\n | \"superseded\"\n | \"expired\";\nexport type PreferenceRegistryProvenanceSource =\n | \"human\"\n | \"onboarding\"\n | \"knowledge_proposal\"\n | \"agent\"\n | \"portable_skill\"\n | \"imported_document\"\n | \"slack\"\n | \"meeting_transcript\"\n | \"call_transcript\";\nexport type PreferenceRegistryTrust =\n | \"untrusted_proposal\"\n | \"personal\"\n | \"workspace_managed\"\n | \"organization_managed\";\nexport type PreferenceRegistryConflictStrategy = \"override\" | \"merge\" | \"reject\" | \"inform\";\n\nexport function normalizePreferenceRegistryStableKey(value: string): string {\n return value.normalize(\"NFKC\").trim().toLowerCase().replace(/\\s+/gu, \"-\").replace(/-+/g, \"-\");\n}\n\nexport type PreferenceRegistryScopeTarget = {\n scope: PreferenceRegistryScope;\n workspaceId: string | null;\n subjectId: string | null;\n};\n\nexport type PreferenceRegistryPrecedence = {\n tier: PreferenceRegistryScope;\n rank: number;\n conflictStrategy: PreferenceRegistryConflictStrategy;\n conflictsWith: string[];\n};\n\nexport type PreferenceRegistryRevisionSummary = {\n id: string;\n preferenceId: string;\n revision: number;\n contentHash: string;\n title: string;\n description: string;\n precedence: PreferenceRegistryPrecedence;\n provenance: {\n source: PreferenceRegistryProvenanceSource;\n sourceId: string | null;\n trust: PreferenceRegistryTrust;\n };\n expiresAt: string | null;\n correctsRevisionId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n};\n\nexport type PreferenceRegistryDescriptorProvenance = {\n source: PreferenceRegistryProvenanceSource;\n sourceIdHash: string | null;\n trust: PreferenceRegistryTrust;\n};\n\nexport type PreferenceRegistryRecord = {\n id: string;\n accountId: string;\n stableKey: string;\n target: PreferenceRegistryScopeTarget;\n status: PreferenceRegistryStatus;\n scopeVersion: number;\n activationVersion: number;\n activeRevision: PreferenceRegistryRevisionSummary | null;\n supersededByPreferenceId: string | null;\n createdBySubjectId: string;\n createdAt: string;\n updatedAt: string;\n};\n\nexport type PreferenceRegistryEvent = {\n id: string;\n accountId: string;\n preferenceId: string;\n type:\n | \"proposal_created\"\n | \"activated\"\n | \"corrected\"\n | \"rejected\"\n | \"deactivated\"\n | \"superseded\"\n | \"scope_changed\";\n version: number;\n oldRevisionId: string | null;\n newRevisionId: string | null;\n oldTarget: PreferenceRegistryScopeTarget | null;\n newTarget: PreferenceRegistryScopeTarget | null;\n relatedPreferenceId: string | null;\n actorSubjectId: string;\n reason: string;\n createdAt: string;\n};\n\nexport type PreferenceRegistryActivationAuthority = \"human_confirmed\" | \"automatic\";\n\nexport type PreferenceRegistryDescriptor = {\n id: string;\n stableKey: string;\n title: string;\n description: string;\n scope: PreferenceRegistryScope;\n activeVersion: number;\n revisionId: string;\n contentHash: string;\n precedence: PreferenceRegistryPrecedence;\n provenance: PreferenceRegistryDescriptorProvenance;\n /**\n * How the active revision became active. `provenance.trust` stays the frozen\n * creation-time fact; this is the separate activation question. Null when the\n * revision became active outside governed learning, or when the descriptor\n * predates this field.\n */\n activationAuthority: PreferenceRegistryActivationAuthority | null;\n expiresAt: string | null;\n retrievalHandle: string;\n};\n\nexport type PreferenceRegistrySnapshot = {\n id: string;\n workspaceId: string;\n sessionId: string;\n turnId: string;\n attemptId: string;\n executionGeneration: number;\n initiatingHumanSubjectId: string;\n descriptorHash: string;\n descriptors: PreferenceRegistryDescriptor[];\n truncated: boolean;\n createdAt: string;\n};\n\nexport type PreferenceRegistryFullContent = {\n descriptor: PreferenceRegistryDescriptor;\n content: string;\n};\n\nexport type CreatePreferenceRegistryProposalRequest = {\n stableKey: string;\n scope: PreferenceRegistryScope;\n title: string;\n description: string;\n content: string;\n precedenceRank?: number;\n conflictStrategy?: PreferenceRegistryConflictStrategy;\n conflictsWith?: string[];\n expiresAt?: string | null;\n provenanceSource?: PreferenceRegistryProvenanceSource;\n provenanceSourceId?: string | null;\n};\n\nexport type ActivatePreferenceRegistryRevisionRequest = {\n revisionId: string;\n expectedCurrentRevisionId: string | null;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type CorrectPreferenceRegistryRequest = {\n expectedCurrentRevisionId: string;\n expectedScopeVersion: number;\n title: string;\n description: string;\n content: string;\n precedenceRank?: number;\n conflictStrategy?: PreferenceRegistryConflictStrategy;\n conflictsWith?: string[];\n expiresAt?: string | null;\n reason: string;\n};\n\nexport type DeactivatePreferenceRegistryRequest = {\n expectedCurrentRevisionId: string;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type ChangePreferenceRegistryScopeRequest = {\n scope: PreferenceRegistryScope;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type SupersedePreferenceRegistryRequest = {\n replacementPreferenceId: string;\n expectedCurrentRevisionId: string;\n expectedScopeVersion: number;\n reason: string;\n};\n\nexport type RejectPreferenceRegistryProposalRequest = {\n revisionId: string;\n expectedScopeVersion: number;\n reason: string;\n};\nexport type PreferenceRegistryListOptions = {\n scope?: PreferenceRegistryScope;\n status?: PreferenceRegistryStatus;\n limit?: number;\n};\nexport type PreferenceRegistryListResponse = { preferences: PreferenceRegistryRecord[] };\nexport type PreferenceRegistryDetailResponse = {\n preference: PreferenceRegistryRecord;\n revisions: PreferenceRegistryRevisionSummary[];\n events: PreferenceRegistryEvent[];\n};\nexport type PreferenceRegistryMutationResponse = {\n preference: PreferenceRegistryRecord;\n event: PreferenceRegistryEvent;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACO,SAAS,oBAAoB,OAAiD;AACnF,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,KAAK;AACzB,QAAI,CAAC,CAAC,UAAU,OAAO,EAAE,SAAS,IAAI,QAAQ,KAAK,IAAI,YAAY,IAAI,SAAU,QAAO;AACxF,QAAI,OAAO;AACX,WAAO,IAAI;AAAA,EACb,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,2BAA2B,QAIzB;AAChB,MAAI,OAAO,cAAc,WAAW,CAAC,OAAO,SAAU,QAAO;AAC7D,MACE,OAAO,aACP,CAAC,CAAC,QAAQ,mBAAmB,iBAAiB,EAAE,SAAS,OAAO,SAAS;AAEzE,WAAO,4BAA4B,OAAO;AAC5C,MAAI,OAAO,yBAAyB,OAAO,SAAS,SAAS,GAAG;AAC9D,WAAO;AACT,QAAM,WAAW,oBAAoB,OAAO,QAAQ;AACpD,MAAI,CAAC,UA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,SAAS,gCACd,QACA,aACA,UAAiD,CAAC,GACT;AACzC,QAAM,SAAS,IAAI,gBAAgB;AACnC,MAAI,QAAQ,UAAW,QAAO,IAAI,aAAa,QAAQ,SAAS;AAChE,MAAI,QAAQ,OAAQ,QAAO,IAAI,UAAU,QAAQ,MAAM;AACvD,MAAI,QAAQ,UAAU,OAAW,QAAO,IAAI,SAAS,OAAO,QAAQ,KAAK,CAAC;AAC1E,QAAM,QAAQ,OAAO,SAAS;AAC9B,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,GAAG,cAAc,aAAa,kBAAkB,CAAC,GAAG,QAAQ,IAAI,KAAK,KAAK,EAAE;AAAA,EAC9E;AACF;AAEO,SAAS,mCACd,QACA,aACA,UAAoD,CAAC,GACT;AAC5C,QAAM,QACJ,QAAQ,UAAU,SAAY,KAAK,UAAU,mBAAmB,OAAO,QAAQ,KAAK,CAAC,CAAC;AACxF,SAAO,OAAO,YAAY,OAAO,GAAG,cAAc,aAAa,qBAAqB,CAAC,GAAG,KAAK,EAAE;AACjG;;;AC3BO,SAAS,qCAAqC,OAAuB;AAC1E,SAAO,MAAM,UAAU,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,GAAG;AAC9F;","names":[]}
|
package/dist/interaction.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { OpenGeniRequestOptions } from "./client.js";
|
|
2
|
+
import type { BrowserDomReadRequest, BrowserDomReadResponse, BrowserTargetState } from "@opengeni/contracts";
|
|
3
|
+
export type { BrowserDomReadRequest, BrowserDomReadResponse, BrowserDomSafeAttribute, BrowserTargetState, } from "@opengeni/contracts";
|
|
2
4
|
import type { RetainedArtifactReference } from "./types.js";
|
|
3
5
|
/** Public Browser/Computer protocol version. Driver and provider details stay private. */
|
|
4
6
|
export declare const INTERACTION_PROTOCOL_VERSION: 1;
|
|
@@ -20,6 +22,20 @@ export type WorkspaceInteractionRevisionEvent = {
|
|
|
20
22
|
export type InteractionJsonValue = null | string | number | boolean | InteractionJsonValue[] | {
|
|
21
23
|
[key: string]: InteractionJsonValue;
|
|
22
24
|
};
|
|
25
|
+
export type InteractionControlFailureCode = "unknown" | "unsupported" | "os" | "not_found" | "consent_required" | "timeout" | "draining" | "protocol" | "stream" | "agent_offline" | "fenced" | "payload_too_large";
|
|
26
|
+
export type InteractionControlFailure = {
|
|
27
|
+
layer: "connected_machine";
|
|
28
|
+
surface: "browser" | "computer";
|
|
29
|
+
code: InteractionControlFailureCode;
|
|
30
|
+
retryable: boolean;
|
|
31
|
+
outcomeUnknown: boolean;
|
|
32
|
+
requestId: string | undefined;
|
|
33
|
+
controlRequestId: string | undefined;
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
/** Decodes the bounded typed control-failure details emitted by OpenGeni. Raw
|
|
37
|
+
* provider/OS detail is intentionally absent; both correlation ids are opaque. */
|
|
38
|
+
export declare function interactionControlFailureFromError(error: unknown): InteractionControlFailure | null;
|
|
23
39
|
export type InteractionPlacement = {
|
|
24
40
|
kind: "sandbox_group";
|
|
25
41
|
sandboxGroupId: string;
|
|
@@ -69,8 +85,17 @@ export type AttachedBrowserDevice = {
|
|
|
69
85
|
createdAt: string;
|
|
70
86
|
updatedAt: string;
|
|
71
87
|
};
|
|
88
|
+
export type AttachedBrowserBridge = {
|
|
89
|
+
enrollmentId: string;
|
|
90
|
+
state: "online" | "offline";
|
|
91
|
+
bridgeGeneration: string;
|
|
92
|
+
inventoryRevision: number;
|
|
93
|
+
connectedProfileCount: number;
|
|
94
|
+
lastSeenAt: string;
|
|
95
|
+
};
|
|
72
96
|
export type AttachedBrowserDeviceListResponse = {
|
|
73
97
|
revision: number;
|
|
98
|
+
bridges: AttachedBrowserBridge[];
|
|
74
99
|
devices: AttachedBrowserDevice[];
|
|
75
100
|
};
|
|
76
101
|
export type InteractionControllerBinding = {
|
|
@@ -668,6 +693,14 @@ export type BrowserObservation = {
|
|
|
668
693
|
frameId: string | null;
|
|
669
694
|
semantic: InteractionSemanticSnapshot | InteractionSemanticDiff | null;
|
|
670
695
|
screenshot: RetainedArtifactReference | null;
|
|
696
|
+
viewport?: {
|
|
697
|
+
width: number;
|
|
698
|
+
height: number;
|
|
699
|
+
visualWidth: number;
|
|
700
|
+
visualHeight: number;
|
|
701
|
+
deviceScaleFactor: number;
|
|
702
|
+
maxTouchPoints: number;
|
|
703
|
+
} | null | undefined;
|
|
671
704
|
focusedRef: string | null;
|
|
672
705
|
changedRegions: InteractionRect[];
|
|
673
706
|
diagnostics: InteractionDiagnosticSummary;
|
|
@@ -724,6 +757,17 @@ export type BrowserPermissionSetting = "granted" | "denied" | "prompt";
|
|
|
724
757
|
export type BrowserAction = {
|
|
725
758
|
type: "navigate";
|
|
726
759
|
url: string;
|
|
760
|
+
} | {
|
|
761
|
+
type: "history";
|
|
762
|
+
direction: "back" | "forward";
|
|
763
|
+
} | {
|
|
764
|
+
type: "activate";
|
|
765
|
+
} | {
|
|
766
|
+
type: "viewport";
|
|
767
|
+
width: number;
|
|
768
|
+
height: number;
|
|
769
|
+
mobile: boolean;
|
|
770
|
+
deviceScaleFactor?: number | undefined;
|
|
727
771
|
} | {
|
|
728
772
|
type: "click";
|
|
729
773
|
locator: BrowserLocator;
|
|
@@ -801,6 +845,7 @@ export type BrowserAction = {
|
|
|
801
845
|
export type BrowserActionBatch = {
|
|
802
846
|
type: "batch";
|
|
803
847
|
actions: BrowserAction[];
|
|
848
|
+
fenceEachAction?: true | undefined;
|
|
804
849
|
};
|
|
805
850
|
export type InteractionError = {
|
|
806
851
|
code: "resource_not_found" | "resource_unavailable" | "controller_stale" | "target_not_found" | "target_stale" | "observation_stale" | "document_stale" | "frame_stale" | "locator_not_found" | "locator_ambiguous" | "unsupported" | "permission_denied" | "machine_locked" | "attempt_stale" | "operation_conflict" | "outcome_unknown" | "invalid_action" | "timeout" | "controller_lost" | "driver_failed";
|
|
@@ -827,6 +872,7 @@ export type CreateBrowserSessionRequest = {
|
|
|
827
872
|
name?: string | undefined;
|
|
828
873
|
initialUrl?: string | undefined;
|
|
829
874
|
headless?: boolean | undefined;
|
|
875
|
+
storageMode?: "private_profile" | "ephemeral_context" | undefined;
|
|
830
876
|
engine?: "chromium" | "lightpanda" | undefined;
|
|
831
877
|
placement?: InteractionPlacement | undefined;
|
|
832
878
|
identityId?: string | undefined;
|
|
@@ -873,12 +919,16 @@ export type ComputerFrameStreamAttachment = InteractionFrameStreamAttachment<4>
|
|
|
873
919
|
kind: "direct_rfb";
|
|
874
920
|
url: string;
|
|
875
921
|
protocols: string[];
|
|
922
|
+
inputAllowed: boolean;
|
|
876
923
|
};
|
|
877
924
|
export type BrowserSessionAttachment = {
|
|
878
925
|
browserSessionId: string;
|
|
879
926
|
controllerGeneration: string;
|
|
880
927
|
targetId: string;
|
|
881
928
|
stream: InteractionFrameStreamAttachment<3>;
|
|
929
|
+
/** Negotiated from this attachment’s live controller, absent on older helpers. */
|
|
930
|
+
fencedInputBatches?: true | undefined;
|
|
931
|
+
focusedInputObservations?: true | undefined;
|
|
882
932
|
expiresAt: string;
|
|
883
933
|
};
|
|
884
934
|
export type BrowserSessionAttachmentRequest = {
|
|
@@ -892,7 +942,10 @@ export type BrowserActionRequest = {
|
|
|
892
942
|
expectedTargetGeneration: string;
|
|
893
943
|
expectedDocumentGeneration: string | null;
|
|
894
944
|
expectedFrameId: string | null;
|
|
895
|
-
|
|
945
|
+
/** `input` is negotiated by focusedInputObservations on a live attachment.
|
|
946
|
+
* It returns optional native-select metadata after a pointer click, and null
|
|
947
|
+
* for ordinary input. Use full for agent observations. */
|
|
948
|
+
observationMode?: "full" | "none" | "input" | undefined;
|
|
896
949
|
action: BrowserAction | BrowserActionBatch;
|
|
897
950
|
};
|
|
898
951
|
export type BrowserActionReceipt = {
|
|
@@ -923,6 +976,8 @@ export type ComputerSessionCapabilities = {
|
|
|
923
976
|
keyboardInput: boolean;
|
|
924
977
|
clipboard: boolean;
|
|
925
978
|
backgroundActions: boolean;
|
|
979
|
+
/** Raw window input stays in the background. Absent means foreground-only. */
|
|
980
|
+
backgroundInput?: boolean | undefined;
|
|
926
981
|
parallelApps: boolean;
|
|
927
982
|
};
|
|
928
983
|
export type ComputerClipboard = {
|
|
@@ -1060,9 +1115,17 @@ export type ComputerSessionAttachment = {
|
|
|
1060
1115
|
computerSessionId: string;
|
|
1061
1116
|
controllerGeneration: string;
|
|
1062
1117
|
targetId: string;
|
|
1118
|
+
/** Viewer posture when attached; actions still reauthorize the live source. */
|
|
1119
|
+
inputAllowed?: boolean | undefined;
|
|
1063
1120
|
stream: ComputerFrameStreamAttachment;
|
|
1064
1121
|
expiresAt: string;
|
|
1065
1122
|
};
|
|
1123
|
+
/** Caller-specific hint only; every action still requires live authorization. */
|
|
1124
|
+
export type ComputerSessionInputPosture = {
|
|
1125
|
+
computerSessionId: string;
|
|
1126
|
+
controllerGeneration: string;
|
|
1127
|
+
inputAllowed: boolean;
|
|
1128
|
+
};
|
|
1066
1129
|
export type ComputerSessionAttachmentRequest = {
|
|
1067
1130
|
targetId: string;
|
|
1068
1131
|
expiresInSeconds?: number | undefined;
|
|
@@ -1140,6 +1203,9 @@ export interface InteractionTransport {
|
|
|
1140
1203
|
selectBrowserTarget(workspaceId: string, browserSessionId: string, targetId: string, options?: OpenGeniRequestOptions): Promise<BrowserObservation>;
|
|
1141
1204
|
closeBrowserTarget(workspaceId: string, browserSessionId: string, targetId: string, options?: OpenGeniRequestOptions): Promise<BrowserTargetListResponse>;
|
|
1142
1205
|
observeBrowserTarget(workspaceId: string, browserSessionId: string, targetId: string, options?: OpenGeniRequestOptions): Promise<BrowserObservation>;
|
|
1206
|
+
getBrowserTargetState(workspaceId: string, browserSessionId: string, targetId: string, options?: OpenGeniRequestOptions): Promise<BrowserTargetState>;
|
|
1207
|
+
readBrowserDom(workspaceId: string, browserSessionId: string, targetId: string, request: BrowserDomReadRequest, options?: OpenGeniRequestOptions): Promise<BrowserDomReadResponse>;
|
|
1208
|
+
captureBrowserTarget(workspaceId: string, browserSessionId: string, targetId: string, options?: OpenGeniRequestOptions, captureOptions?: BrowserScreenshotOptions): Promise<BrowserFrame>;
|
|
1143
1209
|
actInBrowser(workspaceId: string, browserSessionId: string, request: BrowserActionRequest, options?: OpenGeniRequestOptions): Promise<BrowserActionReceipt>;
|
|
1144
1210
|
getBrowserActionReceipt(workspaceId: string, browserSessionId: string, operationId: string, options?: OpenGeniRequestOptions): Promise<BrowserActionReceipt>;
|
|
1145
1211
|
listBrowserDiagnostics(workspaceId: string, browserSessionId: string, targetId: string, options?: BrowserDiagnosticsOptions): Promise<BrowserDiagnosticBatch>;
|
|
@@ -1151,10 +1217,12 @@ export interface InteractionTransport {
|
|
|
1151
1217
|
endBrowserSession(workspaceId: string, browserSessionId: string, request: BrowserSessionLifecycleRequest, options?: OpenGeniRequestOptions): Promise<BrowserSessionMutationResponse>;
|
|
1152
1218
|
listComputerSessions(workspaceId: string, options?: OpenGeniRequestOptions): Promise<ComputerSessionListResponse>;
|
|
1153
1219
|
getComputerSession(workspaceId: string, computerSessionId: string, options?: OpenGeniRequestOptions): Promise<ComputerSession>;
|
|
1220
|
+
getComputerInputPosture?(workspaceId: string, computerSessionId: string, options?: OpenGeniRequestOptions): Promise<ComputerSessionInputPosture>;
|
|
1154
1221
|
readComputerClipboard(workspaceId: string, computerSessionId: string, options?: OpenGeniRequestOptions): Promise<ComputerClipboard>;
|
|
1155
1222
|
createComputerSession(workspaceId: string, request: CreateComputerSessionRequest, options?: OpenGeniRequestOptions): Promise<ComputerSessionMutationResponse>;
|
|
1156
1223
|
listComputerTargets(workspaceId: string, computerSessionId: string, options?: OpenGeniRequestOptions): Promise<ComputerTargetListResponse>;
|
|
1157
1224
|
observeComputerTarget(workspaceId: string, computerSessionId: string, targetId: string, options?: OpenGeniRequestOptions): Promise<ComputerObservation>;
|
|
1225
|
+
captureComputerTarget(workspaceId: string, computerSessionId: string, targetId: string, options?: OpenGeniRequestOptions): Promise<ComputerFrame>;
|
|
1158
1226
|
actInComputer(workspaceId: string, computerSessionId: string, request: ComputerActionRequest, options?: OpenGeniRequestOptions): Promise<ComputerActionReceipt>;
|
|
1159
1227
|
getComputerActionReceipt(workspaceId: string, computerSessionId: string, operationId: string, options?: OpenGeniRequestOptions): Promise<ComputerActionReceipt>;
|
|
1160
1228
|
attachComputerSession(workspaceId: string, computerSessionId: string, request: ComputerSessionAttachmentRequest, options?: OpenGeniRequestOptions): Promise<ComputerSessionAttachment>;
|
|
@@ -1196,6 +1264,7 @@ export type CurrentOrOpenBrowserOptions = {
|
|
|
1196
1264
|
name?: string | undefined;
|
|
1197
1265
|
initialUrl?: string | undefined;
|
|
1198
1266
|
headless?: boolean | undefined;
|
|
1267
|
+
storageMode?: "private_profile" | "ephemeral_context" | undefined;
|
|
1199
1268
|
placement?: InteractionPlacement | undefined;
|
|
1200
1269
|
identityId?: string | undefined;
|
|
1201
1270
|
baseRevisionId?: string | undefined;
|
|
@@ -1348,6 +1417,10 @@ export declare class BrowserSessionResource {
|
|
|
1348
1417
|
constructor(transport: BrowserInteractionTransport, workspaceId: string, id: string);
|
|
1349
1418
|
get(options?: OpenGeniRequestOptions): Promise<BrowserSession>;
|
|
1350
1419
|
observe(targetId: string, options?: OpenGeniRequestOptions): Promise<BrowserObservation>;
|
|
1420
|
+
targetState(targetId: string, options?: OpenGeniRequestOptions): Promise<BrowserTargetState>;
|
|
1421
|
+
readDom(targetId: string, request: BrowserDomReadRequest, options?: OpenGeniRequestOptions): Promise<BrowserDomReadResponse>;
|
|
1422
|
+
capture(targetId: string, options?: OpenGeniRequestOptions, captureOptions?: BrowserScreenshotOptions): Promise<BrowserFrame>;
|
|
1423
|
+
screenshot(targetId: string, captureOptions?: BrowserScreenshotOptions, options?: OpenGeniRequestOptions): Promise<BrowserFrame>;
|
|
1351
1424
|
act(request: BrowserActionRequest, options?: OpenGeniRequestOptions): Promise<BrowserActionReceipt>;
|
|
1352
1425
|
receipt(operationId: string, options?: OpenGeniRequestOptions): Promise<BrowserActionReceipt>;
|
|
1353
1426
|
diagnostics(targetId: string, options?: BrowserDiagnosticsOptions): Promise<BrowserDiagnosticBatch>;
|
|
@@ -1414,9 +1487,11 @@ export declare class ComputerSessionResource {
|
|
|
1414
1487
|
constructor(transport: BrowserInteractionTransport, workspaceId: string, id: string);
|
|
1415
1488
|
get(options?: OpenGeniRequestOptions): Promise<ComputerSession>;
|
|
1416
1489
|
observe(targetId: string, options?: OpenGeniRequestOptions): Promise<ComputerObservation>;
|
|
1490
|
+
capture(targetId: string, options?: OpenGeniRequestOptions): Promise<ComputerFrame>;
|
|
1417
1491
|
act(request: ComputerActionRequest, options?: OpenGeniRequestOptions): Promise<ComputerActionReceipt>;
|
|
1418
1492
|
receipt(operationId: string, options?: OpenGeniRequestOptions): Promise<ComputerActionReceipt>;
|
|
1419
1493
|
attach(request: ComputerSessionAttachmentRequest, options?: OpenGeniRequestOptions): Promise<ComputerSessionAttachment>;
|
|
1494
|
+
inputPosture(options?: OpenGeniRequestOptions): Promise<ComputerSessionInputPosture>;
|
|
1420
1495
|
heartbeat(options?: OpenGeniRequestOptions): Promise<ComputerSessionHeartbeatResponse>;
|
|
1421
1496
|
end(request?: ComputerSessionLifecycleRequest, options?: OpenGeniRequestOptions): Promise<ComputerSessionMutationResponse>;
|
|
1422
1497
|
}
|
|
@@ -1453,6 +1528,13 @@ export type BrowserFrameMetadata = {
|
|
|
1453
1528
|
export type BrowserFrame = BrowserFrameMetadata & {
|
|
1454
1529
|
data: Uint8Array;
|
|
1455
1530
|
};
|
|
1531
|
+
export type BrowserScreenshotOptions = {
|
|
1532
|
+
/** Capture the document content instead of the visible viewport. */
|
|
1533
|
+
fullPage?: boolean;
|
|
1534
|
+
format?: "jpeg" | "png";
|
|
1535
|
+
/** JPEG quality, from 1 to 100. Ignored for PNG. */
|
|
1536
|
+
quality?: number;
|
|
1537
|
+
};
|
|
1456
1538
|
export type ComputerFrameMetadata = {
|
|
1457
1539
|
frameId: string;
|
|
1458
1540
|
computerSessionId: string;
|
|
@@ -1482,3 +1564,4 @@ export declare function decodeBrowserFrameMessage(message: ArrayBuffer | Uint8Ar
|
|
|
1482
1564
|
export declare function decodeComputerFrameMessage(message: ArrayBuffer | Uint8Array): Promise<ComputerFrame>;
|
|
1483
1565
|
export declare function parseBrowserFrameMetadata(value: unknown): BrowserFrameMetadata;
|
|
1484
1566
|
export declare function parseComputerFrameMetadata(value: unknown): ComputerFrameMetadata;
|
|
1567
|
+
export declare function decodeComputerFrameMetadataHeader(value: string): ComputerFrameMetadata;
|
package/dist/interaction.js
CHANGED
|
@@ -35,9 +35,12 @@ import {
|
|
|
35
35
|
computerFrameSocketUrl,
|
|
36
36
|
decodeBrowserFrameMessage,
|
|
37
37
|
decodeComputerFrameMessage,
|
|
38
|
+
decodeComputerFrameMetadataHeader,
|
|
39
|
+
interactionControlFailureFromError,
|
|
38
40
|
parseBrowserFrameMetadata,
|
|
39
41
|
parseComputerFrameMetadata
|
|
40
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-NC57YMUO.js";
|
|
43
|
+
import "./chunk-V6GIY62B.js";
|
|
41
44
|
export {
|
|
42
45
|
AttachedBrowserDeviceCollection,
|
|
43
46
|
AttachedBrowserDeviceResource,
|
|
@@ -75,6 +78,8 @@ export {
|
|
|
75
78
|
computerFrameSocketUrl,
|
|
76
79
|
decodeBrowserFrameMessage,
|
|
77
80
|
decodeComputerFrameMessage,
|
|
81
|
+
decodeComputerFrameMetadataHeader,
|
|
82
|
+
interactionControlFailureFromError,
|
|
78
83
|
parseBrowserFrameMetadata,
|
|
79
84
|
parseComputerFrameMetadata
|
|
80
85
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { AgentLearningMode, AgentLearningCategory, AgentLearningDefaults, AgentLearningOverrides, AgentLearningContext, AgentLearningOverridePatch, AgentLearningSettingsRecord, AgentLearningOverrideRecord, SaveAgentLearningSettingsRequest, KnowledgeFilePreparationResult, KnowledgeSavePreparationRequest, KnowledgeSavePreparationResponse, KnowledgeOriginalFileDownload, KnowledgeEntryKind, KnowledgeEntryScope, KnowledgeIndexStatus, KnowledgeEntryContent, KnowledgeEntrySource, KnowledgeEntryEvidence, KnowledgeEntryRelationship, KnowledgeEntryRecord, KnowledgeEntrySummary, KnowledgeEntrySaveRequest, KnowledgeEntryReviewRequest, KnowledgeEntryBatchReviewRequest, KnowledgeEntryRestoreRequest, KnowledgeEntryWriteReceipt, KnowledgeEntryListRequest, KnowledgeEntryListResponse, KnowledgeReviewBatch, KnowledgeReviewBatchListRequest, KnowledgeReviewBatchListResponse, AgentInstructionReviewRequest, AgentInstructionReceipt, AgentInstructionReviewItem, AgentInstructionReviewListResponse, } from "@opengeni/contracts";
|
|
2
|
+
import type { OpenGeniClient } from "./client.js";
|
|
3
|
+
import type { KnowledgeSavePreparationRequest, KnowledgeSavePreparationResponse, KnowledgeFilePreparationResult } from "@opengeni/contracts";
|
|
4
|
+
/** Agent-only source preparation is a focused transport surface, outside the browser client. */
|
|
5
|
+
export declare function prepareKnowledgeFile(client: Pick<OpenGeniClient, "requestJson">, workspaceId: string, fileId: string, purpose?: "evidence" | "reference"): Promise<KnowledgeFilePreparationResult>;
|
|
6
|
+
/** Read-only collection/duplicate discovery for a live selected agent or human Knowledge reviewer. */
|
|
7
|
+
export declare function prepareKnowledgeSave(client: Pick<OpenGeniClient, "requestJson">, workspaceId: string, request: KnowledgeSavePreparationRequest): Promise<KnowledgeSavePreparationResponse>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/knowledge.ts
|
|
2
|
+
async function prepareKnowledgeFile(client, workspaceId, fileId, purpose) {
|
|
3
|
+
return client.requestJson(
|
|
4
|
+
"POST",
|
|
5
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/knowledge/files/${encodeURIComponent(fileId)}/prepare`,
|
|
6
|
+
purpose ? { purpose } : void 0
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
async function prepareKnowledgeSave(client, workspaceId, request) {
|
|
10
|
+
return client.requestJson(
|
|
11
|
+
"POST",
|
|
12
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/knowledge/entries/prepare-save`,
|
|
13
|
+
request
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
prepareKnowledgeFile,
|
|
18
|
+
prepareKnowledgeSave
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=knowledge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/knowledge.ts"],"sourcesContent":["export type {\n AgentLearningMode,\n AgentLearningCategory,\n AgentLearningDefaults,\n AgentLearningOverrides,\n AgentLearningContext,\n AgentLearningOverridePatch,\n AgentLearningSettingsRecord,\n AgentLearningOverrideRecord,\n SaveAgentLearningSettingsRequest,\n KnowledgeFilePreparationResult,\n KnowledgeSavePreparationRequest,\n KnowledgeSavePreparationResponse,\n KnowledgeOriginalFileDownload,\n KnowledgeEntryKind,\n KnowledgeEntryScope,\n KnowledgeIndexStatus,\n KnowledgeEntryContent,\n KnowledgeEntrySource,\n KnowledgeEntryEvidence,\n KnowledgeEntryRelationship,\n KnowledgeEntryRecord,\n KnowledgeEntrySummary,\n KnowledgeEntrySaveRequest,\n KnowledgeEntryReviewRequest,\n KnowledgeEntryBatchReviewRequest,\n KnowledgeEntryRestoreRequest,\n KnowledgeEntryWriteReceipt,\n KnowledgeEntryListRequest,\n KnowledgeEntryListResponse,\n KnowledgeReviewBatch,\n KnowledgeReviewBatchListRequest,\n KnowledgeReviewBatchListResponse,\n AgentInstructionReviewRequest,\n AgentInstructionReceipt,\n AgentInstructionReviewItem,\n AgentInstructionReviewListResponse,\n} from \"@opengeni/contracts\";\n\nimport type { OpenGeniClient } from \"./client\";\nimport type {\n KnowledgeSavePreparationRequest,\n KnowledgeSavePreparationResponse,\n KnowledgeFilePreparationResult,\n} from \"@opengeni/contracts\";\n\n/** Agent-only source preparation is a focused transport surface, outside the browser client. */\nexport async function prepareKnowledgeFile(\n client: Pick<OpenGeniClient, \"requestJson\">,\n workspaceId: string,\n fileId: string,\n purpose?: \"evidence\" | \"reference\",\n): Promise<KnowledgeFilePreparationResult> {\n return client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/knowledge/files/${encodeURIComponent(fileId)}/prepare`,\n purpose ? { purpose } : undefined,\n );\n}\n\n/** Read-only collection/duplicate discovery for a live selected agent or human Knowledge reviewer. */\nexport async function prepareKnowledgeSave(\n client: Pick<OpenGeniClient, \"requestJson\">,\n workspaceId: string,\n request: KnowledgeSavePreparationRequest,\n): Promise<KnowledgeSavePreparationResponse> {\n return client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/knowledge/entries/prepare-save`,\n request,\n );\n}\n"],"mappings":";AA+CA,eAAsB,qBACpB,QACA,aACA,QACA,SACyC;AACzC,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,kBAAkB,mBAAmB,WAAW,CAAC,oBAAoB,mBAAmB,MAAM,CAAC;AAAA,IAC/F,UAAU,EAAE,QAAQ,IAAI;AAAA,EAC1B;AACF;AAGA,eAAsB,qBACpB,QACA,aACA,SAC2C;AAC3C,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Links an agent writes into chat Markdown that point at OpenGeni-owned objects.
|
|
3
|
+
*
|
|
4
|
+
* Agents write these forms (tool receipts and bundled Skills teach them):
|
|
5
|
+
*
|
|
6
|
+
* - `artifact:<file uuid>` — a retained workspace file (exports, published files, images).
|
|
7
|
+
* - `sandbox:<path>[:<line>]` — a file in the session's sandbox or Connected Machine.
|
|
8
|
+
* - `/workspaces/<ws>/artifacts/editable/<32-hex id>` — a live editable document,
|
|
9
|
+
* workbook, or presentation.
|
|
10
|
+
* - `/workspaces/<ws>/artifacts/<uuid>` — a saved Site / published HTML artifact.
|
|
11
|
+
* - `/workspaces/<ws>/artifacts/files/<uuid>` — a retained file (console path form).
|
|
12
|
+
*
|
|
13
|
+
* None of them is a URL a browser can navigate on its own: the `/workspaces/...`
|
|
14
|
+
* forms are OpenGeni console routes, so inside another product they resolve
|
|
15
|
+
* against that product's origin and 404. Parse them with {@link parseOpenGeniLink}
|
|
16
|
+
* and route each target to the host's own UI (download, panel, page).
|
|
17
|
+
*/
|
|
18
|
+
export type OpenGeniLinkTarget = {
|
|
19
|
+
kind: "file";
|
|
20
|
+
fileId: string;
|
|
21
|
+
workspaceId: string | null;
|
|
22
|
+
fromSession?: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "editable-artifact";
|
|
25
|
+
artifactId: string;
|
|
26
|
+
workspaceId: string;
|
|
27
|
+
fromSession?: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "site";
|
|
30
|
+
artifactId: string;
|
|
31
|
+
workspaceId: string;
|
|
32
|
+
fromSession?: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: "sandbox-file";
|
|
35
|
+
path: string;
|
|
36
|
+
line: number | null;
|
|
37
|
+
};
|
|
38
|
+
/** Application scheme names are case-insensitive, unlike their payloads. */
|
|
39
|
+
export declare function openGeniLinkScheme(href: string | undefined): "artifact" | "sandbox" | null;
|
|
40
|
+
/** Reserved references must never fall back to navigation on a host origin. */
|
|
41
|
+
export declare function isReservedOpenGeniLink(href: string | undefined): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Parse an OpenGeni `sandbox:` href (plus the historical bare `/workspace/...`
|
|
44
|
+
* form). The decoded path is intentionally opaque: target selection, path
|
|
45
|
+
* policy, and filesystem authority belong to the session-aware host.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseSandboxLink(href: string | undefined): {
|
|
48
|
+
path: string;
|
|
49
|
+
line: number | null;
|
|
50
|
+
} | null;
|
|
51
|
+
/** Return the retained-file id of an exact `artifact:<uuid>` reference. */
|
|
52
|
+
export declare function parseRetainedFileReference(href: string | undefined): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Classify an agent-authored Markdown href. Returns `null` for ordinary links
|
|
55
|
+
* (`https://…`, `mailto:`, relative host links), which render as-is.
|
|
56
|
+
*
|
|
57
|
+
* Only root-relative console paths are recognized; an absolute URL is always an
|
|
58
|
+
* ordinary link, so a host's own `https://` routes are never reinterpreted.
|
|
59
|
+
* A validated `?fromSession=<uuid>` return hint is preserved.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseOpenGeniLink(href: string | undefined): OpenGeniLinkTarget | null;
|
|
62
|
+
/** The OpenGeni console route for a target (the form agents write). */
|
|
63
|
+
export declare function openGeniConsolePath(target: OpenGeniLinkTarget, workspaceId: string): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Request header naming the session an embedded artifact read belongs to.
|
|
66
|
+
* `createSessionProxyHandler` only serves artifacts OpenGeni lists for it.
|
|
67
|
+
*/
|
|
68
|
+
export declare const SESSION_SCOPE_HEADER = "x-opengeni-session-id";
|