duckhunt-runner 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +376 -16
- package/dist/announced-capabilities.d.ts +2 -0
- package/dist/announced-capabilities.d.ts.map +1 -1
- package/dist/announced-capabilities.js +6 -0
- package/dist/announced-capabilities.js.map +1 -1
- package/dist/audit-cli.d.ts +7 -0
- package/dist/audit-cli.d.ts.map +1 -0
- package/dist/audit-cli.js +84 -0
- package/dist/audit-cli.js.map +1 -0
- package/dist/audit.d.ts +163 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +286 -0
- package/dist/audit.js.map +1 -0
- package/dist/aws.d.ts +10 -1
- package/dist/aws.d.ts.map +1 -1
- package/dist/aws.js +35 -9
- package/dist/aws.js.map +1 -1
- package/dist/browser-cli.d.ts +9 -0
- package/dist/browser-cli.d.ts.map +1 -0
- package/dist/browser-cli.js +200 -0
- package/dist/browser-cli.js.map +1 -0
- package/dist/claim.d.ts +44 -28
- package/dist/claim.d.ts.map +1 -1
- package/dist/claim.js +106 -85
- package/dist/claim.js.map +1 -1
- package/dist/claude.d.ts +1 -0
- package/dist/claude.d.ts.map +1 -1
- package/dist/claude.js +9 -3
- package/dist/claude.js.map +1 -1
- package/dist/config-legacy.d.ts +20 -0
- package/dist/config-legacy.d.ts.map +1 -0
- package/dist/config-legacy.js +253 -0
- package/dist/config-legacy.js.map +1 -0
- package/dist/config.d.ts +38 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +42 -26
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +80 -20
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +866 -420
- package/dist/daemon.js.map +1 -1
- package/dist/feed.d.ts +5 -1
- package/dist/feed.d.ts.map +1 -1
- package/dist/feed.js +78 -13
- package/dist/feed.js.map +1 -1
- package/dist/index.js +64 -4
- package/dist/index.js.map +1 -1
- package/dist/local/mcp.d.ts +93 -0
- package/dist/local/mcp.d.ts.map +1 -0
- package/dist/local/mcp.js +170 -0
- package/dist/local/mcp.js.map +1 -0
- package/dist/local/policy.d.ts +39 -0
- package/dist/local/policy.d.ts.map +1 -0
- package/dist/local/policy.js +88 -0
- package/dist/local/policy.js.map +1 -0
- package/dist/local/socket.d.ts +68 -0
- package/dist/local/socket.d.ts.map +1 -0
- package/dist/local/socket.js +140 -0
- package/dist/local/socket.js.map +1 -0
- package/dist/local/store.d.ts +75 -0
- package/dist/local/store.d.ts.map +1 -0
- package/dist/local/store.js +110 -0
- package/dist/local/store.js.map +1 -0
- package/dist/logout.d.ts +10 -11
- package/dist/logout.d.ts.map +1 -1
- package/dist/logout.js +63 -34
- package/dist/logout.js.map +1 -1
- package/dist/machine.d.ts +4 -0
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +35 -0
- package/dist/machine.js.map +1 -1
- package/dist/mcp-stdio.d.ts +19 -0
- package/dist/mcp-stdio.d.ts.map +1 -0
- package/dist/mcp-stdio.js +65 -0
- package/dist/mcp-stdio.js.map +1 -0
- package/dist/oauth.d.ts +31 -3
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +64 -31
- package/dist/oauth.js.map +1 -1
- package/dist/paths.d.ts +43 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +136 -0
- package/dist/paths.js.map +1 -0
- package/dist/platform-login.d.ts +19 -0
- package/dist/platform-login.d.ts.map +1 -0
- package/dist/platform-login.js +178 -0
- package/dist/platform-login.js.map +1 -0
- package/dist/platforms/claim-v0.d.ts +44 -0
- package/dist/platforms/claim-v0.d.ts.map +1 -0
- package/dist/platforms/claim-v0.js +243 -0
- package/dist/platforms/claim-v0.js.map +1 -0
- package/dist/platforms/credentials.d.ts +15 -0
- package/dist/platforms/credentials.d.ts.map +1 -0
- package/dist/platforms/credentials.js +40 -0
- package/dist/platforms/credentials.js.map +1 -0
- package/dist/platforms/discovery.d.ts +30 -0
- package/dist/platforms/discovery.d.ts.map +1 -0
- package/dist/platforms/discovery.js +91 -0
- package/dist/platforms/discovery.js.map +1 -0
- package/dist/platforms/duckhunt42.d.ts +33 -0
- package/dist/platforms/duckhunt42.d.ts.map +1 -0
- package/dist/platforms/duckhunt42.js +231 -0
- package/dist/platforms/duckhunt42.js.map +1 -0
- package/dist/platforms/factories.d.ts +3 -0
- package/dist/platforms/factories.d.ts.map +1 -0
- package/dist/platforms/factories.js +10 -0
- package/dist/platforms/factories.js.map +1 -0
- package/dist/platforms/http-transport.d.ts +29 -0
- package/dist/platforms/http-transport.d.ts.map +1 -0
- package/dist/platforms/http-transport.js +88 -0
- package/dist/platforms/http-transport.js.map +1 -0
- package/dist/platforms/local.d.ts +79 -0
- package/dist/platforms/local.d.ts.map +1 -0
- package/dist/platforms/local.js +302 -0
- package/dist/platforms/local.js.map +1 -0
- package/dist/platforms/origin.d.ts +12 -0
- package/dist/platforms/origin.d.ts.map +1 -0
- package/dist/platforms/origin.js +32 -0
- package/dist/platforms/origin.js.map +1 -0
- package/dist/platforms/platform.d.ts +133 -0
- package/dist/platforms/platform.d.ts.map +1 -0
- package/dist/platforms/platform.js +30 -0
- package/dist/platforms/platform.js.map +1 -0
- package/dist/platforms/scheduler.d.ts +32 -0
- package/dist/platforms/scheduler.d.ts.map +1 -0
- package/dist/platforms/scheduler.js +76 -0
- package/dist/platforms/scheduler.js.map +1 -0
- package/dist/platforms/supervisor.d.ts +45 -0
- package/dist/platforms/supervisor.d.ts.map +1 -0
- package/dist/platforms/supervisor.js +112 -0
- package/dist/platforms/supervisor.js.map +1 -0
- package/dist/platforms/types.d.ts +50 -0
- package/dist/platforms/types.d.ts.map +1 -0
- package/dist/platforms/types.js +69 -0
- package/dist/platforms/types.js.map +1 -0
- package/dist/platforms/v0.d.ts +41 -0
- package/dist/platforms/v0.d.ts.map +1 -0
- package/dist/platforms/v0.js +301 -0
- package/dist/platforms/v0.js.map +1 -0
- package/dist/platforms-cli.d.ts +5 -0
- package/dist/platforms-cli.d.ts.map +1 -0
- package/dist/platforms-cli.js +163 -0
- package/dist/platforms-cli.js.map +1 -0
- package/dist/read-shell-guard.d.ts.map +1 -1
- package/dist/read-shell-guard.js +4 -3
- package/dist/read-shell-guard.js.map +1 -1
- package/dist/repo-commands.js +2 -2
- package/dist/repo-commands.js.map +1 -1
- package/dist/repo-key.js +1 -1
- package/dist/repo-key.js.map +1 -1
- package/dist/repos.js +2 -2
- package/dist/repos.js.map +1 -1
- package/dist/resource.d.ts +2 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +91 -0
- package/dist/resource.js.map +1 -0
- package/dist/resources/aws.d.ts +36 -0
- package/dist/resources/aws.d.ts.map +1 -0
- package/dist/resources/aws.js +160 -0
- package/dist/resources/aws.js.map +1 -0
- package/dist/resources/browser/config.d.ts +33 -0
- package/dist/resources/browser/config.d.ts.map +1 -0
- package/dist/resources/browser/config.js +86 -0
- package/dist/resources/browser/config.js.map +1 -0
- package/dist/resources/browser/health.d.ts +48 -0
- package/dist/resources/browser/health.d.ts.map +1 -0
- package/dist/resources/browser/health.js +100 -0
- package/dist/resources/browser/health.js.map +1 -0
- package/dist/resources/browser/odysea-cli.d.ts +41 -0
- package/dist/resources/browser/odysea-cli.d.ts.map +1 -0
- package/dist/resources/browser/odysea-cli.js +122 -0
- package/dist/resources/browser/odysea-cli.js.map +1 -0
- package/dist/resources/browser/origins.d.ts +17 -0
- package/dist/resources/browser/origins.d.ts.map +1 -0
- package/dist/resources/browser/origins.js +72 -0
- package/dist/resources/browser/origins.js.map +1 -0
- package/dist/resources/browser/provider.d.ts +49 -0
- package/dist/resources/browser/provider.d.ts.map +1 -0
- package/dist/resources/browser/provider.js +166 -0
- package/dist/resources/browser/provider.js.map +1 -0
- package/dist/resources/browser/state-filter.d.ts +28 -0
- package/dist/resources/browser/state-filter.d.ts.map +1 -0
- package/dist/resources/browser/state-filter.js +61 -0
- package/dist/resources/browser/state-filter.js.map +1 -0
- package/dist/resources/legacy.d.ts +13 -0
- package/dist/resources/legacy.d.ts.map +1 -0
- package/dist/resources/legacy.js +46 -0
- package/dist/resources/legacy.js.map +1 -0
- package/dist/resources/lifecycle.d.ts +48 -0
- package/dist/resources/lifecycle.d.ts.map +1 -0
- package/dist/resources/lifecycle.js +137 -0
- package/dist/resources/lifecycle.js.map +1 -0
- package/dist/resources/registry.d.ts +20 -0
- package/dist/resources/registry.d.ts.map +1 -0
- package/dist/resources/registry.js +37 -0
- package/dist/resources/registry.js.map +1 -0
- package/dist/{conversation-gc.d.ts → resources/repo/gc.d.ts} +6 -6
- package/dist/resources/repo/gc.d.ts.map +1 -0
- package/dist/{conversation-gc.js → resources/repo/gc.js} +16 -13
- package/dist/resources/repo/gc.js.map +1 -0
- package/dist/{repo-health.d.ts → resources/repo/health.d.ts} +4 -2
- package/dist/resources/repo/health.d.ts.map +1 -0
- package/dist/{repo-health.js → resources/repo/health.js} +14 -9
- package/dist/resources/repo/health.js.map +1 -0
- package/dist/resources/repo/provider.d.ts +14 -0
- package/dist/resources/repo/provider.d.ts.map +1 -0
- package/dist/resources/repo/provider.js +75 -0
- package/dist/resources/repo/provider.js.map +1 -0
- package/dist/{worktree.d.ts → resources/repo/worktree.d.ts} +3 -5
- package/dist/resources/repo/worktree.d.ts.map +1 -0
- package/dist/{worktree.js → resources/repo/worktree.js} +24 -27
- package/dist/resources/repo/worktree.js.map +1 -0
- package/dist/resources/s3-read.d.ts +29 -0
- package/dist/resources/s3-read.d.ts.map +1 -0
- package/dist/resources/s3-read.js +68 -0
- package/dist/resources/s3-read.js.map +1 -0
- package/dist/resources/types.d.ts +106 -0
- package/dist/resources/types.d.ts.map +1 -0
- package/dist/resources/types.js +73 -0
- package/dist/resources/types.js.map +1 -0
- package/dist/run-cli.d.ts +25 -0
- package/dist/run-cli.d.ts.map +1 -0
- package/dist/run-cli.js +432 -0
- package/dist/run-cli.js.map +1 -0
- package/dist/run-id.d.ts +10 -0
- package/dist/run-id.d.ts.map +1 -0
- package/dist/run-id.js +36 -0
- package/dist/run-id.js.map +1 -0
- package/dist/run-lease.d.ts +2 -2
- package/dist/run-mcp-config.d.ts +7 -4
- package/dist/run-mcp-config.d.ts.map +1 -1
- package/dist/run-mcp-config.js +14 -8
- package/dist/run-mcp-config.js.map +1 -1
- package/dist/s3-read-server.d.ts +22 -0
- package/dist/s3-read-server.d.ts.map +1 -0
- package/dist/s3-read-server.js +173 -0
- package/dist/s3-read-server.js.map +1 -0
- package/dist/secret-paths.d.ts +12 -0
- package/dist/secret-paths.d.ts.map +1 -1
- package/dist/secret-paths.js +82 -10
- package/dist/secret-paths.js.map +1 -1
- package/dist/server-state.d.ts +7 -9
- package/dist/server-state.d.ts.map +1 -1
- package/dist/server-state.js +14 -17
- package/dist/server-state.js.map +1 -1
- package/dist/status-report.d.ts +2 -0
- package/dist/status-report.d.ts.map +1 -1
- package/dist/status-report.js.map +1 -1
- package/dist/status.d.ts +5 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +100 -6
- package/dist/status.js.map +1 -1
- package/dist/toolset/intersect.d.ts +10 -0
- package/dist/toolset/intersect.d.ts.map +1 -0
- package/dist/toolset/intersect.js +36 -0
- package/dist/toolset/intersect.js.map +1 -0
- package/dist/toolset/legacy-render.d.ts +12 -0
- package/dist/toolset/legacy-render.d.ts.map +1 -0
- package/dist/toolset/legacy-render.js +69 -0
- package/dist/toolset/legacy-render.js.map +1 -0
- package/dist/toolset/parse.d.ts +4 -0
- package/dist/toolset/parse.d.ts.map +1 -0
- package/dist/toolset/parse.js +74 -0
- package/dist/toolset/parse.js.map +1 -0
- package/dist/toolset/render.d.ts +28 -0
- package/dist/toolset/render.d.ts.map +1 -0
- package/dist/toolset/render.js +78 -0
- package/dist/toolset/render.js.map +1 -0
- package/dist/toolset/shadow.d.ts +16 -0
- package/dist/toolset/shadow.d.ts.map +1 -0
- package/dist/toolset/shadow.js +61 -0
- package/dist/toolset/shadow.js.map +1 -0
- package/dist/vendor/runner-protocol/aws.d.ts +6 -0
- package/dist/vendor/runner-protocol/aws.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/aws.js +69 -0
- package/dist/vendor/runner-protocol/aws.js.map +1 -0
- package/dist/vendor/runner-protocol/capabilities.d.ts +20 -0
- package/dist/vendor/runner-protocol/capabilities.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/capabilities.js +58 -0
- package/dist/vendor/runner-protocol/capabilities.js.map +1 -0
- package/dist/vendor/runner-protocol/claim.d.ts +112 -0
- package/dist/vendor/runner-protocol/claim.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/claim.js +54 -0
- package/dist/vendor/runner-protocol/claim.js.map +1 -0
- package/dist/vendor/runner-protocol/errors.d.ts +17 -0
- package/dist/vendor/runner-protocol/errors.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/errors.js +19 -0
- package/dist/vendor/runner-protocol/errors.js.map +1 -0
- package/dist/vendor/runner-protocol/events.d.ts +14 -0
- package/dist/vendor/runner-protocol/events.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/events.js +22 -0
- package/dist/vendor/runner-protocol/events.js.map +1 -0
- package/dist/vendor/runner-protocol/index.d.ts +10 -0
- package/dist/vendor/runner-protocol/index.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/index.js +24 -0
- package/dist/vendor/runner-protocol/index.js.map +1 -0
- package/dist/vendor/runner-protocol/limits.d.ts +31 -0
- package/dist/vendor/runner-protocol/limits.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/limits.js +60 -0
- package/dist/vendor/runner-protocol/limits.js.map +1 -0
- package/dist/vendor/runner-protocol/resources.d.ts +35 -0
- package/dist/vendor/runner-protocol/resources.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/resources.js +39 -0
- package/dist/vendor/runner-protocol/resources.js.map +1 -0
- package/dist/vendor/runner-protocol/toolset.d.ts +59 -0
- package/dist/vendor/runner-protocol/toolset.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/toolset.js +50 -0
- package/dist/vendor/runner-protocol/toolset.js.map +1 -0
- package/dist/vendor/runner-protocol/v0.d.ts +277 -0
- package/dist/vendor/runner-protocol/v0.d.ts.map +1 -0
- package/dist/vendor/runner-protocol/v0.js +121 -0
- package/dist/vendor/runner-protocol/v0.js.map +1 -0
- package/package.json +3 -2
- package/dist/aws-env.d.ts +0 -21
- package/dist/aws-env.d.ts.map +0 -1
- package/dist/aws-env.js +0 -80
- package/dist/aws-env.js.map +0 -1
- package/dist/conversation-gc.d.ts.map +0 -1
- package/dist/conversation-gc.js.map +0 -1
- package/dist/repo-health.d.ts.map +0 -1
- package/dist/repo-health.js.map +0 -1
- package/dist/worktree.d.ts.map +0 -1
- package/dist/worktree.js.map +0 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// subcomandos `duckhunt-runner browser ...` (t#495, M7): las sesiones de navegador de esta máquina, guardadas por
|
|
2
|
+
// odysea en el vault (resources/browser). `login` abre el navegador visible de odysea para que la persona inicie
|
|
3
|
+
// sesión y guarda la entrada `resources.browser.<clave>` con su allowlist de orígenes; `list` las enseña con su
|
|
4
|
+
// salud (solo json), `check` además las prueba con `odysea probe` y sale con 1 si alguna no sirve, y `remove` quita la
|
|
5
|
+
// entrada (el fichero del vault solo con --purge y si ninguna otra clave lo usa). también son `resource … browser`.
|
|
6
|
+
// ninguna plataforma ve una sesión hasta que se le expone (`platforms expose <id> browser <clave>`).
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { parseArgs } from 'node:util';
|
|
9
|
+
import { loadConfigV2, saveConfigV2 } from './config.js';
|
|
10
|
+
import { ensureBrowserVault } from './paths.js';
|
|
11
|
+
import { BROWSER_KEY_RE, BROWSER_SESSION_RE, originPatterns, vaultDirOf, vaultFileOf } from './resources/browser/config.js';
|
|
12
|
+
import { BLOCKING_BROWSER_HEALTH, browserHealth, PROBE_MODE } from './resources/browser/health.js';
|
|
13
|
+
import { detectOdysea, ODYSEA_LOGIN_EXIT, odyseaLogin } from './resources/browser/odysea-cli.js';
|
|
14
|
+
import { originOf } from './resources/browser/origins.js';
|
|
15
|
+
import { RESOURCE_TYPE } from './resources/types.js';
|
|
16
|
+
const USAGE = `uso:
|
|
17
|
+
duckhunt-runner browser login <clave> <url> [--origin <patrón> …] [--session <nombre>] [--exclusive]
|
|
18
|
+
[--probe-url <url> [--login-pattern <regex>]]
|
|
19
|
+
duckhunt-runner browser list
|
|
20
|
+
duckhunt-runner browser check [clave]
|
|
21
|
+
duckhunt-runner browser remove <clave> [--purge]
|
|
22
|
+
(también \`resource add|list|check|remove browser …\`; ninguna plataforma la ve hasta \`platforms expose <id> browser <clave>\`)
|
|
23
|
+
`;
|
|
24
|
+
export const BROWSER_SUB = { login: 'login', add: 'add', list: 'list', check: 'check', remove: 'remove' };
|
|
25
|
+
const LOGIN_OPTIONS = {
|
|
26
|
+
origin: { type: 'string', multiple: true },
|
|
27
|
+
session: { type: 'string' },
|
|
28
|
+
exclusive: { type: 'boolean' },
|
|
29
|
+
'probe-url': { type: 'string' },
|
|
30
|
+
'login-pattern': { type: 'string' },
|
|
31
|
+
};
|
|
32
|
+
const REMOVE_OPTIONS = { purge: { type: 'boolean' } };
|
|
33
|
+
const fail = (msg) => {
|
|
34
|
+
console.error(msg);
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
};
|
|
37
|
+
const usage = () => fail(USAGE);
|
|
38
|
+
const entriesOf = (cfg) => (cfg?.resources[RESOURCE_TYPE.browser] ?? {});
|
|
39
|
+
// la config v2 del fichero; null si no se puede leer (ya avisado).
|
|
40
|
+
function readConfig() {
|
|
41
|
+
try {
|
|
42
|
+
return { cfg: loadConfigV2() };
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
fail(err.message);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const describe = (key, ref) => `${key} → sesión ${ref.session} · ${ref.origins.join(', ')}${ref.exclusive ? ' · exclusiva' : ''}${ref.probe ? ` · probe ${ref.probe.url}` : ''}`;
|
|
50
|
+
// la salud de unas sesiones, impresa; devuelve si alguna bloquea.
|
|
51
|
+
async function printHealth(cfg, entries, probe) {
|
|
52
|
+
const odysea = await detectOdysea(cfg?.providers?.browser?.bin);
|
|
53
|
+
const findings = await browserHealth({ entries, vaultDir: vaultDirOf(cfg?.providers), odysea, probe, lastProbe: new Map(), nowMs: Date.now() });
|
|
54
|
+
const byKey = findings.reduce((acc, f) => acc.set(f.key, [...(acc.get(f.key) ?? []), f]), new Map());
|
|
55
|
+
Object.entries(entries).forEach(([key, ref]) => {
|
|
56
|
+
console.log(` ${describe(key, ref)}`);
|
|
57
|
+
(byKey.get(key) ?? []).forEach((f) => console.log(` ⚠ ${f.kind}: ${f.detail}`));
|
|
58
|
+
});
|
|
59
|
+
return findings.some((f) => BLOCKING_BROWSER_HEALTH.has(f.kind));
|
|
60
|
+
}
|
|
61
|
+
async function login(args) {
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = parseArgs({ args, options: LOGIN_OPTIONS, allowPositionals: true });
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
return fail(`${err.message}\n${USAGE}`);
|
|
68
|
+
}
|
|
69
|
+
const [key, url] = parsed.positionals;
|
|
70
|
+
const { values } = parsed;
|
|
71
|
+
if (!key || !url || parsed.positionals.length !== 2)
|
|
72
|
+
return usage();
|
|
73
|
+
if (!BROWSER_KEY_RE.test(key))
|
|
74
|
+
return fail(`clave no válida: "${key}" (${BROWSER_KEY_RE.source})`);
|
|
75
|
+
const origin = originOf(url);
|
|
76
|
+
if (origin === null)
|
|
77
|
+
return fail(`url no válida: "${url}" (http o https)`);
|
|
78
|
+
if (values['login-pattern'] !== undefined && values['probe-url'] === undefined)
|
|
79
|
+
return fail('--login-pattern necesita --probe-url');
|
|
80
|
+
const read = readConfig();
|
|
81
|
+
if (!read)
|
|
82
|
+
return;
|
|
83
|
+
const existing = entriesOf(read.cfg)[key];
|
|
84
|
+
const session = values.session ?? existing?.session ?? key;
|
|
85
|
+
if (!BROWSER_SESSION_RE.test(session))
|
|
86
|
+
return fail(`sesión no válida: "${session}" (${BROWSER_SESSION_RE.source})`);
|
|
87
|
+
const probeUrl = values['probe-url'];
|
|
88
|
+
if (probeUrl !== undefined && originOf(probeUrl) === null)
|
|
89
|
+
return fail(`--probe-url no válida: "${probeUrl}"`);
|
|
90
|
+
const ref = {
|
|
91
|
+
session,
|
|
92
|
+
// sin --origin: los de antes o, en una nueva, el de la url de login.
|
|
93
|
+
origins: values.origin ?? existing?.origins ?? [origin],
|
|
94
|
+
...(values.exclusive || existing?.exclusive ? { exclusive: true } : {}),
|
|
95
|
+
...(probeUrl !== undefined
|
|
96
|
+
? { probe: { url: probeUrl, ...(values['login-pattern'] !== undefined ? { loginPattern: values['login-pattern'] } : {}) } }
|
|
97
|
+
: existing?.probe
|
|
98
|
+
? { probe: existing.probe }
|
|
99
|
+
: {}),
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
originPatterns(ref);
|
|
103
|
+
if (ref.probe?.loginPattern !== undefined)
|
|
104
|
+
new RegExp(ref.probe.loginPattern);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
return fail(err.message);
|
|
108
|
+
}
|
|
109
|
+
const odysea = await detectOdysea(read.cfg?.providers?.browser?.bin);
|
|
110
|
+
if (!odysea.ok)
|
|
111
|
+
return fail(`sin odysea: ${odysea.reason}`);
|
|
112
|
+
const vaultDir = ensureBrowserVault(vaultDirOf(read.cfg?.providers));
|
|
113
|
+
const stateFile = vaultFileOf(vaultDir, session);
|
|
114
|
+
const code = await odyseaLogin(odysea.info.bin, stateFile, url);
|
|
115
|
+
// cerrar la ventana antes de enter deja el último autosave: vale si llegó a guardarse algo.
|
|
116
|
+
const saved = code === ODYSEA_LOGIN_EXIT.ok || (code === ODYSEA_LOGIN_EXIT.aborted && fs.existsSync(stateFile));
|
|
117
|
+
if (!saved)
|
|
118
|
+
return fail(`el login de odysea no guardó la sesión (exit ${code ?? 'sin código'}): ${key} no se ha guardado`);
|
|
119
|
+
saveConfigV2((cfg) => ({ ...cfg, resources: { ...cfg.resources, [RESOURCE_TYPE.browser]: { ...entriesOf(cfg), [key]: ref } } }));
|
|
120
|
+
console.log(`${existing ? 'actualizada' : 'añadida'} la sesión de navegador:`);
|
|
121
|
+
const blocked = await printHealth(loadConfigV2(), { [key]: ref }, ref.probe ? PROBE_MODE.force : PROBE_MODE.never);
|
|
122
|
+
if (blocked)
|
|
123
|
+
process.exitCode = 1;
|
|
124
|
+
if (!existing)
|
|
125
|
+
console.log(`ninguna plataforma la ve aún: \`duckhunt-runner platforms expose <id> ${RESOURCE_TYPE.browser} ${key}\``);
|
|
126
|
+
}
|
|
127
|
+
async function list() {
|
|
128
|
+
const read = readConfig();
|
|
129
|
+
if (!read)
|
|
130
|
+
return;
|
|
131
|
+
const entries = entriesOf(read.cfg);
|
|
132
|
+
if (Object.keys(entries).length === 0) {
|
|
133
|
+
console.log(`sin sesiones de navegador (\`duckhunt-runner browser login <clave> <url>\`)`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
await printHealth(read.cfg, entries, PROBE_MODE.never);
|
|
137
|
+
}
|
|
138
|
+
async function check(args) {
|
|
139
|
+
const [key, ...extra] = args;
|
|
140
|
+
if (extra.length > 0)
|
|
141
|
+
return usage();
|
|
142
|
+
const read = readConfig();
|
|
143
|
+
if (!read)
|
|
144
|
+
return;
|
|
145
|
+
const all = entriesOf(read.cfg);
|
|
146
|
+
if (key !== undefined && !Object.hasOwn(all, key))
|
|
147
|
+
return fail(`no hay sesión de navegador ${key}`);
|
|
148
|
+
const entries = key === undefined ? all : { [key]: all[key] };
|
|
149
|
+
if (Object.keys(entries).length === 0) {
|
|
150
|
+
console.log(`${RESOURCE_TYPE.browser}: sin sesiones`);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (await printHealth(read.cfg, entries, PROBE_MODE.force))
|
|
154
|
+
process.exitCode = 1;
|
|
155
|
+
}
|
|
156
|
+
function remove(args) {
|
|
157
|
+
let parsed;
|
|
158
|
+
try {
|
|
159
|
+
parsed = parseArgs({ args, options: REMOVE_OPTIONS, allowPositionals: true });
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
return fail(`${err.message}\n${USAGE}`);
|
|
163
|
+
}
|
|
164
|
+
const [key] = parsed.positionals;
|
|
165
|
+
if (!key || parsed.positionals.length !== 1)
|
|
166
|
+
return usage();
|
|
167
|
+
const read = readConfig();
|
|
168
|
+
if (!read)
|
|
169
|
+
return;
|
|
170
|
+
const ref = entriesOf(read.cfg)[key];
|
|
171
|
+
if (!ref)
|
|
172
|
+
return fail(`no hay sesión de navegador ${key}`);
|
|
173
|
+
saveConfigV2((cfg) => {
|
|
174
|
+
const { [key]: _, ...rest } = entriesOf(cfg);
|
|
175
|
+
return { ...cfg, resources: { ...cfg.resources, [RESOURCE_TYPE.browser]: rest } };
|
|
176
|
+
});
|
|
177
|
+
console.log(`quitada la sesión de navegador ${key}`);
|
|
178
|
+
if (!parsed.values.purge)
|
|
179
|
+
return;
|
|
180
|
+
const shared = Object.entries(entriesOf(read.cfg)).some(([other, r]) => other !== key && r.session === ref.session);
|
|
181
|
+
if (shared) {
|
|
182
|
+
console.log(`el fichero de la sesión ${ref.session} se queda: otra clave lo usa`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
fs.rmSync(vaultFileOf(vaultDirOf(read.cfg?.providers), ref.session), { force: true });
|
|
186
|
+
console.log(`borrado el fichero de la sesión ${ref.session} del vault`);
|
|
187
|
+
}
|
|
188
|
+
export async function browserCommand(args) {
|
|
189
|
+
const [sub, ...rest] = args;
|
|
190
|
+
if (sub === BROWSER_SUB.login || sub === BROWSER_SUB.add)
|
|
191
|
+
return login(rest);
|
|
192
|
+
if (sub === BROWSER_SUB.list && rest.length === 0)
|
|
193
|
+
return list();
|
|
194
|
+
if (sub === BROWSER_SUB.check)
|
|
195
|
+
return check(rest);
|
|
196
|
+
if (sub === BROWSER_SUB.remove)
|
|
197
|
+
return remove(rest);
|
|
198
|
+
usage();
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=browser-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-cli.js","sourceRoot":"","sources":["../src/browser-cli.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,iHAAiH;AACjH,gHAAgH;AAChH,uHAAuH;AACvH,oHAAoH;AACpH,qGAAqG;AAErG,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAmB,MAAM,+BAA+B,CAAC;AAC7I,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,UAAU,EAAuC,MAAM,+BAA+B,CAAC;AACxI,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,KAAK,GAAG;;;;;;;CAOb,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAW,CAAC;AAEnH,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC3B,SAAS,EAAE,EAAE,IAAI,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AG;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7E,IAAI,GAAG,KAAK,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,EAAE,CAAC;IACjE,IAAI,GAAG,KAAK,WAAW,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,GAAG,KAAK,WAAW,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACpD,KAAK,EAAE,CAAC;AACV,CAAC"}
|
package/dist/claim.d.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly checkout: "checkout";
|
|
6
|
-
readonly readShell: "read_shell";
|
|
7
|
-
readonly nativeMemory: "native_memory";
|
|
8
|
-
readonly repoEdit: "repo_edit";
|
|
9
|
-
readonly secretPaths: "secret_paths";
|
|
10
|
-
readonly seedBudget: "seed_budget";
|
|
11
|
-
readonly awsStrict: "aws_strict";
|
|
12
|
-
readonly worktreeReport: "worktree_report";
|
|
13
|
-
readonly logout: "logout";
|
|
14
|
-
readonly model: "model";
|
|
15
|
-
};
|
|
16
|
-
export type RunnerCapability = (typeof RUNNER_CAPABILITY)[keyof typeof RUNNER_CAPABILITY];
|
|
1
|
+
import { RUNNER_CAPABILITY, TOOLSET_V1, type AgentPromptProfile, type AgentRunIsolation, type AgentRunSeed, type RunnerCapability } from './vendor/runner-protocol/index.js';
|
|
2
|
+
import type { ShadowSource } from './toolset/shadow.js';
|
|
3
|
+
import type { ResourceRequest } from './resources/types.js';
|
|
4
|
+
export { RUNNER_CAPABILITY, type RunnerCapability };
|
|
17
5
|
export declare const RUN_ISOLATION: {
|
|
18
6
|
readonly worktree: "worktree";
|
|
19
7
|
readonly checkout: "checkout";
|
|
20
8
|
};
|
|
21
|
-
export type RunIsolation =
|
|
9
|
+
export type RunIsolation = AgentRunIsolation;
|
|
22
10
|
export declare const RUN_KIND: {
|
|
23
11
|
readonly investigate: "investigate";
|
|
24
12
|
readonly resume: "resume";
|
|
@@ -28,12 +16,12 @@ export declare const PROMPT_PROFILE: {
|
|
|
28
16
|
readonly read: "read";
|
|
29
17
|
readonly edit: "edit";
|
|
30
18
|
};
|
|
31
|
-
export type PromptProfile =
|
|
19
|
+
export type PromptProfile = AgentPromptProfile;
|
|
32
20
|
export declare const RUN_SEED: {
|
|
33
21
|
readonly template: "template";
|
|
34
22
|
readonly prompt: "prompt";
|
|
35
23
|
};
|
|
36
|
-
export type RunSeed =
|
|
24
|
+
export type RunSeed = AgentRunSeed;
|
|
37
25
|
export declare const ALLOWED_PERMISSION_MODES: readonly string[];
|
|
38
26
|
export declare const EVENTS_DEFAULTS: {
|
|
39
27
|
readonly nextSeq: 1;
|
|
@@ -53,8 +41,9 @@ export declare const READ_AWS_COMMANDS: readonly string[];
|
|
|
53
41
|
export declare const AWS_OUTFILE_COMMANDS: readonly string[];
|
|
54
42
|
export declare const MODEL_RE: RegExp;
|
|
55
43
|
export declare const REPO_KEY_RE: RegExp;
|
|
44
|
+
export declare const MCP_SERVER_NAME_RE: RegExp;
|
|
56
45
|
export interface ClaimedRun {
|
|
57
|
-
id:
|
|
46
|
+
id: string;
|
|
58
47
|
kind: string;
|
|
59
48
|
entryId: number;
|
|
60
49
|
workspaceId: number;
|
|
@@ -83,6 +72,10 @@ export interface EventsConfig {
|
|
|
83
72
|
bodyMaxChars: number;
|
|
84
73
|
toolArgMaxChars: number;
|
|
85
74
|
}
|
|
75
|
+
export { TOOLSET_V1 };
|
|
76
|
+
export interface ToolsetV1 {
|
|
77
|
+
v: typeof TOOLSET_V1;
|
|
78
|
+
}
|
|
86
79
|
export interface ClaimResponse {
|
|
87
80
|
run: ClaimedRun;
|
|
88
81
|
prompt: string;
|
|
@@ -98,16 +91,27 @@ export interface ClaimResponse {
|
|
|
98
91
|
timeoutMs: number;
|
|
99
92
|
heartbeatMs: number;
|
|
100
93
|
events: EventsConfig | null;
|
|
101
|
-
mcp:
|
|
102
|
-
serverName: string;
|
|
103
|
-
url: string;
|
|
104
|
-
token: string;
|
|
105
|
-
expiresAt: number;
|
|
106
|
-
};
|
|
94
|
+
mcp: McpServer;
|
|
107
95
|
warnings: string[];
|
|
96
|
+
toolset: ToolsetV1 | null;
|
|
97
|
+
toolsetShadow: ShadowSource | null;
|
|
98
|
+
resources?: ResourceRequest[];
|
|
99
|
+
extraMcp?: McpServer[];
|
|
100
|
+
policyAudit?: {
|
|
101
|
+
requested: ShadowSource['toolset'];
|
|
102
|
+
effective: ShadowSource['toolset'];
|
|
103
|
+
narrowed: string[];
|
|
104
|
+
};
|
|
108
105
|
}
|
|
109
|
-
/**
|
|
110
|
-
export
|
|
106
|
+
/** un servidor mcp de la plataforma con el token per-run (expiresAt en ms desde epoch). */
|
|
107
|
+
export interface McpServer {
|
|
108
|
+
serverName: string;
|
|
109
|
+
url: string;
|
|
110
|
+
token: string;
|
|
111
|
+
expiresAt: number;
|
|
112
|
+
}
|
|
113
|
+
/** id de run válido para paths y logs (del entero positivo legacy), o null. sirve para fallar un claim roto. */
|
|
114
|
+
export declare function claimRunId(raw: unknown): string | null;
|
|
111
115
|
/** cordura mínima de una rama para pasarla a git (git check-ref-format decide aparte). */
|
|
112
116
|
export declare function isValidBranchName(branch: string): boolean;
|
|
113
117
|
/** true si el patrón es una lectura de la aws cli fijada en servicio + operación (verbo o lectura suelta). */
|
|
@@ -116,4 +120,16 @@ export declare function isAwsReadPattern(tool: string): boolean;
|
|
|
116
120
|
export declare const isToolId: (tool: string) => boolean;
|
|
117
121
|
/** valida y normaliza la respuesta 200 del claim. lanza con el motivo si algo no es seguro. */
|
|
118
122
|
export declare function parseClaim(raw: unknown): ClaimResponse;
|
|
123
|
+
/**
|
|
124
|
+
* el claim con la forma del legacy y el id de run ya validado por quien llama (el cable legacy, del entero; el v0,
|
|
125
|
+
* su id opaco: platforms/claim-v0.ts lo arma desde el suyo y pasa por aquí para las mismas comprobaciones).
|
|
126
|
+
*/
|
|
127
|
+
export declare function parseClaimBody(raw: unknown, id: string): ClaimResponse;
|
|
128
|
+
/** el claim con las listas que renderizó el daemon (el flip de toolset_v1, toolset/legacy-render.ts) en vez de las
|
|
129
|
+
* del server, pasadas por la misma criba. lanza si no se pueden cumplir. */
|
|
130
|
+
export declare function withRenderedTools(claim: ClaimResponse, rendered: {
|
|
131
|
+
allowed: readonly string[];
|
|
132
|
+
disallowed: readonly string[];
|
|
133
|
+
permissionMode: string;
|
|
134
|
+
}): ClaimResponse;
|
|
119
135
|
//# sourceMappingURL=claim.d.ts.map
|
package/dist/claim.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../src/claim.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../src/claim.ts"],"names":[],"mappings":"AAiCA,OAAO,EAYL,iBAAiB,EACjB,UAAU,EACV,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAc5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,CAAC;AAKpD,eAAO,MAAM,aAAa;;;CAAsB,CAAC;AACjD,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAE7C,eAAO,MAAM,QAAQ;;;;CAAiB,CAAC;AAEvC,eAAO,MAAM,cAAc;;;CAAuB,CAAC;AACnD,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAG/C,eAAO,MAAM,QAAQ;;;CAAiB,CAAC;AACvC,MAAM,MAAM,OAAO,GAAG,YAAY,CAAC;AAInC,eAAO,MAAM,w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AC;QAAC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC9G;AAED,2FAA2F;AAC3F,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AASD,gHAAgH;AAChH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEtD;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEzD;AASD,8GAA8G;AAC9G,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGtD;AAED,sFAAsF;AACtF,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,OAAgC,CAAC;AAuBzE,+FAA+F;AAC/F,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAKtD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa,CAkFtE;AAiCD;6EAC6E;AAC7E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE;IAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAQtK"}
|
package/dist/claim.js
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
// `aws s3 rm … --exclude list-x`) y sus lecturas que escriben un fichero local, negadas siempre.
|
|
19
19
|
// un bug o una deriva del server nunca le da a una lectura una shell que ejecute o escriba.
|
|
20
20
|
// - `run.segment` es la identidad del proceso: viaja de vuelta en heartbeat/progress/events/status.
|
|
21
|
+
// - `run.id` (t#495, M1) es texto opaco por dentro (run-id.ts): del cable legacy solo vale un entero positivo,
|
|
22
|
+
// que se guarda como String(id); la vuelta a número para el cable vive en run-id.ts::legacyWireRunId.
|
|
21
23
|
// - `run.seed` (t#465 P6) dice si la conversación nació de una plantilla de investigación: con
|
|
22
24
|
// seed_budget (0.11.0) su presupuesto se aplica aunque viaje como prompt run (claude-args.ts). el bloque
|
|
23
25
|
// `runner` de un server >= t#465 P12 no es del run: lo lee server-state.ts, y parseClaim lo ignora.
|
|
@@ -27,54 +29,30 @@
|
|
|
27
29
|
// solo pasa un alias o un id de modelo (MODEL_RE, el AGENT_MODEL_ID_RE del server); cualquier otra
|
|
28
30
|
// cosa se ignora con un aviso y el run sigue con el modelo de la máquina: un modelo raro no merece
|
|
29
31
|
// tumbar el claim, y un `-x` nunca llega al cli como flag.
|
|
30
|
-
|
|
32
|
+
import { runIdFromLegacy } from './run-id.js';
|
|
33
|
+
import { AGENT_AWS_READ_COMMANDS, AGENT_AWS_READ_VERBS, AGENT_PROMPT_PROFILE, AGENT_RUN_EVENT_BATCH_MAX, AGENT_RUN_EVENT_BODY_MAX_CHARS, AGENT_RUN_EVENT_FLUSH_COUNT, AGENT_RUN_EVENT_FLUSH_MS, AGENT_RUN_EVENT_TOOL_ARG_MAX_CHARS, AGENT_RUN_ISOLATION, AGENT_RUN_KIND, AGENT_RUN_SEED, RUNNER_CAPABILITY, TOOLSET_V1, } from './vendor/runner-protocol/index.js';
|
|
34
|
+
import { parseToolsetV1 } from './toolset/parse.js';
|
|
35
|
+
// capacidades que el daemon anuncia en el claim: sus ids y lo que el server hace con cada una vienen del
|
|
36
|
+
// protocolo vendorizado (vendor/runner-protocol, t#495 M3). el server entrega kind=prompt solo a quien
|
|
31
37
|
// anuncia `prompt`, pide el feed de progreso solo a quien anuncia `events` y deja abrir una
|
|
32
38
|
// conversación en el checkout solo a quien anuncia `checkout` (>= 0.6.0), la shell de solo lectura
|
|
33
39
|
// en read solo a quien anuncia `read_shell` (>= 0.7.0) y deja de negar Edit/Write enteras en read y
|
|
34
40
|
// en los runs de reglas (su memoria nativa) solo a quien anuncia `native_memory` (>= 0.8.0).
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// acepta cambios del mapa de repos pedidos desde duckhunt (repo-commands.ts); apagable en local.
|
|
43
|
-
repoEdit: 'repo_edit',
|
|
44
|
-
// 0.11.0 (t#465 P12): niega a Read las rutas reales de las credenciales de esta máquina en todo kit
|
|
45
|
-
// de lectura (secret-paths.ts), aplica el presupuesto a las plantillas (seed_budget), corre con la aws
|
|
46
|
-
// vacía una cuenta sin mapear (aws-env.ts), anuncia el trabajo que su gc conservó (keptWorktrees) y
|
|
47
|
-
// sabe desvincularse (`logout`, y lee el bloque runner del claim).
|
|
48
|
-
secretPaths: 'secret_paths',
|
|
49
|
-
seedBudget: 'seed_budget',
|
|
50
|
-
awsStrict: 'aws_strict',
|
|
51
|
-
worktreeReport: 'worktree_report',
|
|
52
|
-
logout: 'logout',
|
|
53
|
-
// 0.12.0 (t#465): pasa a claude el modelo que pide el claim (run.model) con --model. el server solo
|
|
54
|
-
// lo manda a quien lo anuncia, y se anuncia solo si `claude --help` lista --model.
|
|
55
|
-
model: 'model',
|
|
56
|
-
};
|
|
41
|
+
// lo propio de este daemon: `repo_edit` (cambios del mapa de repos pedidos desde duckhunt, repo-commands.ts)
|
|
42
|
+
// es apagable en local; 0.11.0 (t#465 P12) niega a Read las rutas reales de las credenciales de esta máquina
|
|
43
|
+
// en todo kit de lectura (secret-paths.ts), aplica el presupuesto a las plantillas (seed_budget), corre con la
|
|
44
|
+
// aws vacía una cuenta sin mapear (resources/aws.ts), anuncia el trabajo que su gc conservó (keptWorktrees) y
|
|
45
|
+
// sabe desvincularse (`logout`, y lee el bloque runner del claim); 0.12.0 (t#465) pasa a claude el modelo que
|
|
46
|
+
// pide el claim (run.model) con --model, y `model` se anuncia solo si `claude --help` lista --model.
|
|
47
|
+
export { RUNNER_CAPABILITY };
|
|
57
48
|
// dónde trabaja un prompt run con repo (lo elige el usuario al abrir la conversación): el worktree
|
|
58
49
|
// conv-<id> aislado o el checkout tal cual (su rama y sus cambios). ausente o desconocido = worktree,
|
|
59
50
|
// lo más aislado. los runs de reglas no lo usan: su cwd lo decide `worktree` del repo en la config.
|
|
60
|
-
export const RUN_ISOLATION =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
export const RUN_KIND = {
|
|
65
|
-
investigate: 'investigate',
|
|
66
|
-
resume: 'resume',
|
|
67
|
-
prompt: 'prompt',
|
|
68
|
-
};
|
|
69
|
-
export const PROMPT_PROFILE = {
|
|
70
|
-
read: 'read',
|
|
71
|
-
edit: 'edit',
|
|
72
|
-
};
|
|
51
|
+
export const RUN_ISOLATION = AGENT_RUN_ISOLATION;
|
|
52
|
+
export const RUN_KIND = AGENT_RUN_KIND;
|
|
53
|
+
export const PROMPT_PROFILE = AGENT_PROMPT_PROFILE;
|
|
73
54
|
// de qué nació la conversación (run.seed, t#465 P6): una plantilla de investigación o el texto de la persona.
|
|
74
|
-
export const RUN_SEED =
|
|
75
|
-
template: 'template',
|
|
76
|
-
prompt: 'prompt',
|
|
77
|
-
};
|
|
55
|
+
export const RUN_SEED = AGENT_RUN_SEED;
|
|
78
56
|
// techo local de permission modes: el server manda dontAsk; bypassPermissions nunca se acepta
|
|
79
57
|
// desde fuera (el opt-in a saltarse permisos es solo local, `repos add --dangerously-skip-permissions`).
|
|
80
58
|
export const ALLOWED_PERMISSION_MODES = ['dontAsk', 'default', 'acceptEdits', 'plan'];
|
|
@@ -82,14 +60,14 @@ export const ALLOWED_PERMISSION_MODES = ['dontAsk', 'default', 'acceptEdits', 'p
|
|
|
82
60
|
// RUN_HEARTBEAT_INTERVAL_MS del server).
|
|
83
61
|
const DEFAULT_TIMEOUT_MS = 30 * 60_000;
|
|
84
62
|
const DEFAULT_HEARTBEAT_MS = 20_000;
|
|
85
|
-
// defaults del feed si el server no los manda
|
|
63
|
+
// defaults del feed si el server no los manda: los AGENT_RUN_EVENT_* del protocolo, los que manda él.
|
|
86
64
|
export const EVENTS_DEFAULTS = {
|
|
87
65
|
nextSeq: 1,
|
|
88
|
-
flushMs:
|
|
89
|
-
flushCount:
|
|
90
|
-
batchMax:
|
|
91
|
-
bodyMaxChars:
|
|
92
|
-
toolArgMaxChars:
|
|
66
|
+
flushMs: AGENT_RUN_EVENT_FLUSH_MS,
|
|
67
|
+
flushCount: AGENT_RUN_EVENT_FLUSH_COUNT,
|
|
68
|
+
batchMax: AGENT_RUN_EVENT_BATCH_MAX,
|
|
69
|
+
bodyMaxChars: AGENT_RUN_EVENT_BODY_MAX_CHARS,
|
|
70
|
+
toolArgMaxChars: AGENT_RUN_EVENT_TOOL_ARG_MAX_CHARS,
|
|
93
71
|
};
|
|
94
72
|
// cordura mínima de una rama ANTES de tocar git: sin '-' inicial (no puede parecer una opción), sin
|
|
95
73
|
// espacios ni caracteres de control, acotada. quien decide de verdad es `git check-ref-format --branch`.
|
|
@@ -102,23 +80,11 @@ export const READ_FORBIDDEN_TOOLS = ['Edit', 'Write', 'NotebookEdit'];
|
|
|
102
80
|
// built-in con las que el cli escribe su memoria nativa: fuera del deny forzado de lectura.
|
|
103
81
|
export const MEMORY_WRITE_TOOLS = ['Edit', 'Write'];
|
|
104
82
|
export const BASH_TOOL = 'Bash';
|
|
105
|
-
// aws cli en lectura (
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
export const
|
|
109
|
-
|
|
110
|
-
'logs tail',
|
|
111
|
-
'logs start-query',
|
|
112
|
-
's3 ls',
|
|
113
|
-
's3api head-object',
|
|
114
|
-
's3api head-bucket',
|
|
115
|
-
'cloudtrail lookup-events',
|
|
116
|
-
'dynamodb query',
|
|
117
|
-
'dynamodb scan',
|
|
118
|
-
'rds download-db-log-file-portion',
|
|
119
|
-
'sts get-caller-identity',
|
|
120
|
-
'sts get-access-key-info',
|
|
121
|
-
];
|
|
83
|
+
// aws cli en lectura (AGENT_AWS_READ_VERBS / AGENT_AWS_READ_COMMANDS del protocolo): verbos por
|
|
84
|
+
// convención de la api de aws y lecturas sueltas (servicio + operación exacta). el servicio no se acota
|
|
85
|
+
// aquí (el server sí los enumera): lo que fija la lectura es la operación.
|
|
86
|
+
export const READ_AWS_VERBS = AGENT_AWS_READ_VERBS;
|
|
87
|
+
export const READ_AWS_COMMANDS = AGENT_AWS_READ_COMMANDS;
|
|
122
88
|
// lecturas de la aws cli que escriben un fichero local (payload blob → la cli exige un outfile):
|
|
123
89
|
// al deny de TODO claim read, del servicio que sea. derivadas de los modelos de botocore de la aws
|
|
124
90
|
// cli 2.30.4 (operaciones describe|list|get|batch-get|head con payload blob), por prefijo de
|
|
@@ -188,14 +154,19 @@ const SESSION_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
|
188
154
|
// empieza por letra (nunca '-') y sin comas ni saltos (se unen con ',' en un solo argumento).
|
|
189
155
|
const TOOL_ID_RE = /^[A-Za-z_][^,\n\r]{0,199}$/;
|
|
190
156
|
// nombre del servidor mcp: clave del mcp-config y prefijo mcp__<name>__ de las tools.
|
|
191
|
-
const MCP_SERVER_NAME_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
157
|
+
export const MCP_SERVER_NAME_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
158
|
+
// marca de un claim que MANDA con la política neutra toolset_v1 (t#495, M5): separa un claim toolset_v1 de uno
|
|
159
|
+
// legacy donde el runner se comporta distinto (aislar la aws de la máquina, resources/aws.ts). la pone el cable v0
|
|
160
|
+
// (platforms/claim-v0.ts, M4); el toolset del cable legacy va en sombra (toolsetShadow) y allí las listas de tools
|
|
161
|
+
// siguen mandando.
|
|
162
|
+
export { TOOLSET_V1 };
|
|
192
163
|
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
193
164
|
const str = (v) => (typeof v === 'string' ? v : null);
|
|
194
165
|
const posInt = (v) => (typeof v === 'number' && Number.isSafeInteger(v) && v > 0 ? v : null);
|
|
195
166
|
const posNum = (v) => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : null);
|
|
196
|
-
/** id de run válido para paths y logs (entero positivo), o null. sirve para fallar un claim roto. */
|
|
167
|
+
/** id de run válido para paths y logs (del entero positivo legacy), o null. sirve para fallar un claim roto. */
|
|
197
168
|
export function claimRunId(raw) {
|
|
198
|
-
return isObj(raw) && isObj(raw.run) ?
|
|
169
|
+
return isObj(raw) && isObj(raw.run) ? runIdFromLegacy(raw.run.id) : null;
|
|
199
170
|
}
|
|
200
171
|
/** cordura mínima de una rama para pasarla a git (git check-ref-format decide aparte). */
|
|
201
172
|
export function isValidBranchName(branch) {
|
|
@@ -238,10 +209,19 @@ function eventsConfig(v) {
|
|
|
238
209
|
export function parseClaim(raw) {
|
|
239
210
|
if (!isObj(raw) || !isObj(raw.run))
|
|
240
211
|
throw new Error('claim inválido: falta run');
|
|
241
|
-
const
|
|
242
|
-
const id = posInt(r.id);
|
|
212
|
+
const id = runIdFromLegacy(raw.run.id);
|
|
243
213
|
if (id === null)
|
|
244
214
|
throw new Error('claim inválido: run.id no es un entero positivo');
|
|
215
|
+
return parseClaimBody(raw, id);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* el claim con la forma del legacy y el id de run ya validado por quien llama (el cable legacy, del entero; el v0,
|
|
219
|
+
* su id opaco: platforms/claim-v0.ts lo arma desde el suyo y pasa por aquí para las mismas comprobaciones).
|
|
220
|
+
*/
|
|
221
|
+
export function parseClaimBody(raw, id) {
|
|
222
|
+
if (!isObj(raw) || !isObj(raw.run))
|
|
223
|
+
throw new Error('claim inválido: falta run');
|
|
224
|
+
const r = raw.run;
|
|
245
225
|
const kind = str(r.kind);
|
|
246
226
|
if (!kind)
|
|
247
227
|
throw new Error('claim inválido: run.kind ausente');
|
|
@@ -270,25 +250,13 @@ export function parseClaim(raw) {
|
|
|
270
250
|
if (!prompt || !prompt.trim())
|
|
271
251
|
throw new Error('claim inválido: prompt vacío');
|
|
272
252
|
const permissionMode = str(raw.permissionMode) ?? '';
|
|
273
|
-
|
|
274
|
-
throw new Error(`claim inválido: permission mode "${permissionMode}" fuera del techo local (${ALLOWED_PERMISSION_MODES.join(', ')})`);
|
|
275
|
-
}
|
|
276
|
-
if (kind === RUN_KIND.prompt && permissionMode !== PROMPT_PERMISSION_MODE) {
|
|
277
|
-
throw new Error(`claim inválido: un prompt run exige permission mode ${PROMPT_PERMISSION_MODE} (llegó "${permissionMode}")`);
|
|
278
|
-
}
|
|
253
|
+
vetPermissionMode(kind, permissionMode);
|
|
279
254
|
const tools = isObj(raw.tools) ? raw.tools : {};
|
|
280
255
|
const serverAllowed = toolList(tools.allowed, 'tools.allowed');
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// una `Bash(aws …)` que no reconozco (lectura nueva de un server más moderno, o una escritura) se
|
|
286
|
-
// descarta sin tumbar el run: sin ella el cli la niega (dontAsk).
|
|
287
|
-
const unknownAws = readPrompt ? serverAllowed.filter((t) => t.startsWith(`${BASH_TOOL}(`) && !isAwsReadPattern(t)) : [];
|
|
288
|
-
if (unknownAws.length > 0)
|
|
289
|
-
warnings.push(`aws descartada en lectura (no es una lectura que este runner reconozca): ${unknownAws.join(', ')}`);
|
|
290
|
-
const allowed = serverAllowed.filter((t) => !unknownAws.includes(t));
|
|
291
|
-
const disallowed = Array.from(new Set([...toolList(tools.disallowed, 'tools.disallowed'), ...(readPrompt ? READ_FORCED_DENY : [])]));
|
|
256
|
+
const serverDisallowed = toolList(tools.disallowed, 'tools.disallowed');
|
|
257
|
+
const vetted = vetTools(kind, profile, { allowed: serverAllowed, disallowed: serverDisallowed, permissionMode });
|
|
258
|
+
warnings.push(...vetted.warnings);
|
|
259
|
+
const { allowed, disallowed } = vetted;
|
|
292
260
|
const mcp = isObj(raw.mcp) ? raw.mcp : {};
|
|
293
261
|
const serverName = str(mcp.serverName) ?? '';
|
|
294
262
|
const url = str(mcp.url) ?? '';
|
|
@@ -329,6 +297,59 @@ export function parseClaim(raw) {
|
|
|
329
297
|
events: eventsConfig(raw.events),
|
|
330
298
|
mcp: { serverName, url, token, expiresAt: numOrNull(mcp.expiresAt) ?? 0 },
|
|
331
299
|
warnings,
|
|
300
|
+
toolset: null,
|
|
301
|
+
// las listas antes del filtro de aws y del deny forzado de arriba: las que mandó el server.
|
|
302
|
+
toolsetShadow: raw.toolset === undefined || raw.toolset === null
|
|
303
|
+
? null
|
|
304
|
+
: shadowSourceOf(raw.toolset, { allowed: serverAllowed, disallowed: serverDisallowed, permissionMode }, id),
|
|
332
305
|
};
|
|
333
306
|
}
|
|
307
|
+
// el permission mode de un run dentro del techo local (nunca bypassPermissions; un prompt run, el suyo). lanza si no.
|
|
308
|
+
function vetPermissionMode(kind, permissionMode) {
|
|
309
|
+
if (!ALLOWED_PERMISSION_MODES.includes(permissionMode)) {
|
|
310
|
+
throw new Error(`claim inválido: permission mode "${permissionMode}" fuera del techo local (${ALLOWED_PERMISSION_MODES.join(', ')})`);
|
|
311
|
+
}
|
|
312
|
+
if (kind === RUN_KIND.prompt && permissionMode !== PROMPT_PERMISSION_MODE) {
|
|
313
|
+
throw new Error(`claim inválido: un prompt run exige permission mode ${PROMPT_PERMISSION_MODE} (llegó "${permissionMode}")`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/** listas de tools y permission mode de un run, cribadas contra el techo local: las del server al parsear el claim y
|
|
317
|
+
* las que renderiza el daemon en el flip de toolset_v1 (withRenderedTools). lanza si no se pueden cumplir. */
|
|
318
|
+
function vetTools(kind, profile, lists) {
|
|
319
|
+
vetPermissionMode(kind, lists.permissionMode);
|
|
320
|
+
const readPrompt = kind === RUN_KIND.prompt && profile === PROMPT_PROFILE.read;
|
|
321
|
+
const leaked = readPrompt ? lists.allowed.filter(isForbiddenInRead) : [];
|
|
322
|
+
if (leaked.length > 0)
|
|
323
|
+
throw new Error(`claim inválido: un prompt run de lectura no puede permitir ${leaked.join(', ')}`);
|
|
324
|
+
// una `Bash(aws …)` que no reconozco (lectura nueva de un server más moderno, o una escritura) se
|
|
325
|
+
// descarta sin tumbar el run: sin ella el cli la niega (dontAsk).
|
|
326
|
+
const unknownAws = readPrompt ? lists.allowed.filter((t) => t.startsWith(`${BASH_TOOL}(`) && !isAwsReadPattern(t)) : [];
|
|
327
|
+
return {
|
|
328
|
+
allowed: lists.allowed.filter((t) => !unknownAws.includes(t)),
|
|
329
|
+
disallowed: Array.from(new Set([...lists.disallowed, ...(readPrompt ? READ_FORCED_DENY : [])])),
|
|
330
|
+
warnings: unknownAws.length > 0 ? [`aws descartada en lectura (no es una lectura que este runner reconozca): ${unknownAws.join(', ')}`] : [],
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/** el claim con las listas que renderizó el daemon (el flip de toolset_v1, toolset/legacy-render.ts) en vez de las
|
|
334
|
+
* del server, pasadas por la misma criba. lanza si no se pueden cumplir. */
|
|
335
|
+
export function withRenderedTools(claim, rendered) {
|
|
336
|
+
const vetted = vetTools(claim.run.kind, claim.run.profile, rendered);
|
|
337
|
+
return {
|
|
338
|
+
...claim,
|
|
339
|
+
tools: { allowed: vetted.allowed, disallowed: vetted.disallowed },
|
|
340
|
+
permissionMode: rendered.permissionMode,
|
|
341
|
+
warnings: [...claim.warnings, ...vetted.warnings],
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
// el toolset_v1 de un claim para la sombra; uno mal formado no tumba el claim (las listas mandan): se ignora con un
|
|
345
|
+
// aviso en el log, sin sombra.
|
|
346
|
+
function shadowSourceOf(raw, server, runId) {
|
|
347
|
+
try {
|
|
348
|
+
return { toolset: parseToolsetV1(raw), server };
|
|
349
|
+
}
|
|
350
|
+
catch (err) {
|
|
351
|
+
console.warn(`[runner] run ${runId}: ${err.message}: sin sombra de toolset_v1`);
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
334
355
|
//# sourceMappingURL=claim.js.map
|