@tekmidian/pai 0.38.0 → 0.39.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/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-DUshcB-d.mjs → chain-CqlgL7uH.mjs} +734 -1410
- package/dist/chain-CqlgL7uH.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 +106 -3
- 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/fallback-DqYhiACU.mjs +1675 -0
- package/dist/fallback-DqYhiACU.mjs.map +1 -0
- package/dist/hooks/route-agents-to-worker.mjs +73 -8
- package/dist/hooks/route-agents-to-worker.mjs.map +2 -2
- package/dist/hooks/worker-proxy.mjs +71 -6
- package/dist/hooks/worker-proxy.mjs.map +2 -2
- package/dist/hooks/worker-status-line.mjs +137 -11
- 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-DGV8VFib.mjs +243 -0
- package/dist/planner-DGV8VFib.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-Y0hAiVy8.mjs → program-B-QJXCRb.mjs} +95 -19
- package/dist/{program-Y0hAiVy8.mjs.map → program-B-QJXCRb.mjs.map} +1 -1
- 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 +13 -0
- 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 +5 -0
- package/docs/commands/worker.md +74 -0
- package/docs/worker.md +132 -1
- 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/providers-DUshcB-d.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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as PaiClient } from "../ipc-client-BmypMNYk.mjs";
|
|
3
3
|
import { o as loadConfig } from "../config-B64vFg14.mjs";
|
|
4
|
-
import { A as
|
|
4
|
+
import { A as alive, B as ledgerPath, I as ledgerSummary, M as loadStatus, N as loadStatuses, V as workersLogDir, X as readWorkersSection, a as testProvider, g as sayToWorker, h as readInbox, i as runWorker, m as handoffFromInside, t as runChain } from "../chain-CqlgL7uH.mjs";
|
|
5
|
+
import { _ as replayOutput, a as addProvider, c as removeProvider, d as setWorkersEnabled, f as unsetClass, g as psOutput, i as fallbackStatusText, l as setClass, m as useProvider, n as fallbackOn, o as classTargetText, p as updateProvider, r as fallbackStatus, s as describeProviders, t as fallbackOff, u as setProviderEnabled } from "../fallback-DqYhiACU.mjs";
|
|
5
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
8
|
|
|
@@ -1220,6 +1221,10 @@ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
1220
1221
|
return payload;
|
|
1221
1222
|
};
|
|
1222
1223
|
});
|
|
1224
|
+
const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1225
|
+
$ZodType.init(inst, def);
|
|
1226
|
+
inst._zod.parse = (payload) => payload;
|
|
1227
|
+
});
|
|
1223
1228
|
function handleArrayResult(result, final, index) {
|
|
1224
1229
|
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1225
1230
|
final.value[index] = result.value;
|
|
@@ -2084,6 +2089,10 @@ function _boolean(Class, params) {
|
|
|
2084
2089
|
});
|
|
2085
2090
|
}
|
|
2086
2091
|
/* @__NO_SIDE_EFFECTS__ */
|
|
2092
|
+
function _unknown(Class) {
|
|
2093
|
+
return new Class({ type: "unknown" });
|
|
2094
|
+
}
|
|
2095
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2087
2096
|
function _lt(value, params) {
|
|
2088
2097
|
return new $ZodCheckLessThan({
|
|
2089
2098
|
check: "less_than",
|
|
@@ -2646,6 +2655,7 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
2646
2655
|
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
2647
2656
|
json.type = "boolean";
|
|
2648
2657
|
};
|
|
2658
|
+
const unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
2649
2659
|
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
2650
2660
|
const def = schema._zod.def;
|
|
2651
2661
|
const values = getEnumValues(def.entries);
|
|
@@ -3133,6 +3143,14 @@ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
|
3133
3143
|
function boolean(params) {
|
|
3134
3144
|
return _boolean(ZodBoolean, params);
|
|
3135
3145
|
}
|
|
3146
|
+
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
3147
|
+
$ZodUnknown.init(inst, def);
|
|
3148
|
+
ZodType.init(inst, def);
|
|
3149
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
|
|
3150
|
+
});
|
|
3151
|
+
function unknown() {
|
|
3152
|
+
return _unknown(ZodUnknown);
|
|
3153
|
+
}
|
|
3136
3154
|
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
3137
3155
|
$ZodArray.init(inst, def);
|
|
3138
3156
|
ZodType.init(inst, def);
|
|
@@ -4568,6 +4586,11 @@ pai worker run --label "short task label" --class research \\
|
|
|
4568
4586
|
only (max_cost_tier, require_tags) so auto-routing picks a qualifying provider.
|
|
4569
4587
|
- \`worker_run\` — start a worker or chain from chat; returns the id immediately.
|
|
4570
4588
|
- \`worker_toggle\` — off makes Agent subagents run on Anthropic again.
|
|
4589
|
+
- \`worker_fallback\` — machine-wide switch: every NEW Claude Code process
|
|
4590
|
+
(interactive, task-bus, daemon summarizer) runs on a worker provider until
|
|
4591
|
+
switched back. on writes the provider env + model pin into the Claude
|
|
4592
|
+
settings file (the token sits there until off), off restores it exactly,
|
|
4593
|
+
status lists running sessions and the note. Subagent routing is unchanged.
|
|
4571
4594
|
|
|
4572
4595
|
### Preferences from chat (map the phrase, use the tool, never mention files)
|
|
4573
4596
|
|
|
@@ -4579,6 +4602,14 @@ pai worker run --label "short task label" --class research \\
|
|
|
4579
4602
|
require_tags ["reasoning"] (drop the pin if one exists). One line.
|
|
4580
4603
|
- "what handles reviews" / "show the routing table" → worker_classes list
|
|
4581
4604
|
(plus worker_status for providers). One or two lines.
|
|
4605
|
+
- "switch everything to <provider>" / "fallback on" (plan exhausted, every
|
|
4606
|
+
new session must run on the worker provider) → worker_fallback on. Confirm
|
|
4607
|
+
with one line: provider, that running sessions keep their provider until
|
|
4608
|
+
restarted, and how to switch back.
|
|
4609
|
+
- "back to anthropic" / "fallback off" → worker_fallback off. One line: what
|
|
4610
|
+
was restored.
|
|
4611
|
+
- "is fallback on" / "are we on <provider>" → worker_fallback status. One or
|
|
4612
|
+
two lines.
|
|
4582
4613
|
- Never tell the user to edit a config file — the tools do it.`
|
|
4583
4614
|
};
|
|
4584
4615
|
|
|
@@ -5740,7 +5771,8 @@ async function startShim() {
|
|
|
5740
5771
|
});
|
|
5741
5772
|
server.tool("worker_status", [
|
|
5742
5773
|
"Show the worker system state: on/off, active provider, configured providers,",
|
|
5743
|
-
"roles,
|
|
5774
|
+
"roles, today's run tally from the ledger, and the running workers with",
|
|
5775
|
+
"their inbox counts (◆N = handoffs waiting).",
|
|
5744
5776
|
"",
|
|
5745
5777
|
"Use this before delegating with `pai worker run` to see what routing will choose."
|
|
5746
5778
|
].join("\n"), {}, async () => {
|
|
@@ -5748,12 +5780,20 @@ async function startShim() {
|
|
|
5748
5780
|
const { workers } = readWorkersSection();
|
|
5749
5781
|
const s = ledgerSummary(ledgerPath(workersLogDir(workers)), "all", 10);
|
|
5750
5782
|
const tally = s ? [`runs ${s.scope}: ${s.started} started, ${s.endedOk} ok, ${s.endedFailed} failed`, `agent hook: ${s.denied} denied, ${s.allowed} allowed, ${s.reroutes} reroutes`] : ["no runs recorded yet"];
|
|
5783
|
+
const logDir = workersLogDir(workers);
|
|
5784
|
+
const running = loadStatuses(logDir).filter((w) => w.state === "running" && alive(w.pid));
|
|
5785
|
+
const runningLines = running.length ? [
|
|
5786
|
+
"",
|
|
5787
|
+
`running (${running.length}):`,
|
|
5788
|
+
...running.map((w) => ` ${w.id} ${w.label}${w.parent ? ` (sub-worker of ${w.parent})` : ""} · ${w.last}` + (readInbox(logDir, w.id).length ? ` · ◆${readInbox(logDir, w.id).length}` : ""))
|
|
5789
|
+
] : [];
|
|
5751
5790
|
return workerText([
|
|
5752
5791
|
`workers: ${workers.enabled ? "on" : "off"}`,
|
|
5753
5792
|
`active provider: ${workers.active ?? "(none)"}`,
|
|
5754
5793
|
...describeProviders(workers),
|
|
5755
5794
|
"",
|
|
5756
|
-
...tally
|
|
5795
|
+
...tally,
|
|
5796
|
+
...runningLines
|
|
5757
5797
|
].join("\n"));
|
|
5758
5798
|
} catch (e) {
|
|
5759
5799
|
return workerError(e);
|
|
@@ -5861,6 +5901,44 @@ async function startShim() {
|
|
|
5861
5901
|
return workerError(e);
|
|
5862
5902
|
}
|
|
5863
5903
|
});
|
|
5904
|
+
server.tool("worker_fallback", [
|
|
5905
|
+
"Machine-wide fallback: switch every NEW Claude Code process on this",
|
|
5906
|
+
"machine (interactive, task-bus, daemon summarizer) to a worker provider,",
|
|
5907
|
+
"or back to the Anthropic login.",
|
|
5908
|
+
"",
|
|
5909
|
+
"action=on switches (provider optional, default: active) by writing the",
|
|
5910
|
+
"provider's env into ~/.claude/settings.json — the token is read from its",
|
|
5911
|
+
"key file and then sits in settings.json until off. action=off restores",
|
|
5912
|
+
"settings.json exactly. action=status (default) shows on/off, provider,",
|
|
5913
|
+
"running sessions and the FALLBACK-ACTIVE.md note. Running sessions keep",
|
|
5914
|
+
"their provider until restarted. CLAUDE_SETTINGS_PATH retargets settings",
|
|
5915
|
+
"for dry runs. Subagent routing is unchanged while on."
|
|
5916
|
+
].join("\n"), {
|
|
5917
|
+
action: _enum([
|
|
5918
|
+
"on",
|
|
5919
|
+
"off",
|
|
5920
|
+
"status"
|
|
5921
|
+
]).optional().describe("Default: status."),
|
|
5922
|
+
provider: string().optional().describe("Provider to switch to (on). Default: active.")
|
|
5923
|
+
}, async (args) => {
|
|
5924
|
+
try {
|
|
5925
|
+
const action = args.action ?? "status";
|
|
5926
|
+
if (action === "status") return workerText(fallbackStatusText(fallbackStatus()).join("\n"));
|
|
5927
|
+
if (action === "on") {
|
|
5928
|
+
const r = fallbackOn(args.provider);
|
|
5929
|
+
return workerText([
|
|
5930
|
+
r.alreadyOn ? `fallback already on — provider ${r.provider}, env re-applied` : `fallback on — provider ${r.provider}; every new Claude Code process uses it`,
|
|
5931
|
+
`settings.json env: ${r.envKeys.join(", ")}`,
|
|
5932
|
+
`model pin: ${r.model}`,
|
|
5933
|
+
"running sessions keep their current provider until restarted"
|
|
5934
|
+
].join("\n"));
|
|
5935
|
+
}
|
|
5936
|
+
const r = fallbackOff();
|
|
5937
|
+
return workerText(`fallback off — provider ${r.provider} released, settings.json restored (${r.envKeys.join(", ")})`);
|
|
5938
|
+
} catch (e) {
|
|
5939
|
+
return workerError(e);
|
|
5940
|
+
}
|
|
5941
|
+
});
|
|
5864
5942
|
server.tool("worker_classes", [
|
|
5865
5943
|
"Manage worker classes (list, set, unset).",
|
|
5866
5944
|
"",
|
|
@@ -5974,6 +6052,31 @@ async function startShim() {
|
|
|
5974
6052
|
return workerError(e);
|
|
5975
6053
|
}
|
|
5976
6054
|
});
|
|
6055
|
+
server.tool("worker_handoff", [
|
|
6056
|
+
"From inside a worker: send a handoff up to the parent worker.",
|
|
6057
|
+
"",
|
|
6058
|
+
"kind: proposal (do this instead of me), question, blocker, or result",
|
|
6059
|
+
"(results are sent for you when you finish — only send one yourself for",
|
|
6060
|
+
"mid-run findings). The handoff lands in the parent's inbox and is said to",
|
|
6061
|
+
"it when it is still running. Outside a worker this fails — there is no",
|
|
6062
|
+
"sideways or downward path."
|
|
6063
|
+
].join("\n"), {
|
|
6064
|
+
kind: _enum([
|
|
6065
|
+
"proposal",
|
|
6066
|
+
"result",
|
|
6067
|
+
"question",
|
|
6068
|
+
"blocker"
|
|
6069
|
+
]).describe("What the handoff carries."),
|
|
6070
|
+
text: string().min(1).describe("The message body, one paragraph."),
|
|
6071
|
+
data: record(string(), unknown()).optional().describe("Structured payload (optional).")
|
|
6072
|
+
}, async (args) => {
|
|
6073
|
+
try {
|
|
6074
|
+
const h = await handoffFromInside(workersLogDir(readWorkersSection().workers), process.env, args);
|
|
6075
|
+
return workerText(`ok → ${h.to} (${h.kind}); the parent sees it in its inbox`);
|
|
6076
|
+
} catch (e) {
|
|
6077
|
+
return workerError(e);
|
|
6078
|
+
}
|
|
6079
|
+
});
|
|
5977
6080
|
server.tool("worker_toggle", [
|
|
5978
6081
|
"Turn worker routing on or off.",
|
|
5979
6082
|
"",
|