clanka 0.25.2 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/Acp.d.ts +5 -37
  2. package/dist/Acp.d.ts.map +1 -1
  3. package/dist/Acp.js +33 -48
  4. package/dist/Acp.js.map +1 -1
  5. package/dist/Acp.test.js +62 -1
  6. package/dist/Acp.test.js.map +1 -1
  7. package/dist/AcpImage.test.js +3 -2
  8. package/dist/AcpImage.test.js.map +1 -1
  9. package/dist/AcpSessionStore.d.ts +114 -0
  10. package/dist/AcpSessionStore.d.ts.map +1 -0
  11. package/dist/AcpSessionStore.js +327 -0
  12. package/dist/AcpSessionStore.js.map +1 -0
  13. package/dist/AcpSessionStore.test.d.ts +2 -0
  14. package/dist/AcpSessionStore.test.d.ts.map +1 -0
  15. package/dist/AcpSessionStore.test.js +135 -0
  16. package/dist/AcpSessionStore.test.js.map +1 -0
  17. package/dist/Agent.d.ts.map +1 -1
  18. package/dist/Agent.js +5 -1
  19. package/dist/Agent.js.map +1 -1
  20. package/dist/Agent.test.js +20 -0
  21. package/dist/Agent.test.js.map +1 -1
  22. package/dist/ScriptFormatting.d.ts +3 -0
  23. package/dist/ScriptFormatting.d.ts.map +1 -0
  24. package/dist/ScriptFormatting.js +61 -0
  25. package/dist/ScriptFormatting.js.map +1 -0
  26. package/dist/ScriptFormatting.test.d.ts +2 -0
  27. package/dist/ScriptFormatting.test.d.ts.map +1 -0
  28. package/dist/ScriptFormatting.test.js +60 -0
  29. package/dist/ScriptFormatting.test.js.map +1 -0
  30. package/dist/bin/{AiError-CsvdOsKR.mjs → AiError-DBaKz35C.mjs} +2 -2
  31. package/dist/bin/{Latch-B3e9629m.mjs → Latch-DOdbsGMQ.mjs} +1 -1
  32. package/dist/bin/{McpClient-BCxZZgnA.mjs → McpClient-B-FFG6Pg.mjs} +1 -1
  33. package/dist/bin/{OutputFormatter-ByMjyBhe.mjs → OutputFormatter-DhhP2i-7.mjs} +2 -2
  34. package/dist/bin/{Schema-BfUmMefy.mjs → Schema-CFdSO6iH.mjs} +11 -1
  35. package/dist/bin/{SemanticSearch-DMzIsoZb.mjs → SemanticSearch-C3a7LAQr.mjs} +6 -6
  36. package/dist/bin/cli.mjs +392 -143
  37. package/dist/bin/{upgrade-t590zYhO.mjs → upgrade-C4aOEWJH.mjs} +2 -2
  38. package/dist/cli.js +10 -3
  39. package/dist/cli.js.map +1 -1
  40. package/dist/index.d.ts +4 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +4 -0
  43. package/dist/index.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/Acp.test.ts +120 -1
  46. package/src/Acp.ts +41 -55
  47. package/src/AcpImage.test.ts +7 -2
  48. package/src/AcpSessionStore.test.ts +220 -0
  49. package/src/AcpSessionStore.ts +455 -0
  50. package/src/Agent.test.ts +36 -0
  51. package/src/Agent.ts +5 -1
  52. package/src/ScriptFormatting.test.ts +66 -0
  53. package/src/ScriptFormatting.ts +57 -0
  54. package/src/cli.ts +20 -9
  55. package/src/index.ts +5 -0
package/dist/bin/cli.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env -S node --optimize-for-size
2
2
  import { i as __toESM, r as __require, t as __commonJSMin } from "./rolldown-runtime-CXhmmSW5.mjs";
