@tokenfactory/acc-runner 0.43.0 → 0.44.1
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 +75 -3
- package/dist/companion-run.d.ts.map +1 -1
- package/dist/companion-run.js +20 -0
- package/dist/companion-run.js.map +1 -1
- package/dist/config.d.ts +72 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +117 -3
- package/dist/config.js.map +1 -1
- package/dist/cost-pricing.d.ts +45 -0
- package/dist/cost-pricing.d.ts.map +1 -1
- package/dist/cost-pricing.js +57 -0
- package/dist/cost-pricing.js.map +1 -1
- package/dist/doctor.d.ts +4 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +32 -3
- package/dist/doctor.js.map +1 -1
- package/dist/engines/registry.d.ts +17 -6
- package/dist/engines/registry.d.ts.map +1 -1
- package/dist/engines/registry.js +38 -13
- package/dist/engines/registry.js.map +1 -1
- package/dist/git-auth/github-token-source.d.ts +54 -0
- package/dist/git-auth/github-token-source.d.ts.map +1 -0
- package/dist/git-auth/github-token-source.js +44 -0
- package/dist/git-auth/github-token-source.js.map +1 -0
- package/dist/git-auth/index.d.ts +4 -0
- package/dist/git-auth/index.d.ts.map +1 -1
- package/dist/git-auth/index.js +4 -0
- package/dist/git-auth/index.js.map +1 -1
- package/dist/git-auth/installation-token.d.ts +95 -0
- package/dist/git-auth/installation-token.d.ts.map +1 -0
- package/dist/git-auth/installation-token.js +192 -0
- package/dist/git-auth/installation-token.js.map +1 -0
- package/dist/instance.d.ts +30 -0
- package/dist/instance.d.ts.map +1 -0
- package/dist/instance.js +51 -0
- package/dist/instance.js.map +1 -0
- package/dist/keychain.d.ts +4 -8
- package/dist/keychain.d.ts.map +1 -1
- package/dist/keychain.js +10 -4
- package/dist/keychain.js.map +1 -1
- package/dist/local-repo/command.d.ts +28 -0
- package/dist/local-repo/command.d.ts.map +1 -0
- package/dist/local-repo/command.js +178 -0
- package/dist/local-repo/command.js.map +1 -0
- package/dist/local-repo/index.d.ts +119 -0
- package/dist/local-repo/index.d.ts.map +1 -0
- package/dist/local-repo/index.js +141 -0
- package/dist/local-repo/index.js.map +1 -0
- package/dist/login.d.ts +4 -0
- package/dist/login.d.ts.map +1 -1
- package/dist/login.js +6 -1
- package/dist/login.js.map +1 -1
- package/dist/mcp-spawn.d.ts +19 -0
- package/dist/mcp-spawn.d.ts.map +1 -1
- package/dist/mcp-spawn.js +52 -26
- package/dist/mcp-spawn.js.map +1 -1
- package/dist/memory-context.d.ts +106 -0
- package/dist/memory-context.d.ts.map +1 -0
- package/dist/memory-context.js +220 -0
- package/dist/memory-context.js.map +1 -0
- package/dist/memory-curation.d.ts +172 -0
- package/dist/memory-curation.d.ts.map +1 -0
- package/dist/memory-curation.js +277 -0
- package/dist/memory-curation.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +34 -0
- package/dist/program.js.map +1 -1
- package/dist/provider-auth.d.ts +70 -1
- package/dist/provider-auth.d.ts.map +1 -1
- package/dist/provider-auth.js +106 -2
- package/dist/provider-auth.js.map +1 -1
- package/dist/runtime/cache-dir.d.ts.map +1 -1
- package/dist/runtime/cache-dir.js +8 -3
- package/dist/runtime/cache-dir.js.map +1 -1
- package/dist/runtime/decision-provenance.d.ts +63 -0
- package/dist/runtime/decision-provenance.d.ts.map +1 -0
- package/dist/runtime/decision-provenance.js +107 -0
- package/dist/runtime/decision-provenance.js.map +1 -0
- package/dist/runtime/prompt-substitute.d.ts +100 -0
- package/dist/runtime/prompt-substitute.d.ts.map +1 -0
- package/dist/runtime/prompt-substitute.js +124 -0
- package/dist/runtime/prompt-substitute.js.map +1 -0
- package/dist/runtime/review-cost-cap.d.ts +167 -0
- package/dist/runtime/review-cost-cap.d.ts.map +1 -0
- package/dist/runtime/review-cost-cap.js +182 -0
- package/dist/runtime/review-cost-cap.js.map +1 -0
- package/dist/runtime/reviewer-abstain.d.ts +101 -0
- package/dist/runtime/reviewer-abstain.d.ts.map +1 -0
- package/dist/runtime/reviewer-abstain.js +138 -0
- package/dist/runtime/reviewer-abstain.js.map +1 -0
- package/dist/runtime/reviewer.d.ts +75 -0
- package/dist/runtime/reviewer.d.ts.map +1 -1
- package/dist/runtime/reviewer.js +235 -81
- package/dist/runtime/reviewer.js.map +1 -1
- package/dist/runtime/singleton.d.ts.map +1 -1
- package/dist/runtime/singleton.js +9 -1
- package/dist/runtime/singleton.js.map +1 -1
- package/dist/serving-auth/index.d.ts +79 -0
- package/dist/serving-auth/index.d.ts.map +1 -0
- package/dist/serving-auth/index.js +169 -0
- package/dist/serving-auth/index.js.map +1 -0
- package/dist/task-runner.d.ts +19 -2
- package/dist/task-runner.d.ts.map +1 -1
- package/dist/task-runner.js +110 -28
- package/dist/task-runner.js.map +1 -1
- package/dist/watch.d.ts +13 -0
- package/dist/watch.d.ts.map +1 -1
- package/dist/watch.js +128 -20
- package/dist/watch.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOCAL-REPO-CLI — `acc repo add-local <path>` and `acc repo list-local`.
|
|
3
|
+
*
|
|
4
|
+
* The plumbing around ./index.ts's pure rules: probe the directory, call
|
|
5
|
+
* acc.register_local_repo under the operator's OWN session, and write the
|
|
6
|
+
* resulting slug→path pair into this machine's config.json.
|
|
7
|
+
*
|
|
8
|
+
* WHY THE PERSON LANE AND NOT THE RUNNER LANE
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
* The runner session is an ACC-signed JWT that impersonates a machine's owner.
|
|
11
|
+
* It would authenticate fine, and using it would be wrong: the row being written
|
|
12
|
+
* is "THIS human grants THEMSELVES access to a repo on their disk", and the
|
|
13
|
+
* server refuses a null auth.uid() on that path for exactly that reason. So this
|
|
14
|
+
* command runs on the generalized device flow's person credential (`acc login`),
|
|
15
|
+
* the same one `acc chat` and `acc task list` use, and the machine identity is
|
|
16
|
+
* computed locally rather than taken from a session — a person may register a
|
|
17
|
+
* repo before they have ever enrolled this host as a runner.
|
|
18
|
+
*
|
|
19
|
+
* ORDER MATTERS: the server write happens FIRST, the local config write second.
|
|
20
|
+
* A local map entry pointing at a repo the server does not know is a silently
|
|
21
|
+
* dead directory reference; a server registration whose local path failed to
|
|
22
|
+
* save is a legible error the operator can fix by re-running (both writes are
|
|
23
|
+
* idempotent upserts).
|
|
24
|
+
*/
|
|
25
|
+
import { execFileSync } from "node:child_process";
|
|
26
|
+
import fs from "node:fs";
|
|
27
|
+
import os from "node:os";
|
|
28
|
+
import path from "node:path";
|
|
29
|
+
import chalk from "chalk";
|
|
30
|
+
import { loadLocalReposFromConfigFile, userConfigFilePath, writeLocalRepoToConfigFile, } from "../config.js";
|
|
31
|
+
import { machineIdentity } from "../login.js";
|
|
32
|
+
import { userClient } from "../user-cli/client.js";
|
|
33
|
+
import { isMigrationPending, localRepoDisplayName, planLocalRepoRegistration, } from "./index.js";
|
|
34
|
+
/** `~/code/app` → `/Users/me/code/app`. Absolute paths pass through. */
|
|
35
|
+
function expandHome(p) {
|
|
36
|
+
const trimmed = p.trim();
|
|
37
|
+
if (trimmed === "~")
|
|
38
|
+
return os.homedir();
|
|
39
|
+
if (trimmed.startsWith("~/"))
|
|
40
|
+
return path.resolve(os.homedir(), trimmed.slice(2));
|
|
41
|
+
return path.resolve(trimmed);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Probe a candidate directory. Every question is answered from the filesystem or
|
|
45
|
+
* a single read-only `git` call, and a failing `git` is an answer ("no origin"),
|
|
46
|
+
* never an exception — planLocalRepoRegistration decides what is fatal.
|
|
47
|
+
*/
|
|
48
|
+
export function probeLocalRepo(rawPath, nameOverride) {
|
|
49
|
+
const abs = expandHome(rawPath);
|
|
50
|
+
let isDirectory = false;
|
|
51
|
+
try {
|
|
52
|
+
isDirectory = fs.statSync(abs).isDirectory();
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
isDirectory = false;
|
|
56
|
+
}
|
|
57
|
+
// A `.git` FILE (not directory) is a worktree or submodule — still a git repo,
|
|
58
|
+
// so existsSync rather than an isDirectory check.
|
|
59
|
+
const isGitRepo = isDirectory && fs.existsSync(path.join(abs, ".git"));
|
|
60
|
+
let originUrl = null;
|
|
61
|
+
if (isGitRepo) {
|
|
62
|
+
try {
|
|
63
|
+
const out = execFileSync("git", ["-C", abs, "remote", "get-url", "origin"], {
|
|
64
|
+
encoding: "utf8",
|
|
65
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
66
|
+
});
|
|
67
|
+
originUrl = out.trim() || null;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
originUrl = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { path: abs, isDirectory, isGitRepo, originUrl, nameOverride: nameOverride ?? null };
|
|
74
|
+
}
|
|
75
|
+
export async function addLocalRepoCommand(repoPath, opts = {}) {
|
|
76
|
+
const out = opts.out ?? ((line) => console.log(line));
|
|
77
|
+
const plan = planLocalRepoRegistration(probeLocalRepo(repoPath, opts.name));
|
|
78
|
+
const machine = machineIdentity();
|
|
79
|
+
const sb = await userClient();
|
|
80
|
+
const { data, error } = await sb.rpc("register_local_repo", {
|
|
81
|
+
p_name: plan.name,
|
|
82
|
+
p_machine: machine,
|
|
83
|
+
p_project_slug: opts.project?.trim() || null,
|
|
84
|
+
});
|
|
85
|
+
if (error) {
|
|
86
|
+
if (isMigrationPending(error)) {
|
|
87
|
+
throw new Error("local repos are unavailable — migration 0318 has not been applied to this " +
|
|
88
|
+
"environment yet. Until it is, attach repos through the GitHub App path.");
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`could not register ${plan.name}: ${error.message}`);
|
|
91
|
+
}
|
|
92
|
+
const result = data;
|
|
93
|
+
if (!result?.repo) {
|
|
94
|
+
throw new Error("register_local_repo returned no repo slug — nothing was recorded locally");
|
|
95
|
+
}
|
|
96
|
+
const written = writeLocalRepoToConfigFile(result.repo, plan.path);
|
|
97
|
+
out(chalk.green(`✓ registered ${result.repo}`));
|
|
98
|
+
out(` path ${plan.path} ${chalk.dim("(this machine only)")}`);
|
|
99
|
+
out(` machine ${machine}`);
|
|
100
|
+
out(` access ${result.level} · source ${result.source} · you only`);
|
|
101
|
+
if (result.project_slug) {
|
|
102
|
+
out(` project ${result.project_slug}`);
|
|
103
|
+
}
|
|
104
|
+
out(chalk.dim(` recorded in ${written.path}`));
|
|
105
|
+
for (const warning of plan.warnings) {
|
|
106
|
+
out(chalk.yellow(` ! ${warning}`));
|
|
107
|
+
}
|
|
108
|
+
if (written.addedToServedRepos) {
|
|
109
|
+
out(chalk.yellow(" ! Added the slug to this machine's served-repo scope. Restart `acc watch` " +
|
|
110
|
+
"so it re-advertises its capabilities."));
|
|
111
|
+
}
|
|
112
|
+
out("");
|
|
113
|
+
out("Next: run `acc watch` on this machine to execute tasks for this repo.");
|
|
114
|
+
if (!result.project_slug) {
|
|
115
|
+
out(chalk.dim("It is now selectable in the project-create repo step, or attach it to an " +
|
|
116
|
+
"existing project with --project <slug>."));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* What this machine believes it serves locally, and whether the server agrees.
|
|
121
|
+
* The two can disagree in both directions — a config entry whose grant was
|
|
122
|
+
* revoked, or a grant registered from another machine — and an operator
|
|
123
|
+
* debugging "why is my task not running" needs to see which side is missing.
|
|
124
|
+
*/
|
|
125
|
+
export async function listLocalReposCommand(opts = {}) {
|
|
126
|
+
const out = opts.out ?? ((line) => console.log(line));
|
|
127
|
+
const local = loadLocalReposFromConfigFile();
|
|
128
|
+
let granted = [];
|
|
129
|
+
let grantError = null;
|
|
130
|
+
try {
|
|
131
|
+
const sb = await userClient();
|
|
132
|
+
// RLS scopes acc.user_repo_access to auth.uid(), so no user predicate is
|
|
133
|
+
// needed — and none should be added: the caller's own rows are the answer.
|
|
134
|
+
const { data, error } = await sb
|
|
135
|
+
.from("user_repo_access")
|
|
136
|
+
.select("repo, level, source")
|
|
137
|
+
.eq("source", "cli");
|
|
138
|
+
if (error)
|
|
139
|
+
throw new Error(error.message);
|
|
140
|
+
granted = (data ?? [])
|
|
141
|
+
.map((r) => r.repo)
|
|
142
|
+
.filter((r) => typeof r === "string");
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
// Offline / signed out is not a reason to refuse to print the local half.
|
|
146
|
+
grantError = err.message;
|
|
147
|
+
}
|
|
148
|
+
if (opts.json) {
|
|
149
|
+
out(JSON.stringify({
|
|
150
|
+
config_path: userConfigFilePath(),
|
|
151
|
+
local_repos: local,
|
|
152
|
+
granted_repos: granted,
|
|
153
|
+
grant_error: grantError,
|
|
154
|
+
}, null, 2));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const slugs = [...new Set([...Object.keys(local), ...granted.map((r) => r.toLowerCase())])].sort();
|
|
158
|
+
if (slugs.length === 0) {
|
|
159
|
+
out("No local repos registered on this machine.");
|
|
160
|
+
out(chalk.dim("Add one with `acc repo add-local <path>`."));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
for (const slug of slugs) {
|
|
164
|
+
const dir = local[slug];
|
|
165
|
+
const isGranted = granted.some((r) => r.toLowerCase() === slug);
|
|
166
|
+
const state = !dir
|
|
167
|
+
? chalk.yellow("registered on another machine — no local path here")
|
|
168
|
+
: !isGranted && !grantError
|
|
169
|
+
? chalk.yellow("no server grant — re-run `acc repo add-local`")
|
|
170
|
+
: chalk.dim(dir);
|
|
171
|
+
out(` ${localRepoDisplayName(slug).padEnd(24)} ${slug}`);
|
|
172
|
+
out(` ${" ".repeat(24)} ${state}`);
|
|
173
|
+
}
|
|
174
|
+
if (grantError) {
|
|
175
|
+
out(chalk.yellow(`! could not read your server grants: ${grantError}`));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/local-repo/command.ts"],"names":[],"mappings":"AA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C,CAAC,CAAC,SAAS,IAAI,CAAC,UAAU;gBACzB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,+CAA+C,CAAC;gBAC/D,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,GAAG,CAAC,KAAK,oBAAoB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC1D,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,wCAAwC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOCAL-REPO-CLI — the decidable half of `acc repo add-local`.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is pure: given a path on disk and a few probe results, decide
|
|
5
|
+
* what to register, what to refuse, and what to warn about. The plumbing that
|
|
6
|
+
* needs a keychain, a network and a filesystem lives in ./command.ts, the same
|
|
7
|
+
* split serve-scope uses — so every rule below is unit-testable without either.
|
|
8
|
+
*
|
|
9
|
+
* WHAT A "LOCAL REPO" IS, AND WHAT IT IS NOT
|
|
10
|
+
* ----------------------------------------------------------------------------
|
|
11
|
+
* It is a git working copy on THIS machine that ACC may run tasks in, attached
|
|
12
|
+
* to a project without the GitHub App being installed anywhere. That is the
|
|
13
|
+
* whole of it. In particular it is NOT:
|
|
14
|
+
*
|
|
15
|
+
* * a mirror of a GitHub repo ACC will keep in sync — nothing here clones,
|
|
16
|
+
* fetches or pushes on the server's behalf;
|
|
17
|
+
* * a repo other people on the team can work. The grant the server records is
|
|
18
|
+
* scoped to the registering user, and the path is known only to this
|
|
19
|
+
* machine, so a teammate's runner has neither the right nor the directory;
|
|
20
|
+
* * a way to skip a GitHub write grant on a repo that IS on GitHub. The
|
|
21
|
+
* server derives the slug from the caller's user id into a reserved
|
|
22
|
+
* `local.…` namespace precisely so this cannot be that.
|
|
23
|
+
*
|
|
24
|
+
* WHY THE PATH NEVER LEAVES THE MACHINE
|
|
25
|
+
* ----------------------------------------------------------------------------
|
|
26
|
+
* The server needs to know "machine M serves repo R" to route a task; it does
|
|
27
|
+
* not need to know that R is at /Users/priya/code/side-project. Sending the path
|
|
28
|
+
* would put a filesystem layout — usernames, project names, directory
|
|
29
|
+
* structure — into a shared database for no routing benefit, so the path stays
|
|
30
|
+
* in this machine's own config.json (`local-repos`) and the runner resolves it
|
|
31
|
+
* at task time. See docs/acc/LOCAL_REPO_CLI_SETUP.md.
|
|
32
|
+
*/
|
|
33
|
+
/** The reserved namespace the server mints local slugs into (acc.local_repo_slug). */
|
|
34
|
+
export declare const LOCAL_REPO_PREFIX = "local.";
|
|
35
|
+
/**
|
|
36
|
+
* Is this slug in the reserved local/CLI namespace? Mirrors
|
|
37
|
+
* acc.is_local_repo_slug (migration 0318) and src/lib/local-repo.ts. A GitHub
|
|
38
|
+
* owner segment can never contain a '.', so the two namespaces cannot collide.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isLocalRepoSlug(repo: string | null | undefined): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The human-facing name of a local repo — the part after the '/', without the
|
|
43
|
+
* per-user hash fragment that makes the slug unique. `local.9f2c1a/my-app` reads
|
|
44
|
+
* as "my-app (local)" in a list; the full slug is still what gets matched.
|
|
45
|
+
*/
|
|
46
|
+
export declare function localRepoDisplayName(repo: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Slugify a repo NAME the way acc.local_repo_slug does server-side, so the CLI
|
|
49
|
+
* can predict (and preview) the slug it is about to be handed. Kept in sync
|
|
50
|
+
* deliberately — the server is authoritative and the CLI stores whatever comes
|
|
51
|
+
* back, so a drift here is a cosmetic preview bug, never a wrong write.
|
|
52
|
+
*/
|
|
53
|
+
export declare function sanitizeLocalRepoName(raw: string): string;
|
|
54
|
+
/** What ./command.ts probed about the directory the operator pointed at. */
|
|
55
|
+
export interface LocalRepoProbe {
|
|
56
|
+
/** The resolved absolute path. */
|
|
57
|
+
path: string;
|
|
58
|
+
/** Does the path exist and is it a directory? */
|
|
59
|
+
isDirectory: boolean;
|
|
60
|
+
/** Is it a git repository (a `.git` entry at the root)? */
|
|
61
|
+
isGitRepo: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* `git remote get-url origin`, or null when there is no origin. Not a
|
|
64
|
+
* requirement — it only decides which warning the operator gets.
|
|
65
|
+
*/
|
|
66
|
+
originUrl: string | null;
|
|
67
|
+
/** Explicit `--name`, when the operator overrode the directory name. */
|
|
68
|
+
nameOverride?: string | null;
|
|
69
|
+
}
|
|
70
|
+
export interface LocalRepoPlan {
|
|
71
|
+
/** The name to send; the server derives the slug from it. */
|
|
72
|
+
name: string;
|
|
73
|
+
/** The absolute path to record in config.json. */
|
|
74
|
+
path: string;
|
|
75
|
+
/** The slug the server is expected to mint, for the pre-flight preview. */
|
|
76
|
+
previewSlug: string;
|
|
77
|
+
/**
|
|
78
|
+
* Advisory notes to print before the write. A plan always registers — these
|
|
79
|
+
* are the things an operator would rather learn now than at task time.
|
|
80
|
+
*/
|
|
81
|
+
warnings: string[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Decide what to register for a probed directory, or throw with the reason it
|
|
85
|
+
* cannot be registered.
|
|
86
|
+
*
|
|
87
|
+
* Refusals are limited to the two facts that make registration meaningless: the
|
|
88
|
+
* path is not a directory, or it is not a git repository (the runner's whole
|
|
89
|
+
* task loop is `git` — branch, commit, diff — so a plain folder would fail at
|
|
90
|
+
* the first step rather than at a legible place).
|
|
91
|
+
*
|
|
92
|
+
* A missing `origin` is NOT a refusal. Running tasks in a local working copy is
|
|
93
|
+
* useful on its own; it is opening a PR at the end that needs a remote, and the
|
|
94
|
+
* warning says exactly that instead of pre-emptively blocking the register.
|
|
95
|
+
*/
|
|
96
|
+
export declare function planLocalRepoRegistration(probe: LocalRepoProbe): LocalRepoPlan;
|
|
97
|
+
/** The shape acc.register_local_repo returns (migration 0318 §7). */
|
|
98
|
+
export interface RegisterLocalRepoResult {
|
|
99
|
+
repo: string;
|
|
100
|
+
machine: string;
|
|
101
|
+
org_id: string;
|
|
102
|
+
assignment_id: string | null;
|
|
103
|
+
project_id: string | null;
|
|
104
|
+
project_slug: string | null;
|
|
105
|
+
level: string;
|
|
106
|
+
source: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Is this error the "migration 0318 has not been applied here yet" shape?
|
|
110
|
+
* HALT-before-apply means every environment has a window where this command
|
|
111
|
+
* ships and the RPC does not exist; "run psql" and "something is broken" have
|
|
112
|
+
* different remedies, so the command says which. Mirrors serve-scope's
|
|
113
|
+
* isMigrationPending.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isMigrationPending(err: {
|
|
116
|
+
message?: string;
|
|
117
|
+
code?: string;
|
|
118
|
+
} | null): boolean;
|
|
119
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/local-repo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,sFAAsF;AACtF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAKxE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOzD;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,EAAE,OAAO,CAAC;IACrB,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,GAAG,aAAa,CAuC9E;AAYD,qEAAqE;AACrE,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,OAAO,CAY3F"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOCAL-REPO-CLI — the decidable half of `acc repo add-local`.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is pure: given a path on disk and a few probe results, decide
|
|
5
|
+
* what to register, what to refuse, and what to warn about. The plumbing that
|
|
6
|
+
* needs a keychain, a network and a filesystem lives in ./command.ts, the same
|
|
7
|
+
* split serve-scope uses — so every rule below is unit-testable without either.
|
|
8
|
+
*
|
|
9
|
+
* WHAT A "LOCAL REPO" IS, AND WHAT IT IS NOT
|
|
10
|
+
* ----------------------------------------------------------------------------
|
|
11
|
+
* It is a git working copy on THIS machine that ACC may run tasks in, attached
|
|
12
|
+
* to a project without the GitHub App being installed anywhere. That is the
|
|
13
|
+
* whole of it. In particular it is NOT:
|
|
14
|
+
*
|
|
15
|
+
* * a mirror of a GitHub repo ACC will keep in sync — nothing here clones,
|
|
16
|
+
* fetches or pushes on the server's behalf;
|
|
17
|
+
* * a repo other people on the team can work. The grant the server records is
|
|
18
|
+
* scoped to the registering user, and the path is known only to this
|
|
19
|
+
* machine, so a teammate's runner has neither the right nor the directory;
|
|
20
|
+
* * a way to skip a GitHub write grant on a repo that IS on GitHub. The
|
|
21
|
+
* server derives the slug from the caller's user id into a reserved
|
|
22
|
+
* `local.…` namespace precisely so this cannot be that.
|
|
23
|
+
*
|
|
24
|
+
* WHY THE PATH NEVER LEAVES THE MACHINE
|
|
25
|
+
* ----------------------------------------------------------------------------
|
|
26
|
+
* The server needs to know "machine M serves repo R" to route a task; it does
|
|
27
|
+
* not need to know that R is at /Users/priya/code/side-project. Sending the path
|
|
28
|
+
* would put a filesystem layout — usernames, project names, directory
|
|
29
|
+
* structure — into a shared database for no routing benefit, so the path stays
|
|
30
|
+
* in this machine's own config.json (`local-repos`) and the runner resolves it
|
|
31
|
+
* at task time. See docs/acc/LOCAL_REPO_CLI_SETUP.md.
|
|
32
|
+
*/
|
|
33
|
+
/** The reserved namespace the server mints local slugs into (acc.local_repo_slug). */
|
|
34
|
+
export const LOCAL_REPO_PREFIX = "local.";
|
|
35
|
+
/**
|
|
36
|
+
* Is this slug in the reserved local/CLI namespace? Mirrors
|
|
37
|
+
* acc.is_local_repo_slug (migration 0318) and src/lib/local-repo.ts. A GitHub
|
|
38
|
+
* owner segment can never contain a '.', so the two namespaces cannot collide.
|
|
39
|
+
*/
|
|
40
|
+
export function isLocalRepoSlug(repo) {
|
|
41
|
+
const slug = (repo ?? "").trim().toLowerCase();
|
|
42
|
+
const slash = slug.indexOf("/");
|
|
43
|
+
if (slash <= 0 || slash === slug.length - 1)
|
|
44
|
+
return false;
|
|
45
|
+
return slug.slice(0, slash).startsWith(LOCAL_REPO_PREFIX);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The human-facing name of a local repo — the part after the '/', without the
|
|
49
|
+
* per-user hash fragment that makes the slug unique. `local.9f2c1a/my-app` reads
|
|
50
|
+
* as "my-app (local)" in a list; the full slug is still what gets matched.
|
|
51
|
+
*/
|
|
52
|
+
export function localRepoDisplayName(repo) {
|
|
53
|
+
const slash = repo.lastIndexOf("/");
|
|
54
|
+
return slash >= 0 ? repo.slice(slash + 1) : repo;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Slugify a repo NAME the way acc.local_repo_slug does server-side, so the CLI
|
|
58
|
+
* can predict (and preview) the slug it is about to be handed. Kept in sync
|
|
59
|
+
* deliberately — the server is authoritative and the CLI stores whatever comes
|
|
60
|
+
* back, so a drift here is a cosmetic preview bug, never a wrong write.
|
|
61
|
+
*/
|
|
62
|
+
export function sanitizeLocalRepoName(raw) {
|
|
63
|
+
let name = (raw ?? "").trim().toLowerCase();
|
|
64
|
+
name = name.replace(/[^a-z0-9._-]+/g, "-");
|
|
65
|
+
name = name.replace(/^[-._]+|[-._]+$/g, "");
|
|
66
|
+
name = name.slice(0, 64);
|
|
67
|
+
name = name.replace(/^[-._]+|[-._]+$/g, "");
|
|
68
|
+
return name;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Decide what to register for a probed directory, or throw with the reason it
|
|
72
|
+
* cannot be registered.
|
|
73
|
+
*
|
|
74
|
+
* Refusals are limited to the two facts that make registration meaningless: the
|
|
75
|
+
* path is not a directory, or it is not a git repository (the runner's whole
|
|
76
|
+
* task loop is `git` — branch, commit, diff — so a plain folder would fail at
|
|
77
|
+
* the first step rather than at a legible place).
|
|
78
|
+
*
|
|
79
|
+
* A missing `origin` is NOT a refusal. Running tasks in a local working copy is
|
|
80
|
+
* useful on its own; it is opening a PR at the end that needs a remote, and the
|
|
81
|
+
* warning says exactly that instead of pre-emptively blocking the register.
|
|
82
|
+
*/
|
|
83
|
+
export function planLocalRepoRegistration(probe) {
|
|
84
|
+
if (!probe.isDirectory) {
|
|
85
|
+
throw new Error(`${probe.path} is not a directory — point at a git working copy`);
|
|
86
|
+
}
|
|
87
|
+
if (!probe.isGitRepo) {
|
|
88
|
+
throw new Error(`${probe.path} is not a git repository (no .git) — run \`git init\` there first, ` +
|
|
89
|
+
"or point at the repo root");
|
|
90
|
+
}
|
|
91
|
+
const rawName = probe.nameOverride?.trim() || basename(probe.path);
|
|
92
|
+
const name = sanitizeLocalRepoName(rawName);
|
|
93
|
+
if (!name) {
|
|
94
|
+
throw new Error(`could not derive a repo name from ${probe.path} — pass --name with letters or digits`);
|
|
95
|
+
}
|
|
96
|
+
const warnings = [];
|
|
97
|
+
if (!probe.originUrl) {
|
|
98
|
+
warnings.push("This repo has no `origin` remote. Tasks will run and commit here, but the " +
|
|
99
|
+
"runner cannot push a branch or open a PR — add a remote if you want PRs.");
|
|
100
|
+
}
|
|
101
|
+
warnings.push("The code stays on this machine. Only your own runner can work this repo, " +
|
|
102
|
+
"and only while it is online.");
|
|
103
|
+
return {
|
|
104
|
+
name,
|
|
105
|
+
path: probe.path,
|
|
106
|
+
// A preview, not a claim: the server mints the authoritative slug from the
|
|
107
|
+
// caller's user id, which this side deliberately does not know.
|
|
108
|
+
previewSlug: `${LOCAL_REPO_PREFIX}<you>/${name}`,
|
|
109
|
+
warnings,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Last path segment, tolerating a trailing separator (`~/code/my-app/` must
|
|
114
|
+
* yield "my-app", not ""). Local rather than node:path so this module stays
|
|
115
|
+
* dependency-free and testable as pure text.
|
|
116
|
+
*/
|
|
117
|
+
function basename(p) {
|
|
118
|
+
const parts = p.replace(/[\\/]+$/, "").split(/[\\/]/);
|
|
119
|
+
return parts[parts.length - 1] ?? "";
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Is this error the "migration 0318 has not been applied here yet" shape?
|
|
123
|
+
* HALT-before-apply means every environment has a window where this command
|
|
124
|
+
* ships and the RPC does not exist; "run psql" and "something is broken" have
|
|
125
|
+
* different remedies, so the command says which. Mirrors serve-scope's
|
|
126
|
+
* isMigrationPending.
|
|
127
|
+
*/
|
|
128
|
+
export function isMigrationPending(err) {
|
|
129
|
+
if (!err)
|
|
130
|
+
return false;
|
|
131
|
+
// PostgREST: 404 + PGRST202 for an unknown RPC; Postgres 42883 for an
|
|
132
|
+
// undefined function reached another way.
|
|
133
|
+
if (err.code === "PGRST202" || err.code === "42883")
|
|
134
|
+
return true;
|
|
135
|
+
const msg = (err.message ?? "").toLowerCase();
|
|
136
|
+
return (msg.includes("register_local_repo") &&
|
|
137
|
+
(msg.includes("does not exist") ||
|
|
138
|
+
msg.includes("not find") ||
|
|
139
|
+
msg.includes("schema cache")));
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/local-repo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAA+B;IAC7D,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,KAAK,I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AG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAO,CACL,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC;QACnC,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YAC7B,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC;YACxB,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAChC,CAAC;AACJ,CAAC"}
|
package/dist/login.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ export declare function runnerCapsWithRepos(repos: readonly string[] | undefined
|
|
|
40
40
|
reserved_review_slots: number;
|
|
41
41
|
concurrency_source: ConcurrencySource;
|
|
42
42
|
};
|
|
43
|
+
/** The `machine` string the server dedups identity on. NAMED-INSTANCES-1
|
|
44
|
+
* appends `#<name>` so each instance resolves its own stable runner id;
|
|
45
|
+
* unnamed = the v0.44.0 string byte-for-byte. Every caller shares this fn so
|
|
46
|
+
* the suffix can never reach some payloads and not others. */
|
|
43
47
|
export declare function machineIdentity(): string;
|
|
44
48
|
export declare function detectInstalledModels(): Promise<string[]>;
|
|
45
49
|
/**
|
package/dist/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAGV,UAAU,EACX,MAAM,YAAY,CAAC;AAOpB,eAAO,MAAM,WAAW,EAAE,UAczB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CACjC,K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AAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACjD;AAED,wBAAsB,YAAY,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0H5E"}
|
package/dist/login.js
CHANGED
|
@@ -13,6 +13,7 @@ import { execa } from "execa";
|
|
|
13
13
|
import open from "open";
|
|
14
14
|
import { applyBootstrapConfig, concurrencyEnvExplicit, loadConfig, resolveRunnerConcurrency, } from "./config.js";
|
|
15
15
|
import { detectCapableEngines } from "./doctor.js";
|
|
16
|
+
import { instanceMachineSuffix } from "./instance.js";
|
|
16
17
|
import { saveSession } from "./keychain.js";
|
|
17
18
|
import { createRunnerClient } from "./supabase.js";
|
|
18
19
|
import { PROTOCOL_VERSION } from "./types.js";
|
|
@@ -82,8 +83,12 @@ source = concurrencyEnvExplicit() ? "env" : "default") {
|
|
|
82
83
|
concurrency_source: source,
|
|
83
84
|
};
|
|
84
85
|
}
|
|
86
|
+
/** The `machine` string the server dedups identity on. NAMED-INSTANCES-1
|
|
87
|
+
* appends `#<name>` so each instance resolves its own stable runner id;
|
|
88
|
+
* unnamed = the v0.44.0 string byte-for-byte. Every caller shares this fn so
|
|
89
|
+
* the suffix can never reach some payloads and not others. */
|
|
85
90
|
export function machineIdentity() {
|
|
86
|
-
return `${process.platform}-${process.arch}-${os.hostname()}`;
|
|
91
|
+
return `${process.platform}-${process.arch}-${os.hostname()}${instanceMachineSuffix()}`;
|
|
87
92
|
}
|
|
88
93
|
// v0.12.0 (T-52-7): exported for the same reason as RUNNER_CAPS above.
|
|
89
94
|
export async function detectInstalledModels() {
|
package/dist/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,SAAS,CA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AAqB,EAAE,CAAC;IAC7C,oEAAoE;IACpE,uEAAuE;IACvE,2DAA2D;IAC3D,MAAM,OAAO,GAAG,MAAM,oBAAoB,EAAE,CAAC;IAC7C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,iBAAiB,EAAE;QACtD,IAAI,EAAE,SAAS,CAAC,SAAS;QACzB,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,OAAO,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE;QACpE,OAAO,EAAE,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,OAAO;QAC7C,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,MAAM;QAChB,iEAAiE;QACjE,iEAAiE;QACjE,kEAAkE;QAClE,+DAA+D;QAC/D,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC;QAC/C,SAAS,EAAE,eAAe;KAC3B,CAAC,CAAC;IACH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,wBAAwB,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,CAAC;AACjF,CAAC"}
|
package/dist/mcp-spawn.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare const ACC_MCP_KEY = "acc";
|
|
2
|
+
/** Env var acc-mcp-server reads the per-turn delegation JWT from (see cli.ts). */
|
|
3
|
+
export declare const ACC_MCP_DELEGATION_TOKEN_ENV = "ACC_MCP_DELEGATION_TOKEN";
|
|
4
|
+
/** Env var acc-mcp-server (future-facing) reads the calling agent's id from. */
|
|
5
|
+
export declare const ACC_AGENT_ID_ENV = "ACC_AGENT_ID";
|
|
2
6
|
export interface McpSpawnOptions {
|
|
3
7
|
cwd: string;
|
|
4
8
|
taskId: string;
|
|
@@ -7,6 +11,21 @@ export interface McpSpawnOptions {
|
|
|
7
11
|
publicUrl: string;
|
|
8
12
|
supabaseUrl: string;
|
|
9
13
|
supabaseAnonKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional per-turn delegation JWT (FU-5), narrower than `accessToken`.
|
|
16
|
+
* Env-only — never written to argv. Blank/whitespace-only is treated as
|
|
17
|
+
* absent.
|
|
18
|
+
*/
|
|
19
|
+
delegationToken?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional id of the agent this session is acting for, used for
|
|
22
|
+
* attribution of mutating tool calls. Forwarded via env
|
|
23
|
+
* (`ACC_AGENT_ID`) AND `--agent-id` argv (acc-mcp-server's current CLI
|
|
24
|
+
* only reads argv for this one; the env copy is forward-compatible, per
|
|
25
|
+
* the same pattern already used for `ACC_TASK_ID`/`ACC_RUNNER_ID`).
|
|
26
|
+
* Blank/whitespace-only is treated as absent.
|
|
27
|
+
*/
|
|
28
|
+
agentId?: string;
|
|
10
29
|
}
|
|
11
30
|
export interface McpConfigCleanup {
|
|
12
31
|
/** Restore .mcp.json to its pre-spawn state (or delete if we created it). */
|
package/dist/mcp-spawn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-spawn.d.ts","sourceRoot":"","sources":["../src/mcp-spawn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-spawn.d.ts","sourceRoot":"","sources":["../src/mcp-spawn.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,WAAW,QAAQ,CAAC;AAKjC,kFAAkF;AAClF,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AACvE,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAMD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUtE;AAmFD,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAClD;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,eAAe,EACrB,IAAI,GAAE,kBAAuB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CA4B3B"}
|