t3code-cli 0.4.0 → 0.5.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/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as runLast, $n as isNullish, $t as sync, A as Crypto, An as Service, At as flatMap, B as WatchBackend, Bn as isSome, Bt as map$2, C as decodeUnknownEffect, Cn as succeed$1, Ct as asVoid, D as optionalKey, Dn as fail$2, Dt as catch_, E as optional$3, En as map$3, Et as catchTags, F as TypeId$7, Fn as fromNullishOr, Ft as gen, G as fromIterable, Gn as Prototype, Gt as provideContext, H as callback$1, Hn as match, Ht as matchEffect, I as FileDescriptor, In as fromUndefinedOr, It as ignore, J as mkString, Jn as BaseProto, Jt as runFork, K as isStream, Kn as PipeInspectableProto, Kt as provideService, L as FileSystem, Ln as getOrElse, Lt as interrupt, M as fromReadable, Mn as getUnsafe, Mt as fnUntraced, N as fromWritable, Nn as make$13, Nt as forEach, O as tag, On as succeed$3, Ot as effectify, P as Path$1, Pn as flatMap$1, Pt as forkScoped, Q as runFold, Qn as isNotUndefined, Qt as suspend, R as FileTypeId, Rn as getOrUndefined, Rt as isEffect, S as decodeTo, Sn as isSuccess, St as as, T as is, Tn as sync$1, Tt as catchFilter, U as decodeText, Un as none, Ut as orDie, V as make$10, Vn as map$4, Vt as mapError, W as empty, Wn as some, Wt as provide$1, X as runCollect, Xn as hasProperty, Xt as serviceOption, Y as run$1, Yn as format, Yt as scoped, Z as runDrain, Zn as isNotNull, Zt as succeed, _ as Literals, _n as MinimumLogLevel, _t as nominal, a as latestAssistantMessage, an as uninterruptible, ar as pipeArguments, at as get, b as TaggedErrorClass, bn as isDone, bt as addFinalizer, c as Environment, cn as fail$1, ct as isSink, d as ArraySchema, dn as effect, dt as make$12, en as tapCause, er as isUndefined, et as splitLines, f as Boolean$2, fn as mergeAll, ft as offer, g as Literal, gn as sync$2, gt as systemError, h as Int, hn as succeed$2, ht as badArgument, i as ThreadSessionError, in as try_, ir as pipe, it as unwrap, j as make$9, jn as empty$1, jt as fn, k as toCodecStringTree, kn as Reference, kt as fail, l as T3Config, ln as hasInterruptsOnly, lt as endUnsafe, m as ErrorClass, mn as provideMerge, mt as BadArgument, nn as timeoutOrElse, nr as dual, nt as tap, o as threadStatus, on as void_, or as __commonJSMin, ot as make$11, p as Defect, pn as provide, pt as offerUnsafe, q as merge, qn as withFiber, qt as result, r as NodeEnvironmentLive, rn as tryPromise, rr as identity, rt as transduce, s as T3Application, sn as TaggedError, sr as __require, st as drain, t as AppLayer, tn as tapError, tr as constVoid, tt as succeed$4, u as T3Auth, un as squash, ut as failCauseUnsafe, v as String$1, vn as _await, vt as transform$1, w as fromJsonString, wn as ConsoleRef, wt as callback, x as Union, xn as makeUnsafe, xt as andThen, y as Struct, yn as doneUnsafe, yt as acquireRelease, z as Size, zn as isNone, zt as logError } from "./runtime-Cq64iuZr.js";
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";
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";
@@ -17584,6 +17584,7 @@ const pairCommand = make("pair", {
17584
17584
  const output = yield* T3Output;
17585
17585
  const resolvedFormat = resolveOutputFormat(format, environment, "json");
17586
17586
  const result = yield* auth.pair(url);
17587
+ yield* auth.writeConfig(result);
17587
17588
  if (resolvedFormat === "json") yield* output.printJson(result);
17588
17589
  else yield* output.printInfo(formatAuthPaired(result));
17589
17590
  })).pipe(withDescription("pair with t3code server"));
@@ -17606,6 +17607,7 @@ const localCommand = make("local", {
17606
17607
  ...isSome(baseDir) ? { baseDir: baseDir.value } : {},
17607
17608
  ...isSome(origin) ? { origin: origin.value } : {}
17608
17609
  });
17610
+ yield* auth.writeConfig(result);
17609
17611
  if (resolvedFormat === "json") yield* output.printJson(formatAuthLocalJson(result));
17610
17612
  else yield* output.printInfo(formatAuthLocalHuman(result));
17611
17613
  })).pipe(withDescription("authenticate with local t3code installation"));
@@ -18147,7 +18149,7 @@ var T3Version = class extends Service()("t3cli/T3Version") {};
18147
18149
  //#endregion
18148
18150
  //#region src/version/layer.ts
18149
18151
  const PackageJsonSchema = fromJsonString(Struct({ version: String$1 }));
