@capybara-hq/plugin-sdk 0.1.0-rc.5 → 0.1.0-rc.51

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 (134) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +4 -1
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +2 -0
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +29 -3
  13. package/agent-docs/plugin-format.md +53 -2
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +86 -1
  20. package/dist/bootstrap.js +161 -2
  21. package/dist/cards.d.ts +67 -13
  22. package/dist/cards.js +91 -21
  23. package/dist/channel.d.ts +148 -48
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +22 -0
  30. package/dist/config-ui.js +64 -4
  31. package/dist/connector-auth.d.ts +7 -2
  32. package/dist/connector-auth.js +29 -8
  33. package/dist/connector.d.ts +74 -32
  34. package/dist/context.d.ts +40 -0
  35. package/dist/context.js +2 -0
  36. package/dist/ctx.d.ts +120 -29
  37. package/dist/define-extension.d.ts +26 -12
  38. package/dist/define-extension.js +11 -4
  39. package/dist/device-denied-paths.d.ts +14 -0
  40. package/dist/device-denied-paths.js +41 -0
  41. package/dist/device-operation.d.ts +302 -0
  42. package/dist/device-operation.js +292 -0
  43. package/dist/device-protocol.d.ts +490 -0
  44. package/dist/device-protocol.js +1117 -0
  45. package/dist/device-provider.d.ts +472 -0
  46. package/dist/device-provider.js +283 -0
  47. package/dist/extension-point.d.ts +2 -0
  48. package/dist/extension-point.js +6 -2
  49. package/dist/file-preview.d.ts +23 -6
  50. package/dist/git-hosts.d.ts +53 -0
  51. package/dist/git-hosts.js +98 -0
  52. package/dist/hooks.d.ts +125 -20
  53. package/dist/hooks.js +5 -0
  54. package/dist/http-access.d.ts +62 -0
  55. package/dist/http-access.js +12 -0
  56. package/dist/identity.d.ts +38 -9
  57. package/dist/identity.js +21 -1
  58. package/dist/index.d.ts +29 -2
  59. package/dist/index.js +29 -2
  60. package/dist/marketplace.d.ts +26 -0
  61. package/dist/marketplace.js +43 -1
  62. package/dist/model-params.d.ts +41 -22
  63. package/dist/model-params.js +28 -15
  64. package/dist/model.d.ts +206 -71
  65. package/dist/model.js +152 -19
  66. package/dist/net.d.ts +52 -0
  67. package/dist/net.js +34 -0
  68. package/dist/network-classes.d.ts +98 -0
  69. package/dist/network-classes.js +291 -0
  70. package/dist/permissions.d.ts +41 -21
  71. package/dist/permissions.js +101 -42
  72. package/dist/plugin-manifest.d.ts +45 -5
  73. package/dist/plugin-manifest.js +169 -6
  74. package/dist/plugin-package.d.ts +82 -38
  75. package/dist/plugin-package.js +61 -29
  76. package/dist/push.d.ts +75 -0
  77. package/dist/push.js +87 -0
  78. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  79. package/dist/sandbox-linux-runtime-source.js +2318 -0
  80. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  81. package/dist/sandbox-native-runtime-source.js +476 -0
  82. package/dist/sandbox-runtime-source.d.ts +19 -0
  83. package/dist/sandbox-runtime-source.js +28 -0
  84. package/dist/sandbox-write-denies.d.ts +139 -0
  85. package/dist/sandbox-write-denies.js +869 -0
  86. package/dist/secret.d.ts +4 -1
  87. package/dist/secret.js +4 -1
  88. package/dist/setup-check.d.ts +128 -0
  89. package/dist/setup-check.js +142 -0
  90. package/dist/setup-guide-parse.d.ts +135 -0
  91. package/dist/setup-guide-parse.js +413 -0
  92. package/dist/setup-guide-render.d.ts +50 -0
  93. package/dist/setup-guide-render.js +367 -0
  94. package/dist/setup-guide.d.ts +109 -0
  95. package/dist/setup-guide.js +377 -0
  96. package/dist/shell-capabilities.d.ts +231 -0
  97. package/dist/shell-capabilities.js +37 -0
  98. package/dist/shell-environment.d.ts +57 -0
  99. package/dist/shell-environment.js +22 -0
  100. package/dist/skill-invocation.d.ts +4 -3
  101. package/dist/skill-invocation.js +5 -4
  102. package/dist/skill.d.ts +34 -21
  103. package/dist/skill.js +49 -32
  104. package/dist/storage.d.ts +52 -25
  105. package/dist/theme-assets.d.ts +55 -0
  106. package/dist/theme-assets.js +507 -0
  107. package/dist/theme-readability.d.ts +37 -0
  108. package/dist/theme-readability.js +145 -0
  109. package/dist/theme-tokens.generated.d.ts +299 -0
  110. package/dist/theme-tokens.generated.js +184 -0
  111. package/dist/theme.d.ts +190 -0
  112. package/dist/theme.js +471 -0
  113. package/dist/tool.d.ts +69 -26
  114. package/dist/tool.js +29 -9
  115. package/dist/ui-parts.d.ts +23 -0
  116. package/dist/ui-parts.js +348 -0
  117. package/dist/ui-resolve.d.ts +35 -0
  118. package/dist/ui-resolve.js +42 -0
  119. package/dist/ui-slots.d.ts +65 -0
  120. package/dist/ui-slots.js +261 -0
  121. package/dist/ui.d.ts +212 -76
  122. package/dist/ui.js +101 -27
  123. package/dist/url.d.ts +4 -1
  124. package/dist/url.js +4 -1
  125. package/package.json +8 -1
  126. package/schemas/bootstrap-extra.v1.schema.json +172 -0
  127. package/schemas/bootstrap.v1.schema.json +6 -0
  128. package/schemas/connector-template.v1.schema.json +35 -0
  129. package/schemas/marketplace.v1.schema.json +14 -0
  130. package/schemas/plugin.v1.schema.json +117 -3
  131. package/schemas/theme.v1.schema.json +302 -0
  132. package/agent-docs/extension-points/sandbox.md +0 -15
  133. package/dist/sandbox.d.ts +0 -232
  134. package/dist/sandbox.js +0 -120
