clanka 0.24.2 → 0.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/Agent.d.ts.map +1 -1
  2. package/dist/Agent.js +23 -10
  3. package/dist/Agent.js.map +1 -1
  4. package/dist/Agent.test.js +137 -0
  5. package/dist/Agent.test.js.map +1 -1
  6. package/dist/ClaudeAgent.d.ts.map +1 -1
  7. package/dist/ClaudeAgent.js +5 -1
  8. package/dist/ClaudeAgent.js.map +1 -1
  9. package/dist/ClaudeAgent.test.js +45 -0
  10. package/dist/ClaudeAgent.test.js.map +1 -1
  11. package/dist/OutputFormatter.d.ts +1 -1
  12. package/dist/OutputFormatter.d.ts.map +1 -1
  13. package/dist/OutputFormatter.js +42 -2
  14. package/dist/OutputFormatter.js.map +1 -1
  15. package/dist/OutputFormatter.test.d.ts +2 -0
  16. package/dist/OutputFormatter.test.d.ts.map +1 -0
  17. package/dist/OutputFormatter.test.js +93 -0
  18. package/dist/OutputFormatter.test.js.map +1 -0
  19. package/dist/bin/{Stream-C51usiew.mjs → AiError-fiHIiGOy.mjs} +469 -34
  20. package/dist/bin/{Latch-BnrpWMd1.mjs → Latch-D1909CI6.mjs} +1 -1
  21. package/dist/bin/{McpClient-DoPNaNzW.mjs → McpClient-CXwyRd_3.mjs} +2 -3
  22. package/dist/bin/{OutputFormatter-U02YKTfy.mjs → OutputFormatter-B8yF7iiq.mjs} +40 -4
  23. package/dist/bin/{Schema-Box_9VZG.mjs → Schema-D629S5yu.mjs} +5459 -278
  24. package/dist/bin/{SemanticSearch-CH125AHH.mjs → SemanticSearch-BlcfFvPr.mjs} +14 -15
  25. package/dist/bin/cli.mjs +393 -819
  26. package/dist/bin/{upgrade-HMRGSqq8.mjs → upgrade-E_f-q2h8.mjs} +3 -4
  27. package/package.json +1 -1
  28. package/src/Agent.test.ts +198 -0
  29. package/src/Agent.ts +27 -10
  30. package/src/ClaudeAgent.test.ts +62 -0
  31. package/src/ClaudeAgent.ts +7 -1
  32. package/src/OutputFormatter.test.ts +158 -0
  33. package/src/OutputFormatter.ts +56 -1
  34. package/dist/bin/Effect-5XYMLOiB.mjs +0 -5183
