t3mode 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/backend-host.cjs +74 -0
- package/dist/bundles/index.cjs +2 -0
- package/dist/bundles/main.cjs +2832 -2256
- package/dist/bundles/main.cjs.map +1 -1
- package/dist/bundles/preload.cjs +41 -28
- package/dist/bundles/renderer.iife.js +111 -99
- package/dist/bundles/update-helper.ps1 +34 -2
- package/dist/repair.cjs +3 -1
- package/dist/t3mode.cjs +773 -129
- package/package.json +1 -1
package/dist/t3mode.cjs
CHANGED
|
@@ -7130,7 +7130,7 @@ const fiberAwait = (self) => {
|
|
|
7130
7130
|
if (impl._exit) return succeed$5(impl._exit);
|
|
7131
7131
|
return callback$2((resume) => {
|
|
7132
7132
|
if (impl._exit) return resume(succeed$5(impl._exit));
|
|
7133
|
-
return sync$
|
|
7133
|
+
return sync$2(self.addObserver((exit) => resume(succeed$5(exit))));
|
|
7134
7134
|
});
|
|
7135
7135
|
};
|
|
7136
7136
|
/** @internal */
|
|
@@ -7155,7 +7155,7 @@ const fiberAwaitAll = (self) => callback$2((resume) => {
|
|
|
7155
7155
|
resume(succeed$5(exits));
|
|
7156
7156
|
}
|
|
7157
7157
|
loop();
|
|
7158
|
-
return sync$
|
|
7158
|
+
return sync$2(() => cancel?.());
|
|
7159
7159
|
});
|
|
7160
7160
|
/** @internal */
|
|
7161
7161
|
const fiberJoin = (self) => {
|
|
@@ -7163,7 +7163,7 @@ const fiberJoin = (self) => {
|
|
|
7163
7163
|
if (impl._exit) return impl._exit;
|
|
7164
7164
|
return callback$2((resume) => {
|
|
7165
7165
|
if (impl._exit) return resume(impl._exit);
|
|
7166
|
-
return sync$
|
|
7166
|
+
return sync$2(self.addObserver(resume));
|
|
7167
7167
|
});
|
|
7168
7168
|
};
|
|
7169
7169
|
/** @internal */
|
|
@@ -7192,7 +7192,7 @@ const failCause$3 = exitFailCause;
|
|
|
7192
7192
|
/** @internal */
|
|
7193
7193
|
const fail$8 = exitFail;
|
|
7194
7194
|
/** @internal */
|
|
7195
|
-
const sync$
|
|
7195
|
+
const sync$2 = /*#__PURE__*/ makePrimitive$1({
|
|
7196
7196
|
op: "Sync",
|
|
7197
7197
|
[evaluate](fiber) {
|
|
7198
7198
|
const thunk = this[args];
|
|
@@ -7703,7 +7703,7 @@ const mapError$3 = /*#__PURE__*/ dual(2, (self, f) => catchCause$1(self, (cause)
|
|
|
7703
7703
|
/** @internal */
|
|
7704
7704
|
const orDie$1 = (self) => catch_$1(self, die$2);
|
|
7705
7705
|
/** @internal */
|
|
7706
|
-
const orElseSucceed$1 = /*#__PURE__*/ dual(2, (self, f) => catch_$1(self, (error) => sync$
|
|
7706
|
+
const orElseSucceed$1 = /*#__PURE__*/ dual(2, (self, f) => catch_$1(self, (error) => sync$2(() => f(error))));
|
|
7707
7707
|
/** @internal */
|
|
7708
7708
|
const ignoreCauseLogger = (log) => log === "Unhandled" ? (...message) => withFiber$1((fiber) => {
|
|
7709
7709
|
const level = fiber.getRef(UnhandledLogLevel);
|
|
@@ -8016,6 +8016,8 @@ const onErrorFilter = /*#__PURE__*/ dual(3, (self, filter, f) => onExit$2(self,
|
|
|
8016
8016
|
}));
|
|
8017
8017
|
/** @internal */
|
|
8018
8018
|
const onInterrupt$1 = /*#__PURE__*/ dual(2, (self, finalizer) => onErrorFilter(causeFilterInterruptors, finalizer)(self));
|
|
8019
|
+
/** @internal */
|
|
8020
|
+
const acquireUseRelease$1 = (acquire, use, release) => uninterruptibleMask$1((restore) => flatMap$2(acquire, (a) => onExitPrimitive$1(suspend$3(() => restore(use(a))), (exit) => release(a, exit), true)));
|
|
8019
8021
|
const infiniteTTL = /*#__PURE__*/ constant(Infinity);
|
|
8020
8022
|
const makeCachedUnsafe = (self, ttlMillis) => {
|
|
8021
8023
|
let expiresAt = 0;
|
|
@@ -8052,13 +8054,13 @@ const makeCachedUnsafe = (self, ttlMillis) => {
|
|
|
8052
8054
|
exit = exit_;
|
|
8053
8055
|
}));
|
|
8054
8056
|
return run.fiber._exit ?? joined;
|
|
8055
|
-
}), sync$
|
|
8057
|
+
}), sync$2(() => {
|
|
8056
8058
|
current = void 0;
|
|
8057
8059
|
exit = void 0;
|
|
8058
8060
|
})];
|
|
8059
8061
|
};
|
|
8060
8062
|
/** @internal */
|
|
8061
|
-
const cached$1 = (self) => sync$
|
|
8063
|
+
const cached$1 = (self) => sync$2(() => makeCachedUnsafe(self, infiniteTTL)[0]);
|
|
8062
8064
|
/** @internal */
|
|
8063
8065
|
const interrupt$2 = /*#__PURE__*/ withFiber$1((fiber) => failCause$3(causeInterrupt(fiber.id)));
|
|
8064
8066
|
/** @internal */
|
|
@@ -8444,7 +8446,7 @@ var Latch = class {
|
|
|
8444
8446
|
await = /*#__PURE__*/ callback$2((resume) => {
|
|
8445
8447
|
if (this._isOpen) return resume(void_$2);
|
|
8446
8448
|
this.waiters.push(resume);
|
|
8447
|
-
return sync$
|
|
8449
|
+
return sync$2(() => {
|
|
8448
8450
|
let index = this.waiters.indexOf(resume);
|
|
8449
8451
|
if (index !== -1) this.waiters.splice(index, 1);
|
|
8450
8452
|
else if (this.scheduled !== void 0) {
|
|
@@ -8458,7 +8460,7 @@ var Latch = class {
|
|
|
8458
8460
|
this._isOpen = false;
|
|
8459
8461
|
return true;
|
|
8460
8462
|
}
|
|
8461
|
-
close = /*#__PURE__*/ sync$
|
|
8463
|
+
close = /*#__PURE__*/ sync$2(() => this.closeUnsafe());
|
|
8462
8464
|
whenOpen = (self) => flatMap$2(this.await, () => self);
|
|
8463
8465
|
isOpen() {
|
|
8464
8466
|
return this._isOpen;
|
|
@@ -8534,7 +8536,7 @@ const provideSpanStackFrame = (name, stack) => {
|
|
|
8534
8536
|
}));
|
|
8535
8537
|
};
|
|
8536
8538
|
/** @internal */
|
|
8537
|
-
const endSpan = (span, exit, clock, timingEnabled) => sync$
|
|
8539
|
+
const endSpan = (span, exit, clock, timingEnabled) => sync$2(() => {
|
|
8538
8540
|
if (span.status._tag === "Ended") return;
|
|
8539
8541
|
span.end(timingEnabled ? clock.currentTimeNanosUnsafe() : bigint0$2, exit);
|
|
8540
8542
|
});
|
|
@@ -8584,15 +8586,15 @@ var ClockImpl = class {
|
|
|
8584
8586
|
currentTimeMillisUnsafe() {
|
|
8585
8587
|
return Date.now();
|
|
8586
8588
|
}
|
|
8587
|
-
currentTimeMillis = /*#__PURE__*/ sync$
|
|
8589
|
+
currentTimeMillis = /*#__PURE__*/ sync$2(() => this.currentTimeMillisUnsafe());
|
|
8588
8590
|
currentTimeNanosUnsafe() {
|
|
8589
8591
|
return wallTimeNanos();
|
|
8590
8592
|
}
|
|
8591
|
-
currentTimeNanos = /*#__PURE__*/ sync$
|
|
8593
|
+
currentTimeNanos = /*#__PURE__*/ sync$2(() => this.currentTimeNanosUnsafe());
|
|
8592
8594
|
monotonicTimeNanosUnsafe() {
|
|
8593
8595
|
return monotonicNowNanos();
|
|
8594
8596
|
}
|
|
8595
|
-
monotonicTimeNanos = /*#__PURE__*/ sync$
|
|
8597
|
+
monotonicTimeNanos = /*#__PURE__*/ sync$2(() => this.monotonicTimeNanosUnsafe());
|
|
8596
8598
|
sleep(duration) {
|
|
8597
8599
|
return this.sleepMillis(toMillis(duration));
|
|
8598
8600
|
}
|
|
@@ -8602,7 +8604,7 @@ var ClockImpl = class {
|
|
|
8602
8604
|
return callback$2((resume) => {
|
|
8603
8605
|
const continuation = millis > MAX_TIMER_MILLIS ? this.sleepMillis(millis - MAX_TIMER_MILLIS) : void_$2;
|
|
8604
8606
|
const handle = setTimeout(() => resume(continuation), Math.min(millis, MAX_TIMER_MILLIS));
|
|
8605
|
-
return sync$
|
|
8607
|
+
return sync$2(() => clearTimeout(handle));
|
|
8606
8608
|
});
|
|
8607
8609
|
}
|
|
8608
8610
|
};
|
|
@@ -9401,7 +9403,7 @@ const _await = (self) => callback$2((resume) => {
|
|
|
9401
9403
|
if (self.effect) return resume(self.effect);
|
|
9402
9404
|
self.resumes ??= [];
|
|
9403
9405
|
self.resumes.push(resume);
|
|
9404
|
-
return sync$
|
|
9406
|
+
return sync$2(() => {
|
|
9405
9407
|
const resumes = self.resumes;
|
|
9406
9408
|
if (resumes === void 0) return;
|
|
9407
9409
|
const index = resumes.indexOf(resume);
|
|
@@ -9444,7 +9446,7 @@ const _await = (self) => callback$2((resume) => {
|
|
|
9444
9446
|
* @category completion
|
|
9445
9447
|
* @since 2.0.0
|
|
9446
9448
|
*/
|
|
9447
|
-
const done = /* @__PURE__ */ dual(2, (self, effect) => sync$
|
|
9449
|
+
const done = /* @__PURE__ */ dual(2, (self, effect) => sync$2(() => doneUnsafe(self, effect)));
|
|
9448
9450
|
/**
|
|
9449
9451
|
* Attempts to complete the `Deferred` with the specified error.
|
|
9450
9452
|
*
|
|
@@ -9506,7 +9508,7 @@ const fail$5 = /*#__PURE__*/ dual(2, (self, error) => done(self, exitFail(error)
|
|
|
9506
9508
|
* @category predicates
|
|
9507
9509
|
* @since 2.0.0
|
|
9508
9510
|
*/
|
|
9509
|
-
const isDone = (self) => sync$
|
|
9511
|
+
const isDone = (self) => sync$2(() => isDoneUnsafe(self));
|
|
9510
9512
|
/**
|
|
9511
9513
|
* Returns whether this `Deferred` has already been completed synchronously.
|
|
9512
9514
|
*
|
|
@@ -11829,7 +11831,7 @@ const suspend$2 = suspend$3;
|
|
|
11829
11831
|
* @category constructors
|
|
11830
11832
|
* @since 2.0.0
|
|
11831
11833
|
*/
|
|
11832
|
-
const sync = sync$
|
|
11834
|
+
const sync$1 = sync$2;
|
|
11833
11835
|
const void_ = void_$2;
|
|
11834
11836
|
const undefined_$1 = undefined_$2;
|
|
11835
11837
|
/**
|
|
@@ -13991,6 +13993,82 @@ const scopedWith = scopedWith$1;
|
|
|
13991
13993
|
*/
|
|
13992
13994
|
const acquireRelease = acquireRelease$1;
|
|
13993
13995
|
/**
|
|
13996
|
+
* Runs resource acquisition, usage, and release as one bracketed effect.
|
|
13997
|
+
*
|
|
13998
|
+
* **When to use**
|
|
13999
|
+
*
|
|
14000
|
+
* Use to bracket acquire, use, and release logic in one effect.
|
|
14001
|
+
*
|
|
14002
|
+
* **Details**
|
|
14003
|
+
*
|
|
14004
|
+
* `acquireUseRelease` does the following:
|
|
14005
|
+
*
|
|
14006
|
+
* 1. Ensures that the `Effect` value that acquires the resource will not be
|
|
14007
|
+
* interrupted. Note that acquisition may still fail due to internal
|
|
14008
|
+
* reasons (such as an uncaught exception).
|
|
14009
|
+
* 2. Ensures that the `release` `Effect` value will not be interrupted,
|
|
14010
|
+
* and will be executed as long as the acquisition `Effect` value
|
|
14011
|
+
* successfully acquires the resource.
|
|
14012
|
+
*
|
|
14013
|
+
* During the time period between the acquisition and release of the resource,
|
|
14014
|
+
* the `use` `Effect` value will be executed.
|
|
14015
|
+
*
|
|
14016
|
+
* If the `release` `Effect` value fails, then the entire `Effect` value will
|
|
14017
|
+
* fail, even if the `use` `Effect` value succeeds. If this fail-fast behavior
|
|
14018
|
+
* is not desired, errors produced by the `release` `Effect` value can be caught
|
|
14019
|
+
* and ignored.
|
|
14020
|
+
*
|
|
14021
|
+
* **Example** (Acquiring resources with cleanup)
|
|
14022
|
+
*
|
|
14023
|
+
* ```ts import.meta.vitest
|
|
14024
|
+
* import { Effect, Exit } from "effect"
|
|
14025
|
+
* const output: Array<unknown> = []
|
|
14026
|
+
*
|
|
14027
|
+
* interface Database {
|
|
14028
|
+
* readonly connection: string
|
|
14029
|
+
* readonly query: (sql: string) => Effect.Effect<string>
|
|
14030
|
+
* }
|
|
14031
|
+
*
|
|
14032
|
+
* const program = Effect.acquireUseRelease(
|
|
14033
|
+
* // Acquire - connect to database
|
|
14034
|
+
* Effect.gen(function*() {
|
|
14035
|
+
* yield* Effect.sync(() => { output.push("Connecting to database...") })
|
|
14036
|
+
* return {
|
|
14037
|
+
* connection: "db://localhost:5432",
|
|
14038
|
+
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
14039
|
+
* }
|
|
14040
|
+
* }),
|
|
14041
|
+
* // Use - perform database operations
|
|
14042
|
+
* (db) =>
|
|
14043
|
+
* Effect.gen(function*() {
|
|
14044
|
+
* yield* Effect.sync(() => { output.push(`Connected to ${db.connection}`) })
|
|
14045
|
+
* const result = yield* db.query("SELECT * FROM users")
|
|
14046
|
+
* yield* Effect.sync(() => { output.push(`Query result: ${result}`) })
|
|
14047
|
+
* return result
|
|
14048
|
+
* }),
|
|
14049
|
+
* // Release - close database connection
|
|
14050
|
+
* (db, exit) =>
|
|
14051
|
+
* Effect.gen(function*() {
|
|
14052
|
+
* if (Exit.isSuccess(exit)) {
|
|
14053
|
+
* yield* Effect.sync(() => { output.push(`Closing connection to ${db.connection} (success)`) })
|
|
14054
|
+
* } else {
|
|
14055
|
+
* yield* Effect.sync(() => { output.push(`Closing connection to ${db.connection} (failure)`) })
|
|
14056
|
+
* }
|
|
14057
|
+
* })
|
|
14058
|
+
* )
|
|
14059
|
+
*
|
|
14060
|
+
* await Effect.runPromise(program)
|
|
14061
|
+
* output // => ["Connecting to database...", "Connected to db://localhost:5432", "Query result: Result for: SELECT * FROM users", "Closing connection to db://localhost:5432 (success)"]
|
|
14062
|
+
* ```
|
|
14063
|
+
*
|
|
14064
|
+
* @see {@link acquireRelease} for scoped resources whose use happens later
|
|
14065
|
+
*
|
|
14066
|
+
* @stability stable
|
|
14067
|
+
* @category resource management
|
|
14068
|
+
* @since 2.0.0
|
|
14069
|
+
*/
|
|
14070
|
+
const acquireUseRelease = acquireUseRelease$1;
|
|
14071
|
+
/**
|
|
13994
14072
|
* Adds a finalizer to the current scope.
|
|
13995
14073
|
*
|
|
13996
14074
|
* **When to use**
|
|
@@ -16717,9 +16795,9 @@ const walk = /*#__PURE__*/ fnUntraced(function* (fs, compiled, options) {
|
|
|
16717
16795
|
let slots = DIRECTORY_CONCURRENCY;
|
|
16718
16796
|
let finishing = false;
|
|
16719
16797
|
const failed = makeUnsafe$4();
|
|
16720
|
-
const fork = (walk) => walk.pipe(onError((cause) => sync(() => {
|
|
16798
|
+
const fork = (walk) => walk.pipe(onError((cause) => sync$1(() => {
|
|
16721
16799
|
if (!finishing) doneUnsafe(failed, failCause$1(cause));
|
|
16722
|
-
})), ensuring$2(sync(() => {
|
|
16800
|
+
})), ensuring$2(sync$1(() => {
|
|
16723
16801
|
slots++;
|
|
16724
16802
|
})), forkChild);
|
|
16725
16803
|
const directory = fnUntraced(function* (relative, states, excluded, named) {
|
|
@@ -16756,7 +16834,7 @@ const walk = /*#__PURE__*/ fnUntraced(function* (fs, compiled, options) {
|
|
|
16756
16834
|
}
|
|
16757
16835
|
return out;
|
|
16758
16836
|
});
|
|
16759
|
-
return yield* raceFirst(ensuring$2(directory("", compiled.initial, excludes.initial, true), sync(() => {
|
|
16837
|
+
return yield* raceFirst(ensuring$2(directory("", compiled.initial, excludes.initial, true), sync$1(() => {
|
|
16760
16838
|
finishing = true;
|
|
16761
16839
|
})), _await(failed));
|
|
16762
16840
|
});
|
|
@@ -17552,7 +17630,7 @@ const offerUnsafe = (self, message) => {
|
|
|
17552
17630
|
* @category completion
|
|
17553
17631
|
* @since 4.0.0
|
|
17554
17632
|
*/
|
|
17555
|
-
const failCause = /*#__PURE__*/ dual(2, (self, cause) => sync$
|
|
17633
|
+
const failCause = /*#__PURE__*/ dual(2, (self, cause) => sync$2(() => failCauseUnsafe(self, cause)));
|
|
17556
17634
|
/**
|
|
17557
17635
|
* Fails the queue with a cause synchronously. If the queue is already done, `false` is
|
|
17558
17636
|
* returned.
|
|
@@ -17694,7 +17772,7 @@ const endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done$1()));
|
|
|
17694
17772
|
* @category completion
|
|
17695
17773
|
* @since 2.0.0
|
|
17696
17774
|
*/
|
|
17697
|
-
const shutdown = (self) => sync$
|
|
17775
|
+
const shutdown = (self) => sync$2(() => shutdownUnsafe(self));
|
|
17698
17776
|
/**
|
|
17699
17777
|
* Shuts down the queue synchronously, discarding buffered messages and resuming
|
|
17700
17778
|
* pending operations.
|
|
@@ -18042,7 +18120,7 @@ const awaitTake = (self, ready) => callback$2((resume) => {
|
|
|
18042
18120
|
resume
|
|
18043
18121
|
};
|
|
18044
18122
|
self.state.takers.add(taker);
|
|
18045
|
-
return sync$
|
|
18123
|
+
return sync$2(() => {
|
|
18046
18124
|
if (self.state._tag !== "Done") self.state.takers.delete(taker);
|
|
18047
18125
|
});
|
|
18048
18126
|
});
|
|
@@ -18055,7 +18133,7 @@ const waitToOffer = (self, entry) => {
|
|
|
18055
18133
|
if (self.state._tag !== "Open") return resumeUnoffered(entry);
|
|
18056
18134
|
const offers = self.state.offers;
|
|
18057
18135
|
offers.add(entry);
|
|
18058
|
-
return sync$
|
|
18136
|
+
return sync$2(() => {
|
|
18059
18137
|
if (self.state._tag === "Done") return;
|
|
18060
18138
|
offers.delete(entry);
|
|
18061
18139
|
if (self.state._tag === "Closing" && offers.size === 0 && self.messages.length === 0) finalize(self, self.state.exit);
|
|
@@ -18250,7 +18328,7 @@ var SemaphoreImpl = class {
|
|
|
18250
18328
|
* @category constructors
|
|
18251
18329
|
* @since 4.0.0
|
|
18252
18330
|
*/
|
|
18253
|
-
const make$25 = (permits) => sync$
|
|
18331
|
+
const make$25 = (permits) => sync$2(() => new SemaphoreImpl(permits));
|
|
18254
18332
|
// ../../node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Channel.js
|
|
18255
18333
|
/**
|
|
18256
18334
|
* Provides low-level building blocks for streaming data through Effect.
|
|
@@ -18564,7 +18642,7 @@ const readableStreamToPullUnsafe = (options) => {
|
|
|
18564
18642
|
}
|
|
18565
18643
|
});
|
|
18566
18644
|
});
|
|
18567
|
-
return as$1(addFinalizer$1(options.scope, options.releaseLockOnEnd ? sync(() => reader.releaseLock()) : promise(() => reader.cancel().catch((error) => reader.closed.then(() => Promise.reject(error), constVoid))).pipe(ensuring$2(sync(() => reader.releaseLock())))), pull);
|
|
18645
|
+
return as$1(addFinalizer$1(options.scope, options.releaseLockOnEnd ? sync$1(() => reader.releaseLock()) : promise(() => reader.cancel().catch((error) => reader.closed.then(() => Promise.reject(error), constVoid))).pipe(ensuring$2(sync$1(() => reader.releaseLock())))), pull);
|
|
18568
18646
|
};
|
|
18569
18647
|
/**
|
|
18570
18648
|
* Maps the done value of this channel using the specified function.
|
|
@@ -18707,7 +18785,7 @@ const mergeEffect$1 = /*#__PURE__*/ dual(2, (self, effect) => merge$2(self, from
|
|
|
18707
18785
|
* @category splitting
|
|
18708
18786
|
* @since 2.0.0
|
|
18709
18787
|
*/
|
|
18710
|
-
const splitLines$1 = () => fromTransform$1((upstream, _scope) => sync(() => {
|
|
18788
|
+
const splitLines$1 = () => fromTransform$1((upstream, _scope) => sync$1(() => {
|
|
18711
18789
|
let stringBuilder = "";
|
|
18712
18790
|
let midCRLF = false;
|
|
18713
18791
|
let done = none();
|
|
@@ -18791,7 +18869,7 @@ const splitLines$1 = () => fromTransform$1((upstream, _scope) => sync(() => {
|
|
|
18791
18869
|
* @category decoding
|
|
18792
18870
|
* @since 4.0.0
|
|
18793
18871
|
*/
|
|
18794
|
-
const decodeText$1 = (encoding, options) => fromTransform$1((upstream, _scope) => sync(() => {
|
|
18872
|
+
const decodeText$1 = (encoding, options) => fromTransform$1((upstream, _scope) => sync$1(() => {
|
|
18795
18873
|
const decoder = new TextDecoder(encoding, options);
|
|
18796
18874
|
const streamOptions = { stream: true };
|
|
18797
18875
|
let pull = upstream.pipe(map$3(map$6((bytes) => decoder.decode(bytes, streamOptions))), catchDone((leftover) => {
|
|
@@ -19451,7 +19529,7 @@ const release = (self, state) => {
|
|
|
19451
19529
|
});
|
|
19452
19530
|
}
|
|
19453
19531
|
return void_;
|
|
19454
|
-
})).pipe(ensuring$2(sync(() => {
|
|
19532
|
+
})).pipe(ensuring$2(sync$1(() => {
|
|
19455
19533
|
state.fiber = void 0;
|
|
19456
19534
|
})), runForkWith(self.context), runIn(self.scope));
|
|
19457
19535
|
return void_;
|
|
@@ -20022,7 +20100,7 @@ const mapError = /*#__PURE__*/ dual(2, (self, f) => fromChannel(mapError$1(self.
|
|
|
20022
20100
|
* @category aggregation
|
|
20023
20101
|
* @since 2.0.0
|
|
20024
20102
|
*/
|
|
20025
|
-
const transduce = /*#__PURE__*/ dual(2, (self, sink) => transformPull(self, (upstream, scope) => sync(() => {
|
|
20103
|
+
const transduce = /*#__PURE__*/ dual(2, (self, sink) => transformPull(self, (upstream, scope) => sync$1(() => {
|
|
20026
20104
|
let done;
|
|
20027
20105
|
let leftover;
|
|
20028
20106
|
const upstreamWithLeftover = suspend$2(() => {
|
|
@@ -20355,7 +20433,7 @@ const toReadableStreamWith = /*#__PURE__*/ dual((args) => isStream(args[0]), (se
|
|
|
20355
20433
|
const onAbort = () => fiber.interruptUnsafe();
|
|
20356
20434
|
return new ReadableStream({
|
|
20357
20435
|
start(controller) {
|
|
20358
|
-
fiber = runFork(provideContext(runForEach$1(transformPull$1(self.channel, (pull) => succeed$2(latch.whenOpen(pull))), (chunk) => sync(() => {
|
|
20436
|
+
fiber = runFork(provideContext(runForEach$1(transformPull$1(self.channel, (pull) => succeed$2(latch.whenOpen(pull))), (chunk) => sync$1(() => {
|
|
20359
20437
|
latch.closeUnsafe();
|
|
20360
20438
|
for (let i = 0; i < chunk.length; i++) controller.enqueue(chunk[i]);
|
|
20361
20439
|
currentResolve();
|
|
@@ -24421,14 +24499,14 @@ const reservedWords = /*#__PURE__*/ new Set([
|
|
|
24421
24499
|
const quoteWord = (format, value, program) => {
|
|
24422
24500
|
switch (format) {
|
|
24423
24501
|
case "posix": return program && reservedWords.has(value) ? `'${value}'` : quotePosix(value);
|
|
24424
|
-
case "powershell": return quotePowerShell(value);
|
|
24502
|
+
case "powershell": return quotePowerShell$1(value);
|
|
24425
24503
|
case "windows": return program && !value.includes("\"") ? quoteWindowsProgram(value) : quoteWindowsArgument(value);
|
|
24426
24504
|
}
|
|
24427
24505
|
};
|
|
24428
24506
|
const joinWords = (format, quoted) => format === "powershell" ? `& ${quoted.join(" ")}` : quoted.join(" ");
|
|
24429
24507
|
const posixSafe = /^[A-Za-z0-9_@+:,./-]+$/;
|
|
24430
24508
|
const quotePosix = (value) => posixSafe.test(value) ? value : `'${value.replace(/['\\]/g, (char) => `'\\${char}'`)}'`;
|
|
24431
|
-
const quotePowerShell = (value) => `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, "$&$&")}'`;
|
|
24509
|
+
const quotePowerShell$1 = (value) => `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, "$&$&")}'`;
|
|
24432
24510
|
const windowsNeedsQuotes = /[ \t\n\v"]/;
|
|
24433
24511
|
const quoteWindowsArgument = (value) => {
|
|
24434
24512
|
if (value.length > 0 && !windowsNeedsQuotes.test(value)) return value;
|
|
@@ -24859,7 +24937,7 @@ const pullIntoWritable = (options) => withFiber((fiber) => {
|
|
|
24859
24937
|
if (!cancelled) resume(void_);
|
|
24860
24938
|
};
|
|
24861
24939
|
loop();
|
|
24862
|
-
return sync(() => {
|
|
24940
|
+
return sync$1(() => {
|
|
24863
24941
|
cancelled = true;
|
|
24864
24942
|
options.writable.off("drain", loop);
|
|
24865
24943
|
options.writable.off("finish", onFinish);
|
|
@@ -24868,7 +24946,7 @@ const pullIntoWritable = (options) => withFiber((fiber) => {
|
|
|
24868
24946
|
}), forever({ disableYield: true }), options.endOnDone !== false ? catchDone((_) => {
|
|
24869
24947
|
options.writable.end();
|
|
24870
24948
|
return andThen(_await(completion), done$1(_));
|
|
24871
|
-
}) : identity, raceFirst(_await(failure)), ensuring$2(sync(() => {
|
|
24949
|
+
}) : identity, raceFirst(_await(failure)), ensuring$2(sync$1(() => {
|
|
24872
24950
|
cleanup();
|
|
24873
24951
|
const removeErrorListener = () => {
|
|
24874
24952
|
options.writable.off("error", onStreamError);
|
|
@@ -24954,7 +25032,7 @@ const readableToPullUnsafe = (options) => {
|
|
|
24954
25032
|
}
|
|
24955
25033
|
return succeed$2(chunk);
|
|
24956
25034
|
});
|
|
24957
|
-
return as$1(addFinalizer$1(options.scope, sync(() => {
|
|
25035
|
+
return as$1(addFinalizer$1(options.scope, sync$1(() => {
|
|
24958
25036
|
readable.off("readable", onReadable);
|
|
24959
25037
|
if (closeOnDone) destroyStream(readable, cleanup);
|
|
24960
25038
|
else cleanup();
|
|
@@ -25211,7 +25289,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
25211
25289
|
handle.on("spawn", () => {
|
|
25212
25290
|
resume(succeed$2([handle, deferred]));
|
|
25213
25291
|
});
|
|
25214
|
-
return sync(() => {
|
|
25292
|
+
return sync$1(() => {
|
|
25215
25293
|
handle.kill("SIGTERM");
|
|
25216
25294
|
});
|
|
25217
25295
|
});
|
|
@@ -25264,7 +25342,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
25264
25342
|
};
|
|
25265
25343
|
childProcess.on("exit", poll);
|
|
25266
25344
|
poll();
|
|
25267
|
-
return sync(stop);
|
|
25345
|
+
return sync$1(stop);
|
|
25268
25346
|
});
|
|
25269
25347
|
const terminateProcessGroup = fnUntraced(function* (command, childProcess, exitSignal, options) {
|
|
25270
25348
|
const signalGroup = (signal) => ownsProcessGroup(command, childProcess) ? killProcessGroup(command, childProcess, signal).pipe(catch_((error) => hasExited(childProcess) && isUnsignallableProcessGroup(error.cause) ? void_ : killProcess(command, childProcess, signal))) : killProcess(command, childProcess, signal);
|
|
@@ -25338,13 +25416,13 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
25338
25416
|
if (cmd.options.detached !== false) childProcess.on("exit", (code) => {
|
|
25339
25417
|
if (code !== 0 && isNotNull(code)) killProcessGroupOnExit(childProcess, cmd.options.killSignal ?? "SIGTERM");
|
|
25340
25418
|
});
|
|
25341
|
-
const reref = sync(() => {
|
|
25419
|
+
const reref = sync$1(() => {
|
|
25342
25420
|
if (!isReferenced) {
|
|
25343
25421
|
childProcess.ref();
|
|
25344
25422
|
isReferenced = true;
|
|
25345
25423
|
}
|
|
25346
25424
|
});
|
|
25347
|
-
const unref = sync(() => {
|
|
25425
|
+
const unref = sync$1(() => {
|
|
25348
25426
|
if (isReferenced) {
|
|
25349
25427
|
childProcess.unref();
|
|
25350
25428
|
isReferenced = false;
|
|
@@ -25816,7 +25894,7 @@ const utimes = /*#__PURE__*/ (() => {
|
|
|
25816
25894
|
const nodeUtimes = /*#__PURE__*/ effectify(node_fs.utimes, /*#__PURE__*/ handleErrnoException("FileSystem", "utime"), /*#__PURE__*/ handleBadArgument("utime"));
|
|
25817
25895
|
return (path, atime, mtime) => nodeUtimes(path, atime, mtime);
|
|
25818
25896
|
})();
|
|
25819
|
-
const watchNode = (path, info, options) => callback((queue) => acquireRelease(sync(() => {
|
|
25897
|
+
const watchNode = (path, info, options) => callback((queue) => acquireRelease(sync$1(() => {
|
|
25820
25898
|
const directory = info.type === "Directory" ? path : node_path.dirname(path);
|
|
25821
25899
|
const watcher = node_fs.watch(path, { recursive: options?.recursive ?? false }, (event, path) => {
|
|
25822
25900
|
if (!path) return;
|
|
@@ -25854,7 +25932,7 @@ const watchNode = (path, info, options) => callback((queue) => acquireRelease(sy
|
|
|
25854
25932
|
endUnsafe(queue);
|
|
25855
25933
|
});
|
|
25856
25934
|
return watcher;
|
|
25857
|
-
}), (watcher) => sync(() => watcher.close())).pipe(tap(() => sync(() => options?.onReady?.()))));
|
|
25935
|
+
}), (watcher) => sync$1(() => watcher.close())).pipe(tap(() => sync$1(() => options?.onReady?.()))));
|
|
25858
25936
|
const watch = (backend, path, options) => all([stat(path), serviceOption(WatchBackend)]).pipe(map$3(([stat, callerBackend]) => orElse(callerBackend, () => backend).pipe(flatMap$4((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap$3);
|
|
25859
25937
|
const writeFile = (path, data, options) => callback$1((resume, signal) => {
|
|
25860
25938
|
try {
|
|
@@ -26075,10 +26153,10 @@ const make$14 = (options) => ({
|
|
|
26075
26153
|
* @since 4.0.0
|
|
26076
26154
|
*/
|
|
26077
26155
|
const layer$5 = /* @__PURE__ */ succeed$3(Stdio, /*#__PURE__*/ make$14({
|
|
26078
|
-
args: /*#__PURE__*/ sync(() => process.argv.slice(2)),
|
|
26079
|
-
stdinIsTerminal: /*#__PURE__*/ sync(() => process.stdin.isTTY === true),
|
|
26080
|
-
stdoutIsTerminal: /*#__PURE__*/ sync(() => process.stdout.isTTY === true),
|
|
26081
|
-
stderrIsTerminal: /*#__PURE__*/ sync(() => process.stderr.isTTY === true),
|
|
26156
|
+
args: /*#__PURE__*/ sync$1(() => process.argv.slice(2)),
|
|
26157
|
+
stdinIsTerminal: /*#__PURE__*/ sync$1(() => process.stdin.isTTY === true),
|
|
26158
|
+
stdoutIsTerminal: /*#__PURE__*/ sync$1(() => process.stdout.isTTY === true),
|
|
26159
|
+
stderrIsTerminal: /*#__PURE__*/ sync$1(() => process.stderr.isTTY === true),
|
|
26082
26160
|
stdout: (options) => fromWritable({
|
|
26083
26161
|
evaluate: () => process.stdout,
|
|
26084
26162
|
onError: (cause) => systemError({
|
|
@@ -28773,9 +28851,9 @@ const layer$4 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
|
|
|
28773
28851
|
if (!readlineActive) endUnsafe(lines);
|
|
28774
28852
|
};
|
|
28775
28853
|
stdin.once("end", onStdinEnd);
|
|
28776
|
-
yield* addFinalizer(() => sync(() => stdin.off("end", onStdinEnd)));
|
|
28854
|
+
yield* addFinalizer(() => sync$1(() => stdin.off("end", onStdinEnd)));
|
|
28777
28855
|
const rlRef = yield* make$23({
|
|
28778
|
-
acquire: acquireRelease(sync(() => {
|
|
28856
|
+
acquire: acquireRelease(sync$1(() => {
|
|
28779
28857
|
const rl = node_readline.createInterface({
|
|
28780
28858
|
input: stdin,
|
|
28781
28859
|
escapeCodeTimeout: 50
|
|
@@ -28794,7 +28872,7 @@ const layer$4 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
|
|
|
28794
28872
|
onClose,
|
|
28795
28873
|
onLine
|
|
28796
28874
|
};
|
|
28797
|
-
}), ({ rl, onClose, onLine }) => sync(() => {
|
|
28875
|
+
}), ({ rl, onClose, onLine }) => sync$1(() => {
|
|
28798
28876
|
readlineActive = false;
|
|
28799
28877
|
rl.off("line", onLine);
|
|
28800
28878
|
rl.off("close", onClose);
|
|
@@ -28803,22 +28881,22 @@ const layer$4 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
|
|
|
28803
28881
|
})),
|
|
28804
28882
|
idleTimeToLive: "10 millis"
|
|
28805
28883
|
});
|
|
28806
|
-
const setRawMode = (enabled) => sync(() => {
|
|
28884
|
+
const setRawMode = (enabled) => sync$1(() => {
|
|
28807
28885
|
if (stdin.isTTY) stdin.setRawMode(enabled);
|
|
28808
28886
|
});
|
|
28809
28887
|
const rawModeRef = yield* make$23({
|
|
28810
28888
|
acquire: acquireRelease(setRawMode(true), () => setRawMode(false)),
|
|
28811
28889
|
idleTimeToLive: "10 millis"
|
|
28812
28890
|
});
|
|
28813
|
-
const columns = sync(() => stdout.columns ?? 0);
|
|
28814
|
-
const rows = sync(() => stdout.rows ?? 0);
|
|
28891
|
+
const columns = sync$1(() => stdout.columns ?? 0);
|
|
28892
|
+
const rows = sync$1(() => stdout.rows ?? 0);
|
|
28815
28893
|
const size = gen(function* () {
|
|
28816
28894
|
const queue = yield* sliding(1);
|
|
28817
28895
|
const onResize = () => offerUnsafe(queue, {
|
|
28818
28896
|
columns: stdout.columns ?? 0,
|
|
28819
28897
|
rows: stdout.rows ?? 0
|
|
28820
28898
|
});
|
|
28821
|
-
yield* addFinalizer(() => sync(() => {
|
|
28899
|
+
yield* addFinalizer(() => sync$1(() => {
|
|
28822
28900
|
stdout.off("resize", onResize);
|
|
28823
28901
|
endUnsafe(queue);
|
|
28824
28902
|
}));
|
|
@@ -28846,7 +28924,7 @@ const layer$4 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
|
|
|
28846
28924
|
clearInterval(keepAlive);
|
|
28847
28925
|
endUnsafe(queue);
|
|
28848
28926
|
};
|
|
28849
|
-
yield* addFinalizer(() => sync(() => {
|
|
28927
|
+
yield* addFinalizer(() => sync$1(() => {
|
|
28850
28928
|
clearInterval(keepAlive);
|
|
28851
28929
|
stdin.off("keypress", handleKeypress);
|
|
28852
28930
|
stdin.off("end", handleEnd);
|
|
@@ -29660,7 +29738,7 @@ const consoleWith = (f) => withFiber$1((fiber) => f(fiber.getRef(Console)));
|
|
|
29660
29738
|
* @category accessors
|
|
29661
29739
|
* @since 2.0.0
|
|
29662
29740
|
*/
|
|
29663
|
-
const error = (...args) => consoleWith((console) => sync$
|
|
29741
|
+
const error = (...args) => consoleWith((console) => sync$2(() => {
|
|
29664
29742
|
console.error(...args);
|
|
29665
29743
|
}));
|
|
29666
29744
|
/**
|
|
@@ -29694,7 +29772,7 @@ const error = (...args) => consoleWith((console) => sync$1(() => {
|
|
|
29694
29772
|
* @category accessors
|
|
29695
29773
|
* @since 2.0.0
|
|
29696
29774
|
*/
|
|
29697
|
-
const log = (...args) => consoleWith((console) => sync$
|
|
29775
|
+
const log = (...args) => consoleWith((console) => sync$2(() => {
|
|
29698
29776
|
console.log(...args);
|
|
29699
29777
|
}));
|
|
29700
29778
|
// ../../node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/cli/CliError.js
|
|
@@ -32131,7 +32209,7 @@ const handleProcessFloat = (options) => {
|
|
|
32131
32209
|
...state,
|
|
32132
32210
|
error: some("Must provide a floating point value")
|
|
32133
32211
|
} }));
|
|
32134
|
-
else return flatMap$1(sync(() => round(parsed, options.precision)), (rounded) => match$1(options.validate(rounded), {
|
|
32212
|
+
else return flatMap$1(sync$1(() => round(parsed, options.precision)), (rounded) => match$1(options.validate(rounded), {
|
|
32135
32213
|
onFailure: (error) => Action$1.NextFrame({ state: {
|
|
32136
32214
|
...state,
|
|
32137
32215
|
error: some(error)
|
|
@@ -37019,14 +37097,14 @@ const showHelp = (command, error, renderErrors) => gen(function* () {
|
|
|
37019
37097
|
helpDoc
|
|
37020
37098
|
});
|
|
37021
37099
|
});
|
|
37022
|
-
const showUserError = (error$
|
|
37100
|
+
const showUserError = (error$3, userMessage) => gen(function* () {
|
|
37023
37101
|
const formatter = yield* resolveFormatter;
|
|
37024
|
-
const rendered = error$
|
|
37025
|
-
cause: error$
|
|
37102
|
+
const rendered = error$3 instanceof UserError ? error$3 : new UserError({
|
|
37103
|
+
cause: error$3,
|
|
37026
37104
|
userMessage
|
|
37027
37105
|
});
|
|
37028
37106
|
yield* error(formatter.formatError(rendered));
|
|
37029
|
-
Object.assign(error$
|
|
37107
|
+
Object.assign(error$3, { [errorReported]: false });
|
|
37030
37108
|
});
|
|
37031
37109
|
/**
|
|
37032
37110
|
* Runs a command using the arguments supplied by the `Stdio` service.
|
|
@@ -38186,7 +38264,7 @@ const make$1 = (f) => makeWith((effect) => flatMap$1(effect, (request) => withFi
|
|
|
38186
38264
|
cause: urlResult.failure
|
|
38187
38265
|
}) }));
|
|
38188
38266
|
const url = urlResult.success;
|
|
38189
|
-
const send = (request) => scope === void 0 ? f(request, url, controller.signal, fiber) : flatMap$1(addFinalizer$1(scope, sync(() => controller.abort())), () => f(request, url, controller.signal, fiber));
|
|
38267
|
+
const send = (request) => scope === void 0 ? f(request, url, controller.signal, fiber) : flatMap$1(addFinalizer$1(scope, sync$1(() => controller.abort())), () => f(request, url, controller.signal, fiber));
|
|
38190
38268
|
const exchange = (request, onResponse) => uninterruptibleMask((restore) => matchCauseEffect(restore(send(request)), {
|
|
38191
38269
|
onSuccess: (response) => {
|
|
38192
38270
|
response = trackResponse(response, controller, scope !== void 0, urlParamsRedactedNames);
|
|
@@ -38353,7 +38431,7 @@ var InterruptibleResponse = class {
|
|
|
38353
38431
|
applyInterrupt(effect) {
|
|
38354
38432
|
return suspend$2(() => {
|
|
38355
38433
|
responseRegistry.unregister(this.original);
|
|
38356
|
-
return onInterrupt(effect, () => sync(() => {
|
|
38434
|
+
return onInterrupt(effect, () => sync$1(() => {
|
|
38357
38435
|
this.controller.abort();
|
|
38358
38436
|
}));
|
|
38359
38437
|
});
|
|
@@ -38402,7 +38480,7 @@ var InterruptibleResponse = class {
|
|
|
38402
38480
|
get stream() {
|
|
38403
38481
|
return suspend(() => {
|
|
38404
38482
|
responseRegistry.unregister(this.original);
|
|
38405
|
-
return ensuring(this.original.stream, sync(() => {
|
|
38483
|
+
return ensuring(this.original.stream, sync$1(() => {
|
|
38406
38484
|
this.controller.abort();
|
|
38407
38485
|
}));
|
|
38408
38486
|
});
|
|
@@ -38550,7 +38628,7 @@ const layer$1 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$2(/* @__P
|
|
|
38550
38628
|
let headers = options.headers ? merge(fromInput$1(options.headers), request.headers) : request.headers;
|
|
38551
38629
|
if (headers["content-length"]) headers = remove(headers, "content-length");
|
|
38552
38630
|
let uploadController;
|
|
38553
|
-
const stopUpload = sync(() => uploadController?.abort());
|
|
38631
|
+
const stopUpload = sync$1(() => uploadController?.abort());
|
|
38554
38632
|
const send = (body) => map$3(tryPromise({
|
|
38555
38633
|
try: () => fetch(url, {
|
|
38556
38634
|
...options,
|
|
@@ -38595,7 +38673,7 @@ const layer$1 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$2(/* @__P
|
|
|
38595
38673
|
return;
|
|
38596
38674
|
}
|
|
38597
38675
|
uploadSignal.addEventListener("abort", onAbort, { once: true });
|
|
38598
|
-
return sync(() => uploadSignal.removeEventListener("abort", onAbort));
|
|
38676
|
+
return sync$1(() => uploadSignal.removeEventListener("abort", onAbort));
|
|
38599
38677
|
});
|
|
38600
38678
|
return flatMap$1(toReadableStreamEffect(interruptWhen(request.body.stream, stopped)), send);
|
|
38601
38679
|
}
|
|
@@ -38653,6 +38731,8 @@ const homeLayout = (root) => {
|
|
|
38653
38731
|
repairJs: node_path.join(dist, "repair.cjs"),
|
|
38654
38732
|
shimJs: node_path.join(dist, "shim.cjs"),
|
|
38655
38733
|
updateHelper: node_path.join(dist, "update-helper.ps1"),
|
|
38734
|
+
backendHost: node_path.join(dist, "backend-host.cjs"),
|
|
38735
|
+
pluginLogs: node_path.join(logs, "plugins"),
|
|
38656
38736
|
updates: node_path.join(root, "updates"),
|
|
38657
38737
|
updateReady: node_path.join(root, "updates", "ready.json"),
|
|
38658
38738
|
updateLog: node_path.join(logs, "update.log"),
|
|
@@ -38670,9 +38750,33 @@ const PLUGIN_FILES = {
|
|
|
38670
38750
|
};
|
|
38671
38751
|
const MAX_PLUGIN_CODE_BYTES = 5242880;
|
|
38672
38752
|
const MAX_PLUGIN_MANIFEST_BYTES = 65536;
|
|
38753
|
+
const MAX_PLUGIN_SCRIPT_BYTES = 20971520;
|
|
38754
|
+
const MAX_PLUGIN_ASSET_BYTES = 67108864;
|
|
38755
|
+
const MAX_PLUGIN_EXTRA_BYTES = 134217728;
|
|
38756
|
+
const isPluginFile = (name) => /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(name) && !name.endsWith(".") && !Object.values(PLUGIN_FILES).some((reserved) => reserved.toLowerCase() === name.toLowerCase());
|
|
38757
|
+
const isPluginScript = (name) => isPluginFile(name) && /\.(?:js|cjs)$/.test(name);
|
|
38758
|
+
const NO_ACCESS = {
|
|
38759
|
+
backend: false,
|
|
38760
|
+
mcp: false
|
|
38761
|
+
};
|
|
38762
|
+
const declaredAccess = (manifest) => ({
|
|
38763
|
+
backend: manifest.backend !== void 0,
|
|
38764
|
+
mcp: manifest.mcp !== void 0
|
|
38765
|
+
});
|
|
38766
|
+
const accessGrew = (approved, next) => next.backend && !approved.backend || next.mcp && !approved.mcp;
|
|
38767
|
+
const extraFiles = (manifest) => [...new Set([
|
|
38768
|
+
manifest.backend,
|
|
38769
|
+
manifest.mcp,
|
|
38770
|
+
...manifest.files ?? []
|
|
38771
|
+
].filter((name) => name !== void 0))];
|
|
38772
|
+
/** Windows file names ignore case, so two extras that differ only by case would share one file. */
|
|
38773
|
+
const extraFilesCollide = (manifest) => {
|
|
38774
|
+
const names = extraFiles(manifest).map((name) => name.toLowerCase());
|
|
38775
|
+
return new Set(names).size !== names.length;
|
|
38776
|
+
};
|
|
38777
|
+
const accessLines = (access) => [...access.backend ? ["Runs a program outside T3 Code's window"] : [], ...access.mcp ? ["Adds tools to your agents"] : []];
|
|
38673
38778
|
/** The entry for `id`. Own keys only, so an id like "constructor" never finds Object's. */
|
|
38674
38779
|
const lockEntry = (lock, id) => Object.hasOwn(lock.plugins, id) ? lock.plugins[id] : void 0;
|
|
38675
|
-
const SOCKET_ALLOW_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}\*?$/;
|
|
38676
38780
|
/** GitHub's rules: letters, digits and inner hyphens, up to 39 characters. */
|
|
38677
38781
|
const OWNER = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
38678
38782
|
const REPO = /^[A-Za-z0-9._-]{1,100}$/;
|
|
@@ -38790,8 +38894,13 @@ const compareVersions = (a, b) => {
|
|
|
38790
38894
|
return 0;
|
|
38791
38895
|
};
|
|
38792
38896
|
// ../shared/src/PluginStore.ts
|
|
38897
|
+
const AccessSchema = Struct({
|
|
38898
|
+
backend: Boolean$4,
|
|
38899
|
+
mcp: Boolean$4
|
|
38900
|
+
});
|
|
38793
38901
|
var PluginError = class extends TaggedError()("PluginError", {
|
|
38794
38902
|
message: String$6,
|
|
38903
|
+
approval: optionalKey(AccessSchema),
|
|
38795
38904
|
cause: optional$3(Defect())
|
|
38796
38905
|
}) {};
|
|
38797
38906
|
const PluginIdSchema = String$6.check(isPattern(PLUGIN_ID_PATTERN, { expected: "an id of lowercase letters, digits and hyphens, up to 64 characters" }));
|
|
@@ -38813,8 +38922,10 @@ const ManifestSchema = Struct({
|
|
|
38813
38922
|
description: String$6,
|
|
38814
38923
|
author: optionalKey(String$6),
|
|
38815
38924
|
api: Number$2,
|
|
38816
|
-
|
|
38817
|
-
|
|
38925
|
+
backend: optionalKey(matching(isPluginScript, "a JavaScript file name")),
|
|
38926
|
+
mcp: optionalKey(matching(isPluginScript, "a JavaScript file name")),
|
|
38927
|
+
files: optionalKey(ArraySchema(matching(isPluginFile, "an extra file name")))
|
|
38928
|
+
}).check(makeFilter((manifest) => extraFiles(manifest).length <= 20, { expected: "at most 20 extra files" }), makeFilter((manifest) => !extraFilesCollide(manifest), { expected: "extra file names that differ by more than case" }));
|
|
38818
38929
|
const RegistrySchema = Struct({ plugins: Record(String$6, matching(isPluginRoute, "a relative POSIX plugin route")).check(makeFilter((plugins) => Object.keys(plugins).every(isPluginId), { expected: "plugin ids as keys" }), makeFilter((plugins) => Object.keys(plugins).length > 0 && Object.keys(plugins).length <= 50, { expected: `1 to 50 plugins` })) });
|
|
38819
38930
|
var DownloadNotFound = class extends TaggedError()("DownloadNotFound", {
|
|
38820
38931
|
message: String$6,
|
|
@@ -38825,7 +38936,11 @@ const LockfileSchema = Struct({
|
|
|
38825
38936
|
plugins: Record(String$6, Struct({
|
|
38826
38937
|
source: PluginSourceSchema,
|
|
38827
38938
|
version: String$6,
|
|
38828
|
-
sha256: optionalKey(String$6)
|
|
38939
|
+
sha256: optionalKey(String$6),
|
|
38940
|
+
files: optionalKey(Record(String$6, String$6).check(makeFilter((files) => Object.keys(files).every((name) => name === PLUGIN_FILES.code || isPluginFile(name)), { expected: "pinned file names" }))),
|
|
38941
|
+
backend: optionalKey(matching(isPluginScript, "a JavaScript file name")),
|
|
38942
|
+
mcp: optionalKey(matching(isPluginScript, "a JavaScript file name")),
|
|
38943
|
+
approved: optionalKey(AccessSchema)
|
|
38829
38944
|
})).check(makeFilter((plugins) => Object.keys(plugins).every(isPluginId), { expected: "plugin ids as keys" }))
|
|
38830
38945
|
});
|
|
38831
38946
|
const RegistryJson = fromJsonString(RegistrySchema);
|
|
@@ -38883,27 +38998,42 @@ const make = fn$1("PluginStore.make")(function* (options) {
|
|
|
38883
38998
|
const temp = `${file}.tmp`;
|
|
38884
38999
|
yield* fs.makeDirectory(path.dirname(file), { recursive: true });
|
|
38885
39000
|
yield* fs.writeFile(temp, bytes);
|
|
38886
|
-
yield* fs.rename(temp, file);
|
|
39001
|
+
yield* fs.rename(temp, file).pipe(tapError$2(() => fs.remove(temp, { force: true }).pipe(ignore)));
|
|
38887
39002
|
}, mapError$2(fail("t3mode could not write to its plugins folder.")));
|
|
38888
39003
|
const readLock = gen(function* () {
|
|
38889
39004
|
if (!(yield* fs.exists(layout.pluginsLock).pipe(orElseSucceed(() => false)))) return EMPTY_LOCK;
|
|
38890
39005
|
const text = yield* fs.readFileString(layout.pluginsLock).pipe(mapError$2(fail(`Could not read ${layout.pluginsLock}.`)));
|
|
38891
|
-
|
|
39006
|
+
const decoded = yield* decodeEffect(LockfileJson)(text).pipe(mapError$2((cause) => new PluginError({
|
|
38892
39007
|
message: `${layout.pluginsLock} is invalid (${describeSchemaError(cause)}). Fix or delete it.`,
|
|
38893
39008
|
cause
|
|
38894
39009
|
})));
|
|
39010
|
+
const plugins = {};
|
|
39011
|
+
for (const [id, entry] of Object.entries(decoded.plugins)) {
|
|
39012
|
+
const folder = entry.source.kind === "local" ? entry.source.path : path.join(layout.plugins, id);
|
|
39013
|
+
const manifest = entry.approved === void 0 ? yield* fs.readFileString(path.join(folder, PLUGIN_FILES.manifest)).pipe(flatMap$1(decodeEffect(ManifestJson)), option) : none();
|
|
39014
|
+
plugins[id] = {
|
|
39015
|
+
...entry,
|
|
39016
|
+
...entry.files === void 0 && entry.sha256 !== void 0 ? { files: { [PLUGIN_FILES.code]: entry.sha256 } } : {},
|
|
39017
|
+
...isSome(manifest) ? { approved: declaredAccess(manifest.value) } : {}
|
|
39018
|
+
};
|
|
39019
|
+
}
|
|
39020
|
+
return {
|
|
39021
|
+
...decoded,
|
|
39022
|
+
plugins
|
|
39023
|
+
};
|
|
38895
39024
|
});
|
|
38896
39025
|
const writeLock = fn$1("PluginStore.writeLock")(function* (next) {
|
|
38897
39026
|
const text = yield* encodeEffect(LockfileJson)(next).pipe(mapError$2(fail("Could not encode plugins.json.")));
|
|
38898
39027
|
yield* writeAtomic(layout.pluginsLock, new TextEncoder().encode(`${text}\n`));
|
|
38899
39028
|
});
|
|
38900
|
-
const writeCodeThenManifestThenLock = fn$1("PluginStore.writeCodeThenManifestThenLock")(function* (id,
|
|
39029
|
+
const writeCodeThenManifestThenLock = fn$1("PluginStore.writeCodeThenManifestThenLock")(function* (id, files, manifest, next) {
|
|
38901
39030
|
const folder = path.join(layout.plugins, id);
|
|
38902
|
-
yield* writeAtomic(path.join(folder,
|
|
39031
|
+
for (const [name, bytes] of Object.entries(files)) yield* writeAtomic(path.join(folder, name), bytes);
|
|
38903
39032
|
yield* writeAtomic(path.join(folder, PLUGIN_FILES.manifest), manifest);
|
|
38904
39033
|
yield* writeLock(next);
|
|
38905
39034
|
});
|
|
38906
39035
|
const folderOf = (id, entry) => entry.source.kind === "github" ? path.join(layout.plugins, id) : entry.source.path;
|
|
39036
|
+
const stopProcesses = (id, entry) => entry && options.stopProcesses && (entry.backend !== void 0 || entry.source.kind === "github" && entry.mcp !== void 0) ? options.stopProcesses(id, folderOf(id, entry), entry.backend !== void 0) : succeed$2(void_);
|
|
38907
39037
|
const inspect = fn$1("PluginStore.inspect")(function* (id, entry) {
|
|
38908
39038
|
const base = {
|
|
38909
39039
|
id,
|
|
@@ -38921,7 +39051,6 @@ const make = fn$1("PluginStore.make")(function* (options) {
|
|
|
38921
39051
|
const manifest = decoded.success;
|
|
38922
39052
|
const described = {
|
|
38923
39053
|
...base,
|
|
38924
|
-
...manifest.sockets === void 0 ? {} : { sockets: manifest.sockets },
|
|
38925
39054
|
name: manifest.name,
|
|
38926
39055
|
description: manifest.description,
|
|
38927
39056
|
version: manifest.version,
|
|
@@ -38932,12 +39061,45 @@ const make = fn$1("PluginStore.make")(function* (options) {
|
|
|
38932
39061
|
const code = yield* fs.readFile(path.join(folder, PLUGIN_FILES.code)).pipe(option);
|
|
38933
39062
|
if (isNone(code)) return failed(described, `plugin.js is missing from ${folder}.`);
|
|
38934
39063
|
if (code.value.byteLength > 5242880) return failed(described, `plugin.js is larger than ${megabytes(MAX_PLUGIN_CODE_BYTES)}.`);
|
|
38935
|
-
if (entry.source.kind === "github"
|
|
39064
|
+
if (entry.source.kind === "github") {
|
|
39065
|
+
if (!entry.files?.[PLUGIN_FILES.code]) return failed(described, "plugin.js has no installed hash. Install it again.");
|
|
39066
|
+
for (const [name, hash] of Object.entries(entry.files ?? {})) {
|
|
39067
|
+
const bytes = name === PLUGIN_FILES.code ? code : yield* fs.readFile(path.join(folder, name)).pipe(option);
|
|
39068
|
+
if (isNone(bytes) || (yield* sha256Hex(bytes.value)) !== hash) return failed(described, `${name} changed since it was installed. Install it again.`);
|
|
39069
|
+
}
|
|
39070
|
+
}
|
|
38936
39071
|
return {
|
|
38937
39072
|
plugin: described,
|
|
38938
39073
|
code: code.value
|
|
38939
39074
|
};
|
|
38940
39075
|
});
|
|
39076
|
+
/** A program script's absolute path, or undefined when it isn't there to run. */
|
|
39077
|
+
const programScript = fn$1("PluginStore.programScript")(function* (folder, entry, name) {
|
|
39078
|
+
if (name === void 0) return void 0;
|
|
39079
|
+
if (entry.source.kind === "github") return entry.files?.[name] === void 0 ? void 0 : path.join(folder, name);
|
|
39080
|
+
const file = path.join(folder, name);
|
|
39081
|
+
return (yield* fs.exists(file).pipe(orElseSucceed(() => false))) ? file : void 0;
|
|
39082
|
+
});
|
|
39083
|
+
/** A plugin's runnable programs, or undefined when it has none or doesn't load. */
|
|
39084
|
+
const program = fn$1("PluginStore.program")(function* (id, entry) {
|
|
39085
|
+
if (entry.mcp === void 0 && entry.backend === void 0) return void 0;
|
|
39086
|
+
if ((yield* inspect(id, entry)).plugin.error !== void 0) return void 0;
|
|
39087
|
+
const folder = folderOf(id, entry);
|
|
39088
|
+
const linked = entry.source.kind === "local";
|
|
39089
|
+
const mcp = yield* programScript(folder, entry, entry.approved?.mcp === false ? void 0 : entry.mcp);
|
|
39090
|
+
const backend = yield* programScript(folder, entry, entry.approved?.backend === false ? void 0 : entry.backend);
|
|
39091
|
+
if (mcp === void 0 && backend === void 0) return void 0;
|
|
39092
|
+
const modified = linked && backend !== void 0 ? yield* fs.stat(backend).pipe(map$3((info) => getOrUndefined$1(info.mtime)?.getTime()), orElseSucceed(() => void 0)) : void 0;
|
|
39093
|
+
const version = linked ? `${entry.version}@${modified ?? 0}` : Object.entries(entry.files ?? {}).map(([name, hash]) => `${name}:${hash}`).join(",");
|
|
39094
|
+
return {
|
|
39095
|
+
id,
|
|
39096
|
+
folder,
|
|
39097
|
+
linked,
|
|
39098
|
+
...mcp === void 0 ? {} : { mcp },
|
|
39099
|
+
...backend === void 0 ? {} : { backend },
|
|
39100
|
+
version
|
|
39101
|
+
};
|
|
39102
|
+
});
|
|
38941
39103
|
const inspectAll = readLock.pipe(catch_((error) => logWarning(error.message, error.cause).pipe(as$1(EMPTY_LOCK))), flatMap$1((current) => forEach$1(Object.entries(current.plugins), ([id, entry]) => inspect(id, entry))), map$3((items) => items.toSorted((a, b) => a.plugin.name.localeCompare(b.plugin.name))));
|
|
38942
39104
|
const toScript = (id, code) => ({
|
|
38943
39105
|
name: pluginScriptName(id),
|
|
@@ -38981,25 +39143,48 @@ const make = fn$1("PluginStore.make")(function* (options) {
|
|
|
38981
39143
|
};
|
|
38982
39144
|
});
|
|
38983
39145
|
const withLock = lock.withPermits(1);
|
|
38984
|
-
const installNow = fn$1("PluginStore.installNow")(function* (source, expectedId) {
|
|
39146
|
+
const installNow = fn$1("PluginStore.installNow")(function* (source, expectedId, approved) {
|
|
38985
39147
|
const { manifest, bytes: manifestBytes, release } = yield* fetchManifest(source);
|
|
38986
39148
|
yield* checkManifest(manifest, release, expectedId);
|
|
38987
39149
|
const current = yield* readLock;
|
|
38988
39150
|
yield* checkConflict(current, manifest.id, source);
|
|
38989
|
-
const
|
|
38990
|
-
const
|
|
39151
|
+
const previous = lockEntry(current, manifest.id);
|
|
39152
|
+
const access = declaredAccess(manifest);
|
|
39153
|
+
const baseline = approved ?? previous?.approved ?? NO_ACCESS;
|
|
39154
|
+
if (baseline !== "any" && accessGrew(baseline, access)) return yield* new PluginError({
|
|
39155
|
+
message: previous ? "This update asks for new access." : "This release asks for access you weren't shown. Look at it again before installing.",
|
|
39156
|
+
approval: access
|
|
39157
|
+
});
|
|
39158
|
+
const files = {};
|
|
39159
|
+
files[PLUGIN_FILES.code] = (yield* download(source, PLUGIN_FILES.code, MAX_PLUGIN_CODE_BYTES)).bytes;
|
|
39160
|
+
let total = 0;
|
|
39161
|
+
for (const name of extraFiles(manifest)) {
|
|
39162
|
+
const cap = name === manifest.backend || name === manifest.mcp ? MAX_PLUGIN_SCRIPT_BYTES : MAX_PLUGIN_ASSET_BYTES;
|
|
39163
|
+
const bytes = (yield* download(source, name, Math.min(cap, MAX_PLUGIN_EXTRA_BYTES - total))).bytes;
|
|
39164
|
+
total += bytes.byteLength;
|
|
39165
|
+
files[name] = bytes;
|
|
39166
|
+
}
|
|
39167
|
+
const hashes = {};
|
|
39168
|
+
for (const [name, bytes] of Object.entries(files)) hashes[name] = yield* sha256Hex(bytes);
|
|
38991
39169
|
const entry = {
|
|
38992
39170
|
source,
|
|
38993
39171
|
version: manifest.version,
|
|
38994
|
-
sha256
|
|
39172
|
+
sha256: hashes[PLUGIN_FILES.code],
|
|
39173
|
+
files: hashes,
|
|
39174
|
+
...manifest.backend === void 0 ? {} : { backend: manifest.backend },
|
|
39175
|
+
...manifest.mcp === void 0 ? {} : { mcp: manifest.mcp },
|
|
39176
|
+
approved: access
|
|
38995
39177
|
};
|
|
38996
|
-
yield*
|
|
38997
|
-
|
|
38998
|
-
|
|
38999
|
-
|
|
39000
|
-
|
|
39001
|
-
|
|
39002
|
-
|
|
39178
|
+
yield* acquireUseRelease(stopProcesses(manifest.id, previous), () => gen(function* () {
|
|
39179
|
+
yield* writeCodeThenManifestThenLock(manifest.id, files, manifestBytes, {
|
|
39180
|
+
...current,
|
|
39181
|
+
plugins: {
|
|
39182
|
+
...current.plugins,
|
|
39183
|
+
[manifest.id]: entry
|
|
39184
|
+
}
|
|
39185
|
+
});
|
|
39186
|
+
for (const name of Object.keys(previous?.files ?? {})) if (!Object.hasOwn(files, name)) yield* fs.remove(path.join(layout.plugins, manifest.id, name), { force: true }).pipe(mapError$2(fail(`Could not delete ${name}.`)));
|
|
39187
|
+
}), (resume) => resume);
|
|
39003
39188
|
yield* logInfo(`Installed ${manifest.id} ${manifest.version} from ${release}`);
|
|
39004
39189
|
return (yield* inspect(manifest.id, entry)).plugin;
|
|
39005
39190
|
});
|
|
@@ -39050,27 +39235,33 @@ const make = fn$1("PluginStore.make")(function* (options) {
|
|
|
39050
39235
|
}))), { concurrency: 4 })
|
|
39051
39236
|
};
|
|
39052
39237
|
});
|
|
39053
|
-
const install = fn$1("PluginStore.install")((source, expectedId) => installNow(source, expectedId), withLock);
|
|
39054
|
-
const update = fn$1("PluginStore.update")(function* (id) {
|
|
39238
|
+
const install = fn$1("PluginStore.install")((source, expectedId, approved) => installNow(source, expectedId, approved), withLock);
|
|
39239
|
+
const update = fn$1("PluginStore.update")(function* (id, approved) {
|
|
39055
39240
|
const entry = yield* entryOf(id);
|
|
39056
39241
|
if (entry.source.kind === "local") return yield* new PluginError({ message: `"${id}" is linked from ${entry.source.path}. Rebuild it there instead.` });
|
|
39057
39242
|
if (entry.source.tag !== void 0) return yield* new PluginError({ message: `"${id}" is pinned to ${entry.source.tag}. Install another release to change it.` });
|
|
39058
|
-
return yield* installNow(entry.source, id);
|
|
39243
|
+
return yield* installNow(entry.source, id, approved);
|
|
39059
39244
|
}, withLock);
|
|
39060
39245
|
const remove = fn$1("PluginStore.remove")(function* (id) {
|
|
39061
39246
|
const current = yield* readLock;
|
|
39062
39247
|
const entry = lockEntry(current, id);
|
|
39063
39248
|
if (!entry) return "not-installed";
|
|
39064
39249
|
const plugins = Object.fromEntries(Object.entries(current.plugins).filter(([key]) => key !== id));
|
|
39065
|
-
yield*
|
|
39066
|
-
|
|
39067
|
-
|
|
39068
|
-
|
|
39069
|
-
|
|
39070
|
-
|
|
39071
|
-
|
|
39072
|
-
|
|
39073
|
-
|
|
39250
|
+
yield* acquireUseRelease(stopProcesses(id, entry), () => gen(function* () {
|
|
39251
|
+
if (entry.source.kind === "github") yield* fs.remove(path.join(layout.plugins, id), {
|
|
39252
|
+
recursive: true,
|
|
39253
|
+
force: true
|
|
39254
|
+
}).pipe(mapError$2(fail(`Could not delete ${path.join(layout.plugins, id)}.`)));
|
|
39255
|
+
yield* writeLock({
|
|
39256
|
+
...current,
|
|
39257
|
+
plugins
|
|
39258
|
+
});
|
|
39259
|
+
yield* fs.remove(path.join(layout.pluginData, `${id}.json`), { force: true }).pipe(mapError$2(fail(`Could not delete data for ${id}.`)));
|
|
39260
|
+
yield* fs.remove(path.join(layout.pluginData, id), {
|
|
39261
|
+
recursive: true,
|
|
39262
|
+
force: true
|
|
39263
|
+
}).pipe(mapError$2(fail(`Could not delete the data folder of ${id}.`)));
|
|
39264
|
+
}), (resume) => resume);
|
|
39074
39265
|
yield* logInfo(`Removed ${id}`);
|
|
39075
39266
|
return "removed";
|
|
39076
39267
|
}, withLock);
|
|
@@ -39095,7 +39286,10 @@ const make = fn$1("PluginStore.make")(function* (options) {
|
|
|
39095
39286
|
yield* checkConflict(current, manifest.id, source);
|
|
39096
39287
|
const entry = {
|
|
39097
39288
|
source,
|
|
39098
|
-
version: manifest.version
|
|
39289
|
+
version: manifest.version,
|
|
39290
|
+
...manifest.backend === void 0 ? {} : { backend: manifest.backend },
|
|
39291
|
+
...manifest.mcp === void 0 ? {} : { mcp: manifest.mcp },
|
|
39292
|
+
approved: declaredAccess(manifest)
|
|
39099
39293
|
};
|
|
39100
39294
|
return {
|
|
39101
39295
|
id: manifest.id,
|
|
@@ -39145,11 +39339,12 @@ const make = fn$1("PluginStore.make")(function* (options) {
|
|
|
39145
39339
|
update,
|
|
39146
39340
|
remove,
|
|
39147
39341
|
link,
|
|
39148
|
-
checkUpdates
|
|
39342
|
+
checkUpdates,
|
|
39343
|
+
programs: readLock.pipe(orElseSucceed(() => EMPTY_LOCK), flatMap$1((current) => forEach$1(Object.entries(current.plugins), ([id, entry]) => program(id, entry))), map$3((programs) => programs.flatMap((item) => item ? [item] : [])), withSpan("PluginStore.programs"))
|
|
39149
39344
|
});
|
|
39150
39345
|
});
|
|
39151
39346
|
// ../shared/src/Version.ts
|
|
39152
|
-
const T3MODE_VERSION = "0.
|
|
39347
|
+
const T3MODE_VERSION = "0.2.0";
|
|
39153
39348
|
// src/Errors.ts
|
|
39154
39349
|
/** A failure the user can act on. The message is printed as is. */
|
|
39155
39350
|
var CliFailure = class extends TaggedError()("CliFailure", {
|
|
@@ -39200,6 +39395,11 @@ const HOME_BUNDLES = [
|
|
|
39200
39395
|
pkg: "main",
|
|
39201
39396
|
file: "assets/update-helper.ps1",
|
|
39202
39397
|
name: "update-helper.ps1"
|
|
39398
|
+
},
|
|
39399
|
+
{
|
|
39400
|
+
pkg: "main",
|
|
39401
|
+
file: "assets/backend-host.cjs",
|
|
39402
|
+
name: "backend-host.cjs"
|
|
39203
39403
|
}
|
|
39204
39404
|
];
|
|
39205
39405
|
/** Where a bundle is. The published CLI keeps its own bundles next to it, the rest in bundles/. */
|
|
@@ -46079,7 +46279,7 @@ const decodeMarker = decodeUnknownEffect(fromJsonString(Struct({
|
|
|
46079
46279
|
name: Literal("t3mode"),
|
|
46080
46280
|
shimVersion: Int$4
|
|
46081
46281
|
})));
|
|
46082
|
-
var AsarArchive = class extends Service()("
|
|
46282
|
+
var AsarArchive = class extends Service()("t3mode/Asar/AsarArchive") {};
|
|
46083
46283
|
const readRootFile = (archive, file) => try_({
|
|
46084
46284
|
try: () => {
|
|
46085
46285
|
uncacheFilesystem(archive);
|
|
@@ -46606,6 +46806,344 @@ const move = fn$1("LegacyHome.move")(function* (legacy, root) {
|
|
|
46606
46806
|
message: `Could not move ${legacy} to ${root}. Move the folder by hand, then try again.`,
|
|
46607
46807
|
cause
|
|
46608
46808
|
}))));
|
|
46809
|
+
// ../shared/src/ToolServers.ts
|
|
46810
|
+
/** Registered names are `t3mode-<plugin id>`. */
|
|
46811
|
+
const TOOL_SERVER_PREFIX = "t3mode-";
|
|
46812
|
+
const HOME_MARKER_ENV = "T3MODE_HOME";
|
|
46813
|
+
const refuse = (refused) => ({
|
|
46814
|
+
text: void 0,
|
|
46815
|
+
removed: [],
|
|
46816
|
+
conflicts: [],
|
|
46817
|
+
refused
|
|
46818
|
+
});
|
|
46819
|
+
const toolServerName = (id) => `${TOOL_SERVER_PREFIX}${id}`;
|
|
46820
|
+
const idOf = (name) => name.startsWith("t3mode-") ? name.slice(7) : void 0;
|
|
46821
|
+
/** Windows paths compare without case, and with either slash. */
|
|
46822
|
+
const normalizePath = (value) => value.replaceAll("/", "\\").replace(/\\+$/, "").toLowerCase();
|
|
46823
|
+
const samePath = (a, b) => normalizePath(a) === normalizePath(b);
|
|
46824
|
+
const serverEnv = (target) => ({
|
|
46825
|
+
ELECTRON_RUN_AS_NODE: "1",
|
|
46826
|
+
[HOME_MARKER_ENV]: target.home
|
|
46827
|
+
});
|
|
46828
|
+
const claudeEntry = (target, server) => ({
|
|
46829
|
+
type: "stdio",
|
|
46830
|
+
command: target.exe,
|
|
46831
|
+
args: [server.script],
|
|
46832
|
+
env: serverEnv(target)
|
|
46833
|
+
});
|
|
46834
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46835
|
+
const ownsClaudeEntry = (entry, home) => {
|
|
46836
|
+
if (!isRecord(entry) || !isRecord(entry["env"])) return false;
|
|
46837
|
+
const marker = entry["env"][HOME_MARKER_ENV];
|
|
46838
|
+
return typeof marker === "string" && samePath(marker, home);
|
|
46839
|
+
};
|
|
46840
|
+
/**
|
|
46841
|
+
* Edits the text of `~/.claude.json`. Refuses text that isn't a JSON object: the file is Claude's,
|
|
46842
|
+
* and t3mode never rewrites what it can't read.
|
|
46843
|
+
*/
|
|
46844
|
+
const editClaudeConfig = (text, target, servers) => {
|
|
46845
|
+
const notJson = refuse("it isn't a JSON object with an mcpServers object");
|
|
46846
|
+
let config;
|
|
46847
|
+
try {
|
|
46848
|
+
config = JSON.parse(text);
|
|
46849
|
+
} catch {
|
|
46850
|
+
return notJson;
|
|
46851
|
+
}
|
|
46852
|
+
if (!isRecord(config)) return notJson;
|
|
46853
|
+
const existing = config["mcpServers"];
|
|
46854
|
+
if (existing !== void 0 && !isRecord(existing)) return notJson;
|
|
46855
|
+
const current = existing ?? {};
|
|
46856
|
+
const next = {};
|
|
46857
|
+
const removed = [];
|
|
46858
|
+
const conflicts = [];
|
|
46859
|
+
const wanted = new Map(servers.map((server) => [toolServerName(server.id), server]));
|
|
46860
|
+
for (const [name, entry] of Object.entries(current)) {
|
|
46861
|
+
const id = idOf(name);
|
|
46862
|
+
if (id === void 0 || !ownsClaudeEntry(entry, target.home)) {
|
|
46863
|
+
next[name] = entry;
|
|
46864
|
+
continue;
|
|
46865
|
+
}
|
|
46866
|
+
const server = wanted.get(name);
|
|
46867
|
+
if (server) next[name] = claudeEntry(target, server);
|
|
46868
|
+
else removed.push(id);
|
|
46869
|
+
}
|
|
46870
|
+
for (const [name, server] of wanted) {
|
|
46871
|
+
if (Object.hasOwn(next, name)) {
|
|
46872
|
+
if (!ownsClaudeEntry(next[name], target.home)) conflicts.push(server.id);
|
|
46873
|
+
continue;
|
|
46874
|
+
}
|
|
46875
|
+
next[name] = claudeEntry(target, server);
|
|
46876
|
+
}
|
|
46877
|
+
if (JSON.stringify(next) === JSON.stringify(current) && existing !== void 0) return {
|
|
46878
|
+
text: void 0,
|
|
46879
|
+
removed,
|
|
46880
|
+
conflicts
|
|
46881
|
+
};
|
|
46882
|
+
if (existing === void 0 && Object.keys(next).length === 0) return {
|
|
46883
|
+
text: void 0,
|
|
46884
|
+
removed,
|
|
46885
|
+
conflicts
|
|
46886
|
+
};
|
|
46887
|
+
const indent = /^\{\r?\n(\s+)"/.exec(text)?.[1] ?? " ";
|
|
46888
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
46889
|
+
const body = JSON.stringify({
|
|
46890
|
+
...config,
|
|
46891
|
+
mcpServers: next
|
|
46892
|
+
}, null, indent).replaceAll("\n", eol);
|
|
46893
|
+
return {
|
|
46894
|
+
text: /\r?\n$/.test(text) ? `${body}${eol}` : body,
|
|
46895
|
+
removed,
|
|
46896
|
+
conflicts
|
|
46897
|
+
};
|
|
46898
|
+
};
|
|
46899
|
+
const KEY_PART = String.raw`(?:[A-Za-z0-9_-]+|"(?:[^"\\]|\\.)*"|'[^']*')`;
|
|
46900
|
+
const DOTTED_KEY = new RegExp(String.raw`^\s*(${KEY_PART}(?:\s*\.\s*${KEY_PART})*)\s*`);
|
|
46901
|
+
const HEADER = new RegExp(String.raw`^\s*\[\[?\s*(${KEY_PART}(?:\s*\.\s*${KEY_PART})*)\s*\]\]?\s*(?:#.*)?$`);
|
|
46902
|
+
const ASSIGNMENT = new RegExp(`${DOTTED_KEY.source}=`);
|
|
46903
|
+
const MARKER_VALUE = new RegExp(String.raw`(?:^|[\s{,])${HOME_MARKER_ENV}\s*=\s*("(?:[^"\\\r\n]|\\.)*"|'[^'\r\n]*')`, "m");
|
|
46904
|
+
const keyParts = (dotted) => (dotted.match(new RegExp(KEY_PART, "g")) ?? []).map((part) => {
|
|
46905
|
+
if (part.startsWith("'")) return part.slice(1, -1);
|
|
46906
|
+
if (!part.startsWith("\"")) return part;
|
|
46907
|
+
try {
|
|
46908
|
+
return JSON.parse(part);
|
|
46909
|
+
} catch {
|
|
46910
|
+
return part;
|
|
46911
|
+
}
|
|
46912
|
+
});
|
|
46913
|
+
const tomlString = (value) => {
|
|
46914
|
+
const decoded = value.startsWith("'") ? value.slice(1, -1) : void 0;
|
|
46915
|
+
if (decoded !== void 0) return decoded;
|
|
46916
|
+
try {
|
|
46917
|
+
return JSON.parse(value);
|
|
46918
|
+
} catch {
|
|
46919
|
+
return;
|
|
46920
|
+
}
|
|
46921
|
+
};
|
|
46922
|
+
const basic = (value) => JSON.stringify(value);
|
|
46923
|
+
const codexTable = (target, server) => [
|
|
46924
|
+
`[mcp_servers.${toolServerName(server.id)}]`,
|
|
46925
|
+
`command = ${basic(target.exe)}`,
|
|
46926
|
+
`args = [${basic(server.script)}]`,
|
|
46927
|
+
`env = { ELECTRON_RUN_AS_NODE = "1", ${HOME_MARKER_ENV} = ${basic(target.home)} }`
|
|
46928
|
+
];
|
|
46929
|
+
const isComment = (line) => line.trimStart().startsWith("#");
|
|
46930
|
+
const blocksOf = (lines) => {
|
|
46931
|
+
const blocks = [];
|
|
46932
|
+
let start = 0;
|
|
46933
|
+
let path;
|
|
46934
|
+
const close = (stop) => {
|
|
46935
|
+
let end = stop;
|
|
46936
|
+
while (end > start && (lines[end - 1].trim() === "" || isComment(lines[end - 1]))) end--;
|
|
46937
|
+
blocks.push({
|
|
46938
|
+
start,
|
|
46939
|
+
end,
|
|
46940
|
+
path
|
|
46941
|
+
});
|
|
46942
|
+
};
|
|
46943
|
+
lines.forEach((line, index) => {
|
|
46944
|
+
const header = HEADER.exec(line);
|
|
46945
|
+
if (!header) return;
|
|
46946
|
+
close(index);
|
|
46947
|
+
start = index;
|
|
46948
|
+
path = keyParts(header[1]);
|
|
46949
|
+
});
|
|
46950
|
+
close(lines.length);
|
|
46951
|
+
return blocks;
|
|
46952
|
+
};
|
|
46953
|
+
/** Edits the text of Codex's `config.toml`, keeping its line endings and final newline. */
|
|
46954
|
+
const editCodexConfig = (text, target, servers) => {
|
|
46955
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
46956
|
+
const finalNewline = text === "" || /\r?\n$/.test(text);
|
|
46957
|
+
const lines = text === "" ? [] : text.replace(/\r?\n$/, "").split(/\r?\n/);
|
|
46958
|
+
const blocks = blocksOf(lines);
|
|
46959
|
+
const tables = /* @__PURE__ */ new Map();
|
|
46960
|
+
const taken = /* @__PURE__ */ new Set();
|
|
46961
|
+
let inline = false;
|
|
46962
|
+
for (const block of blocks) {
|
|
46963
|
+
const path = block.path ?? [];
|
|
46964
|
+
if (path[0] === "mcp_servers" && path.length >= 2) {
|
|
46965
|
+
const name = path[1];
|
|
46966
|
+
taken.add(name);
|
|
46967
|
+
tables.set(name, [...tables.get(name) ?? [], block]);
|
|
46968
|
+
continue;
|
|
46969
|
+
}
|
|
46970
|
+
for (let index = block.start; index < block.end; index++) {
|
|
46971
|
+
const key = ASSIGNMENT.exec(lines[index]);
|
|
46972
|
+
if (!key) continue;
|
|
46973
|
+
const parts = [...path, ...keyParts(key[1])];
|
|
46974
|
+
if (parts[0] === "mcp_servers" && parts.length >= 2) taken.add(parts[1]);
|
|
46975
|
+
if (parts.length === 1 && parts[0] === "mcp_servers") inline = true;
|
|
46976
|
+
}
|
|
46977
|
+
}
|
|
46978
|
+
if (inline) return servers.length > 0 ? refuse("it sets mcp_servers as an inline table") : {
|
|
46979
|
+
text: void 0,
|
|
46980
|
+
removed: [],
|
|
46981
|
+
conflicts: []
|
|
46982
|
+
};
|
|
46983
|
+
const wanted = new Map(servers.map((server) => [toolServerName(server.id), server]));
|
|
46984
|
+
const drop = /* @__PURE__ */ new Set();
|
|
46985
|
+
const keep = /* @__PURE__ */ new Set();
|
|
46986
|
+
const removed = [];
|
|
46987
|
+
for (const [name, own] of tables) {
|
|
46988
|
+
const id = idOf(name);
|
|
46989
|
+
if (id === void 0) continue;
|
|
46990
|
+
const body = own.map((block) => lines.slice(block.start, block.end).join("\n")).join("\n");
|
|
46991
|
+
const marker = MARKER_VALUE.exec(body)?.[1];
|
|
46992
|
+
const home = marker === void 0 ? void 0 : tomlString(marker);
|
|
46993
|
+
if (home === void 0 || !samePath(home, target.home)) continue;
|
|
46994
|
+
const server = wanted.get(name);
|
|
46995
|
+
if (server && body === codexTable(target, server).join("\n")) {
|
|
46996
|
+
keep.add(name);
|
|
46997
|
+
continue;
|
|
46998
|
+
}
|
|
46999
|
+
for (const block of own) drop.add(block);
|
|
47000
|
+
if (!server) removed.push(id);
|
|
47001
|
+
}
|
|
47002
|
+
const conflicts = [];
|
|
47003
|
+
const added = [];
|
|
47004
|
+
for (const [name, server] of wanted) {
|
|
47005
|
+
if (keep.has(name)) continue;
|
|
47006
|
+
const owned = (tables.get(name) ?? []).some((block) => drop.has(block));
|
|
47007
|
+
if (taken.has(name) && !owned) {
|
|
47008
|
+
conflicts.push(server.id);
|
|
47009
|
+
continue;
|
|
47010
|
+
}
|
|
47011
|
+
added.push(codexTable(target, server));
|
|
47012
|
+
}
|
|
47013
|
+
if (drop.size === 0 && added.length === 0) return {
|
|
47014
|
+
text: void 0,
|
|
47015
|
+
removed,
|
|
47016
|
+
conflicts
|
|
47017
|
+
};
|
|
47018
|
+
const out = [];
|
|
47019
|
+
blocks.forEach((block, index) => {
|
|
47020
|
+
const next = blocks[index + 1];
|
|
47021
|
+
const stop = next ? next.start : lines.length;
|
|
47022
|
+
if (!drop.has(block)) {
|
|
47023
|
+
out.push(...lines.slice(block.start, stop));
|
|
47024
|
+
return;
|
|
47025
|
+
}
|
|
47026
|
+
const after = lines.slice(block.end, stop);
|
|
47027
|
+
if (after.some(isComment)) out.push(...after);
|
|
47028
|
+
});
|
|
47029
|
+
while (out.length > 0 && out.at(-1).trim() === "" && drop.has(blocks.at(-1))) out.pop();
|
|
47030
|
+
for (const table of added) {
|
|
47031
|
+
while (out.length > 0 && out.at(-1).trim() === "") out.pop();
|
|
47032
|
+
if (out.length > 0) out.push("");
|
|
47033
|
+
out.push(...table);
|
|
47034
|
+
}
|
|
47035
|
+
const body = out.join(eol);
|
|
47036
|
+
return {
|
|
47037
|
+
text: finalNewline && body !== "" ? `${body}${eol}` : body,
|
|
47038
|
+
removed,
|
|
47039
|
+
conflicts
|
|
47040
|
+
};
|
|
47041
|
+
};
|
|
47042
|
+
const quotePowerShell = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
47043
|
+
/**
|
|
47044
|
+
* A Windows PowerShell script that stops every process running `exe` whose command line names a
|
|
47045
|
+
* file under one of `folders`, waits for them to exit, and prints how many it stopped. Windows
|
|
47046
|
+
* keeps a loaded `.node` file locked until its process exits, so files can be replaced after this.
|
|
47047
|
+
* Matching on the exe too spares Explorer or an editor opened on the folder.
|
|
47048
|
+
*/
|
|
47049
|
+
const stopProcessesScript = (exe, folders) => {
|
|
47050
|
+
const prefixes = folders.map((folder) => quotePowerShell(`${folder.replace(/[\\/]+$/, "")}\\`));
|
|
47051
|
+
return [
|
|
47052
|
+
"$ErrorActionPreference = 'Stop'",
|
|
47053
|
+
`$exe = ${quotePowerShell(exe)}`,
|
|
47054
|
+
`$folders = @(${prefixes.join(", ")})`,
|
|
47055
|
+
"$found = @(Get-CimInstance Win32_Process | Where-Object {",
|
|
47056
|
+
" $p = $_",
|
|
47057
|
+
" $p.ProcessId -ne $PID -and $p.ExecutablePath -and $p.CommandLine -and",
|
|
47058
|
+
" [string]::Equals($p.ExecutablePath, $exe, [StringComparison]::OrdinalIgnoreCase) -and",
|
|
47059
|
+
" @($folders | Where-Object { $p.CommandLine.IndexOf($_, [StringComparison]::OrdinalIgnoreCase) -ge 0 }).Count -gt 0",
|
|
47060
|
+
"})",
|
|
47061
|
+
"foreach ($p in $found) { Stop-Process -Id $p.ProcessId -Force -ErrorAction SilentlyContinue }",
|
|
47062
|
+
"foreach ($p in $found) { Wait-Process -Id $p.ProcessId -Timeout 10 -ErrorAction SilentlyContinue }",
|
|
47063
|
+
"$found.Count"
|
|
47064
|
+
].join("\n");
|
|
47065
|
+
};
|
|
47066
|
+
/** Where Claude and Codex read their user config, honoring CLAUDE_CONFIG_DIR and CODEX_HOME. */
|
|
47067
|
+
const configPaths = (env, userHome, join) => ({
|
|
47068
|
+
claude: join(env["CLAUDE_CONFIG_DIR"]?.trim() || userHome, ".claude.json"),
|
|
47069
|
+
codex: join(env["CODEX_HOME"]?.trim() || join(userHome, ".codex"), "config.toml")
|
|
47070
|
+
});
|
|
47071
|
+
/**
|
|
47072
|
+
* `<home>/plugins/package.json`. Node picks a `.js` file's module type from the nearest
|
|
47073
|
+
* package.json above it, and a user's `~/package.json` with `"type": "module"` would make every
|
|
47074
|
+
* plugin script ESM. This file stops that search inside the plugins folder.
|
|
47075
|
+
*/
|
|
47076
|
+
const COMMONJS_MARKER = `{ "type": "commonjs" }\n`;
|
|
47077
|
+
/** How many times a config edit starts over when the file changed under it. */
|
|
47078
|
+
const EDIT_ATTEMPTS = 3;
|
|
47079
|
+
/**
|
|
47080
|
+
* Makes both configs register exactly `servers` for this home. A config is skipped when its
|
|
47081
|
+
* provider isn't set up (no `.claude.json`, no Codex folder) or when it can't be read. Never fails.
|
|
47082
|
+
*/
|
|
47083
|
+
const sync = fn$1("ToolServers.sync")(function* (options) {
|
|
47084
|
+
const fs = yield* FileSystem;
|
|
47085
|
+
const path = yield* Path$2;
|
|
47086
|
+
const removed = /* @__PURE__ */ new Set();
|
|
47087
|
+
const conflicts = [];
|
|
47088
|
+
const failures = [];
|
|
47089
|
+
if (options.servers.length > 0) {
|
|
47090
|
+
const marker = path.join(options.pluginsFolder, "package.json");
|
|
47091
|
+
yield* fs.readFileString(marker).pipe(orElseSucceed(() => ""), flatMap$1((text) => text === "{ \"type\": \"commonjs\" }\n" ? void_ : fs.writeFileString(marker, COMMONJS_MARKER)), catch_((error) => sync$1(() => {
|
|
47092
|
+
failures.push({
|
|
47093
|
+
config: marker,
|
|
47094
|
+
message: `Could not write ${marker}: ${error.message}`
|
|
47095
|
+
});
|
|
47096
|
+
})));
|
|
47097
|
+
}
|
|
47098
|
+
const apply = (config, present, edit) => gen(function* () {
|
|
47099
|
+
if (!(yield* present)) return;
|
|
47100
|
+
const read = fs.exists(config).pipe(flatMap$1((exists) => exists ? fs.readFileString(config) : succeed$2("")));
|
|
47101
|
+
const temp = `${config}.t3mode-${process.pid}.tmp`;
|
|
47102
|
+
for (let attempt = 0; attempt < EDIT_ATTEMPTS; attempt++) {
|
|
47103
|
+
const text = yield* read;
|
|
47104
|
+
const result = edit(text);
|
|
47105
|
+
if (result.refused !== void 0) {
|
|
47106
|
+
failures.push({
|
|
47107
|
+
config,
|
|
47108
|
+
message: `t3mode left ${config} alone: ${result.refused}.`
|
|
47109
|
+
});
|
|
47110
|
+
return;
|
|
47111
|
+
}
|
|
47112
|
+
if (result.text !== void 0) {
|
|
47113
|
+
yield* fs.writeFileString(temp, result.text);
|
|
47114
|
+
if ((yield* read) !== text) {
|
|
47115
|
+
yield* fs.remove(temp, { force: true });
|
|
47116
|
+
continue;
|
|
47117
|
+
}
|
|
47118
|
+
yield* fs.rename(temp, config).pipe(tapError$2(() => fs.remove(temp, { force: true }).pipe(ignore)));
|
|
47119
|
+
}
|
|
47120
|
+
for (const id of result.removed) removed.add(id);
|
|
47121
|
+
for (const id of result.conflicts) conflicts.push({
|
|
47122
|
+
config,
|
|
47123
|
+
id
|
|
47124
|
+
});
|
|
47125
|
+
return;
|
|
47126
|
+
}
|
|
47127
|
+
yield* fs.remove(temp, { force: true }).pipe(ignore);
|
|
47128
|
+
failures.push({
|
|
47129
|
+
config,
|
|
47130
|
+
message: `${config} kept changing while t3mode edited it; it will try again later.`
|
|
47131
|
+
});
|
|
47132
|
+
}).pipe(catch_((error) => sync$1(() => {
|
|
47133
|
+
failures.push({
|
|
47134
|
+
config,
|
|
47135
|
+
message: `Could not update ${config}: ${error.message}`
|
|
47136
|
+
});
|
|
47137
|
+
})));
|
|
47138
|
+
const exists = (file) => fs.exists(file).pipe(orElseSucceed(() => false));
|
|
47139
|
+
yield* apply(options.paths.claude, exists(options.paths.claude), (text) => editClaudeConfig(text, options.target, options.servers));
|
|
47140
|
+
yield* apply(options.paths.codex, exists(path.dirname(options.paths.codex)), (text) => editCodexConfig(text, options.target, options.servers));
|
|
47141
|
+
return {
|
|
47142
|
+
removed: [...removed],
|
|
47143
|
+
conflicts,
|
|
47144
|
+
failures
|
|
47145
|
+
};
|
|
47146
|
+
});
|
|
46609
47147
|
// src/Processes.ts
|
|
46610
47148
|
const quote = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
46611
47149
|
const powershell = (script, env) => make$16("powershell.exe", [
|
|
@@ -46617,26 +47155,49 @@ const powershell = (script, env) => make$16("powershell.exe", [
|
|
|
46617
47155
|
env,
|
|
46618
47156
|
extendEnv: true
|
|
46619
47157
|
} : {});
|
|
46620
|
-
|
|
46621
|
-
|
|
47158
|
+
const withSlash = (dir) => dir.endsWith("\\") ? dir : `${dir}\\`;
|
|
47159
|
+
/**
|
|
47160
|
+
* How many processes run from an executable inside `dir`. With `pluginFolders`, plugin processes
|
|
47161
|
+
* (whose command line names a file in one of those folders) don't count.
|
|
47162
|
+
*/
|
|
47163
|
+
const countRunningIn = fn$1("Processes.countRunningIn")(function* (dir, pluginFolders) {
|
|
46622
47164
|
const spawner = yield* ChildProcessSpawner;
|
|
46623
|
-
const prefix = dir
|
|
46624
|
-
const
|
|
47165
|
+
const prefix = quote(withSlash(dir));
|
|
47166
|
+
const folders = (pluginFolders ?? []).map((folder) => quote(withSlash(folder))).join(",");
|
|
47167
|
+
const script = pluginFolders === void 0 || pluginFolders.length === 0 ? `@(Get-Process -ErrorAction SilentlyContinue | Where-Object { $_.Path -and $_.Path.StartsWith(${prefix}, [StringComparison]::OrdinalIgnoreCase) }).Count` : `$f = @(${folders}); @(Get-CimInstance Win32_Process | Where-Object { $p = $_; $p.ExecutablePath -and $p.ExecutablePath.StartsWith(${prefix}, [StringComparison]::OrdinalIgnoreCase) -and -not ($p.CommandLine -and @($f | Where-Object { $p.CommandLine.IndexOf($_, [StringComparison]::OrdinalIgnoreCase) -ge 0 }).Count -gt 0) }).Count`;
|
|
47168
|
+
const output = yield* spawner.string(powershell(script)).pipe(mapError$2((cause) => new CliFailure({
|
|
46625
47169
|
message: "Could not list running processes.",
|
|
46626
47170
|
cause
|
|
46627
47171
|
})));
|
|
46628
47172
|
const count = Number.parseInt(trim(output), 10);
|
|
46629
47173
|
return Number.isNaN(count) ? 0 : count;
|
|
46630
47174
|
});
|
|
46631
|
-
/**
|
|
46632
|
-
|
|
46633
|
-
|
|
46634
|
-
|
|
46635
|
-
|
|
46636
|
-
|
|
46637
|
-
|
|
46638
|
-
|
|
46639
|
-
}));
|
|
47175
|
+
/**
|
|
47176
|
+
* Stops every process of `exe` whose command line names a file in `folders`: the plugin tool
|
|
47177
|
+
* servers Claude or Codex started. Warns instead of failing.
|
|
47178
|
+
*/
|
|
47179
|
+
const stopPluginProcesses = fn$1("Processes.stopPluginProcesses")(function* (exe, folders) {
|
|
47180
|
+
if (folders.length === 0) return;
|
|
47181
|
+
const output = yield* (yield* ChildProcessSpawner).string(powershell(stopProcessesScript(exe, folders))).pipe(catch_((error$2) => error(`Could not stop plugin processes: ${error$2.message}`).pipe(as$1("0"))));
|
|
47182
|
+
const count = Number.parseInt(trim(output), 10);
|
|
47183
|
+
if (count > 0) yield* log(`Stopped ${count} plugin tool server process(es).`);
|
|
47184
|
+
});
|
|
47185
|
+
/**
|
|
47186
|
+
* Fails while T3 Code runs from `dir`, or waits for it to close when `wait` is set. With
|
|
47187
|
+
* `plugins`, plugin tool servers running T3 Code's exe don't count as T3 Code, and they are
|
|
47188
|
+
* stopped once T3 Code itself is closed, so the command can replace its files.
|
|
47189
|
+
*/
|
|
47190
|
+
const ensureClosed = fn$1("Processes.ensureClosed")(function* (dir, wait, plugins) {
|
|
47191
|
+
const running = yield* countRunningIn(dir, plugins?.folders);
|
|
47192
|
+
if (running > 0 && !wait) return yield* new CliFailure({ message: `T3 Code is running from ${dir}. Close it, or pass --wait to wait until it closes.` });
|
|
47193
|
+
if (running > 0) {
|
|
47194
|
+
yield* log("Waiting for T3 Code to close…");
|
|
47195
|
+
yield* countRunningIn(dir, plugins?.folders).pipe(repeat({
|
|
47196
|
+
schedule: spaced("2 seconds"),
|
|
47197
|
+
until: (count) => count === 0
|
|
47198
|
+
}));
|
|
47199
|
+
}
|
|
47200
|
+
if (plugins) yield* stopPluginProcesses(plugins.exe, plugins.folders);
|
|
46640
47201
|
});
|
|
46641
47202
|
/** Starts `exe` detached from this CLI, so it keeps running after the command exits. */
|
|
46642
47203
|
const launch = fn$1("Processes.launch")(function* (exe, args, env) {
|
|
@@ -46701,6 +47262,44 @@ const resolve = fn$1("Target.resolve")(function* (flags) {
|
|
|
46701
47262
|
message: "Could not resolve the T3 Code install.",
|
|
46702
47263
|
cause: error
|
|
46703
47264
|
})));
|
|
47265
|
+
// src/ToolServers.ts
|
|
47266
|
+
const SettingsJson = fromJsonString(Struct({ plugins: Record(String$6, Struct({ enabled: optionalKey(Boolean$4) })) }));
|
|
47267
|
+
/** Plugins turned off on the Plugins page. settings.json is main's; a bad file means none. */
|
|
47268
|
+
const disabledIds = fn$1("ToolServers.disabledIds")(function* (layout) {
|
|
47269
|
+
const settings = yield* (yield* FileSystem).readFileString(layout.settings).pipe(flatMap$1(decodeEffect(SettingsJson)), orElseSucceed(() => ({ plugins: {} })));
|
|
47270
|
+
return new Set(Object.entries(settings.plugins).filter(([, plugin]) => plugin.enabled === false).map(([id]) => id));
|
|
47271
|
+
});
|
|
47272
|
+
/**
|
|
47273
|
+
* Registers the tool servers of `programs` minus the disabled ones, and stops the processes of
|
|
47274
|
+
* disabled plugins. Backends are main's: T3 Code picks the change up at its next reload.
|
|
47275
|
+
*/
|
|
47276
|
+
const reconcile = fn$1("ToolServers.reconcile")(function* (target, programs) {
|
|
47277
|
+
const fs = yield* FileSystem;
|
|
47278
|
+
const path = yield* Path$2;
|
|
47279
|
+
const userHome = yield* String$5("USERPROFILE").pipe(withDefault$2(""));
|
|
47280
|
+
const disabled = yield* disabledIds(target.home);
|
|
47281
|
+
const result = yield* sync({
|
|
47282
|
+
target: {
|
|
47283
|
+
exe: target.exe,
|
|
47284
|
+
home: target.home.root
|
|
47285
|
+
},
|
|
47286
|
+
paths: configPaths(process.env, userHome, path.join),
|
|
47287
|
+
pluginsFolder: target.home.plugins,
|
|
47288
|
+
servers: programs.flatMap((program) => program.mcp === void 0 || disabled.has(program.id) ? [] : [{
|
|
47289
|
+
id: program.id,
|
|
47290
|
+
script: program.mcp
|
|
47291
|
+
}])
|
|
47292
|
+
});
|
|
47293
|
+
for (const { config, id } of result.conflicts) yield* error(`${config} already has a ${toolServerName(id)} that t3mode didn't write; ${id}'s tools aren't added there.`);
|
|
47294
|
+
for (const { message } of result.failures) yield* error(message);
|
|
47295
|
+
const folders = [];
|
|
47296
|
+
const folderOf = new Map(programs.map((program) => [program.id, program.folder]));
|
|
47297
|
+
for (const id of result.removed) {
|
|
47298
|
+
const folder = folderOf.get(id) ?? path.join(target.home.plugins, id);
|
|
47299
|
+
if (yield* fs.exists(folder).pipe(orElseSucceed(() => false))) folders.push(folder);
|
|
47300
|
+
}
|
|
47301
|
+
yield* stopPluginProcesses(target.exe, folders);
|
|
47302
|
+
});
|
|
46704
47303
|
// src/bin.ts
|
|
46705
47304
|
const root = make$4("t3mode").pipe(withSharedFlags({
|
|
46706
47305
|
installDir: Directory("install-dir").pipe(withDescription$1("T3 Code install folder (default: %LOCALAPPDATA%\\Programs\\t3code)"), optional),
|
|
@@ -46709,6 +47308,14 @@ const root = make$4("t3mode").pipe(withSharedFlags({
|
|
|
46709
47308
|
const target = gen(function* () {
|
|
46710
47309
|
return yield* resolve(yield* root);
|
|
46711
47310
|
});
|
|
47311
|
+
/** T3 Code's exe and the folders plugin processes run from: `<home>/plugins` and linked folders. */
|
|
47312
|
+
const pluginsOf = fn$1("pluginsOf")(function* (t) {
|
|
47313
|
+
const programs = yield* (yield* pluginStore).programs;
|
|
47314
|
+
return {
|
|
47315
|
+
exe: t.exe,
|
|
47316
|
+
folders: [t.home.plugins, ...programs.filter((program) => program.linked).map((program) => program.folder)]
|
|
47317
|
+
};
|
|
47318
|
+
});
|
|
46712
47319
|
const wait = Boolean$1("wait").pipe(withDescription$1("Wait for T3 Code to close instead of failing"), withDefault(false));
|
|
46713
47320
|
const launchAfter = Boolean$1("launch").pipe(withDescription$1("Start T3 Code when done"), withDefault(false));
|
|
46714
47321
|
const describeApply = {
|
|
@@ -46718,7 +47325,7 @@ const describeApply = {
|
|
|
46718
47325
|
};
|
|
46719
47326
|
const installOrRepair = (withDeploy) => fn$1(function* (options) {
|
|
46720
47327
|
const t = yield* target;
|
|
46721
|
-
yield* ensureClosed(t.installDir, options.wait);
|
|
47328
|
+
yield* ensureClosed(t.installDir, options.wait, yield* pluginsOf(t));
|
|
46722
47329
|
const flags = yield* root;
|
|
46723
47330
|
if (isNone(flags.home) && !(yield* String$5("T3MODE_HOME").pipe(withDefault$2(""))).trim()) {
|
|
46724
47331
|
const appData = (yield* String$5("APPDATA").pipe(withDefault$2(""))).trim();
|
|
@@ -46749,9 +47356,10 @@ const uninstall = make$4("uninstall", {
|
|
|
46749
47356
|
}, fn$1(function* (options) {
|
|
46750
47357
|
const t = yield* target;
|
|
46751
47358
|
const fs = yield* FileSystem;
|
|
46752
|
-
yield* ensureClosed(t.installDir, options.wait);
|
|
47359
|
+
yield* ensureClosed(t.installDir, options.wait, yield* pluginsOf(t));
|
|
46753
47360
|
const result = yield* removeShim(t);
|
|
46754
47361
|
yield* log(result === "removed" ? "Original T3 Code restored." : "t3mode was not installed.");
|
|
47362
|
+
yield* reconcile(t, []);
|
|
46755
47363
|
if (options.purge) {
|
|
46756
47364
|
yield* fs.remove(t.home.root, {
|
|
46757
47365
|
recursive: true,
|
|
@@ -46769,7 +47377,7 @@ const status = make$4("status", {}, fn$1(function* () {
|
|
|
46769
47377
|
const t = yield* target;
|
|
46770
47378
|
const fs = yield* FileSystem;
|
|
46771
47379
|
const s = yield* readStatus(t);
|
|
46772
|
-
const running = yield* countRunningIn(t.installDir);
|
|
47380
|
+
const running = yield* countRunningIn(t.installDir, (yield* pluginsOf(t)).folders);
|
|
46773
47381
|
const deployed = yield* fs.exists(t.home.mainJs);
|
|
46774
47382
|
const safeMode = yield* fs.exists(t.home.safeMode);
|
|
46775
47383
|
const state = yield* fs.readFileString(t.home.state).pipe(option);
|
|
@@ -46861,13 +47469,33 @@ const sandbox = make$4("sandbox", {
|
|
|
46861
47469
|
});
|
|
46862
47470
|
yield* log(`Sandbox started. DevTools: http://127.0.0.1:${options.port}/json`);
|
|
46863
47471
|
})).pipe(withDescription("Run t3mode on a private copy of T3 Code, for development"));
|
|
47472
|
+
/**
|
|
47473
|
+
* The plugin store, and `refresh`, which brings Claude's and Codex's config in step with it. Both
|
|
47474
|
+
* need T3 Code's exe; without an install there is no tool server to stop or register.
|
|
47475
|
+
*/
|
|
46864
47476
|
const pluginStore = gen(function* () {
|
|
46865
47477
|
const flags = yield* root;
|
|
46866
47478
|
const layout = yield* resolveHome(flags.home);
|
|
46867
|
-
|
|
47479
|
+
const t3 = yield* resolve(flags).pipe(option);
|
|
47480
|
+
const exe = map$9(t3, (t) => t.exe);
|
|
47481
|
+
const spawner = yield* ChildProcessSpawner;
|
|
47482
|
+
let installedPrograms = succeed$2([]);
|
|
47483
|
+
const store = yield* make({
|
|
46868
47484
|
layout,
|
|
46869
|
-
githubBase: githubUrl(process.env)
|
|
47485
|
+
githubBase: githubUrl(process.env),
|
|
47486
|
+
...isSome(t3) ? { stopProcesses: fn$1("stopProcesses")(function* (id, folder, backend) {
|
|
47487
|
+
const folders = [layout.plugins, ...(yield* installedPrograms).filter((program) => program.linked).map((program) => program.folder)];
|
|
47488
|
+
if (backend && (yield* countRunningIn(t3.value.installDir, folders)) > 0) return yield* new PluginError({ message: `${id} runs a backend inside T3 Code. Update or remove it from T3 Code's Plugins page, or close T3 Code first.` });
|
|
47489
|
+
yield* stopPluginProcesses(t3.value.exe, [folder]);
|
|
47490
|
+
return void_;
|
|
47491
|
+
}, catchTag("CliFailure", (error) => fail$4(new PluginError({ message: error.message }))), provideService(ChildProcessSpawner, spawner)) } : {}
|
|
46870
47492
|
});
|
|
47493
|
+
installedPrograms = store.programs;
|
|
47494
|
+
const refresh = isSome(exe) ? store.programs.pipe(flatMap$1((programs) => reconcile({
|
|
47495
|
+
exe: exe.value,
|
|
47496
|
+
home: layout
|
|
47497
|
+
}, programs))) : void_;
|
|
47498
|
+
return Object.assign(store, { refresh });
|
|
46871
47499
|
});
|
|
46872
47500
|
const RELOAD = "Reload T3 Code (Ctrl+R) to apply it.";
|
|
46873
47501
|
const describePlugin = (plugin) => [`${plugin.id.padEnd(24)} ${plugin.version.padEnd(12)} ${sourceLabel(plugin.source)}`, plugin.error === void 0 ? null : ` can't load: ${plugin.error}`].filter((line) => line !== null).join("\n");
|
|
@@ -46885,7 +47513,8 @@ const pluginAdd = make$4("add", {
|
|
|
46885
47513
|
for (const offer of preview.offers) yield* log(offer.kind === "unavailable" ? `${offer.id}: unavailable. ${offer.reason}` : [
|
|
46886
47514
|
`${offer.manifest.name} ${offer.manifest.version}${offer.manifest.author ? ` by ${offer.manifest.author}` : ""}`,
|
|
46887
47515
|
`from github.com/${sourceLabel(offer.source)}`,
|
|
46888
|
-
offer.manifest.description
|
|
47516
|
+
offer.manifest.description,
|
|
47517
|
+
...accessLines(declaredAccess(offer.manifest))
|
|
46889
47518
|
].join("\n"));
|
|
46890
47519
|
const requested = getOrUndefined$1(options.id);
|
|
46891
47520
|
if (requested !== void 0 && !preview.offers.some((offer) => (offer.kind === "ready" ? offer.manifest.id : offer.id) === requested)) return yield* new PluginError({ message: `No plugin "${requested}" in this release.` });
|
|
@@ -46904,11 +47533,15 @@ const pluginAdd = make$4("add", {
|
|
|
46904
47533
|
});
|
|
46905
47534
|
if (selected.length === 0) yield* log("Nothing was installed.");
|
|
46906
47535
|
for (const offer of selected) {
|
|
46907
|
-
const installed = yield* store.install(offer.source, offer.manifest.id);
|
|
47536
|
+
const installed = yield* store.install(offer.source, offer.manifest.id, declaredAccess(offer.manifest));
|
|
46908
47537
|
yield* log(`Installed ${installed.name} ${installed.version}. ${RELOAD}`);
|
|
46909
47538
|
}
|
|
47539
|
+
yield* store.refresh;
|
|
46910
47540
|
})).pipe(withDescription("Install a plugin from a GitHub release"));
|
|
46911
|
-
const pluginUpdate = make$4("update", {
|
|
47541
|
+
const pluginUpdate = make$4("update", {
|
|
47542
|
+
yes: Boolean$1("yes").pipe(withDescription$1("Approve new access without asking"), withDefault(false)),
|
|
47543
|
+
id: String$1("id").pipe(withDescription$2("The plugin to update (default: every plugin with an update)"), optional$1)
|
|
47544
|
+
}, fn$1(function* (options) {
|
|
46912
47545
|
const store = yield* pluginStore;
|
|
46913
47546
|
const ids = isSome(options.id) ? [options.id.value] : yield* gen(function* () {
|
|
46914
47547
|
const { updates, failures } = yield* store.checkUpdates;
|
|
@@ -46920,17 +47553,28 @@ const pluginUpdate = make$4("update", { id: String$1("id").pipe(withDescription$
|
|
|
46920
47553
|
return;
|
|
46921
47554
|
}
|
|
46922
47555
|
for (const id of ids) {
|
|
46923
|
-
const updated = yield* store.update(id)
|
|
47556
|
+
const updated = yield* store.update(id, options.yes ? "any" : void 0).pipe(catch_((error) => gen(function* () {
|
|
47557
|
+
if (!error.approval) return yield* error;
|
|
47558
|
+
yield* log(accessLines(error.approval).join("\n"));
|
|
47559
|
+
if (!(yield* Confirm({ message: `Approve new access for ${id}?` }))) return void 0;
|
|
47560
|
+
return yield* store.update(id, error.approval);
|
|
47561
|
+
})));
|
|
47562
|
+
if (!updated) continue;
|
|
46924
47563
|
yield* log(`Installed the latest release of ${updated.name}: ${updated.version}.`);
|
|
46925
47564
|
}
|
|
47565
|
+
yield* store.refresh;
|
|
46926
47566
|
yield* log(RELOAD);
|
|
46927
47567
|
})).pipe(withDescription("Install the latest release of unpinned GitHub plugins"));
|
|
46928
47568
|
const pluginRemove = make$4("remove", { id: String$1("id").pipe(withDescription$2("The plugin's id")) }, fn$1(function* (options) {
|
|
46929
|
-
const
|
|
47569
|
+
const store = yield* pluginStore;
|
|
47570
|
+
const removed = yield* store.remove(options.id);
|
|
47571
|
+
yield* store.refresh;
|
|
46930
47572
|
yield* log(removed === "removed" ? `Removed ${options.id}. ${RELOAD}` : `${options.id} is not installed.`);
|
|
46931
47573
|
})).pipe(withDescription("Remove a plugin"));
|
|
46932
47574
|
const pluginLink = make$4("link", { folder: Directory$1("folder", { mustExist: true }).pipe(withDescription$2("A built plugin: the folder holding manifest.json and plugin.js")) }, fn$1(function* (options) {
|
|
46933
|
-
const
|
|
47575
|
+
const store = yield* pluginStore;
|
|
47576
|
+
const linked = yield* store.link(options.folder);
|
|
47577
|
+
yield* store.refresh;
|
|
46934
47578
|
yield* log(linked.map((plugin) => `Linked ${plugin.name} ${plugin.version}. After each rebuild, reload T3 Code (Ctrl+R) to pick it up.`).join("\n"));
|
|
46935
47579
|
})).pipe(withDescription("Use a plugin you are developing, read from its folder"));
|
|
46936
47580
|
const plugin = make$4("plugin").pipe(withDescription(`Install and manage plugins (GitHub downloads go to $${GITHUB_URL_ENV} when it is set)`), withSubcommands([
|
|
@@ -46951,6 +47595,6 @@ root.pipe(withSubcommands([
|
|
|
46951
47595
|
safe,
|
|
46952
47596
|
sandbox,
|
|
46953
47597
|
plugin
|
|
46954
|
-
]), run$1({ version: T3MODE_VERSION }), catchTag("PluginError", (error$1) => error(error$1.message).pipe(andThen(sync(() => {
|
|
47598
|
+
]), run$1({ version: T3MODE_VERSION }), catchTag("PluginError", (error$1) => error(error$1.message).pipe(andThen(sync$1(() => {
|
|
46955
47599
|
process.exitCode = 1;
|
|
46956
47600
|
})))), provide(MainLayer), runMain);
|