@capybara-hq/kernel 0.1.0-rc.77 → 0.1.0-rc.79

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 (247) hide show
  1. package/bootstrap.json +6 -6
  2. package/dist/admin/outbox-dead.service.js +4 -1
  3. package/dist/agents/admin-agents.js +2 -0
  4. package/dist/agents/agent-lookup.js +4 -0
  5. package/dist/agents/agent-profile.service.js +3 -0
  6. package/dist/agents/agents.service.js +7 -0
  7. package/dist/agents/org-templates.js +1 -0
  8. package/dist/agents/pending-connector-requests.js +6 -0
  9. package/dist/agents/pending-connectors.service.js +2 -0
  10. package/dist/agents/readiness.service.d.ts +9 -3
  11. package/dist/agents/readiness.service.js +3 -3
  12. package/dist/agents/templates.js +1 -0
  13. package/dist/background/finish.js +3 -0
  14. package/dist/background/stop.js +2 -0
  15. package/dist/background/store.js +44 -0
  16. package/dist/background/tasks.service.js +3 -2
  17. package/dist/background/wake-rules.js +1 -0
  18. package/dist/catalog/admin-catalog.controller.d.ts +6 -0
  19. package/dist/catalog/admin-catalog.controller.js +13 -0
  20. package/dist/catalog/catalog-content.d.ts +9 -0
  21. package/dist/catalog/catalog-content.js +3 -1
  22. package/dist/catalog/catalog-items.js +4 -0
  23. package/dist/catalog/catalog-scope.service.js +4 -1
  24. package/dist/catalog/component-promotion.js +2 -0
  25. package/dist/catalog/component-scope.controller.d.ts +9 -15
  26. package/dist/catalog/component-scope.controller.js +14 -9
  27. package/dist/catalog/component-scope.service.js +5 -0
  28. package/dist/catalog/component-state.d.ts +4 -1
  29. package/dist/catalog/component-state.js +4 -2
  30. package/dist/catalog/marketplace-fetch.d.ts +1 -1
  31. package/dist/catalog/marketplace-fetch.js +1 -1
  32. package/dist/catalog/marketplaces.service.d.ts +6 -1
  33. package/dist/catalog/marketplaces.service.js +8 -3
  34. package/dist/catalog/org-catalog.controller.d.ts +9 -0
  35. package/dist/catalog/org-catalog.controller.js +18 -0
  36. package/dist/catalog/org-catalog.schemas.d.ts +2 -4
  37. package/dist/catalog/org-catalog.schemas.js +2 -3
  38. package/dist/catalog/org-catalog.service.d.ts +10 -1
  39. package/dist/catalog/org-catalog.service.js +34 -23
  40. package/dist/catalog/org-extension-switch.d.ts +3 -10
  41. package/dist/catalog/org-extension-switch.js +14 -60
  42. package/dist/catalog/org-extension.controller.d.ts +6 -7
  43. package/dist/catalog/org-extension.controller.js +4 -4
  44. package/dist/catalog/org-extension.schemas.d.ts +1 -2
  45. package/dist/catalog/org-extension.schemas.js +1 -3
  46. package/dist/catalog/owned-items.js +10 -1
  47. package/dist/catalog/ownership.js +2 -0
  48. package/dist/catalog/plugin-import.d.ts +3 -0
  49. package/dist/catalog/plugin-import.js +10 -1
  50. package/dist/catalog/plugin-install.d.ts +1 -4
  51. package/dist/catalog/plugin-install.js +11 -12
  52. package/dist/catalog/plugin-upgrade.js +4 -1
  53. package/dist/catalog/request-rules.js +6 -0
  54. package/dist/catalog/requests.service.js +4 -0
  55. package/dist/catalog/scope-orgs.js +1 -0
  56. package/dist/catalog/scope-sync.d.ts +8 -5
  57. package/dist/catalog/scope-sync.js +21 -23
  58. package/dist/catalog/template-description.d.ts +17 -0
  59. package/dist/catalog/template-description.js +18 -0
  60. package/dist/catalog/unshare.js +3 -0
  61. package/dist/channels/connections.service.js +1 -0
  62. package/dist/channels/inbound.js +1 -0
  63. package/dist/channels/jobs.js +1 -0
  64. package/dist/channels/outbound.js +6 -0
  65. package/dist/channels/supervisor.js +1 -0
  66. package/dist/channels/threads.js +1 -0
  67. package/dist/client/client-reports.service.js +1 -0
  68. package/dist/config/fields.js +20 -4
  69. package/dist/config/schema.d.ts +1 -1
  70. package/dist/config/schema.js +13 -13
  71. package/dist/conversations/access.js +1 -0
  72. package/dist/conversations/attachments.service.js +16 -4
  73. package/dist/conversations/conversations.service.js +17 -3
  74. package/dist/conversations/event-log.js +2 -0
  75. package/dist/conversations/events.d.ts +1 -0
  76. package/dist/conversations/events.js +3 -1
  77. package/dist/conversations/files.js +3 -2
  78. package/dist/conversations/permission-profiles.service.js +1 -0
  79. package/dist/conversations/prompt-suggestions.js +2 -0
  80. package/dist/conversations/queue.js +8 -0
  81. package/dist/conversations/queue.service.js +6 -2
  82. package/dist/conversations/source.js +2 -0
  83. package/dist/conversations/titles.js +10 -2
  84. package/dist/conversations/tree.js +6 -0
  85. package/dist/db/kernel-schema.d.ts +5 -1
  86. package/dist/devices/conversation-devices.js +3 -0
  87. package/dist/devices/device-projects.service.js +2 -0
  88. package/dist/devices/devices.service.js +5 -0
  89. package/dist/devices/legacy-cleanup.job.js +5 -2
  90. package/dist/dial-in/handlers.js +2 -0
  91. package/dist/dial-in/machines.js +11 -2
  92. package/dist/dial-in/targets.d.ts +0 -2
  93. package/dist/dial-in/targets.js +0 -10
  94. package/dist/errors.d.ts +0 -1
  95. package/dist/errors.js +0 -1
  96. package/dist/evals/budget.js +14 -1
  97. package/dist/evals/run-replay.js +4 -0
  98. package/dist/evals/runs.service.js +13 -7
  99. package/dist/evals/sets.service.js +23 -8
  100. package/dist/evals/trajectory.service.d.ts +1 -1
  101. package/dist/evals/trajectory.service.js +1 -0
  102. package/dist/evals/worker.js +5 -1
  103. package/dist/extensions/admin-ops.js +1 -0
  104. package/dist/extensions/admin-view.js +3 -1
  105. package/dist/extensions/bootstrap-packages.d.ts +12 -1
  106. package/dist/extensions/bootstrap-packages.js +49 -9
  107. package/dist/extensions/bootstrap.d.ts +17 -2
  108. package/dist/extensions/bootstrap.js +41 -9
  109. package/dist/extensions/config-json-schema.d.ts +2 -2
  110. package/dist/extensions/config-json-schema.js +1 -3
  111. package/dist/extensions/deployment-config.d.ts +5 -3
  112. package/dist/extensions/deployment-config.js +3 -3
  113. package/dist/extensions/effective-config.d.ts +8 -7
  114. package/dist/extensions/effective-config.js +8 -7
  115. package/dist/extensions/enabled.js +1 -0
  116. package/dist/extensions/host.d.ts +4 -3
  117. package/dist/extensions/host.js +11 -12
  118. package/dist/extensions/instance.d.ts +1 -1
  119. package/dist/extensions/instance.js +17 -2
  120. package/dist/extensions/org-config.d.ts +35 -97
  121. package/dist/extensions/org-config.js +48 -315
  122. package/dist/extensions/org-levels.d.ts +22 -9
  123. package/dist/extensions/org-levels.js +100 -20
  124. package/dist/extensions/org-overrides.d.ts +14 -15
  125. package/dist/extensions/org-overrides.js +20 -20
  126. package/dist/extensions/package.js +1 -1
  127. package/dist/extensions/permission-set.d.ts +1 -3
  128. package/dist/extensions/permission-set.js +3 -7
  129. package/dist/extensions/permission-view.d.ts +3 -1
  130. package/dist/extensions/permission-view.js +5 -4
  131. package/dist/extensions/plugin-icons.d.ts +80 -1
  132. package/dist/extensions/plugin-icons.js +211 -2
  133. package/dist/extensions/point-defaults.d.ts +17 -18
  134. package/dist/extensions/point-defaults.js +25 -28
  135. package/dist/git/gateway.js +1 -1
  136. package/dist/git/identity.d.ts +1 -1
  137. package/dist/git/identity.js +2 -2
  138. package/dist/identity/accounts.js +6 -0
  139. package/dist/identity/api-tokens.js +8 -0
  140. package/dist/infra/outbox/outbox.dispatcher.js +4 -1
  141. package/dist/infra/outbox/outbox.service.js +2 -0
  142. package/dist/net/public-address.d.ts +3 -3
  143. package/dist/net/public-address.js +3 -3
  144. package/dist/orgs/directory-sync.d.ts +9 -6
  145. package/dist/orgs/directory-sync.js +15 -12
  146. package/dist/orgs/invitations.service.js +2 -0
  147. package/dist/orgs/members.service.js +2 -0
  148. package/dist/orgs/offboarding.js +2 -0
  149. package/dist/packages/npm.d.ts +10 -2
  150. package/dist/packages/npm.js +38 -6
  151. package/dist/platform/exclusions.js +20 -0
  152. package/dist/platform/ops/admin-items.ops.js +1 -0
  153. package/dist/platform/ops/agents.ops.js +1 -0
  154. package/dist/platform/ops/connectors.ops.js +7 -1
  155. package/dist/platform/ops/extensions.ops.d.ts +6 -8
  156. package/dist/platform/ops/extensions.ops.js +18 -97
  157. package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
  158. package/dist/platform/ops/org-plugins.ops.js +14 -65
  159. package/dist/platform/ops/outbox.ops.js +1 -0
  160. package/dist/platform/ops/person-inputs.d.ts +0 -4
  161. package/dist/platform/ops/person-inputs.js +0 -8
  162. package/dist/platform/ops/plugins.ops.d.ts +4 -1
  163. package/dist/platform/ops/plugins.ops.js +27 -34
  164. package/dist/platform/person-fields.d.ts +1 -1
  165. package/dist/platform/person-fields.js +1 -1
  166. package/dist/platform/sealed-reveals.js +2 -0
  167. package/dist/push/recipients.js +9 -2
  168. package/dist/runtime/permission-context.service.js +1 -0
  169. package/dist/runtime/plugin-context.service.js +1 -0
  170. package/dist/runtime/project/knowledge.service.js +1 -0
  171. package/dist/runtime/run-context.service.js +1 -0
  172. package/dist/runtime/run-deletion.js +4 -0
  173. package/dist/runtime/run-execution.js +2 -0
  174. package/dist/runtime/run-finish.js +3 -0
  175. package/dist/runtime/run-jobs.js +3 -0
  176. package/dist/runtime/run-orphan-check.job.js +7 -0
  177. package/dist/runtime/run-queue.js +21 -2
  178. package/dist/runtime/run-worker.js +5 -0
  179. package/dist/runtime/step-log.js +1 -0
  180. package/dist/runtime/subagents/child.js +2 -0
  181. package/dist/runtime/subagents/deliveries.js +3 -0
  182. package/dist/runtime/subagents/dispatch.js +5 -1
  183. package/dist/runtime/subagents/messages.js +2 -0
  184. package/dist/runtime/subagents/org-agents.d.ts +1 -1
  185. package/dist/runtime/subagents/org-agents.js +2 -1
  186. package/dist/runtime/usage-report-jobs.js +1 -0
  187. package/dist/runtime/usage-report.js +3 -0
  188. package/dist/runtime/waits.js +5 -0
  189. package/dist/sandbox/cloud-permission-snapshot.js +9 -3
  190. package/dist/sandbox/device-reports.js +3 -0
  191. package/dist/sandbox/legacy-retirement.js +5 -1
  192. package/dist/sandbox/managed-device-context.js +1 -0
  193. package/dist/sandbox/modes.d.ts +5 -2
  194. package/dist/sandbox/modes.js +8 -4
  195. package/dist/sandbox/network-grants.js +2 -0
  196. package/dist/sandbox/operation-intents.js +58 -0
  197. package/dist/sandbox/operation-reconcile.job.js +2 -0
  198. package/dist/sandbox/permission-authority-lock.js +12 -6
  199. package/dist/sandbox/permission-call-grants.js +6 -0
  200. package/dist/sandbox/permission-ceiling-writes.js +5 -0
  201. package/dist/sandbox/permission-config-publication.js +5 -0
  202. package/dist/sandbox/permission-instance-writes.js +4 -0
  203. package/dist/sandbox/permission-runtime-reports.js +10 -1
  204. package/dist/sandbox/permission-transitions.js +3 -0
  205. package/dist/sandbox/review/review.service.js +8 -5
  206. package/dist/sandbox/sandbox.service.d.ts +14 -0
  207. package/dist/sandbox/sandbox.service.js +195 -29
  208. package/dist/sandbox/unreachable.js +4 -1
  209. package/dist/schedules/fire.js +9 -3
  210. package/dist/schedules/pause.js +2 -0
  211. package/dist/schedules/run-tracker.js +16 -1
  212. package/dist/schedules/scheduled-tasks.service.js +4 -2
  213. package/dist/schedules/store.js +8 -0
  214. package/dist/schedules/unattended.js +4 -0
  215. package/dist/setup/setup-checks.service.d.ts +1 -10
  216. package/dist/setup/setup-checks.service.js +19 -29
  217. package/dist/shares/share-open.service.js +1 -0
  218. package/dist/shares/shares.service.js +2 -0
  219. package/dist/skills/agent-skills.service.d.ts +1 -1
  220. package/dist/skills/agent-skills.service.js +13 -2
  221. package/dist/skills/catalog.js +3 -0
  222. package/dist/skills/changes.service.js +10 -2
  223. package/dist/skills/conversation-catalog.js +1 -0
  224. package/dist/skills/skills.service.js +4 -0
  225. package/dist/tools/approvals.service.js +40 -0
  226. package/dist/tools/builtins/schedules.js +11 -6
  227. package/dist/tools/builtins/web/fetch.js +1 -1
  228. package/dist/tools/builtins/web/search.js +1 -1
  229. package/dist/tools/connector-account-policies.js +3 -0
  230. package/dist/tools/connectors.controller.d.ts +37 -9
  231. package/dist/tools/connectors.controller.js +47 -12
  232. package/dist/tools/connectors.schemas.d.ts +4 -0
  233. package/dist/tools/connectors.schemas.js +13 -1
  234. package/dist/tools/connectors.service.d.ts +17 -0
  235. package/dist/tools/connectors.service.js +36 -2
  236. package/dist/tools/drift.js +5 -0
  237. package/dist/tools/git-push-policy.js +3 -0
  238. package/dist/tools/oauth/discovery.d.ts +2 -2
  239. package/dist/tools/oauth/discovery.js +2 -2
  240. package/dist/tools/oauth/flow.js +1 -0
  241. package/dist/tools/outputs.js +2 -0
  242. package/dist/tools/permission-approval-jobs.js +3 -0
  243. package/dist/tools/pipeline.js +2 -0
  244. package/dist/tools/policy.js +3 -0
  245. package/dist/tools/questions.service.js +13 -0
  246. package/package.json +3 -3
  247. package/src/migrations/0181_connector_description.sql +3 -0
