@hue-run/sdk 0.1.5 → 0.2.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/ENVIRONMENTS.md +182 -0
- package/EVALUATIONS.md +12 -0
- package/README.md +194 -18
- package/dist/ai-sdk.d.ts +9 -1
- package/dist/ai-sdk.js +34 -8
- package/dist/client.d.ts +121 -6
- package/dist/client.js +329 -56
- package/dist/config.d.ts +11 -2
- package/dist/config.js +36 -7
- package/dist/environment/client.d.ts +73 -0
- package/dist/environment/client.js +209 -0
- package/dist/environment/tools.d.ts +30 -0
- package/dist/environment/tools.js +24 -0
- package/dist/environment/types.d.ts +429 -0
- package/dist/environment/types.js +1 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +2 -0
- package/dist/evals/attempt.d.ts +454 -0
- package/dist/evals/attempt.js +687 -0
- package/dist/evals/client.d.ts +99 -5
- package/dist/evals/client.js +136 -7
- package/dist/evals/environment-evidence.d.ts +6 -0
- package/dist/evals/environment-evidence.js +123 -0
- package/dist/evals/environment-json.d.ts +3 -0
- package/dist/evals/environment-json.js +76 -0
- package/dist/evals/json.d.ts +9 -1
- package/dist/evals/json.js +14 -6
- package/dist/evals/runner.d.ts +61 -2
- package/dist/evals/runner.js +71 -9
- package/dist/evals/scorer-publication.d.ts +2 -0
- package/dist/evals/scorer-publication.js +84 -0
- package/dist/evals/scorers.d.ts +11 -0
- package/dist/evals/scorers.js +56 -5
- package/dist/evals/simulation.d.ts +184 -0
- package/dist/evals/simulation.js +603 -0
- package/dist/evals/types.d.ts +304 -0
- package/dist/evals.d.ts +5 -1
- package/dist/evals.js +3 -1
- package/dist/experimental-telemetry.d.ts +8 -0
- package/dist/experimental-telemetry.js +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/managed.d.ts +51 -1
- package/dist/managed.js +11 -1
- package/dist/privacy.d.ts +2 -0
- package/dist/privacy.js +16 -1
- package/dist/receipt.d.ts +12 -1
- package/dist/receipt.js +10 -1
- package/dist/safety.d.ts +1 -2
- package/dist/snapshot.js +4 -0
- package/dist/transport.d.ts +41 -9
- package/dist/transport.js +80 -22
- package/dist/types.d.ts +144 -8
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/package.json +51 -15
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { HueClient } from "../client.js";
|
|
2
|
+
import { type EnvironmentClient } from "../environment/client.js";
|
|
3
|
+
import { type EnvironmentTool } from "../environment/tools.js";
|
|
4
|
+
import type { EnvironmentDefinition, EnvironmentIdentity } from "../environment/types.js";
|
|
5
|
+
import { type EvaluationClient } from "./client.js";
|
|
6
|
+
import { type ActualAgentManifestInputV2, type AttemptConnectionBundleV2, type RequestedAttemptProviderV2 } from "./attempt.js";
|
|
7
|
+
import { type RunnerReport } from "./runner.js";
|
|
8
|
+
import type { ExperimentCase, Identity, JsonValue, LocalScorer, ScorerDefinition, SimulationMcpCapability } from "./types.js";
|
|
9
|
+
/** Repository-authored scorer identity and its public definition or local binding. */
|
|
10
|
+
export interface RepositorySimulationScorer extends Identity {
|
|
11
|
+
/** Scorer definition to publish, or a local callback bound to its source digest. */
|
|
12
|
+
scorer: ScorerDefinition | LocalScorer;
|
|
13
|
+
}
|
|
14
|
+
/** One repository-authored scenario case. */
|
|
15
|
+
export interface RepositorySimulationCase {
|
|
16
|
+
/** Stable key unique within this scenario dataset. */
|
|
17
|
+
externalKey: string;
|
|
18
|
+
/** JSON inputs passed to the local target callback. */
|
|
19
|
+
inputs: JsonValue;
|
|
20
|
+
/** Optional reference output for scorers. */
|
|
21
|
+
expected?: JsonValue;
|
|
22
|
+
/** Optional caller-owned case metadata. */
|
|
23
|
+
metadata?: Record<string, JsonValue>;
|
|
24
|
+
}
|
|
25
|
+
/** Immutable app-authored experiment reference or repository-authored scenario definition. */
|
|
26
|
+
export type SimulationScenario = {
|
|
27
|
+
/** Select an existing app-authored immutable experiment template. */
|
|
28
|
+
kind: "experiment";
|
|
29
|
+
/** Experiment to clone into a fresh attempt. */
|
|
30
|
+
experimentId: string;
|
|
31
|
+
} | {
|
|
32
|
+
/** Publish and resolve the repository-authored definition. */
|
|
33
|
+
kind: "repository";
|
|
34
|
+
/** Experiment display name. */
|
|
35
|
+
name: string;
|
|
36
|
+
/** Stable dataset slug used for immutable version resolution. */
|
|
37
|
+
slug: string;
|
|
38
|
+
/** Optional experiment/dataset description. */
|
|
39
|
+
description?: string;
|
|
40
|
+
/** Environment identity and authored world definition. */
|
|
41
|
+
environment: EnvironmentIdentity & {
|
|
42
|
+
/** Definition normalized and published as an immutable version. */
|
|
43
|
+
definition: EnvironmentDefinition;
|
|
44
|
+
};
|
|
45
|
+
/** Cases published into one frozen dataset version. */
|
|
46
|
+
cases: RepositorySimulationCase[];
|
|
47
|
+
/** Scorers published and pinned by immutable version. */
|
|
48
|
+
scorers: RepositorySimulationScorer[];
|
|
49
|
+
/** JSON configuration passed to every target callback. */
|
|
50
|
+
config?: JsonValue;
|
|
51
|
+
};
|
|
52
|
+
/** Progress emitted without target output, credentials or other sensitive content. */
|
|
53
|
+
export type SimulationProgress = {
|
|
54
|
+
/** Emitted as soon as the inspectable experiment exists. */
|
|
55
|
+
type: "run_created";
|
|
56
|
+
/** Fresh experiment identity. */
|
|
57
|
+
experimentId: string;
|
|
58
|
+
/** Browser URL for inspecting progress and evidence. */
|
|
59
|
+
runUrl: string;
|
|
60
|
+
} | {
|
|
61
|
+
/** World/target lifecycle event. */
|
|
62
|
+
type: "world_created" | "target_started" | "world_sealed";
|
|
63
|
+
/** Fresh experiment identity. */
|
|
64
|
+
experimentId: string;
|
|
65
|
+
/** Target execution identity. */
|
|
66
|
+
executionId: string;
|
|
67
|
+
/** Frozen experiment-case identity. */
|
|
68
|
+
caseId: string;
|
|
69
|
+
/** Isolated simulated-world identity. */
|
|
70
|
+
environmentRunId: string;
|
|
71
|
+
} | {
|
|
72
|
+
/** Strict provider-profile preflight decision. */
|
|
73
|
+
type: "attempt_prepared";
|
|
74
|
+
/** Fresh experiment identity. */
|
|
75
|
+
experimentId: string;
|
|
76
|
+
/** Target execution identity. */
|
|
77
|
+
executionId: string;
|
|
78
|
+
/** Frozen experiment-case identity. */
|
|
79
|
+
caseId: string;
|
|
80
|
+
/** Isolated simulated-world identity. */
|
|
81
|
+
environmentRunId: string;
|
|
82
|
+
/** Stable attempt binding identity. */
|
|
83
|
+
bindingId: string;
|
|
84
|
+
/** Whether strict parity was established. */
|
|
85
|
+
status: "ready" | "environment_incomplete";
|
|
86
|
+
/** Stable nonsecret finding codes. */
|
|
87
|
+
findingCodes: string[];
|
|
88
|
+
/** Credential-free execution manifest digest for ready attempts. */
|
|
89
|
+
executionManifestDigest?: AttemptConnectionBundleV2["parity"]["executionManifestDigest"];
|
|
90
|
+
};
|
|
91
|
+
/** Context supplied to the existing local agent callback for one case attempt. */
|
|
92
|
+
export interface SimulationTargetContext {
|
|
93
|
+
/** Frozen experiment configuration. */
|
|
94
|
+
config: JsonValue;
|
|
95
|
+
/** Frozen case including its immutable environment-version pin. */
|
|
96
|
+
item: ExperimentCase;
|
|
97
|
+
/** Target execution identity. */
|
|
98
|
+
executionId: string;
|
|
99
|
+
/** Stable world identity for adapter control operations such as coverage reporting. */
|
|
100
|
+
environmentRunId: string;
|
|
101
|
+
/** Framework-neutral local callables backed by this attempt's isolated world. */
|
|
102
|
+
tools: Record<string, EnvironmentTool>;
|
|
103
|
+
/** Short-lived capability for providers that execute MCP remotely. */
|
|
104
|
+
mcp: SimulationMcpCapability;
|
|
105
|
+
/** Credential-bearing provider connections for this callback only. Hue never
|
|
106
|
+
* checkpoints, logs or adds this response to parity digests. */
|
|
107
|
+
connectionBundle?: AttemptConnectionBundleV2;
|
|
108
|
+
/** Cancellation is cooperative: pass this signal into the real agent/provider call. */
|
|
109
|
+
signal?: AbortSignal;
|
|
110
|
+
}
|
|
111
|
+
/** Options for {@link runSimulation}. */
|
|
112
|
+
export interface RunSimulationOptions {
|
|
113
|
+
/** Evaluation client for the target Hue project. */
|
|
114
|
+
client: EvaluationClient;
|
|
115
|
+
/** Environment client for the same Hue origin and project. */
|
|
116
|
+
environmentClient: EnvironmentClient;
|
|
117
|
+
/** Hue telemetry client used for target and tool spans. */
|
|
118
|
+
hue: HueClient;
|
|
119
|
+
/** Dedicated private directory for resumable checkpoints. */
|
|
120
|
+
checkpointDirectory: string;
|
|
121
|
+
/** App-authored reference or repository-authored scenario. */
|
|
122
|
+
scenario: SimulationScenario;
|
|
123
|
+
/** Required privacy decision for saved target/scorer content. */
|
|
124
|
+
persistResultContent: boolean;
|
|
125
|
+
/** Required trace receipt policy for every target attempt. */
|
|
126
|
+
traceEvidence: {
|
|
127
|
+
/** Wait for acknowledged trace/log export. */
|
|
128
|
+
mode: "required";
|
|
129
|
+
} | {
|
|
130
|
+
/** Explicitly omit stored trace evidence. */
|
|
131
|
+
mode: "omit";
|
|
132
|
+
/** Bounded explanation for the omission. */
|
|
133
|
+
reason: string;
|
|
134
|
+
};
|
|
135
|
+
/** Local scorer callbacks bound by their declared source digests. */
|
|
136
|
+
localScorers?: LocalScorer[];
|
|
137
|
+
/** Cases in flight, 1–16; defaults to 1. */
|
|
138
|
+
concurrency?: number;
|
|
139
|
+
/** JSON Schema worker deadline in milliseconds. */
|
|
140
|
+
schemaTimeoutMillis?: number;
|
|
141
|
+
/** Per-world action ceiling, 1–500. */
|
|
142
|
+
maxSteps?: number;
|
|
143
|
+
/** Per-world lease in seconds, 1–86400. */
|
|
144
|
+
ttlSeconds?: number;
|
|
145
|
+
/** Cooperative caller cancellation signal. */
|
|
146
|
+
signal?: AbortSignal;
|
|
147
|
+
/** Optional display name for the fresh experiment. */
|
|
148
|
+
runName?: string;
|
|
149
|
+
/** Opt into immutable provider-profile preflight. Provider selection and the MCP
|
|
150
|
+
* projection are required together. Omitted actual evidence normalizes to explicit
|
|
151
|
+
* V2 missing evidence; it is never assumed equal to the baseline. */
|
|
152
|
+
actualAgentManifest?: ActualAgentManifestInputV2 | ((context: {
|
|
153
|
+
/** Frozen experiment configuration. */
|
|
154
|
+
config: JsonValue;
|
|
155
|
+
/** Frozen case selected for this attempt. */
|
|
156
|
+
item: ExperimentCase;
|
|
157
|
+
/** Cooperative caller cancellation signal. */
|
|
158
|
+
signal?: AbortSignal;
|
|
159
|
+
}) => ActualAgentManifestInputV2 | Promise<ActualAgentManifestInputV2>);
|
|
160
|
+
/** Exact provider instances and ordered surfaces asserted for strict preflight. */
|
|
161
|
+
requestedProviders?: RequestedAttemptProviderV2[];
|
|
162
|
+
/** Requested MCP surface projected to the backwards-compatible `context.mcp`. */
|
|
163
|
+
mcpSurface?: {
|
|
164
|
+
/** Provider instance selected from `requestedProviders`. */
|
|
165
|
+
providerInstanceKey: string;
|
|
166
|
+
/** Selected MCP surface. */
|
|
167
|
+
surfaceKey: "google.gmail/mcp" | "slack/mcp";
|
|
168
|
+
};
|
|
169
|
+
/** Invokes the existing local agent exactly once for this attempt. */
|
|
170
|
+
target(inputs: JsonValue, context: SimulationTargetContext): JsonValue | undefined | Promise<JsonValue | undefined>;
|
|
171
|
+
/** Receives bounded nonsecret lifecycle progress. */
|
|
172
|
+
onProgress?(event: SimulationProgress): void | Promise<void>;
|
|
173
|
+
}
|
|
174
|
+
/** Completed simulation report with its inspectable experiment identity. */
|
|
175
|
+
export interface SimulationReport extends RunnerReport {
|
|
176
|
+
/** Fresh experiment created for this invocation. */
|
|
177
|
+
experimentId: string;
|
|
178
|
+
/** Browser URL joining task, trace, world evidence and scoring. */
|
|
179
|
+
runUrl: string;
|
|
180
|
+
}
|
|
181
|
+
/** Run an existing agent callback against one fresh hosted world per case. The helper
|
|
182
|
+
* owns immutable resolution, execution linkage, finalization, scoring and resumable uploads.
|
|
183
|
+
*/
|
|
184
|
+
export declare function runSimulation(options: RunSimulationOptions): Promise<SimulationReport>;
|