@@ -1,5 +1,5 @@
1
- import { $ as ignoreCause, $a as succeed$5, $i as onExitUnsafe, $t as tapError$2, A as ensuring$2, Ac as constVoid, At as raceFirst, Bc as pipeArguments, Bi as fiberRunIn, Bn as doneExitFromCause, Cc as isTagged, Co as get$1, Cs as exitFail, Ds as makePrimitive, E as contextWith, Ea as fromIterable$1, Ei as callback$2, Es as isExit, Et as promise, Fi as fiberAwait, G as forkChild, Gn as nextPow2, Gr as close, Hi as flatMap$3, Hn as isDoneCause, Hr as Scope, Ht as scopedWith, Ia as map$3, Ii as fiberInterrupt, Is as toJson, It as runForkWith, J as forkScoped, Js as symbol, Jt as succeedSome, Kt as succeed$3, L as flatMap$2, Li as fiberInterruptAll, Lt as runPromiseWith, M as fail$3, Mc as dual, Mi as exitInterrupt$1, N as failCause$3, Ni as exitVoid, O as die$3, Oc as constTrue, Os as withFiber$1, Ot as provideContext$2, Pa as lastNonEmpty, Pc as identity, Pi as exitZipRight, Qi as onExitPrimitive, R as flatMapEager, Ra as of, Ri as fiberInterruptAllAs, So as empty$2, Ss as evaluate, St as onInterrupt, T as context, Ti as asSome, Ts as exitSucceed, U as forEach, Ua as headUnsafe, Un as matchEffect, Ur as addFinalizer, V as fnUntraced, Vi as findRecoverableError, Vn as filterDone, W as forever, Wa as fail$4, Wi as getCurrentFiber, Wr as addFinalizerExit, Xa as isSuccess$1, Xr as provide, Xt as sync, Ya as isFailure, Yn as Done$1, Yo as map$4, Yr as makeUnsafe$1, Yt as suspend$2, Z as gen, Zo as none, Zt as tap$1, _i as isFailure$1, a as andThen, aa as suspend$3, ac as hasProperty, bi as void_$2, bs as args, bt as onExit$2, c as as, ci as makeUnsafe$2, cr as fromReasons, di as die$4, dn as void_, ec as random, es as some, et as interrupt$2, fi as fail$5, fn as when, fr as isCause, ft as mapError$2, gi as isExit$1, gs as Done, gt as matchCauseEffect, hi as interrupt$1, ia as succeedNone, ic as symbol$1, ir as done, it as logError, j as exit, ja as isReadonlyArrayNonEmpty, jc as constant, ka as isArrayNonEmpty, kt as provideService$2, la as void_$1, lt as map$2, m as catchCause$2, mn as withFiber, mr as isDone, na as scopeAddFinalizer, no as normalizeNonEmpty, oa as sync$1, on as uninterruptible, p as callback$1, pi as failCause$4, pn as whileLoop, q as forkIn, qo as isSome, qr as forkUnsafe, qt as succeedNone$1, ra as succeed$4, ri as interruptWith, rn as tryPromise, rr as die$2, sa as uninterruptibleMask, t as acquireRelease, ta as scope, ti as doneUnsafe, to as normalize, u as asVoid, ui as asVoidAll, ur as hasInterruptsOnly, vi as isSuccess, vn as yieldNow, vs as PipeInspectableProto, vt as never, w as catch_$2, wi as andThen$1, wr as squash, ws as exitFailCause, xc as isString$1, xs as causeFail, xt as onExitPrimitive$1, yi as succeed$2, yt as onError, z as flatten$2, zi as fiberJoin, zn as catchDone } from "./Effect-5XYMLOiB.mjs";
2
- import { n as makeUnsafe$3, t as make$5 } from "./Latch-BnrpWMd1.mjs";
1
+ import { $c as void_$1, $i as interrupt$2, $u as isExit, Ac as fiberAwait, B as String$1, Bd as pipeArguments, Bo as matchEffect, Bs as addFinalizer, Cc as callback$2, Cl as isReadonlyArrayNonEmpty, Da as provideService$2, Dc as exitInterrupt$1, Dd as isTagged, Di as contextWith, Dl as map$3, Ea as provideContext$2, Ed as isString$1, Ei as context, El as lastNonEmpty, Fa as runPromiseWith, Fc as fiberRunIn, Fd as dual, Fu as none, Ga as succeedSome, Gc as scope, Gu as Done, H as Struct, Hi as forEach, Hl as isSuccess$1, Ho as nextPow2, Hs as close, I as Record, Ic as findRecoverableError, Il as headUnsafe, Io as catchDone, Ja as tap$1, Jc as succeedNone, Jl as format, Jo as Done$1, Ju as causeFail, Ka as suspend$2, Kc as scopeAddFinalizer, Ki as forkIn, Kl as normalize, Ks as makeUnsafe$1, Ku as PipeInspectableProto, L as Redacted, Lc as flatMap$3, Ld as identity, Li as flatMap$2, Ll as fail$4, Lo as doneExitFromCause, Mc as fiberInterruptAll, Mi as exit, Mu as isSome, Nc as fiberInterruptAllAs, Nd as constVoid, Ni as fail$3, Nu as map$4, Oa as raceFirst, Oc as exitVoid, Pa as runForkWith, Pc as fiberJoin, Pd as constant, Pi as failCause$3, Qi as ignoreCause, Qs as doneUnsafe, Qu as exitSucceed, Ri as flatMapEager, Ro as filterDone, Ru as some, Sc as asSome, T as MutableJson, Ti as catch_$2, Ua as succeed$3, Uc as onExitPrimitive, Ui as forever, Vi as fnUntraced, Vl as isFailure, Vs as addFinalizerExit, Wa as succeedNone$1, Wc as onExitUnsafe, Wi as forkChild, Wl as succeed$5, Ws as forkUnsafe, Xa as tapError$2, Xc as sync$1, Xi as gen, Xu as exitFail, Yc as suspend$3, Yu as evaluate, Zc as uninterruptibleMask, Zu as exitFailCause, _a as onError, _c as void_$2, _d as hasProperty, ac as makeUnsafe$2, b as Int, ba as onInterrupt, bn as withConstructorDefault, ca as map$2, cc as die$4, cd as toJson, co as void_, da as mapError$2, di as asVoid, dn as optional, do as withFiber, ds as isCause, ec as interruptWith, ed as makePrimitive, eo as tryPromise, fc as interrupt$1, g as Error$1, ga as never, gc as succeed$2, gd as symbol$1, hc as isSuccess, hd as random, hi as catchCause$2, ho as yieldNow, it as Unknown, j as NullOr, jc as fiberInterrupt, jd as constTrue, ji as ensuring$2, kc as exitZipRight, ki as die$3, kl as of, l as DateTimeUtc, lc as fail$5, li as as, lo as when, ls as hasInterruptsOnly, lu as empty$2, m as Duration, ma as matchCauseEffect, mc as isFailure$1, mi as callback$1, mn as tag, n as ArraySchema, ni as acquireRelease, ns as die$2, oi as andThen, p as Defect, pc as isExit$1, pd as symbol, ps as isDone, qa as sync, qc as succeed$4, qi as forkScoped, ql as normalizeNonEmpty, qs as provide, qu as args, ra as logError, ro as uninterruptible, rs as done, rt as Union, sc as asVoidAll, ss as fromReasons, td as withFiber$1, uc as failCause$4, uo as whileLoop, uu as get$1, va as onExit$2, vl as fromIterable$1, w as Literals, wa as promise, xc as andThen$1, xl as isArrayNonEmpty, xn as withDecodingDefault, xs as squash, ya as onExitPrimitive$1, za as scopedWith, zc as getCurrentFiber, zi as flatten$2, zo as isDoneCause, zs as Scope } from "./Schema-D629S5yu.mjs";
2
+ import { n as makeUnsafe$3, t as make$6 } from "./Latch-D1909CI6.mjs";
3
3
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/String.js
4
4
  const String = globalThis.String;
5
5
  const isString = isString$1;
@@ -14,9 +14,9 @@ const interruptAllAs = fiberInterruptAllAs;
14
14
  const getCurrent = getCurrentFiber;
15
15
  const runIn = fiberRunIn;
16
16
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/MutableRef.js
17
- const TypeId$5 = "~effect/MutableRef";
17
+ const TypeId$6 = "~effect/MutableRef";
18
18
  const MutableRefProto = {
19
- [TypeId$5]: TypeId$5,
19
+ [TypeId$6]: TypeId$6,
20
20
  ...PipeInspectableProto,
21
21
  [symbol](that) {
22
22
  return this === that;
@@ -31,7 +31,7 @@ const MutableRefProto = {
31
31
  };
32
32
  }
33
33
  };
