@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
@@ -19,6 +19,7 @@ import { ExtensionInstalls } from "./installs.js";
19
19
  import { ExtensionLifecycle } from "./lifecycle.js";
20
20
  import { PLUGIN_DEPLOYMENT_CONFIG_TOPIC } from "./lifecycle-topics.js";
21
21
  import { PluginDeploymentConfigLock } from "./locks.js";
22
+ import { type FieldLevel } from "./org-levels.js";
22
23
  export { DEPLOYMENT_SECRETS_ORG, type DeploymentSchemaInfo, mergeDeploymentConfig, readStoredDeploymentConfig, schemaFields, secretPathsOf, };
23
24
  type Obj = Record<string, unknown>;
24
25
  export type { ConfigIssue };
@@ -43,10 +44,11 @@ export interface DeploymentConfigField {
43
44
  */
44
45
  keys?: string[];
45
46
  /**
46
- * What orgs may do with the field (spec A §5.1, the level of its top-level key): `readonly` (they
47
- * see it) or `override` (they may bring their own value); absent = hidden from orgs.
47
+ * The field's org level (unified config spec §5.1, the level of its top-level key): `override`
48
+ * (orgs follow the platform's value or bring their own) or `platform` (platform-only, orgs never
49
+ * see it).
48
50
  */
49
- org?: "readonly" | "override";
51
+ level: FieldLevel;
50
52
  }
51
53
  /**
52
54
  * One operation on a secret record drawn per item (spec §4.3), only for a path some
@@ -423,14 +423,14 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
423
423
  value = d.value;
424
424
  source = value === undefined ? "unset" : "default";
425
425
  }
426
- const level = levels.get(f.path.split(".")[0]);
427
426
  const base = {
428
427
  path: f.path,
429
428
  secret: f.secret,
430
429
  hot: f.hot,
431
430
  source,
432
431
  readonly: from !== undefined,
433
- ...(level !== undefined && level !== "hidden" && { org: level }),
432
+ // a schema with no top-level keys (not an object) has nothing an org could override
433
+ level: levels.get(f.path.split(".")[0]) ?? "platform",
434
434
  };
435
435
  // a schema default (e.g. `secret(record).default({})`) is no secret anybody set
436
436
  const set = value !== undefined && source !== "default";
@@ -528,7 +528,7 @@ function levelsOf(info) {
528
528
  }
529
529
  /**
530
530
  * The required `override` keys `raw` leaves empty: by the zod schema, else (a static form schema)
531
- * the `required` keys marked `override` that have no value.
531
+ * the `required` keys that are not platform-only and have no value.
532
532
  */
