@apo-ai/sdk 0.14.0 → 0.16.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.
package/README.md CHANGED
@@ -250,8 +250,11 @@ For apo tasks the flow is built automatically from the run's trace
250
250
  projection — no extra wiring.
251
251
 
252
252
  **`t.judge(value, instruction)` — LLM-backed assertions.** Configure the judge
253
- with `runTask(dir, { judge: { model, apiKey?, baseURL? } })`, or set
254
- `OPENROUTER_MODEL`/`OPENAI_MODEL` for the CLI runtime. Judge verdicts use the
253
+ with `runTask(dir, { judge: { model, apiKey?, baseURL?, provider? } })`, or set
254
+ `OPENROUTER_MODEL`/`OPENAI_MODEL`/`ANTHROPIC_MODEL` for the CLI runtime. A bare
255
+ `claude-*` model id (or an Anthropic base URL) switches the call to the
256
+ Anthropic Messages wire, authenticated with `ANTHROPIC_API_KEY` or
257
+ `ANTHROPIC_AUTH_TOKEN`. Judge verdicts use the
255
258
  same recorder and result format as code assertions, including model, prompt,
256
259
  response, token usage, and latency metadata.
257
260
 
@@ -1,4 +1,4 @@
1
- import { A as AgentTaskTraceContext } from '../../tracing-FqFObrmt.js';
1
+ import { A as AgentTaskTraceContext } from '../../tracing-CEucJqQI.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-FqFObrmt.js';
1
+ import { A as AgentTaskTraceContext } from '../../tracing-CEucJqQI.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-X73JGMK3.js";
6
- import "../../chunk-JTWQD27M.js";
5
+ } from "../../chunk-4BQSCD6T.js";
6
+ import "../../chunk-JN7RHBTS.js";
7
7
  export {
8
8
  createApoAnthropic
9
9
  };
@@ -1,4 +1,4 @@
1
- import { A as AgentTaskTraceContext } from '../../tracing-FqFObrmt.js';
1
+ import { A as AgentTaskTraceContext } from '../../tracing-CEucJqQI.js';
2
2
 
3
3
  /**
4
4
  * OpenAI JS SDK tracing integration for apo.
@@ -56,6 +56,9 @@ interface OpenAIClientLike {
56
56
  chat: {
57
57
  completions: {
58
58
  create: (...args: any[]) => Promise<any>;
59
+ withRawResponse?: {
60
+ create: (...args: any[]) => Promise<any>;
61
+ };
59
62
  };
60
63
  };
61
64
  [key: string]: any;
@@ -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-A3UYQ7M4.js";
6
- import "../../chunk-JTWQD27M.js";
5
+ } from "../../chunk-NSMKSPBU.js";
6
+ import "../../chunk-JN7RHBTS.js";
7
7
  export {
8
8
  createApoOpenAI
9
9
  };
@@ -1,4 +1,4 @@
1
- import { A as AgentTaskTraceContext, a as AgentTaskTraceOptions } from '../tracing-FqFObrmt.js';
1
+ import { A as AgentTaskTraceContext, a as AgentTaskTraceOptions } from '../tracing-CEucJqQI.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';
@@ -83,6 +83,7 @@ interface TraceProjectionObservation {
83
83
  errorMessage?: string;
84
84
  input?: unknown;
85
85
  output?: unknown;
86
+ /** The model the caller requested (often a gateway alias). */
86
87
  model?: string;
87
88
  toolName?: string;
88
89
  toolParameters?: unknown;
