clanka 0.24.3 → 0.24.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +24 -11
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +137 -0
- package/dist/Agent.test.js.map +1 -1
- package/dist/AgentTools.d.ts +88 -88
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/OutputFormatter.d.ts +1 -1
- package/dist/OutputFormatter.d.ts.map +1 -1
- package/dist/OutputFormatter.js +42 -2
- package/dist/OutputFormatter.js.map +1 -1
- package/dist/OutputFormatter.test.d.ts +2 -0
- package/dist/OutputFormatter.test.d.ts.map +1 -0
- package/dist/OutputFormatter.test.js +93 -0
- package/dist/OutputFormatter.test.js.map +1 -0
- package/dist/bin/{Stream-C51usiew.mjs → AiError-CsvdOsKR.mjs} +533 -74
- package/dist/bin/Latch-B3e9629m.mjs +5 -0
- package/dist/bin/{McpClient-DoPNaNzW.mjs → McpClient-BCxZZgnA.mjs} +2 -3
- package/dist/bin/{OutputFormatter-U02YKTfy.mjs → OutputFormatter-ByMjyBhe.mjs} +40 -4
- package/dist/bin/{Schema-Box_9VZG.mjs → Schema-BfUmMefy.mjs} +5602 -360
- package/dist/bin/{SemanticSearch-CH125AHH.mjs → SemanticSearch-DMzIsoZb.mjs} +80 -68
- package/dist/bin/cli.mjs +849 -1163
- package/dist/bin/{helpers-CljL9OKa.mjs → helpers-Bb68A2Sv.mjs} +2 -2
- package/dist/bin/{index.min-ClUfQ5ji.mjs → index.min-CuA3AuA-.mjs} +1448 -1348
- package/dist/bin/{rolldown-runtime-5zChB7MF.mjs → rolldown-runtime-CXhmmSW5.mjs} +4 -4
- package/dist/bin/{server-HlLriZxF.mjs → server-D4nrvZHH.mjs} +2 -2
- package/dist/bin/{turndown.cjs-C2WBxeA-.mjs → turndown.cjs-CwE2EFNQ.mjs} +15 -10
- package/dist/bin/{types-LcwjLVkt.mjs → types-N9Z-HYP0.mjs} +1 -1
- package/dist/bin/{upgrade-HMRGSqq8.mjs → upgrade-t590zYhO.mjs} +5 -6
- package/package.json +15 -15
- package/src/Agent.test.ts +198 -0
- package/src/Agent.ts +28 -11
- package/src/OutputFormatter.test.ts +158 -0
- package/src/OutputFormatter.ts +56 -1
- package/dist/bin/Effect-5XYMLOiB.mjs +0 -5183
- package/dist/bin/Latch-BnrpWMd1.mjs +0 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { n as makeUnsafe$3, t as make$
|
|
3
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1
|
+
import { $a as tapError$2, $c as sync$1, $u as evaluate, Ac as exitInterrupt$1, Ad as isTagged, Al as lastNonEmpty, B as String$1, Bc as flatMap$3, Bd as identity, Bi as flatMapEager, Bl as headUnsafe, Bo as doneExitFromCause, Di as catch_$2, Dl as isReadonlyArrayNonEmpty, Ea as promise, Ec as callback$2, Fc as fiberInterruptAll, Fi as fail$3, Gi as forever, Gl as isFailure, Go as nextPow2, Gs as close, H as Struct, Ha as scopedWith, Hc as getCurrentFiber, Ho as isDoneCause, Hs as Scope, Hu as some, I as Record, Ic as fiberInterruptAllAs, Id as constVoid, Ii as failCause$3, Iu as isSome, Ja as succeedSome, Jc as scope, Ji as forkIn, Jl as succeed$5, Ka as succeed$3, Kc as onExitPrimitive, Ki as forkChild, Kl as isSuccess$1, L as Redacted, La as runForkWith, Lc as fiberJoin, Ld as constant, Lu as map$4, Mc as exitZipRight, Nc as fiberAwait, Ni as ensuring$2, Nl as of, Oa as provideContext$2, Oi as context, Pc as fiberInterrupt, Pd as constTrue, Pi as exit, Qc as suspend$3, Qi as gen, Ql as format, Qu as causeFail, Ra as runPromiseWith, Rc as fiberRunIn, Rd as dual, Sa as onInterrupt, Sl as fromIterable$1, T as MutableJson, Tc as asSome, Tl as isArrayNonEmpty, Ud as pipeArguments, Ui as fnUntraced, Uo as matchEffect, Us as addFinalizer, Vi as flatten$2, Vl as fail$4, Vo as filterDone, Wi as forEach, Ws as addFinalizerExit, Xa as sync, Xc as succeed$4, Xl as normalize, Xs as provide, Xu as PipeInspectableProto, Ya as suspend$2, Yc as scopeAddFinalizer, Yi as forkScoped, Ys as makeUnsafe$1, Yu as Done, Za as tap$1, Zc as succeedNone, Zl as normalizeNonEmpty, Zo as Done$1, Zu as args, _c as isFailure$1, _i as catchCause$2, aa as logError, ad as withFiber$1, as as die$2, b as Int, ba as onExit$2, bc as void_$2, bd as hasProperty, bn as withConstructorDefault, cc as makeUnsafe$2, ci as andThen, dc as die$4, di as as, dn as optional, do as void_, ea as ignoreCause, ed as exitFail, el as uninterruptibleMask, fc as fail$5, fd as toJson, fo as when, fs as hasInterruptsOnly, g as Error$1, ga as matchCauseEffect, gc as isExit$1, gi as callback$1, gs as isDone, hc as interrupt$1, id as makePrimitive, ii as acquireRelease, it as Unknown, j as NullOr, ja as raceFirst, jc as exitVoid, ji as die$3, jl as map$3, ka as provideService$2, kd as isString$1, ki as contextWith, l as DateTimeUtc, m as Duration, mn as tag, mo as withFiber, ms as isCause, mu as get$1, n as ArraySchema, nd as exitSucceed, nl as void_$1, oo as uninterruptible, os as done, p as Defect, pa as mapError$2, pc as failCause$4, pi as asVoid, po as whileLoop, pu as empty$2, qa as succeedNone$1, qc as onExitUnsafe, qs as forkUnsafe, rc as interruptWith, rd as isExit, ro as tryPromise, rt as Union, ta as interrupt$2, tc as doneUnsafe, td as exitFailCause, ua as map$2, uc as asVoidAll, us as fromReasons, va as never, vc as isSuccess, vo as yieldNow, w as Literals, wc as andThen$1, ws as squash, xa as onExitPrimitive$1, xn as withDecodingDefault, ya as onError, yc as succeed$2, zc as findRecoverableError, zi as flatMap$2, zo as catchDone, zu as none } from "./Schema-BfUmMefy.mjs";
|
|
2
|
+
import { n as makeUnsafe$3, t as make$6 } from "./Latch-B3e9629m.mjs";
|
|
3
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/String.js
|
|
4
4
|
const String = globalThis.String;
|
|
5
5
|
const isString = isString$1;
|
|
6
6
|
const toLowerCase = (self) => self.toLowerCase();
|
|
7
7
|
const camelToSnake = (self) => self.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
8
|
-
// node_modules/.pnpm/effect@4.1.
|
|
8
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Fiber.js
|
|
9
9
|
const await_ = fiberAwait;
|
|
10
10
|
const join = fiberJoin;
|
|
11
11
|
const interrupt = fiberInterrupt;
|
|
@@ -13,17 +13,11 @@ const interruptAll = fiberInterruptAll;
|
|
|
13
13
|
const interruptAllAs = fiberInterruptAllAs;
|
|
14
14
|
const getCurrent = getCurrentFiber;
|
|
15
15
|
const runIn = fiberRunIn;
|
|
16
|
-
// node_modules/.pnpm/effect@4.1.
|
|
17
|
-
const TypeId$
|
|
16
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/MutableRef.js
|
|
17
|
+
const TypeId$6 = "~effect/MutableRef";
|
|
18
18
|
const MutableRefProto = {
|
|
19
|
-
[TypeId$
|
|
19
|
+
[TypeId$6]: TypeId$6,
|
|
20
20
|
...PipeInspectableProto,
|
|
21
|
-
[symbol](that) {
|
|
22
|
-
return this === that;
|
|
23
|
-
},
|
|
24
|
-
[symbol$1]() {
|
|
25
|
-
return random(this);
|
|
26
|
-
},
|
|
27
21
|
toJSON() {
|
|
28
22
|
return {
|
|
29
23
|
_id: "MutableRef",
|
|
@@ -31,7 +25,7 @@ const MutableRefProto = {
|
|
|
31
25
|
};
|
|
32
26
|
}
|
|
33
27
|
};
|
|
34
|
-
const make$
|
|
28
|
+
const make$5 = (value) => {
|
|
35
29
|
const ref = Object.create(MutableRefProto);
|
|
36
30
|
ref.current = value;
|
|
37
31
|
return ref;
|
|
@@ -42,9 +36,9 @@ const set = dual(2, (self, value) => {
|
|
|
42
36
|
return self;
|
|
43
37
|
});
|
|
44
38
|
const update = dual(2, (self, f) => set(self, f(get(self))));
|
|
45
|
-
// node_modules/.pnpm/effect@4.1.
|
|
39
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/MutableList.js
|
|
46
40
|
const Empty = Symbol.for("effect/MutableList/Empty");
|
|
47
|
-
const make$
|
|
41
|
+
const make$4 = () => ({
|
|
48
42
|
head: void 0,
|
|
49
43
|
tail: void 0,
|
|
50
44
|
length: 0
|
|
@@ -131,6 +125,30 @@ const takeN = (self, n) => {
|
|
|
131
125
|
clear(self);
|
|
132
126
|
return array;
|
|
133
127
|
};
|
|
128
|
+
const takeNVoid = (self, n) => {
|
|
129
|
+
n = normalize(n);
|
|
130
|
+
if (n <= 0 || !self.head) return;
|
|
131
|
+
n = Math.min(n, self.length);
|
|
132
|
+
if (n === self.length && self.head?.offset === 0 && !self.head.next) {
|
|
133
|
+
clear(self);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
let count = 0;
|
|
137
|
+
let chunk = self.head;
|
|
138
|
+
while (chunk) {
|
|
139
|
+
const size = chunk.array.length - chunk.offset;
|
|
140
|
+
if (count + size > n) {
|
|
141
|
+
chunk.offset += n - count;
|
|
142
|
+
self.head = chunk;
|
|
143
|
+
self.length -= n;
|
|
144
|
+
compactHead(self);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
count += size;
|
|
148
|
+
chunk = chunk.next;
|
|
149
|
+
}
|
|
150
|
+
clear(self);
|
|
151
|
+
};
|
|
134
152
|
const takeAll$2 = (self) => takeN(self, self.length);
|
|
135
153
|
const take$3 = (self) => {
|
|
136
154
|
if (!self.head) return Empty;
|
|
@@ -165,23 +183,23 @@ const filter$1 = (self, f) => {
|
|
|
165
183
|
self.length = array.length;
|
|
166
184
|
};
|
|
167
185
|
const remove = (self, value) => filter$1(self, (v) => v !== value);
|
|
168
|
-
// node_modules/.pnpm/effect@4.1.
|
|
169
|
-
const TypeId$
|
|
186
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/PubSub.js
|
|
187
|
+
const TypeId$5 = "~effect/PubSub";
|
|
170
188
|
const SubscriptionTypeId = "~effect/PubSub/Subscription";
|
|
171
|
-
const make$
|
|
172
|
-
const bounded$1 = (capacity) => make$
|
|
189
|
+
const make$3 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), new Map(), makeUnsafe$1(), makeUnsafe$3(false), make$5(false), options.strategy(), make$5(none())));
|
|
190
|
+
const bounded$1 = (capacity) => make$3({
|
|
173
191
|
atomicPubSub: () => makeAtomicBounded(capacity),
|
|
174
192
|
strategy: () => new BackPressureStrategy()
|
|
175
193
|
});
|
|
176
|
-
const dropping = (capacity) => make$
|
|
194
|
+
const dropping = (capacity) => make$3({
|
|
177
195
|
atomicPubSub: () => makeAtomicBounded(capacity),
|
|
178
196
|
strategy: () => new DroppingStrategy()
|
|
179
197
|
});
|
|
180
|
-
const sliding$1 = (capacity) => make$
|
|
198
|
+
const sliding$1 = (capacity) => make$3({
|
|
181
199
|
atomicPubSub: () => makeAtomicBounded(capacity),
|
|
182
200
|
strategy: () => new SlidingStrategy()
|
|
183
201
|
});
|
|
184
|
-
const unbounded$1 = (options) => make$
|
|
202
|
+
const unbounded$1 = (options) => make$3({
|
|
185
203
|
atomicPubSub: () => makeAtomicUnbounded(options),
|
|
186
204
|
strategy: () => new DroppingStrategy()
|
|
187
205
|
});
|
|
@@ -306,7 +324,7 @@ const removeSubscribers = (subscribers, subscription, pollers) => {
|
|
|
306
324
|
set.delete(pollers);
|
|
307
325
|
if (set.size === 0) subscribers.delete(subscription);
|
|
308
326
|
};
|
|
309
|
-
const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$
|
|
327
|
+
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
328
|
var BoundedPubSubArb = class {
|
|
311
329
|
array;
|
|
312
330
|
replayIndices;
|
|
@@ -880,7 +898,7 @@ var SubscriptionImpl = class {
|
|
|
880
898
|
}
|
|
881
899
|
};
|
|
882
900
|
var PubSubImpl = class {
|
|
883
|
-
[TypeId$
|
|
901
|
+
[TypeId$5] = { _A: identity };
|
|
884
902
|
pubsub;
|
|
885
903
|
subscribers;
|
|
886
904
|
scope;
|
|
@@ -906,7 +924,7 @@ const ensureCapacity = (capacity) => {
|
|
|
906
924
|
if (capacity <= 0 || capacity !== Infinity && !Number.isInteger(capacity)) throw new Error(`Cannot construct PubSub with capacity of ${capacity}`);
|
|
907
925
|
};
|
|
908
926
|
var BackPressureStrategy = class {
|
|
909
|
-
publishers = make$
|
|
927
|
+
publishers = make$4();
|
|
910
928
|
get shutdown() {
|
|
911
929
|
return withFiber((fiber) => forEach(takeAll$2(this.publishers), ([_, deferred, last]) => last ? interruptWith(deferred, fiber.id) : void_, {
|
|
912
930
|
concurrency: "unbounded",
|
|
@@ -1154,8 +1172,8 @@ const emptyReplayWindow = {
|
|
|
1154
1172
|
takeAll: () => [],
|
|
1155
1173
|
close: () => void 0
|
|
1156
1174
|
};
|
|
1157
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1158
|
-
const TypeId$
|
|
1175
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Queue.js
|
|
1176
|
+
const TypeId$4 = "~effect/Queue";
|
|
1159
1177
|
const EnqueueTypeId = "~effect/Queue/Enqueue";
|
|
1160
1178
|
const DequeueTypeId = "~effect/Queue/Dequeue";
|
|
1161
1179
|
const variance = {
|
|
@@ -1163,7 +1181,7 @@ const variance = {
|
|
|
1163
1181
|
_E: identity
|
|
1164
1182
|
};
|
|
1165
1183
|
const QueueProto = {
|
|
1166
|
-
[TypeId$
|
|
1184
|
+
[TypeId$4]: variance,
|
|
1167
1185
|
[EnqueueTypeId]: variance,
|
|
1168
1186
|
[DequeueTypeId]: variance,
|
|
1169
1187
|
...PipeInspectableProto,
|
|
@@ -1175,12 +1193,12 @@ const QueueProto = {
|
|
|
1175
1193
|
};
|
|
1176
1194
|
}
|
|
1177
1195
|
};
|
|
1178
|
-
const make$
|
|
1196
|
+
const make$2 = (options) => withFiber$1((fiber) => {
|
|
1179
1197
|
const self = Object.create(QueueProto);
|
|
1180
1198
|
self.dispatcher = fiber.currentDispatcher;
|
|
1181
1199
|
self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY;
|
|
1182
1200
|
self.strategy = options?.strategy ?? "suspend";
|
|
1183
|
-
self.messages = make$
|
|
1201
|
+
self.messages = make$4();
|
|
1184
1202
|
self.scheduleRunning = false;
|
|
1185
1203
|
self.state = {
|
|
1186
1204
|
_tag: "Open",
|
|
@@ -1190,24 +1208,27 @@ const make$1 = (options) => withFiber$1((fiber) => {
|
|
|
1190
1208
|
};
|
|
1191
1209
|
return succeed$4(self);
|
|
1192
1210
|
});
|
|
1193
|
-
const bounded = (capacity) => make$
|
|
1194
|
-
const sliding = (capacity) => make$
|
|
1211
|
+
const bounded = (capacity) => make$2({ capacity });
|
|
1212
|
+
const sliding = (capacity) => make$2({
|
|
1195
1213
|
capacity,
|
|
1196
1214
|
strategy: "sliding"
|
|
1197
1215
|
});
|
|
1198
|
-
const unbounded = () => make$
|
|
1216
|
+
const unbounded = () => make$2();
|
|
1199
1217
|
const offer = dual(2, (self, message) => suspend$3(() => offerUnsafe(self, message) ? exitTrue : self.state._tag === "Open" && self.strategy === "suspend" ? offerOrWait(self, message) : exitFalse));
|
|
1200
1218
|
const offerUnsafe = (self, message) => {
|
|
1201
1219
|
if (self.state._tag !== "Open") return false;
|
|
1202
1220
|
else if (self.messages.length >= self.capacity) {
|
|
1203
|
-
if (self.strategy === "sliding") {
|
|
1204
|
-
take$3(self.messages);
|
|
1205
|
-
append(self.messages, message);
|
|
1206
|
-
return true;
|
|
1207
|
-
} else if (self.capacity <= 0 && self.state.takers.size > 0) {
|
|
1221
|
+
if (self.capacity <= 0 && self.state.takers.size > (self.strategy === "sliding" ? 0 : self.messages.length)) {
|
|
1208
1222
|
append(self.messages, message);
|
|
1223
|
+
if (self.strategy === "sliding") takeNVoid(self.messages, self.messages.length - self.state.takers.size);
|
|
1209
1224
|
releaseTakers(self);
|
|
1210
1225
|
return true;
|
|
1226
|
+
} else if (self.strategy === "sliding") {
|
|
1227
|
+
if (self.capacity > 0) {
|
|
1228
|
+
take$3(self.messages);
|
|
1229
|
+
append(self.messages, message);
|
|
1230
|
+
}
|
|
1231
|
+
return true;
|
|
1211
1232
|
}
|
|
1212
1233
|
return false;
|
|
1213
1234
|
}
|
|
@@ -1229,12 +1250,15 @@ const offerAllUnsafe = (self, messages) => {
|
|
|
1229
1250
|
if (self.state._tag !== "Open") return fromIterable$1(messages);
|
|
1230
1251
|
else if (self.capacity === Number.POSITIVE_INFINITY || self.strategy === "sliding") {
|
|
1231
1252
|
appendAll(self.messages, messages);
|
|
1232
|
-
if (self.strategy === "sliding")
|
|
1253
|
+
if (self.strategy === "sliding") {
|
|
1254
|
+
const capacity = self.capacity <= 0 ? self.state.takers.size : self.capacity;
|
|
1255
|
+
takeNVoid(self.messages, self.messages.length - capacity);
|
|
1256
|
+
}
|
|
1233
1257
|
scheduleReleaseTaker(self);
|
|
1234
1258
|
return [];
|
|
1235
1259
|
}
|
|
1236
|
-
const free = self.capacity <= 0 ? self.state.takers.size : self.capacity - self.messages.length;
|
|
1237
|
-
if (free
|
|
1260
|
+
const free = (self.capacity <= 0 ? self.state.takers.size : self.capacity) - self.messages.length;
|
|
1261
|
+
if (free <= 0) return fromIterable$1(messages);
|
|
1238
1262
|
const remaining = [];
|
|
1239
1263
|
let i = 0;
|
|
1240
1264
|
for (const message of messages) {
|
|
@@ -1421,7 +1445,7 @@ const finalize = (self, exit) => {
|
|
|
1421
1445
|
for (const awaiter of openState.awaiters) awaiter(exit);
|
|
1422
1446
|
openState.awaiters.clear();
|
|
1423
1447
|
};
|
|
1424
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1448
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Semaphore.js
|
|
1425
1449
|
const makeUnsafe = (permits) => new SemaphoreImpl(permits);
|
|
1426
1450
|
const firstAvailableWaiter = (self) => {
|
|
1427
1451
|
for (const waiter of self.waiters) if (waiter.permits <= self.free) return waiter;
|
|
@@ -1519,14 +1543,14 @@ var SemaphoreImpl = class {
|
|
|
1519
1543
|
});
|
|
1520
1544
|
}
|
|
1521
1545
|
};
|
|
1522
|
-
const make = (permits) => sync$1(() => new SemaphoreImpl(permits));
|
|
1523
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1546
|
+
const make$1 = (permits) => sync$1(() => new SemaphoreImpl(permits));
|
|
1547
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Take.js
|
|
1524
1548
|
const toPull = (take) => isExit$1(take) ? isSuccess(take) ? done(take.value) : take : succeed$3(take);
|
|
1525
|
-
// node_modules/.pnpm/effect@4.1.
|
|
1526
|
-
const TypeId$
|
|
1527
|
-
const isChannel = (u) => hasProperty(u, TypeId$
|
|
1549
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Channel.js
|
|
1550
|
+
const TypeId$3 = "~effect/Channel";
|
|
1551
|
+
const isChannel = (u) => hasProperty(u, TypeId$3);
|
|
1528
1552
|
const ChannelProto = {
|
|
1529
|
-
[TypeId$
|
|
1553
|
+
[TypeId$3]: {
|
|
1530
1554
|
_Env: identity,
|
|
1531
1555
|
_InErr: identity,
|
|
1532
1556
|
_InElem: identity,
|
|
@@ -1552,7 +1576,7 @@ const fromTransformBracket = (f) => fromTransform(fnUntraced(function* (upstream
|
|
|
1552
1576
|
}));
|
|
1553
1577
|
const toTransform = (channel) => channel.transform;
|
|
1554
1578
|
const DefaultChunkSize = 4096;
|
|
1555
|
-
const asyncQueue = (scope, f, options) => make$
|
|
1579
|
+
const asyncQueue = (scope, f, options) => make$2({
|
|
1556
1580
|
capacity: options?.bufferSize,
|
|
1557
1581
|
strategy: options?.strategy
|
|
1558
1582
|
}).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 }))));
|
|
@@ -1569,15 +1593,15 @@ const fromIteratorArray = (iterator, chunkSize = DefaultChunkSize) => {
|
|
|
1569
1593
|
const size = normalizeNonEmpty(chunkSize);
|
|
1570
1594
|
return fromPull$1(sync(() => {
|
|
1571
1595
|
const iter = iterator();
|
|
1572
|
-
let done$
|
|
1596
|
+
let done$8 = none();
|
|
1573
1597
|
return suspend$2(() => {
|
|
1574
|
-
if (done$
|
|
1598
|
+
if (done$8._tag === "Some") return done(done$8.value);
|
|
1575
1599
|
const buffer = [];
|
|
1576
1600
|
while (buffer.length < size) {
|
|
1577
1601
|
const state = iter.next();
|
|
1578
1602
|
if (state.done) {
|
|
1579
1603
|
if (buffer.length === 0) return done(state.value);
|
|
1580
|
-
done$
|
|
1604
|
+
done$8 = some(state.value);
|
|
1581
1605
|
break;
|
|
1582
1606
|
}
|
|
1583
1607
|
buffer.push(state.value);
|
|
@@ -1593,10 +1617,10 @@ const fail$1 = (error) => fromPull$1(succeed$3(fail$3(error)));
|
|
|
1593
1617
|
const failCause$1 = (cause) => fromPull$1(failCause$3(cause));
|
|
1594
1618
|
const die$1 = (defect) => failCause$1(die$2(defect));
|
|
1595
1619
|
const fromEffect$1 = (effect) => fromPull$1(sync(() => {
|
|
1596
|
-
let done$
|
|
1620
|
+
let done$9 = false;
|
|
1597
1621
|
return suspend$2(() => {
|
|
1598
|
-
if (done$
|
|
1599
|
-
done$
|
|
1622
|
+
if (done$9) return done();
|
|
1623
|
+
done$9 = true;
|
|
1600
1624
|
return effect;
|
|
1601
1625
|
});
|
|
1602
1626
|
}));
|
|
@@ -1614,7 +1638,7 @@ const fromReadableStream$1 = (options) => fromTransform((_, scope) => readableSt
|
|
|
1614
1638
|
}));
|
|
1615
1639
|
const readableStreamToPullUnsafe = (options) => {
|
|
1616
1640
|
const reader = options.readable.getReader();
|
|
1617
|
-
const exit = options.exit ?? make$
|
|
1641
|
+
const exit = options.exit ?? make$5(void 0);
|
|
1618
1642
|
const pull = suspend$2(() => {
|
|
1619
1643
|
if (exit.current) return exit.current;
|
|
1620
1644
|
return matchCauseEffect(tryPromise({
|
|
@@ -1622,9 +1646,9 @@ const readableStreamToPullUnsafe = (options) => {
|
|
|
1622
1646
|
catch: options.onError
|
|
1623
1647
|
}), {
|
|
1624
1648
|
onFailure: (cause) => exit.current ?? failCause$3(cause),
|
|
1625
|
-
onSuccess: ({ done: done$
|
|
1649
|
+
onSuccess: ({ done: done$11, value }) => {
|
|
1626
1650
|
if (exit.current) return exit.current;
|
|
1627
|
-
return done$
|
|
1651
|
+
return done$11 ? done() : succeed$3(of(value));
|
|
1628
1652
|
}
|
|
1629
1653
|
});
|
|
1630
1654
|
});
|
|
@@ -1651,7 +1675,7 @@ const map$1 = dual(2, (self, f) => transformPull$1(self, (pull) => sync(() => {
|
|
|
1651
1675
|
return map$2(pull, (o) => f(o, i++));
|
|
1652
1676
|
})));
|
|
1653
1677
|
const mapDone = dual(2, (self, f) => mapDoneEffect(self, (o) => succeed$3(f(o))));
|
|
1654
|
-
const mapDoneEffect = dual(2, (self, f) => transformPull$1(self, (pull) => succeed$3(catchDone(pull, (done$
|
|
1678
|
+
const mapDoneEffect = dual(2, (self, f) => transformPull$1(self, (pull) => succeed$3(catchDone(pull, (done$12) => flatMap$2(f(done$12), done)))));
|
|
1655
1679
|
const concurrencyIsSequential = (concurrency) => concurrency === void 0 || concurrency !== "unbounded" && concurrency <= 1;
|
|
1656
1680
|
const mapEffect$1 = dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? mapEffectSequential(self, f) : mapEffectConcurrent(self, f, options));
|
|
1657
1681
|
const mapEffectSequential = (self, f) => fromTransform((upstream, scope) => {
|
|
@@ -1797,7 +1821,7 @@ const orDie$1 = (self) => catch_$1(self, die$1);
|
|
|
1797
1821
|
const mergeAll$1 = dual(2, (channels, { bufferSize = 16, concurrency, switch: switch_ = false }) => fromTransformBracket(fnUntraced(function* (upstream, scope, forkedScope) {
|
|
1798
1822
|
const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency);
|
|
1799
1823
|
const semaphore = switch_ ? void 0 : makeUnsafe(concurrencyN);
|
|
1800
|
-
const doneLatch = yield* make$
|
|
1824
|
+
const doneLatch = yield* make$6(true);
|
|
1801
1825
|
const fibers = new Map();
|
|
1802
1826
|
const queue = yield* bounded(bufferSize);
|
|
1803
1827
|
yield* addFinalizer(forkedScope, shutdown(queue));
|
|
@@ -1869,7 +1893,7 @@ const mergeEffect$1 = dual(2, (self, effect) => merge$1(self, fromEffectDrain(ef
|
|
|
1869
1893
|
const splitLines$1 = () => fromTransform((upstream, _scope) => sync(() => {
|
|
1870
1894
|
let stringBuilder = "";
|
|
1871
1895
|
let midCRLF = false;
|
|
1872
|
-
let done$
|
|
1896
|
+
let done$10 = none();
|
|
1873
1897
|
function splitLinesArray(chunk) {
|
|
1874
1898
|
const chunkBuilder = [];
|
|
1875
1899
|
function pushLine(segment) {
|
|
@@ -1914,12 +1938,12 @@ const splitLines$1 = () => fromTransform((upstream, _scope) => sync(() => {
|
|
|
1914
1938
|
return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null;
|
|
1915
1939
|
}
|
|
1916
1940
|
const pullOrFlush = suspend$2(() => {
|
|
1917
|
-
if (done$
|
|
1941
|
+
if (done$10._tag === "Some") return done(done$10.value);
|
|
1918
1942
|
return matchEffect(upstream, {
|
|
1919
1943
|
onSuccess: loop,
|
|
1920
1944
|
onFailure: failCause$3,
|
|
1921
1945
|
onDone: (leftover) => {
|
|
1922
|
-
done$
|
|
1946
|
+
done$10 = some(leftover);
|
|
1923
1947
|
if (stringBuilder.length > 0) {
|
|
1924
1948
|
const last = stringBuilder;
|
|
1925
1949
|
stringBuilder = "";
|
|
@@ -1997,8 +2021,8 @@ const toPubSubTake$1 = dual(2, fnUntraced(function* (self, options) {
|
|
|
1997
2021
|
yield* runForEach$1(self, (value) => publish(pubsub, value)).pipe(onExit$2((exit) => end$1(pubsub, exit)), forkScoped);
|
|
1998
2022
|
return pubsub;
|
|
1999
2023
|
}));
|
|
2000
|
-
// node_modules/.pnpm/effect@4.1.
|
|
2001
|
-
const TypeId$
|
|
2024
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/internal/stream.js
|
|
2025
|
+
const TypeId$2 = "~effect/Stream";
|
|
2002
2026
|
const streamVariance = {
|
|
2003
2027
|
_R: identity,
|
|
2004
2028
|
_E: identity,
|
|
@@ -2008,15 +2032,15 @@ const Stream = function(channel) {
|
|
|
2008
2032
|
this.channel = channel;
|
|
2009
2033
|
};
|
|
2010
2034
|
Stream.prototype = {
|
|
2011
|
-
[TypeId$
|
|
2035
|
+
[TypeId$2]: streamVariance,
|
|
2012
2036
|
pipe() {
|
|
2013
2037
|
return pipeArguments(this, arguments);
|
|
2014
2038
|
}
|
|
2015
2039
|
};
|
|
2016
2040
|
const fromChannel$1 = (channel) => new Stream(channel);
|
|
2017
|
-
// node_modules/.pnpm/effect@4.1.
|
|
2018
|
-
const TypeId = "~effect/Stream";
|
|
2019
|
-
const isStream = (u) => hasProperty(u, TypeId);
|
|
2041
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Stream.js
|
|
2042
|
+
const TypeId$1 = "~effect/Stream";
|
|
2043
|
+
const isStream = (u) => hasProperty(u, TypeId$1);
|
|
2020
2044
|
const fromChannel = fromChannel$1;
|
|
2021
2045
|
const fromEffect = (effect) => fromChannel(fromEffect$1(map$2(effect, of)));
|
|
2022
2046
|
const fromPull = (pull) => fromChannel(fromPull$1(pull));
|
|
@@ -2153,7 +2177,7 @@ const drop = dual(2, (self, n) => {
|
|
|
2153
2177
|
}));
|
|
2154
2178
|
});
|
|
2155
2179
|
const transduce = dual(2, (self, sink) => transformPull(self, (upstream, scope) => sync(() => {
|
|
2156
|
-
let done$
|
|
2180
|
+
let done$3;
|
|
2157
2181
|
let leftover;
|
|
2158
2182
|
const upstreamWithLeftover = suspend$2(() => {
|
|
2159
2183
|
if (leftover !== void 0) {
|
|
@@ -2163,14 +2187,14 @@ const transduce = dual(2, (self, sink) => transformPull(self, (upstream, scope)
|
|
|
2163
2187
|
}
|
|
2164
2188
|
return upstream;
|
|
2165
2189
|
}).pipe(catch_$2((error) => {
|
|
2166
|
-
done$
|
|
2190
|
+
done$3 = fail$5(error);
|
|
2167
2191
|
return done();
|
|
2168
2192
|
}));
|
|
2169
2193
|
const pull = map$2(suspend$2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => {
|
|
2170
2194
|
leftover = leftover_;
|
|
2171
2195
|
return of(value);
|
|
2172
2196
|
});
|
|
2173
|
-
return suspend$2(() => done$
|
|
2197
|
+
return suspend$2(() => done$3 ? done$3 : pull);
|
|
2174
2198
|
})));
|
|
2175
2199
|
const broadcast = dual(2, (self, options) => map$2(toPubSubTake(self, options), fromPubSubTake));
|
|
2176
2200
|
const pipeThroughChannel = dual(2, (self, channel) => fromChannel(pipeTo(self.channel, channel)));
|
|
@@ -2261,4 +2285,439 @@ const toAsyncIterableWith = dual(2, (self, context) => ({ [Symbol.asyncIterator]
|
|
|
2261
2285
|
const toAsyncIterable = (self) => toAsyncIterableWith(self, empty$2());
|
|
2262
2286
|
const runIntoPubSub = dual((args) => isStream(args[0]), (self, pubsub, options) => runIntoPubSubArray(self.channel, pubsub, options));
|
|
2263
2287
|
const toPubSubTake = dual(2, (self, options) => toPubSubTake$1(self.channel, options));
|
|
2264
|
-
|
|
2288
|
+
// node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/ai/AiError.js
|
|
2289
|
+
const HttpResponseDetails = Struct({
|
|
2290
|
+
status: Int,
|
|
2291
|
+
headers: Record(String$1, Union([String$1, Redacted(String$1)]))
|
|
2292
|
+
}).annotate({ identifier: "HttpResponseDetails" });
|
|
2293
|
+
const ReasonTypeId = "~effect/ai/AiError/Reason";
|
|
2294
|
+
const providerMetadataWithDefaults = () => ProviderMetadata.pipe(withConstructorDefault(succeed$3({})), withDecodingDefault(succeed$3({})));
|
|
2295
|
+
var NetworkError = class NetworkError extends Error$1("effect/ai/AiError/NetworkError")({
|
|
2296
|
+
_tag: tag("NetworkError"),
|
|
2297
|
+
reason: Literals([
|
|
2298
|
+
"TransportError",
|
|
2299
|
+
"EncodeError",
|
|
2300
|
+
"InvalidUrlError"
|
|
2301
|
+
]),
|
|
2302
|
+
method: String$1,
|
|
2303
|
+
url: String$1,
|
|
2304
|
+
description: optional(String$1),
|
|
2305
|
+
cause: optional(Defect())
|
|
2306
|
+
}) {
|
|
2307
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2308
|
+
get isRetryable() {
|
|
2309
|
+
return this.reason === "TransportError";
|
|
2310
|
+
}
|
|
2311
|
+
static fromRequestError(error) {
|
|
2312
|
+
return new NetworkError({
|
|
2313
|
+
description: error.description,
|
|
2314
|
+
reason: error._tag,
|
|
2315
|
+
method: error.request.method,
|
|
2316
|
+
url: error.request.url
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
static fromHttpClientError(error) {
|
|
2320
|
+
return new NetworkError({
|
|
2321
|
+
description: error.reason.description,
|
|
2322
|
+
reason: error.reason._tag,
|
|
2323
|
+
method: error.reason.request.method,
|
|
2324
|
+
url: error.reason.request.url,
|
|
2325
|
+
cause: error
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
get message() {
|
|
2329
|
+
const methodAndUrl = `${this.method} ${this.url}`;
|
|
2330
|
+
let baseMessage = this.description ? `${this.reason}: ${this.description}` : `${this.reason}: A network error occurred.`;
|
|
2331
|
+
baseMessage += ` (${methodAndUrl})`;
|
|
2332
|
+
let suggestion = "";
|
|
2333
|
+
switch (this.reason) {
|
|
2334
|
+
case "EncodeError":
|
|
2335
|
+
suggestion += "Check that the request body data is properly formatted and matches the expected content type.";
|
|
2336
|
+
break;
|
|
2337
|
+
case "InvalidUrlError":
|
|
2338
|
+
suggestion += "Verify that the URL format is correct and that all required parameters have been provided.";
|
|
2339
|
+
suggestion += " Check for any special characters that may need encoding.";
|
|
2340
|
+
break;
|
|
2341
|
+
case "TransportError": suggestion += "Check your network connection and verify that the requested URL is accessible.";
|
|
2342
|
+
}
|
|
2343
|
+
baseMessage += `\n\n${suggestion}`;
|
|
2344
|
+
return baseMessage;
|
|
2345
|
+
}
|
|
2346
|
+
};
|
|
2347
|
+
const ProviderMetadata = Record(String$1, NullOr(MutableJson));
|
|
2348
|
+
const UsageInfo = Struct({
|
|
2349
|
+
promptTokens: optional(Int),
|
|
2350
|
+
completionTokens: optional(Int),
|
|
2351
|
+
totalTokens: optional(Int)
|
|
2352
|
+
}).annotate({ identifier: "UsageInfo" });
|
|
2353
|
+
const HttpContext = Struct({
|
|
2354
|
+
response: optional(HttpResponseDetails),
|
|
2355
|
+
body: optional(String$1)
|
|
2356
|
+
}).annotate({ identifier: "HttpContext" });
|
|
2357
|
+
const buildErrorDescription = (params) => {
|
|
2358
|
+
const parts = [];
|
|
2359
|
+
if (params.message) parts.push(params.message);
|
|
2360
|
+
else parts.push(`HTTP ${params.status}`);
|
|
2361
|
+
parts.push(`(${params.method} ${params.url})`);
|
|
2362
|
+
if (params.errorCode) parts.push(`[code: ${params.errorCode}]`);
|
|
2363
|
+
else if (params.errorType) parts.push(`[type: ${params.errorType}]`);
|
|
2364
|
+
if (params.requestId) parts.push(`[requestId: ${params.requestId}]`);
|
|
2365
|
+
if (!params.message && params.body) {
|
|
2366
|
+
const truncated = params.body.length > 200 ? params.body.slice(0, 200) + "..." : params.body;
|
|
2367
|
+
parts.push(`Response: ${truncated}`);
|
|
2368
|
+
}
|
|
2369
|
+
return parts.join(" ");
|
|
2370
|
+
};
|
|
2371
|
+
var RateLimitError = class extends Error$1("effect/ai/AiError/RateLimitError")({
|
|
2372
|
+
_tag: tag("RateLimitError"),
|
|
2373
|
+
retryAfter: optional(Duration),
|
|
2374
|
+
metadata: providerMetadataWithDefaults(),
|
|
2375
|
+
http: optional(HttpContext)
|
|
2376
|
+
}) {
|
|
2377
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2378
|
+
get isRetryable() {
|
|
2379
|
+
return true;
|
|
2380
|
+
}
|
|
2381
|
+
get message() {
|
|
2382
|
+
let msg = "Rate limit exceeded";
|
|
2383
|
+
if (this.retryAfter) msg += `. Retry after ${format(this.retryAfter)}`;
|
|
2384
|
+
return msg;
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
var QuotaExhaustedError = class extends Error$1("effect/ai/AiError/QuotaExhaustedError")({
|
|
2388
|
+
_tag: tag("QuotaExhaustedError"),
|
|
2389
|
+
resetAt: optional(DateTimeUtc),
|
|
2390
|
+
metadata: providerMetadataWithDefaults(),
|
|
2391
|
+
http: optional(HttpContext)
|
|
2392
|
+
}) {
|
|
2393
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2394
|
+
get isRetryable() {
|
|
2395
|
+
return false;
|
|
2396
|
+
}
|
|
2397
|
+
get message() {
|
|
2398
|
+
let msg = "Quota exhausted";
|
|
2399
|
+
if (this.resetAt) msg += `. Resets at ${this.resetAt}`;
|
|
2400
|
+
return `${msg}. Check your account billing and usage limits.`;
|
|
2401
|
+
}
|
|
2402
|
+
};
|
|
2403
|
+
var AuthenticationError = class extends Error$1("effect/ai/AiError/AuthenticationError")({
|
|
2404
|
+
_tag: tag("AuthenticationError"),
|
|
2405
|
+
kind: Literals([
|
|
2406
|
+
"InvalidKey",
|
|
2407
|
+
"ExpiredKey",
|
|
2408
|
+
"MissingKey",
|
|
2409
|
+
"InsufficientPermissions",
|
|
2410
|
+
"Unknown"
|
|
2411
|
+
]),
|
|
2412
|
+
description: optional(String$1),
|
|
2413
|
+
metadata: providerMetadataWithDefaults(),
|
|
2414
|
+
http: optional(HttpContext)
|
|
2415
|
+
}) {
|
|
2416
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2417
|
+
get isRetryable() {
|
|
2418
|
+
return false;
|
|
2419
|
+
}
|
|
2420
|
+
get message() {
|
|
2421
|
+
let msg = `${this.kind}: ${{
|
|
2422
|
+
InvalidKey: "Verify your API key is correct",
|
|
2423
|
+
ExpiredKey: "Your API key has expired. Generate a new one",
|
|
2424
|
+
MissingKey: "No API key provided. Set the appropriate environment variable",
|
|
2425
|
+
InsufficientPermissions: "Your API key lacks required permissions",
|
|
2426
|
+
Unknown: "Authentication failed. Check your credentials"
|
|
2427
|
+
}[this.kind]}`;
|
|
2428
|
+
if (this.description) msg += `. ${this.description}`;
|
|
2429
|
+
return msg;
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
var ContentPolicyError = class extends Error$1("effect/ai/AiError/ContentPolicyError")({
|
|
2433
|
+
_tag: tag("ContentPolicyError"),
|
|
2434
|
+
description: String$1,
|
|
2435
|
+
metadata: providerMetadataWithDefaults(),
|
|
2436
|
+
http: optional(HttpContext)
|
|
2437
|
+
}) {
|
|
2438
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2439
|
+
get isRetryable() {
|
|
2440
|
+
return false;
|
|
2441
|
+
}
|
|
2442
|
+
get message() {
|
|
2443
|
+
return `Content policy violation: ${this.description}`;
|
|
2444
|
+
}
|
|
2445
|
+
};
|
|
2446
|
+
var InvalidRequestError = class extends Error$1("effect/ai/AiError/InvalidRequestError")({
|
|
2447
|
+
_tag: tag("InvalidRequestError"),
|
|
2448
|
+
parameter: optional(String$1),
|
|
2449
|
+
constraint: optional(String$1),
|
|
2450
|
+
description: optional(String$1),
|
|
2451
|
+
metadata: providerMetadataWithDefaults(),
|
|
2452
|
+
http: optional(HttpContext)
|
|
2453
|
+
}) {
|
|
2454
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2455
|
+
get isRetryable() {
|
|
2456
|
+
return false;
|
|
2457
|
+
}
|
|
2458
|
+
get message() {
|
|
2459
|
+
let msg = "Invalid request";
|
|
2460
|
+
if (this.parameter) msg += `: parameter '${this.parameter}'`;
|
|
2461
|
+
if (this.constraint) msg += ` ${this.constraint}`;
|
|
2462
|
+
if (this.description) msg += `. ${this.description}`;
|
|
2463
|
+
return msg;
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
var InternalProviderError = class extends Error$1("effect/ai/AiError/InternalProviderError")({
|
|
2467
|
+
_tag: tag("InternalProviderError"),
|
|
2468
|
+
description: String$1,
|
|
2469
|
+
metadata: providerMetadataWithDefaults(),
|
|
2470
|
+
http: optional(HttpContext)
|
|
2471
|
+
}) {
|
|
2472
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2473
|
+
get isRetryable() {
|
|
2474
|
+
return true;
|
|
2475
|
+
}
|
|
2476
|
+
get message() {
|
|
2477
|
+
return `Internal provider error: ${this.description}`;
|
|
2478
|
+
}
|
|
2479
|
+
};
|
|
2480
|
+
var InvalidResponseError = class InvalidResponseError extends Error$1("effect/ai/AiError/InvalidResponseError")({
|
|
2481
|
+
_tag: tag("InvalidResponseError"),
|
|
2482
|
+
description: String$1,
|
|
2483
|
+
metadata: providerMetadataWithDefaults(),
|
|
2484
|
+
http: optional(HttpContext)
|
|
2485
|
+
}) {
|
|
2486
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2487
|
+
get isRetryable() {
|
|
2488
|
+
return false;
|
|
2489
|
+
}
|
|
2490
|
+
static fromSchemaError(error) {
|
|
2491
|
+
return new InvalidResponseError({ description: error.message });
|
|
2492
|
+
}
|
|
2493
|
+
get message() {
|
|
2494
|
+
return `Invalid response: ${this.description}`;
|
|
2495
|
+
}
|
|
2496
|
+
};
|
|
2497
|
+
var InvalidOutputError = class InvalidOutputError extends Error$1("effect/ai/AiError/InvalidOutputError")({
|
|
2498
|
+
_tag: tag("InvalidOutputError"),
|
|
2499
|
+
description: String$1,
|
|
2500
|
+
metadata: providerMetadataWithDefaults(),
|
|
2501
|
+
usage: optional(UsageInfo)
|
|
2502
|
+
}) {
|
|
2503
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2504
|
+
get isRetryable() {
|
|
2505
|
+
return true;
|
|
2506
|
+
}
|
|
2507
|
+
static fromSchemaError(error) {
|
|
2508
|
+
return new InvalidOutputError({ description: error.message });
|
|
2509
|
+
}
|
|
2510
|
+
get message() {
|
|
2511
|
+
return `Invalid output: ${this.description}`;
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
var StructuredOutputError = class StructuredOutputError extends Error$1("effect/ai/AiError/StructuredOutputError")({
|
|
2515
|
+
_tag: tag("StructuredOutputError"),
|
|
2516
|
+
description: String$1,
|
|
2517
|
+
responseText: String$1,
|
|
2518
|
+
metadata: providerMetadataWithDefaults(),
|
|
2519
|
+
usage: optional(UsageInfo)
|
|
2520
|
+
}) {
|
|
2521
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2522
|
+
get isRetryable() {
|
|
2523
|
+
return true;
|
|
2524
|
+
}
|
|
2525
|
+
static fromSchemaError(error, responseText) {
|
|
2526
|
+
return new StructuredOutputError({
|
|
2527
|
+
description: error.message,
|
|
2528
|
+
responseText
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
get message() {
|
|
2532
|
+
return `Structured output validation failed: ${this.description}`;
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
var UnsupportedSchemaError = class extends Error$1("effect/ai/AiError/UnsupportedSchemaError")({
|
|
2536
|
+
_tag: tag("UnsupportedSchemaError"),
|
|
2537
|
+
description: String$1,
|
|
2538
|
+
metadata: providerMetadataWithDefaults()
|
|
2539
|
+
}) {
|
|
2540
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2541
|
+
get isRetryable() {
|
|
2542
|
+
return false;
|
|
2543
|
+
}
|
|
2544
|
+
get message() {
|
|
2545
|
+
return `Unsupported schema: ${this.description}`;
|
|
2546
|
+
}
|
|
2547
|
+
};
|
|
2548
|
+
var UnknownError = class extends Error$1("effect/ai/AiError/UnknownError")({
|
|
2549
|
+
_tag: tag("UnknownError"),
|
|
2550
|
+
description: optional(String$1),
|
|
2551
|
+
metadata: providerMetadataWithDefaults(),
|
|
2552
|
+
http: optional(HttpContext)
|
|
2553
|
+
}) {
|
|
2554
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2555
|
+
get isRetryable() {
|
|
2556
|
+
return false;
|
|
2557
|
+
}
|
|
2558
|
+
get message() {
|
|
2559
|
+
return this.description ?? "Unknown error";
|
|
2560
|
+
}
|
|
2561
|
+
};
|
|
2562
|
+
var ToolNotFoundError = class extends Error$1("effect/ai/AiError/ToolNotFoundError")({
|
|
2563
|
+
_tag: tag("ToolNotFoundError"),
|
|
2564
|
+
toolName: String$1,
|
|
2565
|
+
availableTools: ArraySchema(String$1)
|
|
2566
|
+
}) {
|
|
2567
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2568
|
+
get isRetryable() {
|
|
2569
|
+
return true;
|
|
2570
|
+
}
|
|
2571
|
+
get message() {
|
|
2572
|
+
const availableTools = this.availableTools.length > 0 ? this.availableTools.join(", ") : "none";
|
|
2573
|
+
return `Tool '${this.toolName}' not found. Available tools: ${availableTools}`;
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
var ToolParameterValidationError = class extends Error$1("effect/ai/AiError/ToolParameterValidationError")({
|
|
2577
|
+
_tag: tag("ToolParameterValidationError"),
|
|
2578
|
+
toolName: String$1,
|
|
2579
|
+
description: String$1
|
|
2580
|
+
}) {
|
|
2581
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2582
|
+
get isRetryable() {
|
|
2583
|
+
return true;
|
|
2584
|
+
}
|
|
2585
|
+
get message() {
|
|
2586
|
+
return `Invalid parameters for tool '${this.toolName}': ${this.description}`;
|
|
2587
|
+
}
|
|
2588
|
+
};
|
|
2589
|
+
var InvalidToolResultError = class extends Error$1("effect/ai/AiError/InvalidToolResultError")({
|
|
2590
|
+
_tag: tag("InvalidToolResultError"),
|
|
2591
|
+
toolName: String$1,
|
|
2592
|
+
description: String$1
|
|
2593
|
+
}) {
|
|
2594
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2595
|
+
get isRetryable() {
|
|
2596
|
+
return false;
|
|
2597
|
+
}
|
|
2598
|
+
get message() {
|
|
2599
|
+
return `Tool '${this.toolName}' returned invalid result: ${this.description}`;
|
|
2600
|
+
}
|
|
2601
|
+
};
|
|
2602
|
+
var ToolResultEncodingError = class extends Error$1("effect/ai/AiError/ToolResultEncodingError")({
|
|
2603
|
+
_tag: tag("ToolResultEncodingError"),
|
|
2604
|
+
toolName: String$1,
|
|
2605
|
+
toolResult: Unknown,
|
|
2606
|
+
description: String$1
|
|
2607
|
+
}) {
|
|
2608
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2609
|
+
get isRetryable() {
|
|
2610
|
+
return false;
|
|
2611
|
+
}
|
|
2612
|
+
get message() {
|
|
2613
|
+
return `Failed to encode result for tool '${this.toolName}': ${this.description}`;
|
|
2614
|
+
}
|
|
2615
|
+
};
|
|
2616
|
+
var ToolConfigurationError = class extends Error$1("effect/ai/AiError/ToolConfigurationError")({
|
|
2617
|
+
_tag: tag("ToolConfigurationError"),
|
|
2618
|
+
toolName: String$1,
|
|
2619
|
+
description: String$1
|
|
2620
|
+
}) {
|
|
2621
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2622
|
+
get isRetryable() {
|
|
2623
|
+
return false;
|
|
2624
|
+
}
|
|
2625
|
+
get message() {
|
|
2626
|
+
return `Invalid configuration for tool '${this.toolName}': ${this.description}`;
|
|
2627
|
+
}
|
|
2628
|
+
};
|
|
2629
|
+
var ToolkitRequiredError = class extends Error$1("effect/ai/AiError/ToolkitRequiredError")({
|
|
2630
|
+
_tag: tag("ToolkitRequiredError"),
|
|
2631
|
+
pendingApprovals: ArraySchema(String$1),
|
|
2632
|
+
description: optional(String$1)
|
|
2633
|
+
}) {
|
|
2634
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2635
|
+
get isRetryable() {
|
|
2636
|
+
return false;
|
|
2637
|
+
}
|
|
2638
|
+
get message() {
|
|
2639
|
+
return `Toolkit required to resolve pending tool approvals: ${this.pendingApprovals.join(", ")}`;
|
|
2640
|
+
}
|
|
2641
|
+
};
|
|
2642
|
+
var InvalidUserInputError = class extends Error$1("effect/ai/AiError/InvalidUserInputError")({
|
|
2643
|
+
_tag: tag("InvalidUserInputError"),
|
|
2644
|
+
description: String$1
|
|
2645
|
+
}) {
|
|
2646
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
2647
|
+
get isRetryable() {
|
|
2648
|
+
return false;
|
|
2649
|
+
}
|
|
2650
|
+
get message() {
|
|
2651
|
+
return `Invalid user input: ${this.description}`;
|
|
2652
|
+
}
|
|
2653
|
+
};
|
|
2654
|
+
const AiErrorReason = Union([
|
|
2655
|
+
RateLimitError,
|
|
2656
|
+
QuotaExhaustedError,
|
|
2657
|
+
AuthenticationError,
|
|
2658
|
+
ContentPolicyError,
|
|
2659
|
+
InvalidRequestError,
|
|
2660
|
+
InvalidResponseError,
|
|
2661
|
+
InternalProviderError,
|
|
2662
|
+
NetworkError,
|
|
2663
|
+
InvalidOutputError,
|
|
2664
|
+
StructuredOutputError,
|
|
2665
|
+
UnsupportedSchemaError,
|
|
2666
|
+
UnknownError,
|
|
2667
|
+
ToolNotFoundError,
|
|
2668
|
+
ToolParameterValidationError,
|
|
2669
|
+
InvalidToolResultError,
|
|
2670
|
+
ToolResultEncodingError,
|
|
2671
|
+
ToolConfigurationError,
|
|
2672
|
+
ToolkitRequiredError,
|
|
2673
|
+
InvalidUserInputError
|
|
2674
|
+
]);
|
|
2675
|
+
const TypeId = "~effect/ai/AiError";
|
|
2676
|
+
var AiError = class extends Error$1("effect/ai/AiError/AiError")({
|
|
2677
|
+
_tag: tag("AiError"),
|
|
2678
|
+
module: String$1,
|
|
2679
|
+
method: String$1,
|
|
2680
|
+
reason: AiErrorReason
|
|
2681
|
+
}) {
|
|
2682
|
+
[TypeId] = TypeId;
|
|
2683
|
+
cause = this.reason;
|
|
2684
|
+
get isRetryable() {
|
|
2685
|
+
return this.reason.isRetryable;
|
|
2686
|
+
}
|
|
2687
|
+
get retryAfter() {
|
|
2688
|
+
return "retryAfter" in this.reason ? this.reason.retryAfter : void 0;
|
|
2689
|
+
}
|
|
2690
|
+
get message() {
|
|
2691
|
+
return `${this.module}.${this.method}: ${this.reason.message}`;
|
|
2692
|
+
}
|
|
2693
|
+
};
|
|
2694
|
+
const isAiError = (u) => hasProperty(u, TypeId);
|
|
2695
|
+
const isAiErrorReason = (u) => hasProperty(u, ReasonTypeId);
|
|
2696
|
+
const make = (params) => new AiError(params);
|
|
2697
|
+
const reasonFromHttpStatus = (params) => {
|
|
2698
|
+
const { status, http, metadata, description } = params;
|
|
2699
|
+
const common = {
|
|
2700
|
+
http,
|
|
2701
|
+
...metadata ? { metadata } : void 0,
|
|
2702
|
+
...description ? { description } : void 0
|
|
2703
|
+
};
|
|
2704
|
+
switch (status) {
|
|
2705
|
+
case 400: return new InvalidRequestError(common);
|
|
2706
|
+
case 401: return new AuthenticationError({
|
|
2707
|
+
kind: "InvalidKey",
|
|
2708
|
+
...common
|
|
2709
|
+
});
|
|
2710
|
+
case 403: return new AuthenticationError({
|
|
2711
|
+
kind: "InsufficientPermissions",
|
|
2712
|
+
...common
|
|
2713
|
+
});
|
|
2714
|
+
case 429: return new RateLimitError(common);
|
|
2715
|
+
default:
|
|
2716
|
+
if (status >= 500) return new InternalProviderError({
|
|
2717
|
+
description: "Server error",
|
|
2718
|
+
...common
|
|
2719
|
+
});
|
|
2720
|
+
return new UnknownError(common);
|
|
2721
|
+
}
|
|
2722
|
+
};
|
|
2723
|
+
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 };
|