@capybara-hq/plugin-sdk 0.1.0-rc.65 → 0.1.0-rc.67

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.
@@ -224,7 +224,11 @@ export interface SandboxBrowseScope extends SandboxOperationRef {
224
224
  }
225
225
  /** Browsing exposes metadata only: no file contents, writes, preparation or execution. */
226
226
  export type SandboxBrowse = Pick<SandboxOperation, "stat"> & Required<Pick<SandboxOperation, "list" | "scan">>;
227
- /** An opaque locator over authenticated transport; validate generation before status, tail or stop. */
227
+ /**
228
+ * An opaque locator over authenticated transport; validate generation before status, tail or stop.
229
+ * `instanceGeneration` is the provider's own generation of the instance (the kernel's when the
230
+ * provider keeps none); the kernel stores the ref as returned and never compares it with its own.
231
+ */
228
232
  export interface SandboxExecutionRef {
229
233
  readonly executionId: string;
230
234
  readonly operationId: string;
@@ -261,7 +265,9 @@ export interface SandboxBackground {
261
265
  * Validate outputPath inside the scope. retainUntilMs bounds status/output record retention.
262
266
  * instanceGeneration is the kernel's generation of the held instance `h` (the kernel always
263
267
  * passes it, and allocates it only after `create` returns): a provider that keeps no generation
264
- * of its own (a cloud provider) returns it in the reference and keys start idempotency by it.
268
+ * of its own (a cloud provider) returns it in the reference and keys start idempotency by it; one
269
+ * that keeps its own (device-local's bound machine generation) returns that one instead. The
270
+ * kernel pins the task to its own generation and the held handle's id, not the ref's generation.
265
271
  */
266
272
  start(h: SandboxHandle, scope: SandboxOperationScope, args: SandboxExecOptions & {
267
273
  taskId: string;
@@ -274,7 +274,9 @@ export declare function isProjectPathRefusedError(e: unknown): e is ProjectPathR
274
274
  * equal token is the same holder and is accepted); `create` seeds the new instance's token and
275
275
  * should refuse when the instance it would replace carries a higher one; `destroy` /
276
276
  * `destroyByName` should refuse an instance carrying a higher token. A provider that cannot (no
277
- * conditional write in its backend) ignores the token and states the residual race in its README.
277
+ * conditional write in its backend) ignores the token and states the residual race in its README;
278
+ * it should implement {@link DeviceProvider.appliedNetwork}, so the kernel narrows a late stale
279
+ * `update` again at the next lifecycle step.
278
280
  * The fence is `undefined` only from an older kernel that sends none: freshness is then unproven,
279
281
  * so a provider answers `recreate` to an in-place change it would otherwise fence, seeds 0 at
280
282
  * `create` and destroys without a check. `null` (destroy only) means the kernel has no fence for
@@ -353,6 +355,25 @@ export interface DeviceProvider {
353
355
  * still refused.
354
356
  */
355
357
  update?(h: SandboxHandle, limits: SandboxLimits, signal: AbortSignal, fence: DeviceFence): Promise<"updated" | "recreate">;
358
+ /**
359
+ * The network the instance `h` enforces now, as the provider's backend reports it, or null when
360
+ * the provider cannot tell (optional; read only with {@link DeviceProvider.update}). A read
361
+ * only: it must not resume, start or change the instance, and must respond to `signal`.
362
+ *
363
+ * For a provider whose `update` cannot honor the fence (no conditional write in its backend), a
364
+ * stale holder's late `update` can leave the instance wider than the kernel's record. At a
365
+ * lifecycle step under the exclusive lease (a resumed instance, a running one the use holds
366
+ * exclusively, an instance created on kept files whose limits are fixed at the file system)
367
+ * the kernel compares this answer with the limits it recorded and, when it allows more (the
368
+ * open public network over an allowlist, or a host the record does not cover), is null or
369
+ * fails, applies the desired limits again through `update` with its own fence (a provider bound
370
+ * to its file system that cannot apply them is stopped until it can). Equal or narrower changes
371
+ * nothing. Since null forces that `update` at every such step, answer null only for a state the
372
+ * provider really cannot read, never as a routine answer. Shared uses of a running instance read
373
+ * nothing, so a late call that lands while the instance keeps running is narrowed at its next
374
+ * resume or rebuild (at the latest after the kernel's maximum running time).
375
+ */
376
+ appliedNetwork?(h: SandboxHandle, signal: AbortSignal): Promise<SandboxLimits["network"] | null>;
356
377
  /**
357
378
  * Creates a device's file system. `name` looks like `cap-device-<deviceId>`. If a file
358
379
  * system with this name already exists, return it.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.65";
1
+ export declare const SDK_VERSION = "0.1.0-rc.67";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./avatar-presets.js";
4
4
  export * from "./bootstrap.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = "0.1.0-rc.65";
1
+ export const SDK_VERSION = "0.1.0-rc.67";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./avatar-presets.js";
4
4
  export * from "./bootstrap.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-sdk",
3
- "version": "0.1.0-rc.65",
3
+ "version": "0.1.0-rc.67",
4
4
  "description": "Capybara plugin SDK: the types and pure functions plugins are written against",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {