@indexnetwork/protocol 3.7.0-rc.277.1 → 3.7.1-rc.279.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.
Files changed (96) hide show
  1. package/dist/agent/agent.tools.js +1 -1
  2. package/dist/agent/agent.tools.js.map +1 -1
  3. package/dist/chat/chat.agent.d.ts +6 -6
  4. package/dist/chat/chat.agent.d.ts.map +1 -1
  5. package/dist/chat/chat.agent.js +10 -9
  6. package/dist/chat/chat.agent.js.map +1 -1
  7. package/dist/chat/chat.graph.d.ts.map +1 -1
  8. package/dist/chat/chat.graph.js +3 -12
  9. package/dist/chat/chat.graph.js.map +1 -1
  10. package/dist/chat/chat.interrupt.classifier.d.ts.map +1 -1
  11. package/dist/chat/chat.interrupt.classifier.js +1 -3
  12. package/dist/chat/chat.interrupt.classifier.js.map +1 -1
  13. package/dist/chat/chat.prompt.d.ts.map +1 -1
  14. package/dist/chat/chat.prompt.js +8 -7
  15. package/dist/chat/chat.prompt.js.map +1 -1
  16. package/dist/chat/chat.prompt.modules.d.ts.map +1 -1
  17. package/dist/chat/chat.prompt.modules.js +5 -0
  18. package/dist/chat/chat.prompt.modules.js.map +1 -1
  19. package/dist/chat/chat.suggester.js.map +1 -1
  20. package/dist/context/context.generator.d.ts +2 -0
  21. package/dist/context/context.generator.d.ts.map +1 -1
  22. package/dist/context/context.generator.js +8 -6
  23. package/dist/context/context.generator.js.map +1 -1
  24. package/dist/intent/intent.clarifier.d.ts +2 -0
  25. package/dist/intent/intent.clarifier.d.ts.map +1 -1
  26. package/dist/intent/intent.clarifier.js +9 -23
  27. package/dist/intent/intent.clarifier.js.map +1 -1
  28. package/dist/intent/intent.graph.d.ts.map +1 -1
  29. package/dist/intent/intent.graph.js +29 -26
  30. package/dist/intent/intent.graph.js.map +1 -1
  31. package/dist/intent/intent.tools.d.ts.map +1 -1
  32. package/dist/intent/intent.tools.js +18 -48
  33. package/dist/intent/intent.tools.js.map +1 -1
  34. package/dist/maintenance/maintenance.graph.d.ts.map +1 -1
  35. package/dist/maintenance/maintenance.graph.js +1 -2
  36. package/dist/maintenance/maintenance.graph.js.map +1 -1
  37. package/dist/mcp/mcp.server.d.ts.map +1 -1
  38. package/dist/mcp/mcp.server.js +3 -5
  39. package/dist/mcp/mcp.server.js.map +1 -1
  40. package/dist/negotiation/negotiation.graph.d.ts.map +1 -1
  41. package/dist/negotiation/negotiation.graph.js +13 -20
  42. package/dist/negotiation/negotiation.graph.js.map +1 -1
  43. package/dist/negotiation/negotiation.tools.d.ts.map +1 -1
  44. package/dist/negotiation/negotiation.tools.js +12 -12
  45. package/dist/negotiation/negotiation.tools.js.map +1 -1
  46. package/dist/network/indexer/indexer.graph.d.ts +9 -9
  47. package/dist/network/indexer/indexer.graph.d.ts.map +1 -1
  48. package/dist/network/indexer/indexer.graph.js.map +1 -1
  49. package/dist/network/network.graph.d.ts.map +1 -1
  50. package/dist/network/network.graph.js +19 -25
  51. package/dist/network/network.graph.js.map +1 -1
  52. package/dist/opportunity/feed/feed.categorizer.d.ts.map +1 -1
  53. package/dist/opportunity/feed/feed.categorizer.js +15 -20
  54. package/dist/opportunity/feed/feed.categorizer.js.map +1 -1
  55. package/dist/opportunity/feed/feed.graph.d.ts.map +1 -1
  56. package/dist/opportunity/feed/feed.graph.js +8 -10
  57. package/dist/opportunity/feed/feed.graph.js.map +1 -1
  58. package/dist/opportunity/opportunity.introducer.d.ts.map +1 -1
  59. package/dist/opportunity/opportunity.introducer.js +1 -2
  60. package/dist/opportunity/opportunity.introducer.js.map +1 -1
  61. package/dist/opportunity/opportunity.tools.d.ts.map +1 -1
  62. package/dist/opportunity/opportunity.tools.js +3 -2
  63. package/dist/opportunity/opportunity.tools.js.map +1 -1
  64. package/dist/profile/profile.enricher.d.ts +5 -7
  65. package/dist/profile/profile.enricher.d.ts.map +1 -1
  66. package/dist/profile/profile.enricher.js +8 -10
  67. package/dist/profile/profile.enricher.js.map +1 -1
  68. package/dist/profile/profile.generator.d.ts.map +1 -1
  69. package/dist/profile/profile.generator.js +1 -2
  70. package/dist/profile/profile.generator.js.map +1 -1
  71. package/dist/profile/profile.tools.js +1 -1
  72. package/dist/profile/profile.tools.js.map +1 -1
  73. package/dist/questioner/questioner.presets.d.ts.map +1 -1
  74. package/dist/questioner/questioner.presets.js +24 -38
  75. package/dist/questioner/questioner.presets.js.map +1 -1
  76. package/dist/shared/agent/tool.factory.d.ts.map +1 -1
  77. package/dist/shared/agent/tool.factory.js +2 -2
  78. package/dist/shared/agent/tool.factory.js.map +1 -1
  79. package/dist/shared/agent/tool.helpers.d.ts +10 -0
  80. package/dist/shared/agent/tool.helpers.d.ts.map +1 -1
  81. package/dist/shared/agent/tool.helpers.js +2 -1
  82. package/dist/shared/agent/tool.helpers.js.map +1 -1
  83. package/dist/shared/agent/tool.runtime.d.ts.map +1 -1
  84. package/dist/shared/agent/tool.runtime.js +20 -13
  85. package/dist/shared/agent/tool.runtime.js.map +1 -1
  86. package/dist/shared/hyde/hyde.graph.d.ts.map +1 -1
  87. package/dist/shared/hyde/hyde.graph.js +3 -2
  88. package/dist/shared/hyde/hyde.graph.js.map +1 -1
  89. package/dist/shared/hyde/hyde.strategies.d.ts +2 -1
  90. package/dist/shared/hyde/hyde.strategies.d.ts.map +1 -1
  91. package/dist/shared/hyde/hyde.strategies.js.map +1 -1
  92. package/dist/shared/observability/trace.d.ts +3 -3
  93. package/dist/shared/observability/trace.d.ts.map +1 -1
  94. package/dist/shared/observability/trace.js +19 -33
  95. package/dist/shared/observability/trace.js.map +1 -1
  96. package/package.json +1 -1
