t3code-cli 0.5.0 → 0.5.1

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/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as is, $n as sync$1, $t as catchFilter, An as timeoutOrElse, Ar as dual, At as tap, B as Boolean$2, Bn as mergeAll, Bt as offer, Cn as scoped, Cr as format, Ct as run$1, Dn as sync, Dr as isNullish, Dt as runLast, En as suspend, Er as isNotUndefined, Et as runFold, F as T3Application, Fn as TaggedError, Fr as __require, Ft as drain, G as Literals, Gn as MinimumLogLevel, Gt as nominal, H as ErrorClass, Hn as provideMerge, Ht as BadArgument, I as Environment, In as fail$1, It as isSink, J as TaggedErrorClass, Jn as isDone, Jt as addFinalizer, K as String$1, Kn as _await, Kt as transform$1, L as T3Config, Ln as hasInterruptsOnly, Lt as endUnsafe, M as ThreadSessionError, Mn as try_, Mr as pipe, Mt as unwrap, N as latestAssistantMessage, Nn as uninterruptible, Nr as pipeArguments, Nt as get, On as tapCause, Or as isUndefined, Ot as splitLines, P as threadStatus, Pn as void_, Pr as __commonJSMin, Pt as make$11, Q as fromJsonString, Qn as ConsoleRef, Qt as callback, R as T3Auth, Rn as squash, Rt as failCauseUnsafe, Sn as runFork, Sr as BaseProto, St as mkString, Tn as succeed, Tr as isNotNull, Tt as runDrain, U as Int, Un as succeed$2, Ut as badArgument, V as Defect, Vn as provide, Vt as offerUnsafe, W as Literal, Wn as sync$2, Wt as systemError, X as decodeTo, Xn as isSuccess, Xt as as, Y as Union, Yn as makeUnsafe, Yt as andThen, Z as decodeUnknownEffect, Zn as succeed$1, Zt as asVoid, _n as orDie, _r as none, _t as decodeText, an as fn, ar as empty$1, at as make$9, bn as provideService, br as PipeInspectableProto, bt as isStream, cn as forkScoped, cr as flatMap$1, ct as Path$1, dn as interrupt, dr as getOrElse, dt as FileSystem, en as catchTags, er as map$3, et as optional$3, fn as isEffect, fr as getOrUndefined, ft as FileTypeId, gn as matchEffect, gr as match, gt as callback$1, hn as mapError, hr as map$4, ht as make$10, in as flatMap, ir as Service, it as Crypto, j as NodeEnvironmentLive, jn as tryPromise, jr as identity, jt as transduce, kn as tapError, kr as constVoid, kt as succeed$4, ln as gen, lr as fromNullishOr, lt as TypeId$7, mn as map$2, mr as isSome, mt as WatchBackend, nn as effectify, nr as succeed$3, nt as tag, on as fnUntraced, or as getUnsafe, ot as fromReadable, pn as logError, pr as isNone, pt as Size, q as Struct, qn as doneUnsafe, qt as acquireRelease, rn as fail, rr as Reference, rt as toCodecStringTree, sn as forEach, sr as make$13, st as fromWritable, t as AppLayer, tn as catch_, tr as fail$2, tt as optionalKey, un as ignore, ur as fromUndefinedOr, ut as FileDescriptor, vn as provide$1, vr as some, vt as empty, wn as serviceOption, wr as hasProperty, wt as runCollect, xn as result, xr as withFiber, xt as merge, yn as provideContext, yr as Prototype, yt as fromIterable, z as ArraySchema, zn as effect, zt as make$12 } from "./runtime-15tR27tv.js";
2
+ import { $ as T3Config, $n as hasInterruptsOnly, $t as endUnsafe, An as map$2, Ar as isSome, At as WatchBackend, Bn as serviceOption, Br as hasProperty, Bt as runCollect, Cn as forEach, Cr as make$13, Ct as fromWritable, Dn as interrupt, Dr as getOrElse, Dt as FileSystem, En as ignore, Er as fromUndefinedOr, Et as FileDescriptor, Fn as provideContext, Fr as Prototype, Ft as fromIterable, Gn as tapError, Gr as constVoid, Gt as succeed$4, Hn as suspend, Hr as isNotUndefined, Ht as runFold, In as provideService, Ir as PipeInspectableProto, It as isStream, J as ThreadSessionError, Jn as try_, Jr as pipe, Jt as unwrap, Kn as timeoutOrElse, Kr as dual, Kt as tap, Ln as result, Lr as withFiber, Lt as merge, Mn as matchEffect, Mr as match, Mt as callback$1, Nn as orDie, Nr as none, Nt as decodeText, On as isEffect, Or as getOrUndefined, Ot as FileTypeId, Pn as provide$1, Pr as some, Pt as empty, Q as Environment, Qn as fail$1, Qt as isSink, Rn as runFork, Rr as BaseProto, Rt as mkString, Sn as fnUntraced, Sr as getUnsafe, St as fromReadable, Tn as gen, Tr as fromNullishOr, Tt as TypeId$7, Un as sync, Ur as isNullish, Ut as runLast, Vn as succeed, Vr as isNotNull, Vt as runDrain, Wn as tapCause, Wr as isUndefined, Wt as splitLines, X as threadStatus, Xn as void_, Xr as __commonJSMin, Xt as make$11, Y as latestAssistantMessage, Yn as uninterruptible, Yr as pipeArguments, Yt as get, Z as T3Application, Zn as TaggedError, Zr as __require, Zt as drain, _n as catch_, _r as fail$2, _t as optionalKey, an as badArgument, ar as succeed$2, at as Int, bn as flatMap, br as Service, bt as Crypto, cn as transform$1, cr as _await, ct as String$1, dn as andThen, dr as makeUnsafe, dt as Union, en as failCauseUnsafe, er as squash, et as T3Auth, fn as as, fr as isSuccess, ft as decodeTo, gn as catchTags, gr as map$3, gt as optional$3, hn as catchFilter, hr as sync$1, ht as is, in as BadArgument, ir as provideMerge, it as ErrorClass, jn as mapError, jr as map$4, jt as make$10, kn as logError, kr as isNone, kt as Size, ln as acquireRelease, lr as doneUnsafe, lt as Struct, mn as callback, mr as ConsoleRef, mt as fromJsonString, nn as offer, nr as mergeAll, nt as Boolean$2, on as systemError, or as sync$2, ot as Literal, pn as asVoid, pr as succeed$1, pt as decodeUnknownEffect, q as NodeEnvironmentLive, qn as tryPromise, qr as identity, qt as transduce, rn as offerUnsafe, rr as provide, rt as Defect, sn as nominal, sr as MinimumLogLevel, st as Literals, t as AppLayer, tn as make$12, tr as effect, tt as ArraySchema, un as addFinalizer, ur as isDone, ut as TaggedErrorClass, vn as effectify, vr as succeed$3, vt as tag, wn as forkScoped, wr as flatMap$1, wt as Path$1, xn as fn, xr as empty$1, xt as make$9, yn as fail, yr as Reference, yt as toCodecStringTree, zn as scoped, zr as format, zt as run$1 } from "./runtime-KQVRmRk-.js";
3
3
  import * as NodeChildProcess from "node:child_process";
4
4
  import * as NodeCrypto from "node:crypto";
5
5
  import * as NFS from "node:fs";
