mesedi 0.1.0 → 0.6.0

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 (104) hide show
  1. package/README.md +81 -31
  2. package/dist/_errorClassesGenerated.d.ts +18 -0
  3. package/dist/_errorClassesGenerated.d.ts.map +1 -0
  4. package/dist/_errorClassesGenerated.js +24 -0
  5. package/dist/_errorClassesGenerated.js.map +1 -0
  6. package/dist/anthropic_integration.d.ts +9 -9
  7. package/dist/anthropic_integration.d.ts.map +1 -1
  8. package/dist/anthropic_integration.js +67 -26
  9. package/dist/anthropic_integration.js.map +1 -1
  10. package/dist/client.d.ts +32 -12
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +46 -18
  13. package/dist/client.js.map +1 -1
  14. package/dist/cohere_integration.d.ts +42 -0
  15. package/dist/cohere_integration.d.ts.map +1 -0
  16. package/dist/cohere_integration.js +456 -0
  17. package/dist/cohere_integration.js.map +1 -0
  18. package/dist/compress.d.ts +69 -0
  19. package/dist/compress.d.ts.map +1 -0
  20. package/dist/compress.js +75 -0
  21. package/dist/compress.js.map +1 -0
  22. package/dist/context.d.ts +13 -4
  23. package/dist/context.d.ts.map +1 -1
  24. package/dist/context.js +15 -5
  25. package/dist/context.js.map +1 -1
  26. package/dist/errors.d.ts +137 -0
  27. package/dist/errors.d.ts.map +1 -0
  28. package/dist/errors.js +462 -0
  29. package/dist/errors.js.map +1 -0
  30. package/dist/events.d.ts +19 -6
  31. package/dist/events.d.ts.map +1 -1
  32. package/dist/events.js +31 -6
  33. package/dist/events.js.map +1 -1
  34. package/dist/gemini_integration.d.ts +33 -0
  35. package/dist/gemini_integration.d.ts.map +1 -0
  36. package/dist/gemini_integration.js +334 -0
  37. package/dist/gemini_integration.js.map +1 -0
  38. package/dist/halt.d.ts +12 -12
  39. package/dist/halt.js +16 -16
  40. package/dist/halt.js.map +1 -1
  41. package/dist/halt_stream.d.ts +6 -6
  42. package/dist/halt_stream.d.ts.map +1 -1
  43. package/dist/halt_stream.js +22 -12
  44. package/dist/halt_stream.js.map +1 -1
  45. package/dist/index.d.ts +26 -13
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +20 -12
  48. package/dist/index.js.map +1 -1
  49. package/dist/integrations/langgraph.d.ts +99 -0
  50. package/dist/integrations/langgraph.d.ts.map +1 -0
  51. package/dist/integrations/langgraph.js +572 -0
  52. package/dist/integrations/langgraph.js.map +1 -0
  53. package/dist/integrations/mastra.d.ts +114 -0
  54. package/dist/integrations/mastra.d.ts.map +1 -0
  55. package/dist/integrations/mastra.js +354 -0
  56. package/dist/integrations/mastra.js.map +1 -0
  57. package/dist/integrations/openai_agents.d.ts +66 -0
  58. package/dist/integrations/openai_agents.d.ts.map +1 -0
  59. package/dist/integrations/openai_agents.js +243 -0
  60. package/dist/integrations/openai_agents.js.map +1 -0
  61. package/dist/integrations/promptfoo.d.ts +62 -0
  62. package/dist/integrations/promptfoo.d.ts.map +1 -0
  63. package/dist/integrations/promptfoo.js +76 -0
  64. package/dist/integrations/promptfoo.js.map +1 -0
  65. package/dist/integrations/ragas.d.ts +65 -0
  66. package/dist/integrations/ragas.d.ts.map +1 -0
  67. package/dist/integrations/ragas.js +78 -0
  68. package/dist/integrations/ragas.js.map +1 -0
  69. package/dist/integrations/vectara.d.ts +60 -0
  70. package/dist/integrations/vectara.d.ts.map +1 -0
  71. package/dist/integrations/vectara.js +59 -0
  72. package/dist/integrations/vectara.js.map +1 -0
  73. package/dist/integrations/vercel_ai.d.ts +6 -6
  74. package/dist/integrations/vercel_ai.js +10 -10
  75. package/dist/integrations/vercel_ai.js.map +1 -1
  76. package/dist/observe.d.ts +358 -3
  77. package/dist/observe.d.ts.map +1 -1
  78. package/dist/observe.js +536 -4
  79. package/dist/observe.js.map +1 -1
  80. package/dist/ollama_integration.d.ts +126 -0
  81. package/dist/ollama_integration.d.ts.map +1 -0
  82. package/dist/ollama_integration.js +404 -0
  83. package/dist/ollama_integration.js.map +1 -0
  84. package/dist/openai_integration.d.ts +67 -0
  85. package/dist/openai_integration.d.ts.map +1 -0
  86. package/dist/openai_integration.js +574 -0
  87. package/dist/openai_integration.js.map +1 -0
  88. package/dist/tool.d.ts +1 -1
  89. package/dist/tool.d.ts.map +1 -1
  90. package/dist/tool.js +193 -10
  91. package/dist/tool.js.map +1 -1
  92. package/dist/truncate.d.ts +84 -0
  93. package/dist/truncate.d.ts.map +1 -0
  94. package/dist/truncate.js +134 -0
  95. package/dist/truncate.js.map +1 -0
  96. package/dist/vertex_gemini_integration.d.ts +27 -0
  97. package/dist/vertex_gemini_integration.d.ts.map +1 -0
  98. package/dist/vertex_gemini_integration.js +229 -0
  99. package/dist/vertex_gemini_integration.js.map +1 -0
  100. package/dist/wrap.d.ts +39 -3
  101. package/dist/wrap.d.ts.map +1 -1
  102. package/dist/wrap.js +15 -12
  103. package/dist/wrap.js.map +1 -1
  104. package/package.json +28 -4
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Vectara HHEM (Hughes Hallucination Evaluation Model) helper
3
+ * (Mesedi #14, Wave 1.3).
4
+ *
5
+ * Vectara HHEM
6
+ * (https://huggingface.co/vectara/hallucination_evaluation_model)
7
+ * is a small open-source model that detects hallucinations in RAG
8
+ * agent outputs. Customers running HHEM against their answers can
9
+ * use this helper to report scores into Mesedi without hand-writing
10
+ * the boilerplate around {@link emitEvalScore}.
11
+ *
12
+ * IMPORTANT — direction note. HHEM scores have INVERTED semantics
13
+ * compared to Ragas / Promptfoo metrics: HIGHER means MORE faithful
14
+ * to context (less hallucination). The helper passes
15
+ * `higherIsBetter: true` to the backend and the parameter is named
16
+ * `faithfulnessScore` to mirror HHEM's documented output. Some HHEM
17
+ * consumers transform the output into a "hallucination_score" where
18
+ * LOWER is better — if your pipeline does that transformation,
19
+ * invert your value before calling this helper (i.e. pass
20
+ * `1 - hallucinationScore`).
21
+ *
22
+ * Report-only design: Mesedi does NOT import the vectara /
23
+ * transformers packages as dependencies. The customer runs HHEM on
24
+ * their side; this helper accepts the resulting score and emits a
25
+ * correctly-shaped `eval_score` event.
26
+ *
27
+ * Typical usage:
28
+ *
29
+ * import { wrap } from "mesedi";
30
+ * import { reportHhem } from "mesedi/integrations/vectara";
31
+ *
32
+ * export const myAgent = wrap(async (question: string) => {
33
+ * const { answer, contexts } = await runRag(question);
34
+ * const hhemScore = await runHhem(answer, contexts); // 0-1, higher = better
35
+ * reportHhem(hhemScore, { threshold: 0.5 });
36
+ * return answer;
37
+ * });
38
+ */
39
+ import { emitEvalScore } from "../observe.js";
40
+ /**
41
+ * Report a Vectara HHEM faithfulness score.
42
+ *
43
+ * HHEM produces a faithfulness probability in [0, 1]; HIGHER means
44
+ * more faithful to the retrieved context (i.e. LESS hallucinated).
45
+ * Read the module docstring for direction-sensitivity notes.
46
+ *
47
+ * @param faithfulnessScore HHEM's faithfulness probability in [0, 1].
48
+ * HIGHER is better.
49
+ * @param opts Threshold + reason.
50
+ */
51
+ export function reportHhem(faithfulnessScore, opts = {}) {
52
+ const threshold = opts.threshold ?? 0.5;
53
+ emitEvalScore("vectara/hhem", "hallucination", faithfulnessScore, faithfulnessScore >= threshold, {
54
+ threshold,
55
+ higherIsBetter: true,
56
+ reason: opts.reason,
57
+ });
58
+ }
59
+ //# sourceMappingURL=vectara.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectara.js","sourceRoot":"","sources":["../../src/integrations/vectara.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAY9C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,iBAAyB,EACzB,OAA6B,EAAE;IAE/B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC;IACxC,aAAa,CACX,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,iBAAiB,IAAI,SAAS,EAC9B;QACE,SAAS;QACT,cAAc,EAAE,IAAI;QACpB,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CACF,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Vercel AI SDK integration — wrap `generateText` to emit Mesedi
2
+ * Vercel AI SDK integration, wrap `generateText` to emit Mesedi
3
3
  * telemetry.
4
4
  *
5
5
  * Usage:
@@ -29,7 +29,7 @@
29
29
  * `wrapGenerateText` is a higher-order function that takes the real
30
30
  * Vercel `generateText` and returns a drop-in replacement with the
31
31
  * same signature plus telemetry side effects. Customers don't have
32
- * to refactor their agent code — they just swap the import.
32
+ * to refactor their agent code, they just swap the import.
33
33
  *
34
34
  * Multi-step (ReAct) generation is the common case for agent
35
35
  * workflows: `generateText({ maxSteps: 5, tools: { ... } })` makes
@@ -42,10 +42,10 @@
42
42
  * Mesedi instrumentation produces.
43
43
  *
44
44
  * Out of scope for this slice:
45
- * - `streamText` / `streamObject` — emit-on-stream-end variant
45
+ * - `streamText` / `streamObject`, emit-on-stream-end variant
46
46
  * would need to drain the stream first or instrument the
47
47
  * stream's transform. Deferred to a later slice.
48
- * - `generateObject` — structured output. The shape is similar to
48
+ * - `generateObject`, structured output. The shape is similar to
49
49
  * `generateText`'s but the response field is `.object` not
50
50
  * `.text`. Will compose well with the same wrapper pattern.
51
51
  * - OpenTelemetry-based instrumentation via `experimental_telemetry`.
@@ -68,7 +68,7 @@ interface GenerateTextOptionsLike {
68
68
  /**
69
69
  * Loose duck-typed shape for the Vercel `generateText` result. We
70
70
  * read .text, .usage, .toolCalls, .toolResults, .steps. All fields
71
- * are optional — older versions, custom providers, or streaming
71
+ * are optional, older versions, custom providers, or streaming
72
72
  * adapters may omit them.
73
73
  */
74
74
  interface GenerateTextResultLike {
@@ -112,7 +112,7 @@ export type GenerateTextLike = (opts: GenerateTextOptionsLike) => Promise<Genera
112
112
  * each invocation emits Mesedi telemetry. Returns a function with
113
113
  * the same signature.
114
114
  *
115
- * Outside a `wrap()` execution, the events silently no-op — same
115
+ * Outside a `wrap()` execution, the events silently no-op, same
116
116
  * fail-open pattern as every other Mesedi primitive.
117
117
  */
118
118
  export declare function wrapGenerateText<F extends GenerateTextLike>(generateTextFn: F): F;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Vercel AI SDK integration — wrap `generateText` to emit Mesedi
2
+ * Vercel AI SDK integration, wrap `generateText` to emit Mesedi
3
3
  * telemetry.
4
4
  *
5
5
  * Usage:
@@ -29,7 +29,7 @@
29
29
  * `wrapGenerateText` is a higher-order function that takes the real
30
30
  * Vercel `generateText` and returns a drop-in replacement with the
31
31
  * same signature plus telemetry side effects. Customers don't have
32
- * to refactor their agent code — they just swap the import.
32
+ * to refactor their agent code, they just swap the import.
33
33
  *
34
34
  * Multi-step (ReAct) generation is the common case for agent
35
35
  * workflows: `generateText({ maxSteps: 5, tools: { ... } })` makes
@@ -42,10 +42,10 @@
42
42
  * Mesedi instrumentation produces.
43
43
  *
44
44
  * Out of scope for this slice:
45
- * - `streamText` / `streamObject` — emit-on-stream-end variant
45
+ * - `streamText` / `streamObject`, emit-on-stream-end variant
46
46
  * would need to drain the stream first or instrument the
47
47
  * stream's transform. Deferred to a later slice.
48
- * - `generateObject` — structured output. The shape is similar to
48
+ * - `generateObject`, structured output. The shape is similar to
49
49
  * `generateText`'s but the response field is `.object` not
50
50
  * `.text`. Will compose well with the same wrapper pattern.
51
51
  * - OpenTelemetry-based instrumentation via `experimental_telemetry`.
@@ -56,7 +56,7 @@
56
56
  import { getClient } from "../client.js";
57
57
  import { currentExecutionContext, newEventId } from "../context.js";
58
58
  import { EventType, utcNowRfc3339 } from "../events.js";
59
- // Truncation budgets — kept in sync with the Python emit_llm_call and
59
+ // Truncation budgets, kept in sync with the Python emit_llm_call and
60
60
  // the TS Anthropic patch so wire-format payloads from this adapter and
61
61
  // from hand-written code are byte-indistinguishable.
62
62
  const MAX_SYSTEM = 1000;
@@ -70,7 +70,7 @@ const MAX_EXC_MSG = 500;
70
70
  * each invocation emits Mesedi telemetry. Returns a function with
71
71
  * the same signature.
72
72
  *
73
- * Outside a `wrap()` execution, the events silently no-op — same
73
+ * Outside a `wrap()` execution, the events silently no-op, same
74
74
  * fail-open pattern as every other Mesedi primitive.
75
75
  */
76
76
  export function wrapGenerateText(generateTextFn) {
@@ -100,7 +100,7 @@ export function wrapGenerateText(generateTextFn) {
100
100
  const durationMs = Date.now() - startedAt;
101
101
  const ctx = currentExecutionContext();
102
102
  if (!ctx) {
103
- // No active execution — nothing to attach events to. Return
103
+ // No active execution, nothing to attach events to. Return
104
104
  // the result unchanged.
105
105
  return result;
106
106
  }
@@ -146,7 +146,7 @@ export function wrapGenerateText(generateTextFn) {
146
146
  return wrapped;
147
147
  }
148
148
  /**
149
- * Inline emit_llm_call helper — direct equivalent of the Python
149
+ * Inline emit_llm_call helper, direct equivalent of the Python
150
150
  * `mesedi.observe.emit_llm_call`. Drift / similar-call /
151
151
  * identical-call / cost-velocity / prompt-injection detectors all
152
152
  * read from the resulting event payload, so a manually-emitted
@@ -157,7 +157,7 @@ function emitLlmCallEvent(args) {
157
157
  const ctx = currentExecutionContext();
158
158
  if (!ctx)
159
159
  return;
160
- // Halt-safe boundary — matches @mesedi.tool, the Anthropic patch,
160
+ // Halt-safe boundary, matches @mesedi.tool, the Anthropic patch,
161
161
  // and the Python emit_llm_call.
162
162
  ctx.checkBudget();
163
163
  if (ctx.budgetTracker) {
@@ -272,7 +272,7 @@ function emitToolCallEvent(tc, tr) {
272
272
  * Extract a stable model identifier from a Vercel model object.
273
273
  *
274
274
  * Vercel provider models expose either `.modelId` (newer) or
275
- * `.id` (older). For unknown shapes we try toString() — most
275
+ * `.id` (older). For unknown shapes we try toString(), most
276
276
  * providers stringify to a human-readable label. Last resort:
277
277
  * "unknown".
278
278
  */
@@ -1 +1 @@
1
- {"version":3,"file":"vercel_ai.js","sourceRoot":"","sources":["../../src/integrations/vercel_ai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC;QACP,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,mBAAmB,CAAC;QAC7B,CAAC;IACH,CAAC;AACH,CAAC"}
package/dist/observe.d.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * }
17
17
  *
18
18
  * Both helpers no-op silently when called outside an active wrap()
19
- * execution context — same fail-open pattern as `tool()`.
19
+ * execution context, same fail-open pattern as `tool()`.
20
20
  */
21
21
  /**
22
22
  * Emit a `checkpoint` event marking a notable point in execution.
@@ -24,7 +24,7 @@
24
24
  * A checkpoint is a free-form marker: a name + arbitrary metadata.
25
25
  * Typical uses: "after_retrieval", "before_synthesis", "cache_hit".
26
26
  * Useful both for Phase 3+ detector hooks (drift, cost-velocity)
27
- * and for ad-hoc debugging — replay UI in a future phase will
27
+ * and for ad-hoc debugging, replay UI in a future phase will
28
28
  * render checkpoints as anchored markers on the execution timeline.
29
29
  *
30
30
  * Outside `wrap()`: silent no-op.
@@ -34,17 +34,372 @@ export type ValidatorSeverity = "warning" | "error" | "critical";
34
34
  export interface ValidatorResultOptions {
35
35
  message?: string;
36
36
  severity?: ValidatorSeverity;
37
+ /**
38
+ * Optional sub-classification of WHY the validator failed (e.g.
39
+ * "schema_mismatch", "hallucination", "missing_required_field").
40
+ * Granular-signature wave: when supplied, the backend concatenates
41
+ * it into the failure_group signature as "<name>:<category>" so a
42
+ * single `quality_check` validator failing for 50 different reasons
43
+ * surfaces as 50 clusters instead of one impossibly-coarse cluster.
44
+ * Truncated to 80 chars client-side + control characters stripped
45
+ * backend-side. Backward-compat: omitting `category` (the default)
46
+ * preserves the original "<name>"-only signature shape.
47
+ */
48
+ category?: string;
37
49
  }
38
50
  /**
39
51
  * Report a validator outcome as a `validator_result` event.
40
52
  *
41
53
  * Validators are checks the agent (or its framework) runs against
42
54
  * intermediate or final outputs: schema conformance, factuality,
43
- * relevance, safety. The result — pass or fail — becomes a discrete
55
+ * relevance, safety. The result, pass or fail, becomes a discrete
44
56
  * event so Phase-3 detection can spot patterns like "validator X
45
57
  * has been failing 90% of the time on this model."
46
58
  *
47
59
  * Outside `wrap()`: silent no-op.
48
60
  */
49
61
  export declare function validatorResult(name: string, passed: boolean, opts?: ValidatorResultOptions): void;
62
+ /**
63
+ * Options for emitInfrastructureEvent. Mirrors the Go
64
+ * InfrastructureEventPayload struct in
65
+ * backend/internal/events/types.go field-for-field, omitting `reason`
66
+ * which is the positional first arg of the emitter.
67
+ */
68
+ export interface InfrastructureEventOptions {
69
+ /** Short provider identifier ("anthropic", "openai", "google"...). */
70
+ provider?: string;
71
+ /** Provider URL path that triggered the event. */
72
+ endpoint?: string;
73
+ /** HTTP status returned (429, 503...). */
74
+ statusCode?: number;
75
+ /** Server-suggested backoff window in ms (from Retry-After). */
76
+ retryAfterMs?: number;
77
+ /** Calls / tokens still available, from x-ratelimit-remaining. */
78
+ quotaRemaining?: number;
79
+ /** Maximum on this quota, from x-ratelimit-limit. */
80
+ quotaLimit?: number;
81
+ /**
82
+ * Stable string identifier for the quota dimension that breached
83
+ * ("tokens_per_minute", "requests_per_second", etc.). Used as a
84
+ * signature dimension by the backend's infrastructure_throttled
85
+ * detector.
86
+ */
87
+ quotaDimension?: string;
88
+ /** How long the caller actually waited before retrying. */
89
+ backoffAppliedMs?: number;
90
+ /**
91
+ * When reason="circuit_breaker", one of "open" / "half_open" /
92
+ * "closed". Empty defaults to "open" in the backend signature
93
+ * assembly.
94
+ */
95
+ circuitState?: string;
96
+ }
97
+ /**
98
+ * Reason codes recognized by ThrottlingSignature on the backend.
99
+ * Other strings are accepted (they cluster as "<reason>:<provider>")
100
+ * so SDKs can emit forward-compatible reasons before the detector
101
+ * adds explicit support.
102
+ */
103
+ export type InfrastructureReason = "rate_limit" | "circuit_breaker" | "quota_exhausted" | (string & {});
104
+ /**
105
+ * If the canonical error_class is a throttling signal, emit an
106
+ * infrastructure_event alongside the failed llm_call so the backend's
107
+ * infrastructure_throttled detector picks up the per-tenant
108
+ * backpressure pattern. No-op for non-throttling errors. Internal
109
+ * helper used by the four instrument_* modules (anthropic, openai,
110
+ * cohere, gemini) so the throttling-class filter and reason mapping
111
+ * live in one place.
112
+ */
113
+ export declare function _maybeEmitThrottlingEvent(args: {
114
+ provider: string;
115
+ errorClass: string;
116
+ httpStatus?: number;
117
+ retryAfterSeconds?: number;
118
+ endpoint?: string;
119
+ quotaDimension?: string;
120
+ }): void;
121
+ /**
122
+ * Emit an `infrastructure_event` for transport-plane backpressure.
123
+ *
124
+ * Used when the SDK or caller observes an HTTP 429, hits a provider
125
+ * quota header, trips a local circuit breaker, or otherwise gets a
126
+ * signal from the network plane that the agent's logic is fine but
127
+ * the underlying infrastructure is pushing back. The Mesedi backend's
128
+ * `infrastructure_throttled` detector consumes these events and
129
+ * clusters them by (reason, provider, quota_dimension) so SRE teams
130
+ * get a single page per affected provider instead of one page per
131
+ * request.
132
+ *
133
+ * Typical caller pattern (Vercel AI SDK / OpenAI / Anthropic):
134
+ *
135
+ * try {
136
+ * const res = await fetch(endpoint, { method: "POST", body });
137
+ * if (res.status === 429) {
138
+ * emitInfrastructureEvent("rate_limit", {
139
+ * provider: "anthropic",
140
+ * endpoint: "/v1/messages",
141
+ * statusCode: 429,
142
+ * retryAfterMs: Number(
143
+ * res.headers.get("retry-after-ms") ?? 0,
144
+ * ),
145
+ * quotaDimension: "tokens_per_minute",
146
+ * quotaRemaining: Number(
147
+ * res.headers.get("x-ratelimit-remaining") ?? 0,
148
+ * ),
149
+ * });
150
+ * }
151
+ * } catch (err) {
152
+ * // ...
153
+ * }
154
+ *
155
+ * Outside `wrap()`: silent no-op. Mirrors the fail-open pattern of
156
+ * every other observe-layer primitive. The SDK does NOT retry on
157
+ * its own; emitting this event is purely observational.
158
+ */
159
+ export declare function emitInfrastructureEvent(reason: InfrastructureReason, opts?: InfrastructureEventOptions): void;
160
+ /**
161
+ * Options for emitMcpCall. Mirrors the Go MCPCallPayload struct in
162
+ * backend/internal/events/types.go field-for-field, omitting
163
+ * `serverName` and `method` which are positional args.
164
+ */
165
+ export interface McpCallOptions {
166
+ /** Optional server URL or stdio target for the expanded view. */
167
+ serverUrl?: string;
168
+ /** Method arguments (any JSON-serializable value). */
169
+ arguments?: unknown;
170
+ /** Successful return value; omit on error. */
171
+ returnValue?: unknown;
172
+ /** Wall-clock duration in milliseconds. */
173
+ latencyMs?: number;
174
+ /** Error message when the call failed. */
175
+ error?: string;
176
+ /** Failure classifier: "hard_error" / "soft_error" / "timeout" / "server_unreachable" / "method_not_found". */
177
+ errorClass?: string;
178
+ }
179
+ /**
180
+ * Emit an `mcp_call` event for one Model Context Protocol server
181
+ * invocation.
182
+ *
183
+ * Use this when your agent talks to an MCP server (Anthropic's
184
+ * filesystem / github servers, a customer-hosted MCP server, etc.).
185
+ * The dashboard renders MCP calls in a distinct chip so cost
186
+ * attribution can break down by server identity, and the existing
187
+ * tool_failures detector picks up failed MCP calls when `error` or
188
+ * `errorClass` is non-empty.
189
+ *
190
+ * Outside `wrap()`: silent no-op.
191
+ */
192
+ export declare function emitMcpCall(serverName: string, method: string, opts?: McpCallOptions): void;
193
+ /** Options for emitEvalScore beyond the required core fields. */
194
+ export interface EvalScoreOptions {
195
+ /** Optional cutoff value the evaluator used. */
196
+ threshold?: number;
197
+ /**
198
+ * True for faithfulness / relevance / correctness; false for
199
+ * inverse metrics like hallucination_rate. Default true.
200
+ */
201
+ higherIsBetter?: boolean;
202
+ /** Optional explanation the evaluator returned. */
203
+ reason?: string;
204
+ /** Optional [0, 1] self-confidence the evaluator reports. */
205
+ confidence?: number;
206
+ }
207
+ /**
208
+ * Emit an `eval_score` event recording one external evaluator
209
+ * verdict on an execution's output.
210
+ *
211
+ * Use this when you run Ragas, Promptfoo, Vectara HHEM, or a custom
212
+ * judge against an execution's output and want Mesedi to track the
213
+ * score over time. Mesedi #14 aggregates these into
214
+ * grounding_failure clusters when scores trend below threshold.
215
+ *
216
+ * Outside `wrap()`: silent no-op.
217
+ */
218
+ export declare function emitEvalScore(evaluatorId: string, metricType: string, score: number, passed: boolean, opts?: EvalScoreOptions): void;
219
+ /** Options for emitMemoryOperation. */
220
+ export interface MemoryOperationOptions {
221
+ storeType?: string;
222
+ storeName?: string;
223
+ query?: string;
224
+ documentCount?: number;
225
+ tokenCount?: number;
226
+ topScore?: number;
227
+ latencyMs?: number;
228
+ cacheHit?: boolean;
229
+ error?: string;
230
+ errorClass?: string;
231
+ }
232
+ /**
233
+ * Emit a `memory_operation` event for one external memory store
234
+ * read / write / search.
235
+ */
236
+ export declare function emitMemoryOperation(operation: "read" | "write" | "search" | "delete" | (string & {}), opts?: MemoryOperationOptions): void;
237
+ /**
238
+ * Options for {@link emitAgentHandoff}.
239
+ *
240
+ * Mesedi #11. Use this at the moment one agent invokes another
241
+ * (supervisor/worker, plan/execute, role-based router). The
242
+ * downstream cascading_failure detector (#12) joins this event
243
+ * back to the topology graph (#10) so that a handoff whose child
244
+ * execution crashes within a short window can be surfaced as
245
+ * one logical failure rather than two unrelated ones.
246
+ *
247
+ * Well-known handoffKind values:
248
+ *
249
+ * - "delegate" one-shot, expects a return value
250
+ * - "spawn" fire-and-forget background sub-agent
251
+ * - "transfer" control transferred (no return)
252
+ * - "consult" short Q&A, return text only
253
+ */
254
+ export interface AgentHandoffOptions {
255
+ handoffKind?: "delegate" | "spawn" | "transfer" | "consult" | (string & {});
256
+ taskSummary?: string;
257
+ childExecutionId?: string;
258
+ latencyMs?: number;
259
+ error?: string;
260
+ errorClass?: string;
261
+ }
262
+ /**
263
+ * Object-form options for the new {@link emitAgentHandoff} overload
264
+ * (Wave 1.2.b). Use this when calling inside a `wrap()` whose
265
+ * `agentName` option supplies the source agent — the `fromAgent`
266
+ * field becomes optional and falls back to the wrapped execution's
267
+ * agent name.
268
+ */
269
+ export interface EmitAgentHandoffArgs extends AgentHandoffOptions {
270
+ fromAgent?: string;
271
+ toAgent: string;
272
+ }
273
+ /**
274
+ * Emit an `agent_handoff` event marking that the current agent
275
+ * delegated work to another agent.
276
+ *
277
+ * Two call shapes (Wave 1.2.b):
278
+ *
279
+ * Positional (original, fully backward-compatible):
280
+ *
281
+ * emitAgentHandoff("planner", "reviewer", { handoffKind: "delegate" });
282
+ *
283
+ * Object-form (new, terser when `wrap({ agentName: "planner" }, ...)`
284
+ * already declared the source agent):
285
+ *
286
+ * emitAgentHandoff({ toAgent: "reviewer", handoffKind: "delegate" });
287
+ *
288
+ * Resolution of the source agent:
289
+ *
290
+ * 1. Explicit `fromAgent` argument wins if supplied (positional or
291
+ * in the object form).
292
+ * 2. Otherwise, the `agentName` set on the active
293
+ * `wrap({ agentName: ... }, fn)` is used.
294
+ * 3. If neither is supplied while inside `wrap()`, this function
295
+ * throws Error rather than silently emitting an `unknown` source
296
+ * agent — polluting the topology graph would degrade
297
+ * cascading_failure / coordination_deadlock clustering at scale.
298
+ *
299
+ * Outside `wrap()` / `runInExecutionContext`: no-op (matches the
300
+ * existing fail-open contract).
301
+ */
302
+ export declare function emitAgentHandoff(args: EmitAgentHandoffArgs): void;
303
+ export declare function emitAgentHandoff(fromAgent: string, toAgent: string, opts?: AgentHandoffOptions): void;
304
+ /**
305
+ * Synchronously transition the current execution to
306
+ * `awaiting_human` (Mesedi #18).
307
+ *
308
+ * Call this from inside a `wrap()`-ed function at the moment the
309
+ * agent reaches a decision that requires a human in the loop. The
310
+ * backend records the pause timestamp, increments pause_count, and
311
+ * starts the HITL clock. A subsequent {@link resumeForAgent} call
312
+ * adds the elapsed time to total_paused_ms so a long HITL wait
313
+ * does not falsely trip the agent's time budget.
314
+ *
315
+ * The host application is responsible for actually blocking the
316
+ * agent until the human responds (typically the wrap()-ed function
317
+ * body itself awaits a queue / websocket / database row). This
318
+ * helper only updates Mesedi's lifecycle state; it does not block.
319
+ *
320
+ * Outside `wrap()`: no-op.
321
+ *
322
+ * Important: this is a SYNCHRONOUS PATCH (await) rather than the
323
+ * asynchronous shipper path that events take. The pause / resume
324
+ * transitions must be committed before the host application
325
+ * suspends the agent, so async-only delivery would race against
326
+ * the human responding.
327
+ */
328
+ export declare function pauseForHuman(): Promise<void>;
329
+ /**
330
+ * Synchronously transition the current execution from
331
+ * `awaiting_human` back to `started` (Mesedi #18).
332
+ *
333
+ * Call this from the host application's HITL response handler the
334
+ * moment the human's decision lands and the agent is about to be
335
+ * unblocked. The backend computes the wait duration and adds it
336
+ * to total_paused_ms so the time-budget detector reads only the
337
+ * agent's actual working time.
338
+ *
339
+ * Outside `wrap()`: no-op.
340
+ */
341
+ export declare function resumeForAgent(): Promise<void>;
342
+ /**
343
+ * Serializable handle to an in-flight HITL request (Mesedi #19).
344
+ *
345
+ * Returned by {@link requestHumanIntervention}. The shape is plain
346
+ * JSON so the host application can stash it in Redis, a database
347
+ * row, a websocket session, or a queue payload while waiting for
348
+ * the human response, then reconstruct a working handle from the
349
+ * stored data via {@link rehydrateHumanInterventionHandle}.
350
+ */
351
+ export interface HumanInterventionHandleData {
352
+ executionId: string;
353
+ requestId: string;
354
+ question: string;
355
+ slaSeconds: number;
356
+ requestedAt: string;
357
+ metadata?: Record<string, unknown>;
358
+ }
359
+ /**
360
+ * Options for completing a HITL request via
361
+ * {@link completeHumanIntervention}.
362
+ *
363
+ * Well-known {@link responseKind} values: `"approved"`, `"rejected"`,
364
+ * `"edited"`, `"timeout"`, `"cancelled"`. Custom strings are
365
+ * accepted but downstream HITL detectors (#20, #21) only recognize
366
+ * the five well-known values.
367
+ */
368
+ export interface CompleteHumanInterventionOptions {
369
+ responseKind: string;
370
+ responsePayload?: Record<string, unknown>;
371
+ decidedBy?: string;
372
+ }
373
+ /**
374
+ * Pause the current execution and return a handle (Mesedi #19).
375
+ *
376
+ * Synchronously transitions the execution into `awaiting_human`
377
+ * and returns a {@link HumanInterventionHandleData} carrying the
378
+ * correlation data needed to complete the cycle later. The host
379
+ * application is responsible for actually waiting on the human
380
+ * response (queue, websocket, DB poll) and then calling
381
+ * {@link completeHumanIntervention} with the answer.
382
+ *
383
+ * Outside `wrap()`: no-op, returns `null`.
384
+ *
385
+ * `slaSeconds` is optional metadata describing the customer's own
386
+ * SLA expectation. The hitl_timeout detector (#20) reads this to
387
+ * fire when the actual wait exceeds the configured SLA. Customers
388
+ * without an explicit SLA can omit it and #20 will fall back to a
389
+ * project-level default.
390
+ */
391
+ export declare function requestHumanIntervention(question: string, options?: {
392
+ slaSeconds?: number;
393
+ metadata?: Record<string, unknown>;
394
+ }): Promise<HumanInterventionHandleData | null>;
395
+ /**
396
+ * Complete a HITL request (Mesedi #19).
397
+ *
398
+ * Emits the `human_intervention` event with the full ask/answer
399
+ * payload, then synchronously transitions the execution from
400
+ * `awaiting_human` back to `started` so the agent code can
401
+ * continue. Idempotent only insofar as a re-call from `started`
402
+ * is a no-op resume (the backend rejects illegal transitions).
403
+ */
404
+ export declare function completeHumanIntervention(handle: HumanInterventionHandleData, opts: CompleteHumanInterventionOptions): Promise<void>;
50
405
  //# sourceMappingURL=observe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../src/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,IAAI,CAuBN;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AAEjE,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,IAAI,GAAE,sBAA2B,GAChC,IAAI,CA8BN"}
1
+ {"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../src/observe.ts"],"names":[],"mappings":"AAAA;;;;;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