@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.
Files changed (55) hide show
  1. package/dist/actions.d.ts +145 -0
  2. package/dist/actions.js +281 -0
  3. package/dist/actiontest.d.ts +80 -0
  4. package/dist/actiontest.js +190 -0
  5. package/dist/artifactstore.d.ts +133 -0
  6. package/dist/artifactstore.js +364 -0
  7. package/dist/backup.d.ts +99 -0
  8. package/dist/backup.js +178 -0
  9. package/dist/containertest.d.ts +71 -0
  10. package/dist/containertest.js +294 -0
  11. package/dist/errors.d.ts +28 -0
  12. package/dist/errors.js +37 -0
  13. package/dist/executor.d.ts +374 -0
  14. package/dist/executor.js +556 -0
  15. package/dist/executortest.d.ts +183 -0
  16. package/dist/executortest.js +534 -0
  17. package/dist/extension.d.ts +496 -1
  18. package/dist/extension.js +1152 -4
  19. package/dist/feed.d.ts +20 -0
  20. package/dist/feed.js +88 -0
  21. package/dist/forward.d.ts +38 -0
  22. package/dist/forward.js +163 -0
  23. package/dist/forwardca.d.ts +21 -0
  24. package/dist/forwardca.js +144 -0
  25. package/dist/hooks.d.ts +108 -0
  26. package/dist/hooks.js +13 -0
  27. package/dist/host.d.ts +166 -2
  28. package/dist/host.js +235 -2
  29. package/dist/index.d.ts +27 -3
  30. package/dist/index.js +14 -2
  31. package/dist/probe.d.ts +61 -0
  32. package/dist/probe.js +92 -0
  33. package/dist/providertest.d.ts +59 -0
  34. package/dist/providertest.js +168 -0
  35. package/dist/resources.d.ts +208 -0
  36. package/dist/resources.js +303 -0
  37. package/dist/sandbox.d.ts +84 -0
  38. package/dist/sandbox.js +85 -0
  39. package/dist/setup.d.ts +145 -0
  40. package/dist/setup.js +179 -0
  41. package/dist/setuptest.d.ts +90 -0
  42. package/dist/setuptest.js +319 -0
  43. package/dist/storetest.d.ts +64 -0
  44. package/dist/storetest.js +740 -0
  45. package/dist/telemetry.d.ts +86 -0
  46. package/dist/telemetry.js +46 -0
  47. package/dist/testing.d.ts +591 -2
  48. package/dist/testing.js +1460 -6
  49. package/dist/toolbelt.d.ts +91 -0
  50. package/dist/toolbelt.js +216 -0
  51. package/dist/tunnel.d.ts +62 -0
  52. package/dist/tunnel.js +93 -0
  53. package/dist/wire.d.ts +4060 -348
  54. package/dist/wire.js +1583 -0
  55. package/package.json +1 -1
package/dist/host.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Infer, type Type } from "./schema.js";
2
- import { AcceptedEvent, ArtifactRef, type Event, EventAcceptResult, type KVCheck, type KVDelete, PendingInput, Work } from "./wire.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
3
  /** The most Work one state.works page holds (protocol.MaxWorksPage). */
4
4
  export declare const MaxWorksPage = 1000;
5
5
  /**
@@ -57,7 +57,15 @@ export interface Accept extends Batch {
57
57
  }
58
58
  export declare class Host {
59
59
  #private;
60
- constructor(call: Caller);
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;
61
69
  /** Makes any extension-to-host call, decoding its result through result. */
62
70
  call<S extends Type<unknown>>(method: string, params: unknown, result: S, signal?: AbortSignal): Promise<Infer<S>>;
63
71
  /** Runs one of the extension's own tasks on the host's next pass. */
@@ -120,10 +128,166 @@ export declare class Host {
120
128
  * names, such as an operation's authority.connection.
121
129
  */
122
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>>;
123
138
  /** Writes an immutable artifact in chunks, each acknowledged before the next. */
124
139
  artifact(mediaType: string, data: Value, signal?: AbortSignal): Promise<ArtifactRef>;
125
140
  /** Sets the progress line of a Work's active Wait ("" clears it). */
126
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
+ }>;
127
291
  }
128
292
  export declare function toBytes(v: Value): Uint8Array;
129
293
  export declare function base64(b: Uint8Array): string;
