@apo-ai/sdk 0.16.1 → 0.17.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.
@@ -1,4 +1,4 @@
1
- import { A as AgentTaskTraceContext } from '../../tracing-CEucJqQI.js';
1
+ import { A as AgentTaskTraceContext } from '../../tracing-CDeEfMis.js';
2
2
 
3
3
  /**
4
4
  * Vercel AI SDK tracing integration for apo.
@@ -1,4 +1,4 @@
1
- import { A as AgentTaskTraceContext } from '../../tracing-CEucJqQI.js';
1
+ import { A as AgentTaskTraceContext } from '../../tracing-CDeEfMis.js';
2
2
 
3
3
  /**
4
4
  * Anthropic JS SDK tracing integration for apo.
@@ -2,8 +2,8 @@
2
2
  // Do not edit by hand — edit the src/ originals and rebuild.
3
3
  import {
4
4
  createApoAnthropic
5
- } from "../../chunk-4BQSCD6T.js";
6
- import "../../chunk-JN7RHBTS.js";
5
+ } from "../../chunk-6U6V7VKZ.js";
6
+ import "../../chunk-KWIYQSWK.js";
7
7
  export {
8
8
  createApoAnthropic
9
9
  };
@@ -1,4 +1,4 @@
1
- import { A as AgentTaskTraceContext } from '../../tracing-CEucJqQI.js';
1
+ import { A as AgentTaskTraceContext } from '../../tracing-CDeEfMis.js';
2
2
 
3
3
  /**
4
4
  * OpenAI JS SDK tracing integration for apo.
@@ -2,8 +2,8 @@
2
2
  // Do not edit by hand — edit the src/ originals and rebuild.
3
3
  import {
4
4
  createApoOpenAI
5
- } from "../../chunk-NSMKSPBU.js";
6
- import "../../chunk-JN7RHBTS.js";
5
+ } from "../../chunk-Z7DVZ34X.js";
6
+ import "../../chunk-KWIYQSWK.js";
7
7
  export {
8
8
  createApoOpenAI
9
9
  };
@@ -1,4 +1,4 @@
1
- import { A as AgentTaskTraceContext, a as AgentTaskTraceOptions } from '../tracing-CEucJqQI.js';
1
+ import { A as AgentTaskTraceContext, E as EmbeddingTracer, a as AgentTaskTraceOptions } from '../tracing-CDeEfMis.js';
2
2
  export { CreateApoTracerOptions, createApoTracer } from './integrations/ai-sdk.js';
3
3
  export { CreateApoOpenAIOptions, createApoOpenAI } from './integrations/openai.js';
4
4
  export { CreateApoAnthropicOptions, createApoAnthropic } from './integrations/anthropic.js';
@@ -52,6 +52,13 @@ interface TraceProjectionCapabilities {
52
52
  * was projected: absent reads as `unavailable`.
53
53
  */
54
54
  usage?: EvidenceAvailability;
55
+ /**
56
+ * Retrieved documents on `RETRIEVER` observations. Optional for snapshots
57
+ * written before retrieval was projected: absent reads as `unavailable`.
58
+ * `partial` means retrievals were observed but none returned a
59
+ * recognizable document list.
60
+ */
61
+ retrieval?: EvidenceAvailability;
55
62
  }
56
63
  /**
57
64
  * Token counts one observation reported. Each dimension is present only when
@@ -61,6 +68,43 @@ interface TraceProjectionUsage {
61
68
  inputTokens?: number;
62
69
  outputTokens?: number;
63
70
  }
71
+ /**
72
+ * Observed serving identity for one generation (issue #307). Each field is
73
+ * present only when the source reported it; unknown stays undefined, never a
74
+ * placeholder string. The provider an OpenAI-compatible call reached can
75
+ * differ from the host that executed inference; both survive here.
76
+ */
77
+ interface TraceProjectionServing {
78
+ /** Response model when reported, else the normalized model. */
79
+ model?: string;
80
+ instrumentationProvider?: string;
81
+ /** The service the harness called, e.g. `openrouter`. */
82
+ apiProvider?: string;
83
+ /** The organization that executed the inference, e.g. `baseten`. */
84
+ servingHost?: string;
85
+ /** The requested named selection policy, e.g. `nitro`. */
86
+ route?: string;
87
+ requestedServiceTier?: string;
88
+ /** The priority class actually served. */
89
+ serviceTier?: string;
90
+ requestModel?: string;
91
+ responseModel?: string;
92
+ }
93
+ /**
94
+ * Speed evidence for one generation (issue #307). Whole-call rate divides
95
+ * output tokens by the full request window; streaming rate divides by the
96
+ * decode window after first content. Absent fields were not measurable.
97
+ */
98
+ interface TraceProjectionRates {
99
+ /** Elapsed milliseconds from request start to first generated content. */
100
+ timeToFirstTokenMs?: number;
101
+ wholeCallOutputTokensPerSecond?: number;
102
+ streamingOutputTokensPerSecond?: number;
103
+ /** Which output-token numerator the rates describe. */
104
+ outputTokenScope?: "text" | "all_output" | "unknown";
105
+ /** Why a streaming rate is absent, when it is. */
106
+ streamingUnavailableReason?: "missing_timing" | "invalid_timing" | "missing_usage" | "scope_mismatch" | "unknown_scope" | "incomplete_call" | "aggregate_only";
107
+ }
64
108
  /** One chat message reconstructed from a generation observation. */