@@ -78,6 +78,22 @@ export async function traceAgent(name, fn, summarize) {
78
78
  emit?.({ type: "agent_end", name, durationMs, ...(summary ? { summary } : {}) });
79
79
  return value;
80
80
  }
81
+ /**
82
+ * Builds a method decorator that wraps the decorated async method in the given
83
+ * trace wrapper (`traceGraph` / `traceAgent` / `tracePhase`). Uses the legacy
84
+ * decorator shape already adopted by `@Timed()`.
85
+ */
86
+ function traceDecorator(wrap) {
87
+ return (name) =>
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ function (_target, _propertyKey, descriptor) {
90
+ const original = descriptor.value;
91
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
+ descriptor.value = function (...args) {
93
+ return wrap(name, () => original.apply(this, args));
94
+ };
95
+ };
96
+ }
81
97
  /**
82
98
  * Method decorator. Wraps the decorated async method in `traceGraph(name, ...)`.
83
99
  * Use on class methods that represent a logical "graph" (a sub-flow with
@@ -89,17 +105,7 @@ export async function traceAgent(name, fn, summarize) {
89
105
  * async run() { ... }
90
106
  * }
91
107
  */
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
- export function TraceGraph(name) {
94
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
- return function (_target, _propertyKey, descriptor) {
96
- const original = descriptor.value;
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- descriptor.value = function (...args) {
99
- return traceGraph(name, () => original.apply(this, args));
100
- };
101
- };
102
- }
108
+ export const TraceGraph = traceDecorator(traceGraph);
103
109
  /**
104
110
  * Method decorator. Wraps the decorated async method in `traceAgent(name, ...)`.
105
111
  * Use on class methods that represent a single agent step (one LLM call,
@@ -111,17 +117,7 @@ export function TraceGraph(name) {
111
117
  * async run() { ... }
112
118
  * }
113
119
  */