@@ -17,15 +17,9 @@ import { OrgCatalogService } from "./org-catalog.service.js";
17
17
  * `PUT orgs/:orgId/extensions/:extension`: for an extension that ships in a catalog plugin, `enabled`
18
18
  * is the plugin's org switch ({@link OrgCatalogService.setSwitch}); anything else is the direct
19
19
  * {@link OrgExtensionConfigs.put}. Lives in the catalog module because the catalog depends on the
20
- * extensions, not the other way round. No in-process state.
21
- *
22
- * Order: the config is validated first (`validateOnly`: no side effect), so an invalid config fails
23
- * before the plugin switches with the plain 400 `extension.config_invalid`. Switching on validates
24
- * the effective config (the stored one with its secrets, or the given `config` merged with them),
25
- * and the install receives the given `config` as its `extensionConfig`, so the extension is enabled
26
- * with it. A config write that fails for another reason after the switch succeeded returns that
27
- * error in the same transaction as the switch, so the switch stays as it was (a fresh install is the
28
- * exception: it commits on its own and carries the config itself).
20
+ * extensions, not the other way round. No in-process state. Switching never checks a config: an
21
+ * extension whose effective config is not valid in the org is switched on and reported
22
+ * `needsConfig` (spec A §6).
29
23
  */
30
24
  let OrgExtensionSwitch = class OrgExtensionSwitch {
31
25
  txHost;
@@ -42,7 +36,6 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
42
36
  * source items) -> 409 `plugin.scope_locked` (an `all` one may go off, layering spec §4).
