@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
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { type Infer, type Type } from "./schema.js";
|
|
2
|
+
import { AcceptedEvent, ArtifactRef, ConfigBaseResult, ConfigEditResult, ConfigTraceResult, ConfigValidateResult, type Event, EventAcceptResult, Execution, type KVCheck, type KVDelete, PendingInput, ProbeRunResult, type ProbeInfo, ActionSubmitResult, type ActionOffer, type RequestOffer, type SandboxLaunch, type SandboxNeeds, type SandboxPlan, TargetResolveResult, type Timer, Work } from "./wire.js";
|
|
3
|
+
/** The most Work one state.works page holds (protocol.MaxWorksPage). */
|
|
4
|
+
export declare const MaxWorksPage = 1000;
|
|
5
|
+
/**
|
|
6
|
+
* What a state.works read selects (storage.WorkQuery): Work in any of
|
|
7
|
+
* `states`, of `scopeId`, `kind`, `parentId`, any of `sources` and
|
|
8
|
+
* `executor`, updated at or after `updatedSince` (an RFC 3339 time).
|
|
9
|
+
* `order` is "created", "-created", "updated" or "-updated".
|
|
10
|
+
*/
|
|
11
|
+
export interface WorksQuery {
|
|
12
|
+
scopeId?: string;
|
|
13
|
+
states?: string[];
|
|
14
|
+
kind?: string;
|
|
15
|
+
parentId?: string;
|
|
16
|
+
sources?: string[];
|
|
17
|
+
executor?: string;
|
|
18
|
+
updatedSince?: string;
|
|
19
|
+
order?: "created" | "-created" | "updated" | "-updated";
|
|
20
|
+
limit?: number;
|
|
21
|
+
}
|
|
22
|
+
/** Makes one extension-to-host call; the result is decoded by the caller. */
|
|
23
|
+
export type Caller = (method: string, params: unknown, signal?: AbortSignal) => Promise<unknown>;
|
|
24
|
+
/** A KV value: bytes, or a string stored as its UTF-8 bytes. */
|
|
25
|
+
export type Value = Uint8Array | string;
|
|
26
|
+
/** A KV entry and its version, which a later commit can require unchanged. */
|
|
27
|
+
export interface Entry {
|
|
28
|
+
key: string;
|
|
29
|
+
value: Uint8Array;
|
|
30
|
+
version: string;
|
|
31
|
+
}
|
|
32
|
+
export interface Put {
|
|
33
|
+
namespace: string;
|
|
34
|
+
key: string;
|
|
35
|
+
value: Value;
|
|
36
|
+
}
|
|
37
|
+
/** A precondition batch, applied atomically: a failed check changes nothing. */
|
|
38
|
+
export interface Batch {
|
|
39
|
+
checks?: KVCheck[];
|
|
40
|
+
puts?: Put[];
|
|
41
|
+
deletes?: KVDelete[];
|
|
42
|
+
}
|
|
43
|
+
/** A delivery to push to a source: a webhook's body, say. */
|
|
44
|
+
export interface DeliveryInput {
|
|
45
|
+
/** The sender's delivery ID: a retry carries the same one. */
|
|
46
|
+
id: string;
|
|
47
|
+
/** When it was received (default now). */
|
|
48
|
+
receivedAt?: string;
|
|
49
|
+
contentType?: string;
|
|
50
|
+
body?: Value;
|
|
51
|
+
}
|
|
52
|
+
/** One Event derived from parent, committed atomically with the batch. */
|
|
53
|
+
export interface Accept extends Batch {
|
|
54
|
+
scopeId: string;
|
|
55
|
+
parent: string;
|
|
56
|
+
event: Event;
|
|
57
|
+
}
|
|
58
|
+
export declare class Host {
|
|
59
|
+
#private;
|
|
60
|
+
/** dirs answers what the host named at initialize; without it both are "". */
|
|
61
|
+
constructor(call: Caller, dirs?: () => {
|
|
62
|
+
stateDir: string;
|
|
63
|
+
configDir: string;
|
|
64
|
+
});
|
|
65
|
+
/** The extension's private state directory the host named at initialize. */
|
|
66
|
+
get stateDir(): string;
|
|
67
|
+
/** The operator's config file's directory the host named at initialize ("" for none), against which a relative path in a config resolves. */
|
|
68
|
+
get configDir(): string;
|
|
69
|
+
/** Makes any extension-to-host call, decoding its result through result. */
|
|
70
|
+
call<S extends Type<unknown>>(method: string, params: unknown, result: S, signal?: AbortSignal): Promise<Infer<S>>;
|
|
71
|
+
/** Runs one of the extension's own tasks on the host's next pass. */
|
|
72
|
+
wakeTask(task: string, signal?: AbortSignal): Promise<void>;
|
|
73
|
+
/** A KV value and its version, or undefined when the key is absent. */
|
|
74
|
+
get(namespace: string, key: string, signal?: AbortSignal): Promise<Entry | undefined>;
|
|
75
|
+
/** The entries under prefix, in lexical key order. */
|
|
76
|
+
list(namespace: string, prefix?: string, signal?: AbortSignal): Promise<Entry[]>;
|
|
77
|
+
/** Applies a batch atomically; a failed check throws ProtocolError conflict. */
|
|
78
|
+
commit(b: Batch, signal?: AbortSignal): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Reads a key, applies fn and commits with a version check, retrying when
|
|
81
|
+
* another writer got there first. fn returns undefined to delete the key.
|
|
82
|
+
*/
|
|
83
|
+
update(namespace: string, key: string, fn: (old: Uint8Array | undefined) => Value | undefined | Promise<Value | undefined>, signal?: AbortSignal): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Derives one Event from parent (an accepted Event in a configured scope),
|
|
86
|
+
* committing the batch's KV writes atomically with it.
|
|
87
|
+
*/
|
|
88
|
+
accept(a: Accept, signal?: AbortSignal): Promise<EventAcceptResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Hands a delivery (a verified webhook's body) to the source registered
|
|
91
|
+
* as name. The host calls the source's push with it and answers once its
|
|
92
|
+
* Events are durably accepted: added[i] is false for an Event it already
|
|
93
|
+
* had, such as a sender's retry.
|
|
94
|
+
*/
|
|
95
|
+
deliver(name: string, delivery: DeliveryInput, signal?: AbortSignal): Promise<{
|
|
96
|
+
accepted: AcceptedEvent[];
|
|
97
|
+
added: boolean[];
|
|
98
|
+
}>;
|
|
99
|
+
/** Accepted Events of the configured scopes after a sequence. */
|
|
100
|
+
events(after?: number, limit?: number, signal?: AbortSignal): Promise<AcceptedEvent[]>;
|
|
101
|
+
/**
|
|
102
|
+
* One Work's accepted Events of the configured scopes after a sequence:
|
|
103
|
+
* those naming it and those routed to it. The host reads them from its
|
|
104
|
+
* index, so the cost follows the Work's own Events, not the whole log.
|
|
105
|
+
*/
|
|
106
|
+
workEvents(workId: string, after?: number, limit?: number, signal?: AbortSignal): Promise<AcceptedEvent[]>;
|
|
107
|
+
/** Work of the configured scopes (one scope when scopeId is set). */
|
|
108
|
+
works(scopeId?: string, signal?: AbortSignal): Promise<Work[]>;
|
|
109
|
+
/**
|
|
110
|
+
* The Work a query selects, of the configured scopes and the extension's
|
|
111
|
+
* own kinds, in its order (by creation unless `order` says otherwise),
|
|
112
|
+
* at most `limit` (all when unset). The host reads them through its
|
|
113
|
+
* indexes a page at a time, so the cost follows the Work selected, not
|
|
114
|
+
* every Work ever made: ask for live Work with `states`, or for Work
|
|
115
|
+
* changed since a time with `updatedSince`.
|
|
116
|
+
*/
|
|
117
|
+
queryWorks(query: WorksQuery, signal?: AbortSignal): Promise<Work[]>;
|
|
118
|
+
/**
|
|
119
|
+
* The input routed to a Work that no attempt of it has read yet, oldest
|
|
120
|
+
* first. Ready Work with none has read everything routed to it; ready
|
|
121
|
+
* Work with some is about to start on it.
|
|
122
|
+
*/
|
|
123
|
+
pending(workId: string, signal?: AbortSignal): Promise<PendingInput[]>;
|
|
124
|
+
/** Resolves secret names bound to the extension's entry in a scope. */
|
|
125
|
+
secrets(scopeId: string, names: string[], signal?: AbortSignal): Promise<Record<string, string>>;
|
|
126
|
+
/**
|
|
127
|
+
* Resolves secret names of a connection an entry or binding in the scope
|
|
128
|
+
* names, such as an operation's authority.connection.
|
|
129
|
+
*/
|
|
130
|
+
connectionSecrets(scopeId: string, connection: string, names: string[], signal?: AbortSignal): Promise<Record<string, string>>;
|
|
131
|
+
/**
|
|
132
|
+
* Resolves secret names a binding in the scope selects, when the
|
|
133
|
+
* binding's executor is one of the extension's own: the values each of
|
|
134
|
+
* its runs is given, for a doctor check that the binding's credential
|
|
135
|
+
* works. The host refuses any other binding or name.
|
|
136
|
+
*/
|
|
137
|
+
bindingSecrets(scopeId: string, binding: string, names: string[], signal?: AbortSignal): Promise<Record<string, string>>;
|
|
138
|
+
/** Writes an immutable artifact in chunks, each acknowledged before the next. */
|
|
139
|
+
artifact(mediaType: string, data: Value, signal?: AbortSignal): Promise<ArtifactRef>;
|
|
140
|
+
/** Sets the progress line of a Work's active Wait ("" clears it). */
|
|
141
|
+
waitProgress(workId: string, progress: string, signal?: AbortSignal): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Records a named telemetry event in the host's telemetry events log,
|
|
144
|
+
* which every telemetry sink receives (telemetry.capture; it needs the
|
|
145
|
+
* telemetry.capture permission). scopeId is one of the extension's
|
|
146
|
+
* configured scopes, or absent for an event about the machine, and goes
|
|
147
|
+
* there rather than in properties; at (RFC 3339) defaults to the host's
|
|
148
|
+
* now. The host refuses a name over 128 bytes or with a newline, and
|
|
149
|
+
* properties over 64 KiB as JSON.
|
|
150
|
+
*/
|
|
151
|
+
capture(e: {
|
|
152
|
+
scopeId?: string;
|
|
153
|
+
name: string;
|
|
154
|
+
at?: string;
|
|
155
|
+
properties?: Record<string, unknown>;
|
|
156
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Reads the configuration now (config.base): its generation and hash, a
|
|
159
|
+
* handle on its file text, the text redacted, and the IDs of the scopes
|
|
160
|
+
* from included folders, whose text is in other files.
|
|
161
|
+
*/
|
|
162
|
+
configBase(signal?: AbortSignal): Promise<ConfigBaseResult>;
|
|
163
|
+
/**
|
|
164
|
+
* Makes one RFC 6902 edit to the text behind handle (config.edit): op is
|
|
165
|
+
* add, replace or remove at a JSON pointer, and value (any JSON value, at
|
|
166
|
+
* most 64 KiB) is for add and replace. It answers the new candidate's
|
|
167
|
+
* handle, its text redacted and the value the edit replaced, redacted
|
|
168
|
+
* (undefined for an insert). The host refuses a pointer that doesn't
|
|
169
|
+
* start with "/" or is over 512 bytes as invalid, and a handle it no
|
|
170
|
+
* longer holds as not_found: read the base again.
|
|
171
|
+
*/
|
|
172
|
+
configEdit(handle: string, op: "add" | "replace" | "remove", pointer: string, value?: unknown, signal?: AbortSignal): Promise<ConfigEditResult>;
|
|
173
|
+
/**
|
|
174
|
+
* Validates the text behind handle as POST /config/validate would,
|
|
175
|
+
* changing nothing (config.validate): its hash when it is valid, its
|
|
176
|
+
* diagnostics when not.
|
|
177
|
+
*/
|
|
178
|
+
configValidate(handle: string, signal?: AbortSignal): Promise<ConfigValidateResult>;
|
|
179
|
+
/**
|
|
180
|
+
* Traces one of a scope's named samples against the text behind handle,
|
|
181
|
+
* writing nothing (config.trace); with no sample it lists the scope's
|
|
182
|
+
* samples. A trace that can't run answers error, a fixed reason.
|
|
183
|
+
*/
|
|
184
|
+
configTrace(handle: string, scope: string, sample?: string, signal?: AbortSignal): Promise<ConfigTraceResult>;
|
|
185
|
+
/**
|
|
186
|
+
* Arms (or re-arms) a recurring timer of one of the extension's
|
|
187
|
+
* recurrence kinds in scopeId (timer.arm): the host fires it at
|
|
188
|
+
* timer.fire_at, asks the kind's recurrence for the occurrence and the
|
|
189
|
+
* next timer, and commits both with the firing. Its Event must be of the
|
|
190
|
+
* extension's own families, sourced in its namespace. expected guards a
|
|
191
|
+
* re-arm: 0 for a new timer, else the revision it replaces. spec is any
|
|
192
|
+
* JSON value, handed back to the recurrence on every firing.
|
|
193
|
+
*/
|
|
194
|
+
armTimer(scopeId: string, timer: Timer, o: {
|
|
195
|
+
kind: string;
|
|
196
|
+
spec?: unknown;
|
|
197
|
+
expected?: number;
|
|
198
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
199
|
+
/** Cancels one of the extension's timers, guarded by expected (timer.cancel); an absent one is a no-op. */
|
|
200
|
+
cancelTimer(id: string, expected?: number, signal?: AbortSignal): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Cancels Work of one of the extension's own kinds (work.cancel),
|
|
203
|
+
* guarded by expected (its revision, 0 for any) and idempotent per key.
|
|
204
|
+
* It answers the ID of the cancellation's Event.
|
|
205
|
+
*/
|
|
206
|
+
cancelWork(workId: string, o: {
|
|
207
|
+
reason: string;
|
|
208
|
+
key: string;
|
|
209
|
+
expected?: number;
|
|
210
|
+
}, signal?: AbortSignal): Promise<string>;
|
|
211
|
+
/**
|
|
212
|
+
* Settles the hold the extension's start gate placed on a Work
|
|
213
|
+
* (work.settle_hold; it needs the work.start_gate permission): admit lets
|
|
214
|
+
* its next start through once, otherwise the Work is cancelled. reason
|
|
215
|
+
* goes in its history and key makes it idempotent. It answers the ID of
|
|
216
|
+
* the Event that records the settlement.
|
|
217
|
+
*/
|
|
218
|
+
settleHold(workId: string, o: {
|
|
219
|
+
admit: boolean;
|
|
220
|
+
reason?: string;
|
|
221
|
+
key: string;
|
|
222
|
+
}, signal?: AbortSignal): Promise<string>;
|
|
223
|
+
/** One attempt of a Work in the extension's scopes or of its own kinds (state.execution). */
|
|
224
|
+
execution(id: string, signal?: AbortSignal): Promise<Execution>;
|
|
225
|
+
/** The Event with a delivery identity, from the host's index (state.delivery); one outside the extension's scopes is not found. */
|
|
226
|
+
eventByDelivery(source: string, deliveryId: string, signal?: AbortSignal): Promise<AcceptedEvent>;
|
|
227
|
+
/**
|
|
228
|
+
* Renders an input Event for an agent's prompt through the extension
|
|
229
|
+
* that owns its family (event.render_owned), as an executor building a
|
|
230
|
+
* prompt does; undefined leaves it to the caller's own rendering.
|
|
231
|
+
*/
|
|
232
|
+
renderOwned(event: Event, signal?: AbortSignal): Promise<string | undefined>;
|
|
233
|
+
/**
|
|
234
|
+
* Resolves a named wait target of kind in one of the extension's scopes
|
|
235
|
+
* ("job" for a `job:<name>` condition) through the extensions that
|
|
236
|
+
* resolve that kind (wait.target): the correlation key and Event types
|
|
237
|
+
* that end it, or undefined when none has it.
|
|
238
|
+
*/
|
|
239
|
+
waitTarget(scopeId: string, kind: string, name: string, signal?: AbortSignal): Promise<{
|
|
240
|
+
key: Infer<typeof TargetResolveResult>["key"];
|
|
241
|
+
types: string[];
|
|
242
|
+
} | undefined>;
|
|
243
|
+
/**
|
|
244
|
+
* Answers whether scope from, one of the extension's, may read ("read",
|
|
245
|
+
* authorization.read_scopes) or file in ("file",
|
|
246
|
+
* authorization.file_scopes) scope to under the operator's configuration
|
|
247
|
+
* (scope.authorize): undefined when it may, else the reason it may not
|
|
248
|
+
* and how the operator would allow it.
|
|
249
|
+
*/
|
|
250
|
+
authorize(kind: "read" | "file", from: string, to: string, signal?: AbortSignal): Promise<string | undefined>;
|
|
251
|
+
/**
|
|
252
|
+
* Invokes an action for a person the extension identified on its own
|
|
253
|
+
* surface (action.submit), such as answering an approval request from a
|
|
254
|
+
* button they pressed. The provider sees the caller as {kind: the
|
|
255
|
+
* extension's name, id: caller}; an empty provider is the one offering
|
|
256
|
+
* the action on the target, and key makes it idempotent. A refusal is
|
|
257
|
+
* the provider's OperationError.
|
|
258
|
+
*/
|
|
259
|
+
act(r: {
|
|
260
|
+
scopeId: string;
|
|
261
|
+
workId?: string;
|
|
262
|
+
provider?: string;
|
|
263
|
+
action: string;
|
|
264
|
+
input?: string;
|
|
265
|
+
caller: string;
|
|
266
|
+
key: string;
|
|
267
|
+
}, signal?: AbortSignal): Promise<Infer<typeof ActionSubmitResult>>;
|
|
268
|
+
/** What every provider offers now on a scope, or on Work in it (action.list), for act to take. */
|
|
269
|
+
actions(scopeId: string, workId?: string, signal?: AbortSignal): Promise<ActionOffer[]>;
|
|
270
|
+
/** The requests every provider reports on Work in a scope, open and settled, with who may answer each (request.list). */
|
|
271
|
+
requests(scopeId: string, workId: string, signal?: AbortSignal): Promise<RequestOffer[]>;
|
|
272
|
+
/** The setup probes the host, its extensions and its executors offer, by full name (probe.list). */
|
|
273
|
+
probes(signal?: AbortSignal): Promise<ProbeInfo[]>;
|
|
274
|
+
/**
|
|
275
|
+
* Runs one setup probe (probe.run), for a session in scopeId when given,
|
|
276
|
+
* which a probe that reads through a connection needs. A probe that ran
|
|
277
|
+
* and failed answers its reason in error.
|
|
278
|
+
*/
|
|
279
|
+
probe(name: string, args?: Record<string, string>, scopeId?: string, signal?: AbortSignal): Promise<Infer<typeof ProbeRunResult>>;
|
|
280
|
+
/**
|
|
281
|
+
* Plans a launch of one of the extension's own processes for its entry
|
|
282
|
+
* in scope, in the sandbox that entry names (an entry type declared with
|
|
283
|
+
* a sandbox; sandbox.entry_plan): the host plans it with the entry's
|
|
284
|
+
* provider and policy and makes the directory it runs in. Run plan.argv
|
|
285
|
+
* with plan.env in dir and nothing else; any error means nothing may run.
|
|
286
|
+
*/
|
|
287
|
+
entrySandbox(scope: string, entry: string, needs: SandboxNeeds, launch: SandboxLaunch, signal?: AbortSignal): Promise<{
|
|
288
|
+
plan: SandboxPlan;
|
|
289
|
+
dir: string;
|
|
290
|
+
}>;
|
|
291
|
+
}
|
|
292
|
+
export declare function toBytes(v: Value): Uint8Array;
|
|
293
|
+
export declare function base64(b: Uint8Array): string;
|
|
294
|
+
/** Decodes a KV value as UTF-8 text. */
|
|
295
|
+
export declare function text(v: Uint8Array): string;
|