@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.
- package/bootstrap.json +6 -6
- package/dist/admin/outbox-dead.service.js +4 -1
- package/dist/agents/admin-agents.js +2 -0
- package/dist/agents/agent-lookup.js +4 -0
- package/dist/agents/agent-profile.service.js +3 -0
- package/dist/agents/agents.service.js +7 -0
- package/dist/agents/org-templates.js +1 -0
- package/dist/agents/pending-connector-requests.js +6 -0
- package/dist/agents/pending-connectors.service.js +2 -0
- package/dist/agents/readiness.service.d.ts +9 -3
- package/dist/agents/readiness.service.js +3 -3
- package/dist/agents/templates.js +1 -0
- package/dist/background/finish.js +3 -0
- package/dist/background/stop.js +2 -0
- package/dist/background/store.js +44 -0
- package/dist/background/tasks.service.js +3 -2
- package/dist/background/wake-rules.js +1 -0
- package/dist/catalog/admin-catalog.controller.d.ts +6 -0
- package/dist/catalog/admin-catalog.controller.js +13 -0
- package/dist/catalog/catalog-content.d.ts +9 -0
- package/dist/catalog/catalog-content.js +3 -1
- package/dist/catalog/catalog-items.js +4 -0
- package/dist/catalog/catalog-scope.service.js +4 -1
- package/dist/catalog/component-promotion.js +2 -0
- package/dist/catalog/component-scope.controller.d.ts +9 -15
- package/dist/catalog/component-scope.controller.js +14 -9
- package/dist/catalog/component-scope.service.js +5 -0
- package/dist/catalog/component-state.d.ts +4 -1
- package/dist/catalog/component-state.js +4 -2
- package/dist/catalog/marketplace-fetch.d.ts +1 -1
- package/dist/catalog/marketplace-fetch.js +1 -1
- package/dist/catalog/marketplaces.service.d.ts +6 -1
- package/dist/catalog/marketplaces.service.js +8 -3
- package/dist/catalog/org-catalog.controller.d.ts +9 -0
- package/dist/catalog/org-catalog.controller.js +18 -0
- package/dist/catalog/org-catalog.schemas.d.ts +2 -4
- package/dist/catalog/org-catalog.schemas.js +2 -3
- package/dist/catalog/org-catalog.service.d.ts +10 -1
- package/dist/catalog/org-catalog.service.js +34 -23
- package/dist/catalog/org-extension-switch.d.ts +3 -10
- package/dist/catalog/org-extension-switch.js +14 -60
- package/dist/catalog/org-extension.controller.d.ts +6 -7
- package/dist/catalog/org-extension.controller.js +4 -4
- package/dist/catalog/org-extension.schemas.d.ts +1 -2
- package/dist/catalog/org-extension.schemas.js +1 -3
- package/dist/catalog/owned-items.js +10 -1
- package/dist/catalog/ownership.js +2 -0
- package/dist/catalog/plugin-import.d.ts +3 -0
- package/dist/catalog/plugin-import.js +10 -1
- package/dist/catalog/plugin-install.d.ts +1 -4
- package/dist/catalog/plugin-install.js +11 -12
- package/dist/catalog/plugin-upgrade.js +4 -1
- package/dist/catalog/request-rules.js +6 -0
- package/dist/catalog/requests.service.js +4 -0
- package/dist/catalog/scope-orgs.js +1 -0
- package/dist/catalog/scope-sync.d.ts +8 -5
- package/dist/catalog/scope-sync.js +21 -23
- package/dist/catalog/template-description.d.ts +17 -0
- package/dist/catalog/template-description.js +18 -0
- package/dist/catalog/unshare.js +3 -0
- package/dist/channels/connections.service.js +1 -0
- package/dist/channels/inbound.js +1 -0
- package/dist/channels/jobs.js +1 -0
- package/dist/channels/outbound.js +6 -0
- package/dist/channels/supervisor.js +1 -0
- package/dist/channels/threads.js +1 -0
- package/dist/client/client-reports.service.js +1 -0
- package/dist/config/fields.js +20 -4
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +13 -13
- package/dist/conversations/access.js +1 -0
- package/dist/conversations/attachments.service.js +16 -4
- package/dist/conversations/conversations.service.js +17 -3
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +3 -1
- package/dist/conversations/files.js +3 -2
- package/dist/conversations/permission-profiles.service.js +1 -0
- package/dist/conversations/prompt-suggestions.js +2 -0
- package/dist/conversations/queue.js +8 -0
- package/dist/conversations/queue.service.js +6 -2
- package/dist/conversations/source.js +2 -0
- package/dist/conversations/titles.js +10 -2
- package/dist/conversations/tree.js +6 -0
- package/dist/db/kernel-schema.d.ts +5 -1
- package/dist/devices/conversation-devices.js +3 -0
- package/dist/devices/device-projects.service.js +2 -0
- package/dist/devices/devices.service.js +5 -0
- package/dist/devices/legacy-cleanup.job.js +5 -2
- package/dist/dial-in/handlers.js +2 -0
- package/dist/dial-in/machines.js +11 -2
- package/dist/dial-in/targets.d.ts +0 -2
- package/dist/dial-in/targets.js +0 -10
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/evals/budget.js +14 -1
- package/dist/evals/run-replay.js +4 -0
- package/dist/evals/runs.service.js +13 -7
- package/dist/evals/sets.service.js +23 -8
- package/dist/evals/trajectory.service.d.ts +1 -1
- package/dist/evals/trajectory.service.js +1 -0
- package/dist/evals/worker.js +5 -1
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +3 -1
- package/dist/extensions/bootstrap-packages.d.ts +12 -1
- package/dist/extensions/bootstrap-packages.js +49 -9
- package/dist/extensions/bootstrap.d.ts +17 -2
- package/dist/extensions/bootstrap.js +41 -9
- package/dist/extensions/config-json-schema.d.ts +2 -2
- package/dist/extensions/config-json-schema.js +1 -3
- package/dist/extensions/deployment-config.d.ts +5 -3
- package/dist/extensions/deployment-config.js +3 -3
- package/dist/extensions/effective-config.d.ts +8 -7
- package/dist/extensions/effective-config.js +8 -7
- package/dist/extensions/enabled.js +1 -0
- package/dist/extensions/host.d.ts +4 -3
- package/dist/extensions/host.js +11 -12
- package/dist/extensions/instance.d.ts +1 -1
- package/dist/extensions/instance.js +17 -2
- package/dist/extensions/org-config.d.ts +35 -97
- package/dist/extensions/org-config.js +48 -315
- package/dist/extensions/org-levels.d.ts +22 -9
- package/dist/extensions/org-levels.js +100 -20
- package/dist/extensions/org-overrides.d.ts +14 -15
- package/dist/extensions/org-overrides.js +20 -20
- package/dist/extensions/package.js +1 -1
- package/dist/extensions/permission-set.d.ts +1 -3
- package/dist/extensions/permission-set.js +3 -7
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +5 -4
- package/dist/extensions/plugin-icons.d.ts +80 -1
- package/dist/extensions/plugin-icons.js +211 -2
- package/dist/extensions/point-defaults.d.ts +17 -18
- package/dist/extensions/point-defaults.js +25 -28
- package/dist/git/gateway.js +1 -1
- package/dist/git/identity.d.ts +1 -1
- package/dist/git/identity.js +2 -2
- package/dist/identity/accounts.js +6 -0
- package/dist/identity/api-tokens.js +8 -0
- package/dist/infra/outbox/outbox.dispatcher.js +4 -1
- package/dist/infra/outbox/outbox.service.js +2 -0
- package/dist/net/public-address.d.ts +3 -3
- package/dist/net/public-address.js +3 -3
- package/dist/orgs/directory-sync.d.ts +9 -6
- package/dist/orgs/directory-sync.js +15 -12
- package/dist/orgs/invitations.service.js +2 -0
- package/dist/orgs/members.service.js +2 -0
- package/dist/orgs/offboarding.js +2 -0
- package/dist/packages/npm.d.ts +10 -2
- package/dist/packages/npm.js +38 -6
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin-items.ops.js +1 -0
- package/dist/platform/ops/agents.ops.js +1 -0
- package/dist/platform/ops/connectors.ops.js +7 -1
- package/dist/platform/ops/extensions.ops.d.ts +6 -8
- package/dist/platform/ops/extensions.ops.js +18 -97
- package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
- package/dist/platform/ops/org-plugins.ops.js +14 -65
- package/dist/platform/ops/outbox.ops.js +1 -0
- package/dist/platform/ops/person-inputs.d.ts +0 -4
- package/dist/platform/ops/person-inputs.js +0 -8
- package/dist/platform/ops/plugins.ops.d.ts +4 -1
- package/dist/platform/ops/plugins.ops.js +27 -34
- package/dist/platform/person-fields.d.ts +1 -1
- package/dist/platform/person-fields.js +1 -1
- package/dist/platform/sealed-reveals.js +2 -0
- package/dist/push/recipients.js +9 -2
- package/dist/runtime/permission-context.service.js +1 -0
- package/dist/runtime/plugin-context.service.js +1 -0
- package/dist/runtime/project/knowledge.service.js +1 -0
- package/dist/runtime/run-context.service.js +1 -0
- package/dist/runtime/run-deletion.js +4 -0
- package/dist/runtime/run-execution.js +2 -0
- package/dist/runtime/run-finish.js +3 -0
- package/dist/runtime/run-jobs.js +3 -0
- package/dist/runtime/run-orphan-check.job.js +7 -0
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +5 -0
- package/dist/runtime/step-log.js +1 -0
- package/dist/runtime/subagents/child.js +2 -0
- package/dist/runtime/subagents/deliveries.js +3 -0
- package/dist/runtime/subagents/dispatch.js +5 -1
- package/dist/runtime/subagents/messages.js +2 -0
- package/dist/runtime/subagents/org-agents.d.ts +1 -1
- package/dist/runtime/subagents/org-agents.js +2 -1
- package/dist/runtime/usage-report-jobs.js +1 -0
- package/dist/runtime/usage-report.js +3 -0
- package/dist/runtime/waits.js +5 -0
- package/dist/sandbox/cloud-permission-snapshot.js +9 -3
- package/dist/sandbox/device-reports.js +3 -0
- package/dist/sandbox/legacy-retirement.js +5 -1
- package/dist/sandbox/managed-device-context.js +1 -0
- package/dist/sandbox/modes.d.ts +5 -2
- package/dist/sandbox/modes.js +8 -4
- package/dist/sandbox/network-grants.js +2 -0
- package/dist/sandbox/operation-intents.js +58 -0
- package/dist/sandbox/operation-reconcile.job.js +2 -0
- package/dist/sandbox/permission-authority-lock.js +12 -6
- package/dist/sandbox/permission-call-grants.js +6 -0
- package/dist/sandbox/permission-ceiling-writes.js +5 -0
- package/dist/sandbox/permission-config-publication.js +5 -0
- package/dist/sandbox/permission-instance-writes.js +4 -0
- package/dist/sandbox/permission-runtime-reports.js +10 -1
- package/dist/sandbox/permission-transitions.js +3 -0
- package/dist/sandbox/review/review.service.js +8 -5
- package/dist/sandbox/sandbox.service.d.ts +14 -0
- package/dist/sandbox/sandbox.service.js +195 -29
- package/dist/sandbox/unreachable.js +4 -1
- package/dist/schedules/fire.js +9 -3
- package/dist/schedules/pause.js +2 -0
- package/dist/schedules/run-tracker.js +16 -1
- package/dist/schedules/scheduled-tasks.service.js +4 -2
- package/dist/schedules/store.js +8 -0
- package/dist/schedules/unattended.js +4 -0
- package/dist/setup/setup-checks.service.d.ts +1 -10
- package/dist/setup/setup-checks.service.js +19 -29
- package/dist/shares/share-open.service.js +1 -0
- package/dist/shares/shares.service.js +2 -0
- package/dist/skills/agent-skills.service.d.ts +1 -1
- package/dist/skills/agent-skills.service.js +13 -2
- package/dist/skills/catalog.js +3 -0
- package/dist/skills/changes.service.js +10 -2
- package/dist/skills/conversation-catalog.js +1 -0
- package/dist/skills/skills.service.js +4 -0
- package/dist/tools/approvals.service.js +40 -0
- package/dist/tools/builtins/schedules.js +11 -6
- package/dist/tools/builtins/web/fetch.js +1 -1
- package/dist/tools/builtins/web/search.js +1 -1
- package/dist/tools/connector-account-policies.js +3 -0
- package/dist/tools/connectors.controller.d.ts +37 -9
- package/dist/tools/connectors.controller.js +47 -12
- package/dist/tools/connectors.schemas.d.ts +4 -0
- package/dist/tools/connectors.schemas.js +13 -1
- package/dist/tools/connectors.service.d.ts +17 -0
- package/dist/tools/connectors.service.js +36 -2
- package/dist/tools/drift.js +5 -0
- package/dist/tools/git-push-policy.js +3 -0
- package/dist/tools/oauth/discovery.d.ts +2 -2
- package/dist/tools/oauth/discovery.js +2 -2
- package/dist/tools/oauth/flow.js +1 -0
- package/dist/tools/outputs.js +2 -0
- package/dist/tools/permission-approval-jobs.js +3 -0
- package/dist/tools/pipeline.js +2 -0
- package/dist/tools/policy.js +3 -0
- package/dist/tools/questions.service.js +13 -0
- package/package.json +3 -3
- 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 `
|
|
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 `
|
|
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
|
|
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
|
-
* -
|
|
93
|
-
*
|
|
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
|
|
142
|
-
*
|
|
143
|
-
*
|
|
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`,
|
|
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
|
-
* -
|
|
93
|
-
*
|
|
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
|
|
169
|
-
*
|
|
170
|
-
*
|
|
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:
|
|
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(
|
|
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,
|
|
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`,
|
|
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.
|
|
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,
|
|
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")
|
package/dist/orgs/offboarding.js
CHANGED
|
@@ -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
|
package/dist/packages/npm.d.ts
CHANGED
|
@@ -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 `
|
|
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
|
-
/**
|
|
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>`)。 */
|
package/dist/packages/npm.js
CHANGED
|
@@ -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 `
|
|
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
|
-
/**
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
13
|
-
* set or not. A secret under
|
|
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
|
|
21
|
-
*
|
|
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
|
-
|
|
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. */
|