@capybara-hq/kernel 0.1.0-rc.104 → 0.1.0-rc.106

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 (250) hide show
  1. package/dist/agents/agents.schemas.d.ts +9 -9
  2. package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
  3. package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
  4. package/dist/automations/automations.module.d.ts +16 -0
  5. package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
  6. package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
  7. package/dist/automations/automations.schemas.js +253 -0
  8. package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
  9. package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
  10. package/dist/{schedules → automations}/calendar.d.ts +8 -8
  11. package/dist/{schedules → automations}/calendar.js +2 -2
  12. package/dist/automations/effective-settings.d.ts +28 -0
  13. package/dist/automations/effective-settings.js +25 -0
  14. package/dist/automations/errors.d.ts +19 -0
  15. package/dist/automations/errors.js +19 -0
  16. package/dist/automations/events/coalesce.d.ts +28 -0
  17. package/dist/automations/events/coalesce.js +131 -0
  18. package/dist/automations/events/deadline.d.ts +10 -0
  19. package/dist/automations/events/deadline.js +24 -0
  20. package/dist/automations/events/dispatcher.d.ts +74 -0
  21. package/dist/automations/events/dispatcher.js +353 -0
  22. package/dist/automations/events/events.module.d.ts +7 -0
  23. package/dist/automations/events/events.module.js +26 -0
  24. package/dist/automations/events/guards.d.ts +32 -0
  25. package/dist/automations/events/guards.js +87 -0
  26. package/dist/automations/events/sweep.job.d.ts +49 -0
  27. package/dist/automations/events/sweep.job.js +202 -0
  28. package/dist/automations/events/token.d.ts +5 -0
  29. package/dist/automations/events/token.js +5 -0
  30. package/dist/automations/events/trigger-events.service.d.ts +47 -0
  31. package/dist/automations/events/trigger-events.service.js +254 -0
  32. package/dist/{schedules → automations}/fire.d.ts +57 -17
  33. package/dist/{schedules → automations}/fire.js +311 -79
  34. package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
  35. package/dist/{schedules → automations}/grant-rules.js +5 -5
  36. package/dist/automations/job-ids.d.ts +113 -0
  37. package/dist/automations/job-ids.js +117 -0
  38. package/dist/{schedules → automations}/pause.d.ts +3 -3
  39. package/dist/{schedules → automations}/pause.js +3 -3
  40. package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
  41. package/dist/{schedules → automations}/run-tracker.js +68 -56
  42. package/dist/{schedules → automations}/scan.job.d.ts +12 -8
  43. package/dist/{schedules → automations}/scan.job.js +39 -23
  44. package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
  45. package/dist/{schedules → automations}/schedule-math.js +17 -7
  46. package/dist/{schedules → automations}/store.d.ts +57 -27
  47. package/dist/{schedules → automations}/store.js +102 -52
  48. package/dist/automations/store.module.d.ts +6 -0
  49. package/dist/{schedules → automations}/store.module.js +9 -9
  50. package/dist/automations/types.d.ts +178 -0
  51. package/dist/{schedules → automations}/unattended.d.ts +22 -11
  52. package/dist/{schedules → automations}/unattended.js +53 -30
  53. package/dist/catalog/marketplaces.service.d.ts +1 -1
  54. package/dist/channels/channels.module.js +3 -3
  55. package/dist/channels/outbound.d.ts +5 -5
  56. package/dist/channels/outbound.js +17 -17
  57. package/dist/channels/threads.d.ts +1 -1
  58. package/dist/channels/threads.js +1 -1
  59. package/dist/config/schema.d.ts +5 -1
  60. package/dist/config/schema.js +44 -6
  61. package/dist/conversations/approval-profile.d.ts +2 -2
  62. package/dist/conversations/approval-profile.js +3 -3
  63. package/dist/conversations/conversations.controller.d.ts +7 -1
  64. package/dist/conversations/conversations.controller.js +26 -10
  65. package/dist/conversations/conversations.service.d.ts +103 -25
  66. package/dist/conversations/conversations.service.js +138 -33
  67. package/dist/conversations/events.d.ts +48 -1
  68. package/dist/conversations/events.js +61 -9
  69. package/dist/conversations/message-context.d.ts +2 -2
  70. package/dist/conversations/message-context.js +1 -1
  71. package/dist/conversations/permission-profile-store.d.ts +2 -1
  72. package/dist/conversations/permission-profiles.controller.d.ts +3 -0
  73. package/dist/conversations/permission-profiles.service.js +1 -1
  74. package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
  75. package/dist/conversations/prompt-suggestion-request.js +2 -1
  76. package/dist/conversations/queue.d.ts +7 -4
  77. package/dist/conversations/queue.js +6 -2
  78. package/dist/conversations/queue.service.d.ts +5 -5
  79. package/dist/conversations/queue.service.js +20 -14
  80. package/dist/ctx/create-ctx.d.ts +20 -1
  81. package/dist/ctx/create-ctx.js +59 -2
  82. package/dist/db/kernel-schema.d.ts +104 -25
  83. package/dist/devices/device-project-files.service.d.ts +88 -0
  84. package/dist/devices/device-project-files.service.js +249 -0
  85. package/dist/devices/device-projects.service.d.ts +40 -0
  86. package/dist/devices/device-projects.service.js +16 -13
  87. package/dist/devices/devices.controller.d.ts +9 -3
  88. package/dist/devices/devices.controller.js +27 -5
  89. package/dist/devices/devices.module.js +9 -1
  90. package/dist/devices/devices.schemas.js +6 -1
  91. package/dist/devices/dto.d.ts +15 -0
  92. package/dist/devices/dto.js +11 -0
  93. package/dist/devices/project-paths.d.ts +29 -0
  94. package/dist/devices/project-paths.js +66 -0
  95. package/dist/devices/project-rules.d.ts +5 -1
  96. package/dist/devices/project-rules.js +5 -1
  97. package/dist/errors.d.ts +47 -13
  98. package/dist/errors.js +47 -13
  99. package/dist/evals/reconstruct.d.ts +10 -1
  100. package/dist/evals/reconstruct.js +7 -0
  101. package/dist/extensions/host.d.ts +6 -1
  102. package/dist/extensions/host.js +10 -0
  103. package/dist/extensions/permission-set.d.ts +17 -1
  104. package/dist/extensions/permission-set.js +13 -1
  105. package/dist/extensions/permission-view.d.ts +1 -1
  106. package/dist/extensions/permission-view.js +4 -1
  107. package/dist/git/gateway.js +2 -2
  108. package/dist/handoff/app-schemes.d.ts +28 -0
  109. package/dist/handoff/app-schemes.js +41 -0
  110. package/dist/handoff/handoff-paths.d.ts +26 -0
  111. package/dist/handoff/handoff-paths.js +25 -0
  112. package/dist/handoff/handoff-tickets.d.ts +28 -0
  113. package/dist/handoff/handoff-tickets.js +111 -0
  114. package/dist/handoff/handoff.controller.d.ts +24 -0
  115. package/dist/handoff/handoff.controller.js +74 -0
  116. package/dist/handoff/handoff.module.d.ts +7 -0
  117. package/dist/handoff/handoff.module.js +26 -0
  118. package/dist/handoff/handoff.schemas.d.ts +13 -0
  119. package/dist/handoff/handoff.schemas.js +3 -0
  120. package/dist/handoff/handoff.service.d.ts +49 -0
  121. package/dist/handoff/handoff.service.js +96 -0
  122. package/dist/http/api.module.js +13 -5
  123. package/dist/http/meta.controller.d.ts +1 -0
  124. package/dist/http/meta.controller.js +7 -0
  125. package/dist/http/request-signal.d.ts +8 -0
  126. package/dist/http/request-signal.js +14 -0
  127. package/dist/identity/sso.controller.d.ts +30 -6
  128. package/dist/identity/sso.controller.js +51 -17
  129. package/dist/identity/sso.d.ts +10 -2
  130. package/dist/identity/sso.js +15 -3
  131. package/dist/inbox/inbox.module.js +2 -2
  132. package/dist/inbox/inbox.service.d.ts +8 -8
  133. package/dist/inbox/inbox.service.js +7 -7
  134. package/dist/infra/config/kernel-config.service.js +10 -5
  135. package/dist/infra/outbox/registry.d.ts +29 -2
  136. package/dist/infra/outbox/registry.js +30 -7
  137. package/dist/kernel.module.js +3 -0
  138. package/dist/orgs/roles.d.ts +1 -1
  139. package/dist/orgs/roles.js +3 -3
  140. package/dist/orgs/settings.controller.d.ts +1 -1
  141. package/dist/orgs/settings.service.d.ts +27 -11
  142. package/dist/orgs/settings.service.js +42 -24
  143. package/dist/overrides.d.ts +4 -4
  144. package/dist/overrides.js +1 -1
  145. package/dist/platform/exclusions.js +5 -0
  146. package/dist/platform/operation.js +2 -2
  147. package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
  148. package/dist/platform/ops/automations.ops.js +560 -0
  149. package/dist/platform/ops/connectors.ops.js +4 -2
  150. package/dist/platform/ops/devices.ops.d.ts +3 -1
  151. package/dist/platform/ops/devices.ops.js +77 -3
  152. package/dist/platform/ops/inbox.ops.js +4 -4
  153. package/dist/platform/ops/orgs.ops.js +1 -1
  154. package/dist/platform/ops/platform.ops.js +4 -4
  155. package/dist/platform/platform-ops.module.d.ts +2 -2
  156. package/dist/platform/platform-ops.module.js +5 -5
  157. package/dist/platform/route-schemas.js +3 -3
  158. package/dist/push/jobs.d.ts +3 -3
  159. package/dist/push/jobs.js +2 -2
  160. package/dist/push/preferences.service.js +1 -1
  161. package/dist/push/push-owed.d.ts +3 -3
  162. package/dist/push/push-owed.js +6 -6
  163. package/dist/push/push.schemas.d.ts +4 -4
  164. package/dist/push/push.schemas.js +3 -3
  165. package/dist/push/recipients.d.ts +4 -4
  166. package/dist/push/recipients.js +23 -23
  167. package/dist/push/texts.d.ts +3 -3
  168. package/dist/push/texts.js +2 -2
  169. package/dist/push/triggers.d.ts +1 -1
  170. package/dist/roles/worker.module.js +3 -3
  171. package/dist/runtime/compaction.service.d.ts +3 -1
  172. package/dist/runtime/compaction.service.js +3 -1
  173. package/dist/runtime/context/build.d.ts +6 -0
  174. package/dist/runtime/context/build.js +14 -3
  175. package/dist/runtime/context/compaction.d.ts +27 -1
  176. package/dist/runtime/context/compaction.js +102 -37
  177. package/dist/runtime/context/run-context.d.ts +38 -0
  178. package/dist/runtime/context/run-context.js +54 -0
  179. package/dist/runtime/maintenance.d.ts +8 -4
  180. package/dist/runtime/maintenance.js +37 -16
  181. package/dist/runtime/model-call.d.ts +6 -4
  182. package/dist/runtime/model-call.js +17 -7
  183. package/dist/runtime/project/knowledge.service.d.ts +16 -7
  184. package/dist/runtime/project/knowledge.service.js +31 -13
  185. package/dist/runtime/run-finish.d.ts +4 -4
  186. package/dist/runtime/run-finish.js +3 -3
  187. package/dist/runtime/run-queue.js +12 -7
  188. package/dist/runtime/run-worker.js +7 -1
  189. package/dist/runtime/runtime.module.js +3 -3
  190. package/dist/runtime/subagents/dispatch.js +11 -3
  191. package/dist/sandbox/browse-roots.d.ts +8 -0
  192. package/dist/sandbox/browse-roots.js +22 -0
  193. package/dist/sandbox/network-grants.d.ts +4 -4
  194. package/dist/sandbox/network-grants.js +7 -7
  195. package/dist/sandbox/operation-authority.d.ts +10 -3
  196. package/dist/sandbox/operation-authority.js +20 -10
  197. package/dist/sandbox/operation-intents.d.ts +3 -1
  198. package/dist/sandbox/operation-intents.js +11 -4
  199. package/dist/sandbox/permission-call-grants.js +2 -2
  200. package/dist/sandbox/permission-facts.js +1 -1
  201. package/dist/sandbox/review/classifier.d.ts +2 -2
  202. package/dist/sandbox/review/classifier.js +22 -11
  203. package/dist/sandbox/review/permission-candidate.d.ts +1 -1
  204. package/dist/sandbox/review/permission-candidate.js +1 -1
  205. package/dist/sandbox/sandbox.service.d.ts +15 -5
  206. package/dist/sandbox/sandbox.service.js +14 -8
  207. package/dist/storage/purge.d.ts +1 -1
  208. package/dist/storage/purge.js +2 -2
  209. package/dist/tools/approvals.service.d.ts +6 -6
  210. package/dist/tools/approvals.service.js +19 -19
  211. package/dist/tools/builtin-names.d.ts +12 -12
  212. package/dist/tools/builtin-names.js +29 -29
  213. package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
  214. package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
  215. package/dist/tools/builtins/builtin-tools.d.ts +8 -8
  216. package/dist/tools/builtins/builtin-tools.js +16 -16
  217. package/dist/tools/call-scope.d.ts +1 -1
  218. package/dist/tools/connectors.service.d.ts +4 -13
  219. package/dist/tools/connectors.service.js +12 -21
  220. package/dist/tools/git-asks.js +1 -1
  221. package/dist/tools/git-push-policy.d.ts +3 -3
  222. package/dist/tools/git-push-policy.js +6 -6
  223. package/dist/tools/network-asks.d.ts +3 -3
  224. package/dist/tools/network-asks.js +3 -3
  225. package/dist/tools/oauth/flow.d.ts +16 -2
  226. package/dist/tools/oauth/flow.js +23 -4
  227. package/dist/tools/oauth/oauth.controller.d.ts +19 -7
  228. package/dist/tools/oauth/oauth.controller.js +42 -12
  229. package/dist/tools/oauth/oauth.schemas.d.ts +14 -1
  230. package/dist/tools/oauth/oauth.schemas.js +4 -1
  231. package/dist/tools/pipeline.d.ts +4 -4
  232. package/dist/tools/pipeline.js +2 -2
  233. package/dist/tools/policy.d.ts +3 -3
  234. package/dist/tools/policy.js +3 -3
  235. package/dist/tools/tools.module.js +9 -9
  236. package/package.json +3 -3
  237. package/src/migrations/0188_automations_rename.sql +309 -0
  238. package/src/migrations/0189_event_automations.sql +136 -0
  239. package/dist/platform/ops/schedules.ops.js +0 -509
  240. package/dist/schedules/effective-settings.d.ts +0 -22
  241. package/dist/schedules/effective-settings.js +0 -18
  242. package/dist/schedules/errors.d.ts +0 -8
  243. package/dist/schedules/errors.js +0 -8
  244. package/dist/schedules/job-ids.d.ts +0 -81
  245. package/dist/schedules/job-ids.js +0 -95
  246. package/dist/schedules/schedules.module.d.ts +0 -16
  247. package/dist/schedules/schedules.schemas.js +0 -213
  248. package/dist/schedules/store.module.d.ts +0 -6
  249. package/dist/schedules/types.d.ts +0 -110
  250. /package/dist/{schedules → automations}/types.js +0 -0
