open-agents-ai 0.184.40 → 0.184.42
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 +16 -72
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61880,6 +61880,9 @@ function ollamaRequest(ollamaUrl, path, method, body) {
|
|
|
61880
61880
|
});
|
|
61881
61881
|
});
|
|
61882
61882
|
});
|
|
61883
|
+
proxyReq.setTimeout(1e4, () => {
|
|
61884
|
+
proxyReq.destroy(new Error("Backend request timeout (10s)"));
|
|
61885
|
+
});
|
|
61883
61886
|
proxyReq.on("error", reject);
|
|
61884
61887
|
if (body)
|
|
61885
61888
|
proxyReq.write(body);
|
|
@@ -61903,6 +61906,9 @@ function ollamaStream(ollamaUrl, path, method, body, onData, onEnd, onError) {
|
|
|
61903
61906
|
proxyRes.on("data", onData);
|
|
61904
61907
|
proxyRes.on("end", onEnd);
|
|
61905
61908
|
});
|
|
61909
|
+
proxyReq.setTimeout(3e4, () => {
|
|
61910
|
+
proxyReq.destroy(new Error("Backend stream timeout (30s)"));
|
|
61911
|
+
});
|
|
61906
61912
|
proxyReq.on("error", onError);
|
|
61907
61913
|
if (body)
|
|
61908
61914
|
proxyReq.write(body);
|
|
@@ -65058,80 +65064,18 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
65058
65064
|
}
|
|
65059
65065
|
try {
|
|
65060
65066
|
const apiPort = parseInt(process.env["OA_PORT"] || "11435", 10);
|
|
65061
|
-
const
|
|
65062
|
-
const
|
|
65063
|
-
|
|
65064
|
-
|
|
65065
|
-
tester.once("error", (err) => {
|
|
65066
|
-
resolve36(err.code !== "EADDRINUSE");
|
|
65067
|
-
});
|
|
65068
|
-
tester.once("listening", () => {
|
|
65069
|
-
tester.close(() => resolve36(true));
|
|
65070
|
-
});
|
|
65071
|
-
tester.listen(apiPort, "127.0.0.1");
|
|
65072
|
-
});
|
|
65073
|
-
if (!portFree) {
|
|
65074
|
-
let isOurServer = false;
|
|
65075
|
-
try {
|
|
65076
|
-
const probe = await fetch(`http://127.0.0.1:${apiPort}/health`, { signal: AbortSignal.timeout(2e3) });
|
|
65077
|
-
if (probe.ok) {
|
|
65078
|
-
const data = await probe.json();
|
|
65079
|
-
isOurServer = data.status === "ok";
|
|
65080
|
-
}
|
|
65081
|
-
} catch {
|
|
65082
|
-
}
|
|
65083
|
-
if (isOurServer) {
|
|
65084
|
-
} else {
|
|
65085
|
-
try {
|
|
65086
|
-
const { execSync: nodeExec } = __require("child_process");
|
|
65087
|
-
if (isWin2) {
|
|
65088
|
-
const out = nodeExec(`netstat -ano | findstr :${apiPort} | findstr LISTENING`, { encoding: "utf8", timeout: 3e3 }).trim();
|
|
65089
|
-
const pid = out.split(/\s+/).pop();
|
|
65090
|
-
if (pid && parseInt(pid, 10) > 0 && parseInt(pid, 10) !== process.pid) {
|
|
65091
|
-
nodeExec(`taskkill /PID ${pid} /F`, { timeout: 3e3 });
|
|
65092
|
-
writeContent(() => renderInfo(`Killed orphaned process on port ${apiPort} (PID ${pid})`));
|
|
65093
|
-
await new Promise((r) => setTimeout(r, 1e3));
|
|
65094
|
-
}
|
|
65095
|
-
} else {
|
|
65096
|
-
try {
|
|
65097
|
-
const out = nodeExec(`lsof -ti :${apiPort} 2>/dev/null || fuser ${apiPort}/tcp 2>/dev/null`, { encoding: "utf8", timeout: 3e3 }).trim();
|
|
65098
|
-
const pids = out.split(/\s+/).map((s) => parseInt(s, 10)).filter((p) => p > 0 && p !== process.pid);
|
|
65099
|
-
for (const pid of pids) {
|
|
65100
|
-
try {
|
|
65101
|
-
process.kill(pid, "SIGTERM");
|
|
65102
|
-
} catch {
|
|
65103
|
-
}
|
|
65104
|
-
}
|
|
65105
|
-
if (pids.length > 0) {
|
|
65106
|
-
writeContent(() => renderInfo(`Killed ${pids.length} orphaned process(es) on port ${apiPort}`));
|
|
65107
|
-
await new Promise((r) => setTimeout(r, 1e3));
|
|
65108
|
-
}
|
|
65109
|
-
} catch {
|
|
65110
|
-
}
|
|
65111
|
-
}
|
|
65112
|
-
} catch {
|
|
65113
|
-
}
|
|
65114
|
-
}
|
|
65115
|
-
}
|
|
65116
|
-
const portNowFree = await new Promise((resolve36) => {
|
|
65117
|
-
const net = __require("net");
|
|
65118
|
-
const tester = net.createServer();
|
|
65119
|
-
tester.once("error", () => resolve36(false));
|
|
65120
|
-
tester.once("listening", () => {
|
|
65121
|
-
tester.close(() => resolve36(true));
|
|
65122
|
-
});
|
|
65123
|
-
tester.listen(apiPort, "127.0.0.1");
|
|
65067
|
+
const { startApiServer: startApiServer2 } = await Promise.resolve().then(() => (init_serve(), serve_exports));
|
|
65068
|
+
const apiServer = startApiServer2({
|
|
65069
|
+
port: apiPort,
|
|
65070
|
+
ollamaUrl: currentConfig.backendUrl || "http://127.0.0.1:11434"
|
|
65124
65071
|
});
|
|
65125
|
-
|
|
65126
|
-
|
|
65127
|
-
|
|
65128
|
-
port: apiPort,
|
|
65129
|
-
ollamaUrl: currentConfig.backendUrl || "http://127.0.0.1:11434"
|
|
65130
|
-
});
|
|
65131
|
-
apiServer.on?.("error", () => {
|
|
65132
|
-
});
|
|
65072
|
+
let apiStarted = false;
|
|
65073
|
+
apiServer.on?.("listening", () => {
|
|
65074
|
+
apiStarted = true;
|
|
65133
65075
|
writeContent(() => renderInfo(`REST API: http://localhost:${apiPort}`));
|
|
65134
|
-
}
|
|
65076
|
+
});
|
|
65077
|
+
apiServer.on?.("error", () => {
|
|
65078
|
+
});
|
|
65135
65079
|
} catch {
|
|
65136
65080
|
}
|
|
65137
65081
|
try {
|
package/package.json
CHANGED