@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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/actions.d.ts +145 -0
- package/dist/actions.js +281 -0
- package/dist/actiontest.d.ts +80 -0
- package/dist/actiontest.js +190 -0
- package/dist/artifactstore.d.ts +133 -0
- package/dist/artifactstore.js +364 -0
- package/dist/backup.d.ts +99 -0
- package/dist/backup.js +178 -0
- package/dist/containertest.d.ts +71 -0
- package/dist/containertest.js +294 -0
- package/dist/errors.d.ts +127 -0
- package/dist/errors.js +180 -0
- package/dist/executor.d.ts +374 -0
- package/dist/executor.js +556 -0
- package/dist/executortest.d.ts +183 -0
- package/dist/executortest.js +534 -0
- package/dist/extension.d.ts +855 -0
- package/dist/extension.js +1822 -0
- package/dist/feed.d.ts +20 -0
- package/dist/feed.js +88 -0
- package/dist/forward.d.ts +38 -0
- package/dist/forward.js +163 -0
- package/dist/forwardca.d.ts +21 -0
- package/dist/forwardca.js +144 -0
- package/dist/hooks.d.ts +108 -0
- package/dist/hooks.js +13 -0
- package/dist/host.d.ts +295 -0
- package/dist/host.js +486 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +31 -0
- package/dist/jsonrpc.d.ts +39 -0
- package/dist/jsonrpc.js +350 -0
- package/dist/probe.d.ts +61 -0
- package/dist/probe.js +92 -0
- package/dist/providertest.d.ts +59 -0
- package/dist/providertest.js +168 -0
- package/dist/resources.d.ts +208 -0
- package/dist/resources.js +303 -0
- package/dist/sandbox.d.ts +84 -0
- package/dist/sandbox.js +85 -0
- package/dist/schema.d.ts +71 -0
- package/dist/schema.js +252 -0
- package/dist/setup.d.ts +145 -0
- package/dist/setup.js +179 -0
- package/dist/setuptest.d.ts +90 -0
- package/dist/setuptest.js +319 -0
- package/dist/storetest.d.ts +64 -0
- package/dist/storetest.js +740 -0
- package/dist/telemetry.d.ts +86 -0
- package/dist/telemetry.js +46 -0
- package/dist/testing.d.ts +756 -0
- package/dist/testing.js +2165 -0
- package/dist/toolbelt.d.ts +91 -0
- package/dist/toolbelt.js +216 -0
- package/dist/tunnel.d.ts +62 -0
- package/dist/tunnel.js +93 -0
- package/dist/wire.d.ts +5359 -0
- package/dist/wire.js +2211 -0
- package/package.json +29 -4
|
@@ -0,0 +1,855 @@
|
|
|
1
|
+
import { type ActionsHandler, type ActionsSpec, type AnnotateFn, type PageSpec } from "./actions.js";
|
|
2
|
+
import { type ProbeHandler, type ProbeSpec } from "./probe.js";
|
|
3
|
+
import type { DependencyFilterFn, OperationGateFn, RecurrenceFn, RenderFn, SegmentEndFn, StartGateFn, TargetFn } from "./hooks.js";
|
|
4
|
+
import { type ResourceHandler, type ResourceProviderSpec } from "./resources.js";
|
|
5
|
+
import { type SandboxHandler, type SandboxProviderSpec } from "./sandbox.js";
|
|
6
|
+
import { type ConfigCandidateFn, type SetupSpec } from "./setup.js";
|
|
7
|
+
import { type ExporterSpec, type MetricsFn, type RunEnvironmentFn, type SinkFn } from "./telemetry.js";
|
|
8
|
+
import { type TunnelHandler, type TunnelProviderSpec } from "./tunnel.js";
|
|
9
|
+
import { type BackupDestinationSpec, type BackupHandler } from "./backup.js";
|
|
10
|
+
import { type Readable, Writable } from "node:stream";
|
|
11
|
+
import { type DeliveryInput, Host, type Put } from "./host.js";
|
|
12
|
+
import { type ExecutorHandler, type ExecutorSpec } from "./executor.js";
|
|
13
|
+
import { type Infer, type Type } from "./schema.js";
|
|
14
|
+
import { type AcceptedEvent, type Authority, type CertificationFile, type ConfigEntry, type ConnectionEntry, type ContainerCreated, type ContainerPin, type ContainerPlan, type ContainerRef, type ContainerState, type ContainerUse, CredentialVerifyParams, type CredentialVerifyResult, type Dependency, type Emitted, type Event, type Family, type FieldDecl, type Manifest, type Placement, type PushResult, type ResourceOwner, type Route, type RouteDecision, type RouteInput, type RouteSample, RouteSamplesParams, type SandboxLaunch, type SandboxNeeds, type SandboxPaths, type Scan, type Scope, type Snapshot, type TaskRunResult, type WaitRequest } from "./wire.js";
|
|
15
|
+
/**
|
|
16
|
+
* The labels the host gives a container it asks a provider to create
|
|
17
|
+
* (extension.ContainerLabel*): list a container by them, and never act on
|
|
18
|
+
* one that doesn't carry the host's.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ContainerLabel: {
|
|
21
|
+
/** The host's container label (ContainerContext.hostLabel). */
|
|
22
|
+
readonly Host: "dev.open-conduit.host";
|
|
23
|
+
readonly Execution: "dev.open-conduit.execution";
|
|
24
|
+
readonly Work: "dev.open-conduit.work";
|
|
25
|
+
readonly Segment: "dev.open-conduit.segment";
|
|
26
|
+
readonly Digest: "dev.open-conduit.digest";
|
|
27
|
+
};
|
|
28
|
+
/** The protocol versions this SDK speaks. */
|
|
29
|
+
export declare const ProtocolVersions: number[];
|
|
30
|
+
/** What a handler can reach besides its input. */
|
|
31
|
+
export interface Context {
|
|
32
|
+
host: Host;
|
|
33
|
+
/** Aborts when the host cancels the request. */
|
|
34
|
+
signal: AbortSignal;
|
|
35
|
+
}
|
|
36
|
+
export interface CallContext extends Context {
|
|
37
|
+
/** The scope, Work and grant the call runs under. */
|
|
38
|
+
authority: Authority;
|
|
39
|
+
/** The caller's idempotency key: a retried call carries the same one. */
|
|
40
|
+
requestId: string;
|
|
41
|
+
}
|
|
42
|
+
export interface OperationSpec<S extends Type<unknown>, Out> {
|
|
43
|
+
/** The input's schema (t.object({}) for none); the handler receives what it accepts. */
|
|
44
|
+
input: S;
|
|
45
|
+
/** What the operation does, in one line (at most 200 bytes). */
|
|
46
|
+
summary?: string;
|
|
47
|
+
/** When an agent should call the operation, in Markdown. */
|
|
48
|
+
guidance?: string;
|
|
49
|
+
/**
|
|
50
|
+
* What a call does in a person's words, for whoever is asked to approve
|
|
51
|
+
* it: a phrase that follows "wants to", with {field} for a top-level
|
|
52
|
+
* input value (e.g. "deploy {service} to {env}"; one line, at most 200
|
|
53
|
+
* bytes).
|
|
54
|
+
*/
|
|
55
|
+
wants?: string;
|
|
56
|
+
/** A capability the operation answers, routed by name (e.g. "git.credential"). */
|
|
57
|
+
serves?: string;
|
|
58
|
+
/** The payload schema the output is sent as (default "<operation>.v1"). */
|
|
59
|
+
output?: string;
|
|
60
|
+
/** Returns the output's data, or throws OperationError to refuse. */
|
|
61
|
+
handler: (input: Infer<S>, ctx: CallContext) => Out | Promise<Out>;
|
|
62
|
+
}
|
|
63
|
+
/** The fields every kind of operation declares. */
|
|
64
|
+
interface OperationDoc<S extends Type<unknown>> {
|
|
65
|
+
/** The input's schema (t.object({}) for none); the handler receives what it accepts. */
|
|
66
|
+
input: S;
|
|
67
|
+
/** What the operation does, in one line (at most 200 bytes). */
|
|
68
|
+
summary?: string;
|
|
69
|
+
/** When an agent should call the operation, in Markdown. */
|
|
70
|
+
guidance?: string;
|
|
71
|
+
/** What a call does in a person's words, as for OperationSpec.wants. */
|
|
72
|
+
wants?: string;
|
|
73
|
+
/** The payload schema the output is sent as (default "<operation>.v1"). */
|
|
74
|
+
output?: string;
|
|
75
|
+
}
|
|
76
|
+
/** What a wait operation's handler returns: what the Work waits for, and what the caller is told. */
|
|
77
|
+
export interface WaitOut {
|
|
78
|
+
/** The Events (and time) that end the wait; keys left out mean every key the Work owns. */
|
|
79
|
+
wait: WaitRequest;
|
|
80
|
+
/** Events on keys the Work doesn't own (another Work's, or one no Work owns yet) to alias into it. */
|
|
81
|
+
dependencies?: Dependency[];
|
|
82
|
+
/** The output's data, returned to the caller as the operation's output. */
|
|
83
|
+
output?: unknown;
|
|
84
|
+
}
|
|
85
|
+
export interface WaitSpec<S extends Type<unknown>> extends OperationDoc<S> {
|
|
86
|
+
/** Turns a call into a wait the host parks the Work on; throws OperationError to refuse. */
|
|
87
|
+
handler: (input: Infer<S>, ctx: CallContext) => WaitOut | Promise<WaitOut>;
|
|
88
|
+
}
|
|
89
|
+
/** What an emission's commit writes and returns. It must be pure and deterministic: the host may run it again. */
|
|
90
|
+
export interface CommitOut {
|
|
91
|
+
/** KV writes in the extension's own namespaces, committed with the Event. */
|
|
92
|
+
records?: Put[];
|
|
93
|
+
/** The output's data, returned to the caller. */
|
|
94
|
+
output?: unknown;
|
|
95
|
+
}
|
|
96
|
+
/** What an emit operation's handler returns: the one Event to emit, of a family the extension declares. */
|
|
97
|
+
export interface EmitOut {
|
|
98
|
+
event: Event;
|
|
99
|
+
/** An accepted Event in the source's namespace the emission derives from, instead of the attempt's trigger. */
|
|
100
|
+
cause?: string;
|
|
101
|
+
/** The emission's identity across executions: at most one Event is accepted per scope and once. */
|
|
102
|
+
once?: string;
|
|
103
|
+
/** Runs in the accepting transaction once the Event is accepted (declare the operation with commit: true). */
|
|
104
|
+
commit?: (emitted: Emitted) => CommitOut;
|
|
105
|
+
}
|
|
106
|
+
export interface EmitSpec<S extends Type<unknown>> extends OperationDoc<S> {
|
|
107
|
+
/** The handler's plans may carry a commit that writes records with the Event. */
|
|
108
|
+
commit?: boolean;
|
|
109
|
+
/** Turns a call into the Event to emit; throws OperationError to refuse. */
|
|
110
|
+
handler: (input: Infer<S>, ctx: CallContext) => EmitOut | Promise<EmitOut>;
|
|
111
|
+
}
|
|
112
|
+
/** One scope's entry of an entry type, with its config decoded. */
|
|
113
|
+
export interface EntryOf<C> {
|
|
114
|
+
scopeId: string;
|
|
115
|
+
name: string;
|
|
116
|
+
config: C;
|
|
117
|
+
/** The secret names the entry may resolve with host.secrets. */
|
|
118
|
+
secrets: string[];
|
|
119
|
+
connection?: ConnectionEntry;
|
|
120
|
+
}
|
|
121
|
+
export interface EntryTypeSpec<S extends Type<unknown>> {
|
|
122
|
+
/** The entry's config schema. A config it refuses is invalid before the daemon applies it. */
|
|
123
|
+
config: S;
|
|
124
|
+
/**
|
|
125
|
+
* Checks the schema can't express; throw to refuse the config. Throw a
|
|
126
|
+
* ConfigError to say which field is wrong and why: the host reports
|
|
127
|
+
* each of its diagnostics at the field's full path. Anything else
|
|
128
|
+
* thrown is reported only as invalid.
|
|
129
|
+
*/
|
|
130
|
+
validate?: (config: Infer<S>) => void | Promise<void>;
|
|
131
|
+
/** Receives every entry of the type on each configuration generation. */
|
|
132
|
+
configure?: (entries: EntryOf<Infer<S>>[], ctx: Context) => void | Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
/** A source an ingress entry registers, with whatever the extension keeps for it. */
|
|
135
|
+
export interface SourceSpec<D = unknown> {
|
|
136
|
+
/** Its registration name: the extension's name, or that and "/" and more (as "<name>/<scope>/<entry>"). */
|
|
137
|
+
name: string;
|
|
138
|
+
/** Its correlation keys' source: the extension's name, or that and "/" and more. */
|
|
139
|
+
namespace: string;
|
|
140
|
+
scopeId: string;
|
|
141
|
+
/** How often the host reconciles it, in whole seconds (at least one). */
|
|
142
|
+
intervalSeconds: number;
|
|
143
|
+
/** Serve the type's webhook for it at /<name> (default: whenever the type has one). */
|
|
144
|
+
webhook?: boolean;
|
|
145
|
+
/** What the handlers need for it: a client, its settings. */
|
|
146
|
+
data?: D;
|
|
147
|
+
}
|
|
148
|
+
/** A delivery the host pushes to a source, with its body as bytes. */
|
|
149
|
+
export interface PushDelivery {
|
|
150
|
+
id: string;
|
|
151
|
+
receivedAt: string;
|
|
152
|
+
contentType?: string;
|
|
153
|
+
body: Uint8Array;
|
|
154
|
+
}
|
|
155
|
+
/** One HTTP request on a source's webhook path. */
|
|
156
|
+
export interface WebhookRequest {
|
|
157
|
+
path: string;
|
|
158
|
+
method: string;
|
|
159
|
+
query: string;
|
|
160
|
+
headers: Headers;
|
|
161
|
+
body: Uint8Array;
|
|
162
|
+
/** When the delivery was first received, by the listener or a forwarder in front of it. */
|
|
163
|
+
receivedAt: string;
|
|
164
|
+
/** The forwarder's delivery ID, when one is configured ("" otherwise). */
|
|
165
|
+
forwardId: string;
|
|
166
|
+
}
|
|
167
|
+
export interface WebhookResponse {
|
|
168
|
+
/** Default 200. A 2xx tells the sender its delivery is durably accepted. */
|
|
169
|
+
status?: number;
|
|
170
|
+
headers?: Record<string, string | string[]>;
|
|
171
|
+
body?: Uint8Array | string;
|
|
172
|
+
}
|
|
173
|
+
export interface WebhookContext extends Context {
|
|
174
|
+
/**
|
|
175
|
+
* Hands a verified delivery to this source: the host calls push with it
|
|
176
|
+
* and answers once its Events are durably accepted. receivedAt defaults
|
|
177
|
+
* to the request's.
|
|
178
|
+
*/
|
|
179
|
+
deliver: (delivery: DeliveryInput) => Promise<{
|
|
180
|
+
accepted: AcceptedEvent[];
|
|
181
|
+
added: boolean[];
|
|
182
|
+
}>;
|
|
183
|
+
}
|
|
184
|
+
export interface IngressTypeSpec<S extends Type<unknown>, D> {
|
|
185
|
+
/** The entry's config schema, as for entryType. */
|
|
186
|
+
config: S;
|
|
187
|
+
/** Checks the schema can't express, as for entryType. */
|
|
188
|
+
validate?: (config: Infer<S>) => void | Promise<void>;
|
|
189
|
+
/** The families its sources observe (declared in the manifest, at least one). */
|
|
190
|
+
families: [Family, ...Family[]];
|
|
191
|
+
/** Each configuration generation: the sources the type's entries register. */
|
|
192
|
+
sources: (entries: EntryOf<Infer<S>>[], ctx: Context) => SourceSpec<D>[] | Promise<SourceSpec<D>[]>;
|
|
193
|
+
/** Maps a delivery to observations (and events of families that aren't re-derivable). */
|
|
194
|
+
push?: (source: SourceSpec<D>, delivery: PushDelivery, ctx: Context) => PushResult | Promise<PushResult>;
|
|
195
|
+
/**
|
|
196
|
+
* Reads one page of what the source holds now. Without it every scan is
|
|
197
|
+
* an empty partial page, which never says anything is gone.
|
|
198
|
+
*/
|
|
199
|
+
reconcile?: (source: SourceSpec<D>, scan: Scan, ctx: Context) => Snapshot | Promise<Snapshot>;
|
|
200
|
+
/**
|
|
201
|
+
* Serves a request on a source's webhook path: verify it (the vendor's
|
|
202
|
+
* own signature), then ctx.deliver it before answering.
|
|
203
|
+
*/
|
|
204
|
+
webhook?: (source: SourceSpec<D>, request: WebhookRequest, ctx: WebhookContext) => WebhookResponse | Promise<WebhookResponse>;
|
|
205
|
+
/** The largest webhook body the host reads, in bytes (default 1 MiB). */
|
|
206
|
+
webhookMaxBytes?: number;
|
|
207
|
+
}
|
|
208
|
+
/** A route's call: the Event, its scope, the Work it already reaches, the route, and the route's config decoded. */
|
|
209
|
+
export interface RouteCall<C> extends RouteInput {
|
|
210
|
+
config: C;
|
|
211
|
+
}
|
|
212
|
+
export interface SampleCall<C> {
|
|
213
|
+
scope: Scope;
|
|
214
|
+
route: Route;
|
|
215
|
+
/** The host's clock, for samples whose data carries a time. */
|
|
216
|
+
now: string;
|
|
217
|
+
config: C;
|
|
218
|
+
}
|
|
219
|
+
export interface RouteSpec<S extends Type<unknown>> {
|
|
220
|
+
/** The route config's schema; checked before the daemon applies a config. */
|
|
221
|
+
config?: S;
|
|
222
|
+
/** Decides what an Event does: open Work, reach the Work it has, or nothing. No side effects. */
|
|
223
|
+
match: (call: RouteCall<Infer<S>>, ctx: Context) => RouteDecision | Promise<RouteDecision>;
|
|
224
|
+
/**
|
|
225
|
+
* Sample Events for a route trace, built from the route's and scope's
|
|
226
|
+
* config so they trace as written; IDs are stable. No side effects.
|
|
227
|
+
*/
|
|
228
|
+
samples?: (call: SampleCall<Infer<S>>, ctx: Context) => RouteSample[] | Promise<RouteSample[]>;
|
|
229
|
+
}
|
|
230
|
+
export interface WorkKindSpec {
|
|
231
|
+
/** Its Work stays open across triggers. */
|
|
232
|
+
standing?: boolean;
|
|
233
|
+
/** Its Work runs on a clock: a dry run starts none of it. */
|
|
234
|
+
timed?: boolean;
|
|
235
|
+
/** Its Work does all its work in one attempt: a handoff completes it. */
|
|
236
|
+
runOnce?: boolean;
|
|
237
|
+
/** Picks, from a Work's pending inputs, the index of the one that triggers its next execution. */
|
|
238
|
+
trigger?: (inputs: Event[]) => number;
|
|
239
|
+
}
|
|
240
|
+
export interface CheckContext extends Context {
|
|
241
|
+
deep: boolean;
|
|
242
|
+
/** The read-only view of the configuration (protocol.CheckConfig). */
|
|
243
|
+
config: unknown;
|
|
244
|
+
}
|
|
245
|
+
/** A check returns its detail line, and throws to fail with the error's message as detail. */
|
|
246
|
+
export type CheckFn = (ctx: CheckContext) => string | Promise<string>;
|
|
247
|
+
/**
|
|
248
|
+
* A task may return when it next has something to do and what wakes it
|
|
249
|
+
* sooner (at most an hour off); returning nothing keeps its interval.
|
|
250
|
+
*/
|
|
251
|
+
export type TaskFn = (ctx: Context) => void | TaskRunResult | Promise<void | TaskRunResult>;
|
|
252
|
+
/** One reference the host asks a secret scheme to resolve (extension.SecretRequest). */
|
|
253
|
+
export interface SecretRequest {
|
|
254
|
+
scheme: string;
|
|
255
|
+
/** The reference text after "<scheme>:", as the operator wrote it (a vault path and field). */
|
|
256
|
+
reference: string;
|
|
257
|
+
}
|
|
258
|
+
/** One value the host asks a writable secret scheme to store (extension.SecretWrite). */
|
|
259
|
+
export interface SecretWrite {
|
|
260
|
+
scheme: string;
|
|
261
|
+
/** The operator's name for the value in the daemon's secret store ([a-z][a-z0-9_-]*). */
|
|
262
|
+
name: string;
|
|
263
|
+
value: string;
|
|
264
|
+
/** The operator's opaque config for the scheme's store (settings.secret_store.config), or undefined. */
|
|
265
|
+
config: unknown;
|
|
266
|
+
/** The secret store's stable identity: every host sharing one installation's state has the same. */
|
|
267
|
+
owner: string;
|
|
268
|
+
}
|
|
269
|
+
/** What the host asks a writable secret scheme to remove (extension.SecretDelete). */
|
|
270
|
+
export interface SecretDeleteRequest {
|
|
271
|
+
scheme: string;
|
|
272
|
+
/** Reference text the scheme's store returned. */
|
|
273
|
+
reference: string;
|
|
274
|
+
owner: string;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* A secret reference scheme the package resolves (extension.SecretProvider),
|
|
278
|
+
* and, with store and delete, stores values of (extension.SecretWriter).
|
|
279
|
+
*
|
|
280
|
+
* serve returns the value, or throws SecretRefusal with a safe code when
|
|
281
|
+
* the reference names nothing it can serve. store returns the reference
|
|
282
|
+
* text that reads the value back, which must not carry the value, and
|
|
283
|
+
* refuses with SecretUnowned a name another owner stored; delete removes
|
|
284
|
+
* what a reference it stored names, succeeds when it is already gone, and
|
|
285
|
+
* refuses another owner's. Anything else thrown is reported to the
|
|
286
|
+
* operator as the provider failing, its text discarded, so an error can't
|
|
287
|
+
* carry a value out; the SDK logs nothing of a request either.
|
|
288
|
+
*/
|
|
289
|
+
export interface SecretSchemeSpec {
|
|
290
|
+
/** One line for the operator: what a reference of the scheme names ("a Vault KV path and field"). */
|
|
291
|
+
summary?: string;
|
|
292
|
+
serve: (r: SecretRequest, ctx: Context) => string | Promise<string>;
|
|
293
|
+
store?: (w: SecretWrite, ctx: Context) => string | Promise<string>;
|
|
294
|
+
delete?: (d: SecretDeleteRequest, ctx: Context) => void | Promise<void>;
|
|
295
|
+
}
|
|
296
|
+
/** One bearer credential the host asks a verifier about (extension.CredentialCheck). */
|
|
297
|
+
export interface CredentialCheck<C = unknown> {
|
|
298
|
+
/** The declared verifier type. */
|
|
299
|
+
type: string;
|
|
300
|
+
/**
|
|
301
|
+
* The host's ID for the trusted issuer. The host records the operator
|
|
302
|
+
* as operator:<issuer>:<subject>, so the verifier never names the actor.
|
|
303
|
+
*/
|
|
304
|
+
issuer: string;
|
|
305
|
+
/** The issuer's config, as the admin gave it and validate accepted it. */
|
|
306
|
+
config: C;
|
|
307
|
+
/** The bearer credential exactly as the request carried it. */
|
|
308
|
+
token: string;
|
|
309
|
+
}
|
|
310
|
+
/** Who a credential the verifier accepted names, as its issuer signed it (extension.VerifiedCredential). */
|
|
311
|
+
export interface VerifiedCredential {
|
|
312
|
+
/** The issuer's stable ID for the person: 1 to 256 printable characters, no spaces. */
|
|
313
|
+
subject: string;
|
|
314
|
+
/** The groups the issuer says the person is in; the issuer's group table, which only an admin sets, maps them to a role. */
|
|
315
|
+
groups?: string[];
|
|
316
|
+
/** When the credential stops being valid. Required: the host stops accepting it then, even if never asked again. */
|
|
317
|
+
expiresAt: Date;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* A credential verifier type (extension.CredentialVerifier), which an admin
|
|
321
|
+
* names when trusting an issuer (PUT /v1/auth/issuers/{id}).
|
|
322
|
+
*
|
|
323
|
+
* The package owns the protocol: signatures, keys and their rotation, the
|
|
324
|
+
* issuer's own claims. The host owns what follows: the actor, the role the
|
|
325
|
+
* groups map to, enforcing expiresAt and refusing the request on any
|
|
326
|
+
* error. verify returns who an accepted credential names, or throws
|
|
327
|
+
* CredentialRefusal for one its issuer didn't sign or that isn't valid
|
|
328
|
+
* now; anything else thrown crosses as internal, which the host refuses
|
|
329
|
+
* too. The host may offer one credential to several issuers in turn, so a
|
|
330
|
+
* credential that is merely not this issuer's is an ordinary refusal.
|
|
331
|
+
* verify must not call the network on every request: cache what the
|
|
332
|
+
* issuer publishes (its signing keys) and fetch again when it rotates.
|
|
333
|
+
*/
|
|
334
|
+
export interface VerifierSpec<S extends Type<unknown>> {
|
|
335
|
+
/** The issuer config's schema: validate (kind verifier) refuses a config it doesn't match, before the host stores it. */
|
|
336
|
+
config?: S;
|
|
337
|
+
/** The issuer config's fields, for adapters and the config editor (manifest verifiers[].fields). */
|
|
338
|
+
fields?: FieldDecl[];
|
|
339
|
+
/**
|
|
340
|
+
* Checks the schema can't express; throw to refuse the config. A
|
|
341
|
+
* ConfigError says which field is wrong and why; anything else thrown is
|
|
342
|
+
* reported only as invalid.
|
|
343
|
+
*/
|
|
344
|
+
validate?: (config: Infer<S>) => void | Promise<void>;
|
|
345
|
+
verify: (c: CredentialCheck<Infer<S>>, ctx: Context) => VerifiedCredential | Promise<VerifiedCredential>;
|
|
346
|
+
}
|
|
347
|
+
interface VerifierHandler {
|
|
348
|
+
validate: (config: unknown) => Promise<void>;
|
|
349
|
+
verify: (p: CredentialVerifyParams, ctx: Context) => Promise<CredentialVerifyResult>;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* A binding's whole container config (extension.ContainerConfig), as the
|
|
353
|
+
* host checked it, with the provider's own settings (its provider field)
|
|
354
|
+
* decoded by the provider's settings schema.
|
|
355
|
+
*/
|
|
356
|
+
export interface ContainerConfig<P = unknown> {
|
|
357
|
+
/** The image, pinned by digest (name@sha256:…). */
|
|
358
|
+
image: string;
|
|
359
|
+
/** The connection whose credential the provider uses, if any. */
|
|
360
|
+
connection?: string;
|
|
361
|
+
/** Host paths the run may write and read: absolute, under ~, or starting with {workspace} or {run}. */
|
|
362
|
+
write?: string[];
|
|
363
|
+
read?: string[];
|
|
364
|
+
network?: {
|
|
365
|
+
allow?: string[];
|
|
366
|
+
};
|
|
367
|
+
limits?: {
|
|
368
|
+
cpus?: number;
|
|
369
|
+
memory?: string;
|
|
370
|
+
pids?: number;
|
|
371
|
+
};
|
|
372
|
+
/** The provider's own settings. */
|
|
373
|
+
provider: P;
|
|
374
|
+
}
|
|
375
|
+
/** The context of a container provider's call: the host's container directory and label for the type, and the bindings that use it. */
|
|
376
|
+
export interface ContainerContext extends Context {
|
|
377
|
+
/** The type's state directory the host named at initialize ("" when it named none). */
|
|
378
|
+
dir: string;
|
|
379
|
+
/** The host's container label (extension.ContainerLabelHost): label what it creates with it, and list only what carries it or a former one. */
|
|
380
|
+
hostLabel: string;
|
|
381
|
+
/** Labels the host made containers under before: listed as the host's too, never put on a new container. */
|
|
382
|
+
formerHosts: string[];
|
|
383
|
+
/** The enabled bindings whose container provider is this type, from the last configure, in config order. */
|
|
384
|
+
uses: ContainerUse[];
|
|
385
|
+
}
|
|
386
|
+
/** One launch to plan (extension.ContainerProvider.Plan). */
|
|
387
|
+
export interface ContainerPlanRequest<P> {
|
|
388
|
+
type: string;
|
|
389
|
+
owner: ResourceOwner;
|
|
390
|
+
config: ContainerConfig<P>;
|
|
391
|
+
/** This attempt's host-set paths. */
|
|
392
|
+
paths: SandboxPaths;
|
|
393
|
+
/** The launch's needs, the resource's and the host's protected set already merged in. */
|
|
394
|
+
needs: SandboxNeeds;
|
|
395
|
+
launch: SandboxLaunch;
|
|
396
|
+
/** Where place put the execution ("" when the provider places nothing). */
|
|
397
|
+
placement: string;
|
|
398
|
+
}
|
|
399
|
+
/** A provider's view of one container (extension.ContainerState). */
|
|
400
|
+
export type ContainerStatus = Omit<ContainerState, "started_at"> & {
|
|
401
|
+
/** When the container started; left out until it has. */
|
|
402
|
+
started_at?: Date | string;
|
|
403
|
+
};
|
|
404
|
+
/** A command to run at a placement (extension.SiteCommand). */
|
|
405
|
+
export interface SiteRun {
|
|
406
|
+
argv: string[];
|
|
407
|
+
dir: string;
|
|
408
|
+
env: string[];
|
|
409
|
+
stdin: Uint8Array;
|
|
410
|
+
/** 0 for none. */
|
|
411
|
+
timeoutMs: number;
|
|
412
|
+
toolbelt: string;
|
|
413
|
+
tokenFile: string;
|
|
414
|
+
}
|
|
415
|
+
/** What a command run at a placement did (extension.SiteResult). A command that ran and failed is its exit code, not an error. */
|
|
416
|
+
export interface SiteOutcome {
|
|
417
|
+
exitCode: number;
|
|
418
|
+
stdout?: Uint8Array | string;
|
|
419
|
+
stderr?: Uint8Array | string;
|
|
420
|
+
truncated?: boolean;
|
|
421
|
+
}
|
|
422
|
+
/** A recovered segment the host asks a provider declared with reattach to give a new wrapper (extension.ContainerReattach). */
|
|
423
|
+
export interface ContainerReattach {
|
|
424
|
+
pin: ContainerPin;
|
|
425
|
+
/** This host's paths for the run. */
|
|
426
|
+
paths: SandboxPaths;
|
|
427
|
+
tokenFile: string;
|
|
428
|
+
/** Whether this host is the one that launched the run. */
|
|
429
|
+
sameHost: boolean;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* A container provider type (extension.ContainerProvider), which a
|
|
433
|
+
* binding's container config names. The host binds it to an attempt: it
|
|
434
|
+
* merges the protected set into the needs, pins the plan's digest and the
|
|
435
|
+
* container, and keeps stop, reconcile and removal, so the provider only
|
|
436
|
+
* plans, creates and reports containers.
|
|
437
|
+
*
|
|
438
|
+
* plan applies the binding's config and checks every need against it,
|
|
439
|
+
* never widening it; create creates the plan's container with the labels
|
|
440
|
+
* and never starts it, answering the argv and env the executor's wrapper
|
|
441
|
+
* runs to start it and wait for its exit; inspect reports one container,
|
|
442
|
+
* gone when the daemon that answered holds none; list reports every
|
|
443
|
+
* container carrying the owner's execution label, or every one of the
|
|
444
|
+
* host's for an owner without one; remove removes a container and what
|
|
445
|
+
* the provider made for it, a gone one included. A listing or inspection
|
|
446
|
+
* that fails must throw, never answer empty or gone: the host acts on
|
|
447
|
+
* both.
|
|
448
|
+
*
|
|
449
|
+
* Refuse with a ProtocolError of the confinement codes, whose message
|
|
450
|
+
* crosses to the executor: Code.SandboxDenied for a need outside the
|
|
451
|
+
* policy, Code.SandboxUnavailable when the provider can't run the launch,
|
|
452
|
+
* Code.NoCapacity (with resetAt when known) when it has no room now, and
|
|
453
|
+
* Code.SiteUnavailable from siteRun for a placement it can't name or
|
|
454
|
+
* reach. Anything else thrown crosses as internal, which the host treats
|
|
455
|
+
* as the container being unavailable, so nothing runs.
|
|
456
|
+
*
|
|
457
|
+
* The optional capabilities are declared by being given: forward names
|
|
458
|
+
* the loopback or private IP the host serves the execution's toolbelt on,
|
|
459
|
+
* over mutual TLS under its own CA (dialForward reaches it); place and
|
|
460
|
+
* siteRun (both or neither) choose the machine and run commands there;
|
|
461
|
+
* collect brings back what an exited container wrote when its wrapper
|
|
462
|
+
* didn't; reattach gives a recovered run a new wrapper.
|
|
463
|
+
*/
|
|
464
|
+
export interface ContainerSpec<S extends Type<unknown>> {
|
|
465
|
+
/** The schema of the container config's provider settings: validate (kind container) refuses settings it doesn't match, at /provider. */
|
|
466
|
+
settings?: S;
|
|
467
|
+
/**
|
|
468
|
+
* Checks the schema can't express; throw to refuse the config. A
|
|
469
|
+
* ConfigError says which field is wrong and why; anything else thrown is
|
|
470
|
+
* reported only as invalid.
|
|
471
|
+
*/
|
|
472
|
+
validate?: (config: ContainerConfig<Infer<S>>) => void | Promise<void>;
|
|
473
|
+
/** Its doctor check runs each of its bindings' version probes in the binding's container (manifest probe). */
|
|
474
|
+
probe?: boolean;
|
|
475
|
+
plan: (r: ContainerPlanRequest<Infer<S>>, ctx: ContainerContext) => ContainerPlan | Promise<ContainerPlan>;
|
|
476
|
+
create: (r: {
|
|
477
|
+
plan: ContainerPlan;
|
|
478
|
+
labels: Record<string, string>;
|
|
479
|
+
}, ctx: ContainerContext) => ContainerCreated | Promise<ContainerCreated>;
|
|
480
|
+
signal: (ref: ContainerRef, signal: string, ctx: ContainerContext) => void | Promise<void>;
|
|
481
|
+
/** Stops a container within graceMs, then kills it; an exited one is no error. */
|
|
482
|
+
stop: (ref: ContainerRef, graceMs: number, ctx: ContainerContext) => void | Promise<void>;
|
|
483
|
+
inspect: (ref: ContainerRef, ctx: ContainerContext) => ContainerStatus | Promise<ContainerStatus>;
|
|
484
|
+
list: (owner: ResourceOwner, ctx: ContainerContext) => ContainerStatus[] | Promise<ContainerStatus[]>;
|
|
485
|
+
remove: (ref: ContainerRef, ctx: ContainerContext) => void | Promise<void>;
|
|
486
|
+
/** The address the host serves the toolbelt on for a binding's config, or "" when its containers reach the socket. */
|
|
487
|
+
forward?: (config: ContainerConfig<Infer<S>>, ctx: ContainerContext) => string | Promise<string>;
|
|
488
|
+
/** Where an execution runs, before anything is acquired for it; prefer is where the Work last ran. */
|
|
489
|
+
place?: (r: {
|
|
490
|
+
owner: ResourceOwner;
|
|
491
|
+
config: ContainerConfig<Infer<S>>;
|
|
492
|
+
prefer: string;
|
|
493
|
+
}, ctx: ContainerContext) => Placement | Promise<Placement>;
|
|
494
|
+
siteRun?: (placement: string, command: SiteRun, ctx: ContainerContext) => SiteOutcome | Promise<SiteOutcome>;
|
|
495
|
+
/** Brings back what an exited container wrote; collecting again changes nothing, and one with nothing to collect is no error. */
|
|
496
|
+
collect?: (ref: ContainerRef, ctx: ContainerContext) => void | Promise<void>;
|
|
497
|
+
reattach?: (ref: ContainerRef, at: ContainerReattach, ctx: ContainerContext) => ContainerCreated | Promise<ContainerCreated>;
|
|
498
|
+
}
|
|
499
|
+
interface ContainerHandler {
|
|
500
|
+
validate: (config: unknown) => Promise<void>;
|
|
501
|
+
serve: (method: string, raw: unknown, ctx: ContainerContext) => Promise<unknown>;
|
|
502
|
+
}
|
|
503
|
+
export type MigrateFn = (from: number, to: number, ctx: Context) => void | Promise<void>;
|
|
504
|
+
export interface Options {
|
|
505
|
+
/** The extension's own version (required). */
|
|
506
|
+
version: string;
|
|
507
|
+
/** The display name operators read (default: the name). */
|
|
508
|
+
title?: string;
|
|
509
|
+
summary?: string;
|
|
510
|
+
/** The package's command (default ["<name>-extension"]). */
|
|
511
|
+
command?: string[];
|
|
512
|
+
/** Host services beyond the extension's own surfaces it uses. */
|
|
513
|
+
permissions?: string[];
|
|
514
|
+
/** The layout version of the extension's own KV namespaces. */
|
|
515
|
+
kvVersion?: number;
|
|
516
|
+
/** A directory of playbooks, relative to the package's manifest, the host offers agents. */
|
|
517
|
+
playbooks?: string;
|
|
518
|
+
}
|
|
519
|
+
type Kind = "handler" | "wait" | "emit";
|
|
520
|
+
interface Op {
|
|
521
|
+
kind: Kind;
|
|
522
|
+
run: (data: unknown, ctx: CallContext) => Promise<unknown>;
|
|
523
|
+
}
|
|
524
|
+
/** A registered source, with the handlers of its type. */
|
|
525
|
+
interface Registered {
|
|
526
|
+
spec: SourceSpec<unknown>;
|
|
527
|
+
type: IngressHandlers;
|
|
528
|
+
}
|
|
529
|
+
interface IngressHandlers {
|
|
530
|
+
push?: (s: SourceSpec<unknown>, d: PushDelivery, ctx: Context) => PushResult | Promise<PushResult>;
|
|
531
|
+
reconcile?: (s: SourceSpec<unknown>, scan: Scan, ctx: Context) => Snapshot | Promise<Snapshot>;
|
|
532
|
+
webhook?: (s: SourceSpec<unknown>, r: WebhookRequest, ctx: WebhookContext) => WebhookResponse | Promise<WebhookResponse>;
|
|
533
|
+
}
|
|
534
|
+
interface EntryType {
|
|
535
|
+
/** Throws ConfigError (or a bare refusal) for a config it refuses. */
|
|
536
|
+
validate: (config: unknown) => Promise<void>;
|
|
537
|
+
/** An ingress type returns the sources its entries register. */
|
|
538
|
+
configure: (entries: ConfigEntry[], ctx: Context) => Promise<Registered[]>;
|
|
539
|
+
}
|
|
540
|
+
interface RouteHandler {
|
|
541
|
+
validate: (config: unknown) => Promise<void>;
|
|
542
|
+
match: (input: RouteInput, ctx: Context) => Promise<RouteDecision>;
|
|
543
|
+
samples: (p: RouteSamplesParams, ctx: Context) => Promise<RouteSample[]>;
|
|
544
|
+
}
|
|
545
|
+
/** Starts an extension named name whose manifest its registrations fill in. */
|
|
546
|
+
export declare function extension(name: string, o: Options): Extension;
|
|
547
|
+
export declare class Extension {
|
|
548
|
+
#private;
|
|
549
|
+
readonly manifest: Manifest;
|
|
550
|
+
constructor(name: string, o: Options);
|
|
551
|
+
/** Registers a request/response toolbelt operation and declares it. */
|
|
552
|
+
operation<S extends Type<unknown>, Out>(name: string, spec: OperationSpec<S, Out>): this;
|
|
553
|
+
/**
|
|
554
|
+
* Registers an operation that suspends the calling Work until an Event
|
|
555
|
+
* (or a time) comes, and declares it with kind wait: "wait until this
|
|
556
|
+
* ticket is resolved".
|
|
557
|
+
*/
|
|
558
|
+
wait<S extends Type<unknown>>(name: string, spec: WaitSpec<S>): this;
|
|
559
|
+
/**
|
|
560
|
+
* Registers an operation that emits one Event of a family the extension
|
|
561
|
+
* declares, and declares it with kind emit (and commit, when spec.commit).
|
|
562
|
+
*/
|
|
563
|
+
emit<S extends Type<unknown>>(name: string, spec: EmitSpec<S>): this;
|
|
564
|
+
/** Declares a scope entry type: an "extensions" entry in a scope's config. */
|
|
565
|
+
entryType<S extends Type<unknown>>(type: string, spec: EntryTypeSpec<S>): this;
|
|
566
|
+
/**
|
|
567
|
+
* Declares a scope entry type whose entries own event sources, with the
|
|
568
|
+
* families they observe. Each configuration generation, sources names
|
|
569
|
+
* the sources the entries register; the host then reconciles each every
|
|
570
|
+
* intervalSeconds through reconcile, pushes deliveries to it through
|
|
571
|
+
* push, and sends requests on its webhook path (/<source name>) to
|
|
572
|
+
* webhook.
|
|
573
|
+
*/
|
|
574
|
+
ingressType<S extends Type<unknown>, D>(type: string, spec: IngressTypeSpec<S, D>): this;
|
|
575
|
+
/**
|
|
576
|
+
* Registers a route handler and declares it: what an Event does (open
|
|
577
|
+
* Work, reach the Work it already has, or nothing). A spec with samples
|
|
578
|
+
* is declared as offering them, so route traces and the routes.decisions
|
|
579
|
+
* certification apply; one with config has its routes' config checked.
|
|
580
|
+
*/
|
|
581
|
+
route<S extends Type<unknown> = Type<Record<string, unknown>>>(handler: string, spec: RouteSpec<S>): this;
|
|
582
|
+
/** Declares a kind of Work the extension's routes create, with its lifecycle. */
|
|
583
|
+
workKind(kind: string, spec?: WorkKindSpec): this;
|
|
584
|
+
/**
|
|
585
|
+
* Registers a secret reference scheme and declares it (manifest
|
|
586
|
+
* secret_schemes): config may then name a secret as
|
|
587
|
+
* "<scheme>:<reference>", and the host asks serve for its value only
|
|
588
|
+
* when the slot's authorised consumer needs it. A spec with store and
|
|
589
|
+
* delete declares the scheme writable, so the daemon's secret store can
|
|
590
|
+
* write to it (settings.secret_store).
|
|
591
|
+
*/
|
|
592
|
+
secretScheme(scheme: string, spec: SecretSchemeSpec): this;
|
|
593
|
+
/**
|
|
594
|
+
* Registers a credential verifier type and declares it (manifest
|
|
595
|
+
* verifiers): an admin may then trust an issuer of the type, whose
|
|
596
|
+
* config validate (kind verifier) checks against spec.config and
|
|
597
|
+
* spec.validate, and the host asks verify, through credential.verify,
|
|
598
|
+
* about each bearer credential it didn't issue itself.
|
|
599
|
+
*/
|
|
600
|
+
verifier<S extends Type<unknown> = Type<Record<string, unknown>>>(type: string, spec: VerifierSpec<S>): this;
|
|
601
|
+
/**
|
|
602
|
+
* Registers a container provider type and declares it (manifest
|
|
603
|
+
* containers), with forward, place, collect and reattach as the spec
|
|
604
|
+
* gives them: a binding's container config may then name the type, the
|
|
605
|
+
* host checks it through validate (kind container) against
|
|
606
|
+
* spec.settings and spec.validate, and binds it to each attempt through
|
|
607
|
+
* container_provider.*.
|
|
608
|
+
*/
|
|
609
|
+
containerProvider<S extends Type<unknown> = Type<Record<string, unknown>>>(type: string, spec: ContainerSpec<S>): this;
|
|
610
|
+
/**
|
|
611
|
+
* Registers a resource provider type and declares it (manifest
|
|
612
|
+
* resources), with mode_default, sandbox, sweep, unsaved and sites as
|
|
613
|
+
* the spec gives them: a binding's resource config may then name the
|
|
614
|
+
* type, the host checks it through validate (kind resource, and the
|
|
615
|
+
* resource_mode, resource_sandbox and resource_site checks) and binds it
|
|
616
|
+
* to each attempt through provider.*.
|
|
617
|
+
*/
|
|
618
|
+
resourceProvider<S extends Type<unknown> = Type<Record<string, unknown>>>(type: string, spec: ResourceProviderSpec<S>): this;
|
|
619
|
+
/**
|
|
620
|
+
* Registers a process sandbox provider type and declares it (manifest
|
|
621
|
+
* sandboxes): a binding's sandbox config may then name the type, the
|
|
622
|
+
* host checks it through validate (kind sandbox) against spec.config and
|
|
623
|
+
* spec.validate, and binds it to each attempt through
|
|
624
|
+
* sandbox_provider.plan and adopt.
|
|
625
|
+
*/
|
|
626
|
+
sandboxProvider<S extends Type<unknown> = Type<Record<string, unknown>>>(type: string, spec: SandboxProviderSpec<S>): this;
|
|
627
|
+
/**
|
|
628
|
+
* Registers a tunnel provider type and declares it (manifest tunnels):
|
|
629
|
+
* settings.webhooks.tunnel may then name the type, its config checked
|
|
630
|
+
* through validate (kind tunnel) against spec.config and spec.validate,
|
|
631
|
+
* and the host runs it through tunnel.run for as long as it wants the
|
|
632
|
+
* tunnel.
|
|
633
|
+
*/
|
|
634
|
+
tunnelProvider<S extends Type<unknown> = Type<Record<string, unknown>>>(type: string, spec: TunnelProviderSpec<S>): this;
|
|
635
|
+
/**
|
|
636
|
+
* Registers a backup destination type and declares it (manifest
|
|
637
|
+
* backup_destinations): settings.backup.destinations may then name the
|
|
638
|
+
* type, whose config validate (kind backup_destination) checks against
|
|
639
|
+
* spec.config and spec.validate, and the host stores bundles with it
|
|
640
|
+
* through backup_destination.*.
|
|
641
|
+
*/
|
|
642
|
+
backupDestination<S extends Type<unknown> = Type<Record<string, unknown>>>(type: string, spec: BackupDestinationSpec<S>): this;
|
|
643
|
+
/**
|
|
644
|
+
* Registers an executor and declares it (manifest executors), with the
|
|
645
|
+
* capabilities spec.capabilities names and the controls (stop, forget,
|
|
646
|
+
* sweep, live, attach, container_attach, interactive_launch) and
|
|
647
|
+
* answers (resource_mode, playbook, version_probe, folder_config) its
|
|
648
|
+
* handlers give: a binding may then name it, its config checked through
|
|
649
|
+
* validate (kind executor) against spec.config and spec.validate, and
|
|
650
|
+
* the host runs, recovers, resumes, observes and drives its attempts
|
|
651
|
+
* through executor.*. A capability whose handler is missing is refused
|
|
652
|
+
* here, as the host would refuse the binding.
|
|
653
|
+
*/
|
|
654
|
+
executor<S extends Type<unknown> = Type<Record<string, unknown>>>(name: string, spec: ExecutorSpec<S>): this;
|
|
655
|
+
/**
|
|
656
|
+
* Registers the extension's actions, requests and panels on scopes and
|
|
657
|
+
* Work and declares them (manifest actions, panels, secret_actions,
|
|
658
|
+
* entry_named): list offers actions on a target, act authorises one
|
|
659
|
+
* invocation as the Event the host accepts under core.action, requests
|
|
660
|
+
* reports what a person is asked to decide, and panels shows documents
|
|
661
|
+
* whose buttons name the listed actions. list and act come together;
|
|
662
|
+
* panels may stand alone, without buttons.
|
|
663
|
+
*/
|
|
664
|
+
actions(spec: ActionsSpec): this;
|
|
665
|
+
/** Registers the extension's Work annotations, name/value lines on each Work's view, and declares them (manifest annotate). */
|
|
666
|
+
annotate(fn: AnnotateFn): this;
|
|
667
|
+
/**
|
|
668
|
+
* Registers the extension's telemetry exporter and declares it (manifest
|
|
669
|
+
* exporters): the host sends it batches of its lifecycle records through
|
|
670
|
+
* telemetry.export, and shutdown when it shuts the extension down.
|
|
671
|
+
*/
|
|
672
|
+
exporter(spec: ExporterSpec): this;
|
|
673
|
+
/**
|
|
674
|
+
* Registers what receives each collection of the host's meter, and asks
|
|
675
|
+
* for the permission that sends it (telemetry.metrics).
|
|
676
|
+
*/
|
|
677
|
+
metrics(fn: MetricsFn): this;
|
|
678
|
+
/**
|
|
679
|
+
* Registers the extension's telemetry sink, and asks for the permission
|
|
680
|
+
* that sends it every named telemetry event the host records
|
|
681
|
+
* (telemetry.sink). Capturing one is host.capture, under the
|
|
682
|
+
* telemetry.capture permission, which Options.permissions asks for.
|
|
683
|
+
*/
|
|
684
|
+
sink(fn: SinkFn): this;
|
|
685
|
+
/**
|
|
686
|
+
* Registers the extension's run environment and declares it (manifest
|
|
687
|
+
* run_environment): the host asks it for a layer of environment
|
|
688
|
+
* variables and files for each run of a Work in a scope that uses the
|
|
689
|
+
* extension, through run.environment.
|
|
690
|
+
*/
|
|
691
|
+
runEnvironment(fn: RunEnvironmentFn): this;
|
|
692
|
+
/**
|
|
693
|
+
* Registers what the extension's Work proposes for the operator to
|
|
694
|
+
* review and apply, and declares it (manifest config_candidate): the
|
|
695
|
+
* host asks fn about a Work of a kind the extension owns through
|
|
696
|
+
* config.candidate. It asks for the config.read permission, without
|
|
697
|
+
* which the extension has no handles to propose and the host never asks,
|
|
698
|
+
* and which serves the host's config service (host.configBase,
|
|
699
|
+
* configEdit, configValidate and configTrace).
|
|
700
|
+
*/
|
|
701
|
+
configCandidate(fn: ConfigCandidateFn): this;
|
|
702
|
+
/**
|
|
703
|
+
* Registers the extension's `open-conduit init <type>` flow and declares
|
|
704
|
+
* it (manifest setup): the host runs it through setup.run, and answers
|
|
705
|
+
* the setup.* callbacks its SetupHost makes while it lasts. A package
|
|
706
|
+
* declares at most one.
|
|
707
|
+
*/
|
|
708
|
+
setup(spec: SetupSpec): this;
|
|
709
|
+
/**
|
|
710
|
+
* Registers a calendar recurrence kind and declares it (manifest
|
|
711
|
+
* recurrences): host.armTimer arms a timer of the kind, and each time it
|
|
712
|
+
* fires the host asks fn for the occurrence and the next timer
|
|
713
|
+
* (recurrence.next), inside the transaction that fires it. fn is
|
|
714
|
+
* synchronous and gets no host (see RecurrenceFn).
|
|
715
|
+
*/
|
|
716
|
+
recurrence(kind: string, fn: RecurrenceFn): this;
|
|
717
|
+
/**
|
|
718
|
+
* Registers the filter of the extension's wait operations' dependencies
|
|
719
|
+
* and declares it (manifest dependency_filter; it needs a wait
|
|
720
|
+
* operation): the host asks fn whether an Event on a dependency matches
|
|
721
|
+
* the filter the wait put on it (dependency.filter), inside its
|
|
722
|
+
* transaction. fn is synchronous and gets no host.
|
|
723
|
+
*/
|
|
724
|
+
dependencyFilter(fn: DependencyFilterFn): this;
|
|
725
|
+
/**
|
|
726
|
+
* Registers the extension's gate on other extensions' operations and
|
|
727
|
+
* declares it (manifest operation_gate), asking for the operation.gate
|
|
728
|
+
* permission, which the operator consents to at install and without
|
|
729
|
+
* which the host never asks: the host asks fn about every toolbelt call
|
|
730
|
+
* to another extension's operation in the extension's scopes
|
|
731
|
+
* (operation.gate), and it may let the call through, park the caller or
|
|
732
|
+
* refuse it.
|
|
733
|
+
*/
|
|
734
|
+
operationGate(fn: OperationGateFn): this;
|
|
735
|
+
/**
|
|
736
|
+
* Registers the extension's start gate and declares it (manifest
|
|
737
|
+
* start_gate), asking for the work.start_gate permission, which the
|
|
738
|
+
* operator consents to at install and without which the host never
|
|
739
|
+
* asks: the host asks fn before the first attempt of any Work in the
|
|
740
|
+
* extension's scopes starts (work.admit), and it may hold the Work until
|
|
741
|
+
* host.settleHold admits or cancels it.
|
|
742
|
+
*/
|
|
743
|
+
startGate(fn: StartGateFn): this;
|
|
744
|
+
/**
|
|
745
|
+
* Registers the resolver of a wait target kind ("job" for a
|
|
746
|
+
* `job:<name>` condition another extension's wait operation names) and
|
|
747
|
+
* declares it (manifest targets): the host asks fn through
|
|
748
|
+
* target.resolve. The Event types it answers must be the extension's own
|
|
749
|
+
* families.
|
|
750
|
+
*/
|
|
751
|
+
target(kind: string, fn: TargetFn): this;
|
|
752
|
+
/**
|
|
753
|
+
* Registers what the extension does when an execution's container
|
|
754
|
+
* segment ends, revoking what it issued for it, and declares it
|
|
755
|
+
* (manifest segment_end; segment.ended).
|
|
756
|
+
*/
|
|
757
|
+
onSegmentEnd(fn: SegmentEndFn): this;
|
|
758
|
+
/**
|
|
759
|
+
* Registers how the extension renders Events of its own families for an
|
|
760
|
+
* agent's prompt and declares it (manifest render; event.render). The
|
|
761
|
+
* host bounds each call and falls back to its generic rendering when fn
|
|
762
|
+
* answers undefined, throws or is slow.
|
|
763
|
+
*/
|
|
764
|
+
render(fn: RenderFn): this;
|
|
765
|
+
/**
|
|
766
|
+
* Declares a page of the extension's own in the operator's web view
|
|
767
|
+
* (manifest pages): a session of one of its Work kinds, started from a
|
|
768
|
+
* scope with one of its entries, drawn by core from the entry's actions
|
|
769
|
+
* and the session's panels. It needs actions, and the entry type, work
|
|
770
|
+
* kind and route it names declared too, which the host checks.
|
|
771
|
+
*/
|
|
772
|
+
page(id: string, spec: PageSpec): this;
|
|
773
|
+
/**
|
|
774
|
+
* Registers a read-only setup probe and declares it (manifest probes):
|
|
775
|
+
* the host lists it as "<extension>.<name>" to setup sessions and runs
|
|
776
|
+
* it through probe.serve, with its declared arguments only.
|
|
777
|
+
*/
|
|
778
|
+
probe(name: string, spec: ProbeSpec): this;
|
|
779
|
+
/** Registers a doctor check and declares it. */
|
|
780
|
+
check(name: string, fn: CheckFn, o?: {
|
|
781
|
+
deep?: boolean;
|
|
782
|
+
}): this;
|
|
783
|
+
/** Registers a task the host runs every intervalSeconds (at least one) and declares it. */
|
|
784
|
+
task(name: string, intervalSeconds: number, fn: TaskFn): this;
|
|
785
|
+
/** Declares event families the extension derives through host.accept or emits (an ingress type's come with it). */
|
|
786
|
+
family(...families: Family[]): this;
|
|
787
|
+
/**
|
|
788
|
+
* Declares a payload schema the extension writes and reads, named
|
|
789
|
+
* <extension>.<thing> and written as <name>.v<N>: the versions it can
|
|
790
|
+
* read, ascending, the highest being the one it writes. The host refuses
|
|
791
|
+
* an Event (ingress, event.accept or emitted) whose data names any other.
|
|
792
|
+
*/
|
|
793
|
+
schema(name: string, ...versions: number[]): this;
|
|
794
|
+
/** Upgrades the extension's KV namespaces to kvVersion. It must be idempotent: a crash mid-way retries it. */
|
|
795
|
+
onMigrate(fn: MigrateFn): this;
|
|
796
|
+
/** Sets the package's certification.json content (package-certification). */
|
|
797
|
+
certification(file: CertificationFile): this;
|
|
798
|
+
/** Serves the extension on input and output (tests pass a pair of in-memory streams). */
|
|
799
|
+
serve(input: Readable, output: Writable): Server;
|
|
800
|
+
/**
|
|
801
|
+
* The entry point of a packaged extension: `package-manifest` prints the
|
|
802
|
+
* manifest, `package-certification` the certification file, and anything
|
|
803
|
+
* else serves on stdin and stdout until stdin closes, then exits.
|
|
804
|
+
*/
|
|
805
|
+
main(argv?: string[]): Promise<void>;
|
|
806
|
+
/** @internal */
|
|
807
|
+
_served(): {
|
|
808
|
+
operations: Map<string, Op>;
|
|
809
|
+
checks: Map<string, CheckFn>;
|
|
810
|
+
tasks: Map<string, TaskFn>;
|
|
811
|
+
entryTypes: Map<string, EntryType>;
|
|
812
|
+
routes: Map<string, RouteHandler>;
|
|
813
|
+
triggers: Map<string, (inputs: Event[]) => number>;
|
|
814
|
+
secrets: Map<string, SecretSchemeSpec>;
|
|
815
|
+
verifiers: Map<string, VerifierHandler>;
|
|
816
|
+
containers: Map<string, ContainerHandler>;
|
|
817
|
+
resources: Map<string, ResourceHandler>;
|
|
818
|
+
sandboxes: Map<string, SandboxHandler>;
|
|
819
|
+
tunnels: Map<string, TunnelHandler>;
|
|
820
|
+
backups: Map<string, BackupHandler>;
|
|
821
|
+
executors: Map<string, ExecutorHandler>;
|
|
822
|
+
probes: Map<string, ProbeHandler>;
|
|
823
|
+
actions: ActionsHandler | undefined;
|
|
824
|
+
annotate: AnnotateFn | undefined;
|
|
825
|
+
exporter: ExporterSpec | undefined;
|
|
826
|
+
metrics: MetricsFn | undefined;
|
|
827
|
+
sink: SinkFn | undefined;
|
|
828
|
+
runEnvironment: RunEnvironmentFn | undefined;
|
|
829
|
+
configCandidate: ConfigCandidateFn | undefined;
|
|
830
|
+
setup: SetupSpec | undefined;
|
|
831
|
+
recurrences: Map<string, RecurrenceFn>;
|
|
832
|
+
targets: Map<string, TargetFn>;
|
|
833
|
+
filter: DependencyFilterFn | undefined;
|
|
834
|
+
gate: OperationGateFn | undefined;
|
|
835
|
+
startGate: StartGateFn | undefined;
|
|
836
|
+
segmentEnd: SegmentEndFn | undefined;
|
|
837
|
+
render: RenderFn | undefined;
|
|
838
|
+
migrate: MigrateFn | undefined;
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
/** One served connection. */
|
|
842
|
+
export declare class Server {
|
|
843
|
+
#private;
|
|
844
|
+
readonly host: Host;
|
|
845
|
+
constructor(ext: Extension, input: Readable, output: Writable);
|
|
846
|
+
/** Resolves when the connection ends. */
|
|
847
|
+
get done(): Promise<void>;
|
|
848
|
+
/** The private state directory the host gave at initialize. */
|
|
849
|
+
get stateDir(): string;
|
|
850
|
+
/** The operator's config file's directory the host named at initialize ("" for none), against which a relative path in a config resolves. */
|
|
851
|
+
get configDir(): string;
|
|
852
|
+
/** Ends the connection. */
|
|
853
|
+
close(): void;
|
|
854
|
+
}
|
|
855
|
+
export {};
|