@capybara-hq/kernel 0.1.0-rc.11 → 0.1.0-rc.13

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 (220) hide show
  1. package/dist/admin/admin.schemas.d.ts +13 -0
  2. package/dist/agents/agent-lookup.d.ts +5 -0
  3. package/dist/agents/agent-lookup.js +15 -0
  4. package/dist/agents/agents.schemas.d.ts +3 -0
  5. package/dist/agents/agents.service.js +11 -1
  6. package/dist/agents/definition.d.ts +1 -0
  7. package/dist/agents/definition.js +7 -3
  8. package/dist/agents/org-templates.js +4 -0
  9. package/dist/agents/pending-connectors.service.js +1 -1
  10. package/dist/background/background.module.js +2 -2
  11. package/dist/background/launch-lock.d.ts +1 -1
  12. package/dist/background/launch-lock.js +1 -1
  13. package/dist/background/poll.job.d.ts +2 -2
  14. package/dist/background/poll.job.js +10 -10
  15. package/dist/background/stop.d.ts +1 -1
  16. package/dist/background/stop.js +3 -3
  17. package/dist/background/store.d.ts +5 -5
  18. package/dist/background/store.js +5 -5
  19. package/dist/background/tasks.service.d.ts +6 -6
  20. package/dist/background/tasks.service.js +13 -13
  21. package/dist/catalog/component-scope.controller.d.ts +18 -6
  22. package/dist/catalog/component-scope.controller.js +36 -13
  23. package/dist/catalog/component-scope.service.d.ts +11 -0
  24. package/dist/catalog/component-scope.service.js +4 -0
  25. package/dist/catalog/component-state.d.ts +8 -0
  26. package/dist/catalog/component-state.js +19 -11
  27. package/dist/catalog/marketplaces.service.d.ts +1 -1
  28. package/dist/catalog/plugin-import.js +4 -1
  29. package/dist/channels/channels.module.js +2 -2
  30. package/dist/channels/inbound.d.ts +8 -8
  31. package/dist/channels/inbound.js +31 -31
  32. package/dist/channels/phrases.d.ts +27 -27
  33. package/dist/channels/phrases.js +27 -27
  34. package/dist/config/docs.js +1 -1
  35. package/dist/config/schema.d.ts +2 -2
  36. package/dist/config/schema.js +21 -21
  37. package/dist/conversations/conversations.controller.d.ts +11 -11
  38. package/dist/conversations/conversations.controller.js +15 -15
  39. package/dist/conversations/conversations.module.d.ts +1 -1
  40. package/dist/conversations/conversations.module.js +7 -7
  41. package/dist/conversations/conversations.schemas.js +1 -1
  42. package/dist/conversations/conversations.service.d.ts +23 -14
  43. package/dist/conversations/conversations.service.js +28 -21
  44. package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
  45. package/dist/conversations/{environment-status.js → device-status.js} +18 -18
  46. package/dist/conversations/event-log.d.ts +1 -1
  47. package/dist/conversations/event-log.js +1 -1
  48. package/dist/conversations/events.d.ts +2 -1
  49. package/dist/conversations/events.js +2 -2
  50. package/dist/ctx/create-ctx.d.ts +10 -1
  51. package/dist/ctx/create-ctx.js +86 -25
  52. package/dist/db/kernel-schema.d.ts +39 -23
  53. package/dist/{environments → devices}/access.d.ts +19 -19
  54. package/dist/{environments → devices}/access.js +28 -28
  55. package/dist/devices/conversation-devices.d.ts +75 -0
  56. package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
  57. package/dist/devices/devices.controller.d.ts +36 -0
  58. package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
  59. package/dist/devices/devices.module.d.ts +5 -13
  60. package/dist/devices/devices.module.js +16 -29
  61. package/dist/devices/devices.schemas.d.ts +3 -0
  62. package/dist/devices/devices.schemas.js +14 -0
  63. package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
  64. package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
  65. package/dist/devices/dto.d.ts +13 -54
  66. package/dist/devices/dto.js +7 -39
  67. package/dist/devices/label.d.ts +11 -0
  68. package/dist/{environments → devices}/label.js +7 -7
  69. package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
  70. package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
  71. package/dist/errors.d.ts +27 -25
  72. package/dist/errors.js +27 -25
  73. package/dist/evals/recorded-tools.d.ts +2 -2
  74. package/dist/evals/recorded-tools.js +6 -6
  75. package/dist/extensions/admin-ops.js +1 -0
  76. package/dist/extensions/admin-view.js +2 -0
  77. package/dist/extensions/effective-config.d.ts +6 -0
  78. package/dist/extensions/effective-config.js +18 -7
  79. package/dist/extensions/host.d.ts +13 -2
  80. package/dist/extensions/host.js +24 -3
  81. package/dist/extensions/instance.d.ts +12 -1
  82. package/dist/extensions/instance.js +13 -0
  83. package/dist/extensions/permission-view.d.ts +10 -1
  84. package/dist/files/previewers.d.ts +1 -1
  85. package/dist/files/previewers.js +1 -1
  86. package/dist/http/api.module.js +10 -6
  87. package/dist/http/gateway-routes.d.ts +1 -1
  88. package/dist/http/gateway-routes.js +1 -1
  89. package/dist/identity/settings.d.ts +32 -0
  90. package/dist/identity/settings.js +26 -2
  91. package/dist/infra/config/kernel-config.service.js +4 -4
  92. package/dist/kernel.module.js +3 -3
  93. package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
  94. package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
  95. package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
  96. package/dist/{devices → local-devices}/device-auth.js +51 -53
  97. package/dist/local-devices/device-auth.module.d.ts +7 -0
  98. package/dist/{devices → local-devices}/device-auth.module.js +5 -5
  99. package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
  100. package/dist/{devices → local-devices}/device-routes.js +2 -2
  101. package/dist/local-devices/dto.d.ts +66 -0
  102. package/dist/local-devices/dto.js +44 -0
  103. package/dist/{devices → local-devices}/keys.d.ts +11 -11
  104. package/dist/{devices → local-devices}/keys.js +11 -11
  105. package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
  106. package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
  107. package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
  108. package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
  109. package/dist/local-devices/local-devices.module.d.ts +16 -0
  110. package/dist/local-devices/local-devices.module.js +44 -0
  111. package/dist/{devices → local-devices}/machines.d.ts +26 -26
  112. package/dist/{devices → local-devices}/machines.js +71 -71
  113. package/dist/{devices → local-devices}/relay.d.ts +15 -15
  114. package/dist/{devices → local-devices}/relay.js +55 -55
  115. package/dist/{devices → local-devices}/targets.d.ts +8 -8
  116. package/dist/{devices → local-devices}/targets.js +14 -14
  117. package/dist/orgs/offboarding.d.ts +6 -6
  118. package/dist/orgs/offboarding.js +12 -12
  119. package/dist/orgs/settings.service.d.ts +28 -0
  120. package/dist/orgs/settings.service.js +20 -1
  121. package/dist/platform/exclusions.js +48 -3
  122. package/dist/platform/operation.js +6 -2
  123. package/dist/platform/ops/admin.ops.js +8 -2
  124. package/dist/platform/ops/agents.ops.js +19 -6
  125. package/dist/platform/ops/conversations.ops.d.ts +3 -3
  126. package/dist/platform/ops/conversations.ops.js +9 -9
  127. package/dist/platform/ops/devices.ops.d.ts +26 -0
  128. package/dist/platform/ops/devices.ops.js +311 -0
  129. package/dist/platform/ops/org-settings.ops.js +2 -2
  130. package/dist/platform/ops/orgs.ops.js +1 -0
  131. package/dist/platform/ops/ui.ops.d.ts +8 -0
  132. package/dist/platform/ops/ui.ops.js +41 -0
  133. package/dist/platform/platform-ops.module.d.ts +3 -2
  134. package/dist/platform/platform-ops.module.js +8 -5
  135. package/dist/platform/route-schemas.js +6 -3
  136. package/dist/roles/gateway-role.d.ts +3 -3
  137. package/dist/roles/gateway-role.js +4 -4
  138. package/dist/roles/gateway.module.d.ts +1 -1
  139. package/dist/roles/gateway.module.js +5 -5
  140. package/dist/roles/worker.module.js +1 -1
  141. package/dist/runtime/context/build.d.ts +1 -1
  142. package/dist/runtime/context/build.js +6 -6
  143. package/dist/runtime/context/compaction.js +1 -1
  144. package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
  145. package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
  146. package/dist/runtime/maintenance.d.ts +1 -1
  147. package/dist/runtime/subagents/definition.d.ts +3 -2
  148. package/dist/runtime/subagents/definition.js +2 -1
  149. package/dist/sandbox/jobs.d.ts +13 -13
  150. package/dist/sandbox/jobs.js +20 -20
  151. package/dist/sandbox/leases.d.ts +9 -9
  152. package/dist/sandbox/leases.js +14 -14
  153. package/dist/sandbox/providers.d.ts +8 -8
  154. package/dist/sandbox/providers.js +8 -8
  155. package/dist/sandbox/sandbox.module.d.ts +1 -1
  156. package/dist/sandbox/sandbox.module.js +1 -1
  157. package/dist/sandbox/sandbox.service.d.ts +76 -76
  158. package/dist/sandbox/sandbox.service.js +230 -230
  159. package/dist/tools/builtins/builtin-tools.d.ts +2 -2
  160. package/dist/tools/builtins/builtin-tools.js +5 -5
  161. package/dist/tools/builtins/platform.js +1 -1
  162. package/dist/tools/builtins/sandbox/bash.js +6 -6
  163. package/dist/tools/builtins/sandbox/common.d.ts +25 -25
  164. package/dist/tools/builtins/sandbox/common.js +51 -51
  165. package/dist/tools/builtins/sandbox/edit.js +2 -2
  166. package/dist/tools/builtins/sandbox/index.d.ts +1 -1
  167. package/dist/tools/builtins/sandbox/index.js +1 -1
  168. package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
  169. package/dist/tools/builtins/sandbox/task-output.js +10 -10
  170. package/dist/tools/builtins/sandbox/task-stop.js +2 -2
  171. package/dist/tools/builtins/sandbox/write.js +2 -2
  172. package/dist/tools/builtins/skill-load.d.ts +1 -1
  173. package/dist/tools/builtins/skill-load.js +2 -2
  174. package/dist/tools/connector-account-policies.d.ts +51 -0
  175. package/dist/tools/connector-account-policies.js +165 -0
  176. package/dist/tools/connectors.controller.d.ts +35 -4
  177. package/dist/tools/connectors.controller.js +66 -7
  178. package/dist/tools/connectors.schemas.d.ts +11 -0
  179. package/dist/tools/connectors.schemas.js +11 -0
  180. package/dist/tools/connectors.service.d.ts +2 -0
  181. package/dist/tools/connectors.service.js +1 -0
  182. package/dist/tools/pipeline.d.ts +1 -1
  183. package/dist/tools/pipeline.js +4 -3
  184. package/dist/tools/policy.d.ts +23 -1
  185. package/dist/tools/policy.js +99 -24
  186. package/dist/tools/registry.d.ts +2 -2
  187. package/dist/tools/tools.module.js +6 -3
  188. package/dist/ui/admin-ui.controller.d.ts +56 -0
  189. package/dist/ui/admin-ui.controller.js +192 -0
  190. package/dist/ui/arrangement.d.ts +74 -0
  191. package/dist/ui/arrangement.js +98 -0
  192. package/dist/ui/embed-token.d.ts +2 -2
  193. package/dist/ui/embed-token.js +30 -5
  194. package/dist/ui/registry.d.ts +29 -14
  195. package/dist/ui/registry.js +31 -10
  196. package/dist/ui/slots.controller.d.ts +11 -0
  197. package/dist/ui/slots.controller.js +25 -0
  198. package/dist/ui/ui-stream.d.ts +20 -3
  199. package/dist/ui/ui-stream.js +25 -7
  200. package/dist/ui/ui.schemas.d.ts +66 -0
  201. package/dist/ui/ui.schemas.js +65 -0
  202. package/dist/ui/views.controller.d.ts +35 -49
  203. package/dist/ui/views.controller.js +48 -70
  204. package/dist/ui/views.d.ts +84 -18
  205. package/dist/ui/views.js +201 -38
  206. package/package.json +3 -3
  207. package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
  208. package/src/migrations/0105_devices_rename.sql +136 -0
  209. package/dist/devices/device-auth.module.d.ts +0 -7
  210. package/dist/environments/conversation-environments.d.ts +0 -75
  211. package/dist/environments/dto.d.ts +0 -25
  212. package/dist/environments/dto.js +0 -12
  213. package/dist/environments/environments.controller.d.ts +0 -36
  214. package/dist/environments/environments.module.d.ts +0 -8
  215. package/dist/environments/environments.module.js +0 -31
  216. package/dist/environments/environments.schemas.d.ts +0 -3
  217. package/dist/environments/environments.schemas.js +0 -14
  218. package/dist/environments/label.d.ts +0 -11
  219. package/dist/platform/ops/environments.ops.d.ts +0 -26
  220. package/dist/platform/ops/environments.ops.js +0 -311
