@open-conduit/sdk 7.0.0 → 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/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 +28 -0
- package/dist/errors.js +37 -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 +496 -1
- package/dist/extension.js +1152 -4
- 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 +166 -2
- package/dist/host.js +235 -2
- package/dist/index.d.ts +27 -3
- package/dist/index.js +14 -2
- 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/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 +591 -2
- package/dist/testing.js +1460 -6
- 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 +4060 -348
- package/dist/wire.js +1583 -0
- package/package.json +1 -1
package/dist/errors.js
CHANGED
|
@@ -99,6 +99,43 @@ export class OperationError extends Error {
|
|
|
99
99
|
this.code = code;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* A secret provider's safe answer for a reference it can't serve, or a
|
|
104
|
+
* write or delete it won't make (extension.SecretRefusal): throw one from
|
|
105
|
+
* a secret scheme's serve, store or delete. The operator is shown the
|
|
106
|
+
* code, so it must never carry the value, the reference or the manager's
|
|
107
|
+
* error text: lower-case letters, digits and underscores, at most 64
|
|
108
|
+
* characters (validSecretCode). The host reports an invalid code as
|
|
109
|
+
* provider_refused, and anything else thrown as provider_failed.
|
|
110
|
+
*/
|
|
111
|
+
export class SecretRefusal extends Error {
|
|
112
|
+
code;
|
|
113
|
+
constructor(code) {
|
|
114
|
+
super(`secret refused: ${code}`);
|
|
115
|
+
this.name = "SecretRefusal";
|
|
116
|
+
this.code = code;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** The refusal code of a write or delete that would touch a value its owner didn't store (extension.SecretUnowned). */
|
|
120
|
+
export const SecretUnowned = "exists_unowned";
|
|
121
|
+
/** Reports whether code is a safe secret refusal code (extension.ValidSecretCode). */
|
|
122
|
+
export function validSecretCode(code) {
|
|
123
|
+
return /^[a-z][a-z0-9_]{0,63}$/.test(code);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A credential verifier's refusal of a credential (extension.ErrUnauthorized):
|
|
127
|
+
* throw one from a verifier's verify for a credential its issuer didn't
|
|
128
|
+
* sign or that isn't valid now. It crosses as unauthorized with a fixed
|
|
129
|
+
* message, so neither the credential nor the reason reaches the host's
|
|
130
|
+
* log; the host answers the request 401 whatever the reason. Anything
|
|
131
|
+
* else thrown crosses as internal, which the host refuses the same way.
|
|
132
|
+
*/
|
|
133
|
+
export class CredentialRefusal extends Error {
|
|
134
|
+
constructor(reason = "credential refused") {
|
|
135
|
+
super(reason);
|
|
136
|
+
this.name = "CredentialRefusal";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
102
139
|
/** The error a request answered after its caller cancelled it. */
|
|
103
140
|
export class CancelledError extends Error {
|
|
104
141
|
constructor() {
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import type { Context } from "./extension.js";
|
|
2
|
+
import { type Infer, type Type } from "./schema.js";
|
|
3
|
+
import { type ArtifactRef, type Event, type Execution, type ExecutionContext, type ExecutorDecl, type FieldDecl, type Payload, type Result, type SandboxLaunch, type SandboxNeeds, type ValidateParams, type ValidateResult, type Work, type WorkspaceRecord } from "./wire.js";
|
|
4
|
+
/** How an attempt's process reaches the toolbelt (extension.Toolbelt*). */
|
|
5
|
+
export type ToolbeltTransport = "none" | "cli" | "mcp" | "sdk";
|
|
6
|
+
/**
|
|
7
|
+
* The mechanical labels a binding's requires is checked against, and a
|
|
8
|
+
* route's binding check sees (domain.Capabilities). interrupt, inject and
|
|
9
|
+
* resume each need their handler. sandbox and container say the
|
|
10
|
+
* executor runs a binding's launch in its process sandbox or its
|
|
11
|
+
* container, through the run's brokers (AttemptRequest.sandbox and
|
|
12
|
+
* container). noProcess says the executor runs no process the agent
|
|
13
|
+
* controls, so a scope that requires isolation accepts its bindings
|
|
14
|
+
* without a sandbox or container.
|
|
15
|
+
*/
|
|
16
|
+
export interface ExecutorCapabilities {
|
|
17
|
+
interrupt?: boolean;
|
|
18
|
+
inject?: boolean;
|
|
19
|
+
resume?: boolean;
|
|
20
|
+
workspace?: boolean;
|
|
21
|
+
toolbelt: ToolbeltTransport;
|
|
22
|
+
sandbox?: boolean;
|
|
23
|
+
container?: boolean;
|
|
24
|
+
noProcess?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** The kinds of outcome an attempt can end with (domain.Outcome*). */
|
|
27
|
+
export type OutcomeKind = "completed" | "failed" | "waiting" | "handoff";
|
|
28
|
+
/**
|
|
29
|
+
* What one segment of an attempt consumed, as the executor counts it
|
|
30
|
+
* (extension.Usage). Budgets are charged in named units: units holds any
|
|
31
|
+
* the executor reports ("usd", "minutes", or its own); the host adds a
|
|
32
|
+
* cost in its currency's code and the tokens itself. What counts as a cost
|
|
33
|
+
* is the executor's to say. attribution describes what did the work
|
|
34
|
+
* ("model", "machine"), for a reader to price it.
|
|
35
|
+
*/
|
|
36
|
+
export interface UsageRecord {
|
|
37
|
+
inputTokens?: number;
|
|
38
|
+
outputTokens?: number;
|
|
39
|
+
cachedTokens?: number;
|
|
40
|
+
cost?: number;
|
|
41
|
+
currency?: string;
|
|
42
|
+
units?: Record<string, number>;
|
|
43
|
+
attribution?: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
/** An attempt's result (extension.Result). */
|
|
46
|
+
export interface ExecutorResult {
|
|
47
|
+
outcome: {
|
|
48
|
+
kind: OutcomeKind;
|
|
49
|
+
summary?: string;
|
|
50
|
+
data?: Payload;
|
|
51
|
+
};
|
|
52
|
+
usage?: UsageRecord;
|
|
53
|
+
/** Artifacts the attempt published (host.createArtifact's refs). */
|
|
54
|
+
artifacts?: ArtifactRef[];
|
|
55
|
+
/** A failed outcome that is a retryable limit, with when it resets when known. */
|
|
56
|
+
retry?: {
|
|
57
|
+
resetAt?: Date | string;
|
|
58
|
+
};
|
|
59
|
+
/** A failed outcome trying again can't cure (the config is wrong). */
|
|
60
|
+
permanent?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The injected Events the attempt has evidence it took in (an echo, a
|
|
63
|
+
* read of its inbox), each at most once. Without proof an input stays
|
|
64
|
+
* pending and is presented again.
|
|
65
|
+
*/
|
|
66
|
+
consumedInputs?: string[];
|
|
67
|
+
/** The resource the attempt ran in, as its provider described it. */
|
|
68
|
+
workspace?: WorkspaceRecord;
|
|
69
|
+
}
|
|
70
|
+
/** A started attempt the host observes (extension.RunHandle). */
|
|
71
|
+
export interface RunHandle {
|
|
72
|
+
/**
|
|
73
|
+
* Resolves with the attempt's result once it ends. The signal aborts
|
|
74
|
+
* when the host stops observing, which doesn't end the attempt: the
|
|
75
|
+
* host may call wait again, on this handle or on a recovered one.
|
|
76
|
+
*/
|
|
77
|
+
wait(signal: AbortSignal): Promise<ExecutorResult>;
|
|
78
|
+
}
|
|
79
|
+
/** What a run asks of its binding's resource provider (extension.ResourceRequest). */
|
|
80
|
+
export interface ResourceRequest {
|
|
81
|
+
/** shared, work or fresh; "" for the resource config's default. */
|
|
82
|
+
mode?: string;
|
|
83
|
+
params?: Payload;
|
|
84
|
+
files?: string[];
|
|
85
|
+
}
|
|
86
|
+
/** A resource the run holds (extension.Resource). */
|
|
87
|
+
export interface AcquiredResource {
|
|
88
|
+
kind: string;
|
|
89
|
+
ref: string;
|
|
90
|
+
dir: string;
|
|
91
|
+
env: Record<string, string>;
|
|
92
|
+
data: Payload;
|
|
93
|
+
summary: string;
|
|
94
|
+
sandbox?: SandboxNeeds;
|
|
95
|
+
site: string;
|
|
96
|
+
files: Record<string, string>;
|
|
97
|
+
/** The provider's progress for this acquisition. */
|
|
98
|
+
log: string;
|
|
99
|
+
/** The resource exists, returned for inspection, but its setup failed. */
|
|
100
|
+
setupFailed: boolean;
|
|
101
|
+
}
|
|
102
|
+
/** The run's resource broker, bound by the host to its trusted owner (extension.ResourceBroker). */
|
|
103
|
+
export interface ResourceBroker {
|
|
104
|
+
acquire(r?: ResourceRequest, signal?: AbortSignal): Promise<AcquiredResource>;
|
|
105
|
+
lookup(ref: string, signal?: AbortSignal): Promise<AcquiredResource>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A wrapped launch the host planned (extension.SandboxPlan): what the
|
|
109
|
+
* executor runs in place of its own argv, with env, in dir when given.
|
|
110
|
+
* signals says what an interrupt can promise (SandboxSignals).
|
|
111
|
+
*/
|
|
112
|
+
export interface LaunchPlan {
|
|
113
|
+
argv: string[];
|
|
114
|
+
env: string[];
|
|
115
|
+
signals: string;
|
|
116
|
+
summary: string;
|
|
117
|
+
data?: Payload;
|
|
118
|
+
dir: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The run's process sandbox, bound by the host to the binding's provider
|
|
122
|
+
* and policy (extension.SandboxBroker). Any error means nothing may run.
|
|
123
|
+
*/
|
|
124
|
+
export interface SandboxBroker {
|
|
125
|
+
/** Wraps one launch; needs are the executor's own, the host merges the rest. */
|
|
126
|
+
plan(needs: SandboxNeeds, launch: SandboxLaunch, signal?: AbortSignal): Promise<LaunchPlan>;
|
|
127
|
+
/** Proves a recovered segment's wrapper, pid parent, still runs inside its sandbox; throws when it doesn't. */
|
|
128
|
+
adopt(parent: number, signal?: AbortSignal): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
/** How an adopted container's segment ended (extension.ContainerExit). */
|
|
131
|
+
export interface ContainerExitStatus {
|
|
132
|
+
exited: boolean;
|
|
133
|
+
exitCode: number;
|
|
134
|
+
interrupted: boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The run's container, bound by the host to the binding's provider and
|
|
138
|
+
* policy (extension.ContainerBroker). Any error means nothing may run; an
|
|
139
|
+
* adopt or reattach that can't prove the pinned container throws
|
|
140
|
+
* Code.NotAdoptable.
|
|
141
|
+
*/
|
|
142
|
+
export interface ContainerBroker {
|
|
143
|
+
/** Creates the launch's container and answers the wrapper's argv and env, with signals term. */
|
|
144
|
+
launch(needs: SandboxNeeds, launch: SandboxLaunch, signal?: AbortSignal): Promise<LaunchPlan>;
|
|
145
|
+
/**
|
|
146
|
+
* Proves a recovered segment's container is the one pinned: with its
|
|
147
|
+
* wrapper alive, adopted as it runs; with it dead, the exited
|
|
148
|
+
* container's exit.
|
|
149
|
+
*/
|
|
150
|
+
adopt(alive: boolean, signal?: AbortSignal): Promise<ContainerExitStatus>;
|
|
151
|
+
/** A new wrapper for a recovered segment's pinned container, its output brought back to run. */
|
|
152
|
+
reattach(run: string, signal?: AbortSignal): Promise<LaunchPlan>;
|
|
153
|
+
}
|
|
154
|
+
/** An attempt to run, recover or resume (extension.RunRequest). */
|
|
155
|
+
export interface AttemptRequest<C = unknown> {
|
|
156
|
+
work: Work;
|
|
157
|
+
execution: Execution;
|
|
158
|
+
/** The selected Event. */
|
|
159
|
+
trigger: Event;
|
|
160
|
+
/** The acceptance-ordered batch, context preceding a wake included. */
|
|
161
|
+
inputs: Event[];
|
|
162
|
+
/** The binding's config data, decoded through the spec's config schema. */
|
|
163
|
+
config: C;
|
|
164
|
+
/** The rest of the execution context as the host sent it: secrets, toolbelt, env, playbooks. */
|
|
165
|
+
context: ExecutionContext;
|
|
166
|
+
/**
|
|
167
|
+
* Durably saves the attempt's continuity state, fenced by the
|
|
168
|
+
* execution's lease: run must call it before it returns the handle, and
|
|
169
|
+
* recover calls it again with the state it was given. It may be called
|
|
170
|
+
* after run returned, to save newer state.
|
|
171
|
+
*/
|
|
172
|
+
persistRecovery(state: Payload): Promise<void>;
|
|
173
|
+
/** The binding's resource provider, when it declares one. */
|
|
174
|
+
resources?: ResourceBroker;
|
|
175
|
+
/** The binding's process sandbox, when it names one (capability sandbox). */
|
|
176
|
+
sandbox?: SandboxBroker;
|
|
177
|
+
/** The binding's container, when it names one (capability container). */
|
|
178
|
+
container?: ContainerBroker;
|
|
179
|
+
}
|
|
180
|
+
/** What an operator's takeover in the binding's container attaches to (extension.ContainerAttachRequest). */
|
|
181
|
+
export interface ContainerAttachRequest<C = unknown> {
|
|
182
|
+
work: Work;
|
|
183
|
+
/** The binding's config data, decoded through the spec's config schema. */
|
|
184
|
+
config: C;
|
|
185
|
+
/** The binding's secrets, as a launch would get them. */
|
|
186
|
+
secrets: Record<string, string>;
|
|
187
|
+
/** The Work's container home. */
|
|
188
|
+
home: string;
|
|
189
|
+
}
|
|
190
|
+
/** The interactive launch the host's container broker plans for the takeover (extension.ContainerAttachSpec); launch.dir is the workspace. */
|
|
191
|
+
export interface ContainerAttachSpec {
|
|
192
|
+
needs: SandboxNeeds;
|
|
193
|
+
launch: SandboxLaunch;
|
|
194
|
+
}
|
|
195
|
+
/** What an interactive session of the executor's CLI starts on (extension.InteractiveLaunchRequest). */
|
|
196
|
+
export interface InteractiveLaunchRequest {
|
|
197
|
+
/** The playbook's text, frontmatter and all. */
|
|
198
|
+
playbook: string;
|
|
199
|
+
/** The playbook's name. */
|
|
200
|
+
name: string;
|
|
201
|
+
summary: string;
|
|
202
|
+
/** Command prefixes the session may run without asking. */
|
|
203
|
+
allow: string[];
|
|
204
|
+
/** The session's working directory. */
|
|
205
|
+
dir: string;
|
|
206
|
+
/** A host directory it may create and write the files its launch needs into. */
|
|
207
|
+
filesDir: string;
|
|
208
|
+
/** The operator's choice of CLI, "" for the executor's default. */
|
|
209
|
+
program: string;
|
|
210
|
+
}
|
|
211
|
+
/** The command the host execs for an interactive session (extension.InteractiveLaunchSpec). */
|
|
212
|
+
export interface InteractiveLaunchSpec {
|
|
213
|
+
argv: string[];
|
|
214
|
+
dir?: string;
|
|
215
|
+
/** The variables to add to the session's environment; never one the host decides. */
|
|
216
|
+
setEnv?: Record<string, string>;
|
|
217
|
+
}
|
|
218
|
+
/** What an executor's handlers can reach. */
|
|
219
|
+
export interface ExecutorContext extends Context {
|
|
220
|
+
/**
|
|
221
|
+
* The executor's state directory, from initialize: the host's
|
|
222
|
+
* executors/<name>, or the extension's own state directory when the host
|
|
223
|
+
* names none. It keeps its runs there.
|
|
224
|
+
*/
|
|
225
|
+
stateDir: string;
|
|
226
|
+
}
|
|
227
|
+
/** Answers which of ids the host holds, asking at most MaxKnownBatch at a time. */
|
|
228
|
+
export type KnownFn = (ids: string[]) => Promise<Set<string>>;
|
|
229
|
+
/** What a sweep did (extension.StateSweepReport). */
|
|
230
|
+
export interface SweepReport {
|
|
231
|
+
/** The executions whose state it released. */
|
|
232
|
+
removed: string[];
|
|
233
|
+
/** State it kept: in_use (a process still runs), unmapped or remove_failed. */
|
|
234
|
+
kept?: {
|
|
235
|
+
executionId?: string;
|
|
236
|
+
ref?: string;
|
|
237
|
+
kept: string;
|
|
238
|
+
}[];
|
|
239
|
+
}
|
|
240
|
+
/** One output of a running execution so far (extension.LiveOutput). */
|
|
241
|
+
export interface LiveOut {
|
|
242
|
+
name: string;
|
|
243
|
+
mediaType: string;
|
|
244
|
+
/** The whole output's length. */
|
|
245
|
+
size: number;
|
|
246
|
+
/** At most its last tail bytes. */
|
|
247
|
+
content: Uint8Array | string;
|
|
248
|
+
}
|
|
249
|
+
/** The most IDs one known call asks about (extension.MaxKnownBatch). */
|
|
250
|
+
export declare const MaxKnownBatch = 256;
|
|
251
|
+
/**
|
|
252
|
+
* An executor (extension.Executor and its optional controls), which a
|
|
253
|
+
* binding names. Errors the host acts on are ProtocolErrors: recover
|
|
254
|
+
* throws Code.NotAdoptable when it has nothing to adopt, inject
|
|
255
|
+
* Code.NotAccepting when the Event was definitely not delivered (any
|
|
256
|
+
* other error is ambiguous, and the host retries), live Code.NotLive and
|
|
257
|
+
* attach Code.NothingToAttach.
|
|
258
|
+
*/
|
|
259
|
+
export interface ExecutorSpec<S extends Type<unknown>> {
|
|
260
|
+
capabilities: ExecutorCapabilities;
|
|
261
|
+
/** The binding config's data schema, checked through validate (kind executor) and decoded for each attempt. */
|
|
262
|
+
config?: S;
|
|
263
|
+
/** Further checks of a config the schema accepts; throw ConfigError to refuse. */
|
|
264
|
+
validate?: (config: Infer<S>) => void | Promise<void>;
|
|
265
|
+
/** The binding config's fields, for adapters and the config editor. */
|
|
266
|
+
fields?: FieldDecl[];
|
|
267
|
+
/** "jobs" counts its runs against settings.job_concurrency, not settings.concurrency. */
|
|
268
|
+
pool?: "jobs";
|
|
269
|
+
/**
|
|
270
|
+
* The resource mode a binding config makes it request (shared, work or
|
|
271
|
+
* fresh), "" for the resource config's default; validate kind
|
|
272
|
+
* executor_mode, manifest resource_mode. Config check uses it to tell
|
|
273
|
+
* when a resource config's own mode never applies.
|
|
274
|
+
*/
|
|
275
|
+
resourceMode?: (config: Infer<S>) => string;
|
|
276
|
+
/** The playbook a binding config starts its turns on, "" for none; validate kind executor_playbook, manifest playbook. */
|
|
277
|
+
playbook?: (config: Infer<S>) => string;
|
|
278
|
+
/**
|
|
279
|
+
* The command that shows the program a binding config runs is installed
|
|
280
|
+
* where it runs, with the variables it runs with in a container, or
|
|
281
|
+
* undefined for none; validate kind executor_probe, manifest
|
|
282
|
+
* version_probe. A container provider's doctor check runs it in the
|
|
283
|
+
* binding's image, with no network, mounts or secrets.
|
|
284
|
+
*/
|
|
285
|
+
versionProbe?: (config: Infer<S>) => {
|
|
286
|
+
argv: string[];
|
|
287
|
+
env?: string[];
|
|
288
|
+
} | undefined;
|
|
289
|
+
/**
|
|
290
|
+
* Adapts a binding from an included folder's config, before it is
|
|
291
|
+
* validated and stored: resolves relative paths against folder, and may
|
|
292
|
+
* default the folder a binding without a resource runs in; validate
|
|
293
|
+
* kind executor_folder, manifest folder_config. It gets the config as
|
|
294
|
+
* written; throw to refuse it.
|
|
295
|
+
*/
|
|
296
|
+
folderConfig?: (config: Record<string, unknown>, folder: string, resource: boolean) => Record<string, unknown>;
|
|
297
|
+
/** Starts an attempt: persistRecovery first, then launch, then the handle. */
|
|
298
|
+
run(r: AttemptRequest<Infer<S>>, ctx: ExecutorContext): Promise<RunHandle>;
|
|
299
|
+
/**
|
|
300
|
+
* Adopts an attempt from its continuity state, never launching a
|
|
301
|
+
* replacement: its live run, or its finished result. Throws
|
|
302
|
+
* Code.NotAdoptable when the state names nothing it holds.
|
|
303
|
+
*/
|
|
304
|
+
recover(r: AttemptRequest<Infer<S>>, state: Payload, ctx: ExecutorContext): Promise<RunHandle>;
|
|
305
|
+
/** Carries a parked attempt on with the wake's inputs (capability resume). */
|
|
306
|
+
resume?(r: AttemptRequest<Infer<S>>, state: Payload, ctx: ExecutorContext): Promise<RunHandle>;
|
|
307
|
+
/** Delivers an accepted Event to the running attempt (capability inject); idempotent per Event ID. */
|
|
308
|
+
inject?(execution: string, event: Event, ctx: ExecutorContext): Promise<void>;
|
|
309
|
+
/** Asks the running attempt to stop (capability interrupt). */
|
|
310
|
+
interrupt?(execution: string, ctx: ExecutorContext): Promise<void>;
|
|
311
|
+
/** Ends whatever of the execution runs at epoch, resolving once nothing of it can; a newer epoch must refuse. */
|
|
312
|
+
stop?(execution: string, epoch: number, ctx: ExecutorContext): Promise<void>;
|
|
313
|
+
/** Releases a terminal execution's private state; idempotent, and never signals a process. */
|
|
314
|
+
forget?(execution: string, ctx: ExecutorContext): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Releases the state of every execution the host doesn't know, as
|
|
317
|
+
* forget would, and never one whose process still runs; a failing known
|
|
318
|
+
* fails the sweep with nothing more released.
|
|
319
|
+
*/
|
|
320
|
+
sweep?(known: KnownFn, ctx: ExecutorContext): Promise<SweepReport>;
|
|
321
|
+
/** A running attempt's outputs so far; Code.NotLive when none runs here. */
|
|
322
|
+
live?(execution: string, tail: number, ctx: ExecutorContext): Promise<LiveOut[]>;
|
|
323
|
+
/** The command an operator's takeover of the Work runs; Code.NothingToAttach when there is none yet. */
|
|
324
|
+
attach?(work: string, ctx: ExecutorContext): Promise<{
|
|
325
|
+
argv: string[];
|
|
326
|
+
dir?: string;
|
|
327
|
+
}>;
|
|
328
|
+
/**
|
|
329
|
+
* The interactive launch an operator's takeover runs in the binding's
|
|
330
|
+
* container (control container_attach), which the host's container
|
|
331
|
+
* broker plans under the binding's policy.
|
|
332
|
+
*/
|
|
333
|
+
containerAttach?(r: ContainerAttachRequest<Infer<S>>, ctx: ExecutorContext): Promise<ContainerAttachSpec>;
|
|
334
|
+
/**
|
|
335
|
+
* The command that starts an interactive session of the executor's own
|
|
336
|
+
* CLI on a playbook in the operator's terminal, outside any Work
|
|
337
|
+
* (control interactive_launch). The host decides the playbook, the
|
|
338
|
+
* allowed commands, the directory and the environment; the executor only
|
|
339
|
+
* expresses them in its CLI's terms.
|
|
340
|
+
*/
|
|
341
|
+
interactiveLaunch?(r: InteractiveLaunchRequest, ctx: ExecutorContext): Promise<InteractiveLaunchSpec>;
|
|
342
|
+
/** Other names an operator may launch it by (`init --with`); they need interactiveLaunch. */
|
|
343
|
+
launchNames?: string[];
|
|
344
|
+
}
|
|
345
|
+
/** @internal An executor's validate and executor.* methods. */
|
|
346
|
+
export interface ExecutorHandler {
|
|
347
|
+
decl: ExecutorDecl;
|
|
348
|
+
validate: (config: unknown) => Promise<void>;
|
|
349
|
+
/** The validate kinds executor_mode, executor_playbook, executor_probe and executor_folder. */
|
|
350
|
+
answer: (p: ValidateParams) => ValidateResult;
|
|
351
|
+
serve: (method: string, raw: unknown, ctx: ExecutorContext, runs: ExecutorRuns) => Promise<unknown>;
|
|
352
|
+
}
|
|
353
|
+
/** @internal The handles of the attempts a connection started, and the sweeps it serves. */
|
|
354
|
+
export declare class ExecutorRuns {
|
|
355
|
+
#private;
|
|
356
|
+
constructor(id: () => string);
|
|
357
|
+
add(h: RunHandle): string;
|
|
358
|
+
get(id: string): RunHandle | undefined;
|
|
359
|
+
delete(id: string): void;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Why a result is invalid (extension.ValidateResult), or "" when it is
|
|
363
|
+
* valid: a known outcome kind, a retry or permanent only on a failure and
|
|
364
|
+
* never both, consumed inputs named once each, a cost with a currency, and
|
|
365
|
+
* usage units and attribution of the allowed names, none of them a unit
|
|
366
|
+
* the host counts itself.
|
|
367
|
+
*/
|
|
368
|
+
export declare function invalidResult(r: ExecutorResult): string;
|
|
369
|
+
/** The result as executor.wait answers it (protocol.FromResult). */
|
|
370
|
+
export declare function wireResult(r: ExecutorResult): Result;
|
|
371
|
+
/** The result a wire Result describes (protocol.Result.Extension). */
|
|
372
|
+
export declare function fromWireResult(r: Result): ExecutorResult;
|
|
373
|
+
/** The handler of one declared executor, refusing a spec whose capabilities its handlers don't back. */
|
|
374
|
+
export declare function executorHandler<S extends Type<unknown>>(name: string, spec: ExecutorSpec<S>, validateConfig: (schema: Type<unknown>, config: unknown, extra?: (config: never) => void | Promise<void>) => Promise<void>): ExecutorHandler;
|