@tekmidian/pai 1.0.5 → 1.0.7
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/dist/{aibroker-client-CQPGqLxL.mjs → aibroker-client-CXsyC7A8.mjs} +2 -2
- package/dist/aibroker-client-ChB7gSxV.mjs +3 -0
- package/dist/auto-route-CAlZ5p-h.mjs +11 -0
- package/dist/{auto-route-DUYr57rs.mjs → auto-route-PDOAYszN.mjs} +2 -2
- package/dist/budget-BXmsSBLI.mjs +15 -0
- package/dist/{caller-identity-Bim8JT-D.mjs → caller-identity-DPDSrZE2.mjs} +4 -4
- package/dist/{capacity-CsZMkVyg.mjs → capacity-CThSydrd.mjs} +82 -10
- package/dist/{chain-Dzz6xcKH.mjs → chain-BvdKqRiZ.mjs} +5 -5
- package/dist/cli/index.mjs +2175 -284
- package/dist/{cockpit-actions-BTA1njMO.mjs → cockpit-actions-BgdKB9G3.mjs} +26 -26
- package/dist/{cockpit-actions-BgsiNcUY.mjs → cockpit-actions-DNl0rKfW.mjs} +18 -18
- package/dist/cockpit-memory-CqLPjcWe.mjs +20 -0
- package/dist/config/defaults/config.yaml +24 -1
- package/dist/config/defaults/workers.yaml +2 -0
- package/dist/{config-h5qK3fst.mjs → config-C2dd2SXS.mjs} +2 -2
- package/dist/{config-CST2uq1v.mjs → config-DGV64YJa.mjs} +11 -3
- package/dist/{config-Dv3t7xnT.mjs → config-DHgPx3ER.mjs} +1 -1
- package/dist/{config-DYbyEe4-.mjs → config-SlZ-Z52i.mjs} +3 -2
- package/dist/{controls-OiVVbe-f.mjs → controls-ByrcupcA.mjs} +59 -66
- package/dist/daemon/index.mjs +40 -40
- package/dist/{daemon-C1dycZ3W.mjs → daemon-BjgJyJMP.mjs} +79 -31
- package/dist/daemon-iymy18Ie.mjs +46 -0
- package/dist/daemon-mcp/index.mjs +49 -38
- package/dist/detect-C8nFP-kR.mjs +10 -0
- package/dist/{detect-CHuxFrLy.mjs → detect-DLjeYwnt.mjs} +2 -2
- package/dist/{embed-pass-DtVF2fOV.mjs → embed-pass-DdTMn4DH.mjs} +5 -5
- package/dist/{embedding-gate-B98PK_wz.mjs → embedding-gate-BVQvUmox.mjs} +2 -2
- package/dist/{embedding-gate-CTAk8STe.mjs → embedding-gate-iq0oQEkF.mjs} +3 -3
- package/dist/{endreason-BqyyU7BH.mjs → endreason-BjPom527.mjs} +4 -4
- package/dist/{factory-BV0MQA3T.mjs → factory-CYwa0jYj.mjs} +6 -6
- package/dist/factory-DFwez99M.mjs +9 -0
- package/dist/{fallback-Bj2cyVk_.mjs → fallback-CQ8_CuVu.mjs} +9 -231
- package/dist/{health-kufVIf6i.mjs → health-Bb2U4PNK.mjs} +5 -5
- package/dist/{helpers-CvbYEKoD.mjs → helpers-Dj2nY56t.mjs} +2 -2
- package/dist/{helpers-WV8tdQHM.mjs → helpers-DyHKAwrW.mjs} +6 -6
- package/dist/hooks/block-sleep-poll.mjs +9 -0
- package/dist/hooks/capture-all-events.mjs +99 -3
- package/dist/hooks/capture-tool-output.mjs +99 -3
- package/dist/hooks/handoff-link.mjs +159 -0
- package/dist/hooks/load-project-context.mjs +10 -1
- package/dist/hooks/local-model-hint.mjs +9 -0
- package/dist/hooks/route-agents-to-worker.mjs +9 -0
- package/dist/hooks/security-validator.mjs +940 -92
- package/dist/hooks/supervision-banner.mjs +219 -48
- package/dist/hooks/worker-edit-repair.mjs +9 -0
- package/dist/hooks/worker-guard.mjs +97 -1
- package/dist/hooks/worker-note.mjs +108 -3
- package/dist/hooks/worker-pool-host.mjs +1670 -315
- package/dist/hooks/worker-proxy.mjs +9 -0
- package/dist/hooks/worker-status-line.mjs +251 -70
- package/dist/hooks/worker-supervision.mjs +9 -0
- package/dist/hooks/worker-tool-name-repair.mjs +9 -0
- package/dist/index.mjs +9 -9
- package/dist/{ipc-client-CnYEF31R.mjs → ipc-client-CmagIFLh.mjs} +2 -2
- package/dist/{ipc-client-DN7EvoVo.mjs → ipc-client-DmbSIBUK.mjs} +1 -1
- package/dist/kill-tree-BlPw1vaU.mjs +10 -0
- package/dist/{kill-tree-CcpsRLCZ.mjs → kill-tree-DTmiEb3T.mjs} +8 -8
- package/dist/{launch-DpQPZGsT.mjs → launch-CV6oPHI2.mjs} +3 -3
- package/dist/{launch-UPQBoW2q.mjs → launch-Dy8qQnSD.mjs} +3 -3
- package/dist/{indexer-backend-B2vtFl38.mjs → lessons-CdmqZD0G.mjs} +262 -43
- package/dist/{local-candidate-Cp_bw4kK.mjs → local-candidate-C2FGhf54.mjs} +3 -3
- package/dist/{local-instances-bdCNNSsL.mjs → local-instances-DhF4_sV2.mjs} +2 -2
- package/dist/{local-instances-B-c-CxzP.mjs → local-instances-GgXydQ2P.mjs} +4 -4
- package/dist/{local-tiers-BtdEEe5n.mjs → local-tiers-CqwGUcEn.mjs} +3 -3
- package/dist/{local-tiers-OBqAAfOg.mjs → local-tiers-X_dQfI4Q.mjs} +3 -3
- package/dist/{main-config-ops-BYsK3BxM.mjs → main-config-ops-C_fkINDv.mjs} +3 -3
- package/dist/{main-resolver-CAC3xfZM.mjs → main-resolver-CN_sfG1R.mjs} +18 -18
- package/dist/{migrate-DrA_OwlZ.mjs → migrate-C2z1YmWC.mjs} +2 -2
- package/dist/{model-inventory-BuTpi9a6.mjs → model-inventory-BYNrSTaY.mjs} +13 -13
- package/dist/{models-add-CJx2YAwh.mjs → models-add-Dc7VXmcu.mjs} +38 -38
- package/dist/operator-IrLbk8hy.mjs +7 -0
- package/dist/{operator-DrwWItVt.mjs → operator-lRGvYr3D.mjs} +2 -2
- package/dist/{pai-marker-DLKJ9Yr5.mjs → pai-marker-kA0iM7rP.mjs} +2 -2
- package/dist/{pane-audit-wv9UkyCe.mjs → pane-audit-DUuilP1V.mjs} +13 -23
- package/dist/{paths-DS5VQKoR.mjs → paths-BwfwHOvN.mjs} +4 -4
- package/dist/{paths-DBd78I7Z.mjs → paths-CKGYM0Lb.mjs} +3 -3
- package/dist/{planner-K0mFrCpL.mjs → planner-BDHVUkIM.mjs} +29 -29
- package/dist/{pool-BZ94nFuq.mjs → pool-CFeHGX7q.mjs} +2 -2
- package/dist/{pool-cli-BjYQDfx6.mjs → pool-cli-Bj2TeA-d.mjs} +6 -6
- package/dist/{pool-cli-B1eKySeN.mjs → pool-cli-DOLgPgOM.mjs} +5 -5
- package/dist/{postgres-CBHY5PIi.mjs → postgres-B1B80bcj.mjs} +3 -3
- package/dist/{postgres-C-T5OWer.mjs → postgres-BL5oBBgY.mjs} +3 -3
- package/dist/{project-setup-pIPHZaXf.mjs → project-setup-i5D0xkTn.mjs} +24 -25
- package/dist/{providers-Dzx5GAUI.mjs → providers-BC2Myo_O.mjs} +6 -6
- package/dist/providers-C-mnlH1b.mjs +16 -0
- package/dist/{query-feedback-DN52N9C5.mjs → query-feedback-BWl2HRwN.mjs} +2 -2
- package/dist/registrable-Ct0DKNKS.mjs +9 -0
- package/dist/{registrable-CXBBpUcz.mjs → registrable-D_4qXCnq.mjs} +4 -4
- package/dist/render-CbifCwTb.mjs +2350 -0
- package/dist/render-FB4Fv_fi.mjs +13 -0
- package/dist/root-80ESg6b7.mjs +36 -0
- package/dist/{root-bG48WVpW.mjs → root-B-ZYiEgi.mjs} +10 -10
- package/dist/route-table-DcBZCuco.mjs +15 -0
- package/dist/{router-CQSc3lk3.mjs → router-D2476pOp.mjs} +2 -2
- package/dist/{router-DwHJRgG9.mjs → router-ghujlEFb.mjs} +1 -1
- package/dist/{routing-BlD_tKjW.mjs → routing-CF0wlR-_.mjs} +15 -15
- package/dist/{routing-D27jxj9x.mjs → routing-CJ8ioPl2.mjs} +13 -13
- package/dist/{run-AZVwceiU.mjs → run-CAjfKBQV.mjs} +74 -31
- package/dist/{runtime-paths-WsO9sJFc.mjs → runtime-paths-twfV23YL.mjs} +2 -2
- package/dist/{scan-C3uotg_f.mjs → scan-ew8M6tTH.mjs} +7 -7
- package/dist/{scope-D8HK6vU7.mjs → scope-BRcaPw5D.mjs} +4 -4
- package/dist/session-BmQsXF_a.mjs +35 -0
- package/dist/{session-BAfypQb9.mjs → session-C1JnDXvP.mjs} +28 -28
- package/dist/session-scan-DWCUKhDM.mjs +9 -0
- package/dist/{session-scan-BmnjSReu.mjs → session-scan-DihMibI-.mjs} +6 -6
- package/dist/{session-usage-oycSdiD3.mjs → session-usage-BRIWFYPS.mjs} +3 -3
- package/dist/status-Bj4yVKj0.mjs +6 -0
- package/dist/{status-COtzewKV.mjs → status-DTMT5lyn.mjs} +9 -5
- package/dist/{tool-errors-DXJ70-sr.mjs → tool-errors-BOW2n882.mjs} +2 -2
- package/dist/{tool-errors-B2LnIqR0.mjs → tool-errors-jNJj3Gzm.mjs} +6 -6
- package/dist/{viewer-BgGRqXfD.mjs → viewer-4BU8w_gK.mjs} +16 -14
- package/dist/viewer-D3VEdqhC.mjs +22 -0
- package/dist/{wait-ChpHKJZV.mjs → wait-BindDA5w.mjs} +3 -3
- package/dist/{worker-config-DgdT0iTB.mjs → worker-config-CdPmb4_2.mjs} +54 -103
- package/dist/worker-config-CfV2dgSb.mjs +42 -0
- package/dist/{workers-config-BhZBrR-Q.mjs → workers-config-2VipVOYk.mjs} +2 -2
- package/dist/{worktree-BY--Rgmy.mjs → worktree-7ZS3RBf8.mjs} +175 -9
- package/dist/{zettelkasten-BHVx5zj-.mjs → zettelkasten-BH8AdNh8.mjs} +4 -4
- package/dist/{zettelkasten-LoH9RBiN.mjs → zettelkasten-FFhQFESJ.mjs} +2 -2
- package/docs/commands/README.md +32 -2
- package/docs/commands/audit.md +34 -3
- package/docs/commands/backup.md +1 -1
- package/docs/commands/build.md +4 -4
- package/docs/commands/cd.md +1 -1
- package/docs/commands/clear-names.md +1 -1
- package/docs/commands/cockpit.md +1 -1
- package/docs/commands/config.md +1 -1
- package/docs/commands/daemon.md +1 -1
- package/docs/commands/db.md +1 -1
- package/docs/commands/doc.md +1 -1
- package/docs/commands/end.md +1 -1
- package/docs/commands/find.md +1 -1
- package/docs/commands/git.md +110 -0
- package/docs/commands/handoff.md +70 -0
- package/docs/commands/harness.md +74 -0
- package/docs/commands/help.md +1 -1
- package/docs/commands/home.md +1 -1
- package/docs/commands/hooks-db.md +1 -1
- package/docs/commands/identity.md +1 -1
- package/docs/commands/install.md +1 -1
- package/docs/commands/issue.md +1 -1
- package/docs/commands/kg.md +1 -1
- package/docs/commands/launch.md +1 -1
- package/docs/commands/lessons.md +201 -0
- package/docs/commands/list.md +1 -1
- package/docs/commands/ls.md +1 -1
- package/docs/commands/mcp.md +1 -1
- package/docs/commands/memory.md +1 -1
- package/docs/commands/models.md +1 -1
- package/docs/commands/more.md +1 -1
- package/docs/commands/new.md +1 -1
- package/docs/commands/notes.md +1 -1
- package/docs/commands/notify.md +1 -1
- package/docs/commands/observation.md +1 -1
- package/docs/commands/obsidian.md +1 -1
- package/docs/commands/open.md +1 -1
- package/docs/commands/pane.md +1 -1
- package/docs/commands/pause.md +1 -1
- package/docs/commands/plan.md +1 -1
- package/docs/commands/project.md +1 -1
- package/docs/commands/projects.md +1 -1
- package/docs/commands/providers.md +1 -1
- package/docs/commands/queue.md +1 -1
- package/docs/commands/registry.md +1 -1
- package/docs/commands/reload.md +1 -1
- package/docs/commands/rename.md +1 -1
- package/docs/commands/restore.md +1 -1
- package/docs/commands/resume.md +1 -1
- package/docs/commands/router.md +1 -1
- package/docs/commands/rules.md +70 -0
- package/docs/commands/session.md +1 -1
- package/docs/commands/sessions.md +1 -1
- package/docs/commands/setup.md +1 -1
- package/docs/commands/setups.md +1 -1
- package/docs/commands/shell-init.md +1 -1
- package/docs/commands/skill.md +1 -1
- package/docs/commands/task.md +1 -1
- package/docs/commands/tasks.md +1 -1
- package/docs/commands/topic.md +1 -1
- package/docs/commands/update.md +1 -1
- package/docs/commands/worker.md +1 -1
- package/docs/commands/zettel.md +1 -1
- package/docs/concepts/panes.md +3 -2
- package/gemini-extension.json +1 -1
- package/package.json +2 -2
- package/pai-plugin.json +1 -1
- package/plugins/context-preservation/plugin.json +1 -1
- package/plugins/core/plugin.json +1 -1
- 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/ts/lib/loop-guard.ts +3 -5
- package/src/hooks/ts/lib/rules/builtin/base64-decode-to-shell.rule.yaml +15 -0
- package/src/hooks/ts/lib/rules/builtin/chmod-world-writable.rule.yaml +13 -0
- package/src/hooks/ts/lib/rules/builtin/chmod-zero.rule.yaml +13 -0
- package/src/hooks/ts/lib/rules/builtin/credential-file-read.rule.yaml +13 -0
- package/src/hooks/ts/lib/rules/builtin/credential-read-then-network.rule.yaml +29 -0
- package/src/hooks/ts/lib/rules/builtin/crontab-persistence.rule.yaml +10 -0
- package/src/hooks/ts/lib/rules/builtin/curl-piped-to-shell.rule.yaml +22 -0
- package/src/hooks/ts/lib/rules/builtin/download-then-execute.rule.yaml +30 -0
- package/src/hooks/ts/lib/rules/builtin/find-root-delete.rule.yaml +14 -0
- package/src/hooks/ts/lib/rules/builtin/git-push-force.rule.yaml +24 -0
- package/src/hooks/ts/lib/rules/builtin/git-push-plus-refspec.rule.yaml +12 -0
- package/src/hooks/ts/lib/rules/builtin/git-reset-hard.rule.yaml +12 -0
- package/src/hooks/ts/lib/rules/builtin/injection-then-tool.rule.yaml +30 -0
- package/src/hooks/ts/lib/rules/builtin/instruction-override-disregard.rule.yaml +14 -0
- package/src/hooks/ts/lib/rules/builtin/instruction-override-ignore.rule.yaml +13 -0
- package/src/hooks/ts/lib/rules/builtin/launchagents-write-persistence.rule.yaml +12 -0
- package/src/hooks/ts/lib/rules/builtin/launchctl-load-persistence.rule.yaml +10 -0
- package/src/hooks/ts/lib/rules/builtin/reverse-shell-dev-tcp.rule.yaml +14 -0
- package/src/hooks/ts/lib/rules/builtin/reverse-shell-interactive-bash.rule.yaml +12 -0
- package/src/hooks/ts/lib/rules/builtin/rm-recursive-parent.rule.yaml +13 -0
- package/src/hooks/ts/lib/rules/builtin/rm-recursive-relative.rule.yaml +12 -0
- package/src/hooks/ts/lib/rules/builtin/rm-recursive-root.rule.yaml +27 -0
- package/src/hooks/ts/lib/rules/builtin/rm-trailing-tilde.rule.yaml +12 -0
- package/src/hooks/ts/lib/rules/builtin/sudoers-nopasswd.rule.yaml +15 -0
- package/src/hooks/ts/lib/rules/builtin.generated.ts +557 -0
- package/src/hooks/ts/lib/rules/eval.ts +76 -0
- package/src/hooks/ts/lib/rules/lint.ts +108 -0
- package/src/hooks/ts/lib/rules/load.ts +264 -0
- package/src/hooks/ts/lib/rules/types.ts +58 -0
- package/src/hooks/ts/pre-tool-use/security-validator.ts +35 -96
- package/src/hooks/ts/user-prompt/handoff-link.ts +34 -0
- package/dist/aibroker-client-BxzeEHPF.mjs +0 -3
- package/dist/auto-route-DWYK_0i0.mjs +0 -11
- package/dist/budget-DX-VIWGf.mjs +0 -15
- package/dist/cockpit-memory-DIrNs4xr.mjs +0 -20
- package/dist/daemon-ieo0lnpq.mjs +0 -46
- package/dist/detect-C0ZBXqDL.mjs +0 -10
- package/dist/factory-DeASMV7Z.mjs +0 -9
- package/dist/kill-tree-CXZ0WfVf.mjs +0 -10
- package/dist/operator-Bpxq_WB5.mjs +0 -7
- package/dist/providers-QJzpaNhX.mjs +0 -16
- package/dist/registrable-Drn8wIDO.mjs +0 -9
- package/dist/render-C4KR8qQ8.mjs +0 -13
- package/dist/render-Cz3BWIBO.mjs +0 -903
- package/dist/root-Bfb1zgwE.mjs +0 -36
- package/dist/route-table-ZVMNBsy7.mjs +0 -15
- package/dist/session-BcnhepLZ.mjs +0 -35
- package/dist/session-scan-CqUQdCac.mjs +0 -9
- package/dist/status-D_SWmOlH.mjs +0 -6
- package/dist/viewer-CbGN2Ri4.mjs +0 -22
- package/dist/worker-config-D1KVAMp4.mjs +0 -42
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __paiCreateRequire } from 'node:module';
|
|
3
|
+
const require = __paiCreateRequire(import.meta.url);
|
|
4
|
+
if (!process.env.PAI_QUIET_NOTICES) process.env.PAI_QUIET_NOTICES = '1';
|
|
5
|
+
|
|
6
|
+
// src/session/handoff.ts
|
|
7
|
+
import { appendFileSync, mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2, writeFileSync } from "node:fs";
|
|
8
|
+
import { basename, dirname as dirname2, join as join2 } from "node:path";
|
|
9
|
+
|
|
10
|
+
// src/workers/ps-table.ts
|
|
11
|
+
var PS_MAX_BUFFER = 64 * 1024 * 1024;
|
|
12
|
+
|
|
13
|
+
// src/utils/redact.ts
|
|
14
|
+
var REDACTED = "[REDACTED]";
|
|
15
|
+
var REDACTED_RE = String.raw`\[REDACTED\]`;
|
|
16
|
+
var KEY_WORDS = "password|passwd|secret|token|api[_-]?key|credential|auth(?:orization)?|bearer";
|
|
17
|
+
var PROSE = "is|are|was|were|be|to|of|in|on|for|and|or|the|a|an|that|this|it|not|out|here|there|so|as|at|by|with|if|when|which";
|
|
18
|
+
var VAL = String.raw`(?:"[^"]*"|'[^']*'|[^\s'"]+)`;
|
|
19
|
+
var REDACT_RULES = [
|
|
20
|
+
{
|
|
21
|
+
// `Authorization: Bearer xxx` / `Authorization: Basic xxx` — keep the scheme
|
|
22
|
+
id: "authorization",
|
|
23
|
+
re: /(Authorization\s*:\s*)(Bearer|Basic)\s+([^\s'"]+)/gi,
|
|
24
|
+
replace: (_m, head, scheme) => `${head}${scheme} ${REDACTED}`
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
// `Cookie: a=b; c=d` — keep the cookie names, redact every value
|
|
28
|
+
id: "cookie",
|
|
29
|
+
re: /((?:Set-)?Cookie\s*:\s*)([^\n]+)/gi,
|
|
30
|
+
replace: (_m, head, rest) => `${head}${rest.replace(/([^=;\s'"]+=)[^;'"]*/g, `$1${REDACTED}`)}`
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
// `key=value`, `key: value`, `"key": "value"` — key carries a secret-ish word;
|
|
34
|
+
// the word must be a whole key segment, so `monkeys=` stays untouched.
|
|
35
|
+
// The separator may start with the key's closing quote (JSON); it is kept.
|
|
36
|
+
id: "key-value",
|
|
37
|
+
re: new RegExp(String.raw`(?<![A-Za-z0-9])((?:[A-Za-z0-9]+[_-])?(?:${KEY_WORDS})(?![A-Za-z0-9])[A-Za-z0-9_-]*)(["']?\s*[:=]\s*)(?!(?:Bearer|Basic) ${REDACTED_RE})(?!(?:${PROSE})\b)(${VAL})`, "gi"),
|
|
38
|
+
replace: (m, key, sep, val) => {
|
|
39
|
+
if (/[_-](?:count|length|len|size|limit|max|min|budget)$/i.test(key) && /^\d+$/.test(val)) return m;
|
|
40
|
+
const q = sep[0] === '"' || sep[0] === "'" ? val[0] : "";
|
|
41
|
+
return q && (q === '"' || q === "'") ? `${key}${sep}${q}${REDACTED}${q}` : `${key}${sep}${REDACTED}`;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
// npmrc `//registry/:_authToken=xxx`
|
|
46
|
+
id: "npm-auth-token",
|
|
47
|
+
re: new RegExp(String.raw`(_authToken\s*=\s*)(${VAL})`, "g"),
|
|
48
|
+
replace: (_m, head) => `${head}${REDACTED}`
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
// `curl -u user:pass` / `--user user:pass` — keep the user
|
|
52
|
+
id: "curl-user",
|
|
53
|
+
re: /(\bcurl\b[^\n]{0,500}?\s(?:-u|--user)[\s=]+['"]?[^\s:'"]+:)([^\s'"]+)/g,
|
|
54
|
+
replace: (_m, head) => `${head}${REDACTED}`
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
// `mysql -phunter2` / `mysqldump -p'hunter2'` — attached password only
|
|
58
|
+
id: "mysql-p",
|
|
59
|
+
re: /(\bmysql(?:dump)?\b[^\n]{0,300}?\s-p)('[^']*'|"[^"]*"|[^\s'"-][^\s'"]*)/g,
|
|
60
|
+
replace: (_m, head) => `${head}${REDACTED}`
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
// `export FOO_TOKEN=...` / `FOO_KEY=...` — SCREAMING_SNAKE env style
|
|
64
|
+
id: "env-style",
|
|
65
|
+
re: new RegExp(String.raw`(?<![A-Za-z0-9])((?:export\s+)?[A-Z][A-Z0-9]*_(?:KEY|SECRET|TOKEN|PASS\w*|CRED\w*|AUTH\w*)\s*=\s*)(${VAL})`, "g"),
|
|
66
|
+
replace: (_m, head) => `${head}${REDACTED}`
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
// long CLI flags only: `--password X`, `--token X`, `--api-key X`, `--secret X`, `--passwd X`
|
|
70
|
+
id: "cli-flag",
|
|
71
|
+
re: new RegExp(String.raw`(--(?:password|token|api-key|secret|passwd)(?:\s*=\s*|\s+))(${VAL})`, "gi"),
|
|
72
|
+
replace: (_m, head) => `${head}${REDACTED}`
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
// `scheme://user:pass@host` — redact the password, keep user and host
|
|
76
|
+
id: "url-credentials",
|
|
77
|
+
re: /((?<![a-z0-9+.-])[a-z][a-z0-9+.-]*:\/\/[^\s/@:]+:)([^\s/@]+)(@)/gi,
|
|
78
|
+
replace: (_m, head, _pass, at) => `${head}${REDACTED}${at}`
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
// provider token prefixes: sk-ant-, sk-, ghp_/gho_/ghu_/ghs_/ghr_, github_pat_,
|
|
82
|
+
// glpat-, xoxb-/xoxp-/xoxa-, AKIA/ASIA + 16 chars, AIza + 35 chars, JWT (eyJ… three segments)
|
|
83
|
+
id: "token-prefix",
|
|
84
|
+
re: /\b(?:sk-ant-[A-Za-z0-9_-]{20,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{22,}|glpat-[A-Za-z0-9_-]{20,}|xox[bap]-[A-Za-z0-9-]{10,}|(?:AKIA|ASIA|AGPA|AIDA|AROA)[A-Z0-9]{16}|[sr]k_(?:live|test)_[A-Za-z0-9]{20,}|npm_[A-Za-z0-9]{36}|hf_[A-Za-z0-9]{30,}|AIza[A-Za-z0-9_-]{35}(?![A-Za-z0-9_-])|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)(?![A-Za-z0-9_-])/g,
|
|
85
|
+
replace: REDACTED
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
// 40+ char opaque base64/hex run, only on a line that also has a secret-ish key word
|
|
89
|
+
id: "long-run",
|
|
90
|
+
re: /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{40,4096}={0,2}(?![\w/])/g,
|
|
91
|
+
// a bare 40-hex git SHA stays; it is only redacted as the value of a secret key
|
|
92
|
+
replace: (m) => /^[0-9a-f]{40}$/i.test(m) ? m : REDACTED
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
var LINE_RULES = REDACT_RULES.filter((r) => r.id !== "long-run");
|
|
96
|
+
var LONG_RUN = REDACT_RULES.find((r) => r.id === "long-run");
|
|
97
|
+
var LONG_RUN_MAX_LINE = 64 * 1024;
|
|
98
|
+
var KEY_LINE = new RegExp(`(?:${KEY_WORDS})`, "i");
|
|
99
|
+
|
|
100
|
+
// src/hooks/ts/lib/loop-guard.ts
|
|
101
|
+
var LOOP_MAX_REPEATS = 4;
|
|
102
|
+
var LOOP_READ_STREAK = Number(process.env.PAI_LOOP_READ_STREAK) > 0 ? Number(process.env.PAI_LOOP_READ_STREAK) : 15;
|
|
103
|
+
var SELF = "If your part is done, commit and write your R report. If you are stuck, report the blocker in R x= (or use pai worker help if available).";
|
|
104
|
+
var LOOP_DENY_REASON = `loop guard: you ran this command ${LOOP_MAX_REPEATS} times with the same result and nothing changed. Stop repeating it. ${SELF}`;
|
|
105
|
+
var WAIT_CAP_MS = 45 * 6e4;
|
|
106
|
+
var FP_FULL_READ_BYTES = 256 * 1024;
|
|
107
|
+
var FP_TOTAL_BYTES = 4 * 1024 * 1024;
|
|
108
|
+
|
|
109
|
+
// src/config/pai-home.ts
|
|
110
|
+
import { existsSync, mkdirSync, readFileSync, copyFileSync, renameSync, readdirSync, statSync } from "node:fs";
|
|
111
|
+
import { homedir } from "node:os";
|
|
112
|
+
import { join, dirname } from "node:path";
|
|
113
|
+
function legacyPaiHomeDir() {
|
|
114
|
+
return join(homedir(), ".claude", "pai");
|
|
115
|
+
}
|
|
116
|
+
function defaultPaiHomeDir() {
|
|
117
|
+
return join(homedir(), ".pai");
|
|
118
|
+
}
|
|
119
|
+
function paiHomeDir() {
|
|
120
|
+
if (process.env.PAI_HOME) return process.env.PAI_HOME;
|
|
121
|
+
const fresh = defaultPaiHomeDir();
|
|
122
|
+
const legacy = legacyPaiHomeDir();
|
|
123
|
+
if (!existsSync(join(fresh, "config.yaml")) && existsSync(join(legacy, "config.yaml"))) return legacy;
|
|
124
|
+
return fresh;
|
|
125
|
+
}
|
|
126
|
+
function paiHomePath(...segments) {
|
|
127
|
+
return join(paiHomeDir(), ...segments);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/session/handoff.ts
|
|
131
|
+
function handoffsDir() {
|
|
132
|
+
return paiHomePath("handoffs");
|
|
133
|
+
}
|
|
134
|
+
function appendHandoffLink(from, to, now = /* @__PURE__ */ new Date()) {
|
|
135
|
+
try {
|
|
136
|
+
const dir = handoffsDir();
|
|
137
|
+
mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
138
|
+
appendFileSync(join2(dir, "links.jsonl"), `${JSON.stringify({ ts: now.toISOString(), from, to })}
|
|
139
|
+
`);
|
|
140
|
+
} catch {
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/hooks/ts/user-prompt/handoff-link.ts
|
|
145
|
+
var MARKER = /\[pai-handoff from=([^\]\s]+)\]/;
|
|
146
|
+
async function main() {
|
|
147
|
+
try {
|
|
148
|
+
const chunks = [];
|
|
149
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
150
|
+
const input = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
151
|
+
const prompt = typeof input.prompt === "string" ? input.prompt : "";
|
|
152
|
+
const m = MARKER.exec(prompt);
|
|
153
|
+
if (!m || !input.session_id) return;
|
|
154
|
+
appendHandoffLink(m[1], input.session_id);
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
void main();
|
|
159
|
+
//# sourceMappingURL=handoff-link.mjs.map
|
|
@@ -8177,6 +8177,7 @@ function defaultWorkersConfig() {
|
|
|
8177
8177
|
cacheKeepaliveSecs: num(w.cacheKeepaliveSecs, 0),
|
|
8178
8178
|
defaultMaxMinutes: num(w.defaultMaxMinutes, 60),
|
|
8179
8179
|
waitAlarmMinutes: num(w.waitAlarmMinutes, 120),
|
|
8180
|
+
scanBudgetMs: num(w.scanBudgetMs, 5e3),
|
|
8180
8181
|
stagger: {
|
|
8181
8182
|
enabled: bool(stagger.enabled, true),
|
|
8182
8183
|
localDefaultSec: num(stagger.localDefaultSec, 20),
|
|
@@ -8771,6 +8772,13 @@ function parseWorkersConfig(raw, yamlProviders = {}) {
|
|
|
8771
8772
|
}
|
|
8772
8773
|
waitAlarmMinutes = w.waitAlarmMinutes;
|
|
8773
8774
|
}
|
|
8775
|
+
let scanBudgetMs = d.scanBudgetMs ?? 5e3;
|
|
8776
|
+
if (w.scanBudgetMs !== void 0) {
|
|
8777
|
+
if (typeof w.scanBudgetMs !== "number" || !Number.isInteger(w.scanBudgetMs) || w.scanBudgetMs < 1) {
|
|
8778
|
+
bad(".scanBudgetMs", "must be a positive integer (milliseconds)");
|
|
8779
|
+
}
|
|
8780
|
+
scanBudgetMs = w.scanBudgetMs;
|
|
8781
|
+
}
|
|
8774
8782
|
const stagger = { ...d.stagger };
|
|
8775
8783
|
if (w.stagger !== void 0) {
|
|
8776
8784
|
if (typeof w.stagger !== "object" || w.stagger === null || Array.isArray(w.stagger)) {
|
|
@@ -8907,6 +8915,7 @@ function parseWorkersConfig(raw, yamlProviders = {}) {
|
|
|
8907
8915
|
cacheKeepaliveSecs,
|
|
8908
8916
|
defaultMaxMinutes,
|
|
8909
8917
|
waitAlarmMinutes,
|
|
8918
|
+
scanBudgetMs,
|
|
8910
8919
|
stagger,
|
|
8911
8920
|
capacity,
|
|
8912
8921
|
localIdle,
|
|
@@ -9034,7 +9043,7 @@ function ownsPid(status) {
|
|
|
9034
9043
|
env: { ...process.env, LC_ALL: "C" }
|
|
9035
9044
|
}).trim();
|
|
9036
9045
|
const psStart = Date.parse(out);
|
|
9037
|
-
const started = spawnTimeOf(status) ?? Date.parse(status.started.replace(" ", "T"));
|
|
9046
|
+
const started = status.procStart ?? spawnTimeOf(status) ?? Date.parse(status.started.replace(" ", "T"));
|
|
9038
9047
|
if (Number.isNaN(psStart) || Number.isNaN(started)) return alive(status.pid);
|
|
9039
9048
|
return Math.abs(psStart - started) <= 12e4;
|
|
9040
9049
|
} catch {
|
|
@@ -8191,6 +8191,7 @@ function defaultWorkersConfig() {
|
|
|
8191
8191
|
cacheKeepaliveSecs: num(w.cacheKeepaliveSecs, 0),
|
|
8192
8192
|
defaultMaxMinutes: num(w.defaultMaxMinutes, 60),
|
|
8193
8193
|
waitAlarmMinutes: num(w.waitAlarmMinutes, 120),
|
|
8194
|
+
scanBudgetMs: num(w.scanBudgetMs, 5e3),
|
|
8194
8195
|
stagger: {
|
|
8195
8196
|
enabled: bool(stagger.enabled, true),
|
|
8196
8197
|
localDefaultSec: num(stagger.localDefaultSec, 20),
|
|
@@ -8785,6 +8786,13 @@ function parseWorkersConfig(raw, yamlProviders = {}) {
|
|
|
8785
8786
|
}
|
|
8786
8787
|
waitAlarmMinutes = w.waitAlarmMinutes;
|
|
8787
8788
|
}
|
|
8789
|
+
let scanBudgetMs = d.scanBudgetMs ?? 5e3;
|
|
8790
|
+
if (w.scanBudgetMs !== void 0) {
|
|
8791
|
+
if (typeof w.scanBudgetMs !== "number" || !Number.isInteger(w.scanBudgetMs) || w.scanBudgetMs < 1) {
|
|
8792
|
+
bad(".scanBudgetMs", "must be a positive integer (milliseconds)");
|
|
8793
|
+
}
|
|
8794
|
+
scanBudgetMs = w.scanBudgetMs;
|
|
8795
|
+
}
|
|
8788
8796
|
const stagger = { ...d.stagger };
|
|
8789
8797
|
if (w.stagger !== void 0) {
|
|
8790
8798
|
if (typeof w.stagger !== "object" || w.stagger === null || Array.isArray(w.stagger)) {
|
|
@@ -8921,6 +8929,7 @@ function parseWorkersConfig(raw, yamlProviders = {}) {
|
|
|
8921
8929
|
cacheKeepaliveSecs,
|
|
8922
8930
|
defaultMaxMinutes,
|
|
8923
8931
|
waitAlarmMinutes,
|
|
8932
|
+
scanBudgetMs,
|
|
8924
8933
|
stagger,
|
|
8925
8934
|
capacity,
|
|
8926
8935
|
localIdle,
|
|
@@ -8194,6 +8194,7 @@ function defaultWorkersConfig() {
|
|
|
8194
8194
|
cacheKeepaliveSecs: num(w.cacheKeepaliveSecs, 0),
|
|
8195
8195
|
defaultMaxMinutes: num(w.defaultMaxMinutes, 60),
|
|
8196
8196
|
waitAlarmMinutes: num(w.waitAlarmMinutes, 120),
|
|
8197
|
+
scanBudgetMs: num(w.scanBudgetMs, 5e3),
|
|
8197
8198
|
stagger: {
|
|
8198
8199
|
enabled: bool(stagger.enabled, true),
|
|
8199
8200
|
localDefaultSec: num(stagger.localDefaultSec, 20),
|
|
@@ -8788,6 +8789,13 @@ function parseWorkersConfig(raw, yamlProviders = {}) {
|
|
|
8788
8789
|
}
|
|
8789
8790
|
waitAlarmMinutes = w.waitAlarmMinutes;
|
|
8790
8791
|
}
|
|
8792
|
+
let scanBudgetMs = d.scanBudgetMs ?? 5e3;
|
|
8793
|
+
if (w.scanBudgetMs !== void 0) {
|
|
8794
|
+
if (typeof w.scanBudgetMs !== "number" || !Number.isInteger(w.scanBudgetMs) || w.scanBudgetMs < 1) {
|
|
8795
|
+
bad(".scanBudgetMs", "must be a positive integer (milliseconds)");
|
|
8796
|
+
}
|
|
8797
|
+
scanBudgetMs = w.scanBudgetMs;
|
|
8798
|
+
}
|
|
8791
8799
|
const stagger = { ...d.stagger };
|
|
8792
8800
|
if (w.stagger !== void 0) {
|
|
8793
8801
|
if (typeof w.stagger !== "object" || w.stagger === null || Array.isArray(w.stagger)) {
|
|
@@ -8924,6 +8932,7 @@ function parseWorkersConfig(raw, yamlProviders = {}) {
|
|
|
8924
8932
|
cacheKeepaliveSecs,
|
|
8925
8933
|
defaultMaxMinutes,
|
|
8926
8934
|
waitAlarmMinutes,
|
|
8935
|
+
scanBudgetMs,
|
|
8927
8936
|
stagger,
|
|
8928
8937
|
capacity,
|
|
8929
8938
|
localIdle,
|