@agent-commons/cli 0.1.11 → 0.1.13
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 +73 -19
- package/package.json +2 -2
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.13") {
|
|
110
110
|
const line = import_chalk.default.cyan(" \u2500".padEnd(2) + "\u2500".repeat(44));
|
|
111
111
|
console.log("");
|
|
112
112
|
console.log(line);
|
|
@@ -1541,7 +1541,8 @@ var LOCAL_TOOLS_DISCLAIMER = `
|
|
|
1541
1541
|
${c.dim("Session activity is logged to")} ${c.primary("~/.agc/sessions/")}
|
|
1542
1542
|
`;
|
|
1543
1543
|
function chatCommand() {
|
|
1544
|
-
return new import_commander8.Command("chat").description("Start an interactive chat REPL with an agent").option("--agent <agentId>", "Agent ID (or set defaultAgentId in config)").option("--resume <sessionId>", "Resume an existing session by ID").option("--no-stream", "Disable token streaming (wait for full response)").option("--local", "
|
|
1544
|
+
return new import_commander8.Command("chat").description("Start an interactive chat REPL with an agent").option("--agent <agentId>", "Agent ID (or set defaultAgentId in config)").option("--resume <sessionId>", "Resume an existing session by ID").option("--no-stream", "Disable token streaming (wait for full response)").option("--no-local", "Disable local file system access for the agent").action(async (opts) => {
|
|
1545
|
+
const localEnabled = opts.local !== false;
|
|
1545
1546
|
const cfg = loadConfig();
|
|
1546
1547
|
const agentId = opts.agent ?? cfg.defaultAgentId;
|
|
1547
1548
|
if (!agentId) {
|
|
@@ -1618,10 +1619,10 @@ ${c.bold("Agent Commons Chat")}`);
|
|
|
1618
1619
|
["Session", c.id(sessionId) + (isResume ? c.dim(" (resumed)") : c.dim(" (new)"))]
|
|
1619
1620
|
];
|
|
1620
1621
|
if (walletLine) headerRows.push(["Wallet", walletLine]);
|
|
1621
|
-
if (
|
|
1622
|
+
if (localEnabled) headerRows.push(["Local tools", c.success("enabled") + c.dim(" (read, write, search, run)")]);
|
|
1622
1623
|
detail(headerRows);
|
|
1623
1624
|
let localToolsCfg = null;
|
|
1624
|
-
if (
|
|
1625
|
+
if (localEnabled) {
|
|
1625
1626
|
console.log(LOCAL_TOOLS_DISCLAIMER);
|
|
1626
1627
|
const rootDir = process.cwd();
|
|
1627
1628
|
localToolsCfg = {
|
|
@@ -1663,7 +1664,7 @@ Session saved. Resume with: agc chat --resume ${sessionId}`));
|
|
|
1663
1664
|
}
|
|
1664
1665
|
if (input === "/tools") {
|
|
1665
1666
|
if (!localToolsCfg) {
|
|
1666
|
-
console.log(c.dim(` Local tools are disabled.
|
|
1667
|
+
console.log(c.dim(` Local tools are disabled. Remove ${c.bold("--no-local")} flag to re-enable them.`));
|
|
1667
1668
|
} else {
|
|
1668
1669
|
console.log(`
|
|
1669
1670
|
${c.bold("Local tools")} ${c.success("enabled")}`);
|
|
@@ -1704,14 +1705,14 @@ Session saved. Resume with: agc chat --resume ${sessionId}`));
|
|
|
1704
1705
|
content: input,
|
|
1705
1706
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1706
1707
|
});
|
|
1707
|
-
const outgoingMessages = localToolsCfg ? [
|
|
1708
|
-
{ role: "system", content: buildLocalToolsManifest(localToolsCfg.rootDir) },
|
|
1709
|
-
{ role: "user", content: input }
|
|
1710
|
-
] : [{ role: "user", content: input }];
|
|
1711
1708
|
const params = {
|
|
1712
1709
|
agentId,
|
|
1713
1710
|
sessionId,
|
|
1714
|
-
messages:
|
|
1711
|
+
messages: [{ role: "user", content: input }],
|
|
1712
|
+
// Inject the tool manifest into the agent's system prompt server-side so
|
|
1713
|
+
// the LLM receives it as part of its actual instructions, not as a stray
|
|
1714
|
+
// second system message appended after the conversation history.
|
|
1715
|
+
...localToolsCfg && { cliContext: buildLocalToolsManifest(localToolsCfg.rootDir) }
|
|
1715
1716
|
};
|
|
1716
1717
|
process.stdout.write(c.primary("agent") + c.dim(" \u203A "));
|
|
1717
1718
|
if (opts.noStream) {
|
|
@@ -1742,6 +1743,42 @@ ${sym.fail} ${c.error(err.message ?? String(err))}`);
|
|
|
1742
1743
|
process.stdout.write(tok);
|
|
1743
1744
|
agentContent += tok;
|
|
1744
1745
|
hasOutput = true;
|
|
1746
|
+
} else if (event.type === "cli_tool_request" && localToolsCfg) {
|
|
1747
|
+
const { requestId, tool: toolName, args } = event;
|
|
1748
|
+
const displayName = String(toolName).replace("cli_", "");
|
|
1749
|
+
if (hasOutput) {
|
|
1750
|
+
process.stdout.write("\n");
|
|
1751
|
+
hasOutput = false;
|
|
1752
|
+
}
|
|
1753
|
+
process.stdout.write(c.dim(` [local] ${displayName}\u2026`));
|
|
1754
|
+
let result;
|
|
1755
|
+
try {
|
|
1756
|
+
const localToolName = String(toolName).replace("cli_", "");
|
|
1757
|
+
result = await runLocalTool({ tool: localToolName, args: args ?? {} }, localToolsCfg);
|
|
1758
|
+
process.stdout.write(c.dim(" \u2713\n"));
|
|
1759
|
+
} catch (err) {
|
|
1760
|
+
result = `Error: ${err?.message ?? String(err)}`;
|
|
1761
|
+
process.stdout.write(c.dim(" \u2717\n"));
|
|
1762
|
+
}
|
|
1763
|
+
appendSessionLog(sessionId, {
|
|
1764
|
+
type: "local_tool_result",
|
|
1765
|
+
tool: toolName,
|
|
1766
|
+
result: result.slice(0, 4e3),
|
|
1767
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1768
|
+
});
|
|
1769
|
+
try {
|
|
1770
|
+
await fetch(`${cfg.apiUrl}/v1/agents/cli-tool-result`, {
|
|
1771
|
+
method: "POST",
|
|
1772
|
+
headers: {
|
|
1773
|
+
"Content-Type": "application/json",
|
|
1774
|
+
"Authorization": `Bearer ${cfg.apiKey}`
|
|
1775
|
+
},
|
|
1776
|
+
body: JSON.stringify({ requestId, result })
|
|
1777
|
+
});
|
|
1778
|
+
} catch (postErr) {
|
|
1779
|
+
console.error(c.warn(`
|
|
1780
|
+
[local] Failed to submit tool result: ${postErr?.message}`));
|
|
1781
|
+
}
|
|
1745
1782
|
} else if (event.type === "toolStart") {
|
|
1746
1783
|
const name = event.toolName ?? "";
|
|
1747
1784
|
if (hasOutput) process.stdout.write("\n");
|
|
@@ -3084,9 +3121,18 @@ async function interactiveMenu() {
|
|
|
3084
3121
|
if (action === "exit") {
|
|
3085
3122
|
process.exit(0);
|
|
3086
3123
|
}
|
|
3124
|
+
const agentId = cfg.defaultAgentId ?? await pickAgentInteractively(action);
|
|
3125
|
+
if ((action === "chat" || action === "run") && !agentId) return;
|
|
3126
|
+
if (action === "run") {
|
|
3127
|
+
const prompt2 = await askPrompt("Enter your prompt:");
|
|
3128
|
+
if (!prompt2) return;
|
|
3129
|
+
runSubcommand(["run", "--agent", agentId, prompt2]);
|
|
3130
|
+
return;
|
|
3131
|
+
}
|
|
3087
3132
|
const commandMap = {
|
|
3088
|
-
chat:
|
|
3089
|
-
run:
|
|
3133
|
+
chat: ["chat", "--agent", agentId],
|
|
3134
|
+
run: [],
|
|
3135
|
+
// handled above
|
|
3090
3136
|
sessions: ["sessions", "list"],
|
|
3091
3137
|
agents: ["agents", "list"],
|
|
3092
3138
|
tasks: ["task", "list"],
|
|
@@ -3099,14 +3145,22 @@ async function interactiveMenu() {
|
|
|
3099
3145
|
config: ["config", "get"],
|
|
3100
3146
|
exit: []
|
|
3101
3147
|
};
|
|
3102
|
-
if ((action === "chat" || action === "run") && !cfg.defaultAgentId) {
|
|
3103
|
-
const pickedId = await pickAgentInteractively(action);
|
|
3104
|
-
if (!pickedId) return;
|
|
3105
|
-
runSubcommand([action, "--agent", pickedId]);
|
|
3106
|
-
return;
|
|
3107
|
-
}
|
|
3108
3148
|
runSubcommand(commandMap[action]);
|
|
3109
3149
|
}
|
|
3150
|
+
async function askPrompt(question) {
|
|
3151
|
+
const { createInterface: createInterface4 } = await import("readline");
|
|
3152
|
+
return new Promise((resolve2) => {
|
|
3153
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
3154
|
+
process.stdout.write(`
|
|
3155
|
+
${c.bold(question)}
|
|
3156
|
+
${c.primary("\u203A")} `);
|
|
3157
|
+
rl.once("line", (line) => {
|
|
3158
|
+
rl.close();
|
|
3159
|
+
const trimmed = line.trim();
|
|
3160
|
+
resolve2(trimmed || null);
|
|
3161
|
+
});
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
3110
3164
|
function runSubcommand(args) {
|
|
3111
3165
|
const child = (0, import_child_process3.spawn)(process.argv[0], [process.argv[1], ...args], {
|
|
3112
3166
|
stdio: "inherit"
|
|
@@ -3164,7 +3218,7 @@ async function pickAgentInteractively(action) {
|
|
|
3164
3218
|
return agentId;
|
|
3165
3219
|
}
|
|
3166
3220
|
var program = new import_commander16.Command();
|
|
3167
|
-
program.name("agc").description("Agent Commons CLI \u2014 interact with the Agent Commons platform").version("0.1.
|
|
3221
|
+
program.name("agc").description("Agent Commons CLI \u2014 interact with the Agent Commons platform").version("0.1.13", "-v, --version").action(async () => {
|
|
3168
3222
|
await interactiveMenu();
|
|
3169
3223
|
});
|
|
3170
3224
|
program.addCommand(loginCommand());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-commons/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Agent Commons CLI — chat, run, and manage agents from your terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"commander": "^12.1.0",
|
|
15
15
|
"chalk": "^5.3.0",
|
|
16
16
|
"ora": "^8.1.1",
|
|
17
|
-
"@agent-commons/sdk": "0.1.
|
|
17
|
+
"@agent-commons/sdk": "0.1.12"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsup": "^8.3.5",
|