@constal/sdk 1.0.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.
@@ -0,0 +1,2523 @@
1
+ /** A secret exposed only to integration code through a declared Credential slot. */
2
+ interface IntegrationSecret {
3
+ value: string;
4
+ version: number;
5
+ fingerprint: Hash;
6
+ credential: CredentialCRN;
7
+ }
8
+ interface IntegrationEgressRequest {
9
+ url: string;
10
+ method: string;
11
+ headers: Record<string, string>;
12
+ bodyBase64?: string;
13
+ maximumResponseBytes: number;
14
+ maximumRedirects: number;
15
+ }
16
+ interface IntegrationEgressResponse {
17
+ url: string;
18
+ status: number;
19
+ headers: Record<string, string>;
20
+ bodyBase64: string;
21
+ bytes: number;
22
+ }
23
+ interface IntegrationState {
24
+ get<T>(key: string): Promise<T | null>;
25
+ set(key: string, value: unknown): Promise<void>;
26
+ delete(key: string): Promise<void>;
27
+ list(prefix: string): Promise<string[]>;
28
+ invalidate(prefix: string): Promise<void>;
29
+ }
30
+ /** Capabilities shared by user-authored Connection and Credential Provider code. */
31
+ interface IntegrationContext {
32
+ readonly config: unknown;
33
+ secret(slot: string): Promise<IntegrationSecret>;
34
+ state: IntegrationState;
35
+ store(bytes: ArrayBuffer | string): Promise<Ref>;
36
+ audit(record: unknown): void;
37
+ egress(request: IntegrationEgressRequest): Promise<IntegrationEgressResponse>;
38
+ }
39
+ interface IntegrationEgressRule {
40
+ operations: string[];
41
+ origin: string;
42
+ pathPrefix?: string;
43
+ pathExact?: string;
44
+ methods: string[];
45
+ }
46
+ interface IntegrationEgressPolicy {
47
+ rules: IntegrationEgressRule[];
48
+ }
49
+ /** Operation declaration accepted from a user-authored Connection package. */
50
+ interface ConnectionOperation {
51
+ op: string;
52
+ description: string;
53
+ schema: object;
54
+ resultSchema: object;
55
+ effect: EffectClass;
56
+ recovery: Recovery;
57
+ async: boolean;
58
+ usage: {
59
+ meter: "none";
60
+ priceTable: null;
61
+ };
62
+ }
63
+ interface ConnectionIdentity {
64
+ crn: string;
65
+ hash: Hash;
66
+ kind: InvokableKind;
67
+ }
68
+ interface ConnectionRequest<A = unknown> {
69
+ resource: ConnectionIdentity;
70
+ op: string;
71
+ args: A;
72
+ idempotencyKey: string;
73
+ handleId: string | null;
74
+ }
75
+ interface ConnectionRecoveryRequest<A = unknown> extends ConnectionRequest<A> {
76
+ }
77
+ interface ConnectionCancelRequest {
78
+ resource: ConnectionIdentity;
79
+ op: string;
80
+ handleId: string;
81
+ idempotencyKey: string;
82
+ }
83
+ /** Provider-observed usage returned when an asynchronous Connection settles. */
84
+ interface ConnectionUsageReport {
85
+ cpuMs: number | null;
86
+ wallMs: number;
87
+ providerUnits?: Record<string, number>;
88
+ priceTable: {
89
+ id: string;
90
+ version: string;
91
+ hash: Hash;
92
+ };
93
+ microUsd: number;
94
+ quality: "reported" | "measured" | "estimated";
95
+ }
96
+ type ConnectionRecoveryResult = {
97
+ status: "completed";
98
+ result: unknown;
99
+ usage?: ConnectionUsageReport;
100
+ } | {
101
+ status: "failed";
102
+ error: unknown;
103
+ usage?: ConnectionUsageReport;
104
+ } | {
105
+ status: "in-progress";
106
+ retryAfterMs?: number;
107
+ } | {
108
+ status: "not-performed";
109
+ } | {
110
+ status: "unknown";
111
+ error?: unknown;
112
+ retryAfterMs?: number;
113
+ };
114
+ /** A remote API returned an HTTP failure. The disposition controls recovery after the call crossed the network boundary. */
115
+ declare class ApiError extends Error {
116
+ readonly status: number;
117
+ readonly body: string;
118
+ readonly disposition: "terminal" | "uncertain";
119
+ constructor(status: number, body: string, disposition?: "terminal" | "uncertain");
120
+ }
121
+ /** The integration can prove that no external request was sent. */
122
+ declare class IntegrationRequestNotSent extends Error {
123
+ constructor(message?: string);
124
+ }
125
+ /** A remote API response was terminally invalid or rejected. */
126
+ declare class TerminalIntegrationFailure extends Error {
127
+ constructor(message?: string);
128
+ }
129
+ declare function integrationEgressPolicy(value: unknown): IntegrationEgressPolicy;
130
+
131
+ type ScorerKind = "code" | "judge" | "human";
132
+ type ScorerApplies = "turn" | "reply" | "fact" | "trajectory" | "case";
133
+ type EvalMode = "fresh" | "replay" | "shadow";
134
+ type VerdictSamplingMode = "gate" | "sample" | "suite" | "label";
135
+ interface ScorerRef {
136
+ crn: ScorerCRN;
137
+ version: string;
138
+ hash: Hash;
139
+ }
140
+ interface EvalSubject {
141
+ session: string;
142
+ run: string;
143
+ fact: FactRef | null;
144
+ turn: Hash | null;
145
+ bundleHash: Hash;
146
+ policyHash: Hash;
147
+ resourcesHash: Hash;
148
+ model: {
149
+ id: string;
150
+ policyVersion: string;
151
+ } | null;
152
+ inputHash: Hash;
153
+ }
154
+ interface Verdict {
155
+ kind: "verdict";
156
+ subject: EvalSubject;
157
+ scorer: ScorerRef;
158
+ score: number | null;
159
+ pass: boolean | null;
160
+ dimensions: Record<string, number> | null;
161
+ evidence: unknown;
162
+ sampling: {
163
+ mode: VerdictSamplingMode;
164
+ rate: number | null;
165
+ suite: string | null;
166
+ };
167
+ cost: Cost | null;
168
+ }
169
+ interface ScorerEvaluation {
170
+ scorer: ScorerRef;
171
+ score: number | null;
172
+ pass: boolean | null;
173
+ dimensions: Record<string, number> | null;
174
+ evidence: unknown;
175
+ cost: Cost | null;
176
+ }
177
+ interface ScorerVerdictIntent {
178
+ position: string;
179
+ applies: ScorerApplies;
180
+ subjectHash: Hash;
181
+ evaluation: ScorerEvaluation;
182
+ }
183
+ interface CodeScorerDefinition {
184
+ kind: "code";
185
+ programRef: Ref;
186
+ }
187
+ interface JudgeScorerDefinition {
188
+ kind: "judge";
189
+ agent: CRN;
190
+ /** Immutable Agent Resource version used for every judgment. */
191
+ agentResourceHash: Hash;
192
+ rubricRef: Ref;
193
+ scale: {
194
+ min: number;
195
+ max: number;
196
+ };
197
+ threshold: number | null;
198
+ }
199
+ interface HumanScorerDefinition {
200
+ kind: "human";
201
+ channel: CRN;
202
+ /** Immutable Channel Resource version used to route the labeling wait. */
203
+ channelResourceHash: Hash;
204
+ schema: object;
205
+ instructionsRef: Ref;
206
+ }
207
+ interface ScorerDef {
208
+ id: string;
209
+ version: string;
210
+ kind: ScorerKind;
211
+ applies: ScorerApplies;
212
+ code?: Omit<CodeScorerDefinition, "kind">;
213
+ judge?: Omit<JudgeScorerDefinition, "kind">;
214
+ human?: Omit<HumanScorerDefinition, "kind">;
215
+ }
216
+ interface CaseRow {
217
+ caseId: string;
218
+ input: unknown;
219
+ context: {
220
+ from?: BranchRef;
221
+ memory?: Record<string, unknown>;
222
+ } | null;
223
+ expected: unknown | null;
224
+ scorers: ScorerRef[];
225
+ source: {
226
+ session: string;
227
+ run?: string;
228
+ fact: FactRef;
229
+ agent?: string;
230
+ customer?: CustomerTenantCRN | null;
231
+ } | null;
232
+ tags: Record<string, string>;
233
+ }
234
+ interface DatasetRef {
235
+ crn: DatasetCRN;
236
+ version: string;
237
+ hash: Hash;
238
+ }
239
+ interface DatasetDraft {
240
+ id: string;
241
+ namespace: string;
242
+ displayName: string;
243
+ description: string;
244
+ revision: number;
245
+ cases: number;
246
+ published: DatasetRef | null;
247
+ createdAt: number;
248
+ updatedAt: number;
249
+ }
250
+ interface CaptureCaseRequest {
251
+ dataset: string;
252
+ caseId?: string;
253
+ source: {
254
+ agent: string;
255
+ session: string;
256
+ run: string;
257
+ fact?: FactRef;
258
+ customer?: CustomerTenantCRN | null;
259
+ };
260
+ expected?: unknown;
261
+ scorers?: ScorerRef[];
262
+ tags?: Record<string, string>;
263
+ }
264
+ /** Address needed to place an asynchronous verdict on the judged Session ledger. */
265
+ interface EvalSubjectSource {
266
+ agent: CRN;
267
+ customer: CustomerTenantCRN | null;
268
+ }
269
+ interface ScoreRequest {
270
+ /** Caller-stable identity. The platform derives one from the invocation when omitted. */
271
+ scoreId?: string;
272
+ source: EvalSubjectSource;
273
+ subject: EvalSubject;
274
+ scorer: ScorerRef;
275
+ /** The bounded turn, reply, fact, trajectory, or case accepted by the Scorer. */
276
+ value: unknown;
277
+ sampling: {
278
+ mode: "sample" | "suite";
279
+ rate: number | null;
280
+ suite: string | null;
281
+ };
282
+ }
283
+ interface LabelRequest {
284
+ source: EvalSubjectSource;
285
+ subject: EvalSubject;
286
+ scorer: ScorerRef;
287
+ value: unknown;
288
+ }
289
+ interface RequestLabelRequest {
290
+ /** Caller-stable identity used for the durable wait and idempotent verdict. */
291
+ labelId: string;
292
+ source: EvalSubjectSource;
293
+ subject: EvalSubject;
294
+ scorer: ScorerRef;
295
+ timeoutMs?: number;
296
+ }
297
+ interface SuiteFact {
298
+ kind: "suite";
299
+ hash: FactRef;
300
+ dataset: DatasetRef;
301
+ subjectSpec: {
302
+ agent: CRN;
303
+ bundleHash: Hash;
304
+ policyHash: Hash;
305
+ /** Agent Resource bindings before the Suite-wide eval Resource boundary is applied. */
306
+ agentResourcesHash: Hash;
307
+ resourcesHash: Hash;
308
+ modelPolicy: string;
309
+ };
310
+ mode: EvalMode;
311
+ cases: number;
312
+ completed: number;
313
+ errored: number;
314
+ scores: Record<string, {
315
+ mean: number;
316
+ p50: number;
317
+ p10: number;
318
+ passRate: number | null;
319
+ n: number;
320
+ }>;
321
+ compare: {
322
+ baseline: FactRef;
323
+ deltas: Record<string, number>;
324
+ significant: Record<string, boolean>;
325
+ } | null;
326
+ /** Agreement of one pinned Judge Scorer with human labels stored in Dataset case.expected. */
327
+ calibration: JudgeCalibration | null;
328
+ verdictsRef: Ref;
329
+ /** Per-case replay request divergences; null outside replay mode. */
330
+ divergencesRef: Ref | null;
331
+ cost: Cost;
332
+ }
333
+ interface EvalDivergence {
334
+ position: string;
335
+ kind: "model" | "resource";
336
+ sourceOpHash: Hash | null;
337
+ candidateOpHash: Hash;
338
+ sourceBodyHash: Hash | null;
339
+ candidateBodyHash: Hash;
340
+ effect: "read-only" | "idempotent" | "reconcilable" | "non-idempotent";
341
+ resolution: "recorded" | "live" | "replay-unsafe" | "source-missing";
342
+ diff: {
343
+ paths: Array<{
344
+ path: string;
345
+ source: unknown;
346
+ candidate: unknown;
347
+ }>;
348
+ truncated: boolean;
349
+ };
350
+ at: number;
351
+ }
352
+ interface RunSuiteRequest {
353
+ /** Caller-stable job identity. The platform generates one when omitted. */
354
+ suiteId?: string;
355
+ dataset: DatasetRef;
356
+ subject: {
357
+ agent: CRN;
358
+ bundle: Hash | "current";
359
+ resource?: Hash;
360
+ };
361
+ mode: EvalMode;
362
+ scorers?: ScorerRef[];
363
+ concurrency: number;
364
+ budgetMicroUsd: number;
365
+ /** Replay-only handling for changed Model requests. */
366
+ onDivergence?: "recorded" | "live";
367
+ /** Compute Judge agreement against `{ score, pass? }` human labels in every case's `expected` field. */
368
+ calibration?: {
369
+ judge: ScorerRef;
370
+ tolerance: number;
371
+ };
372
+ }
373
+ interface JudgeCalibration {
374
+ judge: ScorerRef;
375
+ labels: number;
376
+ tolerance: number;
377
+ exactAgreement: number;
378
+ toleranceAgreement: number;
379
+ meanAbsoluteError: number;
380
+ correlation: number | null;
381
+ kappa: number | null;
382
+ }
383
+ interface EvalComparison {
384
+ suite: FactRef;
385
+ baseline: FactRef;
386
+ deltas: Record<string, number>;
387
+ significant: Record<string, boolean>;
388
+ }
389
+ interface CompareSuitesRequest {
390
+ suite: Ref;
391
+ baseline: Ref;
392
+ }
393
+ interface SetEvalBaselineRequest {
394
+ agent: CRN;
395
+ suite: Ref;
396
+ }
397
+ interface DeploySuiteGate {
398
+ id: string;
399
+ dataset: DatasetRef;
400
+ scorers: ScorerRef[];
401
+ /** Deploy admission always evaluates the candidate against recorded production cases. */
402
+ mode: "replay";
403
+ concurrency: number;
404
+ budgetMicroUsd: number;
405
+ minPassRate: number | null;
406
+ baseline: Ref | null;
407
+ maxRegression: number | null;
408
+ }
409
+ interface AgentDeployPolicy {
410
+ suites: DeploySuiteGate[];
411
+ }
412
+ type TrainingMethod = "sft" | "rl";
413
+ type TrainingJobState = "queued" | "running" | "evaluating" | "succeeded" | "failed" | "cancelled";
414
+ interface TrainingRecipe {
415
+ method: TrainingMethod;
416
+ baseModel: string;
417
+ dataset: DatasetRef;
418
+ validationDataset: DatasetRef | null;
419
+ scorers: ScorerRef[];
420
+ loraRank: number;
421
+ learningRate: number;
422
+ epochs: number;
423
+ batchSize: number;
424
+ /** RL rollout count per prompt. SFT always uses 1. */
425
+ groupSize: number;
426
+ temperature: number;
427
+ seed: number;
428
+ checkpointEvery: number;
429
+ evalEvery: number;
430
+ maxTrainTokens: number;
431
+ maxSampleTokens: number;
432
+ budgetMicroUsd: number;
433
+ }
434
+ interface TrainingJobFact {
435
+ kind: "training";
436
+ job: string;
437
+ provider: {
438
+ resource: CRN;
439
+ resourceHash: Hash;
440
+ runId: string | null;
441
+ };
442
+ recipe: TrainingRecipe;
443
+ state: TrainingJobState;
444
+ step: number;
445
+ checkpoints: {
446
+ step: number;
447
+ ref: Ref;
448
+ metrics: Record<string, number>;
449
+ format?: string;
450
+ createdAt?: number;
451
+ }[];
452
+ evaluation: FactRef | null;
453
+ outputModel: {
454
+ id: string;
455
+ weightsRef: Ref;
456
+ } | null;
457
+ usage: {
458
+ trainTokens: number;
459
+ prefillTokens: number;
460
+ cachedPrefillTokens: number;
461
+ sampleTokens: number;
462
+ };
463
+ cost: Cost | null;
464
+ error: {
465
+ code: string;
466
+ message: string;
467
+ } | null;
468
+ }
469
+
470
+ /** Stable capability implemented by every pluggable training provider. */
471
+ declare const TRAINING_PROVIDER_CAPABILITY: CapabilityContractRef;
472
+ interface TrainingModelOffer {
473
+ id: string;
474
+ name: string;
475
+ providerModel: string;
476
+ contextTokens: number;
477
+ pricing: {
478
+ currency: "USD";
479
+ unit: "million_tokens";
480
+ prefillMicroUsd: number;
481
+ cachedPrefillMicroUsd: number;
482
+ sampleMicroUsd: number;
483
+ trainMicroUsd: number;
484
+ };
485
+ }
486
+ /** Immutable, provider-authored discovery metadata. It never grants invocation authority. */
487
+ interface TrainingProviderMetadata {
488
+ lifecycleVersion: 1;
489
+ methods: Array<"sft" | "rl">;
490
+ models: TrainingModelOffer[];
491
+ checkpoints: {
492
+ formats: string[];
493
+ resume: boolean;
494
+ fork: boolean;
495
+ };
496
+ }
497
+ /** Exact Connection Resource selected for a Training Job. */
498
+ interface TrainingProviderPin {
499
+ crn: CRN;
500
+ hash: Hash;
501
+ }
502
+ /** A durable checkpoint selected as the starting point of a new job. */
503
+ interface TrainingResumePoint {
504
+ job: string;
505
+ step: number;
506
+ ref: Ref;
507
+ }
508
+ interface TrainingUsageUnits {
509
+ trainTokens: number;
510
+ prefillTokens: number;
511
+ cachedPrefillTokens: number;
512
+ sampleTokens: number;
513
+ }
514
+ interface StartTrainingRequest {
515
+ jobId?: string;
516
+ /** Filled by admission. Providers must reject a pin that is not their own Resource. */
517
+ provider?: TrainingProviderPin;
518
+ /** Null starts from the advertised base model. A non-null value creates a resumable fork. */
519
+ resumeFrom?: TrainingResumePoint | null;
520
+ recipe: TrainingRecipe;
521
+ outputModelId: string;
522
+ }
523
+ interface TrainingJobReference {
524
+ job: string;
525
+ state: TrainingJobState;
526
+ }
527
+ interface TrainingJobStatus {
528
+ id: string;
529
+ state: TrainingJobState;
530
+ phase: string;
531
+ provider: TrainingJobFact["provider"];
532
+ recipe: TrainingRecipe;
533
+ method: TrainingRecipe["method"];
534
+ baseModel: string;
535
+ outputModelId: string;
536
+ step: number;
537
+ epoch: number;
538
+ total: number;
539
+ completed: number;
540
+ usage: TrainingUsageUnits;
541
+ costMicroUsd: number;
542
+ checkpoints: TrainingJobFact["checkpoints"];
543
+ evaluation: TrainingJobFact["evaluation"];
544
+ outputModel: TrainingJobFact["outputModel"];
545
+ result: TrainingJobFact | null;
546
+ error: {
547
+ code: string;
548
+ message: string;
549
+ } | null;
550
+ retry: {
551
+ count: number;
552
+ error: {
553
+ code: string;
554
+ message: string;
555
+ };
556
+ } | null;
557
+ createdAt: number;
558
+ updatedAt: number;
559
+ }
560
+ declare function trainingProviderMetadata(value: unknown): TrainingProviderMetadata;
561
+ declare function trainingRecipe(value: unknown): TrainingRecipe;
562
+ declare function startTrainingRequest(value: unknown): StartTrainingRequest;
563
+ /** Stable, model-agnostic completion rendering used by the v1 training loop. */
564
+ declare function renderTrainingCompletion(input: unknown, expected?: unknown): {
565
+ prompt: string;
566
+ completion: string | null;
567
+ };
568
+
569
+ interface GatewayCredentialSlotSetup {
570
+ title: string;
571
+ description?: string;
572
+ documentationUrl?: string;
573
+ /** Optional slots may be omitted when the selected connection mode does not need authentication. */
574
+ required?: boolean;
575
+ /** Credential Provider id suggested by the package author. This is a setup hint, not an authority grant. */
576
+ provider?: string;
577
+ }
578
+ interface GatewayConfigEgressBinding {
579
+ /** Top-level config property containing the exact HTTPS endpoint. */
580
+ urlProperty: string;
581
+ operations: string[];
582
+ methods: string[];
583
+ }
584
+ interface GatewayDiscoverySetup {
585
+ /** Read-only Connection operation used to inspect the remote service during setup. */
586
+ operation: string;
587
+ /** Required, read-only top-level array seeded empty during discovery and populated from its signed result before registration. */
588
+ resultConfigProperty: string;
589
+ }
590
+ /** Immutable formats accepted by a Gateway that can deploy trained checkpoints for inference. */
591
+ interface CheckpointImportMetadata {
592
+ lifecycleVersion: 1;
593
+ formats: string[];
594
+ }
595
+ /** Trusted checkpoint provenance passed to the Gateway's asynchronous import operation. */
596
+ interface CheckpointImportRequest {
597
+ deploymentId: string;
598
+ source: {
599
+ provider: TrainingProviderPin;
600
+ job: string;
601
+ baseModel: string;
602
+ checkpoint: {
603
+ step: number;
604
+ ref: Ref;
605
+ format: string;
606
+ createdAt: number | null;
607
+ };
608
+ };
609
+ /** Content-addressed provider descriptor resolved by the platform from `source.checkpoint.ref`. */
610
+ artifact: {
611
+ ref: Ref;
612
+ value: Record<string, unknown>;
613
+ };
614
+ model: {
615
+ id: string;
616
+ displayName: string;
617
+ temperature: number;
618
+ };
619
+ }
620
+ /** Exact Gateway and trusted import request executed by the platform Evals Agent. */
621
+ interface CheckpointDeploymentRequest {
622
+ gateway: {
623
+ crn: CRN;
624
+ hash: Hash;
625
+ };
626
+ import: CheckpointImportRequest;
627
+ }
628
+ /** Native Artifact CAS address for a canonical JSON checkpoint descriptor. */
629
+ declare function checkpointArtifactRef(value: Record<string, unknown>): Promise<Ref>;
630
+ /** Immutable, user-facing installation metadata carried by a Gateway package. */
631
+ interface GatewayPackageMetadata {
632
+ lifecycleVersion: 1;
633
+ displayName: string;
634
+ description: string;
635
+ documentationUrl?: string;
636
+ service?: string;
637
+ credentialSlots: Record<string, GatewayCredentialSlotSetup>;
638
+ /** Static offers bundled with this immutable package. Empty when discovery is manual or runtime-specific. */
639
+ modelOffers: GatewayModelOffer[];
640
+ capabilities: CapabilityContractRef[];
641
+ billing: {
642
+ upstreamPayer: UpstreamPayer;
643
+ };
644
+ egress: IntegrationEgressPolicy;
645
+ /** Install-time templates compiled to exact Resource egress rules. */
646
+ configEgress?: GatewayConfigEgressBinding[];
647
+ /** Optional reviewed discovery flow. Discovery never mutates an installed Resource. */
648
+ discovery?: GatewayDiscoverySetup;
649
+ /** Present when this Connection implements the Training Provider lifecycle contract. */
650
+ training?: TrainingProviderMetadata;
651
+ /** Present when this Connection can import a trained checkpoint into an inference Model. */
652
+ checkpointImport?: CheckpointImportMetadata;
653
+ }
654
+ interface GatewayDefinition<C = unknown> extends Omit<GatewayPackageMetadata, "lifecycleVersion" | "modelOffers"> {
655
+ id: string;
656
+ version: string;
657
+ kind: Exclude<InvokableKind, "model" | "memory">;
658
+ configSchema: object;
659
+ modelOffers?: GatewayModelOffer[];
660
+ catalog(config: C): ConnectionOperation[];
661
+ invoke(request: ConnectionRequest, context: IntegrationContext): Promise<unknown>;
662
+ reconcile?(request: ConnectionRecoveryRequest, context: IntegrationContext): Promise<ConnectionRecoveryResult>;
663
+ cancel?(request: ConnectionCancelRequest, context: IntegrationContext): Promise<void>;
664
+ }
665
+ /** A provider-neutral Training Provider authored on the ordinary Connection package substrate. */
666
+ interface TrainingProviderDefinition<C = unknown> extends GatewayDefinition<C> {
667
+ training: TrainingProviderMetadata;
668
+ }
669
+ interface GatewayModelOffer extends ModelTechnicalCapabilities {
670
+ id: string;
671
+ displayName: string;
672
+ pricing: ModelAdvertisedPricing | null;
673
+ }
674
+ /** Validated user-authored Gateway package. */
675
+ type GatewayPackage<C = unknown> = Readonly<GatewayDefinition<C>> & {
676
+ readonly metadata: GatewayPackageMetadata;
677
+ };
678
+ type GatewayOperation = ConnectionOperation;
679
+ type GatewayRequest<A = unknown> = ConnectionRequest<A>;
680
+ type GatewayRecoveryRequest<A = unknown> = ConnectionRecoveryRequest<A>;
681
+ type GatewayCancelRequest = ConnectionCancelRequest;
682
+ type GatewayRecoveryResult = ConnectionRecoveryResult;
683
+ type GatewayContext = IntegrationContext;
684
+ declare function checkpointImportMetadata(value: unknown): CheckpointImportMetadata;
685
+ declare function checkpointImportRequest(value: unknown): CheckpointImportRequest;
686
+ declare function checkpointDeploymentRequest(value: unknown): CheckpointDeploymentRequest;
687
+ declare function gatewayModelOffer(value: unknown): GatewayModelOffer;
688
+ declare function gatewayPackageMetadata(value: unknown): GatewayPackageMetadata;
689
+ /** Compiles package setup templates into an exact, immutable Resource egress policy. */
690
+ declare function resolveGatewayEgress(metadata: Pick<GatewayPackageMetadata, "egress" | "configEgress">, config: Record<string, unknown>): IntegrationEgressPolicy;
691
+ /** Defines a user-authored Gateway without exposing its platform transport. */
692
+ declare function gateway<C>(definition: GatewayDefinition<C>): GatewayPackage<C>;
693
+ /**
694
+ * Defines an installable Training Provider without creating a parallel package system.
695
+ * The resulting artifact is a Connection package and can be pinned or scoped like every
696
+ * other Resource.
697
+ */
698
+ declare function trainingProvider<C>(definition: TrainingProviderDefinition<C>): GatewayPackage<C>;
699
+ /** Stable capability implemented by every model-completion Gateway. */
700
+ declare const MODEL_COMPLETION_CAPABILITY: CapabilityContractRef;
701
+ /** Stable capability implemented by Gateways that import immutable training checkpoints. */
702
+ declare const MODEL_CHECKPOINT_IMPORT_CAPABILITY: CapabilityContractRef;
703
+ /** Stable capability implemented by remote MCP client Gateways. */
704
+ declare const MCP_CLIENT_CAPABILITY: CapabilityContractRef;
705
+
706
+ /** Kubernetes-compatible, bounded label selectors shared by Resource consumers. */
707
+
708
+ type LabelSelectorOperator = "In" | "NotIn" | "Exists" | "DoesNotExist";
709
+ interface LabelSelectorRequirement {
710
+ key: string;
711
+ operator: LabelSelectorOperator;
712
+ values?: string[];
713
+ }
714
+ interface LabelSelector {
715
+ matchLabels?: Record<string, string>;
716
+ matchExpressions?: LabelSelectorRequirement[];
717
+ }
718
+ interface ResourceSelector<K extends CRNKind = CRNKind> {
719
+ resourceKind: K;
720
+ selector: LabelSelector;
721
+ }
722
+ declare function resourceLabelMap(value: unknown, options?: {
723
+ allowProtected?: boolean;
724
+ }): Record<string, string>;
725
+ declare function labelSelector(value: unknown): LabelSelector;
726
+ declare function resourceSelector<K extends CRNKind>(value: unknown, allowedKinds: readonly K[]): ResourceSelector<K>;
727
+ declare function matchesLabelSelector(selector: LabelSelector, labels: Record<string, string>): boolean;
728
+
729
+ declare const RESOURCE_KINDS: readonly ["agent", "channel", "auth-provider", "policy", "credential-provider", "credential", "tool", "scorer", "dataset", "model", "memory", "cas", "web", "service", "mcp", "db", "browser", "sandbox-pool", "vault"];
730
+ declare const PLATFORM_ADDRESS_KINDS: readonly ["analytics", "role", "principal", "customer", "binding", "session", "run", "ledger", "table", "artifact", "deployment"];
731
+ declare const INVOKABLE_KINDS: readonly ["model", "memory", "cas", "web", "service", "mcp", "db", "browser", "sandbox-pool", "vault"];
732
+ type ResourceKind = typeof RESOURCE_KINDS[number];
733
+ type PlatformAddressKind = typeof PLATFORM_ADDRESS_KINDS[number];
734
+ type CRNKind = ResourceKind | PlatformAddressKind;
735
+ type InvokableKind = typeof INVOKABLE_KINDS[number];
736
+ type CRN = string & {
737
+ readonly __crn: "CRN";
738
+ };
739
+ type ResourceName = CRN;
740
+ type ResourcePattern = string & {
741
+ readonly __resourcePattern: "ResourcePattern";
742
+ };
743
+ type CredentialCRN = CRN & {
744
+ readonly __credentialCRN: "CredentialCRN";
745
+ };
746
+ type CredentialProviderCRN = CRN & {
747
+ readonly __credentialProviderCRN: "CredentialProviderCRN";
748
+ };
749
+ type AuthProviderCRN = CRN & {
750
+ readonly __authProviderCRN: "AuthProviderCRN";
751
+ };
752
+ type PolicyCRN = CRN & {
753
+ readonly __policyCRN: "PolicyCRN";
754
+ };
755
+ type CustomerTenantCRN = CRN & {
756
+ readonly __customerTenantCRN: "CustomerTenantCRN";
757
+ };
758
+ type BindingCRN = CRN & {
759
+ readonly __bindingCRN: "BindingCRN";
760
+ };
761
+ type ScopedBindingKey = string & {
762
+ readonly __scopedBindingKey: "ScopedBindingKey";
763
+ };
764
+ type BindingOwnerScope = "tenant" | "customer" | "principal";
765
+ type ScorerCRN = CRN & {
766
+ readonly __scorerCRN: "ScorerCRN";
767
+ };
768
+ type DatasetCRN = CRN & {
769
+ readonly __datasetCRN: "DatasetCRN";
770
+ };
771
+ interface ResourceContractRef {
772
+ id: string;
773
+ version: string;
774
+ hash: Hash;
775
+ }
776
+ /**
777
+ * A stable, implementation-independent capability contract. Unlike a
778
+ * ResourceContract, this does not pin a particular implementation or operation
779
+ * catalog. Any Connection Resource may declare that it implements it.
780
+ */
781
+ interface CapabilityContractRef {
782
+ id: string;
783
+ version: string;
784
+ hash: Hash;
785
+ }
786
+ interface ScopedResourceRef {
787
+ kind: "scoped";
788
+ key: ScopedBindingKey;
789
+ owner: BindingOwnerScope;
790
+ required: boolean;
791
+ contract: ResourceContractRef;
792
+ }
793
+ interface FixedModelGatewayRef {
794
+ kind: "fixed";
795
+ resource: {
796
+ crn: CRN;
797
+ hash: Hash;
798
+ };
799
+ contract: CapabilityContractRef;
800
+ }
801
+ interface ScopedModelGatewayRef {
802
+ kind: "scoped";
803
+ key: ScopedBindingKey;
804
+ owner: BindingOwnerScope;
805
+ required: true;
806
+ contract: CapabilityContractRef;
807
+ }
808
+ type ModelGatewayBinding = FixedModelGatewayRef | ScopedModelGatewayRef;
809
+ interface FixedMemoryStoreRef {
810
+ kind: "fixed";
811
+ resource: {
812
+ crn: CRN;
813
+ hash: Hash;
814
+ };
815
+ contract: CapabilityContractRef;
816
+ }
817
+ interface ScopedMemoryStoreRef {
818
+ kind: "scoped";
819
+ key: ScopedBindingKey;
820
+ owner: BindingOwnerScope;
821
+ required: true;
822
+ contract: CapabilityContractRef;
823
+ }
824
+ type MemoryStoreBinding = FixedMemoryStoreRef | ScopedMemoryStoreRef;
825
+ interface ScopedCredentialRef {
826
+ kind: "scoped";
827
+ key: ScopedBindingKey;
828
+ owner: BindingOwnerScope;
829
+ required: boolean;
830
+ }
831
+ type AgentResourceBinding = CRN | ScopedResourceRef;
832
+ type ResourceCredentialBinding = CredentialCRN | ScopedCredentialRef;
833
+ interface ResourceNameParts {
834
+ environment: string;
835
+ tenant: string;
836
+ namespace: string;
837
+ kind: CRNKind;
838
+ path: string;
839
+ }
840
+ type Recovery = {
841
+ kind: "repeat";
842
+ } | {
843
+ kind: "idempotency-key";
844
+ } | {
845
+ kind: "reconcile";
846
+ } | {
847
+ kind: "outcome-unknown";
848
+ };
849
+ interface PriceTableRef {
850
+ id: string;
851
+ version: string;
852
+ hash: Hash;
853
+ }
854
+ type SandboxNetworkMode = "block-all" | "cidr-allow" | "domain-allow" | "managed-http" | "unrestricted";
855
+ type SandboxNetworkPolicy = {
856
+ mode: "block-all";
857
+ } | {
858
+ mode: "cidr-allow";
859
+ cidrs: string[];
860
+ } | {
861
+ mode: "domain-allow";
862
+ domains: string[];
863
+ } | {
864
+ mode: "managed-http";
865
+ transport: "bridge";
866
+ egress: CRN;
867
+ } | {
868
+ mode: "managed-http";
869
+ transport: "proxy";
870
+ egress: CRN;
871
+ domains: string[];
872
+ } | {
873
+ mode: "unrestricted";
874
+ };
875
+ type UpstreamPayer = "platform" | "tenant";
876
+ interface ModelTechnicalCapabilities {
877
+ contextTokens: number;
878
+ maxOutputTokens: number;
879
+ inputModalities?: string[];
880
+ outputModalities?: string[];
881
+ }
882
+ /** Immutable price information advertised by a Gateway for operator visibility. */
883
+ interface ModelAdvertisedPricing {
884
+ currency: "USD";
885
+ unit: "million_tokens";
886
+ inputMicroUsd: number;
887
+ outputMicroUsd: number;
888
+ cachedInputMicroUsd: number | null;
889
+ cacheWriteMicroUsd: number | null;
890
+ version: string;
891
+ }
892
+ interface PolicyDelegationCeiling {
893
+ actions: ActionPattern[];
894
+ resources: ResourcePattern[];
895
+ maxTtlMs: number;
896
+ }
897
+ interface CredentialRotationDefaults {
898
+ mode: "manual" | "scheduled" | "auto";
899
+ intervalMs: number | null;
900
+ overlapMs: number;
901
+ maxAgeMs: number | null;
902
+ refreshBeforeMs: number;
903
+ }
904
+ interface ResourceNeed {
905
+ binding: string;
906
+ kind: ResourceKind;
907
+ ops?: string[];
908
+ }
909
+ type Action = string & {
910
+ readonly __action: "Action";
911
+ };
912
+ type ActionPattern = string & {
913
+ readonly __actionPattern: "ActionPattern";
914
+ };
915
+ declare function scopedBindingKey(value: unknown): ScopedBindingKey;
916
+ declare function resourceContractRef(value: unknown): ResourceContractRef;
917
+ declare function capabilityContractRef(value: unknown): CapabilityContractRef;
918
+ declare function scopedResourceRef(value: unknown): ScopedResourceRef;
919
+ declare function modelGatewayBinding(value: unknown): ModelGatewayBinding;
920
+ declare function memoryStoreBinding(value: unknown): MemoryStoreBinding;
921
+ declare function scopedCredentialRef(value: unknown): ScopedCredentialRef;
922
+ declare function agentResourceBinding(value: unknown): AgentResourceBinding;
923
+ declare function resourceCredentialBinding(value: unknown): ResourceCredentialBinding;
924
+ declare function credentialRotationDefaults(value: unknown): CredentialRotationDefaults;
925
+ declare function resourceName(parts: ResourceNameParts): ResourceName;
926
+ declare function parseResourceName(value: string): ResourceNameParts;
927
+ declare function credentialName(value: string): CredentialCRN;
928
+ declare function credentialProviderName(value: string): CredentialProviderCRN;
929
+ declare function authProviderName(value: string): AuthProviderCRN;
930
+ declare function policyName(value: string): PolicyCRN;
931
+ declare function scorerName(value: string): ScorerCRN;
932
+ declare function datasetName(value: string): DatasetCRN;
933
+ declare function customerTenantName(value: string): CustomerTenantCRN;
934
+ declare function bindingName(value: string): BindingCRN;
935
+ declare function resourcePattern(value: string): ResourcePattern;
936
+ declare function matchesResource(pattern: ResourcePattern | ResourceName, value: ResourceName): boolean;
937
+ declare function action(value: string): Action;
938
+ declare function actionPattern(value: string): ActionPattern;
939
+ declare function matchesAction(pattern: ActionPattern | Action, value: Action): boolean;
940
+ declare function modelAdvertisedPricing(value: unknown): ModelAdvertisedPricing;
941
+ declare function resourceNeed(need: ResourceNeed): ResourceNeed;
942
+ declare function normalizeSandboxNetworkPolicy(value: unknown, options?: {
943
+ allowPrivate?: boolean;
944
+ }): SandboxNetworkPolicy;
945
+
946
+ interface GovernanceContractRef {
947
+ id: string;
948
+ version: string;
949
+ hash: Hash;
950
+ }
951
+ interface ResourceControlsConstraint {
952
+ kind: "resource-controls";
953
+ contract: GovernanceContractRef;
954
+ values: Record<string, unknown>;
955
+ }
956
+ type AdmissionLimitScope = "run" | "session" | "subject" | "customer" | "tenant" | "binding" | "resource";
957
+ type AdmissionLimitWindow = {
958
+ kind: "concurrency";
959
+ } | {
960
+ kind: "fixed";
961
+ milliseconds: number;
962
+ } | {
963
+ kind: "lifetime";
964
+ };
965
+ interface AdmissionLimitConstraint {
966
+ kind: "admission-limit";
967
+ contract: GovernanceContractRef;
968
+ id: string;
969
+ meter: string;
970
+ scope: AdmissionLimitScope;
971
+ window: AdmissionLimitWindow;
972
+ maximum: number;
973
+ continuity: "target" | "target-version";
974
+ }
975
+ type AdmissionLimitInput<M extends string = string> = Omit<AdmissionLimitConstraint, "kind" | "contract" | "meter"> & {
976
+ meter: M;
977
+ };
978
+ interface SandboxGovernanceControls {
979
+ command_timeout_ms: number;
980
+ cpu: number;
981
+ disk_gib: number;
982
+ idle_stop_ms: number;
983
+ max_concurrent_commands: number;
984
+ max_file_bytes: number;
985
+ memory_gib: number;
986
+ network_cidrs: string[];
987
+ network_domains: string[];
988
+ network_egress: string | null;
989
+ network_mode: "block-all" | "cidr-allow" | "domain-allow" | "managed-http" | "unrestricted";
990
+ network_transport: "bridge" | "proxy" | null;
991
+ permitted_paths: string[];
992
+ }
993
+ type SandboxGovernanceMeter = "commands" | "compute_ms" | "file_bytes" | "requests";
994
+ interface ModelGovernanceControls {
995
+ max_input_tokens: number;
996
+ max_output_tokens: number;
997
+ temperature_max: number;
998
+ }
999
+ type ModelGovernanceMeter = "cached_input_tokens" | "input_tokens" | "output_tokens" | "requests";
1000
+ declare function sandboxControls(values: Partial<SandboxGovernanceControls>): ResourceControlsConstraint;
1001
+ declare function sandboxLimit(input: AdmissionLimitInput<SandboxGovernanceMeter>): AdmissionLimitConstraint;
1002
+ declare function modelControls(values: Partial<ModelGovernanceControls>): ResourceControlsConstraint;
1003
+ declare function modelLimit(input: AdmissionLimitInput<ModelGovernanceMeter>): AdmissionLimitConstraint;
1004
+
1005
+ type PrincipalKind = "user" | "service" | "channel" | "agent" | "anonymous";
1006
+ interface CustomerPrincipalContext {
1007
+ crn: CustomerTenantCRN;
1008
+ authorizationSeq: number;
1009
+ }
1010
+ interface Principal {
1011
+ name: ResourceName;
1012
+ kind: PrincipalKind;
1013
+ subject: string;
1014
+ tenant: string;
1015
+ issuer: string;
1016
+ roles: ResourceName[];
1017
+ scopes: ActionPattern[];
1018
+ claims: Record<string, string | number | boolean | string[]>;
1019
+ expiresAt: number | null;
1020
+ customer: CustomerPrincipalContext | null;
1021
+ }
1022
+ interface DelegatedGrant {
1023
+ actions: ActionPattern[];
1024
+ resources: ResourcePattern[];
1025
+ ttlMs: number;
1026
+ }
1027
+ type DelegationCeiling = PolicyDelegationCeiling;
1028
+ type JsonScalar = string | number | boolean | null;
1029
+ type JsonValue = JsonScalar | JsonValue[] | {
1030
+ [key: string]: JsonValue;
1031
+ };
1032
+ type PolicyConstraint = {
1033
+ kind: "arguments";
1034
+ schema: object;
1035
+ } | {
1036
+ kind: "context";
1037
+ equals: Record<string, JsonScalar>;
1038
+ } | {
1039
+ kind: "credential-binding";
1040
+ source: CredentialCRN;
1041
+ consumer: CRN;
1042
+ } | ResourceControlsConstraint | AdmissionLimitConstraint;
1043
+ type PolicyContextValue = string | string[];
1044
+ /** Bounded invocation provenance available to executable Policy code. */
1045
+ type PolicyInvocationOrigin = {
1046
+ kind: "run";
1047
+ agent: CRN;
1048
+ tool: CRN | null;
1049
+ } | {
1050
+ kind: "ingress";
1051
+ channel: CRN;
1052
+ authProvider: CRN;
1053
+ } | {
1054
+ kind: "channel";
1055
+ channel: CRN;
1056
+ phase: "receive" | "respond" | "send" | "alarm";
1057
+ } | {
1058
+ kind: "sandbox";
1059
+ agent: CRN;
1060
+ sandbox: {
1061
+ crn: CRN;
1062
+ hash: Hash;
1063
+ };
1064
+ } | {
1065
+ kind: "system";
1066
+ };
1067
+ interface InvocationPolicyRequest {
1068
+ origin: PolicyInvocationOrigin;
1069
+ resource: {
1070
+ crn: CRN;
1071
+ hash: Hash;
1072
+ };
1073
+ operation: {
1074
+ op: string;
1075
+ hash: Hash;
1076
+ };
1077
+ arguments: unknown;
1078
+ argumentsHash: Hash;
1079
+ capability: string | null;
1080
+ run: {
1081
+ id: string;
1082
+ session: string;
1083
+ agent: CRN;
1084
+ };
1085
+ }
1086
+ interface PolicyInput {
1087
+ principal: Principal;
1088
+ action: Action;
1089
+ target: {
1090
+ crn: ResourceName;
1091
+ hash: Hash | null;
1092
+ kind: CRNKind;
1093
+ labels: Readonly<Record<string, string>>;
1094
+ };
1095
+ context: Readonly<Record<string, PolicyContextValue>>;
1096
+ invocation: InvocationPolicyRequest | null;
1097
+ requestedGrant: DelegatedGrant | null;
1098
+ }
1099
+ type PolicyOutcome = {
1100
+ kind: "allow";
1101
+ } | {
1102
+ kind: "deny";
1103
+ code: string;
1104
+ reason?: string;
1105
+ } | {
1106
+ kind: "constrain";
1107
+ constraints: [PolicyConstraint, ...PolicyConstraint[]];
1108
+ } | {
1109
+ kind: "substitute";
1110
+ value: JsonValue;
1111
+ constraints?: PolicyConstraint[];
1112
+ } | {
1113
+ kind: "require-approval";
1114
+ reason?: string;
1115
+ constraints?: PolicyConstraint[];
1116
+ } | {
1117
+ kind: "grant";
1118
+ grant: DelegatedGrant;
1119
+ };
1120
+
1121
+ type AnalyticsDimensionValue = string | number | boolean;
1122
+ interface AnalyticsEventDefinition<Dimension extends string = string, Metric extends string = string> {
1123
+ id: string;
1124
+ version: string;
1125
+ dimensions: readonly Dimension[];
1126
+ metrics: readonly Metric[];
1127
+ }
1128
+ interface AnalyticsValues<Dimension extends string = string, Metric extends string = string> {
1129
+ dimensions?: Partial<Record<Dimension, AnalyticsDimensionValue>>;
1130
+ metrics?: Partial<Record<Metric, number>>;
1131
+ }
1132
+ interface AnalyticsIntent {
1133
+ event: {
1134
+ id: string;
1135
+ version: string;
1136
+ };
1137
+ position: string;
1138
+ ordinal: number;
1139
+ dimensions: Record<string, string>;
1140
+ metrics: Record<string, number>;
1141
+ }
1142
+ interface AnalyticsClient {
1143
+ emit<Dimension extends string, Metric extends string>(event: AnalyticsEventDefinition<Dimension, Metric>, values?: AnalyticsValues<Dimension, Metric>): void;
1144
+ }
1145
+ declare function analyticsEvent<Dimension extends string, Metric extends string>(definition: AnalyticsEventDefinition<Dimension, Metric>): AnalyticsEventDefinition<Dimension, Metric>;
1146
+
1147
+ interface CreateSandboxOptions {
1148
+ image?: SandboxImage;
1149
+ }
1150
+ interface SandboxExecInput {
1151
+ cmd: string;
1152
+ args?: string[];
1153
+ cwd?: string;
1154
+ env?: Record<string, string>;
1155
+ stdin?: string;
1156
+ timeoutMs?: number;
1157
+ outputs?: string[];
1158
+ }
1159
+ interface SandboxCommandResult {
1160
+ commandId: string;
1161
+ status: "completed" | "failed" | "timeout" | "cancelled" | "lease-lost";
1162
+ exitCode: number | null;
1163
+ stdoutPreview: string;
1164
+ stdoutRef: Ref | null;
1165
+ stderrRef: Ref | null;
1166
+ outputs: {
1167
+ path: string;
1168
+ ref: Ref;
1169
+ bytes: number;
1170
+ }[];
1171
+ sandbox: {
1172
+ id: string;
1173
+ generation: number;
1174
+ fresh: boolean;
1175
+ };
1176
+ reason?: string;
1177
+ }
1178
+ interface SandboxFileResult {
1179
+ path: string;
1180
+ ref: Ref;
1181
+ bytes: number;
1182
+ }
1183
+ interface SandboxMutationResult {
1184
+ ok: boolean;
1185
+ }
1186
+ /** Immutable image handle owned by exactly one SandboxPool Resource. */
1187
+ interface SandboxImage {
1188
+ readonly id: string;
1189
+ readonly pool: SandboxPool;
1190
+ delete(opts?: InvokeOpts): Promise<void>;
1191
+ }
1192
+ /** Mutable, Agent/Session-scoped workspace backed by a VM or container provider. */
1193
+ interface Sandbox {
1194
+ readonly id: string;
1195
+ readonly pool: SandboxPool;
1196
+ readonly agent: CRN;
1197
+ readonly session: string;
1198
+ suspend(opts?: InvokeOpts): Promise<void>;
1199
+ resume(opts?: InvokeOpts): Promise<void>;
1200
+ delete(opts?: InvokeOpts): Promise<void>;
1201
+ exec(input: SandboxExecInput, opts?: InvokeOpts): Handle<SandboxCommandResult>;
1202
+ getFile(path: string, opts?: InvokeOpts): Handle<SandboxFileResult>;
1203
+ putFile(path: string, ref: Ref, options?: {
1204
+ mode?: number;
1205
+ invoke?: InvokeOpts;
1206
+ }): Handle<SandboxMutationResult>;
1207
+ deleteFile(path: string, opts?: InvokeOpts): Handle<SandboxMutationResult>;
1208
+ }
1209
+ /** Provider-neutral factory and owner for images and logical sandboxes. */
1210
+ interface SandboxPool {
1211
+ readonly resource: CRN;
1212
+ /** Capture an immutable image from a sandbox owned by this pool. */
1213
+ createImage(sandbox: Sandbox, opts?: InvokeOpts): Promise<SandboxImage>;
1214
+ /** Register a logical Agent/Session sandbox; provider compute is allocated by its first work operation. */
1215
+ createSandbox(agent: CRN, session: string, options?: CreateSandboxOptions, opts?: InvokeOpts): Promise<Sandbox>;
1216
+ }
1217
+
1218
+ type Tier = "scratch" | "standard" | "audit";
1219
+ type Mode = "script" | "durable";
1220
+ type EffectClass = "read-only" | "idempotent" | "reconcilable" | "non-idempotent";
1221
+ type Hash = string;
1222
+ type Ref = string;
1223
+ type FactRef = Hash;
1224
+ type LedgerAddress = string;
1225
+ type BranchRef = string;
1226
+ type Compensation = [Task<unknown>, unknown];
1227
+ type HandleOutcome = "resolved" | "timeout" | "cancelled" | "failed";
1228
+ type DeliveryMode = "queue" | "live";
1229
+ interface RunIdentityView {
1230
+ readonly customer: {
1231
+ readonly crn: CustomerTenantCRN;
1232
+ } | null;
1233
+ }
1234
+ interface GateVerdict {
1235
+ kind: string;
1236
+ verdict: "pass" | "fail";
1237
+ evidence: unknown;
1238
+ scorer?: ScorerRef;
1239
+ score?: number | null;
1240
+ dimensions?: Record<string, number> | null;
1241
+ cost?: Cost | null;
1242
+ retriesSkipped?: "unsafe-effects";
1243
+ }
1244
+ interface GateEvidence {
1245
+ kind: string;
1246
+ evidence: unknown;
1247
+ }
1248
+ interface Provenance {
1249
+ run: string;
1250
+ specHash: Hash;
1251
+ deploymentRevision: string;
1252
+ policyHash: Hash;
1253
+ resourcesHash: Hash;
1254
+ turn: Hash | null;
1255
+ attempts: number;
1256
+ gate: GateVerdict | null;
1257
+ compensate: {
1258
+ task: string;
1259
+ version: string;
1260
+ deploymentRevision: string;
1261
+ argsRef: Ref;
1262
+ } | null;
1263
+ }
1264
+ interface Fact<A = unknown> {
1265
+ hash: FactRef;
1266
+ k: number;
1267
+ parent: FactRef | null;
1268
+ artifactHash: Hash;
1269
+ artifact?: A;
1270
+ preview?: unknown;
1271
+ tier: Tier;
1272
+ provenance: Provenance;
1273
+ checkpoint: {
1274
+ upTo: FactRef;
1275
+ } | null;
1276
+ at: number;
1277
+ }
1278
+ interface EventBase {
1279
+ seq: number;
1280
+ hash: Hash;
1281
+ prev: Hash | null;
1282
+ at: number;
1283
+ tenant: string;
1284
+ ledger: string;
1285
+ branch: string;
1286
+ }
1287
+ interface Actor {
1288
+ kind: "user" | "operator" | "agent" | "policy";
1289
+ id: string;
1290
+ }
1291
+ type SteerEvent = EventBase & {
1292
+ kind: "steer";
1293
+ eventId: string;
1294
+ actor: Actor;
1295
+ run: string | null;
1296
+ payload: {
1297
+ text: string;
1298
+ data?: unknown;
1299
+ };
1300
+ ref: Ref | null;
1301
+ };
1302
+ type ControlEvent = EventBase & {
1303
+ kind: "control";
1304
+ eventId: string;
1305
+ actor: Actor;
1306
+ run: string;
1307
+ op: "pause" | "resume" | "cancel" | "interrupt" | "policy" | "rebind" | "truncate";
1308
+ mode: "safe-point" | "abort";
1309
+ payload: unknown;
1310
+ };
1311
+ type WaitResolvedEvent = EventBase & {
1312
+ kind: "wait-resolved";
1313
+ eventId: string;
1314
+ actor: Actor;
1315
+ run: string;
1316
+ promiseId: string;
1317
+ outcome: "resolved" | "timeout" | "cancelled" | "failed";
1318
+ };
1319
+ type LedgerEvent = SteerEvent | ControlEvent | WaitResolvedEvent | (EventBase & {
1320
+ kind: "fact";
1321
+ fact: Fact;
1322
+ }) | (EventBase & {
1323
+ kind: "truncate";
1324
+ rollbackId: string;
1325
+ previousHead: FactRef;
1326
+ newHead: FactRef;
1327
+ targets: {
1328
+ after: FactRef;
1329
+ through: FactRef;
1330
+ };
1331
+ count: number;
1332
+ }) | (EventBase & {
1333
+ kind: "branch-created";
1334
+ from: FactRef;
1335
+ }) | (EventBase & {
1336
+ kind: "branch-head-moved";
1337
+ expected: FactRef;
1338
+ from: FactRef;
1339
+ to: FactRef;
1340
+ cause: "publish" | "truncate";
1341
+ }) | (EventBase & {
1342
+ kind: "compensation-started";
1343
+ rollbackId: string;
1344
+ compensationId: string;
1345
+ target: FactRef;
1346
+ task: {
1347
+ id: string;
1348
+ version: string;
1349
+ deploymentRevision: string;
1350
+ };
1351
+ }) | (EventBase & {
1352
+ kind: "compensation-completed";
1353
+ rollbackId: string;
1354
+ compensationId: string;
1355
+ target: FactRef;
1356
+ resultRef: Ref | null;
1357
+ }) | (EventBase & {
1358
+ kind: "compensation-failed";
1359
+ rollbackId: string;
1360
+ compensationId: string;
1361
+ target: FactRef;
1362
+ errorRef: Ref;
1363
+ }) | (EventBase & {
1364
+ kind: "delivery-enqueued";
1365
+ itemId: string;
1366
+ target: LedgerAddress | "export";
1367
+ fact: FactRef;
1368
+ }) | (EventBase & {
1369
+ kind: "delivery-acknowledged";
1370
+ itemId: string;
1371
+ target: LedgerAddress | "export";
1372
+ fact: FactRef;
1373
+ }) | (EventBase & {
1374
+ kind: "anchor";
1375
+ fromSeq: number;
1376
+ toSeq: number;
1377
+ root: Hash;
1378
+ prevAnchor: Hash | null;
1379
+ keyId: string;
1380
+ signature: string;
1381
+ });
1382
+ interface ViewDef<S = unknown, E = Fact> {
1383
+ id: string;
1384
+ version: string;
1385
+ over?: "facts" | "events";
1386
+ init(): S;
1387
+ apply(state: S, item: E): S;
1388
+ }
1389
+ interface HistoryView {
1390
+ session: string;
1391
+ branch: string;
1392
+ head: {
1393
+ k: number;
1394
+ hash: FactRef;
1395
+ } | null;
1396
+ eventHead: Hash | null;
1397
+ message: unknown;
1398
+ checkpoint: Fact | null;
1399
+ facts: Fact[];
1400
+ steers: SteerEvent[];
1401
+ more: string | null;
1402
+ }
1403
+ interface RollbackReport {
1404
+ rollbackId: string;
1405
+ status: "complete" | "complete_with_failures";
1406
+ compensations: {
1407
+ compensationId: string;
1408
+ target: FactRef;
1409
+ status: "completed" | "failed";
1410
+ errorRef: Ref | null;
1411
+ }[];
1412
+ }
1413
+ interface Task<T> {
1414
+ id: string;
1415
+ version: string;
1416
+ run(input: any, ctx: Ctx): Promise<T>;
1417
+ }
1418
+ interface SpawnOpts {
1419
+ retries?: number;
1420
+ dedupe?: "specHash";
1421
+ from?: BranchRef;
1422
+ }
1423
+ interface AwaitOpts<T> {
1424
+ timeout?: number;
1425
+ onTimeout?: T;
1426
+ schema?: object;
1427
+ maxBytes?: number;
1428
+ afterRun?: "ignore" | "message";
1429
+ }
1430
+ interface Handle<T> extends PromiseLike<T> {
1431
+ readonly id: string;
1432
+ readonly resolved: boolean;
1433
+ readonly seq: number | null;
1434
+ readonly outcome: HandleOutcome | null;
1435
+ readonly result: T | undefined;
1436
+ readonly error: unknown | undefined;
1437
+ cancel(): Promise<void>;
1438
+ }
1439
+ interface CommitOpts {
1440
+ tier?: Tier;
1441
+ gate?: string | GateEvidence | {
1442
+ scorer: CRN;
1443
+ };
1444
+ /** Filled by the runtime after a scorer-backed gate; callers must not provide it. */
1445
+ gateVerdict?: GateVerdict;
1446
+ compensate?: Compensation;
1447
+ to?: LedgerAddress;
1448
+ checkpoint?: {
1449
+ upTo: FactRef;
1450
+ };
1451
+ expectedHead?: FactRef;
1452
+ deliver?: DeliveryMode;
1453
+ }
1454
+ interface Cost {
1455
+ accounting: {
1456
+ trackedCost: {
1457
+ microUsd: number | null;
1458
+ reservedMicroUsd: number | null;
1459
+ priceTable: PriceTableRef | null;
1460
+ };
1461
+ platformCharge: {
1462
+ microUsd: number | null;
1463
+ reservedMicroUsd: number | null;
1464
+ priceTable: PriceTableRef | null;
1465
+ };
1466
+ customerCharge: {
1467
+ microUsd: number | null;
1468
+ reservedMicroUsd: number | null;
1469
+ priceTable: PriceTableRef | null;
1470
+ };
1471
+ };
1472
+ tokens: {
1473
+ input: number;
1474
+ output: number;
1475
+ cached: number;
1476
+ cacheWrite: number;
1477
+ };
1478
+ provider: string;
1479
+ model: string;
1480
+ priceTableVersion: string;
1481
+ }
1482
+ interface Tool {
1483
+ name: string;
1484
+ version: string;
1485
+ description: string;
1486
+ schema: object;
1487
+ maxEffect: EffectClass;
1488
+ needs?: ResourceNeed[];
1489
+ tier?: Tier;
1490
+ guard?(args: any, ctx: Ctx): string | null;
1491
+ once?: "per-run-and-args" | "per-run";
1492
+ run(args: any, ctx: Ctx): Promise<any>;
1493
+ }
1494
+ type GateResult = boolean | {
1495
+ pass: boolean;
1496
+ evidence?: unknown;
1497
+ };
1498
+ interface TurnDraft {
1499
+ message: {
1500
+ role: "assistant";
1501
+ content: string;
1502
+ };
1503
+ toolCalls: {
1504
+ name: string;
1505
+ args: unknown;
1506
+ }[];
1507
+ final: boolean;
1508
+ artifact: unknown;
1509
+ }
1510
+ interface TurnGate {
1511
+ id?: string;
1512
+ version?: string;
1513
+ scorer?: CRN;
1514
+ before?(draft: TurnDraft): GateResult;
1515
+ check?(rec: TurnRecord): GateResult;
1516
+ retries?: number;
1517
+ feedback?(rec: TurnRecord | TurnDraft): string;
1518
+ onExhausted?: "fail" | "commit-with-verdict";
1519
+ }
1520
+ interface TurnSpec {
1521
+ system: string;
1522
+ objective?: unknown;
1523
+ context?: unknown;
1524
+ tools?: string[];
1525
+ gate?: TurnGate;
1526
+ model?: string;
1527
+ stream?: boolean;
1528
+ }
1529
+ interface ToolCallRecord {
1530
+ id: string;
1531
+ pos: string;
1532
+ name: string;
1533
+ version: string;
1534
+ args: unknown;
1535
+ maxEffect: EffectClass;
1536
+ effectObserved: EffectClass | null;
1537
+ status: "ok" | "error" | "refused" | "unknown" | "repeated" | "outcome-unknown" | "substituted";
1538
+ result?: unknown;
1539
+ ref?: Ref;
1540
+ preview?: unknown;
1541
+ error?: unknown;
1542
+ substitution?: {
1543
+ actor: Actor;
1544
+ valueRef?: Ref;
1545
+ };
1546
+ }
1547
+ interface TurnRecord {
1548
+ hash: Hash;
1549
+ message: {
1550
+ role: "assistant";
1551
+ content: string;
1552
+ };
1553
+ toolCalls: ToolCallRecord[];
1554
+ final: boolean;
1555
+ artifact: unknown;
1556
+ cost: Cost;
1557
+ attempts: number;
1558
+ gate: GateVerdict | null;
1559
+ }
1560
+ interface DataManifest {
1561
+ hash: Hash;
1562
+ format: "parquet" | "jsonl" | "arrow";
1563
+ schemaRef: Ref;
1564
+ indexRef: Ref;
1565
+ fileCount: number;
1566
+ rowCount: number;
1567
+ byteCount: number;
1568
+ partitioning: Partitioning | null;
1569
+ sortOrder: SortField[];
1570
+ statisticsRef: Ref | null;
1571
+ }
1572
+ type Partitioning = {
1573
+ kind: "bucket";
1574
+ key: string;
1575
+ buckets: number;
1576
+ hash: "murmur3-32";
1577
+ version: string;
1578
+ } | {
1579
+ kind: "range";
1580
+ key: string;
1581
+ bounds: unknown[];
1582
+ };
1583
+ interface SortField {
1584
+ key: string;
1585
+ direction: "asc" | "desc";
1586
+ }
1587
+ interface FileEntry {
1588
+ ref: Ref;
1589
+ rows: number;
1590
+ bytes: number;
1591
+ bucket: number | null;
1592
+ min?: unknown;
1593
+ max?: unknown;
1594
+ }
1595
+ interface ManifestIndexPage {
1596
+ files: FileEntry[];
1597
+ next: Ref | null;
1598
+ }
1599
+ type Over<I> = DataManifest | MapFact | ReduceFact | I[];
1600
+ type PartitionSpec = {
1601
+ rows: number;
1602
+ } | {
1603
+ bytes: number;
1604
+ } | {
1605
+ tokens: number;
1606
+ of: string;
1607
+ } | {
1608
+ key: string;
1609
+ buckets: number;
1610
+ };
1611
+ interface Out<O, R> {
1612
+ emit(row: O): void;
1613
+ residue(row: R): void;
1614
+ budget: {
1615
+ microUsdLeft: number;
1616
+ };
1617
+ }
1618
+ interface PartitionFn<I, O, R = never> {
1619
+ id: string;
1620
+ version: string;
1621
+ effects: "pure" | "read-only" | "idempotent";
1622
+ speculate?: boolean;
1623
+ batch: {
1624
+ rows: number;
1625
+ } | {
1626
+ tokens: number;
1627
+ of: string;
1628
+ };
1629
+ run(batch: I[], out: Out<O, R>): Promise<void>;
1630
+ }
1631
+ interface FoldFn<I, O> {
1632
+ id: string;
1633
+ version: string;
1634
+ deterministic: boolean;
1635
+ associative: true | {
1636
+ orderBy: "partition";
1637
+ };
1638
+ combiner?: FoldFn<I, I>;
1639
+ run(group: {
1640
+ key: string | null;
1641
+ rows: AsyncIterable<I>;
1642
+ }, out: Out<O, never>): Promise<void>;
1643
+ }
1644
+ interface SqlFold {
1645
+ sql: string;
1646
+ version: string;
1647
+ deterministic: true;
1648
+ associative: true;
1649
+ }
1650
+ interface StageOutputSpec {
1651
+ schema: object;
1652
+ sortOrder?: SortField[];
1653
+ }
1654
+ interface MapOpts {
1655
+ partition: PartitionSpec;
1656
+ concurrency?: number;
1657
+ budgetMicroUsd?: number;
1658
+ speculateAfterMs?: number;
1659
+ retries?: number;
1660
+ bucketBy?: {
1661
+ key: string;
1662
+ buckets: number;
1663
+ };
1664
+ tier?: Tier;
1665
+ output?: StageOutputSpec;
1666
+ to?: {
1667
+ table: string;
1668
+ branch?: string;
1669
+ expectedHead: FactRef | null;
1670
+ };
1671
+ }
1672
+ interface ReduceOpts {
1673
+ by?: string;
1674
+ scope?: "key" | "global" | {
1675
+ tree: number;
1676
+ };
1677
+ minGroup?: number;
1678
+ concurrency?: number;
1679
+ budgetMicroUsd?: number;
1680
+ tier?: Tier;
1681
+ output?: StageOutputSpec;
1682
+ to?: {
1683
+ table: string;
1684
+ branch?: string;
1685
+ expectedHead: FactRef | null;
1686
+ };
1687
+ }
1688
+ interface StageInfo {
1689
+ id: string;
1690
+ shards: number;
1691
+ partitions: number;
1692
+ attempts: number;
1693
+ speculated: number;
1694
+ }
1695
+ interface MapFact {
1696
+ kind: "map";
1697
+ hash: FactRef;
1698
+ k: number;
1699
+ fn: {
1700
+ id: string;
1701
+ version: string;
1702
+ };
1703
+ over: Hash;
1704
+ manifest: DataManifest;
1705
+ residue: DataManifest | null;
1706
+ rows: number;
1707
+ costMicroUsd: number;
1708
+ stage: StageInfo;
1709
+ verdict: "committed" | "budget-exhausted";
1710
+ }
1711
+ interface ReduceFact {
1712
+ kind: "reduce";
1713
+ hash: FactRef;
1714
+ k: number;
1715
+ fn: {
1716
+ id: string;
1717
+ version: string;
1718
+ };
1719
+ over: Hash;
1720
+ result: DataManifest | {
1721
+ value: unknown;
1722
+ hash: Hash;
1723
+ };
1724
+ exchanged: boolean;
1725
+ exchange: {
1726
+ partitions: number;
1727
+ costMicroUsd: number;
1728
+ } | null;
1729
+ depth: number;
1730
+ rows: number;
1731
+ costMicroUsd: number;
1732
+ stage: StageInfo;
1733
+ }
1734
+ type ScopeJournalKind = "turn" | "tool" | "step";
1735
+ type LocalJournalKind = "clock" | "random" | "score" | "commit" | "await" | "spawn" | "map" | "reduce" | "view" | "page" | "truncate" | "cancel" | "capability";
1736
+ type JournalKind = ScopeJournalKind | LocalJournalKind | "invoke";
1737
+ /** Stable identity available to Agent code. Platform execution and deployment
1738
+ * metadata intentionally remain outside the public Agent context. */
1739
+ interface RunInfo {
1740
+ id: string;
1741
+ session: string;
1742
+ tenant: string;
1743
+ namespace: string;
1744
+ readonly identity: RunIdentityView;
1745
+ agent: {
1746
+ id: string;
1747
+ version: string;
1748
+ crn: CRN;
1749
+ };
1750
+ mode: Mode;
1751
+ }
1752
+ interface CapabilityRef {
1753
+ readonly id: string;
1754
+ readonly expiresAt: number;
1755
+ }
1756
+ interface InvokeOpts {
1757
+ capability?: CapabilityRef;
1758
+ timeoutMs?: number;
1759
+ dedupeKey?: string;
1760
+ }
1761
+ interface CapabilityGrant {
1762
+ actions: string[];
1763
+ resources: string[];
1764
+ ttlMs: number;
1765
+ reason: string;
1766
+ }
1767
+ interface Ctx {
1768
+ turn(spec: TurnSpec): Promise<TurnRecord>;
1769
+ ledger: {
1770
+ view<S = HistoryView>(name?: string, opts?: {
1771
+ of?: LedgerAddress;
1772
+ }): Promise<S>;
1773
+ page(cursor: string): Promise<{
1774
+ facts: Fact[];
1775
+ more: string | null;
1776
+ }>;
1777
+ branch(at: FactRef): BranchRef;
1778
+ truncate(to: FactRef): Handle<RollbackReport>;
1779
+ };
1780
+ commit<A>(artifact: A, opts?: CommitOpts): Promise<Fact<A>>;
1781
+ await<T>(label: string, opts?: AwaitOpts<T>): Handle<T>;
1782
+ spawn<T>(task: Task<T>, input: unknown, opts?: SpawnOpts): Handle<T>;
1783
+ map<I, O, R = never>(f: PartitionFn<I, O, R>, over: Over<I>, opts: MapOpts): Handle<MapFact>;
1784
+ reduce<I, O>(g: FoldFn<I, O> | SqlFold, over: Over<I>, opts?: ReduceOpts): Handle<ReduceFact>;
1785
+ step<T>(name: string, fn: () => Promise<T>): Promise<T>;
1786
+ resources: Record<string, CRN>;
1787
+ /** Open a provider-neutral sandbox pool bound into this Run. */
1788
+ sandboxPool(resource: CRN): SandboxPool;
1789
+ invoke<T>(resource: CRN, op: string, args: unknown, opts?: InvokeOpts): Promise<T>;
1790
+ invokeAsync<T>(resource: CRN, op: string, args: unknown, opts?: InvokeOpts): Handle<T>;
1791
+ request(policy: PolicyCRN, grant: CapabilityGrant): Handle<CapabilityRef>;
1792
+ analytics: AnalyticsClient;
1793
+ run: RunInfo;
1794
+ }
1795
+ interface AgentDef<S = unknown> {
1796
+ id: string;
1797
+ version: string;
1798
+ model: string;
1799
+ mode?: Mode;
1800
+ onMessage?(message: unknown, ctx: Ctx): Promise<unknown>;
1801
+ init?(message: unknown): S;
1802
+ step?(state: S, ctx: Ctx): Promise<{
1803
+ state: S;
1804
+ done: boolean;
1805
+ }>;
1806
+ output?(state: S): unknown;
1807
+ subtasks?: Task<unknown>[];
1808
+ views?: (ViewDef<unknown, Fact> | ViewDef<unknown, LedgerEvent>)[];
1809
+ partitionFns?: PartitionFn<unknown, unknown, unknown>[];
1810
+ foldFns?: (FoldFn<unknown, unknown> | SqlFold)[];
1811
+ analytics?: AnalyticsEventDefinition[];
1812
+ tools?: Record<string, Tool>;
1813
+ }
1814
+ type Agent<S = unknown> = AgentDef<S>;
1815
+
1816
+ declare function validateTool(tool: Tool, path?: string): Tool;
1817
+ declare function validateView<V extends ViewDef<any, any>>(view: V, path?: string): V;
1818
+ declare function validatePartitionFn<I, O, R>(fn: PartitionFn<I, O, R>): PartitionFn<I, O, R>;
1819
+ declare function validateFoldFn<I, O>(fn: FoldFn<I, O> | SqlFold): FoldFn<I, O> | SqlFold;
1820
+ declare function agent<S>(def: AgentDef<S>): AgentDef<S>;
1821
+ declare function subtask<T>(def: Task<T>): Task<T>;
1822
+
1823
+ interface ChannelRequest {
1824
+ method: string;
1825
+ url: string;
1826
+ headers: Record<string, string>;
1827
+ bodyBase64: string | null;
1828
+ }
1829
+ interface ChannelResponse {
1830
+ status: number;
1831
+ headers?: Record<string, string>;
1832
+ bodyBase64?: string | null;
1833
+ }
1834
+ interface CanonicalEvent<T = unknown> {
1835
+ v: 1;
1836
+ id: string;
1837
+ type: string;
1838
+ source: CRN;
1839
+ target: CRN;
1840
+ session: string;
1841
+ data: T;
1842
+ occurredAt: number;
1843
+ deliver?: DeliveryMode;
1844
+ }
1845
+ interface CanonicalEventDraft<T = unknown> {
1846
+ id: string;
1847
+ type: string;
1848
+ target?: CRN;
1849
+ session: string;
1850
+ data: T;
1851
+ occurredAt?: number;
1852
+ deliver?: DeliveryMode;
1853
+ }
1854
+ interface DispatchResult<T = unknown> {
1855
+ event: CanonicalEvent;
1856
+ runId: string;
1857
+ status: "queued" | "leased" | "suspended" | "complete" | "failed" | "stopped";
1858
+ statusDetail?: RunStatusDetail;
1859
+ result?: T;
1860
+ error?: string;
1861
+ fact?: string;
1862
+ }
1863
+ interface RunStatusDetail {
1864
+ code: "insufficient_funds";
1865
+ message: string;
1866
+ retryable: true;
1867
+ updatedAt: number;
1868
+ }
1869
+ interface ChannelContext {
1870
+ channel: CRN;
1871
+ principal: Principal;
1872
+ invocationId: string;
1873
+ resources: Record<string, CRN>;
1874
+ analytics: AnalyticsClient;
1875
+ invoke<T>(resource: CRN, op: string, args: unknown, opts?: {
1876
+ timeoutMs?: number;
1877
+ dedupeKey?: string;
1878
+ }): Promise<T>;
1879
+ }
1880
+ interface ChannelMessage<T = unknown> {
1881
+ id: string;
1882
+ destination: string;
1883
+ data: T;
1884
+ session?: string;
1885
+ replyTo?: string;
1886
+ metadata?: Record<string, string | number | boolean>;
1887
+ }
1888
+ interface DeliveryReceipt {
1889
+ id: string;
1890
+ status: "accepted" | "delivered" | "failed";
1891
+ externalId?: string;
1892
+ error?: string;
1893
+ metadata?: Record<string, string | number | boolean>;
1894
+ }
1895
+ interface ChannelAlarm<T = unknown> {
1896
+ id: string;
1897
+ scheduledAt: number;
1898
+ data: T;
1899
+ }
1900
+ interface ChannelAlarmResult<Delivery = unknown> {
1901
+ nextAlarmAt?: number | null;
1902
+ messages?: ChannelMessage<Delivery>[];
1903
+ }
1904
+ interface ChannelProtocol<Input = unknown, Output = unknown, Delivery = Output> {
1905
+ id: string;
1906
+ version: string;
1907
+ receive(request: ChannelRequest, context: ChannelContext): Promise<CanonicalEventDraft<Input>> | CanonicalEventDraft<Input>;
1908
+ respond(result: DispatchResult<Output>, context: ChannelContext): Promise<ChannelResponse> | ChannelResponse;
1909
+ send?(message: ChannelMessage<Delivery>, context: ChannelContext): Promise<DeliveryReceipt> | DeliveryReceipt;
1910
+ alarm?(alarm: ChannelAlarm, context: ChannelContext): Promise<ChannelAlarmResult<Delivery> | void> | ChannelAlarmResult<Delivery> | void;
1911
+ }
1912
+ interface Channel<Input = unknown, Output = unknown, Delivery = Output> {
1913
+ id: string;
1914
+ version: string;
1915
+ protocol: ChannelProtocol<Input, Output, Delivery>;
1916
+ authProvider: AuthProviderCRN;
1917
+ public?: boolean;
1918
+ needs?: ResourceNeed[];
1919
+ analytics?: AnalyticsEventDefinition[];
1920
+ }
1921
+ declare function channel<I, O, D = O>(definition: Channel<I, O, D>): Channel<I, O, D>;
1922
+
1923
+ interface AuthProviderRequest {
1924
+ request: ChannelRequest;
1925
+ channel: CRN;
1926
+ audience: CRN;
1927
+ }
1928
+ type AuthProviderResult = {
1929
+ authenticated: false;
1930
+ reason?: string;
1931
+ } | {
1932
+ authenticated: true;
1933
+ subject: string;
1934
+ customer?: {
1935
+ externalId: string;
1936
+ };
1937
+ claims?: Record<string, string | number | boolean | string[]>;
1938
+ expiresAt?: number | null;
1939
+ };
1940
+ interface AuthProviderContext {
1941
+ requestId: string;
1942
+ provider: AuthProviderCRN;
1943
+ channel: CRN;
1944
+ resources: Record<string, CRN>;
1945
+ invoke<T>(resource: CRN, op: string, args: unknown): Promise<T>;
1946
+ }
1947
+ interface AuthProvider {
1948
+ id: string;
1949
+ version: string;
1950
+ needs?: ResourceNeed[];
1951
+ authenticate(request: AuthProviderRequest, context: AuthProviderContext): Promise<AuthProviderResult> | AuthProviderResult;
1952
+ }
1953
+ declare function authProvider(definition: AuthProvider): AuthProvider;
1954
+
1955
+ interface PolicyDefinition {
1956
+ id: string;
1957
+ version: string;
1958
+ evaluate(input: Readonly<PolicyInput>): PolicyOutcome | Promise<PolicyOutcome>;
1959
+ }
1960
+ /** Defines deterministic executable evaluation code for a selector-bound Policy package. */
1961
+ declare function policy(definition: PolicyDefinition): PolicyDefinition;
1962
+ /** Runs and validates one Policy definition without creating a transport envelope. */
1963
+ declare function evaluatePolicyDefinition(definition: PolicyDefinition, input: Readonly<PolicyInput>): Promise<PolicyOutcome>;
1964
+
1965
+ /** RFC 8785-compatible canonical JSON for JSON-safe values. */
1966
+ declare function canonicalJson(value: unknown): string;
1967
+ declare function sha256Hex(bytes: string | ArrayBuffer | Uint8Array): Promise<string>;
1968
+ declare function hash(domain: string, ...values: unknown[]): Promise<string>;
1969
+ declare function hashValue(value: unknown): Promise<string>;
1970
+ /** MurmurHash3 x86 32-bit, used only for deterministic data bucketing. */
1971
+ declare function murmur3_32(value: string, seed?: number): number;
1972
+ declare function bucketFor(value: unknown, buckets: number): number;
1973
+
1974
+ type BatchSpec = {
1975
+ rows: number;
1976
+ } | {
1977
+ tokens: number;
1978
+ of: string;
1979
+ };
1980
+ declare function validatePartitionSpec(spec: PartitionSpec): void;
1981
+ declare function validateBatchSpec(spec: BatchSpec): void;
1982
+ declare function approximateTokens(value: unknown): number;
1983
+ declare function cutPartitions<I>(rows: readonly I[], spec: PartitionSpec): I[][];
1984
+ declare function cutBatches<I>(rows: readonly I[], spec: BatchSpec): I[][];
1985
+
1986
+ interface CatalogTool extends Tool {
1987
+ readonly catalog: {
1988
+ binding: string;
1989
+ op: string;
1990
+ };
1991
+ }
1992
+ declare function opTool(binding: string, op: string, override?: Partial<Pick<Tool, "name" | "description" | "tier" | "once" | "guard">>): CatalogTool;
1993
+ declare function opTools(binding: string, ops?: string[]): CatalogTool[];
1994
+ declare const webFetch: CatalogTool;
1995
+ declare const webSearch: CatalogTool;
1996
+ declare const casTool: Tool;
1997
+
1998
+ type TableScalar = string | number | boolean | null;
1999
+ type TableFilterOperation = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "between";
2000
+ interface TableFilter {
2001
+ field: string;
2002
+ op: TableFilterOperation;
2003
+ value: TableScalar | TableScalar[];
2004
+ }
2005
+ interface TableAggregate {
2006
+ fn: "count" | "sum" | "avg" | "min" | "max";
2007
+ field?: string;
2008
+ as: string;
2009
+ }
2010
+ interface TableOrder {
2011
+ field: string;
2012
+ direction: "asc" | "desc";
2013
+ }
2014
+ interface TableQueryPlan {
2015
+ select?: string[];
2016
+ where?: TableFilter[];
2017
+ groupBy?: string[];
2018
+ aggregates?: TableAggregate[];
2019
+ orderBy?: TableOrder[];
2020
+ limit?: number;
2021
+ }
2022
+ interface TableDescribeArgs {
2023
+ table: string;
2024
+ branch?: string;
2025
+ snapshot?: Hash;
2026
+ stageId?: Hash;
2027
+ waitMs?: number;
2028
+ }
2029
+ interface TableQueryArgs {
2030
+ table: string;
2031
+ branch?: string;
2032
+ snapshot: Hash;
2033
+ query: TableQueryPlan;
2034
+ }
2035
+ interface TableSnapshotDescription {
2036
+ table: string;
2037
+ branch: string;
2038
+ snapshot: Hash;
2039
+ sequence: number;
2040
+ parent: Hash | null;
2041
+ committedAt: number;
2042
+ source: {
2043
+ stageId: Hash;
2044
+ runId: string;
2045
+ session: string;
2046
+ };
2047
+ manifest: Pick<DataManifest, "hash" | "format" | "fileCount" | "rowCount" | "byteCount" | "partitioning" | "sortOrder"> & {
2048
+ schemaRef: Ref;
2049
+ statisticsRef: Ref | null;
2050
+ };
2051
+ schema: object;
2052
+ queryable: true;
2053
+ }
2054
+ interface TableQueryResult {
2055
+ table: string;
2056
+ branch: string;
2057
+ snapshot: Hash;
2058
+ rows: Record<string, TableScalar>[];
2059
+ rowCount: number;
2060
+ truncated: boolean;
2061
+ }
2062
+ /** Validates the deterministic schema/ordering contract attached to a Stage output. */
2063
+ declare function validateStageOutputSpec(value: unknown, path?: string): string | null;
2064
+ declare function stageOutput(value: StageOutputSpec): StageOutputSpec;
2065
+ declare const tableDescribe: Tool;
2066
+ declare const tableQuery: Tool;
2067
+
2068
+ interface MemoryRecord {
2069
+ id: string;
2070
+ content: string;
2071
+ metadata: Record<string, unknown>;
2072
+ createdAt: number;
2073
+ updatedAt: number;
2074
+ expiresAt: number | null;
2075
+ }
2076
+ interface MemoryRememberArgs {
2077
+ id?: string;
2078
+ content: string;
2079
+ metadata?: Record<string, unknown>;
2080
+ }
2081
+ interface MemorySearchArgs {
2082
+ query: string;
2083
+ limit?: number;
2084
+ }
2085
+ interface MemoryGetArgs {
2086
+ id: string;
2087
+ }
2088
+ interface MemoryDeleteArgs {
2089
+ id: string;
2090
+ }
2091
+ interface MemorySearchHit extends MemoryRecord {
2092
+ score: number;
2093
+ }
2094
+ /** The stable Agent-facing contract shared by logical Memories and Memory Store Connections. */
2095
+ declare const MEMORY_OPERATION_DECLARATIONS: readonly ConnectionOperation[];
2096
+
2097
+ interface CredentialMintRequest {
2098
+ credential: CredentialCRN;
2099
+ version: number;
2100
+ trigger: "create" | "manual" | "interval" | "max-age" | "invalid";
2101
+ configuration: unknown;
2102
+ /** Encrypted lifecycle state from the active version. It is never exposed to consuming Resources. */
2103
+ privateState: string | null;
2104
+ }
2105
+ interface CredentialMintResult {
2106
+ material: string;
2107
+ expiresAt?: number | null;
2108
+ /** Replacement lifecycle state encrypted beside this version and visible only to the provider. */
2109
+ privateState?: string | null;
2110
+ }
2111
+ interface CredentialInteractionProof {
2112
+ challenge: string;
2113
+ method: "S256";
2114
+ }
2115
+ interface CredentialInteractionStartRequest {
2116
+ credential: CredentialCRN;
2117
+ session: string;
2118
+ callbackUrl: string;
2119
+ state: string;
2120
+ configuration: unknown;
2121
+ expiresAt: number;
2122
+ proof: CredentialInteractionProof;
2123
+ }
2124
+ type CredentialInteractionEvent = {
2125
+ kind: "callback";
2126
+ method: "GET" | "POST";
2127
+ parameters: Record<string, string>;
2128
+ headers: Record<string, string>;
2129
+ bodyBase64: string | null;
2130
+ } | {
2131
+ kind: "submit";
2132
+ value: unknown;
2133
+ } | {
2134
+ kind: "continue";
2135
+ } | {
2136
+ kind: "poll";
2137
+ };
2138
+ interface CredentialInteractionAdvanceRequest {
2139
+ credential: CredentialCRN;
2140
+ session: string;
2141
+ callbackUrl: string;
2142
+ state: string;
2143
+ configuration: unknown;
2144
+ expiresAt: number;
2145
+ proof: CredentialInteractionProof & {
2146
+ verifier: string;
2147
+ };
2148
+ event: CredentialInteractionEvent;
2149
+ privateState: string | null;
2150
+ }
2151
+ type CredentialInteractionPrimaryAction = {
2152
+ kind: "open-url";
2153
+ label: string;
2154
+ url: string;
2155
+ event: {
2156
+ kind: "continue";
2157
+ };
2158
+ } | {
2159
+ kind: "continue";
2160
+ label: string;
2161
+ event: {
2162
+ kind: "continue";
2163
+ };
2164
+ };
2165
+ type CredentialInteractionAction = {
2166
+ kind: "redirect";
2167
+ url: string;
2168
+ expiresAt?: number;
2169
+ } | {
2170
+ kind: "form";
2171
+ schema: object;
2172
+ title?: string;
2173
+ description?: string;
2174
+ submitLabel?: string;
2175
+ expiresAt?: number;
2176
+ } | {
2177
+ kind: "display";
2178
+ instructions: string;
2179
+ title?: string;
2180
+ userCode?: string;
2181
+ primaryAction: CredentialInteractionPrimaryAction;
2182
+ expiresAt?: number;
2183
+ } | {
2184
+ kind: "wait";
2185
+ resume: "callback" | "poll";
2186
+ expiresAt: number;
2187
+ pollAfterMs?: number;
2188
+ } | {
2189
+ kind: "complete";
2190
+ material: string;
2191
+ expiresAt?: number | null;
2192
+ };
2193
+ interface CredentialInteractionResult {
2194
+ action: CredentialInteractionAction;
2195
+ /** Encrypted between transitions and, after completion, beside the resulting Credential version. */
2196
+ privateState?: string | null;
2197
+ }
2198
+ interface CredentialMaterialRequest {
2199
+ credential: CredentialCRN;
2200
+ version: number;
2201
+ fingerprint: string;
2202
+ material: string;
2203
+ configuration: unknown;
2204
+ privateState: string | null;
2205
+ }
2206
+ interface CredentialVerifyResult {
2207
+ verified: boolean;
2208
+ }
2209
+ interface CredentialDestroyResult {
2210
+ destroyed: boolean;
2211
+ }
2212
+ type CredentialProviderSecretInput = "secret" | "multiline" | "file";
2213
+ interface CredentialProviderCredentialSlotSetup {
2214
+ /** Human-readable name shown while the provider is configured. */
2215
+ title: string;
2216
+ /** Concise help for finding or creating the secret. */
2217
+ description?: string;
2218
+ /** HTTPS documentation for this specific prerequisite. */
2219
+ documentationUrl?: string;
2220
+ /** Presentation hint only. Secret handling and storage semantics do not change. */
2221
+ input?: CredentialProviderSecretInput;
2222
+ /** File suffixes accepted when input is file, for example [".pem"]. */
2223
+ accept?: string[];
2224
+ }
2225
+ interface CredentialProviderSetupMetadata {
2226
+ /** Product or service family used to organize catalog entries. */
2227
+ service?: string;
2228
+ /** Outcome-oriented guidance that helps a tenant choose this provider. */
2229
+ useCase?: string;
2230
+ /** Marks the normal choice when a service exposes several authentication modes. */
2231
+ recommended?: boolean;
2232
+ /** Presentation metadata keyed by the provider's declared bootstrap Credential slots. */
2233
+ credentialSlots?: Record<string, CredentialProviderCredentialSlotSetup>;
2234
+ }
2235
+ interface CredentialProviderPackageMetadata {
2236
+ lifecycleVersion: 3;
2237
+ displayName: string;
2238
+ description: string;
2239
+ /** HTTPS documentation for acquiring and configuring this provider's external prerequisites. */
2240
+ documentationUrl?: string;
2241
+ /** Optional, non-semantic hints for a data-driven setup experience. */
2242
+ setup?: CredentialProviderSetupMetadata;
2243
+ /** Named bootstrap Credential slots used by provider lifecycle code. */
2244
+ credentialSlots: string[];
2245
+ /** Non-secret configuration collected separately for each Credential created from this provider. */
2246
+ credentialConfigSchema: object;
2247
+ /** Interactive acquisition metadata. Null for non-interactive providers. */
2248
+ interaction: {
2249
+ origins: string[];
2250
+ } | null;
2251
+ rotation: CredentialRotationDefaults;
2252
+ egress: IntegrationEgressPolicy;
2253
+ }
2254
+ interface CredentialProviderDefinition<C = unknown> extends Omit<CredentialProviderPackageMetadata, "interaction" | "credentialConfigSchema" | "lifecycleVersion"> {
2255
+ id: string;
2256
+ version: string;
2257
+ configSchema: object;
2258
+ credentialConfigSchema: object;
2259
+ interaction?: {
2260
+ origins: string[];
2261
+ start(request: CredentialInteractionStartRequest, context: IntegrationContext): Promise<CredentialInteractionResult>;
2262
+ advance(request: CredentialInteractionAdvanceRequest, context: IntegrationContext): Promise<CredentialInteractionResult>;
2263
+ };
2264
+ /** Recovery contract for renewal. Single-use refresh protocols should use outcome-unknown. */
2265
+ mintRecovery?: Extract<Recovery, {
2266
+ kind: "idempotency-key" | "outcome-unknown";
2267
+ }>;
2268
+ mint(request: CredentialMintRequest, context: IntegrationContext): Promise<CredentialMintResult>;
2269
+ verify?(request: CredentialMaterialRequest, context: IntegrationContext): Promise<CredentialVerifyResult>;
2270
+ destroy?(request: CredentialMaterialRequest, context: IntegrationContext): Promise<CredentialDestroyResult>;
2271
+ }
2272
+ type CredentialProviderContext = IntegrationContext;
2273
+ /** Validated user-authored Credential Provider package. */
2274
+ type CredentialProviderPackage<C = unknown> = Readonly<CredentialProviderDefinition<C>> & {
2275
+ readonly metadata: CredentialProviderPackageMetadata;
2276
+ };
2277
+ /** Validates the standard schema.json contract for a CredentialProvider package. */
2278
+ declare function credentialProviderConfigSchema(value: unknown): object;
2279
+ /** Validates one untrusted event before it reaches provider interaction code. */
2280
+ declare function credentialInteractionEvent(value: unknown): CredentialInteractionEvent;
2281
+ /** Validates a provider-returned action, including URLs, form schema, bounds, and the session fence. */
2282
+ declare function credentialInteractionAction(value: unknown, origins: string[], state: string, sessionExpiresAt: number): CredentialInteractionAction;
2283
+ declare function credentialInteractionResult(value: unknown, origins: string[], state: string, sessionExpiresAt: number): CredentialInteractionResult;
2284
+ declare function credentialProviderSetupMetadata(value: unknown, slots: string[]): CredentialProviderSetupMetadata | undefined;
2285
+ /** Defines and validates a Credential Provider package. */
2286
+ declare function credentialProvider<C>(definition: CredentialProviderDefinition<C>): CredentialProviderPackage<C>;
2287
+
2288
+ type ModelGatewayProtocol = "anthropic" | "openai";
2289
+ interface ModelTool {
2290
+ name: string;
2291
+ version?: string;
2292
+ description: string;
2293
+ schema: object;
2294
+ }
2295
+ interface ModelInvocationArgs {
2296
+ /** Admission-pinned logical model. Runtime code cannot override this value. */
2297
+ model?: string;
2298
+ system?: string;
2299
+ objective?: unknown;
2300
+ context?: unknown;
2301
+ tools?: ModelTool[];
2302
+ feedback?: string[];
2303
+ maxOutputTokens?: number;
2304
+ temperature?: number;
2305
+ stream?: boolean;
2306
+ }
2307
+ interface ModelCredentialHeader {
2308
+ slot: string;
2309
+ header: string;
2310
+ scheme: "bearer" | "raw";
2311
+ }
2312
+ interface ModelGatewayConfig {
2313
+ baseUrl: string;
2314
+ protocol: ModelGatewayProtocol;
2315
+ model: string;
2316
+ maxOutputTokens?: number;
2317
+ temperature?: number;
2318
+ gatewayAuth?: ModelCredentialHeader | null;
2319
+ providerAuth?: ModelCredentialHeader | null;
2320
+ }
2321
+ type NormalizedModelGatewayConfig = Omit<ModelGatewayConfig, "maxOutputTokens" | "temperature" | "gatewayAuth" | "providerAuth"> & {
2322
+ maxOutputTokens: number;
2323
+ temperature: number | null;
2324
+ gatewayAuth: ModelCredentialHeader | null;
2325
+ providerAuth: ModelCredentialHeader | null;
2326
+ };
2327
+ interface ModelInvocationResult {
2328
+ content: string;
2329
+ toolCalls?: {
2330
+ id: string;
2331
+ name: string;
2332
+ args: unknown;
2333
+ }[];
2334
+ /** Integration-observed timing for the complete upstream model request. */
2335
+ timing?: {
2336
+ upstreamMs: number;
2337
+ };
2338
+ usage: {
2339
+ input: number;
2340
+ output: number;
2341
+ cached: number;
2342
+ cacheWrite?: number;
2343
+ /** Exact upstream inference cost when the Gateway can establish it; null means unavailable. */
2344
+ costUsd?: number | null;
2345
+ costSource?: string;
2346
+ costEstimated?: boolean;
2347
+ };
2348
+ provider: string;
2349
+ model: string;
2350
+ }
2351
+ declare function normalizeModelGatewayConfig(value: unknown): NormalizedModelGatewayConfig;
2352
+ declare function modelGatewayEndpoint(config: Pick<ModelGatewayConfig, "baseUrl" | "protocol">): URL;
2353
+ declare function modelPrompt(args: ModelInvocationArgs): string;
2354
+ declare function modelProtocolRequest(protocol: ModelGatewayProtocol, model: string, maxOutputTokens: number, temperature: number | null, args: ModelInvocationArgs): Record<string, unknown>;
2355
+ declare function modelProtocolResult(protocol: ModelGatewayProtocol, raw: unknown, provider: string, model: string): ModelInvocationResult;
2356
+
2357
+ type CodeScorerRule = {
2358
+ op: "all";
2359
+ rules: CodeScorerRule[];
2360
+ } | {
2361
+ op: "any";
2362
+ rules: CodeScorerRule[];
2363
+ } | {
2364
+ op: "not";
2365
+ rule: CodeScorerRule;
2366
+ } | {
2367
+ op: "schema";
2368
+ path: string;
2369
+ schema: object;
2370
+ } | {
2371
+ op: "regex";
2372
+ path: string;
2373
+ pattern: string;
2374
+ flags?: "" | "i" | "m" | "im";
2375
+ } | {
2376
+ op: "range";
2377
+ path: string;
2378
+ min?: number;
2379
+ max?: number;
2380
+ } | {
2381
+ op: "equals";
2382
+ path: string;
2383
+ value: unknown;
2384
+ } | {
2385
+ op: "contains";
2386
+ path: string;
2387
+ value: unknown;
2388
+ } | {
2389
+ op: "tool-sequence";
2390
+ path: string;
2391
+ expected: string[];
2392
+ mode: "exact" | "ordered-subsequence";
2393
+ } | {
2394
+ op: "citations-in-source";
2395
+ textPath: string;
2396
+ sourcesPath: string;
2397
+ };
2398
+ interface CodeScorerIR {
2399
+ v: 1;
2400
+ rule: CodeScorerRule;
2401
+ }
2402
+ interface CodeScoreResult {
2403
+ score: number;
2404
+ pass: boolean;
2405
+ dimensions: null;
2406
+ evidence: {
2407
+ rule: string;
2408
+ checks: number;
2409
+ failures: {
2410
+ path: string;
2411
+ reason: string;
2412
+ }[];
2413
+ };
2414
+ }
2415
+ declare function codeScorerIR(value: unknown): CodeScorerIR;
2416
+ declare function evaluateCodeScorer(raw: CodeScorerIR | unknown, subject: unknown): CodeScoreResult;
2417
+
2418
+ declare function validateJsonSchemaDefinition(schema: unknown, path?: string, depth?: number): string | null;
2419
+ declare function validateJsonSchema(value: unknown, schema: unknown, path?: string): string | null;
2420
+
2421
+ declare class GateExhausted extends Error {
2422
+ readonly record: TurnRecord;
2423
+ constructor(record: TurnRecord);
2424
+ }
2425
+ declare class CommitGateRejected extends Error {
2426
+ readonly evaluation: ScorerEvaluation;
2427
+ constructor(evaluation: ScorerEvaluation);
2428
+ }
2429
+ declare class SpawnCardinality extends Error {
2430
+ constructor(message?: string);
2431
+ }
2432
+ declare class NondeterministicReplay extends Error {
2433
+ readonly pos: string;
2434
+ readonly expected: {
2435
+ kind: JournalKind;
2436
+ opHash: string;
2437
+ };
2438
+ readonly actual: {
2439
+ kind: JournalKind;
2440
+ opHash: string;
2441
+ };
2442
+ constructor(pos: string, expected: {
2443
+ kind: JournalKind;
2444
+ opHash: string;
2445
+ }, actual: {
2446
+ kind: JournalKind;
2447
+ opHash: string;
2448
+ });
2449
+ }
2450
+ declare class OutcomeUnknown extends Error {
2451
+ readonly pos: string;
2452
+ readonly effect: EffectClass;
2453
+ constructor(pos: string, effect: EffectClass);
2454
+ }
2455
+ declare class LeaseLost extends Error {
2456
+ constructor(message?: string);
2457
+ }
2458
+ declare class AfterYield extends Error {
2459
+ constructor();
2460
+ }
2461
+ declare class SwallowedYield extends Error {
2462
+ constructor();
2463
+ }
2464
+ declare class RollbackTargetInvalid extends Error {
2465
+ readonly target: FactRef;
2466
+ constructor(target: FactRef);
2467
+ }
2468
+ declare class CommitConflict extends Error {
2469
+ readonly expected: FactRef | undefined;
2470
+ readonly actual: FactRef | null;
2471
+ constructor(expected: FactRef | undefined, actual: FactRef | null);
2472
+ }
2473
+ declare class ResourceInvalid extends Error {
2474
+ readonly resource: string;
2475
+ constructor(resource: string);
2476
+ }
2477
+ declare class ResourceUnbound extends Error {
2478
+ readonly resource: string;
2479
+ constructor(resource: string);
2480
+ }
2481
+ declare class ToolUnavailable extends Error {
2482
+ readonly tool: string;
2483
+ constructor(tool: string);
2484
+ }
2485
+ declare class UnknownTool extends Error {
2486
+ readonly tool: string;
2487
+ constructor(tool: string);
2488
+ }
2489
+ declare class EffectCeilingExceeded extends Error {
2490
+ readonly ceiling: EffectClass;
2491
+ readonly observed: EffectClass;
2492
+ constructor(ceiling: EffectClass, observed: EffectClass);
2493
+ }
2494
+ declare class ResourceDisabled extends Error {
2495
+ readonly resource: string;
2496
+ constructor(resource: string);
2497
+ }
2498
+ declare class PolicyDecisionFailed extends Error {
2499
+ readonly decisionHash: string | null;
2500
+ constructor(decisionHash: string | null, message?: string);
2501
+ }
2502
+ declare class PolicyConstraintFailed extends PolicyDecisionFailed {
2503
+ constructor(decisionHash: string | null, message?: string);
2504
+ }
2505
+ declare class CredentialUnavailable extends Error {
2506
+ readonly credential: string;
2507
+ constructor(credential: string);
2508
+ }
2509
+ declare class CredentialRevoked extends Error {
2510
+ readonly credential: string;
2511
+ readonly version: number | null;
2512
+ constructor(credential: string, version: number | null);
2513
+ }
2514
+ declare class DirectNetworkDenied extends Error {
2515
+ constructor();
2516
+ }
2517
+ declare class SessionDeleted extends Error {
2518
+ readonly session: string;
2519
+ constructor(session: string);
2520
+ }
2521
+
2522
+ export { AfterYield, ApiError, CommitConflict, CommitGateRejected, CredentialRevoked, CredentialUnavailable, DirectNetworkDenied, EffectCeilingExceeded, GateExhausted, IntegrationRequestNotSent, LeaseLost, MCP_CLIENT_CAPABILITY, MEMORY_OPERATION_DECLARATIONS, MODEL_CHECKPOINT_IMPORT_CAPABILITY, MODEL_COMPLETION_CAPABILITY, NondeterministicReplay, OutcomeUnknown, PolicyConstraintFailed, PolicyDecisionFailed, ResourceDisabled, ResourceInvalid, ResourceUnbound, RollbackTargetInvalid, SessionDeleted, SpawnCardinality, SwallowedYield, TRAINING_PROVIDER_CAPABILITY, TerminalIntegrationFailure, ToolUnavailable, UnknownTool, action, actionPattern, agent, agentResourceBinding, analyticsEvent, approximateTokens, authProvider, authProviderName, bindingName, bucketFor, canonicalJson, capabilityContractRef, casTool, channel, checkpointArtifactRef, checkpointDeploymentRequest, checkpointImportMetadata, checkpointImportRequest, codeScorerIR, credentialInteractionAction, credentialInteractionEvent, credentialInteractionResult, credentialName, credentialProvider, credentialProviderConfigSchema, credentialProviderName, credentialProviderSetupMetadata, credentialRotationDefaults, customerTenantName, cutBatches, cutPartitions, datasetName, evaluateCodeScorer, evaluatePolicyDefinition, gateway, gatewayModelOffer, gatewayPackageMetadata, hash, hashValue, integrationEgressPolicy, labelSelector, matchesAction, matchesLabelSelector, matchesResource, memoryStoreBinding, modelAdvertisedPricing, modelControls, modelGatewayBinding, modelGatewayEndpoint, modelLimit, modelPrompt, modelProtocolRequest, modelProtocolResult, murmur3_32, normalizeModelGatewayConfig, normalizeSandboxNetworkPolicy, opTool, opTools, parseResourceName, policy, policyName, renderTrainingCompletion, resolveGatewayEgress, resourceContractRef, resourceCredentialBinding, resourceLabelMap, resourceName, resourceNeed, resourcePattern, resourceSelector, sandboxControls, sandboxLimit, scopedBindingKey, scopedCredentialRef, scopedResourceRef, scorerName, sha256Hex, stageOutput, startTrainingRequest, subtask, tableDescribe, tableQuery, trainingProvider, trainingProviderMetadata, trainingRecipe, validateBatchSpec, validateFoldFn, validateJsonSchema, validateJsonSchemaDefinition, validatePartitionFn, validatePartitionSpec, validateStageOutputSpec, validateTool, validateView, webFetch, webSearch };
2523
+ export type { Action, ActionPattern, Actor, AdmissionLimitConstraint, AdmissionLimitInput, AdmissionLimitScope, AdmissionLimitWindow, Agent, AgentDef, AgentDeployPolicy, AnalyticsClient, AnalyticsDimensionValue, AnalyticsEventDefinition, AnalyticsIntent, AnalyticsValues, AuthProvider, AuthProviderCRN, AuthProviderContext, AuthProviderRequest, AuthProviderResult, AwaitOpts, BatchSpec, BindingCRN, BindingOwnerScope, BranchRef, CRN, CRNKind, CanonicalEvent, CanonicalEventDraft, CapabilityContractRef, CapabilityGrant, CapabilityRef, CaptureCaseRequest, CaseRow, CatalogTool, Channel, ChannelAlarm, ChannelAlarmResult, ChannelContext, ChannelMessage, ChannelProtocol, ChannelRequest, ChannelResponse, CheckpointDeploymentRequest, CheckpointImportMetadata, CheckpointImportRequest, CodeScoreResult, CodeScorerIR, CodeScorerRule, CommitOpts, CompareSuitesRequest, Compensation, ConnectionCancelRequest, ConnectionIdentity, ConnectionOperation, ConnectionRecoveryRequest, ConnectionRecoveryResult, ConnectionRequest, ConnectionUsageReport, ControlEvent, Cost, CreateSandboxOptions, CredentialCRN, CredentialDestroyResult, CredentialInteractionAction, CredentialInteractionAdvanceRequest, CredentialInteractionEvent, CredentialInteractionPrimaryAction, CredentialInteractionProof, CredentialInteractionResult, CredentialInteractionStartRequest, CredentialMaterialRequest, CredentialMintRequest, CredentialMintResult, CredentialProviderCRN, CredentialProviderContext, CredentialProviderCredentialSlotSetup, CredentialProviderDefinition, CredentialProviderPackage, CredentialProviderPackageMetadata, CredentialProviderSecretInput, CredentialProviderSetupMetadata, CredentialVerifyResult, Ctx, CustomerTenantCRN, DataManifest, DatasetCRN, DatasetDraft, DatasetRef, DelegatedGrant, DelegationCeiling, DeliveryMode, DeliveryReceipt, DispatchResult, EffectClass, EvalComparison, EvalDivergence, EvalMode, EvalSubject, EvalSubjectSource, EventBase, Fact, FactRef, FileEntry, FixedMemoryStoreRef, FixedModelGatewayRef, FoldFn, GateEvidence, GateResult, GateVerdict, GatewayCancelRequest, GatewayConfigEgressBinding, GatewayContext, GatewayCredentialSlotSetup, GatewayDefinition, GatewayDiscoverySetup, GatewayModelOffer, GatewayOperation, GatewayPackage, GatewayPackageMetadata, GatewayRecoveryRequest, GatewayRecoveryResult, GatewayRequest, GovernanceContractRef, Handle, HandleOutcome, Hash, HistoryView, IntegrationContext, IntegrationEgressPolicy, IntegrationEgressRequest, IntegrationEgressResponse, IntegrationEgressRule, IntegrationSecret, IntegrationState, InvokableKind, InvokeOpts, JsonScalar, JsonValue, LabelRequest, LabelSelector, LabelSelectorOperator, LabelSelectorRequirement, LedgerAddress, LedgerEvent, ManifestIndexPage, MapFact, MapOpts, MemoryDeleteArgs, MemoryGetArgs, MemoryRecord, MemoryRememberArgs, MemorySearchArgs, MemorySearchHit, MemoryStoreBinding, Mode, ModelAdvertisedPricing, ModelCredentialHeader, ModelGatewayBinding, ModelGatewayConfig, ModelGatewayProtocol, ModelGovernanceControls, ModelGovernanceMeter, ModelInvocationArgs, ModelInvocationResult, ModelTechnicalCapabilities, ModelTool, NormalizedModelGatewayConfig, Out, Over, PartitionFn, PartitionSpec, Partitioning, PolicyCRN, PolicyConstraint, PolicyContextValue, PolicyDefinition, PolicyInput, PolicyInvocationOrigin, PolicyOutcome, Principal, PrincipalKind, Provenance, Recovery, ReduceFact, ReduceOpts, Ref, RequestLabelRequest, ResourceContractRef, ResourceControlsConstraint, ResourceCredentialBinding, ResourceKind, ResourceName, ResourceNameParts, ResourceNeed, ResourcePattern, ResourceSelector, RollbackReport, RunIdentityView, RunInfo, RunStatusDetail, RunSuiteRequest, Sandbox, SandboxCommandResult, SandboxExecInput, SandboxFileResult, SandboxGovernanceControls, SandboxGovernanceMeter, SandboxImage, SandboxMutationResult, SandboxNetworkMode, SandboxNetworkPolicy, SandboxPool, ScopedBindingKey, ScopedCredentialRef, ScopedMemoryStoreRef, ScopedModelGatewayRef, ScopedResourceRef, ScoreRequest, ScorerApplies, ScorerCRN, ScorerDef, ScorerEvaluation, ScorerKind, ScorerRef, ScorerVerdictIntent, SetEvalBaselineRequest, SortField, SpawnOpts, SqlFold, StageInfo, StageOutputSpec, StartTrainingRequest, SteerEvent, SuiteFact, TableAggregate, TableDescribeArgs, TableFilter, TableFilterOperation, TableOrder, TableQueryArgs, TableQueryPlan, TableQueryResult, TableScalar, TableSnapshotDescription, Task, Tier, Tool, ToolCallRecord, TrainingJobFact, TrainingJobReference, TrainingJobState, TrainingJobStatus, TrainingMethod, TrainingModelOffer, TrainingProviderDefinition, TrainingProviderMetadata, TrainingProviderPin, TrainingRecipe, TrainingResumePoint, TrainingUsageUnits, TurnDraft, TurnGate, TurnRecord, TurnSpec, UpstreamPayer, Verdict, VerdictSamplingMode, ViewDef, WaitResolvedEvent };