clanka 0.8.4 → 0.8.5

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 (30) hide show
  1. package/dist/AgentSkills.test.js +1 -0
  2. package/dist/AgentSkills.test.js.map +1 -1
  3. package/dist/AgentTools.d.ts.map +1 -1
  4. package/dist/AgentTools.js +2 -1
  5. package/dist/AgentTools.js.map +1 -1
  6. package/dist/Compaction.test.js +1 -0
  7. package/dist/Compaction.test.js.map +1 -1
  8. package/dist/bin/{Effect-BmOuzEIp.mjs → Effect-BEUn4I5E.mjs} +145 -122
  9. package/dist/bin/Effect-BEUn4I5E.mjs.map +1 -0
  10. package/dist/bin/{McpClient-CLpFJSre.mjs → McpClient-C0FVuDj2.mjs} +218 -62
  11. package/dist/bin/McpClient-C0FVuDj2.mjs.map +1 -0
  12. package/dist/bin/{OutputFormatter-C_gdNUl1.mjs → OutputFormatter-DffD5oxX.mjs} +8 -8
  13. package/dist/bin/OutputFormatter-DffD5oxX.mjs.map +1 -0
  14. package/dist/bin/{Schema-C7W9nQug.mjs → Schema-CjUGw2Xh.mjs} +39 -38
  15. package/dist/bin/Schema-CjUGw2Xh.mjs.map +1 -0
  16. package/dist/bin/{SemanticSearch-cqSnq90g.mjs → SemanticSearch-CFB73IPb.mjs} +74 -62
  17. package/dist/bin/SemanticSearch-CFB73IPb.mjs.map +1 -0
  18. package/dist/bin/{Stream-BI6Fx9yq.mjs → Stream-Cu6P7ZHo.mjs} +23 -23
  19. package/dist/bin/{Stream-BI6Fx9yq.mjs.map → Stream-Cu6P7ZHo.mjs.map} +1 -1
  20. package/dist/bin/cli.mjs +267 -188
  21. package/dist/bin/cli.mjs.map +1 -1
  22. package/package.json +14 -14
  23. package/src/AgentSkills.test.ts +1 -0
  24. package/src/AgentTools.ts +2 -1
  25. package/src/Compaction.test.ts +1 -0
  26. package/dist/bin/Effect-BmOuzEIp.mjs.map +0 -1
  27. package/dist/bin/McpClient-CLpFJSre.mjs.map +0 -1
  28. package/dist/bin/OutputFormatter-C_gdNUl1.mjs.map +0 -1
  29. package/dist/bin/Schema-C7W9nQug.mjs.map +0 -1
  30. package/dist/bin/SemanticSearch-cqSnq90g.mjs.map +0 -1
