clanka 0.8.3 → 0.8.4

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 (28) hide show
  1. package/dist/AgentExecutor.d.ts.map +1 -1
  2. package/dist/AgentExecutor.js +1 -1
  3. package/dist/AgentExecutor.js.map +1 -1
  4. package/dist/AgentExecutor.test.d.ts +2 -0
  5. package/dist/AgentExecutor.test.d.ts.map +1 -0
  6. package/dist/AgentExecutor.test.js +87 -0
  7. package/dist/AgentExecutor.test.js.map +1 -0
  8. package/dist/bin/{Effect-BCeySOy1.mjs → Effect-BmOuzEIp.mjs} +243 -215
  9. package/dist/bin/Effect-BmOuzEIp.mjs.map +1 -0
  10. package/dist/bin/{McpClient-DP4jlaD1.mjs → McpClient-CLpFJSre.mjs} +3 -3
  11. package/dist/bin/{McpClient-DP4jlaD1.mjs.map → McpClient-CLpFJSre.mjs.map} +1 -1
  12. package/dist/bin/{OutputFormatter-Ch8yFytV.mjs → OutputFormatter-C_gdNUl1.mjs} +3 -3
  13. package/dist/bin/{OutputFormatter-Ch8yFytV.mjs.map → OutputFormatter-C_gdNUl1.mjs.map} +1 -1
  14. package/dist/bin/{Schema-C9JQ5hI0.mjs → Schema-C7W9nQug.mjs} +477 -382
  15. package/dist/bin/Schema-C7W9nQug.mjs.map +1 -0
  16. package/dist/bin/{SemanticSearch-BJGnYhFt.mjs → SemanticSearch-cqSnq90g.mjs} +269 -228
  17. package/dist/bin/SemanticSearch-cqSnq90g.mjs.map +1 -0
  18. package/dist/bin/{Stream-CgH3SuLu.mjs → Stream-BI6Fx9yq.mjs} +179 -171
  19. package/dist/bin/Stream-BI6Fx9yq.mjs.map +1 -0
  20. package/dist/bin/cli.mjs +169 -201
  21. package/dist/bin/cli.mjs.map +1 -1
  22. package/package.json +12 -12
  23. package/src/AgentExecutor.test.ts +133 -0
  24. package/src/AgentExecutor.ts +1 -2
  25. package/dist/bin/Effect-BCeySOy1.mjs.map +0 -1
  26. package/dist/bin/Schema-C9JQ5hI0.mjs.map +0 -1
  27. package/dist/bin/SemanticSearch-BJGnYhFt.mjs.map +0 -1
  28. package/dist/bin/Stream-CgH3SuLu.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { $ as isEffect, $a as map$1, $o as symbol$1, $t as uninterruptibleMask, Aa as getOrUndefined, Ai as ParentSpan, Ao as assignProperty, B as fnUntraced, Br as succeed$2, C as catch_, Cs as constUndefined, D as delay, Di as updateContext, Dr as doneUnsafe, Ds as flow, E as contextWith, Ea as add, Er as done, Es as dual, Et as provideService, F as filterOrFail, Fa as merge, Fr as failCause, Go as equals, Gt as tap, H as forEach, Hr as ClockRef, I as flatMap, It as scope, Jr as contextWith$1, K as forkScoped, Ko as symbol, Ln as filterInterruptors, Lt as scoped, M as fail$1, Ma as getUnsafe, Mr as makeUnsafe$2, Mt as runFork, Na as make$9, Nt as runForkWith, O as die, Oa as get$1, Oi as void_$2, Oo as withFiber$1, Os as identity, Pi as empty, Pr as fail, Ps as pipeArguments, Qr as exitHasInterrupts, Ra as filter, Ri as flatMapNullishOr, Rr as isFailure, S as catchTags, Si as succeed$1, St as orElseSucceed, T as context, Ta as Service, Tt as provideContext, U as forever, Ua as fromNullishOr, Ut as suspend, Va as flatten, Vi as isArrayNonEmpty, Vn as hasInterruptsOnly, Vr as void_$3, Vt as succeed, Wo as byReferenceUnsafe, Wt as sync, X as ignore, Xt as try_, Y as gen, Ya as isNone, Yo as hash, Yt as tryPromise, Z as interrupt, Za as isSome, Zi as sort, Zr as endSpan, _a as minutes, _r as close, _t as onExit, a as andThen, at as makeSpanScoped, ba as seconds, c as as, co as Number$1, da as fromInputUnsafe, eo as match, er as effect, es as hasProperty, et as logDebug, fa as infinity, fn as Class$1, ft as matchCauseEager, ga as millis, gi as makeSpanUnsafe, h as catchDefect, ha as isZero, hr as addFinalizer, i as all, io as some, js as pipe, ka as getOption, kn as NoSuchElementError, kr as into, kt as request$1, ln as withSpan, lr as provide$1, lt as mapError, m as catchCause, ma as isFinite, mo as make$10, mr as Scope, n as acquireUseRelease, nn as useSpan, nr as effectDiscard, o as annotateCurrentSpan, on as withFiber, ot as map, qi as map$2, ri as fiberInterrupt, rn as void_$1, rt as logInfo, s as annotateLogs, si as fiberJoin, sn as withLogSpan, ss as isNotNull, t as acquireRelease, to as none, tr as effectContext, u as asVoid, ui as forkUnsafe, ur as provideMerge, vi as onExit$1, vo as Prototype, vt as onExitPrimitive, wa as Reference, wr as TracerTimingEnabled, x as catchTag, xa as toMillis, xo as PipeInspectableProto, xr as provide, xt as orDie, y as catchNoSuchElement, yr as make$8, z as fn, zi as fromIterable, zr as isSuccess, zt as serviceOption } from "./Effect-BCeySOy1.mjs";
