@capybara-hq/kernel 0.1.0-rc.76 → 0.1.0-rc.78

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 (230) 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 +6 -0
  21. package/dist/catalog/catalog-content.js +1 -0
  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.js +2 -0
  29. package/dist/catalog/marketplaces.service.d.ts +6 -1
  30. package/dist/catalog/marketplaces.service.js +8 -3
  31. package/dist/catalog/org-catalog.controller.d.ts +9 -0
  32. package/dist/catalog/org-catalog.controller.js +18 -0
  33. package/dist/catalog/org-catalog.schemas.d.ts +2 -4
  34. package/dist/catalog/org-catalog.schemas.js +2 -3
  35. package/dist/catalog/org-catalog.service.d.ts +10 -1
  36. package/dist/catalog/org-catalog.service.js +34 -23
  37. package/dist/catalog/org-extension-switch.d.ts +3 -10
  38. package/dist/catalog/org-extension-switch.js +14 -60
  39. package/dist/catalog/org-extension.controller.d.ts +6 -7
  40. package/dist/catalog/org-extension.controller.js +4 -4
  41. package/dist/catalog/org-extension.schemas.d.ts +1 -2
  42. package/dist/catalog/org-extension.schemas.js +1 -3
  43. package/dist/catalog/owned-items.js +10 -1
  44. package/dist/catalog/ownership.js +2 -0
  45. package/dist/catalog/plugin-import.js +8 -0
  46. package/dist/catalog/plugin-install.d.ts +1 -4
  47. package/dist/catalog/plugin-install.js +11 -12
  48. package/dist/catalog/plugin-upgrade.js +4 -1
  49. package/dist/catalog/request-rules.js +6 -0
  50. package/dist/catalog/requests.service.js +4 -0
  51. package/dist/catalog/scope-orgs.js +1 -0
  52. package/dist/catalog/scope-sync.d.ts +8 -5
  53. package/dist/catalog/scope-sync.js +21 -23
  54. package/dist/catalog/unshare.js +3 -0
  55. package/dist/channels/connections.service.js +1 -0
  56. package/dist/channels/inbound.js +1 -0
  57. package/dist/channels/jobs.js +1 -0
  58. package/dist/channels/outbound.js +6 -0
  59. package/dist/channels/supervisor.js +1 -0
  60. package/dist/channels/threads.js +1 -0
  61. package/dist/client/client-reports.service.js +1 -0
  62. package/dist/config/fields.js +20 -4
  63. package/dist/conversations/access.js +1 -0
  64. package/dist/conversations/attachments.service.js +16 -4
  65. package/dist/conversations/conversations.service.js +17 -3
  66. package/dist/conversations/event-log.js +2 -0
  67. package/dist/conversations/events.d.ts +1 -0
  68. package/dist/conversations/events.js +3 -1
  69. package/dist/conversations/files.js +3 -2
  70. package/dist/conversations/permission-profiles.service.js +1 -0
  71. package/dist/conversations/prompt-suggestions.js +2 -0
  72. package/dist/conversations/queue.js +8 -0
  73. package/dist/conversations/queue.service.js +6 -2
  74. package/dist/conversations/source.js +2 -0
  75. package/dist/conversations/titles.js +10 -2
  76. package/dist/conversations/tree.js +6 -0
  77. package/dist/db/kernel-schema.d.ts +3 -1
  78. package/dist/devices/conversation-devices.js +3 -0
  79. package/dist/devices/device-projects.service.js +2 -0
  80. package/dist/devices/devices.service.js +5 -0
  81. package/dist/devices/legacy-cleanup.job.js +5 -2
  82. package/dist/dial-in/handlers.js +2 -0
  83. package/dist/dial-in/machines.js +11 -2
  84. package/dist/dial-in/targets.d.ts +0 -2
  85. package/dist/dial-in/targets.js +0 -10
  86. package/dist/errors.d.ts +0 -1
  87. package/dist/errors.js +0 -1
  88. package/dist/evals/budget.js +14 -1
  89. package/dist/evals/run-replay.js +4 -0
  90. package/dist/evals/runs.service.js +13 -7
  91. package/dist/evals/sets.service.js +23 -8
  92. package/dist/evals/trajectory.service.d.ts +1 -1
  93. package/dist/evals/trajectory.service.js +1 -0
  94. package/dist/evals/worker.js +5 -1
  95. package/dist/extensions/admin-ops.js +1 -0
  96. package/dist/extensions/admin-view.js +3 -1
  97. package/dist/extensions/bootstrap-packages.d.ts +12 -1
  98. package/dist/extensions/bootstrap-packages.js +49 -9
  99. package/dist/extensions/bootstrap.d.ts +36 -4
  100. package/dist/extensions/bootstrap.js +103 -16
  101. package/dist/extensions/config-json-schema.d.ts +2 -2
  102. package/dist/extensions/config-json-schema.js +1 -3
  103. package/dist/extensions/deployment-config.d.ts +5 -3
  104. package/dist/extensions/deployment-config.js +3 -3
  105. package/dist/extensions/effective-config.d.ts +8 -7
  106. package/dist/extensions/effective-config.js +8 -7
  107. package/dist/extensions/enabled.js +1 -0
  108. package/dist/extensions/host.d.ts +4 -3
  109. package/dist/extensions/host.js +11 -12
  110. package/dist/extensions/instance.d.ts +1 -1
  111. package/dist/extensions/instance.js +17 -2
  112. package/dist/extensions/org-config.d.ts +35 -97
  113. package/dist/extensions/org-config.js +48 -315
  114. package/dist/extensions/org-levels.d.ts +22 -9
  115. package/dist/extensions/org-levels.js +100 -20
  116. package/dist/extensions/org-overrides.d.ts +14 -15
  117. package/dist/extensions/org-overrides.js +20 -20
  118. package/dist/extensions/package.js +1 -1
  119. package/dist/extensions/permission-set.d.ts +1 -3
  120. package/dist/extensions/permission-set.js +3 -7
  121. package/dist/extensions/permission-view.d.ts +3 -1
  122. package/dist/extensions/permission-view.js +5 -4
  123. package/dist/extensions/plugin-icons.d.ts +72 -1
  124. package/dist/extensions/plugin-icons.js +194 -2
  125. package/dist/extensions/point-defaults.d.ts +17 -18
  126. package/dist/extensions/point-defaults.js +25 -28
  127. package/dist/identity/accounts.js +6 -0
  128. package/dist/identity/api-tokens.js +8 -0
  129. package/dist/infra/outbox/outbox.dispatcher.js +4 -1
  130. package/dist/infra/outbox/outbox.service.js +2 -0
  131. package/dist/orgs/directory-sync.d.ts +9 -6
  132. package/dist/orgs/directory-sync.js +15 -12
  133. package/dist/orgs/invitations.service.js +2 -0
  134. package/dist/orgs/members.service.js +2 -0
  135. package/dist/orgs/offboarding.js +2 -0
  136. package/dist/packages/npm.d.ts +9 -1
  137. package/dist/packages/npm.js +37 -5
  138. package/dist/platform/exclusions.js +20 -0
  139. package/dist/platform/ops/admin-items.ops.js +1 -0
  140. package/dist/platform/ops/agents.ops.js +1 -0
  141. package/dist/platform/ops/extensions.ops.d.ts +6 -8
  142. package/dist/platform/ops/extensions.ops.js +18 -97
  143. package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
  144. package/dist/platform/ops/org-plugins.ops.js +14 -65
  145. package/dist/platform/ops/outbox.ops.js +1 -0
  146. package/dist/platform/ops/person-inputs.d.ts +0 -4
  147. package/dist/platform/ops/person-inputs.js +0 -8
  148. package/dist/platform/ops/plugins.ops.d.ts +4 -1
  149. package/dist/platform/ops/plugins.ops.js +27 -34
  150. package/dist/platform/person-fields.d.ts +1 -1
  151. package/dist/platform/person-fields.js +1 -1
  152. package/dist/platform/sealed-reveals.js +2 -0
  153. package/dist/push/recipients.js +9 -2
  154. package/dist/runtime/permission-context.service.js +1 -0
  155. package/dist/runtime/plugin-context.service.js +1 -0
  156. package/dist/runtime/project/knowledge.service.js +1 -0
  157. package/dist/runtime/run-context.service.js +1 -0
  158. package/dist/runtime/run-deletion.js +4 -0
  159. package/dist/runtime/run-execution.js +2 -0
  160. package/dist/runtime/run-finish.js +3 -0
  161. package/dist/runtime/run-jobs.js +3 -0
  162. package/dist/runtime/run-orphan-check.job.js +7 -0
  163. package/dist/runtime/run-queue.js +21 -2
  164. package/dist/runtime/run-worker.js +5 -0
  165. package/dist/runtime/step-log.js +1 -0
  166. package/dist/runtime/subagents/child.js +2 -0
  167. package/dist/runtime/subagents/deliveries.js +3 -0
  168. package/dist/runtime/subagents/dispatch.js +5 -1
  169. package/dist/runtime/subagents/messages.js +2 -0
  170. package/dist/runtime/subagents/org-agents.d.ts +1 -1
  171. package/dist/runtime/subagents/org-agents.js +2 -1
  172. package/dist/runtime/usage-report-jobs.js +1 -0
  173. package/dist/runtime/usage-report.js +3 -0
  174. package/dist/runtime/waits.js +5 -0
  175. package/dist/sandbox/cloud-permission-snapshot.js +9 -3
  176. package/dist/sandbox/device-reports.js +3 -0
  177. package/dist/sandbox/legacy-retirement.js +5 -1
  178. package/dist/sandbox/managed-device-context.js +1 -0
  179. package/dist/sandbox/modes.d.ts +5 -2
  180. package/dist/sandbox/modes.js +8 -4
  181. package/dist/sandbox/network-grants.js +2 -0
  182. package/dist/sandbox/operation-intents.js +58 -0
  183. package/dist/sandbox/operation-reconcile.job.js +2 -0
  184. package/dist/sandbox/permission-authority-lock.js +12 -6
  185. package/dist/sandbox/permission-call-grants.js +6 -0
  186. package/dist/sandbox/permission-ceiling-writes.js +5 -0
  187. package/dist/sandbox/permission-config-publication.js +5 -0
  188. package/dist/sandbox/permission-instance-writes.js +4 -0
  189. package/dist/sandbox/permission-runtime-reports.js +10 -1
  190. package/dist/sandbox/permission-transitions.js +3 -0
  191. package/dist/sandbox/review/review.service.js +8 -5
  192. package/dist/sandbox/sandbox.service.d.ts +14 -0
  193. package/dist/sandbox/sandbox.service.js +195 -29
  194. package/dist/sandbox/unreachable.js +4 -1
  195. package/dist/schedules/fire.js +9 -3
  196. package/dist/schedules/pause.js +2 -0
  197. package/dist/schedules/run-tracker.js +16 -1
  198. package/dist/schedules/scheduled-tasks.service.js +4 -2
  199. package/dist/schedules/store.js +8 -0
  200. package/dist/schedules/unattended.js +4 -0
  201. package/dist/setup/setup-checks.service.d.ts +1 -10
  202. package/dist/setup/setup-checks.service.js +19 -29
  203. package/dist/shares/share-open.service.js +1 -0
  204. package/dist/shares/shares.service.js +2 -0
  205. package/dist/skills/agent-skills.service.d.ts +1 -1
  206. package/dist/skills/agent-skills.service.js +13 -2
  207. package/dist/skills/catalog.js +3 -0
  208. package/dist/skills/changes.service.js +10 -2
  209. package/dist/skills/conversation-catalog.js +1 -0
  210. package/dist/skills/skills.service.js +4 -0
  211. package/dist/tools/approvals.service.js +40 -0
  212. package/dist/tools/builtins/schedules.js +11 -6
  213. package/dist/tools/builtins/skill-load.d.ts +10 -9
  214. package/dist/tools/builtins/skill-load.js +15 -19
  215. package/dist/tools/builtins/web/fetch.js +1 -1
  216. package/dist/tools/builtins/web/search.js +1 -1
  217. package/dist/tools/connector-account-policies.js +3 -0
  218. package/dist/tools/connectors.controller.d.ts +20 -8
  219. package/dist/tools/connectors.controller.js +30 -12
  220. package/dist/tools/connectors.service.d.ts +8 -0
  221. package/dist/tools/connectors.service.js +21 -1
  222. package/dist/tools/drift.js +5 -0
  223. package/dist/tools/git-push-policy.js +3 -0
  224. package/dist/tools/oauth/flow.js +1 -0
  225. package/dist/tools/outputs.js +2 -0
  226. package/dist/tools/permission-approval-jobs.js +3 -0
  227. package/dist/tools/pipeline.js +2 -0
  228. package/dist/tools/policy.js +3 -0
  229. package/dist/tools/questions.service.js +13 -0
  230. package/package.json +3 -3