65
109
  interface TraceProjectionMessage {
66
110
  role: "system" | "user" | "assistant" | "tool";
@@ -91,6 +135,21 @@ interface TraceProjectionObservation {
91
135
  messages?: readonly TraceProjectionMessage[];
92
136
  /** Token usage this observation reported. Absent when none was recorded. */
93
137
  usage?: TraceProjectionUsage;
138
+ /**
139
+ * Observed serving identity (issue #307). Optional: snapshots written
140
+ * before the feature carry none, and non-generation observations never
141
+ * carry one.
142
+ */
143
+ serving?: TraceProjectionServing;
144
+ /** Speed evidence (issue #307). Optional; same snapshot rules as serving. */
145
+ rates?: TraceProjectionRates;
146
+ /**
147
+ * Whether this observation accounts for one physical API request
148
+ * (`"request"`) or a multi-request wrapper (`"aggregate"`). Absent on
149
+ * snapshots written before the feature; unknown accounting is omitted
150
+ * rather than guessed.
151
+ */
152
+ requestAccounting?: "request" | "aggregate";
94
153
  metadata?: Readonly<Record<string, unknown>>;
95
154
  }
96
155
  /** Trace-level facts. All timing is optional; absence is honest. */
@@ -116,6 +175,27 @@ interface TraceProjectionSnapshot {
116
175
  observations: readonly TraceProjectionObservation[];
117
176
  }
118
177
 
178
+ /**
179
+ * Retrieval evidence: the boundary between whatever a retriever returns and
180
+ * the typed documents assertions match on.
181
+ *
182
+ * A retrieval is an action with content: a query in, ranked documents out.
183
+ * Retrievers return wildly different shapes, so the projection tee parses the
184
+ * return value once at capture into the OpenInference document names (id,
185
+ * score, content) and readers only ever see the typed result. Snapshots that
186
+ * did not pass through the tee (canonical backend projections, injected
187
+ * replay observations) go through the same parser at read time, so both
188
+ * paths agree on what counts as recognized.
189
+ */
190
+
191
+ /** One retrieved document. Attribute names follow the OpenInference spec. */
192
+ interface TraceProjectionDocument {
193
+ /** Stable corpus id when the retriever reports one. Absent for content-only retrievers. */
194
+ id?: string;
195
+ score?: number;
196
+ content: string;
197
+ }
198
+
119
199
  /**
120
200
  * TraceView — typed, capability-gated, derived access over a
121
201
  * {@link TraceProjectionSnapshot}. This is the read model the projection-first
@@ -172,6 +252,21 @@ interface TraceToolCall {
172
252
  status: ObservationStatus;
173
253
  startedAt?: string;
174
254
  }
255
+ /** A retrieval derived from a `RETRIEVER` observation. */
256
+ interface TraceRetrieval {
257
+ spanId: string;
258
+ /** The query the retriever ran with, when recorded. */
259
+ query?: string;
260
+ /**
261
+ * The returned documents, in retriever rank order, when the result shape was
262
+ * recognized. Absent means the retrieval happened but its documents are
263
+ * unknown: negative assertions must fail closed on it, never read it as
264
+ * "nothing retrieved".
265
+ */
266
+ documents?: readonly TraceProjectionDocument[];
267
+ status: ObservationStatus;
268
+ startedAt?: string;
269
+ }
175
270
  /** A skill load derived from a `SKILL` observation. */
176
271
  interface TraceSkillLoad {
177
272
  spanId: string;
@@ -227,6 +322,8 @@ declare class TraceView {
227
322
  get toolCalls(): readonly TraceToolCall[];
228
323
  /** Tool names in invocation order with deterministic span-ID tie-breaking. */
229
324
  get toolNamesInOrder(): readonly string[];
325
+ /** Retrievals derived from `RETRIEVER` observations, in invocation order. */
326
+ get retrievals(): readonly TraceRetrieval[];
230
327
  /** Skill loads derived from `SKILL` observations, in invocation order. */
231
328
  get skillLoads(): readonly TraceSkillLoad[];
232
329
  /** Subagent delegations derived from `AGENT` observations, in invocation order. */
@@ -592,6 +689,139 @@ declare function getTaskSteers(): SteerSpec[];
592
689
  /** Clear registrations (loadTask use — mirrors resetTaskTurn). */
593
690
  declare function resetTaskSteers(): void;
594
691
 
692
+ /**
693
+ * Embedding-similarity grading, the deterministic third leg of the check
694
+ * vocabulary (exact/fuzzy matchers, `t.judge`, `t.agent`). Calls any
695
+ * OpenAI-compatible `/embeddings` endpoint (OpenRouter, OpenAI direct, local
696
+ * Ollama/vLLM/LM Studio), L2-normalizes both vectors, and compares with
697
+ * cosine similarity: the same inputs under the same config grade the same
698
+ * every time, unlike an LLM judge.
699
+ *
700
+ * Every verdict records a sacreBLEU-style settings signature
701
+ * (`model:1536d:cosine:apo-v1`) because cosine scales are model-bound: a
702
+ * threshold that means "paraphrase" on one embedding model can mean
703
+ * "unrelated" on another. The signature is the contract.
704
+ */
705
+ /** HTTP embedding config for any OpenAI-compatible `/embeddings` endpoint. */
706
+ type EmbeddingConfig = {
707
+ /**
708
+ * Embedding model id in the provider's namespace, e.g.
709
+ * `"openai/text-embedding-3-small"` (OpenRouter) vs
710
+ * `"text-embedding-3-small"` (OpenAI direct). Never reuse a chat model id.
711
+ */
712
+ model: string;
713
+ /** Endpoint base; defaults per provider resolution. Set for local servers. */
714
+ baseURL?: string;
715
+ /** Optional for local endpoints (Ollama and friends need none). */
716
+ apiKey?: string;
717
+ /**
718
+ * Best-effort Matryoshka truncation (models that support it only). The
719
+ * dimensionality actually returned is always what gets recorded and
720
+ * compared; a 400 naming `dimensions` is retried once without it.
721
+ */
722
+ dimensions?: number;
723
+ };
724
+ /**
725
+ * Full escape hatch: bring any embedder, from Cohere/Voyage request dialects
726
+ * to an in-process transformers.js pipeline, as a function. Programmatic layer
727
+ * only (`runTask({ embedding })`); env and task layers carry the HTTP shape.
728
+ */
729
+ type EmbeddingProvider = EmbeddingConfig | {
730
+ embed: (input: string[]) => Promise<number[][]>;
731
+ };
732
+ /**
733
+ * Metadata recorded on an assertion graded by embedding similarity. The
734
+ * mirror of `JudgeMetadata`: what graded, under which pinned settings, at
735
+ * what cost, so a similarity number is interpretable years later.
736
+ */
737
+ type EmbeddingMetadata = {
738
+ /** The requested model id, e.g. `openai/text-embedding-3-small`. */
739
+ model: string;
740
+ /** The model the provider reports serving (response `model` field). */
741
+ served_model?: string;
742
+ /** Vector dimensionality actually returned. */
743
+ dimensions: number;
744
+ /** Cosine similarity, rounded to 4 decimals. */
745
+ similarity: number;
746
+ threshold: number;
747
+ metric: "cosine";
748
+ /** `model:1536d:cosine:apo-v1`, everything that can move the number. */
749
+ settings_hash: string;
750
+ tokens?: {
751
+ input: number;
752
+ };
753
+ latency_ms?: number;
754
+ /** Deep link to this call's EMBEDDING observation in the trace view. */
755
+ span_id?: string;
756
+ /** Short previews of the compared texts, for string-only renderers. */
757
+ value_preview?: string;
758
+ reference_preview?: string;
759
+ };
760
+ /**
761
+ * Resolved per-call config: the HTTP shape or a custom embed fn, plus the
762
+ * effective model id used in signatures and error messages.
763
+ */
764
+ type ResolvedEmbeddingProvider = {
765
+ config: EmbeddingConfig;
766
+ custom?: undefined;
767
+ } | {
768
+ config?: undefined;
769
+ custom: {
770
+ embed: (input: string[]) => Promise<number[][]>;
771
+ };
772
+ };
773
+ /**
774
+ * Merge an embedding config override onto a base provider, most specific
775
+ * layer winning, the same field-by-field merge `resolveJudgeConfig` uses,
776
+ * so a partial layer (`{ dimensions }`, `{ apiKey }`) applies over the base
777
+ * instead of being dropped. An override carrying a `model` always yields
778
+ * the HTTP shape (switching away from a custom-embed base); without one, a
779
+ * custom-embed base passes through untouched: dimensions and keys mean
780
+ * nothing to a user-supplied function.
781
+ */
782
+ declare function resolveEmbeddingConfig(provider: EmbeddingProvider | ResolvedEmbeddingProvider | undefined, override: Partial<EmbeddingConfig> | undefined): ResolvedEmbeddingProvider | undefined;
783
+ type EmbeddingCallResult = {
784
+ vectors: number[][];
785
+ /** The provider-reported `model` field, when present. */
786
+ servedModel?: string;
787
+ dimensions: number;
788
+ tokens?: {
789
+ input: number;
790
+ };
791
+ /** Present when this call fetched fresh vectors; absent on full cache hits. */
792
+ latencyMs?: number;
793
+ };
794
+ /**
795
+ * Create a run-scoped embedding client: one shared vector cache so a
796
+ * reference reused across checks is embedded once, plus the retry/backoff
797
+ * policy for a single request. The cache key carries every setting that
798
+ * selects a different vector space (model, endpoint, requested dimensions);
799
+ * vectors from different configs must never mix in one comparison.
800
+ * In-flight fetches are deduplicated too: checks run concurrently, and two
801
+ * checks embedding the same reference must share one request, not race past
802
+ * each other into two.
803
+ */
804
+ declare function createEmbeddingClient(): EmbeddingClient;
805
+ /**
806
+ * Cosine similarity of two vectors, L2-normalizing first: identical result
807
+ * on already-normalized providers (OpenAI), correct on unnormalized ones
808
+ * (raw sentence-transformers served via OpenAI-compatible gateways). A
809
+ * zero-magnitude vector has no direction: similarity 0, per the guard every
810
+ * surveyed framework ships.
811
+ */
812
+ declare function cosineSimilarity(a: readonly number[], b: readonly number[]): number;
813
+ /** The run-scoped embedding client surface, for threading through contexts. */
814
+ type EmbeddingClient = {
815
+ embed: (texts: string[], provider: ResolvedEmbeddingProvider) => Promise<EmbeddingCallResult>;
816
+ };
817
+ /**
818
+ * The recorded settings signature: everything that can move the number.
819
+ * `apo-v1` is the grading-semantics version (model + returned dims + cosine
820
+ * on L2-normalized vectors + newline-collapsed inputs); bump it if
821
+ * preprocessing or the metric ever change, so old signatures stay honest.
822
+ */
823
+ declare function embeddingSettingsSignature(model: string, dimensions: number): string;
824
+
595
825
  /**
596
826
  * The outcome of a single assertion.
597
827
  *
@@ -843,8 +1073,14 @@ type AssertionResult = {
843
1073
  */
844
1074
  received?: unknown;
845
1075
  location?: CheckLocation;
846
- evaluator_type?: "llm" | "code" | "agent";
1076
+ evaluator_type?: "llm" | "code" | "agent" | "embedding";
847
1077
  judge?: JudgeMetadata;
1078
+ /**
1079
+ * Details about the embedding-similarity call that graded this assertion
1080
+ * (`t.semantic`): model, settings signature, similarity, threshold,
1081
+ * latency. Absent for every other evaluator.
1082
+ */
1083
+ embedding?: EmbeddingMetadata;
848
1084
  };
849
1085
  /**
850
1086
  * Result of evaluating a single check.
@@ -886,13 +1122,18 @@ type EvaluationItemResult = {
886
1122
  * - ``"regex"`` — pattern matching
887
1123
  * Older persisted results may still use ``"llm"`` at this level.
888
1124
  */
889
- evaluator_type?: "llm" | "code" | "agent" | "regex" | "mixed";
1125
+ evaluator_type?: "llm" | "code" | "agent" | "regex" | "embedding" | "mixed";
890
1126
  /**
891
1127
  * If this check was judged by an LLM, details about the judge call
892
1128
  * (model, prompt, response, tokens, cost, latency). Populated by the
893
1129
  * evaluator author; absent for code-only evaluators.
894
1130
  */
895
1131
  judge?: JudgeMetadata;
1132
+ /**
1133
+ * If this check was graded by embedding similarity (`t.semantic`), the
1134
+ * pinned settings + score details. Absent otherwise.
1135
+ */
1136
+ embedding?: EmbeddingMetadata;
896
1137
  /**
897
1138
  * For code checks: the source location of the failure (parsed from the
898
1139
  * thrown error / failed assertion stack). Lets the dashboard highlight the
@@ -1315,6 +1556,37 @@ type TokenBudgetOptions = {
1315
1556
  turn?: number;
1316
1557
  kind?: TokenKind;
1317
1558
  };
1559
+ /**
1560
+ * Which retrieved document a retrieval assertion looks for. A string is a
1561
+ * document id, matched exactly or as the parent of a chunk id (`"handbook"`
1562
+ * matches `"handbook#p3"`). `idPrefix` covers other chunk-id schemes;
1563
+ * `contentIncludes` covers retrievers that report no ids.
1564
+ */
1565
+ type DocumentMatcher = string | {
1566
+ id: string;
1567
+ } | {
1568
+ idPrefix: string;
1569
+ } | {
1570
+ contentIncludes: string;
1571
+ };
1572
+ type RetrievedOptions = {
1573
+ /** The match must rank within a retrieval's first `topK` documents (retriever order). */
1574
+ topK?: number;
1575
+ /** Only retrievals whose query contains this text count. */
1576
+ query?: string;
1577
+ };
1578
+ type GroundedOptions = {
1579
+ /**
1580
+ * What the answer must be grounded in. `"trace"` (the default) is every
1581
+ * document this run retrieved; an array is author-supplied source texts.
1582
+ */
1583
+ sources?: "trace" | readonly string[];
1584
+ label?: string;
1585
+ /** Per-call judge config override, merged like `t.judge`'s. */
1586
+ judge?: Partial<JudgeConfig>;
1587
+ /** Ground-truth verdict, like `t.judge`'s: `"fail"` asserts the judge catches a known hallucination. */
1588
+ expect?: "pass" | "fail";
1589
+ };
1318
1590
  /**
1319
1591
  * LLM judge model config for `t.judge(...)` calls in checks.ts. Threaded
1320
1592
  * through `runTask({ judge })` from the caller — the runner has no opinion
@@ -1368,6 +1640,17 @@ type JudgeScope = {
1368
1640
  /** Deliverable keys read so far, recorded by the check runner. */
1369
1641
  readDeliverableNames?: () => string[];
1370
1642
  };
1643
+ /**
1644
+ * The embedding plane threaded into check contexts: the layered provider
1645
+ * config, a run-scoped client (one shared vector cache, so a reference
1646
+ * reused across checks is embedded once), and the tracer slice for the EMBEDDING
1647
+ * observation + score record. Built once per run by the check runner.
1648
+ */
1649
+ type EmbeddingRuntime = {
1650
+ provider?: ResolvedEmbeddingProvider;
1651
+ client: EmbeddingClient;
1652
+ tracer?: EmbeddingTracer;
1653
+ };
1371
1654
  interface TestContext {
1372
1655
  /** Asserts a matching tool was called. Pass `{ count }` for an exact count. */
1373
1656
  calledTool(name: NameMatcher, opts?: ToolCallOptions): void;
@@ -1381,6 +1664,14 @@ interface TestContext {
1381
1664
  maxToolCalls(n: number): void;
1382
1665
  /** Asserts no tool/subagent call reported an error — anti-flail. */
1383
1666
  noFailedActions(): void;
1667
+ /**
1668
+ * Asserts a retrieval returned a matching document, optionally within its
1669
+ * first `topK` and only for retrievals whose query matches. Recall as a
1670
+ * test: one committed expectation per assertion, no score.
1671
+ */
1672
+ retrieved(document: DocumentMatcher, opts?: RetrievedOptions): void;
1673
+ /** Asserts at most `n` retrievals ran (anti-flail). */
1674
+ maxRetrievals(n: number): void;
1384
1675
  /** Asserts a skill was loaded. */
1385
1676
  loadedSkill(skill: string): void;
1386
1677
  /** Asserts a subagent delegation happened. */
@@ -1400,6 +1691,13 @@ interface TestContext {
1400
1691
  minTokens(n: number, opts?: TokenBudgetOptions): void;
1401
1692
  /** Escape hatch for a named predicate over the complete normalized run. */
1402
1693
  assert(label: string, predicate: (flow: TraceView) => boolean): void;
1694
+ /**
1695
+ * Negated presence assertions: `t.not.retrieved("acme-payroll")` passes
1696
+ * when that document was not retrieved. Missing evidence stays
1697
+ * `unsupported`, never a pass. Judged checks are not negatable; they carry
1698
+ * their own polarity through `expect: "fail"`.
1699
+ */
1700
+ readonly not: NotTestContext;
1403
1701
  /**
1404
1702
  * Asserts steer n was delivered AND consumed: at least one generation
1405
1703
  * observation started after the steer's delivery timestamp. Fails closed —
@@ -1457,6 +1755,32 @@ interface TestContext {
1457
1755
  */
1458
1756
  expect?: "pass" | "fail";
1459
1757
  }): Promise<void>;
1758
+ /**
1759
+ * Semantic similarity: embeds `value` and `reference` with the configured
1760
+ * embedding model (any OpenAI-compatible `/embeddings` endpoint:
1761
+ * OpenRouter, OpenAI, local Ollama/vLLM/LM Studio) and records one
1762
+ * assertion that passes when their cosine similarity ≥ `threshold`. The
1763
+ * call is async, so the check function must `await` it. Deterministic under a pinned config,
1764
+ * unlike `t.judge`. A non-string `value` is stringified like `t.check` matchers
1765
+ * do; `reference` is the authored text to compare against.
1766
+ *
1767
+ * The threshold is required and has no default: cosine scales are
1768
+ * model-bound (0.3 and 0.79 are both "paraphrase" on different models).
1769
+ * Calibrate with a handful of labeled pass/fail pairs before committing to
1770
+ * one. Every verdict records the raw score to 4 decimals and a settings
1771
+ * signature (`model:1536d:cosine:apo-v1`); similarity numbers from
1772
+ * different signatures are not comparable.
1773
+ *
1774
+ * ``opts.embedding`` overrides the run's embedding config **for this call
1775
+ * only**, merging field-by-field like ``t.judge``'s config override.
1776
+ */
1777
+ semantic(value: unknown, reference: string, opts: {
1778
+ /** Pass when cosine(value, reference) ≥ threshold. No default. */
1779
+ threshold: number;
1780
+ label?: string;
1781
+ /** Per-call embedding config override, merged onto the threaded config. */
1782
+ embedding?: Partial<EmbeddingConfig>;
1783
+ }): Promise<void>;
1460
1784
  /**
1461
1785
  * Agentic judge: a tool-using LLM session that investigates the run's own
1462
1786
  * evidence (deliverables via `read_deliverable`/`search_deliverable`, the
@@ -1476,20 +1800,33 @@ interface TestContext {
1476
1800
  * the check passes only when its verdict matches.
1477
1801
  */
1478
1802
  agent(instruction: string, opts?: AgentJudgeOptions): Promise<void>;
1803
+ /**
1804
+ * Groundedness (faithfulness): an LLM judge checks that every factual claim
1805
+ * in `value` is supported by the sources, by default the documents this run
1806
+ * actually retrieved. A fixed rubric over `t.judge`, so `expect`, judge
1807
+ * overrides and the second judge apply. Without retrieval evidence the
1808
+ * outcome is `unsupported`, never a verdict on missing sources. Async: the
1809
+ * check function must `await` it.
1810
+ */
1811
+ grounded(value: unknown, opts?: GroundedOptions): Promise<void>;
1479
1812
  }
1813
+ /**
1814
+ * The assertions `t.not` negates: presence claims, whose opposite is a clear
1815
+ * absence claim. Budgets and the existing negations (`notCalledTool`,
1816
+ * `usedNoTools`) already state their opposite directly.
1817
+ */
1818
+ type NotTestContext = Pick<TestContext, "calledTool" | "toolOrder" | "loadedSkill" | "calledSubagent" | "messageIncludes" | "retrieved" | "check">;
1480
1819
  /**
1481
1820
  * Canonical names of every assertion method on {@link TestContext}.
1482
1821
  *
1483
- * Single source of truth for "what is a ``t.<method>`` call?" — consumers that
1484
- * highlight, lint, or otherwise detect `t.*` usage in check source read this
1485
- * array instead of keeping their own copy (which historically drifted out of
1486
- * sync with the interface, leaving methods like ``t.maxTurns`` unstyled).
1487
- *
1488
- * The literal below is compile-time-checked against ``keyof TestContext``:
1489
- * adding a method to the interface without registering it here is a type
1490
- * error, and vice versa. See ``tests/test-context-methods.test.ts``.
1822
+ * The dashboard keeps its own copy of this list for syntax highlighting,
1823
+ * pinned to this array by an equality test, so the two cannot drift apart
1824
+ * silently. The literal below is compile-time-checked against
1825
+ * ``keyof TestContext``: adding a method to the interface without
1826
+ * registering it here is a type error, and vice versa. See
1827
+ * ``tests/test-context-methods.test.ts``.
1491
1828
  */
1492
- declare const TEST_METHOD_NAMES: readonly ["calledTool", "notCalledTool", "toolOrder", "usedNoTools", "maxToolCalls", "noFailedActions", "loadedSkill", "calledSubagent", "messageIncludes", "maxTurns", "maxDurationMs", "maxTokens", "minTokens", "steerDelivered", "afterSteer", "assert", "check", "judge", "agent"];
1829
+ declare const TEST_METHOD_NAMES: readonly ["calledTool", "notCalledTool", "toolOrder", "usedNoTools", "maxToolCalls", "noFailedActions", "retrieved", "maxRetrievals", "loadedSkill", "calledSubagent", "messageIncludes", "maxTurns", "maxDurationMs", "maxTokens", "minTokens", "steerDelivered", "afterSteer", "assert", "not", "check", "judge", "semantic", "agent", "grounded"];
1493
1830
 
1494
1831
  type TaskDefinition<TAdapterName extends string = string, TDeliverable extends string = string> = {
1495
1832
  id: string;
@@ -1506,6 +1843,14 @@ type TaskDefinition<TAdapterName extends string = string, TDeliverable extends s
1506
1843
  * `prompt` that tells the judge what it is grading.
1507
1844
  */
1508
1845
  judge?: Partial<JudgeConfig>;
1846
+ /**
1847
+ * Task-level embedding layer: overrides the run-level
1848
+ * `runTask({ embedding })` config for `t.semantic` calls in this task and
1849
+ * is itself overridden per call (`t.semantic(..., { embedding })`). Set
1850
+ * `{ model }` to grade this task's texts with a different embedding model
1851
+ * than the suite default.
1852
+ */
1853
+ embedding?: Partial<EmbeddingConfig>;
1509
1854
  /**
1510
1855
  * Task-level judge-tools layer: MCP evidence servers for `t.agent` sessions
1511
1856
  * in this task. Overrides `runTask({ judgeTools })`, is overridden per
@@ -2070,6 +2415,13 @@ type RunTaskOptions = {
2070
2415
  tracing?: AgentTaskTraceOptions;
2071
2416
  /** LLM judge model config for `t.judge(...)` calls in the task checks. */
2072
2417
  judge?: JudgeConfig;
2418
+ /**
2419
+ * Embedding provider for `t.semantic(...)` calls: the HTTP config for any
2420
+ * OpenAI-compatible `/embeddings` endpoint, or a custom `embed` function.
2421
+ * Layered under `TaskDefinition.embedding` and per-call
2422
+ * `t.semantic(..., { embedding })`.
2423
+ */
2424
+ embedding?: EmbeddingProvider;
2073
2425
  /**
2074
2426
  * Judge tool config for `t.agent(...)` sessions (MCP evidence servers).
2075
2427
  * Layered under `TaskDefinition.judgeTools` and per-call `tools.mcp`.
@@ -2215,6 +2567,7 @@ declare function discoverAgentTaskDirs(rootDir: string): string[];
2215
2567
  type AgentTaskRuntime = {
2216
2568
  judge?: JudgeConfig;
2217
2569
  judgeTools?: JudgeToolsConfig;
2570
+ embedding?: EmbeddingProvider;
2218
2571
  };
2219
2572
  type AgentTaskRunSummary = {
2220
2573
  taskDir: string;
@@ -2321,6 +2674,7 @@ interface OTelSpanProcessorLifecycle {
2321
2674
  declare class ApoSpanProcessor implements OTelSpanProcessorLifecycle {
2322
2675
  private spanMap;
2323
2676
  private servedModelByParent;
2677
+ private servingByParent;
2324
2678
  onStart(span: OTelSpan, _parentContext: OTelContext): void;
2325
2679
  onEnd(span: OTelReadableSpan): void;
2326
2680
  forceFlush(): Promise<void>;
@@ -2700,4 +3054,4 @@ type TranscriptCaptureResult = {
2700
3054
  };
2701
3055
  declare function replayAdapterTranscript(capture: AdapterTranscriptCapture, options: ReplayAdapterTranscriptOptions): Promise<TranscriptCaptureResult>;
2702
3056
 
2703
- export { type AISDKResult, type AdapterDefinition, type AdapterRuntimeState, type AdapterSession, type AdapterTranscriptCapture, type AgentBudget, type AgentEvidence, type AgentJudgeOptions, type AgentJudgeOutcome, type AgentJudgeSession, type AgentJudgeStep, type AgentProgressEvent, type AgentTaskCliOptions, type AgentTaskRunConfiguration, AgentTaskRunError, type AgentTaskRunSummary, type AgentTaskRuntime, AgentTaskTraceContext, AgentTaskTraceOptions, type AgentTurnResult, type AnthropicMessage, type ApoRunContext, ApoSpanProcessor, type ArtifactUploadConfig, COMPUTE_MAX_DEPTH, COMPUTE_MAX_EXPR, type CheckCompaction, type CheckContext, type CheckGroup, type CleanupContext, type CollectDeliverablesContext, type CollectedDeliverables, type ComputeResult, type DeliverableDefinition, type DeliverableSummary, type DeliverableValidationResult, type DescribeRegistration, type DurationBudgetOptions, type EvidenceFingerprint, type ExportOtlpTracesOptions, type FileArtifact, type FileArtifactOptions, type FileEntry, type Flow, type FlowEvent, FlowView, type InitializeContext, JUDGE_SEGMENT_LIMIT, type JudgeConfig, type JudgeContext, type JudgePromptBuilder, type JudgeScope, type JudgeToolsConfig, type LoadedTask, type ManifestFile, type ManifestFileInput, type Matcher, type McpHttpTransport, type McpServerConfig, type McpStdioTransport, type ModeClass, NO_CHECKS_REGISTERED_MESSAGE, type NameMatcher, type OpenAIMessage, type OtlpAttribute, type OtlpAttributeValue, type OtlpSpan, type OtlpTracesPayload, type ParsedTranscriptSession, type PreparedTaskResult, RECEIVED_VALUE_LIMIT, type RegisterApoTracingOptions, type RejudgeCheckStability, type RejudgeEndpoints, RejudgeError, type RejudgeOptions, type RejudgeOutcome, type ReplayAdapterTranscriptOptions, type RunTaskOptions, type SecondJudgeFacts, type SecondJudgeFactsInput, type StartSessionContext, type SteerContext, type SteerDeliveryBoundary, type SteerRecord, type SteerResult, type SteerSpec, type SteerTrigger, TEST_METHOD_NAMES, type TaskConfig, type TaskDefinition, type TaskEvaluationResult, TaskFiles, type TaskRevisionManifestV1, type TaskRunResult, type TaskScope, type TaskTranscript, type TaskTranscriptTurn, type TestContext, type TestRegistration, type TokenBudgetOptions, type ToolCallOptions, type ToolCallStatus, type TranscriptCaptureResult, TranscriptReplayError, type TranscriptReplayOptions, type TranscriptSource, type TranscriptToolCall, type TranscriptTurn, type TranscriptUsage, type TurnContext, type TurnFn, type TurnRecord, type TypedAdapterDefinition, type ValueMatcher, buildApoAuthHeaders, buildManifest, canonicalManifestJson, compactChecksForSubmission, connectMcpServers, contentSha256, defineAdapter, defineTask, describe, detectTranscriptSource, discoverAgentTaskDirs, equals, evaluateComputeExpression, expandSecretPlaceholders, exportOtlpTraces, fileArtifact, filePaths, fromAISDK, fromAnthropicMessages, fromOpenAIMessages, getActiveApoRun, getTaskSteers, getTaskTurn, includes, isFileArtifact, loadTask, loadTaskRuntime, matchValue, matches, normalizeManifestPath, parseAgentTaskCliArgs, parseClaudeCodeTranscript, parseCodexTranscript, persistFileArtifacts, registerApoTracing, rejudgeTaskRun, replayAdapterTranscript, resetApoTracing, resetFlowChecks, resetTaskRegistry, resetTaskSteers, resetTaskTurn, resolveMcpServerPaths, resolveOtlpTracesUrl, resolveTurn, runAgentTaskCli, runTask, runTaskDir, satisfies, secondJudgeFacts, secondJudgeTakeaway, sha256Hex, similarity, steer, task, defineCheck as test, transcriptSessionToOtlp, turn, withApoRun, withApoRunSync };
3057
+ export { type AISDKResult, type AdapterDefinition, type AdapterRuntimeState, type AdapterSession, type AdapterTranscriptCapture, type AgentBudget, type AgentEvidence, type AgentJudgeOptions, type AgentJudgeOutcome, type AgentJudgeSession, type AgentJudgeStep, type AgentProgressEvent, type AgentTaskCliOptions, type AgentTaskRunConfiguration, AgentTaskRunError, type AgentTaskRunSummary, type AgentTaskRuntime, AgentTaskTraceContext, AgentTaskTraceOptions, type AgentTurnResult, type AnthropicMessage, type ApoRunContext, ApoSpanProcessor, type ArtifactUploadConfig, COMPUTE_MAX_DEPTH, COMPUTE_MAX_EXPR, type CheckCompaction, type CheckContext, type CheckGroup, type CleanupContext, type CollectDeliverablesContext, type CollectedDeliverables, type ComputeResult, type DeliverableDefinition, type DeliverableSummary, type DeliverableValidationResult, type DescribeRegistration, type DocumentMatcher, type DurationBudgetOptions, type EmbeddingCallResult, type EmbeddingClient, type EmbeddingConfig, type EmbeddingMetadata, type EmbeddingProvider, type EmbeddingRuntime, type EvidenceFingerprint, type ExportOtlpTracesOptions, type FileArtifact, type FileArtifactOptions, type FileEntry, type Flow, type FlowEvent, FlowView, type GroundedOptions, type InitializeContext, JUDGE_SEGMENT_LIMIT, type JudgeConfig, type JudgeContext, type JudgePromptBuilder, type JudgeScope, type JudgeToolsConfig, type LoadedTask, type ManifestFile, type ManifestFileInput, type Matcher, type McpHttpTransport, type McpServerConfig, type McpStdioTransport, type ModeClass, NO_CHECKS_REGISTERED_MESSAGE, type NameMatcher, type NotTestContext, type OpenAIMessage, type OtlpAttribute, type OtlpAttributeValue, type OtlpSpan, type OtlpTracesPayload, type ParsedTranscriptSession, type PreparedTaskResult, RECEIVED_VALUE_LIMIT, type RegisterApoTracingOptions, type RejudgeCheckStability, type RejudgeEndpoints, RejudgeError, type RejudgeOptions, type RejudgeOutcome, type ReplayAdapterTranscriptOptions, type ResolvedEmbeddingProvider, type RetrievedOptions, type RunTaskOptions, type SecondJudgeFacts, type SecondJudgeFactsInput, type StartSessionContext, type SteerContext, type SteerDeliveryBoundary, type SteerRecord, type SteerResult, type SteerSpec, type SteerTrigger, TEST_METHOD_NAMES, type TaskConfig, type TaskDefinition, type TaskEvaluationResult, TaskFiles, type TaskRevisionManifestV1, type TaskRunResult, type TaskScope, type TaskTranscript, type TaskTranscriptTurn, type TestContext, type TestRegistration, type TokenBudgetOptions, type ToolCallOptions, type ToolCallStatus, type TranscriptCaptureResult, TranscriptReplayError, type TranscriptReplayOptions, type TranscriptSource, type TranscriptToolCall, type TranscriptTurn, type TranscriptUsage, type TurnContext, type TurnFn, type TurnRecord, type TypedAdapterDefinition, type ValueMatcher, buildApoAuthHeaders, buildManifest, canonicalManifestJson, compactChecksForSubmission, connectMcpServers, contentSha256, cosineSimilarity, createEmbeddingClient, defineAdapter, defineTask, describe, detectTranscriptSource, discoverAgentTaskDirs, embeddingSettingsSignature, equals, evaluateComputeExpression, expandSecretPlaceholders, exportOtlpTraces, fileArtifact, filePaths, fromAISDK, fromAnthropicMessages, fromOpenAIMessages, getActiveApoRun, getTaskSteers, getTaskTurn, includes, isFileArtifact, loadTask, loadTaskRuntime, matchValue, matches, normalizeManifestPath, parseAgentTaskCliArgs, parseClaudeCodeTranscript, parseCodexTranscript, persistFileArtifacts, registerApoTracing, rejudgeTaskRun, replayAdapterTranscript, resetApoTracing, resetFlowChecks, resetTaskRegistry, resetTaskSteers, resetTaskTurn, resolveEmbeddingConfig, resolveMcpServerPaths, resolveOtlpTracesUrl, resolveTurn, runAgentTaskCli, runTask, runTaskDir, satisfies, secondJudgeFacts, secondJudgeTakeaway, sha256Hex, similarity, steer, task, defineCheck as test, transcriptSessionToOtlp, turn, withApoRun, withApoRunSync };