@tekmidian/pai 0.66.6 → 0.66.8
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/{aibroker-client-WCZi_tn-.mjs → aibroker-client-BfnVwGZl.mjs} +3 -3
- package/dist/{aibroker-client-WCZi_tn-.mjs.map → aibroker-client-BfnVwGZl.mjs.map} +1 -1
- package/dist/{aibroker-client-Ck3p3k_-.mjs → aibroker-client-C-O3Fflh.mjs} +1 -1
- package/dist/{auto-route-BnizyALK.mjs → auto-route-D8TBDNqb.mjs} +3 -3
- package/dist/{auto-route-BnizyALK.mjs.map → auto-route-D8TBDNqb.mjs.map} +1 -1
- package/dist/auto-route-DCxTKz19.mjs +7 -0
- package/dist/{chain-2_uoiEdD.mjs → chain-BL4khGgy.mjs} +4 -3
- package/dist/{chain-2_uoiEdD.mjs.map → chain-BL4khGgy.mjs.map} +1 -1
- package/dist/cli/index.mjs +20 -16
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/program.mjs +19 -15
- package/dist/{config-Ddc4DIPk.mjs → config-DjZELvoA.mjs} +12 -3
- package/dist/config-DjZELvoA.mjs.map +1 -0
- package/dist/{run-env-CQRnxNht.mjs → config-Dpe2JlbY.mjs} +5 -114
- package/dist/config-Dpe2JlbY.mjs.map +1 -0
- package/dist/{config-CnsDMETf.mjs → config-yomayAwe.mjs} +1 -1
- package/dist/{context-handover-cache-SFkWucuT.mjs → context-handover-cache-DFqxNh-H.mjs} +27 -13
- package/dist/context-handover-cache-DFqxNh-H.mjs.map +1 -0
- package/dist/daemon/index.mjs +20 -15
- package/dist/daemon/index.mjs.map +1 -1
- package/dist/{daemon-vLtT3yaI.mjs → daemon-CsR1S_Qr.mjs} +762 -24
- package/dist/daemon-CsR1S_Qr.mjs.map +1 -0
- package/dist/daemon-WrncnGua.mjs +23 -0
- package/dist/daemon-mcp/index.mjs +15 -12
- package/dist/daemon-mcp/index.mjs.map +1 -1
- package/dist/embedding-gate-DqbKvn56.mjs +378 -0
- package/dist/embedding-gate-DqbKvn56.mjs.map +1 -0
- package/dist/embedding-gate-SJMCPwxG.mjs +5 -0
- package/dist/{embeddings-DMVzpvRZ.mjs → embeddings-BUjZMD9F.mjs} +16 -2
- package/dist/{embeddings-DMVzpvRZ.mjs.map → embeddings-BUjZMD9F.mjs.map} +1 -1
- package/dist/embeddings-DrJ-ewfi.mjs +3 -0
- package/dist/{env-DiolswKQ.mjs → env-CPCNHz3i.mjs} +1 -1
- package/dist/{env-DiolswKQ.mjs.map → env-CPCNHz3i.mjs.map} +1 -1
- package/dist/factory-DjtXElOI.mjs +9 -0
- package/dist/{factory-CXFHwvcv.mjs → factory-yElzJc6f.mjs} +31 -9
- package/dist/factory-yElzJc6f.mjs.map +1 -0
- package/dist/{fallback-DNzd3jJc.mjs → fallback-2yWDDYiT.mjs} +5 -4
- package/dist/{fallback-DNzd3jJc.mjs.map → fallback-2yWDDYiT.mjs.map} +1 -1
- package/dist/{helpers-CZsi_49C.mjs → helpers-B9LHRJ8R.mjs} +1 -1
- package/dist/{helpers-CZsi_49C.mjs.map → helpers-B9LHRJ8R.mjs.map} +1 -1
- package/dist/hooks/block-sleep-poll.mjs +7 -2
- package/dist/hooks/block-sleep-poll.mjs.map +3 -3
- package/dist/hooks/context-compression-hook.mjs +2 -0
- package/dist/hooks/context-compression-hook.mjs.map +2 -2
- package/dist/hooks/load-core-context.mjs +5 -5
- package/dist/hooks/load-core-context.mjs.map +2 -2
- package/dist/hooks/load-project-context.mjs +2 -0
- package/dist/hooks/load-project-context.mjs.map +2 -2
- package/dist/hooks/post-compact-inject.mjs +2 -0
- package/dist/hooks/post-compact-inject.mjs.map +2 -2
- package/dist/hooks/route-agents-to-worker.mjs +2 -0
- package/dist/hooks/route-agents-to-worker.mjs.map +2 -2
- package/dist/hooks/security-validator.mjs +2 -0
- package/dist/hooks/security-validator.mjs.map +2 -2
- package/dist/hooks/whisper-rules.mjs +2 -0
- package/dist/hooks/whisper-rules.mjs.map +2 -2
- package/dist/hooks/worker-guard.mjs +82 -5
- package/dist/hooks/worker-guard.mjs.map +4 -4
- package/dist/hooks/worker-proxy.mjs +2 -0
- package/dist/hooks/worker-proxy.mjs.map +2 -2
- package/dist/hooks/worker-status-line.mjs +7 -2
- package/dist/hooks/worker-status-line.mjs.map +3 -3
- package/dist/hooks/worker-supervision.mjs +2 -0
- package/dist/hooks/worker-supervision.mjs.map +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/{ipc-client-DkxRay-o.mjs → ipc-client-DVZ_EGnu.mjs} +2 -2
- package/dist/{ipc-client-DkxRay-o.mjs.map → ipc-client-DVZ_EGnu.mjs.map} +1 -1
- package/dist/main-resolver-DjQsexge.mjs +8 -0
- package/dist/{main-resolver-SfGGg1DB.mjs → main-resolver-Dxvn4Mv8.mjs} +7 -6
- package/dist/{main-resolver-SfGGg1DB.mjs.map → main-resolver-Dxvn4Mv8.mjs.map} +1 -1
- package/dist/{pai-marker-DXVpFsYz.mjs → pai-marker-1B7iC7oq.mjs} +121 -3
- package/dist/pai-marker-1B7iC7oq.mjs.map +1 -0
- package/dist/{planner-C-gzg7ye.mjs → planner-CspP59ya.mjs} +13 -10
- package/dist/{planner-C-gzg7ye.mjs.map → planner-CspP59ya.mjs.map} +1 -1
- package/dist/{postgres-BxmyQHoA.mjs → postgres-CCAGq1qp.mjs} +86 -5
- package/dist/postgres-CCAGq1qp.mjs.map +1 -0
- package/dist/postgres-CzkEPfAm.mjs +7 -0
- package/dist/{program-CfG1T_ko.mjs → program-cWqZI0_L.mjs} +231 -125
- package/dist/program-cWqZI0_L.mjs.map +1 -0
- package/dist/{query-feedback-BPdapXKd.mjs → query-feedback-GPeVGvIa.mjs} +2 -2
- package/dist/{query-feedback-BPdapXKd.mjs.map → query-feedback-GPeVGvIa.mjs.map} +1 -1
- package/dist/{reranker-3lnggwgq.mjs → reranker-BTiOia8Y.mjs} +1 -1
- package/dist/{reranker-3lnggwgq.mjs.map → reranker-BTiOia8Y.mjs.map} +1 -1
- package/dist/{reranker-CZ2mP4cf.mjs → reranker-YwDT2n5e.mjs} +1 -1
- package/dist/{router-BaTbc9VX.mjs → router-Bk_ySIZT.mjs} +2 -2
- package/dist/{router-BaTbc9VX.mjs.map → router-Bk_ySIZT.mjs.map} +1 -1
- package/dist/router-DyiZNI6o.mjs +3 -0
- package/dist/{run-ChlIbDJ0.mjs → run-BZNdpUGQ.mjs} +226 -1797
- package/dist/run-BZNdpUGQ.mjs.map +1 -0
- package/dist/run-env-Cd0Son-Y.mjs +115 -0
- package/dist/run-env-Cd0Son-Y.mjs.map +1 -0
- package/dist/{pai-home-UncxWxlX.mjs → runtime-paths-DkZoxofH.mjs} +50 -2
- package/dist/runtime-paths-DkZoxofH.mjs.map +1 -0
- package/dist/{search-CNAGTiJP.mjs → search-cPDj-9fO.mjs} +2 -2
- package/dist/{search-CNAGTiJP.mjs.map → search-cPDj-9fO.mjs.map} +1 -1
- package/dist/{sources-CM2g-CLT.mjs → sources-CvvzNZad.mjs} +1 -1
- package/dist/{sources-CM2g-CLT.mjs.map → sources-CvvzNZad.mjs.map} +1 -1
- package/dist/{stop-words-DtxaTWU_.mjs → stop-words-LtkS-Pej.mjs} +1 -1
- package/dist/{stop-words-DtxaTWU_.mjs.map → stop-words-LtkS-Pej.mjs.map} +1 -1
- package/dist/worktree-CwMRTa0H.mjs +1578 -0
- package/dist/worktree-CwMRTa0H.mjs.map +1 -0
- package/dist/{zettelkasten-BRIaHzFm.mjs → zettelkasten-DSIe6wpF.mjs} +6 -5
- package/dist/zettelkasten-DSIe6wpF.mjs.map +1 -0
- package/dist/{zettelkasten-G0-ZTybr.mjs → zettelkasten-DtkAvA18.mjs} +5 -3
- package/docker/docker-compose.yml +4 -0
- package/docs/commands/README.md +6 -0
- package/docs/commands/memory.md +52 -0
- package/docs/commands/worker.md +22 -0
- package/docs/install-linux.md +1 -0
- package/docs/memory.md +69 -0
- package/package.json +1 -1
- package/src/hooks/ts/lib/sleep-poll-gate.test.ts +2 -2
- package/src/hooks/ts/lib/sleep-poll-gate.ts +4 -4
- package/src/hooks/ts/lib/worker-guard-longwait.test.ts +48 -0
- package/src/hooks/ts/lib/worker-guard.ts +50 -6
- package/src/hooks/ts/pre-tool-use/block-sleep-poll.test.ts +1 -1
- package/src/hooks/ts/session-start/load-core-context.ts +11 -8
- package/src/hooks/ts/session-start/session-start-worker-guard.test.ts +34 -2
- package/dist/auto-route-D6fW1Q8z.mjs +0 -3
- package/dist/config-Ddc4DIPk.mjs.map +0 -1
- package/dist/context-handover-cache-SFkWucuT.mjs.map +0 -1
- package/dist/daemon-BHQoEjt0.mjs +0 -18
- package/dist/daemon-vLtT3yaI.mjs.map +0 -1
- package/dist/embeddings-D0WOQpYR.mjs +0 -3
- package/dist/factory-CXFHwvcv.mjs.map +0 -1
- package/dist/factory-CnKsU6zX.mjs +0 -8
- package/dist/main-resolver-DrHtx8iW.mjs +0 -7
- package/dist/pai-home-UncxWxlX.mjs.map +0 -1
- package/dist/pai-marker-DXVpFsYz.mjs.map +0 -1
- package/dist/postgres-B2BEBT-J.mjs +0 -5
- package/dist/postgres-BxmyQHoA.mjs.map +0 -1
- package/dist/program-CfG1T_ko.mjs.map +0 -1
- package/dist/router-BK-hFeQ6.mjs +0 -3
- package/dist/run-ChlIbDJ0.mjs.map +0 -1
- package/dist/run-env-CQRnxNht.mjs.map +0 -1
- package/dist/runtime-paths-Bw3Jk8qJ.mjs +0 -52
- package/dist/runtime-paths-Bw3Jk8qJ.mjs.map +0 -1
- package/dist/zettelkasten-BRIaHzFm.mjs.map +0 -1
|
@@ -1,93 +1,40 @@
|
|
|
1
1
|
import { a as fmtDate, c as ok$1, d as scaffoldProjectDirs, f as shortenPath, g as warn$1, h as smartDecodeDir, i as err, l as renderTable, m as slugify, n as dim$1, o as header, p as slugFromPath, r as encodeDir, s as now, t as bold$1, u as resolvePath } from "./utils-DddRwMsG.mjs";
|
|
2
2
|
import { a as slugify$1, i as parseSessionFilename } from "./migrate-Bq0esMOa.mjs";
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { _ as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { t as
|
|
3
|
+
import { b as OWNER_LABEL_PREFIX, c as migrateConfigFile, d as readMainConfigRaw, f as writeMainConfigRaw, h as resolvedMainConfigPath, l as paiConfigFilePath, m as migrateMainConfigToYaml, n as CONFIG_FILE$2, o as expandHome, p as MainConfigError, s as loadConfig, t as CONFIG_DIR, u as paiConfigYamlFilePath, v as readJsonStrict, x as UNROUTED, y as writeJsonAtomic } from "./config-DjZELvoA.mjs";
|
|
4
|
+
import { a as schedulerLogPath, c as migratePaiFile, d as resolvePaiFile, i as paiSocketPath, l as paiHomeDir, n as daemonLogPath, o as PaiFileMigrationError, s as migratePaiDir, u as paiHomePath } from "./runtime-paths-DkZoxofH.mjs";
|
|
5
|
+
import { A as initWorkersYaml, B as stripModelVariant, F as relocateWorkersYaml, I as workersYamlLegacyNotice, L as workersYamlPath, M as migrateWorkersToYaml, N as needsWorkersYamlRelocation, P as parseWorkersYamlDocument, R as DEFAULT_CONTEXT_WINDOW, S as nativeAnthropicProvider, T as readWorkersSection, _ as expandHome$1, d as PROVIDER_TAGS, j as inlineWorkersYamlKeys, l as MODEL_CAPABILITIES, p as WorkersConfigError, t as ANTHROPIC_NATIVE, v as getProviderOrNative, x as maskKey, y as isModelCapability, z as contextWindowFromModelId } from "./config-Dpe2JlbY.mjs";
|
|
6
|
+
import { D as isLive, E as isChatPane, F as setWorkerLabel, H as ensureNoMcpConfig, I as waitForTerminalStatus, M as ownsPid, O as loadStatus, P as saveStatus, R as longInlinePromptHint, U as eventsPath, W as ledgerPath, _ as appendLedger, g as pendingResults, h as pendingGate, k as loadStatuses, m as formatPending, n as discardWorker, q as workersLogDir, r as gcWorktrees, s as mergeWorker, u as verifyWorker, y as UNLABELED, z as parseRunnerArgs } from "./worktree-CwMRTa0H.mjs";
|
|
7
|
+
import { a as unregistrableReason, n as ensurePaiMarker, o as worktreeReason } from "./pai-marker-1B7iC7oq.mjs";
|
|
8
|
+
import { t as STOP_WORDS } from "./stop-words-LtkS-Pej.mjs";
|
|
9
|
+
import { t as applyRecencyBoost } from "./search-cPDj-9fO.mjs";
|
|
10
|
+
import { c as resolveFromModule, i as retryTransient, n as embedChunksWithBackend, r as indexProjectWithBackend, s as packageRoot } from "./postgres-CCAGq1qp.mjs";
|
|
11
|
+
import { a as getStorageBackend, c as MergeError, f as humanDuration, i as getRegistryBackend, l as federationDbPath, o as oldRegistryPath, r as createStorageBackend, s as registryDbPath, u as oldFederationPath } from "./factory-yElzJc6f.mjs";
|
|
12
|
+
import { c as detectBackends, d as OLLAMA_DEFAULT_MODEL, f as OLLAMA_DEFAULT_URL, i as measureThroughput, o as BACKEND_IDS, p as OLLAMA_ID, s as createBackend, u as provisionOllama } from "./embedding-gate-DqbKvn56.mjs";
|
|
13
|
+
import { At as claudeProjectsDir, Ct as loadScanConfig, Dt as saveScanConfig, Et as resolveHome, Ft as formatDetection, It as formatDetectionJson, Mt as scanTranscriptFolders, Nt as transcriptFiles, Ot as upsertProject, Pt as detectProject, St as cmdScan, a as sessionKeepaliveLedgerSummary, bt as reexecBackground, ct as findLatestNote, jt as findMovedProjects, kt as upsertSession, l as resolveDaemonPid, lt as findNotesDir$1, o as parseSessionUsage, ot as appendCheckpointToNote, r as loadSessionKeepaliveState, rt as extractAndStoreTriples, s as totalUsageTokens, st as applyContinue, t as readContextHandoverCache, ut as readBodyFile, vt as migrateIdentityFile, w as migrateSummaryCooldowns, wt as migrateScanConfig, y as migrateWorkQueue } from "./context-handover-cache-DFqxNh-H.mjs";
|
|
14
|
+
import { A as ensureProxyRunning, I as pinNotices, L as projectLaunchConfig, R as describeMcp, _ as clickrControlsArgv, c as waitOn, d as sayToWorker, g as openPaneForWorker, h as openFollowPane, i as usageContextTokens, j as stopProxy, k as DEFAULT_PROXY_PORT, l as handoffFromInside, m as closeEndedPanes, n as runWorker, o as parseWorkerReport, p as checkPaneForWorker, r as testProvider, v as markControlsHeld, x as requestKill, y as callerDescription, z as expandMcpNames } from "./run-BZNdpUGQ.mjs";
|
|
15
|
+
import { t as PaiClient } from "./ipc-client-DVZ_EGnu.mjs";
|
|
16
|
+
import { A as getConfigValueOp, C as setWorkersEnabled, D as useProvider, E as updateProvider, M as setConfigValueOp, N as unsetConfigValueOp, O as MainConfigOpsError, S as setProviderModel, T as unsetClass, _ as removeProvider, a as followWorkers, b as setClass, c as statusLineOutput, d as addProvider, f as classTargetText, g as modelPrefsText, h as describeProviders, i as fallbackStatusText, j as listConfigOp, k as formatConfigGetOutput, l as readSpecPrompt, m as describeModels, n as fallbackOn, o as psOutput, p as describeCapabilities, r as fallbackStatus, s as replayOutput, t as fallbackOff, u as resolveSpecPath, v as resolveProviderName, w as unsetCapabilityPreference, x as setProviderEnabled, y as setCapabilityPreference } from "./fallback-2yWDDYiT.mjs";
|
|
17
|
+
import { _ as resolveSessionByNameOrId, a as buildDeduped, c as hasConversation, d as providerResumePlan, f as restoreTopLevel, g as migrateSessionScanCache, h as fmtAge, l as launchInDir, m as printExitDir, o as normalizeName$2, p as resumeArgvText, s as renderDedupedSessions, t as cmdMain, u as launchPrompt, v as scanCacheFilePath, y as scanSessions } from "./main-resolver-Dxvn4Mv8.mjs";
|
|
18
|
+
import { n as queriesDirPath, t as migrateQueriesDir } from "./query-feedback-GPeVGvIa.mjs";
|
|
19
|
+
import { t as buildRunEnv } from "./run-env-Cd0Son-Y.mjs";
|
|
20
|
+
import { i as sendToSession, n as fetchLiveSessions, r as revealItermSession, t as callAiBroker } from "./aibroker-client-BfnVwGZl.mjs";
|
|
21
|
+
import { t as runChain } from "./chain-BL4khGgy.mjs";
|
|
20
22
|
import { appendFileSync, chmodSync, closeSync, copyFileSync, cpSync, createReadStream, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
21
23
|
import { homedir, platform, tmpdir, userInfo } from "node:os";
|
|
22
24
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
23
25
|
import chalk from "chalk";
|
|
26
|
+
import { execFile, execFileSync, execSync, spawn, spawnSync } from "node:child_process";
|
|
27
|
+
import { parseDocument } from "yaml";
|
|
24
28
|
import { createHash, randomUUID } from "node:crypto";
|
|
25
29
|
import { Command, InvalidArgumentError } from "commander";
|
|
26
30
|
import { fileURLToPath } from "node:url";
|
|
27
31
|
import pg from "pg";
|
|
28
|
-
import { execFile, execFileSync, execSync, spawn, spawnSync } from "node:child_process";
|
|
29
|
-
import { parseDocument } from "yaml";
|
|
30
32
|
import BetterSqlite3 from "better-sqlite3";
|
|
31
33
|
import { createInterface } from "node:readline";
|
|
32
34
|
import { createConnection } from "net";
|
|
33
35
|
import { getEncoding } from "js-tiktoken";
|
|
34
36
|
import { promisify } from "node:util";
|
|
35
37
|
|
|
36
|
-
//#region src/registry/registrable.ts
|
|
37
|
-
/**
|
|
38
|
-
* registrable.ts — directories that must never become registered projects.
|
|
39
|
-
*
|
|
40
|
-
* A project is a durable thing. The registry, however, has been accepting
|
|
41
|
-
* whatever directory a session happened to start in, and some of those
|
|
42
|
-
* directories are disposable by construction. Measured on the real registry,
|
|
43
|
-
* 2026-08-04:
|
|
44
|
-
*
|
|
45
|
-
* 08 - Others/MDF/Infrastruktur/.claude/worktrees/cool-haibt 1 session
|
|
46
|
-
* 08 - Others/MDF/Infrastruktur/.claude/worktrees/strange-haibt 7 sessions
|
|
47
|
-
* /private/tmp/ops-webui dead
|
|
48
|
-
* /private/tmp/claude-501/-Users-…-AIBroker/aae854c6-… dead
|
|
49
|
-
*
|
|
50
|
-
* The worktrees are agent isolation directories, created to be removed. The temp
|
|
51
|
-
* paths are exactly what their name says. Registering them attributes session
|
|
52
|
-
* history to a location with no future, and lets `pai <name>` route someone into
|
|
53
|
-
* a directory a cleanup can delete underneath them.
|
|
54
|
-
*
|
|
55
|
-
* So this refuses at the point of registration rather than reclassifying
|
|
56
|
-
* afterwards. It is a guard, not a policy about what health should call things —
|
|
57
|
-
* it stops the set growing while the vocabulary question (dead vs duplicate vs
|
|
58
|
-
* misnamed vs ephemeral) is decided separately.
|
|
59
|
-
*
|
|
60
|
-
* Found by the AIBroker session while we were dividing up the dead-path work.
|
|
61
|
-
*/
|
|
62
|
-
/** Path fragments that mark a location as disposable, with why. */
|
|
63
|
-
const EPHEMERAL = [
|
|
64
|
-
{
|
|
65
|
-
fragment: `${sep}.claude${sep}worktrees${sep}`,
|
|
66
|
-
because: "a git worktree created for agent isolation — it is meant to be removed"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
fragment: `${sep}private${sep}tmp${sep}`,
|
|
70
|
-
because: "a system temp directory"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
fragment: `${sep}var${sep}folders${sep}`,
|
|
74
|
-
because: "a macOS per-user temp directory"
|
|
75
|
-
}
|
|
76
|
-
];
|
|
77
|
-
/**
|
|
78
|
-
* Why this path cannot be a project, or undefined if it can.
|
|
79
|
-
*
|
|
80
|
-
* Returns the reason rather than a boolean so the caller can tell the user which
|
|
81
|
-
* rule caught them — "refused" without a reason invites someone to work around it
|
|
82
|
-
* rather than move their project somewhere durable.
|
|
83
|
-
*/
|
|
84
|
-
function unregistrableReason(rootPath) {
|
|
85
|
-
const padded = rootPath.endsWith(sep) ? rootPath : rootPath + sep;
|
|
86
|
-
for (const { fragment, because } of EPHEMERAL) if (padded.includes(fragment)) return because;
|
|
87
|
-
if (padded.startsWith(`${sep}tmp${sep}`)) return "a system temp directory";
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
38
|
//#region src/session/promote.ts
|
|
92
39
|
/**
|
|
93
40
|
* pai project promote --from-session <path> --to <new-project-path> [--name "Name"]
|
|
@@ -155,7 +102,7 @@ async function cmdPromote(opts) {
|
|
|
155
102
|
console.error(dim$1(` Pick a durable location for the new project.`));
|
|
156
103
|
process.exit(1);
|
|
157
104
|
}
|
|
158
|
-
const { getRegistryBackend } = await import("./factory-
|
|
105
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
159
106
|
const registryBackend = await getRegistryBackend();
|
|
160
107
|
const encodedDir = encodeDir(targetPath);
|
|
161
108
|
if (await registryBackend.getProjectBySlug(slug) ?? await registryBackend.getProjectByRootPath(targetPath) ?? await registryBackend.getProjectByEncodedDir(encodedDir)) {
|
|
@@ -1957,6 +1904,12 @@ async function cmdHere(name, opts = {}) {
|
|
|
1957
1904
|
console.log(dim$1(`Would create ${finalSlug} (${name}) at ${target}`));
|
|
1958
1905
|
return;
|
|
1959
1906
|
}
|
|
1907
|
+
const unregistrable = worktreeReason(target);
|
|
1908
|
+
if (unregistrable) {
|
|
1909
|
+
console.error(err(`Not registering ${target}: it is ${unregistrable}.`));
|
|
1910
|
+
process.exitCode = 1;
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1960
1913
|
const ts = now();
|
|
1961
1914
|
await backend.createProject({
|
|
1962
1915
|
slug: finalSlug,
|
|
@@ -2039,7 +1992,7 @@ async function cmdUnregister(slug, opts = {}) {
|
|
|
2039
1992
|
//#region src/cli/commands/project/projects-index.ts
|
|
2040
1993
|
function registerProjectsCommands(projectsCmd) {
|
|
2041
1994
|
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) => {
|
|
2042
|
-
const { cmdMain } = await import("./main-resolver-
|
|
1995
|
+
const { cmdMain } = await import("./main-resolver-DjQsexge.mjs");
|
|
2043
1996
|
await cmdMain(void 0, void 0, opts);
|
|
2044
1997
|
});
|
|
2045
1998
|
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(async (opts) => {
|
|
@@ -2193,7 +2146,12 @@ async function cmdMigrate$1() {
|
|
|
2193
2146
|
const encodedDir = entry.encoded_dir;
|
|
2194
2147
|
const slug = slugify$1(rootPath);
|
|
2195
2148
|
try {
|
|
2196
|
-
const
|
|
2149
|
+
const upserted = await upsertProject(backend, slug, rootPath, encodedDir);
|
|
2150
|
+
if (!upserted) {
|
|
2151
|
+
projectsSkipped++;
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2154
|
+
const { isNew, id } = upserted;
|
|
2197
2155
|
if (isNew) projectsNew++;
|
|
2198
2156
|
else projectsSkipped++;
|
|
2199
2157
|
const notes = entry.notes ?? [];
|
|
@@ -2905,7 +2863,15 @@ const DEFAULT_PAGE_SIZE = 500;
|
|
|
2905
2863
|
async function runEmbed(backend, projectId, projectSlug, batchSize = 50, pageSize = DEFAULT_PAGE_SIZE) {
|
|
2906
2864
|
const label = projectSlug ? `project ${projectSlug}` : "all projects";
|
|
2907
2865
|
console.log(dim$1(`Generating embeddings for ${label} (this may take a while on first run)...`));
|
|
2908
|
-
const {
|
|
2866
|
+
const { serializeEmbedding } = await import("./embeddings-DrJ-ewfi.mjs");
|
|
2867
|
+
const { gateBackend } = await import("./embedding-gate-SJMCPwxG.mjs");
|
|
2868
|
+
const gate = await gateBackend(backend, { record: true });
|
|
2869
|
+
if (!gate.ok) {
|
|
2870
|
+
console.error(err(gate.reason));
|
|
2871
|
+
process.exitCode = 1;
|
|
2872
|
+
return;
|
|
2873
|
+
}
|
|
2874
|
+
const embedder = gate.backend;
|
|
2909
2875
|
const { chunks: totalEstimate } = projectId !== void 0 ? await backend.getProjectStats(projectId) : await backend.getStats();
|
|
2910
2876
|
let done = 0;
|
|
2911
2877
|
let after = null;
|
|
@@ -2914,7 +2880,7 @@ async function runEmbed(backend, projectId, projectSlug, batchSize = 50, pageSiz
|
|
|
2914
2880
|
if (page.length === 0) break;
|
|
2915
2881
|
for (let i = 0; i < page.length; i += batchSize) {
|
|
2916
2882
|
const batch = page.slice(i, i + batchSize);
|
|
2917
|
-
const vecs = await
|
|
2883
|
+
const vecs = await retryTransient(() => embedder.embed(batch.map((r) => r.text)));
|
|
2918
2884
|
await Promise.all(batch.map((row, j) => retryTransient(() => backend.updateEmbedding(row.id, serializeEmbedding(vecs[j])))));
|
|
2919
2885
|
done += batch.length;
|
|
2920
2886
|
process.stdout.write(`\r ${done} / ~${totalEstimate} chunks embedded...`);
|
|
@@ -3074,10 +3040,14 @@ function registerSearchCommand(memoryCmd) {
|
|
|
3074
3040
|
let results;
|
|
3075
3041
|
if (mode === "keyword") results = await backend.searchKeyword(query, searchOpts);
|
|
3076
3042
|
else {
|
|
3077
|
-
const {
|
|
3043
|
+
const { embedQuery } = await import("./embedding-gate-SJMCPwxG.mjs");
|
|
3078
3044
|
console.log(dim$1("Generating query embedding..."));
|
|
3079
|
-
const
|
|
3080
|
-
|
|
3045
|
+
const q = await embedQuery(backend, query);
|
|
3046
|
+
const queryEmbedding = q.vec;
|
|
3047
|
+
if (!queryEmbedding) {
|
|
3048
|
+
console.log(dim$1(` ${q.note}`));
|
|
3049
|
+
results = await backend.searchKeyword(query, searchOpts);
|
|
3050
|
+
} else if (mode === "semantic") results = await backend.searchSemantic(queryEmbedding, searchOpts);
|
|
3081
3051
|
else {
|
|
3082
3052
|
const [keywordResults, semanticResults] = await Promise.all([backend.searchKeyword(query, {
|
|
3083
3053
|
...searchOpts,
|
|
@@ -3120,7 +3090,7 @@ function registerSearchCommand(memoryCmd) {
|
|
|
3120
3090
|
return;
|
|
3121
3091
|
}
|
|
3122
3092
|
if (opts.rerank !== false) {
|
|
3123
|
-
const { rerankResults } = await import("./reranker-
|
|
3093
|
+
const { rerankResults } = await import("./reranker-YwDT2n5e.mjs");
|
|
3124
3094
|
console.log(dim$1("Reranking with cross-encoder..."));
|
|
3125
3095
|
results = await rerankResults(query, results, { topK: maxResults });
|
|
3126
3096
|
}
|
|
@@ -3259,9 +3229,9 @@ function registerStatsCommands(memoryCmd) {
|
|
|
3259
3229
|
//#region src/cli/commands/memory/sources-cmd.ts
|
|
3260
3230
|
function registerSourcesCommand(memoryCmd) {
|
|
3261
3231
|
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) => {
|
|
3262
|
-
const { createStorageBackend } = await import("./factory-
|
|
3263
|
-
const { loadConfig } = await import("./config-
|
|
3264
|
-
const { cmdMemorySources } = await import("./sources-
|
|
3232
|
+
const { createStorageBackend } = await import("./factory-DjtXElOI.mjs");
|
|
3233
|
+
const { loadConfig } = await import("./config-yomayAwe.mjs");
|
|
3234
|
+
const { cmdMemorySources } = await import("./sources-CvvzNZad.mjs");
|
|
3265
3235
|
let backend;
|
|
3266
3236
|
try {
|
|
3267
3237
|
backend = await createStorageBackend(loadConfig());
|
|
@@ -3318,6 +3288,99 @@ function registerPassCommand(memoryCmd) {
|
|
|
3318
3288
|
});
|
|
3319
3289
|
}
|
|
3320
3290
|
|
|
3291
|
+
//#endregion
|
|
3292
|
+
//#region src/memory/reembed.ts
|
|
3293
|
+
async function reembedIndex(storage, target, opts = {}) {
|
|
3294
|
+
const batch = opts.batchSize ?? 5e3;
|
|
3295
|
+
let total = 0;
|
|
3296
|
+
for (;;) {
|
|
3297
|
+
const n = await storage.clearEmbeddingsBatch(batch);
|
|
3298
|
+
if (n === 0) break;
|
|
3299
|
+
total += n;
|
|
3300
|
+
opts.onBatch?.(total);
|
|
3301
|
+
}
|
|
3302
|
+
await storage.setEmbeddingBinding({
|
|
3303
|
+
backend: target.id,
|
|
3304
|
+
model: target.model,
|
|
3305
|
+
dims: target.dims
|
|
3306
|
+
});
|
|
3307
|
+
return total;
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
//#endregion
|
|
3311
|
+
//#region src/cli/commands/memory/backend.ts
|
|
3312
|
+
function fail$5(e) {
|
|
3313
|
+
console.error(err(e instanceof Error ? e.message : String(e)));
|
|
3314
|
+
process.exitCode = 1;
|
|
3315
|
+
}
|
|
3316
|
+
function registerBackendCommands(memoryCmd) {
|
|
3317
|
+
const backendCmd = memoryCmd.command("backend").description("Embedding backends: detect, use, provision (an index is bound to the backend that embedded it)");
|
|
3318
|
+
backendCmd.command("detect").description("Probe the available embedding backends (ollama, then transformers-cpu) and recommend the fastest").action(async () => {
|
|
3319
|
+
try {
|
|
3320
|
+
const cfg = loadConfig();
|
|
3321
|
+
const { results, recommended } = await detectBackends(cfg);
|
|
3322
|
+
for (const r of results) console.log(` ${r.ok ? ok$1(r.id) : dim$1(r.id)} ${r.ok ? "available" : "unavailable"}: ${r.reason}`);
|
|
3323
|
+
console.log(`\nConfigured: ${bold$1(cfg.embedding?.backend ?? "transformers-cpu-q8")}`);
|
|
3324
|
+
console.log(recommended ? `Recommended: ${bold$1(recommended)}` : "Recommended: none available");
|
|
3325
|
+
if (recommended && recommended !== cfg.embedding?.backend) console.log(dim$1(` Switch with \`pai memory backend use ${recommended}\` (an existing index also needs \`pai memory reembed\`).`));
|
|
3326
|
+
} catch (e) {
|
|
3327
|
+
fail$5(e);
|
|
3328
|
+
}
|
|
3329
|
+
});
|
|
3330
|
+
backendCmd.command("use <id>").description(`Write the embedding backend to config (${BACKEND_IDS.join(" | ")}); does not touch the index`).option("--model <name>", "Model name on the backend (ollama: server-side model name)").action(async (id, opts) => {
|
|
3331
|
+
try {
|
|
3332
|
+
const b = createBackend(id, loadConfig(), opts.model);
|
|
3333
|
+
setConfigValueOp("embedding.backend", id);
|
|
3334
|
+
if (opts.model) setConfigValueOp("embedding.model", opts.model, { force: true });
|
|
3335
|
+
console.log(ok$1(`embedding.backend = ${id}`) + (opts.model ? ` (model ${b.model})` : ""));
|
|
3336
|
+
const avail = await b.available();
|
|
3337
|
+
if (!avail.ok) console.log(dim$1(` Note: not available right now: ${avail.reason}`));
|
|
3338
|
+
console.log(dim$1(" If the index already holds vectors from another backend, run `pai memory reembed`."));
|
|
3339
|
+
} catch (e) {
|
|
3340
|
+
fail$5(e);
|
|
3341
|
+
}
|
|
3342
|
+
});
|
|
3343
|
+
backendCmd.command("provision <backend>").description("Provision a backend's model. ollama: download the F16 GGUF of arctic-embed-m-v1.5 and `ollama create` it").action(async (name) => {
|
|
3344
|
+
try {
|
|
3345
|
+
if (name !== "ollama") throw new Error(`Cannot provision "${name}"; only "ollama" needs provisioning`);
|
|
3346
|
+
const cfg = loadConfig();
|
|
3347
|
+
await provisionOllama({
|
|
3348
|
+
baseUrl: cfg.embedding?.ollama?.baseUrl ?? OLLAMA_DEFAULT_URL,
|
|
3349
|
+
model: cfg.embedding?.model ?? OLLAMA_DEFAULT_MODEL
|
|
3350
|
+
});
|
|
3351
|
+
console.log(ok$1("Done.") + dim$1(` Use it with \`pai memory backend use ${OLLAMA_ID}\`.`));
|
|
3352
|
+
} catch (e) {
|
|
3353
|
+
fail$5(e);
|
|
3354
|
+
}
|
|
3355
|
+
});
|
|
3356
|
+
memoryCmd.command("reembed").description("Switch the index to an embedding backend: clears all vectors (batched, resumable); `pai memory embed` refills").option("--backend <id>", "Target backend (default: the configured one); also written to config").option("--yes", "Confirm; without it only the plan is printed").action(async (opts) => {
|
|
3357
|
+
try {
|
|
3358
|
+
const cfg = loadConfig();
|
|
3359
|
+
const id = opts.backend ?? cfg.embedding?.backend ?? "transformers-cpu-q8";
|
|
3360
|
+
const target = createBackend(id, cfg);
|
|
3361
|
+
const avail = await target.available();
|
|
3362
|
+
if (!avail.ok) throw new Error(`${id} is not available: ${avail.reason}`);
|
|
3363
|
+
const storage = await getStorageBackend();
|
|
3364
|
+
const { chunks } = await storage.getStats();
|
|
3365
|
+
const cps = await measureThroughput(target, Array.from({ length: 32 }, () => "memory index chunk embedding vector query ".repeat(40)));
|
|
3366
|
+
const eta = cps > 0 ? Math.round(chunks / cps / 60) : NaN;
|
|
3367
|
+
console.log(`Index: ${bold$1(String(chunks))} chunks. Backend ${bold$1(id)} runs ~${cps.toFixed(1)} chunks/s: ETA ~${eta} min.`);
|
|
3368
|
+
if (!opts.yes) {
|
|
3369
|
+
console.error(err("Refusing without --yes: this clears every stored vector (keyword search keeps working while it refills)."));
|
|
3370
|
+
process.exitCode = 1;
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
const cleared = await reembedIndex(storage, target, { onBatch: (n) => process.stdout.write(`\r ${n} vectors cleared...`) });
|
|
3374
|
+
process.stdout.write("\r");
|
|
3375
|
+
if (opts.backend && opts.backend !== cfg.embedding?.backend) setConfigValueOp("embedding.backend", id);
|
|
3376
|
+
console.log(ok$1(`Cleared ${cleared} vectors; index bound to ${id} (${target.model}).`));
|
|
3377
|
+
console.log(dim$1(" Refill with `pai memory embed --background` (the daemon pass also does it)."));
|
|
3378
|
+
} catch (e) {
|
|
3379
|
+
fail$5(e);
|
|
3380
|
+
}
|
|
3381
|
+
});
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3321
3384
|
//#endregion
|
|
3322
3385
|
//#region src/cli/commands/memory/index.ts
|
|
3323
3386
|
function registerMemoryCommands(memoryCmd) {
|
|
@@ -3327,6 +3390,7 @@ function registerMemoryCommands(memoryCmd) {
|
|
|
3327
3390
|
registerStatsCommands(memoryCmd);
|
|
3328
3391
|
registerSourcesCommand(memoryCmd);
|
|
3329
3392
|
registerPassCommand(memoryCmd);
|
|
3393
|
+
registerBackendCommands(memoryCmd);
|
|
3330
3394
|
}
|
|
3331
3395
|
|
|
3332
3396
|
//#endregion
|
|
@@ -4001,8 +4065,8 @@ async function escalate(task, headline, detail, state, now, opts) {
|
|
|
4001
4065
|
state.alarmedAt[task.id] = now;
|
|
4002
4066
|
let delivered = false;
|
|
4003
4067
|
try {
|
|
4004
|
-
const { routeNotification } = await import("./router-
|
|
4005
|
-
const { loadConfig } = await import("./config-
|
|
4068
|
+
const { routeNotification } = await import("./router-DyiZNI6o.mjs");
|
|
4069
|
+
const { loadConfig } = await import("./config-yomayAwe.mjs");
|
|
4006
4070
|
delivered = (await routeNotification({
|
|
4007
4071
|
event: "error",
|
|
4008
4072
|
title: `PAI: ${headline}`,
|
|
@@ -4037,7 +4101,7 @@ async function escalate(task, headline, detail, state, now, opts) {
|
|
|
4037
4101
|
async function alertParked(task, reason) {
|
|
4038
4102
|
const text = `PAI parked "${task.title}" (${task.id}) — the scheduler will not retry it.\nReason: ${reason}\nTo release it: fix the cause, then move the due date — due_string, natural language only (e.g. "tomorrow 9am").`;
|
|
4039
4103
|
try {
|
|
4040
|
-
const { callAiBroker } = await import("./aibroker-client-
|
|
4104
|
+
const { callAiBroker } = await import("./aibroker-client-C-O3Fflh.mjs");
|
|
4041
4105
|
await callAiBroker("pailot_send", { text }, 8e3);
|
|
4042
4106
|
} catch (e) {
|
|
4043
4107
|
console.error(`[pai-poller] parked-task alert not delivered to PAILot (${e instanceof Error ? e.message : String(e)}): ${text}`);
|
|
@@ -6826,6 +6890,7 @@ async function cmdStatus$1() {
|
|
|
6826
6890
|
console.log(dim$1(` PID: ${resolveDaemonPid() ?? "unknown"}`));
|
|
6827
6891
|
console.log(dim$1(` Uptime: ${s["uptime"]}s`));
|
|
6828
6892
|
console.log(dim$1(` Socket: ${s["socketPath"]}`));
|
|
6893
|
+
if (s["dashboard"]) console.log(dim$1(` Dashboard: ${s["dashboard"]}`));
|
|
6829
6894
|
const health = formatStorageHealth(s);
|
|
6830
6895
|
if (health.length > 0) {
|
|
6831
6896
|
console.log();
|
|
@@ -7132,8 +7197,8 @@ function cmdLogs(opts) {
|
|
|
7132
7197
|
}
|
|
7133
7198
|
function registerDaemonCommands(daemonCmd) {
|
|
7134
7199
|
daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
|
|
7135
|
-
const { serve } = await import("./daemon-
|
|
7136
|
-
const { loadConfig: lc, ensureConfigDir } = await import("./config-
|
|
7200
|
+
const { serve } = await import("./daemon-WrncnGua.mjs");
|
|
7201
|
+
const { loadConfig: lc, ensureConfigDir } = await import("./config-yomayAwe.mjs");
|
|
7137
7202
|
ensureConfigDir();
|
|
7138
7203
|
await serve(lc());
|
|
7139
7204
|
});
|
|
@@ -7742,12 +7807,36 @@ async function stepStorage(rl) {
|
|
|
7742
7807
|
//#endregion
|
|
7743
7808
|
//#region src/cli/commands/setup/steps/03-embedding.ts
|
|
7744
7809
|
/** Step 3: Embedding model selection for semantic search. */
|
|
7810
|
+
/**
|
|
7811
|
+
* Probe the embedding backends (also under --yes). A fresh install adopts the
|
|
7812
|
+
* fastest available one; an existing install (embeddingModel already set) may
|
|
7813
|
+
* hold vectors from the current backend, so it is only told what is available.
|
|
7814
|
+
*/
|
|
7815
|
+
async function stepBackend(rl, fresh) {
|
|
7816
|
+
const { results, recommended } = await detectBackends();
|
|
7817
|
+
line$1();
|
|
7818
|
+
for (const r of results) console.log(` ${r.ok ? c.ok(r.id) : c.dim(r.id)}: ${r.reason}`);
|
|
7819
|
+
if (!recommended) return {};
|
|
7820
|
+
if (!fresh) {
|
|
7821
|
+
console.log(c.dim(` Recommended: ${recommended}. Switch with \`pai memory backend use ${recommended}\` + \`pai memory reembed\`.`));
|
|
7822
|
+
return {};
|
|
7823
|
+
}
|
|
7824
|
+
if (recommended === OLLAMA_ID && await promptYesNo(rl, "Use Ollama (GPU, several times faster)?", true)) return { embedding: {
|
|
7825
|
+
backend: OLLAMA_ID,
|
|
7826
|
+
model: OLLAMA_DEFAULT_MODEL,
|
|
7827
|
+
ollama: { baseUrl: OLLAMA_DEFAULT_URL }
|
|
7828
|
+
} };
|
|
7829
|
+
return {};
|
|
7830
|
+
}
|
|
7745
7831
|
async function stepEmbedding(rl) {
|
|
7746
7832
|
section("Step 3: Embedding Model");
|
|
7747
7833
|
const existing = readConfigRaw();
|
|
7748
7834
|
if (existing.embeddingModel) {
|
|
7749
7835
|
console.log(c.ok(`Embedding model: ${existing.embeddingModel}. Skipping.`));
|
|
7750
|
-
return {
|
|
7836
|
+
return {
|
|
7837
|
+
embeddingModel: existing.embeddingModel,
|
|
7838
|
+
...await stepBackend(rl, false)
|
|
7839
|
+
};
|
|
7751
7840
|
}
|
|
7752
7841
|
line$1();
|
|
7753
7842
|
line$1(" An embedding model converts your text into vectors for semantic search.");
|
|
@@ -7771,12 +7860,13 @@ async function stepEmbedding(rl) {
|
|
|
7771
7860
|
description: "BM25/keyword search only. No model download needed. You can add embeddings later by running `pai memory embed` after selecting a model."
|
|
7772
7861
|
}
|
|
7773
7862
|
]);
|
|
7774
|
-
const
|
|
7863
|
+
const models = {
|
|
7775
7864
|
0: "Snowflake/snowflake-arctic-embed-m-v1.5",
|
|
7776
7865
|
1: "BAAI/bge-small-en-v1.5",
|
|
7777
7866
|
2: "nomic-ai/nomic-embed-text-v1.5",
|
|
7778
7867
|
3: null
|
|
7779
|
-
}
|
|
7868
|
+
};
|
|
7869
|
+
const selectedModel = models[choice];
|
|
7780
7870
|
line$1();
|
|
7781
7871
|
if (selectedModel) {
|
|
7782
7872
|
console.log(c.ok(`Model selected: ${selectedModel}`));
|
|
@@ -7785,7 +7875,11 @@ async function stepEmbedding(rl) {
|
|
|
7785
7875
|
console.log(c.ok("Skipping embeddings. Keyword search will still work."));
|
|
7786
7876
|
console.log(c.dim(` Add later: update embeddingModel in ${CONFIG_FILE$2}`));
|
|
7787
7877
|
}
|
|
7788
|
-
|
|
7878
|
+
const backendUpdate = selectedModel === models[0] ? await stepBackend(rl, true) : {};
|
|
7879
|
+
return {
|
|
7880
|
+
embeddingModel: selectedModel ?? "none",
|
|
7881
|
+
...backendUpdate
|
|
7882
|
+
};
|
|
7789
7883
|
}
|
|
7790
7884
|
|
|
7791
7885
|
//#endregion
|
|
@@ -9759,7 +9853,7 @@ async function cmdExplore(note, opts) {
|
|
|
9759
9853
|
const depth = parseInt(opts.depth ?? "3", 10);
|
|
9760
9854
|
const direction = opts.direction ?? "both";
|
|
9761
9855
|
const mode = opts.mode ?? "all";
|
|
9762
|
-
const { zettelExplore } = await import("./zettelkasten-
|
|
9856
|
+
const { zettelExplore } = await import("./zettelkasten-DtkAvA18.mjs");
|
|
9763
9857
|
const result = await zettelExplore(await getFedBackend(), {
|
|
9764
9858
|
startNote: note,
|
|
9765
9859
|
depth,
|
|
@@ -9824,7 +9918,7 @@ async function cmdHealth(opts) {
|
|
|
9824
9918
|
const projectPath = opts.project;
|
|
9825
9919
|
const recentDays = parseInt(opts.days ?? "30", 10);
|
|
9826
9920
|
const includeTypes = opts.include ? opts.include.split(",").map((s) => s.trim()) : void 0;
|
|
9827
|
-
const { zettelHealth } = await import("./zettelkasten-
|
|
9921
|
+
const { zettelHealth } = await import("./zettelkasten-DtkAvA18.mjs");
|
|
9828
9922
|
const result = await zettelHealth(await getFedBackend(), {
|
|
9829
9923
|
scope,
|
|
9830
9924
|
projectPath,
|
|
@@ -9895,7 +9989,7 @@ async function cmdSurprise(note, opts) {
|
|
|
9895
9989
|
const limit = parseInt(opts.limit ?? "10", 10);
|
|
9896
9990
|
const minSimilarity = parseFloat(opts.minSimilarity ?? "0.3");
|
|
9897
9991
|
const minGraphDistance = parseInt(opts.minDistance ?? "3", 10);
|
|
9898
|
-
const { zettelSurprise } = await import("./zettelkasten-
|
|
9992
|
+
const { zettelSurprise } = await import("./zettelkasten-DtkAvA18.mjs");
|
|
9899
9993
|
const backend = await getFedBackend();
|
|
9900
9994
|
console.log();
|
|
9901
9995
|
console.log(header(" PAI Zettel Surprise"));
|
|
@@ -9950,7 +10044,7 @@ async function cmdSuggest(note, opts) {
|
|
|
9950
10044
|
const vaultProjectId = parseInt(opts.vaultProjectId, 10);
|
|
9951
10045
|
const limit = parseInt(opts.limit ?? "5", 10);
|
|
9952
10046
|
const excludeLinked = opts.excludeLinked !== false;
|
|
9953
|
-
const { zettelSuggest } = await import("./zettelkasten-
|
|
10047
|
+
const { zettelSuggest } = await import("./zettelkasten-DtkAvA18.mjs");
|
|
9954
10048
|
const backend = await getFedBackend();
|
|
9955
10049
|
console.log();
|
|
9956
10050
|
console.log(header(" PAI Zettel Suggest"));
|
|
@@ -10003,7 +10097,7 @@ async function cmdConverse(question, opts) {
|
|
|
10003
10097
|
const vaultProjectId = parseInt(opts.vaultProjectId, 10);
|
|
10004
10098
|
const depth = parseInt(opts.depth ?? "2", 10);
|
|
10005
10099
|
const limit = parseInt(opts.limit ?? "15", 10);
|
|
10006
|
-
const { zettelConverse } = await import("./zettelkasten-
|
|
10100
|
+
const { zettelConverse } = await import("./zettelkasten-DtkAvA18.mjs");
|
|
10007
10101
|
const backend = await getFedBackend();
|
|
10008
10102
|
console.log();
|
|
10009
10103
|
console.log(header(" PAI Zettel Converse"));
|
|
@@ -10066,7 +10160,7 @@ async function cmdThemes(opts) {
|
|
|
10066
10160
|
const minClusterSize = parseInt(opts.minSize ?? "3", 10);
|
|
10067
10161
|
const maxThemes = parseInt(opts.maxThemes ?? "10", 10);
|
|
10068
10162
|
const similarityThreshold = parseFloat(opts.threshold ?? "0.65");
|
|
10069
|
-
const { zettelThemes } = await import("./zettelkasten-
|
|
10163
|
+
const { zettelThemes } = await import("./zettelkasten-DtkAvA18.mjs");
|
|
10070
10164
|
const backend = await getFedBackend();
|
|
10071
10165
|
console.log();
|
|
10072
10166
|
console.log(header(" PAI Zettel Themes"));
|
|
@@ -16138,7 +16232,7 @@ async function migrateToPostgres(opts = {}) {
|
|
|
16138
16232
|
const dump = pgDump(container, pgConfig, dumpPath);
|
|
16139
16233
|
if (!dump.ok) return refused(dump.reason, dryRun);
|
|
16140
16234
|
}
|
|
16141
|
-
const { PostgresBackend } = await import("./postgres-
|
|
16235
|
+
const { PostgresBackend } = await import("./postgres-CzkEPfAm.mjs");
|
|
16142
16236
|
await PostgresBackend.ensureDatabase(pgConfig);
|
|
16143
16237
|
const sqlite = new BetterSqlite3(sqliteFederationPath, { readonly: true });
|
|
16144
16238
|
const registrySqlite = sqliteRegistryPath === sqliteFederationPath ? sqlite : new BetterSqlite3(sqliteRegistryPath, { readonly: true });
|
|
@@ -16709,7 +16803,7 @@ async function getSessionTags(registryBackend, sessionId) {
|
|
|
16709
16803
|
* Session CRUD commands: list, info, rename, slug, tag, route, active, auto-route.
|
|
16710
16804
|
*/
|
|
16711
16805
|
async function cmdList(projectSlug, opts) {
|
|
16712
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16806
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
16713
16807
|
const registryBackend = await getRegistryBackend();
|
|
16714
16808
|
const limit = parseInt(opts.limit ?? "20", 10);
|
|
16715
16809
|
let project;
|
|
@@ -16774,7 +16868,7 @@ async function cmdList(projectSlug, opts) {
|
|
|
16774
16868
|
console.log(dim$1(` ${rows.length} session(s) shown (limit: ${limit})`));
|
|
16775
16869
|
}
|
|
16776
16870
|
async function cmdInfo(projectSlug, sessionNumber) {
|
|
16777
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16871
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
16778
16872
|
const registryBackend = await getRegistryBackend();
|
|
16779
16873
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16780
16874
|
if (!project) {
|
|
@@ -16798,7 +16892,7 @@ async function cmdInfo(projectSlug, sessionNumber) {
|
|
|
16798
16892
|
console.log();
|
|
16799
16893
|
}
|
|
16800
16894
|
async function cmdRename(projectSlug, numberOrLatest, newSlug) {
|
|
16801
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16895
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
16802
16896
|
await cmdRenameWith(await getRegistryBackend(), projectSlug, numberOrLatest, newSlug);
|
|
16803
16897
|
}
|
|
16804
16898
|
async function cmdRenameWith(registryBackend, projectSlug, numberOrLatest, newSlug) {
|
|
@@ -16861,7 +16955,7 @@ async function cmdRenameWith(registryBackend, projectSlug, numberOrLatest, newSl
|
|
|
16861
16955
|
console.log();
|
|
16862
16956
|
}
|
|
16863
16957
|
async function cmdSlug(projectSlug, numberOrLatest, opts) {
|
|
16864
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16958
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
16865
16959
|
const registryBackend = await getRegistryBackend();
|
|
16866
16960
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16867
16961
|
if (!project) {
|
|
@@ -16891,7 +16985,7 @@ async function cmdSlug(projectSlug, numberOrLatest, opts) {
|
|
|
16891
16985
|
}
|
|
16892
16986
|
}
|
|
16893
16987
|
async function cmdTag(projectSlug, sessionNumber, rawTags) {
|
|
16894
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16988
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
16895
16989
|
const registryBackend = await getRegistryBackend();
|
|
16896
16990
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16897
16991
|
if (!project) {
|
|
@@ -16931,7 +17025,7 @@ async function cmdTag(projectSlug, sessionNumber, rawTags) {
|
|
|
16931
17025
|
console.log();
|
|
16932
17026
|
}
|
|
16933
17027
|
async function cmdRoute(projectSlug, sessionNumber, targetProjectSlug, opts) {
|
|
16934
|
-
const { getRegistryBackend } = await import("./factory-
|
|
17028
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
16935
17029
|
const registryBackend = await getRegistryBackend();
|
|
16936
17030
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16937
17031
|
if (!project) {
|
|
@@ -16973,7 +17067,7 @@ async function cmdRoute(projectSlug, sessionNumber, targetProjectSlug, opts) {
|
|
|
16973
17067
|
console.log();
|
|
16974
17068
|
}
|
|
16975
17069
|
async function cmdActive(opts) {
|
|
16976
|
-
const { getRegistryBackend } = await import("./factory-
|
|
17070
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
16977
17071
|
const registryBackend = await getRegistryBackend();
|
|
16978
17072
|
const minutes = parseInt(opts.minutes ?? "60", 10);
|
|
16979
17073
|
const cutoff = Date.now() - minutes * 60 * 1e3;
|
|
@@ -17060,9 +17154,9 @@ async function cmdActive(opts) {
|
|
|
17060
17154
|
], rows));
|
|
17061
17155
|
}
|
|
17062
17156
|
async function cmdAutoRoute(opts) {
|
|
17063
|
-
const { autoRoute, formatAutoRouteJson } = await import("./auto-route-
|
|
17064
|
-
const { getRegistryBackend, createStorageBackend } = await import("./factory-
|
|
17065
|
-
const { loadConfig } = await import("./config-
|
|
17157
|
+
const { autoRoute, formatAutoRouteJson } = await import("./auto-route-DCxTKz19.mjs");
|
|
17158
|
+
const { getRegistryBackend, createStorageBackend } = await import("./factory-DjtXElOI.mjs");
|
|
17159
|
+
const { loadConfig } = await import("./config-yomayAwe.mjs");
|
|
17066
17160
|
const config = loadConfig();
|
|
17067
17161
|
const registryBackend = await getRegistryBackend();
|
|
17068
17162
|
const federation = await createStorageBackend(config);
|
|
@@ -17298,7 +17392,7 @@ async function cmdPause(opts) {
|
|
|
17298
17392
|
process.exitCode = 1;
|
|
17299
17393
|
return;
|
|
17300
17394
|
}
|
|
17301
|
-
const { getRegistryBackend } = await import("./factory-
|
|
17395
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
17302
17396
|
const registryBackend = await getRegistryBackend();
|
|
17303
17397
|
const cwd = process.cwd();
|
|
17304
17398
|
const project = await resolveProjectByCwd(registryBackend, cwd);
|
|
@@ -17693,7 +17787,7 @@ function buildStopBody(project, sessionId) {
|
|
|
17693
17787
|
}
|
|
17694
17788
|
}
|
|
17695
17789
|
async function cmdHandover(projectSlug, numberOrLatest, sessionId) {
|
|
17696
|
-
const { getRegistryBackend } = await import("./factory-
|
|
17790
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
17697
17791
|
const registryBackend = await getRegistryBackend();
|
|
17698
17792
|
let project;
|
|
17699
17793
|
if (projectSlug) {
|
|
@@ -17989,7 +18083,7 @@ function touchSentinel(rootPath) {
|
|
|
17989
18083
|
async function cmdAutosave(opts) {
|
|
17990
18084
|
const minGap = parseInt(opts.minGap ?? String(DEFAULT_MIN_GAP), 10);
|
|
17991
18085
|
const cwd = process.cwd();
|
|
17992
|
-
const { getRegistryBackend } = await import("./factory-
|
|
18086
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
17993
18087
|
const registryBackend = await getRegistryBackend();
|
|
17994
18088
|
const project = await resolveProjectByCwd(registryBackend, cwd);
|
|
17995
18089
|
if (!project) return;
|
|
@@ -19429,6 +19523,18 @@ function registerWorkerCommands(workerCmd) {
|
|
|
19429
19523
|
fail(e);
|
|
19430
19524
|
}
|
|
19431
19525
|
});
|
|
19526
|
+
workerCmd.command("wait-on <pid>").description("Wait at most --max seconds (default 110, cap 115) for a detached job's pid; exit 0 gone, 3 still running, 2 never existed.\nRecipe: nohup sh -c 'CMD; echo $? > /tmp/job.rc' > /tmp/job.log 2>&1 & echo $! > /tmp/job.pid ; then repeat `pai worker wait-on $(cat /tmp/job.pid) --log /tmp/job.log` until exit 0.").option("--log <file>", "Log file whose last lines are printed on return; <file>.rc holds the exit code").option("--max <secs>", "Maximum seconds to block (default 110, hard cap 115)", parseIntArg).option("--tail <n>", "Log lines printed on return (default 20)", parseIntArg).action(async (pid, opts) => {
|
|
19527
|
+
try {
|
|
19528
|
+
process.exitCode = await waitOn({
|
|
19529
|
+
pid: Number(pid),
|
|
19530
|
+
log: opts.log,
|
|
19531
|
+
maxSecs: opts.max,
|
|
19532
|
+
tail: opts.tail
|
|
19533
|
+
});
|
|
19534
|
+
} catch (e) {
|
|
19535
|
+
fail(e);
|
|
19536
|
+
}
|
|
19537
|
+
});
|
|
19432
19538
|
workerCmd.command("wait <ids...>").description("Poll workers until they finish; prints each result as one JSON line, exit 1 on failure or timeout\nNever busy-wait for a worker: no sleep loops, no sleep-then-`pai worker ps` polling, no manual retry loops. Two sanctioned waits: run workers as background Bash tasks (the harness notifies on completion), or call `pai worker wait`, which blocks until they finish and prints each result. If you catch yourself sleeping to re-check a worker, stop — you already get notified. Supervision events arrive automatically — no polling, no sleeps: the daemon watches your workers and tells you when one finishes, fails or stalls (docs/worker.md, Supervision).").option("--timeout <secs>", "Give up after this many seconds (default 900)", parseIntArg).action(async (ids, opts) => {
|
|
19433
19539
|
try {
|
|
19434
19540
|
const { results, timedOut } = await waitWorkers(currentLogDir(), ids, { timeoutMs: (opts.timeout ?? 900) * 1e3 });
|
|
@@ -20353,8 +20459,8 @@ async function analyzeProject(registryBackend, project) {
|
|
|
20353
20459
|
async function countVectorDbPaths(oldPaths) {
|
|
20354
20460
|
if (oldPaths.length === 0) return 0;
|
|
20355
20461
|
try {
|
|
20356
|
-
const { loadConfig } = await import("./config-
|
|
20357
|
-
const { createStorageBackend } = await import("./factory-
|
|
20462
|
+
const { loadConfig } = await import("./config-yomayAwe.mjs");
|
|
20463
|
+
const { createStorageBackend } = await import("./factory-DjtXElOI.mjs");
|
|
20358
20464
|
const config = loadConfig();
|
|
20359
20465
|
if (config.storageBackend !== "postgres") return 0;
|
|
20360
20466
|
const backend = await createStorageBackend(config);
|
|
@@ -20371,8 +20477,8 @@ async function countVectorDbPaths(oldPaths) {
|
|
|
20371
20477
|
async function updateVectorDbPaths(moves) {
|
|
20372
20478
|
if (moves.length === 0) return 0;
|
|
20373
20479
|
try {
|
|
20374
|
-
const { loadConfig } = await import("./config-
|
|
20375
|
-
const { createStorageBackend } = await import("./factory-
|
|
20480
|
+
const { loadConfig } = await import("./config-yomayAwe.mjs");
|
|
20481
|
+
const { createStorageBackend } = await import("./factory-DjtXElOI.mjs");
|
|
20376
20482
|
const config = loadConfig();
|
|
20377
20483
|
if (config.storageBackend !== "postgres") return 0;
|
|
20378
20484
|
const backend = await createStorageBackend(config);
|
|
@@ -20459,7 +20565,7 @@ async function displayDryRun(plans) {
|
|
|
20459
20565
|
console.log();
|
|
20460
20566
|
}
|
|
20461
20567
|
async function executeCleanup(plans, skipReindex) {
|
|
20462
|
-
const { getRegistryBackend } = await import("./factory-
|
|
20568
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
20463
20569
|
const registryBackend = await getRegistryBackend();
|
|
20464
20570
|
let deleted = 0;
|
|
20465
20571
|
let renamed = 0;
|
|
@@ -20656,7 +20762,7 @@ async function executeCleanup(plans, skipReindex) {
|
|
|
20656
20762
|
//#region src/cli/commands/session-cleanup/index.ts
|
|
20657
20763
|
function registerSessionCleanupCommand(sessionCmd) {
|
|
20658
20764
|
sessionCmd.command("cleanup [project-slug]").description("Clean up session notes: delete empties, auto-name unnamed, move into YYYY/MM/ hierarchy, renumber").option("--execute", "Actually perform the cleanup (default is dry-run)").option("--no-renumber", "Skip renumbering sessions after deletions").option("--no-reindex", "Skip triggering memory re-index after moves").action(async (projectSlug, opts) => {
|
|
20659
|
-
const { getRegistryBackend } = await import("./factory-
|
|
20765
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
20660
20766
|
const registryBackend = await getRegistryBackend();
|
|
20661
20767
|
const dryRun = !opts.execute;
|
|
20662
20768
|
const skipReindex = opts.reindex === false;
|
|
@@ -20726,7 +20832,7 @@ function finalizeNote(notePath) {
|
|
|
20726
20832
|
}
|
|
20727
20833
|
async function cmdEnd(opts) {
|
|
20728
20834
|
await cmdPause(opts);
|
|
20729
|
-
const { getRegistryBackend } = await import("./factory-
|
|
20835
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
20730
20836
|
const registryBackend = await getRegistryBackend();
|
|
20731
20837
|
const cwd = process.cwd();
|
|
20732
20838
|
const project = await registryBackend.findProjectByCwdPrefix(cwd);
|
|
@@ -21174,7 +21280,7 @@ async function cmdFind(query, opts) {
|
|
|
21174
21280
|
*/
|
|
21175
21281
|
async function getProjects(includeArchived) {
|
|
21176
21282
|
try {
|
|
21177
|
-
const { getRegistryBackend } = await import("./factory-
|
|
21283
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
21178
21284
|
const rows = await (await getRegistryBackend()).listProjectsWithSessionStats();
|
|
21179
21285
|
return includeArchived ? rows : rows.filter((p) => p.status === "active");
|
|
21180
21286
|
} catch {
|
|
@@ -21648,7 +21754,7 @@ async function cmdPick(opts = {}) {
|
|
|
21648
21754
|
const onRemove = async (rec) => {
|
|
21649
21755
|
if (!rec.slug) return false;
|
|
21650
21756
|
try {
|
|
21651
|
-
const { getRegistryBackend } = await import("./factory-
|
|
21757
|
+
const { getRegistryBackend } = await import("./factory-DjtXElOI.mjs");
|
|
21652
21758
|
const registryBackend = await getRegistryBackend();
|
|
21653
21759
|
const project = await registryBackend.getProjectBySlug(rec.slug);
|
|
21654
21760
|
if (!project || project.status !== "active") return false;
|
|
@@ -21933,4 +22039,4 @@ claude() {
|
|
|
21933
22039
|
|
|
21934
22040
|
//#endregion
|
|
21935
22041
|
export { drainStdio as n, buildProgram as t };
|
|
21936
|
-
//# sourceMappingURL=program-
|
|
22042
|
+
//# sourceMappingURL=program-cWqZI0_L.mjs.map
|