@capybara-hq/kernel 0.1.0-rc.41 → 0.1.0-rc.42

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 (326) hide show
  1. package/bootstrap.json +3 -3
  2. package/dist/admin/admin.schemas.d.ts +6 -0
  3. package/dist/admin/org-network.service.d.ts +3 -1
  4. package/dist/admin/org-network.service.js +10 -2
  5. package/dist/app.d.ts +4 -0
  6. package/dist/app.js +2 -0
  7. package/dist/background/finish.d.ts +9 -1
  8. package/dist/background/finish.js +57 -4
  9. package/dist/background/launch.d.ts +23 -0
  10. package/dist/background/launch.js +55 -1
  11. package/dist/background/managed-output.d.ts +110 -0
  12. package/dist/background/managed-output.js +219 -0
  13. package/dist/background/managed.d.ts +52 -0
  14. package/dist/background/managed.js +128 -0
  15. package/dist/background/poll.job.d.ts +35 -1
  16. package/dist/background/poll.job.js +174 -9
  17. package/dist/background/render.js +1 -0
  18. package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
  19. package/dist/background/retire-legacy-tasks.job.js +149 -0
  20. package/dist/background/session.d.ts +15 -5
  21. package/dist/background/session.js +22 -6
  22. package/dist/background/stop.d.ts +35 -5
  23. package/dist/background/stop.js +94 -8
  24. package/dist/background/store.d.ts +110 -3
  25. package/dist/background/store.js +205 -3
  26. package/dist/background/tasks.service.d.ts +18 -1
  27. package/dist/background/tasks.service.js +99 -9
  28. package/dist/catalog/marketplaces.service.d.ts +1 -1
  29. package/dist/channels/cards.js +1 -1
  30. package/dist/channels/inbound.js +2 -0
  31. package/dist/channels/phrases.d.ts +4 -0
  32. package/dist/channels/phrases.js +4 -0
  33. package/dist/config/load.d.ts +18 -0
  34. package/dist/config/load.js +39 -1
  35. package/dist/config/permission-migration.d.ts +26 -0
  36. package/dist/config/permission-migration.js +64 -0
  37. package/dist/config/schema.d.ts +1 -1
  38. package/dist/config/schema.js +11 -10
  39. package/dist/conversations/conversations.controller.d.ts +1 -1
  40. package/dist/conversations/conversations.controller.js +1 -1
  41. package/dist/conversations/conversations.module.js +12 -0
  42. package/dist/conversations/conversations.service.d.ts +11 -2
  43. package/dist/conversations/conversations.service.js +97 -27
  44. package/dist/conversations/event-log.d.ts +1 -1
  45. package/dist/conversations/event-log.js +10 -2
  46. package/dist/conversations/events.d.ts +304 -4
  47. package/dist/conversations/events.js +279 -29
  48. package/dist/conversations/permission-profile-store.d.ts +50 -0
  49. package/dist/conversations/permission-profile-store.js +67 -0
  50. package/dist/conversations/permission-profile-store.module.d.ts +2 -0
  51. package/dist/conversations/permission-profile-store.module.js +19 -0
  52. package/dist/conversations/permission-profiles.controller.d.ts +84 -0
  53. package/dist/conversations/permission-profiles.controller.js +105 -0
  54. package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
  55. package/dist/conversations/permission-profiles.schemas.js +23 -0
  56. package/dist/conversations/permission-profiles.service.d.ts +56 -0
  57. package/dist/conversations/permission-profiles.service.js +179 -0
  58. package/dist/db/kernel-schema.d.ts +238 -3
  59. package/dist/devices/access.js +1 -1
  60. package/dist/devices/access.module.d.ts +2 -0
  61. package/dist/devices/access.module.js +19 -0
  62. package/dist/devices/conversation-devices.d.ts +8 -29
  63. package/dist/devices/conversation-devices.js +37 -73
  64. package/dist/devices/device-projects.service.d.ts +26 -28
  65. package/dist/devices/device-projects.service.js +123 -127
  66. package/dist/devices/devices.controller.js +3 -1
  67. package/dist/devices/devices.module.js +11 -9
  68. package/dist/devices/devices.service.d.ts +116 -8
  69. package/dist/devices/devices.service.js +252 -20
  70. package/dist/devices/dto.d.ts +16 -0
  71. package/dist/devices/dto.js +34 -6
  72. package/dist/devices/errors.d.ts +8 -0
  73. package/dist/devices/errors.js +10 -0
  74. package/dist/devices/project-rules.d.ts +44 -0
  75. package/dist/devices/project-rules.js +27 -0
  76. package/dist/devices/working-root.d.ts +6 -0
  77. package/dist/devices/working-root.js +12 -1
  78. package/dist/errors.d.ts +31 -0
  79. package/dist/errors.js +31 -0
  80. package/dist/evals/reconstruct.d.ts +19 -2
  81. package/dist/evals/reconstruct.js +40 -2
  82. package/dist/evals/recorded-permission-context.d.ts +77 -0
  83. package/dist/evals/recorded-permission-context.js +151 -0
  84. package/dist/evals/recorded-tools.d.ts +10 -1
  85. package/dist/evals/recorded-tools.js +27 -3
  86. package/dist/evals/run-replay.d.ts +8 -2
  87. package/dist/evals/run-replay.js +18 -2
  88. package/dist/evals/trajectory.d.ts +1 -1
  89. package/dist/evals/worker.d.ts +10 -1
  90. package/dist/evals/worker.js +23 -14
  91. package/dist/http/api.module.js +2 -0
  92. package/dist/identity/accounts.d.ts +14 -1
  93. package/dist/identity/accounts.js +61 -5
  94. package/dist/identity/identity.module.js +2 -0
  95. package/dist/identity/settings.d.ts +28 -12
  96. package/dist/identity/settings.js +89 -33
  97. package/dist/index.d.ts +6 -0
  98. package/dist/index.js +5 -0
  99. package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
  100. package/dist/infra/cli/kernel-cli.module.js +5 -2
  101. package/dist/infra/cli/permission-cutover.d.ts +59 -0
  102. package/dist/infra/cli/permission-cutover.js +107 -0
  103. package/dist/infra/config/kernel-config.service.d.ts +2 -2
  104. package/dist/infra/config/kernel-config.service.js +31 -11
  105. package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
  106. package/dist/infra/database/startup-activation-transaction.js +242 -0
  107. package/dist/infra/database/transaction-host.d.ts +47 -0
  108. package/dist/infra/database/transaction-host.js +119 -0
  109. package/dist/infra/database/xact-lock.d.ts +1 -0
  110. package/dist/infra/database/xact-lock.js +6 -0
  111. package/dist/infra/outbox/registry.d.ts +39 -0
  112. package/dist/infra/outbox/registry.js +18 -0
  113. package/dist/kernel.module.js +2 -0
  114. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  115. package/dist/lifecycle/kernel-lifecycle.js +55 -28
  116. package/dist/local-devices/device-auth.js +1 -1
  117. package/dist/local-devices/device-policy.service.d.ts +35 -5
  118. package/dist/local-devices/device-policy.service.js +188 -13
  119. package/dist/local-devices/instance-bindings.d.ts +82 -0
  120. package/dist/local-devices/instance-bindings.js +304 -0
  121. package/dist/local-devices/keys.d.ts +5 -0
  122. package/dist/local-devices/keys.js +5 -0
  123. package/dist/local-devices/local-device-gateway.d.ts +19 -4
  124. package/dist/local-devices/local-device-gateway.js +185 -17
  125. package/dist/local-devices/local-device-provider.d.ts +42 -7
  126. package/dist/local-devices/local-device-provider.js +185 -10
  127. package/dist/local-devices/local-devices.module.d.ts +17 -2
  128. package/dist/local-devices/local-devices.module.js +49 -8
  129. package/dist/local-devices/machines.d.ts +35 -12
  130. package/dist/local-devices/machines.js +203 -8
  131. package/dist/local-devices/network-grants.js +3 -3
  132. package/dist/local-devices/network-grants.module.d.ts +2 -0
  133. package/dist/local-devices/network-grants.module.js +14 -0
  134. package/dist/local-devices/owner-report.d.ts +79 -0
  135. package/dist/local-devices/owner-report.js +155 -0
  136. package/dist/local-devices/owner-reports.d.ts +48 -0
  137. package/dist/local-devices/owner-reports.js +190 -0
  138. package/dist/local-devices/policy-summary.d.ts +24 -1
  139. package/dist/local-devices/policy-summary.js +48 -0
  140. package/dist/local-devices/relay.d.ts +82 -6
  141. package/dist/local-devices/relay.js +187 -16
  142. package/dist/local-devices/targets.d.ts +16 -1
  143. package/dist/local-devices/targets.js +35 -2
  144. package/dist/orgs/cloud-network-setting.d.ts +33 -0
  145. package/dist/orgs/cloud-network-setting.js +47 -0
  146. package/dist/orgs/offboarding.d.ts +3 -1
  147. package/dist/orgs/offboarding.js +8 -2
  148. package/dist/orgs/org-lock.d.ts +10 -4
  149. package/dist/orgs/org-lock.js +10 -4
  150. package/dist/orgs/orgs.service.d.ts +3 -1
  151. package/dist/orgs/orgs.service.js +8 -2
  152. package/dist/orgs/settings.controller.d.ts +4 -1
  153. package/dist/orgs/settings.controller.js +3 -3
  154. package/dist/orgs/settings.service.d.ts +48 -56
  155. package/dist/orgs/settings.service.js +144 -101
  156. package/dist/overrides.d.ts +6 -1
  157. package/dist/overrides.js +2 -0
  158. package/dist/platform/exclusions.js +20 -0
  159. package/dist/platform/ops/admin.ops.js +14 -11
  160. package/dist/platform/ops/agent-skills.ops.js +2 -0
  161. package/dist/platform/ops/devices.ops.js +10 -2
  162. package/dist/platform/ops/org-settings.ops.js +6 -6
  163. package/dist/platform/ops/orgs.ops.js +1 -0
  164. package/dist/roles/worker.module.js +4 -0
  165. package/dist/runtime/context/build.d.ts +3 -1
  166. package/dist/runtime/context/build.js +19 -3
  167. package/dist/runtime/context/compaction.js +5 -0
  168. package/dist/runtime/context/device-paths.d.ts +9 -2
  169. package/dist/runtime/context/device-paths.js +20 -0
  170. package/dist/runtime/context/permission-profile.d.ts +46 -0
  171. package/dist/runtime/context/permission-profile.js +194 -0
  172. package/dist/runtime/maintenance.d.ts +7 -1
  173. package/dist/runtime/maintenance.js +43 -15
  174. package/dist/runtime/model-call.d.ts +32 -0
  175. package/dist/runtime/model-call.js +67 -0
  176. package/dist/runtime/permission-context-errors.d.ts +39 -0
  177. package/dist/runtime/permission-context-errors.js +67 -0
  178. package/dist/runtime/permission-context.service.d.ts +60 -0
  179. package/dist/runtime/permission-context.service.js +286 -0
  180. package/dist/runtime/project/knowledge.d.ts +7 -2
  181. package/dist/runtime/project/knowledge.js +5 -2
  182. package/dist/runtime/project/knowledge.service.d.ts +17 -2
  183. package/dist/runtime/project/knowledge.service.js +76 -12
  184. package/dist/runtime/run-execution.d.ts +4 -1
  185. package/dist/runtime/run-execution.js +14 -5
  186. package/dist/runtime/run-steps.d.ts +11 -3
  187. package/dist/runtime/run-steps.js +27 -4
  188. package/dist/runtime/runtime.module.js +11 -0
  189. package/dist/sandbox/attachments-path.d.ts +15 -0
  190. package/dist/sandbox/attachments-path.js +15 -0
  191. package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
  192. package/dist/sandbox/cloud-permission-snapshot.js +407 -0
  193. package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
  194. package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
  195. package/dist/sandbox/held-operations.d.ts +39 -0
  196. package/dist/sandbox/held-operations.js +119 -0
  197. package/dist/sandbox/jobs.d.ts +14 -3
  198. package/dist/sandbox/jobs.js +20 -2
  199. package/dist/sandbox/kernel-read.d.ts +55 -0
  200. package/dist/sandbox/kernel-read.js +57 -0
  201. package/dist/sandbox/legacy-retirement.d.ts +336 -0
  202. package/dist/sandbox/legacy-retirement.js +1063 -0
  203. package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
  204. package/dist/sandbox/legacy-retirement.module.js +25 -0
  205. package/dist/sandbox/managed-device-context.d.ts +94 -0
  206. package/dist/sandbox/managed-device-context.js +308 -0
  207. package/dist/sandbox/managed-device-context.module.d.ts +6 -0
  208. package/dist/sandbox/managed-device-context.module.js +33 -0
  209. package/dist/sandbox/modes.d.ts +56 -8
  210. package/dist/sandbox/modes.js +92 -8
  211. package/dist/sandbox/operation-authority-types.d.ts +8 -0
  212. package/dist/sandbox/operation-authority-types.js +32 -0
  213. package/dist/sandbox/operation-authority.d.ts +145 -0
  214. package/dist/sandbox/operation-authority.js +783 -0
  215. package/dist/sandbox/operation-authority.module.d.ts +2 -0
  216. package/dist/sandbox/operation-authority.module.js +29 -0
  217. package/dist/sandbox/operation-intents.d.ts +206 -0
  218. package/dist/sandbox/operation-intents.js +1252 -0
  219. package/dist/sandbox/operation-intents.module.d.ts +2 -0
  220. package/dist/sandbox/operation-intents.module.js +21 -0
  221. package/dist/sandbox/operation-payloads.d.ts +33 -0
  222. package/dist/sandbox/operation-payloads.js +332 -0
  223. package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
  224. package/dist/sandbox/operation-reconcile.job.js +247 -0
  225. package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
  226. package/dist/sandbox/permission-authority-epochs.js +83 -0
  227. package/dist/sandbox/permission-authority-lock.d.ts +38 -0
  228. package/dist/sandbox/permission-authority-lock.js +147 -0
  229. package/dist/sandbox/permission-authority.module.d.ts +9 -0
  230. package/dist/sandbox/permission-authority.module.js +55 -0
  231. package/dist/sandbox/permission-availability.d.ts +18 -0
  232. package/dist/sandbox/permission-availability.js +19 -0
  233. package/dist/sandbox/permission-call-grants.d.ts +34 -0
  234. package/dist/sandbox/permission-call-grants.js +349 -0
  235. package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
  236. package/dist/sandbox/permission-call-grants.module.js +21 -0
  237. package/dist/sandbox/permission-call-types.d.ts +82 -0
  238. package/dist/sandbox/permission-call-types.js +1 -0
  239. package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
  240. package/dist/sandbox/permission-ceiling-writes.js +223 -0
  241. package/dist/sandbox/permission-config-publication.d.ts +76 -0
  242. package/dist/sandbox/permission-config-publication.js +339 -0
  243. package/dist/sandbox/permission-context-types.d.ts +64 -0
  244. package/dist/sandbox/permission-context-types.js +24 -0
  245. package/dist/sandbox/permission-facts.d.ts +206 -0
  246. package/dist/sandbox/permission-facts.js +627 -0
  247. package/dist/sandbox/permission-facts.module.d.ts +2 -0
  248. package/dist/sandbox/permission-facts.module.js +20 -0
  249. package/dist/sandbox/permission-instance-writes.d.ts +90 -0
  250. package/dist/sandbox/permission-instance-writes.js +305 -0
  251. package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
  252. package/dist/sandbox/permission-runtime-reports.js +354 -0
  253. package/dist/sandbox/permission-transitions.d.ts +31 -0
  254. package/dist/sandbox/permission-transitions.js +155 -0
  255. package/dist/sandbox/platform-full-access.d.ts +128 -0
  256. package/dist/sandbox/platform-full-access.js +210 -0
  257. package/dist/sandbox/providers.d.ts +22 -0
  258. package/dist/sandbox/providers.js +10 -2
  259. package/dist/sandbox/providers.module.d.ts +2 -0
  260. package/dist/sandbox/providers.module.js +19 -0
  261. package/dist/sandbox/request-not-sent.d.ts +13 -0
  262. package/dist/sandbox/request-not-sent.js +13 -0
  263. package/dist/sandbox/review/classifier.d.ts +2 -0
  264. package/dist/sandbox/review/classifier.js +8 -0
  265. package/dist/sandbox/review/permission-candidate.d.ts +12 -0
  266. package/dist/sandbox/review/permission-candidate.js +129 -0
  267. package/dist/sandbox/review/review.service.d.ts +4 -1
  268. package/dist/sandbox/review/review.service.js +19 -5
  269. package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
  270. package/dist/sandbox/sandbox-file-reader.js +51 -7
  271. package/dist/sandbox/sandbox.module.js +26 -6
  272. package/dist/sandbox/sandbox.service.d.ts +230 -34
  273. package/dist/sandbox/sandbox.service.js +1368 -199
  274. package/dist/sandbox/unreachable.js +17 -3
  275. package/dist/sandbox/use-context.d.ts +17 -0
  276. package/dist/sandbox/use-context.js +1 -0
  277. package/dist/skills/invoke.d.ts +27 -4
  278. package/dist/skills/invoke.js +72 -7
  279. package/dist/tools/approvals.controller.d.ts +1 -0
  280. package/dist/tools/approvals.schemas.d.ts +1 -0
  281. package/dist/tools/approvals.schemas.js +3 -1
  282. package/dist/tools/approvals.service.d.ts +23 -10
  283. package/dist/tools/approvals.service.js +104 -26
  284. package/dist/tools/builtins/builtin-tools.d.ts +16 -2
  285. package/dist/tools/builtins/builtin-tools.js +38 -10
  286. package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
  287. package/dist/tools/builtins/sandbox/bash.js +201 -5
  288. package/dist/tools/builtins/sandbox/common.d.ts +92 -20
  289. package/dist/tools/builtins/sandbox/common.js +201 -17
  290. package/dist/tools/builtins/sandbox/deliver.js +2 -2
  291. package/dist/tools/builtins/sandbox/edit.js +2 -2
  292. package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
  293. package/dist/tools/builtins/sandbox/glob.js +2 -2
  294. package/dist/tools/builtins/sandbox/grep.js +2 -2
  295. package/dist/tools/builtins/sandbox/read.js +2 -2
  296. package/dist/tools/builtins/sandbox/task-list.js +7 -1
  297. package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
  298. package/dist/tools/builtins/sandbox/task-output.js +172 -0
  299. package/dist/tools/builtins/sandbox/task-stop.js +25 -3
  300. package/dist/tools/builtins/sandbox/write.js +2 -2
  301. package/dist/tools/builtins/skill-load.js +9 -6
  302. package/dist/tools/device-op-resolver.d.ts +1 -1
  303. package/dist/tools/device-op-resolver.js +13 -3
  304. package/dist/tools/permission-approval-jobs.d.ts +18 -0
  305. package/dist/tools/permission-approval-jobs.js +92 -0
  306. package/dist/tools/pipeline.d.ts +17 -2
  307. package/dist/tools/pipeline.js +300 -19
  308. package/dist/tools/registry.d.ts +9 -0
  309. package/dist/tools/tools.module.js +12 -0
  310. package/package.json +4 -3
  311. package/src/migrations/0146_permission_authority_epochs.sql +6 -0
  312. package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
  313. package/src/migrations/0148_first_message_request_hash.sql +2 -0
  314. package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
  315. package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
  316. package/src/migrations/0151_starting_execution_grants.sql +8 -0
  317. package/src/migrations/0152_background_launch_identity.sql +66 -0
  318. package/src/migrations/0153_background_cancel_requester.sql +13 -0
  319. package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
  320. package/src/migrations/0155_device_instance_generations.sql +30 -0
  321. package/src/migrations/0156_device_owner_report.sql +7 -0
  322. package/src/migrations/0157_legacy_retirement.sql +116 -0
  323. package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
  324. package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
  325. package/dist/sandbox/platform-auto-mode.d.ts +0 -63
  326. package/dist/sandbox/platform-auto-mode.js +0 -63