@@ -1,17 +1,20 @@
1
1
  import semver from "semver";
2
2
  import { EXTENSION_POINTS, parseExtensionPoint, } from "./extension-point.js";
3
3
  import { validatePermissions, validateUiContributions, } from "./permissions.js";
4
- /** 插件清单不合法。 */
4
+ /** The plugin manifest is invalid. */
5
5
  export class ExtensionManifestError extends Error {
6
6
  constructor(plugin, message) {
7
7
  super(`extension ${plugin}: ${message}`);
8
8
  this.name = "ExtensionManifestError";
9
9
  }
10
10
  }
11
- /** 插件名规则(清单 `name`;连接器模板的 `plugin` 也按它校验)。 */
11
+ /** Plugin name rule (manifest `name`; a connector template's `plugin` is validated by it too). */
12
12
  export const EXTENSION_NAME_RE = /^[a-z][a-z0-9-]{1,40}$/;
13
13
  const NAME_RE = EXTENSION_NAME_RE;
14
- /** 保留的插件名:内核用 `kernel` 作为自己的 secrets 命名空间,插件不能与之相同。 */
14
+ /**
15
+ * Reserved plugin name: the kernel uses `kernel` as its own secrets namespace, so a plugin cannot
16
+ * take it.
17
+ */
15
18
  const RESERVED_NAMES = new Set(["kernel"]);
16
19
  function checkRefs(label, refs, fail, forbidBrokered = false) {
17
20
  for (const ref of refs) {
@@ -30,7 +33,10 @@ function checkRefs(label, refs, fail, forbidBrokered = false) {
30
33
  }
31
34
  }
32
35
  }
