@otium-team/negotium 0.23.11 → 0.23.14
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 +8 -0
- package/dist/agent-helpers.js +821 -1516
- package/dist/agent-helpers.js.map +22 -21
- package/dist/background-bash.js +48 -19
- package/dist/background-bash.js.map +6 -5
- package/dist/browser-runtime.js +96 -69
- package/dist/browser-runtime.js.map +6 -5
- package/dist/canonical-mcp-bridge.js +8 -9
- package/dist/canonical-mcp-bridge.js.map +1 -1
- package/dist/{chunk-0fenxbe6.js → chunk-3v58ejrk.js} +4 -5
- package/dist/{chunk-0fenxbe6.js.map → chunk-3v58ejrk.js.map} +2 -2
- package/dist/chunk-d1c2wt8q.js +83 -0
- package/dist/{chunk-ad7kxsaq.js.map → chunk-d1c2wt8q.js.map} +1 -1
- package/dist/{chunk-jtv8yzy1.js → chunk-m1ngkjdd.js} +12 -12
- package/dist/{chunk-jtv8yzy1.js.map → chunk-m1ngkjdd.js.map} +2 -2
- package/dist/{chunk-da9ad838.js → chunk-ng13grfj.js} +180 -152
- package/dist/{chunk-da9ad838.js.map → chunk-ng13grfj.js.map} +11 -10
- package/dist/{chunk-mxxwx5mg.js → chunk-pesnv5zv.js} +134 -143
- package/dist/chunk-pesnv5zv.js.map +14 -0
- package/dist/{chunk-f7p0h1gs.js → chunk-ww8a4ej4.js} +5 -5
- package/dist/{chunk-f7p0h1gs.js.map → chunk-ww8a4ej4.js.map} +2 -2
- package/dist/hosted-agent.js +204 -136
- package/dist/hosted-agent.js.map +7 -7
- package/dist/main.js +4340 -4529
- package/dist/main.js.map +31 -28
- package/dist/mcp-catalog.js +4 -4
- package/dist/mcp-catalog.js.map +1 -1
- package/dist/mcp-factories.js +1080 -1767
- package/dist/mcp-factories.js.map +21 -20
- package/dist/mcp-servers.js +5 -5
- package/dist/mcp-servers.js.map +1 -1
- package/dist/media.js +42 -13
- package/dist/media.js.map +6 -5
- package/dist/outbox.js +15 -15
- package/dist/outbox.js.map +2 -2
- package/dist/platform-runtime.js +7 -7
- package/dist/platform-runtime.js.map +1 -1
- package/dist/prompts.js +74 -15
- package/dist/prompts.js.map +8 -7
- package/dist/query-runtime.js +57 -30
- package/dist/query-runtime.js.map +7 -6
- package/dist/registry.js +22 -21
- package/dist/registry.js.map +3 -3
- package/dist/rollout.js +41 -41
- package/dist/rollout.js.map +2 -2
- package/dist/runtime/src/agents/claude-provider.ts +80 -5
- package/dist/runtime/src/agents/claude-registry.ts +2 -1
- package/dist/runtime/src/agents/explicit-agent-switch.ts +1 -1
- package/dist/runtime/src/agents/mcp-tools/self-config.ts +1 -1
- package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +9 -1
- package/dist/runtime/src/agents/model-catalog.ts +13 -0
- package/dist/runtime/src/application/submit-runtime-gateway-turn.ts +84 -20
- package/dist/runtime/src/application/topic-service.ts +6 -2
- package/dist/runtime/src/application/turn-follow-ups.ts +291 -0
- package/dist/runtime/src/bus.ts +6 -0
- package/dist/runtime/src/node-host.ts +11 -0
- package/dist/runtime/src/platform/browser-backend.ts +73 -0
- package/dist/runtime/src/platform/config.ts +3 -0
- package/dist/runtime/src/platform/mcp-config.ts +3 -0
- package/dist/runtime/src/prompts/builders.ts +11 -2
- package/dist/runtime/src/prompts/sessions/_shared-tools.md +2 -0
- package/dist/runtime/src/query/active-rooms.ts +7 -1
- package/dist/runtime/src/runtime/turn-event-stream.ts +34 -6
- package/dist/runtime/src/runtime/turn-runner.ts +54 -9
- package/dist/runtime/src/runtime-gateway.ts +198 -1
- package/dist/runtime/src/storage/runtime-follow-ups.ts +212 -0
- package/dist/runtime/src/storage/runtime-turn-requests.ts +43 -2
- package/dist/runtime/src/storage/token-stats.ts +4 -0
- package/dist/runtime/src/types/api.ts +9 -0
- package/dist/runtime/src/types.ts +23 -0
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-gateway.js +73 -12
- package/dist/runtime-gateway.js.map +3 -3
- package/dist/runtime-helpers.js +107 -80
- package/dist/runtime-helpers.js.map +6 -5
- package/dist/sqlite.js +3 -5
- package/dist/sqlite.js.map +2 -2
- package/dist/storage.js +4843 -4812
- package/dist/storage.js.map +4 -4
- package/dist/types/packages/core/src/bus.d.ts +3 -0
- package/dist/types/packages/core/src/platform/browser-backend.d.ts +8 -0
- package/dist/types/packages/core/src/platform/config.d.ts +2 -0
- package/dist/types/packages/core/src/query/active-rooms.d.ts +7 -1
- package/dist/types/packages/core/src/runtime-gateway.d.ts +59 -1
- package/dist/types/packages/core/src/storage/runtime-turn-requests.d.ts +25 -0
- package/dist/types/packages/core/src/types/api.d.ts +5 -0
- package/dist/types/packages/core/src/types.d.ts +21 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +64 -37
- package/dist/vault.js.map +6 -5
- package/package.json +1 -1
- package/dist/chunk-2mx7fq49.js +0 -6
- package/dist/chunk-2mx7fq49.js.map +0 -9
- package/dist/chunk-ad7kxsaq.js +0 -202
- package/dist/chunk-mxxwx5mg.js.map +0 -13
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/core/src/runtime-gateway.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { ActorTopicScope, RemoteSessionGrant } from \"#types\";\nimport type { MessageDto } from \"#types/api\";\n\nexport const RUNTIME_GATEWAY_VERSION = 1 as const;\nexport const RUNTIME_GATEWAY_CONTROL_PATH = \"/api/v1/control/runtime/v1\";\n\nexport type RuntimeGatewayErrorKind = \"config\" | \"timeout\" | \"transport\" | \"protocol\" | \"http\";\n\nexport class RuntimeGatewayError extends Error {\n constructor(\n message: string,\n public readonly kind: RuntimeGatewayErrorKind,\n public readonly status?: number,\n ) {\n super(message);\n }\n}\n\nexport interface RuntimeGatewayHealth {\n ok: true;\n v: typeof RUNTIME_GATEWAY_VERSION;\n nodeId?: string;\n aiName?: string;\n capabilities: string[];\n cursor: number;\n}\n\n/** Remote-only MCP transport a gateway host may grant to a manager topic. */\nexport interface HostMcpServerSpec {\n type: \"sse\" | \"http\";\n url: string;\n headers?: Record<string, string>;\n timeout?: number;\n}\n\nconst HOST_MCP_SERVER_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nconst HOST_MCP_SERVER_KEYS = new Set([\"type\", \"url\", \"headers\", \"timeout\"]);\nconst HTTP_HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/** Keep host grants remote-only so a gateway caller cannot spawn node processes. */\nexport function parseHostMcpServers(value: unknown): Record<string, HostMcpServerSpec> | undefined {\n if (value === undefined) return undefined;\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\"hostMcpServers must be an object\");\n }\n const parsedEntries: Array<[string, HostMcpServerSpec]> = [];\n for (const [name, raw] of Object.entries(value)) {\n if (!HOST_MCP_SERVER_NAME.test(name)) {\n throw new TypeError(`invalid host MCP server name: ${name}`);\n }\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n throw new TypeError(`hostMcpServers.${name} must be an object`);\n }\n const spec = raw as Record<string, unknown>;\n const unsupported = Object.keys(spec).find((key) => !HOST_MCP_SERVER_KEYS.has(key));\n if (unsupported) {\n throw new TypeError(`hostMcpServers.${name}.${unsupported} is not allowed`);\n }\n if (spec.type !== \"sse\" && spec.type !== \"http\") {\n throw new TypeError(`hostMcpServers.${name}.type must be sse or http`);\n }\n if (typeof spec.url !== \"string\") {\n throw new TypeError(`hostMcpServers.${name}.url must be a string`);\n }\n let url: URL;\n try {\n url = new URL(spec.url);\n } catch {\n throw new TypeError(`hostMcpServers.${name}.url must be a valid URL`);\n }\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n throw new TypeError(`hostMcpServers.${name}.url must use http or https`);\n }\n let headers: Record<string, string> | undefined;\n if (spec.headers !== undefined) {\n if (!spec.headers || typeof spec.headers !== \"object\" || Array.isArray(spec.headers)) {\n throw new TypeError(`hostMcpServers.${name}.headers must be an object`);\n }\n const headerEntries: Array<[string, string]> = [];\n for (const [key, headerValue] of Object.entries(spec.headers)) {\n if (!HTTP_HEADER_NAME.test(key) || typeof headerValue !== \"string\") {\n throw new TypeError(`hostMcpServers.${name}.headers must contain string values`);\n }\n try {\n new Headers([[key, headerValue]]);\n } catch {\n throw new TypeError(`hostMcpServers.${name}.headers contains an invalid header`);\n }\n headerEntries.push([key, headerValue]);\n }\n headers = Object.fromEntries(headerEntries);\n }\n if (\n spec.timeout !== undefined &&\n (typeof spec.timeout !== \"number\" || !Number.isFinite(spec.timeout) || spec.timeout <= 0)\n ) {\n throw new TypeError(`hostMcpServers.${name}.timeout must be a positive number`);\n }\n parsedEntries.push([\n name,\n {\n type: spec.type,\n url: url.toString(),\n ...(headers ? { headers } : {}),\n ...(spec.timeout !== undefined ? { timeout: spec.timeout } : {}),\n },\n ]);\n }\n return Object.fromEntries(parsedEntries);\n}\n\nexport interface RuntimeGatewayTurnInput {\n topicId: string;\n /** Canonical principal on the execution node. */\n userId: string;\n /** Product-side actor, when it differs from the execution principal. */\n actorUserId?: string;\n /**\n * The node topic ids `actorUserId` may reach on the receiving node, as the\n * host's membership store sees it. Omitted by hosts that predate it; the\n * node then confines the turn's cross-room tools to the current room.\n */\n actorTopicScope?: ActorTopicScope;\n /**\n * Hub-issued per-turn authority for remote (`node/topic`) session-comm:\n * `{ hubUrl, capability }`. `hubUrl` must be a loopback `http://` or any\n * `https://` origin (≤ 512 chars); `capability` an opaque `rsc1.` bearer\n * (≤ 2 KiB) the node presents back to the hub and cannot verify — it holds\n * no key. It does base64-decode the payload's `e` (expiry) for one purpose,\n * ordering grants when several requests fold into one turn\n * (`remoteSessionGrantExpiry`); that value is untrusted and takes part in no\n * security decision. Omitted\n * by hosts that predate it or have the feature off; the node then keeps\n * remote session-comm fail-closed on the `otium` surface. Malformed → 400.\n */\n remoteSession?: RemoteSessionGrant;\n actorLabel?: string;\n vaultUserId?: string;\n /** Adapter provenance recorded on the canonical message. */\n sourceAdapter?: string;\n text: string;\n clientMessageId: string;\n requestId?: string;\n allowAutoContinue?: boolean;\n threadRootId?: string;\n /** Inline quote-reply target. Mutually exclusive with `threadRootId`. */\n parentId?: string;\n respond?: boolean;\n /**\n * While a turn from the same person runs: `true` (default) aborts it and\n * resumes with the merged batch; `false` queues this message behind it.\n */\n steer?: boolean;\n /** Run without adding the injected prompt or output to the visible transcript. */\n silent?: boolean;\n attachments?: string[];\n visualTools?: boolean;\n fileDeliveryTools?: boolean;\n /** Host-owned remote MCP servers granted to this manager topic. */\n hostMcpServers?: Record<string, HostMcpServerSpec>;\n}\n\nexport interface RuntimeGatewayTurnAcknowledgement {\n ok: true;\n v: typeof RUNTIME_GATEWAY_VERSION;\n accepted: true;\n deduplicated: boolean;\n requestId: string;\n clientMessageId: string;\n topicId: string;\n messageId: string;\n /** Canonical persisted message when the Node supports inline ACK materialization. */\n message?: MessageDto;\n cursor: number;\n}\n\nexport interface RuntimeGatewayTopicDeriveInput {\n userId: string;\n copyHistory: boolean;\n name?: string;\n}\n\nexport interface RuntimeGatewayDerivedTopic {\n id: string;\n title: string;\n kind?: string;\n agent?: string;\n defaultModel?: string;\n defaultEffort?: string;\n parentTopicId?: string;\n isFork?: boolean;\n}\n\nexport interface RuntimeGatewaySseEvent {\n id?: number;\n event: string;\n data: unknown;\n}\n\nexport interface RuntimeGatewayTopicUsage {\n queries: number;\n inputTokens: number;\n outputTokens: number;\n cacheCreationInputTokens: number;\n cacheReadInputTokens: number;\n estimatedCostUsd: number;\n}\n\nexport interface RuntimeGatewayManagerTopic {\n id: string;\n title: string;\n kind: \"manager\";\n agent?: \"claude\" | \"codex\" | \"maestro\";\n participants: Array<{ userId: string; role: \"owner\" | \"member\" }>;\n}\n\nexport interface RuntimeGatewayDeletedMessage {\n id: string;\n topicId: string;\n authorId: string;\n text: string;\n deleted: true;\n createdAt: string;\n}\n\nexport interface RuntimeGatewayCronJob {\n id: string;\n name: string;\n executionPrincipalUserId: string;\n actorOwnerUserId: string;\n topicId: string;\n source: \"prompt\" | \"script\";\n script: string | null;\n scriptExists: boolean;\n prompt: string | null;\n promptPreview: string | null;\n summary: string | null;\n schedule: string;\n timezone: string | null;\n enabled: boolean;\n agent: \"claude\" | \"codex\" | \"maestro\" | null;\n model: string | null;\n effort: string | null;\n nextRunAt: string;\n runCount: number;\n lastRun: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n canMutate: boolean;\n}\n\nexport interface RuntimeGatewayCronCreateInput {\n userId: string;\n actorUserId: string;\n topicId: string;\n name: string;\n script: string;\n schedule: string;\n timezone?: string;\n agent?: \"claude\" | \"codex\" | \"maestro\";\n model?: string;\n effort?: string;\n}\n\nexport interface RuntimeGatewayCronPatch {\n name?: string;\n topicId?: string;\n script?: string;\n schedule?: string;\n timezone?: string | null;\n enabled?: boolean;\n agent?: \"claude\" | \"codex\" | \"maestro\" | null;\n model?: string | null;\n effort?: string | null;\n}\n\nexport type RuntimeGatewayToken = string | (() => string | Promise<string>);\nexport type RuntimeGatewayFetch = (\n input: string | URL | Request,\n init?: RequestInit,\n) => Promise<Response>;\n\nexport interface RuntimeGatewayClientOptions {\n baseUrl: string;\n token: RuntimeGatewayToken;\n /** Loopback control path or an authenticated relay forward prefix. */\n pathPrefix?: string;\n fetch?: RuntimeGatewayFetch;\n requestTimeoutMs?: number;\n compactTimeoutMs?: number;\n}\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n}\n\nasync function json(response: Response): Promise<unknown> {\n try {\n return await response.json();\n } catch {\n throw new RuntimeGatewayError(\n \"Runtime Gateway returned invalid JSON\",\n \"protocol\",\n response.status,\n );\n }\n}\n\nfunction validHealth(value: unknown): value is RuntimeGatewayHealth {\n const body = record(value);\n return Boolean(\n body?.ok === true &&\n body.v === RUNTIME_GATEWAY_VERSION &&\n Array.isArray(body.capabilities) &&\n typeof body.cursor === \"number\",\n );\n}\n\nfunction validAcknowledgedMessage(value: unknown): value is MessageDto {\n const message = record(value);\n return Boolean(\n message &&\n typeof message.id === \"string\" &&\n typeof message.topicId === \"string\" &&\n typeof message.authorId === \"string\" &&\n typeof message.text === \"string\" &&\n typeof message.createdAt === \"string\",\n );\n}\n\nfunction validTurnAck(value: unknown): value is RuntimeGatewayTurnAcknowledgement {\n const body = record(value);\n return Boolean(\n body?.ok === true &&\n body.v === RUNTIME_GATEWAY_VERSION &&\n body.accepted === true &&\n typeof body.deduplicated === \"boolean\" &&\n typeof body.requestId === \"string\" &&\n typeof body.clientMessageId === \"string\" &&\n typeof body.topicId === \"string\" &&\n typeof body.messageId === \"string\" &&\n (body.message === undefined || validAcknowledgedMessage(body.message)) &&\n typeof body.cursor === \"number\",\n );\n}\n\nfunction validManagerTopic(value: unknown): value is RuntimeGatewayManagerTopic {\n const topic = record(value);\n return Boolean(\n typeof topic?.id === \"string\" &&\n typeof topic.title === \"string\" &&\n topic.kind === \"manager\" &&\n Array.isArray(topic.participants),\n );\n}\n\nfunction validDeletedMessage(value: unknown): value is RuntimeGatewayDeletedMessage {\n const message = record(value);\n return Boolean(\n typeof message?.id === \"string\" &&\n typeof message.topicId === \"string\" &&\n typeof message.authorId === \"string\" &&\n typeof message.text === \"string\" &&\n message.deleted === true &&\n typeof message.createdAt === \"string\",\n );\n}\n\nfunction validCronJob(value: unknown): value is RuntimeGatewayCronJob {\n const job = record(value);\n return Boolean(\n typeof job?.id === \"string\" &&\n typeof job.name === \"string\" &&\n typeof job.executionPrincipalUserId === \"string\" &&\n typeof job.actorOwnerUserId === \"string\" &&\n typeof job.topicId === \"string\" &&\n typeof job.schedule === \"string\" &&\n typeof job.enabled === \"boolean\" &&\n typeof job.nextRunAt === \"string\" &&\n typeof job.canMutate === \"boolean\",\n );\n}\n\nexport async function* parseRuntimeGatewaySse(\n body: ReadableStream<Uint8Array>,\n): AsyncGenerator<RuntimeGatewaySseEvent> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n let event = \"message\";\n let id: number | undefined;\n let data: string[] = [];\n const flush = (): RuntimeGatewaySseEvent | null => {\n if (data.length === 0) return null;\n const raw = data.join(\"\\n\");\n data = [];\n try {\n return { event, id, data: JSON.parse(raw) };\n } catch {\n throw new RuntimeGatewayError(\"Runtime Gateway SSE event has invalid JSON\", \"protocol\");\n } finally {\n event = \"message\";\n id = undefined;\n }\n };\n try {\n while (true) {\n const chunk = await reader.read();\n if (chunk.done) break;\n buffer += decoder.decode(chunk.value, { stream: true }).replace(/\\r\\n/g, \"\\n\");\n let newline = buffer.indexOf(\"\\n\");\n while (newline >= 0) {\n const line = buffer.slice(0, newline);\n buffer = buffer.slice(newline + 1);\n if (line === \"\") {\n const parsed = flush();\n if (parsed) yield parsed;\n } else if (line.startsWith(\"event:\")) {\n event = line.slice(6).trim() || \"message\";\n } else if (line.startsWith(\"id:\")) {\n const parsed = Number.parseInt(line.slice(3).trim(), 10);\n if (Number.isFinite(parsed)) id = parsed;\n } else if (line.startsWith(\"data:\")) {\n data.push(line.slice(5).trimStart());\n }\n newline = buffer.indexOf(\"\\n\");\n }\n }\n buffer += decoder.decode();\n if (buffer.startsWith(\"data:\")) data.push(buffer.slice(5).trimStart());\n const parsed = flush();\n if (parsed) yield parsed;\n } finally {\n reader.releaseLock();\n }\n}\n\nexport class RuntimeGatewayClient {\n private readonly pathPrefix: string;\n private readonly request: RuntimeGatewayFetch;\n private readonly requestTimeoutMs: number;\n private readonly compactTimeoutMs: number;\n\n constructor(private readonly options: RuntimeGatewayClientOptions) {\n this.pathPrefix = options.pathPrefix ?? RUNTIME_GATEWAY_CONTROL_PATH;\n this.request = options.fetch ?? fetch;\n this.requestTimeoutMs = options.requestTimeoutMs ?? 5_000;\n this.compactTimeoutMs = options.compactTimeoutMs ?? 5 * 60_000;\n }\n\n private endpoint(path: string): string {\n if (!this.options.baseUrl || !this.options.token) {\n throw new RuntimeGatewayError(\"Runtime Gateway is not configured\", \"config\");\n }\n return `${this.options.baseUrl.replace(/\\/+$/, \"\")}${this.pathPrefix}${path}`;\n }\n\n private async authorization(): Promise<string> {\n try {\n const token =\n typeof this.options.token === \"function\" ? await this.options.token() : this.options.token;\n return `Bearer ${token}`;\n } catch (error) {\n throw new RuntimeGatewayError(\n error instanceof Error ? error.message : \"Runtime Gateway token resolution failed\",\n \"config\",\n );\n }\n }\n\n private async send(path: string, init: RequestInit, timeoutMs?: number): Promise<Response> {\n const authorization = await this.authorization();\n try {\n return await this.request(this.endpoint(path), {\n ...init,\n headers: { authorization, ...init.headers },\n signal: timeoutMs === undefined ? init.signal : AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n if (error instanceof DOMException && error.name === \"TimeoutError\") {\n throw new RuntimeGatewayError(\"Runtime Gateway request timed out\", \"timeout\");\n }\n throw new RuntimeGatewayError(\"Runtime Gateway request failed\", \"transport\");\n }\n }\n\n async health(): Promise<RuntimeGatewayHealth> {\n const response = await this.send(\"/health\", { method: \"GET\" }, this.requestTimeoutMs);\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway health request failed\",\n \"http\",\n response.status,\n );\n }\n const body = await json(response);\n if (!validHealth(body)) {\n throw new RuntimeGatewayError(\"Runtime Gateway health response is incompatible\", \"protocol\");\n }\n return body;\n }\n\n async submitTurn(input: RuntimeGatewayTurnInput): Promise<RuntimeGatewayTurnAcknowledgement> {\n const response = await this.send(\n \"/turns\",\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...input }),\n },\n this.requestTimeoutMs,\n );\n if (response.status !== 202) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn was not accepted\",\n \"http\",\n response.status,\n );\n }\n const body = await json(response);\n if (!validTurnAck(body)) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn acknowledgement is incompatible\",\n \"protocol\",\n );\n }\n return body;\n }\n\n async deriveTopic(\n topicId: string,\n input: RuntimeGatewayTopicDeriveInput,\n ): Promise<RuntimeGatewayDerivedTopic> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/derive`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...input }),\n },\n this.requestTimeoutMs,\n );\n if (response.status !== 201) {\n throw new RuntimeGatewayError(\"Runtime Gateway topic derive failed\", \"http\", response.status);\n }\n const body = await json(response);\n const topic = record(body)?.topic;\n const topicRecord = record(topic);\n if (\n !topicRecord ||\n typeof topicRecord.id !== \"string\" ||\n typeof topicRecord.title !== \"string\"\n ) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway topic derive response is incompatible\",\n \"protocol\",\n );\n }\n return topic as unknown as RuntimeGatewayDerivedTopic;\n }\n\n async ensureManagerTopic(userId: string): Promise<RuntimeGatewayManagerTopic> {\n const response = await this.send(\n \"/manager-topic\",\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, userId }),\n },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway manager topic request failed\",\n \"http\",\n response.status,\n );\n }\n const body = record(await json(response));\n if (body?.ok !== true || body.v !== RUNTIME_GATEWAY_VERSION || !validManagerTopic(body.topic)) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway manager topic response is incompatible\",\n \"protocol\",\n );\n }\n return body.topic;\n }\n\n async deleteMessage(\n topicId: string,\n messageId: string,\n actorUserId: string,\n allowAdmin = false,\n ): Promise<RuntimeGatewayDeletedMessage> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/messages/${encodeURIComponent(messageId)}`,\n {\n method: \"DELETE\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n v: RUNTIME_GATEWAY_VERSION,\n actorUserId,\n ...(allowAdmin ? { allowAdmin: true } : {}),\n }),\n },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway message delete failed\",\n \"http\",\n response.status,\n );\n }\n const body = record(await json(response));\n if (\n body?.ok !== true ||\n body.v !== RUNTIME_GATEWAY_VERSION ||\n !validDeletedMessage(body.message)\n ) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway message delete response is incompatible\",\n \"protocol\",\n );\n }\n return body.message;\n }\n\n private async cronRequest(path: string, init: RequestInit): Promise<Record<string, unknown>> {\n const response = await this.send(path, init, this.requestTimeoutMs);\n if (!response.ok) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron request failed\", \"http\", response.status);\n }\n const body = record(await json(response));\n if (body?.ok !== true || body.v !== RUNTIME_GATEWAY_VERSION) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron response is incompatible\", \"protocol\");\n }\n return body;\n }\n\n async listCronScripts(): Promise<string[]> {\n const body = await this.cronRequest(\"/cron/scripts\", { method: \"GET\" });\n if (!Array.isArray(body.scripts) || !body.scripts.every((value) => typeof value === \"string\")) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron scripts are incompatible\", \"protocol\");\n }\n return body.scripts;\n }\n\n async listCronJobs(\n userId: string,\n actorUserId: string,\n actorIsAdmin = false,\n ): Promise<RuntimeGatewayCronJob[]> {\n const search = new URLSearchParams({\n user: userId,\n actorUserId,\n actorIsAdmin: actorIsAdmin ? \"1\" : \"0\",\n });\n const body = await this.cronRequest(`/cron/jobs?${search}`, { method: \"GET\" });\n if (!Array.isArray(body.jobs) || !body.jobs.every(validCronJob)) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron jobs are incompatible\", \"protocol\");\n }\n return body.jobs;\n }\n\n async createCronJob(input: RuntimeGatewayCronCreateInput): Promise<RuntimeGatewayCronJob> {\n const body = await this.cronRequest(\"/cron/jobs\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...input }),\n });\n if (!validCronJob(body.job)) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron job is incompatible\", \"protocol\");\n }\n return body.job;\n }\n\n async updateCronJob(\n jobId: string,\n userId: string,\n actorUserId: string,\n patch: RuntimeGatewayCronPatch,\n actorIsAdmin = false,\n ): Promise<RuntimeGatewayCronJob> {\n const body = await this.cronRequest(`/cron/jobs/${encodeURIComponent(jobId)}`, {\n method: \"PATCH\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n v: RUNTIME_GATEWAY_VERSION,\n userId,\n actorUserId,\n actorIsAdmin,\n patch,\n }),\n });\n if (!validCronJob(body.job)) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron job is incompatible\", \"protocol\");\n }\n return body.job;\n }\n\n async deleteCronJob(\n jobId: string,\n userId: string,\n actorUserId: string,\n actorIsAdmin = false,\n ): Promise<string> {\n const search = new URLSearchParams({\n user: userId,\n actorUserId,\n actorIsAdmin: actorIsAdmin ? \"1\" : \"0\",\n });\n const body = await this.cronRequest(`/cron/jobs/${encodeURIComponent(jobId)}?${search}`, {\n method: \"DELETE\",\n });\n if (typeof body.deleted !== \"string\") {\n throw new RuntimeGatewayError(\"Runtime Gateway cron delete is incompatible\", \"protocol\");\n }\n return body.deleted;\n }\n\n async *events(\n after: number,\n topicId?: string,\n signal?: AbortSignal,\n ): AsyncGenerator<RuntimeGatewaySseEvent> {\n const search = new URLSearchParams({ after: String(Math.max(0, after)) });\n if (topicId) search.set(\"topicId\", topicId);\n const response = await this.send(`/events?${search}`, { method: \"GET\", signal });\n if (!response.ok || !response.body) {\n throw new RuntimeGatewayError(\"Runtime Gateway event stream failed\", \"http\", response.status);\n }\n yield* parseRuntimeGatewaySse(response.body);\n }\n\n async getTopicUsage(topicId: string, userId: string): Promise<RuntimeGatewayTopicUsage> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/usage?user=${encodeURIComponent(userId)}`,\n { method: \"GET\" },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway topic usage request failed\",\n \"http\",\n response.status,\n );\n }\n const usage = record(record(await json(response))?.usage);\n const read = (key: keyof RuntimeGatewayTopicUsage): number => {\n const value = usage?.[key];\n return typeof value === \"number\" && Number.isFinite(value) ? value : 0;\n };\n return {\n queries: read(\"queries\"),\n inputTokens: read(\"inputTokens\"),\n outputTokens: read(\"outputTokens\"),\n cacheCreationInputTokens: read(\"cacheCreationInputTokens\"),\n cacheReadInputTokens: read(\"cacheReadInputTokens\"),\n estimatedCostUsd: read(\"estimatedCostUsd\"),\n };\n }\n\n async abortTurn(topicId: string, userId: string): Promise<boolean> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/abort`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, userId }),\n },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\"Runtime Gateway turn abort failed\", \"http\", response.status);\n }\n const body = record(await json(response));\n if (\n body?.ok !== true ||\n body.v !== RUNTIME_GATEWAY_VERSION ||\n typeof body.aborted !== \"boolean\"\n ) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn abort response is incompatible\",\n \"protocol\",\n );\n }\n return body.aborted;\n }\n\n async resetSession(\n topicId: string,\n userId: string,\n reason?: string,\n actorUserId?: string,\n ): Promise<string | undefined> {\n return this.sessionCommand(topicId, userId, \"reset\", reason, actorUserId);\n }\n\n async compactSession(\n topicId: string,\n userId: string,\n reason?: string,\n actorUserId?: string,\n ): Promise<string | undefined> {\n return this.sessionCommand(topicId, userId, \"compact\", reason, actorUserId);\n }\n\n private async sessionCommand(\n topicId: string,\n userId: string,\n command: \"reset\" | \"compact\",\n reason?: string,\n actorUserId?: string,\n ): Promise<string | undefined> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/session/${command}`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n v: RUNTIME_GATEWAY_VERSION,\n userId,\n ...(actorUserId ? { actorUserId } : {}),\n ...(reason ? { reason } : {}),\n }),\n },\n command === \"compact\" ? this.compactTimeoutMs : this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n `Runtime Gateway session ${command} failed`,\n \"http\",\n response.status,\n );\n }\n const body = record(await json(response));\n if (body?.ok !== true || body.v !== RUNTIME_GATEWAY_VERSION) {\n throw new RuntimeGatewayError(\n `Runtime Gateway session ${command} response is incompatible`,\n \"protocol\",\n );\n }\n return typeof body.result === \"string\" ? body.result : undefined;\n }\n}\n"
|
|
5
|
+
"import type { ActorTopicScope, RemoteSessionGrant } from \"#types\";\nimport type { AttachmentDto, MessageDto } from \"#types/api\";\n\nexport const RUNTIME_GATEWAY_VERSION = 1 as const;\nexport const RUNTIME_GATEWAY_CONTROL_PATH = \"/api/v1/control/runtime/v1\";\n\nexport type RuntimeGatewayErrorKind = \"config\" | \"timeout\" | \"transport\" | \"protocol\" | \"http\";\n\nexport class RuntimeGatewayError extends Error {\n constructor(\n message: string,\n public readonly kind: RuntimeGatewayErrorKind,\n public readonly status?: number,\n ) {\n super(message);\n }\n}\n\nexport interface RuntimeGatewayHealth {\n ok: true;\n v: typeof RUNTIME_GATEWAY_VERSION;\n nodeId?: string;\n aiName?: string;\n capabilities: string[];\n cursor: number;\n}\n\n/** Remote-only MCP transport a gateway host may grant to a manager topic. */\nexport interface HostMcpServerSpec {\n type: \"sse\" | \"http\";\n url: string;\n headers?: Record<string, string>;\n timeout?: number;\n}\n\nconst HOST_MCP_SERVER_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nconst HOST_MCP_SERVER_KEYS = new Set([\"type\", \"url\", \"headers\", \"timeout\"]);\nconst HTTP_HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/** Keep host grants remote-only so a gateway caller cannot spawn node processes. */\nexport function parseHostMcpServers(value: unknown): Record<string, HostMcpServerSpec> | undefined {\n if (value === undefined) return undefined;\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\"hostMcpServers must be an object\");\n }\n const parsedEntries: Array<[string, HostMcpServerSpec]> = [];\n for (const [name, raw] of Object.entries(value)) {\n if (!HOST_MCP_SERVER_NAME.test(name)) {\n throw new TypeError(`invalid host MCP server name: ${name}`);\n }\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n throw new TypeError(`hostMcpServers.${name} must be an object`);\n }\n const spec = raw as Record<string, unknown>;\n const unsupported = Object.keys(spec).find((key) => !HOST_MCP_SERVER_KEYS.has(key));\n if (unsupported) {\n throw new TypeError(`hostMcpServers.${name}.${unsupported} is not allowed`);\n }\n if (spec.type !== \"sse\" && spec.type !== \"http\") {\n throw new TypeError(`hostMcpServers.${name}.type must be sse or http`);\n }\n if (typeof spec.url !== \"string\") {\n throw new TypeError(`hostMcpServers.${name}.url must be a string`);\n }\n let url: URL;\n try {\n url = new URL(spec.url);\n } catch {\n throw new TypeError(`hostMcpServers.${name}.url must be a valid URL`);\n }\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n throw new TypeError(`hostMcpServers.${name}.url must use http or https`);\n }\n let headers: Record<string, string> | undefined;\n if (spec.headers !== undefined) {\n if (!spec.headers || typeof spec.headers !== \"object\" || Array.isArray(spec.headers)) {\n throw new TypeError(`hostMcpServers.${name}.headers must be an object`);\n }\n const headerEntries: Array<[string, string]> = [];\n for (const [key, headerValue] of Object.entries(spec.headers)) {\n if (!HTTP_HEADER_NAME.test(key) || typeof headerValue !== \"string\") {\n throw new TypeError(`hostMcpServers.${name}.headers must contain string values`);\n }\n try {\n new Headers([[key, headerValue]]);\n } catch {\n throw new TypeError(`hostMcpServers.${name}.headers contains an invalid header`);\n }\n headerEntries.push([key, headerValue]);\n }\n headers = Object.fromEntries(headerEntries);\n }\n if (\n spec.timeout !== undefined &&\n (typeof spec.timeout !== \"number\" || !Number.isFinite(spec.timeout) || spec.timeout <= 0)\n ) {\n throw new TypeError(`hostMcpServers.${name}.timeout must be a positive number`);\n }\n parsedEntries.push([\n name,\n {\n type: spec.type,\n url: url.toString(),\n ...(headers ? { headers } : {}),\n ...(spec.timeout !== undefined ? { timeout: spec.timeout } : {}),\n },\n ]);\n }\n return Object.fromEntries(parsedEntries);\n}\n\nexport interface RuntimeGatewayTurnInput {\n topicId: string;\n /** Canonical principal on the execution node. */\n userId: string;\n /** Product-side actor, when it differs from the execution principal. */\n actorUserId?: string;\n /**\n * The node topic ids `actorUserId` may reach on the receiving node, as the\n * host's membership store sees it. Omitted by hosts that predate it; the\n * node then confines the turn's cross-room tools to the current room.\n */\n actorTopicScope?: ActorTopicScope;\n /**\n * Hub-issued per-turn authority for remote (`node/topic`) session-comm:\n * `{ hubUrl, capability }`. `hubUrl` must be a loopback `http://` or any\n * `https://` origin (≤ 512 chars); `capability` an opaque `rsc1.` bearer\n * (≤ 2 KiB) the node presents back to the hub and cannot verify — it holds\n * no key. It does base64-decode the payload's `e` (expiry) for one purpose,\n * ordering grants when several requests fold into one turn\n * (`remoteSessionGrantExpiry`); that value is untrusted and takes part in no\n * security decision. Omitted\n * by hosts that predate it or have the feature off; the node then keeps\n * remote session-comm fail-closed on the `otium` surface. Malformed → 400.\n */\n remoteSession?: RemoteSessionGrant;\n actorLabel?: string;\n vaultUserId?: string;\n /** Adapter provenance recorded on the canonical message. */\n sourceAdapter?: string;\n text: string;\n clientMessageId: string;\n requestId?: string;\n allowAutoContinue?: boolean;\n threadRootId?: string;\n /** Inline quote-reply target. Mutually exclusive with `threadRootId`. */\n parentId?: string;\n respond?: boolean;\n /**\n * While a turn from the same person runs: `true` (default) aborts it and\n * resumes with the merged batch; `false` queues this message behind it.\n */\n steer?: boolean;\n /**\n * While a turn from the same person runs: deliver this message into it, read\n * after the step it is on, and the work goes on (Codex-style steer). Wins over\n * `steer`; when the turn cannot take it, the message is queued behind it. A\n * node too old for this ignores the field, so send `steer: false` with it.\n */\n inject?: boolean;\n /**\n * While the room works, hold this message as a follow-up instead of queuing\n * a turn (`turn-follow-ups` capability; use `holdOrSubmitTurn`). Held, it\n * is not in the transcript and can be edited, moved, deleted or sent now; the\n * node sends held follow-ups one per turn once the room is idle.\n */\n hold?: boolean;\n /** Run without adding the injected prompt or output to the visible transcript. */\n silent?: boolean;\n attachments?: string[];\n visualTools?: boolean;\n fileDeliveryTools?: boolean;\n /** Host-owned remote MCP servers granted to this manager topic. */\n hostMcpServers?: Record<string, HostMcpServerSpec>;\n}\n\nexport interface RuntimeGatewayTurnAcknowledgement {\n ok: true;\n v: typeof RUNTIME_GATEWAY_VERSION;\n accepted: true;\n deduplicated: boolean;\n requestId: string;\n clientMessageId: string;\n topicId: string;\n messageId: string;\n /** Canonical persisted message when the Node supports inline ACK materialization. */\n message?: MessageDto;\n cursor: number;\n}\n\n/** A message held while the room worked (`turn-follow-ups`). */\nexport interface RuntimeGatewayFollowUp {\n id: string;\n text: string;\n actorUserId: string;\n attachments: AttachmentDto[];\n createdAt: string;\n}\n\n/** A room's held follow-ups, oldest first, and whether they wait after a stop. */\nexport interface RuntimeGatewayFollowUpLine {\n topicId: string;\n followUps: RuntimeGatewayFollowUp[];\n paused: boolean;\n}\n\nexport interface RuntimeGatewayHeldTurn {\n ok: true;\n v: typeof RUNTIME_GATEWAY_VERSION;\n accepted: true;\n held: true;\n clientMessageId: string;\n topicId: string;\n followUp: RuntimeGatewayFollowUp;\n}\n\nexport interface RuntimeGatewayFollowUpActor {\n /** Canonical principal on the execution node. */\n userId: string;\n /** The person who sent it; only they may change it. Defaults to `userId`. */\n actorUserId?: string;\n}\n\nexport interface RuntimeGatewayTopicDeriveInput {\n userId: string;\n copyHistory: boolean;\n name?: string;\n}\n\nexport interface RuntimeGatewayDerivedTopic {\n id: string;\n title: string;\n kind?: string;\n agent?: string;\n defaultModel?: string;\n defaultEffort?: string;\n parentTopicId?: string;\n isFork?: boolean;\n}\n\nexport interface RuntimeGatewaySseEvent {\n id?: number;\n event: string;\n data: unknown;\n}\n\nexport interface RuntimeGatewayTopicUsage {\n queries: number;\n inputTokens: number;\n outputTokens: number;\n cacheCreationInputTokens: number;\n cacheReadInputTokens: number;\n estimatedCostUsd: number;\n}\n\nexport interface RuntimeGatewayManagerTopic {\n id: string;\n title: string;\n kind: \"manager\";\n agent?: \"claude\" | \"codex\" | \"maestro\";\n participants: Array<{ userId: string; role: \"owner\" | \"member\" }>;\n}\n\nexport interface RuntimeGatewayDeletedMessage {\n id: string;\n topicId: string;\n authorId: string;\n text: string;\n deleted: true;\n createdAt: string;\n}\n\nexport interface RuntimeGatewayCronJob {\n id: string;\n name: string;\n executionPrincipalUserId: string;\n actorOwnerUserId: string;\n topicId: string;\n source: \"prompt\" | \"script\";\n script: string | null;\n scriptExists: boolean;\n prompt: string | null;\n promptPreview: string | null;\n summary: string | null;\n schedule: string;\n timezone: string | null;\n enabled: boolean;\n agent: \"claude\" | \"codex\" | \"maestro\" | null;\n model: string | null;\n effort: string | null;\n nextRunAt: string;\n runCount: number;\n lastRun: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n canMutate: boolean;\n}\n\nexport interface RuntimeGatewayCronCreateInput {\n userId: string;\n actorUserId: string;\n topicId: string;\n name: string;\n script: string;\n schedule: string;\n timezone?: string;\n agent?: \"claude\" | \"codex\" | \"maestro\";\n model?: string;\n effort?: string;\n}\n\nexport interface RuntimeGatewayCronPatch {\n name?: string;\n topicId?: string;\n script?: string;\n schedule?: string;\n timezone?: string | null;\n enabled?: boolean;\n agent?: \"claude\" | \"codex\" | \"maestro\" | null;\n model?: string | null;\n effort?: string | null;\n}\n\nexport type RuntimeGatewayToken = string | (() => string | Promise<string>);\nexport type RuntimeGatewayFetch = (\n input: string | URL | Request,\n init?: RequestInit,\n) => Promise<Response>;\n\nexport interface RuntimeGatewayClientOptions {\n baseUrl: string;\n token: RuntimeGatewayToken;\n /** Loopback control path or an authenticated relay forward prefix. */\n pathPrefix?: string;\n fetch?: RuntimeGatewayFetch;\n requestTimeoutMs?: number;\n compactTimeoutMs?: number;\n}\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n}\n\nasync function json(response: Response): Promise<unknown> {\n try {\n return await response.json();\n } catch {\n throw new RuntimeGatewayError(\n \"Runtime Gateway returned invalid JSON\",\n \"protocol\",\n response.status,\n );\n }\n}\n\nfunction validHealth(value: unknown): value is RuntimeGatewayHealth {\n const body = record(value);\n return Boolean(\n body?.ok === true &&\n body.v === RUNTIME_GATEWAY_VERSION &&\n Array.isArray(body.capabilities) &&\n typeof body.cursor === \"number\",\n );\n}\n\nfunction validAcknowledgedMessage(value: unknown): value is MessageDto {\n const message = record(value);\n return Boolean(\n message &&\n typeof message.id === \"string\" &&\n typeof message.topicId === \"string\" &&\n typeof message.authorId === \"string\" &&\n typeof message.text === \"string\" &&\n typeof message.createdAt === \"string\",\n );\n}\n\nfunction validTurnAck(value: unknown): value is RuntimeGatewayTurnAcknowledgement {\n const body = record(value);\n return Boolean(\n body?.ok === true &&\n body.v === RUNTIME_GATEWAY_VERSION &&\n body.accepted === true &&\n typeof body.deduplicated === \"boolean\" &&\n typeof body.requestId === \"string\" &&\n typeof body.clientMessageId === \"string\" &&\n typeof body.topicId === \"string\" &&\n typeof body.messageId === \"string\" &&\n (body.message === undefined || validAcknowledgedMessage(body.message)) &&\n typeof body.cursor === \"number\",\n );\n}\n\nfunction validFollowUp(value: unknown): value is RuntimeGatewayFollowUp {\n const item = record(value);\n return Boolean(\n typeof item?.id === \"string\" &&\n typeof item.text === \"string\" &&\n typeof item.actorUserId === \"string\" &&\n Array.isArray(item.attachments) &&\n typeof item.createdAt === \"string\",\n );\n}\n\nfunction validFollowUpLine(value: unknown): value is RuntimeGatewayFollowUpLine {\n const body = record(value);\n return Boolean(\n typeof body?.topicId === \"string\" &&\n Array.isArray(body.followUps) &&\n body.followUps.every(validFollowUp) &&\n typeof body.paused === \"boolean\",\n );\n}\n\nfunction validHeldTurn(value: unknown): value is RuntimeGatewayHeldTurn {\n const body = record(value);\n return Boolean(\n body?.ok === true &&\n body.v === RUNTIME_GATEWAY_VERSION &&\n body.accepted === true &&\n body.held === true &&\n typeof body.clientMessageId === \"string\" &&\n typeof body.topicId === \"string\" &&\n validFollowUp(body.followUp),\n );\n}\n\nfunction validManagerTopic(value: unknown): value is RuntimeGatewayManagerTopic {\n const topic = record(value);\n return Boolean(\n typeof topic?.id === \"string\" &&\n typeof topic.title === \"string\" &&\n topic.kind === \"manager\" &&\n Array.isArray(topic.participants),\n );\n}\n\nfunction validDeletedMessage(value: unknown): value is RuntimeGatewayDeletedMessage {\n const message = record(value);\n return Boolean(\n typeof message?.id === \"string\" &&\n typeof message.topicId === \"string\" &&\n typeof message.authorId === \"string\" &&\n typeof message.text === \"string\" &&\n message.deleted === true &&\n typeof message.createdAt === \"string\",\n );\n}\n\nfunction validCronJob(value: unknown): value is RuntimeGatewayCronJob {\n const job = record(value);\n return Boolean(\n typeof job?.id === \"string\" &&\n typeof job.name === \"string\" &&\n typeof job.executionPrincipalUserId === \"string\" &&\n typeof job.actorOwnerUserId === \"string\" &&\n typeof job.topicId === \"string\" &&\n typeof job.schedule === \"string\" &&\n typeof job.enabled === \"boolean\" &&\n typeof job.nextRunAt === \"string\" &&\n typeof job.canMutate === \"boolean\",\n );\n}\n\nexport async function* parseRuntimeGatewaySse(\n body: ReadableStream<Uint8Array>,\n): AsyncGenerator<RuntimeGatewaySseEvent> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n let event = \"message\";\n let id: number | undefined;\n let data: string[] = [];\n const flush = (): RuntimeGatewaySseEvent | null => {\n if (data.length === 0) return null;\n const raw = data.join(\"\\n\");\n data = [];\n try {\n return { event, id, data: JSON.parse(raw) };\n } catch {\n throw new RuntimeGatewayError(\"Runtime Gateway SSE event has invalid JSON\", \"protocol\");\n } finally {\n event = \"message\";\n id = undefined;\n }\n };\n try {\n while (true) {\n const chunk = await reader.read();\n if (chunk.done) break;\n buffer += decoder.decode(chunk.value, { stream: true }).replace(/\\r\\n/g, \"\\n\");\n let newline = buffer.indexOf(\"\\n\");\n while (newline >= 0) {\n const line = buffer.slice(0, newline);\n buffer = buffer.slice(newline + 1);\n if (line === \"\") {\n const parsed = flush();\n if (parsed) yield parsed;\n } else if (line.startsWith(\"event:\")) {\n event = line.slice(6).trim() || \"message\";\n } else if (line.startsWith(\"id:\")) {\n const parsed = Number.parseInt(line.slice(3).trim(), 10);\n if (Number.isFinite(parsed)) id = parsed;\n } else if (line.startsWith(\"data:\")) {\n data.push(line.slice(5).trimStart());\n }\n newline = buffer.indexOf(\"\\n\");\n }\n }\n buffer += decoder.decode();\n if (buffer.startsWith(\"data:\")) data.push(buffer.slice(5).trimStart());\n const parsed = flush();\n if (parsed) yield parsed;\n } finally {\n reader.releaseLock();\n }\n}\n\nexport class RuntimeGatewayClient {\n private readonly pathPrefix: string;\n private readonly request: RuntimeGatewayFetch;\n private readonly requestTimeoutMs: number;\n private readonly compactTimeoutMs: number;\n\n constructor(private readonly options: RuntimeGatewayClientOptions) {\n this.pathPrefix = options.pathPrefix ?? RUNTIME_GATEWAY_CONTROL_PATH;\n this.request = options.fetch ?? fetch;\n this.requestTimeoutMs = options.requestTimeoutMs ?? 5_000;\n this.compactTimeoutMs = options.compactTimeoutMs ?? 5 * 60_000;\n }\n\n private endpoint(path: string): string {\n if (!this.options.baseUrl || !this.options.token) {\n throw new RuntimeGatewayError(\"Runtime Gateway is not configured\", \"config\");\n }\n return `${this.options.baseUrl.replace(/\\/+$/, \"\")}${this.pathPrefix}${path}`;\n }\n\n private async authorization(): Promise<string> {\n try {\n const token =\n typeof this.options.token === \"function\" ? await this.options.token() : this.options.token;\n return `Bearer ${token}`;\n } catch (error) {\n throw new RuntimeGatewayError(\n error instanceof Error ? error.message : \"Runtime Gateway token resolution failed\",\n \"config\",\n );\n }\n }\n\n private async send(path: string, init: RequestInit, timeoutMs?: number): Promise<Response> {\n const authorization = await this.authorization();\n try {\n return await this.request(this.endpoint(path), {\n ...init,\n headers: { authorization, ...init.headers },\n signal: timeoutMs === undefined ? init.signal : AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n if (error instanceof DOMException && error.name === \"TimeoutError\") {\n throw new RuntimeGatewayError(\"Runtime Gateway request timed out\", \"timeout\");\n }\n throw new RuntimeGatewayError(\"Runtime Gateway request failed\", \"transport\");\n }\n }\n\n async health(): Promise<RuntimeGatewayHealth> {\n const response = await this.send(\"/health\", { method: \"GET\" }, this.requestTimeoutMs);\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway health request failed\",\n \"http\",\n response.status,\n );\n }\n const body = await json(response);\n if (!validHealth(body)) {\n throw new RuntimeGatewayError(\"Runtime Gateway health response is incompatible\", \"protocol\");\n }\n return body;\n }\n\n async submitTurn(input: RuntimeGatewayTurnInput): Promise<RuntimeGatewayTurnAcknowledgement> {\n const response = await this.send(\n \"/turns\",\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...input }),\n },\n this.requestTimeoutMs,\n );\n if (response.status !== 202) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn was not accepted\",\n \"http\",\n response.status,\n );\n }\n const body = await json(response);\n if (!validTurnAck(body)) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn acknowledgement is incompatible\",\n \"protocol\",\n );\n }\n return body;\n }\n\n /**\n * `submitTurn` with `hold: true`: while the room works the node holds the\n * message as a follow-up and answers with it; otherwise it is a turn as usual.\n */\n async holdOrSubmitTurn(\n input: RuntimeGatewayTurnInput,\n ): Promise<RuntimeGatewayTurnAcknowledgement | RuntimeGatewayHeldTurn> {\n const response = await this.send(\n \"/turns\",\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...input, hold: true }),\n },\n this.requestTimeoutMs,\n );\n if (response.status !== 202) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn was not accepted\",\n \"http\",\n response.status,\n );\n }\n const body = await json(response);\n if (validHeldTurn(body) || validTurnAck(body)) return body;\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn acknowledgement is incompatible\",\n \"protocol\",\n );\n }\n\n async followUps(topicId: string, userId: string): Promise<RuntimeGatewayFollowUpLine> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/follow-ups?userId=${encodeURIComponent(userId)}`,\n { method: \"GET\" },\n this.requestTimeoutMs,\n );\n return this.followUpLineFrom(response, \"list\");\n }\n\n async editFollowUp(\n topicId: string,\n followUpId: string,\n actor: RuntimeGatewayFollowUpActor,\n text: string,\n ): Promise<RuntimeGatewayFollowUpLine> {\n return this.changeFollowUp(topicId, followUpId, \"\", \"PATCH\", { ...actor, text });\n }\n\n async deleteFollowUp(\n topicId: string,\n followUpId: string,\n actor: RuntimeGatewayFollowUpActor,\n ): Promise<RuntimeGatewayFollowUpLine> {\n return this.changeFollowUp(topicId, followUpId, \"\", \"DELETE\", { ...actor });\n }\n\n async moveFollowUp(\n topicId: string,\n followUpId: string,\n actor: RuntimeGatewayFollowUpActor,\n toIndex: number,\n ): Promise<RuntimeGatewayFollowUpLine> {\n return this.changeFollowUp(topicId, followUpId, \"/move\", \"POST\", { ...actor, toIndex });\n }\n\n /** 지금 보내기: into the running turn when it can take it, else as a turn of its own. */\n async sendFollowUpNow(\n topicId: string,\n followUpId: string,\n actor: RuntimeGatewayFollowUpActor,\n ): Promise<RuntimeGatewayFollowUpLine & { sent: boolean }> {\n const line = await this.changeFollowUp(topicId, followUpId, \"/send\", \"POST\", { ...actor });\n return line as RuntimeGatewayFollowUpLine & { sent: boolean };\n }\n\n private async changeFollowUp(\n topicId: string,\n followUpId: string,\n suffix: \"\" | \"/move\" | \"/send\",\n method: \"PATCH\" | \"DELETE\" | \"POST\",\n body: Record<string, unknown>,\n ): Promise<RuntimeGatewayFollowUpLine> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/follow-ups/${encodeURIComponent(followUpId)}${suffix}`,\n {\n method,\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...body }),\n },\n this.requestTimeoutMs,\n );\n return this.followUpLineFrom(response, method === \"PATCH\" ? \"edit\" : suffix || \"delete\");\n }\n\n private async followUpLineFrom(\n response: Response,\n what: string,\n ): Promise<RuntimeGatewayFollowUpLine> {\n if (!response.ok) {\n throw new RuntimeGatewayError(\n `Runtime Gateway follow-up ${what} failed`,\n \"http\",\n response.status,\n );\n }\n const body = await json(response);\n if (!validFollowUpLine(body)) {\n throw new RuntimeGatewayError(\n `Runtime Gateway follow-up ${what} response is incompatible`,\n \"protocol\",\n );\n }\n return body;\n }\n\n async deriveTopic(\n topicId: string,\n input: RuntimeGatewayTopicDeriveInput,\n ): Promise<RuntimeGatewayDerivedTopic> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/derive`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...input }),\n },\n this.requestTimeoutMs,\n );\n if (response.status !== 201) {\n throw new RuntimeGatewayError(\"Runtime Gateway topic derive failed\", \"http\", response.status);\n }\n const body = await json(response);\n const topic = record(body)?.topic;\n const topicRecord = record(topic);\n if (\n !topicRecord ||\n typeof topicRecord.id !== \"string\" ||\n typeof topicRecord.title !== \"string\"\n ) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway topic derive response is incompatible\",\n \"protocol\",\n );\n }\n return topic as unknown as RuntimeGatewayDerivedTopic;\n }\n\n async ensureManagerTopic(userId: string): Promise<RuntimeGatewayManagerTopic> {\n const response = await this.send(\n \"/manager-topic\",\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, userId }),\n },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway manager topic request failed\",\n \"http\",\n response.status,\n );\n }\n const body = record(await json(response));\n if (body?.ok !== true || body.v !== RUNTIME_GATEWAY_VERSION || !validManagerTopic(body.topic)) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway manager topic response is incompatible\",\n \"protocol\",\n );\n }\n return body.topic;\n }\n\n async deleteMessage(\n topicId: string,\n messageId: string,\n actorUserId: string,\n allowAdmin = false,\n ): Promise<RuntimeGatewayDeletedMessage> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/messages/${encodeURIComponent(messageId)}`,\n {\n method: \"DELETE\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n v: RUNTIME_GATEWAY_VERSION,\n actorUserId,\n ...(allowAdmin ? { allowAdmin: true } : {}),\n }),\n },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway message delete failed\",\n \"http\",\n response.status,\n );\n }\n const body = record(await json(response));\n if (\n body?.ok !== true ||\n body.v !== RUNTIME_GATEWAY_VERSION ||\n !validDeletedMessage(body.message)\n ) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway message delete response is incompatible\",\n \"protocol\",\n );\n }\n return body.message;\n }\n\n private async cronRequest(path: string, init: RequestInit): Promise<Record<string, unknown>> {\n const response = await this.send(path, init, this.requestTimeoutMs);\n if (!response.ok) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron request failed\", \"http\", response.status);\n }\n const body = record(await json(response));\n if (body?.ok !== true || body.v !== RUNTIME_GATEWAY_VERSION) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron response is incompatible\", \"protocol\");\n }\n return body;\n }\n\n async listCronScripts(): Promise<string[]> {\n const body = await this.cronRequest(\"/cron/scripts\", { method: \"GET\" });\n if (!Array.isArray(body.scripts) || !body.scripts.every((value) => typeof value === \"string\")) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron scripts are incompatible\", \"protocol\");\n }\n return body.scripts;\n }\n\n async listCronJobs(\n userId: string,\n actorUserId: string,\n actorIsAdmin = false,\n ): Promise<RuntimeGatewayCronJob[]> {\n const search = new URLSearchParams({\n user: userId,\n actorUserId,\n actorIsAdmin: actorIsAdmin ? \"1\" : \"0\",\n });\n const body = await this.cronRequest(`/cron/jobs?${search}`, { method: \"GET\" });\n if (!Array.isArray(body.jobs) || !body.jobs.every(validCronJob)) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron jobs are incompatible\", \"protocol\");\n }\n return body.jobs;\n }\n\n async createCronJob(input: RuntimeGatewayCronCreateInput): Promise<RuntimeGatewayCronJob> {\n const body = await this.cronRequest(\"/cron/jobs\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, ...input }),\n });\n if (!validCronJob(body.job)) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron job is incompatible\", \"protocol\");\n }\n return body.job;\n }\n\n async updateCronJob(\n jobId: string,\n userId: string,\n actorUserId: string,\n patch: RuntimeGatewayCronPatch,\n actorIsAdmin = false,\n ): Promise<RuntimeGatewayCronJob> {\n const body = await this.cronRequest(`/cron/jobs/${encodeURIComponent(jobId)}`, {\n method: \"PATCH\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n v: RUNTIME_GATEWAY_VERSION,\n userId,\n actorUserId,\n actorIsAdmin,\n patch,\n }),\n });\n if (!validCronJob(body.job)) {\n throw new RuntimeGatewayError(\"Runtime Gateway cron job is incompatible\", \"protocol\");\n }\n return body.job;\n }\n\n async deleteCronJob(\n jobId: string,\n userId: string,\n actorUserId: string,\n actorIsAdmin = false,\n ): Promise<string> {\n const search = new URLSearchParams({\n user: userId,\n actorUserId,\n actorIsAdmin: actorIsAdmin ? \"1\" : \"0\",\n });\n const body = await this.cronRequest(`/cron/jobs/${encodeURIComponent(jobId)}?${search}`, {\n method: \"DELETE\",\n });\n if (typeof body.deleted !== \"string\") {\n throw new RuntimeGatewayError(\"Runtime Gateway cron delete is incompatible\", \"protocol\");\n }\n return body.deleted;\n }\n\n async *events(\n after: number,\n topicId?: string,\n signal?: AbortSignal,\n ): AsyncGenerator<RuntimeGatewaySseEvent> {\n const search = new URLSearchParams({ after: String(Math.max(0, after)) });\n if (topicId) search.set(\"topicId\", topicId);\n const response = await this.send(`/events?${search}`, { method: \"GET\", signal });\n if (!response.ok || !response.body) {\n throw new RuntimeGatewayError(\"Runtime Gateway event stream failed\", \"http\", response.status);\n }\n yield* parseRuntimeGatewaySse(response.body);\n }\n\n async getTopicUsage(topicId: string, userId: string): Promise<RuntimeGatewayTopicUsage> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/usage?user=${encodeURIComponent(userId)}`,\n { method: \"GET\" },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway topic usage request failed\",\n \"http\",\n response.status,\n );\n }\n const usage = record(record(await json(response))?.usage);\n const read = (key: keyof RuntimeGatewayTopicUsage): number => {\n const value = usage?.[key];\n return typeof value === \"number\" && Number.isFinite(value) ? value : 0;\n };\n return {\n queries: read(\"queries\"),\n inputTokens: read(\"inputTokens\"),\n outputTokens: read(\"outputTokens\"),\n cacheCreationInputTokens: read(\"cacheCreationInputTokens\"),\n cacheReadInputTokens: read(\"cacheReadInputTokens\"),\n estimatedCostUsd: read(\"estimatedCostUsd\"),\n };\n }\n\n async abortTurn(topicId: string, userId: string): Promise<boolean> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/abort`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ v: RUNTIME_GATEWAY_VERSION, userId }),\n },\n this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\"Runtime Gateway turn abort failed\", \"http\", response.status);\n }\n const body = record(await json(response));\n if (\n body?.ok !== true ||\n body.v !== RUNTIME_GATEWAY_VERSION ||\n typeof body.aborted !== \"boolean\"\n ) {\n throw new RuntimeGatewayError(\n \"Runtime Gateway turn abort response is incompatible\",\n \"protocol\",\n );\n }\n return body.aborted;\n }\n\n async resetSession(\n topicId: string,\n userId: string,\n reason?: string,\n actorUserId?: string,\n ): Promise<string | undefined> {\n return this.sessionCommand(topicId, userId, \"reset\", reason, actorUserId);\n }\n\n async compactSession(\n topicId: string,\n userId: string,\n reason?: string,\n actorUserId?: string,\n ): Promise<string | undefined> {\n return this.sessionCommand(topicId, userId, \"compact\", reason, actorUserId);\n }\n\n private async sessionCommand(\n topicId: string,\n userId: string,\n command: \"reset\" | \"compact\",\n reason?: string,\n actorUserId?: string,\n ): Promise<string | undefined> {\n const response = await this.send(\n `/topics/${encodeURIComponent(topicId)}/session/${command}`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n v: RUNTIME_GATEWAY_VERSION,\n userId,\n ...(actorUserId ? { actorUserId } : {}),\n ...(reason ? { reason } : {}),\n }),\n },\n command === \"compact\" ? this.compactTimeoutMs : this.requestTimeoutMs,\n );\n if (!response.ok) {\n throw new RuntimeGatewayError(\n `Runtime Gateway session ${command} failed`,\n \"http\",\n response.status,\n );\n }\n const body = record(await json(response));\n if (body?.ok !== true || body.v !== RUNTIME_GATEWAY_VERSION) {\n throw new RuntimeGatewayError(\n `Runtime Gateway session ${command} response is incompatible`,\n \"protocol\",\n );\n }\n return typeof body.result === \"string\" ? body.result : undefined;\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;AAGO,IAAM,0BAA0B;AAChC,IAAM,+BAA+B;AAAA;AAIrC,MAAM,4BAA4B,MAAM;AAAA,EAG3B;AAAA,EACA;AAAA,EAHlB,WAAW,CACT,SACgB,MACA,QAChB;AAAA,IACA,MAAM,OAAO;AAAA,IAHG;AAAA,IACA;AAAA;AAIpB;AAmBA,IAAM,uBAAuB;AAC7B,IAAM,uBAAuB,IAAI,IAAI,CAAC,QAAQ,OAAO,WAAW,SAAS,CAAC;AAC1E,IAAM,mBAAmB;AAGlB,SAAS,mBAAmB,CAAC,OAA+D;AAAA,EACjG,IAAI,UAAU;AAAA,IA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var __require = import.meta.require;
|
|
3
|
-
|
|
4
2
|
// ../../packages/core/src/agents/deep-map.ts
|
|
5
3
|
function deepMapStrings(value, fn) {
|
|
6
4
|
if (typeof value === "string")
|
|
@@ -367,9 +365,9 @@ import {
|
|
|
367
365
|
readSync,
|
|
368
366
|
renameSync as renameSync2,
|
|
369
367
|
rmSync,
|
|
370
|
-
statSync as
|
|
368
|
+
statSync as statSync3
|
|
371
369
|
} from "fs";
|
|
372
|
-
import { join as
|
|
370
|
+
import { join as join5 } from "path";
|
|
373
371
|
|
|
374
372
|
// ../../packages/core/src/outbox/utils.ts
|
|
375
373
|
import { mkdirSync as mkdirSync2, watch } from "fs";
|
|
@@ -430,19 +428,47 @@ var watchDir = defaultWatchOps.watchDir;
|
|
|
430
428
|
import { execFileSync } from "child_process";
|
|
431
429
|
import { randomBytes } from "crypto";
|
|
432
430
|
import {
|
|
433
|
-
accessSync,
|
|
431
|
+
accessSync as accessSync2,
|
|
434
432
|
chmodSync,
|
|
435
|
-
constants,
|
|
433
|
+
constants as constants2,
|
|
436
434
|
existsSync,
|
|
437
435
|
mkdirSync as mkdirSync3,
|
|
438
436
|
readFileSync as readFileSync2,
|
|
439
437
|
writeFileSync as writeFileSync2
|
|
440
438
|
} from "fs";
|
|
441
439
|
import { createRequire } from "module";
|
|
442
|
-
import { homedir } from "os";
|
|
443
|
-
import { dirname as dirname2, join, resolve } from "path";
|
|
440
|
+
import { homedir as homedir2 } from "os";
|
|
441
|
+
import { dirname as dirname2, join as join2, resolve } from "path";
|
|
444
442
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
445
443
|
|
|
444
|
+
// ../../packages/core/src/platform/browser-backend.ts
|
|
445
|
+
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
446
|
+
import { homedir } from "os";
|
|
447
|
+
import { delimiter, isAbsolute, join } from "path";
|
|
448
|
+
function resolveBrowserBackend(value, findEgoBrowser = resolveEgoBrowserBin) {
|
|
449
|
+
const backend = value?.trim();
|
|
450
|
+
if (!backend)
|
|
451
|
+
return findEgoBrowser() ? "egolite" : "chrome";
|
|
452
|
+
if (backend === "chrome" || backend === "egolite")
|
|
453
|
+
return backend;
|
|
454
|
+
throw new Error("NEGOTIUM_BROWSER_BACKEND must be chrome or egolite");
|
|
455
|
+
}
|
|
456
|
+
function resolveEgoBrowserBin(path = process.env.PATH ?? "", home = homedir()) {
|
|
457
|
+
const names = process.platform === "win32" ? ["ego-browser.exe"] : ["ego-browser"];
|
|
458
|
+
const directories = [...path.split(delimiter).filter(isAbsolute), join(home, ".local", "bin")];
|
|
459
|
+
for (const directory of directories) {
|
|
460
|
+
for (const name of names) {
|
|
461
|
+
const candidate = join(directory, name);
|
|
462
|
+
try {
|
|
463
|
+
accessSync(candidate, constants.X_OK);
|
|
464
|
+
if (statSync2(candidate).isFile())
|
|
465
|
+
return candidate;
|
|
466
|
+
} catch {}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
|
|
446
472
|
// ../../packages/core/src/types.ts
|
|
447
473
|
var SUPPORTED_AGENTS = ["maestro", "claude", "codex"];
|
|
448
474
|
function isAgentKind(value) {
|
|
@@ -479,7 +505,7 @@ function parseRuntimePort(value, fallback) {
|
|
|
479
505
|
function envText(envKey) {
|
|
480
506
|
return readEnvText(process.env, envKey);
|
|
481
507
|
}
|
|
482
|
-
var HOME =
|
|
508
|
+
var HOME = homedir2();
|
|
483
509
|
function resolveStateDir() {
|
|
484
510
|
const configured = envText("NEGOTIUM_STATE_DIR");
|
|
485
511
|
if (false) {}
|
|
@@ -528,6 +554,7 @@ var TOPIC_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "topics");
|
|
|
528
554
|
var SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, "wiki");
|
|
529
555
|
var CRON_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "cron");
|
|
530
556
|
var BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
|
|
557
|
+
var BROWSER_BACKEND = resolveBrowserBackend(envText("NEGOTIUM_BROWSER_BACKEND"));
|
|
531
558
|
var BROWSER_PROFILES_DIR = resolve(BROWSER_DIR, "profiles");
|
|
532
559
|
var BINARIES_DIR = resolve(STATE_DIR, "binaries");
|
|
533
560
|
var SECRETS_DIR = resolve(STATE_DIR, "secrets");
|
|
@@ -575,7 +602,7 @@ function resolveBrowserRsBin(envValue) {
|
|
|
575
602
|
}
|
|
576
603
|
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
|
|
577
604
|
try {
|
|
578
|
-
|
|
605
|
+
accessSync2(candidate, constants2.X_OK);
|
|
579
606
|
return browserRsMeetsMinimumVersion(candidate) ? candidate : undefined;
|
|
580
607
|
} catch {
|
|
581
608
|
return;
|
|
@@ -588,7 +615,7 @@ function resolveBashRsBin(envValue) {
|
|
|
588
615
|
const override = envValue?.trim();
|
|
589
616
|
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "bash-rs", BASH_RS_VERSION, `bash-rs${BINARY_EXTENSION}`);
|
|
590
617
|
try {
|
|
591
|
-
|
|
618
|
+
accessSync2(candidate, constants2.X_OK);
|
|
592
619
|
return candidate;
|
|
593
620
|
} catch {
|
|
594
621
|
return;
|
|
@@ -728,8 +755,8 @@ var MAX_TELL_DEPTH = Number.isInteger(_envMaxTellDepth) && _envMaxTellDepth > 0
|
|
|
728
755
|
|
|
729
756
|
// ../../packages/core/src/storage/storage-host.ts
|
|
730
757
|
import { mkdirSync as mkdirSync4 } from "fs";
|
|
731
|
-
import { homedir as
|
|
732
|
-
import { dirname as dirname3, join as
|
|
758
|
+
import { homedir as homedir3 } from "os";
|
|
759
|
+
import { dirname as dirname3, join as join3, resolve as resolve2 } from "path";
|
|
733
760
|
|
|
734
761
|
// ../../packages/core/src/storage/sqlite.ts
|
|
735
762
|
var isBun = typeof process.versions.bun === "string";
|
|
@@ -820,13 +847,13 @@ function envPath(name, fallback) {
|
|
|
820
847
|
return resolve2(value || fallback);
|
|
821
848
|
}
|
|
822
849
|
function defaultStateDir() {
|
|
823
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
850
|
+
return envPath("NEGOTIUM_STATE_DIR", join3(homedir3(), ".negotium"));
|
|
824
851
|
}
|
|
825
852
|
function defaultDataDir() {
|
|
826
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
853
|
+
return envPath("NEGOTIUM_DATA_DIR", join3(defaultStateDir(), "data"));
|
|
827
854
|
}
|
|
828
855
|
function defaultSessionsDatabasePath() {
|
|
829
|
-
return envPath("SESSIONS_DB_PATH",
|
|
856
|
+
return envPath("SESSIONS_DB_PATH", join3(resolveStorageDataDir(), "sessions.db"));
|
|
830
857
|
}
|
|
831
858
|
var SQLITE_INIT_RETRY_MS = 25;
|
|
832
859
|
var SQLITE_INIT_TIMEOUT_MS = 5000;
|
|
@@ -1084,8 +1111,8 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
1084
1111
|
|
|
1085
1112
|
// ../../packages/core/src/storage/session-inbox-signal.ts
|
|
1086
1113
|
import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
1087
|
-
import { join as
|
|
1088
|
-
var SESSION_INBOX_WAKE_FILE =
|
|
1114
|
+
import { join as join4 } from "path";
|
|
1115
|
+
var SESSION_INBOX_WAKE_FILE = join4(SESSION_INBOX_DIR, ".wake");
|
|
1089
1116
|
var listeners = new Set;
|
|
1090
1117
|
var scheduled = null;
|
|
1091
1118
|
function deliver() {
|
|
@@ -1179,7 +1206,7 @@ function isJobResult(value) {
|
|
|
1179
1206
|
}
|
|
1180
1207
|
function readTail(filePath) {
|
|
1181
1208
|
try {
|
|
1182
|
-
const { size } =
|
|
1209
|
+
const { size } = statSync3(filePath);
|
|
1183
1210
|
const fd = openSync2(filePath, "r");
|
|
1184
1211
|
try {
|
|
1185
1212
|
const start = Math.max(0, size - TAIL_BYTES);
|
|
@@ -1194,15 +1221,15 @@ function readTail(filePath) {
|
|
|
1194
1221
|
}
|
|
1195
1222
|
}
|
|
1196
1223
|
function buildMessage(dir, result) {
|
|
1197
|
-
const stdout = readTail(
|
|
1198
|
-
const stderr = readTail(
|
|
1224
|
+
const stdout = readTail(join5(dir, "stdout.log"));
|
|
1225
|
+
const stderr = readTail(join5(dir, "stderr.log"));
|
|
1199
1226
|
const parts = [];
|
|
1200
1227
|
if (stdout.text.trim() || stdout.truncated) {
|
|
1201
|
-
parts.push(`stdout${stdout.truncated ? ` (truncated, full output: ${
|
|
1228
|
+
parts.push(`stdout${stdout.truncated ? ` (truncated, full output: ${join5(dir, "stdout.log")})` : ""}:
|
|
1202
1229
|
${stdout.text.trim()}`);
|
|
1203
1230
|
}
|
|
1204
1231
|
if (stderr.text.trim() || stderr.truncated) {
|
|
1205
|
-
parts.push(`stderr${stderr.truncated ? ` (truncated, full output: ${
|
|
1232
|
+
parts.push(`stderr${stderr.truncated ? ` (truncated, full output: ${join5(dir, "stderr.log")})` : ""}:
|
|
1206
1233
|
${stderr.text.trim()}`);
|
|
1207
1234
|
}
|
|
1208
1235
|
const header = watchHeader(result) ?? `[background_bash ${result.bash_id} finished]`;
|
|
@@ -1236,7 +1263,7 @@ function parseOwner(owner) {
|
|
|
1236
1263
|
return { userId, topicId };
|
|
1237
1264
|
}
|
|
1238
1265
|
function injectedMarker(dir) {
|
|
1239
|
-
return
|
|
1266
|
+
return join5(dir, "result.json.injected");
|
|
1240
1267
|
}
|
|
1241
1268
|
async function flushBashrsCompletions() {
|
|
1242
1269
|
let entries;
|
|
@@ -1247,11 +1274,11 @@ async function flushBashrsCompletions() {
|
|
|
1247
1274
|
}
|
|
1248
1275
|
const now = Date.now();
|
|
1249
1276
|
for (const bashId of entries) {
|
|
1250
|
-
const dir =
|
|
1251
|
-
const resultPath =
|
|
1277
|
+
const dir = join5(BASHRS_SPILL_ROOT, bashId);
|
|
1278
|
+
const resultPath = join5(dir, "result.json");
|
|
1252
1279
|
const marker = injectedMarker(dir);
|
|
1253
1280
|
try {
|
|
1254
|
-
const markerStat =
|
|
1281
|
+
const markerStat = statSync3(marker);
|
|
1255
1282
|
if (now - markerStat.mtimeMs > RETENTION_MS) {
|
|
1256
1283
|
rmSync(dir, { recursive: true, force: true });
|
|
1257
1284
|
}
|
|
@@ -1696,7 +1723,7 @@ import { realpathSync } from "fs";
|
|
|
1696
1723
|
import { resolve as resolve4 } from "path";
|
|
1697
1724
|
|
|
1698
1725
|
// ../../packages/core/src/platform/paths.ts
|
|
1699
|
-
import { dirname as dirname4, isAbsolute, relative, resolve as resolve3, sep } from "path";
|
|
1726
|
+
import { dirname as dirname4, isAbsolute as isAbsolute2, relative, resolve as resolve3, sep } from "path";
|
|
1700
1727
|
function toDisplayPath(filePath) {
|
|
1701
1728
|
return filePath.split(sep).join("/");
|
|
1702
1729
|
}
|
|
@@ -1737,58 +1764,58 @@ function topicMarkdownLink(topicId) {
|
|
|
1737
1764
|
return `[Open topic](${topicAppLink(topicId)})`;
|
|
1738
1765
|
}
|
|
1739
1766
|
export {
|
|
1740
|
-
|
|
1741
|
-
writeJsonFileAtomic,
|
|
1742
|
-
topicMarkdownLink,
|
|
1743
|
-
topicAppLink,
|
|
1744
|
-
textResult,
|
|
1745
|
-
taskPanelMessageId,
|
|
1746
|
-
startBashrsCompletionsWorker,
|
|
1747
|
-
shouldWarnForContext,
|
|
1748
|
-
setBashrsCompletionSink,
|
|
1749
|
-
sanitizeTopicName,
|
|
1750
|
-
sanitizeId,
|
|
1751
|
-
sanitizeFileName,
|
|
1752
|
-
runShutdown,
|
|
1753
|
-
renderTaskPanel,
|
|
1754
|
-
readJsonlLines,
|
|
1755
|
-
readJsonFile,
|
|
1756
|
-
parseUserIdArg,
|
|
1757
|
-
parseJsonlText,
|
|
1758
|
-
onShutdown,
|
|
1759
|
-
normalizeMermaidTheme,
|
|
1760
|
-
nextContextWarning,
|
|
1761
|
-
mermaidThemeFromHtml,
|
|
1762
|
-
mentionsAi,
|
|
1763
|
-
mcpOk,
|
|
1764
|
-
mcpError,
|
|
1765
|
-
isSensitivePath,
|
|
1766
|
-
isAgentKind,
|
|
1767
|
-
formatContextTokenCount,
|
|
1768
|
-
escapeRegExp,
|
|
1769
|
-
errorResult,
|
|
1770
|
-
errMsg,
|
|
1771
|
-
delay,
|
|
1772
|
-
deepMapStrings,
|
|
1773
|
-
createLifecycleManager,
|
|
1774
|
-
createContextWarningState,
|
|
1775
|
-
contextUsageRatio,
|
|
1776
|
-
connectStdio,
|
|
1777
|
-
clearContextWarning,
|
|
1778
|
-
claudeRequestContextTokens,
|
|
1779
|
-
buildMermaidHtml,
|
|
1780
|
-
buildContextWarningText,
|
|
1781
|
-
appendJsonlLine,
|
|
1782
|
-
appendJsonlEntry,
|
|
1783
|
-
SUPPORTED_AGENTS,
|
|
1784
|
-
MERMAID_BROWSER_VERSION,
|
|
1785
|
-
MERMAID_BROWSER_ASSET_RELATIVE_URL,
|
|
1786
|
-
MERMAID_BROWSER_ASSET_PATH,
|
|
1787
|
-
MAESTRO_EFFORT_VALUES,
|
|
1788
|
-
EFFORT_VALUES,
|
|
1789
|
-
DEFAULT_CONTEXT_WARNING_RATIO,
|
|
1767
|
+
CLAUDE_EFFORT_VALUES,
|
|
1790
1768
|
CODEX_EFFORT_VALUES,
|
|
1791
|
-
|
|
1769
|
+
DEFAULT_CONTEXT_WARNING_RATIO,
|
|
1770
|
+
EFFORT_VALUES,
|
|
1771
|
+
MAESTRO_EFFORT_VALUES,
|
|
1772
|
+
MERMAID_BROWSER_ASSET_PATH,
|
|
1773
|
+
MERMAID_BROWSER_ASSET_RELATIVE_URL,
|
|
1774
|
+
MERMAID_BROWSER_VERSION,
|
|
1775
|
+
SUPPORTED_AGENTS,
|
|
1776
|
+
appendJsonlEntry,
|
|
1777
|
+
appendJsonlLine,
|
|
1778
|
+
buildContextWarningText,
|
|
1779
|
+
buildMermaidHtml,
|
|
1780
|
+
claudeRequestContextTokens,
|
|
1781
|
+
clearContextWarning,
|
|
1782
|
+
connectStdio,
|
|
1783
|
+
contextUsageRatio,
|
|
1784
|
+
createContextWarningState,
|
|
1785
|
+
createLifecycleManager,
|
|
1786
|
+
deepMapStrings,
|
|
1787
|
+
delay,
|
|
1788
|
+
errMsg,
|
|
1789
|
+
errorResult,
|
|
1790
|
+
escapeRegExp,
|
|
1791
|
+
formatContextTokenCount,
|
|
1792
|
+
isAgentKind,
|
|
1793
|
+
isSensitivePath,
|
|
1794
|
+
mcpError,
|
|
1795
|
+
mcpOk,
|
|
1796
|
+
mentionsAi,
|
|
1797
|
+
mermaidThemeFromHtml,
|
|
1798
|
+
nextContextWarning,
|
|
1799
|
+
normalizeMermaidTheme,
|
|
1800
|
+
onShutdown,
|
|
1801
|
+
parseJsonlText,
|
|
1802
|
+
parseUserIdArg,
|
|
1803
|
+
readJsonFile,
|
|
1804
|
+
readJsonlLines,
|
|
1805
|
+
renderTaskPanel,
|
|
1806
|
+
runShutdown,
|
|
1807
|
+
sanitizeFileName,
|
|
1808
|
+
sanitizeId,
|
|
1809
|
+
sanitizeTopicName,
|
|
1810
|
+
setBashrsCompletionSink,
|
|
1811
|
+
shouldWarnForContext,
|
|
1812
|
+
startBashrsCompletionsWorker,
|
|
1813
|
+
taskPanelMessageId,
|
|
1814
|
+
textResult,
|
|
1815
|
+
topicAppLink,
|
|
1816
|
+
topicMarkdownLink,
|
|
1817
|
+
writeJsonFileAtomic,
|
|
1818
|
+
writeJsonlFile
|
|
1792
1819
|
};
|
|
1793
1820
|
|
|
1794
|
-
//# debugId=
|
|
1821
|
+
//# debugId=54A225805CC28D1964756E2164756E21
|