open-agents-ai 0.187.577 → 0.187.579
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/index.js +193 -57
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function parseBackendType(value2) {
|
|
|
65
65
|
return VALID_BACKEND_TYPES.has(value2) ? value2 : void 0;
|
|
66
66
|
}
|
|
67
67
|
function loadConfigFile() {
|
|
68
|
-
const configPath2 = join(
|
|
68
|
+
const configPath2 = join(openAgentsConfigDir(), "config.json");
|
|
69
69
|
if (!existsSync(configPath2)) return {};
|
|
70
70
|
try {
|
|
71
71
|
const raw = readFileSync(configPath2, "utf8");
|
|
@@ -110,13 +110,16 @@ function mergeConfig(base3, overrides) {
|
|
|
110
110
|
return { ...base3, ...overrides };
|
|
111
111
|
}
|
|
112
112
|
function setConfigValue(key, value2) {
|
|
113
|
-
const dir =
|
|
113
|
+
const dir = openAgentsConfigDir();
|
|
114
114
|
mkdirSync(dir, { recursive: true });
|
|
115
115
|
const configPath2 = join(dir, "config.json");
|
|
116
116
|
const existing = loadConfigFile();
|
|
117
117
|
existing[key] = coerceConfigValue(key, value2);
|
|
118
118
|
writeFileSync(configPath2, JSON.stringify(existing, null, 2) + "\n", { encoding: "utf8", mode: 384 });
|
|
119
119
|
}
|
|
120
|
+
function openAgentsConfigDir() {
|
|
121
|
+
return join(process.env["OPEN_AGENTS_CONFIG_HOME"] ?? homedir(), ".open-agents");
|
|
122
|
+
}
|
|
120
123
|
function coerceConfigValue(key, value2) {
|
|
121
124
|
const intKeys = /* @__PURE__ */ new Set(["maxRetries", "timeoutMs"]);
|
|
122
125
|
const boolKeys = /* @__PURE__ */ new Set(["dryRun", "verbose"]);
|
|
@@ -548908,7 +548911,7 @@ function buildCommandDef(name10, signatures) {
|
|
|
548908
548911
|
const argsHint = inferArgsHint(signatures[0]?.signature ?? `/${name10}`);
|
|
548909
548912
|
const surfaces = {
|
|
548910
548913
|
tui: true,
|
|
548911
|
-
rest: status === "implemented" && !["quit", "exit"].includes(name10),
|
|
548914
|
+
rest: status === "implemented" && !["quit", "exit"].includes(name10) && !safety.destructive && !safety.secretBearing && !REST_BLOCKED.has(name10),
|
|
548912
548915
|
gateway: status === "implemented" && !safety.destructive && !safety.secretBearing,
|
|
548913
548916
|
agentTool: status === "implemented" && !safety.userOnly && !safety.destructive && !safety.secretBearing && !safety.profileGated
|
|
548914
548917
|
};
|
|
@@ -548942,7 +548945,7 @@ function inferArgsHint(signature) {
|
|
|
548942
548945
|
function normalizeCommandName(name10) {
|
|
548943
548946
|
return name10.replace(/^\//, "").trim().toLowerCase();
|
|
548944
548947
|
}
|
|
548945
|
-
var COMMAND_SIGNATURES, PLANNED_SIGNATURES, CATEGORY_OVERRIDES, ALIASES, USER_ONLY, DESTRUCTIVE, NETWORKED, SECRET_BEARING, PROFILE_GATED, CANONICAL_BY_ALIAS, DYNAMIC_COMMANDS, SLASH_COMMANDS;
|
|
548948
|
+
var COMMAND_SIGNATURES, PLANNED_SIGNATURES, CATEGORY_OVERRIDES, ALIASES, USER_ONLY, DESTRUCTIVE, NETWORKED, SECRET_BEARING, PROFILE_GATED, REST_BLOCKED, CANONICAL_BY_ALIAS, DYNAMIC_COMMANDS, SLASH_COMMANDS;
|
|
548946
548949
|
var init_command_registry = __esm({
|
|
548947
548950
|
"packages/cli/src/tui/command-registry.ts"() {
|
|
548948
548951
|
"use strict";
|
|
@@ -549371,6 +549374,16 @@ var init_command_registry = __esm({
|
|
|
549371
549374
|
"deny",
|
|
549372
549375
|
"sethome"
|
|
549373
549376
|
]);
|
|
549377
|
+
REST_BLOCKED = /* @__PURE__ */ new Set([
|
|
549378
|
+
"pause",
|
|
549379
|
+
"resume",
|
|
549380
|
+
"retry",
|
|
549381
|
+
"undo",
|
|
549382
|
+
"rollback",
|
|
549383
|
+
"background",
|
|
549384
|
+
"bg",
|
|
549385
|
+
"paste"
|
|
549386
|
+
]);
|
|
549374
549387
|
CANONICAL_BY_ALIAS = /* @__PURE__ */ new Map();
|
|
549375
549388
|
for (const [canonical, aliases] of Object.entries(ALIASES)) {
|
|
549376
549389
|
for (const alias of aliases) CANONICAL_BY_ALIAS.set(alias, canonical);
|
|
@@ -594429,6 +594442,18 @@ async function runCommand(input, opts) {
|
|
|
594429
594442
|
const argsStr = rest.join(" ");
|
|
594430
594443
|
const release = await acquireLock2();
|
|
594431
594444
|
try {
|
|
594445
|
+
const quick2 = buildNonInteractiveSummary(cmdName, argsStr, opts?.config);
|
|
594446
|
+
if (quick2) {
|
|
594447
|
+
return {
|
|
594448
|
+
ok: true,
|
|
594449
|
+
command: cmdName,
|
|
594450
|
+
args: argsStr,
|
|
594451
|
+
kind: "handled",
|
|
594452
|
+
output: quick2,
|
|
594453
|
+
ansi: quick2,
|
|
594454
|
+
durationMs: Date.now() - start2
|
|
594455
|
+
};
|
|
594456
|
+
}
|
|
594432
594457
|
const buf = [];
|
|
594433
594458
|
setContentWriteHook({
|
|
594434
594459
|
begin: () => {
|
|
@@ -594479,6 +594504,43 @@ async function runCommand(input, opts) {
|
|
|
594479
594504
|
release();
|
|
594480
594505
|
}
|
|
594481
594506
|
}
|
|
594507
|
+
function buildNonInteractiveSummary(cmdName, _args, config) {
|
|
594508
|
+
const cfg = config ?? loadConfig();
|
|
594509
|
+
if (cmdName === "setup" || cmdName === "wizard") {
|
|
594510
|
+
return [
|
|
594511
|
+
"open-agents setup",
|
|
594512
|
+
"",
|
|
594513
|
+
"The setup wizard is an interactive terminal flow. In the GUI command bridge it is summarized instead of opening prompts, installing software, starting Ollama, or pulling models.",
|
|
594514
|
+
"",
|
|
594515
|
+
`Current backend: ${cfg.backendType ?? "ollama"}`,
|
|
594516
|
+
`Current endpoint: ${cfg.backendUrl ?? "http://127.0.0.1:11434"}`,
|
|
594517
|
+
`Current model: ${cfg.model ?? "qwen3.5:latest"}`,
|
|
594518
|
+
"",
|
|
594519
|
+
"Available non-interactive setup actions:",
|
|
594520
|
+
" /endpoint <url> Set or inspect the inference endpoint.",
|
|
594521
|
+
" /model <name> Set the active model directly.",
|
|
594522
|
+
" /models Show model-selection guidance.",
|
|
594523
|
+
" /config Inspect persisted configuration.",
|
|
594524
|
+
" /doctor Run diagnostics from the terminal if deeper repair is needed.",
|
|
594525
|
+
"",
|
|
594526
|
+
"Open a terminal and run `oa`, then use /setup for the full guided wizard."
|
|
594527
|
+
].join("\n");
|
|
594528
|
+
}
|
|
594529
|
+
if (cmdName === "models") {
|
|
594530
|
+
return [
|
|
594531
|
+
"open-agents models",
|
|
594532
|
+
"",
|
|
594533
|
+
"The model picker is interactive in the TUI. The GUI bridge does not probe remote model endpoints here, so it cannot hang on a stale backend.",
|
|
594534
|
+
"",
|
|
594535
|
+
`Active model: ${cfg.model ?? "qwen3.5:latest"}`,
|
|
594536
|
+
`Endpoint: ${cfg.backendUrl ?? "http://127.0.0.1:11434"}`,
|
|
594537
|
+
`Backend: ${cfg.backendType ?? "ollama"}`,
|
|
594538
|
+
"",
|
|
594539
|
+
"Use /model <name> to set a model directly, /endpoint to switch providers, or open the TUI for the searchable model picker."
|
|
594540
|
+
].join("\n");
|
|
594541
|
+
}
|
|
594542
|
+
return null;
|
|
594543
|
+
}
|
|
594482
594544
|
function acquireLock2() {
|
|
594483
594545
|
let release;
|
|
594484
594546
|
const next = new Promise((res) => {
|
|
@@ -596435,7 +596497,8 @@ async function handleCommandPassthrough(ctx3) {
|
|
|
596435
596497
|
}));
|
|
596436
596498
|
return true;
|
|
596437
596499
|
}
|
|
596438
|
-
const
|
|
596500
|
+
const normalizedInput = input.trim().startsWith("/") ? input.trim() : `/${input.trim()}`;
|
|
596501
|
+
const [commandName = "", ...commandArgs] = normalizedInput.replace(/^\//, "").split(/\s+/);
|
|
596439
596502
|
const registryCommand = findCommand(commandName);
|
|
596440
596503
|
if (registryCommand && !registryCommand.surfaces.rest) {
|
|
596441
596504
|
sendProblem(res, problemDetails({
|
|
@@ -596448,9 +596511,14 @@ async function handleCommandPassthrough(ctx3) {
|
|
|
596448
596511
|
}));
|
|
596449
596512
|
return true;
|
|
596450
596513
|
}
|
|
596514
|
+
if (commandName === "queue" || commandName === "q") {
|
|
596515
|
+
const prompt = commandArgs.join(" ").trim();
|
|
596516
|
+
const queued = await handleRestQueueCommand(ctx3, body, commandName, prompt);
|
|
596517
|
+
if (queued) return true;
|
|
596518
|
+
}
|
|
596451
596519
|
try {
|
|
596452
596520
|
const { runCommand: runCommand3 } = await Promise.resolve().then(() => (init_command_passthrough(), command_passthrough_exports));
|
|
596453
|
-
const result = await runCommand3(
|
|
596521
|
+
const result = await runCommand3(normalizedInput);
|
|
596454
596522
|
sendJson(res, 200, result);
|
|
596455
596523
|
} catch (err) {
|
|
596456
596524
|
sendProblem(res, problemDetails({
|
|
@@ -596463,6 +596531,47 @@ async function handleCommandPassthrough(ctx3) {
|
|
|
596463
596531
|
}
|
|
596464
596532
|
return true;
|
|
596465
596533
|
}
|
|
596534
|
+
async function handleRestQueueCommand(ctx3, body, commandName, prompt) {
|
|
596535
|
+
const { res, requestId } = ctx3;
|
|
596536
|
+
if (!prompt) return false;
|
|
596537
|
+
const sessionId = typeof body?.sessionId === "string" ? body.sessionId : typeof body?.session_id === "string" ? body.session_id : "";
|
|
596538
|
+
if (!sessionId) {
|
|
596539
|
+
sendProblem(res, problemDetails({
|
|
596540
|
+
type: P.invalidRequest,
|
|
596541
|
+
status: 400,
|
|
596542
|
+
title: "sessionId required",
|
|
596543
|
+
detail: "REST /queue requires a chat sessionId so the prompt can be delivered at a turn boundary.",
|
|
596544
|
+
instance: requestId
|
|
596545
|
+
}));
|
|
596546
|
+
return true;
|
|
596547
|
+
}
|
|
596548
|
+
const { lookupSession: lookupSession2, addCheckinMessage: addCheckinMessage2, appendCheckin: appendCheckin2 } = await Promise.resolve().then(() => (init_chat_session(), chat_session_exports));
|
|
596549
|
+
const session = lookupSession2(sessionId);
|
|
596550
|
+
if (!session) {
|
|
596551
|
+
sendProblem(res, problemDetails({
|
|
596552
|
+
type: P.notFound,
|
|
596553
|
+
status: 404,
|
|
596554
|
+
title: "Session not found",
|
|
596555
|
+
detail: `No chat session found for id ${sessionId}.`,
|
|
596556
|
+
instance: requestId
|
|
596557
|
+
}));
|
|
596558
|
+
return true;
|
|
596559
|
+
}
|
|
596560
|
+
addCheckinMessage2(session, prompt);
|
|
596561
|
+
appendCheckin2(sessionId, `[QUEUED NEXT-TURN PROMPT]
|
|
596562
|
+
${prompt}`);
|
|
596563
|
+
sendJson(res, 200, {
|
|
596564
|
+
ok: true,
|
|
596565
|
+
command: commandName,
|
|
596566
|
+
args: prompt,
|
|
596567
|
+
kind: "handled",
|
|
596568
|
+
output: `Queued prompt for session ${sessionId}.`,
|
|
596569
|
+
ansi: "",
|
|
596570
|
+
durationMs: 0,
|
|
596571
|
+
sessionId
|
|
596572
|
+
});
|
|
596573
|
+
return true;
|
|
596574
|
+
}
|
|
596466
596575
|
async function handleRevokeKey(ctx3, prefix) {
|
|
596467
596576
|
const { req: req2, res, requestId } = ctx3;
|
|
596468
596577
|
const reqAuth = req2;
|
|
@@ -607263,6 +607372,7 @@ async function refreshEndpointRegistry() {
|
|
|
607263
607372
|
type: config.backendType || "ollama",
|
|
607264
607373
|
authKey: config.apiKey
|
|
607265
607374
|
});
|
|
607375
|
+
if (process.env["OA_SKIP_SPONSOR_DISCOVERY"] === "1") return;
|
|
607266
607376
|
try {
|
|
607267
607377
|
const resp = await fetch("https://openagents.nexus/api/v1/sponsors", {
|
|
607268
607378
|
signal: AbortSignal.timeout(5e3)
|
|
@@ -607383,6 +607493,16 @@ function getBackendTimeoutMs(perRequestSeconds) {
|
|
|
607383
607493
|
}
|
|
607384
607494
|
return BACKEND_TIMEOUT_DEFAULT_MS;
|
|
607385
607495
|
}
|
|
607496
|
+
function getModelListTimeoutMs() {
|
|
607497
|
+
const envS = process.env["OA_MODEL_LIST_TIMEOUT_S"];
|
|
607498
|
+
if (envS) {
|
|
607499
|
+
const n2 = parseFloat(envS);
|
|
607500
|
+
if (Number.isFinite(n2) && n2 > 0) {
|
|
607501
|
+
return Math.min(Math.floor(n2 * 1e3), 3e4);
|
|
607502
|
+
}
|
|
607503
|
+
}
|
|
607504
|
+
return MODEL_LIST_TIMEOUT_DEFAULT_MS;
|
|
607505
|
+
}
|
|
607386
607506
|
function recordMetric(method, path11, status) {
|
|
607387
607507
|
const key = `${method}|${path11}|${status}`;
|
|
607388
607508
|
const existing = metrics.requests.get(key);
|
|
@@ -607822,10 +607942,12 @@ function ollamaRequest(ollamaUrl, path11, method, body, timeoutMs) {
|
|
|
607822
607942
|
}
|
|
607823
607943
|
};
|
|
607824
607944
|
const transport = isHttps ? https3 : http5;
|
|
607945
|
+
const _to = getBackendTimeoutMs(timeoutMs ? timeoutMs / 1e3 : void 0);
|
|
607825
607946
|
const proxyReq = transport.request(options2, (proxyRes) => {
|
|
607826
607947
|
const chunks = [];
|
|
607827
607948
|
proxyRes.on("data", (chunk) => chunks.push(chunk));
|
|
607828
607949
|
proxyRes.on("end", () => {
|
|
607950
|
+
clearTimeout(hardTimeout);
|
|
607829
607951
|
resolve43({
|
|
607830
607952
|
status: proxyRes.statusCode ?? 500,
|
|
607831
607953
|
headers: proxyRes.headers,
|
|
@@ -607833,11 +607955,17 @@ function ollamaRequest(ollamaUrl, path11, method, body, timeoutMs) {
|
|
|
607833
607955
|
});
|
|
607834
607956
|
});
|
|
607835
607957
|
});
|
|
607836
|
-
const
|
|
607958
|
+
const hardTimeout = setTimeout(() => {
|
|
607959
|
+
proxyReq.destroy(new Error(`Backend request timeout (${Math.round(_to / 1e3)}s)`));
|
|
607960
|
+
}, _to);
|
|
607961
|
+
hardTimeout.unref();
|
|
607837
607962
|
proxyReq.setTimeout(_to, () => {
|
|
607838
607963
|
proxyReq.destroy(new Error(`Backend request timeout (${Math.round(_to / 1e3)}s)`));
|
|
607839
607964
|
});
|
|
607840
|
-
proxyReq.on("error",
|
|
607965
|
+
proxyReq.on("error", (err) => {
|
|
607966
|
+
clearTimeout(hardTimeout);
|
|
607967
|
+
reject(err);
|
|
607968
|
+
});
|
|
607841
607969
|
if (body) proxyReq.write(body);
|
|
607842
607970
|
proxyReq.end();
|
|
607843
607971
|
});
|
|
@@ -608613,7 +608741,7 @@ async function fetchAggregatedOllamaTags() {
|
|
|
608613
608741
|
try {
|
|
608614
608742
|
const isOllama = ep.type === "ollama";
|
|
608615
608743
|
const path11 = isOllama ? "/api/tags" : "/v1/models";
|
|
608616
|
-
const result = await ollamaRequest(ep.url, path11, "GET");
|
|
608744
|
+
const result = await ollamaRequest(ep.url, path11, "GET", void 0, getModelListTimeoutMs());
|
|
608617
608745
|
if (result.status !== 200) return;
|
|
608618
608746
|
const body = JSON.parse(result.body);
|
|
608619
608747
|
if (isOllama) {
|
|
@@ -608670,6 +608798,10 @@ async function fetchAggregatedOllamaTags() {
|
|
|
608670
608798
|
return out.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
608671
608799
|
}
|
|
608672
608800
|
async function handleApiTags(res) {
|
|
608801
|
+
if (process.env["OA_API_TEST_MODE"] === "1") {
|
|
608802
|
+
jsonResponse(res, 200, { models: [] });
|
|
608803
|
+
return;
|
|
608804
|
+
}
|
|
608673
608805
|
try {
|
|
608674
608806
|
const models = await fetchAggregatedOllamaTags();
|
|
608675
608807
|
jsonResponse(res, 200, { models });
|
|
@@ -610585,6 +610717,13 @@ async function handlePostCommand(res, cmd) {
|
|
|
610585
610717
|
});
|
|
610586
610718
|
return;
|
|
610587
610719
|
}
|
|
610720
|
+
if (cmdBase === "queue" || cmdBase === "q") {
|
|
610721
|
+
jsonResponse(res, 400, {
|
|
610722
|
+
error: "sessionId required",
|
|
610723
|
+
message: 'Use POST /v1/command with { input: "/queue <prompt>", sessionId } so the prompt can be delivered to a chat session.'
|
|
610724
|
+
});
|
|
610725
|
+
return;
|
|
610726
|
+
}
|
|
610588
610727
|
try {
|
|
610589
610728
|
const { runCommand: runCommand3 } = await Promise.resolve().then(() => (init_command_passthrough(), command_passthrough_exports));
|
|
610590
610729
|
const result = await runCommand3(`/${cmd}`);
|
|
@@ -611208,8 +611347,16 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
611208
611347
|
jsonResponse(res, 400, { error: "missing_text" });
|
|
611209
611348
|
return;
|
|
611210
611349
|
}
|
|
611350
|
+
const voiceStatus = getRuntimeStatus();
|
|
611351
|
+
if (!voiceStatus.voiceReady) {
|
|
611352
|
+
jsonResponse(res, 501, {
|
|
611353
|
+
error: "tts_not_ready",
|
|
611354
|
+
message: "Voice synthesis is not ready in the daemon. Warm the voice runtime with POST /v1/voice/start before requesting audio.",
|
|
611355
|
+
state: voiceStatus
|
|
611356
|
+
});
|
|
611357
|
+
return;
|
|
611358
|
+
}
|
|
611211
611359
|
try {
|
|
611212
|
-
await ensureRuntime();
|
|
611213
611360
|
const ve = getVoiceEngine();
|
|
611214
611361
|
let prevModel = null;
|
|
611215
611362
|
if (requestedModel && ve.modelId !== requestedModel) {
|
|
@@ -613446,6 +613593,7 @@ function startApiServer(options2 = {}) {
|
|
|
613446
613593
|
if (options2.host) host = options2.host;
|
|
613447
613594
|
if (options2.port) port = options2.port;
|
|
613448
613595
|
const verbose = options2.verbose ?? false;
|
|
613596
|
+
const apiTestMode = process.env["OA_API_TEST_MODE"] === "1";
|
|
613449
613597
|
const config = loadConfig();
|
|
613450
613598
|
const ollamaUrl = options2.ollamaUrl ?? config.backendUrl;
|
|
613451
613599
|
const cwd4 = process.cwd();
|
|
@@ -613465,31 +613613,37 @@ function startApiServer(options2 = {}) {
|
|
|
613465
613613
|
taskMgr.onEviction((taskId) => {
|
|
613466
613614
|
deleteAgentTaskSidecar(taskId);
|
|
613467
613615
|
});
|
|
613468
|
-
|
|
613469
|
-
|
|
613470
|
-
|
|
613616
|
+
if (!apiTestMode) {
|
|
613617
|
+
restoreAgentTasks(taskMgr).then((report2) => {
|
|
613618
|
+
if (report2.restored > 0) {
|
|
613619
|
+
log22(` task recovery: restored=${report2.restored} re-attached=${report2.reAttached} marked-failed=${report2.markedFailed}
|
|
613471
613620
|
`);
|
|
613472
|
-
|
|
613473
|
-
|
|
613474
|
-
|
|
613475
|
-
|
|
613476
|
-
|
|
613477
|
-
|
|
613478
|
-
|
|
613479
|
-
|
|
613480
|
-
|
|
613621
|
+
}
|
|
613622
|
+
}).catch(() => {
|
|
613623
|
+
});
|
|
613624
|
+
}
|
|
613625
|
+
if (!apiTestMode) {
|
|
613626
|
+
setTimeout(() => {
|
|
613627
|
+
try {
|
|
613628
|
+
purgeOldSidecars(24);
|
|
613629
|
+
} catch {
|
|
613630
|
+
}
|
|
613631
|
+
}, 5e3).unref();
|
|
613632
|
+
}
|
|
613481
613633
|
} catch {
|
|
613482
613634
|
}
|
|
613483
|
-
|
|
613484
|
-
|
|
613485
|
-
|
|
613486
|
-
|
|
613635
|
+
if (!apiTestMode) {
|
|
613636
|
+
try {
|
|
613637
|
+
const report2 = loadPersistedSessions();
|
|
613638
|
+
if (report2.restored > 0 || report2.staleInFlight > 0) {
|
|
613639
|
+
log22(` chat sessions: restored=${report2.restored} stale-in-flight=${report2.staleInFlight}
|
|
613487
613640
|
`);
|
|
613641
|
+
}
|
|
613642
|
+
} catch {
|
|
613488
613643
|
}
|
|
613489
|
-
} catch {
|
|
613490
613644
|
}
|
|
613491
613645
|
setTodoEventPublisher(null);
|
|
613492
|
-
try {
|
|
613646
|
+
if (!apiTestMode) try {
|
|
613493
613647
|
const dir = todoDir();
|
|
613494
613648
|
try {
|
|
613495
613649
|
mkdirSync69(dir, { recursive: true });
|
|
@@ -613566,7 +613720,7 @@ function startApiServer(options2 = {}) {
|
|
|
613566
613720
|
`);
|
|
613567
613721
|
}
|
|
613568
613722
|
const retentionDays = parseInt(process.env["OA_JOB_RETENTION_DAYS"] ?? "30", 10);
|
|
613569
|
-
if (retentionDays > 0) {
|
|
613723
|
+
if (!apiTestMode && retentionDays > 0) {
|
|
613570
613724
|
try {
|
|
613571
613725
|
const jobsDir3 = join129(cwd4, ".oa", "jobs");
|
|
613572
613726
|
if (existsSync113(jobsDir3)) {
|
|
@@ -613617,9 +613771,12 @@ function startApiServer(options2 = {}) {
|
|
|
613617
613771
|
}
|
|
613618
613772
|
let _accessRejected = 0;
|
|
613619
613773
|
const handler = (req2, res) => {
|
|
613774
|
+
const requestId = req2.headers["x-request-id"] || randomUUID16();
|
|
613775
|
+
res.setHeader("X-Request-ID", requestId);
|
|
613776
|
+
res.setHeader("X-API-Version", API_VERSION);
|
|
613620
613777
|
const rawIp = req2.socket?.remoteAddress ?? "";
|
|
613621
613778
|
const hasBearer = typeof req2.headers["authorization"] === "string" && req2.headers["authorization"].startsWith("Bearer ");
|
|
613622
|
-
const anyKeyConfigured = Boolean(
|
|
613779
|
+
const anyKeyConfigured = hasBearer && Boolean(
|
|
613623
613780
|
process.env["OA_API_KEY"] || process.env["OA_API_KEYS"] || runtimeKeysExist()
|
|
613624
613781
|
);
|
|
613625
613782
|
if (!isAllowedIP(rawIp, runtimeAccessMode) && !(hasBearer && anyKeyConfigured)) {
|
|
@@ -613706,10 +613863,6 @@ function startApiServer(options2 = {}) {
|
|
|
613706
613863
|
handleEntitiesList(req2, res);
|
|
613707
613864
|
return;
|
|
613708
613865
|
}
|
|
613709
|
-
if (req2.method === "POST" && url.pathname === "/v1/memory/search") {
|
|
613710
|
-
handleMemorySearch2(req2, res);
|
|
613711
|
-
return;
|
|
613712
|
-
}
|
|
613713
613866
|
} catch {
|
|
613714
613867
|
}
|
|
613715
613868
|
handleRequest(req2, res, ollamaUrl, verbose).catch((err) => {
|
|
@@ -613960,6 +614113,10 @@ function startApiServer(options2 = {}) {
|
|
|
613960
614113
|
`);
|
|
613961
614114
|
log22(` Primary: ${config.backendUrl} (${config.backendType || "ollama"})
|
|
613962
614115
|
`);
|
|
614116
|
+
if (apiTestMode) {
|
|
614117
|
+
void refreshEndpointRegistry();
|
|
614118
|
+
return;
|
|
614119
|
+
}
|
|
613963
614120
|
try {
|
|
613964
614121
|
const { writeFileSync: writeFileSync67, mkdirSync: mkdirSync74, existsSync: _exists, readFileSync: _rfs } = require3("node:fs");
|
|
613965
614122
|
const { join: _join } = require3("node:path");
|
|
@@ -614387,28 +614544,6 @@ async function handleEntitiesList(req2, res) {
|
|
|
614387
614544
|
jsonResponse(res, 500, { error: "server_error", message: err instanceof Error ? err.message : String(err) });
|
|
614388
614545
|
}
|
|
614389
614546
|
}
|
|
614390
|
-
async function handleMemorySearch2(req2, res) {
|
|
614391
|
-
try {
|
|
614392
|
-
const body = await parseJsonBody(req2);
|
|
614393
|
-
if (!body || typeof body !== "object") {
|
|
614394
|
-
jsonResponse(res, 400, { error: "bad_request" });
|
|
614395
|
-
return;
|
|
614396
|
-
}
|
|
614397
|
-
const b = body;
|
|
614398
|
-
const query = String(b.query || "");
|
|
614399
|
-
const modality = b.modality ? String(b.modality) : void 0;
|
|
614400
|
-
const limit = b.limit ? Math.max(1, Math.min(200, parseInt(String(b.limit), 10))) : 20;
|
|
614401
|
-
const qEmb = Array.isArray(b.query_embedding) ? new Float32Array(b.query_embedding) : null;
|
|
614402
|
-
const wLex = typeof b.lexical_weight === "number" ? b.lexical_weight : 1;
|
|
614403
|
-
const wEmb = typeof b.embedding_weight === "number" ? b.embedding_weight : 1;
|
|
614404
|
-
const { EpisodeStore: EpisodeStore3 } = await Promise.resolve().then(() => (init_dist7(), dist_exports2));
|
|
614405
|
-
const epStore = new EpisodeStore3(join129(process.cwd(), ".oa", "memory.db"));
|
|
614406
|
-
const results = epStore.search({ query, modality, limit }, { queryEmbedding: qEmb, lexicalWeight: wLex, embeddingWeight: wEmb });
|
|
614407
|
-
jsonResponse(res, 200, { object: "list", data: results.map((e2) => ({ id: e2.id, modality: e2.modality, content: e2.content, timestamp: e2.timestamp })) });
|
|
614408
|
-
} catch (err) {
|
|
614409
|
-
jsonResponse(res, 500, { error: "server_error", message: err instanceof Error ? err.message : String(err) });
|
|
614410
|
-
}
|
|
614411
|
-
}
|
|
614412
614547
|
async function apiServeCommand(opts, config) {
|
|
614413
614548
|
const server2 = startApiServer({
|
|
614414
614549
|
port: opts.port,
|
|
@@ -614469,7 +614604,7 @@ function setTimerEnabled(name10, enabled2) {
|
|
|
614469
614604
|
return false;
|
|
614470
614605
|
}
|
|
614471
614606
|
}
|
|
614472
|
-
var require3, endpointRegistry, modelRouteMap, endpointUsage, _lastEndpointDiagnostics, BACKEND_TIMEOUT_DEFAULT_MS, BACKEND_TIMEOUT_MAX_MS, metrics, startedAt, runningProcesses, perKeyUsage, CRON_MARKER2;
|
|
614607
|
+
var require3, endpointRegistry, modelRouteMap, endpointUsage, _lastEndpointDiagnostics, BACKEND_TIMEOUT_DEFAULT_MS, BACKEND_TIMEOUT_MAX_MS, MODEL_LIST_TIMEOUT_DEFAULT_MS, metrics, startedAt, runningProcesses, perKeyUsage, CRON_MARKER2;
|
|
614473
614608
|
var init_serve = __esm({
|
|
614474
614609
|
"packages/cli/src/api/serve.ts"() {
|
|
614475
614610
|
"use strict";
|
|
@@ -614505,6 +614640,7 @@ var init_serve = __esm({
|
|
|
614505
614640
|
_lastEndpointDiagnostics = [];
|
|
614506
614641
|
BACKEND_TIMEOUT_DEFAULT_MS = 12e4;
|
|
614507
614642
|
BACKEND_TIMEOUT_MAX_MS = 36e5;
|
|
614643
|
+
MODEL_LIST_TIMEOUT_DEFAULT_MS = 1500;
|
|
614508
614644
|
metrics = {
|
|
614509
614645
|
requests: /* @__PURE__ */ new Map(),
|
|
614510
614646
|
totalTokensIn: 0,
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-agents-ai",
|
|
3
|
-
"version": "0.187.
|
|
3
|
+
"version": "0.187.579",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "open-agents-ai",
|
|
9
|
-
"version": "0.187.
|
|
9
|
+
"version": "0.187.579",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "CC-BY-NC-4.0",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED