@tekmidian/pai 1.0.0 → 1.0.3
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/.claude-plugin/plugin.json +1 -1
- package/README.md +67 -5
- package/dist/aibroker-client-BxzeEHPF.mjs +3 -0
- package/dist/{aibroker-client-CXEYBzbf.mjs → aibroker-client-CQPGqLxL.mjs} +1 -1
- package/dist/atomic-file-BorMa4T3.mjs +21 -0
- package/dist/{auto-route-D5SXrMpB.mjs → auto-route-B7Yu6Uam.mjs} +3 -3
- package/dist/auto-route-CjjQqU1o.mjs +11 -0
- package/dist/budget-Dod6rnA9.mjs +15 -0
- package/dist/{caller-identity-CVTuiLSs.mjs → caller-identity-yLFb7CKq.mjs} +6 -5
- package/dist/{capacity-DaXrVj3J.mjs → capacity-DEveQdFV.mjs} +3 -3
- package/dist/{chain-BcQlIlEd.mjs → chain-7n9Gx56r.mjs} +5 -5
- package/dist/cli/index.mjs +1628 -370
- package/dist/{cockpit-actions-ODmt8yF9.mjs → cockpit-actions-BBHeyEZI.mjs} +84 -42
- package/dist/cockpit-actions-DR9X514g.mjs +20 -0
- package/dist/cockpit-memory--dnShXBA.mjs +20 -0
- package/dist/{config-BSXKyeJ1.mjs → config-Bu1_vbY8.mjs} +42 -3
- package/dist/{config-B955yYmo.mjs → config-Cxi-aBf4.mjs} +2 -2
- package/dist/{config-TaWmdTLx.mjs → config-DtENJ6cL.mjs} +1 -1
- package/dist/{config-D5chi2LO.mjs → config-XpZWOYOG.mjs} +2 -2
- package/dist/{controls-BGkK_Bdi.mjs → controls-CPoeudou.mjs} +37 -22
- package/dist/daemon/index.mjs +43 -42
- package/dist/daemon-DKdBNKfa.mjs +45 -0
- package/dist/{daemon-CorGh6Ub.mjs → daemon-DPAo6WTa.mjs} +103 -55
- package/dist/daemon-mcp/index.mjs +40 -39
- package/dist/{define-DGFu-sCf.mjs → define-CjJsmq-6.mjs} +1 -1
- package/dist/{detect-C1d5cUkT.mjs → detect-9CZNO0yf.mjs} +2 -2
- package/dist/detect-D1ziFFfA.mjs +10 -0
- package/dist/{embed-pass-CeQD8kRE.mjs → embed-pass-DIWjA68P.mjs} +5 -5
- package/dist/{embedding-gate-BHuBsgHD.mjs → embedding-gate-6rZrWRXa.mjs} +5 -5
- package/dist/{embedding-gate-Z7CJSOJk.mjs → embedding-gate-Cnk4YCyX.mjs} +3 -3
- package/dist/{embeddings-D4t6L-EH.mjs → embeddings-BVq3esBF.mjs} +1 -1
- package/dist/{embeddings-OF9Pt4by.mjs → embeddings-CIkJBKd-.mjs} +1 -1
- package/dist/{endreason-x1KOSrcO.mjs → endreason-C577xIQz.mjs} +7 -6
- package/dist/{env-DArqGq-Z.mjs → env-BE8mrsxr.mjs} +1 -1
- package/dist/factory-Bsib-qDG.mjs +9 -0
- package/dist/{factory-BtjbQ0np.mjs → factory-DjAAsqr_.mjs} +15 -13
- package/dist/{fallback-BIyEpPsQ.mjs → fallback-DFlItw1Z.mjs} +5 -5
- package/dist/{fmt-age-BiSHrTKN.mjs → fmt-age-ByDkvkoU.mjs} +1 -1
- package/dist/{health-C6jZWvRG.mjs → health-Dnym-qcT.mjs} +4 -4
- package/dist/{helpers-DFmYRCOa.mjs → helpers-BD6V-p9w.mjs} +2 -2
- package/dist/helpers-CMGjy_0N.mjs +10 -0
- package/dist/{helpers-CJpb_MNB.mjs → helpers-CRuBUas3.mjs} +87 -38
- package/dist/hooks/capture-all-events.mjs +52 -11
- package/dist/hooks/capture-session-summary.mjs +64 -47
- package/dist/hooks/capture-tool-output.mjs +49 -8
- package/dist/hooks/context-compression-hook.mjs +30 -10
- package/dist/hooks/initialize-session.mjs +1 -0
- package/dist/hooks/load-core-context.mjs +1 -1
- package/dist/hooks/load-project-context.mjs +32 -29
- package/dist/hooks/security-validator.mjs +45 -13
- package/dist/hooks/stop-hook.mjs +54 -16
- package/dist/hooks/supervision-banner.mjs +9 -0
- package/dist/hooks/sync-todo-to-md.mjs +147 -113
- package/dist/hooks/worker-edit-repair.mjs +2 -1
- package/dist/hooks/worker-guard.mjs +40 -16
- package/dist/hooks/worker-note.mjs +12 -5
- package/dist/hooks/worker-path-repair.mjs +1 -1
- package/dist/hooks/worker-pool-host.mjs +329 -231
- package/dist/hooks/worker-status-line.mjs +195 -114
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +12 -12
- package/dist/{indexer-backend-BM2CUSu8.mjs → indexer-backend-Cll7le4P.mjs} +149 -96
- package/dist/{ipc-client-BMqWw_gv.mjs → ipc-client-CaiGJnSM.mjs} +1 -1
- package/dist/{ipc-client-YYDD6zzU.mjs → ipc-client-ZRmDKd5Z.mjs} +1 -1
- package/dist/kill-tree-BG7dRVtp.mjs +10 -0
- package/dist/{kill-tree-BjYz5BxK.mjs → kill-tree-EWYaEk5v.mjs} +8 -8
- package/dist/{launch-CLp0OJxV.mjs → launch-CXVlZjHt.mjs} +8 -8
- package/dist/{launch-DgqQdAjI.mjs → launch-Jh5NVeNe.mjs} +3 -3
- package/dist/local-candidate-DLdwQt0s.mjs +112 -0
- package/dist/local-instances-DOxSgT_L.mjs +210 -0
- package/dist/local-instances-ZeRkkuS5.mjs +6 -0
- package/dist/{local-tiers-DPZYqv9m.mjs → local-tiers-BE4jGaMa.mjs} +2 -2
- package/dist/{local-tiers-DnBIAkbK.mjs → local-tiers-DNMI5W86.mjs} +3 -3
- package/dist/{main-config-ops-C0SflOWk.mjs → main-config-ops-BEMpuhDz.mjs} +3 -3
- package/dist/{main-resolver-DVPpSWVy.mjs → main-resolver-3Ns1HPmS.mjs} +18 -17
- package/dist/{migrate-BUJHadA8.mjs → migrate-DrA_OwlZ.mjs} +45 -14
- package/dist/min-max-DrSRUaWQ.mjs +16 -0
- package/dist/{model-inventory-Dasber3S.mjs → model-inventory-BFVSNFT3.mjs} +13 -12
- package/dist/{models-add-Bt7aUHDs.mjs → models-add-C1QIc1DA.mjs} +39 -38
- package/dist/operator-BTqvTIc8.mjs +7 -0
- package/dist/{operator-DZxcP-g8.mjs → operator-CyuB3aVw.mjs} +3 -3
- package/dist/{pai-marker-kIYuNt3c.mjs → pai-marker-BcZyJguM.mjs} +7 -6
- package/dist/{pane-audit-OGYrOAik.mjs → pane-audit-DKQt71s4.mjs} +7 -7
- package/dist/{paths-DoRuFc60.mjs → paths-CFHTloSe.mjs} +3 -3
- package/dist/{paths-DoIyRnhx.mjs → paths-CHifubDh.mjs} +3 -3
- package/dist/{planner-DLGOYlVb.mjs → planner-BmFACdLa.mjs} +31 -30
- package/dist/{pool-CZ5MZaXg.mjs → pool-Dh-q3iJi.mjs} +45 -6
- package/dist/{pool-cli-BxNSPzzY.mjs → pool-cli-BggU8GRp.mjs} +5 -5
- package/dist/{pool-cli-CbJfl37y.mjs → pool-cli-DQ6OzRy2.mjs} +6 -6
- package/dist/postgres-BdBNkL_l.mjs +7 -0
- package/dist/{postgres-CDnd_k5f.mjs → postgres-C6ti4haA.mjs} +55 -34
- package/dist/{project-setup-DM4npnL3.mjs → project-setup-jvfONJTQ.mjs} +131 -74
- package/dist/providers-BeDiVEb-.mjs +16 -0
- package/dist/{providers-UsKtLcUR.mjs → providers-CblTFrhz.mjs} +6 -6
- package/dist/{query-feedback-I-txSnld.mjs → query-feedback-BRfPtqki.mjs} +2 -2
- package/dist/registrable-BzH4TObg.mjs +9 -0
- package/dist/{registrable-LrRIVYQc.mjs → registrable-DpyTtajg.mjs} +4 -4
- package/dist/{render-BDbb4CF-.mjs → render-BYmQkuLd.mjs} +8 -8
- package/dist/render-CoMvwMPs.mjs +13 -0
- package/dist/{reranker-B4r4vykM.mjs → reranker-8g6xMwP7.mjs} +1 -1
- package/dist/{reranker-DxxMCtA0.mjs → reranker-CqCbpGnX.mjs} +1 -1
- package/dist/root-FtJsxYnm.mjs +36 -0
- package/dist/{root-BMeJuHOb.mjs → root-Xglu0OPD.mjs} +11 -11
- package/dist/route-table-B7zpoypi.mjs +15 -0
- package/dist/{router-L8Nu-OHF.mjs → router-CQSc3lk3.mjs} +17 -7
- package/dist/{router-D6Ec6Fid.mjs → router-DwHJRgG9.mjs} +1 -1
- package/dist/{routing-CUyiglfu.mjs → routing-BAAST9vT.mjs} +27 -308
- package/dist/{routing-ZuGlc0ge.mjs → routing-CENt4HH1.mjs} +13 -12
- package/dist/{run-ulAi5dFD.mjs → run-CSC7mgPf.mjs} +35 -33
- package/dist/{scan-B7I0gPe-.mjs → scan-C_Y5W9py.mjs} +6 -6
- package/dist/{local-candidate-jOjTNlOL.mjs → scheduler-CtUyWJ3O.mjs} +7 -109
- package/dist/scheduler-dmHXoRvm.mjs +3 -0
- package/dist/{scope-D5VSQxe4.mjs → scope-D-h6F6DN.mjs} +4 -4
- package/dist/{search-CPoE0830.mjs → search-RSyeQqj1.mjs} +18 -18
- package/dist/{session-CNXF6DLP.mjs → session-8iqQDkqb.mjs} +55 -31
- package/dist/session-BeqAbNPd.mjs +35 -0
- package/dist/session-scan-BJI_ZO8M.mjs +9 -0
- package/dist/{session-scan-BDLEc4w1.mjs → session-scan-W-gbwJHM.mjs} +6 -6
- package/dist/{sources-CjhUKKtO.mjs → sources-ESUkZaWv.mjs} +1 -1
- package/dist/{status-DYydKQUI.mjs → status-Dm4dYciN.mjs} +4 -4
- package/dist/{status-CvVi9cDf.mjs → status-ggJ7lgVg.mjs} +17 -9
- package/dist/{stop-words-SdSL1WKH.mjs → stop-words-DSEYQdNe.mjs} +1 -1
- package/dist/{test-isolation-CoDeOVXb.mjs → test-isolation-lqSmYxr0.mjs} +1 -1
- package/dist/{timeouts-OwEONmc8.mjs → timeouts-1MLooEBB.mjs} +1 -1
- package/dist/{tool-errors-AeRQuG3Y.mjs → tool-errors-7E13StWd.mjs} +4 -3
- package/dist/{tool-errors-R5E0fCgf.mjs → tool-errors-CJWODvlo.mjs} +6 -6
- package/dist/viewer-CqozWW39.mjs +22 -0
- package/dist/{viewer-DtWj5Vti.mjs → viewer-mDXUNHNy.mjs} +15 -15
- package/dist/{wait-BMUR-U-U.mjs → wait-ByV0OyMZ.mjs} +3 -3
- package/dist/{worker-config-BLqa1yiD.mjs → worker-config-CJhEMk19.mjs} +294 -92
- package/dist/worker-config-DESkIjMF.mjs +41 -0
- package/dist/{workers-config-DEI9lrV4.mjs → workers-config-f8KrkY4L.mjs} +2 -2
- package/dist/{worktree-zmRf556h.mjs → worktree-CRs2gyg0.mjs} +37 -7
- package/dist/{zettelkasten-nigq7fqs.mjs → zettelkasten-B_rRRRvD.mjs} +5 -5
- package/dist/{zettelkasten-Cr_Xj0mG.mjs → zettelkasten-BzMm8REH.mjs} +29 -19
- package/docs/README.md +2 -0
- package/docs/cockpit.md +10 -4
- package/docs/commands/README.md +4 -4
- package/docs/commands/backup.md +2 -0
- package/docs/commands/install.md +29 -4
- package/docs/commands/providers.md +1 -1
- package/docs/commands/restore.md +4 -0
- package/docs/commands/setup.md +29 -4
- package/docs/commands/worker.md +1 -1
- package/docs/config.md +2 -0
- package/docs/features.md +299 -0
- package/docs/images/architecture.drawio +51 -0
- package/docs/images/architecture.png +0 -0
- package/docs/images/architecture.svg +3 -0
- package/docs/images/cockpit-01-system-tokens.jpg +0 -0
- package/docs/images/cockpit-02-totals-cache.jpg +0 -0
- package/docs/images/cockpit-03-local-servers-models-pool.jpg +0 -0
- package/docs/images/cockpit-04-workers-memory.jpg +0 -0
- package/docs/images/cockpit-05-performance.jpg +0 -0
- package/docs/images/cockpit-06-runs-speed-routing.jpg +0 -0
- package/docs/images/cockpit-07-settings-registry.jpg +0 -0
- package/docs/install/index.md +29 -0
- package/docs/three-tier-coding.md +1 -1
- package/gemini-extension.json +1 -1
- package/package.json +1 -5
- package/pai-plugin.json +1 -1
- package/plugins/context-preservation/plugin.json +1 -1
- package/plugins/core/plugin.json +1 -1
- package/plugins/core/skills/setup/SKILL.md +41 -9
- package/plugins/creative/plugin.json +1 -1
- package/plugins/observability/plugin.json +1 -1
- package/plugins/productivity/plugin.json +1 -1
- package/plugins/semantic-search/plugin.json +1 -1
- package/plugins/ui/plugin.json +1 -1
- package/plugins/zettelkasten/plugin.json +1 -1
- package/src/hooks/session-autosave.sh +8 -1
- package/src/hooks/session-stop.sh +8 -1
- package/src/hooks/ts/capture-all-events.ts +7 -12
- package/src/hooks/ts/lib/context-fill.ts +2 -1
- package/src/hooks/ts/lib/path-repair.ts +1 -1
- package/src/hooks/ts/lib/project-utils/notify.ts +1 -0
- package/src/hooks/ts/lib/project-utils/session-notes.ts +23 -6
- package/src/hooks/ts/lib/raw-capture.ts +36 -0
- package/src/hooks/ts/lib/session-summary.ts +129 -0
- package/src/hooks/ts/lib/todo-sync.ts +120 -0
- package/src/hooks/ts/lib/worker-git-guard.ts +1 -1
- package/src/hooks/ts/post-tool-use/capture-tool-output.ts +6 -10
- package/src/hooks/ts/post-tool-use/sync-todo-to-md.ts +5 -105
- package/src/hooks/ts/pre-compact/context-compression-hook.ts +1 -1
- package/src/hooks/ts/pre-tool-use/security-validator.ts +35 -14
- package/src/hooks/ts/session-end/capture-session-summary.ts +20 -128
- package/src/hooks/ts/session-start/load-core-context.ts +3 -3
- package/src/hooks/ts/session-start/load-project-context.ts +18 -22
- package/src/hooks/ts/stop/stop-hook.ts +13 -5
- package/src/hooks/ztk-auto.sh +7 -2
- package/dist/aibroker-client-JjE74jo0.mjs +0 -3
- package/dist/auto-route-BRk8NEFv.mjs +0 -11
- package/dist/budget-DuhQ2zzG.mjs +0 -14
- package/dist/cockpit-actions-DcQ-ucU8.mjs +0 -19
- package/dist/cockpit-memory-KV45PPO2.mjs +0 -19
- package/dist/daemon-C7yt_ptC.mjs +0 -44
- package/dist/detect-DRUkmHnb.mjs +0 -10
- package/dist/factory-DAGG9_n8.mjs +0 -9
- package/dist/helpers-DPJEHPq6.mjs +0 -10
- package/dist/kill-tree-LV0Q7Mte.mjs +0 -10
- package/dist/operator-CfL0HiBK.mjs +0 -7
- package/dist/postgres-DgqWyqhN.mjs +0 -7
- package/dist/providers-CTu2s1z2.mjs +0 -15
- package/dist/registrable-D9aNZOTh.mjs +0 -9
- package/dist/render-BSfVlYHj.mjs +0 -13
- package/dist/root-xI9DqVIe.mjs +0 -35
- package/dist/route-table-HjvnLVEU.mjs +0 -14
- package/dist/session-BJHzmUg2.mjs +0 -34
- package/dist/session-scan-YORKE1NO.mjs +0 -9
- package/dist/viewer-B8709jDN.mjs +0 -22
- package/dist/worker-config-D8tRuvo7.mjs +0 -40
- package/docs/images/cockpit-limits-routing.jpg +0 -0
- package/docs/images/cockpit-models.jpg +0 -0
- package/docs/images/cockpit-usage.jpg +0 -0
- package/docs/images/cockpit-workers-system.jpg +0 -0
- package/scripts/build-docs.mjs +0 -41
- package/scripts/build-hooks.mjs +0 -311
- package/scripts/build-skill-stubs.mjs +0 -216
- package/scripts/copy-defaults.mjs +0 -46
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { g as paiHomePath, h as paiHomeDir } from "./runtime-paths-WsO9sJFc.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import { t as writeFileAtomic } from "./atomic-file-BorMa4T3.mjs";
|
|
3
|
+
import { A as providerQuotaSkipAt, F as writeWorkersSection, L as isLoopbackHostname, M as resolveCapability, N as resolveModelCapability, O as providerCostTier, P as resolveProviderKey, R as isLoopbackUrl$1, at as MAX_ROUTE_MODELS, b as nativeOrchestratorModel, c as WorkersConfigError, ct as entryProvider, dt as migrateSessionRoutes, ft as parseEntry, j as readWorkersSection, lt as findTier, m as isLocalProvider, mt as targetList, p as getProviderOrNative, pt as sessionTier, s as WORKER_CLASSES, st as classRoute, t as ANTHROPIC_NATIVE, tt as workersYamlPath, u as classModelCapability, ut as listForPolicy, vt as stripModelVariant, y as nativeAnthropicProvider, z as loopbackUrl$1 } from "./config-XpZWOYOG.mjs";
|
|
4
|
+
import { c as loadConfig, f as readMainConfigRaw } from "./config-Bu1_vbY8.mjs";
|
|
5
|
+
import { s as routingStatePath, u as workersLogDir } from "./paths-CHifubDh.mjs";
|
|
6
|
+
import { g as isLive, v as loadStatus, y as loadStatuses } from "./status-ggJ7lgVg.mjs";
|
|
7
|
+
import { o as resolveSession, p as currentWorkerId, t as AIBROKER_REGISTRY } from "./scope-D-h6F6DN.mjs";
|
|
8
|
+
import { x as recordToolError } from "./tool-errors-7E13StWd.mjs";
|
|
9
|
+
import { _ as readLocalConfig, d as installedModelDirs, p as logPathFor } from "./local-tiers-BE4jGaMa.mjs";
|
|
10
|
+
import { a as buildsDir, l as listBuildsSync, t as callerIdentity } from "./caller-identity-yLFb7CKq.mjs";
|
|
11
|
+
import { a as newPrefill, c as schedEnabled, f as sharedScheduler } from "./scheduler-CtUyWJ3O.mjs";
|
|
12
|
+
import { i as effectiveCap } from "./capacity-DEveQdFV.mjs";
|
|
13
|
+
import { i as instanceNumber, l as readInstances, r as instanceEngineKey, s as pickInstance, t as endpointRegistry, u as readLiveInstances } from "./local-instances-DOxSgT_L.mjs";
|
|
14
|
+
import { c as writeLocalStatus, n as tierProviderNames, r as LOCAL_STATUS_REFRESH_MS, s as readLocalStatus, t as isLocalCandidate } from "./local-candidate-DLdwQt0s.mjs";
|
|
15
|
+
import { t as LOCAL_PROBE_TIMEOUT_MS } from "./timeouts-1MLooEBB.mjs";
|
|
13
16
|
import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
14
18
|
import { delimiter, dirname, join } from "node:path";
|
|
15
19
|
import { homedir, tmpdir } from "node:os";
|
|
16
20
|
import { execFile, execFileSync, spawnSync } from "node:child_process";
|
|
17
21
|
import { parse, stringify } from "yaml";
|
|
18
|
-
import { createHash } from "node:crypto";
|
|
19
22
|
import http from "node:http";
|
|
20
23
|
import https from "node:https";
|
|
21
24
|
import net from "node:net";
|
|
@@ -23,21 +26,6 @@ import zlib from "node:zlib";
|
|
|
23
26
|
import { Transform } from "node:stream";
|
|
24
27
|
import { StringDecoder } from "node:string_decoder";
|
|
25
28
|
|
|
26
|
-
//#region src/config/atomic-file.ts
|
|
27
|
-
/** Write text to a temp file and rename it over `path`: a crash mid-write leaves the old file intact. */
|
|
28
|
-
function writeFileAtomic(path, text) {
|
|
29
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
30
|
-
const tmp = `${path}.${process.pid}.tmp`;
|
|
31
|
-
try {
|
|
32
|
-
writeFileSync(tmp, text, "utf8");
|
|
33
|
-
renameSync(tmp, path);
|
|
34
|
-
} catch (e) {
|
|
35
|
-
rmSync(tmp, { force: true });
|
|
36
|
-
throw e;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
29
|
//#region src/router/usage.ts
|
|
42
30
|
/**
|
|
43
31
|
* usage.ts — per-request token and cache accounting for the router.
|
|
@@ -254,82 +242,10 @@ function readUsage(file = usageLogFile()) {
|
|
|
254
242
|
}
|
|
255
243
|
return rows;
|
|
256
244
|
}
|
|
257
|
-
function parseLines(text, into) {
|
|
258
|
-
for (const l of text.split("\n")) {
|
|
259
|
-
if (!l) continue;
|
|
260
|
-
try {
|
|
261
|
-
into.push(JSON.parse(l));
|
|
262
|
-
} catch {}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
/** Parsed log per file: rows up to byte `end` (a line boundary), the file identity they came from. */
|
|
266
|
-
const usageCache = /* @__PURE__ */ new Map();
|
|
267
|
-
/** The longest range the cockpit shows; older rows are dropped from the cache. */
|
|
268
|
-
const USAGE_CACHE_WINDOW_MS = 7 * 864e5;
|
|
269
|
-
const USAGE_HEAD_BYTES = 4096;
|
|
270
245
|
/** Row arrays known to hold their rows in time order (the cached log, while every appended row is not older than the one before). */
|
|
271
246
|
const timeOrdered = /* @__PURE__ */ new WeakSet();
|
|
272
247
|
const isTimeOrdered = (rows) => timeOrdered.has(rows);
|
|
273
248
|
const markTimeOrdered = (rows) => void timeOrdered.add(rows);
|
|
274
|
-
/**
|
|
275
|
-
* readUsage for the cockpit's polls and range clicks: the log is append-only, so the rows parsed
|
|
276
|
-
* last time stay and only the bytes after them are read. A truncated or replaced file is re-read
|
|
277
|
-
* whole; replacement is detected by inode, shrinking, or a changed first 4 KB (an in-place rewrite
|
|
278
|
-
* that grows). Rows older than the 7 d range window are dropped. The returned array is shared —
|
|
279
|
-
* callers must not mutate it.
|
|
280
|
-
*/
|
|
281
|
-
function readUsageCached(file = usageLogFile(), now = Date.now()) {
|
|
282
|
-
if (!existsSync(file)) {
|
|
283
|
-
usageCache.delete(file);
|
|
284
|
-
return [];
|
|
285
|
-
}
|
|
286
|
-
const fd = openSync(file, "r");
|
|
287
|
-
try {
|
|
288
|
-
const st = fstatSync(fd);
|
|
289
|
-
let c = usageCache.get(file);
|
|
290
|
-
const headLen = Math.min(USAGE_HEAD_BYTES, st.size);
|
|
291
|
-
const headBuf = Buffer.alloc(headLen);
|
|
292
|
-
readSync(fd, headBuf, 0, headLen, 0);
|
|
293
|
-
const head = headBuf.toString("latin1");
|
|
294
|
-
if (c && (c.ino !== st.ino || st.size < c.end || !head.startsWith(c.head))) c = void 0;
|
|
295
|
-
if (!c) {
|
|
296
|
-
c = {
|
|
297
|
-
ino: st.ino,
|
|
298
|
-
end: 0,
|
|
299
|
-
rows: [],
|
|
300
|
-
lastMs: 0,
|
|
301
|
-
head: ""
|
|
302
|
-
};
|
|
303
|
-
timeOrdered.add(c.rows);
|
|
304
|
-
}
|
|
305
|
-
if (st.size > c.end) {
|
|
306
|
-
const buf = Buffer.alloc(st.size - c.end);
|
|
307
|
-
const n = readSync(fd, buf, 0, buf.length, c.end);
|
|
308
|
-
let chunk = buf.subarray(0, n);
|
|
309
|
-
const nl = chunk.lastIndexOf(10);
|
|
310
|
-
chunk = nl < 0 ? chunk.subarray(0, 0) : chunk.subarray(0, nl + 1);
|
|
311
|
-
const from = c.rows.length;
|
|
312
|
-
parseLines(chunk.toString("utf8"), c.rows);
|
|
313
|
-
for (let i = from; i < c.rows.length; i++) {
|
|
314
|
-
const t = Date.parse(c.rows[i].ts);
|
|
315
|
-
if (t < c.lastMs) timeOrdered.delete(c.rows);
|
|
316
|
-
else if (t >= 0) c.lastMs = t;
|
|
317
|
-
}
|
|
318
|
-
c.end += chunk.length;
|
|
319
|
-
if (c.head.length < USAGE_HEAD_BYTES) c.head = head.slice(0, Math.min(c.end, USAGE_HEAD_BYTES));
|
|
320
|
-
const cutoff = now - USAGE_CACHE_WINDOW_MS;
|
|
321
|
-
if (c.rows.length && Date.parse(c.rows[0].ts) < cutoff - 864e5) {
|
|
322
|
-
const kept = c.rows.filter((r) => !(Date.parse(r.ts) < cutoff));
|
|
323
|
-
c.rows.length = 0;
|
|
324
|
-
for (const r of kept) c.rows.push(r);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
usageCache.set(file, c);
|
|
328
|
-
return c.rows;
|
|
329
|
-
} finally {
|
|
330
|
-
closeSync(fd);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
249
|
function parseSince(s) {
|
|
334
250
|
const m = /^(\d+)\s*([smhd])$/.exec(s.trim());
|
|
335
251
|
if (!m) throw new Error(`bad --since "${s}" (use e.g. 30m, 1h, 2d)`);
|
|
@@ -1126,209 +1042,6 @@ function setParkConfigSource(src) {
|
|
|
1126
1042
|
parkCfg = src;
|
|
1127
1043
|
}
|
|
1128
1044
|
|
|
1129
|
-
//#endregion
|
|
1130
|
-
//#region src/workers/local-instances.ts
|
|
1131
|
-
/**
|
|
1132
|
-
* local-instances.ts — the running instances of local models.
|
|
1133
|
-
*
|
|
1134
|
-
* An instance is one server process of a catalogue model (a `local_tiers:`
|
|
1135
|
-
* entry) on its own port. The source of truth is the running processes
|
|
1136
|
-
* (`parseServers`); `<logDir>/local-instances.json` adds what ps cannot know
|
|
1137
|
-
* (start time, log, failure). Processes win: `reconcileInstances` drops a row
|
|
1138
|
-
* whose pid is gone and adopts a catalogue server that has no row.
|
|
1139
|
-
*/
|
|
1140
|
-
const localInstancesPath = (logDir) => join(logDir, "local-instances.json");
|
|
1141
|
-
/** Is the process alive (signal 0; EPERM means it exists under another user). */
|
|
1142
|
-
function pidAlive(pid) {
|
|
1143
|
-
try {
|
|
1144
|
-
process.kill(pid, 0);
|
|
1145
|
-
return true;
|
|
1146
|
-
} catch (e) {
|
|
1147
|
-
return e.code === "EPERM";
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
function readInstances(logDir) {
|
|
1151
|
-
const path = localInstancesPath(logDir);
|
|
1152
|
-
if (!existsSync(path)) return [];
|
|
1153
|
-
try {
|
|
1154
|
-
const j = JSON.parse(readFileSync(path, "utf8"));
|
|
1155
|
-
return Array.isArray(j) ? j.filter((r) => r && typeof r.id === "string" && typeof r.model === "string") : [];
|
|
1156
|
-
} catch {
|
|
1157
|
-
return [];
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
/** The recorded rows minus managed ones whose process is gone (killed outside PAI); failed rows stay until dismissed. Readers that report or route use this; writers read the raw file. */
|
|
1161
|
-
function readLiveInstances(logDir) {
|
|
1162
|
-
return readInstances(logDir).filter((r) => !(r.origin === "managed" && r.state !== "failed" && r.pid && !pidAlive(r.pid)));
|
|
1163
|
-
}
|
|
1164
|
-
/** Atomic write (tmp + rename). */
|
|
1165
|
-
function writeInstances(logDir, rows) {
|
|
1166
|
-
const path = localInstancesPath(logDir);
|
|
1167
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
1168
|
-
const tmp = `${path}.${process.pid}.tmp`;
|
|
1169
|
-
writeFileSync(tmp, JSON.stringify(rows) + "\n", "utf8");
|
|
1170
|
-
renameSync(tmp, path);
|
|
1171
|
-
}
|
|
1172
|
-
/** Router / scheduler engine key: n=1 keeps the bare provider name, later copies are `<provider>#<n>`. */
|
|
1173
|
-
function engineKey(provider, n) {
|
|
1174
|
-
return n <= 1 ? provider : `${provider}#${n}`;
|
|
1175
|
-
}
|
|
1176
|
-
/** The n of an instance id `<model>#<n>` (1 when it carries none). */
|
|
1177
|
-
function instanceNumber(id) {
|
|
1178
|
-
const m = /#(\d+)$/.exec(id);
|
|
1179
|
-
return m ? Number(m[1]) : 1;
|
|
1180
|
-
}
|
|
1181
|
-
function instanceEngineKey(i) {
|
|
1182
|
-
return engineKey(i.provider, instanceNumber(i.id));
|
|
1183
|
-
}
|
|
1184
|
-
/** vllm-mlx servers on a port no tier names (a second copy): the tier is the one whose model path the command serves. */
|
|
1185
|
-
function vllmByModelPath(psOut, cfg, selfPid, byPath) {
|
|
1186
|
-
const out = [];
|
|
1187
|
-
for (const line of psOut.split("\n")) {
|
|
1188
|
-
const m = /^\s*(\d+)\s+(\d+)\s+(.*)$/.exec(line);
|
|
1189
|
-
if (!m || Number(m[1]) === selfPid) continue;
|
|
1190
|
-
const cmd = m[3];
|
|
1191
|
-
const sv = /\bserve\s+(\S+)/.exec(cmd);
|
|
1192
|
-
const pm = /--port\s+(\d+)/.exec(cmd);
|
|
1193
|
-
if (!sv || !pm || !cmd.includes(cfg.launcher.processMatch)) continue;
|
|
1194
|
-
const tier = byPath.get(sv[1]);
|
|
1195
|
-
if (!tier) continue;
|
|
1196
|
-
out.push({
|
|
1197
|
-
pid: Number(m[1]),
|
|
1198
|
-
rssKb: Number(m[2]),
|
|
1199
|
-
port: Number(pm[1]),
|
|
1200
|
-
tier,
|
|
1201
|
-
provider: cfg.tiers[tier].provider
|
|
1202
|
-
});
|
|
1203
|
-
}
|
|
1204
|
-
return out;
|
|
1205
|
-
}
|
|
1206
|
-
/** Servers of catalogue models, one per (model, port): the engine child of a Strata server is folded into its server. */
|
|
1207
|
-
function instancesFromProcesses(psOut, cfg, listeners = {}, selfPid = process.pid) {
|
|
1208
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1209
|
-
const out = [];
|
|
1210
|
-
const byPath = /* @__PURE__ */ new Map();
|
|
1211
|
-
for (const t of Object.values(cfg.tiers)) if (t.engine === "vllm-mlx") byPath.set(resolveModelPath(t.model), t.tier);
|
|
1212
|
-
for (const s of [...parseServers(psOut, cfg, selfPid, listeners), ...vllmByModelPath(psOut, cfg, selfPid, byPath)]) {
|
|
1213
|
-
if (!s.tier || s.port === null) continue;
|
|
1214
|
-
const key = `${s.tier}:${s.port}`;
|
|
1215
|
-
if (seen.has(key)) continue;
|
|
1216
|
-
seen.add(key);
|
|
1217
|
-
out.push(s);
|
|
1218
|
-
}
|
|
1219
|
-
return out;
|
|
1220
|
-
}
|
|
1221
|
-
/**
|
|
1222
|
-
* Join state rows with the live servers. A row follows its pid, else its
|
|
1223
|
-
* port; a live server without a row is adopted as `ready` under the smallest
|
|
1224
|
-
* free `<model>#<n>`. Rows with no live server are dropped, except `failed`
|
|
1225
|
-
* ones (kept until the next start dismisses them).
|
|
1226
|
-
*/
|
|
1227
|
-
function reconcileInstances(rows, servers, cfg, now = Date.now()) {
|
|
1228
|
-
const out = [];
|
|
1229
|
-
const used = /* @__PURE__ */ new Set();
|
|
1230
|
-
const claimed = /* @__PURE__ */ new Set();
|
|
1231
|
-
for (const r of rows) {
|
|
1232
|
-
if (r.origin === "registered") continue;
|
|
1233
|
-
if (r.state === "failed") {
|
|
1234
|
-
out.push(r);
|
|
1235
|
-
used.add(r.id);
|
|
1236
|
-
continue;
|
|
1237
|
-
}
|
|
1238
|
-
const s = servers.find((x) => !claimed.has(x) && x.tier === r.model && (x.pid === r.pid || x.port === r.port));
|
|
1239
|
-
if (!s) continue;
|
|
1240
|
-
claimed.add(s);
|
|
1241
|
-
out.push({
|
|
1242
|
-
...r,
|
|
1243
|
-
pid: s.pid,
|
|
1244
|
-
port: s.port ?? r.port
|
|
1245
|
-
});
|
|
1246
|
-
used.add(r.id);
|
|
1247
|
-
}
|
|
1248
|
-
for (const s of servers) {
|
|
1249
|
-
if (claimed.has(s) || !s.tier || s.port === null) continue;
|
|
1250
|
-
const tier = cfg.tiers[s.tier];
|
|
1251
|
-
if (!tier) continue;
|
|
1252
|
-
let n = 1;
|
|
1253
|
-
while (used.has(`${s.tier}#${n}`)) n++;
|
|
1254
|
-
const id = `${s.tier}#${n}`;
|
|
1255
|
-
used.add(id);
|
|
1256
|
-
out.push({
|
|
1257
|
-
id,
|
|
1258
|
-
model: s.tier,
|
|
1259
|
-
provider: tier.provider,
|
|
1260
|
-
url: `http://127.0.0.1:${s.port}`,
|
|
1261
|
-
origin: "managed",
|
|
1262
|
-
port: s.port,
|
|
1263
|
-
pid: s.pid,
|
|
1264
|
-
state: "ready",
|
|
1265
|
-
startedAt: now,
|
|
1266
|
-
log: ""
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
return out.sort((a, b) => a.model.localeCompare(b.model) || instanceNumber(a.id) - instanceNumber(b.id));
|
|
1270
|
-
}
|
|
1271
|
-
/**
|
|
1272
|
-
* Endpoints declared in workers.yaml `providers:` with a url that no catalogue
|
|
1273
|
-
* model launches: no pid, health is a probe (state `ready` until one says
|
|
1274
|
-
* otherwise). Loopback or another machine alike.
|
|
1275
|
-
*/
|
|
1276
|
-
function registeredInstances(providers, cfg) {
|
|
1277
|
-
const launched = new Set(Object.values(cfg.tiers).map((t) => t.provider));
|
|
1278
|
-
const out = [];
|
|
1279
|
-
for (const [name, p] of Object.entries(providers)) {
|
|
1280
|
-
if (!p.url || launched.has(name)) continue;
|
|
1281
|
-
const port = /:(\d+)(?:\/|$)/.exec(p.url)?.[1];
|
|
1282
|
-
out.push({
|
|
1283
|
-
id: name,
|
|
1284
|
-
model: name,
|
|
1285
|
-
provider: name,
|
|
1286
|
-
url: p.url.replace(/\/+$/, ""),
|
|
1287
|
-
origin: "registered",
|
|
1288
|
-
port: port ? Number(port) : 0,
|
|
1289
|
-
state: "ready",
|
|
1290
|
-
startedAt: 0,
|
|
1291
|
-
log: "",
|
|
1292
|
-
...p.characteristics ? { characteristics: p.characteristics } : {}
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
return out;
|
|
1296
|
-
}
|
|
1297
|
-
const rrCounters = /* @__PURE__ */ new Map();
|
|
1298
|
-
/**
|
|
1299
|
-
* The instance (of `running`, already one provider's; `model` keys the round-robin) to send the next request to: the ready one with the
|
|
1300
|
-
* fewest requests in flight (`busy` by engine key); ties go round-robin per
|
|
1301
|
-
* model. Null when none is ready.
|
|
1302
|
-
*/
|
|
1303
|
-
function pickInstance(model, running, busy) {
|
|
1304
|
-
const ready = running.filter((i) => i.state === "ready");
|
|
1305
|
-
if (!ready.length) return null;
|
|
1306
|
-
const load = ready.map((i) => busy(instanceEngineKey(i)));
|
|
1307
|
-
const min = Math.min(...load);
|
|
1308
|
-
const tied = ready.filter((_, k) => load[k] === min);
|
|
1309
|
-
const n = rrCounters.get(model) ?? 0;
|
|
1310
|
-
rrCounters.set(model, n + 1);
|
|
1311
|
-
return tied[n % tied.length];
|
|
1312
|
-
}
|
|
1313
|
-
/**
|
|
1314
|
-
* The endpoint registry: managed instances plus the enabled providers that
|
|
1315
|
-
* declare `characteristics` (a url alone is a cloud or local provider, not a
|
|
1316
|
-
* registered endpoint). A managed instance wins over a registered one of the
|
|
1317
|
-
* same id.
|
|
1318
|
-
*/
|
|
1319
|
-
function endpointRegistry(managed, providers, cfg) {
|
|
1320
|
-
const declared = {};
|
|
1321
|
-
for (const [name, p] of Object.entries(providers)) {
|
|
1322
|
-
if (p.enabled === false || !p.characteristics) continue;
|
|
1323
|
-
declared[name] = {
|
|
1324
|
-
url: p.baseUrl,
|
|
1325
|
-
characteristics: p.characteristics
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
const ids = new Set(managed.map((i) => i.id));
|
|
1329
|
-
return [...managed, ...registeredInstances(declared, cfg).filter((i) => !ids.has(i.id))];
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
1045
|
//#endregion
|
|
1333
1046
|
//#region src/workers/served-models.ts
|
|
1334
1047
|
/**
|
|
@@ -1951,7 +1664,7 @@ function currentSessionName(env = process.env) {
|
|
|
1951
1664
|
*/
|
|
1952
1665
|
async function registryProjectName(cwd) {
|
|
1953
1666
|
try {
|
|
1954
|
-
const { detectProject } = await import("./detect-
|
|
1667
|
+
const { detectProject } = await import("./detect-D1ziFFfA.mjs");
|
|
1955
1668
|
return (await detectProject(cwd))?.display_name || void 0;
|
|
1956
1669
|
} catch {
|
|
1957
1670
|
return;
|
|
@@ -1977,7 +1690,7 @@ async function detectSessionName(env = process.env, deps = {}) {
|
|
|
1977
1690
|
let name;
|
|
1978
1691
|
const registry = deps.registryPath ?? AIBROKER_REGISTRY;
|
|
1979
1692
|
const claudeId = env.CLAUDE_CODE_SESSION_ID?.trim();
|
|
1980
|
-
const { loadBrokerNames, transcriptCustomTitle } = await import("./session-scan-
|
|
1693
|
+
const { loadBrokerNames, transcriptCustomTitle } = await import("./session-scan-BJI_ZO8M.mjs");
|
|
1981
1694
|
name = resolveSession(env.ITERM_SESSION_ID ?? "", registry)?.name ?? (claudeId ? loadBrokerNames(registry, deps.mapPath).get(claudeId) ?? transcriptCustomTitle(claudeId, deps.projectsDir) : void 0) ?? await (deps.projectName ?? registryProjectName)(cwd);
|
|
1982
1695
|
cached = {
|
|
1983
1696
|
key,
|
|
@@ -3573,6 +3286,13 @@ function pinWorkersYamlCopy(env, root = WORKER_CONFIG_COPY_ROOT) {
|
|
|
3573
3286
|
env.PAI_WORKERS_YAML = copy;
|
|
3574
3287
|
} catch {}
|
|
3575
3288
|
}
|
|
3289
|
+
/** Caller's env minus ANTHROPIC_API_KEY: a spawned claude must bill the
|
|
3290
|
+
* subscription, never an API key left in the user's shell. */
|
|
3291
|
+
function nativeLaunchEnv() {
|
|
3292
|
+
const env = { ...process.env };
|
|
3293
|
+
delete env.ANTHROPIC_API_KEY;
|
|
3294
|
+
return env;
|
|
3295
|
+
}
|
|
3576
3296
|
/**
|
|
3577
3297
|
* Environment for a run through `provider`. Caller's env minus the Anthropic
|
|
3578
3298
|
* key. `routerEnabled` routes the run through the local model router instead
|
|
@@ -3581,8 +3301,7 @@ function pinWorkersYamlCopy(env, root = WORKER_CONFIG_COPY_ROOT) {
|
|
|
3581
3301
|
* PAI_WORKER_ORCHESTRATOR=1 makes the edit gate deny code edits.
|
|
3582
3302
|
*/
|
|
3583
3303
|
function buildRunEnv(provider, headless, proxyUrl, providerName, routerEnabled, orchestrate) {
|
|
3584
|
-
const env =
|
|
3585
|
-
delete env.ANTHROPIC_API_KEY;
|
|
3304
|
+
const env = nativeLaunchEnv();
|
|
3586
3305
|
if (headless) {
|
|
3587
3306
|
for (const k of SESSION_IDENTITY_VARS) delete env[k];
|
|
3588
3307
|
for (const k of HEADLESS_STRIP_VARS) delete env[k];
|
|
@@ -6188,5 +5907,5 @@ function resolveCapabilityRun(config, capability) {
|
|
|
6188
5907
|
}
|
|
6189
5908
|
|
|
6190
5909
|
//#endregion
|
|
6191
|
-
export { parseFootprint as $,
|
|
6192
|
-
//# sourceMappingURL=routing-
|
|
5910
|
+
export { parseFootprint as $, findLocal as $t, budgetSkipReason as A, saveSetup as An, TIGHT_PERCENT as At, MODEL_INVENTORY_MAX_AGE_MS as B, aggregate as Bn, routeRows as Bt, detectSessionProvider as C, PORT_TIMEOUT_MS as Cn, removeRunSettings as Ct, budgetExceeded as D, httpModelsCheck as Dn, routerPort as Dt, budgetCache as E, findSetup as En, routerHandler as Et, LimitsCache as F, workersLabel as Fn, flowText as Ft, fmtMem as G, isTimeOrdered as Gn, setRoute as Gt, ProbeHold as H, appendUsage as Hn, servingChip as Ht, buildSpeed as I, parkConfigFrom as In, parseSelector as It, inventoryRows as J, readUsage as Jn, validateRoute as Jt, fmtMemMapped as K, markTimeOrdered as Kn, setSessionRoute as Kt, percentile as L, setParkConfigSource as Ln, resolveSelector as Lt, budgetWall as M, setupWorkersLabel as Mn, clearSessionRoute as Mt, fetchBudgetReading as N, setupsPath as Nn, configuredLocal as Nt, budgetFresh as O, loadSaved as On, isTailnetOrLocalName as Ot, pickBudgetWindow as P, shortModel as Pn, entryLabel as Pt, modelLabel as Q, fallThroughReason as Qt, DOWN_AFTER_MISSES as R, sharedParker as Rn, resolveSessionArg as Rt, applySessionProviderEnv as S, startLocalStatusRefresh as Sn, gcSettingsFiles as St, BudgetCache as T, downLocalProviders as Tn, duplicateModelIds as Tt, computeInventory as U, formatSessionStats as Un, sessionRoutesPatch as Ut, MODEL_INVENTORY_REFRESH_MS as V, aggregateBySession as Vn, routeText as Vt, currentInventory as W, formatStats as Wn, sessionStartTarget as Wt, liveDeps as X, usageLogFile as Xn, clearPolicy as Xt, inventoryText as Y, splitBySessionKind as Yn, POLICY_MODES as Yt, modelKind as Z, committedFallThrough as Zt, resolveTarget as _, pickLocal as _n, nativeRoutePreflight as _t, clearCooldown as a, detectSessionName as an, readInventoryInput as at, SESSION_PROVIDER_ENV as b, resolveLocalProvider as bn, routeLoopbackViaRouter as bt, exclusionReason as c, getProfile as cn, writeInventory as ct, probeQuota as d, updateProfile as dn, claudeCommand as dt, onBattery as en, parseSizeMb as et, quotaExceeded as f, LOCAL_MECHANISM_LINE as fn, claudeSettingsExtra as ft, resolveCapabilityRun as g, localTierOrder as gn, nativeLaunchSettingsArgs as gt, recordBudgetCooldowns as h, localProviderForDelegation as hn, nativeLaunchEnv as ht, capabilityForRun as i, writePolicy as in, readInventory as it, budgetUntilLabel as j, setupProfile as jn, applyPolicyToRoutes as jt, budgetFull as k, orchestratorLabel as kn, loopbackRefusal as kt, isQuotaFailure as l, profilesPath as ln, addSchedulingHeaders as lt, readRoutingState as m, currentLocalStatus as mn, loopbackRouterChoice as mt, NoProviderError as n, readPolicy as nn, processTreeMemory as nt, cooldownRemaining as o, BATCH_ENV as on, readModelLabels as ot, quotaSkipThreshold as p, NoLocalServerError as pn, isLoopbackProvider as pt, inventoryPath as q, parseSince as qn, tierFlow as qt, autoOrder as r, routeRun as rn, processTreeRssMb as rt, entryModel as s, SESSION_NAME_ENV as sn, startInventoryRefresh as st, BUDGET_COOLDOWN_MIN as t, parseDuration as tn, parseTable as tt, nextAutoProvider as u, readProfiles as un, buildRunEnv as ut, setCooldown as v, probeLoopback as vn, pinnedSettings as vt, BUDGET_TTL_MS as w, allSetups as wn, writePrivateFile as wt, SESSION_WORKER_PROVIDER_ENV as x, resolveRunnerProvider as xn, routeVerdictLine as xt, writeRoutingState as y, providerHostPort as yn, pinnedSettingsArgs as yt, INVENTORY_HEADERS as z, recordDuration as zn, routeChoices as zt };
|
|
5911
|
+
//# sourceMappingURL=routing-BAAST9vT.mjs.map
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import "./config-
|
|
2
|
-
import "./config-
|
|
3
|
-
import "./paths-
|
|
4
|
-
import "./status-
|
|
5
|
-
import "./scope-
|
|
6
|
-
import { _ as resolveTarget, a as clearCooldown, c as exclusionReason, d as probeQuota, f as quotaExceeded, g as resolveCapabilityRun, h as recordBudgetCooldowns, i as capabilityForRun, l as isQuotaFailure, m as readRoutingState, n as NoProviderError, o as cooldownRemaining, p as quotaSkipThreshold, r as autoOrder, s as entryModel, t as BUDGET_COOLDOWN_MIN, u as nextAutoProvider, v as setCooldown, y as writeRoutingState } from "./routing-
|
|
7
|
-
import "./tool-errors-
|
|
8
|
-
import "./wait-
|
|
9
|
-
import "./local-tiers-
|
|
10
|
-
import "./caller-identity-
|
|
11
|
-
import "./
|
|
12
|
-
import "./
|
|
1
|
+
import "./config-XpZWOYOG.mjs";
|
|
2
|
+
import "./config-Bu1_vbY8.mjs";
|
|
3
|
+
import "./paths-CHifubDh.mjs";
|
|
4
|
+
import "./status-ggJ7lgVg.mjs";
|
|
5
|
+
import "./scope-D-h6F6DN.mjs";
|
|
6
|
+
import { _ as resolveTarget, a as clearCooldown, c as exclusionReason, d as probeQuota, f as quotaExceeded, g as resolveCapabilityRun, h as recordBudgetCooldowns, i as capabilityForRun, l as isQuotaFailure, m as readRoutingState, n as NoProviderError, o as cooldownRemaining, p as quotaSkipThreshold, r as autoOrder, s as entryModel, t as BUDGET_COOLDOWN_MIN, u as nextAutoProvider, v as setCooldown, y as writeRoutingState } from "./routing-BAAST9vT.mjs";
|
|
7
|
+
import "./tool-errors-7E13StWd.mjs";
|
|
8
|
+
import "./wait-ByV0OyMZ.mjs";
|
|
9
|
+
import "./local-tiers-BE4jGaMa.mjs";
|
|
10
|
+
import "./caller-identity-yLFb7CKq.mjs";
|
|
11
|
+
import "./capacity-DEveQdFV.mjs";
|
|
12
|
+
import "./local-instances-DOxSgT_L.mjs";
|
|
13
|
+
import "./local-candidate-DLdwQt0s.mjs";
|
|
13
14
|
|
|
14
15
|
export { BUDGET_COOLDOWN_MIN, NoProviderError, autoOrder, capabilityForRun, clearCooldown, cooldownRemaining, entryModel, exclusionReason, isQuotaFailure, nextAutoProvider, probeQuota, quotaExceeded, quotaSkipThreshold, readRoutingState, recordBudgetCooldowns, resolveCapabilityRun, resolveTarget, setCooldown, writeRoutingState };
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import { g as paiHomePath, l as claudeHomeDir } from "./runtime-paths-WsO9sJFc.mjs";
|
|
2
|
-
import { Ct as withSummary, I as LOOPBACK_HOST, N as resolveModelCapability, P as resolveProviderKey, St as sessionNote, bt as ledgerEscalate, c as WorkersConfigError, f as escalationCloud, ft as parseEntry, gt as certainContextWindow, h as isModelCapability, j as readWorkersSection, k as providerKeyPath, l as assertProviderRunnable, m as isLocalProvider, ot as applyRouteOverrides, p as getProviderOrNative, t as ANTHROPIC_NATIVE, tt as workersYamlPath, u as classModelCapability, v as nativeAnthropicModels, wt as appendLedger, xt as planEscalation } from "./config-
|
|
3
|
-
import { _ as effectiveWorkersYamlRaw } from "./config-
|
|
4
|
-
import { i as ledgerPath, n as ensureNoMcpConfig, r as eventsPath, u as workersLogDir } from "./paths-
|
|
5
|
-
import { A as applyScratchEnv, C as worktreeWanted, S as worktreeSystemPrompt, _ as ownedTree, a as archiveEmptyResult, f as gcWorktreesThrottled, h as markResumed, i as adoptTree, j as scratchPromptLine, o as commitLines, p as inPlaceSystemPrompt, r as addWorktree, t as GATE_MARK, v as recordWorktree, w as worktreesDir, x as worktreeRefusesStart, y as salvageOnExit } from "./worktree-
|
|
6
|
-
import { C as nowStamp, D as pidAlive, E as parseSleepSecs, J as loadPreamble, Q as appendSystemPromptArgs, S as newWorkerId, X as preambleLine, Y as preambleBlock, Z as projectRoot, a as UNLABELED, d as describeTool, g as isLive, k as saveStatus, nt as shortText, rt as stripPromptValues, tt as parseRunnerArgs, v as loadStatus, x as markStartFailed, y as loadStatuses } from "./status-
|
|
7
|
-
import { D as readMcpServers, E as mcpServersFromToolGrants, O as writeMcpConfig, S as inputSideTokens, T as grantsChrome, d as poolIneligibleReason, g as postTaskToPool, h as poolSettings, n as SLOT_TOOLS, r as UNIT_MARKER, t as SHARED_MARKER, w as expandMcpNames, y as reloadInProgress } from "./pool-
|
|
8
|
-
import { i as itermUuid, o as resolveSession, s as resolveSpawnerSession } from "./scope-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { c as queuedText, d as resolveCap, h as staggerGate, m as recordWarmup, n as capacityGate, p as sessionScopeKey, t as admitCap } from "./capacity-
|
|
15
|
-
import { t as
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
2
|
+
import { Ct as withSummary, I as LOOPBACK_HOST, N as resolveModelCapability, P as resolveProviderKey, St as sessionNote, bt as ledgerEscalate, c as WorkersConfigError, f as escalationCloud, ft as parseEntry, gt as certainContextWindow, h as isModelCapability, j as readWorkersSection, k as providerKeyPath, l as assertProviderRunnable, m as isLocalProvider, ot as applyRouteOverrides, p as getProviderOrNative, t as ANTHROPIC_NATIVE, tt as workersYamlPath, u as classModelCapability, v as nativeAnthropicModels, wt as appendLedger, xt as planEscalation } from "./config-XpZWOYOG.mjs";
|
|
3
|
+
import { _ as effectiveWorkersYamlRaw } from "./config-Bu1_vbY8.mjs";
|
|
4
|
+
import { i as ledgerPath, n as ensureNoMcpConfig, r as eventsPath, u as workersLogDir } from "./paths-CHifubDh.mjs";
|
|
5
|
+
import { A as applyScratchEnv, C as worktreeWanted, S as worktreeSystemPrompt, _ as ownedTree, a as archiveEmptyResult, f as gcWorktreesThrottled, h as markResumed, i as adoptTree, j as scratchPromptLine, o as commitLines, p as inPlaceSystemPrompt, r as addWorktree, t as GATE_MARK, v as recordWorktree, w as worktreesDir, x as worktreeRefusesStart, y as salvageOnExit } from "./worktree-CRs2gyg0.mjs";
|
|
6
|
+
import { C as nowStamp, D as pidAlive, E as parseSleepSecs, J as loadPreamble, Q as appendSystemPromptArgs, S as newWorkerId, X as preambleLine, Y as preambleBlock, Z as projectRoot, a as UNLABELED, d as describeTool, g as isLive, k as saveStatus, nt as shortText, rt as stripPromptValues, tt as parseRunnerArgs, v as loadStatus, x as markStartFailed, y as loadStatuses } from "./status-ggJ7lgVg.mjs";
|
|
7
|
+
import { D as readMcpServers, E as mcpServersFromToolGrants, O as writeMcpConfig, S as inputSideTokens, T as grantsChrome, d as poolIneligibleReason, g as postTaskToPool, h as poolSettings, n as SLOT_TOOLS, r as UNIT_MARKER, t as SHARED_MARKER, w as expandMcpNames, y as reloadInProgress } from "./pool-Dh-q3iJi.mjs";
|
|
8
|
+
import { i as itermUuid, o as resolveSession, s as resolveSpawnerSession } from "./scope-D-h6F6DN.mjs";
|
|
9
|
+
import { Cn as PORT_TIMEOUT_MS, Ct as removeRunSettings, Dn as httpModelsCheck, Dt as routerPort, E as budgetCache, Qt as fallThroughReason, S as applySessionProviderEnv, Zt as committedFallThrough, _ as resolveTarget, an as detectSessionName, bn as resolveLocalProvider, bt as routeLoopbackViaRouter, cn as getProfile, dt as claudeCommand, fn as LOCAL_MECHANISM_LINE, ft as claudeSettingsExtra, g as resolveCapabilityRun, h as recordBudgetCooldowns, i as capabilityForRun, k as budgetFull, l as isQuotaFailure, lt as addSchedulingHeaders, n as NoProviderError, o as cooldownRemaining, on as BATCH_ENV, pn as NoLocalServerError, pt as isLoopbackProvider, r as autoOrder, rn as routeRun, u as nextAutoProvider, ut as buildRunEnv, v as setCooldown, vn as probeLoopback, vt as pinnedSettings, wt as writePrivateFile, x as SESSION_WORKER_PROVIDER_ENV, xn as resolveRunnerProvider, yn as providerHostPort } from "./routing-BAAST9vT.mjs";
|
|
10
|
+
import { t as maxOf } from "./min-max-DrSRUaWQ.mjs";
|
|
11
|
+
import { b as readToolErrors, h as harnessToolErrorTexts, p as grantedToolNames, x as recordToolError } from "./tool-errors-7E13StWd.mjs";
|
|
12
|
+
import { _ as workerContractPrompt, b as killProcessTree, c as checkProof, d as parseWorkerReport, f as promptTrailer, g as verifyReportChanges, h as verifyFailNote, l as newUntracked, m as untrackedPaths, o as AG2_REASK_TEXT, s as OPERATOR_MARK, u as noteTokenSentence, v as repairAndValidateAg2, x as processTree, y as validateAg2 } from "./wait-ByV0OyMZ.mjs";
|
|
13
|
+
import { a as buildsDir, d as releaseBuildsOf } from "./caller-identity-yLFb7CKq.mjs";
|
|
14
|
+
import { c as queuedText, d as resolveCap, h as staggerGate, m as recordWarmup, n as capacityGate, p as sessionScopeKey, t as admitCap } from "./capacity-DEveQdFV.mjs";
|
|
15
|
+
import { n as tierProviderNames, t as isLocalCandidate } from "./local-candidate-DLdwQt0s.mjs";
|
|
16
|
+
import { t as LOCAL_PROBE_TIMEOUT_MS } from "./timeouts-1MLooEBB.mjs";
|
|
17
|
+
import { i as getRegistryBackend } from "./factory-DjAAsqr_.mjs";
|
|
18
|
+
import { c as ensureProxyRunning, i as detectCurrentModel, l as proxyPort } from "./launch-Jh5NVeNe.mjs";
|
|
19
|
+
import { A as tail, Et as openOwnedPane, Kt as isHandoffMessage, Q as NoTerminalError, Wt as deliverHandoff, Xt as localFailures, _ as troublePolicy, _t as paneTitle, at as headlessAllowed, d as aibrokerMessenger, f as detachRun, h as originFromEnv, ht as resolveHostSession, it as followCommand, m as markRunDone, mt as realPaneOps, nt as closePaneForWorker, o as ownerOf, p as eventLine, r as returnControlsIfHeld, ut as openVerifiedPane, v as appendRunLog, z as gatePhaseName } from "./controls-CPoeudou.mjs";
|
|
20
|
+
import { i as endFields, o as parentInfo, r as decideEndReason } from "./endreason-C577xIQz.mjs";
|
|
21
|
+
import { A as resolveLimit, E as armDeadline, F as checkOrphanedChildren, I as isWorkerId, L as launchParent, M as blockedMsOf, O as deadlinePromptLine, P as assertChildAllowed, T as recordDenial, k as extendLimit, w as parseDenialText } from "./render-BYmQkuLd.mjs";
|
|
22
|
+
import { t as createOperatorServer } from "./operator-CyuB3aVw.mjs";
|
|
23
|
+
import { i as killTree } from "./kill-tree-EWYaEk5v.mjs";
|
|
24
|
+
import { r as ensurePoolHost } from "./pool-cli-BggU8GRp.mjs";
|
|
24
25
|
import { closeSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
26
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
25
27
|
import { dirname, join, resolve, sep } from "node:path";
|
|
26
28
|
import { tmpdir } from "node:os";
|
|
27
29
|
import { execFileSync, spawn } from "node:child_process";
|
|
28
30
|
import { fileURLToPath } from "node:url";
|
|
29
31
|
import { parse } from "yaml";
|
|
30
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
31
32
|
import { connect } from "node:net";
|
|
32
33
|
import { createInterface } from "node:readline";
|
|
33
34
|
|
|
@@ -1284,7 +1285,7 @@ async function tryEscalate(a, wid, st, report, resultText, commits, failureWhy,
|
|
|
1284
1285
|
notifySession: async (text) => {
|
|
1285
1286
|
const target = st.session?.id || st.session?.name || st.sessionKey;
|
|
1286
1287
|
if (!target) return;
|
|
1287
|
-
const { sendToSession } = await import("./aibroker-client-
|
|
1288
|
+
const { sendToSession } = await import("./aibroker-client-BxzeEHPF.mjs");
|
|
1288
1289
|
await sendToSession(target, text, void 0, { noReply: true });
|
|
1289
1290
|
}
|
|
1290
1291
|
});
|
|
@@ -1521,7 +1522,6 @@ function adoptInitModel(status, e) {
|
|
|
1521
1522
|
function shouldRetryReport(validation, noReportRetry, hasSession) {
|
|
1522
1523
|
return !validation.ok && validation.validator === "aibroker" && !noReportRetry && hasSession;
|
|
1523
1524
|
}
|
|
1524
|
-
/** Context window announced by the init event, when the endpoint sends one. */
|
|
1525
1525
|
/**
|
|
1526
1526
|
* An empty model response: the model "answered" without producing anything —
|
|
1527
1527
|
* no tool ran and the result text is empty. A local model can stop at once with an empty reply;
|
|
@@ -1544,6 +1544,7 @@ function runSucceeded(headless, rc, resultEvent) {
|
|
|
1544
1544
|
if (!headless) return true;
|
|
1545
1545
|
return resultEvent !== null && !resultEvent.is_error;
|
|
1546
1546
|
}
|
|
1547
|
+
/** Context window announced by the init event, when the endpoint sends one. */
|
|
1547
1548
|
function initContextWindow(e) {
|
|
1548
1549
|
if (typeof e.context_window === "number" && e.context_window > 0) return e.context_window;
|
|
1549
1550
|
if (e.model_info && typeof e.model_info.context_window === "number" && e.model_info.context_window > 0) return e.model_info.context_window;
|
|
@@ -2449,8 +2450,9 @@ function computeSimilarity(s1, s2) {
|
|
|
2449
2450
|
const s2Reversed = s2.split("").reverse().join("");
|
|
2450
2451
|
for (let i = 0; i < minLength; i++) if (s1Reversed[i] === s2Reversed[i]) suffixLength++;
|
|
2451
2452
|
else break;
|
|
2453
|
+
const overlapCap = minLength - prefixLength;
|
|
2452
2454
|
const totalLength = Math.max(s1.length, s2.length);
|
|
2453
|
-
return
|
|
2455
|
+
return (prefixLength + Math.min(suffixLength, overlapCap)) / totalLength;
|
|
2454
2456
|
}
|
|
2455
2457
|
function isEditAssistError(errorText) {
|
|
2456
2458
|
return errorText.includes("No changes to make: old_string and new_string are exactly the same") || errorText.includes("String to replace not found in file");
|
|
@@ -2839,7 +2841,7 @@ function renderUsage(rep, opts) {
|
|
|
2839
2841
|
...body,
|
|
2840
2842
|
...totals
|
|
2841
2843
|
];
|
|
2842
|
-
const w = head.map((_, i) =>
|
|
2844
|
+
const w = head.map((_, i) => maxOf(all.map((r) => r[i].length)));
|
|
2843
2845
|
const textCols = 2;
|
|
2844
2846
|
const fmt = (r) => r.map((c, i) => i < textCols ? c.padEnd(w[i]) : c.padStart(w[i])).join(" ");
|
|
2845
2847
|
return [
|
|
@@ -3410,10 +3412,10 @@ function resolveWorkers(args, ctx) {
|
|
|
3410
3412
|
/** The live context: config, this session's profile, fresh budget readings (warmed best effort) and recorded cooldowns. */
|
|
3411
3413
|
async function liveResolveCtx(env = process.env, warm = true) {
|
|
3412
3414
|
const [{ readWorkersSection }, { budgetCache }, { readRoutingState }, { workersLogDir }] = await Promise.all([
|
|
3413
|
-
import("./config-
|
|
3414
|
-
import("./budget-
|
|
3415
|
-
import("./routing-
|
|
3416
|
-
import("./paths-
|
|
3415
|
+
import("./config-Cxi-aBf4.mjs"),
|
|
3416
|
+
import("./budget-Dod6rnA9.mjs"),
|
|
3417
|
+
import("./routing-CENt4HH1.mjs"),
|
|
3418
|
+
import("./paths-CFHTloSe.mjs")
|
|
3417
3419
|
]);
|
|
3418
3420
|
const { workers } = readWorkersSection();
|
|
3419
3421
|
const profile = getProfile(await detectSessionName(env));
|
|
@@ -4880,7 +4882,7 @@ async function runWorker(opts) {
|
|
|
4880
4882
|
if (gc?.length) process.stderr.write(`pai worker: archived ${gc.length} leftover worktree(s) (pai worker gc)\n`);
|
|
4881
4883
|
} catch {}
|
|
4882
4884
|
if (opts.className === "plan" && !opts._planner) {
|
|
4883
|
-
const { runPlanner } = await import("./planner-
|
|
4885
|
+
const { runPlanner } = await import("./planner-BmFACdLa.mjs");
|
|
4884
4886
|
return runPlanner(opts);
|
|
4885
4887
|
}
|
|
4886
4888
|
const parent = launchParent(opts.parent);
|
|
@@ -5104,4 +5106,4 @@ setRunWorker(runWorker);
|
|
|
5104
5106
|
|
|
5105
5107
|
//#endregion
|
|
5106
5108
|
export { routerPidFile as A, usageContextTokens as B, workerUsage as C, routerHandoverFile as D, probeRouter as E, startHandover as F, testProvider as H, paneWaiver as I, launchPane as L, routerSwapArgs as M, runRouterTick as N, routerIsStale as O, spawnRouter as P, noTerminalReasons as R, usageJson as S, projectLaunchConfig as T, endProcesses as U, printResult as V, findWorktreeOrphans as W, stopLaunchedWorkers as _, resolveWorkers as a, renderUsage as b, reportOriginWithHost as c, capture as d, dirtyPaths as f, realRunnerDeps as g, realCommitsAhead as h, liveResolveCtx as i, routerRunningPid as j, routerLogFile as k, runMessenger as l, mergeBranch as m, LocalProviderRefusedError as n, sessionWorkersLine as o, launchWorker as p, PoolRefusedError as r, finishDetached as s, runWorker as t, startDetached as u, parseWhen as v, pinNotices as w, transcriptUsage as x, priceTableText as y, recordSystemJobStart as z };
|
|
5107
|
-
//# sourceMappingURL=run-
|
|
5109
|
+
//# sourceMappingURL=run-CSC7mgPf.mjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _ as warn, c as ok, i as err, n as dim, r as encodeDir, s as now, t as bold } from "./utils-J2b9y8PC.mjs";
|
|
2
2
|
import { _ as resolvePaiFile, d as defaultPaiHomeDir, g as paiHomePath, m as migratePaiFile, u as claudeProjectsDir$1 } from "./runtime-paths-WsO9sJFc.mjs";
|
|
3
|
-
import { a as slugify, i as parseSessionFilename, n as decodeEncodedDir, t as buildEncodedDirMap } from "./migrate-
|
|
4
|
-
import { D as readJsonStrict, O as writeJsonAtomic, o as expandHome } from "./config-
|
|
5
|
-
import { a as unregistrableReason, o as workerWorktreesRoot, r as pruneWorktreeProjects } from "./registrable-
|
|
6
|
-
import { n as ensurePaiMarker, t as discoverPaiMarkers } from "./pai-marker-
|
|
7
|
-
import { i as getRegistryBackend } from "./factory-
|
|
3
|
+
import { a as slugify, i as parseSessionFilename, n as decodeEncodedDir, t as buildEncodedDirMap } from "./migrate-DrA_OwlZ.mjs";
|
|
4
|
+
import { D as readJsonStrict, O as writeJsonAtomic, o as expandHome } from "./config-Bu1_vbY8.mjs";
|
|
5
|
+
import { a as unregistrableReason, o as workerWorktreesRoot, r as pruneWorktreeProjects } from "./registrable-DpyTtajg.mjs";
|
|
6
|
+
import { n as ensurePaiMarker, t as discoverPaiMarkers } from "./pai-marker-BcZyJguM.mjs";
|
|
7
|
+
import { i as getRegistryBackend } from "./factory-DjAAsqr_.mjs";
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { basename, join, resolve } from "node:path";
|
|
10
10
|
import { homedir } from "node:os";
|
|
@@ -718,4 +718,4 @@ async function cmdScan(opts = {}) {
|
|
|
718
718
|
|
|
719
719
|
//#endregion
|
|
720
720
|
export { resolveHome as a, upsertSession as c, scanTranscriptFolders as d, transcriptFiles as f, performScan as i, claudeProjectsDir as l, loadScanConfig as n, saveScanConfig as o, migrateScanConfig as r, upsertProject as s, cmdScan as t, findMovedProjects as u };
|
|
721
|
-
//# sourceMappingURL=scan-
|
|
721
|
+
//# sourceMappingURL=scan-C_Y5W9py.mjs.map
|