@capybara-hq/kernel 0.1.0-rc.53 → 0.1.0-rc.55

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 (190) hide show
  1. package/dist/admin/admin.schemas.d.ts +11 -1
  2. package/dist/catalog/catalog.module.js +1 -1
  3. package/dist/catalog/marketplaces.service.d.ts +1 -1
  4. package/dist/catalog/requests.service.d.ts +5 -5
  5. package/dist/catalog/requests.service.js +9 -9
  6. package/dist/channels/cards.d.ts +4 -3
  7. package/dist/channels/cards.js +25 -16
  8. package/dist/channels/phrases.d.ts +15 -4
  9. package/dist/channels/phrases.js +15 -1
  10. package/dist/config/load.d.ts +26 -7
  11. package/dist/config/load.js +60 -9
  12. package/dist/config/permission-migration.d.ts +17 -9
  13. package/dist/config/permission-migration.js +60 -9
  14. package/dist/config/schema.d.ts +15 -1
  15. package/dist/config/schema.js +66 -11
  16. package/dist/conversations/events.d.ts +247 -5
  17. package/dist/conversations/events.js +127 -16
  18. package/dist/conversations/permission-profiles.controller.d.ts +12 -2
  19. package/dist/conversations/permission-profiles.service.d.ts +12 -2
  20. package/dist/conversations/permission-profiles.service.js +11 -4
  21. package/dist/db/kernel-schema.d.ts +18 -2
  22. package/dist/devices/device-projects.service.d.ts +1 -1
  23. package/dist/devices/device-projects.service.js +6 -6
  24. package/dist/devices/devices.controller.d.ts +10 -8
  25. package/dist/devices/devices.controller.js +14 -18
  26. package/dist/devices/devices.schemas.d.ts +5 -5
  27. package/dist/devices/devices.schemas.js +5 -5
  28. package/dist/devices/devices.service.d.ts +188 -175
  29. package/dist/devices/devices.service.js +284 -292
  30. package/dist/devices/dto.d.ts +43 -23
  31. package/dist/devices/dto.js +45 -49
  32. package/dist/devices/project-rules.d.ts +0 -10
  33. package/dist/devices/project-rules.js +0 -5
  34. package/dist/errors.d.ts +43 -19
  35. package/dist/errors.js +43 -19
  36. package/dist/evals/reconstruct.d.ts +12 -3
  37. package/dist/evals/reconstruct.js +10 -6
  38. package/dist/evals/recorded-permission-context.d.ts +6 -4
  39. package/dist/evals/recorded-permission-context.js +15 -9
  40. package/dist/evals/run-replay.d.ts +6 -1
  41. package/dist/evals/run-replay.js +7 -2
  42. package/dist/evals/worker.js +3 -1
  43. package/dist/http/api.module.js +8 -0
  44. package/dist/http/app.js +9 -0
  45. package/dist/http/meta.controller.d.ts +33 -0
  46. package/dist/http/meta.controller.js +72 -0
  47. package/dist/identity/app-auth.controller.d.ts +25 -0
  48. package/dist/identity/app-auth.controller.js +64 -0
  49. package/dist/identity/app-auth.d.ts +66 -0
  50. package/dist/identity/app-auth.js +203 -0
  51. package/dist/identity/app-auth.schemas.d.ts +47 -0
  52. package/dist/identity/app-auth.schemas.js +43 -0
  53. package/dist/identity/identity.module.d.ts +1 -1
  54. package/dist/identity/identity.module.js +4 -1
  55. package/dist/identity/settings.d.ts +45 -18
  56. package/dist/identity/settings.js +151 -51
  57. package/dist/infra/config/kernel-config.service.d.ts +1 -1
  58. package/dist/infra/config/kernel-config.service.js +19 -5
  59. package/dist/infra/outbox/registry.d.ts +14 -0
  60. package/dist/infra/outbox/registry.js +15 -0
  61. package/dist/infra/throttler/named-throttlers.d.ts +3 -2
  62. package/dist/infra/throttler/named-throttlers.js +14 -2
  63. package/dist/local-devices/device-auth.controller.d.ts +1 -1
  64. package/dist/local-devices/device-auth.controller.js +1 -1
  65. package/dist/local-devices/device-auth.d.ts +4 -4
  66. package/dist/local-devices/device-auth.js +1 -1
  67. package/dist/local-devices/device-policy.service.d.ts +18 -9
  68. package/dist/local-devices/device-policy.service.js +21 -61
  69. package/dist/local-devices/device-routes.d.ts +3 -1
  70. package/dist/local-devices/device-routes.js +15 -4
  71. package/dist/local-devices/instance-bindings.js +5 -2
  72. package/dist/local-devices/local-device-gateway.d.ts +2 -2
  73. package/dist/local-devices/local-device-gateway.js +3 -3
  74. package/dist/local-devices/local-device-provider.d.ts +4 -4
  75. package/dist/local-devices/local-device-provider.js +23 -9
  76. package/dist/local-devices/local-devices.module.d.ts +1 -1
  77. package/dist/local-devices/local-devices.module.js +1 -1
  78. package/dist/local-devices/machines.d.ts +40 -16
  79. package/dist/local-devices/machines.js +89 -61
  80. package/dist/local-devices/owner-report.d.ts +16 -14
  81. package/dist/local-devices/owner-report.js +24 -30
  82. package/dist/local-devices/owner-reports.js +26 -8
  83. package/dist/local-devices/policy-summary.d.ts +25 -44
  84. package/dist/local-devices/policy-summary.js +26 -71
  85. package/dist/local-devices/relay.d.ts +6 -6
  86. package/dist/local-devices/relay.js +10 -8
  87. package/dist/net/public-address.d.ts +1 -1
  88. package/dist/net/public-address.js +5 -2
  89. package/dist/orgs/device-network-setting.d.ts +82 -0
  90. package/dist/orgs/device-network-setting.js +142 -0
  91. package/dist/orgs/settings.service.d.ts +103 -66
  92. package/dist/orgs/settings.service.js +201 -137
  93. package/dist/overrides.d.ts +5 -1
  94. package/dist/overrides.js +2 -0
  95. package/dist/platform/exclusions.js +24 -1
  96. package/dist/platform/operation.js +2 -2
  97. package/dist/platform/ops/admin.ops.js +20 -11
  98. package/dist/platform/ops/devices.ops.js +70 -5
  99. package/dist/platform/ops/org-settings.ops.js +10 -6
  100. package/dist/platform/ops/orgs.ops.js +2 -1
  101. package/dist/platform/ops/platform-icons.ops.d.ts +14 -0
  102. package/dist/platform/ops/platform-icons.ops.js +117 -0
  103. package/dist/platform/platform-ops.module.d.ts +2 -1
  104. package/dist/platform/platform-ops.module.js +3 -0
  105. package/dist/platform/route-schemas.js +3 -0
  106. package/dist/runtime/context/permission-profile.d.ts +17 -8
  107. package/dist/runtime/context/permission-profile.js +126 -45
  108. package/dist/runtime/maintenance.d.ts +5 -2
  109. package/dist/runtime/maintenance.js +15 -4
  110. package/dist/runtime/permission-context.service.d.ts +1 -1
  111. package/dist/runtime/permission-context.service.js +5 -3
  112. package/dist/runtime/project/knowledge.d.ts +5 -4
  113. package/dist/runtime/project/knowledge.js +2 -1
  114. package/dist/runtime/project/knowledge.service.js +16 -13
  115. package/dist/sandbox/cloud-permission-snapshot.js +22 -3
  116. package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
  117. package/dist/sandbox/device-sandbox-settings.js +470 -0
  118. package/dist/sandbox/device-sandbox.d.ts +187 -0
  119. package/dist/sandbox/device-sandbox.js +236 -0
  120. package/dist/sandbox/held-operations.js +15 -7
  121. package/dist/sandbox/modes.d.ts +49 -24
  122. package/dist/sandbox/modes.js +27 -19
  123. package/dist/sandbox/operation-authority-types.d.ts +6 -5
  124. package/dist/sandbox/operation-authority-types.js +7 -8
  125. package/dist/sandbox/operation-authority.d.ts +23 -9
  126. package/dist/sandbox/operation-authority.js +179 -97
  127. package/dist/sandbox/permission-auto-grants.d.ts +42 -0
  128. package/dist/sandbox/permission-auto-grants.js +145 -0
  129. package/dist/sandbox/permission-call-grants.d.ts +12 -4
  130. package/dist/sandbox/permission-call-grants.js +84 -35
  131. package/dist/sandbox/permission-call-grants.module.js +10 -3
  132. package/dist/sandbox/permission-call-types.d.ts +39 -5
  133. package/dist/sandbox/permission-ceiling-writes.d.ts +29 -3
  134. package/dist/sandbox/permission-ceiling-writes.js +38 -4
  135. package/dist/sandbox/permission-config-publication.d.ts +44 -2
  136. package/dist/sandbox/permission-config-publication.js +230 -59
  137. package/dist/sandbox/permission-context-types.d.ts +2 -2
  138. package/dist/sandbox/permission-facts.d.ts +144 -15
  139. package/dist/sandbox/permission-facts.js +258 -70
  140. package/dist/sandbox/permission-runtime-reports.d.ts +5 -4
  141. package/dist/sandbox/permission-runtime-reports.js +19 -29
  142. package/dist/sandbox/review/classifier.d.ts +8 -0
  143. package/dist/sandbox/review/classifier.js +10 -0
  144. package/dist/sandbox/review/permission-candidate.d.ts +69 -5
  145. package/dist/sandbox/review/permission-candidate.js +153 -30
  146. package/dist/sandbox/review/review.service.d.ts +19 -3
  147. package/dist/sandbox/review/review.service.js +59 -11
  148. package/dist/sandbox/review/rules.js +23 -3
  149. package/dist/sandbox/sandbox.service.d.ts +29 -11
  150. package/dist/sandbox/sandbox.service.js +51 -26
  151. package/dist/skills/invoke.js +3 -2
  152. package/dist/themes/platform-icon-objects.d.ts +51 -0
  153. package/dist/themes/platform-icon-objects.js +113 -0
  154. package/dist/themes/platform-icon-public.controller.d.ts +17 -0
  155. package/dist/themes/platform-icon-public.controller.js +58 -0
  156. package/dist/themes/platform-icon.controller.d.ts +22 -0
  157. package/dist/themes/platform-icon.controller.js +65 -0
  158. package/dist/themes/platform-icon.schemas.d.ts +48 -0
  159. package/dist/themes/platform-icon.schemas.js +53 -0
  160. package/dist/themes/platform-icon.service.d.ts +83 -0
  161. package/dist/themes/platform-icon.service.js +301 -0
  162. package/dist/themes/themes.module.d.ts +4 -1
  163. package/dist/themes/themes.module.js +9 -4
  164. package/dist/tools/approvals.service.d.ts +26 -116
  165. package/dist/tools/approvals.service.js +42 -346
  166. package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
  167. package/dist/tools/builtins/sandbox/bash.js +80 -28
  168. package/dist/tools/builtins/sandbox/common.d.ts +39 -14
  169. package/dist/tools/builtins/sandbox/common.js +47 -24
  170. package/dist/tools/builtins/sandbox/deliver.js +7 -4
  171. package/dist/tools/builtins/skill-load.d.ts +2 -2
  172. package/dist/tools/builtins/skill-load.js +4 -3
  173. package/dist/tools/device-op-resolver.d.ts +4 -10
  174. package/dist/tools/device-op-resolver.js +8 -19
  175. package/dist/tools/network-asks.d.ts +52 -15
  176. package/dist/tools/network-asks.js +55 -25
  177. package/dist/tools/pipeline.d.ts +26 -14
  178. package/dist/tools/pipeline.js +144 -61
  179. package/dist/tools/registry.d.ts +6 -0
  180. package/dist/tools/tools.module.js +1 -1
  181. package/package.json +4 -4
  182. package/src/migrations/0164_platform_icons.sql +10 -0
  183. package/src/migrations/0165_device_network_columns.sql +50 -0
  184. package/src/migrations/0166_permission_grant_full_access.sql +17 -0
  185. package/src/migrations/0167_device_network_backfill.sql +32 -0
  186. package/src/migrations/0168_binding_installed_connection.sql +6 -0
  187. package/dist/orgs/cloud-network-setting.d.ts +0 -33
  188. package/dist/orgs/cloud-network-setting.js +0 -47
  189. package/dist/sandbox/platform-full-access.d.ts +0 -110
  190. package/dist/sandbox/platform-full-access.js +0 -198
