codexuse-cli 3.6.5 → 3.6.6

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.
@@ -551,4 +551,4 @@ defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari"
551
551
  //#endregion
552
552
  export { apps, open as default, openApp };
553
553
 
554
- //# sourceMappingURL=open-Cm7F9p66.mjs.map
554
+ //# sourceMappingURL=open-BM96ykXl.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexuse-cli",
3
- "version": "3.6.5",
3
+ "version": "3.6.6",
4
4
  "description": "CodexUse CLI for profiles, Accounts Pool, daemon mode, licenses, and sync.",
5
5
  "author": {
6
6
  "name": "Hoang",
@@ -1,567 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import { Ba as succeedNone, Eo as filterMap, Ga as updateServices, Ha as sync, Ia as servicesWith, Jo as PipeInspectableProto, Ka as void_, Mo as succeed$1, Na as onExit, Qo as withFiber, Ro as isNone, Ui as _await, Wi as doneUnsafe, Xo as exitSucceed, Yi as makeUnsafe, _n as set$1, ao as fromInputUnsafe, co as isZero, do as toMillis, fa as ClockRef, gn as remove, hn as make$1, io as merge, ko as failVoid, mn as get$1, oo as infinity, so as isFinite, vn as size, vs as dual, ya as asSome, za as succeed, zo as isSome } from "./SqlClient-DSf3-WP1.mjs";
4
- //#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/Cache.js
5
- /**
6
- * @since 4.0.0
7
- */
8
- const TypeId = "~effect/Cache";
9
- /**
10
- * Creates a cache with dynamic time-to-live based on the result and key.
11
- *
12
- * The timeToLive function receives both the exit result and the key, allowing
13
- * for flexible TTL policies based on success/failure state and key characteristics.
14
- *
15
- * @example
16
- * ```ts
17
- * import { Cache, Effect, Exit } from "effect"
18
- *
19
- * // Cache with different TTL for success vs failure
20
- * const program = Effect.gen(function*() {
21
- * const cache = yield* Cache.makeWith<string, number, string>({
22
- * capacity: 100,
23
- * lookup: (key) =>
24
- * key === "fail"
25
- * ? Effect.fail("error")
26
- * : Effect.succeed(key.length),
27
- * timeToLive: (exit, key) => {
28
- * if (Exit.isFailure(exit)) return "1 minute" // Short TTL for errors
29
- * return key.startsWith("temp") ? "5 minutes" : "1 hour"
30
- * }
31
- * })
32
- *
33
- * // Get values with different TTL policies
34
- * const result1 = yield* Cache.get(cache, "hello")
35
- * const result2 = yield* Cache.get(cache, "temp_data")
36
- * console.log({ result1, result2 }) // { result1: 5, result2: 9 }
37
- * })
38
- * ```
39
- *
40
- * @example
41
- * ```ts
42
- * import { Cache, Effect, Exit } from "effect"
43
- *
44
- * // Cache with TTL based on computed value
45
- * const userCache = Effect.gen(function*() {
46
- * const cache = yield* Cache.makeWith<
47
- * number,
48
- * { id: number; active: boolean },
49
- * never
50
- * >({
51
- * capacity: 1000,
52
- * lookup: (id) => Effect.succeed({ id, active: id % 2 === 0 }),
53
- * timeToLive: (exit) => {
54
- * if (Exit.isSuccess(exit)) {
55
- * const user = exit.value
56
- * return user.active ? "1 hour" : "5 minutes"
57
- * }
58
- * return "30 seconds"
59
- * }
60
- * })
61
- *
62
- * return cache
63
- * })
64
- * ```
65
- *
66
- * @since 4.0.0
67
- * @category Constructors
68
- */
69
- const makeWith = (options) => servicesWith((services) => {
70
- const self = Object.create(Proto);
71
- self.lookup = (key) => updateServices(options.lookup(key), (input) => merge(services, input));
72
- self.map = make$1();
73
- self.capacity = options.capacity;
74
- self.timeToLive = options.timeToLive ? (exit, key) => fromInputUnsafe(options.timeToLive(exit, key)) : defaultTimeToLive;
75
- return succeed(self);
76
- });
77
- /**
78
- * Creates a cache with a fixed time-to-live for all entries.
79
- *
80
- * This is the basic cache constructor where all entries share the same TTL.
81
- * The lookup function will be called when a key is not found or has expired.
82
- *
83
- * @example
84
- * ```ts
85
- * import { Cache, Effect } from "effect"
86
- *
87
- * // Basic cache with string keys
88
- * const program = Effect.gen(function*() {
89
- * const cache = yield* Cache.make<string, number>({
90
- * capacity: 100,
91
- * lookup: (key) => Effect.succeed(key.length)
92
- * })
93
- *
94
- * const result1 = yield* Cache.get(cache, "hello")
95
- * const result2 = yield* Cache.get(cache, "world")
96
- * console.log({ result1, result2 }) // { result1: 5, result2: 5 }
97
- * })
98
- * ```
99
- *
100
- * @example
101
- * ```ts
102
- * import { Cache, Effect } from "effect"
103
- *
104
- * // Cache with TTL and async lookup
105
- * const fetchUserCache = Effect.gen(function*() {
106
- * const cache = yield* Cache.make<
107
- * number,
108
- * { name: string; email: string },
109
- * string
110
- * >({
111
- * capacity: 500,
112
- * lookup: (userId) =>
113
- * Effect.tryPromise({
114
- * try: () => fetch(`/api/users/${userId}`).then((r) => r.json()),
115
- * catch: () => "Failed to fetch user"
116
- * }),
117
- * timeToLive: "15 minutes"
118
- * })
119
- *
120
- * // First call fetches from API, second call returns cached result
121
- * const user1 = yield* Cache.get(cache, 123)
122
- * const user2 = yield* Cache.get(cache, 123) // From cache
123
- * return { user1, user2 }
124
- * })
125
- * ```
126
- *
127
- * @since 4.0.0
128
- * @category Constructors
129
- */
130
- const make = (options) => makeWith({
131
- ...options,
132
- timeToLive: options.timeToLive ? () => options.timeToLive : defaultTimeToLive
133
- });
134
- const Proto = {
135
- ...PipeInspectableProto,
136
- [TypeId]: TypeId,
137
- toJSON() {
138
- return {
139
- _id: "Cache",
140
- capacity: this.capacity,
141
- map: this.map
142
- };
143
- }
144
- };
145
- const defaultTimeToLive = (_, _key) => infinity;
146
- /**
147
- * Retrieves the value associated with the specified key from the cache.
148
- *
149
- * If the key is not present or has expired, it will invoke the lookup function
150
- * to construct the value, store it in the cache, and return it.
151
- *
152
- * @example
153
- * ```ts
154
- * import { Cache, Effect } from "effect"
155
- *
156
- * const program = Effect.gen(function*() {
157
- * const cache = yield* Cache.make({
158
- * capacity: 10,
159
- * lookup: (key: string) => Effect.succeed(key.length)
160
- * })
161
- *
162
- * // Cache miss - triggers lookup function
163
- * const result1 = yield* Cache.get(cache, "hello")
164
- * console.log(result1) // 5
165
- *
166
- * // Cache hit - returns cached value without lookup
167
- * const result2 = yield* Cache.get(cache, "hello")
168
- * console.log(result2) // 5 (from cache)
169
- *
170
- * return { result1, result2 }
171
- * })
172
- * ```
173
- *
174
- * @example
175
- * ```ts
176
- * import { Cache, Effect } from "effect"
177
- *
178
- * // Error handling when lookup fails
179
- * const program = Effect.gen(function*() {
180
- * const cache = yield* Cache.make<string, number, string>({
181
- * capacity: 10,
182
- * lookup: (key: string) =>
183
- * key === "error"
184
- * ? Effect.fail("Lookup failed")
185
- * : Effect.succeed(key.length)
186
- * })
187
- *
188
- * // Successful lookup
189
- * const success = yield* Cache.get(cache, "hello")
190
- * console.log(success) // 5
191
- *
192
- * // Failed lookup - returns error
193
- * const failure = yield* Effect.exit(Cache.get(cache, "error"))
194
- * console.log(failure) // Exit.fail("Lookup failed")
195
- * })
196
- * ```
197
- *
198
- * @example
199
- * ```ts
200
- * import { Cache, Effect } from "effect"
201
- *
202
- * // Concurrent access - multiple gets of same key only invoke lookup once
203
- * const program = Effect.gen(function*() {
204
- * let lookupCount = 0
205
- * const cache = yield* Cache.make({
206
- * capacity: 10,
207
- * lookup: (key: string) =>
208
- * Effect.sync(() => {
209
- * lookupCount++
210
- * return key.length
211
- * })
212
- * })
213
- *
214
- * // Multiple concurrent gets
215
- * const results = yield* Effect.all([
216
- * Cache.get(cache, "hello"),
217
- * Cache.get(cache, "hello"),
218
- * Cache.get(cache, "hello")
219
- * ], { concurrency: "unbounded" })
220
- *
221
- * console.log(results) // [5, 5, 5]
222
- * console.log(lookupCount) // 1 (lookup called only once)
223
- * })
224
- * ```
225
- *
226
- * @since 4.0.0
227
- * @category Combinators
228
- */
229
- const get = /* @__PURE__ */ dual(2, (self, key) => withFiber((fiber) => {
230
- const oentry = get$1(self.map, key);
231
- if (isSome(oentry) && !hasExpired(oentry.value, fiber)) {
232
- remove(self.map, key);
233
- set$1(self.map, key, oentry.value);
234
- return _await(oentry.value.deferred);
235
- }
236
- const deferred = makeUnsafe();
237
- const entry = {
238
- expiresAt: void 0,
239
- deferred
240
- };
241
- set$1(self.map, key, entry);
242
- if (Number.isFinite(self.capacity)) checkCapacity(self);
243
- return onExit(self.lookup(key), (exit) => {
244
- doneUnsafe(deferred, exit);
245
- const ttl = self.timeToLive(exit, key);
246
- if (isFinite(ttl)) entry.expiresAt = fiber.getRef(ClockRef).currentTimeMillisUnsafe() + toMillis(ttl);
247
- else if (isZero(ttl)) remove(self.map, key);
248
- return void_;
249
- });
250
- }));
251
- const hasExpired = (entry, fiber) => {
252
- if (entry.expiresAt === void 0) return false;
253
- return fiber.getRef(ClockRef).currentTimeMillisUnsafe() >= entry.expiresAt;
254
- };
255
- const checkCapacity = (self) => {
256
- let diff = size(self.map) - self.capacity;
257
- if (diff <= 0) return;
258
- for (const [key] of self.map) {
259
- remove(self.map, key);
260
- diff--;
261
- if (diff === 0) return;
262
- }
263
- };
264
- /**
265
- * Retrieves the value associated with the specified key from the cache,
266
- * returning an `Option` that is `Some` if the key exists and has not expired,
267
- * or `None` if the key does not exist or has expired.
268
- *
269
- * Unlike `get`, this function will not invoke the lookup function if the key
270
- * is missing or expired.
271
- *
272
- * @example
273
- * ```ts
274
- * import { Cache, Effect } from "effect"
275
- *
276
- * const program = Effect.gen(function*() {
277
- * const cache = yield* Cache.make({
278
- * capacity: 10,
279
- * lookup: (key: string) => Effect.succeed(key.length)
280
- * })
281
- *
282
- * // No value in cache yet - returns None without lookup
283
- * const empty = yield* Cache.getOption(cache, "hello")
284
- * console.log(empty) // Option.none()
285
- *
286
- * // Populate cache using get
287
- * yield* Cache.get(cache, "hello")
288
- *
289
- * // Now getOption returns the cached value
290
- * const cached = yield* Cache.getOption(cache, "hello")
291
- * console.log(cached) // Option.some(5)
292
- *
293
- * return { empty, cached }
294
- * })
295
- * ```
296
- *
297
- * @example
298
- * ```ts
299
- * import { Cache, Effect } from "effect"
300
- * import { TestClock } from "effect/testing"
301
- *
302
- * // Expired entries return None
303
- * const program = Effect.gen(function*() {
304
- * const cache = yield* Cache.make({
305
- * capacity: 10,
306
- * lookup: (key: string) => Effect.succeed(key.length),
307
- * timeToLive: "1 hour"
308
- * })
309
- *
310
- * // Add value to cache
311
- * yield* Cache.get(cache, "hello")
312
- *
313
- * // Value exists before expiration
314
- * const beforeExpiry = yield* Cache.getOption(cache, "hello")
315
- * console.log(beforeExpiry) // Option.some(5)
316
- *
317
- * // Simulate time passing
318
- * yield* TestClock.adjust("2 hours")
319
- *
320
- * // Value expired - returns None
321
- * const afterExpiry = yield* Cache.getOption(cache, "hello")
322
- * console.log(afterExpiry) // Option.none()
323
- * })
324
- * ```
325
- *
326
- * @example
327
- * ```ts
328
- * import { Cache, Deferred, Effect, Fiber } from "effect"
329
- *
330
- * // Waits for ongoing computation to complete
331
- * const program = Effect.gen(function*() {
332
- * const deferred = yield* Deferred.make<void>()
333
- * const cache = yield* Cache.make({
334
- * capacity: 10,
335
- * lookup: (_key: string) => Deferred.await(deferred).pipe(Effect.as(42))
336
- * })
337
- *
338
- * // Start lookup in background
339
- * const getFiber = yield* Effect.forkChild(Cache.get(cache, "key"))
340
- *
341
- * // getOption waits for ongoing computation
342
- * const optionFiber = yield* Effect.forkChild(Cache.getOption(cache, "key"))
343
- *
344
- * // Complete the computation
345
- * yield* Deferred.succeed(deferred, void 0)
346
- *
347
- * const result = yield* Fiber.join(optionFiber)
348
- * console.log(result) // Option.some(42)
349
- * })
350
- * ```
351
- *
352
- * @since 4.0.0
353
- * @category Combinators
354
- */
355
- const getOption = /* @__PURE__ */ dual(2, (self, key) => withFiber((fiber) => {
356
- const entry = getImpl(self, key, fiber);
357
- return entry ? asSome(_await(entry.deferred)) : succeedNone;
358
- }));
359
- const getImpl = (self, key, fiber, isRead = true) => {
360
- const oentry = get$1(self.map, key);
361
- if (isNone(oentry)) return;
362
- else if (hasExpired(oentry.value, fiber)) {
363
- remove(self.map, key);
364
- return;
365
- } else if (isRead) {
366
- remove(self.map, key);
367
- set$1(self.map, key, oentry.value);
368
- }
369
- return oentry.value;
370
- };
371
- /**
372
- * Sets the value associated with the specified key in the cache. This will
373
- * overwrite any existing value for that key, skipping the lookup function.
374
- *
375
- * @example
376
- * ```ts
377
- * import { Cache, Effect } from "effect"
378
- *
379
- * const program = Effect.gen(function*() {
380
- * const cache = yield* Cache.make({
381
- * capacity: 100,
382
- * lookup: (key: string) => Effect.succeed(key.length)
383
- * })
384
- *
385
- * // Set a value directly without invoking lookup
386
- * yield* Cache.set(cache, "hello", 42)
387
- * const result = yield* Cache.get(cache, "hello")
388
- * console.log(result) // 42 (not 5 from lookup)
389
- * })
390
- * ```
391
- *
392
- * @example
393
- * ```ts
394
- * import { Cache, Effect } from "effect"
395
- *
396
- * // Overwriting existing cached values
397
- * const program = Effect.gen(function*() {
398
- * const cache = yield* Cache.make({
399
- * capacity: 100,
400
- * lookup: (key: string) => Effect.succeed(key.length)
401
- * })
402
- *
403
- * // First get populates via lookup
404
- * const original = yield* Cache.get(cache, "test") // 4
405
- *
406
- * // Set overwrites the cached value
407
- * yield* Cache.set(cache, "test", 999)
408
- * const updated = yield* Cache.get(cache, "test") // 999
409
- *
410
- * console.log({ original, updated })
411
- * })
412
- * ```
413
- *
414
- * @example
415
- * ```ts
416
- * import { Cache, Effect } from "effect"
417
- * import { TestClock } from "effect/testing"
418
- *
419
- * // TTL behavior with set operations
420
- * const program = Effect.gen(function*() {
421
- * const cache = yield* Cache.make({
422
- * capacity: 100,
423
- * lookup: (key: string) => Effect.succeed(key.length),
424
- * timeToLive: "1 hour"
425
- * })
426
- *
427
- * // Set value with TTL applied
428
- * yield* Cache.set(cache, "temporary", 123)
429
- * console.log(yield* Cache.has(cache, "temporary")) // true
430
- *
431
- * // Advance time past TTL
432
- * yield* TestClock.adjust("2 hours")
433
- * console.log(yield* Cache.has(cache, "temporary")) // false
434
- * })
435
- * ```
436
- *
437
- * @example
438
- * ```ts
439
- * import { Cache, Effect } from "effect"
440
- *
441
- * // Capacity enforcement with set operations
442
- * const program = Effect.gen(function*() {
443
- * const cache = yield* Cache.make({
444
- * capacity: 2,
445
- * lookup: (key: string) => Effect.succeed(key.length)
446
- * })
447
- *
448
- * // Fill cache to capacity
449
- * yield* Cache.set(cache, "a", 1)
450
- * yield* Cache.set(cache, "b", 2)
451
- * console.log(yield* Cache.size(cache)) // 2
452
- *
453
- * // Adding another entry evicts oldest
454
- * yield* Cache.set(cache, "c", 3)
455
- * console.log(yield* Cache.size(cache)) // 2
456
- * console.log(yield* Cache.has(cache, "a")) // false (evicted)
457
- * console.log(yield* Cache.has(cache, "c")) // true
458
- * })
459
- * ```
460
- *
461
- * @since 4.0.0
462
- * @category Combinators
463
- */
464
- const set = /* @__PURE__ */ dual(3, (self, key, value) => withFiber((fiber) => {
465
- const exit = exitSucceed(value);
466
- const deferred = makeUnsafe();
467
- doneUnsafe(deferred, exit);
468
- const ttl = self.timeToLive(exit, key);
469
- if (isZero(ttl)) {
470
- remove(self.map, key);
471
- return void_;
472
- }
473
- set$1(self.map, key, {
474
- deferred,
475
- expiresAt: isFinite(ttl) ? fiber.getRef(ClockRef).currentTimeMillisUnsafe() + toMillis(ttl) : void 0
476
- });
477
- checkCapacity(self);
478
- return void_;
479
- }));
480
- /**
481
- * Invalidates the entry associated with the specified key in the cache.
482
- *
483
- * @example
484
- * ```ts
485
- * import { Cache, Effect } from "effect"
486
- *
487
- * const program = Effect.gen(function*() {
488
- * const cache = yield* Cache.make({
489
- * capacity: 10,
490
- * lookup: (key: string) => Effect.succeed(key.length)
491
- * })
492
- *
493
- * // Add a value to the cache
494
- * yield* Cache.get(cache, "hello")
495
- * console.log(yield* Cache.has(cache, "hello")) // true
496
- *
497
- * // Invalidate the entry
498
- * yield* Cache.invalidate(cache, "hello")
499
- * console.log(yield* Cache.has(cache, "hello")) // false
500
- *
501
- * // Invalidating non-existent keys doesn't error
502
- * yield* Cache.invalidate(cache, "nonexistent")
503
- *
504
- * // Get after invalidation will invoke lookup again
505
- * let lookupCount = 0
506
- * const cache2 = yield* Cache.make({
507
- * capacity: 10,
508
- * lookup: (key: string) =>
509
- * Effect.sync(() => {
510
- * lookupCount++
511
- * return key.length
512
- * })
513
- * })
514
- *
515
- * yield* Cache.get(cache2, "test") // lookupCount = 1
516
- * yield* Cache.invalidate(cache2, "test")
517
- * yield* Cache.get(cache2, "test") // lookupCount = 2 (lookup called again)
518
- * })
519
- * ```
520
- *
521
- * @since 4.0.0
522
- * @category Combinators
523
- */
524
- const invalidate = /* @__PURE__ */ dual(2, (self, key) => sync(() => {
525
- remove(self.map, key);
526
- }));
527
- /**
528
- * Retrieves all active keys from the cache, automatically filtering out expired entries.
529
- *
530
- * @example
531
- * ```ts
532
- * import { Cache, Effect } from "effect"
533
- *
534
- * // Basic key enumeration
535
- * const program = Effect.gen(function*() {
536
- * const cache = yield* Cache.make({
537
- * capacity: 10,
538
- * lookup: (key: string) => Effect.succeed(key.length)
539
- * })
540
- *
541
- * // Add some entries to the cache
542
- * yield* Cache.get(cache, "hello")
543
- * yield* Cache.get(cache, "world")
544
- * yield* Cache.get(cache, "cache")
545
- *
546
- * // Retrieve all active keys
547
- * const keys = yield* Cache.keys(cache)
548
- *
549
- * console.log(Array.from(keys)) // ["hello", "world", "cache"]
550
- * })
551
- * ```
552
- *
553
- * @since 4.0.0
554
- * @category Combinators
555
- */
556
- const keys = (self) => withFiber((fiber) => {
557
- const now = fiber.getRef(ClockRef).currentTimeMillisUnsafe();
558
- return succeed(filterMap(self.map, ([key, entry]) => {
559
- if (entry.expiresAt === void 0 || entry.expiresAt > now) return succeed$1(key);
560
- remove(self.map, key);
561
- return failVoid;
562
- }));
563
- });
564
- //#endregion
565
- export { make as a, keys as i, getOption as n, makeWith as o, invalidate as r, set as s, get as t };
566
-
567
- //# sourceMappingURL=Cache-Ctxz7HFI.mjs.map