open-agents-ai 0.186.42 → 0.186.44
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 +883 -671
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1440,7 +1440,7 @@ ${stdinInput ?? ""}`);
|
|
|
1440
1440
|
}
|
|
1441
1441
|
runCommand(command, timeout2, stdinInput) {
|
|
1442
1442
|
const start2 = performance.now();
|
|
1443
|
-
return new Promise((
|
|
1443
|
+
return new Promise((resolve38) => {
|
|
1444
1444
|
const child = spawn("bash", ["-c", command], {
|
|
1445
1445
|
cwd: this.workingDir,
|
|
1446
1446
|
env: {
|
|
@@ -1471,7 +1471,7 @@ ${stdinInput ?? ""}`);
|
|
|
1471
1471
|
clearTimeout(timer);
|
|
1472
1472
|
if (exitFlushTimer)
|
|
1473
1473
|
clearTimeout(exitFlushTimer);
|
|
1474
|
-
|
|
1474
|
+
resolve38(result);
|
|
1475
1475
|
};
|
|
1476
1476
|
const timer = setTimeout(() => {
|
|
1477
1477
|
killed = true;
|
|
@@ -3215,7 +3215,7 @@ ${JSON.stringify(extracted, null, 2)}`);
|
|
|
3215
3215
|
return null;
|
|
3216
3216
|
}
|
|
3217
3217
|
runProcess(cmd, args, timeoutMs) {
|
|
3218
|
-
return new Promise((
|
|
3218
|
+
return new Promise((resolve38, reject) => {
|
|
3219
3219
|
const proc = execFile3(cmd, args, {
|
|
3220
3220
|
timeout: timeoutMs,
|
|
3221
3221
|
maxBuffer: 10 * 1024 * 1024,
|
|
@@ -3225,7 +3225,7 @@ ${JSON.stringify(extracted, null, 2)}`);
|
|
|
3225
3225
|
reject(new Error(`Process timeout after ${timeoutMs}ms`));
|
|
3226
3226
|
return;
|
|
3227
3227
|
}
|
|
3228
|
-
|
|
3228
|
+
resolve38({
|
|
3229
3229
|
stdout: String(stdout),
|
|
3230
3230
|
stderr: String(stderr),
|
|
3231
3231
|
exitCode: error ? error.code ?? 1 : 0
|
|
@@ -8279,9 +8279,8 @@ process.on('unhandledRejection', (reason) => {
|
|
|
8279
8279
|
model: _cModel,
|
|
8280
8280
|
max_turns: 8,
|
|
8281
8281
|
timeout_s: 90,
|
|
8282
|
-
|
|
8282
|
+
sandbox: 'container',
|
|
8283
8283
|
profile: 'cohere-mesh',
|
|
8284
|
-
working_directory: '/tmp/cohere-mesh',
|
|
8285
8284
|
}),
|
|
8286
8285
|
signal: AbortSignal.timeout(120000),
|
|
8287
8286
|
});
|
|
@@ -11847,7 +11846,7 @@ var init_custom_tool = __esm({
|
|
|
11847
11846
|
}
|
|
11848
11847
|
/** Execute a single shell command and return output */
|
|
11849
11848
|
runCommand(command) {
|
|
11850
|
-
return new Promise((
|
|
11849
|
+
return new Promise((resolve38) => {
|
|
11851
11850
|
const child = spawn4("bash", ["-c", command], {
|
|
11852
11851
|
cwd: this.workingDir,
|
|
11853
11852
|
env: { ...process.env, CI: "true", NO_COLOR: "1" },
|
|
@@ -11872,11 +11871,11 @@ var init_custom_tool = __esm({
|
|
|
11872
11871
|
child.kill("SIGTERM");
|
|
11873
11872
|
} catch {
|
|
11874
11873
|
}
|
|
11875
|
-
|
|
11874
|
+
resolve38({ success: false, output: stdout, error: "Command timed out after 60s" });
|
|
11876
11875
|
}, 6e4);
|
|
11877
11876
|
child.on("close", (code8) => {
|
|
11878
11877
|
clearTimeout(timer);
|
|
11879
|
-
|
|
11878
|
+
resolve38({
|
|
11880
11879
|
success: code8 === 0,
|
|
11881
11880
|
output: stdout + (stderr && code8 === 0 ? `
|
|
11882
11881
|
STDERR:
|
|
@@ -11886,7 +11885,7 @@ ${stderr}` : ""),
|
|
|
11886
11885
|
});
|
|
11887
11886
|
child.on("error", (err) => {
|
|
11888
11887
|
clearTimeout(timer);
|
|
11889
|
-
|
|
11888
|
+
resolve38({ success: false, output: stdout, error: err.message });
|
|
11890
11889
|
});
|
|
11891
11890
|
});
|
|
11892
11891
|
}
|
|
@@ -13534,7 +13533,7 @@ import { writeFile as writeFile8, mkdtemp, rm, readdir as readdir3, stat } from
|
|
|
13534
13533
|
import { join as join20 } from "node:path";
|
|
13535
13534
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13536
13535
|
function runProcess(cmd, args, options2) {
|
|
13537
|
-
return new Promise((
|
|
13536
|
+
return new Promise((resolve38) => {
|
|
13538
13537
|
const proc = spawn6(cmd, args, {
|
|
13539
13538
|
cwd: options2.cwd,
|
|
13540
13539
|
timeout: options2.timeout,
|
|
@@ -13564,7 +13563,7 @@ function runProcess(cmd, args, options2) {
|
|
|
13564
13563
|
}
|
|
13565
13564
|
});
|
|
13566
13565
|
proc.on("error", (err) => {
|
|
13567
|
-
|
|
13566
|
+
resolve38({
|
|
13568
13567
|
stdout,
|
|
13569
13568
|
stderr: stderr || err.message,
|
|
13570
13569
|
exitCode: 1,
|
|
@@ -13576,7 +13575,7 @@ function runProcess(cmd, args, options2) {
|
|
|
13576
13575
|
if (signal === "SIGTERM" || signal === "SIGKILL") {
|
|
13577
13576
|
timedOut = true;
|
|
13578
13577
|
}
|
|
13579
|
-
|
|
13578
|
+
resolve38({
|
|
13580
13579
|
stdout,
|
|
13581
13580
|
stderr,
|
|
13582
13581
|
exitCode: code8 ?? (timedOut ? 124 : 1),
|
|
@@ -23611,8 +23610,8 @@ var init_multiaddr = __esm({
|
|
|
23611
23610
|
// ../node_modules/p-defer/index.js
|
|
23612
23611
|
function pDefer() {
|
|
23613
23612
|
const deferred = {};
|
|
23614
|
-
deferred.promise = new Promise((
|
|
23615
|
-
deferred.resolve =
|
|
23613
|
+
deferred.promise = new Promise((resolve38, reject) => {
|
|
23614
|
+
deferred.resolve = resolve38;
|
|
23616
23615
|
deferred.reject = reject;
|
|
23617
23616
|
});
|
|
23618
23617
|
return deferred;
|
|
@@ -23744,12 +23743,12 @@ function _pushable(getNext, options2) {
|
|
|
23744
23743
|
if (ended) {
|
|
23745
23744
|
return { done: true };
|
|
23746
23745
|
}
|
|
23747
|
-
return await new Promise((
|
|
23746
|
+
return await new Promise((resolve38, reject) => {
|
|
23748
23747
|
onNext = (next) => {
|
|
23749
23748
|
onNext = null;
|
|
23750
23749
|
buffer2.push(next);
|
|
23751
23750
|
try {
|
|
23752
|
-
|
|
23751
|
+
resolve38(getNext(buffer2));
|
|
23753
23752
|
} catch (err) {
|
|
23754
23753
|
reject(err);
|
|
23755
23754
|
}
|
|
@@ -23825,7 +23824,7 @@ function _pushable(getNext, options2) {
|
|
|
23825
23824
|
let cancel;
|
|
23826
23825
|
let listener;
|
|
23827
23826
|
if (signal != null) {
|
|
23828
|
-
cancel = new Promise((
|
|
23827
|
+
cancel = new Promise((resolve38, reject) => {
|
|
23829
23828
|
listener = () => {
|
|
23830
23829
|
reject(new AbortError2());
|
|
23831
23830
|
};
|
|
@@ -23917,7 +23916,7 @@ function pTimeout(promise, options2) {
|
|
|
23917
23916
|
} = options2;
|
|
23918
23917
|
let timer;
|
|
23919
23918
|
let abortHandler;
|
|
23920
|
-
const wrappedPromise = new Promise((
|
|
23919
|
+
const wrappedPromise = new Promise((resolve38, reject) => {
|
|
23921
23920
|
if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
|
|
23922
23921
|
throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
|
|
23923
23922
|
}
|
|
@@ -23931,7 +23930,7 @@ function pTimeout(promise, options2) {
|
|
|
23931
23930
|
};
|
|
23932
23931
|
signal.addEventListener("abort", abortHandler, { once: true });
|
|
23933
23932
|
}
|
|
23934
|
-
promise.then(
|
|
23933
|
+
promise.then(resolve38, reject);
|
|
23935
23934
|
if (milliseconds === Number.POSITIVE_INFINITY) {
|
|
23936
23935
|
return;
|
|
23937
23936
|
}
|
|
@@ -23939,7 +23938,7 @@ function pTimeout(promise, options2) {
|
|
|
23939
23938
|
timer = customTimers.setTimeout.call(void 0, () => {
|
|
23940
23939
|
if (fallback) {
|
|
23941
23940
|
try {
|
|
23942
|
-
|
|
23941
|
+
resolve38(fallback());
|
|
23943
23942
|
} catch (error) {
|
|
23944
23943
|
reject(error);
|
|
23945
23944
|
}
|
|
@@ -23949,7 +23948,7 @@ function pTimeout(promise, options2) {
|
|
|
23949
23948
|
promise.cancel();
|
|
23950
23949
|
}
|
|
23951
23950
|
if (message2 === false) {
|
|
23952
|
-
|
|
23951
|
+
resolve38();
|
|
23953
23952
|
} else if (message2 instanceof Error) {
|
|
23954
23953
|
reject(message2);
|
|
23955
23954
|
} else {
|
|
@@ -23987,7 +23986,7 @@ var init_p_timeout = __esm({
|
|
|
23987
23986
|
// ../node_modules/p-event/index.js
|
|
23988
23987
|
function pEventMultiple(emitter, event, options2) {
|
|
23989
23988
|
let cancel;
|
|
23990
|
-
const returnValue = new Promise((
|
|
23989
|
+
const returnValue = new Promise((resolve38, reject) => {
|
|
23991
23990
|
options2 = {
|
|
23992
23991
|
rejectionEvents: ["error"],
|
|
23993
23992
|
multiArgs: false,
|
|
@@ -24018,7 +24017,7 @@ function pEventMultiple(emitter, event, options2) {
|
|
|
24018
24017
|
items.push(value2);
|
|
24019
24018
|
if (options2.count === items.length) {
|
|
24020
24019
|
cancel();
|
|
24021
|
-
|
|
24020
|
+
resolve38(items);
|
|
24022
24021
|
}
|
|
24023
24022
|
};
|
|
24024
24023
|
const rejectHandler = (...arguments_) => {
|
|
@@ -24049,7 +24048,7 @@ function pEventMultiple(emitter, event, options2) {
|
|
|
24049
24048
|
}, { once: true });
|
|
24050
24049
|
}
|
|
24051
24050
|
if (options2.resolveImmediately) {
|
|
24052
|
-
|
|
24051
|
+
resolve38(items);
|
|
24053
24052
|
}
|
|
24054
24053
|
});
|
|
24055
24054
|
returnValue.cancel = cancel;
|
|
@@ -24176,7 +24175,7 @@ async function raceSignal(promise, signal, opts) {
|
|
|
24176
24175
|
try {
|
|
24177
24176
|
return await Promise.race([
|
|
24178
24177
|
promise,
|
|
24179
|
-
new Promise((
|
|
24178
|
+
new Promise((resolve38, reject) => {
|
|
24180
24179
|
listener = () => {
|
|
24181
24180
|
reject(translateError(signal));
|
|
24182
24181
|
};
|
|
@@ -29909,10 +29908,10 @@ function createDelay({ clearTimeout: defaultClear, setTimeout: defaultSet } = {}
|
|
|
29909
29908
|
signal.removeEventListener("abort", signalListener);
|
|
29910
29909
|
}
|
|
29911
29910
|
};
|
|
29912
|
-
const delayPromise = new Promise((
|
|
29911
|
+
const delayPromise = new Promise((resolve38, reject) => {
|
|
29913
29912
|
settle = () => {
|
|
29914
29913
|
cleanup();
|
|
29915
|
-
|
|
29914
|
+
resolve38(value2);
|
|
29916
29915
|
};
|
|
29917
29916
|
rejectFunction = reject;
|
|
29918
29917
|
timeoutId = (defaultSet ?? setTimeout)(settle, milliseconds);
|
|
@@ -31377,7 +31376,7 @@ async function raceEvent(emitter, eventName, signal, opts) {
|
|
|
31377
31376
|
if (signal?.aborted === true) {
|
|
31378
31377
|
return Promise.reject(error);
|
|
31379
31378
|
}
|
|
31380
|
-
return new Promise((
|
|
31379
|
+
return new Promise((resolve38, reject) => {
|
|
31381
31380
|
function removeListeners() {
|
|
31382
31381
|
removeListener(signal, "abort", abortListener);
|
|
31383
31382
|
removeListener(emitter, eventName, eventListener);
|
|
@@ -31394,7 +31393,7 @@ async function raceEvent(emitter, eventName, signal, opts) {
|
|
|
31394
31393
|
return;
|
|
31395
31394
|
}
|
|
31396
31395
|
removeListeners();
|
|
31397
|
-
|
|
31396
|
+
resolve38(evt);
|
|
31398
31397
|
};
|
|
31399
31398
|
const errorEventListener = (evt) => {
|
|
31400
31399
|
removeListeners();
|
|
@@ -31901,7 +31900,7 @@ var init_channel = __esm({
|
|
|
31901
31900
|
name: requestEvent.name,
|
|
31902
31901
|
identifier: requestEvent.identifier
|
|
31903
31902
|
});
|
|
31904
|
-
await new Promise((
|
|
31903
|
+
await new Promise((resolve38) => {
|
|
31905
31904
|
const releaseEventListener = (event2) => {
|
|
31906
31905
|
if (event2?.data == null) {
|
|
31907
31906
|
return;
|
|
@@ -31913,7 +31912,7 @@ var init_channel = __esm({
|
|
|
31913
31912
|
};
|
|
31914
31913
|
if (releaseEvent.type === releaseType && releaseEvent.identifier === requestEvent.identifier) {
|
|
31915
31914
|
channel.removeEventListener("message", releaseEventListener);
|
|
31916
|
-
|
|
31915
|
+
resolve38();
|
|
31917
31916
|
}
|
|
31918
31917
|
};
|
|
31919
31918
|
channel.addEventListener("message", releaseEventListener);
|
|
@@ -31975,11 +31974,11 @@ var init_cluster = __esm({
|
|
|
31975
31974
|
name: requestEvent.name,
|
|
31976
31975
|
identifier: requestEvent.identifier
|
|
31977
31976
|
});
|
|
31978
|
-
await new Promise((
|
|
31977
|
+
await new Promise((resolve38) => {
|
|
31979
31978
|
const releaseEventListener = (releaseEvent) => {
|
|
31980
31979
|
if (releaseEvent.type === releaseType && releaseEvent.identifier === requestEvent.identifier) {
|
|
31981
31980
|
worker2.removeListener("message", releaseEventListener);
|
|
31982
|
-
|
|
31981
|
+
resolve38();
|
|
31983
31982
|
}
|
|
31984
31983
|
};
|
|
31985
31984
|
worker2.on("message", releaseEventListener);
|
|
@@ -32064,7 +32063,7 @@ var init_channel2 = __esm({
|
|
|
32064
32063
|
identifier: id,
|
|
32065
32064
|
name: this.name
|
|
32066
32065
|
});
|
|
32067
|
-
return new Promise((
|
|
32066
|
+
return new Promise((resolve38, reject) => {
|
|
32068
32067
|
const abortListener = () => {
|
|
32069
32068
|
this.channel.postMessage({
|
|
32070
32069
|
type: abortType,
|
|
@@ -32082,7 +32081,7 @@ var init_channel2 = __esm({
|
|
|
32082
32081
|
if (event.data?.type === grantType) {
|
|
32083
32082
|
this.channel.removeEventListener("message", listener);
|
|
32084
32083
|
options2?.signal?.removeEventListener("abort", abortListener);
|
|
32085
|
-
|
|
32084
|
+
resolve38(() => {
|
|
32086
32085
|
this.channel.postMessage({
|
|
32087
32086
|
type: releaseType,
|
|
32088
32087
|
identifier: id,
|
|
@@ -32147,7 +32146,7 @@ var init_cluster2 = __esm({
|
|
|
32147
32146
|
identifier: id,
|
|
32148
32147
|
name: this.name
|
|
32149
32148
|
});
|
|
32150
|
-
return new Promise((
|
|
32149
|
+
return new Promise((resolve38, reject) => {
|
|
32151
32150
|
const abortListener = () => {
|
|
32152
32151
|
process.send?.({
|
|
32153
32152
|
type: abortType,
|
|
@@ -32165,7 +32164,7 @@ var init_cluster2 = __esm({
|
|
|
32165
32164
|
if (event.type === grantType) {
|
|
32166
32165
|
process.removeListener("message", listener);
|
|
32167
32166
|
options2?.signal?.removeEventListener("abort", abortListener);
|
|
32168
|
-
|
|
32167
|
+
resolve38(() => {
|
|
32169
32168
|
process.send?.({
|
|
32170
32169
|
type: releaseType,
|
|
32171
32170
|
identifier: id,
|
|
@@ -32314,8 +32313,8 @@ function getImplementation(opts) {
|
|
|
32314
32313
|
async function createReleasable(queue, options2) {
|
|
32315
32314
|
let res;
|
|
32316
32315
|
let rej;
|
|
32317
|
-
const p2 = new Promise((
|
|
32318
|
-
res =
|
|
32316
|
+
const p2 = new Promise((resolve38, reject) => {
|
|
32317
|
+
res = resolve38;
|
|
32319
32318
|
rej = reject;
|
|
32320
32319
|
});
|
|
32321
32320
|
const listener = () => {
|
|
@@ -32325,10 +32324,10 @@ async function createReleasable(queue, options2) {
|
|
|
32325
32324
|
once: true
|
|
32326
32325
|
});
|
|
32327
32326
|
queue.add(async () => {
|
|
32328
|
-
await new Promise((
|
|
32327
|
+
await new Promise((resolve38) => {
|
|
32329
32328
|
res(() => {
|
|
32330
32329
|
options2?.signal?.removeEventListener("abort", listener);
|
|
32331
|
-
|
|
32330
|
+
resolve38();
|
|
32332
32331
|
});
|
|
32333
32332
|
});
|
|
32334
32333
|
}, {
|
|
@@ -40040,7 +40039,7 @@ var init_dist3 = __esm({
|
|
|
40040
40039
|
// Assign unique ID if not provided
|
|
40041
40040
|
id: options2.id ?? (this.#idAssigner++).toString()
|
|
40042
40041
|
};
|
|
40043
|
-
return new Promise((
|
|
40042
|
+
return new Promise((resolve38, reject) => {
|
|
40044
40043
|
const taskSymbol = /* @__PURE__ */ Symbol(`task-${options2.id}`);
|
|
40045
40044
|
this.#queue.enqueue(async () => {
|
|
40046
40045
|
this.#pending++;
|
|
@@ -40078,7 +40077,7 @@ var init_dist3 = __esm({
|
|
|
40078
40077
|
})]);
|
|
40079
40078
|
}
|
|
40080
40079
|
const result = await operation;
|
|
40081
|
-
|
|
40080
|
+
resolve38(result);
|
|
40082
40081
|
this.emit("completed", result);
|
|
40083
40082
|
} catch (error) {
|
|
40084
40083
|
reject(error);
|
|
@@ -40235,13 +40234,13 @@ var init_dist3 = __esm({
|
|
|
40235
40234
|
});
|
|
40236
40235
|
}
|
|
40237
40236
|
async #onEvent(event, filter2) {
|
|
40238
|
-
return new Promise((
|
|
40237
|
+
return new Promise((resolve38) => {
|
|
40239
40238
|
const listener = () => {
|
|
40240
40239
|
if (filter2 && !filter2()) {
|
|
40241
40240
|
return;
|
|
40242
40241
|
}
|
|
40243
40242
|
this.off(event, listener);
|
|
40244
|
-
|
|
40243
|
+
resolve38();
|
|
40245
40244
|
};
|
|
40246
40245
|
this.on(event, listener);
|
|
40247
40246
|
});
|
|
@@ -45377,7 +45376,7 @@ async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTi
|
|
|
45377
45376
|
const finalDelay = Math.min(delayTime, remainingTime);
|
|
45378
45377
|
options2.signal?.throwIfAborted();
|
|
45379
45378
|
if (finalDelay > 0) {
|
|
45380
|
-
await new Promise((
|
|
45379
|
+
await new Promise((resolve38, reject) => {
|
|
45381
45380
|
const onAbort = () => {
|
|
45382
45381
|
clearTimeout(timeoutToken);
|
|
45383
45382
|
options2.signal?.removeEventListener("abort", onAbort);
|
|
@@ -45385,7 +45384,7 @@ async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTi
|
|
|
45385
45384
|
};
|
|
45386
45385
|
const timeoutToken = setTimeout(() => {
|
|
45387
45386
|
options2.signal?.removeEventListener("abort", onAbort);
|
|
45388
|
-
|
|
45387
|
+
resolve38();
|
|
45389
45388
|
}, finalDelay);
|
|
45390
45389
|
if (options2.unref) {
|
|
45391
45390
|
timeoutToken.unref?.();
|
|
@@ -47462,12 +47461,12 @@ var init_connection2 = __esm({
|
|
|
47462
47461
|
for (let i2 = 0; i2 < middleware.length; i2++) {
|
|
47463
47462
|
const mw = middleware[i2];
|
|
47464
47463
|
stream.log.trace("running middleware", i2, mw);
|
|
47465
|
-
await new Promise((
|
|
47464
|
+
await new Promise((resolve38, reject) => {
|
|
47466
47465
|
try {
|
|
47467
47466
|
const result = mw(stream, connection, (s2, c4) => {
|
|
47468
47467
|
stream = s2;
|
|
47469
47468
|
connection = c4;
|
|
47470
|
-
|
|
47469
|
+
resolve38();
|
|
47471
47470
|
});
|
|
47472
47471
|
if (result instanceof Promise) {
|
|
47473
47472
|
result.catch(reject);
|
|
@@ -52466,7 +52465,7 @@ async function randomDelay() {
|
|
|
52466
52465
|
const min = 200;
|
|
52467
52466
|
const max = 1e3;
|
|
52468
52467
|
const delay3 = Math.random() * (max - min) + min;
|
|
52469
|
-
await new Promise((
|
|
52468
|
+
await new Promise((resolve38) => setTimeout(resolve38, delay3));
|
|
52470
52469
|
}
|
|
52471
52470
|
function DsName(name10) {
|
|
52472
52471
|
return new Key(keyPrefix + name10);
|
|
@@ -59522,11 +59521,11 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
59522
59521
|
}
|
|
59523
59522
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
59524
59523
|
function adopt(value2) {
|
|
59525
|
-
return value2 instanceof P ? value2 : new P(function(
|
|
59526
|
-
|
|
59524
|
+
return value2 instanceof P ? value2 : new P(function(resolve38) {
|
|
59525
|
+
resolve38(value2);
|
|
59527
59526
|
});
|
|
59528
59527
|
}
|
|
59529
|
-
return new (P || (P = Promise))(function(
|
|
59528
|
+
return new (P || (P = Promise))(function(resolve38, reject) {
|
|
59530
59529
|
function fulfilled(value2) {
|
|
59531
59530
|
try {
|
|
59532
59531
|
step(generator.next(value2));
|
|
@@ -59542,7 +59541,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
59542
59541
|
}
|
|
59543
59542
|
}
|
|
59544
59543
|
function step(result) {
|
|
59545
|
-
result.done ?
|
|
59544
|
+
result.done ? resolve38(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
59546
59545
|
}
|
|
59547
59546
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
59548
59547
|
});
|
|
@@ -59733,14 +59732,14 @@ function __asyncValues(o2) {
|
|
|
59733
59732
|
}, i2);
|
|
59734
59733
|
function verb(n2) {
|
|
59735
59734
|
i2[n2] = o2[n2] && function(v) {
|
|
59736
|
-
return new Promise(function(
|
|
59737
|
-
v = o2[n2](v), settle(
|
|
59735
|
+
return new Promise(function(resolve38, reject) {
|
|
59736
|
+
v = o2[n2](v), settle(resolve38, reject, v.done, v.value);
|
|
59738
59737
|
});
|
|
59739
59738
|
};
|
|
59740
59739
|
}
|
|
59741
|
-
function settle(
|
|
59740
|
+
function settle(resolve38, reject, d2, v) {
|
|
59742
59741
|
Promise.resolve(v).then(function(v2) {
|
|
59743
|
-
|
|
59742
|
+
resolve38({ value: v2, done: d2 });
|
|
59744
59743
|
}, reject);
|
|
59745
59744
|
}
|
|
59746
59745
|
}
|
|
@@ -65268,11 +65267,11 @@ function __metadata2(metadataKey, metadataValue) {
|
|
|
65268
65267
|
}
|
|
65269
65268
|
function __awaiter2(thisArg, _arguments, P, generator) {
|
|
65270
65269
|
function adopt(value2) {
|
|
65271
|
-
return value2 instanceof P ? value2 : new P(function(
|
|
65272
|
-
|
|
65270
|
+
return value2 instanceof P ? value2 : new P(function(resolve38) {
|
|
65271
|
+
resolve38(value2);
|
|
65273
65272
|
});
|
|
65274
65273
|
}
|
|
65275
|
-
return new (P || (P = Promise))(function(
|
|
65274
|
+
return new (P || (P = Promise))(function(resolve38, reject) {
|
|
65276
65275
|
function fulfilled(value2) {
|
|
65277
65276
|
try {
|
|
65278
65277
|
step(generator.next(value2));
|
|
@@ -65288,7 +65287,7 @@ function __awaiter2(thisArg, _arguments, P, generator) {
|
|
|
65288
65287
|
}
|
|
65289
65288
|
}
|
|
65290
65289
|
function step(result) {
|
|
65291
|
-
result.done ?
|
|
65290
|
+
result.done ? resolve38(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
65292
65291
|
}
|
|
65293
65292
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
65294
65293
|
});
|
|
@@ -65466,14 +65465,14 @@ function __asyncValues2(o2) {
|
|
|
65466
65465
|
}, i2);
|
|
65467
65466
|
function verb(n2) {
|
|
65468
65467
|
i2[n2] = o2[n2] && function(v) {
|
|
65469
|
-
return new Promise(function(
|
|
65470
|
-
v = o2[n2](v), settle(
|
|
65468
|
+
return new Promise(function(resolve38, reject) {
|
|
65469
|
+
v = o2[n2](v), settle(resolve38, reject, v.done, v.value);
|
|
65471
65470
|
});
|
|
65472
65471
|
};
|
|
65473
65472
|
}
|
|
65474
|
-
function settle(
|
|
65473
|
+
function settle(resolve38, reject, d2, v) {
|
|
65475
65474
|
Promise.resolve(v).then(function(v2) {
|
|
65476
|
-
|
|
65475
|
+
resolve38({ value: v2, done: d2 });
|
|
65477
65476
|
}, reject);
|
|
65478
65477
|
}
|
|
65479
65478
|
}
|
|
@@ -83883,10 +83882,10 @@ var require_axios = __commonJS({
|
|
|
83883
83882
|
}
|
|
83884
83883
|
};
|
|
83885
83884
|
var CanceledError$1 = CanceledError;
|
|
83886
|
-
function settle(
|
|
83885
|
+
function settle(resolve38, reject, response) {
|
|
83887
83886
|
const validateStatus = response.config.validateStatus;
|
|
83888
83887
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
83889
|
-
|
|
83888
|
+
resolve38(response);
|
|
83890
83889
|
} else {
|
|
83891
83890
|
reject(
|
|
83892
83891
|
new AxiosError$1(
|
|
@@ -84478,7 +84477,7 @@ var require_axios = __commonJS({
|
|
|
84478
84477
|
}
|
|
84479
84478
|
var isHttpAdapterSupported = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
|
|
84480
84479
|
var wrapAsync = (asyncExecutor) => {
|
|
84481
|
-
return new Promise((
|
|
84480
|
+
return new Promise((resolve38, reject) => {
|
|
84482
84481
|
let onDone;
|
|
84483
84482
|
let isDone;
|
|
84484
84483
|
const done = (value2, isRejected) => {
|
|
@@ -84488,7 +84487,7 @@ var require_axios = __commonJS({
|
|
|
84488
84487
|
};
|
|
84489
84488
|
const _resolve = (value2) => {
|
|
84490
84489
|
done(value2);
|
|
84491
|
-
|
|
84490
|
+
resolve38(value2);
|
|
84492
84491
|
};
|
|
84493
84492
|
const _reject = (reason) => {
|
|
84494
84493
|
done(reason, true);
|
|
@@ -84535,7 +84534,7 @@ var require_axios = __commonJS({
|
|
|
84535
84534
|
}
|
|
84536
84535
|
};
|
|
84537
84536
|
var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config) {
|
|
84538
|
-
return wrapAsync(async function dispatchHttpRequest(
|
|
84537
|
+
return wrapAsync(async function dispatchHttpRequest(resolve38, reject, onDone) {
|
|
84539
84538
|
let { data, lookup, family, httpVersion = 1, http2Options } = config;
|
|
84540
84539
|
const { responseType, responseEncoding } = config;
|
|
84541
84540
|
const method = config.method.toUpperCase();
|
|
@@ -84625,7 +84624,7 @@ var require_axios = __commonJS({
|
|
|
84625
84624
|
}
|
|
84626
84625
|
let convertedData;
|
|
84627
84626
|
if (method !== "GET") {
|
|
84628
|
-
return settle(
|
|
84627
|
+
return settle(resolve38, reject, {
|
|
84629
84628
|
status: 405,
|
|
84630
84629
|
statusText: "method not allowed",
|
|
84631
84630
|
headers: {},
|
|
@@ -84647,7 +84646,7 @@ var require_axios = __commonJS({
|
|
|
84647
84646
|
} else if (responseType === "stream") {
|
|
84648
84647
|
convertedData = stream__default["default"].Readable.from(convertedData);
|
|
84649
84648
|
}
|
|
84650
|
-
return settle(
|
|
84649
|
+
return settle(resolve38, reject, {
|
|
84651
84650
|
data: convertedData,
|
|
84652
84651
|
status: 200,
|
|
84653
84652
|
statusText: "OK",
|
|
@@ -84888,7 +84887,7 @@ var require_axios = __commonJS({
|
|
|
84888
84887
|
};
|
|
84889
84888
|
if (responseType === "stream") {
|
|
84890
84889
|
response.data = responseStream;
|
|
84891
|
-
settle(
|
|
84890
|
+
settle(resolve38, reject, response);
|
|
84892
84891
|
} else {
|
|
84893
84892
|
const responseBuffer = [];
|
|
84894
84893
|
let totalResponseBytes = 0;
|
|
@@ -84938,7 +84937,7 @@ var require_axios = __commonJS({
|
|
|
84938
84937
|
} catch (err) {
|
|
84939
84938
|
return reject(AxiosError$1.from(err, null, config, response.request, response));
|
|
84940
84939
|
}
|
|
84941
|
-
settle(
|
|
84940
|
+
settle(resolve38, reject, response);
|
|
84942
84941
|
});
|
|
84943
84942
|
}
|
|
84944
84943
|
abortEmitter.once("abort", (err) => {
|
|
@@ -85188,7 +85187,7 @@ var require_axios = __commonJS({
|
|
|
85188
85187
|
};
|
|
85189
85188
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
85190
85189
|
var xhrAdapter = isXHRAdapterSupported && function(config) {
|
|
85191
|
-
return new Promise(function dispatchXhrRequest(
|
|
85190
|
+
return new Promise(function dispatchXhrRequest(resolve38, reject) {
|
|
85192
85191
|
const _config2 = resolveConfig(config);
|
|
85193
85192
|
let requestData = _config2.data;
|
|
85194
85193
|
const requestHeaders = AxiosHeaders$1.from(_config2.headers).normalize();
|
|
@@ -85223,7 +85222,7 @@ var require_axios = __commonJS({
|
|
|
85223
85222
|
};
|
|
85224
85223
|
settle(
|
|
85225
85224
|
function _resolve(value2) {
|
|
85226
|
-
|
|
85225
|
+
resolve38(value2);
|
|
85227
85226
|
done();
|
|
85228
85227
|
},
|
|
85229
85228
|
function _reject(err) {
|
|
@@ -85615,8 +85614,8 @@ var require_axios = __commonJS({
|
|
|
85615
85614
|
config
|
|
85616
85615
|
);
|
|
85617
85616
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
85618
|
-
return await new Promise((
|
|
85619
|
-
settle(
|
|
85617
|
+
return await new Promise((resolve38, reject) => {
|
|
85618
|
+
settle(resolve38, reject, {
|
|
85620
85619
|
data: responseData,
|
|
85621
85620
|
headers: AxiosHeaders$1.from(response.headers),
|
|
85622
85621
|
status: response.status,
|
|
@@ -86020,8 +86019,8 @@ var require_axios = __commonJS({
|
|
|
86020
86019
|
throw new TypeError("executor must be a function.");
|
|
86021
86020
|
}
|
|
86022
86021
|
let resolvePromise;
|
|
86023
|
-
this.promise = new Promise(function promiseExecutor(
|
|
86024
|
-
resolvePromise =
|
|
86022
|
+
this.promise = new Promise(function promiseExecutor(resolve38) {
|
|
86023
|
+
resolvePromise = resolve38;
|
|
86025
86024
|
});
|
|
86026
86025
|
const token = this;
|
|
86027
86026
|
this.promise.then((cancel) => {
|
|
@@ -86034,9 +86033,9 @@ var require_axios = __commonJS({
|
|
|
86034
86033
|
});
|
|
86035
86034
|
this.promise.then = (onfulfilled) => {
|
|
86036
86035
|
let _resolve;
|
|
86037
|
-
const promise = new Promise((
|
|
86038
|
-
token.subscribe(
|
|
86039
|
-
_resolve =
|
|
86036
|
+
const promise = new Promise((resolve38) => {
|
|
86037
|
+
token.subscribe(resolve38);
|
|
86038
|
+
_resolve = resolve38;
|
|
86040
86039
|
}).then(onfulfilled);
|
|
86041
86040
|
promise.cancel = function reject() {
|
|
86042
86041
|
token.unsubscribe(_resolve);
|
|
@@ -86264,8 +86263,8 @@ var require_util = __commonJS({
|
|
|
86264
86263
|
}
|
|
86265
86264
|
const duration = backoff.duration();
|
|
86266
86265
|
log22(`Promise rejected attempt #${backoff.attempts}, retrying in ${duration}ms: ${e2.message}`);
|
|
86267
|
-
await new Promise((
|
|
86268
|
-
setTimeout(
|
|
86266
|
+
await new Promise((resolve38) => {
|
|
86267
|
+
setTimeout(resolve38, duration);
|
|
86269
86268
|
});
|
|
86270
86269
|
return retryPromise(fn, attempts, backoff);
|
|
86271
86270
|
}
|
|
@@ -86370,7 +86369,7 @@ var require_util = __commonJS({
|
|
|
86370
86369
|
return resolver;
|
|
86371
86370
|
}
|
|
86372
86371
|
async function retrieveTlsAlpnCertificate(host, port, timeout2 = 3e4) {
|
|
86373
|
-
return new Promise((
|
|
86372
|
+
return new Promise((resolve38, reject) => {
|
|
86374
86373
|
let result;
|
|
86375
86374
|
const socket = tls2.connect({
|
|
86376
86375
|
host,
|
|
@@ -86393,7 +86392,7 @@ var require_util = __commonJS({
|
|
|
86393
86392
|
});
|
|
86394
86393
|
socket.on("end", () => {
|
|
86395
86394
|
if (result) {
|
|
86396
|
-
return
|
|
86395
|
+
return resolve38(result.toString());
|
|
86397
86396
|
}
|
|
86398
86397
|
return reject(new Error("TLS ALPN lookup failed to retrieve certificate"));
|
|
86399
86398
|
});
|
|
@@ -86534,8 +86533,8 @@ var require_axios2 = __commonJS({
|
|
|
86534
86533
|
retryAfter = retryDefaultDelay * config.retryAttempt;
|
|
86535
86534
|
log22(`Unable to locate or parse retry-after response header, waiting ${retryAfter} seconds`);
|
|
86536
86535
|
}
|
|
86537
|
-
await new Promise((
|
|
86538
|
-
setTimeout(
|
|
86536
|
+
await new Promise((resolve38) => {
|
|
86537
|
+
setTimeout(resolve38, retryAfter * 1e3);
|
|
86539
86538
|
});
|
|
86540
86539
|
return instance(config);
|
|
86541
86540
|
}
|
|
@@ -105764,10 +105763,10 @@ function createDelay2({ clearTimeout: defaultClear, setTimeout: defaultSet } = {
|
|
|
105764
105763
|
signal.removeEventListener("abort", signalListener);
|
|
105765
105764
|
}
|
|
105766
105765
|
};
|
|
105767
|
-
const delayPromise = new Promise((
|
|
105766
|
+
const delayPromise = new Promise((resolve38, reject) => {
|
|
105768
105767
|
settle = () => {
|
|
105769
105768
|
cleanup();
|
|
105770
|
-
|
|
105769
|
+
resolve38(value2);
|
|
105771
105770
|
};
|
|
105772
105771
|
rejectFunction = reject;
|
|
105773
105772
|
timeoutId = (defaultSet ?? setTimeout)(settle, milliseconds);
|
|
@@ -112569,9 +112568,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
112569
112568
|
}
|
|
112570
112569
|
close(callback) {
|
|
112571
112570
|
if (callback === void 0) {
|
|
112572
|
-
return new Promise((
|
|
112571
|
+
return new Promise((resolve38, reject) => {
|
|
112573
112572
|
this.close((err, data) => {
|
|
112574
|
-
return err ? reject(err) :
|
|
112573
|
+
return err ? reject(err) : resolve38(data);
|
|
112575
112574
|
});
|
|
112576
112575
|
});
|
|
112577
112576
|
}
|
|
@@ -112609,9 +112608,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
112609
112608
|
err = null;
|
|
112610
112609
|
}
|
|
112611
112610
|
if (callback === void 0) {
|
|
112612
|
-
return new Promise((
|
|
112611
|
+
return new Promise((resolve38, reject) => {
|
|
112613
112612
|
this.destroy(err, (err2, data) => {
|
|
112614
|
-
return err2 ? reject(err2) :
|
|
112613
|
+
return err2 ? reject(err2) : resolve38(data);
|
|
112615
112614
|
});
|
|
112616
112615
|
});
|
|
112617
112616
|
}
|
|
@@ -116088,8 +116087,8 @@ var require_promise = __commonJS({
|
|
|
116088
116087
|
function createDeferredPromise2() {
|
|
116089
116088
|
let res;
|
|
116090
116089
|
let rej;
|
|
116091
|
-
const promise = new Promise((
|
|
116092
|
-
res =
|
|
116090
|
+
const promise = new Promise((resolve38, reject) => {
|
|
116091
|
+
res = resolve38;
|
|
116093
116092
|
rej = reject;
|
|
116094
116093
|
});
|
|
116095
116094
|
return { promise, resolve: res, reject: rej };
|
|
@@ -117390,12 +117389,12 @@ upgrade: ${upgrade}\r
|
|
|
117390
117389
|
cb();
|
|
117391
117390
|
}
|
|
117392
117391
|
}
|
|
117393
|
-
const waitForDrain = () => new Promise((
|
|
117392
|
+
const waitForDrain = () => new Promise((resolve38, reject) => {
|
|
117394
117393
|
assert(callback === null);
|
|
117395
117394
|
if (socket[kError]) {
|
|
117396
117395
|
reject(socket[kError]);
|
|
117397
117396
|
} else {
|
|
117398
|
-
callback =
|
|
117397
|
+
callback = resolve38;
|
|
117399
117398
|
}
|
|
117400
117399
|
});
|
|
117401
117400
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -118240,12 +118239,12 @@ var require_client_h2 = __commonJS({
|
|
|
118240
118239
|
cb();
|
|
118241
118240
|
}
|
|
118242
118241
|
}
|
|
118243
|
-
const waitForDrain = () => new Promise((
|
|
118242
|
+
const waitForDrain = () => new Promise((resolve38, reject) => {
|
|
118244
118243
|
assert(callback === null);
|
|
118245
118244
|
if (socket[kError]) {
|
|
118246
118245
|
reject(socket[kError]);
|
|
118247
118246
|
} else {
|
|
118248
|
-
callback =
|
|
118247
|
+
callback = resolve38;
|
|
118249
118248
|
}
|
|
118250
118249
|
});
|
|
118251
118250
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -118556,16 +118555,16 @@ var require_client2 = __commonJS({
|
|
|
118556
118555
|
return this[kNeedDrain] < 2;
|
|
118557
118556
|
}
|
|
118558
118557
|
[kClose]() {
|
|
118559
|
-
return new Promise((
|
|
118558
|
+
return new Promise((resolve38) => {
|
|
118560
118559
|
if (this[kSize]) {
|
|
118561
|
-
this[kClosedResolve] =
|
|
118560
|
+
this[kClosedResolve] = resolve38;
|
|
118562
118561
|
} else {
|
|
118563
|
-
|
|
118562
|
+
resolve38(null);
|
|
118564
118563
|
}
|
|
118565
118564
|
});
|
|
118566
118565
|
}
|
|
118567
118566
|
[kDestroy](err) {
|
|
118568
|
-
return new Promise((
|
|
118567
|
+
return new Promise((resolve38) => {
|
|
118569
118568
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
118570
118569
|
for (let i2 = 0; i2 < requests.length; i2++) {
|
|
118571
118570
|
const request = requests[i2];
|
|
@@ -118576,7 +118575,7 @@ var require_client2 = __commonJS({
|
|
|
118576
118575
|
this[kClosedResolve]();
|
|
118577
118576
|
this[kClosedResolve] = null;
|
|
118578
118577
|
}
|
|
118579
|
-
|
|
118578
|
+
resolve38(null);
|
|
118580
118579
|
};
|
|
118581
118580
|
if (this[kHTTPContext]) {
|
|
118582
118581
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -118981,8 +118980,8 @@ var require_pool_base = __commonJS({
|
|
|
118981
118980
|
}
|
|
118982
118981
|
return Promise.all(closeAll);
|
|
118983
118982
|
} else {
|
|
118984
|
-
return new Promise((
|
|
118985
|
-
this[kClosedResolve] =
|
|
118983
|
+
return new Promise((resolve38) => {
|
|
118984
|
+
this[kClosedResolve] = resolve38;
|
|
118986
118985
|
});
|
|
118987
118986
|
}
|
|
118988
118987
|
}
|
|
@@ -120074,10 +120073,10 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
120074
120073
|
const proxyHost = this[kProxyUrl].hostname;
|
|
120075
120074
|
const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
|
|
120076
120075
|
debug("creating SOCKS5 connection to", proxyHost, proxyPort);
|
|
120077
|
-
const socket = await new Promise((
|
|
120076
|
+
const socket = await new Promise((resolve38, reject) => {
|
|
120078
120077
|
const onConnect = () => {
|
|
120079
120078
|
socket2.removeListener("error", onError);
|
|
120080
|
-
|
|
120079
|
+
resolve38(socket2);
|
|
120081
120080
|
};
|
|
120082
120081
|
const onError = (err) => {
|
|
120083
120082
|
socket2.removeListener("connect", onConnect);
|
|
@@ -120096,14 +120095,14 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
120096
120095
|
socket.destroy();
|
|
120097
120096
|
});
|
|
120098
120097
|
await socks5Client.handshake();
|
|
120099
|
-
await new Promise((
|
|
120098
|
+
await new Promise((resolve38, reject) => {
|
|
120100
120099
|
const timeout2 = setTimeout(() => {
|
|
120101
120100
|
reject(new Error("SOCKS5 authentication timeout"));
|
|
120102
120101
|
}, 5e3);
|
|
120103
120102
|
const onAuthenticated = () => {
|
|
120104
120103
|
clearTimeout(timeout2);
|
|
120105
120104
|
socks5Client.removeListener("error", onError);
|
|
120106
|
-
|
|
120105
|
+
resolve38();
|
|
120107
120106
|
};
|
|
120108
120107
|
const onError = (err) => {
|
|
120109
120108
|
clearTimeout(timeout2);
|
|
@@ -120112,14 +120111,14 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
120112
120111
|
};
|
|
120113
120112
|
if (socks5Client.state === "authenticated") {
|
|
120114
120113
|
clearTimeout(timeout2);
|
|
120115
|
-
|
|
120114
|
+
resolve38();
|
|
120116
120115
|
} else {
|
|
120117
120116
|
socks5Client.once("authenticated", onAuthenticated);
|
|
120118
120117
|
socks5Client.once("error", onError);
|
|
120119
120118
|
}
|
|
120120
120119
|
});
|
|
120121
120120
|
await socks5Client.connect(targetHost, targetPort);
|
|
120122
|
-
await new Promise((
|
|
120121
|
+
await new Promise((resolve38, reject) => {
|
|
120123
120122
|
const timeout2 = setTimeout(() => {
|
|
120124
120123
|
reject(new Error("SOCKS5 connection timeout"));
|
|
120125
120124
|
}, 5e3);
|
|
@@ -120127,7 +120126,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
120127
120126
|
debug("SOCKS5 tunnel established to", targetHost, targetPort, "via", info);
|
|
120128
120127
|
clearTimeout(timeout2);
|
|
120129
120128
|
socks5Client.removeListener("error", onError);
|
|
120130
|
-
|
|
120129
|
+
resolve38();
|
|
120131
120130
|
};
|
|
120132
120131
|
const onError = (err) => {
|
|
120133
120132
|
clearTimeout(timeout2);
|
|
@@ -120168,8 +120167,8 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
120168
120167
|
servername: targetHost,
|
|
120169
120168
|
...connectOpts.tls || {}
|
|
120170
120169
|
});
|
|
120171
|
-
await new Promise((
|
|
120172
|
-
finalSocket.once("secureConnect",
|
|
120170
|
+
await new Promise((resolve38, reject) => {
|
|
120171
|
+
finalSocket.once("secureConnect", resolve38);
|
|
120173
120172
|
finalSocket.once("error", reject);
|
|
120174
120173
|
});
|
|
120175
120174
|
}
|
|
@@ -121194,7 +121193,7 @@ var require_readable = __commonJS({
|
|
|
121194
121193
|
if (this._readableState.closeEmitted) {
|
|
121195
121194
|
return Promise.resolve(null);
|
|
121196
121195
|
}
|
|
121197
|
-
return new Promise((
|
|
121196
|
+
return new Promise((resolve38, reject) => {
|
|
121198
121197
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
121199
121198
|
this.destroy(new AbortError6());
|
|
121200
121199
|
}
|
|
@@ -121208,11 +121207,11 @@ var require_readable = __commonJS({
|
|
|
121208
121207
|
if (signal.aborted) {
|
|
121209
121208
|
reject(signal.reason ?? new AbortError6());
|
|
121210
121209
|
} else {
|
|
121211
|
-
|
|
121210
|
+
resolve38(null);
|
|
121212
121211
|
}
|
|
121213
121212
|
});
|
|
121214
121213
|
} else {
|
|
121215
|
-
this.on("close",
|
|
121214
|
+
this.on("close", resolve38);
|
|
121216
121215
|
}
|
|
121217
121216
|
this.on("error", noop2).on("data", () => {
|
|
121218
121217
|
if (this[kBytesRead] > limit) {
|
|
@@ -121240,7 +121239,7 @@ var require_readable = __commonJS({
|
|
|
121240
121239
|
}
|
|
121241
121240
|
function consume(stream, type) {
|
|
121242
121241
|
assert(!stream[kConsume]);
|
|
121243
|
-
return new Promise((
|
|
121242
|
+
return new Promise((resolve38, reject) => {
|
|
121244
121243
|
if (isUnusable(stream)) {
|
|
121245
121244
|
const rState = stream._readableState;
|
|
121246
121245
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -121255,7 +121254,7 @@ var require_readable = __commonJS({
|
|
|
121255
121254
|
stream[kConsume] = {
|
|
121256
121255
|
type,
|
|
121257
121256
|
stream,
|
|
121258
|
-
resolve:
|
|
121257
|
+
resolve: resolve38,
|
|
121259
121258
|
reject,
|
|
121260
121259
|
length: 0,
|
|
121261
121260
|
body: []
|
|
@@ -121329,18 +121328,18 @@ var require_readable = __commonJS({
|
|
|
121329
121328
|
return buffer2;
|
|
121330
121329
|
}
|
|
121331
121330
|
function consumeEnd(consume2, encoding) {
|
|
121332
|
-
const { type, body, resolve:
|
|
121331
|
+
const { type, body, resolve: resolve38, stream, length: length4 } = consume2;
|
|
121333
121332
|
try {
|
|
121334
121333
|
if (type === "text") {
|
|
121335
|
-
|
|
121334
|
+
resolve38(chunksDecode(body, length4, encoding));
|
|
121336
121335
|
} else if (type === "json") {
|
|
121337
|
-
|
|
121336
|
+
resolve38(JSON.parse(chunksDecode(body, length4, encoding)));
|
|
121338
121337
|
} else if (type === "arrayBuffer") {
|
|
121339
|
-
|
|
121338
|
+
resolve38(chunksConcat(body, length4).buffer);
|
|
121340
121339
|
} else if (type === "blob") {
|
|
121341
|
-
|
|
121340
|
+
resolve38(new Blob(body, { type: stream[kContentType] }));
|
|
121342
121341
|
} else if (type === "bytes") {
|
|
121343
|
-
|
|
121342
|
+
resolve38(chunksConcat(body, length4));
|
|
121344
121343
|
}
|
|
121345
121344
|
consumeFinish(consume2);
|
|
121346
121345
|
} catch (err) {
|
|
@@ -121530,9 +121529,9 @@ var require_api_request = __commonJS({
|
|
|
121530
121529
|
};
|
|
121531
121530
|
function request(opts, callback) {
|
|
121532
121531
|
if (callback === void 0) {
|
|
121533
|
-
return new Promise((
|
|
121532
|
+
return new Promise((resolve38, reject) => {
|
|
121534
121533
|
request.call(this, opts, (err, data) => {
|
|
121535
|
-
return err ? reject(err) :
|
|
121534
|
+
return err ? reject(err) : resolve38(data);
|
|
121536
121535
|
});
|
|
121537
121536
|
});
|
|
121538
121537
|
}
|
|
@@ -121744,9 +121743,9 @@ var require_api_stream = __commonJS({
|
|
|
121744
121743
|
};
|
|
121745
121744
|
function stream(opts, factory, callback) {
|
|
121746
121745
|
if (callback === void 0) {
|
|
121747
|
-
return new Promise((
|
|
121746
|
+
return new Promise((resolve38, reject) => {
|
|
121748
121747
|
stream.call(this, opts, factory, (err, data) => {
|
|
121749
|
-
return err ? reject(err) :
|
|
121748
|
+
return err ? reject(err) : resolve38(data);
|
|
121750
121749
|
});
|
|
121751
121750
|
});
|
|
121752
121751
|
}
|
|
@@ -122034,9 +122033,9 @@ var require_api_upgrade = __commonJS({
|
|
|
122034
122033
|
};
|
|
122035
122034
|
function upgrade(opts, callback) {
|
|
122036
122035
|
if (callback === void 0) {
|
|
122037
|
-
return new Promise((
|
|
122036
|
+
return new Promise((resolve38, reject) => {
|
|
122038
122037
|
upgrade.call(this, opts, (err, data) => {
|
|
122039
|
-
return err ? reject(err) :
|
|
122038
|
+
return err ? reject(err) : resolve38(data);
|
|
122040
122039
|
});
|
|
122041
122040
|
});
|
|
122042
122041
|
}
|
|
@@ -122129,9 +122128,9 @@ var require_api_connect = __commonJS({
|
|
|
122129
122128
|
};
|
|
122130
122129
|
function connect3(opts, callback) {
|
|
122131
122130
|
if (callback === void 0) {
|
|
122132
|
-
return new Promise((
|
|
122131
|
+
return new Promise((resolve38, reject) => {
|
|
122133
122132
|
connect3.call(this, opts, (err, data) => {
|
|
122134
|
-
return err ? reject(err) :
|
|
122133
|
+
return err ? reject(err) : resolve38(data);
|
|
122135
122134
|
});
|
|
122136
122135
|
});
|
|
122137
122136
|
}
|
|
@@ -123405,7 +123404,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
123405
123404
|
"../node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
123406
123405
|
"use strict";
|
|
123407
123406
|
var { writeFile: writeFile21, readFile: readFile24, mkdir: mkdir16 } = __require("node:fs/promises");
|
|
123408
|
-
var { dirname: dirname25, resolve:
|
|
123407
|
+
var { dirname: dirname25, resolve: resolve38 } = __require("node:path");
|
|
123409
123408
|
var { setTimeout: setTimeout3, clearTimeout: clearTimeout3 } = __require("node:timers");
|
|
123410
123409
|
var { InvalidArgumentError, UndiciError } = require_errors2();
|
|
123411
123410
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -123606,7 +123605,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
123606
123605
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
123607
123606
|
}
|
|
123608
123607
|
try {
|
|
123609
|
-
const data = await readFile24(
|
|
123608
|
+
const data = await readFile24(resolve38(path5), "utf8");
|
|
123610
123609
|
const parsed = JSON.parse(data);
|
|
123611
123610
|
if (Array.isArray(parsed)) {
|
|
123612
123611
|
this.#snapshots.clear();
|
|
@@ -123635,7 +123634,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
123635
123634
|
if (!path5) {
|
|
123636
123635
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
123637
123636
|
}
|
|
123638
|
-
const resolvedPath =
|
|
123637
|
+
const resolvedPath = resolve38(path5);
|
|
123639
123638
|
await mkdir16(dirname25(resolvedPath), { recursive: true });
|
|
123640
123639
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
123641
123640
|
hash,
|
|
@@ -130477,7 +130476,7 @@ var require_fetch = __commonJS({
|
|
|
130477
130476
|
const agent = fetchParams.controller.dispatcher;
|
|
130478
130477
|
const path5 = url.pathname + url.search;
|
|
130479
130478
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
130480
|
-
return new Promise((
|
|
130479
|
+
return new Promise((resolve38, reject) => agent.dispatch(
|
|
130481
130480
|
{
|
|
130482
130481
|
path: hasTrailingQuestionMark ? `${path5}?` : path5,
|
|
130483
130482
|
origin: url.origin,
|
|
@@ -130557,7 +130556,7 @@ var require_fetch = __commonJS({
|
|
|
130557
130556
|
}
|
|
130558
130557
|
}
|
|
130559
130558
|
const onError = this.onError.bind(this);
|
|
130560
|
-
|
|
130559
|
+
resolve38({
|
|
130561
130560
|
status,
|
|
130562
130561
|
statusText,
|
|
130563
130562
|
headersList,
|
|
@@ -130610,7 +130609,7 @@ var require_fetch = __commonJS({
|
|
|
130610
130609
|
headersList.append(headerName, String(value2), true);
|
|
130611
130610
|
}
|
|
130612
130611
|
}
|
|
130613
|
-
|
|
130612
|
+
resolve38({
|
|
130614
130613
|
status,
|
|
130615
130614
|
statusText: STATUS_CODES2[status],
|
|
130616
130615
|
headersList,
|
|
@@ -130626,7 +130625,7 @@ var require_fetch = __commonJS({
|
|
|
130626
130625
|
for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
|
|
130627
130626
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
|
|
130628
130627
|
}
|
|
130629
|
-
|
|
130628
|
+
resolve38({
|
|
130630
130629
|
status,
|
|
130631
130630
|
statusText: STATUS_CODES2[status],
|
|
130632
130631
|
headersList,
|
|
@@ -135228,7 +135227,7 @@ function toBytes(data) {
|
|
|
135228
135227
|
throw new InvalidParametersError("Unsupported data type");
|
|
135229
135228
|
}
|
|
135230
135229
|
async function readResponse2(stream, options2) {
|
|
135231
|
-
return new Promise((
|
|
135230
|
+
return new Promise((resolve38, reject) => {
|
|
135232
135231
|
let readHeaders2 = false;
|
|
135233
135232
|
const parser2 = new HTTPParser("RESPONSE");
|
|
135234
135233
|
parser2[HTTPParser.kOnHeadersComplete] = (info) => {
|
|
@@ -135237,7 +135236,7 @@ async function readResponse2(stream, options2) {
|
|
|
135237
135236
|
for (let i2 = 0; i2 < info.headers.length; i2 += 2) {
|
|
135238
135237
|
headers.push([info.headers[i2], info.headers[i2 + 1]]);
|
|
135239
135238
|
}
|
|
135240
|
-
|
|
135239
|
+
resolve38(new Response2(null, {
|
|
135241
135240
|
status: info.statusCode,
|
|
135242
135241
|
statusText: info.statusMessage,
|
|
135243
135242
|
headers: new Headers(headers)
|
|
@@ -209465,11 +209464,11 @@ var init_mdns = __esm({
|
|
|
209465
209464
|
clearInterval(this._queryInterval);
|
|
209466
209465
|
this._queryInterval = null;
|
|
209467
209466
|
}
|
|
209468
|
-
await new Promise((
|
|
209467
|
+
await new Promise((resolve38) => {
|
|
209469
209468
|
if (this.mdns != null) {
|
|
209470
|
-
this.mdns.destroy(
|
|
209469
|
+
this.mdns.destroy(resolve38);
|
|
209471
209470
|
} else {
|
|
209472
|
-
|
|
209471
|
+
resolve38();
|
|
209473
209472
|
}
|
|
209474
209473
|
});
|
|
209475
209474
|
this.mdns = void 0;
|
|
@@ -210399,9 +210398,9 @@ var init_listener2 = __esm({
|
|
|
210399
210398
|
return;
|
|
210400
210399
|
}
|
|
210401
210400
|
const netConfig = this.status.netConfig;
|
|
210402
|
-
await new Promise((
|
|
210401
|
+
await new Promise((resolve38, reject) => {
|
|
210403
210402
|
this.server.once("error", reject);
|
|
210404
|
-
this.server.listen(netConfig,
|
|
210403
|
+
this.server.listen(netConfig, resolve38);
|
|
210405
210404
|
});
|
|
210406
210405
|
this.status = { ...this.status, code: TCPListenerStatusCode.ACTIVE };
|
|
210407
210406
|
this.log("listening on %s", this.server.address());
|
|
@@ -210494,7 +210493,7 @@ var init_tcp = __esm({
|
|
|
210494
210493
|
options2.signal.throwIfAborted();
|
|
210495
210494
|
options2.onProgress?.(new CustomProgressEvent("tcp:open-connection"));
|
|
210496
210495
|
let rawSocket;
|
|
210497
|
-
return new Promise((
|
|
210496
|
+
return new Promise((resolve38, reject) => {
|
|
210498
210497
|
const start2 = Date.now();
|
|
210499
210498
|
const cOpts = multiaddrToNetConfig(ma, {
|
|
210500
210499
|
...this.opts.dialOpts ?? {},
|
|
@@ -210536,7 +210535,7 @@ var init_tcp = __esm({
|
|
|
210536
210535
|
reject(err);
|
|
210537
210536
|
return;
|
|
210538
210537
|
}
|
|
210539
|
-
|
|
210538
|
+
resolve38(rawSocket);
|
|
210540
210539
|
};
|
|
210541
210540
|
rawSocket.on("error", onError);
|
|
210542
210541
|
rawSocket.on("timeout", onTimeout);
|
|
@@ -214924,14 +214923,14 @@ ${key.data.toString("base64")}
|
|
|
214924
214923
|
};
|
|
214925
214924
|
var Pbkdf2Provider = class extends core__namespace.Pbkdf2Provider {
|
|
214926
214925
|
async onDeriveBits(algorithm, baseKey, length4) {
|
|
214927
|
-
return new Promise((
|
|
214926
|
+
return new Promise((resolve38, reject) => {
|
|
214928
214927
|
const salt = core__namespace.BufferSourceConverter.toArrayBuffer(algorithm.salt);
|
|
214929
214928
|
const hash = algorithm.hash.name.replace("-", "");
|
|
214930
214929
|
crypto14.pbkdf2(getCryptoKey(baseKey).data, buffer2.Buffer.from(salt), algorithm.iterations, length4 >> 3, hash, (err, derivedBits) => {
|
|
214931
214930
|
if (err) {
|
|
214932
214931
|
reject(err);
|
|
214933
214932
|
} else {
|
|
214934
|
-
|
|
214933
|
+
resolve38(new Uint8Array(derivedBits).buffer);
|
|
214935
214934
|
}
|
|
214936
214935
|
});
|
|
214937
214936
|
});
|
|
@@ -215621,7 +215620,7 @@ var init_tls = __esm({
|
|
|
215621
215620
|
socket.emit("error", new HandshakeTimeoutError());
|
|
215622
215621
|
};
|
|
215623
215622
|
options2?.signal?.addEventListener("abort", onAbort);
|
|
215624
|
-
return new Promise((
|
|
215623
|
+
return new Promise((resolve38, reject) => {
|
|
215625
215624
|
const verifyRemote = () => {
|
|
215626
215625
|
const remote = socket.getPeerCertificate();
|
|
215627
215626
|
verifyPeerCertificate(remote.raw, options2?.remotePeer, log22).then((remotePeer) => {
|
|
@@ -215636,7 +215635,7 @@ var init_tls = __esm({
|
|
|
215636
215635
|
reject(err);
|
|
215637
215636
|
}
|
|
215638
215637
|
}
|
|
215639
|
-
|
|
215638
|
+
resolve38({
|
|
215640
215639
|
remotePeer,
|
|
215641
215640
|
connection: toMessageStream2(connection, socket),
|
|
215642
215641
|
streamMuxer
|
|
@@ -221879,12 +221878,12 @@ var require_parser2 = __commonJS({
|
|
|
221879
221878
|
};
|
|
221880
221879
|
Parser2.prototype.parseStringPromise = function(str) {
|
|
221881
221880
|
return new Promise(/* @__PURE__ */ (function(_this) {
|
|
221882
|
-
return function(
|
|
221881
|
+
return function(resolve38, reject) {
|
|
221883
221882
|
return _this.parseString(str, function(err, value2) {
|
|
221884
221883
|
if (err) {
|
|
221885
221884
|
return reject(err);
|
|
221886
221885
|
} else {
|
|
221887
|
-
return
|
|
221886
|
+
return resolve38(value2);
|
|
221888
221887
|
}
|
|
221889
221888
|
});
|
|
221890
221889
|
};
|
|
@@ -222210,7 +222209,7 @@ function initRequest(url, init2) {
|
|
|
222210
222209
|
}
|
|
222211
222210
|
}
|
|
222212
222211
|
async function fetch3(url, init2 = {}) {
|
|
222213
|
-
return new Promise((
|
|
222212
|
+
return new Promise((resolve38, reject) => {
|
|
222214
222213
|
const request = initRequest(new URL(url), init2);
|
|
222215
222214
|
if (init2.body != null) {
|
|
222216
222215
|
request.write(init2.body);
|
|
@@ -222229,7 +222228,7 @@ async function fetch3(url, init2 = {}) {
|
|
|
222229
222228
|
body += chunk.toString();
|
|
222230
222229
|
});
|
|
222231
222230
|
response.on("end", () => {
|
|
222232
|
-
|
|
222231
|
+
resolve38(body);
|
|
222233
222232
|
});
|
|
222234
222233
|
response.on("error", (err) => {
|
|
222235
222234
|
reject(err);
|
|
@@ -222377,7 +222376,7 @@ var init_broadcast_advert = __esm({
|
|
|
222377
222376
|
// ../node_modules/freeport-promise/dist/src/index.js
|
|
222378
222377
|
import { createServer } from "net";
|
|
222379
222378
|
async function freeport() {
|
|
222380
|
-
return await new Promise((
|
|
222379
|
+
return await new Promise((resolve38, reject) => {
|
|
222381
222380
|
const server = createServer();
|
|
222382
222381
|
let port = 0;
|
|
222383
222382
|
server.once("listening", () => {
|
|
@@ -222392,7 +222391,7 @@ async function freeport() {
|
|
|
222392
222391
|
server.close();
|
|
222393
222392
|
});
|
|
222394
222393
|
server.once("close", () => {
|
|
222395
|
-
|
|
222394
|
+
resolve38(port);
|
|
222396
222395
|
});
|
|
222397
222396
|
server.once("error", reject);
|
|
222398
222397
|
server.listen(0, "127.0.0.1");
|
|
@@ -222456,7 +222455,7 @@ async function createLocation(ssdp, advert) {
|
|
|
222456
222455
|
advert.location = {};
|
|
222457
222456
|
await Promise.all(ssdp.sockets.map(async (socket) => Promise.all(findAllInterfaces(socket.type === "udp4" && advert.ipv4, socket.type === "udp6" && advert.ipv6).map(async (iface) => {
|
|
222458
222457
|
await freeport().then(async (port) => {
|
|
222459
|
-
await new Promise((
|
|
222458
|
+
await new Promise((resolve38, reject) => {
|
|
222460
222459
|
let location = "http://";
|
|
222461
222460
|
if (socket.type === "udp6") {
|
|
222462
222461
|
location += `[${iface.address}]`;
|
|
@@ -222470,7 +222469,7 @@ async function createLocation(ssdp, advert) {
|
|
|
222470
222469
|
});
|
|
222471
222470
|
const addr = socket.address();
|
|
222472
222471
|
server.listen(port, addr.address, () => {
|
|
222473
|
-
|
|
222472
|
+
resolve38();
|
|
222474
222473
|
});
|
|
222475
222474
|
server.on("error", (err) => {
|
|
222476
222475
|
reject(err);
|
|
@@ -222480,9 +222479,9 @@ async function createLocation(ssdp, advert) {
|
|
|
222480
222479
|
});
|
|
222481
222480
|
}))));
|
|
222482
222481
|
return async () => {
|
|
222483
|
-
await Promise.all(servers.map(async (server) => new Promise((
|
|
222482
|
+
await Promise.all(servers.map(async (server) => new Promise((resolve38, reject) => {
|
|
222484
222483
|
server.close();
|
|
222485
|
-
|
|
222484
|
+
resolve38();
|
|
222486
222485
|
})));
|
|
222487
222486
|
};
|
|
222488
222487
|
}
|
|
@@ -222675,10 +222674,10 @@ function parseAdvertOptions(ssdp, options2) {
|
|
|
222675
222674
|
}, options2);
|
|
222676
222675
|
const details = opts.details;
|
|
222677
222676
|
opts.details = async () => {
|
|
222678
|
-
return new Promise((
|
|
222677
|
+
return new Promise((resolve38, reject) => {
|
|
222679
222678
|
try {
|
|
222680
222679
|
const builder = new import_xml2js3.default.Builder();
|
|
222681
|
-
|
|
222680
|
+
resolve38(builder.buildObject(details));
|
|
222682
222681
|
} catch (error) {
|
|
222683
222682
|
reject(error);
|
|
222684
222683
|
}
|
|
@@ -222757,7 +222756,7 @@ import { createSocket } from "node:dgram";
|
|
|
222757
222756
|
async function createSockets(ssdp, signal) {
|
|
222758
222757
|
const sockets = [];
|
|
222759
222758
|
await Promise.allSettled((ssdp.options.sockets ?? []).map(async (options2) => {
|
|
222760
|
-
return new Promise((
|
|
222759
|
+
return new Promise((resolve38, reject) => {
|
|
222761
222760
|
const socket = createSocket({
|
|
222762
222761
|
type: options2.type ?? "udp4",
|
|
222763
222762
|
ipv6Only: options2.type === "udp6",
|
|
@@ -222781,7 +222780,7 @@ async function createSockets(ssdp, signal) {
|
|
|
222781
222780
|
socket.setMulticastTTL(options2.maxHops);
|
|
222782
222781
|
}
|
|
222783
222782
|
sockets.push(socket);
|
|
222784
|
-
|
|
222783
|
+
resolve38();
|
|
222785
222784
|
} catch (error) {
|
|
222786
222785
|
error.message = `Adding membership ${options2.broadcast?.address} failed - ${error.message}`;
|
|
222787
222786
|
reject(error);
|
|
@@ -222946,14 +222945,14 @@ var init_utils37 = __esm({
|
|
|
222946
222945
|
// ../node_modules/@achingbrain/ssdp/dist/src/send-ssdp-message.js
|
|
222947
222946
|
function sendSsdpMessage(ssdp, status, headers, remote) {
|
|
222948
222947
|
Promise.all(ssdp.sockets.map(async (socket) => {
|
|
222949
|
-
await new Promise((
|
|
222948
|
+
await new Promise((resolve38, reject) => {
|
|
222950
222949
|
if (socket.closed) {
|
|
222951
|
-
|
|
222950
|
+
resolve38();
|
|
222952
222951
|
return;
|
|
222953
222952
|
}
|
|
222954
222953
|
const recipient = remote ?? socket.options.broadcast;
|
|
222955
222954
|
if (recipient != null && addressFamilyMismatch(recipient, socket)) {
|
|
222956
|
-
|
|
222955
|
+
resolve38();
|
|
222957
222956
|
return;
|
|
222958
222957
|
}
|
|
222959
222958
|
if (headers.LOCATION != null) {
|
|
@@ -222978,7 +222977,7 @@ function sendSsdpMessage(ssdp, status, headers, remote) {
|
|
|
222978
222977
|
reject(error);
|
|
222979
222978
|
return;
|
|
222980
222979
|
}
|
|
222981
|
-
|
|
222980
|
+
resolve38();
|
|
222982
222981
|
});
|
|
222983
222982
|
});
|
|
222984
222983
|
})).catch((err) => {
|
|
@@ -223035,9 +223034,9 @@ var init_ssdp = __esm({
|
|
|
223035
223034
|
async stop() {
|
|
223036
223035
|
await adverts.stopAll();
|
|
223037
223036
|
await Promise.all(this.sockets.map(async (socket) => {
|
|
223038
|
-
await new Promise((
|
|
223037
|
+
await new Promise((resolve38) => {
|
|
223039
223038
|
socket.on("close", () => {
|
|
223040
|
-
|
|
223039
|
+
resolve38();
|
|
223041
223040
|
});
|
|
223042
223041
|
socket.close();
|
|
223043
223042
|
socket.closed = true;
|
|
@@ -225628,12 +225627,12 @@ var init_RTCSctpTransport = __esm({
|
|
|
225628
225627
|
|
|
225629
225628
|
// ../node_modules/node-datachannel/dist/esm/polyfill/RTCPeerConnection.mjs
|
|
225630
225629
|
function createDeferredPromise() {
|
|
225631
|
-
let
|
|
225630
|
+
let resolve38, reject;
|
|
225632
225631
|
const promise = new Promise(function(_resolve, _reject) {
|
|
225633
|
-
|
|
225632
|
+
resolve38 = _resolve;
|
|
225634
225633
|
reject = _reject;
|
|
225635
225634
|
});
|
|
225636
|
-
promise.resolve =
|
|
225635
|
+
promise.resolve = resolve38;
|
|
225637
225636
|
promise.reject = reject;
|
|
225638
225637
|
return promise;
|
|
225639
225638
|
}
|
|
@@ -225950,14 +225949,14 @@ var init_RTCPeerConnection = __esm({
|
|
|
225950
225949
|
throw new DOMException("Not implemented");
|
|
225951
225950
|
}
|
|
225952
225951
|
getStats() {
|
|
225953
|
-
return new Promise((
|
|
225952
|
+
return new Promise((resolve38) => {
|
|
225954
225953
|
const report = /* @__PURE__ */ new Map();
|
|
225955
225954
|
const cp2 = __privateGet9(this, _peerConnection)?.getSelectedCandidatePair();
|
|
225956
225955
|
const bytesSent = __privateGet9(this, _peerConnection)?.bytesSent();
|
|
225957
225956
|
const bytesReceived = __privateGet9(this, _peerConnection)?.bytesReceived();
|
|
225958
225957
|
const rtt = __privateGet9(this, _peerConnection)?.rtt();
|
|
225959
225958
|
if (!cp2) {
|
|
225960
|
-
return
|
|
225959
|
+
return resolve38(report);
|
|
225961
225960
|
}
|
|
225962
225961
|
const localIdRs = getRandomString(8);
|
|
225963
225962
|
const localId = "RTCIceCandidate_" + localIdRs;
|
|
@@ -226012,7 +226011,7 @@ var init_RTCPeerConnection = __esm({
|
|
|
226012
226011
|
dataChannelsOpened: __privateGet9(this, _dataChannels).size,
|
|
226013
226012
|
dataChannelsClosed: __privateGet9(this, _dataChannelsClosed)
|
|
226014
226013
|
});
|
|
226015
|
-
return
|
|
226014
|
+
return resolve38(report);
|
|
226016
226015
|
});
|
|
226017
226016
|
}
|
|
226018
226017
|
getTransceivers() {
|
|
@@ -226843,14 +226842,14 @@ var init_get_port = __esm({
|
|
|
226843
226842
|
}
|
|
226844
226843
|
return results;
|
|
226845
226844
|
};
|
|
226846
|
-
checkAvailablePort = (options2) => new Promise((
|
|
226845
|
+
checkAvailablePort = (options2) => new Promise((resolve38, reject) => {
|
|
226847
226846
|
const server = net3.createServer();
|
|
226848
226847
|
server.unref();
|
|
226849
226848
|
server.on("error", reject);
|
|
226850
226849
|
server.listen(options2, () => {
|
|
226851
226850
|
const { port } = server.address();
|
|
226852
226851
|
server.close(() => {
|
|
226853
|
-
|
|
226852
|
+
resolve38(port);
|
|
226854
226853
|
});
|
|
226855
226854
|
});
|
|
226856
226855
|
});
|
|
@@ -226923,12 +226922,12 @@ var resolveValue, sleep, validateOptions, createTimeoutError, handleFallback, ha
|
|
|
226923
226922
|
var init_p_wait_for = __esm({
|
|
226924
226923
|
"../node_modules/p-wait-for/index.js"() {
|
|
226925
226924
|
resolveValue = /* @__PURE__ */ Symbol("resolveValue");
|
|
226926
|
-
sleep = (ms, signal) => new Promise((
|
|
226925
|
+
sleep = (ms, signal) => new Promise((resolve38, reject) => {
|
|
226927
226926
|
if (signal?.aborted) {
|
|
226928
226927
|
reject(signal.reason);
|
|
226929
226928
|
return;
|
|
226930
226929
|
}
|
|
226931
|
-
const timeout2 = setTimeout(
|
|
226930
|
+
const timeout2 = setTimeout(resolve38, ms);
|
|
226932
226931
|
if (signal) {
|
|
226933
226932
|
signal.addEventListener("abort", () => {
|
|
226934
226933
|
clearTimeout(timeout2);
|
|
@@ -231902,10 +231901,10 @@ var init_listener5 = __esm({
|
|
|
231902
231901
|
...config,
|
|
231903
231902
|
ipv6Only: config.type === "ip6"
|
|
231904
231903
|
});
|
|
231905
|
-
await new Promise((
|
|
231904
|
+
await new Promise((resolve38, reject) => {
|
|
231906
231905
|
const onListening = () => {
|
|
231907
231906
|
removeListeners();
|
|
231908
|
-
|
|
231907
|
+
resolve38();
|
|
231909
231908
|
};
|
|
231910
231909
|
const onError = (err) => {
|
|
231911
231910
|
this.metrics.errors?.increment({ [`${this.addr} listen_error`]: true });
|
|
@@ -242365,41 +242364,41 @@ var require_queue = __commonJS({
|
|
|
242365
242364
|
queue.drained = drained;
|
|
242366
242365
|
return queue;
|
|
242367
242366
|
function push(value2) {
|
|
242368
|
-
var p2 = new Promise(function(
|
|
242367
|
+
var p2 = new Promise(function(resolve38, reject) {
|
|
242369
242368
|
pushCb(value2, function(err, result) {
|
|
242370
242369
|
if (err) {
|
|
242371
242370
|
reject(err);
|
|
242372
242371
|
return;
|
|
242373
242372
|
}
|
|
242374
|
-
|
|
242373
|
+
resolve38(result);
|
|
242375
242374
|
});
|
|
242376
242375
|
});
|
|
242377
242376
|
p2.catch(noop2);
|
|
242378
242377
|
return p2;
|
|
242379
242378
|
}
|
|
242380
242379
|
function unshift(value2) {
|
|
242381
|
-
var p2 = new Promise(function(
|
|
242380
|
+
var p2 = new Promise(function(resolve38, reject) {
|
|
242382
242381
|
unshiftCb(value2, function(err, result) {
|
|
242383
242382
|
if (err) {
|
|
242384
242383
|
reject(err);
|
|
242385
242384
|
return;
|
|
242386
242385
|
}
|
|
242387
|
-
|
|
242386
|
+
resolve38(result);
|
|
242388
242387
|
});
|
|
242389
242388
|
});
|
|
242390
242389
|
p2.catch(noop2);
|
|
242391
242390
|
return p2;
|
|
242392
242391
|
}
|
|
242393
242392
|
function drained() {
|
|
242394
|
-
var p2 = new Promise(function(
|
|
242393
|
+
var p2 = new Promise(function(resolve38) {
|
|
242395
242394
|
process.nextTick(function() {
|
|
242396
242395
|
if (queue.idle()) {
|
|
242397
|
-
|
|
242396
|
+
resolve38();
|
|
242398
242397
|
} else {
|
|
242399
242398
|
var previousDrain = queue.drain;
|
|
242400
242399
|
queue.drain = function() {
|
|
242401
242400
|
if (typeof previousDrain === "function") previousDrain();
|
|
242402
|
-
|
|
242401
|
+
resolve38();
|
|
242403
242402
|
queue.drain = previousDrain;
|
|
242404
242403
|
};
|
|
242405
242404
|
}
|
|
@@ -242885,9 +242884,9 @@ var require_stream4 = __commonJS({
|
|
|
242885
242884
|
});
|
|
242886
242885
|
}
|
|
242887
242886
|
_getStat(filepath) {
|
|
242888
|
-
return new Promise((
|
|
242887
|
+
return new Promise((resolve38, reject) => {
|
|
242889
242888
|
this._stat(filepath, this._fsStatSettings, (error, stats) => {
|
|
242890
|
-
return error === null ?
|
|
242889
|
+
return error === null ? resolve38(stats) : reject(error);
|
|
242891
242890
|
});
|
|
242892
242891
|
});
|
|
242893
242892
|
}
|
|
@@ -242911,10 +242910,10 @@ var require_async6 = __commonJS({
|
|
|
242911
242910
|
this._readerStream = new stream_1.default(this._settings);
|
|
242912
242911
|
}
|
|
242913
242912
|
dynamic(root, options2) {
|
|
242914
|
-
return new Promise((
|
|
242913
|
+
return new Promise((resolve38, reject) => {
|
|
242915
242914
|
this._walkAsync(root, options2, (error, entries) => {
|
|
242916
242915
|
if (error === null) {
|
|
242917
|
-
|
|
242916
|
+
resolve38(entries);
|
|
242918
242917
|
} else {
|
|
242919
242918
|
reject(error);
|
|
242920
242919
|
}
|
|
@@ -242924,10 +242923,10 @@ var require_async6 = __commonJS({
|
|
|
242924
242923
|
async static(patterns, options2) {
|
|
242925
242924
|
const entries = [];
|
|
242926
242925
|
const stream = this._readerStream.static(patterns, options2);
|
|
242927
|
-
return new Promise((
|
|
242926
|
+
return new Promise((resolve38, reject) => {
|
|
242928
242927
|
stream.once("error", reject);
|
|
242929
242928
|
stream.on("data", (entry) => entries.push(entry));
|
|
242930
|
-
stream.once("end", () =>
|
|
242929
|
+
stream.once("end", () => resolve38(entries));
|
|
242931
242930
|
});
|
|
242932
242931
|
}
|
|
242933
242932
|
};
|
|
@@ -243769,7 +243768,7 @@ async function retryAsyncOperation(fn, maxRetries, delayMs) {
|
|
|
243769
243768
|
return await fn();
|
|
243770
243769
|
} catch (error) {
|
|
243771
243770
|
if (i2 < maxRetries - 1) {
|
|
243772
|
-
await new Promise((
|
|
243771
|
+
await new Promise((resolve38) => setTimeout(resolve38, delayMs));
|
|
243773
243772
|
} else {
|
|
243774
243773
|
throw error;
|
|
243775
243774
|
}
|
|
@@ -243790,11 +243789,11 @@ var init_lib3 = __esm({
|
|
|
243790
243789
|
// File is locked, add data for later
|
|
243791
243790
|
#add(data) {
|
|
243792
243791
|
this.#nextData = data;
|
|
243793
|
-
this.#nextPromise ||= new Promise((
|
|
243794
|
-
this.#next = [
|
|
243792
|
+
this.#nextPromise ||= new Promise((resolve38, reject) => {
|
|
243793
|
+
this.#next = [resolve38, reject];
|
|
243795
243794
|
});
|
|
243796
|
-
return new Promise((
|
|
243797
|
-
this.#nextPromise?.then(
|
|
243795
|
+
return new Promise((resolve38, reject) => {
|
|
243796
|
+
this.#nextPromise?.then(resolve38).catch(reject);
|
|
243798
243797
|
});
|
|
243799
243798
|
}
|
|
243800
243799
|
// File isn't locked, write data
|
|
@@ -244325,7 +244324,7 @@ Justification: ${justification || "(none provided)"}`,
|
|
|
244325
244324
|
})();
|
|
244326
244325
|
const ipfsResult = await Promise.race([
|
|
244327
244326
|
ipfsPromise,
|
|
244328
|
-
new Promise((
|
|
244327
|
+
new Promise((resolve38) => setTimeout(() => resolve38(null), 2e3))
|
|
244329
244328
|
]);
|
|
244330
244329
|
if (ipfsResult && ipfsResult.success) {
|
|
244331
244330
|
const cidData = JSON.parse(ipfsResult.output);
|
|
@@ -244846,7 +244845,7 @@ print("__OA_REPL_READY__")
|
|
|
244846
244845
|
return;
|
|
244847
244846
|
const sockId = randomBytes8(8).toString("hex");
|
|
244848
244847
|
this.ipcPath = join23(tmpdir3(), `oa-repl-ipc-${sockId}.sock`);
|
|
244849
|
-
return new Promise((
|
|
244848
|
+
return new Promise((resolve38, reject) => {
|
|
244850
244849
|
this.ipcServer = createServer2((conn) => {
|
|
244851
244850
|
let buffer2 = new Uint8Array(0);
|
|
244852
244851
|
conn.on("data", (chunk) => {
|
|
@@ -244862,7 +244861,7 @@ print("__OA_REPL_READY__")
|
|
|
244862
244861
|
});
|
|
244863
244862
|
});
|
|
244864
244863
|
this.ipcServer.on("error", reject);
|
|
244865
|
-
this.ipcServer.listen(this.ipcPath, () =>
|
|
244864
|
+
this.ipcServer.listen(this.ipcPath, () => resolve38());
|
|
244866
244865
|
});
|
|
244867
244866
|
}
|
|
244868
244867
|
async processIpcBuffer(conn, input) {
|
|
@@ -244925,9 +244924,9 @@ print("__OA_REPL_READY__")
|
|
|
244925
244924
|
}
|
|
244926
244925
|
// ── Code execution ─────────────────────────────────────────────────────
|
|
244927
244926
|
executeCode(code8, isInit = false) {
|
|
244928
|
-
return new Promise((
|
|
244927
|
+
return new Promise((resolve38) => {
|
|
244929
244928
|
if (!this.proc?.stdin || !this.proc?.stdout || !this.proc?.stderr) {
|
|
244930
|
-
|
|
244929
|
+
resolve38({ success: false, output: "REPL process not available", error: "No process", durationMs: 0 });
|
|
244931
244930
|
return;
|
|
244932
244931
|
}
|
|
244933
244932
|
const sentinel = `__OA_SENTINEL_${randomBytes8(6).toString("hex")}__`;
|
|
@@ -244937,7 +244936,7 @@ print("__OA_REPL_READY__")
|
|
|
244937
244936
|
const timeout2 = setTimeout(() => {
|
|
244938
244937
|
if (!resolved) {
|
|
244939
244938
|
resolved = true;
|
|
244940
|
-
|
|
244939
|
+
resolve38({
|
|
244941
244940
|
success: false,
|
|
244942
244941
|
output: stdout || "Execution timed out",
|
|
244943
244942
|
error: `Timeout after ${this.execTimeout / 1e3}s`,
|
|
@@ -244954,13 +244953,13 @@ print("__OA_REPL_READY__")
|
|
|
244954
244953
|
if (isInit) {
|
|
244955
244954
|
const ready = cleanOutput.includes("__OA_REPL_READY__");
|
|
244956
244955
|
const displayOutput = cleanOutput.replace("__OA_REPL_READY__", "").trim();
|
|
244957
|
-
|
|
244956
|
+
resolve38({
|
|
244958
244957
|
success: ready,
|
|
244959
244958
|
output: displayOutput || "REPL initialized",
|
|
244960
244959
|
durationMs: 0
|
|
244961
244960
|
});
|
|
244962
244961
|
} else {
|
|
244963
|
-
|
|
244962
|
+
resolve38({
|
|
244964
244963
|
success: true,
|
|
244965
244964
|
output: cleanOutput || "(no output)",
|
|
244966
244965
|
durationMs: 0
|
|
@@ -244969,7 +244968,7 @@ print("__OA_REPL_READY__")
|
|
|
244969
244968
|
}
|
|
244970
244969
|
if (stdout.length > 2e5) {
|
|
244971
244970
|
cleanup();
|
|
244972
|
-
|
|
244971
|
+
resolve38({
|
|
244973
244972
|
success: true,
|
|
244974
244973
|
output: stdout.slice(0, 2e5) + "\n[output truncated at 200KB]",
|
|
244975
244974
|
durationMs: 0
|
|
@@ -245068,9 +245067,9 @@ print("${sentinel}")
|
|
|
245068
245067
|
if (!this.proc || this.proc.killed) {
|
|
245069
245068
|
return { success: false, path: "" };
|
|
245070
245069
|
}
|
|
245071
|
-
const { mkdirSync:
|
|
245070
|
+
const { mkdirSync: mkdirSync35, writeFileSync: writeFileSync33 } = await import("node:fs");
|
|
245072
245071
|
const sessionDir = join23(this.cwd, ".oa", "rlm");
|
|
245073
|
-
|
|
245072
|
+
mkdirSync35(sessionDir, { recursive: true });
|
|
245074
245073
|
const sessionPath = join23(sessionDir, "session.json");
|
|
245075
245074
|
try {
|
|
245076
245075
|
const inspectCode = `
|
|
@@ -245094,7 +245093,7 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
245094
245093
|
trajectoryCount: this.trajectory.length,
|
|
245095
245094
|
subCallCount: this.subCallCount
|
|
245096
245095
|
};
|
|
245097
|
-
|
|
245096
|
+
writeFileSync33(sessionPath, JSON.stringify(sessionData, null, 2), "utf8");
|
|
245098
245097
|
return { success: true, path: sessionPath };
|
|
245099
245098
|
}
|
|
245100
245099
|
} catch {
|
|
@@ -245106,11 +245105,11 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
245106
245105
|
* what was previously computed. */
|
|
245107
245106
|
async loadSessionInfo() {
|
|
245108
245107
|
try {
|
|
245109
|
-
const { readFileSync:
|
|
245108
|
+
const { readFileSync: readFileSync50, existsSync: existsSync62 } = await import("node:fs");
|
|
245110
245109
|
const sessionPath = join23(this.cwd, ".oa", "rlm", "session.json");
|
|
245111
|
-
if (!
|
|
245110
|
+
if (!existsSync62(sessionPath))
|
|
245112
245111
|
return null;
|
|
245113
|
-
return JSON.parse(
|
|
245112
|
+
return JSON.parse(readFileSync50(sessionPath, "utf8"));
|
|
245114
245113
|
} catch {
|
|
245115
245114
|
return null;
|
|
245116
245115
|
}
|
|
@@ -245287,10 +245286,10 @@ var init_memory_metabolism = __esm({
|
|
|
245287
245286
|
const trajDir = join24(this.cwd, ".oa", "rlm-trajectories");
|
|
245288
245287
|
let lessons = [];
|
|
245289
245288
|
try {
|
|
245290
|
-
const { readdirSync: readdirSync25, readFileSync:
|
|
245289
|
+
const { readdirSync: readdirSync25, readFileSync: readFileSync50 } = await import("node:fs");
|
|
245291
245290
|
const files = readdirSync25(trajDir).filter((f2) => f2.endsWith(".jsonl")).sort().reverse().slice(0, 3);
|
|
245292
245291
|
for (const file of files) {
|
|
245293
|
-
const lines =
|
|
245292
|
+
const lines = readFileSync50(join24(trajDir, file), "utf8").split("\n").filter((l2) => l2.trim());
|
|
245294
245293
|
for (const line of lines) {
|
|
245295
245294
|
try {
|
|
245296
245295
|
const entry = JSON.parse(line);
|
|
@@ -245674,14 +245673,14 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
245674
245673
|
* Optionally filter by task type for phase-aware context (FSM paper insight).
|
|
245675
245674
|
*/
|
|
245676
245675
|
getTopMemoriesSync(k = 5, taskType) {
|
|
245677
|
-
const { readFileSync:
|
|
245676
|
+
const { readFileSync: readFileSync50, existsSync: existsSync62 } = __require("node:fs");
|
|
245678
245677
|
const metaDir = join24(this.cwd, ".oa", "memory", "metabolism");
|
|
245679
245678
|
const storeFile = join24(metaDir, "store.json");
|
|
245680
|
-
if (!
|
|
245679
|
+
if (!existsSync62(storeFile))
|
|
245681
245680
|
return "";
|
|
245682
245681
|
let store2 = [];
|
|
245683
245682
|
try {
|
|
245684
|
-
store2 = JSON.parse(
|
|
245683
|
+
store2 = JSON.parse(readFileSync50(storeFile, "utf8"));
|
|
245685
245684
|
} catch {
|
|
245686
245685
|
return "";
|
|
245687
245686
|
}
|
|
@@ -245703,14 +245702,14 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
245703
245702
|
/** Update memory scores based on task outcome. Called after task completion.
|
|
245704
245703
|
* Memories used in successful tasks get boosted. Memories present during failures get decayed. */
|
|
245705
245704
|
updateFromOutcomeSync(surfacedMemoryText, succeeded) {
|
|
245706
|
-
const { readFileSync:
|
|
245705
|
+
const { readFileSync: readFileSync50, writeFileSync: writeFileSync33, existsSync: existsSync62, mkdirSync: mkdirSync35 } = __require("node:fs");
|
|
245707
245706
|
const metaDir = join24(this.cwd, ".oa", "memory", "metabolism");
|
|
245708
245707
|
const storeFile = join24(metaDir, "store.json");
|
|
245709
|
-
if (!
|
|
245708
|
+
if (!existsSync62(storeFile))
|
|
245710
245709
|
return;
|
|
245711
245710
|
let store2 = [];
|
|
245712
245711
|
try {
|
|
245713
|
-
store2 = JSON.parse(
|
|
245712
|
+
store2 = JSON.parse(readFileSync50(storeFile, "utf8"));
|
|
245714
245713
|
} catch {
|
|
245715
245714
|
return;
|
|
245716
245715
|
}
|
|
@@ -245734,8 +245733,8 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
245734
245733
|
updated = true;
|
|
245735
245734
|
}
|
|
245736
245735
|
if (updated) {
|
|
245737
|
-
|
|
245738
|
-
|
|
245736
|
+
mkdirSync35(metaDir, { recursive: true });
|
|
245737
|
+
writeFileSync33(storeFile, JSON.stringify(store2, null, 2));
|
|
245739
245738
|
}
|
|
245740
245739
|
}
|
|
245741
245740
|
// ── Storage ──────────────────────────────────────────────────────────
|
|
@@ -246157,13 +246156,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
246157
246156
|
// Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
|
|
246158
246157
|
/** Retrieve top-K strategies for context injection. Returns "" if none. */
|
|
246159
246158
|
getRelevantStrategiesSync(k = 3, taskType) {
|
|
246160
|
-
const { readFileSync:
|
|
246159
|
+
const { readFileSync: readFileSync50, existsSync: existsSync62 } = __require("node:fs");
|
|
246161
246160
|
const archiveFile = join26(this.cwd, ".oa", "arche", "variants.json");
|
|
246162
|
-
if (!
|
|
246161
|
+
if (!existsSync62(archiveFile))
|
|
246163
246162
|
return "";
|
|
246164
246163
|
let variants = [];
|
|
246165
246164
|
try {
|
|
246166
|
-
variants = JSON.parse(
|
|
246165
|
+
variants = JSON.parse(readFileSync50(archiveFile, "utf8"));
|
|
246167
246166
|
} catch {
|
|
246168
246167
|
return "";
|
|
246169
246168
|
}
|
|
@@ -246181,13 +246180,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
246181
246180
|
}
|
|
246182
246181
|
/** Archive a strategy variant synchronously (for task completion path) */
|
|
246183
246182
|
archiveVariantSync(strategy, outcome, tags = []) {
|
|
246184
|
-
const { readFileSync:
|
|
246183
|
+
const { readFileSync: readFileSync50, writeFileSync: writeFileSync33, existsSync: existsSync62, mkdirSync: mkdirSync35 } = __require("node:fs");
|
|
246185
246184
|
const dir = join26(this.cwd, ".oa", "arche");
|
|
246186
246185
|
const archiveFile = join26(dir, "variants.json");
|
|
246187
246186
|
let variants = [];
|
|
246188
246187
|
try {
|
|
246189
|
-
if (
|
|
246190
|
-
variants = JSON.parse(
|
|
246188
|
+
if (existsSync62(archiveFile))
|
|
246189
|
+
variants = JSON.parse(readFileSync50(archiveFile, "utf8"));
|
|
246191
246190
|
} catch {
|
|
246192
246191
|
}
|
|
246193
246192
|
variants.push({
|
|
@@ -246202,8 +246201,8 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
246202
246201
|
});
|
|
246203
246202
|
if (variants.length > 50)
|
|
246204
246203
|
variants = variants.slice(-50);
|
|
246205
|
-
|
|
246206
|
-
|
|
246204
|
+
mkdirSync35(dir, { recursive: true });
|
|
246205
|
+
writeFileSync33(archiveFile, JSON.stringify(variants, null, 2));
|
|
246207
246206
|
}
|
|
246208
246207
|
async saveArchive(variants) {
|
|
246209
246208
|
const dir = join26(this.cwd, ".oa", "arche");
|
|
@@ -247167,9 +247166,9 @@ var init_vision = __esm({
|
|
|
247167
247166
|
if (ollamaResult)
|
|
247168
247167
|
return ollamaResult;
|
|
247169
247168
|
try {
|
|
247170
|
-
const { execSync:
|
|
247169
|
+
const { execSync: execSync37 } = await import("node:child_process");
|
|
247171
247170
|
try {
|
|
247172
|
-
|
|
247171
|
+
execSync37("pip3 install --user moondream 2>/dev/null || pip install --user moondream 2>/dev/null", {
|
|
247173
247172
|
timeout: 12e4,
|
|
247174
247173
|
stdio: "pipe"
|
|
247175
247174
|
});
|
|
@@ -247182,7 +247181,7 @@ var init_vision = __esm({
|
|
|
247182
247181
|
} catch {
|
|
247183
247182
|
}
|
|
247184
247183
|
try {
|
|
247185
|
-
|
|
247184
|
+
execSync37("ollama pull moondream", { timeout: 3e5, stdio: "pipe" });
|
|
247186
247185
|
const retryOllama = await this.tryOllamaVision(buffer2, filename, action, prompt, length4, start2);
|
|
247187
247186
|
if (retryOllama)
|
|
247188
247187
|
return retryOllama;
|
|
@@ -247290,8 +247289,8 @@ Coordinates are normalized (0-1). Multiply by image width/height for pixel value
|
|
|
247290
247289
|
const errText = await res.text().catch(() => "");
|
|
247291
247290
|
if (res.status === 404 || /not found|does not exist/i.test(errText)) {
|
|
247292
247291
|
try {
|
|
247293
|
-
const { execSync:
|
|
247294
|
-
|
|
247292
|
+
const { execSync: execSync37 } = await import("node:child_process");
|
|
247293
|
+
execSync37("ollama pull moondream", { timeout: 3e5, stdio: "pipe" });
|
|
247295
247294
|
res = await fetch(`${ollamaHost}/api/generate`, {
|
|
247296
247295
|
method: "POST",
|
|
247297
247296
|
headers: { "Content-Type": "application/json" },
|
|
@@ -253449,7 +253448,7 @@ import { spawn as spawn14 } from "node:child_process";
|
|
|
253449
253448
|
async function runShell(options2) {
|
|
253450
253449
|
const { command, args = [], cwd: cwd4, env: env2, timeoutMs = DEFAULT_TIMEOUT_MS } = options2;
|
|
253451
253450
|
const mergedEnv = env2 ? { ...process.env, ...env2 } : process.env;
|
|
253452
|
-
return new Promise((
|
|
253451
|
+
return new Promise((resolve38) => {
|
|
253453
253452
|
const start2 = Date.now();
|
|
253454
253453
|
let timedOut = false;
|
|
253455
253454
|
const child = spawn14(command, args, {
|
|
@@ -253473,7 +253472,7 @@ async function runShell(options2) {
|
|
|
253473
253472
|
clearTimeout(timer);
|
|
253474
253473
|
const durationMs = Date.now() - start2;
|
|
253475
253474
|
const exitCode = timedOut ? -1 : code8 ?? -1;
|
|
253476
|
-
|
|
253475
|
+
resolve38({
|
|
253477
253476
|
stdout,
|
|
253478
253477
|
stderr,
|
|
253479
253478
|
exitCode,
|
|
@@ -253485,7 +253484,7 @@ async function runShell(options2) {
|
|
|
253485
253484
|
child.on("error", (err) => {
|
|
253486
253485
|
clearTimeout(timer);
|
|
253487
253486
|
const durationMs = Date.now() - start2;
|
|
253488
|
-
|
|
253487
|
+
resolve38({
|
|
253489
253488
|
stdout,
|
|
253490
253489
|
stderr: stderr + err.message,
|
|
253491
253490
|
exitCode: -1,
|
|
@@ -253600,7 +253599,7 @@ async function applyUnifiedDiff(patch) {
|
|
|
253600
253599
|
}
|
|
253601
253600
|
function runWithStdin(options2) {
|
|
253602
253601
|
const { command, args, cwd: cwd4, stdin } = options2;
|
|
253603
|
-
return new Promise((
|
|
253602
|
+
return new Promise((resolve38) => {
|
|
253604
253603
|
const child = spawn15(command, args, {
|
|
253605
253604
|
cwd: cwd4,
|
|
253606
253605
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -253617,10 +253616,10 @@ function runWithStdin(options2) {
|
|
|
253617
253616
|
child.stdin.end();
|
|
253618
253617
|
child.on("close", (code8) => {
|
|
253619
253618
|
const exitCode = code8 ?? -1;
|
|
253620
|
-
|
|
253619
|
+
resolve38({ success: exitCode === 0, exitCode, stdout, stderr });
|
|
253621
253620
|
});
|
|
253622
253621
|
child.on("error", (err) => {
|
|
253623
|
-
|
|
253622
|
+
resolve38({ success: false, exitCode: -1, stdout, stderr: err.message });
|
|
253624
253623
|
});
|
|
253625
253624
|
});
|
|
253626
253625
|
}
|
|
@@ -257496,8 +257495,8 @@ ${this.options.dynamicContext}`,
|
|
|
257496
257495
|
async waitIfPaused() {
|
|
257497
257496
|
if (!this._paused)
|
|
257498
257497
|
return true;
|
|
257499
|
-
await new Promise((
|
|
257500
|
-
this._pauseResolve =
|
|
257498
|
+
await new Promise((resolve38) => {
|
|
257499
|
+
this._pauseResolve = resolve38;
|
|
257501
257500
|
});
|
|
257502
257501
|
return !this.aborted;
|
|
257503
257502
|
}
|
|
@@ -258776,14 +258775,14 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
258776
258775
|
waitForSudoPassword(timeoutMs = 12e4) {
|
|
258777
258776
|
if (this._sudoPassword)
|
|
258778
258777
|
return Promise.resolve(this._sudoPassword);
|
|
258779
|
-
return new Promise((
|
|
258778
|
+
return new Promise((resolve38) => {
|
|
258780
258779
|
const timer = setTimeout(() => {
|
|
258781
258780
|
this._sudoResolve = null;
|
|
258782
|
-
|
|
258781
|
+
resolve38(null);
|
|
258783
258782
|
}, timeoutMs);
|
|
258784
258783
|
this._sudoResolve = (pw) => {
|
|
258785
258784
|
clearTimeout(timer);
|
|
258786
|
-
|
|
258785
|
+
resolve38(pw);
|
|
258787
258786
|
};
|
|
258788
258787
|
});
|
|
258789
258788
|
}
|
|
@@ -258916,10 +258915,10 @@ ${marker}` : marker);
|
|
|
258916
258915
|
if (!this._workingDirectory)
|
|
258917
258916
|
return;
|
|
258918
258917
|
try {
|
|
258919
|
-
const { mkdirSync:
|
|
258920
|
-
const { join:
|
|
258921
|
-
const sessionDir =
|
|
258922
|
-
|
|
258918
|
+
const { mkdirSync: mkdirSync35, writeFileSync: writeFileSync33 } = __require("node:fs");
|
|
258919
|
+
const { join: join83 } = __require("node:path");
|
|
258920
|
+
const sessionDir = join83(this._workingDirectory, ".oa", "session", this._sessionId);
|
|
258921
|
+
mkdirSync35(sessionDir, { recursive: true });
|
|
258923
258922
|
const checkpoint = {
|
|
258924
258923
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
258925
258924
|
sessionId: this._sessionId,
|
|
@@ -258931,7 +258930,7 @@ ${marker}` : marker);
|
|
|
258931
258930
|
memexEntryCount: this._memexArchive.size,
|
|
258932
258931
|
fileRegistrySize: this._fileRegistry.size
|
|
258933
258932
|
};
|
|
258934
|
-
|
|
258933
|
+
writeFileSync33(join83(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
258935
258934
|
} catch {
|
|
258936
258935
|
}
|
|
258937
258936
|
}
|
|
@@ -260068,18 +260067,18 @@ ${transcript}`
|
|
|
260068
260067
|
const buffer2 = Buffer.from(rawBase64, "base64");
|
|
260069
260068
|
let resizedBase64 = null;
|
|
260070
260069
|
try {
|
|
260071
|
-
const { execSync:
|
|
260072
|
-
const { writeFileSync:
|
|
260073
|
-
const { join:
|
|
260070
|
+
const { execSync: execSync37 } = await import("node:child_process");
|
|
260071
|
+
const { writeFileSync: writeFileSync33, readFileSync: readFileSync50, unlinkSync: unlinkSync13 } = await import("node:fs");
|
|
260072
|
+
const { join: join83 } = await import("node:path");
|
|
260074
260073
|
const { tmpdir: tmpdir11 } = await import("node:os");
|
|
260075
|
-
const tmpIn =
|
|
260076
|
-
const tmpOut =
|
|
260077
|
-
|
|
260074
|
+
const tmpIn = join83(tmpdir11(), `oa_img_in_${Date.now()}.png`);
|
|
260075
|
+
const tmpOut = join83(tmpdir11(), `oa_img_out_${Date.now()}.jpg`);
|
|
260076
|
+
writeFileSync33(tmpIn, buffer2);
|
|
260078
260077
|
const pyBin = process.platform === "win32" ? "python" : "python3";
|
|
260079
260078
|
const escapedIn = tmpIn.replace(/\\/g, "\\\\");
|
|
260080
260079
|
const escapedOut = tmpOut.replace(/\\/g, "\\\\");
|
|
260081
|
-
|
|
260082
|
-
const resizedBuf =
|
|
260080
|
+
execSync37(`${pyBin} -c "from PIL import Image; img = Image.open('${escapedIn}'); img.thumbnail((512, 512), Image.LANCZOS); img = img.convert('RGB'); img.save('${escapedOut}', 'JPEG', quality=75)"`, { timeout: 1e4, stdio: "pipe" });
|
|
260081
|
+
const resizedBuf = readFileSync50(tmpOut);
|
|
260083
260082
|
resizedBase64 = `data:image/jpeg;base64,${resizedBuf.toString("base64")}`;
|
|
260084
260083
|
try {
|
|
260085
260084
|
unlinkSync13(tmpIn);
|
|
@@ -260132,8 +260131,8 @@ ${transcript}`
|
|
|
260132
260131
|
if (!res.ok && model === "moondream" && res.status === 404) {
|
|
260133
260132
|
this.emit({ type: "status", content: `Pulling moondream vision model...`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
260134
260133
|
try {
|
|
260135
|
-
const { execSync:
|
|
260136
|
-
|
|
260134
|
+
const { execSync: execSync37 } = await import("node:child_process");
|
|
260135
|
+
execSync37("ollama pull moondream", { timeout: 3e5, stdio: "pipe" });
|
|
260137
260136
|
res = await fetch(`${ollamaHost}/api/generate`, {
|
|
260138
260137
|
method: "POST",
|
|
260139
260138
|
headers: { "Content-Type": "application/json" },
|
|
@@ -260907,12 +260906,12 @@ var init_nexusBackend = __esm({
|
|
|
260907
260906
|
const deadline = Date.now() + (request.timeoutMs ?? 12e4);
|
|
260908
260907
|
try {
|
|
260909
260908
|
while (!done && Date.now() < deadline) {
|
|
260910
|
-
await new Promise((
|
|
260909
|
+
await new Promise((resolve38) => {
|
|
260911
260910
|
let resolved = false;
|
|
260912
260911
|
const finish = () => {
|
|
260913
260912
|
if (!resolved) {
|
|
260914
260913
|
resolved = true;
|
|
260915
|
-
|
|
260914
|
+
resolve38();
|
|
260916
260915
|
}
|
|
260917
260916
|
};
|
|
260918
260917
|
let watcher = null;
|
|
@@ -261996,9 +261995,9 @@ function ensureTranscribeCliBackground() {
|
|
|
261996
261995
|
}
|
|
261997
261996
|
try {
|
|
261998
261997
|
const { exec: exec4 } = await import("node:child_process");
|
|
261999
|
-
return new Promise((
|
|
261998
|
+
return new Promise((resolve38) => {
|
|
262000
261999
|
exec4("npm i -g transcribe-cli", { timeout: 18e4 }, (err) => {
|
|
262001
|
-
|
|
262000
|
+
resolve38(!err);
|
|
262002
262001
|
});
|
|
262003
262002
|
});
|
|
262004
262003
|
} catch {
|
|
@@ -262057,7 +262056,7 @@ var init_listen = __esm({
|
|
|
262057
262056
|
return this._ready;
|
|
262058
262057
|
}
|
|
262059
262058
|
async start() {
|
|
262060
|
-
return new Promise((
|
|
262059
|
+
return new Promise((resolve38, reject) => {
|
|
262061
262060
|
const timeout2 = setTimeout(() => {
|
|
262062
262061
|
reject(new Error("Whisper fallback: model load timeout (5 min). First run downloads the model."));
|
|
262063
262062
|
}, 3e5);
|
|
@@ -262085,7 +262084,7 @@ var init_listen = __esm({
|
|
|
262085
262084
|
this._ready = true;
|
|
262086
262085
|
clearTimeout(timeout2);
|
|
262087
262086
|
this.emit("ready");
|
|
262088
|
-
|
|
262087
|
+
resolve38();
|
|
262089
262088
|
break;
|
|
262090
262089
|
case "transcript":
|
|
262091
262090
|
this.emit("transcript", {
|
|
@@ -262289,11 +262288,11 @@ var init_listen = __esm({
|
|
|
262289
262288
|
this.liveTranscriber.on("error", (err) => {
|
|
262290
262289
|
this.emit("error", err);
|
|
262291
262290
|
});
|
|
262292
|
-
await new Promise((
|
|
262291
|
+
await new Promise((resolve38, reject) => {
|
|
262293
262292
|
const timeout2 = setTimeout(() => reject(new Error("Model load timeout (60s)")), 6e4);
|
|
262294
262293
|
this.liveTranscriber.on("ready", () => {
|
|
262295
262294
|
clearTimeout(timeout2);
|
|
262296
|
-
|
|
262295
|
+
resolve38();
|
|
262297
262296
|
});
|
|
262298
262297
|
this.liveTranscriber.on("error", (err) => {
|
|
262299
262298
|
clearTimeout(timeout2);
|
|
@@ -262455,11 +262454,11 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
262455
262454
|
sampleWidth: 2,
|
|
262456
262455
|
chunkDuration: 3
|
|
262457
262456
|
});
|
|
262458
|
-
await new Promise((
|
|
262457
|
+
await new Promise((resolve38, reject) => {
|
|
262459
262458
|
const timeout2 = setTimeout(() => reject(new Error("Model load timeout (60s)")), 6e4);
|
|
262460
262459
|
transcriber.on("ready", () => {
|
|
262461
262460
|
clearTimeout(timeout2);
|
|
262462
|
-
|
|
262461
|
+
resolve38();
|
|
262463
262462
|
});
|
|
262464
262463
|
transcriber.on("error", (err) => {
|
|
262465
262464
|
clearTimeout(timeout2);
|
|
@@ -267833,8 +267832,8 @@ var init_voice_session = __esm({
|
|
|
267833
267832
|
socket.destroy();
|
|
267834
267833
|
}
|
|
267835
267834
|
});
|
|
267836
|
-
await new Promise((
|
|
267837
|
-
this.server.listen(port, "127.0.0.1", () =>
|
|
267835
|
+
await new Promise((resolve38, reject) => {
|
|
267836
|
+
this.server.listen(port, "127.0.0.1", () => resolve38());
|
|
267838
267837
|
this.server.on("error", reject);
|
|
267839
267838
|
});
|
|
267840
267839
|
try {
|
|
@@ -268057,7 +268056,7 @@ var init_voice_session = __esm({
|
|
|
268057
268056
|
}
|
|
268058
268057
|
// ── Cloudflared tunnel ────────────────────────────────────────────────
|
|
268059
268058
|
startCloudflared(port) {
|
|
268060
|
-
return new Promise((
|
|
268059
|
+
return new Promise((resolve38, reject) => {
|
|
268061
268060
|
const timeout2 = setTimeout(() => {
|
|
268062
268061
|
reject(new Error("Cloudflared tunnel start timeout (30s)"));
|
|
268063
268062
|
}, 3e4);
|
|
@@ -268075,7 +268074,7 @@ var init_voice_session = __esm({
|
|
|
268075
268074
|
if (urlMatch && !urlFound) {
|
|
268076
268075
|
urlFound = true;
|
|
268077
268076
|
clearTimeout(timeout2);
|
|
268078
|
-
|
|
268077
|
+
resolve38(urlMatch[0]);
|
|
268079
268078
|
}
|
|
268080
268079
|
};
|
|
268081
268080
|
this.cloudflaredProcess.stdout?.on("data", handleOutput);
|
|
@@ -268115,13 +268114,13 @@ var init_voice_session = __esm({
|
|
|
268115
268114
|
}
|
|
268116
268115
|
// ── Helpers ───────────────────────────────────────────────────────────
|
|
268117
268116
|
findFreePort() {
|
|
268118
|
-
return new Promise((
|
|
268117
|
+
return new Promise((resolve38, reject) => {
|
|
268119
268118
|
const srv = createServer3();
|
|
268120
268119
|
srv.listen(0, "127.0.0.1", () => {
|
|
268121
268120
|
const addr = srv.address();
|
|
268122
268121
|
if (addr && typeof addr === "object") {
|
|
268123
268122
|
const port = addr.port;
|
|
268124
|
-
srv.close(() =>
|
|
268123
|
+
srv.close(() => resolve38(port));
|
|
268125
268124
|
} else {
|
|
268126
268125
|
srv.close(() => reject(new Error("Could not find free port")));
|
|
268127
268126
|
}
|
|
@@ -268244,8 +268243,8 @@ async function collectSystemMetricsAsync() {
|
|
|
268244
268243
|
vramUtilization: 0
|
|
268245
268244
|
};
|
|
268246
268245
|
try {
|
|
268247
|
-
const smi = await new Promise((
|
|
268248
|
-
exec("nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total,name --format=csv,noheader,nounits 2>/dev/null", { encoding: "utf8", timeout: 3e3 }, (err, stdout) => err ? reject(err) :
|
|
268246
|
+
const smi = await new Promise((resolve38, reject) => {
|
|
268247
|
+
exec("nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total,name --format=csv,noheader,nounits 2>/dev/null", { encoding: "utf8", timeout: 3e3 }, (err, stdout) => err ? reject(err) : resolve38(stdout));
|
|
268249
268248
|
});
|
|
268250
268249
|
const line = smi.trim().split("\n")[0];
|
|
268251
268250
|
if (line) {
|
|
@@ -268448,8 +268447,8 @@ var init_expose = __esm({
|
|
|
268448
268447
|
throw new Error("Gateway already running");
|
|
268449
268448
|
const port = await this.findFreePort();
|
|
268450
268449
|
this.server = this.createProxyServer(port);
|
|
268451
|
-
await new Promise((
|
|
268452
|
-
this.server.listen(port, "127.0.0.1", () =>
|
|
268450
|
+
await new Promise((resolve38, reject) => {
|
|
268451
|
+
this.server.listen(port, "127.0.0.1", () => resolve38());
|
|
268453
268452
|
this.server.on("error", reject);
|
|
268454
268453
|
});
|
|
268455
268454
|
let lastStartErr;
|
|
@@ -268520,8 +268519,8 @@ var init_expose = __esm({
|
|
|
268520
268519
|
this._cloudflaredPid = state.pid;
|
|
268521
268520
|
this._proxyPort = state.proxyPort;
|
|
268522
268521
|
this.server = this.createProxyServer(state.proxyPort);
|
|
268523
|
-
await new Promise((
|
|
268524
|
-
this.server.listen(state.proxyPort, "127.0.0.1", () =>
|
|
268522
|
+
await new Promise((resolve38, reject) => {
|
|
268523
|
+
this.server.listen(state.proxyPort, "127.0.0.1", () => resolve38());
|
|
268525
268524
|
this.server.on("error", reject);
|
|
268526
268525
|
});
|
|
268527
268526
|
this._stats.status = "active";
|
|
@@ -268546,8 +268545,8 @@ var init_expose = __esm({
|
|
|
268546
268545
|
}
|
|
268547
268546
|
this._cloudflaredPid = null;
|
|
268548
268547
|
if (this.server) {
|
|
268549
|
-
await new Promise((
|
|
268550
|
-
this.server.close(() =>
|
|
268548
|
+
await new Promise((resolve38) => {
|
|
268549
|
+
this.server.close(() => resolve38());
|
|
268551
268550
|
});
|
|
268552
268551
|
this.server = null;
|
|
268553
268552
|
}
|
|
@@ -268916,7 +268915,7 @@ var init_expose = __esm({
|
|
|
268916
268915
|
_proxyPort = 0;
|
|
268917
268916
|
startCloudflared(port) {
|
|
268918
268917
|
this._proxyPort = port;
|
|
268919
|
-
return new Promise((
|
|
268918
|
+
return new Promise((resolve38, reject) => {
|
|
268920
268919
|
const TUNNEL_TIMEOUT_MS = 6e4;
|
|
268921
268920
|
const timeout2 = setTimeout(() => {
|
|
268922
268921
|
reject(new Error("Cloudflared tunnel start timeout (60s). Slow network? Try again."));
|
|
@@ -268960,7 +268959,7 @@ var init_expose = __esm({
|
|
|
268960
268959
|
this.cloudflaredProcess?.unref();
|
|
268961
268960
|
this.cloudflaredProcess?.stdout?.destroy();
|
|
268962
268961
|
this.cloudflaredProcess?.stderr?.destroy();
|
|
268963
|
-
|
|
268962
|
+
resolve38(urlMatch[0]);
|
|
268964
268963
|
}
|
|
268965
268964
|
};
|
|
268966
268965
|
this.cloudflaredProcess.stdout?.on("data", handleOutput);
|
|
@@ -269079,13 +269078,13 @@ ${this.formatConnectionInfo()}`);
|
|
|
269079
269078
|
}
|
|
269080
269079
|
// ── Helpers ─────────────────────────────────────────────────────────────
|
|
269081
269080
|
findFreePort() {
|
|
269082
|
-
return new Promise((
|
|
269081
|
+
return new Promise((resolve38, reject) => {
|
|
269083
269082
|
const srv = createServer4();
|
|
269084
269083
|
srv.listen(0, "127.0.0.1", () => {
|
|
269085
269084
|
const addr = srv.address();
|
|
269086
269085
|
if (addr && typeof addr === "object") {
|
|
269087
269086
|
const port = addr.port;
|
|
269088
|
-
srv.close(() =>
|
|
269087
|
+
srv.close(() => resolve38(port));
|
|
269089
269088
|
} else {
|
|
269090
269089
|
srv.close(() => reject(new Error("Could not find free port")));
|
|
269091
269090
|
}
|
|
@@ -270032,8 +270031,8 @@ var init_peer_mesh = __esm({
|
|
|
270032
270031
|
this.wss.on("connection", (ws, req2) => {
|
|
270033
270032
|
this.handleInboundConnection(ws, req2.url ?? "");
|
|
270034
270033
|
});
|
|
270035
|
-
await new Promise((
|
|
270036
|
-
this.server.listen(port, "127.0.0.1", () =>
|
|
270034
|
+
await new Promise((resolve38, reject) => {
|
|
270035
|
+
this.server.listen(port, "127.0.0.1", () => resolve38());
|
|
270037
270036
|
this.server.on("error", reject);
|
|
270038
270037
|
});
|
|
270039
270038
|
this.pingTimer = setInterval(() => this.pingAll(), PING_INTERVAL_MS);
|
|
@@ -270072,7 +270071,7 @@ var init_peer_mesh = __esm({
|
|
|
270072
270071
|
this.wss = null;
|
|
270073
270072
|
}
|
|
270074
270073
|
if (this.server) {
|
|
270075
|
-
await new Promise((
|
|
270074
|
+
await new Promise((resolve38) => this.server.close(() => resolve38()));
|
|
270076
270075
|
this.server = null;
|
|
270077
270076
|
}
|
|
270078
270077
|
this.emit("stopped");
|
|
@@ -270090,7 +270089,7 @@ var init_peer_mesh = __esm({
|
|
|
270090
270089
|
if (!wsUrl.includes("/p2p"))
|
|
270091
270090
|
wsUrl += "/p2p";
|
|
270092
270091
|
wsUrl += `?key=${encodeURIComponent(this._authKey)}`;
|
|
270093
|
-
return new Promise((
|
|
270092
|
+
return new Promise((resolve38, reject) => {
|
|
270094
270093
|
const ws = new import_websocket5.default(wsUrl, { handshakeTimeout: 1e4 });
|
|
270095
270094
|
let resolved = false;
|
|
270096
270095
|
const timeout2 = setTimeout(() => {
|
|
@@ -270130,7 +270129,7 @@ var init_peer_mesh = __esm({
|
|
|
270130
270129
|
this.connections.set(peer.peerId, ws);
|
|
270131
270130
|
this.setupPeerHandlers(ws, peer.peerId);
|
|
270132
270131
|
this.emit("peer_connected", peer);
|
|
270133
|
-
|
|
270132
|
+
resolve38(peer);
|
|
270134
270133
|
} else {
|
|
270135
270134
|
this.handleMessage(msg, ws);
|
|
270136
270135
|
}
|
|
@@ -270185,12 +270184,12 @@ var init_peer_mesh = __esm({
|
|
|
270185
270184
|
throw new Error(`Peer ${peerId} not connected`);
|
|
270186
270185
|
}
|
|
270187
270186
|
const msgId = randomBytes17(8).toString("hex");
|
|
270188
|
-
return new Promise((
|
|
270187
|
+
return new Promise((resolve38, reject) => {
|
|
270189
270188
|
const timeout2 = setTimeout(() => {
|
|
270190
270189
|
this.pendingRequests.delete(msgId);
|
|
270191
270190
|
reject(new Error(`Inference timeout (${timeoutMs}ms)`));
|
|
270192
270191
|
}, timeoutMs);
|
|
270193
|
-
this.pendingRequests.set(msgId, { resolve:
|
|
270192
|
+
this.pendingRequests.set(msgId, { resolve: resolve38, reject, timeout: timeout2, chunks: [] });
|
|
270194
270193
|
this.sendMsg(ws, "infer_request", request, msgId);
|
|
270195
270194
|
});
|
|
270196
270195
|
}
|
|
@@ -270412,13 +270411,13 @@ var init_peer_mesh = __esm({
|
|
|
270412
270411
|
ws.send(JSON.stringify(msg));
|
|
270413
270412
|
}
|
|
270414
270413
|
findFreePort() {
|
|
270415
|
-
return new Promise((
|
|
270414
|
+
return new Promise((resolve38, reject) => {
|
|
270416
270415
|
const srv = createServer5();
|
|
270417
270416
|
srv.listen(0, "127.0.0.1", () => {
|
|
270418
270417
|
const addr = srv.address();
|
|
270419
270418
|
if (addr && typeof addr === "object") {
|
|
270420
270419
|
const port = addr.port;
|
|
270421
|
-
srv.close(() =>
|
|
270420
|
+
srv.close(() => resolve38(port));
|
|
270422
270421
|
} else {
|
|
270423
270422
|
srv.close(() => reject(new Error("Could not find free port")));
|
|
270424
270423
|
}
|
|
@@ -271081,26 +271080,26 @@ async function fetchOpenAIModels(baseUrl, apiKey) {
|
|
|
271081
271080
|
async function fetchPeerModels(peerId, authKey) {
|
|
271082
271081
|
try {
|
|
271083
271082
|
const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports));
|
|
271084
|
-
const { existsSync:
|
|
271085
|
-
const { join:
|
|
271083
|
+
const { existsSync: existsSync62, readFileSync: readFileSync50 } = await import("node:fs");
|
|
271084
|
+
const { join: join83 } = await import("node:path");
|
|
271086
271085
|
const cwd4 = process.cwd();
|
|
271087
271086
|
const nexusTool = new NexusTool2(cwd4);
|
|
271088
271087
|
const nexusDir = nexusTool.getNexusDir();
|
|
271089
271088
|
let isLocalPeer = false;
|
|
271090
271089
|
try {
|
|
271091
|
-
const statusPath =
|
|
271092
|
-
if (
|
|
271093
|
-
const status = JSON.parse(
|
|
271090
|
+
const statusPath = join83(nexusDir, "status.json");
|
|
271091
|
+
if (existsSync62(statusPath)) {
|
|
271092
|
+
const status = JSON.parse(readFileSync50(statusPath, "utf8"));
|
|
271094
271093
|
if (status.peerId === peerId)
|
|
271095
271094
|
isLocalPeer = true;
|
|
271096
271095
|
}
|
|
271097
271096
|
} catch {
|
|
271098
271097
|
}
|
|
271099
271098
|
if (isLocalPeer) {
|
|
271100
|
-
const pricingPath =
|
|
271101
|
-
if (
|
|
271099
|
+
const pricingPath = join83(nexusDir, "pricing.json");
|
|
271100
|
+
if (existsSync62(pricingPath)) {
|
|
271102
271101
|
try {
|
|
271103
|
-
const pricing = JSON.parse(
|
|
271102
|
+
const pricing = JSON.parse(readFileSync50(pricingPath, "utf8"));
|
|
271104
271103
|
const localModels = (pricing.models || []).map((m2) => ({
|
|
271105
271104
|
name: m2.model || "unknown",
|
|
271106
271105
|
size: m2.parameterSize || "",
|
|
@@ -271114,10 +271113,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
271114
271113
|
}
|
|
271115
271114
|
}
|
|
271116
271115
|
}
|
|
271117
|
-
const cachePath =
|
|
271118
|
-
if (
|
|
271116
|
+
const cachePath = join83(nexusDir, "peer-models-cache.json");
|
|
271117
|
+
if (existsSync62(cachePath)) {
|
|
271119
271118
|
try {
|
|
271120
|
-
const cache7 = JSON.parse(
|
|
271119
|
+
const cache7 = JSON.parse(readFileSync50(cachePath, "utf8"));
|
|
271121
271120
|
if (cache7.peerId === peerId && cache7.models?.length > 0) {
|
|
271122
271121
|
const age = Date.now() - new Date(cache7.cachedAt).getTime();
|
|
271123
271122
|
if (age < 5 * 60 * 1e3) {
|
|
@@ -271232,10 +271231,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
271232
271231
|
} catch {
|
|
271233
271232
|
}
|
|
271234
271233
|
if (isLocalPeer) {
|
|
271235
|
-
const pricingPath =
|
|
271236
|
-
if (
|
|
271234
|
+
const pricingPath = join83(nexusDir, "pricing.json");
|
|
271235
|
+
if (existsSync62(pricingPath)) {
|
|
271237
271236
|
try {
|
|
271238
|
-
const pricing = JSON.parse(
|
|
271237
|
+
const pricing = JSON.parse(readFileSync50(pricingPath, "utf8"));
|
|
271239
271238
|
return (pricing.models || []).map((m2) => ({
|
|
271240
271239
|
name: m2.model || "unknown",
|
|
271241
271240
|
size: m2.parameterSize || "",
|
|
@@ -272400,7 +272399,7 @@ function tuiSelect(opts) {
|
|
|
272400
272399
|
const maxVisible = opts.maxVisible ?? Math.max(3, contentArea - selectChrome);
|
|
272401
272400
|
let scrollOffset = 0;
|
|
272402
272401
|
let lastRenderedLines = 0;
|
|
272403
|
-
return new Promise((
|
|
272402
|
+
return new Promise((resolve38) => {
|
|
272404
272403
|
const stdin = process.stdin;
|
|
272405
272404
|
const hadRawMode = stdin.isRaw;
|
|
272406
272405
|
const savedRlListeners = [];
|
|
@@ -272577,7 +272576,7 @@ function tuiSelect(opts) {
|
|
|
272577
272576
|
if (!isSkippable(itemIdx) && matchSet.has(itemIdx)) {
|
|
272578
272577
|
cursor = itemIdx;
|
|
272579
272578
|
cleanup();
|
|
272580
|
-
|
|
272579
|
+
resolve38({ confirmed: true, key: items[cursor].key, index: cursor });
|
|
272581
272580
|
return;
|
|
272582
272581
|
} else if (!isSkippable(itemIdx)) {
|
|
272583
272582
|
cursor = itemIdx;
|
|
@@ -272653,7 +272652,7 @@ function tuiSelect(opts) {
|
|
|
272653
272652
|
items.splice(deletedIdx, 1);
|
|
272654
272653
|
if (items.length === 0) {
|
|
272655
272654
|
cleanup();
|
|
272656
|
-
|
|
272655
|
+
resolve38({ confirmed: false, key: null, index: -1 });
|
|
272657
272656
|
return;
|
|
272658
272657
|
}
|
|
272659
272658
|
updateFilter();
|
|
@@ -272746,7 +272745,7 @@ function tuiSelect(opts) {
|
|
|
272746
272745
|
done: () => render(),
|
|
272747
272746
|
resolve: (result) => {
|
|
272748
272747
|
cleanup();
|
|
272749
|
-
|
|
272748
|
+
resolve38(result);
|
|
272750
272749
|
},
|
|
272751
272750
|
getInput: (prompt, prefill) => getInputFromUser(prompt, prefill),
|
|
272752
272751
|
render: () => render(),
|
|
@@ -272759,7 +272758,7 @@ function tuiSelect(opts) {
|
|
|
272759
272758
|
return;
|
|
272760
272759
|
}
|
|
272761
272760
|
cleanup();
|
|
272762
|
-
|
|
272761
|
+
resolve38({ confirmed: true, key: items[cursor].key, index: cursor });
|
|
272763
272762
|
}
|
|
272764
272763
|
} else if (seq === "\x1B" || seq === "\x1B\x1B") {
|
|
272765
272764
|
if (filter2) {
|
|
@@ -272772,14 +272771,14 @@ function tuiSelect(opts) {
|
|
|
272772
272771
|
render();
|
|
272773
272772
|
} else if (hasBreadcrumbs) {
|
|
272774
272773
|
cleanup();
|
|
272775
|
-
|
|
272774
|
+
resolve38({ confirmed: false, key: "__back__", index: cursor });
|
|
272776
272775
|
} else {
|
|
272777
272776
|
cleanup();
|
|
272778
|
-
|
|
272777
|
+
resolve38({ confirmed: false, key: null, index: cursor });
|
|
272779
272778
|
}
|
|
272780
272779
|
} else if (seq === "") {
|
|
272781
272780
|
cleanup();
|
|
272782
|
-
|
|
272781
|
+
resolve38({ confirmed: false, key: null, index: cursor });
|
|
272783
272782
|
} else if (seq === "\x7F" || seq === "\b") {
|
|
272784
272783
|
if (filter2.length > 0) {
|
|
272785
272784
|
filter2 = filter2.slice(0, -1);
|
|
@@ -272793,7 +272792,7 @@ function tuiSelect(opts) {
|
|
|
272793
272792
|
render();
|
|
272794
272793
|
} else if (hasBreadcrumbs) {
|
|
272795
272794
|
cleanup();
|
|
272796
|
-
|
|
272795
|
+
resolve38({ confirmed: false, key: "__back__", index: cursor });
|
|
272797
272796
|
}
|
|
272798
272797
|
} else if (seq.length === 1 && seq.charCodeAt(0) >= 32 && seq.charCodeAt(0) < 127) {
|
|
272799
272798
|
if (opts.onCustomKey && !isSkippable(cursor) && matchSet.has(cursor)) {
|
|
@@ -272801,7 +272800,7 @@ function tuiSelect(opts) {
|
|
|
272801
272800
|
done: () => render(),
|
|
272802
272801
|
resolve: (result) => {
|
|
272803
272802
|
cleanup();
|
|
272804
|
-
|
|
272803
|
+
resolve38(result);
|
|
272805
272804
|
},
|
|
272806
272805
|
getInput: (prompt, prefill) => getInputFromUser(prompt, prefill),
|
|
272807
272806
|
render: () => render(),
|
|
@@ -273036,7 +273035,7 @@ import { homedir as homedir14 } from "node:os";
|
|
|
273036
273035
|
import { execSync as execSync28, spawn as spawn19, execFile as execFile7 } from "node:child_process";
|
|
273037
273036
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
273038
273037
|
function execAsync(cmd, opts = {}) {
|
|
273039
|
-
return new Promise((
|
|
273038
|
+
return new Promise((resolve38, reject) => {
|
|
273040
273039
|
const child = spawn19("bash", ["-c", cmd], {
|
|
273041
273040
|
stdio: ["ignore", "pipe", "pipe"],
|
|
273042
273041
|
timeout: opts.timeout ?? 3e5,
|
|
@@ -273052,7 +273051,7 @@ function execAsync(cmd, opts = {}) {
|
|
|
273052
273051
|
});
|
|
273053
273052
|
child.on("close", (code8, signal) => {
|
|
273054
273053
|
if (code8 === 0)
|
|
273055
|
-
|
|
273054
|
+
resolve38(stdout.trim());
|
|
273056
273055
|
else
|
|
273057
273056
|
reject(new Error(`Exit ${code8}${signal ? ` (signal: ${signal})` : ""}: ${stderr.slice(0, 500)}`));
|
|
273058
273057
|
});
|
|
@@ -273777,7 +273776,7 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
|
|
|
273777
273776
|
}
|
|
273778
273777
|
log22(`Cloning voice "${voiceName}" from ${inputWav}...`);
|
|
273779
273778
|
log22("This requires loading the full 7B model \u2014 may take 30-60s...");
|
|
273780
|
-
return new Promise((
|
|
273779
|
+
return new Promise((resolve38) => {
|
|
273781
273780
|
const child = spawn19(venvPython2, [
|
|
273782
273781
|
cloneScript,
|
|
273783
273782
|
"--input",
|
|
@@ -273805,10 +273804,10 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
|
|
|
273805
273804
|
child.on("close", (code8) => {
|
|
273806
273805
|
if (code8 === 0 && existsSync38(outputPt)) {
|
|
273807
273806
|
log22(`Voice "${voiceName}" cloned successfully.`);
|
|
273808
|
-
|
|
273807
|
+
resolve38(outputPt);
|
|
273809
273808
|
} else {
|
|
273810
273809
|
log22(`Voice cloning failed (exit ${code8}).`);
|
|
273811
|
-
|
|
273810
|
+
resolve38(null);
|
|
273812
273811
|
}
|
|
273813
273812
|
});
|
|
273814
273813
|
});
|
|
@@ -274145,12 +274144,12 @@ function calculateContextWindow(specs, modelSizeGB2, kvBytesPerToken, archMax) {
|
|
|
274145
274144
|
return { numCtx, label };
|
|
274146
274145
|
}
|
|
274147
274146
|
function ask(rl, question) {
|
|
274148
|
-
return new Promise((
|
|
274149
|
-
rl.question(question, (answer) =>
|
|
274147
|
+
return new Promise((resolve38) => {
|
|
274148
|
+
rl.question(question, (answer) => resolve38(answer.trim()));
|
|
274150
274149
|
});
|
|
274151
274150
|
}
|
|
274152
274151
|
function askSecret(rl, question) {
|
|
274153
|
-
return new Promise((
|
|
274152
|
+
return new Promise((resolve38) => {
|
|
274154
274153
|
process.stdout.write(question);
|
|
274155
274154
|
let secret = "";
|
|
274156
274155
|
const stdin = process.stdin;
|
|
@@ -274168,7 +274167,7 @@ function askSecret(rl, question) {
|
|
|
274168
274167
|
stdin.setRawMode(hadRawMode ?? false);
|
|
274169
274168
|
}
|
|
274170
274169
|
process.stdout.write("\n");
|
|
274171
|
-
|
|
274170
|
+
resolve38(secret.trim());
|
|
274172
274171
|
return;
|
|
274173
274172
|
} else if (c4 === "") {
|
|
274174
274173
|
stdin.removeListener("data", onData);
|
|
@@ -274176,7 +274175,7 @@ function askSecret(rl, question) {
|
|
|
274176
274175
|
stdin.setRawMode(hadRawMode ?? false);
|
|
274177
274176
|
}
|
|
274178
274177
|
process.stdout.write("\n");
|
|
274179
|
-
|
|
274178
|
+
resolve38("");
|
|
274180
274179
|
return;
|
|
274181
274180
|
} else if (c4 === "\x7F" || c4 === "\b") {
|
|
274182
274181
|
if (secret.length > 0) {
|
|
@@ -274411,7 +274410,7 @@ async function ensureOllamaRunning(backendUrl, rl) {
|
|
|
274411
274410
|
return false;
|
|
274412
274411
|
}
|
|
274413
274412
|
for (let i2 = 0; i2 < 5; i2++) {
|
|
274414
|
-
await new Promise((
|
|
274413
|
+
await new Promise((resolve38) => setTimeout(resolve38, 2e3));
|
|
274415
274414
|
try {
|
|
274416
274415
|
const resp = await fetch(`${backendUrl}/api/tags`, {
|
|
274417
274416
|
signal: AbortSignal.timeout(3e3)
|
|
@@ -274880,7 +274879,7 @@ async function doSetup(config, rl) {
|
|
|
274880
274879
|
try {
|
|
274881
274880
|
const child = spawn20("ollama", ["serve"], { stdio: "ignore", detached: true });
|
|
274882
274881
|
child.unref();
|
|
274883
|
-
await new Promise((
|
|
274882
|
+
await new Promise((resolve38) => setTimeout(resolve38, 3e3));
|
|
274884
274883
|
try {
|
|
274885
274884
|
models = await fetchOllamaModels(config.backendUrl);
|
|
274886
274885
|
process.stdout.write(` ${c3.green("\u2714")} Ollama is running.
|
|
@@ -274908,7 +274907,7 @@ async function doSetup(config, rl) {
|
|
|
274908
274907
|
try {
|
|
274909
274908
|
const child = spawn20("ollama", ["serve"], { stdio: "ignore", detached: true });
|
|
274910
274909
|
child.unref();
|
|
274911
|
-
await new Promise((
|
|
274910
|
+
await new Promise((resolve38) => setTimeout(resolve38, 3e3));
|
|
274912
274911
|
try {
|
|
274913
274912
|
models = await fetchOllamaModels(config.backendUrl);
|
|
274914
274913
|
process.stdout.write(` ${c3.green("\u2714")} Ollama is running.
|
|
@@ -276225,12 +276224,12 @@ function stopNeovimMode() {
|
|
|
276225
276224
|
} catch {
|
|
276226
276225
|
}
|
|
276227
276226
|
const s2 = _state;
|
|
276228
|
-
return new Promise((
|
|
276227
|
+
return new Promise((resolve38) => {
|
|
276229
276228
|
setTimeout(() => {
|
|
276230
276229
|
if (s2 && !s2.cleanedUp) {
|
|
276231
276230
|
doCleanup(s2);
|
|
276232
276231
|
}
|
|
276233
|
-
|
|
276232
|
+
resolve38();
|
|
276234
276233
|
}, 300);
|
|
276235
276234
|
});
|
|
276236
276235
|
}
|
|
@@ -279204,7 +279203,7 @@ var init_voice = __esm({
|
|
|
279204
279203
|
this.speaking = false;
|
|
279205
279204
|
}
|
|
279206
279205
|
sleep(ms) {
|
|
279207
|
-
return new Promise((
|
|
279206
|
+
return new Promise((resolve38) => setTimeout(resolve38, ms));
|
|
279208
279207
|
}
|
|
279209
279208
|
// -------------------------------------------------------------------------
|
|
279210
279209
|
// Synthesis pipeline
|
|
@@ -279470,7 +279469,7 @@ var init_voice = __esm({
|
|
|
279470
279469
|
const cmd = this.getPlayCommand(path5);
|
|
279471
279470
|
if (!cmd)
|
|
279472
279471
|
return;
|
|
279473
|
-
return new Promise((
|
|
279472
|
+
return new Promise((resolve38) => {
|
|
279474
279473
|
const child = nodeSpawn(cmd[0], cmd.slice(1), {
|
|
279475
279474
|
stdio: "ignore",
|
|
279476
279475
|
detached: false
|
|
@@ -279479,12 +279478,12 @@ var init_voice = __esm({
|
|
|
279479
279478
|
child.on("close", () => {
|
|
279480
279479
|
if (this.currentPlayback === child)
|
|
279481
279480
|
this.currentPlayback = null;
|
|
279482
|
-
|
|
279481
|
+
resolve38();
|
|
279483
279482
|
});
|
|
279484
279483
|
child.on("error", () => {
|
|
279485
279484
|
if (this.currentPlayback === child)
|
|
279486
279485
|
this.currentPlayback = null;
|
|
279487
|
-
|
|
279486
|
+
resolve38();
|
|
279488
279487
|
});
|
|
279489
279488
|
setTimeout(() => {
|
|
279490
279489
|
if (this.currentPlayback === child) {
|
|
@@ -279494,7 +279493,7 @@ var init_voice = __esm({
|
|
|
279494
279493
|
}
|
|
279495
279494
|
this.currentPlayback = null;
|
|
279496
279495
|
}
|
|
279497
|
-
|
|
279496
|
+
resolve38();
|
|
279498
279497
|
}, 15e3);
|
|
279499
279498
|
});
|
|
279500
279499
|
}
|
|
@@ -279569,7 +279568,7 @@ var init_voice = __esm({
|
|
|
279569
279568
|
/** Non-blocking shell execution — async alternative to execSync.
|
|
279570
279569
|
* Returns stdout string on exit 0, rejects otherwise. */
|
|
279571
279570
|
asyncShell(command, timeoutMs = 3e4) {
|
|
279572
|
-
return new Promise((
|
|
279571
|
+
return new Promise((resolve38, reject) => {
|
|
279573
279572
|
const proc = nodeSpawn("sh", ["-c", command], {
|
|
279574
279573
|
stdio: ["ignore", "pipe", "pipe"],
|
|
279575
279574
|
cwd: tmpdir9()
|
|
@@ -279590,7 +279589,7 @@ var init_voice = __esm({
|
|
|
279590
279589
|
proc.on("close", (code8) => {
|
|
279591
279590
|
clearTimeout(timer);
|
|
279592
279591
|
if (code8 === 0)
|
|
279593
|
-
|
|
279592
|
+
resolve38(stdout.trim());
|
|
279594
279593
|
else
|
|
279595
279594
|
reject(new Error(stderr.slice(0, 300) || `Exit code ${code8}`));
|
|
279596
279595
|
});
|
|
@@ -280126,7 +280125,7 @@ if __name__ == '__main__':
|
|
|
280126
280125
|
const venvPy = luxttsVenvPy();
|
|
280127
280126
|
if (!existsSync43(venvPy))
|
|
280128
280127
|
return false;
|
|
280129
|
-
return new Promise((
|
|
280128
|
+
return new Promise((resolve38) => {
|
|
280130
280129
|
const env2 = { ...process.env, LUXTTS_REPO_PATH: luxttsRepoDir() };
|
|
280131
280130
|
const daemon = nodeSpawn(venvPy, [luxttsInferScript()], {
|
|
280132
280131
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -280153,7 +280152,7 @@ if __name__ == '__main__':
|
|
|
280153
280152
|
status: "running"
|
|
280154
280153
|
});
|
|
280155
280154
|
}
|
|
280156
|
-
|
|
280155
|
+
resolve38(true);
|
|
280157
280156
|
} else if (msg.type === "result" || msg.type === "error") {
|
|
280158
280157
|
const pending = this._luxttsPending.get(msg.id);
|
|
280159
280158
|
if (pending) {
|
|
@@ -280178,25 +280177,25 @@ if __name__ == '__main__':
|
|
|
280178
280177
|
});
|
|
280179
280178
|
daemon.on("error", () => {
|
|
280180
280179
|
this._luxttsDaemon = null;
|
|
280181
|
-
|
|
280180
|
+
resolve38(false);
|
|
280182
280181
|
});
|
|
280183
280182
|
setTimeout(() => {
|
|
280184
280183
|
if (this._luxttsDaemon === daemon && !this._luxttsPending.has("__ready__")) {
|
|
280185
|
-
|
|
280184
|
+
resolve38(false);
|
|
280186
280185
|
}
|
|
280187
280186
|
}, 6e4);
|
|
280188
280187
|
});
|
|
280189
280188
|
}
|
|
280190
280189
|
/** Send a request to the LuxTTS daemon and await the response */
|
|
280191
280190
|
luxttsRequest(req2) {
|
|
280192
|
-
return new Promise((
|
|
280191
|
+
return new Promise((resolve38, reject) => {
|
|
280193
280192
|
if (!this._luxttsDaemon || this._luxttsDaemon.killed) {
|
|
280194
280193
|
reject(new Error("LuxTTS daemon not running"));
|
|
280195
280194
|
return;
|
|
280196
280195
|
}
|
|
280197
280196
|
const id = `req_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
280198
280197
|
req2.id = id;
|
|
280199
|
-
this._luxttsPending.set(id, { resolve:
|
|
280198
|
+
this._luxttsPending.set(id, { resolve: resolve38, reject });
|
|
280200
280199
|
this._luxttsDaemon.stdin.write(JSON.stringify(req2) + "\n");
|
|
280201
280200
|
setTimeout(() => {
|
|
280202
280201
|
if (this._luxttsPending.has(id)) {
|
|
@@ -281072,9 +281071,9 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
281072
281071
|
renderInfo("No wallet configured. Ask the agent to create one via the nexus tool.");
|
|
281073
281072
|
}
|
|
281074
281073
|
} else if (sub === "name") {
|
|
281075
|
-
const { homedir:
|
|
281074
|
+
const { homedir: homedir23 } = __require("node:os");
|
|
281076
281075
|
const { existsSync: ex, readFileSync: rf, writeFileSync: wf, mkdirSync: mkd } = __require("node:fs");
|
|
281077
|
-
const namePath = __require("node:path").join(
|
|
281076
|
+
const namePath = __require("node:path").join(homedir23(), ".open-agents", "agent-name");
|
|
281078
281077
|
if (rest2) {
|
|
281079
281078
|
const customName = rest2.replace(/[^a-zA-Z0-9_\-.\s]/g, "").trim().slice(0, 40);
|
|
281080
281079
|
if (!customName) {
|
|
@@ -281778,8 +281777,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
281778
281777
|
writeFileSync21(jwtFile, JSON.stringify(jwtPayload, null, 2));
|
|
281779
281778
|
renderInfo(`Launching fortemi-react from ${fDir}...`);
|
|
281780
281779
|
try {
|
|
281781
|
-
const { spawn:
|
|
281782
|
-
const child =
|
|
281780
|
+
const { spawn: spawn24 } = __require("node:child_process");
|
|
281781
|
+
const child = spawn24("npx", ["vite", "dev", "--host", "0.0.0.0", "--port", "3000"], {
|
|
281783
281782
|
cwd: join61(fDir, "apps", "standalone"),
|
|
281784
281783
|
stdio: "ignore",
|
|
281785
281784
|
detached: true,
|
|
@@ -282726,8 +282725,8 @@ Clone a new voice: /voice clone <wav-file> [name]`);
|
|
|
282726
282725
|
let sponsorName = (config.header.message || "").replace(/^\/+/, "").trim();
|
|
282727
282726
|
if (!sponsorName || sponsorName.length < 2) {
|
|
282728
282727
|
try {
|
|
282729
|
-
const { homedir:
|
|
282730
|
-
const namePath = __require("path").join(
|
|
282728
|
+
const { homedir: homedir23 } = __require("os");
|
|
282729
|
+
const namePath = __require("path").join(homedir23(), ".open-agents", "agent-name");
|
|
282731
282730
|
if (existsSync44(namePath))
|
|
282732
282731
|
sponsorName = readFileSync33(namePath, "utf8").trim();
|
|
282733
282732
|
} catch {
|
|
@@ -284132,12 +284131,12 @@ async function handleVoiceMenu(ctx3, save2, hasLocal) {
|
|
|
284132
284131
|
continue;
|
|
284133
284132
|
}
|
|
284134
284133
|
const { basename: basename19, join: pathJoin } = await import("node:path");
|
|
284135
|
-
const { copyFileSync: copyFileSync3, mkdirSync:
|
|
284136
|
-
const { homedir:
|
|
284134
|
+
const { copyFileSync: copyFileSync3, mkdirSync: mkdirSync35, existsSync: exists2 } = await import("node:fs");
|
|
284135
|
+
const { homedir: homedir23 } = await import("node:os");
|
|
284137
284136
|
const modelName = basename19(onnxDrop.path, ".onnx").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
284138
|
-
const destDir = pathJoin(
|
|
284137
|
+
const destDir = pathJoin(homedir23(), ".open-agents", "voice", "models", modelName);
|
|
284139
284138
|
if (!exists2(destDir))
|
|
284140
|
-
|
|
284139
|
+
mkdirSync35(destDir, { recursive: true });
|
|
284141
284140
|
copyFileSync3(onnxDrop.path, pathJoin(destDir, "model.onnx"));
|
|
284142
284141
|
copyFileSync3(jsonDrop.path, pathJoin(destDir, "config.json"));
|
|
284143
284142
|
const { registerCustomOnnxModel: registerCustomOnnxModel2 } = await Promise.resolve().then(() => (init_voice(), voice_exports));
|
|
@@ -284830,10 +284829,10 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
284830
284829
|
sponsors.push(...verified);
|
|
284831
284830
|
if (verified.length > 0) {
|
|
284832
284831
|
try {
|
|
284833
|
-
const { mkdirSync:
|
|
284834
|
-
|
|
284832
|
+
const { mkdirSync: mkdirSync35, writeFileSync: writeFileSync33 } = __require("node:fs");
|
|
284833
|
+
mkdirSync35(sponsorDir2, { recursive: true });
|
|
284835
284834
|
const cached = verified.map((s2) => ({ ...s2, lastVerified: Date.now() }));
|
|
284836
|
-
|
|
284835
|
+
writeFileSync33(knownFile, JSON.stringify(cached, null, 2));
|
|
284837
284836
|
} catch {
|
|
284838
284837
|
}
|
|
284839
284838
|
}
|
|
@@ -284997,11 +284996,11 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
|
|
|
284997
284996
|
const models = await fetchModels(peerUrl, authKey);
|
|
284998
284997
|
if (models.length > 0) {
|
|
284999
284998
|
try {
|
|
285000
|
-
const { writeFileSync:
|
|
285001
|
-
const { join:
|
|
285002
|
-
const cachePath =
|
|
285003
|
-
|
|
285004
|
-
|
|
284999
|
+
const { writeFileSync: writeFileSync33, mkdirSync: mkdirSync35 } = await import("node:fs");
|
|
285000
|
+
const { join: join83, dirname: dirname25 } = await import("node:path");
|
|
285001
|
+
const cachePath = join83(ctx3.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
|
|
285002
|
+
mkdirSync35(dirname25(cachePath), { recursive: true });
|
|
285003
|
+
writeFileSync33(cachePath, JSON.stringify({
|
|
285005
285004
|
peerId,
|
|
285006
285005
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
285007
285006
|
models: models.map((m2) => ({ name: m2.name, size: m2.size, parameterSize: m2.parameterSize }))
|
|
@@ -285050,7 +285049,7 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
|
|
|
285050
285049
|
}
|
|
285051
285050
|
}
|
|
285052
285051
|
async function handleParallel(arg, ctx3) {
|
|
285053
|
-
const { execSync:
|
|
285052
|
+
const { execSync: execSync37 } = await import("node:child_process");
|
|
285054
285053
|
const baseUrl = ctx3.config.backendUrl || "http://localhost:11434";
|
|
285055
285054
|
const isRemote = ctx3.config.backendType === "nexus";
|
|
285056
285055
|
if (isRemote) {
|
|
@@ -285074,7 +285073,7 @@ async function handleParallel(arg, ctx3) {
|
|
|
285074
285073
|
}
|
|
285075
285074
|
let systemdVal = "";
|
|
285076
285075
|
try {
|
|
285077
|
-
const out =
|
|
285076
|
+
const out = execSync37("systemctl show ollama.service -p Environment 2>/dev/null || true", { encoding: "utf8" });
|
|
285078
285077
|
const match = out.match(/OLLAMA_NUM_PARALLEL=(\d+)/);
|
|
285079
285078
|
if (match)
|
|
285080
285079
|
systemdVal = match[1];
|
|
@@ -285103,7 +285102,7 @@ async function handleParallel(arg, ctx3) {
|
|
|
285103
285102
|
}
|
|
285104
285103
|
const isSystemd = (() => {
|
|
285105
285104
|
try {
|
|
285106
|
-
const out =
|
|
285105
|
+
const out = execSync37("systemctl is-active ollama.service 2>/dev/null", { encoding: "utf8" }).trim();
|
|
285107
285106
|
return out === "active" || out === "inactive";
|
|
285108
285107
|
} catch {
|
|
285109
285108
|
return false;
|
|
@@ -285117,10 +285116,10 @@ async function handleParallel(arg, ctx3) {
|
|
|
285117
285116
|
const overrideContent = `[Service]
|
|
285118
285117
|
Environment="OLLAMA_NUM_PARALLEL=${n2}"
|
|
285119
285118
|
`;
|
|
285120
|
-
|
|
285121
|
-
|
|
285122
|
-
|
|
285123
|
-
|
|
285119
|
+
execSync37(`sudo mkdir -p ${overrideDir}`, { stdio: "pipe" });
|
|
285120
|
+
execSync37(`echo '${overrideContent}' | sudo tee ${overrideFile} > /dev/null`, { stdio: "pipe" });
|
|
285121
|
+
execSync37("sudo systemctl daemon-reload", { stdio: "pipe" });
|
|
285122
|
+
execSync37("sudo systemctl restart ollama.service", { stdio: "pipe" });
|
|
285124
285123
|
let ready = false;
|
|
285125
285124
|
for (let i2 = 0; i2 < 30 && !ready; i2++) {
|
|
285126
285125
|
await new Promise((r2) => setTimeout(r2, 500));
|
|
@@ -285147,13 +285146,13 @@ Environment="OLLAMA_NUM_PARALLEL=${n2}"
|
|
|
285147
285146
|
renderInfo(`Setting OLLAMA_NUM_PARALLEL=${n2}...`);
|
|
285148
285147
|
try {
|
|
285149
285148
|
try {
|
|
285150
|
-
|
|
285149
|
+
execSync37("pkill -f 'ollama serve' 2>/dev/null || true", { stdio: "pipe" });
|
|
285151
285150
|
} catch {
|
|
285152
285151
|
}
|
|
285153
285152
|
await new Promise((r2) => setTimeout(r2, 1e3));
|
|
285154
285153
|
process.env.OLLAMA_NUM_PARALLEL = String(n2);
|
|
285155
|
-
const { spawn:
|
|
285156
|
-
const child =
|
|
285154
|
+
const { spawn: spawn24 } = await import("node:child_process");
|
|
285155
|
+
const child = spawn24("ollama", ["serve"], {
|
|
285157
285156
|
stdio: "ignore",
|
|
285158
285157
|
detached: true,
|
|
285159
285158
|
env: { ...process.env, OLLAMA_NUM_PARALLEL: String(n2) }
|
|
@@ -285200,17 +285199,17 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
285200
285199
|
try {
|
|
285201
285200
|
const { createRequire: createRequire7 } = await import("node:module");
|
|
285202
285201
|
const { fileURLToPath: fileURLToPath17 } = await import("node:url");
|
|
285203
|
-
const { dirname: dirname25, join:
|
|
285204
|
-
const { existsSync:
|
|
285202
|
+
const { dirname: dirname25, join: join83 } = await import("node:path");
|
|
285203
|
+
const { existsSync: existsSync62 } = await import("node:fs");
|
|
285205
285204
|
const req2 = createRequire7(import.meta.url);
|
|
285206
285205
|
const thisDir = dirname25(fileURLToPath17(import.meta.url));
|
|
285207
285206
|
const candidates = [
|
|
285208
|
-
|
|
285209
|
-
|
|
285210
|
-
|
|
285207
|
+
join83(thisDir, "..", "package.json"),
|
|
285208
|
+
join83(thisDir, "..", "..", "package.json"),
|
|
285209
|
+
join83(thisDir, "..", "..", "..", "package.json")
|
|
285211
285210
|
];
|
|
285212
285211
|
for (const pkgPath of candidates) {
|
|
285213
|
-
if (
|
|
285212
|
+
if (existsSync62(pkgPath)) {
|
|
285214
285213
|
const pkg = req2(pkgPath);
|
|
285215
285214
|
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli") {
|
|
285216
285215
|
currentVersion = pkg.version ?? "0.0.0";
|
|
@@ -285465,11 +285464,11 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
285465
285464
|
const targetVersion = info?.latestVersion ?? currentVersion;
|
|
285466
285465
|
const installOverlay = startInstallOverlay(targetVersion);
|
|
285467
285466
|
let installError = "";
|
|
285468
|
-
const runInstall2 = (cmd) => new Promise((
|
|
285467
|
+
const runInstall2 = (cmd) => new Promise((resolve38) => {
|
|
285469
285468
|
const child = exec4(cmd, { timeout: 18e4 }, (err, _stdout, stderr) => {
|
|
285470
285469
|
if (err)
|
|
285471
285470
|
installError = (stderr || err.message || "").trim();
|
|
285472
|
-
|
|
285471
|
+
resolve38(!err);
|
|
285473
285472
|
});
|
|
285474
285473
|
child.stdout?.on("data", (chunk) => {
|
|
285475
285474
|
const text = String(chunk);
|
|
@@ -285664,8 +285663,8 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
285664
285663
|
}
|
|
285665
285664
|
if (doRebuild) {
|
|
285666
285665
|
installOverlay.setStatus("Rebuilding native modules...");
|
|
285667
|
-
await new Promise((
|
|
285668
|
-
const child = exec4(`${sudoPrefix}npm rebuild -g open-agents-ai 2>/dev/null || true`, { timeout: 12e4 }, () =>
|
|
285666
|
+
await new Promise((resolve38) => {
|
|
285667
|
+
const child = exec4(`${sudoPrefix}npm rebuild -g open-agents-ai 2>/dev/null || true`, { timeout: 12e4 }, () => resolve38(true));
|
|
285669
285668
|
child.stdout?.resume();
|
|
285670
285669
|
child.stderr?.resume();
|
|
285671
285670
|
});
|
|
@@ -285697,8 +285696,8 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
285697
285696
|
const venvPip2 = isWin2 ? pathJoin(venvDir, "Scripts", "pip.exe") : pathJoin(venvDir, "bin", "pip");
|
|
285698
285697
|
if (fsExists(venvPip2)) {
|
|
285699
285698
|
installOverlay.setStatus("Upgrading Python packages...");
|
|
285700
|
-
await new Promise((
|
|
285701
|
-
const child = exec4(`"${venvPip2}" install --upgrade moondream-station pytesseract Pillow opencv-python-headless numpy 2>/dev/null || true`, { timeout: 3e5 }, (err) =>
|
|
285699
|
+
await new Promise((resolve38) => {
|
|
285700
|
+
const child = exec4(`"${venvPip2}" install --upgrade moondream-station pytesseract Pillow opencv-python-headless numpy 2>/dev/null || true`, { timeout: 3e5 }, (err) => resolve38(!err));
|
|
285702
285701
|
child.stdout?.resume();
|
|
285703
285702
|
child.stderr?.resume();
|
|
285704
285703
|
});
|
|
@@ -286090,16 +286089,16 @@ async function showExposeDashboard(gateway, rl, ctx3) {
|
|
|
286090
286089
|
renderDashboard();
|
|
286091
286090
|
}, 1e3);
|
|
286092
286091
|
let stopGateway = false;
|
|
286093
|
-
await new Promise((
|
|
286092
|
+
await new Promise((resolve38) => {
|
|
286094
286093
|
const onData = (data) => {
|
|
286095
286094
|
const key = data.toString();
|
|
286096
286095
|
if (key === "q" || key === "Q" || key === "\x1B" || key === "") {
|
|
286097
|
-
|
|
286096
|
+
resolve38();
|
|
286098
286097
|
return;
|
|
286099
286098
|
}
|
|
286100
286099
|
if (key === "s" || key === "S") {
|
|
286101
286100
|
stopGateway = true;
|
|
286102
|
-
|
|
286101
|
+
resolve38();
|
|
286103
286102
|
return;
|
|
286104
286103
|
}
|
|
286105
286104
|
if (key === "c" || key === "C") {
|
|
@@ -286108,18 +286107,18 @@ async function showExposeDashboard(gateway, rl, ctx3) {
|
|
|
286108
286107
|
const cmd = `/endpoint ${id} --auth ${gateway.authKey ?? ""}`;
|
|
286109
286108
|
let copied = false;
|
|
286110
286109
|
try {
|
|
286111
|
-
const { execSync:
|
|
286110
|
+
const { execSync: execSync37 } = __require("node:child_process");
|
|
286112
286111
|
const platform6 = process.platform;
|
|
286113
286112
|
if (platform6 === "darwin") {
|
|
286114
|
-
|
|
286113
|
+
execSync37("pbcopy", { input: cmd, timeout: 3e3 });
|
|
286115
286114
|
copied = true;
|
|
286116
286115
|
} else if (platform6 === "win32") {
|
|
286117
|
-
|
|
286116
|
+
execSync37("clip", { input: cmd, timeout: 3e3 });
|
|
286118
286117
|
copied = true;
|
|
286119
286118
|
} else {
|
|
286120
286119
|
for (const tool of ["xclip -selection clipboard", "xsel --clipboard --input", "wl-copy"]) {
|
|
286121
286120
|
try {
|
|
286122
|
-
|
|
286121
|
+
execSync37(tool, { input: cmd, timeout: 3e3, stdio: ["pipe", "pipe", "pipe"] });
|
|
286123
286122
|
copied = true;
|
|
286124
286123
|
break;
|
|
286125
286124
|
} catch {
|
|
@@ -286150,8 +286149,8 @@ async function showExposeDashboard(gateway, rl, ctx3) {
|
|
|
286150
286149
|
process.stdout.write("\x1B[?1002h\x1B[?1006h");
|
|
286151
286150
|
}
|
|
286152
286151
|
};
|
|
286153
|
-
const origResolve =
|
|
286154
|
-
|
|
286152
|
+
const origResolve = resolve38;
|
|
286153
|
+
resolve38 = (() => {
|
|
286155
286154
|
cleanup();
|
|
286156
286155
|
origResolve();
|
|
286157
286156
|
});
|
|
@@ -293789,8 +293788,8 @@ async function collectNetworkMetrics() {
|
|
|
293789
293788
|
}
|
|
293790
293789
|
if (plat === "darwin") {
|
|
293791
293790
|
try {
|
|
293792
|
-
const output = await new Promise((
|
|
293793
|
-
exec3("netstat -ib 2>/dev/null | head -30", { encoding: "utf8", timeout: 3e3 }, (err, stdout) => err ? reject(err) :
|
|
293791
|
+
const output = await new Promise((resolve38, reject) => {
|
|
293792
|
+
exec3("netstat -ib 2>/dev/null | head -30", { encoding: "utf8", timeout: 3e3 }, (err, stdout) => err ? reject(err) : resolve38(stdout));
|
|
293794
293793
|
});
|
|
293795
293794
|
let rxBytes = 0, txBytes = 0;
|
|
293796
293795
|
for (const line of output.split("\n")) {
|
|
@@ -293824,8 +293823,8 @@ async function collectGpuMetrics() {
|
|
|
293824
293823
|
if (_nvidiaSmiAvailable === false)
|
|
293825
293824
|
return noGpu;
|
|
293826
293825
|
try {
|
|
293827
|
-
const smi = await new Promise((
|
|
293828
|
-
exec3("nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total,name --format=csv,noheader,nounits 2>/dev/null", { encoding: "utf8", timeout: 3e3 }, (err, stdout) => err ? reject(err) :
|
|
293826
|
+
const smi = await new Promise((resolve38, reject) => {
|
|
293827
|
+
exec3("nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total,name --format=csv,noheader,nounits 2>/dev/null", { encoding: "utf8", timeout: 3e3 }, (err, stdout) => err ? reject(err) : resolve38(stdout));
|
|
293829
293828
|
});
|
|
293830
293829
|
_nvidiaSmiAvailable = true;
|
|
293831
293830
|
const line = smi.trim().split("\n")[0];
|
|
@@ -299125,7 +299124,7 @@ var init_profiles = __esm({
|
|
|
299125
299124
|
},
|
|
299126
299125
|
"cohere-mesh": {
|
|
299127
299126
|
name: "cohere-mesh",
|
|
299128
|
-
description: "COHERE mesh queries \u2014 web search/fetch only
|
|
299127
|
+
description: "COHERE mesh queries \u2014 Docker sandbox, web search/fetch only",
|
|
299129
299128
|
tools: {
|
|
299130
299129
|
allow: ["web_search", "web_fetch", "task_complete"],
|
|
299131
299130
|
deny: [
|
|
@@ -299149,6 +299148,7 @@ var init_profiles = __esm({
|
|
|
299149
299148
|
},
|
|
299150
299149
|
commands: { deny: ["destroy", "update", "sponsor", "expose", "quit"] },
|
|
299151
299150
|
limits: { max_turns: 8, timeout_s: 90 },
|
|
299151
|
+
sandbox: "container",
|
|
299152
299152
|
encrypted: false,
|
|
299153
299153
|
created: "2026-03-31T00:00:00Z"
|
|
299154
299154
|
}
|
|
@@ -299156,6 +299156,185 @@ var init_profiles = __esm({
|
|
|
299156
299156
|
}
|
|
299157
299157
|
});
|
|
299158
299158
|
|
|
299159
|
+
// packages/cli/dist/docker.js
|
|
299160
|
+
import { execSync as execSync35, spawn as spawn21 } from "node:child_process";
|
|
299161
|
+
import { existsSync as existsSync57, readFileSync as readFileSync46, mkdirSync as mkdirSync30, writeFileSync as writeFileSync28 } from "node:fs";
|
|
299162
|
+
import { join as join75, resolve as resolve32 } from "node:path";
|
|
299163
|
+
import { homedir as homedir20 } from "node:os";
|
|
299164
|
+
function isDockerAvailable() {
|
|
299165
|
+
try {
|
|
299166
|
+
execSync35("docker info", { stdio: "pipe", timeout: 1e4 });
|
|
299167
|
+
return true;
|
|
299168
|
+
} catch {
|
|
299169
|
+
return false;
|
|
299170
|
+
}
|
|
299171
|
+
}
|
|
299172
|
+
function isOaImageBuilt() {
|
|
299173
|
+
try {
|
|
299174
|
+
const out = execSync35(`docker images -q ${OA_IMAGE}:${OA_IMAGE_TAG}`, {
|
|
299175
|
+
stdio: "pipe",
|
|
299176
|
+
timeout: 5e3
|
|
299177
|
+
}).toString().trim();
|
|
299178
|
+
return out.length > 0;
|
|
299179
|
+
} catch {
|
|
299180
|
+
return false;
|
|
299181
|
+
}
|
|
299182
|
+
}
|
|
299183
|
+
async function ensureOaImage(force = false) {
|
|
299184
|
+
if (!force && isOaImageBuilt()) {
|
|
299185
|
+
return { ok: true, message: `Image ${OA_IMAGE}:${OA_IMAGE_TAG} already exists` };
|
|
299186
|
+
}
|
|
299187
|
+
let buildContext;
|
|
299188
|
+
if (existsSync57(join75(DOCKER_DIR, "Dockerfile"))) {
|
|
299189
|
+
buildContext = DOCKER_DIR;
|
|
299190
|
+
} else {
|
|
299191
|
+
buildContext = join75(homedir20(), ".oa", "docker-build");
|
|
299192
|
+
mkdirSync30(buildContext, { recursive: true });
|
|
299193
|
+
writeDockerfiles(buildContext);
|
|
299194
|
+
}
|
|
299195
|
+
try {
|
|
299196
|
+
console.log(`[oa-docker] Building image ${OA_IMAGE}:${OA_IMAGE_TAG}...`);
|
|
299197
|
+
execSync35(`docker build -t ${OA_IMAGE}:${OA_IMAGE_TAG} ${buildContext}`, {
|
|
299198
|
+
stdio: "inherit",
|
|
299199
|
+
timeout: 6e5
|
|
299200
|
+
// 10 min
|
|
299201
|
+
});
|
|
299202
|
+
return { ok: true, message: `Image ${OA_IMAGE}:${OA_IMAGE_TAG} built successfully` };
|
|
299203
|
+
} catch (err) {
|
|
299204
|
+
return {
|
|
299205
|
+
ok: false,
|
|
299206
|
+
message: `Image build failed: ${err instanceof Error ? err.message : String(err)}`
|
|
299207
|
+
};
|
|
299208
|
+
}
|
|
299209
|
+
}
|
|
299210
|
+
function writeDockerfiles(dir) {
|
|
299211
|
+
const dockerfile = `FROM node:22-slim
|
|
299212
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \\
|
|
299213
|
+
curl ca-certificates git openssh-server sudo ripgrep procps python3 \\
|
|
299214
|
+
&& rm -rf /var/lib/apt/lists/* && apt-get clean
|
|
299215
|
+
RUN mkdir -p /var/run/sshd && ssh-keygen -A \\
|
|
299216
|
+
&& sed -i 's/#PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config \\
|
|
299217
|
+
&& sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config \\
|
|
299218
|
+
&& echo "AllowUsers node" >> /etc/ssh/sshd_config
|
|
299219
|
+
RUN npm install -g open-agents-ai@latest
|
|
299220
|
+
RUN mkdir -p /workspace && chown node:node /workspace \\
|
|
299221
|
+
&& mkdir -p /home/node/.oa /home/node/.open-agents \\
|
|
299222
|
+
&& chown -R node:node /home/node/.oa /home/node/.open-agents /home/node
|
|
299223
|
+
RUN echo "node ALL=(ALL) NOPASSWD: /usr/bin/npm, /usr/bin/node, /usr/bin/apt-get" > /etc/sudoers.d/node \\
|
|
299224
|
+
&& chmod 440 /etc/sudoers.d/node
|
|
299225
|
+
COPY docker-entrypoint.sh /usr/local/bin/
|
|
299226
|
+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
299227
|
+
ENV OPEN_AGENTS_BACKEND_TYPE=ollama NODE_ENV=production
|
|
299228
|
+
EXPOSE 22
|
|
299229
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \\
|
|
299230
|
+
CMD pgrep sshd > /dev/null || exit 1
|
|
299231
|
+
ENTRYPOINT ["docker-entrypoint.sh"]
|
|
299232
|
+
CMD ["sshd", "-D", "-e"]
|
|
299233
|
+
`;
|
|
299234
|
+
const entrypoint = `#!/bin/bash
|
|
299235
|
+
set -e
|
|
299236
|
+
if [ -n "$SSH_PASSWORD" ]; then
|
|
299237
|
+
echo "node:\${SSH_PASSWORD}" | chpasswd
|
|
299238
|
+
else
|
|
299239
|
+
SSH_PASSWORD=$(head -c 16 /dev/urandom | base64)
|
|
299240
|
+
echo "node:\${SSH_PASSWORD}" | chpasswd
|
|
299241
|
+
echo "[oa-docker] Generated SSH password: \${SSH_PASSWORD}"
|
|
299242
|
+
fi
|
|
299243
|
+
if [ -n "$SSH_PUBLIC_KEY" ]; then
|
|
299244
|
+
mkdir -p /home/node/.ssh
|
|
299245
|
+
echo "$SSH_PUBLIC_KEY" > /home/node/.ssh/authorized_keys
|
|
299246
|
+
chmod 700 /home/node/.ssh && chmod 600 /home/node/.ssh/authorized_keys
|
|
299247
|
+
chown -R node:node /home/node/.ssh
|
|
299248
|
+
fi
|
|
299249
|
+
if [ -z "$OLLAMA_HOST" ] && [ "\${OPEN_AGENTS_BACKEND_TYPE}" = "ollama" ]; then
|
|
299250
|
+
export OLLAMA_HOST="http://host.docker.internal:11434"
|
|
299251
|
+
fi
|
|
299252
|
+
OA_CONFIG="/home/node/.open-agents/config.json"
|
|
299253
|
+
mkdir -p /home/node/.open-agents
|
|
299254
|
+
cat > "$OA_CONFIG" <<EOCFG
|
|
299255
|
+
{
|
|
299256
|
+
"backendType": "\${OPEN_AGENTS_BACKEND_TYPE:-ollama}",
|
|
299257
|
+
"backendUrl": "\${OLLAMA_HOST:-http://host.docker.internal:11434}",
|
|
299258
|
+
"model": "\${OPEN_AGENTS_MODEL:-qwen3:4b}"
|
|
299259
|
+
}
|
|
299260
|
+
EOCFG
|
|
299261
|
+
chown node:node "$OA_CONFIG"
|
|
299262
|
+
chown -R node:node /workspace /home/node/.oa /home/node/.open-agents 2>/dev/null || true
|
|
299263
|
+
if [ "$1" = "oa" ]; then shift; exec su - node -c "cd /workspace && oa $*"; fi
|
|
299264
|
+
exec "$@"
|
|
299265
|
+
`;
|
|
299266
|
+
writeFileSync28(join75(dir, "Dockerfile"), dockerfile);
|
|
299267
|
+
writeFileSync28(join75(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
|
|
299268
|
+
}
|
|
299269
|
+
function hasNvidiaGpu() {
|
|
299270
|
+
try {
|
|
299271
|
+
execSync35("nvidia-smi --query-gpu=name --format=csv,noheader", {
|
|
299272
|
+
stdio: "pipe",
|
|
299273
|
+
timeout: 5e3
|
|
299274
|
+
});
|
|
299275
|
+
const runtimes = execSync35("docker info --format '{{json .Runtimes}}'", {
|
|
299276
|
+
stdio: "pipe",
|
|
299277
|
+
timeout: 5e3
|
|
299278
|
+
}).toString();
|
|
299279
|
+
return runtimes.includes("nvidia");
|
|
299280
|
+
} catch {
|
|
299281
|
+
return false;
|
|
299282
|
+
}
|
|
299283
|
+
}
|
|
299284
|
+
function runInContainer(opts) {
|
|
299285
|
+
const args = ["run", "--rm"];
|
|
299286
|
+
if (opts.name) {
|
|
299287
|
+
args.push("--name", opts.name);
|
|
299288
|
+
}
|
|
299289
|
+
args.push("--add-host", "host.docker.internal:host-gateway");
|
|
299290
|
+
if (opts.gpu && hasNvidiaGpu()) {
|
|
299291
|
+
args.push("--gpus", "all");
|
|
299292
|
+
}
|
|
299293
|
+
args.push("--memory", "4g");
|
|
299294
|
+
args.push("--cpus", "2");
|
|
299295
|
+
const timeout2 = (opts.timeoutS || 120) + 30;
|
|
299296
|
+
args.push("--stop-timeout", String(timeout2));
|
|
299297
|
+
if (opts.workingDir) {
|
|
299298
|
+
const hostDir = resolve32(opts.workingDir);
|
|
299299
|
+
args.push("-v", `${hostDir}:/workspace`);
|
|
299300
|
+
}
|
|
299301
|
+
const ollamaHost = opts.ollamaHost || process.env["OLLAMA_HOST"] || "http://host.docker.internal:11434";
|
|
299302
|
+
args.push("-e", `OLLAMA_HOST=${ollamaHost}`);
|
|
299303
|
+
args.push("-e", "OPEN_AGENTS_BACKEND_TYPE=ollama");
|
|
299304
|
+
if (opts.model) {
|
|
299305
|
+
args.push("-e", `OPEN_AGENTS_MODEL=${opts.model}`);
|
|
299306
|
+
}
|
|
299307
|
+
if (opts.env) {
|
|
299308
|
+
for (const [k, v] of Object.entries(opts.env)) {
|
|
299309
|
+
if (k.startsWith("OA_") || k === "OLLAMA_HOST" || k === "OPENAI_API_KEY") {
|
|
299310
|
+
args.push("-e", `${k}=${v}`);
|
|
299311
|
+
}
|
|
299312
|
+
}
|
|
299313
|
+
}
|
|
299314
|
+
args.push(`${OA_IMAGE}:${OA_IMAGE_TAG}`);
|
|
299315
|
+
args.push("oa");
|
|
299316
|
+
const oaArgs = [opts.task, "--json"];
|
|
299317
|
+
if (opts.model)
|
|
299318
|
+
oaArgs.push("--model", opts.model);
|
|
299319
|
+
if (opts.maxTurns)
|
|
299320
|
+
oaArgs.push("--max-turns", String(opts.maxTurns));
|
|
299321
|
+
if (opts.timeoutS)
|
|
299322
|
+
oaArgs.push("--timeout", String(opts.timeoutS));
|
|
299323
|
+
args.push(...oaArgs);
|
|
299324
|
+
return spawn21("docker", args, {
|
|
299325
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
299326
|
+
});
|
|
299327
|
+
}
|
|
299328
|
+
var OA_IMAGE, OA_IMAGE_TAG, DOCKER_DIR;
|
|
299329
|
+
var init_docker = __esm({
|
|
299330
|
+
"packages/cli/dist/docker.js"() {
|
|
299331
|
+
"use strict";
|
|
299332
|
+
OA_IMAGE = "open-agents";
|
|
299333
|
+
OA_IMAGE_TAG = "latest";
|
|
299334
|
+
DOCKER_DIR = join75(__dirname, "..", "..", "..", "docker");
|
|
299335
|
+
}
|
|
299336
|
+
});
|
|
299337
|
+
|
|
299159
299338
|
// packages/cli/dist/api/serve.js
|
|
299160
299339
|
var serve_exports = {};
|
|
299161
299340
|
__export(serve_exports, {
|
|
@@ -299166,22 +299345,22 @@ import * as http5 from "node:http";
|
|
|
299166
299345
|
import * as https3 from "node:https";
|
|
299167
299346
|
import { createRequire as createRequire4 } from "node:module";
|
|
299168
299347
|
import { fileURLToPath as fileURLToPath14 } from "node:url";
|
|
299169
|
-
import { dirname as dirname22, join as
|
|
299170
|
-
import { spawn as
|
|
299171
|
-
import { mkdirSync as
|
|
299348
|
+
import { dirname as dirname22, join as join76, resolve as resolve33 } from "node:path";
|
|
299349
|
+
import { spawn as spawn22 } from "node:child_process";
|
|
299350
|
+
import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync29, readFileSync as readFileSync47, readdirSync as readdirSync22, existsSync as existsSync58 } from "node:fs";
|
|
299172
299351
|
import { randomBytes as randomBytes19, randomUUID as randomUUID5 } from "node:crypto";
|
|
299173
299352
|
function getVersion3() {
|
|
299174
299353
|
try {
|
|
299175
299354
|
const require3 = createRequire4(import.meta.url);
|
|
299176
299355
|
const thisDir = dirname22(fileURLToPath14(import.meta.url));
|
|
299177
299356
|
const candidates = [
|
|
299178
|
-
|
|
299179
|
-
|
|
299180
|
-
|
|
299357
|
+
join76(thisDir, "..", "package.json"),
|
|
299358
|
+
join76(thisDir, "..", "..", "package.json"),
|
|
299359
|
+
join76(thisDir, "..", "..", "..", "package.json")
|
|
299181
299360
|
];
|
|
299182
299361
|
for (const pkgPath of candidates) {
|
|
299183
299362
|
try {
|
|
299184
|
-
if (!
|
|
299363
|
+
if (!existsSync58(pkgPath))
|
|
299185
299364
|
continue;
|
|
299186
299365
|
const pkg = require3(pkgPath);
|
|
299187
299366
|
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli" || pkg.name === "@open-agents/monorepo") {
|
|
@@ -299393,10 +299572,10 @@ function corsHeaders(req2, res) {
|
|
|
299393
299572
|
return true;
|
|
299394
299573
|
}
|
|
299395
299574
|
function readBody(req2) {
|
|
299396
|
-
return new Promise((
|
|
299575
|
+
return new Promise((resolve38, reject) => {
|
|
299397
299576
|
const chunks = [];
|
|
299398
299577
|
req2.on("data", (chunk) => chunks.push(chunk));
|
|
299399
|
-
req2.on("end", () =>
|
|
299578
|
+
req2.on("end", () => resolve38(Buffer.concat(chunks).toString("utf-8")));
|
|
299400
299579
|
req2.on("error", reject);
|
|
299401
299580
|
});
|
|
299402
299581
|
}
|
|
@@ -299417,7 +299596,7 @@ function backendAuthHeaders(endpoint) {
|
|
|
299417
299596
|
return {};
|
|
299418
299597
|
}
|
|
299419
299598
|
function ollamaRequest(ollamaUrl, path5, method, body) {
|
|
299420
|
-
return new Promise((
|
|
299599
|
+
return new Promise((resolve38, reject) => {
|
|
299421
299600
|
const url = new URL(path5, ollamaUrl);
|
|
299422
299601
|
const isHttps = url.protocol === "https:";
|
|
299423
299602
|
const options2 = {
|
|
@@ -299436,7 +299615,7 @@ function ollamaRequest(ollamaUrl, path5, method, body) {
|
|
|
299436
299615
|
const chunks = [];
|
|
299437
299616
|
proxyRes.on("data", (chunk) => chunks.push(chunk));
|
|
299438
299617
|
proxyRes.on("end", () => {
|
|
299439
|
-
|
|
299618
|
+
resolve38({
|
|
299440
299619
|
status: proxyRes.statusCode ?? 500,
|
|
299441
299620
|
headers: proxyRes.headers,
|
|
299442
299621
|
body: Buffer.concat(chunks).toString("utf-8")
|
|
@@ -299481,30 +299660,30 @@ function ollamaStream(ollamaUrl, path5, method, body, onData, onEnd, onError) {
|
|
|
299481
299660
|
proxyReq.end();
|
|
299482
299661
|
}
|
|
299483
299662
|
function jobsDir() {
|
|
299484
|
-
const root =
|
|
299485
|
-
const dir =
|
|
299486
|
-
|
|
299663
|
+
const root = resolve33(process.cwd());
|
|
299664
|
+
const dir = join76(root, ".oa", "jobs");
|
|
299665
|
+
mkdirSync31(dir, { recursive: true });
|
|
299487
299666
|
return dir;
|
|
299488
299667
|
}
|
|
299489
299668
|
function loadJob(id) {
|
|
299490
|
-
const file =
|
|
299491
|
-
if (!
|
|
299669
|
+
const file = join76(jobsDir(), `${id}.json`);
|
|
299670
|
+
if (!existsSync58(file))
|
|
299492
299671
|
return null;
|
|
299493
299672
|
try {
|
|
299494
|
-
return JSON.parse(
|
|
299673
|
+
return JSON.parse(readFileSync47(file, "utf-8"));
|
|
299495
299674
|
} catch {
|
|
299496
299675
|
return null;
|
|
299497
299676
|
}
|
|
299498
299677
|
}
|
|
299499
299678
|
function listJobs() {
|
|
299500
299679
|
const dir = jobsDir();
|
|
299501
|
-
if (!
|
|
299680
|
+
if (!existsSync58(dir))
|
|
299502
299681
|
return [];
|
|
299503
299682
|
const files = readdirSync22(dir).filter((f2) => f2.endsWith(".json")).sort();
|
|
299504
299683
|
const jobs = [];
|
|
299505
299684
|
for (const file of files) {
|
|
299506
299685
|
try {
|
|
299507
|
-
jobs.push(JSON.parse(
|
|
299686
|
+
jobs.push(JSON.parse(readFileSync47(join76(dir, file), "utf-8")));
|
|
299508
299687
|
} catch {
|
|
299509
299688
|
}
|
|
299510
299689
|
}
|
|
@@ -299934,13 +300113,26 @@ async function handleV1Run(req2, res) {
|
|
|
299934
300113
|
jsonResponse(res, 400, { error: "Task too long", message: "Max 50,000 characters", length: task.length });
|
|
299935
300114
|
return;
|
|
299936
300115
|
}
|
|
299937
|
-
const
|
|
300116
|
+
const profileName = requestBody["profile"] || req2.headers["x-tool-profile"] || void 0;
|
|
300117
|
+
let activeProfile = null;
|
|
300118
|
+
if (profileName) {
|
|
300119
|
+
const profilePassword = req2.headers["x-profile-password"];
|
|
300120
|
+
activeProfile = PRESET_PROFILES[profileName] || loadProfile(profileName, profilePassword);
|
|
300121
|
+
if (!activeProfile) {
|
|
300122
|
+
jsonResponse(res, 400, { error: "Profile not found or wrong password", profile: profileName });
|
|
300123
|
+
return;
|
|
300124
|
+
}
|
|
300125
|
+
}
|
|
300126
|
+
const sandbox = requestBody["sandbox"] || activeProfile?.sandbox || process.env["OA_DEFAULT_SANDBOX"] || "none";
|
|
299938
300127
|
if (sandbox === "container") {
|
|
299939
|
-
|
|
299940
|
-
|
|
299941
|
-
|
|
299942
|
-
}
|
|
299943
|
-
|
|
300128
|
+
if (!isDockerAvailable()) {
|
|
300129
|
+
jsonResponse(res, 400, { error: "Container sandbox unavailable", message: "Docker not found or daemon not running. Install Docker or use sandbox:'none'." });
|
|
300130
|
+
return;
|
|
300131
|
+
}
|
|
300132
|
+
if (!isOaImageBuilt()) {
|
|
300133
|
+
ensureOaImage().catch(() => {
|
|
300134
|
+
});
|
|
300135
|
+
jsonResponse(res, 503, { error: "Container image not ready", message: "Building open-agents Docker image. Retry in ~2 minutes." });
|
|
299944
300136
|
return;
|
|
299945
300137
|
}
|
|
299946
300138
|
}
|
|
@@ -299950,13 +300142,13 @@ async function handleV1Run(req2, res) {
|
|
|
299950
300142
|
const isolate = requestBody["isolate"] === true;
|
|
299951
300143
|
let cwd4;
|
|
299952
300144
|
if (workingDir) {
|
|
299953
|
-
cwd4 =
|
|
300145
|
+
cwd4 = resolve33(workingDir);
|
|
299954
300146
|
} else if (isolate) {
|
|
299955
|
-
const wsDir =
|
|
299956
|
-
|
|
300147
|
+
const wsDir = join76(dir, "..", "workspaces", id);
|
|
300148
|
+
mkdirSync31(wsDir, { recursive: true });
|
|
299957
300149
|
cwd4 = wsDir;
|
|
299958
300150
|
} else {
|
|
299959
|
-
cwd4 =
|
|
300151
|
+
cwd4 = resolve33(process.cwd());
|
|
299960
300152
|
}
|
|
299961
300153
|
const authUser = req2._authUser || "anonymous";
|
|
299962
300154
|
const authScope = req2._authScope || "admin";
|
|
@@ -299982,15 +300174,7 @@ async function handleV1Run(req2, res) {
|
|
|
299982
300174
|
const timeout2 = requestBody["timeout_s"];
|
|
299983
300175
|
if (timeout2 && timeout2 > 0)
|
|
299984
300176
|
args.push("--timeout", String(timeout2));
|
|
299985
|
-
|
|
299986
|
-
let activeProfile = null;
|
|
299987
|
-
if (profileName) {
|
|
299988
|
-
const profilePassword = req2.headers["x-profile-password"];
|
|
299989
|
-
activeProfile = PRESET_PROFILES[profileName] || loadProfile(profileName, profilePassword);
|
|
299990
|
-
if (!activeProfile) {
|
|
299991
|
-
jsonResponse(res, 400, { error: "Profile not found or wrong password", profile: profileName });
|
|
299992
|
-
return;
|
|
299993
|
-
}
|
|
300177
|
+
if (activeProfile) {
|
|
299994
300178
|
if (activeProfile.limits.max_turns && !requestBody["max_turns"]) {
|
|
299995
300179
|
args.push("--max-turns", String(activeProfile.limits.max_turns));
|
|
299996
300180
|
}
|
|
@@ -300022,15 +300206,34 @@ async function handleV1Run(req2, res) {
|
|
|
300022
300206
|
}
|
|
300023
300207
|
}
|
|
300024
300208
|
}
|
|
300025
|
-
|
|
300026
|
-
|
|
300027
|
-
|
|
300028
|
-
|
|
300029
|
-
|
|
300030
|
-
|
|
300031
|
-
|
|
300209
|
+
let child;
|
|
300210
|
+
if (sandbox === "container") {
|
|
300211
|
+
const gpuEnabled = requestBody["gpu"] === true || hasNvidiaGpu();
|
|
300212
|
+
child = runInContainer({
|
|
300213
|
+
task,
|
|
300214
|
+
model: modelArg,
|
|
300215
|
+
maxTurns,
|
|
300216
|
+
timeoutS: timeout2,
|
|
300217
|
+
workingDir: workingDir || void 0,
|
|
300218
|
+
env: runEnv,
|
|
300219
|
+
profile: profileName,
|
|
300220
|
+
gpu: gpuEnabled,
|
|
300221
|
+
name: `oa-${id}`,
|
|
300222
|
+
ollamaHost: runEnv["OLLAMA_HOST"]
|
|
300223
|
+
});
|
|
300224
|
+
job.sandbox = "container";
|
|
300225
|
+
} else {
|
|
300226
|
+
child = spawn22(process.execPath, [oaBin, ...args], {
|
|
300227
|
+
cwd: cwd4,
|
|
300228
|
+
env: runEnv,
|
|
300229
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
300230
|
+
detached: true
|
|
300231
|
+
});
|
|
300232
|
+
child.unref();
|
|
300233
|
+
job.sandbox = sandbox;
|
|
300234
|
+
}
|
|
300032
300235
|
job.pid = child.pid ?? 0;
|
|
300033
|
-
|
|
300236
|
+
writeFileSync29(join76(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
300034
300237
|
runningProcesses.set(id, child);
|
|
300035
300238
|
if (streamMode) {
|
|
300036
300239
|
res.writeHead(200, {
|
|
@@ -300057,7 +300260,7 @@ async function handleV1Run(req2, res) {
|
|
|
300057
300260
|
job.status = code8 === 0 ? "completed" : "failed";
|
|
300058
300261
|
job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
300059
300262
|
try {
|
|
300060
|
-
|
|
300263
|
+
writeFileSync29(join76(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
300061
300264
|
} catch {
|
|
300062
300265
|
}
|
|
300063
300266
|
runningProcesses.delete(id);
|
|
@@ -300077,7 +300280,15 @@ async function handleV1Run(req2, res) {
|
|
|
300077
300280
|
});
|
|
300078
300281
|
child.on("exit", (code8) => {
|
|
300079
300282
|
try {
|
|
300080
|
-
const
|
|
300283
|
+
const lines = output.trim().split("\n");
|
|
300284
|
+
let finalJson = "";
|
|
300285
|
+
for (let i2 = lines.length - 1; i2 >= 0; i2--) {
|
|
300286
|
+
if (lines[i2].trimEnd() === "{" || lines[i2].startsWith("{") && !lines[i2].startsWith('{"type":"tool_call"')) {
|
|
300287
|
+
finalJson = lines.slice(i2).join("\n");
|
|
300288
|
+
break;
|
|
300289
|
+
}
|
|
300290
|
+
}
|
|
300291
|
+
const result = finalJson ? JSON.parse(finalJson) : { status: code8 === 0 ? "completed" : "failed" };
|
|
300081
300292
|
job.status = result["status"] === "completed" ? "completed" : code8 === 0 ? "completed" : "failed";
|
|
300082
300293
|
job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
300083
300294
|
job.summary = result["summary"];
|
|
@@ -300089,7 +300300,7 @@ async function handleV1Run(req2, res) {
|
|
|
300089
300300
|
job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
300090
300301
|
}
|
|
300091
300302
|
try {
|
|
300092
|
-
|
|
300303
|
+
writeFileSync29(join76(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
300093
300304
|
} catch {
|
|
300094
300305
|
}
|
|
300095
300306
|
runningProcesses.delete(id);
|
|
@@ -300138,7 +300349,7 @@ function handleV1RunsDelete(res, id) {
|
|
|
300138
300349
|
job.error = "Aborted via API";
|
|
300139
300350
|
const dir = jobsDir();
|
|
300140
300351
|
try {
|
|
300141
|
-
|
|
300352
|
+
writeFileSync29(join76(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
300142
300353
|
} catch {
|
|
300143
300354
|
}
|
|
300144
300355
|
runningProcesses.delete(id);
|
|
@@ -300250,7 +300461,7 @@ async function handlePostCommand(res, cmd) {
|
|
|
300250
300461
|
return;
|
|
300251
300462
|
}
|
|
300252
300463
|
try {
|
|
300253
|
-
const child =
|
|
300464
|
+
const child = spawn22("node", [oaBin, "run", `/${cmd}`, "--json"], {
|
|
300254
300465
|
env: { ...process.env, __OPEN_AGENTS_NO_AUTO_RUN: "" },
|
|
300255
300466
|
stdio: ["ignore", "pipe", "pipe"],
|
|
300256
300467
|
timeout: 3e4
|
|
@@ -300263,9 +300474,9 @@ async function handlePostCommand(res, cmd) {
|
|
|
300263
300474
|
child.stderr?.on("data", (chunk) => {
|
|
300264
300475
|
stderr += chunk.toString();
|
|
300265
300476
|
});
|
|
300266
|
-
await new Promise((
|
|
300267
|
-
child.on("exit", () =>
|
|
300268
|
-
child.on("error", () =>
|
|
300477
|
+
await new Promise((resolve38) => {
|
|
300478
|
+
child.on("exit", () => resolve38());
|
|
300479
|
+
child.on("error", () => resolve38());
|
|
300269
300480
|
});
|
|
300270
300481
|
jsonResponse(res, 200, {
|
|
300271
300482
|
command: cmd,
|
|
@@ -300361,8 +300572,8 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
300361
300572
|
if (pathname === "/v1/files" && method === "GET") {
|
|
300362
300573
|
const dir = urlObj.searchParams.get("path") || process.cwd();
|
|
300363
300574
|
try {
|
|
300364
|
-
const entries = readdirSync22(
|
|
300365
|
-
jsonResponse(res, 200, { path:
|
|
300575
|
+
const entries = readdirSync22(resolve33(dir), { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".") && e2.name !== "node_modules").slice(0, 100).map((e2) => ({ name: e2.name, type: e2.isDirectory() ? "dir" : "file" }));
|
|
300576
|
+
jsonResponse(res, 200, { path: resolve33(dir), entries });
|
|
300366
300577
|
} catch (e2) {
|
|
300367
300578
|
jsonResponse(res, 400, { error: e2.message });
|
|
300368
300579
|
}
|
|
@@ -300436,7 +300647,7 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
300436
300647
|
}
|
|
300437
300648
|
const sessionId = chatBody.session_id;
|
|
300438
300649
|
const model = chatBody.model || loadConfig().model;
|
|
300439
|
-
const cwdPath =
|
|
300650
|
+
const cwdPath = resolve33(process.cwd());
|
|
300440
300651
|
const session = getSession(sessionId, model, cwdPath);
|
|
300441
300652
|
addUserMessage(session, chatBody.message);
|
|
300442
300653
|
compactSession(session);
|
|
@@ -300460,7 +300671,7 @@ ${historyLines}
|
|
|
300460
300671
|
};
|
|
300461
300672
|
if (currentCfg.apiKey)
|
|
300462
300673
|
runEnv["OA_API_KEY_INHERIT"] = currentCfg.apiKey;
|
|
300463
|
-
const child =
|
|
300674
|
+
const child = spawn22(process.execPath, [oaBin, ...args], {
|
|
300464
300675
|
cwd: cwdPath,
|
|
300465
300676
|
env: runEnv,
|
|
300466
300677
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -300502,7 +300713,7 @@ ${historyLines}
|
|
|
300502
300713
|
});
|
|
300503
300714
|
child.stderr?.on("data", () => {
|
|
300504
300715
|
});
|
|
300505
|
-
await new Promise((
|
|
300716
|
+
await new Promise((resolve38) => {
|
|
300506
300717
|
child.on("close", () => {
|
|
300507
300718
|
if (lineBuffer.trim())
|
|
300508
300719
|
finalLines.push(lineBuffer);
|
|
@@ -300549,7 +300760,7 @@ ${historyLines}
|
|
|
300549
300760
|
addAssistantMessage(session, fullContent);
|
|
300550
300761
|
res.write("data: [DONE]\n\n");
|
|
300551
300762
|
res.end();
|
|
300552
|
-
|
|
300763
|
+
resolve38();
|
|
300553
300764
|
});
|
|
300554
300765
|
});
|
|
300555
300766
|
return;
|
|
@@ -300575,7 +300786,7 @@ ${historyLines}
|
|
|
300575
300786
|
});
|
|
300576
300787
|
child.stderr?.on("data", () => {
|
|
300577
300788
|
});
|
|
300578
|
-
await new Promise((
|
|
300789
|
+
await new Promise((resolve38) => child.on("close", resolve38));
|
|
300579
300790
|
if (nonStreamBuf.trim())
|
|
300580
300791
|
nonStreamLines.push(nonStreamBuf);
|
|
300581
300792
|
const rawNonStream = nonStreamLines.join("\n").trim();
|
|
@@ -300831,20 +301042,20 @@ function startApiServer(options2 = {}) {
|
|
|
300831
301042
|
const config = loadConfig();
|
|
300832
301043
|
const ollamaUrl = options2.ollamaUrl ?? config.backendUrl;
|
|
300833
301044
|
const cwd4 = process.cwd();
|
|
300834
|
-
initAuditLog(
|
|
300835
|
-
initUsageTracker(
|
|
301045
|
+
initAuditLog(join76(cwd4, ".oa"));
|
|
301046
|
+
initUsageTracker(join76(cwd4, ".oa"));
|
|
300836
301047
|
const retentionDays = parseInt(process.env["OA_JOB_RETENTION_DAYS"] ?? "30", 10);
|
|
300837
301048
|
if (retentionDays > 0) {
|
|
300838
301049
|
try {
|
|
300839
|
-
const jobsDir3 =
|
|
300840
|
-
if (
|
|
301050
|
+
const jobsDir3 = join76(cwd4, ".oa", "jobs");
|
|
301051
|
+
if (existsSync58(jobsDir3)) {
|
|
300841
301052
|
const cutoff = Date.now() - retentionDays * 864e5;
|
|
300842
301053
|
for (const f2 of readdirSync22(jobsDir3)) {
|
|
300843
301054
|
if (!f2.endsWith(".json"))
|
|
300844
301055
|
continue;
|
|
300845
301056
|
try {
|
|
300846
|
-
const jobPath =
|
|
300847
|
-
const job = JSON.parse(
|
|
301057
|
+
const jobPath = join76(jobsDir3, f2);
|
|
301058
|
+
const job = JSON.parse(readFileSync47(jobPath, "utf-8"));
|
|
300848
301059
|
const jobTime = new Date(job.startedAt ?? job.completedAt ?? 0).getTime();
|
|
300849
301060
|
if (jobTime > 0 && jobTime < cutoff && job.status !== "running") {
|
|
300850
301061
|
const { unlinkSync: unlinkSync13 } = __require("node:fs");
|
|
@@ -300864,8 +301075,8 @@ function startApiServer(options2 = {}) {
|
|
|
300864
301075
|
if (useTls) {
|
|
300865
301076
|
try {
|
|
300866
301077
|
tlsOpts = {
|
|
300867
|
-
cert:
|
|
300868
|
-
key:
|
|
301078
|
+
cert: readFileSync47(resolve33(tlsCert)),
|
|
301079
|
+
key: readFileSync47(resolve33(tlsKey))
|
|
300869
301080
|
};
|
|
300870
301081
|
} catch (e2) {
|
|
300871
301082
|
log22(`
|
|
@@ -301001,8 +301212,8 @@ async function apiServeCommand(opts, config) {
|
|
|
301001
301212
|
verbose: opts.verbose,
|
|
301002
301213
|
ollamaUrl: config.backendUrl
|
|
301003
301214
|
});
|
|
301004
|
-
await new Promise((
|
|
301005
|
-
server.on("close",
|
|
301215
|
+
await new Promise((resolve38) => {
|
|
301216
|
+
server.on("close", resolve38);
|
|
301006
301217
|
});
|
|
301007
301218
|
}
|
|
301008
301219
|
var endpointRegistry, modelRouteMap, endpointUsage, metrics, startedAt, _corsOrigins, _corsLocalOnly, runningProcesses, perKeyUsage;
|
|
@@ -301020,6 +301231,7 @@ var init_serve = __esm({
|
|
|
301020
301231
|
init_oa_directory();
|
|
301021
301232
|
init_render();
|
|
301022
301233
|
init_profiles();
|
|
301234
|
+
init_docker();
|
|
301023
301235
|
endpointRegistry = [];
|
|
301024
301236
|
modelRouteMap = /* @__PURE__ */ new Map();
|
|
301025
301237
|
endpointUsage = /* @__PURE__ */ new Map();
|
|
@@ -301039,13 +301251,13 @@ var init_serve = __esm({
|
|
|
301039
301251
|
|
|
301040
301252
|
// packages/cli/dist/tui/interactive.js
|
|
301041
301253
|
import { cwd } from "node:process";
|
|
301042
|
-
import { resolve as
|
|
301254
|
+
import { resolve as resolve34, join as join77, dirname as dirname23, extname as extname11 } from "node:path";
|
|
301043
301255
|
import { createRequire as createRequire5 } from "node:module";
|
|
301044
301256
|
import { fileURLToPath as fileURLToPath15 } from "node:url";
|
|
301045
|
-
import { readFileSync as
|
|
301046
|
-
import { existsSync as
|
|
301047
|
-
import { execSync as
|
|
301048
|
-
import { homedir as
|
|
301257
|
+
import { readFileSync as readFileSync48, writeFileSync as writeFileSync30, appendFileSync as appendFileSync6, rmSync as rmSync3, readdirSync as readdirSync23, mkdirSync as mkdirSync32 } from "node:fs";
|
|
301258
|
+
import { existsSync as existsSync59 } from "node:fs";
|
|
301259
|
+
import { execSync as execSync36 } from "node:child_process";
|
|
301260
|
+
import { homedir as homedir21 } from "node:os";
|
|
301049
301261
|
function formatTimeAgo(date) {
|
|
301050
301262
|
const seconds = Math.floor((Date.now() - date.getTime()) / 1e3);
|
|
301051
301263
|
if (seconds < 60)
|
|
@@ -301064,12 +301276,12 @@ function getVersion4() {
|
|
|
301064
301276
|
const require3 = createRequire5(import.meta.url);
|
|
301065
301277
|
const thisDir = dirname23(fileURLToPath15(import.meta.url));
|
|
301066
301278
|
const candidates = [
|
|
301067
|
-
|
|
301068
|
-
|
|
301069
|
-
|
|
301279
|
+
join77(thisDir, "..", "package.json"),
|
|
301280
|
+
join77(thisDir, "..", "..", "package.json"),
|
|
301281
|
+
join77(thisDir, "..", "..", "..", "package.json")
|
|
301070
301282
|
];
|
|
301071
301283
|
for (const pkgPath of candidates) {
|
|
301072
|
-
if (
|
|
301284
|
+
if (existsSync59(pkgPath)) {
|
|
301073
301285
|
const pkg = require3(pkgPath);
|
|
301074
301286
|
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli" || pkg.name === "@open-agents/monorepo") {
|
|
301075
301287
|
return pkg.version ?? "0.0.0";
|
|
@@ -301309,15 +301521,15 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
|
|
|
301309
301521
|
function gatherMemorySnippets(root) {
|
|
301310
301522
|
const snippets = [];
|
|
301311
301523
|
const dirs = [
|
|
301312
|
-
|
|
301313
|
-
|
|
301524
|
+
join77(root, ".oa", "memory"),
|
|
301525
|
+
join77(root, ".open-agents", "memory")
|
|
301314
301526
|
];
|
|
301315
301527
|
for (const dir of dirs) {
|
|
301316
|
-
if (!
|
|
301528
|
+
if (!existsSync59(dir))
|
|
301317
301529
|
continue;
|
|
301318
301530
|
try {
|
|
301319
301531
|
for (const f2 of readdirSync23(dir).filter((f3) => f3.endsWith(".json"))) {
|
|
301320
|
-
const data = JSON.parse(
|
|
301532
|
+
const data = JSON.parse(readFileSync48(join77(dir, f2), "utf-8"));
|
|
301321
301533
|
for (const val of Object.values(data)) {
|
|
301322
301534
|
const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
301323
301535
|
if (v.length > 10)
|
|
@@ -301474,9 +301686,9 @@ ${metabolismMemories}
|
|
|
301474
301686
|
} catch {
|
|
301475
301687
|
}
|
|
301476
301688
|
try {
|
|
301477
|
-
const archeFile =
|
|
301478
|
-
if (
|
|
301479
|
-
const variants = JSON.parse(
|
|
301689
|
+
const archeFile = join77(repoRoot, ".oa", "arche", "variants.json");
|
|
301690
|
+
if (existsSync59(archeFile)) {
|
|
301691
|
+
const variants = JSON.parse(readFileSync48(archeFile, "utf8"));
|
|
301480
301692
|
if (variants.length > 0) {
|
|
301481
301693
|
let filtered = variants;
|
|
301482
301694
|
if (taskType) {
|
|
@@ -301645,9 +301857,9 @@ RULES:
|
|
|
301645
301857
|
const compactionThreshold = modelTier === "small" ? 12e3 : modelTier === "medium" ? 24e3 : 4e4;
|
|
301646
301858
|
let identityInjection = "";
|
|
301647
301859
|
try {
|
|
301648
|
-
const ikStateFile =
|
|
301649
|
-
if (
|
|
301650
|
-
const selfState = JSON.parse(
|
|
301860
|
+
const ikStateFile = join77(repoRoot, ".oa", "identity", "self-state.json");
|
|
301861
|
+
if (existsSync59(ikStateFile)) {
|
|
301862
|
+
const selfState = JSON.parse(readFileSync48(ikStateFile, "utf8"));
|
|
301651
301863
|
const lines = [
|
|
301652
301864
|
`[Identity State v${selfState.version}]`,
|
|
301653
301865
|
`Self: ${selfState.narrative_summary}`,
|
|
@@ -302298,13 +302510,13 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
302298
302510
|
});
|
|
302299
302511
|
}
|
|
302300
302512
|
try {
|
|
302301
|
-
const ikDir =
|
|
302302
|
-
const ikFile =
|
|
302513
|
+
const ikDir = join77(repoRoot, ".oa", "identity");
|
|
302514
|
+
const ikFile = join77(ikDir, "self-state.json");
|
|
302303
302515
|
let ikState;
|
|
302304
|
-
if (
|
|
302305
|
-
ikState = JSON.parse(
|
|
302516
|
+
if (existsSync59(ikFile)) {
|
|
302517
|
+
ikState = JSON.parse(readFileSync48(ikFile, "utf8"));
|
|
302306
302518
|
} else {
|
|
302307
|
-
|
|
302519
|
+
mkdirSync32(ikDir, { recursive: true });
|
|
302308
302520
|
const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
302309
302521
|
ikState = {
|
|
302310
302522
|
self_id: `oa-${machineId}`,
|
|
@@ -302330,7 +302542,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
302330
302542
|
}
|
|
302331
302543
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
302332
302544
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
302333
|
-
|
|
302545
|
+
writeFileSync30(ikFile, JSON.stringify(ikState, null, 2));
|
|
302334
302546
|
} catch (ikErr) {
|
|
302335
302547
|
try {
|
|
302336
302548
|
console.error("[IK-OBSERVE]", ikErr);
|
|
@@ -302345,14 +302557,14 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
302345
302557
|
} else {
|
|
302346
302558
|
renderTaskIncomplete(result.turns, result.toolCalls, result.durationMs, tokens);
|
|
302347
302559
|
try {
|
|
302348
|
-
const ikFile =
|
|
302349
|
-
if (
|
|
302350
|
-
const ikState = JSON.parse(
|
|
302560
|
+
const ikFile = join77(repoRoot, ".oa", "identity", "self-state.json");
|
|
302561
|
+
if (existsSync59(ikFile)) {
|
|
302562
|
+
const ikState = JSON.parse(readFileSync48(ikFile, "utf8"));
|
|
302351
302563
|
ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
|
|
302352
302564
|
ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
|
|
302353
302565
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
302354
302566
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
302355
|
-
|
|
302567
|
+
writeFileSync30(ikFile, JSON.stringify(ikState, null, 2));
|
|
302356
302568
|
}
|
|
302357
302569
|
} catch {
|
|
302358
302570
|
}
|
|
@@ -302430,7 +302642,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
302430
302642
|
} };
|
|
302431
302643
|
}
|
|
302432
302644
|
async function startInteractive(config, repoPath) {
|
|
302433
|
-
const repoRoot =
|
|
302645
|
+
const repoRoot = resolve34(repoPath ?? cwd());
|
|
302434
302646
|
const resumeFlag = process.env.__OA_RESUMED ?? "";
|
|
302435
302647
|
const isResumed = resumeFlag !== "";
|
|
302436
302648
|
const hasTaskToResume = resumeFlag === "1";
|
|
@@ -302449,10 +302661,10 @@ async function startInteractive(config, repoPath) {
|
|
|
302449
302661
|
process.stdin.pause();
|
|
302450
302662
|
}
|
|
302451
302663
|
try {
|
|
302452
|
-
const oaDir =
|
|
302453
|
-
const nexusPidFile =
|
|
302454
|
-
if (
|
|
302455
|
-
const pid = parseInt(
|
|
302664
|
+
const oaDir = join77(repoRoot, ".oa");
|
|
302665
|
+
const nexusPidFile = join77(oaDir, "nexus", "daemon.pid");
|
|
302666
|
+
if (existsSync59(nexusPidFile)) {
|
|
302667
|
+
const pid = parseInt(readFileSync48(nexusPidFile, "utf8").trim(), 10);
|
|
302456
302668
|
if (pid > 0) {
|
|
302457
302669
|
try {
|
|
302458
302670
|
process.kill(pid, 0);
|
|
@@ -302710,14 +302922,14 @@ Review its full output in the [${id}] tab or via full_sub_agent(action='output',
|
|
|
302710
302922
|
renderInfo(msg);
|
|
302711
302923
|
statusBar.endContentWrite();
|
|
302712
302924
|
}
|
|
302713
|
-
}, () => new Promise((
|
|
302925
|
+
}, () => new Promise((resolve38) => {
|
|
302714
302926
|
depSudoPromptPending = true;
|
|
302715
302927
|
depSudoResolver = (pw) => {
|
|
302716
302928
|
depSudoPromptPending = false;
|
|
302717
302929
|
depSudoResolver = null;
|
|
302718
302930
|
if (pw)
|
|
302719
302931
|
sessionSudoPassword = pw;
|
|
302720
|
-
|
|
302932
|
+
resolve38(pw);
|
|
302721
302933
|
};
|
|
302722
302934
|
const pwPrompt = `
|
|
302723
302935
|
${c3.bold(c3.yellow("\u{1F511} Password needed for dependency install:"))}
|
|
@@ -302789,7 +303001,7 @@ Review its full output in the [${id}] tab or via full_sub_agent(action='output',
|
|
|
302789
303001
|
let p2pGateway = null;
|
|
302790
303002
|
let peerMesh = null;
|
|
302791
303003
|
let inferenceRouter = null;
|
|
302792
|
-
const secretVault = new SecretVault(
|
|
303004
|
+
const secretVault = new SecretVault(join77(repoRoot, ".oa", "vault.enc"));
|
|
302793
303005
|
let adminSessionKey = null;
|
|
302794
303006
|
const callSubAgents = /* @__PURE__ */ new Map();
|
|
302795
303007
|
const streamRenderer = new StreamRenderer();
|
|
@@ -303012,13 +303224,13 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303012
303224
|
const hits = allCompletions.filter((c4) => c4.toLowerCase().startsWith(lower));
|
|
303013
303225
|
return [hits, line];
|
|
303014
303226
|
}
|
|
303015
|
-
const HISTORY_DIR =
|
|
303016
|
-
const HISTORY_FILE =
|
|
303227
|
+
const HISTORY_DIR = join77(homedir21(), ".open-agents");
|
|
303228
|
+
const HISTORY_FILE = join77(HISTORY_DIR, "repl-history");
|
|
303017
303229
|
const MAX_HISTORY_LINES = 500;
|
|
303018
303230
|
let savedHistory = [];
|
|
303019
303231
|
try {
|
|
303020
|
-
if (
|
|
303021
|
-
const raw =
|
|
303232
|
+
if (existsSync59(HISTORY_FILE)) {
|
|
303233
|
+
const raw = readFileSync48(HISTORY_FILE, "utf8").trim();
|
|
303022
303234
|
if (raw)
|
|
303023
303235
|
savedHistory = raw.split("\n").reverse();
|
|
303024
303236
|
}
|
|
@@ -303121,12 +303333,12 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303121
303333
|
if (!line.trim())
|
|
303122
303334
|
return;
|
|
303123
303335
|
try {
|
|
303124
|
-
|
|
303336
|
+
mkdirSync32(HISTORY_DIR, { recursive: true });
|
|
303125
303337
|
appendFileSync6(HISTORY_FILE, line + "\n", "utf8");
|
|
303126
303338
|
if (Math.random() < 0.02) {
|
|
303127
|
-
const all2 =
|
|
303339
|
+
const all2 = readFileSync48(HISTORY_FILE, "utf8").trim().split("\n");
|
|
303128
303340
|
if (all2.length > MAX_HISTORY_LINES) {
|
|
303129
|
-
|
|
303341
|
+
writeFileSync30(HISTORY_FILE, all2.slice(-MAX_HISTORY_LINES).join("\n") + "\n", "utf8");
|
|
303130
303342
|
}
|
|
303131
303343
|
}
|
|
303132
303344
|
} catch {
|
|
@@ -303303,10 +303515,10 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303303
303515
|
const { unlinkSync: _rmStale } = await import("node:fs");
|
|
303304
303516
|
const { homedir: _hdir } = await import("node:os");
|
|
303305
303517
|
for (const dp of [
|
|
303306
|
-
|
|
303307
|
-
|
|
303518
|
+
join77(repoRoot, ".oa", "nexus", "nexus-daemon.mjs"),
|
|
303519
|
+
join77(_hdir(), ".open-agents", ".oa", "nexus", "nexus-daemon.mjs")
|
|
303308
303520
|
]) {
|
|
303309
|
-
if (
|
|
303521
|
+
if (existsSync59(dp))
|
|
303310
303522
|
try {
|
|
303311
303523
|
_rmStale(dp);
|
|
303312
303524
|
} catch {
|
|
@@ -303318,9 +303530,9 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303318
303530
|
const autoNexus = new NexusTool(repoRoot);
|
|
303319
303531
|
const _registerNexusDaemon = () => {
|
|
303320
303532
|
try {
|
|
303321
|
-
const nexusPidFile =
|
|
303322
|
-
if (
|
|
303323
|
-
const nPid = parseInt(
|
|
303533
|
+
const nexusPidFile = join77(repoRoot, ".oa", "nexus", "daemon.pid");
|
|
303534
|
+
if (existsSync59(nexusPidFile)) {
|
|
303535
|
+
const nPid = parseInt(readFileSync48(nexusPidFile, "utf8").trim(), 10);
|
|
303324
303536
|
if (nPid > 0 && !registry2.daemons.has("Nexus")) {
|
|
303325
303537
|
registry2.register({ name: "Nexus", pid: nPid, startedAt: Date.now(), status: "running" });
|
|
303326
303538
|
statusBar.ensureMonitorTimer();
|
|
@@ -303361,7 +303573,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303361
303573
|
} catch {
|
|
303362
303574
|
}
|
|
303363
303575
|
try {
|
|
303364
|
-
const oaDir =
|
|
303576
|
+
const oaDir = join77(repoRoot, ".oa");
|
|
303365
303577
|
const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
|
|
303366
303578
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
303367
303579
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -303393,7 +303605,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303393
303605
|
} catch {
|
|
303394
303606
|
}
|
|
303395
303607
|
try {
|
|
303396
|
-
const oaDir =
|
|
303608
|
+
const oaDir = join77(repoRoot, ".oa");
|
|
303397
303609
|
const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
|
|
303398
303610
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
303399
303611
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -303434,11 +303646,11 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303434
303646
|
}
|
|
303435
303647
|
try {
|
|
303436
303648
|
const { homedir: _hd, hostname: _hn, userInfo: _ui } = await import("node:os");
|
|
303437
|
-
const globalNamePath =
|
|
303649
|
+
const globalNamePath = join77(_hd(), ".open-agents", "agent-name");
|
|
303438
303650
|
let agName = "";
|
|
303439
303651
|
try {
|
|
303440
|
-
if (
|
|
303441
|
-
agName =
|
|
303652
|
+
if (existsSync59(globalNamePath))
|
|
303653
|
+
agName = readFileSync48(globalNamePath, "utf8").trim();
|
|
303442
303654
|
} catch {
|
|
303443
303655
|
}
|
|
303444
303656
|
if (!agName) {
|
|
@@ -303467,11 +303679,11 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
303467
303679
|
}
|
|
303468
303680
|
if (!ollamaAlive) {
|
|
303469
303681
|
try {
|
|
303470
|
-
const savedSponsorsPath =
|
|
303682
|
+
const savedSponsorsPath = join77(repoRoot, ".oa", "sponsor", "known-sponsors.json");
|
|
303471
303683
|
let savedSponsors = [];
|
|
303472
303684
|
try {
|
|
303473
|
-
if (
|
|
303474
|
-
savedSponsors = JSON.parse(
|
|
303685
|
+
if (existsSync59(savedSponsorsPath)) {
|
|
303686
|
+
savedSponsors = JSON.parse(readFileSync48(savedSponsorsPath, "utf8"));
|
|
303475
303687
|
const oneHourAgo = Date.now() - 36e5;
|
|
303476
303688
|
savedSponsors = savedSponsors.filter((s2) => (s2.lastVerified || 0) > oneHourAgo);
|
|
303477
303689
|
}
|
|
@@ -304429,7 +304641,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304429
304641
|
kind,
|
|
304430
304642
|
targetUrl,
|
|
304431
304643
|
authKey,
|
|
304432
|
-
stateDir:
|
|
304644
|
+
stateDir: join77(repoRoot, ".oa"),
|
|
304433
304645
|
passthrough: passthrough ?? false,
|
|
304434
304646
|
loadbalance: loadbalance ?? false,
|
|
304435
304647
|
endpointAuth: passthrough ? currentConfig.apiKey : void 0,
|
|
@@ -304475,7 +304687,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304475
304687
|
await tunnelGateway.stop();
|
|
304476
304688
|
tunnelGateway = null;
|
|
304477
304689
|
}
|
|
304478
|
-
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir:
|
|
304690
|
+
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join77(repoRoot, ".oa") });
|
|
304479
304691
|
newTunnel.on("stats", (stats) => {
|
|
304480
304692
|
statusBar.setExposeStatus({
|
|
304481
304693
|
status: stats.status,
|
|
@@ -304564,9 +304776,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304564
304776
|
if (!result.success)
|
|
304565
304777
|
throw new Error(result.error || "Connect failed");
|
|
304566
304778
|
try {
|
|
304567
|
-
const nexusPidFile =
|
|
304568
|
-
if (
|
|
304569
|
-
const pid = parseInt(
|
|
304779
|
+
const nexusPidFile = join77(repoRoot, ".oa", "nexus", "daemon.pid");
|
|
304780
|
+
if (existsSync59(nexusPidFile)) {
|
|
304781
|
+
const pid = parseInt(readFileSync48(nexusPidFile, "utf8").trim(), 10);
|
|
304570
304782
|
if (pid > 0) {
|
|
304571
304783
|
registry2.register({
|
|
304572
304784
|
name: "Nexus",
|
|
@@ -304762,15 +304974,15 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304762
304974
|
writeContent(() => renderInfo(`Killed ${bgKilled} background task(s).`));
|
|
304763
304975
|
}
|
|
304764
304976
|
try {
|
|
304765
|
-
const nexusDir =
|
|
304766
|
-
const pidFile =
|
|
304767
|
-
if (
|
|
304768
|
-
const pid = parseInt(
|
|
304977
|
+
const nexusDir = join77(repoRoot, OA_DIR, "nexus");
|
|
304978
|
+
const pidFile = join77(nexusDir, "daemon.pid");
|
|
304979
|
+
if (existsSync59(pidFile)) {
|
|
304980
|
+
const pid = parseInt(readFileSync48(pidFile, "utf8").trim(), 10);
|
|
304769
304981
|
if (pid > 0) {
|
|
304770
304982
|
try {
|
|
304771
304983
|
if (process.platform === "win32") {
|
|
304772
304984
|
try {
|
|
304773
|
-
|
|
304985
|
+
execSync36(`taskkill /F /PID ${pid}`, { timeout: 5e3, stdio: "ignore" });
|
|
304774
304986
|
} catch {
|
|
304775
304987
|
}
|
|
304776
304988
|
} else {
|
|
@@ -304787,17 +304999,17 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304787
304999
|
} catch {
|
|
304788
305000
|
}
|
|
304789
305001
|
try {
|
|
304790
|
-
const voiceDir2 =
|
|
305002
|
+
const voiceDir2 = join77(homedir21(), ".open-agents", "voice");
|
|
304791
305003
|
const voicePidFiles = ["luxtts-daemon.pid", "piper-daemon.pid"];
|
|
304792
305004
|
for (const pf of voicePidFiles) {
|
|
304793
|
-
const pidPath =
|
|
304794
|
-
if (
|
|
305005
|
+
const pidPath = join77(voiceDir2, pf);
|
|
305006
|
+
if (existsSync59(pidPath)) {
|
|
304795
305007
|
try {
|
|
304796
|
-
const pid = parseInt(
|
|
305008
|
+
const pid = parseInt(readFileSync48(pidPath, "utf8").trim(), 10);
|
|
304797
305009
|
if (pid > 0) {
|
|
304798
305010
|
if (process.platform === "win32") {
|
|
304799
305011
|
try {
|
|
304800
|
-
|
|
305012
|
+
execSync36(`taskkill /F /PID ${pid}`, { timeout: 5e3, stdio: "ignore" });
|
|
304801
305013
|
} catch {
|
|
304802
305014
|
}
|
|
304803
305015
|
} else {
|
|
@@ -304814,11 +305026,11 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304814
305026
|
} catch {
|
|
304815
305027
|
}
|
|
304816
305028
|
try {
|
|
304817
|
-
|
|
305029
|
+
execSync36(process.platform === "win32" ? "timeout /t 1 /nobreak >nul" : "sleep 0.5", { timeout: 3e3, stdio: "ignore" });
|
|
304818
305030
|
} catch {
|
|
304819
305031
|
}
|
|
304820
|
-
const oaPath =
|
|
304821
|
-
if (
|
|
305032
|
+
const oaPath = join77(repoRoot, OA_DIR);
|
|
305033
|
+
if (existsSync59(oaPath)) {
|
|
304822
305034
|
let deleted = false;
|
|
304823
305035
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
304824
305036
|
try {
|
|
@@ -304828,14 +305040,14 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304828
305040
|
} catch (err) {
|
|
304829
305041
|
if (attempt < 2) {
|
|
304830
305042
|
try {
|
|
304831
|
-
|
|
305043
|
+
execSync36(process.platform === "win32" ? "timeout /t 1 /nobreak >nul" : "sleep 0.3", { timeout: 3e3, stdio: "ignore" });
|
|
304832
305044
|
} catch {
|
|
304833
305045
|
}
|
|
304834
305046
|
} else {
|
|
304835
305047
|
writeContent(() => renderWarning(`Could not fully remove ${OA_DIR}/: ${err instanceof Error ? err.message : String(err)}`));
|
|
304836
305048
|
if (process.platform === "win32") {
|
|
304837
305049
|
try {
|
|
304838
|
-
|
|
305050
|
+
execSync36(`rd /s /q "${oaPath}"`, { timeout: 1e4, stdio: "ignore" });
|
|
304839
305051
|
deleted = true;
|
|
304840
305052
|
} catch {
|
|
304841
305053
|
}
|
|
@@ -304901,19 +305113,19 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
304901
305113
|
try {
|
|
304902
305114
|
const { isPersonaPlexRunning: isPersonaPlexRunning2 } = await Promise.resolve().then(() => (init_personaplex(), personaplex_exports));
|
|
304903
305115
|
if (isPersonaPlexRunning2()) {
|
|
304904
|
-
const ppPidFile =
|
|
304905
|
-
const ppPortFile =
|
|
304906
|
-
if (
|
|
304907
|
-
const ppPid = parseInt(
|
|
304908
|
-
const ppPort =
|
|
305116
|
+
const ppPidFile = join77(homedir21(), ".open-agents", "voice", "personaplex", "daemon.pid");
|
|
305117
|
+
const ppPortFile = join77(homedir21(), ".open-agents", "voice", "personaplex", "daemon.port");
|
|
305118
|
+
if (existsSync59(ppPidFile)) {
|
|
305119
|
+
const ppPid = parseInt(readFileSync48(ppPidFile, "utf8").trim(), 10);
|
|
305120
|
+
const ppPort = existsSync59(ppPortFile) ? parseInt(readFileSync48(ppPortFile, "utf8").trim(), 10) : void 0;
|
|
304909
305121
|
if (ppPid > 0 && !registry2.daemons.has("PersonaPlex")) {
|
|
304910
305122
|
registry2.register({ name: "PersonaPlex", pid: ppPid, port: ppPort, startedAt: Date.now(), status: "running" });
|
|
304911
305123
|
}
|
|
304912
305124
|
}
|
|
304913
305125
|
}
|
|
304914
|
-
const nexusPidFile =
|
|
304915
|
-
if (
|
|
304916
|
-
const nPid = parseInt(
|
|
305126
|
+
const nexusPidFile = join77(repoRoot, ".oa", "nexus", "daemon.pid");
|
|
305127
|
+
if (existsSync59(nexusPidFile)) {
|
|
305128
|
+
const nPid = parseInt(readFileSync48(nexusPidFile, "utf8").trim(), 10);
|
|
304917
305129
|
if (nPid > 0 && !registry2.daemons.has("Nexus")) {
|
|
304918
305130
|
try {
|
|
304919
305131
|
process.kill(nPid, 0);
|
|
@@ -305255,8 +305467,8 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
305255
305467
|
}
|
|
305256
305468
|
}
|
|
305257
305469
|
const cleanPath = input.replace(/^['"]|['"]$/g, "").trim();
|
|
305258
|
-
const isImage = isImagePath(cleanPath) &&
|
|
305259
|
-
const isMedia = !isImage && isTranscribablePath(cleanPath) &&
|
|
305470
|
+
const isImage = isImagePath(cleanPath) && existsSync59(resolve34(repoRoot, cleanPath));
|
|
305471
|
+
const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync59(resolve34(repoRoot, cleanPath));
|
|
305260
305472
|
if (activeTask) {
|
|
305261
305473
|
if (activeTask.runner.isPaused) {
|
|
305262
305474
|
activeTask.runner.resume();
|
|
@@ -305264,8 +305476,8 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
305264
305476
|
}
|
|
305265
305477
|
if (isImage) {
|
|
305266
305478
|
try {
|
|
305267
|
-
const imgPath =
|
|
305268
|
-
const imgBuffer =
|
|
305479
|
+
const imgPath = resolve34(repoRoot, cleanPath);
|
|
305480
|
+
const imgBuffer = readFileSync48(imgPath);
|
|
305269
305481
|
const base642 = imgBuffer.toString("base64");
|
|
305270
305482
|
const ext = extname11(cleanPath).toLowerCase();
|
|
305271
305483
|
const mime = ext === ".png" ? "image/png" : ext === ".gif" ? "image/gif" : ext === ".webp" ? "image/webp" : "image/jpeg";
|
|
@@ -305278,7 +305490,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
305278
305490
|
} else if (isMedia) {
|
|
305279
305491
|
writeContent(() => renderInfo(`Transcribing: ${cleanPath}...`));
|
|
305280
305492
|
const engine = getListenEngine();
|
|
305281
|
-
const result = await engine.transcribeFile(
|
|
305493
|
+
const result = await engine.transcribeFile(resolve34(repoRoot, cleanPath), repoRoot);
|
|
305282
305494
|
if (result) {
|
|
305283
305495
|
const transcript = `[Transcription of ${cleanPath}]
|
|
305284
305496
|
${result.text}`;
|
|
@@ -305422,7 +305634,7 @@ ${result.text}`;
|
|
|
305422
305634
|
const ext = cleanPath.toLowerCase().split(".").pop() || "";
|
|
305423
305635
|
if (cloneExts.includes("." + ext)) {
|
|
305424
305636
|
writeContent(() => renderInfo(`Setting voice clone reference: ${cleanPath}`));
|
|
305425
|
-
const msg = await voiceEngine.setCloneVoice(
|
|
305637
|
+
const msg = await voiceEngine.setCloneVoice(resolve34(repoRoot, cleanPath));
|
|
305426
305638
|
writeContent(() => renderInfo(msg));
|
|
305427
305639
|
showPrompt();
|
|
305428
305640
|
return;
|
|
@@ -305431,7 +305643,7 @@ ${result.text}`;
|
|
|
305431
305643
|
if (isMedia && fullInput === input) {
|
|
305432
305644
|
writeContent(() => renderInfo(`Transcribing: ${cleanPath}...`));
|
|
305433
305645
|
const engine = getListenEngine();
|
|
305434
|
-
const result = await engine.transcribeFile(
|
|
305646
|
+
const result = await engine.transcribeFile(resolve34(repoRoot, cleanPath), repoRoot);
|
|
305435
305647
|
if (result) {
|
|
305436
305648
|
fullInput = `The user has provided an audio/video file: ${cleanPath}.
|
|
305437
305649
|
|
|
@@ -305480,7 +305692,7 @@ Summarize or analyze this transcription as appropriate.`;
|
|
|
305480
305692
|
|
|
305481
305693
|
NEW TASK: ${fullInput}`;
|
|
305482
305694
|
restoredSessionContext = null;
|
|
305483
|
-
} else if (
|
|
305695
|
+
} else if (existsSync59(join77(repoRoot, ".oa", "context", "session-diary.md"))) {
|
|
305484
305696
|
taskInput = `[Previous sessions exist \u2014 file_read(".oa/context/session-diary.md") to recall]
|
|
305485
305697
|
|
|
305486
305698
|
${fullInput}`;
|
|
@@ -305751,7 +305963,7 @@ ${c3.dim("(Use /quit to exit)")}
|
|
|
305751
305963
|
};
|
|
305752
305964
|
}
|
|
305753
305965
|
async function runWithTUI(task, config, repoPath, callbacks) {
|
|
305754
|
-
const repoRoot =
|
|
305966
|
+
const repoRoot = resolve34(repoPath ?? cwd());
|
|
305755
305967
|
const needsSetup = isFirstRun() || !await isModelAvailable(config);
|
|
305756
305968
|
if (needsSetup && config.backendType === "ollama") {
|
|
305757
305969
|
const setupModel = await runSetupWizard(config);
|
|
@@ -305798,13 +306010,13 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
305798
306010
|
const handle2 = startTask(task, config, repoRoot);
|
|
305799
306011
|
await handle2.promise;
|
|
305800
306012
|
try {
|
|
305801
|
-
const ikDir =
|
|
305802
|
-
const ikFile =
|
|
306013
|
+
const ikDir = join77(repoRoot, ".oa", "identity");
|
|
306014
|
+
const ikFile = join77(ikDir, "self-state.json");
|
|
305803
306015
|
let ikState;
|
|
305804
|
-
if (
|
|
305805
|
-
ikState = JSON.parse(
|
|
306016
|
+
if (existsSync59(ikFile)) {
|
|
306017
|
+
ikState = JSON.parse(readFileSync48(ikFile, "utf8"));
|
|
305806
306018
|
} else {
|
|
305807
|
-
|
|
306019
|
+
mkdirSync32(ikDir, { recursive: true });
|
|
305808
306020
|
ikState = {
|
|
305809
306021
|
self_id: `oa-${Date.now().toString(36)}`,
|
|
305810
306022
|
version: 1,
|
|
@@ -305826,7 +306038,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
305826
306038
|
ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
|
|
305827
306039
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
305828
306040
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
305829
|
-
|
|
306041
|
+
writeFileSync30(ikFile, JSON.stringify(ikState, null, 2));
|
|
305830
306042
|
} catch (ikErr) {
|
|
305831
306043
|
}
|
|
305832
306044
|
try {
|
|
@@ -305835,12 +306047,12 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
305835
306047
|
ec.archiveVariantSync(`Task: ${task.slice(0, 200)}`, "success \u2014 completed", ["general"]);
|
|
305836
306048
|
} catch {
|
|
305837
306049
|
try {
|
|
305838
|
-
const archeDir =
|
|
305839
|
-
const archeFile =
|
|
306050
|
+
const archeDir = join77(repoRoot, ".oa", "arche");
|
|
306051
|
+
const archeFile = join77(archeDir, "variants.json");
|
|
305840
306052
|
let variants = [];
|
|
305841
306053
|
try {
|
|
305842
|
-
if (
|
|
305843
|
-
variants = JSON.parse(
|
|
306054
|
+
if (existsSync59(archeFile))
|
|
306055
|
+
variants = JSON.parse(readFileSync48(archeFile, "utf8"));
|
|
305844
306056
|
} catch {
|
|
305845
306057
|
}
|
|
305846
306058
|
variants.push({
|
|
@@ -305855,15 +306067,15 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
305855
306067
|
});
|
|
305856
306068
|
if (variants.length > 50)
|
|
305857
306069
|
variants = variants.slice(-50);
|
|
305858
|
-
|
|
305859
|
-
|
|
306070
|
+
mkdirSync32(archeDir, { recursive: true });
|
|
306071
|
+
writeFileSync30(archeFile, JSON.stringify(variants, null, 2));
|
|
305860
306072
|
} catch {
|
|
305861
306073
|
}
|
|
305862
306074
|
}
|
|
305863
306075
|
try {
|
|
305864
|
-
const metaFile =
|
|
305865
|
-
if (
|
|
305866
|
-
const store2 = JSON.parse(
|
|
306076
|
+
const metaFile = join77(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
306077
|
+
if (existsSync59(metaFile)) {
|
|
306078
|
+
const store2 = JSON.parse(readFileSync48(metaFile, "utf8"));
|
|
305867
306079
|
const surfaced = store2.filter((m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15).sort((a2, b) => b.scores.utility * b.scores.confidence - a2.scores.utility * a2.scores.confidence).slice(0, 5);
|
|
305868
306080
|
let updated = false;
|
|
305869
306081
|
for (const item of surfaced) {
|
|
@@ -305874,7 +306086,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
305874
306086
|
updated = true;
|
|
305875
306087
|
}
|
|
305876
306088
|
if (updated) {
|
|
305877
|
-
|
|
306089
|
+
writeFileSync30(metaFile, JSON.stringify(store2, null, 2));
|
|
305878
306090
|
}
|
|
305879
306091
|
}
|
|
305880
306092
|
} catch {
|
|
@@ -305927,9 +306139,9 @@ Rules:
|
|
|
305927
306139
|
try {
|
|
305928
306140
|
const { initDb: initDb2 } = __require("@open-agents/memory");
|
|
305929
306141
|
const { ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
|
|
305930
|
-
const dbDir =
|
|
305931
|
-
|
|
305932
|
-
const db = initDb2(
|
|
306142
|
+
const dbDir = join77(repoRoot, ".oa", "memory");
|
|
306143
|
+
mkdirSync32(dbDir, { recursive: true });
|
|
306144
|
+
const db = initDb2(join77(dbDir, "structured.db"));
|
|
305933
306145
|
const memStore = new ProceduralMemoryStore2(db);
|
|
305934
306146
|
memStore.createWithEmbedding({
|
|
305935
306147
|
content: content.slice(0, 600),
|
|
@@ -305944,12 +306156,12 @@ Rules:
|
|
|
305944
306156
|
db.close();
|
|
305945
306157
|
} catch {
|
|
305946
306158
|
}
|
|
305947
|
-
const metaDir =
|
|
305948
|
-
const storeFile =
|
|
306159
|
+
const metaDir = join77(repoRoot, ".oa", "memory", "metabolism");
|
|
306160
|
+
const storeFile = join77(metaDir, "store.json");
|
|
305949
306161
|
let store2 = [];
|
|
305950
306162
|
try {
|
|
305951
|
-
if (
|
|
305952
|
-
store2 = JSON.parse(
|
|
306163
|
+
if (existsSync59(storeFile))
|
|
306164
|
+
store2 = JSON.parse(readFileSync48(storeFile, "utf8"));
|
|
305953
306165
|
} catch {
|
|
305954
306166
|
}
|
|
305955
306167
|
store2.push({
|
|
@@ -305965,26 +306177,26 @@ Rules:
|
|
|
305965
306177
|
});
|
|
305966
306178
|
if (store2.length > 100)
|
|
305967
306179
|
store2 = store2.slice(-100);
|
|
305968
|
-
|
|
305969
|
-
|
|
306180
|
+
mkdirSync32(metaDir, { recursive: true });
|
|
306181
|
+
writeFileSync30(storeFile, JSON.stringify(store2, null, 2));
|
|
305970
306182
|
}
|
|
305971
306183
|
}
|
|
305972
306184
|
} catch {
|
|
305973
306185
|
}
|
|
305974
306186
|
try {
|
|
305975
|
-
const cohereSettingsFile =
|
|
306187
|
+
const cohereSettingsFile = join77(repoRoot, ".oa", "settings.json");
|
|
305976
306188
|
let cohereActive = false;
|
|
305977
306189
|
try {
|
|
305978
|
-
if (
|
|
305979
|
-
const settings = JSON.parse(
|
|
306190
|
+
if (existsSync59(cohereSettingsFile)) {
|
|
306191
|
+
const settings = JSON.parse(readFileSync48(cohereSettingsFile, "utf8"));
|
|
305980
306192
|
cohereActive = settings.cohere === true;
|
|
305981
306193
|
}
|
|
305982
306194
|
} catch {
|
|
305983
306195
|
}
|
|
305984
306196
|
if (cohereActive) {
|
|
305985
|
-
const metaFile =
|
|
305986
|
-
if (
|
|
305987
|
-
const store2 = JSON.parse(
|
|
306197
|
+
const metaFile = join77(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
306198
|
+
if (existsSync59(metaFile)) {
|
|
306199
|
+
const store2 = JSON.parse(readFileSync48(metaFile, "utf8"));
|
|
305988
306200
|
const latest = store2.filter((m2) => m2.sourceTrace === "trajectory-extraction" || m2.sourceTrace === "llm-trajectory-extraction").slice(-1)[0];
|
|
305989
306201
|
if (latest && latest.scores?.confidence >= 0.6) {
|
|
305990
306202
|
try {
|
|
@@ -306009,18 +306221,18 @@ Rules:
|
|
|
306009
306221
|
}
|
|
306010
306222
|
} catch (err) {
|
|
306011
306223
|
try {
|
|
306012
|
-
const ikFile =
|
|
306013
|
-
if (
|
|
306014
|
-
const ikState = JSON.parse(
|
|
306224
|
+
const ikFile = join77(repoRoot, ".oa", "identity", "self-state.json");
|
|
306225
|
+
if (existsSync59(ikFile)) {
|
|
306226
|
+
const ikState = JSON.parse(readFileSync48(ikFile, "utf8"));
|
|
306015
306227
|
ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
|
|
306016
306228
|
ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
|
|
306017
306229
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
306018
306230
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
306019
|
-
|
|
306231
|
+
writeFileSync30(ikFile, JSON.stringify(ikState, null, 2));
|
|
306020
306232
|
}
|
|
306021
|
-
const metaFile =
|
|
306022
|
-
if (
|
|
306023
|
-
const store2 = JSON.parse(
|
|
306233
|
+
const metaFile = join77(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
306234
|
+
if (existsSync59(metaFile)) {
|
|
306235
|
+
const store2 = JSON.parse(readFileSync48(metaFile, "utf8"));
|
|
306024
306236
|
const surfaced = store2.filter((m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15).sort((a2, b) => b.scores.utility * b.scores.confidence - a2.scores.utility * a2.scores.confidence).slice(0, 5);
|
|
306025
306237
|
for (const item of surfaced) {
|
|
306026
306238
|
item.accessCount = (item.accessCount || 0) + 1;
|
|
@@ -306028,15 +306240,15 @@ Rules:
|
|
|
306028
306240
|
item.scores.utility = Math.max(0, (item.scores.utility || 0.5) - 0.05);
|
|
306029
306241
|
item.scores.confidence = Math.max(0, (item.scores.confidence || 0.5) - 0.02);
|
|
306030
306242
|
}
|
|
306031
|
-
|
|
306243
|
+
writeFileSync30(metaFile, JSON.stringify(store2, null, 2));
|
|
306032
306244
|
}
|
|
306033
306245
|
try {
|
|
306034
|
-
const archeDir =
|
|
306035
|
-
const archeFile =
|
|
306246
|
+
const archeDir = join77(repoRoot, ".oa", "arche");
|
|
306247
|
+
const archeFile = join77(archeDir, "variants.json");
|
|
306036
306248
|
let variants = [];
|
|
306037
306249
|
try {
|
|
306038
|
-
if (
|
|
306039
|
-
variants = JSON.parse(
|
|
306250
|
+
if (existsSync59(archeFile))
|
|
306251
|
+
variants = JSON.parse(readFileSync48(archeFile, "utf8"));
|
|
306040
306252
|
} catch {
|
|
306041
306253
|
}
|
|
306042
306254
|
variants.push({
|
|
@@ -306051,8 +306263,8 @@ Rules:
|
|
|
306051
306263
|
});
|
|
306052
306264
|
if (variants.length > 50)
|
|
306053
306265
|
variants = variants.slice(-50);
|
|
306054
|
-
|
|
306055
|
-
|
|
306266
|
+
mkdirSync32(archeDir, { recursive: true });
|
|
306267
|
+
writeFileSync30(archeFile, JSON.stringify(variants, null, 2));
|
|
306056
306268
|
} catch {
|
|
306057
306269
|
}
|
|
306058
306270
|
} catch {
|
|
@@ -306121,15 +306333,15 @@ __export(run_exports, {
|
|
|
306121
306333
|
runCommand: () => runCommand,
|
|
306122
306334
|
statusCommand: () => statusCommand
|
|
306123
306335
|
});
|
|
306124
|
-
import { resolve as
|
|
306125
|
-
import { spawn as
|
|
306126
|
-
import { mkdirSync as
|
|
306336
|
+
import { resolve as resolve35 } from "node:path";
|
|
306337
|
+
import { spawn as spawn23 } from "node:child_process";
|
|
306338
|
+
import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync31, readFileSync as readFileSync49, readdirSync as readdirSync24, existsSync as existsSync60 } from "node:fs";
|
|
306127
306339
|
import { randomBytes as randomBytes20 } from "node:crypto";
|
|
306128
|
-
import { join as
|
|
306340
|
+
import { join as join78 } from "node:path";
|
|
306129
306341
|
function jobsDir2(repoPath) {
|
|
306130
|
-
const root =
|
|
306131
|
-
const dir =
|
|
306132
|
-
|
|
306342
|
+
const root = resolve35(repoPath ?? process.cwd());
|
|
306343
|
+
const dir = join78(root, ".oa", "jobs");
|
|
306344
|
+
mkdirSync33(dir, { recursive: true });
|
|
306133
306345
|
return dir;
|
|
306134
306346
|
}
|
|
306135
306347
|
async function runCommand(opts, config) {
|
|
@@ -306220,7 +306432,7 @@ function extractSummary(captured) {
|
|
|
306220
306432
|
async function runBackground(task, config, opts) {
|
|
306221
306433
|
const id = `job-${randomBytes20(3).toString("hex")}`;
|
|
306222
306434
|
const dir = jobsDir2(opts.repoPath);
|
|
306223
|
-
const repoRoot =
|
|
306435
|
+
const repoRoot = resolve35(opts.repoPath ?? process.cwd());
|
|
306224
306436
|
const job = {
|
|
306225
306437
|
id,
|
|
306226
306438
|
pid: 0,
|
|
@@ -306232,7 +306444,7 @@ async function runBackground(task, config, opts) {
|
|
|
306232
306444
|
const args = [task, "--json"];
|
|
306233
306445
|
if (config.model)
|
|
306234
306446
|
args.push("--model", config.model);
|
|
306235
|
-
const child =
|
|
306447
|
+
const child = spawn23(process.execPath, [oaBin, ...args], {
|
|
306236
306448
|
cwd: repoRoot,
|
|
306237
306449
|
env: { ...process.env, OA_JOB_ID: id },
|
|
306238
306450
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -306240,7 +306452,7 @@ async function runBackground(task, config, opts) {
|
|
|
306240
306452
|
});
|
|
306241
306453
|
child.unref();
|
|
306242
306454
|
job.pid = child.pid ?? 0;
|
|
306243
|
-
|
|
306455
|
+
writeFileSync31(join78(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
306244
306456
|
let output = "";
|
|
306245
306457
|
child.stdout?.on("data", (chunk) => {
|
|
306246
306458
|
output += chunk.toString();
|
|
@@ -306256,7 +306468,7 @@ async function runBackground(task, config, opts) {
|
|
|
306256
306468
|
job.summary = result.summary;
|
|
306257
306469
|
job.durationMs = result.durationMs;
|
|
306258
306470
|
job.error = result.error;
|
|
306259
|
-
|
|
306471
|
+
writeFileSync31(join78(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
306260
306472
|
} catch {
|
|
306261
306473
|
}
|
|
306262
306474
|
});
|
|
@@ -306272,13 +306484,13 @@ async function runBackground(task, config, opts) {
|
|
|
306272
306484
|
}
|
|
306273
306485
|
function statusCommand(jobId, repoPath) {
|
|
306274
306486
|
const dir = jobsDir2(repoPath);
|
|
306275
|
-
const file =
|
|
306276
|
-
if (!
|
|
306487
|
+
const file = join78(dir, `${jobId}.json`);
|
|
306488
|
+
if (!existsSync60(file)) {
|
|
306277
306489
|
console.error(`Job not found: ${jobId}`);
|
|
306278
306490
|
console.log(`Available jobs: oa jobs`);
|
|
306279
306491
|
process.exit(1);
|
|
306280
306492
|
}
|
|
306281
|
-
const job = JSON.parse(
|
|
306493
|
+
const job = JSON.parse(readFileSync49(file, "utf-8"));
|
|
306282
306494
|
const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
|
|
306283
306495
|
const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
|
|
306284
306496
|
console.log(`${icon} ${job.id} [${job.status}] ${runtime}`);
|
|
@@ -306301,7 +306513,7 @@ function jobsCommand(repoPath) {
|
|
|
306301
306513
|
console.log("Jobs:");
|
|
306302
306514
|
for (const file of files) {
|
|
306303
306515
|
try {
|
|
306304
|
-
const job = JSON.parse(
|
|
306516
|
+
const job = JSON.parse(readFileSync49(join78(dir, file), "utf-8"));
|
|
306305
306517
|
const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
|
|
306306
306518
|
const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
|
|
306307
306519
|
console.log(` ${icon} ${job.id} [${job.status}] ${runtime} \u2014 ${job.task.slice(0, 60)}`);
|
|
@@ -306321,7 +306533,7 @@ import { glob as glob2 } from "glob";
|
|
|
306321
306533
|
import ignore from "ignore";
|
|
306322
306534
|
import { readFile as readFile23, stat as stat5 } from "node:fs/promises";
|
|
306323
306535
|
import { createHash as createHash6 } from "node:crypto";
|
|
306324
|
-
import { join as
|
|
306536
|
+
import { join as join79, relative as relative4, extname as extname12, basename as basename18 } from "node:path";
|
|
306325
306537
|
var DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
|
|
306326
306538
|
var init_codebase_indexer = __esm({
|
|
306327
306539
|
"packages/indexer/dist/codebase-indexer.js"() {
|
|
@@ -306365,7 +306577,7 @@ var init_codebase_indexer = __esm({
|
|
|
306365
306577
|
const ig = ignore.default();
|
|
306366
306578
|
if (this.config.respectGitignore) {
|
|
306367
306579
|
try {
|
|
306368
|
-
const gitignoreContent = await readFile23(
|
|
306580
|
+
const gitignoreContent = await readFile23(join79(this.config.rootDir, ".gitignore"), "utf-8");
|
|
306369
306581
|
ig.add(gitignoreContent);
|
|
306370
306582
|
} catch {
|
|
306371
306583
|
}
|
|
@@ -306380,7 +306592,7 @@ var init_codebase_indexer = __esm({
|
|
|
306380
306592
|
for (const relativePath of files) {
|
|
306381
306593
|
if (ig.ignores(relativePath))
|
|
306382
306594
|
continue;
|
|
306383
|
-
const fullPath =
|
|
306595
|
+
const fullPath = join79(this.config.rootDir, relativePath);
|
|
306384
306596
|
try {
|
|
306385
306597
|
const fileStat = await stat5(fullPath);
|
|
306386
306598
|
if (fileStat.size > this.config.maxFileSize)
|
|
@@ -306426,7 +306638,7 @@ var init_codebase_indexer = __esm({
|
|
|
306426
306638
|
if (!child) {
|
|
306427
306639
|
child = {
|
|
306428
306640
|
name: part,
|
|
306429
|
-
path:
|
|
306641
|
+
path: join79(current.path, part),
|
|
306430
306642
|
type: "directory",
|
|
306431
306643
|
children: []
|
|
306432
306644
|
};
|
|
@@ -306508,14 +306720,14 @@ var index_repo_exports = {};
|
|
|
306508
306720
|
__export(index_repo_exports, {
|
|
306509
306721
|
indexRepoCommand: () => indexRepoCommand
|
|
306510
306722
|
});
|
|
306511
|
-
import { resolve as
|
|
306512
|
-
import { existsSync as
|
|
306723
|
+
import { resolve as resolve36 } from "node:path";
|
|
306724
|
+
import { existsSync as existsSync61, statSync as statSync17 } from "node:fs";
|
|
306513
306725
|
import { cwd as cwd2 } from "node:process";
|
|
306514
306726
|
async function indexRepoCommand(opts, _config2) {
|
|
306515
|
-
const repoRoot =
|
|
306727
|
+
const repoRoot = resolve36(opts.repoPath ?? cwd2());
|
|
306516
306728
|
printHeader("Index Repository");
|
|
306517
306729
|
printInfo(`Indexing: ${repoRoot}`);
|
|
306518
|
-
if (!
|
|
306730
|
+
if (!existsSync61(repoRoot)) {
|
|
306519
306731
|
printError(`Path does not exist: ${repoRoot}`);
|
|
306520
306732
|
process.exit(1);
|
|
306521
306733
|
}
|
|
@@ -306767,8 +306979,8 @@ var config_exports2 = {};
|
|
|
306767
306979
|
__export(config_exports2, {
|
|
306768
306980
|
configCommand: () => configCommand
|
|
306769
306981
|
});
|
|
306770
|
-
import { join as
|
|
306771
|
-
import { homedir as
|
|
306982
|
+
import { join as join80, resolve as resolve37 } from "node:path";
|
|
306983
|
+
import { homedir as homedir22 } from "node:os";
|
|
306772
306984
|
import { cwd as cwd3 } from "node:process";
|
|
306773
306985
|
function redactIfSensitive(key, value2) {
|
|
306774
306986
|
if (SENSITIVE_KEYS.has(key) && typeof value2 === "string" && value2.length > 0) {
|
|
@@ -306800,7 +307012,7 @@ async function configCommand(opts, config) {
|
|
|
306800
307012
|
return handleShow(opts, config);
|
|
306801
307013
|
}
|
|
306802
307014
|
function handleShow(opts, config) {
|
|
306803
|
-
const repoRoot =
|
|
307015
|
+
const repoRoot = resolve37(opts.repoPath ?? cwd3());
|
|
306804
307016
|
printHeader("Configuration");
|
|
306805
307017
|
const resolved = resolveSettings(repoRoot);
|
|
306806
307018
|
printSection("Core Inference");
|
|
@@ -306850,7 +307062,7 @@ function handleShow(opts, config) {
|
|
|
306850
307062
|
}
|
|
306851
307063
|
}
|
|
306852
307064
|
printSection("Config File");
|
|
306853
|
-
printInfo(`~/.open-agents/config.json (${
|
|
307065
|
+
printInfo(`~/.open-agents/config.json (${join80(homedir22(), ".open-agents", "config.json")})`);
|
|
306854
307066
|
printSection("Priority Chain");
|
|
306855
307067
|
printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
|
|
306856
307068
|
printInfo(" 2. Project .oa/settings.json (--local)");
|
|
@@ -306883,13 +307095,13 @@ function handleSet(opts, _config2) {
|
|
|
306883
307095
|
process.exit(1);
|
|
306884
307096
|
}
|
|
306885
307097
|
if (opts.local) {
|
|
306886
|
-
const repoRoot =
|
|
307098
|
+
const repoRoot = resolve37(opts.repoPath ?? cwd3());
|
|
306887
307099
|
try {
|
|
306888
307100
|
initOaDirectory(repoRoot);
|
|
306889
307101
|
const coerced = coerceForSettings(key, value2);
|
|
306890
307102
|
saveProjectSettings(repoRoot, { [key]: coerced });
|
|
306891
307103
|
printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value2)}`);
|
|
306892
|
-
printInfo(`Saved to ${
|
|
307104
|
+
printInfo(`Saved to ${join80(repoRoot, ".oa", "settings.json")}`);
|
|
306893
307105
|
printInfo("This override applies only when running in this workspace.");
|
|
306894
307106
|
} catch (err) {
|
|
306895
307107
|
printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -306997,14 +307209,14 @@ async function serveCommand(opts, config) {
|
|
|
306997
307209
|
printInfo(`Backend: ${config.backendType} (${ollamaUrl})`);
|
|
306998
307210
|
try {
|
|
306999
307211
|
const server = startApiServer({ port, ollamaUrl });
|
|
307000
|
-
await new Promise((
|
|
307212
|
+
await new Promise((resolve38) => {
|
|
307001
307213
|
process.on("SIGINT", () => {
|
|
307002
307214
|
server.close();
|
|
307003
|
-
|
|
307215
|
+
resolve38();
|
|
307004
307216
|
});
|
|
307005
307217
|
process.on("SIGTERM", () => {
|
|
307006
307218
|
server.close();
|
|
307007
|
-
|
|
307219
|
+
resolve38();
|
|
307008
307220
|
});
|
|
307009
307221
|
});
|
|
307010
307222
|
} catch (err) {
|
|
@@ -307032,8 +307244,8 @@ __export(eval_exports, {
|
|
|
307032
307244
|
evalCommand: () => evalCommand
|
|
307033
307245
|
});
|
|
307034
307246
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
307035
|
-
import { mkdirSync as
|
|
307036
|
-
import { join as
|
|
307247
|
+
import { mkdirSync as mkdirSync34, writeFileSync as writeFileSync32 } from "node:fs";
|
|
307248
|
+
import { join as join81 } from "node:path";
|
|
307037
307249
|
async function evalCommand(opts, config) {
|
|
307038
307250
|
const suiteName = opts.suite ?? "basic";
|
|
307039
307251
|
const suite = SUITES[suiteName];
|
|
@@ -307158,9 +307370,9 @@ async function evalCommand(opts, config) {
|
|
|
307158
307370
|
process.exit(failed > 0 ? 1 : 0);
|
|
307159
307371
|
}
|
|
307160
307372
|
function createTempEvalRepo() {
|
|
307161
|
-
const dir =
|
|
307162
|
-
|
|
307163
|
-
|
|
307373
|
+
const dir = join81(tmpdir10(), `open-agents-eval-${Date.now()}`);
|
|
307374
|
+
mkdirSync34(dir, { recursive: true });
|
|
307375
|
+
writeFileSync32(join81(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
|
|
307164
307376
|
return dir;
|
|
307165
307377
|
}
|
|
307166
307378
|
var BASIC_SUITE, FULL_SUITE, SUITES;
|
|
@@ -307220,7 +307432,7 @@ init_updater();
|
|
|
307220
307432
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
307221
307433
|
import { createRequire as createRequire6 } from "node:module";
|
|
307222
307434
|
import { fileURLToPath as fileURLToPath16 } from "node:url";
|
|
307223
|
-
import { dirname as dirname24, join as
|
|
307435
|
+
import { dirname as dirname24, join as join82 } from "node:path";
|
|
307224
307436
|
|
|
307225
307437
|
// packages/cli/dist/cli.js
|
|
307226
307438
|
import { createInterface } from "node:readline";
|
|
@@ -307327,7 +307539,7 @@ init_output();
|
|
|
307327
307539
|
function getVersion5() {
|
|
307328
307540
|
try {
|
|
307329
307541
|
const require3 = createRequire6(import.meta.url);
|
|
307330
|
-
const pkgPath =
|
|
307542
|
+
const pkgPath = join82(dirname24(fileURLToPath16(import.meta.url)), "..", "package.json");
|
|
307331
307543
|
const pkg = require3(pkgPath);
|
|
307332
307544
|
return pkg.version;
|
|
307333
307545
|
} catch {
|
|
@@ -307602,12 +307814,12 @@ function crashLog(label, err) {
|
|
|
307602
307814
|
const logLine = `[${timestamp}] ${label}: ${msg}
|
|
307603
307815
|
`;
|
|
307604
307816
|
try {
|
|
307605
|
-
const { appendFileSync: appendFileSync7, mkdirSync:
|
|
307606
|
-
const { join:
|
|
307607
|
-
const { homedir:
|
|
307608
|
-
const logDir =
|
|
307609
|
-
|
|
307610
|
-
appendFileSync7(
|
|
307817
|
+
const { appendFileSync: appendFileSync7, mkdirSync: mkdirSync35 } = __require("node:fs");
|
|
307818
|
+
const { join: join83 } = __require("node:path");
|
|
307819
|
+
const { homedir: homedir23 } = __require("node:os");
|
|
307820
|
+
const logDir = join83(homedir23(), ".open-agents");
|
|
307821
|
+
mkdirSync35(logDir, { recursive: true });
|
|
307822
|
+
appendFileSync7(join83(logDir, "crash.log"), logLine);
|
|
307611
307823
|
} catch {
|
|
307612
307824
|
}
|
|
307613
307825
|
try {
|