@tekmidian/pai 0.42.1 → 0.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chain-B-DbR82m.mjs +164 -0
- package/dist/chain-B-DbR82m.mjs.map +1 -0
- package/dist/cli/index.mjs +8 -8
- package/dist/cli/program.mjs +8 -8
- package/dist/{config-Bi_F6lXf.mjs → config-_lQI_W08.mjs} +87 -3
- package/dist/config-_lQI_W08.mjs.map +1 -0
- package/dist/{context-handover-cache--bm6Siim.mjs → context-handover-cache-pNFdBNrU.mjs} +3 -3
- package/dist/{context-handover-cache--bm6Siim.mjs.map → context-handover-cache-pNFdBNrU.mjs.map} +1 -1
- package/dist/daemon/index.mjs +7 -7
- package/dist/{daemon-BOAPyL_b.mjs → daemon-Awt_3UJp.mjs} +7 -7
- package/dist/{daemon-DvXih78C.mjs → daemon-Dq8A1uDF.mjs} +587 -368
- package/dist/daemon-Dq8A1uDF.mjs.map +1 -0
- package/dist/daemon-mcp/index.mjs +5 -5
- package/dist/{fallback-8bzmg6No.mjs → fallback-vQPI1qxt.mjs} +14 -12
- package/dist/fallback-vQPI1qxt.mjs.map +1 -0
- package/dist/hooks/mcp-deferred-gate.mjs +286 -0
- package/dist/hooks/mcp-deferred-gate.mjs.map +7 -0
- package/dist/hooks/mcp-deferred-reminder.mjs +54 -0
- package/dist/hooks/mcp-deferred-reminder.mjs.map +7 -0
- package/dist/hooks/route-agents-to-worker.mjs +65 -2
- package/dist/hooks/route-agents-to-worker.mjs.map +2 -2
- package/dist/hooks/worker-proxy.mjs +64 -1
- package/dist/hooks/worker-proxy.mjs.map +2 -2
- package/dist/hooks/worker-status-line.mjs +64 -1
- package/dist/hooks/worker-status-line.mjs.map +2 -2
- package/dist/hooks/worker-supervision.mjs +64 -1
- package/dist/hooks/worker-supervision.mjs.map +2 -2
- package/dist/{main-resolver-CqppP_Bw.mjs → main-resolver-BAfOMppW.mjs} +2 -2
- package/dist/{main-resolver-Dip2VLB5.mjs → main-resolver-DnkxPYkr.mjs} +111 -16
- package/dist/main-resolver-DnkxPYkr.mjs.map +1 -0
- package/dist/{planner-ogy-Zy4O.mjs → planner-BfEGcEs1.mjs} +5 -5
- package/dist/{planner-ogy-Zy4O.mjs.map → planner-BfEGcEs1.mjs.map} +1 -1
- package/dist/{program-B7N5OIJR.mjs → program-BDmeZP-v.mjs} +17 -11
- package/dist/{program-B7N5OIJR.mjs.map → program-BDmeZP-v.mjs.map} +1 -1
- package/dist/{chain-DsvSHnO9.mjs → run-CGXbhf2k.mjs} +359 -163
- package/dist/run-CGXbhf2k.mjs.map +1 -0
- package/dist/{server-DvN-IFIV.mjs → server-D4vAieF4.mjs} +25 -6
- package/dist/server-D4vAieF4.mjs.map +1 -0
- package/dist/{state-BTa10SOM.mjs → state-BRdB-Bf1.mjs} +7 -2
- package/dist/state-BRdB-Bf1.mjs.map +1 -0
- package/dist/state-CY6I-Hnc.mjs +3 -0
- package/dist/{work-queue-worker-19r0cpH4.mjs → work-queue-worker-AEmfVE0F.mjs} +5 -5
- package/dist/{work-queue-worker-DXh_FnT5.mjs → work-queue-worker-DIT-VLSh.mjs} +3 -3
- package/dist/{work-queue-worker-DXh_FnT5.mjs.map → work-queue-worker-DIT-VLSh.mjs.map} +1 -1
- package/docs/cache-keepalive.md +82 -0
- package/docs/commands/worker.md +1 -0
- package/docs/provider-abstraction.md +52 -2
- package/package.json +1 -1
- package/plugins/core/hooks/hooks.json +12 -0
- package/src/hooks/ts/lib/mcp-deferred-gate.test.ts +258 -0
- package/src/hooks/ts/lib/mcp-deferred-gate.ts +261 -0
- package/src/hooks/ts/lib/mcp-deferred-reminder.test.ts +90 -0
- package/src/hooks/ts/lib/mcp-deferred-reminder.ts +66 -0
- package/src/hooks/ts/pre-tool-use/mcp-deferred-gate.ts +126 -0
- package/src/hooks/ts/pre-tool-use/route-agents-to-worker.ts +6 -2
- package/src/hooks/ts/session-start/mcp-deferred-reminder.ts +52 -0
- package/statusline-command.sh +149 -72
- package/dist/chain-DsvSHnO9.mjs.map +0 -1
- package/dist/config-Bi_F6lXf.mjs.map +0 -1
- package/dist/daemon-DvXih78C.mjs.map +0 -1
- package/dist/fallback-8bzmg6No.mjs.map +0 -1
- package/dist/main-resolver-Dip2VLB5.mjs.map +0 -1
- package/dist/scope-CfYnjy5R.mjs +0 -360
- package/dist/scope-CfYnjy5R.mjs.map +0 -1
- package/dist/server-DvN-IFIV.mjs.map +0 -1
- package/dist/state-BTa10SOM.mjs.map +0 -1
- package/dist/state-RXepvbnO.mjs +0 -3
|
@@ -131,6 +131,7 @@ var CONFIG_DIR = join(homedir(), ".config", "pai");
|
|
|
131
131
|
var CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
132
132
|
|
|
133
133
|
// src/workers/config.ts
|
|
134
|
+
var ANTHROPIC_NATIVE = "anthropic";
|
|
134
135
|
var MODEL_TIERS = ["haiku", "sonnet", "opus"];
|
|
135
136
|
var PROVIDER_TAGS = [
|
|
136
137
|
"code",
|
|
@@ -159,6 +160,7 @@ var DEFAULT_TREE = {
|
|
|
159
160
|
maxDepth: 2,
|
|
160
161
|
maxChildren: 4
|
|
161
162
|
};
|
|
163
|
+
var DEFAULT_CACHE_KEEPALIVE_SECS = 0;
|
|
162
164
|
var DEFAULT_MCP_SETS = {
|
|
163
165
|
desktop: ["clickr"]
|
|
164
166
|
};
|
|
@@ -173,6 +175,7 @@ function defaultWorkersConfig() {
|
|
|
173
175
|
logDir: DEFAULT_LOG_DIR,
|
|
174
176
|
routing: { ...DEFAULT_ROUTING2, order: [] },
|
|
175
177
|
tree: { ...DEFAULT_TREE },
|
|
178
|
+
cacheKeepaliveSecs: DEFAULT_CACHE_KEEPALIVE_SECS,
|
|
176
179
|
fallback: null
|
|
177
180
|
};
|
|
178
181
|
}
|
|
@@ -185,6 +188,12 @@ function str(v) {
|
|
|
185
188
|
return typeof v === "string" ? v : "";
|
|
186
189
|
}
|
|
187
190
|
function parseProvider(name, raw) {
|
|
191
|
+
if (name === ANTHROPIC_NATIVE) {
|
|
192
|
+
bad(
|
|
193
|
+
`.providers.${name}`,
|
|
194
|
+
`"${ANTHROPIC_NATIVE}" is reserved for plain Anthropic (Claude Code's own OAuth/Max-plan login) and cannot be configured here \u2014 remove this entry; use --provider ${ANTHROPIC_NATIVE} or "pai worker providers use ${ANTHROPIC_NATIVE}" instead`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
188
197
|
if (typeof raw !== "object" || raw === null) bad(`.providers.${name}`, "must be an object");
|
|
189
198
|
const p = raw;
|
|
190
199
|
const protocol = p.protocol === void 0 ? "anthropic" : str(p.protocol);
|
|
@@ -278,6 +287,51 @@ function parseProvider(name, raw) {
|
|
|
278
287
|
}
|
|
279
288
|
tags = p.tags;
|
|
280
289
|
}
|
|
290
|
+
let usage;
|
|
291
|
+
if (p.usage !== void 0) {
|
|
292
|
+
if (typeof p.usage !== "object" || p.usage === null || Array.isArray(p.usage)) {
|
|
293
|
+
bad(`.providers.${name}.usage`, "must be an object");
|
|
294
|
+
}
|
|
295
|
+
const u = p.usage;
|
|
296
|
+
const usageUrl = str(u.url);
|
|
297
|
+
if (!usageUrl) bad(`.providers.${name}.usage.url`, "is required");
|
|
298
|
+
if (!Array.isArray(u.windows) || u.windows.length === 0) {
|
|
299
|
+
bad(`.providers.${name}.usage.windows`, "must be a non-empty array");
|
|
300
|
+
}
|
|
301
|
+
const windows = [];
|
|
302
|
+
for (const [i, wRaw] of u.windows.entries()) {
|
|
303
|
+
const wpath = `.providers.${name}.usage.windows[${i}]`;
|
|
304
|
+
if (typeof wRaw !== "object" || wRaw === null || Array.isArray(wRaw)) {
|
|
305
|
+
bad(wpath, "must be an object");
|
|
306
|
+
}
|
|
307
|
+
const w = wRaw;
|
|
308
|
+
const wname = str(w.name);
|
|
309
|
+
if (!wname) bad(`${wpath}.name`, "is required");
|
|
310
|
+
const percent = str(w.percent);
|
|
311
|
+
if (!percent) bad(`${wpath}.percent`, "is required (a jq expression yielding 0\u2013100)");
|
|
312
|
+
const resetUnit = w.resetUnit === void 0 ? void 0 : str(w.resetUnit);
|
|
313
|
+
if (resetUnit !== void 0 && resetUnit !== "ms" && resetUnit !== "s" && resetUnit !== "iso") {
|
|
314
|
+
bad(`${wpath}.resetUnit`, `must be "ms", "s" or "iso"`);
|
|
315
|
+
}
|
|
316
|
+
windows.push({
|
|
317
|
+
name: wname,
|
|
318
|
+
percent,
|
|
319
|
+
...str(w.resetAt) ? { resetAt: str(w.resetAt) } : {},
|
|
320
|
+
...resetUnit ? { resetUnit } : {}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
const ttlSeconds = u.ttlSeconds === void 0 ? void 0 : u.ttlSeconds;
|
|
324
|
+
if (ttlSeconds !== void 0 && (typeof ttlSeconds !== "number" || ttlSeconds <= 0)) {
|
|
325
|
+
bad(`.providers.${name}.usage.ttlSeconds`, "must be a positive number of seconds");
|
|
326
|
+
}
|
|
327
|
+
usage = {
|
|
328
|
+
url: usageUrl,
|
|
329
|
+
...str(u.authHeader) ? { authHeader: str(u.authHeader) } : {},
|
|
330
|
+
...str(u.label) ? { label: str(u.label) } : {},
|
|
331
|
+
windows,
|
|
332
|
+
...ttlSeconds !== void 0 ? { ttlSeconds } : {}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
281
335
|
return {
|
|
282
336
|
enabled: p.enabled === void 0 ? true : p.enabled === true,
|
|
283
337
|
protocol,
|
|
@@ -293,7 +347,8 @@ function parseProvider(name, raw) {
|
|
|
293
347
|
...quotaSkipAt !== void 0 ? { quotaSkipAt } : {},
|
|
294
348
|
...contextWindow !== void 0 ? { contextWindow } : {},
|
|
295
349
|
...costTier !== void 0 ? { costTier } : {},
|
|
296
|
-
...tags ? { tags } : {}
|
|
350
|
+
...tags ? { tags } : {},
|
|
351
|
+
...usage ? { usage } : {}
|
|
297
352
|
};
|
|
298
353
|
}
|
|
299
354
|
function parseWorkersConfig(raw) {
|
|
@@ -445,6 +500,13 @@ function parseWorkersConfig(raw) {
|
|
|
445
500
|
maxChildren: t.maxChildren === void 0 ? DEFAULT_TREE.maxChildren : t.maxChildren
|
|
446
501
|
};
|
|
447
502
|
}
|
|
503
|
+
let cacheKeepaliveSecs = DEFAULT_CACHE_KEEPALIVE_SECS;
|
|
504
|
+
if (w.cacheKeepaliveSecs !== void 0) {
|
|
505
|
+
if (typeof w.cacheKeepaliveSecs !== "number" || !Number.isInteger(w.cacheKeepaliveSecs) || w.cacheKeepaliveSecs < 0) {
|
|
506
|
+
bad(".cacheKeepaliveSecs", "must be a non-negative integer (seconds, 0 = off)");
|
|
507
|
+
}
|
|
508
|
+
cacheKeepaliveSecs = w.cacheKeepaliveSecs;
|
|
509
|
+
}
|
|
448
510
|
const active = w.active === void 0 || w.active === null ? null : str(w.active);
|
|
449
511
|
if (active !== null && active !== "auto" && !(active in providers)) {
|
|
450
512
|
}
|
|
@@ -491,6 +553,7 @@ function parseWorkersConfig(raw) {
|
|
|
491
553
|
logDir: str(w.logDir) || d.logDir,
|
|
492
554
|
routing,
|
|
493
555
|
tree,
|
|
556
|
+
cacheKeepaliveSecs,
|
|
494
557
|
fallback
|
|
495
558
|
};
|
|
496
559
|
}
|