open-agents-ai 0.187.134 → 0.187.136
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 +521 -231
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -242342,11 +242342,11 @@ var require_out = __commonJS({
|
|
|
242342
242342
|
async.read(path5, getSettings(optionsOrSettingsOrCallback), callback);
|
|
242343
242343
|
}
|
|
242344
242344
|
exports.stat = stat6;
|
|
242345
|
-
function
|
|
242345
|
+
function statSync21(path5, optionsOrSettings) {
|
|
242346
242346
|
const settings = getSettings(optionsOrSettings);
|
|
242347
242347
|
return sync.read(path5, settings);
|
|
242348
242348
|
}
|
|
242349
|
-
exports.statSync =
|
|
242349
|
+
exports.statSync = statSync21;
|
|
242350
242350
|
function getSettings(settingsOrOptions = {}) {
|
|
242351
242351
|
if (settingsOrOptions instanceof settings_1.default) {
|
|
242352
242352
|
return settingsOrOptions;
|
|
@@ -245714,7 +245714,7 @@ print("${sentinel}")
|
|
|
245714
245714
|
if (!this.proc || this.proc.killed) {
|
|
245715
245715
|
return { success: false, path: "" };
|
|
245716
245716
|
}
|
|
245717
|
-
const { mkdirSync: mkdirSync40, writeFileSync:
|
|
245717
|
+
const { mkdirSync: mkdirSync40, writeFileSync: writeFileSync38 } = await import("node:fs");
|
|
245718
245718
|
const sessionDir = join24(this.cwd, ".oa", "rlm");
|
|
245719
245719
|
mkdirSync40(sessionDir, { recursive: true });
|
|
245720
245720
|
const sessionPath = join24(sessionDir, "session.json");
|
|
@@ -245740,7 +245740,7 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
245740
245740
|
trajectoryCount: this.trajectory.length,
|
|
245741
245741
|
subCallCount: this.subCallCount
|
|
245742
245742
|
};
|
|
245743
|
-
|
|
245743
|
+
writeFileSync38(sessionPath, JSON.stringify(sessionData, null, 2), "utf8");
|
|
245744
245744
|
return { success: true, path: sessionPath };
|
|
245745
245745
|
}
|
|
245746
245746
|
} catch {
|
|
@@ -246349,7 +246349,7 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
246349
246349
|
/** Update memory scores based on task outcome. Called after task completion.
|
|
246350
246350
|
* Memories used in successful tasks get boosted. Memories present during failures get decayed. */
|
|
246351
246351
|
updateFromOutcomeSync(surfacedMemoryText, succeeded) {
|
|
246352
|
-
const { readFileSync: readFileSync56, writeFileSync:
|
|
246352
|
+
const { readFileSync: readFileSync56, writeFileSync: writeFileSync38, existsSync: existsSync71, mkdirSync: mkdirSync40 } = __require("node:fs");
|
|
246353
246353
|
const metaDir = join25(this.cwd, ".oa", "memory", "metabolism");
|
|
246354
246354
|
const storeFile = join25(metaDir, "store.json");
|
|
246355
246355
|
if (!existsSync71(storeFile))
|
|
@@ -246381,7 +246381,7 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
246381
246381
|
}
|
|
246382
246382
|
if (updated) {
|
|
246383
246383
|
mkdirSync40(metaDir, { recursive: true });
|
|
246384
|
-
|
|
246384
|
+
writeFileSync38(storeFile, JSON.stringify(store2, null, 2));
|
|
246385
246385
|
}
|
|
246386
246386
|
}
|
|
246387
246387
|
// ── Storage ──────────────────────────────────────────────────────────
|
|
@@ -246827,7 +246827,7 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
246827
246827
|
}
|
|
246828
246828
|
/** Archive a strategy variant synchronously (for task completion path) */
|
|
246829
246829
|
archiveVariantSync(strategy, outcome, tags = []) {
|
|
246830
|
-
const { readFileSync: readFileSync56, writeFileSync:
|
|
246830
|
+
const { readFileSync: readFileSync56, writeFileSync: writeFileSync38, existsSync: existsSync71, mkdirSync: mkdirSync40 } = __require("node:fs");
|
|
246831
246831
|
const dir = join27(this.cwd, ".oa", "arche");
|
|
246832
246832
|
const archiveFile = join27(dir, "variants.json");
|
|
246833
246833
|
let variants = [];
|
|
@@ -246849,7 +246849,7 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
246849
246849
|
if (variants.length > 50)
|
|
246850
246850
|
variants = variants.slice(-50);
|
|
246851
246851
|
mkdirSync40(dir, { recursive: true });
|
|
246852
|
-
|
|
246852
|
+
writeFileSync38(archiveFile, JSON.stringify(variants, null, 2));
|
|
246853
246853
|
}
|
|
246854
246854
|
async saveArchive(variants) {
|
|
246855
246855
|
const dir = join27(this.cwd, ".oa", "arche");
|
|
@@ -253972,16 +253972,20 @@ var init_process_health = __esm({
|
|
|
253972
253972
|
|
|
253973
253973
|
// packages/execution/dist/tools/camera-capture.js
|
|
253974
253974
|
import { execSync as execSync27 } from "node:child_process";
|
|
253975
|
-
import { readFileSync as readFileSync21, unlinkSync as unlinkSync5, existsSync as existsSync28, mkdirSync as mkdirSync10 } from "node:fs";
|
|
253975
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync11, unlinkSync as unlinkSync5, existsSync as existsSync28, mkdirSync as mkdirSync10, statSync as statSync10 } from "node:fs";
|
|
253976
253976
|
import { join as join44 } from "node:path";
|
|
253977
253977
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
253978
|
-
var CameraCaptureTool;
|
|
253978
|
+
var KANDAO_USB_VENDORS, QOOCAM_WIFI_PASSWORD, QOOCAM_DEFAULT_IP, OSC_TIMEOUT, CameraCaptureTool;
|
|
253979
253979
|
var init_camera_capture = __esm({
|
|
253980
253980
|
"packages/execution/dist/tools/camera-capture.js"() {
|
|
253981
253981
|
"use strict";
|
|
253982
|
+
KANDAO_USB_VENDORS = ["12d1", "2aad"];
|
|
253983
|
+
QOOCAM_WIFI_PASSWORD = "12345678";
|
|
253984
|
+
QOOCAM_DEFAULT_IP = "192.168.173.1";
|
|
253985
|
+
OSC_TIMEOUT = 15e3;
|
|
253982
253986
|
CameraCaptureTool = class {
|
|
253983
253987
|
name = "camera_capture";
|
|
253984
|
-
description = "Access system cameras to capture images. Actions: 'list' to enumerate cameras, 'capture' to grab a JPEG frame, 'info' to query camera capabilities. Use this when you need to SEE the physical environment \u2014 take a photo, check what's on a desk, read a whiteboard, inspect hardware, or observe any real-world scene. The captured image can
|
|
253988
|
+
description = "Access system cameras to capture images. Supports USB webcams (v4l2) AND Kandao QooCam 8K/Pro 360 cameras (auto-connects via WiFi). Actions: 'list' to enumerate all cameras, 'capture' to grab a JPEG frame, 'info' to query camera capabilities. Use this when you need to SEE the physical environment \u2014 take a photo, check what's on a desk, read a whiteboard, inspect hardware, or observe any real-world scene. The captured image can be analyzed with vision tools.";
|
|
253985
253989
|
parameters = {
|
|
253986
253990
|
type: "object",
|
|
253987
253991
|
properties: {
|
|
@@ -253992,15 +253996,15 @@ var init_camera_capture = __esm({
|
|
|
253992
253996
|
},
|
|
253993
253997
|
device: {
|
|
253994
253998
|
type: "string",
|
|
253995
|
-
description: "Camera device path (e.g. /dev/video0). Default:
|
|
253999
|
+
description: "Camera device path (e.g. /dev/video0) or 'qoocam' for the QooCam 360 camera. Default: auto-detect best camera."
|
|
253996
254000
|
},
|
|
253997
254001
|
width: {
|
|
253998
254002
|
type: "number",
|
|
253999
|
-
description: "Capture width in pixels (default: 1280)"
|
|
254003
|
+
description: "Capture width in pixels (default: 1280 for USB, native for QooCam)"
|
|
254000
254004
|
},
|
|
254001
254005
|
height: {
|
|
254002
254006
|
type: "number",
|
|
254003
|
-
description: "Capture height in pixels (default: 720)"
|
|
254007
|
+
description: "Capture height in pixels (default: 720 for USB, native for QooCam)"
|
|
254004
254008
|
},
|
|
254005
254009
|
output_path: {
|
|
254006
254010
|
type: "string",
|
|
@@ -254015,11 +254019,11 @@ var init_camera_capture = __esm({
|
|
|
254015
254019
|
try {
|
|
254016
254020
|
switch (action) {
|
|
254017
254021
|
case "list":
|
|
254018
|
-
return this.listCameras(start2);
|
|
254022
|
+
return await this.listCameras(start2);
|
|
254019
254023
|
case "capture":
|
|
254020
|
-
return this.captureFrame(args, start2);
|
|
254024
|
+
return await this.captureFrame(args, start2);
|
|
254021
254025
|
case "info":
|
|
254022
|
-
return this.cameraInfo(args, start2);
|
|
254026
|
+
return await this.cameraInfo(args, start2);
|
|
254023
254027
|
default:
|
|
254024
254028
|
return { success: false, output: "", error: `Unknown action: ${action}. Use list, capture, or info.`, durationMs: performance.now() - start2 };
|
|
254025
254029
|
}
|
|
@@ -254027,7 +254031,74 @@ var init_camera_capture = __esm({
|
|
|
254027
254031
|
return { success: false, output: "", error: `camera_capture error: ${err instanceof Error ? err.message : String(err)}`, durationMs: performance.now() - start2 };
|
|
254028
254032
|
}
|
|
254029
254033
|
}
|
|
254030
|
-
|
|
254034
|
+
// =========================================================================
|
|
254035
|
+
// List cameras — v4l2 + QooCam discovery
|
|
254036
|
+
// =========================================================================
|
|
254037
|
+
async listCameras(start2) {
|
|
254038
|
+
const cameras = [];
|
|
254039
|
+
const v4l2 = this.discoverV4l2Devices();
|
|
254040
|
+
for (const d2 of v4l2) {
|
|
254041
|
+
cameras.push(` ${d2.device}: ${d2.name} (${d2.driver}) [v4l2]`);
|
|
254042
|
+
}
|
|
254043
|
+
const qoocam = await this.discoverQooCam();
|
|
254044
|
+
if (qoocam.found) {
|
|
254045
|
+
const status = qoocam.connected ? `connected at ${qoocam.ip}, battery ${qoocam.battery ?? "?"}%` : qoocam.ssid ? `WiFi available: ${qoocam.ssid} (use device='qoocam' to auto-connect)` : `USB detected but not connected via WiFi`;
|
|
254046
|
+
cameras.push(` qoocam: ${qoocam.model || "QooCam 8K"} \u2014 ${status} [osc]`);
|
|
254047
|
+
}
|
|
254048
|
+
if (cameras.length === 0) {
|
|
254049
|
+
return {
|
|
254050
|
+
success: true,
|
|
254051
|
+
output: "No cameras found. Connect a USB camera, or power on a QooCam with WiFi hotspot enabled.",
|
|
254052
|
+
durationMs: performance.now() - start2
|
|
254053
|
+
};
|
|
254054
|
+
}
|
|
254055
|
+
return {
|
|
254056
|
+
success: true,
|
|
254057
|
+
output: `Found ${cameras.length} camera(s):
|
|
254058
|
+
${cameras.join("\n")}`,
|
|
254059
|
+
durationMs: performance.now() - start2
|
|
254060
|
+
};
|
|
254061
|
+
}
|
|
254062
|
+
// =========================================================================
|
|
254063
|
+
// Capture frame — auto-selects v4l2 or QooCam
|
|
254064
|
+
// =========================================================================
|
|
254065
|
+
async captureFrame(args, start2) {
|
|
254066
|
+
const device = args["device"] || "";
|
|
254067
|
+
const outputPath = args["output_path"];
|
|
254068
|
+
if (device === "qoocam" || device.startsWith("qoocam")) {
|
|
254069
|
+
return this.captureQooCam(args, start2);
|
|
254070
|
+
}
|
|
254071
|
+
const v4l2Device = device || this.findFirstV4l2Camera();
|
|
254072
|
+
if (!v4l2Device) {
|
|
254073
|
+
const qoocam = await this.discoverQooCam();
|
|
254074
|
+
if (qoocam.found) {
|
|
254075
|
+
return this.captureQooCam(args, start2);
|
|
254076
|
+
}
|
|
254077
|
+
return { success: false, output: "", error: "No camera found. Connect a USB camera or enable QooCam WiFi hotspot.", durationMs: performance.now() - start2 };
|
|
254078
|
+
}
|
|
254079
|
+
return this.captureV4l2(v4l2Device, args, start2);
|
|
254080
|
+
}
|
|
254081
|
+
// =========================================================================
|
|
254082
|
+
// Camera info
|
|
254083
|
+
// =========================================================================
|
|
254084
|
+
async cameraInfo(args, start2) {
|
|
254085
|
+
const device = args["device"] || "";
|
|
254086
|
+
if (device === "qoocam" || device.startsWith("qoocam")) {
|
|
254087
|
+
return this.qoocamInfo(start2);
|
|
254088
|
+
}
|
|
254089
|
+
const v4l2Device = device || this.findFirstV4l2Camera();
|
|
254090
|
+
if (!v4l2Device) {
|
|
254091
|
+
const qoocam = await this.discoverQooCam();
|
|
254092
|
+
if (qoocam.found)
|
|
254093
|
+
return this.qoocamInfo(start2);
|
|
254094
|
+
return { success: false, output: "", error: "No camera found.", durationMs: performance.now() - start2 };
|
|
254095
|
+
}
|
|
254096
|
+
return this.v4l2Info(v4l2Device, start2);
|
|
254097
|
+
}
|
|
254098
|
+
// =========================================================================
|
|
254099
|
+
// V4L2 backend (standard USB/CSI cameras)
|
|
254100
|
+
// =========================================================================
|
|
254101
|
+
discoverV4l2Devices() {
|
|
254031
254102
|
const devices = [];
|
|
254032
254103
|
try {
|
|
254033
254104
|
const devs = execSync27("ls /dev/video* 2>/dev/null", { encoding: "utf8", timeout: 5e3 }).trim().split("\n").filter(Boolean);
|
|
@@ -254055,26 +254126,17 @@ var init_camera_capture = __esm({
|
|
|
254055
254126
|
}
|
|
254056
254127
|
} catch {
|
|
254057
254128
|
}
|
|
254058
|
-
|
|
254059
|
-
return {
|
|
254060
|
-
success: true,
|
|
254061
|
-
output: "No cameras found. Connect a USB camera or enable a built-in camera.",
|
|
254062
|
-
durationMs: performance.now() - start2
|
|
254063
|
-
};
|
|
254064
|
-
}
|
|
254065
|
-
const lines = devices.map((d2) => ` ${d2.device}: ${d2.name} (${d2.driver})`);
|
|
254066
|
-
return {
|
|
254067
|
-
success: true,
|
|
254068
|
-
output: `Found ${devices.length} camera(s):
|
|
254069
|
-
${lines.join("\n")}`,
|
|
254070
|
-
durationMs: performance.now() - start2
|
|
254071
|
-
};
|
|
254129
|
+
return devices;
|
|
254072
254130
|
}
|
|
254073
|
-
|
|
254074
|
-
|
|
254075
|
-
|
|
254076
|
-
return
|
|
254131
|
+
findFirstV4l2Camera() {
|
|
254132
|
+
try {
|
|
254133
|
+
const devs = execSync27("ls /dev/video* 2>/dev/null", { encoding: "utf8", timeout: 3e3 }).trim().split("\n");
|
|
254134
|
+
return devs[0] || null;
|
|
254135
|
+
} catch {
|
|
254136
|
+
return null;
|
|
254077
254137
|
}
|
|
254138
|
+
}
|
|
254139
|
+
captureV4l2(device, args, start2) {
|
|
254078
254140
|
const width = args["width"] || 1280;
|
|
254079
254141
|
const height = args["height"] || 720;
|
|
254080
254142
|
const outputPath = args["output_path"];
|
|
@@ -254097,7 +254159,6 @@ ${lines.join("\n")}`,
|
|
|
254097
254159
|
"1",
|
|
254098
254160
|
"-q:v",
|
|
254099
254161
|
"2",
|
|
254100
|
-
// JPEG quality (2 = high quality)
|
|
254101
254162
|
"-y",
|
|
254102
254163
|
tempFile
|
|
254103
254164
|
].join(" ");
|
|
@@ -254106,42 +254167,14 @@ ${lines.join("\n")}`,
|
|
|
254106
254167
|
} catch (err) {
|
|
254107
254168
|
const msg = err instanceof Error ? err.message : String(err);
|
|
254108
254169
|
if (msg.includes("Device or resource busy")) {
|
|
254109
|
-
return { success: false, output: "", error: `Camera ${device} is busy \u2014
|
|
254170
|
+
return { success: false, output: "", error: `Camera ${device} is busy \u2014 close other camera apps.`, durationMs: performance.now() - start2 };
|
|
254110
254171
|
}
|
|
254111
254172
|
return { success: false, output: "", error: `Failed to capture from ${device}: ${msg.slice(0, 300)}`, durationMs: performance.now() - start2 };
|
|
254112
254173
|
}
|
|
254113
|
-
|
|
254114
|
-
return { success: false, output: "", error: `Capture produced no output file. Camera may not support ${width}x${height}.`, durationMs: performance.now() - start2 };
|
|
254115
|
-
}
|
|
254116
|
-
if (outputPath) {
|
|
254117
|
-
return {
|
|
254118
|
-
success: true,
|
|
254119
|
-
output: `Frame captured and saved to: ${outputPath}`,
|
|
254120
|
-
durationMs: performance.now() - start2
|
|
254121
|
-
};
|
|
254122
|
-
}
|
|
254123
|
-
const data = readFileSync21(tempFile);
|
|
254124
|
-
try {
|
|
254125
|
-
unlinkSync5(tempFile);
|
|
254126
|
-
} catch {
|
|
254127
|
-
}
|
|
254128
|
-
const base642 = data.toString("base64");
|
|
254129
|
-
const sizeKB = Math.round(data.length / 1024);
|
|
254130
|
-
return {
|
|
254131
|
-
success: true,
|
|
254132
|
-
output: `Captured ${width}x${height} frame from ${device} (${sizeKB}KB JPEG).
|
|
254133
|
-
|
|
254134
|
-
Base64 image data (use with vision tools):
|
|
254135
|
-
data:image/jpeg;base64,${base642}`,
|
|
254136
|
-
durationMs: performance.now() - start2
|
|
254137
|
-
};
|
|
254174
|
+
return this.returnCapturedFile(tempFile, `${width}x${height}`, device, outputPath, start2);
|
|
254138
254175
|
}
|
|
254139
|
-
|
|
254140
|
-
|
|
254141
|
-
if (!device) {
|
|
254142
|
-
return { success: false, output: "", error: "No camera device found.", durationMs: performance.now() - start2 };
|
|
254143
|
-
}
|
|
254144
|
-
let info = `Camera: ${device}
|
|
254176
|
+
v4l2Info(device, start2) {
|
|
254177
|
+
let info = `Camera: ${device} [v4l2]
|
|
254145
254178
|
`;
|
|
254146
254179
|
try {
|
|
254147
254180
|
const formats = execSync27(`v4l2-ctl -d ${device} --list-formats-ext 2>/dev/null`, { encoding: "utf8", timeout: 5e3 });
|
|
@@ -254152,26 +254185,275 @@ data:image/jpeg;base64,${base642}`,
|
|
|
254152
254185
|
const lines = probe.split("\n").filter((l2) => l2.includes("Raw") || l2.includes("Compressed") || l2.includes("video4linux2"));
|
|
254153
254186
|
info += "\nFormats (ffmpeg probe):\n" + (lines.length > 0 ? lines.join("\n") : "Could not query formats");
|
|
254154
254187
|
} catch {
|
|
254155
|
-
info += "\nCould not query camera capabilities
|
|
254188
|
+
info += "\nCould not query camera capabilities";
|
|
254156
254189
|
}
|
|
254157
254190
|
}
|
|
254158
254191
|
return { success: true, output: info, durationMs: performance.now() - start2 };
|
|
254159
254192
|
}
|
|
254160
|
-
|
|
254193
|
+
// =========================================================================
|
|
254194
|
+
// QooCam OSC backend (WiFi 360 camera)
|
|
254195
|
+
// =========================================================================
|
|
254196
|
+
/** Discover QooCam: check USB presence, scan WiFi for .OSC SSID, probe if connected */
|
|
254197
|
+
async discoverQooCam() {
|
|
254198
|
+
let usbDetected = false;
|
|
254161
254199
|
try {
|
|
254162
|
-
const
|
|
254163
|
-
|
|
254200
|
+
const lsusb = execSync27("lsusb 2>/dev/null", { encoding: "utf8", timeout: 5e3 });
|
|
254201
|
+
for (const vendor of KANDAO_USB_VENDORS) {
|
|
254202
|
+
if (lsusb.toLowerCase().includes(vendor)) {
|
|
254203
|
+
usbDetected = true;
|
|
254204
|
+
break;
|
|
254205
|
+
}
|
|
254206
|
+
}
|
|
254207
|
+
if (lsusb.toLowerCase().includes("kandao") || lsusb.toLowerCase().includes("qoocam"))
|
|
254208
|
+
usbDetected = true;
|
|
254164
254209
|
} catch {
|
|
254165
|
-
|
|
254210
|
+
}
|
|
254211
|
+
let ssid = null;
|
|
254212
|
+
try {
|
|
254213
|
+
const wifiList = execSync27("nmcli device wifi list 2>/dev/null", { encoding: "utf8", timeout: 1e4 });
|
|
254214
|
+
const oscMatch = wifiList.match(/\b(QooCam[^\s]*\.OSC)\b/i);
|
|
254215
|
+
if (oscMatch)
|
|
254216
|
+
ssid = oscMatch[1];
|
|
254217
|
+
} catch {
|
|
254218
|
+
}
|
|
254219
|
+
let connected = false;
|
|
254220
|
+
let ip = QOOCAM_DEFAULT_IP;
|
|
254221
|
+
try {
|
|
254222
|
+
const activeConns = execSync27("nmcli connection show --active 2>/dev/null", { encoding: "utf8", timeout: 5e3 });
|
|
254223
|
+
if (activeConns.toLowerCase().includes("qoocam") || activeConns.includes(".OSC")) {
|
|
254224
|
+
connected = true;
|
|
254225
|
+
}
|
|
254226
|
+
} catch {
|
|
254227
|
+
}
|
|
254228
|
+
let model;
|
|
254229
|
+
let battery;
|
|
254230
|
+
if (connected) {
|
|
254231
|
+
try {
|
|
254232
|
+
const info = await this.oscFetch("GET", "/osc/info");
|
|
254233
|
+
model = info?.model;
|
|
254234
|
+
} catch {
|
|
254235
|
+
connected = false;
|
|
254236
|
+
}
|
|
254237
|
+
}
|
|
254238
|
+
if (connected) {
|
|
254239
|
+
try {
|
|
254240
|
+
const state = await this.oscFetch("POST", "/osc/state");
|
|
254241
|
+
battery = state?.state?.batteryLevel != null ? Math.round(state.state.batteryLevel * 100) : void 0;
|
|
254242
|
+
} catch {
|
|
254243
|
+
}
|
|
254244
|
+
}
|
|
254245
|
+
return {
|
|
254246
|
+
found: usbDetected || ssid != null || connected,
|
|
254247
|
+
connected,
|
|
254248
|
+
ip: connected ? ip : void 0,
|
|
254249
|
+
ssid: ssid ?? void 0,
|
|
254250
|
+
model,
|
|
254251
|
+
battery
|
|
254252
|
+
};
|
|
254253
|
+
}
|
|
254254
|
+
/** Connect to QooCam WiFi hotspot if not already connected */
|
|
254255
|
+
connectQooCamWiFi() {
|
|
254256
|
+
try {
|
|
254257
|
+
const active = execSync27("nmcli connection show --active 2>/dev/null", { encoding: "utf8", timeout: 5e3 });
|
|
254258
|
+
if (active.toLowerCase().includes("qoocam") || active.includes(".OSC")) {
|
|
254259
|
+
try {
|
|
254260
|
+
execSync27(`ping -c 1 -W 2 ${QOOCAM_DEFAULT_IP}`, { timeout: 5e3, stdio: "pipe" });
|
|
254261
|
+
return { connected: true };
|
|
254262
|
+
} catch {
|
|
254263
|
+
}
|
|
254264
|
+
}
|
|
254265
|
+
} catch {
|
|
254266
|
+
}
|
|
254267
|
+
let ssid = null;
|
|
254268
|
+
try {
|
|
254269
|
+
execSync27("nmcli device wifi rescan 2>/dev/null", { timeout: 5e3, stdio: "pipe" });
|
|
254270
|
+
execSync27("sleep 2", { timeout: 5e3 });
|
|
254271
|
+
const wifiList = execSync27("nmcli device wifi list 2>/dev/null", { encoding: "utf8", timeout: 1e4 });
|
|
254272
|
+
const oscMatch = wifiList.match(/\b(QooCam[^\s]*\.OSC)\b/i);
|
|
254273
|
+
if (oscMatch)
|
|
254274
|
+
ssid = oscMatch[1];
|
|
254275
|
+
} catch {
|
|
254276
|
+
}
|
|
254277
|
+
if (!ssid) {
|
|
254278
|
+
return { connected: false, error: "QooCam WiFi hotspot not found. Ensure the camera is powered on with WiFi in Hotspot mode." };
|
|
254279
|
+
}
|
|
254280
|
+
let wifiIface = "wlp69s0";
|
|
254281
|
+
try {
|
|
254282
|
+
const ifaces = execSync27("nmcli device status 2>/dev/null", { encoding: "utf8", timeout: 5e3 });
|
|
254283
|
+
const wifiLine = ifaces.split("\n").find((l2) => l2.includes("wifi") && !l2.includes("wifi-p2p"));
|
|
254284
|
+
if (wifiLine)
|
|
254285
|
+
wifiIface = wifiLine.trim().split(/\s+/)[0];
|
|
254286
|
+
} catch {
|
|
254287
|
+
}
|
|
254288
|
+
try {
|
|
254289
|
+
execSync27(`nmcli device wifi connect "${ssid}" password "${QOOCAM_WIFI_PASSWORD}" ifname ${wifiIface}`, { encoding: "utf8", timeout: 3e4, stdio: "pipe" });
|
|
254290
|
+
} catch (err) {
|
|
254291
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
254292
|
+
return { connected: false, error: `Failed to connect to ${ssid}: ${msg.slice(0, 200)}` };
|
|
254293
|
+
}
|
|
254294
|
+
try {
|
|
254295
|
+
execSync27("sleep 2", { timeout: 5e3 });
|
|
254296
|
+
execSync27(`ping -c 1 -W 3 ${QOOCAM_DEFAULT_IP}`, { timeout: 8e3, stdio: "pipe" });
|
|
254297
|
+
return { connected: true };
|
|
254298
|
+
} catch {
|
|
254299
|
+
return { connected: false, error: `Connected to ${ssid} but camera not reachable at ${QOOCAM_DEFAULT_IP}` };
|
|
254166
254300
|
}
|
|
254167
254301
|
}
|
|
254302
|
+
/** Capture a frame from QooCam via OSC API */
|
|
254303
|
+
async captureQooCam(args, start2) {
|
|
254304
|
+
const outputPath = args["output_path"];
|
|
254305
|
+
const conn = this.connectQooCamWiFi();
|
|
254306
|
+
if (!conn.connected) {
|
|
254307
|
+
return { success: false, output: "", error: conn.error || "Could not connect to QooCam", durationMs: performance.now() - start2 };
|
|
254308
|
+
}
|
|
254309
|
+
try {
|
|
254310
|
+
const state = await this.oscFetch("POST", "/osc/state");
|
|
254311
|
+
const captureMode = state?.state?._captureMode;
|
|
254312
|
+
if (captureMode && captureMode !== "image") {
|
|
254313
|
+
await this.oscFetch("POST", "/osc/commands/execute", {
|
|
254314
|
+
name: "camera.setOptions",
|
|
254315
|
+
parameters: { options: { captureMode: "image" } }
|
|
254316
|
+
});
|
|
254317
|
+
}
|
|
254318
|
+
} catch {
|
|
254319
|
+
}
|
|
254320
|
+
let fileUrl;
|
|
254321
|
+
let width = 0;
|
|
254322
|
+
let height = 0;
|
|
254323
|
+
try {
|
|
254324
|
+
const result = await this.oscFetch("POST", "/osc/commands/execute", {
|
|
254325
|
+
name: "camera.takePicture"
|
|
254326
|
+
});
|
|
254327
|
+
if (result?.state === "error") {
|
|
254328
|
+
return { success: false, output: "", error: `QooCam capture failed: ${result.error?.message || JSON.stringify(result.error)}`, durationMs: performance.now() - start2 };
|
|
254329
|
+
}
|
|
254330
|
+
const entry = result?.results?.entries?.[0];
|
|
254331
|
+
if (!entry?.fileUrl) {
|
|
254332
|
+
return { success: false, output: "", error: "QooCam took a picture but returned no file URL", durationMs: performance.now() - start2 };
|
|
254333
|
+
}
|
|
254334
|
+
fileUrl = entry.fileUrl;
|
|
254335
|
+
width = entry.width || 0;
|
|
254336
|
+
height = entry.height || 0;
|
|
254337
|
+
} catch (err) {
|
|
254338
|
+
return { success: false, output: "", error: `QooCam OSC error: ${err instanceof Error ? err.message : String(err)}`, durationMs: performance.now() - start2 };
|
|
254339
|
+
}
|
|
254340
|
+
const captureDir = join44(tmpdir8(), "oa-camera");
|
|
254341
|
+
if (!existsSync28(captureDir))
|
|
254342
|
+
mkdirSync10(captureDir, { recursive: true });
|
|
254343
|
+
const tempFile = outputPath || join44(captureDir, `qoocam-${Date.now()}.jpg`);
|
|
254344
|
+
try {
|
|
254345
|
+
execSync27(`curl -s --connect-timeout 5 --max-time 30 "http://${QOOCAM_DEFAULT_IP}${fileUrl}" -o "${tempFile}"`, { timeout: 35e3, stdio: "pipe" });
|
|
254346
|
+
} catch (err) {
|
|
254347
|
+
return { success: false, output: "", error: `Failed to download frame from QooCam: ${err instanceof Error ? err.message : String(err)}`, durationMs: performance.now() - start2 };
|
|
254348
|
+
}
|
|
254349
|
+
const res = width && height ? `${width}x${height}` : "native";
|
|
254350
|
+
return this.returnCapturedFile(tempFile, res, "QooCam 8K (OSC/WiFi)", outputPath, start2);
|
|
254351
|
+
}
|
|
254352
|
+
/** Get QooCam info via OSC */
|
|
254353
|
+
async qoocamInfo(start2) {
|
|
254354
|
+
const conn = this.connectQooCamWiFi();
|
|
254355
|
+
if (!conn.connected) {
|
|
254356
|
+
return { success: false, output: "", error: conn.error || "Could not connect to QooCam", durationMs: performance.now() - start2 };
|
|
254357
|
+
}
|
|
254358
|
+
let info = "Camera: QooCam [OSC/WiFi]\n";
|
|
254359
|
+
try {
|
|
254360
|
+
const oscInfo = await this.oscFetch("GET", "/osc/info");
|
|
254361
|
+
info += ` Model: ${oscInfo.model || "unknown"}
|
|
254362
|
+
`;
|
|
254363
|
+
info += ` Manufacturer: ${oscInfo.manufacturer || "unknown"}
|
|
254364
|
+
`;
|
|
254365
|
+
info += ` Serial: ${oscInfo.serialNumber || "unknown"}
|
|
254366
|
+
`;
|
|
254367
|
+
info += ` Firmware: ${oscInfo.firmwareVersion || "unknown"}
|
|
254368
|
+
`;
|
|
254369
|
+
info += ` Gyro: ${oscInfo.gyro ?? "unknown"}
|
|
254370
|
+
`;
|
|
254371
|
+
info += ` HDR Merge: ${oscInfo._hdrMerge ?? "unknown"}
|
|
254372
|
+
`;
|
|
254373
|
+
info += ` Live 10-bit: ${oscInfo._live10Bit ?? "unknown"}
|
|
254374
|
+
`;
|
|
254375
|
+
} catch {
|
|
254376
|
+
info += " (could not query /osc/info)\n";
|
|
254377
|
+
}
|
|
254378
|
+
try {
|
|
254379
|
+
const oscState = await this.oscFetch("POST", "/osc/state");
|
|
254380
|
+
const s2 = oscState?.state || {};
|
|
254381
|
+
info += `
|
|
254382
|
+
Battery: ${s2.batteryLevel != null ? Math.round(s2.batteryLevel * 100) + "%" : "unknown"}`;
|
|
254383
|
+
info += ` ${s2._batteryCharging ? "(charging)" : ""}
|
|
254384
|
+
`;
|
|
254385
|
+
info += ` Mode: ${s2._captureMode || "unknown"}
|
|
254386
|
+
`;
|
|
254387
|
+
info += ` SD Card: ${s2._SDCardAvailable ? `${(s2._sdcardAvailableMemery ?? 0).toFixed(1)}GB free / ${(s2._sdcardTotalMemery ?? 0).toFixed(1)}GB total` : "not available"}
|
|
254388
|
+
`;
|
|
254389
|
+
info += ` Shooting: ${s2._isShooting ? "yes" : "no"}
|
|
254390
|
+
`;
|
|
254391
|
+
info += ` HDMI In: ${s2._hdmiIn ? "yes" : "no"}
|
|
254392
|
+
`;
|
|
254393
|
+
info += ` Live Mode: ${s2._liveProMode || "unknown"}
|
|
254394
|
+
`;
|
|
254395
|
+
} catch {
|
|
254396
|
+
info += " (could not query /osc/state)\n";
|
|
254397
|
+
}
|
|
254398
|
+
return { success: true, output: info, durationMs: performance.now() - start2 };
|
|
254399
|
+
}
|
|
254400
|
+
// =========================================================================
|
|
254401
|
+
// OSC HTTP helpers
|
|
254402
|
+
// =========================================================================
|
|
254403
|
+
async oscFetch(method, path5, body) {
|
|
254404
|
+
const url = `http://${QOOCAM_DEFAULT_IP}${path5}`;
|
|
254405
|
+
const opts = {
|
|
254406
|
+
method,
|
|
254407
|
+
headers: body ? { "Content-Type": "application/json" } : void 0,
|
|
254408
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
254409
|
+
signal: AbortSignal.timeout(OSC_TIMEOUT)
|
|
254410
|
+
};
|
|
254411
|
+
const resp = await fetch(url, opts);
|
|
254412
|
+
const text = await resp.text();
|
|
254413
|
+
try {
|
|
254414
|
+
return JSON.parse(text);
|
|
254415
|
+
} catch {
|
|
254416
|
+
return text;
|
|
254417
|
+
}
|
|
254418
|
+
}
|
|
254419
|
+
// =========================================================================
|
|
254420
|
+
// Shared helpers
|
|
254421
|
+
// =========================================================================
|
|
254422
|
+
returnCapturedFile(filePath, resolution, source, userOutputPath, start2) {
|
|
254423
|
+
if (!existsSync28(filePath)) {
|
|
254424
|
+
return { success: false, output: "", error: "Capture produced no output file.", durationMs: performance.now() - start2 };
|
|
254425
|
+
}
|
|
254426
|
+
const data = readFileSync21(filePath);
|
|
254427
|
+
const sizeKB = Math.round(data.length / 1024);
|
|
254428
|
+
if (userOutputPath) {
|
|
254429
|
+
return {
|
|
254430
|
+
success: true,
|
|
254431
|
+
output: `Captured ${resolution} frame from ${source} (${sizeKB}KB JPEG).
|
|
254432
|
+
Saved to: ${userOutputPath}`,
|
|
254433
|
+
durationMs: performance.now() - start2
|
|
254434
|
+
};
|
|
254435
|
+
}
|
|
254436
|
+
try {
|
|
254437
|
+
unlinkSync5(filePath);
|
|
254438
|
+
} catch {
|
|
254439
|
+
}
|
|
254440
|
+
const base642 = data.toString("base64");
|
|
254441
|
+
return {
|
|
254442
|
+
success: true,
|
|
254443
|
+
output: `Captured ${resolution} frame from ${source} (${sizeKB}KB JPEG).
|
|
254444
|
+
|
|
254445
|
+
Base64 image data (use with vision tools):
|
|
254446
|
+
data:image/jpeg;base64,${base642}`,
|
|
254447
|
+
durationMs: performance.now() - start2
|
|
254448
|
+
};
|
|
254449
|
+
}
|
|
254168
254450
|
};
|
|
254169
254451
|
}
|
|
254170
254452
|
});
|
|
254171
254453
|
|
|
254172
254454
|
// packages/execution/dist/tools/audio-capture.js
|
|
254173
254455
|
import { execSync as execSync28 } from "node:child_process";
|
|
254174
|
-
import { readFileSync as readFileSync22, unlinkSync as unlinkSync6, existsSync as existsSync29, mkdirSync as mkdirSync11, statSync as
|
|
254456
|
+
import { readFileSync as readFileSync22, unlinkSync as unlinkSync6, existsSync as existsSync29, mkdirSync as mkdirSync11, statSync as statSync11 } from "node:fs";
|
|
254175
254457
|
import { join as join45 } from "node:path";
|
|
254176
254458
|
import { tmpdir as tmpdir9 } from "node:os";
|
|
254177
254459
|
var AudioCaptureTool;
|
|
@@ -254344,7 +254626,7 @@ ${devices.join("\n")}`,
|
|
|
254344
254626
|
if (!existsSync29(tempFile)) {
|
|
254345
254627
|
return { success: false, output: "", error: "Recording produced no output. Device may not support the requested format.", durationMs: performance.now() - start2 };
|
|
254346
254628
|
}
|
|
254347
|
-
const fileSize =
|
|
254629
|
+
const fileSize = statSync11(tempFile).size;
|
|
254348
254630
|
const sizeKB = Math.round(fileSize / 1024);
|
|
254349
254631
|
return {
|
|
254350
254632
|
success: true,
|
|
@@ -254411,7 +254693,7 @@ Saved to: ${tempFile}`,
|
|
|
254411
254693
|
|
|
254412
254694
|
// packages/execution/dist/tools/audio-playback.js
|
|
254413
254695
|
import { execSync as execSync29 } from "node:child_process";
|
|
254414
|
-
import { existsSync as existsSync30, statSync as
|
|
254696
|
+
import { existsSync as existsSync30, statSync as statSync12 } from "node:fs";
|
|
254415
254697
|
var AudioPlaybackTool;
|
|
254416
254698
|
var init_audio_playback = __esm({
|
|
254417
254699
|
"packages/execution/dist/tools/audio-playback.js"() {
|
|
@@ -254483,7 +254765,7 @@ var init_audio_playback = __esm({
|
|
|
254483
254765
|
return { success: false, output: "", error: `Audio file not found: ${file}`, durationMs: performance.now() - start2 };
|
|
254484
254766
|
}
|
|
254485
254767
|
const device = args["device"] || "default";
|
|
254486
|
-
const size =
|
|
254768
|
+
const size = statSync12(file).size;
|
|
254487
254769
|
const ext = file.split(".").pop()?.toLowerCase() || "";
|
|
254488
254770
|
let cmd;
|
|
254489
254771
|
if (ext === "wav") {
|
|
@@ -256291,7 +256573,7 @@ var init_plugin_system = __esm({
|
|
|
256291
256573
|
});
|
|
256292
256574
|
|
|
256293
256575
|
// packages/execution/dist/tools/notebook-edit.js
|
|
256294
|
-
import { readFileSync as readFileSync25, writeFileSync as
|
|
256576
|
+
import { readFileSync as readFileSync25, writeFileSync as writeFileSync12, existsSync as existsSync34 } from "node:fs";
|
|
256295
256577
|
function readNotebook(path5) {
|
|
256296
256578
|
if (!existsSync34(path5))
|
|
256297
256579
|
return `File not found: ${path5}`;
|
|
@@ -256308,7 +256590,7 @@ function readNotebook(path5) {
|
|
|
256308
256590
|
}
|
|
256309
256591
|
}
|
|
256310
256592
|
function writeNotebook(path5, nb) {
|
|
256311
|
-
|
|
256593
|
+
writeFileSync12(path5, JSON.stringify(nb, null, 1) + "\n", "utf8");
|
|
256312
256594
|
}
|
|
256313
256595
|
function sourceToLines(source) {
|
|
256314
256596
|
const lines = source.split("\n");
|
|
@@ -256592,7 +256874,7 @@ var init_environment_snapshot = __esm({
|
|
|
256592
256874
|
|
|
256593
256875
|
// packages/execution/dist/tools/video-understand.js
|
|
256594
256876
|
import { execSync as execSync32 } from "node:child_process";
|
|
256595
|
-
import { existsSync as existsSync35, mkdirSync as mkdirSync13, writeFileSync as
|
|
256877
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync13, writeFileSync as writeFileSync13, readFileSync as readFileSync26, readdirSync as readdirSync8, unlinkSync as unlinkSync7 } from "node:fs";
|
|
256596
256878
|
import { join as join49, basename as basename11 } from "node:path";
|
|
256597
256879
|
import { createHash as createHash2 } from "node:crypto";
|
|
256598
256880
|
function isYouTubeUrl2(url) {
|
|
@@ -256762,7 +257044,7 @@ var init_video_understand = __esm({
|
|
|
256762
257044
|
for (const frame of frames.filter((f2) => !f2.isDuplicate)) {
|
|
256763
257045
|
const dest = join49(permanentDir, basename11(frame.path));
|
|
256764
257046
|
try {
|
|
256765
|
-
|
|
257047
|
+
writeFileSync13(dest, readFileSync26(frame.path));
|
|
256766
257048
|
frame.path = dest;
|
|
256767
257049
|
} catch {
|
|
256768
257050
|
}
|
|
@@ -256799,7 +257081,7 @@ var init_video_understand = __esm({
|
|
|
256799
257081
|
};
|
|
256800
257082
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
256801
257083
|
const resultFile = join49(outDir, `understanding-${timestamp}.json`);
|
|
256802
|
-
|
|
257084
|
+
writeFileSync13(resultFile, JSON.stringify(result, null, 2), "utf-8");
|
|
256803
257085
|
try {
|
|
256804
257086
|
const memDir = join49(this.workingDir, ".oa", "memory");
|
|
256805
257087
|
mkdirSync13(memDir, { recursive: true });
|
|
@@ -256822,7 +257104,7 @@ var init_video_understand = __esm({
|
|
|
256822
257104
|
});
|
|
256823
257105
|
if (indexEntries.length > 30)
|
|
256824
257106
|
indexEntries = indexEntries.slice(-30);
|
|
256825
|
-
|
|
257107
|
+
writeFileSync13(indexFile, JSON.stringify(indexEntries, null, 2), "utf-8");
|
|
256826
257108
|
const CHUNK_WINDOW = 30;
|
|
256827
257109
|
const transcriptFile = join49(memDir, "video-transcripts.json");
|
|
256828
257110
|
let transcriptEntries = {};
|
|
@@ -256853,7 +257135,7 @@ var init_video_understand = __esm({
|
|
|
256853
257135
|
Topic: ${segments.slice(0, 5).map((s2) => s2.text).join(" ").slice(0, 300)}`,
|
|
256854
257136
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
256855
257137
|
};
|
|
256856
|
-
|
|
257138
|
+
writeFileSync13(transcriptFile, JSON.stringify(transcriptEntries, null, 2), "utf-8");
|
|
256857
257139
|
} catch {
|
|
256858
257140
|
}
|
|
256859
257141
|
const lines = [];
|
|
@@ -257173,7 +257455,7 @@ var init_gitWorktree = __esm({
|
|
|
257173
257455
|
});
|
|
257174
257456
|
|
|
257175
257457
|
// packages/execution/dist/patchApplier.js
|
|
257176
|
-
import { readFileSync as readFileSync28, writeFileSync as
|
|
257458
|
+
import { readFileSync as readFileSync28, writeFileSync as writeFileSync14, existsSync as existsSync37, mkdirSync as mkdirSync14 } from "node:fs";
|
|
257177
257459
|
import { dirname as dirname14 } from "node:path";
|
|
257178
257460
|
import { spawn as spawn16 } from "node:child_process";
|
|
257179
257461
|
async function applyPatch(patch) {
|
|
@@ -257194,17 +257476,17 @@ function applyBlockReplace(patch) {
|
|
|
257194
257476
|
throw new Error(`Block not found in "${patch.filePath}": the oldContent string was not found in the file.`);
|
|
257195
257477
|
}
|
|
257196
257478
|
const updated = original.replace(patch.oldContent, patch.newContent);
|
|
257197
|
-
|
|
257479
|
+
writeFileSync14(patch.filePath, updated, "utf-8");
|
|
257198
257480
|
}
|
|
257199
257481
|
function applyRewrite(patch) {
|
|
257200
|
-
|
|
257482
|
+
writeFileSync14(patch.filePath, patch.newContent, "utf-8");
|
|
257201
257483
|
}
|
|
257202
257484
|
function applyNewFile(patch) {
|
|
257203
257485
|
if (existsSync37(patch.filePath)) {
|
|
257204
257486
|
throw new Error(`Cannot create new file: "${patch.filePath}" already exists.`);
|
|
257205
257487
|
}
|
|
257206
257488
|
mkdirSync14(dirname14(patch.filePath), { recursive: true });
|
|
257207
|
-
|
|
257489
|
+
writeFileSync14(patch.filePath, patch.newContent, "utf-8");
|
|
257208
257490
|
}
|
|
257209
257491
|
async function applyUnifiedDiff(patch) {
|
|
257210
257492
|
const { filePath, diff } = patch;
|
|
@@ -257561,7 +257843,7 @@ var init_buildRunner = __esm({
|
|
|
257561
257843
|
});
|
|
257562
257844
|
|
|
257563
257845
|
// packages/execution/dist/constraints.js
|
|
257564
|
-
import { existsSync as existsSync38, readFileSync as readFileSync29, writeFileSync as
|
|
257846
|
+
import { existsSync as existsSync38, readFileSync as readFileSync29, writeFileSync as writeFileSync15, mkdirSync as mkdirSync15 } from "node:fs";
|
|
257565
257847
|
import { join as join52 } from "node:path";
|
|
257566
257848
|
import { homedir as homedir14 } from "node:os";
|
|
257567
257849
|
function loadConstraints(projectRoot) {
|
|
@@ -257593,7 +257875,7 @@ function addProjectConstraint(projectRoot, constraint) {
|
|
|
257593
257875
|
}
|
|
257594
257876
|
data.constraints.push(constraint);
|
|
257595
257877
|
mkdirSync15(join52(projectRoot, ".oa"), { recursive: true });
|
|
257596
|
-
|
|
257878
|
+
writeFileSync15(path5, JSON.stringify(data, null, 2), "utf-8");
|
|
257597
257879
|
projectConstraints = data.constraints;
|
|
257598
257880
|
}
|
|
257599
257881
|
function getAllConstraints() {
|
|
@@ -261767,7 +262049,7 @@ ${body}`;
|
|
|
261767
262049
|
* Hannover reference: services/compact/apiMicrocompact.ts
|
|
261768
262050
|
* Research: arXiv:2307.03172 (Lost in the Middle — recent context matters most)
|
|
261769
262051
|
*/
|
|
261770
|
-
microcompact(messages2) {
|
|
262052
|
+
microcompact(messages2, recentToolResults) {
|
|
261771
262053
|
const tier = this.options.modelTier ?? "large";
|
|
261772
262054
|
const keepResults = tier === "small" ? 6 : tier === "medium" ? 10 : 20;
|
|
261773
262055
|
const toolResultIndices = [];
|
|
@@ -261793,6 +262075,8 @@ ${body}`;
|
|
|
261793
262075
|
cleared++;
|
|
261794
262076
|
}
|
|
261795
262077
|
if (cleared > 0) {
|
|
262078
|
+
if (recentToolResults)
|
|
262079
|
+
recentToolResults.clear();
|
|
261796
262080
|
this.emit({
|
|
261797
262081
|
type: "status",
|
|
261798
262082
|
content: `Microcompact: cleared ${cleared} old tool result(s), keeping ${keepResults} recent`,
|
|
@@ -262317,8 +262601,12 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
262317
262601
|
const strategy = this._pendingCompaction;
|
|
262318
262602
|
this._pendingCompaction = null;
|
|
262319
262603
|
compacted = await this.compactMessages(messages2, strategy, true);
|
|
262604
|
+
recentToolResults.clear();
|
|
262320
262605
|
} else {
|
|
262606
|
+
const prevLen = messages2.length;
|
|
262321
262607
|
compacted = await this.compactMessages(messages2);
|
|
262608
|
+
if (compacted.length < prevLen)
|
|
262609
|
+
recentToolResults.clear();
|
|
262322
262610
|
}
|
|
262323
262611
|
if (this.options.environmentProvider) {
|
|
262324
262612
|
try {
|
|
@@ -262329,7 +262617,7 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
262329
262617
|
} catch {
|
|
262330
262618
|
}
|
|
262331
262619
|
}
|
|
262332
|
-
this.microcompact(compacted);
|
|
262620
|
+
this.microcompact(compacted, recentToolResults);
|
|
262333
262621
|
const { maxOutputTokens: effectiveMaxTokens } = this.contextLimits();
|
|
262334
262622
|
const chatRequest = {
|
|
262335
262623
|
messages: compacted,
|
|
@@ -263553,11 +263841,11 @@ ${errOutput}`;
|
|
|
263553
263841
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
263554
263842
|
});
|
|
263555
263843
|
try {
|
|
263556
|
-
const { mkdirSync: mkdirSync40, writeFileSync:
|
|
263844
|
+
const { mkdirSync: mkdirSync40, writeFileSync: writeFileSync38 } = __require("node:fs");
|
|
263557
263845
|
const { join: join91 } = __require("node:path");
|
|
263558
263846
|
const resultsDir = join91(process.cwd(), ".oa", "tool-results");
|
|
263559
263847
|
mkdirSync40(resultsDir, { recursive: true });
|
|
263560
|
-
|
|
263848
|
+
writeFileSync38(join91(resultsDir, `${handleId}.txt`), `# Tool: ${toolName}
|
|
263561
263849
|
# Turn: ${turn}
|
|
263562
263850
|
# Timestamp: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
263563
263851
|
# Size: ${result.output.length} chars, ${lineCount} lines
|
|
@@ -263696,7 +263984,7 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
|
|
|
263696
263984
|
if (!this._workingDirectory)
|
|
263697
263985
|
return;
|
|
263698
263986
|
try {
|
|
263699
|
-
const { mkdirSync: mkdirSync40, writeFileSync:
|
|
263987
|
+
const { mkdirSync: mkdirSync40, writeFileSync: writeFileSync38 } = __require("node:fs");
|
|
263700
263988
|
const { join: join91 } = __require("node:path");
|
|
263701
263989
|
const sessionDir = join91(this._workingDirectory, ".oa", "session", this._sessionId);
|
|
263702
263990
|
mkdirSync40(sessionDir, { recursive: true });
|
|
@@ -263711,7 +263999,7 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
|
|
|
263711
263999
|
memexEntryCount: this._memexArchive.size,
|
|
263712
264000
|
fileRegistrySize: this._fileRegistry.size
|
|
263713
264001
|
};
|
|
263714
|
-
|
|
264002
|
+
writeFileSync38(join91(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
263715
264003
|
} catch {
|
|
263716
264004
|
}
|
|
263717
264005
|
}
|
|
@@ -265132,12 +265420,12 @@ ${result}`
|
|
|
265132
265420
|
let resizedBase64 = null;
|
|
265133
265421
|
try {
|
|
265134
265422
|
const { execSync: execSync46 } = await import("node:child_process");
|
|
265135
|
-
const { writeFileSync:
|
|
265423
|
+
const { writeFileSync: writeFileSync38, readFileSync: readFileSync56, unlinkSync: unlinkSync17 } = await import("node:fs");
|
|
265136
265424
|
const { join: join91 } = await import("node:path");
|
|
265137
265425
|
const { tmpdir: tmpdir14 } = await import("node:os");
|
|
265138
265426
|
const tmpIn = join91(tmpdir14(), `oa_img_in_${Date.now()}.png`);
|
|
265139
265427
|
const tmpOut = join91(tmpdir14(), `oa_img_out_${Date.now()}.jpg`);
|
|
265140
|
-
|
|
265428
|
+
writeFileSync38(tmpIn, buffer2);
|
|
265141
265429
|
const pyBin = process.platform === "win32" ? "python" : "python3";
|
|
265142
265430
|
const escapedIn = tmpIn.replace(/\\/g, "\\\\");
|
|
265143
265431
|
const escapedOut = tmpOut.replace(/\\/g, "\\\\");
|
|
@@ -265762,7 +266050,7 @@ var init_constraint_learner = __esm({
|
|
|
265762
266050
|
});
|
|
265763
266051
|
|
|
265764
266052
|
// packages/orchestrator/dist/nexusBackend.js
|
|
265765
|
-
import { existsSync as existsSync40, statSync as
|
|
266053
|
+
import { existsSync as existsSync40, statSync as statSync13, openSync, readSync, closeSync, unlinkSync as unlinkSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
265766
266054
|
import { watch as fsWatch } from "node:fs";
|
|
265767
266055
|
import { join as join56 } from "node:path";
|
|
265768
266056
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
@@ -265915,7 +266203,7 @@ var init_nexusBackend = __esm({
|
|
|
265915
266203
|
*/
|
|
265916
266204
|
async *chatCompletionStream(request) {
|
|
265917
266205
|
const streamFile = join56(tmpdir10(), `nexus-stream-${randomBytes14(6).toString("hex")}.jsonl`);
|
|
265918
|
-
|
|
266206
|
+
writeFileSync16(streamFile, "", "utf8");
|
|
265919
266207
|
const daemonArgs = {
|
|
265920
266208
|
model: this.model,
|
|
265921
266209
|
messages: JSON.stringify(request.messages),
|
|
@@ -266068,7 +266356,7 @@ var init_nexusBackend = __esm({
|
|
|
266068
266356
|
finish();
|
|
266069
266357
|
}, 50);
|
|
266070
266358
|
});
|
|
266071
|
-
const stat6 =
|
|
266359
|
+
const stat6 = statSync13(streamFile, { throwIfNoEntry: false });
|
|
266072
266360
|
if (!stat6 || stat6.size <= position)
|
|
266073
266361
|
continue;
|
|
266074
266362
|
const fd = openSync(streamFile, "r");
|
|
@@ -267561,7 +267849,7 @@ __export(listen_exports, {
|
|
|
267561
267849
|
waitForTranscribeCli: () => waitForTranscribeCli
|
|
267562
267850
|
});
|
|
267563
267851
|
import { spawn as spawn17, execSync as execSync34 } from "node:child_process";
|
|
267564
|
-
import { existsSync as existsSync41, mkdirSync as mkdirSync16, writeFileSync as
|
|
267852
|
+
import { existsSync as existsSync41, mkdirSync as mkdirSync16, writeFileSync as writeFileSync17, readdirSync as readdirSync9 } from "node:fs";
|
|
267565
267853
|
import { join as join57, dirname as dirname16 } from "node:path";
|
|
267566
267854
|
import { homedir as homedir15 } from "node:os";
|
|
267567
267855
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
@@ -268207,7 +268495,7 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
268207
268495
|
const transcriptDir = join57(outputDir, ".oa", "transcripts");
|
|
268208
268496
|
mkdirSync16(transcriptDir, { recursive: true });
|
|
268209
268497
|
const outFile = join57(transcriptDir, `${basename19(filePath)}.txt`);
|
|
268210
|
-
|
|
268498
|
+
writeFileSync17(outFile, result.text, "utf-8");
|
|
268211
268499
|
}
|
|
268212
268500
|
return {
|
|
268213
268501
|
text: result.text,
|
|
@@ -274233,7 +274521,7 @@ import { EventEmitter as EventEmitter5 } from "node:events";
|
|
|
274233
274521
|
import { randomBytes as randomBytes15 } from "node:crypto";
|
|
274234
274522
|
import { URL as URL2 } from "node:url";
|
|
274235
274523
|
import { loadavg, cpus as cpus2, totalmem as totalmem2, freemem as freemem2 } from "node:os";
|
|
274236
|
-
import { existsSync as existsSync42, readFileSync as readFileSync31, writeFileSync as
|
|
274524
|
+
import { existsSync as existsSync42, readFileSync as readFileSync31, writeFileSync as writeFileSync18, unlinkSync as unlinkSync9, mkdirSync as mkdirSync17, readdirSync as readdirSync10, statSync as statSync14 } from "node:fs";
|
|
274237
274525
|
import { join as join58 } from "node:path";
|
|
274238
274526
|
function cleanForwardHeaders(raw, targetHost) {
|
|
274239
274527
|
const out = {};
|
|
@@ -274268,7 +274556,7 @@ function readExposeState(stateDir) {
|
|
|
274268
274556
|
function writeExposeState(stateDir, state) {
|
|
274269
274557
|
try {
|
|
274270
274558
|
mkdirSync17(stateDir, { recursive: true });
|
|
274271
|
-
|
|
274559
|
+
writeFileSync18(join58(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
274272
274560
|
} catch {
|
|
274273
274561
|
}
|
|
274274
274562
|
}
|
|
@@ -274384,7 +274672,7 @@ function readP2PExposeState(stateDir) {
|
|
|
274384
274672
|
function writeP2PExposeState(stateDir, state) {
|
|
274385
274673
|
try {
|
|
274386
274674
|
mkdirSync17(stateDir, { recursive: true });
|
|
274387
|
-
|
|
274675
|
+
writeFileSync18(join58(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
274388
274676
|
} catch {
|
|
274389
274677
|
}
|
|
274390
274678
|
}
|
|
@@ -275516,7 +275804,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
275516
275804
|
let recentActive = 0;
|
|
275517
275805
|
for (const f2 of files.slice(-10)) {
|
|
275518
275806
|
try {
|
|
275519
|
-
const st =
|
|
275807
|
+
const st = statSync14(join58(invocDir, f2));
|
|
275520
275808
|
if (now - st.mtimeMs < 1e4) recentActive++;
|
|
275521
275809
|
} catch {
|
|
275522
275810
|
}
|
|
@@ -275786,7 +276074,7 @@ var init_types = __esm({
|
|
|
275786
276074
|
|
|
275787
276075
|
// packages/cli/src/tui/p2p/secret-vault.ts
|
|
275788
276076
|
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes16, scryptSync as scryptSync2, createHash as createHash3 } from "node:crypto";
|
|
275789
|
-
import { readFileSync as readFileSync32, writeFileSync as
|
|
276077
|
+
import { readFileSync as readFileSync32, writeFileSync as writeFileSync19, existsSync as existsSync43, mkdirSync as mkdirSync18 } from "node:fs";
|
|
275790
276078
|
import { dirname as dirname17 } from "node:path";
|
|
275791
276079
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
275792
276080
|
var init_secret_vault = __esm({
|
|
@@ -275995,7 +276283,7 @@ var init_secret_vault = __esm({
|
|
|
275995
276283
|
const blob = Buffer.concat([salt, iv, tag, encrypted]);
|
|
275996
276284
|
const dir = dirname17(this.storePath);
|
|
275997
276285
|
if (!existsSync43(dir)) mkdirSync18(dir, { recursive: true });
|
|
275998
|
-
|
|
276286
|
+
writeFileSync19(this.storePath, blob, { mode: 384 });
|
|
275999
276287
|
}
|
|
276000
276288
|
/**
|
|
276001
276289
|
* Load vault from disk, decrypting with the given passphrase.
|
|
@@ -277745,7 +278033,7 @@ __export(oa_directory_exports, {
|
|
|
277745
278033
|
writeIndexData: () => writeIndexData,
|
|
277746
278034
|
writeIndexMeta: () => writeIndexMeta
|
|
277747
278035
|
});
|
|
277748
|
-
import { existsSync as existsSync45, mkdirSync as mkdirSync19, readFileSync as readFileSync34, writeFileSync as
|
|
278036
|
+
import { existsSync as existsSync45, mkdirSync as mkdirSync19, readFileSync as readFileSync34, writeFileSync as writeFileSync20, readdirSync as readdirSync11, statSync as statSync15, unlinkSync as unlinkSync10 } from "node:fs";
|
|
277749
278037
|
import { join as join62, relative as relative4, basename as basename12 } from "node:path";
|
|
277750
278038
|
import { homedir as homedir16 } from "node:os";
|
|
277751
278039
|
function initOaDirectory(repoRoot) {
|
|
@@ -277759,7 +278047,7 @@ function initOaDirectory(repoRoot) {
|
|
|
277759
278047
|
if (existsSync45(gitignorePath)) {
|
|
277760
278048
|
const content = readFileSync34(gitignorePath, "utf-8");
|
|
277761
278049
|
if (!content.includes(settingsPattern)) {
|
|
277762
|
-
|
|
278050
|
+
writeFileSync20(gitignorePath, content.trimEnd() + "\n" + settingsPattern + "\n", "utf-8");
|
|
277763
278051
|
}
|
|
277764
278052
|
}
|
|
277765
278053
|
} catch {
|
|
@@ -277784,7 +278072,7 @@ function saveProjectSettings(repoRoot, settings) {
|
|
|
277784
278072
|
mkdirSync19(oaPath, { recursive: true });
|
|
277785
278073
|
const existing = loadProjectSettings(repoRoot);
|
|
277786
278074
|
const merged = { ...existing, ...settings };
|
|
277787
|
-
|
|
278075
|
+
writeFileSync20(join62(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
277788
278076
|
}
|
|
277789
278077
|
function loadGlobalSettings() {
|
|
277790
278078
|
const settingsPath = join62(homedir16(), ".open-agents", "settings.json");
|
|
@@ -277801,7 +278089,7 @@ function saveGlobalSettings(settings) {
|
|
|
277801
278089
|
mkdirSync19(dir, { recursive: true });
|
|
277802
278090
|
const existing = loadGlobalSettings();
|
|
277803
278091
|
const merged = { ...existing, ...settings };
|
|
277804
|
-
|
|
278092
|
+
writeFileSync20(join62(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
277805
278093
|
}
|
|
277806
278094
|
function resolveSettings(repoRoot) {
|
|
277807
278095
|
const global2 = loadGlobalSettings();
|
|
@@ -277878,7 +278166,7 @@ function readIndexMeta(repoRoot) {
|
|
|
277878
278166
|
function writeIndexMeta(repoRoot, meta) {
|
|
277879
278167
|
const metaPath = join62(repoRoot, OA_DIR, "index", "meta.json");
|
|
277880
278168
|
mkdirSync19(join62(repoRoot, OA_DIR, "index"), { recursive: true });
|
|
277881
|
-
|
|
278169
|
+
writeFileSync20(metaPath, JSON.stringify(meta, null, 2), "utf-8");
|
|
277882
278170
|
}
|
|
277883
278171
|
function readIndexData(repoRoot, filename) {
|
|
277884
278172
|
const filePath = join62(repoRoot, OA_DIR, "index", filename);
|
|
@@ -277891,7 +278179,7 @@ function readIndexData(repoRoot, filename) {
|
|
|
277891
278179
|
function writeIndexData(repoRoot, filename, data) {
|
|
277892
278180
|
const filePath = join62(repoRoot, OA_DIR, "index", filename);
|
|
277893
278181
|
mkdirSync19(join62(repoRoot, OA_DIR, "index"), { recursive: true });
|
|
277894
|
-
|
|
278182
|
+
writeFileSync20(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
277895
278183
|
}
|
|
277896
278184
|
function generateProjectMap(repoRoot) {
|
|
277897
278185
|
const sections = [];
|
|
@@ -277940,13 +278228,13 @@ ${tree2}\`\`\`
|
|
|
277940
278228
|
const content = sections.join("\n");
|
|
277941
278229
|
const contextDir = join62(repoRoot, OA_DIR, "context");
|
|
277942
278230
|
mkdirSync19(contextDir, { recursive: true });
|
|
277943
|
-
|
|
278231
|
+
writeFileSync20(join62(contextDir, "project-map.md"), content, "utf-8");
|
|
277944
278232
|
return content;
|
|
277945
278233
|
}
|
|
277946
278234
|
function saveSession(repoRoot, session) {
|
|
277947
278235
|
const historyDir = join62(repoRoot, OA_DIR, "history");
|
|
277948
278236
|
mkdirSync19(historyDir, { recursive: true });
|
|
277949
|
-
|
|
278237
|
+
writeFileSync20(
|
|
277950
278238
|
join62(historyDir, `${session.id}.json`),
|
|
277951
278239
|
JSON.stringify(session, null, 2),
|
|
277952
278240
|
"utf-8"
|
|
@@ -277957,7 +278245,7 @@ function loadRecentSessions(repoRoot, limit = 5) {
|
|
|
277957
278245
|
if (!existsSync45(historyDir)) return [];
|
|
277958
278246
|
try {
|
|
277959
278247
|
const files = readdirSync11(historyDir).filter((f2) => f2.endsWith(".json") && f2 !== "pending-task.json").map((f2) => {
|
|
277960
|
-
const stat6 =
|
|
278248
|
+
const stat6 = statSync15(join62(historyDir, f2));
|
|
277961
278249
|
return { file: f2, mtime: stat6.mtimeMs };
|
|
277962
278250
|
}).sort((a2, b) => b.mtime - a2.mtime).slice(0, limit);
|
|
277963
278251
|
return files.map((f2) => {
|
|
@@ -277976,7 +278264,7 @@ function loadRecentSessions(repoRoot, limit = 5) {
|
|
|
277976
278264
|
function savePendingTask(repoRoot, task) {
|
|
277977
278265
|
const historyDir = join62(repoRoot, OA_DIR, "history");
|
|
277978
278266
|
mkdirSync19(historyDir, { recursive: true });
|
|
277979
|
-
|
|
278267
|
+
writeFileSync20(
|
|
277980
278268
|
join62(historyDir, PENDING_TASK_FILE),
|
|
277981
278269
|
JSON.stringify(task, null, 2) + "\n",
|
|
277982
278270
|
"utf-8"
|
|
@@ -278015,7 +278303,7 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
278015
278303
|
ctx3.entries = ctx3.entries.slice(-ctx3.maxEntries);
|
|
278016
278304
|
}
|
|
278017
278305
|
ctx3.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
278018
|
-
|
|
278306
|
+
writeFileSync20(filePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
|
|
278019
278307
|
try {
|
|
278020
278308
|
const diaryLines = ["# Session Diary", ""];
|
|
278021
278309
|
for (const e2 of ctx3.entries.slice(-10)) {
|
|
@@ -278029,7 +278317,7 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
278029
278317
|
if (e2.summary) diaryLines.push(`Summary: ${e2.summary.slice(0, 200)}`);
|
|
278030
278318
|
diaryLines.push("");
|
|
278031
278319
|
}
|
|
278032
|
-
|
|
278320
|
+
writeFileSync20(join62(contextDir, "session-diary.md"), diaryLines.join("\n"), "utf-8");
|
|
278033
278321
|
} catch {
|
|
278034
278322
|
}
|
|
278035
278323
|
}
|
|
@@ -278072,7 +278360,7 @@ function saveSessionHistory(repoRoot, sessionId, contentLines, meta) {
|
|
|
278072
278360
|
const autoName = meta.name || generateSessionName(stripped);
|
|
278073
278361
|
const autoDesc = meta.description || generateSessionDescription(stripped);
|
|
278074
278362
|
const contentPath = join62(sessDir, `${sessionId}.jsonl`);
|
|
278075
|
-
|
|
278363
|
+
writeFileSync20(contentPath, stripped.join("\n"), "utf-8");
|
|
278076
278364
|
const indexPath = join62(sessDir, SESSIONS_INDEX);
|
|
278077
278365
|
let index = [];
|
|
278078
278366
|
try {
|
|
@@ -278103,7 +278391,7 @@ function saveSessionHistory(repoRoot, sessionId, contentLines, meta) {
|
|
|
278103
278391
|
} catch {
|
|
278104
278392
|
}
|
|
278105
278393
|
}
|
|
278106
|
-
|
|
278394
|
+
writeFileSync20(indexPath, JSON.stringify(index, null, 2), "utf-8");
|
|
278107
278395
|
}
|
|
278108
278396
|
function listSessions(repoRoot) {
|
|
278109
278397
|
const indexPath = join62(repoRoot, OA_DIR, SESSIONS_DIR, SESSIONS_INDEX);
|
|
@@ -278133,7 +278421,7 @@ function deleteSession(repoRoot, sessionId) {
|
|
|
278133
278421
|
if (existsSync45(indexPath)) {
|
|
278134
278422
|
let index = JSON.parse(readFileSync34(indexPath, "utf-8"));
|
|
278135
278423
|
index = index.filter((s2) => s2.id !== sessionId);
|
|
278136
|
-
|
|
278424
|
+
writeFileSync20(indexPath, JSON.stringify(index, null, 2), "utf-8");
|
|
278137
278425
|
}
|
|
278138
278426
|
return true;
|
|
278139
278427
|
} catch {
|
|
@@ -278268,7 +278556,7 @@ function loadUsageFile(filePath) {
|
|
|
278268
278556
|
function saveUsageFile(filePath, data) {
|
|
278269
278557
|
const dir = join62(filePath, "..");
|
|
278270
278558
|
mkdirSync19(dir, { recursive: true });
|
|
278271
|
-
|
|
278559
|
+
writeFileSync20(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
278272
278560
|
}
|
|
278273
278561
|
function recordUsage(kind, value2, opts) {
|
|
278274
278562
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -282886,7 +283174,7 @@ __export(personaplex_exports, {
|
|
|
282886
283174
|
startPersonaPlexDaemon: () => startPersonaPlexDaemon,
|
|
282887
283175
|
stopPersonaPlex: () => stopPersonaPlex
|
|
282888
283176
|
});
|
|
282889
|
-
import { existsSync as existsSync46, writeFileSync as
|
|
283177
|
+
import { existsSync as existsSync46, writeFileSync as writeFileSync21, readFileSync as readFileSync36, mkdirSync as mkdirSync20, copyFileSync as copyFileSync2, readdirSync as readdirSync12, statSync as statSync16 } from "node:fs";
|
|
282890
283178
|
import { join as join63, dirname as dirname20 } from "node:path";
|
|
282891
283179
|
import { homedir as homedir17 } from "node:os";
|
|
282892
283180
|
import { execSync as execSync37, spawn as spawn20 } from "node:child_process";
|
|
@@ -283024,7 +283312,7 @@ function getWeightTier() {
|
|
|
283024
283312
|
if (saved in WEIGHT_REPOS) {
|
|
283025
283313
|
const vram = detected.vramGB;
|
|
283026
283314
|
if (saved === "nf4-distilled" && vram < 24) {
|
|
283027
|
-
|
|
283315
|
+
writeFileSync21(tierFile, "nf4");
|
|
283028
283316
|
return "nf4";
|
|
283029
283317
|
}
|
|
283030
283318
|
return saved;
|
|
@@ -283154,7 +283442,7 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
283154
283442
|
let src2 = readFileSync36(serverFile, "utf8");
|
|
283155
283443
|
if (src2.includes('int(request["seed"])')) {
|
|
283156
283444
|
src2 = src2.replace('int(request["seed"])', 'int(request.query["seed"])');
|
|
283157
|
-
|
|
283445
|
+
writeFileSync21(serverFile, src2);
|
|
283158
283446
|
log22("Applied seed parameter bug fix to moshi server.");
|
|
283159
283447
|
}
|
|
283160
283448
|
}
|
|
@@ -283258,7 +283546,7 @@ $2if filename.endswith(".safetensors"):`
|
|
|
283258
283546
|
${patchPoint}`
|
|
283259
283547
|
);
|
|
283260
283548
|
}
|
|
283261
|
-
|
|
283549
|
+
writeFileSync21(loadersFile, src2);
|
|
283262
283550
|
log22("Patched loaders.py with 2-bit TurboQuant native dequant support.");
|
|
283263
283551
|
}
|
|
283264
283552
|
}
|
|
@@ -283356,7 +283644,7 @@ $2if filename.endswith(".safetensors"):`
|
|
|
283356
283644
|
await execAsync(`"${python}" -c "from huggingface_hub import hf_hub_download; hf_hub_download('${nf4.repo}', '${nf4.file}', token=False)"`, {
|
|
283357
283645
|
timeout: 6e5
|
|
283358
283646
|
});
|
|
283359
|
-
|
|
283647
|
+
writeFileSync21(join63(PERSONAPLEX_DIR, "weight_tier"), "nf4");
|
|
283360
283648
|
log22(`Downloaded INT4 weights instead (${nf4.sizeGB}GB, public).`);
|
|
283361
283649
|
} catch {
|
|
283362
283650
|
log22("Weight download failed.");
|
|
@@ -283368,8 +283656,8 @@ $2if filename.endswith(".safetensors"):`
|
|
|
283368
283656
|
log22("Weights will download on first server launch.");
|
|
283369
283657
|
}
|
|
283370
283658
|
}
|
|
283371
|
-
|
|
283372
|
-
|
|
283659
|
+
writeFileSync21(join63(PERSONAPLEX_DIR, "weight_tier"), tier);
|
|
283660
|
+
writeFileSync21(join63(PERSONAPLEX_DIR, "model_ready"), (/* @__PURE__ */ new Date()).toISOString());
|
|
283373
283661
|
log22(`PersonaPlex installed (${tier} tier). Use /call to start voice session.`);
|
|
283374
283662
|
return true;
|
|
283375
283663
|
}
|
|
@@ -283420,7 +283708,7 @@ print('Converted')
|
|
|
283420
283708
|
}
|
|
283421
283709
|
if (existsSync46(cachedBf16)) {
|
|
283422
283710
|
extraArgs.push("--moshi-weight", cachedBf16);
|
|
283423
|
-
log22(`Using distilled weights: ${(
|
|
283711
|
+
log22(`Using distilled weights: ${(statSync16(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
|
|
283424
283712
|
} else {
|
|
283425
283713
|
extraArgs.push("--moshi-weight", weightPath);
|
|
283426
283714
|
}
|
|
@@ -283451,7 +283739,7 @@ print('Converted')
|
|
|
283451
283739
|
);
|
|
283452
283740
|
if (existsSync46(cachedBf16)) {
|
|
283453
283741
|
extraArgs.push("--moshi-weight", cachedBf16);
|
|
283454
|
-
log22(`Using dequantized cache: ${(
|
|
283742
|
+
log22(`Using dequantized cache: ${(statSync16(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
|
|
283455
283743
|
}
|
|
283456
283744
|
} catch (e2) {
|
|
283457
283745
|
log22(`Dequantization failed \u2014 server will try to load original weights`);
|
|
@@ -283536,8 +283824,8 @@ print('Converted')
|
|
|
283536
283824
|
cwd: PERSONAPLEX_DIR
|
|
283537
283825
|
});
|
|
283538
283826
|
if (child.pid) {
|
|
283539
|
-
|
|
283540
|
-
|
|
283827
|
+
writeFileSync21(PID_FILE, String(child.pid));
|
|
283828
|
+
writeFileSync21(PORT_FILE, String(PORT));
|
|
283541
283829
|
registry2.register({
|
|
283542
283830
|
name: "PersonaPlex",
|
|
283543
283831
|
pid: child.pid,
|
|
@@ -283797,7 +284085,7 @@ function patchFrontendVoiceList(onInfo) {
|
|
|
283797
284085
|
if (js.includes(needle)) {
|
|
283798
284086
|
const additions = customVoices.map((v) => `"${v}"`).join(", ");
|
|
283799
284087
|
js = js.replace(needle, `"VARM4.pt", ${additions}]`);
|
|
283800
|
-
|
|
284088
|
+
writeFileSync21(jsPath, js);
|
|
283801
284089
|
log22(`Added ${customVoices.length} custom voice(s) to frontend: ${customVoices.map((v) => v.replace(".pt", "")).join(", ")}`);
|
|
283802
284090
|
}
|
|
283803
284091
|
}
|
|
@@ -283893,7 +284181,7 @@ __export(setup_exports, {
|
|
|
283893
284181
|
import * as readline from "node:readline";
|
|
283894
284182
|
import { execSync as execSync38, spawn as spawn21, exec as exec4 } from "node:child_process";
|
|
283895
284183
|
import { promisify as promisify7 } from "node:util";
|
|
283896
|
-
import { existsSync as existsSync47, writeFileSync as
|
|
284184
|
+
import { existsSync as existsSync47, writeFileSync as writeFileSync22, readFileSync as readFileSync37, appendFileSync as appendFileSync2, mkdirSync as mkdirSync21 } from "node:fs";
|
|
283897
284185
|
import { join as join64 } from "node:path";
|
|
283898
284186
|
import { homedir as homedir18, platform as platform3 } from "node:os";
|
|
283899
284187
|
async function checkToolSupport(modelName, backendUrl = "http://localhost:11434") {
|
|
@@ -284997,7 +285285,7 @@ async function doSetup(config, rl) {
|
|
|
284997
285285
|
const modelDir2 = join64(homedir18(), ".open-agents", "models");
|
|
284998
285286
|
mkdirSync21(modelDir2, { recursive: true });
|
|
284999
285287
|
const modelfilePath = join64(modelDir2, `Modelfile.${customName}`);
|
|
285000
|
-
|
|
285288
|
+
writeFileSync22(modelfilePath, modelfileContent + "\n", "utf8");
|
|
285001
285289
|
process.stdout.write(` ${c3.dim("Creating model...")} `);
|
|
285002
285290
|
execSync38(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
285003
285291
|
stdio: "pipe",
|
|
@@ -285335,7 +285623,7 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
285335
285623
|
}
|
|
285336
285624
|
try {
|
|
285337
285625
|
mkdirSync21(_visionMarkerDir, { recursive: true });
|
|
285338
|
-
|
|
285626
|
+
writeFileSync22(_visionMarkerFile, JSON.stringify({
|
|
285339
285627
|
installed: [..._visionPreviouslyInstalled],
|
|
285340
285628
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
285341
285629
|
}, null, 2));
|
|
@@ -285573,7 +285861,7 @@ function createExpandedVariant(baseModel, specs, sizeGB, kvBytesPerToken, archMa
|
|
|
285573
285861
|
const modelDir2 = join64(homedir18(), ".open-agents", "models");
|
|
285574
285862
|
mkdirSync21(modelDir2, { recursive: true });
|
|
285575
285863
|
const modelfilePath = join64(modelDir2, `Modelfile.${customName}`);
|
|
285576
|
-
|
|
285864
|
+
writeFileSync22(modelfilePath, modelfileContent + "\n", "utf8");
|
|
285577
285865
|
execSync38(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
285578
285866
|
stdio: "pipe",
|
|
285579
285867
|
timeout: 12e4
|
|
@@ -285598,7 +285886,7 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
|
|
|
285598
285886
|
const modelDir2 = join64(homedir18(), ".open-agents", "models");
|
|
285599
285887
|
mkdirSync21(modelDir2, { recursive: true });
|
|
285600
285888
|
const modelfilePath = join64(modelDir2, `Modelfile.${customName}`);
|
|
285601
|
-
|
|
285889
|
+
writeFileSync22(modelfilePath, modelfileContent + "\n", "utf8");
|
|
285602
285890
|
await execAsync2(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
285603
285891
|
timeout: 12e4
|
|
285604
285892
|
});
|
|
@@ -286484,7 +286772,7 @@ __export(daemon_exports, {
|
|
|
286484
286772
|
stopDaemon: () => stopDaemon
|
|
286485
286773
|
});
|
|
286486
286774
|
import { spawn as spawn22 } from "node:child_process";
|
|
286487
|
-
import { existsSync as existsSync50, readFileSync as readFileSync38, writeFileSync as
|
|
286775
|
+
import { existsSync as existsSync50, readFileSync as readFileSync38, writeFileSync as writeFileSync23, mkdirSync as mkdirSync22, unlinkSync as unlinkSync12 } from "node:fs";
|
|
286488
286776
|
import { join as join66 } from "node:path";
|
|
286489
286777
|
import { homedir as homedir19 } from "node:os";
|
|
286490
286778
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
@@ -286555,7 +286843,7 @@ async function startDaemon() {
|
|
|
286555
286843
|
child.unref();
|
|
286556
286844
|
const pid = child.pid ?? null;
|
|
286557
286845
|
if (pid) {
|
|
286558
|
-
|
|
286846
|
+
writeFileSync23(PID_FILE2, String(pid), "utf8");
|
|
286559
286847
|
}
|
|
286560
286848
|
return pid;
|
|
286561
286849
|
} catch {
|
|
@@ -287023,7 +287311,7 @@ __export(sponsor_wizard_exports, {
|
|
|
287023
287311
|
saveSponsorConfig: () => saveSponsorConfig,
|
|
287024
287312
|
showSponsorDashboard: () => showSponsorDashboard
|
|
287025
287313
|
});
|
|
287026
|
-
import { existsSync as existsSync51, readFileSync as readFileSync39, writeFileSync as
|
|
287314
|
+
import { existsSync as existsSync51, readFileSync as readFileSync39, writeFileSync as writeFileSync24, mkdirSync as mkdirSync23 } from "node:fs";
|
|
287027
287315
|
import { join as join67 } from "node:path";
|
|
287028
287316
|
function colorPreview(code8) {
|
|
287029
287317
|
return `\x1B[38;5;${code8}m\u2588\u2588\u2588\u2588\x1B[0m (${code8})`;
|
|
@@ -287055,7 +287343,7 @@ function saveSponsorConfig(projectDir, config) {
|
|
|
287055
287343
|
const dir = sponsorDir(projectDir);
|
|
287056
287344
|
mkdirSync23(dir, { recursive: true });
|
|
287057
287345
|
config.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
287058
|
-
|
|
287346
|
+
writeFileSync24(configPath(projectDir), JSON.stringify(config, null, 2), "utf8");
|
|
287059
287347
|
}
|
|
287060
287348
|
function defaultConfig2() {
|
|
287061
287349
|
return {
|
|
@@ -287935,7 +288223,7 @@ __export(voice_exports, {
|
|
|
287935
288223
|
registerCustomOnnxModel: () => registerCustomOnnxModel,
|
|
287936
288224
|
resetNarrationContext: () => resetNarrationContext
|
|
287937
288225
|
});
|
|
287938
|
-
import { existsSync as existsSync52, mkdirSync as mkdirSync24, writeFileSync as
|
|
288226
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync24, writeFileSync as writeFileSync25, readFileSync as readFileSync40, unlinkSync as unlinkSync13, readdirSync as readdirSync13, statSync as statSync17 } from "node:fs";
|
|
287939
288227
|
import { join as join68, dirname as dirname22 } from "node:path";
|
|
287940
288228
|
import { homedir as homedir20, tmpdir as tmpdir12, platform as platform4 } from "node:os";
|
|
287941
288229
|
import { execSync as execSync40, spawn as nodeSpawn } from "node:child_process";
|
|
@@ -288066,7 +288354,7 @@ def main():
|
|
|
288066
288354
|
if __name__ == "__main__": main()
|
|
288067
288355
|
`;
|
|
288068
288356
|
try {
|
|
288069
|
-
|
|
288357
|
+
writeFileSync25(targetPath, script, { mode: 493 });
|
|
288070
288358
|
} catch {
|
|
288071
288359
|
}
|
|
288072
288360
|
}
|
|
@@ -288333,7 +288621,9 @@ function extractSubAgentTopic(args) {
|
|
|
288333
288621
|
const cut = text.lastIndexOf(" ", 80);
|
|
288334
288622
|
text = text.slice(0, cut > 20 ? cut : 80);
|
|
288335
288623
|
}
|
|
288336
|
-
if (text.length > 0
|
|
288624
|
+
if (text.length > 0 && !(text.length > 1 && text[0] === text[0].toUpperCase() && text[1] === text[1].toUpperCase())) {
|
|
288625
|
+
text = text.charAt(0).toLowerCase() + text.slice(1);
|
|
288626
|
+
}
|
|
288337
288627
|
return text;
|
|
288338
288628
|
}
|
|
288339
288629
|
function extractShellEssence(cmd) {
|
|
@@ -288542,10 +288832,10 @@ function extractContentSummary(text, toolName) {
|
|
|
288542
288832
|
const cut = summary.lastIndexOf(" ", 80);
|
|
288543
288833
|
summary = summary.slice(0, cut > 20 ? cut : 80);
|
|
288544
288834
|
}
|
|
288545
|
-
if (summary.length > 0) {
|
|
288835
|
+
if (summary.length > 0 && !(summary.length > 1 && summary[0] === summary[0].toUpperCase() && summary[1] === summary[1].toUpperCase())) {
|
|
288546
288836
|
summary = summary.charAt(0).toLowerCase() + summary.slice(1);
|
|
288547
|
-
summary = summary.replace(/[.,;:!?]+$/, "");
|
|
288548
288837
|
}
|
|
288838
|
+
if (summary.length > 0) summary = summary.replace(/[.,;:!?]+$/, "");
|
|
288549
288839
|
return summary;
|
|
288550
288840
|
}
|
|
288551
288841
|
if (toolName === "sub_agent") {
|
|
@@ -288907,7 +289197,7 @@ var init_voice = __esm({
|
|
|
288907
289197
|
const destPath = join68(refsDir, destFilename);
|
|
288908
289198
|
try {
|
|
288909
289199
|
const data = readFileSync40(audioPath);
|
|
288910
|
-
|
|
289200
|
+
writeFileSync25(destPath, data);
|
|
288911
289201
|
} catch (err) {
|
|
288912
289202
|
return `Failed to copy audio file: ${err instanceof Error ? err.message : String(err)}`;
|
|
288913
289203
|
}
|
|
@@ -288978,7 +289268,7 @@ var init_voice = __esm({
|
|
|
288978
289268
|
saveCloneMeta(meta) {
|
|
288979
289269
|
const dir = luxttsCloneRefsDir();
|
|
288980
289270
|
if (!existsSync52(dir)) mkdirSync24(dir, { recursive: true });
|
|
288981
|
-
|
|
289271
|
+
writeFileSync25(_VoiceEngine.cloneMetaFile(), JSON.stringify(meta, null, 2));
|
|
288982
289272
|
}
|
|
288983
289273
|
/** Audio file extensions recognized as clone references */
|
|
288984
289274
|
static AUDIO_EXTS = /* @__PURE__ */ new Set(["wav", "mp3", "ogg", "flac", "m4a", "opus", "aac"]);
|
|
@@ -288998,7 +289288,7 @@ var init_voice = __esm({
|
|
|
288998
289288
|
const p2 = join68(dir, f2);
|
|
288999
289289
|
let size = 0;
|
|
289000
289290
|
try {
|
|
289001
|
-
size =
|
|
289291
|
+
size = statSync17(p2).size;
|
|
289002
289292
|
} catch {
|
|
289003
289293
|
}
|
|
289004
289294
|
return {
|
|
@@ -289504,7 +289794,7 @@ var init_voice = __esm({
|
|
|
289504
289794
|
buffer2.writeInt16LE(rSample < 0 ? rSample * 32768 : rSample * 32767, pos);
|
|
289505
289795
|
pos += 2;
|
|
289506
289796
|
}
|
|
289507
|
-
|
|
289797
|
+
writeFileSync25(path5, buffer2);
|
|
289508
289798
|
}
|
|
289509
289799
|
// -------------------------------------------------------------------------
|
|
289510
289800
|
// Phonemization
|
|
@@ -289578,7 +289868,7 @@ var init_voice = __esm({
|
|
|
289578
289868
|
return buffer2;
|
|
289579
289869
|
}
|
|
289580
289870
|
writeWav(samples, sampleRate, path5) {
|
|
289581
|
-
|
|
289871
|
+
writeFileSync25(path5, this.buildWavBuffer(samples, sampleRate));
|
|
289582
289872
|
}
|
|
289583
289873
|
// -------------------------------------------------------------------------
|
|
289584
289874
|
// Audio playback (system default speakers)
|
|
@@ -289807,7 +290097,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
289807
290097
|
samples[i2] = Math.round(samples[i2] * volume);
|
|
289808
290098
|
}
|
|
289809
290099
|
const scaled = Buffer.concat([header, Buffer.from(samples.buffer, samples.byteOffset, samples.byteLength)]);
|
|
289810
|
-
|
|
290100
|
+
writeFileSync25(wavPath, scaled);
|
|
289811
290101
|
}
|
|
289812
290102
|
} catch {
|
|
289813
290103
|
}
|
|
@@ -290271,7 +290561,7 @@ if __name__ == '__main__':
|
|
|
290271
290561
|
`;
|
|
290272
290562
|
const scriptPath2 = luxttsInferScript();
|
|
290273
290563
|
mkdirSync24(voiceDir(), { recursive: true });
|
|
290274
|
-
|
|
290564
|
+
writeFileSync25(scriptPath2, script);
|
|
290275
290565
|
}
|
|
290276
290566
|
/** Ensure the LuxTTS daemon is running, spawn if needed */
|
|
290277
290567
|
async ensureLuxttsDaemon() {
|
|
@@ -290411,7 +290701,7 @@ if __name__ == '__main__':
|
|
|
290411
290701
|
}
|
|
290412
290702
|
const header = wavData.subarray(0, 44);
|
|
290413
290703
|
const scaled = Buffer.concat([header, Buffer.from(samples.buffer, samples.byteOffset, samples.byteLength)]);
|
|
290414
|
-
|
|
290704
|
+
writeFileSync25(wavPath, scaled);
|
|
290415
290705
|
}
|
|
290416
290706
|
} catch {
|
|
290417
290707
|
}
|
|
@@ -290529,13 +290819,13 @@ if __name__ == '__main__':
|
|
|
290529
290819
|
const existing = JSON.parse(readFileSync40(pkgPath, "utf8"));
|
|
290530
290820
|
if (!existing.dependencies?.["phonemizer"]) {
|
|
290531
290821
|
existing.dependencies = { ...existing.dependencies, ...expectedDeps };
|
|
290532
|
-
|
|
290822
|
+
writeFileSync25(pkgPath, JSON.stringify(existing, null, 2));
|
|
290533
290823
|
}
|
|
290534
290824
|
} catch {
|
|
290535
290825
|
}
|
|
290536
290826
|
}
|
|
290537
290827
|
if (!existsSync52(pkgPath)) {
|
|
290538
|
-
|
|
290828
|
+
writeFileSync25(pkgPath, JSON.stringify({
|
|
290539
290829
|
name: "open-agents-voice",
|
|
290540
290830
|
private: true,
|
|
290541
290831
|
dependencies: expectedDeps
|
|
@@ -290620,7 +290910,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
290620
290910
|
const configResp = await fetch(model.configUrl);
|
|
290621
290911
|
if (!configResp.ok) throw new Error(`Failed to download config: HTTP ${configResp.status}`);
|
|
290622
290912
|
const configText = await configResp.text();
|
|
290623
|
-
|
|
290913
|
+
writeFileSync25(configPath2, configText);
|
|
290624
290914
|
}
|
|
290625
290915
|
if (!existsSync52(onnxPath)) {
|
|
290626
290916
|
renderInfo(`Downloading ${model.label} voice model (this may take a minute)...`);
|
|
@@ -290644,7 +290934,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
290644
290934
|
}
|
|
290645
290935
|
}
|
|
290646
290936
|
const fullBuffer = Buffer.concat(chunks);
|
|
290647
|
-
|
|
290937
|
+
writeFileSync25(onnxPath, fullBuffer);
|
|
290648
290938
|
renderInfo(`${model.label} model downloaded (${formatBytes2(fullBuffer.length)}).`);
|
|
290649
290939
|
}
|
|
290650
290940
|
}
|
|
@@ -290685,7 +290975,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
290685
290975
|
// packages/cli/src/tui/commands.ts
|
|
290686
290976
|
import * as nodeOs from "node:os";
|
|
290687
290977
|
import { execSync as nodeExecSync } from "node:child_process";
|
|
290688
|
-
import { existsSync as existsSync53, readFileSync as readFileSync41, writeFileSync as
|
|
290978
|
+
import { existsSync as existsSync53, readFileSync as readFileSync41, writeFileSync as writeFileSync26, mkdirSync as mkdirSync25, readdirSync as readdirSync14, statSync as statSync18, rmSync as rmSync2, appendFileSync as appendFileSync3 } from "node:fs";
|
|
290689
290979
|
import { join as join69 } from "node:path";
|
|
290690
290980
|
async function _immediateReregister(newUrl) {
|
|
290691
290981
|
if (!_lastRegisteredSponsorPayload) return;
|
|
@@ -291622,7 +291912,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
291622
291912
|
ipfsFiles = files.length;
|
|
291623
291913
|
for (const f2 of files) {
|
|
291624
291914
|
try {
|
|
291625
|
-
ipfsBytes +=
|
|
291915
|
+
ipfsBytes += statSync18(join69(ipfsLocalDir, f2)).size;
|
|
291626
291916
|
} catch {
|
|
291627
291917
|
}
|
|
291628
291918
|
}
|
|
@@ -291635,7 +291925,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
291635
291925
|
else {
|
|
291636
291926
|
heliaBlocks++;
|
|
291637
291927
|
try {
|
|
291638
|
-
heliaBytes +=
|
|
291928
|
+
heliaBytes += statSync18(join69(dir, entry.name)).size;
|
|
291639
291929
|
} catch {
|
|
291640
291930
|
}
|
|
291641
291931
|
}
|
|
@@ -291727,7 +292017,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
291727
292017
|
const count = memStore.count();
|
|
291728
292018
|
lines.push(`
|
|
291729
292019
|
${c3.bold("Structured Memory (SQLite)")}`);
|
|
291730
|
-
lines.push(` Memories: ${c3.bold(String(count))} DB: ${c3.dim(formatFileSize(
|
|
292020
|
+
lines.push(` Memories: ${c3.bold(String(count))} DB: ${c3.dim(formatFileSize(statSync18(dbPath).size))}`);
|
|
291731
292021
|
cDb(db);
|
|
291732
292022
|
}
|
|
291733
292023
|
} catch {
|
|
@@ -291758,7 +292048,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
291758
292048
|
walkStorage(full, subCat);
|
|
291759
292049
|
} else {
|
|
291760
292050
|
try {
|
|
291761
|
-
const sz =
|
|
292051
|
+
const sz = statSync18(full).size;
|
|
291762
292052
|
totalBytes += sz;
|
|
291763
292053
|
if (!categories[category]) categories[category] = { files: 0, bytes: 0 };
|
|
291764
292054
|
categories[category].files++;
|
|
@@ -291937,7 +292227,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
291937
292227
|
};
|
|
291938
292228
|
const jwtFile = join69(ctx3.repoRoot, ".oa", "fortemi-jwt.json");
|
|
291939
292229
|
mkdirSync25(join69(ctx3.repoRoot, ".oa"), { recursive: true });
|
|
291940
|
-
|
|
292230
|
+
writeFileSync26(jwtFile, JSON.stringify(jwtPayload, null, 2));
|
|
291941
292231
|
renderInfo(`Launching fortemi-react from ${fDir}...`);
|
|
291942
292232
|
try {
|
|
291943
292233
|
const { spawn: spawn26 } = __require("node:child_process");
|
|
@@ -291952,7 +292242,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
291952
292242
|
renderInfo(`JWT saved to ${jwtFile}`);
|
|
291953
292243
|
renderInfo("Memory operations will proxy to fortemi when available.");
|
|
291954
292244
|
const bridgeFile = join69(ctx3.repoRoot, ".oa", "fortemi-bridge.json");
|
|
291955
|
-
|
|
292245
|
+
writeFileSync26(bridgeFile, JSON.stringify({
|
|
291956
292246
|
url: "http://localhost:3000",
|
|
291957
292247
|
pid: child.pid,
|
|
291958
292248
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -294091,7 +294381,7 @@ async function showCohereDashboard(ctx3) {
|
|
|
294091
294381
|
const snapItems = snaps.slice(0, 20).map((f2) => ({
|
|
294092
294382
|
key: f2,
|
|
294093
294383
|
label: f2.replace(".json", ""),
|
|
294094
|
-
detail: `${formatFileSize(
|
|
294384
|
+
detail: `${formatFileSize(statSync18(join69(snapDir, f2)).size)}`
|
|
294095
294385
|
}));
|
|
294096
294386
|
if (snapItems.length > 0) {
|
|
294097
294387
|
await tuiSelect({
|
|
@@ -295152,10 +295442,10 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
295152
295442
|
sponsors.push(...verified);
|
|
295153
295443
|
if (verified.length > 0) {
|
|
295154
295444
|
try {
|
|
295155
|
-
const { mkdirSync: mkdirSync40, writeFileSync:
|
|
295445
|
+
const { mkdirSync: mkdirSync40, writeFileSync: writeFileSync38 } = __require("node:fs");
|
|
295156
295446
|
mkdirSync40(sponsorDir2, { recursive: true });
|
|
295157
295447
|
const cached = verified.map((s2) => ({ ...s2, lastVerified: Date.now() }));
|
|
295158
|
-
|
|
295448
|
+
writeFileSync38(knownFile, JSON.stringify(cached, null, 2));
|
|
295159
295449
|
} catch {
|
|
295160
295450
|
}
|
|
295161
295451
|
}
|
|
@@ -295252,7 +295542,7 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
295252
295542
|
const existing = existsSync53(knownFile) ? JSON.parse(readFileSync41(knownFile, "utf8")) : [];
|
|
295253
295543
|
const updated = existing.filter((s2) => (s2.url || s2.peerId || s2.name) !== saveKey);
|
|
295254
295544
|
updated.push(selected);
|
|
295255
|
-
|
|
295545
|
+
writeFileSync26(knownFile, JSON.stringify(updated, null, 2), "utf8");
|
|
295256
295546
|
} catch {
|
|
295257
295547
|
}
|
|
295258
295548
|
renderInfo(`Connected to sponsored endpoint: ${selected.name}`);
|
|
@@ -295320,11 +295610,11 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
|
|
|
295320
295610
|
const models = await fetchModels(peerUrl, authKey);
|
|
295321
295611
|
if (models.length > 0) {
|
|
295322
295612
|
try {
|
|
295323
|
-
const { writeFileSync:
|
|
295613
|
+
const { writeFileSync: writeFileSync38, mkdirSync: mkdirSync40 } = await import("node:fs");
|
|
295324
295614
|
const { join: join91, dirname: dirname28 } = await import("node:path");
|
|
295325
295615
|
const cachePath = join91(ctx3.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
|
|
295326
295616
|
mkdirSync40(dirname28(cachePath), { recursive: true });
|
|
295327
|
-
|
|
295617
|
+
writeFileSync38(cachePath, JSON.stringify({
|
|
295328
295618
|
peerId,
|
|
295329
295619
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
295330
295620
|
models: models.map((m2) => ({ name: m2.name, size: m2.size, parameterSize: m2.parameterSize }))
|
|
@@ -297853,7 +298143,7 @@ __export(banner_exports, {
|
|
|
297853
298143
|
saveBannerDesign: () => saveBannerDesign,
|
|
297854
298144
|
setGridText: () => setGridText
|
|
297855
298145
|
});
|
|
297856
|
-
import { existsSync as existsSync55, readFileSync as readFileSync43, writeFileSync as
|
|
298146
|
+
import { existsSync as existsSync55, readFileSync as readFileSync43, writeFileSync as writeFileSync27, mkdirSync as mkdirSync26 } from "node:fs";
|
|
297857
298147
|
import { join as join71 } from "node:path";
|
|
297858
298148
|
function generateMnemonic(seed) {
|
|
297859
298149
|
let h = 2166136261;
|
|
@@ -297986,7 +298276,7 @@ function createSponsorBanner(sponsorName, tagline, primaryColor = 214, bgColor =
|
|
|
297986
298276
|
function saveBannerDesign(workDir, design) {
|
|
297987
298277
|
const dir = join71(workDir, ".oa", "banners");
|
|
297988
298278
|
mkdirSync26(dir, { recursive: true });
|
|
297989
|
-
|
|
298279
|
+
writeFileSync27(join71(dir, `${design.id}.json`), JSON.stringify(design, null, 2), "utf8");
|
|
297990
298280
|
}
|
|
297991
298281
|
function loadBannerDesign(workDir, id) {
|
|
297992
298282
|
const file = join71(workDir, ".oa", "banners", `${id}.json`);
|
|
@@ -298306,7 +298596,7 @@ var init_banner = __esm({
|
|
|
298306
298596
|
});
|
|
298307
298597
|
|
|
298308
298598
|
// packages/cli/src/tui/carousel-descriptors.ts
|
|
298309
|
-
import { existsSync as existsSync56, readFileSync as readFileSync44, writeFileSync as
|
|
298599
|
+
import { existsSync as existsSync56, readFileSync as readFileSync44, writeFileSync as writeFileSync28, mkdirSync as mkdirSync27, readdirSync as readdirSync16 } from "node:fs";
|
|
298310
298600
|
import { join as join72, basename as basename14 } from "node:path";
|
|
298311
298601
|
function loadToolProfile(repoRoot) {
|
|
298312
298602
|
const filePath = join72(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
|
|
@@ -298320,7 +298610,7 @@ function loadToolProfile(repoRoot) {
|
|
|
298320
298610
|
function saveToolProfile(repoRoot, profile) {
|
|
298321
298611
|
const contextDir = join72(repoRoot, OA_DIR, "context");
|
|
298322
298612
|
mkdirSync27(contextDir, { recursive: true });
|
|
298323
|
-
|
|
298613
|
+
writeFileSync28(join72(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
|
|
298324
298614
|
}
|
|
298325
298615
|
function categorizeToolCall(toolName) {
|
|
298326
298616
|
for (const cat2 of TOOL_CATEGORIES) {
|
|
@@ -298392,7 +298682,7 @@ function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
|
|
|
298392
298682
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
298393
298683
|
sourceHash
|
|
298394
298684
|
};
|
|
298395
|
-
|
|
298685
|
+
writeFileSync28(join72(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
|
|
298396
298686
|
}
|
|
298397
298687
|
function generateDescriptors(repoRoot) {
|
|
298398
298688
|
const profile = loadToolProfile(repoRoot);
|
|
@@ -299351,7 +299641,7 @@ var init_promptLoader3 = __esm({
|
|
|
299351
299641
|
});
|
|
299352
299642
|
|
|
299353
299643
|
// packages/cli/src/tui/dream-engine.ts
|
|
299354
|
-
import { mkdirSync as mkdirSync29, writeFileSync as
|
|
299644
|
+
import { mkdirSync as mkdirSync29, writeFileSync as writeFileSync29, readFileSync as readFileSync46, existsSync as existsSync58, readdirSync as readdirSync17 } from "node:fs";
|
|
299355
299645
|
import { join as join75, basename as basename15 } from "node:path";
|
|
299356
299646
|
import { execSync as execSync42 } from "node:child_process";
|
|
299357
299647
|
function setDreamWriteContent(fn) {
|
|
@@ -299571,7 +299861,7 @@ var init_dream_engine = __esm({
|
|
|
299571
299861
|
try {
|
|
299572
299862
|
const dir = join75(targetPath, "..");
|
|
299573
299863
|
mkdirSync29(dir, { recursive: true });
|
|
299574
|
-
|
|
299864
|
+
writeFileSync29(targetPath, content, "utf-8");
|
|
299575
299865
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
299576
299866
|
} catch (err) {
|
|
299577
299867
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -299611,7 +299901,7 @@ var init_dream_engine = __esm({
|
|
|
299611
299901
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
299612
299902
|
}
|
|
299613
299903
|
content = content.replace(oldStr, newStr);
|
|
299614
|
-
|
|
299904
|
+
writeFileSync29(targetPath, content, "utf-8");
|
|
299615
299905
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
299616
299906
|
} catch (err) {
|
|
299617
299907
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -299657,7 +299947,7 @@ var init_dream_engine = __esm({
|
|
|
299657
299947
|
try {
|
|
299658
299948
|
const dir = join75(targetPath, "..");
|
|
299659
299949
|
mkdirSync29(dir, { recursive: true });
|
|
299660
|
-
|
|
299950
|
+
writeFileSync29(targetPath, content, "utf-8");
|
|
299661
299951
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
299662
299952
|
} catch (err) {
|
|
299663
299953
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -299697,7 +299987,7 @@ var init_dream_engine = __esm({
|
|
|
299697
299987
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
299698
299988
|
}
|
|
299699
299989
|
content = content.replace(oldStr, newStr);
|
|
299700
|
-
|
|
299990
|
+
writeFileSync29(targetPath, content, "utf-8");
|
|
299701
299991
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
299702
299992
|
} catch (err) {
|
|
299703
299993
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -299855,7 +300145,7 @@ ${result.summary}`;
|
|
|
299855
300145
|
renderDreamContraction(cycle);
|
|
299856
300146
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
299857
300147
|
const summaryPath = join75(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
299858
|
-
|
|
300148
|
+
writeFileSync29(summaryPath, cycleSummary, "utf-8");
|
|
299859
300149
|
}
|
|
299860
300150
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
299861
300151
|
this.saveVersionCheckpoint(cycle);
|
|
@@ -300516,7 +300806,7 @@ ${summaryResult}
|
|
|
300516
300806
|
`;
|
|
300517
300807
|
try {
|
|
300518
300808
|
mkdirSync29(this.dreamsDir, { recursive: true });
|
|
300519
|
-
|
|
300809
|
+
writeFileSync29(reportPath, report, "utf-8");
|
|
300520
300810
|
} catch {
|
|
300521
300811
|
}
|
|
300522
300812
|
renderSwarmComplete(workspace);
|
|
@@ -300601,10 +300891,10 @@ ${summaryResult}
|
|
|
300601
300891
|
encoding: "utf-8",
|
|
300602
300892
|
timeout: 5e3
|
|
300603
300893
|
}).trim();
|
|
300604
|
-
|
|
300605
|
-
|
|
300606
|
-
|
|
300607
|
-
|
|
300894
|
+
writeFileSync29(join75(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
|
|
300895
|
+
writeFileSync29(join75(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
|
|
300896
|
+
writeFileSync29(join75(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
|
|
300897
|
+
writeFileSync29(
|
|
300608
300898
|
join75(checkpointDir, "checkpoint.json"),
|
|
300609
300899
|
JSON.stringify({
|
|
300610
300900
|
cycle,
|
|
@@ -300616,7 +300906,7 @@ ${summaryResult}
|
|
|
300616
300906
|
);
|
|
300617
300907
|
renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
300618
300908
|
} catch {
|
|
300619
|
-
|
|
300909
|
+
writeFileSync29(
|
|
300620
300910
|
join75(checkpointDir, "checkpoint.json"),
|
|
300621
300911
|
JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2),
|
|
300622
300912
|
"utf-8"
|
|
@@ -300678,7 +300968,7 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
300678
300968
|
---
|
|
300679
300969
|
*Auto-generated by open-agents dream engine*
|
|
300680
300970
|
`;
|
|
300681
|
-
|
|
300971
|
+
writeFileSync29(join75(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
300682
300972
|
} catch {
|
|
300683
300973
|
}
|
|
300684
300974
|
}
|
|
@@ -300764,7 +301054,7 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
300764
301054
|
durationMs
|
|
300765
301055
|
});
|
|
300766
301056
|
try {
|
|
300767
|
-
|
|
301057
|
+
writeFileSync29(
|
|
300768
301058
|
join75(memoryDir, ".last-consolidation"),
|
|
300769
301059
|
JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), summary: result.summary?.slice(0, 500) }) + "\n"
|
|
300770
301060
|
);
|
|
@@ -300782,7 +301072,7 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
300782
301072
|
/** Save dream state for resume/inspection */
|
|
300783
301073
|
saveDreamState() {
|
|
300784
301074
|
try {
|
|
300785
|
-
|
|
301075
|
+
writeFileSync29(
|
|
300786
301076
|
join75(this.dreamsDir, "dream-state.json"),
|
|
300787
301077
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
300788
301078
|
"utf-8"
|
|
@@ -301153,7 +301443,7 @@ var init_bless_engine = __esm({
|
|
|
301153
301443
|
});
|
|
301154
301444
|
|
|
301155
301445
|
// packages/cli/src/tui/dmn-engine.ts
|
|
301156
|
-
import { existsSync as existsSync59, readFileSync as readFileSync47, writeFileSync as
|
|
301446
|
+
import { existsSync as existsSync59, readFileSync as readFileSync47, writeFileSync as writeFileSync30, mkdirSync as mkdirSync30, readdirSync as readdirSync18, unlinkSync as unlinkSync14 } from "node:fs";
|
|
301157
301447
|
import { join as join76, basename as basename16 } from "node:path";
|
|
301158
301448
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
301159
301449
|
const competenceReport = competence.length > 0 ? competence.map((c7) => {
|
|
@@ -301920,7 +302210,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
301920
302210
|
}
|
|
301921
302211
|
saveState() {
|
|
301922
302212
|
try {
|
|
301923
|
-
|
|
302213
|
+
writeFileSync30(
|
|
301924
302214
|
join76(this.stateDir, "state.json"),
|
|
301925
302215
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
301926
302216
|
"utf-8"
|
|
@@ -301931,7 +302221,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
301931
302221
|
saveCycleResult(result) {
|
|
301932
302222
|
try {
|
|
301933
302223
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
301934
|
-
|
|
302224
|
+
writeFileSync30(
|
|
301935
302225
|
join76(this.historyDir, filename),
|
|
301936
302226
|
JSON.stringify(result, null, 2) + "\n",
|
|
301937
302227
|
"utf-8"
|
|
@@ -305923,7 +306213,7 @@ var init_chat_session = __esm({
|
|
|
305923
306213
|
});
|
|
305924
306214
|
|
|
305925
306215
|
// packages/cli/src/api/usage-tracker.ts
|
|
305926
|
-
import { mkdirSync as mkdirSync33, readFileSync as readFileSync51, writeFileSync as
|
|
306216
|
+
import { mkdirSync as mkdirSync33, readFileSync as readFileSync51, writeFileSync as writeFileSync31, existsSync as existsSync64 } from "node:fs";
|
|
305927
306217
|
import { join as join81 } from "node:path";
|
|
305928
306218
|
function initUsageTracker(oaDir) {
|
|
305929
306219
|
const dir = join81(oaDir, "usage");
|
|
@@ -305967,7 +306257,7 @@ function flush2() {
|
|
|
305967
306257
|
if (!initialized2 || !dirty) return;
|
|
305968
306258
|
try {
|
|
305969
306259
|
store.lastSaved = (/* @__PURE__ */ new Date()).toISOString();
|
|
305970
|
-
|
|
306260
|
+
writeFileSync31(usageFile, JSON.stringify(store, null, 2), "utf-8");
|
|
305971
306261
|
dirty = false;
|
|
305972
306262
|
} catch {
|
|
305973
306263
|
}
|
|
@@ -305995,7 +306285,7 @@ var init_usage_tracker = __esm({
|
|
|
305995
306285
|
});
|
|
305996
306286
|
|
|
305997
306287
|
// packages/cli/src/api/profiles.ts
|
|
305998
|
-
import { existsSync as existsSync65, readFileSync as readFileSync52, writeFileSync as
|
|
306288
|
+
import { existsSync as existsSync65, readFileSync as readFileSync52, writeFileSync as writeFileSync32, mkdirSync as mkdirSync34, readdirSync as readdirSync22, unlinkSync as unlinkSync16 } from "node:fs";
|
|
305999
306289
|
import { join as join82 } from "node:path";
|
|
306000
306290
|
import { homedir as homedir23 } from "node:os";
|
|
306001
306291
|
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes18, scryptSync as scryptSync3 } from "node:crypto";
|
|
@@ -306065,10 +306355,10 @@ function saveProfile(profile, password, scope = "global", projectDir) {
|
|
|
306065
306355
|
profile.modified = (/* @__PURE__ */ new Date()).toISOString();
|
|
306066
306356
|
if (password) {
|
|
306067
306357
|
const encrypted = encryptProfile(profile, password);
|
|
306068
|
-
|
|
306358
|
+
writeFileSync32(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
306069
306359
|
} else {
|
|
306070
306360
|
profile.encrypted = false;
|
|
306071
|
-
|
|
306361
|
+
writeFileSync32(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
|
|
306072
306362
|
}
|
|
306073
306363
|
}
|
|
306074
306364
|
function deleteProfile(name10, scope = "global", projectDir) {
|
|
@@ -306190,7 +306480,7 @@ var init_profiles = __esm({
|
|
|
306190
306480
|
|
|
306191
306481
|
// packages/cli/src/docker.ts
|
|
306192
306482
|
import { execSync as execSync43, spawn as spawn23 } from "node:child_process";
|
|
306193
|
-
import { existsSync as existsSync66, mkdirSync as mkdirSync35, writeFileSync as
|
|
306483
|
+
import { existsSync as existsSync66, mkdirSync as mkdirSync35, writeFileSync as writeFileSync33 } from "node:fs";
|
|
306194
306484
|
import { join as join83, resolve as resolve33, dirname as dirname24 } from "node:path";
|
|
306195
306485
|
import { homedir as homedir24 } from "node:os";
|
|
306196
306486
|
import { fileURLToPath as fileURLToPath15 } from "node:url";
|
|
@@ -306415,8 +306705,8 @@ chown -R node:node /workspace /home/node/.oa /home/node/.open-agents 2>/dev/null
|
|
|
306415
306705
|
if [ "$1" = "oa" ]; then shift; exec su - node -c "cd /workspace && oa $*"; fi
|
|
306416
306706
|
exec "$@"
|
|
306417
306707
|
`;
|
|
306418
|
-
|
|
306419
|
-
|
|
306708
|
+
writeFileSync33(join83(dir, "Dockerfile"), dockerfile);
|
|
306709
|
+
writeFileSync33(join83(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
|
|
306420
306710
|
}
|
|
306421
306711
|
function hasNvidiaGpu() {
|
|
306422
306712
|
try {
|
|
@@ -306495,7 +306785,7 @@ import { createRequire as createRequire4 } from "node:module";
|
|
|
306495
306785
|
import { fileURLToPath as fileURLToPath16 } from "node:url";
|
|
306496
306786
|
import { dirname as dirname25, join as join84, resolve as resolve34 } from "node:path";
|
|
306497
306787
|
import { spawn as spawn24, execSync as execSync44 } from "node:child_process";
|
|
306498
|
-
import { mkdirSync as mkdirSync36, writeFileSync as
|
|
306788
|
+
import { mkdirSync as mkdirSync36, writeFileSync as writeFileSync34, readFileSync as readFileSync53, readdirSync as readdirSync23, existsSync as existsSync67 } from "node:fs";
|
|
306499
306789
|
import { randomBytes as randomBytes19, randomUUID as randomUUID5 } from "node:crypto";
|
|
306500
306790
|
function getVersion3() {
|
|
306501
306791
|
try {
|
|
@@ -307376,7 +307666,7 @@ async function handleV1Run(req2, res) {
|
|
|
307376
307666
|
job.sandbox = sandbox;
|
|
307377
307667
|
}
|
|
307378
307668
|
job.pid = child.pid ?? 0;
|
|
307379
|
-
|
|
307669
|
+
writeFileSync34(join84(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
307380
307670
|
runningProcesses.set(id, child);
|
|
307381
307671
|
if (streamMode) {
|
|
307382
307672
|
res.writeHead(200, {
|
|
@@ -307403,7 +307693,7 @@ async function handleV1Run(req2, res) {
|
|
|
307403
307693
|
job.status = code8 === 0 ? "completed" : "failed";
|
|
307404
307694
|
job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
307405
307695
|
try {
|
|
307406
|
-
|
|
307696
|
+
writeFileSync34(join84(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
307407
307697
|
} catch {
|
|
307408
307698
|
}
|
|
307409
307699
|
runningProcesses.delete(id);
|
|
@@ -307443,7 +307733,7 @@ async function handleV1Run(req2, res) {
|
|
|
307443
307733
|
job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
307444
307734
|
}
|
|
307445
307735
|
try {
|
|
307446
|
-
|
|
307736
|
+
writeFileSync34(join84(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
307447
307737
|
} catch {
|
|
307448
307738
|
}
|
|
307449
307739
|
runningProcesses.delete(id);
|
|
@@ -307511,7 +307801,7 @@ function handleV1RunsDelete(res, id) {
|
|
|
307511
307801
|
job.error = "Aborted via API";
|
|
307512
307802
|
const dir = jobsDir();
|
|
307513
307803
|
try {
|
|
307514
|
-
|
|
307804
|
+
writeFileSync34(join84(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
307515
307805
|
} catch {
|
|
307516
307806
|
}
|
|
307517
307807
|
runningProcesses.delete(id);
|
|
@@ -308410,7 +308700,7 @@ import { cwd } from "node:process";
|
|
|
308410
308700
|
import { resolve as resolve35, join as join85, dirname as dirname26, extname as extname11 } from "node:path";
|
|
308411
308701
|
import { createRequire as createRequire5 } from "node:module";
|
|
308412
308702
|
import { fileURLToPath as fileURLToPath17 } from "node:url";
|
|
308413
|
-
import { readFileSync as readFileSync54, writeFileSync as
|
|
308703
|
+
import { readFileSync as readFileSync54, writeFileSync as writeFileSync35, appendFileSync as appendFileSync6, rmSync as rmSync4, readdirSync as readdirSync24, mkdirSync as mkdirSync37 } from "node:fs";
|
|
308414
308704
|
import { existsSync as existsSync68 } from "node:fs";
|
|
308415
308705
|
import { execSync as execSync45 } from "node:child_process";
|
|
308416
308706
|
import { homedir as homedir25 } from "node:os";
|
|
@@ -310054,7 +310344,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
310054
310344
|
}
|
|
310055
310345
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
310056
310346
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
310057
|
-
|
|
310347
|
+
writeFileSync35(ikFile, JSON.stringify(ikState, null, 2));
|
|
310058
310348
|
} catch (ikErr) {
|
|
310059
310349
|
try {
|
|
310060
310350
|
console.error("[IK-OBSERVE]", ikErr);
|
|
@@ -310086,7 +310376,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
310086
310376
|
if (ikState.version_history.length > 200) ikState.version_history = ikState.version_history.slice(-200);
|
|
310087
310377
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
310088
310378
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
310089
|
-
|
|
310379
|
+
writeFileSync35(ikFile, JSON.stringify(ikState, null, 2));
|
|
310090
310380
|
}
|
|
310091
310381
|
} catch {
|
|
310092
310382
|
}
|
|
@@ -311104,7 +311394,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
311104
311394
|
if (Math.random() < 0.02) {
|
|
311105
311395
|
const all2 = readFileSync54(HISTORY_FILE, "utf8").trim().split("\n");
|
|
311106
311396
|
if (all2.length > MAX_HISTORY_LINES) {
|
|
311107
|
-
|
|
311397
|
+
writeFileSync35(HISTORY_FILE, all2.slice(-MAX_HISTORY_LINES).join("\n") + "\n", "utf8");
|
|
311108
311398
|
}
|
|
311109
311399
|
}
|
|
311110
311400
|
} catch {
|
|
@@ -313811,7 +314101,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
313811
314101
|
ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
|
|
313812
314102
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
313813
314103
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
313814
|
-
|
|
314104
|
+
writeFileSync35(ikFile, JSON.stringify(ikState, null, 2));
|
|
313815
314105
|
} catch (ikErr) {
|
|
313816
314106
|
}
|
|
313817
314107
|
try {
|
|
@@ -313843,7 +314133,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
313843
314133
|
});
|
|
313844
314134
|
if (variants.length > 50) variants = variants.slice(-50);
|
|
313845
314135
|
mkdirSync37(archeDir, { recursive: true });
|
|
313846
|
-
|
|
314136
|
+
writeFileSync35(archeFile, JSON.stringify(variants, null, 2));
|
|
313847
314137
|
} catch {
|
|
313848
314138
|
}
|
|
313849
314139
|
}
|
|
@@ -313861,7 +314151,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
|
|
|
313861
314151
|
updated = true;
|
|
313862
314152
|
}
|
|
313863
314153
|
if (updated) {
|
|
313864
|
-
|
|
314154
|
+
writeFileSync35(metaFile, JSON.stringify(store2, null, 2));
|
|
313865
314155
|
}
|
|
313866
314156
|
}
|
|
313867
314157
|
} catch {
|
|
@@ -313951,7 +314241,7 @@ Rules:
|
|
|
313951
314241
|
});
|
|
313952
314242
|
if (store2.length > 100) store2 = store2.slice(-100);
|
|
313953
314243
|
mkdirSync37(metaDir, { recursive: true });
|
|
313954
|
-
|
|
314244
|
+
writeFileSync35(storeFile, JSON.stringify(store2, null, 2));
|
|
313955
314245
|
}
|
|
313956
314246
|
}
|
|
313957
314247
|
} catch {
|
|
@@ -314001,7 +314291,7 @@ Rules:
|
|
|
314001
314291
|
ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
|
|
314002
314292
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
314003
314293
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
314004
|
-
|
|
314294
|
+
writeFileSync35(ikFile, JSON.stringify(ikState, null, 2));
|
|
314005
314295
|
}
|
|
314006
314296
|
const metaFile = join85(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
314007
314297
|
if (existsSync68(metaFile)) {
|
|
@@ -314013,7 +314303,7 @@ Rules:
|
|
|
314013
314303
|
item.scores.utility = Math.max(0, (item.scores.utility || 0.5) - 0.05);
|
|
314014
314304
|
item.scores.confidence = Math.max(0, (item.scores.confidence || 0.5) - 0.02);
|
|
314015
314305
|
}
|
|
314016
|
-
|
|
314306
|
+
writeFileSync35(metaFile, JSON.stringify(store2, null, 2));
|
|
314017
314307
|
}
|
|
314018
314308
|
try {
|
|
314019
314309
|
const archeDir = join85(repoRoot, ".oa", "arche");
|
|
@@ -314035,7 +314325,7 @@ Rules:
|
|
|
314035
314325
|
});
|
|
314036
314326
|
if (variants.length > 50) variants = variants.slice(-50);
|
|
314037
314327
|
mkdirSync37(archeDir, { recursive: true });
|
|
314038
|
-
|
|
314328
|
+
writeFileSync35(archeFile, JSON.stringify(variants, null, 2));
|
|
314039
314329
|
} catch {
|
|
314040
314330
|
}
|
|
314041
314331
|
} catch {
|
|
@@ -314117,7 +314407,7 @@ __export(run_exports, {
|
|
|
314117
314407
|
});
|
|
314118
314408
|
import { resolve as resolve36 } from "node:path";
|
|
314119
314409
|
import { spawn as spawn25 } from "node:child_process";
|
|
314120
|
-
import { mkdirSync as mkdirSync38, writeFileSync as
|
|
314410
|
+
import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync36, readFileSync as readFileSync55, readdirSync as readdirSync25, existsSync as existsSync69 } from "node:fs";
|
|
314121
314411
|
import { randomBytes as randomBytes20 } from "node:crypto";
|
|
314122
314412
|
import { join as join86 } from "node:path";
|
|
314123
314413
|
function jobsDir2(repoPath) {
|
|
@@ -314238,7 +314528,7 @@ async function runBackground(task, config, opts) {
|
|
|
314238
314528
|
}
|
|
314239
314529
|
});
|
|
314240
314530
|
job.pid = child.pid ?? 0;
|
|
314241
|
-
|
|
314531
|
+
writeFileSync36(join86(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
314242
314532
|
let output = "";
|
|
314243
314533
|
child.stdout?.on("data", (chunk) => {
|
|
314244
314534
|
output += chunk.toString();
|
|
@@ -314254,7 +314544,7 @@ async function runBackground(task, config, opts) {
|
|
|
314254
314544
|
job.summary = result.summary;
|
|
314255
314545
|
job.durationMs = result.durationMs;
|
|
314256
314546
|
job.error = result.error;
|
|
314257
|
-
|
|
314547
|
+
writeFileSync36(join86(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
314258
314548
|
} catch {
|
|
314259
314549
|
}
|
|
314260
314550
|
});
|
|
@@ -314529,7 +314819,7 @@ __export(index_repo_exports, {
|
|
|
314529
314819
|
indexRepoCommand: () => indexRepoCommand
|
|
314530
314820
|
});
|
|
314531
314821
|
import { resolve as resolve37 } from "node:path";
|
|
314532
|
-
import { existsSync as existsSync70, statSync as
|
|
314822
|
+
import { existsSync as existsSync70, statSync as statSync20 } from "node:fs";
|
|
314533
314823
|
import { cwd as cwd2 } from "node:process";
|
|
314534
314824
|
async function indexRepoCommand(opts, _config3) {
|
|
314535
314825
|
const repoRoot = resolve37(opts.repoPath ?? cwd2());
|
|
@@ -314539,7 +314829,7 @@ async function indexRepoCommand(opts, _config3) {
|
|
|
314539
314829
|
printError(`Path does not exist: ${repoRoot}`);
|
|
314540
314830
|
process.exit(1);
|
|
314541
314831
|
}
|
|
314542
|
-
const stat6 =
|
|
314832
|
+
const stat6 = statSync20(repoRoot);
|
|
314543
314833
|
if (!stat6.isDirectory()) {
|
|
314544
314834
|
printError(`Path is not a directory: ${repoRoot}`);
|
|
314545
314835
|
process.exit(1);
|
|
@@ -315077,7 +315367,7 @@ __export(eval_exports, {
|
|
|
315077
315367
|
evalCommand: () => evalCommand
|
|
315078
315368
|
});
|
|
315079
315369
|
import { tmpdir as tmpdir13 } from "node:os";
|
|
315080
|
-
import { mkdirSync as mkdirSync39, writeFileSync as
|
|
315370
|
+
import { mkdirSync as mkdirSync39, writeFileSync as writeFileSync37 } from "node:fs";
|
|
315081
315371
|
import { join as join89 } from "node:path";
|
|
315082
315372
|
async function evalCommand(opts, config) {
|
|
315083
315373
|
const suiteName = opts.suite ?? "basic";
|
|
@@ -315209,7 +315499,7 @@ async function evalCommand(opts, config) {
|
|
|
315209
315499
|
function createTempEvalRepo() {
|
|
315210
315500
|
const dir = join89(tmpdir13(), `open-agents-eval-${Date.now()}`);
|
|
315211
315501
|
mkdirSync39(dir, { recursive: true });
|
|
315212
|
-
|
|
315502
|
+
writeFileSync37(
|
|
315213
315503
|
join89(dir, "package.json"),
|
|
315214
315504
|
JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n",
|
|
315215
315505
|
"utf8"
|