43
37
  * - A required bootstrap plugin, a config-declared extension and one sourced from several items
44
38
  * keep the direct write.
45
- * - `config` is always written directly, after the switch.
46
39
  */
47
40
  async put(orgId, actor, extension, body, actorTokenId,
48
41
  /** Merged into the audit details (a Platform operation's `via: "agent"`). */
@@ -62,16 +55,9 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
62
55
  };
63
56
  }
64
57
  const { enabled } = input;
65
- const config = input.config !== undefined ? { config: input.config } : {};
66
- // Fail before the switch when the config would be refused: switching on checks the effective
67
- // config (a required field never saved is refused here, not as a failed install)
68
- if (enabled || input.config !== undefined) {
69
- await this.configs.put(orgId, extension, { ...config, ...(enabled && { enabled: true }) }, actor, actorTokenId, { validateOnly: true });
70
- }
71
58
  // A fresh install is a multi-step saga that commits on its own and already enables the
72
- // extension with the given config (`extensionConfig`): no transaction spans it, and no second
73
- // config write follows. Everything else (the switch row, an uninstall, the config write) is one
74
- // transaction: a failing config write leaves the switch as it was.
59
+ // extension: no transaction spans it. Everything else (the switch row, an uninstall, reading
60
+ // the result back) is one transaction.
75
61
  const installing = enabled === true && !(await this.catalog.hasLiveInstall(orgId, plan.itemId));