@@ -18149,7 +18149,7 @@ var T3Version = class extends Service()("t3cli/T3Version") {};
18149
18149
  //#endregion
18150
18150
  //#region src/version/layer.ts
18151
18151
  const PackageJsonSchema = fromJsonString(Struct({ version: String$1 }));
18152
- const T3VersionBundledLive = sync$2(T3Version, () => ({ version: "0.5.0" }));
18152
+ const T3VersionBundledLive = sync$2(T3Version, () => ({ version: "0.5.1" }));
18153
18153
  effect(T3Version, gen(function* () {
18154
18154
  const packageJson = yield* (yield* FileSystem).readFileString(fileURLToPath(new URL("../../package.json", import.meta.url)));
18155
18155
  return { version: (yield* decodeUnknownEffect(PackageJsonSchema)(packageJson)).version };
package/dist/index.js CHANGED
@@ -1,2 +1,12 @@
1
- import { A as UrlError, C as AuthLocalDatabaseError, D as AuthPairingUrlError, E as AuthLocalSigningError, F as T3Application, I as Environment, L as T3Config, O as AuthTransportError, R as T3Auth, S as AuthConfigError, T as AuthLocalSecretError, _ as parsePairingUrl, a as T3AuthTransportLayer, b as makeT3LocalAuth, c as NodeSqliteClientLive, d as makeT3Config, f as T3AuthLive, g as makeT3AuthPairing, h as T3AuthPairingLive, i as T3AuthPairingLayer, j as NodeEnvironmentLive, k as ConfigError, l as makeNodeSqliteClient, m as T3AuthPairing, n as AuthAppLayer, o as T3LocalAuthLayer, p as makeT3Auth, r as T3AuthLayer, s as NodeSqlClientFactoryLive, t as AppLayer, u as T3ConfigLive, v as T3LocalAuth, w as AuthLocalError, x as SqlClientFactory, y as T3LocalAuthLive } from "./runtime-15tR27tv.js";
2
- export { AppLayer, AuthAppLayer, AuthConfigError, AuthLocalDatabaseError, AuthLocalError, AuthLocalSecretError, AuthLocalSigningError, AuthPairingUrlError, AuthTransportError, ConfigError, Environment, NodeEnvironmentLive, NodeSqlClientFactoryLive, NodeSqliteClientLive, SqlClientFactory, T3Application, T3Auth, T3AuthLayer, T3AuthLive, T3AuthPairing, T3AuthPairingLayer, T3AuthPairingLive, T3AuthTransportLayer, T3Config, T3ConfigLive, T3LocalAuth, T3LocalAuthLayer, T3LocalAuthLive, UrlError, makeNodeSqliteClient, makeT3Auth, makeT3AuthPairing, makeT3Config, makeT3LocalAuth, parsePairingUrl };
1
+ import { $ as T3Config, A as T3LocalAuthTokenLive, B as AuthLocalSigningError, C as makeT3AuthPairing, D as T3LocalAuthLive, E as T3LocalAuth, F as makeT3LocalAuthOrigin, G as layerWebSocketConstructor, H as AuthTransportError, I as AuthConfigError, K as layerUndici, L as AuthLocalDatabaseError, M as SqlClientFactory, N as T3LocalAuthOrigin, O as makeT3LocalAuth, P as T3LocalAuthOriginLive, Q as Environment, R as AuthLocalError, S as T3AuthPairingLive, T as T3AuthTransportLive, U as ConfigError, V as AuthPairingUrlError, W as UrlError, Z as T3Application, _ as makeT3CodeConnectionProvider, a as T3AuthTransportLayer, b as makeT3Auth, c as T3LocalAuthTokenLayer, d as makeNodeSqliteClient, et as T3Auth, f as T3RpcLive, g as T3CodeConnectionProviderLive, h as T3CodeConnectionProvider, i as T3AuthPairingLayer, j as makeT3LocalAuthToken, k as T3LocalAuthToken, l as NodeSqlClientFactoryLive, m as makeT3Config, n as AuthAppLayer, nr as mergeAll, o as T3LocalAuthLayer, p as T3ConfigLive, q as NodeEnvironmentLive, r as T3AuthLayer, rr as provide, s as T3LocalAuthOriginLayer, t as AppLayer, u as NodeSqliteClientLive, v as T3CodeConnectionError, w as parsePairingUrl, x as T3AuthPairing, y as T3AuthLive, z as AuthLocalSecretError } from "./runtime-KQVRmRk-.js";
2
+ //#region src/connection/layer.ts
3
+ function makeT3CodeRpcLayer() {
4
+ return T3RpcLive.pipe(provide(T3AuthTransportLive));
5
+ }
6
+ const T3CodeRpcLayer = makeT3CodeRpcLayer();
7
+ //#endregion
8
+ //#region src/connection/node.ts
9
+ const NodeConnectionPlatformLayer = mergeAll(layerUndici, layerWebSocketConstructor);
10
+ const T3CodeNodeRpcLayer = T3CodeRpcLayer.pipe(provide(NodeConnectionPlatformLayer));
11
+ //#endregion
12
+ export { AppLayer, AuthAppLayer, AuthConfigError, AuthLocalDatabaseError, AuthLocalError, AuthLocalSecretError, AuthLocalSigningError, AuthPairingUrlError, AuthTransportError, ConfigError, Environment, NodeEnvironmentLive, NodeSqlClientFactoryLive, NodeSqliteClientLive, SqlClientFactory, T3Application, T3Auth, T3AuthLayer, T3AuthLive, T3AuthPairing, T3AuthPairingLayer, T3AuthPairingLive, T3AuthTransportLayer, T3CodeConnectionError, T3CodeConnectionProvider, T3CodeConnectionProviderLive, T3CodeNodeRpcLayer, T3CodeRpcLayer, T3Config, T3ConfigLive, T3LocalAuth, T3LocalAuthLayer, T3LocalAuthLive, T3LocalAuthOrigin, T3LocalAuthOriginLayer, T3LocalAuthOriginLive, T3LocalAuthToken, T3LocalAuthTokenLayer, T3LocalAuthTokenLive, UrlError, makeNodeSqliteClient, makeT3Auth, makeT3AuthPairing, makeT3CodeConnectionProvider, makeT3CodeRpcLayer, makeT3Config, makeT3LocalAuth, makeT3LocalAuthOrigin, makeT3LocalAuthToken, parsePairingUrl };
@@ -65511,6 +65511,120 @@ var AuthLocalError = class extends TaggedErrorClass()("AuthLocalError", {
65511
65511
  ]))
65512
65512
  }) {};
65513
65513
  //#endregion