@@ -1,17 +1,17 @@
1
- import { $ as isEffect, $a as match, $o as hasProperty, $t as uninterruptibleMask, As as pipe, B as fnUntraced, Ba as flatten, Bi as isArrayNonEmpty, Br as succeed$2, C as catch_, Ca as Reference, D as delay, Da as get$1, Di as void_$2, Do as withFiber$1, Dr as doneUnsafe, Ds as identity, E as contextWith, Ei as updateContext, Er as done, Es as flow, Et as provideService, F as filterOrFail, Fr as failCause, Go as symbol, Gt as tap, H as forEach, Ha as fromNullishOr, Hr as ClockRef, I as flatMap, It as scope, Ja as isNone, Jo as hash, Jr as contextWith$1, K as forkScoped, Ki as map$2, Kt as tapCause, La as filter, Li as flatMapNullishOr, Ln as filterInterruptors, Lt as scoped, M as fail, Ma as make$9, Mr as makeUnsafe$2, Mt as runFork, Ni as empty, Ns as pipeArguments, Nt as runForkWith, O as die, Oa as getOption, Pa as merge, Pr as fail$1, Qa as map$1, Qo as symbol$1, Qr as exitHasInterrupts, Ri as fromIterable, Rr as isFailure, S as catchTags, Ss as constUndefined, St as orElseSucceed, T as context, Ta as add, Ts as dual, Tt as provideContext, U as forever, Uo as byReferenceUnsafe, Ut as suspend, Vn as hasInterruptsOnly, Vr as void_$3, Vt as succeed, Wo as equals, Wt as sync, X as ignore, Xa as isSome, Xi as sort, Xt as try_, Y as gen, Yt as tryPromise, Z as interrupt, Zr as endSpan, _o as Prototype, _r as close, _t as onExit, a as andThen, at as makeSpanScoped, ba as toMillis, bo as PipeInspectableProto, c as as, da as infinity, eo as none, er as effect, et as logDebug, fn as Class$1, ft as matchCauseEager, ga as minutes, gi as makeSpanUnsafe, gt as onError, h as catchDefect, ha as millis, hr as addFinalizer, i as all, ja as getUnsafe, ka as getOrUndefined, ki as ParentSpan, kn as NoSuchElementError, ko as assignProperty, kr as into, kt as request$1, ln as withSpan, lr as provide$1, lt as mapError, m as catchCause, ma as isZero, mr as Scope, n as acquireUseRelease, nn as useSpan, nr as effectDiscard, o as annotateCurrentSpan, on as withFiber, os as isNotNull, ot as map, pa as isFinite, po as make$10, pt as matchCauseEffect, ri as fiberInterrupt, rn as void_$1, ro as some, rt as logInfo, s as annotateLogs, si as fiberJoin, sn as withLogSpan, so as Number$1, t as acquireRelease, tr as effectContext, u as asVoid, ua as fromInputUnsafe, ui as forkUnsafe, ur as provideMerge, v as catchIf, vi as onExit$1, vt as onExitPrimitive, wa as Service, wr as TracerTimingEnabled, x as catchTag, xi as succeed$1, xr as provide, xt as orDie, y as catchNoSuchElement, ya as seconds, yr as make$8, z as fn, zr as isSuccess, zt as serviceOption } from "./Effect-BmOuzEIp.mjs";
2
- import { $ as tap$1, B as provideService$1, Ft as join$1, H as runCollect, It as runIn, Pt as interruptAs, T as fromQueue, U as runDrain, bt as offerUnsafe, c as die$1, ct as make$12, g as flatMap$1, gt as make$11, ht as failCauseUnsafe, lt as makeUnsafe$3, tt as unwrap, v as fromArray, y as fromArrayEffect } from "./Stream-BI6Fx9yq.mjs";
3
- import { A as OptionFromNullOr, Cn as transform, D as NullOr, Dt as mutable, F as String$1, Ft as toType, I as Struct$2, In as formatIsoDate, It as withConstructorDefault, J as Union$2, Jn as TaggedError$1, O as Number$2, Ot as optional, Rn as now, S as Natural, St as isSchema, Wn as Clock, Z as brand, _n as transform$1, bn as dateTimeUtcFromInput, c as DateTimeUtcFromDate, d as Defect, i as BooleanFromBit, k as Option, kt as optionalKey, l as DateTimeUtcFromMillis, n as ArraySchema, nt as decodeTo, o as Class$2, ot as encodeEffect, r as Boolean, rt as decodeUnknownEffect, s as DateTimeUtc, u as DateTimeUtcFromString, ut as instanceOf, xn as map$3, yn as transformOptional, z as TaggedError, zn as removeTime, zt as evolve } from "./Schema-C7W9nQug.mjs";
4
- import { C as set, D as toPredicate, E as has, S as remove, T as compose, _ as empty$1, a as makeGrouped, b as isEmpty, c as SemanticSearch, d as map$4, f as make$14, g as FileSystem, h as Path, i as batchN, l as maybeRemoveFile, m as Console, n as EmbeddingModel, o as setDelay, p as ChildProcessSpawner, r as EmbeddingRequest, s as withSpan$1, t as Dimensions, u as maybeUpdateFile, v as forEach$1, w as size, x as make$13, y as get$2 } from "./cli.mjs";
1
+ import { $r as exitHasInterrupts, Aa as getOption, An as NoSuchElementError, Ar as into, At as request$1, B as fn, Bi as fromIterable, Br as isSuccess, Bt as serviceOption, C as catchTags, Ci as succeed$1, Ct as orElseSucceed, D as contextWith, Da as add, Dr as done, Ds as dual, Dt as provideService, E as context, Ea as Service, Et as provideContext, Fi as empty, Fr as fail$1, Fs as pipeArguments, Go as byReferenceUnsafe, Gt as sync, Ha as flatten, Hi as isArrayNonEmpty, Hn as hasInterruptsOnly, Hr as void_$3, Ht as succeed, I as filterOrFail, Ia as merge, Ir as failCause, Ji as map$2, Ko as equals, Kt as tap, L as flatMap, Lt as scope, Ms as pipe, Mt as retry, N as fail, Na as getUnsafe, Nr as makeUnsafe$2, Nt as runFork, O as delay, Oi as updateContext, Or as doneUnsafe, Os as flow, Pa as make$8, Pt as runForkWith, Q as interrupt, Qa as isSome, Qi as sort, Qr as endSpan, Rn as filterInterruptors, Rt as scoped, S as catchTag, Sa as toMillis, So as PipeInspectableProto, Sr as provide, St as orDie, Ta as Reference, Tr as TracerTimingEnabled, U as forEach, Ur as ClockRef, V as fnUntraced, Vr as succeed$2, W as forever, Wa as fromNullishOr, Wt as suspend, X as gen, Xa as isNone, Xo as hash, Xt as tryPromise, Yr as contextWith$1, Z as ignore, Zt as try_, _a as millis, _i as makeSpanUnsafe, _t as onError, a as andThen, ao as some, b as catchNoSuchElement, bi as onExit$1, bn as spaced, br as make$7, c as as, ci as fiberJoin, cn as withLogSpan, cs as isNotNull, di as forkUnsafe, dr as provideMerge, en as uninterruptibleMask, eo as map$1, es as symbol$1, et as isEffect, fa as fromInputUnsafe, g as catchDefect, ga as isZero, gr as addFinalizer, ha as isFinite, ho as make$9, hr as Scope, i as all, ii as fiberInterrupt, in as void_$1, it as logInfo, ja as getOrUndefined, ji as ParentSpan, jo as assignProperty, k as die, ka as get$1, ki as void_$2, ko as withFiber$1, ks as identity, lo as Number$1, m as catchCause, mt as matchCauseEffect, n as acquireUseRelease, no as none, nr as effectContext, o as annotateCurrentSpan, ot as makeSpanScoped, pa as infinity, pn as Class$1, pt as matchCauseEager, q as forkScoped, qo as symbol, qt as tapCause, rn as useSpan, rr as effectDiscard, s as annotateLogs, sn as withFiber, st as map, t as acquireRelease, to as match, tr as effect, ts as hasProperty, tt as logDebug, u as asVoid, un as withSpan, ur as provide$1, ut as mapError, va as minutes, vr as close, vt as onExit, w as catch_, wa as zero, ws as constUndefined, xa as seconds, y as catchIf, yo as Prototype, yt as onExitPrimitive, za as filter, zi as flatMapNullishOr, zr as isFailure } from "./Effect-BEUn4I5E.mjs";
2
+ import { $ as tap$1, B as provideService$1, Ft as interruptAs, H as runCollect, It as join$1, Lt as runIn, T as fromQueue, U as runDrain, bt as offerUnsafe, c as die$1, ct as make$11, g as flatMap$1, gt as make$10, ht as failCauseUnsafe, lt as makeUnsafe$3, tt as unwrap, v as fromArray, y as fromArrayEffect } from "./Stream-Cu6P7ZHo.mjs";
3
+ import { A as OptionFromNullOr, Cn as transform, D as NullOr, Dt as mutable, F as String$1, Ft as toType, Gn as monotonicTimeNanos, I as Struct$2, In as formatIsoDate, It as withConstructorDefault, J as Union$2, O as Number$2, Ot as optional, Rn as now, S as Natural, St as isSchema, Wn as Clock, Yn as TaggedError$1, Z as brand, _n as transform$1, bn as dateTimeUtcFromInput, c as DateTimeUtcFromDate, d as Defect, i as BooleanFromBit, k as Option, kt as optionalKey, l as DateTimeUtcFromMillis, n as ArraySchema, nt as decodeTo, o as Class$2, ot as encodeEffect, r as Boolean, rt as decodeUnknownEffect, s as DateTimeUtc, u as DateTimeUtcFromString, ut as instanceOf, xn as map$3, yn as transformOptional, z as TaggedError, zn as removeTime, zt as evolve } from "./Schema-CjUGw2Xh.mjs";
4
+ import { C as set, D as toPredicate, E as has, S as remove, T as compose, _ as empty$1, a as makeGrouped, b as isEmpty, c as SemanticSearch, d as map$4, f as make$13, g as FileSystem, h as Path, i as batchN, l as maybeRemoveFile, m as Console, n as EmbeddingModel, o as setDelay, p as ChildProcessSpawner, r as EmbeddingRequest, s as withSpan$1, t as Dimensions, u as maybeUpdateFile, v as forEach$1, w as size, x as make$12, y as get$2 } from "./cli.mjs";
5
5
  import { createHash } from "node:crypto";