76
62
  const args = {
77
63
  orgId,
@@ -79,7 +65,6 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
79
65
  extension,
80
66
  itemId: plan.itemId,
81
67
  enabled,
82
- input,
83
68
  confirm,
84
69
  actorTokenId,
85
70
  auditDetail,
@@ -103,7 +88,7 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
103
88
  return this.apply(a, false);
104
89
  }
105
90
  async apply(a, installing) {
106
- const { orgId, actor, extension, itemId, enabled, input, confirm, actorTokenId, auditDetail } = a;
91
+ const { orgId, actor, extension, itemId, enabled, confirm, actorTokenId, auditDetail } = a;
107
92
  const audited = auditDetail !== undefined ? { auditDetail } : {};
108
93
  // Switching on inside the transaction relies on the live install seen before it: one removed
109
94
  // meanwhile would run the install saga here, which commits on its own. Refuse instead; the
@@ -111,34 +96,18 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
111
96
  if (!installing && enabled === true && !(await this.catalog.hasLiveInstall(orgId, itemId))) {
112
97
  throw new ApiError("conflict", "The plugin's install in this organization changed while it was being switched on; try again");
113
98
  }
114
- const r = await this.catalog
115
- .setSwitch(orgId, actor, itemId, enabled
116
- ? {
117
- enabled: true,
118
- ...(input.config !== undefined && { inputs: { extensionConfig: input.config } }),
119
- }
120
- : { enabled: false, ...(confirm !== undefined && { confirm }) }, actorTokenId, auditDetail)
121
- .catch((e) => {
122
- throw configInvalidOf(e) ?? e;
123
- });
99
+ const r = await this.catalog.setSwitch(orgId, actor, itemId, enabled ? { enabled: true } : { enabled: false, ...(confirm !== undefined && { confirm }) }, actorTokenId, auditDetail);
124
100
  if (r.kind === "preview")
125
101
  return r;
126
- if (input.config === undefined) {
127
- if (!enabled) {
128
- return "readBack";
129
- }
130
- // Switching on: the install enabled it already (no second write)
131
- return {
132
- kind: "done",
133
- view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
134
- ifDisabled: { skipped: false },
135
- ...audited,
136
- }),
137
- };
138
- }
102
+ if (!enabled)
103
+ return "readBack";
104
+ // Switching on: the install enabled it already (no second write)
139
105
  return {
140
106
  kind: "done",
141
- view: await this.configs.put(orgId, extension, { config: input.config, ...(enabled && { enabled: true }) }, actor, actorTokenId, installing ? { ifDisabled: { skipped: false }, ...audited } : audited),
107
+ view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
108
+ ifDisabled: { skipped: false },
109
+ ...audited,
110
+ }),
142
111
  };
143
112
  }
144
113
  };
@@ -152,18 +121,3 @@ OrgExtensionSwitch = __decorate([
152
121
  __param(2, Inject(OrgCatalogService))
153
122
  ], OrgExtensionSwitch);
154
123
  export { OrgExtensionSwitch };
155
- /**
156
- * An install that failed only at its own extension step on the org config (it was valid when
157
- * checked, then changed concurrently): the plain 400 `extension.config_invalid` with the field
158
- * issues, as when saving the config; the install was rolled back. Anything else: undefined.
159
- */
160
- function configInvalidOf(e) {
161
- if (!(e instanceof ApiError) || e.code !== "plugin.install_failed")
162
- return undefined;
163
- const [d] = (e.details ?? []);
164
- if (d?.step !== "extension" || d.code !== "extension.config_invalid")
165
- return undefined;
166
- if (d.dependency !== undefined || d.rolledBack !== true)
167
- return undefined;
168
- return new ApiError("extension.config_invalid", d.message ?? "Invalid organization config", d.causeDetails);
169
- }
@@ -31,14 +31,13 @@ export type OrgExtensionItem = OrgExtensionView & {
31
31
  };
32
32
  /**
33
33
  * What a member sees of an extension: its state and the points it provides (names only, what the
34
- * 扩展 page sorts by), never the org config, the secrets' state, the config schema, the
35
- * permission list, the suggested appearance (members cannot apply it) or the client build (part of
36
- * the permission review).
34
+ * Extensions page sorts by), never the permission list, the suggested appearance (members cannot
35
+ * apply it) or the client build (part of the permission review).
37
36
  */
38
- export type OrgExtensionMemberItem = Omit<OrgExtensionItem, "config" | "secrets" | "orgConfigSchema" | "permissions" | "suggestedAppearance" | "client">;
37
+ export type OrgExtensionMemberItem = Omit<OrgExtensionItem, "permissions" | "suggestedAppearance" | "client">;
39
38
  /**
40
- * Org-level extension enablement and config (`/api/v1/orgs/:orgId/extensions`); responses echo only
41
- * non-secret config and whether each secret is set.
39
+ * Org-level extension enablement (`/api/v1/orgs/:orgId/extensions`); an org's config of an
40
+ * extension is its copy of the overridable deployment fields (the overrides routes below).
42
41
  */
43
42
  export declare class OrgExtensionConfigsController {
44
43
  private readonly configs;
@@ -56,7 +55,7 @@ export declare class OrgExtensionConfigsController {
56
55
  extensions: OrgExtensionItem[] | OrgExtensionMemberItem[];
57
56
  }>;
58
57
  /**
59
- * Writes enablement and / or config; see {@link OrgExtensionSwitch.put} for how `enabled` follows
58
+ * Writes enablement; see {@link OrgExtensionSwitch.put} for how `enabled` follows
60
59
  * the extension's plugin (off answers `{ preview, confirm }` until `confirm` carries the hash).
61
60
  */
62
61
  put(principal: Principal, org: OrgContext, extension: string, body: z.infer<typeof PutBody>): Promise<{
@@ -38,8 +38,8 @@ class OrgOverridesPutBody extends createZodDto(OverridesPut, "OrgOverridesPutBod
38
38
  class OrgOverridesTakeBody extends createZodDto(OverridesTake, "OrgOverridesTakeBody") {
39
39
  }
40
40
  /**
41
- * Org-level extension enablement and config (`/api/v1/orgs/:orgId/extensions`); responses echo only
42
- * non-secret config and whether each secret is set.
41
+ * Org-level extension enablement (`/api/v1/orgs/:orgId/extensions`); an org's config of an
42
+ * extension is its copy of the overridable deployment fields (the overrides routes below).
43
43
  */
44
44
  let OrgExtensionConfigsController = class OrgExtensionConfigsController {
45
45
  configs;
@@ -81,11 +81,11 @@ let OrgExtensionConfigsController = class OrgExtensionConfigsController {
81
81
  if (admin)
82
82
  return { extensions: items };
83
83
  return {
84
- extensions: items.map(({ config: _c, secrets: _s, orgConfigSchema: _o, permissions: _p, suggestedAppearance: _a, client: _cl, ...rest }) => rest),
84
+ extensions: items.map(({ permissions: _p, suggestedAppearance: _a, client: _cl, ...rest }) => rest),
85
85
  };
86
86
  }
87
87
  /**
88
- * Writes enablement and / or config; see {@link OrgExtensionSwitch.put} for how `enabled` follows
88
+ * Writes enablement; see {@link OrgExtensionSwitch.put} for how `enabled` follows
89
89
  * the extension's plugin (off answers `{ preview, confirm }` until `confirm` carries the hash).
90
90
  */
91
91
  async put(principal, org, extension, body) {
@@ -12,10 +12,9 @@ export declare const OrgToolSwitchPut: z.ZodObject<{
12
12
  enabled: z.ZodBoolean;
13
13
  confirm: z.ZodOptional<z.ZodString>;
14
14
  }, z.core.$strict>;
15
- /** `PUT /orgs/:orgId/extensions/:extension`: enablement and / or the org config. */
15
+ /** `PUT /orgs/:orgId/extensions/:extension`: enablement (an org's config is its copy: `…/overrides`). */
16
16
  export declare const OrgExtensionPut: z.ZodObject<{
17
17
  enabled: z.ZodOptional<z.ZodBoolean>;
18
- config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
19
18
  force: z.ZodOptional<z.ZodBoolean>;
20
19
  confirm: z.ZodOptional<z.ZodString>;
21
20
  }, z.core.$strict>;
@@ -12,12 +12,10 @@ export const OrgToolSwitchPut = z
12
12
  confirm: z.string().min(1).max(128).optional(),
13
13
  })
14
14
  .strict();
15
- /** `PUT /orgs/:orgId/extensions/:extension`: enablement and / or the org config. */
15
+ /** `PUT /orgs/:orgId/extensions/:extension`: enablement (an org's config is its copy: `…/overrides`). */
16
16
  export const OrgExtensionPut = z
17
17
  .object({
18
18
  enabled: z.boolean().optional(),
19
- /** The whole org config: secret fields omitted keep, `null` clears, a value sets. */
20
- config: z.record(z.string(), z.unknown()).optional(),
21
19
  force: z.boolean().optional(),
22
20
  /** The hash of the plugin uninstall preview, to confirm switching the extension's plugin off. */
23
21
  confirm: z.string().optional(),
@@ -126,13 +126,19 @@ let OwnedItems = class OwnedItems {
126
126
  await this.orgLock.lockAndAuthorize(orgId, actor, kind === "skill" ? "skills.manage" : "agents.manage");
127
127
  const row = await this.ownedComponent(orgId, kind, id, true);
128
128
  if (kind === "skill") {
129
- await this.db.updateTable("skills").set({ shareable }).where("id", "=", row.id).execute();
129
+ await this.db
130
+ .updateTable("skills")
131
+ .set({ shareable })
132
+ .where("id", "=", row.id)
133
+ .where("org_id", "=", orgId)
134
+ .execute();
130
135
  }
131
136
  else {
132
137
  await this.db
133
138
  .updateTable("agent_templates")
134
139
  .set({ shareable })
135
140
  .where("id", "=", row.id)
141
+ .where("org_id", "=", orgId)
136
142
  .execute();
137
143
  }
138
144
  // promoted: the platform row is the one every gate reads (ruling P3-2), written in this
@@ -428,6 +434,7 @@ let OwnedItems = class OwnedItems {
428
434
  .where("id", "=", item.id)
429
435
  .execute();
430
436
  if (item.scope === "all") {
437
+ // org-filter: the ownership transfer rewrites the item's whole named list (every org using it)
431
438
  await t.deleteFrom("catalog_item_scope_orgs").where("item_id", "=", item.id).execute();
432
439
  await t
433
440
  .insertInto("catalog_item_scope_orgs")
@@ -472,6 +479,7 @@ let OwnedItems = class OwnedItems {
472
479
  .set({ scope: "named", updated_at: now })
473
480
  .where("id", "=", c.id)
474
481
  .execute();
482
+ // org-filter: the ownership transfer narrows the component's whole named list to the orgs on
475
483
  await t
476
484
  .deleteFrom("component_scope_orgs")
477
485
  .where("kind", "=", c.kind)
@@ -627,6 +635,7 @@ let OwnedItems = class OwnedItems {
627
635
  .where("id", "=", id)
628
636
  .execute();
629
637
  if (narrowTo !== null) {
638
+ // org-filter: the ownership transfer narrows the component's whole named list to the orgs on
630
639
  await t
631
640
  .deleteFrom("component_scope_orgs")
632
641
  .where("kind", "=", kind)
@@ -271,6 +271,8 @@ export function ownerOf(ownerOrgId, owners) {
271
271
  * `except` (usually the owner), by name. One definition for the update notices and the
272
272
  * "used by another org" check of deletes. An item that is gone or disabled is on nowhere.
273
273
  */
274
+ // org-filter: answers which orgs an item is on in, so it reads the item's named list and switches
275
+ // of every org on purpose (keyed by the item id)
274
276
  export async function orgsUsing(db, ref, opts = {}) {
275
277
  const orgs = await db
276
278
  .selectFrom("orgs")
@@ -127,7 +127,10 @@ export interface PluginReviewClient {
127
127
  export interface PluginReviewTemplate {
128
128
  id: string;
129
129
  displayName: LocalizedName;
130
+ /** The English text, or the one text of a plain-string description ("" without one). */
130
131
  description: string;
132
+ /** The Chinese text of a `{ zh, en }` description; null: `description` serves both languages. */
133
+ descriptionZh: string | null;
131
134
  plugin: string;
132
135
  connector: string;
133
136
  endpoint: Record<string, unknown>;
@@ -57,6 +57,7 @@ import { hasImportRequests, importRequestOf, resolveImportRequests } from "./req
57
57
  import { assertNameNotReserved } from "./reserved-names.js";
58
58
  import { oweScopeItem } from "./scope-jobs.js";
59
59
  import { addScopeOrg } from "./scope-orgs.js";
60
+ import { templateDescriptionText } from "./template-description.js";
60
61
  import { maxSatisfying, satisfiesRange } from "./versions.js";
61
62
  /**
62
63
  * Platform import of a plugin (package ecosystem spec §4.3): one review for every plugin, whatever
@@ -583,6 +584,7 @@ let PluginImport = class PluginImport {
583
584
  async staged(stagingId, owner) {
584
585
  if (!UUID_RE.test(stagingId))
585
586
  throw notFound();
587
+ // org-filter: ownStaging(owner) pins the row to the caller's org (org_id NULL for the platform)
586
588
  const row = await this.db
587
589
  .selectFrom("plugin_import_staging")
588
590
  .select(["id", "review", "manifest"])
@@ -610,6 +612,7 @@ let PluginImport = class PluginImport {
610
612
  async stagedTarget(stagingId, owner) {
611
613
  if (!UUID_RE.test(stagingId))
612
614
  throw notFound();
615
+ // org-filter: ownStaging(owner) pins the row to the caller's org (org_id NULL for the platform)
613
616
  const row = await this.db
614
617
  .selectFrom("plugin_import_staging")
615
618
  .select(["review", "manifest", "object_prefix"])
@@ -707,6 +710,7 @@ let PluginImport = class PluginImport {
707
710
  { path: "orgs", message: "scope named needs at least one organization" },
708
711
  ]);
709
712
  }
713
+ // org-filter: ownStaging(owner) pins the row to the caller's org (org_id NULL for the platform)
710
714
  const row = await this.db
711
715
  .selectFrom("plugin_import_staging")
712
716
  .selectAll()
@@ -830,6 +834,7 @@ let PluginImport = class PluginImport {
830
834
  const { owner } = scope;
831
835
  await this.authorizeActor(actor, owner);
832
836
  const t = this.db;
837
+ // org-filter: ownStaging(owner) pins the row to the caller's org (org_id NULL for the platform)
833
838
  const used = await t
834
839
  .deleteFrom("plugin_import_staging")
835
840
  .where("id", "=", stagingId)
@@ -905,6 +910,7 @@ let PluginImport = class PluginImport {
905
910
  await assertNameNotReserved(t, m.name);
906
911
  await this.resolveDependencies(m, owner);
907
912
  }
913
+ // org-filter: the existing item's whole named list (spans orgs), keyed by its item id
908
914
  const actual = existing === undefined
909
915
  ? scope
910
916
  : {
@@ -1276,6 +1282,7 @@ let PluginImport = class PluginImport {
1276
1282
  return total;
1277
1283
  }
1278
1284
  /** The expired staging rows, batch by batch; returns the rows deleted. */
1285
+ // org-filter: deployment-wide expiry sweep (maintenance job) over every org's staging rows
1279
1286
  async cleanupStagingRows() {
1280
1287
  let total = 0;
1281
1288
  for (;;) {
@@ -1309,6 +1316,7 @@ let PluginImport = class PluginImport {
1309
1316
  * One expired staging row (row lock, `SKIP LOCKED`): its objects, then the row; false when another
1310
1317
  * replica has it or it is gone.
1311
1318
  */
1319
+ // org-filter: deployment-wide expiry sweep; the row id comes from the sweep's own read
1312
1320
  async cleanupOne(r) {
1313
1321
  const t = this.db;
1314
1322
  const locked = await t
@@ -1350,6 +1358,7 @@ let PluginImport = class PluginImport {
1350
1358
  .executeTakeFirst();
1351
1359
  if (!pkg)
1352
1360
  return;
1361
+ // org-filter: whether any staging of any org still uses the package (content-addressed sha)
1353
1362
  const used = (await t
1354
1363
  .selectFrom("extension_installs")
1355
1364
  .select("name")
@@ -1525,7 +1534,7 @@ let PluginImport = class PluginImport {
1525
1534
  return {
1526
1535
  id: c.id,
1527
1536
  displayName: c.file.displayName,
1528
- description: c.file.description ?? "",
1537
+ ...templateDescriptionText(c.file.description),
1529
1538
  plugin: t.plugin,
1530
1539
  connector: t.connector,
1531
1540
  endpoint: t.endpoint,
@@ -35,8 +35,6 @@ export interface ConnectorInstallInput {
35
35
  */
36
36
  export interface PluginInstallInput {
37
37
  connectors?: Record<string, ConnectorInstallInput>;
38
- /** The org config of the plugin's extension (used only when this install enables it). */
39
- extensionConfig?: Record<string, unknown>;
40
38
  }
41
39
  /**
42
40
  * `plugin` is a dependency install (ref = its plugin install id); `agent_template` (phase C) an
@@ -166,7 +164,6 @@ export interface InstallPlan {
166
164
  sourceFormat: SourceFormat;
167
165
  /** The plugin's own extension, to enable in the org. */
168
166
  extension: string | null;
169
- extensionConfig: Record<string, unknown> | undefined;
170
167
  templates: {
171
168
  id: string;
172
169
  file: ConnectorTemplateFile;
@@ -412,7 +409,7 @@ export declare class PluginInstaller {
412
409
  * unaffected.
413
410
  */
414
411
  planExtension(orgId: string, manifest: PluginManifest): Promise<string | null>;
415
- /** The input only names the plugin's template ids, and an extension config needs an extension. */
412
+ /** The input only names the plugin's template ids. */
416
413
  private checkInput;
417
414
  /**
418
415
  * Undoes the components this install created, in reverse order (the role is not re-checked: it
@@ -482,7 +482,7 @@ let PluginInstaller = class PluginInstaller {
482
482
  }
483
483
  }
484
484
  else {
485
- this.checkInput(manifest, allTemplates, input, at);
485
+ this.checkInput(allTemplates, input, at);
486
486
  for (const ct of templates) {
487
487
  // The kernel installs only what needs no org input (the scope sync's `needs_config` rule)
488
488
  if (actor === null)
@@ -513,7 +513,6 @@ let PluginInstaller = class PluginInstaller {
513
513
  row: v,
514
514
  sourceFormat: v.source_format,
515
515
  extension,
516
- extensionConfig: input?.extensionConfig,
517
516
  templates,
518
517
  connectors,
519
518
  skillNames,
@@ -743,10 +742,7 @@ let PluginInstaller = class PluginInstaller {
743
742
  }
744
743
  step = "extension";
745
744
  if (plan.extension !== null) {
746
- await this.enableExtension(orgId, plan.extension, {
747
- enabled: true,
748
- ...(plan.extensionConfig !== undefined && { config: plan.extensionConfig }),
749
- }, actor, opts.actorTokenId, { viaItem: itemId, ...(nested && { approvedBy }) }, record);
745
+ await this.enableExtension(orgId, plan.extension, { enabled: true }, actor, opts.actorTokenId, { viaItem: itemId, ...(nested && { approvedBy }) }, record);
750
746
  }
751
747
  step = "connectors";
752
748
  for (const ct of plan.templates) {
@@ -889,6 +885,7 @@ let PluginInstaller = class PluginInstaller {
889
885
  .where("i.id", "=", itemId), eb.ref("plugin_installs.version")),
890
886
  }))
891
887
  .where("id", "=", installId)
888
+ .where("org_id", "=", orgId)
892
889
  .where("status", "=", "installing")
893
890
  .executeTakeFirst();
894
891
  // The install row was already cleaned up as stale: do not audit plugin.org_installed, roll
@@ -927,6 +924,7 @@ let PluginInstaller = class PluginInstaller {
927
924
  .updateTable("plugin_installs")
928
925
  .set({ status: "failed", error: JSON.stringify({ step, code }) })
929
926
  .where("id", "=", installId)
927
+ .where("org_id", "=", orgId)
930
928
  .execute();
931
929
  await audit(t, {
932
930
  actorAccountId: actor,
@@ -967,16 +965,13 @@ let PluginInstaller = class PluginInstaller {
967
965
  }
968
966
  return name;
969
967
  }
970
- /** The input only names the plugin's template ids, and an extension config needs an extension. */
971
- checkInput(manifest, templates, input, at) {
968
+ /** The input only names the plugin's template ids. */
969
+ checkInput(templates, input, at) {
972
970
  const ids = new Set(templates.map((c) => c.id));
973
971
  for (const k of Object.keys(input.connectors ?? {})) {
974
972
  if (!ids.has(k))
975
973
  throw fail(`${at}connectors.${k}`, "No such connector template in this plugin");
976
974
  }
977
- if (input.extensionConfig !== undefined && !manifest.extension) {
978
- throw fail(`${at}extensionConfig`, "This plugin has no extension");
979
- }
980
975
  }
981
976
  /**
982
977
  * Undoes the components this install created, in reverse order (the role is not re-checked: it
@@ -1399,7 +1394,11 @@ let PluginInstaller = class PluginInstaller {
1399
1394
  else if (outcome !== "gone")
1400
1395
  keep(outcome);
1401
1396
  }
1402
- await t.deleteFrom("plugin_installs").where("id", "=", installId).execute();
1397
+ await t
1398
+ .deleteFrom("plugin_installs")
1399
+ .where("id", "=", installId)
1400
+ .where("org_id", "=", orgId)
1401
+ .execute();
1403
1402
  await audit(t, {
1404
1403
  actorAccountId: actor,
1405
1404
  ...(ctx.opts.actorTokenId !== undefined && { actorTokenId: ctx.opts.actorTokenId }),
@@ -1477,7 +1477,10 @@ __decorate([
1477
1477
  Transactional({ propagation: "requires_new" })
1478
1478
  ], PlatformPluginUpdater.prototype, "commit", null);
1479
1479
  PlatformPluginUpdater = __decorate([
1480
- Injectable(),
1480
+ Injectable()
1481
+ // org-filter: the platform plugin update (one version per deployment) moves the item's installs,
1482
+ // connectors and pinned copies in every org by design, keyed by the platform item / template ids
1483
+ ,
1481
1484
  __param(0, Inject(KernelDb)),
1482
1485
  __param(1, Inject(TransactionHost)),
1483
1486
  __param(2, Inject(SuperAdminLock)),
@@ -163,6 +163,8 @@ export async function resolveRequestsByInstall(db, orgId, itemId, actor, opts =
163
163
  }
164
164
  }
165
165
  /** The pending `import` request linked to a staged import (its approval prepared it), if any. */
166
+ // org-filter: by the staging id of the confirm's own staging row (ownStaging checked it); a platform
167
+ // staging prepared by approving import requests links requests of several orgs, read on purpose
166
168
  export async function importRequestOf(db, stagingId) {
167
169
  const r = await db
168
170
  .selectFrom("catalog_requests")
@@ -174,6 +176,8 @@ export async function importRequestOf(db, stagingId) {
174
176
  return r && { id: r.id, orgId: r.org_id };
175
177
  }
176
178
  /** Whether pending `import` requests are linked to the staging (its confirm resolves them). */
179
+ // org-filter: by the staging id of the confirm's own staging row (ownStaging checked it); a platform
180
+ // staging prepared by approving import requests links requests of several orgs, read on purpose
177
181
  export async function hasImportRequests(db, stagingId) {
178
182
  const r = await db
179
183
  .selectFrom("catalog_requests")
@@ -189,6 +193,8 @@ export async function hasImportRequests(db, stagingId) {
189
193
  * staging are approved (decider: the confirming admin) and point at the item. Audits
190
194
  * `catalog.request_decided`. Returns the requests' orgs.
191
195
  */
196
+ // org-filter: by the staging id of the confirm's own staging row (ownStaging checked it); a platform
197
+ // staging prepared by approving import requests links requests of several orgs, read on purpose
192
198
  export async function resolveImportRequests(db, stagingId, itemId, actor, opts = {}) {
193
199
  const rows = await db
194
200
  .updateTable("catalog_requests")
@@ -504,6 +504,7 @@ let CatalogRequestsService = class CatalogRequestsService {
504
504
  /** A pending `access` / `import` request (the row locked; the super admin re-checked). */
505
505
  async pendingDeploymentRequest(actor, requestId) {
506
506
  await this.adminLock.lockAndAuthorize(actor);
507
+ // org-filter: super admin decides deployment requests of every org (adminLock just above)
507
508
  const row = await this.db
508
509
  .selectFrom("catalog_requests")
509
510
  .select(["kind", "status", "marketplace_id", "entry_name", "entry_version", "staging_id"])
@@ -520,6 +521,7 @@ let CatalogRequestsService = class CatalogRequestsService {
520
521
  /** Links a still pending `import` request to its prepared staging. */
521
522
  async linkStaging(actor, requestId, stagingId, opts) {
522
523
  await this.adminLock.lockAndAuthorize(actor);
524
+ // org-filter: super admin links any org's import request (adminLock just above)
523
525
  const row = await this.db
524
526
  .selectFrom("catalog_requests")
525
527
  .select(["org_id", "status", "entry_name"])
@@ -532,6 +534,7 @@ let CatalogRequestsService = class CatalogRequestsService {
532
534
  .updateTable("catalog_requests")
533
535
  .set({ staging_id: stagingId })
534
536
  .where("id", "=", requestId)
537
+ .where("org_id", "=", row.org_id)
535
538
  .execute();
536
539
  await audit(this.db, {
537
540
  actorAccountId: actor,
@@ -605,6 +608,7 @@ let CatalogRequestsService = class CatalogRequestsService {
605
608
  decided_at: sql `now()`,
606
609
  })
607
610
  .where("id", "=", requestId)
611
+ .where("org_id", "=", row.org_id)
608
612
  .execute();
609
613
  await audit(t, {
610
614
  actorAccountId: actor,
@@ -40,6 +40,7 @@ export async function addScopeOrg(db, actor, item, orgId, opts = {}) {
40
40
  })
41
41
  .where("id", "=", item.id)
42
42
  .execute();
43
+ // org-filter: the item's whole named list after the add, for the scope_changed audit (spans orgs)
43
44
  const rows = await db
44
45
  .selectFrom("catalog_item_scope_orgs")
45
46
  .select("org_id")
@@ -1,3 +1,4 @@
1
+ import { EffectiveConfigs } from "../extensions/effective-config.js";
1
2
  import { ExtensionRegistry } from "../extensions/registry.js";
2
3
  import { KernelDb } from "../infra/database/kernel-db.js";
3
4
  import { TransactionHost } from "../infra/database/transaction-host.js";
@@ -79,12 +80,13 @@ export declare class PluginScopeSync {
79
80
  private readonly outbox;
80
81
  private readonly installer;
81
82
  private readonly registry;
83
+ private readonly effective;
82
84
  private readonly locks;
83
85
  private readonly log;
84
86
  readonly txHost: TransactionHost;
85
87
  /** Orgs per chunk job (a test seam; default {@link SCOPE_ORG_CHUNK}). */
86
88
  private readonly chunkSize;
87
- constructor(kdb: KernelDb, outbox: Pick<OutboxService, "add" | "addMany">, installer: PluginInstaller, registry: ExtensionRegistry, locks: LockService, log: KernelLogger, txHost: TransactionHost,
89
+ constructor(kdb: KernelDb, outbox: Pick<OutboxService, "add" | "addMany">, installer: PluginInstaller, registry: ExtensionRegistry, effective: Pick<EffectiveConfigs, "get">, locks: LockService, log: KernelLogger, txHost: TransactionHost,
88
90
  /** Orgs per chunk job (a test seam; default {@link SCOPE_ORG_CHUNK}). */
89
91
  chunkSize?: number);
90
92
  private get db();
@@ -126,18 +128,19 @@ export declare class PluginScopeSync {
126
128
  private syncLocked;
127
129
  /** Whether a live install of the org depends on this install (spec §5 rule 9). */
128
130
  dependedOn(orgId: string, installId: string): Promise<boolean>;
129
- /** The items of the dependency installs this install created. */
131
+ /** The items of the dependency installs this install (of `orgId`) created. */
130
132
  private createdDependencies;
131
133
  /**
132
134
  * Whether installing the item (with the dependencies the org lacks) needs the org's input: a
133
- * connector template, or an extension whose org config is required and not set in the org. The
134
- * same rule as the org catalog's `needs_config`, applied to the whole tree.
135
+ * connector template, or an extension whose effective config for the org is not valid. The same
136
+ * rule as the org catalog's `needs_config`, applied to the whole tree.
135
137
  */
136
138
  needsInput(orgId: string, itemId: string, version: string): Promise<boolean>;
137
139
  /**
138
140
  * Whether installing plugin `itemId` (manifest `m`) needs the org's input: a connector template
139
141
  * on in the org (ruling P2-6: templates switched off there, outside their own scope or disabled
140
- * make no connector), or a required org config of its extension not set yet.
142
+ * make no connector), or its extension's effective config for the org is not valid (a required
143
+ * overridable field the platform leaves empty and the org has no copy of).
141
144
  */
142
145
  private manifestNeedsInput;
143
146
  /**