65514
+ //#region src/config/url.ts
65515
+ function normalizeHttpBaseUrl(value) {
65516
+ return parseUrl$1(value).pipe(flatMap$2((url) => succeed$2(normalizeBaseUrl$1(url))));
65517
+ }
65518
+ function toHttpEndpointUrl(httpBaseUrl, pathname) {
65519
+ return parseUrl$1(httpBaseUrl).pipe(flatMap$2((url) => succeed$2(withPathname(url, pathname).toString())));
65520
+ }
65521
+ function toWebSocketEndpointUrl(httpBaseUrl, pathname) {
65522
+ return parseUrl$1(httpBaseUrl).pipe(flatMap$2((url) => {
65523
+ if (url.protocol === "http:") return succeed$2(withPathname(url, pathname, "ws:").toString());
65524
+ if (url.protocol === "https:") return succeed$2(withPathname(url, pathname, "wss:").toString());
65525
+ return fail$2(new UrlError({
65526
+ message: `unsupported server url protocol: ${url.protocol}`,
65527
+ protocol: url.protocol
65528
+ }));
65529
+ }));
65530
+ }
65531
+ function parseUrl$1(value) {
65532
+ return fromResult(fromString(value)).pipe(catchTags$1({ IllegalArgumentError: (error) => fail$2(new UrlError({
65533
+ message: "invalid url",
65534
+ cause: error
65535
+ })) }));
65536
+ }
65537
+ function normalizeBaseUrl$1(url) {
65538
+ return mutate(url, (current) => {
65539
+ current.hash = "";
65540
+ current.search = "";
65541
+ current.pathname = normalizePathname(current.pathname);
65542
+ }).toString().replace(/\/$/, "");
65543
+ }
65544
+ function withPathname(url, pathname, protocol) {
65545
+ return mutate(url, (current) => {
65546
+ if (protocol !== void 0) current.protocol = protocol;
65547
+ current.pathname = appendPathname(current.pathname, pathname);
65548
+ current.search = "";
65549
+ current.hash = "";
65550
+ });
65551
+ }
65552
+ function normalizePathname(pathname) {
65553
+ return pathname === "/" ? "" : pathname.replace(/\/+$/u, "");
65554
+ }
65555
+ function appendPathname(basePathname, pathname) {
65556
+ return `${normalizePathname(basePathname)}${pathname.startsWith("/") ? pathname : `/${pathname}`}`;
65557
+ }
65558
+ //#endregion
65559
+ //#region src/auth/local-base-dir.ts
65560
+ function resolveLocalBaseDir(input) {
65561
+ const envBaseDir = input.environment.env["T3CODE_HOME"];
65562
+ const raw = input.baseDir ?? envBaseDir;
65563
+ if (raw === void 0 || raw.length === 0) return input.path.join(input.environment.homeDir, ".t3");
65564
+ if (raw === "~") return input.environment.homeDir;
65565
+ if (raw.startsWith("~/") || raw.startsWith("~\\")) return input.path.join(input.environment.homeDir, raw.slice(2));
65566
+ return input.path.resolve(input.environment.cwd, raw);
65567
+ }
65568
+ //#endregion
65569
+ //#region src/auth/schema.ts
65570
+ const AuthAccessTokenResultSchema = Struct({
65571
+ access_token: String$1,
65572
+ issued_token_type: String$1,
65573
+ token_type: Literal("Bearer"),
65574
+ expires_in: Number$1,
65575
+ scope: String$1
65576
+ });
65577
+ const AuthSessionStateSchema = Struct({
65578
+ authenticated: Boolean$1,
65579
+ role: optionalKey(Literals(["owner", "client"])),
65580
+ sessionMethod: optionalKey(String$1),
65581
+ expiresAt: optionalKey(String$1)
65582
+ });
65583
+ const AuthWebSocketTicketResultSchema = Struct({
65584
+ ticket: String$1,
65585
+ expiresAt: String$1
65586
+ });
65587
+ const AuthLocalRuntimeStateSchema = Struct({
65588
+ version: Literal(1),
65589
+ origin: String$1
65590
+ });
65591
+ const decodeAuthAccessTokenResult = decodeUnknownEffect(AuthAccessTokenResultSchema);
65592
+ const decodeAuthSessionState = decodeUnknownEffect(AuthSessionStateSchema);
65593
+ const decodeAuthWebSocketTicketResult = decodeUnknownEffect(AuthWebSocketTicketResultSchema);
65594
+ decodeUnknownEffect(AuthLocalRuntimeStateSchema);
65595
+ const decodeAuthLocalRuntimeStateFromJson = decodeUnknownEffect(fromJsonString(AuthLocalRuntimeStateSchema));
65596
+ //#endregion
65597
+ //#region src/auth/local-origin.ts
65598
+ var T3LocalAuthOrigin = class extends Service$1()("t3cli/T3LocalAuthOrigin") {};
65599
+ const makeT3LocalAuthOrigin = fn("makeT3LocalAuthOrigin")(function* () {
65600
+ const fs = yield* FileSystem;
65601
+ const path = yield* Path;
65602
+ const environment = yield* Environment;
65603
+ return { resolve: fn("T3LocalAuthOriginLive.resolve")(function* (input) {
65604
+ const baseDir = resolveLocalBaseDir({
65605
+ baseDir: input?.baseDir,
65606
+ environment,
65607
+ path
65608
+ });
65609
+ if (input?.origin !== void 0) return yield* normalizeLocalOrigin(input.origin);
65610
+ const runtimeStatePath = path.join(baseDir, "userdata", "server-runtime.json");
65611
+ return yield* normalizeLocalOrigin((yield* decodeAuthLocalRuntimeStateFromJson(yield* fs.readFileString(runtimeStatePath).pipe(mapError$2((error) => new AuthLocalError({
65612
+ message: `local runtime state not found: ${runtimeStatePath}. Make sure T3 Code is running with Network access enabled, or pass --origin manually.`,
65613
+ cause: error
65614
+ })))).pipe(mapError$2((error) => new AuthLocalError({
65615
+ message: "local runtime state has invalid shape",
65616
+ cause: error
65617
+ })))).origin);
65618
+ }) };
65619
+ });
65620
+ const T3LocalAuthOriginLive = effect(T3LocalAuthOrigin, makeT3LocalAuthOrigin());
65621
+ function normalizeLocalOrigin(origin) {
65622
+ return normalizeHttpBaseUrl(origin).pipe(mapError$2((error) => new AuthLocalError({
65623
+ message: error.message,
65624
+ cause: error
65625
+ })));
65626
+ }
65627
+ //#endregion
65514
65628
  //#region node_modules/.pnpm/effect@4.0.0-beta.78/node_modules/effect/dist/unstable/reactivity/Reactivity.js
65515
65629
  /**
65516
65630
  * The `Reactivity` module provides process-local invalidation for connecting
@@ -66488,111 +66602,17 @@ const makeWithTransaction = (options) => (effect) => {
66488
66602
  */
66489
66603
  const TransactionConnection = (clientId) => Service$1(`effect/sql/SqlClient/TransactionConnection/${clientId}`);
66490
66604
  //#endregion