@@ -53,6 +53,19 @@ export declare const DeploymentSettingsBody: z.ZodObject<{
53
53
  uiTheme: z.ZodOptional<z.ZodObject<{
54
54
  id: z.ZodNullable<z.ZodString>;
55
55
  }, z.core.$strict>>;
56
+ uiArrangement: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
57
+ "agent.detail.section": "agent.detail.section";
58
+ "conversation.panel": "conversation.panel";
59
+ "conversation.properties.section": "conversation.properties.section";
60
+ "conversation.tool-result.card": "conversation.tool-result.card";
61
+ "file.preview": "file.preview";
62
+ "org.page": "org.page";
63
+ "org.settings.section": "org.settings.section";
64
+ "platform.page": "platform.page";
65
+ }> & z.core.$partial, z.ZodNullable<z.ZodObject<{
66
+ hidden: z.ZodArray<z.ZodString>;
67
+ order: z.ZodArray<z.ZodString>;
68
+ }, z.core.$strict>>>>;
56
69
  }, z.core.$strict>;
57
70
  export declare const PurposeParams: z.ZodObject<{
58
71
  purpose: z.ZodString;
@@ -49,6 +49,11 @@ export declare function visibleTo(viewerAccountId: string | null): (eb: Expressi
49
49
  * the live org). Deleted agents are never visible.
50
50
  */
51
51
  export declare function isAgentVisibleTo(db: KernelSchemaDb, agentId: string, accountId: string): Promise<boolean>;
52
+ /**
53
+ * {@link isAgentVisibleTo} for an agent of `orgId` only: an agent the account can read in another
54
+ * org is not visible here (UI slots spec R6, the `agent.detail.section` scope rule).
55
+ */
56
+ export declare function isAgentVisibleIn(db: KernelSchemaDb, orgId: string, agentId: string, accountId: string): Promise<boolean>;
52
57
  /**
53
58
  * Reads agents for a viewer (the visibility rule {@link visibleTo}): the part of `AgentsService`
54
59
  * the conversations, the skill invoker and the attachments read, with no dependency on the
@@ -67,6 +67,21 @@ export async function isAgentVisibleTo(db, agentId, accountId) {
67
67
  .executeTakeFirst();
68
68
  return row !== undefined;
69
69
  }
70
+ /**
71
+ * {@link isAgentVisibleTo} for an agent of `orgId` only: an agent the account can read in another
72
+ * org is not visible here (UI slots spec R6, the `agent.detail.section` scope rule).
73
+ */
74
+ export async function isAgentVisibleIn(db, orgId, agentId, accountId) {
75
+ const row = await db
76
+ .selectFrom("agents")
77
+ .select("id")
78
+ .where("id", "=", agentId)
79
+ .where("org_id", "=", orgId)
80
+ .where("deleted_at", "is", null)
81
+ .where(visibleTo(accountId))
82
+ .executeTakeFirst();
83
+ return row !== undefined;
84
+ }
70
85
  /**
71
86
  * Reads agents for a viewer (the visibility rule {@link visibleTo}): the part of `AgentsService`
72
87
  * the conversations, the skill invoker and the attachments read, with no dependency on the
@@ -33,6 +33,7 @@ export declare const AgentCreateDefinition: z.ZodObject<{
33
33
  tools: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
34
34
  }, z.core.$strict>], "kind">>>;
35
35
  toolPolicies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
36
+ allow: "allow";
36
37
  ask: "ask";
37
38
  deny: "deny";
38
39
  }>>>;
@@ -116,6 +117,7 @@ export declare const AgentCreateBody: z.ZodObject<{
116
117
  tools: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
117
118
  }, z.core.$strict>], "kind">>>;
118
119
  toolPolicies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
120
+ allow: "allow";
119
121
  ask: "ask";
120
122
  deny: "deny";
121
123
  }>>>;
@@ -231,6 +233,7 @@ export declare const AgentUpdateBody: z.ZodObject<{
231
233
  tools: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
232
234
  }, z.core.$strict>], "kind">>>;
233
235
  toolPolicies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
236
+ allow: "allow";
234
237
  ask: "ask";
235
238
  deny: "deny";
236
239
  }>>>;
@@ -8,6 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { randomUUID } from "node:crypto";
11
+ import { parseToolKey } from "@capybara-hq/plugin-sdk";
11
12
  import { Inject, Injectable } from "@nestjs/common";
12
13
  import { sql } from "kysely";
13
14
  import { ApiError } from "../errors.js";
@@ -310,7 +311,16 @@ let AgentsService = class AgentsService {
310
311
  message: "subagentTools is set only on a sub-agent's definition at dispatch",
311
312
  });
312
313
  }
313
- for (const key of Object.keys(def.toolPolicies)) {
314
+ for (const [key, policy] of Object.entries(def.toolPolicies)) {
315
+ // `allow` counts only for a connector tool (decision 2026-11-09): elsewhere a policy only
316
+ // tightens, so an `allow` there is refused rather than kept as a no-op
317
+ if (policy === "allow" && parseToolKey(key)?.kind !== "connector") {
318
+ details.push({
319
+ path: `toolPolicies.${key}`,
320
+ message: `"allow" applies only to a connector's tools; "${key}" can only be tightened (ask or deny)`,
321
+ });
322
+ continue;
323
+ }
314
324
  if (!isToolPolicyKey(key, keys)) {
315
325
  // an rc key (tool naming spec §8.3): saving writes current keys only, so name them
316
326
  const renamed = legacyKeySaveText(key, keys);
@@ -196,6 +196,7 @@ export declare const AgentDefinitionSchema: z.ZodObject<{
196
196
  deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
197
197
  }, z.core.$strict>>;
198
198
  toolPolicies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
199
+ allow: "allow";
199
200
  ask: "ask";
200
201
  deny: "deny";
201
202
  }>>>;
@@ -207,10 +207,14 @@ export const AgentDefinitionSchema = z.object({
207
207
  */
208
208
  subagentTools: SubagentToolsSchema.optional(),
209
209
  /**
210
- * Tightened policies by tool key (`ask` / `deny` only, never `allow`); keys are tools the agent
211
- * could have (on or turned off). Older definitions without it read as empty.
210
+ * Policies by tool key; keys are tools the agent could have (on or turned off). `ask` / `deny`
211
+ * tighten any tool. `allow` is accepted only on a connector tool key and counts only for a
212
+ * personal-credential connector's tool (decision 2026-11-09): it overrides the org default and
213
+ * the member's own 询问, never the org's or the member's 禁止 (`tools/policy.ts`
214
+ * `connectorPolicy`); on any other tool it changes nothing. Older definitions without it read as
215
+ * empty.
212
216
  */
213
- toolPolicies: z.record(z.string(), z.enum(["ask", "deny"])).default({}),
217
+ toolPolicies: z.record(z.string(), z.enum(["allow", "ask", "deny"])).default({}),
214
218
  /**
215
219
  * 技能(M5 T13):`orgSkills` 是引用的组织技能 id(保存时校验属于本组织且未删除,不可重复)。
216
220
  * agent 自己的技能(`scope=agent`)自动对它生效,不进定义。可省略(较早保存的定义也没有),按空处理;
@@ -200,6 +200,10 @@ extensionTools = []) {
200
200
  const toolPolicies = {};
201
201
  const connectorPolicies = new Map();
202
202
  for (const [k, v] of Object.entries(def.toolPolicies ?? {})) {
203
+ // a template only tightens: an agent's `allow` (a connector tool's, decision 2026-11-09)
204
+ // is not carried into it
205
+ if (v === "allow")
206
+ continue;
203
207
  const parsed = parseToolKey(k);
204
208
  if (parsed !== null && parsed.kind !== "connector" && TOOL_KEY_RE.test(k)) {
205
209
  toolPolicies[k] = v;
@@ -134,7 +134,7 @@ let PendingConnectorsService = class PendingConnectorsService {
134
134
  }
135
135
  const k = connectorToolKey(c.slug, n);
136
136
  const prev = toolPolicies[k];
137
- if (prev === undefined || RANK[p] > RANK[prev])
137
+ if (prev === undefined || prev === "allow" || RANK[p] > RANK[prev])
138
138
  toolPolicies[k] = p;
139
139
  }
140
140
  // tools are on by default (tools default-on spec §3): binding an entry that names some tools
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Module } from "@nestjs/common";
8
8
  import { ConversationAccessModule } from "../conversations/access.js";
9
9
  import { EventLogModule } from "../conversations/event-log.js";
10
- import { EnvironmentsModule } from "../environments/environments.module.js";
10
+ import { DevicesModule } from "../devices/devices.module.js";
11
11
  import { SandboxModule } from "../sandbox/sandbox.module.js";
12
12
  import { BackgroundTaskFinisher } from "./finish.js";
13
13
  import { BackgroundTaskStopper } from "./stop.js";
@@ -28,7 +28,7 @@ BackgroundModule = __decorate([
28
28
  imports: [
29
29
  BackgroundStoreModule,
30
30
  SandboxModule,
31
- EnvironmentsModule,
31
+ DevicesModule,
32
32
  EventLogModule,
33
33
  ConversationAccessModule,
34
34
  ],
@@ -3,7 +3,7 @@ import { XactLock } from "../infra/database/xact-lock.js";
3
3
  /**
4
4
  * The launch lock of one root conversation (decision R9: one provider per transaction-scoped
5
5
  * lock): serializes background task reservations in its tree, so the count of running tasks
6
- * checked against `sandbox.background.maxTasks` (per root conversation, whatever environment it
6
+ * checked against `sandbox.background.maxTasks` (per root conversation, whatever device it
7
7
  * works in) and the insert of the new row are one step. Joins the
8
8
  * caller's transaction (`mandatory`), which holds it until it ends.
9
9
  */
@@ -14,7 +14,7 @@ import { XactLock } from "../infra/database/xact-lock.js";
14
14
  /**
15
15
  * The launch lock of one root conversation (decision R9: one provider per transaction-scoped
16
16
  * lock): serializes background task reservations in its tree, so the count of running tasks
17
- * checked against `sandbox.background.maxTasks` (per root conversation, whatever environment it
17
+ * checked against `sandbox.background.maxTasks` (per root conversation, whatever device it
18
18
  * works in) and the insert of the new row are one step. Joins the
19
19
  * caller's transaction (`mandatory`), which holds it until it ends.
20
20
  */
@@ -21,7 +21,7 @@ export declare const launchAbandonedAfterMs: (cfg: KernelConfig) => number;
21
21
  /**
22
22
  * The worker's background task jobs (spec 2026-11-05-background-bash-design §4.3), each once per
23
23
  * tick across replicas:
24
- * - `background-task-poll` (every `sandbox.background.pollSeconds`): for every environment
24
+ * - `background-task-poll` (every `sandbox.background.pollSeconds`): for every device
25
25
  * instance with running tasks (of any conversation using it), one exec through
26
26
  * `SandboxService.ifRunning` (which never creates or resumes an instance) reports each task's
27
27
  * exit file and liveness; ended tasks finish through {@link BackgroundTaskFinisher}. Each poll
@@ -47,7 +47,7 @@ export declare class BackgroundTaskPollJob {
47
47
  * result: they never started), with a `changed: "background"` frame to their conversations.
48
48
  */
49
49
  pollOnce(signal?: AbortSignal): Promise<number>;
50
- /** Polls the tasks of one environment instance; returns how many finished. */
50
+ /** Polls the tasks of one device instance; returns how many finished. */
51
51
  private pollSandbox;
52
52
  /** The poll exec of one instance: each task's report by id. */
53
53
  private pollExec;
@@ -44,7 +44,7 @@ const POLL_MAX_OUTPUT_BYTES = 4 * 1024 * 1024;
44
44
  /**
45
45
  * The worker's background task jobs (spec 2026-11-05-background-bash-design §4.3), each once per
46
46
  * tick across replicas:
47
- * - `background-task-poll` (every `sandbox.background.pollSeconds`): for every environment
47
+ * - `background-task-poll` (every `sandbox.background.pollSeconds`): for every device
48
48
  * instance with running tasks (of any conversation using it), one exec through
49
49
  * `SandboxService.ifRunning` (which never creates or resumes an instance) reports each task's
50
50
  * exit file and liveness; ended tasks finish through {@link BackgroundTaskFinisher}. Each poll
@@ -93,8 +93,8 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
93
93
  for (const t of await this.store.runningStarted()) {
94
94
  if (t.sid === null || t.sandboxCreatedAt === null)
95
95
  continue;
96
- // one exec per instance: the tasks of every conversation sharing the environment
97
- const key = `${t.environmentId} ${t.sandboxCreatedAt.getTime()}`;
96
+ // one exec per instance: the tasks of every conversation sharing the device
97
+ const key = `${t.deviceId} ${t.sandboxCreatedAt.getTime()}`;
98
98
  groups.set(key, [...(groups.get(key) ?? []), t]);
99
99
  }
100
100
  let finished = 0;
@@ -102,9 +102,9 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
102
102
  if (signal.aborted)
103
103
  break;
104
104
  try {
105
- // the environment's provider is not there (no cloud provider, `@device` not served):
105
+ // the device's provider is not there (no cloud provider, `@local` not served):
106
106
  // its tasks stay as they are until it is
107
- const env = tasks[0]?.environmentId ?? null;
107
+ const env = tasks[0]?.deviceId ?? null;
108
108
  if (env === null ? !this.sandbox.cloudAvailable : !(await this.sandbox.availableFor(env))) {
109
109
  continue;
110
110
  }
@@ -114,7 +114,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
114
114
  if (signal.aborted)
115
115
  break;
116
116
  this.log.warn("cannot poll background tasks; retrying next tick", {
117
- environmentId: tasks[0]?.environmentId,
117
+ deviceId: tasks[0]?.deviceId,
118
118
  err,
119
119
  });
120
120
  }
@@ -123,13 +123,13 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
123
123
  this.log.info("background tasks finished", { count: finished });
124
124
  return finished;
125
125
  }
126
- /** Polls the tasks of one environment instance; returns how many finished. */
126
+ /** Polls the tasks of one device instance; returns how many finished. */
127
127
  async pollSandbox(tasks, signal) {
128
128
  const [first] = tasks;
129
- // a task from before environments has no instance any more
130
- const r = first.environmentId === null
129
+ // a task from before devices has no instance any more
130
+ const r = first.deviceId === null
131
131
  ? { kind: "not_running", status: "gone" }
132
- : await this.sandbox.ifRunning(first.environmentId, { createdAt: first.sandboxCreatedAt }, (p, h, sig) => this.pollExec(actingAs(p, taskActor(first)), h, tasks, sig), signal);
132
+ : await this.sandbox.ifRunning(first.deviceId, { createdAt: first.sandboxCreatedAt }, (p, h, sig) => this.pollExec(actingAs(p, taskActor(first)), h, tasks, sig), signal);
133
133
  const now = new Date();
134
134
  let n = 0;
135
135
  for (const t of tasks) {
@@ -43,7 +43,7 @@ export declare class BackgroundTaskStopper {
43
43
  stop(task: BackgroundTaskRow, why: StopReason, signal?: AbortSignal): Promise<BackgroundTaskRow>;
44
44
  /**
45
45
  * SIGTERM, the grace period, SIGKILL until the session is empty, then the last lines: in the
46
- * task's own instance only (`ifRunning`); a task from before environments has none.
46
+ * task's own instance only (`ifRunning`); a task from before devices has none.
47
47
  */
48
48
  private signalTask;
49
49
  /**
@@ -138,12 +138,12 @@ let BackgroundTaskStopper = class BackgroundTaskStopper {
138
138
  }
139
139
  /**
140
140
  * SIGTERM, the grace period, SIGKILL until the session is empty, then the last lines: in the
141
- * task's own instance only (`ifRunning`); a task from before environments has none.
141
+ * task's own instance only (`ifRunning`); a task from before devices has none.
142
142
  */
143
143
  async signalTask(cur, sid, signal) {
144
- if (cur.environmentId === null)
144
+ if (cur.deviceId === null)
145
145
  return { kind: "not_running", status: "gone" };
146
- return this.sandbox.ifRunning(cur.environmentId, { createdAt: cur.sandboxCreatedAt }, async (tp, h, sig) => {
146
+ return this.sandbox.ifRunning(cur.deviceId, { createdAt: cur.sandboxCreatedAt }, async (tp, h, sig) => {
147
147
  const p = actingAs(tp, taskActor(cur));
148
148
  const term = await p.exec(h, {
149
149
  command: termScript(cur.id, sid),
@@ -14,10 +14,10 @@ export interface BackgroundTaskRow {
14
14
  */
15
15
  sandboxConversationId: string;
16
16
  /**
17
- * The environment the task runs in (the root conversation's when it was launched): its instance
18
- * is where the task's processes are. Null only for tasks from before environments (all finished).
17
+ * The device the task runs in (the root conversation's when it was launched): its instance
18
+ * is where the task's processes are. Null only for tasks from before devices (all finished).
19
19
  */
20
- environmentId: string | null;
20
+ deviceId: string | null;
21
21
  runId: string;
22
22
  callId: string;
23
23
  triggerAccountId: string;
@@ -157,10 +157,10 @@ export declare class BackgroundTaskStore {
157
157
  /** Moves the read offset forward only (a concurrent reader never moves it back). */
158
158
  advanceOffset(id: string, to: number): Promise<void>;
159
159
  /**
160
- * Finished tasks of an environment whose process may still exist (any conversation's: they
160
+ * Finished tasks of a device whose process may still exist (any conversation's: they
161
161
  * share the instance).
162
162
  */
163
- pendingKills(environmentId: string): Promise<BackgroundTaskRow[]>;
163
+ pendingKills(deviceId: string): Promise<BackgroundTaskRow[]>;
164
164
  clearKill(ids: string[]): Promise<void>;
165
165
  /** Deletes finished tasks that ended before `before`; a running one is never deleted. */
166
166
  pruneFinished(before: Date): Promise<number>;
@@ -18,7 +18,7 @@ const toRow = (r) => ({
18
18
  orgId: r.org_id,
19
19
  conversationId: r.conversation_id,
20
20
  sandboxConversationId: r.sandbox_conversation_id,
21
- environmentId: r.environment_id,
21
+ deviceId: r.device_id,
22
22
  runId: r.run_id,
23
23
  callId: r.call_id,
24
24
  triggerAccountId: r.trigger_account_id,
@@ -195,7 +195,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
195
195
  org_id: row.orgId,
196
196
  conversation_id: row.conversationId,
197
197
  sandbox_conversation_id: row.sandboxConversationId,
198
- environment_id: row.environmentId,
198
+ device_id: row.deviceId,
199
199
  run_id: row.runId,
200
200
  call_id: row.callId,
201
201
  trigger_account_id: row.triggerAccountId,
@@ -314,14 +314,14 @@ let BackgroundTaskStore = class BackgroundTaskStore {
314
314
  .execute();
315
315
  }
316
316
  /**
317
- * Finished tasks of an environment whose process may still exist (any conversation's: they
317
+ * Finished tasks of a device whose process may still exist (any conversation's: they
318
318
  * share the instance).
319
319
  */
320
- async pendingKills(environmentId) {
320
+ async pendingKills(deviceId) {
321
321
  const rows = await this.db
322
322
  .selectFrom("background_tasks")
323
323
  .selectAll()
324
- .where("environment_id", "=", environmentId)
324
+ .where("device_id", "=", deviceId)
325
325
  .where("kill_pending", "=", true)
326
326
  .orderBy("started_at", "asc")
327
327
  .execute();
@@ -1,6 +1,6 @@
1
1
  import { ConversationAccess } from "../conversations/access.js";
2
2
  import { EventLog } from "../conversations/event-log.js";
3
- import { ConversationEnvironments } from "../environments/conversation-environments.js";
3
+ import { ConversationDevices } from "../devices/conversation-devices.js";
4
4
  import { KernelDb } from "../infra/database/kernel-db.js";
5
5
  import { SandboxService } from "../sandbox/sandbox.service.js";
6
6
  import { BackgroundTaskStopper } from "./stop.js";
@@ -45,8 +45,8 @@ export declare class BackgroundTasks {
45
45
  private readonly sandbox;
46
46
  private readonly eventLog;
47
47
  private readonly db;
48
- private readonly environments;
49
- constructor(access: Pick<ConversationAccess, "isAccessible">, store: Pick<BackgroundTaskStore, "listFor" | "get">, stopper: Pick<BackgroundTaskStopper, "stop">, sandbox: Pick<SandboxService, "availableFor" | "ifRunning">, eventLog: Pick<EventLog, "findByIdem">, db: KernelDb, environments: Pick<ConversationEnvironments, "forTool">);
48
+ private readonly devices;
49
+ constructor(access: Pick<ConversationAccess, "isAccessible">, store: Pick<BackgroundTaskStore, "listFor" | "get">, stopper: Pick<BackgroundTaskStopper, "stop">, sandbox: Pick<SandboxService, "availableFor" | "ifRunning">, eventLog: Pick<EventLog, "findByIdem">, db: KernelDb, devices: Pick<ConversationDevices, "forTool">);
50
50
  /**
51
51
  * The conversation and every sub-agent conversation below it (grandchildren too: their tasks run
52
52
  * in the root's sandbox, agent map spec §6); `conversation.not_found` when not visible.
@@ -63,12 +63,12 @@ export declare class BackgroundTasks {
63
63
  */
64
64
  stop(orgId: string, conversationId: string, accountId: string, taskId: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<BackgroundTaskView>;
65
65
  /**
66
- * Whether the task's environment may still be used by its conversation's owner (the access
66
+ * Whether the task's device may still be used by its conversation's owner (the access
67
67
  * re-check every sandbox tool call makes); when it may not, the live read is skipped.
68
68
  */
69
- private environmentUsable;
69
+ private deviceUsable;
70
70
  /**
71
- * The end of the task's output, at most `tail` bytes. Read live when the task's environment
71
+ * The end of the task's output, at most `tail` bytes. Read live when the task's device
72
72
  * instance runs (never resuming a suspended one); a finished task whose sandbox does not run answers
73
73
  * with the last lines its finished event kept. Anything else is
74
74
  * `background_task.output_unavailable` (409).
@@ -12,7 +12,7 @@ import { Inject, Injectable } from "@nestjs/common";
12
12
  import { ConversationAccess } from "../conversations/access.js";
13
13
  import { EventLog } from "../conversations/event-log.js";
14
14
  import { conversationTree } from "../conversations/tree.js";
15
- import { ConversationEnvironments } from "../environments/conversation-environments.js";
15
+ import { ConversationDevices } from "../devices/conversation-devices.js";
16
16
  import { ApiError } from "../errors.js";
17
17
  import { audit } from "../identity/audit.js";
18
18
  import { KernelDb } from "../infra/database/kernel-db.js";
@@ -44,15 +44,15 @@ let BackgroundTasks = class BackgroundTasks {
44
44
  sandbox;
45
45
  eventLog;
46
46
  db;
47
- environments;
48
- constructor(access, store, stopper, sandbox, eventLog, db, environments) {
47
+ devices;
48
+ constructor(access, store, stopper, sandbox, eventLog, db, devices) {
49
49
  this.access = access;
50
50
  this.store = store;
51
51
  this.stopper = stopper;
52
52
  this.sandbox = sandbox;
53
53
  this.eventLog = eventLog;
54
54
  this.db = db;
55
- this.environments = environments;
55
+ this.devices = devices;
56
56
  }
57
57
  /**
58
58
  * The conversation and every sub-agent conversation below it (grandchildren too: their tasks run
@@ -119,12 +119,12 @@ let BackgroundTasks = class BackgroundTasks {
119
119
  return this.view(after, conversationId);
120
120
  }
121
121
  /**
122
- * Whether the task's environment may still be used by its conversation's owner (the access
122
+ * Whether the task's device may still be used by its conversation's owner (the access
123
123
  * re-check every sandbox tool call makes); when it may not, the live read is skipped.
124
124
  */
125
- async environmentUsable(orgId, taskConversationId) {
125
+ async deviceUsable(orgId, taskConversationId) {
126
126
  try {
127
- await this.environments.forTool(orgId, await rootConversationOf(this.db.db, taskConversationId));
127
+ await this.devices.forTool(orgId, await rootConversationOf(this.db.db, taskConversationId));
128
128
  return true;
129
129
  }
130
130
  catch (e) {
@@ -134,7 +134,7 @@ let BackgroundTasks = class BackgroundTasks {
134
134
  }
135
135
  }
136
136
  /**
137
- * The end of the task's output, at most `tail` bytes. Read live when the task's environment
137
+ * The end of the task's output, at most `tail` bytes. Read live when the task's device
138
138
  * instance runs (never resuming a suspended one); a finished task whose sandbox does not run answers
139
139
  * with the last lines its finished event kept. Anything else is
140
140
  * `background_task.output_unavailable` (409).
@@ -143,14 +143,14 @@ let BackgroundTasks = class BackgroundTasks {
143
143
  const task = await this.owned(orgId, conversationId, accountId, taskId);
144
144
  if (task.sid !== null &&
145
145
  task.sandboxCreatedAt !== null &&
146
- task.environmentId !== null &&
147
- (await this.sandbox.availableFor(task.environmentId)) &&
148
- (await this.environmentUsable(orgId, task.conversationId))) {
146
+ task.deviceId !== null &&
147
+ (await this.sandbox.availableFor(task.deviceId)) &&
148
+ (await this.deviceUsable(orgId, task.conversationId))) {
149
149
  const createdAt = task.sandboxCreatedAt;
150
150
  // the person reading it acts in the task's conversation
151
151
  const actor = { accountId, conversationId: task.conversationId };
152
152
  try {
153
- const r = await this.sandbox.ifRunning(task.environmentId, { createdAt }, async (p, h, signal) => {
153
+ const r = await this.sandbox.ifRunning(task.deviceId, { createdAt }, async (p, h, signal) => {
154
154
  const res = await actingAs(p, actor).exec(h, {
155
155
  command: tailScript(task.id, tail),
156
156
  cwd: rootsOf(h).workspace,
@@ -185,7 +185,7 @@ BackgroundTasks = __decorate([
185
185
  __param(3, Inject(SandboxService)),
186
186
  __param(4, Inject(EventLog)),
187
187
  __param(5, Inject(KernelDb)),
188
- __param(6, Inject(ConversationEnvironments))
188
+ __param(6, Inject(ConversationDevices))
189
189
  ], BackgroundTasks);
190
190
  export { BackgroundTasks };
191
191
  /** Prints `size <bytes>` and `out <base64 of the last `tail` bytes>`. Relative to the workspace root. */
@@ -1,4 +1,5 @@
1
1
  import type { z } from "zod";
2
+ import { PluginIcons } from "../extensions/plugin-icons.js";
2
3
  import { type Principal } from "../identity/principal.js";
3
4
  import { type OrgContext } from "../orgs/org.guard.js";
4
5
  import { ComponentParams, ComponentDisabledSchema as DisabledBody, ComponentIdSchema as IdParams, ComponentListQuery as ListQuery, OrgComponentListQuery, ComponentScopePreviewSchema as PreviewBody, ComponentScopeSchema as ScopeBody, ComponentShownSchema as ShownBody, ComponentSwitchBody as SwitchBody, ComponentTemplateVersionSchema as TemplateVersionBody } from "./component-scope.schemas.js";
@@ -13,7 +14,8 @@ import { PlatformComponents, type UploadedComponentVersion } from "./platform-co
13
14
  export declare class AdminComponentsController {
14
15
  private readonly scope;
15
16
  private readonly components;
16
- constructor(scope: ComponentScopeService, components: PlatformComponents);
17
+ private readonly icons;
18
+ constructor(scope: ComponentScopeService, components: PlatformComponents, icons: PluginIcons);
17
19
  /**
18
20
  * Updates a platform skill on its own (spec §7.2): the skill package (zip) as the raw body
19
21
  * (`application/octet-stream`, at most `packages.maxBytes`). The package keeps the skill's name
@@ -26,9 +28,14 @@ export declare class AdminComponentsController {
26
28
  }): Promise<UploadedComponentVersion>;
27
29
  /** Updates a platform agent template on its own: `{ content }` is the template markdown file. */
28
30
  uploadAgentTemplateVersion(principal: Principal, p: z.infer<typeof IdParams>, body: z.infer<typeof TemplateVersionBody>): Promise<UploadedComponentVersion>;
29
- /** `GET ?kind=`: every platform component of the kind (plugin, owner, scope, version, orgs on). */
31
+ /**
32
+ * `GET ?kind=`: every platform component of the kind (plugin, owner, scope, version, orgs on),
33
+ * each with its display name and its plugin's icon (`icon`, the admin route; null without one).
34
+ */
30
35
  list(q: z.infer<typeof ListQuery>): Promise<{
31
- components: ComponentView[];
36
+ components: (ComponentView & {
37
+ icon: string | null;
38
+ })[];
32
39
  }>;
33
40
  /**
34
41
  * A component's versions, newest first: `{ versions: [{ version, catalogVersion, updatedOnOwn,
@@ -65,14 +72,19 @@ export declare class AdminComponentsController {
65
72
  */
66
73
  export declare class OrgComponentsController {
67
74
  private readonly scope;
68
- constructor(scope: ComponentScopeService);
75
+ private readonly icons;
76
+ constructor(scope: ComponentScopeService, icons: PluginIcons);
69
77
  /**
70
78
  * The platform components offered to the org (`?kind=`, `?itemId=`: only those; Task 10): each
71
79
  * with its state in the org (`on`, `locked` for `all`, the org's `switch`) and whether an org
72
- * admin may switch it. Members read it (the workspace pages are read-only for them).
80
+ * admin may switch it. Members read it (the workspace pages are read-only for them). Each has
81
+ * its display name and `icon`, its plugin's icon on the org's catalog route (null without one,
82
+ * or when the org's catalog does not show the plugin to the reader: the share gate holds).
73
83
  */
74
84
  list(org: OrgContext, q: z.infer<typeof OrgComponentListQuery>): Promise<{
75
- components: OrgOfferedComponentView[];
85
+ components: (OrgOfferedComponentView & {
86
+ icon: string | null;
87
+ })[];
76
88
  }>;
77
89
  setSwitch(principal: Principal, org: OrgContext, p: z.infer<typeof ComponentParams>, body: z.infer<typeof SwitchBody>): Promise<{
78
90
  component: OrgComponentView;