@xopcai/xopc 0.0.221 → 0.0.223
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/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-NItGQmvR.js → activity-store--GBciH10.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B8SBTGg3.js → agent-avatar-dicebear-C93T3FLD.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Ba4XF0Im.js +68 -0
- package/dist/gateway/static/root/assets/{api-53ZXsuyr.js → api-HoIz_ija.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BtmPXaqu.js → app-management-settings-panel-Bhl8Xluk.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-t7HoJyNN.js → appearance-settings-CywEN-kG.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BZY09nuJ.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-D8o8CP9Y.js → archive-plugin-CteCVsBP.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CsLXzas8.js → attachment-load-CbNE_EPd.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D-zgoAKz.js → automations-page-Bcqk6tOx.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-DtI6vsMf.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B-MjP_22.js → binary-plugins-M_i3WS5M.js} +1 -1
- package/dist/gateway/static/root/assets/block-editor-eg9LEH2o.js +184 -0
- package/dist/gateway/static/root/assets/browser-settings-page-kKwbvzjj.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-Bi6RSSpD.js → browser-workflow-inputs-1UZ0vnIy.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-EEFHUm1i.js → browser-workflows-page-D8ATQqZ5.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CZRcis8B.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-pC2fno7r.js → capability-presets-api-yNqTIuyd.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CgdRkwnk.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-B5Szgu_z.js → channel-recipient-api-krezGsKc.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-DETCY0Ku.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DMxB7slL.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DT-OFl4r.js → chat-terminal-dock-DQ5bB4Su.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-D9D92u28.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-MZ_AJqrm.js → cron-expression-CEwPkdhh.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Bv9hZLuD.js → date-picker-DDAxTir8.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-D-6oO_Vk.js → dependency-picker-CYVoSZwI.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CiI5caKj.js → desktop-pet-CrNKfW_c.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DhkSOy4K.js → desktop-pet-settings-C06PaB46.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-C4s4Pz8I.js → directory-picker-path-field--D7laeLF.js} +1 -1
- package/dist/gateway/static/root/assets/dist-DaxPZj9e.js +1 -0
- package/dist/gateway/static/root/assets/{dist-DY4Af0fY.js → dist-J_ySZvz0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DE7J1-6W.js → extension-debug-page-Dn4Px9KQ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DSnACD7E.js → extension-page-DzLf3fMQ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Dk7k2Pok.js → extension-settings-page-DIchwtvB.js} +1 -1
- package/dist/gateway/static/root/assets/floating-ui.dom-B7uQOZZW.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-IOA1OlHx.js → gateway-config-api-SmTGLhqK.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BzTbnu4O.js → gateway-config-swr-yUxMMVjK.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-FX7QsgSQ.js → gateway-settings-yCDkOYzA.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B2zpkNvi.js → gateway-startup-retry-9mrsL84j.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-CquIULHX.js +1 -0
- package/dist/gateway/static/root/assets/home-page-COSGBh4c.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BXRjz-iY.js → image-generation-api-CgFAGDi8.js} +1 -1
- package/dist/gateway/static/root/assets/index-5XkDWH_Q.css +2 -0
- package/dist/gateway/static/root/assets/index-wnDPGRTi.js +74 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BjYiM4xq.js → keyboard-shortcuts-settings-DI2To7yl.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CAF5SZXv.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-7DHvwSgA.js → local-apps-page-CSEJsQ1F.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-iKjqemWG.js → locale-store-CPylQjH9.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-D1KFPHL1.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-BSxppo9Z.js → management-settings-CgyaIyuk.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-D4oDjZtl.js → markdown-split-paG9qap9.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-CUsob4Pz.js +69 -0
- package/dist/gateway/static/root/assets/{media-plugins-BPNTGROA.js → media-plugins-0Q-c_QIy.js} +1 -1
- package/dist/gateway/static/root/assets/messages-B82nsi9k.js +3 -0
- package/dist/gateway/static/root/assets/notes-api-CfKZYrBC.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-DU5tKPTq.js → notes-page-Bvb-ycX_.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-DelxGBof.js +4 -0
- package/dist/gateway/static/root/assets/oauth-authorization-window-Cdolr2wE.js +1 -0
- package/dist/gateway/static/root/assets/{popover-select-BzdnTy3h.js → popover-select-CccGri5Y.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CPoQvD6P.js → product-open-page-DrvBwAns.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-C2EnYXEQ.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BiMPU6Oa.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-Cx3JxXSL.js → registry-api-B_5D8epF.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CpbNivVs.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-xqnWcvIv.js → runtime-tools-settings-panel-DKjdN4Lr.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CuIDPYu6.js → schema-form-DskqaNqC.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BxKtzsKI.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BfBKMMUx.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DkAv9ncE.js → settings-form-section-CZlMvHA9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BJUQiEKb.js → settings-loading-skeleton-DS6lcAg9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-KHRbLwmw.js → settings-page-oE5J9tsV.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-C8jd20Db.js → setup-status-panel-C7oFCIqD.js} +1 -1
- package/dist/gateway/static/root/assets/share-preview-page-CPFAj8NE.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-B46DWZK4.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CyKolUZ-.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-CKhR9J81.js → skills-page-Bh4gFi8e.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-AYX-e5sD.js → skills-page.utils-BQaUWP9z.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-IIF-K9ML.js → system-settings-panel-COAZoh_O.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CXkhprf-.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BOD2D0dJ.js → theme-store-BN-32Fz5.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DcktF1j1.js → use-autosave-BAkToU15.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-Br5wgARM.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BMkNTHHE.js → voice-api-key-field-CC4z9-ux.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DVoiXekA.js → work-discovery-overlay-dLVUYSSE.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cw4LQjuM.js → workflow-run-setup-panel-BYU5-0KF.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CJ24a1HM.js +5 -0
- package/dist/gateway/static/root/index.html +15 -14
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-instance-gateway.d.ts +3 -0
- package/dist/src/agent/agent-manager.d.ts +3 -0
- package/dist/src/agent/agent-manager.js +34 -28
- package/dist/src/agent/embedded/index.d.ts +1 -1
- package/dist/src/agent/embedded/index.js +2 -2
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +102 -63
- package/dist/src/agent/embedded/run-turn.js +56 -28
- package/dist/src/agent/embedded/runs.d.ts +16 -29
- package/dist/src/agent/embedded/runs.js +44 -65
- package/dist/src/agent/embedded/types.d.ts +4 -0
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/memory/create-memory-manager.js +1 -1
- package/dist/src/agent/orchestration/agent-run-supervisor.d.ts +28 -0
- package/dist/src/agent/orchestration/agent-run-supervisor.js +49 -0
- package/dist/src/agent/orchestration/agent-turn-policy.d.ts +18 -0
- package/dist/src/agent/orchestration/agent-turn-policy.js +36 -0
- package/dist/src/agent/orchestration/llm-turn-retry.d.ts +5 -0
- package/dist/src/agent/orchestration/llm-turn-retry.js +34 -4
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +10 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +25 -4
- package/dist/src/agent/service/async-queue.d.ts +16 -3
- package/dist/src/agent/service/async-queue.js +29 -11
- package/dist/src/agent/service/process-direct-streaming.js +27 -4
- package/dist/src/agent/service.js +3 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/exec-command.d.ts +2 -0
- package/dist/src/agent/tools/exec-command.js +70 -7
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/index.js +3 -3
- package/dist/src/auth/oauth/registry.d.ts +2 -0
- package/dist/src/auth/oauth/registry.js +20 -12
- package/dist/src/auth/oauth/xopc-cloud.d.ts +1 -0
- package/dist/src/auth/oauth/xopc-cloud.js +32 -16
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/channels/attachments/voice-stt-webchat.js +20 -3
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/tunnel.js +4 -5
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.d.ts +18 -0
- package/dist/src/config/schema.js +19 -1
- package/dist/src/connectors/learning-coordinator.js +3 -19
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/app.js +2 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/oauth-async.d.ts +1 -0
- package/dist/src/gateway/hono/oauth-async.js +11 -4
- package/dist/src/gateway/hono/routes/config.js +10 -0
- package/dist/src/gateway/hono/routes/host-fs.js +40 -1
- package/dist/src/gateway/hono/routes/media.js +33 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +162 -7
- package/dist/src/gateway/hono/routes/shares.js +141 -6
- package/dist/src/gateway/hono/routes/tunnel.js +47 -10
- package/dist/src/gateway/hono/routes/voice.d.ts +2 -6
- package/dist/src/gateway/hono/routes/voice.js +28 -5
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.js +3 -3
- package/dist/src/notes/service.d.ts +6 -2
- package/dist/src/notes/service.js +36 -4
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +3 -3
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/share/note-share-service.d.ts +67 -0
- package/dist/src/share/note-share-service.js +283 -0
- package/dist/src/share/share-config.js +32 -3
- package/dist/src/share/share-landing.d.ts +5 -1
- package/dist/src/share/share-landing.js +28 -1
- package/dist/src/share/share-store.d.ts +34 -5
- package/dist/src/share/share-store.js +125 -19
- package/dist/src/share/share-thumbnail.js +4 -2
- package/dist/src/share/share-types.d.ts +52 -14
- package/dist/src/share/share-types.js +9 -0
- package/dist/src/share/share-zip.d.ts +2 -2
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/tunnel/env.d.ts +12 -6
- package/dist/src/tunnel/env.js +34 -26
- package/dist/src/tunnel/gateway-lifecycle.js +2 -13
- package/dist/src/tunnel/index.d.ts +1 -1
- package/dist/src/tunnel/index.js +2 -2
- package/dist/src/tunnel/tunnel-audit.d.ts +1 -1
- package/dist/src/tunnel/tunnel-config.d.ts +1 -1
- package/dist/src/tunnel/tunnel-config.js +9 -4
- package/dist/src/tunnel/tunnel-service.d.ts +1 -1
- package/dist/src/tunnel/tunnel-service.js +3 -0
- package/dist/src/tunnel/well-known.d.ts +1 -1
- package/dist/src/tunnel/well-known.js +1 -1
- package/dist/src/tunnel/xopc-cloud-registration.d.ts +9 -0
- package/dist/src/tunnel/xopc-cloud-registration.js +42 -0
- package/dist/src/voice/audio/normalize.d.ts +7 -0
- package/dist/src/voice/audio/normalize.js +30 -4
- package/dist/src/voice/local/runtime-worker.js +26 -6
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +8 -14
- package/dist/gateway/static/root/assets/agents-Brs2-m6t.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-DJ_Dsb1j.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-DehLRXfd.js +0 -6
- package/dist/gateway/static/root/assets/block-editor-i4CfDqLG.js +0 -184
- package/dist/gateway/static/root/assets/browser-settings-page-C3QIO4Ti.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BHhUp7FW.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DoClNVLz.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-Je-9a5ZC.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-ByRbxC6z.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-D8z9Trw4.js +0 -2
- package/dist/gateway/static/root/assets/dist-C230izr8.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-D5CGVyci.js +0 -1
- package/dist/gateway/static/root/assets/home-page-DzfZFZx5.js +0 -1
- package/dist/gateway/static/root/assets/index-Dcj5KJRg.css +0 -2
- package/dist/gateway/static/root/assets/index-EvA8c7fo.js +0 -74
- package/dist/gateway/static/root/assets/local-app-workbench-page-hPyTaVYU.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DW0xMKWP.js +0 -2
- package/dist/gateway/static/root/assets/markdown-view-DYkxMtJA.js +0 -69
- package/dist/gateway/static/root/assets/messages-kx5W39dO.js +0 -3
- package/dist/gateway/static/root/assets/notes-api-DJizatxh.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-D669d98r.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CpsQ9PTA.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CitO1LMc.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C9-bL4V6.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CPSARi4y.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BxT80Fmr.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-WCVtJ3sX.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-DrQ_cOXh.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C_4cG30x.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CYjsecEr.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Cy1D2hkt.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DKKH1_Yt.js +0 -5
|
@@ -11,9 +11,16 @@ import { isVoiceLikeAttachment, mergeVoiceTranscriptsIntoUserText } from "../../
|
|
|
11
11
|
import { applyReasoningVisibility } from "../streaming/reasoning-visibility.js";
|
|
12
12
|
import { isSessionSourceBinding, summarizeSourceContext } from "../source-context/types.js";
|
|
13
13
|
import { injectSourceContextsIntoUserMessage } from "../source-context/injector.js";
|
|
14
|
-
import { AsyncQueue } from "./async-queue.js";
|
|
14
|
+
import { AsyncQueue, AsyncQueueOverflowError } from "./async-queue.js";
|
|
15
15
|
import { hydratePerTurnState, runDirectAgentTurn, tryRunSlashCommand } from "./direct-turn-helpers.js";
|
|
16
16
|
//#region src/agent/service/process-direct-streaming.ts
|
|
17
|
+
const MAX_BUFFERED_STREAM_EVENTS = 512;
|
|
18
|
+
const LOSSY_STREAM_EVENT_TYPES = new Set([
|
|
19
|
+
"message_update",
|
|
20
|
+
"tool_execution_update",
|
|
21
|
+
"progress",
|
|
22
|
+
"review_delta"
|
|
23
|
+
]);
|
|
17
24
|
function isReviewOutput(value) {
|
|
18
25
|
return !!value && typeof value === "object" && !Array.isArray(value) && value.type === "review";
|
|
19
26
|
}
|
|
@@ -118,7 +125,10 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
118
125
|
const sessionKey = input.sessionKey ?? "agent:main:main";
|
|
119
126
|
const { channel, chatId } = await deps.resolveSessionEndpoint(sessionKey);
|
|
120
127
|
const context = deps.initDirectStreamingSession(sessionKey, channel, chatId, input.origin);
|
|
121
|
-
const queue = new AsyncQueue(
|
|
128
|
+
const queue = new AsyncQueue({
|
|
129
|
+
maxBuffered: MAX_BUFFERED_STREAM_EVENTS,
|
|
130
|
+
isDroppable: (event) => LOSSY_STREAM_EVENT_TYPES.has(event.type)
|
|
131
|
+
});
|
|
122
132
|
let reasoningLevel = channel === "webchat" ? resolveConfiguredActivityDetailDefault(deps.getConfig()) : "stream";
|
|
123
133
|
const pushVisible = (event) => {
|
|
124
134
|
const visible = channel === "webchat" ? event : applyReasoningVisibility(event, reasoningLevel);
|
|
@@ -144,6 +154,7 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
144
154
|
let ranSlashCommand = false;
|
|
145
155
|
let mergedUserText = input.content;
|
|
146
156
|
let webchatSlashReceipt;
|
|
157
|
+
let streamOverflowed = false;
|
|
147
158
|
let slashCommandMetadata;
|
|
148
159
|
const slashTraceRows = [];
|
|
149
160
|
const taskPromise = (async () => {
|
|
@@ -301,12 +312,24 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
301
312
|
clearPendingTranscriptUserMessage(sessionKey, pendingUserMessage);
|
|
302
313
|
}
|
|
303
314
|
} catch (err) {
|
|
304
|
-
if (
|
|
315
|
+
if (err instanceof AsyncQueueOverflowError) {
|
|
316
|
+
streamOverflowed = true;
|
|
317
|
+
await abortEmbeddedRun(sessionKey).catch(() => false);
|
|
318
|
+
deps.log.warn({
|
|
319
|
+
err,
|
|
320
|
+
sessionKey,
|
|
321
|
+
maxBuffered: err.maxBuffered
|
|
322
|
+
}, "Aborted agent stream because the consumer could not keep up with critical events");
|
|
323
|
+
} else if (!abortHandled) pushVisible({
|
|
305
324
|
type: "error",
|
|
306
325
|
content: formatStreamError(err instanceof Error ? err.message : String(err))
|
|
307
326
|
});
|
|
308
327
|
} finally {
|
|
309
|
-
if (
|
|
328
|
+
if (queue.droppedCount > 0) deps.log.warn({
|
|
329
|
+
sessionKey,
|
|
330
|
+
droppedEvents: queue.droppedCount
|
|
331
|
+
}, "Coalesced stream progress events because the consumer fell behind");
|
|
332
|
+
if (!userAborted && !streamOverflowed && channel === "webchat") try {
|
|
310
333
|
const ttsAudioEvent = await deps.maybeEmitWebchatTts(sessionKey, inboundVoice);
|
|
311
334
|
if (ttsAudioEvent) queue.push(ttsAudioEvent);
|
|
312
335
|
} catch (ttsErr) {
|
|
@@ -3,10 +3,10 @@ import { init_logger } from "../utils/logger.js";
|
|
|
3
3
|
import { getUserProfile } from "../storage/sqlite/user-context-repository.js";
|
|
4
4
|
import { parseNoteAttachmentTarget } from "../notes/attachment-ref.js";
|
|
5
5
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
6
|
-
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
7
|
-
import { init_providers, resolveModel } from "../providers/index.js";
|
|
8
6
|
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
7
|
+
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
9
8
|
import { extractProfileAgentId } from "../config/agent-profile.js";
|
|
9
|
+
import { init_providers, resolveModel } from "../providers/index.js";
|
|
10
10
|
import { extractTextContent } from "./context/workspace.js";
|
|
11
11
|
import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
|
|
12
12
|
import { getProjectForSession } from "../projects/workspace.js";
|
|
@@ -602,6 +602,7 @@ var AgentService = class {
|
|
|
602
602
|
workspaceDir,
|
|
603
603
|
transcriptRuntime: params.transcriptRuntime,
|
|
604
604
|
timeoutMs: resolveAgentTurnTimeoutMs(this.effectiveAppConfig(), params.parentSessionKey),
|
|
605
|
+
turnPolicy: this.agentManager.createAgentTurnPolicy(params.parentSessionKey),
|
|
605
606
|
abortSignal: params.abortSignal,
|
|
606
607
|
onEvent: params.onEvent
|
|
607
608
|
}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { init_workspace_defaults, resolveDefaultAgentWorkspaceDir } from "../../config/workspace-defaults.js";
|
|
4
|
-
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
5
4
|
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
5
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
6
6
|
import { effectiveWorkspacePathForSession, projectWorkspacePath } from "../../session/session-workspace.js";
|
|
7
7
|
import { getProjectForSession } from "../../projects/workspace.js";
|
|
8
8
|
import { resolveCompactionPolicy } from "../memory/compaction-policy.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
2
1
|
import { init_paths, resolveSkillsLockPath } from "../../config/paths.js";
|
|
2
|
+
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
//#region src/agent/skills/hub-lock.ts
|
|
5
5
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { extractAssistantText, getAssistantMessageErrorReason, stripCodeFences } from "../../providers/model-response.js";
|
|
4
3
|
import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
|
|
5
|
-
import { getApiKey, init_providers, resolveModel } from "../../providers/index.js";
|
|
6
|
-
import { completeWithResolvedCredentials } from "../../providers/model-call.js";
|
|
7
4
|
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
5
|
+
import { getApiKey, init_providers, resolveModel } from "../../providers/index.js";
|
|
8
6
|
import { TaskRepository } from "../../tasks/task-repository.js";
|
|
9
7
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
10
8
|
import { TaskRunRepository } from "../../tasks/task-run-repository.js";
|
|
9
|
+
import { completeWithResolvedCredentials } from "../../providers/model-call.js";
|
|
11
10
|
import { TaskApplicationService } from "../../tasks/task-application-service.js";
|
|
11
|
+
import { extractAssistantText, getAssistantMessageErrorReason, stripCodeFences } from "../../providers/model-response.js";
|
|
12
12
|
//#region src/agent/tasks/task-judge-service.ts
|
|
13
13
|
init_schema();
|
|
14
14
|
init_providers();
|
|
@@ -25,6 +25,45 @@ function commandStatus(exitCode, timedOut) {
|
|
|
25
25
|
if (exitCode === 0) return "success";
|
|
26
26
|
return "failed";
|
|
27
27
|
}
|
|
28
|
+
function appendBoundedTail(current, chunk, maxChars) {
|
|
29
|
+
const combined = current + chunk;
|
|
30
|
+
if (combined.length <= maxChars) return {
|
|
31
|
+
value: combined,
|
|
32
|
+
truncated: false
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
value: combined.slice(-maxChars),
|
|
36
|
+
truncated: true
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function terminateProcessTree(proc) {
|
|
40
|
+
if (!proc.pid) return;
|
|
41
|
+
if (process.platform === "win32") {
|
|
42
|
+
const killer = spawn("taskkill", [
|
|
43
|
+
"/pid",
|
|
44
|
+
String(proc.pid),
|
|
45
|
+
"/t",
|
|
46
|
+
"/f"
|
|
47
|
+
], {
|
|
48
|
+
stdio: "ignore",
|
|
49
|
+
windowsHide: true
|
|
50
|
+
});
|
|
51
|
+
killer.once("error", () => {
|
|
52
|
+
try {
|
|
53
|
+
proc.kill("SIGKILL");
|
|
54
|
+
} catch {}
|
|
55
|
+
});
|
|
56
|
+
killer.unref();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
process.kill(-proc.pid, "SIGKILL");
|
|
61
|
+
return;
|
|
62
|
+
} catch {}
|
|
63
|
+
try {
|
|
64
|
+
proc.kill("SIGKILL");
|
|
65
|
+
} catch {}
|
|
66
|
+
}
|
|
28
67
|
function commandFailureHint(details) {
|
|
29
68
|
if (details.status === "success") return void 0;
|
|
30
69
|
if (details.status === "timed_out") return "The command timed out. Re-run a narrower command, increase timeoutMs if the long run is expected, or inspect partial output before retrying.";
|
|
@@ -36,6 +75,7 @@ function formatOutputForModel(details, maxOutputChars) {
|
|
|
36
75
|
let prefix = "";
|
|
37
76
|
if (details.timedOut) prefix += `Command timed out after ${Math.round(details.durationMs / 1e3)}s\n`;
|
|
38
77
|
if (details.exitCode !== 0 && details.exitCode != null) prefix += `Command exited with code ${details.exitCode}\n`;
|
|
78
|
+
if (details.captureTruncated) prefix += `Earlier command output was discarded after ${formatSize(details.totalOutputBytes)}; showing the latest captured output.\n`;
|
|
39
79
|
const truncation = truncateTail(details.aggregatedOutput, { maxBytes: Math.min(maxOutputChars, DEFAULT_MAX_OUTPUT_CHARS) });
|
|
40
80
|
let text = `${prefix}${truncation.content}`.trimEnd();
|
|
41
81
|
if (!text) text = "(no output)";
|
|
@@ -78,6 +118,8 @@ function createExecCommandTool(workspaceCwd, options) {
|
|
|
78
118
|
timedOut: false,
|
|
79
119
|
truncated: false,
|
|
80
120
|
outputBytes: 0,
|
|
121
|
+
totalOutputBytes: 0,
|
|
122
|
+
captureTruncated: false,
|
|
81
123
|
stdout: "",
|
|
82
124
|
stderr: "cmd is required",
|
|
83
125
|
aggregatedOutput: "cmd is required",
|
|
@@ -106,6 +148,8 @@ function createExecCommandTool(workspaceCwd, options) {
|
|
|
106
148
|
timedOut: false,
|
|
107
149
|
truncated: false,
|
|
108
150
|
outputBytes: Buffer.byteLength(text),
|
|
151
|
+
totalOutputBytes: Buffer.byteLength(text),
|
|
152
|
+
captureTruncated: false,
|
|
109
153
|
stdout: "",
|
|
110
154
|
stderr: text,
|
|
111
155
|
aggregatedOutput: text,
|
|
@@ -120,11 +164,14 @@ function createExecCommandTool(workspaceCwd, options) {
|
|
|
120
164
|
let stdout = "";
|
|
121
165
|
let stderr = "";
|
|
122
166
|
let aggregatedOutput = "";
|
|
167
|
+
let totalOutputBytes = 0;
|
|
168
|
+
let captureTruncated = false;
|
|
123
169
|
let timedOut = false;
|
|
124
170
|
let settled = false;
|
|
125
171
|
return new Promise((resolveTool) => {
|
|
126
172
|
const proc = spawn(command, [], {
|
|
127
173
|
shell: true,
|
|
174
|
+
detached: process.platform !== "win32",
|
|
128
175
|
cwd: policy.effectiveCwd,
|
|
129
176
|
env: {
|
|
130
177
|
...runtimeEnv,
|
|
@@ -134,9 +181,19 @@ function createExecCommandTool(workspaceCwd, options) {
|
|
|
134
181
|
const publishDelta = (stream, raw) => {
|
|
135
182
|
const text = raw.toString();
|
|
136
183
|
if (!text) return;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
184
|
+
totalOutputBytes += Buffer.byteLength(text);
|
|
185
|
+
if (stream === "stdout") {
|
|
186
|
+
const next = appendBoundedTail(stdout, text, maxOutputChars);
|
|
187
|
+
stdout = next.value;
|
|
188
|
+
captureTruncated ||= next.truncated;
|
|
189
|
+
} else {
|
|
190
|
+
const next = appendBoundedTail(stderr, text, maxOutputChars);
|
|
191
|
+
stderr = next.value;
|
|
192
|
+
captureTruncated ||= next.truncated;
|
|
193
|
+
}
|
|
194
|
+
const nextAggregate = appendBoundedTail(aggregatedOutput, text, maxOutputChars);
|
|
195
|
+
aggregatedOutput = nextAggregate.value;
|
|
196
|
+
captureTruncated ||= nextAggregate.truncated;
|
|
140
197
|
const delta = text.length > STREAM_DELTA_MAX_CHARS ? `${text.slice(0, STREAM_DELTA_MAX_CHARS)}\n[stream delta truncated]` : text;
|
|
141
198
|
onUpdate?.({
|
|
142
199
|
content: [],
|
|
@@ -155,8 +212,12 @@ function createExecCommandTool(workspaceCwd, options) {
|
|
|
155
212
|
clearTimeout(timeout);
|
|
156
213
|
signal?.removeEventListener("abort", abort);
|
|
157
214
|
if (errorText) {
|
|
158
|
-
|
|
159
|
-
|
|
215
|
+
totalOutputBytes += Buffer.byteLength(errorText);
|
|
216
|
+
const nextStderr = appendBoundedTail(stderr, errorText, maxOutputChars);
|
|
217
|
+
stderr = nextStderr.value;
|
|
218
|
+
const nextAggregate = appendBoundedTail(aggregatedOutput, errorText, maxOutputChars);
|
|
219
|
+
aggregatedOutput = nextAggregate.value;
|
|
220
|
+
captureTruncated ||= nextStderr.truncated || nextAggregate.truncated;
|
|
160
221
|
}
|
|
161
222
|
const durationMs = Date.now() - startTime;
|
|
162
223
|
const baseDetails = {
|
|
@@ -168,6 +229,8 @@ function createExecCommandTool(workspaceCwd, options) {
|
|
|
168
229
|
timedOut,
|
|
169
230
|
truncated: false,
|
|
170
231
|
outputBytes: Buffer.byteLength(aggregatedOutput),
|
|
232
|
+
totalOutputBytes,
|
|
233
|
+
captureTruncated,
|
|
171
234
|
stdout,
|
|
172
235
|
stderr,
|
|
173
236
|
aggregatedOutput
|
|
@@ -190,11 +253,11 @@ function createExecCommandTool(workspaceCwd, options) {
|
|
|
190
253
|
};
|
|
191
254
|
const abort = () => {
|
|
192
255
|
timedOut = true;
|
|
193
|
-
proc
|
|
256
|
+
terminateProcessTree(proc);
|
|
194
257
|
};
|
|
195
258
|
const timeout = setTimeout(() => {
|
|
196
259
|
timedOut = true;
|
|
197
|
-
proc
|
|
260
|
+
terminateProcessTree(proc);
|
|
198
261
|
}, timeoutMs);
|
|
199
262
|
if (signal?.aborted) abort();
|
|
200
263
|
else signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
1
2
|
import { checkBoundary } from "./boundary-guard.js";
|
|
2
3
|
import { resolveModelRole } from "./model-router.js";
|
|
3
4
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
4
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
5
5
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
6
6
|
import { buildAgentRuntimeProfile } from "./runtime-profile.js";
|
|
7
7
|
import { appendAgentRunEvent, createAgentRunTrace, finishAgentRunTrace, hashEffectiveManifest } from "./run-trace.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildAgentManifestPromptSection } from "../agent-manifest/prompt.js";
|
|
2
2
|
import "../agent-manifest/index.js";
|
|
3
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
3
4
|
import { checkBoundary } from "./boundary-guard.js";
|
|
4
5
|
import { resolveModelRole } from "./model-router.js";
|
|
5
6
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
6
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
7
7
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
8
8
|
//#region src/agent-runtime/runtime-profile.ts
|
|
9
9
|
function buildAgentRuntimeProfile(params) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import { getAssistantMessageErrorReason, stripCodeFences } from "../providers/model-response.js";
|
|
4
3
|
import { getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
|
|
5
4
|
import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
|
|
6
5
|
import { isLocalModelBaseUrl, resolveModelCallApiKey, resolveModelCallOptions } from "../providers/model-call.js";
|
|
6
|
+
import { getAssistantMessageErrorReason, stripCodeFences } from "../providers/model-response.js";
|
|
7
7
|
//#region src/ai-assist/text-assist.ts
|
|
8
8
|
init_providers();
|
|
9
9
|
init_logger();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
|
-
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
5
4
|
import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveCredentialsDir, resolveOAuthPath } from "../config/paths.js";
|
|
6
|
-
import {
|
|
5
|
+
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
7
6
|
import { getOAuthProviderDefinition, init_registry } from "./oauth/registry.js";
|
|
7
|
+
import { getApiKeyFromEnv, init_env_keys } from "../providers/env-keys.js";
|
|
8
8
|
import { init_oauth_provider_lock, withOAuthProviderLock } from "./oauth-provider-lock.js";
|
|
9
9
|
import { dirname, join } from "path";
|
|
10
10
|
import { mkdir, readFile, readdir, rm } from "fs/promises";
|
|
@@ -8,8 +8,8 @@ import { init_kimi_coding, kimiCodingOAuthProvider } from "./kimi-coding.js";
|
|
|
8
8
|
import { init_minimax_cn, minimaxCnOAuthProvider } from "./minimax-cn.js";
|
|
9
9
|
import { init_minimax, minimaxOAuthProvider } from "./minimax.js";
|
|
10
10
|
import { init_openai_codex, loginOpenAICodex, openaiCodexOAuthProvider, refreshOpenAICodexToken } from "./openai-codex.js";
|
|
11
|
-
import { init_xopc_cloud, xopcCloudOAuthProvider } from "./xopc-cloud.js";
|
|
12
|
-
import { OAUTH_PROVIDER_DEFINITIONS, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, init_registry, isOAuthOnlyProvider } from "./registry.js";
|
|
11
|
+
import { init_xopc_cloud, xopcCloudOAuthProvider, xopcTunnelOAuthProvider } from "./xopc-cloud.js";
|
|
12
|
+
import { OAUTH_PROVIDER_DEFINITIONS, getModelOAuthProviderIds, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, init_registry, isOAuthOnlyProvider } from "./registry.js";
|
|
13
13
|
//#region src/auth/oauth/index.ts
|
|
14
14
|
init_anthropic();
|
|
15
15
|
init_minimax();
|
|
@@ -22,4 +22,4 @@ init_openai_codex();
|
|
|
22
22
|
init_xopc_cloud();
|
|
23
23
|
init_registry();
|
|
24
24
|
//#endregion
|
|
25
|
-
export { OAUTH_PROVIDER_DEFINITIONS, anthropicOAuthProvider, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, githubCopilotOAuthProvider, antigravityOAuthProvider as googleAntigravityOAuthProvider, geminiCliOAuthProvider as googleGeminiCliOAuthProvider, isOAuthOnlyProvider, kimiCodingOAuthProvider, loginAnthropic, loginAntigravity, loginGeminiCli, loginOpenAICodex, minimaxCnOAuthProvider, minimaxOAuthProvider, openaiCodexOAuthProvider, refreshAnthropicToken, refreshAntigravityToken, refreshGoogleCloudToken, refreshOpenAICodexToken, xopcCloudOAuthProvider };
|
|
25
|
+
export { OAUTH_PROVIDER_DEFINITIONS, anthropicOAuthProvider, getModelOAuthProviderIds, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, githubCopilotOAuthProvider, antigravityOAuthProvider as googleAntigravityOAuthProvider, geminiCliOAuthProvider as googleGeminiCliOAuthProvider, isOAuthOnlyProvider, kimiCodingOAuthProvider, loginAnthropic, loginAntigravity, loginGeminiCli, loginOpenAICodex, minimaxCnOAuthProvider, minimaxOAuthProvider, openaiCodexOAuthProvider, refreshAnthropicToken, refreshAntigravityToken, refreshGoogleCloudToken, refreshOpenAICodexToken, xopcCloudOAuthProvider, xopcTunnelOAuthProvider };
|
|
@@ -2,6 +2,7 @@ import type { OAuthProviderInterface } from './types.js';
|
|
|
2
2
|
export interface OAuthProviderDefinition {
|
|
3
3
|
displayName: string;
|
|
4
4
|
oauthOnly?: boolean;
|
|
5
|
+
purpose: 'models' | 'tunnel';
|
|
5
6
|
provider: OAuthProviderInterface;
|
|
6
7
|
profileId: string;
|
|
7
8
|
urlPrompt: string;
|
|
@@ -10,4 +11,5 @@ export declare const OAUTH_PROVIDER_DEFINITIONS: Readonly<Record<string, OAuthPr
|
|
|
10
11
|
export declare function getOAuthProviderDefinition(provider: string): OAuthProviderDefinition | undefined;
|
|
11
12
|
export declare function getOAuthProviderInterfaces(): Record<string, OAuthProviderInterface>;
|
|
12
13
|
export declare function getOAuthProviderIds(): string[];
|
|
14
|
+
export declare function getModelOAuthProviderIds(): string[];
|
|
13
15
|
export declare function isOAuthOnlyProvider(provider: string): boolean;
|
|
@@ -9,11 +9,12 @@ import { init_kimi_coding, kimiCodingOAuthProvider } from "./kimi-coding.js";
|
|
|
9
9
|
import { init_minimax_cn, minimaxCnOAuthProvider } from "./minimax-cn.js";
|
|
10
10
|
import { init_minimax, minimaxOAuthProvider } from "./minimax.js";
|
|
11
11
|
import { init_openai_codex, openaiCodexOAuthProvider } from "./openai-codex.js";
|
|
12
|
-
import { init_xopc_cloud, xopcCloudOAuthProvider } from "./xopc-cloud.js";
|
|
12
|
+
import { init_xopc_cloud, xopcCloudOAuthProvider, xopcTunnelOAuthProvider } from "./xopc-cloud.js";
|
|
13
13
|
//#region src/auth/oauth/registry.ts
|
|
14
|
-
function definition(provider, displayName = provider.name) {
|
|
14
|
+
function definition(provider, purpose, displayName = provider.name) {
|
|
15
15
|
return {
|
|
16
16
|
displayName,
|
|
17
|
+
purpose,
|
|
17
18
|
provider,
|
|
18
19
|
profileId: `${provider.id}:default`,
|
|
19
20
|
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
@@ -28,6 +29,9 @@ function getOAuthProviderInterfaces() {
|
|
|
28
29
|
function getOAuthProviderIds() {
|
|
29
30
|
return Object.keys(OAUTH_PROVIDER_DEFINITIONS);
|
|
30
31
|
}
|
|
32
|
+
function getModelOAuthProviderIds() {
|
|
33
|
+
return Object.entries(OAUTH_PROVIDER_DEFINITIONS).filter(([, definition]) => definition.purpose === "models").map(([id]) => id);
|
|
34
|
+
}
|
|
31
35
|
function isOAuthOnlyProvider(provider) {
|
|
32
36
|
return OAUTH_PROVIDER_DEFINITIONS[provider]?.oauthOnly === true;
|
|
33
37
|
}
|
|
@@ -44,22 +48,26 @@ var init_registry = __esmMin((() => {
|
|
|
44
48
|
init_xopc_cloud();
|
|
45
49
|
OAUTH_PROVIDER_DEFINITIONS = {
|
|
46
50
|
"xopc-cloud": {
|
|
47
|
-
...definition(xopcCloudOAuthProvider),
|
|
51
|
+
...definition(xopcCloudOAuthProvider, "models"),
|
|
52
|
+
oauthOnly: true
|
|
53
|
+
},
|
|
54
|
+
"xopc-tunnel": {
|
|
55
|
+
...definition(xopcTunnelOAuthProvider, "tunnel"),
|
|
48
56
|
oauthOnly: true
|
|
49
57
|
},
|
|
50
|
-
anthropic: definition(anthropicOAuthProvider, "Anthropic (Claude)"),
|
|
51
|
-
minimax: definition(minimaxOAuthProvider, "MiniMax (幂维智能)"),
|
|
58
|
+
anthropic: definition(anthropicOAuthProvider, "models", "Anthropic (Claude)"),
|
|
59
|
+
minimax: definition(minimaxOAuthProvider, "models", "MiniMax (幂维智能)"),
|
|
52
60
|
"minimax-cn": {
|
|
53
|
-
...definition(minimaxCnOAuthProvider, "MiniMax CN"),
|
|
61
|
+
...definition(minimaxCnOAuthProvider, "models", "MiniMax CN"),
|
|
54
62
|
urlPrompt: "🌐 请在浏览器中打开以下 URL:\n"
|
|
55
63
|
},
|
|
56
|
-
"kimi-coding": definition(kimiCodingOAuthProvider, "Kimi For Coding (月之暗面)"),
|
|
57
|
-
"github-copilot": definition(githubCopilotOAuthProvider),
|
|
58
|
-
"google-gemini-cli": definition(geminiCliOAuthProvider),
|
|
59
|
-
"google-antigravity": definition(antigravityOAuthProvider),
|
|
60
|
-
"openai-codex": definition(openaiCodexOAuthProvider)
|
|
64
|
+
"kimi-coding": definition(kimiCodingOAuthProvider, "models", "Kimi For Coding (月之暗面)"),
|
|
65
|
+
"github-copilot": definition(githubCopilotOAuthProvider, "models"),
|
|
66
|
+
"google-gemini-cli": definition(geminiCliOAuthProvider, "models"),
|
|
67
|
+
"google-antigravity": definition(antigravityOAuthProvider, "models"),
|
|
68
|
+
"openai-codex": definition(openaiCodexOAuthProvider, "models")
|
|
61
69
|
};
|
|
62
70
|
}));
|
|
63
71
|
//#endregion
|
|
64
72
|
init_registry();
|
|
65
|
-
export { OAUTH_PROVIDER_DEFINITIONS, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, init_registry, isOAuthOnlyProvider };
|
|
73
|
+
export { OAUTH_PROVIDER_DEFINITIONS, getModelOAuthProviderIds, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, init_registry, isOAuthOnlyProvider };
|
|
@@ -213,7 +213,7 @@ function callbackHtml(title, message, tone, returnToAppUrl) {
|
|
|
213
213
|
</body>
|
|
214
214
|
</html>`;
|
|
215
215
|
}
|
|
216
|
-
async function loginWithBrowser(callbacks) {
|
|
216
|
+
async function loginWithBrowser(callbacks, scope) {
|
|
217
217
|
if (callbacks.signal?.aborted) throw callbacks.signal.reason instanceof Error ? callbacks.signal.reason : /* @__PURE__ */ new Error("XOPC OAuth login cancelled");
|
|
218
218
|
const { verifier, challenge } = await generatePKCE();
|
|
219
219
|
const state = randomBytes(24).toString("base64url");
|
|
@@ -274,7 +274,7 @@ async function loginWithBrowser(callbacks) {
|
|
|
274
274
|
response_type: "code",
|
|
275
275
|
client_id: CLIENT_ID,
|
|
276
276
|
redirect_uri: redirectUri,
|
|
277
|
-
scope
|
|
277
|
+
scope,
|
|
278
278
|
code_challenge: challenge,
|
|
279
279
|
code_challenge_method: "S256",
|
|
280
280
|
state,
|
|
@@ -309,7 +309,7 @@ async function loginWithBrowser(callbacks) {
|
|
|
309
309
|
server.close();
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
async function loginWithDeviceCode(callbacks) {
|
|
312
|
+
async function loginWithDeviceCode(callbacks, scope) {
|
|
313
313
|
const response = await fetch(`${consoleUrl()}/oauth/device_authorization`, {
|
|
314
314
|
method: "POST",
|
|
315
315
|
headers: {
|
|
@@ -318,7 +318,7 @@ async function loginWithDeviceCode(callbacks) {
|
|
|
318
318
|
},
|
|
319
319
|
body: new URLSearchParams({
|
|
320
320
|
client_id: CLIENT_ID,
|
|
321
|
-
scope
|
|
321
|
+
scope,
|
|
322
322
|
device_name: hostname() || "XOPC client",
|
|
323
323
|
client_type: "cli"
|
|
324
324
|
}),
|
|
@@ -353,9 +353,9 @@ async function loginWithDeviceCode(callbacks) {
|
|
|
353
353
|
}
|
|
354
354
|
throw new Error("XOPC OAuth authorization expired");
|
|
355
355
|
}
|
|
356
|
-
async function login(callbacks) {
|
|
356
|
+
async function login(callbacks, options) {
|
|
357
357
|
return await callbacks.onSelect({
|
|
358
|
-
message:
|
|
358
|
+
message: `Choose how to authorize ${options.serviceName}`,
|
|
359
359
|
options: [{
|
|
360
360
|
id: "browser",
|
|
361
361
|
label: "Browser (recommended for this device)"
|
|
@@ -363,7 +363,7 @@ async function login(callbacks) {
|
|
|
363
363
|
id: "device_code",
|
|
364
364
|
label: "Device code (remote or headless)"
|
|
365
365
|
}]
|
|
366
|
-
}) === "device_code" ? loginWithDeviceCode(callbacks) : loginWithBrowser(callbacks);
|
|
366
|
+
}) === "device_code" ? loginWithDeviceCode(callbacks, options.scope) : loginWithBrowser(callbacks, options.scope);
|
|
367
367
|
}
|
|
368
368
|
async function refreshToken(current, signal) {
|
|
369
369
|
const response = await tokenRequest(new URLSearchParams({
|
|
@@ -375,23 +375,39 @@ async function refreshToken(current, signal) {
|
|
|
375
375
|
if (!response.ok) throw new Error(body.error_description ?? body.error ?? "XOPC OAuth refresh failed");
|
|
376
376
|
return credentials(body);
|
|
377
377
|
}
|
|
378
|
-
|
|
378
|
+
function createXopcOAuthProvider(options) {
|
|
379
|
+
return {
|
|
380
|
+
id: options.id,
|
|
381
|
+
name: options.name,
|
|
382
|
+
loginMethods: ["browser", "device_code"],
|
|
383
|
+
login: (callbacks) => login(callbacks, {
|
|
384
|
+
scope: options.scope,
|
|
385
|
+
serviceName: options.name
|
|
386
|
+
}),
|
|
387
|
+
refreshToken,
|
|
388
|
+
getApiKey: (value) => value.access
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
var CLIENT_ID, DEFAULT_CONSOLE_URL, MODEL_SERVICE_SCOPE, TUNNEL_REGISTRATION_SCOPE, CALLBACK_PATH, AUTHORIZATION_TIMEOUT_MS, xopcCloudOAuthProvider, xopcTunnelOAuthProvider;
|
|
379
392
|
var init_xopc_cloud = __esmMin((() => {
|
|
380
393
|
init_pkce();
|
|
381
394
|
CLIENT_ID = "xopc-native";
|
|
382
395
|
DEFAULT_CONSOLE_URL = "https://console.xopc.ai";
|
|
383
|
-
|
|
396
|
+
MODEL_SERVICE_SCOPE = "models:read models:invoke account:usage connectors:read connectors:manage connectors:execute offline_access";
|
|
397
|
+
TUNNEL_REGISTRATION_SCOPE = "tunnel:register";
|
|
384
398
|
CALLBACK_PATH = "/oauth/callback";
|
|
385
399
|
AUTHORIZATION_TIMEOUT_MS = 5 * 6e4;
|
|
386
|
-
xopcCloudOAuthProvider = {
|
|
400
|
+
xopcCloudOAuthProvider = createXopcOAuthProvider({
|
|
387
401
|
id: "xopc-cloud",
|
|
388
402
|
name: "XOPC Model Service",
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
403
|
+
scope: MODEL_SERVICE_SCOPE
|
|
404
|
+
});
|
|
405
|
+
xopcTunnelOAuthProvider = createXopcOAuthProvider({
|
|
406
|
+
id: "xopc-tunnel",
|
|
407
|
+
name: "XOPC Public Tunnel",
|
|
408
|
+
scope: TUNNEL_REGISTRATION_SCOPE
|
|
409
|
+
});
|
|
394
410
|
}));
|
|
395
411
|
//#endregion
|
|
396
412
|
init_xopc_cloud();
|
|
397
|
-
export { init_xopc_cloud, xopcCloudOAuthProvider };
|
|
413
|
+
export { init_xopc_cloud, xopcCloudOAuthProvider, xopcTunnelOAuthProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
2
1
|
import { init_paths, resolveCredentialsDir } from "../../config/paths.js";
|
|
2
|
+
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { chmodSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
5
5
|
//#region src/auth/profiles/store.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
2
3
|
import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveOAuthPath } from "../config/paths.js";
|
|
3
|
-
import { init_registry, isOAuthOnlyProvider } from "./oauth/registry.js";
|
|
4
4
|
import { init_loader, loadConfig } from "../config/loader.js";
|
|
5
|
-
import {
|
|
5
|
+
import { init_registry, isOAuthOnlyProvider } from "./oauth/registry.js";
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
7
|
//#region src/auth/sync-provider-auth.ts
|
|
8
8
|
/**
|
|
@@ -2,8 +2,8 @@ import { PACKAGE_VERSION, init_package_version } from "../../package-version.js"
|
|
|
2
2
|
import { createLogger } from "../../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../../utils/logger.js";
|
|
4
4
|
import { assertCacheDir, init_cache_dir_policy } from "../cache-dir-policy.js";
|
|
5
|
-
import { init_write_file_atomic, writeTextAtomic } from "../../infra/write-file-atomic.js";
|
|
6
5
|
import { init_paths, resolveBinDir } from "../../config/paths.js";
|
|
6
|
+
import { init_write_file_atomic, writeTextAtomic } from "../../infra/write-file-atomic.js";
|
|
7
7
|
import { shouldRunExtensionBridgeServer } from "../backend-from-config.js";
|
|
8
8
|
import { resolvePackageRoot } from "../../infra/update-check.js";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../../utils/logger.js";
|
|
1
3
|
import { decodeInboundAttachmentBase64, readInboundAttachmentBuffer } from "./inbound-persist.js";
|
|
2
4
|
import { transcribe } from "../../voice/stt/transcribe-core.js";
|
|
3
5
|
import { isSTTAvailable } from "../../voice/stt/availability.js";
|
|
4
6
|
import "../../voice/stt/index.js";
|
|
5
7
|
//#region src/channels/attachments/voice-stt-webchat.ts
|
|
8
|
+
init_logger();
|
|
6
9
|
const STT_MAX_BYTES = 25 * 1024 * 1024;
|
|
10
|
+
const log = createLogger("VoiceAttachmentSTT");
|
|
7
11
|
function isVoiceLikeAttachment(att) {
|
|
8
12
|
if (att.type === "voice") return true;
|
|
9
13
|
return (att.mimeType?.toLowerCase() ?? "").startsWith("audio/");
|
|
@@ -52,10 +56,23 @@ async function mergeVoiceTranscriptsIntoUserText(prepared, userText, sttConfig,
|
|
|
52
56
|
continue;
|
|
53
57
|
}
|
|
54
58
|
try {
|
|
55
|
-
const r = await transcribe(buf, sttConfig, {
|
|
59
|
+
const r = await transcribe(buf, sttConfig, {
|
|
60
|
+
language: sttConfig.provider === "alibaba" ? "zh" : void 0,
|
|
61
|
+
mime: att.mimeType,
|
|
62
|
+
fileName: att.name
|
|
63
|
+
});
|
|
56
64
|
transcripts.push(r.text.trim() || "[Voice: no speech detected]");
|
|
57
|
-
} catch {
|
|
58
|
-
|
|
65
|
+
} catch (error) {
|
|
66
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
67
|
+
log.error({
|
|
68
|
+
...error instanceof Error ? { err: error } : { errorMessage },
|
|
69
|
+
fileName: att.name,
|
|
70
|
+
mimeType: att.mimeType,
|
|
71
|
+
size: buf.length,
|
|
72
|
+
phase: "inbound_transcribe"
|
|
73
|
+
}, `Inbound voice transcription failed: ${errorMessage}`);
|
|
74
|
+
const decoderUnavailable = /ffmpeg|audio decoder|unsupported_audio_codec/i.test(errorMessage);
|
|
75
|
+
transcripts.push(decoderUnavailable ? "[STT failed: audio decoder unavailable]" : "[STT failed]");
|
|
59
76
|
}
|
|
60
77
|
}
|
|
61
78
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAgentDefaultModelRef, init_schema, parseModelRef } from "../../../../config/schema.js";
|
|
2
|
-
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "../../../../providers/env-keys.js";
|
|
3
2
|
import { init_loader, loadConfig } from "../../../../config/loader.js";
|
|
3
|
+
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "../../../../providers/env-keys.js";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
//#region src/cli/commands/doctor/checks/provider-auth.ts
|
|
6
6
|
init_loader();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
|
|
2
|
-
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
3
2
|
import { loadConfig, saveConfig } from "../../config/loader.js";
|
|
3
|
+
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
4
4
|
import { getAllModels, getAvailableModels, getConfiguredProviders, getProviderAuthState, getProviderDisplayName, init_providers, isProviderConfigured, providerSupportsApiKey, providerSupportsOAuth, resolveModel } from "../../providers/index.js";
|
|
5
5
|
import { formatExamples, register } from "../registry.js";
|
|
6
6
|
import { getContextWithOpts } from "../context.js";
|