@@ -0,0 +1,88 @@
1
+ import { ApiError } from "../errors.js";
2
+ import type { KernelLogger } from "../log.js";
3
+ import { SandboxService } from "../sandbox/sandbox.service.js";
4
+ import { DeviceProjectsService } from "./device-projects.service.js";
5
+ /**
6
+ * The most project files one message references (composer menus §5); `statAll` checks no more.
7
+ * Defined here (conversations re-export it) so the devices module needs no conversations import.
8
+ */
9
+ export declare const MAX_PROJECT_FILES = 10;
10
+ /** The most entries one listing answers (composer menus §5). */
11
+ export declare const MAX_PROJECT_FILE_ENTRIES = 200;
12
+ /** One entry of a project directory: `path` is relative to the project root. */
13
+ export interface ProjectFileEntry {
14
+ name: string;
15
+ path: string;
16
+ kind: "file" | "dir";
17
+ /** The file's size in bytes, when the device reports it (a directory listing does not). */
18
+ size?: number;
19
+ }
20
+ /** `GET /devices/:id/projects/:name/files`. */
21
+ export interface ProjectFileList {
22
+ entries: ProjectFileEntry[];
23
+ /** More entries matched than {@link MAX_PROJECT_FILE_ENTRIES} (or than the device listed). */
24
+ truncated: boolean;
25
+ }
26
+ /** The device cannot list its directories for its owner (409 `device.list_unsupported`). */
27
+ export declare const listUnsupported: () => ApiError;
28
+ /**
29
+ * The files of a device's project (composer menus §5): one directory per call, read through the
30
+ * owner browse scope (`SandboxService.ensureRunningForOwner`, then `SandboxService.withBrowse` as
31
+ * the device's owner: metadata only, never file contents, never a write). Every path is relative
32
+ * to the project root and normalized by {@link projectRelativePath} before the device is asked,
33
+ * so the kernel never names a path outside the root; what lies behind a symlink below it is the
34
+ * provider's and its browse scope's to judge. Only the device's owner reads it (anyone else gets
35
+ * `device.not_found`, from the project lookup).
36
+ */
37
+ export declare class DeviceProjectFilesService {
38
+ private readonly projects;
39
+ private readonly sandbox;
40
+ private readonly log;
41
+ constructor(projects: Pick<DeviceProjectsService, "resolveForBinding">, sandbox: Pick<SandboxService, "withBrowse" | "ensureRunningForOwner">, log: Pick<KernelLogger, "warn">);
42
+ /**
43
+ * Lists the directory `opts.path` (relative to the project `projectName`, the root when absent)
44
+ * of the owner's device: directories first, then files, each group by name (ignoring case);
45
+ * `opts.q` keeps the names that contain it (case-insensitive). The device is asked for as many
46
+ * entries as the protocol allows, sorted here, then cut to {@link MAX_PROJECT_FILE_ENTRIES}. The
47
+ * browse scope is rooted at the project path (narrowed from the owner's ceiling).
48
+ * Refused with `device.path_outside_project` (before anything is read), `device.not_found`,
49
+ * `device.project_not_found`, `device.list_unsupported`, the device codes of the projects
50
+ * routes (`device.offline`, `device.not_running`, `device.projects_unavailable`) and the
51
+ * `list` refusals of adding a project (`device.project_path_missing`, `…_unreadable`,
52
+ * `…_outside_mode`, `device.project_refused`).
53
+ */
54
+ list(orgId: string, accountId: string, deviceId: string, projectName: string, opts: {
55
+ path?: string;
56
+ q?: string;
57
+ }, signal?: AbortSignal): Promise<ProjectFileList>;
58
+ /**
59
+ * Which of `paths` (relative to the project rooted at `projectPath`) are not files the device
60
+ * reports, asked with `stat` inside one owner browse of the conversation owner's device: a
61
+ * missing path, a directory or one the browse scope refuses counts as missing. Each path is
62
+ * normalized first ({@link projectFilePath}; one that leaves the project or names its root is
63
+ * refused with `device.path_outside_project` before the device is asked); `missing` holds the
64
+ * normalized paths. The browse scope is rooted at `projectPath`, which must be absolute and normalized
65
+ * (an internal error otherwise), and at most {@link MAX_PROJECT_FILES} paths are checked (more
66
+ * is an internal error: the send route bounds them first). The device codes of {@link list}
67
+ * pass on as they are.
68
+ */
69
+ statAll(ctx: {
70
+ orgId: string;
71
+ accountId: string;
72
+ deviceId: string;
73
+ }, projectPath: string, paths: string[], signal?: AbortSignal): Promise<{
74
+ missing: string[];
75
+ }>;
76
+ /** The owner's project (`resolveForBinding`); a device that offers no listing → `list_unsupported`. */
77
+ private project;
78
+ /**
79
+ * Runs `fn` in the owner browse of the device (`ensureRunningForOwner` first, so a stopped device
80
+ * is started for its owner), its scope rooted at `root` (the project path; narrowed from the
81
+ * owner's ceiling, never wider, `device.project_outside_mode` when they do not meet, checked
82
+ * before the device is started), mapped
83
+ * like the projects routes: kernel refusals stay, a provider
84
+ * without owner browsing is `device.list_unsupported`, an offline machine `device.offline`, an
85
+ * unreachable provider and anything else `device.projects_unavailable`, never a 500.
86
+ */
87
+ private onDevice;
88
+ }
@@ -0,0 +1,249 @@
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 { isDeviceOfflineError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, MAX_DEVICE_LIST_ENTRIES, } from "@capybara-hq/plugin-sdk";
11
+ import { Inject, Injectable } from "@nestjs/common";
12
+ import { deviceOffline } from "../dial-in/relay.js";
13
+ import { ApiError } from "../errors.js";
14
+ import { KERNEL_LOGGER } from "../infra/tokens.js";
15
+ import { SandboxService } from "../sandbox/sandbox.service.js";
16
+ import { SandboxProviderUnreachableError } from "../sandbox/unreachable.js";
17
+ import { browseReader, DeviceProjectsService, listFailure, passThrough, providerUnreachable, unavailable, } from "./device-projects.service.js";
18
+ import { joinProjectPath, projectFilePath, projectRelativePath } from "./project-paths.js";
19
+ import { clipped } from "./project-rules.js";
20
+ /**
21
+ * The most project files one message references (composer menus §5); `statAll` checks no more.
22
+ * Defined here (conversations re-export it) so the devices module needs no conversations import.
23
+ */
24
+ export const MAX_PROJECT_FILES = 10;
25
+ /** The most entries one listing answers (composer menus §5). */
26
+ export const MAX_PROJECT_FILE_ENTRIES = 200;
27
+ /** The device cannot list its directories for its owner (409 `device.list_unsupported`). */
28
+ export const listUnsupported = () => new ApiError("device.list_unsupported", "This device's provider cannot list its directories, so its project files cannot be browsed");
29
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it drops
30
+ const CONTROL = /[\u0000-\u001f\u007f]/;
31
+ /** A name the device answered that the kernel passes on: one plain path segment. */
32
+ const plainName = (name) => name !== "" &&
33
+ name !== "." &&
34
+ name !== ".." &&
35
+ name.length <= 255 &&
36
+ !name.includes("/") &&
37
+ !name.includes("\\") &&
38
+ !CONTROL.test(name);
39
+ /** Folders first, then files; each by name ignoring case, ties by code unit. */
40
+ const byKindThenName = (a, b) => {
41
+ if (a.kind !== b.kind)
42
+ return a.kind === "dir" ? -1 : 1;
43
+ const ci = a.name.localeCompare(b.name, "en", { sensitivity: "base" });
44
+ if (ci !== 0)
45
+ return ci;
46
+ return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
47
+ };
48
+ /** The device answered in a shape the kernel does not accept (503, never a 500). */
49
+ const malformed = () => new ApiError("device.projects_unavailable", "The device answered in a form this kernel does not accept; update its device program or plugin");
50
+ /** A provider's `list` answer checked before the kernel reads it (the device is not trusted). */
51
+ function checkedListing(raw) {
52
+ if (raw === null)
53
+ return null;
54
+ if (typeof raw !== "object" || raw === undefined)
55
+ throw malformed();
56
+ const r = raw;
57
+ if (!Array.isArray(r.entries) || typeof r.truncated !== "boolean")
58
+ throw malformed();
59
+ if (r.entries.length > MAX_DEVICE_LIST_ENTRIES)
60
+ throw malformed();
61
+ const entries = r.entries.map((e) => {
62
+ if (typeof e !== "object" || e === null)
63
+ throw malformed();
64
+ const { name, isDir } = e;
65
+ if (typeof name !== "string" || typeof isDir !== "boolean")
66
+ throw malformed();
67
+ return { name, isDir };
68
+ });
69
+ return { entries, truncated: r.truncated };
70
+ }
71
+ /** A provider's `stat` answer checked before the kernel reads it. */
72
+ function checkedStat(raw) {
73
+ if (raw === null)
74
+ return null;
75
+ if (typeof raw !== "object" || raw === undefined)
76
+ throw malformed();
77
+ const { size, isDir } = raw;
78
+ if (typeof size !== "number" || typeof isDir !== "boolean")
79
+ throw malformed();
80
+ return { size, isDir };
81
+ }
82
+ /**
83
+ * The files of a device's project (composer menus §5): one directory per call, read through the
84
+ * owner browse scope (`SandboxService.ensureRunningForOwner`, then `SandboxService.withBrowse` as
85
+ * the device's owner: metadata only, never file contents, never a write). Every path is relative
86
+ * to the project root and normalized by {@link projectRelativePath} before the device is asked,
87
+ * so the kernel never names a path outside the root; what lies behind a symlink below it is the
88
+ * provider's and its browse scope's to judge. Only the device's owner reads it (anyone else gets
89
+ * `device.not_found`, from the project lookup).
90
+ */
91
+ let DeviceProjectFilesService = class DeviceProjectFilesService {
92
+ projects;
93
+ sandbox;
94
+ log;
95
+ constructor(projects, sandbox, log) {
96
+ this.projects = projects;
97
+ this.sandbox = sandbox;
98
+ this.log = log;
99
+ }
100
+ /**
101
+ * Lists the directory `opts.path` (relative to the project `projectName`, the root when absent)
102
+ * of the owner's device: directories first, then files, each group by name (ignoring case);
103
+ * `opts.q` keeps the names that contain it (case-insensitive). The device is asked for as many
104
+ * entries as the protocol allows, sorted here, then cut to {@link MAX_PROJECT_FILE_ENTRIES}. The
105
+ * browse scope is rooted at the project path (narrowed from the owner's ceiling).
106
+ * Refused with `device.path_outside_project` (before anything is read), `device.not_found`,
107
+ * `device.project_not_found`, `device.list_unsupported`, the device codes of the projects
108
+ * routes (`device.offline`, `device.not_running`, `device.projects_unavailable`) and the
109
+ * `list` refusals of adding a project (`device.project_path_missing`, `…_unreadable`,
110
+ * `…_outside_mode`, `device.project_refused`).
111
+ */
112
+ async list(orgId, accountId, deviceId, projectName, opts, signal = new AbortController().signal) {
113
+ const rel = projectRelativePath(opts.path ?? "");
114
+ const q = (opts.q ?? "").trim().toLowerCase();
115
+ const project = await this.project(orgId, accountId, deviceId, projectName);
116
+ const abs = joinProjectPath(project.path, rel);
117
+ const label = rel === "" ? "The project root" : rel;
118
+ // the whole directory as far as the device answers: sorted here before the cut, so a folder
119
+ // listed late by the device is not lost behind the first page of files
120
+ const answer = await this.onDevice(orgId, accountId, deviceId, project.path, signal, async (b, sig) => {
121
+ let raw;
122
+ try {
123
+ raw = await b.list(abs, { limit: MAX_DEVICE_LIST_ENTRIES, signal: sig });
124
+ }
125
+ catch (e) {
126
+ throw await listFailure(e, browseReader(b, project.path), abs, sig, (err, statErr) => this.log.warn("device project files: the device could not list", {
127
+ deviceId,
128
+ err,
129
+ statErr,
130
+ }), label);
131
+ }
132
+ return checkedListing(raw);
133
+ });
134
+ if (answer === null) {
135
+ throw new ApiError("device.project_path_missing", `${clipped(label)} does not exist on the device`);
136
+ }
137
+ const matched = answer.entries
138
+ .filter((e) => plainName(e.name) && (q === "" || e.name.toLowerCase().includes(q)))
139
+ .map((e) => ({
140
+ name: e.name,
141
+ path: rel === "" ? e.name : `${rel}/${e.name}`,
142
+ kind: e.isDir ? "dir" : "file",
143
+ }))
144
+ .sort(byKindThenName);
145
+ return {
146
+ entries: matched.slice(0, MAX_PROJECT_FILE_ENTRIES),
147
+ truncated: answer.truncated || matched.length > MAX_PROJECT_FILE_ENTRIES,
148
+ };
149
+ }
150
+ /**
151
+ * Which of `paths` (relative to the project rooted at `projectPath`) are not files the device
152
+ * reports, asked with `stat` inside one owner browse of the conversation owner's device: a
153
+ * missing path, a directory or one the browse scope refuses counts as missing. Each path is
154
+ * normalized first ({@link projectFilePath}; one that leaves the project or names its root is
155
+ * refused with `device.path_outside_project` before the device is asked); `missing` holds the
156
+ * normalized paths. The browse scope is rooted at `projectPath`, which must be absolute and normalized
157
+ * (an internal error otherwise), and at most {@link MAX_PROJECT_FILES} paths are checked (more
158
+ * is an internal error: the send route bounds them first). The device codes of {@link list}
159
+ * pass on as they are.
160
+ */
161
+ async statAll(ctx, projectPath, paths, signal = new AbortController().signal) {
162
+ // refuses a project path that is not absolute and normalized (a kernel bug, never the person's)
163
+ joinProjectPath(projectPath, "");
164
+ if (paths.length > MAX_PROJECT_FILES) {
165
+ throw new Error(`statAll: ${paths.length} paths, more than the ${MAX_PROJECT_FILES} one message references`);
166
+ }
167
+ const rels = paths.map((p) => projectFilePath(p));
168
+ if (rels.length === 0)
169
+ return { missing: [] };
170
+ return this.onDevice(ctx.orgId, ctx.accountId, ctx.deviceId, projectPath, signal, async (b, sig) => {
171
+ const missing = [];
172
+ for (const rel of rels) {
173
+ let st;
174
+ try {
175
+ st = checkedStat(await b.stat(joinProjectPath(projectPath, rel), sig));
176
+ }
177
+ catch (e) {
178
+ // the owner browse scope refusing the path: not a file this person can reference
179
+ if (isSandboxScopeDeniedError(e)) {
180
+ missing.push(rel);
181
+ continue;
182
+ }
183
+ if (e instanceof ApiError)
184
+ throw e;
185
+ const passed = passThrough(e);
186
+ if (passed !== undefined)
187
+ throw passed;
188
+ this.log.warn("device project files: the device could not stat", {
189
+ deviceId: ctx.deviceId,
190
+ err: e,
191
+ });
192
+ throw unavailable(e);
193
+ }
194
+ if (st === null || st.isDir)
195
+ missing.push(rel);
196
+ }
197
+ return { missing };
198
+ });
199
+ }
200
+ /** The owner's project (`resolveForBinding`); a device that offers no listing → `list_unsupported`. */
201
+ async project(orgId, accountId, deviceId, name) {
202
+ try {
203
+ return await this.projects.resolveForBinding(orgId, deviceId, accountId, name);
204
+ }
205
+ catch (e) {
206
+ if (e instanceof ApiError && e.code === "device.projects_unsupported")
207
+ throw listUnsupported();
208
+ throw e;
209
+ }
210
+ }
211
+ /**
212
+ * Runs `fn` in the owner browse of the device (`ensureRunningForOwner` first, so a stopped device
213
+ * is started for its owner), its scope rooted at `root` (the project path; narrowed from the
214
+ * owner's ceiling, never wider, `device.project_outside_mode` when they do not meet, checked
215
+ * before the device is started), mapped
216
+ * like the projects routes: kernel refusals stay, a provider
217
+ * without owner browsing is `device.list_unsupported`, an offline machine `device.offline`, an
218
+ * unreachable provider and anything else `device.projects_unavailable`, never a 500.
219
+ */
220
+ async onDevice(orgId, accountId, deviceId, root, signal, fn) {
221
+ try {
222
+ const narrow = { readRoots: [root] };
223
+ await this.sandbox.ensureRunningForOwner({ orgId, deviceId, accountId }, signal, narrow);
224
+ return await this.sandbox.withBrowse({ orgId, deviceId, accountId }, fn, signal, narrow);
225
+ }
226
+ catch (e) {
227
+ // the owner and org ceilings permitting no browsing: this device offers no listing here
228
+ if (e instanceof ApiError && e.code === "device.projects_unsupported")
229
+ throw listUnsupported();
230
+ if (e instanceof ApiError)
231
+ throw e;
232
+ if (isSandboxPermissionUnsupportedError(e))
233
+ throw listUnsupported();
234
+ if (isDeviceOfflineError(e))
235
+ throw deviceOffline();
236
+ if (e instanceof SandboxProviderUnreachableError)
237
+ throw providerUnreachable();
238
+ this.log.warn("device project files: the device could not be asked", { deviceId, err: e });
239
+ throw unavailable(e);
240
+ }
241
+ }
242
+ };
243
+ DeviceProjectFilesService = __decorate([
244
+ Injectable(),
245
+ __param(0, Inject(DeviceProjectsService)),
246
+ __param(1, Inject(SandboxService)),
247
+ __param(2, Inject(KERNEL_LOGGER))
248
+ ], DeviceProjectFilesService);
249
+ export { DeviceProjectFilesService };
@@ -1,3 +1,4 @@
1
+ import { type SandboxBrowse } from "@capybara-hq/plugin-sdk";
1
2
  import { ApiError } from "../errors.js";