114
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
- export function TraceAgent(name) {
116
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
- return function (_target, _propertyKey, descriptor) {
118
- const original = descriptor.value;
119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
- descriptor.value = function (...args) {
121
- return traceAgent(name, () => original.apply(this, args));
122
- };
123
- };
124
- }
120
+ export const TraceAgent = traceDecorator(traceAgent);
125
121
  /**
126
122
  * Method decorator. Wraps the decorated async method in `tracePhase(name, ...)`.
127
123
  * Use for logical groupings of inline work that aren't LangGraph state machines.
@@ -132,15 +128,5 @@ export function TraceAgent(name) {
132
128
  * async run() { ... }
133
129
  * }
134
130
  */
135
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
- export function TracePhase(name) {
137
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
138
- return function (_target, _propertyKey, descriptor) {
139
- const original = descriptor.value;
140
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
141
- descriptor.value = function (...args) {
142
- return tracePhase(name, () => original.apply(this, args));
143
- };
144
- };
145
- }
131
+ export const TracePhase = traceDecorator(tracePhase);
146
132
  //# sourceMappingURL=trace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sourceRoot":"/","sources":["shared/observability/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,SAAS,UAAU;IACjB,MAAM,GAAG,GAAG,cAAc,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC;IACpD,0EAA0E;IAC1E,mEAAmE;IACnE,uDAAuD;IACvD,OAAO,GAAqC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAI,IAAY,EAAE,EAAoB;IACpE,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;IAC1B,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAI,IAAY,EAAE,EAAoB;IACpE,MAAM,I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AAE,IAAI,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Trace helpers — wrap async work in `graph_start`/`graph_end` or\n * `agent_start`/`agent_end` events automatically. Pulls the emitter from the\n * ambient request context so callers don't pass it manually.\n *\n * Available in two flavours:\n * - Functional: `traceGraph(name, fn)` / `traceAgent(name, fn)` — for inline\n * blocks. Returns whatever the wrapped function returns.\n * - Decorator: `@TraceGraph(name)` / `@TraceAgent(name)` — for class methods.\n * Uses the legacy decorator shape already adopted by `@Timed()`.\n */\nimport { requestContext } from \"./request-context.js\";\n\ntype Emitter = (event: Record<string, unknown>) => void;\n\nfunction getEmitter(): Emitter | undefined {\n const raw = requestContext.getStore()?.traceEmitter;\n // The ambient TraceEmitter is typed against a constrained event union; we\n // emit a broader shape here. Same wide-cast pattern used elsewhere\n // (see opportunity.graph.ts, opportunity.discover.ts).\n return raw as unknown as Emitter | undefined;\n}\n\n/**\n * Wrap an async function so it emits `graph_start` / `graph_end` events around\n * its execution. `durationMs` is measured in wall time. If the wrapped\n * function throws, `graph_end` still fires before the error propagates.\n *\n * Use ONLY for actual LangGraph compiled state machines (Opportunity graph,\n * Negotiation graph, etc). For logical groupings of inline work, use\n * `tracePhase` — it has a distinct visual in the trace UI so users can tell\n * \"this is a graph\" from \"this is a phase\".\n */\nexport async function traceGraph<T>(name: string, fn: () => Promise<T>): Promise<T> {\n const emit = getEmitter();\n emit?.({ type: \"graph_start\", name });\n const start = Date.now();\n try {\n return await fn();\n } finally {\n emit?.({ type: \"graph_end\", name, durationMs: Date.now() - start });\n }\n}\n\n/**\n * Wrap an async function so it emits `phase_start` / `phase_end` events around\n * its execution. Phases are logical groupings of inline async work — they\n * share container semantics with graphs (they can host agents) but render\n * differently in the trace UI to make it clear they're NOT LangGraph state\n * machines.\n */\nexport async function tracePhase<T>(name: string, fn: () => Promise<T>): Promise<T> {\n const emit = getEmitter();\n emit?.({ type: \"phase_start\", name });\n const start = Date.now();\n try {\n return await fn();\n } finally {\n emit?.({ type: \"phase_end\", name, durationMs: Date.now() - start });\n }\n}\n\n/**\n * Wrap an async function so it emits `agent_start` / `agent_end` events. The\n * optional `summarize` callback produces a short string shown in the trace\n * panel; receives the wrapped function's resolved value.\n */\nexport async function traceAgent<T>(\n name: string,\n fn: () => Promise<T>,\n summarize?: (value: T) => string | undefined,\n): Promise<T> {\n const emit = getEmitter();\n emit?.({ type: \"agent_start\", name });\n const start = Date.now();\n let value: T;\n try {\n value = await fn();\n } catch (err) {\n emit?.({ type: \"agent_end\", name, durationMs: Date.now() - start });\n throw err;\n }\n const durationMs = Date.now() - start;\n const summary = summarize?.(value);\n emit?.({ type: \"agent_end\", name, durationMs, ...(summary ? { summary } : {}) });\n return value;\n}\n\n/**\n * Method decorator. Wraps the decorated async method in `traceGraph(name, ...)`.\n * Use on class methods that represent a logical \"graph\" (a sub-flow with\n * internal agent calls).\n *\n * @example\n * class RefinePhase {\n * @TraceGraph(\"Refine\")\n * async run() { ... }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function TraceGraph(name: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n const original = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (this: any, ...args: any[]) {\n return traceGraph(name, () => original.apply(this, args));\n };\n };\n}\n\n/**\n * Method decorator. Wraps the decorated async method in `traceAgent(name, ...)`.\n * Use on class methods that represent a single agent step (one LLM call,\n * one summarization, etc).\n *\n * @example\n * class ChatSummary {\n * @TraceAgent(\"Chat summary\")\n * async run() { ... }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function TraceAgent(name: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n const original = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (this: any, ...args: any[]) {\n return traceAgent(name, () => original.apply(this, args));\n };\n };\n}\n\n/**\n * Method decorator. Wraps the decorated async method in `tracePhase(name, ...)`.\n * Use for logical groupings of inline work that aren't LangGraph state machines.\n *\n * @example\n * class RefinePhase {\n * @TracePhase(\"Refine\")\n * async run() { ... }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function TracePhase(name: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n const original = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (this: any, ...args: any[]) {\n return tracePhase(name, () => original.apply(this, args));\n };\n };\n}\n"]}
