@kenkaiiii/gg-boss 4.3.146 → 4.3.147
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.
|
@@ -32167,8 +32167,11 @@ var require_jsx_runtime = __commonJS({
|
|
|
32167
32167
|
}
|
|
32168
32168
|
});
|
|
32169
32169
|
|
|
32170
|
-
// src/
|
|
32170
|
+
// src/logger.ts
|
|
32171
32171
|
init_esm_shims();
|
|
32172
|
+
import fs26 from "fs";
|
|
32173
|
+
import path25 from "path";
|
|
32174
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
32172
32175
|
|
|
32173
32176
|
// ../ggcoder/dist/index.js
|
|
32174
32177
|
init_esm_shims();
|
|
@@ -90714,6 +90717,73 @@ import { execFileSync as execFileSync2 } from "child_process";
|
|
|
90714
90717
|
var ESC3 = String.fromCharCode(27);
|
|
90715
90718
|
var oscResponsePattern = new RegExp(ESC3 + "\\]11;rgb:([0-9a-fA-F]+)/([0-9a-fA-F]+)/([0-9a-fA-F]+)");
|
|
90716
90719
|
|
|
90720
|
+
// src/logger.ts
|
|
90721
|
+
var MAX_BYTES3 = 10 * 1024 * 1024;
|
|
90722
|
+
var fd2 = null;
|
|
90723
|
+
var sessionId2 = "";
|
|
90724
|
+
function getLogPath() {
|
|
90725
|
+
return path25.join(getAppPaths().agentDir, "boss", "debug.log");
|
|
90726
|
+
}
|
|
90727
|
+
function rotateIfNeeded(filePath) {
|
|
90728
|
+
try {
|
|
90729
|
+
const st = fs26.statSync(filePath);
|
|
90730
|
+
if (st.size < MAX_BYTES3) return;
|
|
90731
|
+
const rotated = `${filePath}.1`;
|
|
90732
|
+
try {
|
|
90733
|
+
fs26.unlinkSync(rotated);
|
|
90734
|
+
} catch {
|
|
90735
|
+
}
|
|
90736
|
+
fs26.renameSync(filePath, rotated);
|
|
90737
|
+
} catch {
|
|
90738
|
+
}
|
|
90739
|
+
}
|
|
90740
|
+
function initLogger2(meta3) {
|
|
90741
|
+
if (fd2 !== null) return;
|
|
90742
|
+
const filePath = getLogPath();
|
|
90743
|
+
try {
|
|
90744
|
+
fs26.mkdirSync(path25.dirname(filePath), { recursive: true, mode: 448 });
|
|
90745
|
+
} catch {
|
|
90746
|
+
return;
|
|
90747
|
+
}
|
|
90748
|
+
rotateIfNeeded(filePath);
|
|
90749
|
+
try {
|
|
90750
|
+
fd2 = fs26.openSync(filePath, "a");
|
|
90751
|
+
} catch {
|
|
90752
|
+
return;
|
|
90753
|
+
}
|
|
90754
|
+
sessionId2 = randomBytes3(4).toString("hex");
|
|
90755
|
+
try {
|
|
90756
|
+
fs26.writeSync(fd2, "\n");
|
|
90757
|
+
} catch {
|
|
90758
|
+
}
|
|
90759
|
+
const parts = ["gg-boss"];
|
|
90760
|
+
if (meta3?.version) parts[0] += ` v${meta3.version}`;
|
|
90761
|
+
parts.push("started");
|
|
90762
|
+
if (meta3?.bossProvider) parts.push(`boss=${meta3.bossProvider}/${meta3.bossModel ?? "?"}`);
|
|
90763
|
+
if (meta3?.bossThinking) parts.push(`bossThinking=${meta3.bossThinking}`);
|
|
90764
|
+
if (meta3?.workerProvider) parts.push(`workers=${meta3.workerProvider}/${meta3.workerModel ?? "?"}`);
|
|
90765
|
+
if (meta3?.projectCount !== void 0) parts.push(`projects=${meta3.projectCount}`);
|
|
90766
|
+
parts.push(`pid=${process.pid}`);
|
|
90767
|
+
log2("INFO", "startup", parts.join(" "));
|
|
90768
|
+
}
|
|
90769
|
+
function log2(level, category, message, data) {
|
|
90770
|
+
if (fd2 === null) return;
|
|
90771
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
90772
|
+
let line = `[${ts}] [sid=${sessionId2}] [${level}] [${category}] ${message}`;
|
|
90773
|
+
if (data) {
|
|
90774
|
+
const pairs = Object.entries(data).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
|
|
90775
|
+
if (pairs) line += ` ${pairs}`;
|
|
90776
|
+
}
|
|
90777
|
+
line += "\n";
|
|
90778
|
+
try {
|
|
90779
|
+
fs26.writeSync(fd2, line);
|
|
90780
|
+
} catch {
|
|
90781
|
+
}
|
|
90782
|
+
}
|
|
90783
|
+
|
|
90784
|
+
// src/worker.ts
|
|
90785
|
+
init_esm_shims();
|
|
90786
|
+
|
|
90717
90787
|
// src/boss-store.ts
|
|
90718
90788
|
init_esm_shims();
|
|
90719
90789
|
var import_react75 = __toESM(require_react(), 1);
|
|
@@ -91299,6 +91369,20 @@ var bossStore = {
|
|
|
91299
91369
|
};
|
|
91300
91370
|
|
|
91301
91371
|
// src/worker.ts
|
|
91372
|
+
function safeBusHandler(workerName, handlerName, fn, onError) {
|
|
91373
|
+
return (event) => {
|
|
91374
|
+
try {
|
|
91375
|
+
fn(event);
|
|
91376
|
+
} catch (err) {
|
|
91377
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
91378
|
+
log2("ERROR", "worker", `bus handler "${handlerName}" threw`, {
|
|
91379
|
+
worker: workerName,
|
|
91380
|
+
message
|
|
91381
|
+
});
|
|
91382
|
+
onError(`Worker "${workerName}" event handler error: ${message}`);
|
|
91383
|
+
}
|
|
91384
|
+
};
|
|
91385
|
+
}
|
|
91302
91386
|
var Worker = class {
|
|
91303
91387
|
name;
|
|
91304
91388
|
cwd;
|
|
@@ -91367,45 +91451,88 @@ var Worker = class {
|
|
|
91367
91451
|
}
|
|
91368
91452
|
wireEvents() {
|
|
91369
91453
|
const bus = this.session.eventBus;
|
|
91370
|
-
|
|
91371
|
-
this.currentText += text;
|
|
91372
|
-
});
|
|
91373
|
-
bus.on("tool_call_start", ({ toolCallId, name }) => {
|
|
91374
|
-
this.activeTools.set(toolCallId, name);
|
|
91375
|
-
});
|
|
91376
|
-
bus.on("tool_call_end", ({ toolCallId, isError }) => {
|
|
91377
|
-
const name = this.activeTools.get(toolCallId);
|
|
91378
|
-
this.activeTools.delete(toolCallId);
|
|
91379
|
-
if (name) this.currentTools.push({ name, ok: !isError });
|
|
91380
|
-
});
|
|
91381
|
-
bus.on("agent_done", () => {
|
|
91382
|
-
this.turnCount += 1;
|
|
91383
|
-
const summary = {
|
|
91384
|
-
project: this.name,
|
|
91385
|
-
cwd: this.cwd,
|
|
91386
|
-
status: "idle",
|
|
91387
|
-
finalText: this.currentText.trim(),
|
|
91388
|
-
toolsUsed: [...this.currentTools],
|
|
91389
|
-
turnIndex: this.turnCount,
|
|
91390
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
91391
|
-
};
|
|
91392
|
-
this.currentText = "";
|
|
91393
|
-
this.currentTools = [];
|
|
91394
|
-
this.status = "idle";
|
|
91395
|
-
bossStore.appendWorkerEvent(summary);
|
|
91396
|
-
this.queue.push({ kind: "worker_turn_complete", summary });
|
|
91397
|
-
});
|
|
91398
|
-
bus.on("error", ({ error: error51 }) => {
|
|
91399
|
-
this.status = "error";
|
|
91454
|
+
const reportError2 = (message) => {
|
|
91400
91455
|
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
91401
|
-
|
|
91456
|
+
this.status = "error";
|
|
91457
|
+
bossStore.appendWorkerError(this.name, message, ts);
|
|
91402
91458
|
this.queue.push({
|
|
91403
91459
|
kind: "worker_error",
|
|
91404
91460
|
project: this.name,
|
|
91405
|
-
message
|
|
91461
|
+
message,
|
|
91406
91462
|
timestamp: ts
|
|
91407
91463
|
});
|
|
91408
|
-
}
|
|
91464
|
+
};
|
|
91465
|
+
bus.on(
|
|
91466
|
+
"text_delta",
|
|
91467
|
+
safeBusHandler(
|
|
91468
|
+
this.name,
|
|
91469
|
+
"text_delta",
|
|
91470
|
+
({ text }) => {
|
|
91471
|
+
this.currentText += text;
|
|
91472
|
+
},
|
|
91473
|
+
reportError2
|
|
91474
|
+
)
|
|
91475
|
+
);
|
|
91476
|
+
bus.on(
|
|
91477
|
+
"tool_call_start",
|
|
91478
|
+
safeBusHandler(
|
|
91479
|
+
this.name,
|
|
91480
|
+
"tool_call_start",
|
|
91481
|
+
({ toolCallId, name }) => {
|
|
91482
|
+
this.activeTools.set(toolCallId, name);
|
|
91483
|
+
},
|
|
91484
|
+
reportError2
|
|
91485
|
+
)
|
|
91486
|
+
);
|
|
91487
|
+
bus.on(
|
|
91488
|
+
"tool_call_end",
|
|
91489
|
+
safeBusHandler(
|
|
91490
|
+
this.name,
|
|
91491
|
+
"tool_call_end",
|
|
91492
|
+
({ toolCallId, isError }) => {
|
|
91493
|
+
const name = this.activeTools.get(toolCallId);
|
|
91494
|
+
this.activeTools.delete(toolCallId);
|
|
91495
|
+
if (name) this.currentTools.push({ name, ok: !isError });
|
|
91496
|
+
},
|
|
91497
|
+
reportError2
|
|
91498
|
+
)
|
|
91499
|
+
);
|
|
91500
|
+
bus.on(
|
|
91501
|
+
"agent_done",
|
|
91502
|
+
safeBusHandler(
|
|
91503
|
+
this.name,
|
|
91504
|
+
"agent_done",
|
|
91505
|
+
() => {
|
|
91506
|
+
this.turnCount += 1;
|
|
91507
|
+
const summary = {
|
|
91508
|
+
project: this.name,
|
|
91509
|
+
cwd: this.cwd,
|
|
91510
|
+
status: "idle",
|
|
91511
|
+
finalText: this.currentText.trim(),
|
|
91512
|
+
toolsUsed: [...this.currentTools],
|
|
91513
|
+
turnIndex: this.turnCount,
|
|
91514
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
91515
|
+
};
|
|
91516
|
+
this.currentText = "";
|
|
91517
|
+
this.currentTools = [];
|
|
91518
|
+
this.status = "idle";
|
|
91519
|
+
bossStore.appendWorkerEvent(summary);
|
|
91520
|
+
this.queue.push({ kind: "worker_turn_complete", summary });
|
|
91521
|
+
},
|
|
91522
|
+
reportError2
|
|
91523
|
+
)
|
|
91524
|
+
);
|
|
91525
|
+
bus.on(
|
|
91526
|
+
"error",
|
|
91527
|
+
safeBusHandler(
|
|
91528
|
+
this.name,
|
|
91529
|
+
"error",
|
|
91530
|
+
({ error: error51 }) => {
|
|
91531
|
+
reportError2(error51.message);
|
|
91532
|
+
},
|
|
91533
|
+
reportError2
|
|
91534
|
+
)
|
|
91535
|
+
);
|
|
91409
91536
|
}
|
|
91410
91537
|
};
|
|
91411
91538
|
|
|
@@ -91441,17 +91568,17 @@ var EventQueue = class {
|
|
|
91441
91568
|
|
|
91442
91569
|
// src/settings.ts
|
|
91443
91570
|
init_esm_shims();
|
|
91444
|
-
import
|
|
91445
|
-
import
|
|
91571
|
+
import fs27 from "fs/promises";
|
|
91572
|
+
import path26 from "path";
|
|
91446
91573
|
function settingsPath() {
|
|
91447
|
-
return
|
|
91574
|
+
return path26.join(getAppPaths().agentDir, "boss", "settings.json");
|
|
91448
91575
|
}
|
|
91449
91576
|
async function ensureDir() {
|
|
91450
|
-
await
|
|
91577
|
+
await fs27.mkdir(path26.dirname(settingsPath()), { recursive: true, mode: 448 });
|
|
91451
91578
|
}
|
|
91452
91579
|
async function loadSettings() {
|
|
91453
91580
|
try {
|
|
91454
|
-
const content = await
|
|
91581
|
+
const content = await fs27.readFile(settingsPath(), "utf-8");
|
|
91455
91582
|
const parsed = JSON.parse(content);
|
|
91456
91583
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
91457
91584
|
} catch {
|
|
@@ -91465,81 +91592,13 @@ async function saveSettings(patch) {
|
|
|
91465
91592
|
const merged = { ...current, ...patch };
|
|
91466
91593
|
await ensureDir();
|
|
91467
91594
|
const tmp = `${settingsPath()}.${process.pid}.tmp`;
|
|
91468
|
-
await
|
|
91469
|
-
await
|
|
91595
|
+
await fs27.writeFile(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
|
|
91596
|
+
await fs27.rename(tmp, settingsPath());
|
|
91470
91597
|
});
|
|
91471
91598
|
writeChain = next.catch(() => void 0);
|
|
91472
91599
|
await next;
|
|
91473
91600
|
}
|
|
91474
91601
|
|
|
91475
|
-
// src/logger.ts
|
|
91476
|
-
init_esm_shims();
|
|
91477
|
-
import fs27 from "fs";
|
|
91478
|
-
import path26 from "path";
|
|
91479
|
-
import { randomBytes as randomBytes3 } from "crypto";
|
|
91480
|
-
var MAX_BYTES3 = 10 * 1024 * 1024;
|
|
91481
|
-
var fd2 = null;
|
|
91482
|
-
var sessionId2 = "";
|
|
91483
|
-
function getLogPath() {
|
|
91484
|
-
return path26.join(getAppPaths().agentDir, "boss", "debug.log");
|
|
91485
|
-
}
|
|
91486
|
-
function rotateIfNeeded(filePath) {
|
|
91487
|
-
try {
|
|
91488
|
-
const st = fs27.statSync(filePath);
|
|
91489
|
-
if (st.size < MAX_BYTES3) return;
|
|
91490
|
-
const rotated = `${filePath}.1`;
|
|
91491
|
-
try {
|
|
91492
|
-
fs27.unlinkSync(rotated);
|
|
91493
|
-
} catch {
|
|
91494
|
-
}
|
|
91495
|
-
fs27.renameSync(filePath, rotated);
|
|
91496
|
-
} catch {
|
|
91497
|
-
}
|
|
91498
|
-
}
|
|
91499
|
-
function initLogger2(meta3) {
|
|
91500
|
-
if (fd2 !== null) return;
|
|
91501
|
-
const filePath = getLogPath();
|
|
91502
|
-
try {
|
|
91503
|
-
fs27.mkdirSync(path26.dirname(filePath), { recursive: true, mode: 448 });
|
|
91504
|
-
} catch {
|
|
91505
|
-
return;
|
|
91506
|
-
}
|
|
91507
|
-
rotateIfNeeded(filePath);
|
|
91508
|
-
try {
|
|
91509
|
-
fd2 = fs27.openSync(filePath, "a");
|
|
91510
|
-
} catch {
|
|
91511
|
-
return;
|
|
91512
|
-
}
|
|
91513
|
-
sessionId2 = randomBytes3(4).toString("hex");
|
|
91514
|
-
try {
|
|
91515
|
-
fs27.writeSync(fd2, "\n");
|
|
91516
|
-
} catch {
|
|
91517
|
-
}
|
|
91518
|
-
const parts = ["gg-boss"];
|
|
91519
|
-
if (meta3?.version) parts[0] += ` v${meta3.version}`;
|
|
91520
|
-
parts.push("started");
|
|
91521
|
-
if (meta3?.bossProvider) parts.push(`boss=${meta3.bossProvider}/${meta3.bossModel ?? "?"}`);
|
|
91522
|
-
if (meta3?.bossThinking) parts.push(`bossThinking=${meta3.bossThinking}`);
|
|
91523
|
-
if (meta3?.workerProvider) parts.push(`workers=${meta3.workerProvider}/${meta3.workerModel ?? "?"}`);
|
|
91524
|
-
if (meta3?.projectCount !== void 0) parts.push(`projects=${meta3.projectCount}`);
|
|
91525
|
-
parts.push(`pid=${process.pid}`);
|
|
91526
|
-
log2("INFO", "startup", parts.join(" "));
|
|
91527
|
-
}
|
|
91528
|
-
function log2(level, category, message, data) {
|
|
91529
|
-
if (fd2 === null) return;
|
|
91530
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
91531
|
-
let line = `[${ts}] [sid=${sessionId2}] [${level}] [${category}] ${message}`;
|
|
91532
|
-
if (data) {
|
|
91533
|
-
const pairs = Object.entries(data).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
|
|
91534
|
-
if (pairs) line += ` ${pairs}`;
|
|
91535
|
-
}
|
|
91536
|
-
line += "\n";
|
|
91537
|
-
try {
|
|
91538
|
-
fs27.writeSync(fd2, line);
|
|
91539
|
-
} catch {
|
|
91540
|
-
}
|
|
91541
|
-
}
|
|
91542
|
-
|
|
91543
91602
|
// src/boss-system-prompt.ts
|
|
91544
91603
|
init_esm_shims();
|
|
91545
91604
|
function buildBossSystemPrompt(projects) {
|
|
@@ -92718,132 +92777,144 @@ var GGBoss = class {
|
|
|
92718
92777
|
async run() {
|
|
92719
92778
|
this.running = true;
|
|
92720
92779
|
while (this.running) {
|
|
92721
|
-
|
|
92722
|
-
|
|
92723
|
-
|
|
92724
|
-
|
|
92725
|
-
|
|
92726
|
-
|
|
92727
|
-
|
|
92728
|
-
|
|
92729
|
-
void playDoneAudio();
|
|
92730
|
-
this.hadWorkerActivitySinceReady = true;
|
|
92731
|
-
this.lastSummaries.set(event.summary.project, event.summary);
|
|
92732
|
-
log2("INFO", "worker_turn_complete", "worker finished", {
|
|
92733
|
-
project: event.summary.project,
|
|
92734
|
-
turn: event.summary.turnIndex,
|
|
92735
|
-
tools: event.summary.toolsUsed.length,
|
|
92736
|
-
failed: event.summary.toolsUsed.filter((t) => !t.ok).length
|
|
92737
|
-
});
|
|
92738
|
-
const taskId = this.inFlightTaskByProject.get(event.summary.project);
|
|
92739
|
-
finishedTaskId = taskId ?? null;
|
|
92740
|
-
if (taskId) {
|
|
92741
|
-
this.inFlightTaskByProject.delete(event.summary.project);
|
|
92742
|
-
const task = tasksStore.byId(taskId);
|
|
92743
|
-
if (task && task.status === "in_progress") {
|
|
92744
|
-
const reported = parseReportedStatus(event.summary.finalText);
|
|
92745
|
-
const newStatus = reportedToTaskStatus(
|
|
92746
|
-
reported,
|
|
92747
|
-
event.summary.toolsUsed.some((t) => !t.ok)
|
|
92748
|
-
);
|
|
92749
|
-
await tasksStore.update(taskId, {
|
|
92750
|
-
status: newStatus,
|
|
92751
|
-
resultSummary: event.summary.finalText
|
|
92752
|
-
});
|
|
92753
|
-
}
|
|
92780
|
+
try {
|
|
92781
|
+
await this.runIteration();
|
|
92782
|
+
} catch (err) {
|
|
92783
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
92784
|
+
log2("ERROR", "run_loop", "iteration threw", { message });
|
|
92785
|
+
try {
|
|
92786
|
+
bossStore.appendInfo(`Boss loop error (recovered): ${message}`, "error");
|
|
92787
|
+
} catch {
|
|
92754
92788
|
}
|
|
92755
92789
|
}
|
|
92756
|
-
|
|
92757
|
-
|
|
92758
|
-
|
|
92759
|
-
|
|
92760
|
-
|
|
92761
|
-
|
|
92790
|
+
}
|
|
92791
|
+
}
|
|
92792
|
+
async runIteration() {
|
|
92793
|
+
const event = await this.queue.next();
|
|
92794
|
+
if (!this.running) return;
|
|
92795
|
+
if (event.kind === "user_message") {
|
|
92796
|
+
this.pendingUserMessages = Math.max(0, this.pendingUserMessages - 1);
|
|
92797
|
+
bossStore.setPendingMessages(this.pendingUserMessages);
|
|
92798
|
+
}
|
|
92799
|
+
let finishedTaskId = null;
|
|
92800
|
+
if (event.kind === "worker_turn_complete") {
|
|
92801
|
+
void playDoneAudio();
|
|
92802
|
+
this.hadWorkerActivitySinceReady = true;
|
|
92803
|
+
this.lastSummaries.set(event.summary.project, event.summary);
|
|
92804
|
+
log2("INFO", "worker_turn_complete", "worker finished", {
|
|
92805
|
+
project: event.summary.project,
|
|
92806
|
+
turn: event.summary.turnIndex,
|
|
92807
|
+
tools: event.summary.toolsUsed.length,
|
|
92808
|
+
failed: event.summary.toolsUsed.filter((t) => !t.ok).length
|
|
92809
|
+
});
|
|
92810
|
+
const taskId = this.inFlightTaskByProject.get(event.summary.project);
|
|
92811
|
+
finishedTaskId = taskId ?? null;
|
|
92812
|
+
if (taskId) {
|
|
92813
|
+
this.inFlightTaskByProject.delete(event.summary.project);
|
|
92814
|
+
const task = tasksStore.byId(taskId);
|
|
92815
|
+
if (task && task.status === "in_progress") {
|
|
92816
|
+
const reported = parseReportedStatus(event.summary.finalText);
|
|
92817
|
+
const newStatus = reportedToTaskStatus(
|
|
92818
|
+
reported,
|
|
92819
|
+
event.summary.toolsUsed.some((t) => !t.ok)
|
|
92820
|
+
);
|
|
92762
92821
|
await tasksStore.update(taskId, {
|
|
92763
|
-
status:
|
|
92764
|
-
|
|
92822
|
+
status: newStatus,
|
|
92823
|
+
resultSummary: event.summary.finalText
|
|
92765
92824
|
});
|
|
92766
92825
|
}
|
|
92767
92826
|
}
|
|
92768
|
-
|
|
92769
|
-
|
|
92770
|
-
|
|
92771
|
-
|
|
92772
|
-
|
|
92773
|
-
|
|
92774
|
-
|
|
92775
|
-
|
|
92776
|
-
|
|
92777
|
-
|
|
92778
|
-
|
|
92779
|
-
|
|
92780
|
-
|
|
92781
|
-
|
|
92782
|
-
|
|
92783
|
-
|
|
92784
|
-
|
|
92785
|
-
|
|
92786
|
-
|
|
92787
|
-
|
|
92788
|
-
|
|
92789
|
-
|
|
92790
|
-
|
|
92791
|
-
|
|
92792
|
-
|
|
92793
|
-
|
|
92794
|
-
|
|
92795
|
-
|
|
92796
|
-
|
|
92797
|
-
|
|
92798
|
-
|
|
92799
|
-
|
|
92800
|
-
|
|
92801
|
-
|
|
92802
|
-
|
|
92803
|
-
|
|
92804
|
-
|
|
92805
|
-
|
|
92806
|
-
|
|
92807
|
-
|
|
92808
|
-
|
|
92809
|
-
|
|
92810
|
-
|
|
92811
|
-
|
|
92812
|
-
|
|
92813
|
-
|
|
92814
|
-
|
|
92815
|
-
|
|
92816
|
-
|
|
92817
|
-
|
|
92818
|
-
|
|
92827
|
+
}
|
|
92828
|
+
if (event.kind === "worker_error") {
|
|
92829
|
+
this.hadWorkerActivitySinceReady = true;
|
|
92830
|
+
log2("ERROR", "worker_error", event.message, { project: event.project });
|
|
92831
|
+
const taskId = this.inFlightTaskByProject.get(event.project);
|
|
92832
|
+
if (taskId) {
|
|
92833
|
+
this.inFlightTaskByProject.delete(event.project);
|
|
92834
|
+
await tasksStore.update(taskId, {
|
|
92835
|
+
status: "blocked",
|
|
92836
|
+
notes: `Worker error: ${event.message}`
|
|
92837
|
+
});
|
|
92838
|
+
}
|
|
92839
|
+
}
|
|
92840
|
+
await this.runCompaction(false);
|
|
92841
|
+
const workerSnapshot = [...this.workers.entries()].map(([name, w]) => ({
|
|
92842
|
+
name,
|
|
92843
|
+
status: w.getStatus()
|
|
92844
|
+
}));
|
|
92845
|
+
const notices = this.pendingAutoChainNotices.splice(0);
|
|
92846
|
+
const text = formatEventForBoss(event, workerSnapshot, notices);
|
|
92847
|
+
bossStore.startStreaming();
|
|
92848
|
+
this.turnAc = new AbortController();
|
|
92849
|
+
this.bossAgent.setSignal(this.turnAc.signal);
|
|
92850
|
+
try {
|
|
92851
|
+
const stream2 = this.bossAgent.prompt(text);
|
|
92852
|
+
for await (const e of stream2) {
|
|
92853
|
+
switch (e.type) {
|
|
92854
|
+
case "text_delta":
|
|
92855
|
+
bossStore.appendStreamText(e.text);
|
|
92856
|
+
break;
|
|
92857
|
+
case "thinking_delta":
|
|
92858
|
+
bossStore.appendStreamThinking(e.text);
|
|
92859
|
+
break;
|
|
92860
|
+
case "tool_call_start":
|
|
92861
|
+
bossStore.flushPendingText();
|
|
92862
|
+
bossStore.startTool(e.toolCallId, e.name, e.args);
|
|
92863
|
+
bossStore.setActivityPhase("tools");
|
|
92864
|
+
break;
|
|
92865
|
+
case "tool_call_end":
|
|
92866
|
+
bossStore.endTool(e.toolCallId, e.isError, e.durationMs, e.result, e.details);
|
|
92867
|
+
break;
|
|
92868
|
+
case "turn_end":
|
|
92869
|
+
if (e.usage) {
|
|
92870
|
+
bossStore.setBossInputTokens(computeContextUsed(e.usage, this.opts.bossProvider));
|
|
92871
|
+
}
|
|
92872
|
+
bossStore.flushPendingText();
|
|
92873
|
+
bossStore.flushEndOfTurnInfos();
|
|
92874
|
+
break;
|
|
92875
|
+
case "retry":
|
|
92876
|
+
if (!e.silent) {
|
|
92877
|
+
bossStore.setRetryInfo({
|
|
92878
|
+
reason: e.reason,
|
|
92879
|
+
attempt: e.attempt,
|
|
92880
|
+
maxAttempts: e.maxAttempts,
|
|
92881
|
+
delayMs: e.delayMs
|
|
92882
|
+
});
|
|
92883
|
+
}
|
|
92884
|
+
break;
|
|
92885
|
+
case "error":
|
|
92886
|
+
bossStore.appendInfo(formatProviderError(e.error.message), "error");
|
|
92887
|
+
break;
|
|
92888
|
+
default:
|
|
92889
|
+
break;
|
|
92819
92890
|
}
|
|
92820
|
-
}
|
|
92821
|
-
|
|
92822
|
-
|
|
92823
|
-
|
|
92824
|
-
|
|
92825
|
-
return;
|
|
92826
|
-
}
|
|
92827
|
-
bossStore.appendInfo("Interrupted by user.", "warning");
|
|
92891
|
+
}
|
|
92892
|
+
} catch (err) {
|
|
92893
|
+
if (isAbortError3(err)) {
|
|
92894
|
+
bossStore.interruptStreaming();
|
|
92895
|
+
if (!this.running) {
|
|
92828
92896
|
bossStore.finishStreaming();
|
|
92829
|
-
|
|
92830
|
-
continue;
|
|
92897
|
+
return;
|
|
92831
92898
|
}
|
|
92832
|
-
|
|
92833
|
-
|
|
92834
|
-
|
|
92835
|
-
|
|
92836
|
-
bossStore.finishStreaming();
|
|
92837
|
-
await this.persistNewMessages();
|
|
92838
|
-
if (event.kind === "worker_turn_complete" && finishedTaskId) {
|
|
92839
|
-
await this.maybeAutoChain(event.summary.project);
|
|
92840
|
-
}
|
|
92841
|
-
const allWorkersIdle = [...this.workers.values()].every((w) => w.getStatus() === "idle");
|
|
92842
|
-
if (this.hadWorkerActivitySinceReady && allWorkersIdle && this.queue.size() === 0) {
|
|
92843
|
-
this.hadWorkerActivitySinceReady = false;
|
|
92844
|
-
log2("INFO", "all_clear", "all workers idle, queue empty");
|
|
92845
|
-
void playReadyAudio();
|
|
92899
|
+
bossStore.appendInfo("Interrupted by user.", "warning");
|
|
92900
|
+
bossStore.finishStreaming();
|
|
92901
|
+
await this.persistNewMessages();
|
|
92902
|
+
return;
|
|
92846
92903
|
}
|
|
92904
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
92905
|
+
log2("ERROR", "boss_turn", message);
|
|
92906
|
+
bossStore.appendInfo(formatProviderError(message), "error");
|
|
92907
|
+
}
|
|
92908
|
+
bossStore.finishStreaming();
|
|
92909
|
+
await this.persistNewMessages();
|
|
92910
|
+
if (event.kind === "worker_turn_complete" && finishedTaskId) {
|
|
92911
|
+
await this.maybeAutoChain(event.summary.project);
|
|
92912
|
+
}
|
|
92913
|
+
const allWorkersIdle = [...this.workers.values()].every((w) => w.getStatus() === "idle");
|
|
92914
|
+
if (this.hadWorkerActivitySinceReady && allWorkersIdle && this.queue.size() === 0) {
|
|
92915
|
+
this.hadWorkerActivitySinceReady = false;
|
|
92916
|
+
log2("INFO", "all_clear", "all workers idle, queue empty");
|
|
92917
|
+
void playReadyAudio();
|
|
92847
92918
|
}
|
|
92848
92919
|
}
|
|
92849
92920
|
async maybeAutoChain(project) {
|
|
@@ -92990,6 +93061,8 @@ export {
|
|
|
92990
93061
|
ModelSelector,
|
|
92991
93062
|
useBossState,
|
|
92992
93063
|
bossStore,
|
|
93064
|
+
initLogger2 as initLogger,
|
|
93065
|
+
log2 as log,
|
|
92993
93066
|
Worker,
|
|
92994
93067
|
EventQueue,
|
|
92995
93068
|
useTasksState,
|
|
@@ -92997,8 +93070,6 @@ export {
|
|
|
92997
93070
|
loadSettings,
|
|
92998
93071
|
getSplashAudioDurationMs,
|
|
92999
93072
|
playSplashAudio,
|
|
93000
|
-
initLogger2 as initLogger,
|
|
93001
|
-
log2 as log,
|
|
93002
93073
|
buildBossSystemPrompt,
|
|
93003
93074
|
GGBoss
|
|
93004
93075
|
};
|
|
@@ -93114,4 +93185,4 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
93114
93185
|
* LICENSE file in the root directory of this source tree.
|
|
93115
93186
|
*)
|
|
93116
93187
|
*/
|
|
93117
|
-
//# sourceMappingURL=chunk-
|
|
93188
|
+
//# sourceMappingURL=chunk-ZQ7U73JW.js.map
|