66491
- //#region src/config/url.ts
66492
- function normalizeHttpBaseUrl(value) {
66493
- return parseUrl$1(value).pipe(flatMap$2((url) => succeed$2(normalizeBaseUrl$1(url))));
66494
- }
66495
- function toHttpEndpointUrl(httpBaseUrl, pathname) {
66496
- return parseUrl$1(httpBaseUrl).pipe(flatMap$2((url) => succeed$2(withPathname(url, pathname).toString())));
66497
- }
66498
- function toWebSocketEndpointUrl(httpBaseUrl, pathname) {
66499
- return parseUrl$1(httpBaseUrl).pipe(flatMap$2((url) => {
66500
- if (url.protocol === "http:") return succeed$2(withPathname(url, pathname, "ws:").toString());
66501
- if (url.protocol === "https:") return succeed$2(withPathname(url, pathname, "wss:").toString());
66502
- return fail$2(new UrlError({
66503
- message: `unsupported server url protocol: ${url.protocol}`,
66504
- protocol: url.protocol
66505
- }));
66506
- }));
66507
- }
66508
- function parseUrl$1(value) {
66509
- return fromResult(fromString(value)).pipe(catchTags$1({ IllegalArgumentError: (error) => fail$2(new UrlError({
66510
- message: "invalid url",
66511
- cause: error
66512
- })) }));
66513
- }
66514
- function normalizeBaseUrl$1(url) {
66515
- return mutate(url, (current) => {
66516
- current.hash = "";
66517
- current.search = "";
66518
- current.pathname = normalizePathname(current.pathname);
66519
- }).toString().replace(/\/$/, "");
66520
- }
66521
- function withPathname(url, pathname, protocol) {
66522
- return mutate(url, (current) => {
66523
- if (protocol !== void 0) current.protocol = protocol;
66524
- current.pathname = appendPathname(current.pathname, pathname);
66525
- current.search = "";
66526
- current.hash = "";
66527
- });
66528
- }
66529
- function normalizePathname(pathname) {
66530
- return pathname === "/" ? "" : pathname.replace(/\/+$/u, "");
66531
- }
66532
- function appendPathname(basePathname, pathname) {
66533
- return `${normalizePathname(basePathname)}${pathname.startsWith("/") ? pathname : `/${pathname}`}`;
66534
- }
66535
- //#endregion
66536
66605
  //#region src/sql/service.ts
66537
66606
  var SqlClientFactory = class extends Service$1()("t3cli/SqlClientFactory") {};
66538
66607
  //#endregion
