@0xmaxma/claude-gateway 2.0.20 → 2.0.21
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 +27 -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 +60 -42
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +304 -113
- 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 +4 -0
- 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 +29 -24
- package/dist/api/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/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 +120 -5
- 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 +17 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +21 -1
- package/dist/orchestration/config.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/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/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/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 +15 -1
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +148 -29
- 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 +4 -1
- 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/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/types.d.ts +3 -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 +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/voice/errors.d.ts +6 -1
- package/dist/voice/errors.d.ts.map +1 -1
- package/dist/voice/errors.js +8 -1
- package/dist/voice/errors.js.map +1 -1
- 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/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 +63 -6
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.collectManifest = collectManifest;
|
|
|
4
4
|
exports.cliRoutes = cliRoutes;
|
|
5
5
|
const route_registry_1 = require("./route-registry");
|
|
6
6
|
const cron_router_1 = require("./cron-router");
|
|
7
|
+
const pstack_router_1 = require("./pstack-router");
|
|
7
8
|
/**
|
|
8
9
|
* Populate the route manifest by instantiating every CONVERTED router with
|
|
9
10
|
* throwaway deps. Each factory's defineRoute() calls mount their routes (which
|
|
@@ -18,6 +19,8 @@ function collectManifest() {
|
|
|
18
19
|
(0, route_registry_1.resetRegisteredRoutes)();
|
|
19
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
21
|
(0, cron_router_1.createCronRouter)(undefined);
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
(0, pstack_router_1.createPstackRouter)(undefined, new Map(), undefined, () => undefined);
|
|
21
24
|
return (0, route_registry_1.getRegisteredRoutes)();
|
|
22
25
|
}
|
|
23
26
|
/** The subset of the manifest exposed as friendly CLI commands. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-sources.js","sourceRoot":"","sources":["../../src/api/manifest-sources.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"manifest-sources.js","sourceRoot":"","sources":["../../src/api/manifest-sources.ts"],"names":[],"mappings":";;AAcA,0CASC;AAGD,8BAEC;AA5BD,qDAAwF;AACxF,+CAAiD;AACjD,mDAAqD;AAErD;;;;;;;;;GASG;AACH,SAAgB,eAAe;IAC7B,IAAA,sCAAqB,GAAE,CAAC;IAExB,8DAA8D;IAC9D,IAAA,8BAAgB,EAAC,SAAgB,CAAC,CAAC;IACnC,8DAA8D;IAC9D,IAAA,kCAAkB,EAAC,SAAgB,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAE5E,OAAO,IAAA,oCAAmB,GAAE,CAAC;AAC/B,CAAC;AAED,mEAAmE;AACnE,SAAgB,SAAS;IACvB,OAAO,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import type { AgentConfig, ApiKey, ModelConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Per-agent pstack setup (`agents[].pstack`). pstack itself is installed through
|
|
5
|
+
* Claude Code (`/plugin install pstack@pstack-claude`); these routes only decide
|
|
6
|
+
* which agents' workers load it, and with which models per role.
|
|
7
|
+
*
|
|
8
|
+
* PUT /v1/agents/:agentId/pstack — pstack enable — Set up pstack for the agent
|
|
9
|
+
* DELETE /v1/agents/:agentId/pstack — pstack disable — Remove it; workers stop loading pstack
|
|
10
|
+
*
|
|
11
|
+
* An admin key may change any agent; a write key, the agents it can access.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPstackRouter(apiKeys: ApiKey[], agentConfigs: Map<string, AgentConfig> | (() => Map<string, AgentConfig>), configPath: string | undefined, models: () => ModelConfig[] | undefined): Router;
|
|
14
|
+
//# sourceMappingURL=pstack-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pstack-router.d.ts","sourceRoot":"","sources":["../../src/api/pstack-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AASjE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,EAC7H,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,EAAE,GAAG,SAAS,GAAG,MAAM,CAgDjF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPstackRouter = createPstackRouter;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const auth_1 = require("./auth");
|
|
6
|
+
const route_registry_1 = require("./route-registry");
|
|
7
|
+
const model_registry_1 = require("../agent/model-registry");
|
|
8
|
+
const config_1 = require("../pstack/config");
|
|
9
|
+
const setup_1 = require("../pstack/setup");
|
|
10
|
+
/**
|
|
11
|
+
* Per-agent pstack setup (`agents[].pstack`). pstack itself is installed through
|
|
12
|
+
* Claude Code (`/plugin install pstack@pstack-claude`); these routes only decide
|
|
13
|
+
* which agents' workers load it, and with which models per role.
|
|
14
|
+
*
|
|
15
|
+
* PUT /v1/agents/:agentId/pstack — pstack enable — Set up pstack for the agent
|
|
16
|
+
* DELETE /v1/agents/:agentId/pstack — pstack disable — Remove it; workers stop loading pstack
|
|
17
|
+
*
|
|
18
|
+
* An admin key may change any agent; a write key, the agents it can access.
|
|
19
|
+
*/
|
|
20
|
+
function createPstackRouter(apiKeys, agentConfigs, configPath, models) {
|
|
21
|
+
const router = (0, express_1.Router)();
|
|
22
|
+
if (apiKeys)
|
|
23
|
+
router.use((0, auth_1.createApiAuthMiddleware)(apiKeys));
|
|
24
|
+
const agents = () => typeof agentConfigs === 'function' ? agentConfigs() : agentConfigs;
|
|
25
|
+
/** `update` gets the saved block and returns the new one, or undefined to remove it. */
|
|
26
|
+
async function save(req, res, update) {
|
|
27
|
+
const { agentId } = req.params;
|
|
28
|
+
if (!(0, auth_1.canWriteAgent)(req.apiKey, agentId)) {
|
|
29
|
+
res.status(403).json({ error: 'Write permission required' });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!configPath) {
|
|
33
|
+
res.status(501).json({ error: 'Agent management not available (no configPath)' });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const agent = agents().get(agentId);
|
|
37
|
+
if (!agent) {
|
|
38
|
+
res.status(404).json({ error: `Agent '${agentId}' not found` });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const { saved } = await (0, setup_1.updatePstackConfig)(configPath, agentId, update, await (0, model_registry_1.selectableModels)(models()));
|
|
43
|
+
// Workers read the live agent config at start; config reload also applies it.
|
|
44
|
+
if (saved)
|
|
45
|
+
agent.pstack = saved;
|
|
46
|
+
else
|
|
47
|
+
delete agent.pstack;
|
|
48
|
+
res.json({ agentId, pstack: saved ?? null });
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error instanceof config_1.PstackConfigError) {
|
|
52
|
+
res.status(400).json({ error: error.message, code: error.code });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (error.code === 'AGENT_NOT_FOUND') {
|
|
56
|
+
res.status(404).json({ error: `Agent '${agentId}' not found` });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
console.error(`[api] pstack save failed for agent '${agentId}':`, error.message);
|
|
60
|
+
res.status(500).json({ error: 'Failed to save pstack configuration' });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
(0, route_registry_1.defineRoute)(router, {
|
|
64
|
+
method: 'PUT', path: '/v1/agents/:agentId/pstack', auth: 'key',
|
|
65
|
+
summary: 'Set up pstack for an agent: its workers load the pstack Claude Code plugin with these role models (full model IDs)',
|
|
66
|
+
cli: { noun: 'pstack', verb: 'enable', args: ['agentId'], flags: [
|
|
67
|
+
{ name: 'roles', in: 'body', description: 'JSON map of pstack role -> "<model-id>[ @<level>]" (comma-separated for panel roles); replaces the saved roles, {} resets them. Omitted: unchanged' },
|
|
68
|
+
{ name: 'defaultEffort', in: 'body', description: 'session | low | medium | high | xhigh | max. Omitted: unchanged' },
|
|
69
|
+
] },
|
|
70
|
+
}, (req, res) => {
|
|
71
|
+
const body = (req.body ?? {});
|
|
72
|
+
let roles = body.roles;
|
|
73
|
+
if (typeof roles === 'string') {
|
|
74
|
+
try {
|
|
75
|
+
roles = JSON.parse(roles);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
res.status(400).json({ error: 'roles must be a JSON object', code: 'INVALID_PSTACK_CONFIG' });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// A field left out keeps its saved value, so `pstack enable` on an agent already set up changes nothing;
|
|
83
|
+
// `roles: {}` resets every role to the skill default.
|
|
84
|
+
void save(req, res, previous => ({ ...previous, ...body, ...(roles !== undefined ? { roles } : {}) }));
|
|
85
|
+
});
|
|
86
|
+
(0, route_registry_1.defineRoute)(router, {
|
|
87
|
+
method: 'DELETE', path: '/v1/agents/:agentId/pstack', auth: 'key',
|
|
88
|
+
summary: 'Remove pstack from an agent; its workers stop loading the plugin',
|
|
89
|
+
cli: { noun: 'pstack', verb: 'disable', args: ['agentId'] },
|
|
90
|
+
}, (req, res) => { void save(req, res, () => undefined); });
|
|
91
|
+
return router;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=pstack-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pstack-router.js","sourceRoot":"","sources":["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E,OAAO,EAAE,kEAAkE;QAC3E,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;KAC5D,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5D,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/api/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/api/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAW,QAAQ,EAAE,MAAM,SAAS,CAAC;AASpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAe,WAAW,EAAe,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/api/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAW,QAAQ,EAAE,MAAM,SAAS,CAAC;AASpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAe,WAAW,EAAe,MAAM,UAAU,CAAC;AAyFtF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAExD;AAMD,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAEtD;AAkFD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CA4CjD;AAmUD,wBAAgB,eAAe,CAC7B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EACtC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EACtC,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,WAAW,EAAE,GAAG,SAAS,CAAC,GACzD,MAAM,CAk5IR"}
|
package/dist/api/router.js
CHANGED
|
@@ -61,8 +61,7 @@ const types_2 = require("../history/types");
|
|
|
61
61
|
const wizard_state_1 = require("./wizard-state");
|
|
62
62
|
const pending_senders_1 = require("./pending-senders");
|
|
63
63
|
const create_agent_prompts_1 = require("../agent/create-agent-prompts");
|
|
64
|
-
const
|
|
65
|
-
const runner_2 = require("../agent/runner");
|
|
64
|
+
const model_registry_1 = require("../agent/model-registry");
|
|
66
65
|
const whatsapp_accounts_1 = require("../config/whatsapp-accounts");
|
|
67
66
|
const whatsapp_access_1 = require("./whatsapp-access");
|
|
68
67
|
const MAX_MESSAGE_LENGTH = 10000;
|
|
@@ -134,6 +133,15 @@ function isValidSessionId(v) {
|
|
|
134
133
|
function isValidAgentId(v) {
|
|
135
134
|
return typeof v === 'string' && AGENT_ID_RE.test(v);
|
|
136
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* The structured part of a built-in command reply, beside its text: `command`
|
|
138
|
+
* (the base command), `result` (its fields) and `actions` (buttons; each
|
|
139
|
+
* `command` is sent back as the next message, so it runs with the same key,
|
|
140
|
+
* session and checks as anything typed).
|
|
141
|
+
*/
|
|
142
|
+
function commandReplyFields(message, reply) {
|
|
143
|
+
return { command: message.trim().split(/\s+/)[0], result: reply.result, actions: reply.actions ?? [] };
|
|
144
|
+
}
|
|
137
145
|
/**
|
|
138
146
|
* The one place a turn's stream events become SSE frames (#421).
|
|
139
147
|
*
|
|
@@ -164,7 +172,7 @@ function createSseCallbacks(res, meta) {
|
|
|
164
172
|
}
|
|
165
173
|
catch { /* client gone */ }
|
|
166
174
|
},
|
|
167
|
-
onDone: (fullText, attachments, seq) => {
|
|
175
|
+
onDone: (fullText, attachments, seq, extra) => {
|
|
168
176
|
try {
|
|
169
177
|
const frame = {
|
|
170
178
|
type: 'result',
|
|
@@ -172,6 +180,7 @@ function createSseCallbacks(res, meta) {
|
|
|
172
180
|
seq,
|
|
173
181
|
...ids(),
|
|
174
182
|
duration_ms: Date.now() - meta.startTime,
|
|
183
|
+
...extra,
|
|
175
184
|
};
|
|
176
185
|
if (attachments?.length)
|
|
177
186
|
frame['attachments'] = attachments;
|
|
@@ -844,9 +853,9 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
844
853
|
if (isBuiltinCommand) {
|
|
845
854
|
openSseStream(res);
|
|
846
855
|
try {
|
|
847
|
-
const
|
|
848
|
-
sseCallbacks.onChunk({ type: 'text_delta', text: responseText });
|
|
849
|
-
sseCallbacks.onDone(responseText, []);
|
|
856
|
+
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 });
|
|
857
|
+
sseCallbacks.onChunk({ type: 'text_delta', text: reply.responseText });
|
|
858
|
+
sseCallbacks.onDone(reply.responseText, [], undefined, commandReplyFields(commandMessage, reply));
|
|
850
859
|
}
|
|
851
860
|
catch (err) {
|
|
852
861
|
sseCallbacks.onError(err);
|
|
@@ -891,9 +900,12 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
891
900
|
try {
|
|
892
901
|
let responseText;
|
|
893
902
|
let attachments = [];
|
|
903
|
+
let commandFields = {};
|
|
894
904
|
if (isBuiltinCommand) {
|
|
895
|
-
// Built-in command — answer locally, return the same JSON shape as a normal reply.
|
|
896
|
-
|
|
905
|
+
// Built-in command — answer locally, return the same JSON shape as a normal reply plus its structured part.
|
|
906
|
+
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 });
|
|
907
|
+
responseText = reply.responseText;
|
|
908
|
+
commandFields = commandReplyFields(commandMessage, reply);
|
|
897
909
|
}
|
|
898
910
|
else {
|
|
899
911
|
const agentCfgSync = agentConfigs.get(agentId);
|
|
@@ -917,6 +929,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
917
929
|
response: responseText,
|
|
918
930
|
session_id: sessionId,
|
|
919
931
|
duration_ms: Date.now() - startTime,
|
|
932
|
+
...commandFields,
|
|
920
933
|
};
|
|
921
934
|
if (attachments.length)
|
|
922
935
|
syncResult['attachments'] = attachments;
|
|
@@ -948,19 +961,11 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
948
961
|
* into config.json at provisioning time (issue #409).
|
|
949
962
|
*/
|
|
950
963
|
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;
|
|
964
|
+
// availableModels() falls back to DEFAULT_MODELS, never `[]`: the
|
|
965
|
+
// catalog cache inherits alias/contextWindow/multiplier from whichever
|
|
966
|
+
// caller's list populated it first, so this route must pass the same list
|
|
967
|
+
// the runner does or one request here degrades the picker for 60 seconds.
|
|
968
|
+
const available = await (0, model_registry_1.availableModels)(typeof models === 'function' ? models() : models);
|
|
964
969
|
res.json({ models: available.map((m) => ({ id: m.id, name: m.label, alias: m.alias, contextWindow: m.contextWindow, multiplier: m.multiplier ?? 1 })) });
|
|
965
970
|
});
|
|
966
971
|
/**
|
|
@@ -4941,7 +4946,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4941
4946
|
const { runner, chatId } = ctx;
|
|
4942
4947
|
const { sessionId } = req.params;
|
|
4943
4948
|
try {
|
|
4944
|
-
const { result } = await runner.executeApiCommand(sessionId, chatId, '/clear', { skipPersist: true });
|
|
4949
|
+
const { result } = await runner.executeApiCommand(sessionId, chatId, '/clear confirm', { skipPersist: true });
|
|
4945
4950
|
res.json(result);
|
|
4946
4951
|
}
|
|
4947
4952
|
catch (err) {
|
|
@@ -4958,7 +4963,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4958
4963
|
const { runner, chatId } = ctx;
|
|
4959
4964
|
const { sessionId } = req.params;
|
|
4960
4965
|
try {
|
|
4961
|
-
const { result } = await runner.executeApiCommand(sessionId, chatId, '/compact', { skipPersist: true });
|
|
4966
|
+
const { result } = await runner.executeApiCommand(sessionId, chatId, '/compact confirm', { skipPersist: true });
|
|
4962
4967
|
res.json(result);
|
|
4963
4968
|
}
|
|
4964
4969
|
catch (err) {
|
|
@@ -4992,7 +4997,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
|
|
|
4992
4997
|
const { runner, chatId } = ctx;
|
|
4993
4998
|
const { sessionId } = req.params;
|
|
4994
4999
|
try {
|
|
4995
|
-
const { result } = await runner.executeApiCommand(sessionId, chatId, '/restart', { skipPersist: true });
|
|
5000
|
+
const { result } = await runner.executeApiCommand(sessionId, chatId, '/restart confirm', { skipPersist: true });
|
|
4996
5001
|
res.json(result);
|
|
4997
5002
|
}
|
|
4998
5003
|
catch (err) {
|