@funnycode/myclaude 0.1.95 → 0.1.96
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 +269 -277
- package/dist/myclaude.mjs +269 -277
- 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.96",
|
|
8
|
+
BUILD_TIME: "2026-07-18T10:50:58.819Z",
|
|
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.96",
|
|
117488
117488
|
private: false,
|
|
117489
117489
|
description: "An open-source AI coding assistant in your terminal - powered by Claude",
|
|
117490
117490
|
license: "MIT",
|
|
@@ -210146,214 +210146,6 @@ 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
|
-
|
|
210357
210149
|
// src/services/api/dumpPrompts.ts
|
|
210358
210150
|
import { createHash as createHash5 } from "crypto";
|
|
210359
210151
|
import { promises as fs11 } from "fs";
|
|
@@ -210366,34 +210158,24 @@ function enqueueDumpRequest(agentIdOrSessionId, callback) {
|
|
|
210366
210158
|
dumpRequestQueue.set(agentIdOrSessionId, []);
|
|
210367
210159
|
}
|
|
210368
210160
|
dumpRequestQueue.get(agentIdOrSessionId).push(callback);
|
|
210369
|
-
|
|
210161
|
+
if (!processingFlags.has(agentIdOrSessionId)) {
|
|
210162
|
+
processingFlags.add(agentIdOrSessionId);
|
|
210163
|
+
processQueue(agentIdOrSessionId);
|
|
210164
|
+
}
|
|
210370
210165
|
}
|
|
210371
210166
|
async function processQueue(agentIdOrSessionId) {
|
|
210372
|
-
const mapRelease = await dumpRequestMapMutex.acquire();
|
|
210373
|
-
let mutex = dumpRequestMutexes.get(agentIdOrSessionId);
|
|
210374
|
-
if (!mutex) {
|
|
210375
|
-
mutex = new Mutex;
|
|
210376
|
-
dumpRequestMutexes.set(agentIdOrSessionId, mutex);
|
|
210377
|
-
}
|
|
210378
|
-
mapRelease();
|
|
210379
|
-
const release = await mutex.acquire();
|
|
210380
210167
|
try {
|
|
210381
|
-
|
|
210382
|
-
|
|
210383
|
-
|
|
210384
|
-
|
|
210385
|
-
|
|
210386
|
-
|
|
210387
|
-
|
|
210388
|
-
await callback();
|
|
210389
|
-
if (queue.length > 0) {
|
|
210390
|
-
setImmediate(() => processQueue(agentIdOrSessionId));
|
|
210391
|
-
} else {
|
|
210392
|
-
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210393
|
-
dumpRequestMutexes.delete(agentIdOrSessionId);
|
|
210168
|
+
while (true) {
|
|
210169
|
+
const queue = dumpRequestQueue.get(agentIdOrSessionId);
|
|
210170
|
+
if (!queue || queue.length === 0) {
|
|
210171
|
+
break;
|
|
210172
|
+
}
|
|
210173
|
+
const callback = queue.shift();
|
|
210174
|
+
await callback();
|
|
210394
210175
|
}
|
|
210395
210176
|
} finally {
|
|
210396
|
-
|
|
210177
|
+
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210178
|
+
processingFlags.delete(agentIdOrSessionId);
|
|
210397
210179
|
}
|
|
210398
210180
|
}
|
|
210399
210181
|
function clearDumpState(agentIdOrSessionId) {
|
|
@@ -210590,22 +210372,20 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210590
210372
|
return response;
|
|
210591
210373
|
};
|
|
210592
210374
|
}
|
|
210593
|
-
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue,
|
|
210375
|
+
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue, processingFlags;
|
|
210594
210376
|
var init_dumpPrompts = __esm(() => {
|
|
210595
210377
|
init_state();
|
|
210596
210378
|
init_envUtils();
|
|
210597
210379
|
init_slowOperations();
|
|
210598
210380
|
init_debug();
|
|
210599
210381
|
init_log3();
|
|
210600
|
-
init_async_mutex();
|
|
210601
210382
|
if (process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210602
210383
|
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" });
|
|
210603
210384
|
}
|
|
210604
210385
|
cachedApiRequests = [];
|
|
210605
210386
|
dumpState = new Map;
|
|
210606
210387
|
dumpRequestQueue = new Map;
|
|
210607
|
-
|
|
210608
|
-
dumpRequestMapMutex = new Mutex;
|
|
210388
|
+
processingFlags = new Set;
|
|
210609
210389
|
});
|
|
210610
210390
|
|
|
210611
210391
|
// src/utils/abortController.ts
|
|
@@ -301139,6 +300919,214 @@ var init_gracefulShutdown = __esm(() => {
|
|
|
301139
300919
|
};
|
|
301140
300920
|
});
|
|
301141
300921
|
|
|
300922
|
+
// node_modules/async-mutex/index.mjs
|
|
300923
|
+
class Semaphore {
|
|
300924
|
+
constructor(_value, _cancelError = E_CANCELED) {
|
|
300925
|
+
this._value = _value;
|
|
300926
|
+
this._cancelError = _cancelError;
|
|
300927
|
+
this._queue = [];
|
|
300928
|
+
this._weightedWaiters = [];
|
|
300929
|
+
}
|
|
300930
|
+
acquire(weight = 1, priority = 0) {
|
|
300931
|
+
if (weight <= 0)
|
|
300932
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300933
|
+
return new Promise((resolve28, reject2) => {
|
|
300934
|
+
const task = { resolve: resolve28, reject: reject2, weight, priority };
|
|
300935
|
+
const i3 = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
|
|
300936
|
+
if (i3 === -1 && weight <= this._value) {
|
|
300937
|
+
this._dispatchItem(task);
|
|
300938
|
+
} else {
|
|
300939
|
+
this._queue.splice(i3 + 1, 0, task);
|
|
300940
|
+
}
|
|
300941
|
+
});
|
|
300942
|
+
}
|
|
300943
|
+
runExclusive(callback_1) {
|
|
300944
|
+
return __awaiter$2(this, arguments, undefined, function* (callback, weight = 1, priority = 0) {
|
|
300945
|
+
const [value, release] = yield this.acquire(weight, priority);
|
|
300946
|
+
try {
|
|
300947
|
+
return yield callback(value);
|
|
300948
|
+
} finally {
|
|
300949
|
+
release();
|
|
300950
|
+
}
|
|
300951
|
+
});
|
|
300952
|
+
}
|
|
300953
|
+
waitForUnlock(weight = 1, priority = 0) {
|
|
300954
|
+
if (weight <= 0)
|
|
300955
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300956
|
+
if (this._couldLockImmediately(weight, priority)) {
|
|
300957
|
+
return Promise.resolve();
|
|
300958
|
+
} else {
|
|
300959
|
+
return new Promise((resolve28) => {
|
|
300960
|
+
if (!this._weightedWaiters[weight - 1])
|
|
300961
|
+
this._weightedWaiters[weight - 1] = [];
|
|
300962
|
+
insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve28, priority });
|
|
300963
|
+
});
|
|
300964
|
+
}
|
|
300965
|
+
}
|
|
300966
|
+
isLocked() {
|
|
300967
|
+
return this._value <= 0;
|
|
300968
|
+
}
|
|
300969
|
+
getValue() {
|
|
300970
|
+
return this._value;
|
|
300971
|
+
}
|
|
300972
|
+
setValue(value) {
|
|
300973
|
+
this._value = value;
|
|
300974
|
+
this._dispatchQueue();
|
|
300975
|
+
}
|
|
300976
|
+
release(weight = 1) {
|
|
300977
|
+
if (weight <= 0)
|
|
300978
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300979
|
+
this._value += weight;
|
|
300980
|
+
this._dispatchQueue();
|
|
300981
|
+
}
|
|
300982
|
+
cancel() {
|
|
300983
|
+
this._queue.forEach((entry) => entry.reject(this._cancelError));
|
|
300984
|
+
this._queue = [];
|
|
300985
|
+
}
|
|
300986
|
+
_dispatchQueue() {
|
|
300987
|
+
this._drainUnlockWaiters();
|
|
300988
|
+
while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
|
|
300989
|
+
this._dispatchItem(this._queue.shift());
|
|
300990
|
+
this._drainUnlockWaiters();
|
|
300991
|
+
}
|
|
300992
|
+
}
|
|
300993
|
+
_dispatchItem(item) {
|
|
300994
|
+
const previousValue = this._value;
|
|
300995
|
+
this._value -= item.weight;
|
|
300996
|
+
item.resolve([previousValue, this._newReleaser(item.weight)]);
|
|
300997
|
+
}
|
|
300998
|
+
_newReleaser(weight) {
|
|
300999
|
+
let called = false;
|
|
301000
|
+
return () => {
|
|
301001
|
+
if (called)
|
|
301002
|
+
return;
|
|
301003
|
+
called = true;
|
|
301004
|
+
this.release(weight);
|
|
301005
|
+
};
|
|
301006
|
+
}
|
|
301007
|
+
_drainUnlockWaiters() {
|
|
301008
|
+
if (this._queue.length === 0) {
|
|
301009
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
301010
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
301011
|
+
if (!waiters)
|
|
301012
|
+
continue;
|
|
301013
|
+
waiters.forEach((waiter) => waiter.resolve());
|
|
301014
|
+
this._weightedWaiters[weight - 1] = [];
|
|
301015
|
+
}
|
|
301016
|
+
} else {
|
|
301017
|
+
const queuedPriority = this._queue[0].priority;
|
|
301018
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
301019
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
301020
|
+
if (!waiters)
|
|
301021
|
+
continue;
|
|
301022
|
+
const i3 = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
|
|
301023
|
+
(i3 === -1 ? waiters : waiters.splice(0, i3)).forEach((waiter) => waiter.resolve());
|
|
301024
|
+
}
|
|
301025
|
+
}
|
|
301026
|
+
}
|
|
301027
|
+
_couldLockImmediately(weight, priority) {
|
|
301028
|
+
return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
|
|
301029
|
+
}
|
|
301030
|
+
}
|
|
301031
|
+
function insertSorted(a2, v2) {
|
|
301032
|
+
const i3 = findIndexFromEnd(a2, (other) => v2.priority <= other.priority);
|
|
301033
|
+
a2.splice(i3 + 1, 0, v2);
|
|
301034
|
+
}
|
|
301035
|
+
function findIndexFromEnd(a2, predicate) {
|
|
301036
|
+
for (let i3 = a2.length - 1;i3 >= 0; i3--) {
|
|
301037
|
+
if (predicate(a2[i3])) {
|
|
301038
|
+
return i3;
|
|
301039
|
+
}
|
|
301040
|
+
}
|
|
301041
|
+
return -1;
|
|
301042
|
+
}
|
|
301043
|
+
|
|
301044
|
+
class Mutex {
|
|
301045
|
+
constructor(cancelError) {
|
|
301046
|
+
this._semaphore = new Semaphore(1, cancelError);
|
|
301047
|
+
}
|
|
301048
|
+
acquire() {
|
|
301049
|
+
return __awaiter$1(this, arguments, undefined, function* (priority = 0) {
|
|
301050
|
+
const [, releaser] = yield this._semaphore.acquire(1, priority);
|
|
301051
|
+
return releaser;
|
|
301052
|
+
});
|
|
301053
|
+
}
|
|
301054
|
+
runExclusive(callback, priority = 0) {
|
|
301055
|
+
return this._semaphore.runExclusive(() => callback(), 1, priority);
|
|
301056
|
+
}
|
|
301057
|
+
isLocked() {
|
|
301058
|
+
return this._semaphore.isLocked();
|
|
301059
|
+
}
|
|
301060
|
+
waitForUnlock(priority = 0) {
|
|
301061
|
+
return this._semaphore.waitForUnlock(1, priority);
|
|
301062
|
+
}
|
|
301063
|
+
release() {
|
|
301064
|
+
if (this._semaphore.isLocked())
|
|
301065
|
+
this._semaphore.release();
|
|
301066
|
+
}
|
|
301067
|
+
cancel() {
|
|
301068
|
+
return this._semaphore.cancel();
|
|
301069
|
+
}
|
|
301070
|
+
}
|
|
301071
|
+
var E_TIMEOUT, E_ALREADY_LOCKED, E_CANCELED, __awaiter$2 = function(thisArg, _arguments, P2, generator) {
|
|
301072
|
+
function adopt(value) {
|
|
301073
|
+
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301074
|
+
resolve28(value);
|
|
301075
|
+
});
|
|
301076
|
+
}
|
|
301077
|
+
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301078
|
+
function fulfilled(value) {
|
|
301079
|
+
try {
|
|
301080
|
+
step(generator.next(value));
|
|
301081
|
+
} catch (e) {
|
|
301082
|
+
reject2(e);
|
|
301083
|
+
}
|
|
301084
|
+
}
|
|
301085
|
+
function rejected(value) {
|
|
301086
|
+
try {
|
|
301087
|
+
step(generator["throw"](value));
|
|
301088
|
+
} catch (e) {
|
|
301089
|
+
reject2(e);
|
|
301090
|
+
}
|
|
301091
|
+
}
|
|
301092
|
+
function step(result) {
|
|
301093
|
+
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301094
|
+
}
|
|
301095
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301096
|
+
});
|
|
301097
|
+
}, __awaiter$1 = function(thisArg, _arguments, P2, generator) {
|
|
301098
|
+
function adopt(value) {
|
|
301099
|
+
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301100
|
+
resolve28(value);
|
|
301101
|
+
});
|
|
301102
|
+
}
|
|
301103
|
+
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301104
|
+
function fulfilled(value) {
|
|
301105
|
+
try {
|
|
301106
|
+
step(generator.next(value));
|
|
301107
|
+
} catch (e) {
|
|
301108
|
+
reject2(e);
|
|
301109
|
+
}
|
|
301110
|
+
}
|
|
301111
|
+
function rejected(value) {
|
|
301112
|
+
try {
|
|
301113
|
+
step(generator["throw"](value));
|
|
301114
|
+
} catch (e) {
|
|
301115
|
+
reject2(e);
|
|
301116
|
+
}
|
|
301117
|
+
}
|
|
301118
|
+
function step(result) {
|
|
301119
|
+
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301120
|
+
}
|
|
301121
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301122
|
+
});
|
|
301123
|
+
};
|
|
301124
|
+
var init_async_mutex = __esm(() => {
|
|
301125
|
+
E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
301126
|
+
E_ALREADY_LOCKED = new Error("mutex already locked");
|
|
301127
|
+
E_CANCELED = new Error("request for lock canceled");
|
|
301128
|
+
});
|
|
301129
|
+
|
|
301142
301130
|
// src/services/api/grove.ts
|
|
301143
301131
|
function memoizeWithTTL(fn, ttlMs) {
|
|
301144
301132
|
let lastCachedAt = 0;
|
|
@@ -453788,17 +453776,36 @@ var init_FeedColumn = __esm(() => {
|
|
|
453788
453776
|
// src/services/api/referral.ts
|
|
453789
453777
|
async function fetchReferralEligibility(campaign = "claude_code_guest_pass") {
|
|
453790
453778
|
const { accessToken, orgUUID } = await prepareApiRequest();
|
|
453779
|
+
const existingPromise = fetchInProgressMap.get(orgUUID);
|
|
453780
|
+
if (existingPromise) {
|
|
453781
|
+
logForDebugging(`Passes: Reusing in-flight eligibility fetch for org ${orgUUID}`);
|
|
453782
|
+
return existingPromise;
|
|
453783
|
+
}
|
|
453791
453784
|
const headers = {
|
|
453792
453785
|
...getOAuthHeaders(accessToken),
|
|
453793
453786
|
"x-organization-uuid": orgUUID
|
|
453794
453787
|
};
|
|
453795
453788
|
const url3 = `${getOauthConfig().BASE_API_URL}/api/oauth/organizations/${orgUUID}/referral/eligibility`;
|
|
453796
|
-
|
|
453797
|
-
|
|
453798
|
-
|
|
453799
|
-
timeout: 5000
|
|
453789
|
+
let resolvePromise;
|
|
453790
|
+
const promise3 = new Promise((resolve47) => {
|
|
453791
|
+
resolvePromise = resolve47;
|
|
453800
453792
|
});
|
|
453801
|
-
|
|
453793
|
+
fetchInProgressMap.set(orgUUID, promise3);
|
|
453794
|
+
(async () => {
|
|
453795
|
+
try {
|
|
453796
|
+
const response = await axios_default.get(url3, {
|
|
453797
|
+
headers,
|
|
453798
|
+
params: { campaign },
|
|
453799
|
+
timeout: 5000
|
|
453800
|
+
});
|
|
453801
|
+
resolvePromise(response.data);
|
|
453802
|
+
} catch (error49) {
|
|
453803
|
+
logError2(error49);
|
|
453804
|
+
fetchInProgressMap.delete(orgUUID);
|
|
453805
|
+
throw error49;
|
|
453806
|
+
}
|
|
453807
|
+
})();
|
|
453808
|
+
return promise3;
|
|
453802
453809
|
}
|
|
453803
453810
|
async function fetchReferralRedemptions(campaign = "claude_code_guest_pass") {
|
|
453804
453811
|
const { accessToken, orgUUID } = await prepareApiRequest();
|
|
@@ -453878,41 +453885,26 @@ async function fetchAndStorePassesEligibility() {
|
|
|
453878
453885
|
if (!orgId) {
|
|
453879
453886
|
return null;
|
|
453880
453887
|
}
|
|
453881
|
-
|
|
453882
|
-
|
|
453883
|
-
|
|
453884
|
-
|
|
453888
|
+
try {
|
|
453889
|
+
const response = await fetchReferralEligibility();
|
|
453890
|
+
const cacheEntry = {
|
|
453891
|
+
...response,
|
|
453892
|
+
timestamp: Date.now()
|
|
453893
|
+
};
|
|
453894
|
+
saveGlobalConfig((current) => ({
|
|
453895
|
+
...current,
|
|
453896
|
+
passesEligibilityCache: {
|
|
453897
|
+
...current.passesEligibilityCache,
|
|
453898
|
+
[orgId]: cacheEntry
|
|
453899
|
+
}
|
|
453900
|
+
}));
|
|
453901
|
+
logForDebugging(`Passes eligibility cached for org ${orgId}: ${response.eligible}`);
|
|
453902
|
+
return response;
|
|
453903
|
+
} catch (error49) {
|
|
453904
|
+
logForDebugging("Failed to fetch and cache passes eligibility");
|
|
453905
|
+
logError2(error49);
|
|
453906
|
+
return null;
|
|
453885
453907
|
}
|
|
453886
|
-
let resolvePromise;
|
|
453887
|
-
const promise3 = new Promise((resolve47) => {
|
|
453888
|
-
resolvePromise = resolve47;
|
|
453889
|
-
});
|
|
453890
|
-
fetchInProgressMap.set(orgId, promise3);
|
|
453891
|
-
(async () => {
|
|
453892
|
-
try {
|
|
453893
|
-
const response = await fetchReferralEligibility();
|
|
453894
|
-
const cacheEntry = {
|
|
453895
|
-
...response,
|
|
453896
|
-
timestamp: Date.now()
|
|
453897
|
-
};
|
|
453898
|
-
saveGlobalConfig((current) => ({
|
|
453899
|
-
...current,
|
|
453900
|
-
passesEligibilityCache: {
|
|
453901
|
-
...current.passesEligibilityCache,
|
|
453902
|
-
[orgId]: cacheEntry
|
|
453903
|
-
}
|
|
453904
|
-
}));
|
|
453905
|
-
logForDebugging(`Passes eligibility cached for org ${orgId}: ${response.eligible}`);
|
|
453906
|
-
resolvePromise(response);
|
|
453907
|
-
} catch (error49) {
|
|
453908
|
-
logForDebugging("Failed to fetch and cache passes eligibility");
|
|
453909
|
-
logError2(error49);
|
|
453910
|
-
resolvePromise(null);
|
|
453911
|
-
} finally {
|
|
453912
|
-
fetchInProgressMap.delete(orgId);
|
|
453913
|
-
}
|
|
453914
|
-
})();
|
|
453915
|
-
return promise3;
|
|
453916
453908
|
}
|
|
453917
453909
|
async function getCachedOrFetchPassesEligibility() {
|
|
453918
453910
|
if (!shouldCheckForPasses()) {
|
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.96",
|
|
8
|
+
BUILD_TIME: "2026-07-18T10:50:58.819Z",
|
|
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.96",
|
|
117488
117488
|
private: false,
|
|
117489
117489
|
description: "An open-source AI coding assistant in your terminal - powered by Claude",
|
|
117490
117490
|
license: "MIT",
|
|
@@ -210146,214 +210146,6 @@ 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
|
-
|
|
210357
210149
|
// src/services/api/dumpPrompts.ts
|
|
210358
210150
|
import { createHash as createHash5 } from "crypto";
|
|
210359
210151
|
import { promises as fs11 } from "fs";
|
|
@@ -210366,34 +210158,24 @@ function enqueueDumpRequest(agentIdOrSessionId, callback) {
|
|
|
210366
210158
|
dumpRequestQueue.set(agentIdOrSessionId, []);
|
|
210367
210159
|
}
|
|
210368
210160
|
dumpRequestQueue.get(agentIdOrSessionId).push(callback);
|
|
210369
|
-
|
|
210161
|
+
if (!processingFlags.has(agentIdOrSessionId)) {
|
|
210162
|
+
processingFlags.add(agentIdOrSessionId);
|
|
210163
|
+
processQueue(agentIdOrSessionId);
|
|
210164
|
+
}
|
|
210370
210165
|
}
|
|
210371
210166
|
async function processQueue(agentIdOrSessionId) {
|
|
210372
|
-
const mapRelease = await dumpRequestMapMutex.acquire();
|
|
210373
|
-
let mutex = dumpRequestMutexes.get(agentIdOrSessionId);
|
|
210374
|
-
if (!mutex) {
|
|
210375
|
-
mutex = new Mutex;
|
|
210376
|
-
dumpRequestMutexes.set(agentIdOrSessionId, mutex);
|
|
210377
|
-
}
|
|
210378
|
-
mapRelease();
|
|
210379
|
-
const release = await mutex.acquire();
|
|
210380
210167
|
try {
|
|
210381
|
-
|
|
210382
|
-
|
|
210383
|
-
|
|
210384
|
-
|
|
210385
|
-
|
|
210386
|
-
|
|
210387
|
-
|
|
210388
|
-
await callback();
|
|
210389
|
-
if (queue.length > 0) {
|
|
210390
|
-
setImmediate(() => processQueue(agentIdOrSessionId));
|
|
210391
|
-
} else {
|
|
210392
|
-
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210393
|
-
dumpRequestMutexes.delete(agentIdOrSessionId);
|
|
210168
|
+
while (true) {
|
|
210169
|
+
const queue = dumpRequestQueue.get(agentIdOrSessionId);
|
|
210170
|
+
if (!queue || queue.length === 0) {
|
|
210171
|
+
break;
|
|
210172
|
+
}
|
|
210173
|
+
const callback = queue.shift();
|
|
210174
|
+
await callback();
|
|
210394
210175
|
}
|
|
210395
210176
|
} finally {
|
|
210396
|
-
|
|
210177
|
+
dumpRequestQueue.delete(agentIdOrSessionId);
|
|
210178
|
+
processingFlags.delete(agentIdOrSessionId);
|
|
210397
210179
|
}
|
|
210398
210180
|
}
|
|
210399
210181
|
function clearDumpState(agentIdOrSessionId) {
|
|
@@ -210590,22 +210372,20 @@ function createDumpPromptsFetch(agentIdOrSessionId) {
|
|
|
210590
210372
|
return response;
|
|
210591
210373
|
};
|
|
210592
210374
|
}
|
|
210593
|
-
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue,
|
|
210375
|
+
var MAX_CACHED_REQUESTS = 5, cachedApiRequests, dumpState, dumpRequestQueue, processingFlags;
|
|
210594
210376
|
var init_dumpPrompts = __esm(() => {
|
|
210595
210377
|
init_state();
|
|
210596
210378
|
init_envUtils();
|
|
210597
210379
|
init_slowOperations();
|
|
210598
210380
|
init_debug();
|
|
210599
210381
|
init_log3();
|
|
210600
|
-
init_async_mutex();
|
|
210601
210382
|
if (process.env.USER_TYPE === "ant" && process.env.DUMP_PROMPTS === "1") {
|
|
210602
210383
|
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" });
|
|
210603
210384
|
}
|
|
210604
210385
|
cachedApiRequests = [];
|
|
210605
210386
|
dumpState = new Map;
|
|
210606
210387
|
dumpRequestQueue = new Map;
|
|
210607
|
-
|
|
210608
|
-
dumpRequestMapMutex = new Mutex;
|
|
210388
|
+
processingFlags = new Set;
|
|
210609
210389
|
});
|
|
210610
210390
|
|
|
210611
210391
|
// src/utils/abortController.ts
|
|
@@ -301139,6 +300919,214 @@ var init_gracefulShutdown = __esm(() => {
|
|
|
301139
300919
|
};
|
|
301140
300920
|
});
|
|
301141
300921
|
|
|
300922
|
+
// node_modules/async-mutex/index.mjs
|
|
300923
|
+
class Semaphore {
|
|
300924
|
+
constructor(_value, _cancelError = E_CANCELED) {
|
|
300925
|
+
this._value = _value;
|
|
300926
|
+
this._cancelError = _cancelError;
|
|
300927
|
+
this._queue = [];
|
|
300928
|
+
this._weightedWaiters = [];
|
|
300929
|
+
}
|
|
300930
|
+
acquire(weight = 1, priority = 0) {
|
|
300931
|
+
if (weight <= 0)
|
|
300932
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300933
|
+
return new Promise((resolve28, reject2) => {
|
|
300934
|
+
const task = { resolve: resolve28, reject: reject2, weight, priority };
|
|
300935
|
+
const i3 = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
|
|
300936
|
+
if (i3 === -1 && weight <= this._value) {
|
|
300937
|
+
this._dispatchItem(task);
|
|
300938
|
+
} else {
|
|
300939
|
+
this._queue.splice(i3 + 1, 0, task);
|
|
300940
|
+
}
|
|
300941
|
+
});
|
|
300942
|
+
}
|
|
300943
|
+
runExclusive(callback_1) {
|
|
300944
|
+
return __awaiter$2(this, arguments, undefined, function* (callback, weight = 1, priority = 0) {
|
|
300945
|
+
const [value, release] = yield this.acquire(weight, priority);
|
|
300946
|
+
try {
|
|
300947
|
+
return yield callback(value);
|
|
300948
|
+
} finally {
|
|
300949
|
+
release();
|
|
300950
|
+
}
|
|
300951
|
+
});
|
|
300952
|
+
}
|
|
300953
|
+
waitForUnlock(weight = 1, priority = 0) {
|
|
300954
|
+
if (weight <= 0)
|
|
300955
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300956
|
+
if (this._couldLockImmediately(weight, priority)) {
|
|
300957
|
+
return Promise.resolve();
|
|
300958
|
+
} else {
|
|
300959
|
+
return new Promise((resolve28) => {
|
|
300960
|
+
if (!this._weightedWaiters[weight - 1])
|
|
300961
|
+
this._weightedWaiters[weight - 1] = [];
|
|
300962
|
+
insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve28, priority });
|
|
300963
|
+
});
|
|
300964
|
+
}
|
|
300965
|
+
}
|
|
300966
|
+
isLocked() {
|
|
300967
|
+
return this._value <= 0;
|
|
300968
|
+
}
|
|
300969
|
+
getValue() {
|
|
300970
|
+
return this._value;
|
|
300971
|
+
}
|
|
300972
|
+
setValue(value) {
|
|
300973
|
+
this._value = value;
|
|
300974
|
+
this._dispatchQueue();
|
|
300975
|
+
}
|
|
300976
|
+
release(weight = 1) {
|
|
300977
|
+
if (weight <= 0)
|
|
300978
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
300979
|
+
this._value += weight;
|
|
300980
|
+
this._dispatchQueue();
|
|
300981
|
+
}
|
|
300982
|
+
cancel() {
|
|
300983
|
+
this._queue.forEach((entry) => entry.reject(this._cancelError));
|
|
300984
|
+
this._queue = [];
|
|
300985
|
+
}
|
|
300986
|
+
_dispatchQueue() {
|
|
300987
|
+
this._drainUnlockWaiters();
|
|
300988
|
+
while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
|
|
300989
|
+
this._dispatchItem(this._queue.shift());
|
|
300990
|
+
this._drainUnlockWaiters();
|
|
300991
|
+
}
|
|
300992
|
+
}
|
|
300993
|
+
_dispatchItem(item) {
|
|
300994
|
+
const previousValue = this._value;
|
|
300995
|
+
this._value -= item.weight;
|
|
300996
|
+
item.resolve([previousValue, this._newReleaser(item.weight)]);
|
|
300997
|
+
}
|
|
300998
|
+
_newReleaser(weight) {
|
|
300999
|
+
let called = false;
|
|
301000
|
+
return () => {
|
|
301001
|
+
if (called)
|
|
301002
|
+
return;
|
|
301003
|
+
called = true;
|
|
301004
|
+
this.release(weight);
|
|
301005
|
+
};
|
|
301006
|
+
}
|
|
301007
|
+
_drainUnlockWaiters() {
|
|
301008
|
+
if (this._queue.length === 0) {
|
|
301009
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
301010
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
301011
|
+
if (!waiters)
|
|
301012
|
+
continue;
|
|
301013
|
+
waiters.forEach((waiter) => waiter.resolve());
|
|
301014
|
+
this._weightedWaiters[weight - 1] = [];
|
|
301015
|
+
}
|
|
301016
|
+
} else {
|
|
301017
|
+
const queuedPriority = this._queue[0].priority;
|
|
301018
|
+
for (let weight = this._value;weight > 0; weight--) {
|
|
301019
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
301020
|
+
if (!waiters)
|
|
301021
|
+
continue;
|
|
301022
|
+
const i3 = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
|
|
301023
|
+
(i3 === -1 ? waiters : waiters.splice(0, i3)).forEach((waiter) => waiter.resolve());
|
|
301024
|
+
}
|
|
301025
|
+
}
|
|
301026
|
+
}
|
|
301027
|
+
_couldLockImmediately(weight, priority) {
|
|
301028
|
+
return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
|
|
301029
|
+
}
|
|
301030
|
+
}
|
|
301031
|
+
function insertSorted(a2, v2) {
|
|
301032
|
+
const i3 = findIndexFromEnd(a2, (other) => v2.priority <= other.priority);
|
|
301033
|
+
a2.splice(i3 + 1, 0, v2);
|
|
301034
|
+
}
|
|
301035
|
+
function findIndexFromEnd(a2, predicate) {
|
|
301036
|
+
for (let i3 = a2.length - 1;i3 >= 0; i3--) {
|
|
301037
|
+
if (predicate(a2[i3])) {
|
|
301038
|
+
return i3;
|
|
301039
|
+
}
|
|
301040
|
+
}
|
|
301041
|
+
return -1;
|
|
301042
|
+
}
|
|
301043
|
+
|
|
301044
|
+
class Mutex {
|
|
301045
|
+
constructor(cancelError) {
|
|
301046
|
+
this._semaphore = new Semaphore(1, cancelError);
|
|
301047
|
+
}
|
|
301048
|
+
acquire() {
|
|
301049
|
+
return __awaiter$1(this, arguments, undefined, function* (priority = 0) {
|
|
301050
|
+
const [, releaser] = yield this._semaphore.acquire(1, priority);
|
|
301051
|
+
return releaser;
|
|
301052
|
+
});
|
|
301053
|
+
}
|
|
301054
|
+
runExclusive(callback, priority = 0) {
|
|
301055
|
+
return this._semaphore.runExclusive(() => callback(), 1, priority);
|
|
301056
|
+
}
|
|
301057
|
+
isLocked() {
|
|
301058
|
+
return this._semaphore.isLocked();
|
|
301059
|
+
}
|
|
301060
|
+
waitForUnlock(priority = 0) {
|
|
301061
|
+
return this._semaphore.waitForUnlock(1, priority);
|
|
301062
|
+
}
|
|
301063
|
+
release() {
|
|
301064
|
+
if (this._semaphore.isLocked())
|
|
301065
|
+
this._semaphore.release();
|
|
301066
|
+
}
|
|
301067
|
+
cancel() {
|
|
301068
|
+
return this._semaphore.cancel();
|
|
301069
|
+
}
|
|
301070
|
+
}
|
|
301071
|
+
var E_TIMEOUT, E_ALREADY_LOCKED, E_CANCELED, __awaiter$2 = function(thisArg, _arguments, P2, generator) {
|
|
301072
|
+
function adopt(value) {
|
|
301073
|
+
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301074
|
+
resolve28(value);
|
|
301075
|
+
});
|
|
301076
|
+
}
|
|
301077
|
+
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301078
|
+
function fulfilled(value) {
|
|
301079
|
+
try {
|
|
301080
|
+
step(generator.next(value));
|
|
301081
|
+
} catch (e) {
|
|
301082
|
+
reject2(e);
|
|
301083
|
+
}
|
|
301084
|
+
}
|
|
301085
|
+
function rejected(value) {
|
|
301086
|
+
try {
|
|
301087
|
+
step(generator["throw"](value));
|
|
301088
|
+
} catch (e) {
|
|
301089
|
+
reject2(e);
|
|
301090
|
+
}
|
|
301091
|
+
}
|
|
301092
|
+
function step(result) {
|
|
301093
|
+
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301094
|
+
}
|
|
301095
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301096
|
+
});
|
|
301097
|
+
}, __awaiter$1 = function(thisArg, _arguments, P2, generator) {
|
|
301098
|
+
function adopt(value) {
|
|
301099
|
+
return value instanceof P2 ? value : new P2(function(resolve28) {
|
|
301100
|
+
resolve28(value);
|
|
301101
|
+
});
|
|
301102
|
+
}
|
|
301103
|
+
return new (P2 || (P2 = Promise))(function(resolve28, reject2) {
|
|
301104
|
+
function fulfilled(value) {
|
|
301105
|
+
try {
|
|
301106
|
+
step(generator.next(value));
|
|
301107
|
+
} catch (e) {
|
|
301108
|
+
reject2(e);
|
|
301109
|
+
}
|
|
301110
|
+
}
|
|
301111
|
+
function rejected(value) {
|
|
301112
|
+
try {
|
|
301113
|
+
step(generator["throw"](value));
|
|
301114
|
+
} catch (e) {
|
|
301115
|
+
reject2(e);
|
|
301116
|
+
}
|
|
301117
|
+
}
|
|
301118
|
+
function step(result) {
|
|
301119
|
+
result.done ? resolve28(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
301120
|
+
}
|
|
301121
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
301122
|
+
});
|
|
301123
|
+
};
|
|
301124
|
+
var init_async_mutex = __esm(() => {
|
|
301125
|
+
E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
301126
|
+
E_ALREADY_LOCKED = new Error("mutex already locked");
|
|
301127
|
+
E_CANCELED = new Error("request for lock canceled");
|
|
301128
|
+
});
|
|
301129
|
+
|
|
301142
301130
|
// src/services/api/grove.ts
|
|
301143
301131
|
function memoizeWithTTL(fn, ttlMs) {
|
|
301144
301132
|
let lastCachedAt = 0;
|
|
@@ -453788,17 +453776,36 @@ var init_FeedColumn = __esm(() => {
|
|
|
453788
453776
|
// src/services/api/referral.ts
|
|
453789
453777
|
async function fetchReferralEligibility(campaign = "claude_code_guest_pass") {
|
|
453790
453778
|
const { accessToken, orgUUID } = await prepareApiRequest();
|
|
453779
|
+
const existingPromise = fetchInProgressMap.get(orgUUID);
|
|
453780
|
+
if (existingPromise) {
|
|
453781
|
+
logForDebugging(`Passes: Reusing in-flight eligibility fetch for org ${orgUUID}`);
|
|
453782
|
+
return existingPromise;
|
|
453783
|
+
}
|
|
453791
453784
|
const headers = {
|
|
453792
453785
|
...getOAuthHeaders(accessToken),
|
|
453793
453786
|
"x-organization-uuid": orgUUID
|
|
453794
453787
|
};
|
|
453795
453788
|
const url3 = `${getOauthConfig().BASE_API_URL}/api/oauth/organizations/${orgUUID}/referral/eligibility`;
|
|
453796
|
-
|
|
453797
|
-
|
|
453798
|
-
|
|
453799
|
-
timeout: 5000
|
|
453789
|
+
let resolvePromise;
|
|
453790
|
+
const promise3 = new Promise((resolve47) => {
|
|
453791
|
+
resolvePromise = resolve47;
|
|
453800
453792
|
});
|
|
453801
|
-
|
|
453793
|
+
fetchInProgressMap.set(orgUUID, promise3);
|
|
453794
|
+
(async () => {
|
|
453795
|
+
try {
|
|
453796
|
+
const response = await axios_default.get(url3, {
|
|
453797
|
+
headers,
|
|
453798
|
+
params: { campaign },
|
|
453799
|
+
timeout: 5000
|
|
453800
|
+
});
|
|
453801
|
+
resolvePromise(response.data);
|
|
453802
|
+
} catch (error49) {
|
|
453803
|
+
logError2(error49);
|
|
453804
|
+
fetchInProgressMap.delete(orgUUID);
|
|
453805
|
+
throw error49;
|
|
453806
|
+
}
|
|
453807
|
+
})();
|
|
453808
|
+
return promise3;
|
|
453802
453809
|
}
|
|
453803
453810
|
async function fetchReferralRedemptions(campaign = "claude_code_guest_pass") {
|
|
453804
453811
|
const { accessToken, orgUUID } = await prepareApiRequest();
|
|
@@ -453878,41 +453885,26 @@ async function fetchAndStorePassesEligibility() {
|
|
|
453878
453885
|
if (!orgId) {
|
|
453879
453886
|
return null;
|
|
453880
453887
|
}
|
|
453881
|
-
|
|
453882
|
-
|
|
453883
|
-
|
|
453884
|
-
|
|
453888
|
+
try {
|
|
453889
|
+
const response = await fetchReferralEligibility();
|
|
453890
|
+
const cacheEntry = {
|
|
453891
|
+
...response,
|
|
453892
|
+
timestamp: Date.now()
|
|
453893
|
+
};
|
|
453894
|
+
saveGlobalConfig((current) => ({
|
|
453895
|
+
...current,
|
|
453896
|
+
passesEligibilityCache: {
|
|
453897
|
+
...current.passesEligibilityCache,
|
|
453898
|
+
[orgId]: cacheEntry
|
|
453899
|
+
}
|
|
453900
|
+
}));
|
|
453901
|
+
logForDebugging(`Passes eligibility cached for org ${orgId}: ${response.eligible}`);
|
|
453902
|
+
return response;
|
|
453903
|
+
} catch (error49) {
|
|
453904
|
+
logForDebugging("Failed to fetch and cache passes eligibility");
|
|
453905
|
+
logError2(error49);
|
|
453906
|
+
return null;
|
|
453885
453907
|
}
|
|
453886
|
-
let resolvePromise;
|
|
453887
|
-
const promise3 = new Promise((resolve47) => {
|
|
453888
|
-
resolvePromise = resolve47;
|
|
453889
|
-
});
|
|
453890
|
-
fetchInProgressMap.set(orgId, promise3);
|
|
453891
|
-
(async () => {
|
|
453892
|
-
try {
|
|
453893
|
-
const response = await fetchReferralEligibility();
|
|
453894
|
-
const cacheEntry = {
|
|
453895
|
-
...response,
|
|
453896
|
-
timestamp: Date.now()
|
|
453897
|
-
};
|
|
453898
|
-
saveGlobalConfig((current) => ({
|
|
453899
|
-
...current,
|
|
453900
|
-
passesEligibilityCache: {
|
|
453901
|
-
...current.passesEligibilityCache,
|
|
453902
|
-
[orgId]: cacheEntry
|
|
453903
|
-
}
|
|
453904
|
-
}));
|
|
453905
|
-
logForDebugging(`Passes eligibility cached for org ${orgId}: ${response.eligible}`);
|
|
453906
|
-
resolvePromise(response);
|
|
453907
|
-
} catch (error49) {
|
|
453908
|
-
logForDebugging("Failed to fetch and cache passes eligibility");
|
|
453909
|
-
logError2(error49);
|
|
453910
|
-
resolvePromise(null);
|
|
453911
|
-
} finally {
|
|
453912
|
-
fetchInProgressMap.delete(orgId);
|
|
453913
|
-
}
|
|
453914
|
-
})();
|
|
453915
|
-
return promise3;
|
|
453916
453908
|
}
|
|
453917
453909
|
async function getCachedOrFetchPassesEligibility() {
|
|
453918
453910
|
if (!shouldCheckForPasses()) {
|