clanka 0.8.5 → 0.9.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/Acp.d.ts.map +1 -1
- package/dist/Acp.js +9 -3
- package/dist/Acp.js.map +1 -1
- package/dist/Acp.test.js +72 -1
- package/dist/Acp.test.js.map +1 -1
- package/dist/AcpImage.test.js +1 -0
- package/dist/AcpImage.test.js.map +1 -1
- package/dist/Agent.d.ts +65 -8
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +481 -113
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +77 -4
- package/dist/Agent.test.js.map +1 -1
- package/dist/AgentCallerConfig.test.d.ts +2 -0
- package/dist/AgentCallerConfig.test.d.ts.map +1 -0
- package/dist/AgentCallerConfig.test.js +327 -0
- package/dist/AgentCallerConfig.test.js.map +1 -0
- package/dist/AgentExecutor.d.ts +254 -54
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +416 -99
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.js +201 -31
- package/dist/AgentExecutor.test.js.map +1 -1
- package/dist/AgentExecutorImage.test.js +2 -1
- package/dist/AgentExecutorImage.test.js.map +1 -1
- package/dist/AgentImage.test.js +5 -1
- package/dist/AgentImage.test.js.map +1 -1
- package/dist/AgentOutput.d.ts +54 -2
- package/dist/AgentOutput.d.ts.map +1 -1
- package/dist/AgentOutput.js +52 -0
- package/dist/AgentOutput.js.map +1 -1
- package/dist/AgentSkills.d.ts +22 -0
- package/dist/AgentSkills.d.ts.map +1 -1
- package/dist/AgentSkills.js +36 -0
- package/dist/AgentSkills.js.map +1 -1
- package/dist/AgentSkills.test.js +2 -0
- package/dist/AgentSkills.test.js.map +1 -1
- package/dist/AgentSubagents.test.d.ts +2 -0
- package/dist/AgentSubagents.test.d.ts.map +1 -0
- package/dist/AgentSubagents.test.js +452 -0
- package/dist/AgentSubagents.test.js.map +1 -0
- package/dist/AgentTools.d.ts +356 -14
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +213 -34
- package/dist/AgentTools.js.map +1 -1
- package/dist/CompactionTransport.test.js +1 -1
- package/dist/CompactionTransport.test.js.map +1 -1
- package/dist/OutputFormatter.d.ts.map +1 -1
- package/dist/OutputFormatter.js +16 -2
- package/dist/OutputFormatter.js.map +1 -1
- package/dist/ToolkitRenderer.d.ts.map +1 -1
- package/dist/ToolkitRenderer.js +6 -1
- package/dist/ToolkitRenderer.js.map +1 -1
- package/dist/bin/{Effect-BEUn4I5E.mjs → Effect-2jPlJ8eu.mjs} +399 -207
- package/dist/bin/Effect-2jPlJ8eu.mjs.map +1 -0
- package/dist/bin/{McpClient-C0FVuDj2.mjs → McpClient-1W508adc.mjs} +4 -4
- package/dist/bin/{McpClient-C0FVuDj2.mjs.map → McpClient-1W508adc.mjs.map} +1 -1
- package/dist/bin/{OutputFormatter-DffD5oxX.mjs → OutputFormatter-DXXKo4E8.mjs} +16 -5
- package/dist/bin/{OutputFormatter-DffD5oxX.mjs.map → OutputFormatter-DXXKo4E8.mjs.map} +1 -1
- package/dist/bin/{Schema-CjUGw2Xh.mjs → Schema-D-7VuCiC.mjs} +640 -87
- package/dist/bin/Schema-D-7VuCiC.mjs.map +1 -0
- package/dist/bin/{SemanticSearch-CFB73IPb.mjs → SemanticSearch-Cb8aqvGv.mjs} +89 -56
- package/dist/bin/SemanticSearch-Cb8aqvGv.mjs.map +1 -0
- package/dist/bin/{Stream-Cu6P7ZHo.mjs → Stream-DEu2tfCV.mjs} +81 -51
- package/dist/bin/Stream-DEu2tfCV.mjs.map +1 -0
- package/dist/bin/cli.mjs +3632 -5538
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/{turndown.cjs-usmCKZ4b.mjs → turndown.cjs-DK29wZw3.mjs} +2 -2
- package/dist/bin/{turndown.cjs-usmCKZ4b.mjs.map → turndown.cjs-DK29wZw3.mjs.map} +1 -1
- package/package.json +7 -7
- package/src/Acp.test.ts +121 -2
- package/src/Acp.ts +10 -3
- package/src/AcpImage.test.ts +1 -0
- package/src/Agent.test.ts +100 -3
- package/src/Agent.ts +752 -142
- package/src/AgentCallerConfig.test.ts +514 -0
- package/src/AgentExecutor.test.ts +297 -37
- package/src/AgentExecutor.ts +707 -159
- package/src/AgentExecutorImage.test.ts +2 -1
- package/src/AgentImage.test.ts +11 -2
- package/src/AgentOutput.ts +74 -1
- package/src/AgentSkills.test.ts +2 -0
- package/src/AgentSkills.ts +43 -0
- package/src/AgentSubagents.test.ts +758 -0
- package/src/AgentTools.ts +376 -52
- package/src/CompactionTransport.test.ts +1 -1
- package/src/OutputFormatter.ts +16 -2
- package/src/ToolkitRenderer.ts +7 -1
- package/dist/bin/Effect-BEUn4I5E.mjs.map +0 -1
- package/dist/bin/Schema-CjUGw2Xh.mjs.map +0 -1
- package/dist/bin/SemanticSearch-CFB73IPb.mjs.map +0 -1
- package/dist/bin/Stream-Cu6P7ZHo.mjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import {
|
|
3
|
-
import { A as
|
|
4
|
-
import {
|
|
1
|
+
import { $a as Service, $i as compose, $t as try_, At as request$1, B as fn, Br as provide, Bs as isNotNull, C as catchTags, Ca as sort, Cn as remove, Co as isNone, Cs as symbol, Ct as orElseSucceed, D as contextWith, Do as map$1, Dt as provideService, E as context, Es as hash, Et as provideContext, Ga as minutes, Gr as done, Ha as isZero, Ho as make$10, I as filterOrFail, Io as Number$1, Ir as close, Ja as seconds, Ji as updateContext, Jn as combine, Jr as into, Jt as tap, Ko as Prototype, Kr as doneUnsafe, Kt as suspend, L as flatMap, Li as makeSpanUnsafe, Lt as scope, Mn as spaced, Mo as some, Ms as symbol$1, Mt as retry, N as fail, Nr as Scope, Ns as hasProperty, Nt as runFork, O as delay, Oi as fiberJoin, Oo as match, Or as provide$1, P as failCause$1, Pr as addFinalizer, Pt as runForkWith, Q as interrupt, Qa as Reference, Qn as filterInterruptors, Qr as makeUnsafe$2, Qt as tryPromise, Ra as fromInputUnsafe, Rr as make$7, Rt as scoped, S as catchTag, Sn as make$8, Ss as equals, St as orDie, Tn as size, To as isSome, U as forEach$1, Ui as succeed$1, Un as NoSuchElementError, Ur as TracerTimingEnabled, Ut as succeed, V as fnUntraced, Va as isFinite, Vi as onExitUnsafe, Vt as serviceOption, W as forever, Wa as millis, X as gen, Ya as toMillis, Yi as void_$2, Yo as PipeInspectableProto, Yt as tapCause, Z as ignore, Za as zero, Zi as ParentSpan, _o as fromNullishOr, _t as onError, a as andThen, aa as empty, ac as dual, ai as isFailure, an as useSpan, as as withFiber$1, b as catchNoSuchElement, bn as get$2, br as effectContext, c as as, ci as void_$3, ea as has, eo as add, et as isEffect, fa as isArrayNonEmpty, fn as withSpan, fo as filter, g as catchDefect, gn as Class$1, hi as contextWith$1, ho as flatten, hr as reasonAnnotations, i as all, io as getOrUndefined, it as logInfo, ji as forkUnsafe, k as die, ko as none, kr as provideMerge, la as flatMapNullishOr, li as ClockRef, ln as withFiber, lo as merge, m as catchCause, mt as matchCauseEffect, n as acquireUseRelease, nc as constUndefined, ni as failCause, nn as uninterruptibleMask, no as get$1, o as annotateCurrentSpan, oc as flow, oi as isSuccess, on as void_$1, oo as getUnsafe, ot as makeSpanScoped, pc as pipeArguments, pt as matchCauseEager, q as forkScoped, qt as sync, ro as getOption, rr as hasInterruptsOnly, s as annotateLogs, sc as identity, si as succeed$2, so as make$9, sr as isFailReason, ss as assignProperty, st as map, t as acquireRelease, ta as toPredicate, ti as fail$1, tr as fromReasons, tt as logDebug, u as asVoid, ua as fromIterable, uc as pipe, un as withLogSpan, ur as makeDieReason, ut as mapError, vi as endSpan, vn as empty$1, vt as onExit, w as catch_, wi as fiberInterrupt, wn as set, xn as isEmpty, xr as effectDiscard, xs as byReferenceUnsafe, y as catchIf, ya as map$2, yi as exitHasInterrupts, yn as forEach, yr as effect, yt as onExitPrimitive, za as infinity } from "./Effect-2jPlJ8eu.mjs";
|
|
2
|
+
import { B as provideService$1, H as runCollect, It as interruptAs, Lt as join$1, Rt as runIn, T as fromQueue, U as runDrain, _t as make$11, c as die$1, et as tap$1, g as flatMap$1, gt as failCauseUnsafe, lt as make$12, nt as unwrap, ut as makeUnsafe$3, v as fromArray, xt as offerUnsafe, y as fromArrayEffect } from "./Stream-DEu2tfCV.mjs";
|
|
3
|
+
import { A as Option, At as optionalKey, B as TaggedError, Bn as now, C as Natural, Cn as map$3, I as String$1, Kn as Clock, L as Struct$2, Lt as toType, O as NullOr, Ot as mutable, Q as brand, Rn as formatIsoDate, Rt as withConstructorDefault, Sn as dateTimeUtcFromInput, Tn as transform, Vn as removeTime, Vt as evolve, Y as Union$2, Zn as TaggedError$1, c as DateTimeUtcFromDate, d as Defect, dt as instanceOf, i as BooleanFromBit, it as decodeUnknownEffect, j as OptionFromNullOr, k as Number$2, kt as optional, l as DateTimeUtcFromMillis, n as ArraySchema, o as Class$2, qn as monotonicTimeNanos, r as Boolean, rt as decodeTo, s as DateTimeUtc, st as encodeEffect, u as DateTimeUtcFromString, wt as isSchema, xn as transformOptional, yn as transform$1 } from "./Schema-D-7VuCiC.mjs";
|
|
4
|
+
import { a as makeGrouped, 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 } 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.
|
|
11
|
+
//#region node_modules/.pnpm/effect@4.0.4/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$6 = sync(() => {
|
|
@@ -52,7 +52,7 @@ const make$6 = 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$
|
|
55
|
+
const results = yield* make$11();
|
|
56
56
|
const runFork = flow(runForkWith(services), runIn(scope));
|
|
57
57
|
let running = false;
|
|
58
58
|
let pending = false;
|
|
@@ -122,7 +122,7 @@ const keysToHashes = (keys, f) => {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
//#endregion
|
|
125
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
125
|
+
//#region node_modules/.pnpm/effect@4.0.4/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.
|
|
299
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/sql/Statement.js
|
|
300
300
|
const FragmentTypeId = "~effect/sql/Statement/Fragment";
|
|
301
301
|
const fragment = (segments) => ({
|
|
302
302
|
[FragmentTypeId]: FragmentTypeId,
|
|
@@ -652,8 +652,27 @@ const defaultTransforms = (transformer, nested = true) => {
|
|
|
652
652
|
array
|
|
653
653
|
};
|
|
654
654
|
};
|
|
655
|
-
const
|
|
655
|
+
const spanTarget = (spanAttributes) => {
|
|
656
|
+
const namespace = spanAttribute(spanAttributes, "db.namespace");
|
|
657
|
+
if (isNonEmptyString(namespace)) return namespace;
|
|
658
|
+
const address = spanAttribute(spanAttributes, "server.address");
|
|
659
|
+
if (isNonEmptyString(address)) {
|
|
660
|
+
const port = spanAttribute(spanAttributes, "server.port");
|
|
661
|
+
return port === void 0 ? address : `${address}:${port}`;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
const spanName = (spanAttributes) => {
|
|
665
|
+
const target = spanTarget(spanAttributes);
|
|
666
|
+
if (target !== void 0) return target;
|
|
667
|
+
const system = spanAttribute(spanAttributes, "db.system.name");
|
|
668
|
+
return isNonEmptyString(system) ? system : "sql.execute";
|
|
669
|
+
};
|
|
656
670
|
const ATTR_DB_QUERY_TEXT = "db.query.text";
|
|
671
|
+
const ATTR_SQL_METHOD = "effect.sql.method";
|
|
672
|
+
const spanAttribute = (spanAttributes, key) => {
|
|
673
|
+
for (let i = spanAttributes.length - 1; i >= 0; i--) if (spanAttributes[i][0] === key) return spanAttributes[i][1];
|
|
674
|
+
};
|
|
675
|
+
const isNonEmptyString = (u) => typeof u === "string" && u.length > 0;
|
|
657
676
|
const makeUnsafe$1 = (segments, acquirer, compiler, spanAttributes, transformRows, borrower) => {
|
|
658
677
|
const self = Object.create(StatementProto);
|
|
659
678
|
self.segments = segments;
|
|
@@ -667,13 +686,13 @@ const makeUnsafe$1 = (segments, acquirer, compiler, spanAttributes, transformRow
|
|
|
667
686
|
const StatementProto = {
|
|
668
687
|
[FragmentTypeId]: FragmentTypeId,
|
|
669
688
|
withConnection(operation, f, withoutTransform = false) {
|
|
670
|
-
return useSpan(
|
|
689
|
+
return useSpan(spanName(this.spanAttributes), { kind: "client" }, (span) => this.withConnectionSpan(operation, f, withoutTransform, span));
|
|
671
690
|
},
|
|
672
691
|
withConnectionSpan(operation, f, withoutTransform, span) {
|
|
673
692
|
return withStatement(this, span, (statement, fiber) => {
|
|
674
693
|
const [sql, params] = statement.compile(withoutTransform);
|
|
675
694
|
for (const [key, value] of this.spanAttributes) span.attribute(key, value);
|
|
676
|
-
span.attribute(
|
|
695
|
+
span.attribute(ATTR_SQL_METHOD, operation);
|
|
677
696
|
span.attribute(ATTR_DB_QUERY_TEXT, sql);
|
|
678
697
|
const execute = this.borrower === void 0 ? scoped(flatMap(this.acquirer, (_) => f(_, sql, params))) : this.borrower((connection) => f(connection, sql, params));
|
|
679
698
|
return fiber.cache.tracerEnabled && fiber.getRef(SpanPropagationEnabled) ? provideService(execute, ParentSpan, span) : execute;
|
|
@@ -687,10 +706,10 @@ const StatementProto = {
|
|
|
687
706
|
},
|
|
688
707
|
get stream() {
|
|
689
708
|
const self = this;
|
|
690
|
-
return unwrap(flatMap(makeSpanScoped(
|
|
709
|
+
return unwrap(flatMap(makeSpanScoped(spanName(self.spanAttributes), { kind: "client" }), (span) => withStatement(self, span, (statement, fiber) => {
|
|
691
710
|
const [sql, params] = statement.compile();
|
|
692
711
|
for (const [key, value] of self.spanAttributes) span.attribute(key, value);
|
|
693
|
-
span.attribute(
|
|
712
|
+
span.attribute(ATTR_SQL_METHOD, "executeStream");
|
|
694
713
|
span.attribute(ATTR_DB_QUERY_TEXT, sql);
|
|
695
714
|
const acquire = map(self.acquirer, (_) => _.executeStream(sql, params, self.transformRows));
|
|
696
715
|
return fiber.cache.tracerEnabled && fiber.getRef(SpanPropagationEnabled) ? succeed(provideService$1(unwrap(acquire), ParentSpan, span)) : acquire;
|
|
@@ -709,7 +728,7 @@ const StatementProto = {
|
|
|
709
728
|
...Prototype({
|
|
710
729
|
label: "Statement",
|
|
711
730
|
evaluate(fiber) {
|
|
712
|
-
const span = makeSpanUnsafe(fiber,
|
|
731
|
+
const span = makeSpanUnsafe(fiber, spanName(this.spanAttributes), { kind: "client" });
|
|
713
732
|
const clock = fiber.getRef(Clock);
|
|
714
733
|
const timingEnabled = fiber.getRef(TracerTimingEnabled);
|
|
715
734
|
return onExit(this.withConnectionSpan("execute", (connection, sql, params) => connection.execute(sql, params, this.transformRows), false, span), (exit) => endSpan(span, exit, clock, timingEnabled));
|
|
@@ -786,7 +805,7 @@ function in_() {
|
|
|
786
805
|
}
|
|
787
806
|
const neverFragment = fragment([literal("1=0")]);
|
|
788
807
|
//#endregion
|
|
789
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
808
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/sql/SqlClient.js
|
|
790
809
|
const TypeId$4 = "~effect/sql/SqlClient";
|
|
791
810
|
const SqlClient = Service("effect/sql/SqlClient");
|
|
792
811
|
let clientIdCounter = 0;
|
|
@@ -867,9 +886,10 @@ const makeSqliteAcquirers = (options) => {
|
|
|
867
886
|
}
|
|
868
887
|
});
|
|
869
888
|
});
|
|
889
|
+
const lease = uninterruptibleMask((restore) => flatMap(scope, (scope) => restore(semaphore.take(1)).pipe(andThen(addFinalizer(scope, semaphore.release(1))), andThen(available))));
|
|
870
890
|
return {
|
|
871
|
-
acquirer:
|
|
872
|
-
transactionAcquirer:
|
|
891
|
+
acquirer: lease,
|
|
892
|
+
transactionAcquirer: lease,
|
|
873
893
|
onCommitFailure: (conn) => tapCause(rollback(conn), (cause) => sync(() => poison(cause)))
|
|
874
894
|
};
|
|
875
895
|
};
|
|
@@ -878,9 +898,10 @@ const isNoTransactionError = (error) => {
|
|
|
878
898
|
const message = typeof cause === "string" ? cause : hasProperty(cause, "message") && typeof cause.message === "string" ? cause.message : "";
|
|
879
899
|
return /no transaction is active/i.test(message);
|
|
880
900
|
};
|
|
901
|
+
const failuresToDefects = (cause) => fromReasons(cause.reasons.map((reason) => isFailReason(reason) ? makeDieReason(reason.error).annotate(reasonAnnotations(reason)) : reason));
|
|
881
902
|
const makeWithTransaction = (options) => {
|
|
882
903
|
const transactionSemaphore = Service(`effect/sql/SqlClient/TransactionSemaphore/${transactionSemaphoreIdCounter++}`);
|
|
883
|
-
return (effect) => uninterruptibleMask((restore) => useSpan("sql.transaction", { kind: "
|
|
904
|
+
return (effect) => uninterruptibleMask((restore) => useSpan("sql.transaction", { kind: "internal" }, (span) => withFiber((fiber) => {
|
|
884
905
|
for (const [key, value] of options.spanAttributes) span.attribute(key, value);
|
|
885
906
|
const services = fiber.context;
|
|
886
907
|
const clock = fiber.getRef(Clock);
|
|
@@ -891,16 +912,18 @@ const makeWithTransaction = (options) => {
|
|
|
891
912
|
let effect;
|
|
892
913
|
if (isSuccess(exit)) {
|
|
893
914
|
if (id === 0) {
|
|
894
|
-
span.event("
|
|
915
|
+
span.event("effect.sql.transaction.commit", clock.currentTimeNanosUnsafe());
|
|
895
916
|
const onCommitFailure = options.onCommitFailure;
|
|
896
|
-
effect =
|
|
897
|
-
|
|
917
|
+
effect = onCommitFailure ? catchCause(options.commit(conn), (commitCause) => matchCauseEffect(onCommitFailure(conn), {
|
|
918
|
+
onFailure: (cleanupCause) => failCause$1(failuresToDefects(combine(commitCause, cleanupCause))),
|
|
919
|
+
onSuccess: () => failCause$1(commitCause)
|
|
920
|
+
})) : options.commit(conn);
|
|
898
921
|
} else {
|
|
899
|
-
span.event("
|
|
922
|
+
span.event("effect.sql.transaction.savepoint", clock.currentTimeNanosUnsafe());
|
|
900
923
|
effect = void_$1;
|
|
901
924
|
}
|
|
902
925
|
} else {
|
|
903
|
-
span.event("
|
|
926
|
+
span.event("effect.sql.transaction.rollback", clock.currentTimeNanosUnsafe());
|
|
904
927
|
effect = orDie(id > 0 ? options.rollbackSavepoint(conn, id) : options.rollback(conn));
|
|
905
928
|
}
|
|
906
929
|
if (id > 0 && options.releaseSavepoint) effect = andThen(effect, orDie(options.releaseSavepoint(conn, id)));
|
|
@@ -912,12 +935,12 @@ const makeWithTransaction = (options) => {
|
|
|
912
935
|
const TransactionConnection = (clientId) => Service(`effect/sql/SqlClient/TransactionConnection/${clientId}`);
|
|
913
936
|
const SafeIntegers = Reference("effect/sql/SqlClient/SafeIntegers", { defaultValue: () => false });
|
|
914
937
|
//#endregion
|
|
915
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
938
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/Cache.js
|
|
916
939
|
const TypeId$3 = "~effect/Cache";
|
|
917
940
|
const makeWith = (lookup, options) => contextWith$1((context) => {
|
|
918
941
|
const self = Object.create(Proto$1);
|
|
919
942
|
self.lookup = (key) => updateContext(lookup(key), (input) => merge(context, input));
|
|
920
|
-
self.map = make$
|
|
943
|
+
self.map = make$8();
|
|
921
944
|
self.capacity = options.capacity;
|
|
922
945
|
self.timeToLive = options.timeToLive ? (exit, key) => fromInputUnsafe(options.timeToLive(exit, key)) : defaultTimeToLive;
|
|
923
946
|
return succeed$1(self);
|
|
@@ -940,7 +963,7 @@ const get = dual(2, (self, key) => withFiber$1((fiber) => {
|
|
|
940
963
|
remove(self.map, key);
|
|
941
964
|
if (!hasExpired(oentry.value, fiber)) {
|
|
942
965
|
set(self.map, key, oentry.value);
|
|
943
|
-
return oentry.value.await();
|
|
966
|
+
return oentry.value.await(fiber);
|
|
944
967
|
}
|
|
945
968
|
}
|
|
946
969
|
const entry = new EntryImpl(fiber, self.lookup(key));
|
|
@@ -961,7 +984,7 @@ const get = dual(2, (self, key) => withFiber$1((fiber) => {
|
|
|
961
984
|
const exit = entry.fiber.pollUnsafe();
|
|
962
985
|
if (!skipCache && (exit === void 0 || !exitHasInterrupts(exit))) set(self.map, key, entry);
|
|
963
986
|
if (Number.isFinite(self.capacity)) checkCapacity(self);
|
|
964
|
-
return entry.await();
|
|
987
|
+
return entry.await(fiber);
|
|
965
988
|
}));
|
|
966
989
|
var EntryImpl = class {
|
|
967
990
|
expiresAt;
|
|
@@ -973,16 +996,18 @@ var EntryImpl = class {
|
|
|
973
996
|
this.awaiters = 0;
|
|
974
997
|
this.expiresAt = void 0;
|
|
975
998
|
}
|
|
976
|
-
await() {
|
|
999
|
+
await(fiber) {
|
|
1000
|
+
if (fiber === void 0) return withFiber$1((fiber) => this.await(fiber));
|
|
977
1001
|
const exit = this.fiber.pollUnsafe();
|
|
978
1002
|
if (exit) return exit;
|
|
979
1003
|
this.awaiters++;
|
|
980
|
-
|
|
1004
|
+
onExitUnsafe(fiber, () => {
|
|
981
1005
|
this.awaiters--;
|
|
982
1006
|
if (this.awaiters > 0 || this.fiber.pollUnsafe()) return void_$2;
|
|
983
1007
|
this.onInterrupt?.();
|
|
984
1008
|
return fiberInterrupt(this.fiber);
|
|
985
1009
|
});
|
|
1010
|
+
return fiberJoin(this.fiber);
|
|
986
1011
|
}
|
|
987
1012
|
};
|
|
988
1013
|
const removeEntry = (self, key, entry) => {
|
|
@@ -1003,7 +1028,7 @@ const checkCapacity = (self) => {
|
|
|
1003
1028
|
}
|
|
1004
1029
|
};
|
|
1005
1030
|
//#endregion
|
|
1006
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
1031
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/schema/VariantSchema.js
|
|
1007
1032
|
const TypeId$2 = "~effect/schema/VariantSchema";
|
|
1008
1033
|
const cacheSymbol = Symbol.for(`${TypeId$2}/cache`);
|
|
1009
1034
|
const defaultCacheSymbol = Symbol.for(`${TypeId$2}/defaultCache`);
|
|
@@ -1108,7 +1133,7 @@ const Union$1 = (members, defaultVariant, variants) => {
|
|
|
1108
1133
|
return VariantUnion;
|
|
1109
1134
|
};
|
|
1110
1135
|
//#endregion
|
|
1111
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
1136
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/schema/Model.js
|
|
1112
1137
|
const { Class, Field, FieldExcept, FieldOnly, Struct, Union, extract, fieldEvolve } = make$3({
|
|
1113
1138
|
variants: [
|
|
1114
1139
|
"select",
|
|
@@ -1182,7 +1207,7 @@ const DateTimeUpdateFromNumber = Field({
|
|
|
1182
1207
|
json: DateTimeUtcFromMillis
|
|
1183
1208
|
});
|
|
1184
1209
|
//#endregion
|
|
1185
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
1210
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/sql/SqlResolver.js
|
|
1186
1211
|
const SqlRequestProto = {
|
|
1187
1212
|
...Class$1.prototype,
|
|
1188
1213
|
[symbol](that) {
|
|
@@ -1239,7 +1264,7 @@ const findById = (options) => {
|
|
|
1239
1264
|
request.value.completeUnsafe(succeed$2(result));
|
|
1240
1265
|
}
|
|
1241
1266
|
if (isEmpty(idMap)) return;
|
|
1242
|
-
forEach
|
|
1267
|
+
forEach(idMap, (request) => {
|
|
1243
1268
|
request.completeUnsafe(constNoSuchElement);
|
|
1244
1269
|
});
|
|
1245
1270
|
})
|
|
@@ -1313,14 +1338,14 @@ function transactionKey(entry) {
|
|
|
1313
1338
|
return byReferenceUnsafe(conn);
|
|
1314
1339
|
}
|
|
1315
1340
|
//#endregion
|
|
1316
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
1341
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/sql/SqlSchema.js
|
|
1317
1342
|
const findAll = (options) => {
|
|
1318
1343
|
const encodeRequest = encodeEffect(options.Request);
|
|
1319
1344
|
const decode = decodeUnknownEffect(mutable(ArraySchema(options.Result)));
|
|
1320
1345
|
return (request) => flatMap(flatMap(encodeRequest(request), options.execute), decode);
|
|
1321
1346
|
};
|
|
1322
1347
|
//#endregion
|
|
1323
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
1348
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/sql/SqlModel.js
|
|
1324
1349
|
const makeResolvers = (Model, options) => gen(function* () {
|
|
1325
1350
|
const sql = yield* SqlClient;
|
|
1326
1351
|
const idSchema = Model.fields[options.idColumn];
|
|
@@ -1333,7 +1358,7 @@ const makeResolvers = (Model, options) => gen(function* () {
|
|
|
1333
1358
|
Request: Model.insert,
|
|
1334
1359
|
Result: Model,
|
|
1335
1360
|
execute: (request) => sql.onDialectOrElse({
|
|
1336
|
-
mysql: () => forEach(request, (request) => sql`insert into ${sql(options.tableName)} ${sql.insert(request)};
|
|
1361
|
+
mysql: () => forEach$1(request, (request) => sql`insert into ${sql(options.tableName)} ${sql.insert(request)};
|
|
1337
1362
|
select * from ${sql(options.tableName)} where ${withSoftDeleteFilter(sql`${sql(idColumn)} = LAST_INSERT_ID()`)};`.unprepared.pipe(map(([, results]) => results[0])), { concurrency: 10 }),
|
|
1338
1363
|
orElse: () => sql`insert into ${sql(options.tableName)} ${sql.insert(request).returning("*")}`
|
|
1339
1364
|
})
|
|
@@ -1934,7 +1959,7 @@ const layer$3 = effect(CodeChunker, gen(function* () {
|
|
|
1934
1959
|
});
|
|
1935
1960
|
}));
|
|
1936
1961
|
//#endregion
|
|
1937
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
1962
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/FiberHandle.js
|
|
1938
1963
|
const TypeId$1 = "~effect/FiberHandle";
|
|
1939
1964
|
const isFiberHandle = (u) => hasProperty(u, TypeId$1);
|
|
1940
1965
|
const Proto = {
|
|
@@ -1968,16 +1993,17 @@ const setUnsafe = dual((args) => isFiberHandle(args[0]), (self, fiber, options)
|
|
|
1968
1993
|
if (self.state._tag === "Closed") {
|
|
1969
1994
|
fiber.interruptUnsafe(internalFiberId);
|
|
1970
1995
|
return;
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1996
|
+
}
|
|
1997
|
+
const previous = self.state.fiber;
|
|
1998
|
+
if (previous !== void 0) {
|
|
1999
|
+
if (previous === fiber) return;
|
|
1973
2000
|
else if (options?.onlyIfMissing === true) {
|
|
1974
2001
|
fiber.interruptUnsafe(internalFiberId);
|
|
1975
2002
|
return;
|
|
1976
2003
|
}
|
|
1977
|
-
self.state.fiber.interruptUnsafe(internalFiberId);
|
|
1978
|
-
self.state.fiber = void 0;
|
|
1979
2004
|
}
|
|
1980
2005
|
self.state.fiber = fiber;
|
|
2006
|
+
previous?.interruptUnsafe(internalFiberId);
|
|
1981
2007
|
fiber.addObserver((exit) => {
|
|
1982
2008
|
if (self.state._tag === "Open" && fiber === self.state.fiber) self.state.fiber = void 0;
|
|
1983
2009
|
if (isFailure(exit) && (options?.propagateInterruption === true ? !isInternalInterruption(exit.cause) : !hasInterruptsOnly(exit.cause))) doneUnsafe(self.deferred, exit);
|
|
@@ -2004,7 +2030,7 @@ const runImpl = (self, effect, options) => withFiber((parent) => {
|
|
|
2004
2030
|
return succeed(fiber);
|
|
2005
2031
|
});
|
|
2006
2032
|
//#endregion
|
|
2007
|
-
//#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.
|
|
2033
|
+
//#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.4_effect@4.0.4/node_modules/@effect/sql-sqlite-node/dist/SqliteClient.js
|
|
2008
2034
|
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
2009
2035
|
const MAX_BUSY_TIMEOUT = 2147483647;
|
|
2010
2036
|
const NANOS_PER_MILLI = BigInt(1e6);
|
|
@@ -2021,7 +2047,7 @@ const make$1 = (options) => gen(function* () {
|
|
|
2021
2047
|
}),
|
|
2022
2048
|
catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to open database", "connect") })
|
|
2023
2049
|
}), (db) => sync(() => db.close()));
|
|
2024
|
-
db
|
|
2050
|
+
setLoadExtensionEnabled(db, false);
|
|
2025
2051
|
const busyTimeout = Math.min(MAX_BUSY_TIMEOUT, Math.max(0, Math.round(toMillis(options.busyTimeout ?? seconds(5)))));
|
|
2026
2052
|
const exec = (sql) => try_({
|
|
2027
2053
|
try: () => db.exec(sql),
|
|
@@ -2124,16 +2150,16 @@ const make$1 = (options) => gen(function* () {
|
|
|
2124
2150
|
});
|
|
2125
2151
|
},
|
|
2126
2152
|
loadExtension(path) {
|
|
2127
|
-
return acquireUseRelease(sync(() => db
|
|
2153
|
+
return acquireUseRelease(sync(() => setLoadExtensionEnabled(db, true)), () => try_({
|
|
2128
2154
|
try: () => db.loadExtension(path),
|
|
2129
2155
|
catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to load extension", "loadExtension") })
|
|
2130
|
-
}), () => sync(() => db
|
|
2156
|
+
}), () => sync(() => setLoadExtensionEnabled(db, false)));
|
|
2131
2157
|
}
|
|
2132
2158
|
});
|
|
2133
2159
|
});
|
|
2134
2160
|
const { acquirer, onCommitFailure, transactionAcquirer } = makeSqliteAcquirers({
|
|
2135
2161
|
connection: succeed(connection),
|
|
2136
|
-
semaphore: yield* make$
|
|
2162
|
+
semaphore: yield* make$12(1),
|
|
2137
2163
|
isTransaction: (conn) => conn.isTransaction()
|
|
2138
2164
|
});
|
|
2139
2165
|
return Object.assign(yield* make$4({
|
|
@@ -2148,11 +2174,11 @@ const make$1 = (options) => gen(function* () {
|
|
|
2148
2174
|
}), {
|
|
2149
2175
|
[TypeId]: TypeId,
|
|
2150
2176
|
config: options,
|
|
2151
|
-
backup: (destination) => flatMap(acquirer, (_) => _.backup(destination)),
|
|
2152
|
-
loadExtension: (path) => flatMap(acquirer, (_) => _.loadExtension(path))
|
|
2177
|
+
backup: (destination) => scoped(flatMap(acquirer, (_) => _.backup(destination))),
|
|
2178
|
+
loadExtension: (path) => scoped(flatMap(acquirer, (_) => _.loadExtension(path)))
|
|
2153
2179
|
});
|
|
2154
2180
|
});
|
|
2155
|
-
const layer$2 = (config) => effectContext(map(make$1(config), (client) => make$
|
|
2181
|
+
const layer$2 = (config) => effectContext(map(make$1(config), (client) => make$9(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide$1(layer$5));
|
|
2156
2182
|
const classifyError = (cause, message, operation) => classifySqliteError(sqliteCauseWithErrno(cause), {
|
|
2157
2183
|
message,
|
|
2158
2184
|
operation
|
|
@@ -2163,8 +2189,11 @@ const sqliteCauseWithErrno = (cause) => {
|
|
|
2163
2189
|
if (typeof errcode !== "number") return cause;
|
|
2164
2190
|
return Object.assign(cause, { errno: errcode });
|
|
2165
2191
|
};
|
|
2192
|
+
const setLoadExtensionEnabled = (db, enabled) => {
|
|
2193
|
+
if (typeof db.enableLoadExtension === "function") db.enableLoadExtension(enabled);
|
|
2194
|
+
};
|
|
2166
2195
|
//#endregion
|
|
2167
|
-
//#region node_modules/.pnpm/effect@4.0.
|
|
2196
|
+
//#region node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/sql/Migrator.js
|
|
2168
2197
|
var __rewriteRelativeImportExtension = void 0 && (void 0).__rewriteRelativeImportExtension || function(path, preserveJsx) {
|
|
2169
2198
|
if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
2170
2199
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
|
|
@@ -2187,11 +2216,11 @@ const make = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, tab
|
|
|
2187
2216
|
name VARCHAR(255) NOT NULL,
|
|
2188
2217
|
PRIMARY KEY (migration_id)
|
|
2189
2218
|
)`,
|
|
2190
|
-
pg: () =>
|
|
2219
|
+
pg: () => flatMap(migrationsTableExists(sql, table), (exists) => exists ? void_$1 : asVoid(sql`CREATE TABLE ${sql(table)} (
|
|
2191
2220
|
migration_id integer primary key,
|
|
2192
2221
|
created_at timestamp with time zone not null default now(),
|
|
2193
2222
|
name text not null
|
|
2194
|
-
)`),
|
|
2223
|
+
)`).pipe(catch_((error) => flatMap(migrationsTableExists(sql, table), (exists) => exists ? void_$1 : fail(error))))),
|
|
2195
2224
|
orElse: () => sql`CREATE TABLE IF NOT EXISTS ${sql(table)} (
|
|
2196
2225
|
migration_id integer PRIMARY KEY NOT NULL,
|
|
2197
2226
|
created_at datetime NOT NULL DEFAULT current_timestamp,
|
|
@@ -2249,7 +2278,7 @@ const make = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, tab
|
|
|
2249
2278
|
kind: "Locked",
|
|
2250
2279
|
message: "Migrations already running"
|
|
2251
2280
|
}) : error));
|
|
2252
|
-
yield* forEach(required, ([id, name, effect]) => logDebug(`Running migration`).pipe(flatMap(() => runMigration(id, name, effect)), annotateLogs("migration_id", String(id)), annotateLogs("migration_name", name), withSpan(`Migrator ${id}_${name}`)), { discard: true });
|
|
2281
|
+
yield* forEach$1(required, ([id, name, effect]) => logDebug(`Running migration`).pipe(flatMap(() => runMigration(id, name, effect)), annotateLogs("migration_id", String(id)), annotateLogs("migration_name", name), withSpan(`Migrator ${id}_${name}`)), { discard: true });
|
|
2253
2282
|
yield* pipe(latestMigration, flatMap(match({
|
|
2254
2283
|
onNone: () => logDebug(`Migrations complete`),
|
|
2255
2284
|
onSome: (_) => logDebug(`Migrations complete`).pipe(annotateLogs("latest_migration_id", _.id.toString()), annotateLogs("latest_migration_name", _.name))
|
|
@@ -2261,7 +2290,11 @@ const make = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, tab
|
|
|
2261
2290
|
if (schemaDirectory && completed.length > 0) yield* dumpSchema(`${schemaDirectory}/_schema.sql`, table).pipe(catchCause((cause) => logInfo("Could not dump schema", cause)));
|
|
2262
2291
|
return completed;
|
|
2263
2292
|
});
|
|
2264
|
-
const
|
|
2293
|
+
const migrationsTableExists = (sql, table) => {
|
|
2294
|
+
const quotedTable = sql`${sql(table)}`.compile(true)[0];
|
|
2295
|
+
return map(sql`SELECT 1 AS found WHERE to_regclass(${quotedTable}) IS NOT NULL`.withoutTransform, (rows) => rows.length > 0);
|
|
2296
|
+
};
|
|
2297
|
+
const migrationOrder = make$10(([a], [b]) => Number$1(a, b));
|
|
2265
2298
|
const isConstraintConflict = (error) => error.reason._tag === "ConstraintError" || error.reason._tag === "UniqueViolation";
|
|
2266
2299
|
const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishOr((_) => _.match(/^(\d+)_(.+)$/)), map$2(([key, id, name]) => [
|
|
2267
2300
|
Number(id),
|
|
@@ -2269,7 +2302,7 @@ const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishO
|
|
|
2269
2302
|
succeed(migrations[key])
|
|
2270
2303
|
]), sort(migrationOrder), succeed);
|
|
2271
2304
|
//#endregion
|
|
2272
|
-
//#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.
|
|
2305
|
+
//#region node_modules/.pnpm/@effect+sql-sqlite-node@4.0.4_effect@4.0.4/node_modules/@effect/sql-sqlite-node/dist/SqliteMigrator.js
|
|
2273
2306
|
const run = make({});
|
|
2274
2307
|
const layer$1 = (options) => effectDiscard(run(options));
|
|
2275
2308
|
//#endregion
|
|
@@ -2413,4 +2446,4 @@ const layer = (options) => effect(SemanticSearch, gen(function* () {
|
|
|
2413
2446
|
//#endregion
|
|
2414
2447
|
export { SemanticSearch, chunkEmbeddingInput, layer, makeEmbeddingResolver, maybeRemoveFile, maybeUpdateFile };
|
|
2415
2448
|
|
|
2416
|
-
//# sourceMappingURL=SemanticSearch-
|
|
2449
|
+
//# sourceMappingURL=SemanticSearch-Cb8aqvGv.mjs.map
|