6
6
  import { DatabaseSync, backup } from "node:sqlite";
7
7
  import TreeSitter from "tree-sitter";
8
8
  import TreeSitterJavaScript from "tree-sitter-javascript";
9
9
  import TreeSitterTypeScript from "tree-sitter-typescript";
10
10
  import { getLoadablePath } from "sqlite-vec";
11
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/reactivity/Reactivity.js
11
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/reactivity/Reactivity.js
12
12
  const TypeId$6 = "~effect/reactivity/Reactivity";
13
13
  const Reactivity = Service("effect/reactivity/Reactivity");
14
- const make$7 = sync(() => {
14
+ const make$6 = sync(() => {
15
15
  const handlers = new Map();
16
16
  const invalidateUnsafe = (keys) => {
17
17
  keysToHashes(keys, (hash) => {
@@ -52,7 +52,7 @@ const make$7 = sync(() => {
52
52
  const query = (keys, effect) => gen(function* () {
53
53
  const services = yield* context();
54
54
  const scope = get$1(services, Scope);
55
- const results = yield* make$11();
55
+ const results = yield* make$10();
56
56
  const runFork = flow(runForkWith(services), runIn(scope));
57
57
  let running = false;
58
58
  let pending = false;
@@ -100,7 +100,7 @@ const make$7 = sync(() => {
100
100
  });
101
101
  });
102
102
  var PendingInvalidation = class extends Service()("effect/reactivity/Reactivity/PendingInvalidation") {};
103
- const layer$5 = effect(Reactivity)(make$7);
103
+ const layer$5 = effect(Reactivity)(make$6);
104
104
  function stringOrHash(u) {
105
105
  switch (typeof u) {
106
106
  case "string":
@@ -122,7 +122,7 @@ const keysToHashes = (keys, f) => {
122
122
  }
123
123
  };
124
124
  //#endregion
125
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlError.js
125
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/sql/SqlError.js
126
126
  const TypeId$5 = "~effect/sql/SqlError";
127
127
  const ReasonTypeId = "~effect/sql/SqlError/Reason";
128
128
  const ReasonFields = {
@@ -296,7 +296,7 @@ var ResultLengthMismatch = class extends TaggedError("effect/sql/ResultLengthMis
296
296
  }
297
297
  };
298
298
  //#endregion
299
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/Statement.js
299
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/sql/Statement.js
300
300
  const FragmentTypeId = "~effect/sql/Statement/Fragment";
301
301
  const fragment = (segments) => ({
302
302
  [FragmentTypeId]: FragmentTypeId,
@@ -352,7 +352,7 @@ const recordUpdateHelperSingle = (value, omit) => Object.assign(Object.create(Re
352
352
  omit,
353
353
  returningIdentifier: void 0
354
354
  });
355
- const make$6 = (acquirer, compiler, spanAttributes, transformRows, borrower) => {
355
+ const make$5 = (acquirer, compiler, spanAttributes, transformRows, borrower) => {
356
356
  const cache = transformRows === void 0 ? constructorCache.noTransforms : constructorCache.transforms;
357
357
  if (cache.has(acquirer)) return cache.get(acquirer);
358
358
  const self = Object.assign(function sql(strings, ...args) {
@@ -731,7 +731,7 @@ const StatementProto = {
731
731
  const withStatement = (self, span, f) => withFiber((fiber) => {
732
732
  const transform = fiber.getRef(CurrentTransformer);
733
733
  if (transform === void 0) return f(self, fiber);
734
- return flatMap(transform(self, make$6(self.acquirer, self.compiler, self.spanAttributes, self.transformRows, self.borrower), fiber, span), (statement) => f(statement, fiber));
734
+ return flatMap(transform(self, make$5(self.acquirer, self.compiler, self.spanAttributes, self.transformRows, self.borrower), fiber, span), (statement) => f(statement, fiber));
735
735
  });
736
736
  const isSegment = (u) => {
737
737
  if (!hasProperty(u, "_tag")) return false;
@@ -786,12 +786,12 @@ function in_() {
786
786
  }
787
787
  const neverFragment = fragment([literal("1=0")]);
788
788
  //#endregion
789
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlClient.js
789
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/sql/SqlClient.js
790
790
  const TypeId$4 = "~effect/sql/SqlClient";
791
791
  const SqlClient = Service("effect/sql/SqlClient");
792
792
  let clientIdCounter = 0;
793
793
  let transactionSemaphoreIdCounter = 0;
794
- const make$5 = fnUntraced(function* (options) {
794
+ const make$4 = fnUntraced(function* (options) {
795
795
  const transactionService = options.transactionService ?? TransactionConnection(clientIdCounter++);
796
796
  const getConnection = flatMap(serviceOption(transactionService), match({
797
797
  onNone: () => options.acquirer,
@@ -808,7 +808,7 @@ const make$5 = fnUntraced(function* (options) {
808
808
  const withTransaction = makeWithTransaction({
809
809
  transactionService,
810
810
  spanAttributes: options.spanAttributes,
811
- acquireConnection: flatMap(make$8(), (scope) => provide(transactionAcquirer, scope).pipe(onError((cause) => close(scope, failCause(cause))), map((conn) => [scope, conn]))),
811
+ acquireConnection: flatMap(make$7(), (scope) => provide(transactionAcquirer, scope).pipe(onError((cause) => close(scope, failCause(cause))), map((conn) => [scope, conn]))),
812
812
  begin: (conn) => control(conn, beginTransaction),
813
813
  savepoint: (conn, id) => control(conn, savepoint(`effect_sql_${id}`)),
814
814
  releaseSavepoint: releaseSavepoint ? (conn, id) => control(conn, releaseSavepoint(`effect_sql_${id}`)) : void 0,
@@ -822,7 +822,7 @@ const make$5 = fnUntraced(function* (options) {
822
822
  onNone: () => options.borrower(f),
823
823
  onSome: ([conn]) => f(conn)
824
824
  }));
825
- const client = Object.assign(make$6(getConnection, options.compiler, options.spanAttributes, options.transformRows, borrower), {
825
+ const client = Object.assign(make$5(getConnection, options.compiler, options.spanAttributes, options.transformRows, borrower), {
826
826
  [TypeId$4]: TypeId$4,
827
827
  safe: void 0,
828
828
  withTransaction,
@@ -830,7 +830,7 @@ const make$5 = fnUntraced(function* (options) {
830
830
  reserve: transactionAcquirer,
831
831
  withoutTransforms() {
832
832
  if (options.transformRows === void 0) return this;
833
- const statement = make$6(getConnection, options.compiler.withoutTransform, options.spanAttributes, void 0, borrower);
833
+ const statement = make$5(getConnection, options.compiler.withoutTransform, options.spanAttributes, void 0, borrower);
834
834
  const client = Object.assign(statement, {
835
835
  ...this,
836
836
  ...statement
@@ -912,20 +912,16 @@ const makeWithTransaction = (options) => {
912
912
  const TransactionConnection = (clientId) => Service(`effect/sql/SqlClient/TransactionConnection/${clientId}`);
913
913
  const SafeIntegers = Reference("effect/sql/SqlClient/SafeIntegers", { defaultValue: () => false });
914
914
  //#endregion
915
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/Cache.js
915
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Cache.js
916
916
  const TypeId$3 = "~effect/Cache";
917
917
  const makeWith = (lookup, options) => contextWith$1((context) => {
918
918
  const self = Object.create(Proto$1);
919
919
  self.lookup = (key) => updateContext(lookup(key), (input) => merge(context, input));
920
- self.map = make$13();
920
+ self.map = make$12();
921
921
  self.capacity = options.capacity;
922
922
  self.timeToLive = options.timeToLive ? (exit, key) => fromInputUnsafe(options.timeToLive(exit, key)) : defaultTimeToLive;
923
923
  return succeed$1(self);
924
924
  });
925
- const make$4 = (options) => makeWith(options.lookup, {
926
- ...options,
927
- timeToLive: options.timeToLive !== void 0 ? () => options.timeToLive : defaultTimeToLive
928
- });
929
925
  const Proto$1 = {
930
926
  ...PipeInspectableProto,
931
927
  [TypeId$3]: TypeId$3,
@@ -948,18 +944,18 @@ const get = dual(2, (self, key) => withFiber$1((fiber) => {
948
944
  }
949
945
  }
950
946
  const entry = new EntryImpl(fiber, self.lookup(key));
947
+ entry.onInterrupt = () => removeEntry(self, key, entry);
951
948
  let skipCache = false;
952
949
  entry.fiber.addObserver((exit) => {
950
+ entry.onInterrupt = void 0;
953
951
  if (exitHasInterrupts(exit)) {
954
- const current = get$2(self.map, key);
955
- if (isSome(current) && current.value === entry) remove(self.map, key);
952
+ removeEntry(self, key, entry);
956
953
  return;
957
954
  }
958
955
  const ttl = self.timeToLive(exit, key);
959
956
  if (isZero(ttl)) {
960
957
  skipCache = true;
961
- const current = get$2(self.map, key);
962
- if (isSome(current) && current.value === entry) remove(self.map, key);
958
+ removeEntry(self, key, entry);
963
959
  } else if (isFinite(ttl)) entry.expiresAt = fiber.getRef(ClockRef).currentTimeMillisUnsafe() + toMillis(ttl);
964
960
  });
965
961
  const exit = entry.fiber.pollUnsafe();
@@ -971,6 +967,7 @@ var EntryImpl = class {
971
967
  expiresAt;
972
968
  awaiters;
973
969
  fiber;
970
+ onInterrupt;
974
971
  constructor(parent, valueEffect) {
975
972
  this.fiber = forkUnsafe(parent, valueEffect, true, true);
976
973
  this.awaiters = 0;
@@ -983,10 +980,15 @@ var EntryImpl = class {
983
980
  return onExit$1(fiberJoin(this.fiber), () => {
984
981
  this.awaiters--;
985
982
  if (this.awaiters > 0 || this.fiber.pollUnsafe()) return void_$2;
983
+ this.onInterrupt?.();
986
984
  return fiberInterrupt(this.fiber);
987
985
  });
988
986
  }
989
987
  };
988
+ const removeEntry = (self, key, entry) => {
989
+ const current = get$2(self.map, key);
990
+ if (isSome(current) && current.value === entry) remove(self.map, key);
991
+ };
990
992
  const hasExpired = (entry, fiber) => {
991
993
  if (entry.expiresAt === void 0) return false;
992
994
  return fiber.getRef(ClockRef).currentTimeMillisUnsafe() >= entry.expiresAt;
@@ -1001,7 +1003,7 @@ const checkCapacity = (self) => {
1001
1003
  }
1002
1004
  };
1003
1005
  //#endregion
1004
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/schema/VariantSchema.js
1006
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/schema/VariantSchema.js
1005
1007
  const TypeId$2 = "~effect/schema/VariantSchema";
1006
1008
  const cacheSymbol = Symbol.for(`${TypeId$2}/cache`);
1007
1009
  const defaultCacheSymbol = Symbol.for(`${TypeId$2}/defaultCache`);
@@ -1106,7 +1108,7 @@ const Union$1 = (members, defaultVariant, variants) => {
1106
1108
  return VariantUnion;
1107
1109
  };
1108
1110
  //#endregion
1109
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/schema/Model.js
1111
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/schema/Model.js
1110
1112
  const { Class, Field, FieldExcept, FieldOnly, Struct, Union, extract, fieldEvolve } = make$3({
1111
1113
  variants: [
1112
1114
  "select",
@@ -1180,7 +1182,7 @@ const DateTimeUpdateFromNumber = Field({
1180
1182
  json: DateTimeUtcFromMillis
1181
1183
  });
1182
1184
  //#endregion
1183
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlResolver.js
1185
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/sql/SqlResolver.js
1184
1186
  const SqlRequestProto = {
1185
1187
  ...Class$1.prototype,
1186
1188
  [symbol](that) {
@@ -1311,14 +1313,14 @@ function transactionKey(entry) {
1311
1313
  return byReferenceUnsafe(conn);
1312
1314
  }
1313
1315
  //#endregion
1314
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlSchema.js
1316
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/sql/SqlSchema.js
1315
1317
  const findAll = (options) => {
1316
1318
  const encodeRequest = encodeEffect(options.Request);
1317
1319
  const decode = decodeUnknownEffect(mutable(ArraySchema(options.Result)));
1318
1320
  return (request) => flatMap(flatMap(encodeRequest(request), options.execute), decode);
1319
1321
  };
1320
1322
  //#endregion
1321
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlModel.js
1323
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/sql/SqlModel.js
1322
1324
  const makeResolvers = (Model, options) => gen(function* () {
1323
1325
  const sql = yield* SqlClient;
1324
1326
  const idSchema = Model.fields[options.idColumn];
@@ -1884,7 +1886,7 @@ const layer$3 = effect(CodeChunker, gen(function* () {
1884
1886
  const listFiles = fn("CodeChunker.listFiles")(function* (options) {
1885
1887
  const root = pathService.resolve(options.root);
1886
1888
  const maxFileSize = options.maxFileSize ?? "1M";
1887
- return yield* pipe(spawner.streamLines(make$14("rg", [
1889
+ return yield* pipe(spawner.streamLines(make$13("rg", [
1888
1890
  "--files",
1889
1891
  "--hidden",
1890
1892
  "--max-filesize",
@@ -1932,7 +1934,7 @@ const layer$3 = effect(CodeChunker, gen(function* () {
1932
1934
  });
1933
1935
  }));
1934
1936
  //#endregion
1935
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/FiberHandle.js
1937
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/FiberHandle.js
1936
1938
  const TypeId$1 = "~effect/FiberHandle";
1937
1939
  const isFiberHandle = (u) => hasProperty(u, TypeId$1);
1938
1940
  const Proto = {
@@ -2002,45 +2004,59 @@ const runImpl = (self, effect, options) => withFiber((parent) => {
2002
2004
  return succeed(fiber);
2003
2005
  });
2004
2006
  //#endregion
2005
- //#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.0_effect@4.0.0/node_modules/@effect/sql-sqlite-node/dist/SqliteClient.js
2007
+ //#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.1_effect@4.0.1/node_modules/@effect/sql-sqlite-node/dist/SqliteClient.js
2006
2008
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
2007
2009
  const MAX_BUSY_TIMEOUT = 2147483647;
2010
+ const NANOS_PER_MILLI = BigInt(1e6);
2008
2011
  const TypeId = "~@effect/sql-sqlite-node/SqliteClient";
2009
2012
  const SqliteClient = Service("@effect/sql-sqlite-node/SqliteClient");
2010
2013
  const make$1 = (options) => gen(function* () {
2011
2014
  const compiler = makeCompilerSqlite(options.transformQueryNames);
2012
2015
  const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
2013
2016
  const connection = yield* gen(function* () {
2014
- const scope$1 = yield* scope;
2015
- const db = new DatabaseSync(options.filename, {
2016
- readOnly: options.readonly ?? false,
2017
- allowExtension: true
2018
- });
2019
- yield* addFinalizer(scope$1, sync(() => db.close()));
2017
+ const db = yield* acquireRelease(try_({
2018
+ try: () => new DatabaseSync(options.filename, {
2019
+ readOnly: options.readonly ?? false,
2020
+ allowExtension: true
2021
+ }),
2022
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to open database", "connect") })
2023
+ }), (db) => sync(() => db.close()));
2020
2024
  db.enableLoadExtension(false);
2021
2025
  const busyTimeout = Math.min(MAX_BUSY_TIMEOUT, Math.max(0, Math.round(toMillis(options.busyTimeout ?? seconds(5)))));
2022
- db.exec(`PRAGMA busy_timeout = ${busyTimeout}`);
2023
- if (options.disableWAL !== true) db.exec("PRAGMA journal_mode = WAL");
2026
+ const exec = (sql) => try_({
2027
+ try: () => db.exec(sql),
2028
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to configure database", "connect") })
2029
+ });
2030
+ yield* exec(`PRAGMA busy_timeout = ${busyTimeout}`);
2031
+ if (options.disableWAL !== true && !options.readonly) {
2032
+ const deadline = (yield* monotonicTimeNanos) + BigInt(busyTimeout) * NANOS_PER_MILLI;
2033
+ const remainingMillis = map(monotonicTimeNanos, (now) => Math.max(0, Number((deadline - now) / NANOS_PER_MILLI)));
2034
+ yield* remainingMillis.pipe(flatMap((remaining) => exec(`PRAGMA busy_timeout = ${remaining}`)), andThen(exec("PRAGMA journal_mode = WAL")), retry({
2035
+ while: (error) => error.reason._tag === "LockTimeoutError" && map(remainingMillis, (remaining) => remaining > 0),
2036
+ schedule: spaced("10 millis")
2037
+ }));
2038
+ yield* exec(`PRAGMA busy_timeout = ${busyTimeout}`);
2039
+ }
2024
2040
  const prepare = (sql) => try_({
2025
2041
  try: () => db.prepare(sql),
2026
2042
  catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to prepare statement", "prepare") })
2027
2043
  });
2028
- const prepareCache = yield* make$4({
2044
+ const prepareCacheTTL = options.prepareCacheTTL ?? minutes(10);
2045
+ const prepareCache = yield* makeWith(prepare, {
2029
2046
  capacity: options.prepareCacheSize ?? 200,
2030
- timeToLive: options.prepareCacheTTL ?? minutes(10),
2031
- lookup: prepare
2047
+ timeToLive: (exit) => isSuccess(exit) ? prepareCacheTTL : zero
2032
2048
  });
2033
2049
  const runStatement = (statement, params, raw) => withFiber((fiber) => {
2034
2050
  const useSafeIntegers = get$1(fiber.context, SafeIntegers);
2035
2051
  return try_({
2036
2052
  try: () => {
2037
2053
  statement.setReadBigInts(useSafeIntegers);
2038
- if (statement.columns().length > 0) return statement.all(...params);
2054
+ if (!raw || statement.columns().length > 0) return statement.all(...params);
2039
2055
  const result = statement.run(...params);
2040
- return raw ? {
2056
+ return {
2041
2057
  changes: result.changes,
2042
2058
  lastInsertRowid: result.lastInsertRowid
2043
- } : [];
2059
+ };
2044
2060
  },
2045
2061
  catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
2046
2062
  });
@@ -2050,9 +2066,7 @@ const make$1 = (options) => gen(function* () {
2050
2066
  return try_({
2051
2067
  try: () => {
2052
2068
  statement.setReadBigInts(useSafeIntegers);
2053
- if (statement.columns().length > 0) return statement.all(...params);
2054
- statement.run(...params);
2055
- return [];
2069
+ return statement.all(...params);
2056
2070
  },
2057
2071
  catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
2058
2072
  });
@@ -2063,9 +2077,7 @@ const make$1 = (options) => gen(function* () {
2063
2077
  try: () => {
2064
2078
  statement.setReadBigInts(useSafeIntegers);
2065
2079
  statement.setReturnArrays(true);
2066
- if (statement.columns().length > 0) return statement.all(...params);
2067
- statement.run(...params);
2068
- return [];
2080
+ return statement.all(...params);
2069
2081
  },
2070
2082
  catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
2071
2083
  });
@@ -2121,10 +2133,10 @@ const make$1 = (options) => gen(function* () {
2121
2133
  });
2122
2134
  const { acquirer, onCommitFailure, transactionAcquirer } = makeSqliteAcquirers({
2123
2135
  connection: succeed(connection),
2124
- semaphore: yield* make$12(1),
2136
+ semaphore: yield* make$11(1),
2125
2137
  isTransaction: (conn) => conn.isTransaction()
2126
2138
  });
2127
- return Object.assign(yield* make$5({
2139
+ return Object.assign(yield* make$4({
2128
2140
  acquirer,
2129
2141
  compiler,
2130
2142
  transactionAcquirer,
@@ -2140,7 +2152,7 @@ const make$1 = (options) => gen(function* () {
2140
2152
  loadExtension: (path) => flatMap(acquirer, (_) => _.loadExtension(path))
2141
2153
  });
2142
2154
  });
2143
- const layer$2 = (config) => effectContext(map(make$1(config), (client) => make$9(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide$1(layer$5));
2155
+ const layer$2 = (config) => effectContext(map(make$1(config), (client) => make$8(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide$1(layer$5));
2144
2156
  const classifyError = (cause, message, operation) => classifySqliteError(sqliteCauseWithErrno(cause), {
2145
2157
  message,
2146
2158
  operation
@@ -2152,7 +2164,7 @@ const sqliteCauseWithErrno = (cause) => {
2152
2164
  return Object.assign(cause, { errno: errcode });
2153
2165
  };
2154
2166
  //#endregion
2155
- //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/Migrator.js
2167
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/sql/Migrator.js
2156
2168
  var __rewriteRelativeImportExtension = void 0 && (void 0).__rewriteRelativeImportExtension || function(path, preserveJsx) {
2157
2169
  if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
2158
2170
  return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
@@ -2249,7 +2261,7 @@ const make = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, tab
2249
2261
  if (schemaDirectory && completed.length > 0) yield* dumpSchema(`${schemaDirectory}/_schema.sql`, table).pipe(catchCause((cause) => logInfo("Could not dump schema", cause)));
2250
2262
  return completed;
2251
2263
  });
2252
- const migrationOrder = make$10(([a], [b]) => Number$1(a, b));
2264
+ const migrationOrder = make$9(([a], [b]) => Number$1(a, b));
2253
2265
  const isConstraintConflict = (error) => error.reason._tag === "ConstraintError" || error.reason._tag === "UniqueViolation";
2254
2266
  const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishOr((_) => _.match(/^(\d+)_(.+)$/)), map$2(([key, id, name]) => [
2255
2267
  Number(id),
@@ -2257,7 +2269,7 @@ const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishO
2257
2269
  succeed(migrations[key])
2258
2270
  ]), sort(migrationOrder), succeed);
2259
2271
  //#endregion
2260
- //#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.0_effect@4.0.0/node_modules/@effect/sql-sqlite-node/dist/SqliteMigrator.js
2272
+ //#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.1_effect@4.0.1/node_modules/@effect/sql-sqlite-node/dist/SqliteMigrator.js
2261
2273
  const run = make({});
2262
2274
  const layer$1 = (options) => effectDiscard(run(options));
2263
2275
  //#endregion
@@ -2401,4 +2413,4 @@ const layer = (options) => effect(SemanticSearch, gen(function* () {
2401
2413
  //#endregion
2402
2414
  export { SemanticSearch, chunkEmbeddingInput, layer, makeEmbeddingResolver, maybeRemoveFile, maybeUpdateFile };
2403
2415
 
2404
- //# sourceMappingURL=SemanticSearch-cqSnq90g.mjs.map
2416
+ //# sourceMappingURL=SemanticSearch-CFB73IPb.mjs.map