atlarix 14.41.0 → 14.42.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.
|
@@ -6528,10 +6528,10 @@ var init_session2 = __esm({
|
|
|
6528
6528
|
}
|
|
6529
6529
|
};
|
|
6530
6530
|
PreparedQuery = class extends SQLitePreparedQuery {
|
|
6531
|
-
constructor(stmt, query,
|
|
6531
|
+
constructor(stmt, query, logger94, cache6, queryMetadata, cacheConfig, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
|
6532
6532
|
super("sync", executeMethod, query, cache6, queryMetadata, cacheConfig);
|
|
6533
6533
|
this.stmt = stmt;
|
|
6534
|
-
this.logger =
|
|
6534
|
+
this.logger = logger94;
|
|
6535
6535
|
this.fields = fields;
|
|
6536
6536
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
6537
6537
|
this.customResultMapper = customResultMapper;
|
|
@@ -6543,10 +6543,10 @@ var init_session2 = __esm({
|
|
|
6543
6543
|
return this.stmt.run(...params);
|
|
6544
6544
|
}
|
|
6545
6545
|
all(placeholderValues) {
|
|
6546
|
-
const { fields, joinsNotNullableMap, query, logger:
|
|
6546
|
+
const { fields, joinsNotNullableMap, query, logger: logger94, stmt, customResultMapper } = this;
|
|
6547
6547
|
if (!fields && !customResultMapper) {
|
|
6548
6548
|
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
|
6549
|
-
|
|
6549
|
+
logger94.logQuery(query.sql, params);
|
|
6550
6550
|
return stmt.all(...params);
|
|
6551
6551
|
}
|
|
6552
6552
|
const rows = this.values(placeholderValues);
|
|
@@ -6588,11 +6588,11 @@ var init_session2 = __esm({
|
|
|
6588
6588
|
import Client from "better-sqlite3";
|
|
6589
6589
|
function construct(client2, config2 = {}) {
|
|
6590
6590
|
const dialect = new SQLiteSyncDialect({ casing: config2.casing });
|
|
6591
|
-
let
|
|
6591
|
+
let logger94;
|
|
6592
6592
|
if (config2.logger === true) {
|
|
6593
|
-
|
|
6593
|
+
logger94 = new DefaultLogger();
|
|
6594
6594
|
} else if (config2.logger !== false) {
|
|
6595
|
-
|
|
6595
|
+
logger94 = config2.logger;
|
|
6596
6596
|
}
|
|
6597
6597
|
let schema;
|
|
6598
6598
|
if (config2.schema) {
|
|
@@ -6606,7 +6606,7 @@ function construct(client2, config2 = {}) {
|
|
|
6606
6606
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
6607
6607
|
};
|
|
6608
6608
|
}
|
|
6609
|
-
const session2 = new BetterSQLiteSession(client2, dialect, schema, { logger:
|
|
6609
|
+
const session2 = new BetterSQLiteSession(client2, dialect, schema, { logger: logger94 });
|
|
6610
6610
|
const db2 = new BetterSQLite3Database("sync", dialect, session2, schema);
|
|
6611
6611
|
db2.$client = client2;
|
|
6612
6612
|
return db2;
|
|
@@ -7791,7 +7791,7 @@ var require_scope = __commonJS({
|
|
|
7791
7791
|
"node_modules/electron-log/src/core/scope.js"(exports2, module2) {
|
|
7792
7792
|
"use strict";
|
|
7793
7793
|
module2.exports = scopeFactory;
|
|
7794
|
-
function scopeFactory(
|
|
7794
|
+
function scopeFactory(logger94) {
|
|
7795
7795
|
return Object.defineProperties(scope, {
|
|
7796
7796
|
defaultLabel: { value: "", writable: true },
|
|
7797
7797
|
labelPadding: { value: true, writable: true },
|
|
@@ -7812,8 +7812,8 @@ var require_scope = __commonJS({
|
|
|
7812
7812
|
function scope(label) {
|
|
7813
7813
|
scope.maxLabelLength = Math.max(scope.maxLabelLength, label.length);
|
|
7814
7814
|
const newScope = {};
|
|
7815
|
-
for (const level of
|
|
7816
|
-
newScope[level] = (...d2) =>
|
|
7815
|
+
for (const level of logger94.levels) {
|
|
7816
|
+
newScope[level] = (...d2) => logger94.logData(d2, { level, scope: label });
|
|
7817
7817
|
}
|
|
7818
7818
|
newScope.log = newScope.info;
|
|
7819
7819
|
return newScope;
|
|
@@ -8106,7 +8106,7 @@ var require_transform = __commonJS({
|
|
|
8106
8106
|
"use strict";
|
|
8107
8107
|
module2.exports = { transform: transform2 };
|
|
8108
8108
|
function transform2({
|
|
8109
|
-
logger:
|
|
8109
|
+
logger: logger94,
|
|
8110
8110
|
message,
|
|
8111
8111
|
transport,
|
|
8112
8112
|
initialData = message?.data || [],
|
|
@@ -8114,7 +8114,7 @@ var require_transform = __commonJS({
|
|
|
8114
8114
|
}) {
|
|
8115
8115
|
return transforms.reduce((data, trans) => {
|
|
8116
8116
|
if (typeof trans === "function") {
|
|
8117
|
-
return trans({ data, logger:
|
|
8117
|
+
return trans({ data, logger: logger94, message, transport });
|
|
8118
8118
|
}
|
|
8119
8119
|
return data;
|
|
8120
8120
|
}, initialData);
|
|
@@ -8137,7 +8137,7 @@ var require_console = __commonJS({
|
|
|
8137
8137
|
silly: console.debug,
|
|
8138
8138
|
log: console.log
|
|
8139
8139
|
};
|
|
8140
|
-
function consoleTransportRendererFactory(
|
|
8140
|
+
function consoleTransportRendererFactory(logger94) {
|
|
8141
8141
|
return Object.assign(transport, {
|
|
8142
8142
|
format: "{h}:{i}:{s}.{ms}{scope} \u203A {text}",
|
|
8143
8143
|
transforms: [formatDataFn],
|
|
@@ -8148,13 +8148,13 @@ var require_console = __commonJS({
|
|
|
8148
8148
|
});
|
|
8149
8149
|
function transport(message) {
|
|
8150
8150
|
transport.writeFn({
|
|
8151
|
-
message: { ...message, data: transform2({ logger:
|
|
8151
|
+
message: { ...message, data: transform2({ logger: logger94, message, transport }) }
|
|
8152
8152
|
});
|
|
8153
8153
|
}
|
|
8154
8154
|
}
|
|
8155
8155
|
function formatDataFn({
|
|
8156
8156
|
data = [],
|
|
8157
|
-
logger:
|
|
8157
|
+
logger: logger94 = {},
|
|
8158
8158
|
message = {},
|
|
8159
8159
|
transport = {}
|
|
8160
8160
|
}) {
|
|
@@ -8162,7 +8162,7 @@ var require_console = __commonJS({
|
|
|
8162
8162
|
return transport.format({
|
|
8163
8163
|
data,
|
|
8164
8164
|
level: message?.level || "info",
|
|
8165
|
-
logger:
|
|
8165
|
+
logger: logger94,
|
|
8166
8166
|
message,
|
|
8167
8167
|
transport
|
|
8168
8168
|
});
|
|
@@ -8182,7 +8182,7 @@ var require_console = __commonJS({
|
|
|
8182
8182
|
case "logId":
|
|
8183
8183
|
return message.logId;
|
|
8184
8184
|
case "scope": {
|
|
8185
|
-
const scope = message.scope ||
|
|
8185
|
+
const scope = message.scope || logger94.scope?.defaultLabel;
|
|
8186
8186
|
return scope ? ` (${scope})` : "";
|
|
8187
8187
|
}
|
|
8188
8188
|
case "text":
|
|
@@ -8219,14 +8219,14 @@ var require_ipc = __commonJS({
|
|
|
8219
8219
|
var { transform: transform2 } = require_transform();
|
|
8220
8220
|
module2.exports = ipcTransportRendererFactory;
|
|
8221
8221
|
var RESTRICTED_TYPES = /* @__PURE__ */ new Set([Promise, WeakMap, WeakSet]);
|
|
8222
|
-
function ipcTransportRendererFactory(
|
|
8222
|
+
function ipcTransportRendererFactory(logger94) {
|
|
8223
8223
|
return Object.assign(transport, {
|
|
8224
8224
|
depth: 5,
|
|
8225
8225
|
transforms: [serializeFn]
|
|
8226
8226
|
});
|
|
8227
8227
|
function transport(message) {
|
|
8228
8228
|
if (!window.__electronLog) {
|
|
8229
|
-
|
|
8229
|
+
logger94.processMessage(
|
|
8230
8230
|
{
|
|
8231
8231
|
data: ["electron-log: logger isn't initialized in the main process"],
|
|
8232
8232
|
level: "error"
|
|
@@ -8238,13 +8238,13 @@ var require_ipc = __commonJS({
|
|
|
8238
8238
|
try {
|
|
8239
8239
|
const serialized = transform2({
|
|
8240
8240
|
initialData: message,
|
|
8241
|
-
logger:
|
|
8241
|
+
logger: logger94,
|
|
8242
8242
|
message,
|
|
8243
8243
|
transport
|
|
8244
8244
|
});
|
|
8245
8245
|
__electronLog.sendToMain(serialized);
|
|
8246
8246
|
} catch (e3) {
|
|
8247
|
-
|
|
8247
|
+
logger94.transports.console({
|
|
8248
8248
|
data: ["electronLog.transports.ipc", e3, "data:", message.data],
|
|
8249
8249
|
level: "error"
|
|
8250
8250
|
});
|
|
@@ -8340,7 +8340,7 @@ var require_renderer = __commonJS({
|
|
|
8340
8340
|
module2.exports.Logger = Logger;
|
|
8341
8341
|
module2.exports.default = module2.exports;
|
|
8342
8342
|
function createLogger() {
|
|
8343
|
-
const
|
|
8343
|
+
const logger94 = new Logger({
|
|
8344
8344
|
allowUnknownLevel: true,
|
|
8345
8345
|
errorHandler: new RendererErrorHandler(),
|
|
8346
8346
|
initializeFn: () => {
|
|
@@ -8354,13 +8354,13 @@ var require_renderer = __commonJS({
|
|
|
8354
8354
|
processType: "renderer"
|
|
8355
8355
|
}
|
|
8356
8356
|
});
|
|
8357
|
-
|
|
8357
|
+
logger94.errorHandler.setOptions({
|
|
8358
8358
|
logFn({ error: error51, errorName, showDialog }) {
|
|
8359
|
-
|
|
8359
|
+
logger94.transports.console({
|
|
8360
8360
|
data: [errorName, error51].filter(Boolean),
|
|
8361
8361
|
level: "error"
|
|
8362
8362
|
});
|
|
8363
|
-
|
|
8363
|
+
logger94.transports.ipc({
|
|
8364
8364
|
cmd: "errorHandler",
|
|
8365
8365
|
error: {
|
|
8366
8366
|
cause: error51?.cause,
|
|
@@ -8370,7 +8370,7 @@ var require_renderer = __commonJS({
|
|
|
8370
8370
|
stack: error51?.stack
|
|
8371
8371
|
},
|
|
8372
8372
|
errorName,
|
|
8373
|
-
logId:
|
|
8373
|
+
logId: logger94.logId,
|
|
8374
8374
|
showDialog
|
|
8375
8375
|
});
|
|
8376
8376
|
}
|
|
@@ -8384,12 +8384,12 @@ var require_renderer = __commonJS({
|
|
|
8384
8384
|
}
|
|
8385
8385
|
});
|
|
8386
8386
|
}
|
|
8387
|
-
return new Proxy(
|
|
8387
|
+
return new Proxy(logger94, {
|
|
8388
8388
|
get(target, prop) {
|
|
8389
8389
|
if (typeof target[prop] !== "undefined") {
|
|
8390
8390
|
return target[prop];
|
|
8391
8391
|
}
|
|
8392
|
-
return (...data) =>
|
|
8392
|
+
return (...data) => logger94.logData(data, { level: prop });
|
|
8393
8393
|
}
|
|
8394
8394
|
});
|
|
8395
8395
|
}
|
|
@@ -8826,7 +8826,7 @@ var require_initialize = __commonJS({
|
|
|
8826
8826
|
externalApi,
|
|
8827
8827
|
getSessions,
|
|
8828
8828
|
includeFutureSession,
|
|
8829
|
-
logger:
|
|
8829
|
+
logger: logger94,
|
|
8830
8830
|
preload = true,
|
|
8831
8831
|
spyRendererConsole = false
|
|
8832
8832
|
}) {
|
|
@@ -8837,15 +8837,15 @@ var require_initialize = __commonJS({
|
|
|
8837
8837
|
externalApi,
|
|
8838
8838
|
getSessions,
|
|
8839
8839
|
includeFutureSession,
|
|
8840
|
-
logger:
|
|
8840
|
+
logger: logger94,
|
|
8841
8841
|
preloadOption: preload
|
|
8842
8842
|
});
|
|
8843
8843
|
}
|
|
8844
8844
|
if (spyRendererConsole) {
|
|
8845
|
-
initializeSpyRendererConsole({ externalApi, logger:
|
|
8845
|
+
initializeSpyRendererConsole({ externalApi, logger: logger94 });
|
|
8846
8846
|
}
|
|
8847
8847
|
} catch (err2) {
|
|
8848
|
-
|
|
8848
|
+
logger94.warn(err2);
|
|
8849
8849
|
}
|
|
8850
8850
|
});
|
|
8851
8851
|
}
|
|
@@ -8854,12 +8854,12 @@ var require_initialize = __commonJS({
|
|
|
8854
8854
|
externalApi,
|
|
8855
8855
|
getSessions,
|
|
8856
8856
|
includeFutureSession,
|
|
8857
|
-
logger:
|
|
8857
|
+
logger: logger94,
|
|
8858
8858
|
preloadOption
|
|
8859
8859
|
}) {
|
|
8860
8860
|
let preloadPath = typeof preloadOption === "string" ? preloadOption : void 0;
|
|
8861
8861
|
if (preloadInitialized) {
|
|
8862
|
-
|
|
8862
|
+
logger94.warn(new Error("log.initialize({ preload }) already called").stack);
|
|
8863
8863
|
return;
|
|
8864
8864
|
}
|
|
8865
8865
|
preloadInitialized = true;
|
|
@@ -8890,9 +8890,9 @@ var require_initialize = __commonJS({
|
|
|
8890
8890
|
getSessions
|
|
8891
8891
|
});
|
|
8892
8892
|
}
|
|
8893
|
-
function initializeSpyRendererConsole({ externalApi, logger:
|
|
8893
|
+
function initializeSpyRendererConsole({ externalApi, logger: logger94 }) {
|
|
8894
8894
|
if (spyConsoleInitialized) {
|
|
8895
|
-
|
|
8895
|
+
logger94.warn(
|
|
8896
8896
|
new Error("log.initialize({ spyRendererConsole }) already called").stack
|
|
8897
8897
|
);
|
|
8898
8898
|
return;
|
|
@@ -8902,7 +8902,7 @@ var require_initialize = __commonJS({
|
|
|
8902
8902
|
externalApi.onEveryWebContentsEvent(
|
|
8903
8903
|
"console-message",
|
|
8904
8904
|
(event, level, message) => {
|
|
8905
|
-
|
|
8905
|
+
logger94.processMessage({
|
|
8906
8906
|
data: [message],
|
|
8907
8907
|
level: levels[level],
|
|
8908
8908
|
variables: { processType: "renderer" }
|
|
@@ -9114,7 +9114,7 @@ var require_EventLogger = __commonJS({
|
|
|
9114
9114
|
events,
|
|
9115
9115
|
externalApi,
|
|
9116
9116
|
level,
|
|
9117
|
-
logger:
|
|
9117
|
+
logger: logger94,
|
|
9118
9118
|
format: format2,
|
|
9119
9119
|
formatters,
|
|
9120
9120
|
scope
|
|
@@ -9128,8 +9128,8 @@ var require_EventLogger = __commonJS({
|
|
|
9128
9128
|
if (typeof level === "string") {
|
|
9129
9129
|
this.level = level;
|
|
9130
9130
|
}
|
|
9131
|
-
if (typeof
|
|
9132
|
-
this.logger =
|
|
9131
|
+
if (typeof logger94 === "object") {
|
|
9132
|
+
this.logger = logger94;
|
|
9133
9133
|
}
|
|
9134
9134
|
if (typeof format2 === "string" || typeof format2 === "function") {
|
|
9135
9135
|
this.format = format2;
|
|
@@ -9228,10 +9228,10 @@ var require_EventLogger = __commonJS({
|
|
|
9228
9228
|
}
|
|
9229
9229
|
}
|
|
9230
9230
|
handleEvent({ eventName, eventSource, handlerArgs }) {
|
|
9231
|
-
const
|
|
9232
|
-
if (
|
|
9231
|
+
const log96 = this.formatEventLog({ eventName, eventSource, handlerArgs });
|
|
9232
|
+
if (log96) {
|
|
9233
9233
|
const logFns = this.scope ? this.logger.scope(this.scope) : this.logger;
|
|
9234
|
-
logFns?.[this.level]?.(...
|
|
9234
|
+
logFns?.[this.level]?.(...log96);
|
|
9235
9235
|
}
|
|
9236
9236
|
}
|
|
9237
9237
|
};
|
|
@@ -9250,12 +9250,12 @@ var require_format = __commonJS({
|
|
|
9250
9250
|
formatText,
|
|
9251
9251
|
formatVariables,
|
|
9252
9252
|
timeZoneFromOffset,
|
|
9253
|
-
format({ message, logger:
|
|
9253
|
+
format({ message, logger: logger94, transport, data = message?.data }) {
|
|
9254
9254
|
switch (typeof transport.format) {
|
|
9255
9255
|
case "string": {
|
|
9256
9256
|
return transform2({
|
|
9257
9257
|
message,
|
|
9258
|
-
logger:
|
|
9258
|
+
logger: logger94,
|
|
9259
9259
|
transforms: [formatVariables, formatScope, formatText],
|
|
9260
9260
|
transport,
|
|
9261
9261
|
initialData: [transport.format, ...data]
|
|
@@ -9265,7 +9265,7 @@ var require_format = __commonJS({
|
|
|
9265
9265
|
return transport.format({
|
|
9266
9266
|
data,
|
|
9267
9267
|
level: message?.level || "info",
|
|
9268
|
-
logger:
|
|
9268
|
+
logger: logger94,
|
|
9269
9269
|
message,
|
|
9270
9270
|
transport
|
|
9271
9271
|
});
|
|
@@ -9292,8 +9292,8 @@ var require_format = __commonJS({
|
|
|
9292
9292
|
const minutes = (minutesPositive % 60).toString().padStart(2, "0");
|
|
9293
9293
|
return `${sign}${hours}:${minutes}`;
|
|
9294
9294
|
}
|
|
9295
|
-
function formatScope({ data, logger:
|
|
9296
|
-
const { defaultLabel, labelLength } =
|
|
9295
|
+
function formatScope({ data, logger: logger94, message }) {
|
|
9296
|
+
const { defaultLabel, labelLength } = logger94?.scope || {};
|
|
9297
9297
|
const template2 = data[0];
|
|
9298
9298
|
let label = message.scope;
|
|
9299
9299
|
if (!label) {
|
|
@@ -9569,7 +9569,7 @@ var require_console2 = __commonJS({
|
|
|
9569
9569
|
Object.assign(consoleTransportFactory, {
|
|
9570
9570
|
DEFAULT_FORMAT
|
|
9571
9571
|
});
|
|
9572
|
-
function consoleTransportFactory(
|
|
9572
|
+
function consoleTransportFactory(logger94) {
|
|
9573
9573
|
return Object.assign(transport, {
|
|
9574
9574
|
colorMap: {
|
|
9575
9575
|
error: "red",
|
|
@@ -9597,7 +9597,7 @@ var require_console2 = __commonJS({
|
|
|
9597
9597
|
}
|
|
9598
9598
|
});
|
|
9599
9599
|
function transport(message) {
|
|
9600
|
-
const data = transform2({ logger:
|
|
9600
|
+
const data = transform2({ logger: logger94, message, transport });
|
|
9601
9601
|
transport.writeFn({
|
|
9602
9602
|
message: { ...message, data }
|
|
9603
9603
|
});
|
|
@@ -9880,7 +9880,7 @@ var require_file = __commonJS({
|
|
|
9880
9880
|
var { toString: toString2 } = require_object();
|
|
9881
9881
|
module2.exports = fileTransportFactory;
|
|
9882
9882
|
var globalRegistry2 = new FileRegistry();
|
|
9883
|
-
function fileTransportFactory(
|
|
9883
|
+
function fileTransportFactory(logger94, { registry: registry3 = globalRegistry2, externalApi } = {}) {
|
|
9884
9884
|
let pathVariables;
|
|
9885
9885
|
if (registry3.listenerCount("error") < 1) {
|
|
9886
9886
|
registry3.on("error", (e3, file2) => {
|
|
@@ -9888,7 +9888,7 @@ var require_file = __commonJS({
|
|
|
9888
9888
|
});
|
|
9889
9889
|
}
|
|
9890
9890
|
return Object.assign(transport, {
|
|
9891
|
-
fileName: getDefaultFileName(
|
|
9891
|
+
fileName: getDefaultFileName(logger94.variables.processType),
|
|
9892
9892
|
format: "[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}",
|
|
9893
9893
|
getFile,
|
|
9894
9894
|
inspectOptions: { depth: 5 },
|
|
@@ -9913,7 +9913,7 @@ var require_file = __commonJS({
|
|
|
9913
9913
|
return path51.join(vars.libraryDefaultDir, vars.fileName);
|
|
9914
9914
|
},
|
|
9915
9915
|
setAppName(name29) {
|
|
9916
|
-
|
|
9916
|
+
logger94.dependencies.externalApi.setAppName(name29);
|
|
9917
9917
|
}
|
|
9918
9918
|
});
|
|
9919
9919
|
function transport(message) {
|
|
@@ -9923,7 +9923,7 @@ var require_file = __commonJS({
|
|
|
9923
9923
|
transport.archiveLogFn(file2);
|
|
9924
9924
|
file2.reset();
|
|
9925
9925
|
}
|
|
9926
|
-
const content = transform2({ logger:
|
|
9926
|
+
const content = transform2({ logger: logger94, message, transport });
|
|
9927
9927
|
file2.writeLine(content);
|
|
9928
9928
|
}
|
|
9929
9929
|
function initializeOnFirstAccess() {
|
|
@@ -9958,7 +9958,7 @@ var require_file = __commonJS({
|
|
|
9958
9958
|
if (error51) {
|
|
9959
9959
|
data.push(error51);
|
|
9960
9960
|
}
|
|
9961
|
-
|
|
9961
|
+
logger94.transports.console({ data, date: /* @__PURE__ */ new Date(), level });
|
|
9962
9962
|
}
|
|
9963
9963
|
function getFile(msg) {
|
|
9964
9964
|
initializeOnFirstAccess();
|
|
@@ -10007,11 +10007,11 @@ var require_ipc2 = __commonJS({
|
|
|
10007
10007
|
var { maxDepth, toJSON } = require_object();
|
|
10008
10008
|
var { transform: transform2 } = require_transform();
|
|
10009
10009
|
module2.exports = ipcTransportFactory;
|
|
10010
|
-
function ipcTransportFactory(
|
|
10010
|
+
function ipcTransportFactory(logger94, { externalApi }) {
|
|
10011
10011
|
Object.assign(transport, {
|
|
10012
10012
|
depth: 3,
|
|
10013
10013
|
eventId: "__ELECTRON_LOG_IPC__",
|
|
10014
|
-
level:
|
|
10014
|
+
level: logger94.isDev ? "silly" : false,
|
|
10015
10015
|
transforms: [toJSON, maxDepth]
|
|
10016
10016
|
});
|
|
10017
10017
|
return externalApi?.isElectron() ? transport : void 0;
|
|
@@ -10021,7 +10021,7 @@ var require_ipc2 = __commonJS({
|
|
|
10021
10021
|
}
|
|
10022
10022
|
externalApi?.sendIpc(transport.eventId, {
|
|
10023
10023
|
...message,
|
|
10024
|
-
data: transform2({ logger:
|
|
10024
|
+
data: transform2({ logger: logger94, message, transport })
|
|
10025
10025
|
});
|
|
10026
10026
|
}
|
|
10027
10027
|
}
|
|
@@ -10038,7 +10038,7 @@ var require_remote = __commonJS({
|
|
|
10038
10038
|
var { removeStyles } = require_style();
|
|
10039
10039
|
var { toJSON, maxDepth } = require_object();
|
|
10040
10040
|
module2.exports = remoteTransportFactory;
|
|
10041
|
-
function remoteTransportFactory(
|
|
10041
|
+
function remoteTransportFactory(logger94) {
|
|
10042
10042
|
return Object.assign(transport, {
|
|
10043
10043
|
client: { name: "electron-application" },
|
|
10044
10044
|
depth: 6,
|
|
@@ -10056,7 +10056,7 @@ var require_remote = __commonJS({
|
|
|
10056
10056
|
});
|
|
10057
10057
|
},
|
|
10058
10058
|
processErrorFn({ error: error51 }) {
|
|
10059
|
-
|
|
10059
|
+
logger94.processMessage(
|
|
10060
10060
|
{
|
|
10061
10061
|
data: [`electron-log: can't POST ${transport.url}`, error51],
|
|
10062
10062
|
level: "warn"
|
|
@@ -10085,8 +10085,8 @@ var require_remote = __commonJS({
|
|
|
10085
10085
|
return;
|
|
10086
10086
|
}
|
|
10087
10087
|
const body = transport.makeBodyFn({
|
|
10088
|
-
logger:
|
|
10089
|
-
message: { ...message, data: transform2({ logger:
|
|
10088
|
+
logger: logger94,
|
|
10089
|
+
message: { ...message, data: transform2({ logger: logger94, message, transport }) },
|
|
10090
10090
|
transport
|
|
10091
10091
|
});
|
|
10092
10092
|
const request = transport.sendRequestFn({
|
|
@@ -10096,7 +10096,7 @@ var require_remote = __commonJS({
|
|
|
10096
10096
|
});
|
|
10097
10097
|
request.on("error", (error51) => transport.processErrorFn({
|
|
10098
10098
|
error: error51,
|
|
10099
|
-
logger:
|
|
10099
|
+
logger: logger94,
|
|
10100
10100
|
message,
|
|
10101
10101
|
request,
|
|
10102
10102
|
transport
|
|
@@ -10178,9 +10178,9 @@ var require_main = __commonJS({
|
|
|
10178
10178
|
externalApi.onIpcInvoke("__ELECTRON_LOG__", (_4, { cmd = "", logId }) => {
|
|
10179
10179
|
switch (cmd) {
|
|
10180
10180
|
case "getOptions": {
|
|
10181
|
-
const
|
|
10181
|
+
const logger94 = defaultLogger2.Logger.getInstance({ logId });
|
|
10182
10182
|
return {
|
|
10183
|
-
levels:
|
|
10183
|
+
levels: logger94.levels,
|
|
10184
10184
|
logId
|
|
10185
10185
|
};
|
|
10186
10186
|
}
|
|
@@ -66013,8 +66013,8 @@ async function fetchCatalogWithRetry() {
|
|
|
66013
66013
|
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
66014
66014
|
}
|
|
66015
66015
|
async function refreshModelsDev(opts) {
|
|
66016
|
-
const
|
|
66017
|
-
if (
|
|
66016
|
+
const notify5 = opts?.notify !== false;
|
|
66017
|
+
if (notify5) {
|
|
66018
66018
|
broadcastModelsDevStatus("Updating model catalog in background\u2026");
|
|
66019
66019
|
}
|
|
66020
66020
|
try {
|
|
@@ -66023,7 +66023,7 @@ async function refreshModelsDev(opts) {
|
|
|
66023
66023
|
await saveToCache(data);
|
|
66024
66024
|
setCachedData(data);
|
|
66025
66025
|
logger7.info(`[models.dev] Fetched ${Object.keys(data).length} providers`);
|
|
66026
|
-
if (
|
|
66026
|
+
if (notify5) broadcastModelsDevStatus("");
|
|
66027
66027
|
return data;
|
|
66028
66028
|
}
|
|
66029
66029
|
} catch (e3) {
|
|
@@ -66034,7 +66034,7 @@ async function refreshModelsDev(opts) {
|
|
|
66034
66034
|
level: "warning",
|
|
66035
66035
|
tags: { feature: "models_dev" }
|
|
66036
66036
|
});
|
|
66037
|
-
if (
|
|
66037
|
+
if (notify5) {
|
|
66038
66038
|
broadcastModelsDevStatus(
|
|
66039
66039
|
"Model catalog update timed out; using cached list.",
|
|
66040
66040
|
true
|
|
@@ -66042,7 +66042,7 @@ async function refreshModelsDev(opts) {
|
|
|
66042
66042
|
}
|
|
66043
66043
|
} else {
|
|
66044
66044
|
logger7.warn("[models.dev] Fetch failed, using cache", e3);
|
|
66045
|
-
if (
|
|
66045
|
+
if (notify5) broadcastModelsDevStatus("");
|
|
66046
66046
|
}
|
|
66047
66047
|
}
|
|
66048
66048
|
const cached3 = await loadFromCache();
|
|
@@ -111761,7 +111761,7 @@ var require_node2 = __commonJS({
|
|
|
111761
111761
|
var tty = __require("tty");
|
|
111762
111762
|
var util2 = __require("util");
|
|
111763
111763
|
exports2.init = init2;
|
|
111764
|
-
exports2.log =
|
|
111764
|
+
exports2.log = log96;
|
|
111765
111765
|
exports2.formatArgs = formatArgs;
|
|
111766
111766
|
exports2.save = save;
|
|
111767
111767
|
exports2.load = load;
|
|
@@ -111896,7 +111896,7 @@ var require_node2 = __commonJS({
|
|
|
111896
111896
|
}
|
|
111897
111897
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
111898
111898
|
}
|
|
111899
|
-
function
|
|
111899
|
+
function log96(...args2) {
|
|
111900
111900
|
return process.stderr.write(util2.formatWithOptions(exports2.inspectOpts, ...args2) + "\n");
|
|
111901
111901
|
}
|
|
111902
111902
|
function save(namespaces) {
|
|
@@ -121335,7 +121335,7 @@ var require_logging_utils = __commonJS({
|
|
|
121335
121335
|
exports2.getDebugBackend = getDebugBackend;
|
|
121336
121336
|
exports2.getStructuredBackend = getStructuredBackend;
|
|
121337
121337
|
exports2.setBackend = setBackend;
|
|
121338
|
-
exports2.log =
|
|
121338
|
+
exports2.log = log96;
|
|
121339
121339
|
var events_1 = __require("events");
|
|
121340
121340
|
var process6 = __importStar2(__require("process"));
|
|
121341
121341
|
var util2 = __importStar2(__require("util"));
|
|
@@ -121367,7 +121367,7 @@ var require_logging_utils = __commonJS({
|
|
|
121367
121367
|
this.func.info = (...args2) => this.invokeSeverity(LogSeverity.INFO, ...args2);
|
|
121368
121368
|
this.func.warn = (...args2) => this.invokeSeverity(LogSeverity.WARNING, ...args2);
|
|
121369
121369
|
this.func.error = (...args2) => this.invokeSeverity(LogSeverity.ERROR, ...args2);
|
|
121370
|
-
this.func.sublog = (namespace2) =>
|
|
121370
|
+
this.func.sublog = (namespace2) => log96(namespace2, this.func);
|
|
121371
121371
|
}
|
|
121372
121372
|
invoke(fields, ...args2) {
|
|
121373
121373
|
if (this.upstream) {
|
|
@@ -121406,12 +121406,12 @@ var require_logging_utils = __commonJS({
|
|
|
121406
121406
|
this.setFilters();
|
|
121407
121407
|
this.filtersSet = true;
|
|
121408
121408
|
}
|
|
121409
|
-
let
|
|
121410
|
-
if (!
|
|
121411
|
-
|
|
121412
|
-
this.cached.set(namespace,
|
|
121409
|
+
let logger94 = this.cached.get(namespace);
|
|
121410
|
+
if (!logger94) {
|
|
121411
|
+
logger94 = this.makeLogger(namespace);
|
|
121412
|
+
this.cached.set(namespace, logger94);
|
|
121413
121413
|
}
|
|
121414
|
-
|
|
121414
|
+
logger94(fields, ...args2);
|
|
121415
121415
|
} catch (e3) {
|
|
121416
121416
|
console.error(e3);
|
|
121417
121417
|
}
|
|
@@ -121534,7 +121534,7 @@ var require_logging_utils = __commonJS({
|
|
|
121534
121534
|
cachedBackend = backend;
|
|
121535
121535
|
loggerCache.clear();
|
|
121536
121536
|
}
|
|
121537
|
-
function
|
|
121537
|
+
function log96(namespace, parent) {
|
|
121538
121538
|
if (!cachedBackend) {
|
|
121539
121539
|
const enablesFlag = process6.env[exports2.env.nodeEnables];
|
|
121540
121540
|
if (!enablesFlag) {
|
|
@@ -121556,7 +121556,7 @@ var require_logging_utils = __commonJS({
|
|
|
121556
121556
|
} else if (cachedBackend === void 0) {
|
|
121557
121557
|
cachedBackend = getNodeBackend();
|
|
121558
121558
|
}
|
|
121559
|
-
const
|
|
121559
|
+
const logger94 = (() => {
|
|
121560
121560
|
let previousBackend = void 0;
|
|
121561
121561
|
const newLogger = new AdhocDebugLogger(namespace, (fields, ...args2) => {
|
|
121562
121562
|
if (previousBackend !== cachedBackend) {
|
|
@@ -121571,8 +121571,8 @@ var require_logging_utils = __commonJS({
|
|
|
121571
121571
|
});
|
|
121572
121572
|
return newLogger;
|
|
121573
121573
|
})();
|
|
121574
|
-
loggerCache.set(namespace,
|
|
121575
|
-
return
|
|
121574
|
+
loggerCache.set(namespace, logger94);
|
|
121575
|
+
return logger94.func;
|
|
121576
121576
|
}
|
|
121577
121577
|
}
|
|
121578
121578
|
});
|
|
@@ -121660,14 +121660,14 @@ var require_src5 = __commonJS({
|
|
|
121660
121660
|
var gaxios_1 = require_src3();
|
|
121661
121661
|
var jsonBigint = require_json_bigint();
|
|
121662
121662
|
var gcp_residency_1 = require_gcp_residency();
|
|
121663
|
-
var
|
|
121663
|
+
var logger94 = __importStar2(require_src4());
|
|
121664
121664
|
exports2.BASE_PATH = "/computeMetadata/v1";
|
|
121665
121665
|
exports2.HOST_ADDRESS = "http://169.254.169.254";
|
|
121666
121666
|
exports2.SECONDARY_HOST_ADDRESS = "http://metadata.google.internal.";
|
|
121667
121667
|
exports2.HEADER_NAME = "Metadata-Flavor";
|
|
121668
121668
|
exports2.HEADER_VALUE = "Google";
|
|
121669
121669
|
exports2.HEADERS = Object.freeze({ [exports2.HEADER_NAME]: exports2.HEADER_VALUE });
|
|
121670
|
-
var
|
|
121670
|
+
var log96 = logger94.log("gcp-metadata");
|
|
121671
121671
|
exports2.METADATA_SERVER_DETECTION = Object.freeze({
|
|
121672
121672
|
"assume-present": "don't try to ping the metadata server, but assume it's present",
|
|
121673
121673
|
none: "don't try to ping the metadata server, but don't try to use it either",
|
|
@@ -121730,9 +121730,9 @@ var require_src5 = __commonJS({
|
|
|
121730
121730
|
responseType: "text",
|
|
121731
121731
|
timeout: requestTimeout()
|
|
121732
121732
|
};
|
|
121733
|
-
|
|
121733
|
+
log96.info("instance request %j", req);
|
|
121734
121734
|
const res = await requestMethod(req);
|
|
121735
|
-
|
|
121735
|
+
log96.info("instance metadata is %s", res.data);
|
|
121736
121736
|
const metadataFlavor = res.headers.get(exports2.HEADER_NAME);
|
|
121737
121737
|
if (metadataFlavor !== exports2.HEADER_VALUE) {
|
|
121738
121738
|
throw new RangeError(`Invalid response from metadata service: incorrect ${exports2.HEADER_NAME} header. Expected '${exports2.HEADER_VALUE}', got ${metadataFlavor ? `'${metadataFlavor}'` : "no header"}`);
|
|
@@ -151256,8 +151256,8 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
151256
151256
|
return !!detail.signature;
|
|
151257
151257
|
});
|
|
151258
151258
|
if (validDetails.length < candidateReasoningDetails.length) {
|
|
151259
|
-
const
|
|
151260
|
-
if (
|
|
151259
|
+
const logger94 = globalThis.AI_SDK_LOG_WARNINGS;
|
|
151260
|
+
if (logger94 !== false && typeof logger94 !== "function") {
|
|
151261
151261
|
console.warn(
|
|
151262
151262
|
"[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."
|
|
151263
151263
|
);
|
|
@@ -162069,19 +162069,19 @@ var init_ProviderError = __esm({
|
|
|
162069
162069
|
name = "ProviderError";
|
|
162070
162070
|
tryNextLink;
|
|
162071
162071
|
constructor(message, options = true) {
|
|
162072
|
-
let
|
|
162072
|
+
let logger94;
|
|
162073
162073
|
let tryNextLink = true;
|
|
162074
162074
|
if (typeof options === "boolean") {
|
|
162075
|
-
|
|
162075
|
+
logger94 = void 0;
|
|
162076
162076
|
tryNextLink = options;
|
|
162077
162077
|
} else if (options != null && typeof options === "object") {
|
|
162078
|
-
|
|
162078
|
+
logger94 = options.logger;
|
|
162079
162079
|
tryNextLink = options.tryNextLink ?? true;
|
|
162080
162080
|
}
|
|
162081
162081
|
super(message);
|
|
162082
162082
|
this.tryNextLink = tryNextLink;
|
|
162083
162083
|
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
162084
|
-
|
|
162084
|
+
logger94?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
162085
162085
|
}
|
|
162086
162086
|
static from(error51, options = true) {
|
|
162087
162087
|
return Object.assign(new this(error51.message, options), error51);
|
|
@@ -162510,8 +162510,8 @@ var init_configLoader = __esm({
|
|
|
162510
162510
|
init_fromSharedConfigFiles();
|
|
162511
162511
|
init_fromStatic();
|
|
162512
162512
|
loadConfig = ({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
|
|
162513
|
-
const { signingName, logger:
|
|
162514
|
-
const envOptions = { signingName, logger:
|
|
162513
|
+
const { signingName, logger: logger94 } = configuration;
|
|
162514
|
+
const envOptions = { signingName, logger: logger94 };
|
|
162515
162515
|
return memoize(chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue)));
|
|
162516
162516
|
};
|
|
162517
162517
|
}
|
|
@@ -163380,7 +163380,7 @@ var init_ByteArrayCollector = __esm({
|
|
|
163380
163380
|
});
|
|
163381
163381
|
|
|
163382
163382
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.browser.js
|
|
163383
|
-
function createBufferedReadableStream(upstream, size2,
|
|
163383
|
+
function createBufferedReadableStream(upstream, size2, logger94) {
|
|
163384
163384
|
const reader = upstream.getReader();
|
|
163385
163385
|
let streamBufferingLoggedWarning = false;
|
|
163386
163386
|
let bytesSeen = 0;
|
|
@@ -163418,7 +163418,7 @@ function createBufferedReadableStream(upstream, size2, logger93) {
|
|
|
163418
163418
|
const newSize = merge2(buffers, mode, chunk2);
|
|
163419
163419
|
if (!streamBufferingLoggedWarning && bytesSeen > size2 * 2) {
|
|
163420
163420
|
streamBufferingLoggedWarning = true;
|
|
163421
|
-
|
|
163421
|
+
logger94?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size2}, automatically buffering.`);
|
|
163422
163422
|
}
|
|
163423
163423
|
if (newSize >= size2) {
|
|
163424
163424
|
controller.enqueue(flush2(buffers, mode));
|
|
@@ -163478,9 +163478,9 @@ var init_createBufferedReadable_browser = __esm({
|
|
|
163478
163478
|
|
|
163479
163479
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.js
|
|
163480
163480
|
import { Readable as Readable2 } from "node:stream";
|
|
163481
|
-
function createBufferedReadable(upstream, size2,
|
|
163481
|
+
function createBufferedReadable(upstream, size2, logger94) {
|
|
163482
163482
|
if (isReadableStream(upstream)) {
|
|
163483
|
-
return createBufferedReadableStream(upstream, size2,
|
|
163483
|
+
return createBufferedReadableStream(upstream, size2, logger94);
|
|
163484
163484
|
}
|
|
163485
163485
|
const downstream = new Readable2({ read() {
|
|
163486
163486
|
} });
|
|
@@ -163513,7 +163513,7 @@ function createBufferedReadable(upstream, size2, logger93) {
|
|
|
163513
163513
|
const newSize = merge2(buffers, mode, chunk2);
|
|
163514
163514
|
if (!streamBufferingLoggedWarning && bytesSeen > size2 * 2) {
|
|
163515
163515
|
streamBufferingLoggedWarning = true;
|
|
163516
|
-
|
|
163516
|
+
logger94?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size2}, automatically buffering.`);
|
|
163517
163517
|
}
|
|
163518
163518
|
if (newSize >= size2) {
|
|
163519
163519
|
downstream.push(flush2(buffers, mode));
|
|
@@ -211418,6 +211418,87 @@ var init_system_reminder = __esm({
|
|
|
211418
211418
|
}
|
|
211419
211419
|
});
|
|
211420
211420
|
|
|
211421
|
+
// src/lib/agent/user-interjections.ts
|
|
211422
|
+
var user_interjections_exports = {};
|
|
211423
|
+
__export(user_interjections_exports, {
|
|
211424
|
+
cancelUserInterjection: () => cancelUserInterjection,
|
|
211425
|
+
clearUserInterjections: () => clearUserInterjections,
|
|
211426
|
+
hasPendingUserInterjections: () => hasPendingUserInterjections,
|
|
211427
|
+
listPendingUserInterjections: () => listPendingUserInterjections,
|
|
211428
|
+
recordUserInterjection: () => recordUserInterjection,
|
|
211429
|
+
setUserInterjectionNotifier: () => setUserInterjectionNotifier,
|
|
211430
|
+
takePendingUserInterjections: () => takePendingUserInterjections,
|
|
211431
|
+
takeUserInterjectionsAsPrompt: () => takeUserInterjectionsAsPrompt
|
|
211432
|
+
});
|
|
211433
|
+
function setUserInterjectionNotifier(fn2) {
|
|
211434
|
+
notifier = fn2;
|
|
211435
|
+
}
|
|
211436
|
+
function notify(chatId) {
|
|
211437
|
+
notifier?.(chatId, listPendingUserInterjections(chatId));
|
|
211438
|
+
}
|
|
211439
|
+
function recordUserInterjection(chatId, msg) {
|
|
211440
|
+
const text3 = msg.text.trim();
|
|
211441
|
+
if (!text3) return null;
|
|
211442
|
+
const list = byChat.get(chatId) ?? [];
|
|
211443
|
+
if (list.some((m3) => m3.id === msg.id)) return null;
|
|
211444
|
+
const entry = {
|
|
211445
|
+
id: msg.id,
|
|
211446
|
+
text: text3.length > TEXT_CAP ? `${text3.slice(0, TEXT_CAP)}\u2026` : text3,
|
|
211447
|
+
ts: msg.ts ?? Date.now()
|
|
211448
|
+
};
|
|
211449
|
+
list.push(entry);
|
|
211450
|
+
if (list.length > MAX_QUEUED_PER_CHAT) {
|
|
211451
|
+
console.warn(
|
|
211452
|
+
`[user-interjections] chat ${chatId}: >${MAX_QUEUED_PER_CHAT} undelivered \u2014 dropping ${list.length - MAX_QUEUED_PER_CHAT} oldest`
|
|
211453
|
+
);
|
|
211454
|
+
}
|
|
211455
|
+
byChat.set(chatId, list.slice(-MAX_QUEUED_PER_CHAT));
|
|
211456
|
+
notify(chatId);
|
|
211457
|
+
return entry;
|
|
211458
|
+
}
|
|
211459
|
+
function hasPendingUserInterjections(chatId) {
|
|
211460
|
+
return (byChat.get(chatId)?.length ?? 0) > 0;
|
|
211461
|
+
}
|
|
211462
|
+
function listPendingUserInterjections(chatId) {
|
|
211463
|
+
return [...byChat.get(chatId) ?? []];
|
|
211464
|
+
}
|
|
211465
|
+
function takePendingUserInterjections(chatId) {
|
|
211466
|
+
const list = byChat.get(chatId);
|
|
211467
|
+
if (!list?.length) return null;
|
|
211468
|
+
byChat.delete(chatId);
|
|
211469
|
+
notify(chatId);
|
|
211470
|
+
return list;
|
|
211471
|
+
}
|
|
211472
|
+
function cancelUserInterjection(chatId, id) {
|
|
211473
|
+
const list = byChat.get(chatId);
|
|
211474
|
+
if (!list?.length) return false;
|
|
211475
|
+
const next = list.filter((m3) => m3.id !== id);
|
|
211476
|
+
if (next.length === list.length) return false;
|
|
211477
|
+
if (next.length) byChat.set(chatId, next);
|
|
211478
|
+
else byChat.delete(chatId);
|
|
211479
|
+
notify(chatId);
|
|
211480
|
+
return true;
|
|
211481
|
+
}
|
|
211482
|
+
function takeUserInterjectionsAsPrompt(chatId) {
|
|
211483
|
+
const list = takePendingUserInterjections(chatId);
|
|
211484
|
+
if (!list) return null;
|
|
211485
|
+
return list.map((m3) => m3.text).join("\n\n");
|
|
211486
|
+
}
|
|
211487
|
+
function clearUserInterjections(chatId) {
|
|
211488
|
+
if (!byChat.has(chatId)) return;
|
|
211489
|
+
byChat.delete(chatId);
|
|
211490
|
+
notify(chatId);
|
|
211491
|
+
}
|
|
211492
|
+
var MAX_QUEUED_PER_CHAT, TEXT_CAP, byChat, notifier;
|
|
211493
|
+
var init_user_interjections = __esm({
|
|
211494
|
+
"src/lib/agent/user-interjections.ts"() {
|
|
211495
|
+
MAX_QUEUED_PER_CHAT = 40;
|
|
211496
|
+
TEXT_CAP = 2e4;
|
|
211497
|
+
byChat = /* @__PURE__ */ new Map();
|
|
211498
|
+
notifier = null;
|
|
211499
|
+
}
|
|
211500
|
+
});
|
|
211501
|
+
|
|
211421
211502
|
// src/lib/chat/stream-transport.ts
|
|
211422
211503
|
var stream_transport_exports = {};
|
|
211423
211504
|
__export(stream_transport_exports, {
|
|
@@ -211431,6 +211512,7 @@ __export(stream_transport_exports, {
|
|
|
211431
211512
|
getStreamTransportAppId: () => getStreamTransportAppId,
|
|
211432
211513
|
hydrateStreamTransport: () => hydrateStreamTransport,
|
|
211433
211514
|
insertAskUserAnswerUserMessage: () => insertAskUserAnswerUserMessage,
|
|
211515
|
+
insertUserInterjectionMessage: () => insertUserInterjectionMessage,
|
|
211434
211516
|
isStreamTransportId: () => isStreamTransportId,
|
|
211435
211517
|
nextEphemeralMessageId: () => nextEphemeralMessageId,
|
|
211436
211518
|
seedEphemeralChatCounterBelow: () => seedEphemeralChatCounterBelow,
|
|
@@ -211477,6 +211559,22 @@ function insertAskUserAnswerUserMessage(chatId, formattedContent, sessionRowId)
|
|
|
211477
211559
|
chat.messages.push(msg);
|
|
211478
211560
|
return true;
|
|
211479
211561
|
}
|
|
211562
|
+
function insertUserInterjectionMessage(chatId, content, placeholderMessageId, sessionRowId) {
|
|
211563
|
+
const chat = ephemeralChats.get(chatId);
|
|
211564
|
+
if (!chat) return null;
|
|
211565
|
+
const msg = {
|
|
211566
|
+
id: nextEphemeralMessageId(),
|
|
211567
|
+
chatId,
|
|
211568
|
+
role: "user",
|
|
211569
|
+
content,
|
|
211570
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
211571
|
+
...sessionRowId ? { sessionRowId } : {}
|
|
211572
|
+
};
|
|
211573
|
+
const at2 = chat.messages.findIndex((m3) => m3.id === placeholderMessageId);
|
|
211574
|
+
if (at2 < 0) chat.messages.push(msg);
|
|
211575
|
+
else chat.messages.splice(at2, 0, msg);
|
|
211576
|
+
return msg;
|
|
211577
|
+
}
|
|
211480
211578
|
function editTransportUserMessage(chatId, userMessageId, newContent, newModelContent) {
|
|
211481
211579
|
const chat = ephemeralChats.get(chatId);
|
|
211482
211580
|
if (!chat) return false;
|
|
@@ -211525,6 +211623,8 @@ function isStreamTransportId(chatId) {
|
|
|
211525
211623
|
return chatId < 0;
|
|
211526
211624
|
}
|
|
211527
211625
|
function deleteStreamTransport(chatId) {
|
|
211626
|
+
void Promise.resolve().then(() => (init_user_interjections(), user_interjections_exports)).then((m3) => m3.clearUserInterjections(chatId)).catch(() => {
|
|
211627
|
+
});
|
|
211528
211628
|
return ephemeralChats.delete(chatId);
|
|
211529
211629
|
}
|
|
211530
211630
|
function setTransportMessageDisplaySnapshot(chatId, messageId, snapshot) {
|
|
@@ -212098,7 +212198,7 @@ function scheduleInternal(chatId, delayMs, note, jobId) {
|
|
|
212098
212198
|
const list = nudgesByChat.get(chatId) ?? [];
|
|
212099
212199
|
list.push({ text: nudgeText, ...jobId ? { jobId } : {} });
|
|
212100
212200
|
nudgesByChat.set(chatId, list.slice(-MAX_PENDING_PER_CHAT));
|
|
212101
|
-
|
|
212201
|
+
notifier2?.(chatId, { operationId: id, status: "scheduled" });
|
|
212102
212202
|
}, clamped);
|
|
212103
212203
|
timer.unref?.();
|
|
212104
212204
|
if (!chatTimers) {
|
|
@@ -212175,7 +212275,7 @@ function clearScheduledWakeupsForChat(chatId) {
|
|
|
212175
212275
|
}
|
|
212176
212276
|
nudgesByChat.delete(chatId);
|
|
212177
212277
|
}
|
|
212178
|
-
var MIN_DELAY_MS, MAX_DELAY_MS, MAX_PENDING_PER_CHAT, timersByChat, nudgesByChat, seq,
|
|
212278
|
+
var MIN_DELAY_MS, MAX_DELAY_MS, MAX_PENDING_PER_CHAT, timersByChat, nudgesByChat, seq, notifier2;
|
|
212179
212279
|
var init_scheduled_wakeups = __esm({
|
|
212180
212280
|
"src/lib/agent/scheduled-wakeups.ts"() {
|
|
212181
212281
|
MIN_DELAY_MS = 6e4;
|
|
@@ -212184,7 +212284,7 @@ var init_scheduled_wakeups = __esm({
|
|
|
212184
212284
|
timersByChat = /* @__PURE__ */ new Map();
|
|
212185
212285
|
nudgesByChat = /* @__PURE__ */ new Map();
|
|
212186
212286
|
seq = 0;
|
|
212187
|
-
|
|
212287
|
+
notifier2 = null;
|
|
212188
212288
|
}
|
|
212189
212289
|
});
|
|
212190
212290
|
|
|
@@ -213006,13 +213106,13 @@ __export(background_commands_exports, {
|
|
|
213006
213106
|
updateBackgroundOutput: () => updateBackgroundOutput
|
|
213007
213107
|
});
|
|
213008
213108
|
function setBackgroundJobNotifier(fn2) {
|
|
213009
|
-
|
|
213109
|
+
notifier3 = fn2;
|
|
213010
213110
|
}
|
|
213011
213111
|
function runningCount(chatId) {
|
|
213012
213112
|
return runningJobsByChat.get(chatId)?.size ?? 0;
|
|
213013
213113
|
}
|
|
213014
|
-
function
|
|
213015
|
-
|
|
213114
|
+
function notify2(chatId, operationId, status) {
|
|
213115
|
+
notifier3?.(chatId, { operationId, status, running: runningCount(chatId) });
|
|
213016
213116
|
}
|
|
213017
213117
|
function totalRunningJobs() {
|
|
213018
213118
|
let n2 = 0;
|
|
@@ -213036,8 +213136,8 @@ function scanForStalledJobs() {
|
|
|
213036
213136
|
kind: "match",
|
|
213037
213137
|
matchedPattern: job.wakeOn.pattern
|
|
213038
213138
|
});
|
|
213039
|
-
advisoriesByChat.set(chatId, list2.slice(-
|
|
213040
|
-
|
|
213139
|
+
advisoriesByChat.set(chatId, list2.slice(-MAX_QUEUED_PER_CHAT2));
|
|
213140
|
+
notify2(chatId, job.operationId, "condition_met");
|
|
213041
213141
|
}
|
|
213042
213142
|
if (job.allowStalled) continue;
|
|
213043
213143
|
if (wakeupActive) continue;
|
|
@@ -213053,8 +213153,8 @@ function scanForStalledJobs() {
|
|
|
213053
213153
|
outputTail: tail,
|
|
213054
213154
|
kind: "stall"
|
|
213055
213155
|
});
|
|
213056
|
-
advisoriesByChat.set(chatId, list.slice(-
|
|
213057
|
-
|
|
213156
|
+
advisoriesByChat.set(chatId, list.slice(-MAX_QUEUED_PER_CHAT2));
|
|
213157
|
+
notify2(chatId, job.operationId, "stalled");
|
|
213058
213158
|
}
|
|
213059
213159
|
}
|
|
213060
213160
|
}
|
|
@@ -213084,7 +213184,7 @@ function recordBackgroundCommandStart(chatId, operationId, command, startedAt, w
|
|
|
213084
213184
|
});
|
|
213085
213185
|
runningJobsByChat.set(chatId, jobs);
|
|
213086
213186
|
ensureStallWatchdog();
|
|
213087
|
-
|
|
213187
|
+
notify2(chatId, operationId, "running");
|
|
213088
213188
|
}
|
|
213089
213189
|
function setWakeCondition(chatId, operationId, wakeOn) {
|
|
213090
213190
|
const job = runningJobsByChat.get(chatId)?.get(operationId);
|
|
@@ -213142,13 +213242,13 @@ function recordBackgroundCommandResult(chatId, operationId, result2) {
|
|
|
213142
213242
|
output: result2.output.length > OUTPUT_TAIL_CAP ? `\u2026${result2.output.slice(-OUTPUT_TAIL_CAP)}` : result2.output,
|
|
213143
213243
|
finishedAt: Date.now()
|
|
213144
213244
|
});
|
|
213145
|
-
if (list.length >
|
|
213245
|
+
if (list.length > MAX_QUEUED_PER_CHAT2) {
|
|
213146
213246
|
console.warn(
|
|
213147
|
-
`[background-commands] chat ${chatId}: >${
|
|
213247
|
+
`[background-commands] chat ${chatId}: >${MAX_QUEUED_PER_CHAT2} undrained results \u2014 dropping ${list.length - MAX_QUEUED_PER_CHAT2} oldest (never delivered to the model)`
|
|
213148
213248
|
);
|
|
213149
213249
|
}
|
|
213150
|
-
resultsByChat.set(chatId, list.slice(-
|
|
213151
|
-
|
|
213250
|
+
resultsByChat.set(chatId, list.slice(-MAX_QUEUED_PER_CHAT2));
|
|
213251
|
+
notify2(chatId, operationId, wasCancelled ? "cancelled" : "finished");
|
|
213152
213252
|
}
|
|
213153
213253
|
function hasRunningBackgroundCommands(chatId) {
|
|
213154
213254
|
return runningCount(chatId) > 0;
|
|
@@ -213299,13 +213399,13 @@ function killForegroundCommandsForChat(chatId) {
|
|
|
213299
213399
|
foregroundProcsByChat.delete(chatId);
|
|
213300
213400
|
return killed;
|
|
213301
213401
|
}
|
|
213302
|
-
var OUTPUT_TAIL_CAP,
|
|
213402
|
+
var OUTPUT_TAIL_CAP, MAX_QUEUED_PER_CHAT2, OUTPUT_IDLE_THRESHOLD_MS, STALL_CHECK_INTERVAL_MS, resultsByChat, runningJobsByChat, cancelledOps, stalledNotified, advisoriesByChat, stallWatchdog, notifier3, foregroundProcsByChat;
|
|
213303
213403
|
var init_background_commands = __esm({
|
|
213304
213404
|
"src/lib/agent/background-commands.ts"() {
|
|
213305
213405
|
init_scheduled_wakeups();
|
|
213306
213406
|
init_runShellCommand();
|
|
213307
213407
|
OUTPUT_TAIL_CAP = 8e3;
|
|
213308
|
-
|
|
213408
|
+
MAX_QUEUED_PER_CHAT2 = 10;
|
|
213309
213409
|
OUTPUT_IDLE_THRESHOLD_MS = 18e4;
|
|
213310
213410
|
STALL_CHECK_INTERVAL_MS = 6e4;
|
|
213311
213411
|
resultsByChat = /* @__PURE__ */ new Map();
|
|
@@ -213314,23 +213414,23 @@ var init_background_commands = __esm({
|
|
|
213314
213414
|
stalledNotified = /* @__PURE__ */ new Set();
|
|
213315
213415
|
advisoriesByChat = /* @__PURE__ */ new Map();
|
|
213316
213416
|
stallWatchdog = null;
|
|
213317
|
-
|
|
213417
|
+
notifier3 = null;
|
|
213318
213418
|
foregroundProcsByChat = /* @__PURE__ */ new Map();
|
|
213319
213419
|
}
|
|
213320
213420
|
});
|
|
213321
213421
|
|
|
213322
213422
|
// src/lib/agents/subagent-results.ts
|
|
213323
|
-
function
|
|
213324
|
-
|
|
213423
|
+
function notify3(chatId, taskId, status) {
|
|
213424
|
+
notifier4?.(chatId, { taskId, status, running: runningSubagentCount(chatId) });
|
|
213325
213425
|
}
|
|
213326
213426
|
function notifySubagentStalled(chatId, taskId) {
|
|
213327
|
-
|
|
213427
|
+
notify3(chatId, taskId, "stalled");
|
|
213328
213428
|
}
|
|
213329
213429
|
function recordSubagentStart(chatId, taskId) {
|
|
213330
213430
|
const set2 = runningByChat.get(chatId) ?? /* @__PURE__ */ new Set();
|
|
213331
213431
|
set2.add(taskId);
|
|
213332
213432
|
runningByChat.set(chatId, set2);
|
|
213333
|
-
|
|
213433
|
+
notify3(chatId, taskId, "running");
|
|
213334
213434
|
}
|
|
213335
213435
|
function recordSubagentResult(chatId, taskId, result2) {
|
|
213336
213436
|
runningByChat.get(chatId)?.delete(taskId);
|
|
@@ -213341,13 +213441,13 @@ function recordSubagentResult(chatId, taskId, result2) {
|
|
|
213341
213441
|
body: result2.body.length > BODY_TAIL_CAP ? `\u2026${result2.body.slice(-BODY_TAIL_CAP)}` : result2.body,
|
|
213342
213442
|
finishedAt: Date.now()
|
|
213343
213443
|
});
|
|
213344
|
-
if (list.length >
|
|
213444
|
+
if (list.length > MAX_QUEUED_PER_CHAT3) {
|
|
213345
213445
|
console.warn(
|
|
213346
|
-
`[subagent-results] chat ${chatId}: >${
|
|
213446
|
+
`[subagent-results] chat ${chatId}: >${MAX_QUEUED_PER_CHAT3} undrained results \u2014 dropping ${list.length - MAX_QUEUED_PER_CHAT3} oldest (never delivered to the model)`
|
|
213347
213447
|
);
|
|
213348
213448
|
}
|
|
213349
|
-
resultsByChat2.set(chatId, list.slice(-
|
|
213350
|
-
|
|
213449
|
+
resultsByChat2.set(chatId, list.slice(-MAX_QUEUED_PER_CHAT3));
|
|
213450
|
+
notify3(chatId, taskId, "finished");
|
|
213351
213451
|
}
|
|
213352
213452
|
function hasRunningSubagents(chatId) {
|
|
213353
213453
|
return (runningByChat.get(chatId)?.size ?? 0) > 0;
|
|
@@ -213378,14 +213478,14 @@ function takePendingSubagentResults(chatId) {
|
|
|
213378
213478
|
`Incorporate these result(s) and continue the user's task now. If a sub-agent failed, decide how to recover \u2014 only end your turn once you have acted on every result above. If they COMPLETE the user's request, report the outcome and end your turn \u2014 never re-run work that already finished.`
|
|
213379
213479
|
].join("\n\n");
|
|
213380
213480
|
}
|
|
213381
|
-
var BODY_TAIL_CAP,
|
|
213481
|
+
var BODY_TAIL_CAP, MAX_QUEUED_PER_CHAT3, resultsByChat2, runningByChat, notifier4;
|
|
213382
213482
|
var init_subagent_results = __esm({
|
|
213383
213483
|
"src/lib/agents/subagent-results.ts"() {
|
|
213384
213484
|
BODY_TAIL_CAP = 12e3;
|
|
213385
|
-
|
|
213485
|
+
MAX_QUEUED_PER_CHAT3 = 10;
|
|
213386
213486
|
resultsByChat2 = /* @__PURE__ */ new Map();
|
|
213387
213487
|
runningByChat = /* @__PURE__ */ new Map();
|
|
213388
|
-
|
|
213488
|
+
notifier4 = null;
|
|
213389
213489
|
}
|
|
213390
213490
|
});
|
|
213391
213491
|
|
|
@@ -213410,7 +213510,7 @@ function recordAutomationResult(workspaceId, result2) {
|
|
|
213410
213510
|
...result2,
|
|
213411
213511
|
body: result2.body.slice(-BODY_TAIL_CAP2)
|
|
213412
213512
|
});
|
|
213413
|
-
while (list.length >
|
|
213513
|
+
while (list.length > MAX_QUEUED_PER_CHAT4) list.shift();
|
|
213414
213514
|
resultsByWorkspace.set(workspaceId, list);
|
|
213415
213515
|
}
|
|
213416
213516
|
function hasPendingAutomationResults(chatId) {
|
|
@@ -213439,12 +213539,12 @@ ${r3.body.trim() || "(no detail)"}`;
|
|
|
213439
213539
|
function clearAutomationResultsForTests() {
|
|
213440
213540
|
resultsByWorkspace.clear();
|
|
213441
213541
|
}
|
|
213442
|
-
var BODY_TAIL_CAP2,
|
|
213542
|
+
var BODY_TAIL_CAP2, MAX_QUEUED_PER_CHAT4, resultsByWorkspace;
|
|
213443
213543
|
var init_automation_results = __esm({
|
|
213444
213544
|
"src/lib/agent/automation-results.ts"() {
|
|
213445
213545
|
init_stream_transport();
|
|
213446
213546
|
BODY_TAIL_CAP2 = 8e3;
|
|
213447
|
-
|
|
213547
|
+
MAX_QUEUED_PER_CHAT4 = 10;
|
|
213448
213548
|
resultsByWorkspace = /* @__PURE__ */ new Map();
|
|
213449
213549
|
}
|
|
213450
213550
|
});
|
|
@@ -219061,7 +219161,7 @@ function now() {
|
|
|
219061
219161
|
var _a232, _b21;
|
|
219062
219162
|
return (_b21 = (_a232 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a232.now()) != null ? _b21 : Date.now();
|
|
219063
219163
|
}
|
|
219064
|
-
async function
|
|
219164
|
+
async function notify4(options) {
|
|
219065
219165
|
await Promise.all(
|
|
219066
219166
|
asArray2(options.callbacks).map(async (callback) => {
|
|
219067
219167
|
try {
|
|
@@ -219285,7 +219385,7 @@ async function executeToolCall({
|
|
|
219285
219385
|
event: baseCallbackEvent,
|
|
219286
219386
|
execute: async () => {
|
|
219287
219387
|
let output;
|
|
219288
|
-
await
|
|
219388
|
+
await notify4({
|
|
219289
219389
|
event: baseCallbackEvent,
|
|
219290
219390
|
callbacks: onToolExecutionStart
|
|
219291
219391
|
});
|
|
@@ -219339,7 +219439,7 @@ async function executeToolCall({
|
|
|
219339
219439
|
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
|
|
219340
219440
|
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
219341
219441
|
};
|
|
219342
|
-
await
|
|
219442
|
+
await notify4({
|
|
219343
219443
|
event: {
|
|
219344
219444
|
...baseCallbackEvent,
|
|
219345
219445
|
toolOutput: toolError,
|
|
@@ -219362,7 +219462,7 @@ async function executeToolCall({
|
|
|
219362
219462
|
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
|
|
219363
219463
|
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
219364
219464
|
};
|
|
219365
|
-
await
|
|
219465
|
+
await notify4({
|
|
219366
219466
|
event: {
|
|
219367
219467
|
...baseCallbackEvent,
|
|
219368
219468
|
toolOutput: toolResult,
|
|
@@ -221138,7 +221238,7 @@ async function generateText({
|
|
|
221138
221238
|
};
|
|
221139
221239
|
const executeGenerateText = async () => {
|
|
221140
221240
|
var _a242;
|
|
221141
|
-
await
|
|
221241
|
+
await notify4({
|
|
221142
221242
|
event: generateTextStartEvent,
|
|
221143
221243
|
callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
|
|
221144
221244
|
});
|
|
@@ -221182,14 +221282,14 @@ async function generateText({
|
|
|
221182
221282
|
timeout,
|
|
221183
221283
|
experimental_sandbox: sandbox,
|
|
221184
221284
|
toolsContext,
|
|
221185
|
-
onToolExecutionStart: (event) =>
|
|
221285
|
+
onToolExecutionStart: (event) => notify4({
|
|
221186
221286
|
event,
|
|
221187
221287
|
callbacks: [
|
|
221188
221288
|
resolvedOnToolExecutionStart,
|
|
221189
221289
|
telemetryDispatcher.onToolExecutionStart
|
|
221190
221290
|
]
|
|
221191
221291
|
}),
|
|
221192
|
-
onToolExecutionEnd: (event) =>
|
|
221292
|
+
onToolExecutionEnd: (event) => notify4({
|
|
221193
221293
|
event,
|
|
221194
221294
|
callbacks: [
|
|
221195
221295
|
resolvedOnToolExecutionEnd,
|
|
@@ -221334,7 +221434,7 @@ async function generateText({
|
|
|
221334
221434
|
callSettings: callSettings2,
|
|
221335
221435
|
stepSettings: prepareStepResult
|
|
221336
221436
|
});
|
|
221337
|
-
await
|
|
221437
|
+
await notify4({
|
|
221338
221438
|
event: {
|
|
221339
221439
|
callId,
|
|
221340
221440
|
provider: stepModel.provider,
|
|
@@ -221373,7 +221473,7 @@ async function generateText({
|
|
|
221373
221473
|
...languageModelCallContext
|
|
221374
221474
|
};
|
|
221375
221475
|
const stepStartTimestampMs = now2();
|
|
221376
|
-
await
|
|
221476
|
+
await notify4({
|
|
221377
221477
|
event: languageModelCallStartEvent,
|
|
221378
221478
|
callbacks: [
|
|
221379
221479
|
resolvedOnLanguageModelCallStart,
|
|
@@ -221436,7 +221536,7 @@ async function generateText({
|
|
|
221436
221536
|
toolApprovalResponses: [],
|
|
221437
221537
|
tools
|
|
221438
221538
|
});
|
|
221439
|
-
await
|
|
221539
|
+
await notify4({
|
|
221440
221540
|
event: {
|
|
221441
221541
|
callId,
|
|
221442
221542
|
provider: stepModel.provider,
|
|
@@ -221599,14 +221699,14 @@ async function generateText({
|
|
|
221599
221699
|
timeout,
|
|
221600
221700
|
experimental_sandbox: stepSandbox,
|
|
221601
221701
|
toolsContext,
|
|
221602
|
-
onToolExecutionStart: (event) =>
|
|
221702
|
+
onToolExecutionStart: (event) => notify4({
|
|
221603
221703
|
event,
|
|
221604
221704
|
callbacks: [
|
|
221605
221705
|
resolvedOnToolExecutionStart,
|
|
221606
221706
|
telemetryDispatcher.onToolExecutionStart
|
|
221607
221707
|
]
|
|
221608
221708
|
}),
|
|
221609
|
-
onToolExecutionEnd: (event) =>
|
|
221709
|
+
onToolExecutionEnd: (event) => notify4({
|
|
221610
221710
|
event,
|
|
221611
221711
|
callbacks: [
|
|
221612
221712
|
resolvedOnToolExecutionEnd,
|
|
@@ -221710,7 +221810,7 @@ async function generateText({
|
|
|
221710
221810
|
steps.push(currentStepResult);
|
|
221711
221811
|
instructionsForNextStep = stepInstructions;
|
|
221712
221812
|
messagesForNextStep = [...stepMessages, ...stepResponseMessages];
|
|
221713
|
-
await
|
|
221813
|
+
await notify4({
|
|
221714
221814
|
event: currentStepResult,
|
|
221715
221815
|
callbacks: [resolvedOnStepEnd, telemetryDispatcher.onStepEnd]
|
|
221716
221816
|
});
|
|
@@ -221794,7 +221894,7 @@ async function generateText({
|
|
|
221794
221894
|
finalStep: lastStep,
|
|
221795
221895
|
toolsContext
|
|
221796
221896
|
};
|
|
221797
|
-
await
|
|
221897
|
+
await notify4({
|
|
221798
221898
|
event: onEndEvent,
|
|
221799
221899
|
callbacks: [onEnd, telemetryDispatcher.onEnd]
|
|
221800
221900
|
});
|
|
@@ -223720,7 +223820,7 @@ async function streamLanguageModelCall({
|
|
|
223720
223820
|
const stepToolChoice = prepareToolChoice({
|
|
223721
223821
|
toolChoice
|
|
223722
223822
|
});
|
|
223723
|
-
await
|
|
223823
|
+
await notify4({
|
|
223724
223824
|
event: { promptMessages },
|
|
223725
223825
|
callbacks: onStart
|
|
223726
223826
|
});
|
|
@@ -223736,7 +223836,7 @@ async function streamLanguageModelCall({
|
|
|
223736
223836
|
callId: effectiveCallId,
|
|
223737
223837
|
...languageModelCallContext
|
|
223738
223838
|
};
|
|
223739
|
-
await
|
|
223839
|
+
await notify4({
|
|
223740
223840
|
event: languageModelCallStartEvent,
|
|
223741
223841
|
callbacks: onLanguageModelCallStart
|
|
223742
223842
|
});
|
|
@@ -223935,7 +224035,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
|
|
|
223935
224035
|
timeToFirstOutputMs,
|
|
223936
224036
|
timeBetweenOutputChunksMs: timeBetweenOutputChunksMs.length > 0 ? calculateOutputChunkTimingStats(timeBetweenOutputChunksMs) : void 0
|
|
223937
224037
|
};
|
|
223938
|
-
await
|
|
224038
|
+
await notify4({
|
|
223939
224039
|
event: {
|
|
223940
224040
|
callId,
|
|
223941
224041
|
provider,
|
|
@@ -225273,7 +225373,7 @@ async function embed({
|
|
|
225273
225373
|
event: startEvent,
|
|
225274
225374
|
execute: async () => {
|
|
225275
225375
|
var _a242;
|
|
225276
|
-
await
|
|
225376
|
+
await notify4({
|
|
225277
225377
|
event: startEvent,
|
|
225278
225378
|
callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
|
|
225279
225379
|
});
|
|
@@ -225281,7 +225381,7 @@ async function embed({
|
|
|
225281
225381
|
const { embedding, usage, warnings, response, providerMetadata } = await retry(async () => {
|
|
225282
225382
|
var _a252, _b21;
|
|
225283
225383
|
const embedCallId = generateCallId();
|
|
225284
|
-
await
|
|
225384
|
+
await notify4({
|
|
225285
225385
|
event: {
|
|
225286
225386
|
callId,
|
|
225287
225387
|
embedCallId,
|
|
@@ -225300,7 +225400,7 @@ async function embed({
|
|
|
225300
225400
|
});
|
|
225301
225401
|
const embedding2 = modelResponse.embeddings[0];
|
|
225302
225402
|
const usage2 = (_a252 = modelResponse.usage) != null ? _a252 : { tokens: NaN };
|
|
225303
|
-
await
|
|
225403
|
+
await notify4({
|
|
225304
225404
|
event: {
|
|
225305
225405
|
callId,
|
|
225306
225406
|
embedCallId,
|
|
@@ -225326,7 +225426,7 @@ async function embed({
|
|
|
225326
225426
|
provider: model.provider,
|
|
225327
225427
|
model: model.modelId
|
|
225328
225428
|
});
|
|
225329
|
-
await
|
|
225429
|
+
await notify4({
|
|
225330
225430
|
event: {
|
|
225331
225431
|
callId,
|
|
225332
225432
|
operationId: "ai.embed",
|
|
@@ -225414,7 +225514,7 @@ async function embedMany({
|
|
|
225414
225514
|
event: startEvent,
|
|
225415
225515
|
execute: async () => {
|
|
225416
225516
|
var _a242, _b21;
|
|
225417
|
-
await
|
|
225517
|
+
await notify4({
|
|
225418
225518
|
event: startEvent,
|
|
225419
225519
|
callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
|
|
225420
225520
|
});
|
|
@@ -225426,7 +225526,7 @@ async function embedMany({
|
|
|
225426
225526
|
const { embeddings: embeddings2, usage, warnings: warnings2, response, providerMetadata: providerMetadata2 } = await retry(async () => {
|
|
225427
225527
|
var _a252, _b26;
|
|
225428
225528
|
const embedCallId = generateCallId();
|
|
225429
|
-
await
|
|
225529
|
+
await notify4({
|
|
225430
225530
|
event: {
|
|
225431
225531
|
callId,
|
|
225432
225532
|
embedCallId,
|
|
@@ -225445,7 +225545,7 @@ async function embedMany({
|
|
|
225445
225545
|
});
|
|
225446
225546
|
const embeddings3 = modelResponse.embeddings;
|
|
225447
225547
|
const usage2 = (_a252 = modelResponse.usage) != null ? _a252 : { tokens: NaN };
|
|
225448
|
-
await
|
|
225548
|
+
await notify4({
|
|
225449
225549
|
event: {
|
|
225450
225550
|
callId,
|
|
225451
225551
|
embedCallId,
|
|
@@ -225471,7 +225571,7 @@ async function embedMany({
|
|
|
225471
225571
|
provider: model.provider,
|
|
225472
225572
|
model: model.modelId
|
|
225473
225573
|
});
|
|
225474
|
-
await
|
|
225574
|
+
await notify4({
|
|
225475
225575
|
event: {
|
|
225476
225576
|
callId,
|
|
225477
225577
|
operationId: "ai.embedMany",
|
|
@@ -225511,7 +225611,7 @@ async function embedMany({
|
|
|
225511
225611
|
return retry(async () => {
|
|
225512
225612
|
var _a252, _b26;
|
|
225513
225613
|
const embedCallId = generateCallId();
|
|
225514
|
-
await
|
|
225614
|
+
await notify4({
|
|
225515
225615
|
event: {
|
|
225516
225616
|
callId,
|
|
225517
225617
|
embedCallId,
|
|
@@ -225530,7 +225630,7 @@ async function embedMany({
|
|
|
225530
225630
|
});
|
|
225531
225631
|
const chunkEmbeddings = modelResponse.embeddings;
|
|
225532
225632
|
const usage = (_a252 = modelResponse.usage) != null ? _a252 : { tokens: NaN };
|
|
225533
|
-
await
|
|
225633
|
+
await notify4({
|
|
225534
225634
|
event: {
|
|
225535
225635
|
callId,
|
|
225536
225636
|
embedCallId,
|
|
@@ -225579,7 +225679,7 @@ async function embedMany({
|
|
|
225579
225679
|
provider: model.provider,
|
|
225580
225680
|
model: model.modelId
|
|
225581
225681
|
});
|
|
225582
|
-
await
|
|
225682
|
+
await notify4({
|
|
225583
225683
|
event: {
|
|
225584
225684
|
callId,
|
|
225585
225685
|
operationId: "ai.embedMany",
|
|
@@ -226077,7 +226177,7 @@ async function generateObject(options) {
|
|
|
226077
226177
|
const resolvedOnStepEnd = onStepEnd != null ? onStepEnd : onStepFinish;
|
|
226078
226178
|
const jsonSchema22 = await outputStrategy.jsonSchema();
|
|
226079
226179
|
const callId = generateId3();
|
|
226080
|
-
await
|
|
226180
|
+
await notify4({
|
|
226081
226181
|
event: {
|
|
226082
226182
|
callId,
|
|
226083
226183
|
operationId: "ai.generateObject",
|
|
@@ -226117,7 +226217,7 @@ async function generateObject(options) {
|
|
|
226117
226217
|
download: download2,
|
|
226118
226218
|
provider: model.provider.split(".")[0]
|
|
226119
226219
|
});
|
|
226120
|
-
await
|
|
226220
|
+
await notify4({
|
|
226121
226221
|
event: {
|
|
226122
226222
|
callId,
|
|
226123
226223
|
stepNumber: 0,
|
|
@@ -226187,7 +226287,7 @@ async function generateObject(options) {
|
|
|
226187
226287
|
response,
|
|
226188
226288
|
providerMetadata: resultProviderMetadata
|
|
226189
226289
|
};
|
|
226190
|
-
await
|
|
226290
|
+
await notify4({
|
|
226191
226291
|
event: stepFinishEvent,
|
|
226192
226292
|
callbacks: [resolvedOnStepEnd, telemetryDispatcher.onObjectStepEnd]
|
|
226193
226293
|
});
|
|
@@ -226201,7 +226301,7 @@ async function generateObject(options) {
|
|
|
226201
226301
|
finishReason
|
|
226202
226302
|
}
|
|
226203
226303
|
);
|
|
226204
|
-
await
|
|
226304
|
+
await notify4({
|
|
226205
226305
|
event: {
|
|
226206
226306
|
callId,
|
|
226207
226307
|
object: object32,
|
|
@@ -227799,7 +227899,7 @@ async function rerank({
|
|
|
227799
227899
|
});
|
|
227800
227900
|
const runInTracingChannelSpan = (_a232 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a232 : async ({ execute }) => await execute();
|
|
227801
227901
|
if (documents.length === 0) {
|
|
227802
|
-
await
|
|
227902
|
+
await notify4({
|
|
227803
227903
|
event: {
|
|
227804
227904
|
callId,
|
|
227805
227905
|
operationId: "ai.rerank",
|
|
@@ -227814,7 +227914,7 @@ async function rerank({
|
|
|
227814
227914
|
},
|
|
227815
227915
|
callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
|
|
227816
227916
|
});
|
|
227817
|
-
await
|
|
227917
|
+
await notify4({
|
|
227818
227918
|
event: {
|
|
227819
227919
|
callId,
|
|
227820
227920
|
operationId: "ai.rerank",
|
|
@@ -227864,14 +227964,14 @@ async function rerank({
|
|
|
227864
227964
|
event: startEvent,
|
|
227865
227965
|
execute: async () => {
|
|
227866
227966
|
var _a242, _b21, _c, _d, _e2;
|
|
227867
|
-
await
|
|
227967
|
+
await notify4({
|
|
227868
227968
|
event: startEvent,
|
|
227869
227969
|
callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
|
|
227870
227970
|
});
|
|
227871
227971
|
try {
|
|
227872
227972
|
const { ranking, response, providerMetadata, warnings } = await retry(
|
|
227873
227973
|
async () => {
|
|
227874
|
-
await
|
|
227974
|
+
await notify4({
|
|
227875
227975
|
event: {
|
|
227876
227976
|
callId,
|
|
227877
227977
|
operationId: "ai.rerank.doRerank",
|
|
@@ -227893,7 +227993,7 @@ async function rerank({
|
|
|
227893
227993
|
headers
|
|
227894
227994
|
});
|
|
227895
227995
|
const ranking2 = modelResponse.ranking;
|
|
227896
|
-
await
|
|
227996
|
+
await notify4({
|
|
227897
227997
|
event: {
|
|
227898
227998
|
callId,
|
|
227899
227999
|
operationId: "ai.rerank.doRerank",
|
|
@@ -227917,7 +228017,7 @@ async function rerank({
|
|
|
227917
228017
|
provider: model.provider,
|
|
227918
228018
|
model: model.modelId
|
|
227919
228019
|
});
|
|
227920
|
-
await
|
|
228020
|
+
await notify4({
|
|
227921
228021
|
event: {
|
|
227922
228022
|
callId,
|
|
227923
228023
|
operationId: "ai.rerank",
|
|
@@ -229253,12 +229353,12 @@ var init_dist21 = __esm({
|
|
|
229253
229353
|
if (options.warnings.length === 0) {
|
|
229254
229354
|
return;
|
|
229255
229355
|
}
|
|
229256
|
-
const
|
|
229257
|
-
if (
|
|
229356
|
+
const logger94 = globalThis.AI_SDK_LOG_WARNINGS;
|
|
229357
|
+
if (logger94 === false) {
|
|
229258
229358
|
return;
|
|
229259
229359
|
}
|
|
229260
|
-
if (typeof
|
|
229261
|
-
|
|
229360
|
+
if (typeof logger94 === "function") {
|
|
229361
|
+
logger94(options);
|
|
229262
229362
|
return;
|
|
229263
229363
|
}
|
|
229264
229364
|
if (!hasLoggedBefore) {
|
|
@@ -230654,7 +230754,7 @@ var init_dist21 = __esm({
|
|
|
230654
230754
|
},
|
|
230655
230755
|
providerMetadata: part.providerMetadata
|
|
230656
230756
|
});
|
|
230657
|
-
await
|
|
230757
|
+
await notify4({
|
|
230658
230758
|
event: currentStepResult,
|
|
230659
230759
|
callbacks: [onStepFinish, telemetryDispatcher.onStepEnd]
|
|
230660
230760
|
});
|
|
@@ -230713,7 +230813,7 @@ var init_dist21 = __esm({
|
|
|
230713
230813
|
var _a232;
|
|
230714
230814
|
return (_a232 = step.warnings) != null ? _a232 : [];
|
|
230715
230815
|
});
|
|
230716
|
-
await
|
|
230816
|
+
await notify4({
|
|
230717
230817
|
event: {
|
|
230718
230818
|
callId,
|
|
230719
230819
|
toolsContext: finalStep.toolsContext,
|
|
@@ -230764,7 +230864,7 @@ var init_dist21 = __esm({
|
|
|
230764
230864
|
},
|
|
230765
230865
|
async pull(controller) {
|
|
230766
230866
|
async function abort() {
|
|
230767
|
-
await
|
|
230867
|
+
await notify4({
|
|
230768
230868
|
event: {
|
|
230769
230869
|
callId,
|
|
230770
230870
|
steps: recordedSteps,
|
|
@@ -230882,7 +230982,7 @@ var init_dist21 = __esm({
|
|
|
230882
230982
|
const runInTracingChannelSpanInStreamText = telemetryDispatcher.runInTracingChannelSpan == null ? void 0 : (options) => runInStreamTextTracingChannelContext(
|
|
230883
230983
|
() => telemetryDispatcher.runInTracingChannelSpan(options)
|
|
230884
230984
|
);
|
|
230885
|
-
await
|
|
230985
|
+
await notify4({
|
|
230886
230986
|
event: startEvent,
|
|
230887
230987
|
callbacks: [onStart, telemetryDispatcher.onStart]
|
|
230888
230988
|
});
|
|
@@ -231179,7 +231279,7 @@ var init_dist21 = __esm({
|
|
|
231179
231279
|
),
|
|
231180
231280
|
onStart: async ({ promptMessages }) => {
|
|
231181
231281
|
var _a262, _b34;
|
|
231182
|
-
await
|
|
231282
|
+
await notify4({
|
|
231183
231283
|
event: {
|
|
231184
231284
|
callId,
|
|
231185
231285
|
provider: stepModel.provider,
|
|
@@ -232750,7 +232850,7 @@ var init_dist21 = __esm({
|
|
|
232750
232850
|
const callId = generateId3();
|
|
232751
232851
|
(async () => {
|
|
232752
232852
|
const jsonSchema22 = await outputStrategy.jsonSchema();
|
|
232753
|
-
await
|
|
232853
|
+
await notify4({
|
|
232754
232854
|
event: {
|
|
232755
232855
|
callId,
|
|
232756
232856
|
operationId: "ai.streamObject",
|
|
@@ -232802,7 +232902,7 @@ var init_dist21 = __esm({
|
|
|
232802
232902
|
headers,
|
|
232803
232903
|
includeRawChunks: false
|
|
232804
232904
|
};
|
|
232805
|
-
await
|
|
232905
|
+
await notify4({
|
|
232806
232906
|
event: {
|
|
232807
232907
|
callId,
|
|
232808
232908
|
stepNumber: 0,
|
|
@@ -232962,7 +233062,7 @@ var init_dist21 = __esm({
|
|
|
232962
233062
|
completionTokens: NaN,
|
|
232963
233063
|
totalTokens: NaN
|
|
232964
233064
|
};
|
|
232965
|
-
await
|
|
233065
|
+
await notify4({
|
|
232966
233066
|
event: {
|
|
232967
233067
|
callId,
|
|
232968
233068
|
stepNumber: 0,
|
|
@@ -232986,7 +233086,7 @@ var init_dist21 = __esm({
|
|
|
232986
233086
|
telemetryDispatcher.onObjectStepEnd
|
|
232987
233087
|
]
|
|
232988
233088
|
});
|
|
232989
|
-
await
|
|
233089
|
+
await notify4({
|
|
232990
233090
|
event: {
|
|
232991
233091
|
callId,
|
|
232992
233092
|
object: object32,
|
|
@@ -235200,30 +235300,30 @@ function isUntrustedSenderFrame(event) {
|
|
|
235200
235300
|
const frameUrl = event.senderFrame?.url ?? "";
|
|
235201
235301
|
return /^https?:\/\//i.test(frameUrl);
|
|
235202
235302
|
}
|
|
235203
|
-
function createLoggedHandler(
|
|
235303
|
+
function createLoggedHandler(logger94) {
|
|
235204
235304
|
return (channel, fn2) => {
|
|
235205
235305
|
ipcMain.handle(
|
|
235206
235306
|
channel,
|
|
235207
235307
|
async (event, ...args2) => {
|
|
235208
235308
|
if (isUntrustedSenderFrame(event)) {
|
|
235209
|
-
|
|
235309
|
+
logger94.error(
|
|
235210
235310
|
`IPC ${channel} rejected: untrusted sender frame ${event.senderFrame?.url}`
|
|
235211
235311
|
);
|
|
235212
235312
|
throw new Error(`[${channel}] rejected: untrusted sender frame`);
|
|
235213
235313
|
}
|
|
235214
235314
|
if (verboseIpc) {
|
|
235215
|
-
|
|
235315
|
+
logger94.log(`IPC: ${channel} called with args: ${JSON.stringify(args2)}`);
|
|
235216
235316
|
}
|
|
235217
235317
|
try {
|
|
235218
235318
|
const result2 = await fn2(event, ...args2);
|
|
235219
235319
|
if (verboseIpc) {
|
|
235220
|
-
|
|
235320
|
+
logger94.log(
|
|
235221
235321
|
`IPC: ${channel} returned: ${JSON.stringify(result2)?.slice(0, 100)}...`
|
|
235222
235322
|
);
|
|
235223
235323
|
}
|
|
235224
235324
|
return result2;
|
|
235225
235325
|
} catch (error51) {
|
|
235226
|
-
|
|
235326
|
+
logger94.error(
|
|
235227
235327
|
`Error in ${fn2.name}: args: ${JSON.stringify(args2)}`,
|
|
235228
235328
|
error51
|
|
235229
235329
|
);
|
|
@@ -320054,17 +320154,17 @@ function createTabNetworkLog(tabId) {
|
|
|
320054
320154
|
function bodyKey(method, url2) {
|
|
320055
320155
|
return `${method.toUpperCase()} ${url2}`;
|
|
320056
320156
|
}
|
|
320057
|
-
function beginRequest(
|
|
320157
|
+
function beginRequest(log96, entry) {
|
|
320058
320158
|
const epoch = currentNavigationEpoch(entry.tabId);
|
|
320059
|
-
|
|
320159
|
+
log96.pending.set(entry.id, {
|
|
320060
320160
|
...entry,
|
|
320061
320161
|
navSeq: entry.navSeq ?? epoch.seq,
|
|
320062
320162
|
pageUrl: entry.pageUrl ?? epoch.pageUrl
|
|
320063
320163
|
});
|
|
320064
320164
|
}
|
|
320065
|
-
function completeRequest(
|
|
320066
|
-
const started =
|
|
320067
|
-
if (started)
|
|
320165
|
+
function completeRequest(log96, id, patch, fallback) {
|
|
320166
|
+
const started = log96.pending.get(id);
|
|
320167
|
+
if (started) log96.pending.delete(id);
|
|
320068
320168
|
const base = started ?? (fallback ? {
|
|
320069
320169
|
id,
|
|
320070
320170
|
startedAt: patch.finishedAt ?? Date.now(),
|
|
@@ -320083,33 +320183,33 @@ function completeRequest(log95, id, patch, fallback) {
|
|
|
320083
320183
|
};
|
|
320084
320184
|
if (merged.responseBody === void 0 && merged.url) {
|
|
320085
320185
|
const key = bodyKey(merged.method, merged.url);
|
|
320086
|
-
const orphan =
|
|
320186
|
+
const orphan = log96.orphanBodies.get(key);
|
|
320087
320187
|
if (orphan) {
|
|
320088
|
-
|
|
320188
|
+
log96.orphanBodies.delete(key);
|
|
320089
320189
|
merged.responseBody = orphan.body;
|
|
320090
320190
|
merged.responseBodyTruncated = orphan.truncated;
|
|
320091
320191
|
}
|
|
320092
320192
|
}
|
|
320093
|
-
|
|
320094
|
-
if (
|
|
320095
|
-
|
|
320193
|
+
log96.entries.push(merged);
|
|
320194
|
+
if (log96.entries.length > NETWORK_ENTRIES_PER_TAB_MAX) {
|
|
320195
|
+
log96.entries = log96.entries.slice(-NETWORK_ENTRIES_PER_TAB_MAX);
|
|
320096
320196
|
}
|
|
320097
320197
|
return merged;
|
|
320098
320198
|
}
|
|
320099
|
-
function attachResponseBody(
|
|
320199
|
+
function attachResponseBody(log96, captured) {
|
|
320100
320200
|
const key = bodyKey(captured.method, captured.url);
|
|
320101
|
-
for (let i4 =
|
|
320102
|
-
const entry =
|
|
320201
|
+
for (let i4 = log96.entries.length - 1; i4 >= 0; i4--) {
|
|
320202
|
+
const entry = log96.entries[i4];
|
|
320103
320203
|
if (entry.responseBody !== void 0) continue;
|
|
320104
320204
|
if (bodyKey(entry.method, entry.url) !== key) continue;
|
|
320105
320205
|
entry.responseBody = captured.body;
|
|
320106
320206
|
entry.responseBodyTruncated = captured.truncated;
|
|
320107
320207
|
return true;
|
|
320108
320208
|
}
|
|
320109
|
-
|
|
320110
|
-
if (
|
|
320111
|
-
const oldest =
|
|
320112
|
-
if (!oldest.done)
|
|
320209
|
+
log96.orphanBodies.set(key, { body: captured.body, truncated: captured.truncated });
|
|
320210
|
+
if (log96.orphanBodies.size > NETWORK_ORPHAN_BODIES_MAX) {
|
|
320211
|
+
const oldest = log96.orphanBodies.keys().next();
|
|
320212
|
+
if (!oldest.done) log96.orphanBodies.delete(oldest.value);
|
|
320113
320213
|
}
|
|
320114
320214
|
return false;
|
|
320115
320215
|
}
|
|
@@ -321264,14 +321364,14 @@ var init_preview_verify = __esm({
|
|
|
321264
321364
|
// src/lib/tools/browser-recorder.ts
|
|
321265
321365
|
function recordBrowserAction(chatId, type2, detail, url2) {
|
|
321266
321366
|
if (chatId == null) return;
|
|
321267
|
-
const steps =
|
|
321367
|
+
const steps = byChat2.get(chatId) ?? [];
|
|
321268
321368
|
steps.push({ type: type2, detail: detail.slice(0, 300), url: url2, ts: Date.now() });
|
|
321269
321369
|
if (steps.length > MAX_STEPS) steps.splice(0, steps.length - MAX_STEPS);
|
|
321270
|
-
|
|
321370
|
+
byChat2.set(chatId, steps);
|
|
321271
321371
|
}
|
|
321272
321372
|
function getBrowserRecording(chatId) {
|
|
321273
321373
|
if (chatId == null) return [];
|
|
321274
|
-
return
|
|
321374
|
+
return byChat2.get(chatId) ?? [];
|
|
321275
321375
|
}
|
|
321276
321376
|
function formatBrowserRecordingArtifact(chatId) {
|
|
321277
321377
|
const steps = getBrowserRecording(chatId);
|
|
@@ -321283,11 +321383,11 @@ function formatBrowserRecordingArtifact(chatId) {
|
|
|
321283
321383
|
return `## Browser session walkthrough (${steps.length} step${steps.length === 1 ? "" : "s"})
|
|
321284
321384
|
${lines.join("\n")}`;
|
|
321285
321385
|
}
|
|
321286
|
-
var MAX_STEPS,
|
|
321386
|
+
var MAX_STEPS, byChat2;
|
|
321287
321387
|
var init_browser_recorder = __esm({
|
|
321288
321388
|
"src/lib/tools/browser-recorder.ts"() {
|
|
321289
321389
|
MAX_STEPS = 200;
|
|
321290
|
-
|
|
321390
|
+
byChat2 = /* @__PURE__ */ new Map();
|
|
321291
321391
|
}
|
|
321292
321392
|
});
|
|
321293
321393
|
|
|
@@ -325329,6 +325429,9 @@ function shouldDropSystemWake(req, state) {
|
|
|
325329
325429
|
if (state.userStopped) return "user-stopped";
|
|
325330
325430
|
return null;
|
|
325331
325431
|
}
|
|
325432
|
+
function shouldClearUserStopLatch(req) {
|
|
325433
|
+
return !req.systemWake;
|
|
325434
|
+
}
|
|
325332
325435
|
function isChatStreamLive(chatId) {
|
|
325333
325436
|
return activeStreams.has(chatId) || activeStreamRuns.has(chatId);
|
|
325334
325437
|
}
|
|
@@ -326303,6 +326406,37 @@ function registerSessionHandlers() {
|
|
|
326303
326406
|
return { success: true, restream: true };
|
|
326304
326407
|
}
|
|
326305
326408
|
);
|
|
326409
|
+
setUserInterjectionNotifier((chatId, pending2) => {
|
|
326410
|
+
broadcastToAllWindows("chat:interjections", { chatId, pending: pending2 });
|
|
326411
|
+
});
|
|
326412
|
+
ipcMain.handle(
|
|
326413
|
+
"chat:interject",
|
|
326414
|
+
(_e2, payload) => {
|
|
326415
|
+
const entry = recordUserInterjection(Number(payload?.chatId), {
|
|
326416
|
+
id: String(payload?.id ?? ""),
|
|
326417
|
+
text: String(payload?.text ?? "")
|
|
326418
|
+
});
|
|
326419
|
+
return {
|
|
326420
|
+
ok: entry != null,
|
|
326421
|
+
pending: listPendingUserInterjections(Number(payload?.chatId))
|
|
326422
|
+
};
|
|
326423
|
+
}
|
|
326424
|
+
);
|
|
326425
|
+
ipcMain.handle(
|
|
326426
|
+
"chat:interject-cancel",
|
|
326427
|
+
(_e2, payload) => {
|
|
326428
|
+
const chatId = Number(payload?.chatId);
|
|
326429
|
+
const ok = cancelUserInterjection(chatId, String(payload?.id ?? ""));
|
|
326430
|
+
return { ok, pending: listPendingUserInterjections(chatId) };
|
|
326431
|
+
}
|
|
326432
|
+
);
|
|
326433
|
+
ipcMain.handle(
|
|
326434
|
+
"chat:interject-list",
|
|
326435
|
+
(_e2, chatId) => listPendingUserInterjections(Number(chatId))
|
|
326436
|
+
);
|
|
326437
|
+
ipcMain.handle("chat:interject-flush", (_e2, chatId) => ({
|
|
326438
|
+
text: takeUserInterjectionsAsPrompt(Number(chatId))
|
|
326439
|
+
}));
|
|
326306
326440
|
}
|
|
326307
326441
|
var import_electron_log68, logger67;
|
|
326308
326442
|
var init_session_handlers = __esm({
|
|
@@ -326314,6 +326448,8 @@ var init_session_handlers = __esm({
|
|
|
326314
326448
|
init_safe_sender();
|
|
326315
326449
|
init_stream_lifecycle();
|
|
326316
326450
|
init_stream_state();
|
|
326451
|
+
init_user_interjections();
|
|
326452
|
+
init_broadcast_all_windows();
|
|
326317
326453
|
logger67 = import_electron_log68.default.scope("chat_stream_handlers");
|
|
326318
326454
|
}
|
|
326319
326455
|
});
|
|
@@ -326669,18 +326805,16 @@ async function processResponseChunkUpdate(deps, { fullResponse }) {
|
|
|
326669
326805
|
);
|
|
326670
326806
|
}
|
|
326671
326807
|
const currentMessages = [...updatedChat.messages];
|
|
326672
|
-
|
|
326673
|
-
|
|
326674
|
-
|
|
326675
|
-
|
|
326676
|
-
|
|
326677
|
-
|
|
326678
|
-
|
|
326679
|
-
|
|
326680
|
-
|
|
326681
|
-
|
|
326682
|
-
}
|
|
326683
|
-
}
|
|
326808
|
+
const placeholderId = deps.placeholderAssistantMessage?.id;
|
|
326809
|
+
const idx = placeholderId != null ? currentMessages.findIndex((m3) => m3?.id === placeholderId) : -1;
|
|
326810
|
+
const targetIdx = idx >= 0 ? idx : currentMessages.length > 0 && currentMessages[currentMessages.length - 1].role === "assistant" ? currentMessages.length - 1 : -1;
|
|
326811
|
+
if (targetIdx >= 0) {
|
|
326812
|
+
currentMessages[targetIdx].content = fullResponse;
|
|
326813
|
+
updatedChat.messages[targetIdx].content = fullResponse;
|
|
326814
|
+
const { getStreamTransport: getStreamTransport2 } = await Promise.resolve().then(() => (init_stream_transport(), stream_transport_exports));
|
|
326815
|
+
const ec3 = getStreamTransport2(req.chatId);
|
|
326816
|
+
if (ec3) {
|
|
326817
|
+
ec3.messages = updatedChat.messages;
|
|
326684
326818
|
}
|
|
326685
326819
|
}
|
|
326686
326820
|
safeSend(event.sender, "chat:response:chunk", {
|
|
@@ -328940,6 +329074,47 @@ var init_dropped_history_notice = __esm({
|
|
|
328940
329074
|
}
|
|
328941
329075
|
});
|
|
328942
329076
|
|
|
329077
|
+
// src/ipc/handlers/chat_stream/interjection-delivery.ts
|
|
329078
|
+
async function deliverInterjectionsToTranscript(args2) {
|
|
329079
|
+
const { chatId, streamId, event, placeholderMessageId, interjections } = args2;
|
|
329080
|
+
if (!interjections.length) return;
|
|
329081
|
+
try {
|
|
329082
|
+
const { isStreamTransportId: isStreamTransportId2, getStreamTransport: getStreamTransport2, insertUserInterjectionMessage: insertUserInterjectionMessage2 } = await Promise.resolve().then(() => (init_stream_transport(), stream_transport_exports));
|
|
329083
|
+
if (!isStreamTransportId2(chatId)) return;
|
|
329084
|
+
for (const item of interjections) {
|
|
329085
|
+
let rowId;
|
|
329086
|
+
try {
|
|
329087
|
+
const {
|
|
329088
|
+
resolveOrBindWorkspaceSessionForStream: resolveOrBindWorkspaceSessionForStream2,
|
|
329089
|
+
persistWorkspaceSessionUserMessage: persistWorkspaceSessionUserMessage2
|
|
329090
|
+
} = await Promise.resolve().then(() => (init_workspace_session_handlers(), workspace_session_handlers_exports));
|
|
329091
|
+
const sessionId = await resolveOrBindWorkspaceSessionForStream2({ chatId });
|
|
329092
|
+
const row = await persistWorkspaceSessionUserMessage2(sessionId, item.text, {});
|
|
329093
|
+
rowId = row?.id;
|
|
329094
|
+
} catch (err2) {
|
|
329095
|
+
logger76.warn(`[interjection] could not persist to session: ${String(err2)}`);
|
|
329096
|
+
}
|
|
329097
|
+
insertUserInterjectionMessage2(chatId, item.text, placeholderMessageId, rowId);
|
|
329098
|
+
}
|
|
329099
|
+
const chat = getStreamTransport2(chatId);
|
|
329100
|
+
safeSend(event.sender, "chat:response:chunk", {
|
|
329101
|
+
chatId,
|
|
329102
|
+
streamId,
|
|
329103
|
+
messages: [...chat?.messages ?? []]
|
|
329104
|
+
});
|
|
329105
|
+
} catch (err2) {
|
|
329106
|
+
logger76.warn(`[interjection] transcript insert failed: ${String(err2)}`);
|
|
329107
|
+
}
|
|
329108
|
+
}
|
|
329109
|
+
var import_electron_log77, logger76;
|
|
329110
|
+
var init_interjection_delivery = __esm({
|
|
329111
|
+
"src/ipc/handlers/chat_stream/interjection-delivery.ts"() {
|
|
329112
|
+
import_electron_log77 = __toESM(require_src());
|
|
329113
|
+
init_safe_sender();
|
|
329114
|
+
logger76 = import_electron_log77.default.scope("user-interjections");
|
|
329115
|
+
}
|
|
329116
|
+
});
|
|
329117
|
+
|
|
328943
329118
|
// src/lib/ai/merge-system-prompt.ts
|
|
328944
329119
|
function mergeSystemPromptParts(stable, ...dynamicParts) {
|
|
328945
329120
|
const parts = [stable, ...dynamicParts].filter(
|
|
@@ -328958,18 +329133,37 @@ function perfReportOnce(key, label) {
|
|
|
328958
329133
|
const start = marks.get(key);
|
|
328959
329134
|
if (start == null) return;
|
|
328960
329135
|
reported.add(key);
|
|
328961
|
-
|
|
329136
|
+
logger77.info(`[perf] ${label}: ${Date.now() - start}ms`);
|
|
328962
329137
|
}
|
|
328963
|
-
var
|
|
329138
|
+
var import_electron_log78, logger77, marks, reported;
|
|
328964
329139
|
var init_perf_marks = __esm({
|
|
328965
329140
|
"src/lib/perf-marks.ts"() {
|
|
328966
|
-
|
|
328967
|
-
|
|
329141
|
+
import_electron_log78 = __toESM(require_src());
|
|
329142
|
+
logger77 = import_electron_log78.default.scope("perf");
|
|
328968
329143
|
marks = /* @__PURE__ */ new Map();
|
|
328969
329144
|
reported = /* @__PURE__ */ new Set();
|
|
328970
329145
|
}
|
|
328971
329146
|
});
|
|
328972
329147
|
|
|
329148
|
+
// src/lib/streaming/step-messages.ts
|
|
329149
|
+
function buildStepMessages(args2) {
|
|
329150
|
+
const { messages, injected, interjections, tag } = args2;
|
|
329151
|
+
const hasInterjections = (interjections?.length ?? 0) > 0;
|
|
329152
|
+
if (!injected && !hasInterjections) {
|
|
329153
|
+
return { messages, changed: false };
|
|
329154
|
+
}
|
|
329155
|
+
const out = [...messages];
|
|
329156
|
+
if (injected) out.push({ role: "user", content: tag(injected) });
|
|
329157
|
+
for (const m3 of interjections ?? []) {
|
|
329158
|
+
out.push({ role: "user", content: m3.text });
|
|
329159
|
+
}
|
|
329160
|
+
return { messages: out, changed: true };
|
|
329161
|
+
}
|
|
329162
|
+
var init_step_messages = __esm({
|
|
329163
|
+
"src/lib/streaming/step-messages.ts"() {
|
|
329164
|
+
}
|
|
329165
|
+
});
|
|
329166
|
+
|
|
328973
329167
|
// src/ipc/handlers/chat_stream/turn-runner/simple-stream-text.ts
|
|
328974
329168
|
function providerOptionsBucketName(providerId) {
|
|
328975
329169
|
const camel = providerId.replace(/[-_](\w)/g, (_4, c2) => c2.toUpperCase());
|
|
@@ -329003,7 +329197,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329003
329197
|
abortController
|
|
329004
329198
|
} = deps;
|
|
329005
329199
|
const forceCollectOnWake = deps.forceCollectOnWake && !ctx.forcedToolChoiceRejected;
|
|
329006
|
-
|
|
329200
|
+
logger78.log("sending AI request");
|
|
329007
329201
|
const optionsModel = getEffectiveModelForOptions(settings);
|
|
329008
329202
|
const thinkingTier = enableNativeReasoning;
|
|
329009
329203
|
const maxOutputTokens = await preflight.time(
|
|
@@ -329022,7 +329216,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329022
329216
|
provider: JSON.parse(pinJson)
|
|
329023
329217
|
};
|
|
329024
329218
|
} catch (e3) {
|
|
329025
|
-
|
|
329219
|
+
logger78.warn(
|
|
329026
329220
|
`Ignoring invalid ATLARIX_OPENROUTER_PROVIDER_JSON: ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
329027
329221
|
);
|
|
329028
329222
|
}
|
|
@@ -329130,7 +329324,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329130
329324
|
]
|
|
329131
329325
|
};
|
|
329132
329326
|
}
|
|
329133
|
-
|
|
329327
|
+
logger78.log(
|
|
329134
329328
|
`[native-web-search] ${nativeWeb.kind} active (${modelClient.builtinProviderId}); dropped client tools: ${[...reserved].join(", ")}`
|
|
329135
329329
|
);
|
|
329136
329330
|
}
|
|
@@ -329241,21 +329435,27 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329241
329435
|
const taskLedger = stepNumber === 0 ? currentPlanLedger(req.chatId) ?? taskLedgerBlock : takeRefreshedPlanLedger(req.chatId);
|
|
329242
329436
|
const emptyOutputNudge = ctx.pendingEmptyOutputNudge;
|
|
329243
329437
|
ctx.pendingEmptyOutputNudge = null;
|
|
329438
|
+
const interjections = takePendingUserInterjections(req.chatId);
|
|
329244
329439
|
if (correction) {
|
|
329245
|
-
|
|
329440
|
+
logger78.log(
|
|
329246
329441
|
`[repetition] injecting mid-round correction (chat ${req.chatId})`
|
|
329247
329442
|
);
|
|
329248
329443
|
}
|
|
329249
329444
|
if (bgResults) {
|
|
329250
|
-
|
|
329445
|
+
logger78.log(
|
|
329251
329446
|
`[background-command] injecting finished result (chat ${req.chatId})`
|
|
329252
329447
|
);
|
|
329253
329448
|
}
|
|
329254
329449
|
if (subagentResults) {
|
|
329255
|
-
|
|
329450
|
+
logger78.log(
|
|
329256
329451
|
`[background-subagent] injecting finished result (chat ${req.chatId})`
|
|
329257
329452
|
);
|
|
329258
329453
|
}
|
|
329454
|
+
if (interjections?.length) {
|
|
329455
|
+
logger78.log(
|
|
329456
|
+
`[interjection] delivering ${interjections.length} mid-turn user message(s) (chat ${req.chatId}, step ${stepNumber})`
|
|
329457
|
+
);
|
|
329458
|
+
}
|
|
329259
329459
|
const injected = [
|
|
329260
329460
|
reminder,
|
|
329261
329461
|
droppedHistory,
|
|
@@ -329268,16 +329468,38 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329268
329468
|
// Task ledger + mode re-anchor LAST so they are the final
|
|
329269
329469
|
// things the model reads before it acts.
|
|
329270
329470
|
taskLedger,
|
|
329271
|
-
modeReanchor
|
|
329471
|
+
modeReanchor,
|
|
329472
|
+
// The harness half of a mid-turn message: the user's own words
|
|
329473
|
+
// go below, UNTAGGED, and this says how to read them. Kept in
|
|
329474
|
+
// the tagged block on purpose — guidance about the message is
|
|
329475
|
+
// the harness talking, and putting it in the user's mouth is
|
|
329476
|
+
// exactly the confusion the tag convention exists to prevent.
|
|
329477
|
+
interjections?.length ? `The user sent ${interjections.length === 1 ? "a message" : `${interjections.length} messages`} while you were working; ${interjections.length === 1 ? "it appears" : "they appear"} below as ${interjections.length === 1 ? "a real user turn" : "real user turns, oldest first"}. Fold ${interjections.length === 1 ? "it" : "them"} into what you are already doing and continue \u2014 do NOT restart, re-greet, or re-answer earlier requests. If ${interjections.length === 1 ? "it changes" : "they change"} the goal, say so briefly and change course.` : null
|
|
329272
329478
|
].filter(Boolean).join("\n\n");
|
|
329273
|
-
const
|
|
329479
|
+
const assembled = buildStepMessages({
|
|
329480
|
+
messages,
|
|
329481
|
+
injected,
|
|
329482
|
+
interjections,
|
|
329483
|
+
tag: systemReminder
|
|
329484
|
+
});
|
|
329485
|
+
const stepMessages = assembled.messages;
|
|
329486
|
+
if (interjections?.length) {
|
|
329487
|
+
void deliverInterjectionsToTranscript({
|
|
329488
|
+
chatId: req.chatId,
|
|
329489
|
+
streamId,
|
|
329490
|
+
event,
|
|
329491
|
+
placeholderMessageId: Number(placeholderAssistantMessage?.id),
|
|
329492
|
+
interjections
|
|
329493
|
+
});
|
|
329494
|
+
}
|
|
329274
329495
|
const forceCollect = forceCollectOnWake && stepNumber === 0;
|
|
329275
|
-
const
|
|
329496
|
+
const changedMessages = assembled.changed;
|
|
329497
|
+
const base = cacheMarkerPlacement !== "none" && (stepNumber > 0 || changedMessages) ? {
|
|
329276
329498
|
messages: advanceCacheBreakpointsForStep(
|
|
329277
329499
|
stepMessages,
|
|
329278
329500
|
cacheMarkerPlacement
|
|
329279
329501
|
)
|
|
329280
|
-
} :
|
|
329502
|
+
} : changedMessages ? { messages: stepMessages } : void 0;
|
|
329281
329503
|
if (forceCollect) {
|
|
329282
329504
|
return {
|
|
329283
329505
|
...base ?? { messages },
|
|
@@ -329372,7 +329594,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329372
329594
|
ctx.turnActualCostUsd += orUsage.cost;
|
|
329373
329595
|
}
|
|
329374
329596
|
if (typeof cacheRead === "number" && cacheRead > 0 || typeof cacheWrite === "number" && cacheWrite > 0) {
|
|
329375
|
-
|
|
329597
|
+
logger78.log(
|
|
329376
329598
|
`[prompt-cache] chat ${req.chatId}: read=${cacheRead ?? 0} write=${cacheWrite ?? 0} input=${response.usage?.inputTokens ?? "?"}`
|
|
329377
329599
|
);
|
|
329378
329600
|
}
|
|
@@ -329388,32 +329610,32 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329388
329610
|
}
|
|
329389
329611
|
if (typeof totalTokens === "number" && totalTokens > 0) {
|
|
329390
329612
|
ctx.maxTokensUsed = Math.max(ctx.maxTokensUsed ?? 0, totalTokens);
|
|
329391
|
-
|
|
329613
|
+
logger78.log(
|
|
329392
329614
|
`Total tokens used (aggregated for message ${placeholderAssistantMessage.id}): ${ctx.maxTokensUsed}`
|
|
329393
329615
|
);
|
|
329394
329616
|
} else {
|
|
329395
|
-
|
|
329617
|
+
logger78.log(
|
|
329396
329618
|
`Total tokens used (aggregated for message ${placeholderAssistantMessage.id}): unavailable (no total or prompt/completion counts from provider)`
|
|
329397
329619
|
);
|
|
329398
329620
|
}
|
|
329399
329621
|
},
|
|
329400
329622
|
onError: (error51) => {
|
|
329401
329623
|
if (isNoUsableModelOutputError(error51)) {
|
|
329402
|
-
|
|
329624
|
+
logger78.warn(
|
|
329403
329625
|
"[stream] onError: empty/no usable model output (handled by consumption/retry or auxiliary handlers)",
|
|
329404
329626
|
error51
|
|
329405
329627
|
);
|
|
329406
329628
|
return;
|
|
329407
329629
|
}
|
|
329408
329630
|
if (isNetworkStreamError(error51)) {
|
|
329409
|
-
|
|
329631
|
+
logger78.warn(
|
|
329410
329632
|
"[stream] onError: network/transport failure (will retry silently)",
|
|
329411
329633
|
error51
|
|
329412
329634
|
);
|
|
329413
329635
|
return;
|
|
329414
329636
|
}
|
|
329415
329637
|
if (isForcedToolChoiceRejection(error51)) {
|
|
329416
|
-
|
|
329638
|
+
logger78.warn(
|
|
329417
329639
|
"[stream] onError: provider rejected the forced tool_choice (retrying without it)",
|
|
329418
329640
|
error51
|
|
329419
329641
|
);
|
|
@@ -329434,7 +329656,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329434
329656
|
const statusCode = error51?.statusCode ?? error51?.error?.statusCode;
|
|
329435
329657
|
const rawBody = error51?.responseBody ?? error51?.error?.responseBody ?? "";
|
|
329436
329658
|
const bodyStr = typeof rawBody === "string" ? rawBody : JSON.stringify(rawBody ?? "");
|
|
329437
|
-
|
|
329659
|
+
logger78.error(
|
|
329438
329660
|
`[compass] upstream failure status=${statusCode ?? "none"} body=${bodyStr.slice(0, 800)}`
|
|
329439
329661
|
);
|
|
329440
329662
|
const classified = classifyCompassFailure(statusCode, bodyStr);
|
|
@@ -329443,7 +329665,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329443
329665
|
} else {
|
|
329444
329666
|
message = modelFailureUserMessage(message);
|
|
329445
329667
|
}
|
|
329446
|
-
|
|
329668
|
+
logger78.error(
|
|
329447
329669
|
`AI stream text error for request: errorMessage=${errorMessage} error=`,
|
|
329448
329670
|
error51
|
|
329449
329671
|
);
|
|
@@ -329467,7 +329689,7 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329467
329689
|
});
|
|
329468
329690
|
attachEmptyOutputSafeRejectHandlers(
|
|
329469
329691
|
streamResult,
|
|
329470
|
-
|
|
329692
|
+
logger78.warn.bind(logger78),
|
|
329471
329693
|
"chat_stream"
|
|
329472
329694
|
);
|
|
329473
329695
|
return {
|
|
@@ -329493,10 +329715,10 @@ async function simpleStreamText(ctx, deps, {
|
|
|
329493
329715
|
getResumeMessages: () => completedStepMessages.slice()
|
|
329494
329716
|
};
|
|
329495
329717
|
}
|
|
329496
|
-
var
|
|
329718
|
+
var import_electron_log79, logger78;
|
|
329497
329719
|
var init_simple_stream_text = __esm({
|
|
329498
329720
|
"src/ipc/handlers/chat_stream/turn-runner/simple-stream-text.ts"() {
|
|
329499
|
-
|
|
329721
|
+
import_electron_log79 = __toESM(require_src());
|
|
329500
329722
|
init_dist21();
|
|
329501
329723
|
init_get_model_client();
|
|
329502
329724
|
init_ai_usage();
|
|
@@ -329517,6 +329739,8 @@ var init_simple_stream_text = __esm({
|
|
|
329517
329739
|
init_scheduled_wakeups();
|
|
329518
329740
|
init_dropped_history_notice();
|
|
329519
329741
|
init_subagent_results();
|
|
329742
|
+
init_user_interjections();
|
|
329743
|
+
init_interjection_delivery();
|
|
329520
329744
|
init_anthropic_cache_breakpoints();
|
|
329521
329745
|
init_merge_system_prompt();
|
|
329522
329746
|
init_normalize_tool_schema();
|
|
@@ -329524,8 +329748,9 @@ var init_simple_stream_text = __esm({
|
|
|
329524
329748
|
init_byok_pricing();
|
|
329525
329749
|
init_reasoning_detector();
|
|
329526
329750
|
init_system_reminder();
|
|
329751
|
+
init_step_messages();
|
|
329527
329752
|
init_texts();
|
|
329528
|
-
|
|
329753
|
+
logger78 = import_electron_log79.default.scope("chat_stream_handlers");
|
|
329529
329754
|
}
|
|
329530
329755
|
});
|
|
329531
329756
|
|
|
@@ -329592,7 +329817,7 @@ async function recordEditStats({
|
|
|
329592
329817
|
}
|
|
329593
329818
|
function recordEditStatsSafely(args2) {
|
|
329594
329819
|
void recordEditStats(args2).catch((e3) => {
|
|
329595
|
-
|
|
329820
|
+
logger79.warn("failed to record edit stats", e3);
|
|
329596
329821
|
});
|
|
329597
329822
|
}
|
|
329598
329823
|
function resolveEditStatsModel(effectiveModel, dispatched) {
|
|
@@ -329619,16 +329844,16 @@ function dispatchedModelIdentity(modelClient) {
|
|
|
329619
329844
|
modelId: typeof modelId === "string" ? modelId : void 0
|
|
329620
329845
|
};
|
|
329621
329846
|
}
|
|
329622
|
-
var
|
|
329847
|
+
var import_electron_log80, logger79;
|
|
329623
329848
|
var init_edit_stats2 = __esm({
|
|
329624
329849
|
"src/lib/stats/edit-stats.ts"() {
|
|
329625
|
-
|
|
329850
|
+
import_electron_log80 = __toESM(require_src());
|
|
329626
329851
|
init_drizzle_orm();
|
|
329627
329852
|
init_db2();
|
|
329628
329853
|
init_schema();
|
|
329629
329854
|
init_compose_hunks();
|
|
329630
329855
|
init_compass_constants();
|
|
329631
|
-
|
|
329856
|
+
logger79 = import_electron_log80.default.scope("edit-stats");
|
|
329632
329857
|
}
|
|
329633
329858
|
});
|
|
329634
329859
|
|
|
@@ -330055,7 +330280,7 @@ async function refreshPlanLedgerFromWrittenFile(params) {
|
|
|
330055
330280
|
try {
|
|
330056
330281
|
content = await readFile7(fullPath, "utf8");
|
|
330057
330282
|
} catch (e3) {
|
|
330058
|
-
|
|
330283
|
+
logger80.warn("[refreshPlanLedgerFromWrittenFile] read failed:", e3);
|
|
330059
330284
|
return;
|
|
330060
330285
|
}
|
|
330061
330286
|
const digest = createHash6("sha256").update(content, "utf8").digest("hex");
|
|
@@ -330063,7 +330288,7 @@ async function refreshPlanLedgerFromWrittenFile(params) {
|
|
|
330063
330288
|
const now2 = Date.now();
|
|
330064
330289
|
const prev = refreshGuard.get(guardKey);
|
|
330065
330290
|
if (prev?.hash === digest && now2 - prev.at < DEBOUNCE_MS) {
|
|
330066
|
-
|
|
330291
|
+
logger80.log(
|
|
330067
330292
|
"[refreshPlanLedgerFromWrittenFile] skip duplicate plan body (debounced)"
|
|
330068
330293
|
);
|
|
330069
330294
|
return;
|
|
@@ -330105,12 +330330,12 @@ async function refreshPlanLedgerFromWrittenFile(params) {
|
|
|
330105
330330
|
if (L2) await syncPlanFile2(workspacePath, L2);
|
|
330106
330331
|
}
|
|
330107
330332
|
}
|
|
330108
|
-
var
|
|
330333
|
+
var import_electron_log81, logger80, refreshGuard, DEBOUNCE_MS;
|
|
330109
330334
|
var init_plan_ledger_from_file = __esm({
|
|
330110
330335
|
"src/lib/tasks/plan-ledger-from-file.ts"() {
|
|
330111
|
-
|
|
330336
|
+
import_electron_log81 = __toESM(require_src());
|
|
330112
330337
|
init_plan_sync();
|
|
330113
|
-
|
|
330338
|
+
logger80 = import_electron_log81.default.scope("plan-ledger-from-file");
|
|
330114
330339
|
refreshGuard = /* @__PURE__ */ new Map();
|
|
330115
330340
|
DEBOUNCE_MS = 450;
|
|
330116
330341
|
}
|
|
@@ -330122,7 +330347,7 @@ import pathModule from "node:path";
|
|
|
330122
330347
|
function warnGitMissingOnce(op) {
|
|
330123
330348
|
if (warnedGitMissing) return;
|
|
330124
330349
|
warnedGitMissing = true;
|
|
330125
|
-
|
|
330350
|
+
logger81.warn(
|
|
330126
330351
|
`No git binary available (first noticed during '${op}'); git-backed features are disabled until Git is installed.`
|
|
330127
330352
|
);
|
|
330128
330353
|
}
|
|
@@ -330168,15 +330393,15 @@ async function getCurrentCommitHash({
|
|
|
330168
330393
|
}
|
|
330169
330394
|
return result2.stdout.trim();
|
|
330170
330395
|
}
|
|
330171
|
-
var
|
|
330396
|
+
var import_electron_log82, logger81, warnedGitMissing;
|
|
330172
330397
|
var init_git_utils = __esm({
|
|
330173
330398
|
"src/ipc/utils/git_utils.ts"() {
|
|
330174
330399
|
init_git_author();
|
|
330175
330400
|
init_git_author();
|
|
330176
330401
|
init_system_git_exec();
|
|
330177
330402
|
init_settings();
|
|
330178
|
-
|
|
330179
|
-
|
|
330403
|
+
import_electron_log82 = __toESM(require_src());
|
|
330404
|
+
logger81 = import_electron_log82.default.scope("git_utils");
|
|
330180
330405
|
warnedGitMissing = false;
|
|
330181
330406
|
}
|
|
330182
330407
|
});
|
|
@@ -330238,9 +330463,9 @@ async function insertProjectSnapshot(params) {
|
|
|
330238
330463
|
trigger
|
|
330239
330464
|
});
|
|
330240
330465
|
await pruneSnapshots(workspaceId);
|
|
330241
|
-
|
|
330466
|
+
logger82.debug("insertProjectSnapshot", { workspaceId, trigger });
|
|
330242
330467
|
} catch (e3) {
|
|
330243
|
-
|
|
330468
|
+
logger82.warn("insertProjectSnapshot failed:", e3);
|
|
330244
330469
|
}
|
|
330245
330470
|
}
|
|
330246
330471
|
async function recordPlanUpdateSnapshot(workspaceId, workspacePath) {
|
|
@@ -330300,7 +330525,7 @@ async function applyProjectSnapshotRevert(workspaceId, workspacePath, snapshotId
|
|
|
330300
330525
|
};
|
|
330301
330526
|
}
|
|
330302
330527
|
}
|
|
330303
|
-
var
|
|
330528
|
+
var import_electron_log83, PLAN_FILE, logger82, MAX_SNAPSHOTS_PER_WORKSPACE, touchedWorkspaces, planUpdateSnapshotDebounce, PLAN_UPDATE_SNAPSHOT_DEBOUNCE_MS;
|
|
330304
330529
|
var init_service2 = __esm({
|
|
330305
330530
|
"src/lib/project-memory/service.ts"() {
|
|
330306
330531
|
init_db2();
|
|
@@ -330308,9 +330533,9 @@ var init_service2 = __esm({
|
|
|
330308
330533
|
init_drizzle_orm();
|
|
330309
330534
|
init_paths();
|
|
330310
330535
|
init_git_utils();
|
|
330311
|
-
|
|
330536
|
+
import_electron_log83 = __toESM(require_src());
|
|
330312
330537
|
PLAN_FILE = ".atlarix/ATLARIX_PLAN.md";
|
|
330313
|
-
|
|
330538
|
+
logger82 = import_electron_log83.default.scope("project-memory");
|
|
330314
330539
|
MAX_SNAPSHOTS_PER_WORKSPACE = 100;
|
|
330315
330540
|
touchedWorkspaces = /* @__PURE__ */ new Set();
|
|
330316
330541
|
planUpdateSnapshotDebounce = /* @__PURE__ */ new Map();
|
|
@@ -330323,14 +330548,14 @@ import * as fs35 from "fs/promises";
|
|
|
330323
330548
|
import * as fsSync2 from "node:fs";
|
|
330324
330549
|
import * as path45 from "path";
|
|
330325
330550
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
330326
|
-
var
|
|
330551
|
+
var import_electron_log84, logger83, PermissionInterceptor;
|
|
330327
330552
|
var init_interceptor = __esm({
|
|
330328
330553
|
"src/ipc/handlers/permissions/interceptor.ts"() {
|
|
330329
330554
|
init_realpath_contain();
|
|
330330
330555
|
init_mutation_verify();
|
|
330331
330556
|
init_edit_stats2();
|
|
330332
330557
|
init_untrusted_data();
|
|
330333
|
-
|
|
330558
|
+
import_electron_log84 = __toESM(require_src());
|
|
330334
330559
|
init_electron_stub();
|
|
330335
330560
|
init_schema3();
|
|
330336
330561
|
init_runShellCommand();
|
|
@@ -330352,7 +330577,7 @@ var init_interceptor = __esm({
|
|
|
330352
330577
|
init_system_scope_commands();
|
|
330353
330578
|
init_git_author();
|
|
330354
330579
|
init_git_utils();
|
|
330355
|
-
|
|
330580
|
+
logger83 = import_electron_log84.default.scope("permission-interceptor");
|
|
330356
330581
|
PermissionInterceptor = class extends EventEmitter3 {
|
|
330357
330582
|
/** Map of operation ID to pending permission request */
|
|
330358
330583
|
pendingOperations = /* @__PURE__ */ new Map();
|
|
@@ -330472,7 +330697,7 @@ var init_interceptor = __esm({
|
|
|
330472
330697
|
}
|
|
330473
330698
|
} catch {
|
|
330474
330699
|
}
|
|
330475
|
-
|
|
330700
|
+
logger83.log(`[PermissionInterceptor] Initialized for workspace: ${workspacePath} (id: ${workspaceId}, turn: ${this.snapshotTurnId ?? "none"}, chat: ${this.activeChatId})`);
|
|
330476
330701
|
}
|
|
330477
330702
|
/**
|
|
330478
330703
|
* Approve everything for the remainder of this turn (see `turnBlanketApproved`).
|
|
@@ -330480,7 +330705,7 @@ var init_interceptor = __esm({
|
|
|
330480
330705
|
*/
|
|
330481
330706
|
approveRestOfTurn() {
|
|
330482
330707
|
this.turnBlanketApproved = true;
|
|
330483
|
-
|
|
330708
|
+
logger83.log(
|
|
330484
330709
|
`[approveRestOfTurn] chat ${this.activeChatId}: approvals suppressed for the rest of this turn`
|
|
330485
330710
|
);
|
|
330486
330711
|
}
|
|
@@ -330548,7 +330773,7 @@ var init_interceptor = __esm({
|
|
|
330548
330773
|
for (const win of BrowserWindow.getAllWindows()) {
|
|
330549
330774
|
win.webContents.send("operation-status", payload);
|
|
330550
330775
|
}
|
|
330551
|
-
|
|
330776
|
+
logger83.log(`[emitStatus] ${operationId} -> ${status}${error51 ? ` (${error51})` : ""}`);
|
|
330552
330777
|
}
|
|
330553
330778
|
/**
|
|
330554
330779
|
* Set workspace ID (if not known at construction time)
|
|
@@ -330563,7 +330788,7 @@ var init_interceptor = __esm({
|
|
|
330563
330788
|
setWorkspace(path51, id) {
|
|
330564
330789
|
this.workspacePath = path51;
|
|
330565
330790
|
if (id != null) this.workspaceId = id;
|
|
330566
|
-
|
|
330791
|
+
logger83.log(`[PermissionInterceptor] Workspace updated to: ${path51} (id: ${id})`);
|
|
330567
330792
|
}
|
|
330568
330793
|
// ════════════════════════════════════════════════════════════════════════════
|
|
330569
330794
|
// DETECTION & PARSING
|
|
@@ -330590,13 +330815,13 @@ var init_interceptor = __esm({
|
|
|
330590
330815
|
*/
|
|
330591
330816
|
parsePermissionRequest(result2) {
|
|
330592
330817
|
if (typeof result2 === "object" && result2 !== null && result2.__permission_required) {
|
|
330593
|
-
|
|
330818
|
+
logger83.log("[parsePermissionRequest] Parsed object format");
|
|
330594
330819
|
return result2;
|
|
330595
330820
|
}
|
|
330596
330821
|
if (typeof result2 === "string") {
|
|
330597
330822
|
const parsed = parsePermissionRequest(result2);
|
|
330598
330823
|
if (parsed) {
|
|
330599
|
-
|
|
330824
|
+
logger83.log("[parsePermissionRequest] Parsed JSON string format");
|
|
330600
330825
|
return parsed;
|
|
330601
330826
|
}
|
|
330602
330827
|
}
|
|
@@ -330623,7 +330848,7 @@ var init_interceptor = __esm({
|
|
|
330623
330848
|
createdAt: Date.now()
|
|
330624
330849
|
};
|
|
330625
330850
|
this.pendingOperations.set(operationId, operation);
|
|
330626
|
-
|
|
330851
|
+
logger83.log("[Permission Request Buffered]", {
|
|
330627
330852
|
id: operationId,
|
|
330628
330853
|
operation: request.operation,
|
|
330629
330854
|
path: request.preview?.path || "N/A",
|
|
@@ -330672,7 +330897,7 @@ var init_interceptor = __esm({
|
|
|
330672
330897
|
}
|
|
330673
330898
|
this.pendingApprovals.clear();
|
|
330674
330899
|
this.pendingOperations.clear();
|
|
330675
|
-
|
|
330900
|
+
logger83.log("[PermissionInterceptor] Cleared all pending operations");
|
|
330676
330901
|
}
|
|
330677
330902
|
// ════════════════════════════════════════════════════════════════════════════
|
|
330678
330903
|
// BLOCKING APPROVAL MECHANISM (NEW in v0.9.1)
|
|
@@ -330715,7 +330940,7 @@ var init_interceptor = __esm({
|
|
|
330715
330940
|
// No grace timeout — indefinite block.
|
|
330716
330941
|
createdAt: Date.now()
|
|
330717
330942
|
});
|
|
330718
|
-
|
|
330943
|
+
logger83.log(`[waitForApproval] Blocking (indefinite) for user response on ${operationId}`);
|
|
330719
330944
|
});
|
|
330720
330945
|
}
|
|
330721
330946
|
/**
|
|
@@ -330729,7 +330954,7 @@ var init_interceptor = __esm({
|
|
|
330729
330954
|
if (pending2.timeout) clearTimeout(pending2.timeout);
|
|
330730
330955
|
pending2.resolve(approved ? "approved" : "rejected");
|
|
330731
330956
|
this.pendingApprovals.delete(operationId);
|
|
330732
|
-
|
|
330957
|
+
logger83.log(`[resolveApproval] ${operationId} -> ${approved ? "APPROVED" : "REJECTED"}`);
|
|
330733
330958
|
}
|
|
330734
330959
|
}
|
|
330735
330960
|
// ════════════════════════════════════════════════════════════════════════════
|
|
@@ -330754,7 +330979,7 @@ var init_interceptor = __esm({
|
|
|
330754
330979
|
const preview = request.preview;
|
|
330755
330980
|
if (preview && typeof preview === "object") {
|
|
330756
330981
|
preview.content = options.overrideContent;
|
|
330757
|
-
|
|
330982
|
+
logger83.log(
|
|
330758
330983
|
`[executeOperation] per-hunk override applied for ${operationId} (${request.operation})`
|
|
330759
330984
|
);
|
|
330760
330985
|
}
|
|
@@ -330799,7 +331024,7 @@ var init_interceptor = __esm({
|
|
|
330799
331024
|
}
|
|
330800
331025
|
operation.status = "executed";
|
|
330801
331026
|
this.emitStatus(operationId, "completed");
|
|
330802
|
-
|
|
331027
|
+
logger83.log(`[executeOperation] Executed ${operationId}: ${request.operation}`);
|
|
330803
331028
|
if (this.snapshotTurnId && CONTENT_WRITE_OPS.has(request.operation)) {
|
|
330804
331029
|
recordMutationOutcome(this.snapshotTurnId, true);
|
|
330805
331030
|
}
|
|
@@ -330846,7 +331071,7 @@ var init_interceptor = __esm({
|
|
|
330846
331071
|
operation.status = "failed";
|
|
330847
331072
|
const errorMessage = error51 instanceof Error ? error51.message : String(error51);
|
|
330848
331073
|
this.emitStatus(operationId, "failed", void 0, void 0, errorMessage);
|
|
330849
|
-
|
|
331074
|
+
logger83.error(`[executeOperation] Failed ${operationId}:`, error51);
|
|
330850
331075
|
if (this.snapshotTurnId && CONTENT_WRITE_OPS.has(request.operation)) {
|
|
330851
331076
|
recordMutationOutcome(
|
|
330852
331077
|
this.snapshotTurnId,
|
|
@@ -330999,19 +331224,19 @@ var init_interceptor = __esm({
|
|
|
330999
331224
|
}
|
|
331000
331225
|
}
|
|
331001
331226
|
if (operationsToExecute.length === 0) {
|
|
331002
|
-
|
|
331227
|
+
logger83.log("[executeAllOperations] No pending operations to execute");
|
|
331003
331228
|
return results;
|
|
331004
331229
|
}
|
|
331005
|
-
|
|
331230
|
+
logger83.log(`[executeAllOperations] Processing ${operationsToExecute.length} pending operations sequentially`);
|
|
331006
331231
|
for (const [operationId] of operationsToExecute) {
|
|
331007
331232
|
const result2 = await this.executeOperation(operationId);
|
|
331008
331233
|
results.push(result2);
|
|
331009
|
-
|
|
331234
|
+
logger83.log(`[executeAllOperations] Completed ${result2.operationId}: ${result2.approved ? "success" : "failed"}`);
|
|
331010
331235
|
}
|
|
331011
331236
|
for (const [operationId] of operationsToExecute) {
|
|
331012
331237
|
this.pendingOperations.delete(operationId);
|
|
331013
331238
|
}
|
|
331014
|
-
|
|
331239
|
+
logger83.log(`[executeAllOperations] Completed all ${operationsToExecute.length} operations`);
|
|
331015
331240
|
return results;
|
|
331016
331241
|
}
|
|
331017
331242
|
/**
|
|
@@ -331029,7 +331254,7 @@ var init_interceptor = __esm({
|
|
|
331029
331254
|
}
|
|
331030
331255
|
this.resolveApproval(operationId, false);
|
|
331031
331256
|
operation.status = "rejected";
|
|
331032
|
-
|
|
331257
|
+
logger83.log(`[rejectOperation] Rejected ${operationId}: ${operation.request.operation}`);
|
|
331033
331258
|
return {
|
|
331034
331259
|
operationId,
|
|
331035
331260
|
approved: false
|
|
@@ -331191,7 +331416,7 @@ var init_interceptor = __esm({
|
|
|
331191
331416
|
if (p2) roots.push(path45.resolve(p2));
|
|
331192
331417
|
}
|
|
331193
331418
|
} catch (e3) {
|
|
331194
|
-
|
|
331419
|
+
logger83.warn(
|
|
331195
331420
|
`[writable-roots] could not read granted folders: ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
331196
331421
|
);
|
|
331197
331422
|
}
|
|
@@ -331233,7 +331458,7 @@ var init_interceptor = __esm({
|
|
|
331233
331458
|
grantedRoots: this.writableRoots()
|
|
331234
331459
|
});
|
|
331235
331460
|
} catch (e3) {
|
|
331236
|
-
|
|
331461
|
+
logger83.warn("[maybeCaptureWorkspaceSnapshot] skipped:", e3);
|
|
331237
331462
|
}
|
|
331238
331463
|
}
|
|
331239
331464
|
/**
|
|
@@ -331255,7 +331480,7 @@ var init_interceptor = __esm({
|
|
|
331255
331480
|
if (preview.action === "delete") {
|
|
331256
331481
|
if (!preview.automationId) throw new Error("Automation id missing");
|
|
331257
331482
|
await svc.deleteAutomation(preview.automationId);
|
|
331258
|
-
|
|
331483
|
+
logger83.log(`[automation] deleted ${preview.automationId} (${preview.name})`);
|
|
331259
331484
|
return;
|
|
331260
331485
|
}
|
|
331261
331486
|
const { AutomationInputSchema: AutomationInputSchema2 } = await Promise.resolve().then(() => (init_types4(), types_exports));
|
|
@@ -331270,12 +331495,12 @@ var init_interceptor = __esm({
|
|
|
331270
331495
|
if (this.workspaceId == null) throw new Error("Workspace required");
|
|
331271
331496
|
const { id } = await svc.createAutomation(this.workspaceId, input);
|
|
331272
331497
|
preview.automationId = id;
|
|
331273
|
-
|
|
331498
|
+
logger83.log(`[automation] created ${id} (${input.name})`);
|
|
331274
331499
|
return;
|
|
331275
331500
|
}
|
|
331276
331501
|
if (!preview.automationId) throw new Error("Automation id missing");
|
|
331277
331502
|
await svc.updateAutomation(preview.automationId, input);
|
|
331278
|
-
|
|
331503
|
+
logger83.log(`[automation] updated ${preview.automationId} (${input.name})`);
|
|
331279
331504
|
}
|
|
331280
331505
|
async executeRevertProjectSnapshot(request) {
|
|
331281
331506
|
const preview = request.preview;
|
|
@@ -331291,7 +331516,7 @@ var init_interceptor = __esm({
|
|
|
331291
331516
|
if (!result2.success) {
|
|
331292
331517
|
throw new Error(result2.error || "Revert failed");
|
|
331293
331518
|
}
|
|
331294
|
-
|
|
331519
|
+
logger83.log(`[executeRevertProjectSnapshot] id=${preview.snapshotId}`);
|
|
331295
331520
|
}
|
|
331296
331521
|
async executeWriteFile(request) {
|
|
331297
331522
|
const preview = request.preview;
|
|
@@ -331305,7 +331530,7 @@ var init_interceptor = __esm({
|
|
|
331305
331530
|
await fs35.mkdir(path45.dirname(fullPath), { recursive: true });
|
|
331306
331531
|
const intended = preview.content || "";
|
|
331307
331532
|
await fs35.writeFile(fullPath, intended, "utf-8");
|
|
331308
|
-
|
|
331533
|
+
logger83.log(`Wrote file: ${fullPath}`);
|
|
331309
331534
|
try {
|
|
331310
331535
|
const onDisk = await fs35.readFile(fullPath, "utf-8");
|
|
331311
331536
|
preview.verified = onDisk === intended;
|
|
@@ -331332,7 +331557,7 @@ var init_interceptor = __esm({
|
|
|
331332
331557
|
await this.maybeCaptureWorkspaceSnapshot([this.toWorkspaceRelativePosix(preview.path)]);
|
|
331333
331558
|
const fullPath = this.resolvePathWithinWorkspace(preview.path);
|
|
331334
331559
|
await fs35.unlink(fullPath);
|
|
331335
|
-
|
|
331560
|
+
logger83.log(`Deleted file: ${fullPath}`);
|
|
331336
331561
|
}
|
|
331337
331562
|
async executeRenameFile(request) {
|
|
331338
331563
|
const preview = request.preview;
|
|
@@ -331344,7 +331569,7 @@ var init_interceptor = __esm({
|
|
|
331344
331569
|
const toFullPath = this.resolvePathWithinWorkspace(preview.toPath);
|
|
331345
331570
|
await fs35.mkdir(path45.dirname(toFullPath), { recursive: true });
|
|
331346
331571
|
await fs35.rename(fromFullPath, toFullPath);
|
|
331347
|
-
|
|
331572
|
+
logger83.log(`Renamed file: ${fromFullPath} \u2192 ${toFullPath}`);
|
|
331348
331573
|
}
|
|
331349
331574
|
/**
|
|
331350
331575
|
* Execute diagram update when user approves the AI's request.
|
|
@@ -331449,7 +331674,7 @@ var init_interceptor = __esm({
|
|
|
331449
331674
|
}
|
|
331450
331675
|
);
|
|
331451
331676
|
} catch (e3) {
|
|
331452
|
-
|
|
331677
|
+
logger83.warn("[terminal-buffer] append failed:", e3);
|
|
331453
331678
|
}
|
|
331454
331679
|
this.emit("terminal-output", payload);
|
|
331455
331680
|
}
|
|
@@ -331527,7 +331752,7 @@ ${result2.stdout ?? ""}`
|
|
|
331527
331752
|
try {
|
|
331528
331753
|
upsertSandboxWritablePath(this.workspaceId, denial.grantPath);
|
|
331529
331754
|
} catch (e3) {
|
|
331530
|
-
|
|
331755
|
+
logger83.warn(
|
|
331531
331756
|
`[sandbox-escalation] persist failed: ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
331532
331757
|
);
|
|
331533
331758
|
}
|
|
@@ -331580,12 +331805,12 @@ ${retried.stdout ?? ""}`
|
|
|
331580
331805
|
const workspaceCdStrip = /^cd\s+\/workspace(?:\/[^\s;&|]*)?\s*(?:&&|;)\s*/;
|
|
331581
331806
|
if (workspaceCdStrip.test(preview.command)) {
|
|
331582
331807
|
commandToRun = preview.command.replace(workspaceCdStrip, "").trim() || "true";
|
|
331583
|
-
|
|
331808
|
+
logger83.log(`[executeRunCommand] Stripped 'cd /workspace' prefix (shell already in workspace); running: ${commandToRun}`);
|
|
331584
331809
|
}
|
|
331585
331810
|
if (/\bgit\s+commit\b/.test(commandToRun) && !await hasConfiguredGitIdentity(workingDir)) {
|
|
331586
331811
|
const withAgentIdentity = injectAgentGitIdentity(commandToRun);
|
|
331587
331812
|
if (withAgentIdentity !== commandToRun) {
|
|
331588
|
-
|
|
331813
|
+
logger83.log(`[executeRunCommand] No git identity configured \u2014 injected agent identity into commit command`);
|
|
331589
331814
|
commandToRun = withAgentIdentity;
|
|
331590
331815
|
}
|
|
331591
331816
|
}
|
|
@@ -331594,7 +331819,7 @@ ${retried.stdout ?? ""}`
|
|
|
331594
331819
|
const explicitBackground = preview.background === true;
|
|
331595
331820
|
const wakeOn = preview.wake_on;
|
|
331596
331821
|
const allowStalled = preview.allow_stalled === true;
|
|
331597
|
-
|
|
331822
|
+
logger83.log(
|
|
331598
331823
|
`[executeRunCommand] Running: ${commandToRun} in ${workingDir}` + (explicitBackground ? " (background)" : ` (promote after ${PROMOTE_AFTER_MS}ms)`)
|
|
331599
331824
|
);
|
|
331600
331825
|
const scopeKey = resolveScopeKey(this.activeChatId, this.workspaceId);
|
|
@@ -331605,12 +331830,12 @@ ${retried.stdout ?? ""}`
|
|
|
331605
331830
|
background: explicitBackground
|
|
331606
331831
|
});
|
|
331607
331832
|
if (preview.isDangerous) {
|
|
331608
|
-
|
|
331833
|
+
logger83.warn(`[DANGEROUS-COMMAND-AUDIT] User approved dangerous command | command="${commandToRun}" | cwd="${workingDir}" | explanation="${preview.dangerExplanation ?? "N/A"}" | timestamp=${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
331609
331834
|
}
|
|
331610
331835
|
const sandboxOpts = this.buildRunCommandSandbox(preview);
|
|
331611
331836
|
if (preview.systemScopeInteractive === true) {
|
|
331612
331837
|
const sandboxState = sandboxOpts ? "SANDBOXED (writable roots widened for the approved path)" : "UNSANDBOXED";
|
|
331613
|
-
|
|
331838
|
+
logger83.warn(`[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()}`);
|
|
331614
331839
|
}
|
|
331615
331840
|
this.emitTerminalOutput({
|
|
331616
331841
|
operationId,
|
|
@@ -331701,7 +331926,7 @@ ${stderr}` : "");
|
|
|
331701
331926
|
});
|
|
331702
331927
|
if (retried) result2 = retried;
|
|
331703
331928
|
} catch (e3) {
|
|
331704
|
-
|
|
331929
|
+
logger83.warn(
|
|
331705
331930
|
`[sandbox-escalation] ${e3 instanceof Error ? e3.message : String(e3)}`
|
|
331706
331931
|
);
|
|
331707
331932
|
}
|
|
@@ -331732,9 +331957,9 @@ ${result2.stderr}` : ""),
|
|
|
331732
331957
|
}
|
|
331733
331958
|
this.commandOutputs.set(operationId, result2);
|
|
331734
331959
|
if (result2.success) {
|
|
331735
|
-
|
|
331960
|
+
logger83.log(`[executeRunCommand] Success: ${commandToRun} (${(duration3 / 1e3).toFixed(1)}s)`);
|
|
331736
331961
|
} else {
|
|
331737
|
-
|
|
331962
|
+
logger83.error(`[executeRunCommand] Failed: ${commandToRun} (exit ${result2.exitCode})`);
|
|
331738
331963
|
const errDetail = result2.stderr ? `
|
|
331739
331964
|
|
|
331740
331965
|
${result2.stderr.slice(0, 500)}` : result2.stdout ? `
|
|
@@ -331871,14 +332096,14 @@ async function runAgentTurn(profile, rt2) {
|
|
|
331871
332096
|
if (isForceTextFinishAbort(rt2.abortController.signal.reason)) {
|
|
331872
332097
|
forceTextFinish = true;
|
|
331873
332098
|
} else {
|
|
331874
|
-
|
|
332099
|
+
logger84.log(
|
|
331875
332100
|
`${L2} Stream aborted (${String(rt2.abortController.signal.reason ?? "unknown")}) \u2014 stopping turn loop`
|
|
331876
332101
|
);
|
|
331877
332102
|
throw abortReasonError(rt2.abortController.signal.reason);
|
|
331878
332103
|
}
|
|
331879
332104
|
}
|
|
331880
332105
|
if (!forceTextFinish && Date.now() - loopStartTime > STREAM_TOOL_LOOP_DURATION_CAP_MS) {
|
|
331881
|
-
|
|
332106
|
+
logger84.warn(`${L2} Hit duration limit (30 minutes) mode=${profile.mode}`);
|
|
331882
332107
|
rt2.safeSend("chat:activity", {
|
|
331883
332108
|
id: `duration-limit-${Date.now()}`,
|
|
331884
332109
|
type: "duration_limit_reached",
|
|
@@ -331897,7 +332122,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
331897
332122
|
maxIterations: 0,
|
|
331898
332123
|
totalToolsExecuted: totalToolExecutions
|
|
331899
332124
|
});
|
|
331900
|
-
|
|
332125
|
+
logger84.log(`${L2} Iteration ${agenticIteration + 1} (unbounded)`);
|
|
331901
332126
|
}
|
|
331902
332127
|
const promptSpec = await profile.buildRoundSystemPrompt();
|
|
331903
332128
|
const roundPrompt = typeof promptSpec === "string" ? { systemPromptOverride: promptSpec } : promptSpec;
|
|
@@ -331977,7 +332202,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
331977
332202
|
finalFinishReason = fr2;
|
|
331978
332203
|
if (resumeFromStall && resumeFromStall.length > 0) {
|
|
331979
332204
|
if (stallResumeAttempts >= MAX_STALL_RESUME_ATTEMPTS) {
|
|
331980
|
-
|
|
332205
|
+
logger84.warn(
|
|
331981
332206
|
`${L2} Stall-resume cap (${MAX_STALL_RESUME_ATTEMPTS}) reached \u2014 ending round`
|
|
331982
332207
|
);
|
|
331983
332208
|
finalRoundRespMsgs = resumeFromStall;
|
|
@@ -331985,7 +332210,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
331985
332210
|
break;
|
|
331986
332211
|
}
|
|
331987
332212
|
stallResumeAttempts++;
|
|
331988
|
-
|
|
332213
|
+
logger84.info(
|
|
331989
332214
|
`${L2} Stall-resume ${stallResumeAttempts}/${MAX_STALL_RESUME_ATTEMPTS}: continuing from ${resumeFromStall.length} completed step-message(s)`
|
|
331990
332215
|
);
|
|
331991
332216
|
buildIterMessages = [
|
|
@@ -332040,7 +332265,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332040
332265
|
throw err2;
|
|
332041
332266
|
}
|
|
332042
332267
|
if (forceTextFinish) {
|
|
332043
|
-
|
|
332268
|
+
logger84.info(`${L2} Force-finish round complete \u2014 ending turn`);
|
|
332044
332269
|
break;
|
|
332045
332270
|
}
|
|
332046
332271
|
const nativeIterMessages = [
|
|
@@ -332062,7 +332287,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332062
332287
|
stripThinkBlocks(iterationDeltaResponse)
|
|
332063
332288
|
);
|
|
332064
332289
|
if (textRep.kind === "loop_correct") {
|
|
332065
|
-
|
|
332290
|
+
logger84.info(
|
|
332066
332291
|
`${L2} Repeated status restatement detected \u2014 injecting correction (attempt ${textRep.attempt})`
|
|
332067
332292
|
);
|
|
332068
332293
|
agenticMessages.push({
|
|
@@ -332079,7 +332304,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332079
332304
|
continue;
|
|
332080
332305
|
}
|
|
332081
332306
|
if (textRep.kind === "loop_abort") {
|
|
332082
|
-
|
|
332307
|
+
logger84.info(`${L2} Repeated status restatement persisted \u2014 forcing finish round`);
|
|
332083
332308
|
forceTextFinish = true;
|
|
332084
332309
|
continue;
|
|
332085
332310
|
}
|
|
@@ -332088,21 +332313,21 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332088
332313
|
const hasTextToolCalls = textToolCalls !== null;
|
|
332089
332314
|
const currentOpCount = rt2.permissionInterceptor.getAllOperationsCount();
|
|
332090
332315
|
const executedOpCount = rt2.permissionInterceptor.getExecutedOperationsCount();
|
|
332091
|
-
|
|
332316
|
+
logger84.log(
|
|
332092
332317
|
`${L2} Operation counts: total=${currentOpCount}, executed=${executedOpCount}, tracked=${totalToolExecutions}`
|
|
332093
332318
|
);
|
|
332094
332319
|
const hadNativeToolExecution = currentOpCount > totalToolExecutions;
|
|
332095
332320
|
if (hasTextToolCalls) {
|
|
332096
|
-
|
|
332321
|
+
logger84.log(`${L2} Detected text-based tool calls, parsing and executing...`);
|
|
332097
332322
|
} else if (hadNativeToolExecution) {
|
|
332098
332323
|
const newOps = currentOpCount - totalToolExecutions;
|
|
332099
|
-
|
|
332324
|
+
logger84.log(
|
|
332100
332325
|
`${L2} Native tool calls detected (${newOps} new operations, ${currentOpCount} total)`
|
|
332101
332326
|
);
|
|
332102
332327
|
totalToolExecutions = currentOpCount;
|
|
332103
332328
|
}
|
|
332104
332329
|
if (streamDebugLogging) {
|
|
332105
|
-
|
|
332330
|
+
logger84.log(`${L2} Round summary`, {
|
|
332106
332331
|
iteration: agenticIteration + 1,
|
|
332107
332332
|
hasTextToolCalls,
|
|
332108
332333
|
hadNativeToolExecution,
|
|
@@ -332116,7 +332341,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332116
332341
|
}
|
|
332117
332342
|
if (pendingWorkBlocksEnd()) {
|
|
332118
332343
|
parked = true;
|
|
332119
|
-
|
|
332344
|
+
logger84.info(
|
|
332120
332345
|
`${L2} Model yielded (fr=${String(finalFinishReason)}) \u2192 PARKED \u2014 ${runningSubagentCount(rt2.chatId)} sub-agent(s) / background work outstanding`
|
|
332121
332346
|
);
|
|
332122
332347
|
break;
|
|
@@ -332136,13 +332361,13 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332136
332361
|
gateFeedback = await profile.planCompletionGate();
|
|
332137
332362
|
usePlanGate = gateFeedback != null;
|
|
332138
332363
|
} catch (planErr) {
|
|
332139
|
-
|
|
332364
|
+
logger84.warn(`${L2} plan-completion gate failed to run: ${String(planErr)}`);
|
|
332140
332365
|
}
|
|
332141
332366
|
}
|
|
332142
332367
|
const gateStreak = usePlanGate ? planNudgeStreak : agenticProseOnlyStreak;
|
|
332143
332368
|
const gateCap = usePlanGate ? PLAN_YIELD_MAX_NUDGES : PROSE_YIELD_MAX_NUDGES;
|
|
332144
332369
|
if (gateFeedback == null || gateStreak >= gateCap || usePlanGate && planNudgeTotal >= PLAN_YIELD_TOTAL_MAX) {
|
|
332145
|
-
|
|
332370
|
+
logger84.info(
|
|
332146
332371
|
`${L2} Model yielded (no tool calls) \u2014 ending turn at iteration ${agenticIteration + 1}`
|
|
332147
332372
|
);
|
|
332148
332373
|
break;
|
|
@@ -332164,7 +332389,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332164
332389
|
content: systemReminder(gateFeedback)
|
|
332165
332390
|
});
|
|
332166
332391
|
agenticIteration++;
|
|
332167
|
-
|
|
332392
|
+
logger84.log(
|
|
332168
332393
|
`${L2} ${usePlanGate ? "Plan not complete" : "Completion gate not satisfied"} \u2014 nudge ${gateStreak + 1} of ${gateCap} allowed; continuing`
|
|
332169
332394
|
);
|
|
332170
332395
|
continue;
|
|
@@ -332172,7 +332397,7 @@ async function runAgentTurn(profile, rt2) {
|
|
|
332172
332397
|
agenticProseOnlyStreak = 0;
|
|
332173
332398
|
planNudgeStreak = 0;
|
|
332174
332399
|
if (hasTextToolCalls && (textToolCalls?.length ?? 0) === 0) {
|
|
332175
|
-
|
|
332400
|
+
logger84.log(`${L2} No parseable tool calls found, ending loop`);
|
|
332176
332401
|
break;
|
|
332177
332402
|
}
|
|
332178
332403
|
let iterationResults = [];
|
|
@@ -332189,7 +332414,7 @@ ${r3.result}
|
|
|
332189
332414
|
</tool_result>`).join("\n\n");
|
|
332190
332415
|
if (roundHadNativeToolMessages && !hasTextToolCalls) {
|
|
332191
332416
|
foldNativeIntoTurn(nativeIterMessages);
|
|
332192
|
-
|
|
332417
|
+
logger84.log(
|
|
332193
332418
|
`${L2} Folded ${nativeIterMessages.length} native message(s) into history (no synthetic reflatten)`
|
|
332194
332419
|
);
|
|
332195
332420
|
} else {
|
|
@@ -332209,7 +332434,7 @@ Please continue with your task based on these results.`
|
|
|
332209
332434
|
)
|
|
332210
332435
|
});
|
|
332211
332436
|
} else if (hadNativeToolExecution) {
|
|
332212
|
-
|
|
332437
|
+
logger84.log(
|
|
332213
332438
|
`${L2} Skipping empty tool-results user message (native tools executed in-stream)`
|
|
332214
332439
|
);
|
|
332215
332440
|
}
|
|
@@ -332222,7 +332447,7 @@ Please continue with your task based on these results.`
|
|
|
332222
332447
|
content: systemReminder(runtimeNotice)
|
|
332223
332448
|
});
|
|
332224
332449
|
runtimeNoticeSent = true;
|
|
332225
|
-
|
|
332450
|
+
logger84.log(`${L2} Browser runtime notice delivered (non-blocking, once per turn)`);
|
|
332226
332451
|
}
|
|
332227
332452
|
}
|
|
332228
332453
|
{
|
|
@@ -332235,8 +332460,8 @@ Please continue with your task based on these results.`
|
|
|
332235
332460
|
chatId: rt2.chatId,
|
|
332236
332461
|
loopLabel: profile.compactionLabel,
|
|
332237
332462
|
emitActivity: rt2.emitCompactionActivity,
|
|
332238
|
-
onInfo: (msg) =>
|
|
332239
|
-
onWarn: (msg, err2) =>
|
|
332463
|
+
onInfo: (msg) => logger84.log(msg),
|
|
332464
|
+
onWarn: (msg, err2) => logger84.warn(msg, err2)
|
|
332240
332465
|
});
|
|
332241
332466
|
if (compaction.compacted) {
|
|
332242
332467
|
agenticMessages = compaction.messages;
|
|
@@ -332252,10 +332477,10 @@ Please continue with your task based on these results.`
|
|
|
332252
332477
|
mode: profile.escalationMode
|
|
332253
332478
|
});
|
|
332254
332479
|
} catch (escalationErr) {
|
|
332255
|
-
|
|
332480
|
+
logger84.warn(`${L2} tier escalation guard failed: ${String(escalationErr)}`);
|
|
332256
332481
|
}
|
|
332257
332482
|
if (hasPermissionRequest) {
|
|
332258
|
-
|
|
332483
|
+
logger84.log(`${L2} Had permission requests, continuing loop...`);
|
|
332259
332484
|
}
|
|
332260
332485
|
}
|
|
332261
332486
|
trackTaskCompleted({
|
|
@@ -332276,10 +332501,10 @@ Please continue with your task based on these results.`
|
|
|
332276
332501
|
forcedTextFinish: forceTextFinish
|
|
332277
332502
|
};
|
|
332278
332503
|
}
|
|
332279
|
-
var
|
|
332504
|
+
var import_electron_log85, logger84, DEFAULT_FORCE_FINISH_PROMPT;
|
|
332280
332505
|
var init_run_agent_turn = __esm({
|
|
332281
332506
|
"src/lib/agent/run-agent-turn.ts"() {
|
|
332282
|
-
|
|
332507
|
+
import_electron_log85 = __toESM(require_src());
|
|
332283
332508
|
init_continuation_handler();
|
|
332284
332509
|
init_system_reminder();
|
|
332285
332510
|
init_plan_ledger_refresh();
|
|
@@ -332295,7 +332520,7 @@ var init_run_agent_turn = __esm({
|
|
|
332295
332520
|
init_stream_stop_sentinels();
|
|
332296
332521
|
init_subagent_results();
|
|
332297
332522
|
init_background_commands();
|
|
332298
|
-
|
|
332523
|
+
logger84 = import_electron_log85.default.scope("run-agent-turn");
|
|
332299
332524
|
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.";
|
|
332300
332525
|
}
|
|
332301
332526
|
});
|
|
@@ -332334,7 +332559,7 @@ async function runAskBranch(ctx, deps) {
|
|
|
332334
332559
|
processResponseChunkUpdate: processResponseChunkUpdate2,
|
|
332335
332560
|
applyTierEscalation
|
|
332336
332561
|
} = deps;
|
|
332337
|
-
|
|
332562
|
+
logger85.log(
|
|
332338
332563
|
`Ask tier with workspace \u2014 read-only${effectiveWorkMode === "plan" ? " + Plan tools" : ""} (approval where required)`
|
|
332339
332564
|
);
|
|
332340
332565
|
const askPermissionInterceptor = new PermissionInterceptor(
|
|
@@ -332549,7 +332774,7 @@ async function runAskBranch(ctx, deps) {
|
|
|
332549
332774
|
);
|
|
332550
332775
|
if (outcome.success && outcome.tokensAfter > 0) {
|
|
332551
332776
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
332552
|
-
|
|
332777
|
+
logger85.info(
|
|
332553
332778
|
`[DIAG_146] compress(ask) chat=${req.chatId} ${outcome.tokensBefore}\u2192${outcome.tokensAfter} persisted=${outcome.summaryPersisted} \u2192 emit context-report dispatchedTokens=${outcome.tokensAfter}`
|
|
332554
332779
|
);
|
|
332555
332780
|
}
|
|
@@ -332718,13 +332943,13 @@ ${marker28}
|
|
|
332718
332943
|
operationId,
|
|
332719
332944
|
request: enrichPermissionRequestForUi(permRequest, effectiveAppId, appPath)
|
|
332720
332945
|
});
|
|
332721
|
-
|
|
332946
|
+
logger85.log(`[Ask Mode] Permission request buffered: ${operationId}`);
|
|
332722
332947
|
} else if (askPermissionInterceptor.shouldAlwaysAutoApprove(permRequest)) {
|
|
332723
|
-
|
|
332948
|
+
logger85.log(
|
|
332724
332949
|
`[Ask Mode] Auto-approved .atlarix internal write: ${operationId}`
|
|
332725
332950
|
);
|
|
332726
332951
|
} else {
|
|
332727
|
-
|
|
332952
|
+
logger85.log(`[Ask Mode] Auto-exec: ${operationId}`);
|
|
332728
332953
|
}
|
|
332729
332954
|
try {
|
|
332730
332955
|
let approved;
|
|
@@ -332734,7 +332959,7 @@ ${marker28}
|
|
|
332734
332959
|
if (!approved) {
|
|
332735
332960
|
const execResultRejected = askPermissionInterceptor.getExecutionResult(operationId);
|
|
332736
332961
|
if (execResultRejected.exitCode !== void 0) {
|
|
332737
|
-
|
|
332962
|
+
logger85.log(
|
|
332738
332963
|
`[Ask Mode] Auto-approved op failed: ${operationId} (exit ${execResultRejected.exitCode})`
|
|
332739
332964
|
);
|
|
332740
332965
|
return JSON.stringify({
|
|
@@ -332761,7 +332986,7 @@ ${marker28}
|
|
|
332761
332986
|
}
|
|
332762
332987
|
if (approved) {
|
|
332763
332988
|
const execResult = askPermissionInterceptor.getExecutionResult(operationId);
|
|
332764
|
-
|
|
332989
|
+
logger85.log(`[Ask Mode] Permission approved: ${operationId}`);
|
|
332765
332990
|
const preview = permRequest.preview;
|
|
332766
332991
|
if (preview.path) {
|
|
332767
332992
|
ctx.filesWrittenInThisExchange.push(preview.path);
|
|
@@ -332771,7 +332996,7 @@ ${marker28}
|
|
|
332771
332996
|
output
|
|
332772
332997
|
);
|
|
332773
332998
|
if (hasCompilationErrors) {
|
|
332774
|
-
|
|
332999
|
+
logger85.log(`[Ask Mode] Command output contains errors: ${operationId}`);
|
|
332775
333000
|
return JSON.stringify({
|
|
332776
333001
|
success: true,
|
|
332777
333002
|
hasErrors: true,
|
|
@@ -332797,7 +333022,7 @@ ${marker28}
|
|
|
332797
333022
|
} else {
|
|
332798
333023
|
const execResultRejected = askPermissionInterceptor.getExecutionResult(operationId);
|
|
332799
333024
|
if (execResultRejected.exitCode !== void 0) {
|
|
332800
|
-
|
|
333025
|
+
logger85.log(
|
|
332801
333026
|
`[Ask Mode] Command failed: ${operationId} (exit ${execResultRejected.exitCode})`
|
|
332802
333027
|
);
|
|
332803
333028
|
return JSON.stringify({
|
|
@@ -332809,7 +333034,7 @@ ${marker28}
|
|
|
332809
333034
|
path: permRequest.preview.path || permRequest.preview.command
|
|
332810
333035
|
});
|
|
332811
333036
|
} else {
|
|
332812
|
-
|
|
333037
|
+
logger85.log(`[Ask Mode] Permission denied: ${operationId}`);
|
|
332813
333038
|
return JSON.stringify({
|
|
332814
333039
|
success: false,
|
|
332815
333040
|
error: "Permission denied by user",
|
|
@@ -332819,7 +333044,7 @@ ${marker28}
|
|
|
332819
333044
|
}
|
|
332820
333045
|
}
|
|
332821
333046
|
} catch (error51) {
|
|
332822
|
-
|
|
333047
|
+
logger85.error(`[Ask Mode] Permission error: ${operationId}`, error51);
|
|
332823
333048
|
return JSON.stringify({
|
|
332824
333049
|
success: false,
|
|
332825
333050
|
error: `Permission request failed: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
@@ -332892,13 +333117,13 @@ ${marker28}
|
|
|
332892
333117
|
}
|
|
332893
333118
|
});
|
|
332894
333119
|
}
|
|
332895
|
-
|
|
333120
|
+
logger85.log(
|
|
332896
333121
|
`Ask tier: ${Object.keys(askTools).length} tools (read-only${effectiveWorkMode === "plan" ? " + Plan tools" : ""}; MCP via list_available_mcps + mcp_call)`
|
|
332897
333122
|
);
|
|
332898
333123
|
{
|
|
332899
333124
|
const trimmed = peripheralToolNames(askToolsToInclude, effectiveWorkMode);
|
|
332900
333125
|
const { full, bound } = revealSavings(askToolsToInclude, effectiveWorkMode);
|
|
332901
|
-
|
|
333126
|
+
logger85.log(
|
|
332902
333127
|
`[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(", ")}]` : "")
|
|
332903
333128
|
);
|
|
332904
333129
|
}
|
|
@@ -332989,10 +333214,10 @@ ${askParts.stableHeader}` : askParts.stableHeader;
|
|
|
332989
333214
|
}
|
|
332990
333215
|
askAgenticRepetition.setEnabled(false);
|
|
332991
333216
|
}
|
|
332992
|
-
var
|
|
333217
|
+
var import_electron_log86, logger85;
|
|
332993
333218
|
var init_ask_branch = __esm({
|
|
332994
333219
|
"src/ipc/handlers/chat_stream/turn-runner/ask-branch.ts"() {
|
|
332995
|
-
|
|
333220
|
+
import_electron_log86 = __toESM(require_src());
|
|
332996
333221
|
init_agent_runtime();
|
|
332997
333222
|
init_system_scope_commands();
|
|
332998
333223
|
init_register_delegation_tools();
|
|
@@ -333028,7 +333253,7 @@ var init_ask_branch = __esm({
|
|
|
333028
333253
|
init_resolve_toolset();
|
|
333029
333254
|
init_tool_reveal();
|
|
333030
333255
|
init_edit_stats2();
|
|
333031
|
-
|
|
333256
|
+
logger85 = import_electron_log86.default.scope("chat_stream_handlers");
|
|
333032
333257
|
}
|
|
333033
333258
|
});
|
|
333034
333259
|
|
|
@@ -333126,7 +333351,7 @@ function parseMiniMaxFormat(text3) {
|
|
|
333126
333351
|
args: args2,
|
|
333127
333352
|
rawMatch: match[0]
|
|
333128
333353
|
});
|
|
333129
|
-
|
|
333354
|
+
logger86.log(`[MiniMax] Parsed tool call: ${toolName}`, args2);
|
|
333130
333355
|
}
|
|
333131
333356
|
return results;
|
|
333132
333357
|
}
|
|
@@ -333183,7 +333408,7 @@ function parseLegacyAngleFunctionFormat(text3) {
|
|
|
333183
333408
|
args: args2,
|
|
333184
333409
|
rawMatch: match[0]
|
|
333185
333410
|
});
|
|
333186
|
-
|
|
333411
|
+
logger86.log(`[Legacy function=] Parsed tool call: ${toolName}`, args2);
|
|
333187
333412
|
}
|
|
333188
333413
|
return results;
|
|
333189
333414
|
}
|
|
@@ -333266,11 +333491,11 @@ function parseTextToolCalls(text3) {
|
|
|
333266
333491
|
function stripToolCallXML(text3) {
|
|
333267
333492
|
return text3.replace(/<minimax:tool_call>[\s\S]*?<\/minimax:tool_call>/gi, "").replace(/<tool_call\s*>\s*<function\s*=\s*[a-zA-Z0-9_]+\s*>[\s\S]*?<\/function\s*>\s*<\/tool_call\s*>/gi, "").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();
|
|
333268
333493
|
}
|
|
333269
|
-
var
|
|
333494
|
+
var import_electron_log87, logger86;
|
|
333270
333495
|
var init_text_tool_parser = __esm({
|
|
333271
333496
|
"src/ipc/utils/text_tool_parser.ts"() {
|
|
333272
|
-
|
|
333273
|
-
|
|
333497
|
+
import_electron_log87 = __toESM(require_src());
|
|
333498
|
+
logger86 = import_electron_log87.default.scope("text-tool-parser");
|
|
333274
333499
|
}
|
|
333275
333500
|
});
|
|
333276
333501
|
|
|
@@ -333308,7 +333533,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333308
333533
|
buildToolStreamOpts,
|
|
333309
333534
|
streamDebugLogging
|
|
333310
333535
|
} = deps;
|
|
333311
|
-
|
|
333536
|
+
logger87.log("Build mode with native tool calling + permission system");
|
|
333312
333537
|
const workspacePath = appPath;
|
|
333313
333538
|
let workspaceOverride = null;
|
|
333314
333539
|
const buildResolved = resolveToolsetForSession({
|
|
@@ -333365,7 +333590,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333365
333590
|
isPermissionBased: true
|
|
333366
333591
|
// Don't force-switch to terminal tab
|
|
333367
333592
|
});
|
|
333368
|
-
|
|
333593
|
+
logger87.log(`[Build Mode] Terminal output sent: ${payload.command} (${payload.status})`);
|
|
333369
333594
|
});
|
|
333370
333595
|
const recentCompletedBuildToolNames = [];
|
|
333371
333596
|
const agenticRepetition = createAgenticRepetitionState();
|
|
@@ -333428,7 +333653,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333428
333653
|
execute: async (args2, { toolCallId }) => {
|
|
333429
333654
|
const buildToolStartMs = Date.now();
|
|
333430
333655
|
if (streamDebugLogging) {
|
|
333431
|
-
|
|
333656
|
+
logger87.log(`[Build Tool] start`, {
|
|
333432
333657
|
toolName,
|
|
333433
333658
|
chatId: req.chatId,
|
|
333434
333659
|
argsKeys: args2 && typeof args2 === "object" ? Object.keys(args2) : []
|
|
@@ -333540,7 +333765,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333540
333765
|
);
|
|
333541
333766
|
if (outcome.success && outcome.tokensAfter > 0) {
|
|
333542
333767
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
333543
|
-
|
|
333768
|
+
logger87.info(
|
|
333544
333769
|
`[DIAG_146] compress(build) chat=${req.chatId} ${outcome.tokensBefore}\u2192${outcome.tokensAfter} persisted=${outcome.summaryPersisted} \u2192 emit context-report dispatchedTokens=${outcome.tokensAfter}`
|
|
333545
333770
|
);
|
|
333546
333771
|
}
|
|
@@ -333625,7 +333850,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333625
333850
|
const r3 = result2;
|
|
333626
333851
|
workspaceOverride = { path: r3.workspace_path, id: r3.workspace_id };
|
|
333627
333852
|
permissionInterceptor.setWorkspace(r3.workspace_path, r3.workspace_id);
|
|
333628
|
-
|
|
333853
|
+
logger87.log(
|
|
333629
333854
|
`[Build Mode] Switched to new workspace for this turn: ${r3.workspace_path} (id: ${r3.workspace_id})`
|
|
333630
333855
|
);
|
|
333631
333856
|
}
|
|
@@ -333750,7 +333975,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333750
333975
|
output
|
|
333751
333976
|
);
|
|
333752
333977
|
if (hasCompilationErrors) {
|
|
333753
|
-
|
|
333978
|
+
logger87.log(`[Build Mode] Command output contains errors: ${operationId}`);
|
|
333754
333979
|
return JSON.stringify({
|
|
333755
333980
|
success: true,
|
|
333756
333981
|
hasErrors: true,
|
|
@@ -333774,7 +333999,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333774
333999
|
};
|
|
333775
334000
|
if (skipPermissionWait) {
|
|
333776
334001
|
try {
|
|
333777
|
-
|
|
334002
|
+
logger87.log(`[Build Mode] Autonomous auto-exec: ${operationId}`);
|
|
333778
334003
|
const execMeta = await permissionInterceptor.executeOperation(operationId);
|
|
333779
334004
|
const execResult = permissionInterceptor.getExecutionResult(operationId);
|
|
333780
334005
|
appendAutonomousOp(
|
|
@@ -333788,7 +334013,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333788
334013
|
)
|
|
333789
334014
|
);
|
|
333790
334015
|
if (execMeta.approved) {
|
|
333791
|
-
|
|
334016
|
+
logger87.log(`[Build Mode] Autonomous permission executed: ${operationId}`);
|
|
333792
334017
|
emitAutoApprovedWritePreview(
|
|
333793
334018
|
event.sender,
|
|
333794
334019
|
req.chatId,
|
|
@@ -333798,7 +334023,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333798
334023
|
return recordActivityResult(jsonAfterSuccessfulExec(execResult));
|
|
333799
334024
|
}
|
|
333800
334025
|
if (execResult.exitCode !== void 0) {
|
|
333801
|
-
|
|
334026
|
+
logger87.log(
|
|
333802
334027
|
`[Build Mode] Autonomous exec command failed: ${operationId} (exit ${execResult.exitCode})`
|
|
333803
334028
|
);
|
|
333804
334029
|
activityStatus = "error";
|
|
@@ -333819,7 +334044,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333819
334044
|
path: permRequest.preview.path
|
|
333820
334045
|
}));
|
|
333821
334046
|
} catch (error51) {
|
|
333822
|
-
|
|
334047
|
+
logger87.error(`[Build Mode] Autonomous permission error: ${operationId}`, error51);
|
|
333823
334048
|
activityStatus = "error";
|
|
333824
334049
|
return recordActivityResult(JSON.stringify({
|
|
333825
334050
|
success: false,
|
|
@@ -333832,7 +334057,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333832
334057
|
const __enriched = enrichPermissionRequestForUi(permRequest, effectiveAppId, workspacePath);
|
|
333833
334058
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
333834
334059
|
const prev = permRequest.preview;
|
|
333835
|
-
|
|
334060
|
+
logger87.info(
|
|
333836
334061
|
`[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)`
|
|
333837
334062
|
);
|
|
333838
334063
|
}
|
|
@@ -333841,10 +334066,10 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333841
334066
|
operationId,
|
|
333842
334067
|
request: __enriched
|
|
333843
334068
|
});
|
|
333844
|
-
|
|
334069
|
+
logger87.log(`[Build Mode] Permission request buffered: ${operationId}`);
|
|
333845
334070
|
try {
|
|
333846
334071
|
if (streamDebugLogging) {
|
|
333847
|
-
|
|
334072
|
+
logger87.log(`[Build Tool] waitForApproval start`, {
|
|
333848
334073
|
operationId,
|
|
333849
334074
|
operation: permRequest.operation,
|
|
333850
334075
|
chatId: req.chatId
|
|
@@ -333856,7 +334081,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333856
334081
|
);
|
|
333857
334082
|
const approved = outcome === "approved";
|
|
333858
334083
|
if (streamDebugLogging) {
|
|
333859
|
-
|
|
334084
|
+
logger87.log(`[Build Tool] waitForApproval end`, {
|
|
333860
334085
|
operationId,
|
|
333861
334086
|
approved,
|
|
333862
334087
|
chatId: req.chatId
|
|
@@ -333864,12 +334089,12 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333864
334089
|
}
|
|
333865
334090
|
if (approved) {
|
|
333866
334091
|
const execResult = permissionInterceptor.getExecutionResult(operationId);
|
|
333867
|
-
|
|
334092
|
+
logger87.log(`[Build Mode] Permission approved: ${operationId}`);
|
|
333868
334093
|
return recordActivityResult(jsonAfterSuccessfulExec(execResult));
|
|
333869
334094
|
} else {
|
|
333870
334095
|
const execResult = permissionInterceptor.getExecutionResult(operationId);
|
|
333871
334096
|
if (execResult.exitCode !== void 0) {
|
|
333872
|
-
|
|
334097
|
+
logger87.log(`[Build Mode] Command failed: ${operationId} (exit ${execResult.exitCode})`);
|
|
333873
334098
|
activityStatus = "error";
|
|
333874
334099
|
return recordActivityResult(JSON.stringify({
|
|
333875
334100
|
success: false,
|
|
@@ -333881,7 +334106,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333881
334106
|
path: permRequest.preview.path || permRequest.preview.command
|
|
333882
334107
|
}));
|
|
333883
334108
|
} else {
|
|
333884
|
-
|
|
334109
|
+
logger87.log(`[Build Mode] Permission denied: ${operationId}`);
|
|
333885
334110
|
activityStatus = "error";
|
|
333886
334111
|
return recordActivityResult(JSON.stringify({
|
|
333887
334112
|
success: false,
|
|
@@ -333893,7 +334118,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333893
334118
|
}
|
|
333894
334119
|
} catch (error51) {
|
|
333895
334120
|
if (abortController.signal.aborted) throw error51;
|
|
333896
|
-
|
|
334121
|
+
logger87.error(`[Build Mode] Permission error: ${operationId}`, error51);
|
|
333897
334122
|
activityStatus = "error";
|
|
333898
334123
|
return recordActivityResult(JSON.stringify({
|
|
333899
334124
|
success: false,
|
|
@@ -333928,7 +334153,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333928
334153
|
);
|
|
333929
334154
|
const resultText = toolResultTextForExpand(toolResultForActivity);
|
|
333930
334155
|
if (streamDebugLogging) {
|
|
333931
|
-
|
|
334156
|
+
logger87.log(`[Build Tool] end`, {
|
|
333932
334157
|
toolName,
|
|
333933
334158
|
chatId: req.chatId,
|
|
333934
334159
|
ms: Date.now() - buildToolStartMs,
|
|
@@ -333981,11 +334206,11 @@ async function runBuildBranch(ctx, deps) {
|
|
|
333981
334206
|
}
|
|
333982
334207
|
});
|
|
333983
334208
|
}
|
|
333984
|
-
|
|
334209
|
+
logger87.log(`Build mode: ${Object.keys(tools).length} tools available`);
|
|
333985
334210
|
{
|
|
333986
334211
|
const trimmed = peripheralToolNames(buildToolsToInclude, effectiveWorkMode);
|
|
333987
334212
|
const { full, bound } = revealSavings(buildToolsToInclude, effectiveWorkMode);
|
|
333988
|
-
|
|
334213
|
+
logger87.log(
|
|
333989
334214
|
`[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(", ")}]` : "")
|
|
333990
334215
|
);
|
|
333991
334216
|
}
|
|
@@ -334098,7 +334323,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
334098
334323
|
})
|
|
334099
334324
|
) : null;
|
|
334100
334325
|
if (allReadOnly) {
|
|
334101
|
-
|
|
334326
|
+
logger87.log(`[Agentic Loop] Executed ${textToolCalls.length} read-only tools in parallel`);
|
|
334102
334327
|
}
|
|
334103
334328
|
for (let i4 = 0; i4 < textToolCalls.length; i4++) {
|
|
334104
334329
|
const toolCall = textToolCalls[i4];
|
|
@@ -334318,7 +334543,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
334318
334543
|
operationId,
|
|
334319
334544
|
request: enrichPermissionRequestForUi(permRequest, effectiveAppId, workspacePath)
|
|
334320
334545
|
});
|
|
334321
|
-
|
|
334546
|
+
logger87.log(`[Agentic Loop] Permission request buffered: ${operationId}`);
|
|
334322
334547
|
hasPermissionRequest = true;
|
|
334323
334548
|
try {
|
|
334324
334549
|
const outcome = await permissionInterceptor.waitForApproval(
|
|
@@ -334375,10 +334600,10 @@ async function runBuildBranch(ctx, deps) {
|
|
|
334375
334600
|
} else {
|
|
334376
334601
|
const resultStr = typeof toolResult === "string" ? toolResult : JSON.stringify(toolResult);
|
|
334377
334602
|
iterationResults.push({ tool: toolCall.toolName, result: resultStr });
|
|
334378
|
-
|
|
334603
|
+
logger87.log(`[Agentic Loop] Tool executed: ${toolCall.toolName} \u2713`);
|
|
334379
334604
|
}
|
|
334380
334605
|
} catch (toolError) {
|
|
334381
|
-
|
|
334606
|
+
logger87.error(`[Agentic Loop] Tool error: ${toolCall.toolName}`, toolError);
|
|
334382
334607
|
iterationResults.push({
|
|
334383
334608
|
tool: toolCall.toolName,
|
|
334384
334609
|
result: `Error: ${toolError instanceof Error ? toolError.message : String(toolError)}`
|
|
@@ -334460,7 +334685,7 @@ async function runBuildBranch(ctx, deps) {
|
|
|
334460
334685
|
ctx.turnForcedTextFinish = turnResult.forcedTextFinish;
|
|
334461
334686
|
}
|
|
334462
334687
|
ctx.fullResponse = stripToolCallXML2(ctx.fullResponse);
|
|
334463
|
-
|
|
334688
|
+
logger87.info(`[Agentic Loop] Completed:`, {
|
|
334464
334689
|
chatId: req.chatId,
|
|
334465
334690
|
iterations: agenticIteration,
|
|
334466
334691
|
toolsExecuted: totalToolExecutions,
|
|
@@ -334495,10 +334720,10 @@ ${stopNote}`;
|
|
|
334495
334720
|
{ force: true }
|
|
334496
334721
|
);
|
|
334497
334722
|
}
|
|
334498
|
-
|
|
334723
|
+
logger87.log(`Persisted partial response to ephemeral chat ${chatId} after abort`);
|
|
334499
334724
|
partialResponses.delete(req.chatId);
|
|
334500
334725
|
} catch (error51) {
|
|
334501
|
-
|
|
334726
|
+
logger87.error(
|
|
334502
334727
|
`Error saving partial response for chat ${chatId}:`,
|
|
334503
334728
|
error51
|
|
334504
334729
|
);
|
|
@@ -334507,7 +334732,7 @@ ${stopNote}`;
|
|
|
334507
334732
|
return { earlyReturn: true, value: req.chatId };
|
|
334508
334733
|
}
|
|
334509
334734
|
if (abortController.signal.aborted && ledgerCompleteStop) {
|
|
334510
|
-
|
|
334735
|
+
logger87.log(
|
|
334511
334736
|
`[Agentic Loop] Stream stopped after task ledger complete (chat ${req.chatId})`
|
|
334512
334737
|
);
|
|
334513
334738
|
captureStreamAbortLedgerCompleteIfNeeded();
|
|
@@ -334518,7 +334743,7 @@ ${stopNote}`;
|
|
|
334518
334743
|
agenticRepetition.setEnabled(false);
|
|
334519
334744
|
}
|
|
334520
334745
|
}
|
|
334521
|
-
var
|
|
334746
|
+
var import_electron_log88, logger87;
|
|
334522
334747
|
var init_build_branch = __esm({
|
|
334523
334748
|
"src/ipc/handlers/chat_stream/turn-runner/build-branch.ts"() {
|
|
334524
334749
|
init_file_read_log();
|
|
@@ -334564,9 +334789,9 @@ var init_build_branch = __esm({
|
|
|
334564
334789
|
init_resolve_toolset();
|
|
334565
334790
|
init_tool_reveal();
|
|
334566
334791
|
init_dist21();
|
|
334567
|
-
|
|
334792
|
+
import_electron_log88 = __toESM(require_src());
|
|
334568
334793
|
init_edit_stats2();
|
|
334569
|
-
|
|
334794
|
+
logger87 = import_electron_log88.default.scope("chat_stream_handlers");
|
|
334570
334795
|
}
|
|
334571
334796
|
});
|
|
334572
334797
|
|
|
@@ -334574,14 +334799,14 @@ var init_build_branch = __esm({
|
|
|
334574
334799
|
function trackPendingWork(promise3, label) {
|
|
334575
334800
|
pending.add(promise3);
|
|
334576
334801
|
promise3.catch(
|
|
334577
|
-
(e3) =>
|
|
334802
|
+
(e3) => logger88.warn(`[${label}] background work failed: ${String(e3)}`)
|
|
334578
334803
|
).finally(() => pending.delete(promise3));
|
|
334579
334804
|
}
|
|
334580
|
-
var
|
|
334805
|
+
var import_electron_log89, logger88, pending;
|
|
334581
334806
|
var init_pending_work = __esm({
|
|
334582
334807
|
"src/lib/pending-work.ts"() {
|
|
334583
|
-
|
|
334584
|
-
|
|
334808
|
+
import_electron_log89 = __toESM(require_src());
|
|
334809
|
+
logger88 = import_electron_log89.default.scope("pending-work");
|
|
334585
334810
|
pending = /* @__PURE__ */ new Set();
|
|
334586
334811
|
}
|
|
334587
334812
|
});
|
|
@@ -334686,12 +334911,12 @@ async function finalizeTurn(ctx, deps) {
|
|
|
334686
334911
|
nativeForPersist = boundNativeHistoryForPersist(nativeForPersist, {
|
|
334687
334912
|
budgetTokens: envelopeBudget
|
|
334688
334913
|
});
|
|
334689
|
-
|
|
334914
|
+
logger89.info(
|
|
334690
334915
|
`[stream:${req.chatId}] turn envelope bounded for persist: ~${before2} \u2192 ~${estimateModelMessagesTokens(nativeForPersist)} est. tokens (budget ${envelopeBudget})`
|
|
334691
334916
|
);
|
|
334692
334917
|
}
|
|
334693
334918
|
} catch (e3) {
|
|
334694
|
-
|
|
334919
|
+
logger89.warn(`[stream:${req.chatId}] envelope bounding skipped`, e3);
|
|
334695
334920
|
nativeForPersist = ctx.nativeTurnMessages;
|
|
334696
334921
|
}
|
|
334697
334922
|
}
|
|
@@ -334786,11 +335011,11 @@ async function finalizeTurn(ctx, deps) {
|
|
|
334786
335011
|
planStatus: updated.planStatus,
|
|
334787
335012
|
title: updated.title
|
|
334788
335013
|
});
|
|
334789
|
-
|
|
335014
|
+
logger89.info(`[plan-artifact] safety net marked plan ${buildingPlan.id} built`);
|
|
334790
335015
|
}
|
|
334791
335016
|
}
|
|
334792
335017
|
} catch (planEndErr) {
|
|
334793
|
-
|
|
335018
|
+
logger89.warn("[plan-artifact] build-complete status update failed:", planEndErr);
|
|
334794
335019
|
}
|
|
334795
335020
|
}
|
|
334796
335021
|
if (isBuildModeTurn && !abortController.signal.aborted) {
|
|
@@ -334815,7 +335040,7 @@ async function finalizeTurn(ctx, deps) {
|
|
|
334815
335040
|
const auxBySource = summarizeAuxBySource(auxUsage);
|
|
334816
335041
|
if (auxUsage) {
|
|
334817
335042
|
const est = auxUsage.totalEstimatedTokens;
|
|
334818
|
-
|
|
335043
|
+
logger89.log(
|
|
334819
335044
|
`[usage] auxiliary LLM tokens this turn: ${auxUsage.totalTokens}` + (est > 0 ? ` (+~${est} estimated)` : "") + ` across ${auxUsage.calls} call(s) \u2014 ${Object.entries(auxUsage.byLabel).map(
|
|
334820
335045
|
([k2, v2]) => `${k2}=${v2.tokens}${v2.estimatedTokens > 0 ? `+~${v2.estimatedTokens}est` : ""}(${v2.calls} call${v2.calls === 1 ? "" : "s"})`
|
|
334821
335046
|
).join(", ")}`
|
|
@@ -334894,7 +335119,7 @@ async function finalizeTurn(ctx, deps) {
|
|
|
334894
335119
|
async function handleTurnError(error51, ctx, deps) {
|
|
334895
335120
|
const { overflowRetried, req, event, abortController, streamId } = deps;
|
|
334896
335121
|
if (abortController.signal.aborted && abortReasonSentinel(abortController.signal.reason) === ASK_USER_STREAM_STOP) {
|
|
334897
|
-
|
|
335122
|
+
logger89.log(
|
|
334898
335123
|
`[ask_user] Stream ended at question (benign: ${error51 instanceof Error ? error51.name : String(error51)})`
|
|
334899
335124
|
);
|
|
334900
335125
|
try {
|
|
@@ -334902,7 +335127,8 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
334902
335127
|
const chat = getStreamTransport2(req.chatId);
|
|
334903
335128
|
const pendingArtifact = pendingAskUserArtifactByChatId.get(req.chatId);
|
|
334904
335129
|
if (chat) {
|
|
334905
|
-
const
|
|
335130
|
+
const pid = Number(streamTurnIdByChatId.get(req.chatId));
|
|
335131
|
+
const last2 = (Number.isFinite(pid) ? chat.messages.find((m3) => m3.id === pid) : void 0) ?? chat.messages[chat.messages.length - 1];
|
|
334906
335132
|
if (last2?.role === "assistant") {
|
|
334907
335133
|
let content = stripThinkBlocks(
|
|
334908
335134
|
partialResponses.get(req.chatId) ?? last2.content ?? ""
|
|
@@ -334920,7 +335146,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
334920
335146
|
});
|
|
334921
335147
|
}
|
|
334922
335148
|
} catch (finalizeErr) {
|
|
334923
|
-
|
|
335149
|
+
logger89.warn("[ask_user] Question-turn finalize failed:", finalizeErr);
|
|
334924
335150
|
}
|
|
334925
335151
|
partialResponses.delete(req.chatId);
|
|
334926
335152
|
safeSend(event.sender, "chat:response:end", {
|
|
@@ -334934,7 +335160,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
334934
335160
|
FileUploadsState.getInstance().clear(req.chatId);
|
|
334935
335161
|
return;
|
|
334936
335162
|
}
|
|
334937
|
-
|
|
335163
|
+
logger89.error("Error calling LLM:", error51);
|
|
334938
335164
|
if (error51 instanceof NetworkStreamDisconnectedError) {
|
|
334939
335165
|
safeSend(event.sender, "chat:stream:disconnected", {
|
|
334940
335166
|
chatId: req.chatId,
|
|
@@ -335040,7 +335266,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
335040
335266
|
readSettings().selectedModel?.provider
|
|
335041
335267
|
).catch(() => false);
|
|
335042
335268
|
if (compacted) {
|
|
335043
|
-
|
|
335269
|
+
logger89.warn(
|
|
335044
335270
|
`[stream:${req.chatId}] Context overflow \u2014 compacted and retrying dispatch once`
|
|
335045
335271
|
);
|
|
335046
335272
|
safeSend(event.sender, "chat:activity", {
|
|
@@ -335090,7 +335316,7 @@ async function handleTurnError(error51, ctx, deps) {
|
|
|
335090
335316
|
ctx.streamTerminated = true;
|
|
335091
335317
|
FileUploadsState.getInstance().clear(req.chatId);
|
|
335092
335318
|
}
|
|
335093
|
-
var
|
|
335319
|
+
var import_electron_log90, MAX_ENVELOPE_WINDOW_FRACTION, MIN_ENVELOPE_BUDGET_TOKENS, logger89;
|
|
335094
335320
|
var init_finalize = __esm({
|
|
335095
335321
|
"src/ipc/handlers/chat_stream/turn-runner/finalize.ts"() {
|
|
335096
335322
|
init_autonomous_session_state();
|
|
@@ -335118,10 +335344,10 @@ var init_finalize = __esm({
|
|
|
335118
335344
|
init_turn_usage_aggregator();
|
|
335119
335345
|
init_settings();
|
|
335120
335346
|
init_texts();
|
|
335121
|
-
|
|
335347
|
+
import_electron_log90 = __toESM(require_src());
|
|
335122
335348
|
MAX_ENVELOPE_WINDOW_FRACTION = 0.5;
|
|
335123
335349
|
MIN_ENVELOPE_BUDGET_TOKENS = 8e3;
|
|
335124
|
-
|
|
335350
|
+
logger89 = import_electron_log90.default.scope("chat_stream_handlers");
|
|
335125
335351
|
}
|
|
335126
335352
|
});
|
|
335127
335353
|
|
|
@@ -335246,7 +335472,7 @@ async function loadPrioritySkillsForWorkspace(workspacePath, isWorkforce) {
|
|
|
335246
335472
|
};
|
|
335247
335473
|
skills.push(skill);
|
|
335248
335474
|
} catch (err2) {
|
|
335249
|
-
|
|
335475
|
+
logger90.warn(`[priority-skills] Failed to parse ${entry.name}:`, err2);
|
|
335250
335476
|
}
|
|
335251
335477
|
}
|
|
335252
335478
|
return skills.sort((a2, b3) => {
|
|
@@ -335261,11 +335487,11 @@ function filterSkillsForMode(skills, currentMode) {
|
|
|
335261
335487
|
(s3) => s3.modes.includes("*") || s3.modes.some((m3) => normalizeMode(m3) === wanted)
|
|
335262
335488
|
);
|
|
335263
335489
|
}
|
|
335264
|
-
var
|
|
335490
|
+
var import_electron_log91, logger90, SKILLS_DIR_REL, ALL_MODES;
|
|
335265
335491
|
var init_priority_skill_loader = __esm({
|
|
335266
335492
|
"src/lib/skills/priority-skill-loader.ts"() {
|
|
335267
|
-
|
|
335268
|
-
|
|
335493
|
+
import_electron_log91 = __toESM(require_src());
|
|
335494
|
+
logger90 = import_electron_log91.default.scope("priority-skill-loader");
|
|
335269
335495
|
SKILLS_DIR_REL = ".atlarix/skills";
|
|
335270
335496
|
ALL_MODES = ["ask", "build", "plan", "debug", "review"];
|
|
335271
335497
|
}
|
|
@@ -335345,18 +335571,18 @@ async function buildSkillIndex(workspacePath, currentMode) {
|
|
|
335345
335571
|
});
|
|
335346
335572
|
}
|
|
335347
335573
|
} catch (err2) {
|
|
335348
|
-
|
|
335574
|
+
logger91.warn("[skill-index] repo skills failed:", err2);
|
|
335349
335575
|
}
|
|
335350
335576
|
try {
|
|
335351
335577
|
entries2.push(...await loadInstalledSkillEntries(ws2));
|
|
335352
335578
|
} catch (err2) {
|
|
335353
|
-
|
|
335579
|
+
logger91.warn("[skill-index] installed skills failed:", err2);
|
|
335354
335580
|
}
|
|
335355
335581
|
}
|
|
335356
335582
|
try {
|
|
335357
335583
|
entries2.push(...await loadGuideEntries());
|
|
335358
335584
|
} catch (err2) {
|
|
335359
|
-
|
|
335585
|
+
logger91.warn("[skill-index] bundled guides failed:", err2);
|
|
335360
335586
|
}
|
|
335361
335587
|
return entries2;
|
|
335362
335588
|
}
|
|
@@ -335385,10 +335611,10 @@ function formatSkillIndexForPrompt(entries2) {
|
|
|
335385
335611
|
}
|
|
335386
335612
|
return lines.join("\n");
|
|
335387
335613
|
}
|
|
335388
|
-
var
|
|
335614
|
+
var import_electron_log92, logger91, BUNDLED_GUIDES;
|
|
335389
335615
|
var init_skill_index = __esm({
|
|
335390
335616
|
"src/lib/skills/skill-index.ts"() {
|
|
335391
|
-
|
|
335617
|
+
import_electron_log92 = __toESM(require_src());
|
|
335392
335618
|
init_first_sentence();
|
|
335393
335619
|
init_db2();
|
|
335394
335620
|
init_schema();
|
|
@@ -335396,7 +335622,7 @@ var init_skill_index = __esm({
|
|
|
335396
335622
|
init_paths();
|
|
335397
335623
|
init_skill_loader();
|
|
335398
335624
|
init_priority_skill_loader();
|
|
335399
|
-
|
|
335625
|
+
logger91 = import_electron_log92.default.scope("skill-index");
|
|
335400
335626
|
BUNDLED_GUIDES = [
|
|
335401
335627
|
{
|
|
335402
335628
|
file: "guides/memory.md",
|
|
@@ -335511,7 +335737,7 @@ async function loadModeSkillSection(p2) {
|
|
|
335511
335737
|
${modeSkillBody}`
|
|
335512
335738
|
};
|
|
335513
335739
|
} catch (skillErr) {
|
|
335514
|
-
|
|
335740
|
+
logger92.warn("[skills] Failed to load mode skill:", skillErr);
|
|
335515
335741
|
return null;
|
|
335516
335742
|
}
|
|
335517
335743
|
}
|
|
@@ -335524,12 +335750,12 @@ async function loadSkillsIndexSection(p2) {
|
|
|
335524
335750
|
);
|
|
335525
335751
|
const block = formatSkillIndexForPrompt(entries2);
|
|
335526
335752
|
if (!block.trim()) return null;
|
|
335527
|
-
|
|
335753
|
+
logger92.info(
|
|
335528
335754
|
`[skills-index] ${entries2.length} skill(s) indexed for mode "${effectiveWorkMode}" (${block.length} chars, bodies read on demand)`
|
|
335529
335755
|
);
|
|
335530
335756
|
return { name: "skillsIndex", priority: -2, content: block };
|
|
335531
335757
|
} catch (skillIndexErr) {
|
|
335532
|
-
|
|
335758
|
+
logger92.warn("[skills-index] Failed to build skill index:", skillIndexErr);
|
|
335533
335759
|
return null;
|
|
335534
335760
|
}
|
|
335535
335761
|
}
|
|
@@ -335571,7 +335797,7 @@ async function loadWorkspaceCapsSection(p2) {
|
|
|
335571
335797
|
content: capsBlock
|
|
335572
335798
|
};
|
|
335573
335799
|
} catch (capsErr) {
|
|
335574
|
-
|
|
335800
|
+
logger92.warn("[workspace-capabilities] Failed to load:", capsErr);
|
|
335575
335801
|
return null;
|
|
335576
335802
|
}
|
|
335577
335803
|
}
|
|
@@ -335619,7 +335845,7 @@ ${snippet}`
|
|
|
335619
335845
|
taskLedgerBlock
|
|
335620
335846
|
};
|
|
335621
335847
|
} catch (planCtxErr) {
|
|
335622
|
-
|
|
335848
|
+
logger92.warn("[plan-artifact] context inject failed:", planCtxErr);
|
|
335623
335849
|
return { section: null, taskLedgerBlock: null };
|
|
335624
335850
|
}
|
|
335625
335851
|
}
|
|
@@ -335641,12 +335867,12 @@ async function loadAtlarixMdSection(p2) {
|
|
|
335641
335867
|
`Read them with read_file before you change code or make a design decision, and follow them.`,
|
|
335642
335868
|
headings.length ? `Sections: ${headings.join(" \xB7 ")}` : ""
|
|
335643
335869
|
].filter(Boolean).join("\n");
|
|
335644
|
-
|
|
335870
|
+
logger92.info(
|
|
335645
335871
|
`Project instructions pointer (${instructions.source}, ${sizeKb}KB, ${headings.length} headings)`
|
|
335646
335872
|
);
|
|
335647
335873
|
return { name: "projectMemory", priority: 4, content };
|
|
335648
335874
|
} catch (memErr) {
|
|
335649
|
-
|
|
335875
|
+
logger92.warn("Failed to read project instructions:", memErr);
|
|
335650
335876
|
return null;
|
|
335651
335877
|
}
|
|
335652
335878
|
}
|
|
@@ -335682,20 +335908,20 @@ async function loadMemoryMdSection(p2) {
|
|
|
335682
335908
|
].join("\n");
|
|
335683
335909
|
return { name: "projectKnowledge", priority: 3.9, content };
|
|
335684
335910
|
} catch (memErr) {
|
|
335685
|
-
|
|
335911
|
+
logger92.warn("Failed to read agent memory index:", memErr);
|
|
335686
335912
|
return null;
|
|
335687
335913
|
}
|
|
335688
335914
|
}
|
|
335689
|
-
var
|
|
335915
|
+
var import_electron_log93, logger92;
|
|
335690
335916
|
var init_context_sections = __esm({
|
|
335691
335917
|
"src/ipc/handlers/chat_stream/context-sections.ts"() {
|
|
335692
|
-
|
|
335918
|
+
import_electron_log93 = __toESM(require_src());
|
|
335693
335919
|
init_skill_registry();
|
|
335694
335920
|
init_skill_loader();
|
|
335695
335921
|
init_skill_index();
|
|
335696
335922
|
init_project_memory2();
|
|
335697
335923
|
init_plan_checklist();
|
|
335698
|
-
|
|
335924
|
+
logger92 = import_electron_log93.default.scope("chat_stream_handlers");
|
|
335699
335925
|
}
|
|
335700
335926
|
});
|
|
335701
335927
|
|
|
@@ -335729,7 +335955,7 @@ function registerChatStreamHandlers() {
|
|
|
335729
335955
|
userStopped: isChatUserStopped(req.chatId)
|
|
335730
335956
|
});
|
|
335731
335957
|
if (wakeDrop) {
|
|
335732
|
-
|
|
335958
|
+
logger93.log(
|
|
335733
335959
|
`[wake] dropped system wake for chat ${req.chatId}: ${wakeDrop}`
|
|
335734
335960
|
);
|
|
335735
335961
|
return {
|
|
@@ -335737,7 +335963,7 @@ function registerChatStreamHandlers() {
|
|
|
335737
335963
|
dropped: wakeDrop
|
|
335738
335964
|
};
|
|
335739
335965
|
}
|
|
335740
|
-
if (req
|
|
335966
|
+
if (shouldClearUserStopLatch(req)) {
|
|
335741
335967
|
clearChatUserStopped(req.chatId);
|
|
335742
335968
|
}
|
|
335743
335969
|
const priorController = activeStreams.get(req.chatId);
|
|
@@ -335791,7 +336017,7 @@ function registerChatStreamHandlers() {
|
|
|
335791
336017
|
}
|
|
335792
336018
|
};
|
|
335793
336019
|
const handleStreamStall = () => {
|
|
335794
|
-
|
|
336020
|
+
logger93.warn(`[stream] Stall detected for chat ${req.chatId} \u2014 retrying`);
|
|
335795
336021
|
handleStreamActivityPulse();
|
|
335796
336022
|
};
|
|
335797
336023
|
const streamDebugLogging = isStreamDebugLoggingEnabled();
|
|
@@ -335894,7 +336120,7 @@ function registerChatStreamHandlers() {
|
|
|
335894
336120
|
const { isStreamTransportId: isStreamTransportId2, getStreamTransportAppId: getStreamTransportAppId2 } = await Promise.resolve().then(() => (init_stream_transport(), stream_transport_exports));
|
|
335895
336121
|
if (!isStreamTransportId2(req.chatId)) {
|
|
335896
336122
|
const legacyMsg = "Legacy database chats were removed. Open a workspace session from the sidebar.";
|
|
335897
|
-
|
|
336123
|
+
logger93.warn(`Chat ${req.chatId} rejected: legacy positive chat id`);
|
|
335898
336124
|
safeSend(event.sender, "chat:response:error", {
|
|
335899
336125
|
chatId: req.chatId,
|
|
335900
336126
|
streamId,
|
|
@@ -335912,10 +336138,10 @@ function registerChatStreamHandlers() {
|
|
|
335912
336138
|
if (isStreamTransportId2(req.chatId)) {
|
|
335913
336139
|
const ephemeralAppId = getStreamTransportAppId2(req.chatId);
|
|
335914
336140
|
if (ephemeralAppId) {
|
|
335915
|
-
|
|
336141
|
+
logger93.log(`Chat ${req.chatId} is ephemeral workspace chat for app: ${ephemeralAppId}`);
|
|
335916
336142
|
} else {
|
|
335917
336143
|
const noWorkspaceMsg = "Open a workspace folder to start chatting. Use Open folder on the welcome screen.";
|
|
335918
|
-
|
|
336144
|
+
logger93.warn(`Chat ${req.chatId} rejected: ephemeral chat without workspace`);
|
|
335919
336145
|
safeSend(event.sender, "chat:response:error", {
|
|
335920
336146
|
chatId: req.chatId,
|
|
335921
336147
|
streamId,
|
|
@@ -335953,7 +336179,7 @@ function registerChatStreamHandlers() {
|
|
|
335953
336179
|
lastUsedAt: /* @__PURE__ */ new Date(),
|
|
335954
336180
|
hasAnsweredQuestions: false
|
|
335955
336181
|
};
|
|
335956
|
-
|
|
336182
|
+
logger93.log(`Ephemeral workspace chat loaded for app: ${appData.name} (${appData.path})`);
|
|
335957
336183
|
}
|
|
335958
336184
|
const { resolveOrBindWorkspaceSessionForStream: resolveOrBindWorkspaceSessionForStream2 } = await Promise.resolve().then(() => (init_workspace_session_handlers(), workspace_session_handlers_exports));
|
|
335959
336185
|
req.workspaceSessionId = await preflight.time(
|
|
@@ -336082,7 +336308,7 @@ function registerChatStreamHandlers() {
|
|
|
336082
336308
|
---
|
|
336083
336309
|
`;
|
|
336084
336310
|
} catch (err2) {
|
|
336085
|
-
|
|
336311
|
+
logger93.error(`Error reading file content: ${err2}`);
|
|
336086
336312
|
}
|
|
336087
336313
|
}
|
|
336088
336314
|
}
|
|
@@ -336127,7 +336353,7 @@ function registerChatStreamHandlers() {
|
|
|
336127
336353
|
try {
|
|
336128
336354
|
return await persistOnce();
|
|
336129
336355
|
} catch (firstErr) {
|
|
336130
|
-
|
|
336356
|
+
logger93.warn(
|
|
336131
336357
|
"Persist of workspace session user message failed \u2014 retrying once:",
|
|
336132
336358
|
firstErr
|
|
336133
336359
|
);
|
|
@@ -336136,7 +336362,7 @@ function registerChatStreamHandlers() {
|
|
|
336136
336362
|
});
|
|
336137
336363
|
persistedUserRowId = row?.id;
|
|
336138
336364
|
} catch (err2) {
|
|
336139
|
-
|
|
336365
|
+
logger93.error(
|
|
336140
336366
|
"Failed to persist workspace session user message (after retry) \u2014 a resume of this turn will see attachment stubs without bodies:",
|
|
336141
336367
|
err2
|
|
336142
336368
|
);
|
|
@@ -336169,11 +336395,11 @@ function registerChatStreamHandlers() {
|
|
|
336169
336395
|
name: activeUserAgent.model.slice(slash + 1)
|
|
336170
336396
|
} : { provider: settings.selectedModel.provider, name: activeUserAgent.model };
|
|
336171
336397
|
}
|
|
336172
|
-
|
|
336398
|
+
logger93.log(
|
|
336173
336399
|
`[user-agent] active: ${activeUserAgent.name} (mode=${activeUserAgent.mode}${activeUserAgent.model ? `, model=${activeUserAgent.model}` : ""})`
|
|
336174
336400
|
);
|
|
336175
336401
|
} else {
|
|
336176
|
-
|
|
336402
|
+
logger93.warn(`[user-agent] "${req.agentOverride}" not found \u2014 ignored`);
|
|
336177
336403
|
}
|
|
336178
336404
|
}
|
|
336179
336405
|
const newUserMessageId = nextEphemeralMessageId();
|
|
@@ -336283,7 +336509,7 @@ function registerChatStreamHandlers() {
|
|
|
336283
336509
|
modelClient.builtinProviderId
|
|
336284
336510
|
);
|
|
336285
336511
|
const reasoningCatalogModelId = resolveReasoningCatalogModelId(effectiveModel);
|
|
336286
|
-
|
|
336512
|
+
logger93.log(
|
|
336287
336513
|
`[stream:${req.chatId}] model=${effectiveModel.provider}/${effectiveModel.name} reasoning=${enableNativeReasoning} wire=${modelClient.builtinProviderId ?? "?"} vendor=${reasoningCapabilityProvider ?? "?"}/${reasoningCatalogModelId} catalog=${catalogSaysReasons(
|
|
336288
336514
|
reasoningCapabilityProvider,
|
|
336289
336515
|
reasoningCatalogModelId
|
|
@@ -336294,7 +336520,7 @@ function registerChatStreamHandlers() {
|
|
|
336294
336520
|
}).kind}`
|
|
336295
336521
|
);
|
|
336296
336522
|
const budgetDetail = await contextWindowPromise;
|
|
336297
|
-
|
|
336523
|
+
logger93.log(
|
|
336298
336524
|
`[budget] model=${effectiveModel.provider}/${effectiveModel.name} contextWindow=${budgetDetail.contextWindow} source=${budgetDetail.source}`
|
|
336299
336525
|
);
|
|
336300
336526
|
const usedCompassThisStream = modelClient.builtinProviderId === "compass";
|
|
@@ -336312,7 +336538,7 @@ function registerChatStreamHandlers() {
|
|
|
336312
336538
|
let appPath = effectiveApp?.path ? resolveAppPath(effectiveApp.path) : "";
|
|
336313
336539
|
const effectiveAppId = effectiveApp?.id;
|
|
336314
336540
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
336315
|
-
|
|
336541
|
+
logger93.info(
|
|
336316
336542
|
`[DIAG_146] enforce-appId chat=${req.chatId} effectiveAppId=${effectiveAppId} path=${effectiveApp?.path ?? "<none>"}`
|
|
336317
336543
|
);
|
|
336318
336544
|
}
|
|
@@ -336321,11 +336547,11 @@ function registerChatStreamHandlers() {
|
|
|
336321
336547
|
void Promise.resolve().then(() => (init_skill_loader(), skill_loader_exports)).then((m3) => m3.clearSkillCache()).catch(() => {
|
|
336322
336548
|
});
|
|
336323
336549
|
}
|
|
336324
|
-
|
|
336550
|
+
logger93.log(
|
|
336325
336551
|
`Using workspace for chat ${req.chatId}: ${appPath || "(none)"} (appId: ${effectiveAppId ?? req.appId ?? "n/a"})`
|
|
336326
336552
|
);
|
|
336327
336553
|
if (hasWorkspace && appPath && !fs38.existsSync(appPath)) {
|
|
336328
|
-
|
|
336554
|
+
logger93.warn(`Workspace path does not exist on disk: ${appPath}`);
|
|
336329
336555
|
safeSend(event.sender, "chat:activity", {
|
|
336330
336556
|
id: `workspace-path-missing-${req.chatId}`,
|
|
336331
336557
|
type: "orchestrator_blocker",
|
|
@@ -336345,13 +336571,13 @@ function registerChatStreamHandlers() {
|
|
|
336345
336571
|
}) : "";
|
|
336346
336572
|
const otherAppsCodebaseInfo = mentionedContextBlock;
|
|
336347
336573
|
if (otherAppsCodebaseInfo) {
|
|
336348
|
-
|
|
336574
|
+
logger93.log(
|
|
336349
336575
|
`Injected @-mention context: ${contextMentions.files.length} file(s), ${contextMentions.dirs.length} folder(s)`
|
|
336350
336576
|
);
|
|
336351
336577
|
}
|
|
336352
336578
|
if (hasWorkspace) {
|
|
336353
|
-
|
|
336354
|
-
|
|
336579
|
+
logger93.log(`Extracted codebase information from ${appPath}`);
|
|
336580
|
+
logger93.log(
|
|
336355
336581
|
"codebaseInfo: length",
|
|
336356
336582
|
codebaseInfo.length,
|
|
336357
336583
|
"estimated tokens",
|
|
@@ -336378,18 +336604,18 @@ function registerChatStreamHandlers() {
|
|
|
336378
336604
|
const { sliceFromLastCompactionSummary: sliceFromLastCompactionSummary2 } = await Promise.resolve().then(() => (init_compaction(), compaction_exports));
|
|
336379
336605
|
const sliced = sliceFromLastCompactionSummary2(messageHistory);
|
|
336380
336606
|
if (process.env.ATLARIX_DIAG_146 === "1") {
|
|
336381
|
-
|
|
336607
|
+
logger93.info(
|
|
336382
336608
|
`[DIAG_146] dispatch-slice chat=${req.chatId} markerFound=${sliced.length !== messageHistory.length} fullLen=${messageHistory.length} slicedLen=${sliced.length}`
|
|
336383
336609
|
);
|
|
336384
336610
|
}
|
|
336385
336611
|
if (sliced.length !== messageHistory.length) {
|
|
336386
|
-
|
|
336612
|
+
logger93.log(
|
|
336387
336613
|
`[stream:${req.chatId}] Compaction summary found \u2014 model history ${messageHistory.length} \u2192 ${sliced.length} messages`
|
|
336388
336614
|
);
|
|
336389
336615
|
messageHistory = sliced;
|
|
336390
336616
|
}
|
|
336391
336617
|
}
|
|
336392
|
-
|
|
336618
|
+
logger93.log(
|
|
336393
336619
|
`[stream:${req.chatId}] Prepared message history (len=${messageHistory.length})`
|
|
336394
336620
|
);
|
|
336395
336621
|
let limitedMessageHistory = messageHistory;
|
|
@@ -336419,7 +336645,7 @@ function registerChatStreamHandlers() {
|
|
|
336419
336645
|
unattended: Boolean(req.automation)
|
|
336420
336646
|
}).total;
|
|
336421
336647
|
} catch (e3) {
|
|
336422
|
-
|
|
336648
|
+
logger93.warn(
|
|
336423
336649
|
`[budget] tool-surface measurement failed; budget decisions this turn use the system prompt alone: ${String(e3)}`
|
|
336424
336650
|
);
|
|
336425
336651
|
}
|
|
@@ -336593,7 +336819,7 @@ ${baseSystemPrompt}`;
|
|
|
336593
336819
|
effectiveModel,
|
|
336594
336820
|
contextWindowTokens
|
|
336595
336821
|
);
|
|
336596
|
-
|
|
336822
|
+
logger93.info(
|
|
336597
336823
|
`[budget] window=${contextWindowTokens} usable=${usableTokens} reserve=${contextWindowTokens - usableTokens}`
|
|
336598
336824
|
);
|
|
336599
336825
|
const applyTierEscalation = async (_args) => false;
|
|
@@ -336728,7 +336954,7 @@ ${baseSystemPrompt}`;
|
|
|
336728
336954
|
if (done || !ttftShouldLog || ttftStartRef.ms == null) return;
|
|
336729
336955
|
done = true;
|
|
336730
336956
|
const openRouterCompressionApplied = (modelClient.builtinProviderId === "openrouter" || modelClient.builtinProviderId === "compass") && (budgetTracker.isCritical() || budgetTracker.isOverLimit());
|
|
336731
|
-
|
|
336957
|
+
logger93.log(
|
|
336732
336958
|
`[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}`
|
|
336733
336959
|
);
|
|
336734
336960
|
};
|
|
@@ -336871,7 +337097,7 @@ ${baseSystemPrompt}`;
|
|
|
336871
337097
|
abortController
|
|
336872
337098
|
};
|
|
336873
337099
|
const processResponseChunkUpdate2 = (args2) => processResponseChunkUpdate(
|
|
336874
|
-
{ req, updatedChat, event, streamId },
|
|
337100
|
+
{ req, updatedChat, event, streamId, placeholderAssistantMessage },
|
|
336875
337101
|
args2
|
|
336876
337102
|
);
|
|
336877
337103
|
ctx.filesWrittenInThisExchange = [];
|
|
@@ -336970,13 +337196,13 @@ ${baseSystemPrompt}`;
|
|
|
336970
337196
|
async () => {
|
|
336971
337197
|
if (fs38.existsSync(filePath)) {
|
|
336972
337198
|
await unlink2(filePath);
|
|
336973
|
-
|
|
337199
|
+
logger93.log(`Deleted temporary file: ${filePath}`);
|
|
336974
337200
|
}
|
|
336975
337201
|
},
|
|
336976
337202
|
30 * 60 * 1e3
|
|
336977
337203
|
);
|
|
336978
337204
|
} catch (error51) {
|
|
336979
|
-
|
|
337205
|
+
logger93.error(`Error scheduling file deletion: ${error51}`);
|
|
336980
337206
|
}
|
|
336981
337207
|
}
|
|
336982
337208
|
}
|
|
@@ -337011,7 +337237,7 @@ ${baseSystemPrompt}`;
|
|
|
337011
337237
|
registerLifecycleHandlers(chatStreamHandler);
|
|
337012
337238
|
registerRevertHandlers();
|
|
337013
337239
|
}
|
|
337014
|
-
var
|
|
337240
|
+
var import_electron_log94, logger93, TEMP_DIR;
|
|
337015
337241
|
var init_chat_stream_handlers = __esm({
|
|
337016
337242
|
"src/ipc/handlers/chat_stream_handlers.ts"() {
|
|
337017
337243
|
init_electron_stub();
|
|
@@ -337033,7 +337259,7 @@ var init_chat_stream_handlers = __esm({
|
|
|
337033
337259
|
init_active_model_identity();
|
|
337034
337260
|
init_turn_usage_aggregator();
|
|
337035
337261
|
init_stream_stop_sentinels();
|
|
337036
|
-
|
|
337262
|
+
import_electron_log94 = __toESM(require_src());
|
|
337037
337263
|
init_safe_sender();
|
|
337038
337264
|
init_stream_transport();
|
|
337039
337265
|
init_stream_debug();
|
|
@@ -337079,7 +337305,7 @@ var init_chat_stream_handlers = __esm({
|
|
|
337079
337305
|
init_build_branch();
|
|
337080
337306
|
init_finalize();
|
|
337081
337307
|
init_context_sections();
|
|
337082
|
-
|
|
337308
|
+
logger93 = import_electron_log94.default.scope("chat_stream_handlers");
|
|
337083
337309
|
TEMP_DIR = path48.join(os11.tmpdir(), "atlarix-attachments");
|
|
337084
337310
|
if (!fs38.existsSync(TEMP_DIR)) {
|
|
337085
337311
|
fs38.mkdirSync(TEMP_DIR, { recursive: true });
|
|
@@ -337421,7 +337647,7 @@ if (!process.env.ATLARIX_MODELS_SNAPSHOT) {
|
|
|
337421
337647
|
const shipped = path50.join(here, "models-snapshot.json.gz");
|
|
337422
337648
|
if (fs40.existsSync(shipped)) process.env.ATLARIX_MODELS_SNAPSHOT = shipped;
|
|
337423
337649
|
}
|
|
337424
|
-
var VERSION15 = false ? "dev" : "14.
|
|
337650
|
+
var VERSION15 = false ? "dev" : "14.42.0";
|
|
337425
337651
|
if (process.argv[2] === "run") process.argv.splice(2, 1);
|
|
337426
337652
|
function arg(name29) {
|
|
337427
337653
|
const i4 = process.argv.indexOf(`--${name29}`);
|