2
3
  import { KernelDb } from "../infra/database/kernel-db.js";
3
4
  import { TransactionHost } from "../infra/database/transaction-host.js";
@@ -10,6 +11,20 @@ import { type DeviceProjectScope } from "./project-rules.js";
10
11
  export type { DeviceProjectScope } from "./project-rules.js";
11
12
  /** The most projects one device keeps (project root §4.1). */
12
13
  export declare const MAX_DEVICE_PROJECTS = 100;
14
+ /**
15
+ * What the projects service asks a device: list, scan and stat, never file contents, through the
16
+ * owner browse scope (`SandboxService.withBrowse`: owner-authenticated, no conversation, no Full
17
+ * consent, its roots from the owner's browsing ceiling).
18
+ */
19
+ export interface ProjectReader {
20
+ /** The workspace root: the last known one. */
21
+ workspace: string;
22
+ list?: (path: string, limit: number, signal: AbortSignal) => ReturnType<NonNullable<SandboxBrowse["list"]>>;
23
+ scan?: (base: string, signal: AbortSignal) => ReturnType<NonNullable<SandboxBrowse["scan"]>>;
24
+ stat: (path: string, signal: AbortSignal) => ReturnType<SandboxBrowse["stat"]>;
25
+ }
26
+ /** The owner browse route's reader: the browse scope's stat / list / scan only. */
27
+ export declare function browseReader(b: SandboxBrowse, workspace: string): ProjectReader;
13
28
  /** A project as the web and the Platform tool see it. */
