@opengeni/sdk 4.4.1 → 4.5.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 +27 -0
- package/dist/adapters/next.js +2 -2
- package/dist/artifacts.js +4 -4
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +5 -3
- package/dist/chat/index.js +5 -5
- package/dist/{chunk-3BWTS2MJ.js → chunk-ARDVIZIJ.js} +2 -2
- package/dist/{chunk-PVWOBYAZ.js → chunk-BXMNDWAN.js} +256 -78
- package/dist/chunk-BXMNDWAN.js.map +1 -0
- package/dist/{chunk-IVHLADZ7.js → chunk-GRUMGFK6.js} +2 -2
- package/dist/{chunk-2RVPHF37.js → chunk-JBAGMSN2.js} +66 -10
- package/dist/chunk-JBAGMSN2.js.map +1 -0
- package/dist/{chunk-35S72HAE.js → chunk-U4JUWOZV.js} +5 -5
- package/dist/{chunk-BLID3DCD.js → chunk-V4AIZAFF.js} +1 -1
- package/dist/chunk-V4AIZAFF.js.map +1 -0
- package/dist/{chunk-ALXDFL6C.js → chunk-VSOXNL3T.js} +2 -2
- package/dist/{chunk-CT6P2W2C.js → chunk-WI3WUT5H.js} +2 -2
- package/dist/client.d.ts +24 -1
- package/dist/codex-realtime-controller.js +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.js +5 -3
- package/dist/document-authority.js +3 -3
- package/dist/editable-artifacts.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +35 -33
- package/dist/index.js.map +1 -1
- package/dist/read-retry.d.ts +61 -0
- package/dist/realtime.js +5 -5
- package/dist/session-proxy.d.ts +6 -1
- package/dist/session-proxy.js +2 -2
- package/dist/site-bridge-host.js +3 -3
- package/dist/site-browser-runtime.gen.d.ts +1 -1
- package/dist/site-document.js +1 -1
- package/dist/site-document.js.map +1 -1
- package/dist/site.js +3 -3
- package/dist/types.d.ts +40 -0
- package/dist/workspace-artifacts.d.ts +5 -0
- package/dist/workspace-live-stream.d.ts +7 -0
- package/package.json +3 -3
- package/src/browser.ts +2 -0
- package/src/client.ts +191 -73
- package/src/core.ts +2 -0
- package/src/index.ts +4 -0
- package/src/read-retry.ts +207 -0
- package/src/session-proxy.ts +95 -4
- package/src/site-browser-runtime.gen.ts +1 -1
- package/src/types.ts +38 -0
- package/src/workspace-artifacts.ts +6 -0
- package/src/workspace-live-stream.ts +12 -1
- package/dist/chunk-2RVPHF37.js.map +0 -1
- package/dist/chunk-BLID3DCD.js.map +0 -1
- package/dist/chunk-PVWOBYAZ.js.map +0 -1
- /package/dist/{chunk-3BWTS2MJ.js.map → chunk-ARDVIZIJ.js.map} +0 -0
- /package/dist/{chunk-IVHLADZ7.js.map → chunk-GRUMGFK6.js.map} +0 -0
- /package/dist/{chunk-35S72HAE.js.map → chunk-U4JUWOZV.js.map} +0 -0
- /package/dist/{chunk-ALXDFL6C.js.map → chunk-VSOXNL3T.js.map} +0 -0
- /package/dist/{chunk-CT6P2W2C.js.map → chunk-WI3WUT5H.js.map} +0 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connected-machine-output.ts","../src/prepared-mcp-setup.ts","../../contracts/src/tool-review-presentation.ts","../../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":["/** Presentation-only recognition of the runtime's four-field uncertainty receipt.\n * Never use displayed tool output to decide whether an operation may be retried.\n * Ordinary command stdout has an exec banner and must not be classified by a\n * loose match for words such as \"timeout\" or \"unknown\".\n */\nexport function isConnectedMachineOutcomeUnknownOutput(output: unknown): output is string {\n if (typeof output !== \"string\" || !output.startsWith(\"[connected machine] \")) return false;\n const lines = output.split(\"\\n\");\n return (\n lines.length === 5 &&\n lines[1]!.startsWith(\"What happened: \") &&\n /\\(control code ERROR_CODE_[A-Z_]+\\)\\.$/u.test(lines[1]!) &&\n lines[2]!.startsWith(\"Which layer: \") &&\n lines[3]!.startsWith(\"What was preserved: unknown — \") &&\n lines[4]!.startsWith(\"What to try: \")\n );\n}\n","import type {\n CustomMcpSetupRequest,\n PreparedMcpSetup,\n} from \"@opengeni/contracts/prepared-mcp-setup\";\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst keys = (value: Record<string, unknown>, allowed: string[]) =>\n Object.keys(value).every((key) => allowed.includes(key));\nconst text = (value: unknown, max: number, min = 1): value is string =>\n typeof value === \"string\" && value.length >= min && value.length <= max;\nconst trimmedText = (value: unknown, max: number): value is string =>\n typeof value === \"string\" && text(value.trim(), max);\nconst headerPart = (value: unknown): value is string =>\n text(value, 16_384, 0) && !/[\\r\\n\\0]/.test(value);\nconst fieldId = (value: unknown): value is string =>\n typeof value === \"string\" && /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(value);\nconst endpoint = (value: unknown): value is string => {\n if (!text(value, 2048)) return false;\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" && !url.username && !url.password && !url.search && !url.hash;\n } catch {\n return false;\n }\n};\n\n/** Browser/native-safe display projection. The API owns authoritative schema\n * validation; parity tests keep this lightweight parser aligned without pulling\n * schema runtimes into the SDK or replaying unknown fields into a secret form. */\nexport function parseCustomMcpSetupRequest(value: unknown): CustomMcpSetupRequest | null {\n if (\n !record(value) ||\n !keys(value, [\"kind\", \"name\", \"endpointUrl\", \"rationale\", \"ownership\", \"mcpSetup\"]) ||\n value.kind !== \"mcp\" ||\n !trimmedText(value.name, 256) ||\n !endpoint(value.endpointUrl) ||\n !trimmedText(value.rationale, 2000)\n )\n return null;\n const base = {\n kind: \"mcp\" as const,\n name: value.name.trim(),\n endpointUrl: value.endpointUrl,\n rationale: value.rationale.trim(),\n };\n if (value.ownership === undefined && value.mcpSetup === undefined) return base;\n if (value.ownership !== \"personal\" && value.ownership !== \"workspace\") return null;\n const setup = value.mcpSetup;\n if (\n !record(setup) ||\n !keys(setup, [\"name\", \"endpointUrl\", \"headers\", \"secretFields\"]) ||\n !trimmedText(setup.name, 256) ||\n setup.name.trim() !== base.name ||\n setup.endpointUrl !== base.endpointUrl ||\n !Array.isArray(setup.headers) ||\n setup.headers.length < 1 ||\n setup.headers.length > 32 ||\n !Array.isArray(setup.secretFields) ||\n setup.secretFields.length > 32\n )\n return null;\n const fields: PreparedMcpSetup[\"secretFields\"] = [];\n const fieldIds = new Set<string>();\n for (const field of setup.secretFields) {\n if (\n !record(field) ||\n !keys(field, [\"id\", \"label\"]) ||\n !fieldId(field.id) ||\n !trimmedText(field.label, 256) ||\n fieldIds.has(field.id)\n )\n return null;\n fieldIds.add(field.id);\n fields.push({ id: field.id, label: field.label.trim() });\n }\n const headers: PreparedMcpSetup[\"headers\"] = [];\n const names = new Set<string>();\n const used = new Set<string>();\n for (const header of setup.headers) {\n if (\n !record(header) ||\n !text(header.name, 256) ||\n !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(header.name)\n )\n return null;\n const name = header.name.toLowerCase();\n if (names.has(name)) return null;\n names.add(name);\n if (\"value\" in header) {\n if (\n !keys(header, [\"name\", \"value\"]) ||\n !headerPart(header.value) ||\n !header.value ||\n [\"authorization\", \"proxy-authorization\", \"cookie\", \"x-api-key\", \"api-key\"].includes(name)\n )\n return null;\n headers.push({ name: header.name, value: header.value });\n } else {\n if (\n !keys(header, [\"name\", \"secret\", \"prefix\", \"suffix\"]) ||\n !fieldId(header.secret) ||\n !fieldIds.has(header.secret) ||\n (header.prefix !== undefined && !headerPart(header.prefix)) ||\n (header.suffix !== undefined && !headerPart(header.suffix))\n )\n return null;\n used.add(header.secret);\n headers.push({\n name: header.name,\n secret: header.secret,\n ...(header.prefix !== undefined ? { prefix: header.prefix as string } : {}),\n ...(header.suffix !== undefined ? { suffix: header.suffix as string } : {}),\n });\n }\n }\n if (used.size !== fieldIds.size) return null;\n return {\n ...base,\n ownership: value.ownership,\n mcpSetup: { name: base.name, endpointUrl: base.endpointUrl, headers, secretFields: fields },\n };\n}\n","import type {\n ToolActionReview,\n ToolReviewContext,\n ToolReviewDetailsPage,\n} from \"./tool-action-review\";\n\nconst protectedName =\n /password|passwd|secret|credential|authorization|cookie|(^|[_-])token($|[_-])|api[_-]?key|accessToken|refreshToken|privateKey/i;\nconst protectedReviewField = (key: string, fields: readonly string[] = []) =>\n protectedName.test(key) || fields.includes(key) || fields.includes(\"*\");\nconst bound = (value: string, limit: number) =>\n value.length > limit ? `${value.slice(0, limit)}…` : value;\nexport function toolReviewFieldLabel(key: string): string {\n const label = key\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replace(/[_-]+/g, \" \")\n .replace(/\\bids?\\b/gi, (word) => (word.length === 3 ? \"IDs\" : \"ID\"))\n .replace(\n /\\b(api|url|uri|http|https|ip|sql|json|html)(s?)\\b/gi,\n (_word, name: string, plural: string) => `${name.toUpperCase()}${plural}`,\n )\n // Sentence case, keeping acronyms: \"Working Directory\" → \"Working directory\".\n .replace(\n /(?<=\\S\\s+)([A-Z])([a-z]+)\\b/g,\n (_word, first: string, rest: string) => `${first.toLowerCase()}${rest}`,\n )\n .trim();\n return label.charAt(0).toUpperCase() + label.slice(1);\n}\nexport function decodeReviewArguments(value: unknown): Record<string, unknown> | null {\n // Historical SDK entries sometimes wrapped arguments in JSON. Decode only once.\n let decoded = value;\n if (typeof decoded === \"string\") {\n try {\n decoded = JSON.parse(decoded);\n } catch {\n return null;\n }\n }\n return decoded && typeof decoded === \"object\" && !Array.isArray(decoded)\n ? (decoded as Record<string, unknown>)\n : null;\n}\nexport function safeReviewValue(\n value: unknown,\n key = \"\",\n protectedFields: readonly string[] = [],\n depth = 0,\n): unknown {\n if (protectedReviewField(key, protectedFields)) return \"[Protected value]\";\n if (depth > 20) return \"[Nested value; open this field for details]\";\n if (Array.isArray(value))\n return value.map((entry) => safeReviewValue(entry, \"\", protectedFields, depth + 1));\n if (value && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value).map(([name, entry]) => [\n name,\n safeReviewValue(entry, name, protectedFields, depth + 1),\n ]),\n );\n return value;\n}\nfunction valueText(value: unknown): string {\n return typeof value === \"string\"\n ? value\n : value === null\n ? \"None\"\n : typeof value === \"boolean\"\n ? value\n ? \"Yes\"\n : \"No\"\n : (JSON.stringify(value) ?? \"Unavailable\");\n}\nconst pointer = (name: string) => `/${name.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\")}`;\n// Long arbitrary property names remain readable without placing them in every\n// preview or URL. An indexed segment opens their saved name and value together.\nconst fieldPointer = (key: string, index: number, parent = \"\") =>\n pointer(key).length > 256 || parent.length + pointer(key).length > 1024\n ? `/~2${index}`\n : pointer(key);\n\nexport function toolReviewFields(\n argumentsValue: unknown,\n context?: ToolReviewContext,\n): { fields: ToolActionReview[\"fields\"]; moreFields: number } {\n const args = decodeReviewArguments(argumentsValue);\n if (!args) return { fields: [], moreFields: 0 };\n const entries = Object.entries(args);\n if (context?.email) {\n const email = toolReviewFields(context.email);\n const original = toolReviewFields(args, { ...context, email: undefined });\n const fields = [\n ...email.fields\n .filter(\n (field) =>\n field.path !== \"/contentSha256\" && field.path !== \"/htmlBody\" && field.preview !== \"\",\n )\n .map((field) => ({\n ...field,\n label: field.path === \"/textBody\" ? \"Message\" : field.label,\n path: `/$email${field.path}`,\n ...(field.path === \"/attachments\"\n ? {\n preview: context\n .email!.attachments.map((attachment) => attachment.name)\n .join(\", \")\n .slice(0, 240),\n }\n : {}),\n })),\n ...original.fields.filter(\n (field) =>\n ![\n \"/raw\",\n \"/expectedContentSha256\",\n \"/from\",\n \"/to\",\n \"/cc\",\n \"/bcc\",\n \"/subject\",\n \"/body\",\n \"/textBody\",\n \"/htmlBody\",\n \"/attachments\",\n ].includes(field.path),\n ),\n ];\n return {\n fields: fields.slice(0, 16),\n moreFields: original.moreFields + Math.max(0, fields.length - 16),\n };\n }\n return {\n moreFields: Math.max(0, entries.length - 16),\n fields: entries.slice(0, 16).map(([key, value], index) => {\n const hidden = protectedReviewField(key, context?.protectedFields);\n const safe = hidden ? \"[Protected value]\" : value;\n const count = !hidden && Array.isArray(value) ? value.length : undefined;\n const compactList =\n !hidden &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.length <= 4 &&\n value.every(\n (entry) =>\n typeof entry === \"string\" || typeof entry === \"number\" || typeof entry === \"boolean\",\n )\n ? value.map(valueText).join(\", \")\n : undefined;\n const text =\n compactList !== undefined\n ? compactList\n : count !== undefined\n ? `${count.toLocaleString(\"en-US\")} item${count === 1 ? \"\" : \"s\"}`\n : safe && typeof safe === \"object\"\n ? `${Object.keys(safe).length} field${Object.keys(safe).length === 1 ? \"\" : \"s\"}`\n : valueText(safe);\n return {\n path: fieldPointer(key, index),\n label: bound(\n (context?.fieldLabels && Object.hasOwn(context.fieldLabels, key)\n ? context.fieldLabels[key]\n : undefined) ?? toolReviewFieldLabel(key),\n 256,\n ),\n preview: bound(text, 240),\n ...(count !== undefined ? { count } : {}),\n truncated:\n !hidden &&\n (text.length > 240 ||\n (compactList === undefined && typeof value === \"object\" && value !== null)),\n ...(hidden ? { protected: true } : {}),\n };\n }),\n };\n}\n\n/** Deterministic consequences from the reviewed bytes. Unknown fields remain visible. */\nexport function toolReviewAction(\n toolName: string,\n argumentsValue: unknown,\n context?: ToolReviewContext,\n): Pick<\n ToolActionReview,\n \"title\" | \"approveLabel\" | \"effects\" | \"consequence\" | \"selectionCount\" | \"selectionKind\"\n> {\n const fallback = {\n title:\n context?.title ??\n bound(\n toolReviewFieldLabel(\n toolName.replace(/^mcp_[^_]+__/, \"\").replace(/^batch[_-](?=[a-z])/i, \"\"),\n ),\n 256,\n ),\n approveLabel: \"Approve action\",\n effects: [] as string[],\n };\n if (context?.kind !== \"gmail\") return fallback;\n const args = decodeReviewArguments(argumentsValue);\n if (!args) return fallback;\n const thread = toolName.endsWith(\"_thread\");\n const selectionKind = thread ? (\"threads\" as const) : (\"messages\" as const);\n const ids =\n thread && typeof args.threadId === \"string\"\n ? [args.threadId]\n : Array.isArray(args.messageIds)\n ? args.messageIds\n : typeof args.messageId === \"string\"\n ? [args.messageId]\n : null;\n const selectionCount = ids?.every((id) => typeof id === \"string\") ? new Set(ids).size : undefined;\n const noun =\n selectionCount === undefined\n ? thread\n ? \"conversations\"\n : \"messages\"\n : `${selectionCount.toLocaleString(\"en-US\")} ${thread ? \"conversation\" : \"message\"}${selectionCount === 1 ? \"\" : \"s\"}`;\n const addValues = toolName.startsWith(\"label_\") ? args.labelIds : args.addLabelIds;\n const adds = Array.isArray(addValues)\n ? addValues.filter((v): v is string => typeof v === \"string\")\n : [];\n const removeValues = toolName.startsWith(\"unlabel_\") ? args.labelIds : args.removeLabelIds;\n const removes = Array.isArray(removeValues)\n ? removeValues.filter((v): v is string => typeof v === \"string\")\n : [];\n const labelEffect = (label: string, adding: boolean): string => {\n const known: Record<string, [string, string]> = {\n TRASH: [\"Move to Trash\", \"Remove from Trash\"],\n INBOX: [\"Move to Inbox\", \"Remove from Inbox\"],\n UNREAD: [\"Mark as unread\", \"Mark as read\"],\n STARRED: [\"Add star\", \"Remove star\"],\n SPAM: [\"Mark as spam\", \"Remove from Spam\"],\n IMPORTANT: [\"Mark as important\", \"Remove importance\"],\n };\n return (\n (Object.hasOwn(known, label) ? known[label]?.[adding ? 0 : 1] : undefined) ??\n `${adding ? \"Add\" : \"Remove\"} label ${bound(label, 120)}`\n );\n };\n const effects = [\n ...adds.map((id) => labelEffect(id, true)),\n ...removes.map((id) => labelEffect(id, false)),\n ];\n if (\n [\n \"batch_modify_messages\",\n \"modify_message\",\n \"modify_thread\",\n \"label_message\",\n \"label_thread\",\n \"unlabel_message\",\n \"unlabel_thread\",\n ].includes(toolName)\n ) {\n const trash = adds.includes(\"TRASH\");\n return {\n title: trash ? `Move ${noun} to Trash` : `Update ${noun}`,\n approveLabel: trash ? \"Move to Trash\" : \"Apply changes\",\n effects,\n ...(selectionCount === undefined ? {} : { selectionCount, selectionKind }),\n ...(trash\n ? { consequence: \"Messages stay recoverable in Trash until Gmail deletes them.\" }\n : thread\n ? { consequence: \"Applies to every message in the conversation.\" }\n : {}),\n };\n }\n if ([\"trash_message\", \"restore_message\", \"trash_thread\", \"restore_thread\"].includes(toolName))\n return {\n title: toolName.startsWith(\"trash_\") ? `Move ${noun} to Trash` : `Remove ${noun} from Trash`,\n approveLabel: toolName.startsWith(\"trash_\") ? \"Move to Trash\" : \"Remove from Trash\",\n effects,\n ...(selectionCount === undefined ? {} : { selectionCount, selectionKind }),\n };\n const named: Record<string, [string, string]> = {\n send_message: [\"Send email\", \"Send email\"],\n send_draft: [\"Send draft\", \"Send draft\"],\n create_draft: [\"Create email draft\", \"Create draft\"],\n update_draft: [\"Update email draft\", \"Update draft\"],\n delete_draft: [\"Delete email draft\", \"Delete draft\"],\n create_label: [\"Create label\", \"Create label\"],\n update_label: [\"Update label\", \"Update label\"],\n delete_label: [\"Delete label\", \"Delete label\"],\n };\n const action = Object.hasOwn(named, toolName) ? named[toolName] : undefined;\n return action ? { title: action[0], approveLabel: action[1], effects } : fallback;\n}\n\n/** A bounded slice of the immutable saved arguments; never evaluates a fresh provider query. */\nexport function toolReviewDetails(\n argumentsValue: unknown,\n context: ToolReviewContext | undefined,\n path: string,\n offset: number,\n limit = 25,\n): Omit<ToolReviewDetailsPage, \"id\" | \"actionDigest\" | \"version\"> {\n if (\n !Number.isSafeInteger(offset) ||\n offset < 0 ||\n !Number.isSafeInteger(limit) ||\n limit < 1 ||\n limit > 50\n )\n throw new Error(\"Invalid review page\");\n const args = decodeReviewArguments(argumentsValue);\n let value: unknown = context?.email ? { ...args, $email: context.email } : args;\n if (path !== \"\") {\n if (!path.startsWith(\"/\")) throw new Error(\"Invalid review field\");\n for (const escaped of path.slice(1).split(\"/\")) {\n if (/^~2\\d+$/.test(escaped)) {\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n throw new Error(\"Review field not found\");\n const selected = Object.entries(value)[Number(escaped.slice(2))];\n if (!selected) throw new Error(\"Review field not found\");\n value = {\n fieldName: selected[0],\n value: protectedReviewField(selected[0], context?.protectedFields)\n ? \"[Protected value]\"\n : selected[1],\n };\n continue;\n }\n const key = escaped.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n if (protectedReviewField(key, context?.protectedFields)) {\n value = \"[Protected value]\";\n break;\n }\n if (!value || typeof value !== \"object\" || !Object.hasOwn(value, key))\n throw new Error(\"Review field not found\");\n value = (value as Record<string, unknown>)[key];\n }\n }\n type DetailItem = ToolReviewDetailsPage[\"items\"][number];\n const preview = (\n entry: unknown,\n key: string,\n childPath: string,\n ): Pick<DetailItem, \"value\" | \"truncated\" | \"path\"> => {\n const hidden = protectedReviewField(key, context?.protectedFields);\n if (!hidden && entry !== null && typeof entry === \"object\") {\n const count = Array.isArray(entry) ? entry.length : Object.keys(entry).length;\n return {\n value: `${count.toLocaleString(\"en-US\")} ${Array.isArray(entry) ? (count === 1 ? \"item\" : \"items\") : count === 1 ? \"field\" : \"fields\"}`,\n path: childPath,\n truncated: true,\n };\n }\n const text = valueText(safeReviewValue(entry, key, context?.protectedFields));\n return {\n value: bound(text, 4000),\n ...(hidden ? {} : { path: childPath }),\n truncated: !hidden && text.length > 4000,\n };\n };\n // Selected messages read as subject and sender rather than bare provider ids.\n const labels =\n (path === \"/messageIds\" || path === \"/messageId\") && context?.selectionLabels?.length\n ? new Map(context.selectionLabels.map((label) => [label.id, label]))\n : undefined;\n const labelled = (entry: unknown): Pick<DetailItem, \"value\" | \"detail\"> | undefined => {\n const label = typeof entry === \"string\" ? labels?.get(entry) : undefined;\n return label && typeof entry === \"string\"\n ? {\n value: label.title,\n detail: label.subtitle ? `${label.subtitle} · ${entry}` : entry,\n }\n : undefined;\n };\n let total: number;\n let items: DetailItem[];\n if (Array.isArray(value)) {\n total = value.length;\n items = value.slice(offset, offset + limit).map((entry, index) => ({\n label: `${offset + index + 1}`,\n ...preview(entry, \"\", `${path}/${offset + index}`),\n ...labelled(entry),\n }));\n } else if (offset === 0 && labelled(value)) {\n total = 1;\n items = [{ label: \"Message\", ...labelled(value)! }];\n } else if (value && typeof value === \"object\") {\n const entries = Object.entries(value);\n total = entries.length;\n items = entries.slice(offset, offset + limit).map(([key, entry], index) => ({\n label: bound(\n (context?.fieldLabels && Object.hasOwn(context.fieldLabels, key)\n ? context.fieldLabels[key]\n : undefined) ?? toolReviewFieldLabel(key),\n 256,\n ),\n ...preview(entry, key, `${path}${fieldPointer(key, offset + index, path)}`),\n }));\n } else {\n const text = valueText(value);\n total = Math.max(1, Math.ceil(text.length / 4000));\n items = Array.from({ length: Math.max(0, Math.min(limit, total - offset)) }, (_, index) => ({\n label: `Part ${offset + index + 1}`,\n value: text.slice((offset + index) * 4000, (offset + index + 1) * 4000),\n }));\n }\n return { path, items, total, nextOffset: offset + limit < total ? offset + limit : null };\n}\n","/** 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 (\n Object.keys(item).some(\n (key) => ![\"toolName\", \"title\", \"accountLabel\", \"connector\", \"providerDomain\"].includes(key),\n )\n )\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 if (item.connector !== undefined && !text(item.connector, 512)) return undefined;\n if (item.providerDomain !== undefined && !text(item.providerDomain, 253)) 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 ...(item.connector !== undefined ? { connector: item.connector as string } : {}),\n ...(item.providerDomain !== undefined ? { providerDomain: item.providerDomain 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,SAAS,uCAAuC,QAAmC;AACxF,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,WAAW,sBAAsB,EAAG,QAAO;AACrF,QAAM,QAAQ,OAAO,MAAM,IAAI;AAC/B,SACE,MAAM,WAAW,KACjB,MAAM,CAAC,EAAG,WAAW,iBAAiB,KACtC,0CAA0C,KAAK,MAAM,CAAC,CAAE,KACxD,MAAM,CAAC,EAAG,WAAW,eAAe,KACpC,MAAM,CAAC,EAAG,WAAW,qCAAgC,KACrD,MAAM,CAAC,EAAG,WAAW,eAAe;AAExC;;;ACXA,IAAM,SAAS,CAAC,UACd,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACrE,IAAM,OAAO,CAAC,OAAgC,YAC5C,OAAO,KAAK,KAAK,EAAE,MAAM,CAAC,QAAQ,QAAQ,SAAS,GAAG,CAAC;AACzD,I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C,SAAS,iCAAiC,OAAuB;AACtE,SAAO,MAAM,UAAU,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,GAAG;AAC9F;;;ACnFA,SAAS,cAAc,aAAqB,QAAwB;AAClE,SAAO,kBAAkB,WAAW,kBAAkB,MAAM;AAC9D;AAEO,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":["text","endpoint","text","record","text"]}
|
|
1
|
+
{"version":3,"sources":["../src/connected-machine-output.ts","../src/prepared-mcp-setup.ts","../../contracts/src/tool-review-presentation.ts","../../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":["/** Presentation-only recognition of the runtime's four-field uncertainty receipt.\n * Never use displayed tool output to decide whether an operation may be retried.\n * Ordinary command stdout has an exec banner and must not be classified by a\n * loose match for words such as \"timeout\" or \"unknown\".\n */\nexport function isConnectedMachineOutcomeUnknownOutput(output: unknown): output is string {\n if (typeof output !== \"string\" || !output.startsWith(\"[connected machine] \")) return false;\n const lines = output.split(\"\\n\");\n return (\n lines.length === 5 &&\n lines[1]!.startsWith(\"What happened: \") &&\n /\\(control code ERROR_CODE_[A-Z_]+\\)\\.$/u.test(lines[1]!) &&\n lines[2]!.startsWith(\"Which layer: \") &&\n lines[3]!.startsWith(\"What was preserved: unknown — \") &&\n lines[4]!.startsWith(\"What to try: \")\n );\n}\n","import type {\n CustomMcpSetupRequest,\n PreparedMcpSetup,\n} from \"@opengeni/contracts/prepared-mcp-setup\";\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst keys = (value: Record<string, unknown>, allowed: string[]) =>\n Object.keys(value).every((key) => allowed.includes(key));\nconst text = (value: unknown, max: number, min = 1): value is string =>\n typeof value === \"string\" && value.length >= min && value.length <= max;\nconst trimmedText = (value: unknown, max: number): value is string =>\n typeof value === \"string\" && text(value.trim(), max);\nconst headerPart = (value: unknown): value is string =>\n text(value, 16_384, 0) && !/[\\r\\n\\0]/.test(value);\nconst fieldId = (value: unknown): value is string =>\n typeof value === \"string\" && /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(value);\nconst endpoint = (value: unknown): value is string => {\n if (!text(value, 2048)) return false;\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" && !url.username && !url.password && !url.search && !url.hash;\n } catch {\n return false;\n }\n};\n\n/** Browser/native-safe display projection. The API owns authoritative schema\n * validation; parity tests keep this lightweight parser aligned without pulling\n * schema runtimes into the SDK or replaying unknown fields into a secret form. */\nexport function parseCustomMcpSetupRequest(value: unknown): CustomMcpSetupRequest | null {\n if (\n !record(value) ||\n !keys(value, [\"kind\", \"name\", \"endpointUrl\", \"rationale\", \"ownership\", \"mcpSetup\"]) ||\n value.kind !== \"mcp\" ||\n !trimmedText(value.name, 256) ||\n !endpoint(value.endpointUrl) ||\n !trimmedText(value.rationale, 2000)\n )\n return null;\n const base = {\n kind: \"mcp\" as const,\n name: value.name.trim(),\n endpointUrl: value.endpointUrl,\n rationale: value.rationale.trim(),\n };\n if (value.ownership === undefined && value.mcpSetup === undefined) return base;\n if (value.ownership !== \"personal\" && value.ownership !== \"workspace\") return null;\n const setup = value.mcpSetup;\n if (\n !record(setup) ||\n !keys(setup, [\"name\", \"endpointUrl\", \"headers\", \"secretFields\"]) ||\n !trimmedText(setup.name, 256) ||\n setup.name.trim() !== base.name ||\n setup.endpointUrl !== base.endpointUrl ||\n !Array.isArray(setup.headers) ||\n setup.headers.length < 1 ||\n setup.headers.length > 32 ||\n !Array.isArray(setup.secretFields) ||\n setup.secretFields.length > 32\n )\n return null;\n const fields: PreparedMcpSetup[\"secretFields\"] = [];\n const fieldIds = new Set<string>();\n for (const field of setup.secretFields) {\n if (\n !record(field) ||\n !keys(field, [\"id\", \"label\"]) ||\n !fieldId(field.id) ||\n !trimmedText(field.label, 256) ||\n fieldIds.has(field.id)\n )\n return null;\n fieldIds.add(field.id);\n fields.push({ id: field.id, label: field.label.trim() });\n }\n const headers: PreparedMcpSetup[\"headers\"] = [];\n const names = new Set<string>();\n const used = new Set<string>();\n for (const header of setup.headers) {\n if (\n !record(header) ||\n !text(header.name, 256) ||\n !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(header.name)\n )\n return null;\n const name = header.name.toLowerCase();\n if (names.has(name)) return null;\n names.add(name);\n if (\"value\" in header) {\n if (\n !keys(header, [\"name\", \"value\"]) ||\n !headerPart(header.value) ||\n !header.value ||\n [\"authorization\", \"proxy-authorization\", \"cookie\", \"x-api-key\", \"api-key\"].includes(name)\n )\n return null;\n headers.push({ name: header.name, value: header.value });\n } else {\n if (\n !keys(header, [\"name\", \"secret\", \"prefix\", \"suffix\"]) ||\n !fieldId(header.secret) ||\n !fieldIds.has(header.secret) ||\n (header.prefix !== undefined && !headerPart(header.prefix)) ||\n (header.suffix !== undefined && !headerPart(header.suffix))\n )\n return null;\n used.add(header.secret);\n headers.push({\n name: header.name,\n secret: header.secret,\n ...(header.prefix !== undefined ? { prefix: header.prefix as string } : {}),\n ...(header.suffix !== undefined ? { suffix: header.suffix as string } : {}),\n });\n }\n }\n if (used.size !== fieldIds.size) return null;\n return {\n ...base,\n ownership: value.ownership,\n mcpSetup: { name: base.name, endpointUrl: base.endpointUrl, headers, secretFields: fields },\n };\n}\n","import type {\n ToolActionReview,\n ToolReviewContext,\n ToolReviewDetailsPage,\n} from \"./tool-action-review\";\n\nconst protectedName =\n /password|passwd|secret|credential|authorization|cookie|(^|[_-])token($|[_-])|api[_-]?key|accessToken|refreshToken|privateKey/i;\nconst protectedReviewField = (key: string, fields: readonly string[] = []) =>\n protectedName.test(key) || fields.includes(key) || fields.includes(\"*\");\nconst bound = (value: string, limit: number) =>\n value.length > limit ? `${value.slice(0, limit)}…` : value;\nexport function toolReviewFieldLabel(key: string): string {\n const label = key\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replace(/[_-]+/g, \" \")\n .replace(/\\bids?\\b/gi, (word) => (word.length === 3 ? \"IDs\" : \"ID\"))\n .replace(\n /\\b(api|url|uri|http|https|ip|sql|json|html)(s?)\\b/gi,\n (_word, name: string, plural: string) => `${name.toUpperCase()}${plural}`,\n )\n // Sentence case, keeping acronyms: \"Working Directory\" → \"Working directory\".\n .replace(\n /(?<=\\S\\s+)([A-Z])([a-z]+)\\b/g,\n (_word, first: string, rest: string) => `${first.toLowerCase()}${rest}`,\n )\n .trim();\n return label.charAt(0).toUpperCase() + label.slice(1);\n}\nexport function decodeReviewArguments(value: unknown): Record<string, unknown> | null {\n // Historical SDK entries sometimes wrapped arguments in JSON. Decode only once.\n let decoded = value;\n if (typeof decoded === \"string\") {\n try {\n decoded = JSON.parse(decoded);\n } catch {\n return null;\n }\n }\n return decoded && typeof decoded === \"object\" && !Array.isArray(decoded)\n ? (decoded as Record<string, unknown>)\n : null;\n}\nexport function safeReviewValue(\n value: unknown,\n key = \"\",\n protectedFields: readonly string[] = [],\n depth = 0,\n): unknown {\n if (protectedReviewField(key, protectedFields)) return \"[Protected value]\";\n if (depth > 20) return \"[Nested value; open this field for details]\";\n if (Array.isArray(value))\n return value.map((entry) => safeReviewValue(entry, \"\", protectedFields, depth + 1));\n if (value && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value).map(([name, entry]) => [\n name,\n safeReviewValue(entry, name, protectedFields, depth + 1),\n ]),\n );\n return value;\n}\nfunction valueText(value: unknown): string {\n return typeof value === \"string\"\n ? value\n : value === null\n ? \"None\"\n : typeof value === \"boolean\"\n ? value\n ? \"Yes\"\n : \"No\"\n : (JSON.stringify(value) ?? \"Unavailable\");\n}\nconst pointer = (name: string) => `/${name.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\")}`;\n// Long arbitrary property names remain readable without placing them in every\n// preview or URL. An indexed segment opens their saved name and value together.\nconst fieldPointer = (key: string, index: number, parent = \"\") =>\n pointer(key).length > 256 || parent.length + pointer(key).length > 1024\n ? `/~2${index}`\n : pointer(key);\n\nexport function toolReviewFields(\n argumentsValue: unknown,\n context?: ToolReviewContext,\n): { fields: ToolActionReview[\"fields\"]; moreFields: number } {\n const args = decodeReviewArguments(argumentsValue);\n if (!args) return { fields: [], moreFields: 0 };\n const entries = Object.entries(args);\n if (context?.email) {\n const email = toolReviewFields(context.email);\n const original = toolReviewFields(args, { ...context, email: undefined });\n const fields = [\n ...email.fields\n .filter(\n (field) =>\n field.path !== \"/contentSha256\" && field.path !== \"/htmlBody\" && field.preview !== \"\",\n )\n .map((field) => ({\n ...field,\n label: field.path === \"/textBody\" ? \"Message\" : field.label,\n path: `/$email${field.path}`,\n ...(field.path === \"/attachments\"\n ? {\n preview: context\n .email!.attachments.map((attachment) => attachment.name)\n .join(\", \")\n .slice(0, 240),\n }\n : {}),\n })),\n ...original.fields.filter(\n (field) =>\n ![\n \"/raw\",\n \"/expectedContentSha256\",\n \"/from\",\n \"/to\",\n \"/cc\",\n \"/bcc\",\n \"/subject\",\n \"/body\",\n \"/textBody\",\n \"/htmlBody\",\n \"/attachments\",\n ].includes(field.path),\n ),\n ];\n return {\n fields: fields.slice(0, 16),\n moreFields: original.moreFields + Math.max(0, fields.length - 16),\n };\n }\n return {\n moreFields: Math.max(0, entries.length - 16),\n fields: entries.slice(0, 16).map(([key, value], index) => {\n const hidden = protectedReviewField(key, context?.protectedFields);\n const safe = hidden ? \"[Protected value]\" : value;\n const count = !hidden && Array.isArray(value) ? value.length : undefined;\n const compactList =\n !hidden &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.length <= 4 &&\n value.every(\n (entry) =>\n typeof entry === \"string\" || typeof entry === \"number\" || typeof entry === \"boolean\",\n )\n ? value.map(valueText).join(\", \")\n : undefined;\n const text =\n compactList !== undefined\n ? compactList\n : count !== undefined\n ? `${count.toLocaleString(\"en-US\")} item${count === 1 ? \"\" : \"s\"}`\n : safe && typeof safe === \"object\"\n ? `${Object.keys(safe).length} field${Object.keys(safe).length === 1 ? \"\" : \"s\"}`\n : valueText(safe);\n return {\n path: fieldPointer(key, index),\n label: bound(\n (context?.fieldLabels && Object.hasOwn(context.fieldLabels, key)\n ? context.fieldLabels[key]\n : undefined) ?? toolReviewFieldLabel(key),\n 256,\n ),\n preview: bound(text, 240),\n ...(count !== undefined ? { count } : {}),\n truncated:\n !hidden &&\n (text.length > 240 ||\n (compactList === undefined && typeof value === \"object\" && value !== null)),\n ...(hidden ? { protected: true } : {}),\n };\n }),\n };\n}\n\n/** Deterministic consequences from the reviewed bytes. Unknown fields remain visible. */\nexport function toolReviewAction(\n toolName: string,\n argumentsValue: unknown,\n context?: ToolReviewContext,\n): Pick<\n ToolActionReview,\n \"title\" | \"approveLabel\" | \"effects\" | \"consequence\" | \"selectionCount\" | \"selectionKind\"\n> {\n const fallback = {\n title:\n context?.title ??\n bound(\n toolReviewFieldLabel(\n toolName.replace(/^mcp_[^_]+__/, \"\").replace(/^batch[_-](?=[a-z])/i, \"\"),\n ),\n 256,\n ),\n approveLabel: \"Approve action\",\n effects: [] as string[],\n };\n if (context?.kind !== \"gmail\") return fallback;\n const args = decodeReviewArguments(argumentsValue);\n if (!args) return fallback;\n const thread = toolName.endsWith(\"_thread\");\n const selectionKind = thread ? (\"threads\" as const) : (\"messages\" as const);\n const ids =\n thread && typeof args.threadId === \"string\"\n ? [args.threadId]\n : Array.isArray(args.messageIds)\n ? args.messageIds\n : typeof args.messageId === \"string\"\n ? [args.messageId]\n : null;\n const selectionCount = ids?.every((id) => typeof id === \"string\") ? new Set(ids).size : undefined;\n const noun =\n selectionCount === undefined\n ? thread\n ? \"conversations\"\n : \"messages\"\n : `${selectionCount.toLocaleString(\"en-US\")} ${thread ? \"conversation\" : \"message\"}${selectionCount === 1 ? \"\" : \"s\"}`;\n const addValues = toolName.startsWith(\"label_\") ? args.labelIds : args.addLabelIds;\n const adds = Array.isArray(addValues)\n ? addValues.filter((v): v is string => typeof v === \"string\")\n : [];\n const removeValues = toolName.startsWith(\"unlabel_\") ? args.labelIds : args.removeLabelIds;\n const removes = Array.isArray(removeValues)\n ? removeValues.filter((v): v is string => typeof v === \"string\")\n : [];\n const labelEffect = (label: string, adding: boolean): string => {\n const known: Record<string, [string, string]> = {\n TRASH: [\"Move to Trash\", \"Remove from Trash\"],\n INBOX: [\"Move to Inbox\", \"Remove from Inbox\"],\n UNREAD: [\"Mark as unread\", \"Mark as read\"],\n STARRED: [\"Add star\", \"Remove star\"],\n SPAM: [\"Mark as spam\", \"Remove from Spam\"],\n IMPORTANT: [\"Mark as important\", \"Remove importance\"],\n };\n return (\n (Object.hasOwn(known, label) ? known[label]?.[adding ? 0 : 1] : undefined) ??\n `${adding ? \"Add\" : \"Remove\"} label ${bound(label, 120)}`\n );\n };\n const effects = [\n ...adds.map((id) => labelEffect(id, true)),\n ...removes.map((id) => labelEffect(id, false)),\n ];\n if (\n [\n \"batch_modify_messages\",\n \"modify_message\",\n \"modify_thread\",\n \"label_message\",\n \"label_thread\",\n \"unlabel_message\",\n \"unlabel_thread\",\n ].includes(toolName)\n ) {\n const trash = adds.includes(\"TRASH\");\n return {\n title: trash ? `Move ${noun} to Trash` : `Update ${noun}`,\n approveLabel: trash ? \"Move to Trash\" : \"Apply changes\",\n effects,\n ...(selectionCount === undefined ? {} : { selectionCount, selectionKind }),\n ...(trash\n ? { consequence: \"Messages stay recoverable in Trash until Gmail deletes them.\" }\n : thread\n ? { consequence: \"Applies to every message in the conversation.\" }\n : {}),\n };\n }\n if ([\"trash_message\", \"restore_message\", \"trash_thread\", \"restore_thread\"].includes(toolName))\n return {\n title: toolName.startsWith(\"trash_\") ? `Move ${noun} to Trash` : `Remove ${noun} from Trash`,\n approveLabel: toolName.startsWith(\"trash_\") ? \"Move to Trash\" : \"Remove from Trash\",\n effects,\n ...(selectionCount === undefined ? {} : { selectionCount, selectionKind }),\n };\n const named: Record<string, [string, string]> = {\n send_message: [\"Send email\", \"Send email\"],\n send_draft: [\"Send draft\", \"Send draft\"],\n create_draft: [\"Create email draft\", \"Create draft\"],\n update_draft: [\"Update email draft\", \"Update draft\"],\n delete_draft: [\"Delete email draft\", \"Delete draft\"],\n create_label: [\"Create label\", \"Create label\"],\n update_label: [\"Update label\", \"Update label\"],\n delete_label: [\"Delete label\", \"Delete label\"],\n };\n const action = Object.hasOwn(named, toolName) ? named[toolName] : undefined;\n return action ? { title: action[0], approveLabel: action[1], effects } : fallback;\n}\n\n/** A bounded slice of the immutable saved arguments; never evaluates a fresh provider query. */\nexport function toolReviewDetails(\n argumentsValue: unknown,\n context: ToolReviewContext | undefined,\n path: string,\n offset: number,\n limit = 25,\n): Omit<ToolReviewDetailsPage, \"id\" | \"actionDigest\" | \"version\"> {\n if (\n !Number.isSafeInteger(offset) ||\n offset < 0 ||\n !Number.isSafeInteger(limit) ||\n limit < 1 ||\n limit > 50\n )\n throw new Error(\"Invalid review page\");\n const args = decodeReviewArguments(argumentsValue);\n let value: unknown = context?.email ? { ...args, $email: context.email } : args;\n if (path !== \"\") {\n if (!path.startsWith(\"/\")) throw new Error(\"Invalid review field\");\n for (const escaped of path.slice(1).split(\"/\")) {\n if (/^~2\\d+$/.test(escaped)) {\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n throw new Error(\"Review field not found\");\n const selected = Object.entries(value)[Number(escaped.slice(2))];\n if (!selected) throw new Error(\"Review field not found\");\n value = {\n fieldName: selected[0],\n value: protectedReviewField(selected[0], context?.protectedFields)\n ? \"[Protected value]\"\n : selected[1],\n };\n continue;\n }\n const key = escaped.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n if (protectedReviewField(key, context?.protectedFields)) {\n value = \"[Protected value]\";\n break;\n }\n if (!value || typeof value !== \"object\" || !Object.hasOwn(value, key))\n throw new Error(\"Review field not found\");\n value = (value as Record<string, unknown>)[key];\n }\n }\n type DetailItem = ToolReviewDetailsPage[\"items\"][number];\n const preview = (\n entry: unknown,\n key: string,\n childPath: string,\n ): Pick<DetailItem, \"value\" | \"truncated\" | \"path\"> => {\n const hidden = protectedReviewField(key, context?.protectedFields);\n if (!hidden && entry !== null && typeof entry === \"object\") {\n const count = Array.isArray(entry) ? entry.length : Object.keys(entry).length;\n return {\n value: `${count.toLocaleString(\"en-US\")} ${Array.isArray(entry) ? (count === 1 ? \"item\" : \"items\") : count === 1 ? \"field\" : \"fields\"}`,\n path: childPath,\n truncated: true,\n };\n }\n const text = valueText(safeReviewValue(entry, key, context?.protectedFields));\n return {\n value: bound(text, 4000),\n ...(hidden ? {} : { path: childPath }),\n truncated: !hidden && text.length > 4000,\n };\n };\n // Selected messages read as subject and sender rather than bare provider ids.\n const labels =\n (path === \"/messageIds\" || path === \"/messageId\") && context?.selectionLabels?.length\n ? new Map(context.selectionLabels.map((label) => [label.id, label]))\n : undefined;\n const labelled = (entry: unknown): Pick<DetailItem, \"value\" | \"detail\"> | undefined => {\n const label = typeof entry === \"string\" ? labels?.get(entry) : undefined;\n return label && typeof entry === \"string\"\n ? {\n value: label.title,\n detail: label.subtitle ? `${label.subtitle} · ${entry}` : entry,\n }\n : undefined;\n };\n let total: number;\n let items: DetailItem[];\n if (Array.isArray(value)) {\n total = value.length;\n items = value.slice(offset, offset + limit).map((entry, index) => ({\n label: `${offset + index + 1}`,\n ...preview(entry, \"\", `${path}/${offset + index}`),\n ...labelled(entry),\n }));\n } else if (offset === 0 && labelled(value)) {\n total = 1;\n items = [{ label: \"Message\", ...labelled(value)! }];\n } else if (value && typeof value === \"object\") {\n const entries = Object.entries(value);\n total = entries.length;\n items = entries.slice(offset, offset + limit).map(([key, entry], index) => ({\n label: bound(\n (context?.fieldLabels && Object.hasOwn(context.fieldLabels, key)\n ? context.fieldLabels[key]\n : undefined) ?? toolReviewFieldLabel(key),\n 256,\n ),\n ...preview(entry, key, `${path}${fieldPointer(key, offset + index, path)}`),\n }));\n } else {\n const text = valueText(value);\n total = Math.max(1, Math.ceil(text.length / 4000));\n items = Array.from({ length: Math.max(0, Math.min(limit, total - offset)) }, (_, index) => ({\n label: `Part ${offset + index + 1}`,\n value: text.slice((offset + index) * 4000, (offset + index + 1) * 4000),\n }));\n }\n return { path, items, total, nextOffset: offset + limit < total ? offset + limit : null };\n}\n","/** 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 (\n Object.keys(item).some(\n (key) => ![\"toolName\", \"title\", \"accountLabel\", \"connector\", \"providerDomain\"].includes(key),\n )\n )\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 if (item.connector !== undefined && !text(item.connector, 512)) return undefined;\n if (item.providerDomain !== undefined && !text(item.providerDomain, 253)) 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 ...(item.connector !== undefined ? { connector: item.connector as string } : {}),\n ...(item.providerDomain !== undefined ? { providerDomain: item.providerDomain 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,SAAS,uCAAuC,QAAmC;AACxF,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,WAAW,sBAAsB,EAAG,QAAO;AACrF,QAAM,QAAQ,OAAO,MAAM,IAAI;AAC/B,SACE,MAAM,WAAW,KACjB,MAAM,CAAC,EAAG,W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AAE;AACjG;;;AC3BO,SAAS,qCAAqC,OAAuB;AAC1E,SAAO,MAAM,UAAU,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,GAAG;AAC9F;","names":["text","endpoint","text","record","text"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { OpenGeniApiError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Bounded retry for safe reads (`GET` and `HEAD`) that failed transiently:
|
|
4
|
+
* the request never reached a healthy server (a transport error such as a
|
|
5
|
+
* reset connection) or a gateway answered 502, 503 or 504. These are what an
|
|
6
|
+
* API rolling deploy or a short network blip look like from the client.
|
|
7
|
+
* Mutations are never retried here; they keep their outcome-unknown semantics.
|
|
8
|
+
*/
|
|
9
|
+
export type OpenGeniReadRetryOptions = {
|
|
10
|
+
/** Total attempts including the first. Defaults to 4; `1` disables retries. */
|
|
11
|
+
maxAttempts?: number | undefined;
|
|
12
|
+
/** Backoff before the first retry, before jitter. Defaults to 250 ms. Doubles per retry. */
|
|
13
|
+
initialDelayMs?: number | undefined;
|
|
14
|
+
/** Upper bound for one backoff delay. Defaults to 2000 ms. */
|
|
15
|
+
maxDelayMs?: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Total time budget measured from the first attempt. A retry, including one
|
|
18
|
+
* whose `Retry-After` asks for a longer wait, is only made when its delay
|
|
19
|
+
* still fits in the budget; otherwise the last error surfaces. Defaults to 5000 ms.
|
|
20
|
+
*/
|
|
21
|
+
maxElapsedMs?: number | undefined;
|
|
22
|
+
};
|
|
23
|
+
export type ReadRetryPolicy = {
|
|
24
|
+
maxAttempts: number;
|
|
25
|
+
initialDelayMs: number;
|
|
26
|
+
maxDelayMs: number;
|
|
27
|
+
maxElapsedMs: number;
|
|
28
|
+
};
|
|
29
|
+
export declare const DEFAULT_READ_RETRY_POLICY: Readonly<ReadRetryPolicy>;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve client options to a policy, or `null` when retries are off. Invalid
|
|
32
|
+
* values fall back to the defaults instead of failing client construction.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveReadRetryPolicy(options: OpenGeniReadRetryOptions | false | undefined): ReadRetryPolicy | null;
|
|
35
|
+
export declare function isSafeReadMethod(method: string): boolean;
|
|
36
|
+
/** Gateway statuses a rolling deploy or an overloaded upstream answers with. */
|
|
37
|
+
export declare function isTransientGatewayStatus(status: number): boolean;
|
|
38
|
+
/** Record that `error` is a transport failure of an API request. */
|
|
39
|
+
export declare function markTransportFailure(error: unknown): void;
|
|
40
|
+
/** A 502 for a response the client received but could not accept. */
|
|
41
|
+
export declare function invalidApiResponseError(body: string, options?: ConstructorParameters<typeof OpenGeniApiError>[2]): OpenGeniApiError;
|
|
42
|
+
/**
|
|
43
|
+
* A failure a later identical safe read can plausibly succeed after: a
|
|
44
|
+
* transport error (`fetch` or the response body rejected with a `TypeError`)
|
|
45
|
+
* or a retryable 502, 503 or 504. Auth, permission, not-found, validation,
|
|
46
|
+
* rate limits, aborts, other server errors, a success response the client
|
|
47
|
+
* could not accept, and `TypeError`s from application code are definitive and
|
|
48
|
+
* are not transient.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isTransientRequestError(error: unknown): boolean;
|
|
51
|
+
/** `Retry-After` as milliseconds from `now`, or `null` when absent or invalid. */
|
|
52
|
+
export declare function parseRetryAfterMs(value: string | null | undefined, now?: number): number | null;
|
|
53
|
+
/**
|
|
54
|
+
* The delay before retry number `retry` (1 for the first retry), or `null`
|
|
55
|
+
* when no retry fits the policy. A server `Retry-After` is honored, plus up to
|
|
56
|
+
* 20% so clients told the same instant do not all return at once; otherwise
|
|
57
|
+
* the exponential backoff is jittered to between half and all of it.
|
|
58
|
+
*/
|
|
59
|
+
export declare function readRetryDelayMs(policy: ReadRetryPolicy, retry: number, elapsedMs: number, retryAfterMs: number | null, random?: () => number): number | null;
|
|
60
|
+
/** Resolve after `ms`, or reject with the signal's reason once it aborts. */
|
|
61
|
+
export declare function abortableReadRetryDelay(ms: number, signal: AbortSignal | undefined): Promise<void>;
|
package/dist/realtime.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGatewayRealtimeTransportStarter,
|
|
3
|
+
createXaiSubscriptionRealtimeTransportStarter
|
|
4
|
+
} from "./chunk-M6QTIJ7S.js";
|
|
1
5
|
import {
|
|
2
6
|
CODEX_REALTIME_CONTEXT_APPEND_MAX_BYTES,
|
|
3
7
|
CODEX_REALTIME_INITIAL_ITEMS_MAX_COUNT,
|
|
@@ -25,11 +29,7 @@ import {
|
|
|
25
29
|
sessionRealtimeOwnerStorageKey,
|
|
26
30
|
sessionRealtimeOwnerStorageNamespace,
|
|
27
31
|
startCodexRealtimeWebrtc
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import {
|
|
30
|
-
createGatewayRealtimeTransportStarter,
|
|
31
|
-
createXaiSubscriptionRealtimeTransportStarter
|
|
32
|
-
} from "./chunk-M6QTIJ7S.js";
|
|
32
|
+
} from "./chunk-U4JUWOZV.js";
|
|
33
33
|
import {
|
|
34
34
|
createRealtimeWebsocketTransportStarter
|
|
35
35
|
} from "./chunk-TUE2VNEC.js";
|
package/dist/session-proxy.d.ts
CHANGED
|
@@ -65,7 +65,9 @@ export type SessionProxyContext = {
|
|
|
65
65
|
client: ProxyClient;
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
* The only fields a browser may send when creating a session through the proxy
|
|
68
|
+
* The only fields a browser may send when creating a session through the proxy,
|
|
69
|
+
* besides `modelContext`, which the proxy appends after any context the hook
|
|
70
|
+
* and `messageExtras` return, as it does for follow-up messages.
|
|
69
71
|
* After the `createSession` hook returns, the proxy adds the attached files to
|
|
70
72
|
* the created request (deduplicated by file id) and, when `modelSelection` is
|
|
71
73
|
* not `false`, applies the browser's explicit model choices over the hook's,
|
|
@@ -312,6 +314,9 @@ export type SessionProxyHandlerOptions = {
|
|
|
312
314
|
* pinning a chat, moving it to a project, managing projects and a chat's
|
|
313
315
|
* tool approval settings. Every other write is refused.
|
|
314
316
|
* - Catalog logos are served from the Opengeni API.
|
|
317
|
+
* - Creating a chat also takes the app's own create fields: the id of its
|
|
318
|
+
* first message and the new-chat draft revision it sent. It sends
|
|
319
|
+
* `visibility` and `connectionAccounts` too; the server chooses both.
|
|
315
320
|
*/
|
|
316
321
|
sessionApp?: boolean | undefined;
|
|
317
322
|
/**
|
package/dist/session-proxy.js
CHANGED
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
downloadSessionProxySiteHtml,
|
|
7
7
|
getSessionProxyArtifactAssociation,
|
|
8
8
|
getSessionProxyWorkspaceGrant
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JBAGMSN2.js";
|
|
10
10
|
import "./chunk-UM4ZXXJR.js";
|
|
11
11
|
import "./chunk-QGEIL4TR.js";
|
|
12
12
|
import "./chunk-72YZCZWF.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-V4AIZAFF.js";
|
|
14
14
|
import "./chunk-ODKRQUWR.js";
|
|
15
15
|
export {
|
|
16
16
|
SESSION_PROXY_SITE_HTML_MAX_BYTES,
|
package/dist/site-bridge-host.js
CHANGED
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
sanitizeOpenGeniSiteToolCallRequest,
|
|
13
13
|
sanitizeOpenGeniSiteToolInvokeRequest,
|
|
14
14
|
serveSiteHttp
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VSOXNL3T.js";
|
|
16
16
|
import "./chunk-OV3POE62.js";
|
|
17
17
|
import "./chunk-ORYDCRFM.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-BXMNDWAN.js";
|
|
19
19
|
import "./chunk-X5ITQVXE.js";
|
|
20
20
|
import "./chunk-72YZCZWF.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-V4AIZAFF.js";
|
|
22
22
|
import "./chunk-POYRW6KT.js";
|
|
23
23
|
import "./chunk-ODKRQUWR.js";
|
|
24
24
|
|