@0xmaxma/claude-gateway 2.1.9 → 2.1.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/config.template.json +4 -0
- package/dist/agent/runner.d.ts +93 -6
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +342 -108
- package/dist/agent/runner.js.map +1 -1
- package/dist/api/async-guard.d.ts +13 -0
- package/dist/api/async-guard.d.ts.map +1 -0
- package/dist/api/async-guard.js +38 -0
- package/dist/api/async-guard.js.map +1 -0
- package/dist/api/auth.d.ts +5 -0
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +3 -0
- package/dist/api/auth.js.map +1 -1
- package/dist/api/browser-bindings-router.d.ts.map +1 -1
- package/dist/api/browser-bindings-router.js +2 -0
- package/dist/api/browser-bindings-router.js.map +1 -1
- package/dist/api/capabilities.d.ts +47 -2
- package/dist/api/capabilities.d.ts.map +1 -1
- package/dist/api/capabilities.js +51 -8
- package/dist/api/capabilities.js.map +1 -1
- package/dist/api/files-router.d.ts +23 -0
- package/dist/api/files-router.d.ts.map +1 -0
- package/dist/api/files-router.js +102 -0
- package/dist/api/files-router.js.map +1 -0
- package/dist/api/gateway-router.d.ts +4 -2
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +20 -2
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/git-router.d.ts +4 -0
- package/dist/api/git-router.d.ts.map +1 -0
- package/dist/api/git-router.js +51 -0
- package/dist/api/git-router.js.map +1 -0
- package/dist/api/manifest-sources.d.ts.map +1 -1
- package/dist/api/manifest-sources.js +6 -0
- package/dist/api/manifest-sources.js.map +1 -1
- package/dist/api/processes-router.d.ts +28 -0
- package/dist/api/processes-router.d.ts.map +1 -0
- package/dist/api/processes-router.js +179 -0
- package/dist/api/processes-router.js.map +1 -0
- package/dist/api/router.d.ts +41 -1
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +112 -25
- package/dist/api/router.js.map +1 -1
- package/dist/api/voice-router.d.ts.map +1 -1
- package/dist/api/voice-router.js +2 -0
- package/dist/api/voice-router.js.map +1 -1
- package/dist/automation/browser-outcome.d.ts +3 -1
- package/dist/automation/browser-outcome.d.ts.map +1 -1
- package/dist/automation/browser-outcome.js +2 -2
- package/dist/automation/browser-outcome.js.map +1 -1
- package/dist/automation/command-speech.d.ts +9 -1
- package/dist/automation/command-speech.d.ts.map +1 -1
- package/dist/automation/command-speech.js +18 -0
- package/dist/automation/command-speech.js.map +1 -1
- package/dist/automation/command-steps.d.ts +2 -0
- package/dist/automation/command-steps.d.ts.map +1 -1
- package/dist/automation/command-steps.js +34 -2
- package/dist/automation/command-steps.js.map +1 -1
- package/dist/automation/computer-command.d.ts +1 -0
- package/dist/automation/computer-command.d.ts.map +1 -1
- package/dist/automation/computer-command.js +31 -5
- package/dist/automation/computer-command.js.map +1 -1
- package/dist/automation/computer-outcome.d.ts +26 -3
- package/dist/automation/computer-outcome.d.ts.map +1 -1
- package/dist/automation/computer-outcome.js +183 -13
- package/dist/automation/computer-outcome.js.map +1 -1
- package/dist/automation/computer-policy.d.ts +10 -1
- package/dist/automation/computer-policy.d.ts.map +1 -1
- package/dist/automation/computer-policy.js +20 -6
- package/dist/automation/computer-policy.js.map +1 -1
- package/dist/automation/computer-use.d.ts +34 -0
- package/dist/automation/computer-use.d.ts.map +1 -1
- package/dist/automation/computer-use.js +211 -17
- package/dist/automation/computer-use.js.map +1 -1
- package/dist/automation/direct-command.d.ts +8 -0
- package/dist/automation/direct-command.d.ts.map +1 -1
- package/dist/automation/direct-command.js +12 -0
- package/dist/automation/direct-command.js.map +1 -1
- package/dist/automation/model-choice-evaluator.d.ts +3 -0
- package/dist/automation/model-choice-evaluator.d.ts.map +1 -1
- package/dist/automation/model-choice-evaluator.js +3 -1
- package/dist/automation/model-choice-evaluator.js.map +1 -1
- package/dist/automation/vision-decider.d.ts +4 -2
- package/dist/automation/vision-decider.d.ts.map +1 -1
- package/dist/automation/vision-decider.js +69 -15
- package/dist/automation/vision-decider.js.map +1 -1
- package/dist/build-provenance.json +4 -4
- package/dist/cli/redact.d.ts +1 -0
- package/dist/cli/redact.d.ts.map +1 -1
- package/dist/cli/redact.js +12 -0
- package/dist/cli/redact.js.map +1 -1
- package/dist/config/loader.d.ts +5 -0
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +121 -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 +1 -0
- package/dist/config/reload-policy.js.map +1 -1
- package/dist/config/watcher.d.ts.map +1 -1
- package/dist/config/watcher.js +1 -0
- package/dist/config/watcher.js.map +1 -1
- package/dist/files/config.d.ts +6 -0
- package/dist/files/config.d.ts.map +1 -0
- package/dist/files/config.js +15 -0
- package/dist/files/config.js.map +1 -0
- package/dist/files/delete.d.ts +27 -0
- package/dist/files/delete.d.ts.map +1 -0
- package/dist/files/delete.js +143 -0
- package/dist/files/delete.js.map +1 -0
- package/dist/files/fs.d.ts +70 -0
- package/dist/files/fs.d.ts.map +1 -0
- package/dist/files/fs.js +319 -0
- package/dist/files/fs.js.map +1 -0
- package/dist/files/holds.d.ts +11 -0
- package/dist/files/holds.d.ts.map +1 -0
- package/dist/files/holds.js +20 -0
- package/dist/files/holds.js.map +1 -0
- package/dist/files/paths.d.ts +26 -0
- package/dist/files/paths.d.ts.map +1 -0
- package/dist/files/paths.js +112 -0
- package/dist/files/paths.js.map +1 -0
- package/dist/files/session-cwd.d.ts +8 -0
- package/dist/files/session-cwd.d.ts.map +1 -0
- package/dist/files/session-cwd.js +139 -0
- package/dist/files/session-cwd.js.map +1 -0
- package/dist/git/read.d.ts +25 -0
- package/dist/git/read.d.ts.map +1 -0
- package/dist/git/read.js +166 -0
- package/dist/git/read.js.map +1 -0
- package/dist/git/runner.d.ts +46 -0
- package/dist/git/runner.d.ts.map +1 -0
- package/dist/git/runner.js +176 -0
- package/dist/git/runner.js.map +1 -0
- package/dist/git/status.d.ts +119 -0
- package/dist/git/status.d.ts.map +1 -0
- package/dist/git/status.js +273 -0
- package/dist/git/status.js.map +1 -0
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/jev/browser-contract.d.ts +3 -0
- package/dist/jev/browser-contract.d.ts.map +1 -1
- package/dist/jev/browser-contract.js +6 -0
- package/dist/jev/browser-contract.js.map +1 -1
- package/dist/orchestration/agent-tool-schemas.d.ts +18 -0
- package/dist/orchestration/agent-tool-schemas.d.ts.map +1 -1
- package/dist/orchestration/agent-tool-schemas.js +11 -3
- package/dist/orchestration/agent-tool-schemas.js.map +1 -1
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +26 -5
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/browser-routing.d.ts.map +1 -1
- package/dist/orchestration/browser-routing.js +2 -1
- package/dist/orchestration/browser-routing.js.map +1 -1
- package/dist/orchestration/computer-decisions.d.ts +1 -1
- package/dist/orchestration/computer-decisions.d.ts.map +1 -1
- package/dist/orchestration/computer-decisions.js +21 -7
- package/dist/orchestration/computer-decisions.js.map +1 -1
- package/dist/orchestration/computer-live.d.ts +62 -0
- package/dist/orchestration/computer-live.d.ts.map +1 -0
- package/dist/orchestration/computer-live.js +126 -0
- package/dist/orchestration/computer-live.js.map +1 -0
- package/dist/orchestration/container-tool-schemas.d.ts.map +1 -1
- package/dist/orchestration/container-tool-schemas.js +3 -0
- package/dist/orchestration/container-tool-schemas.js.map +1 -1
- package/dist/orchestration/decisions.d.ts +3 -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/gateway-tasks/browser.d.ts +1 -1
- package/dist/orchestration/gateway-tasks/browser.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/browser.js +4 -3
- package/dist/orchestration/gateway-tasks/browser.js.map +1 -1
- package/dist/orchestration/gateway-tasks/computer-context.d.ts +4 -1
- package/dist/orchestration/gateway-tasks/computer-context.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/computer-context.js +3 -1
- package/dist/orchestration/gateway-tasks/computer-context.js.map +1 -1
- package/dist/orchestration/gateway-tasks/computer.d.ts +78 -15
- package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/computer.js +298 -31
- package/dist/orchestration/gateway-tasks/computer.js.map +1 -1
- package/dist/orchestration/gateway-tasks/controller.d.ts +14 -2
- package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/controller.js +63 -2
- package/dist/orchestration/gateway-tasks/controller.js.map +1 -1
- package/dist/orchestration/notification-mailbox.js +3 -3
- package/dist/orchestration/notification-mailbox.js.map +1 -1
- package/dist/orchestration/process-turn.d.ts.map +1 -1
- package/dist/orchestration/process-turn.js +4 -1
- 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 +2 -0
- package/dist/orchestration/response-errors.js.map +1 -1
- package/dist/orchestration/runtime.d.ts +32 -2
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +106 -10
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/task-controls.d.ts +8 -0
- package/dist/orchestration/task-controls.d.ts.map +1 -1
- package/dist/orchestration/task-controls.js +3 -2
- package/dist/orchestration/task-controls.js.map +1 -1
- package/dist/orchestration/tasks/automation-session.d.ts +42 -11
- package/dist/orchestration/tasks/automation-session.d.ts.map +1 -1
- package/dist/orchestration/tasks/automation-session.js +101 -21
- 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 +19 -1
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/tasks/service.d.ts +48 -2
- package/dist/orchestration/tasks/service.d.ts.map +1 -1
- package/dist/orchestration/tasks/service.js +165 -16
- package/dist/orchestration/tasks/service.js.map +1 -1
- package/dist/orchestration/telegram-tool-status.d.ts.map +1 -1
- package/dist/orchestration/telegram-tool-status.js +2 -0
- package/dist/orchestration/telegram-tool-status.js.map +1 -1
- package/dist/orchestration/types.d.ts +21 -0
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/orchestration/types.js.map +1 -1
- package/dist/processes/listeners.d.ts +41 -0
- package/dist/processes/listeners.d.ts.map +1 -0
- package/dist/processes/listeners.js +140 -0
- package/dist/processes/listeners.js.map +1 -0
- package/dist/processes/start.d.ts +39 -0
- package/dist/processes/start.d.ts.map +1 -0
- package/dist/processes/start.js +208 -0
- package/dist/processes/start.js.map +1 -0
- package/dist/processes/stop.d.ts +37 -0
- package/dist/processes/stop.d.ts.map +1 -0
- package/dist/processes/stop.js +94 -0
- package/dist/processes/stop.js.map +1 -0
- package/dist/session/cwd.d.ts +65 -0
- package/dist/session/cwd.d.ts.map +1 -0
- package/dist/session/cwd.js +24 -0
- package/dist/session/cwd.js.map +1 -0
- package/dist/session/process.d.ts +17 -0
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +58 -3
- package/dist/session/process.js.map +1 -1
- package/dist/session/runtime-profile.d.ts +4 -0
- package/dist/session/runtime-profile.d.ts.map +1 -1
- package/dist/session/runtime-profile.js +1 -0
- package/dist/session/runtime-profile.js.map +1 -1
- package/dist/session/store.d.ts +13 -1
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +50 -4
- package/dist/session/store.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/voice-call-client.d.ts +3 -0
- package/dist/ui/voice-call-client.d.ts.map +1 -1
- package/dist/ui/voice-call-client.js +10 -1
- package/dist/ui/voice-call-client.js.map +1 -1
- package/dist/utils/paths.d.ts +5 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +15 -0
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/result.d.ts +16 -0
- package/dist/utils/result.d.ts.map +1 -0
- package/dist/utils/result.js +8 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/voice/errors.js +1 -1
- package/dist/voice/errors.js.map +1 -1
- package/dist/voice/providers/elevenlabs-tts.d.ts.map +1 -1
- package/dist/voice/providers/elevenlabs-tts.js +17 -1
- package/dist/voice/providers/elevenlabs-tts.js.map +1 -1
- package/dist/voice/providers/socket.js +25 -6
- package/dist/voice/providers/socket.js.map +1 -1
- package/dist/voice/session.js +3 -2
- package/dist/voice/session.js.map +1 -1
- package/mcp/server.ts +1 -1
- package/mcp/tools/tasks/module.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Request, Response, Router } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Express 4 ignores the promise an async handler returns, so a throw after the first `await` would reach the
|
|
4
|
+
* process-level unhandledRejection handler, which shuts the gateway down. Route the rejection to the response
|
|
5
|
+
* instead: 500 JSON, or a closed socket once headers are out.
|
|
6
|
+
*/
|
|
7
|
+
export type RouteFailure = (req: Request, res: Response, err: unknown) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Make every handler later registered on `router` answer a throw or a rejection through `fail` instead of crashing.
|
|
10
|
+
* The default logs the stack to the console and answers 500 `{ error: 'Internal error' }`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function guardAsyncRoutes<R extends Router>(router: R, fail?: RouteFailure): R;
|
|
13
|
+
//# sourceMappingURL=async-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-guard.d.ts","sourceRoot":"","sources":["../../src/api/async-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,OAAO,EAAkB,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIvF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;AAoB/E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAE,YAAwB,GAAG,CAAC,CAO/F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guardAsyncRoutes = guardAsyncRoutes;
|
|
4
|
+
const METHODS = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'all'];
|
|
5
|
+
const answer500 = (req, res, err) => {
|
|
6
|
+
console.error(`[api] ${req.method} ${req.path} failed: ${err?.stack ?? String(err)}`);
|
|
7
|
+
if (res.headersSent) {
|
|
8
|
+
res.end();
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
res.status(500).json({ error: 'Internal error' });
|
|
12
|
+
};
|
|
13
|
+
function guard(fn, fail) {
|
|
14
|
+
if (fn.length > 3 || typeof fn.stack !== 'undefined')
|
|
15
|
+
return fn;
|
|
16
|
+
return (req, res, next) => {
|
|
17
|
+
try {
|
|
18
|
+
const out = fn(req, res, next);
|
|
19
|
+
if (out && typeof out.catch === 'function')
|
|
20
|
+
out.catch((err) => fail(req, res, err));
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
fail(req, res, err);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Make every handler later registered on `router` answer a throw or a rejection through `fail` instead of crashing.
|
|
29
|
+
* The default logs the stack to the console and answers 500 `{ error: 'Internal error' }`.
|
|
30
|
+
*/
|
|
31
|
+
function guardAsyncRoutes(router, fail = answer500) {
|
|
32
|
+
for (const method of METHODS) {
|
|
33
|
+
const original = router[method].bind(router);
|
|
34
|
+
router[method] = (...args) => original(...args.map((a) => (typeof a === 'function' ? guard(a, fail) : Array.isArray(a) ? a.map((f) => (typeof f === 'function' ? guard(f, fail) : f)) : a)));
|
|
35
|
+
}
|
|
36
|
+
return router;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=async-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-guard.js","sourceRoot":"","sources":["../../src/api/async-guard.ts"],"names":[],"mappings":";;AAiCA,4CAOC;AAtCD,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAU,CAAC;AAS7F,MAAM,SAAS,GAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IAChD,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,YAAa,GAAa,EAAE,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;QAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAAC,OAAO;IAAC,CAAC;IAC3C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,SAAS,KAAK,CAAC,EAAkB,EAAE,IAAkB;IACnD,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,OAAQ,EAAqC,CAAC,KAAK,KAAK,WAAW;QAAE,OAAO,EAAE,CAAC;IACpG,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;QAC/D,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAY,CAAC;YAC1C,IAAI,GAAG,IAAI,OAAQ,GAAwB,CAAC,KAAK,KAAK,UAAU;gBAAG,GAAwB,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAClI,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAmB,MAAS,EAAE,OAAqB,SAAS;IAC1F,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAI,MAAkE,CAAC,MAAM,CAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1G,MAA6C,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAC9E,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAmB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAmB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvM,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/api/auth.d.ts
CHANGED
|
@@ -22,4 +22,9 @@ export declare function canWriteAgent(apiKey: ApiKey, agentId: string): boolean;
|
|
|
22
22
|
* Returns true if the key has admin privileges (cross-agent + destructive ops).
|
|
23
23
|
*/
|
|
24
24
|
export declare function isAdmin(apiKey: ApiKey): boolean;
|
|
25
|
+
/** The 403 body for a files route that needs an admin key. */
|
|
26
|
+
export declare const ADMIN_KEY_REQUIRED: {
|
|
27
|
+
readonly error: "An admin API key is required";
|
|
28
|
+
readonly code: "forbidden_key";
|
|
29
|
+
};
|
|
25
30
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/api/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,IAC/B,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,IAAI,CAoC/E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAIvE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE/C"}
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,IAC/B,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,IAAI,CAoC/E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAIvE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB;;;CAA4E,CAAC"}
|
package/dist/api/auth.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADMIN_KEY_REQUIRED = void 0;
|
|
3
4
|
exports.createApiAuthMiddleware = createApiAuthMiddleware;
|
|
4
5
|
exports.canAccessAgent = canAccessAgent;
|
|
5
6
|
exports.canWriteAgent = canWriteAgent;
|
|
@@ -74,4 +75,6 @@ function canWriteAgent(apiKey, agentId) {
|
|
|
74
75
|
function isAdmin(apiKey) {
|
|
75
76
|
return apiKey.admin === true;
|
|
76
77
|
}
|
|
78
|
+
/** The 403 body for a files route that needs an admin key. */
|
|
79
|
+
exports.ADMIN_KEY_REQUIRED = { error: 'An admin API key is required', code: 'forbidden_key' };
|
|
77
80
|
//# sourceMappingURL=auth.js.map
|
package/dist/api/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":";;;AAWA,0DAqCC;AAMD,wCAIC;AAMD,sCAGC;AAKD,0BAEC;AAzED,mCAAyC;AAGzC;;;;;;GAMG;AACH,SAAgB,uBAAuB,CAAC,OAAiB;IACvD,OAAO,SAAS,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QACrE,MAAM,UA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,CAAC;QACvD,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,OAAe;IAC5D,IAAI,MAAM,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACvC,OAAQ,MAAM,CAAC,MAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,MAAc,EAAE,OAAe;IAC3D,IAAI,MAAM,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAC9B,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC;AAC/B,CAAC;AAED,8DAA8D;AACjD,QAAA,kBAAkB,GAAG,EAAE,KAAK,EAAE,8BAA8B,EAAE,IAAI,EAAE,eAAe,EAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-bindings-router.d.ts","sourceRoot":"","sources":["../../src/api/browser-bindings-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-bindings-router.d.ts","sourceRoot":"","sources":["../../src/api/browser-bindings-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,UAAU,CAAC;AAatD,2GAA2G;AAC3G,wBAAgB,2BAA2B,CAAC,MAAM,EAAC,aAAa,EAAC,OAAO,EAAC,GAAG,CAAC,MAAM,EAAC,WAAW,CAAC,EAAC,UAAU,CAAC,EAAC,MAAM,GAAE,MAAM,CAoF1H"}
|
|
@@ -5,6 +5,7 @@ const express_1 = require("express");
|
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const promises_1 = require("fs/promises");
|
|
7
7
|
const auth_1 = require("./auth");
|
|
8
|
+
const router_1 = require("./router");
|
|
8
9
|
const identity_1 = require("../orchestration/identity");
|
|
9
10
|
const config_write_lock_1 = require("../config/config-write-lock");
|
|
10
11
|
const browser_connector_1 = require("../jev/browser-connector");
|
|
@@ -15,6 +16,7 @@ const jev_gateway_1 = require("../orchestration/jev-gateway");
|
|
|
15
16
|
/** Binding administration uses existing admin auth. Session identity is derived, never caller supplied. */
|
|
16
17
|
function createBrowserBindingsRouter(config, runners, configPath) {
|
|
17
18
|
const router = (0, express_1.Router)();
|
|
19
|
+
router.param('sessionId', router_1.requireValidSessionId);
|
|
18
20
|
const base = '/v1/agents/:agentId/sessions/:sessionId';
|
|
19
21
|
router.use(base + '/browser-bindings', (req, res, next) => (0, auth_1.createApiAuthMiddleware)(config.gateway.api?.keys ?? [])(req, res, next));
|
|
20
22
|
const currentKey = (req) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-bindings-router.js","sourceRoot":"","sources":["../../src/api/browser-bindings-router.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"browser-bindings-router.js","sourceRoot":"","sources":["../../src/api/browser-bindings-router.ts"],"names":[],"mappings":";;AAkBA,kEAoFC;AAtGD,qCAA0C;AAC1C,mCAAgD;AAChD,0CAAuC;AAGvC,iCAA0E;AAC1E,qCAAiD;AACjD,wDAAyD;AACzD,mEAAqF;AACrF,gEAAgH;AAChH,wCAAwC;AACxC,kDAA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/D,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { ApiKey } from '../types';
|
|
3
3
|
import { type ChatChannel } from '../history/types';
|
|
4
|
+
import type { GatewayConfig } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* Capability manifest — the single place that declares which optional features
|
|
6
7
|
* this gateway build supports, so clients can feature-detect instead of pinning
|
|
@@ -32,14 +33,57 @@ import { type ChatChannel } from '../history/types';
|
|
|
32
33
|
* automatically, and nothing here can drift out of the canonical union.
|
|
33
34
|
*/
|
|
34
35
|
export declare const CROSS_CHANNEL_MESSAGE_CHANNELS: readonly ChatChannel[];
|
|
36
|
+
/**
|
|
37
|
+
* Folder operations served by files-router.ts under the one files root. Clients gate listing on `includes('list')`,
|
|
38
|
+
* `POST /v1/files/mkdir` on `includes('create')`, `DELETE /v1/files` on `includes('delete')`, and
|
|
39
|
+
* The gateway serves no file contents; they are viewed in code-server.
|
|
40
|
+
*/
|
|
41
|
+
export declare const FILES_CAPABILITIES: readonly ["list", "create", "delete"];
|
|
42
|
+
export type FilesCapability = (typeof FILES_CAPABILITIES)[number];
|
|
43
|
+
/** The operations files-router.ts serves only to an admin key; every other token is open to any key. */
|
|
44
|
+
export declare const FILES_ADMIN_CAPABILITIES: ReadonlySet<FilesCapability>;
|
|
45
|
+
/** Read-only git routes served by git-router.ts: `GET /v1/git/status` and `GET /v1/git/summary`. */
|
|
46
|
+
export declare const GIT_CAPABILITIES: readonly ["status", "summary"];
|
|
47
|
+
export type GitCapability = (typeof GIT_CAPABILITIES)[number];
|
|
48
|
+
/**
|
|
49
|
+
* `cwd`: `POST /v1/agents/:agentId/sessions` accepts `cwd`, a folder under the files root, and runs the chat there.
|
|
50
|
+
* It is accepted through the queued-admission path, which needs orchestration, so a gateway without it does not
|
|
51
|
+
* advertise the token and a client never sends a cwd it would not honour.
|
|
52
|
+
*/
|
|
53
|
+
export declare const SESSIONS_CAPABILITIES: readonly ["cwd"];
|
|
54
|
+
export type SessionsCapability = (typeof SESSIONS_CAPABILITIES)[number];
|
|
55
|
+
/**
|
|
56
|
+
* Routes served by processes-router.ts for folders under the files root: `list` is `GET /v1/processes`, `start` is
|
|
57
|
+
* `POST /v1/processes/start` and `stop` is `POST /v1/processes/stop`; all three need an admin key.
|
|
58
|
+
*/
|
|
59
|
+
export declare const PROCESSES_CAPABILITIES: readonly ["list", "start", "stop"];
|
|
60
|
+
export type ProcessesCapability = (typeof PROCESSES_CAPABILITIES)[number];
|
|
35
61
|
export interface CapabilitiesResponse {
|
|
36
62
|
/** Gateway version from package.json. Informational — clients should key off `capabilities`, not parse this. */
|
|
37
63
|
version: string;
|
|
38
64
|
capabilities: {
|
|
39
65
|
cross_channel_message: ChatChannel[];
|
|
66
|
+
files: FilesCapability[];
|
|
67
|
+
git: GitCapability[];
|
|
68
|
+
sessions: SessionsCapability[];
|
|
69
|
+
processes: ProcessesCapability[];
|
|
40
70
|
};
|
|
71
|
+
/** Why `files`, `git`, `sessions` and `processes` are empty; absent when the files API is usable. */
|
|
72
|
+
filesUnavailable?: FilesUnavailable;
|
|
73
|
+
/** The absolute files root, the value `GET /v1/files` reports as `root`; absent when the files API is off. */
|
|
74
|
+
filesRoot?: string;
|
|
41
75
|
}
|
|
42
|
-
|
|
76
|
+
/** `disabled`: the gateway serves no files or git API. */
|
|
77
|
+
export type FilesUnavailable = 'disabled';
|
|
78
|
+
type FilesAvailability = Pick<CapabilitiesResponse['capabilities'], 'files' | 'git' | 'sessions' | 'processes'> & {
|
|
79
|
+
filesUnavailable?: FilesUnavailable;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* The tokens `apiKey` may use. A non-admin key gets every token but the admin-only ones. A gateway with orchestration
|
|
83
|
+
* off does not advertise `sessions: ['cwd']`. Without a config or a key (tests) the gateway-wide answer is given.
|
|
84
|
+
*/
|
|
85
|
+
export declare function filesAvailability(config?: GatewayConfig, apiKey?: ApiKey): FilesAvailability;
|
|
86
|
+
export declare function buildCapabilitiesResponse(version?: string, config?: GatewayConfig, apiKey?: ApiKey, filesRoot?: string | null): CapabilitiesResponse;
|
|
43
87
|
/**
|
|
44
88
|
* `GET /api/v1/capabilities`. Always behind API-key auth — the response carries
|
|
45
89
|
* the gateway version, which `/health` deliberately withholds from
|
|
@@ -49,5 +93,6 @@ export declare function buildCapabilitiesResponse(version?: string): Capabilitie
|
|
|
49
93
|
* endpoint 404s rather than serving open access. `apiKeys` is therefore always
|
|
50
94
|
* the configured, non-empty key set.
|
|
51
95
|
*/
|
|
52
|
-
export declare function createCapabilitiesRouter(apiKeys: ApiKey[]): Router;
|
|
96
|
+
export declare function createCapabilitiesRouter(apiKeys: ApiKey[], config?: GatewayConfig): Router;
|
|
97
|
+
export {};
|
|
53
98
|
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/api/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/api/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAMnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,EAAE,SAAS,WAAW,EAAuB,CAAC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gB,CAAC,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE1J;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAU5F;AAED,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,MAAwB,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,oBAAoB,CAQrK;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAQ1F"}
|
package/dist/api/capabilities.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CROSS_CHANNEL_MESSAGE_CHANNELS = void 0;
|
|
3
|
+
exports.PROCESSES_CAPABILITIES = exports.SESSIONS_CAPABILITIES = exports.GIT_CAPABILITIES = exports.FILES_ADMIN_CAPABILITIES = exports.FILES_CAPABILITIES = exports.CROSS_CHANNEL_MESSAGE_CHANNELS = void 0;
|
|
4
|
+
exports.filesAvailability = filesAvailability;
|
|
4
5
|
exports.buildCapabilitiesResponse = buildCapabilitiesResponse;
|
|
5
6
|
exports.createCapabilitiesRouter = createCapabilitiesRouter;
|
|
6
7
|
const express_1 = require("express");
|
|
7
8
|
const types_1 = require("../history/types");
|
|
8
9
|
const auth_1 = require("./auth");
|
|
9
10
|
const gateway_version_1 = require("./gateway-version");
|
|
11
|
+
const gateway_config_1 = require("../orchestration/gateway-config");
|
|
12
|
+
const config_1 = require("../files/config");
|
|
13
|
+
const fs_1 = require("../files/fs");
|
|
10
14
|
/**
|
|
11
15
|
* Capability manifest — the single place that declares which optional features
|
|
12
16
|
* this gateway build supports, so clients can feature-detect instead of pinning
|
|
@@ -38,12 +42,50 @@ const gateway_version_1 = require("./gateway-version");
|
|
|
38
42
|
* automatically, and nothing here can drift out of the canonical union.
|
|
39
43
|
*/
|
|
40
44
|
exports.CROSS_CHANNEL_MESSAGE_CHANNELS = [...types_1.CHAT_CHANNELS];
|
|
41
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Folder operations served by files-router.ts under the one files root. Clients gate listing on `includes('list')`,
|
|
47
|
+
* `POST /v1/files/mkdir` on `includes('create')`, `DELETE /v1/files` on `includes('delete')`, and
|
|
48
|
+
* The gateway serves no file contents; they are viewed in code-server.
|
|
49
|
+
*/
|
|
50
|
+
exports.FILES_CAPABILITIES = ['list', 'create', 'delete'];
|
|
51
|
+
/** The operations files-router.ts serves only to an admin key; every other token is open to any key. */
|
|
52
|
+
exports.FILES_ADMIN_CAPABILITIES = new Set(['create', 'delete']);
|
|
53
|
+
/** Read-only git routes served by git-router.ts: `GET /v1/git/status` and `GET /v1/git/summary`. */
|
|
54
|
+
exports.GIT_CAPABILITIES = ['status', 'summary'];
|
|
55
|
+
/**
|
|
56
|
+
* `cwd`: `POST /v1/agents/:agentId/sessions` accepts `cwd`, a folder under the files root, and runs the chat there.
|
|
57
|
+
* It is accepted through the queued-admission path, which needs orchestration, so a gateway without it does not
|
|
58
|
+
* advertise the token and a client never sends a cwd it would not honour.
|
|
59
|
+
*/
|
|
60
|
+
exports.SESSIONS_CAPABILITIES = ['cwd'];
|
|
61
|
+
/**
|
|
62
|
+
* Routes served by processes-router.ts for folders under the files root: `list` is `GET /v1/processes`, `start` is
|
|
63
|
+
* `POST /v1/processes/start` and `stop` is `POST /v1/processes/stop`; all three need an admin key.
|
|
64
|
+
*/
|
|
65
|
+
exports.PROCESSES_CAPABILITIES = ['list', 'start', 'stop'];
|
|
66
|
+
/**
|
|
67
|
+
* The tokens `apiKey` may use. A non-admin key gets every token but the admin-only ones. A gateway with orchestration
|
|
68
|
+
* off does not advertise `sessions: ['cwd']`. Without a config or a key (tests) the gateway-wide answer is given.
|
|
69
|
+
*/
|
|
70
|
+
function filesAvailability(config, apiKey) {
|
|
71
|
+
if (config && !(0, config_1.filesEnabled)(config))
|
|
72
|
+
return { files: [], git: [], sessions: [], processes: [], filesUnavailable: 'disabled' };
|
|
73
|
+
const orchestrated = !config || (0, gateway_config_1.gatewayOrchestrationEnabled)(config.gateway.orchestration);
|
|
74
|
+
const admin = !apiKey || (0, auth_1.isAdmin)(apiKey);
|
|
75
|
+
return {
|
|
76
|
+
files: exports.FILES_CAPABILITIES.filter((c) => admin || !exports.FILES_ADMIN_CAPABILITIES.has(c)),
|
|
77
|
+
git: [...exports.GIT_CAPABILITIES],
|
|
78
|
+
sessions: orchestrated ? [...exports.SESSIONS_CAPABILITIES] : [],
|
|
79
|
+
processes: admin ? [...exports.PROCESSES_CAPABILITIES] : [],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function buildCapabilitiesResponse(version = gateway_version_1.GATEWAY_VERSION, config, apiKey, filesRoot) {
|
|
83
|
+
const { filesUnavailable, ...tokens } = filesAvailability(config, apiKey);
|
|
42
84
|
return {
|
|
43
85
|
version,
|
|
44
|
-
capabilities: {
|
|
45
|
-
|
|
46
|
-
},
|
|
86
|
+
capabilities: { cross_channel_message: [...exports.CROSS_CHANNEL_MESSAGE_CHANNELS], ...tokens },
|
|
87
|
+
...(filesUnavailable ? { filesUnavailable } : {}),
|
|
88
|
+
...(!filesUnavailable && filesRoot ? { filesRoot } : {}),
|
|
47
89
|
};
|
|
48
90
|
}
|
|
49
91
|
/**
|
|
@@ -55,11 +97,12 @@ function buildCapabilitiesResponse(version = gateway_version_1.GATEWAY_VERSION)
|
|
|
55
97
|
* endpoint 404s rather than serving open access. `apiKeys` is therefore always
|
|
56
98
|
* the configured, non-empty key set.
|
|
57
99
|
*/
|
|
58
|
-
function createCapabilitiesRouter(apiKeys) {
|
|
100
|
+
function createCapabilitiesRouter(apiKeys, config) {
|
|
59
101
|
const router = (0, express_1.Router)();
|
|
60
102
|
router.use((0, auth_1.createApiAuthMiddleware)(apiKeys));
|
|
61
|
-
router.get('/v1/capabilities', (
|
|
62
|
-
|
|
103
|
+
router.get('/v1/capabilities', async (req, res) => {
|
|
104
|
+
const filesRoot = config && (0, config_1.filesEnabled)(config) ? await (0, fs_1.reportedRoot)((0, config_1.resolveFilesRoot)(config)) : null;
|
|
105
|
+
res.json(buildCapabilitiesResponse(gateway_version_1.GATEWAY_VERSION, config, req.apiKey, filesRoot));
|
|
63
106
|
});
|
|
64
107
|
return router;
|
|
65
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/api/capabilities.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/api/capabilities.ts"],"names":[],"mappings":";;;AAkGA,8CAUC;AAED,8DAQC;AAWD,4DAQC;AAzID,qCAAoD;AAEpD,4CAAmE;AACnE,iCAA0D;AAC1D,uDAAoD;AACpD,oEAA8E;AAC9E,4CAAiE;AACjE,oCAA2C;AAG3C;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;GAeG;AACU,QAAA,8BAA8B,GAA2B,CAAC,GAAG,qBAAa,CAAC,CAAC;AAEzF;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAGxE,wGAAwG;AAC3F,QAAA,wBAAwB,GAAiC,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEpG,oGAAoG;AACvF,QAAA,gBAAgB,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAU,CAAC;AAG/D;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,CAAC,KAAK,CAAU,CAAC;AAGtD;;;GAGG;AACU,QAAA,sBAAsB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAwBzE;;;GAGG;AACH,SA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GAAG,CAAC,CAAC,gBAAgB,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,OAAiB,EAAE,MAAsB;IAChF,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;IACxB,MAAM,CAAC,GAAG,CAAC,IAAA,8BAAuB,EAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;QACnE,MAAM,SAAS,GAAG,MAAM,IAAI,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,iBAAY,EAAC,IAAA,yBAAgB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACvG,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,iCAAe,EAAE,MAAM,EAAG,GAAoC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACxH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { ApiKey, Logger } from '../types';
|
|
3
|
+
import { DeleteErrorCode } from '../files/delete';
|
|
4
|
+
import { FilesErrorCode } from '../files/paths';
|
|
5
|
+
import { GitErrorCode } from '../git/read';
|
|
6
|
+
export type FilesApiErrorCode = FilesErrorCode | GitErrorCode | DeleteErrorCode | 'confirm_mismatch';
|
|
7
|
+
/** Every error code the files and git routes answer, with its status. website/api/files.md publishes this table. */
|
|
8
|
+
export declare const FILES_ERRORS: Record<FilesApiErrorCode, {
|
|
9
|
+
status: number;
|
|
10
|
+
message: string;
|
|
11
|
+
}>;
|
|
12
|
+
export interface FilesRouterDeps {
|
|
13
|
+
/** The gateway logger, for warnings such as a failed `git init` or a delete that left files behind. */
|
|
14
|
+
logger: Logger;
|
|
15
|
+
/** A chat turn, a spawning session or a task works in this real folder, in one inside it, or in one holding it. */
|
|
16
|
+
inUse?: (realDir: string) => boolean | Promise<boolean>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Pod-wide folder and git routes under one root. Paths are relative to the root and every segment follows the entry
|
|
20
|
+
* name rule. Any key may read; creating and deleting change the pod and need an admin key.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createFilesRouter(apiKeys: ApiKey[], root: string, deps: FilesRouterDeps): Router;
|
|
23
|
+
//# sourceMappingURL=files-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-router.d.ts","sourceRoot":"","sources":["../../src/api/files-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,MAAM,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAK1C,OAAO,EAAE,eAAe,EAAe,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAuC,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAY,YAAY,EAAE,MAAM,aAAa,CAAC;AAKrD,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,YAAY,GAAG,eAAe,GAAG,kBAAkB,CAAC;AAErG,oHAAoH;AACpH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,iBAAiB,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqBvF,CAAC;AAyBF,MAAM,WAAW,eAAe;IAC9B,uGAAuG;IACvG,MAAM,EAAE,MAAM,CAAC;IACf,mHAAmH;IACnH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAuDhG"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FILES_ERRORS = void 0;
|
|
4
|
+
exports.createFilesRouter = createFilesRouter;
|
|
5
|
+
const express_1 = require("express");
|
|
6
|
+
const auth_1 = require("./auth");
|
|
7
|
+
const async_guard_1 = require("./async-guard");
|
|
8
|
+
const route_registry_1 = require("./route-registry");
|
|
9
|
+
const fs_1 = require("../files/fs");
|
|
10
|
+
const delete_1 = require("../files/delete");
|
|
11
|
+
const paths_1 = require("../files/paths");
|
|
12
|
+
/** Every error code the files and git routes answer, with its status. website/api/files.md publishes this table. */
|
|
13
|
+
exports.FILES_ERRORS = {
|
|
14
|
+
invalid_path: { status: 400, message: 'path must be a relative path of entry names joined by /' },
|
|
15
|
+
invalid_name: { status: 400, message: 'A path segment is not a valid entry name' },
|
|
16
|
+
not_a_directory: { status: 400, message: 'Not a directory' },
|
|
17
|
+
confirm_mismatch: { status: 400, message: 'confirm must equal the last segment of path' },
|
|
18
|
+
path_escape: { status: 403, message: 'Path resolves outside the files root' },
|
|
19
|
+
permission_denied: { status: 403, message: 'Permission denied' },
|
|
20
|
+
forbidden_key: { status: 403, message: auth_1.ADMIN_KEY_REQUIRED.error },
|
|
21
|
+
not_found: { status: 404, message: 'Not found' },
|
|
22
|
+
already_exists: { status: 409, message: 'An entry with this name already exists' },
|
|
23
|
+
symlink_in_path: { status: 409, message: 'A folder above the entry is a symbolic link' },
|
|
24
|
+
cross_device: { status: 409, message: 'The entry is on another filesystem or holds a mount point' },
|
|
25
|
+
in_use: { status: 409, message: 'A chat or task is working in this folder' },
|
|
26
|
+
deleting: { status: 409, message: 'The folder is being deleted' },
|
|
27
|
+
not_a_git_repo: { status: 409, message: 'The folder is not a git repository' },
|
|
28
|
+
git_unsafe_owner: { status: 409, message: "Git refuses this repository because another user owns it. Run `git config --global --add safe.directory <path>` as the gateway's user, or fix the owner." },
|
|
29
|
+
git_unreadable: { status: 409, message: 'This is a git repository the gateway cannot read safely: check its permissions, its config, and any filter drivers it defines' },
|
|
30
|
+
internal: { status: 500, message: 'Internal error' },
|
|
31
|
+
git_failed: { status: 500, message: 'Git failed' },
|
|
32
|
+
git_unavailable: { status: 503, message: 'Git is not installed on this machine, or is not on the gateway\'s PATH' },
|
|
33
|
+
timeout: { status: 504, message: 'Git took too long' },
|
|
34
|
+
};
|
|
35
|
+
function fail(res, error) {
|
|
36
|
+
const body = typeof error === 'string' ? { code: error } : error;
|
|
37
|
+
const { status, message } = exports.FILES_ERRORS[body.code];
|
|
38
|
+
res.status(status).json({ error: message, ...body });
|
|
39
|
+
}
|
|
40
|
+
function respond(res, result, status = 200) {
|
|
41
|
+
if (result.ok)
|
|
42
|
+
res.status(status).json(result.value);
|
|
43
|
+
else
|
|
44
|
+
fail(res, result.error);
|
|
45
|
+
}
|
|
46
|
+
function requireAdmin(req, res, next) {
|
|
47
|
+
if ((0, auth_1.isAdmin)(req.apiKey))
|
|
48
|
+
next();
|
|
49
|
+
else
|
|
50
|
+
fail(res, 'forbidden_key');
|
|
51
|
+
}
|
|
52
|
+
/** `?path=`, absent meaning the root. Repeated or nested query values are not strings and are refused. */
|
|
53
|
+
function queryPath(req, includeHidden = false) {
|
|
54
|
+
return (0, paths_1.parseRelPath)(req.query.path ?? '', includeHidden);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Pod-wide folder and git routes under one root. Paths are relative to the root and every segment follows the entry
|
|
58
|
+
* name rule. Any key may read; creating and deleting change the pod and need an admin key.
|
|
59
|
+
*/
|
|
60
|
+
function createFilesRouter(apiKeys, root, deps) {
|
|
61
|
+
const { logger } = deps;
|
|
62
|
+
// The message and stack can carry paths and secrets, so only the error's class and errno code are logged.
|
|
63
|
+
const router = (0, async_guard_1.guardAsyncRoutes)((0, express_1.Router)(), (req, res, err) => {
|
|
64
|
+
const code = err?.code;
|
|
65
|
+
logger.error(`files: ${req.method} ${req.path} failed: ${err instanceof Error ? err.name : typeof err}${typeof code === 'string' ? ` ${code}` : ''}`);
|
|
66
|
+
if (res.headersSent)
|
|
67
|
+
res.end();
|
|
68
|
+
else
|
|
69
|
+
fail(res, 'internal');
|
|
70
|
+
});
|
|
71
|
+
const auth = (0, auth_1.createApiAuthMiddleware)(apiKeys);
|
|
72
|
+
(0, route_registry_1.defineRoute)(router, { method: 'GET', path: '/v1/files', auth: 'key', summary: 'List the folders directly under a path of the files root', cli: null }, auth, async (req, res) => {
|
|
73
|
+
const hidden = req.query.include_hidden;
|
|
74
|
+
if (hidden !== undefined && hidden !== 'true' && hidden !== 'false')
|
|
75
|
+
return fail(res, 'invalid_path');
|
|
76
|
+
const rel = queryPath(req, hidden === 'true');
|
|
77
|
+
if (!rel.ok)
|
|
78
|
+
return fail(res, rel.error);
|
|
79
|
+
respond(res, await (0, fs_1.listDir)(root, rel.value, hidden === 'true'));
|
|
80
|
+
});
|
|
81
|
+
(0, route_registry_1.defineRoute)(router, { method: 'POST', path: '/v1/files/mkdir', auth: 'admin', summary: 'Create one new folder under the files root', cli: null }, auth, requireAdmin, async (req, res) => {
|
|
82
|
+
const body = (req.body ?? {});
|
|
83
|
+
const rel = (0, paths_1.parseRelPath)(body.path);
|
|
84
|
+
if (!rel.ok)
|
|
85
|
+
return fail(res, rel.error);
|
|
86
|
+
respond(res, await (0, fs_1.makeDir)(root, rel.value, body.git_init === true, logger), 201);
|
|
87
|
+
});
|
|
88
|
+
(0, route_registry_1.defineRoute)(router, { method: 'DELETE', path: '/v1/files', auth: 'admin', summary: 'Delete a folder under the files root and everything in it', cli: null }, auth, requireAdmin, async (req, res) => {
|
|
89
|
+
const body = (req.body ?? {});
|
|
90
|
+
const rel = (0, paths_1.parseRelPath)(body.path, true);
|
|
91
|
+
if (!rel.ok)
|
|
92
|
+
return fail(res, rel.error);
|
|
93
|
+
const name = (0, paths_1.pathSegments)(rel.value).pop();
|
|
94
|
+
if (name === undefined)
|
|
95
|
+
return fail(res, 'invalid_path');
|
|
96
|
+
if (body.confirm !== name)
|
|
97
|
+
return fail(res, 'confirm_mismatch');
|
|
98
|
+
respond(res, await (0, delete_1.deleteEntry)(root, rel.value, { logger, inUse: deps.inUse ?? (() => false) }));
|
|
99
|
+
});
|
|
100
|
+
return router;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=files-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-router.js","sourceRoot":"","sources":["../../src/api/files-router.ts"],"names":[],"mappings":";;;AAyEA,8CAuDC;AAhID,qCAAkE;AAElE,iCAA8E;AAC9E,+CAAiD;AACjD,qDAA+C;AAC/C,oCAA+C;AAC/C,4CAA+D;AAC/D,0CAAqF;AAQrF,oHAAoH;AACvG,QAAA,YAAY,GAAmE;IAC1F,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,yDAAyD,EAAE;IACjG,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,0CAA0C,EAAE;IAClF,eAAe,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,EAAE;IAC5D,gBAAgB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,6CAA6C,EAAE;IACzF,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,sCAAsC,EAAE;IAC7E,iBAAiB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,mBAAmB,EAAE;IAChE,aAAa,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,yBAAkB,CAAC,KAAK,EAAE;IACjE,SAAS,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE;IAChD,cAAc,EAAE,EAAE,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EAAE,MAAM,IAAA,oBAAW,EAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACnG,CAAC,CACF,CAAC;IAGF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { AgentRunner } from '../agent/runner';
|
|
3
|
-
import { AgentConfig, AgentStats, ApiKey, GatewayConfig } from '../types';
|
|
3
|
+
import { AgentConfig, AgentStats, ApiKey, GatewayConfig, Logger } from '../types';
|
|
4
4
|
import { CronScheduler } from '../cron/scheduler';
|
|
5
5
|
import { CronManager } from '../cron/manager';
|
|
6
6
|
import { AppsRegistry } from '../apps/registry';
|
|
@@ -69,7 +69,9 @@ export declare class GatewayRouter {
|
|
|
69
69
|
* and an OAuth-flow completion can't race each other's read-modify-write
|
|
70
70
|
* of gateway.customConnectors — see custom-connectors-store.ts. */
|
|
71
71
|
private readonly customConnectorsStore;
|
|
72
|
-
|
|
72
|
+
/** The gateway-wide logger (logs/gateway.log); console when a test builds the router without one. */
|
|
73
|
+
private readonly logger;
|
|
74
|
+
constructor(agents: Map<string, AgentRunner>, configs: Map<string, AgentConfig>, schedulers?: Map<string, CronScheduler>, gatewayConfig?: GatewayConfig, cronManager?: CronManager, configPath?: string, appsRegistry?: AppsRegistry, appInstaller?: AppInstaller, appRegistryClient?: RegistryClient, logger?: Logger);
|
|
73
75
|
/** Configured API keys ([] when none set — auth is then disabled/open). */
|
|
74
76
|
private get apiKeys();
|
|
75
77
|
/** Extract a Bearer / X-Api-Key token from request headers. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-router.d.ts","sourceRoot":"","sources":["../../src/api/gateway-router.ts"],"names":[],"mappings":"AAQA,OAAO,OAA8B,MAAM,SAAS,CAAC;A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,GAAG,IAAI;IAKxB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsIxC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,qBAAqB;IAqB7B,sFAAsF;IACtF,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,GAAG,KAAK,EACnB,SAAS,EAAE,MAAM,GAChB,IAAI;IAIP,gEAAgE;IAChE,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAS5C,+EAA+E;IACzE,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC3B,MAAM,IAAI,OAAO,CAAC,WAAW;IAM7B;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IASvD;;OAEG;IACH,UAAU,IAAI,WAAW,EAAE;IAI3B;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAWtC;;OAEG;IACH,aAAa,IAAI,UAAU,EAAE;CAe9B"}
|
|
@@ -80,6 +80,10 @@ const meta_router_1 = require("./meta-router");
|
|
|
80
80
|
const capabilities_1 = require("./capabilities");
|
|
81
81
|
const gateway_version_1 = require("./gateway-version");
|
|
82
82
|
const workspace_router_1 = require("./workspace-router");
|
|
83
|
+
const files_router_1 = require("./files-router");
|
|
84
|
+
const git_router_1 = require("./git-router");
|
|
85
|
+
const processes_router_1 = require("./processes-router");
|
|
86
|
+
const config_1 = require("../files/config");
|
|
83
87
|
const skills_router_1 = require("./skills-router");
|
|
84
88
|
const packages_1 = require("./packages");
|
|
85
89
|
const webhooks_router_1 = require("./webhooks-router");
|
|
@@ -231,7 +235,7 @@ class RateLimiter {
|
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
237
|
class GatewayRouter {
|
|
234
|
-
constructor(agents, configs, schedulers, gatewayConfig, cronManager, configPath, appsRegistry, appInstaller, appRegistryClient) {
|
|
238
|
+
constructor(agents, configs, schedulers, gatewayConfig, cronManager, configPath, appsRegistry, appInstaller, appRegistryClient, logger) {
|
|
235
239
|
var _a, _b;
|
|
236
240
|
this.dashboardReader = new dashboard_reader_1.DashboardReader();
|
|
237
241
|
this.dashboardStreams = new Set();
|
|
@@ -273,6 +277,7 @@ class GatewayRouter {
|
|
|
273
277
|
this.appsRegistry = appsRegistry;
|
|
274
278
|
this.appInstaller = appInstaller;
|
|
275
279
|
this.appRegistryClient = appRegistryClient;
|
|
280
|
+
this.logger = logger ?? console;
|
|
276
281
|
this.customConnectorsStore = (0, custom_connectors_store_1.createCustomConnectorsStore)(configPath);
|
|
277
282
|
this.app = (0, express_1.default)();
|
|
278
283
|
// Initialise counters for all known agents
|
|
@@ -694,6 +699,19 @@ class GatewayRouter {
|
|
|
694
699
|
const workspaceRouter = (0, workspace_router_1.createWorkspaceRouter)(this.configs, this.gatewayConfig.gateway.api.keys);
|
|
695
700
|
this.app.use('/api', workspaceRouter);
|
|
696
701
|
}
|
|
702
|
+
// Mount the pod-wide files and git API (gateway.files.root, default ~/projects)
|
|
703
|
+
if (this.gatewayConfig?.gateway?.api?.keys && (0, config_1.filesEnabled)(this.gatewayConfig)) {
|
|
704
|
+
const root = (0, config_1.resolveFilesRoot)(this.gatewayConfig);
|
|
705
|
+
this.app.use('/api', (0, files_router_1.createFilesRouter)(this.gatewayConfig.gateway.api.keys, (0, config_1.resolveFilesRoot)(this.gatewayConfig), {
|
|
706
|
+
logger: this.logger,
|
|
707
|
+
inUse: async (dir) => {
|
|
708
|
+
await Promise.all([...this.agents.values()].map((runner) => runner.prepareWorkCheck()));
|
|
709
|
+
return [...this.agents.values()].some((runner) => [...runner.workIn(dir)].some((reason) => reason !== 'session'));
|
|
710
|
+
},
|
|
711
|
+
}));
|
|
712
|
+
this.app.use('/api', (0, git_router_1.createGitRouter)(this.gatewayConfig.gateway.api.keys, root, this.logger));
|
|
713
|
+
this.app.use('/api', (0, processes_router_1.createProcessesRouter)(this.gatewayConfig.gateway.api.keys, root, { logger: this.logger }));
|
|
714
|
+
}
|
|
697
715
|
// Mount skills routes
|
|
698
716
|
if (this.gatewayConfig?.gateway?.api?.keys) {
|
|
699
717
|
const skillsRouter = (0, skills_router_1.createSkillsRouter)(this.configs, this.gatewayConfig.gateway.api.keys, this.agents, this.gatewayConfig);
|
|
@@ -735,7 +753,7 @@ class GatewayRouter {
|
|
|
735
753
|
// Mount the capability manifest (GET /api/v1/capabilities) so clients can
|
|
736
754
|
// feature-detect this build instead of pinning to a version number.
|
|
737
755
|
if (this.gatewayConfig?.gateway?.api?.keys?.length) {
|
|
738
|
-
this.app.use('/api', (0, capabilities_1.createCapabilitiesRouter)(this.gatewayConfig.gateway.api.keys));
|
|
756
|
+
this.app.use('/api', (0, capabilities_1.createCapabilitiesRouter)(this.gatewayConfig.gateway.api.keys, this.gatewayConfig));
|
|
739
757
|
}
|
|
740
758
|
// Mount apps router (admin routes for installing/managing apps)
|
|
741
759
|
if (this.appsRegistry &&
|