mesedi 0.7.1 → 0.7.3

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/README.md CHANGED
@@ -111,7 +111,7 @@ Descriptions are truncated at 2000 characters with an inline
111
111
 
112
112
  ## Optional: hard-halt with local budgets
113
113
 
114
- Cap a single execution across four axes — input tokens, output tokens,
114
+ Cap a single execution across four axes: input tokens, output tokens,
115
115
  wall-clock seconds, and step count. Pass any subset; unset fields impose
116
116
  no limit on that axis. When any budget is exceeded, the SDK throws
117
117
  `MesediHalt` at the next safe boundary (between LLM calls, tool calls,
@@ -137,8 +137,7 @@ export const myAgent = wrap(
137
137
  When a budget is supplied, the SDK also opens an SSE subscription to
138
138
  `GET /executions/{id}/halt-stream`. Operators can halt a running
139
139
  execution from the dashboard. If the SSE connection fails (backend
140
- unreachable, 4xx/5xx, network partition), the reader logs and returns
141
- — the wrapped agent keeps running with local budgets still enforced
140
+ unreachable, 4xx/5xx, network partition), the reader logs and returns. The wrapped agent keeps running with local budgets still enforced
142
141
  client-side. Mesedi never decides to halt on its own; operator intent
143
142
  or your own budget rules are the only triggers. `MesediHalt` carries an
144
143
  internal Symbol marker so `wrap()` detects it even if user code
@@ -158,42 +157,53 @@ opt-in.
158
157
 
159
158
  ```typescript
160
159
  import { configure, wrap } from "mesedi";
161
- import { instrumentGraph } from "mesedi/integrations/langgraph";
160
+ import { instrumentLangGraph } from "mesedi/integrations/langgraph";
162
161
 
163
162
  configure({ apiKey: process.env.MESEDI_API_KEY! });
164
163
 
164
+ let graph = buildMyGraph().compile();
165
+ graph = instrumentLangGraph(graph);
166
+
165
167
  export const runMyGraph = wrap(async (question: string) => {
166
- const graph = buildGraph();
167
- instrumentGraph(graph);
168
- const result = await graph.invoke({ input: question });
169
- return result.output;
168
+ const result = await graph.invoke({ question });
169
+ return result.answer;
170
170
  });
171
171
  ```
172
172
 
173
- `instrumentGraph` attaches Mesedi telemetry to each node in the graph
174
- and emits `llm_call` and `tool_call` events labeled with the node name,
175
- so the dashboard timeline shows the graph's flow alongside per-step
176
- detail.
173
+ `instrumentLangGraph` returns the same graph with its invoke methods
174
+ patched, so re-assigning in place is the intended usage. It emits
175
+ `llm_call` and `tool_call` events plus a `checkpoint` at every node
176
+ entry, labeled with the node name, so the dashboard timeline shows the
177
+ graph's flow alongside per-step detail.
177
178
 
178
179
  ### OpenAI Agents SDK
179
180
 
180
181
  ```typescript
181
182
  import { configure, wrap } from "mesedi";
182
- import { instrumentAgent } from "mesedi/integrations/openai_agents";
183
+ import { MesediRunHooks } from "mesedi/integrations/openai_agents";
184
+ import { Agent, Runner } from "@openai/agents";
183
185
 
184
186
  configure({ apiKey: process.env.MESEDI_API_KEY! });
185
187
 
186
188
  export const runMyAgent = wrap(async (question: string) => {
187
- const agent = buildAgent();
188
- instrumentAgent(agent);
189
- return agent.run(question);
189
+ const result = await Runner.run(
190
+ triageAgent,
191
+ question,
192
+ { hooks: new MesediRunHooks() },
193
+ );
194
+ return result.finalOutput;
190
195
  });
191
196
  ```
192
197
 
193
- `instrumentAgent` subscribes to the OpenAI Agents SDK's lifecycle hooks
194
- and emits `llm_call` + `tool_call` events with the same wire format as
195
- the LangGraph and Vercel AI SDK adapters, so detectors see no
196
- difference.
198
+ `MesediRunHooks` implements the SDK's `RunHooks` interface. It emits a
199
+ `checkpoint` on every agent start and end, an `agent_handoff` on every
200
+ transfer between agents, and a `tool_call` per tool invocation.
201
+
202
+ It does **not** emit `llm_call` events, because the Agents SDK dispatches
203
+ model calls through its own runner and exposes no per-call hook. The
204
+ detectors that read `llm_call` (drift, identical-call and similar-call
205
+ loops, cost velocity) therefore do not fire on an OpenAI-Agents-only
206
+ deployment.
197
207
 
198
208
  ### Vercel AI SDK
199
209
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Cohere TypeScript SDK monkey-patch — auto-emit llm_call events
2
+ * Cohere TypeScript SDK monkey-patch: auto-emit llm_call events
3
3
  * for every chat call inside a wrap()'d execution.
4
4
  *
5
5
  * Mirrors instrumentAnthropic / instrumentOpenAI in fail-open
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Cohere TypeScript SDK monkey-patch — auto-emit llm_call events
2
+ * Cohere TypeScript SDK monkey-patch: auto-emit llm_call events
3
3
  * for every chat call inside a wrap()'d execution.
4
4
  *
5
5
  * Mirrors instrumentAnthropic / instrumentOpenAI in fail-open
package/dist/errors.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * openai_integration, cohere_integration, etc.) classifies its
6
6
  * native exception types into ONE of the values in ErrorClass. The