14
29
  export interface DeviceProjectView {
15
30
  name: string;
@@ -146,3 +161,28 @@ export declare class DeviceProjectsService {
146
161
  }
147
162
  /** A project read on a device whose sandbox provider cannot be reached (the projects routes). */
148
163
  export declare const providerUnreachable: () => ApiError;
164
+ /**
165
+ * An error the projects service passes on as it is: a lost instance or file system (for the
166
+ * sandbox service to handle), a kernel refusal (offline, busy, unavailable), an unreachable
167
+ * provider; a malformed device answer becomes `device.projects_unavailable` (the program's fault).
168
+ * Undefined for anything else.
169
+ */
170
+ export declare function passThrough(e: unknown): unknown;
171
+ /**
172
+ * The device could not be asked now (a failure on the machine or at the provider, an abort, a lost
173
+ * lease): 503 `device.projects_unavailable`. Only a `ToolError`'s message (the relay's, written for
174
+ * people) is passed on; a provider's own error text is not.
175
+ */
176
+ export declare function unavailable(e: unknown): ApiError;
177
+ /**
178
+ * What a failed `list(path)` becomes. A provider's `ProjectPathRefusedError` is
179
+ * `device.project_refused` with its reason; the owner browse scope refusing the path is the
180
+ * device refusing it (`device.project_outside_mode`, the browse scope gives no reason). Any other
181
+ * error alone cannot tell a file or an unreadable directory from a failure on the device, so the
182
+ * device is asked `stat(path)`: a file or a directory it cannot list is the path's problem (422 `device.project_path_unreadable`), a
183
+ * missing path `device.project_path_missing`, and a `stat` that fails too means the device could
184
+ * not be asked (503 `device.projects_unavailable`).
185
+ */
186
+ export declare function listFailure(e: unknown, r: ProjectReader, path: string, signal: AbortSignal, logUnavailable: (err: unknown, statErr: unknown) => void,
187
+ /** How the messages name the path (default: the path itself). */
188
+ label?: string): Promise<unknown>;
@@ -32,7 +32,7 @@ import { aboveHome } from "./working-root.js";
32
32
  /** The most projects one device keeps (project root §4.1). */
33
33
  export const MAX_DEVICE_PROJECTS = 100;
34
34
  /** The owner browse route's reader: the browse scope's stat / list / scan only. */
35
- function browseReader(b, workspace) {
35
+ export function browseReader(b, workspace) {
36
36
  return {
37
37
  workspace,
38
38
  list: (path, limit, signal) => b.list(path, { limit, signal }),
@@ -173,9 +173,9 @@ let DeviceProjectsService = class DeviceProjectsService {
173
173
  const early = baseOf(scope);
174
174
  const path = trimSlash(posix.normalize(posix.join(early, input.path === "" ? "." : input.path)));
175
175
  if (aboveHome(path, scope.home))
176
- throw tooBroad(path);
176
+ throw tooBroad(input.name);
177
177
  const resolved = await this.onDevice(orgId, accountId, deviceId, scope, signal, async (r, sig) => {
178
- const path = resolve(scope, r.workspace, input.path);
178
+ const path = resolve(scope, r.workspace, input.path, input.name);
179
179
  const name = input.name ?? posix.basename(path);
180
180
  if (!isDeviceProjectName(name))
181
181
  throw nameInvalid(name);
@@ -391,15 +391,16 @@ const trimSlash = (path) => path.length > 1 && path.endsWith("/") ? path.slice(0
391
391
  /**
392
392
  * The absolute path of `relative` against the scope's base (the home its provider reported, else
393
393
  * the instance's `workspace`), normalized; refused when the result is not a valid device path or
394
- * lies above the owner's home. Where a project may lie below that is the provider's rule.
394
+ * lies above the owner's home (named by `name`, the project's, when given). Where a project may
395
+ * lie below that is the provider's rule.
395
396
  */
396
- function resolve(scope, workspace, relative) {
397
+ function resolve(scope, workspace, relative, name) {
397
398
  const base = baseOf(scope, workspace);
398
399
  const path = trimSlash(posix.normalize(posix.join(base, relative === "" ? "." : relative)));
399
400
  if (validateSandboxPathShape(path).length > 0)
400
401
  throw outsideMode(path);
401
402
  if (aboveHome(path, scope.home))
402
- throw tooBroad(path);
403
+ throw tooBroad(name);
403
404
  return path;
404
405
  }
405
406
  /**
@@ -408,7 +409,7 @@ function resolve(scope, workspace, relative) {
408
409
  * provider; a malformed device answer becomes `device.projects_unavailable` (the program's fault).
409
410
  * Undefined for anything else.
410
411
  */
411
- function passThrough(e) {
412
+ export function passThrough(e) {
412
413
  if (isSandboxGoneError(e) || isFileSystemGoneError(e) || e instanceof ApiError)
413
414
  return e;
414
415
  if (e instanceof SandboxProviderUnreachableError)
@@ -423,7 +424,7 @@ function passThrough(e) {
423
424
  * lease): 503 `device.projects_unavailable`. Only a `ToolError`'s message (the relay's, written for
424
425
  * people) is passed on; a provider's own error text is not.
425
426
  */
426
- function unavailable(e) {
427
+ export function unavailable(e) {
427
428
  return new ApiError("device.projects_unavailable", e instanceof ToolError
428
429
  ? `The device could not be asked now: ${clipped(e.message)}`
429
430
  : "The device could not be asked now; try again shortly");
@@ -438,7 +439,9 @@ const pathMissing = (path) => new ApiError("device.project_path_missing", `${cli
438
439
  * missing path `device.project_path_missing`, and a `stat` that fails too means the device could
439
440
  * not be asked (503 `device.projects_unavailable`).
440
441
  */
441
- async function listFailure(e, r, path, signal, logUnavailable) {
442
+ export async function listFailure(e, r, path, signal, logUnavailable,
443
+ /** How the messages name the path (default: the path itself). */
444
+ label = path) {
442
445
  const passed = passThrough(e);
443
446
  if (passed !== undefined)
444
447
  return passed;
@@ -449,7 +452,7 @@ async function listFailure(e, r, path, signal, logUnavailable) {
449
452
  }
450
453
  // the owner browse scope refusing the path is the device refusing it
451
454
  if (isSandboxScopeDeniedError(e)) {
452
- return new ApiError("device.project_outside_mode", `The device refused ${clipped(path)}: it is outside what the device lets a project reach`);
455
+ return new ApiError("device.project_outside_mode", `The device refused ${clipped(label)}: it is outside what the device lets a project reach`);
453
456
  }
454
457
  let st;
455
458
  try {
@@ -463,9 +466,9 @@ async function listFailure(e, r, path, signal, logUnavailable) {
463
466
  return unavailable(e);
464
467
  }
465
468
  if (st === null)
466
- return pathMissing(path);
469
+ return pathMissing(label);
467
470
  return new ApiError("device.project_path_unreadable", st.isDir
468
- ? `${clipped(path)} is a directory the device cannot read`
469
- : `${clipped(path)} is a file, not a directory`);
471
+ ? `${clipped(label)} is a directory the device cannot read`
472
+ : `${clipped(label)} is a file, not a directory`);
470
473
  }
471
474
  const relativeTo = (base, path) => path === base ? "" : posix.relative(base, path);
@@ -1,9 +1,10 @@
1
1
  import type { z } from "zod";
2
2
  import { type Principal } from "../identity/principal.js";
3
3
  import { type OrgContext } from "../orgs/org.guard.js";
4
+ import { DeviceProjectFilesService, type ProjectFileList } from "./device-project-files.service.js";
4
5
  import { type DeviceProjectCandidates, type DeviceProjectList, DeviceProjectsService, type DeviceProjectView } from "./device-projects.service.js";
5
6
  import { type DeviceList, DevicesService, type DeviceView } from "./devices.service.js";
6
- import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type DeviceProjectAddBody, type DeviceProjectParams } from "./dto.js";
7
+ import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type DeviceProjectAddBody, type DeviceProjectFilesQuery, type DeviceProjectParams } from "./dto.js";
7
8
  /**
8
9
  * A person's devices in an org (`/api/v1/orgs/:orgId/devices`, spec
9
10
  * 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
@@ -28,12 +29,16 @@ import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type De
28
29
  * `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
29
30
  * `GET /:id/projects/candidates` → the device's suggestions under its base;
30
31
  * `POST /:id/projects { path, name? }` → 201 `{ project }` (path relative to the base);
31
- * `DELETE /:id/projects/:name` → 204 (idempotent).
32
+ * `DELETE /:id/projects/:name` → 204 (idempotent);
33
+ * `GET /:id/projects/:name/files?path=&q=` → `{ entries, truncated }`: one directory of the
34
+ * project (path relative to its root; 422 `device.path_outside_project` for one leaving it),
35
+ * read through the owner browse scope (composer menus §5).
32
36
  */
33
37
  export declare class DevicesController {
34
38
  private readonly devices;
35
39
  private readonly projects;
36
- constructor(devices: DevicesService, projects: DeviceProjectsService);
40
+ private readonly files;
41
+ constructor(devices: DevicesService, projects: DeviceProjectsService, files: DeviceProjectFilesService);
37
42
  list(principal: Principal, org: OrgContext): Promise<DeviceList>;
38
43
  create(principal: Principal, org: OrgContext, body: z.infer<typeof DeviceCreateBody>): Promise<{
39
44
  device: DeviceView;
@@ -48,6 +53,7 @@ export declare class DevicesController {
48
53
  resetFiles(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<void>;
49
54
  listProjects(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectList>;
50
55
  projectCandidates(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectCandidates>;
56
+ listProjectFiles(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceProjectParams>, query: z.infer<typeof DeviceProjectFilesQuery>): Promise<ProjectFileList>;
51
57
  addProject(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>, body: z.infer<typeof DeviceProjectAddBody>): Promise<{
52
58
  project: DeviceProjectView;
53
59
  }>;
@@ -9,11 +9,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Controller, Delete, Get, HttpCode, Inject, Patch, Post } from "@nestjs/common";
11
11
  import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
12
- import { ZBody, ZParam } from "../infra/validation/zod-params.js";
12
+ import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
13
13
  import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
14
+ import { DeviceProjectFilesService } from "./device-project-files.service.js";
14
15
  import { DeviceProjectsService, } from "./device-projects.service.js";
15
16
  import { DevicesService } from "./devices.service.js";
16
- import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DeviceProjectAddBodyDto, DeviceProjectParamsDto, } from "./dto.js";
17
+ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DeviceProjectAddBodyDto, DeviceProjectFilesQueryDto, DeviceProjectParamsDto, } from "./dto.js";
17
18
  /**
18
19
  * A person's devices in an org (`/api/v1/orgs/:orgId/devices`, spec
19
20
  * 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
@@ -38,14 +39,19 @@ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DeviceProject
38
39
  * `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
39
40
  * `GET /:id/projects/candidates` → the device's suggestions under its base;
40
41
  * `POST /:id/projects { path, name? }` → 201 `{ project }` (path relative to the base);
41
- * `DELETE /:id/projects/:name` → 204 (idempotent).
42
+ * `DELETE /:id/projects/:name` → 204 (idempotent);
43
+ * `GET /:id/projects/:name/files?path=&q=` → `{ entries, truncated }`: one directory of the
44
+ * project (path relative to its root; 422 `device.path_outside_project` for one leaving it),
45
+ * read through the owner browse scope (composer menus §5).
42
46
  */
43
47
  let DevicesController = class DevicesController {
44
48
  devices;
45
49
  projects;
46
- constructor(devices, projects) {
50
+ files;
51
+ constructor(devices, projects, files) {
47
52
  this.devices = devices;
48
53
  this.projects = projects;
54
+ this.files = files;
49
55
  }
50
56
  async list(principal, org) {
51
57
  const p = requireUser(principal);
@@ -89,6 +95,13 @@ let DevicesController = class DevicesController {
89
95
  const p = requireUser(principal);
90
96
  return this.projects.candidates(org.orgId, p.account.id, params.id);
91
97
  }
98
+ async listProjectFiles(principal, org, params, query) {
99
+ const p = requireUser(principal);
100
+ return this.files.list(org.orgId, p.account.id, params.id, params.name, {
101
+ ...(query.path !== undefined && { path: query.path }),
102
+ ...(query.q !== undefined && { q: query.q }),
103
+ });
104
+ }
92
105
  async addProject(principal, org, params, body) {
93
106
  const p = requireUser(principal);
94
107
  return {
@@ -158,6 +171,14 @@ __decorate([
158
171
  __param(1, CurrentOrg()),
159
172
  __param(2, ZParam(DeviceParamsDto))
160
173
  ], DevicesController.prototype, "projectCandidates", null);
174
+ __decorate([
175
+ Get(":id/projects/:name/files"),
176
+ OrgAction("agents.use"),
177
+ __param(0, CurrentPrincipal()),
178
+ __param(1, CurrentOrg()),
179
+ __param(2, ZParam(DeviceProjectParamsDto)),
180
+ __param(3, ZQuery(DeviceProjectFilesQueryDto))
181
+ ], DevicesController.prototype, "listProjectFiles", null);
161
182
  __decorate([
162
183
  Post(":id/projects"),
163
184
  OrgAction("agents.use"),
@@ -177,6 +198,7 @@ __decorate([
177
198
  DevicesController = __decorate([
178
199
  Controller("api/v1/orgs/:orgId/devices"),
179
200
  __param(0, Inject(DevicesService)),
180
- __param(1, Inject(DeviceProjectsService))
201
+ __param(1, Inject(DeviceProjectsService)),
202
+ __param(2, Inject(DeviceProjectFilesService))
181
203
  ], DevicesController);
182
204
  export { DevicesController };
@@ -14,6 +14,7 @@ import { SandboxFileReader } from "../sandbox/sandbox-file-reader.js";
14
14
  import { DeviceAccess } from "./access.js";
15
15
  import { DeviceAccessModule } from "./access.module.js";
16
16
  import { ConversationDevices } from "./conversation-devices.js";
17
+ import { DeviceProjectFilesService } from "./device-project-files.service.js";
17
18
  import { DeviceProjectsService } from "./device-projects.service.js";
18
19
  import { DeviceProviderSelectionModule } from "./device-provider-selection.module.js";
19
20
  import { DevicesService } from "./devices.service.js";
@@ -40,13 +41,20 @@ DevicesModule = __decorate([
40
41
  ],
41
42
  // SandboxFileReader lives here, not in SandboxModule: it needs ConversationDevices, and this
42
43
  // module already imports SandboxModule (the other way would be a module cycle)
43
- providers: [DevicesService, ConversationDevices, SandboxFileReader, DeviceProjectsService],
44
+ providers: [
45
+ DevicesService,
46
+ ConversationDevices,
47
+ SandboxFileReader,
48
+ DeviceProjectsService,
49
+ DeviceProjectFilesService,
50
+ ],
44
51
  exports: [
45
52
  DeviceAccessModule,
46
53
  DevicesService,
47
54
  ConversationDevices,
48
55
  SandboxFileReader,
49
56
  DeviceProjectsService,
57
+ DeviceProjectFilesService,
50
58
  ],
51
59
  })
52
60
  ], DevicesModule);
@@ -1,4 +1,4 @@
1
- import { DeviceCreateBody, DeviceParams, DevicePatchBody, DeviceProjectAddBody, DeviceProjectParams, } from "./dto.js";
1
+ import { DeviceCreateBody, DeviceParams, DevicePatchBody, DeviceProjectAddBody, DeviceProjectFilesQuery, DeviceProjectParams, } from "./dto.js";
2
2
  /**
3
3
  * The devices routes the Platform operations mirror (`check:platform-ops` keys). `PATCH /devices/:id`
4
4
  * ({@link DevicePatchBody}) is mirrored by `devices.rename` (the name) and `devices.set-network`
@@ -23,4 +23,9 @@ export const DEVICE_ROUTES = [
23
23
  body: DeviceProjectAddBody,
24
24
  },
25
25
  { route: "DELETE /api/v1/orgs/:orgId/devices/:id/projects/:name", params: DeviceProjectParams },
26
+ {
27
+ route: "GET /api/v1/orgs/:orgId/devices/:id/projects/:name/files",
28
+ params: DeviceProjectParams,
29
+ query: DeviceProjectFilesQuery,
30
+ },
26
31
  ];