@tokenfactory/acc-runner 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -4
- package/package.json +1 -1
- package/dist/anthropic-auth.d.ts +0 -53
- package/dist/anthropic-auth.d.ts.map +0 -1
- package/dist/anthropic-auth.js +0 -89
- package/dist/anthropic-auth.js.map +0 -1
- package/dist/bin-resolve.d.ts +0 -16
- package/dist/bin-resolve.d.ts.map +0 -1
- package/dist/bin-resolve.js +0 -35
- package/dist/bin-resolve.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -128
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts +0 -121
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -396
- package/dist/config.js.map +0 -1
- package/dist/cost-pricing.d.ts +0 -130
- package/dist/cost-pricing.d.ts.map +0 -1
- package/dist/cost-pricing.js +0 -191
- package/dist/cost-pricing.js.map +0 -1
- package/dist/doctor.d.ts +0 -37
- package/dist/doctor.d.ts.map +0 -1
- package/dist/doctor.js +0 -658
- package/dist/doctor.js.map +0 -1
- package/dist/failure-classifier.d.ts +0 -112
- package/dist/failure-classifier.d.ts.map +0 -1
- package/dist/failure-classifier.js +0 -353
- package/dist/failure-classifier.js.map +0 -1
- package/dist/gh.d.ts +0 -22
- package/dist/gh.d.ts.map +0 -1
- package/dist/gh.js +0 -48
- package/dist/gh.js.map +0 -1
- package/dist/git.d.ts +0 -50
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js +0 -127
- package/dist/git.js.map +0 -1
- package/dist/github-client.d.ts +0 -133
- package/dist/github-client.d.ts.map +0 -1
- package/dist/github-client.js +0 -234
- package/dist/github-client.js.map +0 -1
- package/dist/keychain.d.ts +0 -21
- package/dist/keychain.d.ts.map +0 -1
- package/dist/keychain.js +0 -45
- package/dist/keychain.js.map +0 -1
- package/dist/login.d.ts +0 -12
- package/dist/login.d.ts.map +0 -1
- package/dist/login.js +0 -133
- package/dist/login.js.map +0 -1
- package/dist/logout.d.ts +0 -2
- package/dist/logout.d.ts.map +0 -1
- package/dist/logout.js +0 -31
- package/dist/logout.js.map +0 -1
- package/dist/mcp-spawn.d.ts +0 -30
- package/dist/mcp-spawn.d.ts.map +0 -1
- package/dist/mcp-spawn.js +0 -145
- package/dist/mcp-spawn.js.map +0 -1
- package/dist/messaging.d.ts +0 -49
- package/dist/messaging.d.ts.map +0 -1
- package/dist/messaging.js +0 -36
- package/dist/messaging.js.map +0 -1
- package/dist/pkg-version.d.ts +0 -3
- package/dist/pkg-version.d.ts.map +0 -1
- package/dist/pkg-version.js +0 -20
- package/dist/pkg-version.js.map +0 -1
- package/dist/profiles/designer-prompt.d.ts +0 -18
- package/dist/profiles/designer-prompt.d.ts.map +0 -1
- package/dist/profiles/designer-prompt.js +0 -172
- package/dist/profiles/designer-prompt.js.map +0 -1
- package/dist/profiles/developer-prompt.d.ts +0 -24
- package/dist/profiles/developer-prompt.d.ts.map +0 -1
- package/dist/profiles/developer-prompt.js +0 -24
- package/dist/profiles/developer-prompt.js.map +0 -1
- package/dist/profiles/manager-prompt.d.ts +0 -34
- package/dist/profiles/manager-prompt.d.ts.map +0 -1
- package/dist/profiles/manager-prompt.js +0 -93
- package/dist/profiles/manager-prompt.js.map +0 -1
- package/dist/profiles/tester-prompt.d.ts +0 -28
- package/dist/profiles/tester-prompt.d.ts.map +0 -1
- package/dist/profiles/tester-prompt.js +0 -165
- package/dist/profiles/tester-prompt.js.map +0 -1
- package/dist/prompt.d.ts +0 -38
- package/dist/prompt.d.ts.map +0 -1
- package/dist/prompt.js +0 -78
- package/dist/prompt.js.map +0 -1
- package/dist/runtime/cache-dir.d.ts +0 -2
- package/dist/runtime/cache-dir.d.ts.map +0 -1
- package/dist/runtime/cache-dir.js +0 -15
- package/dist/runtime/cache-dir.js.map +0 -1
- package/dist/runtime/conflict-resolver.d.ts +0 -65
- package/dist/runtime/conflict-resolver.d.ts.map +0 -1
- package/dist/runtime/conflict-resolver.js +0 -477
- package/dist/runtime/conflict-resolver.js.map +0 -1
- package/dist/runtime/expand-args.d.ts +0 -28
- package/dist/runtime/expand-args.d.ts.map +0 -1
- package/dist/runtime/expand-args.js +0 -50
- package/dist/runtime/expand-args.js.map +0 -1
- package/dist/runtime/locks.d.ts +0 -21
- package/dist/runtime/locks.d.ts.map +0 -1
- package/dist/runtime/locks.js +0 -97
- package/dist/runtime/locks.js.map +0 -1
- package/dist/runtime/provision-mutex.d.ts +0 -37
- package/dist/runtime/provision-mutex.d.ts.map +0 -1
- package/dist/runtime/provision-mutex.js +0 -67
- package/dist/runtime/provision-mutex.js.map +0 -1
- package/dist/runtime/quarantine.d.ts +0 -26
- package/dist/runtime/quarantine.d.ts.map +0 -1
- package/dist/runtime/quarantine.js +0 -50
- package/dist/runtime/quarantine.js.map +0 -1
- package/dist/runtime/resolution-integrity.d.ts +0 -86
- package/dist/runtime/resolution-integrity.d.ts.map +0 -1
- package/dist/runtime/resolution-integrity.js +0 -248
- package/dist/runtime/resolution-integrity.js.map +0 -1
- package/dist/runtime/reviewer.d.ts +0 -81
- package/dist/runtime/reviewer.d.ts.map +0 -1
- package/dist/runtime/reviewer.js +0 -374
- package/dist/runtime/reviewer.js.map +0 -1
- package/dist/runtime/rework.d.ts +0 -48
- package/dist/runtime/rework.d.ts.map +0 -1
- package/dist/runtime/rework.js +0 -136
- package/dist/runtime/rework.js.map +0 -1
- package/dist/runtime/singleton.d.ts +0 -47
- package/dist/runtime/singleton.d.ts.map +0 -1
- package/dist/runtime/singleton.js +0 -200
- package/dist/runtime/singleton.js.map +0 -1
- package/dist/runtime/version-drift.d.ts +0 -31
- package/dist/runtime/version-drift.d.ts.map +0 -1
- package/dist/runtime/version-drift.js +0 -114
- package/dist/runtime/version-drift.js.map +0 -1
- package/dist/runtime/worktree.d.ts +0 -74
- package/dist/runtime/worktree.d.ts.map +0 -1
- package/dist/runtime/worktree.js +0 -206
- package/dist/runtime/worktree.js.map +0 -1
- package/dist/secrets/inject.d.ts +0 -70
- package/dist/secrets/inject.d.ts.map +0 -1
- package/dist/secrets/inject.js +0 -102
- package/dist/secrets/inject.js.map +0 -1
- package/dist/supabase.d.ts +0 -4
- package/dist/supabase.d.ts.map +0 -1
- package/dist/supabase.js +0 -36
- package/dist/supabase.js.map +0 -1
- package/dist/task-runner.d.ts +0 -313
- package/dist/task-runner.d.ts.map +0 -1
- package/dist/task-runner.js +0 -1766
- package/dist/task-runner.js.map +0 -1
- package/dist/token-provider.d.ts +0 -50
- package/dist/token-provider.d.ts.map +0 -1
- package/dist/token-provider.js +0 -177
- package/dist/token-provider.js.map +0 -1
- package/dist/types.d.ts +0 -120
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -16
- package/dist/types.js.map +0 -1
- package/dist/version-check.d.ts +0 -17
- package/dist/version-check.d.ts.map +0 -1
- package/dist/version-check.js +0 -56
- package/dist/version-check.js.map +0 -1
- package/dist/watch.d.ts +0 -295
- package/dist/watch.d.ts.map +0 -1
- package/dist/watch.js +0 -1532
- package/dist/watch.js.map +0 -1
package/dist/config.js
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolved runtime config for the CLI. Production endpoints are hardcoded
|
|
3
|
-
* as defaults so the CLI works out of the box after `npm i -g`. Env vars
|
|
4
|
-
* still override when set, for pointing the runner at a preview deploy
|
|
5
|
-
* or a local Supabase.
|
|
6
|
-
*
|
|
7
|
-
* All vars are optional. Defaults below.
|
|
8
|
-
*
|
|
9
|
-
* ACC_PUBLIC_URL — production Vercel URL
|
|
10
|
-
* ACC_SUPABASE_URL — production Supabase project URL
|
|
11
|
-
* ACC_SUPABASE_ANON_KEY — production anon key. Safe to ship in the
|
|
12
|
-
* CLI: it's the public anon key; RLS does
|
|
13
|
-
* the gating.
|
|
14
|
-
* ACC_REPO_PATH — local clone fallback (~/work/TechArch).
|
|
15
|
-
* v0.6.0+ this is the LAST resort: task.
|
|
16
|
-
* repo_path_hint on the fetched task row
|
|
17
|
-
* takes precedence so a single runner can
|
|
18
|
-
* span repos. REG-295. v0.38-B: falls back
|
|
19
|
-
* to the `repo-path` field in
|
|
20
|
-
* ~/.config/acc-runner/config.json before
|
|
21
|
-
* defaulting to ~/work/TechArch, so an
|
|
22
|
-
* operator can pin a clone location without
|
|
23
|
-
* a launchd env override.
|
|
24
|
-
* ACC_TARGET_REPO — slug fallback, tokenfactory-pvt-ltd/TechArch.
|
|
25
|
-
* v0.6.0+ task.repo wins when present.
|
|
26
|
-
* REG-295.
|
|
27
|
-
* ACC_INTEGRATION_BRANCH — base branch for new PRs, acc/integration.
|
|
28
|
-
* v0.6.0+ task.integration_branch wins when
|
|
29
|
-
* present so a hotfix task can target a
|
|
30
|
-
* release branch without env churn. REG-301.
|
|
31
|
-
* ACC_RUNNER_CAPABILITIES — v0.6.4+ comma-separated capability tags
|
|
32
|
-
* ("code,docs"). Falls back to capabilities
|
|
33
|
-
* field in ~/.config/acc-runner/config.json,
|
|
34
|
-
* then to the active profile's capabilities
|
|
35
|
-
* (v0.14-DEVELOPER-AGENT), then to empty
|
|
36
|
-
* (matches any task with empty
|
|
37
|
-
* required_capabilities — backward compat).
|
|
38
|
-
* Vocabulary mirrored from
|
|
39
|
-
* api/_lib/capabilities.ts (see
|
|
40
|
-
* CAPABILITY_VOCABULARY below). Sent to the
|
|
41
|
-
* server on register_runner so the
|
|
42
|
-
* task-router picks this runner only for
|
|
43
|
-
* tasks it can do.
|
|
44
|
-
* ACC_RUNNER_PROFILE — v0.14+ name of a runner profile in
|
|
45
|
-
* packages/acc-runner/runner-profiles/<name>.json.
|
|
46
|
-
* Sets capability + model defaults that env
|
|
47
|
-
* / config.json can still override. Unset =
|
|
48
|
-
* v0.13 byte-identical behavior. Vocabulary
|
|
49
|
-
* of supported names lives next to the JSON
|
|
50
|
-
* files on disk; misspellings fail at CLI
|
|
51
|
-
* startup, not at task pickup.
|
|
52
|
-
*/
|
|
53
|
-
import fs from "node:fs";
|
|
54
|
-
import os from "node:os";
|
|
55
|
-
import path from "node:path";
|
|
56
|
-
import { fileURLToPath } from "node:url";
|
|
57
|
-
// DEFAULT_ACC_PUBLIC_URL points to the working Vercel deployment (custom domain DNS is unresolved as of v0.42).
|
|
58
|
-
const DEFAULT_ACC_PUBLIC_URL = "https://agent-control-center-sepia.vercel.app";
|
|
59
|
-
const DEFAULT_ACC_SUPABASE_URL = "https://qfevnwuybyygexkcbdfy.supabase.co";
|
|
60
|
-
const DEFAULT_ACC_SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFmZXZud3V5Ynl5Z2V4a2NiZGZ5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzY0OTU1NjQsImV4cCI6MjA5MjA3MTU2NH0.zRQ4K5H4cfcribPdxyahgarhX-7TCgH38bhdZanYlGA";
|
|
61
|
-
const DEFAULT_ACC_TARGET_REPO = "tokenfactory-pvt-ltd/TechArch";
|
|
62
|
-
const DEFAULT_ACC_INTEGRATION_BRANCH = "acc/integration";
|
|
63
|
-
function envOrDefault(name, fallback) {
|
|
64
|
-
return process.env[name]?.trim() || fallback;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Canonical capability vocabulary, mirrored from
|
|
68
|
-
* `api/_lib/capabilities.ts` and the CHECK constraint enforced by
|
|
69
|
-
* migration 0115 (v0.14-CAPABILITY-VOCAB). Duplicated here because the
|
|
70
|
-
* runner package's tsconfig pins rootDir to `./src/`, so reaching into
|
|
71
|
-
* `api/_lib/` is out of bounds for a published artifact. The
|
|
72
|
-
* integration test `tests/integration/v0.14-DEVELOPER-AGENT.test.ts`
|
|
73
|
-
* asserts this list and the api/_lib version stay in lockstep; the
|
|
74
|
-
* "adding a new capability" recipe in
|
|
75
|
-
* docs/acc/CAPABILITY_VOCABULARY.md covers all three sites (SQL, api/,
|
|
76
|
-
* runner/).
|
|
77
|
-
*/
|
|
78
|
-
export const RUNNER_CAPABILITY_VOCABULARY = [
|
|
79
|
-
"code",
|
|
80
|
-
"design",
|
|
81
|
-
"test",
|
|
82
|
-
"docs",
|
|
83
|
-
"migration",
|
|
84
|
-
"review",
|
|
85
|
-
"orchestration",
|
|
86
|
-
];
|
|
87
|
-
function isRunnerCapability(s) {
|
|
88
|
-
return RUNNER_CAPABILITY_VOCABULARY.includes(s);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Throws if any element of `arr` is outside the canonical vocabulary.
|
|
92
|
-
* Mirrors `assertCapabilityArray` from api/_lib/capabilities.ts. The
|
|
93
|
-
* runner uses this on profile load — misspellings ("desgn") fail at
|
|
94
|
-
* CLI startup, not after a task assignment fires.
|
|
95
|
-
*/
|
|
96
|
-
export function assertRunnerCapabilityArray(arr, context) {
|
|
97
|
-
for (const c of arr) {
|
|
98
|
-
if (!isRunnerCapability(c)) {
|
|
99
|
-
throw new Error(`invalid capability ${JSON.stringify(c)} in ${context}; expected one of ${RUNNER_CAPABILITY_VOCABULARY.join(", ")}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Trim, drop empties, dedupe. The env / config.json paths still pass
|
|
105
|
-
* unknown tags through verbatim — the server accepts the array as-is
|
|
106
|
-
* and a v0.13 runner with `ACC_RUNNER_CAPABILITIES=experimental` keeps
|
|
107
|
-
* working. The profile path tightens further (assertRunnerCapabilityArray
|
|
108
|
-
* above) since profile JSONs are static text under the runner package.
|
|
109
|
-
*/
|
|
110
|
-
function normalizeCapabilities(raw) {
|
|
111
|
-
const seen = new Set();
|
|
112
|
-
const out = [];
|
|
113
|
-
for (const item of raw) {
|
|
114
|
-
const trimmed = item.trim();
|
|
115
|
-
if (!trimmed)
|
|
116
|
-
continue;
|
|
117
|
-
if (seen.has(trimmed))
|
|
118
|
-
continue;
|
|
119
|
-
seen.add(trimmed);
|
|
120
|
-
out.push(trimmed);
|
|
121
|
-
}
|
|
122
|
-
return out;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Read the `repo-path` field from ~/.config/acc-runner/config.json (or
|
|
126
|
-
* $XDG_CONFIG_HOME/acc-runner/config.json). Returns null when the file
|
|
127
|
-
* is missing, malformed, or the field is absent / not a non-empty
|
|
128
|
-
* string. Used as the middle layer of repoPath resolution between
|
|
129
|
-
* ACC_REPO_PATH and the ~/work/TechArch default.
|
|
130
|
-
*/
|
|
131
|
-
function loadRepoPathFromConfigFile() {
|
|
132
|
-
const parsed = readUserConfigFile();
|
|
133
|
-
const value = parsed?.["repo-path"];
|
|
134
|
-
if (typeof value === "string" && value.trim())
|
|
135
|
-
return value.trim();
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* v0.41-B: read the `worktree-repo-path` field from
|
|
140
|
-
* ~/.config/acc-runner/config.json. Returns null when the file is
|
|
141
|
-
* missing, malformed, or the field is absent / not a non-empty string.
|
|
142
|
-
* Used as the middle layer of worktreeRepoPath resolution between
|
|
143
|
-
* ACC_WORKTREE_REPO_PATH and the undefined fallback (which delegates
|
|
144
|
-
* to repoPath inside prepareTaskWorktree).
|
|
145
|
-
*/
|
|
146
|
-
function loadWorktreeRepoPathFromConfigFile() {
|
|
147
|
-
const parsed = readUserConfigFile();
|
|
148
|
-
const value = parsed?.["worktree-repo-path"];
|
|
149
|
-
if (typeof value === "string" && value.trim())
|
|
150
|
-
return value.trim();
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
function readUserConfigFile() {
|
|
154
|
-
const base = process.env.XDG_CONFIG_HOME?.trim() ||
|
|
155
|
-
path.resolve(os.homedir(), ".config");
|
|
156
|
-
const file = path.resolve(base, "acc-runner", "config.json");
|
|
157
|
-
try {
|
|
158
|
-
const raw = fs.readFileSync(file, "utf8");
|
|
159
|
-
return JSON.parse(raw);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* v0.8.2: Scan a list of absolute candidate paths and return the first
|
|
167
|
-
* that exists on disk. Returns null when none exist so loadConfig() can
|
|
168
|
-
* fall through to the ~/work/TechArch last-resort default.
|
|
169
|
-
*
|
|
170
|
-
* Used when neither ACC_REPO_PATH nor config.json supply a path so a
|
|
171
|
-
* freshly-installed runner finds the repo automatically when the operator
|
|
172
|
-
* cloned it to ~/code/ instead of ~/work/. Candidates are checked in
|
|
173
|
-
* order; the first hit wins.
|
|
174
|
-
*/
|
|
175
|
-
export function detectRepoPath(candidates) {
|
|
176
|
-
for (const candidate of candidates) {
|
|
177
|
-
try {
|
|
178
|
-
if (fs.existsSync(candidate))
|
|
179
|
-
return candidate;
|
|
180
|
-
}
|
|
181
|
-
catch {
|
|
182
|
-
// EPERM or similar — skip this candidate
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Read ~/.config/acc-runner/config.json (or $XDG_CONFIG_HOME/acc-runner/
|
|
189
|
-
* config.json) and pull out the capabilities field. Missing file or
|
|
190
|
-
* malformed JSON returns []. This is best-effort, never throws: a
|
|
191
|
-
* runner that can't read its config file should still register with
|
|
192
|
-
* the default-empty capabilities rather than crash at startup.
|
|
193
|
-
*/
|
|
194
|
-
export function loadCapabilitiesFromConfigFile() {
|
|
195
|
-
const parsed = readUserConfigFile();
|
|
196
|
-
const caps = parsed?.capabilities;
|
|
197
|
-
if (Array.isArray(caps)) {
|
|
198
|
-
return normalizeCapabilities(caps.filter((c) => typeof c === "string"));
|
|
199
|
-
}
|
|
200
|
-
return [];
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Locate the runner-profiles directory. config.ts ships compiled to
|
|
204
|
-
* `dist/config.js`, so the published-package layout is
|
|
205
|
-
* `dist/config.js` + `runner-profiles/<name>.json` as siblings of
|
|
206
|
-
* `dist/` and `src/`. The relative `..` works from either rootDir.
|
|
207
|
-
*
|
|
208
|
-
* Tests can override the search root via `ACC_RUNNER_PROFILES_DIR`.
|
|
209
|
-
*/
|
|
210
|
-
function profilesDir() {
|
|
211
|
-
const override = process.env.ACC_RUNNER_PROFILES_DIR?.trim();
|
|
212
|
-
if (override)
|
|
213
|
-
return override;
|
|
214
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
215
|
-
return path.resolve(here, "..", "runner-profiles");
|
|
216
|
-
}
|
|
217
|
-
function isStringArray(value) {
|
|
218
|
-
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
219
|
-
}
|
|
220
|
-
function parseProfile(name, file, raw) {
|
|
221
|
-
let parsed;
|
|
222
|
-
try {
|
|
223
|
-
parsed = JSON.parse(raw);
|
|
224
|
-
}
|
|
225
|
-
catch (err) {
|
|
226
|
-
throw new Error(`runner profile ${file}: invalid JSON — ${err.message}`);
|
|
227
|
-
}
|
|
228
|
-
if (typeof parsed.name !== "string" || parsed.name !== name) {
|
|
229
|
-
throw new Error(`runner profile ${file}: 'name' field must equal '${name}' (got ${JSON.stringify(parsed.name)})`);
|
|
230
|
-
}
|
|
231
|
-
if (!isStringArray(parsed.capabilities)) {
|
|
232
|
-
throw new Error(`runner profile ${file}: 'capabilities' must be an array of strings`);
|
|
233
|
-
}
|
|
234
|
-
assertRunnerCapabilityArray(parsed.capabilities, `runner profile ${file}`);
|
|
235
|
-
const profile = {
|
|
236
|
-
name: parsed.name,
|
|
237
|
-
capabilities: [...parsed.capabilities],
|
|
238
|
-
};
|
|
239
|
-
if (parsed.model_defaults && typeof parsed.model_defaults === "object") {
|
|
240
|
-
const md = parsed.model_defaults;
|
|
241
|
-
profile.modelDefaults = {};
|
|
242
|
-
if (typeof md.primary === "string")
|
|
243
|
-
profile.modelDefaults.primary = md.primary;
|
|
244
|
-
if (typeof md.fallback === "string")
|
|
245
|
-
profile.modelDefaults.fallback = md.fallback;
|
|
246
|
-
}
|
|
247
|
-
if (typeof parsed.prompt_prelude === "string") {
|
|
248
|
-
profile.promptPrelude = parsed.prompt_prelude;
|
|
249
|
-
}
|
|
250
|
-
return profile;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Resolve the active profile name, lowest-to-highest precedence:
|
|
254
|
-
* 1. (profile defaults — N/A here, profile is the layer we're picking)
|
|
255
|
-
* 2. env: ACC_RUNNER_PROFILE
|
|
256
|
-
* 3. config.json: "runner-profile"
|
|
257
|
-
* 4. CLI flags (deferred — a follow-up track adds `--runner-profile`)
|
|
258
|
-
* Returns null when no source supplied a name, which is the v0.13
|
|
259
|
-
* default path and triggers byte-identical behavior throughout.
|
|
260
|
-
*/
|
|
261
|
-
function resolveProfileName() {
|
|
262
|
-
const fromEnv = process.env.ACC_RUNNER_PROFILE?.trim();
|
|
263
|
-
if (fromEnv)
|
|
264
|
-
return fromEnv;
|
|
265
|
-
const fromFile = readUserConfigFile()?.["runner-profile"];
|
|
266
|
-
if (typeof fromFile === "string" && fromFile.trim())
|
|
267
|
-
return fromFile.trim();
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Load the active runner profile, if any. Returns null when no profile
|
|
272
|
-
* is selected (the v0.13 path). Throws on malformed / unknown profile
|
|
273
|
-
* names so the operator sees the misconfiguration at CLI startup
|
|
274
|
-
* rather than at task-pickup time.
|
|
275
|
-
*/
|
|
276
|
-
export function loadProfile() {
|
|
277
|
-
const name = resolveProfileName();
|
|
278
|
-
if (!name)
|
|
279
|
-
return null;
|
|
280
|
-
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
281
|
-
throw new Error(`runner profile name ${JSON.stringify(name)} is not a valid slug ([a-z][a-z0-9-]*)`);
|
|
282
|
-
}
|
|
283
|
-
const file = path.resolve(profilesDir(), `${name}.json`);
|
|
284
|
-
let raw;
|
|
285
|
-
try {
|
|
286
|
-
raw = fs.readFileSync(file, "utf8");
|
|
287
|
-
}
|
|
288
|
-
catch (err) {
|
|
289
|
-
throw new Error(`runner profile '${name}' not found at ${file}: ${err.message}`);
|
|
290
|
-
}
|
|
291
|
-
return parseProfile(name, file, raw);
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Precedence (lowest → highest): profile defaults < env var
|
|
295
|
-
* (ACC_RUNNER_CAPABILITIES) < ~/.config/acc-runner/config.json
|
|
296
|
-
* `capabilities` field < CLI flags. CLI flags for capabilities are not
|
|
297
|
-
* implemented today (no consumer in cli.ts); ACC_RUNNER_CAPABILITIES is
|
|
298
|
-
* the de-facto top of the stack until a future track adds the flag.
|
|
299
|
-
*
|
|
300
|
-
* v0.13 path (no profile selected): env > config.json > []. Adding a
|
|
301
|
-
* profile only extends the floor — explicit env / config.json values
|
|
302
|
-
* still win, so an operator can spawn a developer-profile runner with
|
|
303
|
-
* `ACC_RUNNER_CAPABILITIES=docs` and override the profile's defaults.
|
|
304
|
-
*/
|
|
305
|
-
function loadCapabilities(profile) {
|
|
306
|
-
const fromEnv = process.env.ACC_RUNNER_CAPABILITIES?.trim();
|
|
307
|
-
if (fromEnv) {
|
|
308
|
-
return normalizeCapabilities(fromEnv.split(","));
|
|
309
|
-
}
|
|
310
|
-
const fromFile = loadCapabilitiesFromConfigFile();
|
|
311
|
-
if (fromFile.length > 0) {
|
|
312
|
-
return fromFile;
|
|
313
|
-
}
|
|
314
|
-
if (profile) {
|
|
315
|
-
return [...profile.capabilities];
|
|
316
|
-
}
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
export function loadConfig() {
|
|
320
|
-
// v0.8.2: resolution order (highest → lowest precedence):
|
|
321
|
-
// 1. ACC_REPO_PATH env var
|
|
322
|
-
// 2. ~/.config/acc-runner/config.json "repo-path" field
|
|
323
|
-
// 3. First existing path in the common-clone-locations scan
|
|
324
|
-
// 4. ~/work/TechArch (original hardcoded default, kept as last resort)
|
|
325
|
-
const repoPath = process.env.ACC_REPO_PATH?.trim() ||
|
|
326
|
-
loadRepoPathFromConfigFile() ||
|
|
327
|
-
detectRepoPath([
|
|
328
|
-
path.resolve(os.homedir(), "code", "ACC-Tech"),
|
|
329
|
-
path.resolve(os.homedir(), "code", "TechArch"),
|
|
330
|
-
path.resolve(os.homedir(), "src", "TechArch"),
|
|
331
|
-
]) ||
|
|
332
|
-
path.resolve(os.homedir(), "work", "TechArch");
|
|
333
|
-
// v0.41-B: separate mirror clone for `git worktree` operations.
|
|
334
|
-
// Undefined when neither env nor config.json supplies one, in
|
|
335
|
-
// which case prepareTaskWorktree transparently falls back to
|
|
336
|
-
// repoPath — preserving v0.40-and-earlier behaviour byte-for-byte.
|
|
337
|
-
const worktreeRepoPath = process.env.ACC_WORKTREE_REPO_PATH?.trim() ||
|
|
338
|
-
loadWorktreeRepoPathFromConfigFile() ||
|
|
339
|
-
undefined;
|
|
340
|
-
// Profile loads first because capabilities() consults it as the
|
|
341
|
-
// lowest-precedence default. Loader throws on malformed profile
|
|
342
|
-
// JSON or unknown capability tags, surfacing operator typos at
|
|
343
|
-
// CLI startup rather than at task-pickup time.
|
|
344
|
-
const profile = loadProfile();
|
|
345
|
-
return {
|
|
346
|
-
publicUrl: envOrDefault("ACC_PUBLIC_URL", DEFAULT_ACC_PUBLIC_URL),
|
|
347
|
-
supabaseUrl: envOrDefault("ACC_SUPABASE_URL", DEFAULT_ACC_SUPABASE_URL),
|
|
348
|
-
supabaseAnonKey: envOrDefault("ACC_SUPABASE_ANON_KEY", DEFAULT_ACC_SUPABASE_ANON_KEY),
|
|
349
|
-
repoPath,
|
|
350
|
-
targetRepo: envOrDefault("ACC_TARGET_REPO", DEFAULT_ACC_TARGET_REPO),
|
|
351
|
-
integrationBranch: envOrDefault("ACC_INTEGRATION_BRANCH", DEFAULT_ACC_INTEGRATION_BRANCH),
|
|
352
|
-
capabilities: loadCapabilities(profile),
|
|
353
|
-
worktreeRepoPath,
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Source of each resolved config value. Used by `doctor` to annotate
|
|
358
|
-
* the resolved config with "(env)" / "(default)" labels.
|
|
359
|
-
*/
|
|
360
|
-
export function configSources() {
|
|
361
|
-
const src = (name) => process.env[name]?.trim() ? "env" : "default";
|
|
362
|
-
const repoPathSrc = process.env.ACC_REPO_PATH?.trim()
|
|
363
|
-
? "env"
|
|
364
|
-
: loadRepoPathFromConfigFile()
|
|
365
|
-
? "file"
|
|
366
|
-
: "default";
|
|
367
|
-
const worktreeRepoPathSrc = process.env.ACC_WORKTREE_REPO_PATH?.trim()
|
|
368
|
-
? "env"
|
|
369
|
-
: loadWorktreeRepoPathFromConfigFile()
|
|
370
|
-
? "file"
|
|
371
|
-
: "default";
|
|
372
|
-
return {
|
|
373
|
-
publicUrl: src("ACC_PUBLIC_URL"),
|
|
374
|
-
supabaseUrl: src("ACC_SUPABASE_URL"),
|
|
375
|
-
supabaseAnonKey: src("ACC_SUPABASE_ANON_KEY"),
|
|
376
|
-
repoPath: repoPathSrc,
|
|
377
|
-
targetRepo: src("ACC_TARGET_REPO"),
|
|
378
|
-
integrationBranch: src("ACC_INTEGRATION_BRANCH"),
|
|
379
|
-
capabilities: src("ACC_RUNNER_CAPABILITIES"),
|
|
380
|
-
worktreeRepoPath: worktreeRepoPathSrc,
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Kept for callers that still treat config-load failure as recoverable.
|
|
385
|
-
* With defaults in place loadConfig() does not throw, so this returns
|
|
386
|
-
* a populated RunnerConfig in normal use.
|
|
387
|
-
*/
|
|
388
|
-
export function loadConfigOrNull() {
|
|
389
|
-
try {
|
|
390
|
-
return loadConfig();
|
|
391
|
-
}
|
|
392
|
-
catch {
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;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C,KAAK;QACP,CAAC,CAAC,0BAA0B,EAAE;YAC5B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,mBAAmB,GAAiB,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,EAAE;QAClF,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,kCAAkC,EAAE;YACpC,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,gBAAgB,CAAC;QAChC,WAAW,EAAE,GAAG,CAAC,kBAAkB,CAAC;QACpC,eAAe,EAAE,GAAG,CAAC,uBAAuB,CAAC;QAC7C,QAAQ,EAAE,WAAW;QACrB,UAAU,EAAE,GAAG,CAAC,iBAAiB,CAAC;QAClC,iBAAiB,EAAE,GAAG,CAAC,wBAAwB,CAAC;QAChD,YAAY,EAAE,GAAG,CAAC,yBAAyB,CAAC;QAC5C,gBAAgB,EAAE,mBAAmB;KACtC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC;QACH,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/cost-pricing.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-model token pricing plus a helper that turns a Claude Code
|
|
3
|
-
* `--output-format=json` usage block into integer USD cents.
|
|
4
|
-
*
|
|
5
|
-
* v0.4 sources the live table from `GET /api/llm/pricing` at runner
|
|
6
|
-
* startup (`fetchPricing` below) and caches it in module state for
|
|
7
|
-
* the process lifetime. If the fetch fails — network down, endpoint
|
|
8
|
-
* 5xx, malformed body — the runner stays on the embedded snapshot
|
|
9
|
-
* below and writes a single warning to stderr. The cost-cap surface
|
|
10
|
-
* keeps receiving events with reasonable values rather than zeros.
|
|
11
|
-
*
|
|
12
|
-
* The price math (`priceUsdCents`, `pricingFor`, `normalizeUsage`) is
|
|
13
|
-
* sync, so `task-runner.ts` doesn't have to know a network fetch
|
|
14
|
-
* happens once at boot.
|
|
15
|
-
*
|
|
16
|
-
* The embedded table is intentionally a copy of the server table. The
|
|
17
|
-
* two MUST stay in sync until v0.5 centralises them; the duplication
|
|
18
|
-
* is the price of an always-functional offline fallback.
|
|
19
|
-
*/
|
|
20
|
-
export interface ModelPricing {
|
|
21
|
-
inputPer1M: number;
|
|
22
|
-
outputPer1M: number;
|
|
23
|
-
cacheWritePer1M: number;
|
|
24
|
-
cacheReadPer1M: number;
|
|
25
|
-
}
|
|
26
|
-
export interface ClaudeUsage {
|
|
27
|
-
input_tokens?: number;
|
|
28
|
-
output_tokens?: number;
|
|
29
|
-
cache_creation_input_tokens?: number;
|
|
30
|
-
cache_read_input_tokens?: number;
|
|
31
|
-
}
|
|
32
|
-
export interface NormalizedUsage {
|
|
33
|
-
input_tokens: number;
|
|
34
|
-
output_tokens: number;
|
|
35
|
-
cache_read_tokens: number;
|
|
36
|
-
cache_write_tokens: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Embedded last-known-good snapshot, used as the cache's initial value
|
|
40
|
-
* and as the permanent fallback when `fetchPricing` can't reach the
|
|
41
|
-
* server. Kept in sync with `api/llm/pricing.ts` by hand.
|
|
42
|
-
*/
|
|
43
|
-
export declare const MODEL_PRICING: Record<string, ModelPricing>;
|
|
44
|
-
export interface FetchPricingResult {
|
|
45
|
-
ok: boolean;
|
|
46
|
-
version: string;
|
|
47
|
-
/** Populated when `ok` is false; opaque diagnostic for the operator. */
|
|
48
|
-
reason?: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Fetch the server pricing table and atomically replace the in-memory
|
|
52
|
-
* cache. Subsequent `priceUsdCents` calls in this process use the
|
|
53
|
-
* fetched values. On failure leaves the existing cache untouched and
|
|
54
|
-
* logs one stderr line; the runner stays usable on the fallback.
|
|
55
|
-
*
|
|
56
|
-
* Intentionally NOT deduped across calls — operators can rewarm the
|
|
57
|
-
* cache mid-process by calling this again if pricing rolls over.
|
|
58
|
-
*/
|
|
59
|
-
export declare function fetchPricing(baseUrl: string): Promise<FetchPricingResult>;
|
|
60
|
-
/**
|
|
61
|
-
* Returns the pricing version currently in the cache. Useful for
|
|
62
|
-
* logging at task boundaries; not used in cost arithmetic.
|
|
63
|
-
*/
|
|
64
|
-
export declare function currentPricingVersion(): string;
|
|
65
|
-
/** Test hook: resets cache + version to the embedded fallback. */
|
|
66
|
-
export declare function _resetPricingForTests(): void;
|
|
67
|
-
export declare function pricingFor(model: string): ModelPricing;
|
|
68
|
-
export declare function normalizeUsage(raw: ClaudeUsage | null | undefined): NormalizedUsage;
|
|
69
|
-
export declare function priceUsdCents(model: string, usage: NormalizedUsage): number;
|
|
70
|
-
/**
|
|
71
|
-
* Parse the JSON block Claude Code emits with `--output-format=json`.
|
|
72
|
-
* Returns null on parse failure so the caller can fall back to plain
|
|
73
|
-
* markdown extraction.
|
|
74
|
-
*/
|
|
75
|
-
export interface ClaudeJsonOutput {
|
|
76
|
-
result?: string;
|
|
77
|
-
model?: string;
|
|
78
|
-
usage?: ClaudeUsage;
|
|
79
|
-
}
|
|
80
|
-
export declare function parseClaudeJson(stdout: string): ClaudeJsonOutput | null;
|
|
81
|
-
/**
|
|
82
|
-
* v0.12-MODEL-ALIAS — wire-format translation for the ACC model
|
|
83
|
-
* registry. `acc.models.id` is the short alias the rest of ACC uses
|
|
84
|
-
* (e.g. `claude-sonnet-4`); the runner CLI and the Anthropic Messages
|
|
85
|
-
* API need different wire strings.
|
|
86
|
-
*
|
|
87
|
-
* - cli_alias: passed to `claude --model`. Accepts the short form
|
|
88
|
-
* `sonnet` / `opus` / `haiku` OR a fully-versioned name.
|
|
89
|
-
* - api_id: sent to api.anthropic.com/v1/messages. Must be the
|
|
90
|
-
* canonical model ID (`claude-sonnet-4-6` etc).
|
|
91
|
-
*
|
|
92
|
-
* The embedded table mirrors migration 0108's backfill. `toCliAlias`
|
|
93
|
-
* and `toApiId` fall back to the input verbatim when the alias is
|
|
94
|
-
* unknown, so:
|
|
95
|
-
* 1. A fresh model id not yet registered passes straight through.
|
|
96
|
-
* 2. A stale DB row that has cli_alias = NULL still works — the
|
|
97
|
-
* runner reads `result.model?.id` and translates here.
|
|
98
|
-
*
|
|
99
|
-
* Closes REG-303 + REG-304.
|
|
100
|
-
*/
|
|
101
|
-
export interface ModelAlias {
|
|
102
|
-
cli_alias: string;
|
|
103
|
-
api_id: string;
|
|
104
|
-
}
|
|
105
|
-
export declare const MODEL_ALIASES: Record<string, ModelAlias>;
|
|
106
|
-
/**
|
|
107
|
-
* Test hook: replace the in-memory alias table. Use this from tests
|
|
108
|
-
* that simulate a DB-fetched override; production code calls the
|
|
109
|
-
* embedded MODEL_ALIASES directly. Passing nothing resets to the
|
|
110
|
-
* embedded snapshot, mirroring `_resetPricingForTests`.
|
|
111
|
-
*/
|
|
112
|
-
export declare function registerAliases(table?: Record<string, ModelAlias>): void;
|
|
113
|
-
/**
|
|
114
|
-
* Map an `acc.models.id` to the string accepted by `claude --model`.
|
|
115
|
-
* Returns the input verbatim when unknown so unregistered model ids
|
|
116
|
-
* (a future v0.13 alias not yet in the embedded table; a CLI test
|
|
117
|
-
* fixture passing a literal `sonnet`) still spawn correctly.
|
|
118
|
-
*
|
|
119
|
-
* Empty / whitespace input passes through unchanged so callers that
|
|
120
|
-
* want the operator's CLI default (no `--model` flag at all) can
|
|
121
|
-
* detect it by trimming after this call. See task-runner.buildClaudeArgs.
|
|
122
|
-
*/
|
|
123
|
-
export declare function toCliAlias(modelId: string | null | undefined): string;
|
|
124
|
-
/**
|
|
125
|
-
* Map an `acc.models.id` to the canonical Anthropic Messages API
|
|
126
|
-
* model ID. Used by the reviewer-agent before POSTing to
|
|
127
|
-
* api.anthropic.com. Same verbatim-fallback semantics as toCliAlias.
|
|
128
|
-
*/
|
|
129
|
-
export declare function toApiId(modelId: string | null | undefined): string;
|
|
130
|
-
//# sourceMappingURL=cost-pricing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cost-pricing.d.ts","sourceRoot":"","sources":["../src/cost-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAO,MAAM,CAAC;IACxB,WAAW,EAAM,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,EAAiB,MAAM,CAAC;IACrC,aAAa,CAAC,EAAgB,MAAM,CAAC;IACrC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,uBAAuB,CAAC,EAAM,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAQ,MAAM,CAAC;IAC3B,aAAa,EAAO,MAAM,CAAC;IAC3B,iBAAiB,EAAG,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAuBD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAStD,CAAC;AAoBF,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAQ,OAAO,CAAC;IAClB,OAAO,EAAG,MAAM,CAAC;IACjB,wEAAwE;IACxE,MAAM,CAAC,EAAG,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0B/E;AAuBD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,kEAAkE;AAClE,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAStD;AAED,wBAAgB,cAAc,CAAC,GAAG,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