7
7
  * backend reads `error_class` from llm_call payloads and uses the
8
- * canonical vocabulary to cluster cross-provider signals — e.g.
8
+ * canonical vocabulary to cluster cross-provider signals: e.g.
9
9
  * when both Anthropic and OpenAI are rate-limiting at the same
10
10
  * time, the `provider_incident` detector sees them under the same
11
11
  * `rate_limited` bucket regardless of which exception class each
@@ -61,7 +61,7 @@ export declare function classifyAnthropicException(err: unknown): ErrorClassValu
61
61
  * Two-step classification:
62
62
  * 1. Look up class name in OPENAI_EXCEPTION_MAP.
63
63
  * 2. If result is RATE_LIMITED, probe the body for
64
- * `error.code === "insufficient_quota"` — OpenAI overloads
64
+ * `error.code === "insufficient_quota"`: OpenAI overloads
65
65
  * RateLimitError to cover both true rate limit and billing-
66
66
  * cap exhaustion. The QUOTA_EXHAUSTED bucket needs different
67
67
  * remediation (raise quota vs. back off), so the detector
@@ -81,7 +81,7 @@ export declare function classifyCohereException(err: unknown): ErrorClassValue;
81
81
  * Two-step classification:
82
82
  * 1. Look up class name in GEMINI_EXCEPTION_MAP.
83
83
  * 2. If result is RATE_LIMITED (ResourceExhausted), probe the
84
- * exception message for substring "quota" — Google overloads
84
+ * exception message for substring "quota": Google overloads
85
85
  * ResourceExhausted to cover both true rate-limit and
86
86
  * quota-exhaust.
87
87
  *
@@ -119,7 +119,7 @@ export declare function classifyByProvider(provider: string, err: unknown): Erro
119
119
  /**
120
120
  * Variant of `classifyByProvider` that dispatches on an exception
121
121
  * class NAME (string) rather than an Error object. Mastra's
122
- * SpanErrorInfo carries `.name` as a bare string — the underlying
122
+ * SpanErrorInfo carries `.name` as a bare string: the underlying
123
123
  * Error object is not preserved through the exporter chain. This
124
124
  * shim wraps the name in a synthetic Error so the same class-name
125
125
  * lookup path in the per-provider classifiers works unchanged.
package/dist/errors.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * openai_integration, cohere_integration, etc.) classifies its
6
6
  * native exception types into ONE of the values in ErrorClass. The
7
7
  * backend reads `error_class` from llm_call payloads and uses the
8
- * canonical vocabulary to cluster cross-provider signals — e.g.
8
+ * canonical vocabulary to cluster cross-provider signals: e.g.
9
9
  * when both Anthropic and OpenAI are rate-limiting at the same
10
10
  * time, the `provider_incident` detector sees them under the same
11
11
  * `rate_limited` bucket regardless of which exception class each
@@ -42,7 +42,7 @@ export const PROVIDER_SIDE_ERROR_CLASSES = PROVIDER_SIDE_ERROR_CLASS_VALUES;
42
42
  /**
43
43
  * Mapping from Anthropic exception class names (string, not the
44
44
  * class object) to canonical ErrorClass values. Keyed by name to
45
- * avoid taking a hard runtime dependency on @anthropic-ai/sdk —
45
+ * avoid taking a hard runtime dependency on @anthropic-ai/sdk:
46
46
  * the mesedi SDK works even if the anthropic package is not
47
47
  * installed, and the mapping stays correct because exception class
48
48
  * names are stable across anthropic SDK versions.
@@ -110,7 +110,7 @@ export function classifyAnthropicException(err) {
110
110
  * mapping is stable regardless of which casing the runtime presents.
111
111
  *
112
112
  * RateLimitError is overloaded by OpenAI to cover both true rate
113
- * limiting AND insufficient_quota — classifyOpenAIException probes
113
+ * limiting AND insufficient_quota: classifyOpenAIException probes
114
114
  * the body to distinguish, returning QUOTA_EXHAUSTED for the latter.
115
115
  */