18150
- const T3VersionBundledLive = sync$2(T3Version, () => ({ version: "0.4.0" }));
18152
+ const T3VersionBundledLive = sync$2(T3Version, () => ({ version: "0.5.0" }));
18151
18153
  effect(T3Version, gen(function* () {
18152
18154
  const packageJson = yield* (yield* FileSystem).readFileString(fileURLToPath(new URL("../../package.json", import.meta.url)));
18153
18155
  return { version: (yield* decodeUnknownEffect(PackageJsonSchema)(packageJson)).version };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as AuthAppLayer, r as NodeEnvironmentLive, s as T3Application, t as AppLayer } from "./runtime-Cq64iuZr.js";
2
- export { AppLayer, AuthAppLayer, NodeEnvironmentLive, T3Application };
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 };
@@ -66566,8 +66566,7 @@ const decodeAuthLocalRuntimeStateFromJson = decodeUnknownEffect(fromJsonString(A
66566
66566
  //#endregion
66567
66567
  //#region src/auth/local.ts
66568
66568
  var T3LocalAuth = class extends Service$1()("t3cli/T3LocalAuth") {};
66569
- const T3LocalAuthLive = effect(T3LocalAuth, fn("makeT3LocalAuth")(function* () {
66570
- const config = yield* T3Config;
66569
+ const makeT3LocalAuth = fn("makeT3LocalAuth")(function* () {
66571
66570
  const fs = yield* FileSystem;
66572
66571
  const path = yield* Path;
66573
66572
  const environment = yield* Environment;
@@ -66668,22 +66667,6 @@ const T3LocalAuthLive = effect(T3LocalAuth, fn("makeT3LocalAuth")(function* () {
66668
66667
  expiresAt: formatIso(expiresAt)
66669
66668
  };
66670
66669
  });
66671
- function writeLocalConfig(input) {
66672
- return gen(function* () {
66673
- const existing = yield* config.readStored().pipe(catchTags$1({ ConfigError: (error) => fail$2(new AuthConfigError({
66674
- message: "auth config failed",
66675
- cause: error
66676
- })) }));
66677
- yield* config.writeStored({
66678
- ...existing,
66679
- url: input.url,
66680
- token: input.token
66681
- }).pipe(catchTags$1({ ConfigError: (error) => fail$2(new AuthConfigError({
66682
- message: "auth config failed",
66683
- cause: error
66684
- })) }));
66685
- });
66686
- }
66687
66670
  return { local: fn("T3LocalAuthLive.local")(function* (input) {
66688
66671
  if (input.label.length === 0) return yield* fail$2(new AuthLocalError({ message: "local auth label cannot be empty" }));
66689
66672
  if (input.subject.length === 0) return yield* fail$2(new AuthLocalError({ message: "local auth subject cannot be empty" }));
@@ -66698,23 +66681,20 @@ const T3LocalAuthLive = effect(T3LocalAuth, fn("makeT3LocalAuth")(function* () {
66698
66681
  message: `local auth failed: ${error.message}`,
66699
66682
  cause: error
66700
66683
  })));
66701
- const url = yield* resolveLocalOrigin({
66702
- baseDir,
66703
- ...input.origin !== void 0 ? { origin: input.origin } : {}
66704
- });
66705
- yield* writeLocalConfig({
66706
- url,
66707
- token: session.token
66708
- });
66709
66684
  return {
66710
- url,
66685
+ url: yield* resolveLocalOrigin({
66686
+ baseDir,
66687
+ ...input.origin !== void 0 ? { origin: input.origin } : {}
66688
+ }),
66689
+ token: session.token,
66711
66690
  role: session.role,
66712
66691
  expiresAt: session.expiresAt,
66713
66692
  source: "local",
66714
66693
  baseDir
66715
66694
  };
66716
66695
  }) };
66717
- })());
66696
+ });
66697
+ const T3LocalAuthLive = effect(T3LocalAuth, makeT3LocalAuth());
66718
66698
  function insertAuthSession(input) {
66719
66699
  return gen(function* () {
66720
66700
  const sql = yield* SqlClient;
@@ -66852,31 +66832,20 @@ function makeHttpEndpointUrl(baseUrl, path) {
66852
66832
  //#endregion
66853
66833
  //#region src/auth/pairing.ts
66854
66834
  var T3AuthPairing = class extends Service$1()("t3cli/T3AuthPairing") {};
66855
- const T3AuthPairingLive = effect(T3AuthPairing, fn("makeT3AuthPairing")(function* () {
66856
- const config = yield* T3Config;
66835
+ const makeT3AuthPairing = fn("makeT3AuthPairing")(function* () {
66857
66836
  const transport = yield* T3AuthTransport;
66858
66837
  return { pair: fn("T3AuthPairingLive.pair")(function* (pairingUrl) {
66859
66838
  const parsed = yield* parsePairingUrl(pairingUrl);
66860
66839
  const result = yield* transport.bootstrapBearer(parsed);
66861
- const existing = yield* config.readStored().pipe(catchTags$1({ ConfigError: (error) => fail$2(new AuthConfigError({
66862
- message: "auth config failed",
66863
- cause: error
66864
- })) }));
66865
- yield* config.writeStored({
66866
- ...existing,
66867
- url: parsed.baseUrl,
66868
- token: result.sessionToken
66869
- }).pipe(catchTags$1({ ConfigError: (error) => fail$2(new AuthConfigError({
66870
- message: "auth config failed",
66871
- cause: error
66872
- })) }));
66873
66840
  return {
66874
66841
  url: parsed.baseUrl,
66842
+ token: result.sessionToken,
66875
66843
  role: result.role,
66876
66844
  expiresAt: result.expiresAt
66877
66845
  };
66878
66846
  }) };
66879
- })());
66847
+ });
66848
+ const T3AuthPairingLive = effect(T3AuthPairing, makeT3AuthPairing());
66880
66849
  function parsePairingUrl(value) {
66881
66850
  return gen(function* () {
66882
66851
  const url = yield* parseUrl(value);
@@ -66909,7 +66878,9 @@ function readPairingToken(url) {
66909
66878
  return hashToken !== void 0 && hashToken.length > 0 ? hashToken : token !== void 0 && token.length > 0 ? token : "";
66910
66879
  });
66911
66880
  }
66912
- const T3AuthLive = effect(T3Auth, fn("makeT3Auth")(function* () {
66881
+ //#endregion
66882
+ //#region src/auth/layer.ts
66883
+ const makeT3Auth = fn("makeT3Auth")(function* () {
66913
66884
  const config = yield* T3Config;
66914
66885
  const transport = yield* T3AuthTransport;
66915
66886
  const localAuth = yield* T3LocalAuth;
@@ -66940,14 +66911,32 @@ const T3AuthLive = effect(T3Auth, fn("makeT3Auth")(function* () {
66940
66911
  }));
66941
66912
  return yield* transport.issueWebSocketTicket(resolved);
66942
66913
  });
66914
+ const writeConfig = fn("T3AuthLive.writeConfig")(function* (input) {
66915
+ const existing = yield* config.readStored().pipe(catchTags$1({ ConfigError: (error) => fail$2(new AuthConfigError({
66916
+ message: "auth config failed",
66917
+ cause: error
66918
+ })) }));
66919
+ yield* config.writeStored({
66920
+ ...existing,
66921
+ url: input.url,
66922
+ token: input.token
66923
+ }).pipe(catchTags$1({ ConfigError: (error) => fail$2(new AuthConfigError({
66924
+ message: "auth config failed",
66925
+ cause: error
66926
+ })) }));
66927
+ });
66943
66928
  return {
66944
66929
  pair: pairing.pair,
66945
66930
  local: localAuth.local,
66931
+ writeConfig,
66946
66932
  status,
66947
66933
  issueWebSocketTicket
66948
66934
  };
66949
- })());
66950
- const T3ConfigLive = effect(T3Config, fn("makeT3Config")(function* () {
66935
+ });
66936
+ const T3AuthLive = effect(T3Auth, makeT3Auth());
66937
+ //#endregion
66938
+ //#region src/config/layer.ts
66939
+ const makeT3Config = fn("makeT3Config")(function* () {
66951
66940
  const fs = yield* FileSystem;
66952
66941
  const path = yield* Path;
66953
66942
  const environment = yield* Environment;
@@ -66992,7 +66981,8 @@ const T3ConfigLive = effect(T3Config, fn("makeT3Config")(function* () {
66992
66981
  };
66993
66982
  })
66994
66983
  };
66995
- })());
66984
+ });
66985
+ const T3ConfigLive = effect(T3Config, makeT3Config());
66996
66986
  const StoredConfigSchema = Struct({
66997
66987
  url: optionalKey(String$1),
66998
66988
  token: optionalKey(String$1)
@@ -71415,6 +71405,7 @@ const makeNodeSqliteClient = fn("makeNodeSqliteClient")(function* (config) {
71415
71405
  transformRows
71416
71406
  });
71417
71407
  });
71408
+ const NodeSqliteClientLive = (config) => effectContext(map$3(makeNodeSqliteClient(config), (client) => make$40(SqlClient, client))).pipe(provide$2(layer));
71418
71409
  const NodeSqlClientFactoryLive = succeed$3(SqlClientFactory, { sqliteClient: (config) => makeNodeSqliteClient(config).pipe(provide(layer)) });
71419
71410
  function toSqlInputValue(value) {
71420
71411
  if (value === void 0 || value === null) return null;
@@ -71432,8 +71423,8 @@ function toSqlInputValue(value) {
71432
71423
  //#endregion
71433
71424
  //#region src/runtime.ts
71434
71425
  const T3AuthTransportLayer = T3AuthTransportLive.pipe(provide$2(layerUndici));
71435
- const T3LocalAuthLayer = T3LocalAuthLive.pipe(provide$2(mergeAll$1(T3ConfigLive, NodeSqlClientFactoryLive)));
71436
- const T3AuthPairingLayer = T3AuthPairingLive.pipe(provide$2(mergeAll$1(T3ConfigLive, T3AuthTransportLayer)));
71426
+ const T3LocalAuthLayer = T3LocalAuthLive.pipe(provide$2(NodeSqlClientFactoryLive));
71427
+ const T3AuthPairingLayer = T3AuthPairingLive.pipe(provide$2(T3AuthTransportLayer));
71437
71428
  const T3AuthLayer = T3AuthLive.pipe(provide$2(mergeAll$1(T3ConfigLive, T3AuthTransportLayer, T3LocalAuthLayer, T3AuthPairingLayer)));
71438
71429
  const T3RpcLayer = T3RpcLive.pipe(provide$2(mergeAll$1(T3ConfigLive, T3AuthLayer, layerWebSocketConstructor)));
71439
71430
  const T3OrchestrationLayer = T3OrchestrationLive.pipe(provide$2(T3RpcLayer));
@@ -71441,4 +71432,4 @@ const T3ApplicationLayer = T3ApplicationLive.pipe(provide$2(T3OrchestrationLayer
71441
71432
  const AuthAppLayer = mergeAll$1(T3ConfigLive, T3AuthLayer);
71442
71433
  const AppLayer = mergeAll$1(T3ConfigLive, T3AuthLayer, T3RpcLayer, T3OrchestrationLayer, T3ApplicationLayer);
71443
71434
  //#endregion
71444
- export { runLast as $, isNullish as $n, sync as $t, Crypto as A, Service$1 as An, flatMap$2 as At, WatchBackend as B, isSome as Bn, map$3 as Bt, decodeUnknownEffect as C, succeed$4 as Cn, asVoid as Ct, optionalKey as D, fail$6 as Dn, catch_$1 as Dt, optional as E, map$5 as En, catchTags$1 as Et, TypeId$29 as F, fromNullishOr as Fn, gen as Ft, fromIterable$1 as G, Prototype as Gn, provideContext$2 as Gt, callback as H, match$3 as Hn, matchEffect as Ht, FileDescriptor as I, fromUndefinedOr as In, ignore$1 as It, mkString as J, BaseProto as Jn, runFork as Jt, isStream as K, PipeInspectableProto as Kn, provideService$1 as Kt, FileSystem as L, getOrElse$1 as Ln, interrupt$1 as Lt, fromReadable as M, getUnsafe$2 as Mn, fnUntraced as Mt, fromWritable as N, make$40 as Nn, forEach$1 as Nt, tag as O, succeed$6 as On, effectify as Ot, Path as P, flatMap$4 as Pn, forkScoped as Pt, runFold as Q, isNotUndefined as Qn, suspend$3 as Qt, FileTypeId as R, getOrUndefined as Rn, isEffect as Rt, decodeTo as S, isSuccess as Sn, as as St, is as T, sync$2 as Tn, catchFilter$2 as Tt, decodeText as U, none as Un, orDie as Ut, make$24 as V, map$7 as Vn, mapError$2 as Vt, empty$6 as W, some as Wn, provide as Wt, runCollect as X, hasProperty as Xn, serviceOption as Xt, run$1 as Y, format$1 as Yn, scoped$2 as Yt, runDrain as Z, isNotNull as Zn, succeed$2 as Zt, Literals as _, MinimumLogLevel as _n, nominal as _t, latestAssistantMessage as a, uninterruptible as an, pipeArguments as ar, get$2 as at, TaggedErrorClass as b, isDone$1 as bn, addFinalizer as bt, Environment as c, fail$3 as cn, __toESM as cr, isSink as ct, ArraySchema as d, effect as dn, make$27 as dt, tapCause as en, isUndefined as er, splitLines as et, Boolean$1 as f, mergeAll$1 as fn, offer as ft, Literal as g, sync$1 as gn, systemError as gt, Int as h, succeed$3 as hn, badArgument as ht, ThreadSessionError as i, try_ as in, pipe as ir, unwrap as it, make$23 as j, empty$11 as jn, fn as jt, toCodecStringTree as k, Reference as kn, fail$2 as kt, T3Config as l, hasInterruptsOnly as ln, endUnsafe as lt, ErrorClass as m, provideMerge as mn, BadArgument as mt, AuthAppLayer as n, timeoutOrElse as nn, dual as nr, tap as nt, threadStatus as o, void_$1 as on, __commonJSMin as or, make$25 as ot, Defect as p, provide$2 as pn, offerUnsafe as pt, merge$1 as q, withFiber$1 as qn, result as qt, NodeEnvironmentLive as r, tryPromise as rn, identity as rr, transduce as rt, T3Application as s, TaggedError as sn, __require as sr, drain as st, AppLayer as t, tapError$2 as tn, constVoid as tr, succeed as tt, T3Auth as u, squash as un, failCauseUnsafe as ut, String$1 as v, _await as vn, transform as vt, fromJsonString as w, ConsoleRef as wn, callback$1 as wt, Union as x, makeUnsafe$8 as xn, andThen as xt, Struct as y, doneUnsafe as yn, acquireRelease as yt, Size as z, isNone as zn, logError as zt };
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 };
@@ -772,5 +772,5 @@ export declare const makeT3Application: () => Effect.Effect<{
772
772
  readonly output: string | null;
773
773
  };
774
774
  }[], import("../rpc/error.ts").RpcError, never>;
775
- }, never, import("../environment/service.ts").Environment | import("effect/Path").Path | import("effect/Crypto").Crypto | import("../orchestration/service.ts").T3Orchestration>;
776
- export declare const T3ApplicationLive: Layer.Layer<T3Application, never, import("../environment/service.ts").Environment | import("effect/Path").Path | import("effect/Crypto").Crypto | import("../orchestration/service.ts").T3Orchestration>;
775
+ }, never, import("../index.ts").Environment | import("effect/Path").Path | import("effect/Crypto").Crypto | import("../orchestration/service.ts").T3Orchestration>;
776
+ export declare const T3ApplicationLive: Layer.Layer<T3Application, never, import("../index.ts").Environment | import("effect/Path").Path | import("effect/Crypto").Crypto | import("../orchestration/service.ts").T3Orchestration>;
@@ -6,9 +6,11 @@ import { T3LocalAuth } from "./local.ts";
6
6
  import { T3AuthPairing } from "./pairing.ts";
7
7
  import { T3Auth } from "./service.ts";
8
8
  import { T3AuthTransport } from "./transport.ts";
9
+ import type { AuthConfigInput } from "./type.ts";
9
10
  export declare const makeT3Auth: () => Effect.Effect<{
10
- pair: (pairingUrl: string) => Effect.Effect<import("./type.ts").PairResult, AuthConfigError | import("./error.ts").AuthPairingUrlError | import("./error.ts").AuthTransportError>;
11
- local: (input: import("./type.ts").LocalAuthInput) => Effect.Effect<import("./type.ts").LocalAuthResult, AuthConfigError | import("./error.ts").AuthLocalError>;
11
+ pair: (pairingUrl: string) => Effect.Effect<import("./type.ts").PairResult, import("./error.ts").AuthPairingUrlError | import("./error.ts").AuthTransportError>;
12
+ local: (input: import("./type.ts").LocalAuthInput) => Effect.Effect<import("./type.ts").LocalAuthResult, import("./error.ts").AuthLocalError>;
13
+ writeConfig: (input: AuthConfigInput) => Effect.Effect<void, AuthConfigError, never>;
12
14
  status: () => Effect.Effect<{
13
15
  readonly authenticated: boolean;
14
16
  readonly role?: "client" | "owner";
@@ -4,24 +4,24 @@ import * as Effect from "effect/Effect";
4
4
  import * as FileSystem from "effect/FileSystem";
5
5
  import * as Layer from "effect/Layer";
6
6
  import * as Path from "effect/Path";
7
- import { T3Config } from "../config/service.ts";
8
7
  import { Environment } from "../environment/service.ts";
9
8
  import { SqlClientFactory } from "../sql/service.ts";
10
- import { AuthConfigError, AuthLocalError } from "./error.ts";
9
+ import { AuthLocalError } from "./error.ts";
11
10
  import type { LocalAuthInput, LocalAuthResult } from "./type.ts";
12
11
  declare const T3LocalAuth_base: Context.ServiceClass<T3LocalAuth, "t3cli/T3LocalAuth", {
13
- readonly local: (input: LocalAuthInput) => Effect.Effect<LocalAuthResult, AuthConfigError | AuthLocalError>;
12
+ readonly local: (input: LocalAuthInput) => Effect.Effect<LocalAuthResult, AuthLocalError>;
14
13
  }>;
15
14
  export declare class T3LocalAuth extends T3LocalAuth_base {
16
15
  }
17
16
  export declare const makeT3LocalAuth: () => Effect.Effect<{
18
17
  local: (input: LocalAuthInput) => Effect.Effect<{
19
18
  url: string;
19
+ token: string;
20
20
  role: "client" | "owner";
21
21
  expiresAt: string;
22
22
  source: "local";
23
23
  baseDir: string;
24
- }, AuthConfigError | AuthLocalError, never>;
25
- }, never, Environment | T3Config | SqlClientFactory | Path.Path | FileSystem.FileSystem | Crypto.Crypto>;
26
- export declare const T3LocalAuthLive: Layer.Layer<T3LocalAuth, never, Environment | T3Config | SqlClientFactory | Path.Path | FileSystem.FileSystem | Crypto.Crypto>;
24
+ }, 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>;
27
27
  export {};
@@ -1,22 +1,22 @@
1
1
  import * as Context from "effect/Context";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
- import { T3Config } from "../config/service.ts";
5
- import { AuthConfigError, AuthPairingUrlError, AuthTransportError } from "./error.ts";
4
+ import { AuthPairingUrlError, AuthTransportError } from "./error.ts";
6
5
  import { T3AuthTransport } from "./transport.ts";
7
6
  import type { PairingUrl, PairResult } from "./type.ts";
8
7
  declare const T3AuthPairing_base: Context.ServiceClass<T3AuthPairing, "t3cli/T3AuthPairing", {
9
- readonly pair: (pairingUrl: string) => Effect.Effect<PairResult, AuthConfigError | AuthPairingUrlError | AuthTransportError>;
8
+ readonly pair: (pairingUrl: string) => Effect.Effect<PairResult, AuthPairingUrlError | AuthTransportError>;
10
9
  }>;
11
10
  export declare class T3AuthPairing extends T3AuthPairing_base {
12
11
  }
13
12
  export declare const makeT3AuthPairing: () => Effect.Effect<{
14
13
  pair: (pairingUrl: string) => Effect.Effect<{
15
14
  url: string;
15
+ token: string;
16
16
  role: "client" | "owner";
17
17
  expiresAt: string;
18
- }, AuthPairingUrlError | AuthConfigError | AuthTransportError, never>;
19
- }, never, T3Config | T3AuthTransport>;
20
- export declare const T3AuthPairingLive: Layer.Layer<T3AuthPairing, never, T3Config | T3AuthTransport>;
18
+ }, AuthPairingUrlError | AuthTransportError, never>;
19
+ }, never, T3AuthTransport>;
20
+ export declare const T3AuthPairingLive: Layer.Layer<T3AuthPairing, never, T3AuthTransport>;
21
21
  export declare function parsePairingUrl(value: string): Effect.Effect<PairingUrl, AuthPairingUrlError>;
22
22
  export {};
@@ -2,10 +2,11 @@ import * as Context from "effect/Context";
2
2
  import type * as Effect from "effect/Effect";
3
3
  import type { AuthSessionState, AuthWebSocketTicketResult } from "./schema.ts";
4
4
  import type { AuthError } from "./error.ts";
5
- import type { LocalAuthInput, LocalAuthResult, PairResult } from "./type.ts";
5
+ import type { AuthConfigInput, LocalAuthInput, LocalAuthResult, PairResult } from "./type.ts";
6
6
  declare const T3Auth_base: Context.ServiceClass<T3Auth, "t3cli/T3Auth", {
7
7
  readonly pair: (value: string) => Effect.Effect<PairResult, AuthError>;
8
8
  readonly local: (input: LocalAuthInput) => Effect.Effect<LocalAuthResult, AuthError>;
9
+ readonly writeConfig: (input: AuthConfigInput) => Effect.Effect<void, AuthError>;
9
10
  readonly status: () => Effect.Effect<AuthSessionState, AuthError>;
10
11
  readonly issueWebSocketTicket: () => Effect.Effect<AuthWebSocketTicketResult, AuthError>;
11
12
  }>;
@@ -4,8 +4,13 @@ export type PairingUrl = {
4
4
  readonly baseUrl: string;
5
5
  readonly credential: string;
6
6
  };
7
+ export type AuthConfigInput = {
8
+ readonly url: string;
9
+ readonly token: string;
10
+ };
7
11
  export type PairResult = {
8
12
  readonly url: string;
13
+ readonly token: string;
9
14
  readonly role: AuthBearerBootstrapResult["role"];
10
15
  readonly expiresAt: string;
11
16
  };
@@ -18,6 +23,7 @@ export type LocalAuthInput = {
18
23
  };
19
24
  export type LocalAuthResult = {
20
25
  readonly url: string;
26
+ readonly token: string;
21
27
  readonly role: AuthSessionRole;
22
28
  readonly expiresAt: string;
23
29
  readonly source: "local";
@@ -1,6 +1,24 @@
1
1
  export { T3Application } from "./application/service.ts";
2
2
  export type { SendThreadInput, StartThreadInput, StartThreadPolicy, WaitEvent, } from "./application/service.ts";
3
3
  export type { ApplicationError } from "./application/error.ts";
4
+ export { T3Auth } from "./auth/service.ts";
5
+ export { T3AuthLive, makeT3Auth } from "./auth/layer.ts";
6
+ export { T3LocalAuth, T3LocalAuthLive, makeT3LocalAuth } from "./auth/local.ts";
7
+ export { T3AuthPairing, T3AuthPairingLive, makeT3AuthPairing, parsePairingUrl, } from "./auth/pairing.ts";
8
+ export { AuthConfigError, AuthLocalDatabaseError, AuthLocalError, AuthLocalSecretError, AuthLocalSigningError, AuthPairingUrlError, AuthTransportError, } from "./auth/error.ts";
9
+ export type { AuthError } from "./auth/error.ts";
10
+ export type { AuthSessionState, AuthWebSocketTicketResult } from "./auth/schema.ts";
11
+ export type { AuthConfigInput, AuthSessionRole, LocalAuthInput, LocalAuthResult, PairingUrl, PairResult, } from "./auth/type.ts";
12
+ export { T3Config } from "./config/service.ts";
13
+ export type { ResolvedConfig, StoredConfig } from "./config/service.ts";
14
+ export { T3ConfigLive, makeT3Config } from "./config/layer.ts";
15
+ export { ConfigError, UrlError } from "./config/error.ts";
16
+ export type { ConfigServiceError } from "./config/error.ts";
17
+ export { Environment } from "./environment/service.ts";
18
+ export type { EnvironmentShape } from "./environment/service.ts";
4
19
  export { NodeEnvironmentLive } from "./environment/layer.ts";
5
- export { AppLayer, AuthAppLayer } from "./runtime.ts";
20
+ export { AppLayer, AuthAppLayer, T3AuthLayer, T3AuthPairingLayer, T3AuthTransportLayer, T3LocalAuthLayer, } from "./runtime.ts";
21
+ export { SqlClientFactory } from "./sql/service.ts";
22
+ export type { SqlClientFactoryShape, SqliteClientConfig } from "./sql/service.ts";
23
+ export { NodeSqlClientFactoryLive, NodeSqliteClientLive, makeNodeSqliteClient, } from "./sql/node-sqlite-client.ts";
6
24
  export type { OrchestrationMessage, OrchestrationProjectShell, OrchestrationShellSnapshot, OrchestrationThread, OrchestrationThreadShell, ServerProvider, } from "#t3tools/contracts";
@@ -4674,5 +4674,5 @@ export declare const makeT3RpcLayer: () => Effect.Effect<{
4674
4674
  }[];
4675
4675
  }, import("effect/unstable/rpc/RpcClientError").RpcClientError | (Discard extends true ? never : import("#t3tools/contracts").EnvironmentAuthorizationError | import("#t3tools/contracts").KeybindingsConfigError | import("#t3tools/contracts").ServerSettingsError), never>;
4676
4676
  }, RpcError, never>;
4677
- }, never, T3Config | Scope.Scope | T3Auth>;
4678
- export declare const T3RpcLive: Layer.Layer<T3Rpc, never, T3Config | T3Auth>;
4677
+ }, never, T3Auth | T3Config | Scope.Scope>;
4678
+ export declare const T3RpcLive: Layer.Layer<T3Rpc, never, T3Auth | T3Config>;
@@ -1,3 +1,7 @@
1
1
  import * as Layer from "effect/Layer";
