@funnycode/myclaude 0.1.92 → 0.1.93
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 +257 -234
- package/dist/myclaude.mjs +257 -234
- 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.93",
|
|
8
|
+
BUILD_TIME: "2026-07-18T04:08:04.637Z",
|
|
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.93",
|
|
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) {
|
|
@@ -210228,6 +210444,7 @@ async function dumpRequest(body, ts, state, filePath) {
|
|
|
210228
210444
|
addApiRequestToCache(req);
|
|
210229
210445
|
if (process.env.USER_TYPE !== "ant" || process.env.DUMP_PROMPTS !== "1")
|
|
210230
210446
|
return;
|
|
210447
|
+
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
210448
|
const entries = [];
|
|
210232
210449
|
const messages = req.messages ?? [];
|
|
210233
210450
|
const fingerprint = initFingerprint(req);
|
|
@@ -210293,7 +210510,7 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210293
210510
|
const reader = cloned.body.getReader();
|
|
210294
210511
|
const decoder = new TextDecoder;
|
|
210295
210512
|
let buffer = "";
|
|
210296
|
-
const
|
|
210513
|
+
const chunkEntries = [];
|
|
210297
210514
|
try {
|
|
210298
210515
|
while (true) {
|
|
210299
210516
|
const { done, value } = await reader.read();
|
|
@@ -210313,7 +210530,12 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210313
210530
|
`)) {
|
|
210314
210531
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210315
210532
|
try {
|
|
210316
|
-
|
|
210533
|
+
const chunk = jsonParse(line.slice(6));
|
|
210534
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210535
|
+
if (chunkEntries.length >= 50) {
|
|
210536
|
+
await appendToFile(filePath, chunkEntries);
|
|
210537
|
+
chunkEntries.length = 0;
|
|
210538
|
+
}
|
|
210317
210539
|
} catch (err2) {
|
|
210318
210540
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210319
210541
|
}
|
|
@@ -210333,7 +210555,8 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210333
210555
|
`)) {
|
|
210334
210556
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210335
210557
|
try {
|
|
210336
|
-
|
|
210558
|
+
const chunk = jsonParse(line.slice(6));
|
|
210559
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210337
210560
|
} catch (err2) {
|
|
210338
210561
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210339
210562
|
}
|
|
@@ -210341,7 +210564,10 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210341
210564
|
}
|
|
210342
210565
|
}
|
|
210343
210566
|
}
|
|
210344
|
-
|
|
210567
|
+
if (chunkEntries.length > 0) {
|
|
210568
|
+
await appendToFile(filePath, chunkEntries);
|
|
210569
|
+
}
|
|
210570
|
+
data = { stream: true, chunks: [] };
|
|
210345
210571
|
} else {
|
|
210346
210572
|
data = await cloned.json();
|
|
210347
210573
|
}
|
|
@@ -210360,17 +210586,22 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210360
210586
|
return response;
|
|
210361
210587
|
};
|
|
210362
210588
|
}
|
|
210363
|
-
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue,
|
|
210589
|
+
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue, dumpRequestMutexes, dumpRequestMapMutex;
|
|
210364
210590
|
var init_dumpPrompts = __esm(() => {
|
|
210365
210591
|
init_state();
|
|
210366
210592
|
init_envUtils();
|
|
210367
210593
|
init_slowOperations();
|
|
210368
210594
|
init_debug();
|
|
210369
210595
|
init_log3();
|
|
210596
|
+
init_async_mutex();
|
|
210597
|
+
if (process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210598
|
+
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" });
|
|
210599
|
+
}
|
|
210370
210600
|
cachedApiRequests = [];
|
|
210371
210601
|
dumpState = new Map;
|
|
210372
210602
|
dumpRequestQueue = new Map;
|
|
210373
|
-
|
|
210603
|
+
dumpRequestMutexes = new Map;
|
|
210604
|
+
dumpRequestMapMutex = new Mutex;
|
|
210374
210605
|
});
|
|
210375
210606
|
|
|
210376
210607
|
// src/utils/abortController.ts
|
|
@@ -300904,214 +301135,6 @@ var init_gracefulShutdown = __esm(() => {
|
|
|
300904
301135
|
};
|
|
300905
301136
|
});
|
|
300906
301137
|
|
|
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
301138
|
// src/services/api/grove.ts
|
|
301116
301139
|
function memoizeWithTTL(fn, ttlMs) {
|
|
301117
301140
|
let lastCachedAt = 0;
|
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.93",
|
|
8
|
+
BUILD_TIME: "2026-07-18T04:08:04.637Z",
|
|
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.93",
|
|
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) {
|
|
@@ -210228,6 +210444,7 @@ async function dumpRequest(body, ts, state, filePath) {
|
|
|
210228
210444
|
addApiRequestToCache(req);
|
|
210229
210445
|
if (process.env.USER_TYPE !== "ant" || process.env.DUMP_PROMPTS !== "1")
|
|
210230
210446
|
return;
|
|
210447
|
+
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
210448
|
const entries = [];
|
|
210232
210449
|
const messages = req.messages ?? [];
|
|
210233
210450
|
const fingerprint = initFingerprint(req);
|
|
@@ -210293,7 +210510,7 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210293
210510
|
const reader = cloned.body.getReader();
|
|
210294
210511
|
const decoder = new TextDecoder;
|
|
210295
210512
|
let buffer = "";
|
|
210296
|
-
const
|
|
210513
|
+
const chunkEntries = [];
|
|
210297
210514
|
try {
|
|
210298
210515
|
while (true) {
|
|
210299
210516
|
const { done, value } = await reader.read();
|
|
@@ -210313,7 +210530,12 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210313
210530
|
`)) {
|
|
210314
210531
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210315
210532
|
try {
|
|
210316
|
-
|
|
210533
|
+
const chunk = jsonParse(line.slice(6));
|
|
210534
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210535
|
+
if (chunkEntries.length >= 50) {
|
|
210536
|
+
await appendToFile(filePath, chunkEntries);
|
|
210537
|
+
chunkEntries.length = 0;
|
|
210538
|
+
}
|
|
210317
210539
|
} catch (err2) {
|
|
210318
210540
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210319
210541
|
}
|
|
@@ -210333,7 +210555,8 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210333
210555
|
`)) {
|
|
210334
210556
|
if (line.startsWith("data: ") && line !== "data: [DONE]") {
|
|
210335
210557
|
try {
|
|
210336
|
-
|
|
210558
|
+
const chunk = jsonParse(line.slice(6));
|
|
210559
|
+
chunkEntries.push(jsonStringify({ type: "chunk", timestamp, data: chunk }));
|
|
210337
210560
|
} catch (err2) {
|
|
210338
210561
|
logForDebugging(`dumpPrompts.SSE parse error: ${err2}`, { level: "error" });
|
|
210339
210562
|
}
|
|
@@ -210341,7 +210564,10 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210341
210564
|
}
|
|
210342
210565
|
}
|
|
210343
210566
|
}
|
|
210344
|
-
|
|
210567
|
+
if (chunkEntries.length > 0) {
|
|
210568
|
+
await appendToFile(filePath, chunkEntries);
|
|
210569
|
+
}
|
|
210570
|
+
data = { stream: true, chunks: [] };
|
|
210345
210571
|
} else {
|
|
210346
210572
|
data = await cloned.json();
|
|
210347
210573
|
}
|
|
@@ -210360,17 +210586,22 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210360
210586
|
return response;
|
|
210361
210587
|
};
|
|
210362
210588
|
}
|
|
210363
|
-
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue,
|
|
210589
|
+
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue, dumpRequestMutexes, dumpRequestMapMutex;
|
|
210364
210590
|
var init_dumpPrompts = __esm(() => {
|
|
210365
210591
|
init_state();
|
|
210366
210592
|
init_envUtils();
|
|
210367
210593
|
init_slowOperations();
|
|
210368
210594
|
init_debug();
|
|
210369
210595
|
init_log3();
|
|
210596
|
+
init_async_mutex();
|
|
210597
|
+
if (process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210598
|
+
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" });
|
|
210599
|
+
}
|
|
210370
210600
|
cachedApiRequests = [];
|
|
210371
210601
|
dumpState = new Map;
|
|
210372
210602
|
dumpRequestQueue = new Map;
|
|
210373
|
-
|
|
210603
|
+
dumpRequestMutexes = new Map;
|
|
210604
|
+
dumpRequestMapMutex = new Mutex;
|
|
210374
210605
|
});
|
|
210375
210606
|
|
|
210376
210607
|
// src/utils/abortController.ts
|
|
@@ -300904,214 +301135,6 @@ var init_gracefulShutdown = __esm(() => {
|
|
|
300904
301135
|
};
|
|
300905
301136
|
});
|
|
300906
301137
|
|
|
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
301138
|
// src/services/api/grove.ts
|
|
301116
301139
|
function memoizeWithTTL(fn, ttlMs) {
|
|
301117
301140
|
let lastCachedAt = 0;
|