33
- /** 校验并原样返回插件清单;不合法抛 ExtensionManifestError。 */
36
+ /**
37
+ * Validates the plugin manifest and returns it unchanged; throws ExtensionManifestError when
38
+ * invalid.
39
+ */
34
40
  export function defineExtension(m) {
35
41
  const plugin = typeof m?.name === "string" && m.name !== "" ? m.name : "<unnamed>";
36
42
  const fail = (msg) => {
@@ -78,6 +84,7 @@ export function defineExtension(m) {
78
84
  if (errs.length > 0)
79
85
  fail(`invalid permissions: ${errs.join("; ")}`);
80
86
  }
87
+ // structural ui problems only; slot resolution never fails the extension (UI slots spec §3.2)
81
88
  const uiErrs = validateUiContributions(m.ui, m.permissions);
82
89
  if (uiErrs.length > 0)
83
90
  fail(`invalid ui: ${uiErrs.join("; ")}`);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Paths a local device never opens to restricted work (Request approval, Approve for me), relative
3
+ * to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
4
+ * Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, and the
5
+ * browser profile directories. One source for the device, which denies them (and its own state
6
+ * directory), and the kernel, which never proposes an approval for a path under one. Full access
7
+ * and auto mode run as the owner and do not apply them: the command review does.
8
+ */
9
+ export declare const DEVICE_DENIED_SECRET_PATHS: readonly string[];
10
+ /**
11
+ * The device program's default state directory (`$XDG_CONFIG_HOME/capybara-device` when that is
12
+ * set), relative to `~`: denied to restricted work like the secret paths.
13
+ */
14
+ export declare const DEVICE_DEFAULT_STATE_PATH = "~/.config/capybara-device";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Paths a local device never opens to restricted work (Request approval, Approve for me), relative
3
+ * to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
4
+ * Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, and the
5
+ * browser profile directories. One source for the device, which denies them (and its own state
6
+ * directory), and the kernel, which never proposes an approval for a path under one. Full access
7
+ * and auto mode run as the owner and do not apply them: the command review does.
8
+ */
9
+ export const DEVICE_DENIED_SECRET_PATHS = Object.freeze([
10
+ "~/.ssh",
11
+ "~/.aws",
12
+ "~/.config/gcloud",
13
+ "~/.azure",
14
+ "~/.kube",
15
+ "~/.docker/config.json",
16
+ "~/.netrc",
17
+ "~/.gnupg",
18
+ "~/Library/Application Support/Google/Chrome",
19
+ "~/Library/Application Support/Firefox",
20
+ "~/.mozilla",
21
+ "~/.config/google-chrome",
22
+ "~/.config/chromium",
23
+ // Ruling R19: more credential stores and browser data.
24
+ "~/.config/gh",
25
+ "~/.git-credentials",
26
+ "~/.npmrc",
27
+ "~/.pypirc",
28
+ "~/Library/Keychains",
29
+ "~/Library/Cookies",
30
+ "~/Library/Safari",
31
+ "~/Library/Application Support/BraveSoftware",
32
+ "~/Library/Application Support/Microsoft Edge",
33
+ "~/Library/Application Support/Arc",
34
+ "~/.config/BraveSoftware",
35
+ "~/.config/microsoft-edge",
36
+ ]);
37
+ /**
38
+ * The device program's default state directory (`$XDG_CONFIG_HOME/capybara-device` when that is
39
+ * set), relative to `~`: denied to restricted work like the secret paths.
40
+ */
41
+ export const DEVICE_DEFAULT_STATE_PATH = "~/.config/capybara-device";
@@ -0,0 +1,302 @@
1
+ import { type DeviceProvider, type ExecResult, type SandboxActor, type SandboxHandle } from "./device-provider.js";
2
+ /** The permission profile selected for a conversation. */
3
+ export type PermissionProfile = "request-approval" | "approve-for-me" | "full-access";
4
+ /** Accepts only the supported permission profile names. */
5
+ export declare function isPermissionProfile(value: unknown): value is PermissionProfile;
6
+ /** The provider cannot enforce the requested permission profile. */
7
+ export declare class SandboxPermissionUnsupportedError extends Error {
8
+ readonly sandboxPermissionUnsupported: true;
9
+ constructor(message: string, opts?: ErrorOptions);
10
+ }
11
+ /**
12
+ * Recognizes the inherited tag across SDK copies without requiring this class's identity, so every
13
+ * subclass counts too (for example {@link SandboxWorkUnsettledError}: the same definite refusal).
14
+ */
15
+ export declare function isSandboxPermissionUnsupportedError(e: unknown): e is SandboxPermissionUnsupportedError;
16
+ /**
17
+ * Earlier work on the device has not settled, so it refused to start a new operation. It extends
18
+ * {@link SandboxPermissionUnsupportedError} so every check that treats that error as a definite
19
+ * refusal (nothing ran) treats this one the same way.
20
+ */
21
+ export declare class SandboxWorkUnsettledError extends SandboxPermissionUnsupportedError {
22
+ readonly sandboxWorkUnsettled: true;
23
+ constructor(message: string, opts?: ErrorOptions);
24
+ }
25
+ /** Recognizes the name and tag across SDK copies without requiring this class's identity. */
26
+ export declare function isSandboxWorkUnsettledError(e: unknown): e is SandboxWorkUnsettledError;
27
+ /** The requested operation is outside the permitted scope. */
28
+ export declare class SandboxScopeDeniedError extends Error {
29
+ readonly sandboxScopeDenied: true;
30
+ constructor(message: string, opts?: ErrorOptions);
31
+ }
32
+ /** Recognizes the name and tag across SDK copies without requiring this class's identity. */
33
+ export declare function isSandboxScopeDeniedError(e: unknown): e is SandboxScopeDeniedError;
34
+ /** A scope or execution reference is malformed; validate it before performing any effects. */
35
+ export declare class SandboxScopeValidationError extends Error {
36
+ readonly sandboxScopeValidation: true;
37
+ constructor(message: string, opts?: ErrorOptions);
38
+ }
39
+ /** Recognizes validation errors across SDK copies. */
40
+ export declare function isSandboxScopeValidationError(e: unknown): e is SandboxScopeValidationError;
41
+ /** An operation was consumed but its outcome is unknown. Never automatically retry with a new ID. */
42
+ export declare class SandboxOperationOutcomeUnknownError extends Error {
43
+ readonly sandboxOperationOutcomeUnknown: true;
44
+ constructor(message: string, opts?: ErrorOptions);
45
+ }
46
+ /** Recognizes unknown outcomes across SDK copies; an unknown outcome is not a gone instance. */
47
+ export declare function isSandboxOperationOutcomeUnknownError(e: unknown): e is SandboxOperationOutcomeUnknownError;
48
+ /**
49
+ * A scoped operation names the project root (null in free mode) and the roots it may write; what
50
+ * it may read is the provider's rule. Writable roots are also readable. Device scope uses the
51
+ * device's OS authority, never its host's.
52
+ */
53
+ export type SandboxFileScope = {
54
+ readonly kind: "scoped";
55
+ readonly projectRoot: string | null;
56
+ readonly writeRoots: readonly string[];
57
+ } | {
58
+ readonly kind: "device";
59
+ };
60
+ /** Environment removes only the agent-specific filter; owner/org/provider ceilings still apply. */
61
+ export type SandboxNetworkScope = {
62
+ readonly kind: "none";
63
+ } | {
64
+ readonly kind: "allowlist";
65
+ readonly hosts: readonly string[];
66
+ }
67
+ /**
68
+ * The public internet, decided on the resolved address against `AddressClass`
69
+ * (`network-classes.ts`): every class in `OPEN_PUBLIC_DENIED_CLASSES` stays closed.
70
+ */
71
+ | {
72
+ readonly kind: "open-public";
73
+ }
74
+ /** Only with `filesystem: { kind: "device" }` (and the reverse): the escalated (outside) call. */
75
+ | {
76
+ readonly kind: "environment";
77
+ };
78
+ /** An operation locator for idempotent admission and revocation, never a credential. */
79
+ export interface SandboxOperationRef {
80
+ readonly operationId: string;
81
+ /** Absolute launch-admission deadline; does not shorten an already started execution's timeout. */
82
+ readonly admitBeforeMs: number;
83
+ }
84
+ /**
85
+ * A fresh grant for one method invocation. Providers must copy and freeze the input before use.
86
+ * Full access normally uses device/environment; explicit bounded grants may expand other profiles.
87
+ * Validation does not resolve authority or infer a grant from the profile name.
88
+ */
89
+ export interface SandboxOperationScope extends SandboxOperationRef {
90
+ readonly deviceId: string;
91
+ readonly rootConversationId: string;
92
+ readonly profileRevision: number;
93
+ readonly ceilingRevision: string;
94
+ readonly profile: PermissionProfile;
95
+ readonly actor: Readonly<SandboxActor>;
96
+ readonly tag: string;
97
+ readonly filesystem: SandboxFileScope;
98
+ readonly network: SandboxNetworkScope;
99
+ }
100
+ /**
101
+ * Where a provider's sandbox boundary lies: around each operation (the OS sandbox of a local device,
102
+ * the Linux per-operation runtime) or around the whole instance (a cloud container or microVM).
103
+ */
104
+ export type SandboxBoundary = "operation" | "instance";
105
+ /**
106
+ * Runtime support, version 2 (approval-only profiles design, "SDK and protocol"). `boundary:
107
+ * "instance"` with `restricted: null` is a supported device whose scope is the whole instance.
108
+ * `outsideSandbox` says whether a call can run outside the sandbox (an escalated call). Runtime
109
+ * support, not consent.
110
+ */
111
+ export interface SandboxPermissionSupport {
112
+ readonly version: 2;
113
+ readonly boundary: SandboxBoundary;
114
+ readonly restricted: {
115
+ readonly filesystem: true;
116
+ readonly network: true;
117
+ readonly native: true;
118
+ readonly concurrentScopes: true;
119
+ } | null;
120
+ readonly network: {
121
+ readonly openPublic: boolean;
122
+ readonly allowlist: boolean;
123
+ readonly perOperationHosts: boolean;
124
+ };
125
+ readonly outsideSandbox: boolean;
126
+ readonly background: boolean;
127
+ readonly unavailableReason?: string;
128
+ }
129
+ /**
130
+ * Whether a report is a supported instance boundary: `boundary: "instance"` with no
131
+ * `unavailableReason`. An instance report naming a reason (a stale image, a digest mismatch)
132
+ * claims nothing, so a device reporting it is unsupported, never the whole-instance sandbox.
133
+ */
134
+ export declare function instanceSupported(report: SandboxPermissionSupport): boolean;
135
+ /** Actor and tag come only from the immutable operation scope. */
136
+ export type SandboxExecOptions = Omit<Parameters<DeviceProvider["exec"]>[1], "tag" | "actor">;
137
+ /**
138
+ * A lightweight factory result: no worker opens until a method is called. Factory and method
139
+ * signals jointly end the operation. Every method consumes its operation ID before effects;
140
+ * a matching retry returns the recorded result or SandboxOperationOutcomeUnknownError, never
141
+ * repeats effects. Missing operation support has no fallback to the provider's raw methods.
142
+ * Native results and exec abort/timeout/output semantics match the existing provider contract.
143
+ */
144
+ export interface SandboxOperation {
145
+ exec(args: SandboxExecOptions): Promise<ExecResult>;
146
+ readFile(path: string, opts: {
147
+ maxBytes: number;
148
+ signal: AbortSignal;
149
+ }): Promise<{
150
+ data: Uint8Array;
151
+ truncated: boolean;
152
+ } | null>;
153
+ writeFile(path: string, data: Uint8Array, signal: AbortSignal): Promise<void>;
154
+ stat(path: string, signal: AbortSignal): Promise<{
155
+ size: number;
156
+ isDir: boolean;
157
+ } | null>;
158
+ /** List and scan are optional together; without both, projects are unavailable. */
159
+ list?(path: string, opts: {
160
+ limit: number;
161
+ signal: AbortSignal;
162
+ }): Promise<{
163
+ entries: {
164
+ name: string;
165
+ isDir: boolean;
166
+ }[];
167
+ truncated: boolean;
168
+ } | null>;
169
+ scan?(base: string, opts: {
170
+ signal: AbortSignal;
171
+ }): Promise<{
172
+ path: string;
173
+ suggestedName: string;
174
+ }[]>;
175
+ }
176
+ /** Trusted staging only: providers validate purpose-specific roots; user tools never supply this grant. */
177
+ export interface SandboxPreparationScope {
178
+ readonly operationId: string;
179
+ readonly deviceId: string;
180
+ readonly purpose: "skills" | "attachments";
181
+ readonly writeRoots: readonly string[];
182
+ readonly tag: string;
183
+ }
184
+ /** Marker reads and writes inside trusted preparation roots, with no exec or network capability. */
185
+ export type SandboxPreparation = Pick<SandboxOperation, "readFile" | "writeFile" | "stat">;
186
+ /** Owner-authenticated browsing, independent of a conversation or its profile/consent. */
187
+ export interface SandboxBrowseScope extends SandboxOperationRef {
188
+ readonly deviceId: string;
189
+ readonly accountId: string;
190
+ readonly ceilingRevision: string;
191
+ readonly readRoots: readonly string[];
192
+ readonly tag: string;
193
+ }
194
+ /** Browsing exposes metadata only: no file contents, writes, preparation or execution. */
195
+ export type SandboxBrowse = Pick<SandboxOperation, "stat"> & Required<Pick<SandboxOperation, "list" | "scan">>;
196
+ /** An opaque locator over authenticated transport; validate generation before status, tail or stop. */
197
+ export interface SandboxExecutionRef {
198
+ readonly executionId: string;
199
+ readonly operationId: string;
200
+ readonly instanceId: string;
201
+ readonly instanceGeneration: string;
202
+ }
203
+ /** A lost supervisor never binds this reference to a reused PID. */
204
+ export type SandboxExecutionStatus = {
205
+ state: "running";
206
+ } | {
207
+ state: "exited";
208
+ exitCode: number | null;
209
+ timedOut: boolean;
210
+ } | {
211
+ state: "lost";
212
+ };
213
+ /** Atomically claimed terminal outcome; retries preserve it, including a prior natural exit. */
214
+ export type SandboxStopResult = {
215
+ outcome: "already-exited";
216
+ exitCode: number | null;
217
+ timedOut: boolean;
218
+ } | {
219
+ outcome: "stopped";
220
+ } | {
221
+ outcome: "cancel-pending";
222
+ } | {
223
+ outcome: "lost";
224
+ };
225
+ /** Trusted exact-execution supervision. Status, tail and stop never provision or resume an instance. */
226
+ export interface SandboxBackground {
227
+ /**
228
+ * Persist exact ownership before acknowledging; retries of the same generation/operation/input
229
+ * return the same reference. Retain starting grants for the lifetime of the owned execution.
230
+ * Validate outputPath inside the scope. retainUntilMs bounds status/output record retention.
231
+ * instanceGeneration is the kernel's generation of the held instance `h` (the kernel always
232
+ * passes it, and allocates it only after `create` returns): a provider that keeps no generation
233
+ * of its own (a cloud provider) returns it in the reference and keys start idempotency by it.
234
+ */
235
+ start(h: SandboxHandle, scope: SandboxOperationScope, args: SandboxExecOptions & {
236
+ taskId: string;
237
+ outputPath: string;
238
+ retainUntilMs: number;
239
+ instanceGeneration?: string;
240
+ }): Promise<SandboxExecutionRef>;
241
+ status(h: SandboxHandle, ref: SandboxExecutionRef, signal: AbortSignal): Promise<SandboxExecutionStatus>;
242
+ /** At most 65,536 bytes, preserving UTF-8 boundaries and existing final-line limits; no caller path. */
243
+ tail(h: SandboxHandle, ref: SandboxExecutionRef, opts: {
244
+ maxBytes: number;
245
+ signal: AbortSignal;
246
+ }): Promise<{
247
+ data: Uint8Array;
248
+ truncated: boolean;
249
+ } | {
250
+ unavailable: "lost" | "expired";
251
+ }>;
252
+ /**
253
+ * Read retained raw merged-output bytes by exact reference, without a caller path, new scope,
254
+ * exec, provisioning or resume. Validate before I/O: offset is a nonnegative safe integer;
255
+ * maxBytes is an integer in [0, 65_536], including zero for a metadata-only probe. Invalid
256
+ * bounds throw SandboxScopeDeniedError. The byte budget includes any caller-requested overlap.
257
+ *
258
+ * totalBytes is one committed append-only prefix snapshot pinned at read admission. Return
259
+ * exactly min(maxBytes, max(totalBytes - offset, 0)) bytes starting at the requested offset,
260
+ * without UTF-8 trimming or decoding; retry short reads or report lost. nextOffset equals
261
+ * offset + data.byteLength. At/past the snapshot end, return empty data with unchanged offset.
262
+ * Reads are non-destructive and repeatable; concurrent appends cannot change returned bytes
263
+ * or this snapshot. Safe-integer position overflow fails collection rather than rounding.
264
+ *
265
+ * Missing/untrustworthy retained storage returns lost; a known expired record returns expired.
266
+ * Exact-ref/device/generation mismatches remain scope-denied errors; aborts propagate.
267
+ * Unlike tail, terminal reads retain every line. Current task access checks still apply.
268
+ */
269
+ readOutput(h: SandboxHandle, ref: SandboxExecutionRef, opts: {
270
+ offset: number;
271
+ maxBytes: number;
272
+ signal: AbortSignal;
273
+ }): Promise<{
274
+ data: Uint8Array;
275
+ offset: number;
276
+ nextOffset: number;
277
+ totalBytes: number;
278
+ } | {
279
+ unavailable: "lost" | "expired";
280
+ }>;
281
+ /** Persist pending cancellation while unreachable; apply it before an explicit resume can run work. */
282
+ stop(h: SandboxHandle, ref: SandboxExecutionRef, opts: {
283
+ graceMs: number;
284
+ signal: AbortSignal;
285
+ }): Promise<SandboxStopResult>;
286
+ }
287
+ /** Pure structural validation and a frozen copy; no clock lookup or authority resolution. */
288
+ export declare function parseSandboxOperationRef(value: unknown): SandboxOperationRef;
289
+ /**
290
+ * Validates a scope and returns a deeply frozen copy, throwing SandboxScopeValidationError.
291
+ * IDs and ceiling revisions are bounded to 128 characters; roots to 64 paths of at most 4096 characters;
292
+ * hosts to 100 entries passing validateAllowHost. Empty grants stay empty, including deny-all.
293
+ * Performs no I/O, authority lookup or deadline refresh. Unknown fields are rejected at every level.
294
+ * The `environment` network and the `device` filesystem are accepted only together.
295
+ */
296
+ export declare function parseSandboxOperationScope(value: unknown): SandboxOperationScope;
297
+ /** Validates an owner browsing grant and returns a deeply frozen copy; no conversation is required. */
298
+ export declare function parseSandboxBrowseScope(value: unknown): SandboxBrowseScope;
299
+ /** Validates trusted staging structure and returns a deeply frozen copy; does not authorize its roots. */
300
+ export declare function parseSandboxPreparationScope(value: unknown): SandboxPreparationScope;
301
+ /** Validates all four bounded locator fields and returns a frozen copy; does not authenticate the caller. */
302
+ export declare function parseSandboxExecutionRef(value: unknown): SandboxExecutionRef;