3
- import { $ as URLFromString, $c as sync$1, $i as ignore, $l as fromInputUnsafe$1, $n as optionalKey$1, $r as stripCrlf, $s as TracerTimingEnabled, $t as isPattern, A as Null, Aa as provideServiceEffect, Ad as isTagged, An as escapeToken, Ar as fromBody, As as empty$10, At as isGreaterThan, Au as fromUndefinedOr, B as String$7, Ba as scope, Bd as identity, Bi as flatMapEager, Bl as headUnsafe, Bn as Objects, Br as retryAfterDelay, Bs as suspend$2, Bt as isLessThanDate, Bu as orElse$1, C as Literal, Ca as option$1, Cc as LogToStderr$1, Cd as isNotNullish, Cl as headNonEmpty, Cr as jsonSchemaAnnotationKeys, Cs as reasonAnnotations, Ct as isBetweenCodePoints, Cu as all$1, D as Never, Da as provide$1, Dd as isObject$1, Di as catch_, Dl as isReadonlyArrayNonEmpty, Dn as fromSchemaDraft07, Dr as redactUrl, Ds as effect, Dt as isBetweenSize, Du as flatMapNullishOr, E as Natural, Ea as promise, Ed as isNullish, Ei as catchTags, El as isCanonicalArrayIndex, En as errorWithPath, Er as fromInput, Es as buildWithScope, Et as isBetweenProperties, Eu as flatMap$2, F as OptionFromOptional, Fa as retry, Fd as constUndefined, Fi as fail$1, Fl as sort, Fn as encodeEffect, Fo as jittered, Fr as fromRecordUnsafe, Fs as orDie$1, Ft as isGreaterThanOrEqualToDate, Fu as isNone, G as TaggedClass$1, Ga as sleep, Gi as forever, Gl as isFailure$1, Gn as decodeTo, Gr as formatIso, Gs as close, Gt as isMaxLength, Gu as String$6, H as Struct, Hd as pipe, Hi as fn, Hl as failVoid, Hn as Suspend, Ho as isDoneCause, Hr as setAll, Hs as Scope, Ht as isLessThanOrEqualToBigInt, Hu as some, I as Record, Ia as runFork, Id as constVoid, Ii as failCause, Il as span, In as Arrays, Io as min, Ir as isRedactedName, Is as provide$3, It as isIncluding, Iu as isSome, J as TaggedUnion, Ji as forkIn, Jl as succeed$2, Jn as isJson, Jo as Clock, Js as make$44, Jt as isMinCodePoints, Ju as Prototype, K as TaggedError$1, Ka as succeed$1, Ki as forkChild, Kl as isSuccess$1, Kn as defaultParseOptions, Ko as parse$1, Ks as fork, Kt as isMaxProperties, L as Redacted$4, La as runForkWith, Li as failSync, Ll as assignProperty$1, Ln as Filter, Lo as spaced, Lr as merge$3, Ls as provideMerge, Lt as isInt, Lu as map$8, M as Number$2, Ma as repeat, Md as or, Mi as effectify, Ml as match$3, Mn as getSubschemaKind, Mo as forever$1, Mr as CurrentRedactedNames$1, Ms as merge$2, Mt as isGreaterThanDate, Mu as getOrNull, N as Option, Na as request, Nd as constFalse, Ni as ensuring, Nl as of, Nn as decodeEffect$1, No as fromStep, Nr as empty$6, Ns as mergeAll, Nt as isGreaterThanOrEqualTo, Nu as getOrThrow$1, O as NonEmptyArray, Oa as provideContext, Od as isObjectKeyword, Oi as context, Ol as join$2, On as fromSchemaDraft2020_12, Or as setAll$1, Os as effectContext, Ot as isEndingWith, Pa as result, Pd as constTrue, Pi as exit, Pl as reduce, Pn as decodeUnknownEffect, Po as isSchedule, Pr as fromInput$1, Ps as mock, Pt as isGreaterThanOrEqualToBigInt, Pu as getOrUndefined, Q as URL$1, Qa as tapCause, Qi as gen, Ql as format$1, Qn as null_, Qo as IllegalArgumentError, Qr as decodeNative, Qs as MinimumLogLevel, Qt as isMultipleOf, R as RedactedFromValue, Rd as dual, Ri as filterOrFail, Rl as map$10, Rn as FilterGroup, Ro as toStep, Rr as parseRetryAfter$1, Rs as succeed$4, Rt as isLessThan, Ru as match$2, S as JsonObject$1, Sa as onInterrupt, Sc as ConsoleRef, Sd as isNotNull, Si as catchIf, Sl as fromIterable, Sn as withDecodingDefaultKey, So as TaggedClass$2, Sr as annotationExcludedKeys, Ss as pretty, St as isBetweenBigInt, Ta as orElseSucceed, Td as isNull, Ti as catchTag, Tl as isArrayNonEmpty, Tn as pick, Tr as empty$5, Ts as build, Tt as isBetweenLength, Tu as filter$1, U as StructWithRest, Ua as service, Ud as pipeArguments, Ui as fnUntraced, Ul as getOrThrow, Un as Union$1, Ur as empty$7, Us as addFinalizer, Ut as isLessThanOrEqualToDate, Uu as toArray, V as StringForLiteralAutocomplete, Va as scoped, Vc as forkUnsafe, Vd as memoize, Vl as fail$2, Vn as PropertySignature, Vr as set, Vs as unwrap$4, Vt as isLessThanOrEqualTo, Vu as orElseSome, W as Symbol$1, Wa as serviceOption, Wi as forEach$1, Wl as getOrUndefined$2, Wn as applyToSelfOrLastLinkEncoding, Wo as Random$1, Wr as fromSetCookie, Ws as addFinalizerExit, Wt as isMaxCodePoints, X as Tuple, Xa as sync, Xi as fromOption, Xn as isOptional, Xr as decode$3, Xs as provide$2, Xt as isMinProperties, Xu as PipeInspectableProto, Y as TrueLiterals, Ya as suspend, Yi as forkScoped, Yl as try_$1, Yn as isNever, Yo as currentTimeMillis, Ys as makeUnsafe$2, Yt as isMinLength, Z as TupleWithRest, Za as tap, Zi as fromResult, Zl as normalizeNonEmpty, Zn as mapOrSame, Zo as Done, Zr as encode, Zs as CurrentLogAnnotations, Zt as isMinSize, _ as Exit, _a as matchEffect, _c as isFailure, _i as catchCause, _n as toEncoded$1, _o as withSpan$1, _r as transform$3, _s as isFailReason, _t as encodeUnknownEffect, _u as getOrUndefinedUnsafe, aa as logError, ac as isDone, ad as withFiber$1, al as ParentSpan, an as isUnique, ao as undefined_, ar as toEncoded, at as Void, au as millis, b as Int$5, ba as onExit, bc as void_$1, bd as hasProperty, bi as catchEager, bl as findLast, bn as withConstructorDefault, bo as equalBatchKeys, br as InvalidValue$1, bs as makeFailReason, bt as is, bu as makeUnsafe$3, c as Date$2, ca as logWarning, cc as makeUnsafe$1, cd as setStackTraceLimit, ci as andThen, cl as TaggedClass, cn as makeFilter$1, co as updateContext, cr as Transformation, cs as filterInterruptors, ct as declare, cu as toMillis, da as mapBothEager, dc as die$1, dd as NodeInspectSymbol, di as as, dl as compose, dn as optional$2, do as void_, dr as transformEffect$1, ds as hasInterrupts, dt as decodeTo$1, du as Service, ea as ignoreCause, ec as _await, ei as isRedacted, en as isPropertyNames, eo as timeout, er as replaceChecks, es as StackTrace, et as Uint8Array$2, eu as hours, f as DateTimeUtcFromString, fa as mapEager, fc as fail$3, fi as asSome, fl as has, fn as optionalKey, fr as transformOptional$1, fs as hasInterruptsOnly, ft as decodeUnknownEffect$1, fu as add, g as Error$2, ga as matchCauseEffect, gi as callback, gl as empty$4, gn as toCodecStringTree, go as withParentSpan, gr as passthroughSubtype, gt as encodeTo, gu as getOrUndefined$1, h as DurationFromMillis, hc as interrupt$1, hi as cachedWithTTL, hl as appendAll, hn as toCodecJson, hr as passthrough, hs as isDieReason, ht as encodeEffect$1, hu as getOption, i as Boolean$4, ia as logDebug, ic as into, ii as acquireRelease, il as DisablePropagation, in as isUUID, io as try_, ir as string$1, it as Unknown, iu as max, j as NullOr, ja as raceFirst, jd as isUndefined, ji as die, jl as map$7, jn as parseUriFragment, jo as exponential, jr as unwrap$3, js as fresh, jt as isGreaterThanBigInt, ju as getOrElse, k as NonEmptyString$1, ka as provideService, kd as isString, ki as contextWith, kl as last$1, kn as getReferenceKey, kr as toString, kt as isFinite$1, ku as fromNullishOr, la as makeSpanScoped, lc as succeed$5, ld as BaseProto, li as annotateCurrentSpan, ll as TaggedError, ln as makeFilterGroup, lo as updateService, lr as passthrough$1, ls as findErrorOption, lt as decodeEffect, lu as zero, m as Duration, ma as match$4, mc as findErrorOption$1, md as redact, mi as cached, ml as Array$1, mn as tag, mo as withFiber, mt as decodeUnknownSync, mu as get$2, n as ArraySchema, na as interruptible, nc as fail$4, ni as value, nn as isSchemaError, no as timeoutOrElse, nr as resolveDescription, ns as UnknownError, nt as UndefinedOr, nu as isFinite, o as BooleanLiterals, oa as logFatal, oc as isDoneUnsafe, od as assignProperty, oi as addFinalizer$1, ol as EncodingError, on as link$1, oo as uninterruptible, or as toType$1, os as done, ou as minutes, p as Defect, pa as mapError, pc as failCause$1, pd as format, pi as asVoid, pl as toPredicate, pn as suspend$1, po as whileLoop, ps as interruptors, pt as decodeUnknownOption, pu as empty$8, q as TaggedStruct, qa as succeedNone, qi as forkDetach, ql as map$6, qn as getIndexSignatureKeys, qo as round, qr as fromDateUnsafe, qt as isMaxSize, qu as mapInput, r as BigInt$2, ra as isEffect, ri as stringOrRedacted, rn as isStartingWith, ro as tryPromise, rr as resolveIdentifier, rs as annotate$1, rt as Union, s as Class$1, sa as logInfo, sc as make$43, sd as getStackTraceLimit, si as all, sl as Error$1, sn as make$41, so as uninterruptibleMask, sr as unknown$1, ss as fail$5, st as check, su as seconds, t as Any, ta as interrupt, tc as doneUnsafe, ti as make$40, tn as isSchema, to as timeoutOption, tr as resolveAt, ts as TimeoutError, tt as Uint8ArrayFromBase64, tu as infinity, ua as map$5, ud as Class, ui as annotateLogs, ul as taggedEnum, un as mutable, uo as useSpan, ur as transform$2, us as fromReasons, ut as decodeSync, uu as Reference, v as FalseLiterals, va as never$1, vc as isSuccess, vi as catchCauseIf, vl as findFirst, vn as toJsonSchemaDocument, vo as yieldNow, vr as transformEffect, vs as isTimeoutError, vt as fromJsonString, vu as getUnsafe, w as Literals$2, wa as orDie, wd as isNotUndefined, wi as catchReason, wl as isArray, wn as omit, wr as CurrentRedactedNames, ws as squash, wt as isBetweenDate, wu as exists, x as Json, xd as isIterable, xi as catchFilter, xn as withDecodingDefault, xr as Pointer, xs as map$9, xt as isBetween, xu as merge$1, y as Finite, ya as onError, yc as succeed$3, yl as findFirstIndex, yn as toType, yo as zipWith, yr as transformOptional, ys as makeDieReason, yt as instanceOf, yu as make$42, z as SchemaError, za as runSync, zd as flow, zi as flatMap$1, zl as empty$9, zn as Literal$1, zo as catchDone, zr as remove$1, zs as succeedContext, zt as isLessThanBigInt, zu as none } from "./Schema-BfUmMefy.mjs";
4
- import { $t as offerUnsafe, A as catchTags$1, At as takeUntil, B as failCause$3, Bt as unwrap$5, C as make$47, D as catchCause$1, Dt as succeed$6, E as callback$1, Et as splitLines, F as drainFork, Ft as transduce, G as flattenArray, Gt as endUnsafe, H as filterMap, Ht as makeUnsafe$4, I as drop, It as unwrap$6, Jt as failCauseUnsafe, K as flattenIterable, Kt as fail$7, L as empty$11, Lt as fromTransform$1, M as concat$1, Mt as tap$1, N as decodeText, Nt as tapError, Ot as suspend$3, P as die$2, Pt as toAsyncIterable, Qt as offerAllUnsafe, R as ensuring$1, Rt as mapDone, S as isAiErrorReason, St as runForEachArray, T as broadcast, Tt as scoped$1, Ut as bounded, V as filter$2, Vt as make$48, W as flatten, Wt as end, X as fromChannel$1, Xt as offer, Y as fromAsyncIterable, Yt as make$46, Z as fromEffect, Zt as offerAll, _ as ToolkitRequiredError, _n as toLowerCase, _t as run$4, a as InvalidOutputError, at as mapArray, b as buildErrorDescription, bt as runFold, c as InvalidToolResultError, cn as update, ct as mapError$1, d as RateLimitError, dn as interrupt$2, dt as mkString, en as poll, et as fromPull, f as StructuredOutputError, fn as interruptAll, ft as onExit$1, g as ToolResultEncodingError, gn as camelToSnake, gt as provideService$1, h as ToolParameterValidationError, hn as runIn, ht as provideContext$1, i as InternalProviderError, in as unbounded, it as map$11, j as catch_$1, jt as takeWhile, k as catchReason$1, kt as take$1, l as NetworkError, ln as await_, lt as merge$4, m as ToolNotFoundError, mn as join$3, mt as pipeThroughChannel, n as AuthenticationError, nn as sliding, nt as fromReadableStream, o as InvalidRequestError$1, on as make$45, ot as mapArrayEffect, p as ToolConfigurationError, pn as interruptAllAs, pt as orDie$2, q as fromArray, qt as failCause$2, r as HttpResponseDetails$1, rn as take, rt as isStream, s as InvalidResponseError, sn as set$1, st as mapEffect$1, t as AiError, tn as shutdownUnsafe, tt as fromQueue, u as QuotaExhaustedError, un as getCurrent, ut as mergeAll$1, v as UnknownError$1, vt as runCollect, w as reasonFromHttpStatus, wt as runLast, x as isAiError, xt as runForEach, y as UnsupportedSchemaError, yt as runDrain, z as fail$6, zt as toTransform } from "./AiError-CsvdOsKR.mjs";
5
- import { n as makeUnsafe$5 } from "./Latch-B3e9629m.mjs";
3
+ import { $ as URLFromString, $a as tapCause, $i as gen, $l as format$1, $n as null_, $o as IllegalArgumentError, $r as decodeNative, $s as MinimumLogLevel, $t as isMultipleOf, A as Null, Aa as provideService, Ad as isString, Ai as contextWith, Al as last$1, An as getReferenceKey, Ar as toString, At as isFinite$1, Au as fromNullishOr, B as String$7, Ba as runSync, Bd as flow, Bi as flatMap$1, Bl as empty$9, Bn as Literal$1, Bo as catchDone, Br as remove$1, Bs as succeedContext, Bt as isLessThanBigInt, Bu as none, C as Literal, Ca as onInterrupt, Cc as ConsoleRef, Cd as isNotNull, Ci as catchIf, Cl as fromIterable, Cn as withDecodingDefaultKey, Co as TaggedClass$2, Cr as annotationExcludedKeys, Cs as pretty, Ct as isBetweenBigInt, D as Never, Da as promise, Dd as isNullish, Di as catchTags, Dl as isCanonicalArrayIndex, Dn as errorWithPath, Dr as fromInput, Ds as buildWithScope, Dt as isBetweenProperties, Du as flatMap$2, E as Natural, Ea as orElseSucceed, Ed as isNull, Ei as catchTag, El as isArrayNonEmpty, En as pick, Er as empty$5, Es as build, Et as isBetweenLength, Eu as filter$1, F as OptionFromOptional, Fa as result, Fd as constTrue, Fi as exit, Fl as reduce, Fn as decodeUnknownEffect, Fo as isSchedule, Fr as fromInput$1, Fs as mock, Ft as isGreaterThanOrEqualToBigInt, Fu as getOrUndefined, G as TaggedClass$1, Ga as serviceOption, Gi as forEach$1, Gl as getOrUndefined$2, Gn as applyToSelfOrLastLinkEncoding, Go as Random$1, Gr as fromSetCookie, Gs as addFinalizerExit, Gt as isMaxCodePoints, H as Struct, Ha as scoped, Hc as forkUnsafe, Hd as memoize, Hl as fail$2, Hn as PropertySignature, Hr as set, Hs as unwrap$4, Ht as isLessThanOrEqualTo, Hu as orElseSome, I as Record, Ia as retry, Id as constUndefined, Ii as fail$1, Il as sort, In as encodeEffect, Io as jittered, Ir as fromRecordUnsafe, Is as orDie$1, It as isGreaterThanOrEqualToDate, Iu as isNone, J as TaggedUnion, Ja as succeedNone, Ji as forkDetach, Jl as map$6, Jn as getIndexSignatureKeys, Jo as round, Jr as fromDateUnsafe, Jt as isMaxSize, Ju as mapInput, K as TaggedError$1, Ka as sleep, Ki as forever, Kl as isFailure$1, Kn as decodeTo, Kr as formatIso, Ks as close, Kt as isMaxLength, Ku as String$6, L as Redacted$4, La as runFork, Ld as constVoid, Li as failCause, Ll as span, Ln as Arrays, Lo as min, Lr as isRedactedName, Ls as provide$3, Lt as isIncluding, Lu as isSome, M as Number$2, Ma as raceFirst, Md as isUndefined, Mi as die, Ml as map$7, Mn as parseUriFragment, Mo as exponential, Mr as unwrap$3, Ms as fresh, Mt as isGreaterThanBigInt, Mu as getOrElse, N as Option, Na as repeat, Nd as or, Ni as effectify, Nl as match$3, Nn as getSubschemaKind, No as forever$1, Nr as CurrentRedactedNames$1, Ns as merge$3, Nt as isGreaterThanDate, Nu as getOrNull, O as NonEmptyArray, Oa as provide$1, Od as isObject$1, Oi as catch_, Ol as isReadonlyArrayNonEmpty, On as fromSchemaDraft07, Or as redactUrl, Os as effect, Ot as isBetweenSize, Ou as flatMapNullishOr, Pa as request, Pd as constFalse, Pi as ensuring, Pl as of, Pn as decodeEffect$1, Po as fromStep, Pr as empty$6, Ps as mergeAll, Pt as isGreaterThanOrEqualTo, Pu as getOrThrow$1, Q as URL$1, Qa as tap, Qi as fromResult, Ql as normalizeNonEmpty, Qn as mapOrSame, Qo as Done, Qr as encode, Qs as CurrentLogAnnotations, Qt as isMinSize, R as RedactedFromValue, Ra as runForkWith, Ri as failSync, Rl as assignProperty$1, Rn as Filter, Ro as spaced, Rr as merge$2, Rs as provideMerge, Rt as isInt, Ru as map$8, S as JsonObject$1, Sd as isIterable, Si as catchFilter, Sn as withDecodingDefault, Sr as Pointer, Ss as map$9, St as isBetween, Su as merge$1, Ta as orDie, Td as isNotUndefined, Ti as catchReason, Tl as isArray, Tn as omit, Tr as CurrentRedactedNames, Ts as squash, Tt as isBetweenDate, Tu as exists, U as StructWithRest, Ud as pipe, Ui as fn, Ul as failVoid, Un as Suspend, Uo as isDoneCause, Ur as setAll, Us as Scope, Ut as isLessThanOrEqualToBigInt, Uu as some, V as StringForLiteralAutocomplete, Va as scope, Vd as identity, Vi as flatMapEager, Vl as headUnsafe, Vn as Objects, Vr as retryAfterDelay, Vs as suspend$2, Vt as isLessThanDate, Vu as orElse$1, W as Symbol$1, Wa as service, Wd as pipeArguments, Wi as fnUntraced, Wl as getOrThrow, Wn as Union$1, Wr as empty$7, Ws as addFinalizer, Wt as isLessThanOrEqualToDate, Wu as toArray, X as Tuple, Xa as suspend, Xi as forkScoped, Xl as try_$1, Xn as isNever, Xo as currentTimeMillis, Xs as makeUnsafe$2, Xt as isMinLength, Y as TrueLiterals, Yi as forkIn, Yl as succeed$2, Yn as isJson, Yo as Clock, Ys as make$44, Yt as isMinCodePoints, Yu as Prototype, Z as TupleWithRest, Za as sync, Zi as fromOption, Zn as isOptional, Zr as decode$3, Zs as provide$2, Zt as isMinProperties, Zu as PipeInspectableProto, _ as Exit, _a as matchCauseEffect, _i as callback, _l as empty$4, _n as toCodecStringTree, _o as withParentSpan, _r as passthroughSubtype, _t as encodeTo, _u as getOrUndefined$1, aa as logDebug, ac as into, ai as acquireRelease, al as DisablePropagation, an as isUUID, ao as try_, ar as string$1, at as Void, au as max, b as Int$5, ba as onError, bc as succeed$3, bl as findFirstIndex, bn as toType, bo as zipWith, br as transformOptional, bs as makeDieReason, bt as instanceOf, bu as make$42, c as Date$2, ca as logInfo, cc as make$43, cd as getStackTraceLimit, ci as all, cl as Error$1, cn as make$41, co as uninterruptibleMask, cr as unknown$1, cs as fail$5, ct as declare, cu as seconds, da as map$5, dd as Class, di as annotateLogs, dl as taggedEnum, dn as mutable, do as useSpan, dr as transform$2, ds as fromReasons, dt as decodeSync, du as Reference, ea as ignore, ec as TracerTimingEnabled, ei as stripCrlf, el as sync$1, en as isPattern, er as optionalKey$1, et as Uint8Array$2, eu as fromInputUnsafe$1, f as DateTimeUtcFromString, fa as mapBothEager, fc as die$1, fd as NodeInspectSymbol, fi as as, fl as compose, fn as optional$2, fo as void_, fr as transformEffect$1, fs as hasInterrupts, ft as decodeTo$1, fu as Service, g as Error$2, gc as interrupt$1, gi as cachedWithTTL, gl as appendAll, gn as toCodecJson, gr as passthrough, gs as isDieReason, gt as encodeEffect$1, gu as getOption, h as DurationFromMillis, ha as match$4, hc as findErrorOption$1, hd as redact, hi as cached, hl as Array$1, hn as tag, ho as withFiber, ht as decodeUnknownSync, hu as get$2, i as Boolean$4, ia as isEffect, ii as stringOrRedacted, in as isStartingWith, io as tryPromise, ir as resolveIdentifier, is as annotate$1, it as Unknown, j as NullOr, ja as provideServiceEffect, jd as isTagged, jn as escapeToken, jr as fromBody, js as empty$10, jt as isGreaterThan, ju as fromUndefinedOr, k as NonEmptyString$1, ka as provideContext, kd as isObjectKeyword, ki as context, kl as join$2, kn as fromSchemaDraft2020_12, kr as setAll$1, ks as effectContext, kt as isEndingWith, la as logWarning, lc as makeUnsafe$1, ld as setStackTraceLimit, li as andThen, ll as TaggedClass, ln as makeFilter$1, lo as updateContext, lr as Transformation, ls as filterInterruptors, lt as decodeEffect, lu as toMillis, m as Duration, ma as mapError, mc as failCause$1, md as format, mi as asVoid, ml as toPredicate, mn as suspend$1, mo as whileLoop, ms as interruptors, mt as decodeUnknownOption, mu as empty$8, n as ArraySchema, na as interrupt, nc as doneUnsafe, ni as make$40, nn as isSchema, no as timeoutOption, nr as resolveAt, ns as TimeoutError, nt as UndefinedOr, nu as infinity, o as BooleanLiterals, oa as logError, oc as isDone, od as withFiber$1, ol as ParentSpan, on as isUnique, oo as undefined_, or as toEncoded, ou as millis, p as Defect, pa as mapEager, pc as fail$3, pi as asSome, pl as has, pn as optionalKey, pr as transformOptional$1, ps as hasInterruptsOnly, pt as decodeUnknownEffect$1, pu as add, q as TaggedStruct, qa as succeed$1, qi as forkChild, ql as isSuccess$1, qn as defaultParseOptions, qo as parse$1, qs as fork, qt as isMaxProperties, r as BigInt$2, ra as interruptible, rc as fail$4, ri as value, rn as isSchemaError, ro as timeoutOrElse, rr as resolveDescription, rs as UnknownError, rt as Union, ru as isFinite, s as Class$1, sa as logFatal, sc as isDoneUnsafe, sd as assignProperty, si as addFinalizer$1, sl as EncodingError, sn as link$1, so as uninterruptible, sr as toType$1, ss as done, st as check, su as minutes, t as Any, ta as ignoreCause, tc as _await, ti as isRedacted, tn as isPropertyNames, to as timeout, tr as replaceChecks, ts as StackTrace, tt as Uint8ArrayFromBase64, tu as hours, ua as makeSpanScoped, uc as succeed$5, ud as BaseProto, ui as annotateCurrentSpan, ul as TaggedError, un as makeFilterGroup, uo as updateService, ur as passthrough$1, us as findErrorOption, ut as decodeExit, uu as zero, v as FalseLiterals, va as matchEffect, vc as isFailure, vi as catchCause, vn as toEncoded$1, vo as withSpan$1, vr as transform$3, vs as isFailReason, vt as encodeUnknownEffect, vu as getOrUndefinedUnsafe, w as Literals$2, wa as option$1, wc as LogToStderr$1, wd as isNotNullish, wl as headNonEmpty, wr as jsonSchemaAnnotationKeys, ws as reasonAnnotations, wt as isBetweenCodePoints, wu as all$1, x as Json, xa as onExit, xc as void_$1, xd as hasProperty, xi as catchEager, xl as findLast, xn as withConstructorDefault, xo as equalBatchKeys, xr as InvalidValue$1, xs as makeFailReason, xt as is, xu as makeUnsafe$3, y as Finite, ya as never$1, yc as isSuccess, yi as catchCauseIf, yl as findFirst, yn as toJsonSchemaDocument, yo as yieldNow, yr as transformEffect, ys as isTimeoutError, yt as fromJsonString, yu as getUnsafe, z as SchemaError, zd as dual, zi as filterOrFail, zl as map$10, zn as FilterGroup, zo as toStep, zr as parseRetryAfter$1, zs as succeed$4, zt as isLessThan, zu as match$2 } from "./Schema-CFdSO6iH.mjs";
4
+ import { $t as offerUnsafe, A as catchTags$1, At as takeUntil, B as failCause$3, Bt as unwrap$5, C as make$47, D as catchCause$1, Dt as succeed$6, E as callback$1, Et as splitLines, F as drainFork, Ft as transduce, G as flattenArray, Gt as endUnsafe, H as filterMap, Ht as makeUnsafe$4, I as drop, It as unwrap$6, Jt as failCauseUnsafe, K as flattenIterable, Kt as fail$7, L as empty$11, Lt as fromTransform$1, M as concat$1, Mt as tap$1, N as decodeText, Nt as tapError, Ot as suspend$3, P as die$2, Pt as toAsyncIterable, Qt as offerAllUnsafe, R as ensuring$1, Rt as mapDone, S as isAiErrorReason, St as runForEachArray, T as broadcast, Tt as scoped$1, Ut as bounded, V as filter$2, Vt as make$48, W as flatten, Wt as end, X as fromChannel$1, Xt as offer, Y as fromAsyncIterable, Yt as make$46, Z as fromEffect, Zt as offerAll, _ as ToolkitRequiredError, _n as toLowerCase, _t as run$4, a as InvalidOutputError, at as mapArray, b as buildErrorDescription, bt as runFold, c as InvalidToolResultError, cn as update, ct as mapError$1, d as RateLimitError, dn as interrupt$2, dt as mkString, en as poll, et as fromPull, f as StructuredOutputError, fn as interruptAll, ft as onExit$1, g as ToolResultEncodingError, gn as camelToSnake, gt as provideService$1, h as ToolParameterValidationError, hn as runIn, ht as provideContext$1, i as InternalProviderError, in as unbounded, it as map$11, j as catch_$1, jt as takeWhile, k as catchReason$1, kt as take$1, l as NetworkError, ln as await_, lt as merge$4, m as ToolNotFoundError, mn as join$3, mt as pipeThroughChannel, n as AuthenticationError, nn as sliding, nt as fromReadableStream, o as InvalidRequestError$1, on as make$45, ot as mapArrayEffect, p as ToolConfigurationError, pn as interruptAllAs, pt as orDie$2, q as fromArray, qt as failCause$2, r as HttpResponseDetails$1, rn as take, rt as isStream, s as InvalidResponseError, sn as set$1, st as mapEffect$1, t as AiError, tn as shutdownUnsafe, tt as fromQueue, u as QuotaExhaustedError, un as getCurrent, ut as mergeAll$1, v as UnknownError$1, vt as runCollect, w as reasonFromHttpStatus, wt as runLast, x as isAiError, xt as runForEach, y as UnsupportedSchemaError, yt as runDrain, z as fail$6, zt as toTransform } from "./AiError-DBaKz35C.mjs";
5
+ import { n as makeUnsafe$5 } from "./Latch-DOdbsGMQ.mjs";
6
6
  import { a as mergeCapabilities, c as safeParse, i as Protocol$1, n as assertToolsCallTaskCapability, o as getLiteralValue, r as AjvJsonSchemaValidator, s as getObjectShape, t as assertClientRequestTaskCapability } from "./helpers-Bb68A2Sv.mjs";
