@agent-commons/cli 0.1.17 → 0.1.18
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/bin.js +214 -87
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -106,7 +106,7 @@ var sym = {
|
|
|
106
106
|
bullet: import_chalk.default.dim("\u2022"),
|
|
107
107
|
dot: import_chalk.default.dim("\xB7")
|
|
108
108
|
};
|
|
109
|
-
function banner(version = "0.1.
|
|
109
|
+
function banner(version = "0.1.18") {
|
|
110
110
|
const line = import_chalk.default.cyan(" \u2500".padEnd(2) + "\u2500".repeat(44));
|
|
111
111
|
console.log("");
|
|
112
112
|
console.log(line);
|
|
@@ -1184,73 +1184,7 @@ ${sym.fail} ${c.error(event.message ?? event.type)}`);
|
|
|
1184
1184
|
|
|
1185
1185
|
// src/commands/run.ts
|
|
1186
1186
|
var import_commander7 = require("commander");
|
|
1187
|
-
function runCommand() {
|
|
1188
|
-
return new import_commander7.Command("run").description("Send a single prompt to an agent and stream the response").argument("<prompt>", "Prompt text to send").option("--agent <agentId>", "Agent ID").option("--session <sessionId>", "Session ID").option("--no-stream", "Disable streaming (wait for full response)").option("--json", "Output raw event stream as JSON lines").action(async (prompt2, opts) => {
|
|
1189
|
-
const cfg = loadConfig();
|
|
1190
|
-
const agentId = opts.agent ?? cfg.defaultAgentId;
|
|
1191
|
-
if (!agentId) {
|
|
1192
|
-
console.error(c.error("Specify --agent <agentId> or set defaultAgentId with `agc config set defaultAgentId <id>`"));
|
|
1193
|
-
process.exit(1);
|
|
1194
|
-
}
|
|
1195
|
-
const params = {
|
|
1196
|
-
agentId,
|
|
1197
|
-
sessionId: opts.session,
|
|
1198
|
-
messages: [{ role: "user", content: prompt2 }],
|
|
1199
|
-
...cfg.initiator && { initiatorId: cfg.initiator }
|
|
1200
|
-
};
|
|
1201
|
-
if (opts.noStream) {
|
|
1202
|
-
const spinner = spin("Running\u2026");
|
|
1203
|
-
try {
|
|
1204
|
-
const client = makeClient();
|
|
1205
|
-
const result = await client.run.once(params);
|
|
1206
|
-
spinner.stop();
|
|
1207
|
-
if (opts.json) return jsonOut(result);
|
|
1208
|
-
const text = result?.content ?? result?.text ?? result?.message ?? JSON.stringify(result);
|
|
1209
|
-
console.log(text);
|
|
1210
|
-
} catch (err) {
|
|
1211
|
-
spinner.stop();
|
|
1212
|
-
printError(err);
|
|
1213
|
-
process.exit(1);
|
|
1214
|
-
}
|
|
1215
|
-
return;
|
|
1216
|
-
}
|
|
1217
|
-
try {
|
|
1218
|
-
const client = makeClient();
|
|
1219
|
-
let hasOutput = false;
|
|
1220
|
-
for await (const event of client.agents.stream(params)) {
|
|
1221
|
-
if (opts.json) {
|
|
1222
|
-
console.log(JSON.stringify(event));
|
|
1223
|
-
continue;
|
|
1224
|
-
}
|
|
1225
|
-
if (event.type === "token") {
|
|
1226
|
-
process.stdout.write(event.content ?? "");
|
|
1227
|
-
hasOutput = true;
|
|
1228
|
-
} else if (event.type === "final") {
|
|
1229
|
-
if (hasOutput) process.stdout.write("\n");
|
|
1230
|
-
const e = event;
|
|
1231
|
-
if (e.content && !hasOutput) console.log(e.content);
|
|
1232
|
-
break;
|
|
1233
|
-
} else if (event.type === "error") {
|
|
1234
|
-
if (hasOutput) process.stdout.write("\n");
|
|
1235
|
-
console.error(`
|
|
1236
|
-
${sym.fail} ${c.error(event.message ?? "Error")}`);
|
|
1237
|
-
process.exit(1);
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
if (hasOutput && !opts.json) process.stdout.write("\n");
|
|
1241
|
-
} catch (err) {
|
|
1242
|
-
printError(err);
|
|
1243
|
-
process.exit(1);
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
// src/commands/chat.ts
|
|
1249
|
-
var import_commander8 = require("commander");
|
|
1250
1187
|
var readline3 = __toESM(require("readline"));
|
|
1251
|
-
var import_fs4 = require("fs");
|
|
1252
|
-
var import_path4 = require("path");
|
|
1253
|
-
var import_os3 = require("os");
|
|
1254
1188
|
|
|
1255
1189
|
// src/local-tools.ts
|
|
1256
1190
|
var import_fs3 = require("fs");
|
|
@@ -1310,7 +1244,7 @@ function readFileForContext(rootDir, filePath) {
|
|
|
1310
1244
|
return `[error reading file: ${err?.message}]`;
|
|
1311
1245
|
}
|
|
1312
1246
|
}
|
|
1313
|
-
function buildLocalToolsManifest(rootDir, snapshot, fileContextBlocks = []) {
|
|
1247
|
+
function buildLocalToolsManifest(rootDir, snapshot, fileContextBlocks = [], autoApprove = false) {
|
|
1314
1248
|
const fileSection = fileContextBlocks.length ? `
|
|
1315
1249
|
### File contents included in this turn
|
|
1316
1250
|
|
|
@@ -1336,7 +1270,8 @@ ${fileSection}
|
|
|
1336
1270
|
2. **Always show the actual output** returned by the tool in your response. Never say "I listed the files" without showing them. Report exactly what the tool returns.
|
|
1337
1271
|
3. **Never fabricate results.** Wait for the real tool output before responding.
|
|
1338
1272
|
4. **Sensitive paths are blocked** (.ssh, .gnupg, .aws, .env, credentials). Attempting to access them will return an error.
|
|
1339
|
-
5. **cli_write_file and cli_run_command require the user to confirm** before executing \u2014 you will see the result after they approve.
|
|
1273
|
+
5. ${autoApprove ? "**cli_write_file and cli_run_command execute immediately** \u2014 auto-approve is active, no user confirmation is required." : "**cli_write_file and cli_run_command require the user to confirm** before executing \u2014 you will see the result after they approve."}
|
|
1274
|
+
6. **Git commits must carry the agc co-author trailer.** Always include \`--trailer "Co-Authored-By: <AgentName> (agc) <agc-agent@users.noreply.github.com>"\` when running \`git commit\`. The CLI injects this automatically \u2014 do not omit it or pass \`--no-trailer\`.
|
|
1340
1275
|
|
|
1341
1276
|
### Available CLI tools
|
|
1342
1277
|
|
|
@@ -1408,6 +1343,13 @@ function extractToolCall(text) {
|
|
|
1408
1343
|
}
|
|
1409
1344
|
return null;
|
|
1410
1345
|
}
|
|
1346
|
+
function injectAgcTrailer(command, args, agentId, agentName) {
|
|
1347
|
+
if (command !== "git") return args;
|
|
1348
|
+
if (!args.some((a) => a === "commit")) return args;
|
|
1349
|
+
if (args.some((a) => a.includes("Co-Authored-By: agc"))) return args;
|
|
1350
|
+
const identity = agentName ? `${agentName} (agc)` : agentId ? `agc/${agentId}` : "agc agent";
|
|
1351
|
+
return [...args, "--trailer", `Co-Authored-By: ${identity} <agc-agent@users.noreply.github.com>`];
|
|
1352
|
+
}
|
|
1411
1353
|
function safePath(root, userPath) {
|
|
1412
1354
|
const abs = (0, import_path3.resolve)(root, userPath);
|
|
1413
1355
|
const rel = (0, import_path3.relative)(root, abs);
|
|
@@ -1434,6 +1376,7 @@ function assertNotSensitive(abs) {
|
|
|
1434
1376
|
}
|
|
1435
1377
|
}
|
|
1436
1378
|
async function confirm(message, config, permissionKey) {
|
|
1379
|
+
if (config.autoApprove) return true;
|
|
1437
1380
|
const cached = config.permissions.get(permissionKey);
|
|
1438
1381
|
if (cached === "allow") return true;
|
|
1439
1382
|
if (cached === "deny") return false;
|
|
@@ -1612,7 +1555,8 @@ async function toolRunCommand(args, cfg) {
|
|
|
1612
1555
|
if (!command || typeof command !== "string") throw new Error('run_command requires a "command" string');
|
|
1613
1556
|
if (!Array.isArray(cmdArgs)) throw new Error('"args" must be an array of strings');
|
|
1614
1557
|
const workDir = cwd ? safePath(cfg.rootDir, cwd) : cfg.rootDir;
|
|
1615
|
-
const
|
|
1558
|
+
const injectedArgs = injectAgcTrailer(command, cmdArgs, cfg.agentId, cfg.agentName);
|
|
1559
|
+
const preview = [command, ...injectedArgs].join(" ");
|
|
1616
1560
|
const timeoutMs = Math.min((typeof timeout_seconds === "number" ? timeout_seconds : 120) * 1e3, 3e5);
|
|
1617
1561
|
const ok = await confirm(
|
|
1618
1562
|
`Agent wants to run: \x1B[1m${preview}\x1B[0m
|
|
@@ -1623,7 +1567,7 @@ async function toolRunCommand(args, cfg) {
|
|
|
1623
1567
|
if (!ok) return "User denied command execution.";
|
|
1624
1568
|
if (interactive) {
|
|
1625
1569
|
return new Promise((resolve2) => {
|
|
1626
|
-
const child = (0, import_child_process2.spawn)(command,
|
|
1570
|
+
const child = (0, import_child_process2.spawn)(command, injectedArgs.map(String), { cwd: workDir, stdio: "inherit" });
|
|
1627
1571
|
const timer = setTimeout(() => {
|
|
1628
1572
|
child.kill();
|
|
1629
1573
|
resolve2(`(command timed out after ${timeoutMs / 1e3}s)`);
|
|
@@ -1639,7 +1583,7 @@ async function toolRunCommand(args, cfg) {
|
|
|
1639
1583
|
});
|
|
1640
1584
|
}
|
|
1641
1585
|
return new Promise((resolve2) => {
|
|
1642
|
-
(0, import_child_process2.execFile)(command,
|
|
1586
|
+
(0, import_child_process2.execFile)(command, injectedArgs.map(String), { cwd: workDir, timeout: timeoutMs, maxBuffer: 1024 * 1024 }, (err, stdout, stderr) => {
|
|
1643
1587
|
const out = [stdout, stderr].filter(Boolean).join("\n--- stderr ---\n");
|
|
1644
1588
|
if (err && !out) return resolve2(`Error: ${err.message}`);
|
|
1645
1589
|
resolve2(out || "(no output)");
|
|
@@ -1814,7 +1758,190 @@ async function runLocalTool(call, cfg) {
|
|
|
1814
1758
|
return result;
|
|
1815
1759
|
}
|
|
1816
1760
|
|
|
1761
|
+
// src/commands/run.ts
|
|
1762
|
+
function runCommand() {
|
|
1763
|
+
return new import_commander7.Command("run").description("Send a single prompt to an agent and stream the response").argument("<prompt>", "Prompt text to send").option("--agent <agentId>", "Agent ID").option("--session <sessionId>", "Resume an existing session by ID").option("--new-session", "Create a new session and print its ID for future use").option("--local", "Enable local file system access (with permission prompts)").option("-y, --yes", "Enable local file system access and auto-approve all operations").option("--no-stream", "Disable streaming (wait for full response)").option("--json", "Output raw event stream as JSON lines").action(async (prompt2, opts) => {
|
|
1764
|
+
const cfg = loadConfig();
|
|
1765
|
+
const agentId = opts.agent ?? cfg.defaultAgentId;
|
|
1766
|
+
if (!agentId) {
|
|
1767
|
+
console.error(c.error("Specify --agent <agentId> or set defaultAgentId with `agc config set defaultAgentId <id>`"));
|
|
1768
|
+
process.exit(1);
|
|
1769
|
+
}
|
|
1770
|
+
if (opts.session && opts.newSession) {
|
|
1771
|
+
console.error(c.error("Cannot use --session and --new-session together."));
|
|
1772
|
+
process.exit(1);
|
|
1773
|
+
}
|
|
1774
|
+
const client = makeClient();
|
|
1775
|
+
let sessionId = opts.session;
|
|
1776
|
+
if (opts.session) {
|
|
1777
|
+
const spinner = spin("Loading session\u2026");
|
|
1778
|
+
try {
|
|
1779
|
+
await client.sessions.get(opts.session);
|
|
1780
|
+
spinner.stop();
|
|
1781
|
+
} catch {
|
|
1782
|
+
spinner.stop();
|
|
1783
|
+
console.error(c.error(`Session "${opts.session}" not found.`));
|
|
1784
|
+
process.exit(1);
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
if (opts.newSession) {
|
|
1788
|
+
const spinner = spin("Creating session\u2026");
|
|
1789
|
+
try {
|
|
1790
|
+
const res = await client.sessions.create({
|
|
1791
|
+
agentId,
|
|
1792
|
+
initiator: cfg.initiator ?? "",
|
|
1793
|
+
title: `agc run ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16)}`,
|
|
1794
|
+
source: "cli"
|
|
1795
|
+
});
|
|
1796
|
+
const session = res?.data ?? res;
|
|
1797
|
+
sessionId = session.sessionId;
|
|
1798
|
+
spinner.stop();
|
|
1799
|
+
} catch (err) {
|
|
1800
|
+
spinner.stop();
|
|
1801
|
+
printError(err);
|
|
1802
|
+
process.exit(1);
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
const localEnabled = opts.yes || opts.local;
|
|
1806
|
+
const autoApprove = !!opts.yes;
|
|
1807
|
+
let localToolsCfg = null;
|
|
1808
|
+
let cliContext;
|
|
1809
|
+
if (localEnabled) {
|
|
1810
|
+
const rootDir = process.cwd();
|
|
1811
|
+
localToolsCfg = {
|
|
1812
|
+
rootDir,
|
|
1813
|
+
sessionId: sessionId ?? "run",
|
|
1814
|
+
appendLog: () => {
|
|
1815
|
+
},
|
|
1816
|
+
permissions: /* @__PURE__ */ new Map(),
|
|
1817
|
+
agentId,
|
|
1818
|
+
autoApprove
|
|
1819
|
+
};
|
|
1820
|
+
const snapshot = buildDirSnapshot(rootDir, 2);
|
|
1821
|
+
cliContext = buildLocalToolsManifest(rootDir, snapshot, [], autoApprove);
|
|
1822
|
+
}
|
|
1823
|
+
if (!opts.json) {
|
|
1824
|
+
const rows = [];
|
|
1825
|
+
if (sessionId) {
|
|
1826
|
+
const label = opts.newSession ? `${c.id(sessionId)}${c.dim(" (new)")}` : `${c.id(sessionId)}${c.dim(" (resumed)")}`;
|
|
1827
|
+
rows.push(["Session", label]);
|
|
1828
|
+
}
|
|
1829
|
+
if (localEnabled) {
|
|
1830
|
+
rows.push(["Local tools", autoApprove ? c.warn("enabled (auto-approve on)") : c.success("enabled")]);
|
|
1831
|
+
}
|
|
1832
|
+
if (rows.length) {
|
|
1833
|
+
detail(rows);
|
|
1834
|
+
console.log();
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
const params = {
|
|
1838
|
+
agentId,
|
|
1839
|
+
sessionId,
|
|
1840
|
+
messages: [{ role: "user", content: prompt2 }],
|
|
1841
|
+
...cfg.initiator && { initiatorId: cfg.initiator },
|
|
1842
|
+
...cliContext && { cliContext }
|
|
1843
|
+
};
|
|
1844
|
+
if (opts.noStream) {
|
|
1845
|
+
const spinner = spin("Running\u2026");
|
|
1846
|
+
try {
|
|
1847
|
+
const result = await client.run.once(params);
|
|
1848
|
+
spinner.stop();
|
|
1849
|
+
if (opts.json) return jsonOut(result);
|
|
1850
|
+
const text = result?.content ?? result?.text ?? result?.message ?? JSON.stringify(result);
|
|
1851
|
+
console.log(text);
|
|
1852
|
+
if (sessionId) console.log(c.dim(`
|
|
1853
|
+
Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`));
|
|
1854
|
+
} catch (err) {
|
|
1855
|
+
spinner.stop();
|
|
1856
|
+
printError(err);
|
|
1857
|
+
process.exit(1);
|
|
1858
|
+
}
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
try {
|
|
1862
|
+
let hasOutput = false;
|
|
1863
|
+
let toolStartMs = 0;
|
|
1864
|
+
let lastToolName = "";
|
|
1865
|
+
for await (const event of client.agents.stream(params)) {
|
|
1866
|
+
if (opts.json) {
|
|
1867
|
+
console.log(JSON.stringify(event));
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
if (event.type === "token") {
|
|
1871
|
+
process.stdout.write(event.content ?? "");
|
|
1872
|
+
hasOutput = true;
|
|
1873
|
+
} else if (event.type === "cli_tool_request" && localToolsCfg) {
|
|
1874
|
+
const { requestId, tool: toolName, args } = event;
|
|
1875
|
+
const displayName = String(toolName).replace("cli_", "");
|
|
1876
|
+
if (hasOutput) {
|
|
1877
|
+
process.stdout.write("\n");
|
|
1878
|
+
hasOutput = false;
|
|
1879
|
+
}
|
|
1880
|
+
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(displayName)}`);
|
|
1881
|
+
const startMs = Date.now();
|
|
1882
|
+
let result;
|
|
1883
|
+
let toolOk = true;
|
|
1884
|
+
try {
|
|
1885
|
+
result = await runLocalTool({ tool: displayName, args: args ?? {} }, localToolsCfg);
|
|
1886
|
+
} catch (err) {
|
|
1887
|
+
result = `Error: ${err?.message ?? String(err)}`;
|
|
1888
|
+
toolOk = false;
|
|
1889
|
+
}
|
|
1890
|
+
const elapsed = ((Date.now() - startMs) / 1e3).toFixed(1);
|
|
1891
|
+
readline3.cursorTo(process.stdout, 0);
|
|
1892
|
+
readline3.clearLine(process.stdout, 0);
|
|
1893
|
+
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(displayName)} ${toolOk ? sym.ok : sym.fail} ${c.dim("(" + elapsed + "s)")}
|
|
1894
|
+
`);
|
|
1895
|
+
try {
|
|
1896
|
+
await fetch(`${cfg.apiUrl}/v1/agents/cli-tool-result`, {
|
|
1897
|
+
method: "POST",
|
|
1898
|
+
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${cfg.apiKey}` },
|
|
1899
|
+
body: JSON.stringify({ requestId, result })
|
|
1900
|
+
});
|
|
1901
|
+
} catch {
|
|
1902
|
+
}
|
|
1903
|
+
} else if (event.type === "toolStart") {
|
|
1904
|
+
lastToolName = event.toolName ?? "";
|
|
1905
|
+
toolStartMs = Date.now();
|
|
1906
|
+
if (hasOutput) {
|
|
1907
|
+
process.stdout.write("\n");
|
|
1908
|
+
hasOutput = false;
|
|
1909
|
+
}
|
|
1910
|
+
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(lastToolName)}`);
|
|
1911
|
+
} else if (event.type === "toolEnd") {
|
|
1912
|
+
const elapsed = ((Date.now() - toolStartMs) / 1e3).toFixed(1);
|
|
1913
|
+
readline3.cursorTo(process.stdout, 0);
|
|
1914
|
+
readline3.clearLine(process.stdout, 0);
|
|
1915
|
+
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(lastToolName)} ${sym.ok} ${c.dim("(" + elapsed + "s)")}
|
|
1916
|
+
`);
|
|
1917
|
+
} else if (event.type === "final") {
|
|
1918
|
+
if (hasOutput) process.stdout.write("\n");
|
|
1919
|
+
const e = event;
|
|
1920
|
+
if (e.content && !hasOutput) console.log(e.content);
|
|
1921
|
+
if (sessionId) console.log(c.dim(`
|
|
1922
|
+
Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`));
|
|
1923
|
+
break;
|
|
1924
|
+
} else if (event.type === "error") {
|
|
1925
|
+
if (hasOutput) process.stdout.write("\n");
|
|
1926
|
+
console.error(`
|
|
1927
|
+
${sym.fail} ${c.error(event.message ?? "Error")}`);
|
|
1928
|
+
process.exit(1);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
if (hasOutput && !opts.json) process.stdout.write("\n");
|
|
1932
|
+
} catch (err) {
|
|
1933
|
+
printError(err);
|
|
1934
|
+
process.exit(1);
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1817
1939
|
// src/commands/chat.ts
|
|
1940
|
+
var import_commander8 = require("commander");
|
|
1941
|
+
var readline4 = __toESM(require("readline"));
|
|
1942
|
+
var import_fs4 = require("fs");
|
|
1943
|
+
var import_path4 = require("path");
|
|
1944
|
+
var import_os3 = require("os");
|
|
1818
1945
|
var SESSIONS_DIR = (0, import_path4.join)((0, import_os3.homedir)(), ".agc", "sessions");
|
|
1819
1946
|
function ensureSessionsDir() {
|
|
1820
1947
|
if (!(0, import_fs4.existsSync)(SESSIONS_DIR)) (0, import_fs4.mkdirSync)(SESSIONS_DIR, { recursive: true });
|
|
@@ -1951,7 +2078,7 @@ ${c.bold("Agent Commons Chat")}`);
|
|
|
1951
2078
|
});
|
|
1952
2079
|
}
|
|
1953
2080
|
console.log(c.dim("\nType your message and press Enter. Type /help for commands.\n"));
|
|
1954
|
-
const rl =
|
|
2081
|
+
const rl = readline4.createInterface({
|
|
1955
2082
|
input: process.stdin,
|
|
1956
2083
|
output: process.stdout,
|
|
1957
2084
|
terminal: true,
|
|
@@ -2094,7 +2221,7 @@ ${sym.fail} ${c.error(err.message ?? String(err))}`);
|
|
|
2094
2221
|
if (isWaiting) {
|
|
2095
2222
|
elapsedInterval = setInterval(() => {
|
|
2096
2223
|
elapsedSec++;
|
|
2097
|
-
|
|
2224
|
+
readline4.cursorTo(process.stdout, 0);
|
|
2098
2225
|
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(displayName)}${argStr ? " " + c.dim(argStr) : ""} ${c.dim(elapsedSec + "s\u2026")}`);
|
|
2099
2226
|
}, 1e3);
|
|
2100
2227
|
}
|
|
@@ -2109,8 +2236,8 @@ ${sym.fail} ${c.error(err.message ?? String(err))}`);
|
|
|
2109
2236
|
if (elapsedInterval) clearInterval(elapsedInterval);
|
|
2110
2237
|
const elapsed = ((Date.now() - startMs) / 1e3).toFixed(1);
|
|
2111
2238
|
const preview = toolOk ? toolResultPreview(displayName, result) : "";
|
|
2112
|
-
|
|
2113
|
-
|
|
2239
|
+
readline4.cursorTo(process.stdout, 0);
|
|
2240
|
+
readline4.clearLine(process.stdout, 0);
|
|
2114
2241
|
const statusIcon = toolOk ? sym.ok : sym.fail;
|
|
2115
2242
|
const previewPart = preview ? ` ${c.dim(preview)}` : "";
|
|
2116
2243
|
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(displayName)}${argStr ? " " + c.dim(argStr) : ""} ${statusIcon}${previewPart} ${c.dim("(" + elapsed + "s)")}
|
|
@@ -2144,8 +2271,8 @@ ${sym.fail} ${c.error(err.message ?? String(err))}`);
|
|
|
2144
2271
|
hasOutput = false;
|
|
2145
2272
|
} else if (event.type === "toolEnd") {
|
|
2146
2273
|
const elapsed = ((Date.now() - toolStartMs) / 1e3).toFixed(1);
|
|
2147
|
-
|
|
2148
|
-
|
|
2274
|
+
readline4.cursorTo(process.stdout, 0);
|
|
2275
|
+
readline4.clearLine(process.stdout, 0);
|
|
2149
2276
|
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(lastToolName)} ${sym.ok} ${c.dim("(" + elapsed + "s)")}
|
|
2150
2277
|
`);
|
|
2151
2278
|
process.stdout.write(c.primary("agent") + c.dim(" \u203A "));
|
|
@@ -2202,8 +2329,8 @@ ${sym.fail} ${c.error(event.message ?? "Stream error")}`);
|
|
|
2202
2329
|
}
|
|
2203
2330
|
}
|
|
2204
2331
|
console.log();
|
|
2205
|
-
|
|
2206
|
-
|
|
2332
|
+
readline4.cursorTo(process.stdout, 0);
|
|
2333
|
+
readline4.clearLine(process.stdout, 0);
|
|
2207
2334
|
rl.resume();
|
|
2208
2335
|
rl.prompt();
|
|
2209
2336
|
});
|
|
@@ -2241,8 +2368,8 @@ async function handleLocalToolLoop(agentText, cfg, client, agentId, sessionId, a
|
|
|
2241
2368
|
}
|
|
2242
2369
|
const elapsed = ((Date.now() - startMs) / 1e3).toFixed(1);
|
|
2243
2370
|
const preview = toolOk ? toolResultPreview(toolCall.tool, result) : "";
|
|
2244
|
-
|
|
2245
|
-
|
|
2371
|
+
readline4.cursorTo(process.stdout, 0);
|
|
2372
|
+
readline4.clearLine(process.stdout, 0);
|
|
2246
2373
|
const previewPart = preview ? ` ${c.dim(preview)}` : "";
|
|
2247
2374
|
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(toolCall.tool)}${argStr ? " " + c.dim(argStr) : ""} ${toolOk ? sym.ok : sym.fail}${previewPart} ${c.dim("(" + elapsed + "s)")}
|
|
2248
2375
|
`);
|
|
@@ -2278,8 +2405,8 @@ ${result}
|
|
|
2278
2405
|
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(loopToolName)}`);
|
|
2279
2406
|
} else if (evt.type === "toolEnd") {
|
|
2280
2407
|
const elapsed2 = ((Date.now() - loopToolStartMs) / 1e3).toFixed(1);
|
|
2281
|
-
|
|
2282
|
-
|
|
2408
|
+
readline4.cursorTo(process.stdout, 0);
|
|
2409
|
+
readline4.clearLine(process.stdout, 0);
|
|
2283
2410
|
process.stdout.write(` ${c.dim("\u2500")} ${c.bold(loopToolName)} ${sym.ok} ${c.dim("(" + elapsed2 + "s)")}
|
|
2284
2411
|
`);
|
|
2285
2412
|
process.stdout.write(c.primary("agent") + c.dim(" \u203A "));
|
|
@@ -2917,8 +3044,8 @@ function skillsCommand() {
|
|
|
2917
3044
|
});
|
|
2918
3045
|
cmd.command("delete <slug>").description("Permanently delete a skill").option("--yes", "Skip confirmation prompt").option("--json", "Output result as JSON").action(async (slug, opts) => {
|
|
2919
3046
|
if (!opts.yes) {
|
|
2920
|
-
const
|
|
2921
|
-
const rl =
|
|
3047
|
+
const readline5 = await import("readline");
|
|
3048
|
+
const rl = readline5.createInterface({ input: process.stdin, output: process.stdout });
|
|
2922
3049
|
const answer = await new Promise(
|
|
2923
3050
|
(resolve2) => rl.question(c.warn(`Delete skill "${slug}"? This cannot be undone. [y/N] `), resolve2)
|
|
2924
3051
|
);
|
|
@@ -3674,7 +3801,7 @@ async function pickAgentInteractively(action) {
|
|
|
3674
3801
|
return agentId;
|
|
3675
3802
|
}
|
|
3676
3803
|
var program = new import_commander16.Command();
|
|
3677
|
-
program.name("agc").description("Agent Commons CLI \u2014 interact with the Agent Commons platform").version("0.1.
|
|
3804
|
+
program.name("agc").description("Agent Commons CLI \u2014 interact with the Agent Commons platform").version("0.1.18", "-v, --version").action(async () => {
|
|
3678
3805
|
await interactiveMenu();
|
|
3679
3806
|
});
|
|
3680
3807
|
program.addCommand(loginCommand());
|