34
- const make$4 = (value) => {
34
+ const make$5 = (value) => {
35
35
  const ref = Object.create(MutableRefProto);
36
36
  ref.current = value;
37
37
  return ref;
@@ -44,7 +44,7 @@ const set = dual(2, (self, value) => {
44
44
  const update = dual(2, (self, f) => set(self, f(get(self))));
45
45
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/MutableList.js
46
46
  const Empty = Symbol.for("effect/MutableList/Empty");
47
- const make$3 = () => ({
47
+ const make$4 = () => ({
48
48
  head: void 0,
49
49
  tail: void 0,
50
50
  length: 0
@@ -166,22 +166,22 @@ const filter$1 = (self, f) => {
166
166
  };
167
167
  const remove = (self, value) => filter$1(self, (v) => v !== value);
168
168
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/PubSub.js
169
- const TypeId$4 = "~effect/PubSub";
169
+ const TypeId$5 = "~effect/PubSub";
170
170
  const SubscriptionTypeId = "~effect/PubSub/Subscription";
171
- const make$2 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), new Map(), makeUnsafe$1(), makeUnsafe$3(false), make$4(false), options.strategy(), make$4(none())));
172
- const bounded$1 = (capacity) => make$2({
171
+ const make$3 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), new Map(), makeUnsafe$1(), makeUnsafe$3(false), make$5(false), options.strategy(), make$5(none())));
172
+ const bounded$1 = (capacity) => make$3({
173
173
  atomicPubSub: () => makeAtomicBounded(capacity),
174
174
  strategy: () => new BackPressureStrategy()
175
175
  });
176
- const dropping = (capacity) => make$2({
176
+ const dropping = (capacity) => make$3({
177
177
  atomicPubSub: () => makeAtomicBounded(capacity),
178
178
  strategy: () => new DroppingStrategy()
179
179
  });
180
- const sliding$1 = (capacity) => make$2({
180
+ const sliding$1 = (capacity) => make$3({
181
181
  atomicPubSub: () => makeAtomicBounded(capacity),
182
182
  strategy: () => new SlidingStrategy()
183
183
  });
184
- const unbounded$1 = (options) => make$2({
184
+ const unbounded$1 = (options) => make$3({
185
185
  atomicPubSub: () => makeAtomicUnbounded(options),
186
186
  strategy: () => new DroppingStrategy()
187
187
  });
@@ -306,7 +306,7 @@ const removeSubscribers = (subscribers, subscription, pollers) => {
306
306
  set.delete(pollers);
307
307
  if (set.size === 0) subscribers.delete(subscription);
308
308
  };
309
- const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$3(), makeUnsafe$3(false), make$4(false), strategy, pubsub.replayWindow(), ended);
309
+ const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$4(), makeUnsafe$3(false), make$5(false), strategy, pubsub.replayWindow(), ended);
310
310
  var BoundedPubSubArb = class {
311
311
  array;
312
312
  replayIndices;
@@ -880,7 +880,7 @@ var SubscriptionImpl = class {
880
880
  }
881
881
  };
882
882
  var PubSubImpl = class {
883
- [TypeId$4] = { _A: identity };
883
+ [TypeId$5] = { _A: identity };
884
884
  pubsub;
885
885
  subscribers;
886
886
  scope;
@@ -906,7 +906,7 @@ const ensureCapacity = (capacity) => {
906
906
  if (capacity <= 0 || capacity !== Infinity && !Number.isInteger(capacity)) throw new Error(`Cannot construct PubSub with capacity of ${capacity}`);
907
907
  };
908
908
  var BackPressureStrategy = class {
909
- publishers = make$3();
909
+ publishers = make$4();
910
910
  get shutdown() {
911
911
  return withFiber((fiber) => forEach(takeAll$2(this.publishers), ([_, deferred, last]) => last ? interruptWith(deferred, fiber.id) : void_, {
912
912
  concurrency: "unbounded",
@@ -1155,7 +1155,7 @@ const emptyReplayWindow = {
1155
1155
  close: () => void 0
1156
1156
  };
1157
1157
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Queue.js
1158
- const TypeId$3 = "~effect/Queue";
1158
+ const TypeId$4 = "~effect/Queue";
1159
1159
  const EnqueueTypeId = "~effect/Queue/Enqueue";
1160
1160
  const DequeueTypeId = "~effect/Queue/Dequeue";
1161
1161
  const variance = {
@@ -1163,7 +1163,7 @@ const variance = {
1163
1163
  _E: identity
1164
1164
  };
1165
1165
  const QueueProto = {
1166
- [TypeId$3]: variance,
1166
+ [TypeId$4]: variance,
1167
1167
  [EnqueueTypeId]: variance,
1168
1168
  [DequeueTypeId]: variance,
1169
1169
  ...PipeInspectableProto,
@@ -1175,12 +1175,12 @@ const QueueProto = {
1175
1175
  };
1176
1176
  }
1177
1177
  };
1178
- const make$1 = (options) => withFiber$1((fiber) => {
1178
+ const make$2 = (options) => withFiber$1((fiber) => {
1179
1179
  const self = Object.create(QueueProto);
1180
1180
  self.dispatcher = fiber.currentDispatcher;
1181
1181
  self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY;
1182
1182
  self.strategy = options?.strategy ?? "suspend";
1183
- self.messages = make$3();
1183
+ self.messages = make$4();
1184
1184
  self.scheduleRunning = false;
1185
1185
  self.state = {
1186
1186
  _tag: "Open",
@@ -1190,12 +1190,12 @@ const make$1 = (options) => withFiber$1((fiber) => {
1190
1190
  };
1191
1191
  return succeed$4(self);
1192
1192
  });
1193
- const bounded = (capacity) => make$1({ capacity });
1194
- const sliding = (capacity) => make$1({
1193
+ const bounded = (capacity) => make$2({ capacity });
1194
+ const sliding = (capacity) => make$2({
1195
1195
  capacity,
1196
1196
  strategy: "sliding"
1197
1197
  });
1198
- const unbounded = () => make$1();
1198
+ const unbounded = () => make$2();
1199
1199
  const offer = dual(2, (self, message) => suspend$3(() => offerUnsafe(self, message) ? exitTrue : self.state._tag === "Open" && self.strategy === "suspend" ? offerOrWait(self, message) : exitFalse));
1200
1200
  const offerUnsafe = (self, message) => {
1201
1201
  if (self.state._tag !== "Open") return false;
@@ -1519,14 +1519,14 @@ var SemaphoreImpl = class {
1519
1519
  });
1520
1520
  }
1521
1521
  };
1522
- const make = (permits) => sync$1(() => new SemaphoreImpl(permits));
1522
+ const make$1 = (permits) => sync$1(() => new SemaphoreImpl(permits));
1523
1523
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Take.js
1524
1524
  const toPull = (take) => isExit$1(take) ? isSuccess(take) ? done(take.value) : take : succeed$3(take);
1525
1525
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Channel.js
1526
- const TypeId$2 = "~effect/Channel";
1527
- const isChannel = (u) => hasProperty(u, TypeId$2);
1526
+ const TypeId$3 = "~effect/Channel";
1527
+ const isChannel = (u) => hasProperty(u, TypeId$3);
1528
1528
  const ChannelProto = {
1529
- [TypeId$2]: {
1529
+ [TypeId$3]: {
1530
1530
  _Env: identity,
1531
1531
  _InErr: identity,
1532
1532
  _InElem: identity,
@@ -1552,7 +1552,7 @@ const fromTransformBracket = (f) => fromTransform(fnUntraced(function* (upstream
1552
1552
  }));
1553
1553
  const toTransform = (channel) => channel.transform;
1554
1554
  const DefaultChunkSize = 4096;
1555
- const asyncQueue = (scope, f, options) => make$1({
1555
+ const asyncQueue = (scope, f, options) => make$2({
1556
1556
  capacity: options?.bufferSize,
1557
1557
  strategy: options?.strategy
1558
1558
  }).pipe(tap$1((queue) => addFinalizer(scope, shutdown(queue))), tap$1((queue) => provide(f(queue), scope).pipe(catchCause$2((cause) => failCause$2(queue, cause)), forkIn(scope, { startImmediately: true }))));
@@ -1614,7 +1614,7 @@ const fromReadableStream$1 = (options) => fromTransform((_, scope) => readableSt
1614
1614
  }));
1615
1615
  const readableStreamToPullUnsafe = (options) => {
1616
1616
  const reader = options.readable.getReader();
1617
- const exit = options.exit ?? make$4(void 0);
1617
+ const exit = options.exit ?? make$5(void 0);
1618
1618
  const pull = suspend$2(() => {
1619
1619
  if (exit.current) return exit.current;
1620
1620
  return matchCauseEffect(tryPromise({
@@ -1797,7 +1797,7 @@ const orDie$1 = (self) => catch_$1(self, die$1);
1797
1797
  const mergeAll$1 = dual(2, (channels, { bufferSize = 16, concurrency, switch: switch_ = false }) => fromTransformBracket(fnUntraced(function* (upstream, scope, forkedScope) {
1798
1798
  const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency);
1799
1799
  const semaphore = switch_ ? void 0 : makeUnsafe(concurrencyN);
1800
- const doneLatch = yield* make$5(true);
1800
+ const doneLatch = yield* make$6(true);
1801
1801
  const fibers = new Map();
1802
1802
  const queue = yield* bounded(bufferSize);
1803
1803
  yield* addFinalizer(forkedScope, shutdown(queue));
@@ -1998,7 +1998,7 @@ const toPubSubTake$1 = dual(2, fnUntraced(function* (self, options) {
1998
1998
  return pubsub;
1999
1999
  }));
2000
2000
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/internal/stream.js
2001
- const TypeId$1 = "~effect/Stream";
2001
+ const TypeId$2 = "~effect/Stream";
2002
2002
  const streamVariance = {
2003
2003
  _R: identity,
2004
2004
  _E: identity,
@@ -2008,15 +2008,15 @@ const Stream = function(channel) {
2008
2008
  this.channel = channel;
2009
2009
  };
2010
2010
  Stream.prototype = {
2011
- [TypeId$1]: streamVariance,
2011
+ [TypeId$2]: streamVariance,
2012
2012
  pipe() {
2013
2013
  return pipeArguments(this, arguments);
2014
2014
  }
2015
2015
  };
2016
2016
  const fromChannel$1 = (channel) => new Stream(channel);
2017
2017
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Stream.js
2018
- const TypeId = "~effect/Stream";
2019
- const isStream = (u) => hasProperty(u, TypeId);
2018
+ const TypeId$1 = "~effect/Stream";
2019
+ const isStream = (u) => hasProperty(u, TypeId$1);
2020
2020
  const fromChannel = fromChannel$1;
2021
2021
  const fromEffect = (effect) => fromChannel(fromEffect$1(map$2(effect, of)));
2022
2022
  const fromPull = (pull) => fromChannel(fromPull$1(pull));
@@ -2261,4 +2261,439 @@ const toAsyncIterableWith = dual(2, (self, context) => ({ [Symbol.asyncIterator]
2261
2261
  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
- 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 };
2264
+ // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/ai/AiError.js
2265
+ const HttpResponseDetails = Struct({
2266
+ status: Int,
2267
+ headers: Record(String$1, Union([String$1, Redacted(String$1)]))
2268
+ }).annotate({ identifier: "HttpResponseDetails" });
2269
+ const ReasonTypeId = "~effect/ai/AiError/Reason";
2270
+ const providerMetadataWithDefaults = () => ProviderMetadata.pipe(withConstructorDefault(succeed$3({})), withDecodingDefault(succeed$3({})));
2271
+ var NetworkError = class NetworkError extends Error$1("effect/ai/AiError/NetworkError")({
2272
+ _tag: tag("NetworkError"),
2273
+ reason: Literals([
2274
+ "TransportError",
2275
+ "EncodeError",
2276
+ "InvalidUrlError"
2277
+ ]),
2278
+ method: String$1,
2279
+ url: String$1,
2280
+ description: optional(String$1),
2281
+ cause: optional(Defect())
2282
+ }) {
2283
+ [ReasonTypeId] = ReasonTypeId;
2284
+ get isRetryable() {
2285
+ return this.reason === "TransportError";
2286
+ }
2287
+ static fromRequestError(error) {
2288
+ return new NetworkError({
2289
+ description: error.description,
2290
+ reason: error._tag,
2291
+ method: error.request.method,
2292
+ url: error.request.url
2293
+ });
2294
+ }
2295
+ static fromHttpClientError(error) {
2296
+ return new NetworkError({
2297
+ description: error.reason.description,
2298
+ reason: error.reason._tag,
2299
+ method: error.reason.request.method,
2300
+ url: error.reason.request.url,
2301
+ cause: error
2302
+ });
2303
+ }
2304
+ get message() {
2305
+ const methodAndUrl = `${this.method} ${this.url}`;
2306
+ let baseMessage = this.description ? `${this.reason}: ${this.description}` : `${this.reason}: A network error occurred.`;
2307
+ baseMessage += ` (${methodAndUrl})`;
2308
+ let suggestion = "";
2309
+ switch (this.reason) {
2310
+ case "EncodeError":
2311
+ suggestion += "Check that the request body data is properly formatted and matches the expected content type.";
2312
+ break;
2313
+ case "InvalidUrlError":
2314
+ suggestion += "Verify that the URL format is correct and that all required parameters have been provided.";
2315
+ suggestion += " Check for any special characters that may need encoding.";
2316
+ break;
2317
+ case "TransportError": suggestion += "Check your network connection and verify that the requested URL is accessible.";
2318
+ }
2319
+ baseMessage += `\n\n${suggestion}`;
2320
+ return baseMessage;
2321
+ }
2322
+ };
2323
+ const ProviderMetadata = Record(String$1, NullOr(MutableJson));
2324
+ const UsageInfo = Struct({
2325
+ promptTokens: optional(Int),
2326
+ completionTokens: optional(Int),
2327
+ totalTokens: optional(Int)
2328
+ }).annotate({ identifier: "UsageInfo" });
2329
+ const HttpContext = Struct({
2330
+ response: optional(HttpResponseDetails),
2331
+ body: optional(String$1)
2332
+ }).annotate({ identifier: "HttpContext" });
2333
+ const buildErrorDescription = (params) => {
2334
+ const parts = [];
2335
+ if (params.message) parts.push(params.message);
2336
+ else parts.push(`HTTP ${params.status}`);
2337
+ parts.push(`(${params.method} ${params.url})`);
2338
+ if (params.errorCode) parts.push(`[code: ${params.errorCode}]`);
2339
+ else if (params.errorType) parts.push(`[type: ${params.errorType}]`);
2340
+ if (params.requestId) parts.push(`[requestId: ${params.requestId}]`);
2341
+ if (!params.message && params.body) {
2342
+ const truncated = params.body.length > 200 ? params.body.slice(0, 200) + "..." : params.body;
2343
+ parts.push(`Response: ${truncated}`);
2344
+ }
2345
+ return parts.join(" ");
2346
+ };
2347
+ var RateLimitError = class extends Error$1("effect/ai/AiError/RateLimitError")({
2348
+ _tag: tag("RateLimitError"),
2349
+ retryAfter: optional(Duration),
2350
+ metadata: providerMetadataWithDefaults(),
2351
+ http: optional(HttpContext)
2352
+ }) {
2353
+ [ReasonTypeId] = ReasonTypeId;
2354
+ get isRetryable() {
2355
+ return true;
2356
+ }
2357
+ get message() {
2358
+ let msg = "Rate limit exceeded";
2359
+ if (this.retryAfter) msg += `. Retry after ${format(this.retryAfter)}`;
2360
+ return msg;
2361
+ }
2362
+ };
2363
+ var QuotaExhaustedError = class extends Error$1("effect/ai/AiError/QuotaExhaustedError")({
2364
+ _tag: tag("QuotaExhaustedError"),
2365
+ resetAt: optional(DateTimeUtc),
2366
+ metadata: providerMetadataWithDefaults(),
2367
+ http: optional(HttpContext)
2368
+ }) {
2369
+ [ReasonTypeId] = ReasonTypeId;
2370
+ get isRetryable() {
2371
+ return false;
2372
+ }
2373
+ get message() {
2374
+ let msg = "Quota exhausted";
2375
+ if (this.resetAt) msg += `. Resets at ${this.resetAt}`;
2376
+ return `${msg}. Check your account billing and usage limits.`;
2377
+ }
2378
+ };
2379
+ var AuthenticationError = class extends Error$1("effect/ai/AiError/AuthenticationError")({
2380
+ _tag: tag("AuthenticationError"),
2381
+ kind: Literals([
2382
+ "InvalidKey",
2383
+ "ExpiredKey",
2384
+ "MissingKey",
2385
+ "InsufficientPermissions",
2386
+ "Unknown"
2387
+ ]),
2388
+ description: optional(String$1),
2389
+ metadata: providerMetadataWithDefaults(),
2390
+ http: optional(HttpContext)
2391
+ }) {
2392
+ [ReasonTypeId] = ReasonTypeId;
2393
+ get isRetryable() {
2394
+ return false;
2395
+ }
2396
+ get message() {
2397
+ let msg = `${this.kind}: ${{
2398
+ InvalidKey: "Verify your API key is correct",
2399
+ ExpiredKey: "Your API key has expired. Generate a new one",
2400
+ MissingKey: "No API key provided. Set the appropriate environment variable",
2401
+ InsufficientPermissions: "Your API key lacks required permissions",
2402
+ Unknown: "Authentication failed. Check your credentials"
2403
+ }[this.kind]}`;
2404
+ if (this.description) msg += `. ${this.description}`;
2405
+ return msg;
2406
+ }
2407
+ };
2408
+ var ContentPolicyError = class extends Error$1("effect/ai/AiError/ContentPolicyError")({
2409
+ _tag: tag("ContentPolicyError"),
2410
+ description: String$1,
2411
+ metadata: providerMetadataWithDefaults(),
2412
+ http: optional(HttpContext)
2413
+ }) {
2414
+ [ReasonTypeId] = ReasonTypeId;
2415
+ get isRetryable() {
2416
+ return false;
2417
+ }
2418
+ get message() {
2419
+ return `Content policy violation: ${this.description}`;
2420
+ }
2421
+ };
2422
+ var InvalidRequestError = class extends Error$1("effect/ai/AiError/InvalidRequestError")({
2423
+ _tag: tag("InvalidRequestError"),
2424
+ parameter: optional(String$1),
2425
+ constraint: optional(String$1),
2426
+ description: optional(String$1),
2427
+ metadata: providerMetadataWithDefaults(),
2428
+ http: optional(HttpContext)
2429
+ }) {
2430
+ [ReasonTypeId] = ReasonTypeId;
2431
+ get isRetryable() {
2432
+ return false;
2433
+ }
2434
+ get message() {
2435
+ let msg = "Invalid request";
2436
+ if (this.parameter) msg += `: parameter '${this.parameter}'`;
2437
+ if (this.constraint) msg += ` ${this.constraint}`;
2438
+ if (this.description) msg += `. ${this.description}`;
2439
+ return msg;
2440
+ }
2441
+ };
2442
+ var InternalProviderError = class extends Error$1("effect/ai/AiError/InternalProviderError")({
2443
+ _tag: tag("InternalProviderError"),
2444
+ description: String$1,
2445
+ metadata: providerMetadataWithDefaults(),
2446
+ http: optional(HttpContext)
2447
+ }) {
2448
+ [ReasonTypeId] = ReasonTypeId;
2449
+ get isRetryable() {
2450
+ return true;
2451
+ }
2452
+ get message() {
2453
+ return `Internal provider error: ${this.description}`;
2454
+ }
2455
+ };
2456
+ var InvalidResponseError = class InvalidResponseError extends Error$1("effect/ai/AiError/InvalidResponseError")({
2457
+ _tag: tag("InvalidResponseError"),
2458
+ description: String$1,
2459
+ metadata: providerMetadataWithDefaults(),
2460
+ http: optional(HttpContext)
2461
+ }) {
2462
+ [ReasonTypeId] = ReasonTypeId;
2463
+ get isRetryable() {
2464
+ return false;
2465
+ }
2466
+ static fromSchemaError(error) {
2467
+ return new InvalidResponseError({ description: error.message });
2468
+ }
2469
+ get message() {
2470
+ return `Invalid response: ${this.description}`;
2471
+ }
2472
+ };
2473
+ var InvalidOutputError = class InvalidOutputError extends Error$1("effect/ai/AiError/InvalidOutputError")({
2474
+ _tag: tag("InvalidOutputError"),
2475
+ description: String$1,
2476
+ metadata: providerMetadataWithDefaults(),
2477
+ usage: optional(UsageInfo)
2478
+ }) {
2479
+ [ReasonTypeId] = ReasonTypeId;
2480
+ get isRetryable() {
2481
+ return true;
2482
+ }
2483
+ static fromSchemaError(error) {
2484
+ return new InvalidOutputError({ description: error.message });
2485
+ }
2486
+ get message() {
2487
+ return `Invalid output: ${this.description}`;
2488
+ }
2489
+ };
2490
+ var StructuredOutputError = class StructuredOutputError extends Error$1("effect/ai/AiError/StructuredOutputError")({
2491
+ _tag: tag("StructuredOutputError"),
2492
+ description: String$1,
2493
+ responseText: String$1,
2494
+ metadata: providerMetadataWithDefaults(),
2495
+ usage: optional(UsageInfo)
2496
+ }) {
2497
+ [ReasonTypeId] = ReasonTypeId;
2498
+ get isRetryable() {
2499
+ return true;
2500
+ }
2501
+ static fromSchemaError(error, responseText) {
2502
+ return new StructuredOutputError({
2503
+ description: error.message,
2504
+ responseText
2505
+ });
2506
+ }
2507
+ get message() {
2508
+ return `Structured output validation failed: ${this.description}`;
2509
+ }
2510
+ };
2511
+ var UnsupportedSchemaError = class extends Error$1("effect/ai/AiError/UnsupportedSchemaError")({
2512
+ _tag: tag("UnsupportedSchemaError"),
2513
+ description: String$1,
2514
+ metadata: providerMetadataWithDefaults()
2515
+ }) {
2516
+ [ReasonTypeId] = ReasonTypeId;
2517
+ get isRetryable() {
2518
+ return false;
2519
+ }
2520
+ get message() {
2521
+ return `Unsupported schema: ${this.description}`;
2522
+ }
2523
+ };
2524
+ var UnknownError = class extends Error$1("effect/ai/AiError/UnknownError")({
2525
+ _tag: tag("UnknownError"),
2526
+ description: optional(String$1),
2527
+ metadata: providerMetadataWithDefaults(),
2528
+ http: optional(HttpContext)
2529
+ }) {
2530
+ [ReasonTypeId] = ReasonTypeId;
2531
+ get isRetryable() {
2532
+ return false;
2533
+ }
2534
+ get message() {
2535
+ return this.description ?? "Unknown error";
2536
+ }
2537
+ };
2538
+ var ToolNotFoundError = class extends Error$1("effect/ai/AiError/ToolNotFoundError")({
2539
+ _tag: tag("ToolNotFoundError"),
2540
+ toolName: String$1,
2541
+ availableTools: ArraySchema(String$1)
2542
+ }) {
2543
+ [ReasonTypeId] = ReasonTypeId;
2544
+ get isRetryable() {
2545
+ return true;
2546
+ }
2547
+ get message() {
2548
+ const availableTools = this.availableTools.length > 0 ? this.availableTools.join(", ") : "none";
2549
+ return `Tool '${this.toolName}' not found. Available tools: ${availableTools}`;
2550
+ }
2551
+ };
2552
+ var ToolParameterValidationError = class extends Error$1("effect/ai/AiError/ToolParameterValidationError")({
2553
+ _tag: tag("ToolParameterValidationError"),
2554
+ toolName: String$1,
2555
+ description: String$1
2556
+ }) {
2557
+ [ReasonTypeId] = ReasonTypeId;
2558
+ get isRetryable() {
2559
+ return true;
2560
+ }
2561
+ get message() {
2562
+ return `Invalid parameters for tool '${this.toolName}': ${this.description}`;
2563
+ }
2564
+ };
2565
+ var InvalidToolResultError = class extends Error$1("effect/ai/AiError/InvalidToolResultError")({
2566
+ _tag: tag("InvalidToolResultError"),
2567
+ toolName: String$1,
2568
+ description: String$1
2569
+ }) {
2570
+ [ReasonTypeId] = ReasonTypeId;
2571
+ get isRetryable() {
2572
+ return false;
2573
+ }
2574
+ get message() {
2575
+ return `Tool '${this.toolName}' returned invalid result: ${this.description}`;
2576
+ }
2577
+ };
2578
+ var ToolResultEncodingError = class extends Error$1("effect/ai/AiError/ToolResultEncodingError")({
2579
+ _tag: tag("ToolResultEncodingError"),
2580
+ toolName: String$1,
2581
+ toolResult: Unknown,
2582
+ description: String$1
2583
+ }) {
2584
+ [ReasonTypeId] = ReasonTypeId;
2585
+ get isRetryable() {
2586
+ return false;
2587
+ }
2588
+ get message() {
2589
+ return `Failed to encode result for tool '${this.toolName}': ${this.description}`;
2590
+ }
2591
+ };
2592
+ var ToolConfigurationError = class extends Error$1("effect/ai/AiError/ToolConfigurationError")({
2593
+ _tag: tag("ToolConfigurationError"),
2594
+ toolName: String$1,
2595
+ description: String$1
2596
+ }) {
2597
+ [ReasonTypeId] = ReasonTypeId;
2598
+ get isRetryable() {
2599
+ return false;
2600
+ }
2601
+ get message() {
2602
+ return `Invalid configuration for tool '${this.toolName}': ${this.description}`;
2603
+ }
2604
+ };
2605
+ var ToolkitRequiredError = class extends Error$1("effect/ai/AiError/ToolkitRequiredError")({
2606
+ _tag: tag("ToolkitRequiredError"),
2607
+ pendingApprovals: ArraySchema(String$1),
2608
+ description: optional(String$1)
2609
+ }) {
2610
+ [ReasonTypeId] = ReasonTypeId;
2611
+ get isRetryable() {
2612
+ return false;
2613
+ }
2614
+ get message() {
2615
+ return `Toolkit required to resolve pending tool approvals: ${this.pendingApprovals.join(", ")}`;
2616
+ }
2617
+ };
2618
+ var InvalidUserInputError = class extends Error$1("effect/ai/AiError/InvalidUserInputError")({
2619
+ _tag: tag("InvalidUserInputError"),
2620
+ description: String$1
2621
+ }) {
2622
+ [ReasonTypeId] = ReasonTypeId;
2623
+ get isRetryable() {
2624
+ return false;
2625
+ }
2626
+ get message() {
2627
+ return `Invalid user input: ${this.description}`;
2628
+ }
2629
+ };
2630
+ const AiErrorReason = Union([
2631
+ RateLimitError,
2632
+ QuotaExhaustedError,
2633
+ AuthenticationError,
2634
+ ContentPolicyError,
2635
+ InvalidRequestError,
2636
+ InvalidResponseError,
2637
+ InternalProviderError,
2638
+ NetworkError,
2639
+ InvalidOutputError,
2640
+ StructuredOutputError,
2641
+ UnsupportedSchemaError,
2642
+ UnknownError,
2643
+ ToolNotFoundError,
2644
+ ToolParameterValidationError,
2645
+ InvalidToolResultError,
2646
+ ToolResultEncodingError,
2647
+ ToolConfigurationError,
2648
+ ToolkitRequiredError,
2649
+ InvalidUserInputError
2650
+ ]);
2651
+ const TypeId = "~effect/ai/AiError";
2652
+ var AiError = class extends Error$1("effect/ai/AiError/AiError")({
2653
+ _tag: tag("AiError"),
2654
+ module: String$1,
2655
+ method: String$1,
2656
+ reason: AiErrorReason
2657
+ }) {
2658
+ [TypeId] = TypeId;
2659
+ cause = this.reason;
2660
+ get isRetryable() {
2661
+ return this.reason.isRetryable;
2662
+ }
2663
+ get retryAfter() {
2664
+ return "retryAfter" in this.reason ? this.reason.retryAfter : void 0;
2665
+ }
2666
+ get message() {
2667
+ return `${this.module}.${this.method}: ${this.reason.message}`;
2668
+ }
2669
+ };
2670
+ const isAiError = (u) => hasProperty(u, TypeId);
2671
+ const isAiErrorReason = (u) => hasProperty(u, ReasonTypeId);
2672
+ const make = (params) => new AiError(params);
2673
+ const reasonFromHttpStatus = (params) => {
2674
+ const { status, http, metadata, description } = params;
2675
+ const common = {
2676
+ http,
2677
+ ...metadata ? { metadata } : void 0,
2678
+ ...description ? { description } : void 0
2679
+ };
2680
+ switch (status) {
2681
+ case 400: return new InvalidRequestError(common);
2682
+ case 401: return new AuthenticationError({
2683
+ kind: "InvalidKey",
2684
+ ...common
2685
+ });
2686
+ case 403: return new AuthenticationError({
2687
+ kind: "InsufficientPermissions",
2688
+ ...common
2689
+ });
2690
+ case 429: return new RateLimitError(common);
2691
+ default:
2692
+ if (status >= 500) return new InternalProviderError({
2693
+ description: "Server error",
2694
+ ...common
2695
+ });
2696
+ return new UnknownError(common);
2697
+ }
2698
+ };
2699
+ export { fromPubSub as $, offerUnsafe as $t, catchTags as A, takeUntil as At, failCause as B, unwrap$1 as Bt, make as C, runIntoPubSub as Ct, catchCause as D, succeed as Dt, callback as E, splitLines as Et, drainFork as F, transduce as Ft, flattenArray as G, endUnsafe as Gt, filterMap as H, makeUnsafe as Ht, drop as I, unwrap as It, fromArrayEffect as J, failCauseUnsafe as Jt, flattenIterable as K, fail$2 as Kt, empty as L, fromTransform as Lt, concat as M, tap as Mt, decodeText as N, tapError as Nt, catchIf as O, suspend as Ot, die as P, toAsyncIterable as Pt, fromIterable as Q, offerAllUnsafe as Qt, ensuring as R, mapDone as Rt, isAiErrorReason as S, runForEachArray as St, broadcast as T, scoped as Tt, flatMap as U, bounded as Ut, filter as V, make$1 as Vt, flatten as W, end as Wt, fromChannel as X, offer as Xt, fromAsyncIterable as Y, make$2 as Yt, fromEffect as Z, offerAll as Zt, ToolkitRequiredError as _, toLowerCase as _n, run as _t, InvalidOutputError as a, unbounded$1 as an, mapArray as at, buildErrorDescription as b, runFold as bt, InvalidToolResultError as c, update as cn, mapError as ct, RateLimitError as d, interrupt as dn, mkString as dt, poll as en, fromPull as et, StructuredOutputError as f, interruptAll as fn, onExit as ft, ToolResultEncodingError as g, camelToSnake as gn, provideService as gt, ToolParameterValidationError as h, runIn as hn, provideContext as ht, InternalProviderError as i, unbounded as in, map as it, catch_ as j, takeWhile as jt, catchReason as k, take as kt, NetworkError as l, await_ as ln, merge as lt, ToolNotFoundError as m, join as mn, pipeThroughChannel as mt, AuthenticationError as n, sliding as nn, fromReadableStream as nt, InvalidRequestError as o, make$5 as on, mapArrayEffect as ot, ToolConfigurationError as p, interruptAllAs as pn, orDie as pt, fromArray as q, failCause$2 as qt, HttpResponseDetails as r, take$1 as rn, isStream as rt, InvalidResponseError as s, set as sn, mapEffect as st, AiError as t, shutdownUnsafe as tn, fromQueue as tt, QuotaExhaustedError as u, getCurrent as un, mergeAll as ut, UnknownError as v, runCollect as vt, reasonFromHttpStatus as w, runLast as wt, isAiError as x, runForEach as xt, UnsupportedSchemaError as y, runDrain as yt, fail as z, toTransform as zt };
@@ -1,4 +1,4 @@
1
- import { Ji as makeLatchUnsafe, qi as makeLatch } from "./Effect-5XYMLOiB.mjs";
1
+ import { Bc as makeLatch, Vc as makeLatchUnsafe } from "./Schema-D629S5yu.mjs";
2
2
  // node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Latch.js
3
3
  const makeUnsafe = makeLatchUnsafe;
4
4
  const make = makeLatch;