7
7
  import { $ as array, B as SUPPORTED_PROTOCOL_VERSIONS, C as LATEST_PROTOCOL_VERSION, D as ListResourcesResultSchema, E as ListResourceTemplatesResultSchema, I as PromptListChangedNotificationSchema, J as isJSONRPCResultResponse, N as McpError, Q as any, R as ReadResourceResultSchema, S as JSONRPCMessageSchema, T as ListPromptsResultSchema, U as ToolListChangedNotificationSchema, W as isInitializedNotification, Z as ZodNumber, at as string$2, b as InitializeResultSchema, c as CreateMessageResultSchema, d as ElicitRequestSchema, et as boolean, f as ElicitResultSchema, h as GetPromptResultSchema, it as object, j as ListToolsResultSchema, l as CreateMessageResultWithToolsSchema, lt as NEVER, m as ErrorCode, n as CallToolResultSchema, nt as looseObject, o as CompleteResultSchema, ot as url, p as EmptyResultSchema, q as isJSONRPCRequest, rt as number$1, s as CreateMessageRequestSchema, st as _coercedNumber, tt as literal, u as CreateTaskResultSchema, w as ListChangedOptionsBaseSchema, z as ResourceListChangedNotificationSchema } from "./types-N9Z-HYP0.mjs";
8
8
  import { createRequire } from "node:module";
@@ -18,6 +18,8 @@ import * as NodeConsole from "node:console";
18
18
  import * as NodeVm from "node:vm";
19
19
  import { Worker } from "node:worker_threads";
20
20
  import process$1 from "node:process";
21
+ import TreeSitter from "tree-sitter";
22
+ import JavaScript from "tree-sitter-javascript";
21
23
  import { isDeepStrictEqual } from "node:util";
22
24
  // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/BigInt.js
23
25
  const BigInt$1 = globalThis.BigInt;
@@ -1099,8 +1101,8 @@ const nativeDecodeOptions = { alphabet: "base64url" };
1099
1101
  const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1100
1102
  const codes = new Uint8Array(128);
1101
1103
  for (let i = 0; i < 64; i++) codes[alphabet.charCodeAt(i)] = i;
1102
- const decodeString = (str) => map$6(decode$2(str), (_) => decoder.decode(_));
1103
- const decoder = new TextDecoder("utf-8", { ignoreBOM: true });
1104
+ const decodeString = (str) => map$6(decode$2(str), (_) => decoder$1.decode(_));
1105
+ const decoder$1 = new TextDecoder("utf-8", { ignoreBOM: true });
1104
1106
  // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Terminal.js
