@relayfx/sdk 0.0.46 → 0.0.48

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/index.js CHANGED
@@ -8481,7 +8481,7 @@ __export(exports_agent_loop_service, {
8481
8481
  AgentLoopBudgetExceeded: () => AgentLoopBudgetExceeded
8482
8482
  });
8483
8483
 
8484
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/agent.ts
8484
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/agent.ts
8485
8485
  var exports_agent = {};
8486
8486
  __export(exports_agent, {
8487
8487
  streamObject: () => streamObject,
@@ -8491,10 +8491,10 @@ __export(exports_agent, {
8491
8491
  generate: () => generate,
8492
8492
  defaultObjectPrompt: () => defaultObjectPrompt
8493
8493
  });
8494
- import { Cause as Cause3, Effect as Effect45, Fiber, Option as Option15, Queue as Queue2, Ref as Ref10, Schema as Schema47, Stream as Stream7 } from "effect";
8495
- import { Chat, LanguageModel as LanguageModel3, Prompt as Prompt4, Response as Response3, Telemetry, Tokenizer as Tokenizer2, Tool as Tool4, Toolkit as Toolkit3 } from "effect/unstable/ai";
8494
+ 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";
8495
+ 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";
8496
8496
 
8497
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/agent-event.ts
8497
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/agent-event.ts
8498
8498
  var exports_agent_event = {};
8499
8499
  __export(exports_agent_event, {
8500
8500
  addUsage: () => addUsage,
@@ -8551,7 +8551,7 @@ class AgentSuspended extends Schema38.TaggedErrorClass()("@batonfx/core/AgentSus
8551
8551
  }) {
8552
8552
  }
8553
8553
 
8554
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/approvals.ts
8554
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/approvals.ts
8555
8555
  var exports_approvals = {};
8556
8556
  __export(exports_approvals, {
8557
8557
  testLayer: () => testLayer26,
@@ -8567,7 +8567,7 @@ var autoApprove = Layer29.succeed(Approvals, Approvals.of({ check: () => Effect3
8567
8567
  var denyAll = Layer29.succeed(Approvals, Approvals.of({ check: () => Effect31.succeed({ _tag: "Denied" }) }));
8568
8568
  var testLayer26 = (implementation) => Layer29.succeed(Approvals, Approvals.of(implementation));
8569
8569
 
8570
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/compaction.ts
8570
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/compaction.ts
8571
8571
  var exports_compaction = {};
8572
8572
  __export(exports_compaction, {
8573
8573
  truncate: () => truncate,
@@ -8585,7 +8585,7 @@ __export(exports_compaction, {
8585
8585
  import { Context as Context32, Effect as Effect34, Layer as Layer32, Option as Option10, Schema as Schema41 } from "effect";
8586
8586
  import { LanguageModel, Prompt as Prompt3, Tokenizer, Toolkit as Toolkit2 } from "effect/unstable/ai";
8587
8587
 
8588
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/session.ts
8588
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/session.ts
8589
8589
  var exports_session = {};
8590
8590
  __export(exports_session, {
8591
8591
  testLayer: () => testLayer27,
@@ -8758,7 +8758,7 @@ var memoryLayer24 = Layer30.effect(SessionStore, Ref7.make(initialState).pipe(Ef
8758
8758
  }))));
8759
8759
  var testLayer27 = (implementation) => Layer30.succeed(SessionStore, SessionStore.of(implementation));
8760
8760
 
8761
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/tool-output.ts
8761
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/tool-output.ts
8762
8762
  var exports_tool_output = {};
8763
8763
  __export(exports_tool_output, {
8764
8764
  testLayer: () => testLayer28,
@@ -8818,7 +8818,7 @@ var bound = (result, options) => Effect33.gen(function* () {
8818
8818
  return { _tag: "Success", result: output, encodedResult: output };
8819
8819
  });
8820
8820
 
8821
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/compaction.ts
8821
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/compaction.ts
8822
8822
  var DEFAULT_RESERVE_TOKENS = 16384;
8823
8823
  var DEFAULT_KEEP_RECENT_TOKENS = 20000;
8824
8824
  var SUMMARY_TEMPLATE = `Summarize the conversation so another agent can continue seamlessly.
@@ -9001,7 +9001,7 @@ var truncate = (maxTokens) => ({
9001
9001
  var testLayer29 = (implementation) => Layer32.succeed(Compaction, Compaction.of(implementation));
9002
9002
  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));
9003
9003
 
9004
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/instructions.ts
9004
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/instructions.ts
9005
9005
  var exports_instructions = {};
9006
9006
  __export(exports_instructions, {
9007
9007
  testLayer: () => testLayer30,
@@ -9050,7 +9050,7 @@ var renderUpdate = (epoch, context) => Effect35.gen(function* () {
9050
9050
  var layer27 = (sources) => Layer33.succeed(Instructions, Instructions.of({ sources: [...sources] }));
9051
9051
  var testLayer30 = (implementation) => Layer33.succeed(Instructions, Instructions.of(implementation));
9052
9052
 
9053
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/memory.ts
9053
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/memory.ts
9054
9054
  var exports_memory = {};
9055
9055
  __export(exports_memory, {
9056
9056
  testLayer: () => testLayer31,
@@ -9081,7 +9081,7 @@ var merge = (first, second) => ({
9081
9081
  var noopLayer = Layer34.succeed(Memory, Memory.of(noop));
9082
9082
  var testLayer31 = (implementation) => Layer34.succeed(Memory, Memory.of(implementation));
9083
9083
 
9084
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/model-middleware.ts
9084
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/model-middleware.ts
9085
9085
  var exports_model_middleware = {};
9086
9086
  __export(exports_model_middleware, {
9087
9087
  layer: () => layer28,
@@ -9095,21 +9095,110 @@ class ModelMiddleware extends Context35.Service()("@batonfx/core/ModelMiddleware
9095
9095
  var identityLayer = Layer35.succeed(ModelMiddleware, []);
9096
9096
  var layer28 = (middleware) => Layer35.succeed(ModelMiddleware, middleware);
9097
9097
 
9098
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/model-resilience.ts
9098
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/model-registry.ts
9099
+ var exports_model_registry = {};
9100
+ __export(exports_model_registry, {
9101
+ testLayer: () => testLayer32,
9102
+ registrations: () => registrations,
9103
+ registrationFromLayer: () => registrationFromLayer,
9104
+ register: () => register4,
9105
+ provide: () => provide,
9106
+ memoryLayer: () => memoryLayer25,
9107
+ layerFromRegistrationEffects: () => layerFromRegistrationEffects,
9108
+ layer: () => layer29,
9109
+ combine: () => combine,
9110
+ Service: () => Service29,
9111
+ LanguageModelNotRegistered: () => LanguageModelNotRegistered
9112
+ });
9113
+ 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";
9114
+ import { Model } from "effect/unstable/ai";
9115
+
9116
+ class LanguageModelNotRegistered extends Schema43.TaggedErrorClass()("LanguageModelNotRegistered", {
9117
+ provider: Schema43.String,
9118
+ model: Schema43.String,
9119
+ registration_key: Schema43.optionalKey(Schema43.String)
9120
+ }) {
9121
+ }
9122
+
9123
+ class Service29 extends Context36.Service()("@batonfx/core/ModelRegistry") {
9124
+ }
9125
+ var registrationVariantKey = (value) => value.registrationKey ?? null;
9126
+ var selectionVariantKey = (selection) => selection.registrationKey ?? null;
9127
+ var registryIdentity = (registration) => JSON.stringify([registration.provider, registration.model, registrationVariantKey(registration)]);
9128
+ var matchesSelection = (selection) => (registration) => registration.provider === selection.provider && registration.model === selection.model && registrationVariantKey(registration) === selectionVariantKey(selection);
9129
+ var upsertRegistration = (registry, registration) => {
9130
+ const key2 = registryIdentity(registration);
9131
+ const exists = Option13.isSome(Chunk2.findFirst(registry, (item) => registryIdentity(item) === key2));
9132
+ if (!exists)
9133
+ return Chunk2.append(registry, registration);
9134
+ return Chunk2.map(registry, (item) => registryIdentity(item) === key2 ? registration : item);
9135
+ };
9136
+ var findRegistration = (registry, selection) => Chunk2.findFirst(registry, matchesSelection(selection)).pipe(Option13.getOrUndefined);
9137
+ var registrationFromLayer = (input) => Model.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect38.map((layer29) => ({
9138
+ provider: input.provider,
9139
+ model: input.model,
9140
+ layer: layer29,
9141
+ ...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
9142
+ ...input.metadata === undefined ? {} : { metadata: input.metadata }
9143
+ })));
9144
+ var layer29 = (initialRegistrations = [], options) => Layer36.effect(Service29, Effect38.gen(function* () {
9145
+ const registry = yield* Ref9.make(initialRegistrations.reduce(upsertRegistration, Chunk2.empty()));
9146
+ const semaphore = options?.maxConcurrentModelCalls === undefined ? undefined : yield* Semaphore3.make(options.maxConcurrentModelCalls);
9147
+ const register4 = Effect38.fn("ModelRegistry.register")(function* (input) {
9148
+ yield* Ref9.update(registry, (items) => upsertRegistration(items, input.registration));
9149
+ });
9150
+ const registrations = Ref9.get(registry).pipe(Effect38.map(Chunk2.toReadonlyArray));
9151
+ const provide = Effect38.fn("ModelRegistry.provide")(function* (selection, effect) {
9152
+ const items = yield* Ref9.get(registry);
9153
+ const registration = findRegistration(items, selection);
9154
+ if (registration === undefined) {
9155
+ return yield* Effect38.fail(new LanguageModelNotRegistered({
9156
+ provider: selection.provider,
9157
+ model: selection.model,
9158
+ ...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
9159
+ }));
9160
+ }
9161
+ const provided = effect.pipe(Effect38.provide(registration.layer));
9162
+ return yield* semaphore === undefined ? provided : semaphore.withPermits(1)(provided);
9163
+ });
9164
+ return Service29.of({
9165
+ register: register4,
9166
+ registrations,
9167
+ provide
9168
+ });
9169
+ }));
9170
+ var layerFromRegistrationEffects = (registrations, options) => Layer36.unwrap(Effect38.all(registrations).pipe(Effect38.map((items) => layer29(items, options))));
9171
+ 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))));
9172
+ var memoryLayer25 = layer29;
9173
+ var testLayer32 = (implementation) => Layer36.succeed(Service29, Service29.of(implementation));
9174
+ var register4 = Effect38.fn("ModelRegistry.register.call")(function* (input) {
9175
+ const service = yield* Service29;
9176
+ return yield* service.register(input);
9177
+ });
9178
+ var registrations = Effect38.fn("ModelRegistry.registrations.call")(function* () {
9179
+ const service = yield* Service29;
9180
+ return yield* service.registrations;
9181
+ });
9182
+ var provide = (selection, effect) => Effect38.gen(function* () {
9183
+ const service = yield* Service29;
9184
+ return yield* service.provide(selection, effect);
9185
+ });
9186
+
9187
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/model-resilience.ts
9099
9188
  var exports_model_resilience = {};
9100
9189
  __export(exports_model_resilience, {
9101
- testLayer: () => testLayer32,
9190
+ testLayer: () => testLayer33,
9102
9191
  none: () => none,
9103
9192
  make: () => make3,
9104
- layer: () => layer29,
9193
+ layer: () => layer30,
9105
9194
  defaultClassify: () => defaultClassify,
9106
9195
  apply: () => apply,
9107
9196
  ModelResilience: () => ModelResilience
9108
9197
  });
9109
- import { Cause, Context as Context36, Effect as Effect38, Layer as Layer36, Schedule as Schedule2, Stream as Stream5 } from "effect";
9198
+ import { Cause, Context as Context37, Effect as Effect39, Layer as Layer37, Schedule as Schedule2, Stream as Stream5 } from "effect";
9110
9199
  import { AiError, Response as Response2 } from "effect/unstable/ai";
9111
9200
 
9112
- class ModelResilience extends Context36.Service()("@batonfx/core/ModelResilience") {
9201
+ class ModelResilience extends Context37.Service()("@batonfx/core/ModelResilience") {
9113
9202
  }
9114
9203
  var defaultClassify = (error) => AiError.isAiError(error) && error.isRetryable ? "transient" : "terminal";
9115
9204
  var none = { classify: () => "terminal", retrySchedule: Schedule2.recurs(0) };
@@ -9117,9 +9206,9 @@ var make3 = (input) => ({
9117
9206
  classify: input?.classify ?? defaultClassify,
9118
9207
  retrySchedule: input?.retrySchedule ?? none.retrySchedule
9119
9208
  });
9120
- var layer29 = (input) => Layer36.succeed(ModelResilience, ModelResilience.of(make3(input)));
9121
- var testLayer32 = (implementation) => Layer36.succeed(ModelResilience, ModelResilience.of(implementation));
9122
- var retryEffect = (effect, resilience) => Effect38.suspend(effect).pipe(Effect38.retry({
9209
+ var layer30 = (input) => Layer37.succeed(ModelResilience, ModelResilience.of(make3(input)));
9210
+ var testLayer33 = (implementation) => Layer37.succeed(ModelResilience, ModelResilience.of(implementation));
9211
+ var retryEffect = (effect, resilience) => Effect39.suspend(effect).pipe(Effect39.retry({
9123
9212
  schedule: resilience.retrySchedule,
9124
9213
  while: (error) => resilience.classify(error) === "transient"
9125
9214
  }));
@@ -9130,7 +9219,7 @@ var apply = (model, resilience) => ({
9130
9219
  generateObject: (options) => retryEffect(() => model.generateObject(options), resilience),
9131
9220
  streamText: (options) => Stream5.suspend(() => {
9132
9221
  let emitted = false;
9133
- return model.streamText(options).pipe(Stream5.tap(() => Effect38.sync(() => {
9222
+ return model.streamText(options).pipe(Stream5.tap(() => Effect39.sync(() => {
9134
9223
  emitted = true;
9135
9224
  })), Stream5.catchCause((cause) => {
9136
9225
  if (Cause.hasInterrupts(cause))
@@ -9141,10 +9230,10 @@ var apply = (model, resilience) => ({
9141
9230
  }).pipe(Stream5.retry(retryStreamSchedule(resilience)))
9142
9231
  });
9143
9232
 
9144
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/permissions.ts
9233
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/permissions.ts
9145
9234
  var exports_permissions = {};
9146
9235
  __export(exports_permissions, {
9147
- testLayer: () => testLayer33,
9236
+ testLayer: () => testLayer34,
9148
9237
  ruleStoreTestLayer: () => ruleStoreTestLayer,
9149
9238
  ruleStoreMemory: () => ruleStoreMemory,
9150
9239
  matches: () => matches,
@@ -9156,17 +9245,17 @@ __export(exports_permissions, {
9156
9245
  Permissions: () => Permissions,
9157
9246
  PermissionError: () => PermissionError
9158
9247
  });
9159
- import { Context as Context37, Effect as Effect39, Layer as Layer37, Option as Option13, Ref as Ref9, Schema as Schema43 } from "effect";
9248
+ import { Context as Context38, Effect as Effect40, Layer as Layer38, Option as Option14, Ref as Ref10, Schema as Schema44 } from "effect";
9160
9249
 
9161
- class PermissionError extends Schema43.TaggedErrorClass()("@batonfx/core/PermissionError", {
9162
- message: Schema43.String
9250
+ class PermissionError extends Schema44.TaggedErrorClass()("@batonfx/core/PermissionError", {
9251
+ message: Schema44.String
9163
9252
  }) {
9164
9253
  }
9165
9254
 
9166
- class Permissions extends Context37.Service()("@batonfx/core/Permissions") {
9255
+ class Permissions extends Context38.Service()("@batonfx/core/Permissions") {
9167
9256
  }
9168
9257
 
9169
- class RuleStore extends Context37.Service()("@batonfx/core/PermissionRuleStore") {
9258
+ class RuleStore extends Context38.Service()("@batonfx/core/PermissionRuleStore") {
9170
9259
  }
9171
9260
  var escapeRegExp = (value) => value.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
9172
9261
  var glob = (pattern) => new RegExp(`^${pattern.split("*").map(escapeRegExp).join(".*")}$`);
@@ -9253,28 +9342,28 @@ var decisionFor = (ruleset, request) => {
9253
9342
  return { _tag: "Ask", token: tokenFor(request) };
9254
9343
  }
9255
9344
  };
9256
- var fromRuleset = (ruleset) => Layer37.succeed(Permissions, Permissions.of({
9257
- evaluate: (request) => Effect39.succeed(decisionFor(ruleset, request)),
9258
- await: () => Effect39.succeed(Option13.none())
9345
+ var fromRuleset = (ruleset) => Layer38.succeed(Permissions, Permissions.of({
9346
+ evaluate: (request) => Effect40.succeed(decisionFor(ruleset, request)),
9347
+ await: () => Effect40.succeed(Option14.none())
9259
9348
  }));
9260
- var allowAll = Layer37.succeed(Permissions, Permissions.of({
9261
- evaluate: () => Effect39.succeed({ _tag: "Allow" }),
9262
- await: () => Effect39.succeed(Option13.none())
9349
+ var allowAll = Layer38.succeed(Permissions, Permissions.of({
9350
+ evaluate: () => Effect40.succeed({ _tag: "Allow" }),
9351
+ await: () => Effect40.succeed(Option14.none())
9263
9352
  }));
9264
- var interactive = (options) => Layer37.succeed(Permissions, Permissions.of({
9265
- evaluate: (request) => Effect39.succeed(decisionFor(options.ruleset, request)),
9266
- await: (pending) => options.onAsk(pending).pipe(Effect39.map(Option13.some))
9353
+ var interactive = (options) => Layer38.succeed(Permissions, Permissions.of({
9354
+ evaluate: (request) => Effect40.succeed(decisionFor(options.ruleset, request)),
9355
+ await: (pending) => options.onAsk(pending).pipe(Effect40.map(Option14.some))
9267
9356
  }));
9268
- var ruleStoreMemory = (initialRules = []) => Layer37.effect(RuleStore, Ref9.make(initialRules).pipe(Effect39.map((rules) => RuleStore.of({
9269
- remember: (rule) => Ref9.update(rules, (current2) => [...current2, rule])
9357
+ var ruleStoreMemory = (initialRules = []) => Layer38.effect(RuleStore, Ref10.make(initialRules).pipe(Effect40.map((rules) => RuleStore.of({
9358
+ remember: (rule) => Ref10.update(rules, (current2) => [...current2, rule])
9270
9359
  }))));
9271
- var ruleStoreTestLayer = (implementation) => Layer37.succeed(RuleStore, RuleStore.of(implementation));
9272
- var testLayer33 = (implementation) => Layer37.succeed(Permissions, Permissions.of(implementation));
9360
+ var ruleStoreTestLayer = (implementation) => Layer38.succeed(RuleStore, RuleStore.of(implementation));
9361
+ var testLayer34 = (implementation) => Layer38.succeed(Permissions, Permissions.of(implementation));
9273
9362
 
9274
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/skill-source.ts
9363
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/skill-source.ts
9275
9364
  var exports_skill_source = {};
9276
9365
  __export(exports_skill_source, {
9277
- testLayer: () => testLayer34,
9366
+ testLayer: () => testLayer35,
9278
9367
  selectListings: () => selectListings,
9279
9368
  makeListing: () => makeListing,
9280
9369
  fromSkills: () => fromSkills,
@@ -9283,29 +9372,29 @@ __export(exports_skill_source, {
9283
9372
  SkillSource: () => SkillSource,
9284
9373
  DESCRIPTION_CAP: () => DESCRIPTION_CAP
9285
9374
  });
9286
- import { Context as Context38, Effect as Effect40, Layer as Layer38, Schema as Schema44 } from "effect";
9375
+ import { Context as Context39, Effect as Effect41, Layer as Layer39, Schema as Schema45 } from "effect";
9287
9376
 
9288
- class SkillSourceError extends Schema44.TaggedErrorClass()("@batonfx/core/SkillSourceError", {
9289
- source: Schema44.String,
9290
- message: Schema44.String,
9291
- cause: Schema44.optionalKey(Schema44.Defect())
9377
+ class SkillSourceError extends Schema45.TaggedErrorClass()("@batonfx/core/SkillSourceError", {
9378
+ source: Schema45.String,
9379
+ message: Schema45.String,
9380
+ cause: Schema45.optionalKey(Schema45.Defect())
9292
9381
  }) {
9293
9382
  }
9294
9383
  var DESCRIPTION_CAP = 1536;
9295
9384
 
9296
- class SkillSource extends Context38.Service()("@batonfx/core/SkillSource") {
9385
+ class SkillSource extends Context39.Service()("@batonfx/core/SkillSource") {
9297
9386
  }
9298
9387
  var makeListing = (frontmatter, descriptionCap = DESCRIPTION_CAP) => `- ${frontmatter.name}: ${frontmatter.description.slice(0, Math.max(0, descriptionCap))}`;
9299
9388
  var fromSkills = (skills) => {
9300
9389
  const all = [...skills];
9301
9390
  const byName = new Map(all.map((skill) => [skill.frontmatter.name, skill]));
9302
- return Layer38.succeed(SkillSource, SkillSource.of({
9303
- all: Effect40.succeed(all),
9304
- get: (name) => Effect40.succeed(byName.get(name))
9391
+ return Layer39.succeed(SkillSource, SkillSource.of({
9392
+ all: Effect41.succeed(all),
9393
+ get: (name) => Effect41.succeed(byName.get(name))
9305
9394
  }));
9306
9395
  };
9307
9396
  var empty = fromSkills([]);
9308
- var testLayer34 = (implementation) => Layer38.succeed(SkillSource, SkillSource.of(implementation));
9397
+ var testLayer35 = (implementation) => Layer39.succeed(SkillSource, SkillSource.of(implementation));
9309
9398
  var estimatedTokens = (listing) => Math.ceil(listing.length / 4);
9310
9399
  var usageRank = (skill, recentlyUsed) => {
9311
9400
  const index2 = recentlyUsed.indexOf(skill.frontmatter.name);
@@ -9329,22 +9418,22 @@ var selectListings = (skills, budgetTokens, recentlyUsed) => {
9329
9418
  return selected;
9330
9419
  };
9331
9420
 
9332
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/steering.ts
9421
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/steering.ts
9333
9422
  var exports_steering = {};
9334
9423
  __export(exports_steering, {
9335
- testLayer: () => testLayer35,
9336
- layer: () => layer30,
9424
+ testLayer: () => testLayer36,
9425
+ layer: () => layer31,
9337
9426
  SteeringQueueFull: () => SteeringQueueFull,
9338
9427
  Steering: () => Steering
9339
9428
  });
9340
- import { Context as Context39, Effect as Effect41, Exit, Layer as Layer39, Queue, Schema as Schema45 } from "effect";
9429
+ import { Context as Context40, Effect as Effect42, Exit, Layer as Layer40, Queue, Schema as Schema46 } from "effect";
9341
9430
 
9342
- class Steering extends Context39.Service()("@batonfx/core/Steering") {
9431
+ class Steering extends Context40.Service()("@batonfx/core/Steering") {
9343
9432
  }
9344
9433
 
9345
- class SteeringQueueFull extends Schema45.TaggedErrorClass()("@batonfx/core/SteeringQueueFull", {
9346
- queue: Schema45.Literals(["steering", "followUp"]),
9347
- capacity: Schema45.Number
9434
+ class SteeringQueueFull extends Schema46.TaggedErrorClass()("@batonfx/core/SteeringQueueFull", {
9435
+ queue: Schema46.Literals(["steering", "followUp"]),
9436
+ capacity: Schema46.Number
9348
9437
  }) {
9349
9438
  }
9350
9439
  var resolvePolicy = (policy, mode) => ({
@@ -9363,18 +9452,18 @@ var queueStrategy = (strategy) => {
9363
9452
  return "suspend";
9364
9453
  }
9365
9454
  };
9366
- var makeQueue = (name, policy) => (policy.capacity === undefined ? Queue.unbounded() : Queue.make({ capacity: policy.capacity, strategy: queueStrategy(policy.onFull) })).pipe(Effect41.map((queue) => ({ name, queue, policy })));
9367
- var offer = (runtime, message) => Queue.offer(runtime.queue, message).pipe(Effect41.flatMap((offered) => {
9455
+ 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 })));
9456
+ var offer = (runtime, message) => Queue.offer(runtime.queue, message).pipe(Effect42.flatMap((offered) => {
9368
9457
  if (offered || runtime.policy.capacity === undefined || runtime.policy.onFull !== "fail")
9369
- return Effect41.void;
9370
- return Effect41.fail(new SteeringQueueFull({ queue: runtime.name, capacity: runtime.policy.capacity }));
9458
+ return Effect42.void;
9459
+ return Effect42.fail(new SteeringQueueFull({ queue: runtime.name, capacity: runtime.policy.capacity }));
9371
9460
  }));
9372
- var drainOne = (queue) => Effect41.sync(() => {
9461
+ var drainOne = (queue) => Effect42.sync(() => {
9373
9462
  const taken = Queue.takeUnsafe(queue);
9374
9463
  return taken === undefined || !Exit.isSuccess(taken) ? [] : [taken.value];
9375
9464
  });
9376
9465
  var drain = (queue, mode) => mode === "all" ? Queue.clear(queue) : drainOne(queue);
9377
- var layer30 = (options = {}) => Layer39.effect(Steering, Effect41.gen(function* () {
9466
+ var layer31 = (options = {}) => Layer40.effect(Steering, Effect42.gen(function* () {
9378
9467
  const steeringQueue = yield* makeQueue("steering", resolvePolicy(options.steering, "all"));
9379
9468
  const followUpQueue = yield* makeQueue("followUp", resolvePolicy(options.followUp, "one-at-a-time"));
9380
9469
  return Steering.of({
@@ -9384,30 +9473,30 @@ var layer30 = (options = {}) => Layer39.effect(Steering, Effect41.gen(function*
9384
9473
  takeFollowUp: () => drain(followUpQueue.queue, followUpQueue.policy.mode)
9385
9474
  });
9386
9475
  }));
9387
- var testLayer35 = (implementation) => Layer39.succeed(Steering, Steering.of(implementation));
9476
+ var testLayer36 = (implementation) => Layer40.succeed(Steering, Steering.of(implementation));
9388
9477
 
9389
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/tool-context.ts
9478
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/tool-context.ts
9390
9479
  var exports_tool_context = {};
9391
9480
  __export(exports_tool_context, {
9392
- testLayer: () => testLayer36,
9481
+ testLayer: () => testLayer37,
9393
9482
  layerDefault: () => layerDefault,
9394
9483
  ToolContext: () => ToolContext
9395
9484
  });
9396
- import { Context as Context40, Effect as Effect42, Layer as Layer40 } from "effect";
9485
+ import { Context as Context41, Effect as Effect43, Layer as Layer41 } from "effect";
9397
9486
 
9398
- class ToolContext extends Context40.Service()("@batonfx/core/ToolContext") {
9487
+ class ToolContext extends Context41.Service()("@batonfx/core/ToolContext") {
9399
9488
  }
9400
- var layerDefault = Layer40.sync(ToolContext, () => ToolContext.of({
9489
+ var layerDefault = Layer41.sync(ToolContext, () => ToolContext.of({
9401
9490
  signal: new AbortController().signal,
9402
- emit: () => Effect42.void,
9491
+ emit: () => Effect43.void,
9403
9492
  sessionId: "local"
9404
9493
  }));
9405
- var testLayer36 = (implementation) => Layer40.succeed(ToolContext, ToolContext.of(implementation));
9494
+ var testLayer37 = (implementation) => Layer41.succeed(ToolContext, ToolContext.of(implementation));
9406
9495
 
9407
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/tool-executor.ts
9496
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/tool-executor.ts
9408
9497
  var exports_tool_executor = {};
9409
9498
  __export(exports_tool_executor, {
9410
- testLayer: () => testLayer37,
9499
+ testLayer: () => testLayer38,
9411
9500
  sandbox: () => sandbox,
9412
9501
  router: () => router,
9413
9502
  routeToolkit: () => routeToolkit,
@@ -9419,8 +9508,8 @@ __export(exports_tool_executor, {
9419
9508
  client: () => client,
9420
9509
  ToolExecutor: () => ToolExecutor
9421
9510
  });
9422
- import { Cause as Cause2, Context as Context41, Effect as Effect43, Layer as Layer41, Option as Option14, Schema as Schema46, Sink as Sink2, Stream as Stream6 } from "effect";
9423
- class ToolExecutor extends Context41.Service()("@batonfx/core/ToolExecutor") {
9511
+ 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";
9512
+ class ToolExecutor extends Context42.Service()("@batonfx/core/ToolExecutor") {
9424
9513
  }
9425
9514
  var failureMessage = (cause) => {
9426
9515
  const error = Cause2.squash(cause);
@@ -9442,47 +9531,47 @@ var resultMessage = (result) => {
9442
9531
  var schemaMessage = (error) => error instanceof Error ? error.message : typeof error === "string" ? error : resultMessage(error);
9443
9532
  var decodeSuccess = (tool2, result) => {
9444
9533
  const successSchema = tool2.successSchema;
9445
- if (!Schema46.isSchema(successSchema)) {
9446
- return Effect43.succeed({ _tag: "Success", result, encodedResult: result });
9534
+ if (!Schema47.isSchema(successSchema)) {
9535
+ return Effect44.succeed({ _tag: "Success", result, encodedResult: result });
9447
9536
  }
9448
- return Schema46.decodeUnknownEffect(successSchema)(result).pipe(Effect43.flatMap((decoded) => Schema46.encodeUnknownEffect(successSchema)(decoded).pipe(Effect43.map((encoded) => ({ _tag: "Success", result: decoded, encodedResult: encoded })))), Effect43.catchCause((cause) => Effect43.succeed(failureOutcome(`invalid client result: ${schemaMessage(Cause2.squash(cause))}`))));
9537
+ 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))}`))));
9449
9538
  };
9450
9539
  var placementOutcome = (placement, tool2, response) => {
9451
9540
  switch (response._tag) {
9452
9541
  case "Failure":
9453
- return Effect43.succeed(failureOutcome(response.message));
9542
+ return Effect44.succeed(failureOutcome(response.message));
9454
9543
  case "Suspend":
9455
- return Effect43.succeed({ _tag: "Suspend", token: response.token });
9544
+ return Effect44.succeed({ _tag: "Suspend", token: response.token });
9456
9545
  case "Success":
9457
- return decodeSuccess(tool2, response.result).pipe(Effect43.map((outcome) => outcome._tag === "Failure" ? failureOutcome(outcome.message.replace("invalid client result", `invalid ${placement} result`)) : outcome));
9546
+ return decodeSuccess(tool2, response.result).pipe(Effect44.map((outcome) => outcome._tag === "Failure" ? failureOutcome(outcome.message.replace("invalid client result", `invalid ${placement} result`)) : outcome));
9458
9547
  }
9459
9548
  };
9460
9549
  var executeWithToolkit = (toolkit, request) => {
9461
9550
  if (toolkit.tools[request.call.name] === undefined) {
9462
- return Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
9551
+ return Effect44.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
9463
9552
  }
9464
- return toolkit.handle(request.call.name, request.call.params).pipe(Effect43.flatMap((results) => results.pipe(Stream6.filter((item) => item.preliminary === false), Stream6.run(Sink2.last()))), Effect43.map(Option14.match({
9553
+ 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({
9465
9554
  onNone: () => failureOutcome("Tool handler did not produce a final result"),
9466
9555
  onSome: (result) => result.isFailure ? failureOutcome(resultMessage(result.result)) : {
9467
9556
  _tag: "Success",
9468
9557
  result: result.result,
9469
9558
  encodedResult: result.encodedResult
9470
9559
  }
9471
- })), Effect43.catchCause((cause) => {
9560
+ })), Effect44.catchCause((cause) => {
9472
9561
  if (Cause2.hasInterrupts(cause))
9473
- return Effect43.interrupt;
9562
+ return Effect44.interrupt;
9474
9563
  const error = Cause2.squash(cause);
9475
9564
  if (error instanceof AgentSuspended) {
9476
- return Effect43.succeed({ _tag: "Suspend", token: error.token });
9565
+ return Effect44.succeed({ _tag: "Suspend", token: error.token });
9477
9566
  }
9478
- return Effect43.succeed(failureOutcome(failureMessage(cause)));
9567
+ return Effect44.succeed(failureOutcome(failureMessage(cause)));
9479
9568
  }));
9480
9569
  };
9481
9570
  function executeToolkit(toolkit, request) {
9482
- return ("handle" in toolkit ? Effect43.succeed(toolkit) : toolkit).pipe(Effect43.flatMap((handled) => executeWithToolkit(handled, request)));
9571
+ return ("handle" in toolkit ? Effect44.succeed(toolkit) : toolkit).pipe(Effect44.flatMap((handled) => executeWithToolkit(handled, request)));
9483
9572
  }
9484
9573
  function fromToolkit(toolkit) {
9485
- return Layer41.effect(ToolExecutor, ("handle" in toolkit ? Effect43.succeed(toolkit) : toolkit).pipe(Effect43.map((handled) => ToolExecutor.of({
9574
+ return Layer42.effect(ToolExecutor, ("handle" in toolkit ? Effect44.succeed(toolkit) : toolkit).pipe(Effect44.map((handled) => ToolExecutor.of({
9486
9575
  execute: (request) => executeWithToolkit(handled, request)
9487
9576
  }))));
9488
9577
  }
@@ -9501,10 +9590,10 @@ var placementRoute = (placement, options) => {
9501
9590
  execute: (request) => {
9502
9591
  const tool2 = options.toolkit.tools[request.call.name];
9503
9592
  if (tool2 === undefined)
9504
- return Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
9593
+ return Effect44.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
9505
9594
  const effect = options.execute({ ...request, placement, tool: tool2 });
9506
- const scheduled = "schedule" in options && options.schedule !== undefined ? Effect43.retry(effect, options.schedule) : effect;
9507
- return scheduled.pipe(Effect43.flatMap((response) => placementOutcome(placement, tool2, response)), Effect43.catchCause((cause) => Cause2.hasInterrupts(cause) ? Effect43.interrupt : Effect43.succeed(failureOutcome(`${placement} tool infrastructure failed: ${failureMessage(cause)}`))));
9595
+ const scheduled = "schedule" in options && options.schedule !== undefined ? Effect44.retry(effect, options.schedule) : effect;
9596
+ 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)}`))));
9508
9597
  }
9509
9598
  });
9510
9599
  };
@@ -9517,20 +9606,20 @@ function routeToolkit(toolkit) {
9517
9606
  tools: Object.keys(handled.tools),
9518
9607
  execute: (request) => executeWithToolkit(handled, request)
9519
9608
  });
9520
- return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(Effect43.map(makeRoute));
9609
+ return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(Effect44.map(makeRoute));
9521
9610
  }
9522
- var routeInputEffect = (input) => Effect43.isEffect(input) ? input : Effect43.succeed(input);
9611
+ var routeInputEffect = (input) => Effect44.isEffect(input) ? input : Effect44.succeed(input);
9523
9612
  function router(routes) {
9524
- return Layer41.effect(ToolExecutor, Effect43.all(Array.from(routes, routeInputEffect)).pipe(Effect43.map((resolved) => ToolExecutor.of({
9613
+ return Layer42.effect(ToolExecutor, Effect44.all(Array.from(routes, routeInputEffect)).pipe(Effect44.map((resolved) => ToolExecutor.of({
9525
9614
  execute: (request) => {
9526
9615
  const matched = resolved.find((candidate) => candidate.matches(request));
9527
- return matched === undefined ? Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`)) : matched.execute(request);
9616
+ return matched === undefined ? Effect44.succeed(failureOutcome(`Tool ${request.call.name} is not registered`)) : matched.execute(request);
9528
9617
  }
9529
9618
  }))));
9530
9619
  }
9531
- var testLayer37 = (implementation) => Layer41.succeed(ToolExecutor, ToolExecutor.of(implementation));
9620
+ var testLayer38 = (implementation) => Layer42.succeed(ToolExecutor, ToolExecutor.of(implementation));
9532
9621
 
9533
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/turn-policy.ts
9622
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/turn-policy.ts
9534
9623
  var exports_turn_policy = {};
9535
9624
  __export(exports_turn_policy, {
9536
9625
  untilToolCall: () => untilToolCall,
@@ -9540,7 +9629,7 @@ __export(exports_turn_policy, {
9540
9629
  decision: () => decision,
9541
9630
  both: () => both
9542
9631
  });
9543
- import { Effect as Effect44 } from "effect";
9632
+ import { Effect as Effect45 } from "effect";
9544
9633
  var decision = {
9545
9634
  continue: (overrides) => ({
9546
9635
  _tag: "Continue",
@@ -9549,8 +9638,8 @@ var decision = {
9549
9638
  stop: { _tag: "Stop" }
9550
9639
  };
9551
9640
  var make4 = (decide) => ({ decide });
9552
- var recurs = (n) => make4((info) => Effect44.succeed(info.turn < n + 1 ? decision.continue() : decision.stop));
9553
- var untilToolCall = (name) => make4((info) => Effect44.succeed(info.pendingToolResults.some((result) => result.name === name) ? decision.stop : decision.continue()));
9641
+ var recurs = (n) => make4((info) => Effect45.succeed(info.turn < n + 1 ? decision.continue() : decision.stop));
9642
+ var untilToolCall = (name) => make4((info) => Effect45.succeed(info.pendingToolResults.some((result) => result.name === name) ? decision.stop : decision.continue()));
9554
9643
  var mergeOverrides = (first, second) => {
9555
9644
  if (first === undefined)
9556
9645
  return second;
@@ -9558,7 +9647,7 @@ var mergeOverrides = (first, second) => {
9558
9647
  return first;
9559
9648
  return { ...first, ...second };
9560
9649
  };
9561
- var both = (first, second) => make4((info) => Effect44.gen(function* () {
9650
+ var both = (first, second) => make4((info) => Effect45.gen(function* () {
9562
9651
  const left = yield* first.decide(info);
9563
9652
  if (left._tag === "Stop")
9564
9653
  return decision.stop;
@@ -9569,14 +9658,17 @@ var both = (first, second) => make4((info) => Effect44.gen(function* () {
9569
9658
  }));
9570
9659
  var defaultPolicy = recurs(8);
9571
9660
 
9572
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/agent.ts
9661
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/agent.ts
9573
9662
  function make5(nameOrOptions, options = {}) {
9574
9663
  const resolved = typeof nameOrOptions === "string" ? { ...options, name: nameOrOptions } : nameOrOptions;
9575
9664
  return {
9576
9665
  name: resolved.name,
9577
9666
  ...resolved.instructions === undefined ? {} : { instructions: resolved.instructions },
9578
9667
  toolkit: resolved.toolkit ?? Toolkit3.empty,
9579
- policy: resolved.policy ?? defaultPolicy
9668
+ policy: resolved.policy ?? defaultPolicy,
9669
+ ...resolved.model === undefined ? {} : { model: resolved.model },
9670
+ ...resolved.memory === undefined ? {} : { memory: resolved.memory },
9671
+ ...resolved.metadata === undefined ? {} : { metadata: resolved.metadata }
9580
9672
  };
9581
9673
  }
9582
9674
  var defaultObjectPrompt = "Return the final structured output for the task above.";
@@ -9588,14 +9680,14 @@ var steeringDrainedEvent = (turn, queue, messages) => ({
9588
9680
  });
9589
9681
  var skillListingBudgetTokens = 2048;
9590
9682
  var activateSkillToolName = "activate_skill";
9591
- var activateSkillParameters = Schema47.Struct({ name: Schema47.String });
9683
+ var activateSkillParameters = Schema48.Struct({ name: Schema48.String });
9592
9684
  var activateSkillTool = Tool4.make(activateSkillToolName, {
9593
9685
  description: "Load the full body for one listed Baton skill by name before applying that skill.",
9594
9686
  parameters: activateSkillParameters,
9595
- success: Schema47.Struct({
9596
- name: Schema47.String,
9597
- body: Schema47.String,
9598
- allowedTools: Schema47.Array(Schema47.String)
9687
+ success: Schema48.Struct({
9688
+ name: Schema48.String,
9689
+ body: Schema48.String,
9690
+ allowedTools: Schema48.Array(Schema48.String)
9599
9691
  })
9600
9692
  });
9601
9693
  var errorMessage = (error) => error instanceof Error ? `${error.name}: ${error.message}` : String(error);
@@ -9642,15 +9734,15 @@ var isUserMessagePart = (part) => part.type === "text" || part.type === "file";
9642
9734
  var approvalRequired = (tool2, call, messages) => {
9643
9735
  const needsApproval = tool2?.needsApproval;
9644
9736
  if (needsApproval === undefined)
9645
- return Effect45.succeed(false);
9737
+ return Effect46.succeed(false);
9646
9738
  if (typeof needsApproval === "boolean")
9647
- return Effect45.succeed(needsApproval);
9648
- return Effect45.suspend(() => {
9739
+ return Effect46.succeed(needsApproval);
9740
+ return Effect46.suspend(() => {
9649
9741
  const result = needsApproval(call.params, { toolCallId: call.id, messages });
9650
- return Effect45.isEffect(result) ? result : Effect45.succeed(result);
9651
- }).pipe(Effect45.catchCause((cause) => Cause3.hasInterrupts(cause) ? Effect45.interrupt : Effect45.succeed(true)));
9742
+ return Effect46.isEffect(result) ? result : Effect46.succeed(result);
9743
+ }).pipe(Effect46.catchCause((cause) => Cause3.hasInterrupts(cause) ? Effect46.interrupt : Effect46.succeed(true)));
9652
9744
  };
9653
- var applyPromptChain = (chain, prompt, context) => Effect45.gen(function* () {
9745
+ var applyPromptChain = (chain, prompt, context) => Effect46.gen(function* () {
9654
9746
  let current2 = prompt;
9655
9747
  for (const middleware of chain) {
9656
9748
  if (middleware.transformPrompt !== undefined) {
@@ -9659,10 +9751,10 @@ var applyPromptChain = (chain, prompt, context) => Effect45.gen(function* () {
9659
9751
  }
9660
9752
  return current2;
9661
9753
  });
9662
- var applyPartChain = (chain, part, context) => Effect45.gen(function* () {
9663
- let current2 = Option15.some(part);
9754
+ var applyPartChain = (chain, part, context) => Effect46.gen(function* () {
9755
+ let current2 = Option16.some(part);
9664
9756
  for (const middleware of chain) {
9665
- if (Option15.isNone(current2))
9757
+ if (Option16.isNone(current2))
9666
9758
  break;
9667
9759
  if (middleware.transformPart !== undefined) {
9668
9760
  current2 = yield* middleware.transformPart(current2.value, context);
@@ -9670,74 +9762,83 @@ var applyPartChain = (chain, part, context) => Effect45.gen(function* () {
9670
9762
  }
9671
9763
  return current2;
9672
9764
  });
9673
- var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen(function* () {
9674
- const executor = yield* Effect45.serviceOption(ToolExecutor);
9675
- const approvals = yield* Effect45.serviceOption(Approvals);
9676
- const chain = yield* Effect45.serviceOption(ModelMiddleware).pipe(Effect45.map(Option15.match({ onNone: () => [], onSome: (service) => service })));
9765
+ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect46.gen(function* () {
9766
+ const executor = yield* Effect46.serviceOption(ToolExecutor);
9767
+ const approvals = yield* Effect46.serviceOption(Approvals);
9768
+ const chain = yield* Effect46.serviceOption(ModelMiddleware).pipe(Effect46.map(Option16.match({ onNone: () => [], onSome: (service) => service })));
9677
9769
  if (options.history !== undefined && options.persistence !== undefined) {
9678
- return yield* Effect45.fail(new AgentError({
9770
+ return yield* Effect46.fail(new AgentError({
9679
9771
  message: "RunOptions.history and RunOptions.persistence are mutually exclusive",
9680
9772
  turn: 0
9681
9773
  }));
9682
9774
  }
9683
9775
  if (options.toolOutputMaxBytes !== undefined && (!Number.isFinite(options.toolOutputMaxBytes) || options.toolOutputMaxBytes < 0)) {
9684
- return yield* Effect45.fail(new AgentError({
9776
+ return yield* Effect46.fail(new AgentError({
9685
9777
  message: "RunOptions.toolOutputMaxBytes must be a non-negative finite number",
9686
9778
  turn: 0
9687
9779
  }));
9688
9780
  }
9689
9781
  if (options.compaction?.contextWindow !== undefined && (!Number.isFinite(options.compaction.contextWindow) || options.compaction.contextWindow <= 0)) {
9690
- return yield* Effect45.fail(new AgentError({
9782
+ return yield* Effect46.fail(new AgentError({
9691
9783
  message: "RunOptions.compaction.contextWindow must be a positive finite number",
9692
9784
  turn: 0
9693
9785
  }));
9694
9786
  }
9695
9787
  const sessionId = options.sessionId ?? "local";
9696
- const instructionsService = yield* Effect45.serviceOption(Instructions);
9697
- const skillSourceService = yield* Effect45.serviceOption(SkillSource);
9698
- const skillRuntime = Option15.isNone(skillSourceService) ? undefined : {
9788
+ const instructionsService = yield* Effect46.serviceOption(Instructions);
9789
+ const skillSourceService = yield* Effect46.serviceOption(SkillSource);
9790
+ const skillRuntime = Option16.isNone(skillSourceService) ? undefined : {
9699
9791
  source: skillSourceService.value,
9700
- skills: yield* skillSourceService.value.all.pipe(Effect45.mapError((error) => new AgentError({ message: error.message, turn: 0, cause: error })))
9792
+ skills: yield* skillSourceService.value.all.pipe(Effect46.mapError((error) => new AgentError({ message: error.message, turn: 0, cause: error })))
9701
9793
  };
9702
9794
  const selectedSkills = skillRuntime === undefined ? [] : selectListings(skillRuntime.skills, skillListingBudgetTokens, []);
9703
9795
  const skillListings = selectedSkills.map((skill) => skill.listing).join(`
9704
9796
  `);
9705
9797
  const hasActivatableSkills = selectedSkills.length > 0;
9706
- const instructionsEpoch = options.system === undefined && options.history === undefined && Option15.isSome(instructionsService) ? yield* openEpoch(instructionsService.value, { agentName: agent.name, turn: 0 }) : undefined;
9798
+ const instructionsEpoch = options.system === undefined && options.history === undefined && Option16.isSome(instructionsService) ? yield* openEpoch(instructionsService.value, { agentName: agent.name, turn: 0 }) : undefined;
9707
9799
  const baseSystem = options.system ?? (instructionsEpoch === undefined ? agent.instructions : instructionsEpoch.baseline.length === 0 ? agent.instructions : instructionsEpoch.baseline);
9708
9800
  const system = appendInstructionFragment(baseSystem, options.history === undefined && skillListings.length > 0 ? skillListingsInstructions(skillListings) : undefined);
9709
- const persistenceService = yield* Effect45.serviceOption(Chat.Persistence);
9710
- const resilienceService = yield* Effect45.serviceOption(ModelResilience);
9711
- const permissionsService = yield* Effect45.serviceOption(Permissions);
9712
- const steeringService = yield* Effect45.serviceOption(Steering);
9713
- const compactionService = yield* Effect45.serviceOption(Compaction);
9714
- const memoryService = yield* Effect45.serviceOption(Memory);
9715
- const sessionService = yield* Effect45.serviceOption(SessionStore);
9716
- const tokenizerService = yield* Effect45.serviceOption(Tokenizer2.Tokenizer);
9801
+ const persistenceService = yield* Effect46.serviceOption(Chat.Persistence);
9802
+ const resilienceService = yield* Effect46.serviceOption(ModelResilience);
9803
+ const modelRegistryService = yield* Effect46.serviceOption(Service29);
9804
+ const permissionsService = yield* Effect46.serviceOption(Permissions);
9805
+ const steeringService = yield* Effect46.serviceOption(Steering);
9806
+ const compactionService = yield* Effect46.serviceOption(Compaction);
9807
+ const memoryService = yield* Effect46.serviceOption(Memory);
9808
+ const sessionService = yield* Effect46.serviceOption(SessionStore);
9809
+ const tokenizerService = yield* Effect46.serviceOption(Tokenizer2.Tokenizer);
9717
9810
  const persistenceOptions = options.persistence;
9718
- const memoryOptions = options.memory;
9811
+ const memoryOptions = options.memory ?? (agent.memory === undefined ? undefined : { key: agent.memory });
9812
+ const agentModel = agent.model;
9813
+ const agentModelContext = agentModel === undefined ? undefined : yield* Option16.match(modelRegistryService, {
9814
+ onNone: () => Effect46.fail(new AgentError({
9815
+ message: "Agent.model requires ModelRegistry in context",
9816
+ turn: 0
9817
+ })),
9818
+ onSome: (registry) => registry.provide(agentModel, Effect46.context()).pipe(Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })))
9819
+ });
9719
9820
  const memoryRuntime = memoryOptions === undefined ? undefined : {
9720
9821
  key: memoryOptions.key,
9721
- service: yield* Option15.match(memoryService, {
9722
- onNone: () => Effect45.fail(new AgentError({
9723
- message: "RunOptions.memory requires Memory in context",
9822
+ service: yield* Option16.match(memoryService, {
9823
+ onNone: () => Effect46.fail(new AgentError({
9824
+ message: options.memory === undefined ? "Agent.memory requires Memory in context" : "RunOptions.memory requires Memory in context",
9724
9825
  turn: 0
9725
9826
  })),
9726
- onSome: Effect45.succeed
9827
+ onSome: Effect46.succeed
9727
9828
  })
9728
9829
  };
9729
- const persisted = persistenceOptions === undefined ? undefined : yield* Option15.match(persistenceService, {
9730
- onNone: () => Effect45.fail(new AgentError({
9830
+ const persisted = persistenceOptions === undefined ? undefined : yield* Option16.match(persistenceService, {
9831
+ onNone: () => Effect46.fail(new AgentError({
9731
9832
  message: "RunOptions.persistence requires Chat.Persistence in context",
9732
9833
  turn: 0
9733
9834
  })),
9734
- onSome: (service) => service.getOrCreate(persistenceOptions.chatId, persistenceOptions.timeToLive === undefined ? undefined : { timeToLive: persistenceOptions.timeToLive }).pipe(Effect45.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })))
9835
+ 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 })))
9735
9836
  });
9736
- const seedSystem = persisted !== undefined && system !== undefined && (yield* Ref10.get(persisted.history)).content.length === 0 ? system : undefined;
9837
+ const seedSystem = persisted !== undefined && system !== undefined && (yield* Ref11.get(persisted.history)).content.length === 0 ? system : undefined;
9737
9838
  const freshChat = options.history !== undefined ? Chat.fromPrompt(options.history) : system !== undefined ? Chat.fromPrompt([Prompt4.makeMessage("system", { content: system })]) : Chat.empty;
9738
9839
  const chat = persisted ?? (yield* freshChat);
9739
- const savePersisted = persisted === undefined ? Effect45.void : persisted.save.pipe(Effect45.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })));
9740
- const failSuspended = (call, token, reason) => Stream7.unwrap(savePersisted.pipe(Effect45.as(Stream7.fail(suspended(call, token, reason)))));
9840
+ const savePersisted = persisted === undefined ? Effect46.void : persisted.save.pipe(Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })));
9841
+ const failSuspended = (call, token, reason) => Stream7.unwrap(savePersisted.pipe(Effect46.as(Stream7.fail(suspended(call, token, reason)))));
9741
9842
  const state = {
9742
9843
  text: "",
9743
9844
  turn: 0,
@@ -9750,20 +9851,20 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9750
9851
  const activatedSkillTools = new Map;
9751
9852
  let sessionSyncedMessages = 0;
9752
9853
  let sessionInitialized = false;
9753
- const activeSession = Option15.isSome(compactionService) ? sessionService : Option15.none();
9854
+ const activeSession = Option16.isSome(compactionService) ? sessionService : Option16.none();
9754
9855
  const sessionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
9755
9856
  const compactionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
9756
9857
  const memoryError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
9757
9858
  const skillError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
9758
9859
  const isSkillActivationCall = (call) => call.name === activateSkillToolName && skillRuntime !== undefined && hasActivatableSkills;
9759
- const insertRecalledItems = (turn, prompt, items) => Effect45.gen(function* () {
9860
+ const insertRecalledItems = (turn, prompt, items) => Effect46.gen(function* () {
9760
9861
  const parts = items.flatMap((item) => item.parts);
9761
9862
  if (parts.length === 0)
9762
9863
  return prompt;
9763
9864
  const userParts = [];
9764
9865
  for (const part of parts) {
9765
9866
  if (!isUserMessagePart(part)) {
9766
- return yield* Effect45.fail(new AgentError({
9867
+ return yield* Effect46.fail(new AgentError({
9767
9868
  message: `Memory recalled unsupported prompt part type: ${part.type}`,
9768
9869
  turn
9769
9870
  }));
@@ -9774,12 +9875,12 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9774
9875
  const [first, ...rest] = prompt.content;
9775
9876
  return first?.role === "system" ? Prompt4.fromMessages([first, memoryMessage2, ...rest]) : Prompt4.fromMessages([memoryMessage2, ...prompt.content]);
9776
9877
  });
9777
- const recallInitialPrompt = (prompt) => memoryRuntime === undefined ? Effect45.succeed(prompt) : memoryRuntime.service.recall({ key: memoryRuntime.key, turn: 0, prompt }).pipe(Effect45.mapError((error) => memoryError(0, error)), Effect45.flatMap((items) => insertRecalledItems(0, prompt, items)));
9778
- const rememberTurn = (turn, transcript, terminal) => memoryRuntime === undefined ? Effect45.void : memoryRuntime.service.remember({ key: memoryRuntime.key, turn, transcript, terminal }).pipe(Effect45.mapError((error) => memoryError(turn, error)));
9779
- const syncSession = (turn, transcript) => Option15.match(activeSession, {
9780
- onNone: () => Effect45.succeed([]),
9781
- onSome: (session) => Effect45.gen(function* () {
9782
- const existingPath = yield* session.path().pipe(Effect45.mapError((error) => sessionError(turn, error)));
9878
+ 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)));
9879
+ 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)));
9880
+ const syncSession = (turn, transcript) => Option16.match(activeSession, {
9881
+ onNone: () => Effect46.succeed([]),
9882
+ onSome: (session) => Effect46.gen(function* () {
9883
+ const existingPath = yield* session.path().pipe(Effect46.mapError((error) => sessionError(turn, error)));
9783
9884
  if (!sessionInitialized) {
9784
9885
  sessionInitialized = true;
9785
9886
  if (existingPath.length > 0) {
@@ -9788,40 +9889,40 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9788
9889
  }
9789
9890
  }
9790
9891
  for (const message of transcript.content.slice(sessionSyncedMessages)) {
9791
- yield* session.append({ _tag: "Message", message }).pipe(Effect45.mapError((error) => sessionError(turn, error)));
9892
+ yield* session.append({ _tag: "Message", message }).pipe(Effect46.mapError((error) => sessionError(turn, error)));
9792
9893
  }
9793
9894
  sessionSyncedMessages = transcript.content.length;
9794
- return yield* session.path().pipe(Effect45.mapError((error) => sessionError(turn, error)));
9895
+ return yield* session.path().pipe(Effect46.mapError((error) => sessionError(turn, error)));
9795
9896
  })
9796
9897
  });
9797
9898
  const countTokens = (turn, prompt) => {
9798
9899
  if (state.contextTokens !== undefined)
9799
- return Effect45.succeed(state.contextTokens);
9800
- return Option15.match(tokenizerService, {
9801
- onNone: () => Effect45.succeed(0),
9802
- onSome: (tokenizer) => tokenizer.tokenize(prompt).pipe(Effect45.map((tokens) => tokens.length), Effect45.mapError((error) => new AgentError({ message: errorMessage(error), turn, cause: error })))
9900
+ return Effect46.succeed(state.contextTokens);
9901
+ return Option16.match(tokenizerService, {
9902
+ onNone: () => Effect46.succeed(0),
9903
+ onSome: (tokenizer) => tokenizer.tokenize(prompt).pipe(Effect46.map((tokens) => tokens.length), Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn, cause: error })))
9803
9904
  });
9804
9905
  };
9805
- const compactionUsage = (turn, history, prompt) => countTokens(turn, Prompt4.concat(history, prompt)).pipe(Effect45.map((contextTokens) => ({
9906
+ const compactionUsage = (turn, history, prompt) => countTokens(turn, Prompt4.concat(history, prompt)).pipe(Effect46.map((contextTokens) => ({
9806
9907
  contextTokens,
9807
9908
  contextWindow: options.compaction?.contextWindow ?? Number.POSITIVE_INFINITY,
9808
9909
  reserveTokens: DEFAULT_RESERVE_TOKENS
9809
9910
  })));
9810
- const applyCompactionResult = (turn, result) => Effect45.gen(function* () {
9811
- yield* Ref10.set(chat.history, result.history);
9911
+ const applyCompactionResult = (turn, result) => Effect46.gen(function* () {
9912
+ yield* Ref11.set(chat.history, result.history);
9812
9913
  sessionSyncedMessages = result.history.content.length;
9813
- if (result._tag === "Summarize" && Option15.isSome(activeSession)) {
9914
+ if (result._tag === "Summarize" && Option16.isSome(activeSession)) {
9814
9915
  yield* activeSession.value.append({
9815
9916
  _tag: "Compaction",
9816
9917
  summary: result.summary,
9817
9918
  firstKeptEntryId: result.firstKeptEntryId
9818
- }).pipe(Effect45.mapError((error) => sessionError(turn, error)));
9919
+ }).pipe(Effect46.mapError((error) => sessionError(turn, error)));
9819
9920
  }
9820
9921
  });
9821
- const preparePrompt = (turn, prompt, overflow) => Option15.match(compactionService, {
9822
- onNone: () => Effect45.succeed(prompt),
9823
- onSome: (compaction) => Effect45.gen(function* () {
9824
- const history = yield* Ref10.get(chat.history);
9922
+ const preparePrompt = (turn, prompt, overflow) => Option16.match(compactionService, {
9923
+ onNone: () => Effect46.succeed(prompt),
9924
+ onSome: (compaction) => Effect46.gen(function* () {
9925
+ const history = yield* Ref11.get(chat.history);
9825
9926
  const path2 = yield* syncSession(turn, history);
9826
9927
  const usage = yield* compactionUsage(turn, history, prompt);
9827
9928
  const compacted = yield* compaction.maybeCompact({
@@ -9834,28 +9935,28 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9834
9935
  usage,
9835
9936
  overflow,
9836
9937
  ...options.toolOutputMaxBytes === undefined ? {} : { toolOutputMaxBytes: options.toolOutputMaxBytes }
9837
- }).pipe(Effect45.mapError((error) => compactionError(turn, error)));
9838
- if (Option15.isNone(compacted))
9938
+ }).pipe(Effect46.mapError((error) => compactionError(turn, error)));
9939
+ if (Option16.isNone(compacted))
9839
9940
  return prompt;
9840
9941
  yield* applyCompactionResult(turn, compacted.value);
9841
9942
  return compacted.value.prompt;
9842
9943
  })
9843
9944
  });
9844
- const boundedSuccessResult = (turn, call, outcome) => (options.toolOutputMaxBytes === undefined ? Effect45.succeed(outcome) : bound(outcome, { toolCallId: call.id, maxBytes: options.toolOutputMaxBytes }).pipe(Effect45.mapError((error) => new AgentError({ message: error.message, turn, cause: error })))).pipe(Effect45.map((bounded) => successResult(call, bounded)));
9945
+ 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)));
9845
9946
  const outcomeEvents = (turn, call, outcome) => {
9846
9947
  switch (outcome._tag) {
9847
9948
  case "Success":
9848
- return (isSkillActivationCall(call) ? Effect45.succeed(successResult(call, outcome)) : boundedSuccessResult(turn, call, outcome)).pipe(Effect45.map((result) => {
9949
+ return (isSkillActivationCall(call) ? Effect46.succeed(successResult(call, outcome)) : boundedSuccessResult(turn, call, outcome)).pipe(Effect46.map((result) => {
9849
9950
  state.pending.push(result);
9850
9951
  return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
9851
9952
  }));
9852
9953
  case "Failure": {
9853
9954
  const result = failedResult(call, outcome.message);
9854
9955
  state.pending.push(result);
9855
- return Effect45.succeed(Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]));
9956
+ return Effect46.succeed(Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]));
9856
9957
  }
9857
9958
  case "Suspend":
9858
- return Effect45.succeed(failSuspended(call, outcome.token, "tool-wait"));
9959
+ return Effect46.succeed(failSuspended(call, outcome.token, "tool-wait"));
9859
9960
  }
9860
9961
  };
9861
9962
  const defaultExecute = (request) => {
@@ -9863,11 +9964,11 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9863
9964
  return executeToolkit(agent.toolkit, request);
9864
9965
  }
9865
9966
  const activated = activatedSkillTools.get(request.call.name);
9866
- return activated === undefined ? Effect45.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(Toolkit3.make(activated), request);
9967
+ return activated === undefined ? Effect46.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(Toolkit3.make(activated), request);
9867
9968
  };
9868
- const executeApproved = (turn, call, request) => Stream7.concat(Stream7.fromIterable([{ _tag: "ToolExecutionStarted", turn, call }]), Stream7.unwrap(Effect45.gen(function* () {
9969
+ const executeApproved = (turn, call, request) => Stream7.concat(Stream7.fromIterable([{ _tag: "ToolExecutionStarted", turn, call }]), Stream7.unwrap(Effect46.gen(function* () {
9869
9970
  const progressQueue = yield* Queue2.unbounded();
9870
- const signal = yield* Effect45.abortSignal;
9971
+ const signal = yield* Effect46.abortSignal;
9871
9972
  const context = ToolContext.of({
9872
9973
  signal,
9873
9974
  sessionId,
@@ -9879,14 +9980,14 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9879
9980
  ...progress.message === undefined ? {} : { message: progress.message },
9880
9981
  ...progress.data === undefined ? {} : { data: progress.data }
9881
9982
  };
9882
- return Queue2.offer(progressQueue, event).pipe(Effect45.asVoid);
9983
+ return Queue2.offer(progressQueue, event).pipe(Effect46.asVoid);
9883
9984
  }
9884
9985
  });
9885
- const execution = isSkillActivationCall(call) ? activateSkillOutcome(turn, call) : Option15.match(executor, {
9986
+ const execution = isSkillActivationCall(call) ? activateSkillOutcome(turn, call) : Option16.match(executor, {
9886
9987
  onNone: () => defaultExecute(request),
9887
9988
  onSome: (service) => service.execute(request)
9888
9989
  });
9889
- const fiber = yield* execution.pipe(Effect45.provideService(ToolContext, context), Effect45.ensuring(Queue2.end(progressQueue).pipe(Effect45.asVoid)), Effect45.forkScoped({ startImmediately: true }));
9990
+ const fiber = yield* execution.pipe(Effect46.provideService(ToolContext, context), Effect46.ensuring(Queue2.end(progressQueue).pipe(Effect46.asVoid)), Effect46.forkScoped({ startImmediately: true }));
9890
9991
  return Stream7.concat(Stream7.fromQueue(progressQueue), Stream7.fromEffect(Fiber.join(fiber)).pipe(Stream7.flatMap((outcome) => Stream7.unwrap(outcomeEvents(turn, call, outcome)))));
9891
9992
  })));
9892
9993
  const permissionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
@@ -9895,13 +9996,13 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9895
9996
  state.pending.push(result);
9896
9997
  return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
9897
9998
  };
9898
- const activateSkillOutcome = (turn, call) => Effect45.gen(function* () {
9999
+ const activateSkillOutcome = (turn, call) => Effect46.gen(function* () {
9899
10000
  if (skillRuntime === undefined)
9900
10001
  return { _tag: "Failure", message: "SkillSource is not available" };
9901
- const params = Schema47.decodeUnknownOption(activateSkillParameters)(call.params);
9902
- if (Option15.isNone(params))
10002
+ const params = Schema48.decodeUnknownOption(activateSkillParameters)(call.params);
10003
+ if (Option16.isNone(params))
9903
10004
  return { _tag: "Failure", message: "Skill activation requires a name" };
9904
- const skill = yield* skillRuntime.source.get(params.value.name).pipe(Effect45.mapError((error) => skillError(turn, error)));
10005
+ const skill = yield* skillRuntime.source.get(params.value.name).pipe(Effect46.mapError((error) => skillError(turn, error)));
9905
10006
  if (skill === undefined)
9906
10007
  return { _tag: "Failure", message: `Skill not found: ${params.value.name}` };
9907
10008
  if (skill.frontmatter.disableModelInvocation === true) {
@@ -9909,7 +10010,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9909
10010
  }
9910
10011
  let body = activatedSkillBodies.get(skill.frontmatter.name);
9911
10012
  if (body === undefined) {
9912
- body = yield* skill.body.pipe(Effect45.mapError((error) => skillError(turn, error)));
10013
+ body = yield* skill.body.pipe(Effect46.mapError((error) => skillError(turn, error)));
9913
10014
  activatedSkillBodies.set(skill.frontmatter.name, body);
9914
10015
  for (const tool2 of skill.tools) {
9915
10016
  activatedSkillTools.set(tool2.name, tool2);
@@ -9922,14 +10023,14 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9922
10023
  };
9923
10024
  return { _tag: "Success", result: output, encodedResult: output };
9924
10025
  });
9925
- const rememberAlways = (turn, call) => Effect45.serviceOption(RuleStore).pipe(Effect45.flatMap(Option15.match({
9926
- onNone: () => Effect45.void,
9927
- onSome: (store) => store.remember({ pattern: call.name, level: "allow" }).pipe(Effect45.mapError((error) => permissionError(turn, error)))
10026
+ const rememberAlways = (turn, call) => Effect46.serviceOption(RuleStore).pipe(Effect46.flatMap(Option16.match({
10027
+ onNone: () => Effect46.void,
10028
+ onSome: (store) => store.remember({ pattern: call.name, level: "allow" }).pipe(Effect46.mapError((error) => permissionError(turn, error)))
9928
10029
  })));
9929
- const approvalEvents = (turn, call, messages, request, tool2) => Stream7.unwrap(approvalRequired(tool2, call, messages).pipe(Effect45.map((isRequired) => {
10030
+ const approvalEvents = (turn, call, messages, request, tool2) => Stream7.unwrap(approvalRequired(tool2, call, messages).pipe(Effect46.map((isRequired) => {
9930
10031
  if (!isRequired)
9931
10032
  return executeApproved(turn, call, request);
9932
- if (Option15.isNone(approvals)) {
10033
+ if (Option16.isNone(approvals)) {
9933
10034
  const result = failedResult(call, "Approvals service is required for approval-gated tools");
9934
10035
  state.pending.push(result);
9935
10036
  return Stream7.fromIterable([
@@ -9937,7 +10038,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9937
10038
  { _tag: "ToolExecutionCompleted", turn, call, result }
9938
10039
  ]);
9939
10040
  }
9940
- return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(approvals.value.check(request).pipe(Effect45.map((decision2) => {
10041
+ return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(approvals.value.check(request).pipe(Effect46.map((decision2) => {
9941
10042
  switch (decision2._tag) {
9942
10043
  case "Approved":
9943
10044
  return executeApproved(turn, call, request);
@@ -9958,7 +10059,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9958
10059
  case "Denied":
9959
10060
  return permissionDeniedEvents(turn, call, answer.reason);
9960
10061
  case "Always":
9961
- return Stream7.unwrap(rememberAlways(turn, call).pipe(Effect45.as(executeApproved(turn, call, request))));
10062
+ return Stream7.unwrap(rememberAlways(turn, call).pipe(Effect46.as(executeApproved(turn, call, request))));
9962
10063
  }
9963
10064
  };
9964
10065
  const permissionAskEvents = (turn, call, request, token) => {
@@ -9970,9 +10071,9 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9970
10071
  turn,
9971
10072
  toolCallId: call.id
9972
10073
  };
9973
- if (Option15.isNone(permissionsService))
10074
+ if (Option16.isNone(permissionsService))
9974
10075
  return failSuspended(call, token, "approval");
9975
- return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(permissionsService.value.await(pending).pipe(Effect45.mapError((error) => permissionError(turn, error)), Effect45.map(Option15.match({
10076
+ 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({
9976
10077
  onNone: () => failSuspended(call, token, "approval"),
9977
10078
  onSome: (answer) => permissionAnsweredEvents(turn, call, request, answer)
9978
10079
  })))));
@@ -9980,7 +10081,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9980
10081
  const toolCallEvents = (turn, call, messages) => {
9981
10082
  const request = { call, turn, agentName: agent.name, sessionId };
9982
10083
  const tool2 = currentToolkit().tools[call.name];
9983
- if (Option15.isNone(permissionsService))
10084
+ if (Option16.isNone(permissionsService))
9984
10085
  return approvalEvents(turn, call, messages, request, tool2);
9985
10086
  return Stream7.unwrap(permissionsService.value.evaluate({
9986
10087
  tool: call.name,
@@ -9989,7 +10090,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
9989
10090
  turn,
9990
10091
  toolCallId: call.id,
9991
10092
  sessionId
9992
- }).pipe(Effect45.mapError((error) => permissionError(turn, error)), Effect45.map((decision2) => {
10093
+ }).pipe(Effect46.mapError((error) => permissionError(turn, error)), Effect46.map((decision2) => {
9993
10094
  switch (decision2._tag) {
9994
10095
  case "Allow":
9995
10096
  return approvalEvents(turn, call, messages, request, tool2);
@@ -10000,8 +10101,8 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10000
10101
  }
10001
10102
  })));
10002
10103
  };
10003
- const captureFinishPart = (part) => Effect45.gen(function* () {
10004
- const span = yield* Effect45.currentSpan;
10104
+ const captureFinishPart = (part) => Effect46.gen(function* () {
10105
+ const span = yield* Effect46.currentSpan;
10005
10106
  state.finish = {
10006
10107
  usage: state.finish === undefined ? part.usage : addUsage(state.finish.usage, part.usage),
10007
10108
  reason: part.reason
@@ -10016,18 +10117,20 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10016
10117
  },
10017
10118
  response: { finishReasons: [part.reason] }
10018
10119
  });
10019
- }).pipe(Effect45.orDie);
10020
- const captureStructuredUsage = (content) => Effect45.sync(() => {
10120
+ }).pipe(Effect46.orDie);
10121
+ const captureStructuredUsage = (content) => Effect46.sync(() => {
10021
10122
  for (const part of content) {
10022
10123
  if (part.type === "finish") {
10023
10124
  state.usage = state.usage === undefined ? part.usage : addUsage(state.usage, part.usage);
10024
10125
  }
10025
10126
  }
10026
10127
  });
10027
- const withModelResilience = (effect) => Option15.match(resilienceService, {
10128
+ const withModelResilience = (effect) => Option16.match(resilienceService, {
10028
10129
  onNone: () => effect,
10029
- onSome: (resilience) => Effect45.flatMap(LanguageModel3.LanguageModel, (model) => effect.pipe(Effect45.provideService(LanguageModel3.LanguageModel, apply(model, resilience))))
10130
+ onSome: (resilience) => Effect46.flatMap(LanguageModel4.LanguageModel, (model) => effect.pipe(Effect46.provideService(LanguageModel4.LanguageModel, apply(model, resilience))))
10030
10131
  });
10132
+ const withAgentModel = (effect) => agentModelContext === undefined ? effect : effect.pipe(Effect46.provide(agentModelContext));
10133
+ const provideAgentModel = (stream2) => agentModelContext === undefined ? stream2 : stream2.pipe(Stream7.provideContext(agentModelContext));
10031
10134
  const partEvents = (turn, part, messages) => {
10032
10135
  if (part.type === "error") {
10033
10136
  return Stream7.fail(new AgentError({ message: errorMessage(part.error), turn, cause: part.error }));
@@ -10045,7 +10148,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10045
10148
  }
10046
10149
  return modelPart;
10047
10150
  };
10048
- const applyPartToEvents = (turn, part, messages) => Stream7.unwrap(applyPartChain(chain, part, { agentName: agent.name, turn }).pipe(Effect45.map(Option15.match({
10151
+ const applyPartToEvents = (turn, part, messages) => Stream7.unwrap(applyPartChain(chain, part, { agentName: agent.name, turn }).pipe(Effect46.map(Option16.match({
10049
10152
  onSome: (transformed) => partEvents(turn, transformed, messages),
10050
10153
  onNone: () => part.type === "tool-call" ? Stream7.fail(new MiddlewareViolation({
10051
10154
  turn,
@@ -10056,18 +10159,18 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10056
10159
  const activeToolkit = (activeTools) => Toolkit3.make(...Object.values(currentToolkit().tools).filter((tool2) => activeTools.includes(tool2.name)));
10057
10160
  const modelTurn = (turn, prompt, overrides) => {
10058
10161
  const toolkit = overrides?.activeTools === undefined ? currentToolkit() : activeToolkit(overrides.activeTools);
10059
- const attempt = (activePrompt, retryOverflow) => Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((historyBeforeAttempt) => {
10162
+ const attempt = (activePrompt, retryOverflow) => Stream7.unwrap(Ref11.get(chat.history).pipe(Effect46.map((historyBeforeAttempt) => {
10060
10163
  let emitted = false;
10061
10164
  const messages = Prompt4.concat(historyBeforeAttempt, activePrompt).content;
10062
- return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(Stream7.map((part) => ({ part, messages })), Stream7.tap(() => Effect45.sync(() => {
10165
+ return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(Stream7.map((part) => ({ part, messages })), Stream7.tap(() => Effect46.sync(() => {
10063
10166
  emitted = true;
10064
10167
  })), Stream7.catchCause((cause) => {
10065
10168
  if (Cause3.hasInterrupts(cause))
10066
- return Stream7.fromEffect(Effect45.interrupt);
10169
+ return Stream7.fromEffect(Effect46.interrupt);
10067
10170
  const error = Cause3.squash(cause);
10068
- if (retryOverflow && !emitted && isContextOverflow(error) && Option15.isSome(compactionService)) {
10069
- return Stream7.unwrap(Effect45.gen(function* () {
10070
- yield* Ref10.set(chat.history, historyBeforeAttempt);
10171
+ if (retryOverflow && !emitted && isContextOverflow(error) && Option16.isSome(compactionService)) {
10172
+ return Stream7.unwrap(Effect46.gen(function* () {
10173
+ yield* Ref11.set(chat.history, historyBeforeAttempt);
10071
10174
  const compactedPrompt = yield* preparePrompt(turn, activePrompt, true);
10072
10175
  return attempt(compactedPrompt, false);
10073
10176
  }));
@@ -10075,12 +10178,12 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10075
10178
  return Stream7.make({ part: Response3.makePart("error", { error }), messages });
10076
10179
  }));
10077
10180
  })));
10078
- const parts = Stream7.unwrap(applyPromptChain(chain, Prompt4.make(prompt), { agentName: agent.name, turn }).pipe(Effect45.flatMap((transformedPrompt) => preparePrompt(turn, transformedPrompt, false)), Effect45.map((preparedPrompt) => attempt(preparedPrompt, true).pipe(Stream7.flatMap(({ part, messages }) => applyPartToEvents(turn, part, messages))))));
10079
- const resilientParts = Option15.match(resilienceService, {
10181
+ 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))))));
10182
+ const resilientParts = Option16.match(resilienceService, {
10080
10183
  onNone: () => parts,
10081
- onSome: (resilience) => Stream7.unwrap(LanguageModel3.LanguageModel.pipe(Effect45.map((model) => parts.pipe(Stream7.provideService(LanguageModel3.LanguageModel, apply(model, resilience))))))
10184
+ onSome: (resilience) => Stream7.unwrap(LanguageModel4.LanguageModel.pipe(Effect46.map((model) => parts.pipe(Stream7.provideService(LanguageModel4.LanguageModel, apply(model, resilience))))))
10082
10185
  });
10083
- return overrides?.model === undefined ? resilientParts : resilientParts.pipe(Stream7.provide(overrides.model));
10186
+ return overrides?.model === undefined ? provideAgentModel(resilientParts) : resilientParts.pipe(Stream7.provide(overrides.model));
10084
10187
  };
10085
10188
  const turnCompletedEvent = (turn, transcript) => ({
10086
10189
  _tag: "TurnCompleted",
@@ -10095,21 +10198,21 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10095
10198
  transcript,
10096
10199
  ...state.usage === undefined ? {} : { usage: state.usage }
10097
10200
  });
10098
- const structuredFinalEvents = (turn, config) => Stream7.fromEffect(Effect45.gen(function* () {
10201
+ const structuredFinalEvents = (turn, config) => Stream7.fromEffect(Effect46.gen(function* () {
10099
10202
  const structuredTurn = turn + 1;
10100
10203
  const transformedPrompt = yield* applyPromptChain(chain, Prompt4.make(config.objectPrompt), {
10101
10204
  agentName: agent.name,
10102
10205
  turn: structuredTurn
10103
10206
  });
10104
- const response = yield* withModelResilience(chat.generateObject({
10207
+ const response = yield* withAgentModel(withModelResilience(chat.generateObject({
10105
10208
  prompt: transformedPrompt,
10106
10209
  schema: config.schema,
10107
10210
  objectName: config.objectName,
10108
10211
  toolChoice: "none"
10109
- })).pipe(Effect45.mapError((error) => new AgentError({ message: errorMessage(error), turn: structuredTurn, cause: error })));
10212
+ }))).pipe(Effect46.mapError((error) => new AgentError({ message: errorMessage(error), turn: structuredTurn, cause: error })));
10110
10213
  yield* captureStructuredUsage(response.content);
10111
10214
  yield* savePersisted;
10112
- const transcript = yield* Ref10.get(chat.history);
10215
+ const transcript = yield* Ref11.get(chat.history);
10113
10216
  const structuredOutput = {
10114
10217
  _tag: "StructuredOutput",
10115
10218
  turn: structuredTurn,
@@ -10119,16 +10222,16 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10119
10222
  return [structuredOutput, terminalCompletedEvent(structuredTurn, transcript)];
10120
10223
  })).pipe(Stream7.flatMap((events) => Stream7.fromIterable(events)));
10121
10224
  const promptFromSteeringMessages = (messages) => messages.reduce((prompt, message) => Prompt4.concat(prompt, message.prompt), Prompt4.empty);
10122
- const takeSteering = () => Option15.match(steeringService, {
10123
- onNone: () => Effect45.succeed([]),
10225
+ const takeSteering = () => Option16.match(steeringService, {
10226
+ onNone: () => Effect46.succeed([]),
10124
10227
  onSome: (service) => service.takeSteering()
10125
10228
  });
10126
- const takeFollowUp = () => Option15.match(steeringService, {
10127
- onNone: () => Effect45.succeed([]),
10229
+ const takeFollowUp = () => Option16.match(steeringService, {
10230
+ onNone: () => Effect46.succeed([]),
10128
10231
  onSome: (service) => service.takeFollowUp()
10129
10232
  });
10130
- const afterTurn = (turn) => Effect45.gen(function* () {
10131
- const transcript = yield* Ref10.get(chat.history);
10233
+ const afterTurn = (turn) => Effect46.gen(function* () {
10234
+ const transcript = yield* Ref11.get(chat.history);
10132
10235
  yield* syncSession(turn, transcript);
10133
10236
  const pending = state.pending;
10134
10237
  yield* rememberTurn(turn, transcript, pending.length === 0);
@@ -10183,7 +10286,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10183
10286
  }).pipe(Stream7.drain);
10184
10287
  const runTurn = (turn, prompt, overrides) => {
10185
10288
  let next;
10186
- 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(Effect45.map((result) => {
10289
+ 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) => {
10187
10290
  next = result.next;
10188
10291
  return result.events;
10189
10292
  })))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": turn } }));
@@ -10197,7 +10300,7 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10197
10300
  params: resume.call.params,
10198
10301
  providerExecuted: false
10199
10302
  });
10200
- const currentTurn = resetTurnState(0).pipe(Stream7.concat(Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((history) => toolCallEvents(0, call, history.content))))), Stream7.concat(Stream7.unwrap(afterTurn(0).pipe(Effect45.map((result) => {
10303
+ 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) => {
10201
10304
  next = result.next;
10202
10305
  return result.events;
10203
10306
  })))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": 0 } }));
@@ -10208,10 +10311,10 @@ var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen
10208
10311
  const runStream = options.resume === undefined ? runTurn(0, initialPrompt) : resumeStream(options.resume);
10209
10312
  return runStream.pipe(Stream7.catchCause((cause) => {
10210
10313
  if (Cause3.hasInterrupts(cause))
10211
- return Stream7.fromEffect(Effect45.interrupt);
10314
+ return Stream7.fromEffect(Effect46.interrupt);
10212
10315
  const error = Cause3.squash(cause);
10213
10316
  if (error instanceof AgentSuspended) {
10214
- return Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((transcript) => Stream7.concat(Stream7.fromIterable([turnCompletedEvent(state.turn, transcript)]), Stream7.failCause(cause)))));
10317
+ return Stream7.unwrap(Ref11.get(chat.history).pipe(Effect46.map((transcript) => Stream7.concat(Stream7.fromIterable([turnCompletedEvent(state.turn, transcript)]), Stream7.failCause(cause)))));
10215
10318
  }
10216
10319
  return Stream7.failCause(cause);
10217
10320
  }));
@@ -10222,29 +10325,29 @@ var streamObject = (agent, options) => streamInternal(agent, options, {
10222
10325
  objectName: options.objectName ?? "output",
10223
10326
  objectPrompt: options.objectPrompt ?? defaultObjectPrompt
10224
10327
  });
10225
- var generate = (agent, options) => Stream7.runLast(stream2(agent, options)).pipe(Effect45.flatMap(Option15.match({
10226
- onNone: () => Effect45.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 })),
10227
- onSome: (event) => event._tag === "Completed" ? Effect45.succeed({ text: event.text, turns: event.turns, transcript: event.transcript }) : Effect45.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 }))
10328
+ var generate = (agent, options) => Stream7.runLast(stream2(agent, options)).pipe(Effect46.flatMap(Option16.match({
10329
+ onNone: () => Effect46.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 })),
10330
+ 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 }))
10228
10331
  })));
10229
10332
  var generateObject = (agent, options) => Stream7.runFold(streamObject(agent, options), () => ({
10230
- value: Option15.none(),
10231
- completed: Option15.none()
10333
+ value: Option16.none(),
10334
+ completed: Option16.none()
10232
10335
  }), (acc, event) => {
10233
10336
  if (event._tag === "StructuredOutput") {
10234
- return { ...acc, value: Option15.some(event.value) };
10337
+ return { ...acc, value: Option16.some(event.value) };
10235
10338
  }
10236
10339
  if (event._tag === "Completed") {
10237
- return { ...acc, completed: Option15.some(event) };
10340
+ return { ...acc, completed: Option16.some(event) };
10238
10341
  }
10239
10342
  return acc;
10240
- }).pipe(Effect45.flatMap(({ value, completed }) => Option15.match(completed, {
10241
- onNone: () => Effect45.fail(new AgentError({ message: "Agent object run ended without a Completed event", turn: 0 })),
10242
- onSome: (event) => Option15.match(value, {
10243
- onNone: () => Effect45.fail(new AgentError({
10343
+ }).pipe(Effect46.flatMap(({ value, completed }) => Option16.match(completed, {
10344
+ onNone: () => Effect46.fail(new AgentError({ message: "Agent object run ended without a Completed event", turn: 0 })),
10345
+ onSome: (event) => Option16.match(value, {
10346
+ onNone: () => Effect46.fail(new AgentError({
10244
10347
  message: "Agent object run ended without a StructuredOutput event",
10245
10348
  turn: 0
10246
10349
  })),
10247
- onSome: (typedValue) => Effect45.succeed({
10350
+ onSome: (typedValue) => Effect46.succeed({
10248
10351
  text: event.text,
10249
10352
  turns: event.turns,
10250
10353
  transcript: event.transcript,
@@ -10252,14 +10355,14 @@ var generateObject = (agent, options) => Stream7.runFold(streamObject(agent, opt
10252
10355
  })
10253
10356
  })
10254
10357
  })));
10255
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/agent-tool.ts
10358
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/agent-tool.ts
10256
10359
  var exports_agent_tool = {};
10257
10360
  __export(exports_agent_tool, {
10258
10361
  asTool: () => asTool
10259
10362
  });
10260
- import { Cause as Cause4, Effect as Effect46, Schema as Schema48 } from "effect";
10363
+ import { Cause as Cause4, Effect as Effect47, Schema as Schema49 } from "effect";
10261
10364
  import { Tool as Tool5, Toolkit as Toolkit4 } from "effect/unstable/ai";
10262
- var defaultParameters = Schema48.Struct({ prompt: Schema48.String });
10365
+ var defaultParameters = Schema49.Struct({ prompt: Schema49.String });
10263
10366
  var errorMessage2 = (error) => {
10264
10367
  if (error instanceof AgentSuspended) {
10265
10368
  return `suspended on ${error.tool_name}: ${error.reason}`;
@@ -10278,39 +10381,36 @@ var errorMessage2 = (error) => {
10278
10381
  var causeMessage = (agentName, cause) => `sub-agent '${agentName}' could not complete: ${errorMessage2(Cause4.squash(cause))}`;
10279
10382
  var lazyHandled = (toolkit, name, handler) => ({
10280
10383
  tools: toolkit.tools,
10281
- handle: (toolName, params) => toolkit.pipe(Effect46.provide(toolkit.toLayer({
10384
+ handle: (toolName, params) => toolkit.pipe(Effect47.provide(toolkit.toLayer({
10282
10385
  [name]: handler
10283
- })), Effect46.flatMap((handled) => handled.handle(toolName, params)))
10386
+ })), Effect47.flatMap((handled) => handled.handle(toolName, params)))
10284
10387
  });
10285
10388
  var asTool = (agent, options = {}) => {
10286
10389
  const name = options.name ?? agent.name;
10287
10390
  const parameters = options.parameters ?? defaultParameters;
10288
- const success2 = options.success ?? Schema48.String;
10391
+ const success2 = options.success ?? Schema49.String;
10289
10392
  const toPrompt = options.toPrompt ?? ((params) => params.prompt);
10290
10393
  const fromResult = options.fromResult ?? ((result) => result.text);
10291
10394
  const tool2 = Tool5.make(name, {
10292
10395
  ...options.description === undefined ? {} : { description: options.description },
10293
10396
  parameters,
10294
10397
  success: success2,
10295
- failure: Schema48.String,
10398
+ failure: Schema49.String,
10296
10399
  failureMode: "return"
10297
10400
  });
10298
10401
  const toolkit = Toolkit4.make(tool2);
10299
- const handler = (params) => Effect46.gen(function* () {
10300
- const prompt = yield* Effect46.try({ try: () => toPrompt(params), catch: errorMessage2 });
10301
- const result = yield* generate(agent, { prompt }).pipe(Effect46.catchCause((cause) => {
10402
+ const handler = (params) => Effect47.gen(function* () {
10403
+ const prompt = yield* Effect47.try({ try: () => toPrompt(params), catch: errorMessage2 });
10404
+ const result = yield* generate(agent, { prompt }).pipe(Effect47.catchCause((cause) => {
10302
10405
  if (Cause4.hasInterrupts(cause))
10303
- return Effect46.interrupt;
10304
- const error = Cause4.squash(cause);
10305
- if (error instanceof AgentSuspended)
10306
- return Effect46.die(error);
10307
- return Effect46.fail(causeMessage(agent.name, cause));
10406
+ return Effect47.interrupt;
10407
+ return Effect47.fail(causeMessage(agent.name, cause));
10308
10408
  }));
10309
- return yield* Effect46.try({ try: () => fromResult(result), catch: errorMessage2 });
10409
+ return yield* Effect47.try({ try: () => fromResult(result), catch: errorMessage2 });
10310
10410
  });
10311
10411
  return lazyHandled(toolkit, name, handler);
10312
10412
  };
10313
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/guardrail.ts
10413
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/guardrail.ts
10314
10414
  var exports_guardrail = {};
10315
10415
  __export(exports_guardrail, {
10316
10416
  validateInput: () => validateInput2,
@@ -10318,7 +10418,7 @@ __export(exports_guardrail, {
10318
10418
  redactInput: () => redactInput,
10319
10419
  filterOutput: () => filterOutput
10320
10420
  });
10321
- import { Effect as Effect47, Option as Option16 } from "effect";
10421
+ import { Effect as Effect48, Option as Option17 } from "effect";
10322
10422
  import { Prompt as Prompt6, Response as Response4 } from "effect/unstable/ai";
10323
10423
  var replacement = (options) => options.replacement ?? "[redacted]";
10324
10424
  var redactText = (text3, options) => text3.replace(options.pattern, replacement(options));
@@ -10368,19 +10468,19 @@ var redactPromptText = (prompt, options) => Prompt6.fromMessages(prompt.content.
10368
10468
  }
10369
10469
  }));
10370
10470
  var validateInput2 = (check2) => ({
10371
- transformPrompt: (prompt, context) => check2(prompt, context).pipe(Effect47.flatMap(Option16.match({
10372
- onNone: () => Effect47.succeed(prompt),
10373
- onSome: (reason) => Effect47.fail(new AgentError({ message: `Input guardrail blocked: ${reason}`, turn: context.turn }))
10471
+ transformPrompt: (prompt, context) => check2(prompt, context).pipe(Effect48.flatMap(Option17.match({
10472
+ onNone: () => Effect48.succeed(prompt),
10473
+ onSome: (reason) => Effect48.fail(new AgentError({ message: `Input guardrail blocked: ${reason}`, turn: context.turn }))
10374
10474
  })))
10375
10475
  });
10376
10476
  var redactInput = (options) => ({
10377
- transformPrompt: (prompt) => Effect47.succeed(redactPromptText(prompt, options))
10477
+ transformPrompt: (prompt) => Effect48.succeed(redactPromptText(prompt, options))
10378
10478
  });
10379
10479
  var redactOutput = (options) => ({
10380
10480
  transformPart: (part) => {
10381
10481
  if (part.type !== "text-delta")
10382
- return Effect47.succeed(Option16.some(part));
10383
- return Effect47.succeed(Option16.some(Response4.makePart("text-delta", {
10482
+ return Effect48.succeed(Option17.some(part));
10483
+ return Effect48.succeed(Option17.some(Response4.makePart("text-delta", {
10384
10484
  id: part.id,
10385
10485
  delta: redactText(part.delta, options),
10386
10486
  metadata: part.metadata
@@ -10388,22 +10488,22 @@ var redactOutput = (options) => ({
10388
10488
  }
10389
10489
  });
10390
10490
  var filterOutput = (keep) => ({
10391
- transformPart: (part, context) => Effect47.succeed(part.type === "tool-call" || keep(part, context) ? Option16.some(part) : Option16.none())
10491
+ transformPart: (part, context) => Effect48.succeed(part.type === "tool-call" || keep(part, context) ? Option17.some(part) : Option17.none())
10392
10492
  });
10393
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/handoff.ts
10493
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/handoff.ts
10394
10494
  var exports_handoff = {};
10395
10495
  __export(exports_handoff, {
10396
10496
  transferTool: () => transferTool,
10397
10497
  supervisor: () => supervisor,
10398
10498
  fanOut: () => fanOut
10399
10499
  });
10400
- import { Effect as Effect48, Schema as Schema49 } from "effect";
10500
+ import { Effect as Effect49, Schema as Schema50 } from "effect";
10401
10501
  import { AiError as AiError2, Toolkit as Toolkit5 } from "effect/unstable/ai";
10402
- var defaultTransferParameters = Schema49.Struct({ prompt: Schema49.String });
10502
+ var defaultTransferParameters = Schema50.Struct({ prompt: Schema50.String });
10403
10503
  var transferName = (agentName) => `transfer_to_${agentName}`;
10404
10504
  var positiveConcurrency = (value) => {
10405
10505
  const concurrency = value ?? 4;
10406
- return Number.isInteger(concurrency) && concurrency > 0 ? Effect48.succeed(concurrency) : Effect48.fail(new AgentError({
10506
+ return Number.isInteger(concurrency) && concurrency > 0 ? Effect49.succeed(concurrency) : Effect49.fail(new AgentError({
10407
10507
  message: "Handoff.fanOut concurrency must be a positive integer",
10408
10508
  turn: 0
10409
10509
  }));
@@ -10417,7 +10517,7 @@ var mergeHandled = (toolkits) => {
10417
10517
  tools,
10418
10518
  handle: (name, params) => {
10419
10519
  const toolkit = toolkits.find((candidate) => candidate.tools[name] !== undefined);
10420
- return toolkit === undefined ? Effect48.fail(AiError2.make({
10520
+ return toolkit === undefined ? Effect49.fail(AiError2.make({
10421
10521
  module: "Handoff",
10422
10522
  method: `${String(name)}.handle`,
10423
10523
  reason: new AiError2.ToolNotFoundError({
@@ -10437,7 +10537,7 @@ var transferTool = (target, options = {}) => asTool(target, {
10437
10537
  ...options.toPrompt === undefined ? {} : { toPrompt: options.toPrompt },
10438
10538
  ...options.fromResult === undefined ? {} : { fromResult: options.fromResult }
10439
10539
  });
10440
- var fanOut = (children, options = {}) => positiveConcurrency(options.concurrency).pipe(Effect48.flatMap((concurrency) => Effect48.forEach(children, (child) => generate(child.agent, { ...child.options, prompt: child.prompt }), {
10540
+ var fanOut = (children, options = {}) => positiveConcurrency(options.concurrency).pipe(Effect49.flatMap((concurrency) => Effect49.forEach(children, (child) => generate(child.agent, { ...child.options, prompt: child.prompt }), {
10441
10541
  concurrency
10442
10542
  })));
10443
10543
  var supervisor = (options) => {
@@ -10453,96 +10553,8 @@ var supervisor = (options) => {
10453
10553
  toolkit
10454
10554
  };
10455
10555
  };
10456
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/model-registry.ts
10457
- var exports_model_registry = {};
10458
- __export(exports_model_registry, {
10459
- testLayer: () => testLayer38,
10460
- registrations: () => registrations,
10461
- registrationFromLayer: () => registrationFromLayer,
10462
- register: () => register4,
10463
- provide: () => provide,
10464
- memoryLayer: () => memoryLayer25,
10465
- layerFromRegistrationEffects: () => layerFromRegistrationEffects,
10466
- layer: () => layer31,
10467
- combine: () => combine,
10468
- Service: () => Service29,
10469
- LanguageModelNotRegistered: () => LanguageModelNotRegistered
10470
- });
10471
- 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";
10472
- import { Model } from "effect/unstable/ai";
10473
-
10474
- class LanguageModelNotRegistered extends Schema50.TaggedErrorClass()("LanguageModelNotRegistered", {
10475
- provider: Schema50.String,
10476
- model: Schema50.String,
10477
- registration_key: Schema50.optionalKey(Schema50.String)
10478
- }) {
10479
- }
10480
-
10481
- class Service29 extends Context42.Service()("@batonfx/core/ModelRegistry") {
10482
- }
10483
- var registrationVariantKey = (value) => value.registrationKey ?? null;
10484
- var selectionVariantKey = (selection) => selection.registrationKey ?? null;
10485
- var registryIdentity = (registration) => JSON.stringify([registration.provider, registration.model, registrationVariantKey(registration)]);
10486
- var matchesSelection = (selection) => (registration) => registration.provider === selection.provider && registration.model === selection.model && registrationVariantKey(registration) === selectionVariantKey(selection);
10487
- var upsertRegistration = (registry, registration) => {
10488
- const key2 = registryIdentity(registration);
10489
- const exists = Option17.isSome(Chunk2.findFirst(registry, (item) => registryIdentity(item) === key2));
10490
- if (!exists)
10491
- return Chunk2.append(registry, registration);
10492
- return Chunk2.map(registry, (item) => registryIdentity(item) === key2 ? registration : item);
10493
- };
10494
- var findRegistration = (registry, selection) => Chunk2.findFirst(registry, matchesSelection(selection)).pipe(Option17.getOrUndefined);
10495
- var registrationFromLayer = (input) => Model.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect49.map((layer31) => ({
10496
- provider: input.provider,
10497
- model: input.model,
10498
- layer: layer31,
10499
- ...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
10500
- ...input.metadata === undefined ? {} : { metadata: input.metadata }
10501
- })));
10502
- var layer31 = (initialRegistrations = [], options) => Layer43.effect(Service29, Effect49.gen(function* () {
10503
- const registry = yield* Ref11.make(initialRegistrations.reduce(upsertRegistration, Chunk2.empty()));
10504
- const semaphore = options?.maxConcurrentModelCalls === undefined ? undefined : yield* Semaphore3.make(options.maxConcurrentModelCalls);
10505
- const register4 = Effect49.fn("ModelRegistry.register")(function* (input) {
10506
- yield* Ref11.update(registry, (items) => upsertRegistration(items, input.registration));
10507
- });
10508
- const registrations = Ref11.get(registry).pipe(Effect49.map(Chunk2.toReadonlyArray));
10509
- const provide = Effect49.fn("ModelRegistry.provide")(function* (selection, effect) {
10510
- const items = yield* Ref11.get(registry);
10511
- const registration = findRegistration(items, selection);
10512
- if (registration === undefined) {
10513
- return yield* Effect49.fail(new LanguageModelNotRegistered({
10514
- provider: selection.provider,
10515
- model: selection.model,
10516
- ...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
10517
- }));
10518
- }
10519
- const provided = effect.pipe(Effect49.provide(registration.layer));
10520
- return yield* semaphore === undefined ? provided : semaphore.withPermits(1)(provided);
10521
- });
10522
- return Service29.of({
10523
- register: register4,
10524
- registrations,
10525
- provide
10526
- });
10527
- }));
10528
- var layerFromRegistrationEffects = (registrations, options) => Layer43.unwrap(Effect49.all(registrations).pipe(Effect49.map((items) => layer31(items, options))));
10529
- 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))));
10530
- var memoryLayer25 = layer31;
10531
- var testLayer38 = (implementation) => Layer43.succeed(Service29, Service29.of(implementation));
10532
- var register4 = Effect49.fn("ModelRegistry.register.call")(function* (input) {
10533
- const service = yield* Service29;
10534
- return yield* service.register(input);
10535
- });
10536
- var registrations = Effect49.fn("ModelRegistry.registrations.call")(function* () {
10537
- const service = yield* Service29;
10538
- return yield* service.registrations;
10539
- });
10540
- var provide = (selection, effect) => Effect49.gen(function* () {
10541
- const service = yield* Service29;
10542
- return yield* service.provide(selection, effect);
10543
- });
10544
10556
 
10545
- // ../../node_modules/.bun/@batonfx+core@0.3.5/node_modules/@batonfx/core/src/index.ts
10557
+ // ../../node_modules/.bun/@batonfx+core@0.3.7/node_modules/@batonfx/core/src/index.ts
10546
10558
  import {
10547
10559
  AiError as AiError3,
10548
10560
  Chat as Chat2,
@@ -15778,14 +15790,42 @@ var toolRefsFromBatonAgent = (agent) => {
15778
15790
  const tools = agent.toolkit.tools;
15779
15791
  return Object.values(tools).map((tool2) => ({ name: tool2.name }));
15780
15792
  };
15781
- var registerAgentPayload = (input) => {
15793
+ var modelSelectionFromBatonAgent = (selection) => ({
15794
+ provider: selection.provider,
15795
+ model: selection.model,
15796
+ ...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
15797
+ });
15798
+ var decodeBatonAgentName = (name) => Schema75.decodeUnknownEffect(exports_shared_schema.NonEmptyString)(name).pipe(Effect79.mapError(() => new ClientError({ message: "Baton agent name must not be blank" })));
15799
+ var decodeBatonAgentMetadata = (metadata11) => metadata11 === undefined ? Effect79.succeed(undefined) : Schema75.decodeUnknownEffect(exports_shared_schema.Metadata)(metadata11).pipe(Effect79.mapError(() => new ClientError({ message: "Baton agent metadata must be JSON metadata" })));
15800
+ var decodeBatonMemorySubject = (subject) => Schema75.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect79.mapError(() => new ClientError({ message: "Baton agent memory subject must be a MemorySubjectId" })));
15801
+ var metadataFromBatonAgent = Effect79.fn("Client.metadataFromBatonAgent")(function* (input) {
15802
+ const agentMetadata = yield* decodeBatonAgentMetadata(input.agent.metadata);
15803
+ const memorySubject = input.agent.memory === undefined ? undefined : yield* decodeBatonMemorySubject(input.agent.memory.subject);
15804
+ const metadata11 = {
15805
+ ...agentMetadata,
15806
+ ...memorySubject === undefined ? {} : { memory_subject_id: memorySubject },
15807
+ ...input.metadata
15808
+ };
15809
+ return Object.keys(metadata11).length === 0 ? undefined : metadata11;
15810
+ });
15811
+ var modelSelectionFromRegisterInput = (input) => {
15812
+ if (input.model !== undefined)
15813
+ return Effect79.succeed(input.model);
15814
+ if (input.agent.model !== undefined)
15815
+ return Effect79.succeed(modelSelectionFromBatonAgent(input.agent.model));
15816
+ return Effect79.fail(new ClientError({ message: "Client.registerAgent requires model or agent.model" }));
15817
+ };
15818
+ var registerAgentPayload = Effect79.fn("Client.registerAgentPayload")(function* (input) {
15782
15819
  if (!isRegisterBatonAgentInput(input))
15783
15820
  return exports_agent_schema.define(input);
15821
+ const name = yield* decodeBatonAgentName(input.agent.name);
15822
+ const model = yield* modelSelectionFromRegisterInput(input);
15823
+ const metadata11 = yield* metadataFromBatonAgent(input);
15784
15824
  return exports_agent_schema.define({
15785
15825
  id: input.id,
15786
- name: Schema75.decodeUnknownSync(exports_shared_schema.NonEmptyString)(input.agent.name),
15826
+ name,
15787
15827
  ...input.agent.instructions === undefined ? {} : { instructions: input.agent.instructions },
15788
- model: input.model,
15828
+ model,
15789
15829
  tools: toolRefsFromBatonAgent(input.agent),
15790
15830
  permissions: input.permissions ?? [],
15791
15831
  ...input.skill_definition_ids === undefined ? {} : { skill_definition_ids: input.skill_definition_ids },
@@ -15796,9 +15836,9 @@ var registerAgentPayload = (input) => {
15796
15836
  ...input.child_run_presets === undefined ? {} : { child_run_presets: input.child_run_presets },
15797
15837
  ...input.handoff_targets === undefined ? {} : { handoff_targets: input.handoff_targets },
15798
15838
  ...input.output_schema_ref === undefined ? {} : { output_schema_ref: input.output_schema_ref },
15799
- ...input.metadata === undefined ? {} : { metadata: input.metadata }
15839
+ ...metadata11 === undefined ? {} : { metadata: metadata11 }
15800
15840
  });
15801
- };
15841
+ });
15802
15842
  var agentDefinitionNotFound = (id2) => new ClientError({ message: `Agent not found: ${id2}` });
15803
15843
  var wakeMetadata = (input) => ({
15804
15844
  ...input.metadata,
@@ -15936,7 +15976,7 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
15936
15976
  const skillRegistry = yield* exports_skill_registry_service.Service;
15937
15977
  return Service50.of({
15938
15978
  registerAgent: Effect79.fn("Client.runtime.registerAgent")(function* (input) {
15939
- const payload = registerAgentPayload(input);
15979
+ const payload = yield* registerAgentPayload(input);
15940
15980
  const registered = yield* agentRegistry.register(payload).pipe(Effect79.mapError(toClientError));
15941
15981
  if (input.address !== undefined) {
15942
15982
  yield* addressBook.register(input.address, { kind: "local-agent", route_key: payload.id }).pipe(Effect79.mapError(toClientError));
@@ -16763,7 +16803,7 @@ __export(exports_language_model_registration, {
16763
16803
  anthropic: () => anthropic
16764
16804
  });
16765
16805
 
16766
- // ../../node_modules/.bun/@batonfx+providers@0.3.5/node_modules/@batonfx/providers/src/anthropic.ts
16806
+ // ../../node_modules/.bun/@batonfx+providers@0.3.7/node_modules/@batonfx/providers/src/anthropic.ts
16767
16807
  import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
16768
16808
  import { Layer as Layer72 } from "effect";
16769
16809
  import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
@@ -16779,13 +16819,13 @@ var anthropic = (input) => exports_model_registry.registrationFromLayer({
16779
16819
  });
16780
16820
  var anthropicClientLayerConfig = AnthropicClient.layerConfig;
16781
16821
  var withAnthropic = (options) => exports_model_registry.layerFromRegistrationEffects([anthropic(options)]).pipe(Layer72.provide(AnthropicClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })), Layer72.provide(FetchHttpClient2.layer));
16782
- // ../../node_modules/.bun/@batonfx+providers@0.3.5/node_modules/@batonfx/providers/src/deterministic.ts
16822
+ // ../../node_modules/.bun/@batonfx+providers@0.3.7/node_modules/@batonfx/providers/src/deterministic.ts
16783
16823
  import { OpenAiClient as OpenAiClient3 } from "@effect/ai-openai";
16784
16824
  import { Effect as Effect81, Layer as Layer74, Option as Option29, Stream as Stream12 } from "effect";
16785
16825
  import { LanguageModel as LanguageModel8, Response as Response7 } from "effect/unstable/ai";
16786
16826
  import { FetchHttpClient as FetchHttpClient4 } from "effect/unstable/http";
16787
16827
 
16788
- // ../../node_modules/.bun/@batonfx+providers@0.3.5/node_modules/@batonfx/providers/src/openai.ts
16828
+ // ../../node_modules/.bun/@batonfx+providers@0.3.7/node_modules/@batonfx/providers/src/openai.ts
16789
16829
  import { OpenAiClient as OpenAiClient2, OpenAiLanguageModel } from "@effect/ai-openai";
16790
16830
  import { Layer as Layer73 } from "effect";
16791
16831
  import { FetchHttpClient as FetchHttpClient3 } from "effect/unstable/http";
@@ -16802,7 +16842,7 @@ var openAi = (input) => exports_model_registry.registrationFromLayer({
16802
16842
  var openAiClientLayerConfig2 = OpenAiClient2.layerConfig;
16803
16843
  var withOpenAi = (options) => exports_model_registry.layerFromRegistrationEffects([openAi(options)]).pipe(Layer73.provide(OpenAiClient2.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })), Layer73.provide(FetchHttpClient3.layer));
16804
16844
 
16805
- // ../../node_modules/.bun/@batonfx+providers@0.3.5/node_modules/@batonfx/providers/src/deterministic.ts
16845
+ // ../../node_modules/.bun/@batonfx+providers@0.3.7/node_modules/@batonfx/providers/src/deterministic.ts
16806
16846
  var deterministicModelLayer = Layer74.effect(LanguageModel8.LanguageModel, LanguageModel8.make({
16807
16847
  generateText: () => Effect81.succeed([{ type: "text", text: "deterministic response" }]),
16808
16848
  streamText: () => Stream12.make(Response7.makePart("text-delta", { id: "text", delta: "deterministic response" }))
@@ -16826,7 +16866,7 @@ var withOpenAiOrDeterministic = (options) => Layer74.unwrap(Effect81.gen(functio
16826
16866
  ...Option29.isSome(openAiRegistration) ? [openAiRegistration.value] : []
16827
16867
  ]);
16828
16868
  }));
16829
- // ../../node_modules/.bun/@batonfx+providers@0.3.5/node_modules/@batonfx/providers/src/openai-compat.ts
16869
+ // ../../node_modules/.bun/@batonfx+providers@0.3.7/node_modules/@batonfx/providers/src/openai-compat.ts
16830
16870
  import { OpenAiClient as OpenAiClient4, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai-compat";
16831
16871
  import { Config as Config8, Layer as Layer75 } from "effect";
16832
16872
  import { FetchHttpClient as FetchHttpClient5 } from "effect/unstable/http";
@@ -16847,7 +16887,7 @@ var clientLayerConfig = (options) => OpenAiClient4.layerConfig({
16847
16887
  ...options.baseUrl === undefined ? {} : { apiUrl: Config8.succeed(options.baseUrl) }
16848
16888
  });
16849
16889
  var withOpenAiCompatible = (options) => exports_model_registry.layerFromRegistrationEffects([openAiCompatible(options)]).pipe(Layer75.provide(clientLayerConfig(options)), Layer75.provide(FetchHttpClient5.layer));
16850
- // ../../node_modules/.bun/@batonfx+providers@0.3.5/node_modules/@batonfx/providers/src/openrouter.ts
16890
+ // ../../node_modules/.bun/@batonfx+providers@0.3.7/node_modules/@batonfx/providers/src/openrouter.ts
16851
16891
  import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
16852
16892
  import { Layer as Layer76 } from "effect";
16853
16893
  import { FetchHttpClient as FetchHttpClient6 } from "effect/unstable/http";