@everywheredev/cli 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +274 -59
- package/package.json +3 -2
- package/scripts/build.mjs +68 -0
- package/dist/agent/agent-loop.d.ts +0 -40
- package/dist/agent/agent-loop.d.ts.map +0 -1
- package/dist/agent/agent-loop.js +0 -162
- package/dist/agent/agent-loop.js.map +0 -1
- package/dist/agent/approval.d.ts +0 -38
- package/dist/agent/approval.d.ts.map +0 -1
- package/dist/agent/approval.js +0 -55
- package/dist/agent/approval.js.map +0 -1
- package/dist/agent/run-tracker.d.ts +0 -26
- package/dist/agent/run-tracker.d.ts.map +0 -1
- package/dist/agent/run-tracker.js +0 -43
- package/dist/agent/run-tracker.js.map +0 -1
- package/dist/auth/device-flow.d.ts +0 -61
- package/dist/auth/device-flow.d.ts.map +0 -1
- package/dist/auth/device-flow.js +0 -141
- package/dist/auth/device-flow.js.map +0 -1
- package/dist/auth/hydra-oauth-auth-provider.d.ts +0 -35
- package/dist/auth/hydra-oauth-auth-provider.d.ts.map +0 -1
- package/dist/auth/hydra-oauth-auth-provider.js +0 -153
- package/dist/auth/hydra-oauth-auth-provider.js.map +0 -1
- package/dist/auth/keychain.d.ts +0 -42
- package/dist/auth/keychain.d.ts.map +0 -1
- package/dist/auth/keychain.js +0 -138
- package/dist/auth/keychain.js.map +0 -1
- package/dist/auth/pkce.d.ts +0 -20
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js +0 -44
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/ports.d.ts +0 -25
- package/dist/auth/ports.d.ts.map +0 -1
- package/dist/auth/ports.js +0 -8
- package/dist/auth/ports.js.map +0 -1
- package/dist/commands/activity.d.ts +0 -17
- package/dist/commands/activity.d.ts.map +0 -1
- package/dist/commands/activity.js +0 -54
- package/dist/commands/activity.js.map +0 -1
- package/dist/commands/agent.d.ts +0 -25
- package/dist/commands/agent.d.ts.map +0 -1
- package/dist/commands/agent.js +0 -80
- package/dist/commands/agent.js.map +0 -1
- package/dist/commands/agents.d.ts +0 -9
- package/dist/commands/agents.d.ts.map +0 -1
- package/dist/commands/agents.js +0 -28
- package/dist/commands/agents.js.map +0 -1
- package/dist/commands/commits.d.ts +0 -16
- package/dist/commands/commits.d.ts.map +0 -1
- package/dist/commands/commits.js +0 -39
- package/dist/commands/commits.js.map +0 -1
- package/dist/commands/diff.d.ts +0 -15
- package/dist/commands/diff.d.ts.map +0 -1
- package/dist/commands/diff.js +0 -27
- package/dist/commands/diff.js.map +0 -1
- package/dist/commands/expose.d.ts +0 -15
- package/dist/commands/expose.d.ts.map +0 -1
- package/dist/commands/expose.js +0 -39
- package/dist/commands/expose.js.map +0 -1
- package/dist/commands/index.d.ts +0 -7
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js +0 -12
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/login.d.ts +0 -9
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -27
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -9
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -24
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/me.d.ts +0 -10
- package/dist/commands/me.d.ts.map +0 -1
- package/dist/commands/me.js +0 -25
- package/dist/commands/me.js.map +0 -1
- package/dist/commands/open.d.ts +0 -16
- package/dist/commands/open.d.ts.map +0 -1
- package/dist/commands/open.js +0 -34
- package/dist/commands/open.js.map +0 -1
- package/dist/commands/ports.d.ts +0 -75
- package/dist/commands/ports.d.ts.map +0 -1
- package/dist/commands/ports.js +0 -78
- package/dist/commands/ports.js.map +0 -1
- package/dist/commands/profile.d.ts +0 -21
- package/dist/commands/profile.d.ts.map +0 -1
- package/dist/commands/profile.js +0 -93
- package/dist/commands/profile.js.map +0 -1
- package/dist/commands/push.d.ts +0 -18
- package/dist/commands/push.d.ts.map +0 -1
- package/dist/commands/push.js +0 -116
- package/dist/commands/push.js.map +0 -1
- package/dist/commands/registry.d.ts +0 -15
- package/dist/commands/registry.d.ts.map +0 -1
- package/dist/commands/registry.js +0 -45
- package/dist/commands/registry.js.map +0 -1
- package/dist/commands/request.d.ts +0 -25
- package/dist/commands/request.d.ts.map +0 -1
- package/dist/commands/request.js +0 -58
- package/dist/commands/request.js.map +0 -1
- package/dist/commands/resume.d.ts +0 -22
- package/dist/commands/resume.d.ts.map +0 -1
- package/dist/commands/resume.js +0 -69
- package/dist/commands/resume.js.map +0 -1
- package/dist/commands/save.d.ts +0 -34
- package/dist/commands/save.d.ts.map +0 -1
- package/dist/commands/save.js +0 -141
- package/dist/commands/save.js.map +0 -1
- package/dist/commands/session.d.ts +0 -9
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js +0 -282
- package/dist/commands/session.js.map +0 -1
- package/dist/commands/skills/markdown-loader.d.ts +0 -19
- package/dist/commands/skills/markdown-loader.d.ts.map +0 -1
- package/dist/commands/skills/markdown-loader.js +0 -108
- package/dist/commands/skills/markdown-loader.js.map +0 -1
- package/dist/commands/skills/registry.d.ts +0 -23
- package/dist/commands/skills/registry.d.ts.map +0 -1
- package/dist/commands/skills/registry.js +0 -45
- package/dist/commands/skills/registry.js.map +0 -1
- package/dist/commands/terminal.d.ts +0 -19
- package/dist/commands/terminal.d.ts.map +0 -1
- package/dist/commands/terminal.js +0 -39
- package/dist/commands/terminal.js.map +0 -1
- package/dist/commands/tree.d.ts +0 -16
- package/dist/commands/tree.d.ts.map +0 -1
- package/dist/commands/tree.js +0 -44
- package/dist/commands/tree.js.map +0 -1
- package/dist/commands/undo.d.ts +0 -18
- package/dist/commands/undo.d.ts.map +0 -1
- package/dist/commands/undo.js +0 -46
- package/dist/commands/undo.js.map +0 -1
- package/dist/config/config-store.d.ts +0 -19
- package/dist/config/config-store.d.ts.map +0 -1
- package/dist/config/config-store.js +0 -199
- package/dist/config/config-store.js.map +0 -1
- package/dist/config/defaults.d.ts +0 -22
- package/dist/config/defaults.d.ts.map +0 -1
- package/dist/config/defaults.js +0 -38
- package/dist/config/defaults.js.map +0 -1
- package/dist/config/ports.d.ts +0 -60
- package/dist/config/ports.d.ts.map +0 -1
- package/dist/config/ports.js +0 -8
- package/dist/config/ports.js.map +0 -1
- package/dist/config/profile-constants.d.ts +0 -4
- package/dist/config/profile-constants.d.ts.map +0 -1
- package/dist/config/profile-constants.js +0 -10
- package/dist/config/profile-constants.js.map +0 -1
- package/dist/config/profile.d.ts +0 -84
- package/dist/config/profile.d.ts.map +0 -1
- package/dist/config/profile.js +0 -66
- package/dist/config/profile.js.map +0 -1
- package/dist/contract/index.d.ts +0 -193
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/contract/index.js +0 -14
- package/dist/contract/index.js.map +0 -1
- package/dist/core/app.d.ts +0 -35
- package/dist/core/app.d.ts.map +0 -1
- package/dist/core/app.js +0 -86
- package/dist/core/app.js.map +0 -1
- package/dist/core/command-router.d.ts +0 -29
- package/dist/core/command-router.d.ts.map +0 -1
- package/dist/core/command-router.js +0 -61
- package/dist/core/command-router.js.map +0 -1
- package/dist/core/errors.d.ts +0 -39
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/errors.js +0 -106
- package/dist/core/errors.js.map +0 -1
- package/dist/core/preflight.d.ts +0 -16
- package/dist/core/preflight.d.ts.map +0 -1
- package/dist/core/preflight.js +0 -38
- package/dist/core/preflight.js.map +0 -1
- package/dist/core/repl.d.ts +0 -18
- package/dist/core/repl.d.ts.map +0 -1
- package/dist/core/repl.js +0 -128
- package/dist/core/repl.js.map +0 -1
- package/dist/di/container.d.ts +0 -13
- package/dist/di/container.d.ts.map +0 -1
- package/dist/di/container.js +0 -160
- package/dist/di/container.js.map +0 -1
- package/dist/di/tokens.d.ts +0 -20
- package/dist/di/tokens.d.ts.map +0 -1
- package/dist/di/tokens.js +0 -22
- package/dist/di/tokens.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/render/ink-renderer.d.ts +0 -28
- package/dist/render/ink-renderer.d.ts.map +0 -1
- package/dist/render/ink-renderer.js +0 -174
- package/dist/render/ink-renderer.js.map +0 -1
- package/dist/render/plain-renderer.d.ts +0 -16
- package/dist/render/plain-renderer.d.ts.map +0 -1
- package/dist/render/plain-renderer.js +0 -38
- package/dist/render/plain-renderer.js.map +0 -1
- package/dist/render/ports.d.ts +0 -12
- package/dist/render/ports.d.ts.map +0 -1
- package/dist/render/ports.js +0 -10
- package/dist/render/ports.js.map +0 -1
- package/dist/render/raw-renderer.d.ts +0 -11
- package/dist/render/raw-renderer.d.ts.map +0 -1
- package/dist/render/raw-renderer.js +0 -68
- package/dist/render/raw-renderer.js.map +0 -1
- package/dist/render/repl-input.d.ts +0 -15
- package/dist/render/repl-input.d.ts.map +0 -1
- package/dist/render/repl-input.js +0 -102
- package/dist/render/repl-input.js.map +0 -1
- package/dist/session/file-session-store.d.ts +0 -26
- package/dist/session/file-session-store.d.ts.map +0 -1
- package/dist/session/file-session-store.js +0 -174
- package/dist/session/file-session-store.js.map +0 -1
- package/dist/session/ports.d.ts +0 -50
- package/dist/session/ports.d.ts.map +0 -1
- package/dist/session/ports.js +0 -6
- package/dist/session/ports.js.map +0 -1
- package/dist/sync/git-sync.d.ts +0 -16
- package/dist/sync/git-sync.d.ts.map +0 -1
- package/dist/sync/git-sync.js +0 -28
- package/dist/sync/git-sync.js.map +0 -1
- package/dist/sync/git.d.ts +0 -12
- package/dist/sync/git.d.ts.map +0 -1
- package/dist/sync/git.js +0 -100
- package/dist/sync/git.js.map +0 -1
- package/dist/sync/reconciler.d.ts +0 -36
- package/dist/sync/reconciler.d.ts.map +0 -1
- package/dist/sync/reconciler.js +0 -143
- package/dist/sync/reconciler.js.map +0 -1
- package/dist/sync/walk.d.ts +0 -23
- package/dist/sync/walk.d.ts.map +0 -1
- package/dist/sync/walk.js +0 -81
- package/dist/sync/walk.js.map +0 -1
- package/dist/sync/watch.d.ts +0 -13
- package/dist/sync/watch.d.ts.map +0 -1
- package/dist/sync/watch.js +0 -75
- package/dist/sync/watch.js.map +0 -1
- package/dist/tools/git-diff.d.ts +0 -16
- package/dist/tools/git-diff.d.ts.map +0 -1
- package/dist/tools/git-diff.js +0 -25
- package/dist/tools/git-diff.js.map +0 -1
- package/dist/tools/http-request.d.ts +0 -25
- package/dist/tools/http-request.d.ts.map +0 -1
- package/dist/tools/http-request.js +0 -41
- package/dist/tools/http-request.js.map +0 -1
- package/dist/tools/index.d.ts +0 -7
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -22
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/ports.d.ts +0 -58
- package/dist/tools/ports.d.ts.map +0 -1
- package/dist/tools/ports.js +0 -17
- package/dist/tools/ports.js.map +0 -1
- package/dist/tools/read-file.d.ts +0 -16
- package/dist/tools/read-file.d.ts.map +0 -1
- package/dist/tools/read-file.js +0 -24
- package/dist/tools/read-file.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -10
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js +0 -28
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/run-command.d.ts +0 -20
- package/dist/tools/run-command.d.ts.map +0 -1
- package/dist/tools/run-command.js +0 -65
- package/dist/tools/run-command.js.map +0 -1
- package/dist/tools/write-file.d.ts +0 -24
- package/dist/tools/write-file.d.ts.map +0 -1
- package/dist/tools/write-file.js +0 -60
- package/dist/tools/write-file.js.map +0 -1
- package/dist/transport/composite-transport.d.ts +0 -30
- package/dist/transport/composite-transport.d.ts.map +0 -1
- package/dist/transport/composite-transport.js +0 -71
- package/dist/transport/composite-transport.js.map +0 -1
- package/dist/transport/device-browser.d.ts +0 -19
- package/dist/transport/device-browser.d.ts.map +0 -1
- package/dist/transport/device-browser.js +0 -243
- package/dist/transport/device-browser.js.map +0 -1
- package/dist/transport/device-git.d.ts +0 -14
- package/dist/transport/device-git.d.ts.map +0 -1
- package/dist/transport/device-git.js +0 -107
- package/dist/transport/device-git.js.map +0 -1
- package/dist/transport/device-http.d.ts +0 -10
- package/dist/transport/device-http.d.ts.map +0 -1
- package/dist/transport/device-http.js +0 -96
- package/dist/transport/device-http.js.map +0 -1
- package/dist/transport/device-terminal.d.ts +0 -44
- package/dist/transport/device-terminal.d.ts.map +0 -1
- package/dist/transport/device-terminal.js +0 -140
- package/dist/transport/device-terminal.js.map +0 -1
- package/dist/transport/http-transport.d.ts +0 -26
- package/dist/transport/http-transport.d.ts.map +0 -1
- package/dist/transport/http-transport.js +0 -125
- package/dist/transport/http-transport.js.map +0 -1
- package/dist/transport/ports.d.ts +0 -67
- package/dist/transport/ports.d.ts.map +0 -1
- package/dist/transport/ports.js +0 -11
- package/dist/transport/ports.js.map +0 -1
- package/dist/transport/reconnect.d.ts +0 -44
- package/dist/transport/reconnect.d.ts.map +0 -1
- package/dist/transport/reconnect.js +0 -69
- package/dist/transport/reconnect.js.map +0 -1
- package/dist/transport/terminal-transport.d.ts +0 -28
- package/dist/transport/terminal-transport.d.ts.map +0 -1
- package/dist/transport/terminal-transport.js +0 -63
- package/dist/transport/terminal-transport.js.map +0 -1
- package/dist/transport/ws-stream-transport.d.ts +0 -66
- package/dist/transport/ws-stream-transport.d.ts.map +0 -1
- package/dist/transport/ws-stream-transport.js +0 -246
- package/dist/transport/ws-stream-transport.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everywheredev/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "PocketDev CLI — a Claude-Code-style TypeScript thin client for the PocketDev host (FULL-REMOTE Hydra OAuth2).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"node": ">=20"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "tsc -p tsconfig.json",
|
|
32
|
+
"build": "tsc -p tsconfig.json --noEmit && node scripts/build.mjs",
|
|
33
33
|
"build:watch": "tsc -p tsconfig.json --watch",
|
|
34
34
|
"dev": "node --import tsx ./src/index.ts",
|
|
35
35
|
"test": "vitest run --passWithNoTests",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"@types/node": "^20.14.0",
|
|
59
59
|
"@types/react": "^18.3.3",
|
|
60
60
|
"@types/ws": "^8.5.12",
|
|
61
|
+
"esbuild": "^0.24.0",
|
|
61
62
|
"tsx": "^4.16.0",
|
|
62
63
|
"typescript": "^5.5.0",
|
|
63
64
|
"vitest": "^2.0.0"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Bundles the CLI into a single minified dist/index.js so the published package
|
|
2
|
+
// is not trivially readable (the source repo stays private; only this bundle ships).
|
|
3
|
+
//
|
|
4
|
+
// Why esbuild-direct-from-src is safe: src/ uses no decorators and DI is wired with
|
|
5
|
+
// manual factories (src/di/container.ts), so esbuild not emitting decorator metadata
|
|
6
|
+
// is irrelevant. Type-checking is enforced separately via `tsc --noEmit` (see the
|
|
7
|
+
// "build" script in package.json).
|
|
8
|
+
|
|
9
|
+
import { rm } from "node:fs/promises";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { dirname, resolve } from "node:path";
|
|
12
|
+
import { build } from "esbuild";
|
|
13
|
+
|
|
14
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
15
|
+
|
|
16
|
+
// Clear stale per-file tsc output so only the single bundle ships.
|
|
17
|
+
await rm(resolve(root, "dist"), { recursive: true, force: true });
|
|
18
|
+
|
|
19
|
+
await build({
|
|
20
|
+
absWorkingDir: root,
|
|
21
|
+
entryPoints: ["src/index.ts"],
|
|
22
|
+
outfile: "dist/index.js", // keep this path: bin/pocketdev.js and scripts/smoke.mjs import ../dist/index.js
|
|
23
|
+
bundle: true,
|
|
24
|
+
minify: true,
|
|
25
|
+
platform: "node",
|
|
26
|
+
format: "esm", // package is "type":"module"; preserves import.meta.url for createRequire
|
|
27
|
+
target: "node20",
|
|
28
|
+
legalComments: "none",
|
|
29
|
+
// ESM output has no `require`/__dirname/__filename globals, but bundled CJS deps (e.g. ws calling
|
|
30
|
+
// require("events")) and node-pty's createRequire path rely on them. Define them at the top of the
|
|
31
|
+
// bundle from import.meta.url so those calls resolve against the real Node module system.
|
|
32
|
+
banner: {
|
|
33
|
+
js: [
|
|
34
|
+
"import { createRequire as __everywhere_createRequire } from 'node:module';",
|
|
35
|
+
"import { fileURLToPath as __everywhere_fileURLToPath } from 'node:url';",
|
|
36
|
+
"import { dirname as __everywhere_dirname } from 'node:path';",
|
|
37
|
+
"const require = __everywhere_createRequire(import.meta.url);",
|
|
38
|
+
"const __filename = __everywhere_fileURLToPath(import.meta.url);",
|
|
39
|
+
"const __dirname = __everywhere_dirname(__filename);",
|
|
40
|
+
].join("\n"),
|
|
41
|
+
},
|
|
42
|
+
// Native addons + dynamic-import natives stay external (resolved from node_modules at runtime).
|
|
43
|
+
// node-pty/puppeteer-core/ignore load via createRequire (not followed by the bundler), but we
|
|
44
|
+
// list them for clarity; keytar loads via dynamic import() which esbuild WOULD bundle otherwise.
|
|
45
|
+
// These are real `dependencies` installed in the user's node_modules; keep them external so the
|
|
46
|
+
// native/dynamic loaders (createRequire / dynamic import()) resolve them at runtime.
|
|
47
|
+
external: ["node-pty", "keytar", "puppeteer-core", "ignore"],
|
|
48
|
+
plugins: [
|
|
49
|
+
// ink statically imports react-devtools-core (only used when ink's DEV devtools are enabled).
|
|
50
|
+
// It isn't a dependency, so we can't externalize it (an external ESM import resolves eagerly at
|
|
51
|
+
// load and would crash). Stub it to an empty module — the devtools code path never runs for users.
|
|
52
|
+
{
|
|
53
|
+
name: "stub-react-devtools",
|
|
54
|
+
setup(b) {
|
|
55
|
+
b.onResolve({ filter: /^react-devtools-core$/ }, () => ({
|
|
56
|
+
path: "react-devtools-core",
|
|
57
|
+
namespace: "stub-react-devtools",
|
|
58
|
+
}));
|
|
59
|
+
b.onLoad({ filter: /.*/, namespace: "stub-react-devtools" }, () => ({
|
|
60
|
+
contents: "export default {};",
|
|
61
|
+
loader: "js",
|
|
62
|
+
}));
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
process.stdout.write("built dist/index.js\n");
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Renderer } from "../render/ports.js";
|
|
2
|
-
import type { SessionStore } from "../session/ports.js";
|
|
3
|
-
import type { HttpPort, StreamPort } from "../transport/ports.js";
|
|
4
|
-
import { ApprovalGate } from "./approval.js";
|
|
5
|
-
import { RunTracker } from "./run-tracker.js";
|
|
6
|
-
/** Arguments for one agent prompt. */
|
|
7
|
-
export interface PromptRequest {
|
|
8
|
-
prompt: string;
|
|
9
|
-
agentId?: string;
|
|
10
|
-
context?: string;
|
|
11
|
-
attachments?: string[];
|
|
12
|
-
/** Session to attribute the turns to (REPL); when absent, transcript is skipped. */
|
|
13
|
-
sessionId?: string;
|
|
14
|
-
}
|
|
15
|
-
/** Outcome of a completed run. */
|
|
16
|
-
export interface RunOutcome {
|
|
17
|
-
runId: string;
|
|
18
|
-
agent: string;
|
|
19
|
-
code?: number;
|
|
20
|
-
error?: string;
|
|
21
|
-
/** Files the run touched, in first-seen order (for `/undo`). */
|
|
22
|
-
touchedPaths: string[];
|
|
23
|
-
}
|
|
24
|
-
export declare class AgentLoop {
|
|
25
|
-
private readonly http;
|
|
26
|
-
private readonly stream;
|
|
27
|
-
private readonly renderer;
|
|
28
|
-
private readonly approval;
|
|
29
|
-
private readonly tracker;
|
|
30
|
-
private readonly sessions;
|
|
31
|
-
constructor(http: HttpPort, stream: StreamPort, renderer: Renderer, approval: ApprovalGate, tracker: RunTracker, sessions: SessionStore);
|
|
32
|
-
/**
|
|
33
|
-
* Run one prompt to completion. Resolves when the host emits `agent:end` for this run.
|
|
34
|
-
* `signal` aborts streaming (the host run itself is cancelled by the host on disconnect).
|
|
35
|
-
*/
|
|
36
|
-
run(req: PromptRequest, signal: AbortSignal): Promise<RunOutcome>;
|
|
37
|
-
/** Run the approval gate for a tool event and record it for the transcript + undo. */
|
|
38
|
-
private handleTool;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=agent-loop.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../src/agent/agent-loop.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAmB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AASD,qBAAa,SAAS;IAElB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBALR,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,YAAY;IAGzC;;;OAGG;IACG,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAoFvE,sFAAsF;YACxE,UAAU;CAiBzB"}
|
package/dist/agent/agent-loop.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
// src/agent/agent-loop.ts — the agent + tool loop (cli.md §7).
|
|
2
|
-
//
|
|
3
|
-
// Flow: prompt → POST /api/agent/prompt {runId} → stream agent:output / agent:tool /
|
|
4
|
-
// agent:end over the WS → approval gate on write/exec tools → render → transcript.
|
|
5
|
-
//
|
|
6
|
-
// The host runs the model and APPLIES edits server-side (enforcing Casbin); the CLI renders
|
|
7
|
-
// the stream, runs the LOCAL approval gate (UX only), tracks runId for /undo and resume, and
|
|
8
|
-
// appends turns to the SessionStore. DIP: depends only on ports + the gate/tracker.
|
|
9
|
-
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { CliError } from "../core/errors.js";
|
|
11
|
-
export class AgentLoop {
|
|
12
|
-
http;
|
|
13
|
-
stream;
|
|
14
|
-
renderer;
|
|
15
|
-
approval;
|
|
16
|
-
tracker;
|
|
17
|
-
sessions;
|
|
18
|
-
constructor(http, stream, renderer, approval, tracker, sessions) {
|
|
19
|
-
this.http = http;
|
|
20
|
-
this.stream = stream;
|
|
21
|
-
this.renderer = renderer;
|
|
22
|
-
this.approval = approval;
|
|
23
|
-
this.tracker = tracker;
|
|
24
|
-
this.sessions = sessions;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Run one prompt to completion. Resolves when the host emits `agent:end` for this run.
|
|
28
|
-
* `signal` aborts streaming (the host run itself is cancelled by the host on disconnect).
|
|
29
|
-
*/
|
|
30
|
-
async run(req, signal) {
|
|
31
|
-
await this.stream.connect();
|
|
32
|
-
// Subscribe BEFORE issuing the prompt so we never miss the first chunk. Until the POST
|
|
33
|
-
// returns the runId, `activeRunId` is undefined and handlers accept any run; once set we
|
|
34
|
-
// filter strictly on it.
|
|
35
|
-
let activeRunId;
|
|
36
|
-
const subs = [];
|
|
37
|
-
// The user's turn is appended immediately (crash-safe) for resume.
|
|
38
|
-
if (req.sessionId) {
|
|
39
|
-
await this.sessions.append(req.sessionId, makeTurn("user", req.prompt));
|
|
40
|
-
}
|
|
41
|
-
let outputBuffer = "";
|
|
42
|
-
const toolCalls = [];
|
|
43
|
-
const result = new Promise((resolve, reject) => {
|
|
44
|
-
const onOutput = (p) => {
|
|
45
|
-
if (activeRunId && p.runId !== activeRunId)
|
|
46
|
-
return;
|
|
47
|
-
outputBuffer += p.chunk;
|
|
48
|
-
this.renderer.stream(p.chunk);
|
|
49
|
-
};
|
|
50
|
-
const onTool = (p) => {
|
|
51
|
-
if (activeRunId && p.runId !== activeRunId)
|
|
52
|
-
return;
|
|
53
|
-
// Defer the async approval so the synchronous event handler stays cheap.
|
|
54
|
-
void this.handleTool(p, toolCalls);
|
|
55
|
-
};
|
|
56
|
-
const onEnd = (p) => {
|
|
57
|
-
if (activeRunId && p.runId !== activeRunId)
|
|
58
|
-
return;
|
|
59
|
-
cleanup();
|
|
60
|
-
this.tracker.end(p.runId, { code: p.code, error: p.error });
|
|
61
|
-
const run = this.tracker.get(p.runId);
|
|
62
|
-
const touchedPaths = run?.touchedPaths ?? [];
|
|
63
|
-
// Append the agent's turn (collected output + tool calls) to the transcript.
|
|
64
|
-
if (req.sessionId) {
|
|
65
|
-
const turn = makeTurn("agent", outputBuffer, p.runId);
|
|
66
|
-
if (toolCalls.length)
|
|
67
|
-
turn.toolCalls = toolCalls;
|
|
68
|
-
void this.sessions.append(req.sessionId, turn);
|
|
69
|
-
}
|
|
70
|
-
if (p.error) {
|
|
71
|
-
this.renderer.error(`agent run ${shortId(p.runId)} failed: ${p.error}`);
|
|
72
|
-
}
|
|
73
|
-
else if (touchedPaths.length) {
|
|
74
|
-
// Offer undo for the first touched path (the REPL surfaces the full list).
|
|
75
|
-
this.renderer.stream(`\n[run ${shortId(p.runId)} done — undo with: pocketdev undo ${p.runId} <path>]\n`);
|
|
76
|
-
}
|
|
77
|
-
resolve({ runId: p.runId, agent: run?.agent ?? "", code: p.code, error: p.error, touchedPaths });
|
|
78
|
-
};
|
|
79
|
-
const onAbort = () => {
|
|
80
|
-
cleanup();
|
|
81
|
-
reject(new CliError("network", "agent run aborted before completion."));
|
|
82
|
-
};
|
|
83
|
-
const cleanup = () => {
|
|
84
|
-
for (const off of subs)
|
|
85
|
-
off();
|
|
86
|
-
signal.removeEventListener("abort", onAbort);
|
|
87
|
-
};
|
|
88
|
-
subs.push(this.stream.on("agent:output", onOutput));
|
|
89
|
-
subs.push(this.stream.on("agent:tool", onTool));
|
|
90
|
-
subs.push(this.stream.on("agent:end", onEnd));
|
|
91
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
92
|
-
});
|
|
93
|
-
// Now issue the prompt; map 422 (agent unavailable) to a friendly CliError upstream.
|
|
94
|
-
const res = await this.http.post("/api/agent/prompt", {
|
|
95
|
-
...(req.agentId ? { agentId: req.agentId } : {}),
|
|
96
|
-
prompt: req.prompt,
|
|
97
|
-
...(req.context ? { context: req.context } : {}),
|
|
98
|
-
...(req.attachments ? { attachments: req.attachments } : {}),
|
|
99
|
-
});
|
|
100
|
-
activeRunId = res.runId;
|
|
101
|
-
this.tracker.begin(res.runId, res.agent);
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
/** Run the approval gate for a tool event and record it for the transcript + undo. */
|
|
105
|
-
async handleTool(p, toolCalls) {
|
|
106
|
-
const path = typeof p.path === "string" ? p.path : undefined;
|
|
107
|
-
const action = normalizeAction(p.action);
|
|
108
|
-
const sideEffect = sideEffectFor(p.kind);
|
|
109
|
-
if (path)
|
|
110
|
-
this.tracker.touch(p.runId, path);
|
|
111
|
-
toolCalls.push({ kind: kindFor(p.kind), action, path });
|
|
112
|
-
// Reads are auto-allowed by the default policy; writes/execs prompt the user.
|
|
113
|
-
const allowed = await this.approval.guard({ name: toolName(p.kind, action), sideEffect, path });
|
|
114
|
-
if (!allowed) {
|
|
115
|
-
this.renderer.error(`Denied ${toolName(p.kind, action)}${path ? ` on ${path}` : ""}.`, "The host may have already applied this server-side; review with `pocketdev diff`.");
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// ── helpers ───────────────────────────────────────────────────────────────────
|
|
120
|
-
function makeTurn(role, text, runId) {
|
|
121
|
-
return { id: randomUUID(), role, text, at: Date.now(), ...(runId ? { runId } : {}) };
|
|
122
|
-
}
|
|
123
|
-
function sideEffectFor(kind) {
|
|
124
|
-
switch (kind) {
|
|
125
|
-
case "read":
|
|
126
|
-
return "read";
|
|
127
|
-
case "file":
|
|
128
|
-
return "write";
|
|
129
|
-
case "cmd":
|
|
130
|
-
return "exec";
|
|
131
|
-
default:
|
|
132
|
-
return "exec";
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function kindFor(kind) {
|
|
136
|
-
switch (kind) {
|
|
137
|
-
case "read":
|
|
138
|
-
return "read";
|
|
139
|
-
case "file":
|
|
140
|
-
return "file";
|
|
141
|
-
case "cmd":
|
|
142
|
-
return "cmd";
|
|
143
|
-
default:
|
|
144
|
-
return "cmd";
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function normalizeAction(action) {
|
|
148
|
-
if (action === "create" || action === "modify" || action === "delete")
|
|
149
|
-
return action;
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
function toolName(kind, action) {
|
|
153
|
-
if (kind === "file")
|
|
154
|
-
return action ? `file:${action}` : "file";
|
|
155
|
-
if (kind === "cmd")
|
|
156
|
-
return "command";
|
|
157
|
-
return "read";
|
|
158
|
-
}
|
|
159
|
-
function shortId(id) {
|
|
160
|
-
return id.slice(0, 8);
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=agent-loop.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.js","sourceRoot":"","sources":["../../src/agent/agent-loop.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,sFAAsF;AACtF,0FAA0F;AAC1F,EAAE;AACF,4FAA4F;AAC5F,6FAA6F;AAC7F,oFAAoF;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAkC7C,MAAM,OAAO,SAAS;IAED;IACA;IACA;IACA;IACA;IACA;IANnB,YACmB,IAAc,EACd,MAAkB,EAClB,QAAkB,EAClB,QAAsB,EACtB,OAAmB,EACnB,QAAsB;QALtB,SAAI,GAAJ,IAAI,CAAU;QACd,WAAM,GAAN,MAAM,CAAY;QAClB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAc;QACtB,YAAO,GAAP,OAAO,CAAY;QACnB,aAAQ,GAAR,QAAQ,CAAc;IACtC,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,GAAkB,EAAE,MAAmB;QAC/C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAE5B,uFAAuF;QACvF,yFAAyF;QACzF,yBAAyB;QACzB,IAAI,WAA+B,CAAC;QACpC,MAAM,IAAI,GAAkB,EAAE,CAAC;QAE/B,mEAAmE;QACnE,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,GAA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,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,OAAO,CAAC;QACjB,KAAK,KAAK;YACR,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,IAAuB;IACtC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,KAAK;YACR,OAAO,KAAK,CAAC;QACf;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAAe;IACtC,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACrF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,IAAuB,EAAE,MAA2B;IACpE,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/D,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,SAAS,CAAC;IACrC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,EAAU;IACzB,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxB,CAAC"}
|
package/dist/agent/approval.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Renderer } from "../render/ports.js";
|
|
2
|
-
/** Side effect class drives the gate: reads pass freely, writes/execs are gated. */
|
|
3
|
-
export type SideEffect = "read" | "write" | "exec";
|
|
4
|
-
/** A normalized request the gate reasons about (from a host `agent:tool` event or a Tool). */
|
|
5
|
-
export interface ToolRequest {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly sideEffect: SideEffect;
|
|
8
|
-
readonly path?: string;
|
|
9
|
-
}
|
|
10
|
-
export type Decision = "ask" | "allow" | "deny";
|
|
11
|
-
/**
|
|
12
|
-
* PermissionPolicy decides ask/allow/deny per tool. Implementations are pluggable (OCP):
|
|
13
|
-
* a default policy, a "yolo" auto-allow policy for `--dangerously-allow-all`, or a config
|
|
14
|
-
* driven rule set. The gate depends only on this interface (DIP).
|
|
15
|
-
*/
|
|
16
|
-
export interface PermissionPolicy {
|
|
17
|
-
decide(tool: ToolRequest): Decision;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Default policy: reads are always allowed, writes/execs ask, unless a rule has been
|
|
21
|
-
* remembered via `remember()` (the "always" answer) for that tool name.
|
|
22
|
-
*/
|
|
23
|
-
export declare class DefaultPermissionPolicy implements PermissionPolicy {
|
|
24
|
-
private readonly autoAllowAll;
|
|
25
|
-
private readonly allowed;
|
|
26
|
-
constructor(autoAllowAll?: boolean);
|
|
27
|
-
decide(tool: ToolRequest): Decision;
|
|
28
|
-
/** Remember an "always" answer for the rest of the session. */
|
|
29
|
-
remember(toolName: string): void;
|
|
30
|
-
}
|
|
31
|
-
export declare class ApprovalGate {
|
|
32
|
-
private readonly policy;
|
|
33
|
-
private readonly renderer;
|
|
34
|
-
constructor(policy: PermissionPolicy, renderer: Renderer);
|
|
35
|
-
/** Returns true if the tool may proceed (the host still re-checks via Casbin). */
|
|
36
|
-
guard(tool: ToolRequest): Promise<boolean>;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=approval.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/agent/approval.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,oFAAoF;AACpF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnD,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAC;CACrC;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAGlD,OAAO,CAAC,QAAQ,CAAC,YAAY;IAFzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEhB,YAAY,UAAQ;IAEjD,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ;IAOnC,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAGjC;AAED,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,QAAQ;IAGrC,kFAAkF;IAC5E,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CAkBjD"}
|
package/dist/agent/approval.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// src/agent/approval.ts — ApprovalGate + PermissionPolicy (cli.md §7).
|
|
2
|
-
//
|
|
3
|
-
// The approval gate is a LOCAL UX convenience. It is NEVER the sole guard: the host
|
|
4
|
-
// independently authorizes every action via Casbin server-side. The gate prompts the user
|
|
5
|
-
// before a write/exec tool is applied, and supports "always" to remember a decision for the
|
|
6
|
-
// rest of the session.
|
|
7
|
-
/**
|
|
8
|
-
* Default policy: reads are always allowed, writes/execs ask, unless a rule has been
|
|
9
|
-
* remembered via `remember()` (the "always" answer) for that tool name.
|
|
10
|
-
*/
|
|
11
|
-
export class DefaultPermissionPolicy {
|
|
12
|
-
autoAllowAll;
|
|
13
|
-
allowed = new Set();
|
|
14
|
-
constructor(autoAllowAll = false) {
|
|
15
|
-
this.autoAllowAll = autoAllowAll;
|
|
16
|
-
}
|
|
17
|
-
decide(tool) {
|
|
18
|
-
if (this.autoAllowAll)
|
|
19
|
-
return "allow";
|
|
20
|
-
if (tool.sideEffect === "read")
|
|
21
|
-
return "allow";
|
|
22
|
-
if (this.allowed.has(tool.name))
|
|
23
|
-
return "allow";
|
|
24
|
-
return "ask";
|
|
25
|
-
}
|
|
26
|
-
/** Remember an "always" answer for the rest of the session. */
|
|
27
|
-
remember(toolName) {
|
|
28
|
-
this.allowed.add(toolName);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export class ApprovalGate {
|
|
32
|
-
policy;
|
|
33
|
-
renderer;
|
|
34
|
-
constructor(policy, renderer) {
|
|
35
|
-
this.policy = policy;
|
|
36
|
-
this.renderer = renderer;
|
|
37
|
-
}
|
|
38
|
-
/** Returns true if the tool may proceed (the host still re-checks via Casbin). */
|
|
39
|
-
async guard(tool) {
|
|
40
|
-
switch (this.policy.decide(tool)) {
|
|
41
|
-
case "allow":
|
|
42
|
-
return true;
|
|
43
|
-
case "deny":
|
|
44
|
-
return false;
|
|
45
|
-
case "ask": {
|
|
46
|
-
const answer = await this.renderer.prompt(`Allow ${tool.name}${tool.path ? ` on ${tool.path}` : ""}?`, ["yes", "no", "always"]);
|
|
47
|
-
if (answer === "always" && this.policy instanceof DefaultPermissionPolicy) {
|
|
48
|
-
this.policy.remember(tool.name);
|
|
49
|
-
}
|
|
50
|
-
return answer !== "no";
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=approval.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../../src/agent/approval.ts"],"names":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E,GAAG,EAC3D,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CACxB,CAAC;gBACF,IAAI,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,YAAY,uBAAuB,EAAE,CAAC;oBAC1E,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,MAAM,KAAK,IAAI,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface TrackedRun {
|
|
2
|
-
readonly runId: string;
|
|
3
|
-
readonly agent: string;
|
|
4
|
-
readonly startedAt: number;
|
|
5
|
-
/** Paths the run created/modified, in first-seen order (for undo offers). */
|
|
6
|
-
readonly touchedPaths: string[];
|
|
7
|
-
endedAt?: number;
|
|
8
|
-
code?: number;
|
|
9
|
-
error?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare class RunTracker {
|
|
12
|
-
private readonly runs;
|
|
13
|
-
begin(runId: string, agent: string): TrackedRun;
|
|
14
|
-
/** Record a file path a tool touched during a run (deduplicated, order-preserving). */
|
|
15
|
-
touch(runId: string, path: string): void;
|
|
16
|
-
end(runId: string, result: {
|
|
17
|
-
code?: number;
|
|
18
|
-
error?: string;
|
|
19
|
-
}): void;
|
|
20
|
-
get(runId: string): TrackedRun | undefined;
|
|
21
|
-
/** runIds still streaming — replayed in ResumeState after a reconnect. */
|
|
22
|
-
inFlight(): string[];
|
|
23
|
-
/** Most recent run (for `/undo` with no explicit runId). */
|
|
24
|
-
latest(): TrackedRun | undefined;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=run-tracker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-tracker.d.ts","sourceRoot":"","sources":["../../src/agent/run-tracker.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6EAA6E;IAC7E,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiC;IAEtD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAM/C,uFAAuF;IACvF,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IASnE,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI1C,0EAA0E;IAC1E,QAAQ,IAAI,MAAM,EAAE;IAIpB,4DAA4D;IAC5D,MAAM,IAAI,UAAU,GAAG,SAAS;CAOjC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/agent/run-tracker.ts — tracks agent runs for /undo and reconnect/resume.
|
|
2
|
-
//
|
|
3
|
-
// SRP: remember which runIds are in-flight (so the StreamPort can resume them after a drop)
|
|
4
|
-
// and which file paths a run touched (so `/undo runId path` can offer the right targets).
|
|
5
|
-
export class RunTracker {
|
|
6
|
-
runs = new Map();
|
|
7
|
-
begin(runId, agent) {
|
|
8
|
-
const run = { runId, agent, startedAt: Date.now(), touchedPaths: [] };
|
|
9
|
-
this.runs.set(runId, run);
|
|
10
|
-
return run;
|
|
11
|
-
}
|
|
12
|
-
/** Record a file path a tool touched during a run (deduplicated, order-preserving). */
|
|
13
|
-
touch(runId, path) {
|
|
14
|
-
const run = this.runs.get(runId);
|
|
15
|
-
if (run && !run.touchedPaths.includes(path))
|
|
16
|
-
run.touchedPaths.push(path);
|
|
17
|
-
}
|
|
18
|
-
end(runId, result) {
|
|
19
|
-
const run = this.runs.get(runId);
|
|
20
|
-
if (run) {
|
|
21
|
-
run.endedAt = Date.now();
|
|
22
|
-
run.code = result.code;
|
|
23
|
-
run.error = result.error;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
get(runId) {
|
|
27
|
-
return this.runs.get(runId);
|
|
28
|
-
}
|
|
29
|
-
/** runIds still streaming — replayed in ResumeState after a reconnect. */
|
|
30
|
-
inFlight() {
|
|
31
|
-
return [...this.runs.values()].filter((r) => r.endedAt === undefined).map((r) => r.runId);
|
|
32
|
-
}
|
|
33
|
-
/** Most recent run (for `/undo` with no explicit runId). */
|
|
34
|
-
latest() {
|
|
35
|
-
let newest;
|
|
36
|
-
for (const r of this.runs.values()) {
|
|
37
|
-
if (!newest || r.startedAt > newest.startedAt)
|
|
38
|
-
newest = r;
|
|
39
|
-
}
|
|
40
|
-
return newest;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=run-tracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-tracker.js","sourceRoot":"","sources":["../../src/agent/run-tracker.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,4FAA4F;AAC5F,0FAA0F;AAa1F,MAAM,OAAO,UAAU;IACJ,IAAI,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEtD,KAAK,CAAC,KAAa,EAAE,KAAa;QAChC,MAAM,GAAG,GAAe,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;QAClF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,G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AAC,SAAS;gBAAE,MAAM,GAAG,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/** OIDC discovery document fields we use. */
|
|
2
|
-
export interface OidcDiscovery {
|
|
3
|
-
issuer: string;
|
|
4
|
-
device_authorization_endpoint: string;
|
|
5
|
-
token_endpoint: string;
|
|
6
|
-
revocation_endpoint?: string;
|
|
7
|
-
jwks_uri: string;
|
|
8
|
-
}
|
|
9
|
-
/** RFC 8628 device-authorization response. */
|
|
10
|
-
export interface DeviceAuthResponse {
|
|
11
|
-
device_code: string;
|
|
12
|
-
user_code: string;
|
|
13
|
-
verification_uri: string;
|
|
14
|
-
verification_uri_complete?: string;
|
|
15
|
-
expires_in: number;
|
|
16
|
-
interval?: number;
|
|
17
|
-
}
|
|
18
|
-
/** Token endpoint success response. */
|
|
19
|
-
export interface TokenSet {
|
|
20
|
-
access_token: string;
|
|
21
|
-
token_type: string;
|
|
22
|
-
expires_in?: number;
|
|
23
|
-
refresh_token?: string;
|
|
24
|
-
id_token?: string;
|
|
25
|
-
scope?: string;
|
|
26
|
-
/** Absolute epoch-ms expiry computed from `expires_in` at receipt. */
|
|
27
|
-
expiresAt?: number;
|
|
28
|
-
}
|
|
29
|
-
export interface DeviceFlowConfig {
|
|
30
|
-
oidcIssuer: string;
|
|
31
|
-
clientId: string;
|
|
32
|
-
scopes: readonly string[];
|
|
33
|
-
}
|
|
34
|
-
/** Injected so the device flow stays testable and dependency-free (no global fetch coupling). */
|
|
35
|
-
export type Fetch = typeof fetch;
|
|
36
|
-
/** Called once with the user_code + verification URL so the renderer can prompt the user. */
|
|
37
|
-
export type DevicePrompt = (info: {
|
|
38
|
-
userCode: string;
|
|
39
|
-
verificationUri: string;
|
|
40
|
-
verificationUriComplete?: string;
|
|
41
|
-
expiresIn: number;
|
|
42
|
-
}) => void;
|
|
43
|
-
export declare class DeviceFlow {
|
|
44
|
-
private readonly cfg;
|
|
45
|
-
private readonly fetchImpl;
|
|
46
|
-
private readonly sleep;
|
|
47
|
-
constructor(cfg: DeviceFlowConfig, fetchImpl?: Fetch, sleep?: (ms: number) => Promise<void>);
|
|
48
|
-
/** Discover the OIDC endpoints via /.well-known/openid-configuration. */
|
|
49
|
-
discover(): Promise<OidcDiscovery>;
|
|
50
|
-
/**
|
|
51
|
-
* Run the full grant: discover → request device code (with PKCE challenge) → prompt → poll.
|
|
52
|
-
* Resolves with a TokenSet (access + optional refresh/id tokens) on user approval.
|
|
53
|
-
*/
|
|
54
|
-
authorize(prompt: DevicePrompt): Promise<TokenSet>;
|
|
55
|
-
/** Refresh an access token using a refresh_token grant. */
|
|
56
|
-
refresh(refreshToken: string): Promise<TokenSet>;
|
|
57
|
-
/** Revoke a token (refresh or access) at logout, if the issuer exposes a revocation endpoint. */
|
|
58
|
-
revoke(token: string): Promise<void>;
|
|
59
|
-
private poll;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=device-flow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device-flow.d.ts","sourceRoot":"","sources":["../../src/auth/device-flow.ts"],"names":[],"mappings":"AAUA,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B,EAAE,MAAM,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,uCAAuC;AACvC,MAAM,WAAW,QA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