1105
1107
  const TypeId$25 = "~effect/Terminal";
1106
1108
  const QuitErrorTypeId = "~effect/Terminal/QuitError";
@@ -2672,13 +2674,13 @@ var Uint8Array$1 = class extends Proto$14 {
2672
2674
  };
2673
2675
  }
2674
2676
  };
2675
- const encoder$1 = new TextEncoder();
2677
+ const encoder$2 = new TextEncoder();
2676
2678
  const buffer = globalThis.Buffer;
2677
- const encodeText = buffer !== void 0 ? (body) => buffer.from(body, "utf8") : (body) => encoder$1.encode(body);
2679
+ const encodeText = buffer !== void 0 ? (body) => buffer.from(body, "utf8") : (body) => encoder$2.encode(body);
2678
2680
  const text = (body, contentType) => {
2679
2681
  if (typeof body !== "string") body = body === void 0 ? "" : String(body);
2680
2682
  if (buffer !== void 0) return new Uint8Array$1(void 0, contentType ?? "text/plain", buffer.byteLength(body, "utf8"), body);
2681
- const bytes = encoder$1.encode(body);
2683
+ const bytes = encoder$2.encode(body);
2682
2684
  return new Uint8Array$1(bytes, contentType ?? "text/plain", bytes.length, body);
2683
2685
  };
2684
2686
  const jsonUnsafe = (body, contentType) => text(JSON.stringify(body), contentType ?? "application/json");
@@ -3799,7 +3801,7 @@ var UndiciResponse = class extends Class {
3799
3801
  return pipeArguments(this, arguments);
3800
3802
  }
3801
3803
  };
