clanka 0.23.2 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +24 -1
  2. package/dist/ModelLayer.d.ts +31 -6
  3. package/dist/ModelLayer.d.ts.map +1 -1
  4. package/dist/ModelLayer.js +49 -7
  5. package/dist/ModelLayer.js.map +1 -1
  6. package/dist/ModelLayer.test.js +39 -0
  7. package/dist/ModelLayer.test.js.map +1 -1
  8. package/dist/ModelsRepo.d.ts +7 -5
  9. package/dist/ModelsRepo.d.ts.map +1 -1
  10. package/dist/ModelsRepo.js +12 -4
  11. package/dist/ModelsRepo.js.map +1 -1
  12. package/dist/OpenAiCompat.d.ts +59 -0
  13. package/dist/OpenAiCompat.d.ts.map +1 -0
  14. package/dist/OpenAiCompat.js +96 -0
  15. package/dist/OpenAiCompat.js.map +1 -0
  16. package/dist/OpenAiCompat.test.d.ts +2 -0
  17. package/dist/OpenAiCompat.test.d.ts.map +1 -0
  18. package/dist/OpenAiCompat.test.js +110 -0
  19. package/dist/OpenAiCompat.test.js.map +1 -0
  20. package/dist/bin/Effect-5XYMLOiB.mjs +0 -2
  21. package/dist/bin/Latch-BnrpWMd1.mjs +0 -2
  22. package/dist/bin/McpClient-DoPNaNzW.mjs +0 -2
  23. package/dist/bin/OutputFormatter-U02YKTfy.mjs +0 -2
  24. package/dist/bin/Schema-Box_9VZG.mjs +0 -2
  25. package/dist/bin/SemanticSearch-CH125AHH.mjs +0 -2
  26. package/dist/bin/Stream-C51usiew.mjs +0 -2
  27. package/dist/bin/cli.mjs +106 -51
  28. package/dist/bin/helpers-CljL9OKa.mjs +0 -2
  29. package/dist/bin/index.min-ClUfQ5ji.mjs +0 -2
  30. package/dist/bin/server-HlLriZxF.mjs +0 -2
  31. package/dist/bin/turndown.cjs-C2WBxeA-.mjs +0 -2
  32. package/dist/bin/types-LcwjLVkt.mjs +0 -2
  33. package/dist/bin/upgrade-HMRGSqq8.mjs +0 -2
  34. package/dist/cli.js +38 -31
  35. package/dist/cli.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/ModelLayer.test.ts +62 -0
  38. package/src/ModelLayer.ts +60 -7
  39. package/src/ModelsRepo.ts +12 -4
  40. package/src/OpenAiCompat.test.ts +166 -0
  41. package/src/OpenAiCompat.ts +175 -0
  42. package/src/cli.ts +51 -39
  43. package/dist/bin/Effect-5XYMLOiB.mjs.map +0 -1
  44. package/dist/bin/Latch-BnrpWMd1.mjs.map +0 -1
  45. package/dist/bin/McpClient-DoPNaNzW.mjs.map +0 -1
  46. package/dist/bin/OutputFormatter-U02YKTfy.mjs.map +0 -1
  47. package/dist/bin/Schema-Box_9VZG.mjs.map +0 -1
  48. package/dist/bin/SemanticSearch-CH125AHH.mjs.map +0 -1
  49. package/dist/bin/Stream-C51usiew.mjs.map +0 -1
  50. package/dist/bin/cli.mjs.map +0 -1
  51. package/dist/bin/helpers-CljL9OKa.mjs.map +0 -1
  52. package/dist/bin/index.min-ClUfQ5ji.mjs.map +0 -1
  53. package/dist/bin/server-HlLriZxF.mjs.map +0 -1
  54. package/dist/bin/turndown.cjs-C2WBxeA-.mjs.map +0 -1
  55. package/dist/bin/types-LcwjLVkt.mjs.map +0 -1
  56. package/dist/bin/upgrade-HMRGSqq8.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenAiCompat.test.d.ts","sourceRoot":"","sources":["../src/OpenAiCompat.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,110 @@
