alink-cli 0.12.1 → 0.12.2

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.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { $ as make$66, A as withLoggerDisabled, At as matchStatus, B as limitsServices, Bt as post$1, C as update$2, Ct as setHeader, D as compression, Dt as uint8Array$1, Et as text$2, F as schemaHeaders, Ft as appendUrlParams, G as CloseEvent, Gt as setUrl, Ht as setBody, I as schemaSearchParams, It as bodyFormData, Jt as HttpClientErrorSchema, K as SocketError, Kt as DecodeError, L as toURL, Lt as bodyJson, M as ParsedSearchParams, O as cors$1, Ot as urlParams$1, P as schemaCookies, Pt as schemaBodyJson, Q as join$1, Rt as get$4, S as set$2, Sn as __commonJSMin, T as appendPreResponseHandler, Tt as stream, Ut as setHeader$1, Vt as prependUrl, Wt as setHeaders, X as makeWebSocket, Xt as isHttpClientError, Y as make$67, Yt as StatusCodeError, Z as awaitEmpty, Zt as empty$2, _ as get$3, _n as fromInput, _t as mergeCookies, a as layer$44, an as CurrentRedactedNames, b as makeUnsafe$3, bn as hasBody, cn as fromRecordUnsafe, d as HttpClient, dn as jsonUnsafe$1, en as set$3, et as run$4, f as TracerPropagationEnabled, g as transformResponse$1, gn as urlParams, gt as jsonUnsafe, h as retryTransient, hn as uint8Array, ht as isHttpServerResponse, j as HttpServerRequest, k as logger, kt as filterStatusOk, l as serve$1, ln as merge, lt as symbol$1, m as mapRequest, mn as text$1, mt as file, o as HttpServer, on as empty$3, ot as RouteNotFound, p as filterStatusOk$1, pt as empty$1, q as SocketErrorReason, qt as HttpClientError, r as Mime_default, rt as HttpServerError, sn as fromInput$1, t as layerWebSocketConstructor, tt as runtime, u as withLogAddress, un as isHttpBody, ut as toResponse, v as getAndSet, vn as schemaRecord, w as updateAndGet, wn as __require, wt as setHeaders$1, x as modify$2, xn as map$3, xt as schemaJson, y as make$64, yn as toRecord, yt as redirect, zt as make$65 } from "./NodeSocket-CLfrrutd.mjs";
4
- import { $ as decodeUnknownExit, $a as flatMap$1, $d as hasProperty, $l as format$1, $o as scopedWith, $s as TaggedError, $t as Union$1, $u as add$2, A as StructWithRest, Aa as asVoid, Ac as _await, Ai as make$76, An as encodeBase64, Ao as matchEffect, Ar as mapEffect$1, As as withSpan, At as suspend$1, B as Union, Ba as catchTags, Bc as succeed$4, Bi as offerUnsafe, Bn as now$1, Bo as provide$1, Br as provideService$1, Bs as forever$1, Bt as value, C as Number$1, Ca as andThen, Cc as forkUnsafe, Cd as map$6, Cl as CurrentLoggers$1, Cn as parseJson, Co as map$4, Cs as useSpan, Ct as isTrimmed, Cu as flatMapNullishOr, D as String$1, Da as annotateSpans, Dc as MinimumLogLevel, Dd as Number$2, Di as pipeTo, Dn as decodeBase64String, Do as match$2, Dr as make$75, Ds as withFiber$1, Dt as mutable, E as Record, Ea as annotateLogsScoped, Ec as provide$2, Ed as some, Ei as mapEffect$2, Er as isStream, Es as withErrorReporting, Et as makeFilter, Eu as isReadonlyArrayNonEmpty, Fi as failCause$3, Fl as reportCauseUnsafe, Fn as isGreaterThan$1, Fo as onInterrupt, Fr as onExit$1, Fs as snapshotUnsafe, Ft as toJsonSchemaDocument, G as annotateKey, Ga as currentParentSpan, Gc as isFailure, Gi as takeAll, Gl as ParentSpan, Gn as InvalidValue$1, Go as result, Gr as runFoldEffect, Gs as isDoneCause, Gt as toJsonSchemaMultiDocument, Gu as getOrUndefined$2, H as UnknownFromJsonString$1, Hc as fail$4, Hd as toJson, Hi as shutdown$1, Hn as toEpochMillis, Ho as provideService, Hr as runCollect, Hs as passthrough, Ht as toMultiDocumentOpenApi3_1, Hu as fail$1, I as URLFromString, Ia as catchFilter, Ic as isDeferred, Id as isEffect$1, In as isGreaterThanOrEqualTo$1, Io as option, Is as timer, It as toType, Iu as map$7, J as decodeEffect, Ja as ensuring, Ji as shutdown$2, Jl as make$78, Jn as Path, Jo as runForkWith, Js as Clock, K as brand, Ka as die, Kc as isSuccess, Kd as equals, Ki as unbounded$2, Kl as Tracer, Ko as retry, Kr as runForEach, Ks as parse$2, Kt as escapeToken, Ku as isFailure$1, L as Uint8Array$1, La as catchIf, Ld as withFiber, Li as make$79, Ln as isLessThan$1, Lo as orDie, Lr as pipeThroughChannel, Ls as update$3, Lt as withConstructorDefault, M as TaggedStruct, Ma as callback, Md as setStackTraceLimit, Mi as bounded, Mn as encodeHex, Mo as onError, Mr as merge$2, Ms as yieldNow, Mt as toCodecJson, Mu as reverse, N as TemplateLiteral, Na as catchCause, Nc as fail$3, Nd as Prototype, Ni as end, Nn as add$3, No as onExit, Ns as zipWith, Nt as toCodecJsonAST, Nu as sort, O as StringFromUriComponent, Oa as as, Oc as TracerEnabled, Od as make$73, On as decodeBase64Url, Oo as matchCauseEffect, Or as map$8, Ot as optional$3, Ou as map$5, Pa as catchDefect, Pc as failCause$2, Pd as PipeInspectableProto, Pn as formatIso, Ps as counter, Pt as toCodecStringTree, Q as decodeUnknownEffect, Qa as filterOrFail, Qc as StackTrace, Qd as compose$1, Ql as days, Qo as scoped, Qr as toAsyncIterable, Qs as TaggedClass, Qt as isSchemaError, Qu as Service$2, R as Undefined, Ra as catchReason, Rc as make$74, Rd as assignProperty, Ri as offer$1, Rl as sync$1, Rn as make$72, Ro as orElseSucceed, Rs as withAttributes, Rt as withDecodingDefault, S as NullOr, Sa as all, Sc as closeUnsafe, Sd as isSome, Si as filterArray, Sl as ConsoleRef, Sn as onSome, So as makeSpanScoped, Sr as fromQueue, Ss as updateContext, St as isSchema, Su as findLast, T as OptionFromNullOr, Ta as annotateLogs, Tc as makeUnsafe$8, Td as none, Tl as consolePretty$1, Tn as stringifyJson, To as mapError, Tr as groupedWithin, Ts as whileLoop, Tt as make$71, Tu as isArrayNonEmpty, U as Void, Ua as context, Uc as failCause$4, Ud as format, Ui as sliding$1, Ul as MinimumTraceLevel, Un as toUtc, Uo as raceFirst, Ur as runDrain, Us as spaced, Ut as apply, Uu as failVoid, V as Unknown, Va as catch_, Vc as die$1, Vd as NodeInspectSymbol, Vn as toDate, Vo as provideContext, Vr as run$5, Vt as VALID_OPEN_API_COMPONENTS_SCHEMAS_KEY_REGEXP, W as annotate$2, Wa as contextWith, Wc as interrupt$3, Wi as take$1, Wl as NativeSpan, Wn as Forbidden$1, Wo as repeat, Wr as runFold, Ws as catchDone, Wt as toRepresentations, Wu as getOrThrow, X as decodeSync, Xa as fail, Xi as subscribe, Xn as FileSystem, Xs as currentTimeNanos, Y as decodeExit, Ya as exit, Yc as void_$2, Yi as sliding, Yo as runPromiseWith, Ys as currentTimeMillis, Yu as succeed$2, Z as decodeTo, Za as failCause$1, Zc as NoSuchElementError, Zi as unbounded$1, Zo as scope, Zr as takeWhile, Zt as SchemaError, Zu as Reference, _c as unwrap, _d as fromUndefinedOr, _f as identity, _i as forEach$1, _l as map$9, _n as Transformation, _o as logDebug, _s as try_, _t as isMaxLength, _u as ensure, a as Class, aa as join$2, ac as effectContext, ad as getUnsafe$1, af as isTagged, al as findErrorOption, an as isLiteral, ao as forever, ar as debounce, as as succeedSome, at as encodeUnknownExit, b as NonEmptyString, ba as acquireUseRelease, bc as addFinalizerExit, bd as getOrUndefined, bi as mapInput, bl as squash, bn as transformOrFail, bo as logInfo, br as fromIterable$1, bs as uninterruptible, bt as isNonEmpty, bu as findFirst, c as Defect, ca as drop$1, cd as merge$1, cf as cast, ci as has, cl as hasInterrupts, cn as isOptional, co as forkScoped, cr as drain, cs as tap, ct as instanceOf, cu as minutes, d as ErrorClass, da as isEmpty$2, dc as provide, dd as exists, df as constTrue, dl as interruptors, dn as isVoid, do as ignore$1, ds as tapError, dt as isFinite, du as toMillis, ea as makeUnsafe$7, ec as taggedEnum, ed as empty$5, ef as isNotNull, el as combine$1, es as service, et as decodeUnknownOption, eu as fromInput$2, f as Exit, fa as size$2, fc as provideMerge, fd as filter, ff as constUndefined, fl as isCause, fn as resolveAt, fo as ignoreCause, fr as fail$5, fs as tapErrorTag, ft as isGreaterThan, g as Literals, gc as tap$1, gd as fromNullishOr, gi as drain$1, go as log$1, gr as fromAsyncIterable, gs as tryPromise, gt as isLessThanOrEqualTo, gu as empty$4, h as Literal, ha as PlatformError, hc as sync$2, hd as flatten, hf as dual, hn as toEncoded, ho as isEffect, hr as flatMap$2, ht as isLessThan, i as Cause, ic as effect, id as getOrUndefined$1, if as isString, ii as withSpan$1, in as isDeclaration, io as forEach, ir as concat, is as succeedNone, it as encodeUnknownEffect, j as TaggedErrorClass, ja as cached, jc as die$2, jd as getStackTraceLimit, ji as makeUnsafe$5, jl as fnUntraced$1, jn as encodeBase64Url, jo as never, jr as mapError$1, js as withTracerEnabled, jt as tag, ju as reduce, k as Struct, ka as asSome, kc as TracerTimingEnabled, ki as splitLines, kn as decodeBase64UrlString, kr as mapArrayEffect, ks as withParentSpan, kt as optionalKey, ku as match, l as Duration, la as empty$6, lc as launch, ld as omit, lf as compose, li as invalidate, ll as hasInterruptsOnly, ln as isSuspend, lo as fromResult, lr as empty$7, ls as tapCause, lt as is, lu as nanos, m as Int, mc as succeedContext, md as flatMap$3, mf as constant, mn as resolveIdentifier, mo as interruptible, mr as filter$2, ms as timeoutOption, mt as isInt, mu as allocate, n as ArraySchema, na as getCurrent, nc as build, nd as getOption, nf as isNullish, ni as transformPull, nn as getAST, no as fn, nr as catchCause$1, ns as sleep, nt as encodeEffect, nu as hours, o as DateTimeUtc, oa as runIn, oc as effectDiscard, od as make$69, on as isNull, oo as forkChild, or as decodeText, os as suspend, ot as fieldsAssign, ou as max, p as Finite, pa as toArray, pc as succeed$3, pd as firstSomeOf, pf as constVoid, pl as isFailReason, pn as resolveDescription, po as interrupt$1, pr as failCause$5, ps as timeout, pt as isGreaterThanOrEqualTo, pu as zero, q as declare, qc as match$3, qi as publish, ql as externalSpan, qn as makeFormatterDefault, qo as runFork, qr as runForEachArray, qs as round, qt as assign, qu as isSuccess$1, r as Boolean$1, ra as interrupt$4, rc as buildWithMemoMap, rd as getOrElse$1, rf as isObject$1, ri as unwrap$1, rl as fail$2, rn as getLastEncoding, ro as fnUntraced, rr as changes, rs as succeed$1, rt as encodeSync, s as DateTimeUtcFromString, sa as append$1, sc as empty$8, sd as makeUnsafe$4, si as get$6, sl as hasDies, sn as isObjects, so as forkIn, ss as sync, st as fromJsonString, su as millis, t as Any, ta as await_, tc as CurrentMemoMap, td as get$5, tf as isNotUndefined, to as flatten$1, tr as callback$1, ts as serviceOption, tt as encode$1, tu as fromInputUnsafe, u as DurationFromMillis, ua as head, uc as mergeAll, ud as contains, uf as constFalse, ui as make$70, ul as interrupt$2, un as isUnion, uo as gen, ur as encodeText, us as tapDefect, ut as isBetween, uu as seconds, v as Never, va as Transaction, vc as Scope, vd as getOrElse, vf as pipe, vl as pretty, vo as logError, vr as fromEffect, vs as tx, vt as isMaxProperties, vu as filter$1, w as Option, wa as annotateCurrentSpan, wc as make$77, wd as match$1, wi as fromTransform, wr as fromSubscription, ws as void_$1, wu as fromIterable, x as Null, xa as addFinalizer, xc as close, xd as isNone, xi as decodeText$1, xn as trim, xo as logWarning$1, xr as fromPubSub, xt as isPattern, xu as findFirstIndex, y as NonEmptyArray, ya as acquireRelease, yc as addFinalizer$1, yd as getOrNull, yf as pipeArguments, yl as prettyErrors, yn as transform$1, yo as logFatal, yr as fromEffectSchedule, ys as txRetry, yt as isMinLength, yu as filterMap, z as UndefinedOr, za as catchTag, zi as offerAll, zl as tracerLogger$1, zn as makeUnsafe$6, zo as promise, zr as provideContext$1, zs as addDelay, zt as make$68 } from "./Schema-B4KtKnpr.mjs";
5
- import { a as isQuitError, g as ChildProcessSpawner, h as make$80, i as Terminal$1, l as Crypto, n as layer$45, o as Stdio, r as QuitError, s as make$81, u as fromReadable } from "./NodeServices-BtcL7AtO.mjs";
6
- import { _ as withDefault$2, a as all$1, c as logLevel, d as option$1, f as port, g as url$1, i as TrueValues, l as map$10, m as string$4, n as FalseValues, o as boolean$3, p as schema$1, r as Record$1, s as int, t as Boolean$2, u as number } from "./Config-CxDW-52j.mjs";
7
- import { c as getOption$1, d as make$82, f as makeWith$1, l as invalidate$1, n as SqlClient, p as set$4, s as get$7, u as keys } from "./SqlClient-BQM_tAo_.mjs";
3
+ import { $ as make$67, A as withLoggerDisabled, At as matchStatus, B as limitsServices, Bt as post$1, C as update$2, Ct as setHeader, D as compression, Dt as uint8Array$1, Et as text$2, F as schemaHeaders, Ft as appendUrlParams, G as CloseEvent, Gt as setUrl, Ht as setBody, I as schemaSearchParams, It as bodyFormData, Jt as HttpClientErrorSchema, K as SocketError, Kt as DecodeError, L as toURL, Lt as bodyJson, M as ParsedSearchParams, O as cors$1, Ot as urlParams$1, P as schemaCookies, Pt as schemaBodyJson, Q as join$1, Rt as get$4, S as set$2, Sn as __commonJSMin, T as appendPreResponseHandler, Tt as stream, Ut as setHeader$1, Vt as prependUrl, Wt as setHeaders, X as makeWebSocket, Xt as isHttpClientError, Y as make$68, Yt as StatusCodeError, Z as awaitEmpty, Zt as empty$2, _ as get$3, _n as fromInput, _t as mergeCookies, a as layer$46, an as CurrentRedactedNames, b as makeUnsafe$3, bn as hasBody, cn as fromRecordUnsafe, d as HttpClient, dn as jsonUnsafe$1, en as set$3, et as run$4, f as TracerPropagationEnabled, g as transformResponse$1, gn as urlParams, gt as jsonUnsafe, h as retryTransient, hn as uint8Array, ht as isHttpServerResponse, j as HttpServerRequest, k as logger, kt as filterStatusOk, l as serve$1, ln as merge, lt as symbol$1, m as mapRequest, mn as text$1, mt as file, o as HttpServer, on as empty$3, ot as RouteNotFound, p as filterStatusOk$1, pt as empty$1, q as SocketErrorReason, qt as HttpClientError, r as Mime_default, rt as HttpServerError, sn as fromInput$1, t as layerWebSocketConstructor, tt as runtime, u as withLogAddress, un as isHttpBody, ut as toResponse, v as getAndSet, vn as schemaRecord, w as updateAndGet, wn as __require, wt as setHeaders$1, x as modify$2, xn as map$3, xt as schemaJson, y as make$65, yn as toRecord, yt as redirect, zt as make$66 } from "./NodeSocket-H2hJzAlR.mjs";
4
+ import { $ as decodeUnknownExit, $a as filterOrFail, $c as StackTrace, $d as compose$1, $l as days, $o as scoped, $r as toAsyncIterable, $s as TaggedClass, $t as Union$1, $u as Service$2, A as StructWithRest, Aa as asSome, Ac as TracerTimingEnabled, Ai as splitLines, An as encodeBase64, Ar as mapArrayEffect, As as withParentSpan, At as suspend$1, Au as match, B as Union, Ba as catchTag, Bi as offerAll, Bl as tracerLogger$1, Bn as now$1, Bo as promise, Br as provideContext$1, Bs as addDelay, Bt as value, C as Number$1, Ca as all, Cc as closeUnsafe, Cd as isSome, Ci as filterArray, Cl as ConsoleRef, Cn as parseJson, Co as makeSpanScoped, Cr as fromQueue, Cs as updateContext, Ct as isTrimmed, Cu as findLast, D as String$1, Da as annotateLogsScoped, Dc as provide$2, Dd as some, Di as mapEffect$2, Dn as decodeBase64String, Dr as isStream, Ds as withErrorReporting, Dt as mutable, Du as isReadonlyArrayNonEmpty, E as Record, Ea as annotateLogs, Ec as makeUnsafe$8, Ed as none, El as consolePretty$1, Eo as mapError, Er as groupedWithin, Es as whileLoop, Et as makeFilter, Eu as isArrayNonEmpty, Fa as catchDefect, Fc as failCause$2, Fd as PipeInspectableProto, Fn as isGreaterThan$1, Fs as counter, Ft as toJsonSchemaDocument, G as annotateKey, Ga as contextWith, Gc as interrupt$3, Gi as take$1, Gl as NativeSpan, Gn as InvalidValue$1, Go as repeat, Gr as runFold, Gs as catchDone, Gt as toJsonSchemaMultiDocument, Gu as getOrThrow, H as UnknownFromJsonString$1, Ha as catch_, Hc as die$1, Hd as NodeInspectSymbol, Hn as toEpochMillis, Ho as provideContext, Hr as run$5, Ht as toMultiDocumentOpenApi3_1, I as URLFromString, Ii as failCause$3, Il as reportCauseUnsafe, In as isGreaterThanOrEqualTo$1, Io as onInterrupt, Ir as onExit$1, Is as snapshotUnsafe, It as toType, J as decodeEffect, Jc as match$3, Ji as publish, Jl as externalSpan, Jn as Path, Jo as runFork, Jr as runForEachArray, Js as round, Ju as isSuccess$1, K as brand, Ka as currentParentSpan, Kc as isFailure, Ki as takeAll, Kl as ParentSpan, Ko as result, Kr as runFoldEffect, Ks as isDoneCause, Kt as escapeToken, Ku as getOrUndefined$2, L as Uint8Array$1, La as catchFilter, Lc as isDeferred, Ld as isEffect$1, Ln as isLessThan$1, Lo as option, Ls as timer, Lt as withConstructorDefault, Lu as map$7, M as TaggedStruct, Ma as cached, Mc as die$2, Md as getStackTraceLimit, Mi as makeUnsafe$5, Ml as fnUntraced$1, Mn as encodeHex, Mo as never, Mr as mapError$1, Ms as withTracerEnabled, Mt as toCodecJson, Mu as reduce, N as TemplateLiteral, Na as callback, Nd as setStackTraceLimit, Ni as bounded, Nn as add$3, No as onError, Nr as merge$2, Ns as yieldNow, Nt as toCodecJsonAST, Nu as reverse, O as StringFromUriComponent, Oa as annotateSpans, Oc as MinimumLogLevel, Od as Number$2, Oi as pipeTo, On as decodeBase64Url, Oo as match$2, Or as make$76, Os as withFiber$1, Ot as optional$3, Pa as catchCause, Pc as fail$3, Pd as Prototype, Pi as end, Pn as formatIso, Po as onExit, Ps as zipWith, Pt as toCodecStringTree, Pu as sort, Q as decodeUnknownEffect, Qa as failCause$1, Qc as NoSuchElementError, Qi as unbounded$1, Qo as scope, Qr as takeWhile, Qt as isSchemaError, Qu as Reference, R as Undefined, Ra as catchIf, Rd as withFiber, Ri as make$80, Rn as make$73, Ro as orDie, Rr as pipeThroughChannel, Rs as update$3, Rt as withDecodingDefault, S as NullOr, Sa as addFinalizer, Sc as close, Sd as isNone, Si as decodeText$1, Sn as onSome, So as logWarning$1, Sr as fromPubSub, St as isSchema, Su as findFirstIndex, T as OptionFromNullOr, Ta as annotateCurrentSpan, Tc as make$78, Td as match$1, Ti as fromTransform, Tn as stringifyJson, Tr as fromSubscription, Ts as void_$1, Tt as make$72, Tu as fromIterable, U as Void, Uc as fail$4, Ud as toJson, Ui as shutdown$1, Un as toUtc, Uo as provideService, Ur as runCollect, Us as passthrough, Ut as apply, Uu as fail$1, V as Unknown, Va as catchTags, Vc as succeed$4, Vi as offerUnsafe, Vn as toDate, Vo as provide$1, Vr as provideService$1, Vs as forever$1, Vt as VALID_OPEN_API_COMPONENTS_SCHEMAS_KEY_REGEXP, W as annotate$2, Wa as context, Wc as failCause$4, Wd as format, Wi as sliding$1, Wl as MinimumTraceLevel, Wn as Forbidden$1, Wo as raceFirst, Wr as runDrain, Ws as spaced, Wt as toRepresentations, Wu as failVoid, X as decodeSync, Xa as exit, Xc as void_$2, Xi as sliding, Xn as FileSystem, Xo as runPromiseWith, Xs as currentTimeMillis, Xu as succeed$2, Y as decodeExit, Ya as ensuring, Yi as shutdown$2, Yl as make$79, Yo as runForkWith, Ys as Clock, Z as decodeTo, Za as fail, Zi as subscribe, Zs as currentTimeNanos, Zt as SchemaError, _c as tap$1, _d as fromNullishOr, _i as drain$1, _n as Transformation, _o as log$1, _s as tryPromise, _t as isMaxLength, _u as empty$4, a as Class, ac as effect, ad as getOrUndefined$1, af as isString, ai as withSpan$1, an as isLiteral, ao as forEach, ar as debounce, as as succeedNone, at as encodeUnknownExit, b as NonEmptyString, ba as acquireRelease, bc as addFinalizer$1, bd as getOrNull, bf as pipeArguments, bl as prettyErrors, bn as transformOrFail, bo as logFatal, br as fromIterable$1, bs as txRetry, bt as isNonEmpty, bu as filterMap, c as Defect, ca as append$1, cc as empty$8, cd as makeUnsafe$4, ci as get$6, cl as hasDies, cn as isOptional, co as forkIn, cr as drain, cs as sync, ct as instanceOf, cu as millis, d as ErrorClass, da as head, dc as mergeAll, dd as contains, df as constFalse, di as make$71, dl as interrupt$2, dn as isVoid, do as gen, ds as tapDefect, dt as isFinite, du as seconds, ec as TaggedError, ed as add$2, ef as hasProperty, eo as flatMap$1, es as scopedWith, et as decodeUnknownOption, eu as format$1, f as Exit, fa as isEmpty$2, fc as provide, fd as exists, ff as constTrue, fl as interruptors, fn as resolveAt, fo as ignore$1, fr as fail$5, fs as tapError, ft as isGreaterThan, fu as toMillis, g as Literals, ga as PlatformError, gc as sync$2, gd as flatten, gf as dual, go as isEffect, gr as fromAsyncIterable, gt as isLessThanOrEqualTo, h as Literal, hc as succeedContext, hd as flatMap$3, hf as constant, hn as toEncoded, ho as interruptible, hr as flatMap$2, hs as timeoutOption, ht as isLessThan, hu as allocate, i as Cause, ia as interrupt$4, ic as buildWithMemoMap, id as getOrElse$1, if as isObject$1, ii as unwrap$1, il as fail$2, in as isDeclaration, io as fnUntraced, ir as concat, is as succeed$1, it as encodeUnknownEffect, j as TaggedErrorClass, ja as asVoid, jc as _await, ji as make$77, jn as encodeBase64Url, jo as matchEffect, jr as mapEffect$1, js as withSpan, jt as tag, k as Struct, ka as as, kc as TracerEnabled, kd as make$74, kn as decodeBase64UrlString, ko as matchCauseEffect, kr as map$8, kt as optionalKey, ku as map$5, l as Duration, la as drop$1, ld as merge$1, lf as cast, li as has, ll as hasInterrupts, ln as isSuspend, lo as forkScoped, lr as empty$7, ls as tap, lt as is, lu as minutes, m as Int, ma as toArray, mc as succeed$3, md as firstSomeOf, mf as constVoid, ml as isFailReason, mn as resolveIdentifier, mo as interrupt$1, mr as filter$2, ms as timeout, mt as isInt, mu as zero, n as ArraySchema, na as await_, nc as CurrentMemoMap, nd as get$5, nf as isNotUndefined, nn as getAST, no as flatten$1, nr as catchCause$1, ns as serviceOption, nt as encodeEffect, nu as fromInputUnsafe, o as DateTimeUtc, oa as join$2, oc as effectContext, od as getUnsafe$1, of as isTagged, ol as findErrorOption, on as isNull, oo as forever, or as decodeText, os as succeedSome, ot as fieldsAssign, p as Finite, pa as size$2, pc as provideMerge, pd as filter, pf as constUndefined, pl as isCause, pn as resolveDescription, po as ignoreCause, pr as failCause$5, ps as tapErrorTag, pt as isGreaterThanOrEqualTo, q as declare, qa as die, qc as isSuccess, qd as equals, qi as unbounded$2, ql as Tracer, qn as makeFormatterDefault, qo as retry, qr as runForEach, qs as parse$2, qt as assign, qu as isFailure$1, r as Boolean$1, ra as getCurrent, rc as build, rd as getOption, rf as isNullish, ri as transformPull, rn as getLastEncoding, ro as fn, rr as changes, rs as sleep, rt as encodeSync, ru as hours, s as DateTimeUtcFromString, sa as runIn, sc as effectDiscard, sd as make$70, sn as isObjects, so as forkChild, ss as suspend, st as fromJsonString, su as max, t as Any, ta as makeUnsafe$7, tc as taggedEnum, td as empty$5, tf as isNotNull, tl as combine$1, tr as callback$1, ts as service, tt as encode$1, tu as fromInput$2, u as DurationFromMillis, ua as empty$6, uc as launch, ud as omit, uf as compose, ui as invalidate, ul as hasInterruptsOnly, un as isUnion, uo as fromResult, ur as encodeText, us as tapCause, ut as isBetween, uu as nanos, v as Never, vc as unwrap, vd as fromUndefinedOr, vf as identity, vi as forEach$1, vl as map$9, vo as logDebug, vr as fromEffect, vs as try_, vt as isMaxProperties, vu as ensure, w as Option, wa as andThen, wc as forkUnsafe, wd as map$6, wl as CurrentLoggers$1, wo as map$4, ws as useSpan, wu as flatMapNullishOr, x as Null, xa as acquireUseRelease, xc as addFinalizerExit, xd as getOrUndefined, xi as mapInput, xl as squash, xn as trim, xo as logInfo, xr as fromIteratorSucceed, xs as uninterruptible, xt as isPattern, xu as findFirst, y as NonEmptyArray, ya as Transaction, yc as Scope, yd as getOrElse, yf as pipe, yl as pretty, yn as transform$1, yo as logError, yr as fromEffectSchedule, ys as tx, yt as isMinLength, yu as filter$1, z as UndefinedOr, za as catchReason, zc as make$75, zd as assignProperty, zi as offer$1, zl as sync$1, zn as makeUnsafe$6, zo as orElseSucceed, zs as withAttributes, zt as make$69 } from "./Schema-Ch_m1IpT.mjs";
5
+ import { a as isQuitError, g as ChildProcessSpawner, h as make$81, i as Terminal$1, l as Crypto, n as layer$47, o as Stdio, r as QuitError, s as make$82, u as fromReadable } from "./NodeServices-Brptf0fr.mjs";
6
+ import { _ as withDefault$2, a as all$1, c as logLevel, d as option$1, f as port, g as url$1, i as TrueValues, l as map$10, m as string$4, n as FalseValues, o as boolean$3, p as schema$1, r as Record$1, s as int, t as Boolean$2, u as number } from "./Config-DmzaN-lb.mjs";
7
+ import { c as getOption$1, d as make$83, f as makeWith$1, l as invalidate$1, n as SqlClient, p as set$4, s as get$7, u as keys } from "./SqlClient-DK7CA43E.mjs";
8
8
  import * as NodeModule from "node:module";
9
9
  import * as NodeChildProcess from "node:child_process";
10
10
  import * as NodeCrypto from "node:crypto";
@@ -5882,7 +5882,7 @@ const map$2 = /*#__PURE__*/ dual(2, (self, f) => flatMap(self, (a) => succeed(f(
5882
5882
  * @category constructors
5883
5883
  * @since 4.0.0
5884
5884
  */
5885
- const password = (options) => basePrompt(options, "password").pipe(map$2(make$68));
5885
+ const password = (options) => basePrompt(options, "password").pipe(map$2(make$69));
5886
5886
  /**
5887
5887
  * Runs a prompt by reading terminal input and rendering prompt frames until the
5888
5888
  * prompt submits a value.
@@ -10590,7 +10590,7 @@ const isCommand = (u) => hasProperty(u, TypeId$14);
10590
10590
  * @category constructors
10591
10591
  * @since 4.0.0
10592
10592
  */
10593
- const make$63 = (name, config, handler) => {
10593
+ const make$64 = (name, config, handler) => {
10594
10594
  return makeCommand({
10595
10595
  name,
10596
10596
  config: parseConfig(config ?? {}),
@@ -11086,7 +11086,7 @@ const runWith = (command, config) => {
11086
11086
  }
11087
11087
  const services = match$1(logLevel, {
11088
11088
  onNone: () => empty$5(),
11089
- onSome: (level) => make$69(MinimumLogLevel, level)
11089
+ onSome: (level) => make$70(MinimumLogLevel, level)
11090
11090
  });
11091
11091
  yield* provideContext(program, services);
11092
11092
  }, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$2(error) : fail$1(error), (error) => andThen(showHelp(command, error), fail(error))), catchFilter((e) => isQuitError(e) ? succeed$2(e) : fail$1(e), (_) => interrupt$1));
@@ -11104,7 +11104,7 @@ const closeServer = (server) => {
11104
11104
  * NetService - Service tag for startup networking helpers.
11105
11105
  */
11106
11106
  var NetService = class extends Service$2()("@t3tools/shared/Net/NetService") {};
11107
- const make$62 = () => {
11107
+ const make$63 = () => {
11108
11108
  /**
11109
11109
  * Returns true when a TCP server can bind to {host, port}.
11110
11110
  * `EADDRNOTAVAIL` is treated as available so IPv6-absent hosts don't fail
@@ -11213,7 +11213,7 @@ const make$62 = () => {
11213
11213
  })
11214
11214
  };
11215
11215
  };
11216
- const layer$43 = sync$2(NetService, make$62);
11216
+ const layer$45 = sync$2(NetService, make$63);
11217
11217
  //#endregion
11218
11218
  //#region package.json
11219
11219
  var version = "0.0.31";
@@ -12094,7 +12094,7 @@ function parse$1(input) {
12094
12094
  const FULL_PATH_REGEXP = /^https?:\/\/.*?\//;
12095
12095
  const OPTIONAL_PARAM_REGEXP = /(\/:[^/()]*?)\?(\/?)/;
12096
12096
  /** @internal */
12097
- const make$61 = (options = {}) => new RouterImpl(options);
12097
+ const make$62 = (options = {}) => new RouterImpl(options);
12098
12098
  var RouterImpl = class {
12099
12099
  constructor(options = {}) {
12100
12100
  this.options = {
@@ -12613,7 +12613,7 @@ const httpMethods = [
12613
12613
  * @since 1.0.0
12614
12614
  * @category constructors
12615
12615
  */
12616
- const make$60 = make$61;
12616
+ const make$61 = make$62;
12617
12617
  //#endregion
12618
12618
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/http/HttpRouter.js
12619
12619
  /**
@@ -12648,8 +12648,8 @@ const HttpRouter = /*#__PURE__*/ Service$2("effect/http/HttpRouter");
12648
12648
  * @category constructors
12649
12649
  * @since 4.0.0
12650
12650
  */
12651
- const make$59 = /*#__PURE__*/ gen(function* () {
12652
- const router = make$60(yield* RouterConfig);
12651
+ const make$60 = /*#__PURE__*/ gen(function* () {
12652
+ const router = make$61(yield* RouterConfig);
12653
12653
  const middleware = /* @__PURE__ */ new Set();
12654
12654
  const addAll = (routes) => contextWith((context) => {
12655
12655
  const middleware = getMiddleware(context);
@@ -12815,7 +12815,7 @@ const add$1 = (method, path, handler, options) => use((router) => router.add(met
12815
12815
  * @category layers
12816
12816
  * @since 4.0.0
12817
12817
  */
12818
- const layer$42 = /*#__PURE__*/ effect(HttpRouter)(make$59);
12818
+ const layer$44 = /*#__PURE__*/ effect(HttpRouter)(make$60);
12819
12819
  const RouteTypeId = "~effect/http/HttpRouter/Route";
12820
12820
  const makeRoute = (options) => ({
12821
12821
  ...options,
@@ -12999,7 +12999,7 @@ const cors = (options) => middleware(cors$1(options), { global: true });
12999
12999
  const serve = (appLayer, options) => {
13000
13000
  let middleware = options?.middleware;
13001
13001
  if (options?.disableLogger !== true) middleware = middleware ? compose(middleware, logger) : logger;
13002
- const RouterLayer = options?.routerConfig ? provide(layer$42, succeed$3(RouterConfig)(options.routerConfig)) : layer$42;
13002
+ const RouterLayer = options?.routerConfig ? provide(layer$44, succeed$3(RouterConfig)(options.routerConfig)) : layer$44;
13003
13003
  return gen(function* () {
13004
13004
  const handler = (yield* HttpRouter).asHttpEffect();
13005
13005
  return middleware ? serve$1(handler, middleware) : serve$1(handler);
@@ -13106,7 +13106,7 @@ function makeProto$4(options) {
13106
13106
  * @category constructors
13107
13107
  * @since 4.0.0
13108
13108
  */
13109
- const make$58 = (method) => (identifier, path, options) => {
13109
+ const make$59 = (method) => (identifier, path, options) => {
13110
13110
  const disableCodecs = options?.disableCodecs ?? false;
13111
13111
  const transformStringTree = disableCodecs ? identity : toCodecStringTree;
13112
13112
  return makeProto$4({
@@ -13247,15 +13247,15 @@ function transformPayload(schema, method) {
13247
13247
  * @category constructors
13248
13248
  * @since 4.0.0
13249
13249
  */
13250
- const get$2 = /*#__PURE__*/ make$58("GET");
13250
+ const get$2 = /*#__PURE__*/ make$59("GET");
13251
13251
  /**
13252
13252
  * Creates a `POST` endpoint declaration.
13253
13253
  *
13254
13254
  * @category constructors
13255
13255
  * @since 4.0.0
13256
13256
  */
13257
- const post = /*#__PURE__*/ make$58("POST");
13258
- const del = /*#__PURE__*/ make$58("DELETE");
13257
+ const post = /*#__PURE__*/ make$59("POST");
13258
+ const del = /*#__PURE__*/ make$59("DELETE");
13259
13259
  //#endregion
13260
13260
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/httpapi/HttpApi.js
13261
13261
  const TypeId$11 = "~effect/httpapi/HttpApi";
@@ -13330,7 +13330,7 @@ const makeProto$3 = (options) => {
13330
13330
  * @category constructors
13331
13331
  * @since 4.0.0
13332
13332
  */
13333
- const make$57 = (identifier) => makeProto$3({
13333
+ const make$58 = (identifier) => makeProto$3({
13334
13334
  identifier,
13335
13335
  groups: {},
13336
13336
  annotations: empty$5()
@@ -13469,7 +13469,7 @@ const makeProto$2 = (options) => {
13469
13469
  * @category constructors
13470
13470
  * @since 4.0.0
13471
13471
  */
13472
- const make$56 = (identifier, options) => makeProto$2({
13472
+ const make$57 = (identifier, options) => makeProto$2({
13473
13473
  identifier,
13474
13474
  topLevel: options?.topLevel ?? false,
13475
13475
  endpoints: {},
@@ -14451,6 +14451,17 @@ Union([DispatchableClientOrchestrationCommand, Union([
14451
14451
  turnId: optional$3(TurnId),
14452
14452
  createdAt: IsoDateTime
14453
14453
  }),
14454
+ Struct({
14455
+ type: Literal("thread.history.import"),
14456
+ commandId: CommandId,
14457
+ threadId: ThreadId,
14458
+ messages: ArraySchema(Struct({
14459
+ messageId: MessageId,
14460
+ role: Literals(["user", "assistant"]),
14461
+ text: String$1,
14462
+ createdAt: IsoDateTime
14463
+ })).check(isNonEmpty())
14464
+ }),
14454
14465
  Struct({
14455
14466
  type: Literal("thread.proposed-plan.upsert"),
14456
14467
  commandId: CommandId,
@@ -14710,7 +14721,8 @@ const OrchestrationEventMetadata = Struct({
14710
14721
  providerItemId: optional$3(ProviderItemId),
14711
14722
  adapterKey: optional$3(TrimmedNonEmptyString),
14712
14723
  requestId: optional$3(ApprovalRequestId),
14713
- ingestedAt: optional$3(IsoDateTime)
14724
+ ingestedAt: optional$3(IsoDateTime),
14725
+ historyImport: optional$3(Boolean$1)
14714
14726
  });
14715
14727
  const EventBaseFields = {
14716
14728
  sequence: NonNegativeInt,
@@ -16193,11 +16205,11 @@ const RelayHealthResponse = Struct({
16193
16205
  ok: Boolean$1,
16194
16206
  service: Literal("relay")
16195
16207
  });
16196
- const RelayHealthGroup = make$56("health").add(get$2("health", "/health", {
16208
+ const RelayHealthGroup = make$57("health").add(get$2("health", "/health", {
16197
16209
  success: RelayHealthResponse,
16198
16210
  error: RelayInternalError
16199
16211
  }).annotate(Summary, "Check relay health")).annotate(Description, "Service health and readiness.");
16200
- const RelayMetadataGroup = make$56("metadata").add(get$2("authorizationServer", "/.well-known/oauth-authorization-server", { success: RelayAuthorizationServerMetadata }).annotate(Summary, "Read OAuth authorization-server metadata"), get$2("protectedResource", "/.well-known/oauth-protected-resource", { success: RelayProtectedResourceMetadata }).annotate(Summary, "Read OAuth protected-resource metadata")).annotate(Description, "OAuth and DPoP discovery metadata.");
16212
+ const RelayMetadataGroup = make$57("metadata").add(get$2("authorizationServer", "/.well-known/oauth-authorization-server", { success: RelayAuthorizationServerMetadata }).annotate(Summary, "Read OAuth authorization-server metadata"), get$2("protectedResource", "/.well-known/oauth-protected-resource", { success: RelayProtectedResourceMetadata }).annotate(Summary, "Read OAuth protected-resource metadata")).annotate(Description, "OAuth and DPoP discovery metadata.");
16201
16213
  const RelayRegisterDeviceEndpoint = post("registerDevice", "/v1/mobile/devices", {
16202
16214
  headers: RelayDpopRequestHeaders,
16203
16215
  payload: RelayDeviceRegistrationRequest,
@@ -16221,8 +16233,8 @@ const RelayUnregisterDeviceEndpoint = del("unregisterDevice", "/v1/mobile/device
16221
16233
  success: RelayOkResponse,
16222
16234
  error: RelayAuthAndInternalErrors
16223
16235
  }).annotate(Summary, "Unregister a mobile device");
16224
- const RelayMobileGroup = make$56("mobile").add(RelayRegisterDeviceEndpoint, RelayRegisterLiveActivityEndpoint, RelayAgentActivitySnapshotEndpoint, RelayUnregisterDeviceEndpoint).annotate(Description, "Mobile push-notification and Live Activity registration.").middleware(RelayDpopClientAuth);
16225
- const RelayClientGroup = make$56("client").add(get$2("listEnvironments", "/v1/environments", {
16236
+ const RelayMobileGroup = make$57("mobile").add(RelayRegisterDeviceEndpoint, RelayRegisterLiveActivityEndpoint, RelayAgentActivitySnapshotEndpoint, RelayUnregisterDeviceEndpoint).annotate(Description, "Mobile push-notification and Live Activity registration.").middleware(RelayDpopClientAuth);
16237
+ const RelayClientGroup = make$57("client").add(get$2("listEnvironments", "/v1/environments", {
16226
16238
  headers: RelayBearerRequestHeaders,
16227
16239
  success: RelayListEnvironmentsResponse,
16228
16240
  error: RelayAuthAndInternalErrors
@@ -16257,7 +16269,7 @@ const RelayExchangeDpopAccessTokenEndpoint = post("exchangeDpopAccessToken", "/v
16257
16269
  success: RelayDpopAccessTokenResponse,
16258
16270
  error: RelayAuthAndInternalErrors
16259
16271
  }).annotate(Summary, "Exchange a Clerk token for a DPoP access token").annotate(Description, "Bootstrap endpoint. Send the DPoP proof JWT in the dpop header and the Clerk token in subject_token. The returned access token is bound to the proof key.");
16260
- const RelayTokenGroup = make$56("token").add(RelayExchangeDpopAccessTokenEndpoint).annotate(Description, "OAuth token exchange for DPoP-bound client access.");
16272
+ const RelayTokenGroup = make$57("token").add(RelayExchangeDpopAccessTokenEndpoint).annotate(Description, "OAuth token exchange for DPoP-bound client access.");
16261
16273
  const RelayConnectEnvironmentEndpoint = post("connectEnvironment", "/v1/environments/:environmentId/connect", {
16262
16274
  headers: RelayDpopRequestHeaders,
16263
16275
  params: Struct({ environmentId: EnvironmentId }),
@@ -16271,8 +16283,8 @@ const RelayGetEnvironmentStatusEndpoint = post("getEnvironmentStatus", "/v1/envi
16271
16283
  success: RelayEnvironmentStatusResponse,
16272
16284
  error: RelayEnvironmentConnectErrors
16273
16285
  }).annotate(Summary, "Check environment status");
16274
- const RelayDpopClientGroup = make$56("dpopClient").add(RelayConnectEnvironmentEndpoint, RelayGetEnvironmentStatusEndpoint).annotate(Description, "DPoP-authenticated client access to linked environments.").middleware(RelayDpopClientAuth);
16275
- const RelayServerGroup = make$56("server").add(post("publishAgentActivity", "/v1/environments/:environmentId/threads/:threadId/agent-activity", {
16286
+ const RelayDpopClientGroup = make$57("dpopClient").add(RelayConnectEnvironmentEndpoint, RelayGetEnvironmentStatusEndpoint).annotate(Description, "DPoP-authenticated client access to linked environments.").middleware(RelayDpopClientAuth);
16287
+ const RelayServerGroup = make$57("server").add(post("publishAgentActivity", "/v1/environments/:environmentId/threads/:threadId/agent-activity", {
16276
16288
  params: Struct({
16277
16289
  environmentId: EnvironmentId,
16278
16290
  threadId: ThreadId
@@ -16281,7 +16293,7 @@ const RelayServerGroup = make$56("server").add(post("publishAgentActivity", "/v1
16281
16293
  success: RelayPublishResponse,
16282
16294
  error: RelayAgentActivityPublishErrors
16283
16295
  }).annotate(Summary, "Publish agent activity")).annotate(Description, "Environment-authenticated activity publication.").middleware(RelayEnvironmentAuth);
16284
- make$57("RelayApi").add(RelayHealthGroup, RelayMetadataGroup, RelayMobileGroup, RelayClientGroup, RelayTokenGroup, RelayDpopClientGroup, RelayServerGroup).annotate(Title$1, "AgentLink Relay API").annotate(Version, "1.0.0").annotate(Description, "Control-plane API for linking T3 environments, connecting authorized clients, and publishing agent activity.");
16296
+ make$58("RelayApi").add(RelayHealthGroup, RelayMetadataGroup, RelayMobileGroup, RelayClientGroup, RelayTokenGroup, RelayDpopClientGroup, RelayServerGroup).annotate(Title$1, "AgentLink Relay API").annotate(Version, "1.0.0").annotate(Description, "Control-plane API for linking T3 environments, connecting authorized clients, and publishing agent activity.");
16285
16297
  //#endregion
16286
16298
  //#region ../t3-contracts/src/environmentHttp.ts
16287
16299
  const OptionalBearerHeaders = Struct({
@@ -16459,8 +16471,8 @@ const EnvironmentCloudPreferencesRequest = Struct({ publishAgentActivity: Boolea
16459
16471
  const AuthPairingLinkRevokeResult = Struct({ revoked: Boolean$1 });
16460
16472
  const AuthClientSessionRevokeResult = Struct({ revoked: Boolean$1 });
16461
16473
  const AuthOtherClientSessionsRevokeResult = Struct({ revokedCount: Number$1 });
16462
- var EnvironmentMetadataHttpApi = class extends make$56("metadata").add(get$2("descriptor", "/.well-known/t3/environment", { success: ExecutionEnvironmentDescriptor })) {};
16463
- var EnvironmentAuthHttpApi = class extends make$56("auth").add(get$2("session", "/api/auth/session", {
16474
+ var EnvironmentMetadataHttpApi = class extends make$57("metadata").add(get$2("descriptor", "/.well-known/t3/environment", { success: ExecutionEnvironmentDescriptor })) {};
16475
+ var EnvironmentAuthHttpApi = class extends make$57("auth").add(get$2("session", "/api/auth/session", {
16464
16476
  headers: OptionalBearerHeaders,
16465
16477
  success: AuthSessionState,
16466
16478
  error: [EnvironmentInternalError]
@@ -16506,7 +16518,7 @@ var EnvironmentAuthHttpApi = class extends make$56("auth").add(get$2("session",
16506
16518
  error: EnvironmentScopedOperationErrors
16507
16519
  }).middleware(EnvironmentAuthenticatedAuth)) {};
16508
16520
  const EnvironmentOrchestrationThreadSnapshotParams = Struct({ threadId: ThreadId });
16509
- var EnvironmentOrchestrationHttpApi = class extends make$56("orchestration").add(get$2("snapshot", "/api/orchestration/snapshot", {
16521
+ var EnvironmentOrchestrationHttpApi = class extends make$57("orchestration").add(get$2("snapshot", "/api/orchestration/snapshot", {
16510
16522
  headers: OptionalBearerHeaders,
16511
16523
  success: OrchestrationReadModel,
16512
16524
  error: EnvironmentOrchestrationSnapshotErrors
@@ -16525,7 +16537,7 @@ var EnvironmentOrchestrationHttpApi = class extends make$56("orchestration").add
16525
16537
  success: DispatchResult,
16526
16538
  error: EnvironmentOrchestrationDispatchErrors
16527
16539
  }).middleware(EnvironmentAuthenticatedAuth)) {};
16528
- var EnvironmentConnectHttpApi = class extends make$56("connect").add(post("linkProof", "/api/connect/link-proof", {
16540
+ var EnvironmentConnectHttpApi = class extends make$57("connect").add(post("linkProof", "/api/connect/link-proof", {
16529
16541
  headers: OptionalBearerHeaders,
16530
16542
  payload: RelayLinkProofRequest,
16531
16543
  success: RelayEnvironmentLinkProof,
@@ -16561,7 +16573,7 @@ var EnvironmentConnectHttpApi = class extends make$56("connect").add(post("linkP
16561
16573
  success: RelayEnvironmentMintResponse,
16562
16574
  error: EnvironmentHttpCloudErrors
16563
16575
  })) {};
16564
- var EnvironmentHttpApi = class extends make$57("environment").add(EnvironmentMetadataHttpApi).add(EnvironmentAuthHttpApi).add(EnvironmentOrchestrationHttpApi).add(EnvironmentConnectHttpApi) {};
16576
+ var EnvironmentHttpApi = class extends make$58("environment").add(EnvironmentMetadataHttpApi).add(EnvironmentAuthHttpApi).add(EnvironmentOrchestrationHttpApi).add(EnvironmentConnectHttpApi) {};
16565
16577
  //#endregion
16566
16578
  //#region ../t3-contracts/src/relayClient.ts
16567
16579
  const RelayClientStatusSchema = Union([
@@ -16784,10 +16796,10 @@ const TypeId$7 = "~effect/LayerMap";
16784
16796
  * @category constructors
16785
16797
  * @since 3.14.0
16786
16798
  */
16787
- const make$55 = /*#__PURE__*/ fnUntraced(function* (lookup, options) {
16799
+ const make$56 = /*#__PURE__*/ fnUntraced(function* (lookup, options) {
16788
16800
  const context$3 = yield* context();
16789
16801
  const memoMap = CurrentMemoMap.forkOrCreate(context$3);
16790
- const rcMap = yield* make$70({
16802
+ const rcMap = yield* make$71({
16791
16803
  lookup: (key) => contextWith((_) => buildWithMemoMap(lookup(key), memoMap, get$5(_, Scope))),
16792
16804
  idleTimeToLive: options?.idleTimeToLive
16793
16805
  });
@@ -16852,7 +16864,7 @@ const make$55 = /*#__PURE__*/ fnUntraced(function* (lookup, options) {
16852
16864
  * @category constructors
16853
16865
  * @since 3.14.0
16854
16866
  */
16855
- const fromRecord$1 = (layers, options) => make$55((key) => layers[key], {
16867
+ const fromRecord$1 = (layers, options) => make$56((key) => layers[key], {
16856
16868
  ...options,
16857
16869
  preloadKeys: options?.preload ? Object.keys(layers) : void 0
16858
16870
  });
@@ -16914,7 +16926,7 @@ const Service = () => (id, options) => {
16914
16926
  Object.defineProperty(TagClass, "stack", { get() {
16915
16927
  return creationError.stack;
16916
16928
  } });
16917
- TagClass_.layerNoDeps = effect(TagClass_)("lookup" in options ? make$55(options.lookup, options) : fromRecord$1(options.layers, options));
16929
+ TagClass_.layerNoDeps = effect(TagClass_)("lookup" in options ? make$56(options.lookup, options) : fromRecord$1(options.layers, options));
16918
16930
  TagClass_.layer = options.dependencies && options.dependencies.length > 0 ? provide(TagClass_.layerNoDeps, options.dependencies) : TagClass_.layerNoDeps;
16919
16931
  TagClass_.get = (key) => unwrap(map$4(TagClass_, (layerMap) => layerMap.get(key)));
16920
16932
  TagClass_.contextEffect = (key) => flatMap$1(TagClass_, (layerMap) => layerMap.contextEffect(key));
@@ -17039,7 +17051,7 @@ const tracerLogger = tracerLogger$1;
17039
17051
  * @category layers
17040
17052
  * @since 4.0.0
17041
17053
  */
17042
- const layer$41 = (loggers, options) => effect(CurrentLoggers, withFiber(fnUntraced$1(function* (fiber) {
17054
+ const layer$43 = (loggers, options) => effect(CurrentLoggers, withFiber(fnUntraced$1(function* (fiber) {
17043
17055
  const currentLoggers = new Set(options?.mergeWithExisting === true ? fiber.getRef(CurrentLoggers$1) : []);
17044
17056
  for (const logger of loggers) currentLoggers.add(isEffect$1(logger) ? yield* logger : logger);
17045
17057
  return currentLoggers;
@@ -17105,7 +17117,7 @@ const makeUnsafe$2 = (value) => {
17105
17117
  * @category constructors
17106
17118
  * @since 2.0.0
17107
17119
  */
17108
- const make$54 = (value) => sync(() => makeUnsafe$2(value));
17120
+ const make$55 = (value) => sync(() => makeUnsafe$2(value));
17109
17121
  /**
17110
17122
  * Reads the current value synchronously, bypassing the `Effect` API and the
17111
17123
  * ref's semaphore.
@@ -17190,7 +17202,7 @@ const TypeId$5 = "~effect/transactions/TxRef";
17190
17202
  * @category constructors
17191
17203
  * @since 2.0.0
17192
17204
  */
17193
- const make$53 = (initial) => sync(() => makeUnsafe$1(initial));
17205
+ const make$54 = (initial) => sync(() => makeUnsafe$1(initial));
17194
17206
  /**
17195
17207
  * Creates a new `TxRef` synchronously with the specified initial value.
17196
17208
  *
@@ -17418,7 +17430,7 @@ const TxChunkProto = {
17418
17430
  * @category constructors
17419
17431
  * @since 4.0.0
17420
17432
  */
17421
- const empty = () => map$4(make$53(empty$6()), (ref) => makeUnsafe(ref));
17433
+ const empty = () => map$4(make$54(empty$6()), (ref) => makeUnsafe(ref));
17422
17434
  /**
17423
17435
  * Creates a new `TxChunk` with the specified TxRef.
17424
17436
  *
@@ -17743,7 +17755,7 @@ const TxQueueProto = {
17743
17755
  */
17744
17756
  const unbounded = () => gen(function* () {
17745
17757
  const items = yield* empty();
17746
- const stateRef = yield* make$53({ _tag: "Open" });
17758
+ const stateRef = yield* make$54({ _tag: "Open" });
17747
17759
  const txQueue = Object.create(TxQueueProto);
17748
17760
  txQueue.strategy = "unbounded";
17749
17761
  txQueue.capacity = Number.POSITIVE_INFINITY;
@@ -22388,6 +22400,49 @@ var FilesystemBrowseError = class extends TaggedErrorClass()("FilesystemBrowseEr
22388
22400
  }
22389
22401
  };
22390
22402
  //#endregion
22403
+ //#region ../t3-contracts/src/agentSessions.ts
22404
+ /** Coding agent home directories the scanner knows how to read. */
22405
+ const AgentSessionSource = Literals(["claudeAgent", "codex"]);
22406
+ /** Imported message ids retain their origin after event metadata is projected into SQLite. */
22407
+ function isImportedAgentSessionMessageId(messageId) {
22408
+ return messageId.startsWith("import:");
22409
+ }
22410
+ /**
22411
+ * Empty for now. Kept as a struct so future scan options (source filters,
22412
+ * explicit roots) can be added without a new method.
22413
+ */
22414
+ const AgentSessionScanInput = Struct({});
22415
+ const AgentSessionScanResult = Struct({
22416
+ candidates: ArraySchema(Struct({
22417
+ path: TrimmedNonEmptyString,
22418
+ title: TrimmedNonEmptyString,
22419
+ projectId: optional$3(ProjectId),
22420
+ sources: ArraySchema(AgentSessionSource),
22421
+ threadCount: NonNegativeInt,
22422
+ lastActiveAt: NullOr(IsoDateTime),
22423
+ alreadyImported: Boolean$1
22424
+ })),
22425
+ scannedAt: IsoDateTime
22426
+ });
22427
+ const AgentSessionImportInput = Struct({ projectId: ProjectId });
22428
+ var AgentSessionImportProjectNotFoundError = class extends TaggedErrorClass()("AgentSessionImportProjectNotFoundError", { projectId: ProjectId }) {
22429
+ get message() {
22430
+ return `Project '${this.projectId}' does not exist.`;
22431
+ }
22432
+ };
22433
+ const AgentSessionImportResult = Struct({
22434
+ importedCount: NonNegativeInt,
22435
+ skippedCount: NonNegativeInt
22436
+ });
22437
+ var AgentSessionScanError = class extends TaggedErrorClass()("AgentSessionScanError", {
22438
+ operation: Literals(["read-settings", "read-projects"]),
22439
+ cause: Defect()
22440
+ }) {
22441
+ get message() {
22442
+ return `Failed to scan agent sessions during ${this.operation}.`;
22443
+ }
22444
+ };
22445
+ //#endregion
22391
22446
  //#region ../t3-contracts/src/assets.ts
22392
22447
  const ASSET_PATH_MAX_LENGTH = 1024;
22393
22448
  const AssetResource = Union([
@@ -22916,7 +22971,7 @@ const schema = /*#__PURE__*/ declare(isStream);
22916
22971
  * @since 4.0.0
22917
22972
  */
22918
22973
  function Stream(success, error) {
22919
- return make$71(schema.ast, {
22974
+ return make$72(schema.ast, {
22920
22975
  [StreamSchemaTypeId]: StreamSchemaTypeId,
22921
22976
  success,
22922
22977
  error
@@ -23070,7 +23125,7 @@ const makeProto$1 = (options) => {
23070
23125
  * @category constructors
23071
23126
  * @since 4.0.0
23072
23127
  */
23073
- const make$52 = (tag, options) => {
23128
+ const make$53 = (tag, options) => {
23074
23129
  const successSchema = options?.success ?? Void;
23075
23130
  const errorSchema = options?.error ?? Never;
23076
23131
  const defectSchema = options?.defect ?? Defect();
@@ -23226,7 +23281,7 @@ const RpcGroupProto = {
23226
23281
  });
23227
23282
  },
23228
23283
  annotateRpcs(service, value) {
23229
- return this.annotateRpcsMerge(make$69(service, value));
23284
+ return this.annotateRpcsMerge(make$70(service, value));
23230
23285
  },
23231
23286
  annotateMerge(context) {
23232
23287
  return makeProto({
@@ -23253,7 +23308,7 @@ const makeProto = (options) => Object.assign(function() {}, RpcGroupProto, {
23253
23308
  * @category constructors
23254
23309
  * @since 4.0.0
23255
23310
  */
23256
- const make$51 = (...rpcs) => makeProto({
23311
+ const make$52 = (...rpcs) => makeProto({
23257
23312
  requests: new Map(rpcs.map((rpc) => [rpc._tag, rpc])),
23258
23313
  annotations: empty$5()
23259
23314
  });
@@ -23270,6 +23325,8 @@ const WS_METHODS = {
23270
23325
  projectsWriteFile: "projects.writeFile",
23271
23326
  shellOpenInEditor: "shell.openInEditor",
23272
23327
  filesystemBrowse: "filesystem.browse",
23328
+ agentSessionsScan: "agentSessions.scan",
23329
+ agentSessionsImport: "agentSessions.import",
23273
23330
  assetsCreateUrl: "assets.createUrl",
23274
23331
  vcsPull: "vcs.pull",
23275
23332
  vcsRefreshStatus: "vcs.refreshStatus",
@@ -23348,7 +23405,7 @@ const VoiceInputThread = Struct({ threadId: ThreadId });
23348
23405
  const VoiceInputAudio = Struct({
23349
23406
  threadId: ThreadId,
23350
23407
  data: String$1.check(isMinLength(1), isMaxLength(32e3)),
23351
- sampleRate: Literal(24e3),
23408
+ sampleRate: Literals([16e3, 24e3]),
23352
23409
  numChannels: Literal(1),
23353
23410
  samplesPerChannel: optional$3(NonNegativeInt)
23354
23411
  });
@@ -23359,22 +23416,22 @@ const VoiceInputTranscriptEvent = Struct({
23359
23416
  final: Boolean$1
23360
23417
  });
23361
23418
  var VoiceInputUnavailableError = class extends TaggedErrorClass()("VoiceInputUnavailableError", { message: String$1 }) {};
23362
- const WsServerUpsertKeybindingRpc = make$52(WS_METHODS.serverUpsertKeybinding, {
23419
+ const WsServerUpsertKeybindingRpc = make$53(WS_METHODS.serverUpsertKeybinding, {
23363
23420
  payload: ServerUpsertKeybindingInput,
23364
23421
  success: ServerUpsertKeybindingResult,
23365
23422
  error: Union([KeybindingsConfigError, EnvironmentAuthorizationError])
23366
23423
  });
23367
- const WsServerRemoveKeybindingRpc = make$52(WS_METHODS.serverRemoveKeybinding, {
23424
+ const WsServerRemoveKeybindingRpc = make$53(WS_METHODS.serverRemoveKeybinding, {
23368
23425
  payload: ServerRemoveKeybindingInput,
23369
23426
  success: ServerRemoveKeybindingResult,
23370
23427
  error: Union([KeybindingsConfigError, EnvironmentAuthorizationError])
23371
23428
  });
23372
- const WsServerProbeRpc = make$52(WS_METHODS.serverProbe, {
23429
+ const WsServerProbeRpc = make$53(WS_METHODS.serverProbe, {
23373
23430
  payload: Struct({}),
23374
23431
  success: Struct({}),
23375
23432
  error: EnvironmentAuthorizationError
23376
23433
  });
23377
- const WsServerGetConfigRpc = make$52(WS_METHODS.serverGetConfig, {
23434
+ const WsServerGetConfigRpc = make$53(WS_METHODS.serverGetConfig, {
23378
23435
  payload: Struct({}),
23379
23436
  success: ServerConfig$1,
23380
23437
  error: Union([
@@ -23383,7 +23440,7 @@ const WsServerGetConfigRpc = make$52(WS_METHODS.serverGetConfig, {
23383
23440
  EnvironmentAuthorizationError
23384
23441
  ])
23385
23442
  });
23386
- const WsServerRefreshProvidersRpc = make$52(WS_METHODS.serverRefreshProviders, {
23443
+ const WsServerRefreshProvidersRpc = make$53(WS_METHODS.serverRefreshProviders, {
23387
23444
  payload: Struct({
23388
23445
  /**
23389
23446
  * When supplied, only refresh this specific provider instance. When
@@ -23395,217 +23452,231 @@ instanceId: optional$3(ProviderInstanceId) }),
23395
23452
  success: ServerProviderUpdatedPayload,
23396
23453
  error: EnvironmentAuthorizationError
23397
23454
  });
23398
- const WsServerUpdateProviderRpc = make$52(WS_METHODS.serverUpdateProvider, {
23455
+ const WsServerUpdateProviderRpc = make$53(WS_METHODS.serverUpdateProvider, {
23399
23456
  payload: ServerProviderUpdateInput,
23400
23457
  success: ServerProviderUpdatedPayload,
23401
23458
  error: Union([ServerProviderUpdateError, EnvironmentAuthorizationError])
23402
23459
  });
23403
- const WsServerUpdateServerRpc = make$52(WS_METHODS.serverUpdateServer, {
23460
+ const WsServerUpdateServerRpc = make$53(WS_METHODS.serverUpdateServer, {
23404
23461
  payload: ServerSelfUpdateInput,
23405
23462
  success: ServerSelfUpdateResult,
23406
23463
  error: Union([ServerSelfUpdateError, EnvironmentAuthorizationError])
23407
23464
  });
23408
- const WsServerUpdateServerWithProgressRpc = make$52(WS_METHODS.serverUpdateServerWithProgress, {
23465
+ const WsServerUpdateServerWithProgressRpc = make$53(WS_METHODS.serverUpdateServerWithProgress, {
23409
23466
  payload: ServerSelfUpdateInput,
23410
23467
  success: ServerSelfUpdateProgressEvent,
23411
23468
  error: Union([ServerSelfUpdateError, EnvironmentAuthorizationError]),
23412
23469
  stream: true
23413
23470
  });
23414
- const WsServerGetSettingsRpc = make$52(WS_METHODS.serverGetSettings, {
23471
+ const WsServerGetSettingsRpc = make$53(WS_METHODS.serverGetSettings, {
23415
23472
  payload: Struct({}),
23416
23473
  success: ServerSettings,
23417
23474
  error: Union([ServerSettingsError, EnvironmentAuthorizationError])
23418
23475
  });
23419
- const WsPortProxyListRpc = make$52(WS_METHODS.portProxyList, {
23476
+ const WsPortProxyListRpc = make$53(WS_METHODS.portProxyList, {
23420
23477
  payload: Struct({}),
23421
23478
  success: PortProxyListResult,
23422
23479
  error: EnvironmentAuthorizationError
23423
23480
  });
23424
- const WsPortProxyAuthorizeRpc = make$52(WS_METHODS.portProxyAuthorize, {
23481
+ const WsPortProxyAuthorizeRpc = make$53(WS_METHODS.portProxyAuthorize, {
23425
23482
  payload: PortProxyPortInput,
23426
23483
  success: PortProxyListResult,
23427
23484
  error: EnvironmentAuthorizationError
23428
23485
  });
23429
- const WsPortProxyRevokeRpc = make$52(WS_METHODS.portProxyRevoke, {
23486
+ const WsPortProxyRevokeRpc = make$53(WS_METHODS.portProxyRevoke, {
23430
23487
  payload: PortProxyPortInput,
23431
23488
  success: PortProxyListResult,
23432
23489
  error: EnvironmentAuthorizationError
23433
23490
  });
23434
- const WsServerUpdateSettingsRpc = make$52(WS_METHODS.serverUpdateSettings, {
23491
+ const WsServerUpdateSettingsRpc = make$53(WS_METHODS.serverUpdateSettings, {
23435
23492
  payload: Struct({ patch: ServerSettingsPatch }),
23436
23493
  success: ServerSettings,
23437
23494
  error: Union([ServerSettingsError, EnvironmentAuthorizationError])
23438
23495
  });
23439
- const WsServerDiscoverSourceControlRpc = make$52(WS_METHODS.serverDiscoverSourceControl, {
23496
+ const WsServerDiscoverSourceControlRpc = make$53(WS_METHODS.serverDiscoverSourceControl, {
23440
23497
  payload: Struct({}),
23441
23498
  success: SourceControlDiscoveryResult,
23442
23499
  error: EnvironmentAuthorizationError
23443
23500
  });
23444
- const WsServerGetTraceDiagnosticsRpc = make$52(WS_METHODS.serverGetTraceDiagnostics, {
23501
+ const WsServerGetTraceDiagnosticsRpc = make$53(WS_METHODS.serverGetTraceDiagnostics, {
23445
23502
  payload: Struct({}),
23446
23503
  success: ServerTraceDiagnosticsResult,
23447
23504
  error: EnvironmentAuthorizationError
23448
23505
  });
23449
- const WsServerGetProcessDiagnosticsRpc = make$52(WS_METHODS.serverGetProcessDiagnostics, {
23506
+ const WsServerGetProcessDiagnosticsRpc = make$53(WS_METHODS.serverGetProcessDiagnostics, {
23450
23507
  payload: Struct({}),
23451
23508
  success: ServerProcessDiagnosticsResult,
23452
23509
  error: EnvironmentAuthorizationError
23453
23510
  });
23454
- const WsServerGetProcessResourceHistoryRpc = make$52(WS_METHODS.serverGetProcessResourceHistory, {
23511
+ const WsServerGetProcessResourceHistoryRpc = make$53(WS_METHODS.serverGetProcessResourceHistory, {
23455
23512
  payload: ServerProcessResourceHistoryInput,
23456
23513
  success: ServerProcessResourceHistoryResult,
23457
23514
  error: EnvironmentAuthorizationError
23458
23515
  });
23459
- const WsServerGetResourceTelemetryHistoryRpc = make$52(WS_METHODS.serverGetResourceTelemetryHistory, {
23516
+ const WsServerGetResourceTelemetryHistoryRpc = make$53(WS_METHODS.serverGetResourceTelemetryHistory, {
23460
23517
  payload: ResourceTelemetryHistoryInput,
23461
23518
  success: ResourceTelemetryHistory,
23462
23519
  error: EnvironmentAuthorizationError
23463
23520
  });
23464
- const WsServerRetryResourceTelemetryRpc = make$52(WS_METHODS.serverRetryResourceTelemetry, {
23521
+ const WsServerRetryResourceTelemetryRpc = make$53(WS_METHODS.serverRetryResourceTelemetry, {
23465
23522
  payload: Struct({}),
23466
23523
  success: ResourceTelemetryRetryResult,
23467
23524
  error: EnvironmentAuthorizationError
23468
23525
  });
23469
- const WsServerSignalProcessRpc = make$52(WS_METHODS.serverSignalProcess, {
23526
+ const WsServerSignalProcessRpc = make$53(WS_METHODS.serverSignalProcess, {
23470
23527
  payload: ServerSignalProcessInput,
23471
23528
  success: ServerSignalProcessResult,
23472
23529
  error: EnvironmentAuthorizationError
23473
23530
  });
23474
- const WsCloudGetRelayClientStatusRpc = make$52(WS_METHODS.cloudGetRelayClientStatus, {
23531
+ const WsCloudGetRelayClientStatusRpc = make$53(WS_METHODS.cloudGetRelayClientStatus, {
23475
23532
  payload: Struct({}),
23476
23533
  success: RelayClientStatusSchema,
23477
23534
  error: EnvironmentAuthorizationError
23478
23535
  });
23479
- const WsCloudInstallRelayClientRpc = make$52(WS_METHODS.cloudInstallRelayClient, {
23536
+ const WsCloudInstallRelayClientRpc = make$53(WS_METHODS.cloudInstallRelayClient, {
23480
23537
  payload: Struct({}),
23481
23538
  success: RelayClientInstallProgressEventSchema,
23482
23539
  error: Union([RelayClientInstallFailedError, EnvironmentAuthorizationError]),
23483
23540
  stream: true
23484
23541
  });
23485
- const WsServerReportClientActivityRpc = make$52(WS_METHODS.serverReportClientActivity, {
23542
+ const WsServerReportClientActivityRpc = make$53(WS_METHODS.serverReportClientActivity, {
23486
23543
  payload: ClientActivityReportInput,
23487
23544
  error: EnvironmentAuthorizationError
23488
23545
  });
23489
- const WsServerReportHostPowerStateRpc = make$52(WS_METHODS.serverReportHostPowerState, {
23546
+ const WsServerReportHostPowerStateRpc = make$53(WS_METHODS.serverReportHostPowerState, {
23490
23547
  payload: HostPowerSnapshot,
23491
23548
  error: EnvironmentAuthorizationError
23492
23549
  });
23493
- const WsServerGetBackgroundPolicyRpc = make$52(WS_METHODS.serverGetBackgroundPolicy, {
23550
+ const WsServerGetBackgroundPolicyRpc = make$53(WS_METHODS.serverGetBackgroundPolicy, {
23494
23551
  payload: Struct({}),
23495
23552
  success: BackgroundPolicySnapshot,
23496
23553
  error: EnvironmentAuthorizationError
23497
23554
  });
23498
- const WsSourceControlLookupRepositoryRpc = make$52(WS_METHODS.sourceControlLookupRepository, {
23555
+ const WsSourceControlLookupRepositoryRpc = make$53(WS_METHODS.sourceControlLookupRepository, {
23499
23556
  payload: SourceControlRepositoryLookupInput,
23500
23557
  success: SourceControlRepositoryInfo,
23501
23558
  error: Union([SourceControlRepositoryError, EnvironmentAuthorizationError])
23502
23559
  });
23503
- const WsSourceControlCloneRepositoryRpc = make$52(WS_METHODS.sourceControlCloneRepository, {
23560
+ const WsSourceControlCloneRepositoryRpc = make$53(WS_METHODS.sourceControlCloneRepository, {
23504
23561
  payload: SourceControlCloneRepositoryInput,
23505
23562
  success: SourceControlCloneRepositoryResult,
23506
23563
  error: Union([SourceControlRepositoryError, EnvironmentAuthorizationError])
23507
23564
  });
23508
- const WsSourceControlPublishRepositoryRpc = make$52(WS_METHODS.sourceControlPublishRepository, {
23565
+ const WsSourceControlPublishRepositoryRpc = make$53(WS_METHODS.sourceControlPublishRepository, {
23509
23566
  payload: SourceControlPublishRepositoryInput,
23510
23567
  success: SourceControlPublishRepositoryResult,
23511
23568
  error: Union([SourceControlRepositoryError, EnvironmentAuthorizationError])
23512
23569
  });
23513
- const WsProjectsSearchEntriesRpc = make$52(WS_METHODS.projectsSearchEntries, {
23570
+ const WsProjectsSearchEntriesRpc = make$53(WS_METHODS.projectsSearchEntries, {
23514
23571
  payload: ProjectSearchEntriesInput,
23515
23572
  success: ProjectSearchEntriesResult,
23516
23573
  error: Union([ProjectSearchEntriesError, EnvironmentAuthorizationError])
23517
23574
  });
23518
- const WsProjectsSearchContentsRpc = make$52(WS_METHODS.projectsSearchContents, {
23575
+ const WsProjectsSearchContentsRpc = make$53(WS_METHODS.projectsSearchContents, {
23519
23576
  payload: ProjectSearchContentsInput,
23520
23577
  success: ProjectSearchContentsResult,
23521
23578
  error: Union([ProjectSearchContentsError, EnvironmentAuthorizationError])
23522
23579
  });
23523
- const WsProjectsListEntriesRpc = make$52(WS_METHODS.projectsListEntries, {
23580
+ const WsProjectsListEntriesRpc = make$53(WS_METHODS.projectsListEntries, {
23524
23581
  payload: ProjectListEntriesInput,
23525
23582
  success: ProjectListEntriesResult,
23526
23583
  error: Union([ProjectListEntriesError, EnvironmentAuthorizationError])
23527
23584
  });
23528
- const WsProjectsReadFileRpc = make$52(WS_METHODS.projectsReadFile, {
23585
+ const WsProjectsReadFileRpc = make$53(WS_METHODS.projectsReadFile, {
23529
23586
  payload: ProjectReadFileInput,
23530
23587
  success: ProjectReadFileResult,
23531
23588
  error: Union([ProjectReadFileError, EnvironmentAuthorizationError])
23532
23589
  });
23533
- const WsProjectsWriteFileRpc = make$52(WS_METHODS.projectsWriteFile, {
23590
+ const WsProjectsWriteFileRpc = make$53(WS_METHODS.projectsWriteFile, {
23534
23591
  payload: ProjectWriteFileInput,
23535
23592
  success: ProjectWriteFileResult,
23536
23593
  error: Union([ProjectWriteFileError, EnvironmentAuthorizationError])
23537
23594
  });
23538
- const WsShellOpenInEditorRpc = make$52(WS_METHODS.shellOpenInEditor, {
23595
+ const WsShellOpenInEditorRpc = make$53(WS_METHODS.shellOpenInEditor, {
23539
23596
  payload: LaunchEditorInput,
23540
23597
  error: Union([ExternalLauncherError, EnvironmentAuthorizationError])
23541
23598
  });
23542
- const WsFilesystemBrowseRpc = make$52(WS_METHODS.filesystemBrowse, {
23599
+ const WsFilesystemBrowseRpc = make$53(WS_METHODS.filesystemBrowse, {
23543
23600
  payload: FilesystemBrowseInput,
23544
23601
  success: FilesystemBrowseResult,
23545
23602
  error: Union([FilesystemBrowseError, EnvironmentAuthorizationError])
23546
23603
  });
23547
- const WsAssetsCreateUrlRpc = make$52(WS_METHODS.assetsCreateUrl, {
23604
+ const WsAgentSessionsScanRpc = make$53(WS_METHODS.agentSessionsScan, {
23605
+ payload: AgentSessionScanInput,
23606
+ success: AgentSessionScanResult,
23607
+ error: Union([AgentSessionScanError, EnvironmentAuthorizationError])
23608
+ });
23609
+ const WsAgentSessionsImportRpc = make$53(WS_METHODS.agentSessionsImport, {
23610
+ payload: AgentSessionImportInput,
23611
+ success: AgentSessionImportResult,
23612
+ error: Union([
23613
+ AgentSessionImportProjectNotFoundError,
23614
+ AgentSessionScanError,
23615
+ EnvironmentAuthorizationError
23616
+ ])
23617
+ });
23618
+ const WsAssetsCreateUrlRpc = make$53(WS_METHODS.assetsCreateUrl, {
23548
23619
  payload: AssetCreateUrlInput,
23549
23620
  success: AssetCreateUrlResult,
23550
23621
  error: Union([AssetAccessError, EnvironmentAuthorizationError])
23551
23622
  });
23552
- const WsSubscribeVcsStatusRpc = make$52(WS_METHODS.subscribeVcsStatus, {
23623
+ const WsSubscribeVcsStatusRpc = make$53(WS_METHODS.subscribeVcsStatus, {
23553
23624
  payload: VcsStatusInput,
23554
23625
  success: VcsStatusStreamEvent,
23555
23626
  error: Union([GitManagerServiceError, EnvironmentAuthorizationError]),
23556
23627
  stream: true
23557
23628
  });
23558
- const WsVcsPullRpc = make$52(WS_METHODS.vcsPull, {
23629
+ const WsVcsPullRpc = make$53(WS_METHODS.vcsPull, {
23559
23630
  payload: VcsPullInput,
23560
23631
  success: VcsPullResult,
23561
23632
  error: Union([GitCommandError, EnvironmentAuthorizationError])
23562
23633
  });
23563
- const WsVcsRefreshStatusRpc = make$52(WS_METHODS.vcsRefreshStatus, {
23634
+ const WsVcsRefreshStatusRpc = make$53(WS_METHODS.vcsRefreshStatus, {
23564
23635
  payload: VcsStatusInput,
23565
23636
  success: VcsStatusResult,
23566
23637
  error: Union([GitManagerServiceError, EnvironmentAuthorizationError])
23567
23638
  });
23568
- const WsGitRunStackedActionRpc = make$52(WS_METHODS.gitRunStackedAction, {
23639
+ const WsGitRunStackedActionRpc = make$53(WS_METHODS.gitRunStackedAction, {
23569
23640
  payload: GitRunStackedActionInput,
23570
23641
  success: GitActionProgressEvent,
23571
23642
  error: Union([GitManagerServiceError, EnvironmentAuthorizationError]),
23572
23643
  stream: true
23573
23644
  });
23574
- const WsGitResolvePullRequestRpc = make$52(WS_METHODS.gitResolvePullRequest, {
23645
+ const WsGitResolvePullRequestRpc = make$53(WS_METHODS.gitResolvePullRequest, {
23575
23646
  payload: GitPullRequestRefInput,
23576
23647
  success: GitResolvePullRequestResult,
23577
23648
  error: Union([GitManagerServiceError, EnvironmentAuthorizationError])
23578
23649
  });
23579
- const WsGitPreparePullRequestThreadRpc = make$52(WS_METHODS.gitPreparePullRequestThread, {
23650
+ const WsGitPreparePullRequestThreadRpc = make$53(WS_METHODS.gitPreparePullRequestThread, {
23580
23651
  payload: GitPreparePullRequestThreadInput,
23581
23652
  success: GitPreparePullRequestThreadResult,
23582
23653
  error: Union([GitManagerServiceError, EnvironmentAuthorizationError])
23583
23654
  });
23584
- const WsVcsListRefsRpc = make$52(WS_METHODS.vcsListRefs, {
23655
+ const WsVcsListRefsRpc = make$53(WS_METHODS.vcsListRefs, {
23585
23656
  payload: VcsListRefsInput,
23586
23657
  success: VcsListRefsResult,
23587
23658
  error: Union([GitCommandError, EnvironmentAuthorizationError])
23588
23659
  });
23589
- const WsVcsCreateWorktreeRpc = make$52(WS_METHODS.vcsCreateWorktree, {
23660
+ const WsVcsCreateWorktreeRpc = make$53(WS_METHODS.vcsCreateWorktree, {
23590
23661
  payload: VcsCreateWorktreeInput,
23591
23662
  success: VcsCreateWorktreeResult,
23592
23663
  error: Union([GitCommandError, EnvironmentAuthorizationError])
23593
23664
  });
23594
- const WsVcsRemoveWorktreeRpc = make$52(WS_METHODS.vcsRemoveWorktree, {
23665
+ const WsVcsRemoveWorktreeRpc = make$53(WS_METHODS.vcsRemoveWorktree, {
23595
23666
  payload: VcsRemoveWorktreeInput,
23596
23667
  error: Union([GitCommandError, EnvironmentAuthorizationError])
23597
23668
  });
23598
- const WsVcsCreateRefRpc = make$52(WS_METHODS.vcsCreateRef, {
23669
+ const WsVcsCreateRefRpc = make$53(WS_METHODS.vcsCreateRef, {
23599
23670
  payload: VcsCreateRefInput,
23600
23671
  success: VcsCreateRefResult,
23601
23672
  error: Union([GitCommandError, EnvironmentAuthorizationError])
23602
23673
  });
23603
- const WsVcsSwitchRefRpc = make$52(WS_METHODS.vcsSwitchRef, {
23674
+ const WsVcsSwitchRefRpc = make$53(WS_METHODS.vcsSwitchRef, {
23604
23675
  payload: VcsSwitchRefInput,
23605
23676
  success: VcsSwitchRefResult,
23606
23677
  error: Union([GitCommandError, EnvironmentAuthorizationError])
23607
23678
  });
23608
- const WsVcsInitRpc = make$52(WS_METHODS.vcsInit, {
23679
+ const WsVcsInitRpc = make$53(WS_METHODS.vcsInit, {
23609
23680
  payload: VcsInitInput,
23610
23681
  error: Union([VcsError, EnvironmentAuthorizationError])
23611
23682
  });
@@ -23614,159 +23685,159 @@ const WsVcsInitRpc = make$52(WS_METHODS.vcsInit, {
23614
23685
  * Not the persisted T3 Review model. Future review sessions should use
23615
23686
  * review.open* + review.getSnapshot.
23616
23687
  */
23617
- const WsReviewGetDiffPreviewRpc = make$52(WS_METHODS.reviewGetDiffPreview, {
23688
+ const WsReviewGetDiffPreviewRpc = make$53(WS_METHODS.reviewGetDiffPreview, {
23618
23689
  payload: ReviewDiffPreviewInput,
23619
23690
  success: ReviewDiffPreviewResult,
23620
23691
  error: Union([ReviewDiffPreviewError, EnvironmentAuthorizationError])
23621
23692
  });
23622
- const WsReviewGetDiffFileContentsRpc = make$52(WS_METHODS.reviewGetDiffFileContents, {
23693
+ const WsReviewGetDiffFileContentsRpc = make$53(WS_METHODS.reviewGetDiffFileContents, {
23623
23694
  payload: ReviewDiffFileContentsInput,
23624
23695
  success: ReviewDiffFileContentsResult,
23625
23696
  error: Union([ReviewDiffPreviewError, EnvironmentAuthorizationError])
23626
23697
  });
23627
- const WsTerminalOpenRpc = make$52(WS_METHODS.terminalOpen, {
23698
+ const WsTerminalOpenRpc = make$53(WS_METHODS.terminalOpen, {
23628
23699
  payload: TerminalOpenInput,
23629
23700
  success: TerminalSessionSnapshot,
23630
23701
  error: Union([TerminalError, EnvironmentAuthorizationError])
23631
23702
  });
23632
- const WsTerminalAttachRpc = make$52(WS_METHODS.terminalAttach, {
23703
+ const WsTerminalAttachRpc = make$53(WS_METHODS.terminalAttach, {
23633
23704
  payload: TerminalAttachInput,
23634
23705
  success: TerminalAttachStreamEvent,
23635
23706
  error: Union([TerminalError, EnvironmentAuthorizationError]),
23636
23707
  stream: true
23637
23708
  });
23638
- const WsTerminalWriteRpc = make$52(WS_METHODS.terminalWrite, {
23709
+ const WsTerminalWriteRpc = make$53(WS_METHODS.terminalWrite, {
23639
23710
  payload: TerminalWriteInput,
23640
23711
  error: Union([TerminalError, EnvironmentAuthorizationError])
23641
23712
  });
23642
- const WsTerminalResizeRpc = make$52(WS_METHODS.terminalResize, {
23713
+ const WsTerminalResizeRpc = make$53(WS_METHODS.terminalResize, {
23643
23714
  payload: TerminalResizeInput,
23644
23715
  error: Union([TerminalError, EnvironmentAuthorizationError])
23645
23716
  });
23646
- const WsTerminalClearRpc = make$52(WS_METHODS.terminalClear, {
23717
+ const WsTerminalClearRpc = make$53(WS_METHODS.terminalClear, {
23647
23718
  payload: TerminalClearInput,
23648
23719
  error: Union([TerminalError, EnvironmentAuthorizationError])
23649
23720
  });
23650
- const WsTerminalRestartRpc = make$52(WS_METHODS.terminalRestart, {
23721
+ const WsTerminalRestartRpc = make$53(WS_METHODS.terminalRestart, {
23651
23722
  payload: TerminalRestartInput,
23652
23723
  success: TerminalSessionSnapshot,
23653
23724
  error: Union([TerminalError, EnvironmentAuthorizationError])
23654
23725
  });
23655
- const WsTerminalCloseRpc = make$52(WS_METHODS.terminalClose, {
23726
+ const WsTerminalCloseRpc = make$53(WS_METHODS.terminalClose, {
23656
23727
  payload: TerminalCloseInput,
23657
23728
  error: Union([TerminalError, EnvironmentAuthorizationError])
23658
23729
  });
23659
- const WsPreviewOpenRpc = make$52(WS_METHODS.previewOpen, {
23730
+ const WsPreviewOpenRpc = make$53(WS_METHODS.previewOpen, {
23660
23731
  payload: PreviewOpenInput,
23661
23732
  success: PreviewSessionSnapshot,
23662
23733
  error: Union([PreviewError, EnvironmentAuthorizationError])
23663
23734
  });
23664
- const WsPreviewNavigateRpc = make$52(WS_METHODS.previewNavigate, {
23735
+ const WsPreviewNavigateRpc = make$53(WS_METHODS.previewNavigate, {
23665
23736
  payload: PreviewNavigateInput,
23666
23737
  success: PreviewSessionSnapshot,
23667
23738
  error: Union([PreviewError, EnvironmentAuthorizationError])
23668
23739
  });
23669
- const WsPreviewResizeRpc = make$52(WS_METHODS.previewResize, {
23740
+ const WsPreviewResizeRpc = make$53(WS_METHODS.previewResize, {
23670
23741
  payload: PreviewResizeInput,
23671
23742
  success: PreviewSessionSnapshot,
23672
23743
  error: Union([PreviewError, EnvironmentAuthorizationError])
23673
23744
  });
23674
- const WsPreviewRefreshRpc = make$52(WS_METHODS.previewRefresh, {
23745
+ const WsPreviewRefreshRpc = make$53(WS_METHODS.previewRefresh, {
23675
23746
  payload: PreviewRefreshInput,
23676
23747
  error: Union([PreviewError, EnvironmentAuthorizationError])
23677
23748
  });
23678
- const WsPreviewCloseRpc = make$52(WS_METHODS.previewClose, {
23749
+ const WsPreviewCloseRpc = make$53(WS_METHODS.previewClose, {
23679
23750
  payload: PreviewCloseInput,
23680
23751
  error: Union([PreviewError, EnvironmentAuthorizationError])
23681
23752
  });
23682
- const WsPreviewListRpc = make$52(WS_METHODS.previewList, {
23753
+ const WsPreviewListRpc = make$53(WS_METHODS.previewList, {
23683
23754
  payload: PreviewListInput,
23684
23755
  success: PreviewListResult,
23685
23756
  error: EnvironmentAuthorizationError
23686
23757
  });
23687
- const WsPreviewReportStatusRpc = make$52(WS_METHODS.previewReportStatus, {
23758
+ const WsPreviewReportStatusRpc = make$53(WS_METHODS.previewReportStatus, {
23688
23759
  payload: PreviewReportStatusInput,
23689
23760
  error: Union([PreviewError, EnvironmentAuthorizationError])
23690
23761
  });
23691
- const WsPreviewAutomationConnectRpc = make$52(WS_METHODS.previewAutomationConnect, {
23762
+ const WsPreviewAutomationConnectRpc = make$53(WS_METHODS.previewAutomationConnect, {
23692
23763
  payload: PreviewAutomationHost,
23693
23764
  success: PreviewAutomationStreamEvent,
23694
23765
  error: Union([PreviewAutomationError, EnvironmentAuthorizationError]),
23695
23766
  stream: true
23696
23767
  });
23697
- const WsPreviewAutomationRespondRpc = make$52(WS_METHODS.previewAutomationRespond, {
23768
+ const WsPreviewAutomationRespondRpc = make$53(WS_METHODS.previewAutomationRespond, {
23698
23769
  payload: PreviewAutomationResponse,
23699
23770
  error: Union([PreviewAutomationError, EnvironmentAuthorizationError])
23700
23771
  });
23701
- const WsPreviewAutomationFocusHostRpc = make$52(WS_METHODS.previewAutomationFocusHost, {
23772
+ const WsPreviewAutomationFocusHostRpc = make$53(WS_METHODS.previewAutomationFocusHost, {
23702
23773
  payload: PreviewAutomationHostFocus,
23703
23774
  error: EnvironmentAuthorizationError
23704
23775
  });
23705
- const WsSubscribePreviewEventsRpc = make$52(WS_METHODS.subscribePreviewEvents, {
23776
+ const WsSubscribePreviewEventsRpc = make$53(WS_METHODS.subscribePreviewEvents, {
23706
23777
  payload: Struct({}),
23707
23778
  success: PreviewEvent,
23708
23779
  error: EnvironmentAuthorizationError,
23709
23780
  stream: true
23710
23781
  });
23711
- const WsSubscribeDiscoveredLocalServersRpc = make$52(WS_METHODS.subscribeDiscoveredLocalServers, {
23782
+ const WsSubscribeDiscoveredLocalServersRpc = make$53(WS_METHODS.subscribeDiscoveredLocalServers, {
23712
23783
  payload: Struct({}),
23713
23784
  success: DiscoveredLocalServerList,
23714
23785
  error: EnvironmentAuthorizationError,
23715
23786
  stream: true
23716
23787
  });
23717
- const WsOrchestrationDispatchCommandRpc = make$52(ORCHESTRATION_WS_METHODS.dispatchCommand, {
23788
+ const WsOrchestrationDispatchCommandRpc = make$53(ORCHESTRATION_WS_METHODS.dispatchCommand, {
23718
23789
  payload: ClientOrchestrationCommand,
23719
23790
  success: OrchestrationRpcSchemas.dispatchCommand.output,
23720
23791
  error: Union([OrchestrationDispatchCommandError, EnvironmentAuthorizationError])
23721
23792
  });
23722
- const WsOrchestrationGetWorkflowScriptRpc = make$52(ORCHESTRATION_WS_METHODS.getWorkflowScript, {
23793
+ const WsOrchestrationGetWorkflowScriptRpc = make$53(ORCHESTRATION_WS_METHODS.getWorkflowScript, {
23723
23794
  payload: OrchestrationRpcSchemas.getWorkflowScript.input,
23724
23795
  success: OrchestrationRpcSchemas.getWorkflowScript.output,
23725
23796
  error: Union([OrchestrationGetWorkflowScriptError, EnvironmentAuthorizationError])
23726
23797
  });
23727
- const WsOrchestrationGetTurnDiffRpc = make$52(ORCHESTRATION_WS_METHODS.getTurnDiff, {
23798
+ const WsOrchestrationGetTurnDiffRpc = make$53(ORCHESTRATION_WS_METHODS.getTurnDiff, {
23728
23799
  payload: OrchestrationGetTurnDiffInput,
23729
23800
  success: OrchestrationRpcSchemas.getTurnDiff.output,
23730
23801
  error: Union([OrchestrationGetTurnDiffError, EnvironmentAuthorizationError])
23731
23802
  });
23732
- const WsOrchestrationGetFullThreadDiffRpc = make$52(ORCHESTRATION_WS_METHODS.getFullThreadDiff, {
23803
+ const WsOrchestrationGetFullThreadDiffRpc = make$53(ORCHESTRATION_WS_METHODS.getFullThreadDiff, {
23733
23804
  payload: OrchestrationGetFullThreadDiffInput,
23734
23805
  success: OrchestrationRpcSchemas.getFullThreadDiff.output,
23735
23806
  error: Union([OrchestrationGetFullThreadDiffError, EnvironmentAuthorizationError])
23736
23807
  });
23737
- const WsOrchestrationSearchThreadsRpc = make$52(ORCHESTRATION_WS_METHODS.searchThreads, {
23808
+ const WsOrchestrationSearchThreadsRpc = make$53(ORCHESTRATION_WS_METHODS.searchThreads, {
23738
23809
  payload: OrchestrationSearchThreadsInput,
23739
23810
  success: OrchestrationRpcSchemas.searchThreads.output,
23740
23811
  error: Union([OrchestrationSearchThreadsError, EnvironmentAuthorizationError])
23741
23812
  });
23742
- const WsOrchestrationGetArchivedShellSnapshotRpc = make$52(ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot, {
23813
+ const WsOrchestrationGetArchivedShellSnapshotRpc = make$53(ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot, {
23743
23814
  payload: OrchestrationRpcSchemas.getArchivedShellSnapshot.input,
23744
23815
  success: OrchestrationRpcSchemas.getArchivedShellSnapshot.output,
23745
23816
  error: Union([OrchestrationGetSnapshotError, EnvironmentAuthorizationError])
23746
23817
  });
23747
- const WsOrchestrationSubscribeShellRpc = make$52(ORCHESTRATION_WS_METHODS.subscribeShell, {
23818
+ const WsOrchestrationSubscribeShellRpc = make$53(ORCHESTRATION_WS_METHODS.subscribeShell, {
23748
23819
  payload: OrchestrationRpcSchemas.subscribeShell.input,
23749
23820
  success: OrchestrationRpcSchemas.subscribeShell.output,
23750
23821
  error: Union([OrchestrationGetSnapshotError, EnvironmentAuthorizationError]),
23751
23822
  stream: true
23752
23823
  });
23753
- const WsOrchestrationSubscribeThreadRpc = make$52(ORCHESTRATION_WS_METHODS.subscribeThread, {
23824
+ const WsOrchestrationSubscribeThreadRpc = make$53(ORCHESTRATION_WS_METHODS.subscribeThread, {
23754
23825
  payload: OrchestrationRpcSchemas.subscribeThread.input,
23755
23826
  success: OrchestrationRpcSchemas.subscribeThread.output,
23756
23827
  error: Union([OrchestrationGetSnapshotError, EnvironmentAuthorizationError]),
23757
23828
  stream: true
23758
23829
  });
23759
- const WsRpcGroup = make$51(WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpdateServerWithProgressRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsServerSignalProcessRpc, WsServerReportClientActivityRpc, WsServerReportHostPowerStateRpc, WsServerGetBackgroundPolicyRpc, WsPortProxyListRpc, WsPortProxyAuthorizeRpc, WsPortProxyRevokeRpc, WsCloudGetRelayClientStatusRpc, WsCloudInstallRelayClientRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsReviewGetDiffFileContentsRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, make$52(WS_METHODS.subscribeTerminalEvents, {
23830
+ const WsRpcGroup = make$52(WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpdateServerWithProgressRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsServerSignalProcessRpc, WsServerReportClientActivityRpc, WsServerReportHostPowerStateRpc, WsServerGetBackgroundPolicyRpc, WsPortProxyListRpc, WsPortProxyAuthorizeRpc, WsPortProxyRevokeRpc, WsCloudGetRelayClientStatusRpc, WsCloudInstallRelayClientRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAgentSessionsScanRpc, WsAgentSessionsImportRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsReviewGetDiffFileContentsRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, make$53(WS_METHODS.subscribeTerminalEvents, {
23760
23831
  payload: Struct({}),
23761
23832
  success: TerminalEvent,
23762
23833
  error: EnvironmentAuthorizationError,
23763
23834
  stream: true
23764
- }), make$52(WS_METHODS.subscribeTerminalMetadata, {
23835
+ }), make$53(WS_METHODS.subscribeTerminalMetadata, {
23765
23836
  payload: Struct({}),
23766
23837
  success: TerminalMetadataStreamEvent,
23767
23838
  error: EnvironmentAuthorizationError,
23768
23839
  stream: true
23769
- }), WsPreviewOpenRpc, WsPreviewNavigateRpc, WsPreviewResizeRpc, WsPreviewRefreshRpc, WsPreviewCloseRpc, WsPreviewListRpc, WsPreviewReportStatusRpc, WsPreviewAutomationConnectRpc, WsPreviewAutomationRespondRpc, WsPreviewAutomationFocusHostRpc, WsSubscribePreviewEventsRpc, WsSubscribeDiscoveredLocalServersRpc, make$52(WS_METHODS.subscribeServerConfig, {
23840
+ }), WsPreviewOpenRpc, WsPreviewNavigateRpc, WsPreviewResizeRpc, WsPreviewRefreshRpc, WsPreviewCloseRpc, WsPreviewListRpc, WsPreviewReportStatusRpc, WsPreviewAutomationConnectRpc, WsPreviewAutomationRespondRpc, WsPreviewAutomationFocusHostRpc, WsSubscribePreviewEventsRpc, WsSubscribeDiscoveredLocalServersRpc, make$53(WS_METHODS.subscribeServerConfig, {
23770
23841
  payload: Struct({}),
23771
23842
  success: ServerConfigStreamEvent,
23772
23843
  error: Union([
@@ -23775,39 +23846,39 @@ const WsRpcGroup = make$51(WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefre
23775
23846
  EnvironmentAuthorizationError
23776
23847
  ]),
23777
23848
  stream: true
23778
- }), make$52(WS_METHODS.subscribeServerLifecycle, {
23849
+ }), make$53(WS_METHODS.subscribeServerLifecycle, {
23779
23850
  payload: Struct({}),
23780
23851
  success: ServerLifecycleStreamEvent,
23781
23852
  error: EnvironmentAuthorizationError,
23782
23853
  stream: true
23783
- }), make$52(WS_METHODS.subscribeAuthAccess, {
23854
+ }), make$53(WS_METHODS.subscribeAuthAccess, {
23784
23855
  payload: Struct({}),
23785
23856
  success: AuthAccessStreamEvent,
23786
23857
  error: Union([AuthAccessStreamError, EnvironmentAuthorizationError]),
23787
23858
  stream: true
23788
- }), make$52(WS_METHODS.subscribeBackgroundPolicy, {
23859
+ }), make$53(WS_METHODS.subscribeBackgroundPolicy, {
23789
23860
  payload: Struct({}),
23790
23861
  success: BackgroundPolicySnapshot,
23791
23862
  error: EnvironmentAuthorizationError,
23792
23863
  stream: true
23793
- }), make$52(WS_METHODS.subscribeResourceTelemetry, {
23864
+ }), make$53(WS_METHODS.subscribeResourceTelemetry, {
23794
23865
  payload: Struct({}),
23795
23866
  success: ResourceTelemetrySnapshot,
23796
23867
  error: EnvironmentAuthorizationError,
23797
23868
  stream: true
23798
- }), make$52(WS_METHODS.voiceInputStart, {
23869
+ }), make$53(WS_METHODS.voiceInputStart, {
23799
23870
  payload: VoiceInputThread,
23800
23871
  success: Struct({}),
23801
23872
  error: Union([VoiceInputUnavailableError, EnvironmentAuthorizationError])
23802
- }), make$52(WS_METHODS.voiceInputAppendAudio, {
23873
+ }), make$53(WS_METHODS.voiceInputAppendAudio, {
23803
23874
  payload: VoiceInputAudio,
23804
23875
  success: Struct({}),
23805
23876
  error: Union([VoiceInputUnavailableError, EnvironmentAuthorizationError])
23806
- }), make$52(WS_METHODS.voiceInputStop, {
23877
+ }), make$53(WS_METHODS.voiceInputStop, {
23807
23878
  payload: VoiceInputThread,
23808
23879
  success: Struct({}),
23809
23880
  error: Union([VoiceInputUnavailableError, EnvironmentAuthorizationError])
23810
- }), make$52(WS_METHODS.subscribeVoiceInputTranscript, {
23881
+ }), make$53(WS_METHODS.subscribeVoiceInputTranscript, {
23811
23882
  payload: VoiceInputThread,
23812
23883
  success: VoiceInputTranscriptEvent,
23813
23884
  error: Union([VoiceInputUnavailableError, EnvironmentAuthorizationError]),
@@ -23875,8 +23946,8 @@ var ServerConfig = class extends Service$2()("t3/config/ServerConfig") {
23875
23946
  /** @deprecated Import and use `layerTest` from this module. */
23876
23947
  static layerTest = (cwd, baseDirOrPrefix) => layerTest$2(cwd, baseDirOrPrefix);
23877
23948
  };
23878
- const make$50 = (config) => ServerConfig.of(config);
23879
- const layer$40 = (config) => succeed$3(ServerConfig, make$50(config));
23949
+ const make$51 = (config) => ServerConfig.of(config);
23950
+ const layer$42 = (config) => succeed$3(ServerConfig, make$51(config));
23880
23951
  const deriveServerPaths = fn(function* (baseDir, devUrl, options = {}) {
23881
23952
  const { join } = yield* Path;
23882
23953
  const stateDir = join(baseDir, devUrl !== void 0 && !options.baseDirIsExplicit ? "dev" : "userdata");
@@ -24072,7 +24143,7 @@ function deriveAuthClientMetadata(input) {
24072
24143
  //#endregion
24073
24144
  //#region src/auth/EnvironmentAuthPolicy.ts
24074
24145
  var EnvironmentAuthPolicy = class extends Service$2()("t3/auth/EnvironmentAuthPolicy") {};
24075
- const layer$39 = effect(EnvironmentAuthPolicy, gen(function* () {
24146
+ const layer$41 = effect(EnvironmentAuthPolicy, gen(function* () {
24076
24147
  const config = yield* ServerConfig;
24077
24148
  const isRemoteReachable = isRemoteReachableHost(config.host);
24078
24149
  const policy = config.mode === "desktop" ? isRemoteReachable ? "remote-reachable" : "desktop-managed-local" : isRemoteReachable ? "remote-reachable" : "loopback-browser";
@@ -24284,7 +24355,7 @@ function toPersistenceSqlOrDecodeError$6(sqlOperation, decodeOperation, correlat
24284
24355
  cause
24285
24356
  });
24286
24357
  }
24287
- const layer$38 = effect(AuthPairingLinkRepository, gen(function* () {
24358
+ const layer$40 = effect(AuthPairingLinkRepository, gen(function* () {
24288
24359
  const sql = yield* SqlClient;
24289
24360
  const createPairingLinkRow = void_({
24290
24361
  Request: CreateAuthPairingLinkInput,
@@ -24512,11 +24583,11 @@ const DEV_STARTUP_TTL_HOURS = hours(24);
24512
24583
  const PAIRING_TOKEN_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
24513
24584
  const PAIRING_TOKEN_LENGTH = 12;
24514
24585
  const PAIRING_TOKEN_REJECTION_LIMIT = Math.floor(256 / 32) * 32;
24515
- const layer$37 = effect(PairingGrantStore, gen(function* () {
24586
+ const layer$39 = effect(PairingGrantStore, gen(function* () {
24516
24587
  const crypto = yield* Crypto;
24517
24588
  const config = yield* ServerConfig;
24518
24589
  const pairingLinks = yield* AuthPairingLinkRepository;
24519
- const seededGrantsRef = yield* make$64(/* @__PURE__ */ new Map());
24590
+ const seededGrantsRef = yield* make$65(/* @__PURE__ */ new Map());
24520
24591
  const changesPubSub = yield* unbounded$1();
24521
24592
  const generatePairingToken = gen(function* () {
24522
24593
  let credential = "";
@@ -24709,7 +24780,7 @@ const layer$37 = effect(PairingGrantStore, gen(function* () {
24709
24780
  revoke,
24710
24781
  consume
24711
24782
  });
24712
- })).pipe(provideMerge(layer$38));
24783
+ })).pipe(provideMerge(layer$40));
24713
24784
  //#endregion
24714
24785
  //#region src/auth/ServerSecretStore.ts
24715
24786
  const secretStoreErrorContext = {
@@ -24775,7 +24846,7 @@ const isSecretStoreError = is(Union([
24775
24846
  const isPlatformError = (value) => isTagged(value, "PlatformError");
24776
24847
  const isSecretAlreadyExistsError = (error) => "cause" in error && isPlatformError(error.cause) && error.cause.reason._tag === "AlreadyExists";
24777
24848
  var ServerSecretStore = class extends Service$2()("t3/auth/ServerSecretStore") {};
24778
- const layer$36 = effect(ServerSecretStore, gen(function* () {
24849
+ const layer$38 = effect(ServerSecretStore, gen(function* () {
24779
24850
  const crypto = yield* Crypto;
24780
24851
  const fileSystem = yield* FileSystem;
24781
24852
  const path = yield* Path;
@@ -24956,7 +25027,7 @@ function toPersistenceSqlOrDecodeError$5(sqlOperation, decodeOperation, correlat
24956
25027
  cause
24957
25028
  });
24958
25029
  }
24959
- const layer$35 = effect(AuthSessionRepository, gen(function* () {
25030
+ const layer$37 = effect(AuthSessionRepository, gen(function* () {
24960
25031
  const sql = yield* SqlClient;
24961
25032
  const createSessionRow = void_({
24962
25033
  Request: CreateAuthSessionInput,
@@ -25322,13 +25393,13 @@ function toAuthClientSession(input) {
25322
25393
  current: false
25323
25394
  };
25324
25395
  }
25325
- const layer$34 = effect(SessionStore, gen(function* () {
25396
+ const layer$36 = effect(SessionStore, gen(function* () {
25326
25397
  const crypto = yield* Crypto;
25327
25398
  const serverConfig = yield* ServerConfig;
25328
25399
  const secretStore = yield* ServerSecretStore;
25329
25400
  const authSessions = yield* AuthSessionRepository;
25330
25401
  const signingSecret = yield* secretStore.getOrCreateRandom(SIGNING_SECRET_NAME$1, 32);
25331
- const connectedSessionsRef = yield* make$64(/* @__PURE__ */ new Map());
25402
+ const connectedSessionsRef = yield* make$65(/* @__PURE__ */ new Map());
25332
25403
  const changesPubSub = yield* unbounded$1();
25333
25404
  const cookieName = resolveSessionCookieName({
25334
25405
  mode: serverConfig.mode,
@@ -25455,7 +25526,7 @@ const layer$34 = effect(SessionStore, gen(function* () {
25455
25526
  if (!timingSafeEqualBase64Url(signature, signPayload(encodedPayload, signingSecret))) return yield* new InvalidSessionTokenSignatureError({});
25456
25527
  const claims = yield* decodeSessionClaims(base64UrlDecodeUtf8(encodedPayload)).pipe(mapError((cause) => new InvalidSessionTokenPayloadError({ cause })));
25457
25528
  const observedAt = yield* now$1;
25458
- const expiresAt = make$72(claims.exp);
25529
+ const expiresAt = make$73(claims.exp);
25459
25530
  if (isNone(expiresAt)) return yield* new InvalidSessionExpirationClaimError({
25460
25531
  sessionId: claims.sid,
25461
25532
  expirationClaim: claims.exp
@@ -25515,7 +25586,7 @@ const layer$34 = effect(SessionStore, gen(function* () {
25515
25586
  if (!timingSafeEqualBase64Url(signature, signPayload(encodedPayload, signingSecret))) return yield* new InvalidWebSocketTokenSignatureError({});
25516
25587
  const claims = yield* decodeWebSocketClaims(base64UrlDecodeUtf8(encodedPayload)).pipe(mapError((cause) => new InvalidWebSocketTokenPayloadError({ cause })));
25517
25588
  const observedAt = yield* now$1;
25518
- const expiresAt = make$72(claims.exp);
25589
+ const expiresAt = make$73(claims.exp);
25519
25590
  if (isNone(expiresAt)) return yield* new InvalidSessionExpirationClaimError({
25520
25591
  sessionId: claims.sid,
25521
25592
  expirationClaim: claims.exp
@@ -25620,7 +25691,7 @@ const layer$34 = effect(SessionStore, gen(function* () {
25620
25691
  markConnected,
25621
25692
  markDisconnected
25622
25693
  });
25623
- })).pipe(provideMerge(layer$35));
25694
+ })).pipe(provideMerge(layer$37));
25624
25695
  //#endregion
25625
25696
  //#region ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/cryptoNode.js
25626
25697
  /**
@@ -28406,7 +28477,7 @@ var MigrationError = class extends TaggedError("MigrationError") {};
28406
28477
  * @category constructors
28407
28478
  * @since 4.0.0
28408
28479
  */
28409
- const make$43 = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, table = "effect_sql_migrations" }) => gen(function* () {
28480
+ const make$44 = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, table = "effect_sql_migrations" }) => gen(function* () {
28410
28481
  const sql = yield* SqlClient;
28411
28482
  const ensureMigrationsTable = sql.onDialectOrElse({
28412
28483
  mssql: () => sql`IF OBJECT_ID(N'${sql.literal(table)}', N'U') IS NULL
@@ -28495,7 +28566,7 @@ const make$43 = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory,
28495
28566
  if (schemaDirectory && completed.length > 0) yield* dumpSchema(`${schemaDirectory}/_schema.sql`, table).pipe(catchCause((cause) => logInfo("Could not dump schema", cause)));
28496
28567
  return completed;
28497
28568
  });
28498
- const migrationOrder = /*#__PURE__*/ make$73(([a], [b]) => Number$2(a, b));
28569
+ const migrationOrder = /*#__PURE__*/ make$74(([a], [b]) => Number$2(a, b));
28499
28570
  const isConstraintConflict = (error) => error.reason._tag === "ConstraintError" || error.reason._tag === "UniqueViolation";
28500
28571
  /**
28501
28572
  * Creates a migration loader from a record of migration effects keyed by
@@ -30062,7 +30133,7 @@ const makeMigrationLoader = (throughId) => fromRecord(Object.fromEntries(migrati
30062
30133
  * Migrator run function - no schema dumping needed
30063
30134
  * Uses the base Migrator.make without platform dependencies
30064
30135
  */
30065
- const run = make$43({});
30136
+ const run = make$44({});
30066
30137
  /**
30067
30138
  * Run all pending migrations.
30068
30139
  *
@@ -30084,7 +30155,7 @@ effectDiscard(runMigrations());
30084
30155
  //#region src/persistence/Layers/Sqlite.ts
30085
30156
  const defaultSqliteClientLoaders = {
30086
30157
  bun: () => import("@effect/sql-sqlite-bun/SqliteClient"),
30087
- node: () => import("./NodeSqliteClient-FfrElFAX.mjs")
30158
+ node: () => import("./NodeSqliteClient-BEJTWT28.mjs")
30088
30159
  };
30089
30160
  const makeRuntimeSqliteLayer = fn("makeRuntimeSqliteLayer")(function* (config) {
30090
30161
  const runtime = process.versions.bun !== void 0 ? "bun" : "node";
@@ -30309,7 +30380,7 @@ function parseDpopToken(request) {
30309
30380
  const token = header.slice(5).trim();
30310
30381
  return token.length > 0 ? token : null;
30311
30382
  }
30312
- const layer$33 = effect(EnvironmentAuth, gen(function* () {
30383
+ const layer$35 = effect(EnvironmentAuth, gen(function* () {
30313
30384
  const policy = yield* EnvironmentAuthPolicy;
30314
30385
  const bootstrapCredentials = yield* PairingGrantStore;
30315
30386
  const sessions = yield* SessionStore;
@@ -30517,9 +30588,9 @@ const layer$33 = effect(EnvironmentAuth, gen(function* () {
30517
30588
  issueWebSocketTicket,
30518
30589
  issueStartupPairingUrl
30519
30590
  });
30520
- })).pipe(provideMerge(layer$37), provideMerge(layer$34), provideMerge(layer$39));
30521
- const storageLayer = mergeAll(layer$36, layerConfig);
30522
- const runtimeLayer = layer$33.pipe(provideMerge(storageLayer));
30591
+ })).pipe(provideMerge(layer$39), provideMerge(layer$36), provideMerge(layer$41));
30592
+ const storageLayer = mergeAll(layer$38, layerConfig);
30593
+ const runtimeLayer = layer$35.pipe(provideMerge(storageLayer));
30523
30594
  //#endregion
30524
30595
  //#region src/cliAuthFormat.ts
30525
30596
  const newline = "\n";
@@ -31916,7 +31987,7 @@ const runWithEnvironmentAuth = (flags, run, options) => gen(function* () {
31916
31987
  const minimumLogLevel = options?.quietLogs ? "Error" : config.logLevel;
31917
31988
  return yield* gen(function* () {
31918
31989
  return yield* run(yield* EnvironmentAuth);
31919
- }).pipe(provide$1(mergeAll(runtimeLayer).pipe(provide(layer$40(config)), provide(succeed$3(MinimumLogLevel, minimumLogLevel)))));
31990
+ }).pipe(provide$1(mergeAll(runtimeLayer).pipe(provide(layer$42(config)), provide(succeed$3(MinimumLogLevel, minimumLogLevel)))));
31920
31991
  });
31921
31992
  const ttlFlag$1 = string("ttl").pipe(withSchema(DurationFromString), withDescription$1("TTL, for example `5m`, `1h`, `30d`, or `15 minutes`."), optional);
31922
31993
  const jsonFlag = boolean("json").pipe(withDescription$1("Emit JSON instead of human-readable output."), withDefault(false));
@@ -31924,7 +31995,7 @@ const labelFlag$1 = string("label").pipe(withDescription$1("Optional human-reada
31924
31995
  const subjectFlag = string("subject").pipe(withDescription$1("Optional session subject."), optional);
31925
31996
  const baseUrlFlag = string("base-url").pipe(withDescription$1("Optional public base URL used to print a ready `/pair#token=...` link."), optional);
31926
31997
  const tokenOnlyFlag = boolean("token-only").pipe(withDescription$1("Print only the issued bearer token."), withDefault(false));
31927
- const pairingCreateCommand = make$63("create", {
31998
+ const pairingCreateCommand = make$64("create", {
31928
31999
  ...authLocationFlags,
31929
32000
  ttl: ttlFlag$1,
31930
32001
  label: labelFlag$1,
@@ -31942,26 +32013,26 @@ const pairingCreateCommand = make$63("create", {
31942
32013
  });
31943
32014
  yield* log(output);
31944
32015
  }), { quietLogs: flags.json })));
31945
- const pairingListCommand = make$63("list", {
32016
+ const pairingListCommand = make$64("list", {
31946
32017
  ...authLocationFlags,
31947
32018
  json: jsonFlag
31948
32019
  }).pipe(withDescription("List active client pairing tokens without revealing their secrets."), withHandler((flags) => runWithEnvironmentAuth(flags, (environmentAuth) => gen(function* () {
31949
32020
  const pairingLinks = yield* environmentAuth.listPairingLinks({ excludeSubjects: [INTERNAL_ADMINISTRATIVE_BOOTSTRAP_SUBJECT] });
31950
32021
  yield* log(formatPairingCredentialList(pairingLinks, { json: flags.json }));
31951
32022
  }), { quietLogs: flags.json })));
31952
- const pairingRevokeCommand = make$63("revoke", {
32023
+ const pairingRevokeCommand = make$64("revoke", {
31953
32024
  ...authLocationFlags,
31954
32025
  id: string$1("id").pipe(withDescription$2("Pairing credential id to revoke."))
31955
32026
  }).pipe(withDescription("Revoke an active client pairing token."), withHandler((flags) => runWithEnvironmentAuth(flags, (environmentAuth) => gen(function* () {
31956
32027
  const revoked = yield* environmentAuth.revokePairingLink(flags.id);
31957
32028
  yield* log(revoked ? `Revoked pairing credential ${flags.id}.\n` : `No active pairing credential found for ${flags.id}.\n`);
31958
32029
  }))));
31959
- const pairingCommand = make$63("pairing").pipe(withDescription("Manage one-time client pairing tokens."), withSubcommands([
32030
+ const pairingCommand = make$64("pairing").pipe(withDescription("Manage one-time client pairing tokens."), withSubcommands([
31960
32031
  pairingCreateCommand,
31961
32032
  pairingListCommand,
31962
32033
  pairingRevokeCommand
31963
32034
  ]));
31964
- const sessionIssueCommand = make$63("issue", {
32035
+ const sessionIssueCommand = make$64("issue", {
31965
32036
  ...authLocationFlags,
31966
32037
  ttl: ttlFlag$1,
31967
32038
  label: labelFlag$1,
@@ -31980,26 +32051,26 @@ const sessionIssueCommand = make$63("issue", {
31980
32051
  tokenOnly: flags.tokenOnly
31981
32052
  }));
31982
32053
  }), { quietLogs: flags.json || flags.tokenOnly })));
31983
- const sessionListCommand = make$63("list", {
32054
+ const sessionListCommand = make$64("list", {
31984
32055
  ...authLocationFlags,
31985
32056
  json: jsonFlag
31986
32057
  }).pipe(withDescription("List active sessions without revealing bearer tokens."), withHandler((flags) => runWithEnvironmentAuth(flags, (environmentAuth) => gen(function* () {
31987
32058
  const sessions = yield* environmentAuth.listSessions();
31988
32059
  yield* log(formatSessionList(sessions, { json: flags.json }));
31989
32060
  }), { quietLogs: flags.json })));
31990
- const sessionRevokeCommand = make$63("revoke", {
32061
+ const sessionRevokeCommand = make$64("revoke", {
31991
32062
  ...authLocationFlags,
31992
32063
  sessionId: string$1("session-id").pipe(withDescription$2("Session id to revoke."), withSchema$1(AuthSessionId))
31993
32064
  }).pipe(withDescription("Revoke an active session."), withHandler((flags) => runWithEnvironmentAuth(flags, (environmentAuth) => gen(function* () {
31994
32065
  const revoked = yield* environmentAuth.revokeSession(flags.sessionId);
31995
32066
  yield* log(revoked ? `Revoked session ${flags.sessionId}.\n` : `No active session found for ${flags.sessionId}.\n`);
31996
32067
  }))));
31997
- const sessionCommand = make$63("session").pipe(withDescription("Manage bearer sessions."), withSubcommands([
32068
+ const sessionCommand = make$64("session").pipe(withDescription("Manage bearer sessions."), withSubcommands([
31998
32069
  sessionIssueCommand,
31999
32070
  sessionListCommand,
32000
32071
  sessionRevokeCommand
32001
32072
  ]));
32002
- const authCommand = make$63("auth").pipe(withDescription("Manage the local auth control plane for headless deployments."), withSubcommands([pairingCommand, sessionCommand]));
32073
+ const authCommand = make$64("auth").pipe(withDescription("Manage the local auth control plane for headless deployments."), withSubcommands([pairingCommand, sessionCommand]));
32003
32074
  //#endregion
32004
32075
  //#region ../t3-shared/src/devHome.ts
32005
32076
  /**
@@ -32187,7 +32258,7 @@ const readTailscaleStatus = gen(function* () {
32187
32258
  argumentCount: args.length
32188
32259
  };
32189
32260
  return yield* gen(function* () {
32190
- const child = yield* spawner.spawn(make$80(executable, args)).pipe(mapError((cause) => new TailscaleCommandSpawnError({
32261
+ const child = yield* spawner.spawn(make$81(executable, args)).pipe(mapError((cause) => new TailscaleCommandSpawnError({
32191
32262
  ...commandContext,
32192
32263
  cause
32193
32264
  })));
@@ -32231,7 +32302,7 @@ const runTailscaleCommand = (args, timeoutInput) => gen(function* () {
32231
32302
  };
32232
32303
  const timeout$1 = fromInputUnsafe(timeoutInput);
32233
32304
  return yield* gen(function* () {
32234
- const child = yield* spawner.spawn(make$80(executable, args)).pipe(mapError((cause) => new TailscaleCommandSpawnError({
32305
+ const child = yield* spawner.spawn(make$81(executable, args)).pipe(mapError((cause) => new TailscaleCommandSpawnError({
32235
32306
  ...commandContext,
32236
32307
  cause
32237
32308
  })));
@@ -33448,7 +33519,7 @@ const makePairServerConfig = fn(function* (input) {
33448
33519
  const { baseDir, variant, state } = input.target;
33449
33520
  const devUrl = state.devUrl !== void 0 ? new URL(state.devUrl) : void 0;
33450
33521
  const derivedPaths = yield* deriveServerPaths(baseDir, variant === "dev" ? DEV_VARIANT_PLACEHOLDER_URL : void 0, {});
33451
- return make$50({
33522
+ return make$51({
33452
33523
  logLevel: input.logLevel,
33453
33524
  traceMinLevel: "Info",
33454
33525
  traceTimingEnabled: false,
@@ -33534,9 +33605,9 @@ const mintPairingLink = fn("pair.mintPairingLink")(function* (input) {
33534
33605
  label: getOrElse(input.label, () => "t3 pair"),
33535
33606
  ...isSome(input.ttl) ? { ttl: input.ttl.value } : {}
33536
33607
  });
33537
- }).pipe(provide$1(runtimeLayer.pipe(provide(layer$40(input.config)), provide(succeed$3(MinimumLogLevel, input.config.logLevel)))));
33608
+ }).pipe(provide$1(runtimeLayer.pipe(provide(layer$42(input.config)), provide(succeed$3(MinimumLogLevel, input.config.logLevel)))));
33538
33609
  });
33539
- const pairCommand = make$63("pair", {
33610
+ const pairCommand = make$64("pair", {
33540
33611
  baseDir: baseDirFlag,
33541
33612
  ttl: string("ttl").pipe(withSchema(DurationFromString), withDescription$1("Token TTL, for example `5m`, `1h`, or `15 minutes`. Defaults to 5 minutes."), optional),
33542
33613
  label: string("label").pipe(withDescription$1("Optional label shown in the server's connections list."), optional),
@@ -33577,7 +33648,7 @@ const pairCommand = make$63("pair", {
33577
33648
  expiresAt: issued.expiresAt,
33578
33649
  notes
33579
33650
  }));
33580
- }).pipe(provide$1(layer$44))));
33651
+ }).pipe(provide$1(layer$46))));
33581
33652
  //#endregion
33582
33653
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/encoding/Sse.js
33583
33654
  const SseErrorTypeId = "~effect/encoding/Sse/SseError";
@@ -33923,7 +33994,7 @@ const makeClient = (api, options) => gen(function* () {
33923
33994
  const encodeQuery = map$3(endpoint.query, encodeUnknownEffect);
33924
33995
  const middlewareKeys = Array.from(onEndpointOptions.middleware, (tag) => `${tag.key}/Client`);
33925
33996
  const endpointFn = fnUntraced(function* (request) {
33926
- let httpRequest = make$65(endpoint.method)(endpoint.path);
33997
+ let httpRequest = make$66(endpoint.method)(endpoint.path);
33927
33998
  if (request !== void 0) {
33928
33999
  if (encodeParams !== void 0) {
33929
34000
  const params = yield* encodeParams(request.params);
@@ -33966,7 +34037,7 @@ const makeClient = (api, options) => gen(function* () {
33966
34037
  * @category constructors
33967
34038
  * @since 4.0.0
33968
34039
  */
33969
- const make$41 = (api, options) => flatMap$1(HttpClient, (httpClient) => makeWith(api, {
34040
+ const make$42 = (api, options) => flatMap$1(HttpClient, (httpClient) => makeWith(api, {
33970
34041
  ...options,
33971
34042
  httpClient: options?.transformClient ? options.transformClient(httpClient) : httpClient
33972
34043
  }));
@@ -34716,19 +34787,19 @@ function decodeForEvent(schema, value, eventType, field) {
34716
34787
  function retainThreadMessagesAfterRevert(messages, retainedTurnIds, turnCount) {
34717
34788
  const retainedMessageIds = /* @__PURE__ */ new Set();
34718
34789
  for (const message of messages) {
34719
- if (message.role === "system") {
34790
+ if (message.role === "system" || isImportedAgentSessionMessageId(message.id)) {
34720
34791
  retainedMessageIds.add(message.id);
34721
34792
  continue;
34722
34793
  }
34723
34794
  if (message.turnId !== null && retainedTurnIds.has(message.turnId)) retainedMessageIds.add(message.id);
34724
34795
  }
34725
- const retainedUserCount = messages.filter((message) => message.role === "user" && retainedMessageIds.has(message.id)).length;
34796
+ const retainedUserCount = messages.filter((message) => message.role === "user" && !isImportedAgentSessionMessageId(message.id) && retainedMessageIds.has(message.id)).length;
34726
34797
  const missingUserCount = Math.max(0, turnCount - retainedUserCount);
34727
34798
  if (missingUserCount > 0) {
34728
34799
  const fallbackUserMessages = messages.filter((message) => message.role === "user" && !retainedMessageIds.has(message.id) && (message.turnId === null || retainedTurnIds.has(message.turnId))).toSorted((left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)).slice(0, missingUserCount);
34729
34800
  for (const message of fallbackUserMessages) retainedMessageIds.add(message.id);
34730
34801
  }
34731
- const retainedAssistantCount = messages.filter((message) => message.role === "assistant" && retainedMessageIds.has(message.id)).length;
34802
+ const retainedAssistantCount = messages.filter((message) => message.role === "assistant" && !isImportedAgentSessionMessageId(message.id) && retainedMessageIds.has(message.id)).length;
34732
34803
  const missingAssistantCount = Math.max(0, turnCount - retainedAssistantCount);
34733
34804
  if (missingAssistantCount > 0) {
34734
34805
  const fallbackAssistantMessages = messages.filter((message) => message.role === "assistant" && !retainedMessageIds.has(message.id) && (message.turnId === null || retainedTurnIds.has(message.turnId))).toSorted((left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)).slice(0, missingAssistantCount);
@@ -35120,7 +35191,7 @@ function hasOpenBlockingRequest(thread) {
35120
35191
  * minutes.
35121
35192
  */
35122
35193
  function threadHasQueuedTurnStart(thread, occurredAt) {
35123
- const latestUserMessageAtMs = thread.messages.reduce((latest, message) => message.role === "user" ? Math.max(latest, Date.parse(message.createdAt)) : latest, Number.NEGATIVE_INFINITY);
35194
+ const latestUserMessageAtMs = thread.messages.reduce((latest, message) => message.role === "user" && !isImportedAgentSessionMessageId(message.id) ? Math.max(latest, Date.parse(message.createdAt)) : latest, Number.NEGATIVE_INFINITY);
35124
35195
  const latestTurnAtMs = thread.latestTurn === null ? Number.NEGATIVE_INFINITY : Math.max(...[
35125
35196
  thread.latestTurn.requestedAt,
35126
35197
  thread.latestTurn.startedAt,
@@ -35939,6 +36010,60 @@ const decideOrchestrationCommand = fn("decideOrchestrationCommand")(function* ({
35939
36010
  updatedAt: command.createdAt
35940
36011
  }
35941
36012
  };
36013
+ case "thread.history.import": {
36014
+ const thread = yield* requireThread({
36015
+ readModel,
36016
+ command,
36017
+ threadId: command.threadId
36018
+ });
36019
+ if (thread.deletedAt !== null || thread.archivedAt !== null || thread.messages.length > 0 || thread.latestTurn !== null || thread.session !== null) return yield* new OrchestrationCommandInvariantError({
36020
+ commandType: command.type,
36021
+ detail: `Thread '${command.threadId}' must be active and empty before history can be imported.`
36022
+ });
36023
+ const firstMessage = command.messages[0];
36024
+ if (firstMessage === void 0) return yield* new OrchestrationCommandInvariantError({
36025
+ commandType: command.type,
36026
+ detail: "Thread history imports require at least one message."
36027
+ });
36028
+ const events = [];
36029
+ for (const message of command.messages) events.push({
36030
+ ...yield* withEventBase({
36031
+ aggregateKind: "thread",
36032
+ aggregateId: command.threadId,
36033
+ occurredAt: message.createdAt,
36034
+ commandId: command.commandId,
36035
+ metadata: { historyImport: true }
36036
+ }),
36037
+ type: "thread.message-sent",
36038
+ payload: {
36039
+ threadId: command.threadId,
36040
+ messageId: message.messageId,
36041
+ role: message.role,
36042
+ text: message.text,
36043
+ turnId: null,
36044
+ streaming: false,
36045
+ createdAt: message.createdAt,
36046
+ updatedAt: message.createdAt
36047
+ }
36048
+ });
36049
+ const settledAt = command.messages.reduce((latest, message) => message.createdAt > latest ? message.createdAt : latest, firstMessage.createdAt);
36050
+ events.push({
36051
+ ...yield* withEventBase({
36052
+ aggregateKind: "thread",
36053
+ aggregateId: command.threadId,
36054
+ occurredAt: settledAt,
36055
+ commandId: command.commandId,
36056
+ metadata: { historyImport: true }
36057
+ }),
36058
+ type: "thread.settled",
36059
+ payload: {
36060
+ threadId: command.threadId,
36061
+ settledAt,
36062
+ updatedAt: settledAt
36063
+ }
36064
+ });
36065
+ return events;
36066
+ }
35942
36067
  case "thread.message.assistant.complete":
35943
36068
  yield* requireThread({
35944
36069
  readModel,
@@ -36227,7 +36352,7 @@ const OrchestrationEngineLive = effect(OrchestrationEngineService, gen(function*
36227
36352
  yield* logDebug("orchestration engine started").pipe(annotateLogs({ sequence: commandReadModel.snapshotSequence }));
36228
36353
  const readEvents = (fromSequenceExclusive, limit) => eventStore.readFromSequence(fromSequenceExclusive, limit);
36229
36354
  const dispatch = (command) => gen(function* () {
36230
- const result = yield* make$74();
36355
+ const result = yield* make$75();
36231
36356
  yield* offer$1(commandQueue, {
36232
36357
  command,
36233
36358
  result,
@@ -37779,19 +37904,19 @@ function retainProjectionMessagesAfterRevert(messages, turns, turnCount) {
37779
37904
  if (turn.assistantMessageId !== null) retainedMessageIds.add(turn.assistantMessageId);
37780
37905
  }
37781
37906
  for (const message of messages) {
37782
- if (message.role === "system") {
37907
+ if (message.role === "system" || isImportedAgentSessionMessageId(message.messageId)) {
37783
37908
  retainedMessageIds.add(message.messageId);
37784
37909
  continue;
37785
37910
  }
37786
37911
  if (message.turnId !== null && retainedTurnIds.has(message.turnId)) retainedMessageIds.add(message.messageId);
37787
37912
  }
37788
- const retainedUserCount = messages.filter((message) => message.role === "user" && retainedMessageIds.has(message.messageId)).length;
37913
+ const retainedUserCount = messages.filter((message) => message.role === "user" && !isImportedAgentSessionMessageId(message.messageId) && retainedMessageIds.has(message.messageId)).length;
37789
37914
  const missingUserCount = Math.max(0, turnCount - retainedUserCount);
37790
37915
  if (missingUserCount > 0) {
37791
37916
  const fallbackUserMessages = messages.filter((message) => message.role === "user" && !retainedMessageIds.has(message.messageId) && (message.turnId === null || retainedTurnIds.has(message.turnId))).toSorted((left, right) => left.createdAt.localeCompare(right.createdAt) || left.messageId.localeCompare(right.messageId)).slice(0, missingUserCount);
37792
37917
  for (const message of fallbackUserMessages) retainedMessageIds.add(message.messageId);
37793
37918
  }
37794
- const retainedAssistantCount = messages.filter((message) => message.role === "assistant" && retainedMessageIds.has(message.messageId)).length;
37919
+ const retainedAssistantCount = messages.filter((message) => message.role === "assistant" && !isImportedAgentSessionMessageId(message.messageId) && retainedMessageIds.has(message.messageId)).length;
37795
37920
  const missingAssistantCount = Math.max(0, turnCount - retainedAssistantCount);
37796
37921
  if (missingAssistantCount > 0) {
37797
37922
  const fallbackAssistantMessages = messages.filter((message) => message.role === "assistant" && !retainedMessageIds.has(message.messageId) && (message.turnId === null || retainedTurnIds.has(message.turnId))).toSorted((left, right) => left.createdAt.localeCompare(right.createdAt) || left.messageId.localeCompare(right.messageId)).slice(0, missingAssistantCount);
@@ -37931,7 +38056,7 @@ const OrchestrationProjectionPipelineLive = effect(OrchestrationProjectionPipeli
37931
38056
  projectionPendingApprovalRepository.listByThreadId({ threadId })
37932
38057
  ]);
37933
38058
  let latestUserMessageAt = null;
37934
- for (const message of messages) if (message.role === "user" && (latestUserMessageAt === null || message.createdAt > latestUserMessageAt)) latestUserMessageAt = message.createdAt;
38059
+ for (const message of messages) if (message.role === "user" && !isImportedAgentSessionMessageId(message.messageId) && (latestUserMessageAt === null || message.createdAt > latestUserMessageAt)) latestUserMessageAt = message.createdAt;
37935
38060
  const pendingApprovalCount = pendingApprovals.filter((approval) => approval.status === "pending").length;
37936
38061
  const pendingUserInputCount = derivePendingUserInputCountFromActivities(activities);
37937
38062
  const hasActionableProposedPlan = deriveHasActionableProposedPlan({
@@ -38657,7 +38782,7 @@ const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
38657
38782
  "interrupted"
38658
38783
  ]);
38659
38784
  var ThreadBackgroundLivenessService = class extends Service$2()("t3/orchestration/ThreadBackgroundLiveness/ThreadBackgroundLivenessService") {};
38660
- function make$40() {
38785
+ function make$41() {
38661
38786
  const stateByThreadId = /* @__PURE__ */ new Map();
38662
38787
  const stateFor = (threadId) => {
38663
38788
  const existing = stateByThreadId.get(threadId);
@@ -38707,7 +38832,7 @@ function make$40() {
38707
38832
  }
38708
38833
  };
38709
38834
  }
38710
- const layer$32 = effect(ThreadBackgroundLivenessService, sync(make$40));
38835
+ const layer$34 = effect(ThreadBackgroundLivenessService, sync(make$41));
38711
38836
  //#endregion
38712
38837
  //#region ../t3-shared/src/sourceControl.ts
38713
38838
  function parseRemoteHost(remoteUrl) {
@@ -39007,7 +39132,7 @@ const runProcessCore = fn("processRunner.runProcessCore")(function* (spawner, in
39007
39132
  env: input.env,
39008
39133
  extendEnv
39009
39134
  });
39010
- const child = yield* spawner.spawn(make$80(spawnCommand.command, spawnCommand.args, {
39135
+ const child = yield* spawner.spawn(make$81(spawnCommand.command, spawnCommand.args, {
39011
39136
  ...input.spawnCwd ?? input.cwd ? { cwd: input.spawnCwd ?? input.cwd } : {},
39012
39137
  ...input.env !== void 0 ? {
39013
39138
  env: input.env,
@@ -39025,7 +39150,7 @@ const runProcessCore = fn("processRunner.runProcessCore")(function* (spawner, in
39025
39150
  cause
39026
39151
  })));
39027
39152
  const stdin = input.stdin;
39028
- const writeStdin = stdin === void 0 ? void_$1 : run$5(encodeText(make$75(stdin)), child.stdin).pipe(mapError((cause) => new ProcessStdinError({
39153
+ const writeStdin = stdin === void 0 ? void_$1 : run$5(encodeText(make$76(stdin)), child.stdin).pipe(mapError((cause) => new ProcessStdinError({
39029
39154
  command: input.command,
39030
39155
  argumentCount: input.args.length,
39031
39156
  cwd: input.cwd,
@@ -39075,7 +39200,7 @@ const runProcessCore = fn("processRunner.runProcessCore")(function* (spawner, in
39075
39200
  stderrTruncated: stderr.truncated
39076
39201
  };
39077
39202
  });
39078
- const layer$31 = effect(ProcessRunner, fn("ProcessRunner.make")(function* () {
39203
+ const layer$33 = effect(ProcessRunner, fn("ProcessRunner.make")(function* () {
39079
39204
  const spawner = yield* ChildProcessSpawner;
39080
39205
  const run = (input) => finalizeRunProcess(runProcessCore(spawner, input), input);
39081
39206
  return ProcessRunner.of({ run });
@@ -39170,7 +39295,7 @@ const resolveRepositoryIdentityFromCacheKey = fn("RepositoryIdentityResolver.res
39170
39295
  rootPath: cacheKey
39171
39296
  }) : null;
39172
39297
  });
39173
- const layer$30 = effect(RepositoryIdentityResolver, fn("RepositoryIdentityResolver.make")(function* (options = {}) {
39298
+ const layer$32 = effect(RepositoryIdentityResolver, fn("RepositoryIdentityResolver.make")(function* (options = {}) {
39174
39299
  const processRunner = yield* ProcessRunner;
39175
39300
  const repositoryIdentityCache = yield* makeWith$1((cacheKey) => resolveRepositoryIdentityFromCacheKey(cacheKey).pipe(provideService(ProcessRunner, processRunner)), {
39176
39301
  capacity: options.cacheCapacity ?? DEFAULT_REPOSITORY_IDENTITY_CACHE_CAPACITY,
@@ -39184,7 +39309,7 @@ const layer$30 = effect(RepositoryIdentityResolver, fn("RepositoryIdentityResolv
39184
39309
  return yield* get$7(repositoryIdentityCache, cacheKey);
39185
39310
  });
39186
39311
  return RepositoryIdentityResolver.of({ resolve });
39187
- })()).pipe(provide(layer$31));
39312
+ })()).pipe(provide(layer$33));
39188
39313
  //#endregion
39189
39314
  //#region src/orchestration/Layers/ProjectionSnapshotQuery.ts
39190
39315
  const decodeReadModel = decodeUnknownEffect(OrchestrationReadModel);
@@ -40620,7 +40745,7 @@ const OrchestrationInfrastructureLayerLive = mergeAll(effect(ProjectionSnapshotQ
40620
40745
  getThreadDetailById,
40621
40746
  getThreadDetailSnapshot
40622
40747
  };
40623
- })), mergeAll(OrchestrationEventStoreLive, OrchestrationCommandReceiptRepositoryLive), OrchestrationProjectionPipelineLive.pipe(provide(OrchestrationEventStoreLive))).pipe(provideMerge(layer$32));
40748
+ })), mergeAll(OrchestrationEventStoreLive, OrchestrationCommandReceiptRepositoryLive), OrchestrationProjectionPipelineLive.pipe(provide(OrchestrationEventStoreLive))).pipe(provideMerge(layer$34));
40624
40749
  const OrchestrationLayerLive = mergeAll(OrchestrationInfrastructureLayerLive, OrchestrationEngineLive.pipe(provide(OrchestrationInfrastructureLayerLive)));
40625
40750
  //#endregion
40626
40751
  //#region ../t3-shared/src/keybindings.ts
@@ -41085,16 +41210,16 @@ function mergeWithDefaultKeybindings(custom) {
41085
41210
  * Keybindings - Service tag for keybinding configuration operations.
41086
41211
  */
41087
41212
  var Keybindings = class extends Service$2()("t3/keybindings") {};
41088
- const layer$29 = effect(Keybindings, gen(function* () {
41213
+ const layer$31 = effect(Keybindings, gen(function* () {
41089
41214
  const { keybindingsConfigPath } = yield* ServerConfig;
41090
41215
  const fs = yield* FileSystem;
41091
41216
  const path = yield* Path;
41092
- const upsertSemaphore = yield* make$76(1);
41217
+ const upsertSemaphore = yield* make$77(1);
41093
41218
  const resolvedConfigCacheKey = "resolved";
41094
41219
  const changesPubSub = yield* unbounded$1();
41095
- const startedRef = yield* make$64(false);
41096
- const startedDeferred = yield* make$74();
41097
- const watcherScope = yield* make$77("sequential");
41220
+ const startedRef = yield* make$65(false);
41221
+ const startedDeferred = yield* make$75();
41222
+ const watcherScope = yield* make$78("sequential");
41098
41223
  yield* addFinalizer(() => close(watcherScope, void_$2));
41099
41224
  const emitChange = (configState) => publish(changesPubSub, configState).pipe(asVoid);
41100
41225
  const readConfigExists = fs.exists(keybindingsConfigPath).pipe(mapError((cause) => new KeybindingsConfigError({
@@ -41194,7 +41319,7 @@ const layer$29 = effect(Keybindings, gen(function* () {
41194
41319
  keybindings: mergeWithDefaultKeybindings(compileResolvedKeybindingsConfig(keybindings)),
41195
41320
  issues
41196
41321
  })));
41197
- const resolvedConfigCache = yield* make$82({
41322
+ const resolvedConfigCache = yield* make$83({
41198
41323
  capacity: 1,
41199
41324
  lookup: () => loadConfigStateFromDisk
41200
41325
  });
@@ -41537,7 +41662,7 @@ const resolveEditorLaunch = fn("resolveEditorLaunch")(function* (input) {
41537
41662
  });
41538
41663
  const launchAndUnref = fn("externalLauncher.launchAndUnref")(function* (launch, onError) {
41539
41664
  const spawner = yield* ChildProcessSpawner;
41540
- const command = make$80(launch.command, launch.args, launch.options);
41665
+ const command = make$81(launch.command, launch.args, launch.options);
41541
41666
  yield* spawner.spawn(command).pipe(flatMap$1((handle) => handle.unref), asVoid, scoped, mapError(onError));
41542
41667
  });
41543
41668
  const launchBrowser = fn("externalLauncher.launchBrowser")(function* (target) {
@@ -41574,7 +41699,7 @@ const launchEditorProcess = fn("externalLauncher.launchEditorProcess")(function*
41574
41699
  cause
41575
41700
  }));
41576
41701
  });
41577
- const layer$28 = effect(ExternalLauncher, gen(function* () {
41702
+ const layer$30 = effect(ExternalLauncher, gen(function* () {
41578
41703
  const spawner = yield* ChildProcessSpawner;
41579
41704
  const fileSystem = yield* FileSystem;
41580
41705
  const path = yield* Path;
@@ -41602,9 +41727,9 @@ var OrchestrationReactor = class extends Service$2()("t3/orchestration/Services/
41602
41727
  //#endregion
41603
41728
  //#region src/serverLifecycleEvents.ts
41604
41729
  var ServerLifecycleEvents = class extends Service$2()("t3/serverLifecycleEvents") {};
41605
- const layer$27 = effect(ServerLifecycleEvents, gen(function* () {
41730
+ const layer$29 = effect(ServerLifecycleEvents, gen(function* () {
41606
41731
  const pubsub = yield* unbounded$1();
41607
- const state = yield* make$64({
41732
+ const state = yield* make$65({
41608
41733
  sequence: 0,
41609
41734
  events: []
41610
41735
  });
@@ -41681,7 +41806,7 @@ var ServerSettingsService = class extends Service$2()("t3/serverSettings/ServerS
41681
41806
  const makeTest = (overrides = {}) => gen(function* () {
41682
41807
  const { automaticGitFetchInterval, providerHealthRefreshInterval, ...overridesForMerge } = overrides;
41683
41808
  const merged = deepMerge(DEFAULT_SERVER_SETTINGS, overridesForMerge);
41684
- const currentSettingsRef = yield* make$64(yield* normalizeServerSettings({
41809
+ const currentSettingsRef = yield* make$65(yield* normalizeServerSettings({
41685
41810
  ...merged,
41686
41811
  ...automaticGitFetchInterval !== void 0 ? { automaticGitFetchInterval } : {},
41687
41812
  ...providerHealthRefreshInterval !== void 0 ? { providerHealthRefreshInterval } : {}
@@ -41735,17 +41860,17 @@ function stripDefaultServerSettings(current, defaults) {
41735
41860
  }
41736
41861
  return Object.is(current, defaults) ? void 0 : current;
41737
41862
  }
41738
- const layer$26 = effect(ServerSettingsService, gen(function* () {
41863
+ const layer$28 = effect(ServerSettingsService, gen(function* () {
41739
41864
  const { settingsPath } = yield* ServerConfig;
41740
41865
  const fs = yield* FileSystem;
41741
41866
  const pathService = yield* Path;
41742
41867
  const secretStore = yield* ServerSecretStore;
41743
- const writeSemaphore = yield* make$76(1);
41868
+ const writeSemaphore = yield* make$77(1);
41744
41869
  const cacheKey = "settings";
41745
41870
  const changesPubSub = yield* unbounded$1();
41746
- const startedRef = yield* make$64(false);
41747
- const startedDeferred = yield* make$74();
41748
- const watcherScope = yield* make$77("sequential");
41871
+ const startedRef = yield* make$65(false);
41872
+ const startedDeferred = yield* make$75();
41873
+ const watcherScope = yield* make$78("sequential");
41749
41874
  yield* addFinalizer(() => close(watcherScope, void_$2));
41750
41875
  const emitChange = (settings) => publish(changesPubSub, settings).pipe(asVoid);
41751
41876
  const readConfigExists = fs.exists(settingsPath).pipe(mapError((cause) => new ServerSettingsError({
@@ -41772,7 +41897,7 @@ const layer$26 = effect(ServerSettingsService, gen(function* () {
41772
41897
  }
41773
41898
  return decoded.value;
41774
41899
  });
41775
- const settingsCache = yield* make$82({
41900
+ const settingsCache = yield* make$83({
41776
41901
  capacity: 1,
41777
41902
  lookup: () => loadSettingsFromDisk
41778
41903
  });
@@ -42132,12 +42257,12 @@ var AnalyticsService = class AnalyticsService extends Service$2()("t3/telemetry/
42132
42257
  flush: void_$1
42133
42258
  }));
42134
42259
  };
42135
- const layer$25 = effect(AnalyticsService, gen(function* () {
42260
+ const layer$27 = effect(AnalyticsService, gen(function* () {
42136
42261
  const telemetryConfig = yield* TelemetryEnvConfig;
42137
42262
  const httpClient = yield* HttpClient;
42138
42263
  const serverConfig = yield* ServerConfig;
42139
42264
  const identifier = yield* getTelemetryIdentifier;
42140
- const bufferRef = yield* make$64([]);
42265
+ const bufferRef = yield* make$65([]);
42141
42266
  const clientType = serverConfig.mode === "desktop" ? "desktop-app" : "cli-web-client";
42142
42267
  const hostPlatform = yield* HostProcessPlatform;
42143
42268
  const hostArchitecture = yield* HostProcessArchitecture;
@@ -42337,7 +42462,7 @@ function platformArch(architecture) {
42337
42462
  * state. It intentionally has no fallback Layer.succeed value: callers must
42338
42463
  * provide the external platform services and a ServerConfig.
42339
42464
  */
42340
- const layer$24 = effect(ServerEnvironment, gen(function* () {
42465
+ const layer$26 = effect(ServerEnvironment, gen(function* () {
42341
42466
  const fileSystem = yield* FileSystem;
42342
42467
  const path = yield* Path;
42343
42468
  const serverConfig = yield* ServerConfig;
@@ -42392,7 +42517,7 @@ const layer$24 = effect(ServerEnvironment, gen(function* () {
42392
42517
  getEnvironmentId: succeed$1(environmentId),
42393
42518
  getDescriptor: succeed$1(descriptor)
42394
42519
  });
42395
- })).pipe(provide(layer$31));
42520
+ })).pipe(provide(layer$33));
42396
42521
  //#endregion
42397
42522
  //#region src/provider/Services/ProviderSessionReaper.ts
42398
42523
  var ProviderSessionReaper = class extends Service$2()("t3/provider/Services/ProviderSessionReaper") {};
@@ -42406,7 +42531,7 @@ const forkParked = (effect) => gen(function* () {
42406
42531
  yield* forkScoped(effect);
42407
42532
  return;
42408
42533
  }
42409
- const parked = yield* make$74();
42534
+ const parked = yield* make$75();
42410
42535
  yield* forkScoped(succeed$4(parked, void 0).pipe(andThen(activation), andThen(effect)));
42411
42536
  yield* _await(parked);
42412
42537
  });
@@ -42425,9 +42550,9 @@ var ServerRuntimeStartupError = class extends TaggedErrorClass()("ServerRuntimeS
42425
42550
  var ServerRuntimeStartup = class extends Service$2()("t3/serverRuntimeStartup") {};
42426
42551
  const settleQueuedCommand = (deferred, exit) => isSuccess(exit) ? succeed$4(deferred, exit.value) : failCause$2(deferred, exit.cause);
42427
42552
  const makeCommandGate = gen(function* () {
42428
- const commandReady = yield* make$74();
42553
+ const commandReady = yield* make$75();
42429
42554
  const commandQueue = yield* unbounded$2();
42430
- const commandReadinessState = yield* make$64("pending");
42555
+ const commandReadinessState = yield* make$65("pending");
42431
42556
  yield* forkScoped(forever(take$1(commandQueue).pipe(flatMap$1((command) => command.run))));
42432
42557
  return {
42433
42558
  awaitCommandReady: _await(commandReady),
@@ -42443,7 +42568,7 @@ const makeCommandGate = gen(function* () {
42443
42568
  const readinessState = yield* get$3(commandReadinessState);
42444
42569
  if (readinessState === "ready") return yield* effect;
42445
42570
  if (readinessState !== "pending") return yield* readinessState;
42446
- const result = yield* make$74();
42571
+ const result = yield* make$75();
42447
42572
  yield* offer$1(commandQueue, { run: _await(commandReady).pipe(flatMap$1(() => effect), exit, flatMap$1((exit) => settleQueuedCommand(result, exit))) });
42448
42573
  return yield* _await(result);
42449
42574
  })
@@ -42546,7 +42671,7 @@ const maybeOpenBrowser = (target) => gen(function* () {
42546
42671
  yield* (yield* ExternalLauncher).launchBrowser(target).pipe(catch_(() => logInfo("browser auto-open unavailable", { hint: `Open ${target} in your browser.` })));
42547
42672
  });
42548
42673
  const runStartupPhase = (phase, effect) => effect.pipe(annotateSpans({ "startup.phase": phase }), withSpan(`server.startup.${phase}`));
42549
- const make$31 = (options) => gen(function* () {
42674
+ const make$32 = (options) => gen(function* () {
42550
42675
  const serverConfig = yield* ServerConfig;
42551
42676
  const keybindings = yield* Keybindings;
42552
42677
  const orchestrationReactor = yield* OrchestrationReactor;
@@ -42556,8 +42681,8 @@ const make$31 = (options) => gen(function* () {
42556
42681
  const serverEnvironment = yield* ServerEnvironment;
42557
42682
  const crypto = yield* Crypto;
42558
42683
  const commandGate = yield* makeCommandGate;
42559
- const httpListening = yield* make$74();
42560
- const reactorScope = yield* make$77("sequential");
42684
+ const httpListening = yield* make$75();
42685
+ const reactorScope = yield* make$78("sequential");
42561
42686
  yield* addFinalizer(() => close(reactorScope, void_$2));
42562
42687
  yield* forkScoped(exit(gen(function* () {
42563
42688
  yield* logDebug("startup phase: starting keybindings runtime");
@@ -42660,7 +42785,7 @@ const make$31 = (options) => gen(function* () {
42660
42785
  enqueueCommand: commandGate.enqueueCommand
42661
42786
  };
42662
42787
  });
42663
- const layerWithOptions = (options) => effect(ServerRuntimeStartup, make$31(options));
42788
+ const layerWithOptions = (options) => effect(ServerRuntimeStartup, make$32(options));
42664
42789
  layerWithOptions();
42665
42790
  //#endregion
42666
42791
  //#region src/workspace/WorkspacePaths.ts
@@ -42732,7 +42857,7 @@ function expandHomePath$2(input, path) {
42732
42857
  if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(NodeOS.homedir(), input.slice(2));
42733
42858
  return input;
42734
42859
  }
42735
- const layer$22 = effect(WorkspacePaths, gen(function* () {
42860
+ const layer$24 = effect(WorkspacePaths, gen(function* () {
42736
42861
  const fileSystem = yield* FileSystem;
42737
42862
  const path = yield* Path;
42738
42863
  const statWorkspaceRoot = fn("WorkspacePaths.statWorkspaceRoot")(function* (workspaceRoot, normalizedWorkspaceRoot, phase) {
@@ -42894,14 +43019,14 @@ const projectCommandUuid = Crypto.pipe(flatMap$1((crypto) => crypto.randomUUIDv4
42894
43019
  operation: "generateProjectCommandId",
42895
43020
  cause
42896
43021
  })));
42897
- const ProjectCliRuntimeLive = mergeAll(layer$22, OrchestrationLayerLive.pipe(provideMerge(layer$30), provideMerge(layerConfig)));
43022
+ const ProjectCliRuntimeLive = mergeAll(layer$24, OrchestrationLayerLive.pipe(provideMerge(layer$32), provideMerge(layerConfig)));
42898
43023
  const PROJECT_CLI_LIVE_SERVER_TIMEOUT = seconds(1);
42899
43024
  const withProjectCliSessionToken = (environmentAuth, run) => acquireUseRelease(environmentAuth.issueSession({
42900
43025
  scopes: AuthAdministrativeScopes,
42901
43026
  label: "t3 project cli"
42902
43027
  }), (issued) => run(issued.token), (issued) => environmentAuth.revokeSession(issued.sessionId).pipe(ignore$1({ log: true })));
42903
43028
  const withProjectCliLiveServerTimeout = (effect) => effect.pipe(timeout(PROJECT_CLI_LIVE_SERVER_TIMEOUT));
42904
- const makeLiveServerClient = (origin) => make$41(EnvironmentHttpApi, { baseUrl: origin });
43029
+ const makeLiveServerClient = (origin) => make$42(EnvironmentHttpApi, { baseUrl: origin });
42905
43030
  const normalizeWorkspaceRootForProjectCommand = fn("normalizeWorkspaceRootForProjectCommand")(function* (workspaceRoot) {
42906
43031
  return yield* (yield* WorkspacePaths).normalizeWorkspaceRoot(workspaceRoot);
42907
43032
  });
@@ -42984,7 +43109,7 @@ const runProjectMutation = fn("runProjectMutation")(function* (flags, run) {
42984
43109
  });
42985
43110
  yield* log(output);
42986
43111
  }));
42987
- const offlineRuntimeLayer = ProjectCliRuntimeLive.pipe(provide(layer$40(config)), provide(succeed$3(MinimumLogLevel, minimumLogLevel)));
43112
+ const offlineRuntimeLayer = ProjectCliRuntimeLive.pipe(provide(layer$42(config)), provide(succeed$3(MinimumLogLevel, minimumLogLevel)));
42988
43113
  return yield* gen(function* () {
42989
43114
  const snapshot = yield* getOfflineSnapshot();
42990
43115
  const orchestrationEngine = yield* OrchestrationEngineService;
@@ -42995,9 +43120,9 @@ const runProjectMutation = fn("runProjectMutation")(function* (flags, run) {
42995
43120
  });
42996
43121
  yield* log(output);
42997
43122
  }).pipe(provide$1(offlineRuntimeLayer));
42998
- }).pipe(provide$1(mergeAll(runtimeLayer, layer$22).pipe(provideMerge(layer$44), provide(layer$40(config)), provide(succeed$3(MinimumLogLevel, minimumLogLevel)))));
43123
+ }).pipe(provide$1(mergeAll(runtimeLayer, layer$24).pipe(provideMerge(layer$46), provide(layer$42(config)), provide(succeed$3(MinimumLogLevel, minimumLogLevel)))));
42999
43124
  });
43000
- const projectAddCommand = make$63("add", {
43125
+ const projectAddCommand = make$64("add", {
43001
43126
  ...projectLocationFlags,
43002
43127
  workspaceRoot: string$1("path").pipe(withDescription$2("Workspace root to add as a project.")),
43003
43128
  title: string("title").pipe(withDescription$1("Optional project title."), optional)
@@ -43022,7 +43147,7 @@ const projectAddCommand = make$63("add", {
43022
43147
  });
43023
43148
  return `Added project ${projectId} (${title}) at ${workspaceRoot}.`;
43024
43149
  }))));
43025
- const projectRemoveCommand = make$63("remove", {
43150
+ const projectRemoveCommand = make$64("remove", {
43026
43151
  ...projectLocationFlags,
43027
43152
  project: string$1("project").pipe(withDescription$2("Project id or workspace root to remove.")),
43028
43153
  force: boolean("force").pipe(withDescription$1("Delete the project and all of its threads."), withDefault(false))
@@ -43039,7 +43164,7 @@ const projectRemoveCommand = make$63("remove", {
43039
43164
  });
43040
43165
  return `Removed project ${project.id} (${project.title}).`;
43041
43166
  }))));
43042
- const projectRenameCommand = make$63("rename", {
43167
+ const projectRenameCommand = make$64("rename", {
43043
43168
  ...projectLocationFlags,
43044
43169
  project: string$1("project").pipe(withDescription$2("Project id or workspace root to rename.")),
43045
43170
  title: string$1("title").pipe(withDescription$2("New project title."))
@@ -43058,7 +43183,7 @@ const projectRenameCommand = make$63("rename", {
43058
43183
  });
43059
43184
  return `Renamed project ${project.id} to ${nextTitle}.`;
43060
43185
  }))));
43061
- const projectCommand = make$63("project").pipe(withDescription("Manage projects."), withSubcommands([
43186
+ const projectCommand = make$64("project").pipe(withDescription("Manage projects."), withSubcommands([
43062
43187
  projectAddCommand,
43063
43188
  projectRemoveCommand,
43064
43189
  projectRenameCommand
@@ -43121,7 +43246,7 @@ function acquireDaemonLock(stateDir) {
43121
43246
  * @category layers
43122
43247
  * @since 4.0.0
43123
43248
  */
43124
- const layer$21 = (api, options) => use(fnUntraced(function* (router) {
43249
+ const layer$23 = (api, options) => use(fnUntraced(function* (router) {
43125
43250
  const services = yield* context();
43126
43251
  const routes = [];
43127
43252
  const availableGroups = Array.from(services.mapUnsafe.keys()).filter((key) => key.startsWith("effect/httpapi/HttpApiGroup/"));
@@ -43174,19 +43299,19 @@ const HandlersTypeId = "~effect/httpapi/HttpApiBuilder/Handlers";
43174
43299
  */
43175
43300
  const securityDecode = (self) => {
43176
43301
  switch (self._tag) {
43177
- case "Http": return map$4(HttpServerRequest, (request) => make$68(getAuthorizationCredential(request.headers.authorization, self.scheme) ?? ""));
43302
+ case "Http": return map$4(HttpServerRequest, (request) => make$69(getAuthorizationCredential(request.headers.authorization, self.scheme) ?? ""));
43178
43303
  case "ApiKey": {
43179
43304
  const key = self.in === "header" ? self.key.toLowerCase() : self.key;
43180
43305
  const schema = Struct({ [key]: String$1 });
43181
43306
  return match$2(self.in === "query" ? schemaSearchParams(schema) : self.in === "cookie" ? schemaCookies(schema) : schemaHeaders(schema), {
43182
- onFailure: () => make$68(""),
43183
- onSuccess: (match) => make$68(match[key])
43307
+ onFailure: () => make$69(""),
43308
+ onSuccess: (match) => make$69(match[key])
43184
43309
  });
43185
43310
  }
43186
43311
  case "Basic": {
43187
43312
  const empty = {
43188
43313
  username: "",
43189
- password: make$68("")
43314
+ password: make$69("")
43190
43315
  };
43191
43316
  return map$4(HttpServerRequest, (request) => {
43192
43317
  const encoded = getAuthorizationCredential(request.headers.authorization, basicScheme);
@@ -43197,7 +43322,7 @@ const securityDecode = (self) => {
43197
43322
  if (separator === -1) return empty;
43198
43323
  return {
43199
43324
  username: decoded.slice(0, separator),
43200
- password: make$68(decoded.slice(separator + 1))
43325
+ password: make$69(decoded.slice(separator + 1))
43201
43326
  };
43202
43327
  });
43203
43328
  }
@@ -43735,18 +43860,18 @@ function requireDesktopTelemetryWriteProgress(fd, remainingBytes, written) {
43735
43860
  remainingBytes
43736
43861
  }));
43737
43862
  }
43738
- const layer$20 = effect(DesktopTelemetryReceiver, fn("resourceTelemetry.desktopTelemetryReceiver.make")(function* () {
43863
+ const layer$22 = effect(DesktopTelemetryReceiver, fn("resourceTelemetry.desktopTelemetryReceiver.make")(function* () {
43739
43864
  const config = yield* ServerConfig;
43740
43865
  const serverSettings = yield* ServerSettingsService;
43741
- const latest = yield* make$64(none());
43866
+ const latest = yield* make$65(none());
43742
43867
  const receiverStartedAt = yield* now$1;
43743
- const lastContactAtMs = yield* make$64(initialDesktopTelemetryContactAt(config.desktopTelemetryFd, toEpochMillis(receiverStartedAt)));
43744
- const snapshotStaleAfterMs = yield* make$64(resolveDesktopTelemetrySnapshotStaleAfterMs(DEFAULT_HOST_POWER_ACTIVE_INTERVAL_MS, DEFAULT_HOST_POWER_IDLE_INTERVAL_MS));
43868
+ const lastContactAtMs = yield* make$65(initialDesktopTelemetryContactAt(config.desktopTelemetryFd, toEpochMillis(receiverStartedAt)));
43869
+ const snapshotStaleAfterMs = yield* make$65(resolveDesktopTelemetrySnapshotStaleAfterMs(DEFAULT_HOST_POWER_ACTIVE_INTERVAL_MS, DEFAULT_HOST_POWER_IDLE_INTERVAL_MS));
43745
43870
  const changes = yield* sliding(8);
43746
43871
  const healthChanges = yield* sliding(4);
43747
- const controlMutex = yield* make$76(1);
43748
- const snapshotMutex = yield* make$76(1);
43749
- const health = yield* make$64({
43872
+ const controlMutex = yield* make$77(1);
43873
+ const snapshotMutex = yield* make$77(1);
43874
+ const health = yield* make$65({
43750
43875
  status: config.desktopTelemetryFd === void 0 ? "unavailable" : "starting",
43751
43876
  lastSampleAt: none(),
43752
43877
  lastError: config.desktopTelemetryFd === void 0 ? some(new DesktopTelemetryDescriptorUnavailable({ mode: config.mode }).message) : none()
@@ -43912,8 +44037,8 @@ const makeUnknownSnapshot = (source, updatedAt) => ({
43912
44037
  function samePowerState(left, right) {
43913
44038
  return left.source === right.source && left.idle === right.idle && left.locked === right.locked && left.suspended === right.suspended && left.onBattery === right.onBattery && left.lowPowerMode === right.lowPowerMode && left.thermalState === right.thermalState && left.stale === right.stale;
43914
44039
  }
43915
- const make$28 = fn("background.hostPower.make")(function* (initialSnapshot) {
43916
- const latestRef = yield* make$64(initialSnapshot ?? makeUnknownSnapshot("unknown", yield* now$1));
44040
+ const make$29 = fn("background.hostPower.make")(function* (initialSnapshot) {
44041
+ const latestRef = yield* make$65(initialSnapshot ?? makeUnknownSnapshot("unknown", yield* now$1));
43917
44042
  const changes = yield* sliding(1);
43918
44043
  const report = (snapshot) => modify$2(latestRef, (current) => {
43919
44044
  if (isLessThan$1(snapshot.updatedAt, current.updatedAt)) return [none(), current];
@@ -43928,12 +44053,12 @@ const make$28 = fn("background.hostPower.make")(function* (initialSnapshot) {
43928
44053
  streamChanges: fromPubSub(changes)
43929
44054
  });
43930
44055
  });
43931
- const layer$19 = effect(HostPowerMonitor, gen(function* () {
44056
+ const layer$21 = effect(HostPowerMonitor, gen(function* () {
43932
44057
  const desktopSubscription = yield* (yield* DesktopTelemetryReceiver).subscribe;
43933
44058
  const initial = desktopSubscription.latest;
43934
44059
  const monitor = yield* match$1(initial, {
43935
- onNone: () => make$28(),
43936
- onSome: (snapshot) => make$28(snapshot.power)
44060
+ onNone: () => make$29(),
44061
+ onSome: (snapshot) => make$29(snapshot.power)
43937
44062
  });
43938
44063
  yield* desktopSubscription.changes.pipe(map$8((snapshot) => snapshot.power), runForEach(monitor.report), forkScoped);
43939
44064
  return monitor;
@@ -44023,12 +44148,12 @@ function computeSnapshot(input) {
44023
44148
  updatedAt: input.updatedAt
44024
44149
  };
44025
44150
  }
44026
- const layer$18 = effect(BackgroundPolicy, fn("background.policy.make")(function* () {
44151
+ const layer$20 = effect(BackgroundPolicy, fn("background.policy.make")(function* () {
44027
44152
  const hostPowerMonitor = yield* HostPowerMonitor;
44028
44153
  const serverSettings = yield* ServerSettingsService;
44029
- const leasesRef = yield* make$64(/* @__PURE__ */ new Map());
44154
+ const leasesRef = yield* make$65(/* @__PURE__ */ new Map());
44030
44155
  const changes = yield* sliding(1);
44031
- const publishMutex = yield* make$76(1);
44156
+ const publishMutex = yield* make$77(1);
44032
44157
  const backgroundActivitySettings = serverSettings.getSettings.pipe(map$4(resolveServerBackgroundActivitySettings), orElseSucceed(() => getBackgroundActivityPresetSettings("balanced")));
44033
44158
  const snapshot = gen(function* () {
44034
44159
  const [hostPower, leases, now, settings] = yield* all([
@@ -44116,8 +44241,8 @@ function nonNegativeInteger(value, fallback) {
44116
44241
  if (!Number.isFinite(value)) return 0;
44117
44242
  return Math.max(0, Math.round(value));
44118
44243
  }
44119
- const layer$17 = effect(ResourceAttribution, fn("resourceTelemetry.resourceAttribution.make")(function* () {
44120
- const entries = yield* make$64(/* @__PURE__ */ new Map());
44244
+ const layer$19 = effect(ResourceAttribution, fn("resourceTelemetry.resourceAttribution.make")(function* () {
44245
+ const entries = yield* make$65(/* @__PURE__ */ new Map());
44121
44246
  const record = (input) => update$2(entries, (current) => {
44122
44247
  const next = new Map(current);
44123
44248
  const entryKey = key(input);
@@ -44253,7 +44378,7 @@ const layerFlusher = /*#__PURE__*/ sync$2(Flusher, () => {
44253
44378
  * @category constructors
44254
44379
  * @since 4.0.0
44255
44380
  */
44256
- const make$25 = /*#__PURE__*/ fnUntraced(function* (options) {
44381
+ const make$26 = /*#__PURE__*/ fnUntraced(function* (options) {
44257
44382
  const services = yield* context();
44258
44383
  const clock = get$5(services, Clock);
44259
44384
  const scope = get$5(services, Scope);
@@ -44285,7 +44410,7 @@ const make$25 = /*#__PURE__*/ fnUntraced(function* (options) {
44285
44410
  package: "@effect/opentelemetry",
44286
44411
  module: options.label
44287
44412
  }));
44288
- const exportFibers = yield* make$66();
44413
+ const exportFibers = yield* make$67();
44289
44414
  const runExportFork = yield* runtime(exportFibers)();
44290
44415
  yield* (yield* Flusher).register(runExport);
44291
44416
  yield* addFinalizer$1(scope, suspend(() => {
@@ -44323,7 +44448,7 @@ const make$25 = /*#__PURE__*/ fnUntraced(function* (options) {
44323
44448
  * @category constructors
44324
44449
  * @since 4.0.0
44325
44450
  */
44326
- const make$24 = (options) => {
44451
+ const make$25 = (options) => {
44327
44452
  const resourceAttributes = options.attributes ? entriesToAttributes(Object.entries(options.attributes)) : [];
44328
44453
  resourceAttributes.push({
44329
44454
  key: "service.name",
@@ -44370,7 +44495,7 @@ const fromConfig = /*#__PURE__*/ fnUntraced(function* (options) {
44370
44495
  };
44371
44496
  delete attributes["service.name"];
44372
44497
  delete attributes["service.version"];
44373
- return make$24({
44498
+ return make$25({
44374
44499
  serviceName,
44375
44500
  serviceVersion,
44376
44501
  attributes
@@ -44489,7 +44614,7 @@ const layerJson$1 = /*#__PURE__*/ succeed$3(OtlpSerialization, {
44489
44614
  * @category constructors
44490
44615
  * @since 4.0.0
44491
44616
  */
44492
- const make$23 = /*#__PURE__*/ fnUntraced(function* (options) {
44617
+ const make$24 = /*#__PURE__*/ fnUntraced(function* (options) {
44493
44618
  const clock = yield* Clock;
44494
44619
  const serialization = yield* OtlpSerialization;
44495
44620
  const startTimeNanos = yield* clock.currentTimeNanos;
@@ -44770,7 +44895,7 @@ const make$23 = /*#__PURE__*/ fnUntraced(function* (options) {
44770
44895
  }]
44771
44896
  }] });
44772
44897
  };
44773
- yield* make$25({
44898
+ yield* make$26({
44774
44899
  label: "OtlpMetrics",
44775
44900
  url: options.url,
44776
44901
  headers: options.headers,
@@ -44786,7 +44911,7 @@ const make$23 = /*#__PURE__*/ fnUntraced(function* (options) {
44786
44911
  * @category layers
44787
44912
  * @since 4.0.0
44788
44913
  */
44789
- const layer$16 = (options) => effectDiscard(make$23(options)).pipe(provideMerge(layerFlusher));
44914
+ const layer$18 = (options) => effectDiscard(make$24(options)).pipe(provideMerge(layerFlusher));
44790
44915
  /** Creates a unique key for a metric including its attributes */
44791
44916
  const makeMetricKey = (id, attributes) => {
44792
44917
  if (attributes === void 0 || Object.keys(attributes).length === 0) return id;
@@ -44881,11 +45006,11 @@ const EAggregationTemporality = {
44881
45006
  * @category constructors
44882
45007
  * @since 4.0.0
44883
45008
  */
44884
- const make$22 = /*#__PURE__*/ fnUntraced(function* (options) {
45009
+ const make$23 = /*#__PURE__*/ fnUntraced(function* (options) {
44885
45010
  const otelResource = yield* fromConfig(options.resource);
44886
45011
  const serialization = yield* OtlpSerialization;
44887
45012
  const scope = { name: serviceNameUnsafe(otelResource) };
44888
- const exporter = yield* make$25({
45013
+ const exporter = yield* make$26({
44889
45014
  label: "OtlpTracer",
44890
45015
  url: options.url,
44891
45016
  headers: options.headers,
@@ -44907,7 +45032,7 @@ const make$22 = /*#__PURE__*/ fnUntraced(function* (options) {
44907
45032
  if (!span.sampled) return;
44908
45033
  exporter.push(makeOtlpSpan(span));
44909
45034
  }
44910
- return make$78({
45035
+ return make$79({
44911
45036
  span(options) {
44912
45037
  return makeSpan({
44913
45038
  ...options,
@@ -45425,8 +45550,8 @@ const makeLocalFileTracer = fn("makeLocalFileTracer")(function* (options) {
45425
45550
  batchWindowMs: options.batchWindowMs,
45426
45551
  ...options.onFlush ? { onFlush: options.onFlush } : {}
45427
45552
  }));
45428
- const delegate = options.delegate ?? make$78({ span: (spanOptions) => new NativeSpan(spanOptions) });
45429
- return make$78({
45553
+ const delegate = options.delegate ?? make$79({ span: (spanOptions) => new NativeSpan(spanOptions) });
45554
+ return make$79({
45430
45555
  span(spanOptions) {
45431
45556
  return new LocalFileSpan(spanOptions, delegate.span(spanOptions), sink.push);
45432
45557
  },
@@ -45592,7 +45717,7 @@ const logT3ProjectFileLoadError = (error) => logWarning$1(error).pipe(annotateLo
45592
45717
  filePath: error.filePath,
45593
45718
  errorTag: error._tag
45594
45719
  }));
45595
- const layer$15 = effect(T3ProjectFileLoader, gen(function* () {
45720
+ const layer$17 = effect(T3ProjectFileLoader, gen(function* () {
45596
45721
  const fileSystem = yield* FileSystem;
45597
45722
  const path = yield* Path;
45598
45723
  const load = fn("T3ProjectFileLoader.load")(function* (workspaceRoot) {
@@ -45683,7 +45808,7 @@ function extractIconHref(source) {
45683
45808
  return null;
45684
45809
  }
45685
45810
  const optionOnNotFound$1 = (effect) => effect.pipe(map$4(some), catchTags({ PlatformError: (error) => error.reason._tag === "NotFound" ? succeed$1(none()) : fail(error) }));
45686
- const layer$14 = effect(ProjectFaviconResolver, gen(function* () {
45811
+ const layer$16 = effect(ProjectFaviconResolver, gen(function* () {
45687
45812
  const fileSystem = yield* FileSystem;
45688
45813
  const path = yield* Path;
45689
45814
  const workspacePaths = yield* WorkspacePaths;
@@ -46025,10 +46150,10 @@ const resolveAsset = fn("AssetAccess.resolveAsset")(function* (token, relativePa
46025
46150
  //#endregion
46026
46151
  //#region src/observability/BrowserTraceCollector.ts
46027
46152
  var BrowserTraceCollector = class extends Service$2()("t3/observability/BrowserTraceCollector") {};
46028
- const make$19 = (sink) => BrowserTraceCollector.of({ record: (records) => sync(() => {
46153
+ const make$20 = (sink) => BrowserTraceCollector.of({ record: (records) => sync(() => {
46029
46154
  for (const record of records) sink.push(record);
46030
46155
  }) });
46031
- const layer$13 = (sink) => succeed$3(BrowserTraceCollector, make$19(sink));
46156
+ const layer$15 = (sink) => succeed$3(BrowserTraceCollector, make$20(sink));
46032
46157
  //#endregion
46033
46158
  //#region src/auth/http.ts
46034
46159
  const CREDENTIAL_RESPONSE_HEADERS = {
@@ -49578,7 +49703,7 @@ let clientIdCounter = 0;
49578
49703
  * @category constructors
49579
49704
  * @since 4.0.0
49580
49705
  */
49581
- const make$18 = /*#__PURE__*/ fnUntraced(function* (group, options) {
49706
+ const make$19 = /*#__PURE__*/ fnUntraced(function* (group, options) {
49582
49707
  const clientId = clientIdCounter++;
49583
49708
  const { run, send, supportsAck, supportsTransferables } = yield* Protocol$1;
49584
49709
  const entries = /* @__PURE__ */ new Map();
@@ -49750,7 +49875,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
49750
49875
  const services = yield* context();
49751
49876
  const scope = get$5(services, Scope);
49752
49877
  const trackFiber = runIn(forkUnsafe(scope, "parallel"));
49753
- const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$76(concurrency);
49878
+ const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$77(concurrency);
49754
49879
  const clients = /* @__PURE__ */ new Map();
49755
49880
  let isShutdown = false;
49756
49881
  const shutdownLatch = makeUnsafe$7(false);
@@ -49986,10 +50111,10 @@ const applyMiddleware = (context, handler, options) => {
49986
50111
  * @category running
49987
50112
  * @since 4.0.0
49988
50113
  */
49989
- const make$17 = /*#__PURE__*/ fnUntraced(function* (group, options) {
50114
+ const make$18 = /*#__PURE__*/ fnUntraced(function* (group, options) {
49990
50115
  const { disconnects, end, run, send, supportsAck, supportsSpanPropagation, supportsTransferables } = yield* Protocol;
49991
50116
  const services = yield* context();
49992
- const scope = yield* make$77();
50117
+ const scope = yield* make$78();
49993
50118
  const server = yield* makeNoSerialization(group, {
49994
50119
  ...options,
49995
50120
  disableClientAcks: !supportsAck,
@@ -50177,12 +50302,12 @@ const makeProtocolWithHttpEffectWebsocket = /*#__PURE__*/ gen(function* () {
50177
50302
  */
50178
50303
  const toHttpEffectWebsocket = /*#__PURE__*/ fnUntraced(function* (group, options) {
50179
50304
  const { httpEffect, protocol } = yield* makeProtocolWithHttpEffectWebsocket;
50180
- yield* make$17(group, options).pipe(provideService(Protocol, protocol), forkScoped);
50305
+ yield* make$18(group, options).pipe(provideService(Protocol, protocol), forkScoped);
50181
50306
  return httpEffect;
50182
50307
  });
50183
50308
  const makeSocketProtocol = /*#__PURE__*/ gen(function* () {
50184
50309
  const serialization = yield* RpcSerialization;
50185
- const disconnects = yield* make$79();
50310
+ const disconnects = yield* make$80();
50186
50311
  let clientId = 0;
50187
50312
  const clients = /* @__PURE__ */ new Map();
50188
50313
  const clientIds = /* @__PURE__ */ new Set();
@@ -50257,8 +50382,8 @@ var ProviderRegistry = class extends Service$2()("t3/provider/Services/ProviderR
50257
50382
  //#endregion
50258
50383
  //#region src/provider/providerMaintenanceCommandCoordinator.ts
50259
50384
  const makeProviderMaintenanceCommandCoordinator = fn("makeProviderMaintenanceCommandCoordinator")(function* (input) {
50260
- const runningTargetsRef = yield* make$64(/* @__PURE__ */ new Set());
50261
- const locksRef = yield* make$64(/* @__PURE__ */ new Map());
50385
+ const runningTargetsRef = yield* make$65(/* @__PURE__ */ new Set());
50386
+ const locksRef = yield* make$65(/* @__PURE__ */ new Map());
50262
50387
  const acquireTarget = fn("acquireTarget")(function* (targetKey) {
50263
50388
  return yield* modify$2(runningTargetsRef, (runningTargets) => {
50264
50389
  if (runningTargets.has(targetKey)) return [false, runningTargets];
@@ -50275,7 +50400,7 @@ const makeProviderMaintenanceCommandCoordinator = fn("makeProviderMaintenanceCom
50275
50400
  const getLock = fn("getProviderMaintenanceCommandLock")(function* (lockKey) {
50276
50401
  const existing = (yield* get$3(locksRef)).get(lockKey);
50277
50402
  if (existing) return existing;
50278
- const lock = yield* make$76(1);
50403
+ const lock = yield* make$77(1);
50279
50404
  return yield* modify$2(locksRef, (locks) => {
50280
50405
  const current = locks.get(lockKey);
50281
50406
  if (current) return [current, locks];
@@ -50644,7 +50769,7 @@ const nowIso$3 = map$4(now$1, formatIso);
50644
50769
  const runProviderMaintenanceCommandWithSpawner = fn("ProviderMaintenanceRunner.runCommand")(function* (input) {
50645
50770
  return yield* fn("ProviderMaintenanceRunner.collectCommandResult")(function* () {
50646
50771
  const resolved = yield* resolveSpawnCommand(input.command, input.args);
50647
- const child = yield* input.spawner.spawn(make$80(resolved.command, resolved.args, { shell: resolved.shell })).pipe(mapError((cause) => new ProviderMaintenanceCommandError({
50772
+ const child = yield* input.spawner.spawn(make$81(resolved.command, resolved.args, { shell: resolved.shell })).pipe(mapError((cause) => new ProviderMaintenanceCommandError({
50648
50773
  message: `Failed to run update command ${input.command}: ${cause.message}`,
50649
50774
  cause
50650
50775
  })));
@@ -50712,7 +50837,7 @@ function makeUpdateState(input) {
50712
50837
  output: input.output ?? null
50713
50838
  };
50714
50839
  }
50715
- const layer$12 = effect(ProviderMaintenanceRunner, fn("ProviderMaintenanceRunner.make")(function* () {
50840
+ const layer$14 = effect(ProviderMaintenanceRunner, fn("ProviderMaintenanceRunner.make")(function* () {
50716
50841
  const providerRegistry = yield* ProviderRegistry;
50717
50842
  const spawner = yield* ChildProcessSpawner;
50718
50843
  const httpClient = yield* HttpClient;
@@ -50772,7 +50897,7 @@ const layer$12 = effect(ProviderMaintenanceRunner, fn("ProviderMaintenanceRunner
50772
50897
  })).pipe(asVoid);
50773
50898
  const runProviderUpdate = fn("ProviderMaintenanceRunner.runProviderUpdate")(function* () {
50774
50899
  const finish = (state) => setUpdateState(state).pipe(map$4((providers) => ({ providers })));
50775
- const startedAtRef = yield* make$64(null);
50900
+ const startedAtRef = yield* make$65(null);
50776
50901
  const runCommandAndVerify = fn("ProviderMaintenanceRunner.runCommandAndVerify")(function* () {
50777
50902
  const startedAt = yield* nowIso$3;
50778
50903
  yield* set$2(startedAtRef, startedAt);
@@ -51144,21 +51269,6 @@ const observeRpcStreamEffect = (method, effect, traceAttributes) => {
51144
51269
  return withRpcStreamTracing(method, instrumented, traceAttributes);
51145
51270
  };
51146
51271
  //#endregion
51147
- //#region src/provider/Services/ProviderAdapterRegistry.ts
51148
- /**
51149
- * ProviderAdapterRegistry - Service tag for provider adapter lookup.
51150
- */
51151
- var ProviderAdapterRegistry = class extends Service$2()("t3/provider/Services/ProviderAdapterRegistry") {};
51152
- //#endregion
51153
- //#region src/provider/Services/ProviderSessionDirectory.ts
51154
- var ProviderSessionDirectory = class extends Service$2()("t3/provider/Services/ProviderSessionDirectory") {};
51155
- //#endregion
51156
- //#region src/provider/Services/ProviderService.ts
51157
- /**
51158
- * ProviderService - Service tag for provider orchestration.
51159
- */
51160
- var ProviderService = class extends Service$2()("t3/provider/Services/ProviderService") {};
51161
- //#endregion
51162
51272
  //#region src/portProxy.ts
51163
51273
  const ports = /* @__PURE__ */ new Set();
51164
51274
  const methods = /* @__PURE__ */ new Set([
@@ -51436,7 +51546,7 @@ const waitForIndexReady = fn("WorkspaceSearchIndex.waitForIndexReady")(function*
51436
51546
  timeout: WORKSPACE_INDEX_SCAN_TIMEOUT
51437
51547
  });
51438
51548
  });
51439
- const make$15 = fn("WorkspaceSearchIndex.make")(function* (cwd, variant = "paths") {
51549
+ const make$16 = fn("WorkspaceSearchIndex.make")(function* (cwd, variant = "paths") {
51440
51550
  const finder = yield* acquireRelease(createFinder(cwd, variant), (finder) => try_({
51441
51551
  try: () => finder.destroy(),
51442
51552
  catch: (cause) => new WorkspaceSearchIndexDestroyFailed({
@@ -51565,12 +51675,12 @@ function parseWorkspaceSearchIndexKey(key) {
51565
51675
  * idle cleanup; using a default cwd here would mix resources from different
51566
51676
  * workspaces.
51567
51677
  */
51568
- const layer$11 = (key) => {
51678
+ const layer$13 = (key) => {
51569
51679
  const { cwd, variant } = parseWorkspaceSearchIndexKey(key);
51570
- return effect(WorkspaceSearchIndex, make$15(cwd, variant));
51680
+ return effect(WorkspaceSearchIndex, make$16(cwd, variant));
51571
51681
  };
51572
51682
  var WorkspaceSearchIndexMap = class extends Service()("t3/workspace/WorkspaceSearchIndexMap", {
51573
- lookup: layer$11,
51683
+ lookup: layer$13,
51574
51684
  idleTimeToLive: WORKSPACE_INDEX_IDLE_TTL
51575
51685
  }) {};
51576
51686
  //#endregion
@@ -51632,7 +51742,7 @@ const resolveBrowseTarget = fn("WorkspaceEntries.resolveBrowseTarget")(function*
51632
51742
  if (!input.cwd) return yield* new WorkspaceEntriesCurrentProjectRequiredError({ partialPath: input.partialPath });
51633
51743
  return path.resolve(expandHomePath$1(input.cwd, path), input.partialPath);
51634
51744
  });
51635
- const layer$10 = effect(WorkspaceEntries, gen(function* () {
51745
+ const layer$12 = effect(WorkspaceEntries, gen(function* () {
51636
51746
  const path = yield* Path;
51637
51747
  const workspacePaths = yield* WorkspacePaths;
51638
51748
  const workspaceSearchIndexes = yield* WorkspaceSearchIndexMap;
@@ -51785,7 +51895,7 @@ Union([
51785
51895
  ]);
51786
51896
  /** Service tag for workspace file operations. */
51787
51897
  var WorkspaceFileSystem = class extends Service$2()("t3/workspace/WorkspaceFileSystem") {};
51788
- const layer$9 = effect(WorkspaceFileSystem, gen(function* () {
51898
+ const layer$11 = effect(WorkspaceFileSystem, gen(function* () {
51789
51899
  const fileSystem = yield* FileSystem;
51790
51900
  const path = yield* Path;
51791
51901
  const workspacePaths = yield* WorkspacePaths;
@@ -51969,7 +52079,7 @@ function parseGitRefs(output, refKind, query = "", currentRef = null) {
51969
52079
  });
51970
52080
  }
51971
52081
  var GitWorkspace = class extends Service$2()("agentlink/workspace/GitWorkspace") {};
51972
- const layer$8 = effect(GitWorkspace, gen(function* () {
52082
+ const layer$10 = effect(GitWorkspace, gen(function* () {
51973
52083
  const runner = yield* ProcessRunner;
51974
52084
  const run = fn("GitWorkspace.run")(function* (cwd, operation, args, allowFailure = false) {
51975
52085
  const result = yield* runner.run({
@@ -52106,7 +52216,7 @@ const layer$8 = effect(GitWorkspace, gen(function* () {
52106
52216
  listRefs,
52107
52217
  switchRef
52108
52218
  });
52109
- })).pipe(provide(layer$31));
52219
+ })).pipe(provide(layer$33));
52110
52220
  //#endregion
52111
52221
  //#region src/terminal/PtyAdapter.ts
52112
52222
  /**
@@ -52195,7 +52305,7 @@ function validateCwd(cwd) {
52195
52305
  }
52196
52306
  }).pipe(flatMap$1((stat) => stat.isDirectory() ? void_$1 : new TerminalCwdNotDirectoryError({ cwd })));
52197
52307
  }
52198
- const layer$7 = effect(TerminalManager, gen(function* () {
52308
+ const layer$9 = effect(TerminalManager, gen(function* () {
52199
52309
  const pty = yield* PtyAdapter;
52200
52310
  const runFork = runForkWith(yield* context());
52201
52311
  const sessions = /* @__PURE__ */ new Map();
@@ -52524,6 +52634,964 @@ const layer$7 = effect(TerminalManager, gen(function* () {
52524
52634
  });
52525
52635
  }));
52526
52636
  //#endregion
52637
+ //#region src/pathExpansion.ts
52638
+ /**
52639
+ * Expand a leading `~` (or `~/…`, `~\…`) in a user-supplied path to the
52640
+ * current user's home directory. Spawned processes don't get shell
52641
+ * expansion, so env vars like `CODEX_HOME=~/.codex-work` would be passed
52642
+ * verbatim and treated as relative paths by the receiver.
52643
+ *
52644
+ * Matches the behavior of the other `expandHomePath` helpers in the
52645
+ * workspace layers and CLI bootstrap: `~` alone and both `~/` and `~\`
52646
+ * separators are handled. Returns the input unchanged if it doesn't
52647
+ * start with `~` or is empty. Does not handle `~user` (other-user)
52648
+ * expansion.
52649
+ */
52650
+ function expandHomePath(value) {
52651
+ if (!value) return value;
52652
+ if (value === "~") return NodeOS.homedir();
52653
+ if (value.startsWith("~/") || value.startsWith("~\\")) return NodePath.join(NodeOS.homedir(), value.slice(2));
52654
+ return value;
52655
+ }
52656
+ //#endregion
52657
+ //#region src/provider/Drivers/CodexHomeLayout.ts
52658
+ const KNOWN_SHARED_DIRECTORIES = [
52659
+ "sessions",
52660
+ "archived_sessions",
52661
+ "sqlite",
52662
+ "shell_snapshots",
52663
+ "worktrees",
52664
+ "skills",
52665
+ "plugins",
52666
+ "cache",
52667
+ "logs",
52668
+ "mcp-oauth-locks"
52669
+ ];
52670
+ const PRIVATE_ENTRY_NAMES = /* @__PURE__ */ new Set(["auth.json", "models_cache.json"]);
52671
+ const SHADOW_LOCAL_ENTRY_NAMES = /* @__PURE__ */ new Set([
52672
+ "log",
52673
+ "memories",
52674
+ "tmp"
52675
+ ]);
52676
+ const REPLACEABLE_SHARED_RUNTIME_DIRECTORIES = /* @__PURE__ */ new Set(["mcp-oauth-locks"]);
52677
+ function resolveHomePath(path, value) {
52678
+ const expanded = value && value.trim().length > 0 ? expandHomePath(value) : path.join(NodeOS.homedir(), ".codex");
52679
+ return path.resolve(expanded);
52680
+ }
52681
+ const resolveCodexHomeLayout = fn("resolveCodexHomeLayout")(function* (config) {
52682
+ const path = yield* Path;
52683
+ const sharedHomePath = resolveHomePath(path, config.homePath);
52684
+ const shadowHomePath = config.shadowHomePath.trim();
52685
+ if (shadowHomePath.length === 0) return {
52686
+ mode: "direct",
52687
+ sharedHomePath,
52688
+ effectiveHomePath: config.homePath.trim().length > 0 ? sharedHomePath : void 0,
52689
+ continuationKey: `codex:home:${sharedHomePath}`
52690
+ };
52691
+ return {
52692
+ mode: "authOverlay",
52693
+ sharedHomePath,
52694
+ effectiveHomePath: path.resolve(expandHomePath(shadowHomePath)),
52695
+ continuationKey: `codex:home:${sharedHomePath}`
52696
+ };
52697
+ });
52698
+ const CodexShadowHomeContext = {
52699
+ sharedHomePath: String$1,
52700
+ effectiveHomePath: String$1
52701
+ };
52702
+ var CodexShadowHomeFileSystemError = class extends TaggedErrorClass()("CodexShadowHomeFileSystemError", {
52703
+ ...CodexShadowHomeContext,
52704
+ operation: Literals([
52705
+ "readLink",
52706
+ "makeDirectory",
52707
+ "readDirectory",
52708
+ "remove",
52709
+ "symlink"
52710
+ ]),
52711
+ path: String$1,
52712
+ targetPath: optional$3(String$1),
52713
+ entryName: optional$3(String$1),
52714
+ cause: Defect()
52715
+ }) {
52716
+ get message() {
52717
+ const target = this.targetPath === void 0 ? "" : ` to '${this.targetPath}'`;
52718
+ return `Codex shadow home filesystem operation '${this.operation}' failed for '${this.path}'${target}.`;
52719
+ }
52720
+ };
52721
+ var CodexShadowHomePathConflictError = class extends TaggedErrorClass()("CodexShadowHomePathConflictError", CodexShadowHomeContext) {
52722
+ get message() {
52723
+ return `Codex shadow home path '${this.effectiveHomePath}' must be different from the shared home path '${this.sharedHomePath}'.`;
52724
+ }
52725
+ };
52726
+ var CodexShadowHomeEntryConflictError = class extends TaggedErrorClass()("CodexShadowHomeEntryConflictError", {
52727
+ ...CodexShadowHomeContext,
52728
+ entryName: String$1,
52729
+ linkPath: String$1,
52730
+ targetPath: String$1
52731
+ }) {
52732
+ get message() {
52733
+ return `Cannot create Codex shadow home entry '${this.entryName}' because '${this.linkPath}' already exists and is not a symlink.`;
52734
+ }
52735
+ };
52736
+ var CodexShadowHomePrivateEntrySymlinkError = class extends TaggedErrorClass()("CodexShadowHomePrivateEntrySymlinkError", {
52737
+ ...CodexShadowHomeContext,
52738
+ entryName: String$1,
52739
+ path: String$1
52740
+ }) {
52741
+ get message() {
52742
+ return `Codex shadow home private entry '${this.entryName}' at '${this.path}' must be a real file, not a symlink.`;
52743
+ }
52744
+ };
52745
+ Union([
52746
+ CodexShadowHomeFileSystemError,
52747
+ CodexShadowHomePathConflictError,
52748
+ CodexShadowHomeEntryConflictError,
52749
+ CodexShadowHomePrivateEntrySymlinkError
52750
+ ]);
52751
+ function isNotSymlinkError(error) {
52752
+ const cause = error.reason.cause;
52753
+ return error.reason._tag === "Unknown" && typeof cause === "object" && cause !== null && "code" in cause && cause.code === "EINVAL";
52754
+ }
52755
+ const readLinkState = fn("CodexHomeLayout.readLinkState")(function* (input) {
52756
+ return yield* input.fileSystem.readLink(input.linkPath).pipe(map$4((target) => ({
52757
+ _tag: "Symlink",
52758
+ target
52759
+ })), catchTags({ PlatformError: (cause) => {
52760
+ if (cause.reason._tag === "NotFound") return succeed$1({ _tag: "Missing" });
52761
+ if (isNotSymlinkError(cause)) return succeed$1({ _tag: "NotSymlink" });
52762
+ return new CodexShadowHomeFileSystemError({
52763
+ sharedHomePath: input.sharedHomePath,
52764
+ effectiveHomePath: input.effectiveHomePath,
52765
+ operation: "readLink",
52766
+ path: input.linkPath,
52767
+ entryName: input.entryName,
52768
+ cause
52769
+ });
52770
+ } }));
52771
+ });
52772
+ const removePrivateSymlink = fn("CodexHomeLayout.removePrivateSymlink")(function* (input) {
52773
+ const privatePath = (yield* Path).join(input.effectiveHomePath, input.entryName);
52774
+ if ((yield* readLinkState({
52775
+ ...input,
52776
+ linkPath: privatePath
52777
+ }))._tag === "Symlink") yield* input.fileSystem.remove(privatePath).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
52778
+ sharedHomePath: input.sharedHomePath,
52779
+ effectiveHomePath: input.effectiveHomePath,
52780
+ operation: "remove",
52781
+ path: privatePath,
52782
+ entryName: input.entryName,
52783
+ cause
52784
+ }) }));
52785
+ });
52786
+ const ensureSymlink = fn("CodexHomeLayout.ensureSymlink")(function* (input) {
52787
+ const path = yield* Path;
52788
+ const target = path.join(input.sharedHomePath, input.entryName);
52789
+ const link = path.join(input.effectiveHomePath, input.entryName);
52790
+ const state = yield* readLinkState({
52791
+ ...input,
52792
+ linkPath: link
52793
+ });
52794
+ const createLink = input.fileSystem.symlink(target, link).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
52795
+ sharedHomePath: input.sharedHomePath,
52796
+ effectiveHomePath: input.effectiveHomePath,
52797
+ operation: "symlink",
52798
+ path: link,
52799
+ targetPath: target,
52800
+ entryName: input.entryName,
52801
+ cause
52802
+ }) }));
52803
+ if (state._tag === "NotSymlink") {
52804
+ if (!REPLACEABLE_SHARED_RUNTIME_DIRECTORIES.has(input.entryName)) return yield* new CodexShadowHomeEntryConflictError({
52805
+ sharedHomePath: input.sharedHomePath,
52806
+ effectiveHomePath: input.effectiveHomePath,
52807
+ entryName: input.entryName,
52808
+ linkPath: link,
52809
+ targetPath: target
52810
+ });
52811
+ yield* input.fileSystem.remove(link, { recursive: true }).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
52812
+ sharedHomePath: input.sharedHomePath,
52813
+ effectiveHomePath: input.effectiveHomePath,
52814
+ operation: "remove",
52815
+ path: link,
52816
+ entryName: input.entryName,
52817
+ cause
52818
+ }) }));
52819
+ return yield* createLink;
52820
+ }
52821
+ if (state._tag === "Missing") return yield* createLink;
52822
+ if (path.resolve(path.dirname(link), state.target) !== target) {
52823
+ yield* input.fileSystem.remove(link).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
52824
+ sharedHomePath: input.sharedHomePath,
52825
+ effectiveHomePath: input.effectiveHomePath,
52826
+ operation: "remove",
52827
+ path: link,
52828
+ entryName: input.entryName,
52829
+ cause
52830
+ }) }));
52831
+ yield* createLink;
52832
+ }
52833
+ });
52834
+ const ensureShadowAuthIsPrivate = fn("CodexHomeLayout.ensureShadowAuthIsPrivate")(function* (input) {
52835
+ const path = yield* Path;
52836
+ const entryName = "auth.json";
52837
+ const authPath = path.join(input.effectiveHomePath, entryName);
52838
+ if ((yield* readLinkState({
52839
+ ...input,
52840
+ entryName,
52841
+ linkPath: authPath
52842
+ }))._tag === "Symlink") return yield* new CodexShadowHomePrivateEntrySymlinkError({
52843
+ sharedHomePath: input.sharedHomePath,
52844
+ effectiveHomePath: input.effectiveHomePath,
52845
+ entryName,
52846
+ path: authPath
52847
+ });
52848
+ });
52849
+ const materializeCodexShadowHome = fn("materializeCodexShadowHome")(function* (layout) {
52850
+ if (layout.mode !== "authOverlay") return;
52851
+ const effectiveHomePath = layout.effectiveHomePath;
52852
+ if (!effectiveHomePath) return;
52853
+ if (layout.sharedHomePath === effectiveHomePath) return yield* new CodexShadowHomePathConflictError({
52854
+ sharedHomePath: layout.sharedHomePath,
52855
+ effectiveHomePath
52856
+ });
52857
+ const fileSystem = yield* FileSystem;
52858
+ const path = yield* Path;
52859
+ const makeDirectory = (directoryPath) => fileSystem.makeDirectory(directoryPath, { recursive: true }).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
52860
+ sharedHomePath: layout.sharedHomePath,
52861
+ effectiveHomePath,
52862
+ operation: "makeDirectory",
52863
+ path: directoryPath,
52864
+ cause
52865
+ }) }));
52866
+ yield* all([
52867
+ makeDirectory(layout.sharedHomePath),
52868
+ makeDirectory(effectiveHomePath),
52869
+ ...KNOWN_SHARED_DIRECTORIES.map((directory) => makeDirectory(path.join(layout.sharedHomePath, directory)))
52870
+ ], { concurrency: "unbounded" });
52871
+ const sharedEntryNames = yield* fileSystem.readDirectory(layout.sharedHomePath).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
52872
+ sharedHomePath: layout.sharedHomePath,
52873
+ effectiveHomePath,
52874
+ operation: "readDirectory",
52875
+ path: layout.sharedHomePath,
52876
+ cause
52877
+ }) }));
52878
+ const entries = new Set(KNOWN_SHARED_DIRECTORIES);
52879
+ for (const entryName of sharedEntryNames) if (!PRIVATE_ENTRY_NAMES.has(entryName) && !SHADOW_LOCAL_ENTRY_NAMES.has(entryName)) entries.add(entryName);
52880
+ yield* forEach(PRIVATE_ENTRY_NAMES, (entryName) => entryName === "auth.json" ? void_$1 : removePrivateSymlink({
52881
+ fileSystem,
52882
+ sharedHomePath: layout.sharedHomePath,
52883
+ effectiveHomePath,
52884
+ entryName
52885
+ }), { discard: true });
52886
+ yield* forEach(entries, (entryName) => {
52887
+ if (PRIVATE_ENTRY_NAMES.has(entryName)) return void_$1;
52888
+ return ensureSymlink({
52889
+ fileSystem,
52890
+ sharedHomePath: layout.sharedHomePath,
52891
+ effectiveHomePath,
52892
+ entryName
52893
+ });
52894
+ }, { discard: true });
52895
+ yield* ensureShadowAuthIsPrivate({
52896
+ fileSystem,
52897
+ sharedHomePath: layout.sharedHomePath,
52898
+ effectiveHomePath
52899
+ });
52900
+ });
52901
+ function codexContinuationIdentity(layout) {
52902
+ return {
52903
+ driverKind: ProviderDriverKind.make("codex"),
52904
+ continuationKey: layout.continuationKey
52905
+ };
52906
+ }
52907
+ //#endregion
52908
+ //#region src/project/AgentSessionScanner.ts
52909
+ /**
52910
+ * AgentSessionScanner - discovery of projects a user already works on.
52911
+ *
52912
+ * Claude Code and Codex both keep a per-session transcript on disk, and each
52913
+ * transcript records the directory the session ran in. Reading those `cwd`
52914
+ * values gives us the set of directories worth offering as projects during
52915
+ * onboarding, without asking the user to browse the filesystem.
52916
+ *
52917
+ * The scan is read-only and best-effort: an unreadable home, a malformed
52918
+ * transcript, or a directory that has since been deleted is skipped rather
52919
+ * than failing the scan. Project creation stays with the client, which
52920
+ * dispatches `project.create` for whichever candidates the user picks.
52921
+ *
52922
+ * @module project/AgentSessionScanner
52923
+ */
52924
+ /** Chunk size for transcript reads; stop as soon as session metadata names its cwd. */
52925
+ const TRANSCRIPT_PREFIX_BYTES = 32 * 1024;
52926
+ /** Prevent malformed transcripts from turning project discovery into a full file scan. */
52927
+ const MAX_TRANSCRIPT_SCAN_BYTES = 1024 * 1024;
52928
+ /**
52929
+ * Upper bound on transcripts inspected (first line read) per source.
52930
+ * Newest-first ordering means the cap drops only stale sessions when a home
52931
+ * directory is unusually large.
52932
+ */
52933
+ const MAX_TRANSCRIPTS_PER_SOURCE = 5e3;
52934
+ /**
52935
+ * Upper bound on `stat` calls per source. Newest-first ordering needs mtimes
52936
+ * before the read cap can be applied, so stats get their own larger budget;
52937
+ * once it runs out the scan stops rather than walking a pathological home
52938
+ * indefinitely.
52939
+ */
52940
+ const MAX_STATS_PER_SOURCE = MAX_TRANSCRIPTS_PER_SOURCE * 4;
52941
+ const RECENT_THREAD_WINDOW_MS = 720 * 60 * 60 * 1e3;
52942
+ const MAX_IMPORTED_TRANSCRIPT_BYTES = 16 * 1024 * 1024;
52943
+ const MAX_IMPORTED_MESSAGES = 200;
52944
+ const TranscriptContentBlock = Struct({
52945
+ type: optional$3(String$1),
52946
+ text: optional$3(String$1)
52947
+ });
52948
+ const TranscriptMessage = Struct({
52949
+ role: optional$3(String$1),
52950
+ content: optional$3(Union([String$1, ArraySchema(TranscriptContentBlock)])),
52951
+ model: optional$3(String$1)
52952
+ });
52953
+ const TranscriptRecord = Struct({
52954
+ type: optional$3(String$1),
52955
+ timestamp: optional$3(String$1),
52956
+ sessionId: optional$3(String$1),
52957
+ aiTitle: optional$3(String$1),
52958
+ isSidechain: optional$3(Boolean$1),
52959
+ isMeta: optional$3(Boolean$1),
52960
+ isCompactSummary: optional$3(Boolean$1),
52961
+ message: optional$3(TranscriptMessage),
52962
+ payload: optional$3(Struct({
52963
+ id: optional$3(String$1),
52964
+ session_id: optional$3(String$1),
52965
+ type: optional$3(String$1),
52966
+ role: optional$3(String$1),
52967
+ message: optional$3(String$1),
52968
+ model: optional$3(String$1),
52969
+ content: optional$3(ArraySchema(TranscriptContentBlock))
52970
+ }))
52971
+ });
52972
+ const decodeClaudeSettings$1 = decodeUnknownOption(ClaudeSettings);
52973
+ const decodeCodexSettings$1 = decodeUnknownOption(CodexSettings);
52974
+ const decodeTranscriptRecord = decodeUnknownOption(fromJsonString(TranscriptRecord));
52975
+ /** Service tag for agent session discovery. */
52976
+ var AgentSessionScanner = class extends Service$2()("t3/project/AgentSessionScanner") {};
52977
+ function extractText(content) {
52978
+ if (typeof content === "string") return content.trim();
52979
+ if (content === void 0) return "";
52980
+ return content.filter((block) => block.type === "text" || block.type === "input_text" || block.type === "output_text").map((block) => block.text?.trim() ?? "").filter((text) => text.length > 0).join("\n");
52981
+ }
52982
+ function normalizeTimestamp(value, fallback) {
52983
+ if (value === void 0) return fallback;
52984
+ const parsed = make$73(value);
52985
+ return isSome(parsed) ? formatIso(parsed.value) : fallback;
52986
+ }
52987
+ const LEADING_CODEX_CONTEXT = /^\s*(?:<environment_context>[\s\S]*?<\/environment_context>|<user_instructions>[\s\S]*?<\/user_instructions>|# AGENTS\.md instructions for[^\r\n]*\s*<INSTRUCTIONS>[\s\S]*?<\/INSTRUCTIONS>)\s*/u;
52988
+ /** Codex records leading workspace context as user input even though it is not conversation text. */
52989
+ function visibleCodexUserText(value) {
52990
+ let visible = value;
52991
+ while (LEADING_CODEX_CONTEXT.test(visible)) visible = visible.replace(LEADING_CODEX_CONTEXT, "");
52992
+ return visible.replace(/^\s*## My request for Codex:\s*/u, "").trim();
52993
+ }
52994
+ /** Keep visible user and assistant text while ignoring tools, reasoning, and malformed records. */
52995
+ function parseAgentSessionTranscript(input) {
52996
+ const fallbackTimestamp = formatIso(makeUnsafe$6(input.lastActiveAtMs));
52997
+ let providerSessionId = input.source === "codex" ? "" : input.fallbackSessionId;
52998
+ let title = null;
52999
+ let model = null;
53000
+ let hasCodexSessionId = false;
53001
+ const messages = [];
53002
+ let firstUserMessage;
53003
+ const retainMessage = (message) => {
53004
+ if (firstUserMessage === void 0 && message.role === "user") firstUserMessage = message;
53005
+ messages.push(message);
53006
+ if (messages.length > MAX_IMPORTED_MESSAGES) messages.shift();
53007
+ };
53008
+ const hasMatchingCodexEventInTurn = (text) => {
53009
+ for (let index = messages.length - 1; index >= 0; index--) {
53010
+ const message = messages[index];
53011
+ if (message?.role === "assistant") return false;
53012
+ if (message?.role === "user" && !message.codexResponseUser && message.text === text) return true;
53013
+ }
53014
+ return false;
53015
+ };
53016
+ for (const line of input.contents.split("\n")) {
53017
+ const decoded = decodeTranscriptRecord(line);
53018
+ if (isNone(decoded)) continue;
53019
+ const record = decoded.value;
53020
+ if (input.source === "claudeAgent") {
53021
+ if (record.isSidechain === true || record.isMeta === true || record.isCompactSummary === true) continue;
53022
+ if (record.sessionId?.trim()) providerSessionId = record.sessionId.trim();
53023
+ if (record.aiTitle?.trim()) title = record.aiTitle.trim();
53024
+ const messageModel = record.message?.model?.trim();
53025
+ if (messageModel && messageModel !== "<synthetic>") model = messageModel;
53026
+ if (record.type !== "user" && record.type !== "assistant") continue;
53027
+ const text = extractText(record.message?.content);
53028
+ if (text.length === 0) continue;
53029
+ retainMessage({
53030
+ role: record.type,
53031
+ text,
53032
+ createdAt: normalizeTimestamp(record.timestamp, fallbackTimestamp),
53033
+ codexResponseUser: false
53034
+ });
53035
+ continue;
53036
+ }
53037
+ if (record.type === "session_meta") {
53038
+ const sessionId = record.payload?.id?.trim() || record.payload?.session_id?.trim();
53039
+ if (!hasCodexSessionId && sessionId) {
53040
+ providerSessionId = sessionId;
53041
+ hasCodexSessionId = true;
53042
+ }
53043
+ continue;
53044
+ }
53045
+ if (record.type === "turn_context" && record.payload?.model?.trim()) {
53046
+ model = record.payload.model.trim();
53047
+ continue;
53048
+ }
53049
+ if (record.type === "event_msg" && record.payload?.type === "user_message") {
53050
+ const text = visibleCodexUserText(record.payload.message ?? "");
53051
+ if (text.length === 0) continue;
53052
+ for (let index = messages.length - 1; index >= 0; index--) {
53053
+ const message = messages[index];
53054
+ if (message?.role === "assistant") break;
53055
+ if (message?.codexResponseUser === true && message.text === text) {
53056
+ messages.splice(index, 1);
53057
+ break;
53058
+ }
53059
+ }
53060
+ retainMessage({
53061
+ role: "user",
53062
+ text,
53063
+ createdAt: normalizeTimestamp(record.timestamp, fallbackTimestamp),
53064
+ codexResponseUser: false
53065
+ });
53066
+ continue;
53067
+ }
53068
+ if (record.type !== "response_item" || record.payload?.type !== "message" || record.payload.role !== "user" && record.payload.role !== "assistant") continue;
53069
+ const extractedText = extractText(record.payload.content);
53070
+ const text = record.payload.role === "user" ? visibleCodexUserText(extractedText) : extractedText;
53071
+ if (text.length === 0) continue;
53072
+ if (record.payload.role === "user" && hasMatchingCodexEventInTurn(text)) continue;
53073
+ retainMessage({
53074
+ role: record.payload.role,
53075
+ text,
53076
+ createdAt: normalizeTimestamp(record.timestamp, fallbackTimestamp),
53077
+ codexResponseUser: record.payload.role === "user"
53078
+ });
53079
+ }
53080
+ const visibleMessages = messages.map(({ codexResponseUser: _codexResponseUser, ...message }) => message);
53081
+ if (providerSessionId.trim().length === 0 || firstUserMessage === void 0) return null;
53082
+ const { codexResponseUser: _codexResponseUser, ...visibleFirstUserMessage } = firstUserMessage;
53083
+ const retainedMessages = visibleMessages.some((message) => message.role === "user") ? visibleMessages : [visibleFirstUserMessage, ...visibleMessages.slice(-199)];
53084
+ return {
53085
+ source: input.source,
53086
+ providerInstanceId: input.providerInstanceId,
53087
+ providerSessionId,
53088
+ title: title ?? visibleFirstUserMessage.text.split("\n")[0]?.slice(0, 100).trim() ?? "Imported thread",
53089
+ model,
53090
+ createdAt: retainedMessages[0]?.createdAt ?? fallbackTimestamp,
53091
+ updatedAt: fallbackTimestamp,
53092
+ messages: retainedMessages
53093
+ };
53094
+ }
53095
+ /**
53096
+ * T3 Code runs its own agent sessions inside disposable worktrees. Their
53097
+ * transcripts look exactly like user sessions, but re-importing the app's own
53098
+ * sandboxes as projects is never right. Matches this server's configured
53099
+ * worktrees directory plus the conventional `.t3/worktrees` layout, which
53100
+ * also catches sandboxes from other T3 homes on the same machine. Separators
53101
+ * are normalized (and, on Windows, case folded) so the prefix match holds
53102
+ * there too. Callers check both the recorded spelling and its realpath so a
53103
+ * symlink into the worktrees directory cannot bypass the filter.
53104
+ */
53105
+ function normalizeForWorktreeMatch(value, caseFold) {
53106
+ const normalized = `${value.replaceAll("\\", "/")}/`;
53107
+ return caseFold ? normalized.toLowerCase() : normalized;
53108
+ }
53109
+ function isT3ManagedWorktree(candidatePath, worktreesDir, caseFold) {
53110
+ const normalized = normalizeForWorktreeMatch(candidatePath, caseFold);
53111
+ return normalized.startsWith(normalizeForWorktreeMatch(worktreesDir, caseFold)) || normalized.includes("/.t3/worktrees/");
53112
+ }
53113
+ /** Extract `cwd` from a session-meta record, tolerating the shapes each CLI writes. */
53114
+ function extractCwd(line) {
53115
+ let parsed;
53116
+ try {
53117
+ parsed = JSON.parse(line);
53118
+ } catch {
53119
+ return null;
53120
+ }
53121
+ if (typeof parsed !== "object" || parsed === null) return null;
53122
+ const record = parsed;
53123
+ if (typeof record.cwd === "string" && record.cwd.trim().length > 0) return record.cwd;
53124
+ const payload = record.payload;
53125
+ if (typeof payload === "object" && payload !== null) {
53126
+ const nested = payload.cwd;
53127
+ if (typeof nested === "string" && nested.trim().length > 0) return nested;
53128
+ }
53129
+ return null;
53130
+ }
53131
+ const layer$8 = effect(AgentSessionScanner, gen(function* () {
53132
+ const fileSystem = yield* FileSystem;
53133
+ const path = yield* Path;
53134
+ const serverConfig = yield* ServerConfig;
53135
+ const serverSettings = yield* ServerSettingsService;
53136
+ const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
53137
+ const configuredBaseDir = path.resolve(serverConfig.baseDir);
53138
+ const configuredWorktreesDir = path.resolve(serverConfig.worktreesDir);
53139
+ const baseDir = yield* fileSystem.realPath(configuredBaseDir).pipe(orElseSucceed(() => configuredBaseDir));
53140
+ const worktreesDir = yield* fileSystem.realPath(configuredWorktreesDir).pipe(orElseSucceed(() => configuredWorktreesDir));
53141
+ const foldWorktreeCase = (yield* HostProcessPlatform) === "win32";
53142
+ const hostEnvironment = yield* HostProcessEnvironment;
53143
+ const excludedProjectRoots = new Set([NodeOS.homedir(), NodeOS.tmpdir()].map((directory) => normalizeProjectPathForComparison(path.resolve(directory))));
53144
+ const isExcludedProjectPath = (candidatePath) => excludedProjectRoots.has(normalizeProjectPathForComparison(candidatePath)) || normalizeForWorktreeMatch(candidatePath, foldWorktreeCase).startsWith(normalizeForWorktreeMatch(baseDir, foldWorktreeCase)) || isT3ManagedWorktree(candidatePath, worktreesDir, foldWorktreeCase);
53145
+ const listDirectory = (directory) => fileSystem.readDirectory(directory).pipe(orElseSucceed(() => []));
53146
+ const statOption = (target) => fileSystem.stat(target).pipe(map$4(some), orElseSucceed(none));
53147
+ const readCwd = fn("AgentSessionScanner.readCwd")(function* (filePath) {
53148
+ return yield* scoped(fileSystem.open(filePath, { flag: "r" }).pipe(flatMap$1((file) => gen(function* () {
53149
+ const decoder = new TextDecoder();
53150
+ let remaining = "";
53151
+ let bytesRead = 0;
53152
+ while (bytesRead < MAX_TRANSCRIPT_SCAN_BYTES) {
53153
+ const next = yield* file.readAlloc(Math.min(TRANSCRIPT_PREFIX_BYTES, MAX_TRANSCRIPT_SCAN_BYTES - bytesRead));
53154
+ if (isNone(next)) return extractCwd(remaining.trim());
53155
+ bytesRead += next.value.byteLength;
53156
+ remaining += decoder.decode(next.value, { stream: true });
53157
+ const lines = remaining.split("\n");
53158
+ remaining = lines.pop() ?? "";
53159
+ for (const line of lines) {
53160
+ const cwd = extractCwd(line.trim());
53161
+ if (cwd !== null) return cwd;
53162
+ }
53163
+ }
53164
+ return null;
53165
+ })))).pipe(orElseSucceed(() => null));
53166
+ });
53167
+ /**
53168
+ * Read one stable transcript snapshot. The guard byte detects a file that
53169
+ * grew after stat without reading past the hard per-file limit.
53170
+ */
53171
+ const readTranscript = fn("AgentSessionScanner.readTranscript")(function* (filePath, expectedSize) {
53172
+ if (expectedSize > BigInt(MAX_IMPORTED_TRANSCRIPT_BYTES)) return null;
53173
+ const expectedBytes = Number(expectedSize);
53174
+ return yield* scoped(fileSystem.open(filePath, { flag: "r" }).pipe(flatMap$1((file) => gen(function* () {
53175
+ const decoder = new TextDecoder();
53176
+ let contents = "";
53177
+ let bytesRead = 0;
53178
+ while (bytesRead <= expectedBytes) {
53179
+ const next = yield* file.readAlloc(Math.min(TRANSCRIPT_PREFIX_BYTES, expectedBytes + 1 - bytesRead));
53180
+ if (isNone(next)) return contents + decoder.decode();
53181
+ bytesRead += next.value.byteLength;
53182
+ if (bytesRead > expectedBytes) return null;
53183
+ contents += decoder.decode(next.value, { stream: true });
53184
+ }
53185
+ return null;
53186
+ })))).pipe(orElseSucceed(() => null));
53187
+ });
53188
+ /**
53189
+ * Resolve the Claude config directory the CLI would use, matching the
53190
+ * precedence the spawned CLI sees: the instance's `homePath` (exported as
53191
+ * `CLAUDE_CONFIG_DIR`), then a `CLAUDE_CONFIG_DIR` already in the
53192
+ * environment, then `~/.claude`.
53193
+ */
53194
+ const resolveClaudeConfigDir = (homePath, environmentHome) => {
53195
+ const configured = homePath.trim();
53196
+ if (configured.length > 0) return path.resolve(expandHomePath(configured));
53197
+ const fromEnvironment = environmentHome?.trim() ?? "";
53198
+ if (fromEnvironment.length > 0) return path.resolve(expandHomePath(fromEnvironment));
53199
+ return path.join(NodeOS.homedir(), ".claude");
53200
+ };
53201
+ /**
53202
+ * Claude keeps one directory per project under `projects/`, named after a
53203
+ * lossy slug of the path. The slug can't be decoded (both `/` and `.` become
53204
+ * `-`), so the real path comes from the `cwd` recorded in the newest
53205
+ * transcript inside it.
53206
+ */
53207
+ const scanClaude = fn("AgentSessionScanner.scanClaude")(function* (homePath, providerInstanceId) {
53208
+ const projectsDir = path.join(homePath, "projects");
53209
+ const projectDirectories = yield* listDirectory(projectsDir);
53210
+ let statBudget = MAX_STATS_PER_SOURCE;
53211
+ const transcripts = [];
53212
+ for (const projectDirectory of projectDirectories) {
53213
+ if (statBudget <= 0) break;
53214
+ const directory = path.join(projectsDir, projectDirectory);
53215
+ const directoryTranscripts = (yield* listDirectory(directory)).filter((entry) => entry.endsWith(".jsonl")).map((entry) => path.join(directory, entry));
53216
+ if (directoryTranscripts.length === 0) continue;
53217
+ const statted = directoryTranscripts.slice(0, statBudget);
53218
+ statBudget -= statted.length;
53219
+ for (const filePath of statted) {
53220
+ const stats = yield* statOption(filePath);
53221
+ if (isNone(stats) || isNone(stats.value.mtime)) continue;
53222
+ transcripts.push({
53223
+ filePath,
53224
+ mtimeMs: stats.value.mtime.value.getTime()
53225
+ });
53226
+ }
53227
+ }
53228
+ transcripts.sort((left, right) => right.mtimeMs - left.mtimeMs);
53229
+ transcripts.splice(MAX_TRANSCRIPTS_PER_SOURCE);
53230
+ const byCwd = /* @__PURE__ */ new Map();
53231
+ for (const entry of transcripts) {
53232
+ const cwd = yield* readCwd(entry.filePath);
53233
+ if (cwd === null) continue;
53234
+ const existing = byCwd.get(cwd);
53235
+ if (existing) {
53236
+ existing.threadCount += 1;
53237
+ existing.lastActiveAtMs = Math.max(existing.lastActiveAtMs, entry.mtimeMs);
53238
+ existing.transcripts.push(entry);
53239
+ } else byCwd.set(cwd, {
53240
+ threadCount: 1,
53241
+ lastActiveAtMs: entry.mtimeMs,
53242
+ transcripts: [entry]
53243
+ });
53244
+ }
53245
+ return Array.from(byCwd, ([cwd, group]) => ({
53246
+ cwd,
53247
+ source: "claudeAgent",
53248
+ providerInstanceIds: [providerInstanceId],
53249
+ threadCount: group.threadCount,
53250
+ lastActiveAtMs: group.lastActiveAtMs,
53251
+ transcripts: group.transcripts
53252
+ }));
53253
+ });
53254
+ /**
53255
+ * Codex writes `sessions/YYYY/MM/DD/rollout-*.jsonl`. Always scan the shared
53256
+ * home: in auth-overlay mode the effective home only symlinks to it.
53257
+ */
53258
+ const scanCodex = fn("AgentSessionScanner.scanCodex")(function* (homePath, providerInstanceId) {
53259
+ const sessionsDir = path.join(homePath, "sessions");
53260
+ const rollouts = [];
53261
+ for (const year of (yield* listDirectory(sessionsDir)).toSorted().toReversed()) {
53262
+ for (const month of (yield* listDirectory(path.join(sessionsDir, year))).toSorted().toReversed()) {
53263
+ for (const day of (yield* listDirectory(path.join(sessionsDir, year, month))).toSorted().toReversed()) {
53264
+ const directory = path.join(sessionsDir, year, month, day);
53265
+ for (const entry of (yield* listDirectory(directory)).toSorted().toReversed()) {
53266
+ if (!entry.startsWith("rollout-") || !entry.endsWith(".jsonl")) continue;
53267
+ rollouts.push(path.join(directory, entry));
53268
+ if (rollouts.length >= MAX_TRANSCRIPTS_PER_SOURCE) break;
53269
+ }
53270
+ if (rollouts.length >= MAX_TRANSCRIPTS_PER_SOURCE) break;
53271
+ }
53272
+ if (rollouts.length >= MAX_TRANSCRIPTS_PER_SOURCE) break;
53273
+ }
53274
+ if (rollouts.length >= MAX_TRANSCRIPTS_PER_SOURCE) break;
53275
+ }
53276
+ const byCwd = /* @__PURE__ */ new Map();
53277
+ for (const rollout of rollouts) {
53278
+ const cwd = yield* readCwd(rollout);
53279
+ if (cwd === null) continue;
53280
+ const stats = yield* statOption(rollout);
53281
+ const transcript = {
53282
+ filePath: rollout,
53283
+ mtimeMs: isSome(stats) && isSome(stats.value.mtime) ? stats.value.mtime.value.getTime() : null
53284
+ };
53285
+ const existing = byCwd.get(cwd);
53286
+ if (existing) existing.push(transcript);
53287
+ else byCwd.set(cwd, [transcript]);
53288
+ }
53289
+ const candidates = [];
53290
+ for (const [cwd, transcripts] of byCwd) candidates.push({
53291
+ cwd,
53292
+ source: "codex",
53293
+ providerInstanceIds: [providerInstanceId],
53294
+ threadCount: transcripts.length,
53295
+ lastActiveAtMs: transcripts.reduce((latest, transcript) => transcript.mtimeMs === null ? latest : latest === null ? transcript.mtimeMs : Math.max(latest, transcript.mtimeMs), null),
53296
+ transcripts
53297
+ });
53298
+ return candidates;
53299
+ });
53300
+ const collectCandidates = fn("AgentSessionScanner.collectCandidates")(function* () {
53301
+ const settings = yield* serverSettings.getSettings.pipe(mapError((cause) => new AgentSessionScanError({
53302
+ operation: "read-settings",
53303
+ cause
53304
+ })));
53305
+ const raw = [];
53306
+ const scannedHomes = /* @__PURE__ */ new Map();
53307
+ for (const source of ["claudeAgent", "codex"]) {
53308
+ const instances = Object.entries(settings.providerInstances).filter(([, instance]) => instance.driver === source).map(([instanceId, config]) => ({
53309
+ instanceId: ProviderInstanceId.make(instanceId),
53310
+ config
53311
+ }));
53312
+ if (!Object.hasOwn(settings.providerInstances, source)) instances.push({
53313
+ instanceId: ProviderInstanceId.make(source),
53314
+ config: {
53315
+ driver: ProviderDriverKind.make(source),
53316
+ config: settings.providers[source]
53317
+ }
53318
+ });
53319
+ for (const { instanceId, config: instance } of instances) {
53320
+ const homeVariable = source === "claudeAgent" ? "CLAUDE_CONFIG_DIR" : "CODEX_HOME";
53321
+ const environmentHome = instance.environment?.findLast((variable) => variable.name === homeVariable)?.value ?? hostEnvironment[homeVariable];
53322
+ let homePath;
53323
+ if (source === "claudeAgent") {
53324
+ const config = decodeClaudeSettings$1(instance.config ?? {});
53325
+ if (isNone(config)) continue;
53326
+ homePath = resolveClaudeConfigDir(config.value.homePath, environmentHome);
53327
+ } else {
53328
+ const config = decodeCodexSettings$1(instance.config ?? {});
53329
+ if (isNone(config)) continue;
53330
+ homePath = (yield* resolveCodexHomeLayout(config.value.homePath.trim().length === 0 && config.value.shadowHomePath.trim().length === 0 && environmentHome?.trim() ? {
53331
+ ...config.value,
53332
+ homePath: environmentHome
53333
+ } : config.value).pipe(provideService(Path, path))).sharedHomePath;
53334
+ }
53335
+ const homeKey = `${source}\0${normalizeProjectPathForComparison(yield* fileSystem.realPath(homePath).pipe(orElseSucceed(() => homePath)))}`;
53336
+ const existingCandidates = scannedHomes.get(homeKey);
53337
+ if (existingCandidates !== void 0) {
53338
+ for (const candidate of existingCandidates) if (!candidate.providerInstanceIds.includes(instanceId)) candidate.providerInstanceIds.push(instanceId);
53339
+ continue;
53340
+ }
53341
+ const candidates = yield* source === "claudeAgent" ? scanClaude(homePath, instanceId) : scanCodex(homePath, instanceId);
53342
+ scannedHomes.set(homeKey, candidates);
53343
+ raw.push(...candidates);
53344
+ }
53345
+ }
53346
+ return raw;
53347
+ });
53348
+ let cachedCandidates = null;
53349
+ const scan = gen(function* () {
53350
+ const raw = yield* collectCandidates();
53351
+ cachedCandidates = raw;
53352
+ const merged = /* @__PURE__ */ new Map();
53353
+ const realPathKeys = /* @__PURE__ */ new Map();
53354
+ for (const candidate of raw) {
53355
+ const expanded = expandHomePath(candidate.cwd.trim());
53356
+ if (!path.isAbsolute(expanded)) continue;
53357
+ const resolved = path.resolve(expanded);
53358
+ if (isExcludedProjectPath(resolved)) continue;
53359
+ let key = realPathKeys.get(resolved);
53360
+ if (key === void 0) {
53361
+ const stats = yield* statOption(resolved);
53362
+ if (isNone(stats) || stats.value.type !== "Directory") {
53363
+ realPathKeys.set(resolved, "");
53364
+ continue;
53365
+ }
53366
+ key = yield* fileSystem.realPath(resolved).pipe(orElseSucceed(() => resolved));
53367
+ if (isExcludedProjectPath(key)) key = "";
53368
+ realPathKeys.set(resolved, key);
53369
+ }
53370
+ if (key === "") continue;
53371
+ const existing = merged.get(key);
53372
+ if (!existing) {
53373
+ merged.set(key, {
53374
+ path: resolved,
53375
+ sources: [candidate.source],
53376
+ threadCount: candidate.threadCount,
53377
+ lastActiveAtMs: candidate.lastActiveAtMs
53378
+ });
53379
+ continue;
53380
+ }
53381
+ if (!existing.sources.includes(candidate.source)) existing.sources.push(candidate.source);
53382
+ existing.threadCount += candidate.threadCount;
53383
+ existing.lastActiveAtMs = existing.lastActiveAtMs === null || candidate.lastActiveAtMs === null ? existing.lastActiveAtMs ?? candidate.lastActiveAtMs : Math.max(existing.lastActiveAtMs, candidate.lastActiveAtMs);
53384
+ }
53385
+ const shellSnapshot = yield* projectionSnapshotQuery.getShellSnapshot().pipe(mapError((cause) => new AgentSessionScanError({
53386
+ operation: "read-projects",
53387
+ cause
53388
+ })));
53389
+ const importedProjectsByRoot = /* @__PURE__ */ new Map();
53390
+ for (const project of shellSnapshot.projects) {
53391
+ const resolved = path.resolve(expandHomePath(project.workspaceRoot));
53392
+ importedProjectsByRoot.set(normalizeProjectPathForComparison(resolved), project.id);
53393
+ const realRoot = yield* fileSystem.realPath(resolved).pipe(orElseSucceed(() => resolved));
53394
+ importedProjectsByRoot.set(normalizeProjectPathForComparison(realRoot), project.id);
53395
+ }
53396
+ const candidates = [];
53397
+ for (const [key, entry] of merged.entries()) {
53398
+ const projectId = importedProjectsByRoot.get(normalizeProjectPathForComparison(entry.path)) ?? importedProjectsByRoot.get(normalizeProjectPathForComparison(key));
53399
+ candidates.push({
53400
+ path: entry.path,
53401
+ title: path.basename(entry.path) || entry.path,
53402
+ ...projectId === void 0 ? {} : { projectId },
53403
+ sources: entry.sources,
53404
+ threadCount: entry.threadCount,
53405
+ lastActiveAt: entry.lastActiveAtMs === null ? null : formatIso(makeUnsafe$6(entry.lastActiveAtMs)),
53406
+ alreadyImported: projectId !== void 0
53407
+ });
53408
+ }
53409
+ candidates.sort((left, right) => {
53410
+ if (left.lastActiveAt === right.lastActiveAt) return left.path.localeCompare(right.path);
53411
+ if (left.lastActiveAt === null) return 1;
53412
+ if (right.lastActiveAt === null) return -1;
53413
+ return right.lastActiveAt.localeCompare(left.lastActiveAt);
53414
+ });
53415
+ return {
53416
+ candidates,
53417
+ scannedAt: formatIso(yield* now$1)
53418
+ };
53419
+ });
53420
+ const prepareRecentThreads = fn("AgentSessionScanner.prepareRecentThreads")(function* (workspaceRoot) {
53421
+ const root = path.resolve(expandHomePath(workspaceRoot));
53422
+ const realRoot = yield* fileSystem.realPath(root).pipe(orElseSucceed(() => root));
53423
+ if (isExcludedProjectPath(root) || isExcludedProjectPath(realRoot)) return empty$7;
53424
+ const normalizedRoot = normalizeProjectPathForComparison(realRoot);
53425
+ const cutoffMs = toEpochMillis(yield* now$1) - RECENT_THREAD_WINDOW_MS;
53426
+ const candidates = cachedCandidates ?? (yield* collectCandidates());
53427
+ cachedCandidates = candidates;
53428
+ const eligibleTranscripts = [];
53429
+ for (const candidate of candidates) {
53430
+ const expanded = expandHomePath(candidate.cwd.trim());
53431
+ if (!path.isAbsolute(expanded)) continue;
53432
+ const resolved = path.resolve(expanded);
53433
+ if (normalizeProjectPathForComparison(yield* fileSystem.realPath(resolved).pipe(orElseSucceed(() => resolved))) !== normalizedRoot) continue;
53434
+ for (const transcript of candidate.transcripts) {
53435
+ if (transcript.mtimeMs === null || transcript.mtimeMs < cutoffMs) continue;
53436
+ eligibleTranscripts.push({
53437
+ candidate,
53438
+ transcript: {
53439
+ ...transcript,
53440
+ mtimeMs: transcript.mtimeMs
53441
+ }
53442
+ });
53443
+ }
53444
+ }
53445
+ eligibleTranscripts.sort((left, right) => {
53446
+ if (left.transcript.mtimeMs !== right.transcript.mtimeMs) return right.transcript.mtimeMs - left.transcript.mtimeMs;
53447
+ return left.transcript.filePath.localeCompare(right.transcript.filePath);
53448
+ });
53449
+ const importedSessions = /* @__PURE__ */ new Set();
53450
+ return fromIteratorSucceed(eligibleTranscripts.values(), 1).pipe(mapEffect$1(({ candidate, transcript }) => gen(function* () {
53451
+ const stats = yield* statOption(transcript.filePath);
53452
+ if (isNone(stats)) return [];
53453
+ const contents = yield* readTranscript(transcript.filePath, stats.value.size);
53454
+ if (contents === null) return [];
53455
+ const primaryInstanceId = candidate.providerInstanceIds[0];
53456
+ if (primaryInstanceId === void 0) return [];
53457
+ const parsedThread = parseAgentSessionTranscript({
53458
+ contents,
53459
+ source: candidate.source,
53460
+ providerInstanceId: primaryInstanceId,
53461
+ fallbackSessionId: path.basename(transcript.filePath, ".jsonl"),
53462
+ lastActiveAtMs: transcript.mtimeMs
53463
+ });
53464
+ if (parsedThread === null) return [];
53465
+ const threads = [];
53466
+ for (const providerInstanceId of candidate.providerInstanceIds) {
53467
+ const thread = providerInstanceId === primaryInstanceId ? parsedThread : {
53468
+ ...parsedThread,
53469
+ providerInstanceId
53470
+ };
53471
+ const sessionKey = `${thread.providerInstanceId}\0${thread.providerSessionId}`;
53472
+ if (importedSessions.has(sessionKey)) continue;
53473
+ importedSessions.add(sessionKey);
53474
+ threads.push(thread);
53475
+ }
53476
+ return threads;
53477
+ })), flatMap$2(fromIterable$1));
53478
+ });
53479
+ const recentThreads = (workspaceRoot) => unwrap$1(prepareRecentThreads(workspaceRoot));
53480
+ return AgentSessionScanner.of({
53481
+ scan,
53482
+ recentThreads
53483
+ });
53484
+ }));
53485
+ //#endregion
53486
+ //#region src/provider/Services/ProviderSessionDirectory.ts
53487
+ var ProviderSessionDirectory = class extends Service$2()("t3/provider/Services/ProviderSessionDirectory") {};
53488
+ //#endregion
53489
+ //#region src/project/AgentSessionImporter.ts
53490
+ const CLAUDE_SESSION_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
53491
+ var AgentSessionUnresumableSessionError = class extends TaggedErrorClass()("AgentSessionUnresumableSessionError", {
53492
+ source: AgentSessionSource,
53493
+ providerSessionId: String$1
53494
+ }) {
53495
+ get message() {
53496
+ return `Session '${this.providerSessionId}' from '${this.source}' cannot be resumed.`;
53497
+ }
53498
+ };
53499
+ var AgentSessionThreadProjectConflictError = class extends TaggedErrorClass()("AgentSessionThreadProjectConflictError", {
53500
+ threadId: ThreadId,
53501
+ expectedProjectId: ProjectId,
53502
+ actualProjectId: ProjectId
53503
+ }) {
53504
+ get message() {
53505
+ return `Imported thread '${this.threadId}' belongs to project '${this.actualProjectId}', not '${this.expectedProjectId}'.`;
53506
+ }
53507
+ };
53508
+ /** Import recent transcript text and persist the cursor needed to resume its provider session. */
53509
+ const importRecentAgentThreads = fn("importRecentAgentThreads")(function* (input) {
53510
+ const scanner = yield* AgentSessionScanner;
53511
+ const engine = yield* OrchestrationEngineService;
53512
+ const snapshots = yield* ProjectionSnapshotQuery;
53513
+ const directory = yield* ProviderSessionDirectory;
53514
+ const crypto = yield* Crypto;
53515
+ const workspaceRoot = (yield* snapshots.getProjectShellById(input.projectId).pipe(mapError((cause) => new AgentSessionScanError({
53516
+ operation: "read-projects",
53517
+ cause
53518
+ })), flatMap$1(match$1({
53519
+ onNone: () => fail(new AgentSessionImportProjectNotFoundError({ projectId: input.projectId })),
53520
+ onSome: succeed$1
53521
+ })))).workspaceRoot;
53522
+ const threads = scanner.recentThreads(workspaceRoot);
53523
+ let importedCount = 0;
53524
+ let skippedCount = 0;
53525
+ yield* runForEach(threads, (thread) => gen(function* () {
53526
+ if (yield* gen(function* () {
53527
+ const threadId = ThreadId.make(`import:${thread.providerInstanceId}:${thread.providerSessionId}`);
53528
+ const provider = ProviderDriverKind.make(thread.source);
53529
+ const model = thread.model ?? DEFAULT_MODEL_BY_PROVIDER[provider] ?? "gpt-5.6-sol";
53530
+ const existingThread = yield* snapshots.getThreadDetailById(threadId);
53531
+ const existingBinding = yield* directory.getBinding(threadId);
53532
+ if (thread.source === "claudeAgent" && !CLAUDE_SESSION_ID_PATTERN.test(thread.providerSessionId)) return yield* new AgentSessionUnresumableSessionError({
53533
+ source: thread.source,
53534
+ providerSessionId: thread.providerSessionId
53535
+ });
53536
+ if (isSome(existingThread) && existingThread.value.projectId !== input.projectId) return yield* new AgentSessionThreadProjectConflictError({
53537
+ threadId,
53538
+ expectedProjectId: input.projectId,
53539
+ actualProjectId: existingThread.value.projectId
53540
+ });
53541
+ if (isSome(existingThread) && isSome(existingBinding)) return true;
53542
+ if (isNone(existingThread)) yield* engine.dispatch({
53543
+ type: "thread.create",
53544
+ commandId: CommandId.make(yield* crypto.randomUUIDv4),
53545
+ threadId,
53546
+ projectId: input.projectId,
53547
+ title: thread.title,
53548
+ modelSelection: {
53549
+ instanceId: thread.providerInstanceId,
53550
+ model
53551
+ },
53552
+ runtimeMode: "full-access",
53553
+ interactionMode: "default",
53554
+ branch: null,
53555
+ worktreePath: null,
53556
+ createdAt: thread.createdAt
53557
+ });
53558
+ if (!(isSome(existingThread) ? existingThread.value.messages.some((message) => isImportedAgentSessionMessageId(message.id)) : false)) yield* engine.dispatch({
53559
+ type: "thread.history.import",
53560
+ commandId: CommandId.make(yield* crypto.randomUUIDv4),
53561
+ threadId,
53562
+ messages: thread.messages.map((message, index) => ({
53563
+ messageId: MessageId.make(`${threadId}:${String(index).padStart(6, "0")}`),
53564
+ role: message.role,
53565
+ text: message.text,
53566
+ createdAt: message.createdAt
53567
+ }))
53568
+ });
53569
+ if (isNone(existingBinding)) yield* directory.upsert({
53570
+ threadId,
53571
+ provider,
53572
+ providerInstanceId: thread.providerInstanceId,
53573
+ status: "stopped",
53574
+ runtimeMode: "full-access",
53575
+ resumeCursor: thread.source === "codex" ? { threadId: thread.providerSessionId } : {
53576
+ threadId,
53577
+ resume: thread.providerSessionId
53578
+ },
53579
+ runtimePayload: { cwd: workspaceRoot }
53580
+ }, { onConflict: "ignore" });
53581
+ return true;
53582
+ }).pipe(catch_((cause) => logWarning$1("Could not import an agent session", {
53583
+ provider: thread.source,
53584
+ sessionId: thread.providerSessionId,
53585
+ cause
53586
+ }).pipe(as(false))))) importedCount += 1;
53587
+ else skippedCount += 1;
53588
+ }));
53589
+ return {
53590
+ importedCount,
53591
+ skippedCount
53592
+ };
53593
+ });
53594
+ //#endregion
52527
53595
  //#region src/auth/RpcAuthorization.ts
52528
53596
  /**
52529
53597
  * Keep authorization coverage coupled to the RPC group itself. Adding an RPC to
@@ -52578,6 +53646,8 @@ const RPC_REQUIRED_SCOPES = {
52578
53646
  [WS_METHODS.projectsWriteFile]: AuthOrchestrationOperateScope,
52579
53647
  [WS_METHODS.shellOpenInEditor]: AuthOrchestrationOperateScope,
52580
53648
  [WS_METHODS.filesystemBrowse]: AuthOrchestrationReadScope,
53649
+ [WS_METHODS.agentSessionsScan]: AuthOrchestrationReadScope,
53650
+ [WS_METHODS.agentSessionsImport]: AuthOrchestrationOperateScope,
52581
53651
  [WS_METHODS.assetsCreateUrl]: AuthOrchestrationReadScope,
52582
53652
  [WS_METHODS.subscribeVcsStatus]: AuthOrchestrationReadScope,
52583
53653
  [WS_METHODS.subscribeResourceTelemetry]: AuthOrchestrationReadScope,
@@ -52627,6 +53697,133 @@ function requiredScopeForRpcMethod(method) {
52627
53697
  return requiredScope;
52628
53698
  }
52629
53699
  //#endregion
53700
+ //#region src/voiceInput/WhisperVoiceInput.ts
53701
+ const WHISPER_SAMPLE_RATE = 16e3;
53702
+ const DEFAULT_MAX_RECORDING_SECONDS = 120;
53703
+ const DEFAULT_WHISPER_MODEL = "onnx-community/whisper-small";
53704
+ var VoiceInputError = class extends Error {
53705
+ name = "VoiceInputError";
53706
+ };
53707
+ function invalidAudio(message) {
53708
+ return new VoiceInputError(`Invalid voice audio: ${message}`);
53709
+ }
53710
+ function decodePcm16Base64(data) {
53711
+ if (data.length === 0 || data.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(data)) throw invalidAudio("malformed base64");
53712
+ const bytes = Buffer.from(data, "base64");
53713
+ if (bytes.length === 0 || bytes.length % 2 !== 0) throw invalidAudio("PCM16 data must contain complete samples");
53714
+ const samples = new Int16Array(bytes.length / 2);
53715
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
53716
+ for (let index = 0; index < samples.length; index += 1) samples[index] = view.getInt16(index * 2, true);
53717
+ return samples;
53718
+ }
53719
+ function resamplePcm16ToFloat32(input, inputRate, outputRate = WHISPER_SAMPLE_RATE) {
53720
+ if (input.length === 0) return /* @__PURE__ */ new Float32Array(0);
53721
+ const outputLength = Math.max(1, Math.floor(input.length * outputRate / inputRate));
53722
+ const output = new Float32Array(outputLength);
53723
+ const ratio = inputRate / outputRate;
53724
+ for (let index = 0; index < outputLength; index += 1) {
53725
+ const source = index * ratio;
53726
+ const left = Math.floor(source);
53727
+ const right = Math.min(input.length - 1, left + 1);
53728
+ const fraction = source - left;
53729
+ output[index] = (input[left] * (1 - fraction) + input[right] * fraction) / 32768;
53730
+ }
53731
+ return output;
53732
+ }
53733
+ function combinePcm16(chunks) {
53734
+ const byteLength = chunks.reduce((total, chunk) => total + chunk.byteLength, 0);
53735
+ const bytes = new Uint8Array(byteLength);
53736
+ let offset = 0;
53737
+ for (const chunk of chunks) {
53738
+ bytes.set(chunk, offset);
53739
+ offset += chunk.byteLength;
53740
+ }
53741
+ return decodePcm16Base64(Buffer.from(bytes).toString("base64"));
53742
+ }
53743
+ const makeWhisperVoiceInput = (options) => gen(function* () {
53744
+ const events = yield* unbounded$1();
53745
+ const recordings = /* @__PURE__ */ new Map();
53746
+ const maxRecordingSeconds = options.maxRecordingSeconds ?? DEFAULT_MAX_RECORDING_SECONDS;
53747
+ let inferenceTail = Promise.resolve();
53748
+ const runTranscription = (audio) => {
53749
+ const result = inferenceTail.then(() => options.transcribe(audio));
53750
+ inferenceTail = result.then(() => void 0, () => void 0);
53751
+ return result;
53752
+ };
53753
+ return VoiceInput.of({
53754
+ start: (threadId) => sync(() => {
53755
+ recordings.set(threadId, {
53756
+ sampleRate: void 0,
53757
+ chunks: [],
53758
+ byteLength: 0
53759
+ });
53760
+ }),
53761
+ appendAudio: (threadId, input) => try_({
53762
+ try: () => {
53763
+ const bytes = Buffer.from(input.data, "base64");
53764
+ const decoded = decodePcm16Base64(input.data);
53765
+ if (input.samplesPerChannel !== void 0 && input.samplesPerChannel !== decoded.length) throw invalidAudio("sample count does not match payload");
53766
+ const recording = recordings.get(threadId);
53767
+ if (!recording) throw new VoiceInputError("Voice recording has not started");
53768
+ if (recording.sampleRate !== void 0 && recording.sampleRate !== input.sampleRate) throw invalidAudio("sample rate changed during recording");
53769
+ recording.sampleRate = input.sampleRate;
53770
+ const maxBytes = Math.floor(maxRecordingSeconds * input.sampleRate * 2);
53771
+ if (recording.byteLength + bytes.byteLength > maxBytes) throw new VoiceInputError("Voice recording is too long");
53772
+ recording.chunks.push(new Uint8Array(bytes));
53773
+ recording.byteLength += bytes.byteLength;
53774
+ },
53775
+ catch: (cause) => cause instanceof VoiceInputError ? cause : new VoiceInputError(cause instanceof Error ? cause.message : String(cause))
53776
+ }),
53777
+ stop: (threadId) => gen(function* () {
53778
+ const recording = recordings.get(threadId);
53779
+ if (!recording) return yield* fail(new VoiceInputError("Voice recording has not started"));
53780
+ recordings.delete(threadId);
53781
+ const text = recording.byteLength === 0 ? "" : yield* tryPromise({
53782
+ try: () => runTranscription(resamplePcm16ToFloat32(combinePcm16(recording.chunks), recording.sampleRate ?? WHISPER_SAMPLE_RATE)),
53783
+ catch: (cause) => new VoiceInputError(`Whisper transcription failed: ${cause instanceof Error ? cause.message : String(cause)}`)
53784
+ });
53785
+ yield* publish(events, {
53786
+ threadId,
53787
+ eventId: NodeCrypto.randomUUID(),
53788
+ role: "user",
53789
+ text: text.trim(),
53790
+ final: true
53791
+ });
53792
+ }),
53793
+ stream: (threadId) => fromPubSub(events).pipe(filter$2((event) => event.threadId === threadId))
53794
+ });
53795
+ });
53796
+ var VoiceInput = class extends Service$2()("agentlink/voiceInput/WhisperVoiceInput") {};
53797
+ function createLocalWhisperTranscriber(cacheDir) {
53798
+ let transcriberPromise;
53799
+ return async (audio) => {
53800
+ transcriberPromise ??= (async () => {
53801
+ try {
53802
+ await NodeFSP.mkdir(cacheDir, { recursive: true });
53803
+ const transformers = await import("@huggingface/transformers");
53804
+ transformers.env.cacheDir = cacheDir;
53805
+ return await transformers.pipeline("automatic-speech-recognition", DEFAULT_WHISPER_MODEL, { dtype: "q4" });
53806
+ } catch (cause) {
53807
+ transcriberPromise = void 0;
53808
+ throw cause;
53809
+ }
53810
+ })();
53811
+ const output = await (await transcriberPromise)(audio, {
53812
+ chunk_length_s: 30,
53813
+ stride_length_s: 5,
53814
+ language: "chinese",
53815
+ task: "transcribe"
53816
+ });
53817
+ const candidate = Array.isArray(output) ? output[0] : output;
53818
+ if (!candidate || typeof candidate !== "object" || typeof candidate.text !== "string") throw new Error("Whisper returned no transcript");
53819
+ return candidate.text ?? "";
53820
+ };
53821
+ }
53822
+ const layer$7 = effect(VoiceInput, gen(function* () {
53823
+ const config = yield* ServerConfig;
53824
+ return yield* makeWhisperVoiceInput({ transcribe: createLocalWhisperTranscriber(NodePath.join(config.stateDir, "models", "whisper")) });
53825
+ }));
53826
+ //#endregion
52630
53827
  //#region src/ws.ts
52631
53828
  const isOrchestrationDispatchCommandError = is(OrchestrationDispatchCommandError);
52632
53829
  const nowIso$2 = map$4(now$1, formatIso);
@@ -52779,9 +53976,6 @@ const wsRpcServices = gen(function* () {
52779
53976
  keybindings: yield* Keybindings,
52780
53977
  externalLauncher: yield* ExternalLauncher,
52781
53978
  providerRegistry: yield* ProviderRegistry,
52782
- providerAdapterRegistry: yield* ProviderAdapterRegistry,
52783
- providerSessionDirectory: yield* ProviderSessionDirectory,
52784
- providerService: yield* ProviderService,
52785
53979
  config: yield* ServerConfig,
52786
53980
  lifecycleEvents: yield* ServerLifecycleEvents,
52787
53981
  serverSettings: yield* ServerSettingsService,
@@ -52794,24 +53988,22 @@ const wsRpcServices = gen(function* () {
52794
53988
  backgroundPolicy: yield* BackgroundPolicy,
52795
53989
  serverAuth: yield* EnvironmentAuth,
52796
53990
  bootstrapCredentials: yield* PairingGrantStore,
52797
- sessions: yield* SessionStore
53991
+ sessions: yield* SessionStore,
53992
+ voiceInput: yield* VoiceInput
52798
53993
  };
52799
53994
  });
52800
53995
  const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
52801
53996
  const currentSessionId = currentSession.sessionId;
52802
- const { crypto, projectionSnapshotQuery, orchestrationEngine, providerRuntimeIngestion, keybindings, externalLauncher, providerRegistry, providerAdapterRegistry, providerSessionDirectory, providerService, config, lifecycleEvents, serverSettings, startup, workspaceEntries, workspaceFileSystem, gitWorkspace, terminalManager, serverEnvironment, backgroundPolicy, serverAuth, bootstrapCredentials, sessions } = yield* wsRpcServices;
53997
+ const { crypto, projectionSnapshotQuery, orchestrationEngine, providerRuntimeIngestion, keybindings, externalLauncher, providerRegistry, config, lifecycleEvents, serverSettings, startup, workspaceEntries, workspaceFileSystem, gitWorkspace, terminalManager, serverEnvironment, backgroundPolicy, serverAuth, bootstrapCredentials, sessions, voiceInput } = yield* wsRpcServices;
52803
53998
  const providerMaintenanceRunner = yield* ProviderMaintenanceRunner;
52804
- const rpcClientIds = yield* make$64(/* @__PURE__ */ new Set());
53999
+ const rpcClientIds = yield* make$65(/* @__PURE__ */ new Set());
52805
54000
  yield* addFinalizer(() => get$3(rpcClientIds).pipe(flatMap$1((clientIds) => forEach(clientIds, (clientId) => backgroundPolicy.removeRpcClient(currentSessionId, clientId), { discard: true })), ignore$1));
52806
54001
  const authorizationError = (requiredScope) => new EnvironmentAuthorizationError({
52807
54002
  message: `The authenticated token is missing required scope: ${requiredScope}.`,
52808
54003
  requiredScope
52809
54004
  });
52810
54005
  const voiceInputUnavailable = (message) => new VoiceInputUnavailableError({ message });
52811
- const resolveVoiceInput = (threadId) => providerSessionDirectory.getBinding(threadId).pipe(mapError((cause) => voiceInputUnavailable(cause.message)), flatMap$1((binding) => match$1(binding, {
52812
- onNone: () => fail(voiceInputUnavailable("Start a Codex conversation before using voice input.")),
52813
- onSome: (value) => value.provider !== "codex" ? fail(voiceInputUnavailable("Voice input is currently available for Codex only.")) : providerAdapterRegistry.getByInstance(value.providerInstanceId).pipe(mapError((cause) => voiceInputUnavailable(cause.message)))
52814
- })), flatMap$1((adapter) => adapter.capabilities.realtimeVoiceInput === true && adapter.realtimeVoiceInput ? succeed$1(adapter.realtimeVoiceInput) : fail(voiceInputUnavailable("Update this AgentLink daemon to use Codex voice input."))), tap(() => providerService.ensureSession(threadId).pipe(mapError((cause) => voiceInputUnavailable(cause.message)))));
54006
+ const mapVoiceInputError = (cause) => voiceInputUnavailable(cause.message);
52815
54007
  const authorizeEffect = (requiredScope, effect) => currentSession.scopes.includes(requiredScope) ? effect : fail(authorizationError(requiredScope));
52816
54008
  const authorizeStream = (requiredScope, stream) => currentSession.scopes.includes(requiredScope) ? stream : fail$5(authorizationError(requiredScope));
52817
54009
  const observeRpcEffect$1 = (method, effect, traceAttributes) => observeRpcEffect(method, authorizeEffect(requiredScopeForRpcMethod(method), effect), traceAttributes);
@@ -52977,20 +54169,20 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
52977
54169
  };
52978
54170
  });
52979
54171
  return WsRpcGroup.of({
52980
- [WS_METHODS.voiceInputStart]: ({ threadId }) => observeRpcEffect$1(WS_METHODS.voiceInputStart, resolveVoiceInput(threadId).pipe(flatMap$1((voice) => voice.start(threadId)), mapError((cause) => cause instanceof VoiceInputUnavailableError ? cause : voiceInputUnavailable(cause.message)), as({})), { "rpc.aggregate": "voice-input" }),
52981
- [WS_METHODS.voiceInputAppendAudio]: ({ threadId, data, sampleRate, numChannels, samplesPerChannel }) => observeRpcEffect$1(WS_METHODS.voiceInputAppendAudio, resolveVoiceInput(threadId).pipe(flatMap$1((voice) => voice.appendAudio(threadId, {
54172
+ [WS_METHODS.voiceInputStart]: ({ threadId }) => observeRpcEffect$1(WS_METHODS.voiceInputStart, voiceInput.start(threadId).pipe(as({})), { "rpc.aggregate": "voice-input" }),
54173
+ [WS_METHODS.voiceInputAppendAudio]: ({ threadId, data, sampleRate, numChannels, samplesPerChannel }) => observeRpcEffect$1(WS_METHODS.voiceInputAppendAudio, voiceInput.appendAudio(threadId, {
52982
54174
  data,
52983
54175
  sampleRate,
52984
54176
  numChannels,
52985
54177
  ...samplesPerChannel !== void 0 ? { samplesPerChannel } : {}
52986
- })), mapError((cause) => cause instanceof VoiceInputUnavailableError ? cause : voiceInputUnavailable(cause.message)), as({})), { "rpc.aggregate": "voice-input" }),
52987
- [WS_METHODS.voiceInputStop]: ({ threadId }) => observeRpcEffect$1(WS_METHODS.voiceInputStop, resolveVoiceInput(threadId).pipe(flatMap$1((voice) => voice.stop(threadId)), mapError((cause) => cause instanceof VoiceInputUnavailableError ? cause : voiceInputUnavailable(cause.message)), as({})), { "rpc.aggregate": "voice-input" }),
52988
- [WS_METHODS.subscribeVoiceInputTranscript]: ({ threadId }) => observeRpcStreamEffect$1(WS_METHODS.subscribeVoiceInputTranscript, resolveVoiceInput(threadId).pipe(as(providerService.streamEvents.pipe(filter$2((event) => event.threadId === threadId && (event.type === "thread.realtime.transcript.delta" || event.type === "thread.realtime.transcript.done")), map$8((event) => ({
52989
- eventId: event.eventId,
52990
- role: event.payload.role,
52991
- text: event.type === "thread.realtime.transcript.delta" ? event.payload.delta : event.payload.text,
52992
- final: event.type === "thread.realtime.transcript.done"
52993
- }))))), { "rpc.aggregate": "voice-input" }),
54178
+ }).pipe(mapError(mapVoiceInputError), as({})), { "rpc.aggregate": "voice-input" }),
54179
+ [WS_METHODS.voiceInputStop]: ({ threadId }) => observeRpcEffect$1(WS_METHODS.voiceInputStop, voiceInput.stop(threadId).pipe(mapError(mapVoiceInputError), as({})), { "rpc.aggregate": "voice-input" }),
54180
+ [WS_METHODS.subscribeVoiceInputTranscript]: ({ threadId }) => observeRpcStream$1(WS_METHODS.subscribeVoiceInputTranscript, voiceInput.stream(threadId).pipe(map$8(({ eventId, role, text, final }) => ({
54181
+ eventId,
54182
+ role,
54183
+ text,
54184
+ final
54185
+ }))), { "rpc.aggregate": "voice-input" }),
52994
54186
  [ORCHESTRATION_WS_METHODS.dispatchCommand]: (command) => observeRpcEffect$1(ORCHESTRATION_WS_METHODS.dispatchCommand, gen(function* () {
52995
54187
  const normalizedCommand = yield* normalizeDispatchCommand(command);
52996
54188
  const shouldStopSessionAfterArchive = normalizedCommand.type === "thread.archive" ? yield* projectionSnapshotQuery.getThreadShellById(normalizedCommand.threadId).pipe(map$4(match$1({
@@ -53036,7 +54228,7 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
53036
54228
  if (input.afterSequence !== void 0) {
53037
54229
  const afterSequence = input.afterSequence;
53038
54230
  const replayGap = (yield* orchestrationEngine.latestSequence) - afterSequence;
53039
- if (replayGap < 0 || replayGap > SHELL_RESUME_MAX_GAP) return concat(make$75({
54231
+ if (replayGap < 0 || replayGap > SHELL_RESUME_MAX_GAP) return concat(make$76({
53040
54232
  kind: "snapshot",
53041
54233
  snapshot: yield* loadSnapshot
53042
54234
  }), synchronizedThenLive);
@@ -53045,7 +54237,7 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
53045
54237
  cause
53046
54238
  }))), synchronizedThenLive);
53047
54239
  }
53048
- return concat(make$75({
54240
+ return concat(make$76({
53049
54241
  kind: "snapshot",
53050
54242
  snapshot: yield* loadSnapshot
53051
54243
  }), synchronizedThenLive);
@@ -53087,7 +54279,7 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
53087
54279
  cause: input.threadId
53088
54280
  });
53089
54281
  const afterSnapshot = input.requestCompletionMarker === true ? concat(fromEffect(offer$1(liveBuffer, { kind: "synchronized" })).pipe(drain), bufferedLiveStream) : bufferedLiveStream;
53090
- return concat(make$75({
54282
+ return concat(make$76({
53091
54283
  kind: "snapshot",
53092
54284
  snapshot: projectThreadDetailSnapshot(snapshot.value)
53093
54285
  }), afterSnapshot);
@@ -53156,6 +54348,8 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
53156
54348
  ...filesystemBrowseFailureContext(cause),
53157
54349
  cause
53158
54350
  }))), { "rpc.aggregate": "workspace" }),
54351
+ [WS_METHODS.agentSessionsScan]: () => observeRpcEffect$1(WS_METHODS.agentSessionsScan, AgentSessionScanner.pipe(flatMap$1((scanner) => scanner.scan), provide$1(layer$8)), { "rpc.aggregate": "workspace" }),
54352
+ [WS_METHODS.agentSessionsImport]: (input) => observeRpcEffect$1(WS_METHODS.agentSessionsImport, importRecentAgentThreads(input).pipe(provide$1(layer$8)), { "rpc.aggregate": "workspace" }),
53159
54353
  [WS_METHODS.assetsCreateUrl]: (input) => observeRpcEffect$1(WS_METHODS.assetsCreateUrl, gen(function* () {
53160
54354
  if (input.resource._tag !== "workspace-file") return yield* issueAssetUrl({ resource: input.resource });
53161
54355
  const thread = yield* projectionSnapshotQuery.getThreadShellById(input.resource.threadId).pipe(mapError((cause) => new AssetWorkspaceContextResolutionError({
@@ -53194,7 +54388,7 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
53194
54388
  })));
53195
54389
  yield* providerRegistry.refresh().pipe(ignoreCause({ log: true }), forkScoped);
53196
54390
  const liveUpdates = merge$2(keybindingsUpdates, merge$2(providerStatuses, settingsUpdates));
53197
- return concat(make$75({
54391
+ return concat(make$76({
53198
54392
  version: 1,
53199
54393
  type: "snapshot",
53200
54394
  config: yield* loadServerConfig
@@ -53208,9 +54402,9 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
53208
54402
  }), { "rpc.aggregate": "server" }),
53209
54403
  [WS_METHODS.subscribeAuthAccess]: (_input) => observeRpcStreamEffect$1(WS_METHODS.subscribeAuthAccess, gen(function* () {
53210
54404
  const initialSnapshot = yield* loadAuthAccessSnapshot();
53211
- const revisionRef = yield* make$64(1);
54405
+ const revisionRef = yield* make$65(1);
53212
54406
  const liveEvents = merge$2(bootstrapCredentials.streamChanges, sessions.streamChanges).pipe(mapEffect$1((change) => updateAndGet(revisionRef, (revision) => revision + 1).pipe(map$4((revision) => toAuthAccessStreamEvent(change, revision, currentSessionId)))));
53213
- return concat(make$75({
54407
+ return concat(make$76({
53214
54408
  version: 1,
53215
54409
  revision: 1,
53216
54410
  type: "snapshot",
@@ -53270,7 +54464,7 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
53270
54464
  [ORCHESTRATION_WS_METHODS.getFullThreadDiff]: unsupportedRpc,
53271
54465
  [ORCHESTRATION_WS_METHODS.getTurnDiff]: unsupportedRpc,
53272
54466
  [ORCHESTRATION_WS_METHODS.getWorkflowScript]: unsupportedRpc,
53273
- [WS_METHODS.subscribeBackgroundPolicy]: (_input) => observeRpcStream$1(WS_METHODS.subscribeBackgroundPolicy, unwrap$1(map$4(backgroundPolicy.subscribe, ({ latest, changes }) => concat(make$75(latest), changes))), { "rpc.aggregate": "server" })
54467
+ [WS_METHODS.subscribeBackgroundPolicy]: (_input) => observeRpcStream$1(WS_METHODS.subscribeBackgroundPolicy, unwrap$1(map$4(backgroundPolicy.subscribe, ({ latest, changes }) => concat(make$76(latest), changes))), { "rpc.aggregate": "server" })
53274
54468
  });
53275
54469
  }));
53276
54470
  const websocketRpcRouteLayer = unwrap(gen(function* () {
@@ -53279,7 +54473,7 @@ const websocketRpcRouteLayer = unwrap(gen(function* () {
53279
54473
  const serverAuth = yield* EnvironmentAuth;
53280
54474
  const sessions = yield* SessionStore;
53281
54475
  const session = yield* serverAuth.authenticateWebSocketUpgrade(request).pipe(catchIf(isServerAuthCredentialError, (error) => failEnvironmentAuthInvalid(serverAuthCredentialReason(error))), catchIf(isServerAuthInternalError, (error) => failEnvironmentInternal("internal_error", error)));
53282
- const rpcWebSocketHttpEffect = yield* toHttpEffectWebsocket(WsRpcGroup, { disableTracing: true }).pipe(provide$1(makeWsRpcLayer(session).pipe(provideMerge(layerJson), provide(layer$12))));
54476
+ const rpcWebSocketHttpEffect = yield* toHttpEffectWebsocket(WsRpcGroup, { disableTracing: true }).pipe(provide$1(makeWsRpcLayer(session).pipe(provideMerge(layerJson), provide(layer$14))));
53283
54477
  return yield* acquireUseRelease(sessions.markConnected(session.sessionId), () => rpcWebSocketHttpEffect, () => sessions.markDisconnected(session.sessionId));
53284
54478
  }).pipe(catchTags({
53285
54479
  EnvironmentAuthInvalidError: toResponse,
@@ -53467,7 +54661,7 @@ const ResponseDefectEncoded = (cause) => ({
53467
54661
  });
53468
54662
  const makeTunnelSocketProtocol = gen(function* () {
53469
54663
  const serialization = yield* RpcSerialization;
53470
- const disconnects = yield* make$79();
54664
+ const disconnects = yield* make$80();
53471
54665
  let clientId = 0;
53472
54666
  const clients = /* @__PURE__ */ new Map();
53473
54667
  const clientIds = /* @__PURE__ */ new Set();
@@ -53549,7 +54743,7 @@ function encodeHttpTunnelResponseFrame(frame) {
53549
54743
  }
53550
54744
  const makeTunnelSocket = (input) => {
53551
54745
  const runRaw = (handler, options) => scopedWith((scope) => gen(function* () {
53552
- const fiberSet = yield* make$66().pipe(provide$2(scope));
54746
+ const fiberSet = yield* make$67().pipe(provide$2(scope));
53553
54747
  const runFork = yield* runtime(fiberSet)();
53554
54748
  const deliver = (frame) => {
53555
54749
  const handled = handler(frame);
@@ -53560,7 +54754,7 @@ const makeTunnelSocket = (input) => {
53560
54754
  if (options?.onOpen) yield* options.onOpen;
53561
54755
  yield* _await(input.tunnel.closed).pipe(raceFirst(join$1(fiberSet)));
53562
54756
  }));
53563
- return make$67({
54757
+ return make$68({
53564
54758
  runRaw,
53565
54759
  writer: sync(() => (chunk) => sync(() => {
53566
54760
  if (typeof chunk === "string") for (const part of chunkAgentLinkFrame(chunk)) input.sendEncrypted(JSON.stringify(utf8ToEnvelope(input.enckey, part)));
@@ -53640,8 +54834,8 @@ const runHubTunnel = (config) => gen(function* () {
53640
54834
  subject: "hub-tunnel",
53641
54835
  method: "bearer-access-token",
53642
54836
  scopes: [...TUNNEL_SCOPES]
53643
- }).pipe(provideMerge(layerJson), provide(layer$12))).pipe(provideContext(currentContext));
53644
- yield* make$17(WsRpcGroup, { disableTracing: true }).pipe(provideService(Protocol, protocol), provideContext(rpcContext));
54837
+ }).pipe(provideMerge(layerJson), provide(layer$14))).pipe(provideContext(currentContext));
54838
+ yield* make$18(WsRpcGroup, { disableTracing: true }).pipe(provideService(Protocol, protocol), provideContext(rpcContext));
53645
54839
  }).pipe(tapCause((cause) => logError("hub tunnel: RPC server failed", { cause: String(cause) }))));
53646
54840
  yield* forkScoped(onSocket(socketAdapter));
53647
54841
  if (!writeHub(JSON.stringify({
@@ -53747,7 +54941,7 @@ const runHubTunnel = (config) => gen(function* () {
53747
54941
  if (requestFrame.targetPort === void 0 ? lower === "authorization" || lower === "cookie" : !isPortProxyRequestHeaderAllowed(lower)) continue;
53748
54942
  headers[lower] = value;
53749
54943
  }
53750
- let request = make$65(requestFrame.method)(targetUrl).pipe(setHeaders(headers));
54944
+ let request = make$66(requestFrame.method)(targetUrl).pipe(setHeaders(headers));
53751
54945
  if (requestFrame.body !== null) request = setBody(uint8Array(Buffer.from(requestFrame.body, "base64")))(request);
53752
54946
  const response = yield* httpClient.execute(request);
53753
54947
  const responseBody = yield* response.arrayBuffer;
@@ -53800,7 +54994,7 @@ const runHubTunnel = (config) => gen(function* () {
53800
54994
  const tunnelId = control.tunnelId;
53801
54995
  if (tunnels.has(tunnelId)) return;
53802
54996
  return gen(function* () {
53803
- const closed = yield* make$74();
54997
+ const closed = yield* make$75();
53804
54998
  const purpose = control.purpose === "http" ? "http" : "rpc";
53805
54999
  const live = {
53806
55000
  closed,
@@ -53925,7 +55119,7 @@ function detailForPhase(phase, thread) {
53925
55119
  */
53926
55120
  const makeDrainableWorker = (process) => gen(function* () {
53927
55121
  const queue = yield* acquireRelease(unbounded(), shutdown);
53928
- const outstanding = yield* make$53(0);
55122
+ const outstanding = yield* make$54(0);
53929
55123
  yield* take(queue).pipe(tap((a) => ensuring(process(a), update$1(outstanding, (n) => n - 1))), forever, forkScoped);
53930
55124
  const drain = get$1(outstanding).pipe(tap((n) => n > 0 ? txRetry : void_$1), tx);
53931
55125
  const enqueue = (element) => offer(queue, element).pipe(tap(() => update$1(outstanding, (n) => n + 1)), tx);
@@ -53957,7 +55151,7 @@ const make$10 = (config) => gen(function* () {
53957
55151
  const environment = yield* ServerEnvironment;
53958
55152
  const snapshots = yield* ProjectionSnapshotQuery;
53959
55153
  const engine = yield* OrchestrationEngineService;
53960
- const published = yield* make$64(/* @__PURE__ */ new Map());
55154
+ const published = yield* make$65(/* @__PURE__ */ new Map());
53961
55155
  const publishThread = fn("AgentAwarenessHub.publishThread")(function* (threadId) {
53962
55156
  const thread = yield* snapshots.getThreadShellById(threadId);
53963
55157
  if (isNone(thread)) return;
@@ -54106,6 +55300,20 @@ const layer$4 = effect(ProviderSessionRuntimeRepository, gen(function* () {
54106
55300
  last_seen_at = excluded.last_seen_at,
54107
55301
  resume_cursor_json = excluded.resume_cursor_json,
54108
55302
  runtime_payload_json = excluded.runtime_payload_json
55303
+ `
55304
+ });
55305
+ const insertRuntimeRow = void_({
55306
+ Request: ProviderSessionRuntimeDbRowSchema,
55307
+ execute: (runtime) => sql`
55308
+ INSERT INTO provider_session_runtime (
55309
+ thread_id, provider_name, provider_instance_id, adapter_key,
55310
+ runtime_mode, status, last_seen_at, resume_cursor_json, runtime_payload_json
55311
+ ) VALUES (
55312
+ ${runtime.threadId}, ${runtime.providerName}, ${runtime.providerInstanceId},
55313
+ ${runtime.adapterKey}, ${runtime.runtimeMode}, ${runtime.status},
55314
+ ${runtime.lastSeenAt}, ${runtime.resumeCursor}, ${runtime.runtimePayload}
55315
+ )
55316
+ ON CONFLICT (thread_id) DO NOTHING
54109
55317
  `
54110
55318
  });
54111
55319
  const getRuntimeRowByThreadId = findOneOption({
@@ -54151,7 +55359,7 @@ const layer$4 = effect(ProviderSessionRuntimeRepository, gen(function* () {
54151
55359
  WHERE thread_id = ${threadId}
54152
55360
  `
54153
55361
  });
54154
- const upsert = (runtime) => upsertRuntimeRow(runtime).pipe(mapError(toPersistenceSqlOrDecodeError("ProviderSessionRuntimeRepository.upsert:query", "ProviderSessionRuntimeRepository.upsert:encodeRequest", { threadId: runtime.threadId })));
55362
+ const upsert = (runtime, options) => (options?.onConflict === "ignore" ? insertRuntimeRow(runtime) : upsertRuntimeRow(runtime)).pipe(mapError(toPersistenceSqlOrDecodeError("ProviderSessionRuntimeRepository.upsert:query", "ProviderSessionRuntimeRepository.upsert:encodeRequest", { threadId: runtime.threadId })));
54155
55363
  const getByThreadId = (input) => getRuntimeRowByThreadId(input).pipe(mapError(toPersistenceSqlOrDecodeError("ProviderSessionRuntimeRepository.getByThreadId:query", "ProviderSessionRuntimeRepository.getByThreadId:decodeRow", { threadId: input.threadId })), flatMap$1((runtimeRowOption) => match$1(runtimeRowOption, {
54156
55364
  onNone: () => succeed$1(none()),
54157
55365
  onSome: (row) => decodeRuntimeRow(row).pipe(mapError((cause) => PersistenceDecodeError.fromSchemaError("ProviderSessionRuntimeRepository.getByThreadId:decodeRow", cause, { threadId: input.threadId })), map$4((runtime) => some(runtime)))
@@ -54342,7 +55550,7 @@ const ProviderSessionDirectoryLive = effect(ProviderSessionDirectory, gen(functi
54342
55550
  onNone: () => succeed$1(none()),
54343
55551
  onSome: (value) => toRuntimeBinding(value, "ProviderSessionDirectory.getBinding").pipe(map$4((binding) => some(binding)))
54344
55552
  })));
54345
- const upsert = fn(function* (binding) {
55553
+ const upsert = fn(function* (binding, options) {
54346
55554
  const existingRuntime = getOrUndefined(yield* repository.getByThreadId({ threadId: binding.threadId }).pipe(mapError(toPersistenceError("ProviderSessionDirectory.upsert:getByThreadId"))));
54347
55555
  const resolvedThreadId = binding.threadId ?? existingRuntime?.threadId;
54348
55556
  if (!resolvedThreadId) return yield* new ProviderValidationError({
@@ -54366,7 +55574,7 @@ const ProviderSessionDirectoryLive = effect(ProviderSessionDirectory, gen(functi
54366
55574
  lastSeenAt: now,
54367
55575
  resumeCursor: binding.resumeCursor !== void 0 ? binding.resumeCursor : existingRuntime?.resumeCursor ?? null,
54368
55576
  runtimePayload: mergeRuntimePayload(existingRuntime?.runtimePayload ?? null, binding.runtimePayload)
54369
- }).pipe(mapError(toPersistenceError("ProviderSessionDirectory.upsert:upsert")));
55577
+ }, options).pipe(mapError(toPersistenceError("ProviderSessionDirectory.upsert:upsert")));
54370
55578
  });
54371
55579
  const getProvider = (threadId) => getBinding(threadId).pipe(flatMap$1((binding) => match$1(binding, {
54372
55580
  onSome: (value) => succeed$1(value.provider),
@@ -54388,6 +55596,12 @@ const ProviderSessionDirectoryLive = effect(ProviderSessionDirectory, gen(functi
54388
55596
  //#endregion
54389
55597
  //#region src/provider/Services/ProviderInstanceRegistry.ts
54390
55598
  var ProviderInstanceRegistry = class extends Service$2()("t3/provider/Services/ProviderInstanceRegistry") {};
55599
+ //#endregion
55600
+ //#region src/provider/Services/ProviderAdapterRegistry.ts
55601
+ /**
55602
+ * ProviderAdapterRegistry - Service tag for provider adapter lookup.
55603
+ */
55604
+ var ProviderAdapterRegistry = class extends Service$2()("t3/provider/Services/ProviderAdapterRegistry") {};
54391
55605
  const ProviderAdapterRegistryLive = effect(ProviderAdapterRegistry, fn("makeProviderAdapterRegistry")(function* () {
54392
55606
  const registry = yield* ProviderInstanceRegistry;
54393
55607
  const getByInstance = (instanceId) => registry.getInstance(instanceId).pipe(flatMap$1((instance) => instance === void 0 ? fail(new ProviderUnsupportedError({ provider: instanceId })) : succeed$1(instance.adapter)));
@@ -54750,7 +55964,7 @@ const makeEventNdjsonLogStore = fnUntraced(function* (filePath, options = {}) {
54750
55964
  filePath: failure.filePath,
54751
55965
  errorTag: errorTag(failure.cause)
54752
55966
  });
54753
- const stateRef = yield* make$54({
55967
+ const stateRef = yield* make$55({
54754
55968
  pending: [],
54755
55969
  pendingBytes: 0,
54756
55970
  sinks: /* @__PURE__ */ new Map(),
@@ -54758,7 +55972,7 @@ const makeEventNdjsonLogStore = fnUntraced(function* (filePath, options = {}) {
54758
55972
  closed: false,
54759
55973
  lastRetentionAt: initializedAt
54760
55974
  });
54761
- const timerScope = yield* make$77();
55975
+ const timerScope = yield* make$78();
54762
55976
  const flush = fnUntraced(function* (timerFired, close) {
54763
55977
  const startedAt = yield* currentTimeMillis;
54764
55978
  const result = yield* modifyEffect(stateRef, (state) => sync(() => drainPending({
@@ -54903,6 +56117,12 @@ const layer$3 = effect(ProviderEventLoggers, gen(function* () {
54903
56117
  });
54904
56118
  }));
54905
56119
  //#endregion
56120
+ //#region src/provider/Services/ProviderService.ts
56121
+ /**
56122
+ * ProviderService - Service tag for provider orchestration.
56123
+ */
56124
+ var ProviderService = class extends Service$2()("t3/provider/Services/ProviderService") {};
56125
+ //#endregion
54906
56126
  //#region src/provider/Layers/ProviderService.ts
54907
56127
  /**
54908
56128
  * ProviderServiceLive - Cross-provider orchestration layer.
@@ -55003,7 +56223,7 @@ const ProviderServiceLive = effect(ProviderService, fn("makeProviderService")(fu
55003
56223
  provider: canonicalEvent.provider,
55004
56224
  eventType: canonicalEvent.type
55005
56225
  }).pipe(andThen(publishRuntimeEvent(canonicalEvent)))));
55006
- const subscribedAdapters = yield* make$64(/* @__PURE__ */ new Map());
56226
+ const subscribedAdapters = yield* make$65(/* @__PURE__ */ new Map());
55007
56227
  const getAdapterEntries = get$3(subscribedAdapters).pipe(map$4((map) => Array.from(map.entries())));
55008
56228
  const reconcileInstanceSubscriptions = gen(function* () {
55009
56229
  const previous = yield* get$3(subscribedAdapters);
@@ -56051,26 +57271,6 @@ const resolveClaudeSdkExecutablePath = fn("resolveClaudeSdkExecutablePath")(func
56051
57271
  return binaryPath;
56052
57272
  });
56053
57273
  //#endregion
56054
- //#region src/pathExpansion.ts
56055
- /**
56056
- * Expand a leading `~` (or `~/…`, `~\…`) in a user-supplied path to the
56057
- * current user's home directory. Spawned processes don't get shell
56058
- * expansion, so env vars like `CODEX_HOME=~/.codex-work` would be passed
56059
- * verbatim and treated as relative paths by the receiver.
56060
- *
56061
- * Matches the behavior of the other `expandHomePath` helpers in the
56062
- * workspace layers and CLI bootstrap: `~` alone and both `~/` and `~\`
56063
- * separators are handled. Returns the input unchanged if it doesn't
56064
- * start with `~` or is empty. Does not handle `~user` (other-user)
56065
- * expansion.
56066
- */
56067
- function expandHomePath(value) {
56068
- if (!value) return value;
56069
- if (value === "~") return NodeOS.homedir();
56070
- if (value.startsWith("~/") || value.startsWith("~\\")) return NodePath.join(NodeOS.homedir(), value.slice(2));
56071
- return value;
56072
- }
56073
- //#endregion
56074
57274
  //#region src/provider/Drivers/ClaudeHome.ts
56075
57275
  const resolveClaudeHomePath = fn("resolveClaudeHomePath")(function* (config) {
56076
57276
  const path = yield* Path;
@@ -56215,12 +57415,12 @@ function unavailableUsageLimits(source, checkedAt, reason) {
56215
57415
  };
56216
57416
  }
56217
57417
  function epochSecondsToIso(value) {
56218
- const dateTime = make$72(value * 1e3);
57418
+ const dateTime = make$73(value * 1e3);
56219
57419
  return isSome(dateTime) ? formatIso(dateTime.value) : void 0;
56220
57420
  }
56221
57421
  function normalizeIsoTimestamp(value) {
56222
57422
  if (!value) return void 0;
56223
- const dateTime = make$72(value);
57423
+ const dateTime = make$73(value);
56224
57424
  return isSome(dateTime) ? formatIso(dateTime.value) : void 0;
56225
57425
  }
56226
57426
  function resolveCodexUsageLimits(input) {
@@ -56939,7 +58139,7 @@ const probeClaudeCapabilities = (claudeSettings, environment, cwd) => {
56939
58139
  const runClaudeCommand = fn("runClaudeCommand")(function* (claudeSettings, args, environment) {
56940
58140
  const claudeEnvironment = yield* makeClaudeEnvironment(claudeSettings, environment);
56941
58141
  const spawnCommand = yield* resolveSpawnCommand(claudeSettings.binaryPath, args, { env: claudeEnvironment });
56942
- const command = make$80(spawnCommand.command, spawnCommand.args, {
58142
+ const command = make$81(spawnCommand.command, spawnCommand.args, {
56943
58143
  env: claudeEnvironment,
56944
58144
  shell: spawnCommand.shell
56945
58145
  });
@@ -57161,11 +58361,11 @@ const makeClaudeTextGeneration = fn("makeClaudeTextGeneration")(function* (claud
57161
58361
  ...settingsJson ? ["--settings", settingsJson] : [],
57162
58362
  "--dangerously-skip-permissions"
57163
58363
  ], { env: claudeEnvironment });
57164
- const command = make$80(spawnCommand.command, spawnCommand.args, {
58364
+ const command = make$81(spawnCommand.command, spawnCommand.args, {
57165
58365
  env: claudeEnvironment,
57166
58366
  cwd,
57167
58367
  shell: spawnCommand.shell,
57168
- stdin: { stream: encodeText(make$75(prompt)) }
58368
+ stdin: { stream: encodeText(make$76(prompt)) }
57169
58369
  });
57170
58370
  const child = yield* commandSpawner.spawn(command).pipe(mapError((cause) => normalizeCliError("claude", operation, cause, "Failed to spawn Claude CLI process")));
57171
58371
  const [stdout, stderr, exitCode] = yield* all([
@@ -59507,7 +60707,7 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
59507
60707
  const taskAgents = /* @__PURE__ */ new Map();
59508
60708
  const workflowMemberFingerprints = /* @__PURE__ */ new Map();
59509
60709
  const liveTaskIds = /* @__PURE__ */ new Set();
59510
- const contextRef = yield* make$64(void 0);
60710
+ const contextRef = yield* make$65(void 0);
59511
60711
  /**
59512
60712
  * Handle AskUserQuestion tool calls by emitting a `user-input.requested`
59513
60713
  * runtime event and waiting for the user to respond via `respondToUserInput`.
@@ -59524,7 +60724,7 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
59524
60724
  })) : [],
59525
60725
  multiSelect: typeof q.multiSelect === "boolean" ? q.multiSelect : false
59526
60726
  }));
59527
- const answersDeferred = yield* make$74();
60727
+ const answersDeferred = yield* make$75();
59528
60728
  let aborted = false;
59529
60729
  const pendingInput = {
59530
60730
  questions,
@@ -59620,7 +60820,7 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
59620
60820
  const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
59621
60821
  const requestType = classifyRequestType(toolName);
59622
60822
  const detail = summarizeToolRequest(toolName, toolInput);
59623
- const decisionDeferred = yield* make$74();
60823
+ const decisionDeferred = yield* make$75();
59624
60824
  const pendingApproval = {
59625
60825
  requestType,
59626
60826
  detail,
@@ -60025,15 +61225,15 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
60025
61225
  const makeManagedServerProvider = fn("makeManagedServerProvider")(function* (input) {
60026
61226
  const backgroundPolicy = yield* BackgroundPolicy;
60027
61227
  const serverSettings = yield* ServerSettingsService;
60028
- const refreshSemaphore = yield* make$76(1);
61228
+ const refreshSemaphore = yield* make$77(1);
60029
61229
  const changesPubSub = yield* acquireRelease(unbounded$1(), shutdown$2);
60030
61230
  const initialSettings = yield* input.getSettings;
60031
- const snapshotStateRef = yield* make$64({
61231
+ const snapshotStateRef = yield* make$65({
60032
61232
  snapshot: yield* input.initialSnapshot(initialSettings),
60033
61233
  enrichmentGeneration: 0
60034
61234
  });
60035
- const settingsRef = yield* make$64(initialSettings);
60036
- const enrichmentFiberRef = yield* make$64(null);
61235
+ const settingsRef = yield* make$65(initialSettings);
61236
+ const enrichmentFiberRef = yield* make$65(null);
60037
61237
  const scope$1 = yield* scope;
60038
61238
  const publishEnrichedSnapshot = fn("publishEnrichedSnapshot")(function* (generation, nextSnapshot) {
60039
61239
  const snapshotToPublish = yield* modify$2(snapshotStateRef, (state) => {
@@ -60224,7 +61424,7 @@ const ClaudeDriver = {
60224
61424
  ...eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}
60225
61425
  });
60226
61426
  const textGeneration = yield* makeClaudeTextGeneration(effectiveConfig, processEnv);
60227
- const capabilitiesProbeCache = yield* make$82({
61427
+ const capabilitiesProbeCache = yield* make$83({
60228
61428
  capacity: 1,
60229
61429
  timeToLive: CAPABILITIES_PROBE_TTL,
60230
61430
  lookup: () => probeClaudeCapabilities(effectiveConfig, processEnv, cwd).pipe(provideService(Path, path))
@@ -60360,14 +61560,14 @@ const makeCodexTextGeneration = fn("makeCodexTextGeneration")(function* (codexCo
60360
61560
  ...imagePaths.flatMap((imagePath) => ["--image", imagePath]),
60361
61561
  "-"
60362
61562
  ], { env: resolvedEnvironment });
60363
- const command = make$80(spawnCommand.command, spawnCommand.args, {
61563
+ const command = make$81(spawnCommand.command, spawnCommand.args, {
60364
61564
  env: {
60365
61565
  ...resolvedEnvironment,
60366
61566
  ...codexConfig.homePath ? { CODEX_HOME: expandHomePath(codexConfig.homePath) } : {}
60367
61567
  },
60368
61568
  cwd,
60369
61569
  shell: spawnCommand.shell,
60370
- stdin: { stream: encodeText(make$75(prompt)) }
61570
+ stdin: { stream: encodeText(make$76(prompt)) }
60371
61571
  });
60372
61572
  const child = yield* commandSpawner.spawn(command).pipe(mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to spawn Codex CLI process")));
60373
61573
  const [stdout, stderr, exitCode] = yield* all([
@@ -78320,10 +79520,10 @@ const makeCodexAppServerPatchedProtocol = fn("makeCodexAppServerPatchedProtocol"
78320
79520
  const outgoing = yield* unbounded$2();
78321
79521
  const incomingNotifications = yield* unbounded$2();
78322
79522
  const incomingRequests = yield* unbounded$2();
78323
- const pending = yield* make$64(/* @__PURE__ */ new Map());
78324
- const nextRequestId = yield* make$64(1);
78325
- const remainder = yield* make$64("");
78326
- const terminationHandled = yield* make$64(false);
79523
+ const pending = yield* make$65(/* @__PURE__ */ new Map());
79524
+ const nextRequestId = yield* make$65(1);
79525
+ const remainder = yield* make$65("");
79526
+ const terminationHandled = yield* make$65(false);
78327
79527
  const logProtocol = (event) => {
78328
79528
  if (event.direction === "incoming" && !options.logIncoming) return void_$1;
78329
79529
  if (event.direction === "outgoing" && !options.logOutgoing) return void_$1;
@@ -78422,7 +79622,7 @@ const makeCodexAppServerPatchedProtocol = fn("makeCodexAppServerPatchedProtocol"
78422
79622
  yield* fromQueue(outgoing).pipe(run$5(options.stdio.stdout()), forkScoped);
78423
79623
  const request = (method, payload) => gen(function* () {
78424
79624
  const requestId = yield* modify$2(nextRequestId, (current) => [current, current + 1]);
78425
- const deferred = yield* make$74();
79625
+ const deferred = yield* make$75();
78426
79626
  yield* update$2(pending, (current) => new Map(current).set(String(requestId), {
78427
79627
  deferred,
78428
79628
  method
@@ -78450,7 +79650,7 @@ const makeCodexAppServerPatchedProtocol = fn("makeCodexAppServerPatchedProtocol"
78450
79650
  //#endregion
78451
79651
  //#region ../effect-codex-app-server/src/_internal/stdio.ts
78452
79652
  const encoder$2 = new TextEncoder();
78453
- const makeChildStdio$1 = (handle) => make$81({
79653
+ const makeChildStdio$1 = (handle) => make$82({
78454
79654
  args: succeed$1([]),
78455
79655
  stdin: handle.stdout,
78456
79656
  stdout: () => mapInput(handle.stdin, (chunk) => typeof chunk === "string" ? encoder$2.encode(chunk) : chunk),
@@ -78461,7 +79661,7 @@ fn("makeInMemoryStdio")(function* () {
78461
79661
  const output = yield* unbounded$2();
78462
79662
  const decoder = new TextDecoder();
78463
79663
  return {
78464
- stdio: make$81({
79664
+ stdio: make$82({
78465
79665
  args: succeed$1([]),
78466
79666
  stdin: fromQueue(input),
78467
79667
  stdout: () => forEach$1((chunk) => offer$1(output, typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }))),
@@ -78749,7 +79949,7 @@ const probeCodexAppServerProvider = fn("probeCodexAppServerProvider")(function*
78749
79949
  env: environment,
78750
79950
  extendEnv: true
78751
79951
  });
78752
- const child = yield* spawner.spawn(make$80(spawnCommand.command, spawnCommand.args, {
79952
+ const child = yield* spawner.spawn(make$81(spawnCommand.command, spawnCommand.args, {
78753
79953
  cwd: input.cwd,
78754
79954
  env: environment,
78755
79955
  extendEnv: true,
@@ -79468,14 +80668,14 @@ const makeCodexSessionRuntime = (options) => gen(function* () {
79468
80668
  const runtimeScope = yield* Scope;
79469
80669
  const crypto = yield* Crypto;
79470
80670
  const events = yield* unbounded$2();
79471
- const pendingApprovalsRef = yield* make$64(/* @__PURE__ */ new Map());
79472
- const approvalCorrelationsRef = yield* make$64(/* @__PURE__ */ new Map());
79473
- const pendingUserInputsRef = yield* make$64(/* @__PURE__ */ new Map());
79474
- const collabReceiverTurnsRef = yield* make$64(/* @__PURE__ */ new Map());
79475
- const collabChildAgentsRef = yield* make$64(/* @__PURE__ */ new Map());
80671
+ const pendingApprovalsRef = yield* make$65(/* @__PURE__ */ new Map());
80672
+ const approvalCorrelationsRef = yield* make$65(/* @__PURE__ */ new Map());
80673
+ const pendingUserInputsRef = yield* make$65(/* @__PURE__ */ new Map());
80674
+ const collabReceiverTurnsRef = yield* make$65(/* @__PURE__ */ new Map());
80675
+ const collabChildAgentsRef = yield* make$65(/* @__PURE__ */ new Map());
79476
80676
  /** Child provider-thread id → its currently running provider turn id. */
79477
- const collabChildLiveTurnsRef = yield* make$64(/* @__PURE__ */ new Map());
79478
- const closedRef = yield* make$64(false);
80677
+ const collabChildLiveTurnsRef = yield* make$65(/* @__PURE__ */ new Map());
80678
+ const closedRef = yield* make$65(false);
79479
80679
  const resolvedHomePath = options.homePath ? expandHomePath(options.homePath) : void 0;
79480
80680
  const env = {
79481
80681
  ...options.environment,
@@ -79487,7 +80687,7 @@ const makeCodexSessionRuntime = (options) => gen(function* () {
79487
80687
  env,
79488
80688
  extendEnv
79489
80689
  });
79490
- const child = yield* spawner.spawn(make$80(spawnCommand.command, spawnCommand.args, {
80690
+ const child = yield* spawner.spawn(make$81(spawnCommand.command, spawnCommand.args, {
79491
80691
  cwd: options.cwd,
79492
80692
  env,
79493
80693
  extendEnv,
@@ -79510,7 +80710,7 @@ const makeCodexSessionRuntime = (options) => gen(function* () {
79510
80710
  cause
79511
80711
  })));
79512
80712
  const sessionCreatedAt = yield* nowIso;
79513
- const sessionRef = yield* make$64({
80713
+ const sessionRef = yield* make$65({
79514
80714
  provider: PROVIDER$1,
79515
80715
  ...options.providerInstanceId ? { providerInstanceId: options.providerInstanceId } : {},
79516
80716
  status: "connecting",
@@ -79838,7 +81038,7 @@ const makeCodexSessionRuntime = (options) => gen(function* () {
79838
81038
  const requestId = ApprovalRequestId.make(yield* randomUUIDv4("command-approval-request"));
79839
81039
  const turnId = TurnId.make(payload.turnId);
79840
81040
  const itemId = ProviderItemId.make(payload.itemId);
79841
- const decision = yield* make$74();
81041
+ const decision = yield* make$75();
79842
81042
  yield* update$2(pendingApprovalsRef, (current) => {
79843
81043
  const next = new Map(current);
79844
81044
  next.set(requestId, {
@@ -79881,7 +81081,7 @@ const makeCodexSessionRuntime = (options) => gen(function* () {
79881
81081
  const requestId = ApprovalRequestId.make(yield* randomUUIDv4("file-change-approval-request"));
79882
81082
  const turnId = TurnId.make(payload.turnId);
79883
81083
  const itemId = ProviderItemId.make(payload.itemId);
79884
- const decision = yield* make$74();
81084
+ const decision = yield* make$75();
79885
81085
  yield* update$2(pendingApprovalsRef, (current) => {
79886
81086
  const next = new Map(current);
79887
81087
  next.set(requestId, {
@@ -79924,7 +81124,7 @@ const makeCodexSessionRuntime = (options) => gen(function* () {
79924
81124
  const requestId = ApprovalRequestId.make(yield* randomUUIDv4("user-input-request"));
79925
81125
  const turnId = TurnId.make(payload.turnId);
79926
81126
  const itemId = ProviderItemId.make(payload.itemId);
79927
- const answers = yield* make$74();
81127
+ const answers = yield* make$75();
79928
81128
  yield* update$2(pendingUserInputsRef, (current) => {
79929
81129
  const next = new Map(current);
79930
81130
  next.set(requestId, {
@@ -79957,7 +81157,7 @@ const makeCodexSessionRuntime = (options) => gen(function* () {
79957
81157
  discard: true
79958
81158
  });
79959
81159
  yield* fromQueue(serverNotifications).pipe(runForEach(handleRawNotification), forkIn(runtimeScope));
79960
- const stderrRemainderRef = yield* make$64("");
81160
+ const stderrRemainderRef = yield* make$65("");
79961
81161
  yield* child.stderr.pipe(decodeText(), runForEach((chunk) => modify$2(stderrRemainderRef, (current) => {
79962
81162
  const lines = (current + chunk).split("\n");
79963
81163
  const remainder = lines.pop() ?? "";
@@ -81276,7 +82476,7 @@ const makeCodexAdapter = fn("makeCodexAdapter")(function* (codexConfig, options)
81276
82476
  const existing = sessions.get(input.threadId);
81277
82477
  if (existing && !existing.stopped) yield* suspend(() => stopSessionInternal(existing));
81278
82478
  const runtimeInput = toRuntimeInput(input);
81279
- const sessionScope = yield* make$77("sequential");
82479
+ const sessionScope = yield* make$78("sequential");
81280
82480
  let sessionScopeTransferred = false;
81281
82481
  yield* addFinalizer(() => sessionScopeTransferred ? void_$1 : close(sessionScope, void_$2));
81282
82482
  const runtime = yield* createRuntime(runtimeInput).pipe(provideService(Scope, sessionScope), provideService(ChildProcessSpawner, childProcessSpawner), provideService(Crypto, crypto), mapError((cause) => new ProviderAdapterProcessError({
@@ -81435,257 +82635,6 @@ const makeCodexAdapter = fn("makeCodexAdapter")(function* (codexConfig, options)
81435
82635
  };
81436
82636
  });
81437
82637
  //#endregion
81438
- //#region src/provider/Drivers/CodexHomeLayout.ts
81439
- const KNOWN_SHARED_DIRECTORIES = [
81440
- "sessions",
81441
- "archived_sessions",
81442
- "sqlite",
81443
- "shell_snapshots",
81444
- "worktrees",
81445
- "skills",
81446
- "plugins",
81447
- "cache",
81448
- "logs",
81449
- "mcp-oauth-locks"
81450
- ];
81451
- const PRIVATE_ENTRY_NAMES = /* @__PURE__ */ new Set(["auth.json", "models_cache.json"]);
81452
- const SHADOW_LOCAL_ENTRY_NAMES = /* @__PURE__ */ new Set([
81453
- "log",
81454
- "memories",
81455
- "tmp"
81456
- ]);
81457
- const REPLACEABLE_SHARED_RUNTIME_DIRECTORIES = /* @__PURE__ */ new Set(["mcp-oauth-locks"]);
81458
- function resolveHomePath(path, value) {
81459
- const expanded = value && value.trim().length > 0 ? expandHomePath(value) : path.join(NodeOS.homedir(), ".codex");
81460
- return path.resolve(expanded);
81461
- }
81462
- const resolveCodexHomeLayout = fn("resolveCodexHomeLayout")(function* (config) {
81463
- const path = yield* Path;
81464
- const sharedHomePath = resolveHomePath(path, config.homePath);
81465
- const shadowHomePath = config.shadowHomePath.trim();
81466
- if (shadowHomePath.length === 0) return {
81467
- mode: "direct",
81468
- sharedHomePath,
81469
- effectiveHomePath: config.homePath.trim().length > 0 ? sharedHomePath : void 0,
81470
- continuationKey: `codex:home:${sharedHomePath}`
81471
- };
81472
- return {
81473
- mode: "authOverlay",
81474
- sharedHomePath,
81475
- effectiveHomePath: path.resolve(expandHomePath(shadowHomePath)),
81476
- continuationKey: `codex:home:${sharedHomePath}`
81477
- };
81478
- });
81479
- const CodexShadowHomeContext = {
81480
- sharedHomePath: String$1,
81481
- effectiveHomePath: String$1
81482
- };
81483
- var CodexShadowHomeFileSystemError = class extends TaggedErrorClass()("CodexShadowHomeFileSystemError", {
81484
- ...CodexShadowHomeContext,
81485
- operation: Literals([
81486
- "readLink",
81487
- "makeDirectory",
81488
- "readDirectory",
81489
- "remove",
81490
- "symlink"
81491
- ]),
81492
- path: String$1,
81493
- targetPath: optional$3(String$1),
81494
- entryName: optional$3(String$1),
81495
- cause: Defect()
81496
- }) {
81497
- get message() {
81498
- const target = this.targetPath === void 0 ? "" : ` to '${this.targetPath}'`;
81499
- return `Codex shadow home filesystem operation '${this.operation}' failed for '${this.path}'${target}.`;
81500
- }
81501
- };
81502
- var CodexShadowHomePathConflictError = class extends TaggedErrorClass()("CodexShadowHomePathConflictError", CodexShadowHomeContext) {
81503
- get message() {
81504
- return `Codex shadow home path '${this.effectiveHomePath}' must be different from the shared home path '${this.sharedHomePath}'.`;
81505
- }
81506
- };
81507
- var CodexShadowHomeEntryConflictError = class extends TaggedErrorClass()("CodexShadowHomeEntryConflictError", {
81508
- ...CodexShadowHomeContext,
81509
- entryName: String$1,
81510
- linkPath: String$1,
81511
- targetPath: String$1
81512
- }) {
81513
- get message() {
81514
- return `Cannot create Codex shadow home entry '${this.entryName}' because '${this.linkPath}' already exists and is not a symlink.`;
81515
- }
81516
- };
81517
- var CodexShadowHomePrivateEntrySymlinkError = class extends TaggedErrorClass()("CodexShadowHomePrivateEntrySymlinkError", {
81518
- ...CodexShadowHomeContext,
81519
- entryName: String$1,
81520
- path: String$1
81521
- }) {
81522
- get message() {
81523
- return `Codex shadow home private entry '${this.entryName}' at '${this.path}' must be a real file, not a symlink.`;
81524
- }
81525
- };
81526
- Union([
81527
- CodexShadowHomeFileSystemError,
81528
- CodexShadowHomePathConflictError,
81529
- CodexShadowHomeEntryConflictError,
81530
- CodexShadowHomePrivateEntrySymlinkError
81531
- ]);
81532
- function isNotSymlinkError(error) {
81533
- const cause = error.reason.cause;
81534
- return error.reason._tag === "Unknown" && typeof cause === "object" && cause !== null && "code" in cause && cause.code === "EINVAL";
81535
- }
81536
- const readLinkState = fn("CodexHomeLayout.readLinkState")(function* (input) {
81537
- return yield* input.fileSystem.readLink(input.linkPath).pipe(map$4((target) => ({
81538
- _tag: "Symlink",
81539
- target
81540
- })), catchTags({ PlatformError: (cause) => {
81541
- if (cause.reason._tag === "NotFound") return succeed$1({ _tag: "Missing" });
81542
- if (isNotSymlinkError(cause)) return succeed$1({ _tag: "NotSymlink" });
81543
- return new CodexShadowHomeFileSystemError({
81544
- sharedHomePath: input.sharedHomePath,
81545
- effectiveHomePath: input.effectiveHomePath,
81546
- operation: "readLink",
81547
- path: input.linkPath,
81548
- entryName: input.entryName,
81549
- cause
81550
- });
81551
- } }));
81552
- });
81553
- const removePrivateSymlink = fn("CodexHomeLayout.removePrivateSymlink")(function* (input) {
81554
- const privatePath = (yield* Path).join(input.effectiveHomePath, input.entryName);
81555
- if ((yield* readLinkState({
81556
- ...input,
81557
- linkPath: privatePath
81558
- }))._tag === "Symlink") yield* input.fileSystem.remove(privatePath).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
81559
- sharedHomePath: input.sharedHomePath,
81560
- effectiveHomePath: input.effectiveHomePath,
81561
- operation: "remove",
81562
- path: privatePath,
81563
- entryName: input.entryName,
81564
- cause
81565
- }) }));
81566
- });
81567
- const ensureSymlink = fn("CodexHomeLayout.ensureSymlink")(function* (input) {
81568
- const path = yield* Path;
81569
- const target = path.join(input.sharedHomePath, input.entryName);
81570
- const link = path.join(input.effectiveHomePath, input.entryName);
81571
- const state = yield* readLinkState({
81572
- ...input,
81573
- linkPath: link
81574
- });
81575
- const createLink = input.fileSystem.symlink(target, link).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
81576
- sharedHomePath: input.sharedHomePath,
81577
- effectiveHomePath: input.effectiveHomePath,
81578
- operation: "symlink",
81579
- path: link,
81580
- targetPath: target,
81581
- entryName: input.entryName,
81582
- cause
81583
- }) }));
81584
- if (state._tag === "NotSymlink") {
81585
- if (!REPLACEABLE_SHARED_RUNTIME_DIRECTORIES.has(input.entryName)) return yield* new CodexShadowHomeEntryConflictError({
81586
- sharedHomePath: input.sharedHomePath,
81587
- effectiveHomePath: input.effectiveHomePath,
81588
- entryName: input.entryName,
81589
- linkPath: link,
81590
- targetPath: target
81591
- });
81592
- yield* input.fileSystem.remove(link, { recursive: true }).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
81593
- sharedHomePath: input.sharedHomePath,
81594
- effectiveHomePath: input.effectiveHomePath,
81595
- operation: "remove",
81596
- path: link,
81597
- entryName: input.entryName,
81598
- cause
81599
- }) }));
81600
- return yield* createLink;
81601
- }
81602
- if (state._tag === "Missing") return yield* createLink;
81603
- if (path.resolve(path.dirname(link), state.target) !== target) {
81604
- yield* input.fileSystem.remove(link).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
81605
- sharedHomePath: input.sharedHomePath,
81606
- effectiveHomePath: input.effectiveHomePath,
81607
- operation: "remove",
81608
- path: link,
81609
- entryName: input.entryName,
81610
- cause
81611
- }) }));
81612
- yield* createLink;
81613
- }
81614
- });
81615
- const ensureShadowAuthIsPrivate = fn("CodexHomeLayout.ensureShadowAuthIsPrivate")(function* (input) {
81616
- const path = yield* Path;
81617
- const entryName = "auth.json";
81618
- const authPath = path.join(input.effectiveHomePath, entryName);
81619
- if ((yield* readLinkState({
81620
- ...input,
81621
- entryName,
81622
- linkPath: authPath
81623
- }))._tag === "Symlink") return yield* new CodexShadowHomePrivateEntrySymlinkError({
81624
- sharedHomePath: input.sharedHomePath,
81625
- effectiveHomePath: input.effectiveHomePath,
81626
- entryName,
81627
- path: authPath
81628
- });
81629
- });
81630
- const materializeCodexShadowHome = fn("materializeCodexShadowHome")(function* (layout) {
81631
- if (layout.mode !== "authOverlay") return;
81632
- const effectiveHomePath = layout.effectiveHomePath;
81633
- if (!effectiveHomePath) return;
81634
- if (layout.sharedHomePath === effectiveHomePath) return yield* new CodexShadowHomePathConflictError({
81635
- sharedHomePath: layout.sharedHomePath,
81636
- effectiveHomePath
81637
- });
81638
- const fileSystem = yield* FileSystem;
81639
- const path = yield* Path;
81640
- const makeDirectory = (directoryPath) => fileSystem.makeDirectory(directoryPath, { recursive: true }).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
81641
- sharedHomePath: layout.sharedHomePath,
81642
- effectiveHomePath,
81643
- operation: "makeDirectory",
81644
- path: directoryPath,
81645
- cause
81646
- }) }));
81647
- yield* all([
81648
- makeDirectory(layout.sharedHomePath),
81649
- makeDirectory(effectiveHomePath),
81650
- ...KNOWN_SHARED_DIRECTORIES.map((directory) => makeDirectory(path.join(layout.sharedHomePath, directory)))
81651
- ], { concurrency: "unbounded" });
81652
- const sharedEntryNames = yield* fileSystem.readDirectory(layout.sharedHomePath).pipe(catchTags({ PlatformError: (cause) => new CodexShadowHomeFileSystemError({
81653
- sharedHomePath: layout.sharedHomePath,
81654
- effectiveHomePath,
81655
- operation: "readDirectory",
81656
- path: layout.sharedHomePath,
81657
- cause
81658
- }) }));
81659
- const entries = new Set(KNOWN_SHARED_DIRECTORIES);
81660
- for (const entryName of sharedEntryNames) if (!PRIVATE_ENTRY_NAMES.has(entryName) && !SHADOW_LOCAL_ENTRY_NAMES.has(entryName)) entries.add(entryName);
81661
- yield* forEach(PRIVATE_ENTRY_NAMES, (entryName) => entryName === "auth.json" ? void_$1 : removePrivateSymlink({
81662
- fileSystem,
81663
- sharedHomePath: layout.sharedHomePath,
81664
- effectiveHomePath,
81665
- entryName
81666
- }), { discard: true });
81667
- yield* forEach(entries, (entryName) => {
81668
- if (PRIVATE_ENTRY_NAMES.has(entryName)) return void_$1;
81669
- return ensureSymlink({
81670
- fileSystem,
81671
- sharedHomePath: layout.sharedHomePath,
81672
- effectiveHomePath,
81673
- entryName
81674
- });
81675
- }, { discard: true });
81676
- yield* ensureShadowAuthIsPrivate({
81677
- fileSystem,
81678
- sharedHomePath: layout.sharedHomePath,
81679
- effectiveHomePath
81680
- });
81681
- });
81682
- function codexContinuationIdentity(layout) {
81683
- return {
81684
- driverKind: ProviderDriverKind.make("codex"),
81685
- continuationKey: layout.continuationKey
81686
- };
81687
- }
81688
- //#endregion
81689
82638
  //#region src/provider/Drivers/CodexDriver.ts
81690
82639
  /**
81691
82640
  * CodexDriver — first concrete `ProviderDriver` in the new per-instance model.
@@ -85121,9 +86070,9 @@ const makeAcpPatchedProtocol = fn("makeAcpPatchedProtocol")(function* (options)
85121
86070
  const notificationQueue = yield* unbounded$2();
85122
86071
  const disconnects = yield* unbounded$2();
85123
86072
  const outgoing = yield* unbounded$2();
85124
- const nextRequestId = yield* make$64(1);
85125
- const terminationHandled = yield* make$64(false);
85126
- const extPending = yield* make$64(/* @__PURE__ */ new Map());
86073
+ const nextRequestId = yield* make$65(1);
86074
+ const terminationHandled = yield* make$65(false);
86075
+ const extPending = yield* make$65(/* @__PURE__ */ new Map());
85127
86076
  const logProtocol = (event) => {
85128
86077
  if (event.direction === "incoming" && !options.logIncoming) return void_$1;
85129
86078
  if (event.direction === "outgoing" && !options.logOutgoing) return void_$1;
@@ -85350,7 +86299,7 @@ const makeAcpPatchedProtocol = fn("makeAcpPatchedProtocol")(function* (options)
85350
86299
  },
85351
86300
  request: fn("sendRequest")(function* (method, payload) {
85352
86301
  const requestId = yield* modify$2(nextRequestId, (current) => [current, current + 1]);
85353
- const deferred = yield* make$74();
86302
+ const deferred = yield* make$75();
85354
86303
  yield* update$2(extPending, (pending) => new Map(pending).set(String(requestId), {
85355
86304
  deferred,
85356
86305
  method
@@ -85386,113 +86335,113 @@ const PromptResponseCompat = Union([PromptResponse, NonCanonicalPromptStopReason
85386
86335
  },
85387
86336
  encode: (response) => response
85388
86337
  })));
85389
- const InitializeRpc = make$52(AGENT_METHODS.initialize, {
86338
+ const InitializeRpc = make$53(AGENT_METHODS.initialize, {
85390
86339
  payload: InitializeRequest,
85391
86340
  success: InitializeResponse,
85392
86341
  error: Error$1
85393
86342
  });
85394
- const AuthenticateRpc = make$52(AGENT_METHODS.authenticate, {
86343
+ const AuthenticateRpc = make$53(AGENT_METHODS.authenticate, {
85395
86344
  payload: AuthenticateRequest,
85396
86345
  success: AuthenticateResponse,
85397
86346
  error: Error$1
85398
86347
  });
85399
- const LogoutRpc = make$52(AGENT_METHODS.logout, {
86348
+ const LogoutRpc = make$53(AGENT_METHODS.logout, {
85400
86349
  payload: LogoutRequest,
85401
86350
  success: LogoutResponse,
85402
86351
  error: Error$1
85403
86352
  });
85404
- const NewSessionRpc = make$52(AGENT_METHODS.session_new, {
86353
+ const NewSessionRpc = make$53(AGENT_METHODS.session_new, {
85405
86354
  payload: NewSessionRequest,
85406
86355
  success: NewSessionResponse,
85407
86356
  error: Error$1
85408
86357
  });
85409
- const LoadSessionRpc = make$52(AGENT_METHODS.session_load, {
86358
+ const LoadSessionRpc = make$53(AGENT_METHODS.session_load, {
85410
86359
  payload: LoadSessionRequest,
85411
86360
  success: LoadSessionResponse,
85412
86361
  error: Error$1
85413
86362
  });
85414
- const ListSessionsRpc = make$52(AGENT_METHODS.session_list, {
86363
+ const ListSessionsRpc = make$53(AGENT_METHODS.session_list, {
85415
86364
  payload: ListSessionsRequest,
85416
86365
  success: ListSessionsResponse,
85417
86366
  error: Error$1
85418
86367
  });
85419
- const ForkSessionRpc = make$52(AGENT_METHODS.session_fork, {
86368
+ const ForkSessionRpc = make$53(AGENT_METHODS.session_fork, {
85420
86369
  payload: ForkSessionRequest,
85421
86370
  success: ForkSessionResponse,
85422
86371
  error: Error$1
85423
86372
  });
85424
- const ResumeSessionRpc = make$52(AGENT_METHODS.session_resume, {
86373
+ const ResumeSessionRpc = make$53(AGENT_METHODS.session_resume, {
85425
86374
  payload: ResumeSessionRequest,
85426
86375
  success: ResumeSessionResponse,
85427
86376
  error: Error$1
85428
86377
  });
85429
- const CloseSessionRpc = make$52(AGENT_METHODS.session_close, {
86378
+ const CloseSessionRpc = make$53(AGENT_METHODS.session_close, {
85430
86379
  payload: CloseSessionRequest,
85431
86380
  success: CloseSessionResponse,
85432
86381
  error: Error$1
85433
86382
  });
85434
- const PromptRpc = make$52(AGENT_METHODS.session_prompt, {
86383
+ const PromptRpc = make$53(AGENT_METHODS.session_prompt, {
85435
86384
  payload: PromptRequest,
85436
86385
  success: PromptResponseCompat,
85437
86386
  error: Error$1
85438
86387
  });
85439
- const SetSessionModelRpc = make$52(AGENT_METHODS.session_set_model, {
86388
+ const SetSessionModelRpc = make$53(AGENT_METHODS.session_set_model, {
85440
86389
  payload: SetSessionModelRequest,
85441
86390
  success: SetSessionModelResponse,
85442
86391
  error: Error$1
85443
86392
  });
85444
- const SetSessionConfigOptionRpc = make$52(AGENT_METHODS.session_set_config_option, {
86393
+ const SetSessionConfigOptionRpc = make$53(AGENT_METHODS.session_set_config_option, {
85445
86394
  payload: SetSessionConfigOptionRequest,
85446
86395
  success: SetSessionConfigOptionResponse,
85447
86396
  error: Error$1
85448
86397
  });
85449
- const ReadTextFileRpc = make$52(CLIENT_METHODS.fs_read_text_file, {
86398
+ const ReadTextFileRpc = make$53(CLIENT_METHODS.fs_read_text_file, {
85450
86399
  payload: ReadTextFileRequest,
85451
86400
  success: ReadTextFileResponse,
85452
86401
  error: Error$1
85453
86402
  });
85454
- const WriteTextFileRpc = make$52(CLIENT_METHODS.fs_write_text_file, {
86403
+ const WriteTextFileRpc = make$53(CLIENT_METHODS.fs_write_text_file, {
85455
86404
  payload: WriteTextFileRequest,
85456
86405
  success: WriteTextFileResponse,
85457
86406
  error: Error$1
85458
86407
  });
85459
- const RequestPermissionRpc = make$52(CLIENT_METHODS.session_request_permission, {
86408
+ const RequestPermissionRpc = make$53(CLIENT_METHODS.session_request_permission, {
85460
86409
  payload: RequestPermissionRequest,
85461
86410
  success: RequestPermissionResponse,
85462
86411
  error: Error$1
85463
86412
  });
85464
- const ElicitationRpc = make$52(CLIENT_METHODS.session_elicitation, {
86413
+ const ElicitationRpc = make$53(CLIENT_METHODS.session_elicitation, {
85465
86414
  payload: ElicitationRequest,
85466
86415
  success: ElicitationResponse,
85467
86416
  error: Error$1
85468
86417
  });
85469
- const CreateTerminalRpc = make$52(CLIENT_METHODS.terminal_create, {
86418
+ const CreateTerminalRpc = make$53(CLIENT_METHODS.terminal_create, {
85470
86419
  payload: CreateTerminalRequest,
85471
86420
  success: CreateTerminalResponse,
85472
86421
  error: Error$1
85473
86422
  });
85474
- const TerminalOutputRpc = make$52(CLIENT_METHODS.terminal_output, {
86423
+ const TerminalOutputRpc = make$53(CLIENT_METHODS.terminal_output, {
85475
86424
  payload: TerminalOutputRequest,
85476
86425
  success: TerminalOutputResponse,
85477
86426
  error: Error$1
85478
86427
  });
85479
- const ReleaseTerminalRpc = make$52(CLIENT_METHODS.terminal_release, {
86428
+ const ReleaseTerminalRpc = make$53(CLIENT_METHODS.terminal_release, {
85480
86429
  payload: ReleaseTerminalRequest,
85481
86430
  success: ReleaseTerminalResponse,
85482
86431
  error: Error$1
85483
86432
  });
85484
- const WaitForTerminalExitRpc = make$52(CLIENT_METHODS.terminal_wait_for_exit, {
86433
+ const WaitForTerminalExitRpc = make$53(CLIENT_METHODS.terminal_wait_for_exit, {
85485
86434
  payload: WaitForTerminalExitRequest,
85486
86435
  success: WaitForTerminalExitResponse,
85487
86436
  error: Error$1
85488
86437
  });
85489
- const KillTerminalRpc = make$52(CLIENT_METHODS.terminal_kill, {
86438
+ const KillTerminalRpc = make$53(CLIENT_METHODS.terminal_kill, {
85490
86439
  payload: KillTerminalRequest,
85491
86440
  success: KillTerminalResponse,
85492
86441
  error: Error$1
85493
86442
  });
85494
- const AgentRpcs = make$51(InitializeRpc, AuthenticateRpc, LogoutRpc, NewSessionRpc, LoadSessionRpc, ListSessionsRpc, ForkSessionRpc, ResumeSessionRpc, CloseSessionRpc, PromptRpc, SetSessionModelRpc, SetSessionConfigOptionRpc);
85495
- const ClientRpcs = make$51(ReadTextFileRpc, WriteTextFileRpc, RequestPermissionRpc, ElicitationRpc, CreateTerminalRpc, TerminalOutputRpc, ReleaseTerminalRpc, WaitForTerminalExitRpc, KillTerminalRpc);
86443
+ const AgentRpcs = make$52(InitializeRpc, AuthenticateRpc, LogoutRpc, NewSessionRpc, LoadSessionRpc, ListSessionsRpc, ForkSessionRpc, ResumeSessionRpc, CloseSessionRpc, PromptRpc, SetSessionModelRpc, SetSessionConfigOptionRpc);
86444
+ const ClientRpcs = make$52(ReadTextFileRpc, WriteTextFileRpc, RequestPermissionRpc, ElicitationRpc, CreateTerminalRpc, TerminalOutputRpc, ReleaseTerminalRpc, WaitForTerminalExitRpc, KillTerminalRpc);
85496
86445
  //#endregion
85497
86446
  //#region ../effect-acp/src/_internal/shared.ts
85498
86447
  const isError = is(Error$1);
@@ -85517,7 +86466,7 @@ ArraySchema(Unknown);
85517
86466
  //#endregion
85518
86467
  //#region ../effect-acp/src/_internal/stdio.ts
85519
86468
  const encoder = new TextEncoder();
85520
- const makeChildStdio = (handle) => make$81({
86469
+ const makeChildStdio = (handle) => make$82({
85521
86470
  args: succeed$1([]),
85522
86471
  stdin: handle.stdout,
85523
86472
  stdout: () => mapInput(handle.stdin, (chunk) => typeof chunk === "string" ? encoder.encode(chunk) : chunk),
@@ -85528,7 +86477,7 @@ fn("makeInMemoryStdio")(function* () {
85528
86477
  const output = yield* unbounded$2();
85529
86478
  const decoder = new TextDecoder();
85530
86479
  return {
85531
- stdio: make$81({
86480
+ stdio: make$82({
85532
86481
  args: succeed$1([]),
85533
86482
  stdin: fromQueue(input),
85534
86483
  stdout: () => forEach$1((chunk) => offer$1(output, typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }))),
@@ -85620,9 +86569,9 @@ const make$5 = fn("effect-acp/AcpClient.make")(function* (stdio, options = {}, t
85620
86569
  [CLIENT_METHODS.terminal_kill]: (payload) => runHandler(coreHandlers.terminalKill, payload, CLIENT_METHODS.terminal_kill).pipe(map$4((result) => result ?? {})),
85621
86570
  [CLIENT_METHODS.terminal_release]: (payload) => runHandler(coreHandlers.terminalRelease, payload, CLIENT_METHODS.terminal_release).pipe(map$4((result) => result ?? {}))
85622
86571
  }));
85623
- yield* make$17(ClientRpcs).pipe(provideService(Protocol, transport.serverProtocol), provide$1(clientHandlerLayer), forkScoped);
86572
+ yield* make$18(ClientRpcs).pipe(provideService(Protocol, transport.serverProtocol), provide$1(clientHandlerLayer), forkScoped);
85624
86573
  let nextRpcRequestId = 2 ** 32;
85625
- const rpc = yield* make$18(AgentRpcs, { generateRequestId: () => RequestId$2(nextRpcRequestId++) }).pipe(provideService(Protocol$1, transport.clientProtocol));
86574
+ const rpc = yield* make$19(AgentRpcs, { generateRequestId: () => RequestId$2(nextRpcRequestId++) }).pipe(provideService(Protocol$1, transport.clientProtocol));
85626
86575
  return AcpClient.of({
85627
86576
  raw: {
85628
86577
  notifications: transport.incoming,
@@ -85777,7 +86726,7 @@ const registerLocalToolHandlers = (input) => gen(function* () {
85777
86726
  env,
85778
86727
  extendEnv: true
85779
86728
  } : {});
85780
- const handle = yield* spawner.spawn(make$80(spawnCommand.command, spawnCommand.args, {
86729
+ const handle = yield* spawner.spawn(make$81(spawnCommand.command, spawnCommand.args, {
85781
86730
  cwd: request.cwd ?? input.cwd,
85782
86731
  ...hasEnv ? {
85783
86732
  env,
@@ -85785,7 +86734,7 @@ const registerLocalToolHandlers = (input) => gen(function* () {
85785
86734
  } : {},
85786
86735
  shell: spawnCommand.shell
85787
86736
  })).pipe(provideService(Scope, scope), mapError(() => internalError(`Failed to spawn ACP terminal command: ${request.command}`)));
85788
- const exited = yield* make$74();
86737
+ const exited = yield* make$75();
85789
86738
  const state = {
85790
86739
  handle,
85791
86740
  exited,
@@ -86331,18 +87280,18 @@ const make$4 = (options) => gen(function* () {
86331
87280
  const spawner = yield* ChildProcessSpawner;
86332
87281
  const runtimeScope = yield* Scope;
86333
87282
  const eventQueue = yield* unbounded$2();
86334
- const modeStateRef = yield* make$64(void 0);
86335
- const toolCallsRef = yield* make$64(/* @__PURE__ */ new Map());
87283
+ const modeStateRef = yield* make$65(void 0);
87284
+ const toolCallsRef = yield* make$65(/* @__PURE__ */ new Map());
86336
87285
  const assistantItemRuntimeId = yield* crypto.randomUUIDv4.pipe(mapError((cause) => new AcpTransportError({
86337
87286
  detail: "Failed to generate an ACP assistant item runtime identifier.",
86338
87287
  cause
86339
87288
  })));
86340
- const assistantSegmentRef = yield* make$64({ nextSegmentIndex: 0 });
86341
- const configOptionsRef = yield* make$64(sessionConfigOptionsFromSetup(void 0));
86342
- const startStateRef = yield* make$64({ _tag: "NotStarted" });
86343
- const promptSerializationSemaphore = yield* make$76(1);
86344
- const activePromptFiberRef = yield* make$64(none());
86345
- const sessionLoadGateRef = yield* make$64(none());
87289
+ const assistantSegmentRef = yield* make$65({ nextSegmentIndex: 0 });
87290
+ const configOptionsRef = yield* make$65(sessionConfigOptionsFromSetup(void 0));
87291
+ const startStateRef = yield* make$65({ _tag: "NotStarted" });
87292
+ const promptSerializationSemaphore = yield* make$77(1);
87293
+ const activePromptFiberRef = yield* make$65(none());
87294
+ const sessionLoadGateRef = yield* make$65(none());
86346
87295
  const logRequest = (event) => options.requestLogger ? options.requestLogger(event) : void_$1;
86347
87296
  const runLoggedRequest = (method, payload, effect) => logRequest({
86348
87297
  method,
@@ -86363,7 +87312,7 @@ const make$4 = (options) => gen(function* () {
86363
87312
  env: options.spawn.env,
86364
87313
  extendEnv: true
86365
87314
  } : {});
86366
- const child = yield* spawner.spawn(make$80(spawnCommand.command, spawnCommand.args, {
87315
+ const child = yield* spawner.spawn(make$81(spawnCommand.command, spawnCommand.args, {
86367
87316
  ...options.spawn.cwd ? { cwd: options.spawn.cwd } : {},
86368
87317
  ...options.spawn.env ? {
86369
87318
  env: options.spawn.env,
@@ -86588,7 +87537,7 @@ const make$4 = (options) => gen(function* () {
86588
87537
  };
86589
87538
  });
86590
87539
  const start = gen(function* () {
86591
- const deferred = yield* make$74();
87540
+ const deferred = yield* make$75();
86592
87541
  return yield* yield* modify$2(startStateRef, (state) => {
86593
87542
  switch (state._tag) {
86594
87543
  case "Started": return [succeed$1(state.result), state];
@@ -86622,7 +87571,7 @@ const make$4 = (options) => gen(function* () {
86622
87571
  start: () => start,
86623
87572
  getEvents: () => fromQueue(eventQueue),
86624
87573
  drainEvents: gen(function* () {
86625
- const acknowledge = yield* make$74();
87574
+ const acknowledge = yield* make$75();
86626
87575
  yield* offer$1(eventQueue, {
86627
87576
  _tag: "EventStreamBarrier",
86628
87577
  acknowledge
@@ -86861,7 +87810,7 @@ const makeAcpAgentTextGeneration = (descriptor, settings, environment = process.
86861
87810
  const path = yield* Path;
86862
87811
  const runAcpAgentJson = ({ operation, cwd, prompt, outputSchemaJson, modelSelection }) => gen(function* () {
86863
87812
  const resolvedModel = resolveAcpAgentModelId(descriptor, modelSelection.model);
86864
- const outputRef = yield* make$64("");
87813
+ const outputRef = yield* make$65("");
86865
87814
  const runtime = yield* makeAcpAgentRuntime(descriptor, {
86866
87815
  settings,
86867
87816
  environment,
@@ -87444,7 +88393,7 @@ function makeAcpAgentAdapter(descriptor, settings, options) {
87444
88393
  const managedNativeEventLogger = options?.nativeEventLogger === void 0 ? nativeEventLogger : void 0;
87445
88394
  const makeAcpNativeLoggers = yield* makeAcpNativeLoggerFactory();
87446
88395
  const sessions = /* @__PURE__ */ new Map();
87447
- const threadLocksRef = yield* make$54(/* @__PURE__ */ new Map());
88396
+ const threadLocksRef = yield* make$55(/* @__PURE__ */ new Map());
87448
88397
  const runtimeEventPubSub = yield* unbounded$1();
87449
88398
  const nowIso = map$4(now$1, formatIso);
87450
88399
  const randomUUIDv4 = crypto.randomUUIDv4.pipe(mapError((cause) => new ProviderAdapterRequestError({
@@ -87465,7 +88414,7 @@ function makeAcpAgentAdapter(descriptor, settings, options) {
87465
88414
  const offerRuntimeEvent = (event) => publish(runtimeEventPubSub, event).pipe(asVoid);
87466
88415
  const getThreadSemaphore = (threadId) => modifyEffect(threadLocksRef, (current) => {
87467
88416
  return match$1(fromNullishOr(current.get(threadId)), {
87468
- onNone: () => make$76(1).pipe(map$4((semaphore) => {
88417
+ onNone: () => make$77(1).pipe(map$4((semaphore) => {
87469
88418
  const next = new Map(current);
87470
88419
  next.set(threadId, semaphore);
87471
88420
  return [semaphore, next];
@@ -87648,7 +88597,7 @@ function makeAcpAgentAdapter(descriptor, settings, options) {
87648
88597
  const existing = sessions.get(input.threadId);
87649
88598
  if (existing && !existing.stopped) yield* stopSessionInternal(existing);
87650
88599
  const pendingApprovals = /* @__PURE__ */ new Map();
87651
- const sessionScope = yield* make$77("sequential");
88600
+ const sessionScope = yield* make$78("sequential");
87652
88601
  let sessionScopeTransferred = false;
87653
88602
  yield* addFinalizer(() => sessionScopeTransferred ? void_$1 : close(sessionScope, void_$2));
87654
88603
  const resumeSessionId = resolveResumeSessionId(descriptor, input.resumeCursor);
@@ -87687,7 +88636,7 @@ function makeAcpAgentAdapter(descriptor, settings, options) {
87687
88636
  const permissionRequest = parsePermissionRequest(params);
87688
88637
  const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
87689
88638
  const runtimeRequestId = RuntimeRequestId.make(requestId);
87690
- const decision = yield* make$74();
88639
+ const decision = yield* make$75();
87691
88640
  const turnId = resolveSessionCallbackTurnId(sessions, input.threadId);
87692
88641
  pendingApprovals.set(requestId, { decision });
87693
88642
  yield* offerRuntimeEvent(makeAcpRequestOpenedEvent({
@@ -87944,10 +88893,10 @@ function makeAcpAgentAdapter(descriptor, settings, options) {
87944
88893
  });
87945
88894
  })));
87946
88895
  }));
87947
- const promptSettled = yield* make$64(false);
87948
- const promptRpcSucceeded = yield* make$64(false);
87949
- const promptResultRef = yield* make$64(void 0);
87950
- const promptFailureMessageRef = yield* make$64(void 0);
88896
+ const promptSettled = yield* make$65(false);
88897
+ const promptRpcSucceeded = yield* make$65(false);
88898
+ const promptResultRef = yield* make$65(void 0);
88899
+ const promptFailureMessageRef = yield* make$65(void 0);
87951
88900
  return yield* gen(function* () {
87952
88901
  const result = yield* prepared.acp.prompt({ prompt: prepared.promptParts }).pipe(tap((promptResult) => all([set$2(promptRpcSucceeded, true), set$2(promptResultRef, promptResult)])), tapError((error) => set$2(promptFailureMessageRef, mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error).message).pipe(andThen(prepared.acp.drainEvents))), mapError((error) => mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error)));
87953
88902
  return yield* withThreadLock(input.threadId, gen(function* () {
@@ -88267,7 +89216,7 @@ const discoverModelsViaAcp = (descriptor, settings, environment = process.env) =
88267
89216
  const runVersionCommand = (descriptor, settings, environment = process.env) => gen(function* () {
88268
89217
  const command = settings.binaryPath.trim() || descriptor.defaultBinary;
88269
89218
  const spawnCommand = yield* resolveSpawnCommand(command, ["--version"], { env: environment });
88270
- return yield* spawnAndCollect(command, make$80(spawnCommand.command, spawnCommand.args, {
89219
+ return yield* spawnAndCollect(command, make$81(spawnCommand.command, spawnCommand.args, {
88271
89220
  env: environment,
88272
89221
  shell: spawnCommand.shell
88273
89222
  }));
@@ -88791,7 +89740,7 @@ const buildEntry = (input) => gen(function* () {
88791
89740
  };
88792
89741
  }
88793
89742
  const typedConfig = decodeResult.success;
88794
- const childScope = yield* make$77();
89743
+ const childScope = yield* make$78();
88795
89744
  yield* addFinalizer$1(parentScope, close(childScope, void_$2).pipe(ignore$1));
88796
89745
  const createResult = yield* driver.create({
88797
89746
  instanceId,
@@ -88912,8 +89861,8 @@ const makeProviderInstanceRegistry = (input) => gen(function* () {
88912
89861
  const driversById = new Map(input.drivers.map((driver) => [driver.driverKind, driver]));
88913
89862
  const parentScope = yield* Scope;
88914
89863
  const driverContext = yield* context();
88915
- const entries = yield* make$64(/* @__PURE__ */ new Map());
88916
- const unavailable = yield* make$64(/* @__PURE__ */ new Map());
89864
+ const entries = yield* make$65(/* @__PURE__ */ new Map());
89865
+ const unavailable = yield* make$65(/* @__PURE__ */ new Map());
88917
89866
  const changes = yield* unbounded$1();
88918
89867
  yield* addFinalizer(() => shutdown$2(changes));
88919
89868
  const reconcileWithR = makeReconcile({
@@ -88948,7 +89897,7 @@ const makeProviderInstanceRegistry = (input) => gen(function* () {
88948
89897
  * changes. Tests that exercise the mutator directly can pair this Layer
88949
89898
  * with a test-local `ServerSettingsService`.
88950
89899
  */
88951
- const ProviderInstanceRegistryMutableLayer = (input) => effectContext(makeProviderInstanceRegistry(input).pipe(map$4(({ registry, mutator }) => make$69(ProviderInstanceRegistry, registry).pipe(add$2(ProviderInstanceRegistryMutator, mutator)))));
89900
+ const ProviderInstanceRegistryMutableLayer = (input) => effectContext(makeProviderInstanceRegistry(input).pipe(map$4(({ registry, mutator }) => make$70(ProviderInstanceRegistry, registry).pipe(add$2(ProviderInstanceRegistryMutator, mutator)))));
88952
89901
  //#endregion
88953
89902
  //#region src/provider/Layers/ProviderInstanceRegistryHydration.ts
88954
89903
  /**
@@ -89618,33 +90567,33 @@ const ProviderRuntimeIngestionLive = effect(ProviderRuntimeIngestionService, gen
89618
90567
  const projectionTurnRepository = yield* ProjectionTurnRepository;
89619
90568
  const serverSettingsService = yield* ServerSettingsService;
89620
90569
  const providerCommandId = (event, tag) => String(event.eventId).startsWith("codex-snapshot:") ? succeed$1(CommandId.make(`provider:${event.eventId}:${tag}`)) : crypto.randomUUIDv4.pipe(map$4((uuid) => CommandId.make(`provider:${event.eventId}:${tag}:${uuid}`)));
89621
- const threadLocksRef = yield* make$54(/* @__PURE__ */ new Map());
90570
+ const threadLocksRef = yield* make$55(/* @__PURE__ */ new Map());
89622
90571
  const getThreadSemaphore = (threadId) => modifyEffect(threadLocksRef, (current) => {
89623
90572
  const existing = current.get(threadId);
89624
90573
  if (existing) return succeed$1([existing, current]);
89625
- return make$76(1).pipe(map$4((semaphore) => {
90574
+ return make$77(1).pipe(map$4((semaphore) => {
89626
90575
  const next = new Map(current);
89627
90576
  next.set(threadId, semaphore);
89628
90577
  return [semaphore, next];
89629
90578
  }));
89630
90579
  });
89631
90580
  const withThreadLock = (threadId, effect) => flatMap$1(getThreadSemaphore(threadId), (semaphore) => semaphore.withPermit(effect));
89632
- const turnMessageIdsByTurnKey = yield* make$82({
90581
+ const turnMessageIdsByTurnKey = yield* make$83({
89633
90582
  capacity: TURN_MESSAGE_IDS_BY_TURN_CACHE_CAPACITY,
89634
90583
  timeToLive: TURN_MESSAGE_IDS_BY_TURN_TTL,
89635
90584
  lookup: () => succeed$1(/* @__PURE__ */ new Set())
89636
90585
  });
89637
- const bufferedAssistantTextByMessageId = yield* make$82({
90586
+ const bufferedAssistantTextByMessageId = yield* make$83({
89638
90587
  capacity: BUFFERED_MESSAGE_TEXT_BY_MESSAGE_ID_CACHE_CAPACITY,
89639
90588
  timeToLive: BUFFERED_MESSAGE_TEXT_BY_MESSAGE_ID_TTL,
89640
90589
  lookup: () => succeed$1("")
89641
90590
  });
89642
- const assistantSegmentStateByTurnKey = yield* make$82({
90591
+ const assistantSegmentStateByTurnKey = yield* make$83({
89643
90592
  capacity: TURN_MESSAGE_IDS_BY_TURN_CACHE_CAPACITY,
89644
90593
  timeToLive: TURN_MESSAGE_IDS_BY_TURN_TTL,
89645
90594
  lookup: () => die(/* @__PURE__ */ new Error("assistant segment state should be read through getOption before initialization"))
89646
90595
  });
89647
- const bufferedProposedPlanById = yield* make$82({
90596
+ const bufferedProposedPlanById = yield* make$83({
89648
90597
  capacity: BUFFERED_PROPOSED_PLAN_BY_ID_CACHE_CAPACITY,
89649
90598
  timeToLive: BUFFERED_PROPOSED_PLAN_BY_ID_TTL,
89650
90599
  lookup: () => succeed$1({
@@ -89652,7 +90601,7 @@ const ProviderRuntimeIngestionLive = effect(ProviderRuntimeIngestionService, gen
89652
90601
  createdAt: ""
89653
90602
  })
89654
90603
  });
89655
- const taskDescriptionByTaskKey = yield* make$82({
90604
+ const taskDescriptionByTaskKey = yield* make$83({
89656
90605
  capacity: TASK_DESCRIPTION_BY_TASK_CACHE_CAPACITY,
89657
90606
  timeToLive: TASK_DESCRIPTION_BY_TASK_TTL,
89658
90607
  lookup: () => succeed$1("")
@@ -90406,7 +91355,7 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
90406
91355
  const serverSettingsService = yield* ServerSettingsService;
90407
91356
  const serverCommandId = (tag) => crypto.randomUUIDv4.pipe(map$4((uuid) => CommandId.make(`server:${tag}:${uuid}`)));
90408
91357
  const serverEventId = () => crypto.randomUUIDv4.pipe(map$4(EventId.make));
90409
- const handledTurnStartKeys = yield* make$82({
91358
+ const handledTurnStartKeys = yield* make$83({
90410
91359
  capacity: HANDLED_TURN_START_KEY_MAX,
90411
91360
  timeToLive: HANDLED_TURN_START_KEY_TTL,
90412
91361
  lookup: () => succeed$1(true)
@@ -91215,7 +92164,7 @@ const ProviderRegistryLive = effect(ProviderRegistry, gen(function* () {
91215
92164
  if (provider === void 0 || source === void 0) continue;
91216
92165
  fallbackByInstance.set(source.instanceId, provider);
91217
92166
  }
91218
- const providersRef = yield* make$64(yield* forEach(bootSources, (source) => gen(function* () {
92167
+ const providersRef = yield* make$65(yield* forEach(bootSources, (source) => gen(function* () {
91219
92168
  const filePath = yield* resolveProviderStatusCachePath({
91220
92169
  cacheDir: config.providerStatusCacheDir,
91221
92170
  instanceId: source.instanceId
@@ -91238,9 +92187,9 @@ const ProviderRegistryLive = effect(ProviderRegistry, gen(function* () {
91238
92187
  return succeed$1(hydrateCachedProvider(correlation));
91239
92188
  }));
91240
92189
  }), { concurrency: "unbounded" }).pipe(map$4((providers) => orderProviderSnapshots(providers.filter((provider) => provider !== void 0)))));
91241
- const maintenanceActionStatesRef = yield* make$64(/* @__PURE__ */ new Map());
91242
- const liveSubsRef = yield* make$64(/* @__PURE__ */ new Map());
91243
- const syncSemaphore = yield* make$76(1);
92190
+ const maintenanceActionStatesRef = yield* make$65(/* @__PURE__ */ new Map());
92191
+ const liveSubsRef = yield* make$65(/* @__PURE__ */ new Map());
92192
+ const syncSemaphore = yield* make$77(1);
91244
92193
  const getLiveSources = get$3(liveSubsRef).pipe(map$4((map) => Array.from(map.values(), buildSnapshotSource)));
91245
92194
  const persistProvider = (provider) => gen(function* () {
91246
92195
  const key = snapshotInstanceKey(provider);
@@ -91536,7 +92485,7 @@ const httpHeaderRedactionLayer = effect(CurrentRedactedNames, map$4(CurrentRedac
91536
92485
  //#region src/serverLogger.ts
91537
92486
  const ServerLoggerLive = gen(function* () {
91538
92487
  const minimumLogLevelLayer = succeed$3(MinimumLogLevel, (yield* ServerConfig).logLevel);
91539
- return mergeAll(layer$41([consolePretty(), tracerLogger], { mergeWithExisting: false }), minimumLogLevelLayer);
92488
+ return mergeAll(layer$43([consolePretty(), tracerLogger], { mergeWithExisting: false }), minimumLogLevelLayer);
91540
92489
  }).pipe(unwrap);
91541
92490
  //#endregion
91542
92491
  //#region src/observability/Layers/Observability.ts
@@ -91559,7 +92508,7 @@ const ObservabilityLive = unwrap(gen(function* () {
91559
92508
  durationMs: stats.durationMs
91560
92509
  })
91561
92510
  });
91562
- const delegate = config.otlpTracesUrl === void 0 ? void 0 : yield* make$22({
92511
+ const delegate = config.otlpTracesUrl === void 0 ? void 0 : yield* make$23({
91563
92512
  url: config.otlpTracesUrl,
91564
92513
  exportInterval: `${config.otlpExportIntervalMs} millis`,
91565
92514
  resource: {
@@ -91577,9 +92526,9 @@ const ObservabilityLive = unwrap(gen(function* () {
91577
92526
  batchWindowMs: config.traceBatchWindowMs,
91578
92527
  sink,
91579
92528
  ...delegate ? { delegate } : {}
91580
- })), layer$13(sink));
92529
+ })), layer$15(sink));
91581
92530
  })).pipe(provide(layerFlusher), provideMerge(otlpSerializationLayer));
91582
- const metricsLayer = config.otlpMetricsUrl === void 0 ? empty$8 : layer$16({
92531
+ const metricsLayer = config.otlpMetricsUrl === void 0 ? empty$8 : layer$18({
91583
92532
  url: config.otlpMetricsUrl,
91584
92533
  exportInterval: `${config.otlpExportIntervalMs} millis`,
91585
92534
  resource: {
@@ -91632,11 +92581,11 @@ const orchestrationHttpApiLayer = group(EnvironmentHttpApi, "orchestration", fnU
91632
92581
  //#endregion
91633
92582
  //#region src/server.ts
91634
92583
  const HTTP_PREEMPTIVE_SHUTDOWN_GRACE_MS = 0;
91635
- const ApplicationObservabilityLive = ObservabilityLive.pipe(provideMerge(layer$17));
91636
- const ServerSettingsLayerLive = layer$26.pipe(provide(layer$36));
91637
- const DesktopTelemetryReceiverLayerLive = layer$20.pipe(provideMerge(ServerSettingsLayerLive));
91638
- const HostPowerMonitorLayerLive = layer$19.pipe(provide(DesktopTelemetryReceiverLayerLive));
91639
- const BackgroundLayerLive = layer$18.pipe(provide(HostPowerMonitorLayerLive), provideMerge(ServerSettingsLayerLive));
92584
+ const ApplicationObservabilityLive = ObservabilityLive.pipe(provideMerge(layer$19));
92585
+ const ServerSettingsLayerLive = layer$28.pipe(provide(layer$38));
92586
+ const DesktopTelemetryReceiverLayerLive = layer$22.pipe(provideMerge(ServerSettingsLayerLive));
92587
+ const HostPowerMonitorLayerLive = layer$21.pipe(provide(DesktopTelemetryReceiverLayerLive));
92588
+ const BackgroundLayerLive = layer$20.pipe(provide(HostPowerMonitorLayerLive), provideMerge(ServerSettingsLayerLive));
91640
92589
  const HttpServerLive = unwrap(gen(function* () {
91641
92590
  const config = yield* ServerConfig;
91642
92591
  if (typeof Bun !== "undefined") return (yield* promise(() => import("@effect/platform-bun/BunHttpServer"))).layer({
@@ -91649,7 +92598,7 @@ const HttpServerLive = unwrap(gen(function* () {
91649
92598
  } }
91650
92599
  });
91651
92600
  else {
91652
- const [NodeHttpServer, NodeHttp] = yield* all([promise(() => import("./NodeHttpServer-D2VeYRw1.mjs")), promise(() => import("node:http"))]);
92601
+ const [NodeHttpServer, NodeHttp] = yield* all([promise(() => import("./NodeHttpServer-QSdRgYM7.mjs")), promise(() => import("node:http"))]);
91653
92602
  return NodeHttpServer.layer(NodeHttp.createServer, {
91654
92603
  host: config.host ?? "127.0.0.1",
91655
92604
  port: config.port,
@@ -91663,7 +92612,7 @@ const PlatformServicesLive = unwrap(gen(function* () {
91663
92612
  const { layer } = yield* promise(() => import("@effect/platform-bun/BunServices"));
91664
92613
  return layer;
91665
92614
  } else {
91666
- const { layer } = yield* promise(() => import("./NodeServices-BtcL7AtO.mjs").then((n) => n.t));
92615
+ const { layer } = yield* promise(() => import("./NodeServices-Brptf0fr.mjs").then((n) => n.t));
91667
92616
  return layer;
91668
92617
  }
91669
92618
  }));
@@ -91671,23 +92620,23 @@ const ReactorLayerLive = empty$8.pipe(provideMerge(OrchestrationReactorLive), pr
91671
92620
  const ProviderSessionDirectoryLayerLive = ProviderSessionDirectoryLive.pipe(provide(layer$4));
91672
92621
  const ProviderLayerLive = ProviderServiceLive.pipe(provideMerge(ProviderAdapterRegistryLive), provideMerge(ProviderSessionDirectoryLayerLive));
91673
92622
  const PersistenceLayerLive = empty$8.pipe(provideMerge(layerConfig));
91674
- const WorkspaceEntriesLayerLive = layer$10.pipe(provide(layer$22));
91675
- const WorkspaceLayerLive = mergeAll(layer$22, WorkspaceEntriesLayerLive, layer$9.pipe(provide(layer$22), provide(WorkspaceEntriesLayerLive)));
91676
- const TerminalLayerLive = layer$7.pipe(provide(layer));
91677
- const ProjectFaviconResolverLayerLive = layer$14.pipe(provide(layer$22), provide(layer$15));
91678
- const AuthLayerLive = layer$33.pipe(provideMerge(PersistenceLayerLive), provide(layer$36));
92623
+ const WorkspaceEntriesLayerLive = layer$12.pipe(provide(layer$24));
92624
+ const WorkspaceLayerLive = mergeAll(layer$24, WorkspaceEntriesLayerLive, layer$11.pipe(provide(layer$24), provide(WorkspaceEntriesLayerLive)));
92625
+ const TerminalLayerLive = layer$9.pipe(provide(layer));
92626
+ const ProjectFaviconResolverLayerLive = layer$16.pipe(provide(layer$24), provide(layer$17));
92627
+ const AuthLayerLive = layer$35.pipe(provideMerge(PersistenceLayerLive), provide(layer$38));
91679
92628
  const ProviderRuntimeLayerLive = ProviderSessionReaperLive.pipe(provideMerge(ProviderLayerLive), provideMerge(OrchestrationLayerLive));
91680
- const RuntimeDependenciesLive = ReactorLayerLive.pipe(provideMerge(ServerSettingsLayerLive), provideMerge(ProviderRuntimeLayerLive), provideMerge(PersistenceLayerLive), provideMerge(layer$29), provideMerge(layer$2), provideMerge(ProviderRegistryLive), provideMerge(ProviderInstanceRegistryHydrationLive), provideMerge(layer$3), provideMerge(WorkspaceLayerLive), provideMerge(layer$8), provideMerge(TerminalLayerLive), provideMerge(ProjectFaviconResolverLayerLive), provideMerge(layer$30), provideMerge(layer$24), provideMerge(AuthLayerLive), provideMerge(layer$36)).pipe(provideMerge(BackgroundLayerLive), provideMerge(layer$25), provideMerge(layer$28), provideMerge(layer$27), provide(layer$43));
92629
+ const RuntimeDependenciesLive = ReactorLayerLive.pipe(provideMerge(ServerSettingsLayerLive), provideMerge(ProviderRuntimeLayerLive), provideMerge(PersistenceLayerLive), provideMerge(layer$31), provideMerge(layer$2), provideMerge(ProviderRegistryLive), provideMerge(ProviderInstanceRegistryHydrationLive), provideMerge(layer$3), provideMerge(WorkspaceLayerLive), provideMerge(layer$10), provideMerge(TerminalLayerLive), provideMerge(ProjectFaviconResolverLayerLive), provideMerge(layer$32), provideMerge(layer$26), provideMerge(AuthLayerLive), provideMerge(layer$38), provideMerge(layer$7)).pipe(provideMerge(BackgroundLayerLive), provideMerge(layer$27), provideMerge(layer$30), provideMerge(layer$29), provide(layer$45));
91681
92630
  const commandReadinessLayer = middleware((httpEffect) => flatMap$1(ServerRuntimeStartup, (startup) => startup.awaitCommandReady.pipe(orDie, andThen(httpEffect))), { global: true });
91682
- const makeRoutesLayer = mergeAll(layer$21(EnvironmentHttpApi).pipe(provide(authHttpApiLayer), provide(connectHttpApiLayer), provide(orchestrationHttpApiLayer), provide(serverEnvironmentHttpApiLayer), provide(environmentAuthenticatedAuthLayer)), otlpTracesProxyRouteLayer, assetRouteLayer, staticAndDevRouteLayer, websocketRpcRouteLayer).pipe(provide(commandReadinessLayer), provide(browserApiCorsLayer), provide(httpCompressionLayer));
92631
+ const makeRoutesLayer = mergeAll(layer$23(EnvironmentHttpApi).pipe(provide(authHttpApiLayer), provide(connectHttpApiLayer), provide(orchestrationHttpApiLayer), provide(serverEnvironmentHttpApiLayer), provide(environmentAuthenticatedAuthLayer)), otlpTracesProxyRouteLayer, assetRouteLayer, staticAndDevRouteLayer, websocketRpcRouteLayer).pipe(provide(commandReadinessLayer), provide(browserApiCorsLayer), provide(httpCompressionLayer));
91683
92632
  const runServer = launch(unwrap(gen(function* () {
91684
92633
  const config = yield* ServerConfig;
91685
- const activation = yield* make$74();
92634
+ const activation = yield* make$75();
91686
92635
  const awaitActivation = _await(activation);
91687
92636
  const activationLayer = succeed$3(ServerActivation, awaitActivation);
91688
- const runtimeStateParked = yield* make$74();
91689
- const tailscaleParked = yield* make$74();
91690
- const routesReady = yield* make$74();
92637
+ const runtimeStateParked = yield* make$75();
92638
+ const tailscaleParked = yield* make$75();
92639
+ const routesReady = yield* make$75();
91691
92640
  yield* fixPath();
91692
92641
  const httpListeningLayer = effectDiscard(gen(function* () {
91693
92642
  yield* HttpServer;
@@ -91741,7 +92690,7 @@ const runServer = launch(unwrap(gen(function* () {
91741
92690
  ...config.tailscaleServeEnabled ? [_await(tailscaleParked)] : []
91742
92691
  ], { concurrency: "unbounded" }).pipe(asVoid)
91743
92692
  }).pipe(provideMerge(RuntimeDependenciesLive));
91744
- return mergeAll(serve(makeRoutesLayer, { disableLogger: !config.logWebSocketEvents }).pipe(tap$1(() => succeed$4(routesReady, void 0).pipe(orDie))), httpListeningLayer, runtimeStateLayer, tailscaleServeLayer, config.hubTunnel ? mergeAll(layer$6(config.hubTunnel), layer$5(config.hubTunnel)).pipe(provideMerge(runtimeServicesLive)) : empty$8).pipe(provideMerge(runtimeServicesLive), provide(activationLayer), provideMerge(HttpServerLive), provide(ApplicationObservabilityLive), provideMerge(layer$44), provideMerge(PlatformServicesLive));
92693
+ return mergeAll(serve(makeRoutesLayer, { disableLogger: !config.logWebSocketEvents }).pipe(tap$1(() => succeed$4(routesReady, void 0).pipe(orDie))), httpListeningLayer, runtimeStateLayer, tailscaleServeLayer, config.hubTunnel ? mergeAll(layer$6(config.hubTunnel), layer$5(config.hubTunnel)).pipe(provideMerge(runtimeServicesLive)) : empty$8).pipe(provideMerge(runtimeServicesLive), provide(activationLayer), provideMerge(HttpServerLive), provide(ApplicationObservabilityLive), provideMerge(layer$46), provideMerge(PlatformServicesLive));
91745
92694
  })));
91746
92695
  //#endregion
91747
92696
  //#region src/cli/server.ts
@@ -91753,15 +92702,15 @@ const runServerCommand = (flags, options) => gen(function* () {
91753
92702
  });
91754
92703
  return yield* runServer.pipe(provideService(ServerConfig, config), ensuring(sync(releaseDaemonLock)));
91755
92704
  });
91756
- const startCommand = make$63("start", { ...sharedServerCommandFlags }).pipe(withDescription("Run the T3 Code server."), withHandler((flags) => runServerCommand(flags)));
91757
- const serveCommand = make$63("serve", { ...sharedServerCommandFlags }).pipe(withDescription("Run the T3 Code server without opening a browser."), withHandler((flags) => runServerCommand(flags, {
92705
+ const startCommand = make$64("start", { ...sharedServerCommandFlags }).pipe(withDescription("Run the T3 Code server."), withHandler((flags) => runServerCommand(flags)));
92706
+ const serveCommand = make$64("serve", { ...sharedServerCommandFlags }).pipe(withDescription("Run the T3 Code server without opening a browser."), withHandler((flags) => runServerCommand(flags, {
91758
92707
  startupPresentation: "headless",
91759
92708
  forceAutoBootstrapProjectFromCwd: false
91760
92709
  })));
91761
92710
  //#endregion
91762
92711
  //#region src/bin.ts
91763
- const CliRuntimeLayer = mergeAll(layer$45, layer$43);
91764
- const makeCli = () => make$63("t3", { ...sharedServerCommandFlags }).pipe(withDescription("Run the T3 Code server."), withHandler((flags) => runServerCommand(flags)), withSubcommands([
92712
+ const CliRuntimeLayer = mergeAll(layer$47, layer$45);
92713
+ const makeCli = () => make$64("t3", { ...sharedServerCommandFlags }).pipe(withDescription("Run the T3 Code server."), withHandler((flags) => runServerCommand(flags)), withSubcommands([
91765
92714
  startCommand,
91766
92715
  serveCommand,
91767
92716
  pairCommand,