@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
@@ -62,6 +62,9 @@ export declare function allowedHostProblem(entry: string): string | undefined;
62
62
  */
63
63
  export declare function trustProxyEntryProblem(entry: string): string | undefined;
64
64
  export declare const KernelConfigSchema: z.ZodObject<{
65
+ platform: z.ZodPrefault<z.ZodObject<{
66
+ name: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strict>>;
65
68
  db: z.ZodPrefault<z.ZodObject<{
66
69
  url: z.ZodString;
67
70
  poolMax: z.ZodDefault<z.ZodNumber>;
@@ -130,6 +133,7 @@ export declare const KernelConfigSchema: z.ZodObject<{
130
133
  accessTokenTtlSeconds: z.ZodDefault<z.ZodNumber>;
131
134
  refreshTokenTtlDays: z.ZodDefault<z.ZodNumber>;
132
135
  cookieSecure: z.ZodDefault<z.ZodBoolean>;
136
+ appRedirectUris: z.ZodDefault<z.ZodArray<z.ZodString>>;
133
137
  setupToken: z.ZodOptional<z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>>;
134
138
  loginSources: z.ZodDefault<z.ZodArray<z.ZodString>>;
135
139
  trustedIdentitySources: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -267,10 +271,20 @@ export declare const KernelConfigSchema: z.ZodObject<{
267
271
  }, z.core.$strict>>;
268
272
  }, z.core.$strict>>;
269
273
  devices: z.ZodPrefault<z.ZodObject<{
270
- fullAccess: z.ZodOptional<z.ZodEnum<{
274
+ outsideSandbox: z.ZodOptional<z.ZodEnum<{
271
275
  allowed: "allowed";
272
276
  off: "off";
273
277
  }>>;
278
+ network: z.ZodPrefault<z.ZodObject<{
279
+ default: z.ZodOptional<z.ZodEnum<{
280
+ allowlist: "allowlist";
281
+ open: "open";
282
+ }>>;
283
+ ceiling: z.ZodOptional<z.ZodEnum<{
284
+ allowlist: "allowlist";
285
+ open: "open";
286
+ }>>;
287
+ }, z.core.$strict>>;
274
288
  maxPersonal: z.ZodDefault<z.ZodNumber>;
275
289
  local: z.ZodPrefault<z.ZodObject<{
276
290
  reconnectGraceSeconds: z.ZodDefault<z.ZodNumber>;
@@ -22,6 +22,8 @@ function isValidMasterKey(value) {
22
22
  * 插件名同清单规则(不能是 `local`),租户 id 非空、不含空白;与 identity/external.ts 的身份源键规则一致。
23
23
  */
24
24
  const TRUSTED_SOURCE_RE = /^(?!local:)[a-z0-9][a-z0-9._-]{0,213}:\S{1,256}$/;
25
+ /** Schemes an app redirect URI never uses: the consent page navigates to it. */
26
+ const UNSAFE_REDIRECT_RE = /^\s*(?:javascript|data|vbscript|file):/i;
25
27
  /** `sandbox.limits.maxCommandSeconds` 的默认值。 */
26
28
  export const DEFAULT_MAX_COMMAND_SECONDS = 7200;
27
29
  /** access token 寿命上限(秒);会话吊销标记的 TTL 按它计算,与实例当前配置无关。 */
@@ -304,6 +306,19 @@ export function trustProxyEntryProblem(entry) {
304
306
  return undefined;
305
307
  }
306
308
  export const KernelConfigSchema = z.strictObject({
309
+ platform: z
310
+ .strictObject({
311
+ name: z
312
+ .string()
313
+ .min(1)
314
+ .max(64)
315
+ .optional()
316
+ .meta(meta({
317
+ hot: true,
318
+ description: "The platform's display name (1 to 64 characters), shown by native clients and the installed web app before sign-in (GET /api/v1/meta); unset: clients show their own name",
319
+ })),
320
+ })
321
+ .prefault({}),
307
322
  db: z
308
323
  .strictObject({
309
324
  url: z
@@ -681,6 +696,19 @@ export const KernelConfigSchema = z.strictObject({
681
696
  .meta(meta({
682
697
  description: "Set the Secure attribute on session cookies; set false only for local trials over plain http",
683
698
  })),
699
+ appRedirectUris: z
700
+ .array(z
701
+ .string()
702
+ .min(1)
703
+ .max(2048)
704
+ .refine((v) => URL.canParse(v) && !v.includes("#") && !UNSAFE_REDIRECT_RE.test(v), {
705
+ message: "Each entry must be an absolute URI without a fragment (for example capybara://auth/callback); javascript:, data:, vbscript: and file: are not allowed",
706
+ }))
707
+ .max(20)
708
+ .default(["capybara://auth/callback"])
709
+ .meta(meta({
710
+ description: "Redirect URIs native apps may receive a sign-in code at (desktop client spec §6.5), matched exactly; a fork that ships its own build under another scheme adds its URI here",
711
+ })),
684
712
  setupToken: z
685
713
  // An empty value means "not set" (compose passes ${CAPYBARA_SETUP_TOKEN:-}). Env values are
686
714
  // JSON-parsed, so an all-digit or true / false token arrives as a number or boolean: it is
@@ -714,6 +742,7 @@ export const KernelConfigSchema = z.strictObject({
714
742
  accessTokenTtlSeconds: 900,
715
743
  refreshTokenTtlDays: 30,
716
744
  cookieSecure: true,
745
+ appRedirectUris: ["capybara://auth/callback"],
717
746
  loginSources: [],
718
747
  trustedIdentitySources: [],
719
748
  }),
@@ -1550,7 +1579,7 @@ export const KernelConfigSchema = z.strictObject({
1550
1579
  egress: z
1551
1580
  .enum(["none", "allowlist"], {
1552
1581
  error: (iss) => iss.input === "open"
1553
- ? 'sandbox.limits.egress does not take "open": the open public network is set by devices.fullAccess and an organization\'s cloudNetwork; use "allowlist" or "none"'
1582
+ ? 'sandbox.limits.egress does not take "open": the open public network is set by devices.network and an organization\'s deviceNetwork; use "allowlist" or "none"'
1554
1583
  : undefined,
1555
1584
  })
1556
1585
  .default("allowlist")
@@ -1574,7 +1603,7 @@ export const KernelConfigSchema = z.strictObject({
1574
1603
  .enum(["extend", "within"])
1575
1604
  .default("extend")
1576
1605
  .meta(meta({
1577
- description: "Whether organizations may go beyond allowHosts in sandbox mode: extend (the default: an organization may use the open cloud network and add hosts, and its admins approve network requests) or within (allowHosts is the ceiling: an organization's cloud network in sandbox mode is the allowlist, and it may only keep or drop hosts the list covers; only a super admin adds others). Auto mode is not limited by it: devices.fullAccess governs Full permission's open network, so set devices.fullAccess off as well for a hard ceiling",
1606
+ description: "Whether organizations may go beyond allowHosts: extend (the default: an organization may add hosts of its own, and its admins approve network requests) or within (allowHosts is the ceiling: an organization's list may only keep or drop hosts the list covers; only a super admin adds others). It limits the hosts of the allowlist only: devices.network.ceiling decides whether devices may use the open network, so set it to allowlist as well for a hard ceiling",
1578
1607
  })),
1579
1608
  })
1580
1609
  .prefault({}),
@@ -1583,21 +1612,47 @@ export const KernelConfigSchema = z.strictObject({
1583
1612
  devices: z
1584
1613
  .strictObject({
1585
1614
  /**
1586
- * The platform's Full permission switch (permission runtime cutover B1): whether a device's
1587
- * owner ceiling may allow Full permission. Also a deployment setting the super admin changes
1588
- * in the admin console (`devicesFullAccess`); the startup config wins over it, so this field
1589
- * is optional with no schema default (the default `allowed` is applied by
1590
- * `readDevicesFullAccess`: a schema default would be indistinguishable from a value the config
1591
- * source set). The old key `devices.autoMode` (`CAPYBARA_DEVICES__AUTO_MODE`) is refused with
1592
- * the conversion message (`config/load.ts`).
1615
+ * The platform's outside-sandbox ceiling (approval-only profiles design, "Settings model"):
1616
+ * whether any device may be granted a per-call escalation outside its sandbox. Also a
1617
+ * deployment setting the super admin changes in the admin console (`devicesOutsideSandbox`);
1618
+ * the startup config wins over it, so this field is optional with no schema default (the
1619
+ * default `allowed` is applied by `readDeviceSandboxSettings`: a schema default would be
1620
+ * indistinguishable from a value the config source set). The old keys `devices.fullAccess`
1621
+ * and `devices.autoMode` are refused with the conversion message (`config/load.ts`).
1593
1622
  */
1594
- fullAccess: z
1623
+ outsideSandbox: z
1595
1624
  .enum(["allowed", "off"])
1596
1625
  .optional()
1597
1626
  .meta(meta({
1598
1627
  hot: true,
1599
- description: "Whether devices may run with Full permission (default allowed): a device whose owner allows Full may then run a conversation with Full permission; a cloud device on Full reaches the open public network (private and internal addresses blocked) unless sandbox.limits.egress is none. When off, devices run restricted: local devices on their allowlist, cloud devices on their organization's cloud network (cloudNetwork). An organization may turn it off and follow the platform. Set here, it is read-only in the admin console. Replaces devices.autoMode (CAPYBARA_DEVICES__AUTO_MODE), which is refused: rename it (the same values), or convert a config file with capybara config migrate-permissions",
1628
+ description: "Whether a device may be granted running a call outside its sandbox (default allowed): a person, the review model or Full access then approves such an escalation per call, within the organization's and the device owner's settings; off refuses every escalation, and devices only run in their sandbox. An organization may turn it off and follow the platform. Set here, it is read-only in the admin console. Replaces devices.fullAccess (CAPYBARA_DEVICES__FULL_ACCESS) and devices.autoMode, which are refused: rename them (the same values; off also needs devices.network.ceiling: allowlist to keep devices on the allowlist), or convert a config file with capybara config migrate-permissions",
1600
1629
  })),
1630
+ /**
1631
+ * The platform's device sandbox network (approval-only profiles design, "Settings model"):
1632
+ * the default mode and the widest mode an org or device may choose, `open` (the public
1633
+ * internet; private, loopback and metadata addresses closed) or `allowlist`. Optional with
1634
+ * no schema default, like `outsideSandbox`: the admin console's choice applies when unset
1635
+ * (`devicesNetwork`), else `open`. A default above the ceiling of the same source is refused
1636
+ * (`config/load.ts`); across sources the reader clamps the default to the ceiling.
1637
+ */
1638
+ network: z
1639
+ .strictObject({
1640
+ default: z
1641
+ .enum(["open", "allowlist"])
1642
+ .optional()
1643
+ .meta(meta({
1644
+ hot: true,
1645
+ description: "The sandbox network a device gets when neither its organization nor its owner chooses one (default open): open is the public internet, with private, loopback, link-local and cloud metadata addresses closed; allowlist is only the hosts of sandbox.limits.allowHosts and the organization's list. Never wider than devices.network.ceiling. Set here, it is read-only in the admin console",
1646
+ })),
1647
+ ceiling: z
1648
+ .enum(["open", "allowlist"])
1649
+ .optional()
1650
+ .meta(meta({
1651
+ hot: true,
1652
+ description: "The widest sandbox network an organization or a device may choose (default open). Set it to allowlist for egress control: every device then reaches only the hosts of sandbox.limits.allowHosts and its organization's list. Set here, it is read-only in the admin console",
1653
+ })),
1654
+ })
1655
+ .prefault({}),
1601
1656
  maxPersonal: z
1602
1657
  .number()
1603
1658
  .int()
@@ -9,9 +9,49 @@ export declare function permissionCodePointCompare(a: string, b: string): number
9
9
  */
10
10
  export declare const ACTOR_DEVICE_ACCESS_REASON = "This run's actor cannot use the selected device";
11
11
  export declare const ACTOR_NOT_DEVICE_OWNER_REASON = "The selected device belongs to the conversation's owner, and this run's account is not its owner, so this run continues without the device";
12
- /** Complete recorded facts, never a grant or a requested-but-unverified scope. */
13
- export declare const PermissionContextV1Schema: z.ZodObject<{
14
- version: z.ZodLiteral<1>;
12
+ /**
13
+ * The `sandbox` block of permission context version 2 (approval-only profiles design, "Replay and
14
+ * permission context"): the device sandbox, the same under every profile.
15
+ */
16
+ export declare const PermissionContextSandboxSchema: z.ZodObject<{
17
+ boundary: z.ZodEnum<{
18
+ instance: "instance";
19
+ operation: "operation";
20
+ }>;
21
+ location: z.ZodEnum<{
22
+ cloud: "cloud";
23
+ local: "local";
24
+ }>;
25
+ workingRoot: z.ZodString;
26
+ network: z.ZodObject<{
27
+ kind: z.ZodEnum<{
28
+ allowlist: "allowlist";
29
+ none: "none";
30
+ "open-public": "open-public";
31
+ }>;
32
+ hostsCount: z.ZodNumber;
33
+ }, z.core.$strict>;
34
+ outsideSandbox: z.ZodBoolean;
35
+ outerNetwork: z.ZodDiscriminatedUnion<[z.ZodObject<{
36
+ kind: z.ZodLiteral<"host-environment">;
37
+ }, z.core.$strict>, z.ZodObject<{
38
+ kind: z.ZodLiteral<"none">;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ kind: z.ZodLiteral<"open-public">;
41
+ }, z.core.$strict>, z.ZodObject<{
42
+ kind: z.ZodLiteral<"allowlist">;
43
+ hosts: z.ZodArray<z.ZodString>;
44
+ }, z.core.$strict>], "kind">;
45
+ perCallHosts: z.ZodOptional<z.ZodBoolean>;
46
+ }, z.core.$strict>;
47
+ export type PermissionContextSandbox = z.infer<typeof PermissionContextSandboxSchema>;
48
+ /**
49
+ * Complete recorded facts, never a grant or a requested-but-unverified scope. Version 2
50
+ * (approval-only profiles design) adds the device `sandbox` block, the same under every profile:
51
+ * a profile only chooses who approves a crossing, so Full access records a scoped sandbox too.
52
+ */
53
+ export declare const PermissionContextV2Schema: z.ZodObject<{
54
+ version: z.ZodLiteral<2>;
15
55
  rootConversationId: z.ZodString;
16
56
  profileRevision: z.ZodNullable<z.ZodNumber>;
17
57
  selectedProfile: z.ZodNullable<z.ZodCustom<PermissionProfile, PermissionProfile>>;
@@ -60,6 +100,8 @@ export declare const PermissionContextV1Schema: z.ZodObject<{
60
100
  }, z.core.$strict>, z.ZodObject<{
61
101
  kind: z.ZodLiteral<"allowlist">;
62
102
  hosts: z.ZodArray<z.ZodString>;
103
+ }, z.core.$strict>, z.ZodObject<{
104
+ kind: z.ZodLiteral<"open-public">;
63
105
  }, z.core.$strict>], "kind">;
64
106
  outerNetwork: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
107
  kind: z.ZodLiteral<"host-environment">;
@@ -72,8 +114,142 @@ export declare const PermissionContextV1Schema: z.ZodObject<{
72
114
  hosts: z.ZodArray<z.ZodString>;
73
115
  }, z.core.$strict>], "kind">;
74
116
  }, z.core.$strict>>;
117
+ sandbox: z.ZodNullable<z.ZodObject<{
118
+ boundary: z.ZodEnum<{
119
+ instance: "instance";
120
+ operation: "operation";
121
+ }>;
122
+ location: z.ZodEnum<{
123
+ cloud: "cloud";
124
+ local: "local";
125
+ }>;
126
+ workingRoot: z.ZodString;
127
+ network: z.ZodObject<{
128
+ kind: z.ZodEnum<{
129
+ allowlist: "allowlist";
130
+ none: "none";
131
+ "open-public": "open-public";
132
+ }>;
133
+ hostsCount: z.ZodNumber;
134
+ }, z.core.$strict>;
135
+ outsideSandbox: z.ZodBoolean;
136
+ outerNetwork: z.ZodDiscriminatedUnion<[z.ZodObject<{
137
+ kind: z.ZodLiteral<"host-environment">;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ kind: z.ZodLiteral<"none">;
140
+ }, z.core.$strict>, z.ZodObject<{
141
+ kind: z.ZodLiteral<"open-public">;
142
+ }, z.core.$strict>, z.ZodObject<{
143
+ kind: z.ZodLiteral<"allowlist">;
144
+ hosts: z.ZodArray<z.ZodString>;
145
+ }, z.core.$strict>], "kind">;
146
+ perCallHosts: z.ZodOptional<z.ZodBoolean>;
147
+ }, z.core.$strict>>;
75
148
  }, z.core.$strict>;
76
- export type PermissionContextV1 = z.infer<typeof PermissionContextV1Schema>;
149
+ export type PermissionContextV2 = z.infer<typeof PermissionContextV2Schema>;
150
+ /**
151
+ * Reads a recorded payload as version 2. Stored v1 rows exist on deployments and the log is never
152
+ * rewritten: a v1 payload (`version: 1`, never a `sandbox` key) reads as v2 with `sandbox: null`,
153
+ * which v2 accepts under exactly v1's rules. Anything else is left for the v2 schema to judge.
154
+ */
155
+ export declare function upconvertPermissionContext(payload: unknown): unknown;
156
+ /** A recorded `permission_context` payload as every reader parses it (v1 up-converted). */
157
+ export declare const RecordedPermissionContextSchema: z.ZodPreprocess<z.ZodObject<{
158
+ version: z.ZodLiteral<2>;
159
+ rootConversationId: z.ZodString;
160
+ profileRevision: z.ZodNullable<z.ZodNumber>;
161
+ selectedProfile: z.ZodNullable<z.ZodCustom<PermissionProfile, PermissionProfile>>;
162
+ effectiveProfile: z.ZodNullable<z.ZodCustom<PermissionProfile, PermissionProfile>>;
163
+ execution: z.ZodEnum<{
164
+ interactive: "interactive";
165
+ scheduled: "scheduled";
166
+ }>;
167
+ inherited: z.ZodBoolean;
168
+ deviceId: z.ZodNullable<z.ZodString>;
169
+ scopeRevision: z.ZodNullable<z.ZodString>;
170
+ authorityRevision: z.ZodNullable<z.ZodString>;
171
+ availability: z.ZodDiscriminatedUnion<[z.ZodObject<{
172
+ state: z.ZodLiteral<"supported">;
173
+ }, z.core.$strict>, z.ZodObject<{
174
+ state: z.ZodEnum<{
175
+ unprobed: "unprobed";
176
+ unsupported: "unsupported";
177
+ }>;
178
+ reason: z.ZodString;
179
+ }, z.core.$strict>, z.ZodObject<{
180
+ state: z.ZodLiteral<"unavailable">;
181
+ cause: z.ZodEnum<{
182
+ "actor-device-access": "actor-device-access";
183
+ "no-device": "no-device";
184
+ }>;
185
+ reason: z.ZodString;
186
+ }, z.core.$strict>], "state">;
187
+ scope: z.ZodNullable<z.ZodObject<{
188
+ location: z.ZodEnum<{
189
+ cloud: "cloud";
190
+ local: "local";
191
+ }>;
192
+ workingRoot: z.ZodString;
193
+ filesystem: z.ZodDiscriminatedUnion<[z.ZodObject<{
194
+ kind: z.ZodLiteral<"device">;
195
+ }, z.core.$strict>, z.ZodObject<{
196
+ kind: z.ZodLiteral<"scoped">;
197
+ readDirectories: z.ZodArray<z.ZodString>;
198
+ writeDirectories: z.ZodArray<z.ZodString>;
199
+ }, z.core.$strict>], "kind">;
200
+ network: z.ZodDiscriminatedUnion<[z.ZodObject<{
201
+ kind: z.ZodLiteral<"none">;
202
+ }, z.core.$strict>, z.ZodObject<{
203
+ kind: z.ZodLiteral<"environment">;
204
+ }, z.core.$strict>, z.ZodObject<{
205
+ kind: z.ZodLiteral<"allowlist">;
206
+ hosts: z.ZodArray<z.ZodString>;
207
+ }, z.core.$strict>, z.ZodObject<{
208
+ kind: z.ZodLiteral<"open-public">;
209
+ }, z.core.$strict>], "kind">;
210
+ outerNetwork: z.ZodDiscriminatedUnion<[z.ZodObject<{
211
+ kind: z.ZodLiteral<"host-environment">;
212
+ }, z.core.$strict>, z.ZodObject<{
213
+ kind: z.ZodLiteral<"none">;
214
+ }, z.core.$strict>, z.ZodObject<{
215
+ kind: z.ZodLiteral<"open-public">;
216
+ }, z.core.$strict>, z.ZodObject<{
217
+ kind: z.ZodLiteral<"allowlist">;
218
+ hosts: z.ZodArray<z.ZodString>;
219
+ }, z.core.$strict>], "kind">;
220
+ }, z.core.$strict>>;
221
+ sandbox: z.ZodNullable<z.ZodObject<{
222
+ boundary: z.ZodEnum<{
223
+ instance: "instance";
224
+ operation: "operation";
225
+ }>;
226
+ location: z.ZodEnum<{
227
+ cloud: "cloud";
228
+ local: "local";
229
+ }>;
230
+ workingRoot: z.ZodString;
231
+ network: z.ZodObject<{
232
+ kind: z.ZodEnum<{
233
+ allowlist: "allowlist";
234
+ none: "none";
235
+ "open-public": "open-public";
236
+ }>;
237
+ hostsCount: z.ZodNumber;
238
+ }, z.core.$strict>;
239
+ outsideSandbox: z.ZodBoolean;
240
+ outerNetwork: z.ZodDiscriminatedUnion<[z.ZodObject<{
241
+ kind: z.ZodLiteral<"host-environment">;
242
+ }, z.core.$strict>, z.ZodObject<{
243
+ kind: z.ZodLiteral<"none">;
244
+ }, z.core.$strict>, z.ZodObject<{
245
+ kind: z.ZodLiteral<"open-public">;
246
+ }, z.core.$strict>, z.ZodObject<{
247
+ kind: z.ZodLiteral<"allowlist">;
248
+ hosts: z.ZodArray<z.ZodString>;
249
+ }, z.core.$strict>], "kind">;
250
+ perCallHosts: z.ZodOptional<z.ZodBoolean>;
251
+ }, z.core.$strict>>;
252
+ }, z.core.$strict>, unknown>;
77
253
  export declare const ManagedDevicePathsV1Schema: z.ZodObject<{
78
254
  permissionContextVersion: z.ZodLiteral<1>;
79
255
  deviceId: z.ZodString;
@@ -89,6 +265,7 @@ export declare const PermissionContextMetaV1Schema: z.ZodObject<{
89
265
  version: z.ZodLiteral<1>;
90
266
  contextSeq: z.ZodNullable<z.ZodNumber>;
91
267
  hash: z.ZodString;
268
+ sandbox: z.ZodOptional<z.ZodString>;
92
269
  }, z.core.$strict>;
93
270
  export type PermissionContextMetaV1 = z.infer<typeof PermissionContextMetaV1Schema>;
94
271
  /** The most hosts one network ask (and one `network_blocked` event) lists. */
@@ -188,6 +365,12 @@ export declare const ReviewRecordSchema: z.ZodObject<{
188
365
  }>>;
189
366
  commandHash: z.ZodOptional<z.ZodString>;
190
367
  sandbox: z.ZodOptional<z.ZodLiteral<"escalated">>;
368
+ crossing: z.ZodOptional<z.ZodEnum<{
369
+ directory: "directory";
370
+ host: "host";
371
+ "outside-sandbox": "outside-sandbox";
372
+ sensitive: "sensitive";
373
+ }>>;
191
374
  }, z.core.$strict>;
192
375
  /** The display-only `approval_requested.command` facts of a `command` ask (auto mode spec §5.4). */
193
376
  export declare const CommandAskSchema: z.ZodObject<{
@@ -206,8 +389,14 @@ export declare const CommandAskSchema: z.ZodObject<{
206
389
  workingRoot: z.ZodOptional<z.ZodString>;
207
390
  kind: z.ZodEnum<{
208
391
  command: "command";
392
+ read: "read";
209
393
  write: "write";
210
394
  }>;
395
+ profile: z.ZodOptional<z.ZodEnum<{
396
+ "approve-for-me": "approve-for-me";
397
+ "full-access": "full-access";
398
+ "request-approval": "request-approval";
399
+ }>>;
211
400
  command: z.ZodString;
212
401
  path: z.ZodOptional<z.ZodString>;
213
402
  rule: z.ZodNullable<z.ZodString>;
@@ -455,7 +644,7 @@ export declare const PluginContextSchema: z.ZodObject<{
455
644
  export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
456
645
  type: z.ZodLiteral<"permission_context">;
457
646
  payload: z.ZodObject<{
458
- version: z.ZodLiteral<1>;
647
+ version: z.ZodLiteral<2>;
459
648
  rootConversationId: z.ZodString;
460
649
  profileRevision: z.ZodNullable<z.ZodNumber>;
461
650
  selectedProfile: z.ZodNullable<z.ZodCustom<PermissionProfile, PermissionProfile>>;
@@ -504,7 +693,39 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
504
693
  }, z.core.$strict>, z.ZodObject<{
505
694
  kind: z.ZodLiteral<"allowlist">;
506
695
  hosts: z.ZodArray<z.ZodString>;
696
+ }, z.core.$strict>, z.ZodObject<{
697
+ kind: z.ZodLiteral<"open-public">;
698
+ }, z.core.$strict>], "kind">;
699
+ outerNetwork: z.ZodDiscriminatedUnion<[z.ZodObject<{
700
+ kind: z.ZodLiteral<"host-environment">;
701
+ }, z.core.$strict>, z.ZodObject<{
702
+ kind: z.ZodLiteral<"none">;
703
+ }, z.core.$strict>, z.ZodObject<{
704
+ kind: z.ZodLiteral<"open-public">;
705
+ }, z.core.$strict>, z.ZodObject<{
706
+ kind: z.ZodLiteral<"allowlist">;
707
+ hosts: z.ZodArray<z.ZodString>;
507
708
  }, z.core.$strict>], "kind">;
709
+ }, z.core.$strict>>;
710
+ sandbox: z.ZodNullable<z.ZodObject<{
711
+ boundary: z.ZodEnum<{
712
+ instance: "instance";
713
+ operation: "operation";
714
+ }>;
715
+ location: z.ZodEnum<{
716
+ cloud: "cloud";
717
+ local: "local";
718
+ }>;
719
+ workingRoot: z.ZodString;
720
+ network: z.ZodObject<{
721
+ kind: z.ZodEnum<{
722
+ allowlist: "allowlist";
723
+ none: "none";
724
+ "open-public": "open-public";
725
+ }>;
726
+ hostsCount: z.ZodNumber;
727
+ }, z.core.$strict>;
728
+ outsideSandbox: z.ZodBoolean;
508
729
  outerNetwork: z.ZodDiscriminatedUnion<[z.ZodObject<{
509
730
  kind: z.ZodLiteral<"host-environment">;
510
731
  }, z.core.$strict>, z.ZodObject<{
@@ -515,6 +736,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
515
736
  kind: z.ZodLiteral<"allowlist">;
516
737
  hosts: z.ZodArray<z.ZodString>;
517
738
  }, z.core.$strict>], "kind">;
739
+ perCallHosts: z.ZodOptional<z.ZodBoolean>;
518
740
  }, z.core.$strict>>;
519
741
  }, z.core.$strict>;
520
742
  }, z.core.$strip>, z.ZodObject<{
@@ -564,9 +786,16 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
564
786
  }>;
565
787
  reason: z.ZodString;
566
788
  decisionSource: z.ZodEnum<{
789
+ "full-access": "full-access";
567
790
  "review-model": "review-model";
568
791
  rule: "rule";
569
792
  }>;
793
+ crossing: z.ZodOptional<z.ZodEnum<{
794
+ directory: "directory";
795
+ host: "host";
796
+ "outside-sandbox": "outside-sandbox";
797
+ }>>;
798
+ sensitive: z.ZodOptional<z.ZodArray<z.ZodString>>;
570
799
  }, z.core.$strip>;
571
800
  }, z.core.$strip>, z.ZodObject<{
572
801
  type: z.ZodLiteral<"permission_profile_changed">;
@@ -798,6 +1027,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
798
1027
  version: z.ZodLiteral<1>;
799
1028
  contextSeq: z.ZodNullable<z.ZodNumber>;
800
1029
  hash: z.ZodString;
1030
+ sandbox: z.ZodOptional<z.ZodString>;
801
1031
  }, z.core.$strict>>;
802
1032
  reminderSeqs: z.ZodArray<z.ZodNumber>;
803
1033
  maxOutputTokens: z.ZodNumber;
@@ -1133,6 +1363,12 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
1133
1363
  }>>;
1134
1364
  commandHash: z.ZodOptional<z.ZodString>;
1135
1365
  sandbox: z.ZodOptional<z.ZodLiteral<"escalated">>;
1366
+ crossing: z.ZodOptional<z.ZodEnum<{
1367
+ directory: "directory";
1368
+ host: "host";
1369
+ "outside-sandbox": "outside-sandbox";
1370
+ sensitive: "sensitive";
1371
+ }>>;
1136
1372
  }, z.core.$strict>>;
1137
1373
  loadedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1138
1374
  display: z.ZodOptional<z.ZodObject<{
@@ -1256,8 +1492,14 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
1256
1492
  workingRoot: z.ZodOptional<z.ZodString>;
1257
1493
  kind: z.ZodEnum<{
1258
1494
  command: "command";
1495
+ read: "read";
1259
1496
  write: "write";
1260
1497
  }>;
1498
+ profile: z.ZodOptional<z.ZodEnum<{
1499
+ "approve-for-me": "approve-for-me";
1500
+ "full-access": "full-access";
1501
+ "request-approval": "request-approval";
1502
+ }>>;
1261
1503
  command: z.ZodString;
1262
1504
  path: z.ZodOptional<z.ZodString>;
1263
1505
  rule: z.ZodNullable<z.ZodString>;