@@ -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()`)
@@ -41,6 +41,8 @@ async function resolveConversation(db, conversationId, seq) {
41
41
  const trigger = pushTriggerOf({ type: event.type, payload: event.payload });
42
42
  if (trigger === null)
43
43
  return null;
44
+ // org-filter: conversationId comes from the kernel-written push fan-out job; this read learns
45
+ // the conversation's org, which every later read filters by
44
46
  const conv = await db
45
47
  .selectFrom("conversations")
46
48
  .select(["org_id", "kind", "account_id", "deleted_at"])
@@ -60,6 +62,7 @@ async function resolveConversation(db, conversationId, seq) {
60
62
  .selectFrom("conversations")
61
63
  .select(["org_id", "kind", "account_id", "deleted_at"])
62
64
  .where("id", "=", rootId)
65
+ .where("org_id", "=", orgId)
63
66
  .executeTakeFirst();
64
67
  if (root !== null &&
65
68
  (root === undefined ||
@@ -148,6 +151,7 @@ async function resolveConversation(db, conversationId, seq) {
148
151
  .selectFrom("conversations")
149
152
  .select(["agent_id", "title"])
150
153
  .where("id", "=", rootId)
154
+ .where("org_id", "=", orgId)
151
155
  .executeTakeFirstOrThrow();
152
156
  const org = encodeURIComponent(orgId);
153
157
  const path = rootId === conversationId
@@ -159,12 +163,14 @@ async function resolveConversation(db, conversationId, seq) {
159
163
  category: trigger.category,
160
164
  path,
161
165
  threadId: rootId,
162
- title: await agentName(db, rootRow.agent_id),
166
+ title: await agentName(db, orgId, rootRow.agent_id),
163
167
  conversationTitle: rootRow.title,
164
168
  text: trigger.text,
165
169
  };
166
170
  }
167
171
  async function resolveSchedule(db, taskRunId) {
172
+ // org-filter: taskRunId comes from the kernel-written push fan-out job; this read learns the
173
+ // run's org (checked against its task's below), which every later read filters by
168
174
  const row = await db
169
175
  .selectFrom("scheduled_task_runs")
170
176
  .innerJoin("scheduled_tasks", "scheduled_tasks.id", "scheduled_task_runs.task_id")
@@ -249,7 +255,7 @@ async function activeMembers(db, orgId, ids) {
249
255
  return rows.map((r) => r.id);
250
256
  }
251
257
  /** The agent's name in its current version (empty when it has none). */
252
- async function agentName(db, agentId) {
258
+ async function agentName(db, orgId, agentId) {
253
259
  const row = await db
254
260
  .selectFrom("agents")
255
261
  .innerJoin("agent_versions", (j) => j
@@ -257,6 +263,7 @@ async function agentName(db, agentId) {
257
263
  .onRef("agent_versions.version", "=", "agents.current_version"))
258
264
  .select("agent_versions.definition")
259
265
  .where("agents.id", "=", agentId)
266
+ .where("agents.org_id", "=", orgId)
260
267
  .executeTakeFirst();
261
268
  const name = row?.definition?.name;
262
269
  return typeof name === "string" ? name : "";
@@ -137,6 +137,7 @@ let PermissionContextRecorder = class PermissionContextRecorder {
137
137
  .selectFrom("conversations")
138
138
  .select(["org_id", "kind", "eval_run_id"])
139
139
  .where("id", "=", input.conversationId)
140
+ .where("org_id", "=", input.orgId)
140
141
  .executeTakeFirst();
141
142
  if (!conv || conv.org_id !== input.orgId)
142
143
  throw new ApiError("conversation.not_found", "Conversation not found");
@@ -160,6 +160,7 @@ let PluginContextService = class PluginContextService {
160
160
  .selectFrom("conversations")
161
161
  .select("id")
162
162
  .where("id", "=", input.conversationId)
163
+ .where("org_id", "=", input.orgId)
163
164
  .forUpdate()
164
165
  .executeTakeFirst();
165
166
  if (await runEndedIn(t, input.runId))
@@ -297,6 +297,7 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
297
297
  .selectFrom("conversations")
298
298
  .select("id")
299
299
  .where("id", "=", input.conversationId)
300
+ .where("org_id", "=", input.orgId)
300
301
  .forUpdate()
301
302
  .executeTakeFirst();
302
303
  if (await runEndedIn(t, input.runId))
@@ -79,6 +79,7 @@ let RunContextService = class RunContextService {
79
79
  .selectFrom("conversations")
80
80
  .select("id")
81
81
  .where("id", "=", input.conversationId)
82
+ .where("org_id", "=", input.orgId)
82
83
  .forUpdate()
83
84
  .executeTakeFirst();
84
85
  if (await runEndedIn(t, input.runId))
@@ -76,12 +76,15 @@ let RunDeletion = class RunDeletion {
76
76
  .selectFrom("background_tasks as b")
77
77
  .select("b.id")
78
78
  .whereRef("b.sandbox_conversation_id", "=", "c.id")
79
+ .whereRef("b.org_id", "=", "c.org_id")
79
80
  .where("b.status", "=", RUNNING_TASK_STATUS)),
80
81
  ]))
81
82
  .orderBy("c.id")
82
83
  .limit(100)
83
84
  .execute();
84
85
  }
86
+ // org-filter: the id is the deleted root (ConversationsService.remove checked writable(orgId)
87
+ // first, or the outbox row it wrote); only a deleted conversation is acted on
85
88
  async stopTree(conversationId, byAccountId) {
86
89
  const root = await this.db
87
90
  .selectFrom("conversations")
@@ -107,6 +110,7 @@ let RunDeletion = class RunDeletion {
107
110
  await this.stopConversationIn(conversationId, byAccountId);
108
111
  await this.background.stopForDeletedConversation(conversationId);
109
112
  }
113
+ // org-filter: locks a conversation stopTree / stopDeletedConversation / the org sweep resolved
110
114
  async stopConversationIn(conversationId, byAccountId, reason = "user") {
111
115
  await this.db
112
116
  .selectFrom("conversations")
@@ -90,6 +90,7 @@ let RunExecution = class RunExecution {
90
90
  async claim(conversationId, runId, executionId, live = () => true) {
91
91
  if (!live())
92
92
  return null;
93
+ // org-filter: the worker's claim of a kernel-written run job; reads the conversation's own org
93
94
  const conv = await this.db
94
95
  .selectFrom("conversations")
95
96
  .select("org_id")
@@ -156,6 +157,7 @@ let RunExecution = class RunExecution {
156
157
  .selectFrom("conversations")
157
158
  .select("deleted_at")
158
159
  .where("id", "=", claim.rootId)
160
+ .where("org_id", "=", claim.orgId)
159
161
  .forNoKeyUpdate()
160
162
  .executeTakeFirst();
161
163
  if (!root || !isLive(root.deleted_at))
@@ -84,6 +84,8 @@ let RunFinish = class RunFinish {
84
84
  * approval and input request rows, the run row; they never deadlock with each other.
85
85
  * 调用方在提交后对非 null 的返回值调用 {@link notifyFinished}。
86
86
  */
87
+ // org-filter: ends a run by its kernel-resolved run and conversation ids (worker claim, stop and
88
+ // decision paths that checked the org); the conversation's own org is read here
87
89
  async finishIn(a) {
88
90
  const t = this.kdb.db;
89
91
  const conv = await t
@@ -178,6 +180,7 @@ let RunFinish = class RunFinish {
178
180
  .selectFrom("conversations")
179
181
  .select("id")
180
182
  .where("parent_conversation_id", "=", a.conversationId)
183
+ .where("org_id", "=", orgId)
181
184
  .where("kind", "=", "subagent")
182
185
  .limit(1)
183
186
  .executeTakeFirst()) !== undefined;
@@ -38,6 +38,8 @@ export { TERMINAL_STATUSES } from "./run-status.js";
38
38
  * that writes them (conversation, decided rows, run; ruling R19), so a stop, a run's end, a decision
39
39
  * and a timeout never deadlock. Returns whether any of them is still pending.
40
40
  */
41
+ // org-filter: locks the wait rows of a run the caller already holds (its conversation row is
42
+ // locked first); run ids are kernel-resolved, never request input
41
43
  export async function lockWaitRowsIn(t, runId) {
42
44
  const approvals = await t
43
45
  .selectFrom("approvals")
@@ -253,6 +255,7 @@ let RunResume = class RunResume {
253
255
  .executeTakeFirst();
254
256
  if (!row)
255
257
  return "other-wait-pending";
258
+ // org-filter: the conversation of the run row just resumed above; reads its own org
256
259
  const conv = await t
257
260
  .selectFrom("conversations")
258
261
  .select(["kind", "org_id"])
@@ -92,6 +92,8 @@ export async function orphanCandidates(db, statuses, minAgeMs, limit, after) {
92
92
  }
93
93
  /** Whether delivery is still owed by a pending outbox row; dead copies are not active work.
94
94
  */
95
+ // org-filter: outbox rows looked up by queue and deterministic kernel job id (unique across the
96
+ // deployment) in the deployment-wide orphan check; outbox.org_id is nullable
95
97
  export async function jobInOutbox(db, queue, jobId) {
96
98
  const row = await db
97
99
  .selectFrom("outbox")
@@ -266,6 +268,8 @@ let RunOrphanCheck = class RunOrphanCheck {
266
268
  .onConflict((oc) => oc.column("name").doUpdateSet(values))
267
269
  .execute();
268
270
  }
271
+ // org-filter: outbox rows looked up by queue and deterministic kernel job id (unique across the
272
+ // deployment) in the deployment-wide orphan check; outbox.org_id is nullable
269
273
  async hasDeadDelivery(c) {
270
274
  return ((await this.db
271
275
  .selectFrom("outbox")
@@ -321,6 +325,8 @@ let RunOrphanCheck = class RunOrphanCheck {
321
325
  if (deliveryFailed) {
322
326
  // Lock dead rows against admin retry. A pending retry always takes precedence over a
323
327
  // historical dead copy. Producers of replacement jobs also hold this conversation lock.
328
+ // org-filter: outbox rows by queue and deterministic kernel job id (unique across the
329
+ // deployment); outbox.org_id is nullable
324
330
  const deliveries = await this.db
325
331
  .selectFrom("outbox")
326
332
  .select("dead_at")
@@ -370,6 +376,7 @@ let RunOrphanCheck = class RunOrphanCheck {
370
376
  .selectFrom("conversations")
371
377
  .select("id")
372
378
  .where("id", "=", c.conversationId)
379
+ .where("org_id", "=", c.orgId)
373
380
  .forUpdate()
374
381
  .executeTakeFirst();
375
382
  const r = await this.db