@open-conduit/sdk 0.0.0-stage → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/actions.d.ts +145 -0
  4. package/dist/actions.js +281 -0
  5. package/dist/actiontest.d.ts +80 -0
  6. package/dist/actiontest.js +190 -0
  7. package/dist/artifactstore.d.ts +133 -0
  8. package/dist/artifactstore.js +364 -0
  9. package/dist/backup.d.ts +99 -0
  10. package/dist/backup.js +178 -0
  11. package/dist/containertest.d.ts +71 -0
  12. package/dist/containertest.js +294 -0
  13. package/dist/errors.d.ts +127 -0
  14. package/dist/errors.js +180 -0
  15. package/dist/executor.d.ts +374 -0
  16. package/dist/executor.js +556 -0
  17. package/dist/executortest.d.ts +183 -0
  18. package/dist/executortest.js +534 -0
  19. package/dist/extension.d.ts +855 -0
  20. package/dist/extension.js +1822 -0
  21. package/dist/feed.d.ts +20 -0
  22. package/dist/feed.js +88 -0
  23. package/dist/forward.d.ts +38 -0
  24. package/dist/forward.js +163 -0
  25. package/dist/forwardca.d.ts +21 -0
  26. package/dist/forwardca.js +144 -0
  27. package/dist/hooks.d.ts +108 -0
  28. package/dist/hooks.js +13 -0
  29. package/dist/host.d.ts +295 -0
  30. package/dist/host.js +486 -0
  31. package/dist/index.d.ts +34 -0
  32. package/dist/index.js +31 -0
  33. package/dist/jsonrpc.d.ts +39 -0
  34. package/dist/jsonrpc.js +350 -0
  35. package/dist/probe.d.ts +61 -0
  36. package/dist/probe.js +92 -0
  37. package/dist/providertest.d.ts +59 -0
  38. package/dist/providertest.js +168 -0
  39. package/dist/resources.d.ts +208 -0
  40. package/dist/resources.js +303 -0
  41. package/dist/sandbox.d.ts +84 -0
  42. package/dist/sandbox.js +85 -0
  43. package/dist/schema.d.ts +71 -0
  44. package/dist/schema.js +252 -0
  45. package/dist/setup.d.ts +145 -0
  46. package/dist/setup.js +179 -0
  47. package/dist/setuptest.d.ts +90 -0
  48. package/dist/setuptest.js +319 -0
  49. package/dist/storetest.d.ts +64 -0
  50. package/dist/storetest.js +740 -0
  51. package/dist/telemetry.d.ts +86 -0
  52. package/dist/telemetry.js +46 -0
  53. package/dist/testing.d.ts +756 -0
  54. package/dist/testing.js +2165 -0
  55. package/dist/toolbelt.d.ts +91 -0
  56. package/dist/toolbelt.js +216 -0
  57. package/dist/tunnel.d.ts +62 -0
  58. package/dist/tunnel.js +93 -0
  59. package/dist/wire.d.ts +5359 -0
  60. package/dist/wire.js +2211 -0
  61. package/package.json +29 -4
