@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
@@ -10,8 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { EXTENSION_POINTS, parseExtensionPoint } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { z } from "zod";
13
- import { OrgExtensionParams, OrgExtensionPut, OrgExtensionToolParams, OrgOverridesPut, OrgOverridesTake, OrgToolSwitchPut, } from "../../catalog/org-extension.schemas.js";
14
- import { OrgExtensionSwitch } from "../../catalog/org-extension-switch.js";
13
+ import { OrgExtensionParams, OrgExtensionToolParams, OrgOverridesPut, OrgOverridesTake, OrgToolSwitchPut, } from "../../catalog/org-extension.schemas.js";
15
14
  import { ApiError } from "../../errors.js";
16
15
  import { ExtensionDisplayNames } from "../../extensions/display-name.js";
17
16
  import { OrgExtensionConfigs, providesOf, } from "../../extensions/org-config.js";
@@ -27,7 +26,7 @@ import { personFieldParams, secretFieldsOf } from "../person-fields.js";
27
26
  import { PlatformOperations } from "../registry.js";
28
27
  import { precheckBy, viaAgent } from "./errors.js";
29
28
  import { Cursor, pageOf, startOf } from "./paging.js";
30
- import { configChanges, flatValues, nestedConfig, withPersonInputs } from "./person-inputs.js";
29
+ import { configChanges, flatValues, withPersonInputs } from "./person-inputs.js";
31
30
  import { roleOf } from "./role.js";
32
31
  import { localized, named, orElse } from "./summary.js";
33
32
  import { roleFor, unavailableFields } from "./unavailable.js";
@@ -37,11 +36,9 @@ const Tool = OrgExtensionToolParams.shape.tool;
37
36
  const SwitchConfirm = OrgToolSwitchPut.shape.confirm.unwrap();
38
37
  /** The next step of an extension that needs its org config. */
39
38
  const NEEDS_ORG_CONFIG = {
40
- orgAdmin: "Read what is missing with extensions.org-config, then fill it in with extensions.set-org-config (or the org's own copy of overridable platform fields with extensions.save-org-config); the person enters secrets in a secure input request.",
39
+ orgAdmin: "Read what is missing with extensions.org-config, then fill in the org's own copy of the overridable fields with extensions.save-org-config; the person enters secrets in a secure input request.",
41
40
  member: "Ask an org admin to fill in its org config on the Extensions page.",
42
41
  };
43
- /** The org config a write replaces (the whole non-secret config; secrets left out keep). */
44
- const OrgConfigValues = OrgExtensionPut.shape.config.unwrap();
45
42
  /**
46
43
  * Secret fields of a target the schema walk cannot address (no form schema, a record): web only,
47
44
  * so a value for one in `values` is refused as well.
@@ -54,16 +51,17 @@ function withUnaddressed(found, secretPaths) {
54
51
  };
55
52
  }
56
53
  /**
57
- * The person fields of the org's copy: the copy's own secrets (under overridable top-level fields),
58
- * set or not. A secret under a read-only field is not the org's to set: never asked, and a value
59
- * for it in `values` is refused as well.
54
+ * The person fields of the org's copy: the copy's own secrets (under the listed overridable
55
+ * top-level fields), set or not. A secret under any other field is not the org's to set: never
56
+ * asked, and a value for it in `values` is refused as well.
60
57
  */
