@capybara-hq/kernel 0.1.0-rc.57 → 0.1.0-rc.59

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 (126) hide show
  1. package/dist/admin/extensions.controller.d.ts +2 -10
  2. package/dist/admin/extensions.controller.js +2 -24
  3. package/dist/admin/extensions.schemas.d.ts +21 -0
  4. package/dist/admin/extensions.schemas.js +37 -0
  5. package/dist/catalog/marketplaces.service.d.ts +1 -1
  6. package/dist/catalog/org-catalog.controller.d.ts +0 -5
  7. package/dist/catalog/org-catalog.controller.js +3 -17
  8. package/dist/catalog/org-catalog.schemas.d.ts +43 -0
  9. package/dist/catalog/org-catalog.schemas.js +43 -2
  10. package/dist/catalog/org-extension-switch.d.ts +3 -1
  11. package/dist/catalog/org-extension-switch.js +12 -5
  12. package/dist/catalog/org-extension.controller.d.ts +2 -21
  13. package/dist/catalog/org-extension.controller.js +1 -38
  14. package/dist/catalog/org-extension.schemas.d.ts +31 -0
  15. package/dist/catalog/org-extension.schemas.js +65 -0
  16. package/dist/catalog/plugin-install.d.ts +2 -0
  17. package/dist/catalog/plugin-install.js +3 -3
  18. package/dist/channels/actions.js +2 -0
  19. package/dist/channels/cards.d.ts +8 -0
  20. package/dist/channels/cards.js +18 -0
  21. package/dist/channels/channels.schemas.d.ts +3 -0
  22. package/dist/channels/channels.schemas.js +8 -0
  23. package/dist/channels/connections.service.d.ts +17 -2
  24. package/dist/channels/connections.service.js +30 -5
  25. package/dist/channels/outbound.js +25 -1
  26. package/dist/channels/phrases.d.ts +10 -0
  27. package/dist/channels/phrases.js +10 -0
  28. package/dist/conversations/conversations.module.js +4 -0
  29. package/dist/conversations/events.d.ts +35 -0
  30. package/dist/conversations/events.js +29 -0
  31. package/dist/conversations/leak-check.d.ts +26 -0
  32. package/dist/conversations/leak-check.js +69 -0
  33. package/dist/ctx/secrets.d.ts +13 -1
  34. package/dist/ctx/secrets.js +19 -1
  35. package/dist/db/kernel-schema.d.ts +34 -0
  36. package/dist/devices/working-root.d.ts +2 -3
  37. package/dist/errors.d.ts +19 -0
  38. package/dist/errors.js +19 -0
  39. package/dist/extensions/deployment-config.d.ts +6 -2
  40. package/dist/extensions/deployment-config.js +35 -23
  41. package/dist/extensions/org-config.d.ts +2 -0
  42. package/dist/extensions/org-config.js +1 -0
  43. package/dist/extensions/org-overrides.d.ts +2 -0
  44. package/dist/extensions/org-overrides.js +3 -2
  45. package/dist/http/api.module.js +6 -0
  46. package/dist/identity/initial-passwords.job.d.ts +3 -2
  47. package/dist/identity/initial-passwords.job.js +11 -5
  48. package/dist/orgs/invitations.controller.d.ts +3 -11
  49. package/dist/orgs/invitations.controller.js +9 -10
  50. package/dist/orgs/invitations.service.d.ts +12 -2
  51. package/dist/orgs/invitations.service.js +14 -7
  52. package/dist/orgs/members.service.d.ts +12 -2
  53. package/dist/orgs/members.service.js +10 -8
  54. package/dist/orgs/orgs.controller.d.ts +4 -12
  55. package/dist/orgs/orgs.controller.js +10 -10
  56. package/dist/orgs/orgs.schemas.d.ts +26 -0
  57. package/dist/orgs/orgs.schemas.js +22 -0
  58. package/dist/platform/connector-person-fields.d.ts +67 -0
  59. package/dist/platform/connector-person-fields.js +129 -0
  60. package/dist/platform/exclusions.js +6 -141
  61. package/dist/platform/method.js +1 -0
  62. package/dist/platform/operation.d.ts +61 -2
  63. package/dist/platform/operation.js +4 -4
  64. package/dist/platform/ops/accounts.ops.js +1 -0
  65. package/dist/platform/ops/channels.ops.d.ts +10 -3
  66. package/dist/platform/ops/channels.ops.js +223 -5
  67. package/dist/platform/ops/connectors.ops.d.ts +22 -4
  68. package/dist/platform/ops/connectors.ops.js +664 -13
  69. package/dist/platform/ops/extensions-admin.ops.d.ts +15 -2
  70. package/dist/platform/ops/extensions-admin.ops.js +153 -5
  71. package/dist/platform/ops/extensions.ops.d.ts +19 -5
  72. package/dist/platform/ops/extensions.ops.js +285 -10
  73. package/dist/platform/ops/org-plugins.ops.d.ts +15 -2
  74. package/dist/platform/ops/org-plugins.ops.js +323 -4
  75. package/dist/platform/ops/orgs.ops.d.ts +40 -3
  76. package/dist/platform/ops/orgs.ops.js +293 -12
  77. package/dist/platform/ops/person-inputs.d.ts +65 -0
  78. package/dist/platform/ops/person-inputs.js +129 -0
  79. package/dist/platform/ops/plugins.ops.d.ts +3 -1
  80. package/dist/platform/ops/plugins.ops.js +33 -20
  81. package/dist/platform/parity.d.ts +7 -2
  82. package/dist/platform/parity.js +75 -13
  83. package/dist/platform/person-fields.d.ts +119 -0
  84. package/dist/platform/person-fields.js +403 -0
  85. package/dist/platform/platform.module.d.ts +4 -3
  86. package/dist/platform/platform.module.js +8 -5
  87. package/dist/platform/route-schemas.js +2 -0
  88. package/dist/platform/sealed-inputs.d.ts +44 -0
  89. package/dist/platform/sealed-inputs.js +116 -0
  90. package/dist/platform/sealed-reveals.controller.d.ts +20 -0
  91. package/dist/platform/sealed-reveals.controller.js +48 -0
  92. package/dist/platform/sealed-reveals.d.ts +52 -0
  93. package/dist/platform/sealed-reveals.js +153 -0
  94. package/dist/runtime/project/knowledge.js +24 -19
  95. package/dist/runtime/waits.js +8 -2
  96. package/dist/sandbox/permission-facts.d.ts +5 -1
  97. package/dist/sandbox/permission-facts.js +8 -2
  98. package/dist/setup/setup-guides.service.d.ts +5 -0
  99. package/dist/setup/setup-guides.service.js +2 -1
  100. package/dist/tools/approvals.controller.d.ts +1 -0
  101. package/dist/tools/approvals.controller.js +19 -0
  102. package/dist/tools/approvals.service.d.ts +50 -1
  103. package/dist/tools/approvals.service.js +118 -10
  104. package/dist/tools/builtins/builtin-tools.d.ts +3 -0
  105. package/dist/tools/builtins/builtin-tools.js +31 -9
  106. package/dist/tools/builtins/platform.d.ts +20 -0
  107. package/dist/tools/builtins/platform.js +214 -15
  108. package/dist/tools/connectors.controller.d.ts +6 -7
  109. package/dist/tools/connectors.controller.js +4 -44
  110. package/dist/tools/connectors.schemas.d.ts +170 -1
  111. package/dist/tools/connectors.schemas.js +82 -3
  112. package/dist/tools/connectors.service.d.ts +16 -6
  113. package/dist/tools/connectors.service.js +39 -24
  114. package/dist/tools/oauth/oauth.controller.d.ts +3 -6
  115. package/dist/tools/oauth/oauth.controller.js +3 -12
  116. package/dist/tools/oauth/oauth.schemas.d.ts +14 -0
  117. package/dist/tools/oauth/oauth.schemas.js +27 -0
  118. package/dist/tools/pipeline.d.ts +31 -2
  119. package/dist/tools/pipeline.js +89 -17
  120. package/dist/tools/policy.d.ts +4 -0
  121. package/dist/tools/policy.js +8 -0
  122. package/dist/tools/registry.d.ts +29 -0
  123. package/dist/tools/tools.module.js +3 -0
  124. package/package.json +3 -3
  125. package/src/migrations/0169_platform_sealed_inputs.sql +23 -0
  126. package/src/migrations/0170_platform_sealed_reveals.sql +27 -0
@@ -10,9 +10,12 @@ 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, OrgExtensionToolParams, OrgToolSwitchPut, } from "../../catalog/org-extension.schemas.js";
13
+ import { OrgExtensionParams, OrgExtensionPut, OrgExtensionToolParams, OrgOverridesPut, OrgOverridesTake, OrgToolSwitchPut, } from "../../catalog/org-extension.schemas.js";
14
+ import { OrgExtensionSwitch } from "../../catalog/org-extension-switch.js";
15
+ import { ApiError } from "../../errors.js";
14
16
  import { ExtensionDisplayNames } from "../../extensions/display-name.js";
15
17
  import { OrgExtensionConfigs, providesOf, } from "../../extensions/org-config.js";
18
+ import { OrgOverrides } from "../../extensions/org-overrides.js";
16
19
  import { ExtensionPointDefaults } from "../../extensions/point-defaults.js";
17
20
  import { ExtensionPointDefaultBody, ExtensionPointParams, } from "../../extensions/point-defaults.schemas.js";
18
21
  import { KernelDb } from "../../infra/database/kernel-db.js";
@@ -20,9 +23,11 @@ import { can } from "../../orgs/roles.js";
20
23
  import { OrgToolSwitches } from "../../tools/org-tool-switches.js";
21
24
  import { resolveNext } from "../errors.js";
