@actant/cli 0.2.0 → 0.2.2
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/actant.js +1 -1
- package/dist/{chunk-664FYMDI.js → chunk-FB4IUVWU.js} +260 -139
- package/dist/chunk-FB4IUVWU.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/{program-5GYDDKP6.js → program-P3CKUZHR.js} +2 -2
- package/dist/{repl-ZVBJSFT5.js → repl-G44PJKXP.js} +2 -2
- package/package.json +8 -7
- package/dist/chunk-664FYMDI.js.map +0 -1
- /package/dist/{program-5GYDDKP6.js.map → program-P3CKUZHR.js.map} +0 -0
- /package/dist/{repl-ZVBJSFT5.js.map → repl-G44PJKXP.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/program.ts
|
|
2
|
-
import { Command as
|
|
2
|
+
import { Command as Command75 } from "commander";
|
|
3
3
|
import { readFileSync as readFileSync4 } from "fs";
|
|
4
4
|
import { join as join7 } from "path";
|
|
5
5
|
import { getDefaultIpcPath as getDefaultIpcPath2 } from "@actant/shared";
|
|
@@ -116,7 +116,7 @@ function formatTemplateList(templates, format) {
|
|
|
116
116
|
t.name,
|
|
117
117
|
t.version,
|
|
118
118
|
t.backend.type,
|
|
119
|
-
t.provider.
|
|
119
|
+
t.provider?.type ?? chalk.dim("(default)"),
|
|
120
120
|
t.description ?? chalk.dim("\u2014")
|
|
121
121
|
]);
|
|
122
122
|
}
|
|
@@ -134,7 +134,7 @@ function formatTemplateDetail(template, format) {
|
|
|
134
134
|
`${chalk.bold("Template:")} ${template.name}`,
|
|
135
135
|
`${chalk.bold("Version:")} ${template.version}`,
|
|
136
136
|
`${chalk.bold("Backend:")} ${template.backend.type}`,
|
|
137
|
-
`${chalk.bold("Provider:")} ${template.provider
|
|
137
|
+
`${chalk.bold("Provider:")} ${template.provider?.type ?? "(default)"}`
|
|
138
138
|
];
|
|
139
139
|
if (template.description) {
|
|
140
140
|
lines.push(`${chalk.bold("Desc:")} ${template.description}`);
|
|
@@ -831,6 +831,11 @@ function createAgentDestroyCommand(client, printer = defaultPrinter) {
|
|
|
831
831
|
await client.call("agent.destroy", { name });
|
|
832
832
|
printer.log(`${chalk12.green("Destroyed")} ${name}`);
|
|
833
833
|
} catch (err) {
|
|
834
|
+
const isNotFound = err?.code === -32003 || err?.data?.code === -32003;
|
|
835
|
+
if (opts.force && isNotFound) {
|
|
836
|
+
printer.log(`${chalk12.green("Destroyed")} ${name} (already absent)`);
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
834
839
|
presentError(err, printer);
|
|
835
840
|
process.exitCode = 1;
|
|
836
841
|
}
|
|
@@ -880,11 +885,22 @@ import { spawn } from "child_process";
|
|
|
880
885
|
import { Command as Command15 } from "commander";
|
|
881
886
|
import chalk14 from "chalk";
|
|
882
887
|
function createAgentOpenCommand(client, printer = defaultPrinter) {
|
|
883
|
-
return new Command15("open").description("Open an agent's native TUI/UI (e.g. Cursor IDE)").argument("<name>", "Agent name").action(async (name) => {
|
|
888
|
+
return new Command15("open").description("Open an agent's native TUI/UI (e.g. Cursor IDE, Claude Code)").argument("<name>", "Agent name").action(async (name) => {
|
|
884
889
|
try {
|
|
885
890
|
const result = await client.call("agent.open", { name });
|
|
886
|
-
printer.log(`${chalk14.green("Opening")} ${name} \u2192 ${result.command
|
|
887
|
-
|
|
891
|
+
printer.log(`${chalk14.green("Opening")} ${name} \u2192 ${[result.command, ...result.args].join(" ")}`);
|
|
892
|
+
const opts = result.openSpawnOptions ?? {};
|
|
893
|
+
const child = spawn(result.command, result.args, { cwd: result.cwd, ...opts });
|
|
894
|
+
child.on("error", (err) => {
|
|
895
|
+
printer.error(`Failed to open ${name}: ${err.message}`);
|
|
896
|
+
process.exitCode = 1;
|
|
897
|
+
});
|
|
898
|
+
if (opts.detached !== false) {
|
|
899
|
+
child.unref();
|
|
900
|
+
} else {
|
|
901
|
+
const code = await new Promise((r) => child.on("close", r));
|
|
902
|
+
if (code) process.exitCode = code;
|
|
903
|
+
}
|
|
888
904
|
} catch (err) {
|
|
889
905
|
presentError(err, printer);
|
|
890
906
|
process.exitCode = 1;
|
|
@@ -1089,7 +1105,19 @@ async function runDirectBridgeChat(client, name, opts, printer) {
|
|
|
1089
1105
|
}
|
|
1090
1106
|
};
|
|
1091
1107
|
try {
|
|
1092
|
-
|
|
1108
|
+
try {
|
|
1109
|
+
await conn.spawn(resolved.command, resolved.args, resolved.workspaceDir, resolved.resolvePackage);
|
|
1110
|
+
} catch (spawnErr) {
|
|
1111
|
+
const msg = spawnErr instanceof Error ? spawnErr.message : String(spawnErr);
|
|
1112
|
+
if (/ENOENT|EINVAL|is not recognized|not found/i.test(msg)) {
|
|
1113
|
+
throw new Error(
|
|
1114
|
+
`Cannot start "${resolved.command}". Is it installed?
|
|
1115
|
+
` + (resolved.backendType === "claude-code" ? ` Install with: npm install -g @zed-industries/claude-agent-acp` : ` Ensure the backend CLI is installed and in your PATH.`),
|
|
1116
|
+
{ cause: spawnErr }
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
throw spawnErr;
|
|
1120
|
+
}
|
|
1093
1121
|
await client.call("agent.attach", {
|
|
1094
1122
|
name: resolved.instanceName,
|
|
1095
1123
|
pid: process.pid,
|
|
@@ -1097,7 +1125,23 @@ async function runDirectBridgeChat(client, name, opts, printer) {
|
|
|
1097
1125
|
metadata: { proxyMode: "direct-bridge-chat" }
|
|
1098
1126
|
});
|
|
1099
1127
|
attached = true;
|
|
1100
|
-
|
|
1128
|
+
let initResult;
|
|
1129
|
+
try {
|
|
1130
|
+
initResult = await conn.initialize();
|
|
1131
|
+
} catch (initErr) {
|
|
1132
|
+
const msg = initErr instanceof Error ? initErr.message : String(initErr);
|
|
1133
|
+
if (/exited unexpectedly|ABORT_ERR|premature close/i.test(msg)) {
|
|
1134
|
+
const hint = resolved.backendType === "claude-code" ? `
|
|
1135
|
+
Install ACP bridge: npm install -g @zed-industries/claude-agent-acp` : `
|
|
1136
|
+
Ensure the backend CLI is installed and supports ACP protocol.`;
|
|
1137
|
+
throw new Error(
|
|
1138
|
+
`Failed to initialize ACP connection with "${resolved.command}". The agent process exited before completing the handshake.${hint}
|
|
1139
|
+
Detail: ${msg}`,
|
|
1140
|
+
{ cause: initErr }
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
throw initErr;
|
|
1144
|
+
}
|
|
1101
1145
|
const agentName = initResult.agentInfo?.name ?? name;
|
|
1102
1146
|
session = await conn.newSession(resolved.workspaceDir);
|
|
1103
1147
|
printer.log(
|
|
@@ -1203,6 +1247,8 @@ function createAgentDispatchCommand(client, printer = defaultPrinter) {
|
|
|
1203
1247
|
printer.log("Task queued.");
|
|
1204
1248
|
} else {
|
|
1205
1249
|
printer.dim(`No scheduler for agent "${name}". Task not queued.`);
|
|
1250
|
+
printer.dim(`Hint: use "actant agent run ${name} --prompt <message>" for one-shot execution.`);
|
|
1251
|
+
process.exitCode = 1;
|
|
1206
1252
|
}
|
|
1207
1253
|
} catch (err) {
|
|
1208
1254
|
presentError(err, printer);
|
|
@@ -1292,7 +1338,7 @@ import chalk17 from "chalk";
|
|
|
1292
1338
|
// package.json
|
|
1293
1339
|
var package_default = {
|
|
1294
1340
|
name: "@actant/cli",
|
|
1295
|
-
version: "0.2.
|
|
1341
|
+
version: "0.2.2",
|
|
1296
1342
|
description: "CLI for the Actant AI agent platform \u2014 build, manage, and compose AI agents",
|
|
1297
1343
|
type: "module",
|
|
1298
1344
|
license: "MIT",
|
|
@@ -1323,7 +1369,8 @@ var package_default = {
|
|
|
1323
1369
|
".": {
|
|
1324
1370
|
import: "./dist/index.js",
|
|
1325
1371
|
types: "./dist/index.d.ts"
|
|
1326
|
-
}
|
|
1372
|
+
},
|
|
1373
|
+
"./dist/bin/actant.js": "./dist/bin/actant.js"
|
|
1327
1374
|
},
|
|
1328
1375
|
bin: {
|
|
1329
1376
|
actant: "./dist/bin/actant.js"
|
|
@@ -1883,7 +1930,7 @@ function createPluginCommand(client, printer) {
|
|
|
1883
1930
|
}
|
|
1884
1931
|
|
|
1885
1932
|
// src/commands/source/index.ts
|
|
1886
|
-
import { Command as
|
|
1933
|
+
import { Command as Command61 } from "commander";
|
|
1887
1934
|
|
|
1888
1935
|
// src/commands/source/list.ts
|
|
1889
1936
|
import { Command as Command56 } from "commander";
|
|
@@ -1977,23 +2024,110 @@ function createSourceSyncCommand(client, printer = defaultPrinter) {
|
|
|
1977
2024
|
});
|
|
1978
2025
|
}
|
|
1979
2026
|
|
|
2027
|
+
// src/commands/source/validate.ts
|
|
2028
|
+
import chalk19 from "chalk";
|
|
2029
|
+
import { Command as Command60 } from "commander";
|
|
2030
|
+
function createSourceValidateCommand(client, printer = defaultPrinter) {
|
|
2031
|
+
return new Command60("validate").description("Validate all assets in a component source").argument("[name]", "Registered source name to validate").option("--path <dir>", "Validate a local directory directly (no registration needed)").option("-f, --format <format>", "Output format: table, json", "table").option("--strict", "Treat warnings as errors", false).option("--compat <standard>", "Enable compatibility checks (e.g. agent-skills)").action(async (name, opts) => {
|
|
2032
|
+
try {
|
|
2033
|
+
if (!name && !opts?.path) {
|
|
2034
|
+
printer.error("Provide a source name or --path <dir>");
|
|
2035
|
+
process.exitCode = 1;
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
const result = await client.call("source.validate", {
|
|
2039
|
+
name: name || void 0,
|
|
2040
|
+
path: opts?.path || void 0,
|
|
2041
|
+
strict: opts?.strict || false,
|
|
2042
|
+
compat: opts?.compat || void 0
|
|
2043
|
+
});
|
|
2044
|
+
if (opts?.format === "json") {
|
|
2045
|
+
printer.log(JSON.stringify(result, null, 2));
|
|
2046
|
+
} else {
|
|
2047
|
+
printTableReport(result, printer);
|
|
2048
|
+
}
|
|
2049
|
+
if (!result.valid) {
|
|
2050
|
+
process.exitCode = 1;
|
|
2051
|
+
}
|
|
2052
|
+
} catch (err) {
|
|
2053
|
+
presentError(err, printer);
|
|
2054
|
+
process.exitCode = 1;
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2058
|
+
function printTableReport(report, printer) {
|
|
2059
|
+
printer.log("");
|
|
2060
|
+
printer.log(`Validating source: ${chalk19.bold(report.sourceName)} (${report.rootDir})`);
|
|
2061
|
+
printer.log("");
|
|
2062
|
+
const grouped = groupByPath(report.issues);
|
|
2063
|
+
const reportedPaths = /* @__PURE__ */ new Set();
|
|
2064
|
+
for (const [path, issues] of grouped) {
|
|
2065
|
+
reportedPaths.add(path);
|
|
2066
|
+
for (const issue of issues) {
|
|
2067
|
+
const tag = severityTag(issue.severity);
|
|
2068
|
+
const comp = issue.component ? ` (${issue.component})` : "";
|
|
2069
|
+
printer.log(` ${tag} ${path}${comp} \u2014 ${issue.message}`);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
if (report.summary.pass > 0) {
|
|
2073
|
+
const passMsg = chalk19.green(`${report.summary.pass} component(s) passed`);
|
|
2074
|
+
const errMsg = report.summary.error > 0 ? chalk19.red(`, ${report.summary.error} error(s)`) : "";
|
|
2075
|
+
const warnMsg = report.summary.warn > 0 ? chalk19.yellow(`, ${report.summary.warn} warning(s)`) : "";
|
|
2076
|
+
printer.log("");
|
|
2077
|
+
printer.log(`Summary: ${passMsg}${warnMsg}${errMsg}`);
|
|
2078
|
+
} else if (report.issues.length === 0) {
|
|
2079
|
+
printer.log(chalk19.dim(" No components found to validate."));
|
|
2080
|
+
}
|
|
2081
|
+
printer.log("");
|
|
2082
|
+
if (report.valid) {
|
|
2083
|
+
printer.log(chalk19.green("Validation passed."));
|
|
2084
|
+
} else {
|
|
2085
|
+
printer.log(chalk19.red("Validation failed."));
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
function severityTag(severity) {
|
|
2089
|
+
switch (severity) {
|
|
2090
|
+
case "error":
|
|
2091
|
+
return chalk19.red("[ERROR]");
|
|
2092
|
+
case "warning":
|
|
2093
|
+
return chalk19.yellow("[WARN] ");
|
|
2094
|
+
case "info":
|
|
2095
|
+
return chalk19.blue("[INFO] ");
|
|
2096
|
+
default:
|
|
2097
|
+
return `[${severity}]`;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
function groupByPath(issues) {
|
|
2101
|
+
const map = /* @__PURE__ */ new Map();
|
|
2102
|
+
for (const issue of issues) {
|
|
2103
|
+
let arr = map.get(issue.path);
|
|
2104
|
+
if (!arr) {
|
|
2105
|
+
arr = [];
|
|
2106
|
+
map.set(issue.path, arr);
|
|
2107
|
+
}
|
|
2108
|
+
arr.push(issue);
|
|
2109
|
+
}
|
|
2110
|
+
return map;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
1980
2113
|
// src/commands/source/index.ts
|
|
1981
2114
|
function createSourceCommand(client, printer) {
|
|
1982
|
-
const cmd = new
|
|
2115
|
+
const cmd = new Command61("source").description("Manage component sources (GitHub repos, local dirs)");
|
|
1983
2116
|
cmd.addCommand(createSourceListCommand(client, printer));
|
|
1984
2117
|
cmd.addCommand(createSourceAddCommand(client, printer));
|
|
1985
2118
|
cmd.addCommand(createSourceRemoveCommand(client, printer));
|
|
1986
2119
|
cmd.addCommand(createSourceSyncCommand(client, printer));
|
|
2120
|
+
cmd.addCommand(createSourceValidateCommand(client, printer));
|
|
1987
2121
|
return cmd;
|
|
1988
2122
|
}
|
|
1989
2123
|
|
|
1990
2124
|
// src/commands/preset/index.ts
|
|
1991
|
-
import { Command as
|
|
2125
|
+
import { Command as Command65 } from "commander";
|
|
1992
2126
|
|
|
1993
2127
|
// src/commands/preset/list.ts
|
|
1994
|
-
import { Command as
|
|
2128
|
+
import { Command as Command62 } from "commander";
|
|
1995
2129
|
function createPresetListCommand(client, printer = defaultPrinter) {
|
|
1996
|
-
return new
|
|
2130
|
+
return new Command62("list").alias("ls").description("List available presets from registered sources").argument("[package]", "Filter by source package name").option("-f, --format <format>", "Output format: table, json, quiet", "table").action(async (packageName, opts) => {
|
|
1997
2131
|
try {
|
|
1998
2132
|
const presets = await client.call("preset.list", { packageName });
|
|
1999
2133
|
if (opts.format === "json") {
|
|
@@ -2018,9 +2152,9 @@ function createPresetListCommand(client, printer = defaultPrinter) {
|
|
|
2018
2152
|
}
|
|
2019
2153
|
|
|
2020
2154
|
// src/commands/preset/show.ts
|
|
2021
|
-
import { Command as
|
|
2155
|
+
import { Command as Command63 } from "commander";
|
|
2022
2156
|
function createPresetShowCommand(client, printer = defaultPrinter) {
|
|
2023
|
-
return new
|
|
2157
|
+
return new Command63("show").description("Show preset details").argument("<qualified-name>", "Preset qualified name (package@preset)").option("-f, --format <format>", "Output format: table, json", "table").action(async (qualifiedName, opts) => {
|
|
2024
2158
|
try {
|
|
2025
2159
|
const preset = await client.call("preset.show", { qualifiedName });
|
|
2026
2160
|
if (opts.format === "json") {
|
|
@@ -2041,9 +2175,9 @@ function createPresetShowCommand(client, printer = defaultPrinter) {
|
|
|
2041
2175
|
}
|
|
2042
2176
|
|
|
2043
2177
|
// src/commands/preset/apply.ts
|
|
2044
|
-
import { Command as
|
|
2178
|
+
import { Command as Command64 } from "commander";
|
|
2045
2179
|
function createPresetApplyCommand(client, printer = defaultPrinter) {
|
|
2046
|
-
return new
|
|
2180
|
+
return new Command64("apply").description("Apply a preset to a template (adds all preset components)").argument("<qualified-name>", "Preset qualified name (package@preset)").argument("<template>", "Template name to apply to").action(async (qualifiedName, templateName) => {
|
|
2047
2181
|
try {
|
|
2048
2182
|
const result = await client.call("preset.apply", { qualifiedName, templateName });
|
|
2049
2183
|
printer.success(`Preset "${qualifiedName}" applied to template "${result.name}".`);
|
|
@@ -2056,7 +2190,7 @@ function createPresetApplyCommand(client, printer = defaultPrinter) {
|
|
|
2056
2190
|
|
|
2057
2191
|
// src/commands/preset/index.ts
|
|
2058
2192
|
function createPresetCommand(client, printer) {
|
|
2059
|
-
const cmd = new
|
|
2193
|
+
const cmd = new Command65("preset").description("Manage component presets (bundled compositions)");
|
|
2060
2194
|
cmd.addCommand(createPresetListCommand(client, printer));
|
|
2061
2195
|
cmd.addCommand(createPresetShowCommand(client, printer));
|
|
2062
2196
|
cmd.addCommand(createPresetApplyCommand(client, printer));
|
|
@@ -2064,12 +2198,12 @@ function createPresetCommand(client, printer) {
|
|
|
2064
2198
|
}
|
|
2065
2199
|
|
|
2066
2200
|
// src/commands/schedule/index.ts
|
|
2067
|
-
import { Command as
|
|
2201
|
+
import { Command as Command67 } from "commander";
|
|
2068
2202
|
|
|
2069
2203
|
// src/commands/schedule/list.ts
|
|
2070
|
-
import { Command as
|
|
2204
|
+
import { Command as Command66 } from "commander";
|
|
2071
2205
|
function createScheduleListCommand(client, printer = defaultPrinter) {
|
|
2072
|
-
return new
|
|
2206
|
+
return new Command66("list").alias("ls").description("List schedule sources for an agent").argument("<name>", "Agent name").option("-f, --format <format>", "Output format: table, json", "table").action(async (name, opts) => {
|
|
2073
2207
|
try {
|
|
2074
2208
|
const result = await client.call("schedule.list", { name });
|
|
2075
2209
|
if (opts.format === "json") {
|
|
@@ -2077,6 +2211,7 @@ function createScheduleListCommand(client, printer = defaultPrinter) {
|
|
|
2077
2211
|
} else {
|
|
2078
2212
|
if (result.sources.length === 0 && !result.running) {
|
|
2079
2213
|
printer.dim(`No scheduler for agent "${name}".`);
|
|
2214
|
+
process.exitCode = 1;
|
|
2080
2215
|
} else {
|
|
2081
2216
|
printer.log(`Scheduler: ${result.running ? "running" : "stopped"}`);
|
|
2082
2217
|
for (const s of result.sources) {
|
|
@@ -2093,19 +2228,19 @@ function createScheduleListCommand(client, printer = defaultPrinter) {
|
|
|
2093
2228
|
|
|
2094
2229
|
// src/commands/schedule/index.ts
|
|
2095
2230
|
function createScheduleCommand(client, printer) {
|
|
2096
|
-
const cmd = new
|
|
2231
|
+
const cmd = new Command67("schedule").description("Manage agent schedules (heartbeat, cron, hooks)");
|
|
2097
2232
|
cmd.addCommand(createScheduleListCommand(client, printer));
|
|
2098
2233
|
return cmd;
|
|
2099
2234
|
}
|
|
2100
2235
|
|
|
2101
2236
|
// src/commands/daemon/index.ts
|
|
2102
|
-
import { Command as
|
|
2237
|
+
import { Command as Command71 } from "commander";
|
|
2103
2238
|
|
|
2104
2239
|
// src/commands/daemon/start.ts
|
|
2105
|
-
import { Command as
|
|
2240
|
+
import { Command as Command68 } from "commander";
|
|
2106
2241
|
import { join } from "path";
|
|
2107
2242
|
import { fork, spawn as spawn2 } from "child_process";
|
|
2108
|
-
import
|
|
2243
|
+
import chalk20 from "chalk";
|
|
2109
2244
|
import { onShutdownSignal, isWindows, isSingleExecutable } from "@actant/shared";
|
|
2110
2245
|
var SEA_DAEMON_FLAG = "--__actant-daemon";
|
|
2111
2246
|
function spawnDaemonChild() {
|
|
@@ -2128,7 +2263,7 @@ function spawnDaemonChild() {
|
|
|
2128
2263
|
});
|
|
2129
2264
|
}
|
|
2130
2265
|
function createDaemonStartCommand(printer = defaultPrinter) {
|
|
2131
|
-
return new
|
|
2266
|
+
return new Command68("start").description("Start the Actant daemon").option("--foreground", "Run in foreground (don't daemonize)", false).action(async (opts) => {
|
|
2132
2267
|
const client = new RpcClient(defaultSocketPath());
|
|
2133
2268
|
const alive = await client.ping();
|
|
2134
2269
|
if (alive) {
|
|
@@ -2144,7 +2279,7 @@ function createDaemonStartCommand(printer = defaultPrinter) {
|
|
|
2144
2279
|
process.exit(0);
|
|
2145
2280
|
});
|
|
2146
2281
|
await daemon.start();
|
|
2147
|
-
printer.log(`${
|
|
2282
|
+
printer.log(`${chalk20.green("Daemon started (foreground).")} PID: ${process.pid}`);
|
|
2148
2283
|
printer.dim("Press Ctrl+C to stop.");
|
|
2149
2284
|
await new Promise(() => {
|
|
2150
2285
|
});
|
|
@@ -2182,7 +2317,7 @@ function createDaemonStartCommand(printer = defaultPrinter) {
|
|
|
2182
2317
|
if ("connected" in child && child.connected) child.disconnect();
|
|
2183
2318
|
child.unref();
|
|
2184
2319
|
if (healthy) {
|
|
2185
|
-
printer.log(`${
|
|
2320
|
+
printer.log(`${chalk20.green("Daemon started.")} PID: ${child.pid}`);
|
|
2186
2321
|
} else {
|
|
2187
2322
|
const stderr = Buffer.concat(stderrChunks).toString().trim();
|
|
2188
2323
|
printer.error("Daemon process started but is not responding.");
|
|
@@ -2194,9 +2329,9 @@ function createDaemonStartCommand(printer = defaultPrinter) {
|
|
|
2194
2329
|
}
|
|
2195
2330
|
|
|
2196
2331
|
// src/commands/daemon/stop.ts
|
|
2197
|
-
import { Command as
|
|
2332
|
+
import { Command as Command69 } from "commander";
|
|
2198
2333
|
function createDaemonStopCommand(printer = defaultPrinter, client) {
|
|
2199
|
-
return new
|
|
2334
|
+
return new Command69("stop").description("Stop the Actant daemon").action(async () => {
|
|
2200
2335
|
const rpc = client ?? new RpcClient(defaultSocketPath());
|
|
2201
2336
|
try {
|
|
2202
2337
|
await rpc.call("daemon.shutdown", {});
|
|
@@ -2208,10 +2343,10 @@ function createDaemonStopCommand(printer = defaultPrinter, client) {
|
|
|
2208
2343
|
}
|
|
2209
2344
|
|
|
2210
2345
|
// src/commands/daemon/status.ts
|
|
2211
|
-
import { Command as
|
|
2212
|
-
import
|
|
2346
|
+
import { Command as Command70 } from "commander";
|
|
2347
|
+
import chalk21 from "chalk";
|
|
2213
2348
|
function createDaemonStatusCommand(printer = defaultPrinter) {
|
|
2214
|
-
return new
|
|
2349
|
+
return new Command70("status").description("Check if the daemon is running").option("-f, --format <format>", "Output format: table, json, quiet", "table").action(async (opts) => {
|
|
2215
2350
|
const client = new RpcClient(defaultSocketPath());
|
|
2216
2351
|
try {
|
|
2217
2352
|
const result = await client.call("daemon.ping", {});
|
|
@@ -2231,7 +2366,7 @@ function createDaemonStatusCommand(printer = defaultPrinter) {
|
|
|
2231
2366
|
} else if (opts.format === "quiet") {
|
|
2232
2367
|
printer.log("stopped");
|
|
2233
2368
|
} else {
|
|
2234
|
-
printer.log(
|
|
2369
|
+
printer.log(chalk21.red("Daemon is not running."));
|
|
2235
2370
|
printer.dim("Start with: actant daemon start");
|
|
2236
2371
|
}
|
|
2237
2372
|
process.exitCode = 1;
|
|
@@ -2241,7 +2376,7 @@ function createDaemonStatusCommand(printer = defaultPrinter) {
|
|
|
2241
2376
|
|
|
2242
2377
|
// src/commands/daemon/index.ts
|
|
2243
2378
|
function createDaemonCommand(printer) {
|
|
2244
|
-
const cmd = new
|
|
2379
|
+
const cmd = new Command71("daemon").description("Manage the Actant daemon");
|
|
2245
2380
|
cmd.addCommand(createDaemonStartCommand(printer));
|
|
2246
2381
|
cmd.addCommand(createDaemonStopCommand(printer));
|
|
2247
2382
|
cmd.addCommand(createDaemonStatusCommand(printer));
|
|
@@ -2249,11 +2384,11 @@ function createDaemonCommand(printer) {
|
|
|
2249
2384
|
}
|
|
2250
2385
|
|
|
2251
2386
|
// src/commands/proxy.ts
|
|
2252
|
-
import { Command as
|
|
2387
|
+
import { Command as Command72 } from "commander";
|
|
2253
2388
|
import { spawn as spawn3 } from "child_process";
|
|
2254
2389
|
import { createInterface as createInterface3 } from "readline";
|
|
2255
2390
|
function createProxyCommand(printer = defaultPrinter) {
|
|
2256
|
-
return new
|
|
2391
|
+
return new Command72("proxy").description("Run an ACP proxy for an agent (stdin/stdout ACP protocol)").argument("<name>", "Agent name to proxy").option("--lease", "Use Session Lease mode (requires running agent)", false).option("-t, --template <template>", "Template name (auto-creates instance if not found)").action(async (name, opts) => {
|
|
2257
2392
|
if (opts.lease) {
|
|
2258
2393
|
await runSessionLease(name, printer);
|
|
2259
2394
|
} else {
|
|
@@ -2571,14 +2706,14 @@ function writeAcpError(id, code, message) {
|
|
|
2571
2706
|
}
|
|
2572
2707
|
|
|
2573
2708
|
// src/commands/self-update.ts
|
|
2574
|
-
import { Command as
|
|
2709
|
+
import { Command as Command73 } from "commander";
|
|
2575
2710
|
import { spawn as spawn4 } from "child_process";
|
|
2576
2711
|
import { writeFileSync, mkdirSync, readFileSync, existsSync as existsSync2 } from "fs";
|
|
2577
2712
|
import { join as join2 } from "path";
|
|
2578
2713
|
import { homedir } from "os";
|
|
2579
|
-
import
|
|
2714
|
+
import chalk22 from "chalk";
|
|
2580
2715
|
function createSelfUpdateCommand() {
|
|
2581
|
-
return new
|
|
2716
|
+
return new Command73("self-update").description("Update Actant from local source").option("--source <path>", "Source directory path").option("--check", "Only check for updates, don't apply").option("--force", "Skip active session warnings").option("--dry-run", "Show what would be done without doing it").option("--no-agent", "Skip agent supervisor, run script directly").option("--skip-build", "Skip build step (use pre-built dist)").action(async (opts) => {
|
|
2582
2717
|
const actantHome = process.env.ACTANT_HOME || join2(homedir(), ".actant");
|
|
2583
2718
|
let devSourcePath = opts.source;
|
|
2584
2719
|
if (!devSourcePath) {
|
|
@@ -2591,7 +2726,7 @@ function createSelfUpdateCommand() {
|
|
|
2591
2726
|
}
|
|
2592
2727
|
if (!devSourcePath) {
|
|
2593
2728
|
console.error(
|
|
2594
|
-
|
|
2729
|
+
chalk22.red(
|
|
2595
2730
|
"No source path specified. Use --source <path> or set devSourcePath in ~/.actant/config.json"
|
|
2596
2731
|
)
|
|
2597
2732
|
);
|
|
@@ -2626,37 +2761,37 @@ function createSelfUpdateCommand() {
|
|
|
2626
2761
|
};
|
|
2627
2762
|
mkdirSync(actantHome, { recursive: true });
|
|
2628
2763
|
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
2629
|
-
console.log(
|
|
2764
|
+
console.log(chalk22.cyan("=== Actant Self-Update ==="));
|
|
2630
2765
|
console.log(`Update ID: ${updateId}`);
|
|
2631
2766
|
console.log(`Source: ${devSourcePath}`);
|
|
2632
2767
|
const scriptPath = join2(devSourcePath, "scripts", "self-update.js");
|
|
2633
2768
|
const scriptArgs = ["--manifest", manifestPath];
|
|
2634
2769
|
if (opts.dryRun) scriptArgs.push("--dry-run");
|
|
2635
2770
|
if (opts.skipBuild) scriptArgs.push("--skip-build");
|
|
2636
|
-
console.log(
|
|
2771
|
+
console.log(chalk22.gray(`Spawning: node ${scriptPath} ${scriptArgs.join(" ")}`));
|
|
2637
2772
|
const child = spawn4("node", [scriptPath, ...scriptArgs], {
|
|
2638
2773
|
detached: !opts.noAgent,
|
|
2639
2774
|
stdio: opts.noAgent ? "inherit" : "ignore"
|
|
2640
2775
|
});
|
|
2641
2776
|
if (!opts.noAgent) {
|
|
2642
2777
|
child.unref();
|
|
2643
|
-
console.log(
|
|
2644
|
-
console.log(
|
|
2778
|
+
console.log(chalk22.green("Update script spawned in background. Check logs at:"));
|
|
2779
|
+
console.log(chalk22.gray(` ${join2(actantHome, "logs", `update-${updateId}.log`)}`));
|
|
2645
2780
|
} else {
|
|
2646
2781
|
child.on("exit", (code) => {
|
|
2647
2782
|
if (code === 0) {
|
|
2648
|
-
console.log(
|
|
2783
|
+
console.log(chalk22.green("\nUpdate completed successfully!"));
|
|
2649
2784
|
} else if (code === 1) {
|
|
2650
|
-
console.log(
|
|
2785
|
+
console.log(chalk22.yellow("\nUpdate failed, rolled back to previous version."));
|
|
2651
2786
|
} else {
|
|
2652
|
-
console.log(
|
|
2787
|
+
console.log(chalk22.red("\nSevere failure \u2014 manual intervention may be needed."));
|
|
2653
2788
|
}
|
|
2654
2789
|
});
|
|
2655
2790
|
}
|
|
2656
2791
|
});
|
|
2657
2792
|
}
|
|
2658
2793
|
function showVersionCheck(sourcePath, actantHome) {
|
|
2659
|
-
console.log(
|
|
2794
|
+
console.log(chalk22.cyan("=== Version Check ==="));
|
|
2660
2795
|
try {
|
|
2661
2796
|
const pkg = JSON.parse(readFileSync(join2(sourcePath, "package.json"), "utf-8"));
|
|
2662
2797
|
console.log(`Source version: ${pkg.version || "unknown"}`);
|
|
@@ -2673,8 +2808,8 @@ function showVersionCheck(sourcePath, actantHome) {
|
|
|
2673
2808
|
}
|
|
2674
2809
|
|
|
2675
2810
|
// src/commands/setup/setup.ts
|
|
2676
|
-
import { Command as
|
|
2677
|
-
import
|
|
2811
|
+
import { Command as Command74 } from "commander";
|
|
2812
|
+
import chalk30 from "chalk";
|
|
2678
2813
|
import { getDefaultIpcPath } from "@actant/shared";
|
|
2679
2814
|
|
|
2680
2815
|
// src/commands/setup/steps/choose-home.ts
|
|
@@ -2682,7 +2817,7 @@ import { join as join3 } from "path";
|
|
|
2682
2817
|
import { homedir as homedir2 } from "os";
|
|
2683
2818
|
import { mkdirSync as mkdirSync2, existsSync as existsSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
2684
2819
|
import { select, input } from "@inquirer/prompts";
|
|
2685
|
-
import
|
|
2820
|
+
import chalk23 from "chalk";
|
|
2686
2821
|
var DEFAULT_HOME = join3(homedir2(), ".actant");
|
|
2687
2822
|
var SUBDIRS = [
|
|
2688
2823
|
"configs/skills",
|
|
@@ -2698,7 +2833,7 @@ var SUBDIRS = [
|
|
|
2698
2833
|
];
|
|
2699
2834
|
async function chooseHome(printer) {
|
|
2700
2835
|
printer.log(`
|
|
2701
|
-
${
|
|
2836
|
+
${chalk23.cyan("[ Step 1/7 ]")} ${chalk23.bold("\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55")}
|
|
2702
2837
|
`);
|
|
2703
2838
|
const choice = await select({
|
|
2704
2839
|
message: "Actant \u5DE5\u4F5C\u76EE\u5F55 (ACTANT_HOME):",
|
|
@@ -2738,7 +2873,7 @@ ${chalk22.cyan("[ Step 1/7 ]")} ${chalk22.bold("\u9009\u62E9\u5DE5\u4F5C\u76EE\u
|
|
|
2738
2873
|
if (actantHome !== DEFAULT_HOME) {
|
|
2739
2874
|
printer.warn(
|
|
2740
2875
|
` \u8BF7\u5C06\u4EE5\u4E0B\u5185\u5BB9\u6DFB\u52A0\u5230\u4F60\u7684 shell \u914D\u7F6E\u6587\u4EF6 (~/.bashrc, ~/.zshrc, \u6216 $PROFILE):
|
|
2741
|
-
${
|
|
2876
|
+
${chalk23.cyan(`export ACTANT_HOME="${actantHome}"`)}`
|
|
2742
2877
|
);
|
|
2743
2878
|
}
|
|
2744
2879
|
return actantHome;
|
|
@@ -2753,45 +2888,36 @@ function ensureDirectoryStructure(base) {
|
|
|
2753
2888
|
import { join as join4 } from "path";
|
|
2754
2889
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
2755
2890
|
import { select as select2, input as input2, password, confirm } from "@inquirer/prompts";
|
|
2756
|
-
import
|
|
2757
|
-
|
|
2758
|
-
anthropic: { protocol: "http", baseUrl: "https://api.anthropic.com", apiKeyEnv: "ANTHROPIC_API_KEY" },
|
|
2759
|
-
openai: { protocol: "http", baseUrl: "https://api.openai.com/v1", apiKeyEnv: "OPENAI_API_KEY" },
|
|
2760
|
-
"openai-compatible": { protocol: "http", baseUrl: "http://localhost:11434/v1", apiKeyEnv: "LLM_API_KEY" },
|
|
2761
|
-
custom: { protocol: "http", baseUrl: "http://localhost:8080", apiKeyEnv: "LLM_API_KEY" }
|
|
2762
|
-
};
|
|
2891
|
+
import chalk24 from "chalk";
|
|
2892
|
+
import { modelProviderRegistry, registerBuiltinProviders } from "@actant/core";
|
|
2763
2893
|
async function configureProvider(printer, actantHome) {
|
|
2764
2894
|
printer.log(`
|
|
2765
|
-
${
|
|
2895
|
+
${chalk24.cyan("[ Step 2/7 ]")} ${chalk24.bold("\u914D\u7F6E Model Provider")}
|
|
2766
2896
|
`);
|
|
2897
|
+
registerBuiltinProviders();
|
|
2898
|
+
const registeredProviders = modelProviderRegistry.list();
|
|
2899
|
+
const choices = registeredProviders.map((p) => ({
|
|
2900
|
+
name: p.displayName,
|
|
2901
|
+
value: p.type
|
|
2902
|
+
}));
|
|
2767
2903
|
const providerType = await select2({
|
|
2768
2904
|
message: "\u9009\u62E9 Model Provider:",
|
|
2769
2905
|
default: "anthropic",
|
|
2770
|
-
choices
|
|
2771
|
-
{ name: "Anthropic (Claude)", value: "anthropic" },
|
|
2772
|
-
{ name: "OpenAI", value: "openai" },
|
|
2773
|
-
{ name: "OpenAI-Compatible (vLLM / Ollama / LM Studio \u7B49)", value: "openai-compatible" },
|
|
2774
|
-
{ name: "Custom", value: "custom" }
|
|
2775
|
-
]
|
|
2906
|
+
choices
|
|
2776
2907
|
});
|
|
2777
|
-
const
|
|
2778
|
-
protocol: "http",
|
|
2779
|
-
baseUrl: "",
|
|
2780
|
-
apiKeyEnv: "LLM_API_KEY"
|
|
2781
|
-
};
|
|
2782
|
-
const defaults = PROVIDER_DEFAULTS[providerType] ?? fallback;
|
|
2908
|
+
const descriptor = modelProviderRegistry.get(providerType);
|
|
2783
2909
|
const protocol = await select2({
|
|
2784
|
-
message: "\u534F\u8BAE\
|
|
2910
|
+
message: "API \u534F\u8BAE\u683C\u5F0F:",
|
|
2785
2911
|
choices: [
|
|
2786
|
-
{ name: "
|
|
2787
|
-
{ name: "
|
|
2788
|
-
{ name: "
|
|
2912
|
+
{ name: "OpenAI Compatible (Chat Completions API)", value: "openai" },
|
|
2913
|
+
{ name: "Anthropic (Messages API)", value: "anthropic" },
|
|
2914
|
+
{ name: "Custom", value: "custom" }
|
|
2789
2915
|
],
|
|
2790
|
-
default:
|
|
2916
|
+
default: descriptor?.protocol ?? "custom"
|
|
2791
2917
|
});
|
|
2792
2918
|
const baseUrl = await input2({
|
|
2793
2919
|
message: "Base URL:",
|
|
2794
|
-
default:
|
|
2920
|
+
default: descriptor?.defaultBaseUrl ?? "http://localhost:8080",
|
|
2795
2921
|
validate: (val) => {
|
|
2796
2922
|
try {
|
|
2797
2923
|
new URL(val);
|
|
@@ -2801,12 +2927,8 @@ ${chalk23.cyan("[ Step 2/7 ]")} ${chalk23.bold("\u914D\u7F6E Model Provider")}
|
|
|
2801
2927
|
}
|
|
2802
2928
|
}
|
|
2803
2929
|
});
|
|
2804
|
-
const apiKeyEnvName = await input2({
|
|
2805
|
-
message: "API Key \u73AF\u5883\u53D8\u91CF\u540D:",
|
|
2806
|
-
default: defaults.apiKeyEnv
|
|
2807
|
-
});
|
|
2808
2930
|
const apiKey = await password({
|
|
2809
|
-
message:
|
|
2931
|
+
message: "API Key:",
|
|
2810
2932
|
mask: "*"
|
|
2811
2933
|
});
|
|
2812
2934
|
if (apiKey) {
|
|
@@ -2815,27 +2937,26 @@ ${chalk23.cyan("[ Step 2/7 ]")} ${chalk23.bold("\u914D\u7F6E Model Provider")}
|
|
|
2815
2937
|
default: true
|
|
2816
2938
|
});
|
|
2817
2939
|
if (shouldValidate) {
|
|
2818
|
-
printer.log(
|
|
2819
|
-
const ok = await validateConnection(
|
|
2940
|
+
printer.log(chalk24.dim(" \u6B63\u5728\u9A8C\u8BC1\u8FDE\u63A5..."));
|
|
2941
|
+
const ok = await validateConnection(protocol, baseUrl, apiKey);
|
|
2820
2942
|
if (ok) {
|
|
2821
|
-
printer.success(" \
|
|
2943
|
+
printer.success(" \u8FDE\u63A5\u9A8C\u8BC1\u6210\u529F");
|
|
2822
2944
|
} else {
|
|
2823
|
-
printer.warn(" \
|
|
2945
|
+
printer.warn(" \u8FDE\u63A5\u9A8C\u8BC1\u5931\u8D25\uFF0C\u914D\u7F6E\u5DF2\u4FDD\u5B58\u4F46\u53EF\u80FD\u9700\u8981\u68C0\u67E5");
|
|
2824
2946
|
}
|
|
2825
2947
|
}
|
|
2826
|
-
printer.warn(
|
|
2827
|
-
` \u8BF7\u786E\u4FDD\u73AF\u5883\u53D8\u91CF ${chalk23.cyan(apiKeyEnvName)} \u5DF2\u8BBE\u7F6E:
|
|
2828
|
-
${chalk23.dim(`export ${apiKeyEnvName}="${apiKey.slice(0, 8)}..."`)}`
|
|
2829
|
-
);
|
|
2830
2948
|
}
|
|
2831
2949
|
const providerConfig = {
|
|
2832
2950
|
type: providerType,
|
|
2833
2951
|
protocol,
|
|
2834
2952
|
baseUrl,
|
|
2835
|
-
|
|
2953
|
+
...apiKey ? { apiKey } : {}
|
|
2836
2954
|
};
|
|
2837
2955
|
saveProviderConfig(actantHome, providerConfig);
|
|
2838
|
-
printer.success(
|
|
2956
|
+
printer.success(`Model Provider \u5DF2\u914D\u7F6E: ${providerType} (${protocol} protocol) \u2192 ${baseUrl}`);
|
|
2957
|
+
if (apiKey) {
|
|
2958
|
+
printer.success(`API Key \u5DF2\u4FDD\u5B58\u5230 ${chalk24.cyan("~/.actant/config.json")}`);
|
|
2959
|
+
}
|
|
2839
2960
|
}
|
|
2840
2961
|
function saveProviderConfig(actantHome, provider) {
|
|
2841
2962
|
const configFile = join4(actantHome, "config.json");
|
|
@@ -2847,9 +2968,9 @@ function saveProviderConfig(actantHome, provider) {
|
|
|
2847
2968
|
config.provider = provider;
|
|
2848
2969
|
writeFileSync3(configFile, JSON.stringify(config, null, 2) + "\n");
|
|
2849
2970
|
}
|
|
2850
|
-
async function validateConnection(
|
|
2971
|
+
async function validateConnection(protocol, baseUrl, apiKey) {
|
|
2851
2972
|
try {
|
|
2852
|
-
if (
|
|
2973
|
+
if (protocol === "anthropic") {
|
|
2853
2974
|
const res2 = await fetch(`${baseUrl}/v1/messages`, {
|
|
2854
2975
|
method: "POST",
|
|
2855
2976
|
headers: {
|
|
@@ -2866,7 +2987,7 @@ async function validateConnection(type, _protocol, baseUrl, apiKey) {
|
|
|
2866
2987
|
});
|
|
2867
2988
|
return res2.status === 200 || res2.status === 400;
|
|
2868
2989
|
}
|
|
2869
|
-
if (
|
|
2990
|
+
if (protocol === "openai") {
|
|
2870
2991
|
const res2 = await fetch(`${baseUrl}/models`, {
|
|
2871
2992
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
2872
2993
|
signal: AbortSignal.timeout(1e4)
|
|
@@ -2885,12 +3006,12 @@ async function validateConnection(type, _protocol, baseUrl, apiKey) {
|
|
|
2885
3006
|
|
|
2886
3007
|
// src/commands/setup/steps/configure-source.ts
|
|
2887
3008
|
import { confirm as confirm2, input as input3, select as select3 } from "@inquirer/prompts";
|
|
2888
|
-
import
|
|
3009
|
+
import chalk25 from "chalk";
|
|
2889
3010
|
var DEFAULT_SOURCE_NAME = "actant-hub";
|
|
2890
3011
|
var DEFAULT_SOURCE_URL = "https://github.com/blackplume233/actant-hub.git";
|
|
2891
3012
|
async function configureSource(printer, client) {
|
|
2892
3013
|
printer.log(`
|
|
2893
|
-
${
|
|
3014
|
+
${chalk25.cyan("[ Step 3/7 ]")} ${chalk25.bold("\u914D\u7F6E\u7EC4\u4EF6\u6E90 (Source)")}
|
|
2894
3015
|
`);
|
|
2895
3016
|
const addDefault = await confirm2({
|
|
2896
3017
|
message: `\u6DFB\u52A0\u5B98\u65B9\u7EC4\u4EF6\u6E90 ${DEFAULT_SOURCE_NAME}?`,
|
|
@@ -2898,7 +3019,7 @@ ${chalk24.cyan("[ Step 3/7 ]")} ${chalk24.bold("\u914D\u7F6E\u7EC4\u4EF6\u6E90 (
|
|
|
2898
3019
|
});
|
|
2899
3020
|
if (addDefault) {
|
|
2900
3021
|
try {
|
|
2901
|
-
printer.log(
|
|
3022
|
+
printer.log(chalk25.dim(` \u6B63\u5728\u6CE8\u518C ${DEFAULT_SOURCE_NAME}...`));
|
|
2902
3023
|
const result = await client.call("source.add", {
|
|
2903
3024
|
name: DEFAULT_SOURCE_NAME,
|
|
2904
3025
|
config: { type: "github", url: DEFAULT_SOURCE_URL, branch: "main" }
|
|
@@ -2982,10 +3103,10 @@ ${chalk24.cyan("[ Step 3/7 ]")} ${chalk24.bold("\u914D\u7F6E\u7EC4\u4EF6\u6E90 (
|
|
|
2982
3103
|
|
|
2983
3104
|
// src/commands/setup/steps/materialize-agent.ts
|
|
2984
3105
|
import { checkbox, input as input4 } from "@inquirer/prompts";
|
|
2985
|
-
import
|
|
3106
|
+
import chalk26 from "chalk";
|
|
2986
3107
|
async function materializeAgent(printer, client) {
|
|
2987
3108
|
printer.log(`
|
|
2988
|
-
${
|
|
3109
|
+
${chalk26.cyan("[ Step 4/7 ]")} ${chalk26.bold("\u9009\u62E9\u5E76\u521B\u5EFA Agent")}
|
|
2989
3110
|
`);
|
|
2990
3111
|
let templates;
|
|
2991
3112
|
try {
|
|
@@ -3023,7 +3144,7 @@ ${chalk25.cyan("[ Step 4/7 ]")} ${chalk25.bold("\u9009\u62E9\u5E76\u521B\u5EFA A
|
|
|
3023
3144
|
}
|
|
3024
3145
|
});
|
|
3025
3146
|
try {
|
|
3026
|
-
printer.log(
|
|
3147
|
+
printer.log(chalk26.dim(` \u6B63\u5728\u521B\u5EFA ${instanceName.trim()}...`));
|
|
3027
3148
|
await client.call("agent.create", {
|
|
3028
3149
|
name: instanceName.trim(),
|
|
3029
3150
|
template: templateName
|
|
@@ -3046,15 +3167,15 @@ import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync3 } from "fs";
|
|
|
3046
3167
|
import { join as join5 } from "path";
|
|
3047
3168
|
import { homedir as homedir3 } from "os";
|
|
3048
3169
|
import { confirm as confirm3 } from "@inquirer/prompts";
|
|
3049
|
-
import
|
|
3170
|
+
import chalk27 from "chalk";
|
|
3050
3171
|
import { isWindows as isWindows2 } from "@actant/shared";
|
|
3051
3172
|
async function configureAutostart(printer) {
|
|
3052
3173
|
printer.log(`
|
|
3053
|
-
${
|
|
3174
|
+
${chalk27.cyan("[ Step 5/7 ]")} ${chalk27.bold("\u914D\u7F6E\u81EA\u52A8\u542F\u52A8")}
|
|
3054
3175
|
`);
|
|
3055
3176
|
const platform = process.platform;
|
|
3056
3177
|
const platformName = platform === "win32" ? "Windows" : platform === "darwin" ? "macOS" : "Linux";
|
|
3057
|
-
printer.log(` \u68C0\u6D4B\u5230\u5E73\u53F0: ${
|
|
3178
|
+
printer.log(` \u68C0\u6D4B\u5230\u5E73\u53F0: ${chalk27.bold(platformName)}`);
|
|
3058
3179
|
const enable = await confirm3({
|
|
3059
3180
|
message: "\u914D\u7F6E Actant Daemon \u5F00\u673A\u81EA\u542F?",
|
|
3060
3181
|
default: true
|
|
@@ -3078,7 +3199,7 @@ ${chalk26.cyan("[ Step 5/7 ]")} ${chalk26.bold("\u914D\u7F6E\u81EA\u52A8\u542F\u
|
|
|
3078
3199
|
}
|
|
3079
3200
|
}
|
|
3080
3201
|
function configureWindows(printer) {
|
|
3081
|
-
printer.log(
|
|
3202
|
+
printer.log(chalk27.dim(" \u6B63\u5728\u6CE8\u518C Windows Task Scheduler \u4EFB\u52A1..."));
|
|
3082
3203
|
const actantPath = findActantExecutable();
|
|
3083
3204
|
const taskXml = `<?xml version="1.0" encoding="UTF-16"?>
|
|
3084
3205
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
@@ -3112,7 +3233,7 @@ function configureWindows(printer) {
|
|
|
3112
3233
|
printer.dim(" \u5DF2\u6CE8\u518C\u4EFB\u52A1: ActantDaemon (\u767B\u5F55\u65F6\u81EA\u52A8\u542F\u52A8)");
|
|
3113
3234
|
}
|
|
3114
3235
|
function configureMacOS(printer) {
|
|
3115
|
-
printer.log(
|
|
3236
|
+
printer.log(chalk27.dim(" \u6B63\u5728\u751F\u6210 launchd plist..."));
|
|
3116
3237
|
const actantPath = findActantExecutable();
|
|
3117
3238
|
const plistDir = join5(homedir3(), "Library", "LaunchAgents");
|
|
3118
3239
|
mkdirSync3(plistDir, { recursive: true });
|
|
@@ -3145,7 +3266,7 @@ function configureMacOS(printer) {
|
|
|
3145
3266
|
printer.dim(` \u5DF2\u52A0\u8F7D: ${plistPath}`);
|
|
3146
3267
|
}
|
|
3147
3268
|
function configureLinux(printer) {
|
|
3148
|
-
printer.log(
|
|
3269
|
+
printer.log(chalk27.dim(" \u6B63\u5728\u751F\u6210 systemd user service..."));
|
|
3149
3270
|
const actantPath = findActantExecutable();
|
|
3150
3271
|
const serviceDir = join5(homedir3(), ".config", "systemd", "user");
|
|
3151
3272
|
mkdirSync3(serviceDir, { recursive: true });
|
|
@@ -3183,10 +3304,10 @@ function findActantExecutable() {
|
|
|
3183
3304
|
}
|
|
3184
3305
|
|
|
3185
3306
|
// src/commands/setup/steps/hello-world.ts
|
|
3186
|
-
import
|
|
3307
|
+
import chalk28 from "chalk";
|
|
3187
3308
|
async function helloWorld(printer, client, createdAgents) {
|
|
3188
3309
|
printer.log(`
|
|
3189
|
-
${
|
|
3310
|
+
${chalk28.cyan("[ Step 6/7 ]")} ${chalk28.bold("Hello World \u9A8C\u8BC1")}
|
|
3190
3311
|
`);
|
|
3191
3312
|
const alive = await client.ping();
|
|
3192
3313
|
if (!alive) {
|
|
@@ -3205,12 +3326,12 @@ ${chalk27.cyan("[ Step 6/7 ]")} ${chalk27.bold("Hello World \u9A8C\u8BC1")}
|
|
|
3205
3326
|
printer.dim(" \u65E0\u53EF\u7528 Agent\uFF0C\u8DF3\u8FC7\u7AEF\u5230\u7AEF\u9A8C\u8BC1");
|
|
3206
3327
|
return;
|
|
3207
3328
|
}
|
|
3208
|
-
printer.log(
|
|
3329
|
+
printer.log(chalk28.dim(` \u6B63\u5728\u4F7F\u7528 Agent "${testAgent}" \u8FDB\u884C\u9A8C\u8BC1...`));
|
|
3209
3330
|
try {
|
|
3210
3331
|
await client.call("agent.start", { name: testAgent });
|
|
3211
3332
|
printer.success(` \u2713 Agent "${testAgent}" \u5DF2\u542F\u52A8`);
|
|
3212
3333
|
await waitForAgentReady(client, testAgent, 15e3);
|
|
3213
|
-
printer.log(
|
|
3334
|
+
printer.log(chalk28.dim(` \u53D1\u9001\u6D4B\u8BD5\u6D88\u606F: "Hello, World!"`));
|
|
3214
3335
|
const runResult = await client.call("agent.run", {
|
|
3215
3336
|
name: testAgent,
|
|
3216
3337
|
prompt: "Please respond with exactly: Hello from Actant! (keep it short)"
|
|
@@ -3249,7 +3370,7 @@ async function waitForAgentReady(client, name, timeoutMs) {
|
|
|
3249
3370
|
import { join as join6 } from "path";
|
|
3250
3371
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync5, existsSync as existsSync4 } from "fs";
|
|
3251
3372
|
import { confirm as confirm4, input as input5 } from "@inquirer/prompts";
|
|
3252
|
-
import
|
|
3373
|
+
import chalk29 from "chalk";
|
|
3253
3374
|
function detectDevSourcePath() {
|
|
3254
3375
|
const candidates = [
|
|
3255
3376
|
process.cwd(),
|
|
@@ -3264,7 +3385,7 @@ function detectDevSourcePath() {
|
|
|
3264
3385
|
}
|
|
3265
3386
|
async function configureUpdate(printer, actantHome) {
|
|
3266
3387
|
printer.log(`
|
|
3267
|
-
${
|
|
3388
|
+
${chalk29.cyan("[ Step 7/7 ]")} ${chalk29.bold("\u66F4\u65B0\u9009\u9879")}
|
|
3268
3389
|
`);
|
|
3269
3390
|
const wantConfigure = await confirm4({
|
|
3270
3391
|
message: "\u914D\u7F6E\u81EA\u52A8\u66F4\u65B0\u6E90? (\u7528\u4E8E\u4ECE\u672C\u5730\u6E90\u7801\u66F4\u65B0 Actant)",
|
|
@@ -3295,14 +3416,14 @@ ${chalk28.cyan("[ Step 7/7 ]")} ${chalk28.bold("\u66F4\u65B0\u9009\u9879")}
|
|
|
3295
3416
|
function printUpdateHelp(printer) {
|
|
3296
3417
|
printer.log("");
|
|
3297
3418
|
printer.dim(" \u66F4\u65B0\u547D\u4EE4:");
|
|
3298
|
-
printer.dim(` ${
|
|
3299
|
-
printer.dim(` ${
|
|
3300
|
-
printer.dim(` ${
|
|
3419
|
+
printer.dim(` ${chalk29.cyan("actant self-update")} \u4ECE\u6E90\u7801\u6784\u5EFA\u5E76\u66F4\u65B0`);
|
|
3420
|
+
printer.dim(` ${chalk29.cyan("actant self-update --check")} \u68C0\u67E5\u7248\u672C\u5DEE\u5F02`);
|
|
3421
|
+
printer.dim(` ${chalk29.cyan("npm install -g @actant/cli")} \u4ECE npm \u66F4\u65B0`);
|
|
3301
3422
|
}
|
|
3302
3423
|
|
|
3303
3424
|
// src/commands/setup/setup.ts
|
|
3304
3425
|
function createSetupCommand(printer = defaultPrinter) {
|
|
3305
|
-
return new
|
|
3426
|
+
return new Command74("setup").description("Interactive setup wizard \u2014 configure Actant step by step").option("--skip-home", "Skip work directory selection").option("--skip-provider", "Skip model provider configuration").option("--skip-source", "Skip component source configuration").option("--skip-agent", "Skip agent creation").option("--skip-autostart", "Skip auto-start configuration").option("--skip-hello", "Skip hello world verification").option("--skip-update", "Skip update options").action(async (opts) => {
|
|
3306
3427
|
try {
|
|
3307
3428
|
printBanner(printer);
|
|
3308
3429
|
let actantHome;
|
|
@@ -3334,7 +3455,7 @@ function createSetupCommand(printer = defaultPrinter) {
|
|
|
3334
3455
|
client = new RpcClient(socketPath);
|
|
3335
3456
|
const alive = await client.ping();
|
|
3336
3457
|
if (!alive) {
|
|
3337
|
-
printer.log(
|
|
3458
|
+
printer.log(chalk30.dim("\n \u6B63\u5728\u542F\u52A8 Daemon..."));
|
|
3338
3459
|
daemonStartedBySetup = await tryStartDaemon(printer, socketPath);
|
|
3339
3460
|
if (!daemonStartedBySetup) {
|
|
3340
3461
|
printer.warn(" \u26A0 \u65E0\u6CD5\u81EA\u52A8\u542F\u52A8 Daemon\uFF0C\u8DF3\u8FC7\u9700\u8981 Daemon \u7684\u6B65\u9AA4");
|
|
@@ -3364,7 +3485,7 @@ function createSetupCommand(printer = defaultPrinter) {
|
|
|
3364
3485
|
printSummary(printer, actantHome);
|
|
3365
3486
|
} catch (err) {
|
|
3366
3487
|
if (isUserCancellation(err)) {
|
|
3367
|
-
printer.log(
|
|
3488
|
+
printer.log(chalk30.dim("\n \u5DF2\u53D6\u6D88\u8BBE\u7F6E\u5411\u5BFC"));
|
|
3368
3489
|
return;
|
|
3369
3490
|
}
|
|
3370
3491
|
presentError(err, printer);
|
|
@@ -3374,25 +3495,25 @@ function createSetupCommand(printer = defaultPrinter) {
|
|
|
3374
3495
|
}
|
|
3375
3496
|
function printBanner(printer) {
|
|
3376
3497
|
printer.log("");
|
|
3377
|
-
printer.log(
|
|
3378
|
-
printer.log(
|
|
3379
|
-
printer.log(
|
|
3380
|
-
printer.log(
|
|
3498
|
+
printer.log(chalk30.cyan("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
|
|
3499
|
+
printer.log(chalk30.cyan("\u2551") + chalk30.bold(" Actant Setup Wizard ") + chalk30.cyan("\u2551"));
|
|
3500
|
+
printer.log(chalk30.cyan("\u2551") + chalk30.dim(" Build, manage, and compose AI agents ") + chalk30.cyan("\u2551"));
|
|
3501
|
+
printer.log(chalk30.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
|
|
3381
3502
|
}
|
|
3382
3503
|
function printSummary(printer, actantHome) {
|
|
3383
3504
|
printer.log("");
|
|
3384
|
-
printer.log(
|
|
3385
|
-
printer.log(
|
|
3386
|
-
printer.log(
|
|
3505
|
+
printer.log(chalk30.green("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"));
|
|
3506
|
+
printer.log(chalk30.green.bold(" Setup Complete!"));
|
|
3507
|
+
printer.log(chalk30.green("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"));
|
|
3387
3508
|
printer.log("");
|
|
3388
3509
|
printer.dim(` \u5DE5\u4F5C\u76EE\u5F55: ${actantHome}`);
|
|
3389
3510
|
printer.log("");
|
|
3390
3511
|
printer.log(" \u5FEB\u901F\u5F00\u59CB:");
|
|
3391
|
-
printer.log(` ${
|
|
3392
|
-
printer.log(` ${
|
|
3393
|
-
printer.log(` ${
|
|
3394
|
-
printer.log(` ${
|
|
3395
|
-
printer.log(` ${
|
|
3512
|
+
printer.log(` ${chalk30.cyan("actant daemon start")} \u542F\u52A8 Daemon`);
|
|
3513
|
+
printer.log(` ${chalk30.cyan("actant template list")} \u6D4F\u89C8\u6A21\u677F`);
|
|
3514
|
+
printer.log(` ${chalk30.cyan("actant agent list")} \u67E5\u770B Agent`);
|
|
3515
|
+
printer.log(` ${chalk30.cyan("actant agent chat <n>")} \u4E0E Agent \u5BF9\u8BDD`);
|
|
3516
|
+
printer.log(` ${chalk30.cyan("actant setup")} \u91CD\u65B0\u8FD0\u884C\u6B64\u5411\u5BFC`);
|
|
3396
3517
|
printer.log("");
|
|
3397
3518
|
printer.dim(" \u66F4\u591A\u5E2E\u52A9: actant help");
|
|
3398
3519
|
printer.log("");
|
|
@@ -3455,7 +3576,7 @@ function createProgram(socketPath, printer) {
|
|
|
3455
3576
|
const client = new RpcClient(sock);
|
|
3456
3577
|
const pkgPath = join7(import.meta.dirname, "..", "package.json");
|
|
3457
3578
|
const { version } = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
3458
|
-
const program = new
|
|
3579
|
+
const program = new Command75("actant").version(version).description("Actant \u2014 Build, manage, and compose AI agents");
|
|
3459
3580
|
program.addCommand(createTemplateCommand(client, printer));
|
|
3460
3581
|
program.addCommand(createAgentCommand(client, printer));
|
|
3461
3582
|
program.addCommand(createSkillCommand(client, printer));
|
|
@@ -3483,7 +3604,7 @@ async function run(argv) {
|
|
|
3483
3604
|
if (!versionRequested && !helpRequested) {
|
|
3484
3605
|
const sock = defaultSocketPath();
|
|
3485
3606
|
const client = new RpcClient(sock);
|
|
3486
|
-
const { startRepl } = await import("./repl-
|
|
3607
|
+
const { startRepl } = await import("./repl-G44PJKXP.js");
|
|
3487
3608
|
await startRepl(client, sock);
|
|
3488
3609
|
return;
|
|
3489
3610
|
}
|
|
@@ -3512,4 +3633,4 @@ export {
|
|
|
3512
3633
|
createProgram,
|
|
3513
3634
|
run
|
|
3514
3635
|
};
|
|
3515
|
-
//# sourceMappingURL=chunk-
|
|
3636
|
+
//# sourceMappingURL=chunk-FB4IUVWU.js.map
|