1
+ import { assert, describe, it } from "@effect/vitest";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Redacted from "effect/Redacted";
5
+ import * as Stream from "effect/Stream";
6
+ import * as LanguageModel from "effect/ai/LanguageModel";
7
+ import * as HttpClient from "effect/http/HttpClient";
8
+ import * as HttpClientResponse from "effect/http/HttpClientResponse";
9
+ import * as Compaction from "./Compaction.js";
10
+ import * as ModelsRepo from "./ModelsRepo.js";
11
+ import * as OpenAiCompat from "./OpenAiCompat.js";
12
+ const client = {
13
+ apiUrl: "https://proxy.test/v1",
14
+ apiKey: Redacted.make("proxy-key"),
15
+ };
16
+ // An HttpClient that records its requests and answers each with `response`.
17
+ const recording = (response) => {
18
+ const requests = [];
19
+ const layer = Layer.succeed(HttpClient.HttpClient, HttpClient.make((request) => Effect.sync(() => {
20
+ requests.push(request);
21
+ return HttpClientResponse.fromWeb(request, response());
22
+ })));
23
+ return { requests, layer };
24
+ };
25
+ const jsonBody = (request) => {
26
+ if (request.body._tag !== "Uint8Array")
27
+ throw new Error("Expected JSON body");
28
+ return JSON.parse(new TextDecoder().decode(request.body.body));
29
+ };
30
+ // The requests a prompt sends, then the same prompt as a compaction summary.
31
+ const send = Effect.fnUntraced(function* (options) {
32
+ const http = recording(() => new Response(null, { status: 400 }));
33
+ yield* Effect.gen(function* () {
34
+ const ai = yield* LanguageModel.LanguageModel;
35
+ const summarize = yield* Compaction.SummarizerTransform;
36
+ const request = ai.streamText({ prompt: "hello" }).pipe(Stream.runDrain);
37
+ yield* request.pipe(Effect.exit);
38
+ yield* summarize(request).pipe(Effect.exit);
39
+ }).pipe(Effect.provide(OpenAiCompat.model("kimi-k3", options).pipe(Layer.provide(OpenAiCompat.layerClient(client)), Layer.provide(http.layer))));
40
+ assert.lengthOf(http.requests, 2);
41
+ return http.requests;
42
+ });
43
+ describe("OpenAiCompat.model", () => {
44
+ it.effect("streams chat completions from the configured endpoint", () => Effect.gen(function* () {
45
+ const [request] = yield* send();
46
+ assert.strictEqual(request.url, "https://proxy.test/v1/chat/completions");
47
+ assert.strictEqual(request.headers.authorization, "Bearer proxy-key");
48
+ assert.strictEqual(jsonBody(request).model, "kimi-k3");
49
+ }));
50
+ it.effect("sends the effort as reasoning_effort, and none when null", () => Effect.gen(function* () {
51
+ const [high] = yield* send({ reasoning: { effort: "high" } });
52
+ assert.strictEqual(jsonBody(high).reasoning_effort, "high");
53
+ assert.isFalse("reasoning" in jsonBody(high));
54
+ for (const options of [{ reasoning: null }, undefined]) {
55
+ const [request] = yield* send(options);
56
+ assert.isFalse("reasoning_effort" in jsonBody(request));
57
+ assert.isFalse("reasoning" in jsonBody(request));
58
+ }
59
+ }));
60
+ it.effect("caps compaction summaries with max_tokens", () => Effect.gen(function* () {
61
+ const [prompt, summary] = yield* send();
62
+ assert.isFalse("max_tokens" in jsonBody(prompt));
63
+ assert.strictEqual(jsonBody(summary).max_tokens, Compaction.summarizerMaxOutputTokens);
64
+ }));
65
+ });
66
+ const base = new ModelsRepo.ModelInfo({
67
+ provider: "openai",
68
+ id: "gpt-6-astra",
69
+ name: "GPT-6 Astra",
70
+ efforts: ["low", "high"],
71
+ });
72
+ // The catalog of a repo over `base` and an endpoint answering `response`.
73
+ const catalog = (response) => {
74
+ const http = recording(response);
75
+ return Effect.gen(function* () {
76
+ const repo = yield* ModelsRepo.ModelsRepo;
77
+ const first = yield* repo.models;
78
+ assert.deepStrictEqual(yield* repo.models, first);
79
+ return { models: first, requests: http.requests };
80
+ }).pipe(Effect.provide(OpenAiCompat.layerModelsRepo(client).pipe(Layer.provide([ModelsRepo.ModelsRepo.layer([base]), http.layer]))));
81
+ };
82
+ describe("OpenAiCompat.layerModelsRepo", () => {
83
+ it.effect("appends the listed models, newest first, with unknown efforts", () => Effect.gen(function* () {
84
+ const { models, requests } = yield* catalog(() => Response.json({
85
+ object: "list",
86
+ data: [
87
+ { id: "kimi-k2", object: "model", created: 1 },
88
+ { id: "kimi-k3", object: "model", created: 3 },
89
+ { object: "model" },
90
+ { id: "custom", object: "model" },
91
+ ],
92
+ }));
93
+ assert.lengthOf(requests, 1);
94
+ assert.strictEqual(requests[0].url, "https://proxy.test/v1/models");
95
+ assert.strictEqual(requests[0].headers.authorization, "Bearer proxy-key");
96
+ assert.deepStrictEqual(models, [
97
+ base,
98
+ ...["kimi-k3", "kimi-k2", "custom"].map((id) => new ModelsRepo.ModelInfo({
99
+ provider: "openai-compat",
100
+ id,
101
+ name: id,
102
+ })),
103
+ ]);
104
+ }));
105
+ it.effect("keeps the catalog when the endpoint cannot be listed", () => Effect.gen(function* () {
106
+ const { models } = yield* catalog(() => new Response(null, { status: 401 }));
107
+ assert.deepStrictEqual(models, [base]);
108
+ }));
109
+ });
110
+ //# sourceMappingURL=OpenAiCompat.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenAiCompat.test.js","sourceRoot":"","sources":["../src/OpenAiCompat.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AAEpD,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,uBAAuB;IAC/B,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;CACnC,CAAA;AAED,4EAA4E;AAC5E,MAAM,SAAS,GAAG,CAAC,QAAwB,EAAE,EAAE;IAC7C,MAAM,QAAQ,GAA+C,EAAE,CAAA;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CACzB,UAAU,CAAC,UAAU,EACrB,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC1B,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,QAAQ,CAAC,IAAI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,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;QAC5B,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,GAAG,EAAE,8BAA8B,CAAC,CAAA;QACpE,MAAM,CAAC,WAAW,CAChB,QAAQ,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,aAAa,EAClC,kBAAkB,CACnB,CAAA;QACD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE;YAC7B,IAAI;YACJ,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,GAAG,CACrC,CAAC,EAAE,EAAE,EAAE,CACL,IAAI,UAAU,CAAC,SAAS,CAAC;gBACvB,QAAQ,EAAE,eAAe;gBACzB,EAAE;gBACF,IAAI,EAAE,EAAE;aACT,CAAC,CACL;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CACL,CAAA;IAED,EAAE,CAAC,MAAM,CAAC,sDAAsD,EAAE,GAAG,EAAE,CACrE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,OAAO,CAC/B,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAC1C,CAAA;QACD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -5181,5 +5181,3 @@ const flatMapEager = flatMapEager$1;
5181
5181
  const catchEager = catchEager$1;
5182
5182
  const fnUntracedEager = fnUntracedEager$1;
