atlarix 15.1.0 → 15.2.0
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.
|
@@ -296,7 +296,7 @@ var require_scope = __commonJS({
|
|
|
296
296
|
"node_modules/electron-log/src/core/scope.js"(exports2, module2) {
|
|
297
297
|
"use strict";
|
|
298
298
|
module2.exports = scopeFactory;
|
|
299
|
-
function scopeFactory(
|
|
299
|
+
function scopeFactory(logger102) {
|
|
300
300
|
return Object.defineProperties(scope, {
|
|
301
301
|
defaultLabel: { value: "", writable: true },
|
|
302
302
|
labelPadding: { value: true, writable: true },
|
|
@@ -317,8 +317,8 @@ var require_scope = __commonJS({
|
|
|
317
317
|
function scope(label) {
|
|
318
318
|
scope.maxLabelLength = Math.max(scope.maxLabelLength, label.length);
|
|
319
319
|
const newScope = {};
|
|
320
|
-
for (const level of
|
|
321
|
-
newScope[level] = (...d2) =>
|
|
320
|
+
for (const level of logger102.levels) {
|
|
321
|
+
newScope[level] = (...d2) => logger102.logData(d2, { level, scope: label });
|
|
322
322
|
}
|
|
323
323
|
newScope.log = newScope.info;
|
|
324
324
|
return newScope;
|
|
@@ -611,7 +611,7 @@ var require_transform = __commonJS({
|
|
|
611
611
|
"use strict";
|
|
612
612
|
module2.exports = { transform: transform2 };
|
|
613
613
|
function transform2({
|
|
614
|
-
logger:
|
|
614
|
+
logger: logger102,
|
|
615
615
|
message,
|
|
616
616
|
transport,
|
|
617
617
|
initialData = message?.data || [],
|
|
@@ -619,7 +619,7 @@ var require_transform = __commonJS({
|
|
|
619
619
|
}) {
|
|
620
620
|
return transforms.reduce((data, trans) => {
|
|
621
621
|
if (typeof trans === "function") {
|
|
622
|
-
return trans({ data, logger:
|
|
622
|
+
return trans({ data, logger: logger102, message, transport });
|
|
623
623
|
}
|
|
624
624
|
return data;
|
|
625
625
|
}, initialData);
|
|
@@ -642,7 +642,7 @@ var require_console = __commonJS({
|
|
|
642
642
|
silly: console.debug,
|
|
643
643
|
log: console.log
|
|
644
644
|
};
|
|
645
|
-
function consoleTransportRendererFactory(
|
|
645
|
+
function consoleTransportRendererFactory(logger102) {
|
|
646
646
|
return Object.assign(transport, {
|
|
647
647
|
format: "{h}:{i}:{s}.{ms}{scope} \u203A {text}",
|
|
648
648
|
transforms: [formatDataFn],
|
|
@@ -653,13 +653,13 @@ var require_console = __commonJS({
|
|
|
653
653
|
});
|
|
654
654
|
function transport(message) {
|
|
655
655
|
transport.writeFn({
|
|
656
|
-
message: { ...message, data: transform2({ logger:
|
|
656
|
+
message: { ...message, data: transform2({ logger: logger102, message, transport }) }
|
|
657
657
|
});
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
function formatDataFn({
|
|
661
661
|
data = [],
|
|
662
|
-
logger:
|
|
662
|
+
logger: logger102 = {},
|
|
663
663
|
message = {},
|
|
664
664
|
transport = {}
|
|
665
665
|
}) {
|
|
@@ -667,7 +667,7 @@ var require_console = __commonJS({
|
|
|
667
667
|
return transport.format({
|
|
668
668
|
data,
|
|
669
669
|
level: message?.level || "info",
|
|
670
|
-
logger:
|
|
670
|
+
logger: logger102,
|
|
671
671
|
message,
|
|
672
672
|
transport
|
|
673
673
|
});
|
|
@@ -687,7 +687,7 @@ var require_console = __commonJS({
|
|
|
687
687
|
case "logId":
|
|
688
688
|
return message.logId;
|
|
689
689
|
case "scope": {
|
|
690
|
-
const scope = message.scope ||
|
|
690
|
+
const scope = message.scope || logger102.scope?.defaultLabel;
|
|
691
691
|
return scope ? ` (${scope})` : "";
|
|
692
692
|
}
|
|
693
693
|
case "text":
|
|
@@ -724,14 +724,14 @@ var require_ipc = __commonJS({
|
|
|
724
724
|
var { transform: transform2 } = require_transform();
|
|
725
725
|
module2.exports = ipcTransportRendererFactory;
|
|
726
726
|
var RESTRICTED_TYPES = /* @__PURE__ */ new Set([Promise, WeakMap, WeakSet]);
|
|
727
|
-
function ipcTransportRendererFactory(
|
|
727
|
+
function ipcTransportRendererFactory(logger102) {
|
|
728
728
|
return Object.assign(transport, {
|
|
729
729
|
depth: 5,
|
|
730
730
|
transforms: [serializeFn]
|
|
731
731
|
});
|
|
732
732
|
function transport(message) {
|
|
733
733
|
if (!window.__electronLog) {
|
|
734
|
-
|
|
734
|
+
logger102.processMessage(
|
|
735
735
|
{
|
|
736
736
|
data: ["electron-log: logger isn't initialized in the main process"],
|
|
737
737
|
level: "error"
|
|
@@ -743,13 +743,13 @@ var require_ipc = __commonJS({
|
|
|
743
743
|
try {
|
|
744
744
|
const serialized = transform2({
|
|
745
745
|
initialData: message,
|
|
746
|
-
logger:
|
|
746
|
+
logger: logger102,
|
|
747
747
|
message,
|
|
748
748
|
transport
|
|
749
749
|
});
|
|
750
750
|
__electronLog.sendToMain(serialized);
|
|
751
751
|
} catch (e3) {
|
|
752
|
-
|
|
752
|
+
logger102.transports.console({
|
|
753
753
|
data: ["electronLog.transports.ipc", e3, "data:", message.data],
|
|
754
754
|
level: "error"
|
|
755
755
|
});
|
|
@@ -845,7 +845,7 @@ var require_renderer = __commonJS({
|
|
|
845
845
|
module2.exports.Logger = Logger;
|
|
846
846
|
module2.exports.default = module2.exports;
|
|
847
847
|
function createLogger() {
|
|
848
|
-
const
|
|
848
|
+
const logger102 = new Logger({
|
|
849
849
|
allowUnknownLevel: true,
|
|
850
850
|
errorHandler: new RendererErrorHandler(),
|
|
851
851
|
initializeFn: () => {
|
|
@@ -859,13 +859,13 @@ var require_renderer = __commonJS({
|
|
|
859
859
|
processType: "renderer"
|
|
860
860
|
}
|
|
861
861
|
});
|
|
862
|
-
|
|
862
|
+
logger102.errorHandler.setOptions({
|
|
863
863
|
logFn({ error: error51, errorName, showDialog }) {
|
|
864
|
-
|
|
864
|
+
logger102.transports.console({
|
|
865
865
|
data: [errorName, error51].filter(Boolean),
|
|
866
866
|
level: "error"
|
|
867
867
|
});
|
|
868
|
-
|
|
868
|
+
logger102.transports.ipc({
|
|
869
869
|
cmd: "errorHandler",
|
|
870
870
|
error: {
|
|
871
871
|
cause: error51?.cause,
|
|
@@ -875,7 +875,7 @@ var require_renderer = __commonJS({
|
|
|
875
875
|
stack: error51?.stack
|
|
876
876
|
},
|
|
877
877
|
errorName,
|
|
878
|
-
logId:
|
|
878
|
+
logId: logger102.logId,
|
|
879
879
|
showDialog
|
|
880
880
|
});
|
|
881
881
|
}
|
|
@@ -889,12 +889,12 @@ var require_renderer = __commonJS({
|
|
|
889
889
|
}
|
|
890
890
|
});
|
|
891
891
|
}
|
|
892
|
-
return new Proxy(
|
|
892
|
+
return new Proxy(logger102, {
|
|
893
893
|
get(target, prop) {
|
|
894
894
|
if (typeof target[prop] !== "undefined") {
|
|
895
895
|
return target[prop];
|
|
896
896
|
}
|
|
897
|
-
return (...data) =>
|
|
897
|
+
return (...data) => logger102.logData(data, { level: prop });
|
|
898
898
|
}
|
|
899
899
|
});
|
|
900
900
|
}
|
|
@@ -1331,7 +1331,7 @@ var require_initialize = __commonJS({
|
|
|
1331
1331
|
externalApi,
|
|
1332
1332
|
getSessions,
|
|
1333
1333
|
includeFutureSession,
|
|
1334
|
-
logger:
|
|
1334
|
+
logger: logger102,
|
|
1335
1335
|
preload = true,
|
|
1336
1336
|
spyRendererConsole = false
|
|
1337
1337
|
}) {
|
|
@@ -1342,15 +1342,15 @@ var require_initialize = __commonJS({
|
|
|
1342
1342
|
externalApi,
|
|
1343
1343
|
getSessions,
|
|
1344
1344
|
includeFutureSession,
|
|
1345
|
-
logger:
|
|
1345
|
+
logger: logger102,
|
|
1346
1346
|
preloadOption: preload
|
|
1347
1347
|
});
|
|
1348
1348
|
}
|
|
1349
1349
|
if (spyRendererConsole) {
|
|
1350
|
-
initializeSpyRendererConsole({ externalApi, logger:
|
|
1350
|
+
initializeSpyRendererConsole({ externalApi, logger: logger102 });
|
|
1351
1351
|
}
|
|
1352
1352
|
} catch (err2) {
|
|
1353
|
-
|
|
1353
|
+
logger102.warn(err2);
|
|
1354
1354
|
}
|
|
1355
1355
|
});
|
|
1356
1356
|
}
|
|
@@ -1359,12 +1359,12 @@ var require_initialize = __commonJS({
|
|
|
1359
1359
|
externalApi,
|
|
1360
1360
|
getSessions,
|
|
1361
1361
|
includeFutureSession,
|
|
1362
|
-
logger:
|
|
1362
|
+
logger: logger102,
|
|
1363
1363
|
preloadOption
|
|
1364
1364
|
}) {
|
|
1365
1365
|
let preloadPath = typeof preloadOption === "string" ? preloadOption : void 0;
|
|
1366
1366
|
if (preloadInitialized) {
|
|
1367
|
-
|
|
1367
|
+
logger102.warn(new Error("log.initialize({ preload }) already called").stack);
|
|
1368
1368
|
return;
|
|
1369
1369
|
}
|
|
1370
1370
|
preloadInitialized = true;
|
|
@@ -1395,9 +1395,9 @@ var require_initialize = __commonJS({
|
|
|
1395
1395
|
getSessions
|
|
1396
1396
|
});
|
|
1397
1397
|
}
|
|
1398
|
-
function initializeSpyRendererConsole({ externalApi, logger:
|
|
1398
|
+
function initializeSpyRendererConsole({ externalApi, logger: logger102 }) {
|
|
1399
1399
|
if (spyConsoleInitialized) {
|
|
1400
|
-
|
|
1400
|
+
logger102.warn(
|
|
1401
1401
|
new Error("log.initialize({ spyRendererConsole }) already called").stack
|
|
1402
1402
|
);
|
|
1403
1403
|
return;
|
|
@@ -1407,7 +1407,7 @@ var require_initialize = __commonJS({
|
|
|
1407
1407
|
externalApi.onEveryWebContentsEvent(
|
|
1408
1408
|
"console-message",
|
|
1409
1409
|
(event, level, message) => {
|
|
1410
|
-
|
|
1410
|
+
logger102.processMessage({
|
|
1411
1411
|
data: [message],
|
|
1412
1412
|
level: levels[level],
|
|
1413
1413
|
variables: { processType: "renderer" }
|
|
@@ -1619,7 +1619,7 @@ var require_EventLogger = __commonJS({
|
|
|
1619
1619
|
events,
|
|
1620
1620
|
externalApi,
|
|
1621
1621
|
level,
|
|
1622
|
-
logger:
|
|
1622
|
+
logger: logger102,
|
|
1623
1623
|
format: format2,
|
|
1624
1624
|
formatters,
|
|
1625
1625
|
scope
|
|
@@ -1633,8 +1633,8 @@ var require_EventLogger = __commonJS({
|
|
|
1633
1633
|
if (typeof level === "string") {
|
|
1634
1634
|
this.level = level;
|
|
1635
1635
|
}
|
|
1636
|
-
if (typeof
|
|
1637
|
-
this.logger =
|
|
1636
|
+
if (typeof logger102 === "object") {
|
|
1637
|
+
this.logger = logger102;
|
|
1638
1638
|
}
|
|
1639
1639
|
if (typeof format2 === "string" || typeof format2 === "function") {
|
|
1640
1640
|
this.format = format2;
|
|
@@ -1733,10 +1733,10 @@ var require_EventLogger = __commonJS({
|
|
|
1733
1733
|
}
|
|
1734
1734
|
}
|
|
1735
1735
|
handleEvent({ eventName, eventSource, handlerArgs }) {
|
|
1736
|
-
const
|
|
1737
|
-
if (
|
|
1736
|
+
const log106 = this.formatEventLog({ eventName, eventSource, handlerArgs });
|
|
1737
|
+
if (log106) {
|
|
1738
1738
|
const logFns = this.scope ? this.logger.scope(this.scope) : this.logger;
|
|
1739
|
-
logFns?.[this.level]?.(...
|
|
1739
|
+
logFns?.[this.level]?.(...log106);
|
|
1740
1740
|
}
|
|
1741
1741
|
}
|
|
1742
1742
|
};
|
|
@@ -1755,12 +1755,12 @@ var require_format = __commonJS({
|
|
|
1755
1755
|
formatText,
|
|
1756
1756
|
formatVariables,
|
|
1757
1757
|
timeZoneFromOffset,
|
|
1758
|
-
format({ message, logger:
|
|
1758
|
+
format({ message, logger: logger102, transport, data = message?.data }) {
|
|
1759
1759
|
switch (typeof transport.format) {
|
|
1760
1760
|
case "string": {
|
|
1761
1761
|
return transform2({
|
|
1762
1762
|
message,
|
|
1763
|
-
logger:
|
|
1763
|
+
logger: logger102,
|
|
1764
1764
|
transforms: [formatVariables, formatScope, formatText],
|
|
1765
1765
|
transport,
|
|
1766
1766
|
initialData: [transport.format, ...data]
|
|
@@ -1770,7 +1770,7 @@ var require_format = __commonJS({
|
|
|
1770
1770
|
return transport.format({
|
|
1771
1771
|
data,
|
|
1772
1772
|
level: message?.level || "info",
|
|
1773
|
-
logger:
|
|
1773
|
+
logger: logger102,
|
|
1774
1774
|
message,
|
|
1775
1775
|
transport
|
|
1776
1776
|
});
|
|
@@ -1797,8 +1797,8 @@ var require_format = __commonJS({
|
|
|
1797
1797
|
const minutes = (minutesPositive % 60).toString().padStart(2, "0");
|
|
1798
1798
|
return `${sign}${hours}:${minutes}`;
|
|
1799
1799
|
}
|
|
1800
|
-
function formatScope({ data, logger:
|
|
1801
|
-
const { defaultLabel, labelLength } =
|
|
1800
|
+
function formatScope({ data, logger: logger102, message }) {
|
|
1801
|
+
const { defaultLabel, labelLength } = logger102?.scope || {};
|
|
1802
1802
|
const template2 = data[0];
|
|
1803
1803
|
let label = message.scope;
|
|
1804
1804
|
if (!label) {
|
|
@@ -2074,7 +2074,7 @@ var require_console2 = __commonJS({
|
|
|
2074
2074
|
Object.assign(consoleTransportFactory, {
|
|
2075
2075
|
DEFAULT_FORMAT
|
|
2076
2076
|
});
|
|
2077
|
-
function consoleTransportFactory(
|
|
2077
|
+
function consoleTransportFactory(logger102) {
|
|
2078
2078
|
return Object.assign(transport, {
|
|
2079
2079
|
colorMap: {
|
|
2080
2080
|
error: "red",
|
|
@@ -2102,7 +2102,7 @@ var require_console2 = __commonJS({
|
|
|
2102
2102
|
}
|
|
2103
2103
|
});
|
|
2104
2104
|
function transport(message) {
|
|
2105
|
-
const data = transform2({ logger:
|
|
2105
|
+
const data = transform2({ logger: logger102, message, transport });
|
|
2106
2106
|
transport.writeFn({
|
|
2107
2107
|
message: { ...message, data }
|
|
2108
2108
|
});
|
|
@@ -2385,7 +2385,7 @@ var require_file = __commonJS({
|
|
|
2385
2385
|
var { toString: toString2 } = require_object();
|
|
2386
2386
|
module2.exports = fileTransportFactory;
|
|
2387
2387
|
var globalRegistry2 = new FileRegistry();
|
|
2388
|
-
function fileTransportFactory(
|
|
2388
|
+
function fileTransportFactory(logger102, { registry: registry3 = globalRegistry2, externalApi } = {}) {
|
|
2389
2389
|
let pathVariables;
|
|
2390
2390
|
if (registry3.listenerCount("error") < 1) {
|
|
2391
2391
|
registry3.on("error", (e3, file2) => {
|
|
@@ -2393,7 +2393,7 @@ var require_file = __commonJS({
|
|
|
2393
2393
|
});
|
|
2394
2394
|
}
|
|
2395
2395
|
return Object.assign(transport, {
|
|
2396
|
-
fileName: getDefaultFileName(
|
|
2396
|
+
fileName: getDefaultFileName(logger102.variables.processType),
|
|
2397
2397
|
format: "[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}",
|
|
2398
2398
|
getFile,
|
|
2399
2399
|
inspectOptions: { depth: 5 },
|
|
@@ -2418,7 +2418,7 @@ var require_file = __commonJS({
|
|
|
2418
2418
|
return path67.join(vars.libraryDefaultDir, vars.fileName);
|
|
2419
2419
|
},
|
|
2420
2420
|
setAppName(name29) {
|
|
2421
|
-
|
|
2421
|
+
logger102.dependencies.externalApi.setAppName(name29);
|
|
2422
2422
|
}
|
|
2423
2423
|
});
|
|
2424
2424
|
function transport(message) {
|
|
@@ -2428,7 +2428,7 @@ var require_file = __commonJS({
|
|
|
2428
2428
|
transport.archiveLogFn(file2);
|
|
2429
2429
|
file2.reset();
|
|
2430
2430
|
}
|
|
2431
|
-
const content = transform2({ logger:
|
|
2431
|
+
const content = transform2({ logger: logger102, message, transport });
|
|
2432
2432
|
file2.writeLine(content);
|
|
2433
2433
|
}
|
|
2434
2434
|
function initializeOnFirstAccess() {
|
|
@@ -2463,7 +2463,7 @@ var require_file = __commonJS({
|
|
|
2463
2463
|
if (error51) {
|
|
2464
2464
|
data.push(error51);
|
|
2465
2465
|
}
|
|
2466
|
-
|
|
2466
|
+
logger102.transports.console({ data, date: /* @__PURE__ */ new Date(), level });
|
|
2467
2467
|
}
|
|
2468
2468
|
function getFile(msg) {
|
|
2469
2469
|
initializeOnFirstAccess();
|
|
@@ -2512,11 +2512,11 @@ var require_ipc2 = __commonJS({
|
|
|
2512
2512
|
var { maxDepth, toJSON } = require_object();
|
|
2513
2513
|
var { transform: transform2 } = require_transform();
|
|
2514
2514
|
module2.exports = ipcTransportFactory;
|
|
2515
|
-
function ipcTransportFactory(
|
|
2515
|
+
function ipcTransportFactory(logger102, { externalApi }) {
|
|
2516
2516
|
Object.assign(transport, {
|
|
2517
2517
|
depth: 3,
|
|
2518
2518
|
eventId: "__ELECTRON_LOG_IPC__",
|
|
2519
|
-
level:
|
|
2519
|
+
level: logger102.isDev ? "silly" : false,
|
|
2520
2520
|
transforms: [toJSON, maxDepth]
|
|
2521
2521
|
});
|
|
2522
2522
|
return externalApi?.isElectron() ? transport : void 0;
|
|
@@ -2526,7 +2526,7 @@ var require_ipc2 = __commonJS({
|
|
|
2526
2526
|
}
|
|
2527
2527
|
externalApi?.sendIpc(transport.eventId, {
|
|
2528
2528
|
...message,
|
|
2529
|
-
data: transform2({ logger:
|
|
2529
|
+
data: transform2({ logger: logger102, message, transport })
|
|
2530
2530
|
});
|
|
2531
2531
|
}
|
|
2532
2532
|
}
|
|
@@ -2543,7 +2543,7 @@ var require_remote = __commonJS({
|
|
|
2543
2543
|
var { removeStyles } = require_style();
|
|
2544
2544
|
var { toJSON, maxDepth } = require_object();
|
|
2545
2545
|
module2.exports = remoteTransportFactory;
|
|
2546
|
-
function remoteTransportFactory(
|
|
2546
|
+
function remoteTransportFactory(logger102) {
|
|
2547
2547
|
return Object.assign(transport, {
|
|
2548
2548
|
client: { name: "electron-application" },
|
|
2549
2549
|
depth: 6,
|
|
@@ -2561,7 +2561,7 @@ var require_remote = __commonJS({
|
|
|
2561
2561
|
});
|
|
2562
2562
|
},
|
|
2563
2563
|
processErrorFn({ error: error51 }) {
|
|
2564
|
-
|
|
2564
|
+
logger102.processMessage(
|
|
2565
2565
|
{
|
|
2566
2566
|
data: [`electron-log: can't POST ${transport.url}`, error51],
|
|
2567
2567
|
level: "warn"
|
|
@@ -2590,8 +2590,8 @@ var require_remote = __commonJS({
|
|
|
2590
2590
|
return;
|
|
2591
2591
|
}
|
|
2592
2592
|
const body = transport.makeBodyFn({
|
|
2593
|
-
logger:
|
|
2594
|
-
message: { ...message, data: transform2({ logger:
|
|
2593
|
+
logger: logger102,
|
|
2594
|
+
message: { ...message, data: transform2({ logger: logger102, message, transport }) },
|
|
2595
2595
|
transport
|
|
2596
2596
|
});
|
|
2597
2597
|
const request = transport.sendRequestFn({
|
|
@@ -2601,7 +2601,7 @@ var require_remote = __commonJS({
|
|
|
2601
2601
|
});
|
|
2602
2602
|
request.on("error", (error51) => transport.processErrorFn({
|
|
2603
2603
|
error: error51,
|
|
2604
|
-
logger:
|
|
2604
|
+
logger: logger102,
|
|
2605
2605
|
message,
|
|
2606
2606
|
request,
|
|
2607
2607
|
transport
|
|
@@ -2683,9 +2683,9 @@ var require_main = __commonJS({
|
|
|
2683
2683
|
externalApi.onIpcInvoke("__ELECTRON_LOG__", (_4, { cmd = "", logId }) => {
|
|
2684
2684
|
switch (cmd) {
|
|
2685
2685
|
case "getOptions": {
|
|
2686
|
-
const
|
|
2686
|
+
const logger102 = defaultLogger2.Logger.getInstance({ logId });
|
|
2687
2687
|
return {
|
|
2688
|
-
levels:
|
|
2688
|
+
levels: logger102.levels,
|
|
2689
2689
|
logId
|
|
2690
2690
|
};
|
|
2691
2691
|
}
|
|
@@ -8956,10 +8956,10 @@ var init_session2 = __esm({
|
|
|
8956
8956
|
}
|
|
8957
8957
|
};
|
|
8958
8958
|
PreparedQuery = class extends SQLitePreparedQuery {
|
|
8959
|
-
constructor(stmt, query,
|
|
8959
|
+
constructor(stmt, query, logger102, cache8, queryMetadata, cacheConfig, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
|
8960
8960
|
super("sync", executeMethod, query, cache8, queryMetadata, cacheConfig);
|
|
8961
8961
|
this.stmt = stmt;
|
|
8962
|
-
this.logger =
|
|
8962
|
+
this.logger = logger102;
|
|
8963
8963
|
this.fields = fields;
|
|
8964
8964
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
8965
8965
|
this.customResultMapper = customResultMapper;
|
|
@@ -8971,10 +8971,10 @@ var init_session2 = __esm({
|
|
|
8971
8971
|
return this.stmt.run(...params);
|
|
8972
8972
|
}
|
|
8973
8973
|
all(placeholderValues) {
|
|
8974
|
-
const { fields, joinsNotNullableMap, query, logger:
|
|
8974
|
+
const { fields, joinsNotNullableMap, query, logger: logger102, stmt, customResultMapper } = this;
|
|
8975
8975
|
if (!fields && !customResultMapper) {
|
|
8976
8976
|
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
|
8977
|
-
|
|
8977
|
+
logger102.logQuery(query.sql, params);
|
|
8978
8978
|
return stmt.all(...params);
|
|
8979
8979
|
}
|
|
8980
8980
|
const rows = this.values(placeholderValues);
|
|
@@ -9016,11 +9016,11 @@ var init_session2 = __esm({
|
|
|
9016
9016
|
import Client from "better-sqlite3";
|
|
9017
9017
|
function construct(client2, config2 = {}) {
|
|
9018
9018
|
const dialect = new SQLiteSyncDialect({ casing: config2.casing });
|
|
9019
|
-
let
|
|
9019
|
+
let logger102;
|
|
9020
9020
|
if (config2.logger === true) {
|
|
9021
|
-
|
|
9021
|
+
logger102 = new DefaultLogger();
|
|
9022
9022
|
} else if (config2.logger !== false) {
|
|
9023
|
-
|
|
9023
|
+
logger102 = config2.logger;
|
|
9024
9024
|
}
|
|
9025
9025
|
let schema;
|
|
9026
9026
|
if (config2.schema) {
|
|
@@ -9034,7 +9034,7 @@ function construct(client2, config2 = {}) {
|
|
|
9034
9034
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
9035
9035
|
};
|
|
9036
9036
|
}
|
|
9037
|
-
const session2 = new BetterSQLiteSession(client2, dialect, schema, { logger:
|
|
9037
|
+
const session2 = new BetterSQLiteSession(client2, dialect, schema, { logger: logger102 });
|
|
9038
9038
|
const db3 = new BetterSQLite3Database("sync", dialect, session2, schema);
|
|
9039
9039
|
db3.$client = client2;
|
|
9040
9040
|
return db3;
|
|
@@ -11697,7 +11697,7 @@ function localResetTime(retryAfterSeconds, now2 = Date.now(), timeZone) {
|
|
|
11697
11697
|
}
|
|
11698
11698
|
function freeUsageLimitUserMessage(retryAfterSeconds, now2 = Date.now(), timeZone) {
|
|
11699
11699
|
const when = typeof retryAfterSeconds === "number" && retryAfterSeconds > 0 ? ` \xB7 resets at ${localResetTime(retryAfterSeconds, now2, timeZone)}` : " \xB7 resets at midnight UTC";
|
|
11700
|
-
return `Today's free share is used up${when}. ${
|
|
11700
|
+
return `Today's free share is used up${when}. ${FREE_LIMIT_WAYS}`;
|
|
11701
11701
|
}
|
|
11702
11702
|
function autoConsentRequiredUserMessage() {
|
|
11703
11703
|
return `Atlarix Auto is free once you OK sharing its prompts with OpenAI to improve their models. Review and accept to keep going. ${UPGRADE_LINE}`;
|
|
@@ -11725,7 +11725,7 @@ function compassBadRequestUserMessage(detail) {
|
|
|
11725
11725
|
const suffix = reason ? ` The model reported: "${reason.slice(0, 300)}"` : "";
|
|
11726
11726
|
return `Atlarix Core rejected this request.${suffix} This is usually a problem with the request itself rather than an outage \u2014 try again, and if it repeats, switch Core model or use your own API key in Settings.`;
|
|
11727
11727
|
}
|
|
11728
|
-
var CORE_PAYMENT_SUMMARY, CORE_EXHAUSTED_MESSAGE, NEGATIVE_BALANCE_EXPLAINER, COMPASS_REACHABILITY_ERROR, UPGRADE_LINE;
|
|
11728
|
+
var CORE_PAYMENT_SUMMARY, CORE_EXHAUSTED_MESSAGE, NEGATIVE_BALANCE_EXPLAINER, COMPASS_REACHABILITY_ERROR, UPGRADE_LINE, FREE_LIMIT_WAYS;
|
|
11729
11729
|
var init_billing_copy = __esm({
|
|
11730
11730
|
"src/shared/billing_copy.ts"() {
|
|
11731
11731
|
init_compass_product_copy();
|
|
@@ -11734,6 +11734,7 @@ var init_billing_copy = __esm({
|
|
|
11734
11734
|
NEGATIVE_BALANCE_EXPLAINER = `A refund was applied, so your balance is negative. Top up to restore a positive balance before using ${ATLARIX_CORE_CATEGORY_LABEL}.`;
|
|
11735
11735
|
COMPASS_REACHABILITY_ERROR = "We're currently having trouble reaching Atlarix Core. Please retry or switch to another provider in Settings.";
|
|
11736
11736
|
UPGRADE_LINE = "Get more with Atlarix Pro \u2014 $19/month, includes Core usage across the app, the Chrome extension and Reviewer. Or add credit and pay only for what you use.";
|
|
11737
|
+
FREE_LIMIT_WAYS = "To keep going now, add credit and pay only for what you use (from $10), or switch to your own API key or a local model, which have no Atlarix limits. Atlarix Pro ($19/month) covers Auto too.";
|
|
11737
11738
|
}
|
|
11738
11739
|
});
|
|
11739
11740
|
|
|
@@ -135610,7 +135611,7 @@ var require_node2 = __commonJS({
|
|
|
135610
135611
|
var tty = __require("tty");
|
|
135611
135612
|
var util2 = __require("util");
|
|
135612
135613
|
exports2.init = init2;
|
|
135613
|
-
exports2.log =
|
|
135614
|
+
exports2.log = log106;
|
|
135614
135615
|
exports2.formatArgs = formatArgs;
|
|
135615
135616
|
exports2.save = save;
|
|
135616
135617
|
exports2.load = load;
|
|
@@ -135745,7 +135746,7 @@ var require_node2 = __commonJS({
|
|
|
135745
135746
|
}
|
|
135746
135747
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
135747
135748
|
}
|
|
135748
|
-
function
|
|
135749
|
+
function log106(...args2) {
|
|
135749
135750
|
return process.stderr.write(util2.formatWithOptions(exports2.inspectOpts, ...args2) + "\n");
|
|
135750
135751
|
}
|
|
135751
135752
|
function save(namespaces) {
|
|
@@ -145184,7 +145185,7 @@ var require_logging_utils = __commonJS({
|
|
|
145184
145185
|
exports2.getDebugBackend = getDebugBackend;
|
|
145185
145186
|
exports2.getStructuredBackend = getStructuredBackend;
|
|
145186
145187
|
exports2.setBackend = setBackend;
|
|
145187
|
-
exports2.log =
|
|
145188
|
+
exports2.log = log106;
|
|
145188
145189
|
var events_1 = __require("events");
|
|
145189
145190
|
var process6 = __importStar2(__require("process"));
|
|
145190
145191
|
var util2 = __importStar2(__require("util"));
|
|
@@ -145216,7 +145217,7 @@ var require_logging_utils = __commonJS({
|
|
|
145216
145217
|
this.func.info = (...args2) => this.invokeSeverity(LogSeverity.INFO, ...args2);
|
|
145217
145218
|
this.func.warn = (...args2) => this.invokeSeverity(LogSeverity.WARNING, ...args2);
|
|
145218
145219
|
this.func.error = (...args2) => this.invokeSeverity(LogSeverity.ERROR, ...args2);
|
|
145219
|
-
this.func.sublog = (namespace2) =>
|
|
145220
|
+
this.func.sublog = (namespace2) => log106(namespace2, this.func);
|
|
145220
145221
|
}
|
|
145221
145222
|
invoke(fields, ...args2) {
|
|
145222
145223
|
if (this.upstream) {
|
|
@@ -145255,12 +145256,12 @@ var require_logging_utils = __commonJS({
|
|
|
145255
145256
|
this.setFilters();
|
|
145256
145257
|
this.filtersSet = true;
|
|
145257
145258
|
}
|
|
145258
|
-
let
|
|
145259
|
-
if (!
|
|
145260
|
-
|
|
145261
|
-
this.cached.set(namespace,
|
|
145259
|
+
let logger102 = this.cached.get(namespace);
|
|
145260
|
+
if (!logger102) {
|
|
145261
|
+
logger102 = this.makeLogger(namespace);
|
|
145262
|
+
this.cached.set(namespace, logger102);
|
|
145262
145263
|
}
|
|
145263
|
-
|
|
145264
|
+
logger102(fields, ...args2);
|
|
145264
145265
|
} catch (e3) {
|
|
145265
145266
|
console.error(e3);
|
|
145266
145267
|
}
|
|
@@ -145383,7 +145384,7 @@ var require_logging_utils = __commonJS({
|
|
|
145383
145384
|
cachedBackend = backend;
|
|
145384
145385
|
loggerCache.clear();
|
|
145385
145386
|
}
|
|
145386
|
-
function
|
|
145387
|
+
function log106(namespace, parent) {
|
|
145387
145388
|
if (!cachedBackend) {
|
|
145388
145389
|
const enablesFlag = process6.env[exports2.env.nodeEnables];
|
|
145389
145390
|
if (!enablesFlag) {
|
|
@@ -145405,7 +145406,7 @@ var require_logging_utils = __commonJS({
|
|
|
145405
145406
|
} else if (cachedBackend === void 0) {
|
|
145406
145407
|
cachedBackend = getNodeBackend();
|
|
145407
145408
|
}
|
|
145408
|
-
const
|
|
145409
|
+
const logger102 = (() => {
|
|
145409
145410
|
let previousBackend = void 0;
|
|
145410
145411
|
const newLogger = new AdhocDebugLogger(namespace, (fields, ...args2) => {
|
|
145411
145412
|
if (previousBackend !== cachedBackend) {
|
|
@@ -145420,8 +145421,8 @@ var require_logging_utils = __commonJS({
|
|
|
145420
145421
|
});
|
|
145421
145422
|
return newLogger;
|
|
145422
145423
|
})();
|
|
145423
|
-
loggerCache.set(namespace,
|
|
145424
|
-
return
|
|
145424
|
+
loggerCache.set(namespace, logger102);
|
|
145425
|
+
return logger102.func;
|
|
145425
145426
|
}
|
|
145426
145427
|
}
|
|
145427
145428
|
});
|
|
@@ -145509,14 +145510,14 @@ var require_src5 = __commonJS({
|
|
|
145509
145510
|
var gaxios_1 = require_src3();
|
|
145510
145511
|
var jsonBigint = require_json_bigint();
|
|
145511
145512
|
var gcp_residency_1 = require_gcp_residency();
|
|
145512
|
-
var
|
|
145513
|
+
var logger102 = __importStar2(require_src4());
|
|
145513
145514
|
exports2.BASE_PATH = "/computeMetadata/v1";
|
|
145514
145515
|
exports2.HOST_ADDRESS = "http://169.254.169.254";
|
|
145515
145516
|
exports2.SECONDARY_HOST_ADDRESS = "http://metadata.google.internal.";
|
|
145516
145517
|
exports2.HEADER_NAME = "Metadata-Flavor";
|
|
145517
145518
|
exports2.HEADER_VALUE = "Google";
|
|
145518
145519
|
exports2.HEADERS = Object.freeze({ [exports2.HEADER_NAME]: exports2.HEADER_VALUE });
|
|
145519
|
-
var
|
|
145520
|
+
var log106 = logger102.log("gcp-metadata");
|
|
145520
145521
|
exports2.METADATA_SERVER_DETECTION = Object.freeze({
|
|
145521
145522
|
"assume-present": "don't try to ping the metadata server, but assume it's present",
|
|
145522
145523
|
none: "don't try to ping the metadata server, but don't try to use it either",
|
|
@@ -145579,9 +145580,9 @@ var require_src5 = __commonJS({
|
|
|
145579
145580
|
responseType: "text",
|
|
145580
145581
|
timeout: requestTimeout()
|
|
145581
145582
|
};
|
|
145582
|
-
|
|
145583
|
+
log106.info("instance request %j", req);
|
|
145583
145584
|
const res = await requestMethod(req);
|
|
145584
|
-
|
|
145585
|
+
log106.info("instance metadata is %s", res.data);
|
|
145585
145586
|
const metadataFlavor = res.headers.get(exports2.HEADER_NAME);
|
|
145586
145587
|
if (metadataFlavor !== exports2.HEADER_VALUE) {
|
|
145587
145588
|
throw new RangeError(`Invalid response from metadata service: incorrect ${exports2.HEADER_NAME} header. Expected '${exports2.HEADER_VALUE}', got ${metadataFlavor ? `'${metadataFlavor}'` : "no header"}`);
|
|
@@ -175105,8 +175106,8 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
175105
175106
|
return !!detail.signature;
|
|
175106
175107
|
});
|
|
175107
175108
|
if (validDetails.length < candidateReasoningDetails.length) {
|
|
175108
|
-
const
|
|
175109
|
-
if (
|
|
175109
|
+
const logger102 = globalThis.AI_SDK_LOG_WARNINGS;
|
|
175110
|
+
if (logger102 !== false && typeof logger102 !== "function") {
|
|
175110
175111
|
console.warn(
|
|
175111
175112
|
"[openrouter] Some reasoning_details entries were removed because they were missing signatures. See https://github.com/OpenRouterTeam/ai-sdk-provider/issues/423 and https://github.com/OpenRouterTeam/ai-sdk-provider/issues/418 for more details."
|
|
175112
175113
|
);
|
|
@@ -185918,19 +185919,19 @@ var init_ProviderError = __esm({
|
|
|
185918
185919
|
name = "ProviderError";
|
|
185919
185920
|
tryNextLink;
|
|
185920
185921
|
constructor(message, options = true) {
|
|
185921
|
-
let
|
|
185922
|
+
let logger102;
|
|
185922
185923
|
let tryNextLink = true;
|
|
185923
185924
|
if (typeof options === "boolean") {
|
|
185924
|
-
|
|
185925
|
+
logger102 = void 0;
|
|
185925
185926
|
tryNextLink = options;
|
|
185926
185927
|
} else if (options != null && typeof options === "object") {
|
|
185927
|
-
|
|
185928
|
+
logger102 = options.logger;
|
|
185928
185929
|
tryNextLink = options.tryNextLink ?? true;
|
|
185929
185930
|
}
|
|
185930
185931
|
super(message);
|
|
185931
185932
|
this.tryNextLink = tryNextLink;
|
|
185932
185933
|
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
185933
|
-
|
|
185934
|
+
logger102?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
185934
185935
|
}
|
|
185935
185936
|
static from(error51, options = true) {
|
|
185936
185937
|
return Object.assign(new this(error51.message, options), error51);
|
|
@@ -186359,8 +186360,8 @@ var init_configLoader = __esm({
|
|
|
186359
186360
|
init_fromSharedConfigFiles();
|
|
186360
186361
|
init_fromStatic();
|
|
186361
186362
|
loadConfig = ({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
|
|
186362
|
-
const { signingName, logger:
|
|
186363
|
-
const envOptions = { signingName, logger:
|
|
186363
|
+
const { signingName, logger: logger102 } = configuration;
|
|
186364
|
+
const envOptions = { signingName, logger: logger102 };
|
|
186364
186365
|
return memoize(chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue)));
|
|
186365
186366
|
};
|
|
186366
186367
|
}
|
|
@@ -187229,7 +187230,7 @@ var init_ByteArrayCollector = __esm({
|
|
|
187229
187230
|
});
|
|
187230
187231
|
|
|
187231
187232
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.browser.js
|
|
187232
|
-
function createBufferedReadableStream(upstream, size2,
|
|
187233
|
+
function createBufferedReadableStream(upstream, size2, logger102) {
|
|
187233
187234
|
const reader = upstream.getReader();
|
|
187234
187235
|
let streamBufferingLoggedWarning = false;
|
|
187235
187236
|
let bytesSeen = 0;
|
|
@@ -187267,7 +187268,7 @@ function createBufferedReadableStream(upstream, size2, logger101) {
|
|
|
187267
187268
|
const newSize = merge2(buffers, mode, chunk2);
|
|
187268
187269
|
if (!streamBufferingLoggedWarning && bytesSeen > size2 * 2) {
|
|
187269
187270
|
streamBufferingLoggedWarning = true;
|
|
187270
|
-
|
|
187271
|
+
logger102?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size2}, automatically buffering.`);
|
|
187271
187272
|
}
|
|
187272
187273
|
if (newSize >= size2) {
|
|
187273
187274
|
controller.enqueue(flush2(buffers, mode));
|
|
@@ -187327,9 +187328,9 @@ var init_createBufferedReadable_browser = __esm({
|
|
|
187327
187328
|
|
|
187328
187329
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.js
|
|
187329
187330
|
import { Readable as Readable2 } from "node:stream";
|
|
187330
|
-
function createBufferedReadable(upstream, size2,
|
|
187331
|
+
function createBufferedReadable(upstream, size2, logger102) {
|
|
187331
187332
|
if (isReadableStream(upstream)) {
|
|
187332
|
-
return createBufferedReadableStream(upstream, size2,
|
|
187333
|
+
return createBufferedReadableStream(upstream, size2, logger102);
|
|
187333
187334
|
}
|
|
187334
187335
|
const downstream = new Readable2({ read() {
|
|
187335
187336
|
} });
|
|
@@ -187362,7 +187363,7 @@ function createBufferedReadable(upstream, size2, logger101) {
|
|
|
187362
187363
|
const newSize = merge2(buffers, mode, chunk2);
|
|
187363
187364
|
if (!streamBufferingLoggedWarning && bytesSeen > size2 * 2) {
|
|
187364
187365
|
streamBufferingLoggedWarning = true;
|
|
187365
|
-
|
|
187366
|
+
logger102?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size2}, automatically buffering.`);
|
|
187366
187367
|
}
|
|
187367
187368
|
if (newSize >= size2) {
|
|
187368
187369
|
downstream.push(flush2(buffers, mode));
|
|
@@ -192224,10 +192225,12 @@ function autoStatusFromHeaders(headers) {
|
|
|
192224
192225
|
const billing = billingRaw === "free" || billingRaw === "paid" ? billingRaw : null;
|
|
192225
192226
|
const costRaw = headers.get("x-atlarix-cost-cents");
|
|
192226
192227
|
const cost = costRaw != null && costRaw !== "" ? Number(costRaw) : null;
|
|
192228
|
+
const floorRaw = headers.get("x-atlarix-free-floor");
|
|
192227
192229
|
if (!servedModel && freeRemaining == null && !billing) return null;
|
|
192228
192230
|
return {
|
|
192229
192231
|
servedModel: servedModel || null,
|
|
192230
192232
|
billing,
|
|
192233
|
+
onFloor: floorRaw === "1" ? true : floorRaw === "0" ? false : null,
|
|
192231
192234
|
costCents: cost != null && Number.isFinite(cost) ? cost : null,
|
|
192232
192235
|
freeRemaining: freeRemaining != null && Number.isFinite(freeRemaining) ? Math.max(0, Math.min(100, freeRemaining)) : null
|
|
192233
192236
|
};
|
|
@@ -213113,14 +213116,15 @@ function setUserInterjectionNotifier(fn2) {
|
|
|
213113
213116
|
function notify(chatId) {
|
|
213114
213117
|
notifier?.(chatId, listPendingUserInterjections(chatId));
|
|
213115
213118
|
}
|
|
213116
|
-
function recordUserInterjection(chatId, msg) {
|
|
213119
|
+
function recordUserInterjection(chatId, msg, opts = {}) {
|
|
213117
213120
|
const text3 = msg.text.trim();
|
|
213118
213121
|
if (!text3) return null;
|
|
213122
|
+
const cap = opts.cap === void 0 ? TEXT_CAP : opts.cap;
|
|
213119
213123
|
const list = byChat.get(chatId) ?? [];
|
|
213120
213124
|
if (list.some((m3) => m3.id === msg.id)) return null;
|
|
213121
213125
|
const entry = {
|
|
213122
213126
|
id: msg.id,
|
|
213123
|
-
text: text3.length >
|
|
213127
|
+
text: cap != null && text3.length > cap ? `${text3.slice(0, cap)}\u2026` : text3,
|
|
213124
213128
|
ts: msg.ts ?? Date.now()
|
|
213125
213129
|
};
|
|
213126
213130
|
list.push(entry);
|
|
@@ -231313,12 +231317,12 @@ var init_dist21 = __esm({
|
|
|
231313
231317
|
if (options.warnings.length === 0) {
|
|
231314
231318
|
return;
|
|
231315
231319
|
}
|
|
231316
|
-
const
|
|
231317
|
-
if (
|
|
231320
|
+
const logger102 = globalThis.AI_SDK_LOG_WARNINGS;
|
|
231321
|
+
if (logger102 === false) {
|
|
231318
231322
|
return;
|
|
231319
231323
|
}
|
|
231320
|
-
if (typeof
|
|
231321
|
-
|
|
231324
|
+
if (typeof logger102 === "function") {
|
|
231325
|
+
logger102(options);
|
|
231322
231326
|
return;
|
|
231323
231327
|
}
|
|
231324
231328
|
if (!hasLoggedBefore) {
|
|
@@ -237251,32 +237255,32 @@ function isUntrustedSenderFrame(event) {
|
|
|
237251
237255
|
const frameUrl = event.senderFrame?.url ?? "";
|
|
237252
237256
|
return /^https?:\/\//i.test(frameUrl);
|
|
237253
237257
|
}
|
|
237254
|
-
function createLoggedHandler(
|
|
237258
|
+
function createLoggedHandler(logger102) {
|
|
237255
237259
|
return (channel, fn2) => {
|
|
237256
237260
|
ipcMain.handle(
|
|
237257
237261
|
channel,
|
|
237258
237262
|
async (event, ...args2) => {
|
|
237259
237263
|
if (isUntrustedSenderFrame(event)) {
|
|
237260
|
-
|
|
237264
|
+
logger102.error(
|
|
237261
237265
|
`IPC ${channel} rejected: untrusted sender frame ${event.senderFrame?.url}`
|
|
237262
237266
|
);
|
|
237263
237267
|
throw new Error(`[${channel}] rejected: untrusted sender frame`);
|
|
237264
237268
|
}
|
|
237265
237269
|
if (verboseIpc) {
|
|
237266
|
-
|
|
237270
|
+
logger102.log(
|
|
237267
237271
|
`IPC: ${channel} called with args: ${JSON.stringify(args2)}`
|
|
237268
237272
|
);
|
|
237269
237273
|
}
|
|
237270
237274
|
try {
|
|
237271
237275
|
const result2 = await fn2(event, ...args2);
|
|
237272
237276
|
if (verboseIpc) {
|
|
237273
|
-
|
|
237277
|
+
logger102.log(
|
|
237274
237278
|
`IPC: ${channel} returned: ${JSON.stringify(result2)?.slice(0, 100)}...`
|
|
237275
237279
|
);
|
|
237276
237280
|
}
|
|
237277
237281
|
return result2;
|
|
237278
237282
|
} catch (error51) {
|
|
237279
|
-
|
|
237283
|
+
logger102.error(
|
|
237280
237284
|
`Error in ${fn2.name}: args: ${JSON.stringify(args2)}`,
|
|
237281
237285
|
error51
|
|
237282
237286
|
);
|
|
@@ -238271,6 +238275,9 @@ var init_framing = __esm({
|
|
|
238271
238275
|
});
|
|
238272
238276
|
|
|
238273
238277
|
// src/lib/peers/peer-message.ts
|
|
238278
|
+
function peerSurfaceLabel(surface2) {
|
|
238279
|
+
return surface2 === "cli" ? "CLI" : surface2 === "chrome" ? "browser" : "app";
|
|
238280
|
+
}
|
|
238274
238281
|
var init_peer_message = __esm({
|
|
238275
238282
|
"src/lib/peers/peer-message.ts"() {
|
|
238276
238283
|
}
|
|
@@ -238311,7 +238318,7 @@ function ensureTable(db3) {
|
|
|
238311
238318
|
}
|
|
238312
238319
|
}
|
|
238313
238320
|
function refreshNames(d2) {
|
|
238314
|
-
const ids = [...local.values()].filter((x4) => !x4.materialize).map((x4) => x4.sessionId);
|
|
238321
|
+
const ids = [...local.values()].filter((x4) => !x4.materialize && !x4.deliver).map((x4) => x4.sessionId);
|
|
238315
238322
|
if (ids.length === 0) return;
|
|
238316
238323
|
try {
|
|
238317
238324
|
const rows = d2.prepare(
|
|
@@ -238382,8 +238389,8 @@ function publish() {
|
|
|
238382
238389
|
token,
|
|
238383
238390
|
s3.name,
|
|
238384
238391
|
s3.workspace,
|
|
238385
|
-
surface,
|
|
238386
|
-
hostImpl?.isBusy(s3.chatId) ? 1 : 0,
|
|
238392
|
+
s3.surface ?? surface,
|
|
238393
|
+
!s3.deliver && hostImpl?.isBusy(s3.chatId) ? 1 : 0,
|
|
238387
238394
|
now2,
|
|
238388
238395
|
JSON.stringify(s3.aliases ?? [])
|
|
238389
238396
|
);
|
|
@@ -238447,7 +238454,7 @@ function listPeerSessions(exclude) {
|
|
|
238447
238454
|
sessionId: r3.session_id,
|
|
238448
238455
|
name: r3.name,
|
|
238449
238456
|
workspace: r3.workspace,
|
|
238450
|
-
surface: r3.surface === "cli" ? "cli" : "app",
|
|
238457
|
+
surface: r3.surface === "cli" ? "cli" : r3.surface === "chrome" ? "chrome" : "app",
|
|
238451
238458
|
busy: r3.busy === 1,
|
|
238452
238459
|
pid: r3.pid
|
|
238453
238460
|
});
|
|
@@ -256754,7 +256761,9 @@ var init_server = __esm({
|
|
|
256754
256761
|
});
|
|
256755
256762
|
const done = () => {
|
|
256756
256763
|
clearTimeout(deadline);
|
|
256764
|
+
if (!this.peers.has(peer)) return;
|
|
256757
256765
|
this.peers.delete(peer);
|
|
256766
|
+
if (peer.hello) this.opts.onPeerGone?.(peer.hello, peer);
|
|
256758
256767
|
this.broadcastStatus();
|
|
256759
256768
|
if (this.peers.size === 0) {
|
|
256760
256769
|
for (const [id, p2] of this.pending) {
|
|
@@ -256775,10 +256784,14 @@ var init_server = __esm({
|
|
|
256775
256784
|
this.log(
|
|
256776
256785
|
`browser connected: ${String(body.browser ?? "chromium")} extension ${String(body.extensionVersion ?? "?")} build ${String(body.buildId ?? "?")}`
|
|
256777
256786
|
);
|
|
256778
|
-
this.opts.onHello?.(peer.hello);
|
|
256787
|
+
this.opts.onHello?.(peer.hello, peer);
|
|
256779
256788
|
this.broadcastStatus();
|
|
256780
256789
|
return;
|
|
256781
256790
|
}
|
|
256791
|
+
if (body.type === "ext-request") {
|
|
256792
|
+
this.serveExtRequest(peer, body);
|
|
256793
|
+
return;
|
|
256794
|
+
}
|
|
256782
256795
|
const id = typeof body.id === "string" ? body.id : null;
|
|
256783
256796
|
if (!id) return;
|
|
256784
256797
|
const waiting = this.pending.get(id);
|
|
@@ -256792,6 +256805,28 @@ var init_server = __esm({
|
|
|
256792
256805
|
);
|
|
256793
256806
|
}
|
|
256794
256807
|
}
|
|
256808
|
+
/**
|
|
256809
|
+
* A request the extension started. Dropped, not answered, from a connection
|
|
256810
|
+
* that has not said hello with protocol 2 — an answer would tell an unknown
|
|
256811
|
+
* peer what this side serves.
|
|
256812
|
+
*/
|
|
256813
|
+
serveExtRequest(peer, body) {
|
|
256814
|
+
const hello = peer.hello;
|
|
256815
|
+
const handler = this.opts.onExtRequest;
|
|
256816
|
+
if (!hello || (hello.protocol ?? 1) < 2 || !handler) return;
|
|
256817
|
+
const id = typeof body.id === "string" ? body.id : null;
|
|
256818
|
+
const op = typeof body.op === "string" ? body.op : null;
|
|
256819
|
+
if (!id || !op) return;
|
|
256820
|
+
const args2 = body.args && typeof body.args === "object" ? body.args : {};
|
|
256821
|
+
const reply = (frame) => {
|
|
256822
|
+
if (!peer.socket.destroyed)
|
|
256823
|
+
peer.socket.write(encodeFrame({ type: "ext-reply", id, ...frame }));
|
|
256824
|
+
};
|
|
256825
|
+
handler(hello, op, args2).then(
|
|
256826
|
+
(result2) => reply({ ok: true, result: result2 ?? null }),
|
|
256827
|
+
(err2) => reply({ ok: false, error: err2 instanceof Error ? err2.message : String(err2) })
|
|
256828
|
+
);
|
|
256829
|
+
}
|
|
256795
256830
|
/** Is a browser connected and has it said hello? */
|
|
256796
256831
|
get connected() {
|
|
256797
256832
|
return [...this.peers].some((p2) => p2.hello !== null);
|
|
@@ -256824,8 +256859,8 @@ var init_server = __esm({
|
|
|
256824
256859
|
* hidden, because a two-browser user whose command lands in the other window
|
|
256825
256860
|
* needs the answer to be findable.
|
|
256826
256861
|
*/
|
|
256827
|
-
async request(op, args2 = {}, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
256828
|
-
const peer = this.newestPeer();
|
|
256862
|
+
async request(op, args2 = {}, timeoutMs = REQUEST_TIMEOUT_MS, target = {}) {
|
|
256863
|
+
const peer = target.profileId ? [...this.peers].filter((p2) => p2.hello?.profileId === target.profileId).sort((a2, b3) => b3.connectedAt - a2.connectedAt)[0] ?? null : this.newestPeer();
|
|
256829
256864
|
if (!peer) {
|
|
256830
256865
|
throw new Error(
|
|
256831
256866
|
"no browser is connected to Atlarix. Open the Atlarix side panel in Chrome, Brave or Edge \u2014 the browser opens this connection, the app cannot open it from this side."
|
|
@@ -257006,6 +257041,104 @@ var init_peer = __esm({
|
|
|
257006
257041
|
}
|
|
257007
257042
|
});
|
|
257008
257043
|
|
|
257044
|
+
// src/lib/peers/chrome-peer.ts
|
|
257045
|
+
function chromeSessionId(profileId) {
|
|
257046
|
+
return `chrome-${profileId.replace(/[^a-z0-9]/gi, "").slice(0, 8).toLowerCase()}`;
|
|
257047
|
+
}
|
|
257048
|
+
function browserLabel(hello) {
|
|
257049
|
+
const b3 = (hello.browser ?? "").toLowerCase();
|
|
257050
|
+
if (b3.includes("brave")) return "Brave";
|
|
257051
|
+
if (b3.includes("edge")) return "Edge";
|
|
257052
|
+
return "Chrome";
|
|
257053
|
+
}
|
|
257054
|
+
function speaksPeers(hello) {
|
|
257055
|
+
return (hello.protocol ?? 1) >= 2 && typeof hello.profileId === "string" && hello.profileId.length >= 8;
|
|
257056
|
+
}
|
|
257057
|
+
function chromePeer(server2) {
|
|
257058
|
+
const connections = /* @__PURE__ */ new Map();
|
|
257059
|
+
const fromOf = (hello) => ({
|
|
257060
|
+
sessionId: chromeSessionId(hello.profileId),
|
|
257061
|
+
name: browserLabel(hello),
|
|
257062
|
+
surface: "chrome",
|
|
257063
|
+
workspace: ""
|
|
257064
|
+
});
|
|
257065
|
+
return {
|
|
257066
|
+
onHello(hello, connection) {
|
|
257067
|
+
if (!speaksPeers(hello)) return;
|
|
257068
|
+
const me2 = fromOf(hello);
|
|
257069
|
+
const { profileId } = hello;
|
|
257070
|
+
const open = connections.get(profileId) ?? /* @__PURE__ */ new Set();
|
|
257071
|
+
open.add(connection);
|
|
257072
|
+
connections.set(profileId, open);
|
|
257073
|
+
noteLiveSession({
|
|
257074
|
+
sessionId: me2.sessionId,
|
|
257075
|
+
chatId: -1,
|
|
257076
|
+
name: me2.name,
|
|
257077
|
+
workspace: "",
|
|
257078
|
+
surface: "chrome",
|
|
257079
|
+
deliver: async (id, from, text3) => {
|
|
257080
|
+
const bridge2 = server2();
|
|
257081
|
+
if (!bridge2) return { ok: false, error: "the browser is not connected" };
|
|
257082
|
+
await bridge2.request(
|
|
257083
|
+
"peer_deliver",
|
|
257084
|
+
{ id, from, text: text3 },
|
|
257085
|
+
DELIVER_TIMEOUT_MS,
|
|
257086
|
+
{ profileId }
|
|
257087
|
+
);
|
|
257088
|
+
return { ok: true };
|
|
257089
|
+
}
|
|
257090
|
+
});
|
|
257091
|
+
},
|
|
257092
|
+
onPeerGone(hello, connection) {
|
|
257093
|
+
if (!speaksPeers(hello)) return;
|
|
257094
|
+
const open = connections.get(hello.profileId);
|
|
257095
|
+
open?.delete(connection);
|
|
257096
|
+
if (open && open.size > 0) return;
|
|
257097
|
+
connections.delete(hello.profileId);
|
|
257098
|
+
forgetLiveSession(chromeSessionId(hello.profileId));
|
|
257099
|
+
},
|
|
257100
|
+
async onExtRequest(hello, op, args2) {
|
|
257101
|
+
if (!speaksPeers(hello)) throw new Error("this browser has not identified itself");
|
|
257102
|
+
const me0 = fromOf(hello);
|
|
257103
|
+
if (op === "peer_list") {
|
|
257104
|
+
return {
|
|
257105
|
+
sessions: listPeerSessions(me0.sessionId).filter((r3) => r3.surface !== "chrome").map((r3) => ({
|
|
257106
|
+
sessionId: r3.sessionId,
|
|
257107
|
+
name: r3.name,
|
|
257108
|
+
surface: r3.surface,
|
|
257109
|
+
workspace: r3.workspace.split(/[\\/]/).filter(Boolean).pop() ?? "",
|
|
257110
|
+
busy: r3.busy
|
|
257111
|
+
}))
|
|
257112
|
+
};
|
|
257113
|
+
}
|
|
257114
|
+
if (op !== "peer_send") throw new Error(`the desktop does not serve "${op}"`);
|
|
257115
|
+
const to2 = typeof args2.to === "string" ? args2.to.trim() : "";
|
|
257116
|
+
const text3 = typeof args2.text === "string" ? args2.text.trim() : "";
|
|
257117
|
+
if (!to2) throw new Error("say which session to send to");
|
|
257118
|
+
if (!text3) throw new Error("the message is empty");
|
|
257119
|
+
if (text3.length > PEER_TEXT_CAP) {
|
|
257120
|
+
throw new Error(`the message is over ${PEER_TEXT_CAP} characters`);
|
|
257121
|
+
}
|
|
257122
|
+
const me2 = fromOf(hello);
|
|
257123
|
+
const target = resolvePeer(to2, me2.sessionId);
|
|
257124
|
+
if ("error" in target) throw new Error(target.error);
|
|
257125
|
+
const result2 = await sendPeerMessage(target.row, me2, text3);
|
|
257126
|
+
if (!result2.ok) throw new Error(result2.error ?? "not delivered");
|
|
257127
|
+
logger43.info(`${me2.name} replied to ${target.row.name}`);
|
|
257128
|
+
return { sent: true, to: target.row.name };
|
|
257129
|
+
}
|
|
257130
|
+
};
|
|
257131
|
+
}
|
|
257132
|
+
var import_electron_log47, logger43, DELIVER_TIMEOUT_MS;
|
|
257133
|
+
var init_chrome_peer = __esm({
|
|
257134
|
+
"src/lib/peers/chrome-peer.ts"() {
|
|
257135
|
+
import_electron_log47 = __toESM(require_src());
|
|
257136
|
+
init_peers();
|
|
257137
|
+
logger43 = import_electron_log47.default.scope("peers");
|
|
257138
|
+
DELIVER_TIMEOUT_MS = 1e4;
|
|
257139
|
+
}
|
|
257140
|
+
});
|
|
257141
|
+
|
|
257009
257142
|
// src/lib/bridge/host-install.ts
|
|
257010
257143
|
import { execFile as execFile6 } from "node:child_process";
|
|
257011
257144
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -257278,21 +257411,29 @@ async function startBridge(opts = {}) {
|
|
|
257278
257411
|
stopping = false;
|
|
257279
257412
|
const relayPath = opts.relayPath !== void 0 ? opts.relayPath : resolveRelayPath();
|
|
257280
257413
|
if (!relayPath && !nativeHostInstalled()) {
|
|
257281
|
-
|
|
257414
|
+
logger44.info(
|
|
257282
257415
|
"no relay binary in this build \u2014 the browser bridge is unavailable. Build it with `cargo build --release` in native/atlarix-bridge."
|
|
257283
257416
|
);
|
|
257284
257417
|
return;
|
|
257285
257418
|
}
|
|
257286
257419
|
const socketPath = bridgeSocketPath();
|
|
257287
257420
|
try {
|
|
257421
|
+
let hosted = null;
|
|
257422
|
+
const browserSession = chromePeer(() => hosted);
|
|
257288
257423
|
const next = new BridgeServer({
|
|
257289
257424
|
socketPath,
|
|
257290
257425
|
peersSocketPath: peersSocketPath(socketPath),
|
|
257291
|
-
onLog: (message) =>
|
|
257292
|
-
onHello: (hello) =>
|
|
257293
|
-
|
|
257294
|
-
|
|
257426
|
+
onLog: (message) => logger44.info(message),
|
|
257427
|
+
onHello: (hello, connection) => {
|
|
257428
|
+
logger44.info(
|
|
257429
|
+
`browser attached: ${hello.browser ?? "chromium"} extension ${hello.extensionVersion ?? "?"} build ${hello.buildId ?? "?"}`
|
|
257430
|
+
);
|
|
257431
|
+
browserSession.onHello(hello, connection);
|
|
257432
|
+
},
|
|
257433
|
+
onPeerGone: (hello, connection) => browserSession.onPeerGone(hello, connection),
|
|
257434
|
+
onExtRequest: (hello, op, args2) => browserSession.onExtRequest(hello, op, args2)
|
|
257295
257435
|
});
|
|
257436
|
+
hosted = next;
|
|
257296
257437
|
await next.listen();
|
|
257297
257438
|
endpoint = next;
|
|
257298
257439
|
role = "host";
|
|
@@ -257301,20 +257442,20 @@ async function startBridge(opts = {}) {
|
|
|
257301
257442
|
await joinAsPeer(socketPath);
|
|
257302
257443
|
return;
|
|
257303
257444
|
}
|
|
257304
|
-
|
|
257445
|
+
logger44.warn(`bridge not listening: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
257305
257446
|
return;
|
|
257306
257447
|
}
|
|
257307
257448
|
if (!relayPath || opts.installHost === "if-missing" && nativeHostInstalled()) return;
|
|
257308
257449
|
try {
|
|
257309
257450
|
const install = await installNativeHost({ relayPath, socketPath });
|
|
257310
|
-
|
|
257451
|
+
logger44.info(
|
|
257311
257452
|
`native host installed for ${install.manifests.length} browser profile(s)` + (install.registryKeys ? `, ${install.registryKeys.length} registry key(s)` : "")
|
|
257312
257453
|
);
|
|
257313
257454
|
for (const { dir, reason } of install.skipped) {
|
|
257314
|
-
|
|
257455
|
+
logger44.warn(`could not write ${dir}: ${reason}`);
|
|
257315
257456
|
}
|
|
257316
257457
|
} catch (err2) {
|
|
257317
|
-
|
|
257458
|
+
logger44.warn(
|
|
257318
257459
|
`native host not installed: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
257319
257460
|
);
|
|
257320
257461
|
}
|
|
@@ -257322,7 +257463,7 @@ async function startBridge(opts = {}) {
|
|
|
257322
257463
|
async function joinAsPeer(socketPath) {
|
|
257323
257464
|
const peer = new BridgePeer({
|
|
257324
257465
|
socketPath: peersSocketPath(socketPath),
|
|
257325
|
-
onLog: (message) =>
|
|
257466
|
+
onLog: (message) => logger44.info(message),
|
|
257326
257467
|
// The host quit: one of its peers takes the main socket. The jitter keeps
|
|
257327
257468
|
// two peers from racing for it; the loser finds it live and joins as a peer.
|
|
257328
257469
|
onHostGone: () => {
|
|
@@ -257334,7 +257475,7 @@ async function joinAsPeer(socketPath) {
|
|
|
257334
257475
|
try {
|
|
257335
257476
|
await peer.connect();
|
|
257336
257477
|
} catch (err2) {
|
|
257337
|
-
|
|
257478
|
+
logger44.warn(
|
|
257338
257479
|
`another Atlarix holds the browser and does not share it (${err2 instanceof Error ? err2.message : String(err2)}) \u2014 retrying later`
|
|
257339
257480
|
);
|
|
257340
257481
|
scheduleRetry(3e4);
|
|
@@ -257342,7 +257483,7 @@ async function joinAsPeer(socketPath) {
|
|
|
257342
257483
|
}
|
|
257343
257484
|
endpoint = peer;
|
|
257344
257485
|
role = "peer";
|
|
257345
|
-
|
|
257486
|
+
logger44.info("using the browser through the Atlarix that hosts it");
|
|
257346
257487
|
}
|
|
257347
257488
|
async function stopBridge() {
|
|
257348
257489
|
stopping = true;
|
|
@@ -257353,14 +257494,15 @@ async function stopBridge() {
|
|
|
257353
257494
|
role = null;
|
|
257354
257495
|
await current?.close?.();
|
|
257355
257496
|
}
|
|
257356
|
-
var
|
|
257497
|
+
var import_electron_log48, logger44, endpoint, role, retryTimer, startOptions, stopping;
|
|
257357
257498
|
var init_bridge_lifecycle = __esm({
|
|
257358
257499
|
"src/main/bridge-lifecycle.ts"() {
|
|
257359
|
-
|
|
257500
|
+
import_electron_log48 = __toESM(require_src());
|
|
257360
257501
|
init_server();
|
|
257361
257502
|
init_peer();
|
|
257503
|
+
init_chrome_peer();
|
|
257362
257504
|
init_host_install();
|
|
257363
|
-
|
|
257505
|
+
logger44 = import_electron_log48.default.scope("bridge");
|
|
257364
257506
|
endpoint = null;
|
|
257365
257507
|
role = null;
|
|
257366
257508
|
retryTimer = null;
|
|
@@ -257386,7 +257528,7 @@ async function chromeSearch(query, limit = 10) {
|
|
|
257386
257528
|
try {
|
|
257387
257529
|
const res = await endpoint2.request("search", { query, max: limit }, SEARCH_TIMEOUT_MS);
|
|
257388
257530
|
const rows = res.results ?? [];
|
|
257389
|
-
if (res.challenged)
|
|
257531
|
+
if (res.challenged) logger45.info(`chrome search for "${query}" was challenged by the engines`);
|
|
257390
257532
|
return rows.map((r3, i4) => ({
|
|
257391
257533
|
title: r3.title,
|
|
257392
257534
|
url: r3.url,
|
|
@@ -257395,15 +257537,15 @@ async function chromeSearch(query, limit = 10) {
|
|
|
257395
257537
|
source: `chrome:${res.engine ?? "?"}`
|
|
257396
257538
|
}));
|
|
257397
257539
|
} catch (e3) {
|
|
257398
|
-
|
|
257540
|
+
logger45.info(`chrome search unavailable: ${e3 instanceof Error ? e3.message : String(e3)}`);
|
|
257399
257541
|
return [];
|
|
257400
257542
|
}
|
|
257401
257543
|
}
|
|
257402
|
-
var
|
|
257544
|
+
var import_electron_log49, logger45, SEARCH_TIMEOUT_MS;
|
|
257403
257545
|
var init_chrome_search = __esm({
|
|
257404
257546
|
"src/lib/search/chrome-search.ts"() {
|
|
257405
|
-
|
|
257406
|
-
|
|
257547
|
+
import_electron_log49 = __toESM(require_src());
|
|
257548
|
+
logger45 = import_electron_log49.default.scope("chrome-search");
|
|
257407
257549
|
SEARCH_TIMEOUT_MS = 45e3;
|
|
257408
257550
|
}
|
|
257409
257551
|
});
|
|
@@ -276120,7 +276262,7 @@ function normalizeToolInputSchemaForAiSdk(schema) {
|
|
|
276120
276262
|
useReferences: true
|
|
276121
276263
|
});
|
|
276122
276264
|
} catch (e3) {
|
|
276123
|
-
|
|
276265
|
+
logger46.warn(
|
|
276124
276266
|
"Tool input Zod schema could not be wrapped for AI SDK; using permissive schema:",
|
|
276125
276267
|
e3
|
|
276126
276268
|
);
|
|
@@ -276138,12 +276280,12 @@ function normalizeToolInputSchemaForAiSdk(schema) {
|
|
|
276138
276280
|
}
|
|
276139
276281
|
return jsonSchema(PERMISSIVE_TOOL_JSON_SCHEMA);
|
|
276140
276282
|
}
|
|
276141
|
-
var
|
|
276283
|
+
var import_electron_log50, logger46, PERMISSIVE_TOOL_JSON_SCHEMA;
|
|
276142
276284
|
var init_normalize_tool_schema = __esm({
|
|
276143
276285
|
"src/lib/ai/normalize-tool-schema.ts"() {
|
|
276144
276286
|
init_dist21();
|
|
276145
|
-
|
|
276146
|
-
|
|
276287
|
+
import_electron_log50 = __toESM(require_src());
|
|
276288
|
+
logger46 = import_electron_log50.default.scope("normalize-tool-schema");
|
|
276147
276289
|
PERMISSIVE_TOOL_JSON_SCHEMA = {
|
|
276148
276290
|
type: "object",
|
|
276149
276291
|
properties: {},
|
|
@@ -277834,7 +277976,7 @@ function userAgentsDir(workspacePath) {
|
|
|
277834
277976
|
function toUserAgent(name29, raw) {
|
|
277835
277977
|
const { data, body } = parseFrontmatter(raw);
|
|
277836
277978
|
if (!body.trim()) {
|
|
277837
|
-
|
|
277979
|
+
logger47.warn(`User agent "${name29}" has no system-prompt body \u2014 skipped`);
|
|
277838
277980
|
return null;
|
|
277839
277981
|
}
|
|
277840
277982
|
const modeRaw = typeof data.mode === "string" ? data.mode : "build";
|
|
@@ -277868,7 +278010,7 @@ function listUserAgents(workspacePath) {
|
|
|
277868
278010
|
);
|
|
277869
278011
|
if (agent) byName.set(agent.name, agent);
|
|
277870
278012
|
} catch (e3) {
|
|
277871
|
-
|
|
278013
|
+
logger47.warn(`Failed to read user agent ${entry}: ${String(e3)}`);
|
|
277872
278014
|
}
|
|
277873
278015
|
}
|
|
277874
278016
|
return [...byName.values()].sort((a2, b3) => a2.name.localeCompare(b3.name));
|
|
@@ -277915,12 +278057,12 @@ function renderUserAgentSystemBlock(agent) {
|
|
|
277915
278057
|
agent.systemPrompt
|
|
277916
278058
|
].filter(Boolean).join("\n");
|
|
277917
278059
|
}
|
|
277918
|
-
var
|
|
278060
|
+
var import_electron_log51, logger47, RESERVED_AGENT_NAMES, VALID_MODES, BUILTIN_AGENT_ALIASES;
|
|
277919
278061
|
var init_user_agents = __esm({
|
|
277920
278062
|
"src/lib/agents/user-agents.ts"() {
|
|
277921
|
-
|
|
278063
|
+
import_electron_log51 = __toESM(require_src());
|
|
277922
278064
|
init_builtin_agents();
|
|
277923
|
-
|
|
278065
|
+
logger47 = import_electron_log51.default.scope("user-agents");
|
|
277924
278066
|
RESERVED_AGENT_NAMES = /* @__PURE__ */ new Set([
|
|
277925
278067
|
"ask-mode",
|
|
277926
278068
|
"plan-mode",
|
|
@@ -278046,7 +278188,7 @@ async function runSubagent(args2) {
|
|
|
278046
278188
|
${formatSmallRepoInventory(paths)}`;
|
|
278047
278189
|
}
|
|
278048
278190
|
} catch (invErr) {
|
|
278049
|
-
|
|
278191
|
+
logger48.debug("[Subagent] workspace inventory skipped:", invErr);
|
|
278050
278192
|
}
|
|
278051
278193
|
}
|
|
278052
278194
|
const allowed = new Set(
|
|
@@ -278170,7 +278312,7 @@ ${formatSmallRepoInventory(paths)}`;
|
|
|
278170
278312
|
try {
|
|
278171
278313
|
tierLimit = (await resolveModelContextLimit(effectiveModel, settings)).tierLimit;
|
|
278172
278314
|
} catch (e3) {
|
|
278173
|
-
|
|
278315
|
+
logger48.warn("[Subagent] tier-limit resolve failed; generic fallback:", e3);
|
|
278174
278316
|
}
|
|
278175
278317
|
const systemEstimate = estimateTokens(systemPrompt);
|
|
278176
278318
|
const cacheMarkerPlacement = resolveCacheMarkerPlacement(
|
|
@@ -278277,8 +278419,8 @@ ${formatSmallRepoInventory(paths)}`;
|
|
|
278277
278419
|
tierLimit,
|
|
278278
278420
|
chatId: args2.chatId ?? 0,
|
|
278279
278421
|
loopLabel: "Subagent",
|
|
278280
|
-
onInfo: (msg) =>
|
|
278281
|
-
onWarn: (msg, err2) =>
|
|
278422
|
+
onInfo: (msg) => logger48.log(msg),
|
|
278423
|
+
onWarn: (msg, err2) => logger48.warn(msg, err2)
|
|
278282
278424
|
});
|
|
278283
278425
|
if (compaction.compacted) msgs = compaction.messages;
|
|
278284
278426
|
result2 = await runRound();
|
|
@@ -278315,7 +278457,7 @@ ${formatSmallRepoInventory(paths)}`;
|
|
|
278315
278457
|
\u2014 Tools used: ${uniqTools.join(", ")}` : "";
|
|
278316
278458
|
const tokensFooter = subagentTokens > 0 ? `
|
|
278317
278459
|
\u2014 ${anyRoundEstimated ? "~" : ""}${formatCompactTokens(subagentTokens)} tokens` : "";
|
|
278318
|
-
|
|
278460
|
+
logger48.info(
|
|
278319
278461
|
`Subagent run complete (id=${delegationId}); steps=${totalSteps}; tokens=${subagentTokens}`
|
|
278320
278462
|
);
|
|
278321
278463
|
return {
|
|
@@ -278325,7 +278467,7 @@ ${formatSmallRepoInventory(paths)}`;
|
|
|
278325
278467
|
tokensUsed: subagentTokens
|
|
278326
278468
|
};
|
|
278327
278469
|
} catch (err2) {
|
|
278328
|
-
|
|
278470
|
+
logger48.error(`runSubagent failed (id=${delegationId}):`, err2);
|
|
278329
278471
|
if (isInsufficientCreditError(err2)) {
|
|
278330
278472
|
const message = coreExhaustedUserMessage(requiredCentsFromError(err2));
|
|
278331
278473
|
markCreditExhausted(args2.chatId, message);
|
|
@@ -278337,11 +278479,11 @@ ${formatSmallRepoInventory(paths)}`;
|
|
|
278337
278479
|
};
|
|
278338
278480
|
}
|
|
278339
278481
|
}
|
|
278340
|
-
var
|
|
278482
|
+
var import_electron_log52, logger48, SUBAGENT_LENGTH_CONTINUATION_MAX, SUBAGENT_TOOL_NAMES, WRITER_SUBAGENT_TOOL_NAMES, SUBAGENT_NESTED_EXPAND_TOOLS, THOUGHT_EMIT_INTERVAL_MS, THOUGHT_SEGMENT_CHAR_CAP;
|
|
278341
278483
|
var init_run_subagent = __esm({
|
|
278342
278484
|
"src/lib/agents/run-subagent.ts"() {
|
|
278343
278485
|
init_dist21();
|
|
278344
|
-
|
|
278486
|
+
import_electron_log52 = __toESM(require_src());
|
|
278345
278487
|
init_anthropic_cache_breakpoints();
|
|
278346
278488
|
init_normalize_tool_schema();
|
|
278347
278489
|
init_continuation_handler();
|
|
@@ -278361,7 +278503,7 @@ var init_run_subagent = __esm({
|
|
|
278361
278503
|
init_workspace_file_hints();
|
|
278362
278504
|
init_user_agents();
|
|
278363
278505
|
init_subagent_proposals();
|
|
278364
|
-
|
|
278506
|
+
logger48 = import_electron_log52.default.scope("run-subagent");
|
|
278365
278507
|
SUBAGENT_LENGTH_CONTINUATION_MAX = 3;
|
|
278366
278508
|
SUBAGENT_TOOL_NAMES = [
|
|
278367
278509
|
"read_file",
|
|
@@ -287906,16 +288048,16 @@ ${matrixToCsv(matrix)}
|
|
|
287906
288048
|
sheetName: first2?.sheet
|
|
287907
288049
|
};
|
|
287908
288050
|
} catch (err2) {
|
|
287909
|
-
|
|
288051
|
+
logger49.warn(`xlsx failed: ${err2}`);
|
|
287910
288052
|
return { text: "", sheets: 0, rows: 0, success: false, table: null };
|
|
287911
288053
|
}
|
|
287912
288054
|
}
|
|
287913
|
-
var
|
|
288055
|
+
var import_electron_log53, logger49;
|
|
287914
288056
|
var init_attachment_xlsx_extract = __esm({
|
|
287915
288057
|
"src/lib/attachment-xlsx-extract.ts"() {
|
|
287916
|
-
|
|
288058
|
+
import_electron_log53 = __toESM(require_src());
|
|
287917
288059
|
init_attachment_csv_extract();
|
|
287918
|
-
|
|
288060
|
+
logger49 = import_electron_log53.default.scope("attachment-xlsx");
|
|
287919
288061
|
}
|
|
287920
288062
|
});
|
|
287921
288063
|
|
|
@@ -318982,7 +319124,7 @@ async function forceCompactEphemeralChat(chatId, providerId) {
|
|
|
318982
319124
|
content: m3.content || "",
|
|
318983
319125
|
createdAt: /* @__PURE__ */ new Date()
|
|
318984
319126
|
}));
|
|
318985
|
-
|
|
319127
|
+
logger50.info(
|
|
318986
319128
|
`[compaction] Forced overflow compaction freed ~${stepped.tokensFreed} tokens (chat ${chatId})`
|
|
318987
319129
|
);
|
|
318988
319130
|
return true;
|
|
@@ -319054,7 +319196,7 @@ async function extractTextFromDocx(buffer) {
|
|
|
319054
319196
|
success: Boolean(result2.value && result2.value.trim().length > 0)
|
|
319055
319197
|
};
|
|
319056
319198
|
} catch (err2) {
|
|
319057
|
-
|
|
319199
|
+
logger50.warn(`mammoth failed: ${err2}`);
|
|
319058
319200
|
return { text: "", paragraphs: 0, success: false };
|
|
319059
319201
|
}
|
|
319060
319202
|
}
|
|
@@ -319110,7 +319252,7 @@ function extractStructuredData(attachment) {
|
|
|
319110
319252
|
charCount: text3.length
|
|
319111
319253
|
};
|
|
319112
319254
|
} catch (err2) {
|
|
319113
|
-
|
|
319255
|
+
logger50.warn(`Failed to parse text file ${attachment.filename}:`, err2);
|
|
319114
319256
|
return {
|
|
319115
319257
|
type: "text",
|
|
319116
319258
|
filename: attachment.filename,
|
|
@@ -319152,7 +319294,7 @@ function extractStructuredData(attachment) {
|
|
|
319152
319294
|
};
|
|
319153
319295
|
if (ext === ".pdf") {
|
|
319154
319296
|
if (attachment.pdfExtract) {
|
|
319155
|
-
|
|
319297
|
+
logger50.info(`read_attachment PDF cache hit: ${attachment.filename}`);
|
|
319156
319298
|
const result2 = attachment.pdfExtract;
|
|
319157
319299
|
return {
|
|
319158
319300
|
type: "document",
|
|
@@ -319383,7 +319525,7 @@ function pageAttachmentText(full, offsetParam, limitParam) {
|
|
|
319383
319525
|
hasMore: end < totalLines
|
|
319384
319526
|
};
|
|
319385
319527
|
}
|
|
319386
|
-
var
|
|
319528
|
+
var import_electron_log54, logger50, SUPPORTED_IMAGE_EXTENSIONS, SUPPORTED_DOCUMENT_EXTENSIONS, READ_ATTACHMENT_DEFAULT_LINES, READ_ATTACHMENT_MAX_LINES, READ_ATTACHMENT_MAX_BYTES;
|
|
319387
319529
|
var init_workspace = __esm({
|
|
319388
319530
|
"src/lib/tools/workspace.ts"() {
|
|
319389
319531
|
init_registry();
|
|
@@ -319396,9 +319538,9 @@ var init_workspace = __esm({
|
|
|
319396
319538
|
init_token_utils();
|
|
319397
319539
|
init_compaction();
|
|
319398
319540
|
init_attachment_store();
|
|
319399
|
-
|
|
319541
|
+
import_electron_log54 = __toESM(require_src());
|
|
319400
319542
|
init_ask_user_options();
|
|
319401
|
-
|
|
319543
|
+
logger50 = import_electron_log54.default.scope("workspace-tools");
|
|
319402
319544
|
ToolRegistry.register({
|
|
319403
319545
|
name: "ask_user",
|
|
319404
319546
|
description: "Ask the user one or more questions \u2014 YOUR TURN ENDS after asking. The user answers asynchronously and their answers arrive as the next user message, where you continue the task (or ask follow-ups). Because the turn ends, batch ALL questions you need into ONE call via `questions` (max 5, each with up to 4 `options`) \u2014 ask everything up front, never one at a time. A single `question` + `options` also works. The UI shows option buttons plus a free-text field per question.",
|
|
@@ -319626,7 +319768,7 @@ var init_workspace = __esm({
|
|
|
319626
319768
|
}
|
|
319627
319769
|
};
|
|
319628
319770
|
if (uniqueIds.length === 1) {
|
|
319629
|
-
|
|
319771
|
+
logger50.log(`read_attachment called with id: ${uniqueIds[0]}`);
|
|
319630
319772
|
const one = await readOne(uniqueIds[0]);
|
|
319631
319773
|
if (!one.success) {
|
|
319632
319774
|
return {
|
|
@@ -320153,7 +320295,7 @@ async function updateStep(args2) {
|
|
|
320153
320295
|
);
|
|
320154
320296
|
if (!result2.step) {
|
|
320155
320297
|
const steps2 = parsePlanChecklist(row.content);
|
|
320156
|
-
|
|
320298
|
+
logger51.warn(
|
|
320157
320299
|
`[plan] update_step found no match in plan ${planId} \u2014 step_index=${args2.step_index ?? "none"} step_text=${JSON.stringify(args2.step_text ?? null)} (${steps2.length} step(s) in plan)`
|
|
320158
320300
|
);
|
|
320159
320301
|
return {
|
|
@@ -320191,7 +320333,7 @@ async function updateStep(args2) {
|
|
|
320191
320333
|
(s3) => isActionableStepState(s3.state)
|
|
320192
320334
|
).length;
|
|
320193
320335
|
if (args2.state === "external") {
|
|
320194
|
-
|
|
320336
|
+
logger51.info(
|
|
320195
320337
|
`[plan] step ${result2.step?.index ?? "?"} marked EXTERNAL in plan ${planId} \u2014 reason=${JSON.stringify(externalReason ?? null)} (${actionable} actionable step(s) left)`
|
|
320196
320338
|
);
|
|
320197
320339
|
}
|
|
@@ -320249,17 +320391,17 @@ async function appendStep(args2) {
|
|
|
320249
320391
|
message: "Step appended."
|
|
320250
320392
|
};
|
|
320251
320393
|
}
|
|
320252
|
-
var
|
|
320394
|
+
var import_electron_log55, logger51, NO_SESSION_ERROR;
|
|
320253
320395
|
var init_plan = __esm({
|
|
320254
320396
|
"src/lib/tools/plan.ts"() {
|
|
320255
320397
|
init_registry();
|
|
320256
320398
|
init_plan_artifacts();
|
|
320257
320399
|
init_plan_checklist();
|
|
320258
|
-
|
|
320400
|
+
import_electron_log55 = __toESM(require_src());
|
|
320259
320401
|
init_emit_plan_artifact();
|
|
320260
320402
|
init_plan_ledger_refresh();
|
|
320261
320403
|
init_workspace_session_handlers();
|
|
320262
|
-
|
|
320404
|
+
logger51 = import_electron_log55.default.scope("plan-tool");
|
|
320263
320405
|
NO_SESSION_ERROR = "No workspace session for this chat \u2014 start a new chat in this workspace and retry.";
|
|
320264
320406
|
ToolRegistry.register({
|
|
320265
320407
|
name: "plan",
|
|
@@ -320427,7 +320569,7 @@ import { randomUUID as randomUUID7 } from "node:crypto";
|
|
|
320427
320569
|
function createID() {
|
|
320428
320570
|
return randomUUID7();
|
|
320429
320571
|
}
|
|
320430
|
-
function
|
|
320572
|
+
function log56(level, message, extra) {
|
|
320431
320573
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
320432
320574
|
const color = levelColors[level];
|
|
320433
320575
|
const prefix = `[${timestamp}] [PID: ${process.pid}] ${GREEN}[NODE-CRON]${GREEN} ${color}[${level}]${RESET}`;
|
|
@@ -320735,7 +320877,7 @@ function safeEmit(emitter, event, context, onError) {
|
|
|
320735
320877
|
}
|
|
320736
320878
|
}
|
|
320737
320879
|
}
|
|
320738
|
-
var levelColors, GREEN, RESET, defaultLogger, activeLogger,
|
|
320880
|
+
var levelColors, GREEN, RESET, defaultLogger, activeLogger, logger52, TrackedPromise, DEFAULT_MISSED_EXECUTION_TOLERANCE, DEFAULT_COORDINATOR_TTL, Runner, monthNamesConversion, weekDayNamesConversion, convertAsterisksToRanges, convertRanges, NICKNAMES, convertExpression, LocalizedTime, partsFormatterCache, offsetFormatterCache, LAST_DAY_TOKEN, WEEKDAY_TOKEN, LAST_DAY_OFFSET_TOKEN, LAST_WEEKDAY_REGEX, NTH_WEEKDAY_REGEX, MAX_DAYS, MatcherWalker, TimeMatcher, allowedTransitions, StateMachine, EnvVarRunCoordinator, globalRunCoordinator, TaskEmitter, InlineScheduledTask;
|
|
320739
320881
|
var init_shared = __esm({
|
|
320740
320882
|
"node_modules/node-cron/dist/_shared.js"() {
|
|
320741
320883
|
levelColors = {
|
|
@@ -320748,28 +320890,28 @@ var init_shared = __esm({
|
|
|
320748
320890
|
RESET = "\x1B[0m";
|
|
320749
320891
|
defaultLogger = {
|
|
320750
320892
|
info(message) {
|
|
320751
|
-
|
|
320893
|
+
log56("INFO", message);
|
|
320752
320894
|
},
|
|
320753
320895
|
warn(message) {
|
|
320754
|
-
|
|
320896
|
+
log56("WARN", message);
|
|
320755
320897
|
},
|
|
320756
320898
|
error(message, err2) {
|
|
320757
320899
|
if (message instanceof Error) {
|
|
320758
|
-
|
|
320900
|
+
log56("ERROR", message.message, message);
|
|
320759
320901
|
} else {
|
|
320760
|
-
|
|
320902
|
+
log56("ERROR", message, err2);
|
|
320761
320903
|
}
|
|
320762
320904
|
},
|
|
320763
320905
|
debug(message, err2) {
|
|
320764
320906
|
if (message instanceof Error) {
|
|
320765
|
-
|
|
320907
|
+
log56("DEBUG", message.message, message);
|
|
320766
320908
|
} else {
|
|
320767
|
-
|
|
320909
|
+
log56("DEBUG", message, err2);
|
|
320768
320910
|
}
|
|
320769
320911
|
}
|
|
320770
320912
|
};
|
|
320771
320913
|
activeLogger = defaultLogger;
|
|
320772
|
-
|
|
320914
|
+
logger52 = {
|
|
320773
320915
|
info: (message) => activeLogger.info(message),
|
|
320774
320916
|
warn: (message) => activeLogger.warn(message),
|
|
320775
320917
|
error: (message, err2) => activeLogger.error(message, err2),
|
|
@@ -320857,7 +320999,7 @@ var init_shared = __esm({
|
|
|
320857
320999
|
this.maxExecutions = options?.maxExecutions;
|
|
320858
321000
|
this.maxRandomDelay = options?.maxRandomDelay || 0;
|
|
320859
321001
|
this.missedExecutionTolerance = options?.missedExecutionTolerance ?? DEFAULT_MISSED_EXECUTION_TOLERANCE;
|
|
320860
|
-
this.logger = options?.logger ||
|
|
321002
|
+
this.logger = options?.logger || logger52;
|
|
320861
321003
|
this.onMissedExecution = options?.onMissedExecution || emptyOnFn;
|
|
320862
321004
|
this.onOverlap = options?.onOverlap || emptyOnFn;
|
|
320863
321005
|
this.onError = options?.onError || ((date6, error51) => this.logger.error("Task failed with error!", error51));
|
|
@@ -321446,7 +321588,7 @@ var init_shared = __esm({
|
|
|
321446
321588
|
this.id = createID();
|
|
321447
321589
|
this.name = options?.name || this.id;
|
|
321448
321590
|
this.timezone = options?.timezone;
|
|
321449
|
-
this.logger = options?.logger ||
|
|
321591
|
+
this.logger = options?.logger || logger52;
|
|
321450
321592
|
this.suppressMissedWarning = options?.suppressMissedWarning || false;
|
|
321451
321593
|
this.timeMatcher = new TimeMatcher(cronExpression, options?.timezone);
|
|
321452
321594
|
this.stateMachine = new StateMachine();
|
|
@@ -321811,7 +321953,7 @@ function schedule(expression, func, options) {
|
|
|
321811
321953
|
}
|
|
321812
321954
|
if (started && typeof started.catch === "function") {
|
|
321813
321955
|
started.catch((error51) => {
|
|
321814
|
-
(options?.logger ||
|
|
321956
|
+
(options?.logger || logger52).error(`Failed to start scheduled task: ${error51?.message ?? error51}`);
|
|
321815
321957
|
});
|
|
321816
321958
|
}
|
|
321817
321959
|
return task;
|
|
@@ -321968,7 +322110,7 @@ var init_node_cron = __esm({
|
|
|
321968
322110
|
this.currentExecution = void 0;
|
|
321969
322111
|
this.recordLastRun(context.execution);
|
|
321970
322112
|
});
|
|
321971
|
-
this.logger = options?.logger ||
|
|
322113
|
+
this.logger = options?.logger || logger52;
|
|
321972
322114
|
this.suppressMissedWarning = options?.suppressMissedWarning || false;
|
|
321973
322115
|
this.runCoordinator = options?.distributed ? resolveRunCoordinator(options?.runCoordinator) : void 0;
|
|
321974
322116
|
this.on("task:stopped", () => {
|
|
@@ -322421,20 +322563,20 @@ async function showDesktopNotification(options) {
|
|
|
322421
322563
|
try {
|
|
322422
322564
|
options.onClick?.();
|
|
322423
322565
|
} catch (e3) {
|
|
322424
|
-
|
|
322566
|
+
logger53.warn("notification click handler threw:", e3);
|
|
322425
322567
|
}
|
|
322426
322568
|
});
|
|
322427
322569
|
}
|
|
322428
322570
|
notification.show();
|
|
322429
322571
|
} catch (e3) {
|
|
322430
|
-
|
|
322572
|
+
logger53.warn("desktop notification failed:", e3);
|
|
322431
322573
|
}
|
|
322432
322574
|
}
|
|
322433
|
-
var
|
|
322575
|
+
var import_electron_log56, logger53, live;
|
|
322434
322576
|
var init_desktop_notification = __esm({
|
|
322435
322577
|
"src/main/desktop-notification.ts"() {
|
|
322436
|
-
|
|
322437
|
-
|
|
322578
|
+
import_electron_log56 = __toESM(require_src());
|
|
322579
|
+
logger53 = import_electron_log56.default.scope("notification");
|
|
322438
322580
|
live = /* @__PURE__ */ new Set();
|
|
322439
322581
|
}
|
|
322440
322582
|
});
|
|
@@ -322460,16 +322602,16 @@ async function showAgentNotification(title, body) {
|
|
|
322460
322602
|
}
|
|
322461
322603
|
});
|
|
322462
322604
|
} catch (e3) {
|
|
322463
|
-
|
|
322605
|
+
logger54.warn("agent OS notification failed:", e3);
|
|
322464
322606
|
}
|
|
322465
322607
|
}
|
|
322466
|
-
var
|
|
322608
|
+
var import_electron_log57, logger54;
|
|
322467
322609
|
var init_agent_notification = __esm({
|
|
322468
322610
|
"src/main/agent-notification.ts"() {
|
|
322469
|
-
|
|
322611
|
+
import_electron_log57 = __toESM(require_src());
|
|
322470
322612
|
init_settings();
|
|
322471
322613
|
init_desktop_notification();
|
|
322472
|
-
|
|
322614
|
+
logger54 = import_electron_log57.default.scope("agent-notification");
|
|
322473
322615
|
}
|
|
322474
322616
|
});
|
|
322475
322617
|
|
|
@@ -322493,16 +322635,16 @@ function persistPermissionPreferenceSafely(label, fn2) {
|
|
|
322493
322635
|
try {
|
|
322494
322636
|
fn2();
|
|
322495
322637
|
} catch (e3) {
|
|
322496
|
-
|
|
322638
|
+
logger55.warn(`${label} failed (approval still proceeds):`, e3);
|
|
322497
322639
|
maybeWarnStorageFull(e3);
|
|
322498
322640
|
}
|
|
322499
322641
|
}
|
|
322500
|
-
var
|
|
322642
|
+
var import_electron_log58, logger55, lastStorageWarningAt, STORAGE_WARNING_DEBOUNCE_MS;
|
|
322501
322643
|
var init_persist_safe = __esm({
|
|
322502
322644
|
"src/ipc/handlers/permissions/persist-safe.ts"() {
|
|
322503
|
-
|
|
322645
|
+
import_electron_log58 = __toESM(require_src());
|
|
322504
322646
|
init_agent_notification();
|
|
322505
|
-
|
|
322647
|
+
logger55 = import_electron_log58.default.scope("permission-persist");
|
|
322506
322648
|
lastStorageWarningAt = 0;
|
|
322507
322649
|
STORAGE_WARNING_DEBOUNCE_MS = 6e4;
|
|
322508
322650
|
}
|
|
@@ -322871,14 +323013,14 @@ function runFilePermissionPreflight(operation, relativePath, appId) {
|
|
|
322871
323013
|
canAlwaysAllowExtension: gate.canAlwaysAllowExtension
|
|
322872
323014
|
};
|
|
322873
323015
|
}
|
|
322874
|
-
var
|
|
323016
|
+
var import_electron_log59, logger56;
|
|
322875
323017
|
var init_file_permission_handlers = __esm({
|
|
322876
323018
|
"src/ipc/handlers/file_permission_handlers.ts"() {
|
|
322877
323019
|
init_electron_stub();
|
|
322878
|
-
|
|
323020
|
+
import_electron_log59 = __toESM(require_src());
|
|
322879
323021
|
init_file_permission_scope();
|
|
322880
323022
|
init_file_permissions_store();
|
|
322881
|
-
|
|
323023
|
+
logger56 = import_electron_log59.default.scope("file-permissions");
|
|
322882
323024
|
}
|
|
322883
323025
|
});
|
|
322884
323026
|
|
|
@@ -323374,25 +323516,25 @@ function runCommandCategoryPreflight(command, appId, workspaceRoot, readOnlySour
|
|
|
323374
323516
|
reason: gate.reason
|
|
323375
323517
|
};
|
|
323376
323518
|
}
|
|
323377
|
-
var
|
|
323519
|
+
var import_electron_log60, logger57;
|
|
323378
323520
|
var init_command_permission_handlers = __esm({
|
|
323379
323521
|
"src/ipc/handlers/command_permission_handlers.ts"() {
|
|
323380
323522
|
init_electron_stub();
|
|
323381
|
-
|
|
323523
|
+
import_electron_log60 = __toESM(require_src());
|
|
323382
323524
|
init_terminal_command_category();
|
|
323383
323525
|
init_dangerous_commands();
|
|
323384
323526
|
init_system_scope_commands();
|
|
323385
323527
|
init_command_segments();
|
|
323386
323528
|
init_mutating_commands();
|
|
323387
323529
|
init_command_permissions_store();
|
|
323388
|
-
|
|
323530
|
+
logger57 = import_electron_log60.default.scope("command-permissions");
|
|
323389
323531
|
}
|
|
323390
323532
|
});
|
|
323391
323533
|
|
|
323392
323534
|
// src/ipc/handlers/chat_stream/permission-ui.ts
|
|
323393
323535
|
function runCommandGateResult(_command, workMode) {
|
|
323394
323536
|
if (!WorkModeSchema.safeParse(workMode).success) {
|
|
323395
|
-
|
|
323537
|
+
logger58.warn(
|
|
323396
323538
|
`[run-command gate] invalid workMode ${JSON.stringify(workMode)} \u2014 failing closed`
|
|
323397
323539
|
);
|
|
323398
323540
|
return JSON.stringify({
|
|
@@ -323559,10 +323701,10 @@ function enrichRunCommandPermissionRequest(permRequest, appId, workspaceRoot, re
|
|
|
323559
323701
|
}
|
|
323560
323702
|
};
|
|
323561
323703
|
}
|
|
323562
|
-
var
|
|
323704
|
+
var import_electron_log61, logger58;
|
|
323563
323705
|
var init_permission_ui = __esm({
|
|
323564
323706
|
"src/ipc/handlers/chat_stream/permission-ui.ts"() {
|
|
323565
|
-
|
|
323707
|
+
import_electron_log61 = __toESM(require_src());
|
|
323566
323708
|
init_schemas3();
|
|
323567
323709
|
init_safe_sender();
|
|
323568
323710
|
init_compose_hunks();
|
|
@@ -323570,7 +323712,7 @@ var init_permission_ui = __esm({
|
|
|
323570
323712
|
init_command_permission_handlers();
|
|
323571
323713
|
init_system_scope_commands();
|
|
323572
323714
|
init_mutating_commands();
|
|
323573
|
-
|
|
323715
|
+
logger58 = import_electron_log61.default.scope("chat_stream_handlers");
|
|
323574
323716
|
}
|
|
323575
323717
|
});
|
|
323576
323718
|
|
|
@@ -323634,7 +323776,7 @@ function sendPanelIntent(intent, context) {
|
|
|
323634
323776
|
source: "system"
|
|
323635
323777
|
});
|
|
323636
323778
|
}
|
|
323637
|
-
|
|
323779
|
+
logger59.log(`[Panel Intent] Sent intent: ${intent}`);
|
|
323638
323780
|
}
|
|
323639
323781
|
function getInterceptorForChat(chatId) {
|
|
323640
323782
|
return activeInterceptors.get(chatId);
|
|
@@ -323643,7 +323785,7 @@ function registerInterceptor(chatId, interceptor) {
|
|
|
323643
323785
|
const previous = activeInterceptors.get(chatId);
|
|
323644
323786
|
if (previous && previous !== interceptor) previous.releaseSettledWrites();
|
|
323645
323787
|
activeInterceptors.set(chatId, interceptor);
|
|
323646
|
-
|
|
323788
|
+
logger59.log(`Registered permission interceptor for chat ${chatId}`);
|
|
323647
323789
|
interceptor.on(
|
|
323648
323790
|
"permission-request",
|
|
323649
323791
|
(data) => {
|
|
@@ -323665,7 +323807,7 @@ function registerInterceptor(chatId, interceptor) {
|
|
|
323665
323807
|
(data) => {
|
|
323666
323808
|
const isDevServer = data.command.includes("run dev") || data.command.includes("start") || data.command.includes("serve");
|
|
323667
323809
|
if (isDevServer && data.status === "completed" && data.exitCode === 0) {
|
|
323668
|
-
|
|
323810
|
+
logger59.log(
|
|
323669
323811
|
`[Panel Intent] Dev server completed, switching to show-preview`
|
|
323670
323812
|
);
|
|
323671
323813
|
sendPanelIntent("show-preview", {
|
|
@@ -323751,14 +323893,14 @@ async function applyNewRuleToPendingOperations(interceptor, appId, chatId, sende
|
|
|
323751
323893
|
)
|
|
323752
323894
|
);
|
|
323753
323895
|
if (covered.length === 0) return;
|
|
323754
|
-
|
|
323896
|
+
logger59.log(
|
|
323755
323897
|
`[permissions] new rule covers ${covered.length} queued operation(s) for chat ${chatId}`
|
|
323756
323898
|
);
|
|
323757
323899
|
for (const { id } of covered) {
|
|
323758
323900
|
try {
|
|
323759
323901
|
await interceptor.executeOperation(id);
|
|
323760
323902
|
} catch (err2) {
|
|
323761
|
-
|
|
323903
|
+
logger59.error(`[permissions] auto-approve of ${id} failed:`, err2);
|
|
323762
323904
|
}
|
|
323763
323905
|
}
|
|
323764
323906
|
emitFilePermissionActivity(
|
|
@@ -323771,12 +323913,12 @@ async function applyNewRuleToPendingOperations(interceptor, appId, chatId, sende
|
|
|
323771
323913
|
function getExecutePermissionHandler() {
|
|
323772
323914
|
return executePermissionHandler;
|
|
323773
323915
|
}
|
|
323774
|
-
var
|
|
323916
|
+
var import_electron_log62, logger59, gatedHandle, ChatIdPayloadSchema, activeInterceptors, WAITING_ON_COMMAND_AFTER_MS, waitTrackersByChat, executePermissionHandler;
|
|
323775
323917
|
var init_handlers = __esm({
|
|
323776
323918
|
"src/ipc/handlers/permissions/handlers.ts"() {
|
|
323777
323919
|
init_electron_stub();
|
|
323778
323920
|
init_zod();
|
|
323779
|
-
|
|
323921
|
+
import_electron_log62 = __toESM(require_src());
|
|
323780
323922
|
init_agent_notification();
|
|
323781
323923
|
init_safe_handle();
|
|
323782
323924
|
init_persist_safe();
|
|
@@ -323788,8 +323930,8 @@ var init_handlers = __esm({
|
|
|
323788
323930
|
init_file_permission_handlers();
|
|
323789
323931
|
init_permission_ui();
|
|
323790
323932
|
init_pending_rule_sweep();
|
|
323791
|
-
|
|
323792
|
-
gatedHandle = createLoggedHandler(
|
|
323933
|
+
logger59 = import_electron_log62.default.scope("permission-handlers");
|
|
323934
|
+
gatedHandle = createLoggedHandler(logger59);
|
|
323793
323935
|
ChatIdPayloadSchema = external_exports.object({ chatId: external_exports.number() });
|
|
323794
323936
|
activeInterceptors = /* @__PURE__ */ new Map();
|
|
323795
323937
|
WAITING_ON_COMMAND_AFTER_MS = 1e4;
|
|
@@ -323801,7 +323943,7 @@ var init_handlers = __esm({
|
|
|
323801
323943
|
appId,
|
|
323802
323944
|
overrideContent
|
|
323803
323945
|
}) => {
|
|
323804
|
-
|
|
323946
|
+
logger59.log(
|
|
323805
323947
|
`Executing permission ${operationId} for chat ${chatId} mode=${approvalMode}`
|
|
323806
323948
|
);
|
|
323807
323949
|
const interceptor = activeInterceptors.get(chatId);
|
|
@@ -323903,7 +324045,7 @@ var init_handlers = __esm({
|
|
|
323903
324045
|
ipcMain.handle(
|
|
323904
324046
|
"reject-permission",
|
|
323905
324047
|
async (_event, { chatId, operationId }) => {
|
|
323906
|
-
|
|
324048
|
+
logger59.log(`Rejecting permission ${operationId} for chat ${chatId}`);
|
|
323907
324049
|
const interceptor = activeInterceptors.get(chatId);
|
|
323908
324050
|
if (!interceptor) {
|
|
323909
324051
|
return {
|
|
@@ -323919,7 +324061,7 @@ var init_handlers = __esm({
|
|
|
323919
324061
|
"execute-all-permissions",
|
|
323920
324062
|
async (_event, rawPayload) => {
|
|
323921
324063
|
const { chatId } = ChatIdPayloadSchema.parse(rawPayload);
|
|
323922
|
-
|
|
324064
|
+
logger59.log(`Executing all permissions for chat ${chatId}`);
|
|
323923
324065
|
const interceptor = activeInterceptors.get(chatId);
|
|
323924
324066
|
if (!interceptor) {
|
|
323925
324067
|
return [];
|
|
@@ -323936,7 +324078,7 @@ var init_handlers = __esm({
|
|
|
323936
324078
|
return [];
|
|
323937
324079
|
}
|
|
323938
324080
|
interceptor.approveRestOfTurn();
|
|
323939
|
-
|
|
324081
|
+
logger59.log(
|
|
323940
324082
|
`Approving all permissions for the rest of turn on chat ${chatId}`
|
|
323941
324083
|
);
|
|
323942
324084
|
return interceptor.executeAllOperations();
|
|
@@ -323946,7 +324088,7 @@ var init_handlers = __esm({
|
|
|
323946
324088
|
"reject-all-permissions",
|
|
323947
324089
|
async (_event, rawPayload) => {
|
|
323948
324090
|
const { chatId } = ChatIdPayloadSchema.parse(rawPayload);
|
|
323949
|
-
|
|
324091
|
+
logger59.log(`Rejecting all permissions for chat ${chatId}`);
|
|
323950
324092
|
const interceptor = activeInterceptors.get(chatId);
|
|
323951
324093
|
if (!interceptor) {
|
|
323952
324094
|
return [];
|
|
@@ -324026,19 +324168,19 @@ async function notifyRunFinished(runId) {
|
|
|
324026
324168
|
}
|
|
324027
324169
|
});
|
|
324028
324170
|
} catch (e3) {
|
|
324029
|
-
|
|
324171
|
+
logger60.warn("OS notification failed:", e3);
|
|
324030
324172
|
}
|
|
324031
324173
|
}
|
|
324032
|
-
var
|
|
324174
|
+
var import_electron_log63, logger60;
|
|
324033
324175
|
var init_notify = __esm({
|
|
324034
324176
|
"src/lib/automations/notify.ts"() {
|
|
324035
|
-
|
|
324177
|
+
import_electron_log63 = __toESM(require_src());
|
|
324036
324178
|
init_drizzle_orm();
|
|
324037
324179
|
init_db2();
|
|
324038
324180
|
init_schema();
|
|
324039
324181
|
init_broadcast_all_windows();
|
|
324040
324182
|
init_desktop_notification();
|
|
324041
|
-
|
|
324183
|
+
logger60 = import_electron_log63.default.scope("automations");
|
|
324042
324184
|
}
|
|
324043
324185
|
});
|
|
324044
324186
|
|
|
@@ -324101,7 +324243,7 @@ async function broadcastRunUpdate(runId) {
|
|
|
324101
324243
|
const { broadcastAutomationRunUpdate: broadcastAutomationRunUpdate2 } = await Promise.resolve().then(() => (init_notify(), notify_exports));
|
|
324102
324244
|
await broadcastAutomationRunUpdate2(runId);
|
|
324103
324245
|
} catch (e3) {
|
|
324104
|
-
|
|
324246
|
+
logger61.warn("automation run-update broadcast failed:", e3);
|
|
324105
324247
|
}
|
|
324106
324248
|
}
|
|
324107
324249
|
async function maybeTellTheAgent(automation, status, body, forceNotifyAgent = false) {
|
|
@@ -324118,7 +324260,7 @@ async function maybeTellTheAgent(automation, status, body, forceNotifyAgent = fa
|
|
|
324118
324260
|
finishedAt: Date.now()
|
|
324119
324261
|
});
|
|
324120
324262
|
} catch (e3) {
|
|
324121
|
-
|
|
324263
|
+
logger61.warn("could not queue automation result for the agent:", e3);
|
|
324122
324264
|
}
|
|
324123
324265
|
}
|
|
324124
324266
|
async function executeAutomationRun(automationId, triggerContext, deps, opts) {
|
|
@@ -324127,14 +324269,14 @@ async function executeAutomationRun(automationId, triggerContext, deps, opts) {
|
|
|
324127
324269
|
});
|
|
324128
324270
|
if (!automation || !automation.enabled) return null;
|
|
324129
324271
|
if (automation.workspaceId == null) {
|
|
324130
|
-
|
|
324272
|
+
logger61.warn(`automation ${automationId} has no workspace \u2014 skipping`);
|
|
324131
324273
|
return null;
|
|
324132
324274
|
}
|
|
324133
324275
|
const app2 = await db.query.apps.findFirst({
|
|
324134
324276
|
where: eq(apps.id, automation.workspaceId)
|
|
324135
324277
|
});
|
|
324136
324278
|
if (!app2) {
|
|
324137
|
-
|
|
324279
|
+
logger61.warn(
|
|
324138
324280
|
`automation ${automationId}: workspace ${automation.workspaceId} missing`
|
|
324139
324281
|
);
|
|
324140
324282
|
return null;
|
|
@@ -324160,7 +324302,7 @@ async function executeAutomationRun(automationId, triggerContext, deps, opts) {
|
|
|
324160
324302
|
const { notifyRunFinished: notifyRunFinished2 } = await Promise.resolve().then(() => (init_notify(), notify_exports));
|
|
324161
324303
|
await notifyRunFinished2(runId2);
|
|
324162
324304
|
} catch (e3) {
|
|
324163
|
-
|
|
324305
|
+
logger61.warn("automation notification failed:", e3);
|
|
324164
324306
|
}
|
|
324165
324307
|
await maybeTellTheAgent(
|
|
324166
324308
|
automation,
|
|
@@ -324168,7 +324310,7 @@ async function executeAutomationRun(automationId, triggerContext, deps, opts) {
|
|
|
324168
324310
|
triggerContext ?? headline,
|
|
324169
324311
|
opts?.forceNotifyAgent
|
|
324170
324312
|
);
|
|
324171
|
-
|
|
324313
|
+
logger61.info(`automation "${automation.name}" fired (notify-only)`);
|
|
324172
324314
|
return { runId: runId2 };
|
|
324173
324315
|
}
|
|
324174
324316
|
const resolvedDeps = deps ?? await resolveProdDeps();
|
|
@@ -324292,17 +324434,17 @@ ${wrapUntrustedData("automation-trigger", triggerContext)}` : "") + automationPr
|
|
|
324292
324434
|
const { notifyRunFinished: notifyRunFinished2 } = await Promise.resolve().then(() => (init_notify(), notify_exports));
|
|
324293
324435
|
await notifyRunFinished2(runId);
|
|
324294
324436
|
} catch (e3) {
|
|
324295
|
-
|
|
324437
|
+
logger61.warn("automation notification failed:", e3);
|
|
324296
324438
|
}
|
|
324297
|
-
|
|
324439
|
+
logger61.info(
|
|
324298
324440
|
`automation "${automation.name}" run ${runId} finished: ${status}${runError ? ` (${runError})` : ""}`
|
|
324299
324441
|
);
|
|
324300
324442
|
return { runId };
|
|
324301
324443
|
}
|
|
324302
|
-
var
|
|
324444
|
+
var import_electron_log64, logger61, RUN_TIMEOUT_MS, NOTHING_SENTINEL, RESULT_SENTINEL, SUMMARY_MAX;
|
|
324303
324445
|
var init_execute_run = __esm({
|
|
324304
324446
|
"src/lib/automations/execute-run.ts"() {
|
|
324305
|
-
|
|
324447
|
+
import_electron_log64 = __toESM(require_src());
|
|
324306
324448
|
init_drizzle_orm();
|
|
324307
324449
|
init_db2();
|
|
324308
324450
|
init_schema();
|
|
@@ -324311,7 +324453,7 @@ var init_execute_run = __esm({
|
|
|
324311
324453
|
init_untrusted_data();
|
|
324312
324454
|
init_auto_approve();
|
|
324313
324455
|
init_process_owner();
|
|
324314
|
-
|
|
324456
|
+
logger61 = import_electron_log64.default.scope("automations");
|
|
324315
324457
|
RUN_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
324316
324458
|
NOTHING_SENTINEL = "NOTHING_TO_REPORT";
|
|
324317
324459
|
RESULT_SENTINEL = "AUTOMATION_RESULT:";
|
|
@@ -324443,7 +324585,7 @@ async function defaultDeps() {
|
|
|
324443
324585
|
}
|
|
324444
324586
|
function enqueueRun(automationId, triggerContext, reason) {
|
|
324445
324587
|
if (queuedOrRunning.has(automationId)) {
|
|
324446
|
-
|
|
324588
|
+
logger62.info(
|
|
324447
324589
|
`automation ${automationId} already queued/running \u2014 skipping ${reason} fire`
|
|
324448
324590
|
);
|
|
324449
324591
|
return;
|
|
@@ -324460,7 +324602,7 @@ async function drainQueue() {
|
|
|
324460
324602
|
const item = queue.shift();
|
|
324461
324603
|
try {
|
|
324462
324604
|
if (item.reason !== "manual" && await runningElsewhere(item.automationId)) {
|
|
324463
|
-
|
|
324605
|
+
logger62.info(
|
|
324464
324606
|
`automation ${item.automationId} is running in another Atlarix \u2014 skipping ${item.reason} fire`
|
|
324465
324607
|
);
|
|
324466
324608
|
continue;
|
|
@@ -324468,7 +324610,7 @@ async function drainQueue() {
|
|
|
324468
324610
|
const deps = runnerDeps ?? (runnerDeps = await defaultDeps());
|
|
324469
324611
|
await deps.executeRun(item.automationId, item.context);
|
|
324470
324612
|
} catch (e3) {
|
|
324471
|
-
|
|
324613
|
+
logger62.error(
|
|
324472
324614
|
`automation ${item.automationId} run failed to execute:`,
|
|
324473
324615
|
e3
|
|
324474
324616
|
);
|
|
@@ -324495,7 +324637,7 @@ async function retireUnparseableAutomation(automationId, name29) {
|
|
|
324495
324637
|
await db.update(automations).set({ enabled: false, updatedAt: /* @__PURE__ */ new Date() }).where(eq(automations.id, automationId));
|
|
324496
324638
|
disarm(automationId);
|
|
324497
324639
|
const message = "This automation used a trigger type Atlarix no longer supports (it polled a single code host). It has been disabled. Recreate it as a Schedule or MCP trigger \u2014 an MCP server can poll any API, including GitHub, GitLab and Bitbucket.";
|
|
324498
|
-
|
|
324640
|
+
logger62.warn(`automation "${name29}" retired: unsupported trigger type`);
|
|
324499
324641
|
await recordPollError(automationId, message);
|
|
324500
324642
|
}
|
|
324501
324643
|
async function persistCursor(automationId, cursor) {
|
|
@@ -324551,7 +324693,7 @@ async function pollOnce(automationId) {
|
|
|
324551
324693
|
if (result2.fired) enqueueRun(automationId, result2.context ?? null, "poll");
|
|
324552
324694
|
} catch (e3) {
|
|
324553
324695
|
const message = e3 instanceof Error ? e3.message : String(e3);
|
|
324554
|
-
|
|
324696
|
+
logger62.warn(`automation "${automation.name}" poll failed: ${message}`);
|
|
324555
324697
|
await recordPollError(automationId, message).catch(() => {
|
|
324556
324698
|
});
|
|
324557
324699
|
}
|
|
@@ -324578,7 +324720,7 @@ async function arm(automationId) {
|
|
|
324578
324720
|
}
|
|
324579
324721
|
if (trigger.kind === "schedule") {
|
|
324580
324722
|
if (!validate(trigger.cron)) {
|
|
324581
|
-
|
|
324723
|
+
logger62.warn(
|
|
324582
324724
|
`automation "${automation.name}" has invalid cron "${trigger.cron}" \u2014 not armed`
|
|
324583
324725
|
);
|
|
324584
324726
|
return;
|
|
@@ -324588,7 +324730,7 @@ async function arm(automationId) {
|
|
|
324588
324730
|
(mine) => {
|
|
324589
324731
|
if (mine) enqueueRun(automationId, null, "schedule");
|
|
324590
324732
|
},
|
|
324591
|
-
(e3) =>
|
|
324733
|
+
(e3) => logger62.warn(`automation ${automationId}: could not claim its run:`, e3)
|
|
324592
324734
|
);
|
|
324593
324735
|
});
|
|
324594
324736
|
cronTasks.set(automationId, task);
|
|
@@ -324599,14 +324741,14 @@ async function arm(automationId) {
|
|
|
324599
324741
|
);
|
|
324600
324742
|
const claimedPoll = () => void claimSlot(automationId, pollSlot(minutes)).then(
|
|
324601
324743
|
(mine) => mine ? pollOnce(automationId) : void 0,
|
|
324602
|
-
(e3) =>
|
|
324744
|
+
(e3) => logger62.warn(`automation ${automationId}: could not claim its poll:`, e3)
|
|
324603
324745
|
);
|
|
324604
324746
|
const timer = setInterval(claimedPoll, minutes * 60 * 1e3);
|
|
324605
324747
|
timer.unref?.();
|
|
324606
324748
|
pollTimers.set(automationId, timer);
|
|
324607
324749
|
claimedPoll();
|
|
324608
324750
|
}
|
|
324609
|
-
|
|
324751
|
+
logger62.info(`armed automation "${automation.name}" (${trigger.kind})`);
|
|
324610
324752
|
}
|
|
324611
324753
|
async function refreshAutomationSchedule(automationId) {
|
|
324612
324754
|
await arm(automationId);
|
|
@@ -324672,7 +324814,7 @@ async function recoverInterruptedRuns() {
|
|
|
324672
324814
|
}
|
|
324673
324815
|
}
|
|
324674
324816
|
if (stale.length > 0) {
|
|
324675
|
-
|
|
324817
|
+
logger62.info(
|
|
324676
324818
|
`recovered ${stale.length} automation run(s) interrupted by app quit`
|
|
324677
324819
|
);
|
|
324678
324820
|
}
|
|
@@ -324682,7 +324824,7 @@ function startAutomationRunner(deps) {
|
|
|
324682
324824
|
if (lifecycleTimers.length === 0) {
|
|
324683
324825
|
const every2 = (ms2, fn2, what) => {
|
|
324684
324826
|
const t3 = setInterval(() => {
|
|
324685
|
-
void fn2().catch((e3) =>
|
|
324827
|
+
void fn2().catch((e3) => logger62.warn(`automation ${what} failed:`, e3));
|
|
324686
324828
|
}, ms2);
|
|
324687
324829
|
t3.unref?.();
|
|
324688
324830
|
lifecycleTimers.push(t3);
|
|
@@ -324700,11 +324842,11 @@ function startAutomationRunner(deps) {
|
|
|
324700
324842
|
for (const a2 of all) {
|
|
324701
324843
|
await arm(a2.id);
|
|
324702
324844
|
}
|
|
324703
|
-
|
|
324845
|
+
logger62.info(
|
|
324704
324846
|
`automation runner started (${all.length} enabled automation(s))`
|
|
324705
324847
|
);
|
|
324706
324848
|
} catch (e3) {
|
|
324707
|
-
|
|
324849
|
+
logger62.error("automation runner failed to start:", e3);
|
|
324708
324850
|
}
|
|
324709
324851
|
})();
|
|
324710
324852
|
}
|
|
@@ -324718,17 +324860,17 @@ function resetAutomationRunnerForTests() {
|
|
|
324718
324860
|
for (const t3 of lifecycleTimers.splice(0)) clearInterval(t3);
|
|
324719
324861
|
armedSignature.clear();
|
|
324720
324862
|
}
|
|
324721
|
-
var
|
|
324863
|
+
var import_electron_log65, logger62, HEARTBEAT_MS, STALE_HEARTBEAT_MS, SYNC_MS, LEASE_TTL_MS, runnerDeps, cronTasks, pollTimers, queue, queuedOrRunning, draining, armedSignature, signatureOf, lifecycleTimers, syncDefinitionsForTests, beatForTests;
|
|
324722
324864
|
var init_runner = __esm({
|
|
324723
324865
|
"src/lib/automations/runner.ts"() {
|
|
324724
|
-
|
|
324866
|
+
import_electron_log65 = __toESM(require_src());
|
|
324725
324867
|
init_node_cron();
|
|
324726
324868
|
init_drizzle_orm();
|
|
324727
324869
|
init_db2();
|
|
324728
324870
|
init_schema();
|
|
324729
324871
|
init_types4();
|
|
324730
324872
|
init_process_owner();
|
|
324731
|
-
|
|
324873
|
+
logger62 = import_electron_log65.default.scope("automations");
|
|
324732
324874
|
HEARTBEAT_MS = 3e4;
|
|
324733
324875
|
STALE_HEARTBEAT_MS = 2 * 6e4;
|
|
324734
324876
|
SYNC_MS = 6e4;
|
|
@@ -324797,7 +324939,7 @@ function broadcastAutomationsChanged() {
|
|
|
324797
324939
|
try {
|
|
324798
324940
|
broadcastToAllWindows("automations:changed", {});
|
|
324799
324941
|
} catch (e3) {
|
|
324800
|
-
|
|
324942
|
+
logger63.warn("could not broadcast automations:changed:", e3);
|
|
324801
324943
|
}
|
|
324802
324944
|
}
|
|
324803
324945
|
async function listAutomations(workspaceId) {
|
|
@@ -324848,7 +324990,7 @@ async function createAutomation(workspaceId, input) {
|
|
|
324848
324990
|
});
|
|
324849
324991
|
await refreshSchedule(id);
|
|
324850
324992
|
broadcastAutomationsChanged();
|
|
324851
|
-
|
|
324993
|
+
logger63.log(
|
|
324852
324994
|
`created automation "${input.name}" (${input.trigger.kind}, runMode=${input.runMode}, notifyAgent=${input.notifyAgent})`
|
|
324853
324995
|
);
|
|
324854
324996
|
return { id };
|
|
@@ -324885,16 +325027,16 @@ async function setAutomationNotifyAgent(id, notifyAgent) {
|
|
|
324885
325027
|
await db.update(automations).set({ notifyAgent, updatedAt: /* @__PURE__ */ new Date() }).where(eq(automations.id, id));
|
|
324886
325028
|
broadcastAutomationsChanged();
|
|
324887
325029
|
}
|
|
324888
|
-
var
|
|
325030
|
+
var import_electron_log66, logger63, AUTOMATIONS_WORKSPACE_MAX2;
|
|
324889
325031
|
var init_service = __esm({
|
|
324890
325032
|
"src/lib/automations/service.ts"() {
|
|
324891
325033
|
init_drizzle_orm();
|
|
324892
|
-
|
|
325034
|
+
import_electron_log66 = __toESM(require_src());
|
|
324893
325035
|
init_db2();
|
|
324894
325036
|
init_schema();
|
|
324895
325037
|
init_broadcast_all_windows();
|
|
324896
325038
|
init_workspace_caps();
|
|
324897
|
-
|
|
325039
|
+
logger63 = import_electron_log66.default.scope("automations-service");
|
|
324898
325040
|
AUTOMATIONS_WORKSPACE_MAX2 = AUTOMATIONS_WORKSPACE_MAX;
|
|
324899
325041
|
}
|
|
324900
325042
|
});
|
|
@@ -324915,15 +325057,15 @@ function buildInput(args2, existing) {
|
|
|
324915
325057
|
model: null
|
|
324916
325058
|
});
|
|
324917
325059
|
}
|
|
324918
|
-
var
|
|
325060
|
+
var import_electron_log67, logger64, AUTOMATION_RUN_PROMOTE_AFTER_MS;
|
|
324919
325061
|
var init_automations2 = __esm({
|
|
324920
325062
|
"src/lib/tools/automations.ts"() {
|
|
324921
|
-
|
|
325063
|
+
import_electron_log67 = __toESM(require_src());
|
|
324922
325064
|
init_registry();
|
|
324923
325065
|
init_types4();
|
|
324924
325066
|
init_service();
|
|
324925
325067
|
init_workspace_caps();
|
|
324926
|
-
|
|
325068
|
+
logger64 = import_electron_log67.default.scope("automations-tool");
|
|
324927
325069
|
AUTOMATION_RUN_PROMOTE_AFTER_MS = 15e3;
|
|
324928
325070
|
ToolRegistry.register({
|
|
324929
325071
|
name: "automations",
|
|
@@ -325209,7 +325351,7 @@ var init_automations2 = __esm({
|
|
|
325209
325351
|
};
|
|
325210
325352
|
} catch (e3) {
|
|
325211
325353
|
const message = e3 instanceof Error ? e3.message : String(e3);
|
|
325212
|
-
|
|
325354
|
+
logger64.warn(`automations ${args2.operation} rejected: ${message}`);
|
|
325213
325355
|
return {
|
|
325214
325356
|
success: false,
|
|
325215
325357
|
error: `Could not build that automation: ${message}`
|
|
@@ -325981,7 +326123,7 @@ function findDeviceCli(cli) {
|
|
|
325981
326123
|
}
|
|
325982
326124
|
}
|
|
325983
326125
|
cache5.set(cli, resolved2);
|
|
325984
|
-
|
|
326126
|
+
logger65.info(`[mobile] ${cli}: ${resolved2 ?? "not found"}`);
|
|
325985
326127
|
return resolved2;
|
|
325986
326128
|
}
|
|
325987
326129
|
async function runDeviceCli(cli, args2, opts) {
|
|
@@ -326054,7 +326196,7 @@ async function ensureTapFeedback(deviceId, deviceLabel) {
|
|
|
326054
326196
|
);
|
|
326055
326197
|
if (!put2.ok) return null;
|
|
326056
326198
|
tapFeedback.set(deviceId, previous);
|
|
326057
|
-
|
|
326199
|
+
logger65.info(`[mobile] tap feedback on for ${deviceId} (was ${previous})`);
|
|
326058
326200
|
return `Tap feedback enabled on ${deviceLabel} \u2014 you can watch each tap land. Restored when Atlarix quits.`;
|
|
326059
326201
|
} catch {
|
|
326060
326202
|
return null;
|
|
@@ -326093,11 +326235,11 @@ function iosLogPredicate(level) {
|
|
|
326093
326235
|
if (level === "all") return [];
|
|
326094
326236
|
return ["--predicate", 'messageType == "Error" OR messageType == "Fault"'];
|
|
326095
326237
|
}
|
|
326096
|
-
var
|
|
326238
|
+
var import_electron_log68, logger65, cache5, IOS_UNSUPPORTED, PACKAGE_ID, runnerOverride, tapFeedback, IOS_LOG_WINDOW;
|
|
326097
326239
|
var init_device_tools = __esm({
|
|
326098
326240
|
"src/lib/mobile/device-tools.ts"() {
|
|
326099
|
-
|
|
326100
|
-
|
|
326241
|
+
import_electron_log68 = __toESM(require_src());
|
|
326242
|
+
logger65 = import_electron_log68.default.scope("mobile");
|
|
326101
326243
|
cache5 = /* @__PURE__ */ new Map();
|
|
326102
326244
|
IOS_UNSUPPORTED = {
|
|
326103
326245
|
hierarchy: 'iOS Simulator has no UI-hierarchy dump: `simctl` cannot list elements, so there are no refs to act on. Use mode:"screenshot" to see the screen, and drive the simulator by hand or via `idb` (a separate install) through run_command. This is a platform limitation, not a transient failure \u2014 do not retry.',
|
|
@@ -327085,7 +327227,7 @@ ${body}${more}`,
|
|
|
327085
327227
|
const capped = totalHits >= maxHits ? `
|
|
327086
327228
|
|
|
327087
327229
|
[stopped at ${maxHits} hits \u2014 narrow the query, or raise \`limit\`]` : "";
|
|
327088
|
-
|
|
327230
|
+
logger66.info(
|
|
327089
327231
|
`session_search "${query}" \u2192 ${totalHits} hit(s) across ${sessions.length} session(s)`
|
|
327090
327232
|
);
|
|
327091
327233
|
return {
|
|
@@ -327098,15 +327240,15 @@ Use mode:"read" with an offset to see full turns around a hit.`,
|
|
|
327098
327240
|
ui: { groups }
|
|
327099
327241
|
};
|
|
327100
327242
|
}
|
|
327101
|
-
var
|
|
327243
|
+
var import_electron_log69, logger66, DEFAULT_MAX_HITS, MAX_HITS_CEILING, SNIPPET_CHARS, DEFAULT_READ_LIMIT, MAX_READ_LIMIT, SESSION_LOOKUP_CAP, EXCLUDE_MARKERS_SQL, notACompactionMarker;
|
|
327102
327244
|
var init_sessions = __esm({
|
|
327103
327245
|
"src/lib/tools/sessions.ts"() {
|
|
327104
|
-
|
|
327246
|
+
import_electron_log69 = __toESM(require_src());
|
|
327105
327247
|
init_drizzle_orm();
|
|
327106
327248
|
init_db2();
|
|
327107
327249
|
init_schema();
|
|
327108
327250
|
init_registry();
|
|
327109
|
-
|
|
327251
|
+
logger66 = import_electron_log69.default.scope("session-search");
|
|
327110
327252
|
DEFAULT_MAX_HITS = 20;
|
|
327111
327253
|
MAX_HITS_CEILING = 100;
|
|
327112
327254
|
SNIPPET_CHARS = 220;
|
|
@@ -327348,7 +327490,7 @@ async function transcribeWithOwnKey(params) {
|
|
|
327348
327490
|
return { ok: true, text: text3 };
|
|
327349
327491
|
} catch (e3) {
|
|
327350
327492
|
const error51 = e3 instanceof Error ? e3.message : String(e3);
|
|
327351
|
-
|
|
327493
|
+
logger67.warn(`cloud transcription failed: ${error51}`);
|
|
327352
327494
|
return { ok: false, error: error51 };
|
|
327353
327495
|
}
|
|
327354
327496
|
}
|
|
@@ -327367,7 +327509,7 @@ function registerVoiceHandlers() {
|
|
|
327367
327509
|
const paid = await paidCoreForChat2(void 0).catch(() => false);
|
|
327368
327510
|
return paid ? [ATLARIX_TRANSCRIPTION, ...own] : own;
|
|
327369
327511
|
} catch (e3) {
|
|
327370
|
-
|
|
327512
|
+
logger67.warn("failed to list transcription providers", e3);
|
|
327371
327513
|
return [];
|
|
327372
327514
|
}
|
|
327373
327515
|
}
|
|
@@ -327439,21 +327581,21 @@ function registerVoiceHandlers() {
|
|
|
327439
327581
|
return { ok: true, text: (await result2.text).trim() };
|
|
327440
327582
|
} catch (e4) {
|
|
327441
327583
|
const error51 = e4 instanceof Error ? e4.message : String(e4);
|
|
327442
|
-
|
|
327584
|
+
logger67.warn(`model transcription failed: ${error51}`);
|
|
327443
327585
|
return { ok: false, error: error51 };
|
|
327444
327586
|
}
|
|
327445
327587
|
}
|
|
327446
327588
|
);
|
|
327447
327589
|
}
|
|
327448
|
-
var
|
|
327590
|
+
var import_electron_log70, logger67, GOOGLE_PROVIDER_IDS, FALLBACK_STT_MODEL, EXTENSION_BY_MEDIA_TYPE, ATLARIX_TRANSCRIPTION;
|
|
327449
327591
|
var init_voice_handlers = __esm({
|
|
327450
327592
|
"src/ipc/handlers/voice_handlers.ts"() {
|
|
327451
327593
|
init_electron_stub();
|
|
327452
327594
|
init_safe_sender();
|
|
327453
327595
|
init_provider_api_keys();
|
|
327454
327596
|
init_language_model_constants();
|
|
327455
|
-
|
|
327456
|
-
|
|
327597
|
+
import_electron_log70 = __toESM(require_src());
|
|
327598
|
+
logger67 = import_electron_log70.default.scope("voice");
|
|
327457
327599
|
GOOGLE_PROVIDER_IDS = /* @__PURE__ */ new Set(["gemini", "google"]);
|
|
327458
327600
|
FALLBACK_STT_MODEL = {
|
|
327459
327601
|
openai: "gpt-4o-transcribe",
|
|
@@ -327706,9 +327848,10 @@ var init_peers2 = __esm({
|
|
|
327706
327848
|
"src/lib/tools/peers.ts"() {
|
|
327707
327849
|
init_registry();
|
|
327708
327850
|
init_peers();
|
|
327851
|
+
init_peer_message();
|
|
327709
327852
|
ToolRegistry.register({
|
|
327710
327853
|
name: "list_sessions",
|
|
327711
|
-
description: "The user's other Atlarix sessions on this machine (CLI or
|
|
327854
|
+
description: "The user's other Atlarix sessions on this machine (CLI, app or browser), for send_message.",
|
|
327712
327855
|
requiresWorkspace: false,
|
|
327713
327856
|
isCore: false,
|
|
327714
327857
|
isReadOnly: true,
|
|
@@ -327724,7 +327867,7 @@ var init_peers2 = __esm({
|
|
|
327724
327867
|
};
|
|
327725
327868
|
}
|
|
327726
327869
|
const lines = rows.map(
|
|
327727
|
-
(r3) => `- ${r3.name} (id ${r3.sessionId.startsWith("pending-") ? r3.sessionId : r3.sessionId.slice(0, 8)}, ${r3.surface
|
|
327870
|
+
(r3) => r3.surface === "chrome" ? `- ${r3.name} (id ${r3.sessionId}, browser: the Atlarix extension's agent; it starts on a task when the user clicks the Atlarix icon)` : `- ${r3.name} (id ${r3.sessionId.startsWith("pending-") ? r3.sessionId : r3.sessionId.slice(0, 8)}, ${peerSurfaceLabel(r3.surface)}, ${r3.busy ? "busy" : "idle"}) \u2014 ${r3.workspace || "no workspace"}`
|
|
327728
327871
|
);
|
|
327729
327872
|
return { success: true, text: `Other sessions:
|
|
327730
327873
|
${lines.join("\n")}` };
|
|
@@ -327779,9 +327922,15 @@ ${lines.join("\n")}` };
|
|
|
327779
327922
|
error: `Not sent: ${result2.error ?? "unknown error"}`
|
|
327780
327923
|
};
|
|
327781
327924
|
const replyNote = peerInboxRunning() ? "" : " (This session has no inbox, so it cannot be replied to.)";
|
|
327925
|
+
if (target.row.surface === "chrome") {
|
|
327926
|
+
return {
|
|
327927
|
+
success: true,
|
|
327928
|
+
text: `Delivered to ${target.row.name}. It starts when the user clicks the Atlarix icon in ${target.row.name} (the badge shows it waiting); its result comes back here as a message.${replyNote}`
|
|
327929
|
+
};
|
|
327930
|
+
}
|
|
327782
327931
|
return {
|
|
327783
327932
|
success: true,
|
|
327784
|
-
text: `Sent to ${target.row.name} (${target.row.surface
|
|
327933
|
+
text: `Sent to ${target.row.name} (${peerSurfaceLabel(target.row.surface)}, ${target.row.busy ? "busy: it reads it at its next step" : "idle: it starts a turn with it"}).${replyNote}`
|
|
327785
327934
|
};
|
|
327786
327935
|
}
|
|
327787
327936
|
});
|
|
@@ -328319,7 +328468,7 @@ async function ensureShadowRepo(workspacePath) {
|
|
|
328319
328468
|
{}
|
|
328320
328469
|
);
|
|
328321
328470
|
await fs42.mkdir(path55.join(gitDir, TURNS_DIR), { recursive: true });
|
|
328322
|
-
|
|
328471
|
+
logger68.info(`Initialized shadow snapshot repo for ${workspacePath}`);
|
|
328323
328472
|
return gitDir;
|
|
328324
328473
|
}
|
|
328325
328474
|
async function readManifest(gitDir, seg) {
|
|
@@ -328380,7 +328529,7 @@ async function captureSnapshot(params) {
|
|
|
328380
328529
|
continue;
|
|
328381
328530
|
}
|
|
328382
328531
|
if (st2.size > MAX_SNAPSHOT_FILE_BYTES) {
|
|
328383
|
-
|
|
328532
|
+
logger68.warn(
|
|
328384
328533
|
`Skipping snapshot of large file (${st2.size}B): ${rel}`
|
|
328385
328534
|
);
|
|
328386
328535
|
continue;
|
|
@@ -328397,7 +328546,7 @@ async function captureSnapshot(params) {
|
|
|
328397
328546
|
env3
|
|
328398
328547
|
);
|
|
328399
328548
|
if (add.exitCode !== 0) {
|
|
328400
|
-
|
|
328549
|
+
logger68.warn(`shadow add failed: ${add.stderr || add.stdout}`);
|
|
328401
328550
|
}
|
|
328402
328551
|
}
|
|
328403
328552
|
const tree = await git(["write-tree"], workspacePath, env3);
|
|
@@ -328426,7 +328575,7 @@ async function captureSnapshot(params) {
|
|
|
328426
328575
|
);
|
|
328427
328576
|
void maybePruneOldSnapshots(workspacePath, gitDir);
|
|
328428
328577
|
} catch (err2) {
|
|
328429
|
-
|
|
328578
|
+
logger68.warn(`captureSnapshot failed for turn ${turnId}:`, err2);
|
|
328430
328579
|
}
|
|
328431
328580
|
});
|
|
328432
328581
|
}
|
|
@@ -328469,7 +328618,7 @@ async function recordTurnRoots(workspacePath, turnId, roots) {
|
|
|
328469
328618
|
"utf8"
|
|
328470
328619
|
);
|
|
328471
328620
|
} catch (err2) {
|
|
328472
|
-
|
|
328621
|
+
logger68.warn(`recordTurnRoots failed for turn ${turnId}:`, err2);
|
|
328473
328622
|
}
|
|
328474
328623
|
});
|
|
328475
328624
|
}
|
|
@@ -328532,7 +328681,7 @@ async function shadowRevert(workspacePath, turnId, filterPaths) {
|
|
|
328532
328681
|
if (co2.exitCode === 0) {
|
|
328533
328682
|
restored += toCheckout.length;
|
|
328534
328683
|
} else {
|
|
328535
|
-
|
|
328684
|
+
logger68.warn(`shadow checkout failed: ${co2.stderr || co2.stdout}`);
|
|
328536
328685
|
for (const rel of toCheckout) {
|
|
328537
328686
|
const single = await git(
|
|
328538
328687
|
["checkout", turnRef(seg), "--", rel],
|
|
@@ -328659,23 +328808,23 @@ async function maybePruneOldSnapshots(workspacePath, gitDir) {
|
|
|
328659
328808
|
await git(["gc", "--quiet", "--prune=now"], workspacePath, {
|
|
328660
328809
|
GIT_DIR: gitDir
|
|
328661
328810
|
});
|
|
328662
|
-
|
|
328811
|
+
logger68.info(
|
|
328663
328812
|
`Pruned ${dropped} expired snapshot turn(s) for ${workspacePath}`
|
|
328664
328813
|
);
|
|
328665
328814
|
}
|
|
328666
328815
|
} catch (err2) {
|
|
328667
|
-
|
|
328816
|
+
logger68.warn("snapshot prune failed:", err2);
|
|
328668
328817
|
}
|
|
328669
328818
|
}
|
|
328670
|
-
var
|
|
328819
|
+
var import_electron_log71, logger68, SHADOW_ROOT_DIR, TURNS_DIR, REF_PREFIX, SNAPSHOT_RETENTION_DAYS, MAX_SNAPSHOT_FILE_BYTES, shadowRootOverride, captureChains, prunedThisSession;
|
|
328671
328820
|
var init_snapshot_manager = __esm({
|
|
328672
328821
|
"src/lib/snapshot/snapshot-manager.ts"() {
|
|
328673
328822
|
init_system_git_exec();
|
|
328674
|
-
|
|
328823
|
+
import_electron_log71 = __toESM(require_src());
|
|
328675
328824
|
init_task_ledger();
|
|
328676
328825
|
init_paths();
|
|
328677
328826
|
init_git_author();
|
|
328678
|
-
|
|
328827
|
+
logger68 = import_electron_log71.default.scope("snapshot-manager");
|
|
328679
328828
|
SHADOW_ROOT_DIR = "shadow-snapshots";
|
|
328680
328829
|
TURNS_DIR = "turns";
|
|
328681
328830
|
REF_PREFIX = "refs/atlarix/turns";
|
|
@@ -328704,7 +328853,7 @@ async function isTextFile(filePath) {
|
|
|
328704
328853
|
const { bytesRead } = await handle2.read(buf, 0, SNIFF_SAMPLE_BYTES2, 0);
|
|
328705
328854
|
return classifyContent2(new Uint8Array(buf.subarray(0, bytesRead))).kind === "text";
|
|
328706
328855
|
} catch (err2) {
|
|
328707
|
-
|
|
328856
|
+
logger69.warn(`isTextFile: could not sample ${filePath}: ${String(err2)}`);
|
|
328708
328857
|
return false;
|
|
328709
328858
|
} finally {
|
|
328710
328859
|
await handle2?.close().catch(() => void 0);
|
|
@@ -328723,7 +328872,7 @@ async function performFullRevert(params) {
|
|
|
328723
328872
|
turnId
|
|
328724
328873
|
});
|
|
328725
328874
|
if (!snap.success) {
|
|
328726
|
-
|
|
328875
|
+
logger69.warn("performFullRevert: snapshot restore failed:", snap.error);
|
|
328727
328876
|
}
|
|
328728
328877
|
if (skipMessageFlags) {
|
|
328729
328878
|
return {
|
|
@@ -328753,13 +328902,13 @@ async function performFullRevert(params) {
|
|
|
328753
328902
|
restoredFiles: snap.restoredFiles
|
|
328754
328903
|
};
|
|
328755
328904
|
}
|
|
328756
|
-
var
|
|
328905
|
+
var import_electron_log72, logger69;
|
|
328757
328906
|
var init_stream_misc = __esm({
|
|
328758
328907
|
"src/ipc/handlers/chat_stream/stream-misc.ts"() {
|
|
328759
|
-
|
|
328908
|
+
import_electron_log72 = __toESM(require_src());
|
|
328760
328909
|
init_snapshot_manager();
|
|
328761
328910
|
init_stream_transport();
|
|
328762
|
-
|
|
328911
|
+
logger69 = import_electron_log72.default.scope("chat_stream_handlers");
|
|
328763
328912
|
}
|
|
328764
328913
|
});
|
|
328765
328914
|
|
|
@@ -328796,7 +328945,7 @@ async function resolveAskUserToolResult(event, chatId, toolName, result2, hooks)
|
|
|
328796
328945
|
options: questions[0].options,
|
|
328797
328946
|
questions
|
|
328798
328947
|
});
|
|
328799
|
-
|
|
328948
|
+
logger70.log(
|
|
328800
328949
|
`[ask_user] Questions presented (${questionId}, ${questions.length}) \u2014 ending turn; answers arrive as the next message`
|
|
328801
328950
|
);
|
|
328802
328951
|
hooks?.onAskUserEndTurn?.();
|
|
@@ -328843,7 +328992,7 @@ async function flushInterruptedDraft(chatId, sessionId, content, opts) {
|
|
|
328843
328992
|
);
|
|
328844
328993
|
partialDraftRowByChatId.set(chatId, rowId);
|
|
328845
328994
|
} catch (e3) {
|
|
328846
|
-
|
|
328995
|
+
logger70.warn(`[partial-draft] upsert failed for chat ${chatId}:`, e3);
|
|
328847
328996
|
}
|
|
328848
328997
|
}
|
|
328849
328998
|
async function clearInterruptedDraft(chatId) {
|
|
@@ -328855,13 +329004,13 @@ async function clearInterruptedDraft(chatId) {
|
|
|
328855
329004
|
const { deleteInterruptedAssistantDraft: deleteInterruptedAssistantDraft2 } = await Promise.resolve().then(() => (init_workspace_session_handlers(), workspace_session_handlers_exports));
|
|
328856
329005
|
await deleteInterruptedAssistantDraft2(rowId);
|
|
328857
329006
|
} catch (e3) {
|
|
328858
|
-
|
|
329007
|
+
logger70.warn(`[partial-draft] delete failed for chat ${chatId}:`, e3);
|
|
328859
329008
|
}
|
|
328860
329009
|
}
|
|
328861
329010
|
async function flushPartialStreamsForShutdown() {
|
|
328862
329011
|
const entries2 = [...partialResponses.entries()];
|
|
328863
329012
|
if (entries2.length === 0) return;
|
|
328864
|
-
|
|
329013
|
+
logger70.info(
|
|
328865
329014
|
`[partial-draft] shutdown flush for ${entries2.length} active stream(s)`
|
|
328866
329015
|
);
|
|
328867
329016
|
for (const [chatId, content] of entries2) {
|
|
@@ -328870,7 +329019,7 @@ async function flushPartialStreamsForShutdown() {
|
|
|
328870
329019
|
try {
|
|
328871
329020
|
await flushInterruptedDraft(chatId, sessionId, content, { force: true });
|
|
328872
329021
|
} catch (e3) {
|
|
328873
|
-
|
|
329022
|
+
logger70.warn(
|
|
328874
329023
|
`[partial-draft] shutdown flush failed for chat ${chatId}:`,
|
|
328875
329024
|
e3
|
|
328876
329025
|
);
|
|
@@ -328880,35 +329029,35 @@ async function flushPartialStreamsForShutdown() {
|
|
|
328880
329029
|
function abortAllStreams() {
|
|
328881
329030
|
const count3 = activeStreams.size;
|
|
328882
329031
|
if (count3 === 0) return;
|
|
328883
|
-
|
|
329032
|
+
logger70.log(`[Cleanup] Aborting ${count3} active AI streams to save tokens...`);
|
|
328884
329033
|
for (const [chatId, controller] of activeStreams.entries()) {
|
|
328885
329034
|
try {
|
|
328886
329035
|
controller.abort(streamStopAbortReason(TEARDOWN_STREAM_STOP));
|
|
328887
|
-
|
|
329036
|
+
logger70.log(`[Cleanup] Aborted stream for chat ${chatId}`);
|
|
328888
329037
|
} catch (error51) {
|
|
328889
|
-
|
|
329038
|
+
logger70.warn(`[Cleanup] Error aborting stream ${chatId}:`, error51);
|
|
328890
329039
|
}
|
|
328891
329040
|
}
|
|
328892
329041
|
activeStreams.clear();
|
|
328893
329042
|
activeStreamRuns.clear();
|
|
328894
329043
|
activeStreamId.clear();
|
|
328895
329044
|
partialResponses.clear();
|
|
328896
|
-
|
|
329045
|
+
logger70.log(`[Cleanup] All AI streams aborted`);
|
|
328897
329046
|
}
|
|
328898
329047
|
function cancelStreamForAutomation(chatId) {
|
|
328899
329048
|
const abortController = activeStreams.get(chatId);
|
|
328900
329049
|
if (abortController) {
|
|
328901
329050
|
abortController.abort(streamStopAbortReason(TEARDOWN_STREAM_STOP));
|
|
328902
329051
|
activeStreams.delete(chatId);
|
|
328903
|
-
|
|
329052
|
+
logger70.log(`[automation] Aborted stream for chat ${chatId}`);
|
|
328904
329053
|
}
|
|
328905
329054
|
killForegroundCommandsForChat(chatId);
|
|
328906
329055
|
cancelAllSubagentTasksForChat(chatId);
|
|
328907
329056
|
}
|
|
328908
|
-
var
|
|
329057
|
+
var import_electron_log73, logger70;
|
|
328909
329058
|
var init_stream_lifecycle = __esm({
|
|
328910
329059
|
"src/ipc/handlers/chat_stream/stream-lifecycle.ts"() {
|
|
328911
|
-
|
|
329060
|
+
import_electron_log73 = __toESM(require_src());
|
|
328912
329061
|
init_safe_sender();
|
|
328913
329062
|
init_stream_stop_sentinels();
|
|
328914
329063
|
init_thinking_tags();
|
|
@@ -328918,7 +329067,7 @@ var init_stream_lifecycle = __esm({
|
|
|
328918
329067
|
init_spawn_task();
|
|
328919
329068
|
init_stream_transport();
|
|
328920
329069
|
init_stream_state();
|
|
328921
|
-
|
|
329070
|
+
logger70 = import_electron_log73.default.scope("chat_stream_handlers");
|
|
328922
329071
|
}
|
|
328923
329072
|
});
|
|
328924
329073
|
|
|
@@ -329135,14 +329284,14 @@ function registerLifecycleHandlers(chatStreamHandler) {
|
|
|
329135
329284
|
if (abortController) {
|
|
329136
329285
|
abortController.abort(streamStopAbortReason(USER_CANCEL_STREAM_STOP));
|
|
329137
329286
|
activeStreams.delete(chatId);
|
|
329138
|
-
|
|
329287
|
+
logger71.log(`Aborted stream for chat ${chatId}`);
|
|
329139
329288
|
} else {
|
|
329140
|
-
|
|
329289
|
+
logger71.warn(`No active stream found for chat ${chatId}`);
|
|
329141
329290
|
}
|
|
329142
329291
|
const killed = killForegroundCommandsForChat(chatId);
|
|
329143
329292
|
const subagentsCancelled = cancelAllSubagentTasksForChat(chatId);
|
|
329144
329293
|
if (killed > 0 || subagentsCancelled > 0) {
|
|
329145
|
-
|
|
329294
|
+
logger71.log(
|
|
329146
329295
|
`[chat:cancel] Stopped ${killed} command(s) + ${subagentsCancelled} sub-agent(s) for chat ${chatId}`
|
|
329147
329296
|
);
|
|
329148
329297
|
}
|
|
@@ -329168,13 +329317,13 @@ function registerLifecycleHandlers(chatStreamHandler) {
|
|
|
329168
329317
|
ipcMain.handle("chat:abort", async (_4, chatId) => {
|
|
329169
329318
|
const controller = activeStreams.get(chatId);
|
|
329170
329319
|
if (controller) {
|
|
329171
|
-
|
|
329320
|
+
logger71.log(`[chat:abort] User cancelled stream for chat ${chatId}`);
|
|
329172
329321
|
controller.abort(streamStopAbortReason(USER_CANCEL_STREAM_STOP));
|
|
329173
329322
|
activeStreams.delete(chatId);
|
|
329174
329323
|
const killed = killForegroundCommandsForChat(chatId);
|
|
329175
329324
|
const subagentsCancelled = cancelAllSubagentTasksForChat(chatId);
|
|
329176
329325
|
if (killed > 0 || subagentsCancelled > 0) {
|
|
329177
|
-
|
|
329326
|
+
logger71.log(
|
|
329178
329327
|
`[chat:abort] Stopped ${killed} command(s) + ${subagentsCancelled} sub-agent(s) for chat ${chatId}`
|
|
329179
329328
|
);
|
|
329180
329329
|
}
|
|
@@ -329201,7 +329350,7 @@ function registerLifecycleHandlers(chatStreamHandler) {
|
|
|
329201
329350
|
await chatStreamHandler(event, cached4);
|
|
329202
329351
|
return { success: true };
|
|
329203
329352
|
} catch (error51) {
|
|
329204
|
-
|
|
329353
|
+
logger71.error("[chat:stream:reconnect] re-dispatch failed:", error51);
|
|
329205
329354
|
return {
|
|
329206
329355
|
success: false,
|
|
329207
329356
|
message: error51 instanceof Error ? error51.message : String(error51)
|
|
@@ -329235,7 +329384,7 @@ function registerLifecycleHandlers(chatStreamHandler) {
|
|
|
329235
329384
|
);
|
|
329236
329385
|
newModelContent = expanded !== newContent ? expanded : null;
|
|
329237
329386
|
} catch (e3) {
|
|
329238
|
-
|
|
329387
|
+
logger71.warn(
|
|
329239
329388
|
"Failed to regenerate model content for edited message:",
|
|
329240
329389
|
e3
|
|
329241
329390
|
);
|
|
@@ -329260,10 +329409,10 @@ function registerLifecycleHandlers(chatStreamHandler) {
|
|
|
329260
329409
|
) === "updated";
|
|
329261
329410
|
}
|
|
329262
329411
|
} catch (e3) {
|
|
329263
|
-
|
|
329412
|
+
logger71.warn("Failed to persist edited session message:", e3);
|
|
329264
329413
|
}
|
|
329265
329414
|
if (!persistedToSession) {
|
|
329266
|
-
|
|
329415
|
+
logger71.warn(
|
|
329267
329416
|
`[chat:edit-message] edit not persisted to session (chat ${chatId}, sessionRowId=${sessionRowId ?? "none"})`
|
|
329268
329417
|
);
|
|
329269
329418
|
safeSend(event.sender, "chat:activity", {
|
|
@@ -329280,18 +329429,18 @@ function registerLifecycleHandlers(chatStreamHandler) {
|
|
|
329280
329429
|
}
|
|
329281
329430
|
);
|
|
329282
329431
|
}
|
|
329283
|
-
var
|
|
329432
|
+
var import_electron_log74, logger71;
|
|
329284
329433
|
var init_lifecycle_handlers = __esm({
|
|
329285
329434
|
"src/ipc/handlers/chat_stream/lifecycle-handlers.ts"() {
|
|
329286
329435
|
init_electron_stub();
|
|
329287
|
-
|
|
329436
|
+
import_electron_log74 = __toESM(require_src());
|
|
329288
329437
|
init_safe_sender();
|
|
329289
329438
|
init_file_uploads_state();
|
|
329290
329439
|
init_background_commands();
|
|
329291
329440
|
init_spawn_task();
|
|
329292
329441
|
init_stream_stop_sentinels();
|
|
329293
329442
|
init_stream_state();
|
|
329294
|
-
|
|
329443
|
+
logger71 = import_electron_log74.default.scope("chat_stream_handlers");
|
|
329295
329444
|
}
|
|
329296
329445
|
});
|
|
329297
329446
|
|
|
@@ -329412,7 +329561,7 @@ function registerRevertHandlers() {
|
|
|
329412
329561
|
workspaceId: appId
|
|
329413
329562
|
});
|
|
329414
329563
|
if (!result2.success && result2.error) {
|
|
329415
|
-
|
|
329564
|
+
logger72.warn("Revert: performFullRevert:", result2.error);
|
|
329416
329565
|
}
|
|
329417
329566
|
return { success: true };
|
|
329418
329567
|
}
|
|
@@ -329623,10 +329772,10 @@ function registerRevertHandlers() {
|
|
|
329623
329772
|
}
|
|
329624
329773
|
);
|
|
329625
329774
|
}
|
|
329626
|
-
var
|
|
329775
|
+
var import_electron_log75, logger72;
|
|
329627
329776
|
var init_revert_handlers = __esm({
|
|
329628
329777
|
"src/ipc/handlers/chat_stream/revert-handlers.ts"() {
|
|
329629
|
-
|
|
329778
|
+
import_electron_log75 = __toESM(require_src());
|
|
329630
329779
|
init_drizzle_orm();
|
|
329631
329780
|
init_db2();
|
|
329632
329781
|
init_schema();
|
|
@@ -329635,7 +329784,7 @@ var init_revert_handlers = __esm({
|
|
|
329635
329784
|
init_snapshot_manager();
|
|
329636
329785
|
init_stream_misc();
|
|
329637
329786
|
init_electron_stub();
|
|
329638
|
-
|
|
329787
|
+
logger72 = import_electron_log75.default.scope("chat_stream_handlers");
|
|
329639
329788
|
}
|
|
329640
329789
|
});
|
|
329641
329790
|
|
|
@@ -329683,7 +329832,7 @@ function registerSessionHandlers() {
|
|
|
329683
329832
|
payload.answer
|
|
329684
329833
|
);
|
|
329685
329834
|
if (!isStreamTransportId2(payload.chatId)) {
|
|
329686
|
-
|
|
329835
|
+
logger73.warn(
|
|
329687
329836
|
`[ask_user] Answer submitted for non-ephemeral chat ${payload.chatId} \u2014 ignored`
|
|
329688
329837
|
);
|
|
329689
329838
|
return { success: false };
|
|
@@ -329704,7 +329853,7 @@ function registerSessionHandlers() {
|
|
|
329704
329853
|
);
|
|
329705
329854
|
qaRowId = row?.id;
|
|
329706
329855
|
} catch (err2) {
|
|
329707
|
-
|
|
329856
|
+
logger73.warn("[ask_user] Could not persist Q&A to session:", err2);
|
|
329708
329857
|
}
|
|
329709
329858
|
if (!insertAskUserAnswerUserMessage2(payload.chatId, content, qaRowId)) {
|
|
329710
329859
|
return { success: false };
|
|
@@ -329749,11 +329898,11 @@ function registerSessionHandlers() {
|
|
|
329749
329898
|
text: takeUserInterjectionsAsPrompt(Number(chatId))
|
|
329750
329899
|
}));
|
|
329751
329900
|
}
|
|
329752
|
-
var
|
|
329901
|
+
var import_electron_log76, logger73;
|
|
329753
329902
|
var init_session_handlers = __esm({
|
|
329754
329903
|
"src/ipc/handlers/chat_stream/session-handlers.ts"() {
|
|
329755
329904
|
init_electron_stub();
|
|
329756
|
-
|
|
329905
|
+
import_electron_log76 = __toESM(require_src());
|
|
329757
329906
|
init_settings();
|
|
329758
329907
|
init_work_mode();
|
|
329759
329908
|
init_safe_sender();
|
|
@@ -329761,7 +329910,7 @@ var init_session_handlers = __esm({
|
|
|
329761
329910
|
init_stream_state();
|
|
329762
329911
|
init_user_interjections();
|
|
329763
329912
|
init_broadcast_all_windows();
|
|
329764
|
-
|
|
329913
|
+
logger73 = import_electron_log76.default.scope("chat_stream_handlers");
|
|
329765
329914
|
}
|
|
329766
329915
|
});
|
|
329767
329916
|
|
|
@@ -330032,7 +330181,7 @@ ${systemPrompt}`;
|
|
|
330032
330181
|
|
|
330033
330182
|
${blob2}`;
|
|
330034
330183
|
}
|
|
330035
|
-
|
|
330184
|
+
logger74.info(
|
|
330036
330185
|
`[ContextAssembler] mode=${effectiveWorkMode} cacheHit=${assembledContext.cache.hit} sections=${assembledContext.assembledPromptSections.filter((s3) => s3.included).length}/${assembledContext.assembledPromptSections.length}`
|
|
330037
330186
|
);
|
|
330038
330187
|
const trimReport = [
|
|
@@ -330040,7 +330189,7 @@ ${blob2}`;
|
|
|
330040
330189
|
...assembledContext.trimReport
|
|
330041
330190
|
];
|
|
330042
330191
|
if (trimReport.length > 0) {
|
|
330043
|
-
|
|
330192
|
+
logger74.info(`[ContextAssembler] trims: ${trimReport.join(" | ")}`);
|
|
330044
330193
|
}
|
|
330045
330194
|
safeSend(event.sender, "chat:context-report", {
|
|
330046
330195
|
chatId: req.chatId,
|
|
@@ -330110,15 +330259,15 @@ This conversation includes one or more image attachments. When the user uploads
|
|
|
330110
330259
|
otherCodebasePrefix
|
|
330111
330260
|
};
|
|
330112
330261
|
}
|
|
330113
|
-
var
|
|
330262
|
+
var import_electron_log77, logger74;
|
|
330114
330263
|
var init_prompt_bundle = __esm({
|
|
330115
330264
|
"src/ipc/handlers/chat_stream/turn-runner/prompt-bundle.ts"() {
|
|
330116
|
-
|
|
330265
|
+
import_electron_log77 = __toESM(require_src());
|
|
330117
330266
|
init_ContextAssembler();
|
|
330118
330267
|
init_system_reminder();
|
|
330119
330268
|
init_summarize_chat_system_prompt();
|
|
330120
330269
|
init_safe_sender();
|
|
330121
|
-
|
|
330270
|
+
logger74 = import_electron_log77.default.scope("chat_stream_handlers");
|
|
330122
330271
|
}
|
|
330123
330272
|
});
|
|
330124
330273
|
|
|
@@ -330259,7 +330408,7 @@ function emitModelCompactionActivity(sender, chatId, outcome, reason, episodeId)
|
|
|
330259
330408
|
});
|
|
330260
330409
|
if (outcome.success) {
|
|
330261
330410
|
if (outcome.strategy === "summarized" && !outcome.summaryPersisted) {
|
|
330262
|
-
|
|
330411
|
+
logger75.warn(
|
|
330263
330412
|
`[compaction] chat ${chatId}: summary not persisted \u2014 reopened session may re-load full history`
|
|
330264
330413
|
);
|
|
330265
330414
|
safeSend(sender, "chat:activity", {
|
|
@@ -330274,12 +330423,12 @@ function emitModelCompactionActivity(sender, chatId, outcome, reason, episodeId)
|
|
|
330274
330423
|
}
|
|
330275
330424
|
}
|
|
330276
330425
|
}
|
|
330277
|
-
var
|
|
330426
|
+
var import_electron_log78, logger75;
|
|
330278
330427
|
var init_compaction_activity = __esm({
|
|
330279
330428
|
"src/ipc/handlers/chat_stream/compaction-activity.ts"() {
|
|
330280
|
-
|
|
330429
|
+
import_electron_log78 = __toESM(require_src());
|
|
330281
330430
|
init_safe_sender();
|
|
330282
|
-
|
|
330431
|
+
logger75 = import_electron_log78.default.scope("chat_stream_handlers");
|
|
330283
330432
|
}
|
|
330284
330433
|
});
|
|
330285
330434
|
|
|
@@ -330316,7 +330465,7 @@ async function runContextAssembly(state, deps) {
|
|
|
330316
330465
|
if (loggedOnce[kind]) return;
|
|
330317
330466
|
loggedOnce[kind] = true;
|
|
330318
330467
|
const pct = est / contextWindowTokens * 100;
|
|
330319
|
-
|
|
330468
|
+
logger76.info(
|
|
330320
330469
|
`[compaction] Context at ${pct.toFixed(1)}% (${est}tokens / ${contextWindowTokens}tokens) \u2014 ${kind}`
|
|
330321
330470
|
);
|
|
330322
330471
|
};
|
|
@@ -330426,7 +330575,7 @@ async function runContextAssembly(state, deps) {
|
|
|
330426
330575
|
const fillBefore = dispatchEstimate / contextWindowTokens;
|
|
330427
330576
|
if (dispatchEstimate > usableTokens) {
|
|
330428
330577
|
logCompactionLine(dispatchEstimate, "compact");
|
|
330429
|
-
|
|
330578
|
+
logger76.log(
|
|
330430
330579
|
`[stream:${req.chatId}] pre-dispatch context compaction fill=${(fillBefore * 100).toFixed(1)}% est=${dispatchEstimate} usable=${usableTokens} window=${contextWindowTokens}`
|
|
330431
330580
|
);
|
|
330432
330581
|
const activityBase = `predispatch-compact-${req.chatId}-${Date.now()}`;
|
|
@@ -330449,7 +330598,7 @@ async function runContextAssembly(state, deps) {
|
|
|
330449
330598
|
if (!cr2.ok) break;
|
|
330450
330599
|
}
|
|
330451
330600
|
} catch (e3) {
|
|
330452
|
-
|
|
330601
|
+
logger76.warn(`[stream:${req.chatId}] pre-dispatch compaction failed`, e3);
|
|
330453
330602
|
}
|
|
330454
330603
|
emitCompactionActivity(event.sender, req.chatId, {
|
|
330455
330604
|
id: activityBase,
|
|
@@ -330467,7 +330616,7 @@ async function runContextAssembly(state, deps) {
|
|
|
330467
330616
|
proactiveContextReminderForStream = `Context is at ${livePct}% capacity. Consider calling compress_context before your next heavy tool use.`;
|
|
330468
330617
|
}
|
|
330469
330618
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
330470
|
-
|
|
330619
|
+
logger76.info(
|
|
330471
330620
|
`[DIAG_146] per-dispatch context-report chat=${req.chatId} dispatchedTokens=${dispatchEstimate} window=${contextWindowTokens}`
|
|
330472
330621
|
);
|
|
330473
330622
|
}
|
|
@@ -330492,10 +330641,10 @@ async function runContextAssembly(state, deps) {
|
|
|
330492
330641
|
proactiveContextReminderForStream
|
|
330493
330642
|
};
|
|
330494
330643
|
}
|
|
330495
|
-
var
|
|
330644
|
+
var import_electron_log79, logger76;
|
|
330496
330645
|
var init_context_assembly = __esm({
|
|
330497
330646
|
"src/ipc/handlers/chat_stream/turn-runner/context-assembly.ts"() {
|
|
330498
|
-
|
|
330647
|
+
import_electron_log79 = __toESM(require_src());
|
|
330499
330648
|
init_get_model_client();
|
|
330500
330649
|
init_safe_sender();
|
|
330501
330650
|
init_token_utils();
|
|
@@ -330503,7 +330652,7 @@ var init_context_assembly = __esm({
|
|
|
330503
330652
|
init_context_budget_tracker();
|
|
330504
330653
|
init_compaction_activity();
|
|
330505
330654
|
init_tier_context_budget();
|
|
330506
|
-
|
|
330655
|
+
logger76 = import_electron_log79.default.scope("chat_stream_handlers");
|
|
330507
330656
|
}
|
|
330508
330657
|
});
|
|
330509
330658
|
|
|
@@ -331260,7 +331409,7 @@ function globToRegExp(glob) {
|
|
|
331260
331409
|
function compileRule(raw) {
|
|
331261
331410
|
const m3 = RULE_SHAPE.exec(raw.trim());
|
|
331262
331411
|
if (!m3) {
|
|
331263
|
-
|
|
331412
|
+
logger77.warn(`Ignoring malformed permission rule: ${JSON.stringify(raw)}`);
|
|
331264
331413
|
return null;
|
|
331265
331414
|
}
|
|
331266
331415
|
return {
|
|
@@ -331315,16 +331464,16 @@ function loadRulesetFile(file2) {
|
|
|
331315
331464
|
fs43.readFileSync(file2, "utf8")
|
|
331316
331465
|
);
|
|
331317
331466
|
if (Array.isArray(parsed.ask)) {
|
|
331318
|
-
|
|
331467
|
+
logger77.warn(
|
|
331319
331468
|
`${file2} contains an "ask" list \u2014 that key is NOT supported and is ignored. Use "deny" to block a call outright; mutating tools already prompt for approval.`
|
|
331320
331469
|
);
|
|
331321
331470
|
}
|
|
331322
331471
|
const compiled = compileRuleset(parsed);
|
|
331323
331472
|
cache6.set(file2, { mtimeMs, compiled });
|
|
331324
|
-
|
|
331473
|
+
logger77.log(`Loaded ${compiled.deny.length} deny rule(s) from ${file2}`);
|
|
331325
331474
|
return compiled;
|
|
331326
331475
|
} catch (e3) {
|
|
331327
|
-
|
|
331476
|
+
logger77.warn(`Failed to parse ${file2}: ${String(e3)} \u2014 treating as empty`);
|
|
331328
331477
|
cache6.delete(file2);
|
|
331329
331478
|
return EMPTY;
|
|
331330
331479
|
}
|
|
@@ -331343,11 +331492,11 @@ function loadEffectiveRuleset(workspacePath) {
|
|
|
331343
331492
|
loadWorkspaceRuleset(workspacePath)
|
|
331344
331493
|
);
|
|
331345
331494
|
}
|
|
331346
|
-
var
|
|
331495
|
+
var import_electron_log80, logger77, EMPTY, RULE_SHAPE, cache6, globalAtlarixDirOverride;
|
|
331347
331496
|
var init_ruleset = __esm({
|
|
331348
331497
|
"src/lib/tools/permissions/ruleset.ts"() {
|
|
331349
|
-
|
|
331350
|
-
|
|
331498
|
+
import_electron_log80 = __toESM(require_src());
|
|
331499
|
+
logger77 = import_electron_log80.default.scope("permission-ruleset");
|
|
331351
331500
|
EMPTY = { deny: [] };
|
|
331352
331501
|
RULE_SHAPE = /^([a-z0-9_*?]+)(?:\((.*)\))?$/i;
|
|
331353
331502
|
cache6 = /* @__PURE__ */ new Map();
|
|
@@ -331473,10 +331622,10 @@ function waitForMcpAuth(serverId, opts) {
|
|
|
331473
331622
|
else pendingMcpAuthWaiters.set(serverId, [entry]);
|
|
331474
331623
|
});
|
|
331475
331624
|
}
|
|
331476
|
-
var
|
|
331625
|
+
var import_electron_log81, logger78, pendingMcpAuthWaiters;
|
|
331477
331626
|
var init_mcp_oauth_service = __esm({
|
|
331478
331627
|
"src/lib/mcp/mcp-oauth-service.ts"() {
|
|
331479
|
-
|
|
331628
|
+
import_electron_log81 = __toESM(require_src());
|
|
331480
331629
|
init_electron_stub();
|
|
331481
331630
|
init_auth2();
|
|
331482
331631
|
init_streamableHttp();
|
|
@@ -331486,7 +331635,7 @@ var init_mcp_oauth_service = __esm({
|
|
|
331486
331635
|
init_oauth_loopback_server();
|
|
331487
331636
|
init_oauth_session_store();
|
|
331488
331637
|
init_oauth_token_utils();
|
|
331489
|
-
|
|
331638
|
+
logger78 = import_electron_log81.default.scope("mcp-oauth");
|
|
331490
331639
|
pendingMcpAuthWaiters = /* @__PURE__ */ new Map();
|
|
331491
331640
|
}
|
|
331492
331641
|
});
|
|
@@ -331599,7 +331748,7 @@ async function runToolExecute(toolName, executeArgs, sender, chatId, streamOpts)
|
|
|
331599
331748
|
const canonicalName = ToolRegistry.resolveName(toolName);
|
|
331600
331749
|
const decision = evaluateRuleset(ruleset, toolName, executeArgs) ?? (canonicalName !== toolName ? evaluateRuleset(ruleset, canonicalName, executeArgs) : null);
|
|
331601
331750
|
if (decision?.kind === "deny") {
|
|
331602
|
-
|
|
331751
|
+
logger79.warn(
|
|
331603
331752
|
`[ruleset] ${toolName} blocked by permission rule: ${decision.rule}`
|
|
331604
331753
|
);
|
|
331605
331754
|
return JSON.stringify({
|
|
@@ -331662,10 +331811,10 @@ function attachSearchRoutingActivity(execArgs, sender, chatId) {
|
|
|
331662
331811
|
});
|
|
331663
331812
|
};
|
|
331664
331813
|
}
|
|
331665
|
-
var
|
|
331814
|
+
var import_electron_log82, logger79;
|
|
331666
331815
|
var init_tool_execute = __esm({
|
|
331667
331816
|
"src/ipc/handlers/chat_stream/tool-execute.ts"() {
|
|
331668
|
-
|
|
331817
|
+
import_electron_log82 = __toESM(require_src());
|
|
331669
331818
|
init_electron_stub();
|
|
331670
331819
|
init_ruleset();
|
|
331671
331820
|
init_mcp_consent();
|
|
@@ -331674,7 +331823,7 @@ var init_tool_execute = __esm({
|
|
|
331674
331823
|
init_run_command_guidance();
|
|
331675
331824
|
init_mutation_verify();
|
|
331676
331825
|
init_safe_sender();
|
|
331677
|
-
|
|
331826
|
+
logger79 = import_electron_log82.default.scope("chat_stream_handlers");
|
|
331678
331827
|
}
|
|
331679
331828
|
});
|
|
331680
331829
|
|
|
@@ -331896,7 +332045,7 @@ async function processStreamChunks({
|
|
|
331896
332045
|
}) : firstByteTimeoutMs;
|
|
331897
332046
|
if (sinceChunk >= budget) {
|
|
331898
332047
|
stalled = true;
|
|
331899
|
-
|
|
332048
|
+
logger80.warn(
|
|
331900
332049
|
`[stream] chat ${chatId} stalled \u2014 no chunk for ${sinceChunk}ms (${hasReceivedChunk ? "idle" : "first-byte"} budget ${budget}ms)`
|
|
331901
332050
|
);
|
|
331902
332051
|
onStreamStall?.();
|
|
@@ -331905,7 +332054,7 @@ async function processStreamChunks({
|
|
|
331905
332054
|
}
|
|
331906
332055
|
if (streamDebug && now2 - lastHeartbeatLogAt >= HEARTBEAT_LOG_INTERVAL_MS) {
|
|
331907
332056
|
lastHeartbeatLogAt = now2;
|
|
331908
|
-
|
|
332057
|
+
logger80.log(
|
|
331909
332058
|
`[stream heartbeat] chat ${chatId} active \u2014 ${sinceChunk}ms since last chunk (parts: ${JSON.stringify(partCounts)})`
|
|
331910
332059
|
);
|
|
331911
332060
|
}
|
|
@@ -331945,7 +332094,7 @@ async function processStreamChunks({
|
|
|
331945
332094
|
if (part.type === "error") {
|
|
331946
332095
|
sawStreamError = true;
|
|
331947
332096
|
const err2 = part.error;
|
|
331948
|
-
|
|
332097
|
+
logger80.warn(
|
|
331949
332098
|
`[stream] top-level stream error part: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
331950
332099
|
);
|
|
331951
332100
|
}
|
|
@@ -331955,7 +332104,7 @@ async function processStreamChunks({
|
|
|
331955
332104
|
part.rawFinishReason
|
|
331956
332105
|
);
|
|
331957
332106
|
if (rawFinishFail) {
|
|
331958
|
-
|
|
332107
|
+
logger80.warn(
|
|
331959
332108
|
`[stream] chat ${chatId} finish-step carried a provider error as its finish reason: ${rawFinishFail}`
|
|
331960
332109
|
);
|
|
331961
332110
|
throw new ProviderFinishReasonError(rawFinishFail);
|
|
@@ -331971,7 +332120,7 @@ async function processStreamChunks({
|
|
|
331971
332120
|
part.rawFinishReason
|
|
331972
332121
|
);
|
|
331973
332122
|
if (rawFinishFail) {
|
|
331974
|
-
|
|
332123
|
+
logger80.warn(
|
|
331975
332124
|
`[stream] chat ${chatId} finish carried a provider error as its finish reason: ${rawFinishFail}`
|
|
331976
332125
|
);
|
|
331977
332126
|
throw new ProviderFinishReasonError(rawFinishFail);
|
|
@@ -332024,7 +332173,7 @@ async function processStreamChunks({
|
|
|
332024
332173
|
if (text3 && detectHallucinatedAtlarixToolTag(text3) && !loggedHallucinatedTag) {
|
|
332025
332174
|
loggedHallucinatedTag = true;
|
|
332026
332175
|
if (streamDebug) {
|
|
332027
|
-
|
|
332176
|
+
logger80.warn(
|
|
332028
332177
|
`[stream] chat ${chatId}: model emitted raw Atlarix tool tag in text-delta`
|
|
332029
332178
|
);
|
|
332030
332179
|
}
|
|
@@ -332105,16 +332254,16 @@ ${content}
|
|
|
332105
332254
|
fullResponse = await processResponseChunkUpdate2({ fullResponse });
|
|
332106
332255
|
if (abortController.signal.aborted) {
|
|
332107
332256
|
if (streamDebug) {
|
|
332108
|
-
|
|
332257
|
+
logger80.log(`Stream for chat ${chatId} was aborted`);
|
|
332109
332258
|
}
|
|
332110
332259
|
break;
|
|
332111
332260
|
}
|
|
332112
332261
|
}
|
|
332113
332262
|
} catch (err2) {
|
|
332114
332263
|
if (abortController.signal.aborted && stalled) {
|
|
332115
|
-
|
|
332264
|
+
logger80.warn(`Stream for chat ${chatId} aborted due to stall`);
|
|
332116
332265
|
} else if (isNoUsableModelOutputError(err2) && !abortController.signal.aborted) {
|
|
332117
|
-
|
|
332266
|
+
logger80.warn(
|
|
332118
332267
|
`Stream for chat ${chatId} produced no usable text (mapped to fallback):`,
|
|
332119
332268
|
err2
|
|
332120
332269
|
);
|
|
@@ -332127,7 +332276,7 @@ ${content}
|
|
|
332127
332276
|
} finally {
|
|
332128
332277
|
clearInterval(stallTimer);
|
|
332129
332278
|
if (streamDebug) {
|
|
332130
|
-
|
|
332279
|
+
logger80.log(
|
|
332131
332280
|
`[stream heartbeat] chat ${chatId} ended \u2014 duration ${Date.now() - streamStartedAt}ms stalled=${stalled} finish=${finishReason ?? "n/a"} parts=${JSON.stringify(partCounts)}`
|
|
332132
332281
|
);
|
|
332133
332282
|
}
|
|
@@ -332157,10 +332306,10 @@ ${content}
|
|
|
332157
332306
|
}
|
|
332158
332307
|
return { fullResponse, incrementalResponse, stalled, finishReason };
|
|
332159
332308
|
}
|
|
332160
|
-
var
|
|
332309
|
+
var import_electron_log83, logger80, STREAM_STALL_TIMEOUT_MS, STREAM_FIRST_BYTE_TIMEOUT_MS, HEARTBEAT_LOG_INTERVAL_MS, TOOL_INPUT_PROGRESS_INTERVAL_MS, ADAPTIVE_STALL_MIN_SAMPLES, ADAPTIVE_STALL_FLOOR_MS, ADAPTIVE_STALL_K, MAX_GAP_SAMPLES, TOOL_INPUT_DELTA_EMIT_MS;
|
|
332161
332310
|
var init_stream_chunk_tags = __esm({
|
|
332162
332311
|
"src/ipc/utils/stream_chunk_tags.ts"() {
|
|
332163
|
-
|
|
332312
|
+
import_electron_log83 = __toESM(require_src());
|
|
332164
332313
|
init_texts();
|
|
332165
332314
|
init_no_usable_model_output();
|
|
332166
332315
|
init_cleanFullResponse();
|
|
@@ -332168,7 +332317,7 @@ var init_stream_chunk_tags = __esm({
|
|
|
332168
332317
|
init_stream_debug();
|
|
332169
332318
|
init_tool_result_status();
|
|
332170
332319
|
init_provider_finish_error();
|
|
332171
|
-
|
|
332320
|
+
logger80 = import_electron_log83.default.scope("stream-chunk-tags");
|
|
332172
332321
|
STREAM_STALL_TIMEOUT_MS = 6e5;
|
|
332173
332322
|
STREAM_FIRST_BYTE_TIMEOUT_MS = 18e4;
|
|
332174
332323
|
HEARTBEAT_LOG_INTERVAL_MS = 15e3;
|
|
@@ -332327,7 +332476,7 @@ async function runStreamRoundWithEmptyOutputRetry(ctx, deps, params) {
|
|
|
332327
332476
|
if (networkAttempt >= RECONNECT_DELAYS_MS.length) return null;
|
|
332328
332477
|
const delay3 = jitteredDelay(networkAttempt, retryAfterMs(fault));
|
|
332329
332478
|
networkAttempt++;
|
|
332330
|
-
|
|
332479
|
+
logger81.warn(
|
|
332331
332480
|
`[stream] Network error after ${resumeMessages.length} completed step-message(s) \u2014 resuming from them after ${delay3}ms (attempt ${networkAttempt}/${RECONNECT_DELAYS_MS.length}): ${fault instanceof Error ? fault.message : String(fault)}`
|
|
332332
332481
|
);
|
|
332333
332482
|
sentryAddBreadcrumbSafe({
|
|
@@ -332369,7 +332518,7 @@ async function runStreamRoundWithEmptyOutputRetry(ctx, deps, params) {
|
|
|
332369
332518
|
}
|
|
332370
332519
|
const resumeMessages = bundle.getResumeMessages?.() ?? [];
|
|
332371
332520
|
if (resumeMessages.length > 0) {
|
|
332372
|
-
|
|
332521
|
+
logger81.warn(
|
|
332373
332522
|
`[stream] Stalled after ${resumeMessages.length} completed step-message(s) \u2014 resuming from partial instead of restarting`
|
|
332374
332523
|
);
|
|
332375
332524
|
sentryAddBreadcrumbSafe({
|
|
@@ -332387,7 +332536,7 @@ async function runStreamRoundWithEmptyOutputRetry(ctx, deps, params) {
|
|
|
332387
332536
|
if (networkAttempt < RECONNECT_DELAYS_MS.length) {
|
|
332388
332537
|
const delay3 = jitteredDelay(networkAttempt);
|
|
332389
332538
|
networkAttempt++;
|
|
332390
|
-
|
|
332539
|
+
logger81.warn(
|
|
332391
332540
|
`[stream] Stalled (no chunks), retrying after ${delay3}ms (attempt ${networkAttempt}/${RECONNECT_DELAYS_MS.length})`
|
|
332392
332541
|
);
|
|
332393
332542
|
sentryAddBreadcrumbSafe({
|
|
@@ -332430,13 +332579,13 @@ async function runStreamRoundWithEmptyOutputRetry(ctx, deps, params) {
|
|
|
332430
332579
|
const recordedNetworkError = bundle?.getRecordedNetworkError?.();
|
|
332431
332580
|
const err2 = recordedNetworkError != null && isEmptyOutputStreamError(caught) ? recordedNetworkError : caught;
|
|
332432
332581
|
if (err2 !== caught) {
|
|
332433
|
-
|
|
332582
|
+
logger81.warn(
|
|
332434
332583
|
"[stream] The SDK reported 'no output generated' for a transport failure \u2014 retrying as a network error instead"
|
|
332435
332584
|
);
|
|
332436
332585
|
}
|
|
332437
332586
|
if (isForcedToolChoiceRejection(err2) && !ctx.forcedToolChoiceRejected) {
|
|
332438
332587
|
ctx.forcedToolChoiceRejected = true;
|
|
332439
|
-
|
|
332588
|
+
logger81.warn(
|
|
332440
332589
|
`[stream] Provider rejected the forced tool_choice \u2014 retrying with injected delivery: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
332441
332590
|
);
|
|
332442
332591
|
sentryAddBreadcrumbSafe({
|
|
@@ -332449,7 +332598,7 @@ async function runStreamRoundWithEmptyOutputRetry(ctx, deps, params) {
|
|
|
332449
332598
|
}
|
|
332450
332599
|
if (isEmptyOutputStreamError(err2) && emptyOutputAttempt < MAX_STREAM_EMPTY_OUTPUT_ATTEMPTS - 1) {
|
|
332451
332600
|
emptyOutputAttempt++;
|
|
332452
|
-
|
|
332601
|
+
logger81.warn(
|
|
332453
332602
|
`[stream] Empty output on attempt ${emptyOutputAttempt}/${MAX_STREAM_EMPTY_OUTPUT_ATTEMPTS}, retrying after ${STREAM_EMPTY_OUTPUT_RETRY_DELAY_MS}ms...`
|
|
332454
332603
|
);
|
|
332455
332604
|
sentryAddBreadcrumbSafe({
|
|
@@ -332482,7 +332631,7 @@ async function runStreamRoundWithEmptyOutputRetry(ctx, deps, params) {
|
|
|
332482
332631
|
const retryAfter = retryAfterMs(err2);
|
|
332483
332632
|
const delay3 = jitteredDelay(networkAttempt, retryAfter);
|
|
332484
332633
|
networkAttempt++;
|
|
332485
|
-
|
|
332634
|
+
logger81.warn(
|
|
332486
332635
|
`[stream] Network error on attempt ${networkAttempt}/${RECONNECT_DELAYS_MS.length}, retrying after ${delay3}ms${retryAfter != null ? " (Retry-After)" : ""}: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
332487
332636
|
);
|
|
332488
332637
|
sentryAddBreadcrumbSafe({
|
|
@@ -332509,17 +332658,17 @@ async function runStreamRoundWithEmptyOutputRetry(ctx, deps, params) {
|
|
|
332509
332658
|
}
|
|
332510
332659
|
throw new Error("runStreamRoundWithEmptyOutputRetry: unreachable");
|
|
332511
332660
|
}
|
|
332512
|
-
var
|
|
332661
|
+
var import_electron_log84, logger81, MAX_STREAM_EMPTY_OUTPUT_ATTEMPTS, STREAM_EMPTY_OUTPUT_RETRY_DELAY_MS, isEmptyOutputStreamError;
|
|
332513
332662
|
var init_round_retry = __esm({
|
|
332514
332663
|
"src/ipc/handlers/chat_stream/turn-runner/round-retry.ts"() {
|
|
332515
|
-
|
|
332664
|
+
import_electron_log84 = __toESM(require_src());
|
|
332516
332665
|
init_stream_chunk_tags();
|
|
332517
332666
|
init_safe_sender();
|
|
332518
332667
|
init_no_usable_model_output();
|
|
332519
332668
|
init_network_retry();
|
|
332520
332669
|
init_sentry_safe();
|
|
332521
332670
|
init_stream_state();
|
|
332522
|
-
|
|
332671
|
+
logger81 = import_electron_log84.default.scope("chat_stream_handlers");
|
|
332523
332672
|
MAX_STREAM_EMPTY_OUTPUT_ATTEMPTS = 2;
|
|
332524
332673
|
STREAM_EMPTY_OUTPUT_RETRY_DELAY_MS = 1e3;
|
|
332525
332674
|
isEmptyOutputStreamError = isNoUsableModelOutputError;
|
|
@@ -332731,7 +332880,7 @@ async function deliverInterjectionsToTranscript(args2) {
|
|
|
332731
332880
|
);
|
|
332732
332881
|
rowId = row?.id;
|
|
332733
332882
|
} catch (err2) {
|
|
332734
|
-
|
|
332883
|
+
logger82.warn(
|
|
332735
332884
|
`[interjection] could not persist to session: ${String(err2)}`
|
|
332736
332885
|
);
|
|
332737
332886
|
}
|
|
@@ -332749,15 +332898,15 @@ async function deliverInterjectionsToTranscript(args2) {
|
|
|
332749
332898
|
messages: [...chat?.messages ?? []]
|
|
332750
332899
|
});
|
|
332751
332900
|
} catch (err2) {
|
|
332752
|
-
|
|
332901
|
+
logger82.warn(`[interjection] transcript insert failed: ${String(err2)}`);
|
|
332753
332902
|
}
|
|
332754
332903
|
}
|
|
332755
|
-
var
|
|
332904
|
+
var import_electron_log85, logger82;
|
|
332756
332905
|
var init_interjection_delivery = __esm({
|
|
332757
332906
|
"src/ipc/handlers/chat_stream/interjection-delivery.ts"() {
|
|
332758
|
-
|
|
332907
|
+
import_electron_log85 = __toESM(require_src());
|
|
332759
332908
|
init_safe_sender();
|
|
332760
|
-
|
|
332909
|
+
logger82 = import_electron_log85.default.scope("user-interjections");
|
|
332761
332910
|
}
|
|
332762
332911
|
});
|
|
332763
332912
|
|
|
@@ -332779,13 +332928,13 @@ function perfReportOnce(key, label) {
|
|
|
332779
332928
|
const start = marks.get(key);
|
|
332780
332929
|
if (start == null) return;
|
|
332781
332930
|
reported.add(key);
|
|
332782
|
-
|
|
332931
|
+
logger83.info(`[perf] ${label}: ${Date.now() - start}ms`);
|
|
332783
332932
|
}
|
|
332784
|
-
var
|
|
332933
|
+
var import_electron_log86, logger83, marks, reported;
|
|
332785
332934
|
var init_perf_marks = __esm({
|
|
332786
332935
|
"src/lib/perf-marks.ts"() {
|
|
332787
|
-
|
|
332788
|
-
|
|
332936
|
+
import_electron_log86 = __toESM(require_src());
|
|
332937
|
+
logger83 = import_electron_log86.default.scope("perf");
|
|
332789
332938
|
marks = /* @__PURE__ */ new Map();
|
|
332790
332939
|
reported = /* @__PURE__ */ new Set();
|
|
332791
332940
|
}
|
|
@@ -332846,7 +332995,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
332846
332995
|
abortController
|
|
332847
332996
|
} = deps;
|
|
332848
332997
|
const forceCollectOnWake = deps.forceCollectOnWake && !ctx.forcedToolChoiceRejected;
|
|
332849
|
-
|
|
332998
|
+
logger84.log("sending AI request");
|
|
332850
332999
|
const optionsModel = getEffectiveModelForOptions(settings);
|
|
332851
333000
|
const thinkingTier = enableNativeReasoning;
|
|
332852
333001
|
const maxOutputTokens = await preflight.time(
|
|
@@ -332865,7 +333014,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
332865
333014
|
provider: JSON.parse(pinJson)
|
|
332866
333015
|
};
|
|
332867
333016
|
} catch (e3) {
|
|
332868
|
-
|
|
333017
|
+
logger84.warn(
|
|
332869
333018
|
`Ignoring invalid ATLARIX_OPENROUTER_PROVIDER_JSON: ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
332870
333019
|
);
|
|
332871
333020
|
}
|
|
@@ -332968,7 +333117,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
332968
333117
|
]
|
|
332969
333118
|
};
|
|
332970
333119
|
}
|
|
332971
|
-
|
|
333120
|
+
logger84.log(
|
|
332972
333121
|
`[native-web-search] ${nativeWeb.kind} active (${modelClient.builtinProviderId}); dropped client tools: ${[...reserved].join(", ")}`
|
|
332973
333122
|
);
|
|
332974
333123
|
}
|
|
@@ -333079,22 +333228,22 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333079
333228
|
ctx.pendingEmptyOutputNudge = null;
|
|
333080
333229
|
const interjections = takePendingUserInterjections(req.chatId);
|
|
333081
333230
|
if (correction) {
|
|
333082
|
-
|
|
333231
|
+
logger84.log(
|
|
333083
333232
|
`[repetition] injecting mid-round correction (chat ${req.chatId})`
|
|
333084
333233
|
);
|
|
333085
333234
|
}
|
|
333086
333235
|
if (bgResults) {
|
|
333087
|
-
|
|
333236
|
+
logger84.log(
|
|
333088
333237
|
`[background-command] injecting finished result (chat ${req.chatId})`
|
|
333089
333238
|
);
|
|
333090
333239
|
}
|
|
333091
333240
|
if (subagentResults) {
|
|
333092
|
-
|
|
333241
|
+
logger84.log(
|
|
333093
333242
|
`[background-subagent] injecting finished result (chat ${req.chatId})`
|
|
333094
333243
|
);
|
|
333095
333244
|
}
|
|
333096
333245
|
if (interjections?.length) {
|
|
333097
|
-
|
|
333246
|
+
logger84.log(
|
|
333098
333247
|
`[interjection] delivering ${interjections.length} mid-turn user message(s) (chat ${req.chatId}, step ${stepNumber})`
|
|
333099
333248
|
);
|
|
333100
333249
|
}
|
|
@@ -333239,7 +333388,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333239
333388
|
ctx.turnActualCostUsd += orUsage.cost;
|
|
333240
333389
|
}
|
|
333241
333390
|
if (typeof cacheRead === "number" && cacheRead > 0 || typeof cacheWrite === "number" && cacheWrite > 0) {
|
|
333242
|
-
|
|
333391
|
+
logger84.log(
|
|
333243
333392
|
`[prompt-cache] chat ${req.chatId}: read=${cacheRead ?? 0} write=${cacheWrite ?? 0} input=${response.usage?.inputTokens ?? "?"}`
|
|
333244
333393
|
);
|
|
333245
333394
|
}
|
|
@@ -333255,18 +333404,18 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333255
333404
|
}
|
|
333256
333405
|
if (typeof totalTokens === "number" && totalTokens > 0) {
|
|
333257
333406
|
ctx.maxTokensUsed = Math.max(ctx.maxTokensUsed ?? 0, totalTokens);
|
|
333258
|
-
|
|
333407
|
+
logger84.log(
|
|
333259
333408
|
`Total tokens used (aggregated for message ${placeholderAssistantMessage.id}): ${ctx.maxTokensUsed}`
|
|
333260
333409
|
);
|
|
333261
333410
|
} else {
|
|
333262
|
-
|
|
333411
|
+
logger84.log(
|
|
333263
333412
|
`Total tokens used (aggregated for message ${placeholderAssistantMessage.id}): unavailable (no total or prompt/completion counts from provider)`
|
|
333264
333413
|
);
|
|
333265
333414
|
}
|
|
333266
333415
|
},
|
|
333267
333416
|
onError: (error51) => {
|
|
333268
333417
|
if (isNoUsableModelOutputError(error51)) {
|
|
333269
|
-
|
|
333418
|
+
logger84.warn(
|
|
333270
333419
|
"[stream] onError: empty/no usable model output (handled by consumption/retry or auxiliary handlers)",
|
|
333271
333420
|
error51
|
|
333272
333421
|
);
|
|
@@ -333274,14 +333423,14 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333274
333423
|
}
|
|
333275
333424
|
if (isNetworkStreamError(error51)) {
|
|
333276
333425
|
recordedNetworkError = error51;
|
|
333277
|
-
|
|
333426
|
+
logger84.warn(
|
|
333278
333427
|
"[stream] onError: network/transport failure (will retry silently)",
|
|
333279
333428
|
error51
|
|
333280
333429
|
);
|
|
333281
333430
|
return;
|
|
333282
333431
|
}
|
|
333283
333432
|
if (isForcedToolChoiceRejection(error51)) {
|
|
333284
|
-
|
|
333433
|
+
logger84.warn(
|
|
333285
333434
|
"[stream] onError: provider rejected the forced tool_choice (retrying without it)",
|
|
333286
333435
|
error51
|
|
333287
333436
|
);
|
|
@@ -333303,7 +333452,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333303
333452
|
const statusCode = error51?.statusCode ?? error51?.error?.statusCode ?? (typeof late2?.code === "number" ? late2.code : void 0);
|
|
333304
333453
|
const rawBody = error51?.responseBody ?? error51?.error?.responseBody ?? late2?.message ?? "";
|
|
333305
333454
|
const bodyStr = typeof rawBody === "string" ? rawBody : JSON.stringify(rawBody ?? "");
|
|
333306
|
-
|
|
333455
|
+
logger84.error(
|
|
333307
333456
|
`[compass] upstream failure status=${statusCode ?? "none"} body=${bodyStr.slice(0, 800)}`
|
|
333308
333457
|
);
|
|
333309
333458
|
const classified = classifyCompassFailure(statusCode, bodyStr);
|
|
@@ -333317,7 +333466,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333317
333466
|
);
|
|
333318
333467
|
const running = cancelAllSubagentTasksForChat(req.chatId, message);
|
|
333319
333468
|
if (running > 0 || queued > 0) {
|
|
333320
|
-
|
|
333469
|
+
logger84.warn(
|
|
333321
333470
|
`[compass] credit exhausted on the parent \u2014 stopped ${running} running and ${queued} queued sub-agent(s) for chat ${req.chatId}`
|
|
333322
333471
|
);
|
|
333323
333472
|
}
|
|
@@ -333325,7 +333474,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333325
333474
|
} else {
|
|
333326
333475
|
message = byokLimitUserMessage(message, modelClient.builtinProviderId) ?? modelFailureUserMessage(message);
|
|
333327
333476
|
}
|
|
333328
|
-
|
|
333477
|
+
logger84.error(
|
|
333329
333478
|
`AI stream text error for request: errorMessage=${errorMessage} error=`,
|
|
333330
333479
|
error51
|
|
333331
333480
|
);
|
|
@@ -333347,7 +333496,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333347
333496
|
});
|
|
333348
333497
|
attachEmptyOutputSafeRejectHandlers(
|
|
333349
333498
|
streamResult,
|
|
333350
|
-
|
|
333499
|
+
logger84.warn.bind(logger84),
|
|
333351
333500
|
"chat_stream"
|
|
333352
333501
|
);
|
|
333353
333502
|
const responseMessages = streamResult.responseMessages;
|
|
@@ -333382,10 +333531,10 @@ async function simpleStreamText(ctx, deps, {
|
|
|
333382
333531
|
getRecordedNetworkError: () => recordedNetworkError
|
|
333383
333532
|
};
|
|
333384
333533
|
}
|
|
333385
|
-
var
|
|
333534
|
+
var import_electron_log87, logger84;
|
|
333386
333535
|
var init_simple_stream_text = __esm({
|
|
333387
333536
|
"src/ipc/handlers/chat_stream/turn-runner/simple-stream-text.ts"() {
|
|
333388
|
-
|
|
333537
|
+
import_electron_log87 = __toESM(require_src());
|
|
333389
333538
|
init_dist21();
|
|
333390
333539
|
init_get_model_client();
|
|
333391
333540
|
init_ai_usage();
|
|
@@ -333421,7 +333570,7 @@ var init_simple_stream_text = __esm({
|
|
|
333421
333570
|
init_system_reminder();
|
|
333422
333571
|
init_step_messages();
|
|
333423
333572
|
init_texts();
|
|
333424
|
-
|
|
333573
|
+
logger84 = import_electron_log87.default.scope("chat_stream_handlers");
|
|
333425
333574
|
}
|
|
333426
333575
|
});
|
|
333427
333576
|
|
|
@@ -333488,7 +333637,7 @@ async function recordEditStats({
|
|
|
333488
333637
|
}
|
|
333489
333638
|
function recordEditStatsSafely(args2) {
|
|
333490
333639
|
void recordEditStats(args2).catch((e3) => {
|
|
333491
|
-
|
|
333640
|
+
logger85.warn("failed to record edit stats", e3);
|
|
333492
333641
|
});
|
|
333493
333642
|
}
|
|
333494
333643
|
function resolveEditStatsModel(effectiveModel, dispatched) {
|
|
@@ -333515,16 +333664,16 @@ function dispatchedModelIdentity(modelClient) {
|
|
|
333515
333664
|
modelId: typeof modelId === "string" ? modelId : void 0
|
|
333516
333665
|
};
|
|
333517
333666
|
}
|
|
333518
|
-
var
|
|
333667
|
+
var import_electron_log88, logger85;
|
|
333519
333668
|
var init_edit_stats2 = __esm({
|
|
333520
333669
|
"src/lib/stats/edit-stats.ts"() {
|
|
333521
|
-
|
|
333670
|
+
import_electron_log88 = __toESM(require_src());
|
|
333522
333671
|
init_drizzle_orm();
|
|
333523
333672
|
init_db2();
|
|
333524
333673
|
init_schema();
|
|
333525
333674
|
init_compose_hunks();
|
|
333526
333675
|
init_compass_constants();
|
|
333527
|
-
|
|
333676
|
+
logger85 = import_electron_log88.default.scope("edit-stats");
|
|
333528
333677
|
}
|
|
333529
333678
|
});
|
|
333530
333679
|
|
|
@@ -333959,7 +334108,7 @@ async function refreshPlanLedgerFromWrittenFile(params) {
|
|
|
333959
334108
|
try {
|
|
333960
334109
|
content = await readFile7(fullPath, "utf8");
|
|
333961
334110
|
} catch (e3) {
|
|
333962
|
-
|
|
334111
|
+
logger86.warn("[refreshPlanLedgerFromWrittenFile] read failed:", e3);
|
|
333963
334112
|
return;
|
|
333964
334113
|
}
|
|
333965
334114
|
const digest = createHash7("sha256").update(content, "utf8").digest("hex");
|
|
@@ -333967,7 +334116,7 @@ async function refreshPlanLedgerFromWrittenFile(params) {
|
|
|
333967
334116
|
const now2 = Date.now();
|
|
333968
334117
|
const prev = refreshGuard.get(guardKey);
|
|
333969
334118
|
if (prev?.hash === digest && now2 - prev.at < DEBOUNCE_MS) {
|
|
333970
|
-
|
|
334119
|
+
logger86.log(
|
|
333971
334120
|
"[refreshPlanLedgerFromWrittenFile] skip duplicate plan body (debounced)"
|
|
333972
334121
|
);
|
|
333973
334122
|
return;
|
|
@@ -334009,12 +334158,12 @@ async function refreshPlanLedgerFromWrittenFile(params) {
|
|
|
334009
334158
|
if (L2) await syncPlanFile2(workspacePath, L2);
|
|
334010
334159
|
}
|
|
334011
334160
|
}
|
|
334012
|
-
var
|
|
334161
|
+
var import_electron_log89, logger86, refreshGuard, DEBOUNCE_MS;
|
|
334013
334162
|
var init_plan_ledger_from_file = __esm({
|
|
334014
334163
|
"src/lib/tasks/plan-ledger-from-file.ts"() {
|
|
334015
|
-
|
|
334164
|
+
import_electron_log89 = __toESM(require_src());
|
|
334016
334165
|
init_plan_sync();
|
|
334017
|
-
|
|
334166
|
+
logger86 = import_electron_log89.default.scope("plan-ledger-from-file");
|
|
334018
334167
|
refreshGuard = /* @__PURE__ */ new Map();
|
|
334019
334168
|
DEBOUNCE_MS = 450;
|
|
334020
334169
|
}
|
|
@@ -334026,7 +334175,7 @@ import pathModule from "node:path";
|
|
|
334026
334175
|
function warnGitMissingOnce(op) {
|
|
334027
334176
|
if (warnedGitMissing) return;
|
|
334028
334177
|
warnedGitMissing = true;
|
|
334029
|
-
|
|
334178
|
+
logger87.warn(
|
|
334030
334179
|
`No git binary available (first noticed during '${op}'); git-backed features are disabled until Git is installed.`
|
|
334031
334180
|
);
|
|
334032
334181
|
}
|
|
@@ -334072,15 +334221,15 @@ async function getCurrentCommitHash({
|
|
|
334072
334221
|
}
|
|
334073
334222
|
return result2.stdout.trim();
|
|
334074
334223
|
}
|
|
334075
|
-
var
|
|
334224
|
+
var import_electron_log90, logger87, warnedGitMissing;
|
|
334076
334225
|
var init_git_utils = __esm({
|
|
334077
334226
|
"src/ipc/utils/git_utils.ts"() {
|
|
334078
334227
|
init_git_author();
|
|
334079
334228
|
init_git_author();
|
|
334080
334229
|
init_system_git_exec();
|
|
334081
334230
|
init_settings();
|
|
334082
|
-
|
|
334083
|
-
|
|
334231
|
+
import_electron_log90 = __toESM(require_src());
|
|
334232
|
+
logger87 = import_electron_log90.default.scope("git_utils");
|
|
334084
334233
|
warnedGitMissing = false;
|
|
334085
334234
|
}
|
|
334086
334235
|
});
|
|
@@ -334142,9 +334291,9 @@ async function insertProjectSnapshot(params) {
|
|
|
334142
334291
|
trigger
|
|
334143
334292
|
});
|
|
334144
334293
|
await pruneSnapshots(workspaceId);
|
|
334145
|
-
|
|
334294
|
+
logger88.debug("insertProjectSnapshot", { workspaceId, trigger });
|
|
334146
334295
|
} catch (e3) {
|
|
334147
|
-
|
|
334296
|
+
logger88.warn("insertProjectSnapshot failed:", e3);
|
|
334148
334297
|
}
|
|
334149
334298
|
}
|
|
334150
334299
|
async function recordPlanUpdateSnapshot(workspaceId, workspacePath) {
|
|
@@ -334218,7 +334367,7 @@ async function applyProjectSnapshotRevert(workspaceId, workspacePath, snapshotId
|
|
|
334218
334367
|
};
|
|
334219
334368
|
}
|
|
334220
334369
|
}
|
|
334221
|
-
var
|
|
334370
|
+
var import_electron_log91, PLAN_FILE, logger88, MAX_SNAPSHOTS_PER_WORKSPACE, touchedWorkspaces, planUpdateSnapshotDebounce, PLAN_UPDATE_SNAPSHOT_DEBOUNCE_MS;
|
|
334222
334371
|
var init_service2 = __esm({
|
|
334223
334372
|
"src/lib/project-memory/service.ts"() {
|
|
334224
334373
|
init_db2();
|
|
@@ -334226,9 +334375,9 @@ var init_service2 = __esm({
|
|
|
334226
334375
|
init_drizzle_orm();
|
|
334227
334376
|
init_paths();
|
|
334228
334377
|
init_git_utils();
|
|
334229
|
-
|
|
334378
|
+
import_electron_log91 = __toESM(require_src());
|
|
334230
334379
|
PLAN_FILE = ".atlarix/ATLARIX_PLAN.md";
|
|
334231
|
-
|
|
334380
|
+
logger88 = import_electron_log91.default.scope("project-memory");
|
|
334232
334381
|
MAX_SNAPSHOTS_PER_WORKSPACE = 100;
|
|
334233
334382
|
touchedWorkspaces = /* @__PURE__ */ new Set();
|
|
334234
334383
|
planUpdateSnapshotDebounce = /* @__PURE__ */ new Map();
|
|
@@ -334241,14 +334390,14 @@ import * as fs46 from "fs/promises";
|
|
|
334241
334390
|
import * as fsSync2 from "node:fs";
|
|
334242
334391
|
import * as path59 from "path";
|
|
334243
334392
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
334244
|
-
var
|
|
334393
|
+
var import_electron_log92, logger89, RESULT_BEARING_FILE_OPS, PermissionInterceptor;
|
|
334245
334394
|
var init_interceptor = __esm({
|
|
334246
334395
|
"src/ipc/handlers/permissions/interceptor.ts"() {
|
|
334247
334396
|
init_realpath_contain();
|
|
334248
334397
|
init_mutation_verify();
|
|
334249
334398
|
init_edit_stats2();
|
|
334250
334399
|
init_untrusted_data();
|
|
334251
|
-
|
|
334400
|
+
import_electron_log92 = __toESM(require_src());
|
|
334252
334401
|
init_electron_stub();
|
|
334253
334402
|
init_schema3();
|
|
334254
334403
|
init_runShellCommand();
|
|
@@ -334272,7 +334421,7 @@ var init_interceptor = __esm({
|
|
|
334272
334421
|
init_system_scope_commands();
|
|
334273
334422
|
init_git_author();
|
|
334274
334423
|
init_git_utils();
|
|
334275
|
-
|
|
334424
|
+
logger89 = import_electron_log92.default.scope("permission-interceptor");
|
|
334276
334425
|
RESULT_BEARING_FILE_OPS = /* @__PURE__ */ new Set([
|
|
334277
334426
|
"write_file",
|
|
334278
334427
|
"write_multiple_files",
|
|
@@ -334441,7 +334590,7 @@ var init_interceptor = __esm({
|
|
|
334441
334590
|
}
|
|
334442
334591
|
} catch {
|
|
334443
334592
|
}
|
|
334444
|
-
|
|
334593
|
+
logger89.log(
|
|
334445
334594
|
`[PermissionInterceptor] Initialized for workspace: ${workspacePath} (id: ${workspaceId}, turn: ${this.snapshotTurnId ?? "none"}, chat: ${this.activeChatId})`
|
|
334446
334595
|
);
|
|
334447
334596
|
}
|
|
@@ -334451,7 +334600,7 @@ var init_interceptor = __esm({
|
|
|
334451
334600
|
*/
|
|
334452
334601
|
approveRestOfTurn() {
|
|
334453
334602
|
this.turnBlanketApproved = true;
|
|
334454
|
-
|
|
334603
|
+
logger89.log(
|
|
334455
334604
|
`[approveRestOfTurn] chat ${this.activeChatId}: approvals suppressed for the rest of this turn`
|
|
334456
334605
|
);
|
|
334457
334606
|
}
|
|
@@ -334527,7 +334676,7 @@ var init_interceptor = __esm({
|
|
|
334527
334676
|
for (const win of BrowserWindow.getAllWindows()) {
|
|
334528
334677
|
win.webContents.send("operation-status", payload);
|
|
334529
334678
|
}
|
|
334530
|
-
|
|
334679
|
+
logger89.log(
|
|
334531
334680
|
`[emitStatus] ${operationId} -> ${status}${error51 ? ` (${error51})` : ""}`
|
|
334532
334681
|
);
|
|
334533
334682
|
}
|
|
@@ -334544,7 +334693,7 @@ var init_interceptor = __esm({
|
|
|
334544
334693
|
setWorkspace(path67, id) {
|
|
334545
334694
|
this.workspacePath = path67;
|
|
334546
334695
|
if (id != null) this.workspaceId = id;
|
|
334547
|
-
|
|
334696
|
+
logger89.log(
|
|
334548
334697
|
`[PermissionInterceptor] Workspace updated to: ${path67} (id: ${id})`
|
|
334549
334698
|
);
|
|
334550
334699
|
}
|
|
@@ -334573,13 +334722,13 @@ var init_interceptor = __esm({
|
|
|
334573
334722
|
*/
|
|
334574
334723
|
parsePermissionRequest(result2) {
|
|
334575
334724
|
if (typeof result2 === "object" && result2 !== null && result2.__permission_required) {
|
|
334576
|
-
|
|
334725
|
+
logger89.log("[parsePermissionRequest] Parsed object format");
|
|
334577
334726
|
return result2;
|
|
334578
334727
|
}
|
|
334579
334728
|
if (typeof result2 === "string") {
|
|
334580
334729
|
const parsed = parsePermissionRequest(result2);
|
|
334581
334730
|
if (parsed) {
|
|
334582
|
-
|
|
334731
|
+
logger89.log("[parsePermissionRequest] Parsed JSON string format");
|
|
334583
334732
|
return parsed;
|
|
334584
334733
|
}
|
|
334585
334734
|
}
|
|
@@ -334606,7 +334755,7 @@ var init_interceptor = __esm({
|
|
|
334606
334755
|
createdAt: Date.now()
|
|
334607
334756
|
};
|
|
334608
334757
|
this.pendingOperations.set(operationId, operation);
|
|
334609
|
-
|
|
334758
|
+
logger89.log("[Permission Request Buffered]", {
|
|
334610
334759
|
id: operationId,
|
|
334611
334760
|
operation: request.operation,
|
|
334612
334761
|
path: request.preview?.path || "N/A",
|
|
@@ -334659,7 +334808,7 @@ var init_interceptor = __esm({
|
|
|
334659
334808
|
}
|
|
334660
334809
|
this.pendingApprovals.clear();
|
|
334661
334810
|
this.pendingOperations.clear();
|
|
334662
|
-
|
|
334811
|
+
logger89.log("[PermissionInterceptor] Cleared all pending operations");
|
|
334663
334812
|
}
|
|
334664
334813
|
// ════════════════════════════════════════════════════════════════════════════
|
|
334665
334814
|
// BLOCKING APPROVAL MECHANISM (NEW in v0.9.1)
|
|
@@ -334702,7 +334851,7 @@ var init_interceptor = __esm({
|
|
|
334702
334851
|
// No grace timeout — indefinite block.
|
|
334703
334852
|
createdAt: Date.now()
|
|
334704
334853
|
});
|
|
334705
|
-
|
|
334854
|
+
logger89.log(
|
|
334706
334855
|
`[waitForApproval] Blocking (indefinite) for user response on ${operationId}`
|
|
334707
334856
|
);
|
|
334708
334857
|
});
|
|
@@ -334718,7 +334867,7 @@ var init_interceptor = __esm({
|
|
|
334718
334867
|
if (pending2.timeout) clearTimeout(pending2.timeout);
|
|
334719
334868
|
pending2.resolve(approved ? "approved" : "rejected");
|
|
334720
334869
|
this.pendingApprovals.delete(operationId);
|
|
334721
|
-
|
|
334870
|
+
logger89.log(
|
|
334722
334871
|
`[resolveApproval] ${operationId} -> ${approved ? "APPROVED" : "REJECTED"}`
|
|
334723
334872
|
);
|
|
334724
334873
|
}
|
|
@@ -334745,7 +334894,7 @@ var init_interceptor = __esm({
|
|
|
334745
334894
|
const preview = request.preview;
|
|
334746
334895
|
if (preview && typeof preview === "object") {
|
|
334747
334896
|
preview.content = options.overrideContent;
|
|
334748
|
-
|
|
334897
|
+
logger89.log(
|
|
334749
334898
|
`[executeOperation] per-hunk override applied for ${operationId} (${request.operation})`
|
|
334750
334899
|
);
|
|
334751
334900
|
}
|
|
@@ -334793,7 +334942,7 @@ var init_interceptor = __esm({
|
|
|
334793
334942
|
}
|
|
334794
334943
|
operation.status = "executed";
|
|
334795
334944
|
this.emitStatus(operationId, "completed");
|
|
334796
|
-
|
|
334945
|
+
logger89.log(
|
|
334797
334946
|
`[executeOperation] Executed ${operationId}: ${request.operation}`
|
|
334798
334947
|
);
|
|
334799
334948
|
if (this.snapshotTurnId && CONTENT_WRITE_OPS.has(request.operation)) {
|
|
@@ -334859,7 +335008,7 @@ var init_interceptor = __esm({
|
|
|
334859
335008
|
void 0,
|
|
334860
335009
|
errorMessage
|
|
334861
335010
|
);
|
|
334862
|
-
|
|
335011
|
+
logger89.error(`[executeOperation] Failed ${operationId}:`, error51);
|
|
334863
335012
|
if (this.snapshotTurnId && CONTENT_WRITE_OPS.has(request.operation)) {
|
|
334864
335013
|
recordMutationOutcome(
|
|
334865
335014
|
this.snapshotTurnId,
|
|
@@ -335017,23 +335166,23 @@ var init_interceptor = __esm({
|
|
|
335017
335166
|
}
|
|
335018
335167
|
}
|
|
335019
335168
|
if (operationsToExecute.length === 0) {
|
|
335020
|
-
|
|
335169
|
+
logger89.log("[executeAllOperations] No pending operations to execute");
|
|
335021
335170
|
return results;
|
|
335022
335171
|
}
|
|
335023
|
-
|
|
335172
|
+
logger89.log(
|
|
335024
335173
|
`[executeAllOperations] Processing ${operationsToExecute.length} pending operations sequentially`
|
|
335025
335174
|
);
|
|
335026
335175
|
for (const [operationId] of operationsToExecute) {
|
|
335027
335176
|
const result2 = await this.executeOperation(operationId);
|
|
335028
335177
|
results.push(result2);
|
|
335029
|
-
|
|
335178
|
+
logger89.log(
|
|
335030
335179
|
`[executeAllOperations] Completed ${result2.operationId}: ${result2.approved ? "success" : "failed"}`
|
|
335031
335180
|
);
|
|
335032
335181
|
}
|
|
335033
335182
|
for (const [operationId] of operationsToExecute) {
|
|
335034
335183
|
this.pendingOperations.delete(operationId);
|
|
335035
335184
|
}
|
|
335036
|
-
|
|
335185
|
+
logger89.log(
|
|
335037
335186
|
`[executeAllOperations] Completed all ${operationsToExecute.length} operations`
|
|
335038
335187
|
);
|
|
335039
335188
|
return results;
|
|
@@ -335053,7 +335202,7 @@ var init_interceptor = __esm({
|
|
|
335053
335202
|
}
|
|
335054
335203
|
this.resolveApproval(operationId, false);
|
|
335055
335204
|
operation.status = "rejected";
|
|
335056
|
-
|
|
335205
|
+
logger89.log(
|
|
335057
335206
|
`[rejectOperation] Rejected ${operationId}: ${operation.request.operation}`
|
|
335058
335207
|
);
|
|
335059
335208
|
return {
|
|
@@ -335246,7 +335395,7 @@ var init_interceptor = __esm({
|
|
|
335246
335395
|
if (p2) roots.push(path59.resolve(p2));
|
|
335247
335396
|
}
|
|
335248
335397
|
} catch (e3) {
|
|
335249
|
-
|
|
335398
|
+
logger89.warn(
|
|
335250
335399
|
`[writable-roots] could not read granted folders: ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
335251
335400
|
);
|
|
335252
335401
|
}
|
|
@@ -335288,7 +335437,7 @@ var init_interceptor = __esm({
|
|
|
335288
335437
|
grantedRoots: this.writableRoots()
|
|
335289
335438
|
});
|
|
335290
335439
|
} catch (e3) {
|
|
335291
|
-
|
|
335440
|
+
logger89.warn("[maybeCaptureWorkspaceSnapshot] skipped:", e3);
|
|
335292
335441
|
}
|
|
335293
335442
|
}
|
|
335294
335443
|
/**
|
|
@@ -335323,7 +335472,7 @@ var init_interceptor = __esm({
|
|
|
335323
335472
|
await mcpManager2.dispose(preview.serverId);
|
|
335324
335473
|
await db3.delete(mcpToolConsents2).where(eq2(mcpToolConsents2.serverId, preview.serverId));
|
|
335325
335474
|
await db3.delete(mcpServers2).where(eq2(mcpServers2.id, preview.serverId));
|
|
335326
|
-
|
|
335475
|
+
logger89.log(
|
|
335327
335476
|
`[mcp] deleted server ${preview.serverId} (${preview.serverName})`
|
|
335328
335477
|
);
|
|
335329
335478
|
return;
|
|
@@ -335352,7 +335501,7 @@ var init_interceptor = __esm({
|
|
|
335352
335501
|
appId: input.appId,
|
|
335353
335502
|
authType
|
|
335354
335503
|
}).returning();
|
|
335355
|
-
|
|
335504
|
+
logger89.log(`[mcp] added server ${row?.id} (${input.name}), inactive`);
|
|
335356
335505
|
return;
|
|
335357
335506
|
}
|
|
335358
335507
|
if (input.id == null) throw new Error("MCP server id missing for edit");
|
|
@@ -335367,7 +335516,7 @@ var init_interceptor = __esm({
|
|
|
335367
335516
|
authType,
|
|
335368
335517
|
updatedAt: /* @__PURE__ */ new Date()
|
|
335369
335518
|
}).where(eq2(mcpServers2.id, input.id));
|
|
335370
|
-
|
|
335519
|
+
logger89.log(`[mcp] edited server ${input.id} (${input.name})`);
|
|
335371
335520
|
}
|
|
335372
335521
|
async executeAutomationWrite(request) {
|
|
335373
335522
|
const preview = request.preview;
|
|
@@ -335375,7 +335524,7 @@ var init_interceptor = __esm({
|
|
|
335375
335524
|
if (preview.action === "delete") {
|
|
335376
335525
|
if (!preview.automationId) throw new Error("Automation id missing");
|
|
335377
335526
|
await svc.deleteAutomation(preview.automationId);
|
|
335378
|
-
|
|
335527
|
+
logger89.log(
|
|
335379
335528
|
`[automation] deleted ${preview.automationId} (${preview.name})`
|
|
335380
335529
|
);
|
|
335381
335530
|
return;
|
|
@@ -335392,12 +335541,12 @@ var init_interceptor = __esm({
|
|
|
335392
335541
|
if (this.workspaceId == null) throw new Error("Workspace required");
|
|
335393
335542
|
const { id } = await svc.createAutomation(this.workspaceId, input);
|
|
335394
335543
|
preview.automationId = id;
|
|
335395
|
-
|
|
335544
|
+
logger89.log(`[automation] created ${id} (${input.name})`);
|
|
335396
335545
|
return;
|
|
335397
335546
|
}
|
|
335398
335547
|
if (!preview.automationId) throw new Error("Automation id missing");
|
|
335399
335548
|
await svc.updateAutomation(preview.automationId, input);
|
|
335400
|
-
|
|
335549
|
+
logger89.log(`[automation] updated ${preview.automationId} (${input.name})`);
|
|
335401
335550
|
}
|
|
335402
335551
|
async executeRevertProjectSnapshot(request) {
|
|
335403
335552
|
const preview = request.preview;
|
|
@@ -335413,7 +335562,7 @@ var init_interceptor = __esm({
|
|
|
335413
335562
|
if (!result2.success) {
|
|
335414
335563
|
throw new Error(result2.error || "Revert failed");
|
|
335415
335564
|
}
|
|
335416
|
-
|
|
335565
|
+
logger89.log(`[executeRevertProjectSnapshot] id=${preview.snapshotId}`);
|
|
335417
335566
|
}
|
|
335418
335567
|
async executeWriteFile(request) {
|
|
335419
335568
|
const preview = request.preview;
|
|
@@ -335429,7 +335578,7 @@ var init_interceptor = __esm({
|
|
|
335429
335578
|
await fs46.mkdir(path59.dirname(fullPath), { recursive: true });
|
|
335430
335579
|
const intended = preview.content || "";
|
|
335431
335580
|
await fs46.writeFile(fullPath, intended, "utf-8");
|
|
335432
|
-
|
|
335581
|
+
logger89.log(`Wrote file: ${fullPath}`);
|
|
335433
335582
|
try {
|
|
335434
335583
|
const onDisk = await fs46.readFile(fullPath, "utf-8");
|
|
335435
335584
|
preview.verified = onDisk === intended;
|
|
@@ -335458,7 +335607,7 @@ var init_interceptor = __esm({
|
|
|
335458
335607
|
]);
|
|
335459
335608
|
const fullPath = this.resolvePathWithinWorkspace(preview.path);
|
|
335460
335609
|
await fs46.unlink(fullPath);
|
|
335461
|
-
|
|
335610
|
+
logger89.log(`Deleted file: ${fullPath}`);
|
|
335462
335611
|
}
|
|
335463
335612
|
async executeRenameFile(request) {
|
|
335464
335613
|
const preview = request.preview;
|
|
@@ -335472,7 +335621,7 @@ var init_interceptor = __esm({
|
|
|
335472
335621
|
const toFullPath = this.resolvePathWithinWorkspace(preview.toPath);
|
|
335473
335622
|
await fs46.mkdir(path59.dirname(toFullPath), { recursive: true });
|
|
335474
335623
|
await fs46.rename(fromFullPath, toFullPath);
|
|
335475
|
-
|
|
335624
|
+
logger89.log(`Renamed file: ${fromFullPath} \u2192 ${toFullPath}`);
|
|
335476
335625
|
}
|
|
335477
335626
|
/**
|
|
335478
335627
|
* Execute diagram update when user approves the AI's request.
|
|
@@ -335575,7 +335724,7 @@ var init_interceptor = __esm({
|
|
|
335575
335724
|
}
|
|
335576
335725
|
);
|
|
335577
335726
|
} catch (e3) {
|
|
335578
|
-
|
|
335727
|
+
logger89.warn("[terminal-buffer] append failed:", e3);
|
|
335579
335728
|
}
|
|
335580
335729
|
this.emit("terminal-output", payload);
|
|
335581
335730
|
}
|
|
@@ -335681,7 +335830,7 @@ ${result2.stdout ?? ""}`
|
|
|
335681
335830
|
try {
|
|
335682
335831
|
upsertSandboxWritablePath(this.workspaceId, denial.grantPath);
|
|
335683
335832
|
} catch (e3) {
|
|
335684
|
-
|
|
335833
|
+
logger89.warn(
|
|
335685
335834
|
`[sandbox-escalation] persist failed: ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
335686
335835
|
);
|
|
335687
335836
|
}
|
|
@@ -335747,14 +335896,14 @@ ${retried.stdout ?? ""}`
|
|
|
335747
335896
|
const workspaceCdStrip = /^cd\s+\/workspace(?:\/[^\s;&|]*)?\s*(?:&&|;)\s*/;
|
|
335748
335897
|
if (workspaceCdStrip.test(preview.command)) {
|
|
335749
335898
|
commandToRun = preview.command.replace(workspaceCdStrip, "").trim() || "true";
|
|
335750
|
-
|
|
335899
|
+
logger89.log(
|
|
335751
335900
|
`[executeRunCommand] Stripped 'cd /workspace' prefix (shell already in workspace); running: ${commandToRun}`
|
|
335752
335901
|
);
|
|
335753
335902
|
}
|
|
335754
335903
|
if (/\bgit\s+commit\b/.test(commandToRun) && !await hasConfiguredGitIdentity(workingDir)) {
|
|
335755
335904
|
const withAgentIdentity = injectAgentGitIdentity(commandToRun);
|
|
335756
335905
|
if (withAgentIdentity !== commandToRun) {
|
|
335757
|
-
|
|
335906
|
+
logger89.log(
|
|
335758
335907
|
`[executeRunCommand] No git identity configured \u2014 injected agent identity into commit command`
|
|
335759
335908
|
);
|
|
335760
335909
|
commandToRun = withAgentIdentity;
|
|
@@ -335765,7 +335914,7 @@ ${retried.stdout ?? ""}`
|
|
|
335765
335914
|
const explicitBackground = preview.background === true;
|
|
335766
335915
|
const wakeOn = preview.wake_on;
|
|
335767
335916
|
const allowStalled = preview.allow_stalled === true;
|
|
335768
|
-
|
|
335917
|
+
logger89.log(
|
|
335769
335918
|
`[executeRunCommand] Running: ${commandToRun} in ${workingDir}` + (explicitBackground ? " (background)" : ` (promote after ${PROMOTE_AFTER_MS}ms)`)
|
|
335770
335919
|
);
|
|
335771
335920
|
const scopeKey = resolveScopeKey(this.activeChatId, this.workspaceId);
|
|
@@ -335776,14 +335925,14 @@ ${retried.stdout ?? ""}`
|
|
|
335776
335925
|
background: explicitBackground
|
|
335777
335926
|
});
|
|
335778
335927
|
if (preview.isDangerous) {
|
|
335779
|
-
|
|
335928
|
+
logger89.warn(
|
|
335780
335929
|
`[DANGEROUS-COMMAND-AUDIT] User approved dangerous command | command="${commandToRun}" | cwd="${workingDir}" | explanation="${preview.dangerExplanation ?? "N/A"}" | timestamp=${(/* @__PURE__ */ new Date()).toISOString()}`
|
|
335781
335930
|
);
|
|
335782
335931
|
}
|
|
335783
335932
|
const sandboxOpts = this.buildRunCommandSandbox(preview);
|
|
335784
335933
|
if (preview.systemScopeInteractive === true) {
|
|
335785
335934
|
const sandboxState = sandboxOpts ? "SANDBOXED (writable roots widened for the approved path)" : "UNSANDBOXED";
|
|
335786
|
-
|
|
335935
|
+
logger89.warn(
|
|
335787
335936
|
`[SYSTEM-SCOPE-AUDIT] User approved a system-scope command | sandbox=${sandboxState} | command="${commandToRun}" | cwd="${workingDir}" | explanation="${preview.systemScopeExplanation ?? "N/A"}" | timestamp=${(/* @__PURE__ */ new Date()).toISOString()}`
|
|
335788
335937
|
);
|
|
335789
335938
|
}
|
|
@@ -335890,7 +336039,7 @@ ${stderr}` : "");
|
|
|
335890
336039
|
});
|
|
335891
336040
|
if (retried) result2 = retried;
|
|
335892
336041
|
} catch (e3) {
|
|
335893
|
-
|
|
336042
|
+
logger89.warn(
|
|
335894
336043
|
`[sandbox-escalation] ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
335895
336044
|
);
|
|
335896
336045
|
}
|
|
@@ -335922,11 +336071,11 @@ ${result2.stderr}` : ""),
|
|
|
335922
336071
|
}
|
|
335923
336072
|
this.commandOutputs.set(operationId, result2);
|
|
335924
336073
|
if (result2.success) {
|
|
335925
|
-
|
|
336074
|
+
logger89.log(
|
|
335926
336075
|
`[executeRunCommand] Success: ${commandToRun} (${(duration3 / 1e3).toFixed(1)}s)`
|
|
335927
336076
|
);
|
|
335928
336077
|
} else {
|
|
335929
|
-
|
|
336078
|
+
logger89.error(
|
|
335930
336079
|
`[executeRunCommand] Failed: ${commandToRun} (exit ${result2.exitCode})`
|
|
335931
336080
|
);
|
|
335932
336081
|
const errDetail = result2.stderr ? `
|
|
@@ -336079,14 +336228,14 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336079
336228
|
if (isForceTextFinishAbort(rt2.abortController.signal.reason)) {
|
|
336080
336229
|
forceTextFinish = true;
|
|
336081
336230
|
} else {
|
|
336082
|
-
|
|
336231
|
+
logger90.log(
|
|
336083
336232
|
`${L2} Stream aborted (${String(rt2.abortController.signal.reason ?? "unknown")}) \u2014 stopping turn loop`
|
|
336084
336233
|
);
|
|
336085
336234
|
throw abortReasonError(rt2.abortController.signal.reason);
|
|
336086
336235
|
}
|
|
336087
336236
|
}
|
|
336088
336237
|
if (!forceTextFinish && Date.now() - loopStartTime > STREAM_TOOL_LOOP_DURATION_CAP_MS) {
|
|
336089
|
-
|
|
336238
|
+
logger90.warn(`${L2} Hit duration limit (30 minutes) mode=${profile.mode}`);
|
|
336090
336239
|
rt2.safeSend("chat:activity", {
|
|
336091
336240
|
id: `duration-limit-${Date.now()}`,
|
|
336092
336241
|
type: "duration_limit_reached",
|
|
@@ -336105,7 +336254,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336105
336254
|
maxIterations: 0,
|
|
336106
336255
|
totalToolsExecuted: totalToolExecutions
|
|
336107
336256
|
});
|
|
336108
|
-
|
|
336257
|
+
logger90.log(`${L2} Iteration ${agenticIteration + 1} (unbounded)`);
|
|
336109
336258
|
}
|
|
336110
336259
|
const promptSpec = await profile.buildRoundSystemPrompt();
|
|
336111
336260
|
const roundPrompt = typeof promptSpec === "string" ? { systemPromptOverride: promptSpec } : promptSpec;
|
|
@@ -336185,7 +336334,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336185
336334
|
finalFinishReason = fr2;
|
|
336186
336335
|
if (resumeFromStall && resumeFromStall.length > 0) {
|
|
336187
336336
|
if (stallResumeAttempts >= MAX_STALL_RESUME_ATTEMPTS) {
|
|
336188
|
-
|
|
336337
|
+
logger90.warn(
|
|
336189
336338
|
`${L2} Stall-resume cap (${MAX_STALL_RESUME_ATTEMPTS}) reached \u2014 ending round`
|
|
336190
336339
|
);
|
|
336191
336340
|
finalRoundRespMsgs = resumeFromStall;
|
|
@@ -336193,7 +336342,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336193
336342
|
break;
|
|
336194
336343
|
}
|
|
336195
336344
|
stallResumeAttempts++;
|
|
336196
|
-
|
|
336345
|
+
logger90.info(
|
|
336197
336346
|
`${L2} Stall-resume ${stallResumeAttempts}/${MAX_STALL_RESUME_ATTEMPTS}: continuing from ${resumeFromStall.length} completed step-message(s)`
|
|
336198
336347
|
);
|
|
336199
336348
|
buildIterMessages = [
|
|
@@ -336248,7 +336397,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336248
336397
|
throw err2;
|
|
336249
336398
|
}
|
|
336250
336399
|
if (forceTextFinish) {
|
|
336251
|
-
|
|
336400
|
+
logger90.info(`${L2} Force-finish round complete \u2014 ending turn`);
|
|
336252
336401
|
break;
|
|
336253
336402
|
}
|
|
336254
336403
|
const nativeIterMessages = [
|
|
@@ -336270,7 +336419,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336270
336419
|
stripThinkBlocks(iterationDeltaResponse)
|
|
336271
336420
|
);
|
|
336272
336421
|
if (textRep.kind === "loop_correct") {
|
|
336273
|
-
|
|
336422
|
+
logger90.info(
|
|
336274
336423
|
`${L2} Repeated status restatement detected \u2014 injecting correction (attempt ${textRep.attempt})`
|
|
336275
336424
|
);
|
|
336276
336425
|
agenticMessages.push({
|
|
@@ -336287,7 +336436,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336287
336436
|
continue;
|
|
336288
336437
|
}
|
|
336289
336438
|
if (textRep.kind === "loop_abort") {
|
|
336290
|
-
|
|
336439
|
+
logger90.info(
|
|
336291
336440
|
`${L2} Repeated status restatement persisted \u2014 forcing finish round`
|
|
336292
336441
|
);
|
|
336293
336442
|
forceTextFinish = true;
|
|
@@ -336298,23 +336447,23 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336298
336447
|
const hasTextToolCalls = textToolCalls !== null;
|
|
336299
336448
|
const currentOpCount = rt2.permissionInterceptor.getAllOperationsCount();
|
|
336300
336449
|
const executedOpCount = rt2.permissionInterceptor.getExecutedOperationsCount();
|
|
336301
|
-
|
|
336450
|
+
logger90.log(
|
|
336302
336451
|
`${L2} Operation counts: total=${currentOpCount}, executed=${executedOpCount}, tracked=${totalToolExecutions}`
|
|
336303
336452
|
);
|
|
336304
336453
|
const hadNativeToolExecution = currentOpCount > totalToolExecutions;
|
|
336305
336454
|
if (hasTextToolCalls) {
|
|
336306
|
-
|
|
336455
|
+
logger90.log(
|
|
336307
336456
|
`${L2} Detected text-based tool calls, parsing and executing...`
|
|
336308
336457
|
);
|
|
336309
336458
|
} else if (hadNativeToolExecution) {
|
|
336310
336459
|
const newOps = currentOpCount - totalToolExecutions;
|
|
336311
|
-
|
|
336460
|
+
logger90.log(
|
|
336312
336461
|
`${L2} Native tool calls detected (${newOps} new operations, ${currentOpCount} total)`
|
|
336313
336462
|
);
|
|
336314
336463
|
totalToolExecutions = currentOpCount;
|
|
336315
336464
|
}
|
|
336316
336465
|
if (streamDebugLogging) {
|
|
336317
|
-
|
|
336466
|
+
logger90.log(`${L2} Round summary`, {
|
|
336318
336467
|
iteration: agenticIteration + 1,
|
|
336319
336468
|
hasTextToolCalls,
|
|
336320
336469
|
hadNativeToolExecution,
|
|
@@ -336328,7 +336477,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336328
336477
|
}
|
|
336329
336478
|
if (pendingWorkBlocksEnd()) {
|
|
336330
336479
|
parked = true;
|
|
336331
|
-
|
|
336480
|
+
logger90.info(
|
|
336332
336481
|
`${L2} Model yielded (fr=${String(finalFinishReason)}) \u2192 PARKED \u2014 ${runningSubagentCount(rt2.chatId)} sub-agent(s) / background work outstanding`
|
|
336333
336482
|
);
|
|
336334
336483
|
break;
|
|
@@ -336348,7 +336497,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336348
336497
|
gateFeedback = await profile.planCompletionGate();
|
|
336349
336498
|
usePlanGate = gateFeedback != null;
|
|
336350
336499
|
} catch (planErr) {
|
|
336351
|
-
|
|
336500
|
+
logger90.warn(
|
|
336352
336501
|
`${L2} plan-completion gate failed to run: ${String(planErr)}`
|
|
336353
336502
|
);
|
|
336354
336503
|
}
|
|
@@ -336356,7 +336505,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336356
336505
|
const gateStreak = usePlanGate ? planNudgeStreak : agenticProseOnlyStreak;
|
|
336357
336506
|
const gateCap = usePlanGate ? PLAN_YIELD_MAX_NUDGES : PROSE_YIELD_MAX_NUDGES;
|
|
336358
336507
|
if (gateFeedback == null || gateStreak >= gateCap || usePlanGate && planNudgeTotal >= PLAN_YIELD_TOTAL_MAX) {
|
|
336359
|
-
|
|
336508
|
+
logger90.info(
|
|
336360
336509
|
`${L2} Model yielded (no tool calls) \u2014 ending turn at iteration ${agenticIteration + 1}`
|
|
336361
336510
|
);
|
|
336362
336511
|
break;
|
|
@@ -336378,7 +336527,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336378
336527
|
content: systemReminder(gateFeedback)
|
|
336379
336528
|
});
|
|
336380
336529
|
agenticIteration++;
|
|
336381
|
-
|
|
336530
|
+
logger90.log(
|
|
336382
336531
|
`${L2} ${usePlanGate ? "Plan not complete" : "Completion gate not satisfied"} \u2014 nudge ${gateStreak + 1} of ${gateCap} allowed; continuing`
|
|
336383
336532
|
);
|
|
336384
336533
|
continue;
|
|
@@ -336386,7 +336535,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
336386
336535
|
agenticProseOnlyStreak = 0;
|
|
336387
336536
|
planNudgeStreak = 0;
|
|
336388
336537
|
if (hasTextToolCalls && (textToolCalls?.length ?? 0) === 0) {
|
|
336389
|
-
|
|
336538
|
+
logger90.log(`${L2} No parseable tool calls found, ending loop`);
|
|
336390
336539
|
break;
|
|
336391
336540
|
}
|
|
336392
336541
|
let iterationResults = [];
|
|
@@ -336403,7 +336552,7 @@ ${r3.result}
|
|
|
336403
336552
|
</tool_result>`).join("\n\n");
|
|
336404
336553
|
if (roundHadNativeToolMessages && !hasTextToolCalls) {
|
|
336405
336554
|
foldNativeIntoTurn(nativeIterMessages);
|
|
336406
|
-
|
|
336555
|
+
logger90.log(
|
|
336407
336556
|
`${L2} Folded ${nativeIterMessages.length} native message(s) into history (no synthetic reflatten)`
|
|
336408
336557
|
);
|
|
336409
336558
|
} else {
|
|
@@ -336423,7 +336572,7 @@ Please continue with your task based on these results.`
|
|
|
336423
336572
|
)
|
|
336424
336573
|
});
|
|
336425
336574
|
} else if (hadNativeToolExecution) {
|
|
336426
|
-
|
|
336575
|
+
logger90.log(
|
|
336427
336576
|
`${L2} Skipping empty tool-results user message (native tools executed in-stream)`
|
|
336428
336577
|
);
|
|
336429
336578
|
}
|
|
@@ -336438,8 +336587,8 @@ Please continue with your task based on these results.`
|
|
|
336438
336587
|
chatId: rt2.chatId,
|
|
336439
336588
|
loopLabel: profile.compactionLabel,
|
|
336440
336589
|
emitActivity: rt2.emitCompactionActivity,
|
|
336441
|
-
onInfo: (msg) =>
|
|
336442
|
-
onWarn: (msg, err2) =>
|
|
336590
|
+
onInfo: (msg) => logger90.log(msg),
|
|
336591
|
+
onWarn: (msg, err2) => logger90.warn(msg, err2)
|
|
336443
336592
|
});
|
|
336444
336593
|
if (compaction.compacted) {
|
|
336445
336594
|
agenticMessages = compaction.messages;
|
|
@@ -336455,12 +336604,12 @@ Please continue with your task based on these results.`
|
|
|
336455
336604
|
mode: profile.escalationMode
|
|
336456
336605
|
});
|
|
336457
336606
|
} catch (escalationErr) {
|
|
336458
|
-
|
|
336607
|
+
logger90.warn(
|
|
336459
336608
|
`${L2} tier escalation guard failed: ${String(escalationErr)}`
|
|
336460
336609
|
);
|
|
336461
336610
|
}
|
|
336462
336611
|
if (hasPermissionRequest) {
|
|
336463
|
-
|
|
336612
|
+
logger90.log(`${L2} Had permission requests, continuing loop...`);
|
|
336464
336613
|
}
|
|
336465
336614
|
}
|
|
336466
336615
|
trackTaskCompleted({
|
|
@@ -336480,10 +336629,10 @@ Please continue with your task based on these results.`
|
|
|
336480
336629
|
forcedTextFinish: forceTextFinish
|
|
336481
336630
|
};
|
|
336482
336631
|
}
|
|
336483
|
-
var
|
|
336632
|
+
var import_electron_log93, logger90, DEFAULT_FORCE_FINISH_PROMPT;
|
|
336484
336633
|
var init_run_agent_turn = __esm({
|
|
336485
336634
|
"src/lib/agent/run-agent-turn.ts"() {
|
|
336486
|
-
|
|
336635
|
+
import_electron_log93 = __toESM(require_src());
|
|
336487
336636
|
init_continuation_handler();
|
|
336488
336637
|
init_system_reminder();
|
|
336489
336638
|
init_plan_ledger_refresh();
|
|
@@ -336498,7 +336647,7 @@ var init_run_agent_turn = __esm({
|
|
|
336498
336647
|
init_stream_stop_sentinels();
|
|
336499
336648
|
init_subagent_results();
|
|
336500
336649
|
init_background_commands();
|
|
336501
|
-
|
|
336650
|
+
logger90 = import_electron_log93.default.scope("run-agent-turn");
|
|
336502
336651
|
DEFAULT_FORCE_FINISH_PROMPT = "You have been repeating actions without converging, so tools are now disabled for this turn. Do NOT attempt any further tool calls. In plain prose, briefly summarize what you accomplished, what is still incomplete, and the concrete next step \u2014 then stop.";
|
|
336503
336652
|
}
|
|
336504
336653
|
});
|
|
@@ -336537,7 +336686,7 @@ async function runAskBranch(ctx, deps) {
|
|
|
336537
336686
|
processResponseChunkUpdate: processResponseChunkUpdate2,
|
|
336538
336687
|
applyTierEscalation
|
|
336539
336688
|
} = deps;
|
|
336540
|
-
|
|
336689
|
+
logger91.log(
|
|
336541
336690
|
`Ask tier with workspace \u2014 read-only${effectiveWorkMode === "plan" ? " + Plan tools" : ""} (approval where required)`
|
|
336542
336691
|
);
|
|
336543
336692
|
const askPermissionInterceptor = new PermissionInterceptor(
|
|
@@ -336750,7 +336899,7 @@ async function runAskBranch(ctx, deps) {
|
|
|
336750
336899
|
);
|
|
336751
336900
|
if (outcome.success && outcome.tokensAfter > 0) {
|
|
336752
336901
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
336753
|
-
|
|
336902
|
+
logger91.info(
|
|
336754
336903
|
`[DIAG_146] compress(ask) chat=${req.chatId} ${outcome.tokensBefore}\u2192${outcome.tokensAfter} persisted=${outcome.summaryPersisted} \u2192 emit context-report dispatchedTokens=${outcome.tokensAfter}`
|
|
336755
336904
|
);
|
|
336756
336905
|
}
|
|
@@ -336934,15 +337083,15 @@ ${marker28}
|
|
|
336934
337083
|
isReadOnlyWorkMode(liveWorkMode)
|
|
336935
337084
|
)
|
|
336936
337085
|
});
|
|
336937
|
-
|
|
337086
|
+
logger91.log(
|
|
336938
337087
|
`[Ask Mode] Permission request buffered: ${operationId}`
|
|
336939
337088
|
);
|
|
336940
337089
|
} else if (askPermissionInterceptor.shouldAlwaysAutoApprove(permRequest)) {
|
|
336941
|
-
|
|
337090
|
+
logger91.log(
|
|
336942
337091
|
`[Ask Mode] Auto-approved .atlarix internal write: ${operationId}`
|
|
336943
337092
|
);
|
|
336944
337093
|
} else {
|
|
336945
|
-
|
|
337094
|
+
logger91.log(`[Ask Mode] Auto-exec: ${operationId}`);
|
|
336946
337095
|
}
|
|
336947
337096
|
try {
|
|
336948
337097
|
let approved;
|
|
@@ -336954,7 +337103,7 @@ ${marker28}
|
|
|
336954
337103
|
if (!approved) {
|
|
336955
337104
|
const execResultRejected = askPermissionInterceptor.getExecutionResult(operationId);
|
|
336956
337105
|
if (execResultRejected.exitCode !== void 0) {
|
|
336957
|
-
|
|
337106
|
+
logger91.log(
|
|
336958
337107
|
`[Ask Mode] Auto-approved op failed: ${operationId} (exit ${execResultRejected.exitCode})`
|
|
336959
337108
|
);
|
|
336960
337109
|
return JSON.stringify({
|
|
@@ -336984,7 +337133,7 @@ ${marker28}
|
|
|
336984
337133
|
}
|
|
336985
337134
|
if (approved) {
|
|
336986
337135
|
const execResult = askPermissionInterceptor.getExecutionResult(operationId);
|
|
336987
|
-
|
|
337136
|
+
logger91.log(`[Ask Mode] Permission approved: ${operationId}`);
|
|
336988
337137
|
const preview = permRequest.preview;
|
|
336989
337138
|
if (preview.path) {
|
|
336990
337139
|
ctx.filesWrittenInThisExchange.push(preview.path);
|
|
@@ -336994,7 +337143,7 @@ ${marker28}
|
|
|
336994
337143
|
output
|
|
336995
337144
|
);
|
|
336996
337145
|
if (hasCompilationErrors) {
|
|
336997
|
-
|
|
337146
|
+
logger91.log(
|
|
336998
337147
|
`[Ask Mode] Command output contains errors: ${operationId}`
|
|
336999
337148
|
);
|
|
337000
337149
|
return JSON.stringify({
|
|
@@ -337022,7 +337171,7 @@ ${marker28}
|
|
|
337022
337171
|
} else {
|
|
337023
337172
|
const execResultRejected = askPermissionInterceptor.getExecutionResult(operationId);
|
|
337024
337173
|
if (execResultRejected.exitCode !== void 0) {
|
|
337025
|
-
|
|
337174
|
+
logger91.log(
|
|
337026
337175
|
`[Ask Mode] Command failed: ${operationId} (exit ${execResultRejected.exitCode})`
|
|
337027
337176
|
);
|
|
337028
337177
|
return JSON.stringify({
|
|
@@ -337034,7 +337183,7 @@ ${marker28}
|
|
|
337034
337183
|
path: permRequest.preview.path || permRequest.preview.command
|
|
337035
337184
|
});
|
|
337036
337185
|
} else {
|
|
337037
|
-
|
|
337186
|
+
logger91.log(`[Ask Mode] Permission denied: ${operationId}`);
|
|
337038
337187
|
return JSON.stringify({
|
|
337039
337188
|
success: false,
|
|
337040
337189
|
error: "Permission denied by user",
|
|
@@ -337044,7 +337193,7 @@ ${marker28}
|
|
|
337044
337193
|
}
|
|
337045
337194
|
}
|
|
337046
337195
|
} catch (error51) {
|
|
337047
|
-
|
|
337196
|
+
logger91.error(
|
|
337048
337197
|
`[Ask Mode] Permission error: ${operationId}`,
|
|
337049
337198
|
error51
|
|
337050
337199
|
);
|
|
@@ -337121,13 +337270,13 @@ ${marker28}
|
|
|
337121
337270
|
}
|
|
337122
337271
|
});
|
|
337123
337272
|
}
|
|
337124
|
-
|
|
337273
|
+
logger91.log(
|
|
337125
337274
|
`Ask tier: ${Object.keys(askTools).length} tools (read-only${effectiveWorkMode === "plan" ? " + Plan tools" : ""}; MCP via list_available_mcps + mcp_call)`
|
|
337126
337275
|
);
|
|
337127
337276
|
{
|
|
337128
337277
|
const trimmed = peripheralToolNames(askToolsToInclude, effectiveWorkMode);
|
|
337129
337278
|
const { full, bound } = revealSavings(askToolsToInclude, effectiveWorkMode);
|
|
337130
|
-
|
|
337279
|
+
logger91.log(
|
|
337131
337280
|
`[tool-reveal] mode=${effectiveWorkMode} core=${askToolsToInclude.length - trimmed.length} peripheral=${trimmed.length} desc ${full}\u2192${bound} chars (\u2212${full - bound}); pointer=tool_help` + (trimmed.length > 0 ? ` [${trimmed.join(", ")}]` : "")
|
|
337132
337281
|
);
|
|
337133
337282
|
}
|
|
@@ -337215,10 +337364,10 @@ ${askParts.stableHeader}` : askParts.stableHeader;
|
|
|
337215
337364
|
}
|
|
337216
337365
|
askAgenticRepetition.setEnabled(false);
|
|
337217
337366
|
}
|
|
337218
|
-
var
|
|
337367
|
+
var import_electron_log94, logger91;
|
|
337219
337368
|
var init_ask_branch = __esm({
|
|
337220
337369
|
"src/ipc/handlers/chat_stream/turn-runner/ask-branch.ts"() {
|
|
337221
|
-
|
|
337370
|
+
import_electron_log94 = __toESM(require_src());
|
|
337222
337371
|
init_agent_runtime();
|
|
337223
337372
|
init_system_scope_commands();
|
|
337224
337373
|
init_register_delegation_tools();
|
|
@@ -337254,7 +337403,7 @@ var init_ask_branch = __esm({
|
|
|
337254
337403
|
init_resolve_toolset();
|
|
337255
337404
|
init_tool_reveal();
|
|
337256
337405
|
init_edit_stats2();
|
|
337257
|
-
|
|
337406
|
+
logger91 = import_electron_log94.default.scope("chat_stream_handlers");
|
|
337258
337407
|
}
|
|
337259
337408
|
});
|
|
337260
337409
|
|
|
@@ -337352,7 +337501,7 @@ function parseMiniMaxFormat(text3) {
|
|
|
337352
337501
|
args: args2,
|
|
337353
337502
|
rawMatch: match[0]
|
|
337354
337503
|
});
|
|
337355
|
-
|
|
337504
|
+
logger92.log(`[MiniMax] Parsed tool call: ${toolName}`, args2);
|
|
337356
337505
|
}
|
|
337357
337506
|
return results;
|
|
337358
337507
|
}
|
|
@@ -337409,7 +337558,7 @@ function parseLegacyAngleFunctionFormat(text3) {
|
|
|
337409
337558
|
args: args2,
|
|
337410
337559
|
rawMatch: match[0]
|
|
337411
337560
|
});
|
|
337412
|
-
|
|
337561
|
+
logger92.log(`[Legacy function=] Parsed tool call: ${toolName}`, args2);
|
|
337413
337562
|
}
|
|
337414
337563
|
return results;
|
|
337415
337564
|
}
|
|
@@ -337495,11 +337644,11 @@ function stripToolCallXML(text3) {
|
|
|
337495
337644
|
""
|
|
337496
337645
|
).replace(/<tool_call\s+name="[^"]+">[\s\S]*?<\/tool_call>/gi, "").replace(/<function_call\s+name="[^"]+">[\s\S]*?<\/function_call>/gi, "").replace(/<invoke\s+name="[^"]+"[^>]*>[\s\S]*?<\/invoke>/gi, "").trim();
|
|
337497
337646
|
}
|
|
337498
|
-
var
|
|
337647
|
+
var import_electron_log95, logger92;
|
|
337499
337648
|
var init_text_tool_parser = __esm({
|
|
337500
337649
|
"src/ipc/utils/text_tool_parser.ts"() {
|
|
337501
|
-
|
|
337502
|
-
|
|
337650
|
+
import_electron_log95 = __toESM(require_src());
|
|
337651
|
+
logger92 = import_electron_log95.default.scope("text-tool-parser");
|
|
337503
337652
|
}
|
|
337504
337653
|
});
|
|
337505
337654
|
|
|
@@ -337537,7 +337686,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
337537
337686
|
buildToolStreamOpts,
|
|
337538
337687
|
streamDebugLogging
|
|
337539
337688
|
} = deps;
|
|
337540
|
-
|
|
337689
|
+
logger93.log("Build mode with native tool calling + permission system");
|
|
337541
337690
|
const workspacePath = appPath;
|
|
337542
337691
|
let workspaceOverride = null;
|
|
337543
337692
|
const buildResolved = resolveToolsetForSession({
|
|
@@ -337592,7 +337741,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
337592
337741
|
isPermissionBased: true
|
|
337593
337742
|
// Don't force-switch to terminal tab
|
|
337594
337743
|
});
|
|
337595
|
-
|
|
337744
|
+
logger93.log(
|
|
337596
337745
|
`[Build Mode] Terminal output sent: ${payload.command} (${payload.status})`
|
|
337597
337746
|
);
|
|
337598
337747
|
});
|
|
@@ -337657,7 +337806,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
337657
337806
|
execute: async (args2, { toolCallId }) => {
|
|
337658
337807
|
const buildToolStartMs = Date.now();
|
|
337659
337808
|
if (streamDebugLogging) {
|
|
337660
|
-
|
|
337809
|
+
logger93.log(`[Build Tool] start`, {
|
|
337661
337810
|
toolName,
|
|
337662
337811
|
chatId: req.chatId,
|
|
337663
337812
|
argsKeys: args2 && typeof args2 === "object" ? Object.keys(args2) : []
|
|
@@ -337773,7 +337922,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
337773
337922
|
);
|
|
337774
337923
|
if (outcome.success && outcome.tokensAfter > 0) {
|
|
337775
337924
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
337776
|
-
|
|
337925
|
+
logger93.info(
|
|
337777
337926
|
`[DIAG_146] compress(build) chat=${req.chatId} ${outcome.tokensBefore}\u2192${outcome.tokensAfter} persisted=${outcome.summaryPersisted} \u2192 emit context-report dispatchedTokens=${outcome.tokensAfter}`
|
|
337778
337927
|
);
|
|
337779
337928
|
}
|
|
@@ -337867,7 +338016,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
337867
338016
|
r3.workspace_path,
|
|
337868
338017
|
r3.workspace_id
|
|
337869
338018
|
);
|
|
337870
|
-
|
|
338019
|
+
logger93.log(
|
|
337871
338020
|
`[Build Mode] Switched to new workspace for this turn: ${r3.workspace_path} (id: ${r3.workspace_id})`
|
|
337872
338021
|
);
|
|
337873
338022
|
}
|
|
@@ -338007,7 +338156,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338007
338156
|
output
|
|
338008
338157
|
);
|
|
338009
338158
|
if (hasCompilationErrors) {
|
|
338010
|
-
|
|
338159
|
+
logger93.log(
|
|
338011
338160
|
`[Build Mode] Command output contains errors: ${operationId}`
|
|
338012
338161
|
);
|
|
338013
338162
|
return JSON.stringify({
|
|
@@ -338024,7 +338173,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338024
338173
|
const verb = permRequest.operation === "edit_file" ? "wrote" : "executed";
|
|
338025
338174
|
const target = permRequest.preview.path || "operation";
|
|
338026
338175
|
if (isFileWrite && execResult.success === false) {
|
|
338027
|
-
|
|
338176
|
+
logger93.error(
|
|
338028
338177
|
`[Build Mode] edit_file result unavailable for ${operationId}: ${execResult.error ?? "unknown"}`
|
|
338029
338178
|
);
|
|
338030
338179
|
return JSON.stringify({
|
|
@@ -338043,7 +338192,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338043
338192
|
};
|
|
338044
338193
|
if (skipPermissionWait) {
|
|
338045
338194
|
try {
|
|
338046
|
-
|
|
338195
|
+
logger93.log(
|
|
338047
338196
|
`[Build Mode] Autonomous auto-exec: ${operationId}`
|
|
338048
338197
|
);
|
|
338049
338198
|
const execMeta = await permissionInterceptor.executeOperation(operationId);
|
|
@@ -338059,7 +338208,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338059
338208
|
)
|
|
338060
338209
|
);
|
|
338061
338210
|
if (execMeta.approved) {
|
|
338062
|
-
|
|
338211
|
+
logger93.log(
|
|
338063
338212
|
`[Build Mode] Autonomous permission executed: ${operationId}`
|
|
338064
338213
|
);
|
|
338065
338214
|
emitAutoApprovedWritePreview(
|
|
@@ -338073,7 +338222,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338073
338222
|
);
|
|
338074
338223
|
}
|
|
338075
338224
|
if (execResult.exitCode !== void 0) {
|
|
338076
|
-
|
|
338225
|
+
logger93.log(
|
|
338077
338226
|
`[Build Mode] Autonomous exec command failed: ${operationId} (exit ${execResult.exitCode})`
|
|
338078
338227
|
);
|
|
338079
338228
|
activityStatus = "error";
|
|
@@ -338098,7 +338247,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338098
338247
|
})
|
|
338099
338248
|
);
|
|
338100
338249
|
} catch (error51) {
|
|
338101
|
-
|
|
338250
|
+
logger93.error(
|
|
338102
338251
|
`[Build Mode] Autonomous permission error: ${operationId}`,
|
|
338103
338252
|
error51
|
|
338104
338253
|
);
|
|
@@ -338121,7 +338270,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338121
338270
|
);
|
|
338122
338271
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
338123
338272
|
const prev = permRequest.preview;
|
|
338124
|
-
|
|
338273
|
+
logger93.info(
|
|
338125
338274
|
`[DIAG_146] perm-edit op=${permRequest.operation} target=${prev.path ?? prev.command ?? ""} preflight+buffer=${__enrichT0 - __permEditT0}ms enrich/diff=${Date.now() - __enrichT0}ms (then awaits the user)`
|
|
338126
338275
|
);
|
|
338127
338276
|
}
|
|
@@ -338130,12 +338279,12 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338130
338279
|
operationId,
|
|
338131
338280
|
request: __enriched
|
|
338132
338281
|
});
|
|
338133
|
-
|
|
338282
|
+
logger93.log(
|
|
338134
338283
|
`[Build Mode] Permission request buffered: ${operationId}`
|
|
338135
338284
|
);
|
|
338136
338285
|
try {
|
|
338137
338286
|
if (streamDebugLogging) {
|
|
338138
|
-
|
|
338287
|
+
logger93.log(`[Build Tool] waitForApproval start`, {
|
|
338139
338288
|
operationId,
|
|
338140
338289
|
operation: permRequest.operation,
|
|
338141
338290
|
chatId: req.chatId
|
|
@@ -338147,7 +338296,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338147
338296
|
);
|
|
338148
338297
|
const approved = outcome === "approved";
|
|
338149
338298
|
if (streamDebugLogging) {
|
|
338150
|
-
|
|
338299
|
+
logger93.log(`[Build Tool] waitForApproval end`, {
|
|
338151
338300
|
operationId,
|
|
338152
338301
|
approved,
|
|
338153
338302
|
chatId: req.chatId
|
|
@@ -338155,7 +338304,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338155
338304
|
}
|
|
338156
338305
|
if (approved) {
|
|
338157
338306
|
const execResult = permissionInterceptor.getExecutionResult(operationId);
|
|
338158
|
-
|
|
338307
|
+
logger93.log(
|
|
338159
338308
|
`[Build Mode] Permission approved: ${operationId}`
|
|
338160
338309
|
);
|
|
338161
338310
|
return recordActivityResult(
|
|
@@ -338164,7 +338313,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338164
338313
|
} else {
|
|
338165
338314
|
const execResult = permissionInterceptor.getExecutionResult(operationId);
|
|
338166
338315
|
if (execResult.exitCode !== void 0) {
|
|
338167
|
-
|
|
338316
|
+
logger93.log(
|
|
338168
338317
|
`[Build Mode] Command failed: ${operationId} (exit ${execResult.exitCode})`
|
|
338169
338318
|
);
|
|
338170
338319
|
activityStatus = "error";
|
|
@@ -338180,7 +338329,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338180
338329
|
})
|
|
338181
338330
|
);
|
|
338182
338331
|
} else {
|
|
338183
|
-
|
|
338332
|
+
logger93.log(
|
|
338184
338333
|
`[Build Mode] Permission denied: ${operationId}`
|
|
338185
338334
|
);
|
|
338186
338335
|
activityStatus = "error";
|
|
@@ -338196,7 +338345,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338196
338345
|
}
|
|
338197
338346
|
} catch (error51) {
|
|
338198
338347
|
if (abortController.signal.aborted) throw error51;
|
|
338199
|
-
|
|
338348
|
+
logger93.error(
|
|
338200
338349
|
`[Build Mode] Permission error: ${operationId}`,
|
|
338201
338350
|
error51
|
|
338202
338351
|
);
|
|
@@ -338236,7 +338385,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338236
338385
|
);
|
|
338237
338386
|
const resultText = toolResultTextForExpand(toolResultForActivity);
|
|
338238
338387
|
if (streamDebugLogging) {
|
|
338239
|
-
|
|
338388
|
+
logger93.log(`[Build Tool] end`, {
|
|
338240
338389
|
toolName,
|
|
338241
338390
|
chatId: req.chatId,
|
|
338242
338391
|
ms: Date.now() - buildToolStartMs,
|
|
@@ -338290,14 +338439,14 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338290
338439
|
}
|
|
338291
338440
|
});
|
|
338292
338441
|
}
|
|
338293
|
-
|
|
338442
|
+
logger93.log(`Build mode: ${Object.keys(tools).length} tools available`);
|
|
338294
338443
|
{
|
|
338295
338444
|
const trimmed = peripheralToolNames(buildToolsToInclude, effectiveWorkMode);
|
|
338296
338445
|
const { full, bound } = revealSavings(
|
|
338297
338446
|
buildToolsToInclude,
|
|
338298
338447
|
effectiveWorkMode
|
|
338299
338448
|
);
|
|
338300
|
-
|
|
338449
|
+
logger93.log(
|
|
338301
338450
|
`[tool-reveal] mode=${effectiveWorkMode} core=${buildToolsToInclude.length - trimmed.length} peripheral=${trimmed.length} desc ${full}\u2192${bound} chars (\u2212${full - bound}); pointer=tool_help` + (trimmed.length > 0 ? ` [${trimmed.join(", ")}]` : "")
|
|
338302
338451
|
);
|
|
338303
338452
|
}
|
|
@@ -338414,7 +338563,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338414
338563
|
})
|
|
338415
338564
|
) : null;
|
|
338416
338565
|
if (allReadOnly) {
|
|
338417
|
-
|
|
338566
|
+
logger93.log(
|
|
338418
338567
|
`[Agentic Loop] Executed ${textToolCalls.length} read-only tools in parallel`
|
|
338419
338568
|
);
|
|
338420
338569
|
}
|
|
@@ -338668,7 +338817,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338668
338817
|
isReadOnlyWorkMode(effectiveWorkMode)
|
|
338669
338818
|
)
|
|
338670
338819
|
});
|
|
338671
|
-
|
|
338820
|
+
logger93.log(
|
|
338672
338821
|
`[Agentic Loop] Permission request buffered: ${operationId}`
|
|
338673
338822
|
);
|
|
338674
338823
|
hasPermissionRequest = true;
|
|
@@ -338730,10 +338879,10 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338730
338879
|
tool: toolCall.toolName,
|
|
338731
338880
|
result: resultStr
|
|
338732
338881
|
});
|
|
338733
|
-
|
|
338882
|
+
logger93.log(`[Agentic Loop] Tool executed: ${toolCall.toolName} \u2713`);
|
|
338734
338883
|
}
|
|
338735
338884
|
} catch (toolError) {
|
|
338736
|
-
|
|
338885
|
+
logger93.error(
|
|
338737
338886
|
`[Agentic Loop] Tool error: ${toolCall.toolName}`,
|
|
338738
338887
|
toolError
|
|
338739
338888
|
);
|
|
@@ -338818,7 +338967,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
338818
338967
|
ctx.turnForcedTextFinish = turnResult.forcedTextFinish;
|
|
338819
338968
|
}
|
|
338820
338969
|
ctx.fullResponse = stripToolCallXML2(ctx.fullResponse);
|
|
338821
|
-
|
|
338970
|
+
logger93.info(`[Agentic Loop] Completed:`, {
|
|
338822
338971
|
chatId: req.chatId,
|
|
338823
338972
|
iterations: agenticIteration,
|
|
338824
338973
|
toolsExecuted: totalToolExecutions,
|
|
@@ -338851,12 +339000,12 @@ ${stopNote}`;
|
|
|
338851
339000
|
{ force: true }
|
|
338852
339001
|
);
|
|
338853
339002
|
}
|
|
338854
|
-
|
|
339003
|
+
logger93.log(
|
|
338855
339004
|
`Persisted partial response to ephemeral chat ${chatId} after abort`
|
|
338856
339005
|
);
|
|
338857
339006
|
partialResponses.delete(req.chatId);
|
|
338858
339007
|
} catch (error51) {
|
|
338859
|
-
|
|
339008
|
+
logger93.error(
|
|
338860
339009
|
`Error saving partial response for chat ${chatId}:`,
|
|
338861
339010
|
error51
|
|
338862
339011
|
);
|
|
@@ -338865,7 +339014,7 @@ ${stopNote}`;
|
|
|
338865
339014
|
return { earlyReturn: true, value: req.chatId };
|
|
338866
339015
|
}
|
|
338867
339016
|
if (abortController.signal.aborted && ledgerCompleteStop) {
|
|
338868
|
-
|
|
339017
|
+
logger93.log(
|
|
338869
339018
|
`[Agentic Loop] Stream stopped after task ledger complete (chat ${req.chatId})`
|
|
338870
339019
|
);
|
|
338871
339020
|
captureStreamAbortLedgerCompleteIfNeeded();
|
|
@@ -338876,7 +339025,7 @@ ${stopNote}`;
|
|
|
338876
339025
|
agenticRepetition.setEnabled(false);
|
|
338877
339026
|
}
|
|
338878
339027
|
}
|
|
338879
|
-
var
|
|
339028
|
+
var import_electron_log96, logger93;
|
|
338880
339029
|
var init_build_branch = __esm({
|
|
338881
339030
|
"src/ipc/handlers/chat_stream/turn-runner/build-branch.ts"() {
|
|
338882
339031
|
init_file_read_log();
|
|
@@ -338922,9 +339071,9 @@ var init_build_branch = __esm({
|
|
|
338922
339071
|
init_resolve_toolset();
|
|
338923
339072
|
init_tool_reveal();
|
|
338924
339073
|
init_dist21();
|
|
338925
|
-
|
|
339074
|
+
import_electron_log96 = __toESM(require_src());
|
|
338926
339075
|
init_edit_stats2();
|
|
338927
|
-
|
|
339076
|
+
logger93 = import_electron_log96.default.scope("chat_stream_handlers");
|
|
338928
339077
|
}
|
|
338929
339078
|
});
|
|
338930
339079
|
|
|
@@ -338932,14 +339081,14 @@ var init_build_branch = __esm({
|
|
|
338932
339081
|
function trackPendingWork(promise3, label) {
|
|
338933
339082
|
pending.add(promise3);
|
|
338934
339083
|
promise3.catch(
|
|
338935
|
-
(e3) =>
|
|
339084
|
+
(e3) => logger94.warn(`[${label}] background work failed: ${String(e3)}`)
|
|
338936
339085
|
).finally(() => pending.delete(promise3));
|
|
338937
339086
|
}
|
|
338938
|
-
var
|
|
339087
|
+
var import_electron_log97, logger94, pending;
|
|
338939
339088
|
var init_pending_work = __esm({
|
|
338940
339089
|
"src/lib/pending-work.ts"() {
|
|
338941
|
-
|
|
338942
|
-
|
|
339090
|
+
import_electron_log97 = __toESM(require_src());
|
|
339091
|
+
logger94 = import_electron_log97.default.scope("pending-work");
|
|
338943
339092
|
pending = /* @__PURE__ */ new Set();
|
|
338944
339093
|
}
|
|
338945
339094
|
});
|
|
@@ -339044,12 +339193,12 @@ async function finalizeTurn(ctx, deps) {
|
|
|
339044
339193
|
nativeForPersist = boundNativeHistoryForPersist(nativeForPersist, {
|
|
339045
339194
|
budgetTokens: envelopeBudget
|
|
339046
339195
|
});
|
|
339047
|
-
|
|
339196
|
+
logger95.info(
|
|
339048
339197
|
`[stream:${req.chatId}] turn envelope bounded for persist: ~${before2} \u2192 ~${estimateModelMessagesTokens(nativeForPersist)} est. tokens (budget ${envelopeBudget})`
|
|
339049
339198
|
);
|
|
339050
339199
|
}
|
|
339051
339200
|
} catch (e3) {
|
|
339052
|
-
|
|
339201
|
+
logger95.warn(`[stream:${req.chatId}] envelope bounding skipped`, e3);
|
|
339053
339202
|
nativeForPersist = ctx.nativeTurnMessages;
|
|
339054
339203
|
}
|
|
339055
339204
|
}
|
|
@@ -339147,13 +339296,13 @@ async function finalizeTurn(ctx, deps) {
|
|
|
339147
339296
|
planStatus: updated.planStatus,
|
|
339148
339297
|
title: updated.title
|
|
339149
339298
|
});
|
|
339150
|
-
|
|
339299
|
+
logger95.info(
|
|
339151
339300
|
`[plan-artifact] safety net marked plan ${buildingPlan.id} built`
|
|
339152
339301
|
);
|
|
339153
339302
|
}
|
|
339154
339303
|
}
|
|
339155
339304
|
} catch (planEndErr) {
|
|
339156
|
-
|
|
339305
|
+
logger95.warn(
|
|
339157
339306
|
"[plan-artifact] build-complete status update failed:",
|
|
339158
339307
|
planEndErr
|
|
339159
339308
|
);
|
|
@@ -339182,7 +339331,7 @@ async function finalizeTurn(ctx, deps) {
|
|
|
339182
339331
|
const auxBySource = summarizeAuxBySource(auxUsage);
|
|
339183
339332
|
if (auxUsage) {
|
|
339184
339333
|
const est = auxUsage.totalEstimatedTokens;
|
|
339185
|
-
|
|
339334
|
+
logger95.log(
|
|
339186
339335
|
`[usage] auxiliary LLM tokens this turn: ${auxUsage.totalTokens}` + (est > 0 ? ` (+~${est} estimated)` : "") + ` across ${auxUsage.calls} call(s) \u2014 ${Object.entries(
|
|
339187
339336
|
auxUsage.byLabel
|
|
339188
339337
|
).map(
|
|
@@ -339264,7 +339413,7 @@ async function finalizeTurn(ctx, deps) {
|
|
|
339264
339413
|
async function handleTurnError(error51, ctx, deps) {
|
|
339265
339414
|
const { overflowRetried, req, event, abortController, streamId } = deps;
|
|
339266
339415
|
if (abortController.signal.aborted && abortReasonSentinel(abortController.signal.reason) === ASK_USER_STREAM_STOP) {
|
|
339267
|
-
|
|
339416
|
+
logger95.log(
|
|
339268
339417
|
`[ask_user] Stream ended at question (benign: ${error51 instanceof Error ? error51.name : String(error51)})`
|
|
339269
339418
|
);
|
|
339270
339419
|
try {
|
|
@@ -339291,7 +339440,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
339291
339440
|
});
|
|
339292
339441
|
}
|
|
339293
339442
|
} catch (finalizeErr) {
|
|
339294
|
-
|
|
339443
|
+
logger95.warn("[ask_user] Question-turn finalize failed:", finalizeErr);
|
|
339295
339444
|
}
|
|
339296
339445
|
partialResponses.delete(req.chatId);
|
|
339297
339446
|
safeSend(event.sender, "chat:response:end", {
|
|
@@ -339306,7 +339455,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
339306
339455
|
FileUploadsState.getInstance().clear(req.chatId);
|
|
339307
339456
|
return;
|
|
339308
339457
|
}
|
|
339309
|
-
|
|
339458
|
+
logger95.error("Error calling LLM:", error51);
|
|
339310
339459
|
if (error51 instanceof NetworkStreamDisconnectedError) {
|
|
339311
339460
|
safeSend(event.sender, "chat:stream:disconnected", {
|
|
339312
339461
|
chatId: req.chatId,
|
|
@@ -339416,7 +339565,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
339416
339565
|
readSettings().selectedModel?.provider
|
|
339417
339566
|
).catch(() => false);
|
|
339418
339567
|
if (compacted) {
|
|
339419
|
-
|
|
339568
|
+
logger95.warn(
|
|
339420
339569
|
`[stream:${req.chatId}] Context overflow \u2014 compacted and retrying dispatch once`
|
|
339421
339570
|
);
|
|
339422
339571
|
safeSend(event.sender, "chat:activity", {
|
|
@@ -339468,7 +339617,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
339468
339617
|
ctx.streamTerminated = true;
|
|
339469
339618
|
FileUploadsState.getInstance().clear(req.chatId);
|
|
339470
339619
|
}
|
|
339471
|
-
var
|
|
339620
|
+
var import_electron_log98, MAX_ENVELOPE_WINDOW_FRACTION, MIN_ENVELOPE_BUDGET_TOKENS, logger95;
|
|
339472
339621
|
var init_finalize = __esm({
|
|
339473
339622
|
"src/ipc/handlers/chat_stream/turn-runner/finalize.ts"() {
|
|
339474
339623
|
init_autonomous_session_state();
|
|
@@ -339497,10 +339646,10 @@ var init_finalize = __esm({
|
|
|
339497
339646
|
init_turn_usage_aggregator();
|
|
339498
339647
|
init_settings();
|
|
339499
339648
|
init_texts();
|
|
339500
|
-
|
|
339649
|
+
import_electron_log98 = __toESM(require_src());
|
|
339501
339650
|
MAX_ENVELOPE_WINDOW_FRACTION = 0.5;
|
|
339502
339651
|
MIN_ENVELOPE_BUDGET_TOKENS = 8e3;
|
|
339503
|
-
|
|
339652
|
+
logger95 = import_electron_log98.default.scope("chat_stream_handlers");
|
|
339504
339653
|
}
|
|
339505
339654
|
});
|
|
339506
339655
|
|
|
@@ -339537,7 +339686,7 @@ async function listAccountSkills() {
|
|
|
339537
339686
|
const { data, error: error51 } = await getSupabaseClient().from("account_skills").select("slug, name, description, body").eq("enabled", true).order("name", { ascending: true });
|
|
339538
339687
|
if (error51) {
|
|
339539
339688
|
if (error51.code !== "42P01" && error51.code !== "PGRST205") {
|
|
339540
|
-
|
|
339689
|
+
logger96.warn("[account-skills] read failed:", error51.message);
|
|
339541
339690
|
}
|
|
339542
339691
|
cache7 = { at: now2, skills: [] };
|
|
339543
339692
|
return [];
|
|
@@ -339558,7 +339707,7 @@ async function listAccountSkills() {
|
|
|
339558
339707
|
cache7 = { at: now2, skills };
|
|
339559
339708
|
return skills;
|
|
339560
339709
|
} catch (err2) {
|
|
339561
|
-
|
|
339710
|
+
logger96.warn("[account-skills] read threw:", err2);
|
|
339562
339711
|
cache7 = { at: now2, skills: [] };
|
|
339563
339712
|
return [];
|
|
339564
339713
|
}
|
|
@@ -339578,7 +339727,7 @@ async function materialiseAccountSkills() {
|
|
|
339578
339727
|
const wanted = /* @__PURE__ */ new Set();
|
|
339579
339728
|
for (const skill of skills) {
|
|
339580
339729
|
if (!safeSlug(skill.slug)) {
|
|
339581
|
-
|
|
339730
|
+
logger96.warn(`[account-skills] refusing unsafe slug: ${skill.slug}`);
|
|
339582
339731
|
continue;
|
|
339583
339732
|
}
|
|
339584
339733
|
const file2 = `${skill.slug}.md`;
|
|
@@ -339600,7 +339749,7 @@ ${skill.body}
|
|
|
339600
339749
|
}
|
|
339601
339750
|
}
|
|
339602
339751
|
} catch (err2) {
|
|
339603
|
-
|
|
339752
|
+
logger96.warn("[account-skills] could not write to disk:", err2);
|
|
339604
339753
|
return [];
|
|
339605
339754
|
}
|
|
339606
339755
|
return skills.filter((s3) => safeSlug(s3.slug)).map((s3) => ({
|
|
@@ -339609,13 +339758,13 @@ ${skill.body}
|
|
|
339609
339758
|
readPath: path60.join(dir, `${s3.slug}.md`)
|
|
339610
339759
|
}));
|
|
339611
339760
|
}
|
|
339612
|
-
var
|
|
339761
|
+
var import_electron_log99, logger96, CACHE_MS3, cache7;
|
|
339613
339762
|
var init_account_skills = __esm({
|
|
339614
339763
|
"src/lib/skills/account-skills.ts"() {
|
|
339615
339764
|
init_electron_stub();
|
|
339616
|
-
|
|
339765
|
+
import_electron_log99 = __toESM(require_src());
|
|
339617
339766
|
init_supabase_client();
|
|
339618
|
-
|
|
339767
|
+
logger96 = import_electron_log99.default.scope("account-skills");
|
|
339619
339768
|
CACHE_MS3 = 6e4;
|
|
339620
339769
|
cache7 = null;
|
|
339621
339770
|
}
|
|
@@ -339726,7 +339875,7 @@ async function loadPrioritySkillsForWorkspace(workspacePath, isWorkforce) {
|
|
|
339726
339875
|
};
|
|
339727
339876
|
skills.push(skill);
|
|
339728
339877
|
} catch (err2) {
|
|
339729
|
-
|
|
339878
|
+
logger97.warn(`[priority-skills] Failed to parse ${entry.name}:`, err2);
|
|
339730
339879
|
}
|
|
339731
339880
|
}
|
|
339732
339881
|
return skills.sort((a2, b3) => {
|
|
@@ -339741,11 +339890,11 @@ function filterSkillsForMode(skills, currentMode) {
|
|
|
339741
339890
|
(s3) => s3.modes.includes("*") || s3.modes.some((m3) => normalizeMode(m3) === wanted)
|
|
339742
339891
|
);
|
|
339743
339892
|
}
|
|
339744
|
-
var
|
|
339893
|
+
var import_electron_log100, logger97, SKILLS_DIR_REL, ALL_MODES;
|
|
339745
339894
|
var init_priority_skill_loader = __esm({
|
|
339746
339895
|
"src/lib/skills/priority-skill-loader.ts"() {
|
|
339747
|
-
|
|
339748
|
-
|
|
339896
|
+
import_electron_log100 = __toESM(require_src());
|
|
339897
|
+
logger97 = import_electron_log100.default.scope("priority-skill-loader");
|
|
339749
339898
|
SKILLS_DIR_REL = ".atlarix/skills";
|
|
339750
339899
|
ALL_MODES = ["ask", "build", "plan", "debug", "review"];
|
|
339751
339900
|
}
|
|
@@ -339794,7 +339943,7 @@ async function buildSkillIndex(workspacePath, currentMode) {
|
|
|
339794
339943
|
});
|
|
339795
339944
|
}
|
|
339796
339945
|
} catch (err2) {
|
|
339797
|
-
|
|
339946
|
+
logger98.warn("[skill-index] repo skills failed:", err2);
|
|
339798
339947
|
}
|
|
339799
339948
|
}
|
|
339800
339949
|
try {
|
|
@@ -339807,12 +339956,12 @@ async function buildSkillIndex(workspacePath, currentMode) {
|
|
|
339807
339956
|
});
|
|
339808
339957
|
}
|
|
339809
339958
|
} catch (err2) {
|
|
339810
|
-
|
|
339959
|
+
logger98.warn("[skill-index] account skills failed:", err2);
|
|
339811
339960
|
}
|
|
339812
339961
|
try {
|
|
339813
339962
|
entries2.push(...await loadGuideEntries());
|
|
339814
339963
|
} catch (err2) {
|
|
339815
|
-
|
|
339964
|
+
logger98.warn("[skill-index] bundled guides failed:", err2);
|
|
339816
339965
|
}
|
|
339817
339966
|
return entries2;
|
|
339818
339967
|
}
|
|
@@ -339840,15 +339989,15 @@ function formatSkillIndexForPrompt(entries2) {
|
|
|
339840
339989
|
}
|
|
339841
339990
|
return lines.join("\n");
|
|
339842
339991
|
}
|
|
339843
|
-
var
|
|
339992
|
+
var import_electron_log101, logger98, BUNDLED_GUIDES;
|
|
339844
339993
|
var init_skill_index = __esm({
|
|
339845
339994
|
"src/lib/skills/skill-index.ts"() {
|
|
339846
|
-
|
|
339995
|
+
import_electron_log101 = __toESM(require_src());
|
|
339847
339996
|
init_first_sentence();
|
|
339848
339997
|
init_account_skills();
|
|
339849
339998
|
init_skill_loader();
|
|
339850
339999
|
init_priority_skill_loader();
|
|
339851
|
-
|
|
340000
|
+
logger98 = import_electron_log101.default.scope("skill-index");
|
|
339852
340001
|
BUNDLED_GUIDES = [
|
|
339853
340002
|
{
|
|
339854
340003
|
file: "guides/memory.md",
|
|
@@ -339941,7 +340090,7 @@ async function loadModeSkillSection(p2) {
|
|
|
339941
340090
|
${modeSkillBody}`
|
|
339942
340091
|
};
|
|
339943
340092
|
} catch (skillErr) {
|
|
339944
|
-
|
|
340093
|
+
logger99.warn("[skills] Failed to load mode skill:", skillErr);
|
|
339945
340094
|
return null;
|
|
339946
340095
|
}
|
|
339947
340096
|
}
|
|
@@ -339954,12 +340103,12 @@ async function loadSkillsIndexSection(p2) {
|
|
|
339954
340103
|
);
|
|
339955
340104
|
const block = formatSkillIndexForPrompt(entries2);
|
|
339956
340105
|
if (!block.trim()) return null;
|
|
339957
|
-
|
|
340106
|
+
logger99.info(
|
|
339958
340107
|
`[skills-index] ${entries2.length} skill(s) indexed for mode "${effectiveWorkMode}" (${block.length} chars, bodies read on demand)`
|
|
339959
340108
|
);
|
|
339960
340109
|
return { name: "skillsIndex", priority: -2, content: block };
|
|
339961
340110
|
} catch (skillIndexErr) {
|
|
339962
|
-
|
|
340111
|
+
logger99.warn("[skills-index] Failed to build skill index:", skillIndexErr);
|
|
339963
340112
|
return null;
|
|
339964
340113
|
}
|
|
339965
340114
|
}
|
|
@@ -340001,7 +340150,7 @@ async function loadWorkspaceCapsSection(p2) {
|
|
|
340001
340150
|
content: capsBlock
|
|
340002
340151
|
};
|
|
340003
340152
|
} catch (capsErr) {
|
|
340004
|
-
|
|
340153
|
+
logger99.warn("[workspace-capabilities] Failed to load:", capsErr);
|
|
340005
340154
|
return null;
|
|
340006
340155
|
}
|
|
340007
340156
|
}
|
|
@@ -340047,7 +340196,7 @@ ${snippet}`
|
|
|
340047
340196
|
taskLedgerBlock
|
|
340048
340197
|
};
|
|
340049
340198
|
} catch (planCtxErr) {
|
|
340050
|
-
|
|
340199
|
+
logger99.warn("[plan-artifact] context inject failed:", planCtxErr);
|
|
340051
340200
|
return { section: null, taskLedgerBlock: null };
|
|
340052
340201
|
}
|
|
340053
340202
|
}
|
|
@@ -340082,12 +340231,12 @@ async function loadAtlarixMdSection(p2) {
|
|
|
340082
340231
|
instructions.source === "rules" ? `Read them with read_file \u2014 glob the directory, they all apply \u2014 before you change code or make a design decision, and follow them.` : `Read them with read_file before you change code or make a design decision, and follow them.`,
|
|
340083
340232
|
headings.length ? `Sections: ${headings.join(" \xB7 ")}` : ""
|
|
340084
340233
|
].filter(Boolean).join("\n");
|
|
340085
|
-
|
|
340234
|
+
logger99.info(
|
|
340086
340235
|
`Project instructions pointer (${instructions.source}, ${sizeKb}KB, ${headings.length} headings)`
|
|
340087
340236
|
);
|
|
340088
340237
|
return { name: "projectMemory", priority: 4, content };
|
|
340089
340238
|
} catch (memErr) {
|
|
340090
|
-
|
|
340239
|
+
logger99.warn("Failed to read project instructions:", memErr);
|
|
340091
340240
|
return null;
|
|
340092
340241
|
}
|
|
340093
340242
|
}
|
|
@@ -340123,20 +340272,20 @@ async function loadMemoryMdSection(p2) {
|
|
|
340123
340272
|
].join("\n");
|
|
340124
340273
|
return { name: "projectKnowledge", priority: 3.9, content };
|
|
340125
340274
|
} catch (memErr) {
|
|
340126
|
-
|
|
340275
|
+
logger99.warn("Failed to read agent memory index:", memErr);
|
|
340127
340276
|
return null;
|
|
340128
340277
|
}
|
|
340129
340278
|
}
|
|
340130
|
-
var
|
|
340279
|
+
var import_electron_log102, logger99;
|
|
340131
340280
|
var init_context_sections = __esm({
|
|
340132
340281
|
"src/ipc/handlers/chat_stream/context-sections.ts"() {
|
|
340133
|
-
|
|
340282
|
+
import_electron_log102 = __toESM(require_src());
|
|
340134
340283
|
init_skill_registry();
|
|
340135
340284
|
init_skill_loader();
|
|
340136
340285
|
init_skill_index();
|
|
340137
340286
|
init_project_memory2();
|
|
340138
340287
|
init_plan_checklist();
|
|
340139
|
-
|
|
340288
|
+
logger99 = import_electron_log102.default.scope("chat_stream_handlers");
|
|
340140
340289
|
}
|
|
340141
340290
|
});
|
|
340142
340291
|
|
|
@@ -340170,7 +340319,7 @@ function registerChatStreamHandlers() {
|
|
|
340170
340319
|
userStopped: isChatUserStopped(req.chatId)
|
|
340171
340320
|
});
|
|
340172
340321
|
if (wakeDrop) {
|
|
340173
|
-
|
|
340322
|
+
logger100.log(
|
|
340174
340323
|
`[wake] dropped system wake for chat ${req.chatId}: ${wakeDrop}`
|
|
340175
340324
|
);
|
|
340176
340325
|
return {
|
|
@@ -340232,7 +340381,7 @@ function registerChatStreamHandlers() {
|
|
|
340232
340381
|
}
|
|
340233
340382
|
};
|
|
340234
340383
|
const handleStreamStall = () => {
|
|
340235
|
-
|
|
340384
|
+
logger100.warn(
|
|
340236
340385
|
`[stream] Stall detected for chat ${req.chatId} \u2014 retrying`
|
|
340237
340386
|
);
|
|
340238
340387
|
handleStreamActivityPulse();
|
|
@@ -340340,7 +340489,7 @@ function registerChatStreamHandlers() {
|
|
|
340340
340489
|
const { isStreamTransportId: isStreamTransportId2, getStreamTransportAppId: getStreamTransportAppId2 } = await Promise.resolve().then(() => (init_stream_transport(), stream_transport_exports));
|
|
340341
340490
|
if (!isStreamTransportId2(req.chatId)) {
|
|
340342
340491
|
const legacyMsg = "Legacy database chats were removed. Open a workspace session from the sidebar.";
|
|
340343
|
-
|
|
340492
|
+
logger100.warn(`Chat ${req.chatId} rejected: legacy positive chat id`);
|
|
340344
340493
|
safeSend(event.sender, "chat:response:error", {
|
|
340345
340494
|
chatId: req.chatId,
|
|
340346
340495
|
streamId,
|
|
@@ -340358,12 +340507,12 @@ function registerChatStreamHandlers() {
|
|
|
340358
340507
|
if (isStreamTransportId2(req.chatId)) {
|
|
340359
340508
|
const ephemeralAppId = getStreamTransportAppId2(req.chatId);
|
|
340360
340509
|
if (ephemeralAppId) {
|
|
340361
|
-
|
|
340510
|
+
logger100.log(
|
|
340362
340511
|
`Chat ${req.chatId} is ephemeral workspace chat for app: ${ephemeralAppId}`
|
|
340363
340512
|
);
|
|
340364
340513
|
} else {
|
|
340365
340514
|
const noWorkspaceMsg = "Open a workspace folder to start chatting. Use Open folder on the welcome screen.";
|
|
340366
|
-
|
|
340515
|
+
logger100.warn(
|
|
340367
340516
|
`Chat ${req.chatId} rejected: ephemeral chat without workspace`
|
|
340368
340517
|
);
|
|
340369
340518
|
safeSend(event.sender, "chat:response:error", {
|
|
@@ -340405,7 +340554,7 @@ function registerChatStreamHandlers() {
|
|
|
340405
340554
|
lastUsedAt: /* @__PURE__ */ new Date(),
|
|
340406
340555
|
hasAnsweredQuestions: false
|
|
340407
340556
|
};
|
|
340408
|
-
|
|
340557
|
+
logger100.log(
|
|
340409
340558
|
`Ephemeral workspace chat loaded for app: ${appData.name} (${appData.path})`
|
|
340410
340559
|
);
|
|
340411
340560
|
}
|
|
@@ -340540,7 +340689,7 @@ function registerChatStreamHandlers() {
|
|
|
340540
340689
|
---
|
|
340541
340690
|
`;
|
|
340542
340691
|
} catch (err2) {
|
|
340543
|
-
|
|
340692
|
+
logger100.error(`Error reading file content: ${err2}`);
|
|
340544
340693
|
}
|
|
340545
340694
|
}
|
|
340546
340695
|
}
|
|
@@ -340591,7 +340740,7 @@ function registerChatStreamHandlers() {
|
|
|
340591
340740
|
try {
|
|
340592
340741
|
return await persistOnce();
|
|
340593
340742
|
} catch (firstErr) {
|
|
340594
|
-
|
|
340743
|
+
logger100.warn(
|
|
340595
340744
|
"Persist of workspace session user message failed \u2014 retrying once:",
|
|
340596
340745
|
firstErr
|
|
340597
340746
|
);
|
|
@@ -340605,7 +340754,7 @@ function registerChatStreamHandlers() {
|
|
|
340605
340754
|
{ chatId: req.chatId }
|
|
340606
340755
|
);
|
|
340607
340756
|
} catch (err2) {
|
|
340608
|
-
|
|
340757
|
+
logger100.error(
|
|
340609
340758
|
"Failed to persist workspace session user message (after retry) \u2014 a resume of this turn will see attachment stubs without bodies:",
|
|
340610
340759
|
err2
|
|
340611
340760
|
);
|
|
@@ -340644,11 +340793,11 @@ function registerChatStreamHandlers() {
|
|
|
340644
340793
|
name: activeUserAgent.model
|
|
340645
340794
|
};
|
|
340646
340795
|
}
|
|
340647
|
-
|
|
340796
|
+
logger100.log(
|
|
340648
340797
|
`[user-agent] active: ${activeUserAgent.name} (mode=${activeUserAgent.mode}${activeUserAgent.model ? `, model=${activeUserAgent.model}` : ""})`
|
|
340649
340798
|
);
|
|
340650
340799
|
} else {
|
|
340651
|
-
|
|
340800
|
+
logger100.warn(
|
|
340652
340801
|
`[user-agent] "${req.agentOverride}" not found \u2014 ignored`
|
|
340653
340802
|
);
|
|
340654
340803
|
}
|
|
@@ -340785,7 +340934,7 @@ function registerChatStreamHandlers() {
|
|
|
340785
340934
|
modelClient.builtinProviderId
|
|
340786
340935
|
);
|
|
340787
340936
|
const reasoningCatalogModelId = resolveReasoningCatalogModelId(effectiveModel);
|
|
340788
|
-
|
|
340937
|
+
logger100.log(
|
|
340789
340938
|
`[stream:${req.chatId}] model=${effectiveModel.provider}/${effectiveModel.name} reasoning=${enableNativeReasoning} wire=${modelClient.builtinProviderId ?? "?"} vendor=${reasoningCapabilityProvider ?? "?"}/${reasoningCatalogModelId} catalog=${catalogSaysReasons(
|
|
340790
340939
|
reasoningCapabilityProvider,
|
|
340791
340940
|
reasoningCatalogModelId
|
|
@@ -340796,7 +340945,7 @@ function registerChatStreamHandlers() {
|
|
|
340796
340945
|
}).kind}`
|
|
340797
340946
|
);
|
|
340798
340947
|
const budgetDetail = await contextWindowPromise;
|
|
340799
|
-
|
|
340948
|
+
logger100.log(
|
|
340800
340949
|
`[budget] model=${effectiveModel.provider}/${effectiveModel.name} contextWindow=${budgetDetail.contextWindow} source=${budgetDetail.source}`
|
|
340801
340950
|
);
|
|
340802
340951
|
const usedCompassThisStream = modelClient.builtinProviderId === "compass";
|
|
@@ -340814,7 +340963,7 @@ function registerChatStreamHandlers() {
|
|
|
340814
340963
|
let appPath = effectiveApp?.path ? resolveAppPath(effectiveApp.path) : "";
|
|
340815
340964
|
const effectiveAppId = effectiveApp?.id;
|
|
340816
340965
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
340817
|
-
|
|
340966
|
+
logger100.info(
|
|
340818
340967
|
`[DIAG_146] enforce-appId chat=${req.chatId} effectiveAppId=${effectiveAppId} path=${effectiveApp?.path ?? "<none>"}`
|
|
340819
340968
|
);
|
|
340820
340969
|
}
|
|
@@ -340823,11 +340972,11 @@ function registerChatStreamHandlers() {
|
|
|
340823
340972
|
void Promise.resolve().then(() => (init_skill_loader(), skill_loader_exports)).then((m3) => m3.clearSkillCache()).catch(() => {
|
|
340824
340973
|
});
|
|
340825
340974
|
}
|
|
340826
|
-
|
|
340975
|
+
logger100.log(
|
|
340827
340976
|
`Using workspace for chat ${req.chatId}: ${appPath || "(none)"} (appId: ${effectiveAppId ?? req.appId ?? "n/a"})`
|
|
340828
340977
|
);
|
|
340829
340978
|
if (hasWorkspace && appPath && !fs50.existsSync(appPath)) {
|
|
340830
|
-
|
|
340979
|
+
logger100.warn(`Workspace path does not exist on disk: ${appPath}`);
|
|
340831
340980
|
safeSend(event.sender, "chat:activity", {
|
|
340832
340981
|
id: `workspace-path-missing-${req.chatId}`,
|
|
340833
340982
|
type: "orchestrator_blocker",
|
|
@@ -340847,13 +340996,13 @@ function registerChatStreamHandlers() {
|
|
|
340847
340996
|
}) : "";
|
|
340848
340997
|
const otherAppsCodebaseInfo = mentionedContextBlock;
|
|
340849
340998
|
if (otherAppsCodebaseInfo) {
|
|
340850
|
-
|
|
340999
|
+
logger100.log(
|
|
340851
341000
|
`Injected @-mention context: ${contextMentions.files.length} file(s), ${contextMentions.dirs.length} folder(s)`
|
|
340852
341001
|
);
|
|
340853
341002
|
}
|
|
340854
341003
|
if (hasWorkspace) {
|
|
340855
|
-
|
|
340856
|
-
|
|
341004
|
+
logger100.log(`Extracted codebase information from ${appPath}`);
|
|
341005
|
+
logger100.log(
|
|
340857
341006
|
"codebaseInfo: length",
|
|
340858
341007
|
codebaseInfo.length,
|
|
340859
341008
|
"estimated tokens",
|
|
@@ -340882,18 +341031,18 @@ function registerChatStreamHandlers() {
|
|
|
340882
341031
|
const { sliceFromLastCompactionSummary: sliceFromLastCompactionSummary2 } = await Promise.resolve().then(() => (init_compaction(), compaction_exports));
|
|
340883
341032
|
const sliced = sliceFromLastCompactionSummary2(messageHistory);
|
|
340884
341033
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
340885
|
-
|
|
341034
|
+
logger100.info(
|
|
340886
341035
|
`[DIAG_146] dispatch-slice chat=${req.chatId} markerFound=${sliced.length !== messageHistory.length} fullLen=${messageHistory.length} slicedLen=${sliced.length}`
|
|
340887
341036
|
);
|
|
340888
341037
|
}
|
|
340889
341038
|
if (sliced.length !== messageHistory.length) {
|
|
340890
|
-
|
|
341039
|
+
logger100.log(
|
|
340891
341040
|
`[stream:${req.chatId}] Compaction summary found \u2014 model history ${messageHistory.length} \u2192 ${sliced.length} messages`
|
|
340892
341041
|
);
|
|
340893
341042
|
messageHistory = sliced;
|
|
340894
341043
|
}
|
|
340895
341044
|
}
|
|
340896
|
-
|
|
341045
|
+
logger100.log(
|
|
340897
341046
|
`[stream:${req.chatId}] Prepared message history (len=${messageHistory.length})`
|
|
340898
341047
|
);
|
|
340899
341048
|
let limitedMessageHistory = messageHistory;
|
|
@@ -340923,7 +341072,7 @@ function registerChatStreamHandlers() {
|
|
|
340923
341072
|
unattended: Boolean(req.automation)
|
|
340924
341073
|
}).total;
|
|
340925
341074
|
} catch (e3) {
|
|
340926
|
-
|
|
341075
|
+
logger100.warn(
|
|
340927
341076
|
`[budget] tool-surface measurement failed; budget decisions this turn use the system prompt alone: ${String(e3)}`
|
|
340928
341077
|
);
|
|
340929
341078
|
}
|
|
@@ -341097,7 +341246,7 @@ ${baseSystemPrompt}`;
|
|
|
341097
341246
|
effectiveModel,
|
|
341098
341247
|
contextWindowTokens
|
|
341099
341248
|
);
|
|
341100
|
-
|
|
341249
|
+
logger100.info(
|
|
341101
341250
|
`[budget] window=${contextWindowTokens} usable=${usableTokens} reserve=${contextWindowTokens - usableTokens}`
|
|
341102
341251
|
);
|
|
341103
341252
|
const applyTierEscalation = async (_args) => false;
|
|
@@ -341232,7 +341381,7 @@ ${baseSystemPrompt}`;
|
|
|
341232
341381
|
if (done || !ttftShouldLog || ttftStartRef.ms == null) return;
|
|
341233
341382
|
done = true;
|
|
341234
341383
|
const openRouterCompressionApplied = (modelClient.builtinProviderId === "openrouter" || modelClient.builtinProviderId === "compass") && (budgetTracker.isCritical() || budgetTracker.isOverLimit());
|
|
341235
|
-
|
|
341384
|
+
logger100.log(
|
|
341236
341385
|
`[TTFT] provider=${String(modelClient.builtinProviderId)} model=${String(effectiveModel?.name ?? "")} contextLength=${modelContextResolved.rawContextLength ?? "unknown"} ttft=${Date.now() - ttftStartRef.ms}ms budgetTier=${budgetTracker.getBudgetTier()} estimatedTokens=${dispatchEstimate} pruningApplied=${contextBudgetPruningApplied} compressionApplied=${openRouterCompressionApplied} budgetDroppedMessages=${budgetDroppedMessages}`
|
|
341237
341386
|
);
|
|
341238
341387
|
};
|
|
@@ -341495,13 +341644,13 @@ ${baseSystemPrompt}`;
|
|
|
341495
341644
|
async () => {
|
|
341496
341645
|
if (fs50.existsSync(filePath)) {
|
|
341497
341646
|
await unlink2(filePath);
|
|
341498
|
-
|
|
341647
|
+
logger100.log(`Deleted temporary file: ${filePath}`);
|
|
341499
341648
|
}
|
|
341500
341649
|
},
|
|
341501
341650
|
30 * 60 * 1e3
|
|
341502
341651
|
);
|
|
341503
341652
|
} catch (error51) {
|
|
341504
|
-
|
|
341653
|
+
logger100.error(`Error scheduling file deletion: ${error51}`);
|
|
341505
341654
|
}
|
|
341506
341655
|
}
|
|
341507
341656
|
}
|
|
@@ -341536,7 +341685,7 @@ ${baseSystemPrompt}`;
|
|
|
341536
341685
|
registerLifecycleHandlers(chatStreamHandler);
|
|
341537
341686
|
registerRevertHandlers();
|
|
341538
341687
|
}
|
|
341539
|
-
var
|
|
341688
|
+
var import_electron_log103, logger100, TEMP_DIR;
|
|
341540
341689
|
var init_chat_stream_handlers = __esm({
|
|
341541
341690
|
"src/ipc/handlers/chat_stream_handlers.ts"() {
|
|
341542
341691
|
init_electron_stub();
|
|
@@ -341558,7 +341707,7 @@ var init_chat_stream_handlers = __esm({
|
|
|
341558
341707
|
init_active_model_identity();
|
|
341559
341708
|
init_turn_usage_aggregator();
|
|
341560
341709
|
init_stream_stop_sentinels();
|
|
341561
|
-
|
|
341710
|
+
import_electron_log103 = __toESM(require_src());
|
|
341562
341711
|
init_safe_sender();
|
|
341563
341712
|
init_stream_transport();
|
|
341564
341713
|
init_stream_debug();
|
|
@@ -341604,7 +341753,7 @@ var init_chat_stream_handlers = __esm({
|
|
|
341604
341753
|
init_build_branch();
|
|
341605
341754
|
init_finalize();
|
|
341606
341755
|
init_context_sections();
|
|
341607
|
-
|
|
341756
|
+
logger100 = import_electron_log103.default.scope("chat_stream_handlers");
|
|
341608
341757
|
TEMP_DIR = path63.join(os21.tmpdir(), "atlarix-attachments");
|
|
341609
341758
|
if (!fs50.existsSync(TEMP_DIR)) {
|
|
341610
341759
|
fs50.mkdirSync(TEMP_DIR, { recursive: true });
|
|
@@ -341631,7 +341780,7 @@ function broadcastCoreModelsChanged() {
|
|
|
341631
341780
|
if (!win.isDestroyed()) win.webContents.send("core-models:changed");
|
|
341632
341781
|
}
|
|
341633
341782
|
} catch (e3) {
|
|
341634
|
-
|
|
341783
|
+
logger101.warn("core-models change broadcast failed", e3);
|
|
341635
341784
|
}
|
|
341636
341785
|
}
|
|
341637
341786
|
function applyOverridesAndNotify(raw) {
|
|
@@ -341738,7 +341887,7 @@ async function saveToCache2(raw) {
|
|
|
341738
341887
|
await fs52.mkdir(path65.dirname(cachePath), { recursive: true });
|
|
341739
341888
|
await fs52.writeFile(cachePath, JSON.stringify(raw), "utf-8");
|
|
341740
341889
|
} catch (e3) {
|
|
341741
|
-
|
|
341890
|
+
logger101.warn("failed to save core-models cache", e3);
|
|
341742
341891
|
}
|
|
341743
341892
|
}
|
|
341744
341893
|
async function fetchCoreModelsOnce() {
|
|
@@ -341773,7 +341922,7 @@ async function refreshCoreModelOverrides() {
|
|
|
341773
341922
|
} catch (e3) {
|
|
341774
341923
|
lastError = e3;
|
|
341775
341924
|
if (attempt < FETCH_ATTEMPTS) {
|
|
341776
|
-
|
|
341925
|
+
logger101.warn(
|
|
341777
341926
|
`core-models fetch attempt ${attempt}/${FETCH_ATTEMPTS} failed, retrying`,
|
|
341778
341927
|
e3
|
|
341779
341928
|
);
|
|
@@ -341786,21 +341935,21 @@ async function refreshCoreModelOverrides() {
|
|
|
341786
341935
|
if (map3) {
|
|
341787
341936
|
await saveToCache2(raw);
|
|
341788
341937
|
applyOverridesAndNotify(raw);
|
|
341789
|
-
|
|
341938
|
+
logger101.info(
|
|
341790
341939
|
`loaded ${Object.keys(map3).length} Core model override(s)`,
|
|
341791
341940
|
map3
|
|
341792
341941
|
);
|
|
341793
341942
|
return;
|
|
341794
341943
|
}
|
|
341795
|
-
|
|
341944
|
+
logger101.warn(
|
|
341796
341945
|
"core-models.json had no usable overrides \u2014 keeping env fallback"
|
|
341797
341946
|
);
|
|
341798
341947
|
} catch (e3) {
|
|
341799
|
-
|
|
341948
|
+
logger101.warn("core-models fetch failed, trying cache", e3);
|
|
341800
341949
|
const cachedRaw = await loadRawFromCache();
|
|
341801
341950
|
if (cachedRaw && parseCoreModelsPayload(cachedRaw)) {
|
|
341802
341951
|
applyOverridesAndNotify(cachedRaw);
|
|
341803
|
-
|
|
341952
|
+
logger101.info("applied cached Core override(s)");
|
|
341804
341953
|
}
|
|
341805
341954
|
}
|
|
341806
341955
|
}
|
|
@@ -341818,15 +341967,15 @@ function warmCoreModelOverrides() {
|
|
|
341818
341967
|
refreshTimer2.unref();
|
|
341819
341968
|
}
|
|
341820
341969
|
}
|
|
341821
|
-
var
|
|
341970
|
+
var import_electron_log104, logger101, FETCH_TIMEOUT_MS2, REFRESH_INTERVAL_MS2, REMOTE_URL, CORE_TIER_IDS, refreshTimer2, lastAppliedSerialized, FETCH_ATTEMPTS, RETRY_DELAY_MS;
|
|
341822
341971
|
var init_core_model_overrides = __esm({
|
|
341823
341972
|
"src/lib/routing/core-model-overrides.ts"() {
|
|
341824
|
-
|
|
341973
|
+
import_electron_log104 = __toESM(require_src());
|
|
341825
341974
|
init_electron_stub();
|
|
341826
341975
|
init_paths();
|
|
341827
341976
|
init_compass_constants();
|
|
341828
341977
|
init_core_model_override_store();
|
|
341829
|
-
|
|
341978
|
+
logger101 = import_electron_log104.default.scope("core-models");
|
|
341830
341979
|
FETCH_TIMEOUT_MS2 = 15e3;
|
|
341831
341980
|
REFRESH_INTERVAL_MS2 = 60 * 60 * 1e3;
|
|
341832
341981
|
REMOTE_URL = process.env.ATLARIX_CORE_MODELS_URL ?? "https://raw.githubusercontent.com/AmariahAK/atlarix-releases/main/core-models.json";
|
|
@@ -342816,7 +342965,7 @@ ${err2.stack}` : "";
|
|
|
342816
342965
|
}
|
|
342817
342966
|
|
|
342818
342967
|
// src/headless/atlarix-headless.mts
|
|
342819
|
-
var VERSION15 = false ? "dev" : "15.
|
|
342968
|
+
var VERSION15 = false ? "dev" : "15.2.0";
|
|
342820
342969
|
if (process.argv[2] === "run") process.argv.splice(2, 1);
|
|
342821
342970
|
function arg(name29) {
|
|
342822
342971
|
const i4 = process.argv.indexOf(`--${name29}`);
|