@@ -8,32 +8,50 @@ export declare const DeviceParams: z.ZodObject<{
8
8
  id: z.ZodString;
9
9
  }, z.core.$strip>;
10
10
  /**
11
- * `PATCH /devices/:id`: a new name, and a cloud device's `mode`: `sandbox` narrows it, `null`
12
- * follows the org and the platform again (auto when they allow it; hardening spec D2). `auto` is
13
- * never stored. A local device's mode lives on its machine, so the service refuses a `mode` for it
14
- * (`device.mode_on_device`). The mode is a person's choice in a web session: an API token gets
15
- * `device.mode_requires_session`, and the Platform operation (`devices.rename`) omits it.
11
+ * A cloud device's sandbox network (approval-only profiles design, "Settings model"): `open` (the
12
+ * public internet), `allowlist` (its org's hosts, narrowed to `hosts` when given: a device list
13
+ * never adds a host, and an empty one follows the org's), `none` (closed), or `null` to follow its
14
+ * org again. `hosts` only with `allowlist`.
15
+ */
16
+ export declare const DeviceNetworkBody: z.ZodObject<{
17
+ mode: z.ZodNullable<z.ZodEnum<{
18
+ allowlist: "allowlist";
19
+ none: "none";
20
+ open: "open";
21
+ }>>;
22
+ hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
23
+ }, z.core.$strict>;
24
+ /**
25
+ * `PATCH /devices/:id`: a new name, and a cloud device's sandbox `network`
26
+ * ({@link DeviceNetworkBody}), within its org's and the platform's ceilings (`device.network_not_allowed`
27
+ * above them). A local device's network lives on its machine (`device.ceiling_on_machine`: narrow
28
+ * it with `POST /devices/:id/policy`, widen it on the machine). Through an API token or the
29
+ * Platform tool (`devices.set-network`) the network may only narrow.
16
30
  */
