@desplega.ai/agent-swarm 1.171.1 → 1.172.0
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/{acp-adapter-wnhq4ydy.js → acp-adapter-fpecx1g1.js} +23 -5
- package/dist/{actions-45eyf0ns.js → actions-pw87a1a8.js} +24 -25
- package/dist/{amp-adapter-f5dr6dm0.js → amp-adapter-8jem2bc0.js} +1 -1
- package/dist/{anthropic-messages-etkbxhhy.js → anthropic-messages-8ee2f22q.js} +55 -22
- package/dist/{app-qv86qhzz.js → app-wmf0m843.js} +7 -8
- package/dist/{assistant-10yaeebp.js → assistant-emp1e108.js} +26 -27
- package/dist/{azure-openai-responses-xap57x4b.js → azure-openai-responses-ap1gwxgr.js} +3 -3
- package/dist/{boot-reembed-p2wbqxm4.js → boot-reembed-1de4f4aj.js} +6 -7
- package/dist/{boot-reembed-wyb785et.js → boot-reembed-4ymn9atn.js} +6 -7
- package/dist/{boot-scrub-sweep-daaqcs9t.js → boot-scrub-sweep-adhk1s8c.js} +7 -8
- package/dist/{boot-seeds-1pvzyx4h.js → boot-seeds-8q637aew.js} +9 -10
- package/dist/{claude-adapter-v2py1c6g.js → claude-adapter-t26cv8a4.js} +16 -17
- package/dist/{claude-managed-adapter-kqqqhp2q.js → claude-managed-adapter-xgxhqrt2.js} +2 -2
- package/dist/{claude-sdk-session-mk938tpt.js → claude-sdk-session-gsfsh662.js} +16 -17
- package/dist/{cli-f651ypy4.js → cli-04emfe2q.js} +1 -1
- package/dist/{cli-w0bwte75.js → cli-104zsxba.js} +2 -1
- package/dist/{cli-x6z90nq9.js → cli-19njxg5g.js} +2 -4
- package/dist/{cli-d78fccnb.js → cli-1hgat6pa.js} +5 -5
- package/dist/{cli-1qtgd1h1.js → cli-1m2xxxe2.js} +2 -2
- package/dist/{cli-231av4y6.js → cli-1x7da0de.js} +2 -4
- package/dist/{cli-apnwqe6h.js → cli-388egyf6.js} +1 -1
- package/dist/{cli-j0w59p15.js → cli-4fnb6884.js} +4 -4
- package/dist/{cli-y1j1ggbf.js → cli-4nz8p1p5.js} +1372 -588
- package/dist/{cli-z9cvwx5m.js → cli-5rv1j9ga.js} +6 -6
- package/dist/{cli-mn8qkd8v.js → cli-61625k3x.js} +1 -1
- package/dist/{cli-ehf1dfay.js → cli-6jb2rf77.js} +3 -3
- package/dist/{cli-zh93km01.js → cli-8hzfb6xz.js} +8 -8
- package/dist/{cli-jn9wk8z8.js → cli-8vs9trd4.js} +1 -1
- package/dist/{cli-xf713zz0.js → cli-9fxpr83v.js} +1 -1
- package/dist/{cli-q1vnz8wv.js → cli-9s17naqf.js} +1 -1
- package/dist/{cli-pw9x22wp.js → cli-9xsmdpdt.js} +59 -54
- package/dist/{cli-pwnxv8pw.js → cli-aspcaef3.js} +5 -5
- package/dist/cli-bf7485pm.js +514 -0
- package/dist/{cli-s9y81s7j.js → cli-bt8k5h3s.js} +625 -150
- package/dist/{cli-48ve9gsj.js → cli-c2pq2rjb.js} +2 -2
- package/dist/{cli-13xwcqvj.js → cli-c5km5znr.js} +2 -2
- package/dist/{cli-5y67yrt6.js → cli-cceskcvt.js} +112 -176
- package/dist/{cli-ph3145b7.js → cli-cf69s3ew.js} +4 -4
- package/dist/{cli-k2v5x13t.js → cli-d603qf86.js} +1 -1
- package/dist/{cli-tqzk05ty.js → cli-e0a9sk00.js} +1 -1
- package/dist/{cli-cgj4hc12.js → cli-eh1ytktb.js} +1872 -190
- package/dist/{cli-bkdbswyn.js → cli-esnpehf5.js} +7 -8
- package/dist/cli-ev91t6xp.js +148 -0
- package/dist/{cli-e2prcx5m.js → cli-fdvbjtbw.js} +235 -5
- package/dist/{cli-c9cnsnms.js → cli-g4f5pj26.js} +3 -3
- package/dist/{cli-2aap68ns.js → cli-g6t9texm.js} +5 -5
- package/dist/{cli-6pxmb99j.js → cli-gj81e47t.js} +1 -1
- package/dist/{cli-tb8p51kg.js → cli-gp1rtyvk.js} +2 -2
- package/dist/{cli-rb9m6rpe.js → cli-h6vtvt5c.js} +139 -1
- package/dist/cli-hd27d2md.js +1057 -0
- package/dist/{cli-ndvfgmk8.js → cli-hwwvy36w.js} +3 -3
- package/dist/{cli-2rbt7at8.js → cli-hz99wfxp.js} +1 -1
- package/dist/cli-j1pmc07z.js +706 -0
- package/dist/{cli-jr749y58.js → cli-j6kpj9az.js} +14 -8
- package/dist/{cli-2k8gyaey.js → cli-k46r9hmk.js} +6 -6
- package/dist/{cli-vtqrsgnm.js → cli-kb4ehzx5.js} +5 -5
- package/dist/{cli-agamgm0p.js → cli-mvzyxwg3.js} +1 -1
- package/dist/{cli-j8xzym9k.js → cli-nv4zd0b9.js} +1 -1
- package/dist/{cli-rrbctenq.js → cli-nyhb1r6x.js} +3 -5
- package/dist/{cli-g7k7zbcz.js → cli-p7z6q2m6.js} +2 -1
- package/dist/{cli-yn0a417a.js → cli-phre6gz0.js} +22 -4
- package/dist/{cli-m4csbs67.js → cli-pj6x9qce.js} +1 -1
- package/dist/{cli-8ntwbxmm.js → cli-prrt9fa0.js} +4 -4
- package/dist/{cli-hadkza7w.js → cli-pstq9888.js} +33 -33
- package/dist/{cli-y195hv1a.js → cli-pxeeyc53.js} +1 -1
- package/dist/{cli-hrbedqp0.js → cli-qsztpfry.js} +1 -1
- package/dist/{cli-5t5my0h8.js → cli-qybkr9n3.js} +278 -1267
- package/dist/{cli-xezn9nkh.js → cli-r44t9wqc.js} +29 -472
- package/dist/{cli-xy6sgy6p.js → cli-r8smj8b8.js} +1 -1
- package/dist/{cli-bxqez1p0.js → cli-rcp5aqdw.js} +9 -39
- package/dist/{cli-vr5avem2.js → cli-smcrrmhy.js} +14 -18
- package/dist/{cli-amvnn9wz.js → cli-tgpfnm6r.js} +15 -17
- package/dist/cli-vb8g5x02.js +549 -0
- package/dist/{cli-gt4hxb8p.js → cli-vv0qtfpx.js} +1 -2
- package/dist/{cli-95zs84qw.js → cli-wd0hz6ah.js} +671 -388
- package/dist/{cli-nkqjj42q.js → cli-x4m6feqt.js} +1 -1
- package/dist/{cli-x61srfpp.js → cli-xczpdp9e.js} +2 -2
- package/dist/cli-z1kd834t.js +36 -0
- package/dist/{cli-f3vy7ncj.js → cli-ztrv9y21.js} +48 -33
- package/dist/cli.js +24 -25
- package/dist/{cloudflare-workers-ai-system-one-sta45jf9.js → cloudflare-workers-ai-system-one-vnpyfr7e.js} +3 -3
- package/dist/{codex-adapter-cg8vntj1.js → codex-adapter-m4tgdysy.js} +12 -12
- package/dist/{codex-hook-7ba15hjd.js → codex-hook-xch6z5wt.js} +2 -3
- package/dist/{codex-session-runner-jxs6n1qx.js → codex-session-runner-ymwzm6ea.js} +12 -12
- package/dist/{commands-8zhezbzr.js → commands-n0hshcvs.js} +6 -7
- package/dist/{controllers-connect-q0brsq11.js → controllers-connect-y07cqcvy.js} +24 -25
- package/dist/{cursor-adapter-t4pr1m3c.js → cursor-adapter-q8pgv5qa.js} +2 -3
- package/dist/{db-ggc4b127.js → db-4w7tmt1g.js} +6 -7
- package/dist/{db-d80sy99v.js → db-hkqvrdcb.js} +7 -8
- package/dist/{dispatcher-eascgc1z.js → dispatcher-5sd69y14.js} +23 -24
- package/dist/{easter-egg-3d-66zxervv.js → easter-egg-3d-m8rvz40s.js} +4 -3
- package/dist/execute-107xtsp1.js +3745 -0
- package/dist/{google-generative-ai-pvhm0dq1.js → google-generative-ai-7pavrbv7.js} +3 -3
- package/dist/{google-vertex-tek9sqe2.js → google-vertex-3f1jk41f.js} +3 -3
- package/dist/{grok-adapter-8ram8zse.js → grok-adapter-8m9yqzbq.js} +24 -6
- package/dist/{handlers-hypxbg7e.js → handlers-s20xr10r.js} +26 -27
- package/dist/{heartbeat-ge72pt7q.js → heartbeat-3k31q4g2.js} +25 -26
- package/dist/{hook-grgtyrad.js → hook-gdn6a2fn.js} +13 -14
- package/dist/{hook-xzwg1zwp.js → hook-ygwerrdh.js} +14 -15
- package/dist/{http-2nf2axqq.js → http-jdteeg81.js} +53 -55
- package/dist/{index-6zehd2p5.js → index-6ksewd5y.js} +20 -18
- package/dist/{index-kkeftv5h.js → index-82rk11v7.js} +4 -4
- package/dist/{index-9egx96ey.js → index-e0snym4t.js} +23 -24
- package/dist/{index-27aez391.js → index-ffqzqgwb.js} +6 -7
- package/dist/{index-57svck0z.js → index-tsszt7g9.js} +25 -26
- package/dist/{index-w097eg0x.js → index-vccv018g.js} +1 -1
- package/dist/{index-0h5dd9xg.js → index-vm3bm9t7.js} +24 -25
- package/dist/{keepalive-5pjbsz8f.js → keepalive-jekc896t.js} +8 -9
- package/dist/{lead-g19prqhd.js → lead-4k9s9szx.js} +40 -41
- package/dist/{maintenance-1brc7q4c.js → maintenance-shazch4n.js} +6 -7
- package/dist/{mistral-conversations-rjxa9s1j.js → mistral-conversations-vjc1ggpd.js} +29 -15
- package/dist/{oauth-refresh-sweep-rhe857nd.js → oauth-refresh-sweep-5gb36kn8.js} +7 -8
- package/dist/{onboard-6bcg69eg.js → onboard-ydrbnvww.js} +2 -2
- package/dist/{openai-codex-responses-pgvtddvv.js → openai-codex-responses-33qhkkdy.js} +7 -39
- package/dist/{openai-completions-44gb0zsk.js → openai-completions-s88xm3ns.js} +2 -2
- package/dist/{openai-decisions-vj9nkpf8.js → openai-decisions-fctnj8xd.js} +2 -2
- package/dist/{openai-responses-9dyzwzkr.js → openai-responses-7xd2f2e2.js} +3 -3
- package/dist/opencode-adapter-5zh0he20.js +55 -0
- package/dist/{otel-impl-y237rck3.js → otel-impl-6pf5cv86.js} +1 -1
- package/dist/{pi-mono-adapter-fx6k5wwh.js → pi-mono-adapter-ef9wwx9m.js} +25 -500
- package/dist/{pricing-refresh-se1qg8wn.js → pricing-refresh-s52nsa5q.js} +8 -9
- package/dist/{rbac-roles-b6ca1n23.js → rbac-roles-aq3msh4e.js} +6 -7
- package/dist/{rbac-roles-c58kydph.js → rbac-roles-q5gb5e8v.js} +7 -8
- package/dist/{render-v2-gqz7z5xt.js → render-v2-pd1rg54q.js} +7 -8
- package/dist/{resume-yb3y3vda.js → resume-gw4a2c6v.js} +14 -15
- package/dist/{runtime-h9ha1mq6.js → runtime-qfry88v2.js} +4 -7
- package/dist/{setup-1rbr9x3c.js → setup-jda1ksdh.js} +2 -2
- package/dist/{typesafe-system-one-e988vty7.js → typesafe-system-one-zzzcx4s3.js} +3 -3
- package/dist/{virtual-modules-rdjmcg7q.js → virtual-modules-b3ga2m65.js} +13 -12
- package/dist/{work-objects-nzcp8srm.js → work-objects-tb7ycye8.js} +26 -27
- package/dist/{worker-wnz1h3g0.js → worker-njjccz5d.js} +40 -41
- package/openapi.json +1 -1
- package/package.json +7 -8
- package/src/be/scripts/extract-schema.ts +4 -0
- package/src/github/handlers.ts +61 -18
- package/src/github/types.ts +2 -1
- package/src/prompts/goal-reminder.ts +30 -0
- package/src/prompts/session-templates.ts +22 -0
- package/src/providers/acp-targets.ts +3 -4
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/harness-version.ts +0 -1
- package/src/providers/opencode-adapter.ts +442 -723
- package/src/providers/opencode-swarm-plugin.ts +88 -0
- package/src/providers/pi-mono-extension.ts +58 -37
- package/src/scripts-runtime/executors/native.ts +6 -5
- package/src/scripts-runtime/executors/quickjs-bundle.ts +18 -11
- package/src/scripts-runtime/extract-args-schema.ts +22 -4
- package/src/scripts-runtime/import-allowlist.ts +1 -1
- package/src/scripts-runtime/zod-mini-bundle.ts +5 -0
- package/src/slack/render-v2.ts +2 -2
- package/src/tests/entrypoint-acp-target-binary.test.ts +19 -1
- package/src/tests/github-handlers-inline-comments.test.ts +131 -2
- package/src/tests/github-handlers-reactions.test.ts +9 -0
- package/src/tests/harness-version.test.ts +0 -20
- package/src/tests/opencode-adapter.test.ts +536 -1389
- package/src/tests/opencode-mcp-admission-sdk.test.ts +106 -0
- package/src/tests/opencode-swarm-plugin.test.ts +130 -0
- package/src/tests/pi-mono-extension.test.ts +59 -0
- package/src/tests/prompt-template-session.test.ts +4 -3
- package/src/tests/provider-registration.test.ts +3 -0
- package/src/tests/script-executor-quickjs.test.ts +17 -12
- package/src/tests/scripts-http.test.ts +24 -16
- package/src/tests/scripts-import-allowlist.test.ts +1 -1
- package/src/tests/scripts-runtime.test.ts +78 -40
- package/src/tests/seed-scripts.test.ts +13 -0
- package/src/tests/slack-render-v2.test.ts +4 -2
- package/src/tests/ui-logs-parser.test.ts +28 -0
- package/src/tools/script-upsert.ts +1 -1
- package/src/utils/memory-raters.ts +7 -3
- package/src/utils/openrouter-base-url.ts +0 -2
- package/templates/schedules/weekly-harness-upgrade-check/content.md +4 -6
- package/templates/skills/heartbeat-runbook/content.md +2 -0
- package/templates/skills/swarm-scripts/SKILL.md +1 -0
- package/templates/skills/swarm-scripts/content.md +1 -0
- package/dist/cli-5bfdm1ah.js +0 -462
- package/dist/cli-5c2j5yvx.js +0 -222
- package/dist/cli-rhy7z1rp.js +0 -532
- package/dist/cli-ywh2a87k.js +0 -2359
- package/dist/execute-h4jgevyw.js +0 -1387
- package/dist/opencode-adapter-f1zby94p.js +0 -34
- package/plugin/opencode-plugins/lib/memory-raters.ts +0 -7
- package/src/tests/opencode-plugin.test.ts +0 -580
- package/src/tests/providers/opencode-cost.test.ts +0 -74
package/dist/cli-rhy7z1rp.js
DELETED
|
@@ -1,532 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Text,
|
|
3
|
-
getBinDir,
|
|
4
|
-
getCapabilities,
|
|
5
|
-
getImageDimensions,
|
|
6
|
-
hyperlink,
|
|
7
|
-
imageFallback,
|
|
8
|
-
resolvePath,
|
|
9
|
-
truncateToWidth
|
|
10
|
-
} from "./cli-5t5my0h8.js";
|
|
11
|
-
|
|
12
|
-
// node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.js
|
|
13
|
-
import { randomBytes } from "node:crypto";
|
|
14
|
-
import { createWriteStream } from "node:fs";
|
|
15
|
-
import { writeFile } from "node:fs/promises";
|
|
16
|
-
import { tmpdir } from "node:os";
|
|
17
|
-
import { join } from "node:path";
|
|
18
|
-
var OUTPUT_FILE_MODE = 384;
|
|
19
|
-
function createOutputFilePath(prefix, extension) {
|
|
20
|
-
return join(tmpdir(), `${prefix}-${randomBytes(8).toString("hex")}${extension}`);
|
|
21
|
-
}
|
|
22
|
-
async function writeOutputFile(prefix, extension, data) {
|
|
23
|
-
const path = createOutputFilePath(prefix, extension);
|
|
24
|
-
await writeFile(path, data, { mode: OUTPUT_FILE_MODE, flag: "wx" });
|
|
25
|
-
return path;
|
|
26
|
-
}
|
|
27
|
-
function createOutputFileStream(prefix, extension) {
|
|
28
|
-
const path = createOutputFilePath(prefix, extension);
|
|
29
|
-
return { path, stream: createWriteStream(path, { mode: OUTPUT_FILE_MODE, flags: "wx" }) };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js
|
|
33
|
-
var DEFAULT_MAX_LINES = 2000;
|
|
34
|
-
var DEFAULT_MAX_BYTES = 50 * 1024;
|
|
35
|
-
var GREP_MAX_LINE_LENGTH = 500;
|
|
36
|
-
function splitLinesForCounting(content) {
|
|
37
|
-
if (content.length === 0) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
const lines = content.split(`
|
|
41
|
-
`);
|
|
42
|
-
if (content.endsWith(`
|
|
43
|
-
`)) {
|
|
44
|
-
lines.pop();
|
|
45
|
-
}
|
|
46
|
-
return lines;
|
|
47
|
-
}
|
|
48
|
-
function formatSize(bytes) {
|
|
49
|
-
if (bytes < 1024) {
|
|
50
|
-
return `${bytes}B`;
|
|
51
|
-
} else if (bytes < 1024 * 1024) {
|
|
52
|
-
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
53
|
-
} else {
|
|
54
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function truncateHead(content, options = {}) {
|
|
58
|
-
const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
|
|
59
|
-
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
60
|
-
const totalBytes = Buffer.byteLength(content, "utf-8");
|
|
61
|
-
const lines = splitLinesForCounting(content);
|
|
62
|
-
const totalLines = lines.length;
|
|
63
|
-
if (totalLines <= maxLines && totalBytes <= maxBytes) {
|
|
64
|
-
return {
|
|
65
|
-
content,
|
|
66
|
-
truncated: false,
|
|
67
|
-
truncatedBy: null,
|
|
68
|
-
totalLines,
|
|
69
|
-
totalBytes,
|
|
70
|
-
outputLines: totalLines,
|
|
71
|
-
outputBytes: totalBytes,
|
|
72
|
-
lastLinePartial: false,
|
|
73
|
-
firstLineExceedsLimit: false,
|
|
74
|
-
maxLines,
|
|
75
|
-
maxBytes
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
const firstLineBytes = Buffer.byteLength(lines[0], "utf-8");
|
|
79
|
-
if (firstLineBytes > maxBytes) {
|
|
80
|
-
return {
|
|
81
|
-
content: "",
|
|
82
|
-
truncated: true,
|
|
83
|
-
truncatedBy: "bytes",
|
|
84
|
-
totalLines,
|
|
85
|
-
totalBytes,
|
|
86
|
-
outputLines: 0,
|
|
87
|
-
outputBytes: 0,
|
|
88
|
-
lastLinePartial: false,
|
|
89
|
-
firstLineExceedsLimit: true,
|
|
90
|
-
maxLines,
|
|
91
|
-
maxBytes
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
const outputLinesArr = [];
|
|
95
|
-
let outputBytesCount = 0;
|
|
96
|
-
let truncatedBy = "lines";
|
|
97
|
-
for (let i = 0;i < lines.length && i < maxLines; i++) {
|
|
98
|
-
const line = lines[i];
|
|
99
|
-
const lineBytes = Buffer.byteLength(line, "utf-8") + (i > 0 ? 1 : 0);
|
|
100
|
-
if (outputBytesCount + lineBytes > maxBytes) {
|
|
101
|
-
truncatedBy = "bytes";
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
outputLinesArr.push(line);
|
|
105
|
-
outputBytesCount += lineBytes;
|
|
106
|
-
}
|
|
107
|
-
if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
|
|
108
|
-
truncatedBy = "lines";
|
|
109
|
-
}
|
|
110
|
-
const outputContent = outputLinesArr.join(`
|
|
111
|
-
`);
|
|
112
|
-
const finalOutputBytes = Buffer.byteLength(outputContent, "utf-8");
|
|
113
|
-
return {
|
|
114
|
-
content: outputContent,
|
|
115
|
-
truncated: true,
|
|
116
|
-
truncatedBy,
|
|
117
|
-
totalLines,
|
|
118
|
-
totalBytes,
|
|
119
|
-
outputLines: outputLinesArr.length,
|
|
120
|
-
outputBytes: finalOutputBytes,
|
|
121
|
-
lastLinePartial: false,
|
|
122
|
-
firstLineExceedsLimit: false,
|
|
123
|
-
maxLines,
|
|
124
|
-
maxBytes
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function truncateTail(content, options = {}) {
|
|
128
|
-
const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
|
|
129
|
-
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
130
|
-
const totalBytes = Buffer.byteLength(content, "utf-8");
|
|
131
|
-
const lines = splitLinesForCounting(content);
|
|
132
|
-
const totalLines = lines.length;
|
|
133
|
-
if (totalLines <= maxLines && totalBytes <= maxBytes) {
|
|
134
|
-
return {
|
|
135
|
-
content,
|
|
136
|
-
truncated: false,
|
|
137
|
-
truncatedBy: null,
|
|
138
|
-
totalLines,
|
|
139
|
-
totalBytes,
|
|
140
|
-
outputLines: totalLines,
|
|
141
|
-
outputBytes: totalBytes,
|
|
142
|
-
lastLinePartial: false,
|
|
143
|
-
firstLineExceedsLimit: false,
|
|
144
|
-
maxLines,
|
|
145
|
-
maxBytes
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
const outputLinesArr = [];
|
|
149
|
-
let outputBytesCount = 0;
|
|
150
|
-
let truncatedBy = "lines";
|
|
151
|
-
let lastLinePartial = false;
|
|
152
|
-
for (let i = lines.length - 1;i >= 0 && outputLinesArr.length < maxLines; i--) {
|
|
153
|
-
const line = lines[i];
|
|
154
|
-
const lineBytes = Buffer.byteLength(line, "utf-8") + (outputLinesArr.length > 0 ? 1 : 0);
|
|
155
|
-
if (outputBytesCount + lineBytes > maxBytes) {
|
|
156
|
-
truncatedBy = "bytes";
|
|
157
|
-
if (outputLinesArr.length === 0) {
|
|
158
|
-
const truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);
|
|
159
|
-
outputLinesArr.unshift(truncatedLine);
|
|
160
|
-
outputBytesCount = Buffer.byteLength(truncatedLine, "utf-8");
|
|
161
|
-
lastLinePartial = true;
|
|
162
|
-
}
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
outputLinesArr.unshift(line);
|
|
166
|
-
outputBytesCount += lineBytes;
|
|
167
|
-
}
|
|
168
|
-
if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
|
|
169
|
-
truncatedBy = "lines";
|
|
170
|
-
}
|
|
171
|
-
const outputContent = outputLinesArr.join(`
|
|
172
|
-
`);
|
|
173
|
-
const finalOutputBytes = Buffer.byteLength(outputContent, "utf-8");
|
|
174
|
-
return {
|
|
175
|
-
content: outputContent,
|
|
176
|
-
truncated: true,
|
|
177
|
-
truncatedBy,
|
|
178
|
-
totalLines,
|
|
179
|
-
totalBytes,
|
|
180
|
-
outputLines: outputLinesArr.length,
|
|
181
|
-
outputBytes: finalOutputBytes,
|
|
182
|
-
lastLinePartial,
|
|
183
|
-
firstLineExceedsLimit: false,
|
|
184
|
-
maxLines,
|
|
185
|
-
maxBytes
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function truncateStringToBytesFromEnd(str, maxBytes) {
|
|
189
|
-
const buf = Buffer.from(str, "utf-8");
|
|
190
|
-
if (buf.length <= maxBytes) {
|
|
191
|
-
return str;
|
|
192
|
-
}
|
|
193
|
-
let start = buf.length - maxBytes;
|
|
194
|
-
while (start < buf.length && (buf[start] & 192) === 128) {
|
|
195
|
-
start++;
|
|
196
|
-
}
|
|
197
|
-
return buf.slice(start).toString("utf-8");
|
|
198
|
-
}
|
|
199
|
-
function truncateLine(line, maxChars = GREP_MAX_LINE_LENGTH) {
|
|
200
|
-
if (line.length <= maxChars) {
|
|
201
|
-
return { text: line, wasTruncated: false };
|
|
202
|
-
}
|
|
203
|
-
return { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };
|
|
204
|
-
}
|
|
205
|
-
function truncateMiddle(content, maxBytes) {
|
|
206
|
-
const buf = Buffer.from(content, "utf-8");
|
|
207
|
-
const totalLines = splitLinesForCounting(content).length;
|
|
208
|
-
if (buf.length <= maxBytes) {
|
|
209
|
-
return { content, truncated: false, removedChars: 0, totalBytes: buf.length, totalLines };
|
|
210
|
-
}
|
|
211
|
-
const isBoundary = (index) => index >= buf.length || (buf[index] & 192) !== 128;
|
|
212
|
-
let headEnd = Math.floor(maxBytes / 2);
|
|
213
|
-
while (headEnd > 0 && !isBoundary(headEnd))
|
|
214
|
-
headEnd--;
|
|
215
|
-
let tailStart = buf.length - (maxBytes - Math.floor(maxBytes / 2));
|
|
216
|
-
while (tailStart < buf.length && !isBoundary(tailStart))
|
|
217
|
-
tailStart++;
|
|
218
|
-
const head = buf.subarray(0, headEnd).toString("utf-8");
|
|
219
|
-
const tail = buf.subarray(tailStart).toString("utf-8");
|
|
220
|
-
const removedChars = Array.from(buf.subarray(headEnd, tailStart).toString("utf-8")).length;
|
|
221
|
-
return {
|
|
222
|
-
content: `${head}…${removedChars} chars truncated…${tail}`,
|
|
223
|
-
truncated: true,
|
|
224
|
-
removedChars,
|
|
225
|
-
totalBytes: buf.length,
|
|
226
|
-
totalLines
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.js
|
|
231
|
-
import { existsSync } from "node:fs";
|
|
232
|
-
import { delimiter, join as join2 } from "node:path";
|
|
233
|
-
import { spawn, spawnSync } from "child_process";
|
|
234
|
-
function isLegacyWslBashPath(path) {
|
|
235
|
-
const normalized = path.replace(/\//g, "\\").toLowerCase();
|
|
236
|
-
return /^[a-z]:\\windows\\(?:system32|sysnative)\\bash\.exe$/.test(normalized);
|
|
237
|
-
}
|
|
238
|
-
function getBashShellConfig(shell) {
|
|
239
|
-
return isLegacyWslBashPath(shell) ? { shell, args: ["-s"], commandTransport: "stdin" } : { shell, args: ["-c"] };
|
|
240
|
-
}
|
|
241
|
-
function findExecutableOnPath(executable) {
|
|
242
|
-
if (process.platform === "win32") {
|
|
243
|
-
try {
|
|
244
|
-
const result = spawnSync("where", [executable], {
|
|
245
|
-
encoding: "utf-8",
|
|
246
|
-
timeout: 5000,
|
|
247
|
-
windowsHide: true
|
|
248
|
-
});
|
|
249
|
-
if (result.status === 0 && result.stdout) {
|
|
250
|
-
const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
|
|
251
|
-
if (firstMatch && existsSync(firstMatch)) {
|
|
252
|
-
return firstMatch;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
} catch {}
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
try {
|
|
259
|
-
const result = spawnSync("which", [executable], { encoding: "utf-8", timeout: 5000 });
|
|
260
|
-
if (result.status === 0 && result.stdout) {
|
|
261
|
-
const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
|
|
262
|
-
if (firstMatch) {
|
|
263
|
-
return firstMatch;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
} catch {}
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
function getShellConfig(customShellPath) {
|
|
270
|
-
if (customShellPath) {
|
|
271
|
-
if (existsSync(customShellPath)) {
|
|
272
|
-
return getBashShellConfig(customShellPath);
|
|
273
|
-
}
|
|
274
|
-
throw new Error(`Custom shell path not found: ${customShellPath}`);
|
|
275
|
-
}
|
|
276
|
-
if (process.platform === "win32") {
|
|
277
|
-
const paths = [];
|
|
278
|
-
const programFiles = process.env.ProgramFiles;
|
|
279
|
-
if (programFiles) {
|
|
280
|
-
paths.push(`${programFiles}\\Git\\bin\\bash.exe`);
|
|
281
|
-
}
|
|
282
|
-
const programFilesX86 = process.env["ProgramFiles(x86)"];
|
|
283
|
-
if (programFilesX86) {
|
|
284
|
-
paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
|
|
285
|
-
}
|
|
286
|
-
for (const path of paths) {
|
|
287
|
-
if (existsSync(path)) {
|
|
288
|
-
return getBashShellConfig(path);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
const bashOnPath2 = findExecutableOnPath("bash.exe");
|
|
292
|
-
if (bashOnPath2) {
|
|
293
|
-
return getBashShellConfig(bashOnPath2);
|
|
294
|
-
}
|
|
295
|
-
throw new Error(`No bash shell found. Options:
|
|
296
|
-
` + ` 1. Install Git for Windows: https://git-scm.com/download/win
|
|
297
|
-
` + ` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)
|
|
298
|
-
` + ` 3. Set shellPath in settings.json
|
|
299
|
-
|
|
300
|
-
` + `Searched Git Bash in:
|
|
301
|
-
${paths.map((p) => ` ${p}`).join(`
|
|
302
|
-
`)}`);
|
|
303
|
-
}
|
|
304
|
-
if (existsSync("/bin/bash")) {
|
|
305
|
-
return getBashShellConfig("/bin/bash");
|
|
306
|
-
}
|
|
307
|
-
const bashOnPath = findExecutableOnPath("bash");
|
|
308
|
-
if (bashOnPath) {
|
|
309
|
-
return getBashShellConfig(bashOnPath);
|
|
310
|
-
}
|
|
311
|
-
return { shell: "sh", args: ["-c"] };
|
|
312
|
-
}
|
|
313
|
-
var POWERSHELL_ARGS = ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command"];
|
|
314
|
-
function getPowerShellConfig() {
|
|
315
|
-
if (process.platform !== "win32") {
|
|
316
|
-
throw new Error("The powershell tool is only available on Windows.");
|
|
317
|
-
}
|
|
318
|
-
const shell = findExecutableOnPath("pwsh.exe") ?? findExecutableOnPath("powershell.exe");
|
|
319
|
-
if (!shell) {
|
|
320
|
-
throw new Error("No PowerShell executable found. Install PowerShell or add powershell.exe/pwsh.exe to PATH.");
|
|
321
|
-
}
|
|
322
|
-
return { shell, args: [...POWERSHELL_ARGS] };
|
|
323
|
-
}
|
|
324
|
-
function getShellEnv() {
|
|
325
|
-
const binDir = getBinDir();
|
|
326
|
-
const pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === "path") ?? "PATH";
|
|
327
|
-
const currentPath = process.env[pathKey] ?? "";
|
|
328
|
-
const pathEntries = currentPath.split(delimiter).filter(Boolean);
|
|
329
|
-
const hasBinDir = pathEntries.includes(binDir);
|
|
330
|
-
const updatedPath = hasBinDir ? currentPath : [binDir, currentPath].filter(Boolean).join(delimiter);
|
|
331
|
-
return {
|
|
332
|
-
...process.env,
|
|
333
|
-
[pathKey]: updatedPath
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
function sanitizeBinaryOutput(str) {
|
|
337
|
-
return str.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFF9-\uFFFB]/g, "");
|
|
338
|
-
}
|
|
339
|
-
var trackedDetachedChildPids = new Set;
|
|
340
|
-
function trackDetachedChildPid(pid) {
|
|
341
|
-
trackedDetachedChildPids.add(pid);
|
|
342
|
-
}
|
|
343
|
-
function untrackDetachedChildPid(pid) {
|
|
344
|
-
trackedDetachedChildPids.delete(pid);
|
|
345
|
-
}
|
|
346
|
-
function killTrackedDetachedChildren() {
|
|
347
|
-
for (const pid of trackedDetachedChildPids) {
|
|
348
|
-
killProcessTree(pid);
|
|
349
|
-
}
|
|
350
|
-
trackedDetachedChildPids.clear();
|
|
351
|
-
}
|
|
352
|
-
function killProcessTree(pid) {
|
|
353
|
-
if (process.platform === "win32") {
|
|
354
|
-
try {
|
|
355
|
-
const child = spawn(join2(process.env.SystemRoot ?? "C:\\Windows", "System32", "taskkill.exe"), ["/F", "/T", "/PID", String(pid)], {
|
|
356
|
-
stdio: "ignore",
|
|
357
|
-
detached: true,
|
|
358
|
-
windowsHide: true
|
|
359
|
-
});
|
|
360
|
-
child.once("error", () => {});
|
|
361
|
-
} catch {}
|
|
362
|
-
} else {
|
|
363
|
-
try {
|
|
364
|
-
process.kill(-pid, "SIGKILL");
|
|
365
|
-
} catch {
|
|
366
|
-
try {
|
|
367
|
-
process.kill(pid, "SIGKILL");
|
|
368
|
-
} catch {}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js
|
|
374
|
-
function truncateToVisualLines(text, maxVisualLines, width, paddingX = 0, keep = "end") {
|
|
375
|
-
if (!text) {
|
|
376
|
-
return { visualLines: [], skippedCount: 0 };
|
|
377
|
-
}
|
|
378
|
-
const tempText = new Text(text, paddingX, 0);
|
|
379
|
-
const allVisualLines = tempText.render(width);
|
|
380
|
-
if (allVisualLines.length <= maxVisualLines) {
|
|
381
|
-
return { visualLines: allVisualLines, skippedCount: 0 };
|
|
382
|
-
}
|
|
383
|
-
const truncatedLines = keep === "start" ? allVisualLines.slice(0, maxVisualLines) : allVisualLines.slice(-maxVisualLines);
|
|
384
|
-
const skippedCount = allVisualLines.length - maxVisualLines;
|
|
385
|
-
return { visualLines: truncatedLines, skippedCount };
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
class VisualLinePreview {
|
|
389
|
-
options;
|
|
390
|
-
cachedWidth;
|
|
391
|
-
cachedLines;
|
|
392
|
-
constructor(options) {
|
|
393
|
-
this.options = options;
|
|
394
|
-
}
|
|
395
|
-
render(width) {
|
|
396
|
-
if (this.cachedLines === undefined || this.cachedWidth !== width) {
|
|
397
|
-
const { text, maxVisualLines, keep, formatHint } = this.options;
|
|
398
|
-
const preview = truncateToVisualLines(text, maxVisualLines, width, 0, keep);
|
|
399
|
-
const lines = preview.visualLines;
|
|
400
|
-
if (preview.skippedCount > 0) {
|
|
401
|
-
const hint = truncateToWidth(formatHint(preview.skippedCount), width, "...");
|
|
402
|
-
this.cachedLines = keep === "start" ? [...lines, hint] : [hint, ...lines];
|
|
403
|
-
} else {
|
|
404
|
-
this.cachedLines = lines;
|
|
405
|
-
}
|
|
406
|
-
this.cachedWidth = width;
|
|
407
|
-
}
|
|
408
|
-
return this.cachedLines;
|
|
409
|
-
}
|
|
410
|
-
invalidate() {
|
|
411
|
-
this.cachedWidth = undefined;
|
|
412
|
-
this.cachedLines = undefined;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.js
|
|
417
|
-
var ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
418
|
-
var OSC_START = "\\u001B\\]";
|
|
419
|
-
var CSI_START = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?";
|
|
420
|
-
var CSI_FINAL = "[\\dA-PR-TZcf-nq-uy=><~]";
|
|
421
|
-
var ansiRegex = new RegExp(`(?:${OSC_START}[\\s\\S]*?${ST})|${CSI_START}${CSI_FINAL}`, "g");
|
|
422
|
-
var unfinishedAnsiAtEndRegex = new RegExp(`(?:${OSC_START}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${CSI_START})$`);
|
|
423
|
-
var MAX_PENDING_ANSI_LENGTH = 256;
|
|
424
|
-
function splitIncompleteAnsiSuffix(value) {
|
|
425
|
-
if (!value.includes("\x1B") && !value.includes("")) {
|
|
426
|
-
return { complete: value, pending: "" };
|
|
427
|
-
}
|
|
428
|
-
const windowStart = Math.max(0, value.length - MAX_PENDING_ANSI_LENGTH);
|
|
429
|
-
const match = unfinishedAnsiAtEndRegex.exec(value.slice(windowStart));
|
|
430
|
-
if (!match) {
|
|
431
|
-
return { complete: value, pending: "" };
|
|
432
|
-
}
|
|
433
|
-
const splitAt = windowStart + match.index;
|
|
434
|
-
return { complete: value.slice(0, splitAt), pending: value.slice(splitAt) };
|
|
435
|
-
}
|
|
436
|
-
function stripAnsi(value) {
|
|
437
|
-
if (typeof value !== "string") {
|
|
438
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof value}\``);
|
|
439
|
-
}
|
|
440
|
-
if (!value.includes("\x1B") && !value.includes("")) {
|
|
441
|
-
return value;
|
|
442
|
-
}
|
|
443
|
-
return value.replace(ansiRegex, "");
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.js
|
|
447
|
-
import * as os from "node:os";
|
|
448
|
-
import { pathToFileURL } from "node:url";
|
|
449
|
-
function shortenPath(path) {
|
|
450
|
-
if (typeof path !== "string")
|
|
451
|
-
return "";
|
|
452
|
-
const home = os.homedir();
|
|
453
|
-
if (path.startsWith(home)) {
|
|
454
|
-
return `~${path.slice(home.length)}`;
|
|
455
|
-
}
|
|
456
|
-
return path;
|
|
457
|
-
}
|
|
458
|
-
function linkPath(styledText, rawPath, cwd) {
|
|
459
|
-
if (!getCapabilities().hyperlinks)
|
|
460
|
-
return styledText;
|
|
461
|
-
const absolutePath = resolvePath(rawPath, cwd);
|
|
462
|
-
return hyperlink(styledText, pathToFileURL(absolutePath).href);
|
|
463
|
-
}
|
|
464
|
-
function str(value) {
|
|
465
|
-
if (typeof value === "string")
|
|
466
|
-
return value;
|
|
467
|
-
if (value == null)
|
|
468
|
-
return "";
|
|
469
|
-
return null;
|
|
470
|
-
}
|
|
471
|
-
function replaceTabs(text) {
|
|
472
|
-
return text.replace(/\t/g, " ");
|
|
473
|
-
}
|
|
474
|
-
function normalizeDisplayText(text) {
|
|
475
|
-
return text.replace(/\r/g, "");
|
|
476
|
-
}
|
|
477
|
-
function getTextOutput(result, showImages) {
|
|
478
|
-
if (!result)
|
|
479
|
-
return "";
|
|
480
|
-
const textBlocks = result.content.filter((c) => c.type === "text");
|
|
481
|
-
const imageBlocks = result.content.filter((c) => c.type === "image");
|
|
482
|
-
let output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || "")).replace(/\r/g, "")).join(`
|
|
483
|
-
`);
|
|
484
|
-
const caps = getCapabilities();
|
|
485
|
-
if (imageBlocks.length > 0 && (!caps.images || !showImages)) {
|
|
486
|
-
const imageIndicators = imageBlocks.map((img) => {
|
|
487
|
-
const mimeType = img.mimeType ?? "image/unknown";
|
|
488
|
-
const dims = img.data && img.mimeType ? getImageDimensions(img.data, img.mimeType) ?? undefined : undefined;
|
|
489
|
-
return imageFallback(mimeType, dims);
|
|
490
|
-
}).join(`
|
|
491
|
-
`);
|
|
492
|
-
output = output ? `${output}
|
|
493
|
-
${imageIndicators}` : imageIndicators;
|
|
494
|
-
}
|
|
495
|
-
return output;
|
|
496
|
-
}
|
|
497
|
-
var COLLAPSED_ARGS_CHARS = 100;
|
|
498
|
-
function formatToolCallWithArgs(title, args, theme, expanded) {
|
|
499
|
-
const header = theme.fg("toolTitle", theme.bold(title));
|
|
500
|
-
if (args == null)
|
|
501
|
-
return header;
|
|
502
|
-
const entries = typeof args === "object" && !Array.isArray(args) ? Object.entries(args) : [["args", args]];
|
|
503
|
-
if (entries.length === 0)
|
|
504
|
-
return header;
|
|
505
|
-
if (expanded) {
|
|
506
|
-
const lines = entries.map(([key, value]) => {
|
|
507
|
-
const text = typeof value === "string" ? value : JSON.stringify(value, null, 2) ?? String(value);
|
|
508
|
-
return ` ${key}: ${replaceTabs(text).replace(/\r/g, "").split(`
|
|
509
|
-
`).join(`
|
|
510
|
-
`)}`;
|
|
511
|
-
});
|
|
512
|
-
return `${header}
|
|
513
|
-
${theme.fg("muted", lines.join(`
|
|
514
|
-
`))}`;
|
|
515
|
-
}
|
|
516
|
-
const pairs = entries.map(([key, value]) => `${key}=${JSON.stringify(value) ?? String(value)}`).join(" ");
|
|
517
|
-
const preview = pairs.length > COLLAPSED_ARGS_CHARS ? `${pairs.slice(0, COLLAPSED_ARGS_CHARS - 3)}...` : pairs;
|
|
518
|
-
return `${header} ${theme.fg("muted", preview)}`;
|
|
519
|
-
}
|
|
520
|
-
function invalidArgText(theme) {
|
|
521
|
-
return theme.fg("error", "[invalid arg]");
|
|
522
|
-
}
|
|
523
|
-
function renderToolPath(rawPath, theme, cwd, options) {
|
|
524
|
-
if (rawPath === null)
|
|
525
|
-
return invalidArgText(theme);
|
|
526
|
-
const value = rawPath || options?.emptyFallback;
|
|
527
|
-
if (!value)
|
|
528
|
-
return theme.fg("toolOutput", "...");
|
|
529
|
-
return linkPath(theme.fg("accent", shortenPath(value)), value, cwd);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
export { splitIncompleteAnsiSuffix, stripAnsi, writeOutputFile, createOutputFileStream, getShellConfig, getPowerShellConfig, getShellEnv, sanitizeBinaryOutput, trackDetachedChildPid, untrackDetachedChildPid, killTrackedDetachedChildren, killProcessTree, DEFAULT_MAX_LINES, DEFAULT_MAX_BYTES, GREP_MAX_LINE_LENGTH, formatSize, truncateHead, truncateTail, truncateLine, truncateMiddle, truncateToVisualLines, VisualLinePreview, shortenPath, str, replaceTabs, normalizeDisplayText, getTextOutput, formatToolCallWithArgs, invalidArgText, renderToolPath };
|