5183
5183
  export { ignoreCause as $, succeed$5 as $a, onExitUnsafe as $i, TimeoutError as $n, orElseSome as $o, TracerTimingEnabled as $r, optimize as $s, tapError as $t, ensuring as A, isCanonicalArrayIndex as Aa, constVoid as Ac, endSpan as Ai, size as An, merge$1 as Ao, empty$1 as Ar, assignProperty as As, raceFirst as At, fn as B, sort as Ba, pipeArguments as Bc, fiberRunIn as Bi, doneExitFromCause as Bn, fromUndefinedOr as Bo, suspend$1 as Br, formatPath as Bs, scope as Bt, catchTags as C, findFirstIndex as Ca, isTagged as Cc, LogToStderr as Ci, empty as Cn, get$1 as Co, reasonAnnotations as Cr, exitFail as Cs, option as Ct, delay as D, headNonEmpty as Da, constFalse as Dc, contextWith$1 as Di, make as Dn, getUnsafe$1 as Do, effect as Dr, makePrimitive as Ds, provide as Dt, contextWith as E, fromIterable$1 as Ea, or as Ec, callback$1 as Ei, isEmpty as En, getOrUndefinedUnsafe as Eo, buildWithScope as Er, isExit$1 as Es, promise as Et, failSync as F, makeEquivalence as Fa, memoize as Fc, fiberAwait as Fi, jittered as Fn, flatMap$5 as Fo, orDie$1 as Fr, NodeInspectSymbol as Fs, runFork as Ft, forkChild as G, failVoid as Ga, iterateConcurrent as Gi, nextPow2 as Gn, isNone as Go, close as Gr, asEquivalence as Gs, sleep as Gt, fnUntracedEager as H, empty$3 as Ha, flatMap$2 as Hi, isDoneCause as Hn, getOrNull as Ho, Scope as Hr, currentFiberTypeId as Hs, scopedWith as Ht, filterOrFail as I, map$3 as Ia, memoizeIdempotent as Ic, fiberInterrupt as Ii, min as In, flatMapNullishOr$1 as Io, provide$2 as Ir, toJson as Is, runForkWith as It, forkScoped as J, getOrUndefined as Ja, makeLatchUnsafe as Ji, round as Jn, liftThrowable as Jo, make$1 as Jr, symbol as Js, succeedSome as Jt, forkDetach as K, flatMap$4 as Ka, iterateEager as Ki, parse as Kn, isOption as Ko, fork as Kr, byReferenceUnsafe as Ks, succeed as Kt, flatMap as L, match$2 as La, pipe as Lc, fiberInterruptAll as Li, spaced as Ln, flatten$3 as Lo, provideMerge as Lr, format$1 as Ls, runPromiseWith as Lt, fail as M, join as Ma, dual as Mc, exitInterrupt as Mi, forever$1 as Mn, all$2 as Mo, merge as Mr, setStackTraceLimit as Ms, request as Mt, failCause as N, last as Na, flow as Nc, exitVoid as Ni, fromStep as Nn, exists as No, mergeAll as Nr, BaseProto as Ns, result as Nt, die as O, isArray as Oa, constTrue as Oc, currentTimeMillis as Oi, remove as On, make$5 as Oo, effectContext as Or, withFiber$1 as Os, provideContext as Ot, failCauseSync as P, lastNonEmpty as Pa, identity as Pc, exitZipRight as Pi, isSchedule as Pn, filter as Po, mock as Pr, Class$1 as Ps, retry as Pt, ignore as Q, match$3 as Qa, onExitPrimitive$1 as Qi, StackTrace as Qn, orElse as Qo, MinimumLogLevel as Qr, number as Qs, tapCause as Qt, flatMapEager as R, of as Ra, Class$2 as Rc, fiberInterruptAllAs as Ri, toStep as Rn, fromNullOr as Ro, succeed$1 as Rr, formatDate as Rs, runSync as Rt, catchTag as S, findFirst as Sa, isSymbol as Sc, ConsoleRef as Si, TaggedClass as Sn, empty$4 as So, pretty as Sr, evaluate as Ss, onInterrupt as St, context as T, flatMapNullishOr as Ta, isUnknown as Tc, asSome$1 as Ti, get as Tn, getOrUndefined$1 as To, build as Tr, exitSucceed as Ts, orElseSucceed as Tt, forEach as U, headUnsafe as Ua, forkUnsafe$1 as Ui, matchEffect$1 as Un, getOrThrow$1 as Uo, addFinalizer$1 as Ur, redact as Us, service as Ut, fnUntraced as V, span as Va, findRecoverableError as Vi, filterDone as Vn, getOrElse$1 as Vo, unwrap as Vr, formatPropertyKey as Vs, scoped as Vt, forever as W, fail$5 as Wa, getCurrentFiber as Wi, Random as Wn, getOrUndefined$2 as Wo, addFinalizerExit as Wr, symbolRedactable as Ws, serviceOption as Wt, fromResult as X, isSuccess$1 as Xa, map$2 as Xi, IllegalArgumentError as Xn, match$5 as Xo, provide$3 as Xr, combine$1 as Xs, sync as Xt, fromOption as Y, isFailure$1 as Ya, makeSpanUnsafe as Yi, Done as Yn, map$5 as Yo, makeUnsafe as Yr, array as Ys, suspend as Yt, gen as Z, map$4 as Za, monotonicTimeNanos as Zi, NoSuchElementError as Zn, none as Zo, CurrentLogAnnotations as Zr, hash as Zs, tap as Zt, catchEager as _, append as _a, isNumber as _c, isFailure as _i, withSpan as _n, toSeconds as _o, isTimeoutError as _r, Error$1 as _s, matchEffect as _t, andThen as a, suspend$2 as aa, hasProperty as ac, isDone$1 as ai, undefined_ as an, hours as ao, fail$1 as ar, String$1 as as, logFatal as at, catchNoSuchElement as b, empty$2 as ba, isPropertyKey as bc, void_$1 as bi, equalBatchKeys as bn, Service as bo, makeInterruptReason as br, args as bs, onExit as bt, as as c, updateContext$1 as ca, isError as cc, makeUnsafe$1 as ci, updateContext as cn, isFinite as co, fromReasons as cr, isLessThan as cs, makeSpanScoped as ct, cached as d, ParentSpan as da, isNever as dc, die$2 as di, void_ as dn, millis as do, interruptors as dr, mapInput as ds, mapEager as dt, resolveConcurrency as ea, random$1 as ec, _await as ei, timeout as en, try_$2 as eo, UnknownError as er, some as es, interrupt as et, cachedWithTTL as f, encode as fa, isNotNull as fc, fail$3 as fi, when as fn, minutes as fo, isCause as fr, Tuple as fs, mapError as ft, catchDefect as g, Array$1 as ga, isNullish as gc, isExit as gi, withParentSpan as gn, toMillis as go, isReason as gr, Done$1 as gs, matchCauseEffect as gt, catchCauseIf as h, toPredicate as ha, isNull as hc, interrupt$1 as hi, withLogSpan as hn, seconds as ho, isFailReason as hr, Prototype as hs, matchCauseEager as ht, all as i, succeedNone$1 as ia, symbol$1 as ic, into as ii, try_ as in, fromInputUnsafe as io, done as ir, Number$2 as is, logError as it, exit as j, isReadonlyArrayNonEmpty as ja, constant as jc, exitHasInterrupts as ji, exponential as jn, omit as jo, fresh as jr, getStackTraceLimit as js, repeat as jt, effectify as k, isArrayNonEmpty as ka, constUndefined as kc, effectIsExit as ki, set as kn, makeUnsafe$2 as ko, effectDiscard as kr, assignProperties as ks, provideService as kt, asSome as l, void_$2 as la, isFunction as lc, succeed$2 as li, updateService as ln, isZero as lo, hasInterrupts as lr, isLessThanOrEqualTo as ls, map as lt, catchCause as m, has$1 as ma, isNotUndefined as mc, findErrorOption$1 as mi, withFiber as mn, negativeInfinity as mo, isDone as mr, strictEqual as ms, match as mt, acquireUseRelease as n, scopeAddFinalizer as na, structure as nc, fail$2 as ni, timeoutOrElse as nn, normalizeNonEmpty as no, combine as nr, BigInt$1 as ns, isEffect as nt, annotateCurrentSpan as o, sync$1 as oa, isBigInt as oc, isDoneUnsafe as oi, uninterruptible as on, infinity as oo, filterInterruptors as or, isGreaterThan as os, logInfo as ot, callback as p, compose as pa, isNotNullish as pc, failCause$2 as pi, whileLoop as pn, nanos as po, isDieReason as pr, make$7 as ps, mapErrorEager as pt, forkIn as q, getOrThrow as qa, makeLatch as qi, remainder as qn, isSome as qo, forkUnsafe as qr, equals$1 as qs, succeedNone as qt, addFinalizer as r, succeed$4 as ra, structureKeys as rc, interruptWith as ri, tryPromise as rn, format as ro, die$1 as rr, Date$1 as rs, logDebug as rt, annotateLogs as s, uninterruptibleMask$1 as sa, isBoolean as sc, make$2 as si, uninterruptibleMask as sn, isDuration as so, findErrorOption as sr, isGreaterThanOrEqualTo as ss, logWarning as st, acquireRelease as t, scope$1 as ta, string as tc, doneUnsafe as ti, timeoutOption as tn, normalize as to, annotate as tr, toArray as ts, interruptible as tt, asVoid as u, DisablePropagation as ua, isIterable as uc, asVoidAll as ui, useSpan as un, max as uo, hasInterruptsOnly as ur, make$6 as us, mapBothEager as ut, catchFilter as v, appendAll as va, isObject as vc, isSuccess as vi, yieldNow as vn, zero as vo, makeDieReason as vr, PipeInspectableProto as vs, never as vt, catch_ as w, findLast as wa, isUndefined as wc, andThen$1 as wi, forEach$1 as wn, getOption as wo, squash as wr, exitFailCause as ws, orDie as wt, catchReason as x, ensure as xa, isString as xc, ClockRef as xi, Class as xn, add as xo, map$1 as xr, causeFail as xs, onExitPrimitive as xt, catchIf as y, dedupe as ya, isObjectKeyword as yc, succeed$3 as yi, zipWith as yn, Reference as yo, makeFailReason as yr, TaggedError as ys, onError as yt, flatten as z, reduce as za, Prototype$1 as zc, fiberJoin as zi, catchDone as zn, fromNullishOr$1 as zo, succeedContext as zr, formatJson as zs, runSyncExit as zt };
5184
-
5185
- //# sourceMappingURL=Effect-5XYMLOiB.mjs.map
@@ -3,5 +3,3 @@ import { Ji as makeLatchUnsafe, qi as makeLatch } from "./Effect-5XYMLOiB.mjs";
3
3
  const makeUnsafe = makeLatchUnsafe;
4
4
  const make = makeLatch;
5
5
  export { makeUnsafe as n, make as t };
6
-
7
- //# sourceMappingURL=Latch-BnrpWMd1.mjs.map
@@ -31,5 +31,3 @@ const layer = effect(McpClient, gen(function* () {
31
31
  });
32
32
  }));
33
33
  export { McpClient, McpClientError, layer };
