@relayfx/sdk 0.2.6 → 0.2.7

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.
@@ -11457,7 +11457,7 @@ var resolveLocalAgent = Effect37.fn("AddressResolution.resolveLocalAgent.call")(
11457
11457
  return yield* service.resolveLocalAgent(addressId);
11458
11458
  });
11459
11459
 
11460
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/agent-event.ts
11460
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/agent-event.js
11461
11461
  var exports_agent_event = {};
11462
11462
  __export(exports_agent_event, {
11463
11463
  addUsage: () => addUsage,
@@ -11467,7 +11467,7 @@ __export(exports_agent_event, {
11467
11467
  AgentError: () => AgentError
11468
11468
  });
11469
11469
  import { Schema as Schema52 } from "effect";
11470
- import { Response } from "effect/unstable/ai";
11470
+ import { Prompt, Response, Tool as Tool2 } from "effect/unstable/ai";
11471
11471
  var addUsageField = (left, right) => left === undefined && right === undefined ? undefined : (left ?? 0) + (right ?? 0);
11472
11472
  var addUsage = (left, right) => new Response.Usage({
11473
11473
  inputTokens: {
@@ -11514,40 +11514,184 @@ class AgentSuspended extends Schema52.TaggedErrorClass()("@batonfx/core/AgentSus
11514
11514
  }) {
11515
11515
  }
11516
11516
 
11517
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/approvals.ts
11517
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/tool-context.js
11518
+ var exports_tool_context = {};
11519
+ __export(exports_tool_context, {
11520
+ testLayer: () => testLayer32,
11521
+ layerDefault: () => layerDefault,
11522
+ ToolContext: () => ToolContext
11523
+ });
11524
+ import { Context as Context35, Effect as Effect38, Layer as Layer35 } from "effect";
11525
+
11526
+ class ToolContext extends Context35.Service()("@batonfx/core/ToolContext") {
11527
+ }
11528
+ var layerDefault = Layer35.sync(ToolContext, () => ToolContext.of({
11529
+ signal: new AbortController().signal,
11530
+ emit: () => Effect38.void,
11531
+ sessionId: "local"
11532
+ }));
11533
+ var testLayer32 = (implementation) => Layer35.succeed(ToolContext, ToolContext.of(implementation));
11534
+
11535
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/tool-executor.js
11536
+ var exports_tool_executor = {};
11537
+ __export(exports_tool_executor, {
11538
+ testLayer: () => testLayer33,
11539
+ sandbox: () => sandbox,
11540
+ router: () => router,
11541
+ routeToolkit: () => routeToolkit,
11542
+ route: () => route,
11543
+ remote: () => remote,
11544
+ mcp: () => mcp,
11545
+ fromToolkit: () => fromToolkit,
11546
+ executeToolkit: () => executeToolkit,
11547
+ client: () => client,
11548
+ ToolExecutor: () => ToolExecutor
11549
+ });
11550
+ import { Cause, Context as Context36, Effect as Effect39, Layer as Layer36, Option as Option10, Schedule as Schedule3, Schema as Schema53, Sink as Sink2, Stream as Stream7 } from "effect";
11551
+ import { Response as Response2, Tool as Tool3, Toolkit as Toolkit2 } from "effect/unstable/ai";
11552
+ class ToolExecutor extends Context36.Service()("@batonfx/core/ToolExecutor") {
11553
+ }
11554
+ var failureMessage = (cause) => {
11555
+ const error5 = Cause.squash(cause);
11556
+ return error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5);
11557
+ };
11558
+ var failureOutcome = (message) => ({ _tag: "Failure", message });
11559
+ var resultMessage = (result) => {
11560
+ if (typeof result === "string")
11561
+ return result;
11562
+ if (result instanceof Error)
11563
+ return `${result.name}: ${result.message}`;
11564
+ try {
11565
+ const message = JSON.stringify(result);
11566
+ return message === undefined ? String(result) : message;
11567
+ } catch {
11568
+ return String(result);
11569
+ }
11570
+ };
11571
+ var schemaMessage = (error5) => error5 instanceof Error ? error5.message : typeof error5 === "string" ? error5 : resultMessage(error5);
11572
+ var decodeSuccess = (tool2, result) => {
11573
+ const successSchema = tool2.successSchema;
11574
+ if (!Schema53.isSchema(successSchema)) {
11575
+ return Effect39.succeed({ _tag: "Success", result, encodedResult: result });
11576
+ }
11577
+ return Schema53.decodeUnknownEffect(successSchema)(result).pipe(Effect39.flatMap((decoded) => Schema53.encodeUnknownEffect(successSchema)(decoded).pipe(Effect39.map((encoded) => ({ _tag: "Success", result: decoded, encodedResult: encoded })))), Effect39.catchCause((cause) => Effect39.succeed(failureOutcome(`invalid client result: ${schemaMessage(Cause.squash(cause))}`))));
11578
+ };
11579
+ var placementOutcome = (placement, tool2, response) => {
11580
+ switch (response._tag) {
11581
+ case "Failure":
11582
+ return Effect39.succeed(failureOutcome(response.message));
11583
+ case "Suspend":
11584
+ return Effect39.succeed({ _tag: "Suspend", token: response.token });
11585
+ case "Success":
11586
+ return decodeSuccess(tool2, response.result).pipe(Effect39.map((outcome) => outcome._tag === "Failure" ? failureOutcome(outcome.message.replace("invalid client result", `invalid ${placement} result`)) : outcome));
11587
+ }
11588
+ };
11589
+ var executeWithToolkit = (toolkit, request) => {
11590
+ if (toolkit.tools[request.call.name] === undefined) {
11591
+ return Effect39.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
11592
+ }
11593
+ return toolkit.handle(request.call.name, request.call.params).pipe(Effect39.flatMap((results) => results.pipe(Stream7.filter((item) => item.preliminary === false), Stream7.run(Sink2.last()))), Effect39.map(Option10.match({
11594
+ onNone: () => failureOutcome("Tool handler did not produce a final result"),
11595
+ onSome: (result) => result.isFailure ? failureOutcome(resultMessage(result.result)) : {
11596
+ _tag: "Success",
11597
+ result: result.result,
11598
+ encodedResult: result.encodedResult
11599
+ }
11600
+ })), Effect39.catchCause((cause) => {
11601
+ if (Cause.hasInterrupts(cause))
11602
+ return Effect39.interrupt;
11603
+ const error5 = Cause.squash(cause);
11604
+ if (error5 instanceof AgentSuspended) {
11605
+ return Effect39.succeed({ _tag: "Suspend", token: error5.token });
11606
+ }
11607
+ return Effect39.succeed(failureOutcome(failureMessage(cause)));
11608
+ }));
11609
+ };
11610
+ function executeToolkit(toolkit, request) {
11611
+ return ("handle" in toolkit ? Effect39.succeed(toolkit) : toolkit).pipe(Effect39.flatMap((handled) => executeWithToolkit(handled, request)));
11612
+ }
11613
+ function fromToolkit(toolkit) {
11614
+ return Layer36.effect(ToolExecutor, ("handle" in toolkit ? Effect39.succeed(toolkit) : toolkit).pipe(Effect39.map((handled) => ToolExecutor.of({
11615
+ execute: (request) => executeWithToolkit(handled, request)
11616
+ }))));
11617
+ }
11618
+ var route = (options) => {
11619
+ const routedTools = options.tools ?? [];
11620
+ return {
11621
+ tools: routedTools,
11622
+ matches: (request) => routedTools.includes(request.call.name) || options.matches?.(request) === true,
11623
+ execute: options.execute
11624
+ };
11625
+ };
11626
+ var placementRoute = (placement, options) => {
11627
+ const routedTools = options.tools ?? Object.keys(options.toolkit.tools);
11628
+ return route({
11629
+ tools: routedTools,
11630
+ execute: (request) => {
11631
+ const tool2 = options.toolkit.tools[request.call.name];
11632
+ if (tool2 === undefined)
11633
+ return Effect39.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
11634
+ const effect = options.execute({ ...request, placement, tool: tool2 });
11635
+ const scheduled = "schedule" in options && options.schedule !== undefined ? Effect39.retry(effect, options.schedule) : effect;
11636
+ return scheduled.pipe(Effect39.flatMap((response) => placementOutcome(placement, tool2, response)), Effect39.catchCause((cause) => Cause.hasInterrupts(cause) ? Effect39.interrupt : Effect39.succeed(failureOutcome(`${placement} tool infrastructure failed: ${failureMessage(cause)}`))));
11637
+ }
11638
+ });
11639
+ };
11640
+ var client = (options) => placementRoute("client", options);
11641
+ var remote = (options) => placementRoute("remote", options);
11642
+ var mcp = (options) => placementRoute("mcp", options);
11643
+ var sandbox = (options) => placementRoute("sandbox", options);
11644
+ function routeToolkit(toolkit) {
11645
+ const makeRoute = (handled) => route({
11646
+ tools: Object.keys(handled.tools),
11647
+ execute: (request) => executeWithToolkit(handled, request)
11648
+ });
11649
+ return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(Effect39.map(makeRoute));
11650
+ }
11651
+ var routeInputEffect = (input) => Effect39.isEffect(input) ? input : Effect39.succeed(input);
11652
+ function router(routes) {
11653
+ return Layer36.effect(ToolExecutor, Effect39.all(Array.from(routes, routeInputEffect)).pipe(Effect39.map((resolved) => ToolExecutor.of({
11654
+ execute: (request) => {
11655
+ const matched = resolved.find((candidate) => candidate.matches(request));
11656
+ return matched === undefined ? Effect39.succeed(failureOutcome(`Tool ${request.call.name} is not registered`)) : matched.execute(request);
11657
+ }
11658
+ }))));
11659
+ }
11660
+ var testLayer33 = (implementation) => Layer36.succeed(ToolExecutor, ToolExecutor.of(implementation));
11661
+
11662
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/approvals.js
11518
11663
  var exports_approvals = {};
11519
11664
  __export(exports_approvals, {
11520
- testLayer: () => testLayer32,
11665
+ testLayer: () => testLayer34,
11521
11666
  denyAll: () => denyAll,
11522
11667
  autoApprove: () => autoApprove,
11523
11668
  Approvals: () => Approvals
11524
11669
  });
11525
- import { Context as Context35, Effect as Effect38, Layer as Layer35 } from "effect";
11526
-
11527
- class Approvals extends Context35.Service()("@batonfx/core/Approvals") {
11670
+ import { Context as Context37, Effect as Effect40, Layer as Layer37 } from "effect";
11671
+ class Approvals extends Context37.Service()("@batonfx/core/Approvals") {
11528
11672
  }
11529
- var autoApprove = Layer35.succeed(Approvals, Approvals.of({ check: () => Effect38.succeed({ _tag: "Approved" }) }));
11530
- var denyAll = Layer35.succeed(Approvals, Approvals.of({ check: () => Effect38.succeed({ _tag: "Denied" }) }));
11531
- var testLayer32 = (implementation) => Layer35.succeed(Approvals, Approvals.of(implementation));
11673
+ var autoApprove = Layer37.succeed(Approvals, Approvals.of({ check: () => Effect40.succeed({ _tag: "Approved" }) }));
11674
+ var denyAll = Layer37.succeed(Approvals, Approvals.of({ check: () => Effect40.succeed({ _tag: "Denied" }) }));
11675
+ var testLayer34 = (implementation) => Layer37.succeed(Approvals, Approvals.of(implementation));
11532
11676
 
11533
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/session.ts
11677
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/session.js
11534
11678
  var exports_session = {};
11535
11679
  __export(exports_session, {
11536
- testLayer: () => testLayer33,
11680
+ testLayer: () => testLayer35,
11537
11681
  memoryLayer: () => memoryLayer32,
11538
11682
  buildContext: () => buildContext,
11539
11683
  SessionStoreError: () => SessionStoreError,
11540
11684
  SessionStore: () => SessionStore
11541
11685
  });
11542
- import { Context as Context36, Effect as Effect39, HashMap as HashMap3, Layer as Layer36, Option as Option10, Ref as Ref10, Schema as Schema53 } from "effect";
11686
+ import { Context as Context38, Effect as Effect41, HashMap as HashMap3, Layer as Layer38, Option as Option11, Ref as Ref10, Schema as Schema54 } from "effect";
11543
11687
  import { Prompt as Prompt2 } from "effect/unstable/ai";
11544
11688
 
11545
- class SessionStoreError extends Schema53.TaggedErrorClass()("@batonfx/core/SessionStoreError", {
11546
- message: Schema53.String
11689
+ class SessionStoreError extends Schema54.TaggedErrorClass()("@batonfx/core/SessionStoreError", {
11690
+ message: Schema54.String
11547
11691
  }) {
11548
11692
  }
11549
11693
 
11550
- class SessionStore extends Context36.Service()("@batonfx/core/SessionStore") {
11694
+ class SessionStore extends Context38.Service()("@batonfx/core/SessionStore") {
11551
11695
  }
11552
11696
  var initialState = {
11553
11697
  entries: HashMap3.empty(),
@@ -11560,7 +11704,7 @@ var failure2 = (message) => ({
11560
11704
  _tag: "Failure",
11561
11705
  error: new SessionStoreError({ message })
11562
11706
  });
11563
- var effectFromResult = (result) => result._tag === "Failure" ? Effect39.fail(result.error) : Effect39.succeed(result.value);
11707
+ var effectFromResult = (result) => result._tag === "Failure" ? Effect41.fail(result.error) : Effect41.succeed(result.value);
11564
11708
  var entryFromInput = (input, id2, parentId) => {
11565
11709
  const base2 = {
11566
11710
  id: id2,
@@ -11595,7 +11739,7 @@ var pathFromState = (state, leaf2) => {
11595
11739
  if (entries.length > state.order.length)
11596
11740
  return failure2(`Session path for leaf ${leaf2} contains a cycle`);
11597
11741
  const entry = HashMap3.get(state.entries, cursor);
11598
- if (Option10.isNone(entry))
11742
+ if (Option11.isNone(entry))
11599
11743
  return failure2(`Session entry ${cursor} does not exist`);
11600
11744
  const value = entry.value;
11601
11745
  entries.push(value);
@@ -11633,7 +11777,7 @@ var appendState = (state, input) => {
11633
11777
  ];
11634
11778
  };
11635
11779
  var setLeafState = (state, id2) => {
11636
- if (id2 !== null && Option10.isNone(HashMap3.get(state.entries, id2)))
11780
+ if (id2 !== null && Option11.isNone(HashMap3.get(state.entries, id2)))
11637
11781
  return [failure2(`Session entry ${id2} does not exist`), state];
11638
11782
  return [success(undefined), { ...state, leaf: id2 }];
11639
11783
  };
@@ -11695,41 +11839,40 @@ var projectedMessages = (path2) => {
11695
11839
  return messages;
11696
11840
  };
11697
11841
  var buildContext = (path2) => Prompt2.fromMessages(projectedMessages(path2));
11698
- var memoryLayer32 = Layer36.effect(SessionStore, Ref10.make(initialState).pipe(Effect39.map((state) => SessionStore.of({
11699
- append: (entry) => Ref10.modify(state, (current2) => appendState(current2, entry)).pipe(Effect39.flatMap(effectFromResult)),
11700
- path: (leaf2) => Ref10.get(state).pipe(Effect39.flatMap((current2) => leaf2 === undefined && current2.leaf === null ? Effect39.succeed([]) : effectFromResult(pathFromState(current2, leaf2 ?? current2.leaf ?? "")))),
11701
- setLeaf: (id2) => Ref10.modify(state, (current2) => setLeafState(current2, id2)).pipe(Effect39.flatMap(effectFromResult)),
11702
- leaf: Ref10.get(state).pipe(Effect39.map((current2) => current2.leaf))
11842
+ var memoryLayer32 = Layer38.effect(SessionStore, Ref10.make(initialState).pipe(Effect41.map((state) => SessionStore.of({
11843
+ append: (entry) => Ref10.modify(state, (current2) => appendState(current2, entry)).pipe(Effect41.flatMap(effectFromResult)),
11844
+ path: (leaf2) => Ref10.get(state).pipe(Effect41.flatMap((current2) => leaf2 === undefined && current2.leaf === null ? Effect41.succeed([]) : effectFromResult(pathFromState(current2, leaf2 ?? current2.leaf ?? "")))),
11845
+ setLeaf: (id2) => Ref10.modify(state, (current2) => setLeafState(current2, id2)).pipe(Effect41.flatMap(effectFromResult)),
11846
+ leaf: Ref10.get(state).pipe(Effect41.map((current2) => current2.leaf))
11703
11847
  }))));
11704
- var testLayer33 = (implementation) => Layer36.succeed(SessionStore, SessionStore.of(implementation));
11848
+ var testLayer35 = (implementation) => Layer38.succeed(SessionStore, SessionStore.of(implementation));
11705
11849
 
11706
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/tool-output.ts
11850
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/tool-output.js
11707
11851
  var exports_tool_output = {};
11708
11852
  __export(exports_tool_output, {
11709
- testLayer: () => testLayer34,
11853
+ testLayer: () => testLayer36,
11710
11854
  layerNoop: () => layerNoop,
11711
11855
  layerMemory: () => layerMemory,
11712
11856
  bound: () => bound,
11713
11857
  ToolOutputStore: () => ToolOutputStore,
11714
11858
  ToolOutputError: () => ToolOutputError
11715
11859
  });
11716
- import { Context as Context37, Effect as Effect40, HashMap as HashMap4, Layer as Layer37, Option as Option11, Ref as Ref11, Schema as Schema54 } from "effect";
11717
-
11718
- class ToolOutputStore extends Context37.Service()("@batonfx/core/ToolOutputStore") {
11860
+ import { Context as Context39, Effect as Effect42, HashMap as HashMap4, Layer as Layer39, Option as Option12, Ref as Ref11, Schema as Schema55 } from "effect";
11861
+ class ToolOutputStore extends Context39.Service()("@batonfx/core/ToolOutputStore") {
11719
11862
  }
11720
11863
 
11721
- class ToolOutputError extends Schema54.TaggedErrorClass()("@batonfx/core/ToolOutputError", {
11722
- message: Schema54.String
11864
+ class ToolOutputError extends Schema55.TaggedErrorClass()("@batonfx/core/ToolOutputError", {
11865
+ message: Schema55.String
11723
11866
  }) {
11724
11867
  }
11725
- var layerNoop = Layer37.succeed(ToolOutputStore, ToolOutputStore.of({ put: () => Effect40.succeed(Option11.none()) }));
11726
- var layerMemory = Layer37.effect(ToolOutputStore, Ref11.make({ next: 0, records: HashMap4.empty() }).pipe(Effect40.map((state) => ToolOutputStore.of({
11868
+ var layerNoop = Layer39.succeed(ToolOutputStore, ToolOutputStore.of({ put: () => Effect42.succeed(Option12.none()) }));
11869
+ var layerMemory = Layer39.effect(ToolOutputStore, Ref11.make({ next: 0, records: HashMap4.empty() }).pipe(Effect42.map((state) => ToolOutputStore.of({
11727
11870
  put: (toolCallId, content) => Ref11.modify(state, ({ next, records }) => {
11728
11871
  const id2 = `mem:tool-output-${next + 1}`;
11729
- return [Option11.some(id2), { next: next + 1, records: HashMap4.set(records, id2, { toolCallId, content }) }];
11872
+ return [Option12.some(id2), { next: next + 1, records: HashMap4.set(records, id2, { toolCallId, content }) }];
11730
11873
  })
11731
11874
  }))));
11732
- var testLayer34 = (implementation) => Layer37.succeed(ToolOutputStore, ToolOutputStore.of(implementation));
11875
+ var testLayer36 = (implementation) => Layer39.succeed(ToolOutputStore, ToolOutputStore.of(implementation));
11733
11876
  var encoder2 = new TextEncoder;
11734
11877
  var decoder = new TextDecoder;
11735
11878
  var serialized = (value) => {
@@ -11737,19 +11880,19 @@ var serialized = (value) => {
11737
11880
  return json === undefined ? String(value) : json;
11738
11881
  };
11739
11882
  var preview = (value, maxBytes) => decoder.decode(encoder2.encode(value).slice(0, maxBytes));
11740
- var bound = (result, options) => Effect40.gen(function* () {
11883
+ var bound = (result, options) => Effect42.gen(function* () {
11741
11884
  const encoded = serialized(result.encodedResult);
11742
11885
  const bytes = encoder2.encode(encoded).byteLength;
11743
11886
  if (bytes <= options.maxBytes)
11744
11887
  return result;
11745
- const maybeStore = yield* Effect40.serviceOption(ToolOutputStore);
11746
- if (Option11.isNone(maybeStore))
11888
+ const maybeStore = yield* Effect42.serviceOption(ToolOutputStore);
11889
+ if (Option12.isNone(maybeStore))
11747
11890
  return result;
11748
11891
  const path2 = yield* maybeStore.value.put(options.toolCallId, {
11749
11892
  result: result.result,
11750
11893
  encodedResult: result.encodedResult
11751
11894
  });
11752
- if (Option11.isNone(path2))
11895
+ if (Option12.isNone(path2))
11753
11896
  return result;
11754
11897
  const output = {
11755
11898
  inline: {
@@ -11763,12 +11906,12 @@ var bound = (result, options) => Effect40.gen(function* () {
11763
11906
  return { _tag: "Success", result: output, encodedResult: output };
11764
11907
  });
11765
11908
 
11766
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/compaction.ts
11909
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/compaction.js
11767
11910
  var exports_compaction = {};
11768
11911
  __export(exports_compaction, {
11769
11912
  truncate: () => truncate,
11770
11913
  toolOutputBound: () => toolOutputBound,
11771
- testLayer: () => testLayer35,
11914
+ testLayer: () => testLayer37,
11772
11915
  structuredSummary: () => structuredSummary,
11773
11916
  strategy: () => strategy,
11774
11917
  make: () => make2,
@@ -11783,8 +11926,8 @@ __export(exports_compaction, {
11783
11926
  Compaction: () => Compaction,
11784
11927
  AgentSummary: () => AgentSummary
11785
11928
  });
11786
- import { Context as Context38, Effect as Effect41, Layer as Layer38, Option as Option12, Schema as Schema55 } from "effect";
11787
- import { LanguageModel, Prompt as Prompt3, Tokenizer, Toolkit as Toolkit2 } from "effect/unstable/ai";
11929
+ import { Context as Context40, Effect as Effect43, Layer as Layer40, Option as Option13, Schema as Schema56 } from "effect";
11930
+ import { LanguageModel, Prompt as Prompt3, Tokenizer, Toolkit as Toolkit3 } from "effect/unstable/ai";
11788
11931
  var DEFAULT_RESERVE_TOKENS = 16384;
11789
11932
  var DEFAULT_KEEP_RECENT_TOKENS = 20000;
11790
11933
  var SUMMARY_TEMPLATE = `Summarize the conversation so another agent can continue seamlessly.
@@ -11802,21 +11945,21 @@ Use Markdown with these sections:
11802
11945
  ## Critical Context
11803
11946
 
11804
11947
  Do not mention that context was compacted.`;
11805
- var AgentSummary = Schema55.Struct({
11806
- goal: Schema55.String,
11807
- facts: Schema55.Array(Schema55.String),
11808
- decisions: Schema55.Array(Schema55.String),
11809
- openQuestions: Schema55.Array(Schema55.String),
11810
- toolFindings: Schema55.Array(Schema55.String)
11948
+ var AgentSummary = Schema56.Struct({
11949
+ goal: Schema56.String,
11950
+ facts: Schema56.Array(Schema56.String),
11951
+ decisions: Schema56.Array(Schema56.String),
11952
+ openQuestions: Schema56.Array(Schema56.String),
11953
+ toolFindings: Schema56.Array(Schema56.String)
11811
11954
  });
11812
11955
 
11813
- class CompactionError extends Schema55.TaggedErrorClass()("@batonfx/core/CompactionError", {
11814
- message: Schema55.String,
11815
- cause: Schema55.optionalKey(Schema55.Defect())
11956
+ class CompactionError extends Schema56.TaggedErrorClass()("@batonfx/core/CompactionError", {
11957
+ message: Schema56.String,
11958
+ cause: Schema56.optionalKey(Schema56.Defect())
11816
11959
  }) {
11817
11960
  }
11818
11961
 
11819
- class Compaction extends Context38.Service()("@batonfx/core/Compaction") {
11962
+ class Compaction extends Context40.Service()("@batonfx/core/Compaction") {
11820
11963
  }
11821
11964
  var serialized2 = (value) => {
11822
11965
  const json = JSON.stringify(value);
@@ -11852,11 +11995,11 @@ var isPromptToolResult = (part) => part.type === "tool-result";
11852
11995
  var messageHasToolCall = (message) => typeof message.content !== "string" && message.content.some((part) => part.type === "tool-call");
11853
11996
  var isToolMessage = (entry) => entry?._tag === "Message" && entry.message.role === "tool";
11854
11997
  var isAssistantToolCallEntry = (entry) => entry?._tag === "Message" && entry.message.role === "assistant" && messageHasToolCall(entry.message);
11855
- var compactToolPart = (part, maxBytes) => Effect41.gen(function* () {
11998
+ var compactToolPart = (part, maxBytes) => Effect43.gen(function* () {
11856
11999
  if (part.isFailure)
11857
12000
  return [part, false];
11858
12001
  const success2 = { _tag: "Success", result: part.result, encodedResult: part.result };
11859
- const bounded = yield* bound(success2, { toolCallId: part.id, maxBytes }).pipe(Effect41.mapError((error5) => new CompactionError({ message: error5.message, cause: error5 })));
12002
+ const bounded = yield* bound(success2, { toolCallId: part.id, maxBytes }).pipe(Effect43.mapError((error5) => new CompactionError({ message: error5.message, cause: error5 })));
11860
12003
  if (bounded === success2)
11861
12004
  return [part, false];
11862
12005
  return [
@@ -11869,7 +12012,7 @@ var compactToolPart = (part, maxBytes) => Effect41.gen(function* () {
11869
12012
  true
11870
12013
  ];
11871
12014
  });
11872
- var microcompactPrompt = (prompt, maxBytes) => Effect41.gen(function* () {
12015
+ var microcompactPrompt = (prompt, maxBytes) => Effect43.gen(function* () {
11873
12016
  let changed = false;
11874
12017
  const messages = [];
11875
12018
  for (const message of prompt.content) {
@@ -11931,20 +12074,20 @@ var defaultStrategy = (options = {}) => ({
11931
12074
  cut: (entries, keepRecentTokens) => {
11932
12075
  const index = safeCutIndex(entries, keepRecentTokens);
11933
12076
  if (index <= 0 || index >= entries.length)
11934
- return Option12.none();
12077
+ return Option13.none();
11935
12078
  const recent = entries.slice(index);
11936
12079
  const first = recent[0];
11937
- return first === undefined ? Option12.none() : Option12.some({ firstKeptEntryId: first.id, head: entries.slice(0, index), recent });
12080
+ return first === undefined ? Option13.none() : Option13.some({ firstKeptEntryId: first.id, head: entries.slice(0, index), recent });
11938
12081
  },
11939
12082
  summarize: (plan2, request) => {
11940
- const effect = Effect41.gen(function* () {
12083
+ const effect = Effect43.gen(function* () {
11941
12084
  const head = buildContext(plan2.head);
11942
12085
  const [compactedHead] = request.toolOutputMaxBytes === undefined ? [head, false] : yield* microcompactPrompt(head, request.toolOutputMaxBytes);
11943
12086
  const prompt = summaryPrompt(options.summaryPrompt ?? SUMMARY_TEMPLATE, compactedHead);
11944
12087
  const model = yield* LanguageModel.LanguageModel;
11945
- return yield* model.generateText({ prompt, toolkit: Toolkit2.empty, toolChoice: "none" }).pipe(Effect41.map((response) => response.text), Effect41.mapError((error5) => new CompactionError({ message: String(error5), cause: error5 })));
12088
+ return yield* model.generateText({ prompt, toolkit: Toolkit3.empty, toolChoice: "none" }).pipe(Effect43.map((response) => response.text), Effect43.mapError((error5) => new CompactionError({ message: String(error5), cause: error5 })));
11946
12089
  });
11947
- return options.summaryModel === undefined ? effect : effect.pipe(Effect41.provide(options.summaryModel));
12090
+ return options.summaryModel === undefined ? effect : effect.pipe(Effect43.provide(options.summaryModel));
11948
12091
  }
11949
12092
  });
11950
12093
  var strategy = (parts, base2 = defaultStrategy()) => parts.reduce((current2, part) => ({
@@ -11962,7 +12105,7 @@ var keepRecent = (options) => ({
11962
12105
  });
11963
12106
  var structuredSummary = (options = {}) => ({
11964
12107
  summarize: (plan2, request) => {
11965
- const effect = Effect41.gen(function* () {
12108
+ const effect = Effect43.gen(function* () {
11966
12109
  const head = buildContext(plan2.head);
11967
12110
  const [compactedHead] = request.toolOutputMaxBytes === undefined ? [head, false] : yield* microcompactPrompt(head, request.toolOutputMaxBytes);
11968
12111
  const prompt = summaryPrompt(options.summaryPrompt ?? SUMMARY_TEMPLATE, compactedHead);
@@ -11972,17 +12115,17 @@ var structuredSummary = (options = {}) => ({
11972
12115
  schema: AgentSummary,
11973
12116
  objectName: options.objectName ?? "AgentSummary",
11974
12117
  toolChoice: "none"
11975
- }).pipe(Effect41.map((response) => renderAgentSummary(response.value)), Effect41.mapError((error5) => new CompactionError({ message: String(error5), cause: error5 })));
12118
+ }).pipe(Effect43.map((response) => renderAgentSummary(response.value)), Effect43.mapError((error5) => new CompactionError({ message: String(error5), cause: error5 })));
11976
12119
  });
11977
- return options.summaryModel === undefined ? effect : effect.pipe(Effect41.provide(options.summaryModel));
12120
+ return options.summaryModel === undefined ? effect : effect.pipe(Effect43.provide(options.summaryModel));
11978
12121
  }
11979
12122
  });
11980
12123
  var make2 = (compactionStrategy, options = {}) => ({
11981
- maybeCompact: (input) => Effect41.gen(function* () {
12124
+ maybeCompact: (input) => Effect43.gen(function* () {
11982
12125
  const usage = normalizeUsage(input.usage, options);
11983
12126
  const shouldCompact = input.overflow || compactionStrategy.shouldCompact(usage);
11984
12127
  if (!shouldCompact)
11985
- return Option12.none();
12128
+ return Option13.none();
11986
12129
  let history = input.history;
11987
12130
  let prompt = input.prompt;
11988
12131
  let changed = false;
@@ -11994,11 +12137,11 @@ var make2 = (compactionStrategy, options = {}) => ({
11994
12137
  prompt = compactedPrompt;
11995
12138
  changed = historyChanged || promptChanged;
11996
12139
  if (changed && fits(history, prompt, usage))
11997
- return Option12.some(makeMicrocompact(history, prompt));
12140
+ return Option13.some(makeMicrocompact(history, prompt));
11998
12141
  }
11999
12142
  const plan2 = compactionStrategy.cut(input.path ?? [], compactionStrategy.keepRecentTokens ?? options.keepRecentTokens ?? DEFAULT_KEEP_RECENT_TOKENS);
12000
- if (Option12.isNone(plan2))
12001
- return changed ? Option12.some(makeMicrocompact(history, prompt)) : Option12.none();
12143
+ if (Option13.isNone(plan2))
12144
+ return changed ? Option13.some(makeMicrocompact(history, prompt)) : Option13.none();
12002
12145
  const summary = yield* compactionStrategy.summarize(plan2.value, {
12003
12146
  ...input,
12004
12147
  history,
@@ -12008,7 +12151,7 @@ var make2 = (compactionStrategy, options = {}) => ({
12008
12151
  });
12009
12152
  const recent = buildContext(plan2.value.recent);
12010
12153
  const [compactedRecent] = toolOutputMaxBytes === undefined ? [recent, false] : yield* microcompactPrompt(recent, toolOutputMaxBytes);
12011
- return Option12.some({
12154
+ return Option13.some({
12012
12155
  _tag: "Summarize",
12013
12156
  history: compactedHistory(summary, plan2.value.head, compactedRecent),
12014
12157
  prompt,
@@ -12017,43 +12160,42 @@ var make2 = (compactionStrategy, options = {}) => ({
12017
12160
  });
12018
12161
  })
12019
12162
  });
12020
- var layer32 = (options = {}, providedStrategy = options.strategy ?? defaultStrategy(options)) => Layer38.succeed(Compaction, Compaction.of(make2(providedStrategy, options)));
12163
+ var layer32 = (options = {}, providedStrategy = options.strategy ?? defaultStrategy(options)) => Layer40.succeed(Compaction, Compaction.of(make2(providedStrategy, options)));
12021
12164
  var truncate = (maxTokens) => ({
12022
- maybeCompact: (input) => Effect41.gen(function* () {
12165
+ maybeCompact: (input) => Effect43.gen(function* () {
12023
12166
  const usage = input.usage;
12024
12167
  if (!input.overflow && !(Number.isFinite(usage.contextWindow) && usage.contextTokens > usage.contextWindow - usage.reserveTokens)) {
12025
- return Option12.none();
12168
+ return Option13.none();
12026
12169
  }
12027
- const tokenizer = yield* Effect41.serviceOption(Tokenizer.Tokenizer);
12028
- if (Option12.isNone(tokenizer))
12029
- return Option12.none();
12030
- const prompt = yield* tokenizer.value.truncate(Prompt3.concat(input.history, input.prompt), maxTokens).pipe(Effect41.mapError((error5) => new CompactionError({ message: String(error5), cause: error5 })));
12031
- return Option12.some(makeMicrocompact(Prompt3.empty, prompt));
12170
+ const tokenizer = yield* Effect43.serviceOption(Tokenizer.Tokenizer);
12171
+ if (Option13.isNone(tokenizer))
12172
+ return Option13.none();
12173
+ const prompt = yield* tokenizer.value.truncate(Prompt3.concat(input.history, input.prompt), maxTokens).pipe(Effect43.mapError((error5) => new CompactionError({ message: String(error5), cause: error5 })));
12174
+ return Option13.some(makeMicrocompact(Prompt3.empty, prompt));
12032
12175
  })
12033
12176
  });
12034
- var testLayer35 = (implementation) => Layer38.succeed(Compaction, Compaction.of(implementation));
12177
+ var testLayer37 = (implementation) => Layer40.succeed(Compaction, Compaction.of(implementation));
12035
12178
  var isContextOverflow = (error5) => /context|token|prompt/i.test(error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5)) && /overflow|exceed|exceeded|maximum|too large|too long|length/i.test(error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5));
12036
12179
 
12037
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/instructions.ts
12180
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/instructions.js
12038
12181
  var exports_instructions = {};
12039
12182
  __export(exports_instructions, {
12040
- testLayer: () => testLayer36,
12183
+ testLayer: () => testLayer38,
12041
12184
  staticSource: () => staticSource,
12042
12185
  renderUpdate: () => renderUpdate,
12043
12186
  openEpoch: () => openEpoch,
12044
12187
  layer: () => layer33,
12045
12188
  Instructions: () => Instructions
12046
12189
  });
12047
- import { Context as Context39, Effect as Effect42, Layer as Layer39, Option as Option13 } from "effect";
12048
-
12049
- class Instructions extends Context39.Service()("@batonfx/core/Instructions") {
12190
+ import { Context as Context41, Effect as Effect44, Layer as Layer41, Option as Option14 } from "effect";
12191
+ class Instructions extends Context41.Service()("@batonfx/core/Instructions") {
12050
12192
  }
12051
12193
  var staticSource = (id2, text2) => ({
12052
12194
  id: id2,
12053
12195
  cache: "baseline",
12054
- render: () => Effect42.succeed(text2.length === 0 ? Option13.none() : Option13.some(text2))
12196
+ render: () => Effect44.succeed(text2.length === 0 ? Option14.none() : Option14.some(text2))
12055
12197
  });
12056
- var openEpoch = (instructions, context) => Effect42.gen(function* () {
12198
+ var openEpoch = (instructions, context) => Effect44.gen(function* () {
12057
12199
  const baseline = [];
12058
12200
  const dynamic = [];
12059
12201
  for (const source of instructions.sources) {
@@ -12061,7 +12203,7 @@ var openEpoch = (instructions, context) => Effect42.gen(function* () {
12061
12203
  dynamic.push(source);
12062
12204
  } else {
12063
12205
  const rendered = yield* source.render(context);
12064
- if (Option13.isSome(rendered))
12206
+ if (Option14.isSome(rendered))
12065
12207
  baseline.push(rendered.value);
12066
12208
  }
12067
12209
  }
@@ -12069,69 +12211,70 @@ var openEpoch = (instructions, context) => Effect42.gen(function* () {
12069
12211
 
12070
12212
  `), dynamic };
12071
12213
  });
12072
- var renderUpdate = (epoch, context) => Effect42.gen(function* () {
12214
+ var renderUpdate = (epoch, context) => Effect44.gen(function* () {
12073
12215
  const fragments = [];
12074
12216
  for (const source of epoch.dynamic) {
12075
12217
  const rendered = yield* source.render(context);
12076
- if (Option13.isSome(rendered))
12218
+ if (Option14.isSome(rendered))
12077
12219
  fragments.push(rendered.value);
12078
12220
  }
12079
- return fragments.length === 0 ? Option13.none() : Option13.some(fragments.join(`
12221
+ return fragments.length === 0 ? Option14.none() : Option14.some(fragments.join(`
12080
12222
 
12081
12223
  `));
12082
12224
  });
12083
- var layer33 = (sources) => Layer39.succeed(Instructions, Instructions.of({ sources: [...sources] }));
12084
- var testLayer36 = (implementation) => Layer39.succeed(Instructions, Instructions.of(implementation));
12225
+ var layer33 = (sources) => Layer41.succeed(Instructions, Instructions.of({ sources: [...sources] }));
12226
+ var testLayer38 = (implementation) => Layer41.succeed(Instructions, Instructions.of(implementation));
12085
12227
 
12086
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/memory.ts
12228
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/memory.js
12087
12229
  var exports_memory = {};
12088
12230
  __export(exports_memory, {
12089
- testLayer: () => testLayer37,
12231
+ testLayer: () => testLayer39,
12090
12232
  noopLayer: () => noopLayer,
12091
12233
  merge: () => merge,
12092
12234
  MemoryError: () => MemoryError,
12093
12235
  Memory: () => Memory
12094
12236
  });
12095
- import { Context as Context40, Effect as Effect43, Layer as Layer40, Schema as Schema56 } from "effect";
12237
+ import { Context as Context42, Effect as Effect45, Layer as Layer42, Schema as Schema57 } from "effect";
12238
+ import { Prompt as Prompt4 } from "effect/unstable/ai";
12096
12239
 
12097
- class MemoryError extends Schema56.TaggedErrorClass()("@batonfx/core/MemoryError", {
12098
- message: Schema56.String
12240
+ class MemoryError extends Schema57.TaggedErrorClass()("@batonfx/core/MemoryError", {
12241
+ message: Schema57.String
12099
12242
  }) {
12100
12243
  }
12101
12244
 
12102
- class Memory extends Context40.Service()("@batonfx/core/Memory") {
12245
+ class Memory extends Context42.Service()("@batonfx/core/Memory") {
12103
12246
  }
12104
12247
  var noop = {
12105
- recall: () => Effect43.succeed([]),
12106
- remember: () => Effect43.void,
12107
- forget: () => Effect43.void
12248
+ recall: () => Effect45.succeed([]),
12249
+ remember: () => Effect45.void,
12250
+ forget: () => Effect45.void
12108
12251
  };
12109
12252
  var merge = (first, second) => ({
12110
- recall: (input) => Effect43.all([first.recall(input), second.recall(input)]).pipe(Effect43.map(([firstItems, secondItems]) => [...firstItems, ...secondItems])),
12111
- remember: (input) => Effect43.all([first.remember(input), second.remember(input)], { discard: true }),
12112
- forget: (input) => Effect43.all([first.forget(input), second.forget(input)], { discard: true })
12253
+ recall: (input) => Effect45.all([first.recall(input), second.recall(input)]).pipe(Effect45.map(([firstItems, secondItems]) => [...firstItems, ...secondItems])),
12254
+ remember: (input) => Effect45.all([first.remember(input), second.remember(input)], { discard: true }),
12255
+ forget: (input) => Effect45.all([first.forget(input), second.forget(input)], { discard: true })
12113
12256
  });
12114
- var noopLayer = Layer40.succeed(Memory, Memory.of(noop));
12115
- var testLayer37 = (implementation) => Layer40.succeed(Memory, Memory.of(implementation));
12257
+ var noopLayer = Layer42.succeed(Memory, Memory.of(noop));
12258
+ var testLayer39 = (implementation) => Layer42.succeed(Memory, Memory.of(implementation));
12116
12259
 
12117
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/model-middleware.ts
12260
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/model-middleware.js
12118
12261
  var exports_model_middleware = {};
12119
12262
  __export(exports_model_middleware, {
12120
12263
  layer: () => layer34,
12121
12264
  identityLayer: () => identityLayer,
12122
12265
  ModelMiddleware: () => ModelMiddleware
12123
12266
  });
12124
- import { Context as Context41, Layer as Layer41 } from "effect";
12125
-
12126
- class ModelMiddleware extends Context41.Service()("@batonfx/core/ModelMiddleware") {
12267
+ import { Context as Context43, Effect as Effect46, Layer as Layer43, Option as Option15 } from "effect";
12268
+ import { Prompt as Prompt5, Response as Response3 } from "effect/unstable/ai";
12269
+ class ModelMiddleware extends Context43.Service()("@batonfx/core/ModelMiddleware") {
12127
12270
  }
12128
- var identityLayer = Layer41.succeed(ModelMiddleware, []);
12129
- var layer34 = (middleware) => Layer41.succeed(ModelMiddleware, middleware);
12271
+ var identityLayer = Layer43.succeed(ModelMiddleware, []);
12272
+ var layer34 = (middleware) => Layer43.succeed(ModelMiddleware, middleware);
12130
12273
 
12131
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/model-registry.ts
12274
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/model-registry.js
12132
12275
  var exports_model_registry = {};
12133
12276
  __export(exports_model_registry, {
12134
- testLayer: () => testLayer38,
12277
+ testLayer: () => testLayer40,
12135
12278
  registrations: () => registrations,
12136
12279
  registrationFromLayer: () => registrationFromLayer,
12137
12280
  register: () => register4,
@@ -12143,17 +12286,17 @@ __export(exports_model_registry, {
12143
12286
  Service: () => Service35,
12144
12287
  LanguageModelNotRegistered: () => LanguageModelNotRegistered
12145
12288
  });
12146
- import { Chunk as Chunk2, Context as Context42, Effect as Effect45, Layer as Layer42, Option as Option15, Ref as Ref12, Schema as Schema57, Semaphore as Semaphore4 } from "effect";
12147
- import { Model } from "effect/unstable/ai";
12289
+ import { Chunk as Chunk2, Context as Context44, Effect as Effect47, Layer as Layer44, Option as Option16, Ref as Ref12, Schema as Schema58, Semaphore as Semaphore4 } from "effect";
12290
+ import { LanguageModel as LanguageModel2, Model } from "effect/unstable/ai";
12148
12291
 
12149
- class LanguageModelNotRegistered extends Schema57.TaggedErrorClass()("LanguageModelNotRegistered", {
12150
- provider: Schema57.String,
12151
- model: Schema57.String,
12152
- registration_key: Schema57.optionalKey(Schema57.String)
12292
+ class LanguageModelNotRegistered extends Schema58.TaggedErrorClass()("LanguageModelNotRegistered", {
12293
+ provider: Schema58.String,
12294
+ model: Schema58.String,
12295
+ registration_key: Schema58.optionalKey(Schema58.String)
12153
12296
  }) {
12154
12297
  }
12155
12298
 
12156
- class Service35 extends Context42.Service()("@batonfx/core/ModelRegistry") {
12299
+ class Service35 extends Context44.Service()("@batonfx/core/ModelRegistry") {
12157
12300
  }
12158
12301
  var registrationVariantKey = (value) => value.registrationKey ?? null;
12159
12302
  var selectionVariantKey = (selection) => selection.registrationKey ?? null;
@@ -12161,37 +12304,37 @@ var registryIdentity = (registration) => JSON.stringify([registration.provider,
12161
12304
  var matchesSelection = (selection) => (registration) => registration.provider === selection.provider && registration.model === selection.model && registrationVariantKey(registration) === selectionVariantKey(selection);
12162
12305
  var upsertRegistration = (registry, registration) => {
12163
12306
  const key3 = registryIdentity(registration);
12164
- const exists = Option15.isSome(Chunk2.findFirst(registry, (item) => registryIdentity(item) === key3));
12307
+ const exists = Option16.isSome(Chunk2.findFirst(registry, (item) => registryIdentity(item) === key3));
12165
12308
  if (!exists)
12166
12309
  return Chunk2.append(registry, registration);
12167
12310
  return Chunk2.map(registry, (item) => registryIdentity(item) === key3 ? registration : item);
12168
12311
  };
12169
- var findRegistration = (registry, selection) => Chunk2.findFirst(registry, matchesSelection(selection)).pipe(Option15.getOrUndefined);
12170
- var registrationFromLayer = (input) => Model.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect45.map((layer35) => ({
12312
+ var findRegistration = (registry, selection) => Chunk2.findFirst(registry, matchesSelection(selection)).pipe(Option16.getOrUndefined);
12313
+ var registrationFromLayer = (input) => Model.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect47.map((layer35) => ({
12171
12314
  provider: input.provider,
12172
12315
  model: input.model,
12173
12316
  layer: layer35,
12174
12317
  ...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
12175
12318
  ...input.metadata === undefined ? {} : { metadata: input.metadata }
12176
12319
  })));
12177
- var layer35 = (initialRegistrations = [], options) => Layer42.effect(Service35, Effect45.gen(function* () {
12320
+ var layer35 = (initialRegistrations = [], options) => Layer44.effect(Service35, Effect47.gen(function* () {
12178
12321
  const registry = yield* Ref12.make(initialRegistrations.reduce(upsertRegistration, Chunk2.empty()));
12179
12322
  const semaphore = options?.maxConcurrentModelCalls === undefined ? undefined : yield* Semaphore4.make(options.maxConcurrentModelCalls);
12180
- const register4 = Effect45.fn("ModelRegistry.register")(function* (input) {
12323
+ const register4 = Effect47.fn("ModelRegistry.register")(function* (input) {
12181
12324
  yield* Ref12.update(registry, (items) => upsertRegistration(items, input.registration));
12182
12325
  });
12183
- const registrations = Ref12.get(registry).pipe(Effect45.map(Chunk2.toReadonlyArray));
12184
- const provide = Effect45.fn("ModelRegistry.provide")(function* (selection, effect) {
12326
+ const registrations = Ref12.get(registry).pipe(Effect47.map(Chunk2.toReadonlyArray));
12327
+ const provide = Effect47.fn("ModelRegistry.provide")(function* (selection, effect) {
12185
12328
  const items = yield* Ref12.get(registry);
12186
12329
  const registration = findRegistration(items, selection);
12187
12330
  if (registration === undefined) {
12188
- return yield* Effect45.fail(new LanguageModelNotRegistered({
12331
+ return yield* Effect47.fail(new LanguageModelNotRegistered({
12189
12332
  provider: selection.provider,
12190
12333
  model: selection.model,
12191
12334
  ...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
12192
12335
  }));
12193
12336
  }
12194
- const provided = effect.pipe(Effect45.provide(registration.layer));
12337
+ const provided = effect.pipe(Effect47.provide(registration.layer));
12195
12338
  return yield* semaphore === undefined ? provided : semaphore.withPermits(1)(provided);
12196
12339
  });
12197
12340
  return Service35.of({
@@ -12200,27 +12343,27 @@ var layer35 = (initialRegistrations = [], options) => Layer42.effect(Service35,
12200
12343
  provide
12201
12344
  });
12202
12345
  }));
12203
- var layerFromRegistrationEffects = (registrations, options) => Layer42.unwrap(Effect45.all(registrations).pipe(Effect45.map((items) => layer35(items, options))));
12204
- var combine = (registries, options) => Layer42.unwrap(Effect45.forEach(registries, (registry) => Layer42.build(registry).pipe(Effect45.flatMap((context) => Context42.get(context, Service35).registrations))).pipe(Effect45.map((groups) => layer35(groups.flat(), options))));
12346
+ var layerFromRegistrationEffects = (registrations, options) => Layer44.unwrap(Effect47.all(registrations).pipe(Effect47.map((items) => layer35(items, options))));
12347
+ var combine = (registries, options) => Layer44.unwrap(Effect47.forEach(registries, (registry) => Layer44.build(registry).pipe(Effect47.flatMap((context) => Context44.get(context, Service35).registrations))).pipe(Effect47.map((groups) => layer35(groups.flat(), options))));
12205
12348
  var memoryLayer33 = layer35;
12206
- var testLayer38 = (implementation) => Layer42.succeed(Service35, Service35.of(implementation));
12207
- var register4 = Effect45.fn("ModelRegistry.register.call")(function* (input) {
12349
+ var testLayer40 = (implementation) => Layer44.succeed(Service35, Service35.of(implementation));
12350
+ var register4 = Effect47.fn("ModelRegistry.register.call")(function* (input) {
12208
12351
  const service = yield* Service35;
12209
12352
  return yield* service.register(input);
12210
12353
  });
12211
- var registrations = Effect45.fn("ModelRegistry.registrations.call")(function* () {
12354
+ var registrations = Effect47.fn("ModelRegistry.registrations.call")(function* () {
12212
12355
  const service = yield* Service35;
12213
12356
  return yield* service.registrations;
12214
12357
  });
12215
- var provide = (selection, effect) => Effect45.gen(function* () {
12358
+ var provide = (selection, effect) => Effect47.gen(function* () {
12216
12359
  const service = yield* Service35;
12217
12360
  return yield* service.provide(selection, effect);
12218
12361
  });
12219
12362
 
12220
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/model-resilience.ts
12363
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/model-resilience.js
12221
12364
  var exports_model_resilience = {};
12222
12365
  __export(exports_model_resilience, {
12223
- testLayer: () => testLayer39,
12366
+ testLayer: () => testLayer41,
12224
12367
  none: () => none,
12225
12368
  make: () => make3,
12226
12369
  layer: () => layer36,
@@ -12228,45 +12371,45 @@ __export(exports_model_resilience, {
12228
12371
  apply: () => apply,
12229
12372
  ModelResilience: () => ModelResilience
12230
12373
  });
12231
- import { Cause, Context as Context43, Effect as Effect46, Layer as Layer43, Schedule as Schedule3, Stream as Stream7 } from "effect";
12232
- import { AiError, Response as Response2 } from "effect/unstable/ai";
12374
+ import { Cause as Cause2, Context as Context45, Effect as Effect48, Layer as Layer45, Schedule as Schedule4, Stream as Stream8 } from "effect";
12375
+ import { AiError, LanguageModel as LanguageModel3, Response as Response4 } from "effect/unstable/ai";
12233
12376
 
12234
- class ModelResilience extends Context43.Service()("@batonfx/core/ModelResilience") {
12377
+ class ModelResilience extends Context45.Service()("@batonfx/core/ModelResilience") {
12235
12378
  }
12236
12379
  var defaultClassify = (error5) => AiError.isAiError(error5) && error5.isRetryable ? "transient" : "terminal";
12237
- var none = { classify: () => "terminal", retrySchedule: Schedule3.recurs(0) };
12380
+ var none = { classify: () => "terminal", retrySchedule: Schedule4.recurs(0) };
12238
12381
  var make3 = (input) => ({
12239
12382
  classify: input?.classify ?? defaultClassify,
12240
12383
  retrySchedule: input?.retrySchedule ?? none.retrySchedule
12241
12384
  });
12242
- var layer36 = (input) => Layer43.succeed(ModelResilience, ModelResilience.of(make3(input)));
12243
- var testLayer39 = (implementation) => Layer43.succeed(ModelResilience, ModelResilience.of(implementation));
12244
- var retryEffect = (effect, resilience) => Effect46.suspend(effect).pipe(Effect46.retry({
12385
+ var layer36 = (input) => Layer45.succeed(ModelResilience, ModelResilience.of(make3(input)));
12386
+ var testLayer41 = (implementation) => Layer45.succeed(ModelResilience, ModelResilience.of(implementation));
12387
+ var retryEffect = (effect, resilience) => Effect48.suspend(effect).pipe(Effect48.retry({
12245
12388
  schedule: resilience.retrySchedule,
12246
12389
  while: (error5) => resilience.classify(error5) === "transient"
12247
12390
  }));
12248
- var retryStreamSchedule = (resilience) => resilience.retrySchedule.pipe(Schedule3.while(({ input }) => resilience.classify(input) === "transient"));
12391
+ var retryStreamSchedule = (resilience) => resilience.retrySchedule.pipe(Schedule4.while(({ input }) => resilience.classify(input) === "transient"));
12249
12392
  var apply = (model, resilience) => ({
12250
12393
  ...model,
12251
12394
  generateText: (options) => retryEffect(() => model.generateText(options), resilience),
12252
12395
  generateObject: (options) => retryEffect(() => model.generateObject(options), resilience),
12253
- streamText: (options) => Stream7.suspend(() => {
12396
+ streamText: (options) => Stream8.suspend(() => {
12254
12397
  let emitted = false;
12255
- return model.streamText(options).pipe(Stream7.tap(() => Effect46.sync(() => {
12398
+ return model.streamText(options).pipe(Stream8.tap(() => Effect48.sync(() => {
12256
12399
  emitted = true;
12257
- })), Stream7.catchCause((cause) => {
12258
- if (Cause.hasInterrupts(cause))
12259
- return Stream7.failCause(cause);
12260
- const error5 = Cause.squash(cause);
12261
- return emitted ? Stream7.make(Response2.makePart("error", { error: error5 })) : Stream7.failCause(cause);
12400
+ })), Stream8.catchCause((cause) => {
12401
+ if (Cause2.hasInterrupts(cause))
12402
+ return Stream8.failCause(cause);
12403
+ const error5 = Cause2.squash(cause);
12404
+ return emitted ? Stream8.make(Response4.makePart("error", { error: error5 })) : Stream8.failCause(cause);
12262
12405
  }));
12263
- }).pipe(Stream7.retry(retryStreamSchedule(resilience)))
12406
+ }).pipe(Stream8.retry(retryStreamSchedule(resilience)))
12264
12407
  });
12265
12408
 
12266
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/permissions.ts
12409
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/permissions.js
12267
12410
  var exports_permissions = {};
12268
12411
  __export(exports_permissions, {
12269
- testLayer: () => testLayer40,
12412
+ testLayer: () => testLayer42,
12270
12413
  ruleStoreTestLayer: () => ruleStoreTestLayer,
12271
12414
  ruleStoreMemory: () => ruleStoreMemory,
12272
12415
  matches: () => matches,
@@ -12278,17 +12421,17 @@ __export(exports_permissions, {
12278
12421
  Permissions: () => Permissions,
12279
12422
  PermissionError: () => PermissionError
12280
12423
  });
12281
- import { Context as Context44, Effect as Effect47, Layer as Layer44, Option as Option16, Ref as Ref13, Schema as Schema58 } from "effect";
12424
+ import { Context as Context46, Effect as Effect49, Layer as Layer46, Option as Option17, Ref as Ref13, Schema as Schema59 } from "effect";
12282
12425
 
12283
- class PermissionError extends Schema58.TaggedErrorClass()("@batonfx/core/PermissionError", {
12284
- message: Schema58.String
12426
+ class PermissionError extends Schema59.TaggedErrorClass()("@batonfx/core/PermissionError", {
12427
+ message: Schema59.String
12285
12428
  }) {
12286
12429
  }
12287
12430
 
12288
- class Permissions extends Context44.Service()("@batonfx/core/Permissions") {
12431
+ class Permissions extends Context46.Service()("@batonfx/core/Permissions") {
12289
12432
  }
12290
12433
 
12291
- class RuleStore extends Context44.Service()("@batonfx/core/PermissionRuleStore") {
12434
+ class RuleStore extends Context46.Service()("@batonfx/core/PermissionRuleStore") {
12292
12435
  }
12293
12436
  var escapeRegExp = (value) => value.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
12294
12437
  var glob = (pattern) => new RegExp(`^${pattern.split("*").map(escapeRegExp).join(".*")}$`);
@@ -12375,28 +12518,28 @@ var decisionFor = (ruleset, request) => {
12375
12518
  return { _tag: "Ask", token: tokenFor(request) };
12376
12519
  }
12377
12520
  };
12378
- var fromRuleset = (ruleset) => Layer44.succeed(Permissions, Permissions.of({
12379
- evaluate: (request) => Effect47.succeed(decisionFor(ruleset, request)),
12380
- await: () => Effect47.succeed(Option16.none())
12521
+ var fromRuleset = (ruleset) => Layer46.succeed(Permissions, Permissions.of({
12522
+ evaluate: (request) => Effect49.succeed(decisionFor(ruleset, request)),
12523
+ await: () => Effect49.succeed(Option17.none())
12381
12524
  }));
12382
- var allowAll = Layer44.succeed(Permissions, Permissions.of({
12383
- evaluate: () => Effect47.succeed({ _tag: "Allow" }),
12384
- await: () => Effect47.succeed(Option16.none())
12525
+ var allowAll = Layer46.succeed(Permissions, Permissions.of({
12526
+ evaluate: () => Effect49.succeed({ _tag: "Allow" }),
12527
+ await: () => Effect49.succeed(Option17.none())
12385
12528
  }));
12386
- var interactive = (options) => Layer44.succeed(Permissions, Permissions.of({
12387
- evaluate: (request) => Effect47.succeed(decisionFor(options.ruleset, request)),
12388
- await: (pending) => options.onAsk(pending).pipe(Effect47.map(Option16.some))
12529
+ var interactive = (options) => Layer46.succeed(Permissions, Permissions.of({
12530
+ evaluate: (request) => Effect49.succeed(decisionFor(options.ruleset, request)),
12531
+ await: (pending) => options.onAsk(pending).pipe(Effect49.map(Option17.some))
12389
12532
  }));
12390
- var ruleStoreMemory = (initialRules = []) => Layer44.effect(RuleStore, Ref13.make(initialRules).pipe(Effect47.map((rules) => RuleStore.of({
12533
+ var ruleStoreMemory = (initialRules = []) => Layer46.effect(RuleStore, Ref13.make(initialRules).pipe(Effect49.map((rules) => RuleStore.of({
12391
12534
  remember: (rule) => Ref13.update(rules, (current2) => [...current2, rule])
12392
12535
  }))));
12393
- var ruleStoreTestLayer = (implementation) => Layer44.succeed(RuleStore, RuleStore.of(implementation));
12394
- var testLayer40 = (implementation) => Layer44.succeed(Permissions, Permissions.of(implementation));
12536
+ var ruleStoreTestLayer = (implementation) => Layer46.succeed(RuleStore, RuleStore.of(implementation));
12537
+ var testLayer42 = (implementation) => Layer46.succeed(Permissions, Permissions.of(implementation));
12395
12538
 
12396
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/skill-source.ts
12539
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/skill-source.js
12397
12540
  var exports_skill_source = {};
12398
12541
  __export(exports_skill_source, {
12399
- testLayer: () => testLayer41,
12542
+ testLayer: () => testLayer43,
12400
12543
  selectListings: () => selectListings,
12401
12544
  merge: () => merge2,
12402
12545
  makeListing: () => makeListing,
@@ -12407,31 +12550,32 @@ __export(exports_skill_source, {
12407
12550
  SkillSource: () => SkillSource,
12408
12551
  DESCRIPTION_CAP: () => DESCRIPTION_CAP
12409
12552
  });
12410
- import { Context as Context45, Effect as Effect48, Layer as Layer45, Schema as Schema59 } from "effect";
12553
+ import { Context as Context47, Effect as Effect50, Layer as Layer47, Schema as Schema60 } from "effect";
12554
+ import { Tool as Tool4 } from "effect/unstable/ai";
12411
12555
 
12412
- class SkillSourceError extends Schema59.TaggedErrorClass()("@batonfx/core/SkillSourceError", {
12413
- source: Schema59.String,
12414
- message: Schema59.String,
12415
- cause: Schema59.optionalKey(Schema59.Defect())
12556
+ class SkillSourceError extends Schema60.TaggedErrorClass()("@batonfx/core/SkillSourceError", {
12557
+ source: Schema60.String,
12558
+ message: Schema60.String,
12559
+ cause: Schema60.optionalKey(Schema60.Defect())
12416
12560
  }) {
12417
12561
  }
12418
12562
  var DESCRIPTION_CAP = 1024;
12419
12563
 
12420
- class SkillSource extends Context45.Service()("@batonfx/core/SkillSource") {
12564
+ class SkillSource extends Context47.Service()("@batonfx/core/SkillSource") {
12421
12565
  }
12422
12566
  var makeListing = (frontmatter, descriptionCap = DESCRIPTION_CAP) => `- ${frontmatter.name}: ${frontmatter.description.slice(0, Math.max(0, descriptionCap))}`;
12423
12567
  var fromSkills = (skills) => {
12424
12568
  const all = [...skills];
12425
12569
  const byName = new Map(all.map((skill) => [skill.frontmatter.name, skill]));
12426
- return Layer45.succeed(SkillSource, SkillSource.of({
12427
- all: Effect48.succeed(all),
12428
- get: (name) => Effect48.succeed(byName.get(name))
12570
+ return Layer47.succeed(SkillSource, SkillSource.of({
12571
+ all: Effect50.succeed(all),
12572
+ get: (name) => Effect50.succeed(byName.get(name))
12429
12573
  }));
12430
12574
  };
12431
12575
  var empty = fromSkills([]);
12432
- var testLayer41 = (implementation) => Layer45.succeed(SkillSource, SkillSource.of(implementation));
12576
+ var testLayer43 = (implementation) => Layer47.succeed(SkillSource, SkillSource.of(implementation));
12433
12577
  var merge2 = (sources) => ({
12434
- all: Effect48.forEach(sources, (source) => source.all).pipe(Effect48.map((groups) => {
12578
+ all: Effect50.forEach(sources, (source) => source.all).pipe(Effect50.map((groups) => {
12435
12579
  const byName = new Map;
12436
12580
  for (const skills of groups) {
12437
12581
  for (const skill of skills)
@@ -12439,7 +12583,7 @@ var merge2 = (sources) => ({
12439
12583
  }
12440
12584
  return [...byName.values()];
12441
12585
  })),
12442
- get: (name) => Effect48.gen(function* () {
12586
+ get: (name) => Effect50.gen(function* () {
12443
12587
  for (const source of sources.toReversed()) {
12444
12588
  const found = yield* source.get(name);
12445
12589
  if (found !== undefined)
@@ -12448,7 +12592,7 @@ var merge2 = (sources) => ({
12448
12592
  return;
12449
12593
  })
12450
12594
  });
12451
- var layer37 = (sources) => Layer45.effect(SkillSource, Effect48.forEach(sources, (source) => source).pipe(Effect48.map((built) => SkillSource.of(merge2(built)))));
12595
+ var layer37 = (sources) => Layer47.effect(SkillSource, Effect50.forEach(sources, (source) => source).pipe(Effect50.map((built) => SkillSource.of(merge2(built)))));
12452
12596
  var estimatedTokens = (listing) => Math.ceil(listing.length / 4);
12453
12597
  var usageRank = (skill, recentlyUsed) => {
12454
12598
  const index = recentlyUsed.indexOf(skill.frontmatter.name);
@@ -12472,22 +12616,23 @@ var selectListings = (skills, budgetTokens, recentlyUsed) => {
12472
12616
  return selected;
12473
12617
  };
12474
12618
 
12475
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/steering.ts
12619
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/steering.js
12476
12620
  var exports_steering = {};
12477
12621
  __export(exports_steering, {
12478
- testLayer: () => testLayer42,
12622
+ testLayer: () => testLayer44,
12479
12623
  layer: () => layer38,
12480
12624
  SteeringQueueFull: () => SteeringQueueFull,
12481
12625
  Steering: () => Steering
12482
12626
  });
12483
- import { Context as Context46, Effect as Effect49, Exit, Layer as Layer46, Queue, Schema as Schema60 } from "effect";
12627
+ import { Context as Context48, Effect as Effect51, Exit, Layer as Layer48, Queue, Schema as Schema61 } from "effect";
12628
+ import { Prompt as Prompt6 } from "effect/unstable/ai";
12484
12629
 
12485
- class Steering extends Context46.Service()("@batonfx/core/Steering") {
12630
+ class Steering extends Context48.Service()("@batonfx/core/Steering") {
12486
12631
  }
12487
12632
 
12488
- class SteeringQueueFull extends Schema60.TaggedErrorClass()("@batonfx/core/SteeringQueueFull", {
12489
- queue: Schema60.Literals(["steering", "followUp"]),
12490
- capacity: Schema60.Number
12633
+ class SteeringQueueFull extends Schema61.TaggedErrorClass()("@batonfx/core/SteeringQueueFull", {
12634
+ queue: Schema61.Literals(["steering", "followUp"]),
12635
+ capacity: Schema61.Number
12491
12636
  }) {
12492
12637
  }
12493
12638
  var resolvePolicy = (policy, mode) => ({
@@ -12506,18 +12651,18 @@ var queueStrategy = (strategy2) => {
12506
12651
  return "suspend";
12507
12652
  }
12508
12653
  };
12509
- var makeQueue = (name, policy) => (policy.capacity === undefined ? Queue.unbounded() : Queue.make({ capacity: policy.capacity, strategy: queueStrategy(policy.onFull) })).pipe(Effect49.map((queue) => ({ name, queue, policy })));
12510
- var offer = (runtime, message) => Queue.offer(runtime.queue, message).pipe(Effect49.flatMap((offered) => {
12654
+ var makeQueue = (name, policy) => (policy.capacity === undefined ? Queue.unbounded() : Queue.make({ capacity: policy.capacity, strategy: queueStrategy(policy.onFull) })).pipe(Effect51.map((queue) => ({ name, queue, policy })));
12655
+ var offer = (runtime, message) => Queue.offer(runtime.queue, message).pipe(Effect51.flatMap((offered) => {
12511
12656
  if (offered || runtime.policy.capacity === undefined || runtime.policy.onFull !== "fail")
12512
- return Effect49.void;
12513
- return Effect49.fail(new SteeringQueueFull({ queue: runtime.name, capacity: runtime.policy.capacity }));
12657
+ return Effect51.void;
12658
+ return Effect51.fail(new SteeringQueueFull({ queue: runtime.name, capacity: runtime.policy.capacity }));
12514
12659
  }));
12515
- var drainOne = (queue) => Effect49.sync(() => {
12660
+ var drainOne = (queue) => Effect51.sync(() => {
12516
12661
  const taken = Queue.takeUnsafe(queue);
12517
12662
  return taken === undefined || !Exit.isSuccess(taken) ? [] : [taken.value];
12518
12663
  });
12519
12664
  var drain2 = (queue, mode) => mode === "all" ? Queue.clear(queue) : drainOne(queue);
12520
- var layer38 = (options = {}) => Layer46.effect(Steering, Effect49.gen(function* () {
12665
+ var layer38 = (options = {}) => Layer48.effect(Steering, Effect51.gen(function* () {
12521
12666
  const steeringQueue = yield* makeQueue("steering", resolvePolicy(options.steering, "all"));
12522
12667
  const followUpQueue = yield* makeQueue("followUp", resolvePolicy(options.followUp, "one-at-a-time"));
12523
12668
  return Steering.of({
@@ -12527,153 +12672,9 @@ var layer38 = (options = {}) => Layer46.effect(Steering, Effect49.gen(function*
12527
12672
  takeFollowUp: () => drain2(followUpQueue.queue, followUpQueue.policy.mode)
12528
12673
  });
12529
12674
  }));
12530
- var testLayer42 = (implementation) => Layer46.succeed(Steering, Steering.of(implementation));
12531
-
12532
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/tool-context.ts
12533
- var exports_tool_context = {};
12534
- __export(exports_tool_context, {
12535
- testLayer: () => testLayer43,
12536
- layerDefault: () => layerDefault,
12537
- ToolContext: () => ToolContext
12538
- });
12539
- import { Context as Context47, Effect as Effect50, Layer as Layer47 } from "effect";
12540
-
12541
- class ToolContext extends Context47.Service()("@batonfx/core/ToolContext") {
12542
- }
12543
- var layerDefault = Layer47.sync(ToolContext, () => ToolContext.of({
12544
- signal: new AbortController().signal,
12545
- emit: () => Effect50.void,
12546
- sessionId: "local"
12547
- }));
12548
- var testLayer43 = (implementation) => Layer47.succeed(ToolContext, ToolContext.of(implementation));
12549
-
12550
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/tool-executor.ts
12551
- var exports_tool_executor = {};
12552
- __export(exports_tool_executor, {
12553
- testLayer: () => testLayer44,
12554
- sandbox: () => sandbox,
12555
- router: () => router,
12556
- routeToolkit: () => routeToolkit,
12557
- route: () => route,
12558
- remote: () => remote,
12559
- mcp: () => mcp,
12560
- fromToolkit: () => fromToolkit,
12561
- executeToolkit: () => executeToolkit,
12562
- client: () => client,
12563
- ToolExecutor: () => ToolExecutor
12564
- });
12565
- import { Cause as Cause2, Context as Context48, Effect as Effect51, Layer as Layer48, Option as Option17, Schema as Schema61, Sink as Sink2, Stream as Stream8 } from "effect";
12566
- class ToolExecutor extends Context48.Service()("@batonfx/core/ToolExecutor") {
12567
- }
12568
- var failureMessage = (cause) => {
12569
- const error5 = Cause2.squash(cause);
12570
- return error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5);
12571
- };
12572
- var failureOutcome = (message) => ({ _tag: "Failure", message });
12573
- var resultMessage = (result) => {
12574
- if (typeof result === "string")
12575
- return result;
12576
- if (result instanceof Error)
12577
- return `${result.name}: ${result.message}`;
12578
- try {
12579
- const message = JSON.stringify(result);
12580
- return message === undefined ? String(result) : message;
12581
- } catch {
12582
- return String(result);
12583
- }
12584
- };
12585
- var schemaMessage = (error5) => error5 instanceof Error ? error5.message : typeof error5 === "string" ? error5 : resultMessage(error5);
12586
- var decodeSuccess = (tool2, result) => {
12587
- const successSchema = tool2.successSchema;
12588
- if (!Schema61.isSchema(successSchema)) {
12589
- return Effect51.succeed({ _tag: "Success", result, encodedResult: result });
12590
- }
12591
- return Schema61.decodeUnknownEffect(successSchema)(result).pipe(Effect51.flatMap((decoded) => Schema61.encodeUnknownEffect(successSchema)(decoded).pipe(Effect51.map((encoded) => ({ _tag: "Success", result: decoded, encodedResult: encoded })))), Effect51.catchCause((cause) => Effect51.succeed(failureOutcome(`invalid client result: ${schemaMessage(Cause2.squash(cause))}`))));
12592
- };
12593
- var placementOutcome = (placement, tool2, response) => {
12594
- switch (response._tag) {
12595
- case "Failure":
12596
- return Effect51.succeed(failureOutcome(response.message));
12597
- case "Suspend":
12598
- return Effect51.succeed({ _tag: "Suspend", token: response.token });
12599
- case "Success":
12600
- return decodeSuccess(tool2, response.result).pipe(Effect51.map((outcome) => outcome._tag === "Failure" ? failureOutcome(outcome.message.replace("invalid client result", `invalid ${placement} result`)) : outcome));
12601
- }
12602
- };
12603
- var executeWithToolkit = (toolkit, request) => {
12604
- if (toolkit.tools[request.call.name] === undefined) {
12605
- return Effect51.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
12606
- }
12607
- return toolkit.handle(request.call.name, request.call.params).pipe(Effect51.flatMap((results) => results.pipe(Stream8.filter((item) => item.preliminary === false), Stream8.run(Sink2.last()))), Effect51.map(Option17.match({
12608
- onNone: () => failureOutcome("Tool handler did not produce a final result"),
12609
- onSome: (result) => result.isFailure ? failureOutcome(resultMessage(result.result)) : {
12610
- _tag: "Success",
12611
- result: result.result,
12612
- encodedResult: result.encodedResult
12613
- }
12614
- })), Effect51.catchCause((cause) => {
12615
- if (Cause2.hasInterrupts(cause))
12616
- return Effect51.interrupt;
12617
- const error5 = Cause2.squash(cause);
12618
- if (error5 instanceof AgentSuspended) {
12619
- return Effect51.succeed({ _tag: "Suspend", token: error5.token });
12620
- }
12621
- return Effect51.succeed(failureOutcome(failureMessage(cause)));
12622
- }));
12623
- };
12624
- function executeToolkit(toolkit, request) {
12625
- return ("handle" in toolkit ? Effect51.succeed(toolkit) : toolkit).pipe(Effect51.flatMap((handled) => executeWithToolkit(handled, request)));
12626
- }
12627
- function fromToolkit(toolkit) {
12628
- return Layer48.effect(ToolExecutor, ("handle" in toolkit ? Effect51.succeed(toolkit) : toolkit).pipe(Effect51.map((handled) => ToolExecutor.of({
12629
- execute: (request) => executeWithToolkit(handled, request)
12630
- }))));
12631
- }
12632
- var route = (options) => {
12633
- const routedTools = options.tools ?? [];
12634
- return {
12635
- tools: routedTools,
12636
- matches: (request) => routedTools.includes(request.call.name) || options.matches?.(request) === true,
12637
- execute: options.execute
12638
- };
12639
- };
12640
- var placementRoute = (placement, options) => {
12641
- const routedTools = options.tools ?? Object.keys(options.toolkit.tools);
12642
- return route({
12643
- tools: routedTools,
12644
- execute: (request) => {
12645
- const tool2 = options.toolkit.tools[request.call.name];
12646
- if (tool2 === undefined)
12647
- return Effect51.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
12648
- const effect = options.execute({ ...request, placement, tool: tool2 });
12649
- const scheduled = "schedule" in options && options.schedule !== undefined ? Effect51.retry(effect, options.schedule) : effect;
12650
- return scheduled.pipe(Effect51.flatMap((response) => placementOutcome(placement, tool2, response)), Effect51.catchCause((cause) => Cause2.hasInterrupts(cause) ? Effect51.interrupt : Effect51.succeed(failureOutcome(`${placement} tool infrastructure failed: ${failureMessage(cause)}`))));
12651
- }
12652
- });
12653
- };
12654
- var client = (options) => placementRoute("client", options);
12655
- var remote = (options) => placementRoute("remote", options);
12656
- var mcp = (options) => placementRoute("mcp", options);
12657
- var sandbox = (options) => placementRoute("sandbox", options);
12658
- function routeToolkit(toolkit) {
12659
- const makeRoute = (handled) => route({
12660
- tools: Object.keys(handled.tools),
12661
- execute: (request) => executeWithToolkit(handled, request)
12662
- });
12663
- return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(Effect51.map(makeRoute));
12664
- }
12665
- var routeInputEffect = (input) => Effect51.isEffect(input) ? input : Effect51.succeed(input);
12666
- function router(routes) {
12667
- return Layer48.effect(ToolExecutor, Effect51.all(Array.from(routes, routeInputEffect)).pipe(Effect51.map((resolved) => ToolExecutor.of({
12668
- execute: (request) => {
12669
- const matched = resolved.find((candidate) => candidate.matches(request));
12670
- return matched === undefined ? Effect51.succeed(failureOutcome(`Tool ${request.call.name} is not registered`)) : matched.execute(request);
12671
- }
12672
- }))));
12673
- }
12674
- var testLayer44 = (implementation) => Layer48.succeed(ToolExecutor, ToolExecutor.of(implementation));
12675
+ var testLayer44 = (implementation) => Layer48.succeed(Steering, Steering.of(implementation));
12675
12676
 
12676
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/turn-policy.ts
12677
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/turn-policy.js
12677
12678
  var exports_turn_policy = {};
12678
12679
  __export(exports_turn_policy, {
12679
12680
  untilToolCall: () => untilToolCall,
@@ -12683,7 +12684,8 @@ __export(exports_turn_policy, {
12683
12684
  decision: () => decision,
12684
12685
  both: () => both
12685
12686
  });
12686
- import { Effect as Effect52 } from "effect";
12687
+ import { Effect as Effect52, Layer as Layer49 } from "effect";
12688
+ import { LanguageModel as LanguageModel4, Prompt as Prompt7, Response as Response5 } from "effect/unstable/ai";
12687
12689
  var decision = {
12688
12690
  continue: (overrides) => ({
12689
12691
  _tag: "Continue",
@@ -12721,7 +12723,7 @@ var both = (first, second) => ({
12721
12723
  });
12722
12724
  var defaultPolicy = recurs(8);
12723
12725
 
12724
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/agent.ts
12726
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/agent.js
12725
12727
  var exports_agent = {};
12726
12728
  __export(exports_agent, {
12727
12729
  streamObject: () => streamObject,
@@ -12732,13 +12734,13 @@ __export(exports_agent, {
12732
12734
  defaultObjectPrompt: () => defaultObjectPrompt
12733
12735
  });
12734
12736
  import { Cause as Cause3, Effect as Effect53, Fiber, Option as Option18, Queue as Queue2, Ref as Ref14, Schema as Schema62, Stream as Stream9 } from "effect";
12735
- import { Chat, LanguageModel as LanguageModel4, Prompt as Prompt4, Response as Response3, Telemetry, Tokenizer as Tokenizer2, Tool as Tool3, Toolkit as Toolkit3 } from "effect/unstable/ai";
12737
+ import { Chat, LanguageModel as LanguageModel5, Prompt as Prompt8, Response as Response6, Telemetry, Tokenizer as Tokenizer2, Tool as Tool5, Toolkit as Toolkit4 } from "effect/unstable/ai";
12736
12738
  function make5(nameOrOptions, options = {}) {
12737
12739
  const resolved = typeof nameOrOptions === "string" ? { ...options, name: nameOrOptions } : nameOrOptions;
12738
12740
  return {
12739
12741
  name: resolved.name,
12740
12742
  ...resolved.instructions === undefined ? {} : { instructions: resolved.instructions },
12741
- toolkit: resolved.toolkit ?? Toolkit3.empty,
12743
+ toolkit: resolved.toolkit ?? Toolkit4.empty,
12742
12744
  policy: resolved.policy ?? defaultPolicy,
12743
12745
  ...resolved.model === undefined ? {} : { model: resolved.model },
12744
12746
  ...resolved.memory === undefined ? {} : { memory: resolved.memory },
@@ -12755,7 +12757,7 @@ var steeringDrainedEvent = (turn, queue, messages) => ({
12755
12757
  var skillListingBudgetTokens = 2048;
12756
12758
  var activateSkillToolName = "activate_skill";
12757
12759
  var activateSkillParameters = Schema62.Struct({ name: Schema62.String });
12758
- var activateSkillTool = Tool3.make(activateSkillToolName, {
12760
+ var activateSkillTool = Tool5.make(activateSkillToolName, {
12759
12761
  description: "Load the full body for one listed Baton skill by name before applying that skill.",
12760
12762
  parameters: activateSkillParameters,
12761
12763
  success: Schema62.Struct({
@@ -12774,7 +12776,7 @@ var appendInstructionFragment = (base2, fragment) => {
12774
12776
 
12775
12777
  ${fragment}`;
12776
12778
  };
12777
- var successResult = (call, outcome) => Response3.toolResultPart({
12779
+ var successResult = (call, outcome) => Response6.toolResultPart({
12778
12780
  id: call.id,
12779
12781
  name: call.name,
12780
12782
  isFailure: false,
@@ -12783,7 +12785,7 @@ var successResult = (call, outcome) => Response3.toolResultPart({
12783
12785
  providerExecuted: false,
12784
12786
  preliminary: false
12785
12787
  });
12786
- var failedResult = (call, message) => Response3.toolResultPart({
12788
+ var failedResult = (call, message) => Response6.toolResultPart({
12787
12789
  id: call.id,
12788
12790
  name: call.name,
12789
12791
  isFailure: true,
@@ -12799,7 +12801,7 @@ var suspended = (call, token, reason) => new AgentSuspended({
12799
12801
  tool_name: call.name,
12800
12802
  tool_params: call.params
12801
12803
  });
12802
- var withSystem = (instructions, prompt) => Prompt4.fromMessages([Prompt4.makeMessage("system", { content: instructions }), ...prompt.content]);
12804
+ var withSystem = (instructions, prompt) => Prompt8.fromMessages([Prompt8.makeMessage("system", { content: instructions }), ...prompt.content]);
12803
12805
  var skillListingsInstructions = (listings) => `Available skills:
12804
12806
  ${listings}
12805
12807
 
@@ -12909,10 +12911,10 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
12909
12911
  onSome: (service) => service.getOrCreate(persistenceOptions.chatId, persistenceOptions.timeToLive === undefined ? undefined : { timeToLive: persistenceOptions.timeToLive }).pipe(Effect53.mapError((error5) => new AgentError({ message: errorMessage(error5), turn: 0, cause: error5 })))
12910
12912
  });
12911
12913
  const seedSystem = persisted !== undefined && system !== undefined && (yield* Ref14.get(persisted.history)).content.length === 0 ? system : undefined;
12912
- const freshChat = options.history !== undefined ? Chat.fromPrompt(options.history) : system !== undefined ? Chat.fromPrompt([Prompt4.makeMessage("system", { content: system })]) : Chat.empty;
12914
+ const freshChat = options.history !== undefined ? Chat.fromPrompt(options.history) : system !== undefined ? Chat.fromPrompt([Prompt8.makeMessage("system", { content: system })]) : Chat.empty;
12913
12915
  const chat = persisted ?? (yield* freshChat);
12914
12916
  const savePersisted = persisted === undefined ? Effect53.void : persisted.save.pipe(Effect53.mapError((error5) => new AgentError({ message: errorMessage(error5), turn: 0, cause: error5 })));
12915
- const failSuspended = (call, token, reason) => Stream9.unwrap(savePersisted.pipe(Effect53.as(Stream9.fail(suspended(call, token, reason)))));
12917
+ const failSuspended = (call, token, reason) => Stream9.fail(suspended(call, token, reason));
12916
12918
  const state = {
12917
12919
  text: "",
12918
12920
  turn: 0,
@@ -12945,9 +12947,9 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
12945
12947
  }
12946
12948
  userParts.push(part);
12947
12949
  }
12948
- const memoryMessage2 = Prompt4.makeMessage("user", { content: userParts });
12950
+ const memoryMessage2 = Prompt8.makeMessage("user", { content: userParts });
12949
12951
  const [first, ...rest] = prompt.content;
12950
- return first?.role === "system" ? Prompt4.fromMessages([first, memoryMessage2, ...rest]) : Prompt4.fromMessages([memoryMessage2, ...prompt.content]);
12952
+ return first?.role === "system" ? Prompt8.fromMessages([first, memoryMessage2, ...rest]) : Prompt8.fromMessages([memoryMessage2, ...prompt.content]);
12951
12953
  });
12952
12954
  const recallInitialPrompt = (prompt) => memoryRuntime === undefined ? Effect53.succeed(prompt) : memoryRuntime.service.recall({ key: memoryRuntime.key, turn: 0, prompt }).pipe(Effect53.mapError((error5) => memoryError(0, error5)), Effect53.flatMap((items) => insertRecalledItems(0, prompt, items)));
12953
12955
  const rememberTurn = (turn, transcript, terminal2) => memoryRuntime === undefined ? Effect53.void : memoryRuntime.service.remember({ key: memoryRuntime.key, turn, transcript, terminal: terminal2 }).pipe(Effect53.mapError((error5) => memoryError(turn, error5)));
@@ -12977,7 +12979,7 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
12977
12979
  onSome: (tokenizer) => tokenizer.tokenize(prompt).pipe(Effect53.map((tokens) => tokens.length), Effect53.mapError((error5) => new AgentError({ message: errorMessage(error5), turn, cause: error5 })))
12978
12980
  });
12979
12981
  };
12980
- const compactionUsage = (turn, history, prompt) => countTokens(turn, Prompt4.concat(history, prompt)).pipe(Effect53.map((contextTokens) => ({
12982
+ const compactionUsage = (turn, history, prompt) => countTokens(turn, Prompt8.concat(history, prompt)).pipe(Effect53.map((contextTokens) => ({
12981
12983
  contextTokens,
12982
12984
  contextWindow: options.compaction?.contextWindow ?? Number.POSITIVE_INFINITY,
12983
12985
  reserveTokens: DEFAULT_RESERVE_TOKENS
@@ -13038,7 +13040,7 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13038
13040
  return executeToolkit(agent.toolkit, request);
13039
13041
  }
13040
13042
  const activated = activatedSkillTools.get(request.call.name);
13041
- return activated === undefined ? Effect53.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(Toolkit3.make(activated), request);
13043
+ return activated === undefined ? Effect53.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(Toolkit4.make(activated), request);
13042
13044
  };
13043
13045
  const executeApproved = (turn, call, request) => Stream9.concat(Stream9.fromIterable([{ _tag: "ToolExecutionStarted", turn, call }]), Stream9.unwrap(Effect53.gen(function* () {
13044
13046
  const progressQueue = yield* Queue2.unbounded();
@@ -13201,7 +13203,7 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13201
13203
  });
13202
13204
  const withModelResilience = (effect) => Option18.match(resilienceService, {
13203
13205
  onNone: () => effect,
13204
- onSome: (resilience) => Effect53.flatMap(LanguageModel4.LanguageModel, (model) => effect.pipe(Effect53.provideService(LanguageModel4.LanguageModel, apply(model, resilience))))
13206
+ onSome: (resilience) => Effect53.flatMap(LanguageModel5.LanguageModel, (model) => effect.pipe(Effect53.provideService(LanguageModel5.LanguageModel, apply(model, resilience))))
13205
13207
  });
13206
13208
  const withAgentModel = (effect) => agentModelContext === undefined ? effect : effect.pipe(Effect53.provide(agentModelContext));
13207
13209
  const provideAgentModel = (stream2) => agentModelContext === undefined ? stream2 : stream2.pipe(Stream9.provideContext(agentModelContext));
@@ -13229,13 +13231,13 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13229
13231
  detail: "ModelMiddleware dropped a tool-call part"
13230
13232
  })) : Stream9.empty
13231
13233
  }))));
13232
- const currentToolkit = () => Toolkit3.make(...Object.values(agent.toolkit.tools), ...hasActivatableSkills ? [activateSkillTool] : [], ...activatedSkillTools.values());
13233
- const activeToolkit = (activeTools) => Toolkit3.make(...Object.values(currentToolkit().tools).filter((tool2) => activeTools.includes(tool2.name)));
13234
+ const currentToolkit = () => Toolkit4.make(...Object.values(agent.toolkit.tools), ...hasActivatableSkills ? [activateSkillTool] : [], ...activatedSkillTools.values());
13235
+ const activeToolkit = (activeTools) => Toolkit4.make(...Object.values(currentToolkit().tools).filter((tool2) => activeTools.includes(tool2.name)));
13234
13236
  const modelTurn = (turn, prompt, overrides) => {
13235
13237
  const toolkit = overrides?.activeTools === undefined ? currentToolkit() : activeToolkit(overrides.activeTools);
13236
13238
  const attempt = (activePrompt, retryOverflow) => Stream9.unwrap(Ref14.get(chat.history).pipe(Effect53.map((historyBeforeAttempt) => {
13237
13239
  let emitted = false;
13238
- const messages = Prompt4.concat(historyBeforeAttempt, activePrompt).content;
13240
+ const messages = Prompt8.concat(historyBeforeAttempt, activePrompt).content;
13239
13241
  return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(Stream9.map((part) => ({ part, messages })), Stream9.tap(() => Effect53.sync(() => {
13240
13242
  emitted = true;
13241
13243
  })), Stream9.catchCause((cause) => {
@@ -13249,13 +13251,13 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13249
13251
  return attempt(compactedPrompt, false);
13250
13252
  }));
13251
13253
  }
13252
- return Stream9.make({ part: Response3.makePart("error", { error: error5 }), messages });
13254
+ return Stream9.make({ part: Response6.makePart("error", { error: error5 }), messages });
13253
13255
  }));
13254
13256
  })));
13255
- const parts = Stream9.unwrap(applyPromptChain(chain, Prompt4.make(prompt), { agentName: agent.name, turn }).pipe(Effect53.flatMap((transformedPrompt) => preparePrompt(turn, transformedPrompt, false)), Effect53.map((preparedPrompt) => attempt(preparedPrompt, true).pipe(Stream9.flatMap(({ part, messages }) => applyPartToEvents(turn, part, messages))))));
13257
+ const parts = Stream9.unwrap(applyPromptChain(chain, Prompt8.make(prompt), { agentName: agent.name, turn }).pipe(Effect53.flatMap((transformedPrompt) => preparePrompt(turn, transformedPrompt, false)), Effect53.map((preparedPrompt) => attempt(preparedPrompt, true).pipe(Stream9.flatMap(({ part, messages }) => applyPartToEvents(turn, part, messages))))));
13256
13258
  const resilientParts = Option18.match(resilienceService, {
13257
13259
  onNone: () => parts,
13258
- onSome: (resilience) => Stream9.unwrap(LanguageModel4.LanguageModel.pipe(Effect53.map((model) => parts.pipe(Stream9.provideService(LanguageModel4.LanguageModel, apply(model, resilience))))))
13260
+ onSome: (resilience) => Stream9.unwrap(LanguageModel5.LanguageModel.pipe(Effect53.map((model) => parts.pipe(Stream9.provideService(LanguageModel5.LanguageModel, apply(model, resilience))))))
13259
13261
  });
13260
13262
  return overrides?.model === undefined ? provideAgentModel(resilientParts) : resilientParts.pipe(Stream9.provide(overrides.model));
13261
13263
  };
@@ -13274,7 +13276,7 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13274
13276
  });
13275
13277
  const structuredFinalEvents = (turn, config) => Stream9.fromEffect(Effect53.gen(function* () {
13276
13278
  const structuredTurn = turn + 1;
13277
- const transformedPrompt = yield* applyPromptChain(chain, Prompt4.make(config.objectPrompt), {
13279
+ const transformedPrompt = yield* applyPromptChain(chain, Prompt8.make(config.objectPrompt), {
13278
13280
  agentName: agent.name,
13279
13281
  turn: structuredTurn
13280
13282
  });
@@ -13295,7 +13297,7 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13295
13297
  };
13296
13298
  return [structuredOutput, terminalCompletedEvent(structuredTurn, transcript)];
13297
13299
  })).pipe(Stream9.flatMap((events) => Stream9.fromIterable(events)));
13298
- const promptFromSteeringMessages = (messages) => messages.reduce((prompt, message) => Prompt4.concat(prompt, message.prompt), Prompt4.empty);
13300
+ const promptFromSteeringMessages = (messages) => messages.reduce((prompt, message) => Prompt8.concat(prompt, message.prompt), Prompt8.empty);
13299
13301
  const takeSteering = () => Option18.match(steeringService, {
13300
13302
  onNone: () => Effect53.succeed([]),
13301
13303
  onSome: (service) => service.takeSteering()
@@ -13346,8 +13348,8 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13346
13348
  }
13347
13349
  state.pending = [];
13348
13350
  const steering = yield* takeSteering();
13349
- const toolPrompt = Prompt4.fromResponseParts(pending);
13350
- const basePrompt = steering.length === 0 ? toolPrompt : Prompt4.concat(promptFromSteeringMessages(steering), toolPrompt);
13351
+ const toolPrompt = Prompt8.fromResponseParts(pending);
13352
+ const basePrompt = steering.length === 0 ? toolPrompt : Prompt8.concat(promptFromSteeringMessages(steering), toolPrompt);
13351
13353
  const prompt = decision2.overrides?.instructions === undefined ? basePrompt : withSystem(decision2.overrides.instructions, basePrompt);
13352
13354
  return {
13353
13355
  events: Stream9.fromIterable(steering.length === 0 ? [completed] : [completed, steeringDrainedEvent(turn, "steering", steering)]),
@@ -13368,7 +13370,7 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13368
13370
  };
13369
13371
  const resumeStream = (resume) => {
13370
13372
  let next;
13371
- const call = Response3.makePart("tool-call", {
13373
+ const call = Response6.makePart("tool-call", {
13372
13374
  id: resume.call.id,
13373
13375
  name: resume.call.name,
13374
13376
  params: resume.call.params,
@@ -13380,7 +13382,7 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13380
13382
  })))), Stream9.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": 0 } }));
13381
13383
  return Stream9.concat(currentTurn, Stream9.suspend(() => next === undefined ? Stream9.empty : runTurn(1, next.prompt, next.overrides)));
13382
13384
  };
13383
- const baseInitialPrompt = seedSystem === undefined ? Prompt4.make(options.prompt) : withSystem(seedSystem, Prompt4.make(options.prompt));
13385
+ const baseInitialPrompt = seedSystem === undefined ? Prompt8.make(options.prompt) : withSystem(seedSystem, Prompt8.make(options.prompt));
13384
13386
  const initialPrompt = options.resume === undefined ? yield* recallInitialPrompt(baseInitialPrompt) : baseInitialPrompt;
13385
13387
  const runStream = options.resume === undefined ? runTurn(0, initialPrompt) : resumeStream(options.resume);
13386
13388
  return runStream.pipe(Stream9.catchCause((cause) => {
@@ -13388,7 +13390,13 @@ var streamInternal = (agent, options, structured) => Stream9.unwrap(Effect53.gen
13388
13390
  return Stream9.fromEffect(Effect53.interrupt);
13389
13391
  const error5 = Cause3.squash(cause);
13390
13392
  if (error5 instanceof AgentSuspended) {
13391
- return Stream9.unwrap(Ref14.get(chat.history).pipe(Effect53.map((transcript) => Stream9.concat(Stream9.fromIterable([turnCompletedEvent(state.turn, transcript)]), Stream9.failCause(cause)))));
13393
+ return Stream9.unwrap(Effect53.gen(function* () {
13394
+ const transcript = yield* Ref14.get(chat.history);
13395
+ const checkpoint = state.pending.length === 0 ? transcript : Prompt8.concat(transcript, Prompt8.fromResponseParts(state.pending));
13396
+ yield* Ref14.set(chat.history, checkpoint);
13397
+ yield* savePersisted;
13398
+ return Stream9.concat(Stream9.fromIterable([turnCompletedEvent(state.turn, checkpoint)]), Stream9.failCause(cause));
13399
+ }));
13392
13400
  }
13393
13401
  return Stream9.failCause(cause);
13394
13402
  }));
@@ -13430,13 +13438,13 @@ var generateObject = (agent, options) => Stream9.runFold(streamObject(agent, opt
13430
13438
  })
13431
13439
  })));
13432
13440
 
13433
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/agent-tool.ts
13441
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/agent-tool.js
13434
13442
  var exports_agent_tool = {};
13435
13443
  __export(exports_agent_tool, {
13436
13444
  asTool: () => asTool
13437
13445
  });
13438
13446
  import { Cause as Cause4, Effect as Effect54, Schema as Schema63 } from "effect";
13439
- import { Tool as Tool4, Toolkit as Toolkit4 } from "effect/unstable/ai";
13447
+ import { Prompt as Prompt9, Tool as Tool6, Toolkit as Toolkit5 } from "effect/unstable/ai";
13440
13448
  var defaultParameters = Schema63.Struct({ prompt: Schema63.String });
13441
13449
  var errorMessage2 = (error5) => {
13442
13450
  if (error5 instanceof AgentSuspended) {
@@ -13466,14 +13474,14 @@ var asTool = (agent, options = {}) => {
13466
13474
  const success2 = options.success ?? Schema63.String;
13467
13475
  const toPrompt = options.toPrompt ?? ((params) => params.prompt);
13468
13476
  const fromResult = options.fromResult ?? ((result) => result.text);
13469
- const tool2 = Tool4.make(name, {
13477
+ const tool2 = Tool6.make(name, {
13470
13478
  ...options.description === undefined ? {} : { description: options.description },
13471
13479
  parameters,
13472
13480
  success: success2,
13473
13481
  failure: Schema63.String,
13474
13482
  failureMode: "return"
13475
13483
  });
13476
- const toolkit = Toolkit4.make(tool2);
13484
+ const toolkit = Toolkit5.make(tool2);
13477
13485
  const handler = (params) => Effect54.gen(function* () {
13478
13486
  const prompt = yield* Effect54.try({ try: () => toPrompt(params), catch: errorMessage2 });
13479
13487
  const result = yield* generate(agent, { prompt }).pipe(Effect54.catchCause((cause) => {
@@ -13486,7 +13494,7 @@ var asTool = (agent, options = {}) => {
13486
13494
  return lazyHandled(toolkit, name, handler);
13487
13495
  };
13488
13496
 
13489
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/guardrail.ts
13497
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/guardrail.js
13490
13498
  var exports_guardrail = {};
13491
13499
  __export(exports_guardrail, {
13492
13500
  validateInput: () => validateInput2,
@@ -13495,16 +13503,16 @@ __export(exports_guardrail, {
13495
13503
  filterOutput: () => filterOutput
13496
13504
  });
13497
13505
  import { Effect as Effect55, Option as Option19 } from "effect";
13498
- import { Prompt as Prompt6, Response as Response4 } from "effect/unstable/ai";
13506
+ import { Prompt as Prompt10, Response as Response7 } from "effect/unstable/ai";
13499
13507
  var replacement = (options) => options.replacement ?? "[redacted]";
13500
13508
  var redactText = (text2, options) => text2.replace(options.pattern, replacement(options));
13501
- var redactUserPart = (part, options) => part.type === "text" ? Prompt6.makePart("text", { text: redactText(part.text, options), options: part.options }) : part;
13509
+ var redactUserPart = (part, options) => part.type === "text" ? Prompt10.makePart("text", { text: redactText(part.text, options), options: part.options }) : part;
13502
13510
  var redactAssistantPart = (part, options) => {
13503
13511
  switch (part.type) {
13504
13512
  case "text":
13505
- return Prompt6.makePart("text", { text: redactText(part.text, options), options: part.options });
13513
+ return Prompt10.makePart("text", { text: redactText(part.text, options), options: part.options });
13506
13514
  case "reasoning":
13507
- return Prompt6.makePart("reasoning", { text: redactText(part.text, options), options: part.options });
13515
+ return Prompt10.makePart("reasoning", { text: redactText(part.text, options), options: part.options });
13508
13516
  default:
13509
13517
  return part;
13510
13518
  }
@@ -13512,32 +13520,32 @@ var redactAssistantPart = (part, options) => {
13512
13520
  var redactToolPart = (part, options) => {
13513
13521
  if (part.type !== "tool-approval-response" || part.reason === undefined)
13514
13522
  return part;
13515
- return Prompt6.makePart("tool-approval-response", {
13523
+ return Prompt10.makePart("tool-approval-response", {
13516
13524
  approvalId: part.approvalId,
13517
13525
  approved: part.approved,
13518
13526
  reason: redactText(part.reason, options),
13519
13527
  options: part.options
13520
13528
  });
13521
13529
  };
13522
- var redactPromptText = (prompt, options) => Prompt6.fromMessages(prompt.content.map((message) => {
13530
+ var redactPromptText = (prompt, options) => Prompt10.fromMessages(prompt.content.map((message) => {
13523
13531
  switch (message.role) {
13524
13532
  case "system":
13525
- return Prompt6.makeMessage("system", {
13533
+ return Prompt10.makeMessage("system", {
13526
13534
  content: redactText(message.content, options),
13527
13535
  options: message.options
13528
13536
  });
13529
13537
  case "user":
13530
- return Prompt6.makeMessage("user", {
13538
+ return Prompt10.makeMessage("user", {
13531
13539
  content: message.content.map((part) => redactUserPart(part, options)),
13532
13540
  options: message.options
13533
13541
  });
13534
13542
  case "assistant":
13535
- return Prompt6.makeMessage("assistant", {
13543
+ return Prompt10.makeMessage("assistant", {
13536
13544
  content: message.content.map((part) => redactAssistantPart(part, options)),
13537
13545
  options: message.options
13538
13546
  });
13539
13547
  case "tool":
13540
- return Prompt6.makeMessage("tool", {
13548
+ return Prompt10.makeMessage("tool", {
13541
13549
  content: message.content.map((part) => redactToolPart(part, options)),
13542
13550
  options: message.options
13543
13551
  });
@@ -13556,7 +13564,7 @@ var redactOutput = (options) => ({
13556
13564
  transformPart: (part) => {
13557
13565
  if (part.type !== "text-delta")
13558
13566
  return Effect55.succeed(Option19.some(part));
13559
- return Effect55.succeed(Option19.some(Response4.makePart("text-delta", {
13567
+ return Effect55.succeed(Option19.some(Response7.makePart("text-delta", {
13560
13568
  id: part.id,
13561
13569
  delta: redactText(part.delta, options),
13562
13570
  metadata: part.metadata
@@ -13567,7 +13575,7 @@ var filterOutput = (keep) => ({
13567
13575
  transformPart: (part, context) => Effect55.succeed(part.type === "tool-call" || keep(part, context) ? Option19.some(part) : Option19.none())
13568
13576
  });
13569
13577
 
13570
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/handoff.ts
13578
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/handoff.js
13571
13579
  var exports_handoff = {};
13572
13580
  __export(exports_handoff, {
13573
13581
  transferTool: () => transferTool,
@@ -13575,7 +13583,7 @@ __export(exports_handoff, {
13575
13583
  fanOut: () => fanOut
13576
13584
  });
13577
13585
  import { Effect as Effect56, Schema as Schema64 } from "effect";
13578
- import { AiError as AiError2, Toolkit as Toolkit5 } from "effect/unstable/ai";
13586
+ import { AiError as AiError2, Prompt as Prompt11, Tool as Tool7, Toolkit as Toolkit6 } from "effect/unstable/ai";
13579
13587
  var defaultTransferParameters = Schema64.Struct({ prompt: Schema64.String });
13580
13588
  var transferName = (agentName) => `transfer_to_${agentName}`;
13581
13589
  var positiveConcurrency = (value) => {
@@ -13605,7 +13613,7 @@ var mergeHandled = (toolkits) => {
13605
13613
  }
13606
13614
  };
13607
13615
  };
13608
- var toolkitFromHandled = (toolkit) => Toolkit5.make(...Object.values(toolkit.tools));
13616
+ var toolkitFromHandled = (toolkit) => Toolkit6.make(...Object.values(toolkit.tools));
13609
13617
  var transferTool = (target, options = {}) => asTool(target, {
13610
13618
  name: options.nameOverride ?? transferName(target.name),
13611
13619
  description: options.description ?? `Transfer to ${target.name}`,
@@ -13631,22 +13639,8 @@ var supervisor = (options) => {
13631
13639
  };
13632
13640
  };
13633
13641
 
13634
- // ../../node_modules/.bun/@batonfx+core@0.4.0/node_modules/@batonfx/core/src/index.ts
13635
- import {
13636
- AiError as AiError3,
13637
- Chat as Chat2,
13638
- EmbeddingModel,
13639
- IdGenerator,
13640
- LanguageModel as LanguageModel5,
13641
- Model as Model2,
13642
- Prompt as Prompt8,
13643
- Response as Response5,
13644
- ResponseIdTracker,
13645
- Telemetry as Telemetry2,
13646
- Tokenizer as Tokenizer3,
13647
- Tool as Tool6,
13648
- Toolkit as Toolkit6
13649
- } from "effect/unstable/ai";
13642
+ // ../../node_modules/.bun/@batonfx+core@0.4.2/node_modules/@batonfx/core/dist/index.js
13643
+ import { AiError as AiError3, Chat as Chat2, EmbeddingModel, IdGenerator, LanguageModel as LanguageModel6, Model as Model2, Prompt as Prompt12, Response as Response8, ResponseIdTracker, Telemetry as Telemetry2, Tokenizer as Tokenizer3, Tool as Tool8, Toolkit as Toolkit7 } from "effect/unstable/ai";
13650
13644
 
13651
13645
  // ../runtime/src/child/child-run-service.ts
13652
13646
  var exports_child_run_service = {};
@@ -14870,7 +14864,7 @@ __export(exports_agent_loop_service, {
14870
14864
  AgentLoopBudgetExceeded: () => AgentLoopBudgetExceeded
14871
14865
  });
14872
14866
  import { Config as Config4, Context as Context67, Crypto as Crypto3, Effect as Effect87, HashSet as HashSet6, Layer as Layer73, Option as Option25, Ref as Ref21, Schema as Schema89, Stream as Stream12 } from "effect";
14873
- import { Chat as Chat3, LanguageModel as LanguageModel6, Prompt as Prompt12, Tokenizer as Tokenizer4, Toolkit as Toolkit7 } from "effect/unstable/ai";
14867
+ import { Chat as Chat3, LanguageModel as LanguageModel7, Prompt as Prompt16, Tokenizer as Tokenizer4, Toolkit as Toolkit8 } from "effect/unstable/ai";
14874
14868
 
14875
14869
  // ../runtime/src/child/spawn-child-run-tool.ts
14876
14870
  import { Effect as Effect66, Schema as Schema73 } from "effect";
@@ -15103,7 +15097,7 @@ var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target
15103
15097
 
15104
15098
  // ../runtime/src/memory/memory-service.ts
15105
15099
  import { Clock as Clock8, Context as Context59, Effect as Effect68, Layer as Layer60, Schema as Schema75 } from "effect";
15106
- import { EmbeddingModel as EmbeddingModel3, Prompt as Prompt9 } from "effect/unstable/ai";
15100
+ import { EmbeddingModel as EmbeddingModel3, Prompt as Prompt13 } from "effect/unstable/ai";
15107
15101
 
15108
15102
  // ../runtime/src/model/embedding-model-service.ts
15109
15103
  import { Context as Context58, Effect as Effect67, Layer as Layer59, Ref as Ref18, Schema as Schema74 } from "effect";
@@ -15239,7 +15233,7 @@ var memoryError = (error5) => new exports_memory.MemoryError({
15239
15233
  message: error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5)
15240
15234
  });
15241
15235
  var decodeSubject = (subject) => Schema75.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect68.mapError(memoryError));
15242
- var textPart = (text2) => Prompt9.makePart("text", { text: text2 });
15236
+ var textPart = (text2) => Prompt13.makePart("text", { text: text2 });
15243
15237
  var textFromParts = (parts) => parts.filter((part) => part.type === "text").map((part) => part.text).join(`
15244
15238
  `).trim();
15245
15239
  var latestUserText = (prompt) => {
@@ -16329,7 +16323,7 @@ __export(exports_prompt_assembler_service, {
16329
16323
  PromptAssemblerError: () => PromptAssemblerError
16330
16324
  });
16331
16325
  import { Context as Context66, Effect as Effect80, Layer as Layer67, Schema as Schema85 } from "effect";
16332
- import { Prompt as Prompt10 } from "effect/unstable/ai";
16326
+ import { Prompt as Prompt14 } from "effect/unstable/ai";
16333
16327
 
16334
16328
  // ../runtime/src/content/artifact-store-service.ts
16335
16329
  var exports_artifact_store_service = {};
@@ -16402,19 +16396,19 @@ var contentToPromptPart = (part) => {
16402
16396
  const options = part.provider_options;
16403
16397
  switch (part.type) {
16404
16398
  case "text":
16405
- return Prompt10.makePart("text", { text: part.text, ...options === undefined ? {} : { options } });
16399
+ return Prompt14.makePart("text", { text: part.text, ...options === undefined ? {} : { options } });
16406
16400
  case "structured":
16407
- return Prompt10.makePart("text", {
16401
+ return Prompt14.makePart("text", {
16408
16402
  text: stringifyJson(part.value),
16409
16403
  ...options === undefined ? {} : { options }
16410
16404
  });
16411
16405
  case "tool-call":
16412
- return Prompt10.makePart("text", {
16406
+ return Prompt14.makePart("text", {
16413
16407
  text: stringifyJson(part.call),
16414
16408
  ...options === undefined ? {} : { options }
16415
16409
  });
16416
16410
  case "tool-result":
16417
- return Prompt10.makePart("text", {
16411
+ return Prompt14.makePart("text", {
16418
16412
  text: stringifyJson(part.result),
16419
16413
  ...options === undefined ? {} : { options }
16420
16414
  });
@@ -16424,7 +16418,7 @@ var toAssemblerError = (error5) => new PromptAssemblerError({
16424
16418
  message: error5.reason !== undefined ? `${error5._tag}: ${error5.reason}` : error5.message !== undefined ? `${error5._tag}: ${error5.message}` : error5._tag
16425
16419
  });
16426
16420
  var resolveBlobPart = (blobs, part) => blobs.resolve(part).pipe(Effect80.map((resolved) => [
16427
- Prompt10.makePart("file", {
16421
+ Prompt14.makePart("file", {
16428
16422
  mediaType: resolved.mediaType,
16429
16423
  data: resolved._tag === "Bytes" ? resolved.bytes : resolved.url,
16430
16424
  ...resolved.fileName === undefined ? {} : { fileName: resolved.fileName },
@@ -16465,9 +16459,9 @@ var defaultSystem = (agent, tools) => [`Agent: ${agent.name}`, agent.instruction
16465
16459
  `);
16466
16460
  var defaultPrompt = (blobs, artifacts, input) => Effect80.forEach(input, (part) => resolveContentPart(blobs, artifacts, part), { concurrency: 1 }).pipe(Effect80.map((parts) => {
16467
16461
  const flat = parts.flat();
16468
- return Prompt10.fromMessages([
16469
- Prompt10.makeMessage("user", {
16470
- content: flat.length === 0 ? [Prompt10.makePart("text", { text: "" })] : flat
16462
+ return Prompt14.fromMessages([
16463
+ Prompt14.makeMessage("user", {
16464
+ content: flat.length === 0 ? [Prompt14.makePart("text", { text: "" })] : flat
16471
16465
  })
16472
16466
  ]);
16473
16467
  }));
@@ -16723,7 +16717,7 @@ var layer53 = (config) => Layer69.mergeAll(Layer69.succeed(exports_permissions.P
16723
16717
 
16724
16718
  // ../runtime/src/agent/relay-steering.ts
16725
16719
  import { Clock as Clock14, Effect as Effect83, Layer as Layer70, Schema as Schema87 } from "effect";
16726
- import { Prompt as Prompt11 } from "effect/unstable/ai";
16720
+ import { Prompt as Prompt15 } from "effect/unstable/ai";
16727
16721
  var jsonValue4 = (value) => Schema87.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
16728
16722
  var stringifyJson2 = (value) => JSON.stringify(jsonValue4(value));
16729
16723
  var createdAtForSequence2 = (config, sequence) => config.startedAt + sequence - config.eventSequence;
@@ -16742,22 +16736,22 @@ var purePromptPart = (part) => {
16742
16736
  };
16743
16737
  var contentToPromptPart2 = (part) => {
16744
16738
  const pure = purePromptPart(part);
16745
- return pure === undefined ? Prompt11.makePart("text", { text: stringifyJson2(part) }) : contentToPromptPart(pure);
16739
+ return pure === undefined ? Prompt15.makePart("text", { text: stringifyJson2(part) }) : contentToPromptPart(pure);
16746
16740
  };
16747
- var promptForContent = (content) => Prompt11.fromMessages([
16748
- Prompt11.makeMessage("user", {
16749
- content: content.length === 0 ? [Prompt11.makePart("text", { text: "" })] : content.map((part) => contentToPromptPart2(part))
16741
+ var promptForContent = (content) => Prompt15.fromMessages([
16742
+ Prompt15.makeMessage("user", {
16743
+ content: content.length === 0 ? [Prompt15.makePart("text", { text: "" })] : content.map((part) => contentToPromptPart2(part))
16750
16744
  })
16751
16745
  ]);
16752
16746
  var promptTextParts = (prompt) => prompt.content.flatMap((message) => typeof message.content === "string" ? [exports_content_schema.text(message.content)] : message.content.flatMap((part) => part.type === "text" ? [exports_content_schema.text(part.text)] : []));
16753
16747
  var contentFromMessage = (message) => {
16754
16748
  if (typeof message.prompt === "string")
16755
16749
  return [exports_content_schema.text(message.prompt)];
16756
- const prompt = Prompt11.make(message.prompt);
16750
+ const prompt = Prompt15.make(message.prompt);
16757
16751
  const textParts = promptTextParts(prompt);
16758
16752
  if (textParts.length > 0)
16759
16753
  return textParts;
16760
- return [exports_content_schema.text(stringifyJson2(Schema87.encodeSync(Prompt11.Prompt)(prompt)))];
16754
+ return [exports_content_schema.text(stringifyJson2(Schema87.encodeSync(Prompt15.Prompt)(prompt)))];
16761
16755
  };
16762
16756
  var steeringReceivedEvent = (config, kind, drain3, messages, sequence) => ({
16763
16757
  id: exports_ids_schema.EventId.make(`event:${drain3.drainId}:received`),
@@ -17149,7 +17143,7 @@ var toolFromDefinition = (definition) => dynamicTool(definition.name, {
17149
17143
  ...definition.metadata === undefined ? {} : { metadata: definition.metadata },
17150
17144
  run: () => Effect87.die("model-facing toolkit is not executed")
17151
17145
  }).tool;
17152
- var toolkitFromRegistered = (registered) => Toolkit7.make(...registered.map(toolFromRegistered));
17146
+ var toolkitFromRegistered = (registered) => Toolkit8.make(...registered.map(toolFromRegistered));
17153
17147
  var handlersForToolExecutor = (registered) => Object.fromEntries(registered.map((tool2) => [
17154
17148
  tool2.definition.name,
17155
17149
  () => Effect87.die(`Relay ToolExecutor must execute ${tool2.definition.name}`)
@@ -17231,9 +17225,9 @@ var terminalMemoryTranscript = (prompt, text2) => {
17231
17225
  return;
17232
17226
  if (promptHasAssistantText(prompt, text2))
17233
17227
  return prompt;
17234
- return Prompt12.fromMessages([
17228
+ return Prompt16.fromMessages([
17235
17229
  ...prompt.content,
17236
- Prompt12.makeMessage("assistant", { content: [Prompt12.makePart("text", { text: text2 })] })
17230
+ Prompt16.makeMessage("assistant", { content: [Prompt16.makePart("text", { text: text2 })] })
17237
17231
  ]);
17238
17232
  };
17239
17233
  var recallOnlyMemory = (memory) => exports_memory.Memory.of({
@@ -17505,9 +17499,9 @@ var layer57 = Layer73.effect(Service54, Effect87.gen(function* () {
17505
17499
  }
17506
17500
  });
17507
17501
  const runFold = Effect87.gen(function* () {
17508
- const base2 = yield* LanguageModel6.LanguageModel;
17502
+ const base2 = yield* LanguageModel7.LanguageModel;
17509
17503
  const sessionStore = input.sessionId !== undefined && Option25.isSome(sessionRepository) ? yield* make8(input.sessionId, input.sessionEntryScope ?? input.executionId).pipe(Effect87.provideService(exports_session_repository.Service, sessionRepository.value)) : undefined;
17510
- const folded = exports_agent.stream(agent, batonOptions).pipe(Stream12.runFoldEffect(() => ({ text: "", transcript: undefined, turn: undefined, tokensUsed: seededTokens }), foldEvent), Effect87.provideService(LanguageModel6.LanguageModel, base2), Effect87.provideService(exports_model_resilience.ModelResilience, policy), Effect87.provide(executorLayer), Effect87.provide(handlerLayer), Effect87.provide(layer52), Effect87.provide(exports_model_middleware.identityLayer), Effect87.provide(instructionsLayer), Effect87.provide(permissionsLayer), Effect87.provide(steeringLayer));
17504
+ const folded = exports_agent.stream(agent, batonOptions).pipe(Stream12.runFoldEffect(() => ({ text: "", transcript: undefined, turn: undefined, tokensUsed: seededTokens }), foldEvent), Effect87.provideService(LanguageModel7.LanguageModel, base2), Effect87.provideService(exports_model_resilience.ModelResilience, policy), Effect87.provide(executorLayer), Effect87.provide(handlerLayer), Effect87.provide(layer52), Effect87.provide(exports_model_middleware.identityLayer), Effect87.provide(instructionsLayer), Effect87.provide(permissionsLayer), Effect87.provide(steeringLayer));
17511
17505
  const withToolOutput = toolOutputStore === undefined ? folded : folded.pipe(Effect87.provideService(exports_tool_output.ToolOutputStore, toolOutputStore));
17512
17506
  const withCompaction = compactionService === undefined ? withToolOutput : withToolOutput.pipe(Effect87.provideService(exports_compaction.Compaction, compactionService));
17513
17507
  const withSession = sessionStore === undefined ? withCompaction : withCompaction.pipe(Effect87.provideService(exports_session.SessionStore, sessionStore));
@@ -19214,7 +19208,7 @@ import { FetchHttpClient } from "effect/unstable/http";
19214
19208
  import { SqlClient as SqlClient30 } from "effect/unstable/sql/SqlClient";
19215
19209
  import { RpcSerialization } from "effect/unstable/rpc";
19216
19210
  import { WorkflowEngine } from "effect/unstable/workflow";
19217
- import { LanguageModel as LanguageModel7 } from "effect/unstable/ai";
19211
+ import { LanguageModel as LanguageModel8 } from "effect/unstable/ai";
19218
19212
 
19219
19213
  // ../runtime/src/execution/execution-watch-service.ts
19220
19214
  var exports_execution_watch_service = {};
@@ -19747,7 +19741,7 @@ var sqlClientCheckLayer = Layer87.effect(Service67, Effect101.gen(function* () {
19747
19741
  const checkDatabase = yield* databaseHealthCheck;
19748
19742
  return yield* makeClientService(dialect2, checkDatabase);
19749
19743
  }));
19750
- var deterministicTestModelLayer = Layer87.effect(LanguageModel7.LanguageModel, LanguageModel7.make({
19744
+ var deterministicTestModelLayer = Layer87.effect(LanguageModel8.LanguageModel, LanguageModel8.make({
19751
19745
  generateText: () => Effect101.succeed([{ type: "text", text: "deterministic test response" }]),
19752
19746
  streamText: () => Stream15.make({ type: "text-delta", id: "text", delta: "deterministic test response" })
19753
19747
  }));
@@ -20625,4 +20619,4 @@ var recoverAll = Effect104.fn("ChildFanOutAdmissionService.recoverAll.call")(fun
20625
20619
  const service = yield* Service69;
20626
20620
  return yield* service.recoverAll(inputFor);
20627
20621
  });
20628
- export { __export, exports_ids_schema, exports_shared_schema, exports_address_schema, exports_tool_schema, exports_agent_schema, exports_content_schema, exports_execution_schema, exports_child_orchestration_schema, exports_envelope_schema, exports_inbox_schema, exports_entity_schema, exports_presence_schema, exports_schedule_schema, exports_skill_schema, exports_state_schema, exports_wait_schema, exports_workflow_schema, Dialect, dialect, fromDbTimestamp, fromNullableDbTimestamp, timestampParam, encodeJson, decodeJson, decodeBool, exports_child_execution_repository, exports_child_fan_out_repository, exports_cluster_registry_repository, exports_envelope_repository, exports_notification_bus, exports_execution_event_repository, exports_execution_repository, exports_inbox_repository, exports_schedule_repository, exports_session_repository, exports_skill_definition_repository, exports_steering_repository, exports_tool_call_repository, exports_workflow_definition_repository, exports_address_book_service, exports_event_log_service, exports_wait_service, exports_tool_runtime_service, exports_agent_registry_service, exports_address_resolution_service, exports_agent_event, exports_approvals, exports_session, exports_tool_output, exports_compaction, exports_instructions, exports_memory, exports_model_middleware, exports_model_registry, exports_model_resilience, exports_permissions, exports_skill_source, exports_steering, exports_tool_context, exports_tool_executor, exports_turn_policy, exports_agent, exports_agent_tool, exports_guardrail, exports_handoff, AiError3 as AiError, Chat2 as Chat, EmbeddingModel, IdGenerator, LanguageModel5 as LanguageModel, Model2 as Model, Prompt8 as Prompt, Response5 as Response, ResponseIdTracker, Telemetry2 as Telemetry, Tokenizer3 as Tokenizer, Tool6 as Tool, Toolkit6 as Toolkit, exports_child_run_service, exports_language_model_service, exports_model_call_policy, exports_presence_service, exports_presence_tool, exports_schema_registry_service, exports_blob_store_service, exports_execution_state_service, exports_skill_registry_service, exports_execution_service, exports_tool_transition_coordinator, exports_execution_workflow, exports_wait_signal, exports_topic_service, exports_envelope_service, exports_artifact_store_service, exports_prompt_assembler_service, exports_agent_loop_service, exports_child_fan_out_transition_service, exports_child_fan_out_runtime, exports_execution_entity, exports_entity_registry_service, exports_entity_instance_service, exports_execution_watch_service, exports_session_stream_service, exports_scheduler_service, exports_runner_runtime_service, exports_definition_runtime, exports_activity_version_registry };
20622
+ export { __export, exports_ids_schema, exports_shared_schema, exports_address_schema, exports_tool_schema, exports_agent_schema, exports_content_schema, exports_execution_schema, exports_child_orchestration_schema, exports_envelope_schema, exports_inbox_schema, exports_entity_schema, exports_presence_schema, exports_schedule_schema, exports_skill_schema, exports_state_schema, exports_wait_schema, exports_workflow_schema, Dialect, dialect, fromDbTimestamp, fromNullableDbTimestamp, timestampParam, encodeJson, decodeJson, decodeBool, exports_child_execution_repository, exports_child_fan_out_repository, exports_cluster_registry_repository, exports_envelope_repository, exports_notification_bus, exports_execution_event_repository, exports_execution_repository, exports_inbox_repository, exports_schedule_repository, exports_session_repository, exports_skill_definition_repository, exports_steering_repository, exports_tool_call_repository, exports_workflow_definition_repository, exports_address_book_service, exports_event_log_service, exports_wait_service, exports_tool_runtime_service, exports_agent_registry_service, exports_address_resolution_service, exports_agent_event, exports_tool_context, exports_tool_executor, exports_approvals, exports_session, exports_tool_output, exports_compaction, exports_instructions, exports_memory, exports_model_middleware, exports_model_registry, exports_model_resilience, exports_permissions, exports_skill_source, exports_steering, exports_turn_policy, exports_agent, exports_agent_tool, exports_guardrail, exports_handoff, AiError3 as AiError, Chat2 as Chat, EmbeddingModel, IdGenerator, LanguageModel6 as LanguageModel, Model2 as Model, Prompt12 as Prompt, Response8 as Response, ResponseIdTracker, Telemetry2 as Telemetry, Tokenizer3 as Tokenizer, Tool8 as Tool, Toolkit7 as Toolkit, exports_child_run_service, exports_language_model_service, exports_model_call_policy, exports_presence_service, exports_presence_tool, exports_schema_registry_service, exports_blob_store_service, exports_execution_state_service, exports_skill_registry_service, exports_execution_service, exports_tool_transition_coordinator, exports_execution_workflow, exports_wait_signal, exports_topic_service, exports_envelope_service, exports_artifact_store_service, exports_prompt_assembler_service, exports_agent_loop_service, exports_child_fan_out_transition_service, exports_child_fan_out_runtime, exports_execution_entity, exports_entity_registry_service, exports_entity_instance_service, exports_execution_watch_service, exports_session_stream_service, exports_scheduler_service, exports_runner_runtime_service, exports_definition_runtime, exports_activity_version_registry };