61
58
  export function copyPersonFields(v) {
62
59
  const secrets = v.fields.filter((f) => f.secret);
63
60
  const stored = new Set(secrets.filter((f) => f.org?.set === true).map((f) => f.path));
64
61
  // levels are per top-level property (org-levels.ts)
65
62
  const top = (path) => path.split(/[.[]/)[0];
66
- const overridable = new Set(v.fields.filter((f) => f.level === "override").map((f) => top(f.path)));
63
+ // the view lists overridable fields only
64
+ const overridable = new Set(v.fields.map((f) => top(f.path)));
67
65
  const found = secretFieldsOf(v.schema, stored);
68
66
  const fields = found.fields.filter((f) => overridable.has(top(f.path)));
69
67
  const notOurs = found.fields.filter((f) => !overridable.has(top(f.path))).map((f) => f.path);
@@ -80,8 +78,8 @@ function stateOf(v) {
80
78
  /**
81
79
  * Extension operations of the `Platform` tool (spec §7): the org's extensions (the member projection
82
80
  * of `GET /orgs/:orgId/extensions`, whatever the actor's role), their tool switches and point
83
- * defaults, and for org admins the org config and the org's copy of overridable platform fields
84
- * (read, write, take, save, drop; platform web parity spec §7.2). Secrets are never returned (only
81
+ * defaults, and for org admins the org's copy of overridable platform fields (read, take, save,
82
+ * drop; platform web parity spec §7.2). Secrets are never returned (only
85
83
  * whether each is set) and never taken as params: the person enters them in a secure input request.
86
84
  */
87
85
  let ExtensionsOperations = class ExtensionsOperations {
@@ -92,8 +90,7 @@ let ExtensionsOperations = class ExtensionsOperations {
92
90
  switches;
93
91
  pointDefaults;
94
92
  overrides;
95
- extSwitch;
96
- constructor(registry, configs, displayNames, kdb, switches, pointDefaults, overrides, extSwitch) {
93
+ constructor(registry, configs, displayNames, kdb, switches, pointDefaults, overrides) {
97
94
  this.registry = registry;
98
95
  this.configs = configs;
99
96
  this.displayNames = displayNames;
@@ -101,7 +98,6 @@ let ExtensionsOperations = class ExtensionsOperations {
101
98
  this.switches = switches;
102
99
  this.pointDefaults = pointDefaults;
103
100
  this.overrides = overrides;
104
- this.extSwitch = extSwitch;
105
101
  }
106
102
  /** The org view of one extension, or `extension.not_found` (not installed or not offered). */
107
103
  async viewOf(orgId, name) {
@@ -119,7 +115,7 @@ let ExtensionsOperations = class ExtensionsOperations {
119
115
  this.registry.register([
120
116
  defineOperation({
121
117
  id: "extensions.list",
122
- description: "List the extensions installed on the platform as this org sees them, one compact row each: the state here (on, off, needs_config: the org config is missing, unavailable: it cannot run on the platform), why an unavailable one cannot be used (reason) and your next step (next), whether it is available on the platform, the extension points it provides and the plugin that brings it. State only: an org admin reads and sets the config with extensions.org-config and extensions.set-org-config. Pages by 50: pass the returned next as params.cursor.",
118
+ description: "List the extensions installed on the platform as this org sees them, one compact row each: the state here (on, off, needs_config: its config for this org is not valid, unavailable: it cannot run on the platform), why an unavailable one cannot be used (reason) and your next step (next), whether it is available on the platform, the extension points it provides and the plugin that brings it. State only: an org admin reads the config with extensions.org-config and sets the org's copy with extensions.save-org-config. Pages by 50: pass the returned next as params.cursor.",
123
119
  input: z.object({ cursor: Cursor.optional() }).strict(),
124
120
  example: {},
125
121
  authz: { orgAction: "org.extensions.read" },
@@ -273,7 +269,7 @@ let ExtensionsOperations = class ExtensionsOperations {
273
269
  }),
274
270
  defineOperation({
275
271
  id: "extensions.org-config",
276
- description: "Read an extension's config in this org (org admins): orgConfig is the org's own config (the non-secret values, whether each secret is set, never its value, the form's JSON Schema with x-secret on secret fields, and needsConfig); deploymentCopy is the org's side of the platform's deployment config: following the platform or a copy, the read-only and overridable fields (platform values, the copy's values, secrets as set or not) and whether the effective config is valid. Null when the extension does not run on the platform.",
272
+ description: "Read an extension's config in this org (org admins): configurable (it has fields the org can override) and needsConfig (its config for this org is not valid); deploymentCopy is the org's side of the platform's deployment config: following the platform or a copy, the overridable fields (platform values, the copy's values, secrets as set or not, never a value) and whether the effective config is valid. deploymentCopy is null when the extension does not run on the platform.",
277
273
  input: z.object({ extension: Extension }).strict(),
278
274
  example: { extension: "model-anthropic" },
279
275
  authz: { orgAction: "org.extensions.manage" },
@@ -286,94 +282,20 @@ let ExtensionsOperations = class ExtensionsOperations {
286
282
  },
287
283
  ],
288
284
  run: async (input, ctx) => {
289
- // the web's Extensions page reads both: the org's own config (`config.org`) comes with the
290
- // org extension list, the copy of the platform's overridable fields from the overrides route
285
+ // the state comes with the org extension list, the copy of the platform's overridable
286
+ // fields from the overrides route
291
287
  const v = await this.viewOf(ctx.orgId, input.extension);
292
288
  return {
293
289
  extension: v.plugin,
294
290
  state: stateOf(v),
295
- orgConfig: {
296
- configurable: v.configurable,
297
- config: v.config,
298
- secrets: v.secrets,
299
- schema: v.orgConfigSchema,
300
- needsConfig: v.needsConfig,
301
- },
291
+ configurable: v.configurable,
292
+ needsConfig: v.needsConfig,
302
293
  deploymentCopy: v.available
303
294
  ? await this.overrides.view(ctx.orgId, input.extension)
304
295
  : null,
305
296
  };
306
297
  },
307
298
  }),
308
- defineOperation({
309
- id: "extensions.set-org-config",
310
- description: "Save an extension's org config (org admins): values is the whole non-secret config and replaces the stored one (read it first with extensions.org-config and keep the fields you do not change). Secret fields are never in values: list them in askPerson and the person types them in a secure input request (on the web); a secret not listed keeps its stored value; list stored secrets to empty in clearSecrets. Required secrets without a stored value are asked even when not listed. For overridable fields of the platform's deployment config (an org's own API key for a model provider, say) use extensions.save-org-config. Switching the extension on is plugins.set-enabled.",
311
- input: z
312
- .object({
313
- extension: Extension,
314
- values: OrgConfigValues,
315
- askPerson: personFieldParams.askPerson,
316
- clearSecrets: personFieldParams.clearSecrets,
317
- })
318
- .strict(),
319
- example: {
320
- extension: "lark",
321
- values: { appId: "cli_a1b2c3" },
322
- askPerson: ["appSecret"],
323
- clearSecrets: [],
324
- },
325
- authz: { orgAction: "org.extensions.manage" },
326
- mirrors: ["PUT /api/v1/orgs/:orgId/extensions/:extension"],
327
- renames: { values: "config" },
328
- // switching on and off is plugins.set-enabled (its preview and confirm)
329
- omits: ["enabled", "force", "confirm"],
330
- extras: ["askPerson", "clearSecrets"],
331
- confirm: "org",
332
- errors: [
333
- {
334
- code: "extension.not_found",
335
- next: "The extension is not running or not visible to this org; check the name with extensions.list.",
336
- },
337
- {
338
- code: "extension.no_org_config",
339
- next: "This extension has no org config. Its overridable platform fields, if any, are set with extensions.save-org-config.",
340
- },
341
- {
342
- code: "extension.config_invalid",
343
- next: "Read the form schema with extensions.org-config, correct the values (the error's details name the fields), then call again.",
344
- },
345
- ],
346
- personFields: async (i, ctx) => {
347
- const v = await this.viewOf(ctx.orgId, i.extension);
348
- const n = await this.nameOf(i.extension);
349
- const stored = new Set(v.secrets.filter((x) => x.set).map((x) => x.path));
350
- return {
351
- target: { zh: `扩展「${n.zh}」的组织配置`, en: `${n.en}: org config` },
352
- ...withUnaddressed(secretFieldsOf(v.orgConfigSchema, stored), v.secrets.map((x) => x.path)),
353
- };
354
- },
355
- summary: async (i, ctx) => {
356
- const n = await this.nameOf(i.extension);
357
- const c = configChanges(i, ctx);
358
- return {
359
- zh: `保存扩展「${n.zh}」的组织配置:${c.zh}`,
360
- en: `Save the org config of extension "${n.en}": ${c.en}`,
361
- };
362
- },
363
- run: async (input, ctx) => {
364
- const r = await withPersonInputs("extensions.set-org-config", ctx, (entered, detail) => this.extSwitch.put(ctx.orgId, ctx.actorAccountId, input.extension, { config: nestedConfig(input.values, entered, input.clearSecrets) }, undefined, detail));
365
- // a config-only write never previews (only switching off does)
366
- if (r.kind !== "done")
367
- throw new Error("a config-only org extension write previewed");
368
- const v = r.view;
369
- return {
370
- extension: v.plugin,
371
- state: stateOf(v),
372
- config: v.config,
373
- secrets: v.secrets,
374
- };
375
- },
376
- }),
377
299
  defineOperation({
378
300
  id: "extensions.save-org-config",
379
301
  description: "Save fields of the org's own copy of an extension's platform deployment config (org admins): only overridable fields (extensions.org-config lists them under deploymentCopy). values maps field dot paths to values (null clears; a field left out keeps). Secret fields are never in values: list them in askPerson and the person types them in a secure input request (on the web); list stored secrets to empty in clearSecrets. The first save makes the copy from the platform's non-secret values and must be valid on its own (its required secrets are asked).",
@@ -616,7 +538,6 @@ ExtensionsOperations = __decorate([
616
538
  __param(3, Inject(KernelDb)),
617
539
  __param(4, Inject(OrgToolSwitches)),
618
540
  __param(5, Inject(ExtensionPointDefaults)),
619
- __param(6, Inject(OrgOverrides)),
620
- __param(7, Inject(OrgExtensionSwitch))
541
+ __param(6, Inject(OrgOverrides))
621
542
  ], ExtensionsOperations);
622
543
  export { ExtensionsOperations };
@@ -5,7 +5,6 @@ import { OrgCatalogService } from "../../catalog/org-catalog.service.js";
5
5
  import { OrgPluginUploads } from "../../catalog/org-plugin-uploads.js";
6
6
  import { OwnedItems } from "../../catalog/owned-items.js";
7
7
  import { PluginInstaller } from "../../catalog/plugin-install.js";
8
- import { OrgExtensionConfigs } from "../../extensions/org-config.js";
9
8
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
10
9
  import { KernelDb } from "../../infra/database/kernel-db.js";
11
10
  import { ThemesService } from "../../themes/themes.service.js";
@@ -34,15 +33,13 @@ export declare class OrgPluginsOperations implements OnModuleInit {
34
33
  private readonly kdb;
35
34
  private readonly appearance;
36
35
  private readonly themes;
37
- private readonly extensions;
38
36
  private readonly config;
39
- constructor(registry: PlatformOperations, installer: PluginInstaller, orgCatalog: OrgCatalogService, uploads: OrgPluginUploads, owned: OwnedItems, scope: CatalogScopeService, kdb: KernelDb, appearance: AppearanceService, themes: ThemesService, extensions: OrgExtensionConfigs, config: KernelConfigService);
37
+ constructor(registry: PlatformOperations, installer: PluginInstaller, orgCatalog: OrgCatalogService, uploads: OrgPluginUploads, owned: OwnedItems, scope: CatalogScopeService, kdb: KernelDb, appearance: AppearanceService, themes: ThemesService, config: KernelConfigService);
40
38
  /**
41
39
  * What installing a plugin asks the person for (platform web parity spec §7.2): the connector
42
40
  * templates whose connector the install creates (on in the org, none kept from an earlier
43
- * switch-off, as the install wizard asks), and the secret fields of its extension's org config
44
- * under `extensionConfig.` (stored ones count as set; one the schema walk cannot address is web
45
- * only). An extension whose org view cannot be read refuses the call: its secrets are unknown.
41
+ * switch-off, as the install wizard asks). The extension's config for the org is its copy of the
42
+ * overridable fields, saved apart (`extensions.save-org-config`).
46
43
  */
47
44
  private installTargets;
48
45
  /** The missing connectors of an installed plugin that a configure call names. */
@@ -11,7 +11,7 @@ import { Inject, Injectable } from "@nestjs/common";
11
11
  import { z } from "zod";
12
12
  import { AppearanceService } from "../../catalog/appearance.service.js";
13
13
  import { CatalogScopeService } from "../../catalog/catalog-scope.service.js";
14
- import { CatalogConnectorInput, CatalogItemPathParams, OrgPluginInstallBody, PluginInstallPathParams, } from "../../catalog/org-catalog.schemas.js";
14
+ import { CatalogConnectorInput, CatalogItemPathParams, PluginInstallPathParams, } from "../../catalog/org-catalog.schemas.js";
15
15
  import { OrgCatalogService } from "../../catalog/org-catalog.service.js";
16
16
  import { OrgExtensionParams } from "../../catalog/org-extension.schemas.js";
17
17
  import { OrgPluginUploads } from "../../catalog/org-plugin-uploads.js";
@@ -19,19 +19,18 @@ import { OrgOwnedDeleteBody, OrgOwnedPluginParams, OrgOwnedShareableBody, OrgUpl
19
19
  import { OwnedItems } from "../../catalog/owned-items.js";
20
20
  import { PluginInstaller } from "../../catalog/plugin-install.js";
21
21
  import { ApiError } from "../../errors.js";
22
- import { OrgExtensionConfigs } from "../../extensions/org-config.js";
23
22
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
24
23
  import { KernelDb } from "../../infra/database/kernel-db.js";
25
24
  import { ThemesService } from "../../themes/themes.service.js";
26
25
  import { clientProblem, headersWebOnly, templateConnectorInput, templatePersonFields, } from "../connector-person-fields.js";
27
26
  import { FileRefSchema } from "../file-ref.js";
28
27
  import { defineOperation, } from "../operation.js";
29
- import { PersonFieldsRefused, personFieldParams, planPersonFields, secretFieldsOf, } from "../person-fields.js";
28
+ import { personFieldParams } from "../person-fields.js";
30
29
  import { PlatformOperations } from "../registry.js";
31
30
  import { appearanceSummary, reviewBrief } from "./catalog-admin.ops.js";
32
31
  import { precheckBy, viaAgent } from "./errors.js";
33
32
  import { Cursor, pageOf, startOf } from "./paging.js";
34
- import { afterTaken, enteredUnder, nestedConfig, takePersonInputs } from "./person-inputs.js";
33
+ import { afterTaken, takePersonInputs } from "./person-inputs.js";
35
34
  import { localized, named, orElse } from "./summary.js";
36
35
  const InstallId = PluginInstallPathParams.shape.installId.max(100);
37
36
  /** An org-owned plugin's catalog item id (`:id` of the owned-plugins routes). */
@@ -58,7 +57,6 @@ const InstallInput = z
58
57
  .object({
59
58
  itemId: ItemId,
60
59
  templates: Templates.optional().describe("Per connector template id (plugins.get lists them), the connector's name, slug, endpoint fields and OAuth client id; never a credential."),
61
- extensionConfig: OrgPluginInstallBody.shape.extensionConfig.describe("The plugin's extension org config without its secret fields (extensions.org-config shows the schema)."),
62
60
  askPerson: personFieldParams.askPerson,
63
61
  })
64
62
  .strict();
@@ -164,9 +162,8 @@ let OrgPluginsOperations = class OrgPluginsOperations {
164
162
  kdb;
165
163
  appearance;
166
164
  themes;
167
- extensions;
168
165
  config;
169
- constructor(registry, installer, orgCatalog, uploads, owned, scope, kdb, appearance, themes, extensions, config) {
166
+ constructor(registry, installer, orgCatalog, uploads, owned, scope, kdb, appearance, themes, config) {
170
167
  this.registry = registry;
171
168
  this.installer = installer;
172
169
  this.orgCatalog = orgCatalog;
@@ -176,46 +173,17 @@ let OrgPluginsOperations = class OrgPluginsOperations {
176
173
  this.kdb = kdb;
177
174
  this.appearance = appearance;
178
175
  this.themes = themes;
179
- this.extensions = extensions;
180
176
  this.config = config;
181
177
  }
182
178
  /**
183
179
  * What installing a plugin asks the person for (platform web parity spec §7.2): the connector
184
180
  * templates whose connector the install creates (on in the org, none kept from an earlier
185
- * switch-off, as the install wizard asks), and the secret fields of its extension's org config
186
- * under `extensionConfig.` (stored ones count as set; one the schema walk cannot address is web
187
- * only). An extension whose org view cannot be read refuses the call: its secrets are unknown.
181
+ * switch-off, as the install wizard asks). The extension's config for the org is its copy of the
182
+ * overridable fields, saved apart (`extensions.save-org-config`).
188
183
  */
189
184
  async installTargets(ctx, itemId) {
190
185
  const d = await this.orgCatalog.detail(ctx.orgId, ctx.actorAccountId, itemId);
191
186
  const templates = d.templates.filter((t) => t.on && !t.connected).map(targetOf);
192
- let fields = [];
193
- let recordOnly = [];
194
- if (d.extension !== null) {
195
- const views = await this.extensions.list(ctx.orgId);
196
- // the view of this catalog item; by plugin name only when that name is unambiguous
197
- const byName = views.filter((e) => e.plugin === d.extension);
198
- const v = views.find((e) => e.catalogItem?.itemId === itemId) ??
199
- (byName.length === 1 ? byName[0] : undefined);
200
- if (v === undefined && byName.length > 1) {
201
- throw new PersonFieldsRefused(`Several extensions named ${d.extension} are in this org, so the secret fields of this plugin's extension are not known; install the plugin on the web (Plugins page).`);
202
- }
203
- if (v === undefined) {
204
- throw new PersonFieldsRefused(`Cannot read the config schema of the plugin's extension ${d.extension} now, so its secret fields are unknown; try again, or install the plugin on the web (Plugins page).`);
205
- }
206
- else {
207
- const stored = new Set(v.secrets.filter((x) => x.set).map((x) => x.path));
208
- const found = secretFieldsOf(v.orgConfigSchema, stored);
209
- const asked = new Set(found.fields.map((f) => f.path));
210
- fields = found.fields.map((f) => ({ ...f, path: `extensionConfig.${f.path}` }));
211
- recordOnly = [
212
- ...new Set([
213
- ...found.recordOnly,
214
- ...v.secrets.map((x) => x.path).filter((p) => !asked.has(p)),
215
- ]),
216
- ].map((p) => `extensionConfig.${p}`);
217
- }
218
- }
219
187
  return {
220
188
  item: d.item,
221
189
  templates,
@@ -224,8 +192,8 @@ let OrgPluginsOperations = class OrgPluginsOperations {
224
192
  zh: `插件「${localized(d.item.displayName, d.item.name).zh}」的安装`,
225
193
  en: `${localized(d.item.displayName, d.item.name).en}: install`,
226
194
  },
227
- fields: [...templatePersonFields(templates), ...fields],
228
- recordOnly,
195
+ fields: templatePersonFields(templates),
196
+ recordOnly: [],
229
197
  },
230
198
  };
231
199
  }
@@ -612,7 +580,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
612
580
  }),
613
581
  defineOperation({
614
582
  id: "plugins.install",
615
- description: "Install a plugin in this org with its inputs (org admins; the web's install wizard): per connector template the connector's name, slug, endpoint fields and OAuth client id (templates), and the extension's org config without secrets (extensionConfig). Secrets are never params: the person enters them in a secure input request, at connectors.<templateId>.credential.token (or .credential.username / .credential.password, .client.clientSecret) and extensionConfig.<field>. Required ones are asked even when not listed in askPerson. A plugin that needs no input is switched on with plugins.set-enabled instead.",
583
+ description: "Install a plugin in this org with its inputs (org admins; the web's install wizard): per connector template the connector's name, slug, endpoint fields and OAuth client id (templates). Secrets are never params: the person enters them in a secure input request, at connectors.<templateId>.credential.token (or .credential.username / .credential.password, .client.clientSecret). The extension's config for the org is its copy of the overridable fields (extensions.save-org-config). Required ones are asked even when not listed in askPerson. A plugin that needs no input is switched on with plugins.set-enabled instead.",
616
584
  input: InstallInput,
617
585
  example: {
618
586
  itemId: EXAMPLE_ID,
@@ -643,7 +611,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
643
611
  },
644
612
  {
645
613
  code: "validation_failed",
646
- next: "The error's details name the fields (connectors.<templateId>.… or extensionConfig.…); correct the params and call again.",
614
+ next: "The error's details name the fields (connectors.<templateId>.…); correct the params and call again.",
647
615
  },
648
616
  {
649
617
  code: "platform.secret_record_web_only",
@@ -666,18 +634,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
666
634
  }
667
635
  return templatesRefusal(r.templates, i.templates);
668
636
  },
669
- personFields: async (i, ctx) => {
670
- const { target } = await this.installTargets(ctx, i.itemId);
671
- // the extension config is a dynamic record: its secrets are checked like values
672
- const plan = planPersonFields(target, {
673
- values: { extensionConfig: i.extensionConfig ?? {} },
674
- askPerson: [],
675
- clearSecrets: [],
676
- });
677
- if (!plan.ok)
678
- throw new PersonFieldsRefused(plan.message);
679
- return target;
680
- },
637
+ personFields: async (i, ctx) => (await this.installTargets(ctx, i.itemId)).target,
681
638
  summary: async (i, ctx) => {
682
639
  const { item, templates } = await this.installTargets(ctx, i.itemId);
683
640
  const n = localized(item.displayName, item.name);
@@ -693,15 +650,8 @@ let OrgPluginsOperations = class OrgPluginsOperations {
693
650
  // values are taken first (takePersonInputs)
694
651
  const { entered, auditDetail } = await takePersonInputs("plugins.install", ctx);
695
652
  const connectors = connectorInputs(templates, input.templates, entered);
696
- const ext = enteredUnder(entered, "extensionConfig.");
697
- const extensionConfig = input.extensionConfig !== undefined || Object.keys(ext).length > 0
698
- ? nestedConfig(input.extensionConfig ?? {}, ext, [])
699
- : undefined;
700
653
  const r = await this.orgCatalog
701
- .install(ctx.orgId, ctx.actorAccountId, input.itemId, {
702
- ...(connectors !== undefined && { connectors }),
703
- ...(extensionConfig !== undefined && { extensionConfig }),
704
- }, undefined, auditDetail)
654
+ .install(ctx.orgId, ctx.actorAccountId, input.itemId, (connectors !== undefined ? { connectors } : {}), undefined, auditDetail)
705
655
  .catch((e) => {
706
656
  throw afterTaken(e, entered);
707
657
  });
@@ -730,7 +680,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
730
680
  },
731
681
  {
732
682
  code: "validation_failed",
733
- next: "The error's details name the fields (connectors.<templateId>.… or extensionConfig.…); correct the params and call again.",
683
+ next: "The error's details name the fields (connectors.<templateId>.…); correct the params and call again.",
734
684
  },
735
685
  {
736
686
  code: "platform.secret_record_web_only",
@@ -792,7 +742,6 @@ OrgPluginsOperations = __decorate([
792
742
  __param(6, Inject(KernelDb)),
793
743
  __param(7, Inject(AppearanceService)),
794
744
  __param(8, Inject(ThemesService)),
795
- __param(9, Inject(OrgExtensionConfigs)),
796
- __param(10, Inject(KernelConfigService))
745
+ __param(9, Inject(KernelConfigService))
797
746
  ], OrgPluginsOperations);
798
747
  export { OrgPluginsOperations };
@@ -31,6 +31,7 @@ let OutboxOperations = class OutboxOperations {
31
31
  this.kdb = kdb;
32
32
  }
33
33
  /** The dead row's job (queue and name) for a card, or null when no dead row has the id. */
34
+ // org-filter: super-admin operations (authz superAdmin); dead outbox rows of every org are listed
34
35
  async jobOf(id) {
35
36
  const row = await this.kdb.db
36
37
  .selectFrom("outbox")
@@ -33,10 +33,6 @@ export declare const VALUES_USED_UP_TEXT = "The values the person entered were u
33
33
  * `ToolError` naming only its class (as the pipeline would), with the original as `cause`.
34
34
  */
35
35
  export declare function afterTaken(e: unknown, entered: Readonly<Record<string, string>>): unknown;
36
- /**
37
- * The values under `prefix` (`connectors.<templateId>.`), keyed by the rest of their path.
38
- */
39
- export declare function enteredUnder(entered: Readonly<Record<string, string>>, prefix: string): Record<string, string>;
40
36
  /**
41
37
  * The `values` of a config route keyed by field dot path (deployment config, the org's copy): the
42
38
  * model's non-secret values, the person's entered secrets, and `null` (clear) for each path in
@@ -56,14 +56,6 @@ export function afterTaken(e, entered) {
56
56
  Object.defineProperty(out, "cause", { value: e });
57
57
  return out;
58
58
  }
59
- /**
60
- * The values under `prefix` (`connectors.<templateId>.`), keyed by the rest of their path.
61
- */
62
- export function enteredUnder(entered, prefix) {
63
- return Object.fromEntries(Object.entries(entered)
64
- .filter(([p]) => p.startsWith(prefix))
65
- .map(([p, v]) => [p.slice(prefix.length), v]));
66
- }
67
59
  /**
68
60
  * The `values` of a config route keyed by field dot path (deployment config, the org's copy): the
69
61
  * model's non-secret values, the person's entered secrets, and `null` (clear) for each path in
@@ -9,7 +9,10 @@ import { KernelDb } from "../../infra/database/kernel-db.js";
9
9
  import { PlatformOperations } from "../registry.js";
10
10
  export { OTHER_ORG } from "./other-orgs.js";
11
11
  export declare const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials in a secure input request.";
12
- /** `plugin.needs_input` when what is missing is its extension's org config (an agent can set it). */
12
+ /**
13
+ * What `plugins.set-enabled` adds to its result when the plugin is on but its extension's
14
+ * effective config for the org is not valid yet (switching on never waits for it, as on the web).
15
+ */
13
16
  export declare const needsOrgConfig: (extension: string) => string;
14
17
  /**
15
18
  * Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
@@ -41,8 +41,11 @@ const LOCKED = "This plugin is on for every org (or shipped with the platform) a
41
41
  /** The confirm value of switching off a plugin with nothing installed in the org. */
42
42
  const NOTHING_INSTALLED = "nothing-installed";
43
43
  export const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials in a secure input request.";
44
- /** `plugin.needs_input` when what is missing is its extension's org config (an agent can set it). */
45
- export const needsOrgConfig = (extension) => `This plugin's extension ${extension} needs its org config first: read what is missing with extensions.org-config, fill it in with extensions.set-org-config (the person enters secrets in a secure input request; the org's own copy of overridable platform fields is extensions.save-org-config), then call plugins.set-enabled again.`;
44
+ /**
45
+ * What `plugins.set-enabled` adds to its result when the plugin is on but its extension's
46
+ * effective config for the org is not valid yet (switching on never waits for it, as on the web).
47
+ */
48
+ export const needsOrgConfig = (extension) => `The plugin is on, but its extension ${extension} has no valid config for this org yet and gets no calls until it does: read what is missing with extensions.org-config, then fill in the org's own copy of the overridable fields with extensions.save-org-config (the person enters secrets in a secure input request). If only platform-only fields are missing, the super admin must set them.`;
46
49
  /** The English name of a plugin as next steps and messages name it. */
47
50
  const enName = (i) => localized(i.displayName, i.name).en;
48
51
  /** The item with the reason its extension stopped loading (state unchanged), when it has one. */
@@ -81,35 +84,23 @@ const row = (i, role) => ({
81
84
  switchable: i.switchable,
82
85
  request: i.request,
83
86
  });
84
- const hasConfigFields = (schema) => {
85
- const props = schema?.properties;
86
- return typeof props === "object" && props !== null && Object.keys(props).length > 0;
87
- };
88
87
  /**
89
- * Why switching the plugin on needs input first, as the `plugin.needs_input` message, or null: its
90
- * extension's org config misses required values (an agent fills it in with
91
- * `extensions.set-org-config`), or connector templates without their connector, or anything else
92
- * the item's `needs_config` stands for (connector input: `plugins.install`, `plugins.configure-connectors`). Unlike the web's
93
- * install wizard, an org config form whose required values are all stored does not stop the switch.
88
+ * Why switching the plugin on needs input first, as the `plugin.needs_input` message, or null:
89
+ * connector input only (an installed plugin whose connector template misses its connector, or a
90
+ * plugin not installed yet that has connector templates: `plugins.install`,
91
+ * `plugins.configure-connectors`). Its extension's config never blocks the switch, as on the web
92
+ * and the route: the plugin goes on and its extension stays `needsConfig` until the org's copy
93
+ * (or the platform config) is valid ({@link configStillNeeded}).
94
94
  */
95
- function needsInput(item, extensions) {
96
- const own = extensions.find((e) => e.catalogItem?.itemId === item.id);
97
- // `needs_config` also means connector templates without their connector
98
- if (item.state === "needs_config") {
99
- return own?.needsConfig === true ? needsOrgConfig(own.plugin) : NEEDS_INPUT;
100
- }
95
+ function needsInput(item) {
101
96
  if (item.installed !== null)
102
- return null;
103
- if (item.componentCounts.connectorTemplates > 0)
104
- return NEEDS_INPUT;
105
- if (item.componentCounts.extension === 0)
106
- return null;
107
- return own !== undefined &&
108
- !own.enabled &&
109
- hasConfigFields(own.orgConfigSchema) &&
110
- own.needsConfig
111
- ? needsOrgConfig(own.plugin)
112
- : null;
97
+ return item.state === "needs_config" ? NEEDS_INPUT : null;
98
+ return item.componentCounts.connectorTemplates > 0 ? NEEDS_INPUT : null;
99
+ }
100
+ /** The note for a plugin switched on whose extension's effective config is not valid, or null. */
101
+ function configStillNeeded(item, extensions) {
102
+ const own = extensions.find((e) => e.catalogItem?.itemId === item.id);
103
+ return own?.needsConfig === true ? needsOrgConfig(own.plugin) : null;
113
104
  }
114
105
  /**
115
106
  * Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
@@ -222,7 +213,7 @@ let PluginsOperations = class PluginsOperations {
222
213
  }),
223
214
  defineOperation({
224
215
  id: "plugins.set-enabled",
225
- description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs connector input is refused: install it with plugins.install instead. Switching off removes what the plugin brought and needs confirm: the value plugins.disable-preview returned with the preview the person saw.",
216
+ description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs connector input is refused: install it with plugins.install instead. A plugin whose extension has no valid config for the org yet is switched on anyway, and the result's configNeeded says how to fill in the org's copy (extensions.save-org-config). Switching off removes what the plugin brought and needs confirm: the value plugins.disable-preview returned with the preview the person saw.",
226
217
  input: z.discriminatedUnion("enabled", [
227
218
  z.object({ itemId: ItemId, enabled: z.literal(true) }).strict(),
228
219
  z.object({ itemId: ItemId, enabled: z.literal(false), confirm: Confirm }).strict(),
@@ -262,7 +253,7 @@ let PluginsOperations = class PluginsOperations {
262
253
  },
263
254
  {
264
255
  code: "plugin.needs_input",
265
- next: "When its extension's org config is missing, fill it in with extensions.set-org-config (secrets in askPerson), then call again; a plugin that needs connector input is installed with plugins.install (or plugins.configure-connectors once installed), the person entering the credentials on the card.",
256
+ next: "The plugin needs connector input: install it with plugins.install (or plugins.configure-connectors once installed), the person entering the credentials on the card.",
266
257
  },
267
258
  {
268
259
  code: "catalog.approval_required",
@@ -303,9 +294,7 @@ let PluginsOperations = class PluginsOperations {
303
294
  next: unavailableNext(item.reason, name),
304
295
  };
305
296
  }
306
- const missing = i.enabled
307
- ? needsInput(item, await this.extensions.list(ctx.orgId))
308
- : null;
297
+ const missing = i.enabled ? needsInput(item) : null;
309
298
  if (missing !== null)
310
299
  return { ok: false, code: "plugin.needs_input", message: missing };
311
300
  return { ok: true };
@@ -335,14 +324,18 @@ let PluginsOperations = class PluginsOperations {
335
324
  run: async (input, ctx) => {
336
325
  if (input.enabled) {
337
326
  const [item] = await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, input.itemId);
338
- const missing = item ? needsInput(item, await this.extensions.list(ctx.orgId)) : null;
327
+ const missing = item ? needsInput(item) : null;
339
328
  if (missing !== null)
340
329
  throw new ToolError(missing);
341
330
  }
342
331
  const r = await this.orgCatalog.setSwitch(ctx.orgId, ctx.actorAccountId, input.itemId, input.enabled ? { enabled: true } : { enabled: false, confirm: input.confirm }, undefined, viaAgent("plugins.set-enabled", ctx));
343
332
  if (r.kind === "done") {
333
+ const configNeeded = input.enabled
334
+ ? configStillNeeded(r.item, await this.extensions.list(ctx.orgId))
335
+ : null;
344
336
  return {
345
337
  item: brief(r.item, await roleFor(this.kdb.db, ctx)),
338
+ ...(configNeeded !== null && { configNeeded }),
346
339
  };
347
340
  }
348
341
  // unreachable: confirm is required when switching off
@@ -76,7 +76,7 @@ export declare function secretFieldsOf(jsonSchema: unknown, stored: ReadonlySet<
76
76
  /**
77
77
  * A refusal of a call's person fields (model-visible English, never a value): thrown by the plan,
78
78
  * or by an operation's `personFields` for an input the plan cannot see (a dynamic record such as
79
- * the install's `extensionConfig`). The tool denies the call with the message before the card.
79
+ * a channel connection config). The tool denies the call with the message before the card.
80
80
  */
81
81
  export declare class PersonFieldsRefused extends Error {
82
82
  }
@@ -246,7 +246,7 @@ export function secretFieldsOf(jsonSchema, stored) {
246
246
  /**
247
247
  * A refusal of a call's person fields (model-visible English, never a value): thrown by the plan,
248
248
  * or by an operation's `personFields` for an input the plan cannot see (a dynamic record such as
249
- * the install's `extensionConfig`). The tool denies the call with the message before the card.
249
+ * a channel connection config). The tool denies the call with the message before the card.
250
250
  */
251
251
  export class PersonFieldsRefused extends Error {
252
252
  }
@@ -99,6 +99,7 @@ let SealedReveals = class SealedReveals {
99
99
  .selectFrom("invitations")
100
100
  .select("invitations.id")
101
101
  .whereRef("invitations.id", "=", "platform_sealed_reveals.id")
102
+ .where("invitations.org_id", "=", orgId)
102
103
  .where("invitations.accepted_at", "is", null)
103
104
  .where("invitations.revoked_at", "is", null)
104
105
  .where(sql `invitations.expires_at > now()`)))
@@ -142,6 +143,7 @@ SealedReveals = __decorate([
142
143
  export { SealedReveals };
143
144
  /** Deletes the sealed reveals past `expires_at`; returns how many. */
144
145
  export async function deleteExpiredSealedReveals(db) {
146
+ // org-filter: deployment-wide expiry sweep over every org's sealed reveals (maintenance job)
145
147
  const r = await db
146
148
  .deleteFrom("platform_sealed_reveals")
147
149
  .where("expires_at", "<=", sql `now()`)