34
-
35
- //# sourceMappingURL=McpClient-DoPNaNzW.mjs.map
@@ -583,5 +583,3 @@ const layerMuxer = (formatter) => effect(Muxer, gen(function* () {
583
583
  });
584
584
  }));
585
585
  export { Muxer, layerMuxer, pretty };
586
-
587
- //# sourceMappingURL=OutputFormatter-U02YKTfy.mjs.map
@@ -7335,5 +7335,3 @@ const MutableJson = make(annotate(MutableJson$1, { toCode: () => ({
7335
7335
  Type: "Schema.MutableJson"
7336
7336
  }) }));
7337
7337
  export { URLFromString as $, optionalKey$1 as $n, make$7 as $r, isPattern as $t, Null as A, escapeToken as An, fromBody as Ar, isGreaterThan as At, String$1 as B, Objects as Bn, retryAfterDelay as Br, isLessThanDate as Bt, Literal as C, evolve as Cn, jsonSchemaAnnotationKeys as Cr, isBetweenCodePoints as Ct, Never as D, fromSchemaDraft07 as Dn, redactUrl as Dr, isBetweenSize as Dt, Natural as E, errorWithPath as En, fromInput as Er, isBetweenProperties as Et, OptionFromOptional as F, encodeEffect$1 as Fn, fromRecordUnsafe as Fr, isGreaterThanOrEqualToDate as Ft, TaggedClass as G, decodeTo$1 as Gn, formatIso as Gr, isMaxLength as Gt, Struct as H, Suspend as Hn, setAll$1 as Hr, isLessThanOrEqualToBigInt as Ht, Record as I, Arrays as In, isRedactedName$1 as Ir, isIncluding as It, TaggedUnion as J, isJson as Jn, now as Jr, isMinCodePoints as Jt, TaggedError as K, defaultParseOptions as Kn, formatIsoDate as Kr, isMaxProperties as Kt, Redacted as L, Filter as Ln, merge as Lr, isInt as Lt, Number$1 as M, getSubschemaKind as Mn, CurrentRedactedNames$1 as Mr, isGreaterThanDate as Mt, Option as N, decodeEffect$1 as Nn, empty$1 as Nr, isGreaterThanOrEqualTo as Nt, NonEmptyArray as O, fromSchemaDraft2020_12 as On, setAll as Or, isEndingWith as Ot, OptionFromNullOr as P, decodeUnknownEffect$1 as Pn, fromInput$1 as Pr, isGreaterThanOrEqualToBigInt as Pt, URL$1 as Q, null_ as Qn, isRedacted as Qr, isMultipleOf as Qt, RedactedFromValue as R, FilterGroup as Rn, parseRetryAfter as Rr, isLessThan as Rt, JsonObject as S, withDecodingDefaultKey as Sn, annotationExcludedKeys as Sr, isBetweenBigInt as St, MutableJson as T, pick as Tn, empty as Tr, isBetweenLength as Tt, StructWithRest as U, Union$1 as Un, empty$2 as Ur, isLessThanOrEqualToDate as Ut, StringForLiteralAutocomplete as V, PropertySignature as Vn, set as Vr, isLessThanOrEqualTo as Vt, Symbol$1 as W, applyToSelfOrLastLinkEncoding as Wn, fromSetCookie as Wr, isMaxCodePoints as Wt, Tuple as X, isOptional as Xn, decode as Xr, isMinProperties as Xt, TrueLiterals as Y, isNever as Yn, removeTime as Yr, isMinLength as Yt, TupleWithRest as Z, mapOrSame as Zn, encode as Zr, isMinSize as Zt, Exit as _, toEncoded as _n, transform$1 as _r, encodeUnknownEffect as _t, BooleanFromBit as a, EncodingError as ai, isUnique as an, toEncoded$1 as ar, Void as at, Int as b, withConstructorDefault as bn, InvalidValue as br, is as bt, Date$1 as c, TaggedError$1 as ci, makeFilter as cn, Transformation as cr, declare as ct, DateTimeUtcFromMillis as d, map$1 as di, optional as dn, transformEffect as dr, decodeTo as dt, value as ei, isPropertyNames as en, replaceChecks as er, Uint8Array$1 as et, DateTimeUtcFromString as f, optionalKey as fn, transformOptional as fr, decodeUnknownEffect as ft, Error$1 as g, toCodecStringTree as gn, passthroughSubtype as gr, encodeTo as gt, DurationFromMillis as h, toCodecJson as hn, passthrough$1 as hr, encodeEffect as ht, Boolean as i, monotonicTimeNanos as ii, isUUID as in, string as ir, Unknown as it, NullOr as j, parseUriFragment as jn, unwrap as jr, isGreaterThanBigInt as jt, NonEmptyString as k, getReferenceKey as kn, toString as kr, isFinite as kt, DateTimeUtc as l, taggedEnum as li, makeFilterGroup as ln, passthrough as lr, decodeEffect as lt, Duration as m, tag as mn, map as mr, decodeUnknownSync as mt, ArraySchema as n, Clock as ni, isSchemaError as nn, resolveDescription as nr, UndefinedOr as nt, BooleanLiterals as o, Error$2 as oi, link as on, toType$1 as or, brand as ot, Defect as p, suspend as pn, dateTimeUtcFromInput$1 as pr, decodeUnknownOption as pt, TaggedStruct as q, getIndexSignatureKeys as qn, fromDateUnsafe as qr, isMaxSize as qt, BigInt$1 as r, currentTimeMillis as ri, isStartingWith as rn, resolveIdentifier as rr, Union as rt, Class as s, TaggedClass$1 as si, make as sn, unknown as sr, check as st, Any as t, stringOrRedacted as ti, isSchema as tn, resolveAt as tr, Uint8ArrayFromBase64 as tt, DateTimeUtcFromDate as u, assignProperty as ui, mutable as un, transform as ur, decodeSync as ut, FalseLiterals as v, toJsonSchemaDocument as vn, transformEffect$1 as vr, fromJsonString as vt, Literals as w, omit as wn, CurrentRedactedNames as wr, isBetweenDate as wt, Json as x, withDecodingDefault as xn, Pointer as xr, isBetween as xt, Finite as y, toType as yn, transformOptional$1 as yr, instanceOf as yt, SchemaError as z, Literal$1 as zn, remove as zr, isLessThanBigInt as zt };
7338
-
7339
- //# sourceMappingURL=Schema-Box_9VZG.mjs.map
@@ -2544,5 +2544,3 @@ const layer = (options) => effect(SemanticSearch, gen(function* () {
2544
2544
  });
2545
2545
  })).pipe(provide$1([layer$3, layer$4.pipe(provide$1(SqliteLayer(options.database ?? ".clanka/search.sqlite")))]));
2546
2546
  export { SemanticSearch, chunkEmbeddingInput, layer, makeEmbeddingResolver, maybeRemoveFile, maybeUpdateFile };
2547
-
2548
- //# sourceMappingURL=SemanticSearch-CH125AHH.mjs.map
@@ -2262,5 +2262,3 @@ const toAsyncIterable = (self) => toAsyncIterableWith(self, empty$2());
2262
2262
  const runIntoPubSub = dual((args) => isStream(args[0]), (self, pubsub, options) => runIntoPubSubArray(self.channel, pubsub, options));
2263
2263
  const toPubSubTake = dual(2, (self, options) => toPubSubTake$1(self.channel, options));
