@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/dist/sync/walk.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Ignore } from "ignore";
|
|
2
|
-
/** Names never uploaded, regardless of .gitignore (VCS internals, our own config, deps). */
|
|
3
|
-
export declare const HARD_SKIP: Set<string>;
|
|
4
|
-
/** Build an `ignore` matcher from the root `.gitignore` (empty matcher if there is none). Shared by
|
|
5
|
-
* the one-shot walker and the live watcher so both honor the exact same filter rules. */
|
|
6
|
-
export declare function loadIgnore(root: string): Promise<Ignore>;
|
|
7
|
-
export interface WalkedFile {
|
|
8
|
-
/** POSIX path relative to the walk root (e.g. "src/index.ts"). */
|
|
9
|
-
readonly relPath: string;
|
|
10
|
-
readonly content: string;
|
|
11
|
-
}
|
|
12
|
-
export interface WalkResult {
|
|
13
|
-
readonly files: WalkedFile[];
|
|
14
|
-
/** Total entries skipped (gitignored / too large / binary). */
|
|
15
|
-
readonly skipped: number;
|
|
16
|
-
/** Subset of `skipped` that were binary files (surfaced to the user, who may not expect it). */
|
|
17
|
-
readonly skippedBinary: number;
|
|
18
|
-
}
|
|
19
|
-
/** Recursively collect uploadable text files under `root`, honoring the root `.gitignore`. */
|
|
20
|
-
export declare function walkProject(root: string, maxBytes: number): Promise<WalkResult>;
|
|
21
|
-
/** Heuristic: a NUL byte in the first 8KB ⇒ treat as binary (not uploadable as text). */
|
|
22
|
-
export declare function isBinary(buf: Buffer): boolean;
|
|
23
|
-
//# sourceMappingURL=walk.d.ts.map
|
package/dist/sync/walk.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/sync/walk.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC,4FAA4F;AAC5F,eAAO,MAAM,SAAS,aAAkD,CAAC;AAEzE;0FAC0F;AAC1F,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ9D;AAED,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gGAAgG;IAChG,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,8FAA8F;AAC9F,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA4CrF;AAED,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAM7C"}
|
package/dist/sync/walk.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// Walk a local folder into the set of text files to upload to a cloud project.
|
|
2
|
-
//
|
|
3
|
-
// SRP: recursively list a directory, honoring the project's `.gitignore` (so the upload mirrors what
|
|
4
|
-
// the user would commit) plus a small hard-skip set (.git/.pocketdev/node_modules — never uploaded).
|
|
5
|
-
// Dotfiles ARE included unless gitignored. Binary files and files over the host's max size are skipped
|
|
6
|
-
// (the file API carries UTF-8 text only); binaries are counted separately so the caller can report them.
|
|
7
|
-
import { promises as fs } from "node:fs";
|
|
8
|
-
import { createRequire } from "node:module";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
// `ignore` is CJS with an `export default` typing; under NodeNext the default import isn't seen as
|
|
11
|
-
// callable, so load it via createRequire (typed against the package's own `Ignore` interface).
|
|
12
|
-
const ignore = createRequire(import.meta.url)("ignore");
|
|
13
|
-
/** Names never uploaded, regardless of .gitignore (VCS internals, our own config, deps). */
|
|
14
|
-
export const HARD_SKIP = new Set([".git", ".pocketdev", "node_modules"]);
|
|
15
|
-
/** Build an `ignore` matcher from the root `.gitignore` (empty matcher if there is none). Shared by
|
|
16
|
-
* the one-shot walker and the live watcher so both honor the exact same filter rules. */
|
|
17
|
-
export async function loadIgnore(root) {
|
|
18
|
-
const ig = ignore();
|
|
19
|
-
try {
|
|
20
|
-
ig.add(await fs.readFile(join(root, ".gitignore"), "utf8"));
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// No root .gitignore — only the HARD_SKIP set applies.
|
|
24
|
-
}
|
|
25
|
-
return ig;
|
|
26
|
-
}
|
|
27
|
-
/** Recursively collect uploadable text files under `root`, honoring the root `.gitignore`. */
|
|
28
|
-
export async function walkProject(root, maxBytes) {
|
|
29
|
-
const ig = await loadIgnore(root);
|
|
30
|
-
const files = [];
|
|
31
|
-
let skipped = 0;
|
|
32
|
-
let skippedBinary = 0;
|
|
33
|
-
async function walk(dir, rel) {
|
|
34
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
35
|
-
for (const e of entries) {
|
|
36
|
-
const name = e.name;
|
|
37
|
-
if (HARD_SKIP.has(name)) {
|
|
38
|
-
if (e.isDirectory())
|
|
39
|
-
skipped++;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const childRel = rel ? `${rel}/${name}` : name;
|
|
43
|
-
// `ignore` matches dir patterns (e.g. "dist/") against a trailing-slash path.
|
|
44
|
-
if (ig.ignores(e.isDirectory() ? `${childRel}/` : childRel)) {
|
|
45
|
-
skipped++;
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
const abs = join(dir, name);
|
|
49
|
-
if (e.isDirectory()) {
|
|
50
|
-
await walk(abs, childRel);
|
|
51
|
-
}
|
|
52
|
-
else if (e.isFile()) {
|
|
53
|
-
const stat = await fs.stat(abs);
|
|
54
|
-
if (stat.size > maxBytes) {
|
|
55
|
-
skipped++;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const buf = await fs.readFile(abs);
|
|
59
|
-
if (isBinary(buf)) {
|
|
60
|
-
skipped++;
|
|
61
|
-
skippedBinary++;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
files.push({ relPath: childRel, content: buf.toString("utf8") });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
await walk(root, "");
|
|
69
|
-
files.sort((a, b) => a.relPath.localeCompare(b.relPath));
|
|
70
|
-
return { files, skipped, skippedBinary };
|
|
71
|
-
}
|
|
72
|
-
/** Heuristic: a NUL byte in the first 8KB ⇒ treat as binary (not uploadable as text). */
|
|
73
|
-
export function isBinary(buf) {
|
|
74
|
-
const n = Math.min(buf.length, 8000);
|
|
75
|
-
for (let i = 0; i < n; i++) {
|
|
76
|
-
if (buf[i] === 0)
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=walk.js.map
|
package/dist/sync/walk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../../src/sync/walk.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,qGAAqG;AACrG,qGAAqG;AACrG,uGAAuG;AACvG,yGAAyG;AAEzG,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,mGAAmG;AACnG,+FAA+F;AAC/F,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAkC,CAAC;AAEzF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AAEzE;0FAC0F;AAC1F,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC;QACH,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,uDAAuD;IACzD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAgBD,8FAA8F;AAC9F,MAAM,CAAC,KAAK,UAAU,WAAW,CA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I,IAAI,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC;oBACzB,OAAO,EAAE,CAAC;oBACV,SAAS;gBACX,CAAC;gBACD,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACnC,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBAClB,OAAO,EAAE,CAAC;oBACV,aAAa,EAAE,CAAC;oBAChB,SAAS;gBACX,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACrB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;AAC3C,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/sync/watch.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface WatchHandlers {
|
|
2
|
-
/** A file was created or changed; `content` is its UTF-8 text. */
|
|
3
|
-
onUpsert(relPath: string, content: string): Promise<void> | void;
|
|
4
|
-
/** A file or directory was removed. */
|
|
5
|
-
onDelete(relPath: string): Promise<void> | void;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Watch `root` and drive `handlers` on each change until `signal` aborts (Ctrl-C), then close the
|
|
9
|
-
* watcher and resolve. Handler calls are serialized (a single in-order queue) so output stays
|
|
10
|
-
* ordered and uploads never stampede. Filtering matches `walkProject`.
|
|
11
|
-
*/
|
|
12
|
-
export declare function watchProject(root: string, maxBytes: number, handlers: WatchHandlers, signal: AbortSignal): Promise<void>;
|
|
13
|
-
//# sourceMappingURL=watch.d.ts.map
|
package/dist/sync/watch.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/sync/watch.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjE,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
package/dist/sync/watch.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Live local→remote sync: watch a folder and stream create/modify/delete to the cloud project.
|
|
2
|
-
//
|
|
3
|
-
// SRP: turn local filesystem events into upsert/delete callbacks, applying the SAME filter rules as
|
|
4
|
-
// the one-shot walker (HARD_SKIP dirs, the root .gitignore, the host max-byte size, binary skip) so
|
|
5
|
-
// `sync` and `sync --watch` mirror exactly the same file set. It owns NO transport — the caller
|
|
6
|
-
// (push.ts) decides how an upsert/delete reaches the host (PUT/DELETE /api/file).
|
|
7
|
-
import { watch } from "chokidar";
|
|
8
|
-
import { promises as fs } from "node:fs";
|
|
9
|
-
import { relative, sep } from "node:path";
|
|
10
|
-
import { HARD_SKIP, isBinary, loadIgnore } from "./walk.js";
|
|
11
|
-
/**
|
|
12
|
-
* Watch `root` and drive `handlers` on each change until `signal` aborts (Ctrl-C), then close the
|
|
13
|
-
* watcher and resolve. Handler calls are serialized (a single in-order queue) so output stays
|
|
14
|
-
* ordered and uploads never stampede. Filtering matches `walkProject`.
|
|
15
|
-
*/
|
|
16
|
-
export async function watchProject(root, maxBytes, handlers, signal) {
|
|
17
|
-
const ig = await loadIgnore(root);
|
|
18
|
-
const toRel = (abs) => relative(root, abs).split(sep).join("/");
|
|
19
|
-
const shouldIgnore = (abs) => {
|
|
20
|
-
const rel = toRel(abs);
|
|
21
|
-
if (!rel)
|
|
22
|
-
return false; // never ignore the watch root itself
|
|
23
|
-
if (rel.split("/").some((seg) => HARD_SKIP.has(seg)))
|
|
24
|
-
return true;
|
|
25
|
-
return ig.ignores(rel) || ig.ignores(`${rel}/`);
|
|
26
|
-
};
|
|
27
|
-
// Serialize handler work: each event appends to a promise chain so PUT/DELETEs run in order.
|
|
28
|
-
let chain = Promise.resolve();
|
|
29
|
-
const enqueue = (fn) => {
|
|
30
|
-
chain = chain.then(fn).catch(() => undefined);
|
|
31
|
-
};
|
|
32
|
-
const watcher = watch(root, {
|
|
33
|
-
ignoreInitial: true, // the caller already did the full initial sync
|
|
34
|
-
ignored: (p) => shouldIgnore(p),
|
|
35
|
-
awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }, // debounce editor partial writes
|
|
36
|
-
});
|
|
37
|
-
const onUpsert = (abs) => {
|
|
38
|
-
enqueue(async () => {
|
|
39
|
-
const rel = toRel(abs);
|
|
40
|
-
try {
|
|
41
|
-
const stat = await fs.stat(abs);
|
|
42
|
-
if (!stat.isFile() || stat.size > maxBytes)
|
|
43
|
-
return;
|
|
44
|
-
const buf = await fs.readFile(abs);
|
|
45
|
-
if (isBinary(buf))
|
|
46
|
-
return;
|
|
47
|
-
await handlers.onUpsert(rel, buf.toString("utf8"));
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
// File vanished between event and read, or unreadable — skip; a later event re-syncs.
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const onDelete = (abs) => {
|
|
55
|
-
const rel = toRel(abs);
|
|
56
|
-
if (!rel)
|
|
57
|
-
return;
|
|
58
|
-
enqueue(() => handlers.onDelete(rel));
|
|
59
|
-
};
|
|
60
|
-
watcher.on("add", onUpsert);
|
|
61
|
-
watcher.on("change", onUpsert);
|
|
62
|
-
watcher.on("unlink", onDelete);
|
|
63
|
-
watcher.on("unlinkDir", onDelete);
|
|
64
|
-
return new Promise((resolve) => {
|
|
65
|
-
const stop = () => {
|
|
66
|
-
signal.removeEventListener("abort", stop);
|
|
67
|
-
void watcher.close().finally(() => resolve());
|
|
68
|
-
};
|
|
69
|
-
if (signal.aborted)
|
|
70
|
-
stop();
|
|
71
|
-
else
|
|
72
|
-
signal.addEventListener("abort", stop, { once: true });
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=watch.js.map
|
package/dist/sync/watch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/sync/watch.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,EAAE;AACF,oGAAoG;AACpG,oGAAoG;AACpG,gGAAgG;AAChG,kFAAkF;AAElF,OAAO,EAAE,KAAK,EAAkB,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,QAAQ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Q,CAAC,CAAC;IAElC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,MAAM,IAAI,GAAG,GAAS,EAAE;YACtB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC;QACF,IAAI,MAAM,CAAC,OAAO;YAAE,IAAI,EAAE,CAAC;;YACtB,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/tools/git-diff.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Tool, ToolContext, ToolResult } from "./ports.js";
|
|
3
|
-
export declare class GitDiffTool implements Tool {
|
|
4
|
-
readonly name = "git_diff";
|
|
5
|
-
readonly summary = "Get git diff ranges for a file (GET /api/diff)";
|
|
6
|
-
readonly schema: z.ZodObject<{
|
|
7
|
-
path: z.ZodString;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
path: string;
|
|
10
|
-
}, {
|
|
11
|
-
path: string;
|
|
12
|
-
}>;
|
|
13
|
-
readonly sideEffect: "read";
|
|
14
|
-
execute(ctx: ToolContext): Promise<ToolResult>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=git-diff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git-diff.d.ts","sourceRoot":"","sources":["../../src/tools/git-diff.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAYhE,qBAAa,WAAY,YAAW,IAAI;IACtC,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,OAAO,oDAAoD;IACpE,QAAQ,CAAC,MAAM;;;;;;OAAU;IACzB,QAAQ,CAAC,UAAU,EAAG,MAAM,CAAU;IAEhC,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAUrD"}
|
package/dist/tools/git-diff.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// src/tools/git-diff.ts — `git_diff` tool → GET /api/diff?path
|
|
2
|
-
//
|
|
3
|
-
// Side effect: "read" → auto-allowed. Returns the file's git diff ranges as text the agent
|
|
4
|
-
// can reason about (added/modified/removed line spans).
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
import { ToolResults } from "./ports.js";
|
|
7
|
-
const schema = z.object({
|
|
8
|
-
path: z.string().min(1),
|
|
9
|
-
});
|
|
10
|
-
export class GitDiffTool {
|
|
11
|
-
name = "git_diff";
|
|
12
|
-
summary = "Get git diff ranges for a file (GET /api/diff)";
|
|
13
|
-
schema = schema;
|
|
14
|
-
sideEffect = "read";
|
|
15
|
-
async execute(ctx) {
|
|
16
|
-
const input = schema.parse(ctx.input);
|
|
17
|
-
const res = await ctx.http.get("/api/diff", { path: input.path });
|
|
18
|
-
if (res.ranges.length === 0) {
|
|
19
|
-
return ToolResults.ok(`${res.path}: no changes`, { path: res.path, ranges: [] });
|
|
20
|
-
}
|
|
21
|
-
const lines = res.ranges.map((r) => `${r.type.padEnd(8)} L${r.start}-${r.end}`).join("\n");
|
|
22
|
-
return ToolResults.ok(`${res.path}\n${lines}`, { path: res.path, ranges: res.ranges });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=git-diff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git-diff.js","sourceRoot":"","sources":["../../src/tools/git-diff.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/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,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Tool, ToolContext, ToolResult } from "./ports.js";
|
|
3
|
-
export declare class HttpRequestTool implements Tool {
|
|
4
|
-
readonly name = "http_request";
|
|
5
|
-
readonly summary = "Make an HTTP request through the host proxy (POST /api/request)";
|
|
6
|
-
readonly schema: z.ZodObject<{
|
|
7
|
-
method: z.ZodDefault<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]>>>;
|
|
8
|
-
url: z.ZodString;
|
|
9
|
-
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
10
|
-
body: z.ZodOptional<z.ZodString>;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
method: "POST" | "HEAD" | "GET" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
|
|
13
|
-
url: string;
|
|
14
|
-
headers?: Record<string, string> | undefined;
|
|
15
|
-
body?: string | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
url: string;
|
|
18
|
-
method?: string | undefined;
|
|
19
|
-
headers?: Record<string, string> | undefined;
|
|
20
|
-
body?: string | undefined;
|
|
21
|
-
}>;
|
|
22
|
-
readonly sideEffect: "exec";
|
|
23
|
-
execute(ctx: ToolContext): Promise<ToolResult>;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=http-request.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-request.d.ts","sourceRoot":"","sources":["../../src/tools/http-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAchE,qBAAa,eAAgB,YAAW,IAAI;IAC1C,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,QAAQ,CAAC,OAAO,qEAAqE;IACrF,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;;OAAU;IACzB,QAAQ,CAAC,UAAU,EAAG,MAAM,CAAU;IAEhC,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAoBrD"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/tools/http-request.ts — `http_request` tool → POST /api/request (host HTTP proxy)
|
|
2
|
-
//
|
|
3
|
-
// Side effect: "exec" → gated (an outbound request can mutate remote state). The host's API
|
|
4
|
-
// client performs the request; we return status + body to the agent.
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
import { ToolResults } from "./ports.js";
|
|
7
|
-
const schema = z.object({
|
|
8
|
-
method: z
|
|
9
|
-
.string()
|
|
10
|
-
.transform((m) => m.toUpperCase())
|
|
11
|
-
.pipe(z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]))
|
|
12
|
-
.default("GET"),
|
|
13
|
-
url: z.string().url(),
|
|
14
|
-
headers: z.record(z.string()).optional(),
|
|
15
|
-
body: z.string().optional(),
|
|
16
|
-
});
|
|
17
|
-
export class HttpRequestTool {
|
|
18
|
-
name = "http_request";
|
|
19
|
-
summary = "Make an HTTP request through the host proxy (POST /api/request)";
|
|
20
|
-
schema = schema;
|
|
21
|
-
sideEffect = "exec";
|
|
22
|
-
async execute(ctx) {
|
|
23
|
-
const input = schema.parse(ctx.input);
|
|
24
|
-
const allowed = await ctx.approval.guard({ name: this.name, sideEffect: this.sideEffect, path: input.url });
|
|
25
|
-
if (!allowed)
|
|
26
|
-
return ToolResults.fail(`HTTP request to ${input.url} was denied by the approval gate`);
|
|
27
|
-
const req = {
|
|
28
|
-
method: input.method,
|
|
29
|
-
url: input.url,
|
|
30
|
-
...(input.headers ? { headers: input.headers } : {}),
|
|
31
|
-
...(input.body !== undefined ? { body: input.body } : {}),
|
|
32
|
-
};
|
|
33
|
-
const res = await ctx.http.post("/api/request", req);
|
|
34
|
-
const ok = res.status >= 200 && res.status < 400;
|
|
35
|
-
const summary = `HTTP ${res.status}\n${res.body}`;
|
|
36
|
-
return ok
|
|
37
|
-
? ToolResults.ok(summary, { status: res.status, headers: res.headers })
|
|
38
|
-
: ToolResults.fail(`upstream returned ${res.status}`, summary);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=http-request.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-request.js","sourceRoot":"","sources":["../../src/tools/http-request.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,EAAE;AACF,4FAA4F;AAC5F,qEAAqE;AAErE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SACjC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;SAC1E,OAAO,CAAC,KAAK,CAAC;IACjB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,OAAO,eAAe;IACjB,IAAI,GA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EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;YACvE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,qBAAqB,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;CACF"}
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Tool } from "./ports.js";
|
|
2
|
-
export { ToolRegistry } from "./registry.js";
|
|
3
|
-
export type { Tool, ToolContext, ToolResult, ToolSchema } from "./ports.js";
|
|
4
|
-
export { ToolResults } from "./ports.js";
|
|
5
|
-
/** The built-in tool set, registered at the DI root. */
|
|
6
|
-
export declare function defaultTools(): Tool[];
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,wDAAwD;AACxD,wBAAgB,YAAY,IAAI,IAAI,EAAE,CAQrC"}
|
package/dist/tools/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/tools/index.ts — the default agent-callable tool set (OCP wiring helper).
|
|
2
|
-
//
|
|
3
|
-
// The DI composition root imports `defaultTools()` and feeds it to `ToolRegistry`. Adding a
|
|
4
|
-
// tool = add a file and a line here; the agent loop never changes.
|
|
5
|
-
import { GitDiffTool } from "./git-diff.js";
|
|
6
|
-
import { HttpRequestTool } from "./http-request.js";
|
|
7
|
-
import { ReadFileTool } from "./read-file.js";
|
|
8
|
-
import { RunCommandTool } from "./run-command.js";
|
|
9
|
-
import { WriteFileTool } from "./write-file.js";
|
|
10
|
-
export { ToolRegistry } from "./registry.js";
|
|
11
|
-
export { ToolResults } from "./ports.js";
|
|
12
|
-
/** The built-in tool set, registered at the DI root. */
|
|
13
|
-
export function defaultTools() {
|
|
14
|
-
return [
|
|
15
|
-
new ReadFileTool(),
|
|
16
|
-
new WriteFileTool(),
|
|
17
|
-
new RunCommandTool(),
|
|
18
|
-
new HttpRequestTool(),
|
|
19
|
-
new GitDiffTool(),
|
|
20
|
-
];
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,4FAA4F;AAC5F,mEAAmE;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,wDAAwD;AACxD,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL,IAAI,YAAY,EAAE;QAClB,IAAI,aAAa,EAAE;QACnB,IAAI,cAAc,EAAE;QACpB,IAAI,eAAe,EAAE;QACrB,IAAI,WAAW,EAAE;KAClB,CAAC;AACJ,CAAC"}
|
package/dist/tools/ports.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { ZodTypeAny, z } from "zod";
|
|
2
|
-
import type { AuthProvider } from "../auth/ports.js";
|
|
3
|
-
import type { ApprovalGate, SideEffect } from "../agent/approval.js";
|
|
4
|
-
import type { Renderer } from "../render/ports.js";
|
|
5
|
-
import type { HttpPort, StreamPort, TerminalPort } from "../transport/ports.js";
|
|
6
|
-
/** A tool's input schema is a zod schema validated before `execute`. */
|
|
7
|
-
export type ToolSchema = ZodTypeAny;
|
|
8
|
-
export type ToolInputOf<S extends ToolSchema> = z.infer<S>;
|
|
9
|
-
/** What `execute` returns: a textual result and whether it succeeded. */
|
|
10
|
-
export interface ToolResult {
|
|
11
|
-
/** Whether the tool completed its side effect. */
|
|
12
|
-
ok: boolean;
|
|
13
|
-
/** Human/agent-readable output (file contents, command output, etc.). */
|
|
14
|
-
output: string;
|
|
15
|
-
/** Optional structured detail surfaced to transcript/renderer. */
|
|
16
|
-
detail?: Record<string, unknown>;
|
|
17
|
-
/** Set when `ok` is false. */
|
|
18
|
-
error?: string;
|
|
19
|
-
}
|
|
20
|
-
/** Everything a tool needs, injected by the agent loop. Abstractions only (DIP). */
|
|
21
|
-
export interface ToolContext {
|
|
22
|
-
/** Validated input (the tool's zod schema applied to the raw args). */
|
|
23
|
-
readonly input: Record<string, unknown>;
|
|
24
|
-
/** REST surface for host endpoints. */
|
|
25
|
-
readonly http: HttpPort;
|
|
26
|
-
/** Event stream (for tools that observe files:changed etc.). */
|
|
27
|
-
readonly stream: StreamPort;
|
|
28
|
-
/** PTY surface (for the exec tool to run a command host-side and collect its output). */
|
|
29
|
-
readonly terminal: TerminalPort;
|
|
30
|
-
/** Auth (rarely needed directly; transport already injects the header). */
|
|
31
|
-
readonly auth: AuthProvider;
|
|
32
|
-
/** Renderer for incremental output. */
|
|
33
|
-
readonly renderer: Renderer;
|
|
34
|
-
/** Approval gate; tools with write/exec effects must pass before applying. */
|
|
35
|
-
readonly approval: ApprovalGate;
|
|
36
|
-
/** The agent run this tool call belongs to (for transcript/undo attribution). */
|
|
37
|
-
readonly runId?: string;
|
|
38
|
-
/** Cancels long-running tool work (Ctrl-C / abort). */
|
|
39
|
-
readonly signal: AbortSignal;
|
|
40
|
-
}
|
|
41
|
-
export interface Tool {
|
|
42
|
-
/** Stable name the agent references, e.g. "write_file". */
|
|
43
|
-
readonly name: string;
|
|
44
|
-
/** One-line description surfaced to the user / `/help`. */
|
|
45
|
-
readonly summary: string;
|
|
46
|
-
/** zod input schema. */
|
|
47
|
-
readonly schema: ToolSchema;
|
|
48
|
-
/** Drives the approval gate. */
|
|
49
|
-
readonly sideEffect: SideEffect;
|
|
50
|
-
/** Apply the side effect against injected ports. */
|
|
51
|
-
execute(ctx: ToolContext): Promise<ToolResult>;
|
|
52
|
-
}
|
|
53
|
-
/** Convenience constructors for tool authors. */
|
|
54
|
-
export declare const ToolResults: {
|
|
55
|
-
readonly ok: (output: string, detail?: Record<string, unknown>) => ToolResult;
|
|
56
|
-
readonly fail: (error: string, output?: string) => ToolResult;
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/tools/ports.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEhF,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAA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AAED,iDAAiD;AACjD,eAAO,MAAM,WAAW;0BACX,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,UAAU;2BAGpD,MAAM,sBAAgB,UAAU;CAGpC,CAAC"}
|
package/dist/tools/ports.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/tools/ports.ts — Tool, ToolContext, ToolResult (cli.md §4/§7).
|
|
2
|
-
//
|
|
3
|
-
// A Tool is an agent-callable, side-effect-typed unit. The `sideEffect` field drives the
|
|
4
|
-
// ApprovalGate (read = free, write/exec = gated). Tools call host endpoints via injected
|
|
5
|
-
// ports (DIP) — they never touch `fs`, `undici`, or `ws` directly.
|
|
6
|
-
//
|
|
7
|
-
// OCP: new tools are REGISTERED in the ToolRegistry; the agent loop never changes.
|
|
8
|
-
/** Convenience constructors for tool authors. */
|
|
9
|
-
export const ToolResults = {
|
|
10
|
-
ok(output, detail) {
|
|
11
|
-
return { ok: true, output, detail };
|
|
12
|
-
},
|
|
13
|
-
fail(error, output = "") {
|
|
14
|
-
return { ok: false, output, error };
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=ports.js.map
|
package/dist/tools/ports.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/tools/ports.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,yFAAyF;AACzF,yFAAyF;AACzF,mEAAmE;AACnE,EAAE;AACF,mFAAmF;AA6DnF,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,CAAC,MAAc,EAAE,MAAgC;QACjD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtC,CAAC;IACD,IAAI,CAAC,KAAa,EAAE,MAAM,GAAG,EAAE;QAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;CACO,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Tool, ToolContext, ToolResult } from "./ports.js";
|
|
3
|
-
export declare class ReadFileTool implements Tool {
|
|
4
|
-
readonly name = "read_file";
|
|
5
|
-
readonly summary = "Read a file from the project (GET /api/file)";
|
|
6
|
-
readonly schema: z.ZodObject<{
|
|
7
|
-
path: z.ZodString;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
path: string;
|
|
10
|
-
}, {
|
|
11
|
-
path: string;
|
|
12
|
-
}>;
|
|
13
|
-
readonly sideEffect: "read";
|
|
14
|
-
execute(ctx: ToolContext): Promise<ToolResult>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=read-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../src/tools/read-file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAOhE,qBAAa,YAAa,YAAW,IAAI;IACvC,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,OAAO,kDAAkD;IAClE,QAAQ,CAAC,MAAM;;;;;;OAAU;IACzB,QAAQ,CAAC,UAAU,EAAG,MAAM,CAAU;IAEhC,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CASrD"}
|
package/dist/tools/read-file.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/tools/read-file.ts — `read_file` tool → GET /api/file?path
|
|
2
|
-
//
|
|
3
|
-
// Side effect: "read" → auto-allowed by the default policy. Returns file content for the agent.
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { ToolResults } from "./ports.js";
|
|
6
|
-
const schema = z.object({
|
|
7
|
-
path: z.string().min(1),
|
|
8
|
-
});
|
|
9
|
-
export class ReadFileTool {
|
|
10
|
-
name = "read_file";
|
|
11
|
-
summary = "Read a file from the project (GET /api/file)";
|
|
12
|
-
schema = schema;
|
|
13
|
-
sideEffect = "read";
|
|
14
|
-
async execute(ctx) {
|
|
15
|
-
const input = schema.parse(ctx.input);
|
|
16
|
-
const file = await ctx.http.get("/api/file", { path: input.path });
|
|
17
|
-
return ToolResults.ok(file.content, {
|
|
18
|
-
path: file.path,
|
|
19
|
-
mtime: file.mtime,
|
|
20
|
-
truncated: file.truncated ?? false,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=read-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../src/tools/read-file.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,gGAAgG;AAEhG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,WAAW,CAAC;IACnB,OAAO,GAAG,8CAA8C,CAAC;IACzD,MAAM,GAAG,MAAM,CAAC;IAChB,UAAU,GAAG,MAAe,CAAC;IAEtC,KAAK,CAAC,OAAO,CAAC,GAAgB;QAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAc,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAChF,OAAO,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE;YAClC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK;SACnC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/tools/registry.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Tool } from "./ports.js";
|
|
2
|
-
export declare class ToolRegistry {
|
|
3
|
-
private readonly byName;
|
|
4
|
-
register(tool: Tool): this;
|
|
5
|
-
registerAll(tools: readonly Tool[]): this;
|
|
6
|
-
get(name: string): Tool | undefined;
|
|
7
|
-
has(name: string): boolean;
|
|
8
|
-
list(): Tool[];
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAElD,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAQ1B,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI;IAKzC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAInC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,IAAI,IAAI,IAAI,EAAE;CAGf"}
|
package/dist/tools/registry.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// src/tools/registry.ts — ToolRegistry: the OCP extension point for agent-callable tools.
|
|
2
|
-
//
|
|
3
|
-
// Tools are REGISTERED here; the agent loop resolves them by name and never grows a switch.
|
|
4
|
-
export class ToolRegistry {
|
|
5
|
-
byName = new Map();
|
|
6
|
-
register(tool) {
|
|
7
|
-
if (this.byName.has(tool.name)) {
|
|
8
|
-
throw new Error(`duplicate tool name: ${tool.name}`);
|
|
9
|
-
}
|
|
10
|
-
this.byName.set(tool.name, tool);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
registerAll(tools) {
|
|
14
|
-
for (const t of tools)
|
|
15
|
-
this.register(t);
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
get(name) {
|
|
19
|
-
return this.byName.get(name);
|
|
20
|
-
}
|
|
21
|
-
has(name) {
|
|
22
|
-
return this.byName.has(name);
|
|
23
|
-
}
|
|
24
|
-
list() {
|
|
25
|
-
return [...this.byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,EAAE;AACF,4FAA4F;AAI5F,MAAM,OAAO,YAAY;IACN,MAAM,GAAG,IAAI,GAAG,EAAgB,CAAC;IAElD,QAAQ,CAAC,IAAU;QACjB,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,KAAsB;QAChC,KAAK,MAAM,CAAC,IAAI,KAAK;YAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI;QACF,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChF,CAAC;CACF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Tool, ToolContext, ToolResult } from "./ports.js";
|
|
3
|
-
export declare class RunCommandTool implements Tool {
|
|
4
|
-
readonly name = "run_command";
|
|
5
|
-
readonly summary = "Run a shell command on the host in a PTY (WS terminal:*)";
|
|
6
|
-
readonly schema: z.ZodObject<{
|
|
7
|
-
command: z.ZodString;
|
|
8
|
-
/** Hard cap so a runaway command cannot hang the agent loop. */
|
|
9
|
-
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
command: string;
|
|
12
|
-
timeoutMs: number;
|
|
13
|
-
}, {
|
|
14
|
-
command: string;
|
|
15
|
-
timeoutMs?: number | undefined;
|
|
16
|
-
}>;
|
|
17
|
-
readonly sideEffect: "exec";
|
|
18
|
-
execute(ctx: ToolContext): Promise<ToolResult>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=run-command.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../../src/tools/run-command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAShE,qBAAa,cAAe,YAAW,IAAI;IACzC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,OAAO,8DAA8D;IAC9E,QAAQ,CAAC,MAAM;;QAPf,gEAAgE;;;;;;;;OAOvC;IACzB,QAAQ,CAAC,UAAU,EAAG,MAAM,CAAU;IAEhC,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CA6CrD"}
|