arcie 0.1.6 → 0.1.8
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/_tsup-dts-rollup.d.ts +2280 -0
- package/dist/agent/index.d.ts +1 -6
- package/dist/auth/index.d.ts +4 -11
- package/dist/channels/index.d.ts +3 -8
- package/dist/cli/index.d.ts +1 -8
- package/dist/cli/index.js +2 -2
- package/dist/context/index.d.ts +9 -14
- package/dist/{dev-ZZDVOWUZ.js → dev-DCPOO54H.js} +298 -70
- package/dist/dev-DCPOO54H.js.map +1 -0
- package/dist/discover/index.d.ts +6 -41
- package/dist/hooks/index.d.ts +1 -6
- package/dist/index.d.ts +113 -297
- package/dist/{init-5F7CIVLN.js → init-Q2GCMBCJ.js} +6 -6
- package/dist/instructions/index.d.ts +2 -7
- package/dist/protocol/events.d.ts +44 -200
- package/dist/runner/index.d.ts +4 -4
- package/dist/schedules/index.d.ts +1 -6
- package/dist/skills/index.d.ts +2 -7
- package/dist/tools/index.d.ts +3 -13
- package/package.json +3 -1
- package/dist/dev-ZZDVOWUZ.js.map +0 -1
- package/dist/index-CElLRVTP.d.ts +0 -136
- package/dist/types-DwxwdSa2.d.ts +0 -151
- /package/dist/{init-5F7CIVLN.js.map → init-Q2GCMBCJ.js.map} +0 -0
package/dist/agent/index.d.ts
CHANGED
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
declare function bearer(token: TokenValue): OutboundAuthFn;
|
|
6
|
-
declare function basic(input: {
|
|
7
|
-
username: string;
|
|
8
|
-
password: TokenValue;
|
|
9
|
-
}): OutboundAuthFn;
|
|
10
|
-
|
|
11
|
-
export { type OutboundAuthFn, type TokenValue, basic, bearer };
|
|
1
|
+
export { bearer_alias_1 as bearer } from '../_tsup-dts-rollup.js';
|
|
2
|
+
export { basic_alias_1 as basic } from '../_tsup-dts-rollup.js';
|
|
3
|
+
export { TokenValue_alias_1 as TokenValue } from '../_tsup-dts-rollup.js';
|
|
4
|
+
export { OutboundAuthFn_alias_1 as OutboundAuthFn } from '../_tsup-dts-rollup.js';
|
package/dist/channels/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare function defineChannel(config: ChannelConfig): ChannelConfig;
|
|
5
|
-
declare function POST(handler: ChannelConfig["handler"]): ChannelConfig["handler"];
|
|
6
|
-
declare function GET(handler: ChannelConfig["handler"]): ChannelConfig["handler"];
|
|
7
|
-
|
|
8
|
-
export { GET, POST, defineChannel };
|
|
1
|
+
export { defineChannel_alias_1 as defineChannel } from '../_tsup-dts-rollup.js';
|
|
2
|
+
export { POST_alias_1 as POST } from '../_tsup-dts-rollup.js';
|
|
3
|
+
export { GET_alias_1 as GET } from '../_tsup-dts-rollup.js';
|
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function createCliProgram(logger) {
|
|
|
105
105
|
});
|
|
106
106
|
program.command("init [target]").description("Create a new arcie agent, or add one to an existing project directory.").option("--template <name>", "Template to use (default, agent-only)", "default").option("-y, --yes", "Accepted for compatibility; has no effect").action(async (target, options) => {
|
|
107
107
|
if (options.yes) logger.error("warning: --yes has no effect for arcie init.");
|
|
108
|
-
const { initCommand } = await import("../init-
|
|
108
|
+
const { initCommand } = await import("../init-Q2GCMBCJ.js");
|
|
109
109
|
await initCommand(target, { template: options.template });
|
|
110
110
|
});
|
|
111
111
|
program.command("build").description("Compile the agent for production.").option("--agent-dir <path>", "Path to agent directory", "agent").option("--out-dir <path>", "Output directory", ".arcie").action(async (options) => {
|
|
@@ -140,7 +140,7 @@ function createCliProgram(logger) {
|
|
|
140
140
|
"Model context window size, shown as a usage percentage",
|
|
141
141
|
parseContextSizeOption
|
|
142
142
|
).option("--logs <mode>", "Which logs to show: all | stderr | none", parseLogsMode).action(async (options) => {
|
|
143
|
-
const { devCommand } = await import("../dev-
|
|
143
|
+
const { devCommand } = await import("../dev-DCPOO54H.js");
|
|
144
144
|
await devCommand({
|
|
145
145
|
port: String(options.port ?? 3e3),
|
|
146
146
|
agentDir: options.agentDir,
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare function hasContext(key: string): boolean;
|
|
11
|
-
declare function setContext(key: string, value: unknown): void;
|
|
12
|
-
declare function ensureContext<T>(key: string, factory: () => T): T;
|
|
13
|
-
|
|
14
|
-
export { ensureContext, getContext, getSession, getTurn, hasContext, requireContext, setContext, setSession, setTurn };
|
|
1
|
+
export { getSession_alias_1 as getSession } from '../_tsup-dts-rollup.js';
|
|
2
|
+
export { getTurn_alias_1 as getTurn } from '../_tsup-dts-rollup.js';
|
|
3
|
+
export { setSession_alias_1 as setSession } from '../_tsup-dts-rollup.js';
|
|
4
|
+
export { setTurn_alias_1 as setTurn } from '../_tsup-dts-rollup.js';
|
|
5
|
+
export { getContext_alias_1 as getContext } from '../_tsup-dts-rollup.js';
|
|
6
|
+
export { requireContext_alias_1 as requireContext } from '../_tsup-dts-rollup.js';
|
|
7
|
+
export { hasContext_alias_1 as hasContext } from '../_tsup-dts-rollup.js';
|
|
8
|
+
export { setContext_alias_1 as setContext } from '../_tsup-dts-rollup.js';
|
|
9
|
+
export { ensureContext_alias_1 as ensureContext } from '../_tsup-dts-rollup.js';
|
|
@@ -20,6 +20,9 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
showHeader
|
|
22
22
|
} from "./chunk-XOFWQUOO.js";
|
|
23
|
+
import {
|
|
24
|
+
scaffoldWebChat
|
|
25
|
+
} from "./chunk-SGWQZZ2A.js";
|
|
23
26
|
import {
|
|
24
27
|
streamAgent
|
|
25
28
|
} from "./chunk-4WSILP75.js";
|
|
@@ -39,6 +42,89 @@ import { resolve } from "path";
|
|
|
39
42
|
// src/cli/tui/renderer/start-block-chat.ts
|
|
40
43
|
import { watch } from "fs";
|
|
41
44
|
|
|
45
|
+
// src/cli/agent-config.ts
|
|
46
|
+
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
|
|
47
|
+
import { join } from "path";
|
|
48
|
+
function agentSourcePath(agentDir) {
|
|
49
|
+
return join(agentDir, "agent", "agent.ts");
|
|
50
|
+
}
|
|
51
|
+
function envLocalPath(agentDir) {
|
|
52
|
+
return join(agentDir, ".env.local");
|
|
53
|
+
}
|
|
54
|
+
function readAgentModel(agentDir) {
|
|
55
|
+
const path = agentSourcePath(agentDir);
|
|
56
|
+
if (!existsSync(path)) return void 0;
|
|
57
|
+
try {
|
|
58
|
+
const content = readFileSync(path, "utf-8");
|
|
59
|
+
return content.match(/model:\s*"([^"]+)"/)?.[1];
|
|
60
|
+
} catch {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function writeAgentModel(agentDir, model) {
|
|
65
|
+
const path = agentSourcePath(agentDir);
|
|
66
|
+
if (!existsSync(path)) return false;
|
|
67
|
+
const content = readFileSync(path, "utf-8");
|
|
68
|
+
const updated = content.replace(/model:\s*"[^"]+"/, `model: "${model}"`);
|
|
69
|
+
if (updated === content) return false;
|
|
70
|
+
writeFileSync(path, updated);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
var PROVIDER_KEYS = [
|
|
74
|
+
"CENCORI_API_KEY",
|
|
75
|
+
"OPENAI_API_KEY",
|
|
76
|
+
"ANTHROPIC_API_KEY",
|
|
77
|
+
"GROQ_API_KEY",
|
|
78
|
+
"DEEPSEEK_API_KEY",
|
|
79
|
+
"MISTRAL_API_KEY",
|
|
80
|
+
"GOOGLE_API_KEY",
|
|
81
|
+
"TOGETHER_API_KEY"
|
|
82
|
+
];
|
|
83
|
+
function providerKeyStatus(agentDir) {
|
|
84
|
+
const fileValues = readEnvLocal(agentDir);
|
|
85
|
+
return PROVIDER_KEYS.map((key) => {
|
|
86
|
+
const envValue = process.env[key];
|
|
87
|
+
if (envValue && envValue.length > 0) {
|
|
88
|
+
return { key, set: true, source: "env", masked: maskSecret(envValue) };
|
|
89
|
+
}
|
|
90
|
+
const fileValue = fileValues[key];
|
|
91
|
+
if (fileValue && fileValue.length > 0) {
|
|
92
|
+
return { key, set: true, source: "file", masked: maskSecret(fileValue) };
|
|
93
|
+
}
|
|
94
|
+
return { key, set: false };
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function readEnvLocal(agentDir) {
|
|
98
|
+
const envPath = envLocalPath(agentDir);
|
|
99
|
+
if (!existsSync(envPath)) return {};
|
|
100
|
+
const values = {};
|
|
101
|
+
for (const line of readFileSync(envPath, "utf-8").split("\n")) {
|
|
102
|
+
const trimmed = line.trim();
|
|
103
|
+
if (trimmed.startsWith("#") || !trimmed.includes("=")) continue;
|
|
104
|
+
const eq = trimmed.indexOf("=");
|
|
105
|
+
const key = trimmed.slice(0, eq).trim();
|
|
106
|
+
const value = trimmed.slice(eq + 1).trim();
|
|
107
|
+
if (key && value) values[key] = value;
|
|
108
|
+
}
|
|
109
|
+
return values;
|
|
110
|
+
}
|
|
111
|
+
function listChannels(agentDir) {
|
|
112
|
+
const channelsDir = join(agentDir, "channels");
|
|
113
|
+
if (!existsSync(channelsDir)) return [];
|
|
114
|
+
try {
|
|
115
|
+
return readdirSync(channelsDir).filter((entry) => {
|
|
116
|
+
const full = join(channelsDir, entry);
|
|
117
|
+
return statSync(full).isDirectory();
|
|
118
|
+
}).map((name) => ({ name, path: join(channelsDir, name) }));
|
|
119
|
+
} catch {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function maskSecret(value) {
|
|
124
|
+
if (value.length <= 8) return "\u2022".repeat(value.length);
|
|
125
|
+
return `${value.slice(0, 4)}${"\u2022".repeat(6)}${value.slice(-4)}`;
|
|
126
|
+
}
|
|
127
|
+
|
|
42
128
|
// src/cli/tui/prompt-commands.ts
|
|
43
129
|
var PROMPT_COMMAND_DEFINITIONS = [
|
|
44
130
|
{
|
|
@@ -65,24 +151,25 @@ var PROMPT_COMMAND_DEFINITIONS = [
|
|
|
65
151
|
{
|
|
66
152
|
name: "model",
|
|
67
153
|
aliases: [],
|
|
68
|
-
description: "
|
|
69
|
-
argumentHint: "[provider/
|
|
154
|
+
description: "Show or change the agent's model",
|
|
155
|
+
argumentHint: "[provider/slug]",
|
|
70
156
|
takesArgument: true,
|
|
71
157
|
build: (argument) => ({ type: "extension", name: "model", argument })
|
|
72
158
|
},
|
|
73
159
|
{
|
|
74
160
|
name: "provider",
|
|
75
161
|
aliases: [],
|
|
76
|
-
description: "
|
|
162
|
+
description: "Show provider API key status",
|
|
77
163
|
takesArgument: false,
|
|
78
164
|
build: () => ({ type: "extension", name: "provider", argument: "" })
|
|
79
165
|
},
|
|
80
166
|
{
|
|
81
167
|
name: "channels",
|
|
82
168
|
aliases: [],
|
|
83
|
-
description: "
|
|
84
|
-
|
|
85
|
-
|
|
169
|
+
description: "List or add chat channels",
|
|
170
|
+
argumentHint: "[add web]",
|
|
171
|
+
takesArgument: true,
|
|
172
|
+
build: (argument) => ({ type: "extension", name: "channels", argument })
|
|
86
173
|
},
|
|
87
174
|
{
|
|
88
175
|
name: "loglevel",
|
|
@@ -1097,6 +1184,7 @@ var TerminalRenderer = class {
|
|
|
1097
1184
|
};
|
|
1098
1185
|
|
|
1099
1186
|
// src/cli/tui/renderer/start-block-chat.ts
|
|
1187
|
+
var VALID_LOG_MODES = /* @__PURE__ */ new Set(["all", "stderr", "none"]);
|
|
1100
1188
|
async function startBlockChat(options) {
|
|
1101
1189
|
const { agentDir } = options;
|
|
1102
1190
|
const renderer = new TerminalRenderer();
|
|
@@ -1131,6 +1219,7 @@ async function startBlockChat(options) {
|
|
|
1131
1219
|
} catch {
|
|
1132
1220
|
}
|
|
1133
1221
|
const detachKeys = attachKeyStream((key) => renderer.handleKey(key));
|
|
1222
|
+
const logLevelState = { mode: "none" };
|
|
1134
1223
|
try {
|
|
1135
1224
|
if (options.initialInput !== void 0 && options.initialInput.length > 0) {
|
|
1136
1225
|
await streamOneTurn(renderer, translator, agentDir, options.initialInput);
|
|
@@ -1160,10 +1249,10 @@ async function startBlockChat(options) {
|
|
|
1160
1249
|
await commitHeader();
|
|
1161
1250
|
continue;
|
|
1162
1251
|
case "extension":
|
|
1163
|
-
|
|
1252
|
+
await handleExtension(command, renderer, agentDir, commitHeader);
|
|
1164
1253
|
continue;
|
|
1165
1254
|
case "loglevel":
|
|
1166
|
-
|
|
1255
|
+
handleLogLevel(command, renderer, logLevelState);
|
|
1167
1256
|
continue;
|
|
1168
1257
|
}
|
|
1169
1258
|
continue;
|
|
@@ -1176,6 +1265,121 @@ async function startBlockChat(options) {
|
|
|
1176
1265
|
renderer.stop();
|
|
1177
1266
|
}
|
|
1178
1267
|
}
|
|
1268
|
+
async function handleExtension(command, renderer, agentDir, commitHeader) {
|
|
1269
|
+
const argument = command.argument.trim();
|
|
1270
|
+
switch (command.name) {
|
|
1271
|
+
case "model":
|
|
1272
|
+
await handleModel(argument, renderer, agentDir, commitHeader);
|
|
1273
|
+
return;
|
|
1274
|
+
case "provider":
|
|
1275
|
+
handleProvider(renderer, agentDir);
|
|
1276
|
+
return;
|
|
1277
|
+
case "channels":
|
|
1278
|
+
handleChannels(argument, renderer, agentDir);
|
|
1279
|
+
return;
|
|
1280
|
+
default:
|
|
1281
|
+
renderer.writeNotice(`/${command.name} is not supported here`);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
async function handleModel(argument, renderer, agentDir, commitHeader) {
|
|
1285
|
+
const current = readAgentModel(agentDir);
|
|
1286
|
+
if (argument.length === 0) {
|
|
1287
|
+
renderer.writeNotice(
|
|
1288
|
+
current ? `current model: ${current}` : "no model configured in agent/agent.ts"
|
|
1289
|
+
);
|
|
1290
|
+
renderer.writeNotice("change it with: /model <provider/slug>");
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
if (current === argument) {
|
|
1294
|
+
renderer.writeNotice(`model is already ${argument}`);
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
const changed = writeAgentModel(agentDir, argument);
|
|
1298
|
+
if (!changed) {
|
|
1299
|
+
renderer.writeError(
|
|
1300
|
+
"Model not changed",
|
|
1301
|
+
"Could not update agent/agent.ts \u2014 file missing or model field not found."
|
|
1302
|
+
);
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
renderer.writeNotice(`model set to ${argument}`);
|
|
1306
|
+
await commitHeader();
|
|
1307
|
+
}
|
|
1308
|
+
function handleProvider(renderer, agentDir) {
|
|
1309
|
+
const status = providerKeyStatus(agentDir);
|
|
1310
|
+
const configured = status.filter((row) => row.set);
|
|
1311
|
+
if (configured.length === 0) {
|
|
1312
|
+
renderer.writeNotice("no provider keys configured");
|
|
1313
|
+
renderer.writeNotice("edit .env.local to add CENCORI_API_KEY or a direct provider key");
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
renderer.writeNotice("provider keys:");
|
|
1317
|
+
for (const row of status) {
|
|
1318
|
+
if (row.set) {
|
|
1319
|
+
renderer.writeNotice(` ${row.key} = ${row.masked} (${row.source})`);
|
|
1320
|
+
} else {
|
|
1321
|
+
renderer.writeNotice(` ${row.key} \u2014 not set`);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
function handleChannels(argument, renderer, agentDir) {
|
|
1326
|
+
if (argument.length === 0) {
|
|
1327
|
+
const channels = listChannels(agentDir);
|
|
1328
|
+
if (channels.length === 0) {
|
|
1329
|
+
renderer.writeNotice("no channels scaffolded");
|
|
1330
|
+
renderer.writeNotice("add one with: /channels add web");
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
renderer.writeNotice("channels:");
|
|
1334
|
+
for (const channel of channels) renderer.writeNotice(` ${channel.name} \u2014 ${channel.path}`);
|
|
1335
|
+
renderer.writeNotice("add another with: /channels add <kind>");
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
const parts = argument.split(/\s+/);
|
|
1339
|
+
const subcommand = parts[0];
|
|
1340
|
+
const kind = parts[1];
|
|
1341
|
+
if (subcommand !== "add") {
|
|
1342
|
+
renderer.writeError("Unknown /channels subcommand", `try: /channels add web`);
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
if (kind !== "web") {
|
|
1346
|
+
renderer.writeError("Unsupported channel kind", `${kind ?? "(none)"} \u2014 only 'web' is supported`);
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
try {
|
|
1350
|
+
const result = scaffoldWebChat(agentDir);
|
|
1351
|
+
if (result.alreadyExisted) {
|
|
1352
|
+
renderer.writeNotice(`channels/web already exists \u2014 left it untouched`);
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
renderer.writeNotice(`scaffolded ${result.targetPath}`);
|
|
1356
|
+
renderer.writeNotice("next: cd into it, npm install, npm run dev");
|
|
1357
|
+
} catch (err) {
|
|
1358
|
+
renderer.writeError(
|
|
1359
|
+
"Channel scaffold failed",
|
|
1360
|
+
err instanceof Error ? err.message : String(err)
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
function handleLogLevel(command, renderer, state) {
|
|
1365
|
+
const argument = command.argument.trim();
|
|
1366
|
+
if (argument.length === 0) {
|
|
1367
|
+
renderer.writeNotice(`log level: ${state.mode}`);
|
|
1368
|
+
renderer.writeNotice("change with: /loglevel all | stderr | none");
|
|
1369
|
+
renderer.writeNotice("note: arcie does not currently capture subprocess logs.");
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
if (!VALID_LOG_MODES.has(argument)) {
|
|
1373
|
+
renderer.writeError(
|
|
1374
|
+
"Invalid log level",
|
|
1375
|
+
`${argument} \u2014 pick one of: all, stderr, none`
|
|
1376
|
+
);
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
state.mode = argument;
|
|
1380
|
+
renderer.writeNotice(`log level: ${state.mode}`);
|
|
1381
|
+
renderer.writeNotice("note: arcie does not currently capture subprocess logs.");
|
|
1382
|
+
}
|
|
1179
1383
|
async function streamOneTurn(renderer, translator, agentDir, message) {
|
|
1180
1384
|
let sawApproval = false;
|
|
1181
1385
|
try {
|
|
@@ -1859,51 +2063,40 @@ function checkProviderKeys(modelId) {
|
|
|
1859
2063
|
}
|
|
1860
2064
|
return missing;
|
|
1861
2065
|
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
for (const d of diagnostics) {
|
|
1882
|
-
console.warn(` ${grey("\u26A0")} ${d.code}: ${d.message}`);
|
|
1883
|
-
}
|
|
2066
|
+
var MAX_PORT_ATTEMPTS = 10;
|
|
2067
|
+
function tryListen(server, port) {
|
|
2068
|
+
return new Promise((resolve2, reject) => {
|
|
2069
|
+
const onError = (err) => {
|
|
2070
|
+
server.removeListener("listening", onListening);
|
|
2071
|
+
reject(err);
|
|
2072
|
+
};
|
|
2073
|
+
const onListening = () => {
|
|
2074
|
+
server.removeListener("error", onError);
|
|
2075
|
+
resolve2();
|
|
2076
|
+
};
|
|
2077
|
+
server.once("error", onError);
|
|
2078
|
+
server.once("listening", onListening);
|
|
2079
|
+
server.listen(port);
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
async function listenWithFallback(server, startPort) {
|
|
2083
|
+
for (let offset = 0; offset < MAX_PORT_ATTEMPTS; offset += 1) {
|
|
2084
|
+
const port = startPort + offset;
|
|
1884
2085
|
try {
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
console.log(` ${dimmed(`$ curl -X POST http://localhost:${port} \\`)}`);
|
|
1891
|
-
console.log(` ${dimmed(` -H "Content-Type: application/json" \\`)}`);
|
|
1892
|
-
console.log(` ${dimmed(` -d '{"message": "hello"}'`)}`);
|
|
1893
|
-
console.log();
|
|
1894
|
-
const missing = checkProviderKeys(agent.manifest.config.model);
|
|
1895
|
-
if (missing.length > 0) {
|
|
1896
|
-
console.log(` ${grey("\u26A0")} Missing API keys: ${missing.join(", ")}`);
|
|
1897
|
-
console.log(` ${dimmed(" Set them in .env.local or your environment")}`);
|
|
1898
|
-
console.log();
|
|
1899
|
-
}
|
|
1900
|
-
} catch {
|
|
1901
|
-
console.log(` ${agentDirPath}`);
|
|
1902
|
-
console.log();
|
|
1903
|
-
console.log(` ${dimmed(`http://localhost:${port}`)}`);
|
|
1904
|
-
console.log();
|
|
2086
|
+
await tryListen(server, port);
|
|
2087
|
+
return port;
|
|
2088
|
+
} catch (err) {
|
|
2089
|
+
const code = err.code;
|
|
2090
|
+
if (code !== "EADDRINUSE") throw err;
|
|
1905
2091
|
}
|
|
1906
2092
|
}
|
|
2093
|
+
throw new Error(
|
|
2094
|
+
`Could not find a free port in ${startPort}..${startPort + MAX_PORT_ATTEMPTS - 1}`
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2097
|
+
async function devCommand(options) {
|
|
2098
|
+
const agentDirPath = resolve(process.cwd(), options.agentDir);
|
|
2099
|
+
const requestedPort = parseInt(options.port, 10);
|
|
1907
2100
|
const server = createServer(async (req, res) => {
|
|
1908
2101
|
if (await handleSessionsRequest(req, res)) {
|
|
1909
2102
|
return;
|
|
@@ -1938,30 +2131,65 @@ async function devCommand(options) {
|
|
|
1938
2131
|
res.end("Not found");
|
|
1939
2132
|
}
|
|
1940
2133
|
});
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
console.error();
|
|
1950
|
-
console.error(` ${grey("\u2717")} ${err.message}`);
|
|
1951
|
-
console.error();
|
|
1952
|
-
}
|
|
2134
|
+
let boundPort;
|
|
2135
|
+
try {
|
|
2136
|
+
boundPort = await listenWithFallback(server, requestedPort);
|
|
2137
|
+
} catch (err) {
|
|
2138
|
+
console.error();
|
|
2139
|
+
console.error(` ${grey("\u2717")} ${err instanceof Error ? err.message : String(err)}`);
|
|
2140
|
+
console.error(` ${dimmed("try: arcie dev --port <n> # pick your own starting port")}`);
|
|
2141
|
+
console.error();
|
|
1953
2142
|
process.exit(1);
|
|
1954
|
-
}
|
|
2143
|
+
}
|
|
2144
|
+
const localApiUrl = `http://127.0.0.1:${boundPort}/v1`;
|
|
2145
|
+
if (!process.env.CENCORI_API_KEY) process.env.CENCORI_API_KEY = "local-dev-key";
|
|
2146
|
+
if (!process.env.CENCORI_API_URL) process.env.CENCORI_API_URL = localApiUrl;
|
|
2147
|
+
if (!options.input) {
|
|
2148
|
+
showHeader();
|
|
2149
|
+
const { diagnostics } = discoverAgent(agentDirPath);
|
|
2150
|
+
if (diagnostics.some((d) => d.severity === "error")) {
|
|
2151
|
+
for (const d of diagnostics) {
|
|
2152
|
+
console.error(` ${grey("\u2716")} ${d.code}: ${d.message}`);
|
|
2153
|
+
}
|
|
2154
|
+
process.exit(1);
|
|
2155
|
+
}
|
|
2156
|
+
for (const d of diagnostics) {
|
|
2157
|
+
console.warn(` ${grey("\u26A0")} ${d.code}: ${d.message}`);
|
|
2158
|
+
}
|
|
2159
|
+
try {
|
|
2160
|
+
const agent = await loadAgent(agentDirPath);
|
|
2161
|
+
console.log(` ${agentDirPath} ${grey("\xB7")} ${grey(agent.manifest.config.model)}`);
|
|
2162
|
+
console.log();
|
|
2163
|
+
if (boundPort !== requestedPort) {
|
|
2164
|
+
console.log(
|
|
2165
|
+
` ${grey("!")} port ${requestedPort} was in use ${grey("\xB7")} using ${boundPort}`
|
|
2166
|
+
);
|
|
2167
|
+
console.log();
|
|
2168
|
+
}
|
|
2169
|
+
console.log(` ${dimmed(`http://localhost:${boundPort}`)}`);
|
|
2170
|
+
console.log();
|
|
2171
|
+
console.log(` ${dimmed(`$ curl -X POST http://localhost:${boundPort} \\`)}`);
|
|
2172
|
+
console.log(` ${dimmed(` -H "Content-Type: application/json" \\`)}`);
|
|
2173
|
+
console.log(` ${dimmed(` -d '{"message": "hello"}'`)}`);
|
|
2174
|
+
console.log();
|
|
2175
|
+
const missing = checkProviderKeys(agent.manifest.config.model);
|
|
2176
|
+
if (missing.length > 0) {
|
|
2177
|
+
console.log(` ${grey("\u26A0")} Missing API keys: ${missing.join(", ")}`);
|
|
2178
|
+
console.log(` ${dimmed(" Set them in .env.local or your environment")}`);
|
|
2179
|
+
console.log();
|
|
2180
|
+
}
|
|
2181
|
+
} catch {
|
|
2182
|
+
console.log(` ${agentDirPath}`);
|
|
2183
|
+
console.log();
|
|
2184
|
+
console.log(` ${dimmed(`http://localhost:${boundPort}`)}`);
|
|
2185
|
+
console.log();
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
1955
2188
|
if (options.input) {
|
|
1956
|
-
|
|
1957
|
-
void startBlockChat({ agentDir: agentDirPath });
|
|
1958
|
-
});
|
|
1959
|
-
} else {
|
|
1960
|
-
server.listen(port, () => {
|
|
1961
|
-
});
|
|
2189
|
+
void startBlockChat({ agentDir: agentDirPath });
|
|
1962
2190
|
}
|
|
1963
2191
|
}
|
|
1964
2192
|
export {
|
|
1965
2193
|
devCommand
|
|
1966
2194
|
};
|
|
1967
|
-
//# sourceMappingURL=dev-
|
|
2195
|
+
//# sourceMappingURL=dev-DCPOO54H.js.map
|