clanka 0.24.4 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Agent.js +1 -1
- package/dist/Agent.js.map +1 -1
- package/dist/AgentCallerConfig.test.js +8 -2
- package/dist/AgentCallerConfig.test.js.map +1 -1
- package/dist/AgentExecutor.js +1 -1
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.js +14 -0
- package/dist/AgentExecutor.test.js.map +1 -1
- package/dist/AgentTools.d.ts +112 -88
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +43 -35
- package/dist/AgentTools.js.map +1 -1
- package/dist/bin/{AiError-fiHIiGOy.mjs → AiError-CsvdOsKR.mjs} +67 -43
- package/dist/bin/Latch-B3e9629m.mjs +5 -0
- package/dist/bin/{McpClient-CXwyRd_3.mjs → McpClient-BCxZZgnA.mjs} +1 -1
- package/dist/bin/{OutputFormatter-B8yF7iiq.mjs → OutputFormatter-ByMjyBhe.mjs} +2 -2
- package/dist/bin/{Schema-D629S5yu.mjs → Schema-BfUmMefy.mjs} +224 -163
- package/dist/bin/{SemanticSearch-BlcfFvPr.mjs → SemanticSearch-DMzIsoZb.mjs} +68 -55
- package/dist/bin/cli.mjs +506 -381
- package/dist/bin/{helpers-CljL9OKa.mjs → helpers-Bb68A2Sv.mjs} +2 -2
- package/dist/bin/{index.min-ClUfQ5ji.mjs → index.min-CuA3AuA-.mjs} +1448 -1348
- package/dist/bin/{rolldown-runtime-5zChB7MF.mjs → rolldown-runtime-CXhmmSW5.mjs} +4 -4
- package/dist/bin/{server-HlLriZxF.mjs → server-D4nrvZHH.mjs} +2 -2
- package/dist/bin/{turndown.cjs-C2WBxeA-.mjs → turndown.cjs-CwE2EFNQ.mjs} +15 -10
- package/dist/bin/{types-LcwjLVkt.mjs → types-N9Z-HYP0.mjs} +1 -1
- package/dist/bin/{upgrade-E_f-q2h8.mjs → upgrade-t590zYhO.mjs} +4 -4
- package/package.json +15 -15
- package/src/Agent.ts +1 -1
- package/src/AgentCallerConfig.test.ts +39 -28
- package/src/AgentExecutor.test.ts +38 -0
- package/src/AgentExecutor.ts +1 -1
- package/src/AgentTools.ts +59 -44
- package/dist/bin/Latch-D1909CI6.mjs +0 -5
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { $
|
|
1
|
+
import { $i as ignore, $l as fromInputUnsafe, $o as NoSuchElementError, $s as TracerTimingEnabled$1, Ai as delay, Ao as size, B as String$1, Bd as identity, Ci as catchNoSuchElement, Cn as evolve, Co as empty$1, Cs as reasonAnnotations, Dc as contextWith$1, Di as catch_, Do as make$8, Ds as effect, E as Natural, Ei as catchTags, Eo as isEmpty, Fa as retry, Fd as constUndefined, Fi as fail, Fl as sort, Fu as isNone, Gc as makeSpanUnsafe, Gi as forever, Gs as close, H as Struct$2, Hd as pipe, Hi as fn, Hs as Scope, Hu as some, Ia as runFork, Ii as failCause$1, Is as provide$1, Iu as isSome, Jo as Clock, Jr as now, Js as make$7, Ju as Prototype, K as TaggedError, Ka as succeed, Kr as formatIsoDate, Ku as make$10, La as runForkWith, Lc as fiberJoin, Lo as spaced, Ls as provideMerge, Lu as map$3, M as Number$1, N as Option, Na as request$1, Oa as provideContext, Oc as endSpan, Oi as context, Oo as remove, Os as effectContext, Ou as flatten, P as OptionFromNullOr, Pc as fiberInterrupt, Qa as tapCause, Qi as gen, Rd as dual, Ri as filterOrFail, Ru as match, Sd as isNotNull, Si as catchIf, Sl as fromIterable, Su as omit, Ta as orElseSucceed, Ti as catchTag, Tl as isArrayNonEmpty, To as get$2, Tu as filter, Ud as pipeArguments, Ui as fnUntraced, Us as addFinalizer, Va as scoped, Vc as forkUnsafe, Wa as serviceOption, Wi as forEach, Wu as Number$2, Xa as sync, Xc as succeed$1, Xo as monotonicTimeNanos, Xs as provide, Xu as PipeInspectableProto, Ya as suspend, Yi as forkScoped, Yr as removeTime, Za as tap, _c as isFailure, _d as symbol, _i as catchCause, _o as withSpan, _r as transform, _s as isFailReason, a as BooleanFromBit, ad as withFiber$1, ai as acquireUseRelease, al as ParentSpan, au as millis, ba as onExit, bc as void_$3, bd as hasProperty, bn as withConstructorDefault, cc as makeUnsafe$2, ci as andThen, cs as filterInterruptors, cu as toMillis, d as DateTimeUtcFromMillis, di as as, dl as compose, dn as optional, do as void_$1, dt as decodeTo, du as Service, ea as ignoreCause, f as DateTimeUtcFromString, fc as fail$1, fl as has, fn as optionalKey, fr as transformOptional, fs as hasInterruptsOnly, ft as decodeUnknownEffect, fu as add, ga as matchCauseEffect, gd as equals, gl as empty, gu as getOrUndefined, ha as matchCauseEager, hd as byReferenceUnsafe, ho as withLogSpan, ht as encodeEffect, hu as getOption, i as Boolean, ia as logDebug, ic as into, ii as acquireRelease, io as try_, is as combine, j as NullOr, ji as die, jl as map$2, ka as provideService, kc as exitHasInterrupts, ki as contextWith, ko as set, ks as effectDiscard, ku as fromNullishOr, l as DateTimeUtc, la as makeSpanScoped, li as annotateCurrentSpan, ll as TaggedError$1, lu as zero, mo as withFiber, mr as map$1, mu as get$1, n as ArraySchema, nl as void_$2, nu as isFinite, od as assignProperty, oo as uninterruptible, ot as brand, ou as minutes, p as Defect, pa as mapError, pc as failCause, pi as asVoid, pl as toPredicate, pr as dateTimeUtcFromInput, qc as onExitUnsafe, ra as isEffect, rl as TracerTimingEnabled, ro as tryPromise, rt as Union$2, ru as isZero, s as Class$1, sa as logInfo, si as all, so as uninterruptibleMask, su as seconds, ta as interrupt, tc as doneUnsafe, tl as updateContext, tn as isSchema, tu as infinity, u as DateTimeUtcFromDate, ua as map, ui as annotateLogs, un as mutable, uo as useSpan, ur as transform$1, us as fromReasons, uu as Reference, vc as isSuccess, vd as hash, vu as getUnsafe, wa as orDie, wo as forEach$1, xa as onExitPrimitive, xc as ClockRef, xl as flatMapNullishOr, xo as Class$2, xu as merge, ya as onError, yc as succeed$2, yd as symbol$1, yi as catchDefect, yn as toType, ys as makeDieReason, yt as instanceOf, yu as make$9, zd as flow, zi as flatMap, zu as none } from "./Schema-BfUmMefy.mjs";
|
|
2
2
|
import { D as Path, E as Console, O as FileSystem, T as ChildProcessSpawner, a as makeGrouped, f as SemanticSearch, h as map$4, i as batchN, m as maybeUpdateFile, n as EmbeddingModel, o as setDelay, p as maybeRemoveFile, r as EmbeddingRequest, s as withSpan$1, t as Dimensions, w as make$11 } from "./cli.mjs";
|
|
3
|
-
import { $t as offerUnsafe, Ht as makeUnsafe$3, It as unwrap, J as fromArrayEffect, Jt as failCauseUnsafe, Mt as tap$1, P as die$1, U as flatMap$1, Vt as make$13, Yt as make$12, gt as provideService$1, hn as runIn, mn as join$1, pn as interruptAllAs, q as fromArray, tt as fromQueue, vt as runCollect, yt as runDrain } from "./AiError-
|
|
3
|
+
import { $t as offerUnsafe, Ht as makeUnsafe$3, It as unwrap, J as fromArrayEffect, Jt as failCauseUnsafe, Mt as tap$1, P as die$1, U as flatMap$1, Vt as make$13, Yt as make$12, gt as provideService$1, hn as runIn, mn as join$1, pn as interruptAllAs, q as fromArray, tt as fromQueue, vt as runCollect, yt as runDrain } from "./AiError-CsvdOsKR.mjs";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { DatabaseSync, backup } from "node:sqlite";
|
|
6
6
|
import TreeSitter from "tree-sitter";
|
|
7
7
|
import TreeSitterJavaScript from "tree-sitter-javascript";
|
|
8
8
|
import TreeSitterTypeScript from "tree-sitter-typescript";
|
|
9
9
|
import { getLoadablePath } from "sqlite-vec";
|
|
10
|
-
// node_modules/.pnpm/effect@4.1.
|
|
10
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/internal/sql.js
|
|
11
11
|
const CurrentTransactionService = Reference("effect/sql/CurrentTransactionService", { defaultValue: () => void 0 });
|
|
12
|
-
|
|
12
|
+
const waitClock = (fiber) => fiber.getRef(TracerTimingEnabled) ? fiber.getRef(Clock) : void 0;
|
|
13
|
+
const recordConnectionWait = (span, clock) => span.attribute("db.client.connection.wait_time_ms", Number(clock.currentTimeNanosUnsafe() - span.status.startTime) / 1e6);
|
|
14
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/reactivity/Reactivity.js
|
|
13
15
|
const TypeId$6 = "~effect/reactivity/Reactivity";
|
|
14
16
|
const Reactivity = Service("effect/reactivity/Reactivity");
|
|
15
17
|
const make$6 = sync(() => {
|
|
@@ -130,7 +132,7 @@ const keysToHashes = (keys, f) => {
|
|
|
130
132
|
for (let i = 0; i < ids.length; i++) f(`${key}:${stringOrHash(ids[i])}`);
|
|
131
133
|
}
|
|
132
134
|
};
|
|
133
|
-
// node_modules/.pnpm/effect@4.1.
|
|
135
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/sql/SqlError.js
|
|
134
136
|
const TypeId$5 = "~effect/sql/SqlError";
|
|
135
137
|
const ReasonTypeId = "~effect/sql/SqlError/Reason";
|
|
136
138
|
const ReasonFields = {
|
|
@@ -303,7 +305,7 @@ var ResultLengthMismatch = class extends TaggedError("effect/sql/ResultLengthMis
|
|
|
303
305
|
return `Expected ${this.expected} results but got ${this.actual}`;
|
|
304
306
|
}
|
|
305
307
|
};
|
|
306
|
-
// node_modules/.pnpm/effect@4.1.
|
|
308
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/sql/Statement.js
|
|
307
309
|
const FragmentTypeId = Symbol.for("~effect/sql/Statement/Fragment");
|
|
308
310
|
const SegmentTypeId = Symbol.for("~effect/sql/Statement/Segment");
|
|
309
311
|
const fragment = (segments) => ({
|
|
@@ -366,15 +368,13 @@ const recordUpdateHelperSingle = (value, omit) => Object.assign(Object.create(Re
|
|
|
366
368
|
returningIdentifier: void 0
|
|
367
369
|
});
|
|
368
370
|
const make$5 = (acquirer, compiler, spanAttributes, transformRows, borrower) => {
|
|
369
|
-
const cache = transformRows === void 0 ? constructorCache.noTransforms : constructorCache.transforms;
|
|
370
|
-
if (cache.has(acquirer)) return cache.get(acquirer);
|
|
371
371
|
const self = Object.assign(function sql(strings, ...args) {
|
|
372
372
|
if (typeof strings === "string") return identifier(strings);
|
|
373
|
-
else if (Array.isArray(strings) && "raw" in strings) return
|
|
373
|
+
else if (Array.isArray(strings) && "raw" in strings) return makeUnsafe$1(templateSegments(strings, args), acquirer, compiler, spanAttributes, transformRows, borrower, self);
|
|
374
374
|
throw "absurd";
|
|
375
375
|
}, {
|
|
376
376
|
unsafe(sql, params) {
|
|
377
|
-
return makeUnsafe$1([literal(sql, params)], acquirer, compiler, spanAttributes, transformRows, borrower);
|
|
377
|
+
return makeUnsafe$1([literal(sql, params)], acquirer, compiler, spanAttributes, transformRows, borrower, self);
|
|
378
378
|
},
|
|
379
379
|
literal(sql) {
|
|
380
380
|
return fragment([literal(sql)]);
|
|
@@ -400,14 +400,9 @@ const make$5 = (acquirer, compiler, spanAttributes, transformRows, borrower) =>
|
|
|
400
400
|
return options[compiler.dialect] !== void 0 ? options[compiler.dialect]() : options.orElse();
|
|
401
401
|
}
|
|
402
402
|
});
|
|
403
|
-
cache.set(acquirer, self);
|
|
404
403
|
return self;
|
|
405
404
|
};
|
|
406
|
-
const
|
|
407
|
-
transforms: new WeakMap(),
|
|
408
|
-
noTransforms: new WeakMap()
|
|
409
|
-
};
|
|
410
|
-
const statement = (acquirer, compiler, strings, args, spanAttributes, transformRows, borrower) => {
|
|
405
|
+
const templateSegments = (strings, args) => {
|
|
411
406
|
const segments = strings[0].length > 0 ? [literal(strings[0])] : [];
|
|
412
407
|
for (let i = 0; i < args.length; i++) {
|
|
413
408
|
const arg = args[i];
|
|
@@ -416,7 +411,7 @@ const statement = (acquirer, compiler, strings, args, spanAttributes, transformR
|
|
|
416
411
|
else segments.push(parameter(arg));
|
|
417
412
|
if (strings[i + 1].length > 0) segments.push(literal(strings[i + 1]));
|
|
418
413
|
}
|
|
419
|
-
return
|
|
414
|
+
return segments;
|
|
420
415
|
};
|
|
421
416
|
function join(lit, addParens = true, fallback = "") {
|
|
422
417
|
const literalStatement = literal(lit);
|
|
@@ -690,13 +685,12 @@ const spanName = (spanAttributes) => {
|
|
|
690
685
|
return isNonEmptyString(system) ? system : "sql.execute";
|
|
691
686
|
};
|
|
692
687
|
const ATTR_DB_QUERY_TEXT = "db.query.text";
|
|
693
|
-
const ATTR_DB_CLIENT_CONNECTION_WAIT_TIME = "db.client.connection.wait_time_ms";
|
|
694
688
|
const ATTR_SQL_METHOD = "effect.sql.method";
|
|
695
689
|
const spanAttribute = (spanAttributes, key) => {
|
|
696
690
|
for (let i = spanAttributes.length - 1; i >= 0; i--) if (spanAttributes[i][0] === key) return spanAttributes[i][1];
|
|
697
691
|
};
|
|
698
692
|
const isNonEmptyString = (u) => typeof u === "string" && u.length > 0;
|
|
699
|
-
const makeUnsafe$1 = (segments, acquirer, compiler, spanAttributes, transformRows, borrower) => {
|
|
693
|
+
const makeUnsafe$1 = (segments, acquirer, compiler, spanAttributes, transformRows, borrower, sql) => {
|
|
700
694
|
const self = Object.create(StatementProto);
|
|
701
695
|
self.segments = segments;
|
|
702
696
|
self.acquirer = acquirer;
|
|
@@ -704,6 +698,7 @@ const makeUnsafe$1 = (segments, acquirer, compiler, spanAttributes, transformRow
|
|
|
704
698
|
self.spanAttributes = spanAttributes;
|
|
705
699
|
self.transformRows = transformRows;
|
|
706
700
|
self.borrower = borrower;
|
|
701
|
+
self.sql = sql;
|
|
707
702
|
return self;
|
|
708
703
|
};
|
|
709
704
|
const StatementProto = {
|
|
@@ -764,7 +759,7 @@ const StatementProto = {
|
|
|
764
759
|
evaluate(fiber) {
|
|
765
760
|
const span = makeSpanUnsafe(fiber, spanName(this.spanAttributes), { kind: "client" });
|
|
766
761
|
const clock = fiber.getRef(Clock);
|
|
767
|
-
const timingEnabled = fiber.getRef(TracerTimingEnabled);
|
|
762
|
+
const timingEnabled = fiber.getRef(TracerTimingEnabled$1);
|
|
768
763
|
return onExit(this.withConnectionSpan("execute", (connection, sql, params) => connection.execute(sql, params, this.transformRows), false, span), (exit) => endSpan(span, exit, clock, timingEnabled));
|
|
769
764
|
}
|
|
770
765
|
}),
|
|
@@ -781,12 +776,10 @@ const StatementProto = {
|
|
|
781
776
|
};
|
|
782
777
|
}
|
|
783
778
|
};
|
|
784
|
-
const waitClock = (fiber) => fiber.getRef(TracerTimingEnabled) ? fiber.getRef(Clock) : void 0;
|
|
785
|
-
const recordConnectionWait = (span, clock) => span.attribute(ATTR_DB_CLIENT_CONNECTION_WAIT_TIME, Number(clock.currentTimeNanosUnsafe() - span.status.startTime) / 1e6);
|
|
786
779
|
const withStatement = (self, span, f) => withFiber((fiber) => {
|
|
787
780
|
const transform = fiber.getRef(CurrentTransformer);
|
|
788
781
|
if (transform === void 0) return f(self, fiber);
|
|
789
|
-
return flatMap(transform(self, make$5(self.acquirer, self.compiler, self.spanAttributes, self.transformRows, self.borrower), fiber, span), (statement) => f(statement, fiber));
|
|
782
|
+
return flatMap(transform(self, self.sql ?? make$5(self.acquirer, self.compiler, self.spanAttributes, self.transformRows, self.borrower), fiber, span), (statement) => f(statement, fiber));
|
|
790
783
|
});
|
|
791
784
|
const isSegment = (u) => hasProperty(u, SegmentTypeId);
|
|
792
785
|
function convertLiteralOrFragment(clause) {
|
|
@@ -829,16 +822,17 @@ function in_() {
|
|
|
829
822
|
const neverFragment = fragment([literal("1=0")]);
|
|
830
823
|
const emptyInKeyword = /\b(NOT\s+)?IN\s*$/i;
|
|
831
824
|
const isInLineComment = (sql, index) => sql.lastIndexOf("--", index) > sql.lastIndexOf("\n", index);
|
|
832
|
-
// node_modules/.pnpm/effect@4.1.
|
|
825
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/sql/SqlClient.js
|
|
833
826
|
const TypeId$4 = "~effect/sql/SqlClient";
|
|
834
827
|
const SqlClient = Service("effect/sql/SqlClient");
|
|
835
828
|
let clientIdCounter = 0;
|
|
836
829
|
let transactionSemaphoreIdCounter = 0;
|
|
830
|
+
const ATTR_DB_OPERATION_NAME = "db.operation.name";
|
|
837
831
|
const make$4 = fnUntraced(function* (options) {
|
|
838
832
|
const transactionService = options.transactionService ?? TransactionConnection(clientIdCounter++);
|
|
839
833
|
const getConnection = flatMap(serviceOption(transactionService), match({
|
|
840
834
|
onNone: () => options.acquirer,
|
|
841
|
-
onSome:
|
|
835
|
+
onSome: activeTransactionConnection
|
|
842
836
|
}));
|
|
843
837
|
const beginTransaction = options.beginTransaction ?? "BEGIN";
|
|
844
838
|
const commit = options.commit ?? "COMMIT";
|
|
@@ -855,7 +849,7 @@ const make$4 = fnUntraced(function* (options) {
|
|
|
855
849
|
transactionService,
|
|
856
850
|
spanAttributes: options.spanAttributes,
|
|
857
851
|
acquireConnection: (restore) => restore(transactionAcquirer),
|
|
858
|
-
begin: (conn, statement) => statement === void 0 ? control(conn, beginTransaction) : unprepared(conn, statement),
|
|
852
|
+
begin: options.begin ?? ((conn, statement) => statement === void 0 ? control(conn, beginTransaction) : unprepared(conn, statement)),
|
|
859
853
|
savepoint: (conn, id) => control(conn, savepoint(`effect_sql_${id}`)),
|
|
860
854
|
releaseSavepoint: releaseSavepoint ? (conn, id) => cleanup(conn, releaseSavepoint(`effect_sql_${id}`)) : void 0,
|
|
861
855
|
commit: typeof commit === "string" ? (conn) => control(conn, commit) : commit,
|
|
@@ -867,7 +861,7 @@ const make$4 = fnUntraced(function* (options) {
|
|
|
867
861
|
const reactivity = yield* Reactivity;
|
|
868
862
|
const borrower = options.borrower === void 0 ? void 0 : (f) => flatMap(serviceOption(transactionService), match({
|
|
869
863
|
onNone: () => options.borrower(f),
|
|
870
|
-
onSome: (
|
|
864
|
+
onSome: (transaction) => flatMap(activeTransactionConnection(transaction), f)
|
|
871
865
|
}));
|
|
872
866
|
const client = Object.assign(make$5(getConnection, options.compiler, options.spanAttributes, options.transformRows, borrower), {
|
|
873
867
|
[TypeId$4]: TypeId$4,
|
|
@@ -878,7 +872,6 @@ const make$4 = fnUntraced(function* (options) {
|
|
|
878
872
|
reserve: transactionAcquirer,
|
|
879
873
|
driver: options.driver,
|
|
880
874
|
withoutTransforms() {
|
|
881
|
-
if (options.transformRows === void 0) return this;
|
|
882
875
|
const statement = make$5(getConnection, options.compiler.withoutTransform, options.spanAttributes, void 0, borrower);
|
|
883
876
|
const client = Object.assign(statement, {
|
|
884
877
|
...this,
|
|
@@ -932,6 +925,15 @@ const isNoTransactionError = (error) => {
|
|
|
932
925
|
};
|
|
933
926
|
const failuresToDefects = (cause) => fromReasons(cause.reasons.map((reason) => isFailReason(reason) ? makeDieReason(reason.error).annotate(reasonAnnotations(reason)) : reason));
|
|
934
927
|
const afterCommitBuffers = new WeakMap();
|
|
928
|
+
const hasEnded = (buffer) => {
|
|
929
|
+
for (; buffer !== void 0; buffer = buffer.parent) if (!buffer.open) return true;
|
|
930
|
+
return false;
|
|
931
|
+
};
|
|
932
|
+
const transactionEnded = suspend(() => fail(new SqlError({ reason: new UnknownError({
|
|
933
|
+
cause: void 0,
|
|
934
|
+
message: "SqlClient: the transaction has already ended"
|
|
935
|
+
}) })));
|
|
936
|
+
const activeTransactionConnection = (transaction) => hasEnded(afterCommitBuffers.get(transaction)) ? transactionEnded : succeed(transaction[0]);
|
|
935
937
|
const runAfterCommit = (effect) => ignoreCause(effect, {
|
|
936
938
|
log: "Unhandled",
|
|
937
939
|
message: "Unhandled error in SqlClient.afterCommit callback"
|
|
@@ -940,13 +942,14 @@ const makeAfterCommit = (transactionService) => (effect) => withFiber((fiber) =>
|
|
|
940
942
|
const transaction = getOrUndefined(fiber.context, transactionService);
|
|
941
943
|
const buffer = transaction && afterCommitBuffers.get(transaction);
|
|
942
944
|
if (buffer === void 0) return runAfterCommit(effect);
|
|
943
|
-
|
|
945
|
+
if (hasEnded(buffer)) return die(new Error("SqlClient.afterCommit: the transaction has already ended"));
|
|
944
946
|
buffer.callbacks.push(provideContext(effect, omit(transactionService)(fiber.context)));
|
|
945
947
|
return void_$1;
|
|
946
948
|
});
|
|
947
949
|
const makeWithTransaction = (options) => {
|
|
948
950
|
const transactionSemaphore = Service(`effect/sql/SqlClient/TransactionSemaphore/${transactionSemaphoreIdCounter++}`);
|
|
949
951
|
const afterCommit = makeAfterCommit(options.transactionService);
|
|
952
|
+
const target = spanTarget(options.spanAttributes);
|
|
950
953
|
const deferInvalidations = (reactivity) => {
|
|
951
954
|
const invalidate = (keys) => afterCommit(sync(() => reactivity.invalidateUnsafe(keys)));
|
|
952
955
|
return {
|
|
@@ -959,9 +962,20 @@ const makeWithTransaction = (options) => {
|
|
|
959
962
|
for (const [key, value] of options.spanAttributes) span.attribute(key, value);
|
|
960
963
|
const services = fiber.context;
|
|
961
964
|
const reactivity = getOrUndefined(services, Reactivity);
|
|
962
|
-
const
|
|
965
|
+
const waitedClock = fiber.cache.tracerEnabled && fiber.getRef(SpanPropagationEnabled) ? waitClock(fiber) : void 0;
|
|
966
|
+
const control = (operation, effect) => useSpan(target === void 0 ? operation : `${operation} ${target}`, {
|
|
967
|
+
kind: "client",
|
|
968
|
+
parent: span
|
|
969
|
+
}, (controlSpan) => {
|
|
970
|
+
for (const [key, value] of options.spanAttributes) controlSpan.attribute(key, value);
|
|
971
|
+
controlSpan.attribute(ATTR_DB_OPERATION_NAME, operation);
|
|
972
|
+
return effect;
|
|
973
|
+
});
|
|
963
974
|
const connOption = getOption(services, options.transactionService);
|
|
964
|
-
const conn = connOption._tag === "Some" ?
|
|
975
|
+
const conn = connOption._tag === "Some" ? map(suspend(() => activeTransactionConnection(connOption.value)), (conn) => [void 0, conn]) : flatMap(make$7(), (scope) => provide(options.acquireConnection(restore), scope).pipe(provideService(ParentSpan, span), map((conn) => {
|
|
976
|
+
if (waitedClock !== void 0) recordConnectionWait(span, waitedClock);
|
|
977
|
+
return [scope, conn];
|
|
978
|
+
}), onError((cause) => close(scope, failCause(cause)))));
|
|
965
979
|
const id = connOption._tag === "Some" ? connOption.value[1] + 1 : 0;
|
|
966
980
|
const buffer = {
|
|
967
981
|
callbacks: [],
|
|
@@ -969,28 +983,28 @@ const makeWithTransaction = (options) => {
|
|
|
969
983
|
open: true
|
|
970
984
|
};
|
|
971
985
|
let committed = false;
|
|
972
|
-
const
|
|
986
|
+
const start = (conn) => id === 0 ? control("BEGIN", options.begin(conn, fiber.getRef(BeginTransaction))) : control("SAVEPOINT", options.savepoint(conn, id));
|
|
987
|
+
const transaction = flatMap(conn, ([scope, conn]) => start(conn).pipe(flatMap(() => {
|
|
973
988
|
const level = [conn, id];
|
|
974
989
|
afterCommitBuffers.set(level, buffer);
|
|
975
990
|
return onExitPrimitive(provideContext(restore(effect), services.pipe(add(options.transactionService, level), add(CurrentTransactionService, options.transactionService), reactivity ? add(Reactivity, deferInvalidations(reactivity)) : identity, add(transactionSemaphore, makeUnsafe$3(1)), add(ParentSpan, span))), (exit) => {
|
|
991
|
+
buffer.open = false;
|
|
992
|
+
if (hasEnded(buffer.parent)) return isSuccess(exit) ? transactionEnded : exit;
|
|
976
993
|
let effect;
|
|
977
994
|
if (isSuccess(exit)) {
|
|
978
995
|
if (id === 0) {
|
|
979
|
-
span.event("effect.sql.transaction.commit", clock.currentTimeNanosUnsafe());
|
|
980
996
|
const onCommitFailure = options.onCommitFailure;
|
|
981
|
-
|
|
997
|
+
const commit = control("COMMIT", options.commit(conn));
|
|
998
|
+
effect = onCommitFailure ? catchCause(commit, (commitCause) => matchCauseEffect(control("ROLLBACK", onCommitFailure(conn)), {
|
|
982
999
|
onFailure: (cleanupCause) => failCause$1(failuresToDefects(combine(commitCause, cleanupCause))),
|
|
983
1000
|
onSuccess: () => failCause$1(commitCause)
|
|
984
|
-
})) :
|
|
985
|
-
} else
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
span.event("effect.sql.transaction.rollback", clock.currentTimeNanosUnsafe());
|
|
991
|
-
effect = orDie(id > 0 ? options.rollbackSavepoint(conn, id) : options.rollback(conn));
|
|
1001
|
+
})) : commit;
|
|
1002
|
+
} else effect = void_$1;
|
|
1003
|
+
} else effect = orDie(id > 0 ? control("ROLLBACK TO SAVEPOINT", options.rollbackSavepoint(conn, id)) : control("ROLLBACK", options.rollback(conn)));
|
|
1004
|
+
if (id > 0 && options.releaseSavepoint) {
|
|
1005
|
+
const release = orDie(control("RELEASE SAVEPOINT", options.releaseSavepoint(conn, id)));
|
|
1006
|
+
effect = flatMap(effect, () => hasEnded(buffer.parent) ? void_$1 : release);
|
|
992
1007
|
}
|
|
993
|
-
if (id > 0 && options.releaseSavepoint) effect = andThen(effect, orDie(options.releaseSavepoint(conn, id)));
|
|
994
1008
|
return flatMap(effect, () => {
|
|
995
1009
|
committed = isSuccess(exit);
|
|
996
1010
|
return exit;
|
|
@@ -998,7 +1012,6 @@ const makeWithTransaction = (options) => {
|
|
|
998
1012
|
}, true);
|
|
999
1013
|
}), scope ? (eff) => onExitPrimitive(eff, (exit) => close(scope, exit), true) : identity));
|
|
1000
1014
|
const settled = onExitPrimitive(transaction, () => {
|
|
1001
|
-
buffer.open = false;
|
|
1002
1015
|
if (!committed || buffer.callbacks.length === 0) return;
|
|
1003
1016
|
if (buffer.parent !== void 0) {
|
|
1004
1017
|
buffer.parent.callbacks.push(...buffer.callbacks);
|
|
@@ -1006,13 +1019,13 @@ const makeWithTransaction = (options) => {
|
|
|
1006
1019
|
}
|
|
1007
1020
|
return forEach(buffer.callbacks, runAfterCommit, { discard: true });
|
|
1008
1021
|
}, true);
|
|
1009
|
-
return id === 0 ? settled : getUnsafe(services, transactionSemaphore).withPermit(settled);
|
|
1022
|
+
return id === 0 ? settled : restore(getUnsafe(services, transactionSemaphore).withPermit(uninterruptible(settled)));
|
|
1010
1023
|
})));
|
|
1011
1024
|
};
|
|
1012
1025
|
const TransactionConnection = (clientId) => Service(`effect/sql/SqlClient/TransactionConnection/${clientId}`);
|
|
1013
1026
|
const SafeIntegers = Reference("effect/sql/SqlClient/SafeIntegers", { defaultValue: () => false });
|
|
1014
1027
|
const BeginTransaction = Reference("effect/sql/SqlClient/BeginTransaction", { defaultValue: () => void 0 });
|
|
1015
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1028
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Cache.js
|
|
1016
1029
|
const TypeId$3 = "~effect/Cache";
|
|
1017
1030
|
const makeWith = (lookup, options) => contextWith$1((context) => {
|
|
1018
1031
|
const self = Object.create(Proto$1);
|
|
@@ -1104,7 +1117,7 @@ const checkCapacity = (self) => {
|
|
|
1104
1117
|
if (diff === 0) return;
|
|
1105
1118
|
}
|
|
1106
1119
|
};
|
|
1107
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1120
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/schema/VariantSchema.js
|
|
1108
1121
|
const TypeId$2 = "~effect/schema/VariantSchema";
|
|
1109
1122
|
const cacheSymbol = Symbol.for(`${TypeId$2}/cache`);
|
|
1110
1123
|
const defaultCacheSymbol = Symbol.for(`${TypeId$2}/defaultCache`);
|
|
@@ -1221,7 +1234,7 @@ const Union$1 = (members, defaultVariant, variants) => {
|
|
|
1221
1234
|
for (const variant of variants) Object.defineProperty(VariantUnion, variant, { value: Union$2(members.map((member) => extract$1(member, variant))) });
|
|
1222
1235
|
return VariantUnion;
|
|
1223
1236
|
};
|
|
1224
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1237
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/schema/Model.js
|
|
1225
1238
|
const { Class, Field, FieldExcept, FieldOnly, Struct, Union, extract, fieldEvolve } = make$3({
|
|
1226
1239
|
variants: [
|
|
1227
1240
|
"select",
|
|
@@ -1294,7 +1307,7 @@ const DateTimeUpdateFromNumber = Field({
|
|
|
1294
1307
|
update: DateTimeFromNumberWithNow,
|
|
1295
1308
|
json: DateTimeUtcFromMillis
|
|
1296
1309
|
});
|
|
1297
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1310
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/sql/SqlResolver.js
|
|
1298
1311
|
const SqlRequestProto = {
|
|
1299
1312
|
...Class$2.prototype,
|
|
1300
1313
|
[symbol](that) {
|
|
@@ -1426,13 +1439,13 @@ function transactionKey(entry) {
|
|
|
1426
1439
|
if (currentTransaction === void 0) return byReferenceUnsafe(clientTransaction);
|
|
1427
1440
|
return [byReferenceUnsafe(clientTransaction), byReferenceUnsafe(currentTransaction)];
|
|
1428
1441
|
}
|
|
1429
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1442
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/sql/SqlSchema.js
|
|
1430
1443
|
const findAll = (options) => {
|
|
1431
1444
|
const encodeRequest = encodeEffect(options.Request);
|
|
1432
1445
|
const decode = decodeUnknownEffect(mutable(ArraySchema(options.Result)));
|
|
1433
1446
|
return (request) => flatMap(flatMap(encodeRequest(request), options.execute), decode);
|
|
1434
1447
|
};
|
|
1435
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1448
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/sql/SqlModel.js
|
|
1436
1449
|
const makeResolvers = (Model, options) => gen(function* () {
|
|
1437
1450
|
const sql = yield* SqlClient;
|
|
1438
1451
|
const idSchema = Model.fields[options.idColumn];
|
|
@@ -2043,7 +2056,7 @@ const layer$3 = effect(CodeChunker, gen(function* () {
|
|
|
2043
2056
|
chunkCodebase
|
|
2044
2057
|
});
|
|
2045
2058
|
}));
|
|
2046
|
-
// node_modules/.pnpm/effect@4.1.
|
|
2059
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/FiberHandle.js
|
|
2047
2060
|
const TypeId$1 = "~effect/FiberHandle";
|
|
2048
2061
|
const isFiberHandle = (u) => hasProperty(u, TypeId$1);
|
|
2049
2062
|
const Proto = {
|
|
@@ -2118,7 +2131,7 @@ const runImpl = (self, effect, options) => withFiber((parent) => {
|
|
|
2118
2131
|
setUnsafe(self, fiber, options);
|
|
2119
2132
|
return succeed(fiber);
|
|
2120
2133
|
});
|
|
2121
|
-
// node_modules/.pnpm/@effect+sql-sqlite-node@4.1.
|
|
2134
|
+
// node_modules/.pnpm/@effect+sql-sqlite-node@4.1.3_effect@4.1.3/node_modules/@effect/sql-sqlite-node/dist/SqliteClient.js
|
|
2122
2135
|
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
2123
2136
|
const MAX_BUSY_TIMEOUT = 2147483647;
|
|
2124
2137
|
const NANOS_PER_MILLI = BigInt(1e6);
|
|
@@ -2287,7 +2300,7 @@ const sqliteCauseWithErrno = (cause) => {
|
|
|
2287
2300
|
const setLoadExtensionEnabled = (db, enabled) => {
|
|
2288
2301
|
if (typeof db.enableLoadExtension === "function") db.enableLoadExtension(enabled);
|
|
2289
2302
|
};
|
|
2290
|
-
// node_modules/.pnpm/effect@4.1.
|
|
2303
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/sql/Migrator.js
|
|
2291
2304
|
var MigrationError = class extends TaggedError$1("MigrationError") {};
|
|
2292
2305
|
const make = ({ transformWrites = identity, dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, table = "effect_sql_migrations" }) => gen(function* () {
|
|
2293
2306
|
const sql = yield* SqlClient;
|
|
@@ -2403,7 +2416,7 @@ const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishO
|
|
|
2403
2416
|
name,
|
|
2404
2417
|
succeed(migrations[key])
|
|
2405
2418
|
]), sort(migrationOrder), succeed);
|
|
2406
|
-
// node_modules/.pnpm/@effect+sql-sqlite-node@4.1.
|
|
2419
|
+
// node_modules/.pnpm/@effect+sql-sqlite-node@4.1.3_effect@4.1.3/node_modules/@effect/sql-sqlite-node/dist/SqliteMigrator.js
|
|
2407
2420
|
const run = make({});
|
|
2408
2421
|
const layer$1 = (options) => effectDiscard(run(options));
|
|
2409
2422
|
// src/Sqlite.ts
|