open-agents-ai 0.184.35 → 0.184.37

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.
Files changed (2) hide show
  1. package/dist/index.js +58 -163
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -47641,8 +47641,8 @@ async function handleSlashCommand(input, ctx) {
47641
47641
  writeFileSync19(jwtFile, JSON.stringify(jwtPayload, null, 2));
47642
47642
  renderInfo(`Launching fortemi-react from ${fDir}...`);
47643
47643
  try {
47644
- const { spawn: spawn23 } = __require("node:child_process");
47645
- const child = spawn23("npx", ["vite", "dev", "--host", "0.0.0.0", "--port", "3000"], {
47644
+ const { spawn: spawn22 } = __require("node:child_process");
47645
+ const child = spawn22("npx", ["vite", "dev", "--host", "0.0.0.0", "--port", "3000"], {
47646
47646
  cwd: join58(fDir, "apps", "standalone"),
47647
47647
  stdio: "ignore",
47648
47648
  detached: true,
@@ -50459,8 +50459,8 @@ Environment="OLLAMA_NUM_PARALLEL=${n}"
50459
50459
  }
50460
50460
  await new Promise((r) => setTimeout(r, 1e3));
50461
50461
  process.env.OLLAMA_NUM_PARALLEL = String(n);
50462
- const { spawn: spawn23 } = await import("node:child_process");
50463
- const child = spawn23("ollama", ["serve"], {
50462
+ const { spawn: spawn22 } = await import("node:child_process");
50463
+ const child = spawn22("ollama", ["serve"], {
50464
50464
  stdio: "ignore",
50465
50465
  detached: true,
50466
50466
  env: { ...process.env, OLLAMA_NUM_PARALLEL: String(n) }
@@ -62533,6 +62533,15 @@ function startApiServer(options = {}) {
62533
62533
  }
62534
62534
  });
62535
62535
  });
62536
+ server.on("error", (err) => {
62537
+ if (err.code === "EADDRINUSE") {
62538
+ process.stderr.write(` Port ${port} already in use \u2014 API server not started.
62539
+ `);
62540
+ } else {
62541
+ process.stderr.write(` API server error: ${err.message}
62542
+ `);
62543
+ }
62544
+ });
62536
62545
  server.listen(port, host, () => {
62537
62546
  const version = getVersion3();
62538
62547
  process.stderr.write(`
@@ -64775,19 +64784,33 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
64775
64784
  } catch {
64776
64785
  }
64777
64786
  try {
64778
- const { startApiServer: startApiServer2 } = await Promise.resolve().then(() => (init_serve(), serve_exports));
64779
64787
  const apiPort = parseInt(process.env["OA_PORT"] || "11435", 10);
64780
- const apiServer = startApiServer2({
64781
- port: apiPort,
64782
- ollamaUrl: currentConfig.backendUrl || "http://127.0.0.1:11434"
64788
+ const portFree = await new Promise((resolve36) => {
64789
+ const net = __require("net");
64790
+ const tester = net.createServer();
64791
+ tester.once("error", (err) => {
64792
+ if (err.code === "EADDRINUSE")
64793
+ resolve36(false);
64794
+ else
64795
+ resolve36(true);
64796
+ });
64797
+ tester.once("listening", () => {
64798
+ tester.close(() => resolve36(true));
64799
+ });
64800
+ tester.listen(apiPort, "127.0.0.1");
64783
64801
  });
64784
- writeContent(() => renderInfo(`REST API: http://localhost:${apiPort} (${process.env["OA_API_KEY"] || process.env["OA_API_KEYS"] ? "auth enabled" : "open"})`));
64785
- } catch (apiErr) {
64786
- const msg = apiErr instanceof Error ? apiErr.message : String(apiErr);
64787
- if (msg.includes("EADDRINUSE")) {
64802
+ if (!portFree) {
64788
64803
  } else {
64789
- writeContent(() => renderWarning(`API server: ${msg.slice(0, 60)}`));
64804
+ const { startApiServer: startApiServer2 } = await Promise.resolve().then(() => (init_serve(), serve_exports));
64805
+ const apiServer = startApiServer2({
64806
+ port: apiPort,
64807
+ ollamaUrl: currentConfig.backendUrl || "http://127.0.0.1:11434"
64808
+ });
64809
+ apiServer.on?.("error", () => {
64810
+ });
64811
+ writeContent(() => renderInfo(`REST API: http://localhost:${apiPort}`));
64790
64812
  }
64813
+ } catch {
64791
64814
  }
64792
64815
  try {
64793
64816
  const { homedir: _hd } = await import("node:os");
@@ -68115,161 +68138,33 @@ var serve_exports2 = {};
68115
68138
  __export(serve_exports2, {
68116
68139
  serveCommand: () => serveCommand
68117
68140
  });
68118
- import { spawn as spawn22 } from "node:child_process";
68119
68141
  async function serveCommand(opts, config) {
68120
- const backendType = config.backendType;
68121
- if (backendType === "ollama") {
68122
- await serveOllama(opts, config);
68123
- } else if (backendType === "vllm") {
68124
- await serveVllm(opts, config);
68125
- } else {
68126
- printHeader("Backend: fake");
68127
- printInfo("FakeBackend requires no server \u2014 it runs in-process.");
68128
- printInfo("Use --backend ollama or --backend vllm to connect to a real model.");
68129
- }
68130
- }
68131
- async function serveOllama(opts, config) {
68132
- const model = opts.model ?? config.model;
68133
- const baseUrl = config.backendUrl;
68134
- printHeader("Ollama Backend");
68135
- printSection("Active Configuration");
68136
- printKeyValue("Backend", "Ollama (manages its own server)", 2);
68137
- printKeyValue("URL", baseUrl, 2);
68138
- printKeyValue("Model", model, 2);
68139
- printInfo("Ollama manages its own server process \u2014 no startup needed via open-agents.");
68140
- printInfo("If Ollama is not running, start it with: ollama serve");
68141
- const backend = new OllamaBackend({ baseUrl, model });
68142
- let healthy;
68142
+ const port = opts.port ?? 11435;
68143
+ const ollamaUrl = config.backendUrl || "http://127.0.0.1:11434";
68144
+ printHeader("Open Agents REST API");
68145
+ printInfo(`Starting API server on port ${port}...`);
68146
+ printInfo(`Backend: ${config.backendType} (${ollamaUrl})`);
68143
68147
  try {
68144
- healthy = await backend.healthCheck();
68145
- } catch {
68146
- healthy = false;
68147
- }
68148
- if (!healthy) {
68149
- printWarning(`Ollama is not reachable at ${baseUrl}`);
68150
- printInfo("Start Ollama and then run: open-agents status");
68151
- return;
68152
- }
68153
- printSuccess(`Ollama is running at ${baseUrl}`);
68154
- let availableModels = [];
68155
- try {
68156
- availableModels = await OllamaBackend.listModels(baseUrl);
68157
- } catch {
68158
- }
68159
- if (availableModels.length > 0) {
68160
- printSection("Available Models");
68161
- for (const name of availableModels) {
68162
- const isActive = name === model;
68163
- printKeyValue(isActive ? `${name} (configured)` : name, "", 2);
68164
- }
68165
- if (!availableModels.includes(model)) {
68166
- printWarning(`Model "${model}" is not pulled yet.`);
68167
- printInfo(`Pull it with: ollama pull ${model}`);
68168
- }
68169
- }
68170
- if (opts.verbose) {
68171
- printSection("Next Steps");
68172
- printInfo(`Run a task: open-agents run "your task here" --backend ollama`);
68173
- printInfo(`Check status: open-agents status`);
68174
- }
68175
- const apiPort = opts.port ?? 11435;
68176
- printSection("Starting API Server");
68177
- printKeyValue("Port", String(apiPort), 2);
68178
- printKeyValue("Ollama proxy", baseUrl, 2);
68179
- const server = startApiServer({
68180
- port: apiPort,
68181
- verbose: opts.verbose,
68182
- ollamaUrl: baseUrl
68183
- });
68184
- await new Promise((resolve36) => {
68185
- server.on("close", resolve36);
68186
- });
68187
- }
68188
- async function serveVllm(opts, config) {
68189
- const port = opts.port ?? 8e3;
68190
- const host = opts.host ?? "0.0.0.0";
68191
- const model = opts.model ?? config.model;
68192
- printHeader("Start vLLM Server");
68193
- printSection("Server Configuration");
68194
- printKeyValue("Model", model, 2);
68195
- printKeyValue("Host", host, 2);
68196
- printKeyValue("Port", String(port), 2);
68197
- if (opts.extraArgs && opts.extraArgs.length > 0) {
68198
- printKeyValue("Extra args", opts.extraArgs.join(" "), 2);
68199
- }
68200
- const args = [
68201
- "-m",
68202
- "vllm.entrypoints.openai.api_server",
68203
- "--model",
68204
- model,
68205
- "--host",
68206
- host,
68207
- "--port",
68208
- String(port),
68209
- ...opts.extraArgs ?? []
68210
- ];
68211
- printInfo(`Running: python ${args.join(" ")}`);
68212
- printInfo(`Server will be available at http://${host}:${port}`);
68213
- printInfo("Press Ctrl+C to stop");
68214
- if (opts.verbose) {
68215
- printSection("Environment");
68216
- printKeyValue("CUDA_VISIBLE_DEVICES", process.env["CUDA_VISIBLE_DEVICES"] ?? "(not set)", 2);
68217
- printKeyValue("HF_TOKEN", process.env["HF_TOKEN"] ? "[set]" : "(not set)", 2);
68218
- }
68219
- await runVllmServer(args, opts.verbose ?? false);
68220
- }
68221
- async function runVllmServer(args, verbose) {
68222
- return new Promise((resolve36, reject) => {
68223
- const child = spawn22("python", args, {
68224
- stdio: verbose ? "inherit" : ["ignore", "pipe", "pipe"],
68225
- env: { ...process.env }
68226
- });
68227
- if (child.stdout) {
68228
- child.stdout.on("data", (chunk) => {
68229
- const line = chunk.toString().trim();
68230
- if (line)
68231
- printInfo(`[vllm] ${line}`);
68232
- });
68233
- }
68234
- if (child.stderr) {
68235
- child.stderr.on("data", (chunk) => {
68236
- const line = chunk.toString().trim();
68237
- if (line)
68238
- printWarning(`[vllm] ${line}`);
68239
- });
68240
- }
68241
- child.once("spawn", () => {
68242
- printSuccess("vLLM process started");
68243
- });
68244
- child.once("error", (err) => {
68245
- if (err.code === "ENOENT") {
68246
- printError("'python' not found. Ensure Python 3.10+ and vLLM are installed.");
68247
- printInfo("Install vLLM: pip install vllm");
68248
- reject(err);
68249
- } else {
68250
- printError(`Failed to start vLLM: ${err.message}`);
68251
- reject(err);
68252
- }
68253
- });
68254
- child.once("exit", (code, signal) => {
68255
- if (signal) {
68256
- printInfo(`vLLM server stopped by signal ${signal}`);
68148
+ const server = startApiServer({ port, ollamaUrl });
68149
+ await new Promise((resolve36) => {
68150
+ process.on("SIGINT", () => {
68151
+ server.close();
68257
68152
  resolve36();
68258
- } else if (code === 0) {
68259
- printSuccess("vLLM server exited cleanly");
68153
+ });
68154
+ process.on("SIGTERM", () => {
68155
+ server.close();
68260
68156
  resolve36();
68261
- } else {
68262
- printError(`vLLM server exited with code ${code}`);
68263
- reject(new Error(`vLLM exited with code ${code}`));
68264
- }
68157
+ });
68265
68158
  });
68266
- const forwardSignal = (sig) => {
68267
- if (!child.killed)
68268
- child.kill(sig);
68269
- };
68270
- process.once("SIGINT", () => forwardSignal("SIGINT"));
68271
- process.once("SIGTERM", () => forwardSignal("SIGTERM"));
68272
- });
68159
+ } catch (err) {
68160
+ const msg = err instanceof Error ? err.message : String(err);
68161
+ if (msg.includes("EADDRINUSE")) {
68162
+ printError(`Port ${port} already in use. Another OA instance may be running.`);
68163
+ printInfo(`Try: oa serve --port ${port + 1}`);
68164
+ } else {
68165
+ printError(`API server failed: ${msg}`);
68166
+ }
68167
+ }
68273
68168
  }
68274
68169
  var init_serve2 = __esm({
68275
68170
  "packages/cli/dist/commands/serve.js"() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.184.35",
3
+ "version": "0.184.37",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) \u2014 interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",