1
+ {"version":3,"file":"trace.js","sourceRoot":"/","sources":["shared/observability/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,SAAS,UAAU;IACjB,MAAM,GAAG,GAAG,cAAc,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC;IACpD,0EAA0E;IAC1E,mEAAmE;IACnE,uDAAuD;IACvD,OAAO,GAAqC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAI,IAAY,EAAE,EAAoB;IACpE,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;IAC1B,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,IAAI,EAAE,CAA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K,CAAC;IACtC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,IAA2D;IAG3D,OAAO,CAAC,IAAY,EAAE,EAAE;IACtB,8DAA8D;IAC9D,UAAU,OAAY,EAAE,YAAoB,EAAE,UAA8B;QAC1E,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC;QAClC,8DAA8D;QAC9D,UAAU,CAAC,KAAK,GAAG,UAAqB,GAAG,IAAW;YACpD,OAAO,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC;IACJ,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC","sourcesContent":["/**\n * Trace helpers — wrap async work in `graph_start`/`graph_end` or\n * `agent_start`/`agent_end` events automatically. Pulls the emitter from the\n * ambient request context so callers don't pass it manually.\n *\n * Available in two flavours:\n * - Functional: `traceGraph(name, fn)` / `traceAgent(name, fn)` — for inline\n * blocks. Returns whatever the wrapped function returns.\n * - Decorator: `@TraceGraph(name)` / `@TraceAgent(name)` — for class methods.\n * Uses the legacy decorator shape already adopted by `@Timed()`.\n */\nimport { requestContext } from \"./request-context.js\";\n\ntype Emitter = (event: Record<string, unknown>) => void;\n\nfunction getEmitter(): Emitter | undefined {\n const raw = requestContext.getStore()?.traceEmitter;\n // The ambient TraceEmitter is typed against a constrained event union; we\n // emit a broader shape here. Same wide-cast pattern used elsewhere\n // (see opportunity.graph.ts, opportunity.discover.ts).\n return raw as unknown as Emitter | undefined;\n}\n\n/**\n * Wrap an async function so it emits `graph_start` / `graph_end` events around\n * its execution. `durationMs` is measured in wall time. If the wrapped\n * function throws, `graph_end` still fires before the error propagates.\n *\n * Use ONLY for actual LangGraph compiled state machines (Opportunity graph,\n * Negotiation graph, etc). For logical groupings of inline work, use\n * `tracePhase` — it has a distinct visual in the trace UI so users can tell\n * \"this is a graph\" from \"this is a phase\".\n */\nexport async function traceGraph<T>(name: string, fn: () => Promise<T>): Promise<T> {\n const emit = getEmitter();\n emit?.({ type: \"graph_start\", name });\n const start = Date.now();\n try {\n return await fn();\n } finally {\n emit?.({ type: \"graph_end\", name, durationMs: Date.now() - start });\n }\n}\n\n/**\n * Wrap an async function so it emits `phase_start` / `phase_end` events around\n * its execution. Phases are logical groupings of inline async work — they\n * share container semantics with graphs (they can host agents) but render\n * differently in the trace UI to make it clear they're NOT LangGraph state\n * machines.\n */\nexport async function tracePhase<T>(name: string, fn: () => Promise<T>): Promise<T> {\n const emit = getEmitter();\n emit?.({ type: \"phase_start\", name });\n const start = Date.now();\n try {\n return await fn();\n } finally {\n emit?.({ type: \"phase_end\", name, durationMs: Date.now() - start });\n }\n}\n\n/**\n * Wrap an async function so it emits `agent_start` / `agent_end` events. The\n * optional `summarize` callback produces a short string shown in the trace\n * panel; receives the wrapped function's resolved value.\n */\nexport async function traceAgent<T>(\n name: string,\n fn: () => Promise<T>,\n summarize?: (value: T) => string | undefined,\n): Promise<T> {\n const emit = getEmitter();\n emit?.({ type: \"agent_start\", name });\n const start = Date.now();\n let value: T;\n try {\n value = await fn();\n } catch (err) {\n emit?.({ type: \"agent_end\", name, durationMs: Date.now() - start });\n throw err;\n }\n const durationMs = Date.now() - start;\n const summary = summarize?.(value);\n emit?.({ type: \"agent_end\", name, durationMs, ...(summary ? { summary } : {}) });\n return value;\n}\n\n/**\n * Builds a method decorator that wraps the decorated async method in the given\n * trace wrapper (`traceGraph` / `traceAgent` / `tracePhase`). Uses the legacy\n * decorator shape already adopted by `@Timed()`.\n */\nfunction traceDecorator(\n wrap: <T>(name: string, fn: () => Promise<T>) => Promise<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (name: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void {\n return (name: string) =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n const original = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (this: any, ...args: any[]) {\n return wrap(name, () => original.apply(this, args));\n };\n };\n}\n\n/**\n * Method decorator. Wraps the decorated async method in `traceGraph(name, ...)`.\n * Use on class methods that represent a logical \"graph\" (a sub-flow with\n * internal agent calls).\n *\n * @example\n * class RefinePhase {\n * @TraceGraph(\"Refine\")\n * async run() { ... }\n * }\n */\nexport const TraceGraph = traceDecorator(traceGraph);\n\n/**\n * Method decorator. Wraps the decorated async method in `traceAgent(name, ...)`.\n * Use on class methods that represent a single agent step (one LLM call,\n * one summarization, etc).\n *\n * @example\n * class ChatSummary {\n * @TraceAgent(\"Chat summary\")\n * async run() { ... }\n * }\n */\nexport const TraceAgent = traceDecorator(traceAgent);\n\n/**\n * Method decorator. Wraps the decorated async method in `tracePhase(name, ...)`.\n * Use for logical groupings of inline work that aren't LangGraph state machines.\n *\n * @example\n * class RefinePhase {\n * @TracePhase(\"Refine\")\n * async run() { ... }\n * }\n */\nexport const TracePhase = traceDecorator(tracePhase);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "3.7.0-rc.277.1",
3
+ "version": "3.7.1-rc.279.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",