@relayfx/sdk 0.0.46 → 0.0.47
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/ai.js +387 -372
- package/dist/index.js +421 -378
- package/dist/types/relay/client.d.ts +1 -1
- package/package.json +3 -3
package/dist/ai.js
CHANGED
|
@@ -8428,7 +8428,7 @@ __export(exports_agent_loop_service, {
|
|
|
8428
8428
|
AgentLoopBudgetExceeded: () => AgentLoopBudgetExceeded
|
|
8429
8429
|
});
|
|
8430
8430
|
|
|
8431
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8431
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/agent.ts
|
|
8432
8432
|
var exports_agent = {};
|
|
8433
8433
|
__export(exports_agent, {
|
|
8434
8434
|
streamObject: () => streamObject,
|
|
@@ -8438,10 +8438,10 @@ __export(exports_agent, {
|
|
|
8438
8438
|
generate: () => generate,
|
|
8439
8439
|
defaultObjectPrompt: () => defaultObjectPrompt
|
|
8440
8440
|
});
|
|
8441
|
-
import { Cause as Cause3, Effect as
|
|
8442
|
-
import { Chat, LanguageModel as
|
|
8441
|
+
import { Cause as Cause3, Effect as Effect46, Fiber, Option as Option16, Queue as Queue2, Ref as Ref11, Schema as Schema48, Stream as Stream7 } from "effect";
|
|
8442
|
+
import { Chat, LanguageModel as LanguageModel4, Prompt as Prompt4, Response as Response3, Telemetry, Tokenizer as Tokenizer2, Tool as Tool4, Toolkit as Toolkit3 } from "effect/unstable/ai";
|
|
8443
8443
|
|
|
8444
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8444
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/agent-event.ts
|
|
8445
8445
|
var exports_agent_event = {};
|
|
8446
8446
|
__export(exports_agent_event, {
|
|
8447
8447
|
addUsage: () => addUsage,
|
|
@@ -8498,7 +8498,7 @@ class AgentSuspended extends Schema38.TaggedErrorClass()("@batonfx/core/AgentSus
|
|
|
8498
8498
|
}) {
|
|
8499
8499
|
}
|
|
8500
8500
|
|
|
8501
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8501
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/approvals.ts
|
|
8502
8502
|
var exports_approvals = {};
|
|
8503
8503
|
__export(exports_approvals, {
|
|
8504
8504
|
testLayer: () => testLayer26,
|
|
@@ -8514,7 +8514,7 @@ var autoApprove = Layer29.succeed(Approvals, Approvals.of({ check: () => Effect3
|
|
|
8514
8514
|
var denyAll = Layer29.succeed(Approvals, Approvals.of({ check: () => Effect31.succeed({ _tag: "Denied" }) }));
|
|
8515
8515
|
var testLayer26 = (implementation) => Layer29.succeed(Approvals, Approvals.of(implementation));
|
|
8516
8516
|
|
|
8517
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8517
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/compaction.ts
|
|
8518
8518
|
var exports_compaction = {};
|
|
8519
8519
|
__export(exports_compaction, {
|
|
8520
8520
|
truncate: () => truncate,
|
|
@@ -8532,7 +8532,7 @@ __export(exports_compaction, {
|
|
|
8532
8532
|
import { Context as Context32, Effect as Effect34, Layer as Layer32, Option as Option10, Schema as Schema41 } from "effect";
|
|
8533
8533
|
import { LanguageModel, Prompt as Prompt3, Tokenizer, Toolkit as Toolkit2 } from "effect/unstable/ai";
|
|
8534
8534
|
|
|
8535
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8535
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/session.ts
|
|
8536
8536
|
var exports_session = {};
|
|
8537
8537
|
__export(exports_session, {
|
|
8538
8538
|
testLayer: () => testLayer27,
|
|
@@ -8705,7 +8705,7 @@ var memoryLayer24 = Layer30.effect(SessionStore, Ref7.make(initialState).pipe(Ef
|
|
|
8705
8705
|
}))));
|
|
8706
8706
|
var testLayer27 = (implementation) => Layer30.succeed(SessionStore, SessionStore.of(implementation));
|
|
8707
8707
|
|
|
8708
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8708
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/tool-output.ts
|
|
8709
8709
|
var exports_tool_output = {};
|
|
8710
8710
|
__export(exports_tool_output, {
|
|
8711
8711
|
testLayer: () => testLayer28,
|
|
@@ -8765,7 +8765,7 @@ var bound = (result, options) => Effect33.gen(function* () {
|
|
|
8765
8765
|
return { _tag: "Success", result: output, encodedResult: output };
|
|
8766
8766
|
});
|
|
8767
8767
|
|
|
8768
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8768
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/compaction.ts
|
|
8769
8769
|
var DEFAULT_RESERVE_TOKENS = 16384;
|
|
8770
8770
|
var DEFAULT_KEEP_RECENT_TOKENS = 20000;
|
|
8771
8771
|
var SUMMARY_TEMPLATE = `Summarize the conversation so another agent can continue seamlessly.
|
|
@@ -8948,7 +8948,7 @@ var truncate = (maxTokens) => ({
|
|
|
8948
8948
|
var testLayer29 = (implementation) => Layer32.succeed(Compaction, Compaction.of(implementation));
|
|
8949
8949
|
var isContextOverflow = (error) => /context|token|prompt/i.test(error instanceof Error ? `${error.name}: ${error.message}` : String(error)) && /overflow|exceed|exceeded|maximum|too large|too long|length/i.test(error instanceof Error ? `${error.name}: ${error.message}` : String(error));
|
|
8950
8950
|
|
|
8951
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
8951
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/instructions.ts
|
|
8952
8952
|
var exports_instructions = {};
|
|
8953
8953
|
__export(exports_instructions, {
|
|
8954
8954
|
testLayer: () => testLayer30,
|
|
@@ -8997,7 +8997,7 @@ var renderUpdate = (epoch, context) => Effect35.gen(function* () {
|
|
|
8997
8997
|
var layer27 = (sources) => Layer33.succeed(Instructions, Instructions.of({ sources: [...sources] }));
|
|
8998
8998
|
var testLayer30 = (implementation) => Layer33.succeed(Instructions, Instructions.of(implementation));
|
|
8999
8999
|
|
|
9000
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9000
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/memory.ts
|
|
9001
9001
|
var exports_memory = {};
|
|
9002
9002
|
__export(exports_memory, {
|
|
9003
9003
|
testLayer: () => testLayer31,
|
|
@@ -9028,7 +9028,7 @@ var merge = (first, second) => ({
|
|
|
9028
9028
|
var noopLayer = Layer34.succeed(Memory, Memory.of(noop));
|
|
9029
9029
|
var testLayer31 = (implementation) => Layer34.succeed(Memory, Memory.of(implementation));
|
|
9030
9030
|
|
|
9031
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9031
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/model-middleware.ts
|
|
9032
9032
|
var exports_model_middleware = {};
|
|
9033
9033
|
__export(exports_model_middleware, {
|
|
9034
9034
|
layer: () => layer28,
|
|
@@ -9042,21 +9042,110 @@ class ModelMiddleware extends Context35.Service()("@batonfx/core/ModelMiddleware
|
|
|
9042
9042
|
var identityLayer = Layer35.succeed(ModelMiddleware, []);
|
|
9043
9043
|
var layer28 = (middleware) => Layer35.succeed(ModelMiddleware, middleware);
|
|
9044
9044
|
|
|
9045
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9045
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/model-registry.ts
|
|
9046
|
+
var exports_model_registry = {};
|
|
9047
|
+
__export(exports_model_registry, {
|
|
9048
|
+
testLayer: () => testLayer32,
|
|
9049
|
+
registrations: () => registrations,
|
|
9050
|
+
registrationFromLayer: () => registrationFromLayer,
|
|
9051
|
+
register: () => register4,
|
|
9052
|
+
provide: () => provide,
|
|
9053
|
+
memoryLayer: () => memoryLayer25,
|
|
9054
|
+
layerFromRegistrationEffects: () => layerFromRegistrationEffects,
|
|
9055
|
+
layer: () => layer29,
|
|
9056
|
+
combine: () => combine,
|
|
9057
|
+
Service: () => Service29,
|
|
9058
|
+
LanguageModelNotRegistered: () => LanguageModelNotRegistered
|
|
9059
|
+
});
|
|
9060
|
+
import { Chunk as Chunk2, Context as Context36, Effect as Effect38, Layer as Layer36, Option as Option13, Ref as Ref9, Schema as Schema43, Semaphore as Semaphore3 } from "effect";
|
|
9061
|
+
import { Model } from "effect/unstable/ai";
|
|
9062
|
+
|
|
9063
|
+
class LanguageModelNotRegistered extends Schema43.TaggedErrorClass()("LanguageModelNotRegistered", {
|
|
9064
|
+
provider: Schema43.String,
|
|
9065
|
+
model: Schema43.String,
|
|
9066
|
+
registration_key: Schema43.optionalKey(Schema43.String)
|
|
9067
|
+
}) {
|
|
9068
|
+
}
|
|
9069
|
+
|
|
9070
|
+
class Service29 extends Context36.Service()("@batonfx/core/ModelRegistry") {
|
|
9071
|
+
}
|
|
9072
|
+
var registrationVariantKey = (value) => value.registrationKey ?? null;
|
|
9073
|
+
var selectionVariantKey = (selection) => selection.registrationKey ?? null;
|
|
9074
|
+
var registryIdentity = (registration) => JSON.stringify([registration.provider, registration.model, registrationVariantKey(registration)]);
|
|
9075
|
+
var matchesSelection = (selection) => (registration) => registration.provider === selection.provider && registration.model === selection.model && registrationVariantKey(registration) === selectionVariantKey(selection);
|
|
9076
|
+
var upsertRegistration = (registry, registration) => {
|
|
9077
|
+
const key2 = registryIdentity(registration);
|
|
9078
|
+
const exists = Option13.isSome(Chunk2.findFirst(registry, (item) => registryIdentity(item) === key2));
|
|
9079
|
+
if (!exists)
|
|
9080
|
+
return Chunk2.append(registry, registration);
|
|
9081
|
+
return Chunk2.map(registry, (item) => registryIdentity(item) === key2 ? registration : item);
|
|
9082
|
+
};
|
|
9083
|
+
var findRegistration = (registry, selection) => Chunk2.findFirst(registry, matchesSelection(selection)).pipe(Option13.getOrUndefined);
|
|
9084
|
+
var registrationFromLayer = (input) => Model.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect38.map((layer29) => ({
|
|
9085
|
+
provider: input.provider,
|
|
9086
|
+
model: input.model,
|
|
9087
|
+
layer: layer29,
|
|
9088
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
9089
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
9090
|
+
})));
|
|
9091
|
+
var layer29 = (initialRegistrations = [], options) => Layer36.effect(Service29, Effect38.gen(function* () {
|
|
9092
|
+
const registry = yield* Ref9.make(initialRegistrations.reduce(upsertRegistration, Chunk2.empty()));
|
|
9093
|
+
const semaphore = options?.maxConcurrentModelCalls === undefined ? undefined : yield* Semaphore3.make(options.maxConcurrentModelCalls);
|
|
9094
|
+
const register4 = Effect38.fn("ModelRegistry.register")(function* (input) {
|
|
9095
|
+
yield* Ref9.update(registry, (items) => upsertRegistration(items, input.registration));
|
|
9096
|
+
});
|
|
9097
|
+
const registrations = Ref9.get(registry).pipe(Effect38.map(Chunk2.toReadonlyArray));
|
|
9098
|
+
const provide = Effect38.fn("ModelRegistry.provide")(function* (selection, effect) {
|
|
9099
|
+
const items = yield* Ref9.get(registry);
|
|
9100
|
+
const registration = findRegistration(items, selection);
|
|
9101
|
+
if (registration === undefined) {
|
|
9102
|
+
return yield* Effect38.fail(new LanguageModelNotRegistered({
|
|
9103
|
+
provider: selection.provider,
|
|
9104
|
+
model: selection.model,
|
|
9105
|
+
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
9106
|
+
}));
|
|
9107
|
+
}
|
|
9108
|
+
const provided = effect.pipe(Effect38.provide(registration.layer));
|
|
9109
|
+
return yield* semaphore === undefined ? provided : semaphore.withPermits(1)(provided);
|
|
9110
|
+
});
|
|
9111
|
+
return Service29.of({
|
|
9112
|
+
register: register4,
|
|
9113
|
+
registrations,
|
|
9114
|
+
provide
|
|
9115
|
+
});
|
|
9116
|
+
}));
|
|
9117
|
+
var layerFromRegistrationEffects = (registrations, options) => Layer36.unwrap(Effect38.all(registrations).pipe(Effect38.map((items) => layer29(items, options))));
|
|
9118
|
+
var combine = (registries, options) => Layer36.unwrap(Effect38.forEach(registries, (registry) => Layer36.build(registry).pipe(Effect38.flatMap((context) => Context36.get(context, Service29).registrations))).pipe(Effect38.map((groups) => layer29(groups.flat(), options))));
|
|
9119
|
+
var memoryLayer25 = layer29;
|
|
9120
|
+
var testLayer32 = (implementation) => Layer36.succeed(Service29, Service29.of(implementation));
|
|
9121
|
+
var register4 = Effect38.fn("ModelRegistry.register.call")(function* (input) {
|
|
9122
|
+
const service = yield* Service29;
|
|
9123
|
+
return yield* service.register(input);
|
|
9124
|
+
});
|
|
9125
|
+
var registrations = Effect38.fn("ModelRegistry.registrations.call")(function* () {
|
|
9126
|
+
const service = yield* Service29;
|
|
9127
|
+
return yield* service.registrations;
|
|
9128
|
+
});
|
|
9129
|
+
var provide = (selection, effect) => Effect38.gen(function* () {
|
|
9130
|
+
const service = yield* Service29;
|
|
9131
|
+
return yield* service.provide(selection, effect);
|
|
9132
|
+
});
|
|
9133
|
+
|
|
9134
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/model-resilience.ts
|
|
9046
9135
|
var exports_model_resilience = {};
|
|
9047
9136
|
__export(exports_model_resilience, {
|
|
9048
|
-
testLayer: () =>
|
|
9137
|
+
testLayer: () => testLayer33,
|
|
9049
9138
|
none: () => none,
|
|
9050
9139
|
make: () => make3,
|
|
9051
|
-
layer: () =>
|
|
9140
|
+
layer: () => layer30,
|
|
9052
9141
|
defaultClassify: () => defaultClassify,
|
|
9053
9142
|
apply: () => apply,
|
|
9054
9143
|
ModelResilience: () => ModelResilience
|
|
9055
9144
|
});
|
|
9056
|
-
import { Cause, Context as
|
|
9145
|
+
import { Cause, Context as Context37, Effect as Effect39, Layer as Layer37, Schedule as Schedule2, Stream as Stream5 } from "effect";
|
|
9057
9146
|
import { AiError, Response as Response2 } from "effect/unstable/ai";
|
|
9058
9147
|
|
|
9059
|
-
class ModelResilience extends
|
|
9148
|
+
class ModelResilience extends Context37.Service()("@batonfx/core/ModelResilience") {
|
|
9060
9149
|
}
|
|
9061
9150
|
var defaultClassify = (error) => AiError.isAiError(error) && error.isRetryable ? "transient" : "terminal";
|
|
9062
9151
|
var none = { classify: () => "terminal", retrySchedule: Schedule2.recurs(0) };
|
|
@@ -9064,9 +9153,9 @@ var make3 = (input) => ({
|
|
|
9064
9153
|
classify: input?.classify ?? defaultClassify,
|
|
9065
9154
|
retrySchedule: input?.retrySchedule ?? none.retrySchedule
|
|
9066
9155
|
});
|
|
9067
|
-
var
|
|
9068
|
-
var
|
|
9069
|
-
var retryEffect = (effect, resilience) =>
|
|
9156
|
+
var layer30 = (input) => Layer37.succeed(ModelResilience, ModelResilience.of(make3(input)));
|
|
9157
|
+
var testLayer33 = (implementation) => Layer37.succeed(ModelResilience, ModelResilience.of(implementation));
|
|
9158
|
+
var retryEffect = (effect, resilience) => Effect39.suspend(effect).pipe(Effect39.retry({
|
|
9070
9159
|
schedule: resilience.retrySchedule,
|
|
9071
9160
|
while: (error) => resilience.classify(error) === "transient"
|
|
9072
9161
|
}));
|
|
@@ -9077,7 +9166,7 @@ var apply = (model, resilience) => ({
|
|
|
9077
9166
|
generateObject: (options) => retryEffect(() => model.generateObject(options), resilience),
|
|
9078
9167
|
streamText: (options) => Stream5.suspend(() => {
|
|
9079
9168
|
let emitted = false;
|
|
9080
|
-
return model.streamText(options).pipe(Stream5.tap(() =>
|
|
9169
|
+
return model.streamText(options).pipe(Stream5.tap(() => Effect39.sync(() => {
|
|
9081
9170
|
emitted = true;
|
|
9082
9171
|
})), Stream5.catchCause((cause) => {
|
|
9083
9172
|
if (Cause.hasInterrupts(cause))
|
|
@@ -9088,10 +9177,10 @@ var apply = (model, resilience) => ({
|
|
|
9088
9177
|
}).pipe(Stream5.retry(retryStreamSchedule(resilience)))
|
|
9089
9178
|
});
|
|
9090
9179
|
|
|
9091
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9180
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/permissions.ts
|
|
9092
9181
|
var exports_permissions = {};
|
|
9093
9182
|
__export(exports_permissions, {
|
|
9094
|
-
testLayer: () =>
|
|
9183
|
+
testLayer: () => testLayer34,
|
|
9095
9184
|
ruleStoreTestLayer: () => ruleStoreTestLayer,
|
|
9096
9185
|
ruleStoreMemory: () => ruleStoreMemory,
|
|
9097
9186
|
matches: () => matches,
|
|
@@ -9103,17 +9192,17 @@ __export(exports_permissions, {
|
|
|
9103
9192
|
Permissions: () => Permissions,
|
|
9104
9193
|
PermissionError: () => PermissionError
|
|
9105
9194
|
});
|
|
9106
|
-
import { Context as
|
|
9195
|
+
import { Context as Context38, Effect as Effect40, Layer as Layer38, Option as Option14, Ref as Ref10, Schema as Schema44 } from "effect";
|
|
9107
9196
|
|
|
9108
|
-
class PermissionError extends
|
|
9109
|
-
message:
|
|
9197
|
+
class PermissionError extends Schema44.TaggedErrorClass()("@batonfx/core/PermissionError", {
|
|
9198
|
+
message: Schema44.String
|
|
9110
9199
|
}) {
|
|
9111
9200
|
}
|
|
9112
9201
|
|
|
9113
|
-
class Permissions extends
|
|
9202
|
+
class Permissions extends Context38.Service()("@batonfx/core/Permissions") {
|
|
9114
9203
|
}
|
|
9115
9204
|
|
|
9116
|
-
class RuleStore extends
|
|
9205
|
+
class RuleStore extends Context38.Service()("@batonfx/core/PermissionRuleStore") {
|
|
9117
9206
|
}
|
|
9118
9207
|
var escapeRegExp = (value) => value.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
9119
9208
|
var glob = (pattern) => new RegExp(`^${pattern.split("*").map(escapeRegExp).join(".*")}$`);
|
|
@@ -9200,28 +9289,28 @@ var decisionFor = (ruleset, request) => {
|
|
|
9200
9289
|
return { _tag: "Ask", token: tokenFor(request) };
|
|
9201
9290
|
}
|
|
9202
9291
|
};
|
|
9203
|
-
var fromRuleset = (ruleset) =>
|
|
9204
|
-
evaluate: (request) =>
|
|
9205
|
-
await: () =>
|
|
9292
|
+
var fromRuleset = (ruleset) => Layer38.succeed(Permissions, Permissions.of({
|
|
9293
|
+
evaluate: (request) => Effect40.succeed(decisionFor(ruleset, request)),
|
|
9294
|
+
await: () => Effect40.succeed(Option14.none())
|
|
9206
9295
|
}));
|
|
9207
|
-
var allowAll =
|
|
9208
|
-
evaluate: () =>
|
|
9209
|
-
await: () =>
|
|
9296
|
+
var allowAll = Layer38.succeed(Permissions, Permissions.of({
|
|
9297
|
+
evaluate: () => Effect40.succeed({ _tag: "Allow" }),
|
|
9298
|
+
await: () => Effect40.succeed(Option14.none())
|
|
9210
9299
|
}));
|
|
9211
|
-
var interactive = (options) =>
|
|
9212
|
-
evaluate: (request) =>
|
|
9213
|
-
await: (pending) => options.onAsk(pending).pipe(
|
|
9300
|
+
var interactive = (options) => Layer38.succeed(Permissions, Permissions.of({
|
|
9301
|
+
evaluate: (request) => Effect40.succeed(decisionFor(options.ruleset, request)),
|
|
9302
|
+
await: (pending) => options.onAsk(pending).pipe(Effect40.map(Option14.some))
|
|
9214
9303
|
}));
|
|
9215
|
-
var ruleStoreMemory = (initialRules = []) =>
|
|
9216
|
-
remember: (rule) =>
|
|
9304
|
+
var ruleStoreMemory = (initialRules = []) => Layer38.effect(RuleStore, Ref10.make(initialRules).pipe(Effect40.map((rules) => RuleStore.of({
|
|
9305
|
+
remember: (rule) => Ref10.update(rules, (current2) => [...current2, rule])
|
|
9217
9306
|
}))));
|
|
9218
|
-
var ruleStoreTestLayer = (implementation) =>
|
|
9219
|
-
var
|
|
9307
|
+
var ruleStoreTestLayer = (implementation) => Layer38.succeed(RuleStore, RuleStore.of(implementation));
|
|
9308
|
+
var testLayer34 = (implementation) => Layer38.succeed(Permissions, Permissions.of(implementation));
|
|
9220
9309
|
|
|
9221
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9310
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/skill-source.ts
|
|
9222
9311
|
var exports_skill_source = {};
|
|
9223
9312
|
__export(exports_skill_source, {
|
|
9224
|
-
testLayer: () =>
|
|
9313
|
+
testLayer: () => testLayer35,
|
|
9225
9314
|
selectListings: () => selectListings,
|
|
9226
9315
|
makeListing: () => makeListing,
|
|
9227
9316
|
fromSkills: () => fromSkills,
|
|
@@ -9230,29 +9319,29 @@ __export(exports_skill_source, {
|
|
|
9230
9319
|
SkillSource: () => SkillSource,
|
|
9231
9320
|
DESCRIPTION_CAP: () => DESCRIPTION_CAP
|
|
9232
9321
|
});
|
|
9233
|
-
import { Context as
|
|
9322
|
+
import { Context as Context39, Effect as Effect41, Layer as Layer39, Schema as Schema45 } from "effect";
|
|
9234
9323
|
|
|
9235
|
-
class SkillSourceError extends
|
|
9236
|
-
source:
|
|
9237
|
-
message:
|
|
9238
|
-
cause:
|
|
9324
|
+
class SkillSourceError extends Schema45.TaggedErrorClass()("@batonfx/core/SkillSourceError", {
|
|
9325
|
+
source: Schema45.String,
|
|
9326
|
+
message: Schema45.String,
|
|
9327
|
+
cause: Schema45.optionalKey(Schema45.Defect())
|
|
9239
9328
|
}) {
|
|
9240
9329
|
}
|
|
9241
9330
|
var DESCRIPTION_CAP = 1536;
|
|
9242
9331
|
|
|
9243
|
-
class SkillSource extends
|
|
9332
|
+
class SkillSource extends Context39.Service()("@batonfx/core/SkillSource") {
|
|
9244
9333
|
}
|
|
9245
9334
|
var makeListing = (frontmatter, descriptionCap = DESCRIPTION_CAP) => `- ${frontmatter.name}: ${frontmatter.description.slice(0, Math.max(0, descriptionCap))}`;
|
|
9246
9335
|
var fromSkills = (skills) => {
|
|
9247
9336
|
const all = [...skills];
|
|
9248
9337
|
const byName = new Map(all.map((skill) => [skill.frontmatter.name, skill]));
|
|
9249
|
-
return
|
|
9250
|
-
all:
|
|
9251
|
-
get: (name) =>
|
|
9338
|
+
return Layer39.succeed(SkillSource, SkillSource.of({
|
|
9339
|
+
all: Effect41.succeed(all),
|
|
9340
|
+
get: (name) => Effect41.succeed(byName.get(name))
|
|
9252
9341
|
}));
|
|
9253
9342
|
};
|
|
9254
9343
|
var empty = fromSkills([]);
|
|
9255
|
-
var
|
|
9344
|
+
var testLayer35 = (implementation) => Layer39.succeed(SkillSource, SkillSource.of(implementation));
|
|
9256
9345
|
var estimatedTokens = (listing) => Math.ceil(listing.length / 4);
|
|
9257
9346
|
var usageRank = (skill, recentlyUsed) => {
|
|
9258
9347
|
const index2 = recentlyUsed.indexOf(skill.frontmatter.name);
|
|
@@ -9276,22 +9365,22 @@ var selectListings = (skills, budgetTokens, recentlyUsed) => {
|
|
|
9276
9365
|
return selected;
|
|
9277
9366
|
};
|
|
9278
9367
|
|
|
9279
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9368
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/steering.ts
|
|
9280
9369
|
var exports_steering = {};
|
|
9281
9370
|
__export(exports_steering, {
|
|
9282
|
-
testLayer: () =>
|
|
9283
|
-
layer: () =>
|
|
9371
|
+
testLayer: () => testLayer36,
|
|
9372
|
+
layer: () => layer31,
|
|
9284
9373
|
SteeringQueueFull: () => SteeringQueueFull,
|
|
9285
9374
|
Steering: () => Steering
|
|
9286
9375
|
});
|
|
9287
|
-
import { Context as
|
|
9376
|
+
import { Context as Context40, Effect as Effect42, Exit, Layer as Layer40, Queue, Schema as Schema46 } from "effect";
|
|
9288
9377
|
|
|
9289
|
-
class Steering extends
|
|
9378
|
+
class Steering extends Context40.Service()("@batonfx/core/Steering") {
|
|
9290
9379
|
}
|
|
9291
9380
|
|
|
9292
|
-
class SteeringQueueFull extends
|
|
9293
|
-
queue:
|
|
9294
|
-
capacity:
|
|
9381
|
+
class SteeringQueueFull extends Schema46.TaggedErrorClass()("@batonfx/core/SteeringQueueFull", {
|
|
9382
|
+
queue: Schema46.Literals(["steering", "followUp"]),
|
|
9383
|
+
capacity: Schema46.Number
|
|
9295
9384
|
}) {
|
|
9296
9385
|
}
|
|
9297
9386
|
var resolvePolicy = (policy, mode) => ({
|
|
@@ -9310,18 +9399,18 @@ var queueStrategy = (strategy) => {
|
|
|
9310
9399
|
return "suspend";
|
|
9311
9400
|
}
|
|
9312
9401
|
};
|
|
9313
|
-
var makeQueue = (name, policy) => (policy.capacity === undefined ? Queue.unbounded() : Queue.make({ capacity: policy.capacity, strategy: queueStrategy(policy.onFull) })).pipe(
|
|
9314
|
-
var offer = (runtime, message) => Queue.offer(runtime.queue, message).pipe(
|
|
9402
|
+
var makeQueue = (name, policy) => (policy.capacity === undefined ? Queue.unbounded() : Queue.make({ capacity: policy.capacity, strategy: queueStrategy(policy.onFull) })).pipe(Effect42.map((queue) => ({ name, queue, policy })));
|
|
9403
|
+
var offer = (runtime, message) => Queue.offer(runtime.queue, message).pipe(Effect42.flatMap((offered) => {
|
|
9315
9404
|
if (offered || runtime.policy.capacity === undefined || runtime.policy.onFull !== "fail")
|
|
9316
|
-
return
|
|
9317
|
-
return
|
|
9405
|
+
return Effect42.void;
|
|
9406
|
+
return Effect42.fail(new SteeringQueueFull({ queue: runtime.name, capacity: runtime.policy.capacity }));
|
|
9318
9407
|
}));
|
|
9319
|
-
var drainOne = (queue) =>
|
|
9408
|
+
var drainOne = (queue) => Effect42.sync(() => {
|
|
9320
9409
|
const taken = Queue.takeUnsafe(queue);
|
|
9321
9410
|
return taken === undefined || !Exit.isSuccess(taken) ? [] : [taken.value];
|
|
9322
9411
|
});
|
|
9323
9412
|
var drain = (queue, mode) => mode === "all" ? Queue.clear(queue) : drainOne(queue);
|
|
9324
|
-
var
|
|
9413
|
+
var layer31 = (options = {}) => Layer40.effect(Steering, Effect42.gen(function* () {
|
|
9325
9414
|
const steeringQueue = yield* makeQueue("steering", resolvePolicy(options.steering, "all"));
|
|
9326
9415
|
const followUpQueue = yield* makeQueue("followUp", resolvePolicy(options.followUp, "one-at-a-time"));
|
|
9327
9416
|
return Steering.of({
|
|
@@ -9331,30 +9420,30 @@ var layer30 = (options = {}) => Layer39.effect(Steering, Effect41.gen(function*
|
|
|
9331
9420
|
takeFollowUp: () => drain(followUpQueue.queue, followUpQueue.policy.mode)
|
|
9332
9421
|
});
|
|
9333
9422
|
}));
|
|
9334
|
-
var
|
|
9423
|
+
var testLayer36 = (implementation) => Layer40.succeed(Steering, Steering.of(implementation));
|
|
9335
9424
|
|
|
9336
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9425
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/tool-context.ts
|
|
9337
9426
|
var exports_tool_context = {};
|
|
9338
9427
|
__export(exports_tool_context, {
|
|
9339
|
-
testLayer: () =>
|
|
9428
|
+
testLayer: () => testLayer37,
|
|
9340
9429
|
layerDefault: () => layerDefault,
|
|
9341
9430
|
ToolContext: () => ToolContext
|
|
9342
9431
|
});
|
|
9343
|
-
import { Context as
|
|
9432
|
+
import { Context as Context41, Effect as Effect43, Layer as Layer41 } from "effect";
|
|
9344
9433
|
|
|
9345
|
-
class ToolContext extends
|
|
9434
|
+
class ToolContext extends Context41.Service()("@batonfx/core/ToolContext") {
|
|
9346
9435
|
}
|
|
9347
|
-
var layerDefault =
|
|
9436
|
+
var layerDefault = Layer41.sync(ToolContext, () => ToolContext.of({
|
|
9348
9437
|
signal: new AbortController().signal,
|
|
9349
|
-
emit: () =>
|
|
9438
|
+
emit: () => Effect43.void,
|
|
9350
9439
|
sessionId: "local"
|
|
9351
9440
|
}));
|
|
9352
|
-
var
|
|
9441
|
+
var testLayer37 = (implementation) => Layer41.succeed(ToolContext, ToolContext.of(implementation));
|
|
9353
9442
|
|
|
9354
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9443
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/tool-executor.ts
|
|
9355
9444
|
var exports_tool_executor = {};
|
|
9356
9445
|
__export(exports_tool_executor, {
|
|
9357
|
-
testLayer: () =>
|
|
9446
|
+
testLayer: () => testLayer38,
|
|
9358
9447
|
sandbox: () => sandbox,
|
|
9359
9448
|
router: () => router,
|
|
9360
9449
|
routeToolkit: () => routeToolkit,
|
|
@@ -9366,8 +9455,8 @@ __export(exports_tool_executor, {
|
|
|
9366
9455
|
client: () => client,
|
|
9367
9456
|
ToolExecutor: () => ToolExecutor
|
|
9368
9457
|
});
|
|
9369
|
-
import { Cause as Cause2, Context as
|
|
9370
|
-
class ToolExecutor extends
|
|
9458
|
+
import { Cause as Cause2, Context as Context42, Effect as Effect44, Layer as Layer42, Option as Option15, Schema as Schema47, Sink as Sink2, Stream as Stream6 } from "effect";
|
|
9459
|
+
class ToolExecutor extends Context42.Service()("@batonfx/core/ToolExecutor") {
|
|
9371
9460
|
}
|
|
9372
9461
|
var failureMessage = (cause) => {
|
|
9373
9462
|
const error = Cause2.squash(cause);
|
|
@@ -9389,47 +9478,47 @@ var resultMessage = (result) => {
|
|
|
9389
9478
|
var schemaMessage = (error) => error instanceof Error ? error.message : typeof error === "string" ? error : resultMessage(error);
|
|
9390
9479
|
var decodeSuccess = (tool2, result) => {
|
|
9391
9480
|
const successSchema = tool2.successSchema;
|
|
9392
|
-
if (!
|
|
9393
|
-
return
|
|
9481
|
+
if (!Schema47.isSchema(successSchema)) {
|
|
9482
|
+
return Effect44.succeed({ _tag: "Success", result, encodedResult: result });
|
|
9394
9483
|
}
|
|
9395
|
-
return
|
|
9484
|
+
return Schema47.decodeUnknownEffect(successSchema)(result).pipe(Effect44.flatMap((decoded) => Schema47.encodeUnknownEffect(successSchema)(decoded).pipe(Effect44.map((encoded) => ({ _tag: "Success", result: decoded, encodedResult: encoded })))), Effect44.catchCause((cause) => Effect44.succeed(failureOutcome(`invalid client result: ${schemaMessage(Cause2.squash(cause))}`))));
|
|
9396
9485
|
};
|
|
9397
9486
|
var placementOutcome = (placement, tool2, response) => {
|
|
9398
9487
|
switch (response._tag) {
|
|
9399
9488
|
case "Failure":
|
|
9400
|
-
return
|
|
9489
|
+
return Effect44.succeed(failureOutcome(response.message));
|
|
9401
9490
|
case "Suspend":
|
|
9402
|
-
return
|
|
9491
|
+
return Effect44.succeed({ _tag: "Suspend", token: response.token });
|
|
9403
9492
|
case "Success":
|
|
9404
|
-
return decodeSuccess(tool2, response.result).pipe(
|
|
9493
|
+
return decodeSuccess(tool2, response.result).pipe(Effect44.map((outcome) => outcome._tag === "Failure" ? failureOutcome(outcome.message.replace("invalid client result", `invalid ${placement} result`)) : outcome));
|
|
9405
9494
|
}
|
|
9406
9495
|
};
|
|
9407
9496
|
var executeWithToolkit = (toolkit, request) => {
|
|
9408
9497
|
if (toolkit.tools[request.call.name] === undefined) {
|
|
9409
|
-
return
|
|
9498
|
+
return Effect44.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
|
|
9410
9499
|
}
|
|
9411
|
-
return toolkit.handle(request.call.name, request.call.params).pipe(
|
|
9500
|
+
return toolkit.handle(request.call.name, request.call.params).pipe(Effect44.flatMap((results) => results.pipe(Stream6.filter((item) => item.preliminary === false), Stream6.run(Sink2.last()))), Effect44.map(Option15.match({
|
|
9412
9501
|
onNone: () => failureOutcome("Tool handler did not produce a final result"),
|
|
9413
9502
|
onSome: (result) => result.isFailure ? failureOutcome(resultMessage(result.result)) : {
|
|
9414
9503
|
_tag: "Success",
|
|
9415
9504
|
result: result.result,
|
|
9416
9505
|
encodedResult: result.encodedResult
|
|
9417
9506
|
}
|
|
9418
|
-
})),
|
|
9507
|
+
})), Effect44.catchCause((cause) => {
|
|
9419
9508
|
if (Cause2.hasInterrupts(cause))
|
|
9420
|
-
return
|
|
9509
|
+
return Effect44.interrupt;
|
|
9421
9510
|
const error = Cause2.squash(cause);
|
|
9422
9511
|
if (error instanceof AgentSuspended) {
|
|
9423
|
-
return
|
|
9512
|
+
return Effect44.succeed({ _tag: "Suspend", token: error.token });
|
|
9424
9513
|
}
|
|
9425
|
-
return
|
|
9514
|
+
return Effect44.succeed(failureOutcome(failureMessage(cause)));
|
|
9426
9515
|
}));
|
|
9427
9516
|
};
|
|
9428
9517
|
function executeToolkit(toolkit, request) {
|
|
9429
|
-
return ("handle" in toolkit ?
|
|
9518
|
+
return ("handle" in toolkit ? Effect44.succeed(toolkit) : toolkit).pipe(Effect44.flatMap((handled) => executeWithToolkit(handled, request)));
|
|
9430
9519
|
}
|
|
9431
9520
|
function fromToolkit(toolkit) {
|
|
9432
|
-
return
|
|
9521
|
+
return Layer42.effect(ToolExecutor, ("handle" in toolkit ? Effect44.succeed(toolkit) : toolkit).pipe(Effect44.map((handled) => ToolExecutor.of({
|
|
9433
9522
|
execute: (request) => executeWithToolkit(handled, request)
|
|
9434
9523
|
}))));
|
|
9435
9524
|
}
|
|
@@ -9448,10 +9537,10 @@ var placementRoute = (placement, options) => {
|
|
|
9448
9537
|
execute: (request) => {
|
|
9449
9538
|
const tool2 = options.toolkit.tools[request.call.name];
|
|
9450
9539
|
if (tool2 === undefined)
|
|
9451
|
-
return
|
|
9540
|
+
return Effect44.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
|
|
9452
9541
|
const effect = options.execute({ ...request, placement, tool: tool2 });
|
|
9453
|
-
const scheduled = "schedule" in options && options.schedule !== undefined ?
|
|
9454
|
-
return scheduled.pipe(
|
|
9542
|
+
const scheduled = "schedule" in options && options.schedule !== undefined ? Effect44.retry(effect, options.schedule) : effect;
|
|
9543
|
+
return scheduled.pipe(Effect44.flatMap((response) => placementOutcome(placement, tool2, response)), Effect44.catchCause((cause) => Cause2.hasInterrupts(cause) ? Effect44.interrupt : Effect44.succeed(failureOutcome(`${placement} tool infrastructure failed: ${failureMessage(cause)}`))));
|
|
9455
9544
|
}
|
|
9456
9545
|
});
|
|
9457
9546
|
};
|
|
@@ -9464,20 +9553,20 @@ function routeToolkit(toolkit) {
|
|
|
9464
9553
|
tools: Object.keys(handled.tools),
|
|
9465
9554
|
execute: (request) => executeWithToolkit(handled, request)
|
|
9466
9555
|
});
|
|
9467
|
-
return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(
|
|
9556
|
+
return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(Effect44.map(makeRoute));
|
|
9468
9557
|
}
|
|
9469
|
-
var routeInputEffect = (input) =>
|
|
9558
|
+
var routeInputEffect = (input) => Effect44.isEffect(input) ? input : Effect44.succeed(input);
|
|
9470
9559
|
function router(routes) {
|
|
9471
|
-
return
|
|
9560
|
+
return Layer42.effect(ToolExecutor, Effect44.all(Array.from(routes, routeInputEffect)).pipe(Effect44.map((resolved) => ToolExecutor.of({
|
|
9472
9561
|
execute: (request) => {
|
|
9473
9562
|
const matched = resolved.find((candidate) => candidate.matches(request));
|
|
9474
|
-
return matched === undefined ?
|
|
9563
|
+
return matched === undefined ? Effect44.succeed(failureOutcome(`Tool ${request.call.name} is not registered`)) : matched.execute(request);
|
|
9475
9564
|
}
|
|
9476
9565
|
}))));
|
|
9477
9566
|
}
|
|
9478
|
-
var
|
|
9567
|
+
var testLayer38 = (implementation) => Layer42.succeed(ToolExecutor, ToolExecutor.of(implementation));
|
|
9479
9568
|
|
|
9480
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9569
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/turn-policy.ts
|
|
9481
9570
|
var exports_turn_policy = {};
|
|
9482
9571
|
__export(exports_turn_policy, {
|
|
9483
9572
|
untilToolCall: () => untilToolCall,
|
|
@@ -9487,7 +9576,7 @@ __export(exports_turn_policy, {
|
|
|
9487
9576
|
decision: () => decision,
|
|
9488
9577
|
both: () => both
|
|
9489
9578
|
});
|
|
9490
|
-
import { Effect as
|
|
9579
|
+
import { Effect as Effect45 } from "effect";
|
|
9491
9580
|
var decision = {
|
|
9492
9581
|
continue: (overrides) => ({
|
|
9493
9582
|
_tag: "Continue",
|
|
@@ -9496,8 +9585,8 @@ var decision = {
|
|
|
9496
9585
|
stop: { _tag: "Stop" }
|
|
9497
9586
|
};
|
|
9498
9587
|
var make4 = (decide) => ({ decide });
|
|
9499
|
-
var recurs = (n) => make4((info) =>
|
|
9500
|
-
var untilToolCall = (name) => make4((info) =>
|
|
9588
|
+
var recurs = (n) => make4((info) => Effect45.succeed(info.turn < n + 1 ? decision.continue() : decision.stop));
|
|
9589
|
+
var untilToolCall = (name) => make4((info) => Effect45.succeed(info.pendingToolResults.some((result) => result.name === name) ? decision.stop : decision.continue()));
|
|
9501
9590
|
var mergeOverrides = (first, second) => {
|
|
9502
9591
|
if (first === undefined)
|
|
9503
9592
|
return second;
|
|
@@ -9505,7 +9594,7 @@ var mergeOverrides = (first, second) => {
|
|
|
9505
9594
|
return first;
|
|
9506
9595
|
return { ...first, ...second };
|
|
9507
9596
|
};
|
|
9508
|
-
var both = (first, second) => make4((info) =>
|
|
9597
|
+
var both = (first, second) => make4((info) => Effect45.gen(function* () {
|
|
9509
9598
|
const left = yield* first.decide(info);
|
|
9510
9599
|
if (left._tag === "Stop")
|
|
9511
9600
|
return decision.stop;
|
|
@@ -9516,14 +9605,17 @@ var both = (first, second) => make4((info) => Effect44.gen(function* () {
|
|
|
9516
9605
|
}));
|
|
9517
9606
|
var defaultPolicy = recurs(8);
|
|
9518
9607
|
|
|
9519
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
9608
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/agent.ts
|
|
9520
9609
|
function make5(nameOrOptions, options = {}) {
|
|
9521
9610
|
const resolved = typeof nameOrOptions === "string" ? { ...options, name: nameOrOptions } : nameOrOptions;
|
|
9522
9611
|
return {
|
|
9523
9612
|
name: resolved.name,
|
|
9524
9613
|
...resolved.instructions === undefined ? {} : { instructions: resolved.instructions },
|
|
9525
9614
|
toolkit: resolved.toolkit ?? Toolkit3.empty,
|
|
9526
|
-
policy: resolved.policy ?? defaultPolicy
|
|
9615
|
+
policy: resolved.policy ?? defaultPolicy,
|
|
9616
|
+
...resolved.model === undefined ? {} : { model: resolved.model },
|
|
9617
|
+
...resolved.memory === undefined ? {} : { memory: resolved.memory },
|
|
9618
|
+
...resolved.metadata === undefined ? {} : { metadata: resolved.metadata }
|
|
9527
9619
|
};
|
|
9528
9620
|
}
|
|
9529
9621
|
var defaultObjectPrompt = "Return the final structured output for the task above.";
|
|
@@ -9535,14 +9627,14 @@ var steeringDrainedEvent = (turn, queue, messages) => ({
|
|
|
9535
9627
|
});
|
|
9536
9628
|
var skillListingBudgetTokens = 2048;
|
|
9537
9629
|
var activateSkillToolName = "activate_skill";
|
|
9538
|
-
var activateSkillParameters =
|
|
9630
|
+
var activateSkillParameters = Schema48.Struct({ name: Schema48.String });
|
|
9539
9631
|
var activateSkillTool = Tool4.make(activateSkillToolName, {
|
|
9540
9632
|
description: "Load the full body for one listed Baton skill by name before applying that skill.",
|
|
9541
9633
|
parameters: activateSkillParameters,
|
|
9542
|
-
success:
|
|
9543
|
-
name:
|
|
9544
|
-
body:
|
|
9545
|
-
allowedTools:
|
|
9634
|
+
success: Schema48.Struct({
|
|
9635
|
+
name: Schema48.String,
|
|
9636
|
+
body: Schema48.String,
|
|
9637
|
+
allowedTools: Schema48.Array(Schema48.String)
|
|
9546
9638
|
})
|
|
9547
9639
|
});
|
|
9548
9640
|
var errorMessage = (error) => error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
@@ -9589,15 +9681,15 @@ var isUserMessagePart = (part) => part.type === "text" || part.type === "file";
|
|
|
9589
9681
|
var approvalRequired = (tool2, call, messages) => {
|
|
9590
9682
|
const needsApproval = tool2?.needsApproval;
|
|
9591
9683
|
if (needsApproval === undefined)
|
|
9592
|
-
return
|
|
9684
|
+
return Effect46.succeed(false);
|
|
9593
9685
|
if (typeof needsApproval === "boolean")
|
|
9594
|
-
return
|
|
9595
|
-
return
|
|
9686
|
+
return Effect46.succeed(needsApproval);
|
|
9687
|
+
return Effect46.suspend(() => {
|
|
9596
9688
|
const result = needsApproval(call.params, { toolCallId: call.id, messages });
|
|
9597
|
-
return
|
|
9598
|
-
}).pipe(
|
|
9689
|
+
return Effect46.isEffect(result) ? result : Effect46.succeed(result);
|
|
9690
|
+
}).pipe(Effect46.catchCause((cause) => Cause3.hasInterrupts(cause) ? Effect46.interrupt : Effect46.succeed(true)));
|
|
9599
9691
|
};
|
|
9600
|
-
var applyPromptChain = (chain, prompt, context) =>
|
|
9692
|
+
var applyPromptChain = (chain, prompt, context) => Effect46.gen(function* () {
|
|
9601
9693
|
let current2 = prompt;
|
|
9602
9694
|
for (const middleware of chain) {
|
|
9603
9695
|
if (middleware.transformPrompt !== undefined) {
|
|
@@ -9606,10 +9698,10 @@ var applyPromptChain = (chain, prompt, context) => Effect45.gen(function* () {
|
|
|
9606
9698
|
}
|
|
9607
9699
|
return current2;
|
|
9608
9700
|
});
|
|
9609
|
-
var applyPartChain = (chain, part, context) =>
|
|
9610
|
-
let current2 =
|
|
9701
|
+
var applyPartChain = (chain, part, context) => Effect46.gen(function* () {
|
|
9702
|
+
let current2 = Option16.some(part);
|
|
9611
9703
|
for (const middleware of chain) {
|
|
9612
|
-
if (
|
|
9704
|
+
if (Option16.isNone(current2))
|
|
9613
9705
|
break;
|
|
9614
9706
|
if (middleware.transformPart !== undefined) {
|
|
9615
9707
|
current2 = yield* middleware.transformPart(current2.value, context);
|
|
@@ -9617,74 +9709,83 @@ var applyPartChain = (chain, part, context) => Effect45.gen(function* () {
|
|
|
9617
9709
|
}
|
|
9618
9710
|
return current2;
|
|
9619
9711
|
});
|
|
9620
|
-
var streamInternal = (agent, options, structured) => Stream7.unwrap(
|
|
9621
|
-
const executor = yield*
|
|
9622
|
-
const approvals = yield*
|
|
9623
|
-
const chain = yield*
|
|
9712
|
+
var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect46.gen(function* () {
|
|
9713
|
+
const executor = yield* Effect46.serviceOption(ToolExecutor);
|
|
9714
|
+
const approvals = yield* Effect46.serviceOption(Approvals);
|
|
9715
|
+
const chain = yield* Effect46.serviceOption(ModelMiddleware).pipe(Effect46.map(Option16.match({ onNone: () => [], onSome: (service) => service })));
|
|
9624
9716
|
if (options.history !== undefined && options.persistence !== undefined) {
|
|
9625
|
-
return yield*
|
|
9717
|
+
return yield* Effect46.fail(new AgentError({
|
|
9626
9718
|
message: "RunOptions.history and RunOptions.persistence are mutually exclusive",
|
|
9627
9719
|
turn: 0
|
|
9628
9720
|
}));
|
|
9629
9721
|
}
|
|
9630
9722
|
if (options.toolOutputMaxBytes !== undefined && (!Number.isFinite(options.toolOutputMaxBytes) || options.toolOutputMaxBytes < 0)) {
|
|
9631
|
-
return yield*
|
|
9723
|
+
return yield* Effect46.fail(new AgentError({
|
|
9632
9724
|
message: "RunOptions.toolOutputMaxBytes must be a non-negative finite number",
|
|
9633
9725
|
turn: 0
|
|
9634
9726
|
}));
|
|
9635
9727
|
}
|
|
9636
9728
|
if (options.compaction?.contextWindow !== undefined && (!Number.isFinite(options.compaction.contextWindow) || options.compaction.contextWindow <= 0)) {
|
|
9637
|
-
return yield*
|
|
9729
|
+
return yield* Effect46.fail(new AgentError({
|
|
9638
9730
|
message: "RunOptions.compaction.contextWindow must be a positive finite number",
|
|
9639
9731
|
turn: 0
|
|
9640
9732
|
}));
|
|
9641
9733
|
}
|
|
9642
9734
|
const sessionId = options.sessionId ?? "local";
|
|
9643
|
-
const instructionsService = yield*
|
|
9644
|
-
const skillSourceService = yield*
|
|
9645
|
-
const skillRuntime =
|
|
9735
|
+
const instructionsService = yield* Effect46.serviceOption(Instructions);
|
|
9736
|
+
const skillSourceService = yield* Effect46.serviceOption(SkillSource);
|
|
9737
|
+
const skillRuntime = Option16.isNone(skillSourceService) ? undefined : {
|
|
9646
9738
|
source: skillSourceService.value,
|
|
9647
|
-
skills: yield* skillSourceService.value.all.pipe(
|
|
9739
|
+
skills: yield* skillSourceService.value.all.pipe(Effect46.mapError((error) => new AgentError({ message: error.message, turn: 0, cause: error })))
|
|
9648
9740
|
};
|
|
9649
9741
|
const selectedSkills = skillRuntime === undefined ? [] : selectListings(skillRuntime.skills, skillListingBudgetTokens, []);
|
|
9650
9742
|
const skillListings = selectedSkills.map((skill) => skill.listing).join(`
|
|
9651
9743
|
`);
|
|
9652
9744
|
const hasActivatableSkills = selectedSkills.length > 0;
|
|
9653
|
-
const instructionsEpoch = options.system === undefined && options.history === undefined &&
|
|
9745
|
+
const instructionsEpoch = options.system === undefined && options.history === undefined && Option16.isSome(instructionsService) ? yield* openEpoch(instructionsService.value, { agentName: agent.name, turn: 0 }) : undefined;
|
|
9654
9746
|
const baseSystem = options.system ?? (instructionsEpoch === undefined ? agent.instructions : instructionsEpoch.baseline.length === 0 ? agent.instructions : instructionsEpoch.baseline);
|
|
9655
9747
|
const system = appendInstructionFragment(baseSystem, options.history === undefined && skillListings.length > 0 ? skillListingsInstructions(skillListings) : undefined);
|
|
9656
|
-
const persistenceService = yield*
|
|
9657
|
-
const resilienceService = yield*
|
|
9658
|
-
const
|
|
9659
|
-
const
|
|
9660
|
-
const
|
|
9661
|
-
const
|
|
9662
|
-
const
|
|
9663
|
-
const
|
|
9748
|
+
const persistenceService = yield* Effect46.serviceOption(Chat.Persistence);
|
|
9749
|
+
const resilienceService = yield* Effect46.serviceOption(ModelResilience);
|
|
9750
|
+
const modelRegistryService = yield* Effect46.serviceOption(Service29);
|
|
9751
|
+
const permissionsService = yield* Effect46.serviceOption(Permissions);
|
|
9752
|
+
const steeringService = yield* Effect46.serviceOption(Steering);
|
|
9753
|
+
const compactionService = yield* Effect46.serviceOption(Compaction);
|
|
9754
|
+
const memoryService = yield* Effect46.serviceOption(Memory);
|
|
9755
|
+
const sessionService = yield* Effect46.serviceOption(SessionStore);
|
|
9756
|
+
const tokenizerService = yield* Effect46.serviceOption(Tokenizer2.Tokenizer);
|
|
9664
9757
|
const persistenceOptions = options.persistence;
|
|
9665
|
-
const memoryOptions = options.memory;
|
|
9758
|
+
const memoryOptions = options.memory ?? (agent.memory === undefined ? undefined : { key: agent.memory });
|
|
9759
|
+
const agentModel = agent.model;
|
|
9760
|
+
const agentModelContext = agentModel === undefined ? undefined : yield* Option16.match(modelRegistryService, {
|
|
9761
|
+
onNone: () => Effect46.fail(new AgentError({
|
|
9762
|
+
message: "Agent.model requires ModelRegistry in context",
|
|
9763
|
+
turn: 0
|
|
9764
|
+
})),
|
|
9765
|
+
onSome: (registry) => registry.provide(agentModel, Effect46.context()).pipe(Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })))
|
|
9766
|
+
});
|
|
9666
9767
|
const memoryRuntime = memoryOptions === undefined ? undefined : {
|
|
9667
9768
|
key: memoryOptions.key,
|
|
9668
|
-
service: yield*
|
|
9669
|
-
onNone: () =>
|
|
9670
|
-
message: "RunOptions.memory requires Memory in context",
|
|
9769
|
+
service: yield* Option16.match(memoryService, {
|
|
9770
|
+
onNone: () => Effect46.fail(new AgentError({
|
|
9771
|
+
message: options.memory === undefined ? "Agent.memory requires Memory in context" : "RunOptions.memory requires Memory in context",
|
|
9671
9772
|
turn: 0
|
|
9672
9773
|
})),
|
|
9673
|
-
onSome:
|
|
9774
|
+
onSome: Effect46.succeed
|
|
9674
9775
|
})
|
|
9675
9776
|
};
|
|
9676
|
-
const persisted = persistenceOptions === undefined ? undefined : yield*
|
|
9677
|
-
onNone: () =>
|
|
9777
|
+
const persisted = persistenceOptions === undefined ? undefined : yield* Option16.match(persistenceService, {
|
|
9778
|
+
onNone: () => Effect46.fail(new AgentError({
|
|
9678
9779
|
message: "RunOptions.persistence requires Chat.Persistence in context",
|
|
9679
9780
|
turn: 0
|
|
9680
9781
|
})),
|
|
9681
|
-
onSome: (service) => service.getOrCreate(persistenceOptions.chatId, persistenceOptions.timeToLive === undefined ? undefined : { timeToLive: persistenceOptions.timeToLive }).pipe(
|
|
9782
|
+
onSome: (service) => service.getOrCreate(persistenceOptions.chatId, persistenceOptions.timeToLive === undefined ? undefined : { timeToLive: persistenceOptions.timeToLive }).pipe(Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })))
|
|
9682
9783
|
});
|
|
9683
|
-
const seedSystem = persisted !== undefined && system !== undefined && (yield*
|
|
9784
|
+
const seedSystem = persisted !== undefined && system !== undefined && (yield* Ref11.get(persisted.history)).content.length === 0 ? system : undefined;
|
|
9684
9785
|
const freshChat = options.history !== undefined ? Chat.fromPrompt(options.history) : system !== undefined ? Chat.fromPrompt([Prompt4.makeMessage("system", { content: system })]) : Chat.empty;
|
|
9685
9786
|
const chat = persisted ?? (yield* freshChat);
|
|
9686
|
-
const savePersisted = persisted === undefined ?
|
|
9687
|
-
const failSuspended = (call, token, reason) => Stream7.unwrap(savePersisted.pipe(
|
|
9787
|
+
const savePersisted = persisted === undefined ? Effect46.void : persisted.save.pipe(Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })));
|
|
9788
|
+
const failSuspended = (call, token, reason) => Stream7.unwrap(savePersisted.pipe(Effect46.as(Stream7.fail(suspended(call, token, reason)))));
|
|
9688
9789
|
const state = {
|
|
9689
9790
|
text: "",
|
|
9690
9791
|
turn: 0,
|
|
@@ -9697,20 +9798,20 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9697
9798
|
const activatedSkillTools = new Map;
|
|
9698
9799
|
let sessionSyncedMessages = 0;
|
|
9699
9800
|
let sessionInitialized = false;
|
|
9700
|
-
const activeSession =
|
|
9801
|
+
const activeSession = Option16.isSome(compactionService) ? sessionService : Option16.none();
|
|
9701
9802
|
const sessionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
|
|
9702
9803
|
const compactionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
|
|
9703
9804
|
const memoryError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
|
|
9704
9805
|
const skillError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
|
|
9705
9806
|
const isSkillActivationCall = (call) => call.name === activateSkillToolName && skillRuntime !== undefined && hasActivatableSkills;
|
|
9706
|
-
const insertRecalledItems = (turn, prompt, items) =>
|
|
9807
|
+
const insertRecalledItems = (turn, prompt, items) => Effect46.gen(function* () {
|
|
9707
9808
|
const parts = items.flatMap((item) => item.parts);
|
|
9708
9809
|
if (parts.length === 0)
|
|
9709
9810
|
return prompt;
|
|
9710
9811
|
const userParts = [];
|
|
9711
9812
|
for (const part of parts) {
|
|
9712
9813
|
if (!isUserMessagePart(part)) {
|
|
9713
|
-
return yield*
|
|
9814
|
+
return yield* Effect46.fail(new AgentError({
|
|
9714
9815
|
message: `Memory recalled unsupported prompt part type: ${part.type}`,
|
|
9715
9816
|
turn
|
|
9716
9817
|
}));
|
|
@@ -9721,12 +9822,12 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9721
9822
|
const [first, ...rest] = prompt.content;
|
|
9722
9823
|
return first?.role === "system" ? Prompt4.fromMessages([first, memoryMessage2, ...rest]) : Prompt4.fromMessages([memoryMessage2, ...prompt.content]);
|
|
9723
9824
|
});
|
|
9724
|
-
const recallInitialPrompt = (prompt) => memoryRuntime === undefined ?
|
|
9725
|
-
const rememberTurn = (turn, transcript, terminal) => memoryRuntime === undefined ?
|
|
9726
|
-
const syncSession = (turn, transcript) =>
|
|
9727
|
-
onNone: () =>
|
|
9728
|
-
onSome: (session) =>
|
|
9729
|
-
const existingPath = yield* session.path().pipe(
|
|
9825
|
+
const recallInitialPrompt = (prompt) => memoryRuntime === undefined ? Effect46.succeed(prompt) : memoryRuntime.service.recall({ key: memoryRuntime.key, turn: 0, prompt }).pipe(Effect46.mapError((error) => memoryError(0, error)), Effect46.flatMap((items) => insertRecalledItems(0, prompt, items)));
|
|
9826
|
+
const rememberTurn = (turn, transcript, terminal) => memoryRuntime === undefined ? Effect46.void : memoryRuntime.service.remember({ key: memoryRuntime.key, turn, transcript, terminal }).pipe(Effect46.mapError((error) => memoryError(turn, error)));
|
|
9827
|
+
const syncSession = (turn, transcript) => Option16.match(activeSession, {
|
|
9828
|
+
onNone: () => Effect46.succeed([]),
|
|
9829
|
+
onSome: (session) => Effect46.gen(function* () {
|
|
9830
|
+
const existingPath = yield* session.path().pipe(Effect46.mapError((error) => sessionError(turn, error)));
|
|
9730
9831
|
if (!sessionInitialized) {
|
|
9731
9832
|
sessionInitialized = true;
|
|
9732
9833
|
if (existingPath.length > 0) {
|
|
@@ -9735,40 +9836,40 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9735
9836
|
}
|
|
9736
9837
|
}
|
|
9737
9838
|
for (const message of transcript.content.slice(sessionSyncedMessages)) {
|
|
9738
|
-
yield* session.append({ _tag: "Message", message }).pipe(
|
|
9839
|
+
yield* session.append({ _tag: "Message", message }).pipe(Effect46.mapError((error) => sessionError(turn, error)));
|
|
9739
9840
|
}
|
|
9740
9841
|
sessionSyncedMessages = transcript.content.length;
|
|
9741
|
-
return yield* session.path().pipe(
|
|
9842
|
+
return yield* session.path().pipe(Effect46.mapError((error) => sessionError(turn, error)));
|
|
9742
9843
|
})
|
|
9743
9844
|
});
|
|
9744
9845
|
const countTokens = (turn, prompt) => {
|
|
9745
9846
|
if (state.contextTokens !== undefined)
|
|
9746
|
-
return
|
|
9747
|
-
return
|
|
9748
|
-
onNone: () =>
|
|
9749
|
-
onSome: (tokenizer) => tokenizer.tokenize(prompt).pipe(
|
|
9847
|
+
return Effect46.succeed(state.contextTokens);
|
|
9848
|
+
return Option16.match(tokenizerService, {
|
|
9849
|
+
onNone: () => Effect46.succeed(0),
|
|
9850
|
+
onSome: (tokenizer) => tokenizer.tokenize(prompt).pipe(Effect46.map((tokens) => tokens.length), Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn, cause: error })))
|
|
9750
9851
|
});
|
|
9751
9852
|
};
|
|
9752
|
-
const compactionUsage = (turn, history, prompt) => countTokens(turn, Prompt4.concat(history, prompt)).pipe(
|
|
9853
|
+
const compactionUsage = (turn, history, prompt) => countTokens(turn, Prompt4.concat(history, prompt)).pipe(Effect46.map((contextTokens) => ({
|
|
9753
9854
|
contextTokens,
|
|
9754
9855
|
contextWindow: options.compaction?.contextWindow ?? Number.POSITIVE_INFINITY,
|
|
9755
9856
|
reserveTokens: DEFAULT_RESERVE_TOKENS
|
|
9756
9857
|
})));
|
|
9757
|
-
const applyCompactionResult = (turn, result) =>
|
|
9758
|
-
yield*
|
|
9858
|
+
const applyCompactionResult = (turn, result) => Effect46.gen(function* () {
|
|
9859
|
+
yield* Ref11.set(chat.history, result.history);
|
|
9759
9860
|
sessionSyncedMessages = result.history.content.length;
|
|
9760
|
-
if (result._tag === "Summarize" &&
|
|
9861
|
+
if (result._tag === "Summarize" && Option16.isSome(activeSession)) {
|
|
9761
9862
|
yield* activeSession.value.append({
|
|
9762
9863
|
_tag: "Compaction",
|
|
9763
9864
|
summary: result.summary,
|
|
9764
9865
|
firstKeptEntryId: result.firstKeptEntryId
|
|
9765
|
-
}).pipe(
|
|
9866
|
+
}).pipe(Effect46.mapError((error) => sessionError(turn, error)));
|
|
9766
9867
|
}
|
|
9767
9868
|
});
|
|
9768
|
-
const preparePrompt = (turn, prompt, overflow) =>
|
|
9769
|
-
onNone: () =>
|
|
9770
|
-
onSome: (compaction) =>
|
|
9771
|
-
const history = yield*
|
|
9869
|
+
const preparePrompt = (turn, prompt, overflow) => Option16.match(compactionService, {
|
|
9870
|
+
onNone: () => Effect46.succeed(prompt),
|
|
9871
|
+
onSome: (compaction) => Effect46.gen(function* () {
|
|
9872
|
+
const history = yield* Ref11.get(chat.history);
|
|
9772
9873
|
const path2 = yield* syncSession(turn, history);
|
|
9773
9874
|
const usage = yield* compactionUsage(turn, history, prompt);
|
|
9774
9875
|
const compacted = yield* compaction.maybeCompact({
|
|
@@ -9781,28 +9882,28 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9781
9882
|
usage,
|
|
9782
9883
|
overflow,
|
|
9783
9884
|
...options.toolOutputMaxBytes === undefined ? {} : { toolOutputMaxBytes: options.toolOutputMaxBytes }
|
|
9784
|
-
}).pipe(
|
|
9785
|
-
if (
|
|
9885
|
+
}).pipe(Effect46.mapError((error) => compactionError(turn, error)));
|
|
9886
|
+
if (Option16.isNone(compacted))
|
|
9786
9887
|
return prompt;
|
|
9787
9888
|
yield* applyCompactionResult(turn, compacted.value);
|
|
9788
9889
|
return compacted.value.prompt;
|
|
9789
9890
|
})
|
|
9790
9891
|
});
|
|
9791
|
-
const boundedSuccessResult = (turn, call, outcome) => (options.toolOutputMaxBytes === undefined ?
|
|
9892
|
+
const boundedSuccessResult = (turn, call, outcome) => (options.toolOutputMaxBytes === undefined ? Effect46.succeed(outcome) : bound(outcome, { toolCallId: call.id, maxBytes: options.toolOutputMaxBytes }).pipe(Effect46.mapError((error) => new AgentError({ message: error.message, turn, cause: error })))).pipe(Effect46.map((bounded) => successResult(call, bounded)));
|
|
9792
9893
|
const outcomeEvents = (turn, call, outcome) => {
|
|
9793
9894
|
switch (outcome._tag) {
|
|
9794
9895
|
case "Success":
|
|
9795
|
-
return (isSkillActivationCall(call) ?
|
|
9896
|
+
return (isSkillActivationCall(call) ? Effect46.succeed(successResult(call, outcome)) : boundedSuccessResult(turn, call, outcome)).pipe(Effect46.map((result) => {
|
|
9796
9897
|
state.pending.push(result);
|
|
9797
9898
|
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9798
9899
|
}));
|
|
9799
9900
|
case "Failure": {
|
|
9800
9901
|
const result = failedResult(call, outcome.message);
|
|
9801
9902
|
state.pending.push(result);
|
|
9802
|
-
return
|
|
9903
|
+
return Effect46.succeed(Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]));
|
|
9803
9904
|
}
|
|
9804
9905
|
case "Suspend":
|
|
9805
|
-
return
|
|
9906
|
+
return Effect46.succeed(failSuspended(call, outcome.token, "tool-wait"));
|
|
9806
9907
|
}
|
|
9807
9908
|
};
|
|
9808
9909
|
const defaultExecute = (request) => {
|
|
@@ -9810,11 +9911,11 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9810
9911
|
return executeToolkit(agent.toolkit, request);
|
|
9811
9912
|
}
|
|
9812
9913
|
const activated = activatedSkillTools.get(request.call.name);
|
|
9813
|
-
return activated === undefined ?
|
|
9914
|
+
return activated === undefined ? Effect46.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(Toolkit3.make(activated), request);
|
|
9814
9915
|
};
|
|
9815
|
-
const executeApproved = (turn, call, request) => Stream7.concat(Stream7.fromIterable([{ _tag: "ToolExecutionStarted", turn, call }]), Stream7.unwrap(
|
|
9916
|
+
const executeApproved = (turn, call, request) => Stream7.concat(Stream7.fromIterable([{ _tag: "ToolExecutionStarted", turn, call }]), Stream7.unwrap(Effect46.gen(function* () {
|
|
9816
9917
|
const progressQueue = yield* Queue2.unbounded();
|
|
9817
|
-
const signal = yield*
|
|
9918
|
+
const signal = yield* Effect46.abortSignal;
|
|
9818
9919
|
const context = ToolContext.of({
|
|
9819
9920
|
signal,
|
|
9820
9921
|
sessionId,
|
|
@@ -9826,14 +9927,14 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9826
9927
|
...progress.message === undefined ? {} : { message: progress.message },
|
|
9827
9928
|
...progress.data === undefined ? {} : { data: progress.data }
|
|
9828
9929
|
};
|
|
9829
|
-
return Queue2.offer(progressQueue, event).pipe(
|
|
9930
|
+
return Queue2.offer(progressQueue, event).pipe(Effect46.asVoid);
|
|
9830
9931
|
}
|
|
9831
9932
|
});
|
|
9832
|
-
const execution = isSkillActivationCall(call) ? activateSkillOutcome(turn, call) :
|
|
9933
|
+
const execution = isSkillActivationCall(call) ? activateSkillOutcome(turn, call) : Option16.match(executor, {
|
|
9833
9934
|
onNone: () => defaultExecute(request),
|
|
9834
9935
|
onSome: (service) => service.execute(request)
|
|
9835
9936
|
});
|
|
9836
|
-
const fiber = yield* execution.pipe(
|
|
9937
|
+
const fiber = yield* execution.pipe(Effect46.provideService(ToolContext, context), Effect46.ensuring(Queue2.end(progressQueue).pipe(Effect46.asVoid)), Effect46.forkScoped({ startImmediately: true }));
|
|
9837
9938
|
return Stream7.concat(Stream7.fromQueue(progressQueue), Stream7.fromEffect(Fiber.join(fiber)).pipe(Stream7.flatMap((outcome) => Stream7.unwrap(outcomeEvents(turn, call, outcome)))));
|
|
9838
9939
|
})));
|
|
9839
9940
|
const permissionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
|
|
@@ -9842,13 +9943,13 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9842
9943
|
state.pending.push(result);
|
|
9843
9944
|
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9844
9945
|
};
|
|
9845
|
-
const activateSkillOutcome = (turn, call) =>
|
|
9946
|
+
const activateSkillOutcome = (turn, call) => Effect46.gen(function* () {
|
|
9846
9947
|
if (skillRuntime === undefined)
|
|
9847
9948
|
return { _tag: "Failure", message: "SkillSource is not available" };
|
|
9848
|
-
const params =
|
|
9849
|
-
if (
|
|
9949
|
+
const params = Schema48.decodeUnknownOption(activateSkillParameters)(call.params);
|
|
9950
|
+
if (Option16.isNone(params))
|
|
9850
9951
|
return { _tag: "Failure", message: "Skill activation requires a name" };
|
|
9851
|
-
const skill = yield* skillRuntime.source.get(params.value.name).pipe(
|
|
9952
|
+
const skill = yield* skillRuntime.source.get(params.value.name).pipe(Effect46.mapError((error) => skillError(turn, error)));
|
|
9852
9953
|
if (skill === undefined)
|
|
9853
9954
|
return { _tag: "Failure", message: `Skill not found: ${params.value.name}` };
|
|
9854
9955
|
if (skill.frontmatter.disableModelInvocation === true) {
|
|
@@ -9856,7 +9957,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9856
9957
|
}
|
|
9857
9958
|
let body = activatedSkillBodies.get(skill.frontmatter.name);
|
|
9858
9959
|
if (body === undefined) {
|
|
9859
|
-
body = yield* skill.body.pipe(
|
|
9960
|
+
body = yield* skill.body.pipe(Effect46.mapError((error) => skillError(turn, error)));
|
|
9860
9961
|
activatedSkillBodies.set(skill.frontmatter.name, body);
|
|
9861
9962
|
for (const tool2 of skill.tools) {
|
|
9862
9963
|
activatedSkillTools.set(tool2.name, tool2);
|
|
@@ -9869,14 +9970,14 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9869
9970
|
};
|
|
9870
9971
|
return { _tag: "Success", result: output, encodedResult: output };
|
|
9871
9972
|
});
|
|
9872
|
-
const rememberAlways = (turn, call) =>
|
|
9873
|
-
onNone: () =>
|
|
9874
|
-
onSome: (store) => store.remember({ pattern: call.name, level: "allow" }).pipe(
|
|
9973
|
+
const rememberAlways = (turn, call) => Effect46.serviceOption(RuleStore).pipe(Effect46.flatMap(Option16.match({
|
|
9974
|
+
onNone: () => Effect46.void,
|
|
9975
|
+
onSome: (store) => store.remember({ pattern: call.name, level: "allow" }).pipe(Effect46.mapError((error) => permissionError(turn, error)))
|
|
9875
9976
|
})));
|
|
9876
|
-
const approvalEvents = (turn, call, messages, request, tool2) => Stream7.unwrap(approvalRequired(tool2, call, messages).pipe(
|
|
9977
|
+
const approvalEvents = (turn, call, messages, request, tool2) => Stream7.unwrap(approvalRequired(tool2, call, messages).pipe(Effect46.map((isRequired) => {
|
|
9877
9978
|
if (!isRequired)
|
|
9878
9979
|
return executeApproved(turn, call, request);
|
|
9879
|
-
if (
|
|
9980
|
+
if (Option16.isNone(approvals)) {
|
|
9880
9981
|
const result = failedResult(call, "Approvals service is required for approval-gated tools");
|
|
9881
9982
|
state.pending.push(result);
|
|
9882
9983
|
return Stream7.fromIterable([
|
|
@@ -9884,7 +9985,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9884
9985
|
{ _tag: "ToolExecutionCompleted", turn, call, result }
|
|
9885
9986
|
]);
|
|
9886
9987
|
}
|
|
9887
|
-
return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(approvals.value.check(request).pipe(
|
|
9988
|
+
return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(approvals.value.check(request).pipe(Effect46.map((decision2) => {
|
|
9888
9989
|
switch (decision2._tag) {
|
|
9889
9990
|
case "Approved":
|
|
9890
9991
|
return executeApproved(turn, call, request);
|
|
@@ -9905,7 +10006,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9905
10006
|
case "Denied":
|
|
9906
10007
|
return permissionDeniedEvents(turn, call, answer.reason);
|
|
9907
10008
|
case "Always":
|
|
9908
|
-
return Stream7.unwrap(rememberAlways(turn, call).pipe(
|
|
10009
|
+
return Stream7.unwrap(rememberAlways(turn, call).pipe(Effect46.as(executeApproved(turn, call, request))));
|
|
9909
10010
|
}
|
|
9910
10011
|
};
|
|
9911
10012
|
const permissionAskEvents = (turn, call, request, token) => {
|
|
@@ -9917,9 +10018,9 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9917
10018
|
turn,
|
|
9918
10019
|
toolCallId: call.id
|
|
9919
10020
|
};
|
|
9920
|
-
if (
|
|
10021
|
+
if (Option16.isNone(permissionsService))
|
|
9921
10022
|
return failSuspended(call, token, "approval");
|
|
9922
|
-
return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(permissionsService.value.await(pending).pipe(
|
|
10023
|
+
return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(permissionsService.value.await(pending).pipe(Effect46.mapError((error) => permissionError(turn, error)), Effect46.map(Option16.match({
|
|
9923
10024
|
onNone: () => failSuspended(call, token, "approval"),
|
|
9924
10025
|
onSome: (answer) => permissionAnsweredEvents(turn, call, request, answer)
|
|
9925
10026
|
})))));
|
|
@@ -9927,7 +10028,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9927
10028
|
const toolCallEvents = (turn, call, messages) => {
|
|
9928
10029
|
const request = { call, turn, agentName: agent.name, sessionId };
|
|
9929
10030
|
const tool2 = currentToolkit().tools[call.name];
|
|
9930
|
-
if (
|
|
10031
|
+
if (Option16.isNone(permissionsService))
|
|
9931
10032
|
return approvalEvents(turn, call, messages, request, tool2);
|
|
9932
10033
|
return Stream7.unwrap(permissionsService.value.evaluate({
|
|
9933
10034
|
tool: call.name,
|
|
@@ -9936,7 +10037,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9936
10037
|
turn,
|
|
9937
10038
|
toolCallId: call.id,
|
|
9938
10039
|
sessionId
|
|
9939
|
-
}).pipe(
|
|
10040
|
+
}).pipe(Effect46.mapError((error) => permissionError(turn, error)), Effect46.map((decision2) => {
|
|
9940
10041
|
switch (decision2._tag) {
|
|
9941
10042
|
case "Allow":
|
|
9942
10043
|
return approvalEvents(turn, call, messages, request, tool2);
|
|
@@ -9947,8 +10048,8 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9947
10048
|
}
|
|
9948
10049
|
})));
|
|
9949
10050
|
};
|
|
9950
|
-
const captureFinishPart = (part) =>
|
|
9951
|
-
const span = yield*
|
|
10051
|
+
const captureFinishPart = (part) => Effect46.gen(function* () {
|
|
10052
|
+
const span = yield* Effect46.currentSpan;
|
|
9952
10053
|
state.finish = {
|
|
9953
10054
|
usage: state.finish === undefined ? part.usage : addUsage(state.finish.usage, part.usage),
|
|
9954
10055
|
reason: part.reason
|
|
@@ -9963,18 +10064,20 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9963
10064
|
},
|
|
9964
10065
|
response: { finishReasons: [part.reason] }
|
|
9965
10066
|
});
|
|
9966
|
-
}).pipe(
|
|
9967
|
-
const captureStructuredUsage = (content) =>
|
|
10067
|
+
}).pipe(Effect46.orDie);
|
|
10068
|
+
const captureStructuredUsage = (content) => Effect46.sync(() => {
|
|
9968
10069
|
for (const part of content) {
|
|
9969
10070
|
if (part.type === "finish") {
|
|
9970
10071
|
state.usage = state.usage === undefined ? part.usage : addUsage(state.usage, part.usage);
|
|
9971
10072
|
}
|
|
9972
10073
|
}
|
|
9973
10074
|
});
|
|
9974
|
-
const withModelResilience = (effect) =>
|
|
10075
|
+
const withModelResilience = (effect) => Option16.match(resilienceService, {
|
|
9975
10076
|
onNone: () => effect,
|
|
9976
|
-
onSome: (resilience) =>
|
|
10077
|
+
onSome: (resilience) => Effect46.flatMap(LanguageModel4.LanguageModel, (model) => effect.pipe(Effect46.provideService(LanguageModel4.LanguageModel, apply(model, resilience))))
|
|
9977
10078
|
});
|
|
10079
|
+
const withAgentModel = (effect) => agentModelContext === undefined ? effect : effect.pipe(Effect46.provide(agentModelContext));
|
|
10080
|
+
const provideAgentModel = (stream2) => agentModelContext === undefined ? stream2 : stream2.pipe(Stream7.provideContext(agentModelContext));
|
|
9978
10081
|
const partEvents = (turn, part, messages) => {
|
|
9979
10082
|
if (part.type === "error") {
|
|
9980
10083
|
return Stream7.fail(new AgentError({ message: errorMessage(part.error), turn, cause: part.error }));
|
|
@@ -9992,7 +10095,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
9992
10095
|
}
|
|
9993
10096
|
return modelPart;
|
|
9994
10097
|
};
|
|
9995
|
-
const applyPartToEvents = (turn, part, messages) => Stream7.unwrap(applyPartChain(chain, part, { agentName: agent.name, turn }).pipe(
|
|
10098
|
+
const applyPartToEvents = (turn, part, messages) => Stream7.unwrap(applyPartChain(chain, part, { agentName: agent.name, turn }).pipe(Effect46.map(Option16.match({
|
|
9996
10099
|
onSome: (transformed) => partEvents(turn, transformed, messages),
|
|
9997
10100
|
onNone: () => part.type === "tool-call" ? Stream7.fail(new MiddlewareViolation({
|
|
9998
10101
|
turn,
|
|
@@ -10003,18 +10106,18 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
10003
10106
|
const activeToolkit = (activeTools) => Toolkit3.make(...Object.values(currentToolkit().tools).filter((tool2) => activeTools.includes(tool2.name)));
|
|
10004
10107
|
const modelTurn = (turn, prompt, overrides) => {
|
|
10005
10108
|
const toolkit = overrides?.activeTools === undefined ? currentToolkit() : activeToolkit(overrides.activeTools);
|
|
10006
|
-
const attempt = (activePrompt, retryOverflow) => Stream7.unwrap(
|
|
10109
|
+
const attempt = (activePrompt, retryOverflow) => Stream7.unwrap(Ref11.get(chat.history).pipe(Effect46.map((historyBeforeAttempt) => {
|
|
10007
10110
|
let emitted = false;
|
|
10008
10111
|
const messages = Prompt4.concat(historyBeforeAttempt, activePrompt).content;
|
|
10009
|
-
return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(Stream7.map((part) => ({ part, messages })), Stream7.tap(() =>
|
|
10112
|
+
return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(Stream7.map((part) => ({ part, messages })), Stream7.tap(() => Effect46.sync(() => {
|
|
10010
10113
|
emitted = true;
|
|
10011
10114
|
})), Stream7.catchCause((cause) => {
|
|
10012
10115
|
if (Cause3.hasInterrupts(cause))
|
|
10013
|
-
return Stream7.fromEffect(
|
|
10116
|
+
return Stream7.fromEffect(Effect46.interrupt);
|
|
10014
10117
|
const error = Cause3.squash(cause);
|
|
10015
|
-
if (retryOverflow && !emitted && isContextOverflow(error) &&
|
|
10016
|
-
return Stream7.unwrap(
|
|
10017
|
-
yield*
|
|
10118
|
+
if (retryOverflow && !emitted && isContextOverflow(error) && Option16.isSome(compactionService)) {
|
|
10119
|
+
return Stream7.unwrap(Effect46.gen(function* () {
|
|
10120
|
+
yield* Ref11.set(chat.history, historyBeforeAttempt);
|
|
10018
10121
|
const compactedPrompt = yield* preparePrompt(turn, activePrompt, true);
|
|
10019
10122
|
return attempt(compactedPrompt, false);
|
|
10020
10123
|
}));
|
|
@@ -10022,12 +10125,12 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
10022
10125
|
return Stream7.make({ part: Response3.makePart("error", { error }), messages });
|
|
10023
10126
|
}));
|
|
10024
10127
|
})));
|
|
10025
|
-
const parts = Stream7.unwrap(applyPromptChain(chain, Prompt4.make(prompt), { agentName: agent.name, turn }).pipe(
|
|
10026
|
-
const resilientParts =
|
|
10128
|
+
const parts = Stream7.unwrap(applyPromptChain(chain, Prompt4.make(prompt), { agentName: agent.name, turn }).pipe(Effect46.flatMap((transformedPrompt) => preparePrompt(turn, transformedPrompt, false)), Effect46.map((preparedPrompt) => attempt(preparedPrompt, true).pipe(Stream7.flatMap(({ part, messages }) => applyPartToEvents(turn, part, messages))))));
|
|
10129
|
+
const resilientParts = Option16.match(resilienceService, {
|
|
10027
10130
|
onNone: () => parts,
|
|
10028
|
-
onSome: (resilience) => Stream7.unwrap(
|
|
10131
|
+
onSome: (resilience) => Stream7.unwrap(LanguageModel4.LanguageModel.pipe(Effect46.map((model) => parts.pipe(Stream7.provideService(LanguageModel4.LanguageModel, apply(model, resilience))))))
|
|
10029
10132
|
});
|
|
10030
|
-
return overrides?.model === undefined ? resilientParts : resilientParts.pipe(Stream7.provide(overrides.model));
|
|
10133
|
+
return overrides?.model === undefined ? provideAgentModel(resilientParts) : resilientParts.pipe(Stream7.provide(overrides.model));
|
|
10031
10134
|
};
|
|
10032
10135
|
const turnCompletedEvent = (turn, transcript) => ({
|
|
10033
10136
|
_tag: "TurnCompleted",
|
|
@@ -10042,21 +10145,21 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
10042
10145
|
transcript,
|
|
10043
10146
|
...state.usage === undefined ? {} : { usage: state.usage }
|
|
10044
10147
|
});
|
|
10045
|
-
const structuredFinalEvents = (turn, config) => Stream7.fromEffect(
|
|
10148
|
+
const structuredFinalEvents = (turn, config) => Stream7.fromEffect(Effect46.gen(function* () {
|
|
10046
10149
|
const structuredTurn = turn + 1;
|
|
10047
10150
|
const transformedPrompt = yield* applyPromptChain(chain, Prompt4.make(config.objectPrompt), {
|
|
10048
10151
|
agentName: agent.name,
|
|
10049
10152
|
turn: structuredTurn
|
|
10050
10153
|
});
|
|
10051
|
-
const response = yield* withModelResilience(chat.generateObject({
|
|
10154
|
+
const response = yield* withAgentModel(withModelResilience(chat.generateObject({
|
|
10052
10155
|
prompt: transformedPrompt,
|
|
10053
10156
|
schema: config.schema,
|
|
10054
10157
|
objectName: config.objectName,
|
|
10055
10158
|
toolChoice: "none"
|
|
10056
|
-
})).pipe(
|
|
10159
|
+
}))).pipe(Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn: structuredTurn, cause: error })));
|
|
10057
10160
|
yield* captureStructuredUsage(response.content);
|
|
10058
10161
|
yield* savePersisted;
|
|
10059
|
-
const transcript = yield*
|
|
10162
|
+
const transcript = yield* Ref11.get(chat.history);
|
|
10060
10163
|
const structuredOutput = {
|
|
10061
10164
|
_tag: "StructuredOutput",
|
|
10062
10165
|
turn: structuredTurn,
|
|
@@ -10066,16 +10169,16 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
10066
10169
|
return [structuredOutput, terminalCompletedEvent(structuredTurn, transcript)];
|
|
10067
10170
|
})).pipe(Stream7.flatMap((events) => Stream7.fromIterable(events)));
|
|
10068
10171
|
const promptFromSteeringMessages = (messages) => messages.reduce((prompt, message) => Prompt4.concat(prompt, message.prompt), Prompt4.empty);
|
|
10069
|
-
const takeSteering = () =>
|
|
10070
|
-
onNone: () =>
|
|
10172
|
+
const takeSteering = () => Option16.match(steeringService, {
|
|
10173
|
+
onNone: () => Effect46.succeed([]),
|
|
10071
10174
|
onSome: (service) => service.takeSteering()
|
|
10072
10175
|
});
|
|
10073
|
-
const takeFollowUp = () =>
|
|
10074
|
-
onNone: () =>
|
|
10176
|
+
const takeFollowUp = () => Option16.match(steeringService, {
|
|
10177
|
+
onNone: () => Effect46.succeed([]),
|
|
10075
10178
|
onSome: (service) => service.takeFollowUp()
|
|
10076
10179
|
});
|
|
10077
|
-
const afterTurn = (turn) =>
|
|
10078
|
-
const transcript = yield*
|
|
10180
|
+
const afterTurn = (turn) => Effect46.gen(function* () {
|
|
10181
|
+
const transcript = yield* Ref11.get(chat.history);
|
|
10079
10182
|
yield* syncSession(turn, transcript);
|
|
10080
10183
|
const pending = state.pending;
|
|
10081
10184
|
yield* rememberTurn(turn, transcript, pending.length === 0);
|
|
@@ -10130,7 +10233,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
10130
10233
|
}).pipe(Stream7.drain);
|
|
10131
10234
|
const runTurn = (turn, prompt, overrides) => {
|
|
10132
10235
|
let next;
|
|
10133
|
-
const currentTurn = Stream7.fromIterable([{ _tag: "TurnStarted", turn }]).pipe(Stream7.concat(resetTurnState(turn)), Stream7.concat(modelTurn(turn, prompt, overrides)), Stream7.concat(Stream7.unwrap(afterTurn(turn).pipe(
|
|
10236
|
+
const currentTurn = Stream7.fromIterable([{ _tag: "TurnStarted", turn }]).pipe(Stream7.concat(resetTurnState(turn)), Stream7.concat(modelTurn(turn, prompt, overrides)), Stream7.concat(Stream7.unwrap(afterTurn(turn).pipe(Effect46.map((result) => {
|
|
10134
10237
|
next = result.next;
|
|
10135
10238
|
return result.events;
|
|
10136
10239
|
})))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": turn } }));
|
|
@@ -10144,7 +10247,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
10144
10247
|
params: resume.call.params,
|
|
10145
10248
|
providerExecuted: false
|
|
10146
10249
|
});
|
|
10147
|
-
const currentTurn = resetTurnState(0).pipe(Stream7.concat(Stream7.unwrap(
|
|
10250
|
+
const currentTurn = resetTurnState(0).pipe(Stream7.concat(Stream7.unwrap(Ref11.get(chat.history).pipe(Effect46.map((history) => toolCallEvents(0, call, history.content))))), Stream7.concat(Stream7.unwrap(afterTurn(0).pipe(Effect46.map((result) => {
|
|
10148
10251
|
next = result.next;
|
|
10149
10252
|
return result.events;
|
|
10150
10253
|
})))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": 0 } }));
|
|
@@ -10155,10 +10258,10 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
|
|
|
10155
10258
|
const runStream = options.resume === undefined ? runTurn(0, initialPrompt) : resumeStream(options.resume);
|
|
10156
10259
|
return runStream.pipe(Stream7.catchCause((cause) => {
|
|
10157
10260
|
if (Cause3.hasInterrupts(cause))
|
|
10158
|
-
return Stream7.fromEffect(
|
|
10261
|
+
return Stream7.fromEffect(Effect46.interrupt);
|
|
10159
10262
|
const error = Cause3.squash(cause);
|
|
10160
10263
|
if (error instanceof AgentSuspended) {
|
|
10161
|
-
return Stream7.unwrap(
|
|
10264
|
+
return Stream7.unwrap(Ref11.get(chat.history).pipe(Effect46.map((transcript) => Stream7.concat(Stream7.fromIterable([turnCompletedEvent(state.turn, transcript)]), Stream7.failCause(cause)))));
|
|
10162
10265
|
}
|
|
10163
10266
|
return Stream7.failCause(cause);
|
|
10164
10267
|
}));
|
|
@@ -10169,29 +10272,29 @@ var streamObject = (agent, options) => streamInternal(agent, options, {
|
|
|
10169
10272
|
objectName: options.objectName ?? "output",
|
|
10170
10273
|
objectPrompt: options.objectPrompt ?? defaultObjectPrompt
|
|
10171
10274
|
});
|
|
10172
|
-
var generate = (agent, options) => Stream7.runLast(stream2(agent, options)).pipe(
|
|
10173
|
-
onNone: () =>
|
|
10174
|
-
onSome: (event) => event._tag === "Completed" ?
|
|
10275
|
+
var generate = (agent, options) => Stream7.runLast(stream2(agent, options)).pipe(Effect46.flatMap(Option16.match({
|
|
10276
|
+
onNone: () => Effect46.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 })),
|
|
10277
|
+
onSome: (event) => event._tag === "Completed" ? Effect46.succeed({ text: event.text, turns: event.turns, transcript: event.transcript }) : Effect46.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 }))
|
|
10175
10278
|
})));
|
|
10176
10279
|
var generateObject = (agent, options) => Stream7.runFold(streamObject(agent, options), () => ({
|
|
10177
|
-
value:
|
|
10178
|
-
completed:
|
|
10280
|
+
value: Option16.none(),
|
|
10281
|
+
completed: Option16.none()
|
|
10179
10282
|
}), (acc, event) => {
|
|
10180
10283
|
if (event._tag === "StructuredOutput") {
|
|
10181
|
-
return { ...acc, value:
|
|
10284
|
+
return { ...acc, value: Option16.some(event.value) };
|
|
10182
10285
|
}
|
|
10183
10286
|
if (event._tag === "Completed") {
|
|
10184
|
-
return { ...acc, completed:
|
|
10287
|
+
return { ...acc, completed: Option16.some(event) };
|
|
10185
10288
|
}
|
|
10186
10289
|
return acc;
|
|
10187
|
-
}).pipe(
|
|
10188
|
-
onNone: () =>
|
|
10189
|
-
onSome: (event) =>
|
|
10190
|
-
onNone: () =>
|
|
10290
|
+
}).pipe(Effect46.flatMap(({ value, completed }) => Option16.match(completed, {
|
|
10291
|
+
onNone: () => Effect46.fail(new AgentError({ message: "Agent object run ended without a Completed event", turn: 0 })),
|
|
10292
|
+
onSome: (event) => Option16.match(value, {
|
|
10293
|
+
onNone: () => Effect46.fail(new AgentError({
|
|
10191
10294
|
message: "Agent object run ended without a StructuredOutput event",
|
|
10192
10295
|
turn: 0
|
|
10193
10296
|
})),
|
|
10194
|
-
onSome: (typedValue) =>
|
|
10297
|
+
onSome: (typedValue) => Effect46.succeed({
|
|
10195
10298
|
text: event.text,
|
|
10196
10299
|
turns: event.turns,
|
|
10197
10300
|
transcript: event.transcript,
|
|
@@ -10199,14 +10302,14 @@ var generateObject = (agent, options) => Stream7.runFold(streamObject(agent, opt
|
|
|
10199
10302
|
})
|
|
10200
10303
|
})
|
|
10201
10304
|
})));
|
|
10202
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
10305
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/agent-tool.ts
|
|
10203
10306
|
var exports_agent_tool = {};
|
|
10204
10307
|
__export(exports_agent_tool, {
|
|
10205
10308
|
asTool: () => asTool
|
|
10206
10309
|
});
|
|
10207
|
-
import { Cause as Cause4, Effect as
|
|
10310
|
+
import { Cause as Cause4, Effect as Effect47, Schema as Schema49 } from "effect";
|
|
10208
10311
|
import { Tool as Tool5, Toolkit as Toolkit4 } from "effect/unstable/ai";
|
|
10209
|
-
var defaultParameters =
|
|
10312
|
+
var defaultParameters = Schema49.Struct({ prompt: Schema49.String });
|
|
10210
10313
|
var errorMessage2 = (error) => {
|
|
10211
10314
|
if (error instanceof AgentSuspended) {
|
|
10212
10315
|
return `suspended on ${error.tool_name}: ${error.reason}`;
|
|
@@ -10225,39 +10328,39 @@ var errorMessage2 = (error) => {
|
|
|
10225
10328
|
var causeMessage = (agentName, cause) => `sub-agent '${agentName}' could not complete: ${errorMessage2(Cause4.squash(cause))}`;
|
|
10226
10329
|
var lazyHandled = (toolkit, name, handler) => ({
|
|
10227
10330
|
tools: toolkit.tools,
|
|
10228
|
-
handle: (toolName, params) => toolkit.pipe(
|
|
10331
|
+
handle: (toolName, params) => toolkit.pipe(Effect47.provide(toolkit.toLayer({
|
|
10229
10332
|
[name]: handler
|
|
10230
|
-
})),
|
|
10333
|
+
})), Effect47.flatMap((handled) => handled.handle(toolName, params)))
|
|
10231
10334
|
});
|
|
10232
10335
|
var asTool = (agent, options = {}) => {
|
|
10233
10336
|
const name = options.name ?? agent.name;
|
|
10234
10337
|
const parameters = options.parameters ?? defaultParameters;
|
|
10235
|
-
const success2 = options.success ??
|
|
10338
|
+
const success2 = options.success ?? Schema49.String;
|
|
10236
10339
|
const toPrompt = options.toPrompt ?? ((params) => params.prompt);
|
|
10237
10340
|
const fromResult = options.fromResult ?? ((result) => result.text);
|
|
10238
10341
|
const tool2 = Tool5.make(name, {
|
|
10239
10342
|
...options.description === undefined ? {} : { description: options.description },
|
|
10240
10343
|
parameters,
|
|
10241
10344
|
success: success2,
|
|
10242
|
-
failure:
|
|
10345
|
+
failure: Schema49.String,
|
|
10243
10346
|
failureMode: "return"
|
|
10244
10347
|
});
|
|
10245
10348
|
const toolkit = Toolkit4.make(tool2);
|
|
10246
|
-
const handler = (params) =>
|
|
10247
|
-
const prompt = yield*
|
|
10248
|
-
const result = yield* generate(agent, { prompt }).pipe(
|
|
10349
|
+
const handler = (params) => Effect47.gen(function* () {
|
|
10350
|
+
const prompt = yield* Effect47.try({ try: () => toPrompt(params), catch: errorMessage2 });
|
|
10351
|
+
const result = yield* generate(agent, { prompt }).pipe(Effect47.catchCause((cause) => {
|
|
10249
10352
|
if (Cause4.hasInterrupts(cause))
|
|
10250
|
-
return
|
|
10353
|
+
return Effect47.interrupt;
|
|
10251
10354
|
const error = Cause4.squash(cause);
|
|
10252
10355
|
if (error instanceof AgentSuspended)
|
|
10253
|
-
return
|
|
10254
|
-
return
|
|
10356
|
+
return Effect47.die(error);
|
|
10357
|
+
return Effect47.fail(causeMessage(agent.name, cause));
|
|
10255
10358
|
}));
|
|
10256
|
-
return yield*
|
|
10359
|
+
return yield* Effect47.try({ try: () => fromResult(result), catch: errorMessage2 });
|
|
10257
10360
|
});
|
|
10258
10361
|
return lazyHandled(toolkit, name, handler);
|
|
10259
10362
|
};
|
|
10260
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
10363
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/guardrail.ts
|
|
10261
10364
|
var exports_guardrail = {};
|
|
10262
10365
|
__export(exports_guardrail, {
|
|
10263
10366
|
validateInput: () => validateInput2,
|
|
@@ -10265,7 +10368,7 @@ __export(exports_guardrail, {
|
|
|
10265
10368
|
redactInput: () => redactInput,
|
|
10266
10369
|
filterOutput: () => filterOutput
|
|
10267
10370
|
});
|
|
10268
|
-
import { Effect as
|
|
10371
|
+
import { Effect as Effect48, Option as Option17 } from "effect";
|
|
10269
10372
|
import { Prompt as Prompt6, Response as Response4 } from "effect/unstable/ai";
|
|
10270
10373
|
var replacement = (options) => options.replacement ?? "[redacted]";
|
|
10271
10374
|
var redactText = (text3, options) => text3.replace(options.pattern, replacement(options));
|
|
@@ -10315,19 +10418,19 @@ var redactPromptText = (prompt, options) => Prompt6.fromMessages(prompt.content.
|
|
|
10315
10418
|
}
|
|
10316
10419
|
}));
|
|
10317
10420
|
var validateInput2 = (check2) => ({
|
|
10318
|
-
transformPrompt: (prompt, context) => check2(prompt, context).pipe(
|
|
10319
|
-
onNone: () =>
|
|
10320
|
-
onSome: (reason) =>
|
|
10421
|
+
transformPrompt: (prompt, context) => check2(prompt, context).pipe(Effect48.flatMap(Option17.match({
|
|
10422
|
+
onNone: () => Effect48.succeed(prompt),
|
|
10423
|
+
onSome: (reason) => Effect48.fail(new AgentError({ message: `Input guardrail blocked: ${reason}`, turn: context.turn }))
|
|
10321
10424
|
})))
|
|
10322
10425
|
});
|
|
10323
10426
|
var redactInput = (options) => ({
|
|
10324
|
-
transformPrompt: (prompt) =>
|
|
10427
|
+
transformPrompt: (prompt) => Effect48.succeed(redactPromptText(prompt, options))
|
|
10325
10428
|
});
|
|
10326
10429
|
var redactOutput = (options) => ({
|
|
10327
10430
|
transformPart: (part) => {
|
|
10328
10431
|
if (part.type !== "text-delta")
|
|
10329
|
-
return
|
|
10330
|
-
return
|
|
10432
|
+
return Effect48.succeed(Option17.some(part));
|
|
10433
|
+
return Effect48.succeed(Option17.some(Response4.makePart("text-delta", {
|
|
10331
10434
|
id: part.id,
|
|
10332
10435
|
delta: redactText(part.delta, options),
|
|
10333
10436
|
metadata: part.metadata
|
|
@@ -10335,22 +10438,22 @@ var redactOutput = (options) => ({
|
|
|
10335
10438
|
}
|
|
10336
10439
|
});
|
|
10337
10440
|
var filterOutput = (keep) => ({
|
|
10338
|
-
transformPart: (part, context) =>
|
|
10441
|
+
transformPart: (part, context) => Effect48.succeed(part.type === "tool-call" || keep(part, context) ? Option17.some(part) : Option17.none())
|
|
10339
10442
|
});
|
|
10340
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
10443
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/handoff.ts
|
|
10341
10444
|
var exports_handoff = {};
|
|
10342
10445
|
__export(exports_handoff, {
|
|
10343
10446
|
transferTool: () => transferTool,
|
|
10344
10447
|
supervisor: () => supervisor,
|
|
10345
10448
|
fanOut: () => fanOut
|
|
10346
10449
|
});
|
|
10347
|
-
import { Effect as
|
|
10450
|
+
import { Effect as Effect49, Schema as Schema50 } from "effect";
|
|
10348
10451
|
import { AiError as AiError2, Toolkit as Toolkit5 } from "effect/unstable/ai";
|
|
10349
|
-
var defaultTransferParameters =
|
|
10452
|
+
var defaultTransferParameters = Schema50.Struct({ prompt: Schema50.String });
|
|
10350
10453
|
var transferName = (agentName) => `transfer_to_${agentName}`;
|
|
10351
10454
|
var positiveConcurrency = (value) => {
|
|
10352
10455
|
const concurrency = value ?? 4;
|
|
10353
|
-
return Number.isInteger(concurrency) && concurrency > 0 ?
|
|
10456
|
+
return Number.isInteger(concurrency) && concurrency > 0 ? Effect49.succeed(concurrency) : Effect49.fail(new AgentError({
|
|
10354
10457
|
message: "Handoff.fanOut concurrency must be a positive integer",
|
|
10355
10458
|
turn: 0
|
|
10356
10459
|
}));
|
|
@@ -10364,7 +10467,7 @@ var mergeHandled = (toolkits) => {
|
|
|
10364
10467
|
tools,
|
|
10365
10468
|
handle: (name, params) => {
|
|
10366
10469
|
const toolkit = toolkits.find((candidate) => candidate.tools[name] !== undefined);
|
|
10367
|
-
return toolkit === undefined ?
|
|
10470
|
+
return toolkit === undefined ? Effect49.fail(AiError2.make({
|
|
10368
10471
|
module: "Handoff",
|
|
10369
10472
|
method: `${String(name)}.handle`,
|
|
10370
10473
|
reason: new AiError2.ToolNotFoundError({
|
|
@@ -10384,7 +10487,7 @@ var transferTool = (target, options = {}) => asTool(target, {
|
|
|
10384
10487
|
...options.toPrompt === undefined ? {} : { toPrompt: options.toPrompt },
|
|
10385
10488
|
...options.fromResult === undefined ? {} : { fromResult: options.fromResult }
|
|
10386
10489
|
});
|
|
10387
|
-
var fanOut = (children, options = {}) => positiveConcurrency(options.concurrency).pipe(
|
|
10490
|
+
var fanOut = (children, options = {}) => positiveConcurrency(options.concurrency).pipe(Effect49.flatMap((concurrency) => Effect49.forEach(children, (child) => generate(child.agent, { ...child.options, prompt: child.prompt }), {
|
|
10388
10491
|
concurrency
|
|
10389
10492
|
})));
|
|
10390
10493
|
var supervisor = (options) => {
|
|
@@ -10400,96 +10503,8 @@ var supervisor = (options) => {
|
|
|
10400
10503
|
toolkit
|
|
10401
10504
|
};
|
|
10402
10505
|
};
|
|
10403
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/model-registry.ts
|
|
10404
|
-
var exports_model_registry = {};
|
|
10405
|
-
__export(exports_model_registry, {
|
|
10406
|
-
testLayer: () => testLayer38,
|
|
10407
|
-
registrations: () => registrations,
|
|
10408
|
-
registrationFromLayer: () => registrationFromLayer,
|
|
10409
|
-
register: () => register4,
|
|
10410
|
-
provide: () => provide,
|
|
10411
|
-
memoryLayer: () => memoryLayer25,
|
|
10412
|
-
layerFromRegistrationEffects: () => layerFromRegistrationEffects,
|
|
10413
|
-
layer: () => layer31,
|
|
10414
|
-
combine: () => combine,
|
|
10415
|
-
Service: () => Service29,
|
|
10416
|
-
LanguageModelNotRegistered: () => LanguageModelNotRegistered
|
|
10417
|
-
});
|
|
10418
|
-
import { Chunk as Chunk2, Context as Context42, Effect as Effect49, Layer as Layer43, Option as Option17, Ref as Ref11, Schema as Schema50, Semaphore as Semaphore3 } from "effect";
|
|
10419
|
-
import { Model } from "effect/unstable/ai";
|
|
10420
|
-
|
|
10421
|
-
class LanguageModelNotRegistered extends Schema50.TaggedErrorClass()("LanguageModelNotRegistered", {
|
|
10422
|
-
provider: Schema50.String,
|
|
10423
|
-
model: Schema50.String,
|
|
10424
|
-
registration_key: Schema50.optionalKey(Schema50.String)
|
|
10425
|
-
}) {
|
|
10426
|
-
}
|
|
10427
|
-
|
|
10428
|
-
class Service29 extends Context42.Service()("@batonfx/core/ModelRegistry") {
|
|
10429
|
-
}
|
|
10430
|
-
var registrationVariantKey = (value) => value.registrationKey ?? null;
|
|
10431
|
-
var selectionVariantKey = (selection) => selection.registrationKey ?? null;
|
|
10432
|
-
var registryIdentity = (registration) => JSON.stringify([registration.provider, registration.model, registrationVariantKey(registration)]);
|
|
10433
|
-
var matchesSelection = (selection) => (registration) => registration.provider === selection.provider && registration.model === selection.model && registrationVariantKey(registration) === selectionVariantKey(selection);
|
|
10434
|
-
var upsertRegistration = (registry, registration) => {
|
|
10435
|
-
const key2 = registryIdentity(registration);
|
|
10436
|
-
const exists = Option17.isSome(Chunk2.findFirst(registry, (item) => registryIdentity(item) === key2));
|
|
10437
|
-
if (!exists)
|
|
10438
|
-
return Chunk2.append(registry, registration);
|
|
10439
|
-
return Chunk2.map(registry, (item) => registryIdentity(item) === key2 ? registration : item);
|
|
10440
|
-
};
|
|
10441
|
-
var findRegistration = (registry, selection) => Chunk2.findFirst(registry, matchesSelection(selection)).pipe(Option17.getOrUndefined);
|
|
10442
|
-
var registrationFromLayer = (input) => Model.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect49.map((layer31) => ({
|
|
10443
|
-
provider: input.provider,
|
|
10444
|
-
model: input.model,
|
|
10445
|
-
layer: layer31,
|
|
10446
|
-
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
10447
|
-
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
10448
|
-
})));
|
|
10449
|
-
var layer31 = (initialRegistrations = [], options) => Layer43.effect(Service29, Effect49.gen(function* () {
|
|
10450
|
-
const registry = yield* Ref11.make(initialRegistrations.reduce(upsertRegistration, Chunk2.empty()));
|
|
10451
|
-
const semaphore = options?.maxConcurrentModelCalls === undefined ? undefined : yield* Semaphore3.make(options.maxConcurrentModelCalls);
|
|
10452
|
-
const register4 = Effect49.fn("ModelRegistry.register")(function* (input) {
|
|
10453
|
-
yield* Ref11.update(registry, (items) => upsertRegistration(items, input.registration));
|
|
10454
|
-
});
|
|
10455
|
-
const registrations = Ref11.get(registry).pipe(Effect49.map(Chunk2.toReadonlyArray));
|
|
10456
|
-
const provide = Effect49.fn("ModelRegistry.provide")(function* (selection, effect) {
|
|
10457
|
-
const items = yield* Ref11.get(registry);
|
|
10458
|
-
const registration = findRegistration(items, selection);
|
|
10459
|
-
if (registration === undefined) {
|
|
10460
|
-
return yield* Effect49.fail(new LanguageModelNotRegistered({
|
|
10461
|
-
provider: selection.provider,
|
|
10462
|
-
model: selection.model,
|
|
10463
|
-
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
10464
|
-
}));
|
|
10465
|
-
}
|
|
10466
|
-
const provided = effect.pipe(Effect49.provide(registration.layer));
|
|
10467
|
-
return yield* semaphore === undefined ? provided : semaphore.withPermits(1)(provided);
|
|
10468
|
-
});
|
|
10469
|
-
return Service29.of({
|
|
10470
|
-
register: register4,
|
|
10471
|
-
registrations,
|
|
10472
|
-
provide
|
|
10473
|
-
});
|
|
10474
|
-
}));
|
|
10475
|
-
var layerFromRegistrationEffects = (registrations, options) => Layer43.unwrap(Effect49.all(registrations).pipe(Effect49.map((items) => layer31(items, options))));
|
|
10476
|
-
var combine = (registries, options) => Layer43.unwrap(Effect49.forEach(registries, (registry) => Layer43.build(registry).pipe(Effect49.flatMap((context) => Context42.get(context, Service29).registrations))).pipe(Effect49.map((groups) => layer31(groups.flat(), options))));
|
|
10477
|
-
var memoryLayer25 = layer31;
|
|
10478
|
-
var testLayer38 = (implementation) => Layer43.succeed(Service29, Service29.of(implementation));
|
|
10479
|
-
var register4 = Effect49.fn("ModelRegistry.register.call")(function* (input) {
|
|
10480
|
-
const service = yield* Service29;
|
|
10481
|
-
return yield* service.register(input);
|
|
10482
|
-
});
|
|
10483
|
-
var registrations = Effect49.fn("ModelRegistry.registrations.call")(function* () {
|
|
10484
|
-
const service = yield* Service29;
|
|
10485
|
-
return yield* service.registrations;
|
|
10486
|
-
});
|
|
10487
|
-
var provide = (selection, effect) => Effect49.gen(function* () {
|
|
10488
|
-
const service = yield* Service29;
|
|
10489
|
-
return yield* service.provide(selection, effect);
|
|
10490
|
-
});
|
|
10491
10506
|
|
|
10492
|
-
// ../../node_modules/.bun/@batonfx+core@0.3.
|
|
10507
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.6/node_modules/@batonfx/core/src/index.ts
|
|
10493
10508
|
import {
|
|
10494
10509
|
AiError as AiError3,
|
|
10495
10510
|
Chat as Chat2,
|
|
@@ -15626,7 +15641,7 @@ __export(exports_language_model_registration, {
|
|
|
15626
15641
|
anthropic: () => anthropic
|
|
15627
15642
|
});
|
|
15628
15643
|
|
|
15629
|
-
// ../../node_modules/.bun/@batonfx+providers@0.3.
|
|
15644
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.6/node_modules/@batonfx/providers/src/anthropic.ts
|
|
15630
15645
|
import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
|
|
15631
15646
|
import { Layer as Layer70 } from "effect";
|
|
15632
15647
|
import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
|
|
@@ -15642,13 +15657,13 @@ var anthropic = (input) => exports_model_registry.registrationFromLayer({
|
|
|
15642
15657
|
});
|
|
15643
15658
|
var anthropicClientLayerConfig = AnthropicClient.layerConfig;
|
|
15644
15659
|
var withAnthropic = (options) => exports_model_registry.layerFromRegistrationEffects([anthropic(options)]).pipe(Layer70.provide(AnthropicClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })), Layer70.provide(FetchHttpClient2.layer));
|
|
15645
|
-
// ../../node_modules/.bun/@batonfx+providers@0.3.
|
|
15660
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.6/node_modules/@batonfx/providers/src/deterministic.ts
|
|
15646
15661
|
import { OpenAiClient as OpenAiClient3 } from "@effect/ai-openai";
|
|
15647
15662
|
import { Effect as Effect79, Layer as Layer72, Option as Option28, Stream as Stream11 } from "effect";
|
|
15648
15663
|
import { LanguageModel as LanguageModel8, Response as Response7 } from "effect/unstable/ai";
|
|
15649
15664
|
import { FetchHttpClient as FetchHttpClient4 } from "effect/unstable/http";
|
|
15650
15665
|
|
|
15651
|
-
// ../../node_modules/.bun/@batonfx+providers@0.3.
|
|
15666
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.6/node_modules/@batonfx/providers/src/openai.ts
|
|
15652
15667
|
import { OpenAiClient as OpenAiClient2, OpenAiLanguageModel } from "@effect/ai-openai";
|
|
15653
15668
|
import { Layer as Layer71 } from "effect";
|
|
15654
15669
|
import { FetchHttpClient as FetchHttpClient3 } from "effect/unstable/http";
|
|
@@ -15665,7 +15680,7 @@ var openAi = (input) => exports_model_registry.registrationFromLayer({
|
|
|
15665
15680
|
var openAiClientLayerConfig2 = OpenAiClient2.layerConfig;
|
|
15666
15681
|
var withOpenAi = (options) => exports_model_registry.layerFromRegistrationEffects([openAi(options)]).pipe(Layer71.provide(OpenAiClient2.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })), Layer71.provide(FetchHttpClient3.layer));
|
|
15667
15682
|
|
|
15668
|
-
// ../../node_modules/.bun/@batonfx+providers@0.3.
|
|
15683
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.6/node_modules/@batonfx/providers/src/deterministic.ts
|
|
15669
15684
|
var deterministicModelLayer = Layer72.effect(LanguageModel8.LanguageModel, LanguageModel8.make({
|
|
15670
15685
|
generateText: () => Effect79.succeed([{ type: "text", text: "deterministic response" }]),
|
|
15671
15686
|
streamText: () => Stream11.make(Response7.makePart("text-delta", { id: "text", delta: "deterministic response" }))
|
|
@@ -15689,7 +15704,7 @@ var withOpenAiOrDeterministic = (options) => Layer72.unwrap(Effect79.gen(functio
|
|
|
15689
15704
|
...Option28.isSome(openAiRegistration) ? [openAiRegistration.value] : []
|
|
15690
15705
|
]);
|
|
15691
15706
|
}));
|
|
15692
|
-
// ../../node_modules/.bun/@batonfx+providers@0.3.
|
|
15707
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.6/node_modules/@batonfx/providers/src/openai-compat.ts
|
|
15693
15708
|
import { OpenAiClient as OpenAiClient4, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai-compat";
|
|
15694
15709
|
import { Config as Config8, Layer as Layer73 } from "effect";
|
|
15695
15710
|
import { FetchHttpClient as FetchHttpClient5 } from "effect/unstable/http";
|
|
@@ -15710,7 +15725,7 @@ var clientLayerConfig = (options) => OpenAiClient4.layerConfig({
|
|
|
15710
15725
|
...options.baseUrl === undefined ? {} : { apiUrl: Config8.succeed(options.baseUrl) }
|
|
15711
15726
|
});
|
|
15712
15727
|
var withOpenAiCompatible = (options) => exports_model_registry.layerFromRegistrationEffects([openAiCompatible(options)]).pipe(Layer73.provide(clientLayerConfig(options)), Layer73.provide(FetchHttpClient5.layer));
|
|
15713
|
-
// ../../node_modules/.bun/@batonfx+providers@0.3.
|
|
15728
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.6/node_modules/@batonfx/providers/src/openrouter.ts
|
|
15714
15729
|
import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
|
|
15715
15730
|
import { Layer as Layer74 } from "effect";
|
|
15716
15731
|
import { FetchHttpClient as FetchHttpClient6 } from "effect/unstable/http";
|