@@ -1,8 +1,189 @@
1
- import { CONTEXT_LIMITS, DOCUMENT_MEDIA_TYPES, hasControlChars, IMAGE_MEDIA_TYPES, isAttachmentId, isSkillName, MEDIA_NAME_MAX_CHARS, } from "@capybara-hq/plugin-sdk";
1
+ import { posix } from "node:path";
2
+ import { CONTEXT_LIMITS, DOCUMENT_MEDIA_TYPES, hasControlChars, IMAGE_MEDIA_TYPES, isAttachmentId, isSkillName, MEDIA_NAME_MAX_CHARS, validateAllowHost, validateSandboxPathShape, } from "@capybara-hq/plugin-sdk";
2
3
  import { z } from "zod";
3
4
  import { AgentDefinitionSchema, DisabledSkillRef, DisabledToolRef, ModelRef, } from "../agents/definition.js";
4
5
  import { ORG_ROLES } from "../orgs/roles.js";
6
+ import { coversHost } from "../sandbox/modes.js";
5
7
  import { TOOL_VIEW_DIFF_MAX_LINES, TOOL_VIEW_LINE_MAX_CHARS, TOOL_VIEW_PATH_MAX_CHARS, } from "../tools/view.js";
8
+ /** Code-point ordering is independent of the host locale and UTF-16 surrogate ordering. */
9
+ export function permissionCodePointCompare(a, b) {
10
+ const left = Array.from(a, (c) => c.codePointAt(0));
11
+ const right = Array.from(b, (c) => c.codePointAt(0));
12
+ for (let i = 0; i < Math.min(left.length, right.length); i++) {
13
+ const difference = left[i] - right[i];
14
+ if (difference)
15
+ return difference;
16
+ }
17
+ return left.length - right.length;
18
+ }
19
+ const PermissionProfileSchema = z.custom((value) => value === "request-approval" || value === "approve-for-me" || value === "full-access");
20
+ const PermissionPath = z
21
+ .string()
22
+ .min(1)
23
+ .max(4096)
24
+ .refine((value) => validateSandboxPathShape(value).length === 0, "Expected an absolute bounded device path")
25
+ // the authority's exact spelling: no "." segments and no trailing slash, never repaired here
26
+ .refine((value) => posix.normalize(value) === value && (value === "/" || !value.endsWith("/")), "Expected a normalized device path");
27
+ const PermissionHosts = z
28
+ .array(z
29
+ .string()
30
+ .max(253)
31
+ .refine((value) => validateAllowHost(value).length === 0, "Expected a normalized authority host"))
32
+ .min(1)
33
+ .max(100)
34
+ .refine((values) => values.every((value, i) => i === 0 || permissionCodePointCompare(values[i - 1], value) < 0), "Hosts must be unique and sorted by Unicode code point");
35
+ const PermissionDirectories = z
36
+ .array(PermissionPath)
37
+ .min(1)
38
+ .max(64)
39
+ .refine((values) => values.every((value, i) => i === 0 || permissionCodePointCompare(values[i - 1], value) < 0), "Directories must be unique and sorted by Unicode code point");
40
+ const PermissionRevision = z.string().min(1).max(256);
41
+ const PermissionReason = z
42
+ .string()
43
+ .min(1)
44
+ .max(1000)
45
+ .refine((value) => value.trim().length > 0);
46
+ const PermissionId = z.string().uuid();
47
+ const PermissionScopeSchema = z
48
+ .object({
49
+ location: z.enum(["local", "cloud"]),
50
+ workingRoot: PermissionPath,
51
+ filesystem: z.discriminatedUnion("kind", [
52
+ z.object({ kind: z.literal("device") }).strict(),
53
+ z
54
+ .object({
55
+ kind: z.literal("scoped"),
56
+ readDirectories: PermissionDirectories,
57
+ writeDirectories: PermissionDirectories,
58
+ })
59
+ .strict(),
60
+ ]),
61
+ network: z.discriminatedUnion("kind", [
62
+ z.object({ kind: z.literal("none") }).strict(),
63
+ z.object({ kind: z.literal("environment") }).strict(),
64
+ z.object({ kind: z.literal("allowlist"), hosts: PermissionHosts }).strict(),
65
+ ]),
66
+ outerNetwork: z.discriminatedUnion("kind", [
67
+ z.object({ kind: z.literal("host-environment") }).strict(),
68
+ z.object({ kind: z.literal("none") }).strict(),
69
+ z.object({ kind: z.literal("open-public") }).strict(),
70
+ z.object({ kind: z.literal("allowlist"), hosts: PermissionHosts }).strict(),
71
+ ]),
72
+ })
73
+ .strict();
74
+ /** Complete recorded facts, never a grant or a requested-but-unverified scope. */
75
+ export const PermissionContextV1Schema = z
76
+ .object({
77
+ version: z.literal(1),
78
+ rootConversationId: PermissionId,
79
+ profileRevision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable(),
80
+ selectedProfile: PermissionProfileSchema.nullable(),
81
+ effectiveProfile: PermissionProfileSchema.nullable(),
82
+ execution: z.enum(["interactive", "scheduled"]),
83
+ inherited: z.boolean(),
84
+ deviceId: PermissionId.nullable(),
85
+ scopeRevision: PermissionRevision.nullable(),
86
+ authorityRevision: PermissionRevision.nullable(),
87
+ availability: z.discriminatedUnion("state", [
88
+ z.object({ state: z.literal("supported") }).strict(),
89
+ z.object({ state: z.enum(["unsupported", "unprobed"]), reason: PermissionReason }).strict(),
90
+ z
91
+ .object({
92
+ state: z.literal("unavailable"),
93
+ cause: z.enum(["no-device", "actor-device-access"]),
94
+ reason: PermissionReason,
95
+ })
96
+ .strict(),
97
+ ]),
98
+ scope: PermissionScopeSchema.nullable(),
99
+ })
100
+ .strict()
101
+ .superRefine((p, ctx) => {
102
+ const reject = (message) => ctx.addIssue({ code: "custom", message });
103
+ if ((p.profileRevision === null) !== (p.selectedProfile === null))
104
+ reject("Profile and revision nullability must agree");
105
+ if (p.availability.state === "unavailable") {
106
+ if (p.effectiveProfile !== null ||
107
+ p.deviceId !== null ||
108
+ p.scopeRevision !== null ||
109
+ p.authorityRevision !== null ||
110
+ p.scope !== null)
111
+ reject("Unavailable context must not expose device authority");
112
+ if (p.availability.cause === "actor-device-access") {
113
+ if (p.selectedProfile !== null || p.profileRevision !== null)
114
+ reject("Device access refusal must redact the owner's profile");
115
+ if (p.availability.reason !== "This run's actor cannot use the selected device")
116
+ reject("Invalid device access reason");
117
+ }
118
+ else if (p.availability.reason !== "Choose a device to run device operations")
119
+ reject("Invalid no-device reason");
120
+ }
121
+ else if (p.selectedProfile === null ||
122
+ p.effectiveProfile === null ||
123
+ p.profileRevision === null ||
124
+ p.deviceId === null ||
125
+ p.scopeRevision === null ||
126
+ p.authorityRevision === null) {
127
+ reject("Accessible device context requires complete profile and authority identities");
128
+ }
129
+ if ((p.scope !== null) !== (p.availability.state === "supported"))
130
+ reject("Only supported context carries scope");
131
+ if (p.effectiveProfile !== null) {
132
+ if (p.execution === "scheduled" && p.effectiveProfile !== "request-approval")
133
+ reject("Scheduled context requires Request approval");
134
+ if (p.execution === "interactive" &&
135
+ (p.selectedProfile === "full-access"
136
+ ? p.effectiveProfile !== "full-access" && p.effectiveProfile !== "approve-for-me"
137
+ : p.selectedProfile !== p.effectiveProfile))
138
+ reject("Invalid effective profile transition");
139
+ }
140
+ const s = p.scope;
141
+ if (!s)
142
+ return;
143
+ if (p.effectiveProfile === "full-access") {
144
+ if (s.filesystem.kind !== "device" || s.network.kind !== "environment")
145
+ reject("Full access requires device filesystem and environment networking");
146
+ }
147
+ else if (s.filesystem.kind !== "scoped" || s.network.kind === "environment")
148
+ reject("Restricted profiles require scoped filesystem and restricted networking");
149
+ if (s.filesystem.kind === "scoped") {
150
+ const { readDirectories, writeDirectories } = s.filesystem;
151
+ if (!readDirectories.includes(s.workingRoot) ||
152
+ !writeDirectories.includes(s.workingRoot) ||
153
+ writeDirectories.some((p) => !readDirectories.includes(p)))
154
+ reject("Writable roots must be readable and both must include the working root");
155
+ if (new Set([...readDirectories, ...writeDirectories]).size > 64)
156
+ reject("At most 64 combined roots are allowed");
157
+ }
158
+ if ((s.location === "local") !== (s.outerNetwork.kind === "host-environment"))
159
+ reject("Outer boundary must match the device location");
160
+ if (s.location === "cloud" && s.network.kind === "allowlist") {
161
+ if (s.outerNetwork.kind === "none")
162
+ reject("Network hosts exceed the disabled outer boundary");
163
+ if (s.outerNetwork.kind === "allowlist") {
164
+ const outer = s.outerNetwork.hosts;
165
+ if (s.network.hosts.some((host) => !outer.some((pattern) => coversHost(pattern, host))))
166
+ reject("Network hosts exceed the applied outer allowlist");
167
+ }
168
+ }
169
+ });
170
+ export const ManagedDevicePathsV1Schema = z
171
+ .object({
172
+ permissionContextVersion: z.literal(1),
173
+ deviceId: PermissionId,
174
+ roots: z
175
+ .object({ workspace: PermissionPath, skills: PermissionPath, tmp: PermissionPath })
176
+ .strict(),
177
+ workingRoot: PermissionPath,
178
+ })
179
+ .strict();
180
+ export const PermissionContextMetaV1Schema = z
181
+ .object({
182
+ version: z.literal(1),
183
+ contextSeq: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).nullable(),
184
+ hash: z.string().regex(/^[a-f0-9]{64}$/),
185
+ })
186
+ .strict();
6
187
  /** 供应商私有数据(`ProviderOpaque`):原样保存、只回放给同一供应商。 */