2
- import { $ as tap$1, At as getCurrent, 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-CgH3SuLu.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-C9JQ5hI0.mjs";
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
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";
5
5
  import { createHash } from "node:crypto";
6
6
  import { DatabaseSync, backup } from "node:sqlite";
@@ -8,7 +8,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@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/reactivity/Reactivity.js
11
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/reactivity/Reactivity.js
12
12
  const TypeId$6 = "~effect/reactivity/Reactivity";
13
13
  const Reactivity = Service("effect/reactivity/Reactivity");
14
14
  const make$7 = sync(() => {
@@ -122,7 +122,181 @@ const keysToHashes = (keys, f) => {
122
122
  }
123
123
  };
124
124
  //#endregion
125
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/sql/Statement.js
125
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlError.js
126
+ const TypeId$5 = "~effect/sql/SqlError";
127
+ const ReasonTypeId = "~effect/sql/SqlError/Reason";
128
+ const ReasonFields = {
129
+ cause: Defect(),
130
+ message: optional(String$1),
131
+ operation: optional(String$1)
132
+ };
133
+ var ConnectionError = class extends TaggedError("effect/sql/SqlError/ConnectionError")("ConnectionError", ReasonFields) {
134
+ [ReasonTypeId] = ReasonTypeId;
135
+ get isRetryable() {
136
+ return true;
137
+ }
138
+ };
139
+ var AuthenticationError = class extends TaggedError("effect/sql/SqlError/AuthenticationError")("AuthenticationError", ReasonFields) {
140
+ [ReasonTypeId] = ReasonTypeId;
141
+ get isRetryable() {
142
+ return false;
143
+ }
144
+ };
145
+ var AuthorizationError = class extends TaggedError("effect/sql/SqlError/AuthorizationError")("AuthorizationError", ReasonFields) {
146
+ [ReasonTypeId] = ReasonTypeId;
147
+ get isRetryable() {
148
+ return false;
149
+ }
150
+ };
151
+ var SqlSyntaxError = class extends TaggedError("effect/sql/SqlError/SqlSyntaxError")("SqlSyntaxError", ReasonFields) {
152
+ [ReasonTypeId] = ReasonTypeId;
153
+ get isRetryable() {
154
+ return false;
155
+ }
156
+ };
157
+ const UniqueViolationFields = {
158
+ ...ReasonFields,
159
+ constraint: String$1
160
+ };
161
+ var UniqueViolation = class extends TaggedError("effect/sql/SqlError/UniqueViolation")("UniqueViolation", UniqueViolationFields) {
162
+ [ReasonTypeId] = ReasonTypeId;
163
+ get isRetryable() {
164
+ return false;
165
+ }
166
+ };
167
+ var ConstraintError = class extends TaggedError("effect/sql/SqlError/ConstraintError")("ConstraintError", ReasonFields) {
168
+ [ReasonTypeId] = ReasonTypeId;
169
+ get isRetryable() {
170
+ return false;
171
+ }
172
+ };
173
+ var DeadlockError = class extends TaggedError("effect/sql/SqlError/DeadlockError")("DeadlockError", ReasonFields) {
174
+ [ReasonTypeId] = ReasonTypeId;
175
+ get isRetryable() {
176
+ return true;
177
+ }
178
+ };
179
+ var SerializationError = class extends TaggedError("effect/sql/SqlError/SerializationError")("SerializationError", ReasonFields) {
180
+ [ReasonTypeId] = ReasonTypeId;
181
+ get isRetryable() {
182
+ return true;
183
+ }
184
+ };
185
+ var LockTimeoutError = class extends TaggedError("effect/sql/SqlError/LockTimeoutError")("LockTimeoutError", ReasonFields) {
186
+ [ReasonTypeId] = ReasonTypeId;
187
+ get isRetryable() {
188
+ return true;
189
+ }
190
+ };
191
+ var StatementTimeoutError = class extends TaggedError("effect/sql/SqlError/StatementTimeoutError")("StatementTimeoutError", ReasonFields) {
192
+ [ReasonTypeId] = ReasonTypeId;
193
+ get isRetryable() {
194
+ return true;
195
+ }
196
+ };
197
+ var UnknownError = class extends TaggedError("effect/sql/SqlError/UnknownError")("UnknownError", ReasonFields) {
198
+ [ReasonTypeId] = ReasonTypeId;
199
+ get isRetryable() {
200
+ return false;
201
+ }
202
+ };
203
+ const SqlErrorReason = Union$2([
204
+ ConnectionError,
205
+ AuthenticationError,
206
+ AuthorizationError,
207
+ SqlSyntaxError,
208
+ UniqueViolation,
209
+ ConstraintError,
210
+ DeadlockError,
211
+ SerializationError,
212
+ LockTimeoutError,
213
+ StatementTimeoutError,
214
+ UnknownError
215
+ ]);
216
+ var SqlError = class extends TaggedError("effect/sql/SqlError")("SqlError", { reason: SqlErrorReason }) {
217
+ [TypeId$5] = TypeId$5;
218
+ cause = this.reason;
219
+ get message() {
220
+ return this.reason.message || this.reason._tag;
221
+ }
222
+ get isRetryable() {
223
+ return this.reason.isRetryable;
224
+ }
225
+ };
226
+ const sqliteCodeFromCause = (cause) => {
227
+ if (!hasProperty(cause, "code")) return;
228
+ const code = cause.code;
229
+ return typeof code === "string" || typeof code === "number" ? code : void 0;
230
+ };
231
+ const sqliteNumericCodeFromCause = (cause) => {
232
+ const code = sqliteCodeFromCause(cause);
233
+ if (typeof code === "number") return code;
234
+ if (!hasProperty(cause, "errno")) return;
235
+ const errno = cause.errno;
236
+ return typeof errno === "number" ? errno : void 0;
237
+ };
238
+ const matchesSqliteNumericCode = (cause, expected) => {
239
+ if (sqliteCodeFromCause(cause) === expected) return true;
240
+ if (!hasProperty(cause, "errno")) return false;
241
+ return cause.errno === expected;
242
+ };
243
+ const matchesSqliteCode = (code, expected) => code === expected || code.startsWith(expected + "_");
244
+ const UNKNOWN_CONSTRAINT = "unknown";
245
+ const SQLITE_CONSTRAINT_UNIQUE = "SQLITE_CONSTRAINT_UNIQUE";
246
+ const SQLITE_CONSTRAINT_UNIQUE_CODE = 2067;
247
+ const normalizeConstraintIdentifier = (identifier) => {
248
+ if (typeof identifier !== "string") return UNKNOWN_CONSTRAINT;
249
+ const trimmed = identifier.trim();
250
+ return trimmed.length === 0 ? UNKNOWN_CONSTRAINT : trimmed;
251
+ };
252
+ const sqliteUniqueConstraintFromCause = (cause) => {
253
+ if (hasProperty(cause, "constraint")) return normalizeConstraintIdentifier(cause.constraint);
254
+ if (!hasProperty(cause, "message")) return UNKNOWN_CONSTRAINT;
255
+ const message = cause.message;
256
+ if (typeof message !== "string") return UNKNOWN_CONSTRAINT;
257
+ const index = message.indexOf("UNIQUE constraint failed:");
258
+ return index === -1 ? UNKNOWN_CONSTRAINT : normalizeConstraintIdentifier(message.slice(index + 25));
259
+ };
260
+ const classifySqliteError = (cause, { message, operation } = {}) => {
261
+ const props = {
262
+ cause,
263
+ message,
264
+ operation
265
+ };
266
+ const code = sqliteCodeFromCause(cause);
267
+ const numericCode = sqliteNumericCodeFromCause(cause);
268
+ if (code === SQLITE_CONSTRAINT_UNIQUE || matchesSqliteNumericCode(cause, SQLITE_CONSTRAINT_UNIQUE_CODE)) return new UniqueViolation({
269
+ ...props,
270
+ constraint: sqliteUniqueConstraintFromCause(cause)
271
+ });
272
+ if (typeof code === "string") {
273
+ if (matchesSqliteCode(code, "SQLITE_AUTH")) return new AuthenticationError(props);
274
+ if (matchesSqliteCode(code, "SQLITE_PERM")) return new AuthorizationError(props);
275
+ if (matchesSqliteCode(code, "SQLITE_CONSTRAINT")) return new ConstraintError(props);
276
+ if (matchesSqliteCode(code, "SQLITE_BUSY") || matchesSqliteCode(code, "SQLITE_LOCKED")) return new LockTimeoutError(props);
277
+ if (matchesSqliteCode(code, "SQLITE_CANTOPEN")) return new ConnectionError(props);
278
+ }
279
+ if (typeof numericCode === "number") switch (numericCode & 255) {
280
+ case 23: return new AuthenticationError(props);
281
+ case 3: return new AuthorizationError(props);
282
+ case 19: return new ConstraintError(props);
283
+ case 5:
284
+ case 6: return new LockTimeoutError(props);
285
+ case 14: return new ConnectionError(props);
286
+ default: return new UnknownError(props);
287
+ }
288
+ return new UnknownError(props);
289
+ };
290
+ var ResultLengthMismatch = class extends TaggedError("effect/sql/ResultLengthMismatch")("ResultLengthMismatch", {
291
+ expected: Natural,
292
+ actual: Natural
293
+ }) {
294
+ get message() {
295
+ return `Expected ${this.expected} results but got ${this.actual}`;
296
+ }
297
+ };
298
+ //#endregion
299
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/Statement.js
126
300
  const FragmentTypeId = "~effect/sql/Statement/Fragment";
127
301
  const fragment = (segments) => ({
128
302
  [FragmentTypeId]: FragmentTypeId,
@@ -612,8 +786,8 @@ function in_() {
612
786
  }
613
787
  const neverFragment = fragment([literal("1=0")]);
614
788
  //#endregion
615
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/sql/SqlClient.js
616
- const TypeId$5 = "~effect/sql/SqlClient";
789
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlClient.js
790
+ const TypeId$4 = "~effect/sql/SqlClient";
617
791
  const SqlClient = Service("effect/sql/SqlClient");
618
792
  let clientIdCounter = 0;
619
793
  let transactionSemaphoreIdCounter = 0;
@@ -634,11 +808,12 @@ const make$5 = fnUntraced(function* (options) {
634
808
  const withTransaction = makeWithTransaction({
635
809
  transactionService,
636
810
  spanAttributes: options.spanAttributes,
637
- acquireConnection: flatMap(make$8(), (scope) => map(provide(transactionAcquirer, scope), (conn) => [scope, conn])),
811
+ acquireConnection: flatMap(make$8(), (scope) => provide(transactionAcquirer, scope).pipe(onError((cause) => close(scope, failCause(cause))), map((conn) => [scope, conn]))),
638
812
  begin: (conn) => control(conn, beginTransaction),
639
813
  savepoint: (conn, id) => control(conn, savepoint(`effect_sql_${id}`)),
640
814
  releaseSavepoint: releaseSavepoint ? (conn, id) => control(conn, releaseSavepoint(`effect_sql_${id}`)) : void 0,
641
- commit: (conn) => control(conn, commit),
815
+ commit: typeof commit === "string" ? (conn) => control(conn, commit) : commit,
816
+ onCommitFailure: options.onCommitFailure,
642
817
  rollback: (conn) => control(conn, rollback),
643
818
  rollbackSavepoint: (conn, id) => control(conn, rollbackSavepoint(`effect_sql_${id}`))
644
819
  });
@@ -648,7 +823,7 @@ const make$5 = fnUntraced(function* (options) {
648
823
  onSome: ([conn]) => f(conn)
649
824
  }));
650
825
  const client = Object.assign(make$6(getConnection, options.compiler, options.spanAttributes, options.transformRows, borrower), {
651
- [TypeId$5]: TypeId$5,
826
+ [TypeId$4]: TypeId$4,
652
827
  safe: void 0,
653
828
  withTransaction,
654
829
  transactionService,
@@ -670,6 +845,39 @@ const make$5 = fnUntraced(function* (options) {
670
845
  client.safe = client;
671
846
  return client;
672
847
  });
848
+ const makeSqliteAcquirers = (options) => {
849
+ const { isTransaction, semaphore } = options;
850
+ let poisoned;
851
+ const poison = (cause) => poisoned = new SqlError({ reason: new ConnectionError({
852
+ message: "SQLite connection cannot be reused after failed COMMIT cleanup",
853
+ operation: "rollback",
854
+ cause
855
+ }) });
856
+ const rollback = (conn) => {
857
+ if (isTransaction) return isTransaction(conn) ? asVoid(conn.executeUnprepared("ROLLBACK", [], void 0)) : void_$1;
858
+ return conn.executeUnprepared("ROLLBACK", [], void 0).pipe(asVoid, catchIf(isNoTransactionError, () => void_$1));
859
+ };
860
+ const available = flatMap(options.connection, (conn) => {
861
+ if (poisoned === void 0) return succeed(conn);
862
+ return matchCauseEffect(rollback(conn), {
863
+ onFailure: (cause) => fail(poison(cause)),
864
+ onSuccess: () => {
865
+ poisoned = void 0;
866
+ return succeed(conn);
867
+ }
868
+ });
869
+ });
870
+ return {
871
+ acquirer: semaphore.withPermits(1)(available),
872
+ transactionAcquirer: uninterruptibleMask((restore) => flatMap(scope, (scope) => restore(semaphore.take(1)).pipe(andThen(addFinalizer(scope, semaphore.release(1))), andThen(available)))),
873
+ onCommitFailure: (conn) => tapCause(rollback(conn), (cause) => sync(() => poison(cause)))
874
+ };
875
+ };
876
+ const isNoTransactionError = (error) => {
877
+ const cause = error.reason.cause;
878
+ const message = typeof cause === "string" ? cause : hasProperty(cause, "message") && typeof cause.message === "string" ? cause.message : "";
879
+ return /no transaction is active/i.test(message);
880
+ };
673
881
  const makeWithTransaction = (options) => {
674
882
  const transactionSemaphore = Service(`effect/sql/SqlClient/TransactionSemaphore/${transactionSemaphoreIdCounter++}`);
675
883
  return (effect) => uninterruptibleMask((restore) => useSpan("sql.transaction", { kind: "client" }, (span) => withFiber((fiber) => {
@@ -684,7 +892,9 @@ const makeWithTransaction = (options) => {
684
892
  if (isSuccess(exit)) {
685
893
  if (id === 0) {
686
894
  span.event("db.transaction.commit", clock.currentTimeNanosUnsafe());
895
+ const onCommitFailure = options.onCommitFailure;
687
896
  effect = orDie(options.commit(conn));
897
+ if (onCommitFailure) effect = onError(effect, () => orDie(onCommitFailure(conn)));
688
898
  } else {
689
899
  span.event("db.transaction.savepoint", clock.currentTimeNanosUnsafe());
690
900
  effect = void_$1;
@@ -702,8 +912,8 @@ const makeWithTransaction = (options) => {
702
912
  const TransactionConnection = (clientId) => Service(`effect/sql/SqlClient/TransactionConnection/${clientId}`);
703
913
  const SafeIntegers = Reference("effect/sql/SqlClient/SafeIntegers", { defaultValue: () => false });
704
914
  //#endregion
705
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Cache.js
706
- const TypeId$4 = "~effect/Cache";
915
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/Cache.js
916
+ const TypeId$3 = "~effect/Cache";
707
917
  const makeWith = (lookup, options) => contextWith$1((context) => {
708
918
  const self = Object.create(Proto$1);
709
919
  self.lookup = (key) => updateContext(lookup(key), (input) => merge(context, input));
@@ -718,7 +928,7 @@ const make$4 = (options) => makeWith(options.lookup, {
718
928
  });
719
929
  const Proto$1 = {
720
930
  ...PipeInspectableProto,
721
- [TypeId$4]: TypeId$4,
931
+ [TypeId$3]: TypeId$3,
722
932
  toJSON() {
723
933
  return {
724
934
  _id: "Cache",
@@ -730,12 +940,15 @@ const Proto$1 = {
730
940
  const defaultTimeToLive = (_, _key) => infinity;
731
941
  const get = dual(2, (self, key) => withFiber$1((fiber) => {
732
942
  const oentry = get$2(self.map, key);
733
- if (isSome(oentry) && !hasExpired(oentry.value, fiber)) {
943
+ if (isSome(oentry)) {
734
944
  remove(self.map, key);
735
- set(self.map, key, oentry.value);
736
- return oentry.value.await();
945
+ if (!hasExpired(oentry.value, fiber)) {
946
+ set(self.map, key, oentry.value);
947
+ return oentry.value.await();
948
+ }
737
949
  }
738
950
  const entry = new EntryImpl(fiber, self.lookup(key));
951
+ let skipCache = false;
739
952
  entry.fiber.addObserver((exit) => {
740
953
  if (exitHasInterrupts(exit)) {
741
954
  const current = get$2(self.map, key);
@@ -743,11 +956,14 @@ const get = dual(2, (self, key) => withFiber$1((fiber) => {
743
956
  return;
744
957
  }
745
958
  const ttl = self.timeToLive(exit, key);
746
- if (isFinite(ttl)) entry.expiresAt = fiber.getRef(ClockRef).currentTimeMillisUnsafe() + toMillis(ttl);
747
- else if (isZero(ttl)) remove(self.map, key);
959
+ if (isZero(ttl)) {
960
+ skipCache = true;
961
+ const current = get$2(self.map, key);
962
+ if (isSome(current) && current.value === entry) remove(self.map, key);
963
+ } else if (isFinite(ttl)) entry.expiresAt = fiber.getRef(ClockRef).currentTimeMillisUnsafe() + toMillis(ttl);
748
964
  });
749
965
  const exit = entry.fiber.pollUnsafe();
750
- if (exit === void 0 || !exitHasInterrupts(exit)) set(self.map, key, entry);
966
+ if (!skipCache && (exit === void 0 || !exitHasInterrupts(exit))) set(self.map, key, entry);
751
967
  if (Number.isFinite(self.capacity)) checkCapacity(self);
752
968
  return entry.await();
753
969
  }));
@@ -785,11 +1001,11 @@ const checkCapacity = (self) => {
785
1001
  }
786
1002
  };
787
1003
  //#endregion
788
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/schema/VariantSchema.js
789
- const TypeId$3 = "~effect/schema/VariantSchema";
790
- const cacheSymbol = Symbol.for(`${TypeId$3}/cache`);
791
- const defaultCacheSymbol = Symbol.for(`${TypeId$3}/defaultCache`);
792
- const isStruct = (u) => hasProperty(u, TypeId$3);
1004
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/schema/VariantSchema.js
1005
+ const TypeId$2 = "~effect/schema/VariantSchema";
1006
+ const cacheSymbol = Symbol.for(`${TypeId$2}/cache`);
1007
+ const defaultCacheSymbol = Symbol.for(`${TypeId$2}/defaultCache`);
1008
+ const isStruct = (u) => hasProperty(u, TypeId$2);
793
1009
  const FieldTypeId = "~effect/schema/VariantSchema/Field";
794
1010
  const isField = (u) => hasProperty(u, FieldTypeId);
795
1011
  const extract$1 = dual((args) => isStruct(args[0]), (self, variant, options) => {
@@ -797,8 +1013,8 @@ const extract$1 = dual((args) => isStruct(args[0]), (self, variant, options) =>
797
1013
  const cache = options?.isDefault === true ? self[defaultCacheSymbol] ?? (self[defaultCacheSymbol] = Object.create(null)) : self[cacheSymbol] ?? (self[cacheSymbol] = Object.create(null));
798
1014
  if (Object.hasOwn(cache, variant)) return cache[variant];
799
1015
  const fields = {};
800
- for (const key of Object.keys(self[TypeId$3])) {
801
- const value = self[TypeId$3][key];
1016
+ for (const key of Object.keys(self[TypeId$2])) {
1017
+ const value = self[TypeId$2][key];
802
1018
  if (value === void 0) continue;
803
1019
  if ("~effect/schema/VariantSchema" in value) {
804
1020
  if (options?.isDefault === true && isSchema(value)) assignProperty(fields, key, value);
@@ -821,7 +1037,7 @@ const make$3 = (options) => {
821
1037
  const schema = extract$1(variantStruct, options.defaultVariant, { isDefault: true });
822
1038
  const SClass = Class$2;
823
1039
  class Base extends SClass(identifier)(schema.fields, annotations) {
824
- static [TypeId$3] = fields;
1040
+ static [TypeId$2] = fields;
825
1041
  }
826
1042
  for (const variant of options.variants) Object.defineProperty(Base, variant, { value: extract$1(variantStruct, variant).annotate({
827
1043
  id: `${identifier}.${variant}`,
@@ -870,7 +1086,7 @@ const StructProto = { pipe() {
870
1086
  } };
871
1087
  const Struct$1 = (fields) => {
872
1088
  const self = Object.create(StructProto);
873
- self[TypeId$3] = fields;
1089
+ self[TypeId$2] = fields;
874
1090
  return self;
875
1091
  };
876
1092
  const FieldProto = {
@@ -890,7 +1106,7 @@ const Union$1 = (members, defaultVariant, variants) => {
890
1106
  return VariantUnion;
891
1107
  };
892
1108
  //#endregion
893
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/schema/Model.js
1109
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/schema/Model.js
894
1110
  const { Class, Field, FieldExcept, FieldOnly, Struct, Union, extract, fieldEvolve } = make$3({
895
1111
  variants: [
896
1112
  "select",
@@ -964,181 +1180,7 @@ const DateTimeUpdateFromNumber = Field({
964
1180
  json: DateTimeUtcFromMillis
965
1181
  });
966
1182
  //#endregion
967
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/sql/SqlError.js
968
- const TypeId$2 = "~effect/sql/SqlError";
969
- const ReasonTypeId = "~effect/sql/SqlError/Reason";
970
- const ReasonFields = {
971
- cause: Defect(),
972
- message: optional(String$1),
973
- operation: optional(String$1)
974
- };
975
- var ConnectionError = class extends TaggedError("effect/sql/SqlError/ConnectionError")("ConnectionError", ReasonFields) {
976
- [ReasonTypeId] = ReasonTypeId;
977
- get isRetryable() {
978
- return true;
979
- }
980
- };
981
- var AuthenticationError = class extends TaggedError("effect/sql/SqlError/AuthenticationError")("AuthenticationError", ReasonFields) {
982
- [ReasonTypeId] = ReasonTypeId;
983
- get isRetryable() {
984
- return false;
985
- }
986
- };
987
- var AuthorizationError = class extends TaggedError("effect/sql/SqlError/AuthorizationError")("AuthorizationError", ReasonFields) {
988
- [ReasonTypeId] = ReasonTypeId;
989
- get isRetryable() {
990
- return false;
991
- }
992
- };
993
- var SqlSyntaxError = class extends TaggedError("effect/sql/SqlError/SqlSyntaxError")("SqlSyntaxError", ReasonFields) {
994
- [ReasonTypeId] = ReasonTypeId;
995
- get isRetryable() {
996
- return false;
997
- }
998
- };
999
- const UniqueViolationFields = {
1000
- ...ReasonFields,
1001
- constraint: String$1
1002
- };
1003
- var UniqueViolation = class extends TaggedError("effect/sql/SqlError/UniqueViolation")("UniqueViolation", UniqueViolationFields) {
1004
- [ReasonTypeId] = ReasonTypeId;
1005
- get isRetryable() {
1006
- return false;
1007
- }
1008
- };
1009
- var ConstraintError = class extends TaggedError("effect/sql/SqlError/ConstraintError")("ConstraintError", ReasonFields) {
1010
- [ReasonTypeId] = ReasonTypeId;
1011
- get isRetryable() {
1012
- return false;
1013
- }
1014
- };
1015
- var DeadlockError = class extends TaggedError("effect/sql/SqlError/DeadlockError")("DeadlockError", ReasonFields) {
1016
- [ReasonTypeId] = ReasonTypeId;
1017
- get isRetryable() {
1018
- return true;
1019
- }
1020
- };
1021
- var SerializationError = class extends TaggedError("effect/sql/SqlError/SerializationError")("SerializationError", ReasonFields) {
1022
- [ReasonTypeId] = ReasonTypeId;
1023
- get isRetryable() {
1024
- return true;
1025
- }
1026
- };
1027
- var LockTimeoutError = class extends TaggedError("effect/sql/SqlError/LockTimeoutError")("LockTimeoutError", ReasonFields) {
1028
- [ReasonTypeId] = ReasonTypeId;
1029
- get isRetryable() {
1030
- return true;
1031
- }
1032
- };
1033
- var StatementTimeoutError = class extends TaggedError("effect/sql/SqlError/StatementTimeoutError")("StatementTimeoutError", ReasonFields) {
1034
- [ReasonTypeId] = ReasonTypeId;
1035
- get isRetryable() {
1036
- return true;
1037
- }
1038
- };
1039
- var UnknownError = class extends TaggedError("effect/sql/SqlError/UnknownError")("UnknownError", ReasonFields) {
1040
- [ReasonTypeId] = ReasonTypeId;
1041
- get isRetryable() {
1042
- return false;
1043
- }
1044
- };
1045
- const SqlErrorReason = Union$2([
1046
- ConnectionError,
1047
- AuthenticationError,
1048
- AuthorizationError,
1049
- SqlSyntaxError,
1050
- UniqueViolation,
1051
- ConstraintError,
1052
- DeadlockError,
1053
- SerializationError,
1054
- LockTimeoutError,
1055
- StatementTimeoutError,
1056
- UnknownError
1057
- ]);
1058
- var SqlError = class extends TaggedError("effect/sql/SqlError")("SqlError", { reason: SqlErrorReason }) {
1059
- [TypeId$2] = TypeId$2;
1060
- cause = this.reason;
1061
- get message() {
1062
- return this.reason.message || this.reason._tag;
1063
- }
1064
- get isRetryable() {
1065
- return this.reason.isRetryable;
1066
- }
1067
- };
1068
- const sqliteCodeFromCause = (cause) => {
1069
- if (!hasProperty(cause, "code")) return;
1070
- const code = cause.code;
1071
- return typeof code === "string" || typeof code === "number" ? code : void 0;
1072
- };
1073
- const sqliteNumericCodeFromCause = (cause) => {
1074
- const code = sqliteCodeFromCause(cause);
1075
- if (typeof code === "number") return code;
1076
- if (!hasProperty(cause, "errno")) return;
1077
- const errno = cause.errno;
1078
- return typeof errno === "number" ? errno : void 0;
1079
- };
1080
- const matchesSqliteNumericCode = (cause, expected) => {
1081
- if (sqliteCodeFromCause(cause) === expected) return true;
1082
- if (!hasProperty(cause, "errno")) return false;
1083
- return cause.errno === expected;
1084
- };
1085
- const matchesSqliteCode = (code, expected) => code === expected || code.startsWith(expected + "_");
1086
- const UNKNOWN_CONSTRAINT = "unknown";
1087
- const SQLITE_CONSTRAINT_UNIQUE = "SQLITE_CONSTRAINT_UNIQUE";
1088
- const SQLITE_CONSTRAINT_UNIQUE_CODE = 2067;
1089
- const normalizeConstraintIdentifier = (identifier) => {
1090
- if (typeof identifier !== "string") return UNKNOWN_CONSTRAINT;
1091
- const trimmed = identifier.trim();
1092
- return trimmed.length === 0 ? UNKNOWN_CONSTRAINT : trimmed;
1093
- };
1094
- const sqliteUniqueConstraintFromCause = (cause) => {
1095
- if (hasProperty(cause, "constraint")) return normalizeConstraintIdentifier(cause.constraint);
1096
- if (!hasProperty(cause, "message")) return UNKNOWN_CONSTRAINT;
1097
- const message = cause.message;
1098
- if (typeof message !== "string") return UNKNOWN_CONSTRAINT;
1099
- const index = message.indexOf("UNIQUE constraint failed:");
1100
- return index === -1 ? UNKNOWN_CONSTRAINT : normalizeConstraintIdentifier(message.slice(index + 25));
1101
- };
1102
- const classifySqliteError = (cause, { message, operation } = {}) => {
1103
- const props = {
1104
- cause,
1105
- message,
1106
- operation
1107
- };
1108
- const code = sqliteCodeFromCause(cause);
1109
- const numericCode = sqliteNumericCodeFromCause(cause);
1110
- if (code === SQLITE_CONSTRAINT_UNIQUE || matchesSqliteNumericCode(cause, SQLITE_CONSTRAINT_UNIQUE_CODE)) return new UniqueViolation({
1111
- ...props,
1112
- constraint: sqliteUniqueConstraintFromCause(cause)
1113
- });
1114
- if (typeof code === "string") {
1115
- if (matchesSqliteCode(code, "SQLITE_AUTH")) return new AuthenticationError(props);
1116
- if (matchesSqliteCode(code, "SQLITE_PERM")) return new AuthorizationError(props);
1117
- if (matchesSqliteCode(code, "SQLITE_CONSTRAINT")) return new ConstraintError(props);
1118
- if (matchesSqliteCode(code, "SQLITE_BUSY") || matchesSqliteCode(code, "SQLITE_LOCKED")) return new LockTimeoutError(props);
1119
- if (matchesSqliteCode(code, "SQLITE_CANTOPEN")) return new ConnectionError(props);
1120
- }
1121
- if (typeof numericCode === "number") switch (numericCode & 255) {
1122
- case 23: return new AuthenticationError(props);
1123
- case 3: return new AuthorizationError(props);
1124
- case 19: return new ConstraintError(props);
1125
- case 5:
1126
- case 6: return new LockTimeoutError(props);
1127
- case 14: return new ConnectionError(props);
1128
- default: return new UnknownError(props);
1129
- }
1130
- return new UnknownError(props);
1131
- };
1132
- var ResultLengthMismatch = class extends TaggedError("effect/sql/ResultLengthMismatch")("ResultLengthMismatch", {
1133
- expected: Natural,
1134
- actual: Natural
1135
- }) {
1136
- get message() {
1137
- return `Expected ${this.expected} results but got ${this.actual}`;
1138
- }
1139
- };
1140
- //#endregion
1141
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/sql/SqlResolver.js
1183
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlResolver.js
1142
1184
  const SqlRequestProto = {
1143
1185
  ...Class$1.prototype,
1144
1186
  [symbol](that) {
@@ -1210,7 +1252,7 @@ const void_ = (options) => makeGrouped({
1210
1252
  for (let i = 0; i < entries.length; i++) entries[i].completeUnsafe(void_$3);
1211
1253
  })
1212
1254
  });
1213
- const constNoSuchElement = fail(new NoSuchElementError());
1255
+ const constNoSuchElement = fail$1(new NoSuchElementError());
1214
1256
  const partitionRequests = function* (requests, schema) {
1215
1257
  const len = requests.length;
1216
1258
  const inputs = empty();
@@ -1269,14 +1311,14 @@ function transactionKey(entry) {
1269
1311
  return byReferenceUnsafe(conn);
1270
1312
  }
1271
1313
  //#endregion
1272
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/sql/SqlSchema.js
1314
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlSchema.js
1273
1315
  const findAll = (options) => {
1274
1316
  const encodeRequest = encodeEffect(options.Request);
1275
1317
  const decode = decodeUnknownEffect(mutable(ArraySchema(options.Result)));
1276
1318
  return (request) => flatMap(flatMap(encodeRequest(request), options.execute), decode);
1277
1319
  };
1278
1320
  //#endregion
1279
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/sql/SqlModel.js
1321
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/SqlModel.js
1280
1322
  const makeResolvers = (Model, options) => gen(function* () {
1281
1323
  const sql = yield* SqlClient;
1282
1324
  const idSchema = Model.fields[options.idColumn];
@@ -1406,18 +1448,18 @@ const layer$4 = effect(ChunkRepo, gen(function* () {
1406
1448
  insert: (insert) => request(insert, insertResolver).pipe(catchTags({
1407
1449
  SchemaError: die,
1408
1450
  ResultLengthMismatch: die
1409
- }, (reason) => fail$1(new ChunkRepoError({ reason })))),
1451
+ }, (reason) => fail(new ChunkRepoError({ reason })))),
1410
1452
  findById: (id) => request(id, findByIdResolver).pipe(catchTags({
1411
1453
  SchemaError: die,
1412
- SqlError: (reason) => fail$1(new ChunkRepoError({ reason }))
1454
+ SqlError: (reason) => fail(new ChunkRepoError({ reason }))
1413
1455
  })),
1414
1456
  exists: (hash) => request(hash, exists).pipe(map((result) => result.id), catchNoSuchElement, catchTags({
1415
- SqlError: (reason) => fail$1(new ChunkRepoError({ reason })),
1457
+ SqlError: (reason) => fail(new ChunkRepoError({ reason })),
1416
1458
  SchemaError: die
1417
1459
  })),
1418
1460
  search: fn("ChunkRepo.search")(function* (options) {
1419
1461
  return yield* search(options).pipe(catchTags({
1420
- SqlError: (reason) => fail$1(new ChunkRepoError({ reason })),
1462
+ SqlError: (reason) => fail(new ChunkRepoError({ reason })),
1421
1463
  SchemaError: die
1422
1464
  }));
1423
1465
  }),
@@ -1890,7 +1932,7 @@ const layer$3 = effect(CodeChunker, gen(function* () {
1890
1932
  });
1891
1933
  }));
1892
1934
  //#endregion
1893
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/FiberHandle.js
1935
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/FiberHandle.js
1894
1936
  const TypeId$1 = "~effect/FiberHandle";
1895
1937
  const isFiberHandle = (u) => hasProperty(u, TypeId$1);
1896
1938
  const Proto = {
@@ -1955,12 +1997,12 @@ const run$1 = function() {
1955
1997
  const runImpl = (self, effect, options) => withFiber((parent) => {
1956
1998
  if (self.state._tag === "Closed") return interrupt;
1957
1999
  else if (self.state.fiber !== void 0 && options?.onlyIfMissing === true) return sync(constInterruptedFiber);
1958
- const fiber = runForkWith(parent.context)(effect);
2000
+ const fiber = forkUnsafe(parent, effect, options?.startImmediately ?? true, true);
1959
2001
  setUnsafe(self, fiber, options);
1960
2002
  return succeed(fiber);
1961
2003
  });
1962
2004
  //#endregion
1963
- //#region node_modules/.pnpm/@effect+sql-sqlite-node@https+++pkg.pr.new+Effect-TS+effect+@effect+sql-sqlite-node@b30_35f9412091f754d7278f29eda52a67a4/node_modules/@effect/sql-sqlite-node/dist/SqliteClient.js
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
1964
2006
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
1965
2007
  const MAX_BUSY_TIMEOUT = 2147483647;
1966
2008
  const TypeId = "~@effect/sql-sqlite-node/SqliteClient";
@@ -1968,7 +2010,7 @@ const SqliteClient = Service("@effect/sql-sqlite-node/SqliteClient");
1968
2010
  const make$1 = (options) => gen(function* () {
1969
2011
  const compiler = makeCompilerSqlite(options.transformQueryNames);
1970
2012
  const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
1971
- const makeConnection = gen(function* () {
2013
+ const connection = yield* gen(function* () {
1972
2014
  const scope$1 = yield* scope;
1973
2015
  const db = new DatabaseSync(options.filename, {
1974
2016
  readOnly: options.readonly ?? false,
@@ -2035,6 +2077,7 @@ const make$1 = (options) => gen(function* () {
2035
2077
  }, (statement) => sync(() => statement.setReturnArrays(false)));
2036
2078
  const runValuesUnprepared = (sql, params) => flatMap(prepare(sql), (statement) => runStatementValuesUnprepared(statement, params));
2037
2079
  return identity({
2080
+ isTransaction: () => db.isTransaction,
2038
2081
  execute(sql, params, transformRows) {
2039
2082
  return transformRows ? map(run(sql, params), transformRows) : run(sql, params);
2040
2083
  },
@@ -2076,18 +2119,16 @@ const make$1 = (options) => gen(function* () {
2076
2119
  }
2077
2120
  });
2078
2121
  });
2079
- const semaphore = yield* make$12(1);
2080
- const connection = yield* makeConnection;
2081
- const acquirer = semaphore.withPermits(1)(succeed(connection));
2082
- const transactionAcquirer = uninterruptibleMask((restore) => {
2083
- const fiber = getCurrent();
2084
- const scope = getUnsafe(fiber.context, Scope);
2085
- return as(tap(restore(semaphore.take(1)), () => addFinalizer(scope, semaphore.release(1))), connection);
2122
+ const { acquirer, onCommitFailure, transactionAcquirer } = makeSqliteAcquirers({
2123
+ connection: succeed(connection),
2124
+ semaphore: yield* make$12(1),
2125
+ isTransaction: (conn) => conn.isTransaction()
2086
2126
  });
2087
2127
  return Object.assign(yield* make$5({
2088
2128
  acquirer,
2089
2129
  compiler,
2090
2130
  transactionAcquirer,
2131
+ onCommitFailure,
2091
2132
  releaseSavepoint: (name) => `RELEASE SAVEPOINT ${name}`,
2092
2133
  beginTransaction: options.readonly === true ? "BEGIN" : "BEGIN IMMEDIATE",
2093
2134
  spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
@@ -2111,7 +2152,7 @@ const sqliteCauseWithErrno = (cause) => {
2111
2152
  return Object.assign(cause, { errno: errcode });
2112
2153
  };
2113
2154
  //#endregion
2114
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/sql/Migrator.js
2155
+ //#region node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/sql/Migrator.js
2115
2156
  var __rewriteRelativeImportExtension = void 0 && (void 0).__rewriteRelativeImportExtension || function(path, preserveJsx) {
2116
2157
  if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
2117
2158
  return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
@@ -2154,10 +2195,10 @@ const make = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, tab
2154
2195
  name,
2155
2196
  createdAt: created_at
2156
2197
  })));
2157
- const loadMigration = ([id, name, load]) => catchDefect(load, (_) => fail$1(new MigrationError({
2198
+ const loadMigration = ([id, name, load]) => catchDefect(load, (_) => fail(new MigrationError({
2158
2199
  kind: "ImportError",
2159
2200
  message: `Could not import migration "${id}_${name}"\n\n${_}`
2160
- }))).pipe(flatMap((_) => isEffect(_) ? succeed(_) : _.default ? succeed(_.default?.default ?? _.default) : fail$1(new MigrationError({
2201
+ }))).pipe(flatMap((_) => isEffect(_) ? succeed(_) : _.default ? succeed(_.default?.default ?? _.default) : fail(new MigrationError({
2161
2202
  kind: "ImportError",
2162
2203
  message: `Default export not found for migration "${id}_${name}"`
2163
2204
  }))), filterOrFail((_) => isEffect(_), () => new MigrationError({
@@ -2204,7 +2245,7 @@ const make = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, tab
2204
2245
  return required.map(([id, name]) => [id, name]);
2205
2246
  });
2206
2247
  yield* ensureMigrationsTable;
2207
- const completed = yield* pipe(sql.withTransaction(run), catchTag("MigrationError", (_) => _.kind === "Locked" ? as(logDebug(_.message), []) : fail$1(_)));
2248
+ const completed = yield* pipe(sql.withTransaction(run), catchTag("MigrationError", (_) => _.kind === "Locked" ? as(logDebug(_.message), []) : fail(_)));
2208
2249
  if (schemaDirectory && completed.length > 0) yield* dumpSchema(`${schemaDirectory}/_schema.sql`, table).pipe(catchCause((cause) => logInfo("Could not dump schema", cause)));
2209
2250
  return completed;
2210
2251
  });
@@ -2216,7 +2257,7 @@ const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishO
2216
2257
  succeed(migrations[key])
2217
2258
  ]), sort(migrationOrder), succeed);
2218
2259
  //#endregion
2219
- //#region node_modules/.pnpm/@effect+sql-sqlite-node@https+++pkg.pr.new+Effect-TS+effect+@effect+sql-sqlite-node@b30_35f9412091f754d7278f29eda52a67a4/node_modules/@effect/sql-sqlite-node/dist/SqliteMigrator.js
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
2220
2261
  const run = make({});
2221
2262
  const layer$1 = (options) => effectDiscard(run(options));
2222
2263
  //#endregion
@@ -2360,4 +2401,4 @@ const layer = (options) => effect(SemanticSearch, gen(function* () {
2360
2401
  //#endregion
2361
2402
  export { SemanticSearch, chunkEmbeddingInput, layer, makeEmbeddingResolver, maybeRemoveFile, maybeUpdateFile };
2362
2403
 
2363
- //# sourceMappingURL=SemanticSearch-BJGnYhFt.mjs.map
2404
+ //# sourceMappingURL=SemanticSearch-cqSnq90g.mjs.map