@@ -0,0 +1,756 @@
1
+ import type { BackupChunk, BackupFile } from "./backup.js";
2
+ import { type Extension } from "./extension.js";
3
+ import type { ResourceOwnerStatus } from "./resources.js";
4
+ import { type RunLayer } from "./telemetry.js";
5
+ import { type Candidate } from "./setup.js";
6
+ import { type TestConfig, type TestSetupOptions, type TestSetupRecord } from "./setuptest.js";
7
+ import { type TestExecutor } from "./executortest.js";
8
+ import { type Value } from "./host.js";
9
+ import { type Infer } from "./schema.js";
10
+ import { type AcceptedEvent, type ArtifactRef, type Authority, type CheckRunResult, type ConfigEntry, ConfigureResult, ContainerCreated, type ContainerPin, ContainerPlan, type ContainerRef, ContainerState, type ContainerUse, type Event, type Payload, type Resource, ResourceAcquireParams, ResourceReport, ResourceSweepReport, SetupRunResult, type TelemetryEvent, type Metric, type TelemetryRecord, type ResourceUnsaved, SandboxPlan, type PendingInput, Placement, type ResourceOwner, type Route, RouteDecision, type RouteInput, RouteSample, type SandboxLaunch, type SandboxNeeds, type SandboxPaths, type Scan, type Scope, CredentialVerifyResult, SecretDeleteResult, SecretServeResult, SecretStoreResult, Snapshot, type SourceDecl, WaitPlan, type Work, type Annotation, type ConnectionEntry, ProbeRunResult, type ActionOffer, type Key, type RequestOffer, type Timer } from "./wire.js";
11
+ import type { TestActionProvider } from "./actiontest.js";
12
+ /** The test clock's start (sdktest.Start, conformance.NewClock's start). */
13
+ export declare const testStart = "2026-10-24T12:00:00.000Z";
14
+ /** The host's clock. It moves only when the test moves it. */
15
+ export declare class TestClock {
16
+ #private;
17
+ constructor(start?: string | Date);
18
+ /** The clock's time, as an RFC 3339 string. */
19
+ now(): string;
20
+ /** Moves the clock on by ms milliseconds. */
21
+ advance(ms: number): void;
22
+ /** Sets the clock to a time. */
23
+ set(at: string | Date): void;
24
+ }
25
+ export interface TestHostOptions {
26
+ clock?: TestClock;
27
+ /** Scopes configured for the extension (configure's entries add theirs). */
28
+ scopes?: string[];
29
+ /** Seeded Work; its scope is configured. */
30
+ works?: Work[];
31
+ /** Seeded accepted Events, in order, each in a scope. */
32
+ events?: {
33
+ scopeId: string;
34
+ event: Event;
35
+ }[];
36
+ /** Input routed to a Work that no attempt has read yet, by Work ID. */
37
+ pending?: Record<string, PendingInput[]>;
38
+ /** Secret values an entry may resolve, by scope. */
39
+ secrets?: Record<string, Record<string, string>>;
40
+ /** Secret values of a connection in a scope. */
41
+ connectionSecrets?: {
42
+ scopeId: string;
43
+ connection: string;
44
+ values: Record<string, string>;
45
+ }[];
46
+ /** Secret values a binding in a scope selects, for a binding of one of the extension's executors. */
47
+ bindingSecrets?: {
48
+ scopeId: string;
49
+ binding: string;
50
+ values: Record<string, string>;
51
+ }[];
52
+ /** Seeded KV values. */
53
+ kv?: {
54
+ namespace: string;
55
+ key: string;
56
+ value: Value;
57
+ }[];
58
+ /** The KV layout the host has recorded (default 0). */
59
+ kvVersion?: number;
60
+ /** The operator's config file's directory given at initialize (default none). */
61
+ configDir?: string;
62
+ /** The private state directory given at initialize (default "/sdktest/state"). */
63
+ stateDir?: string;
64
+ /** The authority operation calls carry; unset fields are defaulted. */
65
+ authority?: Partial<Authority>;
66
+ /** The state directories of the extension's container provider types, by type, given at initialize. */
67
+ containerDirs?: Record<string, string>;
68
+ /** The host's container label given at initialize (default "sdktest-host" when the extension declares containers). */
69
+ containerHost?: string;
70
+ /** The host's former container labels given at initialize. */
71
+ containerFormerHosts?: string[];
72
+ /** The state directories of the extension's executors, by name, given at initialize (default <stateDir>/executors/<name>). */
73
+ executorDirs?: Record<string, string>;
74
+ /** The state directories of the extension's resource provider types, by type, given at initialize (default <stateDir>/resources/<type>). */
75
+ resourceDirs?: Record<string, string>;
76
+ /** Answers a run's resource.acquire and resource.lookup, as the binding's resource provider would. */
77
+ resources?: {
78
+ acquire?: (p: Infer<typeof ResourceAcquireParams>) => Resource;
79
+ lookup?: (ref: string) => Resource;
80
+ };
81
+ /**
82
+ * Answers a run's sandbox.plan and sandbox.adopt, as the binding's
83
+ * sandbox provider bound by the host would. A run whose request doesn't
84
+ * set context.sandbox is refused, as the host refuses it.
85
+ */
86
+ sandbox?: TestSandboxBroker;
87
+ /** Answers a run's container.launch, adopt and reattach, as the binding's container provider bound by the host would; only for a run whose request sets context.container. */
88
+ container?: TestContainerBroker;
89
+ /**
90
+ * The sites a resource provider declared with sites may run commands at,
91
+ * by ID: an acquisition given one runs there under its call, and
92
+ * site.run naming one without a call reaches it as the host's resolver
93
+ * would.
94
+ */
95
+ sites?: Record<string, TestSite>;
96
+ /**
97
+ * The configuration the host's config service holds (config.*, for an
98
+ * extension with the config.read permission). Without it config.* is
99
+ * refused, as a host with no configuration yet refuses it.
100
+ */
101
+ config?: TestConfig;
102
+ /**
103
+ * Answers wait.target as the extensions that resolve a kind would:
104
+ * the key and types that end the target, or undefined for none. Without
105
+ * it wait.target is refused as unsupported.
106
+ */
107
+ waitTargets?: (scopeId: string, kind: string, name: string) => {
108
+ key: Key;
109
+ types: string[];
110
+ } | undefined;
111
+ /**
112
+ * Answers scope.authorize as the operator's authorization would:
113
+ * undefined allows, a string is the reason it doesn't. Without it
114
+ * scope.authorize is refused as unsupported.
115
+ */
116
+ authorize?: (kind: string, from: string, to: string) => string | undefined;
117
+ /** Answers event.render_owned as the extension owning the Event's family would; undefined leaves it unrendered. */
118
+ renderOwned?: (event: Event) => string | undefined;
119
+ /**
120
+ * The action providers action.list, request.list and action.submit
121
+ * reach, for an extension with the action.submit permission. submit
122
+ * answers the Event the action records (accepted in the call's scope,
123
+ * with delivery ID "<extension>/<key>" unless it sets one, so a retry
124
+ * with the same key adds nothing) and the provider's message, or throws
125
+ * OperationError to refuse.
126
+ */
127
+ actions?: TestActions;
128
+ }
129
+ /** The action providers a test host's action.* calls reach (TestHostOptions.actions). */
130
+ export interface TestActions {
131
+ offers?: (scopeId: string, workId: string) => ActionOffer[];
132
+ requests?: (scopeId: string, workId: string) => RequestOffer[];
133
+ submit?: (call: TestActionSubmit) => {
134
+ event: Event;
135
+ message?: string;
136
+ };
137
+ }
138
+ /** An action.submit as the provider sees it: the caller is {kind: the extension's name, id}. */
139
+ export interface TestActionSubmit {
140
+ scopeId: string;
141
+ workId: string;
142
+ provider: string;
143
+ action: string;
144
+ input: string;
145
+ caller: {
146
+ kind: string;
147
+ id: string;
148
+ };
149
+ key: string;
150
+ }
151
+ /** A timer the extension armed (host.armTimer), as the test host holds it. */
152
+ export interface TestTimer {
153
+ scopeId: string;
154
+ timer: Timer;
155
+ kind: string;
156
+ spec: unknown;
157
+ }
158
+ /** What one firing of a recurring timer did (TestHost.fireTimer). */
159
+ export interface TestFiring {
160
+ /** The occurrence accepted, if the recurrence answered one. */
161
+ occurrence?: AcceptedEvent;
162
+ /** The timer re-armed, if the recurrence answered a next one; else the timer is gone. */
163
+ next?: Timer;
164
+ }
165
+ /** What an operation returned: a handler's output, a wait's plan, an emission's Event and commit output. */
166
+ export interface OperationOut {
167
+ /** The output's data (a handler's, a wait plan's, or an emission's commit's). */
168
+ output: unknown;
169
+ wait?: WaitPlan;
170
+ event?: AcceptedEvent;
171
+ /** False when an emission's once matched one already accepted. */
172
+ added?: boolean;
173
+ }
174
+ export interface WebhookCall {
175
+ method?: string;
176
+ query?: string;
177
+ headers?: Record<string, string | string[]>;
178
+ body?: Value;
179
+ /** The host's receipt time (default now). */
180
+ receivedAt?: string;
181
+ forwardId?: string;
182
+ }
183
+ export interface WebhookOut {
184
+ status: number;
185
+ headers: Record<string, string[]>;
186
+ body: Uint8Array;
187
+ }
188
+ /** A secret scheme reached over the wire (TestHost.secretProvider). */
189
+ export interface TestSecretProvider {
190
+ serve(reference: string): Promise<string>;
191
+ store(name: string, value: string, o?: {
192
+ owner?: string;
193
+ config?: unknown;
194
+ }): Promise<string>;
195
+ delete(reference: string, o?: {
196
+ owner?: string;
197
+ }): Promise<void>;
198
+ }
199
+ /** A credential verifier reached over the wire, under one trusted issuer (TestHost.credentialVerifier). */
200
+ export interface TestCredentialVerifier {
201
+ /**
202
+ * One credential.verify: who the credential names, or a
203
+ * CredentialRefusal when the verifier refused it or failed, as the host
204
+ * answers 401 either way.
205
+ */
206
+ verify(token: string): Promise<{
207
+ subject: string;
208
+ groups: string[];
209
+ expiresAt: Date;
210
+ }>;
211
+ }
212
+ /**
213
+ * A backup destination under one configured target, reached over the wire
214
+ * as the host reaches it (TestHost.backupDestination).
215
+ */
216
+ export interface TestBackupDestination {
217
+ /**
218
+ * Puts one file as the host does: in chunks of at most MaxChunkBytes
219
+ * under a fresh upload ID, the last one final. If body fails, or ends
220
+ * before file.size, the upload is aborted and put rejects.
221
+ */
222
+ put(bundle: string, file: BackupFile, body: Uint8Array | AsyncIterable<Uint8Array>): Promise<void>;
223
+ list(): Promise<string[]>;
224
+ files(bundle: string): Promise<BackupFile[]>;
225
+ /** One backup_destination.read, its length capped at MaxChunkBytes as the host caps it. */
226
+ read(bundle: string, path: string, offset: number, length: number): Promise<BackupChunk>;
227
+ }
228
+ /** One committed artifact. */
229
+ export interface TestArtifact {
230
+ ref: ArtifactRef;
231
+ mediaType: string;
232
+ data: Uint8Array;
233
+ }
234
+ /** A KV value's version: a digest of its content, as sdktest.Version. */
235
+ export declare function kvVersion(value: Uint8Array): string;
236
+ /**
237
+ * Serves ext on an in-memory host and initializes it. Close it when the
238
+ * test ends (in an after hook), so the served connection ends.
239
+ */
240
+ export declare function testHost(ext: Extension, o?: TestHostOptions): Promise<TestHost>;
241
+ export declare class TestHost {
242
+ #private;
243
+ readonly clock: TestClock;
244
+ readonly stateDir: string;
245
+ constructor(ext: Extension, o: TestHostOptions);
246
+ /** @internal */
247
+ _initialize(): Promise<void>;
248
+ /** The host's container label the extension was given. */
249
+ get containerHost(): string;
250
+ /** Ends the served connection. */
251
+ close(): void;
252
+ /** The host clock's time. */
253
+ now(): string;
254
+ /** Makes any host-to-extension call, for a surface without a helper. */
255
+ call(method: string, p: unknown): Promise<unknown>;
256
+ /**
257
+ * Applies a configuration generation. Each entry's scope becomes
258
+ * configured, and the sources the result registers can be delivered to,
259
+ * reconciled and sent webhooks.
260
+ */
261
+ configure(entries: ConfigEntry[], o?: {
262
+ disabled?: ConfigEntry[];
263
+ publicUrl?: string;
264
+ /** The bindings whose container provider the extension declares. */
265
+ containers?: ContainerUse[];
266
+ }): Promise<ConfigureResult>;
267
+ /** Checks a config object as config check does: throws the extension's refusal. */
268
+ validate(kind: string, type: string, config: unknown): Promise<void>;
269
+ /**
270
+ * Calls a declared operation with input as its data, by the kind the
271
+ * manifest declares. Unset authority fields default: the first
272
+ * configured scope, Work "sdktest-work", execution "sdktest-execution",
273
+ * an expiry an hour from now, every declared operation and family. An
274
+ * emission is accepted in the authority's scope, and its commit's
275
+ * records are written to KV, as the toolbelt would.
276
+ */
277
+ operation(name: string, input?: unknown, authority?: Partial<Authority>): Promise<OperationOut>;
278
+ /** Asks a route handler to match one input; route.config is given as its data. */
279
+ route(handler: string, input: Omit<RouteInput, "event"> & {
280
+ event: Event | AcceptedEvent;
281
+ }): Promise<RouteDecision>;
282
+ /** The sample Events a route handler offers for a route of a scope, as of the clock's now. */
283
+ samples(handler: string, scope: Scope, route: Route): Promise<RouteSample[]>;
284
+ /** Reads one page of a registered source. */
285
+ reconcile(source: string, scan?: Omit<Scan, "source">): Promise<Snapshot>;
286
+ /** Reads every page of a registered source, from its first. */
287
+ reconcileAll(source: string): Promise<Snapshot[]>;
288
+ /** Pushes a delivery to a registered source and accepts what it observed, as the host's ingress does. */
289
+ push(source: string, delivery: {
290
+ id: string;
291
+ body: Value;
292
+ contentType?: string;
293
+ receivedAt?: string;
294
+ }): Promise<{
295
+ accepted: AcceptedEvent[];
296
+ added: boolean[];
297
+ }>;
298
+ /**
299
+ * Sends one HTTP request on a webhook path, as the host's listener
300
+ * does. A path no registered source took answers 404 here, as the
301
+ * listener answers it, without reaching the extension.
302
+ */
303
+ webhook(path: string, req?: WebhookCall): Promise<WebhookOut>;
304
+ /** Asks a Work kind's trigger which of inputs triggers the next execution. */
305
+ trigger(kind: string, inputs: Event[]): Promise<number>;
306
+ /** Runs a background task once. */
307
+ task(name: string): Promise<void>;
308
+ /** Runs a doctor check, with an empty configuration view unless config is given. */
309
+ check(name: string, o?: {
310
+ deep?: boolean;
311
+ config?: unknown;
312
+ }): Promise<CheckRunResult>;
313
+ /**
314
+ * Asks the extension's secret scheme for the value reference names
315
+ * (secret.serve), as the host's resolver does: the value, or the code it
316
+ * refused with. An answer with both, or neither, fails the call.
317
+ */
318
+ serveSecret(scheme: string, reference: string): Promise<SecretServeResult>;
319
+ /**
320
+ * Asks a writable secret scheme to store value under name for owner
321
+ * (secret.store): the reference that reads it back, or the code it
322
+ * refused with. Unless given, owner is "sdktest-store" and there is no
323
+ * config.
324
+ */
325
+ storeSecret(scheme: string, name: string, value: string, o?: {
326
+ owner?: string;
327
+ config?: unknown;
328
+ }): Promise<SecretStoreResult>;
329
+ /** Asks a writable secret scheme to remove what reference names (secret.delete): empty, or the code it refused with. */
330
+ deleteSecret(scheme: string, reference: string, o?: {
331
+ owner?: string;
332
+ }): Promise<SecretDeleteResult>;
333
+ /**
334
+ * The extension's secret scheme as the host reaches it over the wire
335
+ * (sdktest.Host.SecretProvider): each call is one secret.serve,
336
+ * secret.store or secret.delete, a refused one throwing SecretRefusal
337
+ * with its code.
338
+ */
339
+ secretProvider(scheme: string): TestSecretProvider;
340
+ /**
341
+ * Asks the extension's credential verifier of type about token
342
+ * (credential.verify) under a trusted issuer's config, as the host does
343
+ * (sdktest.Host.Verify): the answer, or the ProtocolError it refused
344
+ * with. Unless given, the issuer's ID is "sdktest-issuer" and its config
345
+ * empty. The answer must name a subject and a valid expires_at.
346
+ */
347
+ verify(type: string, token: string, o?: {
348
+ issuer?: string;
349
+ config?: unknown;
350
+ }): Promise<CredentialVerifyResult>;
351
+ /**
352
+ * The extension's credential verifier of type, under one trusted
353
+ * issuer's config, as the host reaches it over the wire: each verify is
354
+ * one credential.verify, a refusal or failure thrown as
355
+ * CredentialRefusal.
356
+ */
357
+ /**
358
+ * The extension's actions, requests and panels as the host reaches them
359
+ * over the wire (extproc's remoteActions): each call one work.actions,
360
+ * work.act, work.requests or view.render, its answer checked as the host
361
+ * reads it. An invocation's refusal throws the OperationError (or
362
+ * ProtocolError) it crossed as. An extension that serves no requests or
363
+ * no panels shows none, as the host treats it.
364
+ */
365
+ actionProvider(): TestActionProvider;
366
+ /** Asks for the extension's annotations of work (work.annotate), as the host does. */
367
+ annotate(work: Work): Promise<Annotation[]>;
368
+ /**
369
+ * Runs one of the extension's probes (probe.serve) as the host's
370
+ * probe.run does: arguments it doesn't declare, or a required one
371
+ * missing, are refused before the probe sees them. With connection, the
372
+ * run goes through that connection in scopeId, and the probe may read
373
+ * its values (default none) until the run ends.
374
+ */
375
+ probe(name: string, args?: Record<string, string>, o?: {
376
+ scopeId?: string;
377
+ connection?: ConnectionEntry;
378
+ values?: Record<string, string>;
379
+ }): Promise<ProbeRunResult>;
380
+ credentialVerifier(type: string, o?: {
381
+ issuer?: string;
382
+ config?: unknown;
383
+ }): TestCredentialVerifier;
384
+ /**
385
+ * The extension's container provider of type as the host reaches it over
386
+ * the wire (extproc's remoteContainer): each call one
387
+ * container_provider.* request, its answer checked as the host reads it.
388
+ */
389
+ containerProvider(type: string): TestContainerProvider;
390
+ /**
391
+ * The extension's resource provider of type as the host reaches it over
392
+ * the wire (extproc's remoteProvider): each call one provider.* or
393
+ * validate request. reconcile and sweep answer the provider's
394
+ * provider.owner_status from status while they run, and an acquisition
395
+ * given a site runs its site.run there, as the host does.
396
+ */
397
+ resourceProvider(type: string): TestResourceProvider;
398
+ /**
399
+ * The extension's sandbox provider of type as the host reaches it over
400
+ * the wire (extproc's remoteSandbox): plan answers the plan with the
401
+ * digest the host pins (sandboxDigest), and adopt is one call.
402
+ */
403
+ sandboxProvider(type: string): TestSandboxProvider;
404
+ /**
405
+ * The extension's tunnel provider of type as the host runs it (extproc's
406
+ * remoteTunnel): start holds one tunnel.run open, taking the URLs the
407
+ * run publishes as the host does (refusing one checkPublicURL refuses),
408
+ * until stop cancels it.
409
+ */
410
+ tunnelProvider(type: string): TestTunnelProvider;
411
+ /**
412
+ * The extension's executor of name as the host reaches it over the wire
413
+ * (extproc's remoteExecutor): run, recover and resume each one call,
414
+ * their persist_recovery answered by the persist the call was given
415
+ * (refused without one), the handle's wait one executor.wait, and each
416
+ * control one call, refused without one when the manifest doesn't
417
+ * declare it.
418
+ */
419
+ executor(name: string): TestExecutor;
420
+ /**
421
+ * The extension's backup destination of type under one configured
422
+ * target, as the host reaches it over the wire (extproc's
423
+ * remoteBackupDestination). Unless given, the target's name is
424
+ * "sdktest-destination" and its config empty.
425
+ */
426
+ backupDestination(type: string, o?: {
427
+ name?: string;
428
+ config?: unknown;
429
+ }): TestBackupDestination;
430
+ /**
431
+ * Sends the extension's exporter a batch of lifecycle records
432
+ * (telemetry.export), as the host's telemetry pipeline does. Only an
433
+ * extension that declares exporters is sent any.
434
+ */
435
+ exportTelemetry(records: TelemetryRecord[]): Promise<void>;
436
+ /**
437
+ * Sends the extension one collection of the host's meter
438
+ * (telemetry.metrics), as the host does only for an extension with the
439
+ * telemetry.metrics permission.
440
+ */
441
+ exportMetrics(metrics: Metric[]): Promise<void>;
442
+ /**
443
+ * Hands the extension one of the host's named telemetry events
444
+ * (telemetry.sink), as the host hands each to every extension with the
445
+ * telemetry.sink permission, and returns whether it was sent: one
446
+ * without the permission gets nothing. at defaults to the clock's now.
447
+ */
448
+ sink(e: {
449
+ scopeId?: string;
450
+ name: string;
451
+ at?: string;
452
+ properties?: Record<string, unknown>;
453
+ }): Promise<boolean>;
454
+ /**
455
+ * Asks for the extension's environment layer for a run
456
+ * (run.environment), as the host does: an extension that doesn't
457
+ * declare run_environment has none; files for a run with no filesDir
458
+ * are dropped; files checkRunFiles refuses fail the call as they fail
459
+ * the run (ProtocolError invalid); and env is what the host applies,
460
+ * without the variables it skips (appliedEnv).
461
+ */
462
+ runEnvironment(r: {
463
+ owner: ResourceOwner;
464
+ connection?: string;
465
+ binding?: string;
466
+ filesDir?: string;
467
+ }): Promise<RunLayer>;
468
+ /**
469
+ * Asks what a Work proposes (config.candidate), as the host does: an
470
+ * extension that doesn't declare config_candidate, or lacks the
471
+ * config.read permission, is never asked and has none (undefined), as is
472
+ * a Work it proposes nothing on. A candidate whose handle the host
473
+ * doesn't hold is refused (ProtocolError not_found), as the daemon
474
+ * refuses to serve it; configText(handle) is the text behind one it
475
+ * does, as the operator is served it.
476
+ */
477
+ configCandidate(work: Work): Promise<Candidate | undefined>;
478
+ /** The config text behind a handle the host gave out, unredacted, as the operator is served it; undefined for one it doesn't hold. */
479
+ configText(handle: string): string | undefined;
480
+ /**
481
+ * Runs the extension's setup flow of type (setup.run), as `open-conduit
482
+ * init <type>` does: its setup.* callbacks are answered from o for this
483
+ * run alone, and any quoting another run ID is refused as conflict.
484
+ * Returns what the flow answered and what the operator saw. A flow the
485
+ * manifest doesn't declare is refused without a call.
486
+ */
487
+ setup(type: string, o?: TestSetupOptions): Promise<{
488
+ result: SetupRunResult;
489
+ record: TestSetupRecord;
490
+ }>;
491
+ /** The timers the extension has armed, by ID. */
492
+ timers(): TestTimer[];
493
+ /**
494
+ * Fires one of the extension's armed timers, as the host does at its
495
+ * fire_at (the clock is not moved): it asks the timer's recurrence for
496
+ * the occurrence and the next timer (recurrence.next), checks both as
497
+ * the runtime does, accepts the occurrence in the timer's scope and
498
+ * re-arms the next, or drops the timer when there is none. A refused
499
+ * answer (ProtocolError invalid, unauthorized or schema) changes
500
+ * nothing, and the timer stays due, as an aborted firing leaves it.
501
+ */
502
+ fireTimer(id: string): Promise<TestFiring>;
503
+ /**
504
+ * Asks the extension's dependency filter whether event matches filter
505
+ * (dependency.filter), as core does for an Event on a wait's
506
+ * dependency. An extension that doesn't declare dependency_filter
507
+ * matches everything, as core matches without a filter; one that
508
+ * refuses the call (unreadable or undeclared) does not match.
509
+ */
510
+ dependencyFilter(filter: Payload, event: Event): Promise<boolean>;
511
+ /**
512
+ * Asks the extension's operation gate about a call to another
513
+ * extension's operation (operation.gate), as the toolbelt does:
514
+ * undefined lets it through, a plan parks the caller. An extension
515
+ * without the declaration or the operation.gate permission is never
516
+ * asked, nor about a call outside its scopes. The host fails closed: an
517
+ * OperationError reaches the caller as it is, and anything else (a
518
+ * protocol error, an unreadable plan) refuses the call as gate_failed.
519
+ */
520
+ gate(call: {
521
+ operation: string;
522
+ owner: string;
523
+ input?: Payload;
524
+ authority?: Partial<Authority>;
525
+ capability?: string;
526
+ wants?: string;
527
+ }): Promise<WaitPlan | undefined>;
528
+ /**
529
+ * Asks the extension's start gate about a Work's first attempt
530
+ * (work.admit), as the runtime does: undefined lets the start through,
531
+ * a hold holds the Work until host.settleHold settles it (holds()). An
532
+ * extension without the declaration or the work.start_gate permission
533
+ * is never asked, nor about Work outside its scopes; what it throws
534
+ * refuses the start for now.
535
+ */
536
+ admit(call: {
537
+ work: Work;
538
+ binding?: string;
539
+ event: Event;
540
+ }): Promise<{
541
+ reason: string;
542
+ } | undefined>;
543
+ /** The Work the extension's start gate holds now, by ID, with each hold's reason. */
544
+ holds(): Record<string, string>;
545
+ /** How each hold the extension settled ended, by Work ID: "admitted" or "cancelled". */
546
+ settled(): Record<string, string>;
547
+ /** The Work the extension cancelled (work.cancel), by ID, with each reason. */
548
+ cancelled(): Record<string, string>;
549
+ /**
550
+ * Resolves a wait target of kind in a scope through the extension
551
+ * (target.resolve), as the host does: only a kind it declares, only in
552
+ * its scopes, and nothing when it answers a type that isn't one of its
553
+ * families or the call fails.
554
+ */
555
+ resolveTarget(scopeId: string, kind: string, name: string): Promise<{
556
+ key: Key;
557
+ types: string[];
558
+ } | undefined>;
559
+ /**
560
+ * Tells the extension an execution's container segment ended
561
+ * (segment.ended), and waits for it, though the host doesn't: what it
562
+ * throws is returned rather than thrown, as the host ignores it. An
563
+ * extension without segment_end is never told.
564
+ */
565
+ segmentEnded(executionId: string): Promise<unknown>;
566
+ /**
567
+ * Renders an Event for an agent's prompt through the extension
568
+ * (event.render), as the host does: undefined, the host's generic
569
+ * rendering, for an extension without render, an Event of a family it
570
+ * doesn't own or a payload it can't read, a failed call, or no answer.
571
+ */
572
+ render(event: Event): Promise<string | undefined>;
573
+ /** A KV value, or undefined. */
574
+ kv(namespace: string, key: string): Uint8Array | undefined;
575
+ /** A KV value as UTF-8 text, or undefined. */
576
+ kvText(namespace: string, key: string): string | undefined;
577
+ /** Every accepted Event, in order, seeded ones included. */
578
+ events(): AcceptedEvent[];
579
+ /** The sources the last configure registered. */
580
+ sources(): SourceDecl[];
581
+ /** Committed artifacts, in order. */
582
+ artifacts(): TestArtifact[];
583
+ /** The progress line wait.progress last set for a Work ("" for none). */
584
+ progress(workId: string): string;
585
+ /** The telemetry events the extension captured (telemetry.capture), in order, each at the time the host recorded. */
586
+ captured(): TelemetryEvent[];
587
+ }
588
+ /** A site of the test host: runs one command, as a placement's machine would. */
589
+ export type TestSite = (cmd: {
590
+ argv: string[];
591
+ dir: string;
592
+ env: string[];
593
+ stdin: Uint8Array;
594
+ timeoutMs: number;
595
+ }) => {
596
+ exitCode: number;
597
+ stdout?: Value;
598
+ stderr?: Value;
599
+ } | Promise<{
600
+ exitCode: number;
601
+ stdout?: Value;
602
+ stderr?: Value;
603
+ }>;
604
+ /** An owner's durable status as a test reports it; unset fields are false. */
605
+ export type TestStatusFn = (owner: ResourceOwner) => Partial<ResourceOwnerStatus> | Promise<Partial<ResourceOwnerStatus>>;
606
+ /** What an acquisition answered: the resource, the provider's log, and whether its setup failed. */
607
+ export interface TestAcquired {
608
+ resource: Resource;
609
+ log: string;
610
+ setupFailed: boolean;
611
+ }
612
+ /**
613
+ * A resource provider type reached over the wire, as the host's adapter
614
+ * reaches a package's: each call one request, a refusal thrown as the
615
+ * ProtocolError it crossed as.
616
+ */
617
+ export interface TestResourceProvider {
618
+ acquire(owner: ResourceOwner, config: unknown, request?: {
619
+ mode?: string;
620
+ params?: Payload;
621
+ files?: string[];
622
+ hostEnv?: Record<string, string>;
623
+ /** The site the launch is placed at (TestHostOptions.sites), given only to a type declared with sites. */
624
+ site?: string;
625
+ }): Promise<TestAcquired>;
626
+ lookup(owner: ResourceOwner, ref: string): Promise<Resource>;
627
+ reconcile(status: TestStatusFn): Promise<ResourceReport>;
628
+ sweep(status: TestStatusFn): Promise<ResourceSweepReport>;
629
+ unsaved(): Promise<ResourceUnsaved[]>;
630
+ /** validate resource_mode: the mode the config names, "" for none. */
631
+ modeDefault(config: unknown): Promise<string>;
632
+ /** validate resource_sandbox: throws the refusal, whose detail is the operator's reason. */
633
+ sandboxWorkspace(config: unknown, mode?: string): Promise<void>;
634
+ /** validate resource_site. */
635
+ needsSite(config: unknown): Promise<boolean>;
636
+ }
637
+ /** The policy of one sandboxed launch a test plans (extension.SandboxPolicy). */
638
+ export interface TestSandboxPolicy {
639
+ /** The binding's sandbox config. */
640
+ config: unknown;
641
+ paths?: SandboxPaths;
642
+ }
643
+ /** A sandbox provider type reached over the wire. */
644
+ /** A wrapped launch a test broker answers. */
645
+ export interface TestLaunchPlan {
646
+ argv: string[];
647
+ env?: string[];
648
+ signals?: string;
649
+ summary?: string;
650
+ data?: Payload;
651
+ dir?: string;
652
+ }
653
+ /** The host's sandbox broker as a test gives it (TestHostOptions.sandbox); throwing a ProtocolError refuses with its code. */
654
+ export interface TestSandboxBroker {
655
+ plan(needs: SandboxNeeds, launch: SandboxLaunch, run: string): TestLaunchPlan | Promise<TestLaunchPlan>;
656
+ adopt(parent: number, run: string): void | Promise<void>;
657
+ }
658
+ /** The host's container broker as a test gives it (TestHostOptions.container). Without reattach, a reattach is not adoptable. */
659
+ export interface TestContainerBroker {
660
+ launch(needs: SandboxNeeds, launch: SandboxLaunch, run: string): TestLaunchPlan | Promise<TestLaunchPlan>;
661
+ adopt(alive: boolean, run: string): {
662
+ exited?: boolean;
663
+ exitCode?: number;
664
+ interrupted?: boolean;
665
+ } | Promise<{
666
+ exited?: boolean;
667
+ exitCode?: number;
668
+ interrupted?: boolean;
669
+ }>;
670
+ /** A new wrapper for the run's pinned container, its output brought back to dir. */
671
+ reattach?(dir: string, run: string): TestLaunchPlan | Promise<TestLaunchPlan>;
672
+ }
673
+ export interface TestSandboxProvider {
674
+ /** The plan, with the digest the host pins. */
675
+ plan(owner: ResourceOwner, policy: TestSandboxPolicy, needs: SandboxNeeds, launch: SandboxLaunch): Promise<SandboxPlan>;
676
+ adopt(plan: SandboxPlan, parent: number, root: number): Promise<void>;
677
+ }
678
+ /** One tunnel run the test host holds open. */
679
+ export interface TestTunnelRun {
680
+ /** Every URL the run published and the host took, in order ("" while it was down). */
681
+ readonly urls: string[];
682
+ /** The URLs the host refused. */
683
+ readonly refused: string[];
684
+ /** The next published URL not yet read; rejects with a URL the host refused, or if the run ends first. */
685
+ next(): Promise<string>;
686
+ /** Settles when the run's call does: stopped by stop, or ended on its own (error is its refusal). */
687
+ readonly ended: Promise<{
688
+ stopped: boolean;
689
+ error?: unknown;
690
+ }>;
691
+ /** Cancels the run, as the host does when it no longer wants the tunnel. */
692
+ stop(): Promise<void>;
693
+ }
694
+ /** A tunnel provider type the test host runs. */
695
+ export interface TestTunnelProvider {
696
+ start(addr: string, config: unknown): TestTunnelRun;
697
+ /** validate (kind tunnel): throws the refusal. */
698
+ validate(config: unknown): Promise<void>;
699
+ }
700
+ /** A sandbox plan's digest as the host pins it (extension.SandboxDigest). */
701
+ export declare function sandboxDigest(argv: string[], data: unknown): string;
702
+ /** The policy of one launch a test plans (extension.ContainerPolicy). */
703
+ export interface TestContainerPolicy {
704
+ /** The binding's whole container config, provider settings in its provider field. */
705
+ config: unknown;
706
+ paths?: SandboxPaths;
707
+ placement?: string;
708
+ }
709
+ /** What a command run at a placement did, as the host reads it. */
710
+ export interface TestSiteResult {
711
+ exitCode: number;
712
+ stdout: Uint8Array;
713
+ stderr: Uint8Array;
714
+ truncated: boolean;
715
+ }
716
+ /**
717
+ * A container provider type reached over the wire, as the host's adapter
718
+ * reaches a package's (extproc's remoteContainer): each call is one
719
+ * container_provider.* request, and a refusal throws the ProtocolError it
720
+ * crossed as. list keeps only what carries the owner's execution label,
721
+ * as the host does.
722
+ */
723
+ export interface TestContainerProvider {
724
+ plan(owner: ResourceOwner, policy: TestContainerPolicy, needs: SandboxNeeds, launch: SandboxLaunch): Promise<ContainerPlan>;
725
+ create(plan: ContainerPlan, labels: Record<string, string>): Promise<ContainerCreated>;
726
+ signal(ref: ContainerRef, signal: string): Promise<void>;
727
+ stop(ref: ContainerRef, graceMs: number): Promise<void>;
728
+ inspect(ref: ContainerRef): Promise<ContainerState>;
729
+ list(owner: ResourceOwner): Promise<ContainerState[]>;
730
+ remove(ref: ContainerRef): Promise<void>;
731
+ forward(config: unknown): Promise<string>;
732
+ place(owner: ResourceOwner, config: unknown, prefer?: string): Promise<Placement>;
733
+ siteRun(placement: string, command: {
734
+ argv: string[];
735
+ dir?: string;
736
+ env?: string[];
737
+ stdin?: Value;
738
+ timeoutMs?: number;
739
+ }): Promise<TestSiteResult>;
740
+ collect(ref: ContainerRef): Promise<void>;
741
+ reattach(ref: ContainerRef, at: {
742
+ pin: ContainerPin;
743
+ paths: SandboxPaths;
744
+ tokenFile?: string;
745
+ sameHost?: boolean;
746
+ }): Promise<ContainerCreated>;
747
+ }
748
+ /** A plan's digest as the host pins it (extension.ContainerDigest). */
749
+ export declare function containerDigest(image: string, data: unknown): string;
750
+ export { type ResourceFixture, type SandboxFixture, type TunnelFixture, checkResourceProvider, checkSandboxProvider, checkTunnelProvider, } from "./providertest.js";
751
+ export { checkContainerForwarder, checkContainerPlacer, checkContainerProvider, type ContainerFixture, type ForwarderFixture, type PlacerFixture, } from "./containertest.js";
752
+ export { ForwardAuthority } from "./forwardca.js";
753
+ export { type ActionFixture, type PanelFixture, type RequestFixture, type TestActionProvider, checkActions, checkPanels, checkRequests, testScope, testWork, } from "./actiontest.js";
754
+ export { type InjectFixture, type Persist, type StateSweepFixture, type TestExecutor, type TestRunHandle, type TestRunRequestOptions, type TestToolCall, type TurnFixture, TestToolbelt, checkExecutor, checkInjectExecutor, checkStateSweeper, checkTurnEnds, testRunRequest, } from "./executortest.js";
755
+ export { type ArtifactCase, type ArtifactFixture, type BackupCase, type BackupTargets, type TestArtifactProvider, type TestArtifactStore, type TestArtifactWriter, artifactCases, backupCases, checkArtifactStore, checkBackupDestination, testArtifactProvider, } from "./storetest.js";
756
+ export { type TestConfig, type TestSetupOptions, type TestSetupRecord, Redacted, configHash, redactConfig, } from "./setuptest.js";