@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
@@ -193,7 +193,7 @@ export function parseCidr(s) {
193
193
  }
194
194
  const HOSTNAME = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/;
195
195
  /**
196
- * Why a `marketplaces.allowPrivateHosts` entry is invalid (English), or null when it is a hostname,
196
+ * Why a `net.allowPrivateHosts` entry is invalid (English), or null when it is a hostname,
197
197
  * an IP address or a CIDR no broader than /8 (IPv4) or /16 (IPv6).
198
198
  */
199
199
  export function privateHostEntryProblem(entry) {
@@ -210,7 +210,7 @@ export function privateHostEntryProblem(entry) {
210
210
  return null;
211
211
  return "must be a hostname, an IP address or a CIDR such as 10.1.0.0/16";
212
212
  }
213
- /** A valid `marketplaces.allowPrivateHosts` entry (see {@link privateHostEntryProblem}). */
213
+ /** A valid `net.allowPrivateHosts` entry (see {@link privateHostEntryProblem}). */
214
214
  export function isPrivateHostEntry(entry) {
215
215
  return privateHostEntryProblem(entry) === null;
216
216
  }
@@ -320,7 +320,7 @@ export async function resolvePublic(host, policy, lookup = defaultLookup, origin
320
320
  (isLinkLocalAddress(a) || ownHost(a) || (!ex.all && !allowedBy(ex.cidrs, a)));
321
321
  if (addrs.some(refused)) {
322
322
  const hint = policy.extension?.privateHint ??
323
- "add the hostname to marketplaces.allowPrivateHosts to allow an internal host";
323
+ "add the hostname to net.allowPrivateHosts to allow an internal host";
324
324
  throw new NetDeniedError("net.private_address", h, addrs.some(isLinkLocalAddress)
325
325
  ? `Access to ${h} is refused: it resolves to a link-local or cloud metadata address, which is never allowed.`
326
326
  : addrs.some(ownHost)
@@ -89,8 +89,11 @@ export interface SyncJobData {
89
89
  /**
90
90
  * 通讯录同步(`directory@1`):把企业通讯录同步为组织成员。框架无关。
91
91
  *
92
- * - 维护队列每小时 `directory-scan`:给每个「插件提供 `directory@1`、在该组织启用、组织级配置满足 schema」的
93
- * (组织, 插件) 投递一次同步(job id 按小时桶去重,多副本重复扫描只跑一次);手动与 `directory_changed` 也投递同步。
92
+ * - The maintenance queue's hourly `directory-scan` enqueues one sync per (org, extension) whose
93
+ * extension provides `directory@1`, is enabled in the org and has a valid effective config there
94
+ * (job ids deduplicated by hour bucket, so repeated scans on several replicas run once); manual
95
+ * triggers and `directory_changed` enqueue syncs too. Each call gets the org's own effective
96
+ * config (its copy of the overridable fields, or the platform's), never another org's.
94
97
  * - One sync at a time per (org, extension): the `LockService` lock
95
98
  * `lock:directory-sync:<org>:<plugin>`, renewed while held. A sync that finds the lock taken sets
96
99
  * the dirty flag `capk:directory-sync-dirty:<org>:<plugin>` (1 hour) and ends; after releasing
@@ -138,9 +141,9 @@ export declare class DirectorySync {
138
141
  /** 插件提供的 `directory@1`;未加载或不提供时 undefined。 */
139
142
  private provider;
140
143
  /**
141
- * The org exists, the extension provides a directory, is enabled in the org, its org config
142
- * satisfies the schema (reuses the `OrgExtensionConfigs.get` validation) and its effective
143
- * deployment config for the org is valid (layering spec A §6).
144
+ * The org exists, the extension provides a directory and is enabled in the org, and its effective
145
+ * deployment config for the org (the platform's, or this org's copy of the overridable fields;
146
+ * never another org's) is valid (layering spec A §6).
144
147
  */
145
148
  private eligible;
146
149
  /**
@@ -153,7 +156,7 @@ export declare class DirectorySync {
153
156
  /**
154
157
  * Manual trigger by an admin: re-checks `org.members.manage` live under the org row lock, then that
155
158
  * the extension can sync (does not provide a directory -> `extension.not_found`, not enabled ->
156
- * `extension.not_enabled`, config no longer valid -> `extension.config_invalid`, the extension says
159
+ * `extension.not_enabled`, its state cannot be read -> `extension.config_invalid`, the extension says
157
160
  * the directory is not configured -> `directory.not_configured`, Ruling A28; the effective config
158
161
  * is not valid in the org -> `extension.needs_config`, layering spec A §6), and enqueues a sync
159
162
  * job with a unique id.
@@ -89,8 +89,11 @@ class OrgGone extends Error {
89
89
  /**
90
90
  * 通讯录同步(`directory@1`):把企业通讯录同步为组织成员。框架无关。
91
91
  *
92
- * - 维护队列每小时 `directory-scan`:给每个「插件提供 `directory@1`、在该组织启用、组织级配置满足 schema」的
93
- * (组织, 插件) 投递一次同步(job id 按小时桶去重,多副本重复扫描只跑一次);手动与 `directory_changed` 也投递同步。
92
+ * - The maintenance queue's hourly `directory-scan` enqueues one sync per (org, extension) whose
93
+ * extension provides `directory@1`, is enabled in the org and has a valid effective config there
94
+ * (job ids deduplicated by hour bucket, so repeated scans on several replicas run once); manual
95
+ * triggers and `directory_changed` enqueue syncs too. Each call gets the org's own effective
96
+ * config (its copy of the overridable fields, or the platform's), never another org's.
94
97
  * - One sync at a time per (org, extension): the `LockService` lock
95
98
  * `lock:directory-sync:<org>:<plugin>`, renewed while held. A sync that finds the lock taken sets
96
99
  * the dirty flag `capk:directory-sync-dirty:<org>:<plugin>` (1 hour) and ends; after releasing
@@ -165,9 +168,9 @@ let DirectorySync = class DirectorySync {
165
168
  .find((e) => e.plugin === plugin && e.capability === DIRECTORY_EXTENSION_POINT)?.impl;
166
169
  }
167
170
  /**
168
- * The org exists, the extension provides a directory, is enabled in the org, its org config
169
- * satisfies the schema (reuses the `OrgExtensionConfigs.get` validation) and its effective
170
- * deployment config for the org is valid (layering spec A §6).
171
+ * The org exists, the extension provides a directory and is enabled in the org, and its effective
172
+ * deployment config for the org (the platform's, or this org's copy of the overridable fields;
173
+ * never another org's) is valid (layering spec A §6).
171
174
  */
172
175
  async eligible(orgId, plugin) {
173
176
  const directory = this.provider(plugin);
@@ -186,7 +189,7 @@ let DirectorySync = class DirectorySync {
186
189
  cfg = await this.orgConfigs.get(orgId, plugin);
187
190
  }
188
191
  catch (err) {
189
- this.log.warn("directory sync: stored organization config is invalid", {
192
+ this.log.warn("directory sync: cannot read whether the extension is enabled", {
190
193
  orgId,
191
194
  plugin,
192
195
  err,
@@ -209,7 +212,7 @@ let DirectorySync = class DirectorySync {
209
212
  if (directory.configured !== undefined) {
210
213
  let configured = false;
211
214
  try {
212
- configured = directory.configured(cfg.config, effective.config) === true;
215
+ configured = directory.configured(effective.config) === true;
213
216
  }
214
217
  catch {
215
218
  configured = false;
@@ -217,7 +220,7 @@ let DirectorySync = class DirectorySync {
217
220
  if (!configured)
218
221
  return { ok: false, reason: "not_configured" };
219
222
  }
220
- return { ok: true, directory, orgConfig: cfg.config, config: effective.config };
223
+ return { ok: true, directory, config: effective.config };
221
224
  }
222
225
  /**
223
226
  * 投递一次 `directory_changed` 同步(按分钟桶去重);返回 job id。入站 `directory_changed` 经
@@ -252,7 +255,7 @@ let DirectorySync = class DirectorySync {
252
255
  /**
253
256
  * Manual trigger by an admin: re-checks `org.members.manage` live under the org row lock, then that
254
257
  * the extension can sync (does not provide a directory -> `extension.not_found`, not enabled ->
255
- * `extension.not_enabled`, config no longer valid -> `extension.config_invalid`, the extension says
258
+ * `extension.not_enabled`, its state cannot be read -> `extension.config_invalid`, the extension says
256
259
  * the directory is not configured -> `directory.not_configured`, Ruling A28; the effective config
257
260
  * is not valid in the org -> `extension.needs_config`, layering spec A §6), and enqueues a sync
258
261
  * job with a unique id.
@@ -346,7 +349,7 @@ let DirectorySync = class DirectorySync {
346
349
  // 锁丢了(续租失败、过期后被他人取得):停止本轮,不再移除任何人
347
350
  const signal = lease.lost;
348
351
  try {
349
- return await this.run(orgId, plugin, e.directory, e.orgConfig, e.config, signal, opts);
352
+ return await this.run(orgId, plugin, e.directory, e.config, signal, opts);
350
353
  }
351
354
  finally {
352
355
  await lease.release().catch(() => { });
@@ -368,7 +371,7 @@ let DirectorySync = class DirectorySync {
368
371
  this.log.warn("directory sync: cannot enqueue follow-up sync", { orgId, plugin, err });
369
372
  }
370
373
  }
371
- async run(orgId, plugin, directory, orgConfig, config, signal, opts) {
374
+ async run(orgId, plugin, directory, config, signal, opts) {
372
375
  const source = `directory:${plugin}`;
373
376
  const counts = { added: 0, removed: 0, skippedLastOwner: 0, failed: 0, total: 0 };
374
377
  /** 本轮仍在职的账号(只在本次任务内使用)。 */
@@ -384,8 +387,8 @@ let DirectorySync = class DirectorySync {
384
387
  }
385
388
  signal.throwIfAborted();
386
389
  const r = await directory.listMembers({
387
- orgConfig,
388
390
  config,
391
+ orgId,
389
392
  ...(cursor !== undefined && { cursor }),
390
393
  signal: AbortSignal.any([signal, AbortSignal.timeout(DIRECTORY_PAGE_TIMEOUT_MS)]),
391
394
  });
@@ -142,6 +142,7 @@ let InvitationsService = class InvitationsService {
142
142
  .updateTable("invitations")
143
143
  .set({ revoked_at: sql `now()` })
144
144
  .where("id", "=", id)
145
+ .where("org_id", "=", orgId)
145
146
  .execute();
146
147
  await audit(this.db.db, {
147
148
  actorAccountId,
@@ -186,6 +187,7 @@ let InvitationsService = class InvitationsService {
186
187
  .updateTable("invitations")
187
188
  .set({ accepted_at: sql `now()`, accepted_by: account.id })
188
189
  .where("id", "=", inv.id)
190
+ .where("org_id", "=", inv.org_id)
189
191
  .where("accepted_at", "is", null)
190
192
  .where("revoked_at", "is", null)
191
193
  .where(sql `expires_at > now()`)
@@ -21,6 +21,8 @@ import { OrgLock } from "./org-lock.js";
21
21
  * 账号是不是某个组织的匿名访客(`org_anonymous_accounts`)。匿名访客没有登录方式,只能以 guest 身份
22
22
  * 代表 IM 里未绑定的人:不能被授予别的角色、成为 owner、指派为 agent 负责人、加入别的组织或被移出。
23
23
  */
24
+ // org-filter: an anonymous guest account is one org's guest and can join no other org, so the
25
+ // question "is this account any org's anonymous guest" is account-wide by design
24
26
  export async function isAnonymousGuest(db, accountId) {
25
27
  const row = await db
26
28
  .selectFrom("org_anonymous_accounts")
@@ -199,6 +199,7 @@ let Offboarding = class Offboarding {
199
199
  .returning("id")
200
200
  .execute()
201
201
  : [];
202
+ // org-filter: removal revokes the person's personal tokens account-wide on purpose (comment above)
202
203
  const tokens = revoke
203
204
  ? await this.db
204
205
  .updateTable("api_tokens")
@@ -301,6 +302,7 @@ let Offboarding = class Offboarding {
301
302
  .updateTable("conversations")
302
303
  .set({ queue_paused: false, queue_pause_reason: null })
303
304
  .where("id", "in", queueConversations)
305
+ .where("org_id", "=", orgId)
304
306
  .execute();
305
307
  }
306
308
  const devices = await this.db
@@ -4,7 +4,7 @@ import { type LookupFn, type NetPolicy } from "../net/public-address.js";
4
4
  * the config (trusted), but whatever it returns is external input:
5
5
  * - every request goes through `packages/kernel/src/net` ({@link safeFetch}) under `cfg.net`
6
6
  * (the kernel passes `marketplaceNetPolicy`: the registry's origin is trusted, any other host
7
- * must resolve to public addresses unless `marketplaces.allowPrivateHosts` exempts it, https
7
+ * must resolve to public addresses unless `net.allowPrivateHosts` exempts it, https
8
8
  * tunnels through `net.httpsProxy`, and the connection is pinned to the checked address);
9
9
  * - redirects are never followed (a 3xx fails): one registry redirect could otherwise send the
10
10
  * download (and the token) anywhere;
@@ -16,10 +16,18 @@ import { type LookupFn, type NetPolicy } from "../net/public-address.js";
16
16
  * under `net.allowInsecureLoopback`), needs `expectedIntegrity`, and never gets the registry
17
17
  * token unless it is on the registry's origin.
18
18
  */
19
- /** 下载或校验失败(HTTP 层映射为 `packages.npm_failed`,502)。消息为英文,不含令牌。 */
19
+ /**
20
+ * A download or verification failed (the HTTP layer maps it to `packages.npm_failed`, 502). The
21
+ * message is English and never carries the token. `transient`: the failure may go away on its own
22
+ * (a network error such as a reset, a DNS failure, a timeout, HTTP 408 / 429 / 5xx, a body cut off
23
+ * while read), so a caller may retry; never set for a refused connection (nothing listens), a
24
+ * refusal by the network rules, another 4xx such as 404, bad metadata or a mismatch.
25
+ */
20
26
  export declare class NpmFetchError extends Error {
27
+ readonly transient: boolean;
21
28
  constructor(message: string, options?: {
22
29
  cause?: unknown;
30
+ transient?: boolean;
23
31
  });
24
32
  }
25
33
  /** 下载内容与期望的 integrity 不符(`expected` / `actual` 为 `sha512-<base64>`)。 */
@@ -8,7 +8,7 @@ import { safeFetch } from "../net/safe-fetch.js";
8
8
  * the config (trusted), but whatever it returns is external input:
9
9
  * - every request goes through `packages/kernel/src/net` ({@link safeFetch}) under `cfg.net`
10
10
  * (the kernel passes `marketplaceNetPolicy`: the registry's origin is trusted, any other host
11
- * must resolve to public addresses unless `marketplaces.allowPrivateHosts` exempts it, https
11
+ * must resolve to public addresses unless `net.allowPrivateHosts` exempts it, https
12
12
  * tunnels through `net.httpsProxy`, and the connection is pinned to the checked address);
13
13
  * - redirects are never followed (a 3xx fails): one registry redirect could otherwise send the
14
14
  * download (and the token) anywhere;
@@ -20,11 +20,19 @@ import { safeFetch } from "../net/safe-fetch.js";
20
20
  * under `net.allowInsecureLoopback`), needs `expectedIntegrity`, and never gets the registry
21
21
  * token unless it is on the registry's origin.
22
22
  */
23
- /** 下载或校验失败(HTTP 层映射为 `packages.npm_failed`,502)。消息为英文,不含令牌。 */
23
+ /**
24
+ * A download or verification failed (the HTTP layer maps it to `packages.npm_failed`, 502). The
25
+ * message is English and never carries the token. `transient`: the failure may go away on its own
26
+ * (a network error such as a reset, a DNS failure, a timeout, HTTP 408 / 429 / 5xx, a body cut off
27
+ * while read), so a caller may retry; never set for a refused connection (nothing listens), a
28
+ * refusal by the network rules, another 4xx such as 404, bad metadata or a mismatch.
29
+ */
24
30
  export class NpmFetchError extends Error {
31
+ transient;
25
32
  constructor(message, options) {
26
33
  super(message, options);
27
34
  this.name = "NpmFetchError";
35
+ this.transient = options?.transient === true;
28
36
  }
29
37
  }
30
38
  /** 下载内容与期望的 integrity 不符(`expected` / `actual` 为 `sha512-<base64>`)。 */
@@ -100,14 +108,38 @@ export async function npmGet(cfg, url, headers, signal, what) {
100
108
  if (e instanceof NetDeniedError && e.code === "net.redirect") {
101
109
  throw new NpmFetchError(`the ${what} responded with a redirect (${e.status}); redirects are not followed`, { cause: e });
102
110
  }
103
- throw new NpmFetchError(`cannot fetch the ${what}: ${errMsg(e)}`, { cause: e });
111
+ // A refusal by the network rules stays a refusal (a DNS failure may be a passing one), and so
112
+ // does a refused connection: nothing listens there, a wrong URL or a registry that is down
113
+ const transient = e instanceof NetDeniedError ? e.code === "net.dns_failed" : !hasErrorCode(e, "ECONNREFUSED");
114
+ throw new NpmFetchError(`cannot fetch the ${what}: ${errMsg(e)}`, { cause: e, transient });
104
115
  }
105
116
  if (!res.ok) {
106
117
  await res.body?.cancel().catch(() => { });
107
- throw new NpmFetchError(`the ${what} responded with HTTP ${res.status}`);
118
+ const transient = res.status === 408 || res.status === 429 || res.status >= 500;
119
+ throw new NpmFetchError(`the ${what} responded with HTTP ${res.status}`, { transient });
108
120
  }
109
121
  return res;
110
122
  }
123
+ /** Whether `e`, its `cause` chain or an `AggregateError`'s errors carry the system error `code`. */
124
+ function hasErrorCode(e, code, depth = 0) {
125
+ if (depth > 8 || typeof e !== "object" || e === null)
126
+ return false;
127
+ if (e.code === code)
128
+ return true;
129
+ const errors = e instanceof AggregateError ? e.errors : [];
130
+ return [e.cause, ...errors].some((x) => hasErrorCode(x, code, depth + 1));
131
+ }
132
+ /** {@link readCapped}, with a body cut off while read as a transient {@link NpmFetchError}. */
133
+ async function readBody(res, max, onTooLarge, what) {
134
+ try {
135
+ return await readCapped(res, max, onTooLarge);
136
+ }
137
+ catch (e) {
138
+ if (e instanceof NpmFetchError || e instanceof PackageTooLargeError)
139
+ throw e;
140
+ throw new NpmFetchError(`cannot read the ${what}: ${errMsg(e)}`, { cause: e, transient: true });
141
+ }
142
+ }
111
143
  /** `sha512-<base64>` 形式的 SRI;可能有空格分隔的多个,取其中的 sha512。 */
112
144
  function sha512Of(integrity) {
113
145
  for (const part of integrity.trim().split(/\s+/)) {
@@ -172,7 +204,7 @@ export async function fetchNpmPackage(cfg, name, version, signal, opts = {}) {
172
204
  // scope 包名里的 `/` 按 npm 客户端的写法编码为 %2f
173
205
  const docUrl = new URL(name.replace("/", "%2f"), registry);
174
206
  const res = await npmGet(cfg, docUrl, { ...authHeaders, accept: "application/json" }, signal, "npm registry");
175
- const raw = await readCapped(res, MAX_METADATA_BYTES, () => new NpmFetchError("the npm package metadata is too large"));
207
+ const raw = await readBody(res, MAX_METADATA_BYTES, () => new NpmFetchError("the npm package metadata is too large"), "npm package metadata");
176
208
  let doc;
177
209
  try {
178
210
  doc = JSON.parse(raw.toString("utf8"));
@@ -219,7 +251,7 @@ export async function fetchNpmPackage(cfg, name, version, signal, opts = {}) {
219
251
  resolved = picked;
220
252
  }
221
253
  const res = await npmGet(cfg, tarball, tarballHeaders, signal, "package tarball");
222
- const bytes = await readCapped(res, cfg.maxBytes, tooLarge);
254
+ const bytes = await readBody(res, cfg.maxBytes, tooLarge, "package tarball");
223
255
  verify(bytes, integrity, opts.expectedIntegrity !== undefined ? "the expected integrity" : "the npm dist.integrity");
224
256
  return {
225
257
  bytes: new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength),
@@ -118,6 +118,11 @@ export const PLATFORM_EXCLUSIONS = [
118
118
  category: "transport",
119
119
  reason: "Serves icon image bytes",
120
120
  },
121
+ {
122
+ route: "GET /api/v1/admin/catalog/connector-templates/:templateId/icon",
123
+ category: "transport",
124
+ reason: "Serves icon image bytes",
125
+ },
121
126
  {
122
127
  route: "GET /api/v1/admin/catalog/:itemId/guides/:guideId",
123
128
  category: "internal",
@@ -151,6 +156,16 @@ export const PLATFORM_EXCLUSIONS = [
151
156
  category: "transport",
152
157
  reason: "Serves icon image bytes",
153
158
  },
159
+ {
160
+ route: "GET /api/v1/orgs/:orgId/connector-templates/:templateId/icon",
161
+ category: "transport",
162
+ reason: "Serves icon image bytes",
163
+ },
164
+ {
165
+ route: "GET /api/v1/orgs/:orgId/connectors/:connectorId/icon",
166
+ category: "transport",
167
+ reason: "Serves icon image bytes",
168
+ },
154
169
  {
155
170
  route: "POST /api/v1/orgs/:orgId/catalog-requests/network",
156
171
  category: "human-only",
@@ -497,6 +512,11 @@ export const PLATFORM_EXCLUSIONS = [
497
512
  { route: "GET /readyz", category: "transport", reason: "Readiness probe for the orchestrator" },
498
513
  // models
499
514
  // orgs
515
+ {
516
+ route: "PUT /api/v1/orgs/:orgId/extensions/:extension",
517
+ category: "internal",
518
+ reason: "The web's switch of an extension. For an extension shipped in one catalog plugin it is that plugin's switch, which plugins.set-enabled covers through the catalog switch route (with its uninstall preview). A direct-path extension (config-declared, or sourced from several catalog items) has no operation: an agent cannot switch it, a known gap (a required bootstrap plugin is on everywhere and has no switch); the org's config of any extension is its copy of the overridable fields (extensions.save-org-config)",
519
+ },
500
520
  {
501
521
  route: "POST /api/v1/orgs/:orgId/extensions/:extension/directory/sync",
502
522
  category: "human-only",
@@ -127,6 +127,7 @@ let AdminItemsOperations = class AdminItemsOperations {
127
127
  .selectFrom("conversations")
128
128
  .select("agent_id")
129
129
  .where("id", "=", rootId)
130
+ .where("org_id", "=", ctx.orgId)
130
131
  .executeTakeFirst();
131
132
  if (i.agentId === ctx.agentId || i.agentId === root?.agent_id) {
132
133
  return {
@@ -609,6 +609,7 @@ let AgentsOperations = class AgentsOperations {
609
609
  .selectFrom("conversations")
610
610
  .select("agent_id")
611
611
  .where("id", "=", rootId)
612
+ .where("org_id", "=", ctx.orgId)
612
613
  .executeTakeFirst();
613
614
  if (i.agentId === ctx.agentId || i.agentId === root?.agent_id) {
614
615
  return {
@@ -116,6 +116,7 @@ const summary = (c) => ({
116
116
  },
117
117
  status: c.status,
118
118
  platformTemplateId: c.platformTemplateId,
119
+ description: c.description,
119
120
  updatedAt: c.updatedAt,
120
121
  });
121
122
  /** A connector's detail: its tools (name, description, state, default policy) and your credential state. */
@@ -483,7 +484,7 @@ let ConnectorsOperations = class ConnectorsOperations {
483
484
  }),
484
485
  defineOperation({
485
486
  id: "connectors.update",
486
- description: "Edit a connector (org admins): rename it, switch it off or on (status), or use an org-credential connector that declares git hosts for git in sandboxes (useForGit; pushes are then the bot's). Its endpoint and credential are not edited here (credentials: connectors.set-org-credential); per-tool state and default policies stay on the connector's web page.",
487
+ description: "Edit a connector (org admins): rename it, set or clear its own description (description; null clears it), switch it off or on (status), or use an org-credential connector that declares git hosts for git in sandboxes (useForGit; pushes are then the bot's). Its endpoint and credential are not edited here (credentials: connectors.set-org-credential); per-tool state and default policies stay on the connector's web page.",
487
488
  input: UpdateInput,
488
489
  example: { connectorId: EXAMPLE_ID, name: "Docs (staging)" },
489
490
  authz: { orgAction: "connectors.manage" },
@@ -511,6 +512,11 @@ let ConnectorsOperations = class ConnectorsOperations {
511
512
  zh.push(i.status === "active" ? "启用" : "停用");
512
513
  en.push(i.status === "active" ? "switch it on" : "switch it off");
513
514
  }
515
+ if (i.description !== undefined) {
516
+ const text = i.description?.trim() ?? "";
517
+ zh.push(text === "" ? "清除说明" : `说明改为「${named(text)}」`);
518
+ en.push(text === "" ? "clear its description" : `set its description to "${named(text)}"`);
519
+ }
514
520
  if (i.useForGit !== undefined) {
515
521
  zh.push(i.useForGit ? "用于沙箱中的 git" : "不再用于沙箱中的 git");
516
522
  en.push(i.useForGit ? "use it for git in sandboxes" : "stop using it for git");
@@ -1,5 +1,4 @@
1
1
  import { type OnModuleInit } from "@nestjs/common";
2
- import { OrgExtensionSwitch } from "../../catalog/org-extension-switch.js";
3
2
  import { ExtensionDisplayNames } from "../../extensions/display-name.js";
4
3
  import { OrgExtensionConfigs } from "../../extensions/org-config.js";
5
4
  import { OrgOverrides, type OrgOverrideView } from "../../extensions/org-overrides.js";
@@ -9,16 +8,16 @@ import { OrgToolSwitches } from "../../tools/org-tool-switches.js";
9
8
  import { type PersonFieldTarget } from "../person-fields.js";
10
9
  import { PlatformOperations } from "../registry.js";
11
10
  /**
12
- * The person fields of the org's copy: the copy's own secrets (under overridable top-level fields),
13
- * set or not. A secret under a read-only field is not the org's to set: never asked, and a value
14
- * for it in `values` is refused as well.
11
+ * The person fields of the org's copy: the copy's own secrets (under the listed overridable
12
+ * top-level fields), set or not. A secret under any other field is not the org's to set: never
13
+ * asked, and a value for it in `values` is refused as well.
15
14
  */
16
15
  export declare function copyPersonFields(v: OrgOverrideView): Pick<PersonFieldTarget, "fields" | "recordOnly">;
17
16
  /**
18
17
  * Extension operations of the `Platform` tool (spec §7): the org's extensions (the member projection
19
18
  * of `GET /orgs/:orgId/extensions`, whatever the actor's role), their tool switches and point
20
- * defaults, and for org admins the org config and the org's copy of overridable platform fields
21
- * (read, write, take, save, drop; platform web parity spec §7.2). Secrets are never returned (only
19
+ * defaults, and for org admins the org's copy of overridable platform fields (read, take, save,
20
+ * drop; platform web parity spec §7.2). Secrets are never returned (only
22
21
  * whether each is set) and never taken as params: the person enters them in a secure input request.
23
22
  */
24
23
  export declare class ExtensionsOperations implements OnModuleInit {
@@ -29,8 +28,7 @@ export declare class ExtensionsOperations implements OnModuleInit {
29
28
  private readonly switches;
30
29
  private readonly pointDefaults;
31
30
  private readonly overrides;
32
- private readonly extSwitch;
33
- constructor(registry: PlatformOperations, configs: OrgExtensionConfigs, displayNames: ExtensionDisplayNames, kdb: KernelDb, switches: OrgToolSwitches, pointDefaults: ExtensionPointDefaults, overrides: OrgOverrides, extSwitch: OrgExtensionSwitch);
31
+ constructor(registry: PlatformOperations, configs: OrgExtensionConfigs, displayNames: ExtensionDisplayNames, kdb: KernelDb, switches: OrgToolSwitches, pointDefaults: ExtensionPointDefaults, overrides: OrgOverrides);
34
32
  /** The org view of one extension, or `extension.not_found` (not installed or not offered). */
35
33
  private viewOf;
36
34
  /** An extension's display name for a card (its plugin's), else the name, clipped. */