@0xmaxma/claude-gateway 2.0.10 → 2.0.11
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 +15 -0
- package/config.template.json +1 -1
- package/dist/agent/runner.d.ts +119 -11
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +58 -8
- package/dist/agent/runner.js.map +1 -1
- package/dist/api/browser-bindings-router.d.ts +6 -0
- package/dist/api/browser-bindings-router.d.ts.map +1 -0
- package/dist/api/browser-bindings-router.js +150 -0
- package/dist/api/browser-bindings-router.js.map +1 -0
- package/dist/api/connectors-router.js +1 -1
- package/dist/api/connectors-router.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +30 -2
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/jev-router.d.ts +8 -0
- package/dist/api/jev-router.d.ts.map +1 -0
- package/dist/api/jev-router.js +128 -0
- package/dist/api/jev-router.js.map +1 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +53 -6
- package/dist/api/router.js.map +1 -1
- package/dist/api/voice-router.d.ts.map +1 -1
- package/dist/api/voice-router.js +42 -3
- package/dist/api/voice-router.js.map +1 -1
- package/dist/automation/browser-command.d.ts +79 -0
- package/dist/automation/browser-command.d.ts.map +1 -0
- package/dist/automation/browser-command.js +118 -0
- package/dist/automation/browser-command.js.map +1 -0
- package/dist/automation/browser-outcome.d.ts +3 -0
- package/dist/automation/browser-outcome.d.ts.map +1 -0
- package/dist/automation/browser-outcome.js +78 -0
- package/dist/automation/browser-outcome.js.map +1 -0
- package/dist/automation/browser-steps.d.ts +33 -0
- package/dist/automation/browser-steps.d.ts.map +1 -0
- package/dist/automation/browser-steps.js +293 -0
- package/dist/automation/browser-steps.js.map +1 -0
- package/dist/automation/browser-trace.d.ts +60 -0
- package/dist/automation/browser-trace.d.ts.map +1 -0
- package/dist/automation/browser-trace.js +24 -0
- package/dist/automation/browser-trace.js.map +1 -0
- package/dist/automation/browser-use.d.ts +210 -0
- package/dist/automation/browser-use.d.ts.map +1 -0
- package/dist/automation/browser-use.js +1271 -0
- package/dist/automation/browser-use.js.map +1 -0
- package/dist/automation/command-speech.d.ts +33 -0
- package/dist/automation/command-speech.d.ts.map +1 -0
- package/dist/automation/command-speech.js +117 -0
- package/dist/automation/command-speech.js.map +1 -0
- package/dist/automation/command-steps.d.ts +35 -0
- package/dist/automation/command-steps.d.ts.map +1 -0
- package/dist/automation/command-steps.js +155 -0
- package/dist/automation/command-steps.js.map +1 -0
- package/dist/automation/computer-choice-ids.d.ts +7 -0
- package/dist/automation/computer-choice-ids.d.ts.map +1 -0
- package/dist/automation/computer-choice-ids.js +24 -0
- package/dist/automation/computer-choice-ids.js.map +1 -0
- package/dist/automation/computer-command.d.ts +126 -0
- package/dist/automation/computer-command.d.ts.map +1 -0
- package/dist/automation/computer-command.js +313 -0
- package/dist/automation/computer-command.js.map +1 -0
- package/dist/automation/computer-outcome.d.ts +8 -0
- package/dist/automation/computer-outcome.d.ts.map +1 -0
- package/dist/automation/computer-outcome.js +82 -0
- package/dist/automation/computer-outcome.js.map +1 -0
- package/dist/automation/computer-policy.d.ts +84 -0
- package/dist/automation/computer-policy.d.ts.map +1 -0
- package/dist/automation/computer-policy.js +56 -0
- package/dist/automation/computer-policy.js.map +1 -0
- package/dist/automation/computer-safety.d.ts +27 -0
- package/dist/automation/computer-safety.d.ts.map +1 -0
- package/dist/automation/computer-safety.js +47 -0
- package/dist/automation/computer-safety.js.map +1 -0
- package/dist/automation/computer-steps.d.ts +20 -0
- package/dist/automation/computer-steps.d.ts.map +1 -0
- package/dist/automation/computer-steps.js +251 -0
- package/dist/automation/computer-steps.js.map +1 -0
- package/dist/automation/computer-use.d.ts +315 -0
- package/dist/automation/computer-use.d.ts.map +1 -0
- package/dist/automation/computer-use.js +864 -0
- package/dist/automation/computer-use.js.map +1 -0
- package/dist/automation/direct-command.d.ts +51 -0
- package/dist/automation/direct-command.d.ts.map +1 -0
- package/dist/automation/direct-command.js +152 -0
- package/dist/automation/direct-command.js.map +1 -0
- package/dist/automation/interrupt.d.ts +4 -0
- package/dist/automation/interrupt.d.ts.map +1 -0
- package/dist/automation/interrupt.js +26 -0
- package/dist/automation/interrupt.js.map +1 -0
- package/dist/build-provenance.json +4 -4
- package/dist/child-env-exclusions.d.ts +4 -0
- package/dist/child-env-exclusions.d.ts.map +1 -0
- package/dist/child-env-exclusions.js +23 -0
- package/dist/child-env-exclusions.js.map +1 -0
- package/dist/cli/startup-diagnostics.d.ts.map +1 -1
- package/dist/cli/startup-diagnostics.js +19 -0
- package/dist/cli/startup-diagnostics.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +4 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/reload-policy.d.ts.map +1 -1
- package/dist/config/reload-policy.js +2 -1
- package/dist/config/reload-policy.js.map +1 -1
- package/dist/jev/automatic-browser-bindings.d.ts +15 -0
- package/dist/jev/automatic-browser-bindings.d.ts.map +1 -0
- package/dist/jev/automatic-browser-bindings.js +115 -0
- package/dist/jev/automatic-browser-bindings.js.map +1 -0
- package/dist/jev/browser-connector.d.ts +29 -0
- package/dist/jev/browser-connector.d.ts.map +1 -0
- package/dist/jev/browser-connector.js +347 -0
- package/dist/jev/browser-connector.js.map +1 -0
- package/dist/jev/browser-consent.d.ts +6 -0
- package/dist/jev/browser-consent.d.ts.map +1 -0
- package/dist/jev/browser-consent.js +50 -0
- package/dist/jev/browser-consent.js.map +1 -0
- package/dist/jev/browser-contract.d.ts +215 -0
- package/dist/jev/browser-contract.d.ts.map +1 -0
- package/dist/jev/browser-contract.js +10 -0
- package/dist/jev/browser-contract.js.map +1 -0
- package/dist/jev/browser-evidence-summary.d.ts +73 -0
- package/dist/jev/browser-evidence-summary.d.ts.map +1 -0
- package/dist/jev/browser-evidence-summary.js +22 -0
- package/dist/jev/browser-evidence-summary.js.map +1 -0
- package/dist/jev/browser-module-import.d.ts +3 -0
- package/dist/jev/browser-module-import.d.ts.map +1 -0
- package/dist/jev/browser-module-import.js +6 -0
- package/dist/jev/browser-module-import.js.map +1 -0
- package/dist/jev/child-env.d.ts +11 -0
- package/dist/jev/child-env.d.ts.map +1 -0
- package/dist/jev/child-env.js +60 -0
- package/dist/jev/child-env.js.map +1 -0
- package/dist/jev/computer-connector.d.ts +34 -0
- package/dist/jev/computer-connector.d.ts.map +1 -0
- package/dist/jev/computer-connector.js +82 -0
- package/dist/jev/computer-connector.js.map +1 -0
- package/dist/jev/computer-inputs.d.ts +41 -0
- package/dist/jev/computer-inputs.d.ts.map +1 -0
- package/dist/jev/computer-inputs.js +7 -0
- package/dist/jev/computer-inputs.js.map +1 -0
- package/dist/jev/index.d.ts +6 -0
- package/dist/jev/index.d.ts.map +1 -0
- package/dist/jev/index.js +25 -0
- package/dist/jev/index.js.map +1 -0
- package/dist/jev/relay-grants.d.ts +9 -0
- package/dist/jev/relay-grants.d.ts.map +1 -0
- package/dist/jev/relay-grants.js +49 -0
- package/dist/jev/relay-grants.js.map +1 -0
- package/dist/jev/service.d.ts +27 -0
- package/dist/jev/service.d.ts.map +1 -0
- package/dist/jev/service.js +264 -0
- package/dist/jev/service.js.map +1 -0
- package/dist/jev/thinking-provider.d.ts +7 -0
- package/dist/jev/thinking-provider.d.ts.map +1 -0
- package/dist/jev/thinking-provider.js +25 -0
- package/dist/jev/thinking-provider.js.map +1 -0
- package/dist/jev/types.d.ts +124 -0
- package/dist/jev/types.d.ts.map +1 -0
- package/dist/jev/types.js +13 -0
- package/dist/jev/types.js.map +1 -0
- package/dist/jev/validation.d.ts +45 -0
- package/dist/jev/validation.d.ts.map +1 -0
- package/dist/jev/validation.js +179 -0
- package/dist/jev/validation.js.map +1 -0
- package/dist/load-dotenv.d.ts.map +1 -1
- package/dist/load-dotenv.js +5 -1
- package/dist/load-dotenv.js.map +1 -1
- package/dist/orchestration/agent-tool-schemas.d.ts.map +1 -1
- package/dist/orchestration/agent-tool-schemas.js +12 -7
- package/dist/orchestration/agent-tool-schemas.js.map +1 -1
- package/dist/orchestration/background-work.d.ts +1 -0
- package/dist/orchestration/background-work.d.ts.map +1 -1
- package/dist/orchestration/background-work.js +1 -0
- package/dist/orchestration/background-work.js.map +1 -1
- package/dist/orchestration/bridge.d.ts +4 -0
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +176 -41
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/browser-fields.d.ts +25 -0
- package/dist/orchestration/browser-fields.d.ts.map +1 -0
- package/dist/orchestration/browser-fields.js +23 -0
- package/dist/orchestration/browser-fields.js.map +1 -0
- package/dist/orchestration/browser-routing.d.ts +1 -1
- package/dist/orchestration/browser-routing.d.ts.map +1 -1
- package/dist/orchestration/browser-routing.js +7 -3
- package/dist/orchestration/browser-routing.js.map +1 -1
- package/dist/orchestration/capabilities.d.ts +4 -1
- package/dist/orchestration/capabilities.d.ts.map +1 -1
- package/dist/orchestration/capabilities.js +15 -9
- package/dist/orchestration/capabilities.js.map +1 -1
- package/dist/orchestration/channel-controls.js +1 -1
- package/dist/orchestration/channel-controls.js.map +1 -1
- package/dist/orchestration/cli-skills.d.ts.map +1 -1
- package/dist/orchestration/cli-skills.js +3 -2
- package/dist/orchestration/cli-skills.js.map +1 -1
- package/dist/orchestration/computer-end-screenshot.d.ts +11 -0
- package/dist/orchestration/computer-end-screenshot.d.ts.map +1 -0
- package/dist/orchestration/computer-end-screenshot.js +37 -0
- package/dist/orchestration/computer-end-screenshot.js.map +1 -0
- package/dist/orchestration/computer-prompt.d.ts +6 -0
- package/dist/orchestration/computer-prompt.d.ts.map +1 -0
- package/dist/orchestration/computer-prompt.js +24 -0
- package/dist/orchestration/computer-prompt.js.map +1 -0
- package/dist/orchestration/config.d.ts +17 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +10 -4
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/container-tool-schemas.d.ts +47 -3
- package/dist/orchestration/container-tool-schemas.d.ts.map +1 -1
- package/dist/orchestration/container-tool-schemas.js +41 -6
- package/dist/orchestration/container-tool-schemas.js.map +1 -1
- package/dist/orchestration/container.d.ts +4 -1
- package/dist/orchestration/container.d.ts.map +1 -1
- package/dist/orchestration/container.js +48 -29
- package/dist/orchestration/container.js.map +1 -1
- package/dist/orchestration/context-footprint.d.ts +1 -1
- package/dist/orchestration/context-footprint.d.ts.map +1 -1
- package/dist/orchestration/context-footprint.js +5 -5
- package/dist/orchestration/context-footprint.js.map +1 -1
- package/dist/orchestration/control-notification.d.ts +6 -0
- package/dist/orchestration/control-notification.d.ts.map +1 -0
- package/dist/orchestration/control-notification.js +23 -0
- package/dist/orchestration/control-notification.js.map +1 -0
- package/dist/orchestration/dashboard-reader-worker.js +2 -2
- package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
- package/dist/orchestration/execution-observation.d.ts +3 -0
- package/dist/orchestration/execution-observation.d.ts.map +1 -1
- package/dist/orchestration/execution-observation.js.map +1 -1
- package/dist/orchestration/gateway-tasks/browser.d.ts +59 -0
- package/dist/orchestration/gateway-tasks/browser.d.ts.map +1 -0
- package/dist/orchestration/gateway-tasks/browser.js +426 -0
- package/dist/orchestration/gateway-tasks/browser.js.map +1 -0
- package/dist/orchestration/gateway-tasks/computer-context.d.ts +6 -0
- package/dist/orchestration/gateway-tasks/computer-context.d.ts.map +1 -0
- package/dist/orchestration/gateway-tasks/computer-context.js +19 -0
- package/dist/orchestration/gateway-tasks/computer-context.js.map +1 -0
- package/dist/orchestration/gateway-tasks/computer.d.ts +123 -0
- package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -0
- package/dist/orchestration/gateway-tasks/computer.js +519 -0
- package/dist/orchestration/gateway-tasks/computer.js.map +1 -0
- package/dist/orchestration/gateway-tasks/controller.d.ts +40 -6
- package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/controller.js +118 -12
- package/dist/orchestration/gateway-tasks/controller.js.map +1 -1
- package/dist/orchestration/gateway-tasks/safemode.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/safemode.js +2 -1
- package/dist/orchestration/gateway-tasks/safemode.js.map +1 -1
- package/dist/orchestration/jev-gateway.d.ts +25 -0
- package/dist/orchestration/jev-gateway.d.ts.map +1 -0
- package/dist/orchestration/jev-gateway.js +103 -0
- package/dist/orchestration/jev-gateway.js.map +1 -0
- package/dist/orchestration/jev-tool.d.ts +45 -0
- package/dist/orchestration/jev-tool.d.ts.map +1 -0
- package/dist/orchestration/jev-tool.js +10 -0
- package/dist/orchestration/jev-tool.js.map +1 -0
- package/dist/orchestration/live-execution-input.d.ts +26 -0
- package/dist/orchestration/live-execution-input.d.ts.map +1 -0
- package/dist/orchestration/live-execution-input.js +70 -0
- package/dist/orchestration/live-execution-input.js.map +1 -0
- package/dist/orchestration/notification-mailbox.d.ts.map +1 -1
- package/dist/orchestration/notification-mailbox.js +5 -2
- package/dist/orchestration/notification-mailbox.js.map +1 -1
- package/dist/orchestration/process-platform.d.ts +0 -3
- package/dist/orchestration/process-platform.d.ts.map +1 -1
- package/dist/orchestration/process-platform.js +0 -4
- package/dist/orchestration/process-platform.js.map +1 -1
- package/dist/orchestration/process-turn.d.ts +8 -0
- package/dist/orchestration/process-turn.d.ts.map +1 -1
- package/dist/orchestration/process-turn.js +65 -8
- package/dist/orchestration/process-turn.js.map +1 -1
- package/dist/orchestration/response-errors.d.ts.map +1 -1
- package/dist/orchestration/response-errors.js +1 -0
- package/dist/orchestration/response-errors.js.map +1 -1
- package/dist/orchestration/runtime.d.ts +51 -1
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +383 -27
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/skill-catalog-budget.d.ts +6 -0
- package/dist/orchestration/skill-catalog-budget.d.ts.map +1 -0
- package/dist/orchestration/skill-catalog-budget.js +9 -0
- package/dist/orchestration/skill-catalog-budget.js.map +1 -0
- package/dist/orchestration/skills.d.ts +4 -2
- package/dist/orchestration/skills.d.ts.map +1 -1
- package/dist/orchestration/skills.js +44 -3
- package/dist/orchestration/skills.js.map +1 -1
- package/dist/orchestration/store.d.ts +1 -0
- package/dist/orchestration/store.d.ts.map +1 -1
- package/dist/orchestration/store.js +2 -0
- package/dist/orchestration/store.js.map +1 -1
- package/dist/orchestration/task-controls.d.ts +78 -8
- package/dist/orchestration/task-controls.d.ts.map +1 -1
- package/dist/orchestration/task-controls.js +6 -1
- package/dist/orchestration/task-controls.js.map +1 -1
- package/dist/orchestration/tasks/automation-session.d.ts +25 -0
- package/dist/orchestration/tasks/automation-session.d.ts.map +1 -0
- package/dist/orchestration/tasks/automation-session.js +68 -0
- package/dist/orchestration/tasks/automation-session.js.map +1 -0
- package/dist/orchestration/tasks/driver.d.ts.map +1 -1
- package/dist/orchestration/tasks/driver.js +3 -2
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/tasks/service.d.ts +68 -7
- package/dist/orchestration/tasks/service.d.ts.map +1 -1
- package/dist/orchestration/tasks/service.js +646 -44
- package/dist/orchestration/tasks/service.js.map +1 -1
- package/dist/orchestration/types.d.ts +82 -3
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/orchestration/types.js.map +1 -1
- package/dist/session/codex-extension-discovery.d.ts.map +1 -1
- package/dist/session/codex-extension-discovery.js +4 -2
- package/dist/session/codex-extension-discovery.js.map +1 -1
- package/dist/session/codex-native-mcp-client.d.ts.map +1 -1
- package/dist/session/codex-native-mcp-client.js +2 -1
- package/dist/session/codex-native-mcp-client.js.map +1 -1
- package/dist/session/codex-process.d.ts.map +1 -1
- package/dist/session/codex-process.js +9 -4
- package/dist/session/codex-process.js.map +1 -1
- package/dist/session/process.d.ts +16 -4
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +153 -75
- package/dist/session/process.js.map +1 -1
- package/dist/session/runtime-profile.d.ts +10 -5
- package/dist/session/runtime-profile.d.ts.map +1 -1
- package/dist/session/runtime-profile.js +5 -5
- package/dist/session/runtime-profile.js.map +1 -1
- package/dist/session/worker-extensions.d.ts.map +1 -1
- package/dist/session/worker-extensions.js +2 -1
- package/dist/session/worker-extensions.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/dashboard-client.d.ts.map +1 -1
- package/dist/ui/dashboard-client.js +33 -3
- package/dist/ui/dashboard-client.js.map +1 -1
- package/dist/ui/web-ui.js +1 -1
- package/lib/automation/browser-thinking.cjs +9 -0
- package/lib/automation/browser-thinking.d.cts +2 -0
- package/lib/automation/computer-thinking.cjs +10 -0
- package/lib/automation/computer-thinking.d.cts +2 -0
- package/lib/automation/index.cjs +47 -0
- package/lib/automation/index.d.cts +3 -0
- package/lib/automation/reasoning-instructions.cjs +5 -0
- package/lib/automation/thinking.cjs +35 -0
- package/lib/automation/thinking.d.cts +2 -0
- package/mcp/capability-catalog.ts +2 -2
- package/mcp/server.ts +1 -1
- package/mcp/tools/tasks/module.ts +9 -0
- package/package.json +5 -3
package/dist/api/router.js
CHANGED
|
@@ -42,6 +42,7 @@ const response_errors_1 = require("../orchestration/response-errors");
|
|
|
42
42
|
const voice_settings_router_1 = require("./voice-settings-router");
|
|
43
43
|
const express_1 = require("express");
|
|
44
44
|
const identity_1 = require("../orchestration/identity");
|
|
45
|
+
const types_1 = require("../orchestration/types");
|
|
45
46
|
const crypto_1 = require("crypto");
|
|
46
47
|
const fs = __importStar(require("fs"));
|
|
47
48
|
const fsp = __importStar(require("fs/promises"));
|
|
@@ -56,7 +57,7 @@ const config_write_lock_1 = require("../config/config-write-lock");
|
|
|
56
57
|
const auth_1 = require("./auth");
|
|
57
58
|
const media_store_1 = require("../history/media-store");
|
|
58
59
|
const db_1 = require("../history/db");
|
|
59
|
-
const
|
|
60
|
+
const types_2 = require("../history/types");
|
|
60
61
|
const wizard_state_1 = require("./wizard-state");
|
|
61
62
|
const pending_senders_1 = require("./pending-senders");
|
|
62
63
|
const create_agent_prompts_1 = require("../agent/create-agent-prompts");
|
|
@@ -117,6 +118,12 @@ const SAFE_FILENAME_RE = /^[a-zA-Z0-9._\-() ]+$/;
|
|
|
117
118
|
// escape the agent's directory. Clients may pass custom (non-UUID) session ids, so
|
|
118
119
|
// this preserves that while blocking path traversal.
|
|
119
120
|
const SESSION_ID_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
121
|
+
// Task and command ids are server/client-generated UUIDs; controlByUser rejects anything else.
|
|
122
|
+
const TASK_CONTROL_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
123
|
+
const TASK_CONTROL_ERROR_STATUS = {
|
|
124
|
+
INVALID_INPUT: 400, EXECUTION_DENIED: 403, AUTOMATION_SESSION_CLOSED: 410, COMMAND_QUEUE_FULL: 429,
|
|
125
|
+
REVISION_CONFLICT: 409, STATE_CONFLICT: 409, NOTHING_TO_RESUME: 409, IDEMPOTENCY_CONFLICT: 409, ORCHESTRATION_DISABLED: 409,
|
|
126
|
+
};
|
|
120
127
|
function isValidSessionId(v) {
|
|
121
128
|
return typeof v === 'string' && SESSION_ID_RE.test(v);
|
|
122
129
|
}
|
|
@@ -623,6 +630,11 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
623
630
|
return;
|
|
624
631
|
}
|
|
625
632
|
const clientMessageId = client_message_id;
|
|
633
|
+
if (body.execution_task_id !== undefined && !isValidSessionId(body.execution_task_id)) {
|
|
634
|
+
res.status(400).json({ error: 'Invalid execution task' });
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
const executionTaskId = body.execution_task_id;
|
|
626
638
|
if (message !== undefined && typeof message !== 'string') {
|
|
627
639
|
res.status(400).json({ error: 'message must be a string if provided' });
|
|
628
640
|
return;
|
|
@@ -811,7 +823,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
811
823
|
const inputId = await runner.acceptApiMessage(sessionId, chatIdStr, trimmedMessage, {
|
|
812
824
|
timeoutMs, allowTools: agentConfigs.get(agentId)?.allow_tools ?? !!apiKey.allow_tools, mediaFiles: validatedMediaFiles, model: modelStr,
|
|
813
825
|
imageParams: validatedImageParams, videoParams: validatedVideoParams,
|
|
814
|
-
requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId,
|
|
826
|
+
requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId, executionTaskId,
|
|
815
827
|
});
|
|
816
828
|
res.status(202).json({ status: 'accepted', input_id: inputId, session_id: sessionId, client_message_id: clientMessageId });
|
|
817
829
|
}
|
|
@@ -849,7 +861,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
849
861
|
openSseStream(res);
|
|
850
862
|
const agentCfg = agentConfigs.get(agentId);
|
|
851
863
|
const allowTools = agentCfg.allow_tools ?? !!apiKey.allow_tools;
|
|
852
|
-
onClientDisconnect = await runner.sendApiMessageStream(sessionId, chatIdStr, trimmedMessage, sseCallbacks, { timeoutMs, allowTools, mediaFiles: validatedMediaFiles, model: modelStr, skipUserMessage, imageParams: validatedImageParams, videoParams: validatedVideoParams, requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId });
|
|
864
|
+
onClientDisconnect = await runner.sendApiMessageStream(sessionId, chatIdStr, trimmedMessage, sseCallbacks, { timeoutMs, allowTools, mediaFiles: validatedMediaFiles, model: modelStr, skipUserMessage, imageParams: validatedImageParams, videoParams: validatedVideoParams, requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId, executionTaskId });
|
|
853
865
|
// Client disconnect — detaches this connection's sink. The turn keeps
|
|
854
866
|
// running and keeps buffering, so the client can resume it on a new
|
|
855
867
|
// connection via GET …/sessions/:sessionId/stream?after_seq= (#421).
|
|
@@ -896,7 +908,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
896
908
|
videoParams: validatedVideoParams,
|
|
897
909
|
requestId,
|
|
898
910
|
principalId: (0, identity_1.apiPrincipal)(apiKey),
|
|
899
|
-
clientMessageId,
|
|
911
|
+
clientMessageId, executionTaskId,
|
|
900
912
|
}));
|
|
901
913
|
}
|
|
902
914
|
const syncResult = {
|
|
@@ -4153,7 +4165,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4153
4165
|
return;
|
|
4154
4166
|
}
|
|
4155
4167
|
const { source, rawChatId } = parseHistoryChatId(chatId);
|
|
4156
|
-
if (!(0,
|
|
4168
|
+
if (!(0, types_2.isChatChannel)(source)) {
|
|
4157
4169
|
res.status(400).json({ error: 'Sessions endpoint only supports telegram/discord/line/slack/whatsapp/whatsapp_cloud chats' });
|
|
4158
4170
|
return;
|
|
4159
4171
|
}
|
|
@@ -4339,7 +4351,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4339
4351
|
return;
|
|
4340
4352
|
}
|
|
4341
4353
|
const { source, rawChatId } = parseHistoryChatId(chatId);
|
|
4342
|
-
if (!(0,
|
|
4354
|
+
if (!(0, types_2.isChatChannel)(source)) {
|
|
4343
4355
|
res.status(400).json({ error: 'Cross-channel messaging only supported for telegram/discord/line/slack/whatsapp/whatsapp_cloud chats' });
|
|
4344
4356
|
return;
|
|
4345
4357
|
}
|
|
@@ -5188,6 +5200,41 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
5188
5200
|
res.status(403).json({ error: 'Question unavailable for this principal or already answered' });
|
|
5189
5201
|
}
|
|
5190
5202
|
});
|
|
5203
|
+
router.post('/v1/agents/:agentId/sessions/:sessionId/tasks/:taskId/control', auth, async (req, res) => {
|
|
5204
|
+
const { agentId, sessionId, taskId } = req.params;
|
|
5205
|
+
const key = req.apiKey, runner = agentRunners.get(agentId);
|
|
5206
|
+
if (!(0, auth_1.canAccessAgent)(key, agentId) || !runner) {
|
|
5207
|
+
res.status(403).json({ error: 'ACCESS_DENIED' });
|
|
5208
|
+
return;
|
|
5209
|
+
}
|
|
5210
|
+
if (!isValidSessionId(sessionId) || !TASK_CONTROL_UUID_RE.test(taskId)) {
|
|
5211
|
+
res.status(400).json({ error: 'INVALID_INPUT' });
|
|
5212
|
+
return;
|
|
5213
|
+
}
|
|
5214
|
+
if (!(runner.getAgentConfig().allow_tools ?? Boolean(key.allow_tools))) {
|
|
5215
|
+
res.status(403).json({ error: 'EXECUTION_DENIED' });
|
|
5216
|
+
return;
|
|
5217
|
+
}
|
|
5218
|
+
const b = req.body;
|
|
5219
|
+
if (!b || Object.keys(b).some(k => !['id', 'action', 'expectedRevision', 'text'].includes(k)) || typeof b.id !== 'string' || !TASK_CONTROL_UUID_RE.test(b.id) || !['pause', 'revise', 'resume', 'agent', 'user'].includes(b.action) || !Number.isSafeInteger(b.expectedRevision) || b.expectedRevision < 1 || (b.action === 'revise' ? (typeof b.text !== 'string' || !b.text.trim() || b.text.length > 4000) : b.text !== undefined)) {
|
|
5220
|
+
res.status(400).json({ error: 'INVALID_INPUT' });
|
|
5221
|
+
return;
|
|
5222
|
+
}
|
|
5223
|
+
try {
|
|
5224
|
+
res.status(202).json({ task: await runner.controlApiTask(sessionId, (0, identity_1.apiPrincipal)(key), taskId, b) });
|
|
5225
|
+
}
|
|
5226
|
+
catch (e) {
|
|
5227
|
+
// Map by code: OrchestrationError messages may carry human-readable detail.
|
|
5228
|
+
const code = e instanceof types_1.OrchestrationError ? e.code : e instanceof Error ? e.message : '';
|
|
5229
|
+
const status = TASK_CONTROL_ERROR_STATUS[code];
|
|
5230
|
+
if (status) {
|
|
5231
|
+
res.status(status).json({ error: code });
|
|
5232
|
+
return;
|
|
5233
|
+
}
|
|
5234
|
+
// Unknown codes (e.g. TASK_NOT_FOUND) stay ACCESS_DENIED so task existence is not revealed.
|
|
5235
|
+
res.status(403).json({ error: 'ACCESS_DENIED' });
|
|
5236
|
+
}
|
|
5237
|
+
});
|
|
5191
5238
|
router.post('/v1/agents/:agentId/sessions/:sessionId/tasks/:taskId/cancel', auth, async (req, res) => {
|
|
5192
5239
|
const { agentId, sessionId, taskId } = req.params;
|
|
5193
5240
|
const key = req.apiKey, runner = agentRunners.get(agentId);
|