2264
2264
  export { runLast as $, fromQueue as A, shutdownUnsafe as At, mkString as B, interrupt as Bt, fromArray as C, failCauseUnsafe as Ct, fromEffect as D, offerAllUnsafe as Dt, fromChannel as E, offerAll as Et, mapArrayEffect as F, make$4 as Ft, provideService as G, camelToSnake as Gt, orDie as H, interruptAllAs as Ht, mapEffect as I, set as It, runDrain as J, run as K, toLowerCase as Kt, mapError as L, update as Lt, isStream as M, take$1 as Mt, map as N, unbounded as Nt, fromPubSub as O, offerUnsafe as Ot, mapArray as P, unbounded$1 as Pt, runIntoPubSub as Q, merge as R, await_ as Rt, flattenIterable as S, failCause$2 as St, fromAsyncIterable as T, offer as Tt, pipeThroughChannel as U, join as Ut, onExit as V, interruptAll as Vt, provideContext as W, runIn as Wt, runForEach as X, runFold as Y, runForEachArray as Z, filter as _, makeUnsafe as _t, catchReason as a, takeUntil as at, flatten as b, endUnsafe as bt, concat as c, tapError as ct, drainFork as d, unwrap as dt, scoped as et, drop as f, fromTransform as ft, failCause as g, make as gt, fail as h, unwrap$1 as ht, catchIf as i, take as it, fromReadableStream as j, sliding as jt, fromPull as k, poll as kt, decodeText as l, toAsyncIterable as lt, ensuring as m, toTransform as mt, callback as n, succeed as nt, catchTags as o, takeWhile as ot, empty as p, mapDone as pt, runCollect as q, catchCause as r, suspend as rt, catch_ as s, tap as st, broadcast as t, splitLines as tt, die as u, transduce as ut, filterMap as v, bounded as vt, fromArrayEffect as w, make$1 as wt, flattenArray as x, fail$2 as xt, flatMap as y, end as yt, mergeAll as z, getCurrent as zt };