@@ -615,6 +616,12 @@ type AssertionOutcome = "pass" | "fail" | "unsupported" | "error";
615
616
  type JudgeMetadata = {
616
617
  /** Model identifier, e.g. ``"deepseek/deepseek-v4.1-flash"``. */
617
618
  model?: string;
619
+ /**
620
+ * The model the provider reports as having served the judge call (the
621
+ * response's `model` field). Diverges from `model` when the judge's
622
+ * gateway fell back — judge spend and attribution key on this.
623
+ */
624
+ served_model?: string;
618
625
  /**
619
626
  * Which response contract elicited this judgment (#163): reasoning-first
620
627
  * (the default) or the legacy verdict-first (``pass`` before
@@ -658,6 +665,22 @@ type JudgeMetadata = {
658
665
  * trusted (the noop trace context's sentinel).
659
666
  */
660
667
  span_id?: string;
668
+ /**
669
+ * What the judge itself concluded about the deliverable — the raw verdict,
670
+ * distinct from the check's `pass` (which is agreement with the author's
671
+ * ground truth under `expect` polarity). Identical to the check outcome
672
+ * when no `expect` was set; deliberately opposite on a correctly-judged
673
+ * `expect: "fail"` check. Recorded so downstream consumers — the history
674
+ * plane above all — can state what prior judges verdicted without
675
+ * parsing reasoning prose.
676
+ */
677
+ verdict_pass?: boolean;
678
+ /**
679
+ * The author's ground-truth polarity for this check (`expect`), when one
680
+ * was pinned. Together with `verdict_pass` it makes the check outcome
681
+ * reconstructible: outcome = verdict_pass matches expected_verdict.
682
+ */
683
+ expected_verdict?: "pass" | "fail";
661
684
  /**
662
685
  * Second-grader evidence: a typed-decision model (Jev via OpenRouter's
663
686
  * `/alpha/decisions`) graded the same deliverable + instruction alongside
@@ -1004,6 +1027,8 @@ declare function similarity(expected: string, threshold?: number): Matcher<unkno
1004
1027
  * LLM-as-judge call. Used by `t.judge(values, instruction)` to evaluate
1005
1028
  * deliverables against a natural-language rubric. Calls an OpenAI-compatible
1006
1029
  * endpoint (OpenRouter, OpenAI, etc.) via fetch and parses the verdict.
1030
+ * Anthropic-direct (`api.anthropic.com` Messages API) speaks its own wire —
1031
+ * see {@link resolveJudgeWire}.
1007
1032
  */
1008
1033
 
1009
1034
  /**
@@ -1055,7 +1080,16 @@ type HistoryRunDetail = {
1055
1080
  status: string;
1056
1081
  checks: {
1057
1082
  id: string;
1083
+ /** Check outcome — agreement with the author's ground truth. */
1058
1084
  pass: boolean;
1085
+ /**
1086
+ * What the judge itself concluded. Equal to `pass` without `expect`;
1087
+ * deliberately opposite on a correctly-judged `expect: "fail"` check.
1088
+ * Absent on pre-polarity recordings and non-judged (code) checks.
1089
+ */
1090
+ verdict_pass?: boolean;
1091
+ /** The author's ground truth (`expect`), when one was pinned. */
1092
+ expected_verdict?: "pass" | "fail";
1059
1093
  evaluator: string;
1060
1094
  reasoning?: string;
1061
1095
  assertions?: {
@@ -1294,6 +1328,13 @@ type JudgeConfig = {
1294
1328
  baseURL?: string;
1295
1329
  /** Override the API key (defaults to env). */
1296
1330
  apiKey?: string;
1331
+ /**
1332
+ * Force the Anthropic Messages wire (`api.anthropic.com/v1/messages`) for a
1333
+ * base URL whose hostname does not identify it — an Anthropic-protocol
1334
+ * gateway. Unset = auto-detection (Anthropic host, or a bare `claude-*`
1335
+ * model id); see `resolveJudgeWire` in judge.ts.
1336
+ */
1337
+ provider?: "anthropic";
1297
1338
  /**
1298
1339
  * Build a custom judge briefing from the threaded context (#161). The SDK
1299
1340
  * keeps ownership of the JSON response contract — see
@@ -1771,8 +1812,15 @@ type SecondJudgeFacts = {
1771
1812
  * types the CLI and dashboard read from the backend are all assignable.
1772
1813
  */
1773
1814
  type SecondJudgeFactsInput = {
1815
+ /**
1816
+ * The check outcome. Under `expect` polarity this is agreement with the
1817
+ * author's ground truth, not the judge's verdict — the verdict comparison
1818
+ * must read `judge.verdict_pass` instead.
1819
+ */
1774
1820
  pass: boolean;
1775
1821
  judge?: {
1822
+ /** What the judge itself concluded; absent on runs recorded before it. */
1823
+ verdict_pass?: boolean;
1776
1824
  secondJudge?: {
1777
1825
  choice?: "pass" | "fail";
1778
1826
  confidence?: number;
@@ -1785,6 +1833,44 @@ declare function secondJudgeFacts(check: SecondJudgeFactsInput): SecondJudgeFact
1785
1833
  /** One honest sentence about the relation; null when corroborated. */
1786
1834
  declare function secondJudgeTakeaway(check: SecondJudgeFactsInput): string | null;
1787
1835
 
1836
+ /**
1837
+ * The judge's compute tool: an arithmetic expression in, an exact value out.
1838
+ *
1839
+ * This is an expression evaluator, not a code-execution sandbox — the
1840
+ * distinction is the security model. The grammar below has numbers, four
1841
+ * arithmetic operations, remainder, exponentiation, parentheses, a fixed
1842
+ * allowlist of math functions, and two constants. A model cannot express
1843
+ * anything else: no strings, no variables, no property access, no loops, no
1844
+ * function definitions. There is no I/O to forbid and nothing to time out —
1845
+ * evaluation is a single linear pass whose only recursion is bounded by the
1846
+ * expression-length cap, with parenthesization nesting tracked explicitly.
1847
+ *
1848
+ * Failures are honest return values (an `{ error }` with the allowlist, the
1849
+ * cap, or the offending operation in the message) so the judge can rephrase,
1850
+ * never exceptions past the tool boundary.
1851
+ */
1852
+ /** A successful evaluation: the raw IEEE-754 double and a display form. */
1853
+ type ComputeSuccess = {
1854
+ value: number;
1855
+ text: string;
1856
+ };
1857
+ /** Every way an expression fails to evaluate. Never thrown. */
1858
+ type ComputeResult = ComputeSuccess | {
1859
+ error: string;
1860
+ };
1861
+ /** Input-length cap; re-checked here although the tool schema also enforces it. */
1862
+ declare const COMPUTE_MAX_EXPR = 512;
1863
+ /** Maximum parenthesization / function-argument nesting depth. */
1864
+ declare const COMPUTE_MAX_DEPTH = 64;
1865
+ /**
1866
+ * Evaluate one arithmetic expression. Pure: no I/O, no ambient state, never
1867
+ * throws. `text` normalizes the double to at most 12 significant digits so a
1868
+ * judge comparing against human-stated figures ("3.5%") is not eyeballing
1869
+ * IEEE remainder digits (`3.4013605442176873` → `"3.40136054422"`,
1870
+ * `0.30000000000000004` → `"0.3"`); `value` keeps the exact double.
1871
+ */
1872
+ declare function evaluateComputeExpression(expression: string): ComputeResult;
1873
+
1788
1874
  /**
1789
1875
  * Check submission compaction (issue #175).
1790
1876
  *
@@ -2613,4 +2699,4 @@ type TranscriptCaptureResult = {
2613
2699
  };
2614
2700
  declare function replayAdapterTranscript(capture: AdapterTranscriptCapture, options: ReplayAdapterTranscriptOptions): Promise<TranscriptCaptureResult>;
2615
2701
 
2616
- 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, type CheckCompaction, type CheckContext, type CheckGroup, type CleanupContext, type CollectDeliverablesContext, type CollectedDeliverables, 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, 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 };
2702
+ 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 };