open-agents-ai 0.184.43 → 0.184.45
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 +636 -416
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -672,20 +672,20 @@ var init_VllmBackend = __esm({
|
|
|
672
672
|
// -------------------------------------------------------------------------
|
|
673
673
|
// LLMBackend — complete
|
|
674
674
|
// -------------------------------------------------------------------------
|
|
675
|
-
async complete(
|
|
676
|
-
const messages =
|
|
675
|
+
async complete(request) {
|
|
676
|
+
const messages = request.messages.map(agentMessageToChatMessage);
|
|
677
677
|
const body = {
|
|
678
678
|
model: this.model,
|
|
679
679
|
messages,
|
|
680
|
-
temperature:
|
|
681
|
-
max_tokens:
|
|
680
|
+
temperature: request.temperature ?? 0,
|
|
681
|
+
max_tokens: request.maxTokens ?? 4096
|
|
682
682
|
};
|
|
683
|
-
if (
|
|
684
|
-
body.tools =
|
|
683
|
+
if (request.tools && request.tools.length > 0) {
|
|
684
|
+
body.tools = request.tools;
|
|
685
685
|
body.tool_choice = "auto";
|
|
686
686
|
}
|
|
687
|
-
if (
|
|
688
|
-
body.response_format =
|
|
687
|
+
if (request.responseFormat) {
|
|
688
|
+
body.response_format = request.responseFormat;
|
|
689
689
|
}
|
|
690
690
|
const start = Date.now();
|
|
691
691
|
const rawResponse = await this.postWithRetry("/v1/chat/completions", body);
|
|
@@ -822,24 +822,24 @@ var init_OllamaBackend = __esm({
|
|
|
822
822
|
// -------------------------------------------------------------------------
|
|
823
823
|
// LLMBackend — complete
|
|
824
824
|
// -------------------------------------------------------------------------
|
|
825
|
-
async complete(
|
|
826
|
-
const messages =
|
|
825
|
+
async complete(request) {
|
|
826
|
+
const messages = request.messages.map(agentMessageToChatMessage2);
|
|
827
827
|
const body = {
|
|
828
828
|
model: this.model,
|
|
829
829
|
messages,
|
|
830
|
-
temperature:
|
|
831
|
-
max_tokens:
|
|
830
|
+
temperature: request.temperature ?? 0,
|
|
831
|
+
max_tokens: request.maxTokens ?? 4096,
|
|
832
832
|
// Disable Qwen thinking mode by default so tokens go to content,
|
|
833
833
|
// not reasoning. The model still produces good output without it
|
|
834
834
|
// and coding agents need structured JSON in the content field.
|
|
835
835
|
think: false
|
|
836
836
|
};
|
|
837
|
-
if (
|
|
838
|
-
body.tools =
|
|
837
|
+
if (request.tools && request.tools.length > 0) {
|
|
838
|
+
body.tools = request.tools;
|
|
839
839
|
body.tool_choice = "auto";
|
|
840
840
|
}
|
|
841
|
-
if (
|
|
842
|
-
body.response_format =
|
|
841
|
+
if (request.responseFormat) {
|
|
842
|
+
body.response_format = request.responseFormat;
|
|
843
843
|
}
|
|
844
844
|
const start = Date.now();
|
|
845
845
|
const rawResponse = await this.postWithRetry("/v1/chat/completions", body);
|
|
@@ -1003,19 +1003,19 @@ var init_FakeBackend = __esm({
|
|
|
1003
1003
|
this._healthCheckCount++;
|
|
1004
1004
|
return this.options.healthy;
|
|
1005
1005
|
}
|
|
1006
|
-
async complete(
|
|
1006
|
+
async complete(request) {
|
|
1007
1007
|
this._completeCount++;
|
|
1008
1008
|
if (this.options.shouldThrow) {
|
|
1009
1009
|
throw new Error(this.options.errorMessage);
|
|
1010
1010
|
}
|
|
1011
|
-
const lastMessage =
|
|
1011
|
+
const lastMessage = request.messages[request.messages.length - 1];
|
|
1012
1012
|
const inputKey = lastMessage ? `${lastMessage.role}:${lastMessage.content}` : "empty";
|
|
1013
1013
|
const hash = fnv1a32(inputKey);
|
|
1014
1014
|
const deterministicContent = `fake-response-${hash.toString(16).padStart(8, "0")}`;
|
|
1015
1015
|
const usage = {
|
|
1016
|
-
prompt_tokens:
|
|
1016
|
+
prompt_tokens: request.messages.length * 10,
|
|
1017
1017
|
completion_tokens: 20,
|
|
1018
|
-
total_tokens:
|
|
1018
|
+
total_tokens: request.messages.length * 10 + 20
|
|
1019
1019
|
};
|
|
1020
1020
|
if (this.options.toolCallResponses.length > 0) {
|
|
1021
1021
|
return {
|
|
@@ -11711,13 +11711,13 @@ Validation: ${validation.pass ? "PASS" : "NEEDS IMPROVEMENT"} (${validation.over
|
|
|
11711
11711
|
// -------------------------------------------------------------------------
|
|
11712
11712
|
// Phase 1: Seed Analysis
|
|
11713
11713
|
// -------------------------------------------------------------------------
|
|
11714
|
-
async analyzeSeed(
|
|
11714
|
+
async analyzeSeed(request) {
|
|
11715
11715
|
const prompt = loadBuilderPrompt("seed-analysis.md", {
|
|
11716
|
-
skill_request:
|
|
11716
|
+
skill_request: request
|
|
11717
11717
|
});
|
|
11718
11718
|
const response = await this.llmCall([
|
|
11719
11719
|
{ role: "system", content: prompt },
|
|
11720
|
-
{ role: "user", content: `Analyze this skill request: "${
|
|
11720
|
+
{ role: "user", content: `Analyze this skill request: "${request}"` }
|
|
11721
11721
|
]);
|
|
11722
11722
|
const jsonStr = extractJSON(response);
|
|
11723
11723
|
const seed = JSON.parse(jsonStr);
|
|
@@ -13598,9 +13598,9 @@ print("${sentinel}")
|
|
|
13598
13598
|
if (!this.proc || this.proc.killed) {
|
|
13599
13599
|
return { success: false, path: "" };
|
|
13600
13600
|
}
|
|
13601
|
-
const { mkdirSync:
|
|
13601
|
+
const { mkdirSync: mkdirSync30, writeFileSync: writeFileSync29 } = await import("node:fs");
|
|
13602
13602
|
const sessionDir = join22(this.cwd, ".oa", "rlm");
|
|
13603
|
-
|
|
13603
|
+
mkdirSync30(sessionDir, { recursive: true });
|
|
13604
13604
|
const sessionPath = join22(sessionDir, "session.json");
|
|
13605
13605
|
try {
|
|
13606
13606
|
const inspectCode = `
|
|
@@ -13624,7 +13624,7 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
13624
13624
|
trajectoryCount: this.trajectory.length,
|
|
13625
13625
|
subCallCount: this.subCallCount
|
|
13626
13626
|
};
|
|
13627
|
-
|
|
13627
|
+
writeFileSync29(sessionPath, JSON.stringify(sessionData, null, 2), "utf8");
|
|
13628
13628
|
return { success: true, path: sessionPath };
|
|
13629
13629
|
}
|
|
13630
13630
|
} catch {
|
|
@@ -13636,11 +13636,11 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
13636
13636
|
* what was previously computed. */
|
|
13637
13637
|
async loadSessionInfo() {
|
|
13638
13638
|
try {
|
|
13639
|
-
const { readFileSync:
|
|
13639
|
+
const { readFileSync: readFileSync44, existsSync: existsSync56 } = await import("node:fs");
|
|
13640
13640
|
const sessionPath = join22(this.cwd, ".oa", "rlm", "session.json");
|
|
13641
|
-
if (!
|
|
13641
|
+
if (!existsSync56(sessionPath))
|
|
13642
13642
|
return null;
|
|
13643
|
-
return JSON.parse(
|
|
13643
|
+
return JSON.parse(readFileSync44(sessionPath, "utf8"));
|
|
13644
13644
|
} catch {
|
|
13645
13645
|
return null;
|
|
13646
13646
|
}
|
|
@@ -13817,10 +13817,10 @@ var init_memory_metabolism = __esm({
|
|
|
13817
13817
|
const trajDir = join23(this.cwd, ".oa", "rlm-trajectories");
|
|
13818
13818
|
let lessons = [];
|
|
13819
13819
|
try {
|
|
13820
|
-
const { readdirSync: readdirSync23, readFileSync:
|
|
13820
|
+
const { readdirSync: readdirSync23, readFileSync: readFileSync44 } = await import("node:fs");
|
|
13821
13821
|
const files = readdirSync23(trajDir).filter((f) => f.endsWith(".jsonl")).sort().reverse().slice(0, 3);
|
|
13822
13822
|
for (const file of files) {
|
|
13823
|
-
const lines =
|
|
13823
|
+
const lines = readFileSync44(join23(trajDir, file), "utf8").split("\n").filter((l) => l.trim());
|
|
13824
13824
|
for (const line of lines) {
|
|
13825
13825
|
try {
|
|
13826
13826
|
const entry = JSON.parse(line);
|
|
@@ -14204,14 +14204,14 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
|
|
|
14204
14204
|
* Optionally filter by task type for phase-aware context (FSM paper insight).
|
|
14205
14205
|
*/
|
|
14206
14206
|
getTopMemoriesSync(k = 5, taskType) {
|
|
14207
|
-
const { readFileSync:
|
|
14207
|
+
const { readFileSync: readFileSync44, existsSync: existsSync56 } = __require("node:fs");
|
|
14208
14208
|
const metaDir = join23(this.cwd, ".oa", "memory", "metabolism");
|
|
14209
14209
|
const storeFile = join23(metaDir, "store.json");
|
|
14210
|
-
if (!
|
|
14210
|
+
if (!existsSync56(storeFile))
|
|
14211
14211
|
return "";
|
|
14212
14212
|
let store = [];
|
|
14213
14213
|
try {
|
|
14214
|
-
store = JSON.parse(
|
|
14214
|
+
store = JSON.parse(readFileSync44(storeFile, "utf8"));
|
|
14215
14215
|
} catch {
|
|
14216
14216
|
return "";
|
|
14217
14217
|
}
|
|
@@ -14233,14 +14233,14 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
|
|
|
14233
14233
|
/** Update memory scores based on task outcome. Called after task completion.
|
|
14234
14234
|
* Memories used in successful tasks get boosted. Memories present during failures get decayed. */
|
|
14235
14235
|
updateFromOutcomeSync(surfacedMemoryText, succeeded) {
|
|
14236
|
-
const { readFileSync:
|
|
14236
|
+
const { readFileSync: readFileSync44, writeFileSync: writeFileSync29, existsSync: existsSync56, mkdirSync: mkdirSync30 } = __require("node:fs");
|
|
14237
14237
|
const metaDir = join23(this.cwd, ".oa", "memory", "metabolism");
|
|
14238
14238
|
const storeFile = join23(metaDir, "store.json");
|
|
14239
|
-
if (!
|
|
14239
|
+
if (!existsSync56(storeFile))
|
|
14240
14240
|
return;
|
|
14241
14241
|
let store = [];
|
|
14242
14242
|
try {
|
|
14243
|
-
store = JSON.parse(
|
|
14243
|
+
store = JSON.parse(readFileSync44(storeFile, "utf8"));
|
|
14244
14244
|
} catch {
|
|
14245
14245
|
return;
|
|
14246
14246
|
}
|
|
@@ -14264,8 +14264,8 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
|
|
|
14264
14264
|
updated = true;
|
|
14265
14265
|
}
|
|
14266
14266
|
if (updated) {
|
|
14267
|
-
|
|
14268
|
-
|
|
14267
|
+
mkdirSync30(metaDir, { recursive: true });
|
|
14268
|
+
writeFileSync29(storeFile, JSON.stringify(store, null, 2));
|
|
14269
14269
|
}
|
|
14270
14270
|
}
|
|
14271
14271
|
// ── Storage ──────────────────────────────────────────────────────────
|
|
@@ -14687,13 +14687,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
14687
14687
|
// Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
|
|
14688
14688
|
/** Retrieve top-K strategies for context injection. Returns "" if none. */
|
|
14689
14689
|
getRelevantStrategiesSync(k = 3, taskType) {
|
|
14690
|
-
const { readFileSync:
|
|
14690
|
+
const { readFileSync: readFileSync44, existsSync: existsSync56 } = __require("node:fs");
|
|
14691
14691
|
const archiveFile = join25(this.cwd, ".oa", "arche", "variants.json");
|
|
14692
|
-
if (!
|
|
14692
|
+
if (!existsSync56(archiveFile))
|
|
14693
14693
|
return "";
|
|
14694
14694
|
let variants = [];
|
|
14695
14695
|
try {
|
|
14696
|
-
variants = JSON.parse(
|
|
14696
|
+
variants = JSON.parse(readFileSync44(archiveFile, "utf8"));
|
|
14697
14697
|
} catch {
|
|
14698
14698
|
return "";
|
|
14699
14699
|
}
|
|
@@ -14711,13 +14711,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
14711
14711
|
}
|
|
14712
14712
|
/** Archive a strategy variant synchronously (for task completion path) */
|
|
14713
14713
|
archiveVariantSync(strategy, outcome, tags = []) {
|
|
14714
|
-
const { readFileSync:
|
|
14714
|
+
const { readFileSync: readFileSync44, writeFileSync: writeFileSync29, existsSync: existsSync56, mkdirSync: mkdirSync30 } = __require("node:fs");
|
|
14715
14715
|
const dir = join25(this.cwd, ".oa", "arche");
|
|
14716
14716
|
const archiveFile = join25(dir, "variants.json");
|
|
14717
14717
|
let variants = [];
|
|
14718
14718
|
try {
|
|
14719
|
-
if (
|
|
14720
|
-
variants = JSON.parse(
|
|
14719
|
+
if (existsSync56(archiveFile))
|
|
14720
|
+
variants = JSON.parse(readFileSync44(archiveFile, "utf8"));
|
|
14721
14721
|
} catch {
|
|
14722
14722
|
}
|
|
14723
14723
|
variants.push({
|
|
@@ -14732,8 +14732,8 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
14732
14732
|
});
|
|
14733
14733
|
if (variants.length > 50)
|
|
14734
14734
|
variants = variants.slice(-50);
|
|
14735
|
-
|
|
14736
|
-
|
|
14735
|
+
mkdirSync30(dir, { recursive: true });
|
|
14736
|
+
writeFileSync29(archiveFile, JSON.stringify(variants, null, 2));
|
|
14737
14737
|
}
|
|
14738
14738
|
async saveArchive(variants) {
|
|
14739
14739
|
const dir = join25(this.cwd, ".oa", "arche");
|
|
@@ -24287,22 +24287,22 @@ var init_snippetPacker = __esm({
|
|
|
24287
24287
|
});
|
|
24288
24288
|
|
|
24289
24289
|
// packages/retrieval/dist/contextAssembler.js
|
|
24290
|
-
async function assembleContext(
|
|
24290
|
+
async function assembleContext(request, opts) {
|
|
24291
24291
|
const { repoRoot, graph, semanticEngine, summaryMap, maxFiles = 8, maxSnippets = 20, maxLogs = 3, maxTokens = 24e3, expandNeighbors = true, architectureNote, priorAttemptNote } = opts;
|
|
24292
24292
|
const lexOpts = {
|
|
24293
24293
|
rootDir: repoRoot,
|
|
24294
24294
|
includePatterns: [],
|
|
24295
|
-
includeTests:
|
|
24296
|
-
includeConfigs:
|
|
24295
|
+
includeTests: request.includeTests,
|
|
24296
|
+
includeConfigs: request.includeConfigs,
|
|
24297
24297
|
maxMatches: 30
|
|
24298
24298
|
};
|
|
24299
24299
|
const [pathMatches, symbolMatches, errorMatches, semanticResults] = await Promise.all([
|
|
24300
|
-
Promise.all(
|
|
24301
|
-
Promise.all(
|
|
24302
|
-
Promise.all(
|
|
24303
|
-
semanticEngine?.isAvailable ? semanticEngine.search(
|
|
24300
|
+
Promise.all(request.pathsHint.map((p) => searchByPath(p, { rootDir: repoRoot, maxMatches: 10 }))).then((res) => res.flat()),
|
|
24301
|
+
Promise.all(request.symbolHint.map((s) => searchBySymbol(s, { rootDir: repoRoot, maxMatches: 10 }))).then((res) => res.flat()),
|
|
24302
|
+
Promise.all(request.errorHint.slice(0, maxLogs).map((e) => searchByError(e, { rootDir: repoRoot, maxMatches: 5 }))).then((res) => res.flat()),
|
|
24303
|
+
semanticEngine?.isAvailable ? semanticEngine.search(request.query, maxFiles) : Promise.resolve([])
|
|
24304
24304
|
]);
|
|
24305
|
-
const queryType = classifyQuery(
|
|
24305
|
+
const queryType = classifyQuery(request.query);
|
|
24306
24306
|
const rrfK = adaptiveK(queryType, opts.rrfConfig?.k);
|
|
24307
24307
|
const wFts = opts.rrfConfig?.weightFts ?? 1;
|
|
24308
24308
|
const wSem = opts.rrfConfig?.weightSemantic ?? 1;
|
|
@@ -24373,7 +24373,7 @@ async function assembleContext(request2, opts) {
|
|
|
24373
24373
|
}
|
|
24374
24374
|
}
|
|
24375
24375
|
return {
|
|
24376
|
-
request
|
|
24376
|
+
request,
|
|
24377
24377
|
files,
|
|
24378
24378
|
snippets: packed.slice(0, maxSnippets),
|
|
24379
24379
|
architectureNote,
|
|
@@ -27091,10 +27091,10 @@ ${marker}` : marker);
|
|
|
27091
27091
|
if (!this._workingDirectory)
|
|
27092
27092
|
return;
|
|
27093
27093
|
try {
|
|
27094
|
-
const { mkdirSync:
|
|
27095
|
-
const { join:
|
|
27096
|
-
const sessionDir =
|
|
27097
|
-
|
|
27094
|
+
const { mkdirSync: mkdirSync30, writeFileSync: writeFileSync29 } = __require("node:fs");
|
|
27095
|
+
const { join: join76 } = __require("node:path");
|
|
27096
|
+
const sessionDir = join76(this._workingDirectory, ".oa", "session", this._sessionId);
|
|
27097
|
+
mkdirSync30(sessionDir, { recursive: true });
|
|
27098
27098
|
const checkpoint = {
|
|
27099
27099
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
27100
27100
|
sessionId: this._sessionId,
|
|
@@ -27106,7 +27106,7 @@ ${marker}` : marker);
|
|
|
27106
27106
|
memexEntryCount: this._memexArchive.size,
|
|
27107
27107
|
fileRegistrySize: this._fileRegistry.size
|
|
27108
27108
|
};
|
|
27109
|
-
|
|
27109
|
+
writeFileSync29(join76(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
27110
27110
|
} catch {
|
|
27111
27111
|
}
|
|
27112
27112
|
}
|
|
@@ -28232,14 +28232,14 @@ ${transcript}`
|
|
|
28232
28232
|
* assembles and returns the same response format as chatCompletion().
|
|
28233
28233
|
* The non-streaming chatCompletion path is NEVER touched by this code.
|
|
28234
28234
|
*/
|
|
28235
|
-
async streamingRequest(
|
|
28235
|
+
async streamingRequest(request, turn) {
|
|
28236
28236
|
const backend = this.backend;
|
|
28237
28237
|
let content = "";
|
|
28238
28238
|
let inThinkTag = false;
|
|
28239
28239
|
const toolCallAccumulators = /* @__PURE__ */ new Map();
|
|
28240
28240
|
let streamUsage;
|
|
28241
28241
|
this.emit({ type: "stream_start", turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
28242
|
-
for await (const chunk of backend.chatCompletionStream(
|
|
28242
|
+
for await (const chunk of backend.chatCompletionStream(request)) {
|
|
28243
28243
|
if (this.aborted)
|
|
28244
28244
|
break;
|
|
28245
28245
|
if (chunk.type === "usage" && chunk.usage) {
|
|
@@ -28349,13 +28349,13 @@ ${transcript}`
|
|
|
28349
28349
|
}
|
|
28350
28350
|
return headers;
|
|
28351
28351
|
}
|
|
28352
|
-
async chatCompletion(
|
|
28352
|
+
async chatCompletion(request) {
|
|
28353
28353
|
const body = {
|
|
28354
28354
|
model: this.model,
|
|
28355
|
-
messages:
|
|
28356
|
-
tools:
|
|
28357
|
-
temperature:
|
|
28358
|
-
max_tokens:
|
|
28355
|
+
messages: request.messages,
|
|
28356
|
+
tools: request.tools,
|
|
28357
|
+
temperature: request.temperature,
|
|
28358
|
+
max_tokens: request.maxTokens,
|
|
28359
28359
|
think: this.thinking
|
|
28360
28360
|
};
|
|
28361
28361
|
const fetchOpts = {
|
|
@@ -28412,13 +28412,13 @@ ${transcript}`
|
|
|
28412
28412
|
* Uses `stream: true` and the current thinking setting.
|
|
28413
28413
|
* The existing chatCompletion() method is completely unmodified.
|
|
28414
28414
|
*/
|
|
28415
|
-
async *chatCompletionStream(
|
|
28415
|
+
async *chatCompletionStream(request) {
|
|
28416
28416
|
const body = {
|
|
28417
28417
|
model: this.model,
|
|
28418
|
-
messages:
|
|
28419
|
-
tools:
|
|
28420
|
-
temperature:
|
|
28421
|
-
max_tokens:
|
|
28418
|
+
messages: request.messages,
|
|
28419
|
+
tools: request.tools,
|
|
28420
|
+
temperature: request.temperature,
|
|
28421
|
+
max_tokens: request.maxTokens,
|
|
28422
28422
|
stream: true,
|
|
28423
28423
|
stream_options: { include_usage: true },
|
|
28424
28424
|
think: this.thinking
|
|
@@ -28538,7 +28538,7 @@ var init_nexusBackend = __esm({
|
|
|
28538
28538
|
this.targetPeer = peerId;
|
|
28539
28539
|
this.consecutiveFailures = 0;
|
|
28540
28540
|
}
|
|
28541
|
-
async chatCompletion(
|
|
28541
|
+
async chatCompletion(request) {
|
|
28542
28542
|
if (this.consecutiveFailures >= _NexusAgenticBackend.MAX_CONSECUTIVE_FAILURES) {
|
|
28543
28543
|
const err = new Error(`Remote peer unreachable after ${this.consecutiveFailures} attempts. Use /endpoint to switch to a local model or reconnect.`);
|
|
28544
28544
|
err.fatal = true;
|
|
@@ -28546,10 +28546,10 @@ var init_nexusBackend = __esm({
|
|
|
28546
28546
|
}
|
|
28547
28547
|
const daemonArgs = {
|
|
28548
28548
|
model: this.model,
|
|
28549
|
-
messages: JSON.stringify(
|
|
28550
|
-
tools: JSON.stringify(
|
|
28551
|
-
temperature: String(
|
|
28552
|
-
max_tokens: String(
|
|
28549
|
+
messages: JSON.stringify(request.messages),
|
|
28550
|
+
tools: JSON.stringify(request.tools),
|
|
28551
|
+
temperature: String(request.temperature),
|
|
28552
|
+
max_tokens: String(request.maxTokens)
|
|
28553
28553
|
};
|
|
28554
28554
|
if (this.targetPeer) {
|
|
28555
28555
|
daemonArgs.target_peer = this.targetPeer;
|
|
@@ -28560,7 +28560,7 @@ var init_nexusBackend = __esm({
|
|
|
28560
28560
|
daemonArgs.think = String(this.thinking);
|
|
28561
28561
|
let rawResult;
|
|
28562
28562
|
try {
|
|
28563
|
-
rawResult = await this.sendFn("remote_infer", daemonArgs,
|
|
28563
|
+
rawResult = await this.sendFn("remote_infer", daemonArgs, request.timeoutMs || 12e4);
|
|
28564
28564
|
} catch (sendErr) {
|
|
28565
28565
|
this.consecutiveFailures++;
|
|
28566
28566
|
throw sendErr;
|
|
@@ -28653,15 +28653,15 @@ var init_nexusBackend = __esm({
|
|
|
28653
28653
|
* the file for token-by-token delivery from the remote peer.
|
|
28654
28654
|
* Falls back to unary + word-split if streaming setup fails.
|
|
28655
28655
|
*/
|
|
28656
|
-
async *chatCompletionStream(
|
|
28656
|
+
async *chatCompletionStream(request) {
|
|
28657
28657
|
const streamFile = join47(tmpdir7(), `nexus-stream-${randomBytes11(6).toString("hex")}.jsonl`);
|
|
28658
28658
|
writeFileSync11(streamFile, "", "utf8");
|
|
28659
28659
|
const daemonArgs = {
|
|
28660
28660
|
model: this.model,
|
|
28661
|
-
messages: JSON.stringify(
|
|
28662
|
-
tools: JSON.stringify(
|
|
28663
|
-
temperature: String(
|
|
28664
|
-
max_tokens: String(
|
|
28661
|
+
messages: JSON.stringify(request.messages),
|
|
28662
|
+
tools: JSON.stringify(request.tools),
|
|
28663
|
+
temperature: String(request.temperature),
|
|
28664
|
+
max_tokens: String(request.maxTokens),
|
|
28665
28665
|
stream_file: streamFile
|
|
28666
28666
|
};
|
|
28667
28667
|
if (this.targetPeer)
|
|
@@ -28671,7 +28671,7 @@ var init_nexusBackend = __esm({
|
|
|
28671
28671
|
daemonArgs.think = String(this.thinking);
|
|
28672
28672
|
let rawResult;
|
|
28673
28673
|
try {
|
|
28674
|
-
rawResult = await this.sendFn("remote_infer", daemonArgs,
|
|
28674
|
+
rawResult = await this.sendFn("remote_infer", daemonArgs, request.timeoutMs || 12e4);
|
|
28675
28675
|
} catch (sendErr) {
|
|
28676
28676
|
this.consecutiveFailures++;
|
|
28677
28677
|
try {
|
|
@@ -28744,7 +28744,7 @@ var init_nexusBackend = __esm({
|
|
|
28744
28744
|
this.consecutiveFailures = 0;
|
|
28745
28745
|
let position = 0;
|
|
28746
28746
|
let done = false;
|
|
28747
|
-
const deadline = Date.now() + (
|
|
28747
|
+
const deadline = Date.now() + (request.timeoutMs ?? 12e4);
|
|
28748
28748
|
try {
|
|
28749
28749
|
while (!done && Date.now() < deadline) {
|
|
28750
28750
|
await new Promise((resolve36) => {
|
|
@@ -28917,10 +28917,10 @@ var init_cascadeBackend = __esm({
|
|
|
28917
28917
|
get fallbackCount() {
|
|
28918
28918
|
return this.endpoints.filter((ep, i) => i !== this.activeIndex && ep.modelAvailable !== false).length;
|
|
28919
28919
|
}
|
|
28920
|
-
async chatCompletion(
|
|
28920
|
+
async chatCompletion(request) {
|
|
28921
28921
|
const backend = this.getActiveBackend();
|
|
28922
28922
|
try {
|
|
28923
|
-
const result = await backend.chatCompletion(
|
|
28923
|
+
const result = await backend.chatCompletion(request);
|
|
28924
28924
|
this.consecutiveFailures = 0;
|
|
28925
28925
|
return result;
|
|
28926
28926
|
} catch (err) {
|
|
@@ -28936,7 +28936,7 @@ var init_cascadeBackend = __esm({
|
|
|
28936
28936
|
this.onSwitch?.(from, to, reason);
|
|
28937
28937
|
const newBackend = this.getActiveBackend();
|
|
28938
28938
|
try {
|
|
28939
|
-
const result = await newBackend.chatCompletion(
|
|
28939
|
+
const result = await newBackend.chatCompletion(request);
|
|
28940
28940
|
return result;
|
|
28941
28941
|
} catch (cascadeErr) {
|
|
28942
28942
|
this.consecutiveFailures++;
|
|
@@ -28950,11 +28950,11 @@ var init_cascadeBackend = __esm({
|
|
|
28950
28950
|
/**
|
|
28951
28951
|
* Streaming support — delegates to active backend's stream method if available.
|
|
28952
28952
|
*/
|
|
28953
|
-
async *chatCompletionStream(
|
|
28953
|
+
async *chatCompletionStream(request) {
|
|
28954
28954
|
const backend = this.getActiveBackend();
|
|
28955
28955
|
const streamable = backend;
|
|
28956
28956
|
if (typeof streamable.chatCompletionStream !== "function") {
|
|
28957
|
-
const result = await this.chatCompletion(
|
|
28957
|
+
const result = await this.chatCompletion(request);
|
|
28958
28958
|
const choice = result.choices[0];
|
|
28959
28959
|
if (choice?.message.content) {
|
|
28960
28960
|
yield { type: "content", content: choice.message.content };
|
|
@@ -28985,7 +28985,7 @@ var init_cascadeBackend = __esm({
|
|
|
28985
28985
|
return;
|
|
28986
28986
|
}
|
|
28987
28987
|
try {
|
|
28988
|
-
for await (const chunk of streamable.chatCompletionStream(
|
|
28988
|
+
for await (const chunk of streamable.chatCompletionStream(request)) {
|
|
28989
28989
|
yield chunk;
|
|
28990
28990
|
}
|
|
28991
28991
|
this.consecutiveFailures = 0;
|
|
@@ -28999,7 +28999,7 @@ var init_cascadeBackend = __esm({
|
|
|
28999
28999
|
this.activeIndex = nextIdx;
|
|
29000
29000
|
this.consecutiveFailures = 0;
|
|
29001
29001
|
this.onSwitch?.(from, to, err instanceof Error ? err.message : String(err));
|
|
29002
|
-
const result = await this.chatCompletion(
|
|
29002
|
+
const result = await this.chatCompletion(request);
|
|
29003
29003
|
const choice = result.choices[0];
|
|
29004
29004
|
if (choice?.message.content) {
|
|
29005
29005
|
yield { type: "content", content: choice.message.content };
|
|
@@ -32596,7 +32596,7 @@ var require_websocket = __commonJS({
|
|
|
32596
32596
|
"node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/websocket.js"(exports, module) {
|
|
32597
32597
|
"use strict";
|
|
32598
32598
|
var EventEmitter7 = __require("events");
|
|
32599
|
-
var
|
|
32599
|
+
var https2 = __require("https");
|
|
32600
32600
|
var http2 = __require("http");
|
|
32601
32601
|
var net = __require("net");
|
|
32602
32602
|
var tls = __require("tls");
|
|
@@ -33131,7 +33131,7 @@ var require_websocket = __commonJS({
|
|
|
33131
33131
|
}
|
|
33132
33132
|
const defaultPort = isSecure ? 443 : 80;
|
|
33133
33133
|
const key = randomBytes18(16).toString("base64");
|
|
33134
|
-
const
|
|
33134
|
+
const request = isSecure ? https2.request : http2.request;
|
|
33135
33135
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
33136
33136
|
let perMessageDeflate;
|
|
33137
33137
|
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
@@ -33208,12 +33208,12 @@ var require_websocket = __commonJS({
|
|
|
33208
33208
|
if (opts.auth && !options.headers.authorization) {
|
|
33209
33209
|
options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
|
|
33210
33210
|
}
|
|
33211
|
-
req = websocket._req =
|
|
33211
|
+
req = websocket._req = request(opts);
|
|
33212
33212
|
if (websocket._redirects) {
|
|
33213
33213
|
websocket.emit("redirect", websocket.url, req);
|
|
33214
33214
|
}
|
|
33215
33215
|
} else {
|
|
33216
|
-
req = websocket._req =
|
|
33216
|
+
req = websocket._req = request(opts);
|
|
33217
33217
|
}
|
|
33218
33218
|
if (opts.timeout) {
|
|
33219
33219
|
req.on("timeout", () => {
|
|
@@ -37601,7 +37601,7 @@ var init_peer_mesh = __esm({
|
|
|
37601
37601
|
* Send an inference request to a specific peer.
|
|
37602
37602
|
* Returns a promise that resolves when the response arrives.
|
|
37603
37603
|
*/
|
|
37604
|
-
async requestInference(peerId,
|
|
37604
|
+
async requestInference(peerId, request, timeoutMs = 12e4) {
|
|
37605
37605
|
const ws = this.connections.get(peerId);
|
|
37606
37606
|
if (!ws || ws.readyState !== import_websocket.default.OPEN) {
|
|
37607
37607
|
throw new Error(`Peer ${peerId} not connected`);
|
|
@@ -37613,7 +37613,7 @@ var init_peer_mesh = __esm({
|
|
|
37613
37613
|
reject(new Error(`Inference timeout (${timeoutMs}ms)`));
|
|
37614
37614
|
}, timeoutMs);
|
|
37615
37615
|
this.pendingRequests.set(msgId, { resolve: resolve36, reject, timeout, chunks: [] });
|
|
37616
|
-
this.sendMsg(ws, "infer_request",
|
|
37616
|
+
this.sendMsg(ws, "infer_request", request, msgId);
|
|
37617
37617
|
});
|
|
37618
37618
|
}
|
|
37619
37619
|
// ── Inbound connection handling ─────────────────────────────────────────
|
|
@@ -37955,7 +37955,7 @@ var init_inference_router = __esm({
|
|
|
37955
37955
|
}
|
|
37956
37956
|
}));
|
|
37957
37957
|
}
|
|
37958
|
-
const
|
|
37958
|
+
const request = {
|
|
37959
37959
|
model,
|
|
37960
37960
|
messages: redactedMessages,
|
|
37961
37961
|
tools: redactedTools,
|
|
@@ -37968,7 +37968,7 @@ var init_inference_router = __esm({
|
|
|
37968
37968
|
if (redactedCount > 0)
|
|
37969
37969
|
this._totalRedacted++;
|
|
37970
37970
|
try {
|
|
37971
|
-
const response = await this.mesh.requestInference(peer.peerId,
|
|
37971
|
+
const response = await this.mesh.requestInference(peer.peerId, request, options?.timeoutMs ?? this.defaultTimeoutMs);
|
|
37972
37972
|
const injectedContent = this.vault.inject(response.content);
|
|
37973
37973
|
const injectedToolCalls = response.toolCalls?.map((tc) => ({
|
|
37974
37974
|
...tc,
|
|
@@ -38001,8 +38001,8 @@ var init_inference_router = __esm({
|
|
|
38001
38001
|
* The response text may contain placeholders from the requester's vault,
|
|
38002
38002
|
* which is fine — we don't have their secrets and don't need them.
|
|
38003
38003
|
*/
|
|
38004
|
-
async handleInboundRequest(
|
|
38005
|
-
for (const msg of
|
|
38004
|
+
async handleInboundRequest(request, inferFn) {
|
|
38005
|
+
for (const msg of request.messages) {
|
|
38006
38006
|
const found = this.vault.scan(msg.content);
|
|
38007
38007
|
if (found.length > 0) {
|
|
38008
38008
|
this.emit("leaked_secrets_detected", {
|
|
@@ -38011,7 +38011,7 @@ var init_inference_router = __esm({
|
|
|
38011
38011
|
});
|
|
38012
38012
|
}
|
|
38013
38013
|
}
|
|
38014
|
-
return inferFn(
|
|
38014
|
+
return inferFn(request);
|
|
38015
38015
|
}
|
|
38016
38016
|
// ── Scoring ────────────────────────────────────────────────────────────
|
|
38017
38017
|
scoreRoute(peer, model) {
|
|
@@ -38470,26 +38470,26 @@ async function fetchOpenAIModels(baseUrl, apiKey) {
|
|
|
38470
38470
|
async function fetchPeerModels(peerId, authKey) {
|
|
38471
38471
|
try {
|
|
38472
38472
|
const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
38473
|
-
const { existsSync:
|
|
38474
|
-
const { join:
|
|
38473
|
+
const { existsSync: existsSync56, readFileSync: readFileSync44 } = await import("node:fs");
|
|
38474
|
+
const { join: join76 } = await import("node:path");
|
|
38475
38475
|
const cwd4 = process.cwd();
|
|
38476
38476
|
const nexusTool = new NexusTool2(cwd4);
|
|
38477
38477
|
const nexusDir = nexusTool.getNexusDir();
|
|
38478
38478
|
let isLocalPeer = false;
|
|
38479
38479
|
try {
|
|
38480
|
-
const statusPath =
|
|
38481
|
-
if (
|
|
38482
|
-
const status = JSON.parse(
|
|
38480
|
+
const statusPath = join76(nexusDir, "status.json");
|
|
38481
|
+
if (existsSync56(statusPath)) {
|
|
38482
|
+
const status = JSON.parse(readFileSync44(statusPath, "utf8"));
|
|
38483
38483
|
if (status.peerId === peerId)
|
|
38484
38484
|
isLocalPeer = true;
|
|
38485
38485
|
}
|
|
38486
38486
|
} catch {
|
|
38487
38487
|
}
|
|
38488
38488
|
if (isLocalPeer) {
|
|
38489
|
-
const pricingPath =
|
|
38490
|
-
if (
|
|
38489
|
+
const pricingPath = join76(nexusDir, "pricing.json");
|
|
38490
|
+
if (existsSync56(pricingPath)) {
|
|
38491
38491
|
try {
|
|
38492
|
-
const pricing = JSON.parse(
|
|
38492
|
+
const pricing = JSON.parse(readFileSync44(pricingPath, "utf8"));
|
|
38493
38493
|
const localModels = (pricing.models || []).map((m) => ({
|
|
38494
38494
|
name: m.model || "unknown",
|
|
38495
38495
|
size: m.parameterSize || "",
|
|
@@ -38503,10 +38503,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
38503
38503
|
}
|
|
38504
38504
|
}
|
|
38505
38505
|
}
|
|
38506
|
-
const cachePath =
|
|
38507
|
-
if (
|
|
38506
|
+
const cachePath = join76(nexusDir, "peer-models-cache.json");
|
|
38507
|
+
if (existsSync56(cachePath)) {
|
|
38508
38508
|
try {
|
|
38509
|
-
const cache4 = JSON.parse(
|
|
38509
|
+
const cache4 = JSON.parse(readFileSync44(cachePath, "utf8"));
|
|
38510
38510
|
if (cache4.peerId === peerId && cache4.models?.length > 0) {
|
|
38511
38511
|
const age = Date.now() - new Date(cache4.cachedAt).getTime();
|
|
38512
38512
|
if (age < 5 * 60 * 1e3) {
|
|
@@ -38621,10 +38621,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
38621
38621
|
} catch {
|
|
38622
38622
|
}
|
|
38623
38623
|
if (isLocalPeer) {
|
|
38624
|
-
const pricingPath =
|
|
38625
|
-
if (
|
|
38624
|
+
const pricingPath = join76(nexusDir, "pricing.json");
|
|
38625
|
+
if (existsSync56(pricingPath)) {
|
|
38626
38626
|
try {
|
|
38627
|
-
const pricing = JSON.parse(
|
|
38627
|
+
const pricing = JSON.parse(readFileSync44(pricingPath, "utf8"));
|
|
38628
38628
|
return (pricing.models || []).map((m) => ({
|
|
38629
38629
|
name: m.model || "unknown",
|
|
38630
38630
|
size: m.parameterSize || "",
|
|
@@ -49621,12 +49621,12 @@ async function handleVoiceMenu(ctx, save, hasLocal) {
|
|
|
49621
49621
|
continue;
|
|
49622
49622
|
}
|
|
49623
49623
|
const { basename: basename18, join: pathJoin } = await import("node:path");
|
|
49624
|
-
const { copyFileSync: copyFileSync2, mkdirSync:
|
|
49624
|
+
const { copyFileSync: copyFileSync2, mkdirSync: mkdirSync30, existsSync: exists } = await import("node:fs");
|
|
49625
49625
|
const { homedir: homedir20 } = await import("node:os");
|
|
49626
49626
|
const modelName = basename18(onnxDrop.path, ".onnx").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
49627
49627
|
const destDir = pathJoin(homedir20(), ".open-agents", "voice", "models", modelName);
|
|
49628
49628
|
if (!exists(destDir))
|
|
49629
|
-
|
|
49629
|
+
mkdirSync30(destDir, { recursive: true });
|
|
49630
49630
|
copyFileSync2(onnxDrop.path, pathJoin(destDir, "model.onnx"));
|
|
49631
49631
|
copyFileSync2(jsonDrop.path, pathJoin(destDir, "config.json"));
|
|
49632
49632
|
const { registerCustomOnnxModel: registerCustomOnnxModel2 } = await Promise.resolve().then(() => (init_voice(), voice_exports));
|
|
@@ -50304,11 +50304,11 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
|
|
|
50304
50304
|
const models = await fetchModels(peerUrl, authKey);
|
|
50305
50305
|
if (models.length > 0) {
|
|
50306
50306
|
try {
|
|
50307
|
-
const { writeFileSync:
|
|
50308
|
-
const { join:
|
|
50309
|
-
const cachePath =
|
|
50310
|
-
|
|
50311
|
-
|
|
50307
|
+
const { writeFileSync: writeFileSync29, mkdirSync: mkdirSync30 } = await import("node:fs");
|
|
50308
|
+
const { join: join76, dirname: dirname23 } = await import("node:path");
|
|
50309
|
+
const cachePath = join76(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
|
|
50310
|
+
mkdirSync30(dirname23(cachePath), { recursive: true });
|
|
50311
|
+
writeFileSync29(cachePath, JSON.stringify({
|
|
50312
50312
|
peerId,
|
|
50313
50313
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
50314
50314
|
models: models.map((m) => ({ name: m.name, size: m.size, parameterSize: m.parameterSize }))
|
|
@@ -50507,17 +50507,17 @@ async function handleUpdate(subcommand, ctx) {
|
|
|
50507
50507
|
try {
|
|
50508
50508
|
const { createRequire: createRequire5 } = await import("node:module");
|
|
50509
50509
|
const { fileURLToPath: fileURLToPath15 } = await import("node:url");
|
|
50510
|
-
const { dirname: dirname23, join:
|
|
50511
|
-
const { existsSync:
|
|
50510
|
+
const { dirname: dirname23, join: join76 } = await import("node:path");
|
|
50511
|
+
const { existsSync: existsSync56 } = await import("node:fs");
|
|
50512
50512
|
const req = createRequire5(import.meta.url);
|
|
50513
50513
|
const thisDir = dirname23(fileURLToPath15(import.meta.url));
|
|
50514
50514
|
const candidates = [
|
|
50515
|
-
|
|
50516
|
-
|
|
50517
|
-
|
|
50515
|
+
join76(thisDir, "..", "package.json"),
|
|
50516
|
+
join76(thisDir, "..", "..", "package.json"),
|
|
50517
|
+
join76(thisDir, "..", "..", "..", "package.json")
|
|
50518
50518
|
];
|
|
50519
50519
|
for (const pkgPath of candidates) {
|
|
50520
|
-
if (
|
|
50520
|
+
if (existsSync56(pkgPath)) {
|
|
50521
50521
|
const pkg = req(pkgPath);
|
|
50522
50522
|
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli") {
|
|
50523
50523
|
currentVersion = pkg.version ?? "0.0.0";
|
|
@@ -52569,6 +52569,24 @@ var init_carousel = __esm({
|
|
|
52569
52569
|
});
|
|
52570
52570
|
|
|
52571
52571
|
// packages/cli/dist/tui/banner.js
|
|
52572
|
+
var banner_exports = {};
|
|
52573
|
+
__export(banner_exports, {
|
|
52574
|
+
BannerRenderer: () => BannerRenderer,
|
|
52575
|
+
createAnimatedBanner: () => createAnimatedBanner,
|
|
52576
|
+
createCohereBanner: () => createCohereBanner,
|
|
52577
|
+
createDefaultBanner: () => createDefaultBanner,
|
|
52578
|
+
createEmptyGrid: () => createEmptyGrid,
|
|
52579
|
+
createSponsorBanner: () => createSponsorBanner,
|
|
52580
|
+
fillGridRegion: () => fillGridRegion,
|
|
52581
|
+
generateMnemonic: () => generateMnemonic,
|
|
52582
|
+
getNodeMnemonic: () => getNodeMnemonic,
|
|
52583
|
+
listBannerDesigns: () => listBannerDesigns,
|
|
52584
|
+
loadBannerDesign: () => loadBannerDesign,
|
|
52585
|
+
saveBannerDesign: () => saveBannerDesign,
|
|
52586
|
+
setGridText: () => setGridText
|
|
52587
|
+
});
|
|
52588
|
+
import { existsSync as existsSync44, readFileSync as readFileSync33, writeFileSync as writeFileSync20, mkdirSync as mkdirSync19 } from "node:fs";
|
|
52589
|
+
import { join as join60 } from "node:path";
|
|
52572
52590
|
function generateMnemonic(seed) {
|
|
52573
52591
|
let h = 2166136261;
|
|
52574
52592
|
for (let i = 0; i < seed.length; i++) {
|
|
@@ -52661,7 +52679,8 @@ function createDefaultBanner(version = "0.120.0") {
|
|
|
52661
52679
|
alignment: ["left", "center", "left"],
|
|
52662
52680
|
flowSpeed: [0, 0, 0],
|
|
52663
52681
|
author: "system",
|
|
52664
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
52682
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
52683
|
+
version
|
|
52665
52684
|
};
|
|
52666
52685
|
}
|
|
52667
52686
|
function createCohereBanner() {
|
|
@@ -52698,6 +52717,108 @@ function createCohereBanner() {
|
|
|
52698
52717
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
52699
52718
|
};
|
|
52700
52719
|
}
|
|
52720
|
+
function createSponsorBanner(sponsorName, tagline, primaryColor = 214, bgColor = 0) {
|
|
52721
|
+
const width = process.stdout.columns ?? 80;
|
|
52722
|
+
const rows = 3;
|
|
52723
|
+
const grid = [];
|
|
52724
|
+
for (let r = 0; r < rows; r++) {
|
|
52725
|
+
const row = [];
|
|
52726
|
+
for (let c3 = 0; c3 < width; c3++) {
|
|
52727
|
+
row.push({ char: " ", fg: primaryColor, bg: bgColor, bold: false });
|
|
52728
|
+
}
|
|
52729
|
+
grid.push(row);
|
|
52730
|
+
}
|
|
52731
|
+
const nameText = ` ${sponsorName}`;
|
|
52732
|
+
for (let i = 0; i < nameText.length && i < width; i++) {
|
|
52733
|
+
grid[0][i] = { char: nameText[i], fg: primaryColor, bg: bgColor, bold: true };
|
|
52734
|
+
}
|
|
52735
|
+
const startCol = Math.max(0, Math.floor((width - tagline.length) / 2));
|
|
52736
|
+
for (let i = 0; i < tagline.length && startCol + i < width; i++) {
|
|
52737
|
+
grid[1][startCol + i] = { char: tagline[i], fg: primaryColor, bg: bgColor, bold: false };
|
|
52738
|
+
}
|
|
52739
|
+
for (let c3 = 0; c3 < width; c3++) {
|
|
52740
|
+
grid[2][c3] = { char: c3 % 2 === 0 ? "\u2500" : "\u2550", fg: primaryColor, bg: bgColor, bold: false };
|
|
52741
|
+
}
|
|
52742
|
+
return {
|
|
52743
|
+
id: `sponsor-${sponsorName.toLowerCase().replace(/\s+/g, "-")}`,
|
|
52744
|
+
name: `Sponsor: ${sponsorName}`,
|
|
52745
|
+
type: "sponsor",
|
|
52746
|
+
frames: [{ grid, durationMs: 0 }],
|
|
52747
|
+
alignment: ["left", "center", "left"],
|
|
52748
|
+
flowSpeed: [0, 0, 0],
|
|
52749
|
+
author: sponsorName,
|
|
52750
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
52751
|
+
};
|
|
52752
|
+
}
|
|
52753
|
+
function saveBannerDesign(workDir, design) {
|
|
52754
|
+
const dir = join60(workDir, ".oa", "banners");
|
|
52755
|
+
mkdirSync19(dir, { recursive: true });
|
|
52756
|
+
writeFileSync20(join60(dir, `${design.id}.json`), JSON.stringify(design, null, 2), "utf8");
|
|
52757
|
+
}
|
|
52758
|
+
function loadBannerDesign(workDir, id) {
|
|
52759
|
+
const file = join60(workDir, ".oa", "banners", `${id}.json`);
|
|
52760
|
+
if (!existsSync44(file))
|
|
52761
|
+
return null;
|
|
52762
|
+
try {
|
|
52763
|
+
return JSON.parse(readFileSync33(file, "utf8"));
|
|
52764
|
+
} catch {
|
|
52765
|
+
return null;
|
|
52766
|
+
}
|
|
52767
|
+
}
|
|
52768
|
+
function listBannerDesigns(workDir) {
|
|
52769
|
+
const dir = join60(workDir, ".oa", "banners");
|
|
52770
|
+
if (!existsSync44(dir))
|
|
52771
|
+
return [];
|
|
52772
|
+
try {
|
|
52773
|
+
const { readdirSync: readdirSync23 } = __require("node:fs");
|
|
52774
|
+
return readdirSync23(dir).filter((f) => f.endsWith(".json")).map((f) => f.replace(".json", ""));
|
|
52775
|
+
} catch {
|
|
52776
|
+
return [];
|
|
52777
|
+
}
|
|
52778
|
+
}
|
|
52779
|
+
function createEmptyGrid(width, rows = 3) {
|
|
52780
|
+
const grid = [];
|
|
52781
|
+
for (let r = 0; r < rows; r++) {
|
|
52782
|
+
const row = [];
|
|
52783
|
+
for (let c3 = 0; c3 < width; c3++) {
|
|
52784
|
+
row.push({ char: " ", fg: -1, bg: -1, bold: false });
|
|
52785
|
+
}
|
|
52786
|
+
grid.push(row);
|
|
52787
|
+
}
|
|
52788
|
+
return grid;
|
|
52789
|
+
}
|
|
52790
|
+
function setGridText(grid, row, col, text, fg2 = -1, bg = -1, bold = false) {
|
|
52791
|
+
if (!grid[row])
|
|
52792
|
+
return;
|
|
52793
|
+
for (let i = 0; i < text.length; i++) {
|
|
52794
|
+
if (col + i < grid[row].length) {
|
|
52795
|
+
grid[row][col + i] = { char: text[i], fg: fg2, bg, bold };
|
|
52796
|
+
}
|
|
52797
|
+
}
|
|
52798
|
+
}
|
|
52799
|
+
function fillGridRegion(grid, startRow, startCol, endRow, endCol, cell) {
|
|
52800
|
+
for (let r = startRow; r <= endRow && r < grid.length; r++) {
|
|
52801
|
+
for (let c3 = startCol; c3 <= endCol && grid[r] && c3 < grid[r].length; c3++) {
|
|
52802
|
+
grid[r][c3] = { ...cell };
|
|
52803
|
+
}
|
|
52804
|
+
}
|
|
52805
|
+
}
|
|
52806
|
+
function createAnimatedBanner(id, name, frameBuilders, frameDurationMs, author = "user") {
|
|
52807
|
+
const width = process.stdout.columns ?? 80;
|
|
52808
|
+
return {
|
|
52809
|
+
id,
|
|
52810
|
+
name,
|
|
52811
|
+
type: "custom",
|
|
52812
|
+
frames: frameBuilders.map((builder) => ({
|
|
52813
|
+
grid: builder(width),
|
|
52814
|
+
durationMs: frameDurationMs
|
|
52815
|
+
})),
|
|
52816
|
+
alignment: ["left", "center", "left"],
|
|
52817
|
+
flowSpeed: [0, 0, 0],
|
|
52818
|
+
author,
|
|
52819
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
52820
|
+
};
|
|
52821
|
+
}
|
|
52701
52822
|
var isTTY7, MNEMONIC_ADJECTIVES, MNEMONIC_NOUNS, BannerRenderer;
|
|
52702
52823
|
var init_banner = __esm({
|
|
52703
52824
|
"packages/cli/dist/tui/banner.js"() {
|
|
@@ -52841,7 +52962,7 @@ var init_banner = __esm({
|
|
|
52841
52962
|
this.width = process.stdout.columns ?? 80;
|
|
52842
52963
|
if (this.currentDesign) {
|
|
52843
52964
|
if (this.currentDesign.type === "default") {
|
|
52844
|
-
const version = this.currentDesign.
|
|
52965
|
+
const version = this.currentDesign.version ?? "0.0.0";
|
|
52845
52966
|
this.currentDesign = createDefaultBanner(version);
|
|
52846
52967
|
} else if (this.currentDesign.type === "cohere") {
|
|
52847
52968
|
this.currentDesign = createCohereBanner();
|
|
@@ -52978,22 +53099,22 @@ var init_banner = __esm({
|
|
|
52978
53099
|
});
|
|
52979
53100
|
|
|
52980
53101
|
// packages/cli/dist/tui/carousel-descriptors.js
|
|
52981
|
-
import { existsSync as
|
|
52982
|
-
import { join as
|
|
53102
|
+
import { existsSync as existsSync45, readFileSync as readFileSync34, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, readdirSync as readdirSync14 } from "node:fs";
|
|
53103
|
+
import { join as join61, basename as basename13 } from "node:path";
|
|
52983
53104
|
function loadToolProfile(repoRoot) {
|
|
52984
|
-
const filePath =
|
|
53105
|
+
const filePath = join61(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
|
|
52985
53106
|
try {
|
|
52986
|
-
if (!
|
|
53107
|
+
if (!existsSync45(filePath))
|
|
52987
53108
|
return null;
|
|
52988
|
-
return JSON.parse(
|
|
53109
|
+
return JSON.parse(readFileSync34(filePath, "utf-8"));
|
|
52989
53110
|
} catch {
|
|
52990
53111
|
return null;
|
|
52991
53112
|
}
|
|
52992
53113
|
}
|
|
52993
53114
|
function saveToolProfile(repoRoot, profile) {
|
|
52994
|
-
const contextDir =
|
|
52995
|
-
|
|
52996
|
-
|
|
53115
|
+
const contextDir = join61(repoRoot, OA_DIR, "context");
|
|
53116
|
+
mkdirSync20(contextDir, { recursive: true });
|
|
53117
|
+
writeFileSync21(join61(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
|
|
52997
53118
|
}
|
|
52998
53119
|
function categorizeToolCall(toolName) {
|
|
52999
53120
|
for (const cat of TOOL_CATEGORIES) {
|
|
@@ -53051,25 +53172,25 @@ function weightedColor(profile) {
|
|
|
53051
53172
|
return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
|
|
53052
53173
|
}
|
|
53053
53174
|
function loadCachedDescriptors(repoRoot) {
|
|
53054
|
-
const filePath =
|
|
53175
|
+
const filePath = join61(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
|
|
53055
53176
|
try {
|
|
53056
|
-
if (!
|
|
53177
|
+
if (!existsSync45(filePath))
|
|
53057
53178
|
return null;
|
|
53058
|
-
const cached = JSON.parse(
|
|
53179
|
+
const cached = JSON.parse(readFileSync34(filePath, "utf-8"));
|
|
53059
53180
|
return cached.phrases.length > 0 ? cached.phrases : null;
|
|
53060
53181
|
} catch {
|
|
53061
53182
|
return null;
|
|
53062
53183
|
}
|
|
53063
53184
|
}
|
|
53064
53185
|
function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
|
|
53065
|
-
const contextDir =
|
|
53066
|
-
|
|
53186
|
+
const contextDir = join61(repoRoot, OA_DIR, "context");
|
|
53187
|
+
mkdirSync20(contextDir, { recursive: true });
|
|
53067
53188
|
const cached = {
|
|
53068
53189
|
phrases,
|
|
53069
53190
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
53070
53191
|
sourceHash
|
|
53071
53192
|
};
|
|
53072
|
-
|
|
53193
|
+
writeFileSync21(join61(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
|
|
53073
53194
|
}
|
|
53074
53195
|
function generateDescriptors(repoRoot) {
|
|
53075
53196
|
const profile = loadToolProfile(repoRoot);
|
|
@@ -53117,11 +53238,11 @@ function generateDescriptors(repoRoot) {
|
|
|
53117
53238
|
return phrases;
|
|
53118
53239
|
}
|
|
53119
53240
|
function extractFromPackageJson(repoRoot, tags) {
|
|
53120
|
-
const pkgPath =
|
|
53241
|
+
const pkgPath = join61(repoRoot, "package.json");
|
|
53121
53242
|
try {
|
|
53122
|
-
if (!
|
|
53243
|
+
if (!existsSync45(pkgPath))
|
|
53123
53244
|
return;
|
|
53124
|
-
const pkg = JSON.parse(
|
|
53245
|
+
const pkg = JSON.parse(readFileSync34(pkgPath, "utf-8"));
|
|
53125
53246
|
if (pkg.name && typeof pkg.name === "string") {
|
|
53126
53247
|
const parts = pkg.name.replace(/^@/, "").split("/");
|
|
53127
53248
|
for (const p of parts)
|
|
@@ -53165,7 +53286,7 @@ function extractFromManifests(repoRoot, tags) {
|
|
|
53165
53286
|
{ file: ".github/workflows", tag: "ci/cd" }
|
|
53166
53287
|
];
|
|
53167
53288
|
for (const check of manifestChecks) {
|
|
53168
|
-
if (
|
|
53289
|
+
if (existsSync45(join61(repoRoot, check.file))) {
|
|
53169
53290
|
tags.push(check.tag);
|
|
53170
53291
|
}
|
|
53171
53292
|
}
|
|
@@ -53187,16 +53308,16 @@ function extractFromSessions(repoRoot, tags) {
|
|
|
53187
53308
|
}
|
|
53188
53309
|
}
|
|
53189
53310
|
function extractFromMemory(repoRoot, tags) {
|
|
53190
|
-
const memoryDir =
|
|
53311
|
+
const memoryDir = join61(repoRoot, OA_DIR, "memory");
|
|
53191
53312
|
try {
|
|
53192
|
-
if (!
|
|
53313
|
+
if (!existsSync45(memoryDir))
|
|
53193
53314
|
return;
|
|
53194
53315
|
const files = readdirSync14(memoryDir).filter((f) => f.endsWith(".json"));
|
|
53195
53316
|
for (const file of files) {
|
|
53196
53317
|
const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
|
|
53197
53318
|
tags.push(topic);
|
|
53198
53319
|
try {
|
|
53199
|
-
const data = JSON.parse(
|
|
53320
|
+
const data = JSON.parse(readFileSync34(join61(memoryDir, file), "utf-8"));
|
|
53200
53321
|
if (data && typeof data === "object") {
|
|
53201
53322
|
const keys = Object.keys(data).slice(0, 3);
|
|
53202
53323
|
for (const key of keys) {
|
|
@@ -53851,13 +53972,13 @@ var init_stream_renderer = __esm({
|
|
|
53851
53972
|
});
|
|
53852
53973
|
|
|
53853
53974
|
// packages/cli/dist/tui/edit-history.js
|
|
53854
|
-
import { appendFileSync as appendFileSync3, mkdirSync as
|
|
53855
|
-
import { join as
|
|
53975
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync21 } from "node:fs";
|
|
53976
|
+
import { join as join62 } from "node:path";
|
|
53856
53977
|
function createEditHistoryLogger(repoRoot, sessionId) {
|
|
53857
|
-
const historyDir =
|
|
53858
|
-
const logPath2 =
|
|
53978
|
+
const historyDir = join62(repoRoot, ".oa", "history");
|
|
53979
|
+
const logPath2 = join62(historyDir, "edits.jsonl");
|
|
53859
53980
|
try {
|
|
53860
|
-
|
|
53981
|
+
mkdirSync21(historyDir, { recursive: true });
|
|
53861
53982
|
} catch {
|
|
53862
53983
|
}
|
|
53863
53984
|
function logToolCall(toolName, toolArgs, success) {
|
|
@@ -53966,17 +54087,17 @@ var init_edit_history = __esm({
|
|
|
53966
54087
|
});
|
|
53967
54088
|
|
|
53968
54089
|
// packages/cli/dist/tui/promptLoader.js
|
|
53969
|
-
import { readFileSync as
|
|
53970
|
-
import { join as
|
|
54090
|
+
import { readFileSync as readFileSync35, existsSync as existsSync46 } from "node:fs";
|
|
54091
|
+
import { join as join63, dirname as dirname19 } from "node:path";
|
|
53971
54092
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
53972
54093
|
function loadPrompt3(promptPath, vars) {
|
|
53973
54094
|
let content = cache3.get(promptPath);
|
|
53974
54095
|
if (content === void 0) {
|
|
53975
|
-
const fullPath =
|
|
53976
|
-
if (!
|
|
54096
|
+
const fullPath = join63(PROMPTS_DIR3, promptPath);
|
|
54097
|
+
if (!existsSync46(fullPath)) {
|
|
53977
54098
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
53978
54099
|
}
|
|
53979
|
-
content =
|
|
54100
|
+
content = readFileSync35(fullPath, "utf-8");
|
|
53980
54101
|
cache3.set(promptPath, content);
|
|
53981
54102
|
}
|
|
53982
54103
|
if (!vars)
|
|
@@ -53989,23 +54110,23 @@ var init_promptLoader3 = __esm({
|
|
|
53989
54110
|
"use strict";
|
|
53990
54111
|
__filename3 = fileURLToPath11(import.meta.url);
|
|
53991
54112
|
__dirname6 = dirname19(__filename3);
|
|
53992
|
-
devPath2 =
|
|
53993
|
-
publishedPath2 =
|
|
53994
|
-
PROMPTS_DIR3 =
|
|
54113
|
+
devPath2 = join63(__dirname6, "..", "..", "prompts");
|
|
54114
|
+
publishedPath2 = join63(__dirname6, "..", "prompts");
|
|
54115
|
+
PROMPTS_DIR3 = existsSync46(devPath2) ? devPath2 : publishedPath2;
|
|
53995
54116
|
cache3 = /* @__PURE__ */ new Map();
|
|
53996
54117
|
}
|
|
53997
54118
|
});
|
|
53998
54119
|
|
|
53999
54120
|
// packages/cli/dist/tui/dream-engine.js
|
|
54000
|
-
import { mkdirSync as
|
|
54001
|
-
import { join as
|
|
54121
|
+
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync22, readFileSync as readFileSync36, existsSync as existsSync47, cpSync, rmSync as rmSync2, readdirSync as readdirSync15 } from "node:fs";
|
|
54122
|
+
import { join as join64, basename as basename14 } from "node:path";
|
|
54002
54123
|
import { execSync as execSync31 } from "node:child_process";
|
|
54003
54124
|
function loadAutoresearchMemory(repoRoot) {
|
|
54004
|
-
const memoryPath =
|
|
54005
|
-
if (!
|
|
54125
|
+
const memoryPath = join64(repoRoot, ".oa", "memory", "autoresearch.json");
|
|
54126
|
+
if (!existsSync47(memoryPath))
|
|
54006
54127
|
return "";
|
|
54007
54128
|
try {
|
|
54008
|
-
const raw =
|
|
54129
|
+
const raw = readFileSync36(memoryPath, "utf-8");
|
|
54009
54130
|
const data = JSON.parse(raw);
|
|
54010
54131
|
const sections = [];
|
|
54011
54132
|
for (const key of AUTORESEARCH_MEMORY_KEYS) {
|
|
@@ -54195,14 +54316,14 @@ var init_dream_engine = __esm({
|
|
|
54195
54316
|
const content = String(args["content"] ?? "");
|
|
54196
54317
|
if (!rawPath)
|
|
54197
54318
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
54198
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
54319
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join64(this.autoresearchDir, basename14(rawPath)) : join64(this.autoresearchDir, rawPath);
|
|
54199
54320
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
54200
54321
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
54201
54322
|
}
|
|
54202
54323
|
try {
|
|
54203
|
-
const dir =
|
|
54204
|
-
|
|
54205
|
-
|
|
54324
|
+
const dir = join64(targetPath, "..");
|
|
54325
|
+
mkdirSync22(dir, { recursive: true });
|
|
54326
|
+
writeFileSync22(targetPath, content, "utf-8");
|
|
54206
54327
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
54207
54328
|
} catch (err) {
|
|
54208
54329
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
|
|
@@ -54230,20 +54351,20 @@ var init_dream_engine = __esm({
|
|
|
54230
54351
|
const rawPath = String(args["path"] ?? "");
|
|
54231
54352
|
const oldStr = String(args["old_string"] ?? "");
|
|
54232
54353
|
const newStr = String(args["new_string"] ?? "");
|
|
54233
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
54354
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join64(this.autoresearchDir, basename14(rawPath)) : join64(this.autoresearchDir, rawPath);
|
|
54234
54355
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
54235
54356
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
54236
54357
|
}
|
|
54237
54358
|
try {
|
|
54238
|
-
if (!
|
|
54359
|
+
if (!existsSync47(targetPath)) {
|
|
54239
54360
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start };
|
|
54240
54361
|
}
|
|
54241
|
-
let content =
|
|
54362
|
+
let content = readFileSync36(targetPath, "utf-8");
|
|
54242
54363
|
if (!content.includes(oldStr)) {
|
|
54243
54364
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start };
|
|
54244
54365
|
}
|
|
54245
54366
|
content = content.replace(oldStr, newStr);
|
|
54246
|
-
|
|
54367
|
+
writeFileSync22(targetPath, content, "utf-8");
|
|
54247
54368
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start };
|
|
54248
54369
|
} catch (err) {
|
|
54249
54370
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
|
|
@@ -54284,14 +54405,14 @@ var init_dream_engine = __esm({
|
|
|
54284
54405
|
const content = String(args["content"] ?? "");
|
|
54285
54406
|
if (!rawPath)
|
|
54286
54407
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
54287
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
54408
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join64(this.dreamsDir, basename14(rawPath)) : join64(this.dreamsDir, rawPath);
|
|
54288
54409
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
54289
54410
|
return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
54290
54411
|
}
|
|
54291
54412
|
try {
|
|
54292
|
-
const dir =
|
|
54293
|
-
|
|
54294
|
-
|
|
54413
|
+
const dir = join64(targetPath, "..");
|
|
54414
|
+
mkdirSync22(dir, { recursive: true });
|
|
54415
|
+
writeFileSync22(targetPath, content, "utf-8");
|
|
54295
54416
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
54296
54417
|
} catch (err) {
|
|
54297
54418
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
|
|
@@ -54319,20 +54440,20 @@ var init_dream_engine = __esm({
|
|
|
54319
54440
|
const rawPath = String(args["path"] ?? "");
|
|
54320
54441
|
const oldStr = String(args["old_string"] ?? "");
|
|
54321
54442
|
const newStr = String(args["new_string"] ?? "");
|
|
54322
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
54443
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join64(this.dreamsDir, basename14(rawPath)) : join64(this.dreamsDir, rawPath);
|
|
54323
54444
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
54324
54445
|
return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
54325
54446
|
}
|
|
54326
54447
|
try {
|
|
54327
|
-
if (!
|
|
54448
|
+
if (!existsSync47(targetPath)) {
|
|
54328
54449
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start };
|
|
54329
54450
|
}
|
|
54330
|
-
let content =
|
|
54451
|
+
let content = readFileSync36(targetPath, "utf-8");
|
|
54331
54452
|
if (!content.includes(oldStr)) {
|
|
54332
54453
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start };
|
|
54333
54454
|
}
|
|
54334
54455
|
content = content.replace(oldStr, newStr);
|
|
54335
|
-
|
|
54456
|
+
writeFileSync22(targetPath, content, "utf-8");
|
|
54336
54457
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start };
|
|
54337
54458
|
} catch (err) {
|
|
54338
54459
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
|
|
@@ -54386,7 +54507,7 @@ var init_dream_engine = __esm({
|
|
|
54386
54507
|
constructor(config, repoRoot) {
|
|
54387
54508
|
this.config = config;
|
|
54388
54509
|
this.repoRoot = repoRoot;
|
|
54389
|
-
this.dreamsDir =
|
|
54510
|
+
this.dreamsDir = join64(repoRoot, ".oa", "dreams");
|
|
54390
54511
|
this.state = {
|
|
54391
54512
|
mode: "default",
|
|
54392
54513
|
active: false,
|
|
@@ -54417,7 +54538,7 @@ var init_dream_engine = __esm({
|
|
|
54417
54538
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
54418
54539
|
results: []
|
|
54419
54540
|
};
|
|
54420
|
-
|
|
54541
|
+
mkdirSync22(this.dreamsDir, { recursive: true });
|
|
54421
54542
|
this.saveDreamState();
|
|
54422
54543
|
try {
|
|
54423
54544
|
for (let cycle = 1; cycle <= totalCycles; cycle++) {
|
|
@@ -54470,8 +54591,8 @@ ${result.summary}`;
|
|
|
54470
54591
|
if (mode !== "default" || cycle === totalCycles) {
|
|
54471
54592
|
renderDreamContraction(cycle);
|
|
54472
54593
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
54473
|
-
const summaryPath =
|
|
54474
|
-
|
|
54594
|
+
const summaryPath = join64(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
54595
|
+
writeFileSync22(summaryPath, cycleSummary, "utf-8");
|
|
54475
54596
|
}
|
|
54476
54597
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
54477
54598
|
this.saveVersionCheckpoint(cycle);
|
|
@@ -54683,7 +54804,7 @@ After synthesis, call task_complete with the final prioritized summary.`, toolMo
|
|
|
54683
54804
|
}
|
|
54684
54805
|
/** Build role-specific tool sets for swarm agents */
|
|
54685
54806
|
buildSwarmTools(role, _workspace) {
|
|
54686
|
-
const autoresearchDir =
|
|
54807
|
+
const autoresearchDir = join64(this.repoRoot, ".oa", "autoresearch");
|
|
54687
54808
|
const taskComplete = this.createSwarmTaskCompleteTool(role);
|
|
54688
54809
|
switch (role) {
|
|
54689
54810
|
case "researcher": {
|
|
@@ -55047,7 +55168,7 @@ INSTRUCTIONS:
|
|
|
55047
55168
|
2. Summarize the key learnings and next steps
|
|
55048
55169
|
|
|
55049
55170
|
Call task_complete with a human-readable summary of the autoresearch session.`, workspace, onEvent);
|
|
55050
|
-
const reportPath =
|
|
55171
|
+
const reportPath = join64(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
|
|
55051
55172
|
const report = `# Autoresearch Swarm Report \u2014 Cycle ${cycleNum}
|
|
55052
55173
|
|
|
55053
55174
|
**Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -55069,8 +55190,8 @@ ${summaryResult}
|
|
|
55069
55190
|
*Generated by open-agents autoresearch swarm*
|
|
55070
55191
|
`;
|
|
55071
55192
|
try {
|
|
55072
|
-
|
|
55073
|
-
|
|
55193
|
+
mkdirSync22(this.dreamsDir, { recursive: true });
|
|
55194
|
+
writeFileSync22(reportPath, report, "utf-8");
|
|
55074
55195
|
} catch {
|
|
55075
55196
|
}
|
|
55076
55197
|
renderSwarmComplete(workspace);
|
|
@@ -55136,9 +55257,9 @@ ${summaryResult}
|
|
|
55136
55257
|
}
|
|
55137
55258
|
/** Save workspace backup for lucid mode */
|
|
55138
55259
|
saveVersionCheckpoint(cycle) {
|
|
55139
|
-
const checkpointDir =
|
|
55260
|
+
const checkpointDir = join64(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
|
|
55140
55261
|
try {
|
|
55141
|
-
|
|
55262
|
+
mkdirSync22(checkpointDir, { recursive: true });
|
|
55142
55263
|
try {
|
|
55143
55264
|
const gitStatus = execSync31("git status --porcelain", {
|
|
55144
55265
|
cwd: this.repoRoot,
|
|
@@ -55155,10 +55276,10 @@ ${summaryResult}
|
|
|
55155
55276
|
encoding: "utf-8",
|
|
55156
55277
|
timeout: 5e3
|
|
55157
55278
|
}).trim();
|
|
55158
|
-
|
|
55159
|
-
|
|
55160
|
-
|
|
55161
|
-
|
|
55279
|
+
writeFileSync22(join64(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
|
|
55280
|
+
writeFileSync22(join64(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
|
|
55281
|
+
writeFileSync22(join64(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
|
|
55282
|
+
writeFileSync22(join64(checkpointDir, "checkpoint.json"), JSON.stringify({
|
|
55162
55283
|
cycle,
|
|
55163
55284
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
55164
55285
|
gitHash,
|
|
@@ -55166,7 +55287,7 @@ ${summaryResult}
|
|
|
55166
55287
|
}, null, 2), "utf-8");
|
|
55167
55288
|
renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
55168
55289
|
} catch {
|
|
55169
|
-
|
|
55290
|
+
writeFileSync22(join64(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
|
|
55170
55291
|
renderInfo(`Checkpoint saved: cycle ${cycle} (no git)`);
|
|
55171
55292
|
}
|
|
55172
55293
|
} catch (err) {
|
|
@@ -55224,14 +55345,14 @@ ${files.map((f) => `- [\`${f}\`](./${f})`).join("\n")}
|
|
|
55224
55345
|
---
|
|
55225
55346
|
*Auto-generated by open-agents dream engine*
|
|
55226
55347
|
`;
|
|
55227
|
-
|
|
55348
|
+
writeFileSync22(join64(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
55228
55349
|
} catch {
|
|
55229
55350
|
}
|
|
55230
55351
|
}
|
|
55231
55352
|
/** Save dream state for resume/inspection */
|
|
55232
55353
|
saveDreamState() {
|
|
55233
55354
|
try {
|
|
55234
|
-
|
|
55355
|
+
writeFileSync22(join64(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
55235
55356
|
} catch {
|
|
55236
55357
|
}
|
|
55237
55358
|
}
|
|
@@ -55605,8 +55726,8 @@ var init_bless_engine = __esm({
|
|
|
55605
55726
|
});
|
|
55606
55727
|
|
|
55607
55728
|
// packages/cli/dist/tui/dmn-engine.js
|
|
55608
|
-
import { existsSync as
|
|
55609
|
-
import { join as
|
|
55729
|
+
import { existsSync as existsSync48, readFileSync as readFileSync37, writeFileSync as writeFileSync23, mkdirSync as mkdirSync23, readdirSync as readdirSync16, unlinkSync as unlinkSync10 } from "node:fs";
|
|
55730
|
+
import { join as join65, basename as basename15 } from "node:path";
|
|
55610
55731
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
55611
55732
|
const competenceReport = competence.length > 0 ? competence.map((c3) => {
|
|
55612
55733
|
const rate = c3.attempts > 0 ? Math.round(c3.successes / c3.attempts * 100) : 0;
|
|
@@ -55726,9 +55847,9 @@ var init_dmn_engine = __esm({
|
|
|
55726
55847
|
constructor(config, repoRoot) {
|
|
55727
55848
|
this.config = config;
|
|
55728
55849
|
this.repoRoot = repoRoot;
|
|
55729
|
-
this.stateDir =
|
|
55730
|
-
this.historyDir =
|
|
55731
|
-
|
|
55850
|
+
this.stateDir = join65(repoRoot, ".oa", "dmn");
|
|
55851
|
+
this.historyDir = join65(repoRoot, ".oa", "dmn", "cycles");
|
|
55852
|
+
mkdirSync23(this.historyDir, { recursive: true });
|
|
55732
55853
|
this.loadState();
|
|
55733
55854
|
}
|
|
55734
55855
|
get stats() {
|
|
@@ -56317,11 +56438,11 @@ OUTPUT: Call task_complete with JSON:
|
|
|
56317
56438
|
async gatherMemoryTopics() {
|
|
56318
56439
|
const topics = [];
|
|
56319
56440
|
const dirs = [
|
|
56320
|
-
|
|
56321
|
-
|
|
56441
|
+
join65(this.repoRoot, ".oa", "memory"),
|
|
56442
|
+
join65(this.repoRoot, ".open-agents", "memory")
|
|
56322
56443
|
];
|
|
56323
56444
|
for (const dir of dirs) {
|
|
56324
|
-
if (!
|
|
56445
|
+
if (!existsSync48(dir))
|
|
56325
56446
|
continue;
|
|
56326
56447
|
try {
|
|
56327
56448
|
const files = readdirSync16(dir).filter((f) => f.endsWith(".json"));
|
|
@@ -56337,29 +56458,29 @@ OUTPUT: Call task_complete with JSON:
|
|
|
56337
56458
|
}
|
|
56338
56459
|
// ── State persistence ─────────────────────────────────────────────────
|
|
56339
56460
|
loadState() {
|
|
56340
|
-
const path =
|
|
56341
|
-
if (
|
|
56461
|
+
const path = join65(this.stateDir, "state.json");
|
|
56462
|
+
if (existsSync48(path)) {
|
|
56342
56463
|
try {
|
|
56343
|
-
this.state = JSON.parse(
|
|
56464
|
+
this.state = JSON.parse(readFileSync37(path, "utf-8"));
|
|
56344
56465
|
} catch {
|
|
56345
56466
|
}
|
|
56346
56467
|
}
|
|
56347
56468
|
}
|
|
56348
56469
|
saveState() {
|
|
56349
56470
|
try {
|
|
56350
|
-
|
|
56471
|
+
writeFileSync23(join65(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
56351
56472
|
} catch {
|
|
56352
56473
|
}
|
|
56353
56474
|
}
|
|
56354
56475
|
saveCycleResult(result) {
|
|
56355
56476
|
try {
|
|
56356
56477
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
56357
|
-
|
|
56478
|
+
writeFileSync23(join65(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
|
|
56358
56479
|
const files = readdirSync16(this.historyDir).filter((f) => f.startsWith("cycle-") && f.endsWith(".json")).sort();
|
|
56359
56480
|
if (files.length > 50) {
|
|
56360
56481
|
for (const old of files.slice(0, files.length - 50)) {
|
|
56361
56482
|
try {
|
|
56362
|
-
unlinkSync10(
|
|
56483
|
+
unlinkSync10(join65(this.historyDir, old));
|
|
56363
56484
|
} catch {
|
|
56364
56485
|
}
|
|
56365
56486
|
}
|
|
@@ -56372,8 +56493,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
56372
56493
|
});
|
|
56373
56494
|
|
|
56374
56495
|
// packages/cli/dist/tui/snr-engine.js
|
|
56375
|
-
import { existsSync as
|
|
56376
|
-
import { join as
|
|
56496
|
+
import { existsSync as existsSync49, readdirSync as readdirSync17, readFileSync as readFileSync38 } from "node:fs";
|
|
56497
|
+
import { join as join66, basename as basename16 } from "node:path";
|
|
56377
56498
|
function computeDPrime(signalScores, noiseScores) {
|
|
56378
56499
|
if (signalScores.length === 0 || noiseScores.length === 0)
|
|
56379
56500
|
return 0;
|
|
@@ -56613,11 +56734,11 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
56613
56734
|
loadMemoryEntries(topics) {
|
|
56614
56735
|
const entries = [];
|
|
56615
56736
|
const dirs = [
|
|
56616
|
-
|
|
56617
|
-
|
|
56737
|
+
join66(this.repoRoot, ".oa", "memory"),
|
|
56738
|
+
join66(this.repoRoot, ".open-agents", "memory")
|
|
56618
56739
|
];
|
|
56619
56740
|
for (const dir of dirs) {
|
|
56620
|
-
if (!
|
|
56741
|
+
if (!existsSync49(dir))
|
|
56621
56742
|
continue;
|
|
56622
56743
|
try {
|
|
56623
56744
|
const files = readdirSync17(dir).filter((f) => f.endsWith(".json"));
|
|
@@ -56626,7 +56747,7 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
56626
56747
|
if (topics.length > 0 && !topics.includes(topic))
|
|
56627
56748
|
continue;
|
|
56628
56749
|
try {
|
|
56629
|
-
const data = JSON.parse(
|
|
56750
|
+
const data = JSON.parse(readFileSync38(join66(dir, f), "utf-8"));
|
|
56630
56751
|
for (const [key, val] of Object.entries(data)) {
|
|
56631
56752
|
const value = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
56632
56753
|
entries.push({ topic, key, value });
|
|
@@ -57193,8 +57314,8 @@ var init_tool_policy = __esm({
|
|
|
57193
57314
|
});
|
|
57194
57315
|
|
|
57195
57316
|
// packages/cli/dist/tui/telegram-bridge.js
|
|
57196
|
-
import { mkdirSync as
|
|
57197
|
-
import { join as
|
|
57317
|
+
import { mkdirSync as mkdirSync24, existsSync as existsSync50, unlinkSync as unlinkSync11, readdirSync as readdirSync18, statSync as statSync15 } from "node:fs";
|
|
57318
|
+
import { join as join67, resolve as resolve30 } from "node:path";
|
|
57198
57319
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
57199
57320
|
function convertMarkdownToTelegramHTML(md) {
|
|
57200
57321
|
let html = md;
|
|
@@ -57522,7 +57643,7 @@ with summary "no_reply" to silently skip without responding.
|
|
|
57522
57643
|
this.polling = true;
|
|
57523
57644
|
this.abortController = new AbortController();
|
|
57524
57645
|
try {
|
|
57525
|
-
|
|
57646
|
+
mkdirSync24(this.mediaCacheDir, { recursive: true });
|
|
57526
57647
|
} catch {
|
|
57527
57648
|
}
|
|
57528
57649
|
this.mediaCacheCleanupTimer = setInterval(() => this.cleanupMediaCache(), 5 * 60 * 1e3);
|
|
@@ -57959,7 +58080,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
|
|
|
57959
58080
|
return null;
|
|
57960
58081
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
57961
58082
|
const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension}`;
|
|
57962
|
-
const localPath =
|
|
58083
|
+
const localPath = join67(this.mediaCacheDir, fileName);
|
|
57963
58084
|
await writeFileAsync(localPath, buffer);
|
|
57964
58085
|
return localPath;
|
|
57965
58086
|
} catch {
|
|
@@ -59315,7 +59436,7 @@ var init_text_selection = __esm({
|
|
|
59315
59436
|
});
|
|
59316
59437
|
|
|
59317
59438
|
// packages/cli/dist/tui/status-bar.js
|
|
59318
|
-
import { readFileSync as
|
|
59439
|
+
import { readFileSync as readFileSync39 } from "node:fs";
|
|
59319
59440
|
function setTerminalTitle(task, version) {
|
|
59320
59441
|
if (!process.stdout.isTTY)
|
|
59321
59442
|
return;
|
|
@@ -59997,7 +60118,7 @@ var init_status_bar = __esm({
|
|
|
59997
60118
|
if (nexusDir) {
|
|
59998
60119
|
try {
|
|
59999
60120
|
const metricsPath = nexusDir + "/remote-metrics.json";
|
|
60000
|
-
const raw =
|
|
60121
|
+
const raw = readFileSync39(metricsPath, "utf8");
|
|
60001
60122
|
const cached = JSON.parse(raw);
|
|
60002
60123
|
if (cached && cached.ts && Date.now() - cached.ts < 6e4) {
|
|
60003
60124
|
const m = cached.data;
|
|
@@ -61598,24 +61719,24 @@ var init_mouse_filter = __esm({
|
|
|
61598
61719
|
});
|
|
61599
61720
|
|
|
61600
61721
|
// packages/cli/dist/api/profiles.js
|
|
61601
|
-
import { existsSync as
|
|
61602
|
-
import { join as
|
|
61722
|
+
import { existsSync as existsSync51, readFileSync as readFileSync40, writeFileSync as writeFileSync24, mkdirSync as mkdirSync25, readdirSync as readdirSync19, unlinkSync as unlinkSync12 } from "node:fs";
|
|
61723
|
+
import { join as join68 } from "node:path";
|
|
61603
61724
|
import { homedir as homedir17 } from "node:os";
|
|
61604
61725
|
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes15, scryptSync as scryptSync3, createHash as createHash5 } from "node:crypto";
|
|
61605
61726
|
function globalProfileDir() {
|
|
61606
|
-
return
|
|
61727
|
+
return join68(homedir17(), ".open-agents", "profiles");
|
|
61607
61728
|
}
|
|
61608
61729
|
function projectProfileDir(projectDir) {
|
|
61609
|
-
return
|
|
61730
|
+
return join68(projectDir || process.cwd(), ".oa", "profiles");
|
|
61610
61731
|
}
|
|
61611
61732
|
function listProfiles(projectDir) {
|
|
61612
61733
|
const result = [];
|
|
61613
61734
|
const seen = /* @__PURE__ */ new Set();
|
|
61614
61735
|
const projDir = projectProfileDir(projectDir);
|
|
61615
|
-
if (
|
|
61736
|
+
if (existsSync51(projDir)) {
|
|
61616
61737
|
for (const f of readdirSync19(projDir).filter((f2) => f2.endsWith(".json"))) {
|
|
61617
61738
|
try {
|
|
61618
|
-
const raw = JSON.parse(
|
|
61739
|
+
const raw = JSON.parse(readFileSync40(join68(projDir, f), "utf8"));
|
|
61619
61740
|
const name = f.replace(".json", "");
|
|
61620
61741
|
seen.add(name);
|
|
61621
61742
|
result.push({
|
|
@@ -61629,13 +61750,13 @@ function listProfiles(projectDir) {
|
|
|
61629
61750
|
}
|
|
61630
61751
|
}
|
|
61631
61752
|
const globDir = globalProfileDir();
|
|
61632
|
-
if (
|
|
61753
|
+
if (existsSync51(globDir)) {
|
|
61633
61754
|
for (const f of readdirSync19(globDir).filter((f2) => f2.endsWith(".json"))) {
|
|
61634
61755
|
const name = f.replace(".json", "");
|
|
61635
61756
|
if (seen.has(name))
|
|
61636
61757
|
continue;
|
|
61637
61758
|
try {
|
|
61638
|
-
const raw = JSON.parse(
|
|
61759
|
+
const raw = JSON.parse(readFileSync40(join68(globDir, f), "utf8"));
|
|
61639
61760
|
result.push({
|
|
61640
61761
|
name,
|
|
61641
61762
|
description: raw.description || "",
|
|
@@ -61650,12 +61771,12 @@ function listProfiles(projectDir) {
|
|
|
61650
61771
|
}
|
|
61651
61772
|
function loadProfile(name, password, projectDir) {
|
|
61652
61773
|
const sanitized = name.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
61653
|
-
const projPath =
|
|
61654
|
-
const globPath =
|
|
61655
|
-
const filePath =
|
|
61774
|
+
const projPath = join68(projectProfileDir(projectDir), `${sanitized}.json`);
|
|
61775
|
+
const globPath = join68(globalProfileDir(), `${sanitized}.json`);
|
|
61776
|
+
const filePath = existsSync51(projPath) ? projPath : existsSync51(globPath) ? globPath : null;
|
|
61656
61777
|
if (!filePath)
|
|
61657
61778
|
return null;
|
|
61658
|
-
const raw = JSON.parse(
|
|
61779
|
+
const raw = JSON.parse(readFileSync40(filePath, "utf8"));
|
|
61659
61780
|
if (raw.encrypted === true) {
|
|
61660
61781
|
if (!password)
|
|
61661
61782
|
return null;
|
|
@@ -61665,23 +61786,23 @@ function loadProfile(name, password, projectDir) {
|
|
|
61665
61786
|
}
|
|
61666
61787
|
function saveProfile(profile, password, scope = "global", projectDir) {
|
|
61667
61788
|
const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
|
|
61668
|
-
|
|
61789
|
+
mkdirSync25(dir, { recursive: true });
|
|
61669
61790
|
const sanitized = profile.name.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
61670
|
-
const filePath =
|
|
61791
|
+
const filePath = join68(dir, `${sanitized}.json`);
|
|
61671
61792
|
profile.modified = (/* @__PURE__ */ new Date()).toISOString();
|
|
61672
61793
|
if (password) {
|
|
61673
61794
|
const encrypted = encryptProfile(profile, password);
|
|
61674
|
-
|
|
61795
|
+
writeFileSync24(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
61675
61796
|
} else {
|
|
61676
61797
|
profile.encrypted = false;
|
|
61677
|
-
|
|
61798
|
+
writeFileSync24(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
|
|
61678
61799
|
}
|
|
61679
61800
|
}
|
|
61680
61801
|
function deleteProfile(name, scope = "global", projectDir) {
|
|
61681
61802
|
const sanitized = name.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
61682
61803
|
const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
|
|
61683
|
-
const filePath =
|
|
61684
|
-
if (
|
|
61804
|
+
const filePath = join68(dir, `${sanitized}.json`);
|
|
61805
|
+
if (existsSync51(filePath)) {
|
|
61685
61806
|
unlinkSync12(filePath);
|
|
61686
61807
|
return true;
|
|
61687
61808
|
}
|
|
@@ -61771,16 +61892,17 @@ __export(serve_exports, {
|
|
|
61771
61892
|
startApiServer: () => startApiServer
|
|
61772
61893
|
});
|
|
61773
61894
|
import * as http from "node:http";
|
|
61895
|
+
import * as https from "node:https";
|
|
61774
61896
|
import { createRequire as createRequire2 } from "node:module";
|
|
61775
61897
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
61776
|
-
import { dirname as dirname20, join as
|
|
61898
|
+
import { dirname as dirname20, join as join69, resolve as resolve31 } from "node:path";
|
|
61777
61899
|
import { spawn as spawn20 } from "node:child_process";
|
|
61778
|
-
import { mkdirSync as
|
|
61900
|
+
import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync25, readFileSync as readFileSync41, readdirSync as readdirSync20, existsSync as existsSync52 } from "node:fs";
|
|
61779
61901
|
import { randomBytes as randomBytes16 } from "node:crypto";
|
|
61780
61902
|
function getVersion3() {
|
|
61781
61903
|
try {
|
|
61782
61904
|
const require2 = createRequire2(import.meta.url);
|
|
61783
|
-
const pkgPath =
|
|
61905
|
+
const pkgPath = join69(dirname20(fileURLToPath12(import.meta.url)), "..", "..", "package.json");
|
|
61784
61906
|
const pkg = require2(pkgPath);
|
|
61785
61907
|
return pkg.version;
|
|
61786
61908
|
} catch {
|
|
@@ -61856,20 +61978,29 @@ async function parseJsonBody(req) {
|
|
|
61856
61978
|
return null;
|
|
61857
61979
|
}
|
|
61858
61980
|
}
|
|
61981
|
+
function backendAuthHeaders() {
|
|
61982
|
+
const config = loadConfig();
|
|
61983
|
+
if (config.apiKey)
|
|
61984
|
+
return { Authorization: `Bearer ${config.apiKey}` };
|
|
61985
|
+
return {};
|
|
61986
|
+
}
|
|
61859
61987
|
function ollamaRequest(ollamaUrl, path, method, body) {
|
|
61860
61988
|
return new Promise((resolve36, reject) => {
|
|
61861
61989
|
const url = new URL(path, ollamaUrl);
|
|
61990
|
+
const isHttps = url.protocol === "https:";
|
|
61862
61991
|
const options = {
|
|
61863
61992
|
hostname: url.hostname,
|
|
61864
|
-
port: url.port,
|
|
61993
|
+
port: url.port || (isHttps ? 443 : 80),
|
|
61865
61994
|
path: url.pathname + url.search,
|
|
61866
61995
|
method,
|
|
61867
61996
|
headers: {
|
|
61868
61997
|
"Content-Type": "application/json",
|
|
61869
|
-
...body ? { "Content-Length": Buffer.byteLength(body) } : {}
|
|
61998
|
+
...body ? { "Content-Length": Buffer.byteLength(body) } : {},
|
|
61999
|
+
...backendAuthHeaders()
|
|
61870
62000
|
}
|
|
61871
62001
|
};
|
|
61872
|
-
const
|
|
62002
|
+
const transport = isHttps ? https : http;
|
|
62003
|
+
const proxyReq = transport.request(options, (proxyRes) => {
|
|
61873
62004
|
const chunks = [];
|
|
61874
62005
|
proxyRes.on("data", (chunk) => chunks.push(chunk));
|
|
61875
62006
|
proxyRes.on("end", () => {
|
|
@@ -61891,17 +62022,20 @@ function ollamaRequest(ollamaUrl, path, method, body) {
|
|
|
61891
62022
|
}
|
|
61892
62023
|
function ollamaStream(ollamaUrl, path, method, body, onData, onEnd, onError) {
|
|
61893
62024
|
const url = new URL(path, ollamaUrl);
|
|
62025
|
+
const isHttps = url.protocol === "https:";
|
|
61894
62026
|
const options = {
|
|
61895
62027
|
hostname: url.hostname,
|
|
61896
|
-
port: url.port,
|
|
62028
|
+
port: url.port || (isHttps ? 443 : 80),
|
|
61897
62029
|
path: url.pathname + url.search,
|
|
61898
62030
|
method,
|
|
61899
62031
|
headers: {
|
|
61900
62032
|
"Content-Type": "application/json",
|
|
61901
|
-
...body ? { "Content-Length": Buffer.byteLength(body) } : {}
|
|
62033
|
+
...body ? { "Content-Length": Buffer.byteLength(body) } : {},
|
|
62034
|
+
...backendAuthHeaders()
|
|
61902
62035
|
}
|
|
61903
62036
|
};
|
|
61904
|
-
const
|
|
62037
|
+
const transport = isHttps ? https : http;
|
|
62038
|
+
const proxyReq = transport.request(options, (proxyRes) => {
|
|
61905
62039
|
proxyRes.setEncoding("utf-8");
|
|
61906
62040
|
proxyRes.on("data", onData);
|
|
61907
62041
|
proxyRes.on("end", onEnd);
|
|
@@ -61916,29 +62050,29 @@ function ollamaStream(ollamaUrl, path, method, body, onData, onEnd, onError) {
|
|
|
61916
62050
|
}
|
|
61917
62051
|
function jobsDir() {
|
|
61918
62052
|
const root = resolve31(process.cwd());
|
|
61919
|
-
const dir =
|
|
61920
|
-
|
|
62053
|
+
const dir = join69(root, ".oa", "jobs");
|
|
62054
|
+
mkdirSync26(dir, { recursive: true });
|
|
61921
62055
|
return dir;
|
|
61922
62056
|
}
|
|
61923
62057
|
function loadJob(id) {
|
|
61924
|
-
const file =
|
|
61925
|
-
if (!
|
|
62058
|
+
const file = join69(jobsDir(), `${id}.json`);
|
|
62059
|
+
if (!existsSync52(file))
|
|
61926
62060
|
return null;
|
|
61927
62061
|
try {
|
|
61928
|
-
return JSON.parse(
|
|
62062
|
+
return JSON.parse(readFileSync41(file, "utf-8"));
|
|
61929
62063
|
} catch {
|
|
61930
62064
|
return null;
|
|
61931
62065
|
}
|
|
61932
62066
|
}
|
|
61933
62067
|
function listJobs() {
|
|
61934
62068
|
const dir = jobsDir();
|
|
61935
|
-
if (!
|
|
62069
|
+
if (!existsSync52(dir))
|
|
61936
62070
|
return [];
|
|
61937
62071
|
const files = readdirSync20(dir).filter((f) => f.endsWith(".json")).sort();
|
|
61938
62072
|
const jobs = [];
|
|
61939
62073
|
for (const file of files) {
|
|
61940
62074
|
try {
|
|
61941
|
-
jobs.push(JSON.parse(
|
|
62075
|
+
jobs.push(JSON.parse(readFileSync41(join69(dir, file), "utf-8")));
|
|
61942
62076
|
} catch {
|
|
61943
62077
|
}
|
|
61944
62078
|
}
|
|
@@ -61996,14 +62130,17 @@ function handleHealth(res) {
|
|
|
61996
62130
|
}
|
|
61997
62131
|
async function handleHealthReady(res, ollamaUrl) {
|
|
61998
62132
|
try {
|
|
61999
|
-
const
|
|
62133
|
+
const config = loadConfig();
|
|
62134
|
+
const isVllm = config.backendType === "vllm";
|
|
62135
|
+
const checkPath = isVllm ? "/v1/models" : "/api/tags";
|
|
62136
|
+
const result = await ollamaRequest(ollamaUrl, checkPath, "GET");
|
|
62000
62137
|
if (result.status === 200) {
|
|
62001
|
-
jsonResponse(res, 200, { status: "ready",
|
|
62138
|
+
jsonResponse(res, 200, { status: "ready", backend: "reachable", type: config.backendType || "ollama" });
|
|
62002
62139
|
} else {
|
|
62003
|
-
jsonResponse(res, 503, { status: "not_ready",
|
|
62140
|
+
jsonResponse(res, 503, { status: "not_ready", backend: "unreachable", code: result.status });
|
|
62004
62141
|
}
|
|
62005
62142
|
} catch {
|
|
62006
|
-
jsonResponse(res, 503, { status: "not_ready",
|
|
62143
|
+
jsonResponse(res, 503, { status: "not_ready", backend: "unreachable" });
|
|
62007
62144
|
}
|
|
62008
62145
|
}
|
|
62009
62146
|
function handleHealthStartup(res) {
|
|
@@ -62022,9 +62159,20 @@ function handleMetrics(res) {
|
|
|
62022
62159
|
}
|
|
62023
62160
|
async function handleV1Models(res, ollamaUrl) {
|
|
62024
62161
|
try {
|
|
62162
|
+
const config = loadConfig();
|
|
62163
|
+
const isVllm = config.backendType === "vllm";
|
|
62164
|
+
if (isVllm) {
|
|
62165
|
+
const result2 = await ollamaRequest(ollamaUrl, "/v1/models", "GET");
|
|
62166
|
+
if (result2.status !== 200) {
|
|
62167
|
+
jsonResponse(res, result2.status, { error: "Failed to fetch models from backend" });
|
|
62168
|
+
return;
|
|
62169
|
+
}
|
|
62170
|
+
jsonResponse(res, 200, JSON.parse(result2.body));
|
|
62171
|
+
return;
|
|
62172
|
+
}
|
|
62025
62173
|
const result = await ollamaRequest(ollamaUrl, "/api/tags", "GET");
|
|
62026
62174
|
if (result.status !== 200) {
|
|
62027
|
-
jsonResponse(res, result.status, { error: "Failed to fetch models from
|
|
62175
|
+
jsonResponse(res, result.status, { error: "Failed to fetch models from backend" });
|
|
62028
62176
|
return;
|
|
62029
62177
|
}
|
|
62030
62178
|
const ollamaBody = JSON.parse(result.body);
|
|
@@ -62037,7 +62185,7 @@ async function handleV1Models(res, ollamaUrl) {
|
|
|
62037
62185
|
jsonResponse(res, 200, { object: "list", data: models });
|
|
62038
62186
|
} catch (err) {
|
|
62039
62187
|
jsonResponse(res, 502, {
|
|
62040
|
-
error: "Failed to proxy to
|
|
62188
|
+
error: "Failed to proxy to backend",
|
|
62041
62189
|
message: err instanceof Error ? err.message : String(err)
|
|
62042
62190
|
});
|
|
62043
62191
|
}
|
|
@@ -62051,6 +62199,51 @@ async function handleV1ChatCompletions(req, res, ollamaUrl) {
|
|
|
62051
62199
|
const requestBody = body;
|
|
62052
62200
|
const stream = requestBody["stream"] === true;
|
|
62053
62201
|
const model = requestBody["model"] || "unknown";
|
|
62202
|
+
const config = loadConfig();
|
|
62203
|
+
const isVllm = config.backendType === "vllm";
|
|
62204
|
+
if (isVllm) {
|
|
62205
|
+
const payload = JSON.stringify(requestBody);
|
|
62206
|
+
if (stream) {
|
|
62207
|
+
res.writeHead(200, {
|
|
62208
|
+
"Content-Type": "text/event-stream",
|
|
62209
|
+
"Cache-Control": "no-cache",
|
|
62210
|
+
"Connection": "keep-alive",
|
|
62211
|
+
"Access-Control-Allow-Origin": "*",
|
|
62212
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, PATCH, DELETE, OPTIONS",
|
|
62213
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization"
|
|
62214
|
+
});
|
|
62215
|
+
ollamaStream(ollamaUrl, "/v1/chat/completions", "POST", payload, (chunk) => {
|
|
62216
|
+
res.write(chunk);
|
|
62217
|
+
}, () => {
|
|
62218
|
+
res.end();
|
|
62219
|
+
}, (err) => {
|
|
62220
|
+
try {
|
|
62221
|
+
res.write(`data: ${JSON.stringify({ error: err.message })}
|
|
62222
|
+
|
|
62223
|
+
`);
|
|
62224
|
+
} catch {
|
|
62225
|
+
}
|
|
62226
|
+
res.end();
|
|
62227
|
+
});
|
|
62228
|
+
} else {
|
|
62229
|
+
try {
|
|
62230
|
+
const result = await ollamaRequest(ollamaUrl, "/v1/chat/completions", "POST", payload);
|
|
62231
|
+
if (result.status !== 200) {
|
|
62232
|
+
jsonResponse(res, result.status, { error: "Backend request failed", details: result.body });
|
|
62233
|
+
return;
|
|
62234
|
+
}
|
|
62235
|
+
const parsed = JSON.parse(result.body);
|
|
62236
|
+
if (parsed.usage) {
|
|
62237
|
+
metrics.totalTokensIn += parsed.usage.prompt_tokens ?? 0;
|
|
62238
|
+
metrics.totalTokensOut += parsed.usage.completion_tokens ?? 0;
|
|
62239
|
+
}
|
|
62240
|
+
jsonResponse(res, 200, parsed);
|
|
62241
|
+
} catch (err) {
|
|
62242
|
+
jsonResponse(res, 502, { error: "Failed to proxy to backend", message: err instanceof Error ? err.message : String(err) });
|
|
62243
|
+
}
|
|
62244
|
+
}
|
|
62245
|
+
return;
|
|
62246
|
+
}
|
|
62054
62247
|
const ollamaPayload = JSON.stringify({
|
|
62055
62248
|
...requestBody,
|
|
62056
62249
|
stream,
|
|
@@ -62208,6 +62401,22 @@ async function handleV1Embeddings(req, res, ollamaUrl) {
|
|
|
62208
62401
|
return;
|
|
62209
62402
|
}
|
|
62210
62403
|
const requestBody = body;
|
|
62404
|
+
const config = loadConfig();
|
|
62405
|
+
const isVllm = config.backendType === "vllm";
|
|
62406
|
+
if (isVllm) {
|
|
62407
|
+
try {
|
|
62408
|
+
const payload = JSON.stringify(requestBody);
|
|
62409
|
+
const result = await ollamaRequest(ollamaUrl, "/v1/embeddings", "POST", payload);
|
|
62410
|
+
if (result.status !== 200) {
|
|
62411
|
+
jsonResponse(res, result.status, { error: "Backend embeddings request failed", details: result.body });
|
|
62412
|
+
return;
|
|
62413
|
+
}
|
|
62414
|
+
jsonResponse(res, 200, JSON.parse(result.body));
|
|
62415
|
+
} catch (err) {
|
|
62416
|
+
jsonResponse(res, 502, { error: "Failed to proxy to backend", message: err instanceof Error ? err.message : String(err) });
|
|
62417
|
+
}
|
|
62418
|
+
return;
|
|
62419
|
+
}
|
|
62211
62420
|
const ollamaPayload = JSON.stringify({
|
|
62212
62421
|
model: requestBody["model"],
|
|
62213
62422
|
input: requestBody["input"]
|
|
@@ -62216,7 +62425,7 @@ async function handleV1Embeddings(req, res, ollamaUrl) {
|
|
|
62216
62425
|
const result = await ollamaRequest(ollamaUrl, "/api/embed", "POST", ollamaPayload);
|
|
62217
62426
|
if (result.status !== 200) {
|
|
62218
62427
|
jsonResponse(res, result.status, {
|
|
62219
|
-
error: "
|
|
62428
|
+
error: "Backend embeddings request failed",
|
|
62220
62429
|
details: result.body
|
|
62221
62430
|
});
|
|
62222
62431
|
return;
|
|
@@ -62235,7 +62444,7 @@ async function handleV1Embeddings(req, res, ollamaUrl) {
|
|
|
62235
62444
|
});
|
|
62236
62445
|
} catch (err) {
|
|
62237
62446
|
jsonResponse(res, 502, {
|
|
62238
|
-
error: "Failed to proxy to
|
|
62447
|
+
error: "Failed to proxy to backend",
|
|
62239
62448
|
message: err instanceof Error ? err.message : String(err)
|
|
62240
62449
|
});
|
|
62241
62450
|
}
|
|
@@ -62261,8 +62470,8 @@ async function handleV1Run(req, res) {
|
|
|
62261
62470
|
if (workingDir) {
|
|
62262
62471
|
cwd4 = resolve31(workingDir);
|
|
62263
62472
|
} else if (isolate) {
|
|
62264
|
-
const wsDir =
|
|
62265
|
-
|
|
62473
|
+
const wsDir = join69(dir, "..", "workspaces", id);
|
|
62474
|
+
mkdirSync26(wsDir, { recursive: true });
|
|
62266
62475
|
cwd4 = wsDir;
|
|
62267
62476
|
} else {
|
|
62268
62477
|
cwd4 = resolve31(process.cwd());
|
|
@@ -62334,7 +62543,7 @@ async function handleV1Run(req, res) {
|
|
|
62334
62543
|
});
|
|
62335
62544
|
child.unref();
|
|
62336
62545
|
job.pid = child.pid ?? 0;
|
|
62337
|
-
|
|
62546
|
+
writeFileSync25(join69(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
62338
62547
|
runningProcesses.set(id, child);
|
|
62339
62548
|
if (streamMode) {
|
|
62340
62549
|
res.writeHead(200, {
|
|
@@ -62364,7 +62573,7 @@ async function handleV1Run(req, res) {
|
|
|
62364
62573
|
job.status = code === 0 ? "completed" : "failed";
|
|
62365
62574
|
job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
62366
62575
|
try {
|
|
62367
|
-
|
|
62576
|
+
writeFileSync25(join69(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
62368
62577
|
} catch {
|
|
62369
62578
|
}
|
|
62370
62579
|
runningProcesses.delete(id);
|
|
@@ -62395,7 +62604,7 @@ async function handleV1Run(req, res) {
|
|
|
62395
62604
|
job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
62396
62605
|
}
|
|
62397
62606
|
try {
|
|
62398
|
-
|
|
62607
|
+
writeFileSync25(join69(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
62399
62608
|
} catch {
|
|
62400
62609
|
}
|
|
62401
62610
|
runningProcesses.delete(id);
|
|
@@ -62436,17 +62645,23 @@ function handleV1RunsDelete(res, id) {
|
|
|
62436
62645
|
job.error = "Aborted via API";
|
|
62437
62646
|
const dir = jobsDir();
|
|
62438
62647
|
try {
|
|
62439
|
-
|
|
62648
|
+
writeFileSync25(join69(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
62440
62649
|
} catch {
|
|
62441
62650
|
}
|
|
62442
62651
|
runningProcesses.delete(id);
|
|
62443
62652
|
}
|
|
62444
62653
|
jsonResponse(res, 200, { run_id: id, status: "aborted" });
|
|
62445
62654
|
}
|
|
62655
|
+
function redactSecrets(obj) {
|
|
62656
|
+
const copy = { ...obj };
|
|
62657
|
+
if (typeof copy.apiKey === "string" && copy.apiKey)
|
|
62658
|
+
copy.apiKey = "[redacted]";
|
|
62659
|
+
return copy;
|
|
62660
|
+
}
|
|
62446
62661
|
function handleGetConfig(res) {
|
|
62447
62662
|
const config = loadConfig();
|
|
62448
62663
|
const settings = loadGlobalSettings();
|
|
62449
|
-
jsonResponse(res, 200, { config, settings });
|
|
62664
|
+
jsonResponse(res, 200, { config: redactSecrets(config), settings: redactSecrets(settings) });
|
|
62450
62665
|
}
|
|
62451
62666
|
async function handlePatchConfig(req, res) {
|
|
62452
62667
|
const body = await parseJsonBody(req);
|
|
@@ -62474,7 +62689,7 @@ async function handlePatchConfig(req, res) {
|
|
|
62474
62689
|
settingsUpdate.timeoutMs = updates["timeoutMs"];
|
|
62475
62690
|
saveGlobalSettings(settingsUpdate);
|
|
62476
62691
|
const updatedConfig = loadConfig();
|
|
62477
|
-
jsonResponse(res, 200, { config: updatedConfig, updated: Object.keys(settingsUpdate) });
|
|
62692
|
+
jsonResponse(res, 200, { config: redactSecrets(updatedConfig), updated: Object.keys(settingsUpdate) });
|
|
62478
62693
|
}
|
|
62479
62694
|
function handleGetConfigModel(res) {
|
|
62480
62695
|
const config = loadConfig();
|
|
@@ -62815,7 +63030,8 @@ function startApiServer(options = {}) {
|
|
|
62815
63030
|
`);
|
|
62816
63031
|
process.stderr.write(` Listening on http://${host}:${port}
|
|
62817
63032
|
`);
|
|
62818
|
-
|
|
63033
|
+
const beType = config.backendType || "ollama";
|
|
63034
|
+
process.stderr.write(` Backend (${beType}): ${ollamaUrl}
|
|
62819
63035
|
`);
|
|
62820
63036
|
if (process.env["OA_API_KEYS"]) {
|
|
62821
63037
|
const keyCount = process.env["OA_API_KEYS"].split(",").length;
|
|
@@ -62882,11 +63098,11 @@ var init_serve = __esm({
|
|
|
62882
63098
|
import * as readline2 from "node:readline";
|
|
62883
63099
|
import { Writable } from "node:stream";
|
|
62884
63100
|
import { cwd } from "node:process";
|
|
62885
|
-
import { resolve as resolve32, join as
|
|
63101
|
+
import { resolve as resolve32, join as join70, dirname as dirname21, extname as extname11 } from "node:path";
|
|
62886
63102
|
import { createRequire as createRequire3 } from "node:module";
|
|
62887
63103
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
62888
|
-
import { readFileSync as
|
|
62889
|
-
import { existsSync as
|
|
63104
|
+
import { readFileSync as readFileSync42, writeFileSync as writeFileSync26, appendFileSync as appendFileSync4, rmSync as rmSync3, readdirSync as readdirSync21, mkdirSync as mkdirSync27 } from "node:fs";
|
|
63105
|
+
import { existsSync as existsSync53 } from "node:fs";
|
|
62890
63106
|
import { execSync as execSync33 } from "node:child_process";
|
|
62891
63107
|
import { homedir as homedir18 } from "node:os";
|
|
62892
63108
|
function formatTimeAgo(date) {
|
|
@@ -62907,14 +63123,14 @@ function getVersion4() {
|
|
|
62907
63123
|
const require2 = createRequire3(import.meta.url);
|
|
62908
63124
|
const thisDir = dirname21(fileURLToPath13(import.meta.url));
|
|
62909
63125
|
const candidates = [
|
|
62910
|
-
|
|
62911
|
-
|
|
62912
|
-
|
|
63126
|
+
join70(thisDir, "..", "package.json"),
|
|
63127
|
+
join70(thisDir, "..", "..", "package.json"),
|
|
63128
|
+
join70(thisDir, "..", "..", "..", "package.json")
|
|
62913
63129
|
];
|
|
62914
63130
|
for (const pkgPath of candidates) {
|
|
62915
|
-
if (
|
|
63131
|
+
if (existsSync53(pkgPath)) {
|
|
62916
63132
|
const pkg = require2(pkgPath);
|
|
62917
|
-
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli") {
|
|
63133
|
+
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli" || pkg.name === "@open-agents/monorepo") {
|
|
62918
63134
|
return pkg.version ?? "0.0.0";
|
|
62919
63135
|
}
|
|
62920
63136
|
}
|
|
@@ -63147,15 +63363,15 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
|
|
|
63147
63363
|
function gatherMemorySnippets(root) {
|
|
63148
63364
|
const snippets = [];
|
|
63149
63365
|
const dirs = [
|
|
63150
|
-
|
|
63151
|
-
|
|
63366
|
+
join70(root, ".oa", "memory"),
|
|
63367
|
+
join70(root, ".open-agents", "memory")
|
|
63152
63368
|
];
|
|
63153
63369
|
for (const dir of dirs) {
|
|
63154
|
-
if (!
|
|
63370
|
+
if (!existsSync53(dir))
|
|
63155
63371
|
continue;
|
|
63156
63372
|
try {
|
|
63157
63373
|
for (const f of readdirSync21(dir).filter((f2) => f2.endsWith(".json"))) {
|
|
63158
|
-
const data = JSON.parse(
|
|
63374
|
+
const data = JSON.parse(readFileSync42(join70(dir, f), "utf-8"));
|
|
63159
63375
|
for (const val of Object.values(data)) {
|
|
63160
63376
|
const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
63161
63377
|
if (v.length > 10)
|
|
@@ -63312,9 +63528,9 @@ ${metabolismMemories}
|
|
|
63312
63528
|
} catch {
|
|
63313
63529
|
}
|
|
63314
63530
|
try {
|
|
63315
|
-
const archeFile =
|
|
63316
|
-
if (
|
|
63317
|
-
const variants = JSON.parse(
|
|
63531
|
+
const archeFile = join70(repoRoot, ".oa", "arche", "variants.json");
|
|
63532
|
+
if (existsSync53(archeFile)) {
|
|
63533
|
+
const variants = JSON.parse(readFileSync42(archeFile, "utf8"));
|
|
63318
63534
|
if (variants.length > 0) {
|
|
63319
63535
|
let filtered = variants;
|
|
63320
63536
|
if (taskType) {
|
|
@@ -63451,9 +63667,9 @@ ${lines.join("\n")}
|
|
|
63451
63667
|
const compactionThreshold = modelTier === "small" ? 12e3 : modelTier === "medium" ? 24e3 : 4e4;
|
|
63452
63668
|
let identityInjection = "";
|
|
63453
63669
|
try {
|
|
63454
|
-
const ikStateFile =
|
|
63455
|
-
if (
|
|
63456
|
-
const selfState = JSON.parse(
|
|
63670
|
+
const ikStateFile = join70(repoRoot, ".oa", "identity", "self-state.json");
|
|
63671
|
+
if (existsSync53(ikStateFile)) {
|
|
63672
|
+
const selfState = JSON.parse(readFileSync42(ikStateFile, "utf8"));
|
|
63457
63673
|
const lines = [
|
|
63458
63674
|
`[Identity State v${selfState.version}]`,
|
|
63459
63675
|
`Self: ${selfState.narrative_summary}`,
|
|
@@ -64094,13 +64310,13 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
64094
64310
|
});
|
|
64095
64311
|
}
|
|
64096
64312
|
try {
|
|
64097
|
-
const ikDir =
|
|
64098
|
-
const ikFile =
|
|
64313
|
+
const ikDir = join70(repoRoot, ".oa", "identity");
|
|
64314
|
+
const ikFile = join70(ikDir, "self-state.json");
|
|
64099
64315
|
let ikState;
|
|
64100
|
-
if (
|
|
64101
|
-
ikState = JSON.parse(
|
|
64316
|
+
if (existsSync53(ikFile)) {
|
|
64317
|
+
ikState = JSON.parse(readFileSync42(ikFile, "utf8"));
|
|
64102
64318
|
} else {
|
|
64103
|
-
|
|
64319
|
+
mkdirSync27(ikDir, { recursive: true });
|
|
64104
64320
|
const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
64105
64321
|
ikState = {
|
|
64106
64322
|
self_id: `oa-${machineId}`,
|
|
@@ -64126,7 +64342,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
64126
64342
|
}
|
|
64127
64343
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
64128
64344
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
64129
|
-
|
|
64345
|
+
writeFileSync26(ikFile, JSON.stringify(ikState, null, 2));
|
|
64130
64346
|
} catch (ikErr) {
|
|
64131
64347
|
try {
|
|
64132
64348
|
console.error("[IK-OBSERVE]", ikErr);
|
|
@@ -64141,14 +64357,14 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
64141
64357
|
} else {
|
|
64142
64358
|
renderTaskIncomplete(result.turns, result.toolCalls, result.durationMs, tokens);
|
|
64143
64359
|
try {
|
|
64144
|
-
const ikFile =
|
|
64145
|
-
if (
|
|
64146
|
-
const ikState = JSON.parse(
|
|
64360
|
+
const ikFile = join70(repoRoot, ".oa", "identity", "self-state.json");
|
|
64361
|
+
if (existsSync53(ikFile)) {
|
|
64362
|
+
const ikState = JSON.parse(readFileSync42(ikFile, "utf8"));
|
|
64147
64363
|
ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
|
|
64148
64364
|
ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
|
|
64149
64365
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
64150
64366
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
64151
|
-
|
|
64367
|
+
writeFileSync26(ikFile, JSON.stringify(ikState, null, 2));
|
|
64152
64368
|
}
|
|
64153
64369
|
} catch {
|
|
64154
64370
|
}
|
|
@@ -64491,7 +64707,7 @@ Review its full output in the [${id}] tab or via full_sub_agent(action='output',
|
|
|
64491
64707
|
let p2pGateway = null;
|
|
64492
64708
|
let peerMesh = null;
|
|
64493
64709
|
let inferenceRouter = null;
|
|
64494
|
-
const secretVault = new SecretVault(
|
|
64710
|
+
const secretVault = new SecretVault(join70(repoRoot, ".oa", "vault.enc"));
|
|
64495
64711
|
let adminSessionKey = null;
|
|
64496
64712
|
const callSubAgents = /* @__PURE__ */ new Map();
|
|
64497
64713
|
const streamRenderer = new StreamRenderer();
|
|
@@ -64712,13 +64928,13 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
64712
64928
|
const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
|
|
64713
64929
|
return [hits, line];
|
|
64714
64930
|
}
|
|
64715
|
-
const HISTORY_DIR =
|
|
64716
|
-
const HISTORY_FILE =
|
|
64931
|
+
const HISTORY_DIR = join70(homedir18(), ".open-agents");
|
|
64932
|
+
const HISTORY_FILE = join70(HISTORY_DIR, "repl-history");
|
|
64717
64933
|
const MAX_HISTORY_LINES = 500;
|
|
64718
64934
|
let savedHistory = [];
|
|
64719
64935
|
try {
|
|
64720
|
-
if (
|
|
64721
|
-
const raw =
|
|
64936
|
+
if (existsSync53(HISTORY_FILE)) {
|
|
64937
|
+
const raw = readFileSync42(HISTORY_FILE, "utf8").trim();
|
|
64722
64938
|
if (raw)
|
|
64723
64939
|
savedHistory = raw.split("\n").reverse();
|
|
64724
64940
|
}
|
|
@@ -64810,12 +65026,12 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
64810
65026
|
if (!line.trim())
|
|
64811
65027
|
return;
|
|
64812
65028
|
try {
|
|
64813
|
-
|
|
65029
|
+
mkdirSync27(HISTORY_DIR, { recursive: true });
|
|
64814
65030
|
appendFileSync4(HISTORY_FILE, line + "\n", "utf8");
|
|
64815
65031
|
if (Math.random() < 0.02) {
|
|
64816
|
-
const all =
|
|
65032
|
+
const all = readFileSync42(HISTORY_FILE, "utf8").trim().split("\n");
|
|
64817
65033
|
if (all.length > MAX_HISTORY_LINES) {
|
|
64818
|
-
|
|
65034
|
+
writeFileSync26(HISTORY_FILE, all.slice(-MAX_HISTORY_LINES).join("\n") + "\n", "utf8");
|
|
64819
65035
|
}
|
|
64820
65036
|
}
|
|
64821
65037
|
} catch {
|
|
@@ -64991,7 +65207,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
64991
65207
|
} catch {
|
|
64992
65208
|
}
|
|
64993
65209
|
try {
|
|
64994
|
-
const oaDir =
|
|
65210
|
+
const oaDir = join70(repoRoot, ".oa");
|
|
64995
65211
|
const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
|
|
64996
65212
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
64997
65213
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -65023,7 +65239,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
65023
65239
|
} catch {
|
|
65024
65240
|
}
|
|
65025
65241
|
try {
|
|
65026
|
-
const oaDir =
|
|
65242
|
+
const oaDir = join70(repoRoot, ".oa");
|
|
65027
65243
|
const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
|
|
65028
65244
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
65029
65245
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -65063,19 +65279,23 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
65063
65279
|
} catch {
|
|
65064
65280
|
}
|
|
65065
65281
|
try {
|
|
65066
|
-
const { homedir: _hd } = await import("node:os");
|
|
65067
|
-
const globalNamePath =
|
|
65068
|
-
let agName = "
|
|
65282
|
+
const { homedir: _hd, hostname: _hn, userInfo: _ui } = await import("node:os");
|
|
65283
|
+
const globalNamePath = join70(_hd(), ".open-agents", "agent-name");
|
|
65284
|
+
let agName = "";
|
|
65069
65285
|
try {
|
|
65070
|
-
if (
|
|
65071
|
-
agName =
|
|
65286
|
+
if (existsSync53(globalNamePath))
|
|
65287
|
+
agName = readFileSync42(globalNamePath, "utf8").trim();
|
|
65072
65288
|
} catch {
|
|
65073
65289
|
}
|
|
65290
|
+
if (!agName) {
|
|
65291
|
+
const { getNodeMnemonic: getNodeMnemonic2 } = await Promise.resolve().then(() => (init_banner(), banner_exports));
|
|
65292
|
+
agName = getNodeMnemonic2();
|
|
65293
|
+
}
|
|
65074
65294
|
fetch("https://openagents.nexus/api/v1/directory", {
|
|
65075
65295
|
method: "POST",
|
|
65076
65296
|
headers: { "Content-Type": "application/json" },
|
|
65077
65297
|
body: JSON.stringify({
|
|
65078
|
-
peerId: agName
|
|
65298
|
+
peerId: agName,
|
|
65079
65299
|
agentName: agName,
|
|
65080
65300
|
multiaddrs: [],
|
|
65081
65301
|
rooms: []
|
|
@@ -65974,7 +66194,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
65974
66194
|
kind,
|
|
65975
66195
|
targetUrl,
|
|
65976
66196
|
authKey,
|
|
65977
|
-
stateDir:
|
|
66197
|
+
stateDir: join70(repoRoot, ".oa"),
|
|
65978
66198
|
passthrough: passthrough ?? false,
|
|
65979
66199
|
loadbalance: loadbalance ?? false,
|
|
65980
66200
|
endpointAuth: passthrough ? currentConfig.apiKey : void 0,
|
|
@@ -66022,7 +66242,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
66022
66242
|
await tunnelGateway.stop();
|
|
66023
66243
|
tunnelGateway = null;
|
|
66024
66244
|
}
|
|
66025
|
-
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir:
|
|
66245
|
+
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join70(repoRoot, ".oa") });
|
|
66026
66246
|
newTunnel.on("stats", (stats) => {
|
|
66027
66247
|
statusBar.setExposeStatus({
|
|
66028
66248
|
status: stats.status,
|
|
@@ -66294,10 +66514,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
66294
66514
|
writeContent(() => renderInfo(`Killed ${bgKilled} background task(s).`));
|
|
66295
66515
|
}
|
|
66296
66516
|
try {
|
|
66297
|
-
const nexusDir =
|
|
66298
|
-
const pidFile =
|
|
66299
|
-
if (
|
|
66300
|
-
const pid = parseInt(
|
|
66517
|
+
const nexusDir = join70(repoRoot, OA_DIR, "nexus");
|
|
66518
|
+
const pidFile = join70(nexusDir, "daemon.pid");
|
|
66519
|
+
if (existsSync53(pidFile)) {
|
|
66520
|
+
const pid = parseInt(readFileSync42(pidFile, "utf8").trim(), 10);
|
|
66301
66521
|
if (pid > 0) {
|
|
66302
66522
|
try {
|
|
66303
66523
|
if (process.platform === "win32") {
|
|
@@ -66319,13 +66539,13 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
66319
66539
|
} catch {
|
|
66320
66540
|
}
|
|
66321
66541
|
try {
|
|
66322
|
-
const voiceDir2 =
|
|
66542
|
+
const voiceDir2 = join70(homedir18(), ".open-agents", "voice");
|
|
66323
66543
|
const voicePidFiles = ["luxtts-daemon.pid", "piper-daemon.pid"];
|
|
66324
66544
|
for (const pf of voicePidFiles) {
|
|
66325
|
-
const pidPath =
|
|
66326
|
-
if (
|
|
66545
|
+
const pidPath = join70(voiceDir2, pf);
|
|
66546
|
+
if (existsSync53(pidPath)) {
|
|
66327
66547
|
try {
|
|
66328
|
-
const pid = parseInt(
|
|
66548
|
+
const pid = parseInt(readFileSync42(pidPath, "utf8").trim(), 10);
|
|
66329
66549
|
if (pid > 0) {
|
|
66330
66550
|
if (process.platform === "win32") {
|
|
66331
66551
|
try {
|
|
@@ -66349,8 +66569,8 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
66349
66569
|
execSync33(process.platform === "win32" ? "timeout /t 1 /nobreak >nul" : "sleep 0.5", { timeout: 3e3, stdio: "ignore" });
|
|
66350
66570
|
} catch {
|
|
66351
66571
|
}
|
|
66352
|
-
const oaPath =
|
|
66353
|
-
if (
|
|
66572
|
+
const oaPath = join70(repoRoot, OA_DIR);
|
|
66573
|
+
if (existsSync53(oaPath)) {
|
|
66354
66574
|
let deleted = false;
|
|
66355
66575
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
66356
66576
|
try {
|
|
@@ -66736,8 +66956,8 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
66736
66956
|
}
|
|
66737
66957
|
}
|
|
66738
66958
|
const cleanPath = input.replace(/^['"]|['"]$/g, "").trim();
|
|
66739
|
-
const isImage = isImagePath(cleanPath) &&
|
|
66740
|
-
const isMedia = !isImage && isTranscribablePath(cleanPath) &&
|
|
66959
|
+
const isImage = isImagePath(cleanPath) && existsSync53(resolve32(repoRoot, cleanPath));
|
|
66960
|
+
const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync53(resolve32(repoRoot, cleanPath));
|
|
66741
66961
|
if (activeTask) {
|
|
66742
66962
|
if (activeTask.runner.isPaused) {
|
|
66743
66963
|
activeTask.runner.resume();
|
|
@@ -66746,7 +66966,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
66746
66966
|
if (isImage) {
|
|
66747
66967
|
try {
|
|
66748
66968
|
const imgPath = resolve32(repoRoot, cleanPath);
|
|
66749
|
-
const imgBuffer =
|
|
66969
|
+
const imgBuffer = readFileSync42(imgPath);
|
|
66750
66970
|
const base64 = imgBuffer.toString("base64");
|
|
66751
66971
|
const ext = extname11(cleanPath).toLowerCase();
|
|
66752
66972
|
const mime = ext === ".png" ? "image/png" : ext === ".gif" ? "image/gif" : ext === ".webp" ? "image/webp" : "image/jpeg";
|
|
@@ -67245,13 +67465,13 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
67245
67465
|
const handle = startTask(task, config, repoRoot);
|
|
67246
67466
|
await handle.promise;
|
|
67247
67467
|
try {
|
|
67248
|
-
const ikDir =
|
|
67249
|
-
const ikFile =
|
|
67468
|
+
const ikDir = join70(repoRoot, ".oa", "identity");
|
|
67469
|
+
const ikFile = join70(ikDir, "self-state.json");
|
|
67250
67470
|
let ikState;
|
|
67251
|
-
if (
|
|
67252
|
-
ikState = JSON.parse(
|
|
67471
|
+
if (existsSync53(ikFile)) {
|
|
67472
|
+
ikState = JSON.parse(readFileSync42(ikFile, "utf8"));
|
|
67253
67473
|
} else {
|
|
67254
|
-
|
|
67474
|
+
mkdirSync27(ikDir, { recursive: true });
|
|
67255
67475
|
ikState = {
|
|
67256
67476
|
self_id: `oa-${Date.now().toString(36)}`,
|
|
67257
67477
|
version: 1,
|
|
@@ -67273,7 +67493,7 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
67273
67493
|
ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
|
|
67274
67494
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
67275
67495
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
67276
|
-
|
|
67496
|
+
writeFileSync26(ikFile, JSON.stringify(ikState, null, 2));
|
|
67277
67497
|
} catch (ikErr) {
|
|
67278
67498
|
}
|
|
67279
67499
|
try {
|
|
@@ -67282,12 +67502,12 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
67282
67502
|
ec.archiveVariantSync(`Task: ${task.slice(0, 200)}`, "success \u2014 completed", ["general"]);
|
|
67283
67503
|
} catch {
|
|
67284
67504
|
try {
|
|
67285
|
-
const archeDir =
|
|
67286
|
-
const archeFile =
|
|
67505
|
+
const archeDir = join70(repoRoot, ".oa", "arche");
|
|
67506
|
+
const archeFile = join70(archeDir, "variants.json");
|
|
67287
67507
|
let variants = [];
|
|
67288
67508
|
try {
|
|
67289
|
-
if (
|
|
67290
|
-
variants = JSON.parse(
|
|
67509
|
+
if (existsSync53(archeFile))
|
|
67510
|
+
variants = JSON.parse(readFileSync42(archeFile, "utf8"));
|
|
67291
67511
|
} catch {
|
|
67292
67512
|
}
|
|
67293
67513
|
variants.push({
|
|
@@ -67302,15 +67522,15 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
67302
67522
|
});
|
|
67303
67523
|
if (variants.length > 50)
|
|
67304
67524
|
variants = variants.slice(-50);
|
|
67305
|
-
|
|
67306
|
-
|
|
67525
|
+
mkdirSync27(archeDir, { recursive: true });
|
|
67526
|
+
writeFileSync26(archeFile, JSON.stringify(variants, null, 2));
|
|
67307
67527
|
} catch {
|
|
67308
67528
|
}
|
|
67309
67529
|
}
|
|
67310
67530
|
try {
|
|
67311
|
-
const metaFile =
|
|
67312
|
-
if (
|
|
67313
|
-
const store = JSON.parse(
|
|
67531
|
+
const metaFile = join70(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
67532
|
+
if (existsSync53(metaFile)) {
|
|
67533
|
+
const store = JSON.parse(readFileSync42(metaFile, "utf8"));
|
|
67314
67534
|
const surfaced = store.filter((m) => m.type !== "quarantine" && m.scores?.confidence > 0.15).sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence).slice(0, 5);
|
|
67315
67535
|
let updated = false;
|
|
67316
67536
|
for (const item of surfaced) {
|
|
@@ -67321,7 +67541,7 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
67321
67541
|
updated = true;
|
|
67322
67542
|
}
|
|
67323
67543
|
if (updated) {
|
|
67324
|
-
|
|
67544
|
+
writeFileSync26(metaFile, JSON.stringify(store, null, 2));
|
|
67325
67545
|
}
|
|
67326
67546
|
}
|
|
67327
67547
|
} catch {
|
|
@@ -67374,9 +67594,9 @@ Rules:
|
|
|
67374
67594
|
try {
|
|
67375
67595
|
const { initDb: initDb2 } = __require("@open-agents/memory");
|
|
67376
67596
|
const { ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
|
|
67377
|
-
const dbDir =
|
|
67378
|
-
|
|
67379
|
-
const db = initDb2(
|
|
67597
|
+
const dbDir = join70(repoRoot, ".oa", "memory");
|
|
67598
|
+
mkdirSync27(dbDir, { recursive: true });
|
|
67599
|
+
const db = initDb2(join70(dbDir, "structured.db"));
|
|
67380
67600
|
const memStore = new ProceduralMemoryStore2(db);
|
|
67381
67601
|
memStore.createWithEmbedding({
|
|
67382
67602
|
content: content.slice(0, 600),
|
|
@@ -67391,12 +67611,12 @@ Rules:
|
|
|
67391
67611
|
db.close();
|
|
67392
67612
|
} catch {
|
|
67393
67613
|
}
|
|
67394
|
-
const metaDir =
|
|
67395
|
-
const storeFile =
|
|
67614
|
+
const metaDir = join70(repoRoot, ".oa", "memory", "metabolism");
|
|
67615
|
+
const storeFile = join70(metaDir, "store.json");
|
|
67396
67616
|
let store = [];
|
|
67397
67617
|
try {
|
|
67398
|
-
if (
|
|
67399
|
-
store = JSON.parse(
|
|
67618
|
+
if (existsSync53(storeFile))
|
|
67619
|
+
store = JSON.parse(readFileSync42(storeFile, "utf8"));
|
|
67400
67620
|
} catch {
|
|
67401
67621
|
}
|
|
67402
67622
|
store.push({
|
|
@@ -67412,26 +67632,26 @@ Rules:
|
|
|
67412
67632
|
});
|
|
67413
67633
|
if (store.length > 100)
|
|
67414
67634
|
store = store.slice(-100);
|
|
67415
|
-
|
|
67416
|
-
|
|
67635
|
+
mkdirSync27(metaDir, { recursive: true });
|
|
67636
|
+
writeFileSync26(storeFile, JSON.stringify(store, null, 2));
|
|
67417
67637
|
}
|
|
67418
67638
|
}
|
|
67419
67639
|
} catch {
|
|
67420
67640
|
}
|
|
67421
67641
|
try {
|
|
67422
|
-
const cohereSettingsFile =
|
|
67642
|
+
const cohereSettingsFile = join70(repoRoot, ".oa", "settings.json");
|
|
67423
67643
|
let cohereActive = false;
|
|
67424
67644
|
try {
|
|
67425
|
-
if (
|
|
67426
|
-
const settings = JSON.parse(
|
|
67645
|
+
if (existsSync53(cohereSettingsFile)) {
|
|
67646
|
+
const settings = JSON.parse(readFileSync42(cohereSettingsFile, "utf8"));
|
|
67427
67647
|
cohereActive = settings.cohere === true;
|
|
67428
67648
|
}
|
|
67429
67649
|
} catch {
|
|
67430
67650
|
}
|
|
67431
67651
|
if (cohereActive) {
|
|
67432
|
-
const metaFile =
|
|
67433
|
-
if (
|
|
67434
|
-
const store = JSON.parse(
|
|
67652
|
+
const metaFile = join70(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
67653
|
+
if (existsSync53(metaFile)) {
|
|
67654
|
+
const store = JSON.parse(readFileSync42(metaFile, "utf8"));
|
|
67435
67655
|
const latest = store.filter((m) => m.sourceTrace === "trajectory-extraction" || m.sourceTrace === "llm-trajectory-extraction").slice(-1)[0];
|
|
67436
67656
|
if (latest && latest.scores?.confidence >= 0.6) {
|
|
67437
67657
|
try {
|
|
@@ -67456,18 +67676,18 @@ Rules:
|
|
|
67456
67676
|
}
|
|
67457
67677
|
} catch (err) {
|
|
67458
67678
|
try {
|
|
67459
|
-
const ikFile =
|
|
67460
|
-
if (
|
|
67461
|
-
const ikState = JSON.parse(
|
|
67679
|
+
const ikFile = join70(repoRoot, ".oa", "identity", "self-state.json");
|
|
67680
|
+
if (existsSync53(ikFile)) {
|
|
67681
|
+
const ikState = JSON.parse(readFileSync42(ikFile, "utf8"));
|
|
67462
67682
|
ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
|
|
67463
67683
|
ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
|
|
67464
67684
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
67465
67685
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
67466
|
-
|
|
67686
|
+
writeFileSync26(ikFile, JSON.stringify(ikState, null, 2));
|
|
67467
67687
|
}
|
|
67468
|
-
const metaFile =
|
|
67469
|
-
if (
|
|
67470
|
-
const store = JSON.parse(
|
|
67688
|
+
const metaFile = join70(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
67689
|
+
if (existsSync53(metaFile)) {
|
|
67690
|
+
const store = JSON.parse(readFileSync42(metaFile, "utf8"));
|
|
67471
67691
|
const surfaced = store.filter((m) => m.type !== "quarantine" && m.scores?.confidence > 0.15).sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence).slice(0, 5);
|
|
67472
67692
|
for (const item of surfaced) {
|
|
67473
67693
|
item.accessCount = (item.accessCount || 0) + 1;
|
|
@@ -67475,15 +67695,15 @@ Rules:
|
|
|
67475
67695
|
item.scores.utility = Math.max(0, (item.scores.utility || 0.5) - 0.05);
|
|
67476
67696
|
item.scores.confidence = Math.max(0, (item.scores.confidence || 0.5) - 0.02);
|
|
67477
67697
|
}
|
|
67478
|
-
|
|
67698
|
+
writeFileSync26(metaFile, JSON.stringify(store, null, 2));
|
|
67479
67699
|
}
|
|
67480
67700
|
try {
|
|
67481
|
-
const archeDir =
|
|
67482
|
-
const archeFile =
|
|
67701
|
+
const archeDir = join70(repoRoot, ".oa", "arche");
|
|
67702
|
+
const archeFile = join70(archeDir, "variants.json");
|
|
67483
67703
|
let variants = [];
|
|
67484
67704
|
try {
|
|
67485
|
-
if (
|
|
67486
|
-
variants = JSON.parse(
|
|
67705
|
+
if (existsSync53(archeFile))
|
|
67706
|
+
variants = JSON.parse(readFileSync42(archeFile, "utf8"));
|
|
67487
67707
|
} catch {
|
|
67488
67708
|
}
|
|
67489
67709
|
variants.push({
|
|
@@ -67498,8 +67718,8 @@ Rules:
|
|
|
67498
67718
|
});
|
|
67499
67719
|
if (variants.length > 50)
|
|
67500
67720
|
variants = variants.slice(-50);
|
|
67501
|
-
|
|
67502
|
-
|
|
67721
|
+
mkdirSync27(archeDir, { recursive: true });
|
|
67722
|
+
writeFileSync26(archeFile, JSON.stringify(variants, null, 2));
|
|
67503
67723
|
} catch {
|
|
67504
67724
|
}
|
|
67505
67725
|
} catch {
|
|
@@ -67566,13 +67786,13 @@ __export(run_exports, {
|
|
|
67566
67786
|
});
|
|
67567
67787
|
import { resolve as resolve33 } from "node:path";
|
|
67568
67788
|
import { spawn as spawn21 } from "node:child_process";
|
|
67569
|
-
import { mkdirSync as
|
|
67789
|
+
import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync27, readFileSync as readFileSync43, readdirSync as readdirSync22, existsSync as existsSync54 } from "node:fs";
|
|
67570
67790
|
import { randomBytes as randomBytes17 } from "node:crypto";
|
|
67571
|
-
import { join as
|
|
67791
|
+
import { join as join71 } from "node:path";
|
|
67572
67792
|
function jobsDir2(repoPath) {
|
|
67573
67793
|
const root = resolve33(repoPath ?? process.cwd());
|
|
67574
|
-
const dir =
|
|
67575
|
-
|
|
67794
|
+
const dir = join71(root, ".oa", "jobs");
|
|
67795
|
+
mkdirSync28(dir, { recursive: true });
|
|
67576
67796
|
return dir;
|
|
67577
67797
|
}
|
|
67578
67798
|
async function runCommand(opts, config) {
|
|
@@ -67657,7 +67877,7 @@ async function runBackground(task, config, opts) {
|
|
|
67657
67877
|
});
|
|
67658
67878
|
child.unref();
|
|
67659
67879
|
job.pid = child.pid ?? 0;
|
|
67660
|
-
|
|
67880
|
+
writeFileSync27(join71(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
67661
67881
|
let output = "";
|
|
67662
67882
|
child.stdout?.on("data", (chunk) => {
|
|
67663
67883
|
output += chunk.toString();
|
|
@@ -67673,7 +67893,7 @@ async function runBackground(task, config, opts) {
|
|
|
67673
67893
|
job.summary = result.summary;
|
|
67674
67894
|
job.durationMs = result.durationMs;
|
|
67675
67895
|
job.error = result.error;
|
|
67676
|
-
|
|
67896
|
+
writeFileSync27(join71(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
67677
67897
|
} catch {
|
|
67678
67898
|
}
|
|
67679
67899
|
});
|
|
@@ -67689,13 +67909,13 @@ async function runBackground(task, config, opts) {
|
|
|
67689
67909
|
}
|
|
67690
67910
|
function statusCommand(jobId, repoPath) {
|
|
67691
67911
|
const dir = jobsDir2(repoPath);
|
|
67692
|
-
const file =
|
|
67693
|
-
if (!
|
|
67912
|
+
const file = join71(dir, `${jobId}.json`);
|
|
67913
|
+
if (!existsSync54(file)) {
|
|
67694
67914
|
console.error(`Job not found: ${jobId}`);
|
|
67695
67915
|
console.log(`Available jobs: oa jobs`);
|
|
67696
67916
|
process.exit(1);
|
|
67697
67917
|
}
|
|
67698
|
-
const job = JSON.parse(
|
|
67918
|
+
const job = JSON.parse(readFileSync43(file, "utf-8"));
|
|
67699
67919
|
const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
|
|
67700
67920
|
const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
|
|
67701
67921
|
console.log(`${icon} ${job.id} [${job.status}] ${runtime}`);
|
|
@@ -67718,7 +67938,7 @@ function jobsCommand(repoPath) {
|
|
|
67718
67938
|
console.log("Jobs:");
|
|
67719
67939
|
for (const file of files) {
|
|
67720
67940
|
try {
|
|
67721
|
-
const job = JSON.parse(
|
|
67941
|
+
const job = JSON.parse(readFileSync43(join71(dir, file), "utf-8"));
|
|
67722
67942
|
const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
|
|
67723
67943
|
const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
|
|
67724
67944
|
console.log(` ${icon} ${job.id} [${job.status}] ${runtime} \u2014 ${job.task.slice(0, 60)}`);
|
|
@@ -67738,7 +67958,7 @@ import { glob } from "glob";
|
|
|
67738
67958
|
import ignore from "ignore";
|
|
67739
67959
|
import { readFile as readFile23, stat as stat4 } from "node:fs/promises";
|
|
67740
67960
|
import { createHash as createHash6 } from "node:crypto";
|
|
67741
|
-
import { join as
|
|
67961
|
+
import { join as join72, relative as relative4, extname as extname12, basename as basename17 } from "node:path";
|
|
67742
67962
|
var DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
|
|
67743
67963
|
var init_codebase_indexer = __esm({
|
|
67744
67964
|
"packages/indexer/dist/codebase-indexer.js"() {
|
|
@@ -67782,7 +68002,7 @@ var init_codebase_indexer = __esm({
|
|
|
67782
68002
|
const ig = ignore.default();
|
|
67783
68003
|
if (this.config.respectGitignore) {
|
|
67784
68004
|
try {
|
|
67785
|
-
const gitignoreContent = await readFile23(
|
|
68005
|
+
const gitignoreContent = await readFile23(join72(this.config.rootDir, ".gitignore"), "utf-8");
|
|
67786
68006
|
ig.add(gitignoreContent);
|
|
67787
68007
|
} catch {
|
|
67788
68008
|
}
|
|
@@ -67797,7 +68017,7 @@ var init_codebase_indexer = __esm({
|
|
|
67797
68017
|
for (const relativePath of files) {
|
|
67798
68018
|
if (ig.ignores(relativePath))
|
|
67799
68019
|
continue;
|
|
67800
|
-
const fullPath =
|
|
68020
|
+
const fullPath = join72(this.config.rootDir, relativePath);
|
|
67801
68021
|
try {
|
|
67802
68022
|
const fileStat = await stat4(fullPath);
|
|
67803
68023
|
if (fileStat.size > this.config.maxFileSize)
|
|
@@ -67843,7 +68063,7 @@ var init_codebase_indexer = __esm({
|
|
|
67843
68063
|
if (!child) {
|
|
67844
68064
|
child = {
|
|
67845
68065
|
name: part,
|
|
67846
|
-
path:
|
|
68066
|
+
path: join72(current.path, part),
|
|
67847
68067
|
type: "directory",
|
|
67848
68068
|
children: []
|
|
67849
68069
|
};
|
|
@@ -67926,13 +68146,13 @@ __export(index_repo_exports, {
|
|
|
67926
68146
|
indexRepoCommand: () => indexRepoCommand
|
|
67927
68147
|
});
|
|
67928
68148
|
import { resolve as resolve34 } from "node:path";
|
|
67929
|
-
import { existsSync as
|
|
68149
|
+
import { existsSync as existsSync55, statSync as statSync16 } from "node:fs";
|
|
67930
68150
|
import { cwd as cwd2 } from "node:process";
|
|
67931
68151
|
async function indexRepoCommand(opts, _config) {
|
|
67932
68152
|
const repoRoot = resolve34(opts.repoPath ?? cwd2());
|
|
67933
68153
|
printHeader("Index Repository");
|
|
67934
68154
|
printInfo(`Indexing: ${repoRoot}`);
|
|
67935
|
-
if (!
|
|
68155
|
+
if (!existsSync55(repoRoot)) {
|
|
67936
68156
|
printError(`Path does not exist: ${repoRoot}`);
|
|
67937
68157
|
process.exit(1);
|
|
67938
68158
|
}
|
|
@@ -68184,7 +68404,7 @@ var config_exports = {};
|
|
|
68184
68404
|
__export(config_exports, {
|
|
68185
68405
|
configCommand: () => configCommand
|
|
68186
68406
|
});
|
|
68187
|
-
import { join as
|
|
68407
|
+
import { join as join73, resolve as resolve35 } from "node:path";
|
|
68188
68408
|
import { homedir as homedir19 } from "node:os";
|
|
68189
68409
|
import { cwd as cwd3 } from "node:process";
|
|
68190
68410
|
function redactIfSensitive(key, value) {
|
|
@@ -68267,7 +68487,7 @@ function handleShow(opts, config) {
|
|
|
68267
68487
|
}
|
|
68268
68488
|
}
|
|
68269
68489
|
printSection("Config File");
|
|
68270
|
-
printInfo(`~/.open-agents/config.json (${
|
|
68490
|
+
printInfo(`~/.open-agents/config.json (${join73(homedir19(), ".open-agents", "config.json")})`);
|
|
68271
68491
|
printSection("Priority Chain");
|
|
68272
68492
|
printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
|
|
68273
68493
|
printInfo(" 2. Project .oa/settings.json (--local)");
|
|
@@ -68306,7 +68526,7 @@ function handleSet(opts, _config) {
|
|
|
68306
68526
|
const coerced = coerceForSettings(key, value);
|
|
68307
68527
|
saveProjectSettings(repoRoot, { [key]: coerced });
|
|
68308
68528
|
printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value)}`);
|
|
68309
|
-
printInfo(`Saved to ${
|
|
68529
|
+
printInfo(`Saved to ${join73(repoRoot, ".oa", "settings.json")}`);
|
|
68310
68530
|
printInfo("This override applies only when running in this workspace.");
|
|
68311
68531
|
} catch (err) {
|
|
68312
68532
|
printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -68449,8 +68669,8 @@ __export(eval_exports, {
|
|
|
68449
68669
|
evalCommand: () => evalCommand
|
|
68450
68670
|
});
|
|
68451
68671
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
68452
|
-
import { mkdirSync as
|
|
68453
|
-
import { join as
|
|
68672
|
+
import { mkdirSync as mkdirSync29, writeFileSync as writeFileSync28 } from "node:fs";
|
|
68673
|
+
import { join as join74 } from "node:path";
|
|
68454
68674
|
async function evalCommand(opts, config) {
|
|
68455
68675
|
const suiteName = opts.suite ?? "basic";
|
|
68456
68676
|
const suite = SUITES[suiteName];
|
|
@@ -68491,17 +68711,17 @@ async function evalCommand(opts, config) {
|
|
|
68491
68711
|
rawBackend = new FakeBackend();
|
|
68492
68712
|
}
|
|
68493
68713
|
const backend = {
|
|
68494
|
-
async complete(
|
|
68714
|
+
async complete(request) {
|
|
68495
68715
|
const result = await rawBackend.complete({
|
|
68496
|
-
messages:
|
|
68716
|
+
messages: request.messages.map((m) => ({
|
|
68497
68717
|
id: globalThis.crypto.randomUUID(),
|
|
68498
68718
|
sessionId: globalThis.crypto.randomUUID(),
|
|
68499
68719
|
role: m.role,
|
|
68500
68720
|
content: m.content,
|
|
68501
68721
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
68502
68722
|
})),
|
|
68503
|
-
maxTokens:
|
|
68504
|
-
temperature:
|
|
68723
|
+
maxTokens: request.maxTokens,
|
|
68724
|
+
temperature: request.temperature
|
|
68505
68725
|
});
|
|
68506
68726
|
return { content: result.content ?? "" };
|
|
68507
68727
|
}
|
|
@@ -68575,9 +68795,9 @@ async function evalCommand(opts, config) {
|
|
|
68575
68795
|
process.exit(failed > 0 ? 1 : 0);
|
|
68576
68796
|
}
|
|
68577
68797
|
function createTempEvalRepo() {
|
|
68578
|
-
const dir =
|
|
68579
|
-
|
|
68580
|
-
|
|
68798
|
+
const dir = join74(tmpdir10(), `open-agents-eval-${Date.now()}`);
|
|
68799
|
+
mkdirSync29(dir, { recursive: true });
|
|
68800
|
+
writeFileSync28(join74(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
|
|
68581
68801
|
return dir;
|
|
68582
68802
|
}
|
|
68583
68803
|
var BASIC_SUITE, FULL_SUITE, SUITES;
|
|
@@ -68637,7 +68857,7 @@ init_updater();
|
|
|
68637
68857
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
68638
68858
|
import { createRequire as createRequire4 } from "node:module";
|
|
68639
68859
|
import { fileURLToPath as fileURLToPath14 } from "node:url";
|
|
68640
|
-
import { dirname as dirname22, join as
|
|
68860
|
+
import { dirname as dirname22, join as join75 } from "node:path";
|
|
68641
68861
|
|
|
68642
68862
|
// packages/cli/dist/cli.js
|
|
68643
68863
|
import { createInterface } from "node:readline";
|
|
@@ -68744,7 +68964,7 @@ init_output();
|
|
|
68744
68964
|
function getVersion5() {
|
|
68745
68965
|
try {
|
|
68746
68966
|
const require2 = createRequire4(import.meta.url);
|
|
68747
|
-
const pkgPath =
|
|
68967
|
+
const pkgPath = join75(dirname22(fileURLToPath14(import.meta.url)), "..", "package.json");
|
|
68748
68968
|
const pkg = require2(pkgPath);
|
|
68749
68969
|
return pkg.version;
|
|
68750
68970
|
} catch {
|