17
31
  export declare const DevicePatchBody: z.ZodObject<{
18
32
  name: z.ZodOptional<z.ZodString>;
19
- mode: z.ZodOptional<z.ZodNullable<z.ZodLiteral<"sandbox">>>;
20
- ownerCeiling: z.ZodOptional<z.ZodObject<{
21
- fullAccess: z.ZodBoolean;
33
+ network: z.ZodOptional<z.ZodObject<{
34
+ mode: z.ZodNullable<z.ZodEnum<{
35
+ allowlist: "allowlist";
36
+ none: "none";
37
+ open: "open";
38
+ }>>;
39
+ hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
40
  }, z.core.$strict>>;
23
- confirmWidening: z.ZodOptional<z.ZodLiteral<true>>;
24
41
  }, z.core.$strict>;
25
42
  /**
26
- * `POST /devices/:id/policy` (network ask-to-allow spec §7; auto mode spec §4.1): the device
27
- * owner's change of the machine's local policy. `add` and `remove` change its sandbox-mode
28
- * allowlist; `mode: "sandbox"` turns the sandbox back on (turning auto mode on is decided on the
29
- * machine only).
43
+ * `POST /devices/:id/policy` (approval-only profiles design, "Settings model"): the device owner
44
+ * narrows the local machine's sandbox from the web: `remove` hosts from its allowlist, and narrow
45
+ * its owner ceiling (`outsideSandbox: false`, `network: "allowlist"`, `restrictedProjectReach:
46
+ * "workspace"`). The web never widens it: the owner adds hosts, opens the network or allows
47
+ * running outside the sandbox on the machine (`capybara-device policy add allowedDomains`,
48
+ * `capybara-device ceiling set`).
30
49
  */
31
50
  export declare const DevicePolicyBody: z.ZodObject<{
32
- add: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
51
  remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
- mode: z.ZodOptional<z.ZodLiteral<"sandbox">>;
35
52
  ownerCeiling: z.ZodOptional<z.ZodObject<{
36
- fullAccess: z.ZodOptional<z.ZodLiteral<false>>;
53
+ outsideSandbox: z.ZodOptional<z.ZodLiteral<false>>;
54
+ network: z.ZodOptional<z.ZodLiteral<"allowlist">>;
37
55
  restrictedProjectReach: z.ZodOptional<z.ZodLiteral<"workspace">>;
38
56
  }, z.core.$strict>>;
39
57
  }, z.core.$strict>;
@@ -63,11 +81,14 @@ export declare class DeviceCreateBodyDto extends DeviceCreateBodyDto_base {
63
81
  }
64
82
  declare const DevicePatchBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
65
83
  name: z.ZodOptional<z.ZodString>;
66
- mode: z.ZodOptional<z.ZodNullable<z.ZodLiteral<"sandbox">>>;
67
- ownerCeiling: z.ZodOptional<z.ZodObject<{
68
- fullAccess: z.ZodBoolean;
84
+ network: z.ZodOptional<z.ZodObject<{
85
+ mode: z.ZodNullable<z.ZodEnum<{
86
+ allowlist: "allowlist";
87
+ none: "none";
88
+ open: "open";
89
+ }>>;
90
+ hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
91
  }, z.core.$strict>>;
70
- confirmWidening: z.ZodOptional<z.ZodLiteral<true>>;
71
92
  }, z.core.$strict>>;
72
93
  export declare class DevicePatchBodyDto extends DevicePatchBodyDto_base {
73
94
  }
@@ -77,11 +98,10 @@ declare const DeviceParamsDto_base: import("../infra/validation/create-zod-dto.j
77
98
  export declare class DeviceParamsDto extends DeviceParamsDto_base {
78
99
  }
79
100
  declare const DevicePolicyBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
80
- add: z.ZodOptional<z.ZodArray<z.ZodString>>;
81
101
  remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
82
- mode: z.ZodOptional<z.ZodLiteral<"sandbox">>;
83
102
  ownerCeiling: z.ZodOptional<z.ZodObject<{
84
- fullAccess: z.ZodOptional<z.ZodLiteral<false>>;
103
+ outsideSandbox: z.ZodOptional<z.ZodLiteral<false>>;
104
+ network: z.ZodOptional<z.ZodLiteral<"allowlist">>;
85
105
  restrictedProjectReach: z.ZodOptional<z.ZodLiteral<"workspace">>;
86
106
  }, z.core.$strict>>;
87
107
  }, z.core.$strict>>;
@@ -1,36 +1,10 @@
1
1
  import { isDeviceProjectName, MAX_DEVICE_PROJECT_NAME_LENGTH, validateAllowHost, } from "@capybara-hq/plugin-sdk";
2
2
  import { z } from "zod";
3
3
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
4
- import { publicSuffixWildcard } from "./public-suffix.js";
5
4
  /** A device's name: trimmed, 1-64 characters (unique per person, case-insensitive). */
6
5
  export const DeviceName = z.string().trim().min(1).max(64);
7
6
  export const DeviceNameBody = z.object({ name: DeviceName }).strict();
8
7
  export const DeviceParams = z.object({ id: z.string().min(1).max(100) });
9
- /**
10
- * `PATCH /devices/:id`: a new name, and a cloud device's `mode`: `sandbox` narrows it, `null`
11
- * follows the org and the platform again (auto when they allow it; hardening spec D2). `auto` is
12
- * never stored. A local device's mode lives on its machine, so the service refuses a `mode` for it
13
- * (`device.mode_on_device`). The mode is a person's choice in a web session: an API token gets
14
- * `device.mode_requires_session`, and the Platform operation (`devices.rename`) omits it.
15
- */
16
- export const DevicePatchBody = z
17
- .object({
18
- name: DeviceName.optional(),
19
- mode: z.literal("sandbox").nullable().optional(),
20
- /**
21
- * B2: a cloud device's explicit Full ceiling. `false` narrows; `true` widens and needs
22
- * `confirmWidening: true` (a person in a web session only); it never opens the outer network.
23
- */
24
- ownerCeiling: z.object({ fullAccess: z.boolean() }).strict().optional(),
25
- confirmWidening: z.literal(true).optional(),
26
- })
27
- .strict()
28
- .refine((b) => b.name !== undefined || b.mode !== undefined || b.ownerCeiling !== undefined, {
29
- message: "Give at least one of name, mode or ownerCeiling",
30
- })
31
- .refine((b) => b.mode === undefined || b.ownerCeiling === undefined, {
32
- message: "Give either mode or ownerCeiling, not both",
33
- });
34
8
  /** One host of a device's network allowlist (`validateAllowHost`: lowercase, `*.` allowed). */
35
9
  const PolicyHost = z
36
10
  .string()
@@ -39,44 +13,66 @@ const PolicyHost = z
39
13
  for (const message of validateAllowHost(h))
40
14
  ctx.addIssue({ code: "custom", message });
41
15
  });
