@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
|
@@ -132,6 +132,7 @@ var CONFIG_DIR = join(homedir(), ".config", "pai");
|
|
|
132
132
|
var CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
133
133
|
|
|
134
134
|
// src/workers/config.ts
|
|
135
|
+
var ANTHROPIC_NATIVE = "anthropic";
|
|
135
136
|
var MODEL_TIERS = ["haiku", "sonnet", "opus"];
|
|
136
137
|
var PROVIDER_TAGS = [
|
|
137
138
|
"code",
|
|
@@ -160,6 +161,7 @@ var DEFAULT_TREE = {
|
|
|
160
161
|
maxDepth: 2,
|
|
161
162
|
maxChildren: 4
|
|
162
163
|
};
|
|
164
|
+
var DEFAULT_CACHE_KEEPALIVE_SECS = 0;
|
|
163
165
|
var DEFAULT_MCP_SETS = {
|
|
164
166
|
desktop: ["clickr"]
|
|
165
167
|
};
|
|
@@ -174,6 +176,7 @@ function defaultWorkersConfig() {
|
|
|
174
176
|
logDir: DEFAULT_LOG_DIR,
|
|
175
177
|
routing: { ...DEFAULT_ROUTING2, order: [] },
|
|
176
178
|
tree: { ...DEFAULT_TREE },
|
|
179
|
+
cacheKeepaliveSecs: DEFAULT_CACHE_KEEPALIVE_SECS,
|
|
177
180
|
fallback: null
|
|
178
181
|
};
|
|
179
182
|
}
|
|
@@ -186,6 +189,12 @@ function str(v) {
|
|
|
186
189
|
return typeof v === "string" ? v : "";
|
|
187
190
|
}
|
|
188
191
|
function parseProvider(name, raw) {
|
|
192
|
+
if (name === ANTHROPIC_NATIVE) {
|
|
193
|
+
bad(
|
|
194
|
+
`.providers.${name}`,
|
|
195
|
+
`"${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`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
189
198
|
if (typeof raw !== "object" || raw === null) bad(`.providers.${name}`, "must be an object");
|
|
190
199
|
const p = raw;
|
|
191
200
|
const protocol = p.protocol === void 0 ? "anthropic" : str(p.protocol);
|
|
@@ -279,6 +288,51 @@ function parseProvider(name, raw) {
|
|
|
279
288
|
}
|
|
280
289
|
tags = p.tags;
|
|
281
290
|
}
|
|
291
|
+
let usage;
|
|
292
|
+
if (p.usage !== void 0) {
|
|
293
|
+
if (typeof p.usage !== "object" || p.usage === null || Array.isArray(p.usage)) {
|
|
294
|
+
bad(`.providers.${name}.usage`, "must be an object");
|
|
295
|
+
}
|
|
296
|
+
const u = p.usage;
|
|
297
|
+
const usageUrl = str(u.url);
|
|
298
|
+
if (!usageUrl) bad(`.providers.${name}.usage.url`, "is required");
|
|
299
|
+
if (!Array.isArray(u.windows) || u.windows.length === 0) {
|
|
300
|
+
bad(`.providers.${name}.usage.windows`, "must be a non-empty array");
|
|
301
|
+
}
|
|
302
|
+
const windows = [];
|
|
303
|
+
for (const [i, wRaw] of u.windows.entries()) {
|
|
304
|
+
const wpath = `.providers.${name}.usage.windows[${i}]`;
|
|
305
|
+
if (typeof wRaw !== "object" || wRaw === null || Array.isArray(wRaw)) {
|
|
306
|
+
bad(wpath, "must be an object");
|
|
307
|
+
}
|
|
308
|
+
const w = wRaw;
|
|
309
|
+
const wname = str(w.name);
|
|
310
|
+
if (!wname) bad(`${wpath}.name`, "is required");
|
|
311
|
+
const percent = str(w.percent);
|
|
312
|
+
if (!percent) bad(`${wpath}.percent`, "is required (a jq expression yielding 0\u2013100)");
|
|
313
|
+
const resetUnit = w.resetUnit === void 0 ? void 0 : str(w.resetUnit);
|
|
314
|
+
if (resetUnit !== void 0 && resetUnit !== "ms" && resetUnit !== "s" && resetUnit !== "iso") {
|
|
315
|
+
bad(`${wpath}.resetUnit`, `must be "ms", "s" or "iso"`);
|
|
316
|
+
}
|
|
317
|
+
windows.push({
|
|
318
|
+
name: wname,
|
|
319
|
+
percent,
|
|
320
|
+
...str(w.resetAt) ? { resetAt: str(w.resetAt) } : {},
|
|
321
|
+
...resetUnit ? { resetUnit } : {}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const ttlSeconds = u.ttlSeconds === void 0 ? void 0 : u.ttlSeconds;
|
|
325
|
+
if (ttlSeconds !== void 0 && (typeof ttlSeconds !== "number" || ttlSeconds <= 0)) {
|
|
326
|
+
bad(`.providers.${name}.usage.ttlSeconds`, "must be a positive number of seconds");
|
|
327
|
+
}
|
|
328
|
+
usage = {
|
|
329
|
+
url: usageUrl,
|
|
330
|
+
...str(u.authHeader) ? { authHeader: str(u.authHeader) } : {},
|
|
331
|
+
...str(u.label) ? { label: str(u.label) } : {},
|
|
332
|
+
windows,
|
|
333
|
+
...ttlSeconds !== void 0 ? { ttlSeconds } : {}
|
|
334
|
+
};
|
|
335
|
+
}
|
|
282
336
|
return {
|
|
283
337
|
enabled: p.enabled === void 0 ? true : p.enabled === true,
|
|
284
338
|
protocol,
|
|
@@ -294,7 +348,8 @@ function parseProvider(name, raw) {
|
|
|
294
348
|
...quotaSkipAt !== void 0 ? { quotaSkipAt } : {},
|
|
295
349
|
...contextWindow !== void 0 ? { contextWindow } : {},
|
|
296
350
|
...costTier !== void 0 ? { costTier } : {},
|
|
297
|
-
...tags ? { tags } : {}
|
|
351
|
+
...tags ? { tags } : {},
|
|
352
|
+
...usage ? { usage } : {}
|
|
298
353
|
};
|
|
299
354
|
}
|
|
300
355
|
function parseWorkersConfig(raw) {
|
|
@@ -446,6 +501,13 @@ function parseWorkersConfig(raw) {
|
|
|
446
501
|
maxChildren: t.maxChildren === void 0 ? DEFAULT_TREE.maxChildren : t.maxChildren
|
|
447
502
|
};
|
|
448
503
|
}
|
|
504
|
+
let cacheKeepaliveSecs = DEFAULT_CACHE_KEEPALIVE_SECS;
|
|
505
|
+
if (w.cacheKeepaliveSecs !== void 0) {
|
|
506
|
+
if (typeof w.cacheKeepaliveSecs !== "number" || !Number.isInteger(w.cacheKeepaliveSecs) || w.cacheKeepaliveSecs < 0) {
|
|
507
|
+
bad(".cacheKeepaliveSecs", "must be a non-negative integer (seconds, 0 = off)");
|
|
508
|
+
}
|
|
509
|
+
cacheKeepaliveSecs = w.cacheKeepaliveSecs;
|
|
510
|
+
}
|
|
449
511
|
const active = w.active === void 0 || w.active === null ? null : str(w.active);
|
|
450
512
|
if (active !== null && active !== "auto" && !(active in providers)) {
|
|
451
513
|
}
|
|
@@ -492,6 +554,7 @@ function parseWorkersConfig(raw) {
|
|
|
492
554
|
logDir: str(w.logDir) || d.logDir,
|
|
493
555
|
routing,
|
|
494
556
|
tree,
|
|
557
|
+
cacheKeepaliveSecs,
|
|
495
558
|
fallback
|
|
496
559
|
};
|
|
497
560
|
}
|