@funnycode/myclaude 0.1.92 → 0.1.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/myclaude.js +281 -258
- package/dist/myclaude.mjs +281 -258
- package/package.json +1 -1
package/dist/myclaude.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// MACRO - build-time constants (injected by build.ts)
|
|
5
5
|
// MACRO injected by build script
|
|
6
6
|
globalThis.MACRO = {
|
|
7
|
-
VERSION: "0.1.
|
|
8
|
-
BUILD_TIME: "2026-07-
|
|
7
|
+
VERSION: "0.1.94",
|
|
8
|
+
BUILD_TIME: "2026-07-18T06:27:57.445Z",
|
|
9
9
|
PACKAGE_URL: "@funnycode/myclaude",
|
|
10
10
|
NATIVE_PACKAGE_URL: "@funnycode/myclaude",
|
|
11
11
|
VERSION_CHANGELOG: '',
|
|
@@ -117484,7 +117484,7 @@ var package_default;
|
|
|
117484
117484
|
var init_package = __esm(() => {
|
|
117485
117485
|
package_default = {
|
|
117486
117486
|
name: "@funnycode/myclaude",
|
|
117487
|
-
version: "0.1.
|
|
117487
|
+
version: "0.1.94",
|
|
117488
117488
|
private: false,
|
|
117489
117489
|
description: "An open-source AI coding assistant in your terminal - powered by Claude",
|
|
117490
117490
|
license: "MIT",
|
|
@@ -210146,6 +210146,214 @@ var init_postSamplingHooks = __esm(() => {
|
|
|
210146
210146
|
postSamplingHooks = [];
|
|
210147
210147
|
});
|
|
210148
210148
|
|
|
210149
|
+
// node_modules/async-mutex/index.mjs
|
|
210150
|
+
class Semaphore {
|
|
210151
|
+
constructor(_value, _cancelError = E_CANCELED) {
|
|
210152
|
+
this._value = _value;
|
|
210153
|
+
this._cancelError = _cancelError;
|
|
210154
|
+
this._queue = [];
|
|
210155
|
+
this._weightedWaiters = [];
|
|
210156
|
+
}
|
|
210157
|
+
acquire(weight = 1, priority = 0) {
|
|
210158
|
+
if (weight <= 0)
|
|
210159
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
210160
|
+
return new Promise((resolve25, reject2) => {
|
|
210161
|
+
const task = { resolve: resolve25, reject: reject2, weight, priority };
|
|
210162
|
+
const i3 = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
|
|
210163
|
+
if (i3 === -1 && weight <= this._value) {
|
|
210164
|
+
this._dispatchItem(task);
|
|
210165
|
+
} else {
|
|
210166
|
+
this._queue.splice(i3 + 1, 0, task);
|
|
210167
|
+
}
|
|
210168
|
+
});
|
|
210169
|
+
}
|
|
210170
|
+
runExclusive(callback_1) {
|
|
210171
|
+
return __awaiter$2(this, arguments, undefined, function* (callback, weight = 1, priority = 0) {
|
|
210172
|
+
const [value, release] = yield this.acquire(weight, priority);
|
|
210173
|
+
try {
|
|
210174
|
+
return yield callback(value);
|
|
210175
|
+
} finally {
|
|
210176
|
+
release();
|
|
210177
|
+
}
|
|
210178
|
+
});
|
|
210179
|
+
}
|
|
210180
|
+
waitForUnlock(weight = 1, priority = 0) {
|
|
210181
|
+
if (weight <= 0)
|
|
210182
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
210183
|
+
if (this._couldLockImmediately(weight, priority)) {
|
|
210184
|
+
return Promise.resolve();
|
|
210185
|
+
} else {
|
|
210186
|
+
return new Promise((resolve25) => {
|
|
210187
|
+
if (!this._weightedWaiters[weight - 1])
|
|
210188
|
+
this._weightedWaiters[weight - 1] = [];
|
|
210189
|
+
insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve25, priority });
|
|
210190
|
+
});
|
|
210191
|
+
}
|
|
210192
|
+
}
|
|
210193
|
+
isLocked() {
|
|
210194
|
+
return this._value <= 0;
|
|
210195
|
+
}
|
|
210196
|
+
getValue() {
|
|
210197
|
+
return this._value;
|
|
210198
|
+
}
|
|
210199
|
+
setValue(value) {
|
|
210200
|
+
this._value = value;
|
|
210201
|
+
this._dispatchQueue();
|
|
210202
|
+
}
|
|
210203
|
+
release(weight = 1) {
|
|
210204
|
+
if (weight <= 0)
|
|
210205
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
210206
|
+
this._value += weight;
|
|
210207
|
+
this._dispatchQueue();
|
|
210208
|
+
}
|
|
210209
|
+
cancel() {
|
|
210210
|
+
this._queue.forEach((entry) => entry.reject(this._cancelError));
|
|
210211
|
+
this._queue = [];
|
|
210212
|
+
}
|
|
210213
|
+
_dispatchQueue() {
|
|
210214
|
+
this._drainUnlockWaiters();
|
|
210215
|
+
while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
|
|
210216
|
+
this._dispatchItem(this._queue.shift());
|
|
210217
|
+
this._drainUnlockWaiters();
|
|
210218
|
+
}
|
|
210219
|
+
}
|
|
210220
|
+
_dispatchItem(item) {
|
|
210221
|
+
const previousValue = this._value;
|
|
210222
|
+
this._value -= item.weight;
|
|
210223
|
+
item.resolve([previousValue, this._newReleaser(item.weight)]);
|
|
210224
|
+
}
|
|
210225
|
+
_newReleaser(weight) {
|
|
210226
|
+
let called = false;
|
|
210227
|
+
return () => {
|
|
210228
|
+
if (called)
|
|
210229
|
+
return;
|
|
210230
|
+
called = true;
|
|
210231
|
+
this.release(weight);
|
|
210232
|
+
};
|
|
210233
|
+
}
|
|
210234
|
+
_drainUnlockWaiters() {
|
|
210235
|
+
if (this._queue.length === 0) {
|
|
210236
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
210237
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
210238
|
+
if (!waiters)
|
|
210239
|
+
continue;
|
|
210240
|
+
waiters.forEach((waiter) => waiter.resolve());
|
|
210241
|
+
this._weightedWaiters[weight - 1] = [];
|
|
210242
|
+
}
|
|
210243
|
+
} else {
|
|
210244
|
+
const queuedPriority = this._queue[0].priority;
|
|
210245
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
210246
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
210247
|
+
if (!waiters)
|
|
210248
|
+
continue;
|
|
210249
|
+
const i3 = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
|
|
210250
|
+
(i3 === -1 ? waiters : waiters.splice(0, i3)).forEach((waiter) => waiter.resolve());
|
|
210251
|
+
}
|
|
210252
|
+
}
|
|
210253
|
+
}
|
|
210254
|
+
_couldLockImmediately(weight, priority) {
|
|
210255
|
+
return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
|
|
210256
|
+
}
|
|
210257
|
+
}
|
|
210258
|
+
function insertSorted(a2, v2) {
|
|
210259
|
+
const i3 = findIndexFromEnd(a2, (other) => v2.priority <= other.priority);
|
|
210260
|
+
a2.splice(i3 + 1, 0, v2);
|
|
210261
|
+
}
|
|
210262
|
+
function findIndexFromEnd(a2, predicate) {
|
|
210263
|
+
for (let i3 = a2.length - 1;i3 >= 0; i3--) {
|
|
210264
|
+
if (predicate(a2[i3])) {
|
|
210265
|
+
return i3;
|
|
210266
|
+
}
|
|
210267
|
+
}
|
|
210268
|
+
return -1;
|
|
210269
|
+
}
|
|
210270
|
+
|
|
210271
|
+
class Mutex {
|
|
210272
|
+
constructor(cancelError) {
|
|
210273
|
+
this._semaphore = new Semaphore(1, cancelError);
|
|
210274
|
+
}
|
|
210275
|
+
acquire() {
|
|
210276
|
+
return __awaiter$1(this, arguments, undefined, function* (priority = 0) {
|
|
210277
|
+
const [, releaser] = yield this._semaphore.acquire(1, priority);
|
|
210278
|
+
return releaser;
|
|
210279
|
+
});
|
|
210280
|
+
}
|
|
210281
|
+
runExclusive(callback, priority = 0) {
|
|
210282
|
+
return this._semaphore.runExclusive(() => callback(), 1, priority);
|
|
210283
|
+
}
|
|
210284
|
+
isLocked() {
|
|
210285
|
+
return this._semaphore.isLocked();
|
|
210286
|
+
}
|
|
210287
|
+
waitForUnlock(priority = 0) {
|
|
210288
|
+
return this._semaphore.waitForUnlock(1, priority);
|
|
210289
|
+
}
|
|
210290
|
+
release() {
|
|
210291
|
+
if (this._semaphore.isLocked())
|
|
210292
|
+
this._semaphore.release();
|
|
210293
|
+
}
|
|
210294
|
+
cancel() {
|
|
210295
|
+
return this._semaphore.cancel();
|
|
210296
|
+
}
|
|
210297
|
+
}
|
|
210298
|
+
var E_TIMEOUT, E_ALREADY_LOCKED, E_CANCELED, __awaiter$2 = function(thisArg, _arguments, P2, generator) {
|
|
210299
|
+
function adopt(value) {
|
|
210300
|
+
return value instanceof P2 ? value : new P2(function(resolve25) {
|
|
210301
|
+
resolve25(value);
|
|
210302
|
+
});
|
|
210303
|
+
}
|
|
210304
|
+
return new (P2 || (P2 = Promise))(function(resolve25, reject2) {
|
|
210305
|
+
function fulfilled(value) {
|
|
210306
|
+
try {
|
|
210307
|
+
step(generator.next(value));
|
|
210308
|
+
} catch (e) {
|
|
210309
|
+
reject2(e);
|
|
210310
|
+
}
|
|
210311
|
+
}
|
|
210312
|
+
function rejected(value) {
|
|
210313
|
+
try {
|
|
210314
|
+
step(generator["throw"](value));
|
|
210315
|
+
} catch (e) {
|
|
210316
|
+
reject2(e);
|
|
210317
|
+
}
|
|
210318
|
+
}
|
|
210319
|
+
function step(result) {
|
|
210320
|
+
result.done ? resolve25(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
210321
|
+
}
|
|
210322
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
210323
|
+
});
|
|
210324
|
+
}, __awaiter$1 = function(thisArg, _arguments, P2, generator) {
|
|
210325
|
+
function adopt(value) {
|
|
210326
|
+
return value instanceof P2 ? value : new P2(function(resolve25) {
|
|
210327
|
+
resolve25(value);
|
|
210328
|
+
});
|
|
210329
|
+
}
|
|
210330
|
+
return new (P2 || (P2 = Promise))(function(resolve25, reject2) {
|
|
210331
|
+
function fulfilled(value) {
|
|
210332
|
+
try {
|
|
210333
|
+
step(generator.next(value));
|
|
210334
|
+
} catch (e) {
|
|
210335
|
+
reject2(e);
|
|
210336
|
+
}
|
|
210337
|
+
}
|
|
210338
|
+
function rejected(value) {
|
|
210339
|
+
try {
|
|
210340
|
+
step(generator["throw"](value));
|
|
210341
|
+
} catch (e) {
|
|
210342
|
+
reject2(e);
|
|
210343
|
+
}
|
|
210344
|
+
}
|
|
210345
|
+
function step(result) {
|
|
210346
|
+
result.done ? resolve25(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
210347
|
+
}
|
|
210348
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
210349
|
+
});
|
|
210350
|
+
};
|
|
210351
|
+
var init_async_mutex = __esm(() => {
|
|
210352
|
+
E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
210353
|
+
E_ALREADY_LOCKED = new Error("mutex already locked");
|
|
210354
|
+
E_CANCELED = new Error("request for lock canceled");
|
|
210355
|
+
});
|
|
210356
|
+
|
|
210149
210357
|
// src/services/api/dumpPrompts.ts
|
|
210150
210358
|
import { createHash as createHash5 } from "crypto";
|
|
210151
210359
|
import { promises as fs11 } from "fs";
|
|
@@ -210158,26 +210366,34 @@ function enqueueDumpRequest(agentIdOrSessionId, callback) {
|
|
|
210158
210366
|
dumpRequestQueue.set(agentIdOrSessionId, []);
|
|
210159
210367
|
}
|
|
210160
210368
|
dumpRequestQueue.get(agentIdOrSessionId).push(callback);
|
|
210161
|
-
|
|
210162
|
-
processingQueues.add(agentIdOrSessionId);
|
|
210163
|
-
processQueue(agentIdOrSessionId);
|
|
210164
|
-
}
|
|
210369
|
+
processQueue(agentIdOrSessionId);
|
|
210165
210370
|
}
|
|
210166
210371
|
async function processQueue(agentIdOrSessionId) {
|
|
210167
|
-
|
|
210168
|
-
|
|
210169
|
-
if (!
|
|
210170
|
-
|
|
210171
|
-
|
|
210172
|
-
return;
|
|
210372
|
+
const mapRelease = await dumpRequestMapMutex.acquire();
|
|
210373
|
+
let mutex = dumpRequestMutexes.get(agentIdOrSessionId);
|
|
210374
|
+
if (!mutex) {
|
|
210375
|
+
mutex = new Mutex;
|
|
210376
|
+
dumpRequestMutexes.set(agentIdOrSessionId, mutex);
|
|
210173
210377
|
}
|
|
210174
|
-
|
|
210175
|
-
await
|
|
210176
|
-
|
|
210177
|
-
|
|
210178
|
-
|
|
210179
|
-
|
|
210180
|
-
|
|
210378
|
+
mapRelease();
|
|
210379
|
+
const release = await mutex.acquire();
|
|
210380
|
+
try {
|
|
210381
|
+
const queue = dumpRequestQueue.get(agentIdOrSessionId);
|
|
210382
|
+
if (!queue || queue.length === 0) {
|
|
210383
|
+
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210384
|
+
dumpRequestMutexes.delete(agentIdOrSessionId);
|
|
210385
|
+
return;
|
|
210386
|
+
}
|
|
210387
|
+
const callback = queue.shift();
|
|
210388
|
+
await callback();
|
|
210389
|
+
if (queue.length > 0) {
|
|
210390
|
+
setImmediate(() => processQueue(agentIdOrSessionId));
|
|
210391
|
+
} else {
|
|
210392
|
+
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210393
|
+
dumpRequestMutexes.delete(agentIdOrSessionId);
|
|
210394
|
+
}
|
|
210395
|
+
} finally {
|
|
210396
|
+
release();
|
|
210181
210397
|
}
|
|
210182
210398
|
}
|
|
210183
210399
|
function clearDumpState(agentIdOrSessionId) {
|
|
@@ -210223,11 +210439,14 @@ function initFingerprint(req) {
|
|
|
210223
210439
|
return `${req.model}|${toolNames}|${sysLen}`;
|
|
210224
210440
|
}
|
|
210225
210441
|
async function dumpRequest(body, ts, state, filePath) {
|
|
210442
|
+
if (false)
|
|
210443
|
+
;
|
|
210226
210444
|
try {
|
|
210227
210445
|
const req = jsonParse(body);
|
|
210228
210446
|
addApiRequestToCache(req);
|
|
210229
210447
|
if (process.env.USER_TYPE !== "ant" || process.env.DUMP_PROMPTS !== "1")
|
|
210230
210448
|
return;
|
|
210449
|
+
logForDebugging("DUMP_PROMPTS is enabled. This will write full API payloads (including system prompts, user messages, and tool definitions) to the filesystem. This is intended for debugging only and should NOT be used in production.", { level: "warn" });
|
|
210231
210450
|
const entries = [];
|
|
210232
210451
|
const messages = req.messages ?? [];
|
|
210233
210452
|
const fingerprint = initFingerprint(req);
|
|
@@ -210283,7 +210502,7 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210283
210502
|
});
|
|
210284
210503
|
}
|
|
210285
210504
|
const response = await globalThis.fetch(input, init2);
|
|
210286
|
-
if (timestamp && response.ok && process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210505
|
+
if (timestamp && response.ok && true && process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210287
210506
|
const cloned = response.clone();
|
|
210288
210507
|
(async () => {
|
|
210289
210508
|
try {
|
|
@@ -210293,7 +210512,7 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210293
210512
|
const reader = cloned.body.getReader();
|
|
210294
210513
|
const decoder = new TextDecoder;
|
|
210295
210514
|
let buffer = "";
|
|
210296
|
-
const
|
|
210515
|
+
const chunkEntries = [];
|
|
210297
210516
|
try {
|
|
210298
210517
|
while (true) {
|
|
210299
210518
|
const { done, value } = await reader.read();
|
|
@@ -210313,7 +210532,12 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210313
210532
|
`)) {
|
|
210314
210533
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210315
210534
|
try {
|
|
210316
|
-
|
|
210535
|
+
const chunk = jsonParse(line.slice(6));
|
|
210536
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210537
|
+
if (chunkEntries.length >= 50) {
|
|
210538
|
+
await appendToFile(filePath, chunkEntries);
|
|
210539
|
+
chunkEntries.length = 0;
|
|
210540
|
+
}
|
|
210317
210541
|
} catch (err2) {
|
|
210318
210542
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210319
210543
|
}
|
|
@@ -210333,7 +210557,8 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210333
210557
|
`)) {
|
|
210334
210558
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210335
210559
|
try {
|
|
210336
|
-
|
|
210560
|
+
const chunk = jsonParse(line.slice(6));
|
|
210561
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210337
210562
|
} catch (err2) {
|
|
210338
210563
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210339
210564
|
}
|
|
@@ -210341,7 +210566,10 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210341
210566
|
}
|
|
210342
210567
|
}
|
|
210343
210568
|
}
|
|
210344
|
-
|
|
210569
|
+
if (chunkEntries.length > 0) {
|
|
210570
|
+
await appendToFile(filePath, chunkEntries);
|
|
210571
|
+
}
|
|
210572
|
+
data = { stream: true, chunks: [] };
|
|
210345
210573
|
} else {
|
|
210346
210574
|
data = await cloned.json();
|
|
210347
210575
|
}
|
|
@@ -210360,17 +210588,22 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210360
210588
|
return response;
|
|
210361
210589
|
};
|
|
210362
210590
|
}
|
|
210363
|
-
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue,
|
|
210591
|
+
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue, dumpRequestMutexes, dumpRequestMapMutex;
|
|
210364
210592
|
var init_dumpPrompts = __esm(() => {
|
|
210365
210593
|
init_state();
|
|
210366
210594
|
init_envUtils();
|
|
210367
210595
|
init_slowOperations();
|
|
210368
210596
|
init_debug();
|
|
210369
210597
|
init_log3();
|
|
210598
|
+
init_async_mutex();
|
|
210599
|
+
if (process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210600
|
+
logForDebugging("DUMP_PROMPTS is enabled. This will write full API payloads (including system prompts, user messages, and tool definitions) to the filesystem. This is intended for debugging only and should NOT be used in production.", { level: "warn" });
|
|
210601
|
+
}
|
|
210370
210602
|
cachedApiRequests = [];
|
|
210371
210603
|
dumpState = new Map;
|
|
210372
210604
|
dumpRequestQueue = new Map;
|
|
210373
|
-
|
|
210605
|
+
dumpRequestMutexes = new Map;
|
|
210606
|
+
dumpRequestMapMutex = new Mutex;
|
|
210374
210607
|
});
|
|
210375
210608
|
|
|
210376
210609
|
// src/utils/abortController.ts
|
|
@@ -300904,214 +301137,6 @@ var init_gracefulShutdown = __esm(() => {
|
|
|
300904
301137
|
};
|
|
300905
301138
|
});
|
|
300906
301139
|
|
|
300907
|
-
// node_modules/async-mutex/index.mjs
|
|
300908
|
-
class Semaphore {
|
|
300909
|
-
constructor(_value, _cancelError = E_CANCELED) {
|
|
300910
|
-
this._value = _value;
|
|
300911
|
-
this._cancelError = _cancelError;
|
|
300912
|
-
this._queue = [];
|
|
300913
|
-
this._weightedWaiters = [];
|
|
300914
|
-
}
|
|
300915
|
-
acquire(weight = 1, priority = 0) {
|
|
300916
|
-
if (weight <= 0)
|
|
300917
|
-
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300918
|
-
return new Promise((resolve28, reject2) => {
|
|
300919
|
-
const task = { resolve: resolve28, reject: reject2, weight, priority };
|
|
300920
|
-
const i3 = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
|
|
300921
|
-
if (i3 === -1 && weight <= this._value) {
|
|
300922
|
-
this._dispatchItem(task);
|
|
300923
|
-
} else {
|
|
300924
|
-
this._queue.splice(i3 + 1, 0, task);
|
|
300925
|
-
}
|
|
300926
|
-
});
|
|
300927
|
-
}
|
|
300928
|
-
runExclusive(callback_1) {
|
|
300929
|
-
return __awaiter$2(this, arguments, undefined, function* (callback, weight = 1, priority = 0) {
|
|
300930
|
-
const [value, release] = yield this.acquire(weight, priority);
|
|
300931
|
-
try {
|
|
300932
|
-
return yield callback(value);
|
|
300933
|
-
} finally {
|
|
300934
|
-
release();
|
|
300935
|
-
}
|
|
300936
|
-
});
|
|
300937
|
-
}
|
|
300938
|
-
waitForUnlock(weight = 1, priority = 0) {
|
|
300939
|
-
if (weight <= 0)
|
|
300940
|
-
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300941
|
-
if (this._couldLockImmediately(weight, priority)) {
|
|
300942
|
-
return Promise.resolve();
|
|
300943
|
-
} else {
|
|
300944
|
-
return new Promise((resolve28) => {
|
|
300945
|
-
if (!this._weightedWaiters[weight - 1])
|
|
300946
|
-
this._weightedWaiters[weight - 1] = [];
|
|
300947
|
-
insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve28, priority });
|
|
300948
|
-
});
|
|
300949
|
-
}
|
|
300950
|
-
}
|
|
300951
|
-
isLocked() {
|
|
300952
|
-
return this._value <= 0;
|
|
300953
|
-
}
|
|
300954
|
-
getValue() {
|
|
300955
|
-
return this._value;
|
|
300956
|
-
}
|
|
300957
|
-
setValue(value) {
|
|
300958
|
-
this._value = value;
|
|
300959
|
-
this._dispatchQueue();
|
|
300960
|
-
}
|
|
300961
|
-
release(weight = 1) {
|
|
300962
|
-
if (weight <= 0)
|
|
300963
|
-
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300964
|
-
this._value += weight;
|
|
300965
|
-
this._dispatchQueue();
|
|
300966
|
-
}
|
|
300967
|
-
cancel() {
|
|
300968
|
-
this._queue.forEach((entry) => entry.reject(this._cancelError));
|
|
300969
|
-
this._queue = [];
|
|
300970
|
-
}
|
|
300971
|
-
_dispatchQueue() {
|
|
300972
|
-
this._drainUnlockWaiters();
|
|
300973
|
-
while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
|
|
300974
|
-
this._dispatchItem(this._queue.shift());
|
|
300975
|
-
this._drainUnlockWaiters();
|
|
300976
|
-
}
|
|
300977
|
-
}
|
|
300978
|
-
_dispatchItem(item) {
|
|
300979
|
-
const previousValue = this._value;
|
|
300980
|
-
this._value -= item.weight;
|
|
300981
|
-
item.resolve([previousValue, this._newReleaser(item.weight)]);
|
|
300982
|
-
}
|
|
300983
|
-
_newReleaser(weight) {
|
|
300984
|
-
let called = false;
|
|
300985
|
-
return () => {
|
|
300986
|
-
if (called)
|
|
300987
|
-
return;
|
|
300988
|
-
called = true;
|
|
300989
|
-
this.release(weight);
|
|
300990
|
-
};
|
|
300991
|
-
}
|
|
300992
|
-
_drainUnlockWaiters() {
|
|
300993
|
-
if (this._queue.length === 0) {
|
|
300994
|
-
for (let weight = this._value;weight > 0; weight--) {
|
|
300995
|
-
const waiters = this._weightedWaiters[weight - 1];
|
|
300996
|
-
if (!waiters)
|
|
300997
|
-
continue;
|
|
300998
|
-
waiters.forEach((waiter) => waiter.resolve());
|
|
300999
|
-
this._weightedWaiters[weight - 1] = [];
|
|
301000
|
-
}
|
|
301001
|
-
} else {
|
|
301002
|
-
const queuedPriority = this._queue[0].priority;
|
|
301003
|
-
for (let weight = this._value;weight > 0; weight--) {
|
|
301004
|
-
const waiters = this._weightedWaiters[weight - 1];
|
|
301005
|
-
if (!waiters)
|
|
301006
|
-
continue;
|
|
301007
|
-
const i3 = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
|
|
301008
|
-
(i3 === -1 ? waiters : waiters.splice(0, i3)).forEach((waiter) => waiter.resolve());
|
|
301009
|
-
}
|
|
301010
|
-
}
|
|
301011
|
-
}
|
|
301012
|
-
_couldLockImmediately(weight, priority) {
|
|
301013
|
-
return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
|
|
301014
|
-
}
|
|
301015
|
-
}
|
|
301016
|
-
function insertSorted(a2, v2) {
|
|
301017
|
-
const i3 = findIndexFromEnd(a2, (other) => v2.priority <= other.priority);
|
|
301018
|
-
a2.splice(i3 + 1, 0, v2);
|
|
301019
|
-
}
|
|
301020
|
-
function findIndexFromEnd(a2, predicate) {
|
|
301021
|
-
for (let i3 = a2.length - 1;i3 >= 0; i3--) {
|
|
301022
|
-
if (predicate(a2[i3])) {
|
|
301023
|
-
return i3;
|
|
301024
|
-
}
|
|
301025
|
-
}
|
|
301026
|
-
return -1;
|
|
301027
|
-
}
|
|
301028
|
-
|
|
301029
|
-
class Mutex {
|
|
301030
|
-
constructor(cancelError) {
|
|
301031
|
-
this._semaphore = new Semaphore(1, cancelError);
|
|
301032
|
-
}
|
|
301033
|
-
acquire() {
|
|
301034
|
-
return __awaiter$1(this, arguments, undefined, function* (priority = 0) {
|
|
301035
|
-
const [, releaser] = yield this._semaphore.acquire(1, priority);
|
|
301036
|
-
return releaser;
|
|
301037
|
-
});
|
|
301038
|
-
}
|
|
301039
|
-
runExclusive(callback, priority = 0) {
|
|
301040
|
-
return this._semaphore.runExclusive(() => callback(), 1, priority);
|
|
301041
|
-
}
|
|
301042
|
-
isLocked() {
|
|
301043
|
-
return this._semaphore.isLocked();
|
|
301044
|
-
}
|
|
301045
|
-
waitForUnlock(priority = 0) {
|
|
301046
|
-
return this._semaphore.waitForUnlock(1, priority);
|
|
301047
|
-
}
|
|
301048
|
-
release() {
|
|
301049
|
-
if (this._semaphore.isLocked())
|
|
301050
|
-
this._semaphore.release();
|
|
301051
|
-
}
|
|
301052
|
-
cancel() {
|
|
301053
|
-
return this._semaphore.cancel();
|
|
301054
|
-
}
|
|
301055
|
-
}
|
|
301056
|
-
var E_TIMEOUT, E_ALREADY_LOCKED, E_CANCELED, __awaiter$2 = function(thisArg, _arguments, P2, generator) {
|
|
301057
|
-
function adopt(value) {
|
|
301058
|
-
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301059
|
-
resolve28(value);
|
|
301060
|
-
});
|
|
301061
|
-
}
|
|
301062
|
-
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301063
|
-
function fulfilled(value) {
|
|
301064
|
-
try {
|
|
301065
|
-
step(generator.next(value));
|
|
301066
|
-
} catch (e) {
|
|
301067
|
-
reject2(e);
|
|
301068
|
-
}
|
|
301069
|
-
}
|
|
301070
|
-
function rejected(value) {
|
|
301071
|
-
try {
|
|
301072
|
-
step(generator["throw"](value));
|
|
301073
|
-
} catch (e) {
|
|
301074
|
-
reject2(e);
|
|
301075
|
-
}
|
|
301076
|
-
}
|
|
301077
|
-
function step(result) {
|
|
301078
|
-
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301079
|
-
}
|
|
301080
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301081
|
-
});
|
|
301082
|
-
}, __awaiter$1 = function(thisArg, _arguments, P2, generator) {
|
|
301083
|
-
function adopt(value) {
|
|
301084
|
-
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301085
|
-
resolve28(value);
|
|
301086
|
-
});
|
|
301087
|
-
}
|
|
301088
|
-
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301089
|
-
function fulfilled(value) {
|
|
301090
|
-
try {
|
|
301091
|
-
step(generator.next(value));
|
|
301092
|
-
} catch (e) {
|
|
301093
|
-
reject2(e);
|
|
301094
|
-
}
|
|
301095
|
-
}
|
|
301096
|
-
function rejected(value) {
|
|
301097
|
-
try {
|
|
301098
|
-
step(generator["throw"](value));
|
|
301099
|
-
} catch (e) {
|
|
301100
|
-
reject2(e);
|
|
301101
|
-
}
|
|
301102
|
-
}
|
|
301103
|
-
function step(result) {
|
|
301104
|
-
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301105
|
-
}
|
|
301106
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301107
|
-
});
|
|
301108
|
-
};
|
|
301109
|
-
var init_async_mutex = __esm(() => {
|
|
301110
|
-
E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
301111
|
-
E_ALREADY_LOCKED = new Error("mutex already locked");
|
|
301112
|
-
E_CANCELED = new Error("request for lock canceled");
|
|
301113
|
-
});
|
|
301114
|
-
|
|
301115
301140
|
// src/services/api/grove.ts
|
|
301116
301141
|
function memoizeWithTTL(fn, ttlMs) {
|
|
301117
301142
|
let lastCachedAt = 0;
|
|
@@ -342303,21 +342328,21 @@ var init_KeybindingProviderSetup = __esm(() => {
|
|
|
342303
342328
|
});
|
|
342304
342329
|
|
|
342305
342330
|
// src/services/api/sessionIngress.ts
|
|
342306
|
-
function
|
|
342307
|
-
let
|
|
342308
|
-
if (!
|
|
342309
|
-
|
|
342310
|
-
|
|
342311
|
-
|
|
342312
|
-
|
|
342313
|
-
}
|
|
342314
|
-
|
|
342315
|
-
|
|
342316
|
-
|
|
342317
|
-
|
|
342318
|
-
|
|
342331
|
+
function getOrCreateSequential(sessionId) {
|
|
342332
|
+
let wrapper = sequentialBySession.get(sessionId);
|
|
342333
|
+
if (!wrapper) {
|
|
342334
|
+
wrapper = sequential(async (entryOrSid, url3, headers, isFetch = false) => {
|
|
342335
|
+
if (isFetch) {
|
|
342336
|
+
const sid = entryOrSid;
|
|
342337
|
+
return await fetchSessionLogsFromUrl(sid, url3, headers);
|
|
342338
|
+
} else {
|
|
342339
|
+
const entry = entryOrSid;
|
|
342340
|
+
return await appendSessionLogImpl(sessionId, entry, url3, headers);
|
|
342341
|
+
}
|
|
342342
|
+
});
|
|
342343
|
+
sequentialBySession.set(sessionId, wrapper);
|
|
342319
342344
|
}
|
|
342320
|
-
return
|
|
342345
|
+
return wrapper;
|
|
342321
342346
|
}
|
|
342322
342347
|
async function appendSessionLogImpl(sessionId, entry, url3, headers) {
|
|
342323
342348
|
for (let attempt = 1;attempt <= MAX_RETRIES; attempt++) {
|
|
@@ -342348,10 +342373,10 @@ async function appendSessionLogImpl(sessionId, entry, url3, headers) {
|
|
|
342348
342373
|
lastUuidMap.set(sessionId, serverLastUuid);
|
|
342349
342374
|
logForDebugging(`Session 409: adopting server lastUuid=${serverLastUuid} from header, retrying entry ${entry.uuid}`);
|
|
342350
342375
|
} else {
|
|
342351
|
-
const
|
|
342376
|
+
const sequential2 = getOrCreateSequential(sessionId);
|
|
342352
342377
|
let logs2 = null;
|
|
342353
342378
|
try {
|
|
342354
|
-
logs2 = await
|
|
342379
|
+
logs2 = await sequential2(sessionId, url3, headers, true);
|
|
342355
342380
|
} catch (fetchError) {
|
|
342356
342381
|
logError2(new Error(`Session 409: fetch failed for session ${sessionId}, entry ${entry.uuid}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`));
|
|
342357
342382
|
logForDiagnosticsNoPII("error", "session_persist_409_fetch_fail");
|
|
@@ -342409,8 +342434,8 @@ async function appendSessionLog(sessionId, entry, url3) {
|
|
|
342409
342434
|
Authorization: `Bearer ${sessionToken}`,
|
|
342410
342435
|
"Content-Type": "application/json"
|
|
342411
342436
|
};
|
|
342412
|
-
const
|
|
342413
|
-
return
|
|
342437
|
+
const sequential2 = getOrCreateSequential(sessionId);
|
|
342438
|
+
return sequential2(entry, url3, headers, false);
|
|
342414
342439
|
}
|
|
342415
342440
|
async function getSessionLogs(sessionId, url3) {
|
|
342416
342441
|
const sessionToken = getSessionIngressAuthToken();
|
|
@@ -342571,10 +342596,9 @@ function findLastUuid(logs2) {
|
|
|
342571
342596
|
}
|
|
342572
342597
|
function clearAllSessions() {
|
|
342573
342598
|
lastUuidMap.clear();
|
|
342574
|
-
|
|
342575
|
-
sequentialFetchBySession.clear();
|
|
342599
|
+
sequentialBySession.clear();
|
|
342576
342600
|
}
|
|
342577
|
-
var lastUuidMap, MAX_RETRIES = 10, BASE_DELAY_MS2 = 500,
|
|
342601
|
+
var lastUuidMap, MAX_RETRIES = 10, BASE_DELAY_MS2 = 500, sequentialBySession;
|
|
342578
342602
|
var init_sessionIngress = __esm(() => {
|
|
342579
342603
|
init_axios2();
|
|
342580
342604
|
init_oauth();
|
|
@@ -342586,8 +342610,7 @@ var init_sessionIngress = __esm(() => {
|
|
|
342586
342610
|
init_slowOperations();
|
|
342587
342611
|
init_api2();
|
|
342588
342612
|
lastUuidMap = new Map;
|
|
342589
|
-
|
|
342590
|
-
sequentialFetchBySession = new Map;
|
|
342613
|
+
sequentialBySession = new Map;
|
|
342591
342614
|
});
|
|
342592
342615
|
|
|
342593
342616
|
// src/utils/fileHistory.ts
|
package/dist/myclaude.mjs
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// MACRO - build-time constants (injected by build.ts)
|
|
5
5
|
// MACRO injected by build script
|
|
6
6
|
globalThis.MACRO = {
|
|
7
|
-
VERSION: "0.1.
|
|
8
|
-
BUILD_TIME: "2026-07-
|
|
7
|
+
VERSION: "0.1.94",
|
|
8
|
+
BUILD_TIME: "2026-07-18T06:27:57.445Z",
|
|
9
9
|
PACKAGE_URL: "@funnycode/myclaude",
|
|
10
10
|
NATIVE_PACKAGE_URL: "@funnycode/myclaude",
|
|
11
11
|
VERSION_CHANGELOG: '',
|
|
@@ -117484,7 +117484,7 @@ var package_default;
|
|
|
117484
117484
|
var init_package = __esm(() => {
|
|
117485
117485
|
package_default = {
|
|
117486
117486
|
name: "@funnycode/myclaude",
|
|
117487
|
-
version: "0.1.
|
|
117487
|
+
version: "0.1.94",
|
|
117488
117488
|
private: false,
|
|
117489
117489
|
description: "An open-source AI coding assistant in your terminal - powered by Claude",
|
|
117490
117490
|
license: "MIT",
|
|
@@ -210146,6 +210146,214 @@ var init_postSamplingHooks = __esm(() => {
|
|
|
210146
210146
|
postSamplingHooks = [];
|
|
210147
210147
|
});
|
|
210148
210148
|
|
|
210149
|
+
// node_modules/async-mutex/index.mjs
|
|
210150
|
+
class Semaphore {
|
|
210151
|
+
constructor(_value, _cancelError = E_CANCELED) {
|
|
210152
|
+
this._value = _value;
|
|
210153
|
+
this._cancelError = _cancelError;
|
|
210154
|
+
this._queue = [];
|
|
210155
|
+
this._weightedWaiters = [];
|
|
210156
|
+
}
|
|
210157
|
+
acquire(weight = 1, priority = 0) {
|
|
210158
|
+
if (weight <= 0)
|
|
210159
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
210160
|
+
return new Promise((resolve25, reject2) => {
|
|
210161
|
+
const task = { resolve: resolve25, reject: reject2, weight, priority };
|
|
210162
|
+
const i3 = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
|
|
210163
|
+
if (i3 === -1 && weight <= this._value) {
|
|
210164
|
+
this._dispatchItem(task);
|
|
210165
|
+
} else {
|
|
210166
|
+
this._queue.splice(i3 + 1, 0, task);
|
|
210167
|
+
}
|
|
210168
|
+
});
|
|
210169
|
+
}
|
|
210170
|
+
runExclusive(callback_1) {
|
|
210171
|
+
return __awaiter$2(this, arguments, undefined, function* (callback, weight = 1, priority = 0) {
|
|
210172
|
+
const [value, release] = yield this.acquire(weight, priority);
|
|
210173
|
+
try {
|
|
210174
|
+
return yield callback(value);
|
|
210175
|
+
} finally {
|
|
210176
|
+
release();
|
|
210177
|
+
}
|
|
210178
|
+
});
|
|
210179
|
+
}
|
|
210180
|
+
waitForUnlock(weight = 1, priority = 0) {
|
|
210181
|
+
if (weight <= 0)
|
|
210182
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
210183
|
+
if (this._couldLockImmediately(weight, priority)) {
|
|
210184
|
+
return Promise.resolve();
|
|
210185
|
+
} else {
|
|
210186
|
+
return new Promise((resolve25) => {
|
|
210187
|
+
if (!this._weightedWaiters[weight - 1])
|
|
210188
|
+
this._weightedWaiters[weight - 1] = [];
|
|
210189
|
+
insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve25, priority });
|
|
210190
|
+
});
|
|
210191
|
+
}
|
|
210192
|
+
}
|
|
210193
|
+
isLocked() {
|
|
210194
|
+
return this._value <= 0;
|
|
210195
|
+
}
|
|
210196
|
+
getValue() {
|
|
210197
|
+
return this._value;
|
|
210198
|
+
}
|
|
210199
|
+
setValue(value) {
|
|
210200
|
+
this._value = value;
|
|
210201
|
+
this._dispatchQueue();
|
|
210202
|
+
}
|
|
210203
|
+
release(weight = 1) {
|
|
210204
|
+
if (weight <= 0)
|
|
210205
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
210206
|
+
this._value += weight;
|
|
210207
|
+
this._dispatchQueue();
|
|
210208
|
+
}
|
|
210209
|
+
cancel() {
|
|
210210
|
+
this._queue.forEach((entry) => entry.reject(this._cancelError));
|
|
210211
|
+
this._queue = [];
|
|
210212
|
+
}
|
|
210213
|
+
_dispatchQueue() {
|
|
210214
|
+
this._drainUnlockWaiters();
|
|
210215
|
+
while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
|
|
210216
|
+
this._dispatchItem(this._queue.shift());
|
|
210217
|
+
this._drainUnlockWaiters();
|
|
210218
|
+
}
|
|
210219
|
+
}
|
|
210220
|
+
_dispatchItem(item) {
|
|
210221
|
+
const previousValue = this._value;
|
|
210222
|
+
this._value -= item.weight;
|
|
210223
|
+
item.resolve([previousValue, this._newReleaser(item.weight)]);
|
|
210224
|
+
}
|
|
210225
|
+
_newReleaser(weight) {
|
|
210226
|
+
let called = false;
|
|
210227
|
+
return () => {
|
|
210228
|
+
if (called)
|
|
210229
|
+
return;
|
|
210230
|
+
called = true;
|
|
210231
|
+
this.release(weight);
|
|
210232
|
+
};
|
|
210233
|
+
}
|
|
210234
|
+
_drainUnlockWaiters() {
|
|
210235
|
+
if (this._queue.length === 0) {
|
|
210236
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
210237
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
210238
|
+
if (!waiters)
|
|
210239
|
+
continue;
|
|
210240
|
+
waiters.forEach((waiter) => waiter.resolve());
|
|
210241
|
+
this._weightedWaiters[weight - 1] = [];
|
|
210242
|
+
}
|
|
210243
|
+
} else {
|
|
210244
|
+
const queuedPriority = this._queue[0].priority;
|
|
210245
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
210246
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
210247
|
+
if (!waiters)
|
|
210248
|
+
continue;
|
|
210249
|
+
const i3 = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
|
|
210250
|
+
(i3 === -1 ? waiters : waiters.splice(0, i3)).forEach((waiter) => waiter.resolve());
|
|
210251
|
+
}
|
|
210252
|
+
}
|
|
210253
|
+
}
|
|
210254
|
+
_couldLockImmediately(weight, priority) {
|
|
210255
|
+
return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
|
|
210256
|
+
}
|
|
210257
|
+
}
|
|
210258
|
+
function insertSorted(a2, v2) {
|
|
210259
|
+
const i3 = findIndexFromEnd(a2, (other) => v2.priority <= other.priority);
|
|
210260
|
+
a2.splice(i3 + 1, 0, v2);
|
|
210261
|
+
}
|
|
210262
|
+
function findIndexFromEnd(a2, predicate) {
|
|
210263
|
+
for (let i3 = a2.length - 1;i3 >= 0; i3--) {
|
|
210264
|
+
if (predicate(a2[i3])) {
|
|
210265
|
+
return i3;
|
|
210266
|
+
}
|
|
210267
|
+
}
|
|
210268
|
+
return -1;
|
|
210269
|
+
}
|
|
210270
|
+
|
|
210271
|
+
class Mutex {
|
|
210272
|
+
constructor(cancelError) {
|
|
210273
|
+
this._semaphore = new Semaphore(1, cancelError);
|
|
210274
|
+
}
|
|
210275
|
+
acquire() {
|
|
210276
|
+
return __awaiter$1(this, arguments, undefined, function* (priority = 0) {
|
|
210277
|
+
const [, releaser] = yield this._semaphore.acquire(1, priority);
|
|
210278
|
+
return releaser;
|
|
210279
|
+
});
|
|
210280
|
+
}
|
|
210281
|
+
runExclusive(callback, priority = 0) {
|
|
210282
|
+
return this._semaphore.runExclusive(() => callback(), 1, priority);
|
|
210283
|
+
}
|
|
210284
|
+
isLocked() {
|
|
210285
|
+
return this._semaphore.isLocked();
|
|
210286
|
+
}
|
|
210287
|
+
waitForUnlock(priority = 0) {
|
|
210288
|
+
return this._semaphore.waitForUnlock(1, priority);
|
|
210289
|
+
}
|
|
210290
|
+
release() {
|
|
210291
|
+
if (this._semaphore.isLocked())
|
|
210292
|
+
this._semaphore.release();
|
|
210293
|
+
}
|
|
210294
|
+
cancel() {
|
|
210295
|
+
return this._semaphore.cancel();
|
|
210296
|
+
}
|
|
210297
|
+
}
|
|
210298
|
+
var E_TIMEOUT, E_ALREADY_LOCKED, E_CANCELED, __awaiter$2 = function(thisArg, _arguments, P2, generator) {
|
|
210299
|
+
function adopt(value) {
|
|
210300
|
+
return value instanceof P2 ? value : new P2(function(resolve25) {
|
|
210301
|
+
resolve25(value);
|
|
210302
|
+
});
|
|
210303
|
+
}
|
|
210304
|
+
return new (P2 || (P2 = Promise))(function(resolve25, reject2) {
|
|
210305
|
+
function fulfilled(value) {
|
|
210306
|
+
try {
|
|
210307
|
+
step(generator.next(value));
|
|
210308
|
+
} catch (e) {
|
|
210309
|
+
reject2(e);
|
|
210310
|
+
}
|
|
210311
|
+
}
|
|
210312
|
+
function rejected(value) {
|
|
210313
|
+
try {
|
|
210314
|
+
step(generator["throw"](value));
|
|
210315
|
+
} catch (e) {
|
|
210316
|
+
reject2(e);
|
|
210317
|
+
}
|
|
210318
|
+
}
|
|
210319
|
+
function step(result) {
|
|
210320
|
+
result.done ? resolve25(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
210321
|
+
}
|
|
210322
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
210323
|
+
});
|
|
210324
|
+
}, __awaiter$1 = function(thisArg, _arguments, P2, generator) {
|
|
210325
|
+
function adopt(value) {
|
|
210326
|
+
return value instanceof P2 ? value : new P2(function(resolve25) {
|
|
210327
|
+
resolve25(value);
|
|
210328
|
+
});
|
|
210329
|
+
}
|
|
210330
|
+
return new (P2 || (P2 = Promise))(function(resolve25, reject2) {
|
|
210331
|
+
function fulfilled(value) {
|
|
210332
|
+
try {
|
|
210333
|
+
step(generator.next(value));
|
|
210334
|
+
} catch (e) {
|
|
210335
|
+
reject2(e);
|
|
210336
|
+
}
|
|
210337
|
+
}
|
|
210338
|
+
function rejected(value) {
|
|
210339
|
+
try {
|
|
210340
|
+
step(generator["throw"](value));
|
|
210341
|
+
} catch (e) {
|
|
210342
|
+
reject2(e);
|
|
210343
|
+
}
|
|
210344
|
+
}
|
|
210345
|
+
function step(result) {
|
|
210346
|
+
result.done ? resolve25(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
210347
|
+
}
|
|
210348
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
210349
|
+
});
|
|
210350
|
+
};
|
|
210351
|
+
var init_async_mutex = __esm(() => {
|
|
210352
|
+
E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
210353
|
+
E_ALREADY_LOCKED = new Error("mutex already locked");
|
|
210354
|
+
E_CANCELED = new Error("request for lock canceled");
|
|
210355
|
+
});
|
|
210356
|
+
|
|
210149
210357
|
// src/services/api/dumpPrompts.ts
|
|
210150
210358
|
import { createHash as createHash5 } from "crypto";
|
|
210151
210359
|
import { promises as fs11 } from "fs";
|
|
@@ -210158,26 +210366,34 @@ function enqueueDumpRequest(agentIdOrSessionId, callback) {
|
|
|
210158
210366
|
dumpRequestQueue.set(agentIdOrSessionId, []);
|
|
210159
210367
|
}
|
|
210160
210368
|
dumpRequestQueue.get(agentIdOrSessionId).push(callback);
|
|
210161
|
-
|
|
210162
|
-
processingQueues.add(agentIdOrSessionId);
|
|
210163
|
-
processQueue(agentIdOrSessionId);
|
|
210164
|
-
}
|
|
210369
|
+
processQueue(agentIdOrSessionId);
|
|
210165
210370
|
}
|
|
210166
210371
|
async function processQueue(agentIdOrSessionId) {
|
|
210167
|
-
|
|
210168
|
-
|
|
210169
|
-
if (!
|
|
210170
|
-
|
|
210171
|
-
|
|
210172
|
-
return;
|
|
210372
|
+
const mapRelease = await dumpRequestMapMutex.acquire();
|
|
210373
|
+
let mutex = dumpRequestMutexes.get(agentIdOrSessionId);
|
|
210374
|
+
if (!mutex) {
|
|
210375
|
+
mutex = new Mutex;
|
|
210376
|
+
dumpRequestMutexes.set(agentIdOrSessionId, mutex);
|
|
210173
210377
|
}
|
|
210174
|
-
|
|
210175
|
-
await
|
|
210176
|
-
|
|
210177
|
-
|
|
210178
|
-
|
|
210179
|
-
|
|
210180
|
-
|
|
210378
|
+
mapRelease();
|
|
210379
|
+
const release = await mutex.acquire();
|
|
210380
|
+
try {
|
|
210381
|
+
const queue = dumpRequestQueue.get(agentIdOrSessionId);
|
|
210382
|
+
if (!queue || queue.length === 0) {
|
|
210383
|
+
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210384
|
+
dumpRequestMutexes.delete(agentIdOrSessionId);
|
|
210385
|
+
return;
|
|
210386
|
+
}
|
|
210387
|
+
const callback = queue.shift();
|
|
210388
|
+
await callback();
|
|
210389
|
+
if (queue.length > 0) {
|
|
210390
|
+
setImmediate(() => processQueue(agentIdOrSessionId));
|
|
210391
|
+
} else {
|
|
210392
|
+
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210393
|
+
dumpRequestMutexes.delete(agentIdOrSessionId);
|
|
210394
|
+
}
|
|
210395
|
+
} finally {
|
|
210396
|
+
release();
|
|
210181
210397
|
}
|
|
210182
210398
|
}
|
|
210183
210399
|
function clearDumpState(agentIdOrSessionId) {
|
|
@@ -210223,11 +210439,14 @@ function initFingerprint(req) {
|
|
|
210223
210439
|
return `${req.model}|${toolNames}|${sysLen}`;
|
|
210224
210440
|
}
|
|
210225
210441
|
async function dumpRequest(body, ts, state, filePath) {
|
|
210442
|
+
if (false)
|
|
210443
|
+
;
|
|
210226
210444
|
try {
|
|
210227
210445
|
const req = jsonParse(body);
|
|
210228
210446
|
addApiRequestToCache(req);
|
|
210229
210447
|
if (process.env.USER_TYPE !== "ant" || process.env.DUMP_PROMPTS !== "1")
|
|
210230
210448
|
return;
|
|
210449
|
+
logForDebugging("DUMP_PROMPTS is enabled. This will write full API payloads (including system prompts, user messages, and tool definitions) to the filesystem. This is intended for debugging only and should NOT be used in production.", { level: "warn" });
|
|
210231
210450
|
const entries = [];
|
|
210232
210451
|
const messages = req.messages ?? [];
|
|
210233
210452
|
const fingerprint = initFingerprint(req);
|
|
@@ -210283,7 +210502,7 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210283
210502
|
});
|
|
210284
210503
|
}
|
|
210285
210504
|
const response = await globalThis.fetch(input, init2);
|
|
210286
|
-
if (timestamp && response.ok && process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210505
|
+
if (timestamp && response.ok && true && process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210287
210506
|
const cloned = response.clone();
|
|
210288
210507
|
(async () => {
|
|
210289
210508
|
try {
|
|
@@ -210293,7 +210512,7 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210293
210512
|
const reader = cloned.body.getReader();
|
|
210294
210513
|
const decoder = new TextDecoder;
|
|
210295
210514
|
let buffer = "";
|
|
210296
|
-
const
|
|
210515
|
+
const chunkEntries = [];
|
|
210297
210516
|
try {
|
|
210298
210517
|
while (true) {
|
|
210299
210518
|
const { done, value } = await reader.read();
|
|
@@ -210313,7 +210532,12 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210313
210532
|
`)) {
|
|
210314
210533
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210315
210534
|
try {
|
|
210316
|
-
|
|
210535
|
+
const chunk = jsonParse(line.slice(6));
|
|
210536
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210537
|
+
if (chunkEntries.length >= 50) {
|
|
210538
|
+
await appendToFile(filePath, chunkEntries);
|
|
210539
|
+
chunkEntries.length = 0;
|
|
210540
|
+
}
|
|
210317
210541
|
} catch (err2) {
|
|
210318
210542
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210319
210543
|
}
|
|
@@ -210333,7 +210557,8 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210333
210557
|
`)) {
|
|
210334
210558
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210335
210559
|
try {
|
|
210336
|
-
|
|
210560
|
+
const chunk = jsonParse(line.slice(6));
|
|
210561
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210337
210562
|
} catch (err2) {
|
|
210338
210563
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210339
210564
|
}
|
|
@@ -210341,7 +210566,10 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210341
210566
|
}
|
|
210342
210567
|
}
|
|
210343
210568
|
}
|
|
210344
|
-
|
|
210569
|
+
if (chunkEntries.length > 0) {
|
|
210570
|
+
await appendToFile(filePath, chunkEntries);
|
|
210571
|
+
}
|
|
210572
|
+
data = { stream: true, chunks: [] };
|
|
210345
210573
|
} else {
|
|
210346
210574
|
data = await cloned.json();
|
|
210347
210575
|
}
|
|
@@ -210360,17 +210588,22 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210360
210588
|
return response;
|
|
210361
210589
|
};
|
|
210362
210590
|
}
|
|
210363
|
-
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue,
|
|
210591
|
+
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue, dumpRequestMutexes, dumpRequestMapMutex;
|
|
210364
210592
|
var init_dumpPrompts = __esm(() => {
|
|
210365
210593
|
init_state();
|
|
210366
210594
|
init_envUtils();
|
|
210367
210595
|
init_slowOperations();
|
|
210368
210596
|
init_debug();
|
|
210369
210597
|
init_log3();
|
|
210598
|
+
init_async_mutex();
|
|
210599
|
+
if (process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210600
|
+
logForDebugging("DUMP_PROMPTS is enabled. This will write full API payloads (including system prompts, user messages, and tool definitions) to the filesystem. This is intended for debugging only and should NOT be used in production.", { level: "warn" });
|
|
210601
|
+
}
|
|
210370
210602
|
cachedApiRequests = [];
|
|
210371
210603
|
dumpState = new Map;
|
|
210372
210604
|
dumpRequestQueue = new Map;
|
|
210373
|
-
|
|
210605
|
+
dumpRequestMutexes = new Map;
|
|
210606
|
+
dumpRequestMapMutex = new Mutex;
|
|
210374
210607
|
});
|
|
210375
210608
|
|
|
210376
210609
|
// src/utils/abortController.ts
|
|
@@ -300904,214 +301137,6 @@ var init_gracefulShutdown = __esm(() => {
|
|
|
300904
301137
|
};
|
|
300905
301138
|
});
|
|
300906
301139
|
|
|
300907
|
-
// node_modules/async-mutex/index.mjs
|
|
300908
|
-
class Semaphore {
|
|
300909
|
-
constructor(_value, _cancelError = E_CANCELED) {
|
|
300910
|
-
this._value = _value;
|
|
300911
|
-
this._cancelError = _cancelError;
|
|
300912
|
-
this._queue = [];
|
|
300913
|
-
this._weightedWaiters = [];
|
|
300914
|
-
}
|
|
300915
|
-
acquire(weight = 1, priority = 0) {
|
|
300916
|
-
if (weight <= 0)
|
|
300917
|
-
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300918
|
-
return new Promise((resolve28, reject2) => {
|
|
300919
|
-
const task = { resolve: resolve28, reject: reject2, weight, priority };
|
|
300920
|
-
const i3 = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
|
|
300921
|
-
if (i3 === -1 && weight <= this._value) {
|
|
300922
|
-
this._dispatchItem(task);
|
|
300923
|
-
} else {
|
|
300924
|
-
this._queue.splice(i3 + 1, 0, task);
|
|
300925
|
-
}
|
|
300926
|
-
});
|
|
300927
|
-
}
|
|
300928
|
-
runExclusive(callback_1) {
|
|
300929
|
-
return __awaiter$2(this, arguments, undefined, function* (callback, weight = 1, priority = 0) {
|
|
300930
|
-
const [value, release] = yield this.acquire(weight, priority);
|
|
300931
|
-
try {
|
|
300932
|
-
return yield callback(value);
|
|
300933
|
-
} finally {
|
|
300934
|
-
release();
|
|
300935
|
-
}
|
|
300936
|
-
});
|
|
300937
|
-
}
|
|
300938
|
-
waitForUnlock(weight = 1, priority = 0) {
|
|
300939
|
-
if (weight <= 0)
|
|
300940
|
-
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300941
|
-
if (this._couldLockImmediately(weight, priority)) {
|
|
300942
|
-
return Promise.resolve();
|
|
300943
|
-
} else {
|
|
300944
|
-
return new Promise((resolve28) => {
|
|
300945
|
-
if (!this._weightedWaiters[weight - 1])
|
|
300946
|
-
this._weightedWaiters[weight - 1] = [];
|
|
300947
|
-
insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve28, priority });
|
|
300948
|
-
});
|
|
300949
|
-
}
|
|
300950
|
-
}
|
|
300951
|
-
isLocked() {
|
|
300952
|
-
return this._value <= 0;
|
|
300953
|
-
}
|
|
300954
|
-
getValue() {
|
|
300955
|
-
return this._value;
|
|
300956
|
-
}
|
|
300957
|
-
setValue(value) {
|
|
300958
|
-
this._value = value;
|
|
300959
|
-
this._dispatchQueue();
|
|
300960
|
-
}
|
|
300961
|
-
release(weight = 1) {
|
|
300962
|
-
if (weight <= 0)
|
|
300963
|
-
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300964
|
-
this._value += weight;
|
|
300965
|
-
this._dispatchQueue();
|
|
300966
|
-
}
|
|
300967
|
-
cancel() {
|
|
300968
|
-
this._queue.forEach((entry) => entry.reject(this._cancelError));
|
|
300969
|
-
this._queue = [];
|
|
300970
|
-
}
|
|
300971
|
-
_dispatchQueue() {
|
|
300972
|
-
this._drainUnlockWaiters();
|
|
300973
|
-
while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
|
|
300974
|
-
this._dispatchItem(this._queue.shift());
|
|
300975
|
-
this._drainUnlockWaiters();
|
|
300976
|
-
}
|
|
300977
|
-
}
|
|
300978
|
-
_dispatchItem(item) {
|
|
300979
|
-
const previousValue = this._value;
|
|
300980
|
-
this._value -= item.weight;
|
|
300981
|
-
item.resolve([previousValue, this._newReleaser(item.weight)]);
|
|
300982
|
-
}
|
|
300983
|
-
_newReleaser(weight) {
|
|
300984
|
-
let called = false;
|
|
300985
|
-
return () => {
|
|
300986
|
-
if (called)
|
|
300987
|
-
return;
|
|
300988
|
-
called = true;
|
|
300989
|
-
this.release(weight);
|
|
300990
|
-
};
|
|
300991
|
-
}
|
|
300992
|
-
_drainUnlockWaiters() {
|
|
300993
|
-
if (this._queue.length === 0) {
|
|
300994
|
-
for (let weight = this._value;weight > 0; weight--) {
|
|
300995
|
-
const waiters = this._weightedWaiters[weight - 1];
|
|
300996
|
-
if (!waiters)
|
|
300997
|
-
continue;
|
|
300998
|
-
waiters.forEach((waiter) => waiter.resolve());
|
|
300999
|
-
this._weightedWaiters[weight - 1] = [];
|
|
301000
|
-
}
|
|
301001
|
-
} else {
|
|
301002
|
-
const queuedPriority = this._queue[0].priority;
|
|
301003
|
-
for (let weight = this._value;weight > 0; weight--) {
|
|
301004
|
-
const waiters = this._weightedWaiters[weight - 1];
|
|
301005
|
-
if (!waiters)
|
|
301006
|
-
continue;
|
|
301007
|
-
const i3 = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
|
|
301008
|
-
(i3 === -1 ? waiters : waiters.splice(0, i3)).forEach((waiter) => waiter.resolve());
|
|
301009
|
-
}
|
|
301010
|
-
}
|
|
301011
|
-
}
|
|
301012
|
-
_couldLockImmediately(weight, priority) {
|
|
301013
|
-
return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
|
|
301014
|
-
}
|
|
301015
|
-
}
|
|
301016
|
-
function insertSorted(a2, v2) {
|
|
301017
|
-
const i3 = findIndexFromEnd(a2, (other) => v2.priority <= other.priority);
|
|
301018
|
-
a2.splice(i3 + 1, 0, v2);
|
|
301019
|
-
}
|
|
301020
|
-
function findIndexFromEnd(a2, predicate) {
|
|
301021
|
-
for (let i3 = a2.length - 1;i3 >= 0; i3--) {
|
|
301022
|
-
if (predicate(a2[i3])) {
|
|
301023
|
-
return i3;
|
|
301024
|
-
}
|
|
301025
|
-
}
|
|
301026
|
-
return -1;
|
|
301027
|
-
}
|
|
301028
|
-
|
|
301029
|
-
class Mutex {
|
|
301030
|
-
constructor(cancelError) {
|
|
301031
|
-
this._semaphore = new Semaphore(1, cancelError);
|
|
301032
|
-
}
|
|
301033
|
-
acquire() {
|
|
301034
|
-
return __awaiter$1(this, arguments, undefined, function* (priority = 0) {
|
|
301035
|
-
const [, releaser] = yield this._semaphore.acquire(1, priority);
|
|
301036
|
-
return releaser;
|
|
301037
|
-
});
|
|
301038
|
-
}
|
|
301039
|
-
runExclusive(callback, priority = 0) {
|
|
301040
|
-
return this._semaphore.runExclusive(() => callback(), 1, priority);
|
|
301041
|
-
}
|
|
301042
|
-
isLocked() {
|
|
301043
|
-
return this._semaphore.isLocked();
|
|
301044
|
-
}
|
|
301045
|
-
waitForUnlock(priority = 0) {
|
|
301046
|
-
return this._semaphore.waitForUnlock(1, priority);
|
|
301047
|
-
}
|
|
301048
|
-
release() {
|
|
301049
|
-
if (this._semaphore.isLocked())
|
|
301050
|
-
this._semaphore.release();
|
|
301051
|
-
}
|
|
301052
|
-
cancel() {
|
|
301053
|
-
return this._semaphore.cancel();
|
|
301054
|
-
}
|
|
301055
|
-
}
|
|
301056
|
-
var E_TIMEOUT, E_ALREADY_LOCKED, E_CANCELED, __awaiter$2 = function(thisArg, _arguments, P2, generator) {
|
|
301057
|
-
function adopt(value) {
|
|
301058
|
-
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301059
|
-
resolve28(value);
|
|
301060
|
-
});
|
|
301061
|
-
}
|
|
301062
|
-
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301063
|
-
function fulfilled(value) {
|
|
301064
|
-
try {
|
|
301065
|
-
step(generator.next(value));
|
|
301066
|
-
} catch (e) {
|
|
301067
|
-
reject2(e);
|
|
301068
|
-
}
|
|
301069
|
-
}
|
|
301070
|
-
function rejected(value) {
|
|
301071
|
-
try {
|
|
301072
|
-
step(generator["throw"](value));
|
|
301073
|
-
} catch (e) {
|
|
301074
|
-
reject2(e);
|
|
301075
|
-
}
|
|
301076
|
-
}
|
|
301077
|
-
function step(result) {
|
|
301078
|
-
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301079
|
-
}
|
|
301080
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301081
|
-
});
|
|
301082
|
-
}, __awaiter$1 = function(thisArg, _arguments, P2, generator) {
|
|
301083
|
-
function adopt(value) {
|
|
301084
|
-
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301085
|
-
resolve28(value);
|
|
301086
|
-
});
|
|
301087
|
-
}
|
|
301088
|
-
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301089
|
-
function fulfilled(value) {
|
|
301090
|
-
try {
|
|
301091
|
-
step(generator.next(value));
|
|
301092
|
-
} catch (e) {
|
|
301093
|
-
reject2(e);
|
|
301094
|
-
}
|
|
301095
|
-
}
|
|
301096
|
-
function rejected(value) {
|
|
301097
|
-
try {
|
|
301098
|
-
step(generator["throw"](value));
|
|
301099
|
-
} catch (e) {
|
|
301100
|
-
reject2(e);
|
|
301101
|
-
}
|
|
301102
|
-
}
|
|
301103
|
-
function step(result) {
|
|
301104
|
-
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301105
|
-
}
|
|
301106
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301107
|
-
});
|
|
301108
|
-
};
|
|
301109
|
-
var init_async_mutex = __esm(() => {
|
|
301110
|
-
E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
301111
|
-
E_ALREADY_LOCKED = new Error("mutex already locked");
|
|
301112
|
-
E_CANCELED = new Error("request for lock canceled");
|
|
301113
|
-
});
|
|
301114
|
-
|
|
301115
301140
|
// src/services/api/grove.ts
|
|
301116
301141
|
function memoizeWithTTL(fn, ttlMs) {
|
|
301117
301142
|
let lastCachedAt = 0;
|
|
@@ -342303,21 +342328,21 @@ var init_KeybindingProviderSetup = __esm(() => {
|
|
|
342303
342328
|
});
|
|
342304
342329
|
|
|
342305
342330
|
// src/services/api/sessionIngress.ts
|
|
342306
|
-
function
|
|
342307
|
-
let
|
|
342308
|
-
if (!
|
|
342309
|
-
|
|
342310
|
-
|
|
342311
|
-
|
|
342312
|
-
|
|
342313
|
-
}
|
|
342314
|
-
|
|
342315
|
-
|
|
342316
|
-
|
|
342317
|
-
|
|
342318
|
-
|
|
342331
|
+
function getOrCreateSequential(sessionId) {
|
|
342332
|
+
let wrapper = sequentialBySession.get(sessionId);
|
|
342333
|
+
if (!wrapper) {
|
|
342334
|
+
wrapper = sequential(async (entryOrSid, url3, headers, isFetch = false) => {
|
|
342335
|
+
if (isFetch) {
|
|
342336
|
+
const sid = entryOrSid;
|
|
342337
|
+
return await fetchSessionLogsFromUrl(sid, url3, headers);
|
|
342338
|
+
} else {
|
|
342339
|
+
const entry = entryOrSid;
|
|
342340
|
+
return await appendSessionLogImpl(sessionId, entry, url3, headers);
|
|
342341
|
+
}
|
|
342342
|
+
});
|
|
342343
|
+
sequentialBySession.set(sessionId, wrapper);
|
|
342319
342344
|
}
|
|
342320
|
-
return
|
|
342345
|
+
return wrapper;
|
|
342321
342346
|
}
|
|
342322
342347
|
async function appendSessionLogImpl(sessionId, entry, url3, headers) {
|
|
342323
342348
|
for (let attempt = 1;attempt <= MAX_RETRIES; attempt++) {
|
|
@@ -342348,10 +342373,10 @@ async function appendSessionLogImpl(sessionId, entry, url3, headers) {
|
|
|
342348
342373
|
lastUuidMap.set(sessionId, serverLastUuid);
|
|
342349
342374
|
logForDebugging(`Session 409: adopting server lastUuid=${serverLastUuid} from header, retrying entry ${entry.uuid}`);
|
|
342350
342375
|
} else {
|
|
342351
|
-
const
|
|
342376
|
+
const sequential2 = getOrCreateSequential(sessionId);
|
|
342352
342377
|
let logs2 = null;
|
|
342353
342378
|
try {
|
|
342354
|
-
logs2 = await
|
|
342379
|
+
logs2 = await sequential2(sessionId, url3, headers, true);
|
|
342355
342380
|
} catch (fetchError) {
|
|
342356
342381
|
logError2(new Error(`Session 409: fetch failed for session ${sessionId}, entry ${entry.uuid}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`));
|
|
342357
342382
|
logForDiagnosticsNoPII("error", "session_persist_409_fetch_fail");
|
|
@@ -342409,8 +342434,8 @@ async function appendSessionLog(sessionId, entry, url3) {
|
|
|
342409
342434
|
Authorization: `Bearer ${sessionToken}`,
|
|
342410
342435
|
"Content-Type": "application/json"
|
|
342411
342436
|
};
|
|
342412
|
-
const
|
|
342413
|
-
return
|
|
342437
|
+
const sequential2 = getOrCreateSequential(sessionId);
|
|
342438
|
+
return sequential2(entry, url3, headers, false);
|
|
342414
342439
|
}
|
|
342415
342440
|
async function getSessionLogs(sessionId, url3) {
|
|
342416
342441
|
const sessionToken = getSessionIngressAuthToken();
|
|
@@ -342571,10 +342596,9 @@ function findLastUuid(logs2) {
|
|
|
342571
342596
|
}
|
|
342572
342597
|
function clearAllSessions() {
|
|
342573
342598
|
lastUuidMap.clear();
|
|
342574
|
-
|
|
342575
|
-
sequentialFetchBySession.clear();
|
|
342599
|
+
sequentialBySession.clear();
|
|
342576
342600
|
}
|
|
342577
|
-
var lastUuidMap, MAX_RETRIES = 10, BASE_DELAY_MS2 = 500,
|
|
342601
|
+
var lastUuidMap, MAX_RETRIES = 10, BASE_DELAY_MS2 = 500, sequentialBySession;
|
|
342578
342602
|
var init_sessionIngress = __esm(() => {
|
|
342579
342603
|
init_axios2();
|
|
342580
342604
|
init_oauth();
|
|
@@ -342586,8 +342610,7 @@ var init_sessionIngress = __esm(() => {
|
|
|
342586
342610
|
init_slowOperations();
|
|
342587
342611
|
init_api2();
|
|
342588
342612
|
lastUuidMap = new Map;
|
|
342589
|
-
|
|
342590
|
-
sequentialFetchBySession = new Map;
|
|
342613
|
+
sequentialBySession = new Map;
|
|
342591
342614
|
});
|
|
342592
342615
|
|
|
342593
342616
|
// src/utils/fileHistory.ts
|