42
- /** A host to add: also no `*.` wildcard over a whole public suffix (`*.com`, `*.co.uk`). */
43
- const AddHost = PolicyHost.superRefine((h, ctx) => {
44
- const tooBroad = publicSuffixWildcard(h);
45
- if (tooBroad !== null)
46
- ctx.addIssue({ code: "custom", message: tooBroad });
16
+ /**
17
+ * A cloud device's sandbox network (approval-only profiles design, "Settings model"): `open` (the
18
+ * public internet), `allowlist` (its org's hosts, narrowed to `hosts` when given: a device list
19
+ * never adds a host, and an empty one follows the org's), `none` (closed), or `null` to follow its
20
+ * org again. `hosts` only with `allowlist`.
21
+ */
22
+ export const DeviceNetworkBody = z
23
+ .object({
24
+ mode: z.enum(["open", "allowlist", "none"]).nullable(),
25
+ hosts: z.array(PolicyHost).max(100).optional(),
26
+ })
27
+ .strict()
28
+ .refine((n) => n.hosts === undefined || n.hosts.length === 0 || n.mode === "allowlist", {
29
+ message: "Give hosts only with the allowlist network",
47
30
  });
48
31
  /**
49
- * `POST /devices/:id/policy` (network ask-to-allow spec §7; auto mode spec §4.1): the device
50
- * owner's change of the machine's local policy. `add` and `remove` change its sandbox-mode
51
- * allowlist; `mode: "sandbox"` turns the sandbox back on (turning auto mode on is decided on the
52
- * machine only).
32
+ * `PATCH /devices/:id`: a new name, and a cloud device's sandbox `network`
33
+ * ({@link DeviceNetworkBody}), within its org's and the platform's ceilings (`device.network_not_allowed`
34
+ * above them). A local device's network lives on its machine (`device.ceiling_on_machine`: narrow
35
+ * it with `POST /devices/:id/policy`, widen it on the machine). Through an API token or the
36
+ * Platform tool (`devices.set-network`) the network may only narrow.
37
+ */
38
+ export const DevicePatchBody = z
39
+ .object({
40
+ name: DeviceName.optional(),
41
+ network: DeviceNetworkBody.optional(),
42
+ })
43
+ .strict()
44
+ .refine((b) => b.name !== undefined || b.network !== undefined, {
45
+ message: "Give at least one of name or network",
46
+ });
47
+ /**
48
+ * `POST /devices/:id/policy` (approval-only profiles design, "Settings model"): the device owner
49
+ * narrows the local machine's sandbox from the web: `remove` hosts from its allowlist, and narrow
50
+ * its owner ceiling (`outsideSandbox: false`, `network: "allowlist"`, `restrictedProjectReach:
51
+ * "workspace"`). The web never widens it: the owner adds hosts, opens the network or allows
52
+ * running outside the sandbox on the machine (`capybara-device policy add allowedDomains`,
53
+ * `capybara-device ceiling set`).
53
54
  */
54
55
  export const DevicePolicyBody = z
55
56
  .object({
56
- add: z.array(AddHost).min(1).max(20).optional(),
57
57
  remove: z.array(PolicyHost).min(1).max(100).optional(),
58
- mode: z.literal("sandbox").optional(),
59
- /**
60
- * B2: narrow the machine's owner ceiling. Only `fullAccess: false` and `workspace` reach are
61
- * accepted: the web never widens it (the owner does, on the machine, with `capybara-device
62
- * ceiling set`).
63
- */
64
58
  ownerCeiling: z
65
59
  .object({
66
- fullAccess: z.literal(false).optional(),
60
+ outsideSandbox: z.literal(false).optional(),
61
+ network: z.literal("allowlist").optional(),
67
62
  restrictedProjectReach: z.literal("workspace").optional(),
68
63
  })
69
64
  .strict()
70
- .refine((c) => c.fullAccess !== undefined || c.restrictedProjectReach !== undefined, {
71
- message: "Give fullAccess: false or restrictedProjectReach: workspace",
65
+ .refine((c) => c.outsideSandbox !== undefined ||
66
+ c.network !== undefined ||
67
+ c.restrictedProjectReach !== undefined, {
68
+ message: "Give outsideSandbox: false, network: allowlist or restrictedProjectReach: workspace",
72
69
  })
73
70
  .optional(),
74
71
  })
75
72
  .strict()
76
- .refine((b) => b.add !== undefined ||
77
- b.remove !== undefined ||
78
- b.mode !== undefined ||
79
- b.ownerCeiling !== undefined, { message: "Give at least one of add, remove, mode or ownerCeiling" });
73
+ .refine((b) => b.remove !== undefined || b.ownerCeiling !== undefined, {
74
+ message: "Give at least one of remove or ownerCeiling",
75
+ });
80
76
  /**
81
77
  * A project's name (project root §4.1, `isDeviceProjectName`): 1-64 UTF-16 code units, not `.` or
82
78
  * `..`, no `/`, no control characters, no leading or trailing whitespace; unique on its device.
@@ -14,18 +14,8 @@ export interface DeviceProjectScope {
14
14
  /** The owner's home a local machine reported; null when unknown (and for a cloud device). */
15
15
  home: string | null;
16
16
  supported: boolean;
17
- /**
18
- * A machine without an authenticated owner report whose own policy is auto mode while the
19
- * organization allows only sandbox mode: the kernel reads nothing on it unasked.
20
- */
21
- widerThanAllowed: boolean;
22
17
  }
23
18
  type Scope = DeviceProjectScope;
24
- /**
25
- * The protocol 2 read mode for list/scan on the device (`limits.mode`): the reach, encoded (B2: a
26
- * restricted OS-user read is never a Full grant; the v3 browse scope carries roots instead).
27
- */
28
- export declare const readModeOf: (s: Pick<Scope, "source" | "reach" | "mode">) => SandboxMode;
29
19
  /** The base a relative path is resolved against in the scope's mode (project root §4.2). */
30
20
  export declare const baseOf: (s: Scope, workspace?: string) => string | null;
31
21
  /**
@@ -1,11 +1,6 @@
1
1
  import { ApiError } from "../errors.js";
2
2
  /** Only the owner's home bounds nothing: OS-user reach on a machine reads what its owner can. */
3
3
  const homeBased = (s) => s.source === "local" && s.reach === "os-user";
4
- /**
5
- * The protocol 2 read mode for list/scan on the device (`limits.mode`): the reach, encoded (B2: a
6
- * restricted OS-user read is never a Full grant; the v3 browse scope carries roots instead).
7
- */
8
- export const readModeOf = (s) => s.source === "local" ? (s.reach === "os-user" ? "auto" : "sandbox") : s.mode;
9
4
  /** The base a relative path is resolved against in the scope's mode (project root §4.2). */
10
5
  export const baseOf = (s, workspace = s.workspace) => homeBased(s) ? s.home : workspace;
11
6
  /**
package/dist/errors.d.ts CHANGED
@@ -28,6 +28,15 @@ export declare const ERROR_CODES: {
28
28
  readonly "auth.rate_limited": 429;
29
29
  readonly "auth.session_required": 403;
30
30
  readonly "auth.password_change_required": 403;
31
+ /** Native-app sign-in: the redirect URI is not one of `auth.appRedirectUris` (exact match). */
32
+ readonly "app_auth.redirect_uri_invalid": 400;
33
+ /**
34
+ * Native-app sign-in: the code is unknown, used, expired, for another redirect URI or verifier,
35
+ * or its account or browser session is no longer valid; start the sign-in again.
36
+ */
37
+ readonly "app_auth.code_invalid": 400;
38
+ /** Native-app sign-in needs `http.publicUrl` (the issuer the app checks). */
39
+ readonly "app_auth.unavailable": 503;
31
40
  readonly "token.not_found": 404;
32
41
  readonly "org.not_found": 404;
33
42
  readonly "org.creation_disabled": 403;
@@ -36,10 +45,15 @@ export declare const ERROR_CODES: {
36
45
  readonly "org.owner_required": 403;
37
46
  readonly "org.sandbox_egress_not_allowed": 400;
38
47
  /**
39
- * The org asked for Full permission (`fullAccess: allowed`) where the platform turned it off, or
40
- * widened it through an API token or the Platform tool.
48
+ * The org allowed running outside the sandbox (`outsideSandbox: allowed`) where the platform
49
+ * turned it off, or widened it through an API token or the Platform tool.
50
+ */
51
+ readonly "org.outside_sandbox_not_allowed": 400;
52
+ /**
53
+ * The org's device network default or ceiling is above the platform's ceiling, or was opened
54
+ * through an API token or the Platform tool.
41
55
  */
42
- readonly "org.full_access_not_allowed": 400;
56
+ readonly "org.network_not_allowed": 400;
43
57
  /** An org network allowance entry that is malformed, names a link-local address, or is over the cap. */
44
58
  readonly "org.network_allowance_invalid": 400;
45
59
  readonly "org.network_allowance_not_found": 404;
@@ -52,8 +66,13 @@ export declare const ERROR_CODES: {
52
66
  readonly "org.external_sharing_not_allowed": 400;
53
67
  /** A deployment setting set in the startup config (file, Nacos or env): read-only in the admin console. */
54
68
  readonly "deployment.setting_readonly": 409;
55
- /** Allowing the platform's Full permission through an API token or the Platform tool (only off). */
56
- readonly "deployment.full_access_not_allowed": 400;
69
+ /** Allowing outside-sandbox runs platform-wide through an API token or the Platform tool (only off). */
70
+ readonly "deployment.outside_sandbox_not_allowed": 400;
71
+ /**
72
+ * The platform's network default above its ceiling, or a default or ceiling opened through an API
73
+ * token or the Platform tool.
74
+ */
75
+ readonly "deployment.network_not_allowed": 400;
57
76
  /** Allowing external sharing at the platform level through an API token or the Platform tool. */
58
77
  readonly "deployment.external_sharing_not_allowed": 400;
59
78
  /**
@@ -167,6 +186,16 @@ export declare const ERROR_CODES: {
167
186
  * a removed theme's versions are still served.
168
187
  */
169
188
  readonly "theme.not_found": 404;
189
+ /** A platform icon upload of the wrong type for its purpose (mobile layout spec §10.2.1). */
190
+ readonly "platform_icon.invalid_type": 400;
191
+ /** A PNG platform icon that is not exactly 512 × 512 (§10.2.1). */
192
+ readonly "platform_icon.invalid_size": 400;
193
+ /** A platform icon file over 1 MiB (§10.2.1). */
194
+ readonly "platform_icon.too_large": 413;
195
+ /** No object store to keep or serve the platform icon in (§10.2.1). */
196
+ readonly "platform_icon.storage_unavailable": 503;
197
+ /** No platform icon of that purpose is uploaded, or the URL's hash is not the current one. */
198
+ readonly "platform_icon.not_found": 404;
170
199
  /**
171
200
  * An `extension.client` section whose extension manifest lacks `permissions.client: true`
172
201
  * (client extensions spec §5.4: client code is always declared and reviewed).
@@ -413,11 +442,6 @@ export declare const ERROR_CODES: {
413
442
  * is admitted until a lifecycle action (a file reset) establishes them.
414
443
  */
415
444
  readonly "device.permission_reconcile_required": 409;
416
- /**
417
- * B1: a cloud device's owner ceiling PATCH before its snapshot exists (not migrated yet); the old
418
- * sandbox switch still narrows it. A file reset does not change this.
419
- */
420
- readonly "device.permission_not_migrated": 409;
421
445
  readonly "device.owner_report_stale": 409;
422
446
  /** A local device's old instance may still run legacy work until the computer restarts (8.5). */
423
447
  readonly "device.restart_required": 503;
@@ -425,19 +449,19 @@ export declare const ERROR_CODES: {
425
449
  readonly "device.replace_required": 503;
426
450
  /** A cloud device's earlier instance may run legacy work no evidence can cover (8.5). */
427
451
  readonly "device.recreate_required": 503;
428
- readonly "device.owner_ceiling_confirmation_required": 409;
429
- readonly "device.full_access_not_allowed": 409;
430
452
  /**
431
- * A device's mode is not a stored setting: a local device's mode lives on its machine
432
- * (`capybara-device ceiling set` or the device page's policy op), and a cloud device has none to
433
- * choose.
453
+ * A cloud device's network above its org's or the platform's ceiling, a host outside its org's
454
+ * list, or a widening through an API token or the Platform tool (narrow only).
434
455
  */
435
- readonly "device.mode_on_device": 409;
456
+ readonly "device.network_not_allowed": 400;
457
+ /** Running outside the sandbox where the device, its org, the platform or its provider forbids it. */
458
+ readonly "device.outside_sandbox_not_allowed": 409;
436
459
  /**
437
- * A cloud device's mode (`PATCH /devices/:id` `mode`, sandbox or null) sent with an API token:
438
- * only its owner in a web session changes it (hardening spec D2, K4).
460
+ * A local device's sandbox settings live on its machine: the web narrows them with
461
+ * `POST /devices/:id/policy`, the owner widens them on the machine (`capybara-device ceiling set`,
462
+ * `capybara-device policy add allowedDomains`).
439
463
  */
440
- readonly "device.mode_requires_session": 403;
464
+ readonly "device.ceiling_on_machine": 409;
441
465
  /**
442
466
  * The device offers no projects (project root §4.1): its `capybara-device` does not announce
443
467
  * `projects` (update it), or its cloud sandbox provider has no `list` / `scan`.
package/dist/errors.js CHANGED
@@ -28,6 +28,15 @@ export const ERROR_CODES = {
28
28
  "auth.rate_limited": 429,
29
29
  "auth.session_required": 403,
30
30
  "auth.password_change_required": 403,
31
+ /** Native-app sign-in: the redirect URI is not one of `auth.appRedirectUris` (exact match). */
32
+ "app_auth.redirect_uri_invalid": 400,
33
+ /**
34
+ * Native-app sign-in: the code is unknown, used, expired, for another redirect URI or verifier,
35
+ * or its account or browser session is no longer valid; start the sign-in again.
36
+ */
37
+ "app_auth.code_invalid": 400,
38
+ /** Native-app sign-in needs `http.publicUrl` (the issuer the app checks). */
39
+ "app_auth.unavailable": 503,
31
40
  "token.not_found": 404,
32
41
  "org.not_found": 404,
33
42
  "org.creation_disabled": 403,
@@ -36,10 +45,15 @@ export const ERROR_CODES = {
36
45
  "org.owner_required": 403,
37
46
  "org.sandbox_egress_not_allowed": 400,
38
47
  /**
39
- * The org asked for Full permission (`fullAccess: allowed`) where the platform turned it off, or
40
- * widened it through an API token or the Platform tool.
48
+ * The org allowed running outside the sandbox (`outsideSandbox: allowed`) where the platform
49
+ * turned it off, or widened it through an API token or the Platform tool.
50
+ */
51
+ "org.outside_sandbox_not_allowed": 400,
52
+ /**
53
+ * The org's device network default or ceiling is above the platform's ceiling, or was opened
54
+ * through an API token or the Platform tool.
41
55
  */
42
- "org.full_access_not_allowed": 400,
56
+ "org.network_not_allowed": 400,
43
57
  /** An org network allowance entry that is malformed, names a link-local address, or is over the cap. */
44
58
  "org.network_allowance_invalid": 400,
45
59
  "org.network_allowance_not_found": 404,
@@ -52,8 +66,13 @@ export const ERROR_CODES = {
52
66
  "org.external_sharing_not_allowed": 400,
53
67
  /** A deployment setting set in the startup config (file, Nacos or env): read-only in the admin console. */
54
68
  "deployment.setting_readonly": 409,
55
- /** Allowing the platform's Full permission through an API token or the Platform tool (only off). */
56
- "deployment.full_access_not_allowed": 400,
69
+ /** Allowing outside-sandbox runs platform-wide through an API token or the Platform tool (only off). */
70
+ "deployment.outside_sandbox_not_allowed": 400,
71
+ /**
72
+ * The platform's network default above its ceiling, or a default or ceiling opened through an API
73
+ * token or the Platform tool.
74
+ */
75
+ "deployment.network_not_allowed": 400,
57
76
  /** Allowing external sharing at the platform level through an API token or the Platform tool. */
58
77
  "deployment.external_sharing_not_allowed": 400,
59
78
  /**
@@ -167,6 +186,16 @@ export const ERROR_CODES = {
167
186
  * a removed theme's versions are still served.
168
187
  */
169
188
  "theme.not_found": 404,
189
+ /** A platform icon upload of the wrong type for its purpose (mobile layout spec §10.2.1). */
190
+ "platform_icon.invalid_type": 400,
191
+ /** A PNG platform icon that is not exactly 512 × 512 (§10.2.1). */
192
+ "platform_icon.invalid_size": 400,
193
+ /** A platform icon file over 1 MiB (§10.2.1). */
194
+ "platform_icon.too_large": 413,
195
+ /** No object store to keep or serve the platform icon in (§10.2.1). */
196
+ "platform_icon.storage_unavailable": 503,
197
+ /** No platform icon of that purpose is uploaded, or the URL's hash is not the current one. */
198
+ "platform_icon.not_found": 404,
170
199
  /**
171
200
  * An `extension.client` section whose extension manifest lacks `permissions.client: true`
172
201
  * (client extensions spec §5.4: client code is always declared and reviewed).
@@ -413,11 +442,6 @@ export const ERROR_CODES = {
413
442
  * is admitted until a lifecycle action (a file reset) establishes them.
414
443
  */
415
444
  "device.permission_reconcile_required": 409,
416
- /**
417
- * B1: a cloud device's owner ceiling PATCH before its snapshot exists (not migrated yet); the old
418
- * sandbox switch still narrows it. A file reset does not change this.
419
- */
420
- "device.permission_not_migrated": 409,
421
445
  "device.owner_report_stale": 409,
422
446
  /** A local device's old instance may still run legacy work until the computer restarts (8.5). */
423
447
  "device.restart_required": 503,
@@ -425,19 +449,19 @@ export const ERROR_CODES = {
425
449
  "device.replace_required": 503,
426
450
  /** A cloud device's earlier instance may run legacy work no evidence can cover (8.5). */
427
451
  "device.recreate_required": 503,
428
- "device.owner_ceiling_confirmation_required": 409,
429
- "device.full_access_not_allowed": 409,
430
452
  /**
431
- * A device's mode is not a stored setting: a local device's mode lives on its machine
432
- * (`capybara-device ceiling set` or the device page's policy op), and a cloud device has none to
433
- * choose.
453
+ * A cloud device's network above its org's or the platform's ceiling, a host outside its org's
454
+ * list, or a widening through an API token or the Platform tool (narrow only).
434
455
  */
435
- "device.mode_on_device": 409,
456
+ "device.network_not_allowed": 400,
457
+ /** Running outside the sandbox where the device, its org, the platform or its provider forbids it. */
458
+ "device.outside_sandbox_not_allowed": 409,
436
459
  /**
437
- * A cloud device's mode (`PATCH /devices/:id` `mode`, sandbox or null) sent with an API token:
438
- * only its owner in a web session changes it (hardening spec D2, K4).
460
+ * A local device's sandbox settings live on its machine: the web narrows them with
461
+ * `POST /devices/:id/policy`, the owner widens them on the machine (`capybara-device ceiling set`,
462
+ * `capybara-device policy add allowedDomains`).
439
463
  */
440
- "device.mode_requires_session": 403,
464
+ "device.ceiling_on_machine": 409,
441
465
  /**
442
466
  * The device offers no projects (project root §4.1): its `capybara-device` does not announce
443
467
  * `projects` (update it), or its cloud sandbox provider has no `list` / `scan`.
@@ -17,7 +17,10 @@ import { type CaseSnapshot } from "./snapshot.js";
17
17
  * whose effective definition differs from the one frozen in its `subagent_started` (see
18
18
  * {@link subagentChanged}); the request still renders the logged definition and preamble. A child
19
19
  * case never consults `definitions` (no `definition_missing`);
20
- * - `params_changed`:没给候选参数时,记录的参数按所用模型的声明清洗后有键被丢弃或值变了(换了模型或模型声明变了);
20
+ * - `device_sandbox_changed`: the rebuilt permission context's `sandbox` block differs from the one
21
+ * the recorded metadata names (see {@link recordedPermissionContextDrift});
22
+ * - `params_changed`: without candidate params, sanitizing the recorded params against the model's
23
+ * declarations dropped a key or changed a value (another model, or its declarations changed);
21
24
  * - `media_missing`:某附件记录里不是「不再可用」,还原时却取不到;
22
25
  * - `media_changed`(只在基线判定):其余任何媒体结果与记录不同(按附件 id 比 outcome 与 etag:预算省略、
23
26
  * 图片数 / 页数上限、对象被替换后 etag 变了等);
@@ -30,7 +33,13 @@ export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing"
30
33
  /** A child case's candidate has another effective definition than the logged one (phase C). */
31
34
  | "subagent_changed"
32
35
  /** Original bounded permission contributions or their recorded locator/hash differ. */
33
- | "permission_profile_changed" | "params_changed"
36
+ | "permission_profile_changed"
37
+ /**
38
+ * Approval-only profiles: the snapshot rebuilds another device `sandbox` block for the request
39
+ * than the one its recorded metadata names (`permissionContext.sandbox`). An ordinary sandbox
40
+ * change between runs is recorded input: zero drift.
41
+ */
42
+ | "device_sandbox_changed" | "params_changed"
34
43
  /**
35
44
  * UI refresh B: a non-baseline reconstruction whose run used a person's mid-conversation model
36
45
  * switch (`model_switched`) and whose candidate model (`modelRef`) replaces it.
@@ -104,7 +113,7 @@ type ModelCallEvent = Extract<ConversationEvent, {
104
113
  export declare function assertSnapshotPermissionEvents(events: readonly ConversationEvent[]): void;
105
114
  /**
106
115
  * Compare only the original request range, never live state or candidate-generated history.
107
- * Throws `eval.snapshot_invalid` first when any recorded v1 event in the snapshot
116
+ * Throws `eval.snapshot_invalid` first when any recorded permission event in the snapshot
108
117
  * (inside or outside the range, covered by a summary or not) fails its strict schema.
109
118
  */
110
119
  export declare function recordedPermissionContextDrift(events: readonly ConversationEvent[], call: ModelCallEvent): DriftReason[];
@@ -40,6 +40,7 @@ const DRIFT_ORDER = [
40
40
  "definition_missing",
41
41
  "subagent_changed",
42
42
  "permission_profile_changed",
43
+ "device_sandbox_changed",
43
44
  "params_changed",
44
45
  "model_switched",
45
46
  "media_missing",
@@ -76,7 +77,7 @@ export function assertSnapshotPermissionEvents(events) {
76
77
  }
77
78
  /**
78
79
  * Compare only the original request range, never live state or candidate-generated history.
79
- * Throws `eval.snapshot_invalid` first when any recorded v1 event in the snapshot
80
+ * Throws `eval.snapshot_invalid` first when any recorded permission event in the snapshot
80
81
  * (inside or outside the range, covered by a summary or not) fails its strict schema.
81
82
  */
82
83
  export function recordedPermissionContextDrift(events, call) {
@@ -87,12 +88,15 @@ export function recordedPermissionContextDrift(events, call) {
87
88
  if (recorded === undefined && rebuilt === undefined)
88
89
  return [];
89
90
  const parsed = PermissionContextMetaV1Schema.safeParse(recorded);
90
- if (!parsed.success ||
91
- rebuilt === undefined ||
92
- parsed.data.contextSeq !== rebuilt.contextSeq ||
93
- parsed.data.hash !== rebuilt.hash)
91
+ if (!parsed.success || rebuilt === undefined)
94
92
  return ["permission_profile_changed"];
95
- return [];
93
+ const drift = [];
94
+ if (parsed.data.contextSeq !== rebuilt.contextSeq || parsed.data.hash !== rebuilt.hash)
95
+ drift.push("permission_profile_changed");
96
+ // the sandbox block the request saw, against the one the snapshot rebuilds
97
+ if (parsed.data.sandbox !== rebuilt.sandbox)
98
+ drift.push("device_sandbox_changed");
99
+ return drift;
96
100
  }
97
101
  /** 该请求的 agent 版本:所属运行的 `run_started`;没有(不应出现)时用快照运行的版本。 */
98
102
  function recordedVersion(s, events, call) {
@@ -1,6 +1,7 @@
1
1
  import type { EventLog } from "../conversations/event-log.js";
2
2
  import type { ConversationEvent } from "../conversations/events.js";
3
3
  import type { PermissionContextPort } from "../runtime/model-call.js";
4
+ import { type DriftReason } from "./reconstruct.js";
4
5
  import { type CaseSnapshot } from "./snapshot.js";
5
6
  /**
6
7
  * Recorded-only permission context for a full-run replay (permission context replay spec B4).
@@ -63,11 +64,12 @@ export interface ReplayTarget {
63
64
  }
64
65
  /**
65
66
  * Recorded original-coordinate diagnostics over every original request of the replayed run (spec
66
- * "Replay and meaningful drift detection"): true when any of them cannot reproduce its recorded
67
- * permission metadata from its own bounded range. Throws `eval.snapshot_invalid` for a recorded
68
- * v1 event its strict schema rejects. Never compares generated seqs or hashes with the original.
67
+ * "Replay and meaningful drift detection"): the reasons (`permission_profile_changed`,
68
+ * `device_sandbox_changed`) of every request that cannot reproduce its recorded permission
69
+ * metadata from its own bounded range, deduplicated. Throws `eval.snapshot_invalid` for a recorded
70
+ * event its strict schema rejects. Never compares generated seqs or hashes with the original.
69
71
  */
70
- export declare function recordedRunPermissionDrift(s: CaseSnapshot): boolean;
72
+ export declare function recordedRunPermissionDrift(s: CaseSnapshot): DriftReason[];
71
73
  /**
72
74
  * The recorded-only feeder for the replay of `s` (spec B4) into `target`, or undefined for a
73
75
  * recording without any v1 permission marker, so the request boundary stays absent and old
@@ -1,5 +1,6 @@
1
1
  import { ApiError } from "../errors.js";
2
- import { assertSnapshotPermissionEvents, recordedPermissionContextDrift } from "./reconstruct.js";
2
+ import { readRecordedPermissionContext } from "../runtime/context/permission-profile.js";
3
+ import { assertSnapshotPermissionEvents, recordedPermissionContextDrift, } from "./reconstruct.js";
3
4
  import { toEvents } from "./snapshot.js";
4
5
  const invalid = (message) => new ApiError("eval.snapshot_invalid", message);
5
6
  /** Whether the recording holds any v1 permission marker (event, managed path or metadata). */
@@ -87,18 +88,22 @@ export function selectOriginalRequest(requests, step, attempt) {
87
88
  export const replayPermissionContextIdemKey = (generatedRunId, originalSeq) => `replay_permission_context:${generatedRunId}:${originalSeq}`;
88
89
  /**
89
90
  * Recorded original-coordinate diagnostics over every original request of the replayed run (spec
90
- * "Replay and meaningful drift detection"): true when any of them cannot reproduce its recorded
91
- * permission metadata from its own bounded range. Throws `eval.snapshot_invalid` for a recorded
92
- * v1 event its strict schema rejects. Never compares generated seqs or hashes with the original.
91
+ * "Replay and meaningful drift detection"): the reasons (`permission_profile_changed`,
92
+ * `device_sandbox_changed`) of every request that cannot reproduce its recorded permission
93
+ * metadata from its own bounded range, deduplicated. Throws `eval.snapshot_invalid` for a recorded
94
+ * event its strict schema rejects. Never compares generated seqs or hashes with the original.
93
95
  */
94
96
  export function recordedRunPermissionDrift(s) {
95
97
  const events = toEvents(s);
96
98
  if (!hasPermissionMarkers(events))
97
- return false;
99
+ return [];
98
100
  assertSnapshotPermissionEvents(events);
99
- return events.some((e) => e.type === "model_call" &&
100
- e.runId === s.runId &&
101
- recordedPermissionContextDrift(events, e).length > 0);
101
+ const drift = new Set();
102
+ for (const e of events)
103
+ if (e.type === "model_call" && e.runId === s.runId)
104
+ for (const reason of recordedPermissionContextDrift(events, e))
105
+ drift.add(reason);
106
+ return [...drift];
102
107
  }
103
108
  /**
104
109
  * The recorded-only feeder for the replay of `s` (spec B4) into `target`, or undefined for a
@@ -139,7 +144,8 @@ export function recordedPermissionContext(s, eventLog, target) {
139
144
  type: "permission_context",
140
145
  runId: target.runId,
141
146
  idemKey: replayPermissionContextIdemKey(target.runId, c.seq),
142
- payload: structuredClone(c.payload),
147
+ // the eval log is new: a stored v1 context is written as its v2 form (same text)
148
+ payload: readRecordedPermissionContext(c.payload),
143
149
  })));
144
150
  for (const [i, c] of due.entries()) {
145
151
  const w = written[i];