533
533
  function orgMustConfigureOf(info, raw, levels) {
534
534
  if (info.schema)
@@ -18,8 +18,9 @@ export declare const NEEDS_CONFIG_REASON = "needs configuration in this organiza
18
18
  /** The kernel's own secrets namespace (`kernel` is a reserved plugin name). */
19
19
  export declare const OVERRIDE_SECRETS_NAMESPACE = "kernel";
20
20
  /**
21
- * Where a copy's secret field lives in `capybara.secrets` (under the org): a namespace of its own,
22
- * distinct from the org-only `plugin-config:<plugin>:<path>` (spec A §5.8).
21
+ * Where a copy's secret field lives in `capybara.secrets` (under the org): a key prefix of its
22
+ * own, distinct from the retired org config secrets `plugin-config:<plugin>:<path>` (spec A §5.8;
23
+ * no longer read, purged by a later contract migration).
23
24
  */
24
25
  export declare const overrideSecretKey: (plugin: string, path: string) => string;
25
26
  /**
@@ -53,11 +54,11 @@ export declare function overrideSecretPaths(schema: z.ZodTypeAny, levels?: Map<s
53
54
  export declare function platformOverrideValues(schema: z.ZodTypeAny, platform: unknown): Obj;
54
55
  /**
55
56
  * The deployment config an org with a copy runs with, before validation (spec A §5.4): the
56
- * platform's values of the hidden and read-only keys, and for each `override` key the copy's value
57
- * (its non-secret part and its own secrets). An `override` key the copy does not hold (one that
58
- * became overridable after the copy was made) takes the platform's value with every secret leaf
59
- * removed: a copy never falls back to a platform secret, required or not. Copy values of keys that
60
- * are no longer `override` are ignored.
57
+ * platform's values of the platform-only keys (their secrets included: an org cannot set them),
58
+ * and for each `override` key the copy's value (its non-secret part and its own secrets). An
59
+ * `override` key the copy does not hold (one that became overridable after the copy was made)
60
+ * takes the platform's value with every secret leaf removed: a copy never falls back to a platform
61
+ * secret, required or not. Copy values of keys that are no longer `override` are ignored.
61
62
  */
62
63
  export declare function mergeCopy(schema: z.ZodTypeAny, platform: unknown, copy: StoredCopy): Obj;
63
64
  /**
@@ -33,8 +33,9 @@ export const NEEDS_CONFIG_REASON = "needs configuration in this organization";
33
33
  export const OVERRIDE_SECRETS_NAMESPACE = "kernel";
34
34
  const OVERRIDE_KEY_PREFIX = "plugin-override:";
35
35
  /**
36
- * Where a copy's secret field lives in `capybara.secrets` (under the org): a namespace of its own,
37
- * distinct from the org-only `plugin-config:<plugin>:<path>` (spec A §5.8).
36
+ * Where a copy's secret field lives in `capybara.secrets` (under the org): a key prefix of its
37
+ * own, distinct from the retired org config secrets `plugin-config:<plugin>:<path>` (spec A §5.8;
38
+ * no longer read, purged by a later contract migration).
38
39
  */
39
40
  export const overrideSecretKey = (plugin, path) => `${OVERRIDE_KEY_PREFIX}${plugin}:${path}`;
40
41
  const notRunning = () => ({
@@ -79,11 +80,11 @@ export function platformOverrideValues(schema, platform) {
79
80
  }
80
81
  /**
81
82
  * The deployment config an org with a copy runs with, before validation (spec A §5.4): the
82
- * platform's values of the hidden and read-only keys, and for each `override` key the copy's value
83
- * (its non-secret part and its own secrets). An `override` key the copy does not hold (one that
84
- * became overridable after the copy was made) takes the platform's value with every secret leaf
85
- * removed: a copy never falls back to a platform secret, required or not. Copy values of keys that
86
- * are no longer `override` are ignored.
83
+ * platform's values of the platform-only keys (their secrets included: an org cannot set them),
84
+ * and for each `override` key the copy's value (its non-secret part and its own secrets). An
85
+ * `override` key the copy does not hold (one that became overridable after the copy was made)
86
+ * takes the platform's value with every secret leaf removed: a copy never falls back to a platform
87
+ * secret, required or not. Copy values of keys that are no longer `override` are ignored.
87
88
  */
88
89
  export function mergeCopy(schema, platform, copy) {
89
90
  const levels = fieldLevels(schema);
@@ -54,6 +54,7 @@ export function enabledExtensionsQuery(db, orgId) {
54
54
  * `plugin`): `.innerJoin(enabledExtensionsByOrg(db).as("en"), (j) => j.onRef("en.org_id", …)…)`.
55
55
  * Soft-deleted orgs are included, as their org config rows are; callers filter `orgs.deleted_at`.
56
56
  */
57
+ // org-filter: every (org, extension) pair by design; callers join it on their own org column
57
58
  export function enabledExtensionsByOrg(db) {
58
59
  return db
59
60
  .selectFrom("extension_org_configs as eoc")
@@ -59,8 +59,9 @@ export interface InspectedExtension {
59
59
  displayName: LocalizedName | null;
60
60
  }
61
61
  /**
62
- * 插件两级配置 schema 中的每个 `secret()` 都必须标在对象路径的字段上(见 `unreachableSecrets`),
63
- * 否则内核无法把它单独加密存储 / 打码、会按明文保存与回显——此时拒绝加载并点名插件与路径。
62
+ * Every `secret()` in an extension's deployment schema must sit on an object field path (see
63
+ * `unreachableSecrets`); otherwise the kernel cannot store and mask it on its own and would keep
64
+ * and echo it in clear, so the load is refused, naming the extension and the path.
64
65
  */
65
66
  export declare function assertSecretsReachable(manifest: ExtensionManifest): void;
66
67
  /**
@@ -417,7 +418,7 @@ export declare class ExtensionHost {
417
418
  */
418
419
  private loadDeferred;
419
420
  /**
420
- * Checks the config UI hints of a loaded module's deployment and org schemas (spec §4.1). Invalid
421
+ * Checks the config UI hints of a loaded module's deployment schema (spec §4.1). Invalid
421
422
  * hints never fail the load: the form schemas drop their `x-ui` (`configFormSchema`), one warning
422
423
  * per `<name>@<version>` is logged, and the returned text goes into the status detail (null when
423
424
  * every hint is valid). The packer refuses such a package; this covers hand-made ones. It never
@@ -189,18 +189,17 @@ async function migratePlugin(dbUrl, manifest, migrationsDir, connectTimeoutMs, s
189
189
  }
190
190
  }
191
191
  /**
192
- * 插件两级配置 schema 中的每个 `secret()` 都必须标在对象路径的字段上(见 `unreachableSecrets`),
193
- * 否则内核无法把它单独加密存储 / 打码、会按明文保存与回显——此时拒绝加载并点名插件与路径。
192
+ * Every `secret()` in an extension's deployment schema must sit on an object field path (see
193
+ * `unreachableSecrets`); otherwise the kernel cannot store and mask it on its own and would keep
194
+ * and echo it in clear, so the load is refused, naming the extension and the path.
194
195
  */
195
196
  export function assertSecretsReachable(manifest) {
196
- for (const level of ["deployment", "org"]) {
197
- const schema = manifest.config?.[level];
198
- if (!schema)
199
- continue;
200
- const bad = unreachableSecrets(schema);
201
- if (bad.length > 0) {
202
- throw new Error(`plugin ${manifest.name}: config.${level}: ${bad.map((p) => `secret() at "${p}"`).join(", ")} is not on an object field path; secret() inside union / intersection / transform / pipe / lazy / array / record / tuple is not supported — mark the whole enclosing object field secret instead`);
203
- }
197
+ const schema = manifest.config?.deployment;
198
+ if (!schema)
199
+ return;
200
+ const bad = unreachableSecrets(schema);
201
+ if (bad.length > 0) {
202
+ throw new Error(`plugin ${manifest.name}: config.deployment: ${bad.map((p) => `secret() at "${p}"`).join(", ")} is not on an object field path; secret() inside union / intersection / transform / pipe / lazy / array / record / tuple is not supported — mark the whole enclosing object field secret instead`);
204
203
  }
205
204
  }
206
205
  /** 按模块解析的插件(配置声明)的迁移目录:清单 `migrations` 相对模块所在目录。 */
@@ -1153,7 +1152,7 @@ let ExtensionHost = class ExtensionHost {
1153
1152
  }
1154
1153
  }
1155
1154
  /**
1156
- * Checks the config UI hints of a loaded module's deployment and org schemas (spec §4.1). Invalid
1155
+ * Checks the config UI hints of a loaded module's deployment schema (spec §4.1). Invalid
1157
1156
  * hints never fail the load: the form schemas drop their `x-ui` (`configFormSchema`), one warning
1158
1157
  * per `<name>@<version>` is logged, and the returned text goes into the status detail (null when
1159
1158
  * every hint is valid). The packer refuses such a package; this covers hand-made ones. It never
@@ -1162,7 +1161,7 @@ let ExtensionHost = class ExtensionHost {
1162
1161
  */
1163
1162
  checkConfigUi(manifest) {
1164
1163
  const parts = [];
1165
- for (const level of ["deployment", "org"]) {
1164
+ for (const level of ["deployment"]) {
1166
1165
  const schema = manifest.config?.[level];
1167
1166
  if (!schema)
1168
1167
  continue;
@@ -11,7 +11,7 @@ export type { Registration, RegistrationKind } from "./ledger.js";
11
11
  export declare class ManifestMismatchError extends Error {
12
12
  constructor(plugin: string, moduleName: string);
13
13
  }
14
- /** 模块清单与审阅过的静态清单是否一致(名字与 {@link staticManifestOf} 都须相同)。 */
14
+ /** Whether a module's manifest matches the reviewed static manifest (same name and {@link staticManifestOf}). */
15
15
  export declare function matchesSection(manifest: ExtensionManifest, name: string, section: StaticExtensionManifest): boolean;
16
16
  /** 导入一个插件模块(default 导出)并按 defineExtension 校验清单。 */
17
17
  export declare function importExtensionModule(url: string, label: string, resolveFrom: string): Promise<ExtensionManifest>;
@@ -23,9 +23,24 @@ const canonical = (v) => {
23
23
  }
24
24
  return JSON.stringify(v) ?? "null";
25
25
  };
26
- /** 模块清单与审阅过的静态清单是否一致(名字与 {@link staticManifestOf} 都须相同)。 */
26
+ /**
27
+ * A reviewed static manifest without the `config.org` list that packages packed before core#720
28
+ * carry (stored install records and catalog sections keep it as reviewed). The list is dropped, not
29
+ * compared: the SDK no longer has org-only config, and `defineExtension` drops the module's own
30
+ * `config.org` the same way. Removed with the other pre-core#720 readers once the official plugins are
31
+ * republished and re-pinned (core#720 plan Task 17).
32
+ */
33
+ function withoutLegacyOrgConfig(section) {
34
+ const config = section.config;
35
+ if (config === undefined || !("org" in config))
36
+ return section;
37
+ const { org: _legacyOrg, ...rest } = config;
38
+ return { ...section, config: rest };
39
+ }
40
+ /** Whether a module's manifest matches the reviewed static manifest (same name and {@link staticManifestOf}). */
27
41
  export function matchesSection(manifest, name, section) {
28
- return manifest.name === name && canonical(staticManifestOf(manifest)) === canonical(section);
42
+ return (manifest.name === name &&
43
+ canonical(staticManifestOf(manifest)) === canonical(withoutLegacyOrgConfig(section)));
29
44
  }
30
45
  /** 导入一个插件模块(default 导出)并按 defineExtension 校验清单。 */
31
46
  export async function importExtensionModule(url, label, resolveFrom) {
@@ -1,36 +1,29 @@
1
1
  import type { PluginScope } from "../catalog/scope.js";
2
- import { type Keyring } from "../ctx/secrets.js";
3
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
4
3
  import { KernelDb } from "../infra/database/kernel-db.js";
5
4
  import { TransactionHost } from "../infra/database/transaction-host.js";
6
5
  import { KernelEvents } from "../infra/events/kernel-events.js";
7
- import type { KernelLogger } from "../log.js";
8
6
  import { OrgLock } from "../orgs/org-lock.js";
9
- import { type ConfigIssue, toIssues } from "./config-issues.js";
10
- import { type JsonSchema } from "./config-json-schema.js";
11
7
  import { EffectiveConfigs } from "./effective-config.js";
12
8
  import { ExtensionHost } from "./host.js";
13
9
  import { ExtensionInstalls } from "./installs.js";
14
10
  import { type DeploymentExtensionStatus, type PermissionGroup } from "./permission-view.js";
15
11
  import { ExtensionAvailability, type ExtensionUnavailableReason } from "./unavailable.js";
16
- export { type ConfigIssue, toIssues };
17
- /** 组织视角下一个已加载插件的状态;`config` 永远不含密钥字段,密钥只回显「是否已设置」。 */
12
+ /**
13
+ * An org's view of one extension: its state in the org, never a config value (an org's config is
14
+ * its copy of the overridable deployment fields, read through the overrides route).
15
+ */
18
16
  export interface OrgExtensionView {
19
17
  plugin: string;
20
18
  version: string;
21
19
  enabled: boolean;
22
- /** 插件是否声明了 `config.org`。 */
20
+ /**
21
+ * The org can configure it: its deployment schema has at least one org-overridable field (spec
22
+ * §5.4). False when unavailable.
23
+ */
23
24
  configurable: boolean;
24
- /** 已存的非密钥配置;未配置或不可配置时为 null。 */
25
- config: Record<string, unknown> | null;
26
- secrets: {
27
- path: string;
28
- set: boolean;
29
- }[];
30
25
  /** 插件要用的权限,按类别分组并标出敏感项(密钥、公开路由、工具、hook)。 */
31
26
  permissions: PermissionGroup[];
32
- /** `config.org` 的 JSON Schema(密钥字段带 `x-secret`);不可配置时为 null。 */
33
- orgConfigSchema: JsonSchema | null;
34
27
  /**
35
28
  * 插件此刻在部署上可用(已加载)。false:已安装但在部署上停用(或尚未加载),组织页显示「不可用」,
36
29
  * 组织的启用开关保留不变(不能修改),其余字段为空。
@@ -48,7 +41,7 @@ export interface OrgExtensionView {
48
41
  reason?: ExtensionUnavailableReason;
49
42
  /**
50
43
  * A required bootstrap plugin: enabled in every org (`enabled` is always true) and cannot be
51
- * disabled here (`extension.required`); its org config, when it has one, can still be set. An
44
+ * disabled here (`extension.required`); its overridable fields can still be copied. An
52
45
  * extension of a builtin plugin is enabled in every org as well (`enabled.ts`) without being
53
46
  * required: it is locked by its plugin (`switchable` false, `plugin.scope_locked`).
54
47
  */
@@ -67,16 +60,15 @@ export interface OrgExtensionView {
67
60
  overrideState: "following" | "copy" | "none";
68
61
  /**
69
62
  * The org must configure the extension before it works here (spec A §6): its effective config
70
- * is not valid, or a required org-only field is missing. Always false when unavailable.
63
+ * for the org is not valid. Always false when unavailable.
71
64
  */
72
65
  needsConfig: boolean;
73
66
  }
74
67
  /** The extension points an extension provides, from its permission list's `provides` group. */
75
68
  export declare function providesOf(view: Pick<OrgExtensionView, "permissions">): string[];
76
- /** `put` 的输入:`config` 中的密钥字段缺省 = 保留原值、`null` = 清除、其他值 = 新值。 */
69
+ /** The input of `put`: enablement only. */
77
70
  export interface OrgExtensionInput {
78
71
  enabled?: boolean | undefined;
79
- config?: Record<string, unknown> | undefined;
80
72
  /** Disable even when enabled dependents remain (default `extension.has_dependents`). */
81
73
  force?: boolean | undefined;
82
74
  }
@@ -96,7 +88,7 @@ export interface OrgExtensionPutOptions {
96
88
  approvedBy?: string;
97
89
  /**
98
90
  * For a plugin install: when the extension is already enabled under the org row lock, nothing is
99
- * written (no config change, no audit) and `skipped` is set to true. "Enabled before" and
91
+ * written (no audit) and `skipped` is set to true. "Enabled before" and
100
92
  * "enabled now" are decided under the lock, so a concurrent enable cannot race it. A caller that
101
93
  * records the extension in the same transaction (the catalog install, `put` joins its
102
94
  * transaction) reads `skipped` after `put` returns: no concurrent uninstall fits in between.
@@ -104,37 +96,19 @@ export interface OrgExtensionPutOptions {
104
96
  ifDisabled?: {
105
97
  skipped: boolean;
106
98
  };
107
- /**
108
- * Check the role and the config (the given `config`, or with `enabled: true` the stored one,
109
- * merged with the stored secrets, against the schema) and write nothing: lets a caller that must
110
- * do another write first fail without a side effect. The rules for newly enabling (catalog policy,
111
- * dependencies) are left to that write: the plugin install that enables it checks them.
112
- */
113
- validateOnly?: boolean;
114
99
  /** Merged into the audit detail (a Platform operation's `via: "agent"`). */
115
100
  auditDetail?: Record<string, unknown>;
116
101
  }
117
102
  /**
118
- * An org's stored config of a plugin no longer matches its org schema (e.g. after a plugin upgrade):
119
- * a known state, not a read error. The message names the plugin, the org and the failing paths,
120
- * never the values.
121
- */
122
- export declare class OrgConfigInvalidError extends Error {
123
- readonly plugin: string;
124
- readonly orgId: string;
125
- constructor(plugin: string, orgId: string, detail: string);
126
- }
127
- /**
128
- * Org-level extension config: enablement and the `config.org` config stored per org.
129
- * The non-secret part is stored in `capybara.extension_org_configs.config`; each secret field is
130
- * encrypted separately in `capybara.secrets` (namespace `kernel`, key `plugin-config:<plugin>:<path>`),
131
- * written in the same transaction as the config row.
103
+ * Org-level extension enablement (`capybara.extension_org_configs.enabled`) and the org's view of
104
+ * each extension. An org's config of an extension is its copy of the overridable deployment fields
105
+ * (`OrgOverrides`, `EffectiveConfigs`); the retired `config` column and the `plugin-config:` org
106
+ * secrets are neither read nor written (spec §5.4; dropped by a later contract migration).
132
107
  * No in-process state: every call reads PG, safe with multiple replicas.
133
108
  */
134
109
  export declare class OrgExtensionConfigs {
135
110
  private readonly kdb;
136
111
  readonly txHost: TransactionHost;
137
- private readonly keyring;
138
112
  private readonly host;
139
113
  /** The org row lock (orgs/org-lock.ts): joins the transaction. */
140
114
  private readonly orgLock;
@@ -142,50 +116,42 @@ export declare class OrgExtensionConfigs {
142
116
  private readonly installs;
143
117
  /** `extension.org-disabled` after a disable commits (channel connections drop at once). */
144
118
  private readonly events;
145
- /** Secret values handled (written or decrypted) are masked in the logs after the commit. */
146
- private readonly log;
147
119
  /** The effective deployment config of each org (spec A §6): read for `needsConfig`. */
148
120
  private readonly effective;
149
121
  /** Why an installed extension is not loaded (`status` / `reason` of the unavailable ones). */
150
122
  private readonly availability;
151
- /** Test seam only: a deterministic interleaving point after the config rows are read, before the secrets. */
152
- afterConfigRowRead: (() => Promise<void>) | undefined;
153
- constructor(kdb: KernelDb, txHost: TransactionHost, keyring: Keyring, host: ExtensionHost,
123
+ constructor(kdb: KernelDb, txHost: TransactionHost, host: ExtensionHost,
154
124
  /** The org row lock (orgs/org-lock.ts): joins the transaction. */
155
125
  orgLock: OrgLock,
156
126
  /** Install records (any desired state): the ones not loaded are listed unavailable (T14). */
157
127
  installs: ExtensionInstalls,
158
128
  /** `extension.org-disabled` after a disable commits (channel connections drop at once). */
159
129
  events: KernelEvents,
160
- /** Secret values handled (written or decrypted) are masked in the logs after the commit. */
161
- log: KernelLogger,
162
130
  /** The effective deployment config of each org (spec A §6): read for `needsConfig`. */
163
131
  effective: EffectiveConfigs,
164
132
  /** Why an installed extension is not loaded (`status` / `reason` of the unavailable ones). */
165
133
  availability: ExtensionAvailability);
166
134
  /** The kernel-schema handle of the current transaction. */
167
135
  private get db();
168
- /** 把一份组织配置里的密钥值登记到日志打码(无密钥时无操作);调用方须在事务提交后调用。 */
169
- private reportSecrets;
170
136
  /** After a write committed: a disabled extension's channel connections drop at once. */
171
137
  private afterPut;
172
138
  /**
173
- * The state of every loaded extension the org sees, in load order (no row: `enabled` false,
174
- * `config` null), then the installed extensions not loaded right now (disabled on the deployment
175
- * and the like) as `available: false`, sorted by name. The rows and secrets are read in a
176
- * `requires_new` snapshot on a second pool connection: never call it inside a transaction that
177
- * holds a pool connection (unlike {@link get}, it does not join one).
139
+ * The state of every loaded extension the org sees, in load order (no row: `enabled` false),
140
+ * then the installed extensions not loaded right now (disabled on the deployment and the like)
141
+ * as `available: false`, sorted by name. The rows are read in a `requires_new` snapshot on a
142
+ * second pool connection: never call it inside a transaction that holds a pool connection
143
+ * (unlike {@link get}, it does not join one).
178
144
  */
179
145
  list(orgId: string): Promise<OrgExtensionView[]>;
180
146
  /**
181
- * Fills `overrideState` and the platform half of `needsConfig` (spec A §6) for the views of
182
- * extensions with overridable fields (the others always run with the platform's config, which
147
+ * Fills `overrideState` and `needsConfig` (spec A §6: the effective config alone) for the views
148
+ * of extensions with overridable fields (the others always run with the platform's config, which
183
149
  * loaded valid). Reads the org's copy rows once and the effective config of each such extension.
184
150
  */
185
151
  private withLayers;
186
152
  /**
187
- * `REPEATABLE READ` read-only: the config rows and the secrets come from one snapshot. It is
188
- * `requires_new`: it always takes a second pool connection, so never call `list` inside a
153
+ * `REPEATABLE READ` read-only: the enablement rows and the plugin items come from one snapshot.
154
+ * It is `requires_new`: it always takes a second pool connection, so never call `list` inside a
189
155
  * transaction that holds one (a locked transaction waiting on the pool can starve it; `get`
190
156
  * joins the caller's transaction instead).
191
157
  */
@@ -206,15 +172,12 @@ export declare class OrgExtensionConfigs {
206
172
  itemId: string;
207
173
  }>;
208
174
  /**
209
- * Writes enablement and / or config. The actor's role is re-read under the org row lock (needs
175
+ * Writes enablement. The actor's role is re-read under the org row lock (needs
210
176
  * `org.extensions.manage`).
211
- * - Extension not loaded -> `extension.not_found`; `config` given but the extension has no
212
- * `config.org` -> `extension.no_org_config`; `enabled: false` for a required bootstrap plugin
213
- * -> `extension.required` (it stays enabled in every org; its config can still be written).
214
- * - Non-secret fields are replaced as a whole by the given value; secret fields keep the old value
215
- * when omitted, `null` clears, any other value is the new value.
216
- * - The merged full config (or, without `config`, the existing config when the result is enabled)
217
- * does not satisfy the schema -> `extension.config_invalid`.
177
+ * - Extension not loaded -> `extension.not_found`; `enabled: false` for a required bootstrap
178
+ * plugin -> `extension.required` (it stays enabled in every org).
179
+ * - Enabling never checks a config: an extension whose effective config is not valid for the org
180
+ * is enabled and reported `needsConfig` (spec A §6: it gets no org-bound call until then).
218
181
  */
219
182
  put(orgId: string, plugin: string, input: OrgExtensionInput,
220
183
  /** null: the kernel itself (the plugin scope sync installing a plugin), no role check. */
@@ -227,31 +190,14 @@ export declare class OrgExtensionConfigs {
227
190
  */
228
191
  private assertSwitchRules;
229
192
  /**
230
- * 读取并解密某插件在该组织下的完整配置(供运行时按组织构造插件实例)。
231
- * An always-on extension (a required bootstrap plugin, or its plugin is builtin: `enabled.ts`) is
232
- * enabled without a row (its stored config, or `{}`, is validated).
233
- * 无记录 → undefined;插件无 `config.org` 或已停用(`enabled=false`,不校验、不读密钥)时 `config` 为 null。
234
- * Inside a caller's transaction it joins that transaction (its connection and isolation, and it
235
- * sees the caller's uncommitted writes): the config row and its secrets are consistent there when
236
- * the caller holds the org row, as every writer of org configs and their secrets locks it first.
237
- * On its own it reads them in one `REPEATABLE READ` read-only snapshot.
238
- * A stored config that no longer matches the schema (e.g. after a plugin upgrade) throws
239
- * {@link OrgConfigInvalidError} (plugin, org ID and the failing paths, no values); other errors are
240
- * read errors.
193
+ * Whether `plugin` is enabled in the org: an always-on extension (a required bootstrap plugin, or
194
+ * its plugin is builtin: `enabled.ts`) is enabled without a row; no row otherwise -> undefined.
195
+ * Inside a caller's transaction it reads in that transaction (it sees the caller's uncommitted
196
+ * writes). The extension's config for the org is its effective config ({@link EffectiveConfigs}).
241
197
  */
242
198
  get(orgId: string, plugin: string): Promise<{
243
199
  enabled: boolean;
244
- config: unknown;
245
200
  } | undefined>;
246
- /**
247
- * On its own, `REPEATABLE READ` read-only: the config row and the secrets come from one snapshot.
248
- * Inside a caller's transaction it reads in that transaction instead (`required`; consistent when
249
- * the caller holds the org row, see {@link get}): a caller holding a
250
- * connection never waits for a second one from the pool (the device provider check runs inside
251
- * locked transactions; concurrent runs would starve the pool).
252
- */
253
- private getSnapshot;
254
- private decode;
255
201
  /**
256
202
  * 该组织里已启用、且所 requires 的按组织启用的能力只剩这个插件提供的插件(停用它会让它们失去依赖)。
257
203
  * 在调用方事务里读(应用卸载 / 回滚前判断是否保留;`mandatory`: the caller holds the org row lock).
@@ -277,14 +223,6 @@ export declare class OrgExtensionConfigs {
277
223
  private manifest;
278
224
  private permissionsOf;
279
225
  private view;
280
- /**
281
- * The org schema's form JSON Schema, a copy (`x-ui` stripped when its hints are invalid; the host
282
- * warns at load). Never throws: a hint conversion that throws serves the plain schema, or null
283
- * (one warning per schema on this replica), so one hand-made package cannot fail the org's list.
284
- */
285
- private formSchema;
286
- /** 该组织在 `kernel` 命名空间下已设置的插件配置密钥键(不解密)。 */
287
- private setSecretKeys;
288
226
  }
289
227
  /**
290
228
  * Whether the org may see `plugin` (a required bootstrap plugin always; else under its catalog