66539
- //#region src/auth/schema.ts
66540
- const AuthAccessTokenResultSchema = Struct({
66541
- access_token: String$1,
66542
- issued_token_type: String$1,
66543
- token_type: Literal("Bearer"),
66544
- expires_in: Number$1,
66545
- scope: String$1
66546
- });
66547
- const AuthSessionStateSchema = Struct({
66548
- authenticated: Boolean$1,
66549
- role: optionalKey(Literals(["owner", "client"])),
66550
- sessionMethod: optionalKey(String$1),
66551
- expiresAt: optionalKey(String$1)
66552
- });
66553
- const AuthWebSocketTicketResultSchema = Struct({
66554
- ticket: String$1,
66555
- expiresAt: String$1
66556
- });
66557
- const AuthLocalRuntimeStateSchema = Struct({
66558
- version: Literal(1),
66559
- origin: String$1
66560
- });
66561
- const decodeAuthAccessTokenResult = decodeUnknownEffect(AuthAccessTokenResultSchema);
66562
- const decodeAuthSessionState = decodeUnknownEffect(AuthSessionStateSchema);
66563
- const decodeAuthWebSocketTicketResult = decodeUnknownEffect(AuthWebSocketTicketResultSchema);
66564
- decodeUnknownEffect(AuthLocalRuntimeStateSchema);
66565
- const decodeAuthLocalRuntimeStateFromJson = decodeUnknownEffect(fromJsonString(AuthLocalRuntimeStateSchema));
66566
- //#endregion
66567
- //#region src/auth/local.ts
66568
- var T3LocalAuth = class extends Service$1()("t3cli/T3LocalAuth") {};
66569
- const makeT3LocalAuth = fn("makeT3LocalAuth")(function* () {
66608
+ //#region src/auth/local-token.ts
66609
+ var T3LocalAuthToken = class extends Service$1()("t3cli/T3LocalAuthToken") {};
66610
+ const makeT3LocalAuthToken = fn("makeT3LocalAuthToken")(function* () {
66570
66611
  const fs = yield* FileSystem;
66571
66612
  const path = yield* Path;
66572
66613
  const environment = yield* Environment;
66573
66614
  const crypto = yield* Crypto;
66574
66615
  const sqlClientFactory = yield* SqlClientFactory;
66575
- function resolveLocalBaseDir(input) {
66576
- const envBaseDir = environment.env["T3CODE_HOME"];
66577
- const raw = input ?? envBaseDir;
66578
- if (raw === void 0 || raw.length === 0) return path.join(environment.homeDir, ".t3");
66579
- if (raw === "~") return environment.homeDir;
66580
- if (raw.startsWith("~/") || raw.startsWith("~\\")) return path.join(environment.homeDir, raw.slice(2));
66581
- return path.resolve(environment.cwd, raw);
66582
- }
66583
- function resolveLocalOrigin(input) {
66584
- return gen(function* () {
66585
- if (input.origin !== void 0) return yield* normalizeLocalOrigin(input.origin);
66586
- const runtimeStatePath = path.join(input.baseDir, "userdata", "server-runtime.json");
66587
- return yield* normalizeLocalOrigin((yield* decodeAuthLocalRuntimeStateFromJson(yield* fs.readFileString(runtimeStatePath).pipe(mapError$2((error) => new AuthLocalError({
66588
- message: `local runtime state not found: ${runtimeStatePath}. Make sure T3 Code is running with Network access enabled, or pass --origin manually.`,
66589
- cause: error
66590
- })))).pipe(mapError$2((error) => new AuthLocalError({
66591
- message: "local runtime state has invalid shape",
66592
- cause: error
66593
- })))).origin);
66594
- });
66595
- }
66596
66616
  function readSigningSecret(secretPath) {
66597
66617
  return fs.readFile(secretPath).pipe(map$3((bytes) => Uint8Array.from(bytes)), catchFilter$2(reason("PlatformError", "NotFound"), () => succeed$2(void 0)), mapError$2((error) => new AuthLocalSecretError({
66598
66618
  message: `failed to read signing secret: ${secretPath}`,
@@ -66667,10 +66687,14 @@ const makeT3LocalAuth = fn("makeT3LocalAuth")(function* () {
66667
66687
  expiresAt: formatIso(expiresAt)
66668
66688
  };
66669
66689
  });
66670
- return { local: fn("T3LocalAuthLive.local")(function* (input) {
66690
+ return { create: fn("T3LocalAuthTokenLive.create")(function* (input) {
66671
66691
  if (input.label.length === 0) return yield* fail$2(new AuthLocalError({ message: "local auth label cannot be empty" }));
66672
66692
  if (input.subject.length === 0) return yield* fail$2(new AuthLocalError({ message: "local auth subject cannot be empty" }));
66673
- const baseDir = resolveLocalBaseDir(input.baseDir);
66693
+ const baseDir = resolveLocalBaseDir({
66694
+ baseDir: input.baseDir,
66695
+ environment,
66696
+ path
66697
+ });
66674
66698
  const session = yield* issueLocalDatabaseSession({
66675
66699
  dbPath: path.join(baseDir, "userdata", "state.sqlite"),
66676
66700
  secretsDir: path.join(baseDir, "userdata", "secrets"),
@@ -66682,10 +66706,6 @@ const makeT3LocalAuth = fn("makeT3LocalAuth")(function* () {
66682
66706
  cause: error
66683
66707
  })));
66684
66708
  return {
66685
- url: yield* resolveLocalOrigin({
66686
- baseDir,
66687
- ...input.origin !== void 0 ? { origin: input.origin } : {}
66688
- }),
66689
66709
  token: session.token,
66690
66710
  role: session.role,
66691
66711
  expiresAt: session.expiresAt,
@@ -66694,7 +66714,7 @@ const makeT3LocalAuth = fn("makeT3LocalAuth")(function* () {
66694
66714
  };
66695
66715
  }) };
66696
66716
  });
66697
- const T3LocalAuthLive = effect(T3LocalAuth, makeT3LocalAuth());
66717
+ const T3LocalAuthTokenLive = effect(T3LocalAuthToken, makeT3LocalAuthToken());
66698
66718
  function insertAuthSession(input) {
66699
66719
  return gen(function* () {
66700
66720
  const sql = yield* SqlClient;
@@ -66738,12 +66758,6 @@ function insertAuthSession(input) {
66738
66758
  `;
66739
66759
  });
66740
66760
  }
66741
- function normalizeLocalOrigin(origin) {
66742
- return normalizeHttpBaseUrl(origin).pipe(mapError$2((error) => new AuthLocalError({
66743
- message: error.message,
66744
- cause: error
66745
- })));
66746
- }
66747
66761
  const defaultSessionTtlMs = 720 * 60 * 60 * 1e3;
66748
66762
  const signingSecretName = "server-signing-key";
66749
66763
  const sha256BlockSize = 64;
@@ -66754,6 +66768,28 @@ function concatBytes(first, second) {
66754
66768
  return bytes;
66755
66769
  }
66756
66770
  //#endregion
66771
+ //#region src/auth/local.ts
66772
+ var T3LocalAuth = class extends Service$1()("t3cli/T3LocalAuth") {};
66773
+ const makeT3LocalAuth = fn("makeT3LocalAuth")(function* () {
66774
+ const origin = yield* T3LocalAuthOrigin;
66775
+ const token = yield* T3LocalAuthToken;
66776
+ return { local: fn("T3LocalAuthLive.local")(function* (input) {
66777
+ const created = yield* token.create(input);
66778
+ return {
66779
+ url: yield* origin.resolve({
66780
+ baseDir: created.baseDir,
66781
+ ...input.origin !== void 0 ? { origin: input.origin } : {}
66782
+ }),
66783
+ token: created.token,
66784
+ role: created.role,
66785
+ expiresAt: created.expiresAt,
66786
+ source: "local",
66787
+ baseDir: created.baseDir
66788
+ };
66789
+ }) };
66790
+ });
66791
+ const T3LocalAuthLive = effect(T3LocalAuth, makeT3LocalAuth());
66792
+ //#endregion
66757
66793
  //#region src/auth/transport.ts
66758
66794
  var T3AuthTransport = class extends Service$1()("t3cli/T3AuthTransport") {};
66759
66795
  const T3AuthTransportLive = effect(T3AuthTransport, fn("makeT3AuthTransport")(function* () {
@@ -66788,8 +66824,8 @@ const T3AuthTransportLive = effect(T3AuthTransport, fn("makeT3AuthTransport")(fu
66788
66824
  sessionToken: result.access_token
66789
66825
  };
66790
66826
  }),
66791
- getSession: fn("AuthTransport.getSession")(function* (config) {
66792
- const request = get$1(yield* makeHttpEndpointUrl(config.url, "/api/auth/session")).pipe(authenticatedRequest(config));
66827
+ getSession: fn("AuthTransport.getSession")(function* (connection) {
66828
+ const request = get$1(yield* makeHttpEndpointUrl(connection.url, "/api/auth/session")).pipe(authenticatedRequest(connection));
66793
66829
  return yield* (yield* client.execute(request).pipe(catchTags$1({ HttpClientError: (error) => fail$2(new AuthTransportError({
66794
66830
  message: "auth request failed",
66795
66831
  cause: HttpClientErrorSchema.fromHttpClientError(error)
@@ -66804,8 +66840,8 @@ const T3AuthTransportLive = effect(T3AuthTransport, fn("makeT3AuthTransport")(fu
66804
66840
  }))
66805
66841
  }));
66806
66842
  }),
66807
- issueWebSocketTicket: fn("AuthTransport.issueWebSocketTicket")(function* (config) {
66808
- const request = post$1(yield* makeHttpEndpointUrl(config.url, "/api/auth/websocket-ticket")).pipe(authenticatedRequest(config));
66843
+ issueWebSocketTicket: fn("AuthTransport.issueWebSocketTicket")(function* (connection) {
66844
+ const request = post$1(yield* makeHttpEndpointUrl(connection.url, "/api/auth/websocket-ticket")).pipe(authenticatedRequest(connection));
66809
66845
  return yield* (yield* client.execute(request).pipe(catchTags$1({ HttpClientError: (error) => fail$2(new AuthTransportError({
66810
66846
  message: "auth request failed",
66811
66847
  cause: HttpClientErrorSchema.fromHttpClientError(error)
@@ -66822,7 +66858,7 @@ const T3AuthTransportLive = effect(T3AuthTransport, fn("makeT3AuthTransport")(fu
66822
66858
  })
66823
66859
  };
66824
66860
  })());
66825
- const authenticatedRequest = (config) => (request) => request.pipe(acceptJson, bearerToken(config.token));
66861
+ const authenticatedRequest = (connection) => (request) => request.pipe(acceptJson, bearerToken(connection.token));
66826
66862
  function makeHttpEndpointUrl(baseUrl, path) {
66827
66863
  return toHttpEndpointUrl(baseUrl, path).pipe(catchTags$1({ UrlError: (error) => fail$2(new AuthTransportError({
66828
66864
  message: "auth request failed",
@@ -66935,6 +66971,21 @@ const makeT3Auth = fn("makeT3Auth")(function* () {
66935
66971
  });
66936
66972
  const T3AuthLive = effect(T3Auth, makeT3Auth());
66937
66973
  //#endregion
66974
+ //#region src/connection/error.ts
66975
+ var T3CodeConnectionError = class extends TaggedErrorClass()("T3CodeConnectionError", {
66976
+ message: String$1,
66977
+ cause: optionalKey(Unknown)
66978
+ }) {};
66979
+ //#endregion
66980
+ //#region src/connection/service.ts
66981
+ var T3CodeConnectionProvider = class extends Service$1()("t3cli/T3CodeConnectionProvider") {};
66982
+ function makeT3CodeConnectionProvider(get) {
66983
+ return { get };
66984
+ }
66985
+ function T3CodeConnectionProviderLive(connection) {
66986
+ return succeed$3(T3CodeConnectionProvider, makeT3CodeConnectionProvider(succeed$2(connection)));
66987
+ }
66988
+ //#endregion
66938
66989
  //#region src/config/layer.ts
66939
66990
  const makeT3Config = fn("makeT3Config")(function* () {
66940
66991
  const fs = yield* FileSystem;
@@ -70260,11 +70311,8 @@ const RpcErrorCauseSchema = Union([
70260
70311
  OrchestrationDispatchCommandError,
70261
70312
  OrchestrationGetSnapshotError,
70262
70313
  ServerSettingsError,
70263
- AuthConfigError,
70264
- AuthLocalError,
70265
- AuthPairingUrlError,
70266
70314
  AuthTransportError,
70267
- ConfigError,
70315
+ T3CodeConnectionError,
70268
70316
  HttpClientErrorSchema,
70269
70317
  UrlError,
70270
70318
  instanceOf(SchemaError)
@@ -70867,17 +70915,18 @@ const makeClient = make$1(make$5(WsOrchestrationDispatchCommandRpc, WsOrchestrat
70867
70915
  })));
70868
70916
  const connectionRetrySchedule = exponential("100 millis").pipe(take$2(4));
70869
70917
  const makeT3RpcLayer = fn("makeT3RpcLayer")(function* () {
70870
- const config = yield* T3Config;
70871
- const auth = yield* T3Auth;
70918
+ const connectionProvider = yield* T3CodeConnectionProvider;
70919
+ const authTransport = yield* T3AuthTransport;
70920
+ const webSocketConstructor = yield* WebSocketConstructor;
70872
70921
  const parentScope = yield* Scope;
70873
70922
  const connection = yield* make(none());
70874
70923
  const openConnection = fn("T3RpcLive.openConnection")(function* () {
70875
70924
  const scope = yield* fork(parentScope);
70876
70925
  return yield* gen(function* () {
70877
70926
  const protocol = yield* buildWithScope(makeProtocolLayer(yield* makeWsUrl({
70878
- auth,
70879
- config
70880
- })), scope);
70927
+ authTransport,
70928
+ connectionProvider
70929
+ }), webSocketConstructor), scope);
70881
70930
  return {
70882
70931
  scope,
70883
70932
  client: yield* makeClient.pipe(provide(protocol), provideService$1(Scope, scope))
@@ -70904,12 +70953,16 @@ const makeT3RpcLayer = fn("makeT3RpcLayer")(function* () {
70904
70953
  };
70905
70954
  });
70906
70955
  const makeWsUrl = fn("makeWsUrl")(function* (input) {
70907
- const resolved = yield* input.config.resolve();
70908
- const wsTicket = yield* input.auth.issueWebSocketTicket();
70909
- return getOrThrow(toUrl(get$1(yield* toWebSocketEndpointUrl(resolved.url, "/ws")).pipe(setUrlParam("wsTicket", wsTicket.ticket)))).toString();
70956
+ const connection = yield* input.connectionProvider.get;
70957
+ const origin = yield* normalizeHttpBaseUrl(connection.origin.url);
70958
+ const wsTicket = yield* input.authTransport.issueWebSocketTicket({
70959
+ url: origin,
70960
+ token: connection.auth.token
70961
+ });
70962
+ return getOrThrow(toUrl(get$1(yield* toWebSocketEndpointUrl(origin, "/ws")).pipe(setUrlParam("wsTicket", wsTicket.ticket)))).toString();
70910
70963
  });
70911
- function makeProtocolLayer(url) {
70912
- const socketLayer = layerWebSocket(url).pipe(provide$2(layerWebSocketConstructor));
70964
+ function makeProtocolLayer(url, webSocketConstructor) {
70965
+ const socketLayer = layerWebSocket(url).pipe(provide$2(succeed$3(WebSocketConstructor, webSocketConstructor)));
70913
70966
  return layerProtocolSocket({ retryTransientErrors: true }).pipe(provide$2(socketLayer), provide$2(layerJson));
70914
70967
  }
70915
70968
  const T3RpcLive = effectContext(makeT3RpcLayer().pipe(map$3((rpc) => make$40(T3Rpc, rpc))));
@@ -71423,13 +71476,24 @@ function toSqlInputValue(value) {
71423
71476
  //#endregion
71424
71477
  //#region src/runtime.ts
71425
71478
  const T3AuthTransportLayer = T3AuthTransportLive.pipe(provide$2(layerUndici));
71426
- const T3LocalAuthLayer = T3LocalAuthLive.pipe(provide$2(NodeSqlClientFactoryLive));
71479
+ const T3LocalAuthOriginLayer = T3LocalAuthOriginLive;
71480
+ const T3LocalAuthTokenLayer = T3LocalAuthTokenLive.pipe(provide$2(NodeSqlClientFactoryLive));
71481
+ const T3LocalAuthLayer = T3LocalAuthLive.pipe(provide$2(mergeAll$1(T3LocalAuthOriginLayer, T3LocalAuthTokenLayer)));
71427
71482
  const T3AuthPairingLayer = T3AuthPairingLive.pipe(provide$2(T3AuthTransportLayer));
71428
71483
  const T3AuthLayer = T3AuthLive.pipe(provide$2(mergeAll$1(T3ConfigLive, T3AuthTransportLayer, T3LocalAuthLayer, T3AuthPairingLayer)));
71429
- const T3RpcLayer = T3RpcLive.pipe(provide$2(mergeAll$1(T3ConfigLive, T3AuthLayer, layerWebSocketConstructor)));
71484
+ const T3ConfigConnectionProviderLayer = effect(T3CodeConnectionProvider, gen(function* () {
71485
+ return makeT3CodeConnectionProvider((yield* T3Config).resolve().pipe(map$3((resolved) => ({
71486
+ origin: { url: resolved.url },
71487
+ auth: { token: resolved.token }
71488
+ })), mapError$2((error) => new T3CodeConnectionError({
71489
+ message: "failed to resolve T3 Code connection from CLI config",
71490
+ cause: error
71491
+ }))));
71492
+ })).pipe(provide$2(T3ConfigLive));
71493
+ const T3RpcLayer = T3RpcLive.pipe(provide$2(mergeAll$1(T3ConfigConnectionProviderLayer, T3AuthTransportLayer, layerWebSocketConstructor)));
71430
71494
  const T3OrchestrationLayer = T3OrchestrationLive.pipe(provide$2(T3RpcLayer));
71431
71495
  const T3ApplicationLayer = T3ApplicationLive.pipe(provide$2(T3OrchestrationLayer));
71432
71496
  const AuthAppLayer = mergeAll$1(T3ConfigLive, T3AuthLayer);
71433
71497
  const AppLayer = mergeAll$1(T3ConfigLive, T3AuthLayer, T3RpcLayer, T3OrchestrationLayer, T3ApplicationLayer);
71434
71498
  //#endregion
71435
- export { is as $, sync$2 as $n, catchFilter$2 as $t, UrlError as A, timeoutOrElse as An, dual as Ar, tap as At, Boolean$1 as B, mergeAll$1 as Bn, offer as Bt, AuthLocalDatabaseError as C, scoped$2 as Cn, format$1 as Cr, run$1 as Ct, AuthPairingUrlError as D, sync as Dn, isNullish as Dr, runLast as Dt, AuthLocalSigningError as E, suspend$3 as En, isNotUndefined as Er, runFold as Et, T3Application as F, TaggedError as Fn, __require as Fr, drain as Ft, Literals as G, MinimumLogLevel as Gn, nominal as Gt, ErrorClass as H, provideMerge as Hn, BadArgument as Ht, Environment as I, fail$3 as In, __toESM as Ir, isSink as It, TaggedErrorClass as J, isDone$1 as Jn, addFinalizer as Jt, String$1 as K, _await as Kn, transform as Kt, T3Config as L, hasInterruptsOnly as Ln, endUnsafe as Lt, ThreadSessionError as M, try_ as Mn, pipe as Mr, unwrap as Mt, latestAssistantMessage as N, uninterruptible as Nn, pipeArguments as Nr, get$2 as Nt, AuthTransportError as O, tapCause as On, isUndefined as Or, splitLines as Ot, threadStatus as P, void_$1 as Pn, __commonJSMin as Pr, make$25 as Pt, fromJsonString as Q, ConsoleRef as Qn, callback$1 as Qt, T3Auth as R, squash as Rn, failCauseUnsafe as Rt, AuthConfigError as S, runFork as Sn, BaseProto as Sr, mkString as St, AuthLocalSecretError as T, succeed$2 as Tn, isNotNull as Tr, runDrain as Tt, Int as U, succeed$3 as Un, badArgument as Ut, Defect as V, provide$2 as Vn, offerUnsafe as Vt, Literal as W, sync$1 as Wn, systemError as Wt, decodeTo as X, isSuccess as Xn, as as Xt, Union as Y, makeUnsafe$8 as Yn, andThen as Yt, decodeUnknownEffect as Z, succeed$4 as Zn, asVoid as Zt, parsePairingUrl as _, orDie as _n, none as _r, decodeText as _t, T3AuthTransportLayer as a, fn as an, empty$11 as ar, make$23 as at, makeT3LocalAuth as b, provideService$1 as bn, PipeInspectableProto as br, isStream as bt, NodeSqliteClientLive as c, forkScoped as cn, flatMap$4 as cr, Path as ct, makeT3Config as d, interrupt$1 as dn, getOrElse$1 as dr, FileSystem as dt, catchTags$1 as en, map$5 as er, optional as et, T3AuthLive as f, isEffect as fn, getOrUndefined as fr, FileTypeId as ft, makeT3AuthPairing as g, matchEffect as gn, match$3 as gr, callback as gt, T3AuthPairingLive as h, mapError$2 as hn, map$7 as hr, make$24 as ht, T3AuthPairingLayer as i, flatMap$2 as in, Service$1 as ir, Crypto as it, NodeEnvironmentLive as j, tryPromise as jn, identity as jr, transduce as jt, ConfigError as k, tapError$2 as kn, constVoid as kr, succeed as kt, makeNodeSqliteClient as l, gen as ln, fromNullishOr as lr, TypeId$29 as lt, T3AuthPairing as m, map$3 as mn, isSome as mr, WatchBackend as mt, AuthAppLayer as n, effectify as nn, succeed$6 as nr, tag as nt, T3LocalAuthLayer as o, fnUntraced as on, getUnsafe$2 as or, fromReadable as ot, makeT3Auth as p, logError as pn, isNone as pr, Size as pt, Struct as q, doneUnsafe as qn, acquireRelease as qt, T3AuthLayer as r, fail$2 as rn, Reference as rr, toCodecStringTree as rt, NodeSqlClientFactoryLive as s, forEach$1 as sn, make$40 as sr, fromWritable as st, AppLayer as t, catch_$1 as tn, fail$6 as tr, optionalKey as tt, T3ConfigLive as u, ignore$1 as un, fromUndefinedOr as ur, FileDescriptor as ut, T3LocalAuth as v, provide as vn, some as vr, empty$6 as vt, AuthLocalError as w, serviceOption as wn, hasProperty as wr, runCollect as wt, SqlClientFactory as x, result as xn, withFiber$1 as xr, merge$1 as xt, T3LocalAuthLive as y, provideContext$2 as yn, Prototype as yr, fromIterable$1 as yt, ArraySchema as z, effect as zn, make$27 as zt };
71499
+ export { T3Config as $, hasInterruptsOnly as $n, endUnsafe as $t, T3LocalAuthTokenLive as A, map$3 as An, isSome as Ar, WatchBackend as At, AuthLocalSigningError as B, serviceOption as Bn, hasProperty as Br, runCollect as Bt, makeT3AuthPairing as C, forEach$1 as Cn, make$40 as Cr, fromWritable as Ct, T3LocalAuthLive as D, interrupt$1 as Dn, getOrElse$1 as Dr, FileSystem as Dt, T3LocalAuth as E, ignore$1 as En, fromUndefinedOr as Er, FileDescriptor as Et, makeT3LocalAuthOrigin as F, provideContext$2 as Fn, Prototype as Fr, fromIterable$1 as Ft, layerWebSocketConstructor as G, tapError$2 as Gn, constVoid as Gr, succeed as Gt, AuthTransportError as H, suspend$3 as Hn, isNotUndefined as Hr, runFold as Ht, AuthConfigError as I, provideService$1 as In, PipeInspectableProto as Ir, isStream as It, ThreadSessionError as J, try_ as Jn, pipe as Jr, unwrap as Jt, layerUndici as K, timeoutOrElse as Kn, dual as Kr, tap as Kt, AuthLocalDatabaseError as L, result as Ln, withFiber$1 as Lr, merge$1 as Lt, SqlClientFactory as M, matchEffect as Mn, match$3 as Mr, callback as Mt, T3LocalAuthOrigin as N, orDie as Nn, none as Nr, decodeText as Nt, makeT3LocalAuth as O, isEffect as On, getOrUndefined as Or, FileTypeId as Ot, T3LocalAuthOriginLive as P, provide as Pn, some as Pr, empty$6 as Pt, Environment as Q, fail$3 as Qn, __toESM as Qr, isSink as Qt, AuthLocalError as R, runFork as Rn, BaseProto as Rr, mkString as Rt, T3AuthPairingLive as S, fnUntraced as Sn, getUnsafe$2 as Sr, fromReadable as St, T3AuthTransportLive as T, gen as Tn, fromNullishOr as Tr, TypeId$29 as Tt, ConfigError as U, sync as Un, isNullish as Ur, runLast as Ut, AuthPairingUrlError as V, succeed$2 as Vn, isNotNull as Vr, runDrain as Vt, UrlError as W, tapCause as Wn, isUndefined as Wr, splitLines as Wt, threadStatus as X, void_$1 as Xn, __commonJSMin as Xr, make$25 as Xt, latestAssistantMessage as Y, uninterruptible as Yn, pipeArguments as Yr, get$2 as Yt, T3Application as Z, TaggedError as Zn, __require as Zr, drain as Zt, makeT3CodeConnectionProvider as _, catch_$1 as _n, fail$6 as _r, optionalKey as _t, T3AuthTransportLayer as a, badArgument as an, succeed$3 as ar, Int as at, makeT3Auth as b, flatMap$2 as bn, Service$1 as br, Crypto as bt, T3LocalAuthTokenLayer as c, transform as cn, _await as cr, String$1 as ct, makeNodeSqliteClient as d, andThen as dn, makeUnsafe$8 as dr, Union as dt, failCauseUnsafe as en, squash as er, T3Auth as et, T3RpcLive as f, as as fn, isSuccess as fr, decodeTo as ft, T3CodeConnectionProviderLive as g, catchTags$1 as gn, map$5 as gr, optional as gt, T3CodeConnectionProvider as h, catchFilter$2 as hn, sync$2 as hr, is as ht, T3AuthPairingLayer as i, BadArgument as in, provideMerge as ir, ErrorClass as it, makeT3LocalAuthToken as j, mapError$2 as jn, map$7 as jr, make$24 as jt, T3LocalAuthToken as k, logError as kn, isNone as kr, Size as kt, NodeSqlClientFactoryLive as l, acquireRelease as ln, doneUnsafe as lr, Struct as lt, makeT3Config as m, callback$1 as mn, ConsoleRef as mr, fromJsonString as mt, AuthAppLayer as n, offer as nn, mergeAll$1 as nr, Boolean$1 as nt, T3LocalAuthLayer as o, systemError as on, sync$1 as or, Literal as ot, T3ConfigLive as p, asVoid as pn, succeed$4 as pr, decodeUnknownEffect as pt, NodeEnvironmentLive as q, tryPromise as qn, identity as qr, transduce as qt, T3AuthLayer as r, offerUnsafe as rn, provide$2 as rr, Defect as rt, T3LocalAuthOriginLayer as s, nominal as sn, MinimumLogLevel as sr, Literals as st, AppLayer as t, make$27 as tn, effect as tr, ArraySchema as tt, NodeSqliteClientLive as u, addFinalizer as un, isDone$1 as ur, TaggedErrorClass as ut, T3CodeConnectionError as v, effectify as vn, succeed$6 as vr, tag as vt, parsePairingUrl as w, forkScoped as wn, flatMap$4 as wr, Path as wt, T3AuthPairing as x, fn as xn, empty$11 as xr, make$23 as xt, T3AuthLive as y, fail$2 as yn, Reference as yr, toCodecStringTree as yt, AuthLocalSecretError as z, scoped$2 as zn, format$1 as zr, run$1 as zt };
@@ -0,0 +1,7 @@
1
+ import type * as Path from "effect/Path";
2
+ import type { EnvironmentShape } from "../environment/service.ts";
3
+ export declare function resolveLocalBaseDir(input: {
4
+ readonly baseDir: string | undefined;
5
+ readonly environment: EnvironmentShape;
6
+ readonly path: Path.Path;
7
+ }): string;
@@ -0,0 +1,18 @@
1
+ import * as Context from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import * as FileSystem from "effect/FileSystem";
4
+ import * as Layer from "effect/Layer";
5
+ import * as Path from "effect/Path";
6
+ import { Environment } from "../environment/service.ts";
7
+ import { AuthLocalError } from "./error.ts";
8
+ import type { LocalAuthOriginInput } from "./type.ts";
9
+ declare const T3LocalAuthOrigin_base: Context.ServiceClass<T3LocalAuthOrigin, "t3cli/T3LocalAuthOrigin", {
10
+ readonly resolve: (input?: LocalAuthOriginInput) => Effect.Effect<string, AuthLocalError>;
11
+ }>;
12
+ export declare class T3LocalAuthOrigin extends T3LocalAuthOrigin_base {
13
+ }
14
+ export declare const makeT3LocalAuthOrigin: () => Effect.Effect<{
15
+ resolve: (input?: LocalAuthOriginInput | undefined) => Effect.Effect<string, AuthLocalError, never>;
16
+ }, never, Environment | Path.Path | FileSystem.FileSystem>;
17
+ export declare const T3LocalAuthOriginLive: Layer.Layer<T3LocalAuthOrigin, never, Environment | Path.Path | FileSystem.FileSystem>;
18
+ export {};
@@ -0,0 +1,26 @@
1
+ import * as Context from "effect/Context";
2
+ import * as Crypto from "effect/Crypto";
3
+ import * as Effect from "effect/Effect";
4
+ import * as FileSystem from "effect/FileSystem";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Path from "effect/Path";
7
+ import { Environment } from "../environment/service.ts";
8
+ import { SqlClientFactory } from "../sql/service.ts";
9
+ import { AuthLocalError } from "./error.ts";
10
+ import type { LocalAuthTokenInput, LocalAuthTokenResult } from "./type.ts";
11
+ declare const T3LocalAuthToken_base: Context.ServiceClass<T3LocalAuthToken, "t3cli/T3LocalAuthToken", {
12
+ readonly create: (input: LocalAuthTokenInput) => Effect.Effect<LocalAuthTokenResult, AuthLocalError>;
13
+ }>;
14
+ export declare class T3LocalAuthToken extends T3LocalAuthToken_base {
15
+ }
16
+ export declare const makeT3LocalAuthToken: () => Effect.Effect<{
17
+ create: (input: LocalAuthTokenInput) => Effect.Effect<{
18
+ token: string;
19
+ role: "client" | "owner";
20
+ expiresAt: string;
21
+ source: "local";
22
+ baseDir: string;
23
+ }, AuthLocalError, never>;
24
+ }, never, Environment | Path.Path | FileSystem.FileSystem | SqlClientFactory | Crypto.Crypto>;
25
+ export declare const T3LocalAuthTokenLive: Layer.Layer<T3LocalAuthToken, never, Environment | Path.Path | FileSystem.FileSystem | SqlClientFactory | Crypto.Crypto>;
26
+ export {};
@@ -1,12 +1,9 @@
1
1
  import * as Context from "effect/Context";
2
- import * as Crypto from "effect/Crypto";
3
2
  import * as Effect from "effect/Effect";
4
- import * as FileSystem from "effect/FileSystem";
5
3
  import * as Layer from "effect/Layer";
6
- import * as Path from "effect/Path";
7
- import { Environment } from "../environment/service.ts";
8
- import { SqlClientFactory } from "../sql/service.ts";
9
4
  import { AuthLocalError } from "./error.ts";
5
+ import { T3LocalAuthOrigin } from "./local-origin.ts";
6
+ import { T3LocalAuthToken } from "./local-token.ts";
10
7
  import type { LocalAuthInput, LocalAuthResult } from "./type.ts";
11
8
  declare const T3LocalAuth_base: Context.ServiceClass<T3LocalAuth, "t3cli/T3LocalAuth", {
12
9
  readonly local: (input: LocalAuthInput) => Effect.Effect<LocalAuthResult, AuthLocalError>;
@@ -22,6 +19,6 @@ export declare const makeT3LocalAuth: () => Effect.Effect<{
22
19
  source: "local";
23
20
  baseDir: string;
24
21
  }, AuthLocalError, never>;
25
- }, never, Environment | SqlClientFactory | Path.Path | FileSystem.FileSystem | Crypto.Crypto>;
26
- export declare const T3LocalAuthLive: Layer.Layer<T3LocalAuth, never, Environment | SqlClientFactory | Path.Path | FileSystem.FileSystem | Crypto.Crypto>;
22
+ }, never, T3LocalAuthOrigin | T3LocalAuthToken>;
23
+ export declare const T3LocalAuthLive: Layer.Layer<T3LocalAuth, never, T3LocalAuthOrigin | T3LocalAuthToken>;
27
24
  export {};
@@ -2,16 +2,19 @@ import * as Context from "effect/Context";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
4
  import { HttpClient } from "effect/unstable/http";
5
- import type { ResolvedConfig } from "../config/service.ts";
6
5
  import { AuthTransportError } from "./error.ts";
7
6
  import { type AuthBearerBootstrapResult, type AuthSessionState, type AuthWebSocketTicketResult } from "./schema.ts";
7
+ export type AuthTransportConnection = {
8
+ readonly url: string;
9
+ readonly token: string;
10
+ };
8
11
  declare const T3AuthTransport_base: Context.ServiceClass<T3AuthTransport, "t3cli/T3AuthTransport", {
9
12
  readonly bootstrapBearer: (input: {
10
13
  readonly baseUrl: string;
11
14
  readonly credential: string;
12
15
  }) => Effect.Effect<AuthBearerBootstrapResult, AuthTransportError>;
13
- readonly getSession: (config: ResolvedConfig) => Effect.Effect<AuthSessionState, AuthTransportError>;
14
- readonly issueWebSocketTicket: (config: ResolvedConfig) => Effect.Effect<AuthWebSocketTicketResult, AuthTransportError>;
16
+ readonly getSession: (connection: AuthTransportConnection) => Effect.Effect<AuthSessionState, AuthTransportError>;
17
+ readonly issueWebSocketTicket: (connection: AuthTransportConnection) => Effect.Effect<AuthWebSocketTicketResult, AuthTransportError>;
15
18
  }>;
16
19
  export declare class T3AuthTransport extends T3AuthTransport_base {
17
20
  }