@xopcai/xopc 0.0.252 → 0.0.253
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/manifest.json +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +2 -2
- package/dist/extensions/telegram/src/plugin.js +3 -2
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-w3eq3YpP.js → activity-store-CeS1bgXP.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-k039rbUz.js → agent-avatar-dicebear-BdF3HhCW.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Bs34Kp0K.js +1 -0
- package/dist/gateway/static/root/assets/{agents-Bmth_bSQ.js → agents-DARlgjTm.js} +1 -1
- package/dist/gateway/static/root/assets/{api-2joIfbrH.js → api-zMPeC0yU.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-ByJ4kiD0.js → app-management-settings-panel-BaAFln8W.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BK2Jga-B.js → appearance-settings-CXvsoBlw.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-B3ky7cWU.js → apps-page-BhgvfBJT.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DMDKtYpi.js → archive-plugin-C0o_mVQI.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B764Ql3Z.js → attachment-load-B5Ry3tGL.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D-sO8CZe.js → automations-page-DY5QAEQd.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BzX4lILP.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-fxtzYRpv.js → binary-plugins-BydpEgBA.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Bcjtvckh.js → block-editor-D0CpUOMo.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BSmnusjD.js → browser-automation-inputs-DzbTsGI6.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-DC_OQIBk.js → browser-automations-page-D7fZYjni.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-C1FojyG6.js → browser-settings-page-BBdMqxl0.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D_WfftDW.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-bdRLT9KA.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-BuWjIG_a.js → channels-status-swr-BGGRTkn6.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-5SevEo_I.js → chat-terminal-dock-_CP4nvlg.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-CPDjU5wU.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DtsfalBM.js → cron-expression-g2U8Rllf.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-tDEQV5TP.js → date-picker-SmVlhtj_.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-HhNwg0Y2.js → dependency-picker-D-0gcbbM.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-acU4Li-C.js → desktop-pet-Cl3JRIu6.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-R84AR0Pe.js → desktop-pet-settings-D7kvWQ9H.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CrLlRkSN.js → extension-debug-page-DtP2tJHY.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BH5lmZXE.js → extension-page-CphZDdoT.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BscjNAd1.js → extension-settings-page-CsxVLV4-.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-9HidFZUd.js → gateway-config-swr-BW3Bx-aV.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-DxBZ05dX.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DRCPXONr.js → gateway-startup-retry-DAq74TZe.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-K5Zhl2rx.js → heartbeat-settings-DWcKsIoZ.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BdvLZKQZ.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CR6Kle8H.js → image-generation-api-MPuaXDRs.js} +1 -1
- package/dist/gateway/static/root/assets/index-C7RDs6S-.js +74 -0
- package/dist/gateway/static/root/assets/index-Cu8xqZQ9.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B1QR49-7.js → keyboard-shortcuts-settings-CfhaTqgE.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-wicoV-ti.js → local-app-workbench-page-CR6asX7L.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-C74It-T8.js → local-apps-page-g01W3kEK.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BfZGZKSs.js → locale-store-BkeaPZpn.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-xX-7S49A.js → logs-page-ZP4QTWoC.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-1kNnYL97.js → management-settings-DeGxJF_Z.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-Ca7BRBLL.js +201 -0
- package/dist/gateway/static/root/assets/{media-plugins-B5c0AoS1.js → media-plugins-FmOhmzlD.js} +1 -1
- package/dist/gateway/static/root/assets/messages-C72stReU.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-CsIZqK51.js → mobile-pairing-wizard-BXNbn05L.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-EeVeF4II.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-D7bMff96.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-CqJN6Ljz.js → page-tabs-pyukZ1PJ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DqRIGxf4.js → preview-open-alternatives-slFHoMUe.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DE2nPE_K.js → product-open-page-CXa3FNNk.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BDF88VdN.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DeTD6pu1.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-Bpy8XX-5.js → registry-api-CviQoUBf.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CxKrdQ6a.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bb4b74-P.js → runtime-tools-settings-panel-O9D9o7-O.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DoPU5j3J.js → schema-form-8FesicnL.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DUFJN-2t.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CcSYDjaH.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Ci-9WajJ.js → settings-form-section-CBic9TFH.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CL_2F95D.js → settings-page-Xz66_Mjg.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C6DuwrP5.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-XUA3oKQX.js → share-preview-page--JpjwB58.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CovcdHSC.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CrHagTsE.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-sXXAZDc9.js → skills-page-fVKExKv5.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DD79Bl1I.js → skills-page.utils-Yv9u3uJp.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BEH64qBV.js → system-settings-panel-CCWjVdc2.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-I8hueJnG.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-CISSxU1c.js → theme-store-BtkaVpMm.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DrKDhnJm.js → tunnel-api-C__W9BaN.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CPYePL-Q.js → use-autosave-Dow9RRcq.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CU6nxmoM.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DKqzrCXx.js → voice-api-key-field-CvF3lEyx.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-e9xWjwBX.js → voice-config-api-BEUVAyM6.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-kTQug6bq.js → work-discovery-overlay-B9PDfReq.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-m9SKj_GT.js → workflow-run-setup-panel-kWGFkhjz.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-B4Is5E42.js +5 -0
- package/dist/gateway/static/root/index.html +10 -10
- package/dist/package.js +1 -1
- package/dist/packages/realtime-protocol/src/voice.js +6 -1
- package/dist/src/agent/agent-manager.js +20 -3
- package/dist/src/agent/embedded/execution-context.d.ts +2 -1
- package/dist/src/agent/embedded/execution-context.js +10 -4
- package/dist/src/agent/embedded/index.d.ts +1 -1
- package/dist/src/agent/embedded/index.js +2 -2
- package/dist/src/agent/embedded/run-for-session.js +4 -3
- package/dist/src/agent/embedded/run-turn.js +22 -3
- package/dist/src/agent/embedded/types.d.ts +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +6 -3
- package/dist/src/agent/service/process-direct-streaming.js +6 -3
- package/dist/src/agent/service.d.ts +2 -0
- package/dist/src/agent/service.js +21 -7
- package/dist/src/agent/tools/clarify-tool.d.ts +17 -3
- package/dist/src/agent/tools/clarify-tool.js +27 -32
- package/dist/src/agent/tools/cli-clarify.js +23 -8
- package/dist/src/agent/tools/factory.js +14 -4
- package/dist/src/automations/domain/validation.d.ts +4 -4
- package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +5 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +5 -1
- package/dist/src/gateway/clarify-runtime.d.ts +7 -5
- package/dist/src/gateway/clarify-runtime.js +8 -11
- package/dist/src/gateway/ephemeral-clarification-waiter.d.ts +17 -0
- package/dist/src/gateway/ephemeral-clarification-waiter.js +46 -0
- package/dist/src/gateway/hono/routes/agent-stream.js +44 -18
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +10 -2
- package/dist/src/gateway/hono/routes/side-chats.js +24 -4
- package/dist/src/gateway/security/gateway-scopes.js +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +25 -36
- package/dist/src/gateway/service/agent-runner.js +103 -32
- package/dist/src/gateway/service/run-gateway-agent.js +5 -2
- package/dist/src/gateway/service/session-input-coordinator.js +4 -1
- package/dist/src/gateway/service/sessions-api.js +1 -1
- package/dist/src/gateway/service.d.ts +4 -2
- package/dist/src/gateway/service.js +26 -10
- package/dist/src/gateway/side-chat/manager.d.ts +2 -1
- package/dist/src/gateway/side-chat/manager.js +5 -4
- package/dist/src/gateway/side-chat/run-service.d.ts +5 -1
- package/dist/src/gateway/side-chat/run-service.js +24 -23
- package/dist/src/gateway/side-chat/types.d.ts +3 -1
- package/dist/src/storage/sqlite/clarification-wait-repository.d.ts +41 -0
- package/dist/src/storage/sqlite/clarification-wait-repository.js +418 -0
- package/dist/src/storage/sqlite/index.d.ts +2 -1
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/migrations/154_session_clarification_waits.sql +60 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +11 -6
- package/dist/src/voice/realtime/agentEngine.js +7 -2
- package/dist/src/voice/realtime/runtime.types.d.ts +5 -0
- package/package.json +3 -3
- package/skills/creative/hatch-pet/SKILL.md +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D4J4oq8p.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ds5-_-9z.js +0 -6
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Bs59UCut.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-CM9vNmoo.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BPZ44D-V.js +0 -2
- package/dist/gateway/static/root/assets/gateway-settings-BxLcW6ij.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CZAg9RBv.js +0 -1
- package/dist/gateway/static/root/assets/index-D4Ykja-U.js +0 -72
- package/dist/gateway/static/root/assets/index-zIJ3AXgR.css +0 -2
- package/dist/gateway/static/root/assets/markdown-view-DjiwT28p.js +0 -201
- package/dist/gateway/static/root/assets/messages-DaIwVWar.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-CfWxopl4.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CYN-LCHJ.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-B5G3LzDq.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CuVK2mKu.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Dnd73xWt.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-XL4LyKZe.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-0ForzDSS.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DVws6XZc.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BwDvcacF.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BJjrATqE.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-0jxMi75O.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-B6zLDfDl.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-Bcd1XqP7.js +0 -5
- package/dist/src/gateway/clarify-bridge.d.ts +0 -46
- package/dist/src/gateway/clarify-bridge.js +0 -111
|
@@ -81,7 +81,7 @@ export declare class GatewayService {
|
|
|
81
81
|
private stopRealtimeLogBridge;
|
|
82
82
|
/**
|
|
83
83
|
* Webchat agent invocation surface (`runAgent`, `abortAgentRun`, `steer*`,
|
|
84
|
-
*
|
|
84
|
+
* clarification dispatch). Owns the
|
|
85
85
|
* `activeWebchatRunBySession` + `runAbortControllers` maps.
|
|
86
86
|
*/
|
|
87
87
|
readonly agentRunner: GatewayAgentRunner;
|
|
@@ -168,7 +168,9 @@ export declare class GatewayService {
|
|
|
168
168
|
idle: boolean;
|
|
169
169
|
}>;
|
|
170
170
|
getActiveWebchatRunId(sessionKey: string): string | undefined;
|
|
171
|
-
|
|
171
|
+
answerEphemeralClarification(requestId: string, answer: string): boolean;
|
|
172
|
+
getClarificationState(sessionKey: string): import("@xopcai/gateway-contract/src/clarifications.js").ClarificationWaitSnapshot;
|
|
173
|
+
resolveClarificationResponse(input: Parameters<GatewayAgentRunner['resolveClarificationResponse']>[0]): import("../storage/sqlite/clarification-wait-repository.js").ResolveClarificationResult;
|
|
172
174
|
private initializeExtensionLoader;
|
|
173
175
|
private registerExtensionChannelPlugins;
|
|
174
176
|
/**
|
|
@@ -50,7 +50,7 @@ import "../infra/bus/index.js";
|
|
|
50
50
|
import { AgentService } from "../agent/service.js";
|
|
51
51
|
import { ensureStarterAgentsInitialized } from "../agent/starter-agents.js";
|
|
52
52
|
import { setPairingBroadcastSink } from "../channels/pairing/pairing-events.js";
|
|
53
|
-
import {
|
|
53
|
+
import { registerClarificationChannelRuntime } from "./clarify-runtime.js";
|
|
54
54
|
import { ChannelManager } from "../channels/manager.js";
|
|
55
55
|
import { getWorkspacePath } from "../config/workspace-path-helpers.js";
|
|
56
56
|
import "../config/index.js";
|
|
@@ -97,6 +97,7 @@ import { assertGatewayRuntimeConfig } from "./runtime-config.js";
|
|
|
97
97
|
import { auditGatewayConfig } from "./security/audit.js";
|
|
98
98
|
import { getXopcCloudCatalogCoordinator } from "../providers/xopc-cloud-catalog-coordinator.js";
|
|
99
99
|
import { ModelCatalogSyncService } from "../providers/model-catalog-sync-service.js";
|
|
100
|
+
import { collectMediaUrisFromMessages, deleteMediaUris } from "../media/session-references.js";
|
|
100
101
|
import { runBootstrapMigrationsSync } from "../migrations/runner.js";
|
|
101
102
|
import { NotificationService } from "../notifications/service.js";
|
|
102
103
|
import { LocalAppService } from "../local-apps/service.js";
|
|
@@ -268,7 +269,7 @@ var GatewayService = class {
|
|
|
268
269
|
stopRealtimeLogBridge = null;
|
|
269
270
|
/**
|
|
270
271
|
* Webchat agent invocation surface (`runAgent`, `abortAgentRun`, `steer*`,
|
|
271
|
-
*
|
|
272
|
+
* clarification dispatch). Owns the
|
|
272
273
|
* `activeWebchatRunBySession` + `runAbortControllers` maps.
|
|
273
274
|
*/
|
|
274
275
|
agentRunner;
|
|
@@ -465,8 +466,12 @@ var GatewayService = class {
|
|
|
465
466
|
getParentMetadata: (sessionKey) => this.sessionIndex.getSessionMetadata(sessionKey),
|
|
466
467
|
loadParentMessages: (sessionKey) => this.sessionIndex.getStore().load(sessionKey),
|
|
467
468
|
getDefaultModelRef: (sessionKey) => this.ensureAgentService().getModelForSession(sessionKey),
|
|
469
|
+
getDefaultThinkingLevel: (sessionKey) => this.ensureAgentService().getThinkingLevelForSession(sessionKey),
|
|
468
470
|
getWorkspacePath: (metadata) => metadata.cwd || this.currentWorkspacePath,
|
|
469
|
-
onBeforeDispose: (sideChatId, clientInstanceId
|
|
471
|
+
onBeforeDispose: async (sideChatId, clientInstanceId, messages) => {
|
|
472
|
+
await sideChatRuns?.cancelRun(sideChatId, clientInstanceId);
|
|
473
|
+
await deleteMediaUris(collectMediaUrisFromMessages(messages));
|
|
474
|
+
},
|
|
470
475
|
onExpired: (sideChatId, clientInstanceId, reason) => {
|
|
471
476
|
const topic = `side-chat:${clientInstanceId}:${sideChatId}`;
|
|
472
477
|
this.realtime.broker.publish(topic, "expired", { reason });
|
|
@@ -572,10 +577,12 @@ var GatewayService = class {
|
|
|
572
577
|
}
|
|
573
578
|
return null;
|
|
574
579
|
},
|
|
575
|
-
gatewayClarify: { requestClarification: (
|
|
576
|
-
const executionSessionKey = getEmbeddedExecutionSession() ?? sessionKey;
|
|
580
|
+
gatewayClarify: { requestClarification: (context, request) => {
|
|
581
|
+
const executionSessionKey = getEmbeddedExecutionSession() ?? context.sessionKey;
|
|
577
582
|
return this.agentRunner.requestClarification({
|
|
578
583
|
sessionKey: executionSessionKey,
|
|
584
|
+
runId: context.runId,
|
|
585
|
+
toolCallId: context.toolCallId,
|
|
579
586
|
request,
|
|
580
587
|
publishStreamFor: (_runId) => (event) => {
|
|
581
588
|
this._agentService.turnDispatcher.enqueueWebchatStreamEvent(executionSessionKey, event);
|
|
@@ -776,8 +783,14 @@ var GatewayService = class {
|
|
|
776
783
|
getActiveWebchatRunId(sessionKey) {
|
|
777
784
|
return this.agentRunner.getActiveRunId(sessionKey);
|
|
778
785
|
}
|
|
779
|
-
|
|
780
|
-
return this.agentRunner.
|
|
786
|
+
answerEphemeralClarification(requestId, answer) {
|
|
787
|
+
return this.agentRunner.answerEphemeralClarification(requestId, answer);
|
|
788
|
+
}
|
|
789
|
+
getClarificationState(sessionKey) {
|
|
790
|
+
return this.agentRunner.getClarificationState(sessionKey);
|
|
791
|
+
}
|
|
792
|
+
resolveClarificationResponse(input) {
|
|
793
|
+
return this.agentRunner.resolveClarificationResponse(input);
|
|
781
794
|
}
|
|
782
795
|
initializeExtensionLoader() {
|
|
783
796
|
try {
|
|
@@ -925,7 +938,10 @@ var GatewayService = class {
|
|
|
925
938
|
errorMessage: readiness.error.message
|
|
926
939
|
}, `Initial XOPC Cloud catalog refresh failed: ${readiness.error.message}`);
|
|
927
940
|
}
|
|
928
|
-
|
|
941
|
+
registerClarificationChannelRuntime({
|
|
942
|
+
answerChoice: (requestId, choiceIndex, idempotencyKey) => this.agentRunner.answerClarificationChoice(requestId, choiceIndex, idempotencyKey),
|
|
943
|
+
answerText: (sessionKey, text, idempotencyKey) => this.agentRunner.answerClarificationText(sessionKey, text, idempotencyKey)
|
|
944
|
+
});
|
|
929
945
|
this.ensureAgentService();
|
|
930
946
|
this.agentRunner.recoverSessionInputs();
|
|
931
947
|
this.connectionRecovery.start();
|
|
@@ -1242,9 +1258,9 @@ var GatewayService = class {
|
|
|
1242
1258
|
}
|
|
1243
1259
|
this.browserExtensionProvider = null;
|
|
1244
1260
|
this.browserExtensionBindKey = null;
|
|
1245
|
-
|
|
1261
|
+
registerClarificationChannelRuntime(null);
|
|
1246
1262
|
this.connectionRecovery.stop();
|
|
1247
|
-
this.agentRunner.
|
|
1263
|
+
this.agentRunner.disposeClarifications();
|
|
1248
1264
|
await disposeAllSessionMcpRuntimes().catch((err) => {
|
|
1249
1265
|
log.warn({ err }, "MCP runtime shutdown failed");
|
|
1250
1266
|
});
|
|
@@ -11,13 +11,14 @@ export interface EphemeralSideChatManagerOptions {
|
|
|
11
11
|
getParentMetadata: (sessionKey: string) => Promise<SessionMetadata | null>;
|
|
12
12
|
loadParentMessages: (sessionKey: string) => Promise<AgentMessage[]>;
|
|
13
13
|
getDefaultModelRef: (sessionKey: string) => string;
|
|
14
|
+
getDefaultThinkingLevel?: (sessionKey: string) => ThinkingLevel;
|
|
14
15
|
getWorkspacePath: (metadata: SessionMetadata) => string;
|
|
15
16
|
idleTtlMs?: number;
|
|
16
17
|
maxPerClient?: number;
|
|
17
18
|
maxTotal?: number;
|
|
18
19
|
now?: () => number;
|
|
19
20
|
startSweepTimer?: boolean;
|
|
20
|
-
onBeforeDispose?: (sideChatId: string, clientInstanceId: string) => void | Promise<void>;
|
|
21
|
+
onBeforeDispose?: (sideChatId: string, clientInstanceId: string, messages: AgentMessage[]) => void | Promise<void>;
|
|
21
22
|
onExpired?: (sideChatId: string, clientInstanceId: string, reason: 'idle' | 'waiting') => void;
|
|
22
23
|
}
|
|
23
24
|
export declare class EphemeralSideChatManager {
|
|
@@ -90,7 +90,7 @@ var EphemeralSideChatManager = class {
|
|
|
90
90
|
runtime.captureBaseline();
|
|
91
91
|
const config = {
|
|
92
92
|
modelRef: normalizeOptionalString(input.config?.modelRef) || this.options.getDefaultModelRef(parentSessionKey),
|
|
93
|
-
thinkingLevel: input.config?.thinkingLevel
|
|
93
|
+
thinkingLevel: input.config?.thinkingLevel ?? this.options.getDefaultThinkingLevel?.(parentSessionKey) ?? "medium"
|
|
94
94
|
};
|
|
95
95
|
const entry = {
|
|
96
96
|
id,
|
|
@@ -169,10 +169,11 @@ var EphemeralSideChatManager = class {
|
|
|
169
169
|
}
|
|
170
170
|
if (entry.clientInstanceId !== clientInstanceId) return false;
|
|
171
171
|
entry.status = "closing";
|
|
172
|
+
const messages = entry.runtime.loadConversationMessages();
|
|
172
173
|
this.entries.delete(id);
|
|
173
174
|
const cleanup = (async () => {
|
|
174
175
|
try {
|
|
175
|
-
await this.runBeforeDispose(id, clientInstanceId);
|
|
176
|
+
await this.runBeforeDispose(id, clientInstanceId, messages);
|
|
176
177
|
await evictEmbeddedSessionRunner(entry.runtime.runtimeId, "side_chat_dispose");
|
|
177
178
|
return true;
|
|
178
179
|
} finally {
|
|
@@ -255,9 +256,9 @@ var EphemeralSideChatManager = class {
|
|
|
255
256
|
entry.lastActiveAt = new Date(now).toISOString();
|
|
256
257
|
entry.expiresAt = entry.status === "running" ? null : new Date(now + this.idleTtlMs).toISOString();
|
|
257
258
|
}
|
|
258
|
-
async runBeforeDispose(id, clientInstanceId) {
|
|
259
|
+
async runBeforeDispose(id, clientInstanceId, messages) {
|
|
259
260
|
try {
|
|
260
|
-
await this.options.onBeforeDispose?.(id, clientInstanceId);
|
|
261
|
+
await this.options.onBeforeDispose?.(id, clientInstanceId, messages);
|
|
261
262
|
} catch (err) {
|
|
262
263
|
log.warn({
|
|
263
264
|
err,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentService } from '../../agent/service.js';
|
|
2
2
|
import type { GatewayAgentRunner } from '../service/agent-runner.js';
|
|
3
3
|
import { type EphemeralSideChatManager } from './manager.js';
|
|
4
|
+
import type { UserTurnAttachment } from '../user-turn-input.js';
|
|
4
5
|
export interface SideChatRunServiceOptions {
|
|
5
6
|
manager: EphemeralSideChatManager;
|
|
6
7
|
getAgentService: () => AgentService;
|
|
@@ -12,7 +13,10 @@ export declare class SideChatRunService {
|
|
|
12
13
|
private readonly options;
|
|
13
14
|
private readonly activeBySideChat;
|
|
14
15
|
constructor(options: SideChatRunServiceOptions);
|
|
15
|
-
submit(sideChatId: string, clientInstanceId: string,
|
|
16
|
+
submit(sideChatId: string, clientInstanceId: string, input: {
|
|
17
|
+
content: string;
|
|
18
|
+
attachments?: UserTurnAttachment[];
|
|
19
|
+
}): {
|
|
16
20
|
runId: string;
|
|
17
21
|
};
|
|
18
22
|
abort(sideChatId: string, clientInstanceId: string, runId?: string): Promise<boolean>;
|
|
@@ -12,9 +12,9 @@ var SideChatRunService = class {
|
|
|
12
12
|
constructor(options) {
|
|
13
13
|
this.options = options;
|
|
14
14
|
}
|
|
15
|
-
submit(sideChatId, clientInstanceId,
|
|
16
|
-
const text = content.trim();
|
|
17
|
-
if (!text) throw new SideChatError("content
|
|
15
|
+
submit(sideChatId, clientInstanceId, input) {
|
|
16
|
+
const text = input.content.trim();
|
|
17
|
+
if (!text && !input.attachments?.length) throw new SideChatError("content or attachments are required", "INVALID_REQUEST");
|
|
18
18
|
const sideChat = this.options.manager.get(sideChatId, clientInstanceId);
|
|
19
19
|
if (this.activeBySideChat.has(sideChatId)) throw new SideChatError("A side chat run is already active", "CONFLICT");
|
|
20
20
|
const run = {
|
|
@@ -26,7 +26,10 @@ var SideChatRunService = class {
|
|
|
26
26
|
};
|
|
27
27
|
this.activeBySideChat.set(sideChatId, run);
|
|
28
28
|
this.options.manager.setStatus(sideChatId, clientInstanceId, "running", run.runId);
|
|
29
|
-
this.execute(run,
|
|
29
|
+
this.execute(run, {
|
|
30
|
+
content: text,
|
|
31
|
+
attachments: input.attachments
|
|
32
|
+
}, sideChat.config).catch((err) => {
|
|
30
33
|
log.error({
|
|
31
34
|
err,
|
|
32
35
|
sideChatId,
|
|
@@ -55,11 +58,11 @@ var SideChatRunService = class {
|
|
|
55
58
|
}
|
|
56
59
|
submitClarification(sideChatId, clientInstanceId, requestId, answer) {
|
|
57
60
|
if (this.options.manager.get(sideChatId, clientInstanceId).clarification?.requestId !== requestId) return false;
|
|
58
|
-
const handled = this.options.agentRunner.
|
|
61
|
+
const handled = this.options.agentRunner.answerEphemeralClarification(requestId, answer);
|
|
59
62
|
if (handled) this.options.manager.setStatus(sideChatId, clientInstanceId, "running");
|
|
60
63
|
return handled;
|
|
61
64
|
}
|
|
62
|
-
async execute(run,
|
|
65
|
+
async execute(run, input, config) {
|
|
63
66
|
const topic = `run:${run.runId}`;
|
|
64
67
|
const mapper = new ChatStreamMapper({
|
|
65
68
|
runId: run.runId,
|
|
@@ -73,8 +76,10 @@ var SideChatRunService = class {
|
|
|
73
76
|
if (run.abortController.signal.aborted) return;
|
|
74
77
|
if (event.type === "clarify_request") this.options.manager.waitForInput(run.sideChatId, run.clientInstanceId, {
|
|
75
78
|
requestId: String(event.requestId),
|
|
79
|
+
kind: event.kind === "approval" ? "approval" : "input",
|
|
76
80
|
question: String(event.question),
|
|
77
|
-
choices: Array.isArray(event.choices) ? event.choices.filter((choice) => typeof choice === "string") : void 0
|
|
81
|
+
choices: Array.isArray(event.choices) ? event.choices.filter((choice) => typeof choice === "string") : void 0,
|
|
82
|
+
suggestedAnswer: typeof event.suggestedAnswer === "string" ? event.suggestedAnswer : void 0
|
|
78
83
|
}, event.kind === "approval" ? "waiting-approval" : "waiting-input");
|
|
79
84
|
for (const mapped of mapper.map(event)) publish(mapped);
|
|
80
85
|
};
|
|
@@ -82,28 +87,24 @@ var SideChatRunService = class {
|
|
|
82
87
|
for (const event of mapper.start()) publish(event);
|
|
83
88
|
publishMapped({
|
|
84
89
|
type: "user_message",
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
timestamp: Date.now()
|
|
89
|
-
}
|
|
90
|
+
content: input.content,
|
|
91
|
+
media: input.attachments?.map(({ data: _data, ...attachment }) => attachment),
|
|
92
|
+
timestamp: Date.now()
|
|
90
93
|
});
|
|
91
|
-
this.options.agentRunner.registerExternalWebchatRun(run.executionSessionKey, run.runId, (event) => publishMapped(event), {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
} catch {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
94
|
+
this.options.agentRunner.registerExternalWebchatRun(run.executionSessionKey, run.runId, (event) => publishMapped(event), { beforeClarificationResponse: () => {
|
|
95
|
+
try {
|
|
96
|
+
this.options.manager.setStatus(run.sideChatId, run.clientInstanceId, "running");
|
|
97
|
+
return true;
|
|
98
|
+
} catch {
|
|
99
|
+
return false;
|
|
100
100
|
}
|
|
101
|
-
});
|
|
101
|
+
} });
|
|
102
102
|
const result = await this.options.getAgentService().runEphemeralTurn({
|
|
103
103
|
executionSessionKey: run.executionSessionKey,
|
|
104
104
|
parentSessionKey: this.options.manager.get(run.sideChatId, run.clientInstanceId).parentSessionKey,
|
|
105
105
|
runId: run.runId,
|
|
106
|
-
content,
|
|
106
|
+
content: input.content,
|
|
107
|
+
attachments: input.attachments,
|
|
107
108
|
modelRef: config.modelRef,
|
|
108
109
|
thinkingLevel: config.thinkingLevel,
|
|
109
110
|
transcriptRuntime: this.options.manager.getRuntime(run.sideChatId, run.clientInstanceId),
|
|
@@ -39,7 +39,7 @@ export interface SideChatContextSnapshot {
|
|
|
39
39
|
}
|
|
40
40
|
export interface SideChatConfig {
|
|
41
41
|
modelRef: string;
|
|
42
|
-
thinkingLevel
|
|
42
|
+
thinkingLevel: ThinkingLevel;
|
|
43
43
|
}
|
|
44
44
|
export interface SideChatView {
|
|
45
45
|
id: string;
|
|
@@ -54,8 +54,10 @@ export interface SideChatView {
|
|
|
54
54
|
runId?: string;
|
|
55
55
|
clarification?: {
|
|
56
56
|
requestId: string;
|
|
57
|
+
kind: 'input' | 'approval';
|
|
57
58
|
question: string;
|
|
58
59
|
choices?: string[];
|
|
60
|
+
suggestedAnswer?: string;
|
|
59
61
|
};
|
|
60
62
|
messageCount: number;
|
|
61
63
|
context: SideChatContextSnapshot;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ClarificationKind, ClarificationResponseAction, ClarificationWait, ClarificationWaitSnapshot } from '@xopcai/gateway-contract';
|
|
2
|
+
import { type SessionInput } from './session-input-repository.js';
|
|
3
|
+
export type CreateClarificationInput = {
|
|
4
|
+
sessionKey: string;
|
|
5
|
+
runId: string;
|
|
6
|
+
toolCallId: string;
|
|
7
|
+
kind: ClarificationKind;
|
|
8
|
+
question: string;
|
|
9
|
+
choices?: string[];
|
|
10
|
+
suggestedAnswer?: string;
|
|
11
|
+
approvalKey?: string;
|
|
12
|
+
now?: number;
|
|
13
|
+
};
|
|
14
|
+
export type ResolveClarificationInput = {
|
|
15
|
+
id: string;
|
|
16
|
+
expectedVersion: number;
|
|
17
|
+
idempotencyKey: string;
|
|
18
|
+
action: ClarificationResponseAction;
|
|
19
|
+
answer?: string;
|
|
20
|
+
now?: number;
|
|
21
|
+
};
|
|
22
|
+
export type ResolveClarificationResult = {
|
|
23
|
+
ok: true;
|
|
24
|
+
clarification: ClarificationWait;
|
|
25
|
+
idempotent: boolean;
|
|
26
|
+
queued: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
code: 'NOT_FOUND' | 'CONFLICT' | 'EXPIRED' | 'INVALID';
|
|
30
|
+
clarification?: ClarificationWait;
|
|
31
|
+
};
|
|
32
|
+
export declare function getClarification(id: string): ClarificationWait | undefined;
|
|
33
|
+
export declare function getActiveClarification(sessionKey: string): ClarificationWait | undefined;
|
|
34
|
+
export declare function getClarificationSnapshot(sessionKey: string): ClarificationWaitSnapshot | undefined;
|
|
35
|
+
export declare function createClarificationWait(input: CreateClarificationInput): ClarificationWait;
|
|
36
|
+
export declare function isClarificationSuspended(sessionKey: string, runId: string): boolean;
|
|
37
|
+
export declare function resolveClarification(input: ResolveClarificationInput): ResolveClarificationResult;
|
|
38
|
+
export declare function getClarificationResumeInput(sessionKey: string, runId: string): SessionInput | undefined;
|
|
39
|
+
export declare function consumeClarificationResume(input: SessionInput): boolean;
|
|
40
|
+
export declare function consumeClarificationApproval(sessionKey: string, approvalKey: string): 'approved' | 'denied' | undefined;
|
|
41
|
+
export declare function supersedeActiveClarification(sessionKey: string, now?: number): ClarificationWait | undefined;
|