@xopcai/xopc 0.0.129 → 0.0.131
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/dist/browser-ext/icons/icon-128.png +0 -0
- package/dist/browser-ext/icons/icon-16.png +0 -0
- package/dist/browser-ext/icons/icon-32.png +0 -0
- package/dist/browser-ext/icons/icon-48.png +0 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/apple-touch-icon.png +0 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DHzfg5D-.js → agent-avatar-dicebear-BJYeTxQ9.js} +1 -1
- package/dist/gateway/static/root/assets/agents-kVsY4Iz_.js +2 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-Bj8iJ-7d.js +1 -0
- package/dist/gateway/static/root/assets/{appearance-settings-bYeEj3IW.js → appearance-settings-6TjISbHB.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DC4YwXLL.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Dy6lsTHw.js → archive-plugin-2G62raBg.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-qOtBYR6Y.js → attachment-load-kLNJMEJh.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BFH-RfaV.js → automation-suggestion-card-CpcZSSD8.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-MZ8m4bYP.js +4 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DJvi_thc.js → binary-plugins-C_zSrWow.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DlMnizlt.js → block-editor-D_PMrT-l.js} +4 -4
- package/dist/gateway/static/root/assets/browser-settings-page-C89wKfPd.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-CPFtajl7.js +1 -0
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Dng8Grpv.js → capability-presets-settings-panel-DWw31-4v.js} +1 -1
- package/dist/gateway/static/root/assets/channel-recipient-api-BUi8syv2.js +1 -0
- package/dist/gateway/static/root/assets/channels-settings-DOYzcMAE.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-DCE-PgQF.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-BYV16wez.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-B-u63N4e.js → desktop-pet-settings-DGIaFqPR.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-8p1ehIHn.js → directory-picker-path-field-BEhDuShd.js} +1 -1
- package/dist/gateway/static/root/assets/dreaming-settings-BIkgLFDH.js +3 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DJ1ABK95.js → extension-debug-page-BIjLZMAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CP9P2lGM.js → extension-page-Cxv4Bgj5.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-DNd0tRFl.js +1 -0
- package/dist/gateway/static/root/assets/fetch-Bl7zMnmd.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-BiqKIkkp.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-D_Cvasqi.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CY5W2Pp4.js → gateway-startup-retry-CPOgTcpv.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-2lPbGfp3.js → goal-create-dialog-DZ68qzpm.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DF8QhTHH.js +4 -0
- package/dist/gateway/static/root/assets/goals-config-api-h26_-2Vm.js +1 -0
- package/dist/gateway/static/root/assets/goals-page-BzBKHZJg.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-BFG1uTI8.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-5vV8vTva.js +1 -0
- package/dist/gateway/static/root/assets/index-DOetFpTt.js +262 -0
- package/dist/gateway/static/root/assets/index-W4ogAiHt.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BrENZzM7.js → keyboard-shortcuts-settings-Dpx1ovO6.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-3QO3elfx.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-BYF4ReGM.js → markdown-split-Ba4EsPkV.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CpQDz-QJ.js → media-plugins-lA5rvtCq.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-YzjnURPJ.js → messages-Bq4REfIj.js} +2 -2
- package/dist/gateway/static/root/assets/models-hub-panel-BBG87CHZ.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-DrUGE-Hn.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-eAIE8iKV.js +2 -0
- package/dist/gateway/static/root/assets/{page-tabs-RnYYOIWO.js → page-tabs-Cy7bX7Ce.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CTRt06Ri.js → preview-open-alternatives-B9_iql49.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Cwct6pCV.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BXZlzV8t.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-C29EWM0P.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-c4pZeikq.js → save-bar-controls-nMloZ0mp.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-Cb6R7iuP.js → schedule-field-BuajpVNF.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BqET_hEP.js → schema-form-IeXV_yQk.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DHHVDqsy.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-hDvmobsT.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-DuOvqNsI.js → settings-collapsible-section-ByixWwvu.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DptSsbWd.js → settings-form-section-C-5-n-jM.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BlVfBCb9.js → settings-loading-skeleton-CTA5Gje4.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-DzqxeemF.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-DVt69dJJ.js → settings-page-layout-DgFTf6nM.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-svpHcJ62.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-IOjU69FC.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-Ddg8gHPN.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DcNOEJsK.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DoonnYRs.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CW22OkZ4.js → system-settings-panel-BMDD7FXg.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BqpGAKxV.js → typed-models-lib-DayamJ56.js} +1 -1
- package/dist/gateway/static/root/assets/use-channel-catalog-ChYwFiqo.js +1 -0
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-CERVLuaW.js → user-profile-settings-panel-Dd0X3mPv.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-BnmysurA.js → utils-D9v9ZpK4.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-QXGvjTwa.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CP-5OUYI.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Ci9GSPnS.js → workflow-run-setup-panel-IidqhbUI.js} +2 -2
- package/dist/gateway/static/root/assets/{workflow-start-dialog-BhDj8pqH.js → workflow-start-dialog-BQQkr8YD.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-DtVIjVSX.js +18 -0
- package/dist/gateway/static/root/favicon-16x16.png +0 -0
- package/dist/gateway/static/root/favicon-32x32.png +0 -0
- package/dist/gateway/static/root/favicon-icon.svg +23 -1
- package/dist/gateway/static/root/favicon.ico +0 -0
- package/dist/gateway/static/root/favicon.png +0 -0
- package/dist/gateway/static/root/favicon.svg +20 -24
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/gateway/static/root/logo-dark.svg +18 -23
- package/dist/gateway/static/root/logo.svg +18 -24
- package/dist/gateway/static/root/pwa-192x192.png +0 -0
- package/dist/gateway/static/root/pwa-512x512.png +0 -0
- package/dist/gateway/static/root/site.webmanifest +23 -0
- package/dist/package.js +1 -1
- package/dist/src/cli/commands/gateway/probe.js +6 -6
- package/dist/src/cli/commands/gateway/probe.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +2 -2
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/cli/commands/tui.js +11 -4
- package/dist/src/cli/commands/tui.js.map +1 -1
- package/dist/src/cli/utils/gateway-client-options.d.ts +3 -0
- package/dist/src/cli/utils/gateway-client-options.js +2 -1
- package/dist/src/cli/utils/gateway-client-options.js.map +1 -1
- package/dist/src/cli/utils/gateway-client.d.ts +6 -3
- package/dist/src/cli/utils/gateway-client.js +14 -8
- package/dist/src/cli/utils/gateway-client.js.map +1 -1
- package/dist/src/gateway/credential.d.ts +9 -0
- package/dist/src/gateway/credential.js +16 -0
- package/dist/src/gateway/credential.js.map +1 -0
- package/dist/src/gateway/hono/app.d.ts +0 -1
- package/dist/src/gateway/hono/app.js +2 -9
- package/dist/src/gateway/hono/app.js.map +1 -1
- package/dist/src/gateway/hono/middleware/auth.d.ts +0 -2
- package/dist/src/gateway/hono/middleware/auth.js +46 -21
- package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +2 -27
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/server.js +1 -5
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/mcp/channel-bridge.d.ts +2 -1
- package/dist/src/mcp/channel-bridge.js +10 -6
- package/dist/src/mcp/channel-bridge.js.map +1 -1
- package/dist/src/mcp/channel-server.d.ts +2 -1
- package/dist/src/mcp/channel-server.js +1 -1
- package/dist/src/mcp/channel-server.js.map +1 -1
- package/dist/src/mcp/gateway-http-client.d.ts +3 -2
- package/dist/src/mcp/gateway-http-client.js +9 -7
- package/dist/src/mcp/gateway-http-client.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +3 -2
- package/dist/src/tui/backends/gateway-sse-backend.js +45 -41
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/tui-types.d.ts +3 -2
- package/dist/src/tui/tui-types.js.map +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/tui/tui.js.map +1 -1
- package/package.json +5 -2
- package/dist/gateway/static/root/assets/agents-CMxKKFQD.js +0 -2
- package/dist/gateway/static/root/assets/app-management-settings-panel-ptk9c5BN.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-DdZvDf5B.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-B8JTjkCr.js +0 -4
- package/dist/gateway/static/root/assets/browser-settings-page-slHLiZgi.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-D4q7vHVJ.js +0 -1
- package/dist/gateway/static/root/assets/channel-recipient-api-BrW5Kcgc.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-KIsISXw0.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-C5fx4Qs9.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-Jmdn6q47.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-CCkKP-I4.js +0 -3
- package/dist/gateway/static/root/assets/extension-settings-page-DnhU-tx0.js +0 -1
- package/dist/gateway/static/root/assets/fetch-BMjlW0g1.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-CjxDn46s.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-TING7224.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DHWVRafk.js +0 -4
- package/dist/gateway/static/root/assets/goals-config-api-BqhuxG8P.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-CMk-9ZYN.js +0 -2
- package/dist/gateway/static/root/assets/goals-settings-BHzOAU_l.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-BQIm0P3V.js +0 -1
- package/dist/gateway/static/root/assets/index-C4k6QSXw.js +0 -257
- package/dist/gateway/static/root/assets/index-EKmpPvZj.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-BiL302Ve.js +0 -2
- package/dist/gateway/static/root/assets/models-hub-panel-CFPpl3Cq.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-BurgcdVZ.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-BAELRM_O.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-iXX1Ceo2.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-GDVTFAY7.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUrbUnwv.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CiOreA2k.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-xQx2Pkg5.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DWB8VdLK.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-8m_ACH0z.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-CgxfhNxI.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BBFUOxmf.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-bo695odu.js +0 -2
- package/dist/gateway/static/root/assets/url-DFGNSBNT.js +0 -1
- package/dist/gateway/static/root/assets/use-channel-catalog-CPdJ0o0i.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-Jr3jvPcB.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-B-8rex4u.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-Brb3UGvs.js +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-http-client.js","names":["undiciFetch"],"sources":["../../../src/mcp/gateway-http-client.ts"],"sourcesContent":["import { fetch as undiciFetch } from 'undici';\nimport { resolveGatewayLocalClientHost } from '../config/gateway-bind.js';\nimport type { Config } from '../config/schema.js';\nimport { loadConfig } from '../config/loader.js';\nimport { createLogger } from '../utils/logger.js';\n\nconst log = createLogger('Mcp:GatewayClient');\n\nfunction
|
|
1
|
+
{"version":3,"file":"gateway-http-client.js","names":["undiciFetch"],"sources":["../../../src/mcp/gateway-http-client.ts"],"sourcesContent":["import { fetch as undiciFetch } from 'undici';\nimport { resolveGatewayLocalClientHost } from '../config/gateway-bind.js';\nimport type { Config } from '../config/schema.js';\nimport { loadConfig } from '../config/loader.js';\nimport {\n createGatewayCredential,\n gatewayCredentialAuthorization,\n type GatewayCredential,\n} from '../gateway/credential.js';\nimport { createLogger } from '../utils/logger.js';\n\nconst log = createLogger('Mcp:GatewayClient');\n\nfunction resolveGatewayCredentialFromConfig(cfg: Config): GatewayCredential | undefined {\n const auth = cfg.gateway?.auth;\n if (auth?.mode === 'password') {\n return createGatewayCredential('password', auth.password);\n }\n if (auth?.mode === 'token') {\n return createGatewayCredential('token', auth.token ?? process.env.XOPC_GATEWAY_TOKEN);\n }\n return undefined;\n}\n\nexport type GatewayHttpClientOptions = {\n baseUrl: string;\n credential?: GatewayCredential;\n};\n\nexport class GatewayHttpClient {\n constructor(private readonly opts: GatewayHttpClientOptions) {}\n\n private headers(extra?: Record<string, string>): Record<string, string> {\n const h: Record<string, string> = { Accept: 'application/json', ...extra };\n const authorization = gatewayCredentialAuthorization(this.opts.credential);\n if (authorization) {\n h.Authorization = authorization;\n }\n return h;\n }\n\n async getJson<T>(path: string): Promise<T> {\n const res = await undiciFetch(`${this.opts.baseUrl}${path}`, {\n headers: this.headers(),\n });\n if (!res.ok) {\n const em = `Gateway GET ${path} failed: ${res.status}`;\n log.warn({ phase: 'mcp.gateway.http', method: 'GET', path, status: res.status }, em);\n throw new Error(em);\n }\n const body = (await res.json()) as { ok?: boolean; payload?: T } | T;\n if (body && typeof body === 'object' && 'payload' in body) {\n return (body as { payload: T }).payload;\n }\n return body as T;\n }\n\n async postJson<T>(path: string, data: unknown): Promise<T> {\n const res = await undiciFetch(`${this.opts.baseUrl}${path}`, {\n method: 'POST',\n headers: this.headers({ 'Content-Type': 'application/json' }),\n body: JSON.stringify(data),\n });\n if (!res.ok) {\n const em = `Gateway POST ${path} failed: ${res.status}`;\n log.warn({ phase: 'mcp.gateway.http', method: 'POST', path, status: res.status }, em);\n throw new Error(em);\n }\n const body = (await res.json()) as { ok?: boolean; payload?: T } | T;\n if (body && typeof body === 'object' && 'payload' in body) {\n return (body as { payload: T }).payload;\n }\n return body as T;\n }\n}\n\nexport function resolveGatewayHttpBaseUrl(config: Config, override?: string): string {\n if (override?.trim()) {\n return override.replace(/\\/$/, '');\n }\n const host = resolveGatewayLocalClientHost(config);\n const port = config.gateway?.port ?? 18790;\n return `http://${host}:${port}`;\n}\n\nexport function createGatewayHttpClientFromConfig(params: {\n config?: Config;\n gatewayUrl?: string;\n gatewayCredential?: GatewayCredential;\n}): GatewayHttpClient {\n const cfg = params.config ?? loadConfig();\n const credential = params.gatewayCredential ?? resolveGatewayCredentialFromConfig(cfg);\n return new GatewayHttpClient({\n baseUrl: resolveGatewayHttpBaseUrl(cfg, params.gatewayUrl),\n credential,\n });\n}\n"],"mappings":";;;;;;;aAGiD;aAMC;AAElD,MAAM,MAAM,aAAa,oBAAoB;AAE7C,SAAS,mCAAmC,KAA4C;CACtF,MAAM,OAAO,IAAI,SAAS;AAC1B,KAAI,MAAM,SAAS,WACjB,QAAO,wBAAwB,YAAY,KAAK,SAAS;AAE3D,KAAI,MAAM,SAAS,QACjB,QAAO,wBAAwB,SAAS,KAAK,SAAS,QAAQ,IAAI,mBAAmB;;AAUzF,IAAa,oBAAb,MAA+B;CAC7B,YAAY,MAAiD;AAAhC,OAAA,OAAA;;CAE7B,QAAgB,OAAwD;EACtE,MAAM,IAA4B;GAAE,QAAQ;GAAoB,GAAG;GAAO;EAC1E,MAAM,gBAAgB,+BAA+B,KAAK,KAAK,WAAW;AAC1E,MAAI,cACF,GAAE,gBAAgB;AAEpB,SAAO;;CAGT,MAAM,QAAW,MAA0B;EACzC,MAAM,MAAM,MAAMA,MAAY,GAAG,KAAK,KAAK,UAAU,QAAQ,EAC3D,SAAS,KAAK,SAAS,EACxB,CAAC;AACF,MAAI,CAAC,IAAI,IAAI;GACX,MAAM,KAAK,eAAe,KAAK,WAAW,IAAI;AAC9C,OAAI,KAAK;IAAE,OAAO;IAAoB,QAAQ;IAAO;IAAM,QAAQ,IAAI;IAAQ,EAAE,GAAG;AACpF,SAAM,IAAI,MAAM,GAAG;;EAErB,MAAM,OAAQ,MAAM,IAAI,MAAM;AAC9B,MAAI,QAAQ,OAAO,SAAS,YAAY,aAAa,KACnD,QAAQ,KAAwB;AAElC,SAAO;;CAGT,MAAM,SAAY,MAAc,MAA2B;EACzD,MAAM,MAAM,MAAMA,MAAY,GAAG,KAAK,KAAK,UAAU,QAAQ;GAC3D,QAAQ;GACR,SAAS,KAAK,QAAQ,EAAE,gBAAgB,oBAAoB,CAAC;GAC7D,MAAM,KAAK,UAAU,KAAK;GAC3B,CAAC;AACF,MAAI,CAAC,IAAI,IAAI;GACX,MAAM,KAAK,gBAAgB,KAAK,WAAW,IAAI;AAC/C,OAAI,KAAK;IAAE,OAAO;IAAoB,QAAQ;IAAQ;IAAM,QAAQ,IAAI;IAAQ,EAAE,GAAG;AACrF,SAAM,IAAI,MAAM,GAAG;;EAErB,MAAM,OAAQ,MAAM,IAAI,MAAM;AAC9B,MAAI,QAAQ,OAAO,SAAS,YAAY,aAAa,KACnD,QAAQ,KAAwB;AAElC,SAAO;;;AAIX,SAAgB,0BAA0B,QAAgB,UAA2B;AACnF,KAAI,UAAU,MAAM,CAClB,QAAO,SAAS,QAAQ,OAAO,GAAG;AAIpC,QAAO,UAFM,8BAA8B,OAEtB,CAAC,GADT,OAAO,SAAS,QAAQ;;AAIvC,SAAgB,kCAAkC,QAI5B;CACpB,MAAM,MAAM,OAAO,UAAU,YAAY;CACzC,MAAM,aAAa,OAAO,qBAAqB,mCAAmC,IAAI;AACtF,QAAO,IAAI,kBAAkB;EAC3B,SAAS,0BAA0B,KAAK,OAAO,WAAW;EAC1D;EACD,CAAC"}
|
|
@@ -3,9 +3,10 @@ import type { SessionTimelineItem } from '../../session/transcript-outline.js';
|
|
|
3
3
|
import type { ChatSendOptions, HistoryMessage, TuiBackend, TuiCompactionResult, TuiEvent, TuiModelChoice, TuiShareRequest, TuiShareResult, TuiSessionStats, TuiSessionItem, TuiStartupResources, TuiTranscriptTreeEntry, TuiAgentInfo, TuiWorkspaceFileSearchEntry, TuiWorkflowRunStartRequest, TuiWorkflowRunStartResult, TuiStartupProjectResult } from '../tui-backend.js';
|
|
4
4
|
import type { SessionInfo } from '../tui-types.js';
|
|
5
5
|
import type { ReviewContext } from '../../review/review-git.js';
|
|
6
|
+
import { type GatewayCredential } from '../../gateway/credential.js';
|
|
6
7
|
interface GatewaySSEOptions {
|
|
7
8
|
url: string;
|
|
8
|
-
|
|
9
|
+
credential?: GatewayCredential;
|
|
9
10
|
}
|
|
10
11
|
export declare function normalizeGatewaySseEvent(evt: TuiEvent): TuiEvent;
|
|
11
12
|
/**
|
|
@@ -17,7 +18,7 @@ export declare function normalizeGatewaySseEvent(evt: TuiEvent): TuiEvent;
|
|
|
17
18
|
*/
|
|
18
19
|
export declare class GatewaySseBackend implements TuiBackend {
|
|
19
20
|
private readonly baseUrl;
|
|
20
|
-
private readonly
|
|
21
|
+
private readonly credential;
|
|
21
22
|
private eventAbort;
|
|
22
23
|
private chatAbort;
|
|
23
24
|
onEvent?: (evt: TuiEvent) => void;
|
|
@@ -3,6 +3,7 @@ import { init_logger } from "../../utils/logger.js";
|
|
|
3
3
|
import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
|
|
4
4
|
import { transcriptRowsToClientHistory } from "../../session/client-history.js";
|
|
5
5
|
import { parseModelRef } from "../../agent/models/selection.js";
|
|
6
|
+
import { gatewayCredentialAuthorization } from "../../gateway/credential.js";
|
|
6
7
|
import { consumeSSEStream, parseSSEData } from "../sse-consumer.js";
|
|
7
8
|
import { buildTuiTranscriptTree, transcriptTreeEntryIdToRowNumber } from "../tui-transcript-tree.js";
|
|
8
9
|
import { computeTuiSessionStats } from "../tui-session-stats.js";
|
|
@@ -31,10 +32,11 @@ function normalizeGatewaySseEvent(evt) {
|
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
/** Fetch wrapper that adds auth headers. */
|
|
34
|
-
async function gatewayFetch(baseUrl, path,
|
|
35
|
+
async function gatewayFetch(baseUrl, path, credential, init) {
|
|
36
|
+
const authorization = gatewayCredentialAuthorization(credential);
|
|
35
37
|
const headers = {
|
|
36
38
|
"Content-Type": "application/json",
|
|
37
|
-
...
|
|
39
|
+
...authorization ? { Authorization: authorization } : {},
|
|
38
40
|
...init?.headers
|
|
39
41
|
};
|
|
40
42
|
return fetch(`${baseUrl}${path}`, {
|
|
@@ -51,7 +53,7 @@ async function gatewayFetch(baseUrl, path, token, init) {
|
|
|
51
53
|
*/
|
|
52
54
|
var GatewaySseBackend = class {
|
|
53
55
|
baseUrl;
|
|
54
|
-
|
|
56
|
+
credential;
|
|
55
57
|
eventAbort = null;
|
|
56
58
|
chatAbort = null;
|
|
57
59
|
onEvent;
|
|
@@ -60,7 +62,7 @@ var GatewaySseBackend = class {
|
|
|
60
62
|
onGap;
|
|
61
63
|
constructor(opts) {
|
|
62
64
|
this.baseUrl = opts.url.replace(/\/+$/, "");
|
|
63
|
-
this.
|
|
65
|
+
this.credential = opts.credential;
|
|
64
66
|
}
|
|
65
67
|
get connectionLabel() {
|
|
66
68
|
return this.baseUrl;
|
|
@@ -85,7 +87,7 @@ var GatewaySseBackend = class {
|
|
|
85
87
|
const runId = crypto.randomUUID();
|
|
86
88
|
(async () => {
|
|
87
89
|
try {
|
|
88
|
-
const res = await gatewayFetch(this.baseUrl, "/api/agent", this.
|
|
90
|
+
const res = await gatewayFetch(this.baseUrl, "/api/agent", this.credential, {
|
|
89
91
|
method: "POST",
|
|
90
92
|
headers: { Accept: "text/event-stream" },
|
|
91
93
|
body: JSON.stringify({
|
|
@@ -211,7 +213,7 @@ var GatewaySseBackend = class {
|
|
|
211
213
|
params.set("q", query);
|
|
212
214
|
params.set("limit", String(options?.limit ?? 15));
|
|
213
215
|
params.set("sessionKey", sessionKey);
|
|
214
|
-
const res = await gatewayFetch(this.baseUrl, `/api/workspace/editor/files/search?${params.toString()}`, this.
|
|
216
|
+
const res = await gatewayFetch(this.baseUrl, `/api/workspace/editor/files/search?${params.toString()}`, this.credential);
|
|
215
217
|
if (!res.ok) return [];
|
|
216
218
|
return (await res.json()).payload?.entries ?? [];
|
|
217
219
|
} catch (err) {
|
|
@@ -226,14 +228,14 @@ var GatewaySseBackend = class {
|
|
|
226
228
|
}
|
|
227
229
|
async getReviewContext(sessionKey) {
|
|
228
230
|
const params = new URLSearchParams({ sessionKey });
|
|
229
|
-
const res = await gatewayFetch(this.baseUrl, `/api/review/context?${params.toString()}`, this.
|
|
231
|
+
const res = await gatewayFetch(this.baseUrl, `/api/review/context?${params.toString()}`, this.credential);
|
|
230
232
|
const json = await res.json().catch(() => ({}));
|
|
231
233
|
if (!res.ok || !json.ok || !json.payload) throw new Error(json.error?.message ?? `Review context failed (${res.status})`);
|
|
232
234
|
return json.payload;
|
|
233
235
|
}
|
|
234
236
|
async startWorkflowRun(opts) {
|
|
235
237
|
const goal = opts.goal?.trim();
|
|
236
|
-
const res = await gatewayFetch(this.baseUrl, "/api/workflows/runs", this.
|
|
238
|
+
const res = await gatewayFetch(this.baseUrl, "/api/workflows/runs", this.credential, {
|
|
237
239
|
method: "POST",
|
|
238
240
|
body: JSON.stringify({
|
|
239
241
|
definitionId: opts.definitionId,
|
|
@@ -256,7 +258,7 @@ var GatewaySseBackend = class {
|
|
|
256
258
|
};
|
|
257
259
|
}
|
|
258
260
|
async resolveStartupProject(opts) {
|
|
259
|
-
const res = await gatewayFetch(this.baseUrl, "/api/projects/resolve-workspace", this.
|
|
261
|
+
const res = await gatewayFetch(this.baseUrl, "/api/projects/resolve-workspace", this.credential, {
|
|
260
262
|
method: "POST",
|
|
261
263
|
body: JSON.stringify(opts)
|
|
262
264
|
});
|
|
@@ -285,7 +287,7 @@ var GatewaySseBackend = class {
|
|
|
285
287
|
});
|
|
286
288
|
let res;
|
|
287
289
|
try {
|
|
288
|
-
res = await gatewayFetch(this.baseUrl, "/api/agent/resume", this.
|
|
290
|
+
res = await gatewayFetch(this.baseUrl, "/api/agent/resume", this.credential, {
|
|
289
291
|
method: "POST",
|
|
290
292
|
headers: { Accept: "text/event-stream" },
|
|
291
293
|
body: JSON.stringify({
|
|
@@ -349,7 +351,7 @@ var GatewaySseBackend = class {
|
|
|
349
351
|
this.chatAbort?.abort();
|
|
350
352
|
this.chatAbort = null;
|
|
351
353
|
try {
|
|
352
|
-
return { ok: (await (await gatewayFetch(this.baseUrl, "/api/agent/abort", this.
|
|
354
|
+
return { ok: (await (await gatewayFetch(this.baseUrl, "/api/agent/abort", this.credential, {
|
|
353
355
|
method: "POST",
|
|
354
356
|
body: JSON.stringify({ runId: opts.runId })
|
|
355
357
|
})).json()).ok ?? false };
|
|
@@ -359,7 +361,7 @@ var GatewaySseBackend = class {
|
|
|
359
361
|
}
|
|
360
362
|
async steerChat(opts) {
|
|
361
363
|
try {
|
|
362
|
-
const res = await gatewayFetch(this.baseUrl, "/api/agent/steer", this.
|
|
364
|
+
const res = await gatewayFetch(this.baseUrl, "/api/agent/steer", this.credential, {
|
|
363
365
|
method: "POST",
|
|
364
366
|
body: JSON.stringify({
|
|
365
367
|
sessionKey: opts.sessionKey,
|
|
@@ -380,7 +382,7 @@ var GatewaySseBackend = class {
|
|
|
380
382
|
connectors: []
|
|
381
383
|
};
|
|
382
384
|
try {
|
|
383
|
-
const res = await gatewayFetch(this.baseUrl, `/api/tui/startup-resources?sessionKey=${encodeURIComponent(sessionKey)}`, this.
|
|
385
|
+
const res = await gatewayFetch(this.baseUrl, `/api/tui/startup-resources?sessionKey=${encodeURIComponent(sessionKey)}`, this.credential);
|
|
384
386
|
if (!res.ok) return empty;
|
|
385
387
|
const json = await res.json();
|
|
386
388
|
return {
|
|
@@ -401,7 +403,7 @@ var GatewaySseBackend = class {
|
|
|
401
403
|
}
|
|
402
404
|
async loadHistory(opts) {
|
|
403
405
|
try {
|
|
404
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(opts.sessionKey)}?include=transcriptRows`, this.
|
|
406
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(opts.sessionKey)}?include=transcriptRows`, this.credential);
|
|
405
407
|
if (!res.ok) return { messages: [] };
|
|
406
408
|
const json = await res.json();
|
|
407
409
|
return { messages: transcriptRowsToClientHistory(Array.isArray(json.session?.transcriptRows) ? json.session.transcriptRows : [], { limit: opts.limit }) };
|
|
@@ -421,7 +423,7 @@ var GatewaySseBackend = class {
|
|
|
421
423
|
after: String(opts.after ?? 120)
|
|
422
424
|
});
|
|
423
425
|
try {
|
|
424
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(opts.sessionKey)}/transcript/window?${params.toString()}`, this.
|
|
426
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(opts.sessionKey)}/transcript/window?${params.toString()}`, this.credential);
|
|
425
427
|
if (!res.ok) return {
|
|
426
428
|
messages: [],
|
|
427
429
|
startRowNumber: 0,
|
|
@@ -453,7 +455,7 @@ var GatewaySseBackend = class {
|
|
|
453
455
|
}
|
|
454
456
|
async loadTranscriptTree(sessionKey) {
|
|
455
457
|
try {
|
|
456
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}?include=transcriptRows`, this.
|
|
458
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}?include=transcriptRows`, this.credential);
|
|
457
459
|
if (!res.ok) return [];
|
|
458
460
|
const json = await res.json();
|
|
459
461
|
return buildTuiTranscriptTree(Array.isArray(json.session?.transcriptRows) ? json.session.transcriptRows : []);
|
|
@@ -469,7 +471,7 @@ var GatewaySseBackend = class {
|
|
|
469
471
|
}
|
|
470
472
|
async loadTimeline(sessionKey) {
|
|
471
473
|
try {
|
|
472
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/timeline`, this.
|
|
474
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/timeline`, this.credential);
|
|
473
475
|
if (!res.ok) return [];
|
|
474
476
|
const json = await res.json();
|
|
475
477
|
return Array.isArray(json.items) ? json.items : [];
|
|
@@ -485,7 +487,7 @@ var GatewaySseBackend = class {
|
|
|
485
487
|
}
|
|
486
488
|
async getSessionStats(sessionKey) {
|
|
487
489
|
try {
|
|
488
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}?include=transcriptRows`, this.
|
|
490
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}?include=transcriptRows`, this.credential);
|
|
489
491
|
if (!res.ok) return computeTuiSessionStats([]);
|
|
490
492
|
const json = await res.json();
|
|
491
493
|
return computeTuiSessionStats(Array.isArray(json.session?.transcriptRows) ? json.session.transcriptRows : []);
|
|
@@ -501,7 +503,7 @@ var GatewaySseBackend = class {
|
|
|
501
503
|
}
|
|
502
504
|
async listSessions() {
|
|
503
505
|
try {
|
|
504
|
-
const res = await gatewayFetch(this.baseUrl, "/api/sessions", this.
|
|
506
|
+
const res = await gatewayFetch(this.baseUrl, "/api/sessions", this.credential);
|
|
505
507
|
if (!res.ok) return [];
|
|
506
508
|
return ((await res.json()).items ?? []).map((s) => ({
|
|
507
509
|
key: s.key,
|
|
@@ -520,7 +522,7 @@ var GatewaySseBackend = class {
|
|
|
520
522
|
async listAgents() {
|
|
521
523
|
const agents = /* @__PURE__ */ new Map();
|
|
522
524
|
try {
|
|
523
|
-
const res = await gatewayFetch(this.baseUrl, "/api/agents", this.
|
|
525
|
+
const res = await gatewayFetch(this.baseUrl, "/api/agents", this.credential);
|
|
524
526
|
if (res.ok) {
|
|
525
527
|
const json = await res.json();
|
|
526
528
|
for (const row of json.payload?.agents ?? []) {
|
|
@@ -544,7 +546,7 @@ var GatewaySseBackend = class {
|
|
|
544
546
|
}
|
|
545
547
|
async setTuiDefaultAgent(agentId) {
|
|
546
548
|
const target = agentId.trim().toLowerCase();
|
|
547
|
-
const res = await gatewayFetch(this.baseUrl, "/api/config", this.
|
|
549
|
+
const res = await gatewayFetch(this.baseUrl, "/api/config", this.credential, {
|
|
548
550
|
method: "PATCH",
|
|
549
551
|
body: JSON.stringify({ tui: { defaultAgent: target } })
|
|
550
552
|
});
|
|
@@ -560,7 +562,7 @@ var GatewaySseBackend = class {
|
|
|
560
562
|
const out = {};
|
|
561
563
|
try {
|
|
562
564
|
const sessionPath = `/api/sessions/${encodeURIComponent(sessionKey)}`;
|
|
563
|
-
const [sessionRes, agentCfgRes] = await Promise.all([gatewayFetch(this.baseUrl, sessionPath, this.
|
|
565
|
+
const [sessionRes, agentCfgRes] = await Promise.all([gatewayFetch(this.baseUrl, sessionPath, this.credential), gatewayFetch(this.baseUrl, `${sessionPath}/agent-config`, this.credential)]);
|
|
564
566
|
let session;
|
|
565
567
|
if (sessionRes.ok) {
|
|
566
568
|
session = (await sessionRes.json()).session;
|
|
@@ -608,7 +610,7 @@ var GatewaySseBackend = class {
|
|
|
608
610
|
}
|
|
609
611
|
async listModels() {
|
|
610
612
|
try {
|
|
611
|
-
const res = await gatewayFetch(this.baseUrl, "/api/models", this.
|
|
613
|
+
const res = await gatewayFetch(this.baseUrl, "/api/models", this.credential);
|
|
612
614
|
if (!res.ok) return [];
|
|
613
615
|
return ((await res.json()).payload?.models ?? []).map(normalizeGatewayModelChoice);
|
|
614
616
|
} catch {
|
|
@@ -616,11 +618,11 @@ var GatewaySseBackend = class {
|
|
|
616
618
|
}
|
|
617
619
|
}
|
|
618
620
|
async resetSession(sessionKey) {
|
|
619
|
-
await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/reset`, this.
|
|
621
|
+
await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/reset`, this.credential, { method: "POST" }).catch(() => {});
|
|
620
622
|
}
|
|
621
623
|
async compactSession(sessionKey, options) {
|
|
622
624
|
try {
|
|
623
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/compaction/run`, this.
|
|
625
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/compaction/run`, this.credential, {
|
|
624
626
|
method: "POST",
|
|
625
627
|
body: JSON.stringify({
|
|
626
628
|
force: options?.force ?? true,
|
|
@@ -652,12 +654,12 @@ var GatewaySseBackend = class {
|
|
|
652
654
|
}
|
|
653
655
|
async exportSession(sessionKey, format) {
|
|
654
656
|
const params = new URLSearchParams({ format });
|
|
655
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/export?${params.toString()}`, this.
|
|
657
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/export?${params.toString()}`, this.credential);
|
|
656
658
|
if (!res.ok) throw new Error(`Export failed (${res.status})`);
|
|
657
659
|
return (await res.json()).content ?? "";
|
|
658
660
|
}
|
|
659
661
|
async importSession(targetSessionKey, jsonContent) {
|
|
660
|
-
const res = await gatewayFetch(this.baseUrl, "/api/sessions/import", this.
|
|
662
|
+
const res = await gatewayFetch(this.baseUrl, "/api/sessions/import", this.credential, {
|
|
661
663
|
method: "POST",
|
|
662
664
|
body: JSON.stringify({
|
|
663
665
|
targetKey: targetSessionKey,
|
|
@@ -672,7 +674,7 @@ var GatewaySseBackend = class {
|
|
|
672
674
|
};
|
|
673
675
|
}
|
|
674
676
|
async createShare(sessionKey, request, options) {
|
|
675
|
-
const res = await gatewayFetch(this.baseUrl, "/api/shares/auto", this.
|
|
677
|
+
const res = await gatewayFetch(this.baseUrl, "/api/shares/auto", this.credential, {
|
|
676
678
|
method: "POST",
|
|
677
679
|
body: JSON.stringify({
|
|
678
680
|
path: request.path,
|
|
@@ -702,7 +704,7 @@ var GatewaySseBackend = class {
|
|
|
702
704
|
};
|
|
703
705
|
}
|
|
704
706
|
async btwQuery(sessionKey, question) {
|
|
705
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/btw`, this.
|
|
707
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/btw`, this.credential, {
|
|
706
708
|
method: "POST",
|
|
707
709
|
body: JSON.stringify({ question })
|
|
708
710
|
});
|
|
@@ -713,7 +715,7 @@ var GatewaySseBackend = class {
|
|
|
713
715
|
return await res.json();
|
|
714
716
|
}
|
|
715
717
|
async forkSession(sourceSessionKey, targetSessionKey) {
|
|
716
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sourceSessionKey)}/fork`, this.
|
|
718
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sourceSessionKey)}/fork`, this.credential, {
|
|
717
719
|
method: "POST",
|
|
718
720
|
body: JSON.stringify({ targetKey: targetSessionKey })
|
|
719
721
|
});
|
|
@@ -727,7 +729,7 @@ var GatewaySseBackend = class {
|
|
|
727
729
|
async forkSessionAt(sourceSessionKey, targetSessionKey, entryId) {
|
|
728
730
|
const throughRow = transcriptTreeEntryIdToRowNumber(entryId);
|
|
729
731
|
if (throughRow == null) throw new Error(`Invalid transcript entry: ${entryId}`);
|
|
730
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sourceSessionKey)}/fork-row`, this.
|
|
732
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sourceSessionKey)}/fork-row`, this.credential, {
|
|
731
733
|
method: "POST",
|
|
732
734
|
body: JSON.stringify({
|
|
733
735
|
targetKey: targetSessionKey,
|
|
@@ -742,7 +744,7 @@ var GatewaySseBackend = class {
|
|
|
742
744
|
};
|
|
743
745
|
}
|
|
744
746
|
async setTranscriptLabel(sessionKey, entryId, label) {
|
|
745
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/label`, this.
|
|
747
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/label`, this.credential, {
|
|
746
748
|
method: "POST",
|
|
747
749
|
body: JSON.stringify({
|
|
748
750
|
targetId: entryId,
|
|
@@ -754,7 +756,7 @@ var GatewaySseBackend = class {
|
|
|
754
756
|
return { ok: true };
|
|
755
757
|
}
|
|
756
758
|
async appendCustomEntry(sessionKey, customType, data) {
|
|
757
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/custom`, this.
|
|
759
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/custom`, this.credential, {
|
|
758
760
|
method: "POST",
|
|
759
761
|
body: JSON.stringify({
|
|
760
762
|
customType,
|
|
@@ -766,7 +768,7 @@ var GatewaySseBackend = class {
|
|
|
766
768
|
return { ok: true };
|
|
767
769
|
}
|
|
768
770
|
async appendCustomMessage(sessionKey, message) {
|
|
769
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/custom-message`, this.
|
|
771
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/custom-message`, this.credential, {
|
|
770
772
|
method: "POST",
|
|
771
773
|
body: JSON.stringify(message)
|
|
772
774
|
});
|
|
@@ -775,7 +777,7 @@ var GatewaySseBackend = class {
|
|
|
775
777
|
return { ok: true };
|
|
776
778
|
}
|
|
777
779
|
async appendBashExecution(sessionKey, entry) {
|
|
778
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/bash`, this.
|
|
780
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/transcript/bash`, this.credential, {
|
|
779
781
|
method: "POST",
|
|
780
782
|
body: JSON.stringify(entry)
|
|
781
783
|
});
|
|
@@ -784,7 +786,7 @@ var GatewaySseBackend = class {
|
|
|
784
786
|
return { ok: true };
|
|
785
787
|
}
|
|
786
788
|
async patchSession(sessionKey, patch) {
|
|
787
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/agent-config`, this.
|
|
789
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/agent-config`, this.credential, {
|
|
788
790
|
method: "PATCH",
|
|
789
791
|
body: JSON.stringify(patch)
|
|
790
792
|
});
|
|
@@ -792,7 +794,7 @@ var GatewaySseBackend = class {
|
|
|
792
794
|
if (!res.ok || json.ok === false) throw new Error(json.error ?? `Session config patch failed (${res.status})`);
|
|
793
795
|
const projectId = typeof patch.projectId === "string" ? patch.projectId.trim() : "";
|
|
794
796
|
if (projectId) {
|
|
795
|
-
const metaRes = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}`, this.
|
|
797
|
+
const metaRes = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}`, this.credential, {
|
|
796
798
|
method: "PATCH",
|
|
797
799
|
body: JSON.stringify({ projectId })
|
|
798
800
|
});
|
|
@@ -802,7 +804,7 @@ var GatewaySseBackend = class {
|
|
|
802
804
|
}
|
|
803
805
|
async renameSession(sessionKey, name) {
|
|
804
806
|
try {
|
|
805
|
-
return { ok: (await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/rename`, this.
|
|
807
|
+
return { ok: (await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}/rename`, this.credential, {
|
|
806
808
|
method: "POST",
|
|
807
809
|
body: JSON.stringify({ name })
|
|
808
810
|
})).ok };
|
|
@@ -812,7 +814,7 @@ var GatewaySseBackend = class {
|
|
|
812
814
|
}
|
|
813
815
|
async deleteSession(sessionKey) {
|
|
814
816
|
try {
|
|
815
|
-
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}`, this.
|
|
817
|
+
const res = await gatewayFetch(this.baseUrl, `/api/sessions/${encodeURIComponent(sessionKey)}`, this.credential, { method: "DELETE" });
|
|
816
818
|
if (!res.ok) return { ok: false };
|
|
817
819
|
return { ok: (await res.json()).deleted !== false };
|
|
818
820
|
} catch {
|
|
@@ -823,12 +825,14 @@ var GatewaySseBackend = class {
|
|
|
823
825
|
this.eventAbort?.abort();
|
|
824
826
|
this.eventAbort = new AbortController();
|
|
825
827
|
const url = new URL(`${this.baseUrl}/api/events`);
|
|
826
|
-
if (this.token) url.searchParams.set("token", this.token);
|
|
827
828
|
const connect = async () => {
|
|
828
829
|
try {
|
|
829
830
|
const res = await fetch(url.toString(), {
|
|
830
831
|
signal: this.eventAbort.signal,
|
|
831
|
-
headers: {
|
|
832
|
+
headers: {
|
|
833
|
+
Accept: "text/event-stream",
|
|
834
|
+
...gatewayCredentialAuthorization(this.credential) ? { Authorization: gatewayCredentialAuthorization(this.credential) } : {}
|
|
835
|
+
}
|
|
832
836
|
});
|
|
833
837
|
if (!res.ok || !res.body) {
|
|
834
838
|
this.onDisconnected?.(`event stream error: ${res.status}`);
|