22
25
  import { defineOperation } from "../operation.js";
26
+ import { personFieldParams, secretFieldsOf } from "../person-fields.js";
23
27
  import { PlatformOperations } from "../registry.js";
24
28
  import { precheckBy, viaAgent } from "./errors.js";
25
29
  import { Cursor, pageOf, startOf } from "./paging.js";
30
+ import { configChanges, flatValues, nestedConfig, withPersonInputs } from "./person-inputs.js";
26
31
  import { roleOf } from "./role.js";
27
32
  import { localized, named, orElse } from "./summary.js";
28
33
  import { roleFor, unavailableFields } from "./unavailable.js";
@@ -30,11 +35,40 @@ const NoInput = z.object({}).strict();
30
35
  const Extension = OrgExtensionParams.shape.extension;
31
36
  const Tool = OrgExtensionToolParams.shape.tool;
32
37
  const SwitchConfirm = OrgToolSwitchPut.shape.confirm.unwrap();
33
- /** The next step of an extension that needs its org config (an org admin enters it on the web). */
38
+ /** The next step of an extension that needs its org config. */
34
39
  const NEEDS_ORG_CONFIG = {
35
- orgAdmin: "An org admin fills in its org config on the Extensions page, where secrets are entered.",
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 on the confirmation card.",
36
41
  member: "Ask an org admin to fill in its org config on the Extensions page.",
37
42
  };