7
188
  const ProviderOpaqueSchema = z.object({
8
189
  provider: z.string(),
@@ -56,8 +237,40 @@ export const COMMAND_ASK_MAX_CHARS = 32 * 1024;
56
237
  * `commandHash` is the SHA-256 of the command text the approval holds in full, so an audit can
57
238
  * match a record to what ran.
58
239
  */
59
- const ReviewRecordSchema = z
240
+ export const PermissionExpansionSchema = z
60
241
  .object({
242
+ readDirectories: z.array(z.string().max(4096)).max(64),
243
+ writeDirectories: z.array(z.string().max(4096)).max(64),
244
+ hosts: z.array(z.string().max(253)).max(100),
245
+ })
246
+ .strict();
247
+ export const PermissionCallBindingSchema = z
248
+ .object({
249
+ orgId: z.string(),
250
+ rootConversationId: z.string(),
251
+ conversationId: z.string(),
252
+ deviceId: z.string(),
253
+ accountId: z.string(),
254
+ runId: z.string(),
255
+ callId: z.string(),
256
+ toolKey: z.string(),
257
+ specHash: z.string(),
258
+ callInputHash: z.string(),
259
+ resolvedInputHash: z.string(),
260
+ profile: z.enum(["request-approval", "approve-for-me", "full-access"]),
261
+ profileRevision: z.number().int().nonnegative(),
262
+ scopeRevision: z.string(),
263
+ authorityRevision: z.string(),
264
+ })
265
+ .strict();
266
+ export const ReviewRecordSchema = z
267
+ .object({
268
+ profile: z.enum(["request-approval", "approve-for-me", "full-access"]).optional(),
269
+ profileRevision: z.number().int().nonnegative().optional(),
270
+ scopeRevision: z.string().optional(),
271
+ decisionSource: z
272
+ .enum(["scope", "human", "review-model", "full-access", "task-grant"])
273
+ .optional(),
61
274
  decision: z.enum(["allow", "deny"]),
62
275
  by: z.enum(["rule", "classifier", "person"]),
63
276
  rule: z.string().nullable(),
@@ -72,6 +285,9 @@ const ReviewRecordSchema = z
72
285
  /** The display-only `approval_requested.command` facts of a `command` ask (auto mode spec §5.4). */
73
286
  export const CommandAskSchema = z
74
287
  .object({
288
+ permissionScope: PermissionExpansionSchema.optional(),
289
+ targetPath: z.string().max(4096).optional(),
290
+ candidateHash: z.string().optional(),
75
291
  /** A shell command or a file write. */
76
292
  kind: z.enum(["command", "write"]),
77
293
  /** The command text, or the tool key of the write. */
@@ -334,6 +550,26 @@ export const PluginContextSchema = z.object({
334
550
  * 读出时按写入时的形状原样返回。
335
551
  */
336
552
  export const ConversationEventSchema = z.discriminatedUnion("type", [
553
+ ev("permission_context", PermissionContextV1Schema),
554
+ ev("permission_reviewed", z.object({
555
+ binding: PermissionCallBindingSchema,
556
+ permissionScope: PermissionExpansionSchema,
557
+ targetPath: z.string().max(4096).optional(),
558
+ scopeKind: z.literal("directories-and-hosts"),
559
+ candidateHash: z.string(),
560
+ outcome: z.enum(["allow", "ask", "deny"]),
561
+ reason: z.string(),
562
+ decisionSource: z.literal("review-model"),
563
+ })),
564
+ ev("permission_profile_changed", z.object({
565
+ oldProfile: z.enum(["request-approval", "approve-for-me", "full-access"]),
566
+ newProfile: z.enum(["request-approval", "approve-for-me", "full-access"]),
567
+ actorAccountId: z.string().nullable(),
568
+ reason: z.enum(["user", "authority-changed"]).optional(),
569
+ deviceId: z.string().nullable(),
570
+ scopeRevision: z.string().nullable(),
571
+ revision: z.number().int().nonnegative(),
572
+ })),
337
573
  ev("user_message", z.object({
338
574
  content: z.array(ContentBlockSchema),
339
575
  /**
@@ -480,6 +716,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
480
716
  toSeq: seqNo,
481
717
  summarySeq: seqNo.nullable(),
482
718
  systemHash: z.string(),
719
+ permissionContext: PermissionContextMetaV1Schema.optional(),
483
720
  reminderSeqs: z.array(seqNo),
484
721
  /**
485
722
  * The request's output cap: `min(model cap, maxOutputTokens knob ??
@@ -646,32 +883,36 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
646
883
  * they change, before that call's result. **Model-visible**: rendered at its position as a
647
884
  * system message (`devicePathsText`); a summary covering it is followed by the latest one again.
648
885
  */
649
- ev("device_paths", z.object({
650
- roots: z.object({
651
- workspace: z.string().min(1).max(4096),
652
- skills: z.string().min(1).max(4096),
653
- tmp: z.string().min(1).max(4096),
654
- }),
655
- tier: z.enum(["strict", "dev", "open"]).optional(),
656
- isolation: z.enum(["sandbox", "none"]).optional(),
657
- /** The current network (`none` on events recorded before auto mode). */
658
- network: z
659
- .union([
660
- z.literal("none"),
661
- z.object({
662
- kind: z.enum(["open-public", "allowlist"]),
663
- hosts: z.array(z.string()),
886
+ ev("device_paths", z.union([
887
+ ManagedDevicePathsV1Schema,
888
+ z.object({
889
+ permissionContextVersion: z.never().optional(),
890
+ roots: z.object({
891
+ workspace: z.string().min(1).max(4096),
892
+ skills: z.string().min(1).max(4096),
893
+ tmp: z.string().min(1).max(4096),
664
894
  }),
665
- ])
666
- .optional(),
667
- localhost: z.enum(["on", "off-proxy-detected", "off"]).optional(),
668
- unixSockets: z.enum(["roots", "all-masked", "off"]).optional(),
669
- unattended: z.literal(true).optional(),
670
- /** Auto mode: the mode and its ceiling, and whether the device is a connected machine. */
671
- mode: z.enum(["auto", "sandbox"]).optional(),
672
- allowedMode: z.enum(["auto", "sandbox"]).optional(),
673
- local: z.boolean().optional(),
674
- })),
895
+ tier: z.enum(["strict", "dev", "open"]).optional(),
896
+ isolation: z.enum(["sandbox", "none"]).optional(),
897
+ /** The current network (`none` on events recorded before auto mode). */
898
+ network: z
899
+ .union([
900
+ z.literal("none"),
901
+ z.object({
902
+ kind: z.enum(["open-public", "allowlist"]),
903
+ hosts: z.array(z.string()),
904
+ }),
905
+ ])
906
+ .optional(),
907
+ localhost: z.enum(["on", "off-proxy-detected", "off"]).optional(),
908
+ unixSockets: z.enum(["roots", "all-masked", "off"]).optional(),
909
+ unattended: z.literal(true).optional(),
910
+ /** Auto mode: the mode and its ceiling, and whether the device is a connected machine. */
911
+ mode: z.enum(["auto", "sandbox"]).optional(),
912
+ allowedMode: z.enum(["auto", "sandbox"]).optional(),
913
+ local: z.boolean().optional(),
914
+ }),
915
+ ])),
675
916
  /**
676
917
  * The project a bound conversation's run read at its start (project root spec §4.4): the
677
918
  * project's name and root, its `AGENTS.md` text, and per skill its name, description and digest;
@@ -742,7 +983,15 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
742
983
  }
743
984
  })),
744
985
  /** 工具调用开始执行之前写入(续跑时「有开始无结果」的调用记为结果未知,不再执行)。 */
745
- ev("tool_call_started", z.object({ step: count, callId: z.string(), toolKey: z.string(), specHash: z.string() })),
986
+ ev("tool_call_started", z.object({
987
+ step: count,
988
+ callId: z.string(),
989
+ toolKey: z.string(),
990
+ specHash: z.string(),
991
+ permissionInput: z
992
+ .object({ callInputHash: z.string(), resolvedInputHash: z.string() })
993
+ .optional(),
994
+ })),
746
995
  /**
747
996
  * 工具调用的结果(模型看到的文本)。构建请求时还原为紧随该步 assistant 消息的 user 消息中的
748
997
  * `tool_result` 块。`outputId`:超长结果转存后的存档 id;`contentTypes`:结果里出现的内容类型。
@@ -840,7 +1089,8 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
840
1089
  ev("approval_decided", z.object({
841
1090
  approvalId: z.string(),
842
1091
  callId: z.string(),
843
- decision: z.enum(["approved", "denied", "expired", "cancelled", "skipped"]),
1092
+ decision: z.enum(["approved", "denied", "expired", "cancelled", "skipped", "superseded"]),
1093
+ revision: z.number().int().nonnegative().optional(),
844
1094
  scope: z.enum(["once", "session", "always"]).optional(),
845
1095
  byAccountId: z.string().nullable(),
846
1096
  /**
@@ -0,0 +1,50 @@
1
+ import type { Selectable } from "kysely";
2
+ import type { ConversationsTable } from "../db/kernel-schema.js";
3
+ import { KernelDb } from "../infra/database/kernel-db.js";
4
+ import { ConversationAccess } from "./access.js";
5
+ export type PermissionRoot = Selectable<ConversationsTable>;
6
+ /** Stored root state and the existing live access checks, without profile views or lifecycle calls. */
7
+ export declare class PermissionProfileStore {
8
+ private readonly db;
9
+ private readonly access;
10
+ constructor(db: KernelDb, access: ConversationAccess);
11
+ own(orgId: string, id: string, accountId: string): Promise<{
12
+ account_id: string;
13
+ agent_id: string;
14
+ archived_at: Date | null;
15
+ consumed_seq: string;
16
+ create_request_hash: string | null;
17
+ create_request_id: string | null;
18
+ created_at: Date;
19
+ deleted_at: Date | null;
20
+ device_id: string | null;
21
+ eval_run_id: string | null;
22
+ id: string;
23
+ kind: import("../db/kernel-schema.js").ConversationKind;
24
+ last_seq: string;
25
+ org_id: string;
26
+ parent_conversation_id: string | null;
27
+ permission_consent: unknown;
28
+ permission_profile: "approve-for-me" | "full-access" | "request-approval";
29
+ permission_revision: number;
30
+ project_name: string | null;
31
+ project_path: string | null;
32
+ queue_pause_reason: string | null;
33
+ queue_paused: boolean;
34
+ scheduled_task_id: string | null;
35
+ selection: unknown;
36
+ source: "channel_dm" | "channel_group" | "subagent" | "web";
37
+ subagent_depth: number;
38
+ subagent_type: string | null;
39
+ title: string | null;
40
+ title_attempts: number;
41
+ title_source: import("../db/kernel-schema.js").TitleSource | null;
42
+ tree_stopped_at: Date | null;
43
+ updated_at: Date;
44
+ }>;
45
+ /** Internal stored facts; request callers use readOwnedRoot to check every ancestor. */
46
+ readRoot(orgId: string, id: string): Promise<PermissionRoot>;
47
+ private read;
48
+ /** Keep the existing account, agent visibility and ancestor checks on every read. */
49
+ readOwnedRoot(orgId: string, id: string, accountId: string): Promise<PermissionRoot>;
50
+ }
@@ -0,0 +1,67 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Inject, Injectable } from "@nestjs/common";
11
+ import { ApiError } from "../errors.js";
12
+ import { KernelDb } from "../infra/database/kernel-db.js";
13
+ import { ConversationAccess } from "./access.js";
14
+ /** Stored root state and the existing live access checks, without profile views or lifecycle calls. */
15
+ let PermissionProfileStore = class PermissionProfileStore {
16
+ db;
17
+ access;
18
+ constructor(db, access) {
19
+ this.db = db;
20
+ this.access = access;
21
+ }
22
+ async own(orgId, id, accountId) {
23
+ if (!(await this.access.isAccessible(orgId, id, accountId)))
24
+ throw new ApiError("conversation.not_found", "Conversation not found");
25
+ return this.db
26
+ .selectFrom("conversations")
27
+ .selectAll()
28
+ .where("id", "=", id)
29
+ .where("org_id", "=", orgId)
30
+ .executeTakeFirstOrThrow();
31
+ }
32
+ /** Internal stored facts; request callers use readOwnedRoot to check every ancestor. */
33
+ async readRoot(orgId, id) {
34
+ let row = await this.read(orgId, id);
35
+ for (let depth = 0; row.parent_conversation_id && depth < 16; depth++)
36
+ row = await this.read(orgId, row.parent_conversation_id);
37
+ if (row.parent_conversation_id)
38
+ throw new ApiError("conversation.not_found", "Conversation root not found");
39
+ return row;
40
+ }
41
+ async read(orgId, id) {
42
+ const row = await this.db
43
+ .selectFrom("conversations")
44
+ .selectAll()
45
+ .where("id", "=", id)
46
+ .where("org_id", "=", orgId)
47
+ .executeTakeFirst();
48
+ if (!row)
49
+ throw new ApiError("conversation.not_found", "Conversation not found");
50
+ return row;
51
+ }
52
+ /** Keep the existing account, agent visibility and ancestor checks on every read. */
53
+ async readOwnedRoot(orgId, id, accountId) {
54
+ let row = await this.own(orgId, id, accountId);
55
+ for (let depth = 0; row.parent_conversation_id && depth < 16; depth++)
56
+ row = await this.own(orgId, row.parent_conversation_id, accountId);
57
+ if (row.parent_conversation_id)
58
+ throw new ApiError("conversation.not_found", "Conversation root not found");
59
+ return row;
60
+ }
61
+ };
62
+ PermissionProfileStore = __decorate([
63
+ Injectable(),
64
+ __param(0, Inject(KernelDb)),
65
+ __param(1, Inject(ConversationAccess))
66
+ ], PermissionProfileStore);
67
+ export { PermissionProfileStore };
@@ -0,0 +1,2 @@
1
+ export declare class PermissionProfileStoreModule {
2
+ }
@@ -0,0 +1,19 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Module } from "@nestjs/common";
8
+ import { ConversationAccessModule } from "./access.js";
9
+ import { PermissionProfileStore } from "./permission-profile-store.js";
10
+ let PermissionProfileStoreModule = class PermissionProfileStoreModule {
11
+ };
12
+ PermissionProfileStoreModule = __decorate([
13
+ Module({
14
+ imports: [ConversationAccessModule],
15
+ providers: [PermissionProfileStore],
16
+ exports: [PermissionProfileStore],
17
+ })
18
+ ], PermissionProfileStoreModule);
19
+ export { PermissionProfileStoreModule };
@@ -0,0 +1,84 @@
1
+ import type { FastifyReply } from "fastify";
2
+ import type { z } from "zod";
3
+ import { type Principal } from "../identity/principal.js";
4
+ import { type OrgContext } from "../orgs/org.guard.js";
5
+ import { ConversationsService } from "./conversations.service.js";
6
+ import { PermissionGetParams, PermissionPatchBody, PermissionPreviewQuery } from "./permission-profiles.schemas.js";
7
+ import { PermissionProfilesService } from "./permission-profiles.service.js";
8
+ export declare const FirstMessageBody: z.ZodObject<{
9
+ agentId: z.ZodString;
10
+ deviceId: z.ZodOptional<z.ZodString>;
11
+ project: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
12
+ message: z.ZodNonOptional<z.ZodOptional<z.ZodObject<{
13
+ text: z.ZodString;
14
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
15
+ connectorId: z.ZodUUID;
16
+ uri: z.ZodString;
17
+ }, z.core.$strict>>>;
18
+ files: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
19
+ model: z.ZodOptional<z.ZodObject<{
20
+ provider: z.ZodString;
21
+ model: z.ZodString;
22
+ }, z.core.$strict>>;
23
+ effort: z.ZodOptional<z.ZodEnum<{
24
+ high: "high";
25
+ low: "low";
26
+ max: "max";
27
+ medium: "medium";
28
+ xhigh: "xhigh";
29
+ }>>;
30
+ skill: z.ZodOptional<z.ZodObject<{
31
+ name: z.ZodString;
32
+ }, z.core.$strict>>;
33
+ timeZone: z.ZodOptional<z.ZodString>;
34
+ locale: z.ZodOptional<z.ZodEnum<{
35
+ en: "en";
36
+ zh: "zh";
37
+ }>>;
38
+ clientMessageId: z.ZodString;
39
+ }, z.core.$strict>>>;
40
+ permission: z.ZodObject<{
41
+ profile: z.ZodEnum<{
42
+ "approve-for-me": "approve-for-me";
43
+ "full-access": "full-access";
44
+ "request-approval": "request-approval";
45
+ }>;
46
+ consentScopeRevision: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strict>;
48
+ }, z.core.$strict>;
49
+ export declare class PermissionProfilesController {
50
+ private readonly permissions;
51
+ private readonly conversations;
52
+ constructor(permissions: PermissionProfilesService, conversations: ConversationsService);
53
+ get(org: OrgContext, p: Principal, { id }: z.infer<typeof PermissionGetParams>): Promise<{
54
+ profile: import("@capybara-hq/plugin-sdk").PermissionProfile;
55
+ revision: number;
56
+ rootConversationId: string;
57
+ deviceId: string | null;
58
+ consentScope: {
59
+ deviceId: string;
60
+ scopeRevision: string;
61
+ } | null;
62
+ scopeRevision: string | null;
63
+ availability: import("../sandbox/permission-availability.js").PermissionAvailability;
64
+ fullAccessCeiling: boolean;
65
+ broadProjectReach: boolean;
66
+ startingWorkNotice: string;
67
+ }>;
68
+ set(org: OrgContext, p: Principal, { id }: z.infer<typeof PermissionGetParams>, body: z.infer<typeof PermissionPatchBody>): Promise<{
69
+ revision: number;
70
+ }>;
71
+ preview(org: OrgContext, p: Principal, q: z.infer<typeof PermissionPreviewQuery>): Promise<{
72
+ deviceId: string;
73
+ project: string | null;
74
+ scopeRevision: string;
75
+ availability: import("../sandbox/permission-availability.js").PermissionAvailability;
76
+ fullAccessCeiling: boolean;
77
+ broadProjectReach: boolean;
78
+ }>;
79
+ first(org: OrgContext, p: Principal, body: z.infer<typeof FirstMessageBody>, reply: FastifyReply): Promise<{
80
+ conversation: import("./conversations.service.js").ConversationView;
81
+ event: import("./events.js").ConversationEvent;
82
+ events: import("./events.js").ConversationEvent[];
83
+ }>;
84
+ }