llmist 10.1.1 → 10.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7902,19 +7902,16 @@ var init_typed_gadget = __esm({
7902
7902
  import equal from "fast-deep-equal";
7903
7903
  import { z as z4 } from "zod";
7904
7904
  function getHostExportsInternal() {
7905
- if (!cachedHostExports) {
7906
- cachedHostExports = {
7907
- AgentBuilder,
7908
- Gadget,
7909
- createGadget,
7910
- ExecutionTree,
7911
- LLMist,
7912
- z: z4
7913
- };
7914
- }
7915
- return cachedHostExports;
7905
+ return {
7906
+ AgentBuilder,
7907
+ Gadget,
7908
+ createGadget,
7909
+ ExecutionTree,
7910
+ LLMist,
7911
+ z: z4
7912
+ };
7916
7913
  }
7917
- var cachedHostExports, GadgetExecutor;
7914
+ var GadgetExecutor;
7918
7915
  var init_executor = __esm({
7919
7916
  "src/gadgets/executor.ts"() {
7920
7917
  "use strict";
@@ -10769,13 +10766,67 @@ var init_builder = __esm({
10769
10766
  };
10770
10767
  }
10771
10768
  if (ctx.onSubagentEvent && ctx.invocationId) {
10769
+ const invocationId = ctx.invocationId;
10772
10770
  this.subagentEventCallback = (event) => {
10773
10771
  ctx.onSubagentEvent({
10774
10772
  ...event,
10775
- gadgetInvocationId: ctx.invocationId,
10776
- depth
10773
+ gadgetInvocationId: invocationId,
10774
+ // Add depths: parent's depth + event's depth (for recursive nesting)
10775
+ depth: depth + (event.depth ?? 0)
10777
10776
  });
10778
10777
  };
10778
+ const existingHooks = this.hooks ?? {};
10779
+ this.hooks = {
10780
+ ...existingHooks,
10781
+ observers: {
10782
+ ...existingHooks.observers,
10783
+ onLLMCallStart: async (info) => {
10784
+ await existingHooks.observers?.onLLMCallStart?.(info);
10785
+ ctx.onSubagentEvent({
10786
+ type: "llm_call_start",
10787
+ event: {
10788
+ iteration: info.iteration,
10789
+ model: info.options.model
10790
+ },
10791
+ gadgetInvocationId: invocationId,
10792
+ depth,
10793
+ iteration: info.iteration
10794
+ });
10795
+ },
10796
+ onGadgetExecutionStart: async (gadgetCtx) => {
10797
+ await existingHooks.observers?.onGadgetExecutionStart?.(gadgetCtx);
10798
+ ctx.onSubagentEvent({
10799
+ type: "gadget_call",
10800
+ event: {
10801
+ type: "gadget_call",
10802
+ call: {
10803
+ gadgetName: gadgetCtx.gadgetName,
10804
+ invocationId: gadgetCtx.invocationId,
10805
+ parametersRaw: JSON.stringify(gadgetCtx.parameters),
10806
+ parameters: gadgetCtx.parameters,
10807
+ dependencies: []
10808
+ }
10809
+ },
10810
+ gadgetInvocationId: invocationId,
10811
+ depth
10812
+ });
10813
+ },
10814
+ onLLMCallComplete: async (info) => {
10815
+ await existingHooks.observers?.onLLMCallComplete?.(info);
10816
+ ctx.onSubagentEvent({
10817
+ type: "llm_call_end",
10818
+ event: {
10819
+ iteration: info.iteration,
10820
+ model: info.options.model,
10821
+ finishReason: info.finishReason ?? void 0,
10822
+ usage: info.usage
10823
+ },
10824
+ gadgetInvocationId: invocationId,
10825
+ depth
10826
+ });
10827
+ }
10828
+ }
10829
+ };
10779
10830
  }
10780
10831
  if (ctx.signal && !this.signal) {
10781
10832
  this.signal = ctx.signal;