43
+ /** The org config a write replaces (the whole non-secret config; secrets left out keep). */
44
+ const OrgConfigValues = OrgExtensionPut.shape.config.unwrap();
45
+ /**
46
+ * Secret fields of a target the schema walk cannot address (no form schema, a record): web only,
47
+ * so a value for one in `values` is refused as well.
48
+ */
49
+ function withUnaddressed(found, secretPaths) {
50
+ const asked = new Set(found.fields.map((f) => f.path));
51
+ return {
52
+ fields: found.fields,
53
+ recordOnly: [...new Set([...found.recordOnly, ...secretPaths.filter((p) => !asked.has(p))])],
54
+ };
55
+ }
56
+ /**
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.
60
+ */
61
+ export function copyPersonFields(v) {
62
+ const secrets = v.fields.filter((f) => f.secret);
63
+ const stored = new Set(secrets.filter((f) => f.org?.set === true).map((f) => f.path));
64
+ // levels are per top-level property (org-levels.ts)
65
+ const top = (path) => path.split(/[.[]/)[0];
66
+ const overridable = new Set(v.fields.filter((f) => f.level === "override").map((f) => top(f.path)));
67
+ const found = secretFieldsOf(v.schema, stored);
68
+ const fields = found.fields.filter((f) => overridable.has(top(f.path)));
69
+ const notOurs = found.fields.filter((f) => !overridable.has(top(f.path))).map((f) => f.path);
70
+ return withUnaddressed({ fields, recordOnly: [...found.recordOnly, ...notOurs] }, secrets.map((f) => f.path));
71
+ }
38
72
  /** An extension's state in the org, as the Extensions page shows it. */
39
73
  function stateOf(v) {
40
74
  if (!v.available)
@@ -44,10 +78,11 @@ function stateOf(v) {
44
78
  return v.enabled ? "on" : "off";
45
79
  }
46
80
  /**
47
- * Extension operations of the `Platform` tool (spec §7): read only, and state only. The org config,
48
- * the secrets' state, the config schema and the permission list are never returned (the member
49
- * projection of `GET /orgs/:orgId/extensions`, whatever the actor's role); configuring an
50
- * extension is done on the web.
81
+ * Extension operations of the `Platform` tool (spec §7): the org's extensions (the member projection
82
+ * 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
85
+ * whether each is set) and never taken as params: the person enters them on the confirmation card.
51
86
  */
52
87
  let ExtensionsOperations = class ExtensionsOperations {
53
88
  registry;
@@ -56,13 +91,25 @@ let ExtensionsOperations = class ExtensionsOperations {
56
91
  kdb;
57
92
  switches;
58
93
  pointDefaults;
59
- constructor(registry, configs, displayNames, kdb, switches, pointDefaults) {
94
+ overrides;
95
+ extSwitch;
96
+ constructor(registry, configs, displayNames, kdb, switches, pointDefaults, overrides, extSwitch) {
60
97
  this.registry = registry;
61
98
  this.configs = configs;
62
99
  this.displayNames = displayNames;
63
100
  this.kdb = kdb;
64
101
  this.switches = switches;
65
102
  this.pointDefaults = pointDefaults;
103
+ this.overrides = overrides;
104
+ this.extSwitch = extSwitch;
105
+ }
106
+ /** The org view of one extension, or `extension.not_found` (not installed or not offered). */
107
+ async viewOf(orgId, name) {
108
+ const v = (await this.configs.list(orgId)).find((x) => x.plugin === name);
109
+ if (v === undefined) {
110
+ throw new ApiError("extension.not_found", `Extension ${name} is not installed`);
111
+ }
112
+ return v;
66
113
  }
67
114
  /** An extension's display name for a card (its plugin's), else the name, clipped. */
68
115
  async nameOf(name) {
@@ -72,7 +119,7 @@ let ExtensionsOperations = class ExtensionsOperations {
72
119
  this.registry.register([
73
120
  defineOperation({
74
121
  id: "extensions.list",
75
- 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: configuring one is done on the web. Pages by 50: pass the returned next as params.cursor.",
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.",
76
123
  input: z.object({ cursor: Cursor.optional() }).strict(),
77
124
  example: {},
78
125
  authz: { orgAction: "org.extensions.read" },
@@ -224,6 +271,232 @@ let ExtensionsOperations = class ExtensionsOperations {
224
271
  auditDetail: viaAgent("extensions.set-tool-enabled", ctx),
225
272
  }, input.enabled ? undefined : input.confirm),
226
273
  }),
274
+ defineOperation({
275
+ 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.",
277
+ input: z.object({ extension: Extension }).strict(),
278
+ example: { extension: "model-anthropic" },
279
+ authz: { orgAction: "org.extensions.manage" },
280
+ mirrors: ["GET /api/v1/orgs/:orgId/extensions/:extension/overrides"],
281
+ confirm: "read",
282
+ errors: [
283
+ {
284
+ code: "extension.not_found",
285
+ next: "The extension is not running or not visible to this org; check the name with extensions.list.",
286
+ },
287
+ ],
288
+ 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
291
+ const v = await this.viewOf(ctx.orgId, input.extension);
292
+ return {
293
+ extension: v.plugin,
294
+ 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
+ },
302
+ deploymentCopy: v.available
303
+ ? await this.overrides.view(ctx.orgId, input.extension)
304
+ : null,
305
+ };
306
+ },
307
+ }),
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 on the confirmation card (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
+ defineOperation({
378
+ id: "extensions.save-org-config",
379
+ 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 on the confirmation card (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).",
380
+ input: z
381
+ .object({
382
+ extension: Extension,
383
+ values: OrgOverridesPut.shape.values.default({}),
384
+ askPerson: personFieldParams.askPerson,
385
+ clearSecrets: personFieldParams.clearSecrets,
386
+ })
387
+ .strict(),
388
+ example: {
389
+ extension: "model-anthropic",
390
+ values: {},
391
+ askPerson: ["apiKey"],
392
+ clearSecrets: [],
393
+ },
394
+ authz: { orgAction: "org.extensions.manage" },
395
+ mirrors: ["PUT /api/v1/orgs/:orgId/extensions/:extension/overrides"],
396
+ // secret record entries are entered on the web page (ruling R1)
397
+ omits: ["secretEntries"],
398
+ extras: ["askPerson", "clearSecrets"],
399
+ loosens: {
400
+ values: "defaults to {} so a call that only asks the person for secrets needs no values",
401
+ },
402
+ confirm: "org",
403
+ errors: [
404
+ {
405
+ code: "extension.not_found",
406
+ next: "The extension is not running or not visible to this org; check the name with extensions.list.",
407
+ },
408
+ {
409
+ code: "extension.field_not_overridable",
410
+ next: "Only overridable fields go into the org's copy; extensions.org-config lists them under deploymentCopy.",
411
+ },
412
+ {
413
+ code: "extension.config_invalid",
414
+ next: "Read the fields with extensions.org-config, correct the values (the error's details name the fields), then call again.",
415
+ },
416
+ ],
417
+ personFields: async (i, ctx) => {
418
+ const n = await this.nameOf(i.extension);
419
+ return {
420
+ target: { zh: `扩展「${n.zh}」的组织配置副本`, en: `${n.en}: the org's config copy` },
421
+ ...copyPersonFields(await this.overrides.view(ctx.orgId, i.extension)),
422
+ };
423
+ },
424
+ summary: async (i, ctx) => {
425
+ const n = await this.nameOf(i.extension);
426
+ const c = configChanges(i, ctx);
427
+ return {
428
+ zh: `保存本组织对扩展「${n.zh}」平台配置的副本:${c.zh}`,
429
+ en: `Save the org's copy of the platform config of extension "${n.en}": ${c.en}`,
430
+ };
431
+ },
432
+ run: async (input, ctx) => withPersonInputs("extensions.save-org-config", ctx, (entered, detail) => this.overrides.save(ctx.orgId, input.extension, flatValues(input.values, entered, input.clearSecrets), [], { accountId: ctx.actorAccountId, auditDetail: detail })),
433
+ }),
434
+ defineOperation({
435
+ id: "extensions.take-org-config",
436
+ description: "Take the platform's current values of non-secret overridable fields into the org's copy of an extension's deployment config (org admins); the org keeps its copy. paths are field dot paths from extensions.org-config.",
437
+ input: z.object({ extension: Extension, paths: OrgOverridesTake.shape.paths }).strict(),
438
+ example: { extension: "model-anthropic", paths: ["baseUrl"] },
439
+ authz: { orgAction: "org.extensions.manage" },
440
+ mirrors: ["POST /api/v1/orgs/:orgId/extensions/:extension/overrides/take"],
441
+ confirm: "org",
442
+ errors: [
443
+ {
444
+ code: "extension.not_found",
445
+ next: "The extension is not running or not visible to this org; check the name with extensions.list.",
446
+ },
447
+ {
448
+ code: "extension.no_org_override",
449
+ next: "The org follows the platform (no copy), so it has the platform's values already.",
450
+ },
451
+ {
452
+ code: "extension.field_not_overridable",
453
+ next: "Only non-secret overridable fields can be taken; extensions.org-config lists them under deploymentCopy.",
454
+ },
455
+ ],
456
+ summary: async (i) => {
457
+ const n = await this.nameOf(i.extension);
458
+ const paths = i.paths.map(named);
459
+ return {
460
+ zh: `把平台的 ${paths.join("、")} 取到本组织对扩展「${n.zh}」的配置副本`,
461
+ en: `Take the platform's ${paths.join(", ")} into the org's config copy of extension "${n.en}"`,
462
+ };
463
+ },
464
+ run: async (input, ctx) => this.overrides.take(ctx.orgId, input.extension, input.paths, {
465
+ accountId: ctx.actorAccountId,
466
+ auditDetail: viaAgent("extensions.take-org-config", ctx),
467
+ }),
468
+ }),
469
+ defineOperation({
470
+ id: "extensions.drop-org-config",
471
+ description: "Drop the org's copy of an extension's deployment config, its secrets too (org admins): the org follows the platform's config again.",
472
+ input: z.object({ extension: Extension }).strict(),
473
+ example: { extension: "model-anthropic" },
474
+ authz: { orgAction: "org.extensions.manage" },
475
+ mirrors: ["DELETE /api/v1/orgs/:orgId/extensions/:extension/overrides"],
476
+ confirm: "org",
477
+ rememberable: false,
478
+ errors: [
479
+ {
480
+ code: "extension.not_found",
481
+ next: "The extension is not running or not visible to this org; check the name with extensions.list.",
482
+ },
483
+ {
484
+ code: "extension.no_org_override",
485
+ next: "The org follows the platform already; there is no copy to drop.",
486
+ },
487
+ ],
488
+ summary: async (i) => {
489
+ const n = await this.nameOf(i.extension);
490
+ return {
491
+ zh: `删除本组织对扩展「${n.zh}」的配置副本(含其密钥),改为跟随平台`,
492
+ en: `Drop the org's config copy of extension "${n.en}" (its secrets too) and follow the platform`,
493
+ };
494
+ },
495
+ run: async (input, ctx) => this.overrides.reset(ctx.orgId, input.extension, {
496
+ accountId: ctx.actorAccountId,
497
+ auditDetail: viaAgent("extensions.drop-org-config", ctx),
498
+ }),
499
+ }),
227
500
  defineOperation({
228
501
  id: "extensions.point-defaults",
229
502
  description: "List the extension points where this org picks a default provider (org admins), such as web search: each point's candidate extensions, the stored default and the provider a call uses now.",
@@ -342,6 +615,8 @@ ExtensionsOperations = __decorate([
342
615
  __param(2, Inject(ExtensionDisplayNames)),
343
616
  __param(3, Inject(KernelDb)),
344
617
  __param(4, Inject(OrgToolSwitches)),
345
- __param(5, Inject(ExtensionPointDefaults))
618
+ __param(5, Inject(ExtensionPointDefaults)),
619
+ __param(6, Inject(OrgOverrides)),
620
+ __param(7, Inject(OrgExtensionSwitch))
346
621
  ], ExtensionsOperations);
347
622
  export { ExtensionsOperations };
@@ -5,12 +5,14 @@ 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";
8
9
  import { KernelDb } from "../../infra/database/kernel-db.js";
9
10
  import { ThemesService } from "../../themes/themes.service.js";
10
11
  import { PlatformOperations } from "../registry.js";
11
12
  /**
12
13
  * The org's own plugin operations of the `Platform` tool (spec §14.2): the org's plugin installs
13
- * (list, uninstall), its staged uploads (read; uploading is a byte transport and confirming is done
14
+ * (list, uninstall; installing with inputs and creating missing connectors, their secrets entered
15
+ * by the person on the card, platform web parity spec §7.2), its staged uploads (read; uploading is a byte transport and confirming is done
14
16
  * by a person on the web), and the plugins it owns (share, delete after a preview, withdraw a
15
17
  * pending upload). Org admins; the services re-check the role under the org lock.
16
18
  */
@@ -24,7 +26,18 @@ export declare class OrgPluginsOperations implements OnModuleInit {
24
26
  private readonly kdb;
25
27
  private readonly appearance;
26
28
  private readonly themes;
27
- constructor(registry: PlatformOperations, installer: PluginInstaller, orgCatalog: OrgCatalogService, uploads: OrgPluginUploads, owned: OwnedItems, scope: CatalogScopeService, kdb: KernelDb, appearance: AppearanceService, themes: ThemesService);
29
+ private readonly extensions;
30
+ constructor(registry: PlatformOperations, installer: PluginInstaller, orgCatalog: OrgCatalogService, uploads: OrgPluginUploads, owned: OwnedItems, scope: CatalogScopeService, kdb: KernelDb, appearance: AppearanceService, themes: ThemesService, extensions: OrgExtensionConfigs);
31
+ /**
32
+ * What installing a plugin asks the person for (platform web parity spec §7.2): the connector
33
+ * templates whose connector the install creates (on in the org, none kept from an earlier
34
+ * switch-off, as the install wizard asks), and the secret fields of its extension's org config
35
+ * under `extensionConfig.` (stored ones count as set; one the schema walk cannot address is web
36
+ * only). An extension whose org view cannot be read refuses the call: its secrets are unknown.
37
+ */
38
+ private installTargets;
39
+ /** The missing connectors of an installed plugin that a configure call names. */
40
+ private configureTargets;
28
41
  /** The display name of the live plugin of `extension`, or the name when it cannot be read. */
29
42
  private pluginNames;
30
43
  /** The org's own live plugin `id`, or null (another org's, a platform one, deleted, unknown). */