@paperclipai/plugin-sdk 2026.1106.0 → 2026.1107.0-canary.1
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/README.md +144 -11
- package/dist/.paperclip-build-complete +1 -1
- package/dist/environment-acquire-error.d.ts +19 -0
- package/dist/environment-acquire-error.d.ts.map +1 -0
- package/dist/environment-acquire-error.js +36 -0
- package/dist/environment-acquire-error.js.map +1 -0
- package/dist/environment-resume-error.d.ts +25 -0
- package/dist/environment-resume-error.d.ts.map +1 -0
- package/dist/environment-resume-error.js +50 -0
- package/dist/environment-resume-error.js.map +1 -0
- package/dist/environment-runner-ingress-error.d.ts +13 -0
- package/dist/environment-runner-ingress-error.d.ts.map +1 -0
- package/dist/environment-runner-ingress-error.js +39 -0
- package/dist/environment-runner-ingress-error.js.map +1 -0
- package/dist/environment-stop-error.d.ts +14 -0
- package/dist/environment-stop-error.d.ts.map +1 -0
- package/dist/environment-stop-error.js +44 -0
- package/dist/environment-stop-error.js.map +1 -0
- package/dist/environment-sync-error.js +1 -1
- package/dist/environment-sync-error.js.map +1 -1
- package/dist/environment-task-error.d.ts +25 -0
- package/dist/environment-task-error.d.ts.map +1 -0
- package/dist/environment-task-error.js +73 -0
- package/dist/environment-task-error.js.map +1 -0
- package/dist/environment-tasks.d.ts +93 -2
- package/dist/environment-tasks.d.ts.map +1 -1
- package/dist/environment-tasks.js +44 -3
- package/dist/environment-tasks.js.map +1 -1
- package/dist/host-client-factory.d.ts +2 -0
- package/dist/host-client-factory.d.ts.map +1 -1
- package/dist/host-client-factory.js +19 -2
- package/dist/host-client-factory.js.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/invocation-tracer.d.ts +10 -0
- package/dist/invocation-tracer.d.ts.map +1 -0
- package/dist/invocation-tracer.js +61 -0
- package/dist/invocation-tracer.js.map +1 -0
- package/dist/protocol.d.ts +73 -24
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/testing.d.ts +5 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +8 -0
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +29 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/worker-rpc-host.d.ts.map +1 -1
- package/dist/worker-rpc-host.js +57 -16
- package/dist/worker-rpc-host.js.map +1 -1
- package/dist/workspace-operation-error.d.ts +46 -0
- package/dist/workspace-operation-error.d.ts.map +1 -0
- package/dist/workspace-operation-error.js +78 -0
- package/dist/workspace-operation-error.js.map +1 -0
- package/dist/workspace-provider.d.ts +47 -1
- package/dist/workspace-provider.d.ts.map +1 -1
- package/dist/workspace-provider.js +16 -1
- package/dist/workspace-provider.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -52,6 +52,36 @@ The SDK is stable enough for local development and first-party examples, but the
|
|
|
52
52
|
|
|
53
53
|
If you are authoring a plugin for others to deploy, treat npm-packaged installation as the supported path and treat repo-local example installs as a development convenience.
|
|
54
54
|
|
|
55
|
+
## Runner ingress failures
|
|
56
|
+
|
|
57
|
+
Environment providers can throw `PluginEnvironmentRunnerIngressError` from
|
|
58
|
+
`onEnvironmentRunnerIngressEndpoint` with a validated SDK HTTP status and one
|
|
59
|
+
closed phase: `sandbox_lookup`, `sandbox_start`, `sandbox_refresh` or
|
|
60
|
+
`private_preview`. The worker forwards only this closed status/phase envelope.
|
|
61
|
+
It omits response bodies, URLs, headers and causes. The host independently
|
|
62
|
+
validates it with `readEnvironmentRunnerIngressFailure`. Do not derive a status
|
|
63
|
+
from error text. Unknown and configuration failures keep their normal errors.
|
|
64
|
+
The envelope alone grants no retry, accounting or cleanup authority; native
|
|
65
|
+
execution also requires its complete, current controller checkpoint proof.
|
|
66
|
+
|
|
67
|
+
## Stop failures
|
|
68
|
+
|
|
69
|
+
Environment providers can throw `PluginEnvironmentStopError` from
|
|
70
|
+
`onEnvironmentStopLease` when they cannot stop a resource that is in a provider
|
|
71
|
+
error state. The error takes one closed reason:
|
|
72
|
+
|
|
73
|
+
- `resource_unrecoverable`: the provider reports that the resource cannot recover.
|
|
74
|
+
- `recovery_failed`: the resource is in an error state again after one recovery attempt.
|
|
75
|
+
- `recovery_incomplete`: recovery did not finish before the stop deadline.
|
|
76
|
+
|
|
77
|
+
The worker forwards only the reason. It omits messages, provider error text and
|
|
78
|
+
causes. The host reads it with `readEnvironmentStopFailure`, which derives the
|
|
79
|
+
`terminal` flag from the reason. The first two reasons are terminal: another
|
|
80
|
+
automatic attempt cannot succeed without provider or operator action. The host
|
|
81
|
+
escalates a terminal failure at once and retries it at its slowest cleanup
|
|
82
|
+
interval. It never abandons the pending cleanup. Other stop errors keep their
|
|
83
|
+
normal retry behavior.
|
|
84
|
+
|
|
55
85
|
## Worker quick start
|
|
56
86
|
|
|
57
87
|
```ts
|
|
@@ -259,6 +289,77 @@ A card or section rendered on the main dashboard. Use this for at-a-glance metri
|
|
|
259
289
|
|
|
260
290
|
An additional tab on a project, issue, agent, goal, or run detail page. Rendered when the user navigates to that entity's detail view. Receives `PluginDetailTabProps` with `context.companyId` set to the active company and `context.entityId` / `context.entityType` guaranteed to be non-null, so you can immediately scope data fetches to the relevant entity. Specify which entity types the tab applies to via the `entityTypes` array in the manifest slot declaration. Requires the `ui.detailTab.register` capability.
|
|
261
291
|
|
|
292
|
+
Agent detail tabs can also appear in task side panels. `taskSidePanel` makes the
|
|
293
|
+
view available for manual selection with the running or assigned agent. Manual
|
|
294
|
+
selection mounts the same component as the agent detail page, including while
|
|
295
|
+
the task is idle. An optional activity mapping also opens it automatically:
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
taskSidePanel: {
|
|
299
|
+
availabilityPath: "/agents/:entityId/view/availability",
|
|
300
|
+
activation: { namespace: "example.runtime", activityKey: "desktop.used" },
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Declare the exact availability path as a board-only GET API route with
|
|
305
|
+
`companyResolution: { from: "agent", param: "entityId" }`. Core maps the declared
|
|
306
|
+
namespace/activity pair to installed agent detail tabs. Runner knows no plugin
|
|
307
|
+
or UI slot. Declarations without `activation` support manual task-panel selection.
|
|
308
|
+
Activity controls automatic opening and grants no access permission.
|
|
309
|
+
|
|
310
|
+
#### Runtime activity recording
|
|
311
|
+
|
|
312
|
+
A runtime client captures Runner's opaque activity context before an eligible
|
|
313
|
+
operation, then sends a structured notification after successful use:
|
|
314
|
+
|
|
315
|
+
```sh
|
|
316
|
+
context=$("$PAPERCLIP_RUNTIME_NOTIFICATION_HELPER" notification-context)
|
|
317
|
+
# Perform the operation; notify only on success.
|
|
318
|
+
"$PAPERCLIP_RUNTIME_NOTIFICATION_HELPER" record-activity "$context" example.runtime desktop.used
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Runner supplies the matching absolute executable as
|
|
322
|
+
`PAPERCLIP_RUNTIME_NOTIFICATION_HELPER` and an atomic endpoint descriptor as
|
|
323
|
+
`PAPERCLIP_RUNTIME_NOTIFICATION_CONTEXT`. Configured task environment cannot
|
|
324
|
+
override them. Provider launch boundaries preserve both values. Codex receives
|
|
325
|
+
read access to the helper, descriptor and publisher lock, plus write access to
|
|
326
|
+
one named pipe. The pipe and lock live in a private temporary directory, outside
|
|
327
|
+
durable Runner state. The enclosing directories remain protected.
|
|
328
|
+
|
|
329
|
+
The helper captures context locally. After success, it publishes newline-delimited
|
|
330
|
+
JSON through a nonblocking pipe. A leading newline terminates an interrupted
|
|
331
|
+
previous write. A read-only file lock serializes publishers with a 500 ms deadline.
|
|
332
|
+
Runner reuses its bounded line reader: 2 KiB per record, 128 queued records and
|
|
333
|
+
16 records per control-loop iteration. Idle transport blocks; cleanup removes
|
|
334
|
+
only its pipe, lock and empty private directory.
|
|
335
|
+
|
|
336
|
+
A successful helper exit means publication to the pipe. Runner validates context
|
|
337
|
+
against the active run, deduplicates up to 128 activity pairs per authority, and
|
|
338
|
+
persists `runtime.activity.recorded` through its authenticated event stream.
|
|
339
|
+
Warm attachment and process recovery rotate context. The helper accepts no run
|
|
340
|
+
identity. Clients treat this hint as best effort, including with older runtimes.
|
|
341
|
+
Notify only after successful use; exclude help, schema discovery, status probes
|
|
342
|
+
and failures. No agent instruction is required.
|
|
343
|
+
|
|
344
|
+
Identifiers are 1–160 Unicode code points, excluding C0 controls and DEL.
|
|
345
|
+
Core maps declared activity identifiers to its consumers and applies their
|
|
346
|
+
existing discovery, authorization and availability checks.
|
|
347
|
+
|
|
348
|
+
Core reads durable activity on mount/reconnect and uses the existing live stream.
|
|
349
|
+
The authorized run binding identifies company, task and agent; caller payloads
|
|
350
|
+
cannot override them. Core replaces `:entityId` with the running agent ID, adds
|
|
351
|
+
`runId` and `issueId`, and requires `{ available: true }`. History/live hints merge
|
|
352
|
+
without losing earlier activity. Only matching current-task activity can open a
|
|
353
|
+
panel automatically.
|
|
354
|
+
Readiness and transient discovery failures get at most three attempts; authorization
|
|
355
|
+
failures are not retried. No periodic readiness polling is added. Dismissal stays
|
|
356
|
+
scoped to the current run. Only tab identity is stored in browser state; activity
|
|
357
|
+
remains in the authorized run log. Failed history reads, unavailable views and
|
|
358
|
+
access failures prevent automatic opening. Manual selection uses the viewer's
|
|
359
|
+
own authorization and status handling. Missing or disabled plugins add no view.
|
|
360
|
+
The plugin owns labels, content and controls. No private integration identifier
|
|
361
|
+
belongs in Core.
|
|
362
|
+
|
|
262
363
|
#### `taskDetailView`
|
|
263
364
|
|
|
264
365
|
A specialized slot rendered in the context of a task or issue detail view. Similar to `detailTab` but designed for inline content within the task detail layout rather than a separate tab. Receives `context.companyId`, `context.entityId`, and `context.entityType` like `detailTab`. Requires the `ui.detailTab.register` capability.
|
|
@@ -1315,10 +1416,10 @@ implement `onResourceLifecycle` and `onWorkspaceOperation`. Project lifecycle
|
|
|
1315
1416
|
creates and retains the storage; workspace operations manage task checkouts in
|
|
1316
1417
|
that storage. Execution remains a separate environment driver contract.
|
|
1317
1418
|
|
|
1318
|
-
|
|
1319
|
-
plugin's UUID
|
|
1320
|
-
|
|
1321
|
-
that default by declaring, for example:
|
|
1419
|
+
`project.executionWorkspacePolicy.storageProviderPluginId` holds a project's storage:
|
|
1420
|
+
an installed plugin's UUID, or `null` or no value for Core/local storage. Core
|
|
1421
|
+
applies the installed company-enabled default once, when it creates the project. A
|
|
1422
|
+
provider claims that default by declaring, for example:
|
|
1322
1423
|
|
|
1323
1424
|
```ts
|
|
1324
1425
|
workspaceProvider: {
|
|
@@ -1328,13 +1429,16 @@ workspaceProvider: {
|
|
|
1328
1429
|
}
|
|
1329
1430
|
```
|
|
1330
1431
|
|
|
1331
|
-
The declared defaults must be supported by the provider.
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1432
|
+
The declared defaults must be supported by the provider. Installing a provider
|
|
1433
|
+
does not change existing projects. A Core/local project can move to a provider, and
|
|
1434
|
+
a plugin-backed project stays attached to that plugin: requests to change it fail,
|
|
1435
|
+
and it never falls back to local storage. Core applies missing mode and strategy
|
|
1436
|
+
settings without writing them. Explicit settings remain intact; incompatible
|
|
1437
|
+
settings fail with a configuration error. If more than one enabled provider claims
|
|
1438
|
+
the default, creating a project needs an explicit choice. Core sends a provider
|
|
1439
|
+
project lifecycle events only for projects attached to it, and acknowledges the
|
|
1440
|
+
others on its behalf. No company settings row means enabled, matching the normal
|
|
1441
|
+
plugin contract.
|
|
1338
1442
|
|
|
1339
1443
|
New and imported tasks leave an unspecified project mode inherited. Provider-owned
|
|
1340
1444
|
workspaces retain explicit project and task strategies in shared and operator-branch
|
|
@@ -1432,3 +1536,32 @@ lifecycle inbox listings or the company secret catalog. Do not expose values
|
|
|
1432
1536
|
through plugin entities, state, data handlers, UI, or logs. Agent instance
|
|
1433
1537
|
secrets retain their existing lifecycle contract. Back up the tenant's existing
|
|
1434
1538
|
local secrets master key together with its database.
|
|
1539
|
+
|
|
1540
|
+
### Project Git credentials
|
|
1541
|
+
|
|
1542
|
+
Trusted workspace providers can declare `projects.git-credentials` and call
|
|
1543
|
+
`ctx.projects.resolveGitCredential(projectId, workspaceId, companyId)` from the
|
|
1544
|
+
matching host-issued project lifecycle or workspace operation. Other invocations
|
|
1545
|
+
cannot obtain credentials through this method. The workspace must be a current
|
|
1546
|
+
repository in that project and company; plugins cannot supply arbitrary URLs.
|
|
1547
|
+
|
|
1548
|
+
Background work uses a project writer's explicit consent to their own personal,
|
|
1549
|
+
company-installed GitHub Connector grant. It does not retain task context. Core
|
|
1550
|
+
checks the exact grant and its owner's active company membership on every use.
|
|
1551
|
+
Foreground preparation uses the active run's identity and trust policy instead.
|
|
1552
|
+
Public repositories return null and require no connection. Private repositories
|
|
1553
|
+
without authorization wait before provisioning. Repository visibility comes from
|
|
1554
|
+
the Connector catalog and retained project selections; legacy URL-only sources
|
|
1555
|
+
use anonymous discovery when visibility is unknown. A revoked or invalid private
|
|
1556
|
+
repository authorization fails closed. There is no fallback to another grant.
|
|
1557
|
+
Project consent follows the connection's current repository access, including
|
|
1558
|
+
sources added later, rather than a separate project repository approval list.
|
|
1559
|
+
The consenting user must retain project read access, and background credential
|
|
1560
|
+
export requires the project's existing trust policy to allow standard execution.
|
|
1561
|
+
Archived projects keep credential access only for host-issued workspace inspection
|
|
1562
|
+
and removal with existing consent; provisioning remains blocked.
|
|
1563
|
+
|
|
1564
|
+
The return value is transient raw credential material with the Connector's
|
|
1565
|
+
existing permissions. This capability is for trusted execution infrastructure,
|
|
1566
|
+
not agent-facing tools or UI. Never expose or persist it. See
|
|
1567
|
+
[GitHub identity](../../../doc/execution-github-identity.md#project-authorization-for-background-repository-work).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"sources":"
|
|
1
|
+
{"sources":"c13463824c69a908786b042228ed0bf13461f2efcd17a23c81c8e1d77179f110","outputs":"cf006cd8eb15cada779b27b2d49ad8311b3bf686ccceef593217243fc6910d90"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PluginEnvironmentResumeErrorDiagnostic } from "./environment-resume-error.js";
|
|
2
|
+
/**
|
|
3
|
+
* Diagnostic evidence for a refused `environmentAcquireLease`: the provider's
|
|
4
|
+
* HTTP status or a closed errno code. It crosses the worker RPC boundary as
|
|
5
|
+
* structured error data because a JSON-RPC error carries only a message and a
|
|
6
|
+
* numeric RPC code. Provider text and identifiers never cross. The host uses it
|
|
7
|
+
* only to decide whether a bounded retry is worthwhile; ownership of any
|
|
8
|
+
* provisional allocation stays with the creation-cleanup envelope.
|
|
9
|
+
*/
|
|
10
|
+
export type PluginEnvironmentAcquireErrorDiagnostic = PluginEnvironmentResumeErrorDiagnostic;
|
|
11
|
+
/**
|
|
12
|
+
* Worker side: the RPC error data for a failed acquisition. A creation whose
|
|
13
|
+
* cleanup could not be confirmed keeps its ownership envelope and adds the
|
|
14
|
+
* status of the create call only, never of the compensating lookup or delete.
|
|
15
|
+
*/
|
|
16
|
+
export declare function environmentAcquireErrorData(error: unknown): unknown;
|
|
17
|
+
/** Host side: read and re-validate the provider diagnostic from an RPC error. */
|
|
18
|
+
export declare function readEnvironmentAcquireErrorDiagnostic(error: unknown): PluginEnvironmentAcquireErrorDiagnostic | null;
|
|
19
|
+
//# sourceMappingURL=environment-acquire-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-acquire-error.d.ts","sourceRoot":"","sources":["../src/environment-acquire-error.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,sCAAsC,EAC5C,MAAM,+BAA+B,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,uCAAuC,GAAG,sCAAsC,CAAC;AAU7F;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQnE;AAED,iFAAiF;AACjF,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,uCAAuC,GAAG,IAAI,CAMpH"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PluginEnvironmentCreationCleanupError, environmentCreationCleanupErrorData } from "./environment-creation-cleanup.js";
|
|
2
|
+
import { providerErrorDiagnostic, sanitizeProviderErrorDiagnostic, } from "./environment-resume-error.js";
|
|
3
|
+
const SCHEMA = "paperclip/environment-acquire-error/v1";
|
|
4
|
+
const CLEANUP_SCHEMA = "paperclip/environment-creation-cleanup/v1";
|
|
5
|
+
function field(value, key) {
|
|
6
|
+
try {
|
|
7
|
+
return value && typeof value === "object" ? value[key] : undefined;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Worker side: the RPC error data for a failed acquisition. A creation whose
|
|
15
|
+
* cleanup could not be confirmed keeps its ownership envelope and adds the
|
|
16
|
+
* status of the create call only, never of the compensating lookup or delete.
|
|
17
|
+
*/
|
|
18
|
+
export function environmentAcquireErrorData(error) {
|
|
19
|
+
const createError = error instanceof PluginEnvironmentCreationCleanupError ? error.errors[0] : error;
|
|
20
|
+
const providerDiagnostic = providerErrorDiagnostic(createError);
|
|
21
|
+
const cleanup = environmentCreationCleanupErrorData(error, true);
|
|
22
|
+
if (cleanup && typeof cleanup === "object") {
|
|
23
|
+
return providerDiagnostic ? { ...cleanup, providerDiagnostic } : cleanup;
|
|
24
|
+
}
|
|
25
|
+
return providerDiagnostic ? { schema: SCHEMA, providerDiagnostic } : undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Host side: read and re-validate the provider diagnostic from an RPC error. */
|
|
28
|
+
export function readEnvironmentAcquireErrorDiagnostic(error) {
|
|
29
|
+
const data = field(error, "data");
|
|
30
|
+
const schema = field(data, "schema");
|
|
31
|
+
if (schema !== SCHEMA && schema !== CLEANUP_SCHEMA)
|
|
32
|
+
return null;
|
|
33
|
+
const diagnostic = field(data, "providerDiagnostic");
|
|
34
|
+
return sanitizeProviderErrorDiagnostic({ httpStatus: field(diagnostic, "httpStatus"), errorCode: field(diagnostic, "errorCode") });
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=environment-acquire-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-acquire-error.js","sourceRoot":"","sources":["../src/environment-acquire-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,mCAAmC,EAAE,MAAM,mCAAmC,CAAC;AAC/H,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAEhC,MAAM,+BAA+B,CAAC;AAYvC,MAAM,MAAM,GAAG,wCAAwC,CAAC;AACxD,MAAM,cAAc,GAAG,2CAA2C,CAAC;AAEnE,SAAS,KAAK,CAAC,KAAc,EAAE,GAAW;IACxC,IAAI,CAAC;QAAC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAAC,CAAC;IACxG,MAAM,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACxD,MAAM,WAAW,GAAG,KAAK,YAAY,qCAAqC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACrG,MAAM,kBAAkB,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,mCAAmC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACjE,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAC3E,CAAC;IACD,OAAO,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,qCAAqC,CAAC,KAAc;IAClE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrC,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,cAAc;QAAE,OAAO,IAAI,CAAC;IAChE,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACrD,OAAO,+BAA+B,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;AACrI,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostic evidence for a refused `environmentResumeLease`. It crosses the
|
|
3
|
+
* worker RPC boundary as structured error data, because the JSON-RPC error
|
|
4
|
+
* carries only a message and a numeric RPC code. Never use it to authorize
|
|
5
|
+
* replacement or cleanup: a refusal does not prove that a sandbox is lost.
|
|
6
|
+
*/
|
|
7
|
+
export interface PluginEnvironmentResumeErrorDiagnostic {
|
|
8
|
+
httpStatus?: number;
|
|
9
|
+
errorCode?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Shared with the acquisition envelope: the same closed status/errno fields. */
|
|
12
|
+
export declare function sanitizeProviderErrorDiagnostic(input: {
|
|
13
|
+
httpStatus?: unknown;
|
|
14
|
+
errorCode?: unknown;
|
|
15
|
+
}): PluginEnvironmentResumeErrorDiagnostic | null;
|
|
16
|
+
/** Derive the closed status/errno fields from a thrown provider error and its causes. */
|
|
17
|
+
export declare function providerErrorDiagnostic(error: unknown): PluginEnvironmentResumeErrorDiagnostic | null;
|
|
18
|
+
/** Worker side: derive safe fields from a thrown provider error and its causes. */
|
|
19
|
+
export declare function environmentResumeErrorData(error: unknown): {
|
|
20
|
+
schema: string;
|
|
21
|
+
diagnostic: PluginEnvironmentResumeErrorDiagnostic;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/** Host side: read and re-validate the envelope from an RPC error. */
|
|
24
|
+
export declare function readEnvironmentResumeErrorDiagnostic(error: unknown): PluginEnvironmentResumeErrorDiagnostic | null;
|
|
25
|
+
//# sourceMappingURL=environment-resume-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-resume-error.d.ts","sourceRoot":"","sources":["../src/environment-resume-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,sCAAsC;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAcD,iFAAiF;AACjF,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,sCAAsC,GAAG,IAAI,CAMnJ;AAED,yFAAyF;AACzF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,sCAAsC,GAAG,IAAI,CAUrG;AAED,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,sCAAsC,CAAA;CAAE,GAAG,SAAS,CAG7I;AAED,sEAAsE;AACtE,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,OAAO,GAAG,sCAAsC,GAAG,IAAI,CAKlH"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const SCHEMA = "paperclip/environment-resume-error/v1";
|
|
2
|
+
// Closed errno-style set. Provider text and identifiers never cross.
|
|
3
|
+
const ERROR_CODES = new Set([
|
|
4
|
+
"ECONNRESET", "ECONNREFUSED", "ETIMEDOUT", "EPIPE", "ENOTFOUND", "EAI_AGAIN", "ENETUNREACH",
|
|
5
|
+
"ABORT_ERR", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_SOCKET",
|
|
6
|
+
]);
|
|
7
|
+
function field(value, key) {
|
|
8
|
+
try {
|
|
9
|
+
return value && typeof value === "object" ? value[key] : undefined;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Shared with the acquisition envelope: the same closed status/errno fields. */
|
|
16
|
+
export function sanitizeProviderErrorDiagnostic(input) {
|
|
17
|
+
const httpStatus = Number.isInteger(input.httpStatus) && input.httpStatus >= 100 && input.httpStatus <= 599
|
|
18
|
+
? input.httpStatus : undefined;
|
|
19
|
+
const errorCode = typeof input.errorCode === "string" && ERROR_CODES.has(input.errorCode) ? input.errorCode : undefined;
|
|
20
|
+
if (httpStatus === undefined && errorCode === undefined)
|
|
21
|
+
return null;
|
|
22
|
+
return { ...(httpStatus !== undefined ? { httpStatus } : {}), ...(errorCode !== undefined ? { errorCode } : {}) };
|
|
23
|
+
}
|
|
24
|
+
/** Derive the closed status/errno fields from a thrown provider error and its causes. */
|
|
25
|
+
export function providerErrorDiagnostic(error) {
|
|
26
|
+
let httpStatus;
|
|
27
|
+
let errorCode;
|
|
28
|
+
for (let cause = error, depth = 0; cause && depth < 4; cause = field(cause, "cause"), depth++) {
|
|
29
|
+
httpStatus ??= [field(cause, "status"), field(cause, "statusCode"), field(field(cause, "response"), "status")]
|
|
30
|
+
.find(value => Number.isInteger(value));
|
|
31
|
+
const code = field(cause, "code");
|
|
32
|
+
if (errorCode === undefined && typeof code === "string" && ERROR_CODES.has(code))
|
|
33
|
+
errorCode = code;
|
|
34
|
+
}
|
|
35
|
+
return sanitizeProviderErrorDiagnostic({ httpStatus, errorCode });
|
|
36
|
+
}
|
|
37
|
+
/** Worker side: derive safe fields from a thrown provider error and its causes. */
|
|
38
|
+
export function environmentResumeErrorData(error) {
|
|
39
|
+
const diagnostic = providerErrorDiagnostic(error);
|
|
40
|
+
return diagnostic ? { schema: SCHEMA, diagnostic } : undefined;
|
|
41
|
+
}
|
|
42
|
+
/** Host side: read and re-validate the envelope from an RPC error. */
|
|
43
|
+
export function readEnvironmentResumeErrorDiagnostic(error) {
|
|
44
|
+
const data = field(error, "data");
|
|
45
|
+
if (field(data, "schema") !== SCHEMA)
|
|
46
|
+
return null;
|
|
47
|
+
const diagnostic = field(data, "diagnostic");
|
|
48
|
+
return sanitizeProviderErrorDiagnostic({ httpStatus: field(diagnostic, "httpStatus"), errorCode: field(diagnostic, "errorCode") });
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=environment-resume-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-resume-error.js","sourceRoot":"","sources":["../src/environment-resume-error.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,GAAG,uCAAuC,CAAC;AACvD,qEAAqE;AACrE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa;IAC3F,WAAW,EAAE,yBAAyB,EAAE,gBAAgB;CACzD,CAAC,CAAC;AAEH,SAAS,KAAK,CAAC,KAAc,EAAE,GAAW;IACxC,IAAI,CAAC;QAAC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAAC,CAAC;IACxG,MAAM,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;AAC7B,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,+BAA+B,CAAC,KAAoD;IAClG,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,IAAK,KAAK,CAAC,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,MAAM,CAAC,CAAC;QAClC,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS,GAAG,IAAI,CAAC;IACrG,CAAC;IACD,OAAO,+BAA+B,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACvD,MAAM,UAAU,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAClD,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,oCAAoC,CAAC,KAAc;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAClD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC7C,OAAO,+BAA+B,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;AACrI,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const PHASES: readonly ["sandbox_lookup", "sandbox_start", "sandbox_refresh", "private_preview"];
|
|
2
|
+
export interface PluginEnvironmentRunnerIngressFailure {
|
|
3
|
+
phase: typeof PHASES[number];
|
|
4
|
+
httpStatus: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class PluginEnvironmentRunnerIngressError extends Error {
|
|
7
|
+
readonly failure: PluginEnvironmentRunnerIngressFailure | null;
|
|
8
|
+
constructor(failure: PluginEnvironmentRunnerIngressFailure);
|
|
9
|
+
}
|
|
10
|
+
export declare function environmentRunnerIngressErrorData(error: unknown): unknown;
|
|
11
|
+
export declare function readEnvironmentRunnerIngressFailure(error: unknown): PluginEnvironmentRunnerIngressFailure | null;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=environment-runner-ingress-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-runner-ingress-error.d.ts","sourceRoot":"","sources":["../src/environment-runner-ingress-error.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,YAAI,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,CAAU,CAAC;AAElG,MAAM,WAAW,qCAAqC;IACpD,KAAK,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAeD,qBAAa,mCAAoC,SAAQ,KAAK;IAC5D,QAAQ,CAAC,OAAO,EAAE,qCAAqC,GAAG,IAAI,CAAC;IAE/D,YAAY,OAAO,EAAE,qCAAqC,EAKzD;CACF;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIzE;AAED,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,OAAO,GAAG,qCAAqC,GAAG,IAAI,CAGhH"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const SCHEMA = "paperclip/environment-runner-ingress-error/v1";
|
|
2
|
+
const PHASES = ["sandbox_lookup", "sandbox_start", "sandbox_refresh", "private_preview"];
|
|
3
|
+
function field(value, name) {
|
|
4
|
+
if (!value || typeof value !== "object")
|
|
5
|
+
return undefined;
|
|
6
|
+
try {
|
|
7
|
+
return Object.getOwnPropertyDescriptor(value, name)?.value;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function validate(value) {
|
|
14
|
+
const phase = field(value, "phase"), httpStatus = field(value, "httpStatus");
|
|
15
|
+
if (!PHASES.includes(phase)
|
|
16
|
+
|| typeof httpStatus !== "number" || !Number.isInteger(httpStatus) || httpStatus < 400 || httpStatus > 599)
|
|
17
|
+
return null;
|
|
18
|
+
return { phase: phase, httpStatus };
|
|
19
|
+
}
|
|
20
|
+
export class PluginEnvironmentRunnerIngressError extends Error {
|
|
21
|
+
failure;
|
|
22
|
+
constructor(failure) {
|
|
23
|
+
const safe = validate(failure);
|
|
24
|
+
super(`Runner connection endpoint could not be acquired${safe ? ` (HTTP ${safe.httpStatus})` : ""}.`);
|
|
25
|
+
this.name = "PluginEnvironmentRunnerIngressError";
|
|
26
|
+
this.failure = safe;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function environmentRunnerIngressErrorData(error) {
|
|
30
|
+
if (!(error instanceof PluginEnvironmentRunnerIngressError))
|
|
31
|
+
return undefined;
|
|
32
|
+
const failure = validate(field(error, "failure"));
|
|
33
|
+
return failure ? { schema: SCHEMA, failure } : undefined;
|
|
34
|
+
}
|
|
35
|
+
export function readEnvironmentRunnerIngressFailure(error) {
|
|
36
|
+
const data = field(error, "data");
|
|
37
|
+
return field(data, "schema") === SCHEMA ? validate(field(data, "failure")) : null;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=environment-runner-ingress-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-runner-ingress-error.js","sourceRoot":"","sources":["../src/environment-runner-ingress-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,+CAA+C,CAAC;AAC/D,MAAM,MAAM,GAAG,CAAC,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,CAAU,CAAC;AAOlG,SAAS,KAAK,CAAC,KAAc,EAAE,IAAY;IACzC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,IAAI,CAAC;QAAC,OAAO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AC,CAAC,SAAS,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,KAAc;IAChE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const REASONS: readonly ["resource_unrecoverable", "recovery_failed", "recovery_incomplete"];
|
|
2
|
+
export type PluginEnvironmentStopFailureReason = typeof REASONS[number];
|
|
3
|
+
export interface PluginEnvironmentStopFailure {
|
|
4
|
+
reason: PluginEnvironmentStopFailureReason;
|
|
5
|
+
terminal: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class PluginEnvironmentStopError extends Error {
|
|
8
|
+
readonly failure: PluginEnvironmentStopFailure | null;
|
|
9
|
+
constructor(reason: PluginEnvironmentStopFailureReason);
|
|
10
|
+
}
|
|
11
|
+
export declare function environmentStopErrorData(error: unknown): unknown;
|
|
12
|
+
export declare function readEnvironmentStopFailure(error: unknown): PluginEnvironmentStopFailure | null;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=environment-stop-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-stop-error.d.ts","sourceRoot":"","sources":["../src/environment-stop-error.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,OAAO,YAAI,wBAAwB,EAAE,iBAAiB,EAAE,qBAAqB,CAAU,CAAC;AAG9F,MAAM,MAAM,kCAAkC,GAAG,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AAExE,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,kCAAkC,CAAC;IAC3C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAoBD,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAEtD,YAAY,MAAM,EAAE,kCAAkC,EAKrD;CACF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIhE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,4BAA4B,GAAG,IAAI,CAG9F"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const SCHEMA = "paperclip/environment-stop-error/v1";
|
|
2
|
+
const REASONS = ["resource_unrecoverable", "recovery_failed", "recovery_incomplete"];
|
|
3
|
+
const TERMINAL_REASONS = new Set(["resource_unrecoverable", "recovery_failed"]);
|
|
4
|
+
const MESSAGES = {
|
|
5
|
+
resource_unrecoverable: "The provider reports that the environment resource cannot recover from its error state, so it cannot be stopped.",
|
|
6
|
+
recovery_failed: "The environment resource returned to an error state after a recovery attempt, so it cannot be stopped.",
|
|
7
|
+
recovery_incomplete: "The environment resource did not finish recovery from its error state before the stop deadline.",
|
|
8
|
+
};
|
|
9
|
+
function field(value, name) {
|
|
10
|
+
if (!value || typeof value !== "object")
|
|
11
|
+
return undefined;
|
|
12
|
+
try {
|
|
13
|
+
return Object.getOwnPropertyDescriptor(value, name)?.value;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function validate(value) {
|
|
20
|
+
const reason = field(value, "reason");
|
|
21
|
+
if (!REASONS.includes(reason))
|
|
22
|
+
return null;
|
|
23
|
+
return { reason: reason, terminal: TERMINAL_REASONS.has(reason) };
|
|
24
|
+
}
|
|
25
|
+
export class PluginEnvironmentStopError extends Error {
|
|
26
|
+
failure;
|
|
27
|
+
constructor(reason) {
|
|
28
|
+
const failure = validate({ reason });
|
|
29
|
+
super(failure ? MESSAGES[failure.reason] : "The environment resource could not be stopped.");
|
|
30
|
+
this.name = "PluginEnvironmentStopError";
|
|
31
|
+
this.failure = failure;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function environmentStopErrorData(error) {
|
|
35
|
+
if (!(error instanceof PluginEnvironmentStopError))
|
|
36
|
+
return undefined;
|
|
37
|
+
const failure = validate(field(error, "failure"));
|
|
38
|
+
return failure ? { schema: SCHEMA, failure: { reason: failure.reason } } : undefined;
|
|
39
|
+
}
|
|
40
|
+
export function readEnvironmentStopFailure(error) {
|
|
41
|
+
const data = field(error, "data");
|
|
42
|
+
return field(data, "schema") === SCHEMA ? validate(field(data, "failure")) : null;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=environment-stop-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-stop-error.js","sourceRoot":"","sources":["../src/environment-stop-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,qCAAqC,CAAC;AACrD,MAAM,OAAO,GAAG,CAAC,wBAAwB,EAAE,iBAAiB,EAAE,qBAAqB,CAAU,CAAC;AAC9F,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAAC,CAAC;AASrG,MAAM,QAAQ,GAAuD;IACnE,sBAAsB,EAAE,kHAAkH;IAC1I,eAAe,EAAE,wGAAwG;IACzH,mBAAmB,EAAE,iGAAiG;CACvH,CAAC;AAEF,SAAS,KAAK,CAAC,KAAc,EAAE,IAAY;IACzC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,IAAI,CAAC;QAAC,OAAO,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC;IACnE,MAAM,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;AAC7B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,MAAM,MAAM,GAAG,KAAK,CA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,CAAC;AACpF,CAAC"}
|
|
@@ -56,7 +56,7 @@ const SCHEMA = "paperclip/environment-sync-error/v1";
|
|
|
56
56
|
// Match the host's workspace restore diagnostic allowlist. Both sides validate
|
|
57
57
|
// independently: plugin-supplied data must never widen the host's log surface.
|
|
58
58
|
const ERROR_CODES = new Set([
|
|
59
|
-
"ENOENT", "EACCES", "EPERM", "ENOSPC", "EIO", "EXDEV", "ENOTDIR", "EISDIR",
|
|
59
|
+
"ENOENT", "EACCES", "EPERM", "ENOSPC", "EIO", "EXDEV", "ENOTDIR", "EISDIR", "ENAMETOOLONG",
|
|
60
60
|
"ECONNRESET", "ECONNREFUSED", "ETIMEDOUT", "EPIPE", "ENOTFOUND", "EAI_AGAIN",
|
|
61
61
|
"ABORT_ERR", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_SOCKET",
|
|
62
62
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-sync-error.js","sourceRoot":"","sources":["../src/environment-sync-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe;IACnE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB;CACnE,CAAC,CAAC;AAEZ,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB;IACzE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB;CACpG,CAAC,CAAC;AAOZ,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAW,CAAC;AAEjD,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAI,SAA2B;IAClF,MAAM,KAAK,GAAY,EAAE,MAAM,EAAE,IAAI,EAA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,OAAO,0BAA0B,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;AACrF,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,kCAAkC,CAAC,KAAc;IAC/D,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Diagnostic only. A refusal never authorizes replacement, retry or cleanup. */
|
|
2
|
+
export interface PluginEnvironmentTaskErrorDiagnostic {
|
|
3
|
+
httpStatus: 409;
|
|
4
|
+
errorCode: "SESSION_STATE_UNAVAILABLE";
|
|
5
|
+
reason: "unresolved_operation" | "source_state_unverified";
|
|
6
|
+
}
|
|
7
|
+
/** Worker side: copy only the closed refusal fields, never provider text or identities. */
|
|
8
|
+
export declare function environmentTaskErrorData(error: unknown): {
|
|
9
|
+
schema: string;
|
|
10
|
+
diagnostic: PluginEnvironmentTaskErrorDiagnostic;
|
|
11
|
+
} | undefined;
|
|
12
|
+
/** Host side: validate the envelope again after the worker RPC. */
|
|
13
|
+
export declare function readEnvironmentTaskErrorDiagnostic(error: unknown): PluginEnvironmentTaskErrorDiagnostic | null;
|
|
14
|
+
export declare const ENVIRONMENT_TASK_ERROR_CODES: readonly ["runner_revision_mismatch"];
|
|
15
|
+
export type PluginEnvironmentTaskErrorCode = typeof ENVIRONMENT_TASK_ERROR_CODES[number];
|
|
16
|
+
export declare class PluginEnvironmentTaskError extends Error {
|
|
17
|
+
readonly errorCode: PluginEnvironmentTaskErrorCode;
|
|
18
|
+
constructor(errorCode: PluginEnvironmentTaskErrorCode);
|
|
19
|
+
}
|
|
20
|
+
export declare function environmentTaskErrorCodeData(error: unknown): {
|
|
21
|
+
schema: string;
|
|
22
|
+
errorCode: PluginEnvironmentTaskErrorCode;
|
|
23
|
+
} | undefined;
|
|
24
|
+
export declare function readEnvironmentTaskErrorCode(error: unknown): PluginEnvironmentTaskErrorCode | null;
|
|
25
|
+
//# sourceMappingURL=environment-task-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-task-error.d.ts","sourceRoot":"","sources":["../src/environment-task-error.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,WAAW,oCAAoC;IACnD,UAAU,EAAE,GAAG,CAAC;IAChB,SAAS,EAAE,2BAA2B,CAAC;IACvC,MAAM,EAAE,sBAAsB,GAAG,yBAAyB,CAAC;CAC5D;AAeD,2FAA2F;AAC3F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG;IACxD,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,oCAAoC,CAAC;CAClE,GAAG,SAAS,CAGZ;AAED,mEAAmE;AACnE,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,oCAAoC,GAAG,IAAI,CAK9G;AAED,eAAO,MAAM,4BAA4B,YAAI,0BAA0B,CAAU,CAAC;AAClF,MAAM,MAAM,8BAA8B,GAAG,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAC;AAezF,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,SAAS,EAAE,8BAA8B,CAAC;IAEnD,YAAY,SAAS,EAAE,8BAA8B,EAMpD;CACF;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,8BAA8B,CAAA;CAAE,GAAG,SAAS,CAItI;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,8BAA8B,GAAG,IAAI,CASlG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const SCHEMA = "paperclip/environment-task-error/v1";
|
|
2
|
+
function field(value, key) {
|
|
3
|
+
try {
|
|
4
|
+
return value && typeof value === "object" ? value[key] : undefined;
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function sanitize(httpStatus, errorCode, reason) {
|
|
11
|
+
if (httpStatus !== 409 || errorCode !== "SESSION_STATE_UNAVAILABLE" ||
|
|
12
|
+
(reason !== "unresolved_operation" && reason !== "source_state_unverified"))
|
|
13
|
+
return null;
|
|
14
|
+
return { httpStatus, errorCode, reason };
|
|
15
|
+
}
|
|
16
|
+
/** Worker side: copy only the closed refusal fields, never provider text or identities. */
|
|
17
|
+
export function environmentTaskErrorData(error) {
|
|
18
|
+
const diagnostic = sanitize(field(error, "status"), field(error, "code"), field(error, "reason"));
|
|
19
|
+
return diagnostic ? { schema: SCHEMA, diagnostic } : undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Host side: validate the envelope again after the worker RPC. */
|
|
22
|
+
export function readEnvironmentTaskErrorDiagnostic(error) {
|
|
23
|
+
const data = field(error, "data");
|
|
24
|
+
if (field(data, "schema") !== SCHEMA)
|
|
25
|
+
return null;
|
|
26
|
+
const diagnostic = field(data, "diagnostic");
|
|
27
|
+
return sanitize(field(diagnostic, "httpStatus"), field(diagnostic, "errorCode"), field(diagnostic, "reason"));
|
|
28
|
+
}
|
|
29
|
+
export const ENVIRONMENT_TASK_ERROR_CODES = ["runner_revision_mismatch"];
|
|
30
|
+
const CODE_SCHEMA = "paperclip/environment-task-error-code/v1";
|
|
31
|
+
function ownField(value, name) {
|
|
32
|
+
if (!value || typeof value !== "object")
|
|
33
|
+
return undefined;
|
|
34
|
+
try {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(value, name)?.value;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function validateCode(value) {
|
|
42
|
+
return ENVIRONMENT_TASK_ERROR_CODES.includes(value)
|
|
43
|
+
? value : null;
|
|
44
|
+
}
|
|
45
|
+
export class PluginEnvironmentTaskError extends Error {
|
|
46
|
+
errorCode;
|
|
47
|
+
constructor(errorCode) {
|
|
48
|
+
const safe = validateCode(errorCode);
|
|
49
|
+
if (!safe)
|
|
50
|
+
throw new TypeError("Unknown environment task error code");
|
|
51
|
+
super("The installed Runner does not match the expected revision");
|
|
52
|
+
this.name = "PluginEnvironmentTaskError";
|
|
53
|
+
this.errorCode = safe;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function environmentTaskErrorCodeData(error) {
|
|
57
|
+
if (!(error instanceof PluginEnvironmentTaskError))
|
|
58
|
+
return undefined;
|
|
59
|
+
const errorCode = validateCode(ownField(error, "errorCode"));
|
|
60
|
+
return errorCode ? { schema: CODE_SCHEMA, errorCode } : undefined;
|
|
61
|
+
}
|
|
62
|
+
export function readEnvironmentTaskErrorCode(error) {
|
|
63
|
+
for (let current = error, depth = 0; current && depth < 5; current = ownField(current, "cause"), depth++) {
|
|
64
|
+
const data = ownField(current, "data");
|
|
65
|
+
if (ownField(data, "schema") === CODE_SCHEMA) {
|
|
66
|
+
const code = validateCode(ownField(data, "errorCode"));
|
|
67
|
+
if (code)
|
|
68
|
+
return code;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=environment-task-error.js.map
|