pybao-cli 1.5.8 → 1.5.9
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/REPL-FDBOFOZN.js +50 -0
- package/dist/{acp-53E7A6L4.js → acp-TKO6ZSSV.js} +54 -36
- package/dist/acp-TKO6ZSSV.js.map +7 -0
- package/dist/{agentsValidate-VSDRHIJQ.js → agentsValidate-RDNLI7GA.js} +7 -7
- package/dist/{ask-XUXTH3EI.js → ask-KTXMYPIA.js} +60 -34
- package/dist/ask-KTXMYPIA.js.map +7 -0
- package/dist/{autoUpdater-GAWZB7YO.js → autoUpdater-53BZ6QWD.js} +3 -3
- package/dist/{chunk-WBAZ4MMW.js → chunk-276RV4DQ.js} +4 -4
- package/dist/{chunk-4I2M26LO.js → chunk-35X2VS4L.js} +3 -3
- package/dist/{chunk-RAOXUYK3.js → chunk-4C2CGHBI.js} +2 -2
- package/dist/{chunk-YABL4JYT.js → chunk-4KPVE4K7.js} +1 -1
- package/dist/{chunk-JFIH5LIP.js → chunk-57GJQMFS.js} +2 -2
- package/dist/{chunk-FKDSZPS4.js → chunk-6PXEXL7C.js} +2 -2
- package/dist/{chunk-HOBCGAUT.js → chunk-AMQ6XZOU.js} +1 -1
- package/dist/{chunk-5PSLFGDF.js → chunk-AWRDD6BG.js} +18 -1
- package/dist/chunk-AWRDD6BG.js.map +7 -0
- package/dist/{chunk-JZPXOQK3.js → chunk-BZGQQ4WZ.js} +3 -3
- package/dist/{chunk-AQXOZUAV.js → chunk-CATWZQ3R.js} +2 -2
- package/dist/{chunk-H67PQDUM.js → chunk-CPLMSZ63.js} +4 -4
- package/dist/{chunk-KRTFCQTN.js → chunk-DA6NJEFI.js} +2 -2
- package/dist/{chunk-46Z3GAE4.js → chunk-E35YJNX2.js} +4 -4
- package/dist/{chunk-DRP66QHJ.js → chunk-G7DKRXDS.js} +1 -4
- package/dist/{chunk-62CZOFWT.js → chunk-HIJYNCCN.js} +1 -1
- package/dist/{chunk-543LWZDY.js → chunk-JE43CQYI.js} +3 -3
- package/dist/{chunk-LNPUQ3UL.js → chunk-JLC2I3EY.js} +1 -1
- package/dist/chunk-JRMAK4PK.js +926 -0
- package/dist/chunk-JRMAK4PK.js.map +7 -0
- package/dist/{chunk-VW7ZPH5U.js → chunk-KNLP4UO6.js} +4 -4
- package/dist/chunk-L3R7MPZU.js +81 -0
- package/dist/{chunk-MHFWCK5F.js.map → chunk-L3R7MPZU.js.map} +1 -1
- package/dist/{chunk-LNE2PRIU.js → chunk-LEYWQQ7V.js} +3 -3
- package/dist/{chunk-Z35GPUWK.js → chunk-LIOZM4KE.js} +1 -1
- package/dist/chunk-OC5CZWBQ.js.map +7 -0
- package/dist/{chunk-TJUTH3WH.js → chunk-PH6DPTO3.js} +2014 -1318
- package/dist/chunk-PH6DPTO3.js.map +7 -0
- package/dist/{chunk-VBJ6J63U.js → chunk-PPFVOBEG.js} +144 -76
- package/dist/chunk-PPFVOBEG.js.map +7 -0
- package/dist/{chunk-IZ6NAVRD.js → chunk-Q5EZLUFC.js} +1 -1
- package/dist/{chunk-VRWY6YIJ.js → chunk-QMN64ICT.js} +3 -3
- package/dist/{chunk-4QTASHFO.js → chunk-R4ZEH3KJ.js} +1 -1
- package/dist/{chunk-IWKEQNWI.js → chunk-SNASBZ2C.js} +3 -3
- package/dist/chunk-T7P3SSAQ.js +78 -0
- package/dist/chunk-T7P3SSAQ.js.map +7 -0
- package/dist/{chunk-RFY3YUHB.js → chunk-TLZS274Y.js} +3 -3
- package/dist/{chunk-FQMMZCOL.js → chunk-YSL5H7NJ.js} +2 -2
- package/dist/{chunk-WQVP2232.js → chunk-YTEQEQ56.js} +43 -34
- package/dist/chunk-YTEQEQ56.js.map +7 -0
- package/dist/{cli-3QFWTKDS.js → cli-LYWCNPC6.js} +131 -102
- package/dist/cli-LYWCNPC6.js.map +7 -0
- package/dist/commands-DYXAWJO6.js +54 -0
- package/dist/{config-DFRB2SLO.js → config-66BMMOES.js} +4 -4
- package/dist/{context-V62FBZVF.js → context-PG7YTQCJ.js} +6 -6
- package/dist/conversationPersistence-DB6IUU2I.js +13 -0
- package/dist/{conversationTracker-DZR2N3FQ.js → conversationTracker-WG3J56PX.js} +4 -3
- package/dist/{customCommands-3ZIVHLTU.js → customCommands-XDKUVT73.js} +4 -4
- package/dist/{env-BMFEDWPX.js → env-FW74XJHK.js} +2 -2
- package/dist/{file-SD5NRUTD.js → file-U2NXQ6RC.js} +4 -4
- package/dist/index.js +3 -3
- package/dist/{llm-466UDKVG.js → llm-6VJMMPDO.js} +416 -49
- package/dist/llm-6VJMMPDO.js.map +7 -0
- package/dist/{llmLazy-7R7P5A3P.js → llmLazy-LYGZWC7G.js} +1 -1
- package/dist/{loader-X7RIUXJB.js → loader-DMZVU2XJ.js} +4 -4
- package/dist/{lsp-2FPBS2M3.js → lsp-6LNF5DQB.js} +6 -6
- package/dist/{lspAnchor-KQNSWWL3.js → lspAnchor-SF5Y7ZJT.js} +6 -6
- package/dist/{mcp-3SV4TZYL.js → mcp-NLDX3RQE.js} +7 -7
- package/dist/{mentionProcessor-KJP4IYVF.js → mentionProcessor-BMX6VGRH.js} +5 -5
- package/dist/{messages-BXF7LJIV.js → messages-OTQ6IJM5.js} +9 -5
- package/dist/{model-F6VCUHDL.js → model-KWGEASLY.js} +5 -5
- package/dist/{openai-QTTJIB6O.js → openai-XIRWQY5H.js} +5 -5
- package/dist/{outputStyles-SJ57QG7S.js → outputStyles-HKYM5C76.js} +4 -4
- package/dist/{pluginRuntime-4SDXCK4Q.js → pluginRuntime-25Y2MVIN.js} +6 -6
- package/dist/{pluginValidation-YJ4W3MX4.js → pluginValidation-CIJIQKGB.js} +6 -6
- package/dist/prompts-WH3VEHH6.js +56 -0
- package/dist/{pybAgentSessionLoad-IZULLNUL.js → pybAgentSessionLoad-TF3BFX4S.js} +4 -4
- package/dist/{pybAgentSessionResume-QRNTC3A3.js → pybAgentSessionResume-Y5JO4GLH.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-RUHPYCTJ.js → pybAgentStreamJsonSession-46VLF4QN.js} +4 -3
- package/dist/pybAgentStreamJsonSession-46VLF4QN.js.map +7 -0
- package/dist/{pybHooks-GX3AIY4U.js → pybHooks-LZPU4EF6.js} +4 -4
- package/dist/query-4B3GTPBN.js +58 -0
- package/dist/{registry-JNPRNIFB.js → registry-6LUE7ZWC.js} +5 -5
- package/dist/{ripgrep-ZKWM7RMS.js → ripgrep-KVB55D22.js} +3 -3
- package/dist/{skillMarketplace-4LJAYRMX.js → skillMarketplace-2IVEPC2E.js} +3 -3
- package/dist/{state-I6BQR2T5.js → state-OGBESWFS.js} +2 -2
- package/dist/{theme-GL7HKKCQ.js → theme-QQ2SCFEK.js} +5 -5
- package/dist/{toolPermissionSettings-ZRTSQVQ2.js → toolPermissionSettings-ZGGPBK6S.js} +6 -6
- package/dist/tools-UXPFIHD4.js +55 -0
- package/dist/tools-UXPFIHD4.js.map +7 -0
- package/dist/{userInput-M6JYKQCU.js → userInput-75VCTJDE.js} +76 -49
- package/dist/userInput-75VCTJDE.js.map +7 -0
- package/package.json +18 -1
- package/dist/REPL-AHBTBEED.js +0 -49
- package/dist/acp-53E7A6L4.js.map +0 -7
- package/dist/ask-XUXTH3EI.js.map +0 -7
- package/dist/chunk-5PSLFGDF.js.map +0 -7
- package/dist/chunk-B62BK4YK.js +0 -516
- package/dist/chunk-B62BK4YK.js.map +0 -7
- package/dist/chunk-MHFWCK5F.js +0 -240
- package/dist/chunk-O6DTZU7F.js.map +0 -7
- package/dist/chunk-TJUTH3WH.js.map +0 -7
- package/dist/chunk-VBJ6J63U.js.map +0 -7
- package/dist/chunk-WQVP2232.js.map +0 -7
- package/dist/cli-3QFWTKDS.js.map +0 -7
- package/dist/commands-ITOHDPPP.js +0 -53
- package/dist/llm-466UDKVG.js.map +0 -7
- package/dist/prompts-5RPQRZ3L.js +0 -55
- package/dist/pybAgentStreamJsonSession-RUHPYCTJ.js.map +0 -7
- package/dist/query-YLKPJVHB.js +0 -57
- package/dist/tools-4GEB2BRR.js +0 -54
- package/dist/userInput-M6JYKQCU.js.map +0 -7
- /package/dist/{REPL-AHBTBEED.js.map → REPL-FDBOFOZN.js.map} +0 -0
- /package/dist/{agentsValidate-VSDRHIJQ.js.map → agentsValidate-RDNLI7GA.js.map} +0 -0
- /package/dist/{autoUpdater-GAWZB7YO.js.map → autoUpdater-53BZ6QWD.js.map} +0 -0
- /package/dist/{chunk-WBAZ4MMW.js.map → chunk-276RV4DQ.js.map} +0 -0
- /package/dist/{chunk-4I2M26LO.js.map → chunk-35X2VS4L.js.map} +0 -0
- /package/dist/{chunk-RAOXUYK3.js.map → chunk-4C2CGHBI.js.map} +0 -0
- /package/dist/{chunk-YABL4JYT.js.map → chunk-4KPVE4K7.js.map} +0 -0
- /package/dist/{chunk-JFIH5LIP.js.map → chunk-57GJQMFS.js.map} +0 -0
- /package/dist/{chunk-FKDSZPS4.js.map → chunk-6PXEXL7C.js.map} +0 -0
- /package/dist/{chunk-HOBCGAUT.js.map → chunk-AMQ6XZOU.js.map} +0 -0
- /package/dist/{chunk-JZPXOQK3.js.map → chunk-BZGQQ4WZ.js.map} +0 -0
- /package/dist/{chunk-AQXOZUAV.js.map → chunk-CATWZQ3R.js.map} +0 -0
- /package/dist/{chunk-H67PQDUM.js.map → chunk-CPLMSZ63.js.map} +0 -0
- /package/dist/{chunk-KRTFCQTN.js.map → chunk-DA6NJEFI.js.map} +0 -0
- /package/dist/{chunk-46Z3GAE4.js.map → chunk-E35YJNX2.js.map} +0 -0
- /package/dist/{chunk-DRP66QHJ.js.map → chunk-G7DKRXDS.js.map} +0 -0
- /package/dist/{chunk-62CZOFWT.js.map → chunk-HIJYNCCN.js.map} +0 -0
- /package/dist/{chunk-543LWZDY.js.map → chunk-JE43CQYI.js.map} +0 -0
- /package/dist/{chunk-LNPUQ3UL.js.map → chunk-JLC2I3EY.js.map} +0 -0
- /package/dist/{chunk-VW7ZPH5U.js.map → chunk-KNLP4UO6.js.map} +0 -0
- /package/dist/{chunk-LNE2PRIU.js.map → chunk-LEYWQQ7V.js.map} +0 -0
- /package/dist/{chunk-Z35GPUWK.js.map → chunk-LIOZM4KE.js.map} +0 -0
- /package/dist/{chunk-O6DTZU7F.js → chunk-OC5CZWBQ.js} +0 -0
- /package/dist/{chunk-IZ6NAVRD.js.map → chunk-Q5EZLUFC.js.map} +0 -0
- /package/dist/{chunk-VRWY6YIJ.js.map → chunk-QMN64ICT.js.map} +0 -0
- /package/dist/{chunk-4QTASHFO.js.map → chunk-R4ZEH3KJ.js.map} +0 -0
- /package/dist/{chunk-IWKEQNWI.js.map → chunk-SNASBZ2C.js.map} +0 -0
- /package/dist/{chunk-RFY3YUHB.js.map → chunk-TLZS274Y.js.map} +0 -0
- /package/dist/{chunk-FQMMZCOL.js.map → chunk-YSL5H7NJ.js.map} +0 -0
- /package/dist/{commands-ITOHDPPP.js.map → commands-DYXAWJO6.js.map} +0 -0
- /package/dist/{config-DFRB2SLO.js.map → config-66BMMOES.js.map} +0 -0
- /package/dist/{context-V62FBZVF.js.map → context-PG7YTQCJ.js.map} +0 -0
- /package/dist/{conversationTracker-DZR2N3FQ.js.map → conversationPersistence-DB6IUU2I.js.map} +0 -0
- /package/dist/{customCommands-3ZIVHLTU.js.map → conversationTracker-WG3J56PX.js.map} +0 -0
- /package/dist/{env-BMFEDWPX.js.map → customCommands-XDKUVT73.js.map} +0 -0
- /package/dist/{file-SD5NRUTD.js.map → env-FW74XJHK.js.map} +0 -0
- /package/dist/{llmLazy-7R7P5A3P.js.map → file-U2NXQ6RC.js.map} +0 -0
- /package/dist/{loader-X7RIUXJB.js.map → llmLazy-LYGZWC7G.js.map} +0 -0
- /package/dist/{lsp-2FPBS2M3.js.map → loader-DMZVU2XJ.js.map} +0 -0
- /package/dist/{mcp-3SV4TZYL.js.map → lsp-6LNF5DQB.js.map} +0 -0
- /package/dist/{lspAnchor-KQNSWWL3.js.map → lspAnchor-SF5Y7ZJT.js.map} +0 -0
- /package/dist/{messages-BXF7LJIV.js.map → mcp-NLDX3RQE.js.map} +0 -0
- /package/dist/{mentionProcessor-KJP4IYVF.js.map → mentionProcessor-BMX6VGRH.js.map} +0 -0
- /package/dist/{model-F6VCUHDL.js.map → messages-OTQ6IJM5.js.map} +0 -0
- /package/dist/{openai-QTTJIB6O.js.map → model-KWGEASLY.js.map} +0 -0
- /package/dist/{outputStyles-SJ57QG7S.js.map → openai-XIRWQY5H.js.map} +0 -0
- /package/dist/{pluginValidation-YJ4W3MX4.js.map → outputStyles-HKYM5C76.js.map} +0 -0
- /package/dist/{pluginRuntime-4SDXCK4Q.js.map → pluginRuntime-25Y2MVIN.js.map} +0 -0
- /package/dist/{prompts-5RPQRZ3L.js.map → pluginValidation-CIJIQKGB.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-IZULLNUL.js.map → prompts-WH3VEHH6.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-QRNTC3A3.js.map → pybAgentSessionLoad-TF3BFX4S.js.map} +0 -0
- /package/dist/{pybHooks-GX3AIY4U.js.map → pybAgentSessionResume-Y5JO4GLH.js.map} +0 -0
- /package/dist/{query-YLKPJVHB.js.map → pybHooks-LZPU4EF6.js.map} +0 -0
- /package/dist/{registry-JNPRNIFB.js.map → query-4B3GTPBN.js.map} +0 -0
- /package/dist/{ripgrep-ZKWM7RMS.js.map → registry-6LUE7ZWC.js.map} +0 -0
- /package/dist/{skillMarketplace-4LJAYRMX.js.map → ripgrep-KVB55D22.js.map} +0 -0
- /package/dist/{state-I6BQR2T5.js.map → skillMarketplace-2IVEPC2E.js.map} +0 -0
- /package/dist/{theme-GL7HKKCQ.js.map → state-OGBESWFS.js.map} +0 -0
- /package/dist/{toolPermissionSettings-ZRTSQVQ2.js.map → theme-QQ2SCFEK.js.map} +0 -0
- /package/dist/{tools-4GEB2BRR.js.map → toolPermissionSettings-ZGGPBK6S.js.map} +0 -0
package/dist/chunk-MHFWCK5F.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { createRequire as __pybCreateRequire } from "node:module";
|
|
2
|
-
const require = __pybCreateRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
getPybAgentSessionId
|
|
5
|
-
} from "./chunk-B6IMQJZM.js";
|
|
6
|
-
import {
|
|
7
|
-
PLAN_SLUG_ADJECTIVES,
|
|
8
|
-
PLAN_SLUG_NOUNS,
|
|
9
|
-
PLAN_SLUG_VERBS,
|
|
10
|
-
getCwd,
|
|
11
|
-
resolveXdgDataPath
|
|
12
|
-
} from "./chunk-DRP66QHJ.js";
|
|
13
|
-
import {
|
|
14
|
-
MACRO
|
|
15
|
-
} from "./chunk-5PSLFGDF.js";
|
|
16
|
-
|
|
17
|
-
// src/utils/protocol/pybAgentSessionLog.ts
|
|
18
|
-
import { execFileSync } from "child_process";
|
|
19
|
-
import {
|
|
20
|
-
appendFileSync,
|
|
21
|
-
existsSync,
|
|
22
|
-
mkdirSync,
|
|
23
|
-
readFileSync,
|
|
24
|
-
statSync,
|
|
25
|
-
writeFileSync
|
|
26
|
-
} from "fs";
|
|
27
|
-
import { randomBytes } from "crypto";
|
|
28
|
-
import { dirname, join } from "path";
|
|
29
|
-
function getSessionStoreBaseDir() {
|
|
30
|
-
return resolveXdgDataPath("sessions");
|
|
31
|
-
}
|
|
32
|
-
function sanitizeProjectNameForSessionStore(cwd) {
|
|
33
|
-
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
34
|
-
}
|
|
35
|
-
function getSessionProjectsDir() {
|
|
36
|
-
return join(getSessionStoreBaseDir(), "projects");
|
|
37
|
-
}
|
|
38
|
-
function getSessionProjectDir(cwd) {
|
|
39
|
-
return join(getSessionProjectsDir(), sanitizeProjectNameForSessionStore(cwd));
|
|
40
|
-
}
|
|
41
|
-
function getSessionLogFilePath(args) {
|
|
42
|
-
return join(getSessionProjectDir(args.cwd), `${args.sessionId}.jsonl`);
|
|
43
|
-
}
|
|
44
|
-
function getAgentLogFilePath(args) {
|
|
45
|
-
return join(getSessionProjectDir(args.cwd), `agent-${args.agentId}.jsonl`);
|
|
46
|
-
}
|
|
47
|
-
function safeMkdir(dir) {
|
|
48
|
-
if (existsSync(dir)) return;
|
|
49
|
-
mkdirSync(dir, { recursive: true });
|
|
50
|
-
}
|
|
51
|
-
function safeEnsureFile(path) {
|
|
52
|
-
safeMkdir(dirname(path));
|
|
53
|
-
if (!existsSync(path)) writeFileSync(path, "", "utf8");
|
|
54
|
-
}
|
|
55
|
-
function safeAppendJsonl(path, record) {
|
|
56
|
-
try {
|
|
57
|
-
safeEnsureFile(path);
|
|
58
|
-
appendFileSync(path, JSON.stringify(record) + "\n", "utf8");
|
|
59
|
-
} catch {
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
var lastUuidByFile = /* @__PURE__ */ new Map();
|
|
63
|
-
var snapshotWrittenByFile = /* @__PURE__ */ new Set();
|
|
64
|
-
var slugBySessionId = /* @__PURE__ */ new Map();
|
|
65
|
-
var currentSessionCustomTitle = null;
|
|
66
|
-
var currentSessionTag = null;
|
|
67
|
-
function safeReadLastPersistedInfo(filePath) {
|
|
68
|
-
try {
|
|
69
|
-
if (!existsSync(filePath)) return { uuid: null, slug: null };
|
|
70
|
-
const content = readFileSync(filePath, "utf8");
|
|
71
|
-
const lines = content.split("\n");
|
|
72
|
-
let lastSlug = null;
|
|
73
|
-
for (let i = lines.length - 1; i >= 0; i--) {
|
|
74
|
-
const line = lines[i]?.trim();
|
|
75
|
-
if (!line) continue;
|
|
76
|
-
let parsed;
|
|
77
|
-
try {
|
|
78
|
-
parsed = JSON.parse(line);
|
|
79
|
-
} catch {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (!parsed || typeof parsed !== "object") continue;
|
|
83
|
-
if (!lastSlug && typeof parsed.slug === "string" && parsed.slug.trim()) {
|
|
84
|
-
lastSlug = parsed.slug.trim();
|
|
85
|
-
}
|
|
86
|
-
if (typeof parsed.uuid === "string" && parsed.uuid) {
|
|
87
|
-
return { uuid: parsed.uuid, slug: lastSlug };
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return { uuid: null, slug: lastSlug };
|
|
91
|
-
} catch {
|
|
92
|
-
return { uuid: null, slug: null };
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function pickIndex(length) {
|
|
96
|
-
return randomBytes(4).readUInt32BE(0) % length;
|
|
97
|
-
}
|
|
98
|
-
function pickWord(words) {
|
|
99
|
-
return words[pickIndex(words.length)];
|
|
100
|
-
}
|
|
101
|
-
function generateSessionSlug() {
|
|
102
|
-
const adjective = pickWord(PLAN_SLUG_ADJECTIVES);
|
|
103
|
-
const verb = pickWord(PLAN_SLUG_VERBS);
|
|
104
|
-
const noun = pickWord(PLAN_SLUG_NOUNS);
|
|
105
|
-
return `${adjective}-${verb}-${noun}`;
|
|
106
|
-
}
|
|
107
|
-
function getOrCreateSessionSlug(sessionId) {
|
|
108
|
-
const existing = slugBySessionId.get(sessionId);
|
|
109
|
-
if (existing) return existing;
|
|
110
|
-
const slug = generateSessionSlug();
|
|
111
|
-
slugBySessionId.set(sessionId, slug);
|
|
112
|
-
return slug;
|
|
113
|
-
}
|
|
114
|
-
var gitBranchCache = null;
|
|
115
|
-
function getGitBranchBestEffort(cwd) {
|
|
116
|
-
if (gitBranchCache && gitBranchCache.cwd === cwd) return gitBranchCache.value;
|
|
117
|
-
let value;
|
|
118
|
-
try {
|
|
119
|
-
const stdout = execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
120
|
-
cwd,
|
|
121
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
122
|
-
timeout: 750
|
|
123
|
-
});
|
|
124
|
-
const branch = stdout.toString("utf8").trim();
|
|
125
|
-
value = branch || void 0;
|
|
126
|
-
} catch {
|
|
127
|
-
value = void 0;
|
|
128
|
-
}
|
|
129
|
-
gitBranchCache = { cwd, value };
|
|
130
|
-
return value;
|
|
131
|
-
}
|
|
132
|
-
function ensureFileHistorySnapshot(filePath, firstMessageUuid) {
|
|
133
|
-
if (snapshotWrittenByFile.has(filePath)) return;
|
|
134
|
-
try {
|
|
135
|
-
safeEnsureFile(filePath);
|
|
136
|
-
const size = statSync(filePath).size;
|
|
137
|
-
if (size > 0) {
|
|
138
|
-
snapshotWrittenByFile.add(filePath);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
} catch {
|
|
142
|
-
}
|
|
143
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
144
|
-
safeAppendJsonl(filePath, {
|
|
145
|
-
type: "file-history-snapshot",
|
|
146
|
-
messageId: firstMessageUuid,
|
|
147
|
-
snapshot: {
|
|
148
|
-
messageId: firstMessageUuid,
|
|
149
|
-
trackedFileBackups: {},
|
|
150
|
-
timestamp: now
|
|
151
|
-
},
|
|
152
|
-
isSnapshotUpdate: false
|
|
153
|
-
});
|
|
154
|
-
snapshotWrittenByFile.add(filePath);
|
|
155
|
-
}
|
|
156
|
-
function resolvePersistTarget(toolUseContext) {
|
|
157
|
-
const agentId = toolUseContext.agentId;
|
|
158
|
-
if (agentId && agentId !== "main") return { kind: "agent", agentId };
|
|
159
|
-
return { kind: "session", sessionId: getPybAgentSessionId() };
|
|
160
|
-
}
|
|
161
|
-
function appendSessionJsonlFromMessage(args) {
|
|
162
|
-
const { message, toolUseContext } = args;
|
|
163
|
-
if (message.type !== "user" && message.type !== "assistant") return;
|
|
164
|
-
const cwd = getCwd();
|
|
165
|
-
const userType = (process.env.USER_TYPE ?? "external").trim() || "external";
|
|
166
|
-
const sessionId = getPybAgentSessionId();
|
|
167
|
-
const agentId = (toolUseContext.agentId ?? "main").trim() || "main";
|
|
168
|
-
const isSidechain = agentId !== "main";
|
|
169
|
-
const gitBranch = getGitBranchBestEffort(cwd);
|
|
170
|
-
const target = resolvePersistTarget(toolUseContext);
|
|
171
|
-
const filePath = target.kind === "agent" ? getAgentLogFilePath({ cwd, agentId: target.agentId }) : getSessionLogFilePath({ cwd, sessionId: target.sessionId });
|
|
172
|
-
if (!lastUuidByFile.has(filePath)) {
|
|
173
|
-
const info = safeReadLastPersistedInfo(filePath);
|
|
174
|
-
lastUuidByFile.set(filePath, info.uuid);
|
|
175
|
-
if (info.slug) slugBySessionId.set(sessionId, info.slug);
|
|
176
|
-
}
|
|
177
|
-
const previousUuid = lastUuidByFile.get(filePath) ?? null;
|
|
178
|
-
const slug = getOrCreateSessionSlug(sessionId);
|
|
179
|
-
if (target.kind === "session") {
|
|
180
|
-
ensureFileHistorySnapshot(filePath, message.uuid);
|
|
181
|
-
}
|
|
182
|
-
const base = {
|
|
183
|
-
parentUuid: previousUuid,
|
|
184
|
-
logicalParentUuid: void 0,
|
|
185
|
-
isSidechain,
|
|
186
|
-
userType,
|
|
187
|
-
cwd,
|
|
188
|
-
sessionId,
|
|
189
|
-
version: MACRO.VERSION,
|
|
190
|
-
...gitBranch ? { gitBranch } : {},
|
|
191
|
-
agentId,
|
|
192
|
-
slug,
|
|
193
|
-
uuid: message.uuid,
|
|
194
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
195
|
-
};
|
|
196
|
-
const record = message.type === "user" ? {
|
|
197
|
-
...base,
|
|
198
|
-
type: "user",
|
|
199
|
-
message: message.message,
|
|
200
|
-
...message.toolUseResult?.data !== void 0 ? { toolUseResult: message.toolUseResult.data } : {}
|
|
201
|
-
} : {
|
|
202
|
-
...base,
|
|
203
|
-
type: "assistant",
|
|
204
|
-
message: message.message,
|
|
205
|
-
...typeof message.requestId === "string" ? { requestId: String(message.requestId) } : {},
|
|
206
|
-
...message.isApiErrorMessage ? { isApiErrorMessage: true } : {}
|
|
207
|
-
};
|
|
208
|
-
safeAppendJsonl(filePath, record);
|
|
209
|
-
lastUuidByFile.set(filePath, message.uuid);
|
|
210
|
-
}
|
|
211
|
-
function appendSessionCustomTitleRecord(args) {
|
|
212
|
-
const cwd = getCwd();
|
|
213
|
-
safeAppendJsonl(getSessionLogFilePath({ cwd, sessionId: args.sessionId }), {
|
|
214
|
-
type: "custom-title",
|
|
215
|
-
sessionId: args.sessionId,
|
|
216
|
-
customTitle: args.customTitle
|
|
217
|
-
});
|
|
218
|
-
if (args.sessionId === getPybAgentSessionId()) {
|
|
219
|
-
currentSessionCustomTitle = args.customTitle;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
function appendSessionTagRecord(args) {
|
|
223
|
-
const cwd = getCwd();
|
|
224
|
-
safeAppendJsonl(getSessionLogFilePath({ cwd, sessionId: args.sessionId }), {
|
|
225
|
-
type: "tag",
|
|
226
|
-
sessionId: args.sessionId,
|
|
227
|
-
tag: args.tag
|
|
228
|
-
});
|
|
229
|
-
if (args.sessionId === getPybAgentSessionId()) {
|
|
230
|
-
currentSessionTag = args.tag;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export {
|
|
235
|
-
getSessionProjectsDir,
|
|
236
|
-
getSessionProjectDir,
|
|
237
|
-
appendSessionJsonlFromMessage,
|
|
238
|
-
appendSessionCustomTitleRecord,
|
|
239
|
-
appendSessionTagRecord
|
|
240
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/core/tools/tool.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod'\nimport type * as React from 'react'\nimport type { PermissionMode } from '@pyb-types/permissionMode'\nimport type { ToolPermissionContext } from '@pyb-types/toolPermissionContext'\n\nexport type SetToolJSXFn = (\n jsx: {\n jsx: React.ReactNode | null\n shouldHidePromptInput: boolean\n } | null,\n) => void\n\nexport interface ToolUseContext {\n messageId: string | undefined\n toolUseId?: string\n agentId?: string\n agentType?: string\n safeMode?: boolean\n abortController: AbortController\n readFileTimestamps: { [filePath: string]: number }\n options?: {\n commands?: any[]\n tools?: any[]\n verbose?: boolean\n slowAndCapableModel?: string\n safeMode?: boolean\n permissionMode?: PermissionMode\n toolPermissionContext?: ToolPermissionContext\n lastUserPrompt?: string\n forkNumber?: number\n messageLogName?: string\n maxThinkingTokens?: any\n model?: string\n commandAllowedTools?: string[]\n isPybRequest?: boolean\n pybContext?: string\n isCustomCommand?: boolean\n mcpClients?: any[]\n disableSlashCommands?: boolean\n persistSession?: boolean\n shouldAvoidPermissionPrompts?: boolean\n }\n responseState?: {\n previousResponseId?: string\n conversationId?: string\n }\n}\n\nexport interface ExtendedToolUseContext extends ToolUseContext {\n setToolJSX: SetToolJSXFn\n}\n\nexport interface ValidationResult {\n result: boolean\n message?: string\n errorCode?: number\n meta?: any\n}\n\nexport interface Tool<\n TInput extends z.ZodTypeAny = z.ZodTypeAny,\n TOutput = any,\n> {\n name: string\n description?: string | ((input?: z.infer<TInput>) => Promise<string>)\n inputSchema: TInput\n inputJSONSchema?: Record<string, unknown>\n prompt: (options?: { safeMode?: boolean }) => Promise<string>\n userFacingName?: (input?: z.infer<TInput>) => string\n cachedDescription?: string\n isEnabled: () => Promise<boolean>\n isReadOnly: (input?: z.infer<TInput>) => boolean\n isConcurrencySafe: (input?: z.infer<TInput>) => boolean\n needsPermissions: (input?: z.infer<TInput>) => boolean\n requiresUserInteraction?: (input?: z.infer<TInput>) => boolean\n validateInput?: (\n input: z.infer<TInput>,\n context?: ToolUseContext,\n ) => Promise<ValidationResult>\n renderResultForAssistant: (output: TOutput) => string | any[]\n renderToolUseMessage: (\n input: z.infer<TInput>,\n options: { verbose: boolean },\n ) => string | React.ReactElement | null\n renderToolUseRejectedMessage?: (...args: any[]) => React.ReactElement\n renderToolResultMessage?: (\n output: TOutput,\n options: { verbose: boolean },\n ) => React.ReactNode\n call: (\n input: z.infer<TInput>,\n context: ToolUseContext,\n ) => AsyncGenerator<\n | {\n type: 'result'\n data: TOutput\n resultForAssistant?: string | any[]\n newMessages?: unknown[]\n contextModifier?: {\n modifyContext: (ctx: ToolUseContext) => ToolUseContext\n }\n }\n | {\n type: 'progress'\n content: any\n normalizedMessages?: any[]\n tools?: any[]\n },\n void,\n unknown\n >\n}\n\nexport function getToolDescription(tool: Tool): string {\n if (tool.cachedDescription) {\n return tool.cachedDescription\n }\n\n if (typeof tool.description === 'string') {\n return tool.description\n }\n\n return `Tool: ${tool.name}`\n}\n"],
|
|
5
|
-
"mappings": ";;;;AAiHO,SAAS,mBAAmB,MAAoB;AACrD,MAAI,KAAK,mBAAmB;AAC1B,WAAO,KAAK;AAAA,EACd;AAEA,MAAI,OAAO,KAAK,gBAAgB,UAAU;AACxC,WAAO,KAAK;AAAA,EACd;AAEA,SAAO,SAAS,KAAK,IAAI;AAC3B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|