@tekmidian/pai 0.37.0 → 0.39.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/dist/{auto-route-DM7GhJ8y.mjs → auto-route-BlWOWT4z.mjs} +2 -2
- package/dist/{auto-route-DM7GhJ8y.mjs.map → auto-route-BlWOWT4z.mjs.map} +1 -1
- package/dist/{providers-sXcK5bDZ.mjs → chain-CTtHligI.mjs} +1040 -782
- package/dist/chain-CTtHligI.mjs.map +1 -0
- package/dist/cli/index.mjs +4 -3
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/program.mjs +4 -3
- package/dist/{clusters-Do4tEGyc.mjs → clusters-wlK0w41E.mjs} +1 -1
- package/dist/{clusters-Do4tEGyc.mjs.map → clusters-wlK0w41E.mjs.map} +1 -1
- package/dist/daemon/index.mjs +7 -7
- package/dist/{daemon-CGg1VCbA.mjs → daemon-CTkN_Vn8.mjs} +25 -25
- package/dist/{daemon-CGg1VCbA.mjs.map → daemon-CTkN_Vn8.mjs.map} +1 -1
- package/dist/{daemon-DsGGiIJM.mjs → daemon-CmHHmKpg.mjs} +7 -7
- package/dist/daemon-mcp/index.mjs +207 -34
- package/dist/daemon-mcp/index.mjs.map +1 -1
- package/dist/{detector-CMap-9vw.mjs → detector-Bwk_4Pk4.mjs} +1 -1
- package/dist/{detector-CMap-9vw.mjs.map → detector-Bwk_4Pk4.mjs.map} +1 -1
- package/dist/detector-DO730Zq0.mjs +5 -0
- package/dist/{factory-DD2T33C9.mjs → factory-A9x-T2Kg.mjs} +5 -5
- package/dist/{factory-DD2T33C9.mjs.map → factory-A9x-T2Kg.mjs.map} +1 -1
- package/dist/factory-BD-np0Vd.mjs +3 -0
- package/dist/hooks/route-agents-to-worker.mjs +112 -20
- package/dist/hooks/route-agents-to-worker.mjs.map +2 -2
- package/dist/hooks/worker-proxy.mjs +110 -18
- package/dist/hooks/worker-proxy.mjs.map +2 -2
- package/dist/hooks/worker-status-line.mjs +176 -23
- package/dist/hooks/worker-status-line.mjs.map +4 -4
- package/dist/{indexer-backend-Cox9BCo-.mjs → indexer-backend-TG64CCQC.mjs} +1 -1
- package/dist/{indexer-backend-Cox9BCo-.mjs.map → indexer-backend-TG64CCQC.mjs.map} +1 -1
- package/dist/{latent-ideas-BC1oINZ-.mjs → latent-ideas-B7wq75Pt.mjs} +2 -2
- package/dist/{latent-ideas-BC1oINZ-.mjs.map → latent-ideas-B7wq75Pt.mjs.map} +1 -1
- package/dist/{link-boost-QFLrJwD6.mjs → link-boost-HkG7JWZR.mjs} +1 -1
- package/dist/{link-boost-QFLrJwD6.mjs.map → link-boost-HkG7JWZR.mjs.map} +1 -1
- package/dist/{neighborhood-D9MJ1c8f.mjs → neighborhood-lThN-MaQ.mjs} +1 -1
- package/dist/{neighborhood-D9MJ1c8f.mjs.map → neighborhood-lThN-MaQ.mjs.map} +1 -1
- package/dist/{note-context-d1wT_-GA.mjs → note-context-b6k0mAKi.mjs} +1 -1
- package/dist/{note-context-d1wT_-GA.mjs.map → note-context-b6k0mAKi.mjs.map} +1 -1
- package/dist/planner-BDI7bE9B.mjs +243 -0
- package/dist/planner-BDI7bE9B.mjs.map +1 -0
- package/dist/{postgres--BjPtLa0.mjs → postgres-mW1n7Vi1.mjs} +1 -1
- package/dist/{postgres--BjPtLa0.mjs.map → postgres-mW1n7Vi1.mjs.map} +1 -1
- package/dist/{program-CEIHn_Ma.mjs → program-DXBwJV7h.mjs} +274 -65
- package/dist/program-DXBwJV7h.mjs.map +1 -0
- package/dist/providers-FYkZjn_C.mjs +1405 -0
- package/dist/providers-FYkZjn_C.mjs.map +1 -0
- package/dist/{query-feedback-BUJxgw5B.mjs → query-feedback-BV4CcxqS.mjs} +1 -1
- package/dist/{query-feedback-BUJxgw5B.mjs.map → query-feedback-BV4CcxqS.mjs.map} +1 -1
- package/dist/query-feedback-DSVyHtrG.mjs +3 -0
- package/dist/router-Bk77E7hj.mjs +3 -0
- package/dist/{router-DK_sLsUL.mjs → router-DcHKnEPa.mjs} +1 -1
- package/dist/{router-DK_sLsUL.mjs.map → router-DcHKnEPa.mjs.map} +1 -1
- package/dist/skills/Worker/SKILL.md +34 -12
- package/dist/{sources-Bi7--33T.mjs → sources-kLnQsNrW.mjs} +1 -1
- package/dist/{sources-Bi7--33T.mjs.map → sources-kLnQsNrW.mjs.map} +1 -1
- package/dist/{sqlite-DtaL1glm.mjs → sqlite-BenGr3UP.mjs} +1 -1
- package/dist/{sqlite-DtaL1glm.mjs.map → sqlite-BenGr3UP.mjs.map} +1 -1
- package/dist/{state-BY2L6-vX.mjs → state-CAeyOdfq.mjs} +1 -1
- package/dist/{state-BY2L6-vX.mjs.map → state-CAeyOdfq.mjs.map} +1 -1
- package/dist/{state-8Hm9E4tW.mjs → state-Ca9F_sZc.mjs} +1 -1
- package/dist/{themes-BN0a2duq.mjs → themes-BI4GMRP9.mjs} +1 -1
- package/dist/{themes-BN0a2duq.mjs.map → themes-BI4GMRP9.mjs.map} +1 -1
- package/dist/{tools-CGPqpU3A.mjs → tools-Bp7hj6OW.mjs} +1 -1
- package/dist/{tools-y2bJpKom.mjs → tools-DGcB3o_S.mjs} +13 -13
- package/dist/{tools-y2bJpKom.mjs.map → tools-DGcB3o_S.mjs.map} +1 -1
- package/dist/{trace-h23JCcFD.mjs → trace-bobARFEX.mjs} +1 -1
- package/dist/{trace-h23JCcFD.mjs.map → trace-bobARFEX.mjs.map} +1 -1
- package/dist/{vault-indexer-DgsPjMgs.mjs → vault-indexer-C3OfXTNF.mjs} +1 -1
- package/dist/{vault-indexer-DgsPjMgs.mjs.map → vault-indexer-C3OfXTNF.mjs.map} +1 -1
- package/dist/{work-queue-worker-gsKd2LJa.mjs → work-queue-worker-DW8lz-Oo.mjs} +3 -3
- package/dist/{work-queue-worker-Dva_v_pI.mjs → work-queue-worker-R7UGIag_.mjs} +3 -3
- package/dist/{work-queue-worker-Dva_v_pI.mjs.map → work-queue-worker-R7UGIag_.mjs.map} +1 -1
- package/dist/{zettelkasten-vo7psPdT.mjs → zettelkasten-m5QPtb-L.mjs} +3 -3
- package/dist/{zettelkasten-vo7psPdT.mjs.map → zettelkasten-m5QPtb-L.mjs.map} +1 -1
- package/docs/commands/README.md +12 -7
- package/docs/commands/worker.md +110 -17
- package/docs/worker.md +244 -25
- package/package.json +1 -1
- package/src/hooks/ts/pre-tool-use/route-agents-to-worker.ts +2 -2
- package/dist/detector-DtLExmHN.mjs +0 -5
- package/dist/factory-BXzqRYVZ.mjs +0 -3
- package/dist/program-CEIHn_Ma.mjs.map +0 -1
- package/dist/providers-sXcK5bDZ.mjs.map +0 -1
- package/dist/query-feedback-DhyLOe5S.mjs +0 -3
- package/dist/router-1zi8jiNF.mjs +0 -3
- /package/dist/{main-resolver-IhZo4pI0.mjs → main-resolver-D6IImXvF.mjs} +0 -0
|
@@ -11,10 +11,11 @@ import { _ as findMovedProjects, a as findLatestNote, c as extractAndStoreTriple
|
|
|
11
11
|
import { a as schedulerLogPath, i as paiSocketPath, n as daemonLogPath, r as daemonPidPath } from "./runtime-paths-rni52zHX.mjs";
|
|
12
12
|
import { t as PaiClient } from "./ipc-client-BmypMNYk.mjs";
|
|
13
13
|
import { a as expandHome, c as UNROUTED, i as ensureConfigDir, n as CONFIG_FILE$2, o as loadConfig, s as OWNER_LABEL_PREFIX, t as CONFIG_DIR } from "./config-B64vFg14.mjs";
|
|
14
|
-
import { r as humanDuration, t as createStorageBackend } from "./factory-
|
|
15
|
-
import {
|
|
14
|
+
import { r as humanDuration, t as createStorageBackend } from "./factory-A9x-T2Kg.mjs";
|
|
15
|
+
import { B as workersLogDir, H as PROVIDER_TAGS, I as parseRunnerArgs, J as readWorkersSection, R as eventsPath, U as WorkersConfigError, X as readJsonStrict, Z as writeJsonAtomic, a as testProvider, b as openPaneForWorker, c as stopProxy, f as discardWorker, g as sayToWorker, i as runWorker, j as loadStatus, l as describeMcp, m as handoffFromInside, o as DEFAULT_PROXY_PORT, p as mergeWorker, s as ensureProxyRunning, t as runChain, v as checkPaneForWorker, y as openFollowPane, z as ledgerPath } from "./chain-CTtHligI.mjs";
|
|
16
16
|
import { s as kgQuery } from "./kg-entity-r8duqhi9.mjs";
|
|
17
17
|
import { _ as scanSessions, a as renderDedupedSessions, c as probeResume, d as callAiBroker, f as fetchLiveSessions, g as resolveSessionByNameOrId, h as fmtAge, i as normalizeName$2, l as restoreTopLevel, m as sendToSession, o as hasConversation, p as revealItermSession, r as buildDeduped, s as launchInDir, t as cmdMain, u as printExitDir } from "./main-resolver-DlaLOFBA.mjs";
|
|
18
|
+
import { a as setClass, c as unsetClass, d as followWorkers, f as psOutput, i as removeProvider, l as updateProvider, m as statusLineOutput, n as classTargetText, o as setProviderEnabled, p as replayOutput, r as describeProviders, s as setWorkersEnabled, t as addProvider, u as useProvider } from "./providers-FYkZjn_C.mjs";
|
|
18
19
|
import { appendFileSync, chmodSync, copyFileSync, createReadStream, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
19
20
|
import { homedir, platform, tmpdir } from "node:os";
|
|
20
21
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
@@ -1889,7 +1890,7 @@ function cmdUnregister(db, slug, opts = {}) {
|
|
|
1889
1890
|
//#region src/cli/commands/project/projects-index.ts
|
|
1890
1891
|
function registerProjectsCommands(projectsCmd, getDb) {
|
|
1891
1892
|
projectsCmd.command("list", { isDefault: true }).description("Show the unified deduped listing (same as `pai`).\nUse --all to include cold / zero-session / archived projects.").option("--all", "Show all entries including cold / zero-session / archived projects").option("-n, --n <count>", "Max rows to show", "20").action(async (opts) => {
|
|
1892
|
-
const { cmdMain } = await import("./main-resolver-
|
|
1893
|
+
const { cmdMain } = await import("./main-resolver-D6IImXvF.mjs");
|
|
1893
1894
|
await cmdMain(getDb(), void 0, void 0, opts);
|
|
1894
1895
|
});
|
|
1895
1896
|
projectsCmd.command("list-raw").description("Raw registry listing with slug, path, status, last_active columns").option("--all", "Include archived projects (default: active only)").option("--status <status>", "Filter by status: active | archived").option("--tag <tag>", "Filter by tag").option("--type <type>", "Filter by type").action((opts) => {
|
|
@@ -2961,9 +2962,9 @@ function registerStatsCommands(memoryCmd, getDb) {
|
|
|
2961
2962
|
//#region src/cli/commands/memory/sources-cmd.ts
|
|
2962
2963
|
function registerSourcesCommand(memoryCmd) {
|
|
2963
2964
|
memoryCmd.command("sources").description("Show what the indexer has taken in: composition by source, which roots\ncontent enters from, the heaviest single files, and how many chunks are\nrewritten per day (which distinguishes a finite backlog from a treadmill).").option("--limit <n>", "Rows per section (default 8)", "8").action(async (opts) => {
|
|
2964
|
-
const { createStorageBackend } = await import("./factory-
|
|
2965
|
+
const { createStorageBackend } = await import("./factory-BD-np0Vd.mjs");
|
|
2965
2966
|
const { loadConfig } = await import("./config-C_ErGddD.mjs");
|
|
2966
|
-
const { cmdMemorySources } = await import("./sources-
|
|
2967
|
+
const { cmdMemorySources } = await import("./sources-kLnQsNrW.mjs");
|
|
2967
2968
|
let backend;
|
|
2968
2969
|
try {
|
|
2969
2970
|
backend = await createStorageBackend(loadConfig());
|
|
@@ -3650,7 +3651,7 @@ function cmdLogs(opts) {
|
|
|
3650
3651
|
}
|
|
3651
3652
|
function registerDaemonCommands(daemonCmd) {
|
|
3652
3653
|
daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
|
|
3653
|
-
const { serve } = await import("./daemon-
|
|
3654
|
+
const { serve } = await import("./daemon-CmHHmKpg.mjs");
|
|
3654
3655
|
const { loadConfig: lc, ensureConfigDir } = await import("./config-C_ErGddD.mjs");
|
|
3655
3656
|
ensureConfigDir();
|
|
3656
3657
|
await serve(lc());
|
|
@@ -6253,7 +6254,7 @@ async function stepWorkers(rl) {
|
|
|
6253
6254
|
return { workers: {
|
|
6254
6255
|
enabled: false,
|
|
6255
6256
|
providers: {},
|
|
6256
|
-
|
|
6257
|
+
classes: {}
|
|
6257
6258
|
} };
|
|
6258
6259
|
}
|
|
6259
6260
|
line$1();
|
|
@@ -6265,14 +6266,14 @@ async function stepWorkers(rl) {
|
|
|
6265
6266
|
line$1(c.dim(" --key-file ~/.config/example/api_key \\"));
|
|
6266
6267
|
line$1(c.dim(" --model example-4.7 --fast-model example-4.7-flash"));
|
|
6267
6268
|
line$1();
|
|
6268
|
-
line$1(" The first provider turns workers on and seeds the
|
|
6269
|
+
line$1(" The first provider turns workers on and seeds the classes.");
|
|
6269
6270
|
line$1();
|
|
6270
6271
|
const r = installWorkers();
|
|
6271
6272
|
for (const l of r.lines) line$1(` ${l}`);
|
|
6272
6273
|
return { workers: {
|
|
6273
6274
|
enabled: false,
|
|
6274
6275
|
providers: {},
|
|
6275
|
-
|
|
6276
|
+
classes: {}
|
|
6276
6277
|
} };
|
|
6277
6278
|
}
|
|
6278
6279
|
|
|
@@ -7228,7 +7229,7 @@ async function cmdExplore(note, opts) {
|
|
|
7228
7229
|
const depth = parseInt(opts.depth ?? "3", 10);
|
|
7229
7230
|
const direction = opts.direction ?? "both";
|
|
7230
7231
|
const mode = opts.mode ?? "all";
|
|
7231
|
-
const { zettelExplore } = await import("./zettelkasten-
|
|
7232
|
+
const { zettelExplore } = await import("./zettelkasten-m5QPtb-L.mjs");
|
|
7232
7233
|
const result = zettelExplore(getFedDb(), {
|
|
7233
7234
|
startNote: note,
|
|
7234
7235
|
depth,
|
|
@@ -7293,7 +7294,7 @@ async function cmdHealth(opts) {
|
|
|
7293
7294
|
const projectPath = opts.project;
|
|
7294
7295
|
const recentDays = parseInt(opts.days ?? "30", 10);
|
|
7295
7296
|
const includeTypes = opts.include ? opts.include.split(",").map((s) => s.trim()) : void 0;
|
|
7296
|
-
const { zettelHealth } = await import("./zettelkasten-
|
|
7297
|
+
const { zettelHealth } = await import("./zettelkasten-m5QPtb-L.mjs");
|
|
7297
7298
|
const result = zettelHealth(getFedDb(), {
|
|
7298
7299
|
scope,
|
|
7299
7300
|
projectPath,
|
|
@@ -7364,7 +7365,7 @@ async function cmdSurprise(note, opts) {
|
|
|
7364
7365
|
const limit = parseInt(opts.limit ?? "10", 10);
|
|
7365
7366
|
const minSimilarity = parseFloat(opts.minSimilarity ?? "0.3");
|
|
7366
7367
|
const minGraphDistance = parseInt(opts.minDistance ?? "3", 10);
|
|
7367
|
-
const { zettelSurprise } = await import("./zettelkasten-
|
|
7368
|
+
const { zettelSurprise } = await import("./zettelkasten-m5QPtb-L.mjs");
|
|
7368
7369
|
const db = getFedDb();
|
|
7369
7370
|
console.log();
|
|
7370
7371
|
console.log(header(" PAI Zettel Surprise"));
|
|
@@ -7419,7 +7420,7 @@ async function cmdSuggest(note, opts) {
|
|
|
7419
7420
|
const vaultProjectId = parseInt(opts.vaultProjectId, 10);
|
|
7420
7421
|
const limit = parseInt(opts.limit ?? "5", 10);
|
|
7421
7422
|
const excludeLinked = opts.excludeLinked !== false;
|
|
7422
|
-
const { zettelSuggest } = await import("./zettelkasten-
|
|
7423
|
+
const { zettelSuggest } = await import("./zettelkasten-m5QPtb-L.mjs");
|
|
7423
7424
|
const db = getFedDb();
|
|
7424
7425
|
console.log();
|
|
7425
7426
|
console.log(header(" PAI Zettel Suggest"));
|
|
@@ -7472,7 +7473,7 @@ async function cmdConverse(question, opts) {
|
|
|
7472
7473
|
const vaultProjectId = parseInt(opts.vaultProjectId, 10);
|
|
7473
7474
|
const depth = parseInt(opts.depth ?? "2", 10);
|
|
7474
7475
|
const limit = parseInt(opts.limit ?? "15", 10);
|
|
7475
|
-
const { zettelConverse } = await import("./zettelkasten-
|
|
7476
|
+
const { zettelConverse } = await import("./zettelkasten-m5QPtb-L.mjs");
|
|
7476
7477
|
const db = getFedDb();
|
|
7477
7478
|
console.log();
|
|
7478
7479
|
console.log(header(" PAI Zettel Converse"));
|
|
@@ -7535,7 +7536,7 @@ async function cmdThemes(opts) {
|
|
|
7535
7536
|
const minClusterSize = parseInt(opts.minSize ?? "3", 10);
|
|
7536
7537
|
const maxThemes = parseInt(opts.maxThemes ?? "10", 10);
|
|
7537
7538
|
const similarityThreshold = parseFloat(opts.threshold ?? "0.65");
|
|
7538
|
-
const { zettelThemes } = await import("./zettelkasten-
|
|
7539
|
+
const { zettelThemes } = await import("./zettelkasten-m5QPtb-L.mjs");
|
|
7539
7540
|
const db = getFedDb();
|
|
7540
7541
|
console.log();
|
|
7541
7542
|
console.log(header(" PAI Zettel Themes"));
|
|
@@ -9110,7 +9111,7 @@ async function escalate(task, headline, detail, state, now, opts) {
|
|
|
9110
9111
|
state.alarmedAt[task.id] = now;
|
|
9111
9112
|
let delivered = false;
|
|
9112
9113
|
try {
|
|
9113
|
-
const { routeNotification } = await import("./router-
|
|
9114
|
+
const { routeNotification } = await import("./router-Bk77E7hj.mjs");
|
|
9114
9115
|
const { loadConfig } = await import("./config-C_ErGddD.mjs");
|
|
9115
9116
|
delivered = (await routeNotification({
|
|
9116
9117
|
event: "error",
|
|
@@ -11727,9 +11728,9 @@ function cmdActive(db, opts) {
|
|
|
11727
11728
|
], rows));
|
|
11728
11729
|
}
|
|
11729
11730
|
async function cmdAutoRoute(opts) {
|
|
11730
|
-
const { autoRoute, formatAutoRoute, formatAutoRouteJson } = await import("./auto-route-
|
|
11731
|
+
const { autoRoute, formatAutoRoute, formatAutoRouteJson } = await import("./auto-route-BlWOWT4z.mjs");
|
|
11731
11732
|
const { openRegistry } = await import("./db-XEwJbuGO.mjs");
|
|
11732
|
-
const { createStorageBackend } = await import("./factory-
|
|
11733
|
+
const { createStorageBackend } = await import("./factory-BD-np0Vd.mjs");
|
|
11733
11734
|
const { loadConfig } = await import("./config-C_ErGddD.mjs");
|
|
11734
11735
|
const config = loadConfig();
|
|
11735
11736
|
const registryDb = openRegistry();
|
|
@@ -13577,6 +13578,99 @@ function registerSessionCommands(sessionCmd, getDb) {
|
|
|
13577
13578
|
});
|
|
13578
13579
|
}
|
|
13579
13580
|
|
|
13581
|
+
//#endregion
|
|
13582
|
+
//#region src/workers/agents.ts
|
|
13583
|
+
/**
|
|
13584
|
+
* agents.ts — run agent definitions (~/.claude/agents/<name>.md) as workers.
|
|
13585
|
+
*
|
|
13586
|
+
* The file format is the Claude Code agent one: YAML front matter (`model`,
|
|
13587
|
+
* `tools`, `description`) followed by a Markdown body that is the agent's
|
|
13588
|
+
* system prompt. `pai worker run --agent <name>` loads it and maps it onto
|
|
13589
|
+
* the worker runner:
|
|
13590
|
+
*
|
|
13591
|
+
* - body → --append-system-prompt (prepended, so an explicit caller
|
|
13592
|
+
* flag still wins);
|
|
13593
|
+
* - tools → --allowedTools;
|
|
13594
|
+
* - model → a task class (haiku→simple, sonnet→implement, opus→complex),
|
|
13595
|
+
* unless --class is given.
|
|
13596
|
+
*/
|
|
13597
|
+
/** Directory the agent library lives in. */
|
|
13598
|
+
function agentsDir() {
|
|
13599
|
+
return join(homedir(), ".claude", "agents");
|
|
13600
|
+
}
|
|
13601
|
+
function agentPath(name) {
|
|
13602
|
+
return join(agentsDir(), `${name}.md`);
|
|
13603
|
+
}
|
|
13604
|
+
/** `key: value` (bare) or `key: [a, b]` / `key:\n - a\n - b` (list). */
|
|
13605
|
+
function parseFrontMatter(text) {
|
|
13606
|
+
const out = {};
|
|
13607
|
+
let key = "";
|
|
13608
|
+
for (const raw of text.split("\n")) {
|
|
13609
|
+
const listItem = /^\s+-\s+(.*)$/.exec(raw);
|
|
13610
|
+
if (listItem && key) {
|
|
13611
|
+
const cur = out[key];
|
|
13612
|
+
const item = listItem[1].trim().replace(/^["']|["']$/g, "");
|
|
13613
|
+
out[key] = Array.isArray(cur) ? [...cur, item] : [item];
|
|
13614
|
+
continue;
|
|
13615
|
+
}
|
|
13616
|
+
const kv = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(raw);
|
|
13617
|
+
if (!kv) continue;
|
|
13618
|
+
key = kv[1];
|
|
13619
|
+
const val = kv[2].trim();
|
|
13620
|
+
if (!val) out[key] = [];
|
|
13621
|
+
else if (val.startsWith("[") && val.endsWith("]")) out[key] = val.slice(1, -1).split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
13622
|
+
else out[key] = val.replace(/^["']|["']$/g, "");
|
|
13623
|
+
}
|
|
13624
|
+
return out;
|
|
13625
|
+
}
|
|
13626
|
+
/** Parse an agent file's text (front matter + body). Throws on empty body. */
|
|
13627
|
+
function parseAgentFile(name, text, path) {
|
|
13628
|
+
const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(text);
|
|
13629
|
+
if (!m) throw new Error(`${path}: expected YAML front matter (--- … ---) before the agent body`);
|
|
13630
|
+
const fm = parseFrontMatter(m[1]);
|
|
13631
|
+
const body = m[2].trim();
|
|
13632
|
+
if (!body) throw new Error(`${path}: the agent body (after the front matter) is empty`);
|
|
13633
|
+
const def = {
|
|
13634
|
+
name,
|
|
13635
|
+
body,
|
|
13636
|
+
path
|
|
13637
|
+
};
|
|
13638
|
+
if (typeof fm.model === "string" && fm.model) def.model = fm.model;
|
|
13639
|
+
if (Array.isArray(fm.tools) && fm.tools.length) def.tools = fm.tools;
|
|
13640
|
+
if (typeof fm.description === "string" && fm.description) def.description = fm.description;
|
|
13641
|
+
return def;
|
|
13642
|
+
}
|
|
13643
|
+
/** Load ~/.claude/agents/<name>.md; the error names the library when missing. */
|
|
13644
|
+
function loadAgent(name) {
|
|
13645
|
+
const path = agentPath(name);
|
|
13646
|
+
let text;
|
|
13647
|
+
try {
|
|
13648
|
+
text = readFileSync(path, "utf8");
|
|
13649
|
+
} catch {
|
|
13650
|
+
throw new Error(`no agent named "${name}" at ${path}. The agent library lives in ~/.claude/agents/<name>.md and runs on workers.`);
|
|
13651
|
+
}
|
|
13652
|
+
return parseAgentFile(name, text, path);
|
|
13653
|
+
}
|
|
13654
|
+
/** Map an agent's front-matter model to a worker class. */
|
|
13655
|
+
function modelToClass(model) {
|
|
13656
|
+
if (!model) return void 0;
|
|
13657
|
+
const m = model.toLowerCase();
|
|
13658
|
+
if (m.includes("haiku")) return "simple";
|
|
13659
|
+
if (m.includes("sonnet")) return "implement";
|
|
13660
|
+
if (m.includes("opus")) return "complex";
|
|
13661
|
+
}
|
|
13662
|
+
/** Extra claude args the definition contributes (before the caller's own). */
|
|
13663
|
+
function agentClaudeArgs(def) {
|
|
13664
|
+
const args = [];
|
|
13665
|
+
if (def.tools?.length) args.push("--allowedTools", def.tools.join(","));
|
|
13666
|
+
args.push("--append-system-prompt", def.body);
|
|
13667
|
+
return args;
|
|
13668
|
+
}
|
|
13669
|
+
/** `<agent>: <first 50 chars of prompt>` — the default label for a run. */
|
|
13670
|
+
function agentLabel(name, prompt) {
|
|
13671
|
+
return `${name}: ${prompt ?? "(no prompt)"}`.slice(0, name.length + 2 + 50);
|
|
13672
|
+
}
|
|
13673
|
+
|
|
13580
13674
|
//#endregion
|
|
13581
13675
|
//#region src/cli/commands/worker/providers.ts
|
|
13582
13676
|
function fail$1(e) {
|
|
@@ -13599,14 +13693,37 @@ function parseIntArg$1(v) {
|
|
|
13599
13693
|
if (Number.isNaN(n) || n <= 0) throw new WorkersConfigError(`expected a positive number, got "${v}"`);
|
|
13600
13694
|
return n;
|
|
13601
13695
|
}
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
if (
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13696
|
+
function parseCostTier(v) {
|
|
13697
|
+
const n = parseInt(v, 10);
|
|
13698
|
+
if (!Number.isInteger(n) || n < 1 || n > 5) throw new WorkersConfigError(`cost tier must be an integer 1 (cheapest) … 5 (most expensive), got "${v}"`);
|
|
13699
|
+
return n;
|
|
13700
|
+
}
|
|
13701
|
+
/** `--tags a,b` (repeatable) → validated tag list. */
|
|
13702
|
+
function collectTags(vals) {
|
|
13703
|
+
const out = [];
|
|
13704
|
+
for (const v of vals ?? []) for (const t of v.split(",").map((s) => s.trim()).filter(Boolean)) {
|
|
13705
|
+
if (!PROVIDER_TAGS.includes(t)) throw new WorkersConfigError(`"${t}" is not a tag (from: ${PROVIDER_TAGS.join(", ")})`);
|
|
13706
|
+
if (!out.includes(t)) out.push(t);
|
|
13608
13707
|
}
|
|
13609
|
-
return
|
|
13708
|
+
return out;
|
|
13709
|
+
}
|
|
13710
|
+
/** Positional target + constraint flags → a ClassTarget for setClass. */
|
|
13711
|
+
function buildClassTarget(target, opts) {
|
|
13712
|
+
const hasConstraints = opts.provider !== void 0 || opts.mcp !== void 0 || opts.maxCostTier !== void 0 || opts.requireTags !== void 0 || opts.order !== void 0;
|
|
13713
|
+
if (target !== void 0 && !hasConstraints) return target;
|
|
13714
|
+
const obj = {};
|
|
13715
|
+
if (target !== void 0) obj.provider = target.split("/")[0];
|
|
13716
|
+
if (opts.provider !== void 0) obj.provider = opts.provider;
|
|
13717
|
+
if (opts.mcp !== void 0) obj.mcp = opts.mcp.split(",").map((s) => s.trim()).filter(Boolean);
|
|
13718
|
+
if (opts.maxCostTier !== void 0) obj.maxCostTier = opts.maxCostTier;
|
|
13719
|
+
if (opts.requireTags !== void 0) obj.requireTags = opts.requireTags;
|
|
13720
|
+
if (opts.order !== void 0) obj.order = opts.order.split(",").map((s) => s.trim()).filter(Boolean);
|
|
13721
|
+
if (target !== void 0 && target.includes("/") && obj.provider) {
|
|
13722
|
+
const alias = target.split("/")[1];
|
|
13723
|
+
if (alias && alias !== "default") throw new WorkersConfigError(`a provider alias ("${alias}") cannot be combined with constraint flags — use the plain "<target>" form for pinning`);
|
|
13724
|
+
}
|
|
13725
|
+
if (!Object.keys(obj).length) throw new WorkersConfigError("give a target (provider, provider/fast) or a constraint (--max-cost-tier, --require-tags, …)");
|
|
13726
|
+
return obj;
|
|
13610
13727
|
}
|
|
13611
13728
|
function registerWorkerProviderCommands(providersCmd) {
|
|
13612
13729
|
providersCmd.description("Providers: list (default), add, remove, use, enable, disable, test").action(() => {
|
|
@@ -13617,13 +13734,14 @@ function registerWorkerProviderCommands(providersCmd) {
|
|
|
13617
13734
|
console.log(dim$1(` workers are ${workers.enabled ? "on" : "off"} — pai worker ${workers.enabled ? "off" : "on"}`));
|
|
13618
13735
|
console.log();
|
|
13619
13736
|
});
|
|
13620
|
-
providersCmd.command("add <name>").description("Add a provider; the first one also turns workers on and seeds
|
|
13737
|
+
providersCmd.command("add <name>").description("Add a provider; the first one also turns workers on and seeds classes.\nExample: pai worker providers add glm --base-url https://…/anthropic \\\n --key-file ~/.config/zai/api_key --model glm-5.3 --fast-model glm-5.3-flash\nOpenAI-protocol: --protocol openai --upstream-url https://…/v1 (runs via the PAI proxy).\nCodex (ChatGPT plan): --engine codex — runs through the Codex CLI.").option("--base-url <url>", "Anthropic-compatible API base URL (required unless --protocol openai)").requiredOption("--model <model>", "Default model id for this provider").option("--key-file <path>", "File holding the API token (0600); omit for token \"local\"").option("--fast-model <model>", "Cheaper model for spotchecks and routing").option("--env <name=value>", "Extra env for runs (repeatable)", (v, acc) => [...acc, v], []).option("--note <text>", "Human note shown in `providers list`").option("--protocol <proto>", "anthropic (default) or openai — openai runs through the local PAI proxy").option("--upstream-url <url>", "Chat Completions base URL (required for --protocol openai)").option("--engine <engine>", "claude (default) or codex — codex runs `codex exec --json`").option("--context-window <tokens>", "Context window for the meter (default 200000; init event overrides)", parseIntArg$1).option("--quota-probe <url>", "URL whose JSON first number is the quota percent (0-100)").option("--cost-tier <1-5>", "Cost tier 1 (cheapest) … 5 (most expensive; default 3)", parseCostTier).option("--tags <tags>", "Capability tags, comma-separated (from: " + PROVIDER_TAGS.join(", ") + ")", (v, acc) => [...acc, v], []).action((name, opts) => {
|
|
13621
13738
|
try {
|
|
13622
13739
|
const protocol = opts.protocol;
|
|
13623
13740
|
const engine = opts.engine;
|
|
13624
13741
|
if (protocol && protocol !== "anthropic" && protocol !== "openai") throw new WorkersConfigError(`--protocol must be anthropic or openai, got "${protocol}"`);
|
|
13625
13742
|
if (engine && engine !== "claude" && engine !== "codex") throw new WorkersConfigError(`--engine must be claude or codex, got "${engine}"`);
|
|
13626
13743
|
if (protocol !== "openai" && !opts.baseUrl) throw new WorkersConfigError("--base-url is required (only --protocol openai goes without it)");
|
|
13744
|
+
const tags = collectTags(opts.tags);
|
|
13627
13745
|
addProvider({
|
|
13628
13746
|
name,
|
|
13629
13747
|
baseUrl: opts.baseUrl ?? "",
|
|
@@ -13636,7 +13754,9 @@ function registerWorkerProviderCommands(providersCmd) {
|
|
|
13636
13754
|
...opts.upstreamUrl ? { upstreamUrl: opts.upstreamUrl } : {},
|
|
13637
13755
|
...engine ? { engine } : {},
|
|
13638
13756
|
...opts.contextWindow ? { contextWindow: opts.contextWindow } : {},
|
|
13639
|
-
quotaProbe: opts.quotaProbe
|
|
13757
|
+
quotaProbe: opts.quotaProbe,
|
|
13758
|
+
...opts.costTier !== void 0 ? { costTier: opts.costTier } : {},
|
|
13759
|
+
...tags.length ? { tags } : {}
|
|
13640
13760
|
});
|
|
13641
13761
|
const { workers } = readWorkersSection();
|
|
13642
13762
|
console.log(ok$1(`provider ${name} added`));
|
|
@@ -13646,7 +13766,22 @@ function registerWorkerProviderCommands(providersCmd) {
|
|
|
13646
13766
|
fail$1(e);
|
|
13647
13767
|
}
|
|
13648
13768
|
});
|
|
13649
|
-
providersCmd.command("
|
|
13769
|
+
providersCmd.command("update <name>").description("Change cost tier and tags of a provider (routing constraints use these)").option("--cost-tier <1-5>", "Cost tier 1 (cheapest) … 5 (most expensive)", parseCostTier).option("--tags <tags>", "Capability tags, comma-separated (from: " + PROVIDER_TAGS.join(", ") + "); --tags '' clears", (v, acc) => [...acc, v], []).action((name, opts) => {
|
|
13770
|
+
try {
|
|
13771
|
+
if (opts.costTier === void 0 && opts.tags === void 0) throw new WorkersConfigError("nothing to update — pass --cost-tier and/or --tags");
|
|
13772
|
+
const tags = opts.tags === void 0 ? void 0 : collectTags(opts.tags);
|
|
13773
|
+
updateProvider(name, {
|
|
13774
|
+
...opts.costTier !== void 0 ? { costTier: opts.costTier } : {},
|
|
13775
|
+
...tags !== void 0 ? { tags } : {}
|
|
13776
|
+
});
|
|
13777
|
+
console.log(ok$1(`provider ${name} updated`));
|
|
13778
|
+
const { workers } = readWorkersSection();
|
|
13779
|
+
for (const line of describeProviders(workers)) console.log(dim$1(` ${line}`));
|
|
13780
|
+
} catch (e) {
|
|
13781
|
+
fail$1(e);
|
|
13782
|
+
}
|
|
13783
|
+
});
|
|
13784
|
+
providersCmd.command("remove <name>").description("Remove a provider and any classes pointing at it").action((name) => {
|
|
13650
13785
|
try {
|
|
13651
13786
|
removeProvider(name);
|
|
13652
13787
|
console.log(ok$1(`provider ${name} removed`));
|
|
@@ -13654,7 +13789,7 @@ function registerWorkerProviderCommands(providersCmd) {
|
|
|
13654
13789
|
fail$1(e);
|
|
13655
13790
|
}
|
|
13656
13791
|
});
|
|
13657
|
-
providersCmd.command("use <name>").description("Make this provider the active one for runs without --provider/--
|
|
13792
|
+
providersCmd.command("use <name>").description("Make this provider the active one for runs without --provider/--class").action((name) => {
|
|
13658
13793
|
try {
|
|
13659
13794
|
useProvider(name);
|
|
13660
13795
|
console.log(ok$1(`active provider: ${name}`));
|
|
@@ -13699,43 +13834,40 @@ function registerWorkerProviderCommands(providersCmd) {
|
|
|
13699
13834
|
}
|
|
13700
13835
|
});
|
|
13701
13836
|
}
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
const
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
const { workers } = readWorkersSection();
|
|
13715
|
-
const entries = Object.entries(workers.roles);
|
|
13716
|
-
if (!entries.length) {
|
|
13717
|
-
console.log(dim$1(" no roles set — runs use the active provider"));
|
|
13718
|
-
return;
|
|
13719
|
-
}
|
|
13720
|
-
for (const [role, target] of entries) console.log(` ${role.padEnd(12)} ${roleTargetText(target)}`);
|
|
13721
|
-
});
|
|
13722
|
-
rolesCmd.command("set <role> <provider[/alias]>").description("Point a role at a provider, optionally its fast model (e.g. glm/fast)").action((role, target) => {
|
|
13837
|
+
function printClasses() {
|
|
13838
|
+
const { workers } = readWorkersSection();
|
|
13839
|
+
const entries = Object.entries(workers.classes);
|
|
13840
|
+
if (!entries.length) {
|
|
13841
|
+
console.log(dim$1(" no classes set — runs use the active provider (or auto routing)"));
|
|
13842
|
+
return;
|
|
13843
|
+
}
|
|
13844
|
+
for (const [cls, target] of entries) console.log(` ${cls.padEnd(12)} ${classTargetText(target)}`);
|
|
13845
|
+
}
|
|
13846
|
+
function registerClassSubcommands(classesCmd) {
|
|
13847
|
+
classesCmd.command("list").description("List classes and their targets (default action)").action(() => printClasses());
|
|
13848
|
+
classesCmd.command("set <class> [target]").description("Point a class at a provider (or provider/fast), or give only constraints:\nclasses set research --max-cost-tier 2 --require-tags long-context,reasoning").option("--provider <name>", "Pin the class to this provider (object form)").option("--mcp <names>", "MCP servers/sets for runs of this class (comma-separated)").option("--max-cost-tier <1-5>", "Auto-routing considers only providers up to this cost tier", parseCostTier).option("--require-tags <tags>", "Auto-routing needs these tags (comma-separated)", (v) => v.split(",").map((s) => s.trim()).filter(Boolean)).option("--order <providers>", "Per-class routing order overriding workers.routing.order (comma-separated)").action((cls, target, opts) => {
|
|
13723
13849
|
try {
|
|
13724
|
-
|
|
13725
|
-
|
|
13850
|
+
const built = buildClassTarget(target, opts);
|
|
13851
|
+
setClass(cls, built);
|
|
13852
|
+
console.log(ok$1(`class ${cls} → ${classTargetText(built)}`));
|
|
13726
13853
|
} catch (e) {
|
|
13727
13854
|
fail$1(e);
|
|
13728
13855
|
}
|
|
13729
13856
|
});
|
|
13730
|
-
|
|
13857
|
+
classesCmd.command("unset <class>").description("Remove a class (runs then use the active provider)").action((cls) => {
|
|
13731
13858
|
try {
|
|
13732
|
-
|
|
13733
|
-
console.log(ok$1(`
|
|
13859
|
+
unsetClass(cls);
|
|
13860
|
+
console.log(ok$1(`class ${cls} removed`));
|
|
13734
13861
|
} catch (e) {
|
|
13735
13862
|
fail$1(e);
|
|
13736
13863
|
}
|
|
13737
13864
|
});
|
|
13738
13865
|
}
|
|
13866
|
+
/** `pai worker classes` — class → target assignment (roles is the old name). */
|
|
13867
|
+
function registerWorkerClassCommands(workerCmd) {
|
|
13868
|
+
registerClassSubcommands(workerCmd.command("classes").description("Classes: which provider serves draft / implement / review / …").action(() => printClasses()));
|
|
13869
|
+
registerClassSubcommands(workerCmd.command("roles", { hidden: true }).description("Alias of `classes` (roles was renamed to classes)").action(() => printClasses()));
|
|
13870
|
+
}
|
|
13739
13871
|
|
|
13740
13872
|
//#endregion
|
|
13741
13873
|
//#region src/cli/commands/worker/index.ts
|
|
@@ -13749,16 +13881,44 @@ function fail(e) {
|
|
|
13749
13881
|
process.exitCode = 1;
|
|
13750
13882
|
}
|
|
13751
13883
|
function registerWorkerCommands(workerCmd) {
|
|
13752
|
-
workerCmd.command("run").description("Run one claude-code worker through the configured provider.\nUnknown options are passed to claude verbatim (e.g. -p, --allowedTools);\n--output-format/--verbose are handled here.").allowUnknownOption(true).option("--provider <name>", "Provider to run on (default: active, else routing order)").option("--
|
|
13884
|
+
workerCmd.command("run").description("Run one claude-code worker through the configured provider.\nUnknown options are passed to claude verbatim (e.g. -p, --allowedTools);\n--output-format/--verbose are handled here.\n--chain draft,implement[,review] runs a spec-first pipeline;\n--agent <name> runs an agent definition from ~/.claude/agents.").allowUnknownOption(true).option("--provider <name>", "Provider to run on (default: active, else routing order)").option("--class <name>", "Use the provider of this class (draft, implement, review, research, spotcheck, simple, complex, image)").option("--role <name>", "Alias of --class (roles were renamed to classes)").option("--chain <stages>", "Comma-separated stage classes, e.g. draft,implement or draft,implement,review").option("--agent <name>", "Run the agent definition ~/.claude/agents/<name>.md on a worker").option("--model <model>", "Override the provider's model for this run").option("--label <text>", "Short task label shown in ps / follow / status line").option("--mcp <names>", "MCP servers/sets this worker may use (comma-separated; see `pai worker mcp`)").option("--no-pane", "Do not open a follow pane for this worker").option("--worktree", "Run in a git worktree on branch worker/<id> (default for implement/complex/plan in a git repo)").option("--no-worktree", "Run in place, no worktree").argument("[args...]", "claude arguments, e.g. -p '<task>' --allowedTools 'Read,Edit,Bash'").action(async (args, opts) => {
|
|
13753
13885
|
try {
|
|
13886
|
+
const className = opts.class ?? opts.role;
|
|
13887
|
+
let claudeArgs = args;
|
|
13888
|
+
let label = opts.label;
|
|
13889
|
+
let agentClass;
|
|
13890
|
+
if (opts.agent) {
|
|
13891
|
+
const def = loadAgent(opts.agent);
|
|
13892
|
+
claudeArgs = [...agentClaudeArgs(def), ...args];
|
|
13893
|
+
agentClass = modelToClass(def.model);
|
|
13894
|
+
if (!label) label = agentLabel(opts.agent, parseRunnerArgs(args).prompt);
|
|
13895
|
+
}
|
|
13896
|
+
if (opts.chain) {
|
|
13897
|
+
const brief = parseRunnerArgs(claudeArgs).prompt;
|
|
13898
|
+
if (!brief) throw new Error("--chain needs the task as -p '<brief>'");
|
|
13899
|
+
const rc = await runChain({
|
|
13900
|
+
stages: opts.chain.split(","),
|
|
13901
|
+
className: className ?? agentClass,
|
|
13902
|
+
providerFlag: opts.provider,
|
|
13903
|
+
modelFlag: opts.model,
|
|
13904
|
+
label,
|
|
13905
|
+
noPane: opts.pane === false,
|
|
13906
|
+
mcpFlag: opts.mcp,
|
|
13907
|
+
brief,
|
|
13908
|
+
claudeArgs
|
|
13909
|
+
});
|
|
13910
|
+
process.exitCode = rc;
|
|
13911
|
+
return;
|
|
13912
|
+
}
|
|
13754
13913
|
const rc = await runWorker({
|
|
13755
13914
|
providerFlag: opts.provider,
|
|
13756
|
-
|
|
13915
|
+
className: className ?? agentClass,
|
|
13757
13916
|
modelFlag: opts.model,
|
|
13758
|
-
label
|
|
13917
|
+
label,
|
|
13759
13918
|
mcpFlag: opts.mcp,
|
|
13760
13919
|
noPane: opts.pane === false,
|
|
13761
|
-
|
|
13920
|
+
worktreeFlag: opts.worktree,
|
|
13921
|
+
claudeArgs
|
|
13762
13922
|
});
|
|
13763
13923
|
process.exitCode = rc;
|
|
13764
13924
|
} catch (e) {
|
|
@@ -13799,13 +13959,13 @@ function registerWorkerCommands(workerCmd) {
|
|
|
13799
13959
|
process.exitCode = code ?? 1;
|
|
13800
13960
|
});
|
|
13801
13961
|
});
|
|
13802
|
-
workerCmd.command("pane [id]").description("Open the follow pane for a worker (or one shared pane for this session)").option("--check", "Only report whether the pane is open, plus the profile file's path and
|
|
13962
|
+
workerCmd.command("pane [id]").description("Open the follow pane for a worker (or one shared pane for this session)").option("--check", "Only report whether the pane is open, plus the profile file's path, font, and the hosting window's bounds").action(async (id, opts) => {
|
|
13803
13963
|
try {
|
|
13804
13964
|
const { workers } = readWorkersSection();
|
|
13805
13965
|
const logDir = currentLogDir();
|
|
13806
13966
|
const term = process.env.ITERM_SESSION_ID ?? "";
|
|
13807
13967
|
if (id) {
|
|
13808
|
-
const msg = opts.check ? await checkPaneForWorker(id, workers.pane.fontSize) : await openPaneForWorker(logDir, workers, id, term);
|
|
13968
|
+
const msg = opts.check ? await checkPaneForWorker(id, workers.pane.fontSize, term) : await openPaneForWorker(logDir, workers, id, term);
|
|
13809
13969
|
console.log(msg);
|
|
13810
13970
|
} else console.log(await openFollowPane(logDir, workers, term, opts.check === true));
|
|
13811
13971
|
} catch (e) {
|
|
@@ -13860,6 +14020,55 @@ function registerWorkerCommands(workerCmd) {
|
|
|
13860
14020
|
fail(e);
|
|
13861
14021
|
}
|
|
13862
14022
|
});
|
|
14023
|
+
workerCmd.command("handoff <json>").description("From inside a worker: append a handoff to the parent's inbox and (when it runs) say it to the parent.\nPayload: {\"kind\":\"proposal|question|blocker\",\"text\":\"…\",\"data\":{…}} — from/to come from the environment.").action(async (json) => {
|
|
14024
|
+
try {
|
|
14025
|
+
let payload;
|
|
14026
|
+
try {
|
|
14027
|
+
payload = JSON.parse(json);
|
|
14028
|
+
} catch {
|
|
14029
|
+
fail(/* @__PURE__ */ new Error(`payload is not JSON: ${json}`));
|
|
14030
|
+
return;
|
|
14031
|
+
}
|
|
14032
|
+
const h = await handoffFromInside(currentLogDir(), process.env, payload);
|
|
14033
|
+
console.log(`ok → ${h.to} (${h.kind}); inbox ${h.to}.inbox.jsonl`);
|
|
14034
|
+
} catch (e) {
|
|
14035
|
+
fail(e);
|
|
14036
|
+
}
|
|
14037
|
+
});
|
|
14038
|
+
workerCmd.command("merge <id>").description("Merge a worker's worktree branch (worker/<id>) into the original checkout, then remove the worktree").action((id) => {
|
|
14039
|
+
try {
|
|
14040
|
+
console.log(mergeWorker(currentLogDir(), id));
|
|
14041
|
+
} catch (e) {
|
|
14042
|
+
fail(e);
|
|
14043
|
+
}
|
|
14044
|
+
});
|
|
14045
|
+
workerCmd.command("discard <id>").description("Drop a worker's worktree and branch, keeping nothing").action((id) => {
|
|
14046
|
+
try {
|
|
14047
|
+
console.log(discardWorker(currentLogDir(), id));
|
|
14048
|
+
} catch (e) {
|
|
14049
|
+
fail(e);
|
|
14050
|
+
}
|
|
14051
|
+
});
|
|
14052
|
+
workerCmd.command("controls <id> <who>").description("Hand the desktop controls (clickr) to a worker or take them back.\n<who> is `you` (the worker may actuate) or `me` (the operator keeps them);\ninside a worker's pane, typing \"your controls\" does the same.").action((id, who) => {
|
|
14053
|
+
try {
|
|
14054
|
+
if (who !== "you" && who !== "me") {
|
|
14055
|
+
fail(/* @__PURE__ */ new Error(`<who> must be "you" or "me"`));
|
|
14056
|
+
return;
|
|
14057
|
+
}
|
|
14058
|
+
if (!loadStatus(currentLogDir(), id)) {
|
|
14059
|
+
fail(/* @__PURE__ */ new Error(`no worker named "${id}"`));
|
|
14060
|
+
return;
|
|
14061
|
+
}
|
|
14062
|
+
const proc = spawn("clickr", ["controls", who], { stdio: "inherit" });
|
|
14063
|
+
proc.on("error", (e) => fail(/* @__PURE__ */ new Error(`cannot run clickr controls: ${e.message} (is clickr installed?)`)));
|
|
14064
|
+
proc.on("close", (code) => {
|
|
14065
|
+
if (code === 0) console.log(`controls → ${who === "you" ? id : "operator"}`);
|
|
14066
|
+
process.exitCode = code ?? 1;
|
|
14067
|
+
});
|
|
14068
|
+
} catch (e) {
|
|
14069
|
+
fail(e);
|
|
14070
|
+
}
|
|
14071
|
+
});
|
|
13863
14072
|
workerCmd.command("resume <id> <text>").description("Continue a finished worker on the same provider: claude --resume <session>").option("--print-id", "Print the new worker id on its own line (pane follow handoff)").option("--no-pane", "Do not open a follow pane for the resumed worker").action(async (id, text, opts) => {
|
|
13864
14073
|
try {
|
|
13865
14074
|
const old = loadStatus(currentLogDir(), id);
|
|
@@ -13955,7 +14164,7 @@ function registerWorkerCommands(workerCmd) {
|
|
|
13955
14164
|
}
|
|
13956
14165
|
});
|
|
13957
14166
|
registerWorkerProviderCommands(workerCmd.command("providers").description("Providers: list, add, remove, use, enable, disable, test"));
|
|
13958
|
-
|
|
14167
|
+
registerWorkerClassCommands(workerCmd);
|
|
13959
14168
|
}
|
|
13960
14169
|
function parseIntArg(v) {
|
|
13961
14170
|
const n = parseInt(v, 10);
|
|
@@ -14326,7 +14535,7 @@ async function countVectorDbPaths(oldPaths) {
|
|
|
14326
14535
|
if (oldPaths.length === 0) return 0;
|
|
14327
14536
|
try {
|
|
14328
14537
|
const { loadConfig } = await import("./config-C_ErGddD.mjs");
|
|
14329
|
-
const { PostgresBackend } = await import("./postgres
|
|
14538
|
+
const { PostgresBackend } = await import("./postgres-mW1n7Vi1.mjs");
|
|
14330
14539
|
const config = loadConfig();
|
|
14331
14540
|
if (config.storageBackend !== "postgres") return 0;
|
|
14332
14541
|
const pgBackend = new PostgresBackend(config.postgres ?? {});
|
|
@@ -14347,7 +14556,7 @@ async function updateVectorDbPaths(moves) {
|
|
|
14347
14556
|
if (moves.length === 0) return 0;
|
|
14348
14557
|
try {
|
|
14349
14558
|
const { loadConfig } = await import("./config-C_ErGddD.mjs");
|
|
14350
|
-
const { PostgresBackend } = await import("./postgres
|
|
14559
|
+
const { PostgresBackend } = await import("./postgres-mW1n7Vi1.mjs");
|
|
14351
14560
|
const config = loadConfig();
|
|
14352
14561
|
if (config.storageBackend !== "postgres") return 0;
|
|
14353
14562
|
const pgBackend = new PostgresBackend(config.postgres ?? {});
|
|
@@ -15872,4 +16081,4 @@ claude() {
|
|
|
15872
16081
|
|
|
15873
16082
|
//#endregion
|
|
15874
16083
|
export { drainStdio as n, buildProgram as t };
|
|
15875
|
-
//# sourceMappingURL=program-
|
|
16084
|
+
//# sourceMappingURL=program-DXBwJV7h.mjs.map
|