@garuda-agent/garuda 0.0.1 → 0.15.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/CHANGELOG.md +77 -0
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +1097 -0
- package/SECURITY.md +32 -0
- package/dist/acpCommand-FZ2P5JFO.js +153 -0
- package/dist/anthropic-NQDBCHJU.js +327 -0
- package/dist/chunk-23FXBNBB.js +46 -0
- package/dist/chunk-2S62ZNTC.js +320 -0
- package/dist/chunk-2TAXSFWN.js +49 -0
- package/dist/chunk-36GQIVGT.js +526 -0
- package/dist/chunk-3CEPHS4C.js +231 -0
- package/dist/chunk-3NJNVZTK.js +123 -0
- package/dist/chunk-42DSA4EA.js +116 -0
- package/dist/chunk-4JSUUDFQ.js +118 -0
- package/dist/chunk-4P26OKTP.js +100 -0
- package/dist/chunk-5DEWP3YX.js +139 -0
- package/dist/chunk-A2QAIRQL.js +45 -0
- package/dist/chunk-ATW7BNIG.js +31 -0
- package/dist/chunk-B25VL4RU.js +242 -0
- package/dist/chunk-EPKWDCV4.js +9 -0
- package/dist/chunk-EU7PA45O.js +324 -0
- package/dist/chunk-FARS4R67.js +206 -0
- package/dist/chunk-G2AX7MGS.js +36 -0
- package/dist/chunk-HRGX53VC.js +173 -0
- package/dist/chunk-HUIK3WXO.js +234 -0
- package/dist/chunk-INRZR772.js +73 -0
- package/dist/chunk-K3SIUOAG.js +138 -0
- package/dist/chunk-K7KK7U44.js +9358 -0
- package/dist/chunk-KKB5W47S.js +231 -0
- package/dist/chunk-N4I6YS3E.js +73 -0
- package/dist/chunk-NXJ4XLB5.js +19 -0
- package/dist/chunk-OUCV3FCT.js +205 -0
- package/dist/chunk-PQNT34LY.js +1247 -0
- package/dist/chunk-PZS3V6P3.js +46 -0
- package/dist/chunk-S77XDSD4.js +157 -0
- package/dist/chunk-SI2QJYCR.js +1341 -0
- package/dist/chunk-WMOLXTBU.js +61 -0
- package/dist/chunk-YFQJXRIJ.js +193 -0
- package/dist/chunk-YQTGMCU6.js +111 -0
- package/dist/chunk-ZAE25JM2.js +158 -0
- package/dist/cli/index.js +1203 -0
- package/dist/create-N4I7TIZE.js +223 -0
- package/dist/deadline-F5RJJ2QW.js +86 -0
- package/dist/detect-LARDSLLZ.js +10 -0
- package/dist/evalCommand-3SSFMZQD.js +2798 -0
- package/dist/export-HN3CT7AV.js +158 -0
- package/dist/inkChat-34BTFG2K.js +1193 -0
- package/dist/install-VRPBZY5H.js +17 -0
- package/dist/job-3NYDMP2M.js +31 -0
- package/dist/jobCommand-XJ5GULS5.js +30 -0
- package/dist/launchd-QVHQ3VNN.js +40 -0
- package/dist/lspCommand-XNTBHXLA.js +99 -0
- package/dist/manager-4PMSXT47.js +14 -0
- package/dist/manager-CSI76AWF.js +847 -0
- package/dist/nightCommand-CR6ZHYGP.js +247 -0
- package/dist/oauth-W6OK6XXO.js +23 -0
- package/dist/openaiCompatible-CJWVJP5M.js +501 -0
- package/dist/policy-EJPLEEXP.js +31 -0
- package/dist/proxy-XJAHCZB2.js +192 -0
- package/dist/remove-LE7Q7K46.js +59 -0
- package/dist/run-ML6GSPN4.js +888 -0
- package/dist/server-R3GNIC33.js +676 -0
- package/dist/servers-6YDGWOZ6.js +24 -0
- package/dist/text-J2GD647J.js +11 -0
- package/package.json +84 -3
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
summariseCall,
|
|
4
|
+
summariseResult
|
|
5
|
+
} from "./chunk-FARS4R67.js";
|
|
6
|
+
import {
|
|
7
|
+
serverCallText,
|
|
8
|
+
serverResultSummary
|
|
9
|
+
} from "./chunk-A2QAIRQL.js";
|
|
10
|
+
import {
|
|
11
|
+
PathOutsideRootError,
|
|
12
|
+
displayPath,
|
|
13
|
+
resolveInRoot
|
|
14
|
+
} from "./chunk-WMOLXTBU.js";
|
|
15
|
+
|
|
16
|
+
// src/cli/export.ts
|
|
17
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
18
|
+
import { dirname } from "path";
|
|
19
|
+
function sessionMarkdown(records, sessionId) {
|
|
20
|
+
const out = [];
|
|
21
|
+
const start = records.find((r) => r.type === "start");
|
|
22
|
+
out.push(`# Garuda session ${sessionId}`, "");
|
|
23
|
+
if (start?.type === "start") {
|
|
24
|
+
out.push(`- Folder: ${start.root}`, `- Model: ${start.model}`, `- Started: ${when(start.t)}`);
|
|
25
|
+
}
|
|
26
|
+
out.push("");
|
|
27
|
+
const calls = /* @__PURE__ */ new Map();
|
|
28
|
+
const turns = [];
|
|
29
|
+
const undone = [];
|
|
30
|
+
let answering = false;
|
|
31
|
+
for (const record of records) {
|
|
32
|
+
switch (record.type) {
|
|
33
|
+
case "user": {
|
|
34
|
+
const [prompt, ...rest] = record.message.content;
|
|
35
|
+
out.push(`## You \xB7 ${when(record.t)}`, "", prompt?.type === "text" ? prompt.text : "", "");
|
|
36
|
+
for (const block of rest) {
|
|
37
|
+
if (block.type !== "text") continue;
|
|
38
|
+
const ran = /^(?:<garuda_note>)?The user ran a command in the chat \(not you\):\n\$ (.*)/.exec(
|
|
39
|
+
block.text
|
|
40
|
+
);
|
|
41
|
+
const file = /^The user attached (?:the folder )?(\S+?)(?: \(its entries\))?:\n/.exec(
|
|
42
|
+
block.text
|
|
43
|
+
);
|
|
44
|
+
if (ran !== null) out.push(`> Ran ${code(ran[1] ?? "")} before this message.`, "");
|
|
45
|
+
else if (file !== null) out.push(`> Attached ${file[1]}`, "");
|
|
46
|
+
}
|
|
47
|
+
answering = false;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "assistant":
|
|
51
|
+
if (!answering) out.push("## Garuda", "");
|
|
52
|
+
answering = true;
|
|
53
|
+
for (const block of record.response.content) {
|
|
54
|
+
if (block.type === "text" && block.text.trim() !== "") out.push(block.text.trim(), "");
|
|
55
|
+
if (block.type === "tool_use") calls.set(block.id, block);
|
|
56
|
+
if (block.type === "server_tool_result") {
|
|
57
|
+
const call = record.response.content.find(
|
|
58
|
+
(b) => b.type === "server_tool_use" && b.id === block.toolUseId
|
|
59
|
+
);
|
|
60
|
+
const query = call?.type === "server_tool_use" ? ` ${serverCallText(call)}` : "";
|
|
61
|
+
out.push(
|
|
62
|
+
`- ${code(`${block.name} (Claude)${query}`)} \u2192 ${serverResultSummary(block)}`,
|
|
63
|
+
...block.results.map((r) => ` - [${r.title.replace(/[[\]]/g, "")}](${r.url})`),
|
|
64
|
+
""
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case "tool_results": {
|
|
70
|
+
const lines = [];
|
|
71
|
+
for (const block of record.message.content) {
|
|
72
|
+
if (block.type !== "tool_result") continue;
|
|
73
|
+
const call = calls.get(block.toolUseId);
|
|
74
|
+
if (call === void 0) continue;
|
|
75
|
+
const result = summariseResult(call, { content: block.content, isError: block.isError });
|
|
76
|
+
const what = code([call.name, summariseCall(call)].filter((p) => p !== "").join(" "));
|
|
77
|
+
lines.push(`- ${what} \u2192 ${block.isError ? `failed: ${result}` : result}`);
|
|
78
|
+
}
|
|
79
|
+
if (lines.length > 0) out.push(...lines, "");
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "snapshot":
|
|
83
|
+
turns.push(record.prompt);
|
|
84
|
+
break;
|
|
85
|
+
case "undo": {
|
|
86
|
+
const prompt = turns.pop();
|
|
87
|
+
if (prompt !== void 0) undone.push(prompt);
|
|
88
|
+
out.push(`_/undo: the turn "${prompt ?? "?"}" was taken back._`, "");
|
|
89
|
+
answering = false;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "redo": {
|
|
93
|
+
const prompt = undone.pop();
|
|
94
|
+
if (prompt !== void 0) turns.push(prompt);
|
|
95
|
+
out.push(`_/redo: the turn "${prompt ?? "?"}" came back._`, "");
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case "compaction":
|
|
99
|
+
out.push("_The conversation was compacted here to fit the context window._", "");
|
|
100
|
+
break;
|
|
101
|
+
case "model":
|
|
102
|
+
out.push(`_The model changed to ${record.model}._`, "");
|
|
103
|
+
break;
|
|
104
|
+
case "continue":
|
|
105
|
+
out.push(
|
|
106
|
+
`_The response hit the output limit; Garuda asked the model to go on (${record.maxTokens} tokens)._`,
|
|
107
|
+
""
|
|
108
|
+
);
|
|
109
|
+
break;
|
|
110
|
+
case "end":
|
|
111
|
+
if (record.stopReason !== "done") out.push(`_The turn stopped: ${record.stopReason}._`, "");
|
|
112
|
+
break;
|
|
113
|
+
case "start":
|
|
114
|
+
case "resume":
|
|
115
|
+
case "title":
|
|
116
|
+
case "thinking":
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return `${out.join("\n").replace(/\n{3,}/g, "\n\n").trim()}
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
function code(text) {
|
|
124
|
+
return text.includes("`") ? `\`\` ${text} \`\`` : `\`${text}\``;
|
|
125
|
+
}
|
|
126
|
+
function when(iso) {
|
|
127
|
+
const d = new Date(iso);
|
|
128
|
+
if (Number.isNaN(d.getTime())) return iso;
|
|
129
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
130
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
131
|
+
}
|
|
132
|
+
async function writeExport(root, sessionId, markdown, file = "") {
|
|
133
|
+
const name = file === "" ? `garuda-${sessionId}.md` : file;
|
|
134
|
+
let absolute;
|
|
135
|
+
try {
|
|
136
|
+
absolute = await resolveInRoot(root, name);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof PathOutsideRootError) {
|
|
139
|
+
return { problem: `${name} is outside the working folder.` };
|
|
140
|
+
}
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
await mkdir(dirname(absolute), { recursive: true });
|
|
145
|
+
await writeFile(absolute, markdown, { flag: "wx" });
|
|
146
|
+
} catch (error) {
|
|
147
|
+
const code2 = error.code;
|
|
148
|
+
return {
|
|
149
|
+
problem: code2 === "EEXIST" ? `${displayPath(root, absolute)} already exists. Give another name: /export <file>.` : `Cannot write ${displayPath(root, absolute)}: ${error.message}`
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return { path: displayPath(root, absolute) };
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
sessionMarkdown,
|
|
156
|
+
writeExport
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=export-HN3CT7AV.js.map
|