clanka 0.12.3 → 0.13.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 +9 -0
- package/dist/Acp.d.ts.map +1 -1
- package/dist/Acp.js +20 -9
- package/dist/Acp.js.map +1 -1
- package/dist/Acp.test.js +15 -1
- package/dist/Acp.test.js.map +1 -1
- package/dist/Codex.d.ts +12 -2
- package/dist/Codex.d.ts.map +1 -1
- package/dist/Codex.js +7 -5
- package/dist/Codex.js.map +1 -1
- package/dist/Codex.test.d.ts +2 -0
- package/dist/Codex.test.d.ts.map +1 -0
- package/dist/Codex.test.js +37 -0
- package/dist/Codex.test.js.map +1 -0
- package/dist/Copilot.d.ts.map +1 -1
- package/dist/Copilot.js +4 -4
- package/dist/Copilot.js.map +1 -1
- package/dist/Copilot.test.d.ts +2 -0
- package/dist/Copilot.test.d.ts.map +1 -0
- package/dist/Copilot.test.js +32 -0
- package/dist/Copilot.test.js.map +1 -0
- package/dist/ModelLayer.d.ts +64 -0
- package/dist/ModelLayer.d.ts.map +1 -0
- package/dist/ModelLayer.js +96 -0
- package/dist/ModelLayer.js.map +1 -0
- package/dist/ModelLayer.test.d.ts +2 -0
- package/dist/ModelLayer.test.d.ts.map +1 -0
- package/dist/ModelLayer.test.js +83 -0
- package/dist/ModelLayer.test.js.map +1 -0
- package/dist/ModelsRepo.d.ts +80 -0
- package/dist/ModelsRepo.d.ts.map +1 -0
- package/dist/ModelsRepo.js +162 -0
- package/dist/ModelsRepo.js.map +1 -0
- package/dist/ModelsRepo.test.d.ts +2 -0
- package/dist/ModelsRepo.test.d.ts.map +1 -0
- package/dist/ModelsRepo.test.js +168 -0
- package/dist/ModelsRepo.test.js.map +1 -0
- package/dist/Xai.d.ts +12 -2
- package/dist/Xai.d.ts.map +1 -1
- package/dist/Xai.js +8 -2
- package/dist/Xai.js.map +1 -1
- package/dist/Xai.test.js +38 -7
- package/dist/Xai.test.js.map +1 -1
- package/dist/bin/{Effect-DuThyCJ1.mjs → Effect-4B1lzxy4.mjs} +2 -2
- package/dist/bin/{Effect-DuThyCJ1.mjs.map → Effect-4B1lzxy4.mjs.map} +1 -1
- package/dist/bin/{McpClient-CIiPyMDJ.mjs → McpClient-DMfHHEx3.mjs} +3 -3
- package/dist/bin/{McpClient-CIiPyMDJ.mjs.map → McpClient-DMfHHEx3.mjs.map} +1 -1
- package/dist/bin/{OutputFormatter-BvIjvUmT.mjs → OutputFormatter-DRycCEdr.mjs} +3 -3
- package/dist/bin/{OutputFormatter-BvIjvUmT.mjs.map → OutputFormatter-DRycCEdr.mjs.map} +1 -1
- package/dist/bin/{Schema-DcXUXpRg.mjs → Schema-D4fxUgEU.mjs} +3 -3
- package/dist/bin/{Schema-DcXUXpRg.mjs.map → Schema-D4fxUgEU.mjs.map} +1 -1
- package/dist/bin/{SemanticSearch-CdGA4CIC.mjs → SemanticSearch-BcLFv9qz.mjs} +4 -4
- package/dist/bin/{SemanticSearch-CdGA4CIC.mjs.map → SemanticSearch-BcLFv9qz.mjs.map} +1 -1
- package/dist/bin/{Stream-I9SRMlLj.mjs → Stream-i37nF1ep.mjs} +2 -2
- package/dist/bin/{Stream-I9SRMlLj.mjs.map → Stream-i37nF1ep.mjs.map} +1 -1
- package/dist/bin/cli.mjs +756 -419
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/cli.js +59 -46
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Acp.test.ts +27 -0
- package/src/Acp.ts +31 -11
- package/src/Codex.test.ts +60 -0
- package/src/Codex.ts +26 -14
- package/src/Copilot.test.ts +55 -0
- package/src/Copilot.ts +7 -4
- package/src/ModelLayer.test.ts +122 -0
- package/src/ModelLayer.ts +149 -0
- package/src/ModelsRepo.test.ts +206 -0
- package/src/ModelsRepo.ts +260 -0
- package/src/Xai.test.ts +62 -7
- package/src/Xai.ts +27 -8
- package/src/cli.ts +74 -81
- package/src/index.ts +5 -0
package/dist/bin/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --optimize-for-size
|
|
2
2
|
import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-zY4HT0JA.mjs";
|
|
3
|
-
import { $ as interruptible, $a as
|
|
4
|
-
import { $ as take$1, A as mapArray, At as makeUnsafe$4, B as provideContext$1, Bt as toLowerCase, C as fromEffect, Ct as shutdownUnsafe, D as fromReadableStream, Dt as make$
|
|
5
|
-
import { $ as TupleWithRest, $n as null_, $t as isMinLength, A as NonEmptyString$1, An as toCodecJson$1, Ar as CurrentRedactedNames, At as isBetweenProperties, B as RedactedFromValue, Bn as Filter, Br as fromSetCookie, Bt as isIncluding, C as JsonObject$1, Cn as toType, Cr as CurrentRedactedNames$1, Ct as instanceOf, D as Natural, Dr as setAll$1, Dt as isBetweenCodePoints, E as MutableJson, En as withDecodingDefaultKey, Er as redactUrl, Et as isBetweenBigInt, F as Option, Fn as decodeEffect$1, Fr as merge$5, Ft as isGreaterThanBigInt, G as StructWithRest, Gn as Suspend, Gr as fromDateUnsafe, Gt as isLessThanOrEqualTo, H as String$6, Hn as Literal$1, Hr as encode$1, Ht as isLessThan, In as decodeUnknownEffect, Ir as remove$1, It as isGreaterThanDate, J as TaggedError$1, Jn as decodeTo, Jr as isRedacted, Jt as isMaxCodePoints, K as Symbol$1, Kn as Union$1, Kt as isLessThanOrEqualToBigInt, L as OptionFromOptional, Ln as decodeUnknownResult, Lr as set$1, Lt as isGreaterThanOrEqualTo, M as NullOr, Mn as fromSchemaDraft2020_12, Mr as fromInput$1, Mt as isEndingWith, N as Number$2, Nn as getReferenceKey, Nr as fromRecordUnsafe, Nt as isFinite$1, O as Never, On as omit$1, Or as toString, Ot as isBetweenDate, P as ObjectKeyword, Pn as _is, Pr as isRedactedName, Pt as isGreaterThan, Q as Tuple, Qn as mapOrSame, Qr as Clock, Qt as isMinCodePoints, R as Record, Rn as encodeEffect, Rr as setAll, Rt as isGreaterThanOrEqualToBigInt, S as Json, Sn as toJsonSchemaDocument, Sr as Pointer, St as fromJsonString, T as Literals$2, Tn as withDecodingDefault, Tr as fromInput, Tt as isBetween, U as StringForLiteralAutocomplete, Un as Objects, Ur as formatIso, Ut as isLessThanBigInt, V as SchemaError, Vn as FilterGroup, Vr as decode$4, Vt as isInt, W as Struct, Wn as PropertySignature, Wt as isLessThanDate, X as TemplateLiteral, Xn as isNever, Xr as value, Xt as isMaxProperties, Y as TaggedUnion, Yn as isJson, Yr as make$
|
|
3
|
+
import { $ as interruptible, $a as max, $i as sync$1, $s as isNotNullish, $t as tryPromise, A as effectify, Aa as reduce, An as isSchedule, Ao as getOrNull, Ar as mergeAll, As as redact, At as request, B as fn, Ba as isFailure$1, Bn as Random$1, Bo as orElse$1, Br as addFinalizerExit, Bt as service, C as catchTags, Ca as join$1, Cc as pipe$1, Co as flatMap$2, Cr as buildWithScope, Ct as orElseSucceed, D as contextWith, Da as map$7, Dn as exponential, Do as fromNullishOr, Dr as empty$7, Dt as provideService, E as context, Ec as pipeArguments, Et as provideContext, Fa as fail$2, Fn as catchDone, Fo as isSome, Fr as succeed$4, Ft as runSync, G as forkChild, Ga as try_$1, Gn as round, Gr as makeUnsafe$1, Gs as hasProperty, Ha as map$6, Ho as some, Hr as fork, Ht as sleep, I as filterOrFail, Ia as failVoid, Ir as succeedContext, J as fromOption, Ja as hours, Jr as MinimumLogLevel, Jt as tap, K as forkIn, Ka as format$1, Kn as Done, Kr as provide$2, Kt as suspend, L as flatMap$1, Lo as map$8, Lr as unwrap$1, Lt as scope, M as exit, Ma as empty$6, Mn as min, Mo as getOrUndefined, Mr as orDie$1, Mt as retry, N as fail$1, Na as headUnsafe, Nn as spaced, No as isNone, Nr as provide$3, Nt as runFork, Oa as match$3, On as forever$1, Oo as fromUndefinedOr, Or as fresh, Ot as raceFirst, P as failCause, Pa as size, Pn as toStep, Pr as provideMerge, Pt as runForkWith, Q as interrupt, Qn as annotate$1, Qr as doneUnsafe, Qs as isNotNull, Qt as timeoutOrElse, R as flatMapEager, Ri as forkUnsafe, Ro as match$2, Rr as Scope, Rt as scoped, S as catchTag, Sa as isReadonlyArrayNonEmpty, So as filter$1, Sr as build, Ss as NodeInspectSymbol, St as orDie, T as clockWith, Tr as effectContext, Tt as provide$1, U as forEach$1, Un as parse$2, Uo as toArray, Ut as succeed$1, V as fnUntraced, Va as isSuccess$1, Vn as nextBetween, Vo as orElseSome, Vr as close, Vt as serviceOption, W as forever, Wa as succeed$2, Wn as remainder, Wr as make$45, Wt as succeedNone, X as gen, Xn as TimeoutError, Xr as _await, Xs as isIterable, Xt as timeout, Y as fromResult, Ya as infinity, Yn as StackTrace, Yr as TracerTimingEnabled, Yt as tapCause, Z as ignore, Za as isFinite, Zn as UnknownError$1, Zt as timeoutOption, _ as catchEager, _i as ConsoleRef, _o as make$43, _s as assignProperty, _t as onError, a as andThen, an as updateService, ao as toMillis, ar as findErrorOption, as as PipeInspectableProto, at as logWarning, ba as isArrayNonEmpty, bc as identity, bo as all$1, br as reasonAnnotations, bs as BaseProto, bt as onInterrupt, c as as, ca as toPredicate, ci as failCause$1, co as Reference, cr as hasInterruptsOnly, ct as mapBothEager, d as cached$1, da as appendAll, do as empty$5, dr as isDieReason, ec as isNotUndefined, ei as into, en as try_, eo as millis, et as isEffect, f as cachedWithTTL, fc as or, fi as isFailure, fn as withParentSpan, fo as get$2, fr as isFailReason, ft as match$4, ga as findLast, gc as constVoid, gn as equalBatchKeys, go as getUnsafe, gr as makeFailReason, gt as never$2, h as catchCauseIf, ha as findFirstIndex, hc as constUndefined, hi as void_$1, hn as zipWith, ho as getOrUndefinedUnsafe, hr as makeDieReason, hs as withFiber$1, ht as matchEffect, i as all, ia as ParentSpan, ic as isObject$2, ii as makeUnsafe$2, in as updateContext, io as seconds, it as logInfo, j as ensuring, jn as jittered, jo as getOrThrow, jr as mock, jt as result, k as die, ka as of, kn as fromStep, ko as getOrElse, kr as merge$3, kt as repeat, l as asSome, la as Array$1, lc as isTagged, li as findErrorOption$1, ln as whileLoop, lo as Service, lr as interruptors, lt as mapEager, m as catchCause, ma as findFirst, mc as constTrue, mi as succeed$3, mn as yieldNow, mo as getOrUndefined$1, mr as isTimeoutError, mt as matchCauseEffect, nc as isNullish, ni as isDoneUnsafe, nn as uninterruptible, nr as fail$4, ns as Prototype, nt as logError, o as annotateCurrentSpan, oa as compose, oi as die$1, on as useSpan, or as fromReasons, ot as makeSpanScoped, p as callback, pa as empty$4, pc as constFalse, pi as isSuccess, pn as withSpan$1, po as getOption, q as forkScoped, qa as fromInputUnsafe$1, qr as CurrentLogAnnotations, qt as sync, r as addFinalizer, ra as DisablePropagation, ri as make$44, rn as uninterruptibleMask, rr as filterInterruptors, rt as logFatal, s as annotateLogs, sa as has, sc as isString, si as fail$3, sn as void_, so as zero, sr as hasInterrupts, st as map$5, t as acquireRelease, tc as isNull, ti as isDone, tn as undefined_, to as minutes, tr as done, tt as logDebug, u as asVoid, uc as isUndefined, ui as interrupt$1, un as withFiber, uo as add, ut as mapError, v as catchFilter, va as fromIterable, vc as dual, vi as LogToStderr$1, vn as TaggedClass, vo as makeUnsafe$3, vs as getStackTraceLimit, vt as onExit, w as catch_, wa as last$1, wo as flatMapNullishOr, wr as effect, ws as format, wt as promise, x as catchReason, xa as isCanonicalArrayIndex, xc as memoize, xo as exists, xr as squash, xs as Class, xt as option$1, y as catchIf, ya as headNonEmpty, yc as flow, yo as merge$2, yr as pretty, ys as setStackTraceLimit, za as getOrUndefined$2, zo as none, zr as addFinalizer$1 } from "./Effect-4B1lzxy4.mjs";
|
|
4
|
+
import { $ as take$1, A as mapArray, At as makeUnsafe$4, B as provideContext$1, Bt as toLowerCase, C as fromEffect, Ct as shutdownUnsafe, D as fromReadableStream, Dt as make$46, E as fromQueue, F as mergeAll$1, Ft as interruptAllAs, G as runFold, H as run$4, I as mkString, K as runForEach, L as onEnd, Lt as join$2, M as mapEffect$1, Mt as getCurrent, N as mapError$1, Nt as interrupt$2, O as isStream, Ot as set, P as merge$4, Pt as interruptAll, Q as suspend$1, R as orDie$2, Rt as runIn, S as fromChannel$1, St as poll, T as fromPull, Tt as unbounded, U as runCollect, V as provideService$1, Vt as normalizeNonEmpty, X as splitLines, Y as runLast, Z as succeed$5, _ as flattenArray, _t as make$47, a as catchTags$1, at as fromTransform$1, bt as offerAllUnsafe, c as die$2, ct as unwrap$2, d as ensuring$1, dt as bounded, et as takeUntil, f as fail$5, ft as end, gt as failCauseUnsafe, h as filterMap, ht as failCause$2, i as catchReason$1, it as unwrap$3, j as mapArrayEffect, jt as await_, k as map$9, kt as update, l as drop, lt as make$48, m as filter$2, mt as fail$6, n as callback$1, nt as tap$1, o as catch_$1, ot as mapDone, p as failCause$3, pt as endUnsafe, q as runForEachArray, rt as transduce, s as decodeText, st as toTransform, t as broadcast, tt as takeWhile, u as empty$8, ut as makeUnsafe$5, v as flattenIterable, vt as offer, wt as take, x as fromAsyncIterable, xt as offerUnsafe, yt as offerAll, z as pipeThroughChannel, zt as camelToSnake } from "./Stream-i37nF1ep.mjs";
|
|
5
|
+
import { $ as TupleWithRest, $n as null_, $r as currentTimeMillis, $t as isMinLength, A as NonEmptyString$1, An as toCodecJson$1, Ar as CurrentRedactedNames, At as isBetweenProperties, B as RedactedFromValue, Bn as Filter, Br as fromSetCookie, Bt as isIncluding, C as JsonObject$1, Cn as toType, Cr as CurrentRedactedNames$1, Ct as instanceOf, D as Natural, Dr as setAll$1, Dt as isBetweenCodePoints, E as MutableJson, En as withDecodingDefaultKey, Er as redactUrl, Et as isBetweenBigInt, F as Option, Fn as decodeEffect$1, Fr as merge$5, Ft as isGreaterThanBigInt, G as StructWithRest, Gn as Suspend, Gr as fromDateUnsafe, Gt as isLessThanOrEqualTo, H as String$6, Hn as Literal$1, Hr as encode$1, Ht as isLessThan, In as decodeUnknownEffect, Ir as remove$1, It as isGreaterThanDate, J as TaggedError$1, Jn as decodeTo, Jr as isRedacted, Jt as isMaxCodePoints, K as Symbol$1, Kn as Union$1, Kt as isLessThanOrEqualToBigInt, L as OptionFromOptional, Ln as decodeUnknownResult, Lr as set$1, Lt as isGreaterThanOrEqualTo, M as NullOr, Mn as fromSchemaDraft2020_12, Mr as fromInput$1, Mt as isEndingWith, N as Number$2, Nn as getReferenceKey, Nr as fromRecordUnsafe, Nt as isFinite$1, O as Never, On as omit$1, Or as toString, Ot as isBetweenDate, P as ObjectKeyword, Pn as _is, Pr as isRedactedName, Pt as isGreaterThan, Q as Tuple, Qn as mapOrSame, Qr as Clock, Qt as isMinCodePoints, R as Record, Rn as encodeEffect, Rr as setAll, Rt as isGreaterThanOrEqualToBigInt, S as Json, Sn as toJsonSchemaDocument, Sr as Pointer, St as fromJsonString, T as Literals$2, Tn as withDecodingDefault, Tr as fromInput, Tt as isBetween, U as StringForLiteralAutocomplete, Un as Objects, Ur as formatIso, Ut as isLessThanBigInt, V as SchemaError, Vn as FilterGroup, Vr as decode$4, Vt as isInt, W as Struct, Wn as PropertySignature, Wt as isLessThanDate, X as TemplateLiteral, Xn as isNever, Xr as value, Xt as isMaxProperties, Y as TaggedUnion, Yn as isJson, Yr as make$49, Yt as isMaxLength, Z as TrueLiterals, Zn as isOptional, Zr as stringOrRedacted, Zt as isMaxSize, _ as Error$2, _n as suspend$2, _r as passthroughSubtype, _t as decodeUnknownOption, ai as taggedEnum, an as isSchema, ar as string$3, at as UndefinedOr, b as Finite, bn as toCodecStringTree, br as transformOptional, bt as encodeTo, c as Date$2, cn as isUUID, cr as unknown$2, ct as Unknown, dn as makeFilter, dr as transform$4, dt as check, en as isMinProperties, er as optionalKey$1, et as URL$1, f as DateTimeUtcFromString, fn as makeFilterGroup, fr as transformEffect$1, ft as declare, g as Enum, gn as optionalKey, gr as passthrough, gt as decodeUnknownEffect$1, h as DurationFromMillis, hn as optional$3, ht as decodeTo$1, i as Boolean$5, ii as TaggedError, in as isPropertyNames, ir as resolveIdentifier, it as Undefined, j as Null, jn as fromSchemaDraft07, jr as empty$10, jt as isBetweenSize, k as NonEmptyArray, kn as errorWithPath, kr as unwrap$4, kt as isBetweenLength, l as DateTimeUtc, ln as isUnique, lr as Transformation, lt as Void, m as Duration, mn as mutableKey, mt as decodeSync, n as ArraySchema, ni as Error$1, nn as isMultipleOf, nr as resolveAt, nt as Uint8Array$2, o as BooleanLiterals, oi as assignProperty$1, on as isSchemaError, or as toEncoded, ot as Union, p as Defect, pn as mutable, pr as transformOptional$1, pt as decodeEffect, q as TaggedClass$2, qn as applyToSelfOrLastLinkEncoding, qt as isLessThanOrEqualToDate, r as BigInt$2, ri as TaggedClass$1, rn as isPattern, rr as resolveDescription, rt as Uint8ArrayFromBase64, s as Class$1, si as map$10, sn as isStartingWith, sr as toType$1, st as UniqueSymbol, t as Any, ti as EncodingError, tn as isMinSize, tr as replaceChecks, tt as URLFromString, un as make$50, ur as passthrough$1, v as Exit, vn as tag, vr as transform$5, vt as decodeUnknownSync, w as Literal, wn as withConstructorDefault, wr as empty$9, wt as is, x as Int$1, xn as toEncoded$1, xr as InvalidValue$1, xt as encodeUnknownEffect, y as FalseLiterals, yn as toCodecJson, yr as transformEffect, yt as encodeEffect$1, z as Redacted$4, zn as Arrays, zr as empty$11, zt as isGreaterThanOrEqualToDate } from "./Schema-D4fxUgEU.mjs";
|
|
6
6
|
import * as Http from "node:http";
|
|
7
7
|
import * as Https from "node:https";
|
|
8
8
|
import { PassThrough, Readable, Writable } from "node:stream";
|
|
@@ -208,13 +208,13 @@ const binaryUnits = [
|
|
|
208
208
|
];
|
|
209
209
|
const allUnits = [...decimalUnits, ...binaryUnits.slice(1)];
|
|
210
210
|
const unitsByName = new Map(allUnits.flatMap((unit) => unit.names.map((name) => [name, unit])));
|
|
211
|
-
const make$
|
|
211
|
+
const make$42 = (value) => value;
|
|
212
212
|
const invalid = (message) => {
|
|
213
213
|
throw new Error(`Invalid ByteSize: ${message}`);
|
|
214
214
|
};
|
|
215
215
|
const fromNumber = (input) => {
|
|
216
216
|
if (!Number.isSafeInteger(input) || input < 0) return invalid(`expected a non-negative safe integer, received ${input}`);
|
|
217
|
-
return make$
|
|
217
|
+
return make$42(BigInt(input));
|
|
218
218
|
};
|
|
219
219
|
const fromStringUnsafe = (input) => {
|
|
220
220
|
const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input);
|
|
@@ -225,13 +225,13 @@ const fromStringUnsafe = (input) => {
|
|
|
225
225
|
const scale = BigInt(10) ** BigInt(fraction.length);
|
|
226
226
|
const numerator = BigInt(match[1] + fraction) * unit.factor;
|
|
227
227
|
if (numerator % scale !== bigint0) return invalid(`${JSON.stringify(input)} does not represent an integral number of bytes`);
|
|
228
|
-
return make$
|
|
228
|
+
return make$42(numerator / scale);
|
|
229
229
|
};
|
|
230
230
|
const fromInputUnsafe = (input) => {
|
|
231
231
|
switch (typeof input) {
|
|
232
232
|
case "bigint":
|
|
233
233
|
if (input < bigint0) return invalid(`expected a non-negative bigint, received ${input}`);
|
|
234
|
-
return make$
|
|
234
|
+
return make$42(input);
|
|
235
235
|
case "number": return fromNumber(input);
|
|
236
236
|
case "string": return fromStringUnsafe(input);
|
|
237
237
|
}
|
|
@@ -330,7 +330,7 @@ var RcRefImpl = class {
|
|
|
330
330
|
this.idleTimeToLive = idleTimeToLive;
|
|
331
331
|
}
|
|
332
332
|
};
|
|
333
|
-
const make$
|
|
333
|
+
const make$41 = (options) => withFiber((fiber) => {
|
|
334
334
|
const context = fiber.context;
|
|
335
335
|
const scope = get$2(context, Scope);
|
|
336
336
|
const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== void 0 ? fromInputUnsafe$1(options.idleTimeToLive) : void 0);
|
|
@@ -431,14 +431,14 @@ const invalidate$1 = (self_) => {
|
|
|
431
431
|
};
|
|
432
432
|
//#endregion
|
|
433
433
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/RcRef.js
|
|
434
|
-
const make$
|
|
434
|
+
const make$40 = make$41;
|
|
435
435
|
const get = get$1;
|
|
436
436
|
const invalidate = invalidate$1;
|
|
437
437
|
//#endregion
|
|
438
438
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/FileSystem.js
|
|
439
439
|
const TypeId$29 = "~effect/FileSystem";
|
|
440
440
|
const FileSystem = Service("effect/FileSystem");
|
|
441
|
-
const make$
|
|
441
|
+
const make$39 = (impl) => FileSystem.of({
|
|
442
442
|
...impl,
|
|
443
443
|
[TypeId$29]: TypeId$29,
|
|
444
444
|
exists: (path) => pipe$1(impl.access(path), as(true), catchTag("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed$1(false) : fail$1(e))),
|
|
@@ -490,7 +490,7 @@ var WatchBackend = class extends Service()("effect/FileSystem/WatchBackend") {};
|
|
|
490
490
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Path.js
|
|
491
491
|
const TypeId$28 = "~effect/Path";
|
|
492
492
|
const Path$3 = Service("effect/Path");
|
|
493
|
-
const make$
|
|
493
|
+
const make$38 = (impl) => Path$3.of({
|
|
494
494
|
...impl,
|
|
495
495
|
[TypeId$28]: TypeId$28,
|
|
496
496
|
resolveWithin(root, input) {
|
|
@@ -533,7 +533,7 @@ var QuitError = class extends Error$2("QuitError")({ _tag: tag("QuitError") }) {
|
|
|
533
533
|
};
|
|
534
534
|
const isQuitError = (u) => hasProperty(u, QuitErrorTypeId);
|
|
535
535
|
const Terminal = Service("effect/Terminal");
|
|
536
|
-
const make$
|
|
536
|
+
const make$37 = (impl) => Terminal.of({
|
|
537
537
|
...impl,
|
|
538
538
|
[TypeId$27]: TypeId$27
|
|
539
539
|
});
|
|
@@ -760,7 +760,7 @@ const Int = (options) => {
|
|
|
760
760
|
});
|
|
761
761
|
};
|
|
762
762
|
const map$4 = dual(2, (self, f) => flatMap(self, (a) => succeed(f(a))));
|
|
763
|
-
const Password = (options) => basePrompt(options, "password").pipe(map$4(make$
|
|
763
|
+
const Password = (options) => basePrompt(options, "password").pipe(map$4(make$49));
|
|
764
764
|
const run$3 = fnUntraced(function* (self) {
|
|
765
765
|
const terminal = yield* Terminal;
|
|
766
766
|
const input = yield* cached$1(terminal.readInput);
|
|
@@ -788,6 +788,27 @@ const Select = (options) => {
|
|
|
788
788
|
clear: handleSelectClear(opts)
|
|
789
789
|
});
|
|
790
790
|
};
|
|
791
|
+
const AutoComplete = (options) => {
|
|
792
|
+
const opts = {
|
|
793
|
+
maxPerPage: 10,
|
|
794
|
+
filterLabel: "filter",
|
|
795
|
+
filterPlaceholder: "type to filter",
|
|
796
|
+
emptyMessage: "No matches",
|
|
797
|
+
...options
|
|
798
|
+
};
|
|
799
|
+
const initialIndex = getSelectInitialIndex(opts.choices);
|
|
800
|
+
const filtered = filterAutoCompleteChoices(opts.choices, "");
|
|
801
|
+
const initialState = {
|
|
802
|
+
query: "",
|
|
803
|
+
index: filtered.length === 0 ? 0 : filtered.includes(initialIndex) ? initialIndex : filtered[0],
|
|
804
|
+
filtered
|
|
805
|
+
};
|
|
806
|
+
return Custom(initialState, {
|
|
807
|
+
render: handleAutoCompleteRender(opts),
|
|
808
|
+
process: handleAutoCompleteProcess(opts),
|
|
809
|
+
clear: handleAutoCompleteClear(opts)
|
|
810
|
+
});
|
|
811
|
+
};
|
|
791
812
|
const succeed = (value) => {
|
|
792
813
|
const op = Object.create(proto);
|
|
793
814
|
op._tag = "Succeed";
|
|
@@ -1536,8 +1557,43 @@ const handleProcessFloat = (options) => {
|
|
|
1536
1557
|
}
|
|
1537
1558
|
};
|
|
1538
1559
|
};
|
|
1560
|
+
const filterAutoCompleteChoices = (choices, query) => {
|
|
1561
|
+
const normalizedQuery = query.toLowerCase();
|
|
1562
|
+
const indices = [];
|
|
1563
|
+
for (let i = 0; i < choices.length; i++) if (choices[i].title.toLowerCase().includes(normalizedQuery)) indices.push(i);
|
|
1564
|
+
return indices;
|
|
1565
|
+
};
|
|
1566
|
+
const updateAutoCompleteState = (state, options, query) => {
|
|
1567
|
+
const filtered = filterAutoCompleteChoices(options.choices, query);
|
|
1568
|
+
if (filtered.length === 0) return {
|
|
1569
|
+
...state,
|
|
1570
|
+
query,
|
|
1571
|
+
filtered,
|
|
1572
|
+
index: 0
|
|
1573
|
+
};
|
|
1574
|
+
if (filtered.includes(state.index)) return {
|
|
1575
|
+
...state,
|
|
1576
|
+
query,
|
|
1577
|
+
filtered
|
|
1578
|
+
};
|
|
1579
|
+
return {
|
|
1580
|
+
...state,
|
|
1581
|
+
query,
|
|
1582
|
+
filtered,
|
|
1583
|
+
index: filtered[0]
|
|
1584
|
+
};
|
|
1585
|
+
};
|
|
1586
|
+
const autoCompleteCursor = (state) => getOrElse(findFirstIndex(state.filtered, (index) => index === state.index), () => 0);
|
|
1539
1587
|
const renderSelectOutput = (leadingSymbol, trailingSymbol, options, theme, renderOptions) => options.message === void 0 ? void 0 : renderPrompt$1("", options.message, leadingSymbol, trailingSymbol, theme, renderOptions);
|
|
1540
1588
|
const withSelectHeader = (header, body) => header === void 0 ? body : header + "\n" + body;
|
|
1589
|
+
const renderAutoCompleteFilter = (state, options, theme, renderOptions) => {
|
|
1590
|
+
const filterValue = state.query.length === 0 ? renderOptions?.plain === true ? options.filterPlaceholder : annotate(theme.colors, options.filterPlaceholder, theme.mutedColor) : renderOptions?.plain === true ? state.query : annotate(theme.colors, state.query, combine(underlined, theme.primaryColor));
|
|
1591
|
+
return `[${options.filterLabel}: ${filterValue}]`;
|
|
1592
|
+
};
|
|
1593
|
+
const renderAutoCompleteOutput = (state, leadingSymbol, trailingSymbol, options, theme, renderOptions) => {
|
|
1594
|
+
const filter = renderAutoCompleteFilter(state, options, theme, renderOptions);
|
|
1595
|
+
return renderPrompt$1(filter, options.message, leadingSymbol, trailingSymbol, theme, renderOptions);
|
|
1596
|
+
};
|
|
1541
1597
|
const renderChoicePrefix = (state, choices, toDisplay, currentIndex, figures, renderOptions) => {
|
|
1542
1598
|
const prefix = renderPagingPrefix(figures, currentIndex === toDisplay.startIndex && toDisplay.startIndex > 0, currentIndex === toDisplay.endIndex - 1 && toDisplay.endIndex < choices.length);
|
|
1543
1599
|
if (renderOptions?.plain === true) return state === currentIndex ? figures.pointer + prefix : prefix + " ".repeat(figures.pointer.length);
|
|
@@ -1547,6 +1603,16 @@ const renderChoicePrefix = (state, choices, toDisplay, currentIndex, figures, re
|
|
|
1547
1603
|
}
|
|
1548
1604
|
return state === currentIndex ? annotateSymbol(figures, figures.pointer, figures.primaryColor) + prefix : prefix + " ".repeat(figures.pointer.length);
|
|
1549
1605
|
};
|
|
1606
|
+
const renderAutoCompleteChoicePrefix = (state, options, toDisplay, currentIndex, figures, renderOptions) => {
|
|
1607
|
+
const prefix = renderPagingPrefix(figures, currentIndex === toDisplay.startIndex && toDisplay.startIndex > 0, currentIndex === toDisplay.endIndex - 1 && toDisplay.endIndex < state.filtered.length);
|
|
1608
|
+
const choiceIndex = state.filtered[currentIndex];
|
|
1609
|
+
if (renderOptions?.plain === true) return state.index === choiceIndex ? figures.pointer + prefix : prefix + " ".repeat(figures.pointer.length);
|
|
1610
|
+
if (options.choices[choiceIndex].disabled) {
|
|
1611
|
+
const annotation = combine(bold, figures.mutedColor);
|
|
1612
|
+
return state.index === choiceIndex ? annotateSymbol(figures, figures.pointer, annotation) + prefix : prefix + " ".repeat(figures.pointer.length);
|
|
1613
|
+
}
|
|
1614
|
+
return state.index === choiceIndex ? annotateSymbol(figures, figures.pointer, figures.primaryColor) + prefix : prefix + " ".repeat(figures.pointer.length);
|
|
1615
|
+
};
|
|
1550
1616
|
const renderChoiceTitle = (choice, isSelected, theme, renderOptions) => {
|
|
1551
1617
|
if (renderOptions?.plain === true) return choice.title;
|
|
1552
1618
|
const title = choice.title;
|
|
@@ -1567,6 +1633,22 @@ const renderSelectChoices = (state, options, figures, renderOptions) => {
|
|
|
1567
1633
|
}
|
|
1568
1634
|
return documents.join("\n");
|
|
1569
1635
|
};
|
|
1636
|
+
const renderAutoCompleteChoices = (state, options, figures, renderOptions) => {
|
|
1637
|
+
if (state.filtered.length === 0) return renderOptions?.plain === true ? options.emptyMessage : annotate(figures.colors, options.emptyMessage, figures.mutedColor);
|
|
1638
|
+
const cursor = autoCompleteCursor(state);
|
|
1639
|
+
const toDisplay = entriesToDisplay(cursor, state.filtered.length, options.maxPerPage);
|
|
1640
|
+
const documents = [];
|
|
1641
|
+
for (let index = toDisplay.startIndex; index < toDisplay.endIndex; index++) {
|
|
1642
|
+
const choiceIndex = state.filtered[index];
|
|
1643
|
+
const choice = options.choices[choiceIndex];
|
|
1644
|
+
const isSelected = state.index === choiceIndex;
|
|
1645
|
+
const prefix = renderAutoCompleteChoicePrefix(state, options, toDisplay, index, figures, renderOptions);
|
|
1646
|
+
const title = renderChoiceTitle(choice, isSelected, figures, renderOptions);
|
|
1647
|
+
const description = renderChoiceDescription(choice, isSelected, figures, renderOptions);
|
|
1648
|
+
documents.push(prefix + title + " " + description);
|
|
1649
|
+
}
|
|
1650
|
+
return documents.join("\n");
|
|
1651
|
+
};
|
|
1570
1652
|
const renderSelectNextFrame = fnUntraced(function* (state, options) {
|
|
1571
1653
|
const figures = yield* getTheme(options);
|
|
1572
1654
|
const choices = renderSelectChoices(state, options, figures);
|
|
@@ -1575,6 +1657,14 @@ const renderSelectNextFrame = fnUntraced(function* (state, options) {
|
|
|
1575
1657
|
const promptMsg = renderSelectOutput(leadingSymbol, trailingSymbol, options, figures);
|
|
1576
1658
|
return cursorHide + withSelectHeader(promptMsg, choices);
|
|
1577
1659
|
});
|
|
1660
|
+
const renderAutoCompleteNextFrame = fnUntraced(function* (state, options) {
|
|
1661
|
+
const figures = yield* getTheme(options);
|
|
1662
|
+
const choices = renderAutoCompleteChoices(state, options, figures);
|
|
1663
|
+
const leadingSymbol = annotateSymbol(figures, figures.prefix, figures.primaryColor);
|
|
1664
|
+
const trailingSymbol = annotateSymbol(figures, figures.pointerSmall, figures.mutedColor);
|
|
1665
|
+
const promptMsg = renderAutoCompleteOutput(state, leadingSymbol, trailingSymbol, options, figures);
|
|
1666
|
+
return cursorHide + promptMsg + "\n" + choices;
|
|
1667
|
+
});
|
|
1578
1668
|
const renderSelectSubmission = fnUntraced(function* (state, options) {
|
|
1579
1669
|
const figures = yield* getTheme(options);
|
|
1580
1670
|
const selected = options.choices[state].title;
|
|
@@ -1582,6 +1672,13 @@ const renderSelectSubmission = fnUntraced(function* (state, options) {
|
|
|
1582
1672
|
const trailingSymbol = annotateSymbol(figures, figures.ellipsis, figures.mutedColor);
|
|
1583
1673
|
return (renderSelectOutput(leadingSymbol, trailingSymbol, options, figures) ?? leadingSymbol) + " " + annotate(figures.colors, selected, figures.submittedColor) + "\n";
|
|
1584
1674
|
});
|
|
1675
|
+
const renderAutoCompleteSubmission = fnUntraced(function* (state, options) {
|
|
1676
|
+
const figures = yield* getTheme(options);
|
|
1677
|
+
const selected = options.choices[state.index].title;
|
|
1678
|
+
const leadingSymbol = annotateSymbol(figures, figures.tick, figures.successColor);
|
|
1679
|
+
const trailingSymbol = annotateSymbol(figures, figures.ellipsis, figures.mutedColor);
|
|
1680
|
+
return renderAutoCompleteOutput(state, leadingSymbol, trailingSymbol, options, figures) + " " + annotate(figures.colors, selected, figures.submittedColor) + "\n";
|
|
1681
|
+
});
|
|
1585
1682
|
const processSelectCursorUp = (state, choices) => {
|
|
1586
1683
|
if (state === 0) return succeed$1(Action$1.NextFrame({ state: choices.length - 1 }));
|
|
1587
1684
|
return succeed$1(Action$1.NextFrame({ state: state - 1 }));
|
|
@@ -1593,6 +1690,35 @@ const processSelectCursorDown = (state, choices) => {
|
|
|
1593
1690
|
const processSelectNext = (state, choices) => {
|
|
1594
1691
|
return succeed$1(Action$1.NextFrame({ state: (state + 1) % choices.length }));
|
|
1595
1692
|
};
|
|
1693
|
+
const processAutoCompleteCursorUp = (state) => {
|
|
1694
|
+
if (state.filtered.length === 0) return succeed$1(Action$1.Beep());
|
|
1695
|
+
const cursor = autoCompleteCursor(state);
|
|
1696
|
+
const nextCursor = cursor === 0 ? state.filtered.length - 1 : cursor - 1;
|
|
1697
|
+
return succeed$1(Action$1.NextFrame({ state: {
|
|
1698
|
+
...state,
|
|
1699
|
+
index: state.filtered[nextCursor]
|
|
1700
|
+
} }));
|
|
1701
|
+
};
|
|
1702
|
+
const processAutoCompleteCursorDown = (state) => {
|
|
1703
|
+
if (state.filtered.length === 0) return succeed$1(Action$1.Beep());
|
|
1704
|
+
const nextCursor = (autoCompleteCursor(state) + 1) % state.filtered.length;
|
|
1705
|
+
return succeed$1(Action$1.NextFrame({ state: {
|
|
1706
|
+
...state,
|
|
1707
|
+
index: state.filtered[nextCursor]
|
|
1708
|
+
} }));
|
|
1709
|
+
};
|
|
1710
|
+
const processAutoCompleteNext = (state) => processAutoCompleteCursorDown(state);
|
|
1711
|
+
const processAutoCompleteBackspace = (state, options) => {
|
|
1712
|
+
if (state.query.length === 0) return succeed$1(Action$1.Beep());
|
|
1713
|
+
const query = state.query.slice(0, state.query.length - 1);
|
|
1714
|
+
return succeed$1(Action$1.NextFrame({ state: updateAutoCompleteState(state, options, query) }));
|
|
1715
|
+
};
|
|
1716
|
+
const processAutoCompleteClear = (state, options) => succeed$1(Action$1.NextFrame({ state: updateAutoCompleteState(state, options, "") }));
|
|
1717
|
+
const processAutoCompleteInput = (input, state, options) => {
|
|
1718
|
+
if (input.length === 0) return succeed$1(Action$1.Beep());
|
|
1719
|
+
const query = state.query + input;
|
|
1720
|
+
return succeed$1(Action$1.NextFrame({ state: updateAutoCompleteState(state, options, query) }));
|
|
1721
|
+
};
|
|
1596
1722
|
const handleSelectRender = (options) => {
|
|
1597
1723
|
return (state, action) => {
|
|
1598
1724
|
return Action$1.$match(action, {
|
|
@@ -1602,6 +1728,15 @@ const handleSelectRender = (options) => {
|
|
|
1602
1728
|
});
|
|
1603
1729
|
};
|
|
1604
1730
|
};
|
|
1731
|
+
const handleAutoCompleteRender = (options) => {
|
|
1732
|
+
return (state, action) => {
|
|
1733
|
+
return Action$1.$match(action, {
|
|
1734
|
+
Beep: () => succeed$1(renderBeep),
|
|
1735
|
+
NextFrame: ({ state }) => renderAutoCompleteNextFrame(state, options),
|
|
1736
|
+
Submit: () => renderAutoCompleteSubmission(state, options)
|
|
1737
|
+
});
|
|
1738
|
+
};
|
|
1739
|
+
};
|
|
1605
1740
|
const handleSelectClear = (options) => fnUntraced(function* (state, _) {
|
|
1606
1741
|
const columns = yield* (yield* Terminal).columns;
|
|
1607
1742
|
const figures = yield* getTheme(options);
|
|
@@ -1610,6 +1745,14 @@ const handleSelectClear = (options) => fnUntraced(function* (state, _) {
|
|
|
1610
1745
|
const choicesText = renderSelectChoices(state, options, figures, { plain: true });
|
|
1611
1746
|
return eraseText(withSelectHeader(promptText, choicesText), columns) + clearPrompt;
|
|
1612
1747
|
});
|
|
1748
|
+
const handleAutoCompleteClear = (options) => fnUntraced(function* (state, _) {
|
|
1749
|
+
const columns = yield* (yield* Terminal).columns;
|
|
1750
|
+
const figures = yield* getTheme(options);
|
|
1751
|
+
const clearPrompt = eraseLine + "\x1B[G";
|
|
1752
|
+
const promptText = renderAutoCompleteOutput(state, figures.prefix, figures.pointerSmall, options, figures, { plain: true });
|
|
1753
|
+
const choicesText = renderAutoCompleteChoices(state, options, figures, { plain: true });
|
|
1754
|
+
return eraseText(`${promptText}\n${choicesText}`, columns) + clearPrompt;
|
|
1755
|
+
});
|
|
1613
1756
|
const handleSelectProcess = (options) => {
|
|
1614
1757
|
return (input, state) => {
|
|
1615
1758
|
switch (input.key.name) {
|
|
@@ -1628,6 +1771,31 @@ const handleSelectProcess = (options) => {
|
|
|
1628
1771
|
}
|
|
1629
1772
|
};
|
|
1630
1773
|
};
|
|
1774
|
+
const handleAutoCompleteProcess = (options) => {
|
|
1775
|
+
return (input, state) => {
|
|
1776
|
+
if (input.key.ctrl) switch (input.key.name) {
|
|
1777
|
+
case "u": return processAutoCompleteClear(state, options);
|
|
1778
|
+
case "p":
|
|
1779
|
+
case "k": return processAutoCompleteCursorUp(state);
|
|
1780
|
+
case "n": return processAutoCompleteCursorDown(state);
|
|
1781
|
+
default: return succeed$1(Action$1.Beep());
|
|
1782
|
+
}
|
|
1783
|
+
switch (input.key.name) {
|
|
1784
|
+
case "up": return processAutoCompleteCursorUp(state);
|
|
1785
|
+
case "down": return processAutoCompleteCursorDown(state);
|
|
1786
|
+
case "tab": return processAutoCompleteNext(state);
|
|
1787
|
+
case "backspace": return processAutoCompleteBackspace(state, options);
|
|
1788
|
+
case "enter":
|
|
1789
|
+
case "return": {
|
|
1790
|
+
if (state.filtered.length === 0) return succeed$1(Action$1.Beep());
|
|
1791
|
+
const selected = options.choices[state.index];
|
|
1792
|
+
if (selected.disabled) return succeed$1(Action$1.Beep());
|
|
1793
|
+
return succeed$1(Action$1.Submit({ value: selected.value }));
|
|
1794
|
+
}
|
|
1795
|
+
default: return processAutoCompleteInput(getOrElse(input.input, () => ""), state, options);
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
};
|
|
1631
1799
|
const renderClearScreen = fnUntraced(function* (state, options) {
|
|
1632
1800
|
const columns = yield* (yield* Terminal).columns;
|
|
1633
1801
|
const figures = yield* getTheme(options);
|
|
@@ -2042,7 +2210,7 @@ const updateHeaders$1 = (headers, body) => {
|
|
|
2042
2210
|
//#endregion
|
|
2043
2211
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Url.js
|
|
2044
2212
|
var UrlError = class extends TaggedError("UrlError") {};
|
|
2045
|
-
const make$
|
|
2213
|
+
const make$36 = (url, params, hash) => try_$1({
|
|
2046
2214
|
try: () => {
|
|
2047
2215
|
const urlInstance = new URL(url, baseUrl());
|
|
2048
2216
|
for (let i = 0; i < params.params.length; i++) {
|
|
@@ -2089,12 +2257,12 @@ function makeWith$3(method, url, urlParams, hash, headers, body) {
|
|
|
2089
2257
|
return self;
|
|
2090
2258
|
}
|
|
2091
2259
|
const empty$2 = makeWith$3("GET", "", empty$9, none(), empty$10, empty$3);
|
|
2092
|
-
const make$
|
|
2260
|
+
const make$35 = (method) => (url, options) => modify(empty$2, {
|
|
2093
2261
|
method,
|
|
2094
2262
|
url,
|
|
2095
2263
|
...options ?? void 0
|
|
2096
2264
|
});
|
|
2097
|
-
const post = make$
|
|
2265
|
+
const post = make$35("POST");
|
|
2098
2266
|
const modify = dual(2, (self, options) => {
|
|
2099
2267
|
let result = self;
|
|
2100
2268
|
if (options.method) result = setMethod(result, options.method);
|
|
@@ -2141,7 +2309,7 @@ const setBody = dual(2, (self, body) => {
|
|
|
2141
2309
|
const bodyJsonUnsafe = dual(2, (self, body) => setBody(self, jsonUnsafe(body)));
|
|
2142
2310
|
const bodyUrlParams = dual(2, (self, input) => setBody(self, urlParams(fromInput(input))));
|
|
2143
2311
|
function toUrl(self) {
|
|
2144
|
-
const r = make$
|
|
2312
|
+
const r = make$36(self.url, self.urlParams, getOrUndefined(self.hash));
|
|
2145
2313
|
if (isSuccess$1(r)) return some(r.success);
|
|
2146
2314
|
return none();
|
|
2147
2315
|
}
|
|
@@ -2352,13 +2520,13 @@ const Proto$12 = {
|
|
|
2352
2520
|
return { _id: "effect/HttpClient" };
|
|
2353
2521
|
},
|
|
2354
2522
|
...Object.fromEntries(allShort.map(([fullMethod, method]) => [method, function(url, options) {
|
|
2355
|
-
return this.execute(make$
|
|
2523
|
+
return this.execute(make$35(fullMethod)(url, options));
|
|
2356
2524
|
}]))
|
|
2357
2525
|
};
|
|
2358
|
-
const make$
|
|
2526
|
+
const make$34 = (f) => makeWith$2((effect) => flatMap$1(effect, (request) => withFiber((fiber) => {
|
|
2359
2527
|
const scopedController = scopedRequests.get(request);
|
|
2360
2528
|
const controller = scopedController ?? new AbortController();
|
|
2361
|
-
const urlResult = make$
|
|
2529
|
+
const urlResult = make$36(request.url, request.urlParams, getOrUndefined(request.hash));
|
|
2362
2530
|
if (isFailure$1(urlResult)) return fail$1(new HttpClientError({ reason: new InvalidUrlError({
|
|
2363
2531
|
request,
|
|
2364
2532
|
cause: urlResult.failure
|
|
@@ -2681,7 +2849,7 @@ const toArrayBuffer = (readable, options) => {
|
|
|
2681
2849
|
const readableToPullUnsafe = (options) => {
|
|
2682
2850
|
const readable = options.readable;
|
|
2683
2851
|
const closeOnDone = options.closeOnDone ?? true;
|
|
2684
|
-
const exit = options.exit ?? make$
|
|
2852
|
+
const exit = options.exit ?? make$46(void 0);
|
|
2685
2853
|
const latch = options.latch ?? makeUnsafe$4(false);
|
|
2686
2854
|
function onReadable() {
|
|
2687
2855
|
latch.openUnsafe();
|
|
@@ -2898,7 +3066,7 @@ const makeAgent = (options) => zipWith(acquireRelease(sync(() => new Http.Agent(
|
|
|
2898
3066
|
const layerAgentOptions = flow(makeAgent, effect(HttpAgent));
|
|
2899
3067
|
const makeNodeHttp = gen(function* () {
|
|
2900
3068
|
const agent = yield* HttpAgent;
|
|
2901
|
-
return make$
|
|
3069
|
+
return make$34((request, url, signal) => {
|
|
2902
3070
|
const nodeRequest = url.protocol === "https:" ? Https.request(url, {
|
|
2903
3071
|
agent: agent.https,
|
|
2904
3072
|
method: request.method,
|
|
@@ -3084,7 +3252,7 @@ const getErrorReported = (u) => {
|
|
|
3084
3252
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Stdio.js
|
|
3085
3253
|
const TypeId$19 = "~effect/Stdio";
|
|
3086
3254
|
const Stdio = Service(TypeId$19);
|
|
3087
|
-
const make$
|
|
3255
|
+
const make$33 = (options) => ({
|
|
3088
3256
|
[TypeId$19]: TypeId$19,
|
|
3089
3257
|
stdinIsTerminal: succeed$1(false),
|
|
3090
3258
|
stdoutIsTerminal: succeed$1(false),
|
|
@@ -3303,7 +3471,7 @@ function makeProvider(load, mapInput) {
|
|
|
3303
3471
|
function makeSource(get, transform) {
|
|
3304
3472
|
return makeProvider((path) => get(transform(path)), (f) => makeSource(get, (path) => f(transform(path))));
|
|
3305
3473
|
}
|
|
3306
|
-
function make$
|
|
3474
|
+
function make$32(get) {
|
|
3307
3475
|
return makeSource(get, identityPath);
|
|
3308
3476
|
}
|
|
3309
3477
|
function emptyStringAsMissing(value, preserveEmptyStrings) {
|
|
@@ -3312,7 +3480,7 @@ function emptyStringAsMissing(value, preserveEmptyStrings) {
|
|
|
3312
3480
|
function fromEnvRecord(env, options) {
|
|
3313
3481
|
const preserveEmptyStrings = options?.preserveEmptyStrings === true;
|
|
3314
3482
|
const trie = buildEnvTrie(env);
|
|
3315
|
-
return make$
|
|
3483
|
+
return make$32((path) => succeed$1(nodeAtEnv(trie, env, path, preserveEmptyStrings)));
|
|
3316
3484
|
}
|
|
3317
3485
|
function fromEnv(options) {
|
|
3318
3486
|
return fromEnvRecord(options?.env ?? {
|
|
@@ -3380,7 +3548,7 @@ const Proto$10 = {
|
|
|
3380
3548
|
return { _id: "Config" };
|
|
3381
3549
|
}
|
|
3382
3550
|
};
|
|
3383
|
-
function make$
|
|
3551
|
+
function make$31(evaluator) {
|
|
3384
3552
|
const self = Object.create(Proto$10);
|
|
3385
3553
|
self.evaluator = evaluator;
|
|
3386
3554
|
self.parse = (provider) => flatMapEager(evaluator(provider, []), fromResult);
|
|
@@ -3388,10 +3556,10 @@ function make$30(evaluator) {
|
|
|
3388
3556
|
}
|
|
3389
3557
|
const evaluateAt = (self, provider, pathPrefix) => self.evaluator(provider, pathPrefix);
|
|
3390
3558
|
const map$3 = dual(2, (self, f) => {
|
|
3391
|
-
return make$
|
|
3559
|
+
return make$31((provider, pathPrefix) => map$5(evaluateAt(self, provider, pathPrefix), map$6(f)));
|
|
3392
3560
|
});
|
|
3393
3561
|
const orElse = dual(2, (self, that) => {
|
|
3394
|
-
return make$
|
|
3562
|
+
return make$31((provider, pathPrefix) => matchCauseEffect(evaluateAt(self, provider, pathPrefix), {
|
|
3395
3563
|
onFailure: (cause) => {
|
|
3396
3564
|
const error = findErrorOption(cause);
|
|
3397
3565
|
return isSome(error) && cause.reasons.every(isFailReason) ? evaluateAt(that(error.value), provider, pathPrefix) : failCause(cause);
|
|
@@ -3400,7 +3568,7 @@ const orElse = dual(2, (self, that) => {
|
|
|
3400
3568
|
}));
|
|
3401
3569
|
});
|
|
3402
3570
|
const withDefault$2 = dual(2, (self, defaultValue) => {
|
|
3403
|
-
return make$
|
|
3571
|
+
return make$31((provider, pathPrefix) => mapEager(evaluateAt(self, provider, pathPrefix), (resolution) => isFailure$1(resolution) ? succeed$2(defaultValue) : resolution));
|
|
3404
3572
|
});
|
|
3405
3573
|
const option = (self) => self.pipe(map$3(some), withDefault$2(none()));
|
|
3406
3574
|
const isSourceError = (u) => isTagged(u, "SourceError");
|
|
@@ -3484,9 +3652,9 @@ const toConfigCursorAST = memoize((root) => {
|
|
|
3484
3652
|
function schema$1(codec, path) {
|
|
3485
3653
|
const codecStringTree = toCodecStringTree(codec);
|
|
3486
3654
|
const encodedAst = toEncoded(codecStringTree.ast);
|
|
3487
|
-
const decodeCursor = decodeUnknownEffect(make$
|
|
3655
|
+
const decodeCursor = decodeUnknownEffect(make$50(toConfigCursorAST(codecStringTree.ast)));
|
|
3488
3656
|
const localPath = typeof path === "string" ? [path] : path ?? [];
|
|
3489
|
-
return make$
|
|
3657
|
+
return make$31((provider, pathPrefix) => {
|
|
3490
3658
|
const fullPath = [...pathPrefix, ...localPath];
|
|
3491
3659
|
return loadCursor(provider, fullPath).pipe(flatMapEager((cursor) => decodeCursor(cursor).pipe(mapEager(succeed$2), catchEager((issue) => {
|
|
3492
3660
|
const error = new ConfigError(new SchemaError(fullPath.length > 0 ? new Pointer(fullPath, issue) : issue));
|
|
@@ -4101,7 +4269,7 @@ const Path$2 = (pathType, mustExist) => {
|
|
|
4101
4269
|
}));
|
|
4102
4270
|
return Object.assign(primitive, { pathType });
|
|
4103
4271
|
};
|
|
4104
|
-
const Redacted$2 = makePrimitive("Redacted", (value) => succeed$1(make$
|
|
4272
|
+
const Redacted$2 = makePrimitive("Redacted", (value) => succeed$1(make$49(value)));
|
|
4105
4273
|
const getTypeName = (primitive) => {
|
|
4106
4274
|
switch (primitive._tag) {
|
|
4107
4275
|
case "Boolean": return "boolean";
|
|
@@ -6388,7 +6556,7 @@ const formatShellArg = (arg) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(arg) ? arg : `'$
|
|
|
6388
6556
|
//#endregion
|
|
6389
6557
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/cli/Command.js
|
|
6390
6558
|
const isCommand = (u) => hasProperty(u, TypeId$15);
|
|
6391
|
-
const make$
|
|
6559
|
+
const make$30 = (name, config, handler) => {
|
|
6392
6560
|
const parsedConfig = parseConfig(config ?? {});
|
|
6393
6561
|
return makeCommand({
|
|
6394
6562
|
name,
|
|
@@ -6621,7 +6789,7 @@ const runWith = (command, config) => {
|
|
|
6621
6789
|
}
|
|
6622
6790
|
const services = match$2(logLevel, {
|
|
6623
6791
|
onNone: () => empty$5(),
|
|
6624
|
-
onSome: (level) => make$
|
|
6792
|
+
onSome: (level) => make$43(MinimumLogLevel, level)
|
|
6625
6793
|
});
|
|
6626
6794
|
yield* provideContext(program, services);
|
|
6627
6795
|
}, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$2(error) : fail$2(error), (error) => andThen(showHelp(command, error, config.renderErrors !== false), fail$1(error))), catchFilter((error) => config.renderErrors !== false && isCliError(error) && error._tag === "UserError" ? succeed$2(error) : fail$2(error), (error) => andThen(showUserError(error), fail$1(error))), catchFilter((e) => isQuitError(e) ? succeed$2(e) : fail$2(e), (_) => interrupt));
|
|
@@ -6651,7 +6819,7 @@ const HandleProto = {
|
|
|
6651
6819
|
}
|
|
6652
6820
|
};
|
|
6653
6821
|
const makeHandle = (params) => Object.setPrototypeOf({ ...params }, HandleProto);
|
|
6654
|
-
const make$
|
|
6822
|
+
const make$29 = (spawn) => {
|
|
6655
6823
|
const streamString = (command, options) => spawn(command).pipe(map$5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap$3);
|
|
6656
6824
|
const streamLines = (command, options) => splitLines(streamString(command, options));
|
|
6657
6825
|
return ChildProcessSpawner.of({
|
|
@@ -6682,7 +6850,7 @@ const makeStandardCommand = (command, args, options) => Object.assign(Object.cre
|
|
|
6682
6850
|
args,
|
|
6683
6851
|
options
|
|
6684
6852
|
});
|
|
6685
|
-
const make$
|
|
6853
|
+
const make$28 = function make(...args) {
|
|
6686
6854
|
if (isTemplateString(args[0])) {
|
|
6687
6855
|
const [templates, ...expressions] = args;
|
|
6688
6856
|
const tokens = parseTemplates(templates, expressions);
|
|
@@ -6863,7 +7031,7 @@ const taskkill = (childProcess, onExit = () => {}) => {
|
|
|
6863
7031
|
"/F"
|
|
6864
7032
|
], { windowsHide: true }, onExit);
|
|
6865
7033
|
};
|
|
6866
|
-
const make$
|
|
7034
|
+
const make$27 = gen(function* () {
|
|
6867
7035
|
const fs = yield* FileSystem;
|
|
6868
7036
|
const path = yield* Path$3;
|
|
6869
7037
|
const resolveWorkingDirectory = fnUntraced(function* (options) {
|
|
@@ -7186,7 +7354,7 @@ const make$26 = gen(function* () {
|
|
|
7186
7354
|
const stdinConfig = resolveStdinOption(command.options);
|
|
7187
7355
|
const sourceStream = unwrap$3(succeed$1(getSourceStream(handles[handles.length - 1], options.from)));
|
|
7188
7356
|
const toOption = options.to ?? "stdin";
|
|
7189
|
-
if (toOption === "stdin") handles.push(yield* spawnCommand(make$
|
|
7357
|
+
if (toOption === "stdin") handles.push(yield* spawnCommand(make$28(command.command, command.args, {
|
|
7190
7358
|
...command.options,
|
|
7191
7359
|
stdin: {
|
|
7192
7360
|
...stdinConfig,
|
|
@@ -7198,7 +7366,7 @@ const make$26 = gen(function* () {
|
|
|
7198
7366
|
if (isNotUndefined(fd)) {
|
|
7199
7367
|
const fdName$1 = fdName(fd);
|
|
7200
7368
|
const existingFds = command.options.additionalFds ?? {};
|
|
7201
|
-
handles.push(yield* spawnCommand(make$
|
|
7369
|
+
handles.push(yield* spawnCommand(make$28(command.command, command.args, {
|
|
7202
7370
|
...command.options,
|
|
7203
7371
|
additionalFds: {
|
|
7204
7372
|
...existingFds,
|
|
@@ -7208,7 +7376,7 @@ const make$26 = gen(function* () {
|
|
|
7208
7376
|
}
|
|
7209
7377
|
}
|
|
7210
7378
|
})));
|
|
7211
|
-
} else handles.push(yield* spawnCommand(make$
|
|
7379
|
+
} else handles.push(yield* spawnCommand(make$28(command.command, command.args, {
|
|
7212
7380
|
...command.options,
|
|
7213
7381
|
stdin: {
|
|
7214
7382
|
...stdinConfig,
|
|
@@ -7240,9 +7408,9 @@ const make$26 = gen(function* () {
|
|
|
7240
7408
|
}
|
|
7241
7409
|
}
|
|
7242
7410
|
});
|
|
7243
|
-
return make$
|
|
7411
|
+
return make$29(spawnCommand);
|
|
7244
7412
|
});
|
|
7245
|
-
const layer$20 = effect(ChildProcessSpawner, make$
|
|
7413
|
+
const layer$20 = effect(ChildProcessSpawner, make$27);
|
|
7246
7414
|
const flattenCommand = (command) => {
|
|
7247
7415
|
const commands = [];
|
|
7248
7416
|
const pipeOptions = [];
|
|
@@ -7322,7 +7490,7 @@ function v7Bytes(timestampMillis, bytes = randomBytes()) {
|
|
|
7322
7490
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Crypto.js
|
|
7323
7491
|
const TypeId$13 = "~effect/Crypto";
|
|
7324
7492
|
const Crypto = Service("effect/Crypto");
|
|
7325
|
-
const make$
|
|
7493
|
+
const make$26 = (impl) => {
|
|
7326
7494
|
const randomBytesUnsafe = impl.randomBytes;
|
|
7327
7495
|
const randomBytes = (size) => map$5(validateSize("randomBytes", size), randomBytesUnsafe);
|
|
7328
7496
|
const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 256 + bytes[6];
|
|
@@ -7399,11 +7567,11 @@ const digest = (algorithm, data) => try_({
|
|
|
7399
7567
|
cause
|
|
7400
7568
|
})
|
|
7401
7569
|
});
|
|
7402
|
-
const make$
|
|
7570
|
+
const make$25 = make$26({
|
|
7403
7571
|
randomBytes: NodeCrypto.randomBytes,
|
|
7404
7572
|
digest
|
|
7405
7573
|
});
|
|
7406
|
-
const layer$19 = succeed$4(Crypto, make$
|
|
7574
|
+
const layer$19 = succeed$4(Crypto, make$25);
|
|
7407
7575
|
//#endregion
|
|
7408
7576
|
//#region node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.2.1/node_modules/@effect/platform-node/dist/NodeCrypto.js
|
|
7409
7577
|
const layer$18 = layer$19;
|
|
@@ -7779,7 +7947,7 @@ const writeFile = (path, data, options) => callback((resume, signal) => {
|
|
|
7779
7947
|
resume(fail$1(handleBadArgument("writeFile")(err)));
|
|
7780
7948
|
}
|
|
7781
7949
|
});
|
|
7782
|
-
const makeFileSystem = map$5(serviceOption(WatchBackend), (backend) => make$
|
|
7950
|
+
const makeFileSystem = map$5(serviceOption(WatchBackend), (backend) => make$39({
|
|
7783
7951
|
access,
|
|
7784
7952
|
chmod,
|
|
7785
7953
|
chown,
|
|
@@ -7832,15 +8000,15 @@ const fileUrlOps = (windows) => ({
|
|
|
7832
8000
|
})
|
|
7833
8001
|
})
|
|
7834
8002
|
});
|
|
7835
|
-
const layerPosix = succeed$4(Path$3)(make$
|
|
8003
|
+
const layerPosix = succeed$4(Path$3)(make$38({
|
|
7836
8004
|
...Path.posix,
|
|
7837
8005
|
...fileUrlOps(false)
|
|
7838
8006
|
}));
|
|
7839
|
-
const layerWin32 = succeed$4(Path$3)(make$
|
|
8007
|
+
const layerWin32 = succeed$4(Path$3)(make$38({
|
|
7840
8008
|
...Path.win32,
|
|
7841
8009
|
...fileUrlOps(true)
|
|
7842
8010
|
}));
|
|
7843
|
-
const layer$15 = succeed$4(Path$3)(make$
|
|
8011
|
+
const layer$15 = succeed$4(Path$3)(make$38({
|
|
7844
8012
|
...Path,
|
|
7845
8013
|
...fileUrlOps(void 0)
|
|
7846
8014
|
}));
|
|
@@ -7849,7 +8017,7 @@ const layer$15 = succeed$4(Path$3)(make$37({
|
|
|
7849
8017
|
const layer$14 = layer$15;
|
|
7850
8018
|
//#endregion
|
|
7851
8019
|
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.5_effect@4.0.5/node_modules/@effect/platform-node-shared/dist/NodeStdio.js
|
|
7852
|
-
const layer$13 = succeed$4(Stdio, make$
|
|
8020
|
+
const layer$13 = succeed$4(Stdio, make$33({
|
|
7853
8021
|
args: sync(() => process.argv.slice(2)),
|
|
7854
8022
|
stdinIsTerminal: sync(() => process.stdin.isTTY === true),
|
|
7855
8023
|
stdoutIsTerminal: sync(() => process.stdout.isTTY === true),
|
|
@@ -7890,10 +8058,10 @@ const layer$13 = succeed$4(Stdio, make$32({
|
|
|
7890
8058
|
const layer$12 = layer$13;
|
|
7891
8059
|
//#endregion
|
|
7892
8060
|
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.5_effect@4.0.5/node_modules/@effect/platform-node-shared/dist/NodeTerminal.js
|
|
7893
|
-
const make$
|
|
8061
|
+
const make$24 = fnUntraced(function* (shouldQuit = defaultShouldQuit) {
|
|
7894
8062
|
const stdin = process.stdin;
|
|
7895
8063
|
const stdout = process.stdout;
|
|
7896
|
-
const lines = yield* make$
|
|
8064
|
+
const lines = yield* make$47();
|
|
7897
8065
|
let inputEnded = stdin.readableEnded;
|
|
7898
8066
|
let readlineActive = false;
|
|
7899
8067
|
const onStdinEnd = () => {
|
|
@@ -7902,7 +8070,7 @@ const make$23 = fnUntraced(function* (shouldQuit = defaultShouldQuit) {
|
|
|
7902
8070
|
};
|
|
7903
8071
|
stdin.once("end", onStdinEnd);
|
|
7904
8072
|
yield* addFinalizer(() => sync(() => stdin.off("end", onStdinEnd)));
|
|
7905
|
-
const rlRef = yield* make$
|
|
8073
|
+
const rlRef = yield* make$40({
|
|
7906
8074
|
acquire: acquireRelease(sync(() => {
|
|
7907
8075
|
const rl = readline.createInterface({
|
|
7908
8076
|
input: stdin,
|
|
@@ -7936,7 +8104,7 @@ const make$23 = fnUntraced(function* (shouldQuit = defaultShouldQuit) {
|
|
|
7936
8104
|
const columns = sync(() => stdout.columns ?? 0);
|
|
7937
8105
|
const rows = sync(() => stdout.rows ?? 0);
|
|
7938
8106
|
const readInput = gen(function* () {
|
|
7939
|
-
const queue = yield* make$
|
|
8107
|
+
const queue = yield* make$47();
|
|
7940
8108
|
const handleKeypress = (s, k) => {
|
|
7941
8109
|
const userInput = {
|
|
7942
8110
|
input: fromUndefinedOr(s),
|
|
@@ -7980,7 +8148,7 @@ const make$23 = fnUntraced(function* (shouldQuit = defaultShouldQuit) {
|
|
|
7980
8148
|
cause: err
|
|
7981
8149
|
}))));
|
|
7982
8150
|
}));
|
|
7983
|
-
return make$
|
|
8151
|
+
return make$37({
|
|
7984
8152
|
columns,
|
|
7985
8153
|
rows,
|
|
7986
8154
|
readInput,
|
|
@@ -7988,7 +8156,7 @@ const make$23 = fnUntraced(function* (shouldQuit = defaultShouldQuit) {
|
|
|
7988
8156
|
display
|
|
7989
8157
|
});
|
|
7990
8158
|
});
|
|
7991
|
-
const layer$11 = effect(Terminal, make$
|
|
8159
|
+
const layer$11 = effect(Terminal, make$24(defaultShouldQuit));
|
|
7992
8160
|
function defaultShouldQuit(input) {
|
|
7993
8161
|
const key = input.key;
|
|
7994
8162
|
return key.name === "escape" || key.ctrl && (key.name === "c" || key.name === "d");
|
|
@@ -8024,7 +8192,7 @@ const runMain = runMain$1;
|
|
|
8024
8192
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/socket/Socket.js
|
|
8025
8193
|
const TypeId$12 = "~effect/socket/Socket";
|
|
8026
8194
|
const Socket = Service("effect/socket/Socket");
|
|
8027
|
-
const make$
|
|
8195
|
+
const make$23 = (options) => Socket.of({
|
|
8028
8196
|
[TypeId$12]: TypeId$12,
|
|
8029
8197
|
reader: options.reader,
|
|
8030
8198
|
writer: options.writer
|
|
@@ -8270,7 +8438,7 @@ const fromWebSocket = (acquire, options) => withFiber((fiber) => {
|
|
|
8270
8438
|
write,
|
|
8271
8439
|
writeAll
|
|
8272
8440
|
});
|
|
8273
|
-
return succeed$1(make$
|
|
8441
|
+
return succeed$1(make$23({
|
|
8274
8442
|
reader,
|
|
8275
8443
|
writer
|
|
8276
8444
|
}));
|
|
@@ -8418,7 +8586,7 @@ const Proto$5 = {
|
|
|
8418
8586
|
const makePrompt = (content) => Object.assign(Object.create(Proto$5), { content });
|
|
8419
8587
|
const decodeMessagesSync = decodeSync(ArraySchema(Message));
|
|
8420
8588
|
const empty$1 = makePrompt([]);
|
|
8421
|
-
const make$
|
|
8589
|
+
const make$22 = (input) => {
|
|
8422
8590
|
if (typeof input === "string") {
|
|
8423
8591
|
const part = makePart$1("text", { text: input });
|
|
8424
8592
|
const message = makeMessage("user", { content: [part] });
|
|
@@ -8550,7 +8718,7 @@ const fromResponseParts = (parts) => {
|
|
|
8550
8718
|
return makePrompt(messages);
|
|
8551
8719
|
};
|
|
8552
8720
|
const concat = dual(2, (self, input) => {
|
|
8553
|
-
const other = make$
|
|
8721
|
+
const other = make$22(input);
|
|
8554
8722
|
if (self.content.length === 0) return other;
|
|
8555
8723
|
if (other.content.length === 0) return self;
|
|
8556
8724
|
return fromMessages([...self.content, ...other.content]);
|
|
@@ -8572,7 +8740,7 @@ var KeyValueStoreError = class extends TaggedError("KeyValueStoreError") {
|
|
|
8572
8740
|
[ErrorTypeId] = ErrorTypeId;
|
|
8573
8741
|
};
|
|
8574
8742
|
const KeyValueStore = Service("effect/persistence/KeyValueStore");
|
|
8575
|
-
const make$
|
|
8743
|
+
const make$21 = (options) => KeyValueStore.of({
|
|
8576
8744
|
[TypeId$10]: TypeId$10,
|
|
8577
8745
|
has: (key) => map$5(options.get(key), isNotUndefined),
|
|
8578
8746
|
isEmpty: map$5(options.size, (size) => size === 0),
|
|
@@ -8607,7 +8775,7 @@ const layerFileSystem = (directory) => effect(KeyValueStore)(gen(function* () {
|
|
|
8607
8775
|
message: `Invalid key ${key}`
|
|
8608
8776
|
})) : f(path.join(directory, encodeURIComponent(key)));
|
|
8609
8777
|
if (!(yield* fs.exists(directory))) yield* fs.makeDirectory(directory, { recursive: true });
|
|
8610
|
-
return make$
|
|
8778
|
+
return make$21({
|
|
8611
8779
|
get: (key) => withKeyPath("get", key, (path) => catchTag(fs.readFileString(path), "PlatformError", (cause) => cause.reason._tag === "NotFound" ? undefined_ : fail$1(new KeyValueStoreError({
|
|
8612
8780
|
method: "get",
|
|
8613
8781
|
key,
|
|
@@ -8705,7 +8873,7 @@ const Proto$4 = {
|
|
|
8705
8873
|
};
|
|
8706
8874
|
}
|
|
8707
8875
|
};
|
|
8708
|
-
const make$
|
|
8876
|
+
const make$20 = (provider, modelName, layer) => Object.assign(Object.create(Proto$4), { provider }, merge$3(layer, succeedContext(ProviderName.context(provider).pipe(add(ModelName, modelName)))));
|
|
8709
8877
|
//#endregion
|
|
8710
8878
|
//#region src/ApplyPatch.ts
|
|
8711
8879
|
const BEGIN = "*** Begin Patch";
|
|
@@ -9051,7 +9219,7 @@ var ExaError = class extends TaggedError$1()("ExaError", { cause: Defect() }) {}
|
|
|
9051
9219
|
const layer$8 = effect(ExaSearch, gen(function* () {
|
|
9052
9220
|
const scope$5 = yield* scope;
|
|
9053
9221
|
const getClient = yield* cachedWithTTL(gen(function* () {
|
|
9054
|
-
const McpClient = yield* tryPromise(() => import("./McpClient-
|
|
9222
|
+
const McpClient = yield* tryPromise(() => import("./McpClient-DMfHHEx3.mjs"));
|
|
9055
9223
|
const context = yield* buildWithScope(McpClient.layer, scope$5);
|
|
9056
9224
|
return get$2(context, McpClient.McpClient);
|
|
9057
9225
|
}), (exit) => isSuccess(exit) ? infinity : zero);
|
|
@@ -9534,7 +9702,7 @@ var AiError = class extends Error$2("effect/ai/AiError/AiError")({
|
|
|
9534
9702
|
}
|
|
9535
9703
|
};
|
|
9536
9704
|
const isAiErrorReason = (u) => hasProperty(u, ReasonTypeId);
|
|
9537
|
-
const make$
|
|
9705
|
+
const make$19 = (params) => new AiError(params);
|
|
9538
9706
|
const reasonFromHttpStatus = (params) => {
|
|
9539
9707
|
const { status, http, metadata, description } = params;
|
|
9540
9708
|
const common = {
|
|
@@ -9613,7 +9781,7 @@ const userDefinedProto = (options) => {
|
|
|
9613
9781
|
self.id = `effect/ai/Tool/${options.name}`;
|
|
9614
9782
|
return self;
|
|
9615
9783
|
};
|
|
9616
|
-
const make$
|
|
9784
|
+
const make$18 = (name, options) => {
|
|
9617
9785
|
const successSchema = options?.success ?? Void;
|
|
9618
9786
|
const failureSchema = options?.failure ?? Never;
|
|
9619
9787
|
return userDefinedProto({
|
|
@@ -9718,7 +9886,7 @@ function isEmptyParamsRecord(indexSignature) {
|
|
|
9718
9886
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/Toolkit.js
|
|
9719
9887
|
const TypeId$6 = "~effect/ai/Toolkit";
|
|
9720
9888
|
const FailureOrigin = Reference("effect/ai/Toolkit/FailureOrigin", { defaultValue: () => "result" });
|
|
9721
|
-
const failureCause = (error, origin) => annotate$1(fail$4(error), make$
|
|
9889
|
+
const failureCause = (error, origin) => annotate$1(fail$4(error), make$43(FailureOrigin, origin));
|
|
9722
9890
|
const Proto$2 = {
|
|
9723
9891
|
...Prototype({
|
|
9724
9892
|
label: "Toolkit",
|
|
@@ -9752,7 +9920,7 @@ const Proto$2 = {
|
|
|
9752
9920
|
tool: name,
|
|
9753
9921
|
parameters: params
|
|
9754
9922
|
});
|
|
9755
|
-
if (isUndefined(tool)) return yield* make$
|
|
9923
|
+
if (isUndefined(tool)) return yield* make$19({
|
|
9756
9924
|
module: "Toolkit",
|
|
9757
9925
|
method: `${name}.handle`,
|
|
9758
9926
|
reason: new ToolNotFoundError({
|
|
@@ -9761,7 +9929,7 @@ const Proto$2 = {
|
|
|
9761
9929
|
})
|
|
9762
9930
|
});
|
|
9763
9931
|
const schemas = getSchemas(tool);
|
|
9764
|
-
const encodeResult = (result, isFailure) => schemas.encodeResult(result, isFailure).pipe(mapError((cause) => make$
|
|
9932
|
+
const encodeResult = (result, isFailure) => schemas.encodeResult(result, isFailure).pipe(mapError((cause) => make$19({
|
|
9765
9933
|
module: "Toolkit",
|
|
9766
9934
|
method: `${name}.handle`,
|
|
9767
9935
|
reason: new ToolResultEncodingError({
|
|
@@ -9772,7 +9940,7 @@ const Proto$2 = {
|
|
|
9772
9940
|
})));
|
|
9773
9941
|
const decodedParamsResult = yield* result(schemas.decodeParameters(params, options));
|
|
9774
9942
|
if (isFailure$1(decodedParamsResult)) {
|
|
9775
|
-
const error = make$
|
|
9943
|
+
const error = make$19({
|
|
9776
9944
|
module: "Toolkit",
|
|
9777
9945
|
method: `${name}.handle`,
|
|
9778
9946
|
reason: new ToolParameterValidationError({
|
|
@@ -9790,7 +9958,7 @@ const Proto$2 = {
|
|
|
9790
9958
|
})));
|
|
9791
9959
|
}
|
|
9792
9960
|
const decodedParams = decodedParamsResult.success;
|
|
9793
|
-
const queue = yield* make$
|
|
9961
|
+
const queue = yield* make$47();
|
|
9794
9962
|
const context = {
|
|
9795
9963
|
toolCallId,
|
|
9796
9964
|
preliminary: (result) => asVoid(offer(queue, {
|
|
@@ -9808,14 +9976,14 @@ const Proto$2 = {
|
|
|
9808
9976
|
onSuccess: () => end(queue)
|
|
9809
9977
|
}), forkChild);
|
|
9810
9978
|
const normalizeError = (error) => {
|
|
9811
|
-
return isSchemaError(error) ? make$
|
|
9979
|
+
return isSchemaError(error) ? make$19({
|
|
9812
9980
|
module: "Toolkit",
|
|
9813
9981
|
method: `${name}.handle`,
|
|
9814
9982
|
reason: new InvalidToolResultError({
|
|
9815
9983
|
toolName: name,
|
|
9816
9984
|
description: `Tool handler returned invalid result: ${error.message}`
|
|
9817
9985
|
})
|
|
9818
|
-
}) : isAiErrorReason(error) ? make$
|
|
9986
|
+
}) : isAiErrorReason(error) ? make$19({
|
|
9819
9987
|
module: "Toolkit",
|
|
9820
9988
|
method: `${name}.handle`,
|
|
9821
9989
|
reason: error
|
|
@@ -9876,7 +10044,7 @@ const resolveInput = (...tools) => {
|
|
|
9876
10044
|
return output;
|
|
9877
10045
|
};
|
|
9878
10046
|
const empty = makeProto$2({});
|
|
9879
|
-
const make$
|
|
10047
|
+
const make$17 = (...tools) => makeProto$2(resolveInput(...tools));
|
|
9880
10048
|
const merge$1 = (...toolkits) => {
|
|
9881
10049
|
const tools = {};
|
|
9882
10050
|
for (const toolkit of toolkits) for (const [name, tool] of Object.entries(toolkit.tools)) assignProperty(tools, name, tool);
|
|
@@ -10275,7 +10443,7 @@ var CommandLimits = class extends Reference("clanka/AgentTools/CommandLimits", {
|
|
|
10275
10443
|
timeout: void 0,
|
|
10276
10444
|
outputChars: void 0
|
|
10277
10445
|
}) }) {};
|
|
10278
|
-
const makeBashTool = (timeout) => make$
|
|
10446
|
+
const makeBashTool = (timeout) => make$18("bash", {
|
|
10279
10447
|
description: "Run a bash command and return the output",
|
|
10280
10448
|
parameters: Struct({
|
|
10281
10449
|
command: String$6,
|
|
@@ -10285,12 +10453,12 @@ const makeBashTool = (timeout) => make$17("bash", {
|
|
|
10285
10453
|
dependencies: [CurrentDirectory]
|
|
10286
10454
|
});
|
|
10287
10455
|
const globNamesDirectory = (glob) => glob.split("/").slice(0, -1).some((segment) => segment.length > 0 && !/[*?[\]{}]/.test(segment));
|
|
10288
|
-
const AgentTools = make$
|
|
10456
|
+
const AgentTools = make$17(make$18("changeDirectory", {
|
|
10289
10457
|
description: "Change the executor's working directory to an existing directory and return its absolute path. Relative paths resolve from the current directory without shell expansion. Await this before dependent tools. The change persists across your scripts. A sub-agent starts in your directory at the time it is created, and its changes do not affect yours. AGENTS.md files and skills that apply to the new directory are sent to you after the script ends. The semantic-search index root stays fixed.",
|
|
10290
10458
|
parameters: String$6.annotate({ identifier: "directory" }),
|
|
10291
10459
|
success: String$6,
|
|
10292
10460
|
dependencies: [DirectoryChanger]
|
|
10293
|
-
}), make$
|
|
10461
|
+
}), make$18("readFile", {
|
|
10294
10462
|
description: "Read a file and optionally filter the lines to return. Returns null if the file doesn't exist. For png/jpeg/gif/webp files the image itself is attached to your next turn and a short marker is returned instead of the bytes; line ranges are not allowed on images.",
|
|
10295
10463
|
parameters: Struct({
|
|
10296
10464
|
path: String$6,
|
|
@@ -10300,7 +10468,7 @@ const AgentTools = make$16(make$17("changeDirectory", {
|
|
|
10300
10468
|
}),
|
|
10301
10469
|
success: NullOr(String$6),
|
|
10302
10470
|
dependencies: [CurrentDirectory, ImageAttacher]
|
|
10303
|
-
}), make$
|
|
10471
|
+
}), make$18("rg", {
|
|
10304
10472
|
description: "Search for a pattern in files using ripgrep",
|
|
10305
10473
|
parameters: Struct({
|
|
10306
10474
|
pattern: String$6,
|
|
@@ -10310,7 +10478,7 @@ const AgentTools = make$16(make$17("changeDirectory", {
|
|
|
10310
10478
|
}),
|
|
10311
10479
|
success: String$6,
|
|
10312
10480
|
dependencies: [CurrentDirectory]
|
|
10313
|
-
}), make$
|
|
10481
|
+
}), make$18("delegate", {
|
|
10314
10482
|
description: "Delegate a task to another software engineer / sub-agent. By default it waits for the sub-agent and returns its output. With `background: true` it returns straight away with status \"running\"; the sub-agent keeps working while you take more turns, and its result is sent to you as a <subagent> message when it finishes. Keep the returned id to address the agent later.",
|
|
10315
10483
|
parameters: Struct({
|
|
10316
10484
|
prompt: String$6,
|
|
@@ -10319,13 +10487,13 @@ const AgentTools = make$16(make$17("changeDirectory", {
|
|
|
10319
10487
|
success: DelegateResult,
|
|
10320
10488
|
failure: String$6,
|
|
10321
10489
|
dependencies: [SubagentExecutor]
|
|
10322
|
-
}), make$
|
|
10490
|
+
}), make$18("waitAgents", {
|
|
10323
10491
|
description: "Wait until the given sub-agents have finished, or all of your sub-agents when no ids are passed. A failed agent is returned with status \"failed\" and its error as the output; it does not throw.",
|
|
10324
10492
|
parameters: UndefinedOr(ArraySchema(String$6)).annotate({ identifier: "ids" }),
|
|
10325
10493
|
success: ArraySchema(SubagentResult),
|
|
10326
10494
|
failure: String$6,
|
|
10327
10495
|
dependencies: [SubagentExecutor]
|
|
10328
|
-
}), make$
|
|
10496
|
+
}), make$18("messageAgent", {
|
|
10329
10497
|
description: "Send a message to one of your sub-agents. A running agent receives it as steering; a finished agent starts a new turn on top of its previous conversation. Returns straight away; the result is sent to you as a <subagent> message.",
|
|
10330
10498
|
parameters: Struct({
|
|
10331
10499
|
id: String$6,
|
|
@@ -10334,73 +10502,73 @@ const AgentTools = make$16(make$17("changeDirectory", {
|
|
|
10334
10502
|
success: SubagentResult,
|
|
10335
10503
|
failure: String$6,
|
|
10336
10504
|
dependencies: [SubagentExecutor]
|
|
10337
|
-
}), make$
|
|
10505
|
+
}), make$18("stopAgent", {
|
|
10338
10506
|
description: "Stop one of your sub-agents and every agent it started. Returns its final status.",
|
|
10339
10507
|
parameters: String$6.annotate({ identifier: "id" }),
|
|
10340
10508
|
success: SubagentResult,
|
|
10341
10509
|
failure: String$6,
|
|
10342
10510
|
dependencies: [SubagentExecutor]
|
|
10343
|
-
}), make$
|
|
10511
|
+
}), make$18("listAgents", {
|
|
10344
10512
|
description: "List the sub-agents you have started in this run, with their status.",
|
|
10345
10513
|
parameters: Void,
|
|
10346
10514
|
success: ArraySchema(SubagentInfo),
|
|
10347
10515
|
dependencies: [SubagentExecutor]
|
|
10348
|
-
}), make$
|
|
10516
|
+
}), make$18("glob", {
|
|
10349
10517
|
description: "Find files matching a glob pattern.",
|
|
10350
10518
|
parameters: String$6.annotate({ identifier: "pattern" }),
|
|
10351
10519
|
success: ArraySchema(String$6),
|
|
10352
10520
|
dependencies: [CurrentDirectory]
|
|
10353
|
-
}), make$
|
|
10521
|
+
}), make$18("gh", {
|
|
10354
10522
|
description: "Use the GitHub CLI to run a command - use this instead of the bash tool.",
|
|
10355
10523
|
parameters: ArraySchema(String$6).annotate({ identifier: "args" }),
|
|
10356
10524
|
success: String$6,
|
|
10357
10525
|
dependencies: [CurrentDirectory]
|
|
10358
|
-
}), makeBashTool(defaultBashTimeout), make$
|
|
10526
|
+
}), makeBashTool(defaultBashTimeout), make$18("applyPatch", {
|
|
10359
10527
|
description: "Add, update or remove multiple files with a git diff / unified diff / wrapped patch.",
|
|
10360
10528
|
parameters: String$6.annotate({ identifier: "patch" }),
|
|
10361
10529
|
success: String$6,
|
|
10362
10530
|
dependencies: [CurrentDirectory]
|
|
10363
|
-
}), make$
|
|
10531
|
+
}), make$18("writeFile", {
|
|
10364
10532
|
description: "Write content to a file, creating parent directories if needed.",
|
|
10365
10533
|
parameters: Struct({
|
|
10366
10534
|
path: String$6,
|
|
10367
10535
|
content: String$6
|
|
10368
10536
|
}),
|
|
10369
10537
|
dependencies: [CurrentDirectory]
|
|
10370
|
-
}), make$
|
|
10538
|
+
}), make$18("removeFile", {
|
|
10371
10539
|
description: "Remove a file.",
|
|
10372
10540
|
parameters: String$6.annotate({ identifier: "path" }),
|
|
10373
10541
|
dependencies: [CurrentDirectory]
|
|
10374
|
-
}), make$
|
|
10542
|
+
}), make$18("renameFile", {
|
|
10375
10543
|
description: "Rename or move a file, creating parent directories if needed.",
|
|
10376
10544
|
parameters: Struct({
|
|
10377
10545
|
from: String$6,
|
|
10378
10546
|
to: String$6
|
|
10379
10547
|
}),
|
|
10380
10548
|
dependencies: [CurrentDirectory]
|
|
10381
|
-
}), make$
|
|
10549
|
+
}), make$18("ls", {
|
|
10382
10550
|
description: "List the contents of a directory",
|
|
10383
10551
|
parameters: String$6.annotate({ identifier: "directory" }),
|
|
10384
10552
|
success: ArraySchema(String$6),
|
|
10385
10553
|
dependencies: [CurrentDirectory]
|
|
10386
|
-
}), make$
|
|
10554
|
+
}), make$18("webSearch", {
|
|
10387
10555
|
description: "Search the web for recent information.",
|
|
10388
10556
|
parameters: ExaSearchOptions,
|
|
10389
10557
|
success: String$6
|
|
10390
|
-
}), make$
|
|
10558
|
+
}), make$18("fetchMarkdown", {
|
|
10391
10559
|
description: "Fetch a web page and convert it to markdown.",
|
|
10392
10560
|
parameters: String$6.annotate({ identifier: "url" }),
|
|
10393
10561
|
success: String$6
|
|
10394
|
-
}), make$
|
|
10562
|
+
}), make$18("sleep", {
|
|
10395
10563
|
description: "Sleep for a specified number of milliseconds",
|
|
10396
10564
|
parameters: Finite.annotate({ identifier: "ms" })
|
|
10397
|
-
}), make$
|
|
10565
|
+
}), make$18("taskComplete", {
|
|
10398
10566
|
description: "Only call this when the task is fully complete and you have a final output message to send.",
|
|
10399
10567
|
parameters: String$6.annotate({ identifier: "output" }),
|
|
10400
10568
|
dependencies: [TaskCompleter],
|
|
10401
10569
|
failure: String$6
|
|
10402
10570
|
}));
|
|
10403
|
-
const SearchTool = make$
|
|
10571
|
+
const SearchTool = make$17(make$18("search", {
|
|
10404
10572
|
description: "Semantic code search - you just need to describe what you are looking for",
|
|
10405
10573
|
parameters: String$6.annotate({ identifier: "query" }),
|
|
10406
10574
|
success: String$6,
|
|
@@ -10512,7 +10680,7 @@ const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(gen(function* () {
|
|
|
10512
10680
|
}
|
|
10513
10681
|
args.push(options.pattern);
|
|
10514
10682
|
const run = fnUntraced(function* (args) {
|
|
10515
|
-
let stream = spawner.streamLines(make$
|
|
10683
|
+
let stream = spawner.streamLines(make$28("rg", args, {
|
|
10516
10684
|
cwd,
|
|
10517
10685
|
stdin: "ignore"
|
|
10518
10686
|
}));
|
|
@@ -10537,7 +10705,7 @@ const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(gen(function* () {
|
|
|
10537
10705
|
timeoutMs
|
|
10538
10706
|
}));
|
|
10539
10707
|
const cwd = yield* CurrentDirectory;
|
|
10540
|
-
const cmd = make$
|
|
10708
|
+
const cmd = make$28("bash", ["-c", options.command], {
|
|
10541
10709
|
cwd,
|
|
10542
10710
|
stdin: "ignore"
|
|
10543
10711
|
});
|
|
@@ -10546,7 +10714,7 @@ const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(gen(function* () {
|
|
|
10546
10714
|
gh: fn("AgentTools.gh")(function* (args) {
|
|
10547
10715
|
yield* logInfo(`Calling "gh"`).pipe(annotateLogs({ args }));
|
|
10548
10716
|
const cwd = yield* CurrentDirectory;
|
|
10549
|
-
const cmd = make$
|
|
10717
|
+
const cmd = make$28("gh", args, {
|
|
10550
10718
|
cwd,
|
|
10551
10719
|
stdin: "ignore"
|
|
10552
10720
|
});
|
|
@@ -11239,7 +11407,7 @@ const makeUnsafe = (backing, deferred) => {
|
|
|
11239
11407
|
self.deferred = deferred;
|
|
11240
11408
|
return self;
|
|
11241
11409
|
};
|
|
11242
|
-
const make$
|
|
11410
|
+
const make$16 = () => acquireRelease(sync(() => makeUnsafe(new Set(), makeUnsafe$2())), (set) => suspend(() => {
|
|
11243
11411
|
const state = set.state;
|
|
11244
11412
|
if (state._tag === "Closed") return void_;
|
|
11245
11413
|
set.state = { _tag: "Closed" };
|
|
@@ -11316,7 +11484,7 @@ function getStreamSchemas(schema) {
|
|
|
11316
11484
|
}
|
|
11317
11485
|
const schema = declare(isStream);
|
|
11318
11486
|
function Stream(success, error) {
|
|
11319
|
-
return make$
|
|
11487
|
+
return make$50(schema.ast, {
|
|
11320
11488
|
[StreamSchemaTypeId]: StreamSchemaTypeId,
|
|
11321
11489
|
success,
|
|
11322
11490
|
error
|
|
@@ -11422,7 +11590,7 @@ const makeProto$1 = (options) => {
|
|
|
11422
11590
|
Rpc.key = `effect/rpc/Rpc/${options._tag}`;
|
|
11423
11591
|
return Rpc;
|
|
11424
11592
|
};
|
|
11425
|
-
const make$
|
|
11593
|
+
const make$15 = (tag, options) => {
|
|
11426
11594
|
const successSchema = options?.success ?? Void;
|
|
11427
11595
|
const errorSchema = options?.error ?? Never;
|
|
11428
11596
|
const defectSchema = options?.defect ?? Defect();
|
|
@@ -11750,7 +11918,7 @@ const makeNoSerialization = fnUntraced(function* (group, options) {
|
|
|
11750
11918
|
};
|
|
11751
11919
|
});
|
|
11752
11920
|
let clientIdCounter = 0;
|
|
11753
|
-
const make$
|
|
11921
|
+
const make$14 = fnUntraced(function* (group, options) {
|
|
11754
11922
|
const clientId = clientIdCounter++;
|
|
11755
11923
|
const { codecFor, run, send, supportsAck, supportsTransferables } = yield* Protocol$1;
|
|
11756
11924
|
const rpcSchemas = makeRpcSchemas(codecFor);
|
|
@@ -11977,7 +12145,7 @@ const RpcGroupProto = {
|
|
|
11977
12145
|
});
|
|
11978
12146
|
},
|
|
11979
12147
|
annotateRpcs(service, value) {
|
|
11980
|
-
return this.annotateRpcsMerge(make$
|
|
12148
|
+
return this.annotateRpcsMerge(make$43(service, value));
|
|
11981
12149
|
},
|
|
11982
12150
|
annotateMerge(context) {
|
|
11983
12151
|
return makeProto({
|
|
@@ -11998,7 +12166,7 @@ const makeProto = (options) => Object.assign(function() {}, RpcGroupProto, {
|
|
|
11998
12166
|
requests: options.requests,
|
|
11999
12167
|
annotations: options.annotations
|
|
12000
12168
|
});
|
|
12001
|
-
const make$
|
|
12169
|
+
const make$13 = (...rpcs) => makeProto({
|
|
12002
12170
|
requests: new Map(rpcs.map((rpc) => [rpc._tag, rpc])),
|
|
12003
12171
|
annotations: empty$5()
|
|
12004
12172
|
});
|
|
@@ -12716,7 +12884,7 @@ const makeLocalWith = fnUntraced(function* (options) {
|
|
|
12716
12884
|
const scriptTimeout = map$8(fromUndefinedOr(options.limits?.scriptTimeout), fromInputUnsafe$1);
|
|
12717
12885
|
const excluded = excludedToolNames(options.excludeTools);
|
|
12718
12886
|
const search = yield* serviceOption(SemanticSearch);
|
|
12719
|
-
const BuiltInTools = make$
|
|
12887
|
+
const BuiltInTools = make$17(...Object.values(merge$1(isSome(search) ? AgentToolsWithSearch : AgentTools, make$17(makeBashTool(commandLimits.timeout ?? defaultBashTimeout))).tools).filter((tool) => !excluded.has(tool.name)));
|
|
12720
12888
|
const hasSearch = "search" in BuiltInTools.tools;
|
|
12721
12889
|
const AllTools = merge$1(BuiltInTools, options.tools ?? empty);
|
|
12722
12890
|
const tools = yield* AllTools;
|
|
@@ -12788,7 +12956,7 @@ const makeLocalWith = fnUntraced(function* (options) {
|
|
|
12788
12956
|
}), add(ImageAttacher, opts.onImage), add(CommandLimits, commandLimits), add(Console, console), add(CurrentLogAnnotations, {}), isSome(search) ? add(SemanticSearch, search.value) : identity);
|
|
12789
12957
|
yield* gen(function* () {
|
|
12790
12958
|
const source = prepareScript(opts.script);
|
|
12791
|
-
const settled = yield* make$
|
|
12959
|
+
const settled = yield* make$44();
|
|
12792
12960
|
const worker = yield* acquireRelease(sync(() => new Worker(workerSource, {
|
|
12793
12961
|
eval: true,
|
|
12794
12962
|
workerData: {
|
|
@@ -12891,7 +13059,7 @@ const makeLocalWith = fnUntraced(function* (options) {
|
|
|
12891
13059
|
};
|
|
12892
13060
|
});
|
|
12893
13061
|
const makeRpc = gen(function* () {
|
|
12894
|
-
const client = yield* make$
|
|
13062
|
+
const client = yield* make$14(Rpcs, { spanPrefix: "AgentExecutorClient" });
|
|
12895
13063
|
return AgentExecutor.of({
|
|
12896
13064
|
capabilities: orDie(client.capabilities()),
|
|
12897
13065
|
execute: (opts) => Scope.useSync((scope) => {
|
|
@@ -12973,10 +13141,10 @@ const ExecuteOutput = TaggedUnion({
|
|
|
12973
13141
|
},
|
|
12974
13142
|
Environment: { environment: ExecutionEnvironment }
|
|
12975
13143
|
});
|
|
12976
|
-
var Rpcs = class extends make$
|
|
13144
|
+
var Rpcs = class extends make$13(make$15("capabilities", { success: Capabilities }), make$15("respond", { payload: {
|
|
12977
13145
|
id: Finite,
|
|
12978
13146
|
response: AgentResponse
|
|
12979
|
-
} }), make$
|
|
13147
|
+
} }), make$15("execute", {
|
|
12980
13148
|
payload: Struct({
|
|
12981
13149
|
script: String$6,
|
|
12982
13150
|
environment: ExecutionEnvironment,
|
|
@@ -12984,13 +13152,13 @@ var Rpcs = class extends make$12(make$14("capabilities", { success: Capabilities
|
|
|
12984
13152
|
}),
|
|
12985
13153
|
success: ExecuteOutput,
|
|
12986
13154
|
stream: true
|
|
12987
|
-
}), make$
|
|
13155
|
+
}), make$15("renderEnvironment", {
|
|
12988
13156
|
payload: {
|
|
12989
13157
|
environment: ExecutionEnvironment,
|
|
12990
13158
|
reset: Boolean$5
|
|
12991
13159
|
},
|
|
12992
13160
|
success: EnvironmentUpdate
|
|
12993
|
-
}), make$
|
|
13161
|
+
}), make$15("executeUnsafe", {
|
|
12994
13162
|
payload: Struct({
|
|
12995
13163
|
tool: String$6,
|
|
12996
13164
|
params: Json,
|
|
@@ -29305,7 +29473,7 @@ var Connected = class extends TaggedClass$1("Connected") {};
|
|
|
29305
29473
|
var Failed = class extends TaggedClass$1("Failed") {};
|
|
29306
29474
|
var McpServers = class extends Service()("clanka/McpServers") {};
|
|
29307
29475
|
const layer$6 = (config) => fromEntries(Object.entries(config).map(([name, entry]) => toEntry(name, entry)));
|
|
29308
|
-
const fromEntries = (entries) => effect(McpServers, make$
|
|
29476
|
+
const fromEntries = (entries) => effect(McpServers, make$12(entries));
|
|
29309
29477
|
const reservedWords = new Set([
|
|
29310
29478
|
"arguments",
|
|
29311
29479
|
"await",
|
|
@@ -29432,7 +29600,7 @@ const currentStatus = (server) => {
|
|
|
29432
29600
|
const shortReason = (error) => error.split("\n")[0];
|
|
29433
29601
|
const stderrLines = 20;
|
|
29434
29602
|
const stderrChars = 2e3;
|
|
29435
|
-
const make$
|
|
29603
|
+
const make$12 = fnUntraced(function* (entries) {
|
|
29436
29604
|
const runFork = runForkWith(yield* context());
|
|
29437
29605
|
const owners = new Map();
|
|
29438
29606
|
const planned = entries.map((entry) => {
|
|
@@ -29874,7 +30042,7 @@ function toCodec(schema) {
|
|
|
29874
30042
|
const encoded = toEncoded(jsonCodec.ast);
|
|
29875
30043
|
const from = transform(encoded);
|
|
29876
30044
|
if (from === encoded) return jsonCodec.ast === schema.ast ? schema : jsonCodec;
|
|
29877
|
-
return make$
|
|
30045
|
+
return make$50(decodeTo(from, jsonCodec.ast, passthrough$1()));
|
|
29878
30046
|
}
|
|
29879
30047
|
function transform(root) {
|
|
29880
30048
|
let cache;
|
|
@@ -30372,7 +30540,7 @@ const ErrorPart = Struct({
|
|
|
30372
30540
|
//#endregion
|
|
30373
30541
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/ResponseIdTracker.js
|
|
30374
30542
|
var ResponseIdTracker = class extends Service()("effect/ai/ResponseIdTracker") {};
|
|
30375
|
-
const make$
|
|
30543
|
+
const make$11 = sync(() => {
|
|
30376
30544
|
const sentParts = new Map();
|
|
30377
30545
|
const none$1 = () => {
|
|
30378
30546
|
sentParts.clear();
|
|
@@ -30493,7 +30661,7 @@ var GenerateObjectResponse = class extends GenerateTextResponse {
|
|
|
30493
30661
|
this.value = value;
|
|
30494
30662
|
}
|
|
30495
30663
|
};
|
|
30496
|
-
const make$
|
|
30664
|
+
const make$10 = fnUntraced(function* (params) {
|
|
30497
30665
|
const codecTransformer = params.codecTransformer ?? defaultCodecTransformer;
|
|
30498
30666
|
const parentSpanTransformer = yield* serviceOption(CurrentSpanTransformer);
|
|
30499
30667
|
const getSpanTransformer = serviceOption(CurrentSpanTransformer).pipe(map$5(orElse$1(() => parentSpanTransformer)));
|
|
@@ -30503,7 +30671,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30503
30671
|
const generateText = (options) => useSpan("LanguageModel.generateText", { kind: "client" }, fnUntraced(function* (span) {
|
|
30504
30672
|
const spanTransformer = yield* getSpanTransformer;
|
|
30505
30673
|
const providerOptions = {
|
|
30506
|
-
prompt: make$
|
|
30674
|
+
prompt: make$22(options.prompt),
|
|
30507
30675
|
tools: [],
|
|
30508
30676
|
toolChoice: "none",
|
|
30509
30677
|
responseFormat: { type: "text" },
|
|
@@ -30514,7 +30682,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30514
30682
|
const content = yield* generateContent(options, providerOptions);
|
|
30515
30683
|
applySpanTransformer(spanTransformer, content, providerOptions);
|
|
30516
30684
|
return new GenerateTextResponse(content);
|
|
30517
|
-
}, catchTag("SchemaError", (error) => fail$1(make$
|
|
30685
|
+
}, catchTag("SchemaError", (error) => fail$1(make$19({
|
|
30518
30686
|
module: "LanguageModel",
|
|
30519
30687
|
method: "generateText",
|
|
30520
30688
|
reason: InvalidOutputError.fromSchemaError(error)
|
|
@@ -30527,7 +30695,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30527
30695
|
}, fnUntraced(function* (span) {
|
|
30528
30696
|
const spanTransformer = yield* getSpanTransformer;
|
|
30529
30697
|
const providerOptions = {
|
|
30530
|
-
prompt: make$
|
|
30698
|
+
prompt: make$22(options.prompt),
|
|
30531
30699
|
tools: [],
|
|
30532
30700
|
toolChoice: "none",
|
|
30533
30701
|
responseFormat: {
|
|
@@ -30543,7 +30711,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30543
30711
|
applySpanTransformer(spanTransformer, content, providerOptions);
|
|
30544
30712
|
const { codec } = yield* try_({
|
|
30545
30713
|
try: () => codecTransformer(options.schema),
|
|
30546
|
-
catch: (error) => make$
|
|
30714
|
+
catch: (error) => make$19({
|
|
30547
30715
|
module: "LanguageModel",
|
|
30548
30716
|
method: "generateObject",
|
|
30549
30717
|
reason: new UnsupportedSchemaError({ description: error instanceof Error ? error.message : String(error) })
|
|
@@ -30551,7 +30719,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30551
30719
|
});
|
|
30552
30720
|
const value = yield* resolveStructuredOutput(content, codec);
|
|
30553
30721
|
return new GenerateObjectResponse(value, content);
|
|
30554
|
-
}, catchTag("SchemaError", (error) => fail$1(make$
|
|
30722
|
+
}, catchTag("SchemaError", (error) => fail$1(make$19({
|
|
30555
30723
|
module: "LanguageModel",
|
|
30556
30724
|
method: "generateObject",
|
|
30557
30725
|
reason: InvalidOutputError.fromSchemaError(error)
|
|
@@ -30560,7 +30728,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30560
30728
|
const streamText = fnUntraced(function* (options) {
|
|
30561
30729
|
const span = yield* makeSpanScoped("LanguageModel.streamText", { kind: "client" });
|
|
30562
30730
|
const providerOptions = {
|
|
30563
|
-
prompt: make$
|
|
30731
|
+
prompt: make$22(options.prompt),
|
|
30564
30732
|
tools: [],
|
|
30565
30733
|
toolChoice: "none",
|
|
30566
30734
|
responseFormat: { type: "text" },
|
|
@@ -30581,7 +30749,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30581
30749
|
response: content
|
|
30582
30750
|
});
|
|
30583
30751
|
})));
|
|
30584
|
-
}, unwrap$3, mapError$1((error) => isSchemaError(error) ? make$
|
|
30752
|
+
}, unwrap$3, mapError$1((error) => isSchemaError(error) ? make$19({
|
|
30585
30753
|
module: "LanguageModel",
|
|
30586
30754
|
method: "streamText",
|
|
30587
30755
|
reason: InvalidOutputError.fromSchemaError(error)
|
|
@@ -30608,7 +30776,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30608
30776
|
const { approved: allResolved, denied: allDenied, pendingApproved: approved, pendingDenied: denied } = collectToolApprovals(providerOptions.prompt.content);
|
|
30609
30777
|
const hasPendingApprovals = approved.length > 0 || denied.length > 0;
|
|
30610
30778
|
if (isUndefined(options.toolkit)) {
|
|
30611
|
-
if (hasPendingApprovals) return yield* make$
|
|
30779
|
+
if (hasPendingApprovals) return yield* make$19({
|
|
30612
30780
|
module: "LanguageModel",
|
|
30613
30781
|
method: "generateText",
|
|
30614
30782
|
reason: new ToolkitRequiredError({ pendingApprovals: [...approved, ...denied].map((result) => result.toolCall?.name).filter(isNotUndefined) })
|
|
@@ -30631,7 +30799,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30631
30799
|
}
|
|
30632
30800
|
const toolkit = yield* resolveToolkit(options.toolkit);
|
|
30633
30801
|
if (Object.values(toolkit.tools).length === 0) {
|
|
30634
|
-
if (hasPendingApprovals) return yield* make$
|
|
30802
|
+
if (hasPendingApprovals) return yield* make$19({
|
|
30635
30803
|
module: "LanguageModel",
|
|
30636
30804
|
method: "generateText",
|
|
30637
30805
|
reason: new ToolkitRequiredError({ pendingApprovals: [...approved, ...denied].map((result) => result.toolCall?.name).filter(isNotUndefined) })
|
|
@@ -30654,7 +30822,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30654
30822
|
}
|
|
30655
30823
|
let preResolvedResults = [];
|
|
30656
30824
|
if (hasPendingApprovals) {
|
|
30657
|
-
for (const approval of approved) if (approval.toolCall && !toolkit.tools[approval.toolCall.name]) return yield* make$
|
|
30825
|
+
for (const approval of approved) if (approval.toolCall && !toolkit.tools[approval.toolCall.name]) return yield* make$19({
|
|
30658
30826
|
module: "LanguageModel",
|
|
30659
30827
|
method: "generateText",
|
|
30660
30828
|
reason: new ToolNotFoundError({
|
|
@@ -30728,7 +30896,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30728
30896
|
const { approved: allResolved, denied: allDenied, pendingApproved, pendingDenied } = collectToolApprovals(providerOptions.prompt.content);
|
|
30729
30897
|
const hasPendingApprovals = pendingApproved.length > 0 || pendingDenied.length > 0;
|
|
30730
30898
|
if (isUndefined(options.toolkit)) {
|
|
30731
|
-
if (hasPendingApprovals) return yield* make$
|
|
30899
|
+
if (hasPendingApprovals) return yield* make$19({
|
|
30732
30900
|
module: "LanguageModel",
|
|
30733
30901
|
method: "streamText",
|
|
30734
30902
|
reason: new ToolkitRequiredError({ pendingApprovals: [...pendingApproved, ...pendingDenied].map((a) => a.toolCall?.name).filter(isNotUndefined) })
|
|
@@ -30749,7 +30917,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30749
30917
|
}
|
|
30750
30918
|
const toolkit = yield* resolveToolkit(options.toolkit);
|
|
30751
30919
|
if (Object.values(toolkit.tools).length === 0) {
|
|
30752
|
-
if (hasPendingApprovals) return yield* make$
|
|
30920
|
+
if (hasPendingApprovals) return yield* make$19({
|
|
30753
30921
|
module: "LanguageModel",
|
|
30754
30922
|
method: "streamText",
|
|
30755
30923
|
reason: new ToolkitRequiredError({ pendingApprovals: [...pendingApproved, ...pendingDenied].map((a) => a.toolCall?.name).filter(isNotUndefined) })
|
|
@@ -30770,7 +30938,7 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30770
30938
|
}
|
|
30771
30939
|
let preResolvedStreamParts = [];
|
|
30772
30940
|
if (hasPendingApprovals) {
|
|
30773
|
-
for (const approval of pendingApproved) if (approval.toolCall && !toolkit.tools[approval.toolCall.name]) return yield* make$
|
|
30941
|
+
for (const approval of pendingApproved) if (approval.toolCall && !toolkit.tools[approval.toolCall.name]) return yield* make$19({
|
|
30774
30942
|
module: "LanguageModel",
|
|
30775
30943
|
method: "streamText",
|
|
30776
30944
|
reason: new ToolNotFoundError({
|
|
@@ -30810,11 +30978,11 @@ const make$9 = fnUntraced(function* (params) {
|
|
|
30810
30978
|
return void_;
|
|
30811
30979
|
}) : identity)));
|
|
30812
30980
|
}
|
|
30813
|
-
const queue = yield* make$
|
|
30981
|
+
const queue = yield* make$47();
|
|
30814
30982
|
const deferredFinishParts = [];
|
|
30815
30983
|
if (preResolvedStreamParts.length > 0) yield* offerAll(queue, preResolvedStreamParts);
|
|
30816
|
-
const toolCallFibers = yield* make$
|
|
30817
|
-
const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$
|
|
30984
|
+
const toolCallFibers = yield* make$16();
|
|
30985
|
+
const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$48(concurrency);
|
|
30818
30986
|
const pendingToolCalls = new Map();
|
|
30819
30987
|
const bufferedToolCalls = [];
|
|
30820
30988
|
const handleToolCall = fnUntraced(function* (part) {
|
|
@@ -30973,7 +31141,7 @@ const executeApprovedToolCalls = (approvals, toolkit, concurrency) => {
|
|
|
30973
31141
|
const toolCall = approval.toolCall;
|
|
30974
31142
|
if (isUndefined(toolCall)) return yield* die("Approval missing tool call reference");
|
|
30975
31143
|
const tool = toolkit.tools[toolCall.name];
|
|
30976
|
-
if (isUndefined(tool)) return yield* make$
|
|
31144
|
+
if (isUndefined(tool)) return yield* make$19({
|
|
30977
31145
|
module: "LanguageModel",
|
|
30978
31146
|
method: "generateText",
|
|
30979
31147
|
reason: new ToolNotFoundError({
|
|
@@ -31120,8 +31288,8 @@ const withParameterMode = (tool, mode) => {
|
|
|
31120
31288
|
}
|
|
31121
31289
|
return tools[mode] ??= tool.setParameters(mode === "encoded" ? toEncoded$1(tool.parametersSchema) : Unknown);
|
|
31122
31290
|
};
|
|
31123
|
-
const makeToolkitWithEncodedParameters = (toolkit) => make$
|
|
31124
|
-
const makeToolkitWithOpaqueParameters = (toolkit) => make$
|
|
31291
|
+
const makeToolkitWithEncodedParameters = (toolkit) => make$17(...Object.values(toolkit.tools).map((tool) => withParameterMode(tool, "encoded")));
|
|
31292
|
+
const makeToolkitWithOpaqueParameters = (toolkit) => make$17(...Object.values(toolkit.tools).map((tool) => withParameterMode(tool, "opaque")));
|
|
31125
31293
|
const isToolCallValidationDeferred = (options) => options.disableToolCallResolution === true && options.toolCallValidation === "deferred";
|
|
31126
31294
|
const UndeclaredToolCallPart = ToolCallPart("", Unknown).mapFields((fields) => ({
|
|
31127
31295
|
...fields,
|
|
@@ -31151,7 +31319,7 @@ const resolveStructuredOutput = fnUntraced(function* (response, schema) {
|
|
|
31151
31319
|
const texts = [];
|
|
31152
31320
|
for (const part of response) if (part.type === "text") texts.push(part.text);
|
|
31153
31321
|
const text = texts.join("");
|
|
31154
|
-
if (text.length === 0) return yield* make$
|
|
31322
|
+
if (text.length === 0) return yield* make$19({
|
|
31155
31323
|
module: "LanguageModel",
|
|
31156
31324
|
method: "generateObject",
|
|
31157
31325
|
reason: new StructuredOutputError({
|
|
@@ -31160,7 +31328,7 @@ const resolveStructuredOutput = fnUntraced(function* (response, schema) {
|
|
|
31160
31328
|
})
|
|
31161
31329
|
});
|
|
31162
31330
|
const decode = decodeEffect(fromJsonString(schema));
|
|
31163
|
-
return yield* mapError(decode(text), (error) => make$
|
|
31331
|
+
return yield* mapError(decode(text), (error) => make$19({
|
|
31164
31332
|
module: "LanguageModel",
|
|
31165
31333
|
method: "generateObject",
|
|
31166
31334
|
reason: StructuredOutputError.fromSchemaError(error, text)
|
|
@@ -31411,7 +31579,7 @@ ${summary}
|
|
|
31411
31579
|
})}<conversation>
|
|
31412
31580
|
${conversation}
|
|
31413
31581
|
</conversation>`;
|
|
31414
|
-
return make$
|
|
31582
|
+
return make$22(text).pipe(setSystem(summarizerSystem));
|
|
31415
31583
|
};
|
|
31416
31584
|
const wrapSummary = (summary) => `${summaryOpenTag}\n${summary}\n${summaryCloseTag}`;
|
|
31417
31585
|
const rewrite = (options) => fromMessages([
|
|
@@ -31431,7 +31599,7 @@ const compact = fnUntraced(function* (options) {
|
|
|
31431
31599
|
previousSummary,
|
|
31432
31600
|
messages: toSummarize
|
|
31433
31601
|
}) }).pipe(runFold(() => "", (text, part) => part.type === "text-delta" ? text + part.delta : text)))).trim();
|
|
31434
|
-
if (summary.length === 0) return yield* make$
|
|
31602
|
+
if (summary.length === 0) return yield* make$19({
|
|
31435
31603
|
module: "clanka/Compaction",
|
|
31436
31604
|
method: "compact",
|
|
31437
31605
|
reason: new InvalidOutputError({ description: "The summarizer returned no text" })
|
|
@@ -31582,8 +31750,8 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
31582
31750
|
let agentCounter = 0;
|
|
31583
31751
|
const outputBuffer = new Map();
|
|
31584
31752
|
let currentOutputAgent = null;
|
|
31585
|
-
const history = make$
|
|
31586
|
-
const environment = make$
|
|
31753
|
+
const history = make$46(empty$1);
|
|
31754
|
+
const environment = make$46(capabilities.environment);
|
|
31587
31755
|
const spawn = fnUntraced(function* (opts) {
|
|
31588
31756
|
const agentId = opts.agentId;
|
|
31589
31757
|
const ai = yield* LanguageModel;
|
|
@@ -31604,7 +31772,7 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
31604
31772
|
...mcpServers.handlers(onImage)
|
|
31605
31773
|
};
|
|
31606
31774
|
let scriptsRan = false;
|
|
31607
|
-
const output = yield* make$
|
|
31775
|
+
const output = yield* make$47();
|
|
31608
31776
|
let inputTokens = 0;
|
|
31609
31777
|
let outputTokens = 0;
|
|
31610
31778
|
let cacheRead = 0;
|
|
@@ -31658,7 +31826,7 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
31658
31826
|
}
|
|
31659
31827
|
state.push(options.part);
|
|
31660
31828
|
}
|
|
31661
|
-
const runScope = yield* make$
|
|
31829
|
+
const runScope = yield* make$45();
|
|
31662
31830
|
const runContext = yield* context();
|
|
31663
31831
|
const provideSubagentModel = (effect) => match$2(subagentModel, {
|
|
31664
31832
|
onNone: () => effect,
|
|
@@ -31699,7 +31867,7 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
31699
31867
|
const display = opts.display && !options.background;
|
|
31700
31868
|
const stream = spawn({
|
|
31701
31869
|
agentId: child.id,
|
|
31702
|
-
prompt: make$
|
|
31870
|
+
prompt: make$22(options.prompt),
|
|
31703
31871
|
environmentUpdate: options.environmentUpdate,
|
|
31704
31872
|
system: opts.system,
|
|
31705
31873
|
history: child.history,
|
|
@@ -31758,8 +31926,8 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
31758
31926
|
const child = {
|
|
31759
31927
|
id: agentId,
|
|
31760
31928
|
prompt,
|
|
31761
|
-
history: make$
|
|
31762
|
-
environment: make$
|
|
31929
|
+
history: make$46(empty$1),
|
|
31930
|
+
environment: make$46(environment.environment),
|
|
31763
31931
|
mailbox: makeMailbox(),
|
|
31764
31932
|
turn: makeTurn(agentId, background)
|
|
31765
31933
|
};
|
|
@@ -31979,7 +32147,7 @@ ${prompt}`,
|
|
|
31979
32147
|
return;
|
|
31980
32148
|
}
|
|
31981
32149
|
if (mailbox.messages.size > 0) {
|
|
31982
|
-
appendHistory(make$
|
|
32150
|
+
appendHistory(make$22(Array$1.from(mailbox.messages, ({ message, resume }) => {
|
|
31983
32151
|
resume(void_);
|
|
31984
32152
|
return {
|
|
31985
32153
|
role: "user",
|
|
@@ -31994,7 +32162,7 @@ ${prompt}`,
|
|
|
31994
32162
|
turn.delivered = true;
|
|
31995
32163
|
return true;
|
|
31996
32164
|
});
|
|
31997
|
-
if (pushes.length > 0) appendHistory(make$
|
|
32165
|
+
if (pushes.length > 0) appendHistory(make$22(pushes.map((turn) => ({
|
|
31998
32166
|
role: "user",
|
|
31999
32167
|
content: `<subagent id="${turn.agentId}" status="${turn.status}">
|
|
32000
32168
|
${capOutput(turn.output ?? "").output}
|
|
@@ -32197,7 +32365,7 @@ ${capOutput(turn.output ?? "").output}
|
|
|
32197
32365
|
environment,
|
|
32198
32366
|
send: (options) => spawn({
|
|
32199
32367
|
agentId: agentCounter++,
|
|
32200
|
-
prompt: make$
|
|
32368
|
+
prompt: make$22(options.prompt),
|
|
32201
32369
|
system: options.system,
|
|
32202
32370
|
history,
|
|
32203
32371
|
environment,
|
|
@@ -32219,7 +32387,7 @@ ${capOutput(turn.output ?? "").output}
|
|
|
32219
32387
|
})
|
|
32220
32388
|
});
|
|
32221
32389
|
});
|
|
32222
|
-
const make$
|
|
32390
|
+
const make$9 = makeWith$1({});
|
|
32223
32391
|
const makeMailbox = () => ({
|
|
32224
32392
|
messages: new Set(),
|
|
32225
32393
|
notify: () => {}
|
|
@@ -32233,19 +32401,19 @@ const makeTurn = (agentId, background) => ({
|
|
|
32233
32401
|
fiber: void 0
|
|
32234
32402
|
});
|
|
32235
32403
|
const causeMessage = (cause) => errorMessage(squash(cause));
|
|
32236
|
-
const turnTimeoutError = make$
|
|
32404
|
+
const turnTimeoutError = make$19({
|
|
32237
32405
|
module: "clanka/Agent",
|
|
32238
32406
|
method: "send",
|
|
32239
32407
|
reason: new UnknownError({ description: "TurnTimeout was reached" })
|
|
32240
32408
|
});
|
|
32241
|
-
const incompleteResponseError = (description) => make$
|
|
32409
|
+
const incompleteResponseError = (description) => make$19({
|
|
32242
32410
|
module: "clanka/Agent",
|
|
32243
32411
|
method: "send",
|
|
32244
32412
|
reason: new InternalProviderError({ description })
|
|
32245
32413
|
});
|
|
32246
32414
|
const retryPolicy = min([exponential(100, 1.5), spaced(5e3)]).pipe(jittered);
|
|
32247
32415
|
const environmentUpdateOpen = "<environment-update>";
|
|
32248
|
-
const environmentUpdateMessage = (text) => make$
|
|
32416
|
+
const environmentUpdateMessage = (text) => make$22([{
|
|
32249
32417
|
role: "user",
|
|
32250
32418
|
content: `${environmentUpdateOpen}\n${text}\n</environment-update>`
|
|
32251
32419
|
}]);
|
|
@@ -32325,7 +32493,7 @@ package.json: {
|
|
|
32325
32493
|
"version": "1.0.0"
|
|
32326
32494
|
}
|
|
32327
32495
|
\`\`\``;
|
|
32328
|
-
const ReadSkillTools = make$
|
|
32496
|
+
const ReadSkillTools = make$17(make$18("readSkill", {
|
|
32329
32497
|
description: "Read the instructions of a skill listed under Skills, by its name.",
|
|
32330
32498
|
parameters: String$6.annotate({ identifier: "name" }),
|
|
32331
32499
|
success: String$6,
|
|
@@ -32360,7 +32528,7 @@ const makeLoopTools = fnUntraced(function* (options) {
|
|
|
32360
32528
|
});
|
|
32361
32529
|
const errorMessage = (error) => typeof error === "string" ? error : error instanceof Error ? error.message : JSON.stringify(error) ?? String(error);
|
|
32362
32530
|
var ScriptExecutor = class extends Service()("clanka/Agent/ScriptExecutor") {};
|
|
32363
|
-
const SingleTools = make$
|
|
32531
|
+
const SingleTools = make$17(make$18("execute", {
|
|
32364
32532
|
description: "Execute javascript code and return the output",
|
|
32365
32533
|
parameters: Struct({ script: String$6 }),
|
|
32366
32534
|
success: String$6,
|
|
@@ -32369,7 +32537,7 @@ const SingleTools = make$16(make$17("execute", {
|
|
|
32369
32537
|
const SingleToolHandlers = SingleTools.toLayer({ execute: fnUntraced(function* ({ script }) {
|
|
32370
32538
|
return yield* (yield* ScriptExecutor)(script);
|
|
32371
32539
|
}) });
|
|
32372
|
-
const layer$5 = effect(Agent, make$
|
|
32540
|
+
const layer$5 = effect(Agent, make$9);
|
|
32373
32541
|
const layerWith = (options) => effect(Agent, makeWith$1(options));
|
|
32374
32542
|
const layerLocal = (options) => layerWith(options).pipe(provide$3(layerLocal$1(options)));
|
|
32375
32543
|
var SubagentModel = class extends Service()("clanka/Agent/SubagentModel") {};
|
|
@@ -32461,7 +32629,7 @@ const LoadSessionParams = Struct({
|
|
|
32461
32629
|
model: optionalKey(String$6),
|
|
32462
32630
|
mcpServers: optionalKey(ArraySchema(McpServer))
|
|
32463
32631
|
});
|
|
32464
|
-
const redactValues = (entries) => Object.fromEntries((entries ?? []).map(({ name, value }) => [name, make$
|
|
32632
|
+
const redactValues = (entries) => Object.fromEntries((entries ?? []).map(({ name, value }) => [name, make$49(value)]));
|
|
32465
32633
|
const mcpServerEntries = fnUntraced(function* (servers, cwd) {
|
|
32466
32634
|
const entries = Object.create(null);
|
|
32467
32635
|
for (const server of servers) {
|
|
@@ -32599,7 +32767,7 @@ const historyUpdates = (history) => {
|
|
|
32599
32767
|
}
|
|
32600
32768
|
return updates;
|
|
32601
32769
|
};
|
|
32602
|
-
const make$
|
|
32770
|
+
const make$8 = fnUntraced(function* (options) {
|
|
32603
32771
|
const kvs = yield* KeyValueStore;
|
|
32604
32772
|
const { contextWindow } = yield* CompactionConfig;
|
|
32605
32773
|
const size = Number.isFinite(contextWindow) ? Math.max(0, Math.round(contextWindow)) : 0;
|
|
@@ -32638,15 +32806,19 @@ const make$7 = fnUntraced(function* (options) {
|
|
|
32638
32806
|
name: value
|
|
32639
32807
|
}))
|
|
32640
32808
|
}];
|
|
32641
|
-
const sessionState = (session)
|
|
32642
|
-
|
|
32643
|
-
|
|
32644
|
-
|
|
32645
|
-
|
|
32646
|
-
|
|
32647
|
-
|
|
32648
|
-
|
|
32649
|
-
|
|
32809
|
+
const sessionState = fnUntraced(function* (session) {
|
|
32810
|
+
const catalog = options.availableModels === void 0 ? [] : yield* options.availableModels;
|
|
32811
|
+
const listed = new Set(catalog.map((model) => model.modelId));
|
|
32812
|
+
return {
|
|
32813
|
+
models: {
|
|
32814
|
+
availableModels: [...catalog, ...[...new Set([session.model, options.defaultModel])].filter((modelId) => !listed.has(modelId)).map((modelId) => ({
|
|
32815
|
+
modelId,
|
|
32816
|
+
name: modelId
|
|
32817
|
+
}))],
|
|
32818
|
+
currentModelId: session.model
|
|
32819
|
+
},
|
|
32820
|
+
configOptions: configOptions(session)
|
|
32821
|
+
};
|
|
32650
32822
|
});
|
|
32651
32823
|
const persist = (session) => store.set(session.id, new SessionRecord({
|
|
32652
32824
|
cwd: session.cwd,
|
|
@@ -32888,13 +33060,13 @@ const make$7 = fnUntraced(function* (options) {
|
|
|
32888
33060
|
yield* persist(session);
|
|
32889
33061
|
return {
|
|
32890
33062
|
sessionId: session.id,
|
|
32891
|
-
...sessionState(session)
|
|
33063
|
+
...yield* sessionState(session)
|
|
32892
33064
|
};
|
|
32893
33065
|
});
|
|
32894
33066
|
const loadSession = fnUntraced(function* (params, replay) {
|
|
32895
33067
|
const { sessionId, cwd, model, mcpServers } = yield* decodeParams(LoadSessionParams, params);
|
|
32896
33068
|
const existing = sessions.get(sessionId);
|
|
32897
|
-
if (existing !== void 0) return sessionState(existing);
|
|
33069
|
+
if (existing !== void 0) return yield* sessionState(existing);
|
|
32898
33070
|
const record = yield* store.get(sessionId).pipe(mapError((error) => new RpcError({
|
|
32899
33071
|
code: -32603,
|
|
32900
33072
|
message: error.message
|
|
@@ -32910,7 +33082,7 @@ const make$7 = fnUntraced(function* (options) {
|
|
|
32910
33082
|
...record.value.environment !== void 0 && (cwd === void 0 || cwd === record.value.cwd) ? { environment: record.value.environment } : {}
|
|
32911
33083
|
}), mcpServers ?? []);
|
|
32912
33084
|
if (replay) yield* replayHistory(session);
|
|
32913
|
-
return sessionState(session);
|
|
33085
|
+
return yield* sessionState(session);
|
|
32914
33086
|
});
|
|
32915
33087
|
const setModel = fnUntraced(function* (params) {
|
|
32916
33088
|
const { sessionId, modelId } = yield* decodeParams(SetModelParams, params);
|
|
@@ -33014,9 +33186,9 @@ const make$7 = fnUntraced(function* (options) {
|
|
|
33014
33186
|
});
|
|
33015
33187
|
const runStdio = (options) => gen(function* () {
|
|
33016
33188
|
const stdio = yield* Stdio;
|
|
33017
|
-
const output = yield* make$
|
|
33189
|
+
const output = yield* make$47();
|
|
33018
33190
|
const writer = yield* fromQueue(output).pipe(map$9((line) => `${line}\n`), run$4(stdio.stdout()), forkScoped);
|
|
33019
|
-
const server = yield* make$
|
|
33191
|
+
const server = yield* make$8({
|
|
33020
33192
|
...options,
|
|
33021
33193
|
send: (message) => offer(output, JSON.stringify(message)).pipe(asVoid)
|
|
33022
33194
|
});
|
|
@@ -33025,6 +33197,142 @@ const runStdio = (options) => gen(function* () {
|
|
|
33025
33197
|
yield* join$2(writer);
|
|
33026
33198
|
}).pipe(scoped);
|
|
33027
33199
|
//#endregion
|
|
33200
|
+
//#region src/McpConfig.ts
|
|
33201
|
+
var McpConfigError = class extends TaggedError$1()("McpConfigError", { message: String$6 }) {};
|
|
33202
|
+
const ConfigFile = fromJsonString(Struct({ mcpServers: optionalKey(Record(String$6, Unknown)) }));
|
|
33203
|
+
const RedactedStrings = Record(String$6, RedactedFromValue(String$6));
|
|
33204
|
+
const FileEntry = Struct({
|
|
33205
|
+
type: optionalKey(Literals$2([
|
|
33206
|
+
"stdio",
|
|
33207
|
+
"http",
|
|
33208
|
+
"sse"
|
|
33209
|
+
])),
|
|
33210
|
+
command: optionalKey(String$6),
|
|
33211
|
+
args: optionalKey(ArraySchema(String$6)),
|
|
33212
|
+
env: optionalKey(RedactedStrings),
|
|
33213
|
+
cwd: optionalKey(String$6),
|
|
33214
|
+
url: optionalKey(String$6),
|
|
33215
|
+
headers: optionalKey(RedactedStrings),
|
|
33216
|
+
connectTimeout: optionalKey(DurationFromMillis),
|
|
33217
|
+
callTimeout: optionalKey(DurationFromMillis)
|
|
33218
|
+
});
|
|
33219
|
+
const decodeFile = decodeUnknownEffect$1(ConfigFile);
|
|
33220
|
+
const decodeFileEntry = decodeUnknownEffect$1(FileEntry);
|
|
33221
|
+
const load = fnUntraced(function* (options) {
|
|
33222
|
+
if (!options.enabled) return {};
|
|
33223
|
+
const fs = yield* FileSystem;
|
|
33224
|
+
const path = yield* Path$3;
|
|
33225
|
+
const configHome = yield* NonEmptyString("XDG_CONFIG_HOME").pipe(orElse(() => NonEmptyString("HOME").pipe(map$3((home) => path.join(home, ".config")))), option, orElseSucceed(() => none()));
|
|
33226
|
+
const sources = [
|
|
33227
|
+
...match$2(configHome, {
|
|
33228
|
+
onNone: () => [],
|
|
33229
|
+
onSome: (home) => [{
|
|
33230
|
+
file: path.join(home, "clanka", "mcp.json"),
|
|
33231
|
+
required: false
|
|
33232
|
+
}]
|
|
33233
|
+
}),
|
|
33234
|
+
{
|
|
33235
|
+
file: path.join(options.cwd, ".mcp.json"),
|
|
33236
|
+
required: false
|
|
33237
|
+
},
|
|
33238
|
+
...options.files.map((file) => ({
|
|
33239
|
+
file: path.resolve(options.cwd, file),
|
|
33240
|
+
required: true
|
|
33241
|
+
}))
|
|
33242
|
+
];
|
|
33243
|
+
const servers = Object.create(null);
|
|
33244
|
+
for (const { file, required } of sources) {
|
|
33245
|
+
const fail = (message) => new McpConfigError({ message: `${file}: ${message}` });
|
|
33246
|
+
const text = yield* fs.readFileString(file).pipe(catchReason("PlatformError", "NotFound", (_, error) => required ? fail$1(error) : void_), mapError((error) => fail(error.message)));
|
|
33247
|
+
if (text === void 0) continue;
|
|
33248
|
+
const { mcpServers } = yield* decodeFile(text).pipe(mapError((error) => fail(error.message)));
|
|
33249
|
+
for (const [name, entry] of Object.entries(mcpServers ?? {})) servers[name] = yield* decodeEntry(entry, {
|
|
33250
|
+
directory: path.dirname(file),
|
|
33251
|
+
fail: (message) => fail(`MCP server "${name}": ${message}`),
|
|
33252
|
+
resolve: path.resolve
|
|
33253
|
+
});
|
|
33254
|
+
}
|
|
33255
|
+
return servers;
|
|
33256
|
+
});
|
|
33257
|
+
const decodeEntry = fnUntraced(function* (raw, options) {
|
|
33258
|
+
const entry = yield* decodeFileEntry(yield* expandEntry(raw)).pipe(mapError((error) => options.fail(error.message)));
|
|
33259
|
+
switch (entry.type ?? (entry.command !== void 0 ? "stdio" : entry.url !== void 0 ? "http" : void 0)) {
|
|
33260
|
+
case void 0: return yield* options.fail("needs a command or a url");
|
|
33261
|
+
case "sse": return {
|
|
33262
|
+
type: "unavailable",
|
|
33263
|
+
error: "SSE transport is not supported"
|
|
33264
|
+
};
|
|
33265
|
+
case "stdio":
|
|
33266
|
+
if (entry.command === void 0) return yield* options.fail("a stdio server needs a command");
|
|
33267
|
+
return {
|
|
33268
|
+
...omit$1(entry, [
|
|
33269
|
+
"type",
|
|
33270
|
+
"url",
|
|
33271
|
+
"headers",
|
|
33272
|
+
"cwd"
|
|
33273
|
+
]),
|
|
33274
|
+
type: "stdio",
|
|
33275
|
+
command: entry.command,
|
|
33276
|
+
...entry.cwd !== void 0 ? { cwd: options.resolve(options.directory, entry.cwd) } : {}
|
|
33277
|
+
};
|
|
33278
|
+
case "http":
|
|
33279
|
+
if (entry.url === void 0) return yield* options.fail("an http server needs a url");
|
|
33280
|
+
return {
|
|
33281
|
+
...omit$1(entry, [
|
|
33282
|
+
"type",
|
|
33283
|
+
"command",
|
|
33284
|
+
"args",
|
|
33285
|
+
"env",
|
|
33286
|
+
"cwd"
|
|
33287
|
+
]),
|
|
33288
|
+
type: "http",
|
|
33289
|
+
url: entry.url
|
|
33290
|
+
};
|
|
33291
|
+
}
|
|
33292
|
+
}, catchTag("MissingVariable", (missing) => succeed$1({
|
|
33293
|
+
type: "unavailable",
|
|
33294
|
+
error: `environment variable ${missing.variable} is not set`
|
|
33295
|
+
})));
|
|
33296
|
+
var MissingVariable = class extends TaggedError("MissingVariable") {};
|
|
33297
|
+
const variablePattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
|
|
33298
|
+
const lookup = (name) => String$4(name).pipe(option, orElseSucceed(() => none()));
|
|
33299
|
+
const expand = fnUntraced(function* (text) {
|
|
33300
|
+
let result = "";
|
|
33301
|
+
let last = 0;
|
|
33302
|
+
for (const match of text.matchAll(variablePattern)) {
|
|
33303
|
+
const [whole, name, fallback] = match;
|
|
33304
|
+
const value = filter$1(yield* lookup(name), (value) => fallback === void 0 ? true : value !== "");
|
|
33305
|
+
if (isNone(value) && fallback === void 0) return yield* new MissingVariable({ variable: name });
|
|
33306
|
+
result += text.slice(last, match.index) + getOrElse(value, () => fallback);
|
|
33307
|
+
last = match.index + whole.length;
|
|
33308
|
+
}
|
|
33309
|
+
return result + text.slice(last);
|
|
33310
|
+
});
|
|
33311
|
+
const expandStrings = fnUntraced(function* (value) {
|
|
33312
|
+
if (typeof value === "string") return yield* expand(value);
|
|
33313
|
+
if (Array.isArray(value)) return yield* forEach$1(value, (item) => typeof item === "string" ? expand(item) : succeed$1(item));
|
|
33314
|
+
if (typeof value === "object" && value !== null) {
|
|
33315
|
+
const result = {};
|
|
33316
|
+
for (const [key, item] of Object.entries(value)) result[key] = typeof item === "string" ? yield* expand(item) : item;
|
|
33317
|
+
return result;
|
|
33318
|
+
}
|
|
33319
|
+
return value;
|
|
33320
|
+
});
|
|
33321
|
+
const expandedFields = [
|
|
33322
|
+
"command",
|
|
33323
|
+
"args",
|
|
33324
|
+
"env",
|
|
33325
|
+
"cwd",
|
|
33326
|
+
"url",
|
|
33327
|
+
"headers"
|
|
33328
|
+
];
|
|
33329
|
+
const expandEntry = fnUntraced(function* (raw) {
|
|
33330
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
|
|
33331
|
+
const entry = { ...raw };
|
|
33332
|
+
for (const field of expandedFields) if (field in entry) entry[field] = yield* expandStrings(entry[field]);
|
|
33333
|
+
return entry;
|
|
33334
|
+
});
|
|
33335
|
+
//#endregion
|
|
33028
33336
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/encoding/Sse.js
|
|
33029
33337
|
const SseErrorTypeId = "~effect/encoding/Sse/SseError";
|
|
33030
33338
|
var EventTooLarge = class extends TaggedError("EventTooLarge") {
|
|
@@ -35677,12 +35985,12 @@ const OpenAiCompatibleErrorBody = Struct({
|
|
|
35677
35985
|
error: String$6,
|
|
35678
35986
|
code: optional$3(String$6)
|
|
35679
35987
|
});
|
|
35680
|
-
const mapSchemaError$1 = dual(2, (error, method) => make$
|
|
35988
|
+
const mapSchemaError$1 = dual(2, (error, method) => make$19({
|
|
35681
35989
|
module: "OpenAiClient",
|
|
35682
35990
|
method,
|
|
35683
35991
|
reason: InvalidOutputError.fromSchemaError(error)
|
|
35684
35992
|
}));
|
|
35685
|
-
const mapSseError$1 = dual(2, (error, method) => make$
|
|
35993
|
+
const mapSseError$1 = dual(2, (error, method) => make$19({
|
|
35686
35994
|
module: "OpenAiClient",
|
|
35687
35995
|
method,
|
|
35688
35996
|
reason: new InvalidOutputError({ description: error.message })
|
|
@@ -35690,7 +35998,7 @@ const mapSseError$1 = dual(2, (error, method) => make$18({
|
|
|
35690
35998
|
const mapHttpClientError$1 = dual(2, (error, method) => {
|
|
35691
35999
|
const reason = error.reason;
|
|
35692
36000
|
switch (reason._tag) {
|
|
35693
|
-
case "TransportError": return fail$1(make$
|
|
36001
|
+
case "TransportError": return fail$1(make$19({
|
|
35694
36002
|
module: "OpenAiClient",
|
|
35695
36003
|
method,
|
|
35696
36004
|
reason: new NetworkError({
|
|
@@ -35699,7 +36007,7 @@ const mapHttpClientError$1 = dual(2, (error, method) => {
|
|
|
35699
36007
|
request: buildHttpRequestDetails$3(reason.request)
|
|
35700
36008
|
})
|
|
35701
36009
|
}));
|
|
35702
|
-
case "EncodeError": return fail$1(make$
|
|
36010
|
+
case "EncodeError": return fail$1(make$19({
|
|
35703
36011
|
module: "OpenAiClient",
|
|
35704
36012
|
method,
|
|
35705
36013
|
reason: new NetworkError({
|
|
@@ -35708,7 +36016,7 @@ const mapHttpClientError$1 = dual(2, (error, method) => {
|
|
|
35708
36016
|
request: buildHttpRequestDetails$3(reason.request)
|
|
35709
36017
|
})
|
|
35710
36018
|
}));
|
|
35711
|
-
case "InvalidUrlError": return fail$1(make$
|
|
36019
|
+
case "InvalidUrlError": return fail$1(make$19({
|
|
35712
36020
|
module: "OpenAiClient",
|
|
35713
36021
|
method,
|
|
35714
36022
|
reason: new NetworkError({
|
|
@@ -35718,12 +36026,12 @@ const mapHttpClientError$1 = dual(2, (error, method) => {
|
|
|
35718
36026
|
})
|
|
35719
36027
|
}));
|
|
35720
36028
|
case "StatusCodeError": return mapStatusCodeError$1(reason, method);
|
|
35721
|
-
case "DecodeError": return fail$1(make$
|
|
36029
|
+
case "DecodeError": return fail$1(make$19({
|
|
35722
36030
|
module: "OpenAiClient",
|
|
35723
36031
|
method,
|
|
35724
36032
|
reason: new InvalidOutputError({ description: reason.description ?? "Failed to decode response" })
|
|
35725
36033
|
}));
|
|
35726
|
-
case "EmptyBodyError": return fail$1(make$
|
|
36034
|
+
case "EmptyBodyError": return fail$1(make$19({
|
|
35727
36035
|
module: "OpenAiClient",
|
|
35728
36036
|
method,
|
|
35729
36037
|
reason: new InvalidOutputError({ description: reason.description ?? "Response body was empty" })
|
|
@@ -35765,7 +36073,7 @@ const mapStatusCodeError$1 = fnUntraced(function* (error, method) {
|
|
|
35765
36073
|
requestId: requestId ?? null
|
|
35766
36074
|
}
|
|
35767
36075
|
});
|
|
35768
|
-
return yield* make$
|
|
36076
|
+
return yield* make$19({
|
|
35769
36077
|
module: "OpenAiClient",
|
|
35770
36078
|
method,
|
|
35771
36079
|
reason
|
|
@@ -36719,7 +37027,7 @@ const RedactedOpenAiHeaders$1 = {
|
|
|
36719
37027
|
OpenAiProject: "OpenAI-Project"
|
|
36720
37028
|
};
|
|
36721
37029
|
const withRedactedHeaders$1 = updateService(CurrentRedactedNames, appendAll(Object.values(RedactedOpenAiHeaders$1)));
|
|
36722
|
-
const make$
|
|
37030
|
+
const make$7 = fnUntraced(function* (options) {
|
|
36723
37031
|
const baseClient = yield* HttpClient;
|
|
36724
37032
|
const apiUrl = options.apiUrl ?? "https://api.openai.com/v1";
|
|
36725
37033
|
const httpClient = baseClient.pipe(mapRequest(flow(prependUrl(apiUrl), options.apiKey ? bearerToken(value(options.apiKey)) : identity, options.organizationId ? setHeader(RedactedOpenAiHeaders$1.OpenAiOrganization, value(options.organizationId)) : identity, options.projectId ? setHeader(RedactedOpenAiHeaders$1.OpenAiProject, value(options.projectId)) : identity, acceptJson)), filterStatusOk, options.transformClient ? options.transformClient : identity);
|
|
@@ -36762,11 +37070,11 @@ const make$6 = fnUntraced(function* (options) {
|
|
|
36762
37070
|
createDecisions
|
|
36763
37071
|
});
|
|
36764
37072
|
}, withRedactedHeaders$1);
|
|
36765
|
-
const layer$4 = (options) => effect(OpenAiClient$1, make$
|
|
37073
|
+
const layer$4 = (options) => effect(OpenAiClient$1, make$7(options));
|
|
36766
37074
|
var OpenAiSocket = class extends Service()("@effect/ai-openai/OpenAiClient/OpenAiSocket") {};
|
|
36767
37075
|
const makeSocket = gen(function* () {
|
|
36768
37076
|
const client = yield* OpenAiClient$1;
|
|
36769
|
-
const tracker = yield* make$
|
|
37077
|
+
const tracker = yield* make$11;
|
|
36770
37078
|
const socketScope = yield* scope;
|
|
36771
37079
|
const makeRequest = flatMap$1(OpenAiConfig$1.getOrUndefined, (config) => {
|
|
36772
37080
|
const httpClient = isNotUndefined(config?.transformClient) ? config.transformClient(client.client) : client.client;
|
|
@@ -36774,7 +37082,7 @@ const makeSocket = gen(function* () {
|
|
|
36774
37082
|
});
|
|
36775
37083
|
const makeWebSocket$1 = yield* WebSocketConstructor;
|
|
36776
37084
|
const decoder = new TextDecoder();
|
|
36777
|
-
const queueRef = yield* make$
|
|
37085
|
+
const queueRef = yield* make$40({
|
|
36778
37086
|
idleTimeToLive: 6e4,
|
|
36779
37087
|
acquire: gen(function* () {
|
|
36780
37088
|
const scope$1 = yield* scope;
|
|
@@ -36790,7 +37098,7 @@ const makeSocket = gen(function* () {
|
|
|
36790
37098
|
send: (message) => writer.write(JSON.stringify({
|
|
36791
37099
|
type: "response.create",
|
|
36792
37100
|
...message
|
|
36793
|
-
})).pipe(mapError((_error) => make$
|
|
37101
|
+
})).pipe(mapError((_error) => make$19({
|
|
36794
37102
|
module: "OpenAiClient",
|
|
36795
37103
|
method: "createResponseStream",
|
|
36796
37104
|
reason: new NetworkError({
|
|
@@ -36821,7 +37129,7 @@ const makeSocket = gen(function* () {
|
|
|
36821
37129
|
const errorType = error.code ?? (error.type === "api_error" && /^gRPC error: Response with id=\S+ not found$/.test(error.message) ? "previous_response_not_found" : error.type ?? "unknown");
|
|
36822
37130
|
const json = JSON.stringify(error);
|
|
36823
37131
|
if (errorType === "previous_response_not_found") connection.current = void 0;
|
|
36824
|
-
failCauseUnsafe(turn, fail$4(make$
|
|
37132
|
+
failCauseUnsafe(turn, fail$4(make$19({
|
|
36825
37133
|
module: "OpenAiClient",
|
|
36826
37134
|
method: "createResponseStream",
|
|
36827
37135
|
reason: reasonFromHttpStatus({
|
|
@@ -36854,7 +37162,7 @@ const makeSocket = gen(function* () {
|
|
|
36854
37162
|
const messages = yield* pull;
|
|
36855
37163
|
for (let i = 0; i < messages.length; i++) handleMessage(messages[i]);
|
|
36856
37164
|
}
|
|
36857
|
-
}).pipe(scoped, catchTag("SocketError", (error) => make$
|
|
37165
|
+
}).pipe(scoped, catchTag("SocketError", (error) => make$19({
|
|
36858
37166
|
module: "OpenAiClient",
|
|
36859
37167
|
method: "createResponseStream",
|
|
36860
37168
|
reason: new NetworkError({
|
|
@@ -36932,7 +37240,7 @@ const makeWith = (options) => {
|
|
|
36932
37240
|
};
|
|
36933
37241
|
const defaultKeyObject = {};
|
|
36934
37242
|
const defaultKey = (_request) => defaultKeyObject;
|
|
36935
|
-
const make$
|
|
37243
|
+
const make$6 = (runAll) => makeWith({
|
|
36936
37244
|
batchKey: defaultKey,
|
|
36937
37245
|
delay: yieldNow,
|
|
36938
37246
|
collectWhile: constTrue,
|
|
@@ -36997,13 +37305,13 @@ var EmbedManyResponse = class extends Class$1("effect/ai/EmbeddingModel/EmbedMan
|
|
|
36997
37305
|
usage: EmbeddingUsage
|
|
36998
37306
|
}) {};
|
|
36999
37307
|
var EmbeddingRequest = class extends TaggedClass("EmbeddingRequest") {};
|
|
37000
|
-
const invalidProviderResponse = (description) => make$
|
|
37308
|
+
const invalidProviderResponse = (description) => make$19({
|
|
37001
37309
|
module: "EmbeddingModel",
|
|
37002
37310
|
method: "embedMany",
|
|
37003
37311
|
reason: new InvalidOutputError({ description })
|
|
37004
37312
|
});
|
|
37005
|
-
const make$
|
|
37006
|
-
const resolver = make$
|
|
37313
|
+
const make$5 = fnUntraced(function* (params) {
|
|
37314
|
+
const resolver = make$6((entries) => flatMap$1(params.embedMany({ inputs: entries.map((entry) => entry.request.input) }), (response) => map$5(mapProviderResults(entries.length, response.results), (embeddings) => {
|
|
37007
37315
|
for (let i = 0; i < entries.length; i++) entries[i].completeUnsafe(succeed$3(embeddings[i]));
|
|
37008
37316
|
}))).pipe(withSpan("EmbeddingModel.resolver"));
|
|
37009
37317
|
return EmbeddingModel.of({
|
|
@@ -37031,21 +37339,21 @@ const mapProviderResults = (inputLength, results) => {
|
|
|
37031
37339
|
//#endregion
|
|
37032
37340
|
//#region node_modules/.pnpm/@effect+ai-openai@4.0.5_effect@4.0.5/node_modules/@effect/ai-openai/dist/OpenAiEmbeddingModel.js
|
|
37033
37341
|
var Config$2 = class extends Service()("@effect/ai-openai/OpenAiEmbeddingModel/Config") {};
|
|
37034
|
-
const model$3 = (model, options) => make$
|
|
37342
|
+
const model$3 = (model, options) => make$20("openai", model, merge$3(layer$3({
|
|
37035
37343
|
model,
|
|
37036
37344
|
config: {
|
|
37037
37345
|
...options.config,
|
|
37038
37346
|
dimensions: options.dimensions
|
|
37039
37347
|
}
|
|
37040
37348
|
}), succeed$4(Dimensions, options.dimensions)));
|
|
37041
|
-
const make$
|
|
37349
|
+
const make$4 = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
37042
37350
|
const client = yield* OpenAiClient$1;
|
|
37043
37351
|
const makeConfig = contextWith((services) => succeed$1({
|
|
37044
37352
|
model,
|
|
37045
37353
|
...providerConfig,
|
|
37046
37354
|
...getOrUndefined$1(services, Config$2)
|
|
37047
37355
|
}));
|
|
37048
|
-
return yield* make$
|
|
37356
|
+
return yield* make$5({ embedMany: fnUntraced(function* ({ inputs }) {
|
|
37049
37357
|
const config = yield* makeConfig;
|
|
37050
37358
|
const response = yield* client.createEmbedding({
|
|
37051
37359
|
...config,
|
|
@@ -37054,7 +37362,7 @@ const make$3 = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
|
37054
37362
|
return yield* mapProviderResponse(inputs.length, response);
|
|
37055
37363
|
}) });
|
|
37056
37364
|
});
|
|
37057
|
-
const layer$3 = (options) => effect(EmbeddingModel, make$
|
|
37365
|
+
const layer$3 = (options) => effect(EmbeddingModel, make$4(options));
|
|
37058
37366
|
const mapProviderResponse = (inputLength, response) => {
|
|
37059
37367
|
if (response.data.length !== inputLength) return fail$1(invalidOutput("Provider returned " + response.data.length + " embeddings but expected " + inputLength));
|
|
37060
37368
|
const results = new Array(inputLength);
|
|
@@ -37072,7 +37380,7 @@ const mapProviderResponse = (inputLength, response) => {
|
|
|
37072
37380
|
usage: { inputTokens: response.usage?.prompt_tokens }
|
|
37073
37381
|
});
|
|
37074
37382
|
};
|
|
37075
|
-
const invalidOutput = (description) => make$
|
|
37383
|
+
const invalidOutput = (description) => make$19({
|
|
37076
37384
|
module: "OpenAiEmbeddingModel",
|
|
37077
37385
|
method: "embedMany",
|
|
37078
37386
|
reason: new InvalidOutputError({ description })
|
|
@@ -37317,7 +37625,7 @@ const addGenAIAnnotations$1 = dual(2, (span, options) => {
|
|
|
37317
37625
|
ModelIdsResponses.members[1];
|
|
37318
37626
|
ModelIdsShared.members[1];
|
|
37319
37627
|
var Config$1 = class extends Service()("@effect/ai-openai/OpenAiLanguageModel/Config") {};
|
|
37320
|
-
const make$
|
|
37628
|
+
const make$3 = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
37321
37629
|
const client = yield* OpenAiClient$1;
|
|
37322
37630
|
const makeConfig = gen(function* () {
|
|
37323
37631
|
const services = yield* context();
|
|
@@ -37360,7 +37668,7 @@ const make$2 = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
|
37360
37668
|
if (options.previousResponseId) request.previous_response_id = options.previousResponseId;
|
|
37361
37669
|
return request;
|
|
37362
37670
|
});
|
|
37363
|
-
return yield* make$
|
|
37671
|
+
return yield* make$10({
|
|
37364
37672
|
codecTransformer: toCodecOpenAI,
|
|
37365
37673
|
generateText: fnUntraced(function* (options) {
|
|
37366
37674
|
const config = yield* makeConfig;
|
|
@@ -37403,7 +37711,7 @@ const make$2 = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
|
37403
37711
|
})))
|
|
37404
37712
|
});
|
|
37405
37713
|
});
|
|
37406
|
-
const layer$2 = (options) => effect(LanguageModel, make$
|
|
37714
|
+
const layer$2 = (options) => effect(LanguageModel, make$3(options));
|
|
37407
37715
|
const withConfigOverride$1 = dual(2, (self, overrides) => flatMap$1(serviceOption(Config$1), (config) => provideService(self, Config$1, {
|
|
37408
37716
|
...config._tag === "Some" ? config.value : {},
|
|
37409
37717
|
...overrides
|
|
@@ -37483,7 +37791,7 @@ const prepareMessages$1 = fnUntraced(function* ({ config, options, isReasoningMo
|
|
|
37483
37791
|
file_data: fileData
|
|
37484
37792
|
});
|
|
37485
37793
|
}
|
|
37486
|
-
} else return yield* make$
|
|
37794
|
+
} else return yield* make$19({
|
|
37487
37795
|
module: "OpenAiLanguageModel",
|
|
37488
37796
|
method: "prepareMessages",
|
|
37489
37797
|
reason: new InvalidRequestError$1({ description: `Detected unsupported media type for file: '${part.mediaType}'` })
|
|
@@ -37499,7 +37807,7 @@ const prepareMessages$1 = fnUntraced(function* ({ config, options, isReasoningMo
|
|
|
37499
37807
|
case "assistant": {
|
|
37500
37808
|
const reasoningMessages = Object.create(null);
|
|
37501
37809
|
const providerExecutedParts = message.content.filter((part) => (part.type === "tool-call" || part.type === "tool-result") && part.providerExecuted);
|
|
37502
|
-
const unreplayableProviderItem = (name, id) => make$
|
|
37810
|
+
const unreplayableProviderItem = (name, id) => make$19({
|
|
37503
37811
|
module: "OpenAiLanguageModel",
|
|
37504
37812
|
method: "prepareMessages",
|
|
37505
37813
|
reason: new InvalidRequestError$1({ description: `Cannot replay provider-executed tool item '${name}' ('${id}') losslessly` })
|
|
@@ -37633,7 +37941,7 @@ const prepareMessages$1 = fnUntraced(function* ({ config, options, isReasoningMo
|
|
|
37633
37941
|
}
|
|
37634
37942
|
const toolName = toolNameMapper.getProviderName(part.name);
|
|
37635
37943
|
if (isNotUndefined(localShellTool) && toolName === "local_shell") {
|
|
37636
|
-
const params = yield* decodeUnknownEffect$1(localShellTool.parametersSchema)(part.params).pipe(mapError((error) => make$
|
|
37944
|
+
const params = yield* decodeUnknownEffect$1(localShellTool.parametersSchema)(part.params).pipe(mapError((error) => make$19({
|
|
37637
37945
|
module: "OpenAiLanguageModel",
|
|
37638
37946
|
method: "prepareMessages",
|
|
37639
37947
|
reason: new ToolParameterValidationError({
|
|
@@ -37651,7 +37959,7 @@ const prepareMessages$1 = fnUntraced(function* ({ config, options, isReasoningMo
|
|
|
37651
37959
|
break;
|
|
37652
37960
|
}
|
|
37653
37961
|
if (isNotUndefined(shellTool) && toolName === "shell") {
|
|
37654
|
-
const params = yield* decodeUnknownEffect$1(shellTool.parametersSchema)(part.params).pipe(mapError((error) => make$
|
|
37962
|
+
const params = yield* decodeUnknownEffect$1(shellTool.parametersSchema)(part.params).pipe(mapError((error) => make$19({
|
|
37655
37963
|
module: "OpenAiLanguageModel",
|
|
37656
37964
|
method: "prepareMessages",
|
|
37657
37965
|
reason: new ToolParameterValidationError({
|
|
@@ -37870,7 +38178,7 @@ const makeResponse$1 = fnUntraced(function* ({ options, rawResponse, response, t
|
|
|
37870
38178
|
const toolName = part.name;
|
|
37871
38179
|
const toolParams = yield* try_({
|
|
37872
38180
|
try: () => unsafeSecureJsonParse(part.arguments),
|
|
37873
|
-
catch: (cause) => make$
|
|
38181
|
+
catch: (cause) => make$19({
|
|
37874
38182
|
module: "OpenAiLanguageModel",
|
|
37875
38183
|
method: "makeResponse",
|
|
37876
38184
|
reason: new ToolParameterValidationError({
|
|
@@ -38482,7 +38790,7 @@ const makeStreamResponse$1 = fnUntraced(function* ({ stream, response, config, o
|
|
|
38482
38790
|
const toolArgs = event.item.arguments;
|
|
38483
38791
|
const toolParams = yield* try_({
|
|
38484
38792
|
try: () => unsafeSecureJsonParse(toolArgs),
|
|
38485
|
-
catch: (cause) => make$
|
|
38793
|
+
catch: (cause) => make$19({
|
|
38486
38794
|
module: "OpenAiLanguageModel",
|
|
38487
38795
|
method: "makeStreamResponse",
|
|
38488
38796
|
reason: new ToolParameterValidationError({
|
|
@@ -38729,7 +39037,7 @@ const makeStreamResponse$1 = fnUntraced(function* ({ stream, response, config, o
|
|
|
38729
39037
|
hasToolCalls = true;
|
|
38730
39038
|
const toolParams = yield* try_({
|
|
38731
39039
|
try: () => unsafeSecureJsonParse(event.arguments),
|
|
38732
|
-
catch: (cause) => make$
|
|
39040
|
+
catch: (cause) => make$19({
|
|
38733
39041
|
module: "OpenAiLanguageModel",
|
|
38734
39042
|
method: "makeStreamResponse",
|
|
38735
39043
|
reason: new ToolParameterValidationError({
|
|
@@ -38949,7 +39257,7 @@ const prepareTools$1 = fnUntraced(function* ({ config, options, toolNameMapper }
|
|
|
38949
39257
|
tools.push({ type: "apply_patch" });
|
|
38950
39258
|
break;
|
|
38951
39259
|
case "OpenAiCodeInterpreter": {
|
|
38952
|
-
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$
|
|
39260
|
+
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$19({
|
|
38953
39261
|
module: "OpenAiLanguageModel",
|
|
38954
39262
|
method: "prepareTools",
|
|
38955
39263
|
reason: new ToolConfigurationError({
|
|
@@ -38964,7 +39272,7 @@ const prepareTools$1 = fnUntraced(function* ({ config, options, toolNameMapper }
|
|
|
38964
39272
|
break;
|
|
38965
39273
|
}
|
|
38966
39274
|
case "OpenAiFileSearch": {
|
|
38967
|
-
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$
|
|
39275
|
+
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$19({
|
|
38968
39276
|
module: "OpenAiLanguageModel",
|
|
38969
39277
|
method: "prepareTools",
|
|
38970
39278
|
reason: new ToolConfigurationError({
|
|
@@ -38982,7 +39290,7 @@ const prepareTools$1 = fnUntraced(function* ({ config, options, toolNameMapper }
|
|
|
38982
39290
|
tools.push({ type: "shell" });
|
|
38983
39291
|
break;
|
|
38984
39292
|
case "OpenAiImageGeneration": {
|
|
38985
|
-
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$
|
|
39293
|
+
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$19({
|
|
38986
39294
|
module: "OpenAiLanguageModel",
|
|
38987
39295
|
method: "prepareTools",
|
|
38988
39296
|
reason: new ToolConfigurationError({
|
|
@@ -39000,7 +39308,7 @@ const prepareTools$1 = fnUntraced(function* ({ config, options, toolNameMapper }
|
|
|
39000
39308
|
tools.push({ type: "local_shell" });
|
|
39001
39309
|
break;
|
|
39002
39310
|
case "OpenAiMcp": {
|
|
39003
|
-
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$
|
|
39311
|
+
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$19({
|
|
39004
39312
|
module: "OpenAiLanguageModel",
|
|
39005
39313
|
method: "prepareTools",
|
|
39006
39314
|
reason: new ToolConfigurationError({
|
|
@@ -39015,7 +39323,7 @@ const prepareTools$1 = fnUntraced(function* ({ config, options, toolNameMapper }
|
|
|
39015
39323
|
break;
|
|
39016
39324
|
}
|
|
39017
39325
|
case "OpenAiWebSearch": {
|
|
39018
|
-
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$
|
|
39326
|
+
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$19({
|
|
39019
39327
|
module: "OpenAiLanguageModel",
|
|
39020
39328
|
method: "prepareTools",
|
|
39021
39329
|
reason: new ToolConfigurationError({
|
|
@@ -39030,7 +39338,7 @@ const prepareTools$1 = fnUntraced(function* ({ config, options, toolNameMapper }
|
|
|
39030
39338
|
break;
|
|
39031
39339
|
}
|
|
39032
39340
|
case "OpenAiWebSearchPreview": {
|
|
39033
|
-
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$
|
|
39341
|
+
const args = yield* decodeUnknownEffect$1(openAiTool.argsSchema)(tool.args).pipe(mapError((error) => make$19({
|
|
39034
39342
|
module: "OpenAiLanguageModel",
|
|
39035
39343
|
method: "prepareTools",
|
|
39036
39344
|
reason: new ToolConfigurationError({
|
|
@@ -39044,7 +39352,7 @@ const prepareTools$1 = fnUntraced(function* ({ config, options, toolNameMapper }
|
|
|
39044
39352
|
});
|
|
39045
39353
|
break;
|
|
39046
39354
|
}
|
|
39047
|
-
default: return yield* make$
|
|
39355
|
+
default: return yield* make$19({
|
|
39048
39356
|
module: "OpenAiLanguageModel",
|
|
39049
39357
|
method: "prepareTools",
|
|
39050
39358
|
reason: new InvalidRequestError$1({ description: `Unknown provider-defined tool '${tool.name}'` })
|
|
@@ -39077,7 +39385,7 @@ const getPromptCacheBreakpoint = (input) => {
|
|
|
39077
39385
|
};
|
|
39078
39386
|
const makeItemIdMetadata$1 = (itemId) => isNotUndefined(itemId) ? { itemId } : {};
|
|
39079
39387
|
const makeEncryptedContentMetadata = (encryptedContent) => isNotNullish(encryptedContent) ? { encryptedContent } : void 0;
|
|
39080
|
-
const unsupportedSchemaError$1 = (error, method) => make$
|
|
39388
|
+
const unsupportedSchemaError$1 = (error, method) => make$19({
|
|
39081
39389
|
module: "OpenAiLanguageModel",
|
|
39082
39390
|
method,
|
|
39083
39391
|
reason: new UnsupportedSchemaError({ description: error instanceof Error ? error.message : String(error) })
|
|
@@ -39138,7 +39446,7 @@ const normalizeMcpToolCall = fnUntraced(function* ({ toolNameMapper, toolParams,
|
|
|
39138
39446
|
toolName,
|
|
39139
39447
|
params: yield* try_({
|
|
39140
39448
|
try: () => unsafeSecureJsonParse(toolParams),
|
|
39141
|
-
catch: (cause) => make$
|
|
39449
|
+
catch: (cause) => make$19({
|
|
39142
39450
|
module: "OpenAiLanguageModel",
|
|
39143
39451
|
method,
|
|
39144
39452
|
reason: new ToolParameterValidationError({
|
|
@@ -39204,7 +39512,7 @@ const transformToolCallParams$1 = fnUntraced(function* (options, toolName, toolP
|
|
|
39204
39512
|
const tool = options.tools.find((tool) => tool.name === toolName);
|
|
39205
39513
|
if (isUndefined(tool)) {
|
|
39206
39514
|
if (options.toolCallValidation === "deferred") return toolParams;
|
|
39207
|
-
return yield* make$
|
|
39515
|
+
return yield* make$19({
|
|
39208
39516
|
module: "OpenAiLanguageModel",
|
|
39209
39517
|
method: "makeResponse",
|
|
39210
39518
|
reason: new ToolNotFoundError({
|
|
@@ -39455,8 +39763,8 @@ var CodexAuth = class CodexAuth extends Service()("clanka/CodexAuth") {
|
|
|
39455
39763
|
//#endregion
|
|
39456
39764
|
//#region src/Codex.ts
|
|
39457
39765
|
const layerClient$2 = layer$4({ apiUrl: "https://chatgpt.com/backend-api/codex" }).pipe(provide$3(CodexAuth.layerClient));
|
|
39458
|
-
const model$2 = (model, options) => make$
|
|
39459
|
-
const modelWebSocket$1 = (model, options) => make$
|
|
39766
|
+
const model$2 = (model, options) => make$20("openai", model, layerModel(model, options));
|
|
39767
|
+
const modelWebSocket$1 = (model, options) => make$20("openai", model, layerModel(model, options).pipe(merge$3(fresh(layerWebSocketMode))));
|
|
39460
39768
|
const layerModel = (model, options) => layer$2({
|
|
39461
39769
|
model,
|
|
39462
39770
|
config: {
|
|
@@ -39466,7 +39774,7 @@ const layerModel = (model, options) => layer$2({
|
|
|
39466
39774
|
"supportsImages"
|
|
39467
39775
|
]),
|
|
39468
39776
|
store: false,
|
|
39469
|
-
reasoning: {
|
|
39777
|
+
reasoning: options?.reasoning === null ? void 0 : {
|
|
39470
39778
|
effort: "medium",
|
|
39471
39779
|
summary: "auto",
|
|
39472
39780
|
...options?.reasoning
|
|
@@ -39489,12 +39797,12 @@ const OpenAiErrorBodyJson = decodeUnknownOption(fromJsonString(Union([OpenAiErro
|
|
|
39489
39797
|
decode: headNonEmpty,
|
|
39490
39798
|
encode: (item) => [item]
|
|
39491
39799
|
})))])));
|
|
39492
|
-
const mapSchemaError = dual(2, (error, method) => make$
|
|
39800
|
+
const mapSchemaError = dual(2, (error, method) => make$19({
|
|
39493
39801
|
module: "OpenAiClient",
|
|
39494
39802
|
method,
|
|
39495
39803
|
reason: InvalidOutputError.fromSchemaError(error)
|
|
39496
39804
|
}));
|
|
39497
|
-
const mapSseError = dual(2, (error, method) => make$
|
|
39805
|
+
const mapSseError = dual(2, (error, method) => make$19({
|
|
39498
39806
|
module: "OpenAiClient",
|
|
39499
39807
|
method,
|
|
39500
39808
|
reason: new InvalidOutputError({ description: error.message })
|
|
@@ -39502,7 +39810,7 @@ const mapSseError = dual(2, (error, method) => make$18({
|
|
|
39502
39810
|
const mapHttpClientError = dual(2, (error, method) => {
|
|
39503
39811
|
const reason = error.reason;
|
|
39504
39812
|
switch (reason._tag) {
|
|
39505
|
-
case "TransportError": return fail$1(make$
|
|
39813
|
+
case "TransportError": return fail$1(make$19({
|
|
39506
39814
|
module: "OpenAiClient",
|
|
39507
39815
|
method,
|
|
39508
39816
|
reason: new NetworkError({
|
|
@@ -39511,7 +39819,7 @@ const mapHttpClientError = dual(2, (error, method) => {
|
|
|
39511
39819
|
request: buildHttpRequestDetails$1(reason.request)
|
|
39512
39820
|
})
|
|
39513
39821
|
}));
|
|
39514
|
-
case "EncodeError": return fail$1(make$
|
|
39822
|
+
case "EncodeError": return fail$1(make$19({
|
|
39515
39823
|
module: "OpenAiClient",
|
|
39516
39824
|
method,
|
|
39517
39825
|
reason: new NetworkError({
|
|
@@ -39520,7 +39828,7 @@ const mapHttpClientError = dual(2, (error, method) => {
|
|
|
39520
39828
|
request: buildHttpRequestDetails$1(reason.request)
|
|
39521
39829
|
})
|
|
39522
39830
|
}));
|
|
39523
|
-
case "InvalidUrlError": return fail$1(make$
|
|
39831
|
+
case "InvalidUrlError": return fail$1(make$19({
|
|
39524
39832
|
module: "OpenAiClient",
|
|
39525
39833
|
method,
|
|
39526
39834
|
reason: new NetworkError({
|
|
@@ -39530,12 +39838,12 @@ const mapHttpClientError = dual(2, (error, method) => {
|
|
|
39530
39838
|
})
|
|
39531
39839
|
}));
|
|
39532
39840
|
case "StatusCodeError": return mapStatusCodeError(reason, method);
|
|
39533
|
-
case "DecodeError": return fail$1(make$
|
|
39841
|
+
case "DecodeError": return fail$1(make$19({
|
|
39534
39842
|
module: "OpenAiClient",
|
|
39535
39843
|
method,
|
|
39536
39844
|
reason: new InvalidOutputError({ description: reason.description ?? "Failed to decode response" })
|
|
39537
39845
|
}));
|
|
39538
|
-
case "EmptyBodyError": return fail$1(make$
|
|
39846
|
+
case "EmptyBodyError": return fail$1(make$19({
|
|
39539
39847
|
module: "OpenAiClient",
|
|
39540
39848
|
method,
|
|
39541
39849
|
reason: new InvalidOutputError({ description: reason.description ?? "Response body was empty" })
|
|
@@ -39564,7 +39872,7 @@ const mapStatusCodeError = fnUntraced(function* (error, method) {
|
|
|
39564
39872
|
requestId: requestId ?? null
|
|
39565
39873
|
}
|
|
39566
39874
|
});
|
|
39567
|
-
return yield* make$
|
|
39875
|
+
return yield* make$19({
|
|
39568
39876
|
module: "OpenAiClient",
|
|
39569
39877
|
method,
|
|
39570
39878
|
reason
|
|
@@ -39683,7 +39991,7 @@ const RedactedOpenAiHeaders = {
|
|
|
39683
39991
|
OpenAiProject: "openai-project"
|
|
39684
39992
|
};
|
|
39685
39993
|
const withRedactedHeaders = updateService(CurrentRedactedNames, appendAll(Object.values(RedactedOpenAiHeaders)));
|
|
39686
|
-
const make$
|
|
39994
|
+
const make$2 = fnUntraced(function* (options) {
|
|
39687
39995
|
const httpClient = (yield* HttpClient).pipe(mapRequest((request) => request.pipe(prependUrl(options.apiUrl ?? "https://api.openai.com/v1"), options.apiKey !== void 0 ? bearerToken(value(options.apiKey)) : identity, options.organizationId !== void 0 ? setHeader(RedactedOpenAiHeaders.OpenAiOrganization, value(options.organizationId)) : identity, options.projectId !== void 0 ? setHeader(RedactedOpenAiHeaders.OpenAiProject, value(options.projectId)) : identity, acceptJson)), options.transformClient !== void 0 ? options.transformClient : identity);
|
|
39688
39996
|
const resolveHttpClient = map$5(OpenAiConfig.getOrUndefined, (config) => config?.transformClient !== void 0 ? config.transformClient(httpClient) : httpClient);
|
|
39689
39997
|
const decodeResponse = schemaBodyJson(ChatCompletionResponse);
|
|
@@ -39718,7 +40026,7 @@ const make$1 = fnUntraced(function* (options) {
|
|
|
39718
40026
|
createEmbedding
|
|
39719
40027
|
});
|
|
39720
40028
|
}, withRedactedHeaders);
|
|
39721
|
-
const layer$1 = (options) => effect(OpenAiClient, make$
|
|
40029
|
+
const layer$1 = (options) => effect(OpenAiClient, make$2(options));
|
|
39722
40030
|
const EmbeddingSchema = Struct({
|
|
39723
40031
|
embedding: Union([ArraySchema(Finite), String$6]),
|
|
39724
40032
|
index: Int$1,
|
|
@@ -39844,7 +40152,7 @@ const addGenAIAnnotations = dual(2, (span, options) => {
|
|
|
39844
40152
|
//#endregion
|
|
39845
40153
|
//#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.5_effect@4.0.5/node_modules/@effect/ai-openai-compat/dist/OpenAiLanguageModel.js
|
|
39846
40154
|
var Config = class extends Service()("@effect/ai-openai-compat/OpenAiLanguageModel/Config") {};
|
|
39847
|
-
const make = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
40155
|
+
const make$1 = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
39848
40156
|
const client = yield* OpenAiClient;
|
|
39849
40157
|
const makeConfig = contextWith((services) => succeed$1({
|
|
39850
40158
|
model,
|
|
@@ -39881,7 +40189,7 @@ const make = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
|
39881
40189
|
toolCodecs
|
|
39882
40190
|
};
|
|
39883
40191
|
});
|
|
39884
|
-
return yield* make$
|
|
40192
|
+
return yield* make$10({
|
|
39885
40193
|
codecTransformer: toCodecOpenAI,
|
|
39886
40194
|
generateText: fnUntraced(function* (options) {
|
|
39887
40195
|
const config = yield* makeConfig;
|
|
@@ -39925,7 +40233,7 @@ const make = fnUntraced(function* ({ model, config: providerConfig }) {
|
|
|
39925
40233
|
})))
|
|
39926
40234
|
});
|
|
39927
40235
|
});
|
|
39928
|
-
const layer = (options) => effect(LanguageModel, make(options));
|
|
40236
|
+
const layer = (options) => effect(LanguageModel, make$1(options));
|
|
39929
40237
|
const withConfigOverride = dual(2, (self, overrides) => flatMap$1(serviceOption(Config), (config) => provideService(self, Config, {
|
|
39930
40238
|
...config._tag === "Some" ? config.value : {},
|
|
39931
40239
|
...overrides
|
|
@@ -39986,7 +40294,7 @@ const prepareMessages = fnUntraced(function* ({ config, options, toolNameMapper
|
|
|
39986
40294
|
file_data: fileData
|
|
39987
40295
|
});
|
|
39988
40296
|
}
|
|
39989
|
-
} else return yield* make$
|
|
40297
|
+
} else return yield* make$19({
|
|
39990
40298
|
module: "OpenAiLanguageModel",
|
|
39991
40299
|
method: "prepareMessages",
|
|
39992
40300
|
reason: new InvalidRequestError$1({ description: `Detected unsupported media type for file: '${part.mediaType}'` })
|
|
@@ -40089,7 +40397,7 @@ const makeResponse = fnUntraced(function* ({ options, rawResponse, response, too
|
|
|
40089
40397
|
const toolParamsJson = toolCall.function?.arguments ?? "{}";
|
|
40090
40398
|
const toolParams = yield* try_({
|
|
40091
40399
|
try: () => unsafeSecureJsonParse(toolParamsJson),
|
|
40092
|
-
catch: (cause) => make$
|
|
40400
|
+
catch: (cause) => make$19({
|
|
40093
40401
|
module: "OpenAiLanguageModel",
|
|
40094
40402
|
method: "makeResponse",
|
|
40095
40403
|
reason: new ToolParameterValidationError({
|
|
@@ -40151,7 +40459,7 @@ const makeStreamResponse = fnUntraced(function* ({ options, stream, response, to
|
|
|
40151
40459
|
const toolParams = toolCall.arguments.length > 0 ? toolCall.arguments : "{}";
|
|
40152
40460
|
const parsedParams = yield* try_({
|
|
40153
40461
|
try: () => unsafeSecureJsonParse(toolParams),
|
|
40154
|
-
catch: (cause) => make$
|
|
40462
|
+
catch: (cause) => make$19({
|
|
40155
40463
|
module: "OpenAiLanguageModel",
|
|
40156
40464
|
method: "makeStreamResponse",
|
|
40157
40465
|
reason: new ToolParameterValidationError({
|
|
@@ -40329,7 +40637,7 @@ const annotateStreamResponse = (span, part) => {
|
|
|
40329
40637
|
});
|
|
40330
40638
|
}
|
|
40331
40639
|
};
|
|
40332
|
-
const unsupportedSchemaError = (error, method) => make$
|
|
40640
|
+
const unsupportedSchemaError = (error, method) => make$19({
|
|
40333
40641
|
module: "OpenAiLanguageModel",
|
|
40334
40642
|
method,
|
|
40335
40643
|
reason: new UnsupportedSchemaError({ description: error instanceof Error ? error.message : String(error) })
|
|
@@ -40346,7 +40654,7 @@ const transformToolCallParams = fnUntraced(function* (options, toolName, toolPar
|
|
|
40346
40654
|
const tool = options.tools.find((tool) => tool.name === toolName);
|
|
40347
40655
|
if (isUndefined(tool)) {
|
|
40348
40656
|
if (options.toolCallValidation === "deferred") return toolParams;
|
|
40349
|
-
return yield* make$
|
|
40657
|
+
return yield* make$19({
|
|
40350
40658
|
module: "OpenAiLanguageModel",
|
|
40351
40659
|
method: "makeResponse",
|
|
40352
40660
|
reason: new ToolNotFoundError({
|
|
@@ -40833,14 +41141,122 @@ var GithubCopilotAuth = class GithubCopilotAuth extends Service()("clanka/Github
|
|
|
40833
41141
|
//#endregion
|
|
40834
41142
|
//#region src/Copilot.ts
|
|
40835
41143
|
const layerClient$1 = layer$1({ apiUrl: API_URL }).pipe(provide$3(GithubCopilotAuth.layerClient));
|
|
40836
|
-
const model$1 = (model, options) => make$
|
|
41144
|
+
const model$1 = (model, options) => make$20("openai", model, mergeAll(layer({
|
|
40837
41145
|
model,
|
|
40838
|
-
config: omit$1(options ?? {}, [
|
|
41146
|
+
config: omit$1(options ?? {}, options?.reasoning === null ? [
|
|
41147
|
+
"reasoning",
|
|
41148
|
+
"systemPromptTransform",
|
|
41149
|
+
"supportsImages"
|
|
41150
|
+
] : ["systemPromptTransform", "supportsImages"])
|
|
40839
41151
|
}), AgentModelConfig.layer({
|
|
40840
41152
|
systemPromptTransform: options?.systemPromptTransform,
|
|
40841
41153
|
supportsImages: options?.supportsImages
|
|
40842
41154
|
}), succeed$4(SummarizerTransform, (effect) => withConfigOverride(effect, { max_output_tokens: summarizerMaxOutputTokens }))));
|
|
40843
41155
|
//#endregion
|
|
41156
|
+
//#region src/ModelsRepo.ts
|
|
41157
|
+
const Provider = Literals$2([
|
|
41158
|
+
"openai",
|
|
41159
|
+
"copilot",
|
|
41160
|
+
"xai"
|
|
41161
|
+
]);
|
|
41162
|
+
var ModelInfo = class extends Class$1("clanka/ModelsRepo/ModelInfo")({
|
|
41163
|
+
provider: Provider,
|
|
41164
|
+
id: String$6,
|
|
41165
|
+
name: String$6,
|
|
41166
|
+
efforts: ArraySchema(ThoughtLevel)
|
|
41167
|
+
}) {};
|
|
41168
|
+
const fallback = [
|
|
41169
|
+
new ModelInfo({
|
|
41170
|
+
provider: "openai",
|
|
41171
|
+
id: "gpt-6-astra",
|
|
41172
|
+
name: "GPT-6 Astra",
|
|
41173
|
+
efforts: [
|
|
41174
|
+
"low",
|
|
41175
|
+
"medium",
|
|
41176
|
+
"high",
|
|
41177
|
+
"xhigh",
|
|
41178
|
+
"max"
|
|
41179
|
+
]
|
|
41180
|
+
}),
|
|
41181
|
+
new ModelInfo({
|
|
41182
|
+
provider: "copilot",
|
|
41183
|
+
id: "gpt-6-astra",
|
|
41184
|
+
name: "GPT-6 Astra",
|
|
41185
|
+
efforts: [
|
|
41186
|
+
"low",
|
|
41187
|
+
"medium",
|
|
41188
|
+
"high",
|
|
41189
|
+
"xhigh",
|
|
41190
|
+
"max"
|
|
41191
|
+
]
|
|
41192
|
+
}),
|
|
41193
|
+
new ModelInfo({
|
|
41194
|
+
provider: "xai",
|
|
41195
|
+
id: "grok-4.6",
|
|
41196
|
+
name: "Grok 4.6",
|
|
41197
|
+
efforts: [
|
|
41198
|
+
"low",
|
|
41199
|
+
"medium",
|
|
41200
|
+
"high",
|
|
41201
|
+
"xhigh"
|
|
41202
|
+
]
|
|
41203
|
+
})
|
|
41204
|
+
];
|
|
41205
|
+
const ModelsDevModel = Struct({
|
|
41206
|
+
id: String$6,
|
|
41207
|
+
name: String$6,
|
|
41208
|
+
type: optionalKey(String$6),
|
|
41209
|
+
status: optionalKey(String$6),
|
|
41210
|
+
tool_call: optionalKey(Boolean$5),
|
|
41211
|
+
reasoning_options: optionalKey(ArraySchema(Struct({
|
|
41212
|
+
type: String$6,
|
|
41213
|
+
values: optionalKey(ArraySchema(Unknown))
|
|
41214
|
+
})))
|
|
41215
|
+
});
|
|
41216
|
+
const ModelsDevProvider = Struct({ models: Record(String$6, Unknown) });
|
|
41217
|
+
const providerIds = [
|
|
41218
|
+
["openai", "openai"],
|
|
41219
|
+
["github-copilot", "copilot"],
|
|
41220
|
+
["xai", "xai"]
|
|
41221
|
+
];
|
|
41222
|
+
const ModelsDevApi = Struct(Object.fromEntries(providerIds.map(([id]) => [id, optionalKey(ModelsDevProvider)])));
|
|
41223
|
+
const decodeModel = decodeUnknownOption(ModelsDevModel);
|
|
41224
|
+
const isThoughtLevel = is(ThoughtLevel);
|
|
41225
|
+
const toCatalog = (api) => providerIds.flatMap(([id, provider]) => Object.values(api[id]?.models ?? {}).flatMap((entry) => {
|
|
41226
|
+
const model = getOrUndefined(decodeModel(entry));
|
|
41227
|
+
if (model === void 0 || model.type !== void 0 || model.status === "deprecated" || model.tool_call !== true) return [];
|
|
41228
|
+
const effort = model.reasoning_options?.find((option) => option.type === "effort");
|
|
41229
|
+
return [new ModelInfo({
|
|
41230
|
+
provider,
|
|
41231
|
+
id: model.id,
|
|
41232
|
+
name: model.name,
|
|
41233
|
+
efforts: (effort?.values ?? []).filter(isThoughtLevel)
|
|
41234
|
+
})];
|
|
41235
|
+
}));
|
|
41236
|
+
var CachedCatalog = class extends Class$1("clanka/ModelsRepo/CachedCatalog")({
|
|
41237
|
+
fetchedAt: Finite,
|
|
41238
|
+
models: ArraySchema(ModelInfo)
|
|
41239
|
+
}) {};
|
|
41240
|
+
var ModelsRepo = class ModelsRepo extends Service()("clanka/ModelsRepo") {
|
|
41241
|
+
static layer = (models) => succeed$4(ModelsRepo, ModelsRepo.of({ models: succeed$1(models) }));
|
|
41242
|
+
static layerModelsDev = (options) => effect(ModelsRepo, gen(function* () {
|
|
41243
|
+
const url = options?.url ?? "https://models.dev/api.json";
|
|
41244
|
+
const ttl = toMillis(fromInputUnsafe$1(options?.ttl ?? hours(24)));
|
|
41245
|
+
const store = toSchemaStore(prefix(yield* KeyValueStore, "models-dev/"), CachedCatalog);
|
|
41246
|
+
const fetchCatalog = (yield* HttpClient).pipe(filterStatusOk).get(url).pipe(flatMap$1(schemaBodyJson(ModelsDevApi)), map$5(toCatalog), timeout("15 seconds"));
|
|
41247
|
+
const load = gen(function* () {
|
|
41248
|
+
const cached = yield* store.get(url).pipe(map$5(getOrUndefined), catch_(() => undefined_));
|
|
41249
|
+
const now = yield* currentTimeMillis;
|
|
41250
|
+
if (cached !== void 0 && now - cached.fetchedAt < ttl) return cached.models;
|
|
41251
|
+
return yield* fetchCatalog.pipe(tap((models) => store.set(url, new CachedCatalog({
|
|
41252
|
+
fetchedAt: now,
|
|
41253
|
+
models
|
|
41254
|
+
})).pipe(catch_((error) => logWarning("Failed to cache the models.dev catalog", error)))), catch_((error) => logWarning(cached !== void 0 ? "Failed to refresh the models.dev catalog, using the cached catalog" : "Failed to fetch the models.dev catalog, using the built-in catalog", error).pipe(as(cached?.models ?? fallback))));
|
|
41255
|
+
});
|
|
41256
|
+
return ModelsRepo.of({ models: yield* cached$1(load) });
|
|
41257
|
+
}));
|
|
41258
|
+
};
|
|
41259
|
+
//#endregion
|
|
40844
41260
|
//#region src/XaiAuth.ts
|
|
40845
41261
|
const CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
|
|
40846
41262
|
const ISSUER = "https://auth.x.ai";
|
|
@@ -40984,13 +41400,17 @@ var XaiAuth = class XaiAuth extends Service()("clanka/XaiAuth") {
|
|
|
40984
41400
|
//#endregion
|
|
40985
41401
|
//#region src/Xai.ts
|
|
40986
41402
|
const layerClient = layer$4({ apiUrl: "https://api.x.ai/v1" }).pipe(provide$3(XaiAuth.layerClient));
|
|
40987
|
-
const modelWebSocket = (model, options) => make$
|
|
41403
|
+
const modelWebSocket = (model, options) => make$20("xai", model, mergeAll(layer$2({
|
|
40988
41404
|
model,
|
|
40989
41405
|
config: {
|
|
40990
|
-
...omit$1(options ?? {}, [
|
|
41406
|
+
...omit$1(options ?? {}, [
|
|
41407
|
+
"reasoning",
|
|
41408
|
+
"systemPromptTransform",
|
|
41409
|
+
"supportsImages"
|
|
41410
|
+
]),
|
|
40991
41411
|
store: true,
|
|
40992
41412
|
useItemReferences: false,
|
|
40993
|
-
reasoning: {
|
|
41413
|
+
reasoning: options?.reasoning === null ? void 0 : {
|
|
40994
41414
|
effort: "high",
|
|
40995
41415
|
...options?.reasoning
|
|
40996
41416
|
}
|
|
@@ -41000,159 +41420,77 @@ const modelWebSocket = (model, options) => make$19("xai", model, mergeAll(layer$
|
|
|
41000
41420
|
supportsImages: options?.supportsImages
|
|
41001
41421
|
}), succeed$4(SummarizerTransform, (effect) => withConfigOverride$1(effect, { max_output_tokens: summarizerMaxOutputTokens })), fresh(layerWebSocketMode)));
|
|
41002
41422
|
//#endregion
|
|
41003
|
-
//#region src/
|
|
41004
|
-
|
|
41005
|
-
const
|
|
41006
|
-
const
|
|
41007
|
-
|
|
41008
|
-
|
|
41009
|
-
|
|
41010
|
-
|
|
41011
|
-
|
|
41012
|
-
|
|
41013
|
-
|
|
41014
|
-
|
|
41015
|
-
|
|
41016
|
-
|
|
41017
|
-
|
|
41018
|
-
|
|
41019
|
-
|
|
41020
|
-
|
|
41021
|
-
|
|
41022
|
-
const
|
|
41023
|
-
const
|
|
41024
|
-
|
|
41025
|
-
if (
|
|
41026
|
-
|
|
41027
|
-
|
|
41028
|
-
|
|
41029
|
-
const
|
|
41030
|
-
|
|
41031
|
-
onNone: () => [],
|
|
41032
|
-
onSome: (home) => [{
|
|
41033
|
-
file: path.join(home, "clanka", "mcp.json"),
|
|
41034
|
-
required: false
|
|
41035
|
-
}]
|
|
41036
|
-
}),
|
|
41037
|
-
{
|
|
41038
|
-
file: path.join(options.cwd, ".mcp.json"),
|
|
41039
|
-
required: false
|
|
41040
|
-
},
|
|
41041
|
-
...options.files.map((file) => ({
|
|
41042
|
-
file: path.resolve(options.cwd, file),
|
|
41043
|
-
required: true
|
|
41044
|
-
}))
|
|
41045
|
-
];
|
|
41046
|
-
const servers = Object.create(null);
|
|
41047
|
-
for (const { file, required } of sources) {
|
|
41048
|
-
const fail = (message) => new McpConfigError({ message: `${file}: ${message}` });
|
|
41049
|
-
const text = yield* fs.readFileString(file).pipe(catchReason("PlatformError", "NotFound", (_, error) => required ? fail$1(error) : void_), mapError((error) => fail(error.message)));
|
|
41050
|
-
if (text === void 0) continue;
|
|
41051
|
-
const { mcpServers } = yield* decodeFile(text).pipe(mapError((error) => fail(error.message)));
|
|
41052
|
-
for (const [name, entry] of Object.entries(mcpServers ?? {})) servers[name] = yield* decodeEntry(entry, {
|
|
41053
|
-
directory: path.dirname(file),
|
|
41054
|
-
fail: (message) => fail(`MCP server "${name}": ${message}`),
|
|
41055
|
-
resolve: path.resolve
|
|
41056
|
-
});
|
|
41057
|
-
}
|
|
41058
|
-
return servers;
|
|
41059
|
-
});
|
|
41060
|
-
const decodeEntry = fnUntraced(function* (raw, options) {
|
|
41061
|
-
const entry = yield* decodeFileEntry(yield* expandEntry(raw)).pipe(mapError((error) => options.fail(error.message)));
|
|
41062
|
-
switch (entry.type ?? (entry.command !== void 0 ? "stdio" : entry.url !== void 0 ? "http" : void 0)) {
|
|
41063
|
-
case void 0: return yield* options.fail("needs a command or a url");
|
|
41064
|
-
case "sse": return {
|
|
41065
|
-
type: "unavailable",
|
|
41066
|
-
error: "SSE transport is not supported"
|
|
41067
|
-
};
|
|
41068
|
-
case "stdio":
|
|
41069
|
-
if (entry.command === void 0) return yield* options.fail("a stdio server needs a command");
|
|
41070
|
-
return {
|
|
41071
|
-
...omit$1(entry, [
|
|
41072
|
-
"type",
|
|
41073
|
-
"url",
|
|
41074
|
-
"headers",
|
|
41075
|
-
"cwd"
|
|
41076
|
-
]),
|
|
41077
|
-
type: "stdio",
|
|
41078
|
-
command: entry.command,
|
|
41079
|
-
...entry.cwd !== void 0 ? { cwd: options.resolve(options.directory, entry.cwd) } : {}
|
|
41080
|
-
};
|
|
41081
|
-
case "http":
|
|
41082
|
-
if (entry.url === void 0) return yield* options.fail("an http server needs a url");
|
|
41083
|
-
return {
|
|
41084
|
-
...omit$1(entry, [
|
|
41085
|
-
"type",
|
|
41086
|
-
"command",
|
|
41087
|
-
"args",
|
|
41088
|
-
"env",
|
|
41089
|
-
"cwd"
|
|
41090
|
-
]),
|
|
41091
|
-
type: "http",
|
|
41092
|
-
url: entry.url
|
|
41093
|
-
};
|
|
41094
|
-
}
|
|
41095
|
-
}, catchTag("MissingVariable", (missing) => succeed$1({
|
|
41096
|
-
type: "unavailable",
|
|
41097
|
-
error: `environment variable ${missing.variable} is not set`
|
|
41423
|
+
//#region src/ModelLayer.ts
|
|
41424
|
+
const withSubagentModel = (model) => merge$3(model, layerSubagentModel(model));
|
|
41425
|
+
const make = (provider, model, effort, openai) => {
|
|
41426
|
+
const options = effort === void 0 ? void 0 : { reasoning: effort === null ? null : { effort } };
|
|
41427
|
+
return provider === "openai" ? openai.apiKey !== void 0 ? withSubagentModel(model$2(model, options)).pipe(provide$3(layer$4(openai))) : withSubagentModel(modelWebSocket$1(model, options)).pipe(provide$3(layerClient$2)) : provider === "xai" ? withSubagentModel(modelWebSocket(model, options)).pipe(provide$3(layerClient)) : withSubagentModel(model$1(model, options)).pipe(provide$3(layerClient$1));
|
|
41428
|
+
};
|
|
41429
|
+
const isProvider$1 = is(Provider);
|
|
41430
|
+
const parseAcpModelId = (modelId) => {
|
|
41431
|
+
const [provider, model, ...rest] = modelId.split(":");
|
|
41432
|
+
return isProvider$1(provider) && model !== void 0 && rest.length === 0 ? some({
|
|
41433
|
+
provider,
|
|
41434
|
+
model
|
|
41435
|
+
}) : none();
|
|
41436
|
+
};
|
|
41437
|
+
const acpModels = (models) => models.map((model) => ({
|
|
41438
|
+
modelId: `${model.provider}:${model.id}`,
|
|
41439
|
+
name: `${model.name} (${model.provider})`
|
|
41440
|
+
}));
|
|
41441
|
+
const rank = (level) => ThoughtLevel.literals.indexOf(level);
|
|
41442
|
+
const resolveEffort = (efforts, thoughtLevel) => {
|
|
41443
|
+
const distance = (level) => Math.abs(rank(level) - rank(thoughtLevel));
|
|
41444
|
+
let resolved = null;
|
|
41445
|
+
for (const effort of efforts) if (resolved === null || distance(effort) < distance(resolved) || distance(effort) === distance(resolved) && rank(effort) > rank(resolved)) resolved = effort;
|
|
41446
|
+
return resolved;
|
|
41447
|
+
};
|
|
41448
|
+
const makeAcp = (options) => (modelId, thoughtLevel) => map$8(parseAcpModelId(modelId), ({ provider, model }) => unwrap$1(map$5(options.models, (catalog) => {
|
|
41449
|
+
const info = catalog.find((entry) => entry.provider === provider && entry.id === model);
|
|
41450
|
+
return make(provider, model, info === void 0 ? thoughtLevel : resolveEffort(info.efforts, thoughtLevel), options.openai);
|
|
41098
41451
|
})));
|
|
41099
|
-
var MissingVariable = class extends TaggedError("MissingVariable") {};
|
|
41100
|
-
const variablePattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
|
|
41101
|
-
const lookup = (name) => String$4(name).pipe(option, orElseSucceed(() => none()));
|
|
41102
|
-
const expand = fnUntraced(function* (text) {
|
|
41103
|
-
let result = "";
|
|
41104
|
-
let last = 0;
|
|
41105
|
-
for (const match of text.matchAll(variablePattern)) {
|
|
41106
|
-
const [whole, name, fallback] = match;
|
|
41107
|
-
const value = filter$1(yield* lookup(name), (value) => fallback === void 0 ? true : value !== "");
|
|
41108
|
-
if (isNone(value) && fallback === void 0) return yield* new MissingVariable({ variable: name });
|
|
41109
|
-
result += text.slice(last, match.index) + getOrElse(value, () => fallback);
|
|
41110
|
-
last = match.index + whole.length;
|
|
41111
|
-
}
|
|
41112
|
-
return result + text.slice(last);
|
|
41113
|
-
});
|
|
41114
|
-
const expandStrings = fnUntraced(function* (value) {
|
|
41115
|
-
if (typeof value === "string") return yield* expand(value);
|
|
41116
|
-
if (Array.isArray(value)) return yield* forEach$1(value, (item) => typeof item === "string" ? expand(item) : succeed$1(item));
|
|
41117
|
-
if (typeof value === "object" && value !== null) {
|
|
41118
|
-
const result = {};
|
|
41119
|
-
for (const [key, item] of Object.entries(value)) result[key] = typeof item === "string" ? yield* expand(item) : item;
|
|
41120
|
-
return result;
|
|
41121
|
-
}
|
|
41122
|
-
return value;
|
|
41123
|
-
});
|
|
41124
|
-
const expandedFields = [
|
|
41125
|
-
"command",
|
|
41126
|
-
"args",
|
|
41127
|
-
"env",
|
|
41128
|
-
"cwd",
|
|
41129
|
-
"url",
|
|
41130
|
-
"headers"
|
|
41131
|
-
];
|
|
41132
|
-
const expandEntry = fnUntraced(function* (raw) {
|
|
41133
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
|
|
41134
|
-
const entry = { ...raw };
|
|
41135
|
-
for (const field of expandedFields) if (field in entry) entry[field] = yield* expandStrings(entry[field]);
|
|
41136
|
-
return entry;
|
|
41137
|
-
});
|
|
41138
41452
|
//#endregion
|
|
41139
41453
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Logger.js
|
|
41140
41454
|
const LogToStderr = LogToStderr$1;
|
|
41141
41455
|
//#endregion
|
|
41142
41456
|
//#region package.json
|
|
41143
|
-
var version$1 = "0.
|
|
41457
|
+
var version$1 = "0.13.0";
|
|
41144
41458
|
//#endregion
|
|
41145
41459
|
//#region src/cli.ts
|
|
41146
41460
|
const version = version$1;
|
|
41147
41461
|
const HttpClientLive = layerNodeHttpNoAgent.pipe(provide$3(layerAgentOptions({ keepAlive: true })));
|
|
41148
|
-
const providers =
|
|
41149
|
-
|
|
41150
|
-
|
|
41151
|
-
|
|
41152
|
-
|
|
41153
|
-
const
|
|
41154
|
-
|
|
41155
|
-
|
|
41462
|
+
const providers = Provider.literals;
|
|
41463
|
+
const selectModel = fnUntraced(function* (provider) {
|
|
41464
|
+
const catalog = (yield* (yield* ModelsRepo).models).filter((model) => model.provider === provider);
|
|
41465
|
+
const models = catalog.length > 0 ? catalog : fallback.filter((model) => model.provider === provider);
|
|
41466
|
+
const defaultId = fallback.find((model) => model.provider === provider)?.id;
|
|
41467
|
+
const model = yield* AutoComplete({
|
|
41468
|
+
message: "Select a model",
|
|
41469
|
+
choices: models.map((model) => ({
|
|
41470
|
+
title: model.name,
|
|
41471
|
+
description: model.id,
|
|
41472
|
+
value: model,
|
|
41473
|
+
selected: model.id === defaultId
|
|
41474
|
+
}))
|
|
41475
|
+
});
|
|
41476
|
+
if (model.efforts.length === 0) return {
|
|
41477
|
+
model: model.id,
|
|
41478
|
+
effort: null
|
|
41479
|
+
};
|
|
41480
|
+
const effort = yield* Select({
|
|
41481
|
+
message: "Select a reasoning effort",
|
|
41482
|
+
choices: model.efforts.map((effort) => ({
|
|
41483
|
+
title: effort,
|
|
41484
|
+
value: effort,
|
|
41485
|
+
selected: effort === "medium"
|
|
41486
|
+
}))
|
|
41487
|
+
});
|
|
41488
|
+
return {
|
|
41489
|
+
model: model.id,
|
|
41490
|
+
effort
|
|
41491
|
+
};
|
|
41492
|
+
});
|
|
41493
|
+
const isProvider = is(Provider);
|
|
41156
41494
|
const parseModelId = (modelId) => {
|
|
41157
41495
|
const [provider, model, effort, ...rest] = modelId.split("/");
|
|
41158
41496
|
return isProvider(provider) && model !== void 0 && is(ThoughtLevel)(effort) && rest.length === 0 ? some({
|
|
@@ -41160,13 +41498,6 @@ const parseModelId = (modelId) => {
|
|
|
41160
41498
|
thoughtLevel: effort
|
|
41161
41499
|
}) : none();
|
|
41162
41500
|
};
|
|
41163
|
-
const parseAcpModelId = (modelId) => {
|
|
41164
|
-
const [provider, model, ...rest] = modelId.split(":");
|
|
41165
|
-
return isProvider(provider) && model !== void 0 && rest.length === 0 ? some({
|
|
41166
|
-
provider,
|
|
41167
|
-
model
|
|
41168
|
-
}) : none();
|
|
41169
|
-
};
|
|
41170
41501
|
const ModelId = String$6.pipe(check(makeFilter((modelId) => isSome(parseModelId(modelId)) || `Invalid model "${modelId}", expected <provider>/<model>/<effort> with effort one of ${ThoughtLevel.literals.join(", ")}`)));
|
|
41171
41502
|
const provider = Literals("provider", providers).pipe(withAlias("p"), withFallbackPrompt(Select({
|
|
41172
41503
|
message: "Select a provider",
|
|
@@ -41207,28 +41538,35 @@ const Search = (directory) => unwrap$1(gen(function* () {
|
|
|
41207
41538
|
return empty$7;
|
|
41208
41539
|
}
|
|
41209
41540
|
const path = yield* Path$3;
|
|
41210
|
-
return (yield* promise(() => import("./SemanticSearch-
|
|
41541
|
+
return (yield* promise(() => import("./SemanticSearch-BcLFv9qz.mjs"))).layer({
|
|
41211
41542
|
directory: process.cwd(),
|
|
41212
41543
|
database: path.join(directory, "search.sqlite")
|
|
41213
41544
|
}).pipe(provide$3(model$3("text-embedding-3-small", { dimensions: 1536 })), provide$3(layer$4({ apiKey: apiKey.value })));
|
|
41214
41545
|
})).pipe(provide$3([layer$9, HttpClientLive]));
|
|
41215
41546
|
const acpModel = String$1("model").pipe(withAlias("m"), withDescription$1("Default model as <provider>/<model>/<effort>, e.g. openai/gpt-6-astra/medium"), withSchema(ModelId), withDefault("openai/gpt-6-astra/medium"), map$1((modelId) => getOrThrow(parseModelId(modelId))));
|
|
41216
|
-
const acp = make$
|
|
41547
|
+
const acp = make$30("acp", {
|
|
41217
41548
|
model: acpModel,
|
|
41218
41549
|
compaction,
|
|
41219
41550
|
apiKey,
|
|
41220
41551
|
apiUrl
|
|
41221
|
-
}).pipe(withDescription("Run as an Agent Client Protocol (ACP) server over stdio"), withHandler(({ model, apiKey, apiUrl }) =>
|
|
41222
|
-
|
|
41223
|
-
|
|
41224
|
-
|
|
41225
|
-
|
|
41226
|
-
|
|
41227
|
-
|
|
41228
|
-
|
|
41229
|
-
|
|
41552
|
+
}).pipe(withDescription("Run as an Agent Client Protocol (ACP) server over stdio"), withHandler(({ model, apiKey, apiUrl }) => gen(function* () {
|
|
41553
|
+
const repo = yield* ModelsRepo;
|
|
41554
|
+
return yield* runStdio({
|
|
41555
|
+
version,
|
|
41556
|
+
defaultModel: model.model,
|
|
41557
|
+
defaultThoughtLevel: model.thoughtLevel,
|
|
41558
|
+
availableModels: map$5(repo.models, acpModels),
|
|
41559
|
+
makeAgent: (cwd) => make$9.pipe(provide$1(layerLocal$1({ directory: cwd }))),
|
|
41560
|
+
makeModel: makeAcp({
|
|
41561
|
+
models: repo.models,
|
|
41562
|
+
openai: {
|
|
41563
|
+
apiKey: getOrUndefined(apiKey),
|
|
41564
|
+
apiUrl: getOrUndefined(apiUrl)
|
|
41565
|
+
}
|
|
41566
|
+
})
|
|
41567
|
+
});
|
|
41230
41568
|
})), provide(({ compaction }) => mergeAll(ConversationMode.layer(true), succeed$4(LogToStderr, true), layerLog, CompactionConfig.layer({ enabled: compaction }))));
|
|
41231
|
-
make$
|
|
41569
|
+
make$30("clanka", {
|
|
41232
41570
|
provider,
|
|
41233
41571
|
model,
|
|
41234
41572
|
semantic,
|
|
@@ -41245,18 +41583,18 @@ make$29("clanka", {
|
|
|
41245
41583
|
files: mcpConfig,
|
|
41246
41584
|
enabled: mcp
|
|
41247
41585
|
});
|
|
41248
|
-
const OutputFormatter = yield* promise(() => import("./OutputFormatter-
|
|
41249
|
-
const
|
|
41250
|
-
onSome:
|
|
41251
|
-
|
|
41252
|
-
|
|
41253
|
-
|
|
41254
|
-
|
|
41255
|
-
|
|
41256
|
-
|
|
41257
|
-
|
|
41258
|
-
})
|
|
41259
|
-
const Model =
|
|
41586
|
+
const OutputFormatter = yield* promise(() => import("./OutputFormatter-DRycCEdr.mjs"));
|
|
41587
|
+
const { model, effort } = yield* match$2(modelRaw, {
|
|
41588
|
+
onSome: (selected) => {
|
|
41589
|
+
const [model, effort] = selected.split("/");
|
|
41590
|
+
return succeed$1({
|
|
41591
|
+
model,
|
|
41592
|
+
effort
|
|
41593
|
+
});
|
|
41594
|
+
},
|
|
41595
|
+
onNone: () => selectModel(provider)
|
|
41596
|
+
});
|
|
41597
|
+
const Model = make(provider, model, effort, {
|
|
41260
41598
|
apiKey: getOrUndefined(apiKey),
|
|
41261
41599
|
apiUrl: getOrUndefined(apiUrl)
|
|
41262
41600
|
});
|
|
@@ -41278,12 +41616,11 @@ make$29("clanka", {
|
|
|
41278
41616
|
})), provideMerge(layer$6(mcpServers))), Model]));
|
|
41279
41617
|
})), provide(({ prompt, compaction }) => mergeAll(ConversationMode.layer(isNone(prompt)), CompactionConfig.layer({ enabled: compaction }))), withSubcommands([acp]), run$1({ version }), provide$1([
|
|
41280
41618
|
layer$9,
|
|
41281
|
-
Kvs,
|
|
41282
|
-
HttpClientLive,
|
|
41619
|
+
ModelsRepo.layerModelsDev().pipe(provideMerge([Kvs, HttpClientLive])),
|
|
41283
41620
|
layerWebSocketConstructor,
|
|
41284
41621
|
layerConsole
|
|
41285
41622
|
]), runMain);
|
|
41286
41623
|
//#endregion
|
|
41287
|
-
export { Path$3 as _, makeGrouped as a, StreamableHTTPClientTransport as c, maybeRemoveFile as d, maybeUpdateFile as f, Console as g, ChildProcessSpawner as h, batchN as i, Client as l, make$
|
|
41624
|
+
export { Path$3 as _, makeGrouped as a, StreamableHTTPClientTransport as c, maybeRemoveFile as d, maybeUpdateFile as f, Console as g, ChildProcessSpawner as h, batchN as i, Client as l, make$28 as m, EmbeddingModel as n, setDelay as o, map as p, EmbeddingRequest as r, withSpan as s, Dimensions as t, SemanticSearch as u, FileSystem as v };
|
|
41288
41625
|
|
|
41289
41626
|
//# sourceMappingURL=cli.mjs.map
|