116
116
  const OPENAI_EXCEPTION_MAP = {
@@ -137,7 +137,7 @@ const OPENAI_EXCEPTION_MAP = {
137
137
  * Two-step classification:
138
138
  * 1. Look up class name in OPENAI_EXCEPTION_MAP.
139
139
  * 2. If result is RATE_LIMITED, probe the body for
140
- * `error.code === "insufficient_quota"` — OpenAI overloads
140
+ * `error.code === "insufficient_quota"`: OpenAI overloads
141
141
  * RateLimitError to cover both true rate limit and billing-
142
142
  * cap exhaustion. The QUOTA_EXHAUSTED bucket needs different
143
143
  * remediation (raise quota vs. back off), so the detector
@@ -216,7 +216,7 @@ const GEMINI_EXCEPTION_MAP = {
216
216
  * Two-step classification:
217
217
  * 1. Look up class name in GEMINI_EXCEPTION_MAP.
218
218
  * 2. If result is RATE_LIMITED (ResourceExhausted), probe the
219
- * exception message for substring "quota" — Google overloads
219
+ * exception message for substring "quota": Google overloads
220
220
  * ResourceExhausted to cover both true rate-limit and
221
221
  * quota-exhaust.
222
222
  *
@@ -242,7 +242,7 @@ export function classifyGeminiException(err) {
242
242
  * QUOTA_EXHAUSTED are absent from this map by design.
243
243
  *
244
244
  * ResponseError (Ollama-native HTTP error) carries .status_code and
245
- * is bucketed by HTTP-code range inside classifyOllamaException —
245
+ * is bucketed by HTTP-code range inside classifyOllamaException:
246
246
  * NOT mapped here because the class name alone doesn't carry the
247
247
  * 4xx-vs-5xx distinction the detectors require. */
248
248
  const OLLAMA_EXCEPTION_MAP = {
@@ -335,7 +335,7 @@ export function classifyByProvider(provider, err) {
335
335
  /**
336
336
  * Variant of `classifyByProvider` that dispatches on an exception
337
337
  * class NAME (string) rather than an Error object. Mastra's
338
- * SpanErrorInfo carries `.name` as a bare string — the underlying
338
+ * SpanErrorInfo carries `.name` as a bare string: the underlying
339
339
  * Error object is not preserved through the exporter chain. This
340
340
  * shim wraps the name in a synthetic Error so the same class-name
341
341
  * lookup path in the per-provider classifiers works unchanged.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Google Gemini TypeScript SDK monkey-patch — auto-emit llm_call
2
+ * Google Gemini TypeScript SDK monkey-patch: auto-emit llm_call
3
3
  * events for every GenerativeModel.generateContent() call inside a
4
4
  * wrap()'d execution.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Google Gemini TypeScript SDK monkey-patch — auto-emit llm_call
2
+ * Google Gemini TypeScript SDK monkey-patch: auto-emit llm_call
3
3
  * events for every GenerativeModel.generateContent() call inside a
4
4
  * wrap()'d execution.
5
5
  *
@@ -2,7 +2,7 @@
2
2
  * Shared helpers for framework-adapter integration tests
3
3
  * (mastra.integration.test.ts, langchain.integration.test.ts).
4
4
  *
5
- * Design mirrors backend/test/integration/conftest.py — same wire
5
+ * Design mirrors backend/test/integration/conftest.py: same wire
6
6
  * protocol against the real Mesedi backend, same fresh-per-session
7
7
  * project mint, same `awaitFailureGroup` polling contract.
8
8
  *
@@ -17,12 +17,12 @@
17
17
  * if (!INTEGRATION_ENABLED) return test.skip(...)
18
18
  *
19
19
  * Set `RUN_INTEGRATION_TESTS=1` to opt in. Default `npm test` skips
20
- * everything in this file — unit tests stay fast.
20
+ * everything in this file: unit tests stay fast.
21
21
  */
22
22
  export declare const INTEGRATION_ENABLED: boolean;
23
23
  /**
24
24
  * Secondary gate for tests that make real LLM calls (Anthropic).
25
- * These add real cost — ~$0.01-$0.20 per test depending on payload
25
+ * These add real cost: ~$0.01-$0.20 per test depending on payload
26
26
  * size. Set `ANTHROPIC_API_KEY` in env to unlock. Absent → skip with
27
27
  * a clear reason.
28
28
  */
@@ -58,7 +58,7 @@ export interface AwaitFailureGroupOptions {
58
58
  signaturePrefix?: string;
59
59
  /** accept any one of a list of alternative (failure_class,
60
60
  * signaturePrefix?) pairs in addition to the primary match. Useful
61
- * when a signal has multiple valid backend clustering shapes — e.g.
61
+ * when a signal has multiple valid backend clustering shapes: e.g.
62
62
  * near-duplicate LLM calls fire as EITHER `loops/similar_call_*` OR
63
63
  * `drift/lexical_drift_*` depending on detector sensitivity. Both
64
64
  * are correct product signals; the test succeeds if ANY of the
@@ -2,7 +2,7 @@
2
2
  * Shared helpers for framework-adapter integration tests
3
3
  * (mastra.integration.test.ts, langchain.integration.test.ts).
4
4
  *
5
- * Design mirrors backend/test/integration/conftest.py — same wire
5
+ * Design mirrors backend/test/integration/conftest.py: same wire
6
6
  * protocol against the real Mesedi backend, same fresh-per-session
7
7
  * project mint, same `awaitFailureGroup` polling contract.
8
8
  *
@@ -18,12 +18,12 @@
18
18
  * if (!INTEGRATION_ENABLED) return test.skip(...)
19
19
  *
20
20
  * Set `RUN_INTEGRATION_TESTS=1` to opt in. Default `npm test` skips
21
- * everything in this file — unit tests stay fast.
21
+ * everything in this file: unit tests stay fast.
22
22
  */
23
23
  export const INTEGRATION_ENABLED = process.env["RUN_INTEGRATION_TESTS"] === "1";
24
24
  /**
25
25
  * Secondary gate for tests that make real LLM calls (Anthropic).
26
- * These add real cost — ~$0.01-$0.20 per test depending on payload
26
+ * These add real cost: ~$0.01-$0.20 per test depending on payload
27
27
  * size. Set `ANTHROPIC_API_KEY` in env to unlock. Absent → skip with
28
28
  * a clear reason.
29
29
  */
@@ -29,7 +29,7 @@
29
29
  *
30
30
  * `mesedi.wrap()` manages the execution boundary (started / completed /
31
31
  * crash signature). The callback handler emits the intra-execution
32
- * events — `llm_call` and `tool_call` — that Mesedi's detectors
32
+ * events, `llm_call` and `tool_call`, that Mesedi's detectors
33
33
  * consume. Splitting responsibility this way lets the customer adopt
34
34
  * Mesedi without reshaping their LangChain code: `wrap` goes around
35
35
  * the entry point, the handler gets attached at the existing
@@ -68,7 +68,7 @@ import type { BaseMessage } from "@langchain/core/messages";
68
68
  * format from `emit_llm_call` and the Anthropic patch) and one
69
69
  * `tool_call` event per tool invocation (matching the wire format
70
70
  * from `@mesedi.tool`). Both event types feed the standard Mesedi
71
- * detector chain — drift, identical / similar-call loops,
71
+ * detector chain: drift, identical / similar-call loops,
72
72
  * tool-failures, cost-velocity, prompt-injection.
73
73
  *
74
74
  * Outside a `wrap()` execution context, all emissions silently no-op
@@ -29,7 +29,7 @@
29
29
  *
30
30
  * `mesedi.wrap()` manages the execution boundary (started / completed /
31
31
  * crash signature). The callback handler emits the intra-execution
32
- * events — `llm_call` and `tool_call` — that Mesedi's detectors
32
+ * events, `llm_call` and `tool_call`, that Mesedi's detectors
33
33
  * consume. Splitting responsibility this way lets the customer adopt
34
34
  * Mesedi without reshaping their LangChain code: `wrap` goes around
35
35
  * the entry point, the handler gets attached at the existing
@@ -94,7 +94,7 @@ const MAX_EXC_MSG = 500;
94
94
  * format from `emit_llm_call` and the Anthropic patch) and one
95
95
  * `tool_call` event per tool invocation (matching the wire format
96
96
  * from `@mesedi.tool`). Both event types feed the standard Mesedi
97
- * detector chain — drift, identical / similar-call loops,
97
+ * detector chain: drift, identical / similar-call loops,
98
98
  * tool-failures, cost-velocity, prompt-injection.
99
99
  *
100
100
  * Outside a `wrap()` execution context, all emissions silently no-op
@@ -39,9 +39,9 @@
39
39
  * Out of scope for v1:
40
40
  *
41
41
  * - Streaming hooks (`graph.streamEvents`). Covered in a follow-up.
42
- * - LangGraph's persistence (checkpointer) — Mesedi emits
42
+ * - LangGraph's persistence (checkpointer): Mesedi emits
43
43
  * telemetry parallel to it without touching the stored state.
44
- * - LangGraph `interrupt()` auto-bridging — use the existing HITL
44
+ * - LangGraph `interrupt()` auto-bridging: use the existing HITL
45
45
  * helpers (`pauseForHuman`, `requestHumanIntervention`) for now.
46
46
  */
47
47
  /**
@@ -39,9 +39,9 @@
39
39
  * Out of scope for v1:
40
40
  *
41
41
  * - Streaming hooks (`graph.streamEvents`). Covered in a follow-up.
42
- * - LangGraph's persistence (checkpointer) — Mesedi emits
42
+ * - LangGraph's persistence (checkpointer): Mesedi emits
43
43
  * telemetry parallel to it without touching the stored state.
44
- * - LangGraph `interrupt()` auto-bridging — use the existing HITL
44
+ * - LangGraph `interrupt()` auto-bridging: use the existing HITL
45
45
  * helpers (`pauseForHuman`, `requestHumanIntervention`) for now.
46
46
  */
47
47
  import { getClient } from "../client.js";
@@ -16,7 +16,7 @@
16
16
  * configure({ apiKey: process.env.MESEDI_API_KEY });
17
17
  *
18
18
  * // Then wire the exporter into Mastra. Mastra 1.x requires the
19
- * // `configs` shape below — the `exporters: {...}` root shape from
19
+ * // `configs` shape below: the `exporters: {...}` root shape from
20
20
  * // pre-1.x is silently ignored and no spans reach the exporter.
21
21
  * const mastra = new Mastra({
22
22
  * observability: new Observability({
@@ -38,7 +38,7 @@
38
38
  * observability integration is to implement an Observability exporter
39
39
  * that consumes those spans. Unlike the other Mesedi integrations
40
40
  * (LangGraph, OpenAI Agents, Vercel AI SDK), the customer does NOT
41
- * need to wrap their entry function with `mesedi.wrap()` — Mastra's
41
+ * need to wrap their entry function with `mesedi.wrap()`: Mastra's
42
42
  * AGENT_RUN / WORKFLOW_RUN root span is the execution boundary. The
43
43
  * exporter opens a Mesedi execution on root-span-start and closes it
44
44
  * on root-span-end. All descendant spans on the same trace flow into
@@ -54,7 +54,7 @@
54
54
  * - Other span types (RAG_*, MEMORY_OPERATION, WORKSPACE_ACTION,
55
55
  * SCORER_*, MAPPING, PROCESSOR_RUN, MODEL_STEP / MODEL_INFERENCE /
56
56
  * MODEL_CHUNK) are silently ignored in v1. MODEL_GENERATION is
57
- * the aggregating span for a full model call — the finer-grained
57
+ * the aggregating span for a full model call: the finer-grained
58
58
  * step / inference / chunk spans are noise for Mesedi's detectors
59
59
  * and are already rolled up by Mastra.
60
60
  *
@@ -66,7 +66,7 @@ import { BaseExporter } from "@mastra/observability";
66
66
  import type { TracingEvent } from "@mastra/core/observability";
67
67
  /**
68
68
  * Configuration accepted by `new MesediExporter(...)`. Kept tiny on
69
- * purpose — the SDK's `configure()` already owns apiKey / baseUrl /
69
+ * purpose: the SDK's `configure()` already owns apiKey / baseUrl /
70
70
  * shipper knobs globally; passing them per-exporter would produce two
71
71
  * shippers if the customer ever instantiates two Mastra apps in the
72
72
  * same process.
@@ -16,7 +16,7 @@
16
16
  * configure({ apiKey: process.env.MESEDI_API_KEY });
17
17
  *
18
18
  * // Then wire the exporter into Mastra. Mastra 1.x requires the
19
- * // `configs` shape below — the `exporters: {...}` root shape from
19
+ * // `configs` shape below: the `exporters: {...}` root shape from
20
20
  * // pre-1.x is silently ignored and no spans reach the exporter.
21
21
  * const mastra = new Mastra({
22
22
  * observability: new Observability({
@@ -38,7 +38,7 @@
38
38
  * observability integration is to implement an Observability exporter
39
39
  * that consumes those spans. Unlike the other Mesedi integrations
40
40
  * (LangGraph, OpenAI Agents, Vercel AI SDK), the customer does NOT
41
- * need to wrap their entry function with `mesedi.wrap()` — Mastra's
41
+ * need to wrap their entry function with `mesedi.wrap()`: Mastra's
42
42
  * AGENT_RUN / WORKFLOW_RUN root span is the execution boundary. The
43
43
  * exporter opens a Mesedi execution on root-span-start and closes it
44
44
  * on root-span-end. All descendant spans on the same trace flow into
@@ -54,7 +54,7 @@
54
54
  * - Other span types (RAG_*, MEMORY_OPERATION, WORKSPACE_ACTION,
55
55
  * SCORER_*, MAPPING, PROCESSOR_RUN, MODEL_STEP / MODEL_INFERENCE /
56
56
  * MODEL_CHUNK) are silently ignored in v1. MODEL_GENERATION is
57
- * the aggregating span for a full model call — the finer-grained
57
+ * the aggregating span for a full model call: the finer-grained
58
58
  * step / inference / chunk spans are noise for Mesedi's detectors
59
59
  * and are already rolled up by Mastra.
60
60
  *
@@ -9,13 +9,13 @@
9
9
  * use this helper to report scores into Mesedi without hand-writing
10
10
  * the boilerplate around {@link emitEvalScore}.
11
11
  *
12
- * IMPORTANT — direction note. HHEM scores have INVERTED semantics
12
+ * IMPORTANT: direction note. HHEM scores have INVERTED semantics
13
13
  * compared to Ragas / Promptfoo metrics: HIGHER means MORE faithful
14
14
  * to context (less hallucination). The helper passes
15
15
  * `higherIsBetter: true` to the backend and the parameter is named
16
16
  * `faithfulnessScore` to mirror HHEM's documented output. Some HHEM
17
17
  * consumers transform the output into a "hallucination_score" where
18
- * LOWER is better — if your pipeline does that transformation,
18
+ * LOWER is better: if your pipeline does that transformation,
19
19
  * invert your value before calling this helper (i.e. pass
20
20
  * `1 - hallucinationScore`).
21
21
  *
@@ -9,13 +9,13 @@
9
9
  * use this helper to report scores into Mesedi without hand-writing
10
10
  * the boilerplate around {@link emitEvalScore}.
11
11
  *
12
- * IMPORTANT — direction note. HHEM scores have INVERTED semantics
12
+ * IMPORTANT: direction note. HHEM scores have INVERTED semantics
13
13
  * compared to Ragas / Promptfoo metrics: HIGHER means MORE faithful
14
14
  * to context (less hallucination). The helper passes
15
15
  * `higherIsBetter: true` to the backend and the parameter is named
16
16
  * `faithfulnessScore` to mirror HHEM's documented output. Some HHEM
17
17
  * consumers transform the output into a "hallucination_score" where
18
- * LOWER is better — if your pipeline does that transformation,
18
+ * LOWER is better: if your pipeline does that transformation,
19
19
  * invert your value before calling this helper (i.e. pass
20
20
  * `1 - hallucinationScore`).
21
21
  *
package/dist/observe.d.ts CHANGED
@@ -262,7 +262,7 @@ export interface AgentHandoffOptions {
262
262
  /**
263
263
  * Object-form options for the new {@link emitAgentHandoff} overload
264
264
  * (). Use this when calling inside a `wrap()` whose
265
- * `agentName` option supplies the source agent — the `fromAgent`
265
+ * `agentName` option supplies the source agent: the `fromAgent`
266
266
  * field becomes optional and falls back to the wrapped execution's
267
267
  * agent name.
268
268
  */
@@ -293,7 +293,7 @@ export interface EmitAgentHandoffArgs extends AgentHandoffOptions {
293
293
  * `wrap({ agentName: ... }, fn)` is used.
294
294
  * 3. If neither is supplied while inside `wrap()`, this function
295
295
  * throws Error rather than silently emitting an `unknown` source
296
- * agent — polluting the topology graph would degrade
296
+ * agent: polluting the topology graph would degrade
297
297
  * cascading_failure / coordination_deadlock clustering at scale.
298
298
  *
299
299
  * Outside `wrap()` / `runInExecutionContext`: no-op (matches the
package/dist/observe.js CHANGED
@@ -106,7 +106,7 @@ export function validatorResult(name, passed, opts = {}) {
106
106
  client.submitEvent(event);
107
107
  }
108
108
  /**
109
- * Canonical error_class values that signal per-tenant throttling — used
109
+ * Canonical error_class values that signal per-tenant throttling: used
110
110
  * by the instrument_* modules to decide whether to auto-emit an
111
111
  * infrastructure_event alongside their failed llm_call event so the
112
112
  * infrastructure_throttled detector picks up the pattern. Deliberately
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Ollama SDK monkey-patch — auto-emit llm_call events for every
2
+ * Ollama SDK monkey-patch: auto-emit llm_call events for every
3
3
  * `Ollama.chat()` call inside a wrap()'d execution.
4
4
  *
5
5
  * Mirrors instrumentOpenAI / instrumentAnthropic shape (same
6
6
  * fail-open semantics, same payload contract, same idempotency
7
7
  * guarantee), with Ollama-shape adjustments:
8
8
  *
9
- * - Token field names: prompt_eval_count / eval_count — translated
9
+ * - Token field names: prompt_eval_count / eval_count: translated
10
10
  * to canonical input_tokens / output_tokens on payload.
11
11
  * - Response text is `response.message.content` (not `choices[0]...`).
12
12
  * - No API-key auth; customers point at localhost or a remote
13
- * Ollama host. No throttling auto-emit in this sub-wave — for a
13
+ * Ollama host. No throttling auto-emit in this sub-wave: for a
14
14
  * local runtime there is no upstream rate-limit signal worth
15
15
  * surfacing.
16
16
  *
@@ -118,7 +118,7 @@ export declare const _testing: {
118
118
  * full wrap() + chat() integration scaffold. Not part of the
119
119
  * public API. */
120
120
  maybeWarnStreamingUnsupported: typeof maybeWarnStreamingUnsupported;
121
- /** — exposed for unit tests of the streaming chunk-
121
+ /**: exposed for unit tests of the streaming chunk-
122
122
  * aggregation logic. Not part of the public API. */
123
123
  accumulateChunk: typeof accumulateChunk;
124
124
  };
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Ollama SDK monkey-patch — auto-emit llm_call events for every
2
+ * Ollama SDK monkey-patch: auto-emit llm_call events for every
3
3
  * `Ollama.chat()` call inside a wrap()'d execution.
4
4
  *
5
5
  * Mirrors instrumentOpenAI / instrumentAnthropic shape (same
6
6
  * fail-open semantics, same payload contract, same idempotency
7
7
  * guarantee), with Ollama-shape adjustments:
8
8
  *
9
- * - Token field names: prompt_eval_count / eval_count — translated
9
+ * - Token field names: prompt_eval_count / eval_count: translated
10
10
  * to canonical input_tokens / output_tokens on payload.
11
11
  * - Response text is `response.message.content` (not `choices[0]...`).
12
12
  * - No API-key auth; customers point at localhost or a remote
13
- * Ollama host. No throttling auto-emit in this sub-wave — for a
13
+ * Ollama host. No throttling auto-emit in this sub-wave: for a
14
14
  * local runtime there is no upstream rate-limit signal worth
15
15
  * surfacing.
16
16
  *
@@ -47,11 +47,11 @@ const MAX_RESPONSE = 1000;
47
47
  const MAX_EXC_MSG = 500;
48
48
  /** Stable lowercase provider identifier shipped on every llm_call
49
49
  * event. Backend's provider_incident detector clusters cross-tenant
50
- * signals on (provider, error_class) — though for local runtimes the
50
+ * signals on (provider, error_class), though for local runtimes the
51
51
  * cross-tenant signal is necessarily quiet. */
52
52
  const PROVIDER = "ollama";
53
53
  const _patched = new WeakSet();
54
- /** — one-time guard for streaming calls. The
54
+ /**: one-time guard for streaming calls. The
55
55
  * chunk-aggregating wrapper for streaming responses ships in a
56
56
  * follow-up sub-wave; until then, calls with stream: true emit NO
57
57
  * llm_call event AND log a single console.info so customers
@@ -397,7 +397,7 @@ export const _testing = {
397
397
  * full wrap() + chat() integration scaffold. Not part of the
398
398
  * public API. */
399
399
  maybeWarnStreamingUnsupported,
400
- /** — exposed for unit tests of the streaming chunk-
400
+ /**: exposed for unit tests of the streaming chunk-
401
401
  * aggregation logic. Not part of the public API. */
402
402
  accumulateChunk,
403
403
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OpenAI SDK monkey-patch — auto-emit llm_call events for every
2
+ * OpenAI SDK monkey-patch: auto-emit llm_call events for every
3
3
  * chat.completions.create() and responses.create() call inside a
4
4
  * wrap()'d execution.
5
5
  *
@@ -12,7 +12,7 @@
12
12
  * - Response text is `choices[0].message.content` for chat
13
13
  * completions, OR `output_text` for the Responses API.
14
14
  * - Token names: `prompt_tokens` / `completion_tokens` for chat,
15
- * `input_tokens` / `output_tokens` for Responses — both
15
+ * `input_tokens` / `output_tokens` for Responses: both
16
16
  * normalized to the canonical input_tokens/output_tokens on
17
17
  * payload.
18
18
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OpenAI SDK monkey-patch — auto-emit llm_call events for every
2
+ * OpenAI SDK monkey-patch: auto-emit llm_call events for every
3
3
  * chat.completions.create() and responses.create() call inside a
4
4
  * wrap()'d execution.
5
5
  *
@@ -12,7 +12,7 @@
12
12
  * - Response text is `choices[0].message.content` for chat
13
13
  * completions, OR `output_text` for the Responses API.
14
14
  * - Token names: `prompt_tokens` / `completion_tokens` for chat,
15
- * `input_tokens` / `output_tokens` for Responses — both
15
+ * `input_tokens` / `output_tokens` for Responses: both
16
16
  * normalized to the canonical input_tokens/output_tokens on
17
17
  * payload.
18
18
  *
package/dist/tool.js CHANGED
@@ -26,7 +26,7 @@ const MAX_EXC_MSG = 500;
26
26
  * The SDK uses this as a generous upper bound; the backend applies
27
27
  * its OWN per-project cap (default 8 KB) at fingerprint time so
28
28
  * customers tune storage / fingerprint policy from the dashboard
29
- * without an SDK redeploy (see , migration 042).
29
+ * without an SDK redeploy (see migration 042).
30
30
  *
31
31
  * Raised from the v0.5.0 hardcoded 2048 to 16384 (16 KB) so the
32
32
  * SDK no longer aggressively truncates returns that the backend
@@ -24,13 +24,13 @@
24
24
  *
25
25
  * **Markers added on truncation:**
26
26
  *
27
- * - `_truncated` (boolean) — always `true` when this
27
+ * - `_truncated` (boolean): always `true` when this
28
28
  * helper altered the payload.
29
- * - `_original_payload_bytes` (number) — serialized byte count of
29
+ * - `_original_payload_bytes` (number): serialized byte count of
30
30
  * the original payload, so the
31
31
  * customer can see how much got
32
32
  * dropped.
33
- * - `_truncated_fields` (string[]) — names of the top-level
33
+ * - `_truncated_fields` (string[]): names of the top-level
34
34
  * fields whose values got shortened.
35
35
  *
36
36
  * **Fail-open.** Any exception during truncation falls back to the
package/dist/truncate.js CHANGED
@@ -24,13 +24,13 @@
24
24
  *
25
25
  * **Markers added on truncation:**
26
26
  *
27
- * - `_truncated` (boolean) — always `true` when this
27
+ * - `_truncated` (boolean): always `true` when this
28
28
  * helper altered the payload.
29
- * - `_original_payload_bytes` (number) — serialized byte count of
29
+ * - `_original_payload_bytes` (number): serialized byte count of
30
30
  * the original payload, so the
31
31
  * customer can see how much got
32
32
  * dropped.
33
- * - `_truncated_fields` (string[]) — names of the top-level
33
+ * - `_truncated_fields` (string[]): names of the top-level
34
34
  * fields whose values got shortened.
35
35
  *
36
36
  * **Fail-open.** Any exception during truncation falls back to the
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Vertex AI Gemini TypeScript SDK monkey-patch — auto-emit llm_call
2
+ * Vertex AI Gemini TypeScript SDK monkey-patch: auto-emit llm_call
3
3
  * events for every GenerativeModel.generateContent() call inside a
4
4
  * wrap()'d execution against the Vertex AI surface
5
5
  * (@google-cloud/vertexai package).
6
6
  *
7
7
  * Same provider tag ("gemini") and same canonical error_class map
8
8
  * as instrumentGemini. Customers running both surfaces call both
9
- * instrumentGemini() and instrumentVertexGemini() — each patches a
9
+ * instrumentGemini() and instrumentVertexGemini(): each patches a
10
10
  * different package's class. Provider_incident detection sees one
11
11
  * signal regardless of which surface was hit.
12
12
  *
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Vertex AI Gemini TypeScript SDK monkey-patch — auto-emit llm_call
2
+ * Vertex AI Gemini TypeScript SDK monkey-patch: auto-emit llm_call
3
3
  * events for every GenerativeModel.generateContent() call inside a
4
4
  * wrap()'d execution against the Vertex AI surface
5
5
  * (@google-cloud/vertexai package).
6
6
  *
7
7
  * Same provider tag ("gemini") and same canonical error_class map
8
8
  * as instrumentGemini. Customers running both surfaces call both
9
- * instrumentGemini() and instrumentVertexGemini() — each patches a
9
+ * instrumentGemini() and instrumentVertexGemini(): each patches a
10
10
  * different package's class. Provider_incident detection sees one
11
11
  * signal regardless of which surface was hit.
12
12
  *
package/dist/wrap.d.ts CHANGED
@@ -91,7 +91,7 @@ export interface WrapOptions {
91
91
  *
92
92
  * Explicit `fromAgent` always wins. If neither is supplied while
93
93
  * inside `wrap()`, `emitAgentHandoff` throws an Error rather than
94
- * silently emitting an `unknown` source agent — the topology graph
94
+ * silently emitting an `unknown` source agent: the topology graph
95
95
  * powers cascading_failure / coordination_deadlock clustering and
96
96
  * must not be polluted.
97
97
  */
package/dist/wrap.js CHANGED
@@ -79,7 +79,7 @@ export function wrap(fnOrOpts, maybeFn) {
79
79
  status: Status.STARTED,
80
80
  started_at: utcNowRfc3339(),
81
81
  sdk_language: "typescript",
82
- sdk_version: "0.7.1",
82
+ sdk_version: "0.7.3",
83
83
  // Optional tenant_id flows through to the wire body via
84
84
  // executionStartPayload's omitempty-style assignment.
85
85
  ...(opts.tenant_id !== undefined ? { tenant_id: opts.tenant_id } : {}),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mesedi",
3
- "version": "0.7.1",
4
- "description": "Mesedi SDK — guardians for autonomous AI agents. Detect failures, halt runaways, escalate first occurrence.",
3
+ "version": "0.7.3",
4
+ "description": "Mesedi SDK: guardians for autonomous AI agents. Detect failures, halt runaways, escalate first occurrence.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://mesedi.ai",
7
7
  "repository": {