@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/api/router.js
CHANGED
|
@@ -58,11 +58,11 @@ const auth_1 = require("./auth");
|
|
|
58
58
|
const media_store_1 = require("../history/media-store");
|
|
59
59
|
const db_1 = require("../history/db");
|
|
60
60
|
const types_2 = require("../history/types");
|
|
61
|
+
const access_1 = require("../telegram/access");
|
|
61
62
|
const wizard_state_1 = require("./wizard-state");
|
|
62
63
|
const pending_senders_1 = require("./pending-senders");
|
|
63
64
|
const create_agent_prompts_1 = require("../agent/create-agent-prompts");
|
|
64
|
-
const
|
|
65
|
-
const runner_2 = require("../agent/runner");
|
|
65
|
+
const model_registry_1 = require("../agent/model-registry");
|
|
66
66
|
const whatsapp_accounts_1 = require("../config/whatsapp-accounts");
|
|
67
67
|
const whatsapp_access_1 = require("./whatsapp-access");
|
|
68
68
|
const MAX_MESSAGE_LENGTH = 10000;
|
|
@@ -134,6 +134,15 @@ function isValidSessionId(v) {
|
|
|
134
134
|
function isValidAgentId(v) {
|
|
135
135
|
return typeof v === 'string' && AGENT_ID_RE.test(v);
|
|
136
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* The structured part of a built-in command reply, beside its text: `command`
|
|
139
|
+
* (the base command), `result` (its fields) and `actions` (buttons; each
|
|
140
|
+
* `command` is sent back as the next message, so it runs with the same key,
|
|
141
|
+
* session and checks as anything typed).
|
|
142
|
+
*/
|
|
143
|
+
function commandReplyFields(message, reply) {
|
|
144
|
+
return { command: message.trim().split(/\s+/)[0], result: reply.result, actions: reply.actions ?? [] };
|
|
145
|
+
}
|
|
137
146
|
/**
|
|
138
147
|
* The one place a turn's stream events become SSE frames (#421).
|
|
139
148
|
*
|
|
@@ -164,7 +173,7 @@ function createSseCallbacks(res, meta) {
|
|
|
164
173
|
}
|
|
165
174
|
catch { /* client gone */ }
|
|
166
175
|
},
|
|
167
|
-
onDone: (fullText, attachments, seq) => {
|
|
176
|
+
onDone: (fullText, attachments, seq, extra) => {
|
|
168
177
|
try {
|
|
169
178
|
const frame = {
|
|
170
179
|
type: 'result',
|
|
@@ -172,6 +181,7 @@ function createSseCallbacks(res, meta) {
|
|
|
172
181
|
seq,
|
|
173
182
|
...ids(),
|
|
174
183
|
duration_ms: Date.now() - meta.startTime,
|
|
184
|
+
...extra,
|
|
175
185
|
};
|
|
176
186
|
if (attachments?.length)
|
|
177
187
|
frame['attachments'] = attachments;
|
|
@@ -844,9 +854,9 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
844
854
|
if (isBuiltinCommand) {
|
|
845
855
|
openSseStream(res);
|
|
846
856
|
try {
|
|
847
|
-
const
|
|
848
|
-
sseCallbacks.onChunk({ type: 'text_delta', text: responseText });
|
|
849
|
-
sseCallbacks.onDone(responseText, []);
|
|
857
|
+
const reply = await runner.executeApiCommand(sessionId, chatIdStr, commandMessage, { skipPersist: skipUserMessage, model: modelStr, principalId: (0, identity_1.apiPrincipal)(apiKey), displayCommand: trimmedMessage, clientMessageId, canWriteAgent: (0, auth_1.canWriteAgent)(apiKey, agentId), implicitSession: session_id === undefined });
|
|
858
|
+
sseCallbacks.onChunk({ type: 'text_delta', text: reply.responseText });
|
|
859
|
+
sseCallbacks.onDone(reply.responseText, [], undefined, commandReplyFields(commandMessage, reply));
|
|
850
860
|
}
|
|
851
861
|
catch (err) {
|
|
852
862
|
sseCallbacks.onError(err);
|
|
@@ -891,9 +901,12 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
891
901
|
try {
|
|
892
902
|
let responseText;
|
|
893
903
|
let attachments = [];
|
|
904
|
+
let commandFields = {};
|
|
894
905
|
if (isBuiltinCommand) {
|
|
895
|
-
// Built-in command — answer locally, return the same JSON shape as a normal reply.
|
|
896
|
-
|
|
906
|
+
// Built-in command — answer locally, return the same JSON shape as a normal reply plus its structured part.
|
|
907
|
+
const reply = await runner.executeApiCommand(sessionId, chatIdStr, commandMessage, { skipPersist: skipUserMessage, principalId: (0, identity_1.apiPrincipal)(apiKey), displayCommand: trimmedMessage, clientMessageId, canWriteAgent: (0, auth_1.canWriteAgent)(apiKey, agentId), implicitSession: session_id === undefined });
|
|
908
|
+
responseText = reply.responseText;
|
|
909
|
+
commandFields = commandReplyFields(commandMessage, reply);
|
|
897
910
|
}
|
|
898
911
|
else {
|
|
899
912
|
const agentCfgSync = agentConfigs.get(agentId);
|
|
@@ -917,6 +930,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
917
930
|
response: responseText,
|
|
918
931
|
session_id: sessionId,
|
|
919
932
|
duration_ms: Date.now() - startTime,
|
|
933
|
+
...commandFields,
|
|
920
934
|
};
|
|
921
935
|
if (attachments.length)
|
|
922
936
|
syncResult['attachments'] = attachments;
|
|
@@ -948,19 +962,11 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
948
962
|
* into config.json at provisioning time (issue #409).
|
|
949
963
|
*/
|
|
950
964
|
router.get('/v1/models', auth, async (_req, res) => {
|
|
951
|
-
//
|
|
952
|
-
//
|
|
953
|
-
//
|
|
954
|
-
//
|
|
955
|
-
|
|
956
|
-
// gateway whose config has no `gateway.models`, one request here would
|
|
957
|
-
// cache a catalog with every alias set to its id and every context window
|
|
958
|
-
// at the 200k default — and the picker and all six contextWindowFor()
|
|
959
|
-
// callers would read that degraded list for the next 60 seconds. It also
|
|
960
|
-
// makes this endpoint agree with the picker on an unconfigured gateway
|
|
961
|
-
// instead of reporting no models at all.
|
|
962
|
-
const staticModels = (typeof models === 'function' ? models() : models) ?? runner_2.DEFAULT_MODELS;
|
|
963
|
-
const available = (await (0, model_catalog_1.fetchModelCatalog)(staticModels)) ?? staticModels;
|
|
965
|
+
// availableModels() falls back to DEFAULT_MODELS, never `[]`: the
|
|
966
|
+
// catalog cache inherits alias/contextWindow/multiplier from whichever
|
|
967
|
+
// caller's list populated it first, so this route must pass the same list
|
|
968
|
+
// the runner does or one request here degrades the picker for 60 seconds.
|
|
969
|
+
const available = await (0, model_registry_1.availableModels)(typeof models === 'function' ? models() : models);
|
|
964
970
|
res.json({ models: available.map((m) => ({ id: m.id, name: m.label, alias: m.alias, contextWindow: m.contextWindow, multiplier: m.multiplier ?? 1 })) });
|
|
965
971
|
});
|
|
966
972
|
/**
|
|
@@ -1197,67 +1203,10 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
1197
1203
|
return (0, agent_env_1.agentsDirForConfig)(configPath);
|
|
1198
1204
|
}
|
|
1199
1205
|
function getTelegramStateDir(agentId) {
|
|
1200
|
-
|
|
1201
|
-
const cfg = agentConfigs.get(agentId);
|
|
1202
|
-
const workspace = cfg?.workspace
|
|
1203
|
-
? (cfg.workspace.startsWith('~') ? path.join(os.homedir(), cfg.workspace.slice(1)) : cfg.workspace)
|
|
1204
|
-
: path.join(agentsBase, agentId, 'workspace');
|
|
1205
|
-
return path.join(workspace, '.telegram-state');
|
|
1206
|
+
return (0, access_1.telegramStateDir)(agentConfigs.get(agentId)?.workspace, getAgentsBaseDir(), agentId);
|
|
1206
1207
|
}
|
|
1207
1208
|
function readTelegramAccess(agentId) {
|
|
1208
|
-
|
|
1209
|
-
try {
|
|
1210
|
-
const raw = fs.readFileSync(accessFile, 'utf8');
|
|
1211
|
-
const parsed = JSON.parse(raw);
|
|
1212
|
-
// Migrate the legacy 4-value dmPolicy (pairing folded in) to the split
|
|
1213
|
-
// model. SECURITY: a legacy 'allowlist' file was locked down → pairing:false
|
|
1214
|
-
// (an absent pairing on an existing file means pre-split); 'pairing' → mint on.
|
|
1215
|
-
// Mirrors migrateAccess() in mcp/tools/telegram/pure.ts — keep in sync.
|
|
1216
|
-
const legacy = parsed.dmPolicy;
|
|
1217
|
-
let dmPolicy;
|
|
1218
|
-
let pairing;
|
|
1219
|
-
if (legacy === 'pairing') {
|
|
1220
|
-
dmPolicy = 'allowlist';
|
|
1221
|
-
pairing = true;
|
|
1222
|
-
}
|
|
1223
|
-
else {
|
|
1224
|
-
dmPolicy = legacy ?? 'allowlist';
|
|
1225
|
-
pairing = parsed.pairing ?? false;
|
|
1226
|
-
}
|
|
1227
|
-
// Group tier: flatten legacy per-group `groups` map to a flat allowlist,
|
|
1228
|
-
// behavior-preserving (groups were closed-by-default). Mirrors pure.ts.
|
|
1229
|
-
// A group's per-user `allowFrom` override has no flat-model equivalent,
|
|
1230
|
-
// but it's a real restriction — preserve it (mirrors
|
|
1231
|
-
// deriveLegacyGroupAllowFrom in pure.ts, keep in sync) rather than
|
|
1232
|
-
// silently dropping it and widening the group to every member.
|
|
1233
|
-
const groupAllowlist = parsed.groupAllowlist ?? Object.keys(parsed.groups ?? {});
|
|
1234
|
-
const groupPolicy = parsed.groupPolicy ?? 'allowlist';
|
|
1235
|
-
const requireMention = parsed.requireMention ?? true;
|
|
1236
|
-
let legacyGroupAllowFrom = parsed.legacyGroupAllowFrom;
|
|
1237
|
-
if (!legacyGroupAllowFrom && parsed.groups) {
|
|
1238
|
-
const derived = {};
|
|
1239
|
-
for (const [groupId, g] of Object.entries(parsed.groups)) {
|
|
1240
|
-
if (g.allowFrom && g.allowFrom.length > 0)
|
|
1241
|
-
derived[groupId] = [...g.allowFrom];
|
|
1242
|
-
}
|
|
1243
|
-
if (Object.keys(derived).length > 0)
|
|
1244
|
-
legacyGroupAllowFrom = derived;
|
|
1245
|
-
}
|
|
1246
|
-
return {
|
|
1247
|
-
dmPolicy,
|
|
1248
|
-
pairing,
|
|
1249
|
-
allowFrom: parsed.allowFrom ?? [],
|
|
1250
|
-
groupPolicy,
|
|
1251
|
-
groupAllowlist,
|
|
1252
|
-
requireMention,
|
|
1253
|
-
legacyGroupAllowFrom,
|
|
1254
|
-
pending: parsed.pending ?? {},
|
|
1255
|
-
};
|
|
1256
|
-
}
|
|
1257
|
-
catch {
|
|
1258
|
-
// Brand-new agent (no file): closed base + pairing on (capture owner id).
|
|
1259
|
-
return { dmPolicy: 'allowlist', pairing: true, allowFrom: [], groupPolicy: 'allowlist', groupAllowlist: [], requireMention: true, pending: {} };
|
|
1260
|
-
}
|
|
1209
|
+
return (0, access_1.readTelegramAccess)(getTelegramStateDir(agentId));
|
|
1261
1210
|
}
|
|
1262
1211
|
function writeTelegramAccess(agentId, access) {
|
|
1263
1212
|
const stateDir = getTelegramStateDir(agentId);
|
|
@@ -4941,7 +4890,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4941
4890
|
const { runner, chatId } = ctx;
|
|
4942
4891
|
const { sessionId } = req.params;
|
|
4943
4892
|
try {
|
|
4944
|
-
const { result } = await runner.executeApiCommand(sessionId, chatId, '/clear', { skipPersist: true });
|
|
4893
|
+
const { result } = await runner.executeApiCommand(sessionId, chatId, '/clear confirm', { skipPersist: true });
|
|
4945
4894
|
res.json(result);
|
|
4946
4895
|
}
|
|
4947
4896
|
catch (err) {
|
|
@@ -4958,7 +4907,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4958
4907
|
const { runner, chatId } = ctx;
|
|
4959
4908
|
const { sessionId } = req.params;
|
|
4960
4909
|
try {
|
|
4961
|
-
const { result } = await runner.executeApiCommand(sessionId, chatId, '/compact', { skipPersist: true });
|
|
4910
|
+
const { result } = await runner.executeApiCommand(sessionId, chatId, '/compact confirm', { skipPersist: true });
|
|
4962
4911
|
res.json(result);
|
|
4963
4912
|
}
|
|
4964
4913
|
catch (err) {
|
|
@@ -4992,7 +4941,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4992
4941
|
const { runner, chatId } = ctx;
|
|
4993
4942
|
const { sessionId } = req.params;
|
|
4994
4943
|
try {
|
|
4995
|
-
const { result } = await runner.executeApiCommand(sessionId, chatId, '/restart', { skipPersist: true });
|
|
4944
|
+
const { result } = await runner.executeApiCommand(sessionId, chatId, '/restart confirm', { skipPersist: true });
|
|
4996
4945
|
res.json(result);
|
|
4997
4946
|
}
|
|
4998
4947
|
catch (err) {
|