2265
-
2266
- //# sourceMappingURL=Stream-C51usiew.mjs.map
package/dist/bin/cli.mjs CHANGED
@@ -22395,7 +22395,7 @@ const load = fnUntraced(function* (options) {
22395
22395
  const text = yield* fs.readFileString(file).pipe(catchReason("PlatformError", "NotFound", (_, error) => required ? fail$1(error) : void_), mapError((error) => fail(error.message)));
22396
22396
  if (text === void 0) continue;
22397
22397
  const { mcpServers } = yield* decodeFile(text).pipe(mapError((error) => fail(error.message)));
22398
- for (const [name, entry] of Object.entries(mcpServers ?? {})) servers[name] = yield* decodeEntry(entry, {
22398
+ for (const [name, entry] of Object.entries(mcpServers ?? {})) servers[name] = yield* decodeEntry$1(entry, {
22399
22399
  directory: path.dirname(file),
22400
22400
  fail: (message) => fail(`MCP server "${name}": ${message}`),
22401
22401
  resolve: path.resolve
@@ -22403,7 +22403,7 @@ const load = fnUntraced(function* (options) {
22403
22403
  }
22404
22404
  return servers;
22405
22405
  });
22406
- const decodeEntry = fnUntraced(function* (raw, options) {
22406
+ const decodeEntry$1 = fnUntraced(function* (raw, options) {
22407
22407
  const entry = yield* decodeFileEntry(yield* expandEntry(raw)).pipe(mapError((error) => options.fail(error.message)));
22408
22408
  switch (entry.type ?? (entry.command !== void 0 ? "stdio" : entry.url !== void 0 ? "http" : void 0)) {
22409
22409
  case void 0: return yield* options.fail("needs a command or a url");
@@ -26435,7 +26435,7 @@ const mapProviderResults = (inputLength, results) => {
26435
26435
  };
26436
26436
  // node_modules/.pnpm/@effect+ai-openai@4.1.1_effect@4.1.1/node_modules/@effect/ai-openai/dist/OpenAiEmbeddingModel.js
26437
26437
  var Config$2 = class extends Service()("@effect/ai-openai/OpenAiEmbeddingModel/Config") {};
26438
- const model$4 = (model, options) => make$19("openai", model, merge$2(layer$3({
26438
+ const model$5 = (model, options) => make$19("openai", model, merge$2(layer$3({
26439
26439
  model,
26440
26440
  config: {
26441
26441
  ...options.config,
@@ -28631,7 +28631,7 @@ const transformToolCallParams$1 = fnUntraced(function* (options, toolName, toolP
28631
28631
  return yield* decodeEffect(codec)(toolParams).pipe(flatMap$1((decoded) => encodeUnknownEffect(tool.parametersSchema)(decoded)), orElseSucceed(() => toolParams));
28632
28632
  });
28633
28633
  // package.json
28634
- var version$1 = "0.23.2";
28634
+ var version$1 = "0.24.1";
28635
28635
  // src/ClaudeAgent.ts
28636
28636
  const minimumClaudeCodeVersion = "2.1.248";
28637
28637
  const serverName = "clanka";
@@ -29304,7 +29304,7 @@ const toParts = (parts) => {
29304
29304
  }
29305
29305
  return result;
29306
29306
  };
29307
- const model$3 = (model, options) => make$19("claude", model, merge$2(layerLanguageModel(model, options), AgentModelConfig.layer({
29307
+ const model$4 = (model, options) => make$19("claude", model, merge$2(layerLanguageModel(model, options), AgentModelConfig.layer({
29308
29308
  supportsImages: options?.supportsImages,
29309
29309
  cutStreamOnSteering: false
29310
29310
  })));
@@ -29542,8 +29542,8 @@ var CodexAuth = class CodexAuth extends Service()("clanka/CodexAuth") {
29542
29542
  static layerClient = this.layerClientNoDeps.pipe(provide$3(CodexAuth.layer));
29543
29543
  };
29544
29544
  // src/Codex.ts
29545
- const layerClient$2 = layer$4({ apiUrl: "https://chatgpt.com/backend-api/codex" }).pipe(provide$3(CodexAuth.layerClient));
29546
- const model$2 = (model, options) => make$19("openai", model, layerModel(model, options));
29545
+ const layerClient$3 = layer$4({ apiUrl: "https://chatgpt.com/backend-api/codex" }).pipe(provide$3(CodexAuth.layerClient));
29546
+ const model$3 = (model, options) => make$19("openai", model, layerModel(model, options));
29547
29547
  const modelWebSocket$1 = (model, options) => make$19("openai", model, layerModel(model, options).pipe(merge$2(fresh(layerWebSocketMode))));
29548
29548
  const layerModel = (model, options) => suspend$1(() => layer$2({
29549
29549
  model,
@@ -30879,8 +30879,8 @@ var GithubCopilotAuth = class GithubCopilotAuth extends Service()("clanka/Github
30879
30879
  static layerClient = this.layerClientNoDeps.pipe(provide$3(GithubCopilotAuth.layer));
30880
30880
  };
30881
30881
  // src/Copilot.ts
30882
- const layerClient$1 = layer$1({ apiUrl: API_URL }).pipe(provide$3(GithubCopilotAuth.layerClient));
30883
- const model$1 = (model, options) => make$19("openai", model, mergeAll(layer({
30882
+ const layerClient$2 = layer$1({ apiUrl: API_URL }).pipe(provide$3(GithubCopilotAuth.layerClient));
30883
+ const model$2 = (model, options) => make$19("openai", model, mergeAll(layer({
30884
30884
  model,
30885
30885
  config: omit(options ?? {}, options?.reasoning === null ? ["reasoning", ...AgentModelConfig.optionKeys] : AgentModelConfig.optionKeys)
30886
30886
  }), AgentModelConfig.layer(pick(options ?? {}, AgentModelConfig.optionKeys)), succeed$4(SummarizerTransform, (effect) => withConfigOverride(effect, { max_output_tokens: summarizerMaxOutputTokens }))));
@@ -30889,13 +30889,14 @@ const Provider = Literals$2([
30889
30889
  "openai",
30890
30890
  "copilot",
30891
30891
  "xai",
30892
- "claude"
30892
+ "claude",
30893
+ "openai-compat"
30893
30894
  ]);
30894
30895
  var ModelInfo = class extends Class$1("clanka/ModelsRepo/ModelInfo")({
30895
30896
  provider: Provider,
30896
30897
  id: String$7,
30897
30898
  name: String$7,
30898
- efforts: ArraySchema(ThoughtLevel)
30899
+ efforts: optionalKey(ArraySchema(ThoughtLevel))
30899
30900
  }) {};
30900
30901
  const fallback = [
30901
30902
  new ModelInfo({
@@ -31014,6 +31015,34 @@ var ModelsRepo = class ModelsRepo extends Service()("clanka/ModelsRepo") {
31014
31015
  return ModelsRepo.of({ models: yield* cached(load) });
31015
31016
  }));
31016
31017
  };
31018
+ // src/OpenAiCompat.ts
31019
+ const layerClient$1 = (options) => layer$1(options);
31020
+ const model$1 = (model, options) => make$19("openai-compat", model, mergeAll(layer({
31021
+ model,
31022
+ config: {
31023
+ ...omit(options ?? {}, ["reasoning", ...AgentModelConfig.optionKeys]),
31024
+ ...options?.reasoning?.effort === void 0 ? void 0 : { reasoning_effort: options.reasoning.effort }
31025
+ }
31026
+ }), AgentModelConfig.layer(pick(options ?? {}, AgentModelConfig.optionKeys)), succeed$4(SummarizerTransform, (effect) => withConfigOverride(effect, { max_output_tokens: summarizerMaxOutputTokens }))));
31027
+ const ModelsResponse = Struct({ data: ArraySchema(Unknown) });
31028
+ const ModelEntry = Struct({
31029
+ id: String$7,
31030
+ created: optionalKey(Finite)
31031
+ });
31032
+ const decodeEntry = decodeUnknownOption(ModelEntry);
31033
+ const models = gen(function* () {
31034
+ const { client } = yield* OpenAiClient;
31035
+ return (yield* filterStatusOk(client).get("/models").pipe(flatMap$1(schemaBodyJson(ModelsResponse)))).data.flatMap((entry) => decodeEntry(entry).pipe(toArray)).toSorted((a, b) => (b.created ?? 0) - (a.created ?? 0) || a.id.localeCompare(b.id)).map((entry) => new ModelInfo({
31036
+ provider: "openai-compat",
31037
+ id: entry.id,
31038
+ name: entry.id
31039
+ }));
31040
+ }).pipe(timeout("15 seconds"), catch_((error) => logWarning("Failed to list the openai-compat models", error).pipe(as([]))));
31041
+ const layerModelsRepo = (client) => effect(ModelsRepo, gen(function* () {
31042
+ const repo = yield* ModelsRepo;
31043
+ const listed = yield* cached(provideService(models, OpenAiClient, yield* OpenAiClient));
31044
+ return ModelsRepo.of({ models: zipWith(repo.models, listed, (catalog, compat) => [...catalog, ...compat], { concurrent: true }) });
31045
+ })).pipe(provide$3(layerClient$1(client)));
31017
31046
  // src/XaiAuth.ts
31018
31047
  const CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
31019
31048
  const ISSUER = "https://auth.x.ai";
@@ -31177,10 +31206,14 @@ const languageModel = (provider, model, effort, openai, fastMode) => {
31177
31206
  service_tier: "priority"
31178
31207
  } : options;
31179
31208
  switch (provider) {
31180
- case "openai": return openai.apiKey !== void 0 ? model$2(model, openaiOptions).pipe(provide$3(layer$4(openai))) : modelWebSocket$1(model, openaiOptions).pipe(provide$3(layerClient$2));
31209
+ case "openai": return openai.apiKey !== void 0 ? model$3(model, openaiOptions).pipe(provide$3(layer$4(openai))) : modelWebSocket$1(model, openaiOptions).pipe(provide$3(layerClient$3));
31181
31210
  case "xai": return modelWebSocket(model, options).pipe(provide$3(layerClient));
31182
- case "claude": return model$3(model, { effort });
31183
- case "copilot": return model$1(model, options).pipe(provide$3(layerClient$1));
31211
+ case "claude": return model$4(model, { effort });
31212
+ case "copilot": return model$2(model, options).pipe(provide$3(layerClient$2));
31213
+ case "openai-compat": return model$1(model, options).pipe(provide$3(layerClient$1({
31214
+ apiKey: openai.apiKey,
31215
+ apiUrl: openai.apiUrl
31216
+ })));
31184
31217
  }
31185
31218
  };
31186
31219
  const make = (provider, model, effort, openai, fastMode = false, auxiliary) => {
@@ -31188,14 +31221,38 @@ const make = (provider, model, effort, openai, fastMode = false, auxiliary) => {
31188
31221
  const main = languageModel(provider, model, effort, openai, fastMode);
31189
31222
  return mergeAll(main, layerSubagentModel(auxiliary?.subagent === void 0 ? main : fromSpec(auxiliary.subagent)), layerSummarizerModel(auxiliary?.summarizer === void 0 ? main : fromSpec(auxiliary.summarizer)));
31190
31223
  };
31191
- const isProvider$1 = is(Provider);
31224
+ const isProvider = is(Provider);
31192
31225
  const parseAcpModelId = (modelId) => {
31193
- const [provider, model, ...rest] = modelId.split(":");
31194
- return isProvider$1(provider) && model !== void 0 && rest.length === 0 ? some({
31226
+ const index = modelId.indexOf(":");
31227
+ const provider = modelId.slice(0, index);
31228
+ const model = modelId.slice(index + 1);
31229
+ return index !== -1 && isProvider(provider) && model !== "" ? some({
31195
31230
  provider,
31196
31231
  model
31197
31232
  }) : none();
31198
31233
  };
31234
+ const isThoughtLevel = is(ThoughtLevel);
31235
+ const parseModel = (value) => {
31236
+ const index = value.lastIndexOf("/");
31237
+ const effort = value.slice(index + 1);
31238
+ return index > 0 && isThoughtLevel(effort) ? {
31239
+ model: value.slice(0, index),
31240
+ effort
31241
+ } : {
31242
+ model: value,
31243
+ effort: void 0
31244
+ };
31245
+ };
31246
+ const parseModelSpec = (value) => {
31247
+ const index = value.indexOf("/");
31248
+ const provider = value.slice(0, index);
31249
+ const { model, effort } = parseModel(value.slice(index + 1));
31250
+ return index !== -1 && isProvider(provider) && model !== "" ? some({
31251
+ provider,
31252
+ model,
31253
+ effort
31254
+ }) : none();
31255
+ };
31199
31256
  const acpSupportsFastMode = (modelId) => exists(parseAcpModelId(modelId), ({ provider }) => supportsFastMode(provider));
31200
31257
  const acpModels = (models) => models.map((model) => ({
31201
31258
  modelId: `${model.provider}:${model.id}`,
@@ -31210,7 +31267,7 @@ const resolveEffort = (efforts, thoughtLevel) => {
31210
31267
  };
31211
31268
  const makeAcp = (options) => (modelId, thoughtLevel, fastMode = false) => map$8(parseAcpModelId(modelId), ({ provider, model }) => unwrap$3(map$5(options.models, (catalog) => {
31212
31269
  const info = catalog.find((entry) => entry.provider === provider && entry.id === model);
31213
- return make(provider, model, info === void 0 ? thoughtLevel : resolveEffort(info.efforts, thoughtLevel), options.openai, fastMode, options.auxiliary);
31270
+ return make(provider, model, info?.efforts === void 0 ? thoughtLevel : resolveEffort(info.efforts, thoughtLevel), options.openai, fastMode, options.auxiliary);
31214
31271
  })));
31215
31272
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Logger.js
31216
31273
  const LogToStderr = LogToStderr$1;
@@ -31229,6 +31286,7 @@ const providers = Provider.literals;
31229
31286
  const selectModel = fnUntraced(function* (provider) {
31230
31287
  const catalog = (yield* (yield* ModelsRepo).models).filter((model) => model.provider === provider);
31231
31288
  const models = catalog.length > 0 ? catalog : fallback.filter((model) => model.provider === provider);
31289
+ if (models.length === 0) return parseModel(yield* String$5({ message: "Enter a model id" }));
31232
31290
  const defaultId = fallback.find((model) => model.provider === provider)?.id;
31233
31291
  const model = yield* AutoComplete({
31234
31292
  message: "Select a model",
@@ -31239,6 +31297,10 @@ const selectModel = fnUntraced(function* (provider) {
31239
31297
  selected: model.id === defaultId
31240
31298
  }))
31241
31299
  });
31300
+ if (model.efforts === void 0) return {
31301
+ model: model.id,
31302
+ effort: void 0
31303
+ };
31242
31304
  if (model.efforts.length === 0) return {
31243
31305
  model: model.id,
31244
31306
  effort: null
@@ -31256,24 +31318,8 @@ const selectModel = fnUntraced(function* (provider) {
31256
31318
  effort
31257
31319
  };
31258
31320
  });
31259
- const isProvider = is(Provider);
31260
- const isThoughtLevel = is(ThoughtLevel);
31261
- const parseModelId = (modelId) => {
31262
- const [provider, model, effort, ...rest] = modelId.split("/");
31263
- return isProvider(provider) && model !== void 0 && (effort === void 0 || isThoughtLevel(effort)) && rest.length === 0 ? some({
31264
- model: `${provider}:${model}`,
31265
- thoughtLevel: fromUndefinedOr(effort)
31266
- }) : none();
31267
- };
31268
- const ModelId = String$7.pipe(check(makeFilter$1((modelId) => isSome(parseModelId(modelId)) || `Invalid model "${modelId}", expected <provider>/<model>[/<effort>] with effort one of ${ThoughtLevel.literals.join(", ")}`)));
31269
- const auxiliaryModel = (options) => String$1(options.name).pipe(withDescription$1(`${options.description} As <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/low; also ${options.env}.`), withFallbackConfig(String$4(options.env)), withSchema(ModelId), map$1((modelId) => {
31270
- const [provider, model, effort] = modelId.split("/");
31271
- return {
31272
- provider,
31273
- model,
31274
- effort
31275
- };
31276
- }), optional);
31321
+ const ModelId = String$7.pipe(check(makeFilter$1((modelId) => isSome(parseModelSpec(modelId)) || `Invalid model "${modelId}", expected <provider>/<model>[/<effort>] with provider one of ${providers.join(", ")}`)));
31322
+ const auxiliaryModel = (options) => String$1(options.name).pipe(withDescription$1(`${options.description} As <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/low; also ${options.env}.`), withFallbackConfig(String$4(options.env)), withSchema(ModelId), map$1((modelId) => getOrThrow$1(parseModelSpec(modelId))), optional);
31277
31323
  const subagentModel = auxiliaryModel({
31278
31324
  name: "subagent-model",
31279
31325
  env: "CLANKA_SUBAGENT_MODEL",
@@ -31307,12 +31353,23 @@ const provider = Literals("provider", providers).pipe(withAlias("p"), withFallba
31307
31353
  {
31308
31354
  title: "claude",
31309
31355
  value: "claude"
31356
+ },
31357
+ {
31358
+ title: "openai-compat",
31359
+ value: "openai-compat"
31310
31360
  }
31311
31361
  ]
31312
31362
  })));
31313
31363
  const model = String$1("model").pipe(withAlias("m"), optional);
31314
- const apiKey = Redacted("api-key").pipe(withDescription$1("OpenAI API key (defaults to CLANKA_OPENAI_API_KEY)"), withFallbackConfig(Redacted$3("CLANKA_OPENAI_API_KEY")), optional);
31315
- const apiUrl = String$1("api-url").pipe(withDescription$1("OpenAI API base URL for API-key mode (defaults to CLANKA_OPENAI_API_URL or https://api.openai.com/v1)"), withFallbackConfig(String$4("CLANKA_OPENAI_API_URL")), optional);
31364
+ const apiKey = Redacted("api-key").pipe(withDescription$1("API key for the openai API-key mode and the openai-compat provider (defaults to CLANKA_OPENAI_API_KEY)"), withFallbackConfig(Redacted$3("CLANKA_OPENAI_API_KEY")), optional);
31365
+ const apiUrl = String$1("api-url").pipe(withDescription$1("API base URL for the openai API-key mode and the openai-compat provider (defaults to CLANKA_OPENAI_API_URL or https://api.openai.com/v1). When set, the models it lists at /models are offered as openai-compat models."), withFallbackConfig(String$4("CLANKA_OPENAI_API_URL")), optional);
31366
+ const openAiCompatModels = (flags) => match$2(flags.apiUrl, {
31367
+ onNone: () => empty$7,
31368
+ onSome: (apiUrl) => layerModelsRepo({
31369
+ apiUrl,
31370
+ apiKey: getOrUndefined(flags.apiKey)
31371
+ })
31372
+ });
31316
31373
  const fast = Boolean("fast").pipe(withDescription$1("Use OpenAI fast mode (the priority service tier) for faster responses at a higher cost. Applies to the openai provider only; also CLANKA_FAST=true."), withFallbackConfig(Boolean$3("CLANKA_FAST").pipe(withDefault$2(false))));
31317
31374
  const semantic = Directory("search").pipe(withDescription$1("Directory for semantic search data (uses OPENAI_API_KEY env var)"), withAlias("s"), optional);
31318
31375
  const prompt = String$1("prompt").pipe(withDescription$1("Pass a prompt in non-interactive mode"), optional);
@@ -31348,9 +31405,15 @@ const Search = (directory) => unwrap$3(gen(function* () {
31348
31405
  return (yield* promise(() => import("./SemanticSearch-CH125AHH.mjs"))).layer({
31349
31406
  directory: process.cwd(),
31350
31407
  database: path.join(directory, "search.sqlite")
31351
- }).pipe(provide$3(model$4("text-embedding-3-small", { dimensions: 1536 })), provide$3(layer$4({ apiKey: apiKey.value })));
31408
+ }).pipe(provide$3(model$5("text-embedding-3-small", { dimensions: 1536 })), provide$3(layer$4({ apiKey: apiKey.value })));
31352
31409
  })).pipe(provide$3([layer$9, HttpClientLive]));
31353
- const acpModel = String$1("model").pipe(withAlias("m"), withDescription$1("Default model as <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/medium. Without an effort, uses CLANKA_REASONING, or medium."), withSchema(ModelId), withDefault("openai/gpt-6-astra"), map$1((modelId) => getOrThrow$1(parseModelId(modelId))));
31410
+ const acpModel = String$1("model").pipe(withAlias("m"), withDescription$1("Default model as <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/medium. Without an effort, uses CLANKA_REASONING, or medium."), withSchema(ModelId), withDefault("openai/gpt-6-astra"), map$1((modelId) => {
31411
+ const spec = getOrThrow$1(parseModelSpec(modelId));
31412
+ return {
31413
+ model: `${spec.provider}:${spec.model}`,
31414
+ thoughtLevel: fromUndefinedOr(spec.effort)
31415
+ };
31416
+ }));
31354
31417
  const trustAllTools = Boolean("trust-all-tools").pipe(withDescription$1("Accepted for kiro-cli compatibility. Has no effect: clanka runs every tool call without asking."), withDefault(false));
31355
31418
  const reasoning = schema$1(ThoughtLevel, "CLANKA_REASONING").pipe(withDefault$2("medium"));
31356
31419
  const acp = make$27("acp", {
@@ -31387,7 +31450,7 @@ const acp = make$27("acp", {
31387
31450
  auxiliary: auxiliaryModels(flags)
31388
31451
  })
31389
31452
  });
31390
- })), provide((flags) => mergeAll(ConversationMode.layer(false), succeed$4(LogToStderr, true), layerLog, compactionConfig(flags))));
31453
+ })), provide((flags) => mergeAll(ConversationMode.layer(false), succeed$4(LogToStderr, true), layerLog, compactionConfig(flags), openAiCompatModels(flags))));
31391
31454
  make$27("clanka", {
31392
31455
  provider,
31393
31456
  fetch: fetch$1,
@@ -31412,13 +31475,7 @@ make$27("clanka", {
31412
31475
  });
31413
31476
  const OutputFormatter = yield* promise(() => import("./OutputFormatter-U02YKTfy.mjs"));
31414
31477
  const { model, effort } = yield* match$2(modelRaw, {
31415
- onSome: (selected) => {
31416
- const [model, effort] = selected.split("/");
31417
- return succeed$1({
31418
- model,
31419
- effort
31420
- });
31421
- },
31478
+ onSome: (selected) => succeed$1(parseModel(selected)),
31422
31479
  onNone: () => selectModel(provider)
31423
31480
  });
31424
31481
  const Model = make(provider, model, effort, {
@@ -31444,12 +31501,10 @@ make$27("clanka", {
31444
31501
  onNone: () => empty$7,
31445
31502
  onSome: Search
31446
31503
  })), provideMerge(layer$6(mcpServers))), Model]));
31447
- })), provide(({ prompt, ...flags }) => mergeAll(ConversationMode.layer(isNone(prompt)), compactionConfig(flags))), withSubcommands([acp]), withGlobalFlags([ReportedVersion]), run$1({ version }), provide$1([
31504
+ })), provide(({ prompt, ...flags }) => mergeAll(ConversationMode.layer(isNone(prompt)), compactionConfig(flags), openAiCompatModels(flags))), withSubcommands([acp]), withGlobalFlags([ReportedVersion]), run$1({ version }), provide$1([
31448
31505
  layer$9,
31449
31506
  ModelsRepo.layerModelsDev().pipe(provideMerge([Kvs, HttpClientLive])),
31450
31507
  layerWebSocketConstructor,
31451
31508
  layerConsole
31452
31509
  ]), runMain);
31453
31510
  export { ChildProcessSpawner as C, FileSystem as E, make$25 as S, Path$3 as T, SocketReadError as _, makeGrouped as a, isCloseEvent as b, StreamableHTTPClientTransport as c, maybeRemoveFile as d, maybeUpdateFile as f, SocketOpenError as g, SocketError as h, batchN as i, Client as l, SocketCloseError as m, EmbeddingModel as n, setDelay as o, map as p, EmbeddingRequest as r, withSpan as s, Dimensions as t, SemanticSearch as u, SocketUpgradeError as v, Console as w, make$22 as x, SocketWriteError as y };
31454
-
31455
- //# sourceMappingURL=cli.mjs.map
@@ -7153,5 +7153,3 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
7153
7153
  }
7154
7154
  }
7155
7155
  export { mergeCapabilities as a, safeParse as c, Protocol as i, assertToolsCallTaskCapability as n, getLiteralValue as o, AjvJsonSchemaValidator as r, getObjectShape as s, assertClientRequestTaskCapability as t };
7156
-
7157
- //# sourceMappingURL=helpers-CljL9OKa.mjs.map
@@ -3778,5 +3778,3 @@ var Cs = Object.assign(ks, {
3778
3778
  });
3779
3779
  Cs.glob = Cs;
3780
3780
  export { j as Glob, at as Ignore, K as escape, Cs as glob, Os as globIterate, Qt as globIterateSync, As as globStream, Jt as globStreamSync, Rs as globSync, _e as hasMagic, fn as iterate, cn as iterateSync, ln as stream, an as streamSync, un as sync, st as unescape };
3781
-
3782
- //# sourceMappingURL=index.min-ClUfQ5ji.mjs.map
@@ -315,5 +315,3 @@ var Server = class extends Protocol {
315
315
  }
316
316
  };
317
317
  export { Server };
318
-
319
- //# sourceMappingURL=server-HlLriZxF.mjs.map
@@ -15137,5 +15137,3 @@ var require_turndown_cjs = __commonJSMin(((exports, module) => {
15137
15137
  }));
15138
15138
  export default require_turndown_cjs();
15139
15139
  export {};
15140
-
15141
- //# sourceMappingURL=turndown.cjs-C2WBxeA-.mjs.map
@@ -5256,5 +5256,3 @@ var UrlElicitationRequiredError = class extends McpError {
5256
5256
  }
5257
5257
  };
5258
5258
  export { array as $, ListTasksResultSchema as A, SUPPORTED_PROTOCOL_VERSIONS as B, LATEST_PROTOCOL_VERSION as C, ListResourcesResultSchema as D, ListResourceTemplatesResultSchema as E, ProgressNotificationSchema as F, isJSONRPCErrorResponse as G, TaskStatusNotificationSchema as H, PromptListChangedNotificationSchema as I, isJSONRPCResultResponse as J, isJSONRPCNotification as K, RELATED_TASK_META_KEY as L, LoggingLevelSchema as M, McpError as N, ListRootsResultSchema as O, PingRequestSchema as P, any as Q, ReadResourceResultSchema as R, JSONRPCMessageSchema as S, ListPromptsResultSchema as T, ToolListChangedNotificationSchema as U, SetLevelRequestSchema as V, isInitializedNotification as W, types_exports as X, isTaskAugmentedRequestParams as Y, ZodNumber as Z, GetTaskRequestSchema as _, CancelledNotificationSchema as a, string as at, InitializeResultSchema as b, CreateMessageResultSchema as c, safeParse$1 as ct, ElicitRequestSchema as d, boolean as et, ElicitResultSchema as f, GetTaskPayloadRequestSchema as g, GetPromptResultSchema as h, CancelTaskResultSchema as i, object as it, ListToolsResultSchema as j, ListTasksRequestSchema as k, CreateMessageResultWithToolsSchema as l, NEVER as lt, ErrorCode as m, CallToolResultSchema as n, looseObject as nt, CompleteResultSchema as o, url as ot, EmptyResultSchema as p, isJSONRPCRequest as q, CancelTaskRequestSchema as r, number as rt, CreateMessageRequestSchema as s, _coercedNumber as st, CallToolRequestSchema as t, literal as tt, CreateTaskResultSchema as u, GetTaskResultSchema as v, ListChangedOptionsBaseSchema as w, InitializedNotificationSchema as x, InitializeRequestSchema as y, ResourceListChangedNotificationSchema as z };
5259
-
5260
- //# sourceMappingURL=types-LcwjLVkt.mjs.map
@@ -338,5 +338,3 @@ const drainBody = (body, maxBytes) => callback((resume) => {
338
338
  return sync(done);
339
339
  });
340
340
  export { drainBody, frameBody, toSocket };
341
-
342
- //# sourceMappingURL=upgrade-HMRGSqq8.mjs.map