2
- export declare const AuthAppLayer: Layer.Layer<import("./config/service.ts").T3Config | import("./auth/service.ts").T3Auth, never, import("./environment/service.ts").Environment | import("effect/Path").Path | import("effect/FileSystem").FileSystem | import("effect/Crypto").Crypto>;
3
- export declare const AppLayer: Layer.Layer<import("./index.ts").T3Application | import("./config/service.ts").T3Config | import("./auth/service.ts").T3Auth | import("./orchestration/service.ts").T3Orchestration | import("./rpc/service.ts").T3Rpc, never, import("./environment/service.ts").Environment | import("effect/Path").Path | import("effect/FileSystem").FileSystem | import("effect/Crypto").Crypto>;
2
+ export declare const T3AuthTransportLayer: Layer.Layer<import("./auth/transport.ts").T3AuthTransport, never, never>;
3
+ export declare const T3LocalAuthLayer: Layer.Layer<import("./auth/local.ts").T3LocalAuth, never, import("./index.ts").Environment | import("effect/Path").Path | import("effect/FileSystem").FileSystem | import("effect/Crypto").Crypto>;
4
+ export declare const T3AuthPairingLayer: Layer.Layer<import("./auth/pairing.ts").T3AuthPairing, never, never>;
5
+ export declare const T3AuthLayer: Layer.Layer<import("./index.ts").T3Auth, never, import("./index.ts").Environment | import("effect/Path").Path | import("effect/FileSystem").FileSystem | import("effect/Crypto").Crypto>;
6
+ export declare const AuthAppLayer: Layer.Layer<import("./index.ts").T3Auth | import("./index.ts").T3Config, never, import("./index.ts").Environment | import("effect/Path").Path | import("effect/FileSystem").FileSystem | import("effect/Crypto").Crypto>;
7
+ export declare const AppLayer: Layer.Layer<import("./index.ts").T3Application | import("./index.ts").T3Auth | import("./index.ts").T3Config | import("./orchestration/service.ts").T3Orchestration | import("./rpc/service.ts").T3Rpc, never, import("./index.ts").Environment | import("effect/Path").Path | import("effect/FileSystem").FileSystem | import("effect/Crypto").Crypto>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t3code-cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "CLI for t3code",
5
5
  "keywords": [
6
6
  "claude",
package/src/auth/layer.ts CHANGED
@@ -7,6 +7,7 @@ import { T3LocalAuth } from "./local.ts";
7
7
  import { T3AuthPairing } from "./pairing.ts";
8
8
  import { T3Auth } from "./service.ts";
9
9
  import { T3AuthTransport } from "./transport.ts";
10
+ import type { AuthConfigInput } from "./type.ts";
10
11
 
11
12
  export const makeT3Auth = Effect.fn("makeT3Auth")(function* () {
12
13
  const config = yield* T3Config;
@@ -38,9 +39,25 @@ export const makeT3Auth = Effect.fn("makeT3Auth")(function* () {
38
39
  return yield* transport.issueWebSocketTicket(resolved);
39
40
  });
40
41
 
42
+ const writeConfig = Effect.fn("T3AuthLive.writeConfig")(function* (input: AuthConfigInput) {
43
+ const existing = yield* config.readStored().pipe(
44
+ Effect.catchTags({
45
+ ConfigError: (error) =>
46
+ Effect.fail(new AuthConfigError({ message: "auth config failed", cause: error })),
47
+ }),
48
+ );
49
+ yield* config.writeStored({ ...existing, url: input.url, token: input.token }).pipe(
50
+ Effect.catchTags({
51
+ ConfigError: (error) =>
52
+ Effect.fail(new AuthConfigError({ message: "auth config failed", cause: error })),
53
+ }),
54
+ );
55
+ });
56
+
41
57
  return {
42
58
  pair: pairing.pair,
43
59
  local: localAuth.local,
60
+ writeConfig,
44
61
  status,
45
62
  issueWebSocketTicket,
46
63
  };
package/src/auth/local.ts CHANGED
@@ -15,12 +15,10 @@ import * as Path from "effect/Path";
15
15
  import * as Predicate from "effect/Predicate";
16
16
  import * as SqlClient from "effect/unstable/sql/SqlClient";
17
17
 
18
- import { T3Config } from "../config/service.ts";
19
18
  import { normalizeHttpBaseUrl } from "../config/url.ts";
20
19
  import { Environment } from "../environment/service.ts";
21
20
  import { SqlClientFactory } from "../sql/service.ts";
22
21
  import {
23
- AuthConfigError,
24
22
  AuthLocalDatabaseError,
25
23
  AuthLocalError,
26
24
  AuthLocalSecretError,
@@ -32,14 +30,11 @@ import type { LocalAuthInput, LocalAuthResult } from "./type.ts";
32
30
  export class T3LocalAuth extends Context.Service<
33
31
  T3LocalAuth,
34
32
  {
35
- readonly local: (
36
- input: LocalAuthInput,
37
- ) => Effect.Effect<LocalAuthResult, AuthConfigError | AuthLocalError>;
33
+ readonly local: (input: LocalAuthInput) => Effect.Effect<LocalAuthResult, AuthLocalError>;
38
34
  }
39
35
  >()("t3cli/T3LocalAuth") {}
40
36
 
41
37
  export const makeT3LocalAuth = Effect.fn("makeT3LocalAuth")(function* () {
42
- const config = yield* T3Config;
43
38
  const fs = yield* FileSystem.FileSystem;
44
39
  const path = yield* Path.Path;
45
40
  const environment = yield* Environment;
@@ -218,23 +213,6 @@ export const makeT3LocalAuth = Effect.fn("makeT3LocalAuth")(function* () {
218
213
  };
219
214
  });
220
215
 
221
- function writeLocalConfig(input: { readonly url: string; readonly token: string }) {
222
- return Effect.gen(function* () {
223
- const existing = yield* config.readStored().pipe(
224
- Effect.catchTags({
225
- ConfigError: (error) =>
226
- Effect.fail(new AuthConfigError({ message: "auth config failed", cause: error })),
227
- }),
228
- );
229
- yield* config.writeStored({ ...existing, url: input.url, token: input.token }).pipe(
230
- Effect.catchTags({
231
- ConfigError: (error) =>
232
- Effect.fail(new AuthConfigError({ message: "auth config failed", cause: error })),
233
- }),
234
- );
235
- });
236
- }
237
-
238
216
  const local = Effect.fn("T3LocalAuthLive.local")(function* (input: LocalAuthInput) {
239
217
  if (input.label.length === 0) {
240
218
  return yield* Effect.fail(
@@ -264,9 +242,9 @@ export const makeT3LocalAuth = Effect.fn("makeT3LocalAuth")(function* () {
264
242
  baseDir,
265
243
  ...(input.origin !== undefined ? { origin: input.origin } : {}),
266
244
  });
267
- yield* writeLocalConfig({ url, token: session.token });
268
245
  return {
269
246
  url,
247
+ token: session.token,
270
248
  role: session.role,
271
249
  expiresAt: session.expiresAt,
272
250
  source: "local" as const,
@@ -3,8 +3,7 @@ import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
4
  import { Url } from "effect/unstable/http";
5
5
 
6
- import { T3Config } from "../config/service.ts";
7
- import { AuthConfigError, AuthPairingUrlError, AuthTransportError } from "./error.ts";
6
+ import { AuthPairingUrlError, AuthTransportError } from "./error.ts";
8
7
  import { T3AuthTransport } from "./transport.ts";
9
8
  import type { PairingUrl, PairResult } from "./type.ts";
10
9
 
@@ -13,32 +12,22 @@ export class T3AuthPairing extends Context.Service<
13
12
  {
14
13
  readonly pair: (
15
14
  pairingUrl: string,
16
- ) => Effect.Effect<PairResult, AuthConfigError | AuthPairingUrlError | AuthTransportError>;
15
+ ) => Effect.Effect<PairResult, AuthPairingUrlError | AuthTransportError>;
17
16
  }
18
17
  >()("t3cli/T3AuthPairing") {}
19
18
 
20
19
  export const makeT3AuthPairing = Effect.fn("makeT3AuthPairing")(function* () {
21
- const config = yield* T3Config;
22
20
  const transport = yield* T3AuthTransport;
23
21
 
24
22
  const pair = Effect.fn("T3AuthPairingLive.pair")(function* (pairingUrl: string) {
25
23
  const parsed = yield* parsePairingUrl(pairingUrl);
26
24
  const result = yield* transport.bootstrapBearer(parsed);
27
- const existing = yield* config.readStored().pipe(
28
- Effect.catchTags({
29
- ConfigError: (error) =>
30
- Effect.fail(new AuthConfigError({ message: "auth config failed", cause: error })),
31
- }),
32
- );
33
- yield* config
34
- .writeStored({ ...existing, url: parsed.baseUrl, token: result.sessionToken })
35
- .pipe(
36
- Effect.catchTags({
37
- ConfigError: (error) =>
38
- Effect.fail(new AuthConfigError({ message: "auth config failed", cause: error })),
39
- }),
40
- );
41
- return { url: parsed.baseUrl, role: result.role, expiresAt: result.expiresAt };
25
+ return {
26
+ url: parsed.baseUrl,
27
+ token: result.sessionToken,
28
+ role: result.role,
29
+ expiresAt: result.expiresAt,
30
+ };
42
31
  });
43
32
 
44
33
  return { pair };
@@ -3,13 +3,14 @@ import type * as Effect from "effect/Effect";
3
3
 
4
4
  import type { AuthSessionState, AuthWebSocketTicketResult } from "./schema.ts";
5
5
  import type { AuthError } from "./error.ts";
6
- import type { LocalAuthInput, LocalAuthResult, PairResult } from "./type.ts";
6
+ import type { AuthConfigInput, LocalAuthInput, LocalAuthResult, PairResult } from "./type.ts";
7
7
 
8
8
  export class T3Auth extends Context.Service<
9
9
  T3Auth,
10
10
  {
11
11
  readonly pair: (value: string) => Effect.Effect<PairResult, AuthError>;
12
12
  readonly local: (input: LocalAuthInput) => Effect.Effect<LocalAuthResult, AuthError>;
13
+ readonly writeConfig: (input: AuthConfigInput) => Effect.Effect<void, AuthError>;
13
14
  readonly status: () => Effect.Effect<AuthSessionState, AuthError>;
14
15
  readonly issueWebSocketTicket: () => Effect.Effect<AuthWebSocketTicketResult, AuthError>;
15
16
  }
package/src/auth/type.ts CHANGED
@@ -7,8 +7,14 @@ export type PairingUrl = {
7
7
  readonly credential: string;
8
8
  };
9
9
 
10
+ export type AuthConfigInput = {
11
+ readonly url: string;
12
+ readonly token: string;
13
+ };
14
+
10
15
  export type PairResult = {
11
16
  readonly url: string;
17
+ readonly token: string;
12
18
  readonly role: AuthBearerBootstrapResult["role"];
13
19
  readonly expiresAt: string;
14
20
  };
@@ -23,6 +29,7 @@ export type LocalAuthInput = {
23
29
 
24
30
  export type LocalAuthResult = {
25
31
  readonly url: string;
32
+ readonly token: string;
26
33
  readonly role: AuthSessionRole;
27
34
  readonly expiresAt: string;
28
35
  readonly source: "local";
package/src/cli/auth.ts CHANGED
@@ -35,6 +35,7 @@ const pairCommand = Command.make(
35
35
  const output = yield* T3Output;
36
36
  const resolvedFormat = resolveOutputFormat(format, environment, "json");
37
37
  const result = yield* auth.pair(url);
38
+ yield* auth.writeConfig(result);
38
39
  if (resolvedFormat === "json") {
39
40
  yield* output.printJson(result);
40
41
  } else {
@@ -66,6 +67,7 @@ const localCommand = Command.make(
66
67
  ...(Option.isSome(baseDir) ? { baseDir: baseDir.value } : {}),
67
68
  ...(Option.isSome(origin) ? { origin: origin.value } : {}),
68
69
  });
70
+ yield* auth.writeConfig(result);
69
71
  if (resolvedFormat === "json") {
70
72
  yield* output.printJson(formatAuthLocalJson(result));
71
73
  } else {
package/src/index.ts CHANGED
@@ -6,8 +6,57 @@ export type {
6
6
  WaitEvent,
7
7
  } from "./application/service.ts";
8
8
  export type { ApplicationError } from "./application/error.ts";
9
+ export { T3Auth } from "./auth/service.ts";
10
+ export { T3AuthLive, makeT3Auth } from "./auth/layer.ts";
11
+ export { T3LocalAuth, T3LocalAuthLive, makeT3LocalAuth } from "./auth/local.ts";
12
+ export {
13
+ T3AuthPairing,
14
+ T3AuthPairingLive,
15
+ makeT3AuthPairing,
16
+ parsePairingUrl,
17
+ } from "./auth/pairing.ts";
18
+ export {
19
+ AuthConfigError,
20
+ AuthLocalDatabaseError,
21
+ AuthLocalError,
22
+ AuthLocalSecretError,
23
+ AuthLocalSigningError,
24
+ AuthPairingUrlError,
25
+ AuthTransportError,
26
+ } from "./auth/error.ts";
27
+ export type { AuthError } from "./auth/error.ts";
28
+ export type { AuthSessionState, AuthWebSocketTicketResult } from "./auth/schema.ts";
29
+ export type {
30
+ AuthConfigInput,
31
+ AuthSessionRole,
32
+ LocalAuthInput,
33
+ LocalAuthResult,
34
+ PairingUrl,
35
+ PairResult,
36
+ } from "./auth/type.ts";
37
+ export { T3Config } from "./config/service.ts";
38
+ export type { ResolvedConfig, StoredConfig } from "./config/service.ts";
39
+ export { T3ConfigLive, makeT3Config } from "./config/layer.ts";
40
+ export { ConfigError, UrlError } from "./config/error.ts";
41
+ export type { ConfigServiceError } from "./config/error.ts";
42
+ export { Environment } from "./environment/service.ts";
43
+ export type { EnvironmentShape } from "./environment/service.ts";
9
44
  export { NodeEnvironmentLive } from "./environment/layer.ts";
10
- export { AppLayer, AuthAppLayer } from "./runtime.ts";
45
+ export {
46
+ AppLayer,
47
+ AuthAppLayer,
48
+ T3AuthLayer,
49
+ T3AuthPairingLayer,
50
+ T3AuthTransportLayer,
51
+ T3LocalAuthLayer,
52
+ } from "./runtime.ts";
53
+ export { SqlClientFactory } from "./sql/service.ts";
54
+ export type { SqlClientFactoryShape, SqliteClientConfig } from "./sql/service.ts";
55
+ export {
56
+ NodeSqlClientFactoryLive,
57
+ NodeSqliteClientLive,
58
+ makeNodeSqliteClient,
59
+ } from "./sql/node-sqlite-client.ts";
11
60
  export type {
12
61
  OrchestrationMessage,
13
62
  OrchestrationProjectShell,
package/src/runtime.ts CHANGED
@@ -12,14 +12,12 @@ import { T3OrchestrationLive } from "./orchestration/layer.ts";
12
12
  import { T3RpcLive } from "./rpc/layer.ts";
13
13
  import { NodeSqlClientFactoryLive } from "./sql/node-sqlite-client.ts";
14
14
 
15
- const T3AuthTransportLayer = T3AuthTransportLive.pipe(Layer.provide(NodeHttpClient.layerUndici));
16
- const T3LocalAuthLayer = T3LocalAuthLive.pipe(
17
- Layer.provide(Layer.mergeAll(T3ConfigLive, NodeSqlClientFactoryLive)),
15
+ export const T3AuthTransportLayer = T3AuthTransportLive.pipe(
16
+ Layer.provide(NodeHttpClient.layerUndici),
18
17
  );
19
- const T3AuthPairingLayer = T3AuthPairingLive.pipe(
20
- Layer.provide(Layer.mergeAll(T3ConfigLive, T3AuthTransportLayer)),
21
- );
22
- const T3AuthLayer = T3AuthLive.pipe(
18
+ export const T3LocalAuthLayer = T3LocalAuthLive.pipe(Layer.provide(NodeSqlClientFactoryLive));
19
+ export const T3AuthPairingLayer = T3AuthPairingLive.pipe(Layer.provide(T3AuthTransportLayer));
20
+ export const T3AuthLayer = T3AuthLive.pipe(
23
21
  Layer.provide(
24
22
  Layer.mergeAll(T3ConfigLive, T3AuthTransportLayer, T3LocalAuthLayer, T3AuthPairingLayer),
25
23
  ),