package/dist/host.js CHANGED
@@ -5,14 +5,28 @@
5
5
  import { Code, ProtocolError } from "./errors.js";
6
6
  import { MaxChunkBytes } from "./jsonrpc.js";
7
7
  import { matches, t } from "./schema.js";
8
- import { AcceptedEvent, ArtifactCreateResult, ArtifactRef, EventAcceptResult, IngressDeliverResult, KVGetResult, KVListResult, PendingInput, SecretResolveResult, Work, } from "./wire.js";
8
+ import { AcceptedEvent, ArtifactCreateResult, ArtifactRef, ConfigBaseResult, ConfigEditResult, ConfigTraceResult, ConfigValidateResult, EntrySandboxResult, EventAcceptResult, EventRenderResult, Execution, IngressDeliverResult, KVGetResult, KVListResult, PendingInput, ProbeListResult, ProbeRunResult, RequestListResult, ActionListResult, ActionSubmitResult, ScopeAuthorizeResult, SecretResolveResult, TargetResolveResult, Work, WorkCancelResult, WorkSettleHoldResult, } from "./wire.js";
9
9
  /** The most Work one state.works page holds (protocol.MaxWorksPage). */
10
10
  export const MaxWorksPage = 1000;
11
11
  const Empty = t.any();
12
12
  export class Host {
13
13
  #call;
14
- constructor(call) {
14
+ #dirs;
15
+ /** dirs answers what the host named at initialize; without it both are "". */
16
+ constructor(call, dirs = () => ({
17
+ stateDir: "",
18
+ configDir: "",
19
+ })) {
15
20
  this.#call = call;
21
+ this.#dirs = dirs;
22
+ }
23
+ /** The extension's private state directory the host named at initialize. */
24
+ get stateDir() {
25
+ return this.#dirs().stateDir;
26
+ }
27
+ /** The operator's config file's directory the host named at initialize ("" for none), against which a relative path in a config resolves. */
28
+ get configDir() {
29
+ return this.#dirs().configDir;
16
30
  }
17
31
  /** Makes any extension-to-host call, decoding its result through result. */
18
32
  async call(method, params, result, signal) {
@@ -196,6 +210,16 @@ export class Host {
196
210
  const out = await this.call("secret.resolve", { scope_id: scopeId, connection, names }, SecretResolveResult, signal);
197
211
  return out.values ?? {};
198
212
  }
213
+ /**
214
+ * Resolves secret names a binding in the scope selects, when the
215
+ * binding's executor is one of the extension's own: the values each of
216
+ * its runs is given, for a doctor check that the binding's credential
217
+ * works. The host refuses any other binding or name.
218
+ */
219
+ async bindingSecrets(scopeId, binding, names, signal) {
220
+ const out = await this.call("secret.resolve", { scope_id: scopeId, binding, names }, SecretResolveResult, signal);
221
+ return out.values ?? {};
222
+ }
199
223
  /** Writes an immutable artifact in chunks, each acknowledged before the next. */
200
224
  async artifact(mediaType, data, signal) {
201
225
  const bytes = toBytes(data);
@@ -216,6 +240,215 @@ export class Host {
216
240
  async waitProgress(workId, progress, signal) {
217
241
  await this.call("wait.progress", { work_id: workId, progress }, Empty, signal);
218
242
  }
243
+ /**
244
+ * Records a named telemetry event in the host's telemetry events log,
245
+ * which every telemetry sink receives (telemetry.capture; it needs the
246
+ * telemetry.capture permission). scopeId is one of the extension's
247
+ * configured scopes, or absent for an event about the machine, and goes
248
+ * there rather than in properties; at (RFC 3339) defaults to the host's
249
+ * now. The host refuses a name over 128 bytes or with a newline, and
250
+ * properties over 64 KiB as JSON.
251
+ */
252
+ async capture(e, signal) {
253
+ await this.call("telemetry.capture", {
254
+ ...(e.scopeId ? { scope_id: e.scopeId } : {}),
255
+ name: e.name,
256
+ ...(e.at === undefined ? {} : { at: e.at }),
257
+ ...(e.properties === undefined ? {} : { properties: e.properties }),
258
+ }, Empty, signal);
259
+ }
260
+ // The host's config service (config.*; it needs the config.read
261
+ // permission). The host keeps config text behind handles and answers only
262
+ // copies with every secret_refs value "[redacted]", so an extension builds
263
+ // a candidate by editing a handle and never holds reference text. Nothing
264
+ // here applies a configuration: only the operator does that.
265
+ /**
266
+ * Reads the configuration now (config.base): its generation and hash, a
267
+ * handle on its file text, the text redacted, and the IDs of the scopes
268
+ * from included folders, whose text is in other files.
269
+ */
270
+ async configBase(signal) {
271
+ return this.call("config.base", {}, ConfigBaseResult, signal);
272
+ }
273
+ /**
274
+ * Makes one RFC 6902 edit to the text behind handle (config.edit): op is
275
+ * add, replace or remove at a JSON pointer, and value (any JSON value, at
276
+ * most 64 KiB) is for add and replace. It answers the new candidate's
277
+ * handle, its text redacted and the value the edit replaced, redacted
278
+ * (undefined for an insert). The host refuses a pointer that doesn't
279
+ * start with "/" or is over 512 bytes as invalid, and a handle it no
280
+ * longer holds as not_found: read the base again.
281
+ */
282
+ async configEdit(handle, op, pointer, value, signal) {
283
+ return this.call("config.edit", { handle, op, pointer, ...(value === undefined ? {} : { value }) }, ConfigEditResult, signal);
284
+ }
285
+ /**
286
+ * Validates the text behind handle as POST /config/validate would,
287
+ * changing nothing (config.validate): its hash when it is valid, its
288
+ * diagnostics when not.
289
+ */
290
+ async configValidate(handle, signal) {
291
+ return this.call("config.validate", { handle }, ConfigValidateResult, signal);
292
+ }
293
+ /**
294
+ * Traces one of a scope's named samples against the text behind handle,
295
+ * writing nothing (config.trace); with no sample it lists the scope's
296
+ * samples. A trace that can't run answers error, a fixed reason.
297
+ */
298
+ async configTrace(handle, scope, sample, signal) {
299
+ return this.call("config.trace", { handle, scope, ...(sample ? { sample } : {}) }, ConfigTraceResult, signal);
300
+ }
301
+ // Timers, cancellation and start holds.
302
+ /**
303
+ * Arms (or re-arms) a recurring timer of one of the extension's
304
+ * recurrence kinds in scopeId (timer.arm): the host fires it at
305
+ * timer.fire_at, asks the kind's recurrence for the occurrence and the
306
+ * next timer, and commits both with the firing. Its Event must be of the
307
+ * extension's own families, sourced in its namespace. expected guards a
308
+ * re-arm: 0 for a new timer, else the revision it replaces. spec is any
309
+ * JSON value, handed back to the recurrence on every firing.
310
+ */
311
+ async armTimer(scopeId, timer, o, signal) {
312
+ await this.call("timer.arm", {
313
+ scope_id: scopeId,
314
+ timer,
315
+ expected: o.expected ?? 0,
316
+ kind: o.kind,
317
+ spec: o.spec ?? null,
318
+ }, Empty, signal);
319
+ }
320
+ /** Cancels one of the extension's timers, guarded by expected (timer.cancel); an absent one is a no-op. */
321
+ async cancelTimer(id, expected = 0, signal) {
322
+ await this.call("timer.cancel", { id, expected }, Empty, signal);
323
+ }
324
+ /**
325
+ * Cancels Work of one of the extension's own kinds (work.cancel),
326
+ * guarded by expected (its revision, 0 for any) and idempotent per key.
327
+ * It answers the ID of the cancellation's Event.
328
+ */
329
+ async cancelWork(workId, o, signal) {
330
+ const out = await this.call("work.cancel", {
331
+ work_id: workId,
332
+ expected: o.expected ?? 0,
333
+ reason: o.reason,
334
+ key: o.key,
335
+ }, WorkCancelResult, signal);
336
+ return out.event_id;
337
+ }
338
+ /**
339
+ * Settles the hold the extension's start gate placed on a Work
340
+ * (work.settle_hold; it needs the work.start_gate permission): admit lets
341
+ * its next start through once, otherwise the Work is cancelled. reason
342
+ * goes in its history and key makes it idempotent. It answers the ID of
343
+ * the Event that records the settlement.
344
+ */
345
+ async settleHold(workId, o, signal) {
346
+ const out = await this.call("work.settle_hold", {
347
+ work_id: workId,
348
+ admit: o.admit,
349
+ ...(o.reason ? { reason: o.reason } : {}),
350
+ key: o.key,
351
+ }, WorkSettleHoldResult, signal);
352
+ return out.event_id;
353
+ }
354
+ // Reading across extensions.
355
+ /** One attempt of a Work in the extension's scopes or of its own kinds (state.execution). */
356
+ async execution(id, signal) {
357
+ return this.call("state.execution", { id }, Execution, signal);
358
+ }
359
+ /** The Event with a delivery identity, from the host's index (state.delivery); one outside the extension's scopes is not found. */
360
+ async eventByDelivery(source, deliveryId, signal) {
361
+ return this.call("state.delivery", { source, delivery_id: deliveryId }, AcceptedEvent, signal);
362
+ }
363
+ /**
364
+ * Renders an input Event for an agent's prompt through the extension
365
+ * that owns its family (event.render_owned), as an executor building a
366
+ * prompt does; undefined leaves it to the caller's own rendering.
367
+ */
368
+ async renderOwned(event, signal) {
369
+ const out = await this.call("event.render_owned", { event }, EventRenderResult, signal);
370
+ return out.ok ? (out.text ?? "") : undefined;
371
+ }
372
+ /**
373
+ * Resolves a named wait target of kind in one of the extension's scopes
374
+ * ("job" for a `job:<name>` condition) through the extensions that
375
+ * resolve that kind (wait.target): the correlation key and Event types
376
+ * that end it, or undefined when none has it.
377
+ */
378
+ async waitTarget(scopeId, kind, name, signal) {
379
+ const out = await this.call("wait.target", { scope_id: scopeId, kind, name }, TargetResolveResult, signal);
380
+ return out.ok ? { key: out.key, types: out.types ?? [] } : undefined;
381
+ }
382
+ /**
383
+ * Answers whether scope from, one of the extension's, may read ("read",
384
+ * authorization.read_scopes) or file in ("file",
385
+ * authorization.file_scopes) scope to under the operator's configuration
386
+ * (scope.authorize): undefined when it may, else the reason it may not
387
+ * and how the operator would allow it.
388
+ */
389
+ async authorize(kind, from, to, signal) {
390
+ const out = await this.call("scope.authorize", { kind, from, to }, ScopeAuthorizeResult, signal);
391
+ return out.allowed ? undefined : (out.reason ?? "not allowed");
392
+ }
393
+ // Actions for a person on the extension's own surface (it needs the
394
+ // action.submit permission).
395
+ /**
396
+ * Invokes an action for a person the extension identified on its own
397
+ * surface (action.submit), such as answering an approval request from a
398
+ * button they pressed. The provider sees the caller as {kind: the
399
+ * extension's name, id: caller}; an empty provider is the one offering
400
+ * the action on the target, and key makes it idempotent. A refusal is
401
+ * the provider's OperationError.
402
+ */
403
+ async act(r, signal) {
404
+ return this.call("action.submit", {
405
+ scope_id: r.scopeId,
406
+ ...(r.workId ? { work_id: r.workId } : {}),
407
+ ...(r.provider ? { provider: r.provider } : {}),
408
+ action: r.action,
409
+ ...(r.input ? { input: r.input } : {}),
410
+ caller: r.caller,
411
+ key: r.key,
412
+ }, ActionSubmitResult, signal);
413
+ }
414
+ /** What every provider offers now on a scope, or on Work in it (action.list), for act to take. */
415
+ async actions(scopeId, workId = "", signal) {
416
+ const out = await this.call("action.list", { scope_id: scopeId, ...(workId ? { work_id: workId } : {}) }, ActionListResult, signal);
417
+ return out.actions ?? [];
418
+ }
419
+ /** The requests every provider reports on Work in a scope, open and settled, with who may answer each (request.list). */
420
+ async requests(scopeId, workId, signal) {
421
+ const out = await this.call("request.list", { scope_id: scopeId, work_id: workId }, RequestListResult, signal);
422
+ return out.requests ?? [];
423
+ }
424
+ // Setup probes (they need the probes permission).
425
+ /** The setup probes the host, its extensions and its executors offer, by full name (probe.list). */
426
+ async probes(signal) {
427
+ const out = await this.call("probe.list", {}, ProbeListResult, signal);
428
+ return out.probes ?? [];
429
+ }
430
+ /**
431
+ * Runs one setup probe (probe.run), for a session in scopeId when given,
432
+ * which a probe that reads through a connection needs. A probe that ran
433
+ * and failed answers its reason in error.
434
+ */
435
+ async probe(name, args = {}, scopeId = "", signal) {
436
+ return this.call("probe.run", {
437
+ name,
438
+ ...(Object.keys(args).length > 0 ? { args } : {}),
439
+ ...(scopeId ? { scope_id: scopeId } : {}),
440
+ }, ProbeRunResult, signal);
441
+ }
442
+ /**
443
+ * Plans a launch of one of the extension's own processes for its entry
444
+ * in scope, in the sandbox that entry names (an entry type declared with
445
+ * a sandbox; sandbox.entry_plan): the host plans it with the entry's
446
+ * provider and policy and makes the directory it runs in. Run plan.argv
447
+ * with plan.env in dir and nothing else; any error means nothing may run.
448
+ */
449
+ async entrySandbox(scope, entry, needs, launch, signal) {
450
+ return this.call("sandbox.entry_plan", { scope, entry, needs, launch }, EntrySandboxResult, signal);
451
+ }
219
452
  }
220
453
  function entry(e) {
221
454
  return {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,34 @@
1
- export { extension, Extension, Server, ProtocolVersions } from "./extension.js";
2
- export type { CallContext, CheckContext, CheckFn, CommitOut, Context, EmitOut, EmitSpec, EntryOf, EntryTypeSpec, IngressTypeSpec, MigrateFn, OperationSpec, Options, PushDelivery, RouteCall, RouteSpec, SampleCall, SourceSpec, TaskFn, WaitOut, WaitSpec, WebhookContext, WebhookRequest, WebhookResponse, WorkKindSpec, } from "./extension.js";
1
+ export { extension, Extension, Server, ProtocolVersions, ContainerLabel, } from "./extension.js";
2
+ export type { CallContext, CheckContext, CheckFn, CommitOut, ContainerConfig, ContainerContext, ContainerPlanRequest, ContainerReattach, ContainerSpec, ContainerStatus, Context, EmitOut, EmitSpec, EntryOf, EntryTypeSpec, IngressTypeSpec, MigrateFn, OperationSpec, Options, PushDelivery, RouteCall, RouteSpec, SampleCall, CredentialCheck, SecretDeleteRequest, SecretRequest, SecretSchemeSpec, SecretWrite, SiteOutcome, SiteRun, SourceSpec, TaskFn, VerifiedCredential, VerifierSpec, WaitOut, WaitSpec, WebhookContext, WebhookRequest, WebhookResponse, WorkKindSpec, } from "./extension.js";
3
+ export { LocalOperator, PanelLimits, RequestState, Tone, panelProblem, } from "./actions.js";
4
+ export type { ActionCall, ActionCaller, ActionPlan, ActionsSpec, AnnotateFn, PageSpec, Panel, PanelMessage, PanelSection, RequestInfo, } from "./actions.js";
5
+ export { ProbeFailure } from "./probe.js";
6
+ export type { ProbeArgSpec, ProbeConnection, ProbeContext, ProbeOutput, ProbeSpec, } from "./probe.js";
7
+ export { ResourceMode, ResourceSetupError } from "./resources.js";
8
+ export type { LeaseAttention, ReconcileReport, ResourceAcquisition, ResourceContext, ResourceModeName, ResourceOut, ResourceOwnerStatus, ResourceProviderSpec, ResourceStatusFn, Site, SiteCommandInput, SiteRunResult, } from "./resources.js";
9
+ export { SandboxSignals } from "./sandbox.js";
10
+ export type { SandboxAdoptRequest, SandboxContext, SandboxPlanOut, SandboxPlanRequest, SandboxProviderSpec, } from "./sandbox.js";
11
+ export { TunnelConfigError, checkPublicURL } from "./tunnel.js";
12
+ export { ChangeState, SetupNoInput, SetupUsageError } from "./setup.js";
13
+ export type { Candidate, CandidateChange, ConfigCandidateFn, SetupHost, SetupResult, SetupSpec, } from "./setup.js";
14
+ export type { DependencyFilterFn, GateCall, GateWait, OperationGateFn, RecurrenceCall, RecurrenceFn, RecurrenceNext, RenderFn, ResolvedTarget, SegmentEndFn, StartCall, StartGateFn, TargetFn, } from "./hooks.js";
15
+ export { MaxRunFileBytes, MaxRunFiles, appliedEnv, checkRunFiles, } from "./telemetry.js";
16
+ export type { ExporterSpec, MetricsFn, RunEnvironmentFn, RunEnvironmentRequest, RunLayer, SinkFn, } from "./telemetry.js";
17
+ export type { PublishFn, TunnelProviderSpec, TunnelRunRequest, } from "./tunnel.js";
18
+ export { BackupManifest, validBackupBundle, validBackupPath, } from "./backup.js";
19
+ export type { BackupChunk, BackupDestinationSpec, BackupFile, BackupTarget, } from "./backup.js";
20
+ export { ArtifactCode, ArtifactError, ArtifactStoreChunk, ArtifactStoreVersion, serveArtifactProvider, serveArtifactStore, } from "./artifactstore.js";
21
+ export type { ArtifactBackend, ArtifactProvider, StoredArtifactRef, ArtifactStore, ArtifactWriter, Ownership, StoredArtifact, } from "./artifactstore.js";
22
+ export { MaxKnownBatch, fromWireResult, invalidResult, wireResult, } from "./executor.js";
23
+ export type { AcquiredResource, AttemptRequest, ContainerAttachRequest, ContainerAttachSpec, ContainerBroker, ContainerExitStatus, ExecutorCapabilities, ExecutorContext, ExecutorResult, ExecutorSpec, InteractiveLaunchRequest, InteractiveLaunchSpec, KnownFn, LaunchPlan, LiveOut, OutcomeKind, ResourceBroker, ResourceRequest, RunHandle, SandboxBroker, SweepReport, ToolbeltTransport, UsageRecord, } from "./executor.js";
24
+ export { Toolbelt, ToolbeltError, TurnEnded, toolbelt } from "./toolbelt.js";
25
+ export type { CallOptions, ToolResult, ToolWait, ToolbeltOptions, TurnEnd, } from "./toolbelt.js";
3
26
  export { Host, MaxWorksPage, text } from "./host.js";
4
27
  export type { Accept, Batch, Caller, DeliveryInput, Entry, Put, Value, WorksQuery, } from "./host.js";
5
28
  export { t, check, diagnose, matches, isRecord } from "./schema.js";
6
29
  export type { Infer, Type } from "./schema.js";
7
- export { Code, OperationError, ProtocolError, ConfigError, pointer, CancelledError, TransportError, isProtocolCode, } from "./errors.js";
30
+ export { Code, OperationError, ProtocolError, ConfigError, CredentialRefusal, SecretRefusal, SecretUnowned, validSecretCode, pointer, CancelledError, TransportError, isProtocolCode, } from "./errors.js";
8
31
  export type { ConfigDiagnostic } from "./errors.js";
32
+ export { dialForward, forwardAddress, forwardClientOptions, ForwardPortFile, ForwardCAFile, ForwardCertFile, ForwardServerName, } from "./forward.js";
9
33
  export { Conn, MaxMessageBytes, MaxChunkBytes, MaxInflight, MaxControlInflight, laneOf, } from "./jsonrpc.js";
10
34
  export * from "./wire.js";
package/dist/index.js CHANGED
@@ -11,9 +11,21 @@
11
11
  // await ext.main();
12
12
  //
13
13
  // The guide is site/src/content/docs/architecture/extension-packaging.md.
14
- export { extension, Extension, Server, ProtocolVersions } from "./extension.js";
14
+ export { extension, Extension, Server, ProtocolVersions, ContainerLabel, } from "./extension.js";
15
+ export { LocalOperator, PanelLimits, RequestState, Tone, panelProblem, } from "./actions.js";
16
+ export { ProbeFailure } from "./probe.js";
17
+ export { ResourceMode, ResourceSetupError } from "./resources.js";
18
+ export { SandboxSignals } from "./sandbox.js";
19
+ export { TunnelConfigError, checkPublicURL } from "./tunnel.js";
20
+ export { ChangeState, SetupNoInput, SetupUsageError } from "./setup.js";
21
+ export { MaxRunFileBytes, MaxRunFiles, appliedEnv, checkRunFiles, } from "./telemetry.js";
22
+ export { BackupManifest, validBackupBundle, validBackupPath, } from "./backup.js";
23
+ export { ArtifactCode, ArtifactError, ArtifactStoreChunk, ArtifactStoreVersion, serveArtifactProvider, serveArtifactStore, } from "./artifactstore.js";
24
+ export { MaxKnownBatch, fromWireResult, invalidResult, wireResult, } from "./executor.js";
25
+ export { Toolbelt, ToolbeltError, TurnEnded, toolbelt } from "./toolbelt.js";
15
26
  export { Host, MaxWorksPage, text } from "./host.js";
16
27
  export { t, check, diagnose, matches, isRecord } from "./schema.js";
17
- export { Code, OperationError, ProtocolError, ConfigError, pointer, CancelledError, TransportError, isProtocolCode, } from "./errors.js";
28
+ export { Code, OperationError, ProtocolError, ConfigError, CredentialRefusal, SecretRefusal, SecretUnowned, validSecretCode, pointer, CancelledError, TransportError, isProtocolCode, } from "./errors.js";
29
+ export { dialForward, forwardAddress, forwardClientOptions, ForwardPortFile, ForwardCAFile, ForwardCertFile, ForwardServerName, } from "./forward.js";
18
30
  export { Conn, MaxMessageBytes, MaxChunkBytes, MaxInflight, MaxControlInflight, laneOf, } from "./jsonrpc.js";
19
31
  export * from "./wire.js";
@@ -0,0 +1,61 @@
1
+ import type { Context } from "./extension.js";
2
+ import { type ProbeInfo, type ProbeRunParams, type ProbeRunResult } from "./wire.js";
3
+ import type { Host } from "./host.js";
4
+ /** One argument a probe takes. */
5
+ export interface ProbeArgSpec {
6
+ name: string;
7
+ summary?: string;
8
+ required?: boolean;
9
+ /** The value is a connection ID, which the host grants the probe for the run (ProbeContext.connection). */
10
+ connection?: boolean;
11
+ }
12
+ /** The connection a probe runs through. secret works only while the run lasts. */
13
+ export interface ProbeConnection {
14
+ id: string;
15
+ type: string;
16
+ config: unknown;
17
+ /** The names of its secrets. */
18
+ secrets: string[];
19
+ secret(name: string): Promise<string>;
20
+ }
21
+ export interface ProbeContext extends Context {
22
+ /** The scope a run through a connection is for; empty otherwise, since the host names one only then. */
23
+ scopeId: string;
24
+ /** The connection a connection argument named, granted for this run. */
25
+ connection?: ProbeConnection;
26
+ }
27
+ /** A probe's output and the command it stands for, shown to the operator ("gh auth status"). */
28
+ export interface ProbeOutput {
29
+ command?: string;
30
+ /** Any JSON value: safe output, with no secret and no account detail the setup doesn't need. */
31
+ output?: unknown;
32
+ }
33
+ export interface ProbeSpec {
34
+ /** One line for the agent: what the probe tells it. */
35
+ summary: string;
36
+ args?: ProbeArgSpec[];
37
+ /**
38
+ * Runs the probe without a shell. Throw ProbeFailure for a probe that
39
+ * ran and found a problem: its reason is shown to the agent, so it must
40
+ * be fixed text with no secret in it. Anything else thrown answers that
41
+ * the probe failed, never its message.
42
+ */
43
+ run: (args: Record<string, string>, ctx: ProbeContext) => ProbeOutput | Promise<ProbeOutput>;
44
+ }
45
+ /**
46
+ * A probe that ran and failed (extension.ErrProbeInput, or any reason it
47
+ * found): the message is shown to the agent, so it must be fixed and
48
+ * secret-free.
49
+ */
50
+ export declare class ProbeFailure extends Error {
51
+ constructor(reason: string);
52
+ }
53
+ /** @internal */
54
+ export interface ProbeHandler {
55
+ info: ProbeInfo;
56
+ serve: (p: ProbeRunParams, ctx: Context & {
57
+ host: Host;
58
+ }) => Promise<ProbeRunResult>;
59
+ }
60
+ /** @internal */
61
+ export declare function probeHandler(name: string, spec: ProbeSpec): ProbeHandler;