@0xmaxma/claude-gateway 2.0.20 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/config.template.json +3 -2
- package/dist/agent/builtin-commands.d.ts +4 -0
- package/dist/agent/builtin-commands.d.ts.map +1 -1
- package/dist/agent/builtin-commands.js +11 -4
- package/dist/agent/builtin-commands.js.map +1 -1
- package/dist/agent/command-help.d.ts +11 -2
- package/dist/agent/command-help.d.ts.map +1 -1
- package/dist/agent/command-help.js +29 -8
- package/dist/agent/command-help.js.map +1 -1
- package/dist/agent/model-registry.d.ts +48 -0
- package/dist/agent/model-registry.d.ts.map +1 -0
- package/dist/agent/model-registry.js +144 -0
- package/dist/agent/model-registry.js.map +1 -0
- package/dist/agent/runner.d.ts +73 -43
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +361 -120
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/session-confirmations.d.ts +1 -1
- package/dist/agent/session-confirmations.d.ts.map +1 -1
- package/dist/agent/session-confirmations.js +5 -3
- package/dist/agent/session-confirmations.js.map +1 -1
- package/dist/agent/skill-learning/reviewer.d.ts.map +1 -1
- package/dist/agent/skill-learning/reviewer.js +2 -1
- package/dist/agent/skill-learning/reviewer.js.map +1 -1
- package/dist/agent/turn-stream.d.ts +2 -1
- package/dist/agent/turn-stream.d.ts.map +1 -1
- package/dist/agent/turn-stream.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +17 -1
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/manifest-sources.d.ts.map +1 -1
- package/dist/api/manifest-sources.js +3 -0
- package/dist/api/manifest-sources.js.map +1 -1
- package/dist/api/pstack-router.d.ts +14 -0
- package/dist/api/pstack-router.d.ts.map +1 -0
- package/dist/api/pstack-router.js +93 -0
- package/dist/api/pstack-router.js.map +1 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +32 -83
- package/dist/api/router.js.map +1 -1
- package/dist/api/voice-call-router.d.ts +21 -0
- package/dist/api/voice-call-router.d.ts.map +1 -0
- package/dist/api/voice-call-router.js +119 -0
- package/dist/api/voice-call-router.js.map +1 -0
- package/dist/api/voice-router.d.ts +27 -0
- package/dist/api/voice-router.d.ts.map +1 -1
- package/dist/api/voice-router.js +126 -63
- package/dist/api/voice-router.js.map +1 -1
- package/dist/api/voice-settings-router.d.ts.map +1 -1
- package/dist/api/voice-settings-router.js +3 -1
- package/dist/api/voice-settings-router.js.map +1 -1
- package/dist/automation/computer-use.d.ts.map +1 -1
- package/dist/automation/computer-use.js +8 -1
- package/dist/automation/computer-use.js.map +1 -1
- package/dist/build-provenance.json +4 -4
- package/dist/cli/commands.generated.d.ts.map +1 -1
- package/dist/cli/commands.generated.js +36 -1
- package/dist/cli/commands.generated.js.map +1 -1
- package/dist/cli-viewer/pairing-store.d.ts +4 -0
- package/dist/cli-viewer/pairing-store.d.ts.map +1 -1
- package/dist/cli-viewer/pairing-store.js +6 -6
- package/dist/cli-viewer/pairing-store.js.map +1 -1
- package/dist/cli-viewer/telegram-initdata.d.ts +1 -1
- package/dist/cli-viewer/telegram-initdata.d.ts.map +1 -1
- package/dist/cli-viewer/telegram-initdata.js +2 -2
- package/dist/cli-viewer/telegram-initdata.js.map +1 -1
- package/dist/cli-viewer/url.d.ts +2 -0
- package/dist/cli-viewer/url.d.ts.map +1 -1
- package/dist/cli-viewer/url.js +6 -0
- package/dist/cli-viewer/url.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +7 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/reload-policy.js +1 -1
- package/dist/config/reload-policy.js.map +1 -1
- package/dist/config/watcher.d.ts.map +1 -1
- package/dist/config/watcher.js +2 -0
- package/dist/config/watcher.js.map +1 -1
- package/dist/orchestration/agent-tool-schemas.js +1 -1
- package/dist/orchestration/agent-tool-schemas.js.map +1 -1
- package/dist/orchestration/bridge.d.ts +6 -2
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +122 -6
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/capabilities.d.ts.map +1 -1
- package/dist/orchestration/capabilities.js +10 -3
- package/dist/orchestration/capabilities.js.map +1 -1
- package/dist/orchestration/capacity.d.ts +9 -2
- package/dist/orchestration/capacity.d.ts.map +1 -1
- package/dist/orchestration/capacity.js +18 -7
- package/dist/orchestration/capacity.js.map +1 -1
- package/dist/orchestration/cli-skills.d.ts.map +1 -1
- package/dist/orchestration/cli-skills.js +4 -2
- package/dist/orchestration/cli-skills.js.map +1 -1
- package/dist/orchestration/config.d.ts +47 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +25 -4
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/conversation-intake.d.ts.map +1 -1
- package/dist/orchestration/conversation-intake.js +3 -1
- package/dist/orchestration/conversation-intake.js.map +1 -1
- package/dist/orchestration/dashboard-reader-worker.js +5 -3
- package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
- package/dist/orchestration/decisions.d.ts.map +1 -1
- package/dist/orchestration/decisions.js +4 -2
- package/dist/orchestration/decisions.js.map +1 -1
- package/dist/orchestration/delivery.d.ts.map +1 -1
- package/dist/orchestration/delivery.js +1 -0
- package/dist/orchestration/delivery.js.map +1 -1
- package/dist/orchestration/display-stream.d.ts +6 -0
- package/dist/orchestration/display-stream.d.ts.map +1 -1
- package/dist/orchestration/display-stream.js +13 -8
- package/dist/orchestration/display-stream.js.map +1 -1
- package/dist/orchestration/gateway-tasks/computer.d.ts +2 -0
- package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/computer.js +68 -28
- package/dist/orchestration/gateway-tasks/computer.js.map +1 -1
- package/dist/orchestration/gateway-tasks/controller.d.ts +6 -6
- package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -1
- package/dist/orchestration/identity.d.ts +5 -1
- package/dist/orchestration/identity.d.ts.map +1 -1
- package/dist/orchestration/identity.js +6 -0
- package/dist/orchestration/identity.js.map +1 -1
- package/dist/orchestration/input-batch.d.ts +8 -2
- package/dist/orchestration/input-batch.d.ts.map +1 -1
- package/dist/orchestration/input-batch.js +28 -8
- package/dist/orchestration/input-batch.js.map +1 -1
- package/dist/orchestration/live-voice-transcript.d.ts +13 -0
- package/dist/orchestration/live-voice-transcript.d.ts.map +1 -0
- package/dist/orchestration/live-voice-transcript.js +36 -0
- package/dist/orchestration/live-voice-transcript.js.map +1 -0
- package/dist/orchestration/mutation-recovery.js +1 -1
- package/dist/orchestration/mutation-recovery.js.map +1 -1
- package/dist/orchestration/notification-mailbox.d.ts.map +1 -1
- package/dist/orchestration/notification-mailbox.js +4 -2
- package/dist/orchestration/notification-mailbox.js.map +1 -1
- package/dist/orchestration/process-turn.d.ts +6 -1
- package/dist/orchestration/process-turn.d.ts.map +1 -1
- package/dist/orchestration/process-turn.js +9 -5
- package/dist/orchestration/process-turn.js.map +1 -1
- package/dist/orchestration/recovery.d.ts.map +1 -1
- package/dist/orchestration/recovery.js +21 -0
- package/dist/orchestration/recovery.js.map +1 -1
- package/dist/orchestration/response-errors.d.ts +5 -0
- package/dist/orchestration/response-errors.d.ts.map +1 -1
- package/dist/orchestration/response-errors.js +25 -0
- package/dist/orchestration/response-errors.js.map +1 -1
- package/dist/orchestration/runtime.d.ts +26 -2
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +221 -48
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/speech.d.ts +3 -0
- package/dist/orchestration/speech.d.ts.map +1 -1
- package/dist/orchestration/speech.js +13 -5
- package/dist/orchestration/speech.js.map +1 -1
- package/dist/orchestration/store.d.ts +5 -0
- package/dist/orchestration/store.d.ts.map +1 -1
- package/dist/orchestration/store.js +13 -5
- package/dist/orchestration/store.js.map +1 -1
- package/dist/orchestration/subagent-tool-schemas.d.ts +12 -0
- package/dist/orchestration/subagent-tool-schemas.d.ts.map +1 -0
- package/dist/orchestration/subagent-tool-schemas.js +23 -0
- package/dist/orchestration/subagent-tool-schemas.js.map +1 -0
- package/dist/orchestration/task-controls.d.ts.map +1 -1
- package/dist/orchestration/task-controls.js +2 -1
- package/dist/orchestration/task-controls.js.map +1 -1
- package/dist/orchestration/task-questions.d.ts.map +1 -1
- package/dist/orchestration/task-questions.js +3 -1
- package/dist/orchestration/task-questions.js.map +1 -1
- package/dist/orchestration/tasks/automation-session.d.ts +12 -0
- package/dist/orchestration/tasks/automation-session.d.ts.map +1 -1
- package/dist/orchestration/tasks/automation-session.js +26 -1
- package/dist/orchestration/tasks/automation-session.js.map +1 -1
- package/dist/orchestration/tasks/driver.d.ts.map +1 -1
- package/dist/orchestration/tasks/driver.js +54 -14
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/tasks/scheduler.d.ts.map +1 -1
- package/dist/orchestration/tasks/scheduler.js +17 -3
- package/dist/orchestration/tasks/scheduler.js.map +1 -1
- package/dist/orchestration/tasks/service.d.ts +110 -34
- package/dist/orchestration/tasks/service.d.ts.map +1 -1
- package/dist/orchestration/tasks/service.js +234 -19
- package/dist/orchestration/tasks/service.js.map +1 -1
- package/dist/orchestration/tasks/task-directive.d.ts.map +1 -1
- package/dist/orchestration/tasks/task-directive.js +5 -1
- package/dist/orchestration/tasks/task-directive.js.map +1 -1
- package/dist/orchestration/telegram-tool-status.d.ts +8 -1
- package/dist/orchestration/telegram-tool-status.d.ts.map +1 -1
- package/dist/orchestration/telegram-tool-status.js +57 -6
- package/dist/orchestration/telegram-tool-status.js.map +1 -1
- package/dist/orchestration/telegram-voices.d.ts +4 -0
- package/dist/orchestration/telegram-voices.d.ts.map +1 -1
- package/dist/orchestration/telegram-voices.js +6 -2
- package/dist/orchestration/telegram-voices.js.map +1 -1
- package/dist/orchestration/token-ledger.d.ts +14 -0
- package/dist/orchestration/token-ledger.d.ts.map +1 -1
- package/dist/orchestration/token-ledger.js +28 -2
- package/dist/orchestration/token-ledger.js.map +1 -1
- package/dist/orchestration/token-usage.d.ts +14 -0
- package/dist/orchestration/token-usage.d.ts.map +1 -1
- package/dist/orchestration/token-usage.js +16 -2
- package/dist/orchestration/token-usage.js.map +1 -1
- package/dist/orchestration/tool-name.d.ts.map +1 -1
- package/dist/orchestration/tool-name.js +5 -1
- package/dist/orchestration/tool-name.js.map +1 -1
- package/dist/orchestration/types.d.ts +29 -0
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/orchestration/types.js +11 -0
- package/dist/orchestration/types.js.map +1 -1
- package/dist/orchestration/worker-harness.d.ts.map +1 -1
- package/dist/orchestration/worker-harness.js +5 -2
- package/dist/orchestration/worker-harness.js.map +1 -1
- package/dist/pstack/config.d.ts +48 -0
- package/dist/pstack/config.d.ts.map +1 -0
- package/dist/pstack/config.js +147 -0
- package/dist/pstack/config.js.map +1 -0
- package/dist/pstack/menu.d.ts +71 -0
- package/dist/pstack/menu.d.ts.map +1 -0
- package/dist/pstack/menu.js +286 -0
- package/dist/pstack/menu.js.map +1 -0
- package/dist/pstack/overlay.d.ts +30 -0
- package/dist/pstack/overlay.d.ts.map +1 -0
- package/dist/pstack/overlay.js +121 -0
- package/dist/pstack/overlay.js.map +1 -0
- package/dist/pstack/plugin-info.d.ts +36 -0
- package/dist/pstack/plugin-info.d.ts.map +1 -0
- package/dist/pstack/plugin-info.js +51 -0
- package/dist/pstack/plugin-info.js.map +1 -0
- package/dist/pstack/reflect.d.ts +14 -0
- package/dist/pstack/reflect.d.ts.map +1 -0
- package/dist/pstack/reflect.js +49 -0
- package/dist/pstack/reflect.js.map +1 -0
- package/dist/pstack/setup.d.ts +17 -0
- package/dist/pstack/setup.d.ts.map +1 -0
- package/dist/pstack/setup.js +47 -0
- package/dist/pstack/setup.js.map +1 -0
- package/dist/pstack/sheet.d.ts +19 -0
- package/dist/pstack/sheet.d.ts.map +1 -0
- package/dist/pstack/sheet.js +44 -0
- package/dist/pstack/sheet.js.map +1 -0
- package/dist/pstack/templates.d.ts +14 -0
- package/dist/pstack/templates.d.ts.map +1 -0
- package/dist/pstack/templates.js +41 -0
- package/dist/pstack/templates.js.map +1 -0
- package/dist/session/codex-process.d.ts +0 -3
- package/dist/session/codex-process.d.ts.map +1 -1
- package/dist/session/codex-process.js +8 -3
- package/dist/session/codex-process.js.map +1 -1
- package/dist/session/compactor.d.ts.map +1 -1
- package/dist/session/compactor.js +2 -1
- package/dist/session/compactor.js.map +1 -1
- package/dist/session/process-diagnostics.d.ts +3 -0
- package/dist/session/process-diagnostics.d.ts.map +1 -1
- package/dist/session/process-diagnostics.js +10 -0
- package/dist/session/process-diagnostics.js.map +1 -1
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +9 -4
- package/dist/session/process.js.map +1 -1
- package/dist/session/provider-refusal.d.ts +36 -0
- package/dist/session/provider-refusal.d.ts.map +1 -0
- package/dist/session/provider-refusal.js +109 -0
- package/dist/session/provider-refusal.js.map +1 -0
- package/dist/session/runtime-profile.d.ts +13 -2
- package/dist/session/runtime-profile.d.ts.map +1 -1
- package/dist/session/runtime-profile.js +35 -2
- package/dist/session/runtime-profile.js.map +1 -1
- package/dist/session/worker-extensions.d.ts +5 -2
- package/dist/session/worker-extensions.d.ts.map +1 -1
- package/dist/session/worker-extensions.js +10 -5
- package/dist/session/worker-extensions.js.map +1 -1
- package/dist/telegram/access.d.ts +23 -0
- package/dist/telegram/access.d.ts.map +1 -0
- package/dist/telegram/access.js +105 -0
- package/dist/telegram/access.js.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/cli-viewer-ui.d.ts +5 -0
- package/dist/ui/cli-viewer-ui.d.ts.map +1 -1
- package/dist/ui/cli-viewer-ui.js +9 -6
- package/dist/ui/cli-viewer-ui.js.map +1 -1
- package/dist/ui/dashboard-client.d.ts.map +1 -1
- package/dist/ui/dashboard-client.js +14 -4
- package/dist/ui/dashboard-client.js.map +1 -1
- package/dist/ui/dashboard-presentation.d.ts +29 -0
- package/dist/ui/dashboard-presentation.d.ts.map +1 -1
- package/dist/ui/dashboard-presentation.js +26 -1
- package/dist/ui/dashboard-presentation.js.map +1 -1
- package/dist/ui/token-report.d.ts +3 -0
- package/dist/ui/token-report.d.ts.map +1 -1
- package/dist/ui/token-report.js +1 -1
- package/dist/ui/token-report.js.map +1 -1
- package/dist/ui/voice-call-client.d.ts +142 -0
- package/dist/ui/voice-call-client.d.ts.map +1 -0
- package/dist/ui/voice-call-client.js +328 -0
- package/dist/ui/voice-call-client.js.map +1 -0
- package/dist/ui/voice-call-ui.d.ts +21 -0
- package/dist/ui/voice-call-ui.d.ts.map +1 -0
- package/dist/ui/voice-call-ui.js +488 -0
- package/dist/ui/voice-call-ui.js.map +1 -0
- package/dist/voice/audio-tags.d.ts +7 -0
- package/dist/voice/audio-tags.d.ts.map +1 -0
- package/dist/voice/audio-tags.js +66 -0
- package/dist/voice/audio-tags.js.map +1 -0
- package/dist/voice/call-pairing.d.ts +76 -0
- package/dist/voice/call-pairing.d.ts.map +1 -0
- package/dist/voice/call-pairing.js +126 -0
- package/dist/voice/call-pairing.js.map +1 -0
- package/dist/voice/diagnostics.d.ts +12 -9
- package/dist/voice/diagnostics.d.ts.map +1 -1
- package/dist/voice/diagnostics.js +2 -1
- package/dist/voice/diagnostics.js.map +1 -1
- package/dist/voice/errors.d.ts +6 -1
- package/dist/voice/errors.d.ts.map +1 -1
- package/dist/voice/errors.js +12 -1
- package/dist/voice/errors.js.map +1 -1
- package/dist/voice/fast-ack.d.ts +27 -0
- package/dist/voice/fast-ack.d.ts.map +1 -0
- package/dist/voice/fast-ack.js +52 -0
- package/dist/voice/fast-ack.js.map +1 -0
- package/dist/voice/managed-quota.d.ts +29 -3
- package/dist/voice/managed-quota.d.ts.map +1 -1
- package/dist/voice/managed-quota.js +68 -23
- package/dist/voice/managed-quota.js.map +1 -1
- package/dist/voice/notes.d.ts +27 -3
- package/dist/voice/notes.d.ts.map +1 -1
- package/dist/voice/notes.js +59 -10
- package/dist/voice/notes.js.map +1 -1
- package/dist/voice/providers/elevenlabs-tts.d.ts +1 -0
- package/dist/voice/providers/elevenlabs-tts.d.ts.map +1 -1
- package/dist/voice/providers/elevenlabs-tts.js +62 -12
- package/dist/voice/providers/elevenlabs-tts.js.map +1 -1
- package/dist/voice/providers/gemini.d.ts +4 -0
- package/dist/voice/providers/gemini.d.ts.map +1 -1
- package/dist/voice/providers/gemini.js +7 -1
- package/dist/voice/providers/gemini.js.map +1 -1
- package/dist/voice/providers/registry.d.ts.map +1 -1
- package/dist/voice/providers/registry.js +34 -2
- package/dist/voice/providers/registry.js.map +1 -1
- package/dist/voice/scope.d.ts +13 -0
- package/dist/voice/scope.d.ts.map +1 -0
- package/dist/voice/scope.js +3 -0
- package/dist/voice/scope.js.map +1 -0
- package/dist/voice/session.d.ts +16 -1
- package/dist/voice/session.d.ts.map +1 -1
- package/dist/voice/session.js +90 -16
- package/dist/voice/session.js.map +1 -1
- package/dist/voice/telegram-avatar.d.ts +38 -0
- package/dist/voice/telegram-avatar.d.ts.map +1 -0
- package/dist/voice/telegram-avatar.js +95 -0
- package/dist/voice/telegram-avatar.js.map +1 -0
- package/mcp/lazy-tools.ts +4 -2
- package/mcp/server.ts +6 -2
- package/mcp/tools/tasks/module.ts +3 -1
- package/mcp/tools/telegram/pstack-menu.ts +22 -0
- package/mcp/tools/telegram/pure.ts +40 -0
- package/mcp/tools/telegram/receiver-server.ts +86 -7
- package/package.json +1 -1
package/dist/agent/runner.js
CHANGED
|
@@ -42,6 +42,7 @@ const config_1 = require("./dreaming/config");
|
|
|
42
42
|
const response_errors_1 = require("../orchestration/response-errors");
|
|
43
43
|
const channel_media_error_1 = require("../orchestration/channel-media-error");
|
|
44
44
|
const store_1 = require("../orchestration/store");
|
|
45
|
+
const identity_1 = require("../orchestration/identity");
|
|
45
46
|
const config_2 = require("../orchestration/config");
|
|
46
47
|
const channel_input_media_1 = require("../orchestration/channel-input-media");
|
|
47
48
|
const chunks_1 = require("../telegram/chunks");
|
|
@@ -89,6 +90,7 @@ const incident_1 = require("./incident");
|
|
|
89
90
|
const pty_stream_registry_1 = require("../shell/pty-stream-registry");
|
|
90
91
|
const pairing_store_1 = require("../cli-viewer/pairing-store");
|
|
91
92
|
const url_1 = require("../cli-viewer/url");
|
|
93
|
+
const call_pairing_1 = require("../voice/call-pairing");
|
|
92
94
|
const screen_1 = require("../shell/screen");
|
|
93
95
|
const db_1 = require("../history/db");
|
|
94
96
|
const media_store_1 = require("../history/media-store");
|
|
@@ -111,60 +113,16 @@ const ANTHROPIC_SOCKET_ERROR = 'socket connection was closed unexpectedly';
|
|
|
111
113
|
// a cap higher than it.
|
|
112
114
|
const TOO_LARGE_HISTORY_LADDER = [process_1.MAX_HISTORY_MESSAGES, 40, 30, 20, 10, 0];
|
|
113
115
|
exports.MAX_IMAGE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// migrateModels(). Nobody is moved onto 5.1 by this change.
|
|
125
|
-
//
|
|
126
|
-
// Both Fable 5.x entries carry the same 200k/1M split as the rest: their CLI
|
|
127
|
-
// catalog entry says `native_1m`, but native 1M only applies when the base URL
|
|
128
|
-
// is api.anthropic.com. Behind a proxy the `[1m]` id suffix and the
|
|
129
|
-
// `context-1m-2025-08-07` beta header are what actually buy the larger window,
|
|
130
|
-
// which is exactly what the paired rows below encode.
|
|
131
|
-
//
|
|
132
|
-
// Opus 5.5 (`claude-opus-5-5`) follows the same convention on its own family:
|
|
133
|
-
// it takes the bare `opus` alias and Opus 5 is demoted to `opus5`, mirroring
|
|
134
|
-
// the Opus 5 -> Opus 4.8 demotion above and the Fable 5.1 -> Fable 5 one.
|
|
135
|
-
// Selection still stores the resolved id, so an agent already on Opus 5 stays
|
|
136
|
-
// on claude-opus-5 — only `/model opus` from now on resolves to 5.5.
|
|
137
|
-
//
|
|
138
|
-
// Sonnet 5.5 (`claude-sonnet-5-5`) does the same on the Sonnet family: it takes
|
|
139
|
-
// `sonnet` / `sonnet[1m]` and Sonnet 5 is demoted to `sonnet5` / `sonnet5[1m]`;
|
|
140
|
-
// Sonnet 4.6 keeps `sonnet46`. An agent already on Sonnet 5 stays on
|
|
141
|
-
// claude-sonnet-5.
|
|
142
|
-
exports.DEFAULT_MODELS = [
|
|
143
|
-
{ id: 'claude-fable-5-1[1m]', label: 'Fable 5.1 (1M)', alias: 'fable[1m]', contextWindow: 1000000 },
|
|
144
|
-
{ id: 'claude-fable-5[1m]', label: 'Fable 5 (1M)', alias: 'fable5[1m]', contextWindow: 1000000 },
|
|
145
|
-
{ id: 'claude-opus-5-5[1m]', label: 'Opus 5.5 (1M)', alias: 'opus[1m]', contextWindow: 1000000 },
|
|
146
|
-
{ id: 'claude-opus-5[1m]', label: 'Opus 5 (1M)', alias: 'opus5[1m]', contextWindow: 1000000 },
|
|
147
|
-
{ id: 'claude-opus-4-8[1m]', label: 'Opus 4.8 (1M)', alias: 'opus48[1m]', contextWindow: 1000000 },
|
|
148
|
-
{ id: 'claude-sonnet-5-5[1m]', label: 'Sonnet 5.5 (1M)', alias: 'sonnet[1m]', contextWindow: 1000000 },
|
|
149
|
-
{ id: 'claude-sonnet-5[1m]', label: 'Sonnet 5 (1M)', alias: 'sonnet5[1m]', contextWindow: 1000000 },
|
|
150
|
-
{ id: 'claude-fable-5-1', label: 'Fable 5.1', alias: 'fable', contextWindow: 200000 },
|
|
151
|
-
{ id: 'claude-fable-5', label: 'Fable 5', alias: 'fable5', contextWindow: 200000 },
|
|
152
|
-
{ id: 'claude-opus-5-5', label: 'Opus 5.5', alias: 'opus', contextWindow: 200000 },
|
|
153
|
-
{ id: 'claude-opus-5', label: 'Opus 5', alias: 'opus5', contextWindow: 200000 },
|
|
154
|
-
{ id: 'claude-opus-4-8', label: 'Opus 4.8', alias: 'opus48', contextWindow: 200000 },
|
|
155
|
-
{ id: 'claude-opus-4-6', label: 'Opus 4.6', alias: 'opus46', contextWindow: 200000 },
|
|
156
|
-
{ id: 'claude-sonnet-5-5', label: 'Sonnet 5.5', alias: 'sonnet', contextWindow: 200000 },
|
|
157
|
-
{ id: 'claude-sonnet-5', label: 'Sonnet 5', alias: 'sonnet5', contextWindow: 200000 },
|
|
158
|
-
{ id: 'claude-sonnet-4-6', label: 'Sonnet 4.6', alias: 'sonnet46', contextWindow: 200000 },
|
|
159
|
-
{ id: 'claude-haiku-4-5-20251001', label: 'Haiku 4.5', alias: 'haiku', contextWindow: 200000 },
|
|
160
|
-
{ id: 'gpt-6-sol[1m]', label: 'GPT 6 Sol', alias: 'gpt6sol', contextWindow: 1050000 },
|
|
161
|
-
{ id: 'gpt-6-astra[1m]', label: 'GPT 6 Astra', alias: 'gpt6astra', contextWindow: 1050000 },
|
|
162
|
-
{ id: 'gpt-6-luna[1m]', label: 'GPT 6 Luna', alias: 'gpt6luna', contextWindow: 1050000 },
|
|
163
|
-
{ id: 'gpt-5.6-sol[1m]', label: 'GPT 5.6 Sol', alias: 'gpt56sol', contextWindow: 1050000 },
|
|
164
|
-
{ id: 'gpt-5.6-terra[1m]', label: 'GPT 5.6 Terra', alias: 'gpt56terra', contextWindow: 1050000 },
|
|
165
|
-
{ id: 'gpt-5.6-luna[1m]', label: 'GPT 5.6 Luna', alias: 'gpt56luna', contextWindow: 1050000 },
|
|
166
|
-
{ id: 'gpt-5.5[1m]', label: 'GPT 5.5', alias: 'gpt55', contextWindow: 1050000 },
|
|
167
|
-
];
|
|
116
|
+
var model_registry_1 = require("./model-registry");
|
|
117
|
+
Object.defineProperty(exports, "DEFAULT_MODELS", { enumerable: true, get: function () { return model_registry_1.DEFAULT_MODELS; } });
|
|
118
|
+
const model_registry_2 = require("./model-registry");
|
|
119
|
+
const plugin_info_1 = require("../pstack/plugin-info");
|
|
120
|
+
const config_4 = require("../pstack/config");
|
|
121
|
+
const sheet_1 = require("../pstack/sheet");
|
|
122
|
+
const setup_1 = require("../pstack/setup");
|
|
123
|
+
const menu_1 = require("../pstack/menu");
|
|
124
|
+
const PSTACK_WRITE_REQUIRED = 'Changing the pstack setup needs an API key with write access to this agent. /pstack-setup without arguments shows it.';
|
|
125
|
+
const PSTACK_SETUP_USAGE = 'Usage: /pstack-setup on | off | <role>: <model-id>[ @<level>] (one per line; "<role>: default" drops an override; "<role> += <model-id>[ @<level>]" / "<role> -= <model-id>" edit a panel list; "default effort: <level|session>").';
|
|
168
126
|
const PROTECTED_WORKSPACE_FILES = [
|
|
169
127
|
'AGENTS.md', 'SOUL.md', 'MEMORY.md', 'CLAUDE.md',
|
|
170
128
|
'IDENTITY.md', 'USER.md', 'HEARTBEAT.md',
|
|
@@ -197,10 +155,10 @@ const RECOVERY_TRIAGE_TIMEOUT_MS = 15000;
|
|
|
197
155
|
// 30s cooldown), so anything older is a finished turn — pruned to keep the
|
|
198
156
|
// budget map from growing unbounded over a long-lived runner (Epic #195, 3b).
|
|
199
157
|
const RECOVERY_BUDGET_TTL_MS = 10 * 60000;
|
|
200
|
-
// Trailing-edge window for coalescing channel messages
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
158
|
+
// Trailing-edge window for coalescing consecutive channel messages (text, images,
|
|
159
|
+
// client-split long text, photo+caption) into a single turn. Reset on every new
|
|
160
|
+
// update, so an album burst or a client-split message is gathered whole. Every
|
|
161
|
+
// non-command message waits this window before its turn starts.
|
|
204
162
|
exports.CHANNEL_COALESCE_WINDOW_MS = 1200;
|
|
205
163
|
/**
|
|
206
164
|
* Move UI-uploaded files from staging (ui-upload/) to permanent per-session storage
|
|
@@ -397,20 +355,47 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
397
355
|
async authorizeVoiceSession(sessionId, principalId) {
|
|
398
356
|
(await this.getOrchestration()).authorizeSession(sessionId, principalId);
|
|
399
357
|
}
|
|
358
|
+
async voiceTts(scope, tts) {
|
|
359
|
+
return (await this.getOrchestration()).telegramVoices.forScope(scope, tts);
|
|
360
|
+
}
|
|
400
361
|
async subscribeVoiceResults(sessionId, principalId, receive, gender) {
|
|
401
362
|
return (await this.getOrchestration()).subscribeVoiceResults(sessionId, principalId, receive, gender);
|
|
402
363
|
}
|
|
403
364
|
recordVoicePlayback(responseId, principalId, progress, state) {
|
|
404
365
|
this.orchestration?.recordPlayback(responseId, principalId, progress, state);
|
|
405
366
|
}
|
|
406
|
-
|
|
367
|
+
/** The Telegram session a DM call speaks in: the chat's active session, as for typed messages. */
|
|
368
|
+
async telegramVoiceSession(chatId) {
|
|
369
|
+
return this.sessionStore.getActiveSessionId(this.agentConfig.id, chatId, 'telegram');
|
|
370
|
+
}
|
|
371
|
+
/** A `/call` ended: a system notice with its length in the DM (or topic) the call joined. */
|
|
372
|
+
async notifyVoiceCallEnded(sessionId, scope, durationMs) {
|
|
373
|
+
const orchestration = await this.getOrchestration();
|
|
374
|
+
await orchestration.notifyChat(sessionId, 'telegram', scope.chatId, scope.threadKey, (0, call_pairing_1.voiceCallEndedText)(durationMs));
|
|
375
|
+
}
|
|
376
|
+
async submitVoiceUtterance(sessionId, voiceScope, text, utteranceId, allowTools, model, executionTaskId, onMark) {
|
|
407
377
|
if (!this.agentConfig.orchestration?.enabled || !this.agentConfig.voice?.enabled)
|
|
408
378
|
throw new Error('Voice is disabled');
|
|
409
|
-
|
|
410
|
-
|
|
379
|
+
const { chatId, principalId } = voiceScope;
|
|
380
|
+
let scope;
|
|
381
|
+
if (voiceScope.kind === 'telegram') {
|
|
382
|
+
// The call joins the DM it was opened from: the same conversation, delivery
|
|
383
|
+
// binding and membership as a message typed in that chat.
|
|
384
|
+
if (!(0, call_pairing_1.telegramVoiceCallsEnabled)(this.agentConfig))
|
|
385
|
+
throw new Error('Voice is disabled');
|
|
386
|
+
// /new or a session switch moves the chat; the call must not keep talking to the old session.
|
|
387
|
+
if (await this.telegramVoiceSession(chatId) !== sessionId)
|
|
388
|
+
throw Object.assign(new Error('Voice session changed'), { code: 'VOICE_SESSION_CHANGED' });
|
|
389
|
+
scope = (0, identity_1.channelScope)(this.agentConfig.id, sessionId, 'telegram', chatId, voiceScope.threadKey, principalId.slice('telegram:'.length));
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
if (!(await this.apiSessionExists(chatId, sessionId)))
|
|
393
|
+
throw new Error('Session not found');
|
|
394
|
+
scope = { agentId: this.agentConfig.id, agentSessionId: sessionId, source: 'api', accountId: principalId, chatId, threadKey: '', principalId };
|
|
395
|
+
}
|
|
411
396
|
const orchestration = await this.getOrchestration();
|
|
412
|
-
const accepted = orchestration.submitInput({ scope
|
|
413
|
-
|
|
397
|
+
const accepted = orchestration.submitInput({ scope, text, model, metadata: { executionTaskId }, modality: 'live_voice', ingressKey: `utterance:${utteranceId}`,
|
|
398
|
+
...(voiceScope.kind === 'telegram' ? { trustedChannelMember: true } : {}) }, { execute: allowTools, writeMemory: false }, undefined, onMark);
|
|
414
399
|
// The browser refreshes history on utterance.accepted, before inference finishes.
|
|
415
400
|
await orchestration.flushHistory();
|
|
416
401
|
return { ...accepted, responseId: () => orchestration.responseIdForInput(accepted.inputId) };
|
|
@@ -753,7 +738,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
753
738
|
catch { /* already gone */ }
|
|
754
739
|
finish({ stdout: '', timedOut: true });
|
|
755
740
|
}, RECOVERY_TRIAGE_TIMEOUT_MS);
|
|
756
|
-
const child = spawn('claude', ['-p', '--output-format', 'text'], {
|
|
741
|
+
const child = spawn('claude', ['-p', '--output-format', 'text', '--settings', JSON.stringify(plugin_info_1.PSTACK_OFF_SETTINGS)], {
|
|
757
742
|
stdio: ['pipe', 'pipe', 'ignore'],
|
|
758
743
|
});
|
|
759
744
|
child.stdout?.on('data', (d) => { out += String(d); });
|
|
@@ -903,8 +888,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
903
888
|
const sessionId = await this.sessionStore.getActiveSessionId(this.agentConfig.id, chatId, channelSource);
|
|
904
889
|
const runtime = await this.getOrchestration();
|
|
905
890
|
const senderId = meta.user_id ?? meta.user ?? chatId;
|
|
906
|
-
const scope =
|
|
907
|
-
accountId: this.agentConfig.id, chatId, threadKey: channelSource === 'whatsapp' && meta.account_id ? `whatsapp-account:${meta.account_id}` : meta.thread_ts ?? meta.message_thread_id ?? '', principalId: `${channelSource}:${senderId}` };
|
|
891
|
+
const scope = (0, identity_1.channelScope)(this.agentConfig.id, sessionId, channelSource, chatId, channelSource === 'whatsapp' && meta.account_id ? `whatsapp-account:${meta.account_id}` : meta.thread_ts ?? meta.message_thread_id ?? '', senderId);
|
|
908
892
|
const { ingress_recovery_batch, ...originalMeta } = meta;
|
|
909
893
|
let recoveryBatch = ingress_recovery_batch, recoveryKey = meta.message_id;
|
|
910
894
|
const fingerprint = (0, store_1.payloadHash)({ content, meta: originalMeta });
|
|
@@ -1384,6 +1368,42 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
1384
1368
|
}
|
|
1385
1369
|
return;
|
|
1386
1370
|
}
|
|
1371
|
+
if (command === 'telegram_pstack') {
|
|
1372
|
+
// A private chat's id is its user's id, as for every Telegram menu here.
|
|
1373
|
+
const chatId = body.chat_id ?? '', payload = body.payload ?? {};
|
|
1374
|
+
if (!/^\d+$/.test(chatId) || payload.user_id !== chatId || typeof payload.data !== 'string' || !/^ps:[\x21-\x7e]{1,61}$/.test(payload.data)) {
|
|
1375
|
+
respond({ success: false }, 400);
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
try {
|
|
1379
|
+
respond({ success: true, ...await this.pstackMenu(payload.data) });
|
|
1380
|
+
}
|
|
1381
|
+
catch (error) {
|
|
1382
|
+
this.logger.error('pstack setup button failed', { data: payload.data, error: String(error) });
|
|
1383
|
+
respond({ success: false, error: 'pstack setup unavailable. Use /pstack_setup again.' });
|
|
1384
|
+
}
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
if (command === 'telegram_voice_retry') {
|
|
1388
|
+
// A private chat's id is its user's id; the runtime also checks the note's sender and chat.
|
|
1389
|
+
const chatId = body.chat_id ?? '', payload = body.payload ?? {};
|
|
1390
|
+
if (!/^\d+$/.test(chatId) || payload.user_id !== chatId || typeof payload.input_id !== 'string' || !/^[a-f0-9-]{36}$/.test(payload.input_id)) {
|
|
1391
|
+
respond({ success: false }, 400);
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
if (!this.agentConfig.orchestration?.enabled || !this.agentConfig.orchestration.channels?.includes('telegram')) {
|
|
1395
|
+
respond({ success: false, error: 'Voice retry requires orchestration mode.' });
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
try {
|
|
1399
|
+
respond({ success: true, ...(await this.getOrchestration()).retryVoiceNote('telegram', chatId, `telegram:${payload.user_id}`, payload.input_id) });
|
|
1400
|
+
}
|
|
1401
|
+
catch (error) {
|
|
1402
|
+
this.logger.warn('Voice note retry refused', { referenceId: payload.input_id, code: error instanceof Error ? error.message : String(error) });
|
|
1403
|
+
respond({ success: false, error: 'This voice note cannot be retried here. Please record it again.' });
|
|
1404
|
+
}
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1387
1407
|
if (command === 'telegram_question') {
|
|
1388
1408
|
const chatId = body.chat_id ?? '', payload = body.payload ?? {};
|
|
1389
1409
|
if (!/^\d+$/.test(chatId) || payload.user_id !== chatId) {
|
|
@@ -1498,6 +1518,28 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
1498
1518
|
}
|
|
1499
1519
|
return;
|
|
1500
1520
|
}
|
|
1521
|
+
// `/call` — the receiver has checked the DM sender against its allowlist.
|
|
1522
|
+
// Mint a voice-call pairing for that user; the Mini App proves the same user
|
|
1523
|
+
// again with signed initData before any ticket is issued.
|
|
1524
|
+
if (command === 'voice_call_pair') {
|
|
1525
|
+
const chatId = body.chat_id ?? '', userId = body.payload?.user_id, threadId = body.payload?.thread_id;
|
|
1526
|
+
// Private chats only: a DM's chat id is its user id.
|
|
1527
|
+
if (!/^\d+$/.test(chatId) || userId !== chatId || (threadId !== undefined && (typeof threadId !== 'string' || !/^\d+$/.test(threadId)))) {
|
|
1528
|
+
respond({ success: false, error: 'invalid_request' }, 400);
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
if (!(0, call_pairing_1.telegramVoiceCallsEnabled)(this.agentConfig)) {
|
|
1532
|
+
respond({ success: false, error: 'voice_not_configured' });
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
// Telegram opens Mini Apps over HTTPS only.
|
|
1536
|
+
if (!(0, url_1.normalizePublicUrl)(this.gatewayConfig.gateway.publicUrl)?.startsWith('https://')) {
|
|
1537
|
+
respond({ success: false, error: 'not_configured' });
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
respond({ success: true, url: (0, url_1.buildVoiceCallUrl)(this.gatewayConfig.gateway.publicUrl, call_pairing_1.voiceCallPairings.create(this.agentConfig.id, chatId, threadId ?? '')) });
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1501
1543
|
if (command === 'get_model') {
|
|
1502
1544
|
respond({ model: this.agentConfig.claude.model });
|
|
1503
1545
|
return;
|
|
@@ -1508,7 +1550,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
1508
1550
|
// it — fetchModelCatalog is bounded and never rejects.
|
|
1509
1551
|
void this.availableModels()
|
|
1510
1552
|
.then((availableModels) => {
|
|
1511
|
-
const configuredIds = new Set((this.gatewayConfig.gateway.models ??
|
|
1553
|
+
const configuredIds = new Set((this.gatewayConfig.gateway.models ?? model_registry_2.DEFAULT_MODELS).map(m => m.id));
|
|
1512
1554
|
const configured = availableModels.filter(m => configuredIds.has(m.id));
|
|
1513
1555
|
const live = availableModels.filter(m => !configuredIds.has(m.id));
|
|
1514
1556
|
respond({
|
|
@@ -2963,7 +3005,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
2963
3005
|
async handleSessionCommand(chatId, content, meta = {}) {
|
|
2964
3006
|
const agentId = this.agentConfig.id;
|
|
2965
3007
|
if (content.trim() === '/help') {
|
|
2966
|
-
this.writeAutoForward(chatId, (0, command_help_1.commandHelp)(this.channelFor(chatId),
|
|
3008
|
+
this.writeAutoForward(chatId, (0, command_help_1.commandHelp)(this.channelFor(chatId), this.requiresDurableChannelIngress(this.channelFor(chatId)), this.gatewayConfig.gateway.headless === false));
|
|
2967
3009
|
}
|
|
2968
3010
|
else if (/^\/restart(?:\s|$)/.test(content)) {
|
|
2969
3011
|
await this.restartProcess(chatId);
|
|
@@ -2990,6 +3032,9 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
2990
3032
|
const name = content.replace('/rename', '').trim();
|
|
2991
3033
|
await this.handleCommandRename(agentId, chatId, name);
|
|
2992
3034
|
}
|
|
3035
|
+
else if (/^\/pstack[-_]setup\b/.test(content)) {
|
|
3036
|
+
await this.handleCommandPstackSetup(chatId, content.replace(/^\/pstack[-_]setup(?:@\w+)?/, '').trim(), meta);
|
|
3037
|
+
}
|
|
2993
3038
|
else if (content.startsWith('/models')) {
|
|
2994
3039
|
await this.handleCommandModels(chatId);
|
|
2995
3040
|
}
|
|
@@ -3014,8 +3059,12 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
3014
3059
|
* exactly that state before this.
|
|
3015
3060
|
*/
|
|
3016
3061
|
async handleCommandModels(chatId) {
|
|
3062
|
+
this.writeAutoForward(chatId, (await this.modelList('Switch with /model <id or alias>')).text);
|
|
3063
|
+
}
|
|
3064
|
+
/** The /models list: configured models, then live-only ones, each marked when current. */
|
|
3065
|
+
async modelList(switchHint) {
|
|
3017
3066
|
const models = await this.availableModels();
|
|
3018
|
-
const configuredIds = new Set((this.gatewayConfig.gateway.models ??
|
|
3067
|
+
const configuredIds = new Set((this.gatewayConfig.gateway.models ?? model_registry_2.DEFAULT_MODELS).map(m => m.id));
|
|
3019
3068
|
const configured = models.filter(m => configuredIds.has(m.id));
|
|
3020
3069
|
const live = models.filter(m => !configuredIds.has(m.id));
|
|
3021
3070
|
const current = this.agentConfig.claude.model;
|
|
@@ -3031,8 +3080,101 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
3031
3080
|
lines.push(`${marker}${m.label} — \`${m.id}\``);
|
|
3032
3081
|
}
|
|
3033
3082
|
}
|
|
3034
|
-
lines.push('',
|
|
3035
|
-
|
|
3083
|
+
lines.push('', switchHint);
|
|
3084
|
+
return { text: lines.join('\n'), models: [...configured, ...live].map(m => ({ id: m.id, label: m.label, current: m.id === current })) };
|
|
3085
|
+
}
|
|
3086
|
+
/**
|
|
3087
|
+
* /pstack-setup — the gateway's counterpart of pstack's own setup-pstack:
|
|
3088
|
+
* decides whether this agent's workers load pstack, and with which models.
|
|
3089
|
+
* Arguments are pstack-models.md lines, one per line (`<role>: <model-id>`,
|
|
3090
|
+
* `<role>: default` to drop an override, `<role> += <model-id>` / `<role> -= <model-id>`
|
|
3091
|
+
* to edit a panel list, `default effort: <level>`); `on`
|
|
3092
|
+
* sets the agent up with the skill defaults and `off` removes it. Changes
|
|
3093
|
+
* apply to the next worker. Direct messages only, like /model; the bare
|
|
3094
|
+
* form too, so a group is not shown the agent's setup.
|
|
3095
|
+
*/
|
|
3096
|
+
async handleCommandPstackSetup(chatId, arg, meta = {}) {
|
|
3097
|
+
if (!this.isDirectChat(meta)) {
|
|
3098
|
+
this.writeAutoForward(chatId, 'pstack setup is only available in a direct message with the bot — it changes this agent for every chat.');
|
|
3099
|
+
return;
|
|
3100
|
+
}
|
|
3101
|
+
this.writeAutoForward(chatId, arg ? await this.applyPstackSetup(arg) : await this.pstackSetupText());
|
|
3102
|
+
}
|
|
3103
|
+
/** The bare /pstack-setup reply for channels without buttons: status, every role's current model, the syntax and the model IDs. */
|
|
3104
|
+
async pstackSetupText() {
|
|
3105
|
+
return (0, menu_1.pstackMenuText)(await this.pstackMenuState(), PSTACK_SETUP_USAGE);
|
|
3106
|
+
}
|
|
3107
|
+
async pstackMenuState() {
|
|
3108
|
+
const plugin = (0, plugin_info_1.pstackPluginInfo)();
|
|
3109
|
+
return { block: this.agentConfig.pstack, plugin: plugin.installPath ? (0, plugin_info_1.pstackModels)(plugin.installPath) : undefined, models: await this.availableModels(), installHint: plugin_info_1.PSTACK_INSTALL_HINT };
|
|
3110
|
+
}
|
|
3111
|
+
/** Change the saved pstack block (`undefined` removes it) through the same path as the API. */
|
|
3112
|
+
async updatePstack(update) {
|
|
3113
|
+
const result = await (0, setup_1.updatePstackConfig)(this.configPath, this.agentConfig.id, update, await this.selectableModels());
|
|
3114
|
+
if (result.saved)
|
|
3115
|
+
this.agentConfig.pstack = result.saved;
|
|
3116
|
+
else
|
|
3117
|
+
delete this.agentConfig.pstack;
|
|
3118
|
+
return result;
|
|
3119
|
+
}
|
|
3120
|
+
/** Apply `/pstack-setup <arg>` (on, off, or pstack-models.md lines) and describe the outcome. */
|
|
3121
|
+
async applyPstackSetup(arg) {
|
|
3122
|
+
const plugin = (0, plugin_info_1.pstackPluginInfo)();
|
|
3123
|
+
const roles = plugin.installPath ? (0, plugin_info_1.pstackModels)(plugin.installPath) : undefined;
|
|
3124
|
+
try {
|
|
3125
|
+
const { saved } = await this.updatePstack(previous => arg === 'off' ? undefined : arg === 'on' ? previous ?? {} : (0, config_4.applySheetLines)(previous ?? {}, arg, roles && (role => (0, sheet_1.pstackPanelDefault)(roles, role))));
|
|
3126
|
+
if (!saved)
|
|
3127
|
+
return 'pstack is removed from this agent. Its next worker does not load it.';
|
|
3128
|
+
// `on` for an agent already set up saves nothing, so a plugin that cannot be read is only noticed here.
|
|
3129
|
+
if (!roles)
|
|
3130
|
+
return `pstack is set up for this agent, but ${plugin_info_1.PSTACK_PLUGIN_ID} is not installed for Claude Code on this host, so its workers cannot load it. ${plugin_info_1.PSTACK_INSTALL_HINT}`;
|
|
3131
|
+
return `pstack is set up for this agent. The next worker loads it with this sheet:\n\n${(0, sheet_1.renderPstackSheet)(saved, roles)}`;
|
|
3132
|
+
}
|
|
3133
|
+
catch (error) {
|
|
3134
|
+
if (!(error instanceof config_4.PstackConfigError))
|
|
3135
|
+
throw error;
|
|
3136
|
+
return `${error.code}: ${error.message}`;
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
/** One /pstack-setup button (Telegram): apply its change, if any, and render the next screen. */
|
|
3140
|
+
async pstackMenu(data, canWrite = true) {
|
|
3141
|
+
const state = await this.pstackMenuState();
|
|
3142
|
+
let step;
|
|
3143
|
+
try {
|
|
3144
|
+
step = (0, menu_1.pstackMenuStep)(data, state);
|
|
3145
|
+
}
|
|
3146
|
+
catch (error) {
|
|
3147
|
+
if (!(error instanceof config_4.PstackConfigError))
|
|
3148
|
+
throw error;
|
|
3149
|
+
return { ...(0, menu_1.pstackMenuScreen)({ kind: 'home' }, state, `⚠️ ${error.message}`), toast: error.message };
|
|
3150
|
+
}
|
|
3151
|
+
if (step.next === undefined)
|
|
3152
|
+
return (0, menu_1.pstackMenuScreen)(step.view, state);
|
|
3153
|
+
if (!canWrite)
|
|
3154
|
+
return { ...(0, menu_1.pstackMenuScreen)(step.view, state, `⚠️ ${PSTACK_WRITE_REQUIRED}`), toast: PSTACK_WRITE_REQUIRED };
|
|
3155
|
+
let result;
|
|
3156
|
+
try {
|
|
3157
|
+
// Applied again to the saved block, so a change made meanwhile from the API or CLI is kept.
|
|
3158
|
+
result = await this.updatePstack(previous => {
|
|
3159
|
+
const next = (0, menu_1.pstackMenuStep)(data, { ...state, block: previous }).next;
|
|
3160
|
+
return next === undefined ? previous : next ?? undefined;
|
|
3161
|
+
});
|
|
3162
|
+
}
|
|
3163
|
+
catch (error) {
|
|
3164
|
+
if (!(error instanceof config_4.PstackConfigError))
|
|
3165
|
+
throw error;
|
|
3166
|
+
return { ...(0, menu_1.pstackMenuScreen)(step.view, state, `⚠️ ${error.code}: ${error.message}`), toast: error.message };
|
|
3167
|
+
}
|
|
3168
|
+
const unchanged = result.saved === result.previous;
|
|
3169
|
+
// Turn on/off ends the menu with its result and no buttons, as a /voice or /models choice does.
|
|
3170
|
+
if (data === 'ps:on' || data === 'ps:off') {
|
|
3171
|
+
const text = !result.saved ? `pstack is ${unchanged ? 'already off' : 'off'} for ${this.agentConfig.id}. The next worker does not load it.`
|
|
3172
|
+
: `pstack is ${unchanged ? 'already on' : 'on'} for ${this.agentConfig.id}. The next worker loads it.`;
|
|
3173
|
+
return { text: `✅ ${text}`, keyboard: [], done: true, toast: text };
|
|
3174
|
+
}
|
|
3175
|
+
const saved = unchanged ? 'No change.' : !result.saved ? 'pstack is off. The next worker does not load it.'
|
|
3176
|
+
: result.previous ? 'Saved. The next worker uses it.' : 'Saved, and pstack is on now. The next worker uses it.';
|
|
3177
|
+
return { ...(0, menu_1.pstackMenuScreen)(step.view, await this.pstackMenuState(), `✅ ${saved}`), toast: saved };
|
|
3036
3178
|
}
|
|
3037
3179
|
/**
|
|
3038
3180
|
* /model — show the current model, or switch to one from the catalog.
|
|
@@ -3055,9 +3197,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
3055
3197
|
+ 'Use /models here to see the list.');
|
|
3056
3198
|
return;
|
|
3057
3199
|
}
|
|
3058
|
-
const
|
|
3059
|
-
const wanted = arg.toLowerCase();
|
|
3060
|
-
const match = models.find((m) => m.id.toLowerCase() === wanted || m.alias.toLowerCase() === wanted);
|
|
3200
|
+
const match = (0, model_registry_2.findModel)(await this.selectableModels(), arg);
|
|
3061
3201
|
if (!match) {
|
|
3062
3202
|
this.writeAutoForward(chatId, `Unknown model "${arg}". Use /models to see the list.`);
|
|
3063
3203
|
return;
|
|
@@ -4420,7 +4560,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
4420
4560
|
async dashboardContextWindow(model) {
|
|
4421
4561
|
const models = await this.availableModels();
|
|
4422
4562
|
return models.find(m => m.id === model)?.contextWindow
|
|
4423
|
-
?? (this.gatewayConfig.gateway.models ??
|
|
4563
|
+
?? (this.gatewayConfig.gateway.models ?? model_registry_2.DEFAULT_MODELS).find(m => m.id === model)?.contextWindow
|
|
4424
4564
|
?? null;
|
|
4425
4565
|
}
|
|
4426
4566
|
getTokenReport(sessionId) {
|
|
@@ -5279,6 +5419,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5279
5419
|
// "/stop now") resolve to their base command instead of falling through to the
|
|
5280
5420
|
// unknown-command branch. The router gate is prefix-based, so these already pass.
|
|
5281
5421
|
const cmd = command.trim().split(/\s+/)[0] ?? '';
|
|
5422
|
+
const arg = command.trim().slice(cmd.length).trim();
|
|
5282
5423
|
// Validate BEFORE persisting anything. Reuse the same api-channel gate as the router
|
|
5283
5424
|
// so an unknown command throws with nothing written — no orphan user row is left, and
|
|
5284
5425
|
// the router surfaces the error/500 exactly as before. After token dispatch + the
|
|
@@ -5288,6 +5429,10 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5288
5429
|
}
|
|
5289
5430
|
if (cmd === '/stop' && this.agentConfig.orchestration?.enabled && opts?.principalId)
|
|
5290
5431
|
this.orchestration?.authorizeSession(sessionId, opts.principalId);
|
|
5432
|
+
// A fresh session has nothing to rename; refused before it is registered, so no empty session is left.
|
|
5433
|
+
if (cmd === '/rename' && opts?.implicitSession) {
|
|
5434
|
+
return { result: { error: 'SESSION_ID_REQUIRED' }, responseText: '⚠️ /rename renames the session given by session_id; send it with the session to rename.', actions: [] };
|
|
5435
|
+
}
|
|
5291
5436
|
// Register session in the api-{chatId} index on first use (same as sendApiMessageStream)
|
|
5292
5437
|
await this.sessionStore.ensureApiSession(agentId, storeChatId, sessionId).catch((err) => {
|
|
5293
5438
|
this.logger.warn('Failed to register API session in index for command', { agentId, chatId, sessionId, error: err.message });
|
|
@@ -5307,16 +5452,121 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5307
5452
|
return;
|
|
5308
5453
|
this.historyDb.insertMessage({ chatId: dbChatId, sessionId, source: 'api', role, content, ts: Date.now(), ...(role === 'user' && opts?.clientMessageId ? { clientMessageId: opts.clientMessageId } : {}) });
|
|
5309
5454
|
};
|
|
5310
|
-
// Persist the full user command before executing so it appears in history.
|
|
5311
|
-
|
|
5455
|
+
// Persist the full user command before executing so it appears in history. A pressed
|
|
5456
|
+
// action (`/orch <token>`, `/pstack-setup ps:…`, `/stop <menu> <n>`) is not something the
|
|
5457
|
+
// user typed, so only its reply is kept, except a setup menu page: that is UI, not
|
|
5458
|
+
// conversation, and would push real messages out of the history a new context starts from.
|
|
5459
|
+
const display = opts?.displayCommand ?? command;
|
|
5460
|
+
const pressed = /^\/(?:orch \S+|pstack[-_]setup ps:\S+|stop [0-9a-f-]{36} \d+)$/.test(display.trim());
|
|
5461
|
+
const menuPage = /^\/pstack[-_]setup ps:\S+$/.test(display.trim());
|
|
5462
|
+
if (!pressed)
|
|
5463
|
+
persist('user', display);
|
|
5312
5464
|
let result;
|
|
5313
5465
|
let responseText;
|
|
5466
|
+
let actions = [];
|
|
5314
5467
|
let forcePersist = false;
|
|
5468
|
+
const confirmScope = { channel: 'api', chatId, thread: '', sessionId, principalId: opts?.principalId ?? '' };
|
|
5469
|
+
const contextCommand = async (operation) => {
|
|
5470
|
+
if (operation === 'clear') {
|
|
5471
|
+
await this.clearContext(sessionId);
|
|
5472
|
+
return { result: { success: true, historyUnchanged: true, historyLimit: 50 }, responseText: 'Claude Code context reset. Chat history is unchanged. Your next message starts a new context with the latest 50 messages.' };
|
|
5473
|
+
}
|
|
5474
|
+
if (operation === 'compact') {
|
|
5475
|
+
await this.compactContext(sessionId, opts?.model);
|
|
5476
|
+
return { result: { success: true, native: true, historyUnchanged: true }, responseText: 'Claude Code context compacted. Chat history is unchanged.' };
|
|
5477
|
+
}
|
|
5478
|
+
await this.restartProcess(sessionId, sessionId);
|
|
5479
|
+
return { result: { restarting: true }, responseText: 'Session is restarting.' };
|
|
5480
|
+
};
|
|
5315
5481
|
try {
|
|
5316
5482
|
if (cmd === '/help') {
|
|
5317
|
-
|
|
5483
|
+
// /tasks is listed only where the web chat is in orchestration mode (orchestration.channels).
|
|
5484
|
+
responseText = (0, command_help_1.commandHelp)('api', this.orchestrationForApi(sessionId));
|
|
5318
5485
|
result = { text: responseText };
|
|
5319
5486
|
}
|
|
5487
|
+
else if ((cmd === '/clear' || cmd === '/compact' || cmd === '/restart') && arg !== 'confirm') {
|
|
5488
|
+
// Asked first, as in the chat channels: Yes/No are one-use actions for this session and key,
|
|
5489
|
+
// valid for five minutes. A caller that has already confirmed sends `<command> confirm`.
|
|
5490
|
+
const menu = this.sessionConfirmations.open(confirmScope, cmd.slice(1));
|
|
5491
|
+
result = { confirmationRequired: true };
|
|
5492
|
+
responseText = `${menu.text}\n\nOr reply ${cmd} confirm.`;
|
|
5493
|
+
actions = menu.buttons.map(button => ({ label: button.label, command: `/orch ${button.data.replace(/^orch:/, '')}` }));
|
|
5494
|
+
}
|
|
5495
|
+
else if (cmd === '/clear' || cmd === '/compact' || cmd === '/restart') {
|
|
5496
|
+
({ result, responseText } = await contextCommand(cmd.slice(1)));
|
|
5497
|
+
}
|
|
5498
|
+
else if (cmd === '/orch' && this.sessionConfirmations.owns(command.trim())) {
|
|
5499
|
+
const chosen = (() => { try {
|
|
5500
|
+
return this.sessionConfirmations.choose(confirmScope, command.trim());
|
|
5501
|
+
}
|
|
5502
|
+
catch (error) {
|
|
5503
|
+
return error;
|
|
5504
|
+
} })();
|
|
5505
|
+
if (chosen instanceof Error) {
|
|
5506
|
+
result = { error: 'CONFIRMATION_UNAVAILABLE' };
|
|
5507
|
+
responseText = chosen.message;
|
|
5508
|
+
}
|
|
5509
|
+
else if (chosen === 'cancel') {
|
|
5510
|
+
result = { cancelled: true };
|
|
5511
|
+
responseText = 'Cancelled.';
|
|
5512
|
+
}
|
|
5513
|
+
else
|
|
5514
|
+
({ result, responseText } = await contextCommand(chosen));
|
|
5515
|
+
}
|
|
5516
|
+
else if (cmd === '/models') {
|
|
5517
|
+
const list = await this.modelList('Change the model with the model picker or PUT /api/v1/agents/:agentId/model.');
|
|
5518
|
+
result = { model: this.agentConfig.claude.model, models: list.models };
|
|
5519
|
+
responseText = list.text;
|
|
5520
|
+
}
|
|
5521
|
+
else if (cmd === '/new' && opts?.implicitSession) {
|
|
5522
|
+
// Without session_id the command already runs in a new session: name that one rather than leave it empty beside another.
|
|
5523
|
+
if (arg)
|
|
5524
|
+
await this.updateApiSession(storeChatId, sessionId, { sessionName: arg });
|
|
5525
|
+
result = { sessionId, sessionName: arg || null };
|
|
5526
|
+
responseText = `New session created${arg ? `: "${arg}"` : ''}. Continue in it with session_id ${sessionId}.`;
|
|
5527
|
+
}
|
|
5528
|
+
else if (cmd === '/new') {
|
|
5529
|
+
// An API client picks its session by session_id, so this creates one and names it; the client opens it.
|
|
5530
|
+
const meta = await this.createApiSession(storeChatId, undefined, arg || undefined);
|
|
5531
|
+
result = { sessionId: meta.id, sessionName: meta.name };
|
|
5532
|
+
responseText = `New session created: "${meta.name}". This conversation stays in the current session; open the new one to continue there.`;
|
|
5533
|
+
}
|
|
5534
|
+
else if (cmd === '/rename') {
|
|
5535
|
+
if (!arg) {
|
|
5536
|
+
result = { error: 'SESSION_NAME_REQUIRED' };
|
|
5537
|
+
responseText = '⚠️ Usage: /rename <new name>\nExample: /rename Design review';
|
|
5538
|
+
}
|
|
5539
|
+
else {
|
|
5540
|
+
result = await this.updateApiSession(storeChatId, sessionId, { sessionName: arg });
|
|
5541
|
+
responseText = `✅ Session renamed to "${arg}"`;
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
else if (cmd === '/tasks' || cmd === '/orch') {
|
|
5545
|
+
// The chat channels' task browser; its buttons come back as `/orch <token>`, bound to this session and principal.
|
|
5546
|
+
// The same test /help and message routing use, so what /help lists is what works.
|
|
5547
|
+
const apiOrchestration = this.orchestrationForApi(sessionId) ? this.orchestration : undefined;
|
|
5548
|
+
if (!apiOrchestration || !opts?.principalId) {
|
|
5549
|
+
result = {};
|
|
5550
|
+
responseText = cmd === '/orch' ? 'This action expired or is unavailable. Run the command again.' : 'Task controls require orchestration mode.';
|
|
5551
|
+
}
|
|
5552
|
+
else {
|
|
5553
|
+
apiOrchestration.authorizeSession(sessionId, opts.principalId);
|
|
5554
|
+
let menu;
|
|
5555
|
+
try {
|
|
5556
|
+
menu = await apiOrchestration.channelControls.handle({ channel: 'api', chatId, thread: '', sessionId, principalId: opts.principalId }, cmd === '/tasks' ? '/tasks' : `/orch ${arg}`);
|
|
5557
|
+
}
|
|
5558
|
+
catch {
|
|
5559
|
+
menu = { text: 'Control unavailable or expired. Please open the command again.', buttons: [] };
|
|
5560
|
+
}
|
|
5561
|
+
result = { closed: menu.close === true };
|
|
5562
|
+
responseText = menu.text;
|
|
5563
|
+
actions = menu.buttons.map(button => ({ label: button.label, command: `/orch ${button.data.replace(/^orch:/, '')}` }));
|
|
5564
|
+
}
|
|
5565
|
+
}
|
|
5566
|
+
else if (cmd === '/voice' || cmd === '/voices') {
|
|
5567
|
+
result = {};
|
|
5568
|
+
responseText = 'Voice on the web is set in the voice settings, not with a chat command: GET/PATCH /api/v1/agents/:agentId/voice-settings, and GET /api/v1/agents/:agentId/voice-sessions/voices for the voice list.';
|
|
5569
|
+
}
|
|
5320
5570
|
else if (cmd === '/model') {
|
|
5321
5571
|
const model = this.agentConfig.claude.model;
|
|
5322
5572
|
const hasArg = command.trim().includes(' ');
|
|
@@ -5343,6 +5593,9 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5343
5593
|
const menu = this.orchestration.stopControls.open(sessionId, opts.principalId);
|
|
5344
5594
|
responseText = (0, stop_controls_1.stopMenuText)(menu);
|
|
5345
5595
|
result = { ...menu, responseText };
|
|
5596
|
+
// Same choices as Telegram's /stop buttons; a bare number reply still works too.
|
|
5597
|
+
if (menu.tasks.length)
|
|
5598
|
+
actions = [...menu.tasks.map((t, i) => ({ label: `${i + 1}. ${t.title} (${t.state})`, command: `/stop ${menu.menuId} ${i + 1}` })), { label: 'Dismiss', command: `/stop ${menu.menuId} 0` }];
|
|
5346
5599
|
}
|
|
5347
5600
|
forcePersist = true;
|
|
5348
5601
|
}
|
|
@@ -5362,10 +5615,24 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5362
5615
|
forcePersist = stopped;
|
|
5363
5616
|
}
|
|
5364
5617
|
}
|
|
5365
|
-
else if (cmd === '/
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5618
|
+
else if (cmd === '/pstack-setup' || cmd === '/pstack_setup') {
|
|
5619
|
+
// Changes need the same access as PUT /api/v1/agents/:agentId/pstack.
|
|
5620
|
+
// `ps:…` is a menu button (the Telegram menu's callback data) sent back from the actions.
|
|
5621
|
+
let screen;
|
|
5622
|
+
if (!arg) {
|
|
5623
|
+
responseText = await this.pstackSetupText();
|
|
5624
|
+
screen = (0, menu_1.pstackMenuScreen)({ kind: 'home' }, await this.pstackMenuState());
|
|
5625
|
+
}
|
|
5626
|
+
else if (/^ps:\S+$/.test(arg)) {
|
|
5627
|
+
screen = await this.pstackMenu(arg, !!opts?.canWriteAgent);
|
|
5628
|
+
responseText = screen.text;
|
|
5629
|
+
}
|
|
5630
|
+
else {
|
|
5631
|
+
responseText = opts?.canWriteAgent ? await this.applyPstackSetup(arg) : PSTACK_WRITE_REQUIRED;
|
|
5632
|
+
}
|
|
5633
|
+
result = { pstack: this.agentConfig.pstack ?? null };
|
|
5634
|
+
if (screen && !screen.closed && !screen.done)
|
|
5635
|
+
actions = screen.keyboard.flat().map(button => ({ label: button.text, command: `/pstack-setup ${button.data}` }));
|
|
5369
5636
|
}
|
|
5370
5637
|
else if (cmd === '/session') {
|
|
5371
5638
|
const index = await this.sessionStore.listSessions(agentId, storeChatId, 'api').catch(() => null);
|
|
@@ -5406,16 +5673,6 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5406
5673
|
responseText = `Sessions (${withCounts.length}):\n${lines.join('\n')}`;
|
|
5407
5674
|
}
|
|
5408
5675
|
}
|
|
5409
|
-
else if (cmd === '/clear') {
|
|
5410
|
-
await this.clearContext(sessionId);
|
|
5411
|
-
result = { success: true, historyUnchanged: true, historyLimit: 50 };
|
|
5412
|
-
responseText = 'Claude Code context reset. Chat history is unchanged. Your next message starts a new context with the latest 50 messages.';
|
|
5413
|
-
}
|
|
5414
|
-
else if (cmd === '/compact') {
|
|
5415
|
-
await this.compactContext(sessionId, opts?.model);
|
|
5416
|
-
result = { success: true, native: true, historyUnchanged: true };
|
|
5417
|
-
responseText = 'Claude Code context compacted. Chat history is unchanged.';
|
|
5418
|
-
}
|
|
5419
5676
|
else {
|
|
5420
5677
|
// Passed the gate but has no dispatch branch — BUILTIN_COMMANDS drifted from this
|
|
5421
5678
|
// table. Throw so the failure surfaces (and ends history with an assistant turn via
|
|
@@ -5435,8 +5692,9 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5435
5692
|
// Persist the human-readable response as an assistant turn so the conversation ends with
|
|
5436
5693
|
// an assistant message (the web's computeIsPendingResponse needs last.role !== 'user').
|
|
5437
5694
|
// forcePersist writes it even under skipPersist (set only when /stop cut a turn off).
|
|
5438
|
-
|
|
5439
|
-
|
|
5695
|
+
if (!menuPage)
|
|
5696
|
+
persist('assistant', responseText, forcePersist);
|
|
5697
|
+
return { result, responseText, actions };
|
|
5440
5698
|
}
|
|
5441
5699
|
/**
|
|
5442
5700
|
* Whether an inbound channel message came from a 1:1 chat with the bot.
|
|
@@ -5457,6 +5715,9 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5457
5715
|
*/
|
|
5458
5716
|
isDirectChat(meta) {
|
|
5459
5717
|
const kind = meta['chat_type'] ?? meta['line_chat_type'] ?? meta['slack_chat_type'];
|
|
5718
|
+
// Telegram reports no chat type; a private chat's id is its user's id (groups are negative).
|
|
5719
|
+
if (kind === undefined && this.channelFor(meta['chat_id'] ?? '') === 'telegram')
|
|
5720
|
+
return /^\d+$/.test(meta['chat_id'] ?? '') && meta['chat_id'] === meta['user_id'];
|
|
5460
5721
|
return kind === 'direct' || kind === 'user';
|
|
5461
5722
|
}
|
|
5462
5723
|
/**
|
|
@@ -5479,15 +5740,8 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5479
5740
|
await Promise.all(restartPromises);
|
|
5480
5741
|
return restartPromises.length > 0;
|
|
5481
5742
|
}
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
* the configured/static list otherwise (issue #409). Cached upstream, so the
|
|
5485
|
-
* six callers that only want one model's context window pay for at most one
|
|
5486
|
-
* fetch a minute between them.
|
|
5487
|
-
*/
|
|
5488
|
-
async availableModels() {
|
|
5489
|
-
const staticModels = this.gatewayConfig.gateway.models ?? exports.DEFAULT_MODELS;
|
|
5490
|
-
return (await (0, model_catalog_1.fetchModelCatalog)(staticModels)) ?? staticModels;
|
|
5743
|
+
availableModels() {
|
|
5744
|
+
return (0, model_registry_2.availableModels)(this.gatewayConfig.gateway.models);
|
|
5491
5745
|
}
|
|
5492
5746
|
/**
|
|
5493
5747
|
* Context window for a model id. Resolving this through the live catalog is
|
|
@@ -5504,24 +5758,11 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5504
5758
|
// /session context use against a fifth of the real window and handing
|
|
5505
5759
|
// SessionCompactor a window small enough to compact far too early.
|
|
5506
5760
|
return models.find((m) => m.id === modelId)?.contextWindow
|
|
5507
|
-
?? (this.gatewayConfig.gateway.models ??
|
|
5761
|
+
?? (this.gatewayConfig.gateway.models ?? model_registry_2.DEFAULT_MODELS).find((m) => m.id === modelId)?.contextWindow
|
|
5508
5762
|
?? (requireKnown ? 0 : model_catalog_1.DEFAULT_CONTEXT_WINDOW);
|
|
5509
5763
|
}
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
* configured list.
|
|
5513
|
-
*
|
|
5514
|
-
* The union is only for *resolution*, never for the `/models` listing — the
|
|
5515
|
-
* listing has to reflect what upstream actually offers, or a model removed
|
|
5516
|
-
* upstream would linger in the picker forever, which is the bug this all
|
|
5517
|
-
* started from. Without the union a user who switches to a live-only model
|
|
5518
|
-
* is trapped: their previous configured model is no longer nameable.
|
|
5519
|
-
*/
|
|
5520
|
-
async selectableModels() {
|
|
5521
|
-
const live = await this.availableModels();
|
|
5522
|
-
const configured = this.gatewayConfig.gateway.models ?? exports.DEFAULT_MODELS;
|
|
5523
|
-
const ids = new Set(live.map((m) => m.id));
|
|
5524
|
-
return [...live, ...configured.filter((m) => !ids.has(m.id))];
|
|
5764
|
+
selectableModels() {
|
|
5765
|
+
return (0, model_registry_2.selectableModels)(this.gatewayConfig.gateway.models);
|
|
5525
5766
|
}
|
|
5526
5767
|
async setModel(newModel) {
|
|
5527
5768
|
// Allow any model string through — BYOK/third-party models (openrouter/* etc.)
|
|
@@ -5562,7 +5803,7 @@ class AgentRunner extends events_1.EventEmitter {
|
|
|
5562
5803
|
const { promisify } = await Promise.resolve().then(() => __importStar(require('util')));
|
|
5563
5804
|
const execFileAsync = promisify(execFile);
|
|
5564
5805
|
const titlePrompt = `Summarise in 3-5 words as a session title (no punctuation, no quotes): ${prompt}`;
|
|
5565
|
-
const { stdout } = await execFileAsync('claude', ['-p', titlePrompt, '--output-format', 'text', '--model', 'claude-haiku-4-5-20251001'], { timeout: 15000, encoding: 'utf-8' });
|
|
5806
|
+
const { stdout } = await execFileAsync('claude', ['-p', titlePrompt, '--output-format', 'text', '--model', 'claude-haiku-4-5-20251001', '--settings', JSON.stringify(plugin_info_1.PSTACK_OFF_SETTINGS)], { timeout: 15000, encoding: 'utf-8' });
|
|
5566
5807
|
const aiName = stdout.trim().slice(0, 60) || undefined;
|
|
5567
5808
|
if (aiName) {
|
|
5568
5809
|
await this.sessionStore.updateSessionMeta(this.agentConfig.id, chatId, sessionId, { name: aiName }, 'api');
|