3802
- const loadUpgrade = promise(() => import("./upgrade-t590zYhO.mjs"));
3804
+ const loadUpgrade = promise(() => import("./upgrade-C4aOEWJH.mjs"));
3803
3805
  const takeOver = (conn, head, signal) => {
3804
3806
  if (head !== void 0 && head.length > 0) conn.unshift(head);
3805
3807
  conn.on("error", constVoid);
@@ -9355,7 +9357,7 @@ const make$21 = (options) => Socket.of({
9355
9357
  reader: options.reader,
9356
9358
  writer: options.writer
9357
9359
  });
9358
- const encoder = new TextEncoder();
9360
+ const encoder$1 = new TextEncoder();
9359
9361
  const CloseEventTypeId = "~effect/socket/Socket/CloseEvent";
9360
9362
  const isCloseEvent = (u) => hasProperty(u, CloseEventTypeId);
9361
9363
  const SocketErrorTypeId = "~effect/socket/Socket/SocketError";
@@ -9476,7 +9478,7 @@ const fromWebSocket = (acquire, options) => withFiber((fiber) => {
9476
9478
  }
9477
9479
  function push(data) {
9478
9480
  buffer.push(data);
9479
- if (highWaterMark !== void 0) bufferSize += typeof data === "string" ? encoder.encode(data).byteLength : data.byteLength;
9481
+ if (highWaterMark !== void 0) bufferSize += typeof data === "string" ? encoder$1.encode(data).byteLength : data.byteLength;
9480
9482
  if (waiter !== void 0) deliver();
9481
9483
  if (pausable && bufferSize >= highWaterMark) pauseWebSocket();
9482
9484
  else if (!pausable && !waiter && highWaterMark !== void 0 && bufferSize > highWaterMark) fail(new SocketError({ reason: new SocketReadError({ cause: new Error(`Socket highWaterMark of ${highWaterMark} bytes exceeded`) }) }));
@@ -9950,7 +9952,7 @@ const prefix = dual(2, (self, prefix) => {
9950
9952
  modifyUint8Array: (key, f) => self.modifyUint8Array(`${prefix}${key}`, f)
9951
9953
  };
9952
9954
  });
9953
- const layerFileSystem = (directory) => effect(KeyValueStore)(gen(function* () {
9955
+ const layerFileSystem$1 = (directory) => effect(KeyValueStore)(gen(function* () {
9954
9956
  const fs = yield* FileSystem;
9955
9957
  const path = yield* Path$3;
9956
9958
  const withKeyPath = (method, key, f) => key.length === 0 || key === "." || key === ".." ? fail$1(new KeyValueStoreError({
@@ -10052,30 +10054,6 @@ const toSchemaStore = (self, schema) => {
10052
10054
  isEmpty: self.isEmpty
10053
10055
  };
10054
10056
  };
10055
- // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/ai/Model.js
10056
- const TypeId$8 = "~effect/ai/Model";
10057
- var ProviderName = class extends Service()("effect/ai/Model/ProviderName") {};
10058
- var ModelName = class extends Service()("effect/ai/Model/ModelName") {};
10059
- const Proto$4 = {
10060
- [TypeId$8]: TypeId$8,
10061
- ["~effect/Layer"]: {
10062
- _ROut: identity,
10063
- _E: identity,
10064
- _RIn: identity
10065
- },
10066
- get captureRequirements() {
10067
- const self = this;
10068
- return contextWith((context) => succeed$1(provide$3(self, succeedContext(context))));
10069
- },
10070
- ...PipeInspectableProto,
10071
- toJSON() {
10072
- return {
10073
- _id: "effect/ai/Model",
10074
- provider: this.provider
10075
- };
10076
- }
10077
- };
10078
- const make$18 = (provider, modelName, layer) => Object.assign(Object.create(Proto$4), { provider }, merge$2(layer, succeedContext(ProviderName.context(provider).pipe(add(ModelName, modelName)))));
10079
10057
  // src/ApplyPatch.ts
10080
10058
  const BEGIN = "*** Begin Patch";
10081
10059
  const END = "*** End Patch";
@@ -10419,7 +10397,7 @@ var ExaError = class extends TaggedError$1()("ExaError", { cause: Defect() }) {}
10419
10397
  const layer$8 = effect(ExaSearch, gen(function* () {
10420
10398
  const scope$5 = yield* scope;
10421
10399
  const getClient = yield* cachedWithTTL(gen(function* () {
10422
- const McpClient = yield* tryPromise(() => import("./McpClient-BCxZZgnA.mjs"));
10400
+ const McpClient = yield* tryPromise(() => import("./McpClient-B-FFG6Pg.mjs"));
10423
10401
  const context = yield* buildWithScope(McpClient.layer, scope$5);
10424
10402
  return get$2(context, McpClient.McpClient);
10425
10403
  }), (exit) => isSuccess(exit) ? infinity : zero);
@@ -10491,7 +10469,7 @@ const layer$7 = effect(WebToMarkdown, gen(function* () {
10491
10469
  });
10492
10470
  }));
10493
10471
  // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/ai/Tool.js
10494
- const TypeId$7 = "~effect/ai/Tool";
10472
+ const TypeId$8 = "~effect/ai/Tool";
10495
10473
  const ProviderDefinedTypeId = "~effect/ai/Tool/ProviderDefined";
10496
10474
  const DynamicTypeId = "~effect/ai/Tool/Dynamic";
10497
10475
  const isUserDefined = (u) => hasProperty(u, "~effect/ai/Tool") && !isProviderDefined(u) && !isDynamic(u);
@@ -10499,8 +10477,8 @@ const isProviderDefined = (u) => hasProperty(u, ProviderDefinedTypeId);
10499
10477
  const isDynamic = (u) => hasProperty(u, DynamicTypeId);
10500
10478
  const isClientExecuted = (tool) => tool.execution === "client";
10501
10479
  const clone = (self, overrides) => Object.assign(Object.create(Object.getPrototypeOf(self)), self, overrides);
10502
- const Proto$3 = {
10503
- [TypeId$7]: {
10480
+ const Proto$4 = {
10481
+ [TypeId$8]: {
10504
10482
  _Config: identity,
10505
10483
  _Requirements: identity
10506
10484
  },
@@ -10536,19 +10514,19 @@ const Proto$3 = {
10536
10514
  }
10537
10515
  };
10538
10516
  const ProviderDefinedProto = {
10539
- ...Proto$3,
10517
+ ...Proto$4,
10540
10518
  [ProviderDefinedTypeId]: ProviderDefinedTypeId
10541
10519
  };
10542
10520
  const DynamicProto = {
10543
- ...Proto$3,
10521
+ ...Proto$4,
10544
10522
  [DynamicTypeId]: DynamicTypeId
10545
10523
  };
10546
10524
  const userDefinedProto = (options) => {
10547
- const self = Object.assign(Object.create(Proto$3), options);
10525
+ const self = Object.assign(Object.create(Proto$4), options);
10548
10526
  self.id = `effect/ai/Tool/${options.name}`;
10549
10527
  return self;
10550
10528
  };
10551
- const make$17 = (name, options) => {
10529
+ const make$18 = (name, options) => {
10552
10530
  const successSchema = options?.success ?? Void;
10553
10531
  const failureSchema = options?.failure ?? Never;
10554
10532
  return userDefinedProto({
@@ -10650,7 +10628,7 @@ function isEmptyParamsRecord(indexSignature) {
10650
10628
  return indexSignature.parameter === string$1 && isNever(indexSignature.type);
10651
10629
  }
10652
10630
  // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/ai/Toolkit.js
10653
- const TypeId$6 = "~effect/ai/Toolkit";
10631
+ const TypeId$7 = "~effect/ai/Toolkit";
10654
10632
  const FailureOrigin = Reference("effect/ai/Toolkit/FailureOrigin", { defaultValue: () => "result" });
10655
10633
  const PreliminaryBuffer = Reference("effect/ai/Toolkit/PreliminaryBuffer", { defaultValue: () => "unbounded" });
10656
10634
  const RecordToolArguments = Reference("effect/ai/Toolkit/RecordToolArguments", { defaultValue: () => false });
@@ -10663,7 +10641,7 @@ const stringifyToolArguments = (params) => {
10663
10641
  };
10664
10642
  const failureCause = (error, origin) => annotate$1(fail$5(error), make$42(FailureOrigin, origin));
10665
10643
  const failureOrigin = (error) => isSchemaError(error) ? "result" : "handler";
10666
- const Proto$2 = {
10644
+ const Proto$3 = {
10667
10645
  ...Prototype({
10668
10646
  label: "Toolkit",
10669
10647
  evaluate: fnUntraced(function* (parent) {
@@ -10791,7 +10769,7 @@ const Proto$2 = {
10791
10769
  };
10792
10770
  })
10793
10771
  }),
10794
- [TypeId$6]: TypeId$6,
10772
+ [TypeId$7]: TypeId$7,
10795
10773
  of: identity,
10796
10774
  toHandlers(build) {
10797
10775
  return gen({ self: this }, function* () {
@@ -10819,14 +10797,14 @@ const Proto$2 = {
10819
10797
  };
10820
10798
  }
10821
10799
  };
10822
- const makeProto$2 = (tools) => Object.assign(function() {}, Proto$2, { tools });
10800
+ const makeProto$2 = (tools) => Object.assign(function() {}, Proto$3, { tools });
10823
10801
  const resolveInput = (...tools) => {
10824
10802
  const output = {};
10825
10803
  for (const tool of tools) assignProperty(output, tool.name, tool);
10826
10804
  return output;
10827
10805
  };
10828
10806
  const empty = makeProto$2({});
10829
- const make$16 = (...tools) => makeProto$2(resolveInput(...tools));
10807
+ const make$17 = (...tools) => makeProto$2(resolveInput(...tools));
10830
10808
  const merge = (...toolkits) => {
10831
10809
  const tools = {};
10832
10810
  for (const toolkit of toolkits) for (const [name, tool] of Object.entries(toolkit.tools)) assignProperty(tools, name, tool);
@@ -11220,7 +11198,7 @@ var CommandLimits = class extends Reference("clanka/AgentTools/CommandLimits", {
11220
11198
  timeout: void 0,
11221
11199
  outputChars: void 0
11222
11200
  }) }) {};
11223
- const makeBashTool = (timeout) => make$17("bash", {
11201
+ const makeBashTool = (timeout) => make$18("bash", {
11224
11202
  description: "Run a bash command and return a task.",
11225
11203
  parameters: Struct({
11226
11204
  command: String$7,
@@ -11231,12 +11209,12 @@ const makeBashTool = (timeout) => make$17("bash", {
11231
11209
  dependencies: [CurrentDirectory]
11232
11210
  });
11233
11211
  const globNamesDirectory = (glob) => glob.split("/").slice(0, -1).some((segment) => segment.length > 0 && !/[*?[\]{}]/.test(segment));
11234
- const AgentTools = make$16(make$17("changeDirectory", {
11212
+ const AgentTools = make$17(make$18("changeDirectory", {
11235
11213
  description: "Change the executor's working directory to an existing directory and return its absolute path. The change persists across your scripts.",
11236
11214
  parameters: String$7.annotate({ identifier: "directory" }),
11237
11215
  success: String$7,
11238
11216
  dependencies: [DirectoryChanger]
11239
- }), make$17("readFile", {
11217
+ }), make$18("readFile", {
11240
11218
  description: "Read a file and optionally filter the lines to return. Returns null if the file doesn't exist. For png/jpeg/gif/webp files the image itself is attached to your next turn.",
11241
11219
  parameters: Struct({
11242
11220
  path: String$7,
@@ -11246,12 +11224,12 @@ const AgentTools = make$16(make$17("changeDirectory", {
11246
11224
  }),
11247
11225
  success: NullOr(String$7),
11248
11226
  dependencies: [CurrentDirectory, ImageAttacher]
11249
- }), make$17("run", {
11227
+ }), make$18("run", {
11250
11228
  description: "Run a shell command and return its output. If it takes too long it will become a background task. Use 'bash' for more control.",
11251
11229
  parameters: String$7.annotate({ identifier: "command" }),
11252
11230
  success: String$7,
11253
11231
  dependencies: [CurrentDirectory]
11254
- }), make$17("rg", {
11232
+ }), make$18("rg", {
11255
11233
  description: "Search for a pattern in files using ripgrep",
11256
11234
  parameters: Struct({
11257
11235
  pattern: String$7,
@@ -11261,7 +11239,7 @@ const AgentTools = make$16(make$17("changeDirectory", {
11261
11239
  }),
11262
11240
  success: String$7,
11263
11241
  dependencies: [CurrentDirectory]
11264
- }), make$17("subagent", {
11242
+ }), make$18("subagent", {
11265
11243
  description: "Delegate a task to another software engineer / sub-agent. With `background: true` the sub-agent works in the background, and its result is sent to you when it finishes.",
11266
11244
  parameters: Struct({
11267
11245
  prompt: String$7,
@@ -11270,57 +11248,57 @@ const AgentTools = make$16(make$17("changeDirectory", {
11270
11248
  success: Task,
11271
11249
  failure: String$7,
11272
11250
  dependencies: [AgentTaskExecutor]
11273
- }), make$17("gh", {
11251
+ }), make$18("gh", {
11274
11252
  description: "Use the GitHub CLI to run a command - use this instead of the bash tool.",
11275
11253
  parameters: ArraySchema(String$7).annotate({ identifier: "args" }),
11276
11254
  success: String$7,
11277
11255
  dependencies: [CurrentDirectory]
11278
- }), makeBashTool(defaultBashTimeout), make$17("applyPatch", {
11256
+ }), makeBashTool(defaultBashTimeout), make$18("applyPatch", {
11279
11257
  description: "Add, update or remove multiple files with a git diff / unified diff / wrapped patch.",
11280
11258
  parameters: String$7.annotate({ identifier: "patch" }),
11281
11259
  success: String$7,
11282
11260
  dependencies: [CurrentDirectory]
11283
- }), make$17("writeFile", {
11261
+ }), make$18("writeFile", {
11284
11262
  description: "Write content to a file, creating parent directories if needed.",
11285
11263
  parameters: Struct({
11286
11264
  path: String$7,
11287
11265
  content: Union([String$7, Uint8Array$2.annotate({ identifier: "Uint8Array" })])
11288
11266
  }),
11289
11267
  dependencies: [CurrentDirectory]
11290
- }), make$17("removeFile", {
11268
+ }), make$18("removeFile", {
11291
11269
  description: "Remove a file.",
11292
11270
  parameters: String$7.annotate({ identifier: "path" }),
11293
11271
  dependencies: [CurrentDirectory]
11294
- }), make$17("renameFile", {
11272
+ }), make$18("renameFile", {
11295
11273
  description: "Rename or move a file, creating parent directories if needed.",
11296
11274
  parameters: Struct({
11297
11275
  from: String$7,
11298
11276
  to: String$7
11299
11277
  }),
11300
11278
  dependencies: [CurrentDirectory]
11301
- }), make$17("ls", {
11279
+ }), make$18("ls", {
11302
11280
  description: "List the contents of a directory",
11303
11281
  parameters: String$7.annotate({ identifier: "directory" }),
11304
11282
  success: ArraySchema(String$7),
11305
11283
  dependencies: [CurrentDirectory]
11306
- }), make$17("webSearch", {
11284
+ }), make$18("webSearch", {
11307
11285
  description: "Search the web for recent information.",
11308
11286
  parameters: ExaSearchOptions,
11309
11287
  success: String$7
11310
- }), make$17("fetchMarkdown", {
11288
+ }), make$18("fetchMarkdown", {
11311
11289
  description: "Fetch a web page and convert it to markdown.",
11312
11290
  parameters: String$7.annotate({ identifier: "url" }),
11313
11291
  success: String$7
11314
- }), make$17("sleep", {
11292
+ }), make$18("sleep", {
11315
11293
  description: "Sleep for a specified number of milliseconds",
11316
11294
  parameters: Finite.annotate({ identifier: "ms" })
11317
- }), make$17("taskOutput", {
11295
+ }), make$18("taskOutput", {
11318
11296
  description: "Return the status and output so far of one of your tasks: a background bash command or a sub-agent.",
11319
11297
  parameters: String$7.annotate({ identifier: "id" }),
11320
11298
  success: Task,
11321
11299
  failure: String$7,
11322
11300
  dependencies: [AgentTaskExecutor]
11323
- }), make$17("waitTasks", {
11301
+ }), make$18("waitTasks", {
11324
11302
  description: "Wait until the given tasks have ended and return them, in the order given.",
11325
11303
  parameters: Struct({
11326
11304
  ids: ArraySchema(String$7),
@@ -11329,17 +11307,17 @@ const AgentTools = make$16(make$17("changeDirectory", {
11329
11307
  success: ArraySchema(Task),
11330
11308
  failure: String$7,
11331
11309
  dependencies: [AgentTaskExecutor]
11332
- }), make$17("stopTask", {
11310
+ }), make$18("stopTask", {
11333
11311
  description: "Stop one of your tasks.",
11334
11312
  parameters: String$7.annotate({ identifier: "id" }),
11335
11313
  failure: String$7,
11336
11314
  dependencies: [AgentTaskExecutor]
11337
- }), make$17("listTasks", {
11315
+ }), make$18("listTasks", {
11338
11316
  description: "List the tasks you have started, with their status.",
11339
11317
  parameters: Void,
11340
11318
  success: ArraySchema(Task),
11341
11319
  dependencies: [AgentTaskExecutor]
11342
- }), make$17("messageAgent", {
11320
+ }), make$18("messageAgent", {
11343
11321
  description: "Send a message to one of your sub-agents.",
11344
11322
  parameters: Struct({
11345
11323
  id: String$7,
@@ -11347,13 +11325,13 @@ const AgentTools = make$16(make$17("changeDirectory", {
11347
11325
  }),
11348
11326
  failure: String$7,
11349
11327
  dependencies: [AgentTaskExecutor]
11350
- }), make$17("taskComplete", {
11328
+ }), make$18("taskComplete", {
11351
11329
  description: "Only call this when the task is fully complete and you have a final output message to send.",
11352
11330
  parameters: String$7.annotate({ identifier: "output" }),
11353
11331
  dependencies: [TaskCompleter],
11354
11332
  failure: String$7
11355
11333
  }));
11356
- const SearchTool = make$16(make$17("search", {
11334
+ const SearchTool = make$17(make$18("search", {
11357
11335
  description: "Semantic code search - you just need to describe what you are looking for",
11358
11336
  parameters: String$7.annotate({ identifier: "query" }),
11359
11337
  success: String$7,
@@ -12326,10 +12304,10 @@ const makeCollectorUnsafe = () => {
12326
12304
  });
12327
12305
  };
12328
12306
  // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/FiberSet.js
12329
- const TypeId$5 = "~effect/FiberSet";
12330
- const isFiberSet = (u) => hasProperty(u, TypeId$5);
12331
- const Proto$1 = {
12332
- [TypeId$5]: TypeId$5,
12307
+ const TypeId$6 = "~effect/FiberSet";
12308
+ const isFiberSet = (u) => hasProperty(u, TypeId$6);
12309
+ const Proto$2 = {
12310
+ [TypeId$6]: TypeId$6,
12333
12311
  [Symbol.iterator]() {
12334
12312
  if (this.state._tag === "Closed") return empty$9();
12335
12313
  return this.state.backing[Symbol.iterator]();
@@ -12343,7 +12321,7 @@ const Proto$1 = {
12343
12321
  }
12344
12322
  };
12345
12323
  const makeUnsafe = (backing, deferred) => {
12346
- const self = Object.create(Proto$1);
12324
+ const self = Object.create(Proto$2);
12347
12325
  self.state = {
12348
12326
  _tag: "Open",
12349
12327
  backing
@@ -12351,7 +12329,7 @@ const makeUnsafe = (backing, deferred) => {
12351
12329
  self.deferred = deferred;
12352
12330
  return self;
12353
12331
  };
12354
- const make$15 = () => acquireRelease(sync(() => makeUnsafe(new Set(), makeUnsafe$1())), (set) => suspend(() => {
12332
+ const make$16 = () => acquireRelease(sync(() => makeUnsafe(new Set(), makeUnsafe$1())), (set) => suspend(() => {
12355
12333
  const state = set.state;
12356
12334
  if (state._tag === "Closed") return void_;
12357
12335
  set.state = { _tag: "Closed" };
@@ -12439,9 +12417,9 @@ var ClientAbort = class extends Service()("effect/rpc/RpcSchema/ClientAbort") {
12439
12417
  }));
12440
12418
  };
12441
12419
  // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/rpc/Rpc.js
12442
- const TypeId$4 = "~effect/rpc/Rpc";
12443
- const Proto = {
12444
- [TypeId$4]: TypeId$4,
12420
+ const TypeId$5 = "~effect/rpc/Rpc";
12421
+ const Proto$1 = {
12422
+ [TypeId$5]: TypeId$5,
12445
12423
  pipe() {
12446
12424
  return pipeArguments(this, arguments);
12447
12425
  },
@@ -12525,12 +12503,12 @@ const Proto = {
12525
12503
  };
12526
12504
  const makeProto$1 = (options) => {
12527
12505
  function Rpc() {}
12528
- Object.setPrototypeOf(Rpc, Proto);
12506
+ Object.setPrototypeOf(Rpc, Proto$1);
12529
12507
  Object.assign(Rpc, options);
12530
12508
  Rpc.key = `effect/rpc/Rpc/${options._tag}`;
12531
12509
  return Rpc;
12532
12510
  };
12533
- const make$14 = (tag, options) => {
12511
+ const make$15 = (tag, options) => {
12534
12512
  const successSchema = options?.success ?? Void;
12535
12513
  const errorSchema = options?.error ?? Never;
12536
12514
  const defectSchema = options?.defect ?? Defect();
@@ -12702,7 +12680,7 @@ const makeNoSerialization = fnUntraced(function* (group, options) {
12702
12680
  spanId: span.spanId,
12703
12681
  sampled: span.sampled
12704
12682
  } : {},
12705
- headers: merge$3(parentFiber.getRef(CurrentHeaders), headers),
12683
+ headers: merge$2(parentFiber.getRef(CurrentHeaders), headers),
12706
12684
  ...discard ? { discard: true } : {}
12707
12685
  });
12708
12686
  let fiber;
@@ -12773,7 +12751,7 @@ const makeNoSerialization = fnUntraced(function* (group, options) {
12773
12751
  spanId: span.spanId,
12774
12752
  sampled: span.sampled
12775
12753
  } : {},
12776
- headers: merge$3(fiber.getRef(CurrentHeaders), headers)
12754
+ headers: merge$2(fiber.getRef(CurrentHeaders), headers)
12777
12755
  }).pipe(span ? withParentSpan(span, { captureStackTrace: false }) : identity, onError((cause) => {
12778
12756
  if (!hasInterruptsOnly(cause)) entries.delete(id);
12779
12757
  return failCause$2(queue, cause);
@@ -12864,7 +12842,7 @@ const makeNoSerialization = fnUntraced(function* (group, options) {
12864
12842
  };
12865
12843
  });
12866
12844
  let clientIdCounter = 0;
12867
- const make$13 = fnUntraced(function* (group, options) {
12845
+ const make$14 = fnUntraced(function* (group, options) {
12868
12846
  const clientId = clientIdCounter++;
12869
12847
  const { codecFor, run, send, supportsAck, supportsTransferables } = yield* Protocol;
12870
12848
  const rpcSchemas = makeRpcSchemas(codecFor);
@@ -13134,7 +13112,7 @@ const makeProto = (options) => Object.assign(function() {}, RpcGroupProto, {
13134
13112
  requests: options.requests,
13135
13113
  annotations: options.annotations
13136
13114
  });
13137
- const make$12 = (...rpcs) => makeProto({
13115
+ const make$13 = (...rpcs) => makeProto({
13138
13116
  requests: new Map(rpcs.map((rpc) => [rpc._tag, rpc])),
13139
13117
  annotations: empty$8()
13140
13118
  });
@@ -13852,7 +13830,7 @@ const makeLocalWith = fnUntraced(function* (options) {
13852
13830
  const excluded = excludedToolNames(options.excludeTools);
13853
13831
  const offersFetch = !excluded.has("fetch");
13854
13832
  const search = yield* serviceOption(SemanticSearch);
13855
- const BuiltInTools = make$16(...Object.values(merge(isSome(search) ? AgentToolsWithSearch : AgentTools, make$16(makeBashTool(commandLimits.timeout ?? defaultBashTimeout))).tools).filter((tool) => !excluded.has(tool.name)));
13833
+ const BuiltInTools = make$17(...Object.values(merge(isSome(search) ? AgentToolsWithSearch : AgentTools, make$17(makeBashTool(commandLimits.timeout ?? defaultBashTimeout))).tools).filter((tool) => !excluded.has(tool.name)));
13856
13834
  const hasSearch = "search" in BuiltInTools.tools;
13857
13835
  const AllTools = merge(BuiltInTools, options.tools ?? empty);
13858
13836
  const tools = yield* AllTools;
@@ -14029,7 +14007,7 @@ const makeLocalWith = fnUntraced(function* (options) {
14029
14007
  };
14030
14008
  });
14031
14009
  const makeRpc = gen(function* () {
14032
- const client = yield* make$13(Rpcs, { spanPrefix: "AgentExecutorClient" });
14010
+ const client = yield* make$14(Rpcs, { spanPrefix: "AgentExecutorClient" });
14033
14011
  return AgentExecutor.of({
14034
14012
  capabilities: orDie(client.capabilities()),
14035
14013
  execute: (opts) => Scope.useSync((scope) => {
@@ -14133,10 +14111,10 @@ const ExecuteOutput = TaggedUnion({
14133
14111
  kind: TaskKind
14134
14112
  }
14135
14113
  });
14136
- var Rpcs = class extends make$12(make$14("capabilities", { success: Capabilities }), make$14("respond", { payload: {
14114
+ var Rpcs = class extends make$13(make$15("capabilities", { success: Capabilities }), make$15("respond", { payload: {
14137
14115
  id: Finite,
14138
14116
  response: AgentResponse
14139
- } }), make$14("execute", {
14117
+ } }), make$15("execute", {
14140
14118
  payload: Struct({
14141
14119
  script: String$7,
14142
14120
  environment: ExecutionEnvironment,
@@ -14146,21 +14124,21 @@ var Rpcs = class extends make$12(make$14("capabilities", { success: Capabilities
14146
14124
  }),
14147
14125
  success: ExecuteOutput,
14148
14126
  stream: true
14149
- }), make$14("awaitTask", {
14127
+ }), make$15("awaitTask", {
14150
14128
  payload: { id: String$7 },
14151
14129
  success: Task,
14152
14130
  error: String$7
14153
- }), make$14("claimTask", {
14131
+ }), make$15("claimTask", {
14154
14132
  payload: { id: String$7 },
14155
14133
  success: Boolean$4,
14156
14134
  error: String$7
14157
- }), make$14("renderEnvironment", {
14135
+ }), make$15("renderEnvironment", {
14158
14136
  payload: {
14159
14137
  environment: ExecutionEnvironment,
14160
14138
  reset: Boolean$4
14161
14139
  },
14162
14140
  success: EnvironmentUpdate
14163
- }), make$14("executeUnsafe", {
14141
+ }), make$15("executeUnsafe", {
14164
14142
  payload: Struct({
14165
14143
  tool: String$7,
14166
14144
  params: optionalKey(Json),
@@ -14409,6 +14387,233 @@ var QueueWriteStream = class extends Writable {
14409
14387
  callback();
14410
14388
  }
14411
14389
  };
14390
+ // src/AcpSessionStore.ts
14391
+ const ThoughtLevel = Literals$2([
14392
+ "none",
14393
+ "minimal",
14394
+ "low",
14395
+ "medium",
14396
+ "high",
14397
+ "xhigh",
14398
+ "max"
14399
+ ]);
14400
+ var SessionRecord = class extends Class$1("clanka/Acp/SessionRecord")({
14401
+ cwd: String$7,
14402
+ model: String$7,
14403
+ thoughtLevel: ThoughtLevel,
14404
+ fastMode: optionalKey(Boolean$4),
14405
+ history: Prompt,
14406
+ environment: optionalKey(ExecutionEnvironment)
14407
+ }) {};
14408
+ var AcpSessionStoreError = class extends TaggedError$1()("AcpSessionStoreError", {
14409
+ message: String$7,
14410
+ cause: optional$2(Defect())
14411
+ }) {};
14412
+ var AcpSessionStore = class extends Service()("clanka/AcpSessionStore") {};
14413
+ const keyValueStore = (kvs) => {
14414
+ const store = toSchemaStore(prefix(kvs, "session-"), SessionRecord);
14415
+ return AcpSessionStore.of({
14416
+ get: (sessionId) => store.get(sessionId).pipe(mapError((cause) => new AcpSessionStoreError({
14417
+ message: cause.message,
14418
+ cause
14419
+ }))),
14420
+ set: (sessionId, record) => store.set(sessionId, record).pipe(mapError((cause) => new AcpSessionStoreError({
14421
+ message: cause.message,
14422
+ cause
14423
+ })))
14424
+ });
14425
+ };
14426
+ const layerKeyValueStore = effect(AcpSessionStore, gen(function* () {
14427
+ return keyValueStore(yield* KeyValueStore);
14428
+ }));
14429
+ const Snapshot = TaggedStruct("Snapshot", {
14430
+ record: SessionRecord,
14431
+ id: String$7
14432
+ });
14433
+ const Update = TaggedStruct("Update", {
14434
+ cwd: optionalKey(String$7),
14435
+ model: optionalKey(String$7),
14436
+ thoughtLevel: optionalKey(ThoughtLevel),
14437
+ fastMode: optionalKey(Boolean$4),
14438
+ environment: optionalKey(ExecutionEnvironment),
14439
+ messages: optionalKey(ArraySchema(Message)),
14440
+ parent: String$7,
14441
+ id: String$7
14442
+ });
14443
+ const Entry = Union([Snapshot, Update]);
14444
+ const EntryJson = fromJsonString(toCodecJson(Entry));
14445
+ const decodeEntry$2 = decodeExit(EntryJson);
14446
+ const encodeEntry = encodeEffect$1(EntryJson);
14447
+ const fieldKeys = [
14448
+ "cwd",
14449
+ "model",
14450
+ "thoughtLevel",
14451
+ "fastMode",
14452
+ "environment"
14453
+ ];
14454
+ const applyUpdate = (record, update) => {
14455
+ const { _tag, messages, parent: _parent, id: _id, ...fields } = update;
14456
+ return new SessionRecord({
14457
+ ...record,
14458
+ ...fields,
14459
+ history: messages === void 0 ? record.history : fromMessages([...record.history.content, ...messages])
14460
+ });
14461
+ };
14462
+ const diff = (previous, next) => {
14463
+ const before = previous.history.content;
14464
+ const after = next.history.content;
14465
+ if (after.length < before.length || before.some((message, index) => after[index] !== message)) return;
14466
+ const changes = {};
14467
+ for (const key of fieldKeys) {
14468
+ if (previous[key] === next[key]) continue;
14469
+ if (next[key] === void 0) return void 0;
14470
+ changes[key] = next[key];
14471
+ }
14472
+ if (after.length > before.length) changes.messages = after.slice(before.length);
14473
+ return changes;
14474
+ };
14475
+ const storeError = (message) => (cause) => new AcpSessionStoreError({
14476
+ message,
14477
+ cause
14478
+ });
14479
+ const encodeLine = (entry) => encodeEntry(entry).pipe(map$5((json) => encoder.encode(`${json}\n`)), mapError(storeError("Failed to encode session")));
14480
+ const newline = 10;
14481
+ const encoder = new TextEncoder();
14482
+ const decoder = new TextDecoder();
14483
+ const layerFileSystem = (directory) => effect(AcpSessionStore, gen(function* () {
14484
+ const fs = yield* FileSystem;
14485
+ const path = yield* Path$3;
14486
+ yield* fs.makeDirectory(directory, { recursive: true });
14487
+ const semaphore = yield* make$48(1);
14488
+ const files = new Map();
14489
+ const fileFor = (sessionId) => path.join(directory, `${encodeURIComponent(sessionId)}.jsonl`);
14490
+ const read = fnUntraced(function* (sessionId) {
14491
+ const file = fileFor(sessionId);
14492
+ files.delete(sessionId);
14493
+ const result = yield* fs.readFile(file).pipe(asSome, catchReason("PlatformError", "NotFound", () => succeedNone), mapError(storeError(`Failed to read session ${sessionId}`)));
14494
+ if (isNone(result)) return none();
14495
+ const bytes = result.value;
14496
+ let record;
14497
+ let id = "";
14498
+ let start = 0;
14499
+ while (start < bytes.length) {
14500
+ const end = bytes.indexOf(newline, start);
14501
+ if (end === -1) break;
14502
+ const entry = decodeEntry$2(decoder.decode(bytes.subarray(start, end)));
14503
+ start = end + 1;
14504
+ if (entry._tag === "Failure") continue;
14505
+ const line = entry.value;
14506
+ if (line._tag === "Snapshot") {
14507
+ if (record !== void 0) continue;
14508
+ record = line.record;
14509
+ } else {
14510
+ if (record === void 0 || line.parent !== id) continue;
14511
+ record = applyUpdate(record, line);
14512
+ }
14513
+ id = line.id;
14514
+ }
14515
+ if (record === void 0) return yield* new AcpSessionStoreError({ message: `Session file for ${sessionId} does not start with a snapshot` });
14516
+ if (start < bytes.length) yield* logWarning("Ignoring an incomplete end of an ACP session file").pipe(annotateLogs({
14517
+ sessionId,
14518
+ file
14519
+ }));
14520
+ else files.set(sessionId, {
14521
+ record,
14522
+ id,
14523
+ size: bytes.length,
14524
+ tail: bytes.slice(-64)
14525
+ });
14526
+ return some(record);
14527
+ });
14528
+ const writeSnapshot = fnUntraced(function* (sessionId, record) {
14529
+ const file = fileFor(sessionId);
14530
+ const temporary = `${file}.${crypto.randomUUID()}.tmp`;
14531
+ const id = crypto.randomUUID();
14532
+ const bytes = yield* encodeLine(Snapshot.make({
14533
+ record,
14534
+ id
14535
+ }));
14536
+ files.delete(sessionId);
14537
+ yield* fs.writeFile(temporary, bytes).pipe(andThen(fs.rename(temporary, file)), onError(() => ignore(fs.remove(temporary, { force: true }))), mapError(storeError(`Failed to write session ${sessionId}`)));
14538
+ files.set(sessionId, {
14539
+ record,
14540
+ id,
14541
+ size: bytes.length,
14542
+ tail: bytes.slice(-64)
14543
+ });
14544
+ });
14545
+ const append = fnUntraced(function* (sessionId, known, bytes) {
14546
+ const handle = yield* fs.open(fileFor(sessionId), { flag: "a+" });
14547
+ const info = yield* handle.stat;
14548
+ if (Number(info.size) !== known.size) return false;
14549
+ const tail = new Uint8Array(known.tail.length);
14550
+ if ((yield* handle.read(tail, { position: BigInt(known.size - tail.length) })) !== tail.length || tail.some((byte, index) => byte !== known.tail[index])) return false;
14551
+ if (bytes.length === 0) return true;
14552
+ files.delete(sessionId);
14553
+ yield* handle.writeAll(bytes);
14554
+ return true;
14555
+ }, scoped, (effect, sessionId) => mapError(effect, storeError(`Failed to write session ${sessionId}`)));
14556
+ const write = fnUntraced(function* (sessionId, record) {
14557
+ const known = files.get(sessionId);
14558
+ const changes = known && diff(known.record, record);
14559
+ if (known !== void 0 && changes !== void 0) {
14560
+ if (Object.keys(changes).length === 0) {
14561
+ if (yield* append(sessionId, known, new Uint8Array())) {
14562
+ files.set(sessionId, {
14563
+ ...known,
14564
+ record
14565
+ });
14566
+ return;
14567
+ }
14568
+ } else {
14569
+ const id = crypto.randomUUID();
14570
+ const bytes = yield* encodeLine(Update.make({
14571
+ ...changes,
14572
+ parent: known.id,
14573
+ id
14574
+ }));
14575
+ if (yield* append(sessionId, known, bytes)) {
14576
+ files.set(sessionId, {
14577
+ record,
14578
+ id,
14579
+ size: known.size + bytes.length,
14580
+ tail: bytes.slice(-64)
14581
+ });
14582
+ return;
14583
+ }
14584
+ }
14585
+ }
14586
+ yield* writeSnapshot(sessionId, record);
14587
+ });
14588
+ return AcpSessionStore.of({
14589
+ get: (sessionId) => semaphore.withPermit(read(sessionId)),
14590
+ set: (sessionId, record) => semaphore.withPermit(write(sessionId, record))
14591
+ });
14592
+ }));
14593
+ // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/ai/Model.js
14594
+ const TypeId$4 = "~effect/ai/Model";
14595
+ var ProviderName = class extends Service()("effect/ai/Model/ProviderName") {};
14596
+ var ModelName = class extends Service()("effect/ai/Model/ModelName") {};
14597
+ const Proto = {
14598
+ [TypeId$4]: TypeId$4,
14599
+ ["~effect/Layer"]: {
14600
+ _ROut: identity,
14601
+ _E: identity,
14602
+ _RIn: identity
14603
+ },
14604
+ get captureRequirements() {
14605
+ const self = this;
14606
+ return contextWith((context) => succeed$1(provide$3(self, succeedContext(context))));
14607
+ },
14608
+ ...PipeInspectableProto,
14609
+ toJSON() {
14610
+ return {
14611
+ _id: "effect/ai/Model",
14612
+ provider: this.provider
14613
+ };
14614
+ }
14615
+ };
14616
+ const make$12 = (provider, modelName, layer) => Object.assign(Object.create(Proto), { provider }, merge$3(layer, succeedContext(ProviderName.context(provider).pipe(add(ModelName, modelName)))));
14412
14617
  // node_modules/.pnpm/zod@4.4.2/node_modules/zod/v4/classic/compat.js
14413
14618
  const ZodIssueCode = {
14414
14619
  invalid_type: "invalid_type",
@@ -18527,6 +18732,49 @@ const stripWrappingCodeFence = (script) => {
18527
18732
  const newLine = script.includes("\r\n") ? "\r\n" : "\n";
18528
18733
  return lines.slice(firstNonEmpty + 1, lastNonEmpty).join(newLine);
18529
18734
  };
18735
+ // src/ScriptFormatting.ts
18736
+ const parser = new TreeSitter();
18737
+ parser.setLanguage(JavaScript);
18738
+ const formatScript = (script) => {
18739
+ try {
18740
+ const tree = parser.parse(script, void 0, { bufferSize: Math.max(32768, script.length + 1) });
18741
+ if (tree.rootNode.hasError) return script;
18742
+ const breaks = new Set();
18743
+ const visit = (node) => {
18744
+ if ([
18745
+ "string",
18746
+ "template_string",
18747
+ "regex",
18748
+ "comment"
18749
+ ].includes(node.type)) return;
18750
+ if (node.type === "for_statement") {
18751
+ const body = node.childForFieldName("body");
18752
+ if (body) visit(body);
18753
+ return;
18754
+ }
18755
+ if (node.type === ";") breaks.add(node.endIndex);
18756
+ if (node.type === "statement_block") breaks.add(node.startIndex + 1);
18757
+ if (node.type === "program" || node.type === "statement_block") {
18758
+ for (const child of node.namedChildren) if (child.type !== "comment") breaks.add(child.endIndex);
18759
+ }
18760
+ for (const child of node.children) visit(child);
18761
+ };
18762
+ visit(tree.rootNode);
18763
+ let output = "";
18764
+ let start = 0;
18765
+ const newline = script.includes("\r\n") ? "\r\n" : "\n";
18766
+ for (const index of [...breaks].toSorted((a, b) => a - b)) {
18767
+ const rest = script.slice(index);
18768
+ if (/^[ \t]*(?:[\r\n]|$)/.test(rest)) continue;
18769
+ output += script.slice(start, index) + newline;
18770
+ start = index;
18771
+ while (script[start] === " " || script[start] === " ") start++;
18772
+ }
18773
+ return output + script.slice(start);
18774
+ } catch {
18775
+ return script;
18776
+ }
18777
+ };
18530
18778
  // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Random.js
18531
18779
  const Random = Random$1;
18532
18780
  const randomWith = (f) => withFiber((fiber) => succeed$1(f(fiber.getRef(Random))));
@@ -19506,7 +19754,7 @@ const make$9 = fnUntraced(function* (params) {
19506
19754
  const queue = yield* make$46();
19507
19755
  const deferredFinishParts = [];
19508
19756
  if (preResolvedStreamParts.length > 0) yield* offerAll(queue, preResolvedStreamParts);
19509
- const toolCallFibers = yield* make$15();
19757
+ const toolCallFibers = yield* make$16();
19510
19758
  const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$48(concurrency);
19511
19759
  const pendingToolCalls = new Map();
19512
19760
  const bufferedToolCalls = [];
@@ -19823,8 +20071,8 @@ const withParameterMode = (tool, mode) => {
19823
20071
  }
19824
20072
  return tools[mode] ??= tool.setParameters(mode === "opaque" ? Unknown : hasProviderParameters(tool) ? toEncoded$1(tool.parametersSchema) : toEncoded$1(toCodecJson(tool.parametersSchema)));
19825
20073
  };
19826
- const makeToolkitWithEncodedParameters = (toolkit) => make$16(...Object.values(toolkit.tools).map((tool) => withParameterMode(tool, "encoded")));
19827
- const makeToolkitWithOpaqueParameters = (toolkit) => make$16(...Object.values(toolkit.tools).map((tool) => withParameterMode(tool, "opaque")));
20074
+ const makeToolkitWithEncodedParameters = (toolkit) => make$17(...Object.values(toolkit.tools).map((tool) => withParameterMode(tool, "encoded")));
20075
+ const makeToolkitWithOpaqueParameters = (toolkit) => make$17(...Object.values(toolkit.tools).map((tool) => withParameterMode(tool, "opaque")));
19828
20076
  const isToolCallValidationDeferred = (options) => options.disableToolCallResolution === true && options.toolCallValidation === "deferred";
19829
20077
  const UndeclaredToolCallPart = ToolCallPart("", Unknown).mapFields((fields) => ({
19830
20078
  ...fields,
@@ -21050,7 +21298,7 @@ ${prompt}`,
21050
21298
  });
21051
21299
  maybeSend({
21052
21300
  agentId,
21053
- part: new ScriptDelta({ delta: script })
21301
+ part: new ScriptDelta({ delta: formatScript(script) })
21054
21302
  });
21055
21303
  return executeScript(script);
21056
21304
  }), ensuring(close(runScope, void_$1)), ensuring(sync(() => {
@@ -21214,7 +21462,7 @@ And then you will receive back the console output:
21214
21462
  files: [ 'package.json' ]
21215
21463
  package.json: { name: 'my-project', version: '1.0.0' }
21216
21464
  \`\`\``;
21217
- const ReadSkillTools = make$16(make$17("readSkill", {
21465
+ const ReadSkillTools = make$17(make$18("readSkill", {
21218
21466
  description: "Read the instructions of a skill listed under Skills, by its name.",
21219
21467
  parameters: String$7.annotate({ identifier: "name" }),
21220
21468
  success: String$7,
@@ -21249,7 +21497,7 @@ const makeLoopTools = fnUntraced(function* (options) {
21249
21497
  });
21250
21498
  const errorMessage = (error) => typeof error === "string" ? error : error instanceof Error ? error.message : JSON.stringify(error) ?? String(error);
21251
21499
  var ScriptExecutor = class extends Service()("clanka/Agent/ScriptExecutor") {};
21252
- const SingleTools = make$16(make$17("execute", {
21500
+ const SingleTools = make$17(make$18("execute", {
21253
21501
  description: "Execute javascript code and return the output",
21254
21502
  parameters: Struct({ script: String$7 }),
21255
21503
  success: String$7,
@@ -21294,23 +21542,6 @@ const responseToSummary = (response) => {
21294
21542
  return parts.join("\n\n");
21295
21543
  };
21296
21544
  // src/Acp.ts
21297
- const ThoughtLevel = Literals$2([
21298
- "none",
21299
- "minimal",
21300
- "low",
21301
- "medium",
21302
- "high",
21303
- "xhigh",
21304
- "max"
21305
- ]);
21306
- var SessionRecord = class extends Class$1("clanka/Acp/SessionRecord")({
21307
- cwd: String$7,
21308
- model: String$7,
21309
- thoughtLevel: ThoughtLevel,
21310
- fastMode: optionalKey(Boolean$4),
21311
- history: Prompt,
21312
- environment: optionalKey(ExecutionEnvironment)
21313
- }) {};
21314
21545
  var RpcError = class extends TaggedError$1()("AcpRpcError", {
21315
21546
  code: Number$2,
21316
21547
  message: String$7
@@ -21504,13 +21735,12 @@ const historyUpdates = (history) => {
21504
21735
  return updates;
21505
21736
  };
21506
21737
  const make$7 = fnUntraced(function* (options) {
21507
- const kvs = yield* KeyValueStore;
21738
+ const store = yield* AcpSessionStore;
21508
21739
  const { contextWindow } = yield* CompactionConfig;
21509
21740
  const size = Number.isFinite(contextWindow) ? Math.max(0, Math.round(contextWindow)) : 0;
21510
21741
  const http = yield* serviceOption(HttpClient);
21511
21742
  const fs = yield* serviceOption(FileSystem);
21512
21743
  const path = yield* serviceOption(Path$3);
21513
- const store = toSchemaStore(prefix(kvs, "session-"), SessionRecord);
21514
21744
  const scope$3 = yield* scope;
21515
21745
  const sessions = new Map();
21516
21746
  yield* addFinalizer$1(() => {
@@ -21571,14 +21801,24 @@ const make$7 = fnUntraced(function* (options) {
21571
21801
  configOptions: configOptions(session)
21572
21802
  };
21573
21803
  });
21574
- const persist = (session) => store.set(session.id, new SessionRecord({
21575
- cwd: session.cwd,
21576
- model: session.model,
21577
- thoughtLevel: session.thoughtLevel,
21578
- fastMode: session.fastMode,
21579
- history: session.agent.history.current,
21580
- environment: session.agent.environment.current
21581
- })).pipe(catch_((error) => logWarning("Failed to persist session", error)));
21804
+ const persist = (session) => {
21805
+ const history = session.agent.history.current;
21806
+ const environment = session.agent.environment.current;
21807
+ return store.set(session.id, new SessionRecord({
21808
+ cwd: session.cwd,
21809
+ model: session.model,
21810
+ thoughtLevel: session.thoughtLevel,
21811
+ fastMode: session.fastMode,
21812
+ history,
21813
+ environment
21814
+ })).pipe(tap(() => sync(() => {
21815
+ session.stored = {
21816
+ history,
21817
+ environment
21818
+ };
21819
+ })), catch_((error) => logWarning("Failed to persist session", error)));
21820
+ };
21821
+ const persistCommitted = (session) => suspend(() => session.stored?.history === session.agent.history.current && session.stored.environment === session.agent.environment.current ? void_ : persist(session));
21582
21822
  const openSession = fnUntraced(function* (id, record, mcpServers) {
21583
21823
  const sessionScope = yield* fork(scope$3);
21584
21824
  let makeAgent = options.makeAgent(record.cwd);
@@ -21605,7 +21845,8 @@ const make$7 = fnUntraced(function* (options) {
21605
21845
  toolCalls: 0,
21606
21846
  announcedSubagents: new Set(),
21607
21847
  scope: sessionScope,
21608
- mcpFailures
21848
+ mcpFailures,
21849
+ stored: void 0
21609
21850
  };
21610
21851
  sessions.set(id, session);
21611
21852
  return session;
@@ -21798,6 +22039,8 @@ const make$7 = fnUntraced(function* (options) {
21798
22039
  }]
21799
22040
  });
21800
22041
  }
22042
+ case "HistoryAppended":
22043
+ case "HistoryReplaced": return persistCommitted(session);
21801
22044
  default: return void_;
21802
22045
  }
21803
22046
  };
@@ -21944,7 +22187,7 @@ const make$7 = fnUntraced(function* (options) {
21944
22187
  session.running = yield* runPrompt(session, input).pipe(provide$1(model), forkChild);
21945
22188
  const exit$1 = yield* exit(join$3(session.running));
21946
22189
  session.running = void 0;
21947
- yield* persist(session);
22190
+ yield* persistCommitted(session);
21948
22191
  if (isSuccess(exit$1)) return { stopReason: "end_turn" };
21949
22192
  if (hasInterruptsOnly(exit$1.cause)) return { stopReason: "cancelled" };
21950
22193
  return yield* toRpcError(exit$1.cause);
@@ -26123,7 +26366,7 @@ const mapProviderResults = (inputLength, results) => {
26123
26366
  };
26124
26367
  // node_modules/.pnpm/@effect+ai-openai@4.1.3_effect@4.1.3/node_modules/@effect/ai-openai/dist/OpenAiEmbeddingModel.js
26125
26368
  var Config$2 = class extends Service()("@effect/ai-openai/OpenAiEmbeddingModel/Config") {};
26126
- const model$5 = (model, options) => make$18("openai", model, merge$2(layer$3({
26369
+ const model$5 = (model, options) => make$12("openai", model, merge$3(layer$3({
26127
26370
  model,
26128
26371
  config: {
26129
26372
  ...options.config,
@@ -28321,7 +28564,7 @@ const transformToolCallParams$1 = fnUntraced(function* (options, toolName, toolP
28321
28564
  return yield* decodeEffect(codec)(toolParams).pipe(flatMap$1((decoded) => encodeUnknownEffect(toCodecJson(tool.parametersSchema))(decoded)), orElseSucceed(() => toolParams));
28322
28565
  });
28323
28566
  // package.json
28324
- var version$1 = "0.25.2";
28567
+ var version$1 = "0.26.0";
28325
28568
  // src/ClaudeAgent.ts
28326
28569
  const minimumClaudeCodeVersion = "2.1.248";
28327
28570
  const serverName = "clanka";
@@ -28995,7 +29238,7 @@ const toParts = (parts) => {
28995
29238
  }
28996
29239
  return result;
28997
29240
  };
28998
- const model$4 = (model, options) => make$18("claude", model, merge$2(layerLanguageModel(model, options), AgentModelConfig.layer({
29241
+ const model$4 = (model, options) => make$12("claude", model, merge$3(layerLanguageModel(model, options), AgentModelConfig.layer({
28999
29242
  supportsImages: options?.supportsImages,
29000
29243
  cutStreamOnSteering: false
29001
29244
  })));
@@ -29234,8 +29477,8 @@ var CodexAuth = class CodexAuth extends Service()("clanka/CodexAuth") {
29234
29477
  };
29235
29478
  // src/Codex.ts
29236
29479
  const layerClient$3 = layer$4({ apiUrl: "https://chatgpt.com/backend-api/codex" }).pipe(provide$3(CodexAuth.layerClient));
29237
- const model$3 = (model, options) => make$18("openai", model, layerModel(model, options));
29238
- const modelWebSocket$1 = (model, options) => make$18("openai", model, layerModel(model, options).pipe(merge$2(fresh(layerWebSocketMode))));
29480
+ const model$3 = (model, options) => make$12("openai", model, layerModel(model, options));
29481
+ const modelWebSocket$1 = (model, options) => make$12("openai", model, layerModel(model, options).pipe(merge$3(fresh(layerWebSocketMode))));
29239
29482
  const layerModel = (model, options) => suspend$2(() => layer$2({
29240
29483
  model,
29241
29484
  config: {
@@ -29248,7 +29491,7 @@ const layerModel = (model, options) => suspend$2(() => layer$2({
29248
29491
  ...options?.reasoning
29249
29492
  }
29250
29493
  }
29251
- })).pipe(merge$2(AgentModelConfig.layer({
29494
+ })).pipe(merge$3(AgentModelConfig.layer({
29252
29495
  ...pick(options ?? {}, AgentModelConfig.optionKeys),
29253
29496
  systemPromptTransform: (system, effect) => withConfigOverride$1(effect, { instructions: system })
29254
29497
  })));
@@ -30571,7 +30814,7 @@ var GithubCopilotAuth = class GithubCopilotAuth extends Service()("clanka/Github
30571
30814
  };
30572
30815
  // src/Copilot.ts
30573
30816
  const layerClient$2 = layer$1({ apiUrl: API_URL }).pipe(provide$3(GithubCopilotAuth.layerClient));
30574
- const model$2 = (model, options) => make$18("openai", model, mergeAll(layer({
30817
+ const model$2 = (model, options) => make$12("openai", model, mergeAll(layer({
30575
30818
  model,
30576
30819
  config: omit(options ?? {}, options?.reasoning === null ? ["reasoning", ...AgentModelConfig.optionKeys] : AgentModelConfig.optionKeys)
30577
30820
  }), AgentModelConfig.layer(pick(options ?? {}, AgentModelConfig.optionKeys)), succeed$4(SummarizerTransform, (effect) => withConfigOverride(effect, { max_output_tokens: summarizerMaxOutputTokens }))));
@@ -30708,7 +30951,7 @@ var ModelsRepo = class ModelsRepo extends Service()("clanka/ModelsRepo") {
30708
30951
  };
30709
30952
  // src/OpenAiCompat.ts
30710
30953
  const layerClient$1 = (options) => layer$1(options);
30711
- const model$1 = (model, options) => make$18("openai-compat", model, mergeAll(layer({
30954
+ const model$1 = (model, options) => make$12("openai-compat", model, mergeAll(layer({
30712
30955
  model,
30713
30956
  config: {
30714
30957
  ...omit(options ?? {}, ["reasoning", ...AgentModelConfig.optionKeys]),
@@ -30876,7 +31119,7 @@ var XaiAuth = class XaiAuth extends Service()("clanka/XaiAuth") {
30876
31119
  };
30877
31120
  // src/Xai.ts
30878
31121
  const layerClient = layer$4({ apiUrl: "https://api.x.ai/v1" }).pipe(provide$3(XaiAuth.layerClient));
30879
- const modelWebSocket = (model, options) => make$18("xai", model, mergeAll(layer$2({
31122
+ const modelWebSocket = (model, options) => make$12("xai", model, mergeAll(layer$2({
30880
31123
  model,
30881
31124
  config: {
30882
31125
  ...omit(options ?? {}, ["reasoning", ...AgentModelConfig.optionKeys]),
@@ -31081,10 +31324,16 @@ const fetch$1 = Boolean("fetch").pipe(withDescription$1("Expose the global Fetch
31081
31324
  const mcp = Boolean("mcp").pipe(withDescription$1("Start the MCP servers from ~/.config/clanka/mcp.json, ./.mcp.json and --mcp-config. Disable with --no-mcp or CLANKA_MCP=false."), withFallbackConfig(Boolean$3("CLANKA_MCP").pipe(withDefault$2(true))));
31082
31325
  const mcpConfig = String$1("mcp-config").pipe(withDescription$1("An MCP config file in the { \"mcpServers\": { ... } } format. Repeatable; a later file wins."), atLeast(0));
31083
31326
  const mcpSummary = (status) => `MCP: ${Object.entries(status).map(([name, server]) => server._tag === "Connected" ? `${name} (${server.tools.length} tools)` : `${name} failed: ${server.error.split("\n")[0]}`).join(", ")}`;
31084
- const Kvs = unwrap$4(gen(function* () {
31327
+ const configDirectory = gen(function* () {
31085
31328
  const path = yield* Path$3;
31086
31329
  const configHome = yield* NonEmptyString("XDG_CONFIG_HOME").pipe(orElse(() => NonEmptyString("HOME").pipe(map$3((home) => path.join(home, ".config")))));
31087
- return layerFileSystem(path.join(configHome, "clanka"));
31330
+ return path.join(configHome, "clanka");
31331
+ });
31332
+ const Kvs = unwrap$4(map$5(configDirectory, layerFileSystem$1)).pipe(provide$3(layer$9));
31333
+ const AcpSessions = unwrap$4(gen(function* () {
31334
+ const path = yield* Path$3;
31335
+ const directory = yield* configDirectory;
31336
+ return layerFileSystem(path.join(directory, "sessions"));
31088
31337
  })).pipe(provide$3(layer$9));
31089
31338
  const Search = (directory) => unwrap$4(gen(function* () {
31090
31339
  const apiKey = yield* Redacted$3("OPENAI_API_KEY").pipe(option);
@@ -31093,7 +31342,7 @@ const Search = (directory) => unwrap$4(gen(function* () {
31093
31342
  return empty$10;
31094
31343
  }
31095
31344
  const path = yield* Path$3;
31096
- return (yield* promise(() => import("./SemanticSearch-DMzIsoZb.mjs"))).layer({
31345
+ return (yield* promise(() => import("./SemanticSearch-C3a7LAQr.mjs"))).layer({
31097
31346
  directory: process.cwd(),
31098
31347
  database: path.join(directory, "search.sqlite")
31099
31348
  }).pipe(provide$3(model$5("text-embedding-3-small", { dimensions: 1536 })), provide$3(layer$4({ apiKey: apiKey.value })));
@@ -31141,7 +31390,7 @@ const acp = make$26("acp", {
31141
31390
  auxiliary: auxiliaryModels(flags)
31142
31391
  })
31143
31392
  });
31144
- })), provide((flags) => mergeAll(ConversationMode.layer(false), succeed$4(LogToStderr, true), layerLog, compactionConfig(flags), openAiCompatModels(flags))));
31393
+ })), provide((flags) => mergeAll(AcpSessions, ConversationMode.layer(false), succeed$4(LogToStderr, true), layerLog, compactionConfig(flags), openAiCompatModels(flags))));
31145
31394
  make$26("clanka", {
31146
31395
  provider,
31147
31396
  fetch: fetch$1,
@@ -31164,7 +31413,7 @@ make$26("clanka", {
31164
31413
  files: mcpConfig,
31165
31414
  enabled: mcp
31166
31415
  });
31167
- const OutputFormatter = yield* promise(() => import("./OutputFormatter-ByMjyBhe.mjs"));
31416
+ const OutputFormatter = yield* promise(() => import("./OutputFormatter-DhhP2i-7.mjs"));
31168
31417
  const { model, effort } = yield* match$2(modelRaw, {
31169
31418
  onSome: (selected) => succeed$1(parseModel(selected)),
31170
31419
  onNone: () => selectModel(provider)