@capybara-hq/kernel 0.1.0-rc.121 → 0.1.0-rc.122
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/dist/background/finish.d.ts +5 -1
- package/dist/background/finish.js +29 -18
- package/dist/background/launch.d.ts +0 -5
- package/dist/background/launch.js +1 -6
- package/dist/background/managed.js +1 -4
- package/dist/background/poll.job.d.ts +3 -25
- package/dist/background/poll.job.js +20 -112
- package/dist/background/render.d.ts +2 -8
- package/dist/background/render.js +3 -17
- package/dist/background/stop.d.ts +15 -16
- package/dist/background/stop.js +39 -76
- package/dist/background/store.d.ts +17 -45
- package/dist/background/store.js +60 -94
- package/dist/background/tasks.service.d.ts +2 -5
- package/dist/background/tasks.service.js +9 -20
- package/dist/background/wake.js +3 -2
- package/dist/catalog/admin-catalog.controller.d.ts +2 -18
- package/dist/catalog/admin-catalog.controller.js +2 -28
- package/dist/catalog/catalog-content.d.ts +1 -5
- package/dist/catalog/catalog-items.d.ts +2 -6
- package/dist/catalog/catalog-items.js +5 -26
- package/dist/catalog/catalog-scope.service.d.ts +1 -121
- package/dist/catalog/catalog-scope.service.js +12 -552
- package/dist/catalog/catalog.service.d.ts +4 -15
- package/dist/catalog/catalog.service.js +7 -35
- package/dist/catalog/job-ids.d.ts +0 -18
- package/dist/catalog/job-ids.js +0 -20
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.js +6 -20
- package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -19
- package/dist/catalog/org-plugin-uploads.controller.js +6 -34
- package/dist/catalog/org-plugin-uploads.d.ts +3 -10
- package/dist/catalog/org-plugin-uploads.js +4 -18
- package/dist/catalog/org-plugin-uploads.schemas.js +0 -1
- package/dist/catalog/owned-items.d.ts +6 -11
- package/dist/catalog/owned-items.js +10 -20
- package/dist/catalog/ownership.d.ts +3 -29
- package/dist/catalog/ownership.js +4 -54
- package/dist/catalog/platform-components.d.ts +5 -11
- package/dist/catalog/platform-components.js +8 -15
- package/dist/catalog/plugin-import.d.ts +3 -42
- package/dist/catalog/plugin-import.js +26 -195
- package/dist/catalog/plugin-install.js +1 -6
- package/dist/catalog/plugin-package.d.ts +1 -0
- package/dist/catalog/plugin-package.js +5 -0
- package/dist/catalog/plugin-upgrade.d.ts +3 -26
- package/dist/catalog/plugin-upgrade.js +20 -103
- package/dist/catalog/request-rules.js +4 -6
- package/dist/catalog/scope-sync.js +2 -4
- package/dist/catalog/scope.d.ts +2 -5
- package/dist/channels/jobs.d.ts +3 -3
- package/dist/channels/jobs.js +4 -3
- package/dist/channels/outbound.d.ts +1 -0
- package/dist/channels/outbound.js +32 -8
- package/dist/config/load.d.ts +0 -25
- package/dist/config/load.js +0 -57
- package/dist/config/schema.js +2 -3
- package/dist/conversations/attachments.service.js +3 -5
- package/dist/conversations/conversations.service.d.ts +3 -3
- package/dist/conversations/conversations.service.js +3 -3
- package/dist/conversations/job-org.d.ts +3 -0
- package/dist/conversations/job-org.js +11 -0
- package/dist/conversations/prompt-suggestions.d.ts +2 -7
- package/dist/conversations/prompt-suggestions.js +29 -27
- package/dist/conversations/titles.d.ts +3 -4
- package/dist/conversations/titles.js +19 -30
- package/dist/db/kernel-schema.d.ts +6 -16
- package/dist/db/pool.js +7 -2
- package/dist/devices/devices.controller.d.ts +0 -5
- package/dist/devices/devices.controller.js +2 -20
- package/dist/devices/devices.service.d.ts +1 -17
- package/dist/devices/devices.service.js +0 -22
- package/dist/errors.d.ts +1 -5
- package/dist/errors.js +1 -5
- package/dist/evals/judge.d.ts +3 -0
- package/dist/evals/judge.js +1 -1
- package/dist/evals/run-replay.d.ts +1 -1
- package/dist/evals/run-replay.js +26 -29
- package/dist/evals/step-replay.d.ts +3 -1
- package/dist/evals/step-replay.js +10 -1
- package/dist/evals/worker.d.ts +3 -1
- package/dist/evals/worker.js +53 -21
- package/dist/extensions/deployment-config-store.js +18 -14
- package/dist/extensions/effective-config.d.ts +1 -5
- package/dist/extensions/effective-config.js +1 -5
- package/dist/extensions/hooks.d.ts +3 -1
- package/dist/extensions/hooks.js +7 -2
- package/dist/extensions/installs.d.ts +2 -14
- package/dist/extensions/installs.js +10 -32
- package/dist/extensions/org-config.d.ts +3 -4
- package/dist/extensions/org-config.js +3 -4
- package/dist/extensions/plugin-guides.d.ts +0 -1
- package/dist/extensions/plugin-guides.js +0 -1
- package/dist/extensions/plugin-icons.d.ts +0 -1
- package/dist/extensions/plugin-icons.js +0 -3
- package/dist/files/blob-sweep.job.d.ts +2 -11
- package/dist/files/blob-sweep.job.js +7 -21
- package/dist/files/hash-job.d.ts +5 -15
- package/dist/files/hash-job.js +14 -33
- package/dist/files/library-jobs.module.d.ts +1 -6
- package/dist/files/library-jobs.module.js +3 -9
- package/dist/identity/api-tokens.js +54 -40
- package/dist/identity/auth.guard.js +2 -2
- package/dist/identity/sessions.js +7 -3
- package/dist/identity/settings.js +5 -21
- package/dist/inbox/inbox.service.d.ts +2 -3
- package/dist/inbox/org-notices.d.ts +0 -14
- package/dist/inbox/platform-inbox.service.d.ts +1 -8
- package/dist/inbox/platform-inbox.service.js +2 -6
- package/dist/inbox/platform-notices.d.ts +3 -3
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -3
- package/dist/infra/database/database.module.js +2 -1
- package/dist/infra/database/org-scope.d.ts +5 -3
- package/dist/infra/database/org-scope.js +7 -1
- package/dist/infra/database/scoped-dialect.d.ts +3 -1
- package/dist/infra/database/scoped-dialect.js +17 -5
- package/dist/infra/events/kernel-events.d.ts +2 -0
- package/dist/infra/outbox/outbox.service.d.ts +2 -0
- package/dist/infra/outbox/outbox.service.js +10 -0
- package/dist/infra/outbox/registry.d.ts +0 -41
- package/dist/infra/outbox/registry.js +0 -37
- package/dist/models/embeddings.d.ts +0 -5
- package/dist/models/embeddings.js +28 -35
- package/dist/models/images.d.ts +3 -8
- package/dist/models/images.js +19 -37
- package/dist/models/purposes.d.ts +7 -2
- package/dist/models/purposes.js +16 -3
- package/dist/orgs/device-network-setting.d.ts +0 -44
- package/dist/orgs/device-network-setting.js +0 -83
- package/dist/orgs/invitations.service.js +34 -30
- package/dist/orgs/offboarding.d.ts +2 -2
- package/dist/orgs/offboarding.js +2 -2
- package/dist/orgs/orgs.service.d.ts +1 -1
- package/dist/orgs/orgs.service.js +19 -15
- package/dist/orgs/settings.service.d.ts +19 -14
- package/dist/orgs/settings.service.js +12 -37
- package/dist/platform/exclusions.js +0 -11
- package/dist/platform/ops/catalog-admin.ops.js +0 -8
- package/dist/platform/ops/devices.ops.js +0 -28
- package/dist/platform/ops/extensions-admin.ops.js +3 -3
- package/dist/platform/ops/inbox.ops.js +5 -22
- package/dist/platform/ops/org-plugins.ops.d.ts +1 -3
- package/dist/platform/ops/org-plugins.ops.js +11 -67
- package/dist/roles/worker.module.js +0 -9
- package/dist/runtime/hook-calls.d.ts +13 -6
- package/dist/runtime/hook-calls.js +26 -4
- package/dist/runtime/maintenance.d.ts +3 -12
- package/dist/runtime/maintenance.js +25 -55
- package/dist/runtime/model-call.d.ts +4 -2
- package/dist/runtime/model-call.js +59 -58
- package/dist/runtime/providers.d.ts +27 -1
- package/dist/runtime/providers.js +57 -0
- package/dist/runtime/run-jobs.d.ts +1 -1
- package/dist/runtime/run-processors.d.ts +3 -9
- package/dist/runtime/run-worker.d.ts +2 -0
- package/dist/runtime/run-worker.js +23 -8
- package/dist/runtime/subagents/deliveries.js +6 -1
- package/dist/runtime/subagents/dispatch.d.ts +3 -3
- package/dist/runtime/write-base.service.d.ts +2 -3
- package/dist/runtime/write-base.service.js +3 -5
- package/dist/sandbox/device-sandbox-settings.d.ts +38 -92
- package/dist/sandbox/device-sandbox-settings.js +19 -325
- package/dist/sandbox/jobs.d.ts +3 -14
- package/dist/sandbox/jobs.js +2 -20
- package/dist/sandbox/modes.d.ts +5 -45
- package/dist/sandbox/modes.js +3 -60
- package/dist/sandbox/operation-authority.js +0 -11
- package/dist/sandbox/operation-intents.d.ts +32 -9
- package/dist/sandbox/operation-intents.js +241 -32
- package/dist/sandbox/operation-intents.module.js +2 -1
- package/dist/sandbox/operation-reconcile.job.d.ts +9 -11
- package/dist/sandbox/operation-reconcile.job.js +119 -33
- package/dist/sandbox/operation-revoke.d.ts +20 -0
- package/dist/sandbox/operation-revoke.js +3 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +1 -2
- package/dist/sandbox/permission-ceiling-writes.js +3 -6
- package/dist/sandbox/permission-config-publication.d.ts +1 -28
- package/dist/sandbox/permission-config-publication.js +14 -211
- package/dist/sandbox/permission-facts.d.ts +4 -15
- package/dist/sandbox/permission-facts.js +7 -29
- package/dist/sandbox/permission-instance-writes.d.ts +1 -4
- package/dist/sandbox/permission-instance-writes.js +1 -55
- package/dist/sandbox/providers.d.ts +1 -6
- package/dist/sandbox/providers.js +1 -15
- package/dist/sandbox/review/classifier.js +12 -13
- package/dist/sandbox/sandbox.module.js +3 -6
- package/dist/sandbox/sandbox.service.d.ts +17 -123
- package/dist/sandbox/sandbox.service.js +239 -998
- package/dist/shares/liveness.d.ts +1 -2
- package/dist/shares/liveness.js +1 -2
- package/dist/shares/shares.module.d.ts +1 -2
- package/dist/shares/shares.module.js +2 -5
- package/dist/shares/shares.service.js +1 -2
- package/dist/tools/builtins/image/generate.js +7 -15
- package/dist/tools/builtins/sandbox/common.d.ts +0 -2
- package/dist/tools/builtins/sandbox/common.js +1 -27
- package/dist/tools/builtins/sandbox/task-list.js +10 -10
- package/dist/tools/builtins/sandbox/task-output.d.ts +3 -10
- package/dist/tools/builtins/sandbox/task-output.js +13 -83
- package/dist/tools/builtins/sandbox/task-stop.js +18 -22
- package/dist/tools/builtins/vision/read-image.js +9 -10
- package/dist/tools/builtins/web/extract.js +9 -10
- package/package.json +3 -3
- package/src/migrations/0206_retire_org_extension_uploads.sql +125 -0
- package/src/migrations/0207_confirm_device_instance_destruction.sql +25 -0
- package/src/migrations/0208_convert_stored_permission_settings.sql +189 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +0 -57
- package/dist/background/retire-legacy-tasks.job.js +0 -149
- package/dist/catalog/owned-plugin-cleanup.d.ts +0 -47
- package/dist/catalog/owned-plugin-cleanup.js +0 -140
- package/dist/config/permission-migration.d.ts +0 -34
- package/dist/config/permission-migration.js +0 -115
- package/dist/devices/legacy-cleanup.job.d.ts +0 -34
- package/dist/devices/legacy-cleanup.job.js +0 -147
- package/dist/files/library-backfill.d.ts +0 -63
- package/dist/files/library-backfill.js +0 -143
- package/dist/infra/cli/permission-cutover.d.ts +0 -59
- package/dist/infra/cli/permission-cutover.js +0 -107
- package/dist/sandbox/cloud-permission-snapshot.d.ts +0 -159
- package/dist/sandbox/cloud-permission-snapshot.js +0 -430
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +0 -8
- package/dist/sandbox/cloud-permission-snapshot.module.js +0 -34
- package/dist/sandbox/legacy-retirement.d.ts +0 -284
- package/dist/sandbox/legacy-retirement.js +0 -1165
- package/dist/sandbox/legacy-retirement.module.d.ts +0 -8
- package/dist/sandbox/legacy-retirement.module.js +0 -25
- package/dist/shares/share-objects.d.ts +0 -47
- package/dist/shares/share-objects.js +0 -93
|
@@ -24,7 +24,7 @@ import { PluginGuides } from "../extensions/plugin-guides.js";
|
|
|
24
24
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
25
25
|
import { audit } from "../identity/audit.js";
|
|
26
26
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
27
|
-
import {
|
|
27
|
+
import { notifySharedUpdate } from "../inbox/org-notices.js";
|
|
28
28
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
29
29
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
30
30
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -45,9 +45,10 @@ import { agentsUsing, clashingOrgSkills, clashingPlatformSkills, componentOn, co
|
|
|
45
45
|
import { credentialKey } from "./credential-key.js";
|
|
46
46
|
import { LIVE_INSTALL_STATUSES } from "./install-status.js";
|
|
47
47
|
import { CatalogItemLock } from "./locks.js";
|
|
48
|
-
import { isUsable
|
|
48
|
+
import { isUsable } from "./ownership.js";
|
|
49
49
|
import { PlanStale, PlatformComponents } from "./platform-components.js";
|
|
50
50
|
import { catalogSkillNames, PluginInstaller } from "./plugin-install.js";
|
|
51
|
+
import { assertDeclarativeUpload } from "./plugin-package.js";
|
|
51
52
|
import { wantedOn } from "./scope.js";
|
|
52
53
|
import { PluginScopeSync } from "./scope-sync.js";
|
|
53
54
|
import { oweTemplateConnectors } from "./template-connector-jobs.js";
|
|
@@ -56,10 +57,8 @@ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
|
|
56
57
|
const sha256 = (s) => createHash("sha256").update(s).digest("hex");
|
|
57
58
|
const itemNotFound = () => new ApiError("catalog.item_not_found", "Catalog item not found");
|
|
58
59
|
const stale = () => new ApiError("plugin.upgrade_stale", "The update preview is out of date (the catalog version, the platform components, a pin or a connector changed); preview the update again");
|
|
59
|
-
/** The pending version a super admin confirms was replaced by another upload (P3-11). */
|
|
60
|
-
const pendingStale = (name) => new ApiError("extension.approval_stale", `The pending upload of ${name} changed since it was reviewed; review it again`);
|
|
61
60
|
const targetInvalid = (message, details) => new ApiError("plugin.upgrade_target_invalid", message, details);
|
|
62
|
-
/** A version an org uploaded that was never applied
|
|
61
|
+
/** A version an org uploaded that was never applied (P3-37, P3-52). */
|
|
63
62
|
const notApplied = (name, version) => targetInvalid(`Version ${version} of plugin ${name} was uploaded by an organization and never applied or confirmed (or was rejected); the generic update cannot apply it`, [{ reason: "org_version_not_applied", version }]);
|
|
64
63
|
const KIND_ORDER = {
|
|
65
64
|
skill: 0,
|
|
@@ -291,7 +290,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
291
290
|
* re-checked under the org row lock in the transaction), then the platform update as
|
|
292
291
|
* {@link update} does, also removing the extension when the target drops it. In the update's
|
|
293
292
|
* transaction the orgs using the shared plugin are told (`shared_item_updated`, one notice per
|
|
294
|
-
* plugin)
|
|
293
|
+
* plugin).
|
|
295
294
|
*/
|
|
296
295
|
async updateAsOwner(orgId, actor, itemId, version, diffHash, opts = {}) {
|
|
297
296
|
if (!UUID_RE.test(itemId))
|
|
@@ -318,33 +317,9 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
318
317
|
await handle.release();
|
|
319
318
|
}
|
|
320
319
|
}
|
|
321
|
-
/**
|
|
322
|
-
* The super admin's confirmation of an org upload's pending new version (rulings P3-10, P3-21,
|
|
323
|
-
* pre-flight F8): the update to `version` as {@link update} does it (the super admin's, the
|
|
324
|
-
* extension installed or upgraded on the deployment), with the version allowed although it is
|
|
325
|
-
* pending. Its transaction re-reads the item under the row lock: removed meanwhile -> 409
|
|
326
|
-
* `catalog.item_removed`, the pending version replaced -> 409 `extension.approval_stale` (both
|
|
327
|
-
* undo the extension step); then the pending state is cleared and the owner told
|
|
328
|
-
* (`upload_confirmed`). The caller checked the digest of the version's package.
|
|
329
|
-
*/
|
|
330
|
-
async updateToPending(actor, itemId, version, opts = {}) {
|
|
331
|
-
if (!UUID_RE.test(itemId))
|
|
332
|
-
throw itemNotFound();
|
|
333
|
-
return this.locked(itemId, () => this.updateToPendingLocked(actor, itemId, version, opts));
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* {@link updateToPending} for a caller already holding the item's update lock
|
|
337
|
-
* ({@link withItemLock}): the super admin's confirmation runs all its steps under it (ruling
|
|
338
|
-
* P3-35).
|
|
339
|
-
*/
|
|
340
|
-
async updateToPendingLocked(actor, itemId, version, opts = {}) {
|
|
341
|
-
const d = await this.diff(itemId, version, { confirmPending: version });
|
|
342
|
-
return this.updateLocked(actor, itemId, { version, diffHash: d.diffHash }, opts, undefined, version);
|
|
343
|
-
}
|
|
344
320
|
/**
|
|
345
321
|
* Runs `f` holding the item's update lock (the one every platform update of the item takes;
|
|
346
|
-
* another holder -> 409 `plugin.install_in_progress`)
|
|
347
|
-
* upload runs every step under it (ruling P3-35).
|
|
322
|
+
* another holder -> 409 `plugin.install_in_progress`).
|
|
348
323
|
*/
|
|
349
324
|
withItemLock(itemId, f) {
|
|
350
325
|
if (!UUID_RE.test(itemId))
|
|
@@ -359,9 +334,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
359
334
|
return this.updateLocked(actor, itemId, input, opts);
|
|
360
335
|
}
|
|
361
336
|
/**
|
|
362
|
-
* Runs an update confirmed with the preview's `diffHash` (see the class comment).
|
|
363
|
-
* org upload waits with, or an item whose first version waits, -> 409 `catalog.item_pending`
|
|
364
|
-
* (confirmed in the admin console's pending confirmations instead, pre-flight F8). `actor`
|
|
337
|
+
* Runs an update confirmed with the preview's `diffHash` (see the class comment). `actor`
|
|
365
338
|
* null: the kernel itself (the bootstrap step raising a pinned plugin without an extension): no
|
|
366
339
|
* super admin is re-checked and the audits name no account.
|
|
367
340
|
*/
|
|
@@ -370,11 +343,10 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
370
343
|
throw itemNotFound();
|
|
371
344
|
return this.locked(itemId, () => this.updateLocked(actor, itemId, input, opts));
|
|
372
345
|
}
|
|
373
|
-
async updateLocked(actor, itemId, input, opts, owner
|
|
346
|
+
async updateLocked(actor, itemId, input, opts, owner) {
|
|
374
347
|
// Storage is read and written here, before any transaction (see the class comment)
|
|
375
348
|
const checked = await this.diff(itemId, input.version, {
|
|
376
349
|
...(owner && { owner }),
|
|
377
|
-
...(confirmPending !== undefined && { confirmPending }),
|
|
378
350
|
});
|
|
379
351
|
if (checked.diffHash !== input.diffHash)
|
|
380
352
|
throw stale();
|
|
@@ -420,7 +392,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
420
392
|
contents: checked.contents,
|
|
421
393
|
extension: ext,
|
|
422
394
|
createOrgs: [...new Set(checked.creates.map((c) => c.orgId))],
|
|
423
|
-
}, prepared, owner
|
|
395
|
+
}, prepared, owner);
|
|
424
396
|
return {
|
|
425
397
|
itemId,
|
|
426
398
|
version: diff.to.version,
|
|
@@ -504,7 +476,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
504
476
|
* The update's transaction (see the class comment): the super admin re-checked, the diff
|
|
505
477
|
* recomputed under the item name's lock, then every write. Returns the diff it applied.
|
|
506
478
|
*/
|
|
507
|
-
async commit(actor, itemId, input, opts, pre, prepared, owner
|
|
479
|
+
async commit(actor, itemId, input, opts, pre, prepared, owner) {
|
|
508
480
|
if (owner !== undefined && actor === null) {
|
|
509
481
|
throw new Error("an owner update needs the acting account");
|
|
510
482
|
}
|
|
@@ -523,25 +495,9 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
523
495
|
if (!named)
|
|
524
496
|
throw itemNotFound();
|
|
525
497
|
await this.itemLock.lock(named.name);
|
|
526
|
-
let pendingOwner = null;
|
|
527
|
-
if (confirmPending !== undefined) {
|
|
528
|
-
// The super admin's confirmation (P3-21): still pending with the version they reviewed
|
|
529
|
-
const row = await this.db
|
|
530
|
-
.selectFrom("catalog_items")
|
|
531
|
-
.select(["deleted_at", "pending_version", "owner_org_id"])
|
|
532
|
-
.where("id", "=", itemId)
|
|
533
|
-
.forUpdate()
|
|
534
|
-
.executeTakeFirstOrThrow();
|
|
535
|
-
if (row.deleted_at !== null)
|
|
536
|
-
throw itemRemovedError(named.name);
|
|
537
|
-
if (row.pending_version !== confirmPending)
|
|
538
|
-
throw pendingStale(named.name);
|
|
539
|
-
pendingOwner = row.owner_org_id;
|
|
540
|
-
}
|
|
541
498
|
const diff = await this.diff(itemId, input.version, {
|
|
542
499
|
pre,
|
|
543
500
|
...(owner && { owner }),
|
|
544
|
-
...(confirmPending !== undefined && { confirmPending }),
|
|
545
501
|
});
|
|
546
502
|
if (diff.diffHash !== input.diffHash)
|
|
547
503
|
throw stale();
|
|
@@ -641,31 +597,14 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
641
597
|
.where("item_id", "=", itemId)
|
|
642
598
|
.where("status", "in", [...LIVE_INSTALL_STATUSES])
|
|
643
599
|
.execute();
|
|
644
|
-
if (owner !== undefined
|
|
645
|
-
// An org's version becomes its latest once applied
|
|
600
|
+
if (owner !== undefined) {
|
|
601
|
+
// An org's version becomes its latest once applied
|
|
646
602
|
await t
|
|
647
603
|
.updateTable("catalog_items")
|
|
648
604
|
.set({ latest_version: diff.to.version })
|
|
649
605
|
.where("id", "=", itemId)
|
|
650
606
|
.execute();
|
|
651
607
|
await markVersionApplied(t, itemId, diff.to.version);
|
|
652
|
-
// An owner's new version replaces a version waiting for the super admin (pre-flight F7):
|
|
653
|
-
// their confirmation of it is then refused (409 extension.not_pending); the super admin's
|
|
654
|
-
// confirmation applied it
|
|
655
|
-
await t
|
|
656
|
-
.updateTable("catalog_items")
|
|
657
|
-
.set({ pending_version: null, pending_by: null, pending_at: null })
|
|
658
|
-
.where("id", "=", itemId)
|
|
659
|
-
.where("pending_version", "is not", null)
|
|
660
|
-
.execute();
|
|
661
|
-
}
|
|
662
|
-
if (confirmPending !== undefined && pendingOwner !== null) {
|
|
663
|
-
await addOrgNotice(t, pendingOwner, "upload_confirmed", {
|
|
664
|
-
itemId,
|
|
665
|
-
name: diff.name,
|
|
666
|
-
displayName: await itemDisplayName(t, itemId),
|
|
667
|
-
version: diff.to.version,
|
|
668
|
-
});
|
|
669
608
|
}
|
|
670
609
|
// The orgs using a shared org-owned plugin are told, one notice per plugin (a platform-owned
|
|
671
610
|
// plugin tells nobody); a plugin never synced before has no version to come from
|
|
@@ -774,27 +713,15 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
774
713
|
"deleted_at",
|
|
775
714
|
"platform_synced_version",
|
|
776
715
|
"owner_org_id",
|
|
777
|
-
"awaiting_confirmation",
|
|
778
|
-
"pending_version",
|
|
779
716
|
"latest_version",
|
|
780
717
|
])
|
|
781
718
|
.where("id", "=", itemId)
|
|
782
719
|
.executeTakeFirst();
|
|
783
720
|
if (!item || item.deleted_at !== null)
|
|
784
721
|
throw itemNotFound();
|
|
785
|
-
// A
|
|
786
|
-
if (o.
|
|
787
|
-
|
|
788
|
-
throw itemPendingError(item.name);
|
|
789
|
-
if (item.pending_version !== null && item.pending_version === version) {
|
|
790
|
-
throw itemPendingError(item.name, version);
|
|
791
|
-
}
|
|
792
|
-
// The super admin's generic update of an org's plugin reaches only its applied version
|
|
793
|
-
// (`latest_version`, ruling P3-34/P3-37): one the org uploaded that was never applied or
|
|
794
|
-
// confirmed (a rejected or failed one) is not theirs to apply
|
|
795
|
-
if (o.owner === undefined && item.owner_org_id !== null && version !== item.latest_version) {
|
|
796
|
-
throw notApplied(item.name, version);
|
|
797
|
-
}
|
|
722
|
+
// A super admin can update an org's plugin only to its currently applied version.
|
|
723
|
+
if (o.owner === undefined && item.owner_org_id !== null && version !== item.latest_version) {
|
|
724
|
+
throw notApplied(item.name, version);
|
|
798
725
|
}
|
|
799
726
|
if (o.owner !== undefined && item.owner_org_id !== o.owner.orgId)
|
|
800
727
|
throw itemNotFound();
|
|
@@ -804,30 +731,20 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
804
731
|
const name = item.name;
|
|
805
732
|
const versions = (await db
|
|
806
733
|
.selectFrom("catalog_item_versions")
|
|
807
|
-
.select([
|
|
808
|
-
"version",
|
|
809
|
-
"manifest",
|
|
810
|
-
"object_prefix",
|
|
811
|
-
"files",
|
|
812
|
-
"extension_sha256",
|
|
813
|
-
"applied_at",
|
|
814
|
-
"rejected_at",
|
|
815
|
-
])
|
|
734
|
+
.select(["version", "manifest", "object_prefix", "files", "extension_sha256", "applied_at"])
|
|
816
735
|
.where("item_id", "=", itemId)
|
|
817
736
|
.execute());
|
|
818
737
|
const to = o.target ?? versions.find((v) => v.version === version);
|
|
819
738
|
if (!to)
|
|
820
739
|
throw new ApiError("catalog.item_not_found", `Version ${version} of this item not found`);
|
|
821
740
|
// Whoever owns the item now (a transfer keeps the version rows), the generic update never
|
|
822
|
-
// reaches a version that was
|
|
741
|
+
// reaches a version that was never applied (ruling P3-52)
|
|
823
742
|
const row = versions.find((v) => v.version === version);
|
|
824
|
-
if (o.owner === undefined &&
|
|
743
|
+
if (o.owner === undefined && row && !versionUsable(row)) {
|
|
825
744
|
throw notApplied(item.name, version);
|
|
826
745
|
}
|
|
827
|
-
if (o.owner !== undefined
|
|
828
|
-
|
|
829
|
-
throw new ApiError("plugin.extension_upload_pending", `Version ${to.version} of plugin ${item.name} has an extension; it applies once a super admin confirms it`);
|
|
830
|
-
}
|
|
746
|
+
if (o.owner !== undefined)
|
|
747
|
+
assertDeclarativeUpload(to.manifest);
|
|
831
748
|
const from = item.platform_synced_version;
|
|
832
749
|
const fromRow = versions.find((v) => v.version === from);
|
|
833
750
|
if (from === to.version) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sql } from "kysely";
|
|
2
2
|
import { ApiError } from "../errors.js";
|
|
3
3
|
import { audit } from "../identity/audit.js";
|
|
4
|
-
import { isUsable
|
|
4
|
+
import { isUsable } from "./ownership.js";
|
|
5
5
|
import { visibleTo } from "./scope.js";
|
|
6
6
|
/**
|
|
7
7
|
* The catalog's database-level rules shared by the installers, the import confirm and the request
|
|
@@ -17,7 +17,7 @@ async function lockItem(t, itemId) {
|
|
|
17
17
|
return undefined;
|
|
18
18
|
return t
|
|
19
19
|
.selectFrom("catalog_items")
|
|
20
|
-
.select(["id", "name", "disabled", "scope", "builtin", "deleted_at"
|
|
20
|
+
.select(["id", "name", "disabled", "scope", "builtin", "deleted_at"])
|
|
21
21
|
.where("id", "=", itemId)
|
|
22
22
|
.forShare()
|
|
23
23
|
.executeTakeFirst();
|
|
@@ -39,14 +39,12 @@ export async function assertItemInstallable(t, orgId, itemId, approvedBy = itemI
|
|
|
39
39
|
throw notOffered();
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* The item
|
|
43
|
-
*
|
|
42
|
+
* The item must be usable ({@link isUsable}). A gone or disabled item returns
|
|
43
|
+
* `catalog.item_disabled`.
|
|
44
44
|
*/
|
|
45
45
|
function assertUsable(item) {
|
|
46
46
|
if (item && isUsable(item))
|
|
47
47
|
return;
|
|
48
|
-
if (item && item.deleted_at === null && !item.disabled)
|
|
49
|
-
throw itemPendingError(item.name);
|
|
50
48
|
throw itemDisabled();
|
|
51
49
|
}
|
|
52
50
|
const notOffered = () => new ApiError("catalog.approval_required", "This catalog item is not offered to this organization (plugin scope)");
|
|
@@ -13,6 +13,7 @@ import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
|
13
13
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
14
14
|
import { audit } from "../identity/audit.js";
|
|
15
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
16
|
+
import { withOrgScope } from "../infra/database/org-scope.js";
|
|
16
17
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
17
18
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
18
19
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
@@ -237,7 +238,7 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
237
238
|
ttlMs: ORG_LOCK_TTL_MS,
|
|
238
239
|
waitMs: ORG_LOCK_WAIT_MS,
|
|
239
240
|
...(signal !== undefined && { signal }),
|
|
240
|
-
}, () => this.syncRecorded(itemId, orgId, opts.finalTry === true));
|
|
241
|
+
}, () => withOrgScope(orgId, () => this.syncRecorded(itemId, orgId, opts.finalTry === true)));
|
|
241
242
|
}
|
|
242
243
|
/**
|
|
243
244
|
* {@link syncLocked} plus the pair's open failure (`plugin_scope_sync_failures`, the super
|
|
@@ -266,7 +267,6 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
266
267
|
"builtin",
|
|
267
268
|
"disabled",
|
|
268
269
|
"deleted_at",
|
|
269
|
-
"awaiting_confirmation",
|
|
270
270
|
"latest_version",
|
|
271
271
|
"platform_synced_version",
|
|
272
272
|
])
|
|
@@ -323,8 +323,6 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
323
323
|
}
|
|
324
324
|
return "unchanged";
|
|
325
325
|
}
|
|
326
|
-
// Never installed while not usable: an org upload still waiting for the super admin
|
|
327
|
-
// (ruling P3-9) has nothing confirmed to install
|
|
328
326
|
if (!isUsable(item))
|
|
329
327
|
return "unchanged";
|
|
330
328
|
// The platform's version (one per deployment, Task 7); the latest import before the first sync
|
package/dist/catalog/scope.d.ts
CHANGED
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
export type PluginScope = "all" | "optional" | "named";
|
|
3
3
|
/**
|
|
4
4
|
* The effective state of a plugin in one org. `not_offered`: a `named` item that does not list the
|
|
5
|
-
* org but is shown to other orgs, which may request access (spec §5.1).
|
|
6
|
-
* the org's own upload with an extension, until the super admin confirms it (ruling P3-9).
|
|
5
|
+
* org but is shown to other orgs, which may request access (spec §5.1).
|
|
7
6
|
*/
|
|
8
|
-
export type OrgPluginState = "on" | "off" | "needs_config" | "unavailable" | "not_offered"
|
|
9
|
-
/** The org's own upload, waiting for the super admin's confirmation (owner only, P3-9). */
|
|
10
|
-
| "awaiting_confirmation";
|
|
7
|
+
export type OrgPluginState = "on" | "off" | "needs_config" | "unavailable" | "not_offered";
|
|
11
8
|
/**
|
|
12
9
|
* Whether the item should be on in the org. Builtin is on unless disabled and its switch is
|
|
13
10
|
* ignored. Otherwise `all` is on unless disabled or the org switched it off (layering spec §4),
|
package/dist/channels/jobs.d.ts
CHANGED
|
@@ -93,10 +93,10 @@ export declare class ChannelJobs implements OnApplicationShutdown {
|
|
|
93
93
|
*/
|
|
94
94
|
oweResume(connectionId: string, orgId: string, at: Date): Promise<boolean>;
|
|
95
95
|
/**
|
|
96
|
-
* The {@link RESUME_JOB} job:
|
|
97
|
-
*
|
|
96
|
+
* The {@link RESUME_JOB} job: queues a delivery for each conversation of this connection's org
|
|
97
|
+
* that fell behind while the connection was disabled or its credentials were invalid.
|
|
98
98
|
*/
|
|
99
|
-
resumeConnection(connectionId: string): Promise<void>;
|
|
99
|
+
resumeConnection(connectionId: string, orgId: string): Promise<void>;
|
|
100
100
|
/** No more jobs from this process (the stop's channel-outbound phase). Idempotent. */
|
|
101
101
|
close(): void;
|
|
102
102
|
}
|
package/dist/channels/jobs.js
CHANGED
|
@@ -176,15 +176,16 @@ let ChannelJobs = class ChannelJobs {
|
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
|
-
* The {@link RESUME_JOB} job:
|
|
180
|
-
*
|
|
179
|
+
* The {@link RESUME_JOB} job: queues a delivery for each conversation of this connection's org
|
|
180
|
+
* that fell behind while the connection was disabled or its credentials were invalid.
|
|
181
181
|
*/
|
|
182
|
-
async resumeConnection(connectionId) {
|
|
182
|
+
async resumeConnection(connectionId, orgId) {
|
|
183
183
|
const rows = await this.db
|
|
184
184
|
.selectFrom("channel_deliveries")
|
|
185
185
|
.innerJoin("conversations", "conversations.id", "channel_deliveries.conversation_id")
|
|
186
186
|
.select("channel_deliveries.conversation_id")
|
|
187
187
|
.where("channel_deliveries.connection_id", "=", connectionId)
|
|
188
|
+
.where("conversations.org_id", "=", orgId)
|
|
188
189
|
.whereRef("channel_deliveries.last_seq", "<", "conversations.last_seq")
|
|
189
190
|
.execute();
|
|
190
191
|
for (const r of rows)
|
|
@@ -144,6 +144,7 @@ export declare class ChannelOutbound {
|
|
|
144
144
|
* connection's catch-up.
|
|
145
145
|
*/
|
|
146
146
|
process(job: Job<ChannelJobData>, token: string | undefined): Promise<void>;
|
|
147
|
+
private resolveOutboundOrg;
|
|
147
148
|
/** 本副本没有加载连接的插件:推迟重试(不消耗重试次数),排队超过上限才放弃。 */
|
|
148
149
|
private pluginPending;
|
|
149
150
|
/**
|
|
@@ -20,6 +20,7 @@ import { ApiError } from "../errors.js";
|
|
|
20
20
|
import { BlobsService } from "../files/blobs.service.js";
|
|
21
21
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
22
22
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
23
|
+
import { asPlatform, withOrgScope } from "../infra/database/org-scope.js";
|
|
23
24
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
24
25
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
25
26
|
import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
|
|
@@ -269,11 +270,30 @@ let ChannelOutbound = class ChannelOutbound {
|
|
|
269
270
|
return this.requeue(job, token, 0);
|
|
270
271
|
if (job.name === INBOUND_JOB)
|
|
271
272
|
return this.processInbound(job, token);
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return
|
|
273
|
+
const data = job.data;
|
|
274
|
+
const orgId = await this.resolveOutboundOrg(data);
|
|
275
|
+
if (orgId === undefined)
|
|
276
|
+
return;
|
|
277
|
+
return withOrgScope(orgId, () => job.name === RESUME_JOB
|
|
278
|
+
? this.jobs.resumeConnection(data.connectionId, orgId)
|
|
279
|
+
: this.deliver(job, token, orgId));
|
|
280
|
+
}
|
|
281
|
+
async resolveOutboundOrg(data) {
|
|
282
|
+
// org-filter: deployment-wide lookup of the owning org for a queued outbound channel job
|
|
283
|
+
const row = await asPlatform("resolve the org of a queued outbound channel job", () => {
|
|
284
|
+
const query = this.kdb
|
|
285
|
+
.selectFrom("channel_connections as connection")
|
|
286
|
+
.select("connection.org_id");
|
|
287
|
+
return ("connectionId" in data
|
|
288
|
+
? query.where("connection.id", "=", data.connectionId)
|
|
289
|
+
: query
|
|
290
|
+
.innerJoin("channel_deliveries as delivery", "delivery.connection_id", "connection.id")
|
|
291
|
+
.innerJoin("conversations as conversation", (join) => join
|
|
292
|
+
.onRef("conversation.id", "=", "delivery.conversation_id")
|
|
293
|
+
.onRef("conversation.org_id", "=", "connection.org_id"))
|
|
294
|
+
.where("delivery.conversation_id", "=", data.conversationId)).executeTakeFirst();
|
|
295
|
+
});
|
|
296
|
+
return row?.org_id;
|
|
277
297
|
}
|
|
278
298
|
/** 本副本没有加载连接的插件:推迟重试(不消耗重试次数),排队超过上限才放弃。 */
|
|
279
299
|
async pluginPending(job, token, what) {
|
|
@@ -318,7 +338,7 @@ let ChannelOutbound = class ChannelOutbound {
|
|
|
318
338
|
throw err;
|
|
319
339
|
}
|
|
320
340
|
}
|
|
321
|
-
async deliver(job, token) {
|
|
341
|
+
async deliver(job, token, orgId) {
|
|
322
342
|
const { conversationId } = job.data;
|
|
323
343
|
const owner = `${job.id ?? "job"}.`;
|
|
324
344
|
const acquire = () => this.lock.acquire(conversationId, `${owner}${randomUUID()}`, this.config.get().runtime.jobLockMs);
|
|
@@ -338,7 +358,7 @@ let ChannelOutbound = class ChannelOutbound {
|
|
|
338
358
|
const startSeq = await this.lastSeq(conversationId);
|
|
339
359
|
let outcome;
|
|
340
360
|
try {
|
|
341
|
-
outcome = await new Delivery(this.d, conversationId, lease, this.stopping.signal).run();
|
|
361
|
+
outcome = await new Delivery(this.d, conversationId, orgId, lease, this.stopping.signal).run();
|
|
342
362
|
}
|
|
343
363
|
catch (err) {
|
|
344
364
|
if (err instanceof RetryableDeliveryError) {
|
|
@@ -565,6 +585,7 @@ const hasToolCall = (content) => content.some((b) => b.type === "tool_call");
|
|
|
565
585
|
class Delivery {
|
|
566
586
|
d;
|
|
567
587
|
conversationId;
|
|
588
|
+
orgId;
|
|
568
589
|
lease;
|
|
569
590
|
stopping;
|
|
570
591
|
inbox = [];
|
|
@@ -635,9 +656,10 @@ class Delivery {
|
|
|
635
656
|
progressBroken = false;
|
|
636
657
|
/** Tool display metadata for the card's step labels, per tool key (this job only). */
|
|
637
658
|
toolInfos = new Map();
|
|
638
|
-
constructor(d, conversationId, lease, stopping) {
|
|
659
|
+
constructor(d, conversationId, orgId, lease, stopping) {
|
|
639
660
|
this.d = d;
|
|
640
661
|
this.conversationId = conversationId;
|
|
662
|
+
this.orgId = orgId;
|
|
641
663
|
this.lease = lease;
|
|
642
664
|
this.stopping = stopping;
|
|
643
665
|
}
|
|
@@ -655,6 +677,7 @@ class Delivery {
|
|
|
655
677
|
async run() {
|
|
656
678
|
const row = await this.d.db
|
|
657
679
|
.selectFrom("channel_deliveries")
|
|
680
|
+
.innerJoin("channel_connections", "channel_connections.id", "channel_deliveries.connection_id")
|
|
658
681
|
.select([
|
|
659
682
|
"connection_id",
|
|
660
683
|
"target",
|
|
@@ -668,6 +691,7 @@ class Delivery {
|
|
|
668
691
|
"progress_final",
|
|
669
692
|
])
|
|
670
693
|
.where("conversation_id", "=", this.conversationId)
|
|
694
|
+
.where("channel_connections.org_id", "=", this.orgId)
|
|
671
695
|
.executeTakeFirst();
|
|
672
696
|
if (!row)
|
|
673
697
|
return { kind: "done" };
|
package/dist/config/load.d.ts
CHANGED
|
@@ -6,31 +6,6 @@ export { ConfigError, type ConfigSource };
|
|
|
6
6
|
export declare function selectConfigSource(env: NodeJS.ProcessEnv): ConfigSource;
|
|
7
7
|
/** 深合并:对象递归合并,其余(含数组)由 override 整体替换。 */
|
|
8
8
|
export declare function deepMerge(base: unknown, override: unknown): unknown;
|
|
9
|
-
/**
|
|
10
|
-
* The permission keys the approval-only profiles design replaced, each with its replacement (B1's
|
|
11
|
-
* `devices.autoMode` and its successor `devices.fullAccess`, both now `devices.outsideSandbox`).
|
|
12
|
-
* The old keys are no longer read: {@link refuseLegacyPermissionKeys} refuses them with the
|
|
13
|
-
* conversion message, and `capybara config migrate-permissions` (`permission-migration.ts`)
|
|
14
|
-
* converts a config file. The values are the same (`allowed` / `off`); an old `off` also kept every
|
|
15
|
-
* device on the allowlist, so its conversion adds `devices.network.ceiling: allowlist` (never wider).
|
|
16
|
-
*/
|
|
17
|
-
export declare const LEGACY_PERMISSION_KEYS: readonly [{
|
|
18
|
-
readonly path: readonly ["devices", "autoMode"];
|
|
19
|
-
readonly replacement: readonly ["devices", "outsideSandbox"];
|
|
20
|
-
readonly env: "CAPYBARA_DEVICES__AUTO_MODE";
|
|
21
|
-
readonly replacementEnv: "CAPYBARA_DEVICES__OUTSIDE_SANDBOX";
|
|
22
|
-
}, {
|
|
23
|
-
readonly path: readonly ["devices", "fullAccess"];
|
|
24
|
-
readonly replacement: readonly ["devices", "outsideSandbox"];
|
|
25
|
-
readonly env: "CAPYBARA_DEVICES__FULL_ACCESS";
|
|
26
|
-
readonly replacementEnv: "CAPYBARA_DEVICES__OUTSIDE_SANDBOX";
|
|
27
|
-
}];
|
|
28
|
-
/** The key and variable an old `off` adds, so a converted deployment never widens a device. */
|
|
29
|
-
export declare const LEGACY_OFF_NETWORK_CEILING: {
|
|
30
|
-
readonly path: readonly ["devices", "network", "ceiling"];
|
|
31
|
-
readonly env: "CAPYBARA_DEVICES__NETWORK__CEILING";
|
|
32
|
-
readonly value: "allowlist";
|
|
33
|
-
};
|
|
34
9
|
/**
|
|
35
10
|
* Deep-merges the environment overrides (highest precedence) into the raw configuration, then
|
|
36
11
|
* validates it; hot reload and startup share it. Errors name only paths, never values.
|
package/dist/config/load.js
CHANGED
|
@@ -63,62 +63,6 @@ export function deepMerge(base, override) {
|
|
|
63
63
|
}
|
|
64
64
|
return out;
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
67
|
-
* The permission keys the approval-only profiles design replaced, each with its replacement (B1's
|
|
68
|
-
* `devices.autoMode` and its successor `devices.fullAccess`, both now `devices.outsideSandbox`).
|
|
69
|
-
* The old keys are no longer read: {@link refuseLegacyPermissionKeys} refuses them with the
|
|
70
|
-
* conversion message, and `capybara config migrate-permissions` (`permission-migration.ts`)
|
|
71
|
-
* converts a config file. The values are the same (`allowed` / `off`); an old `off` also kept every
|
|
72
|
-
* device on the allowlist, so its conversion adds `devices.network.ceiling: allowlist` (never wider).
|
|
73
|
-
*/
|
|
74
|
-
export const LEGACY_PERMISSION_KEYS = [
|
|
75
|
-
{
|
|
76
|
-
path: ["devices", "autoMode"],
|
|
77
|
-
replacement: ["devices", "outsideSandbox"],
|
|
78
|
-
env: "CAPYBARA_DEVICES__AUTO_MODE",
|
|
79
|
-
replacementEnv: "CAPYBARA_DEVICES__OUTSIDE_SANDBOX",
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
path: ["devices", "fullAccess"],
|
|
83
|
-
replacement: ["devices", "outsideSandbox"],
|
|
84
|
-
env: "CAPYBARA_DEVICES__FULL_ACCESS",
|
|
85
|
-
replacementEnv: "CAPYBARA_DEVICES__OUTSIDE_SANDBOX",
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
/** The key and variable an old `off` adds, so a converted deployment never widens a device. */
|
|
89
|
-
export const LEGACY_OFF_NETWORK_CEILING = {
|
|
90
|
-
path: ["devices", "network", "ceiling"],
|
|
91
|
-
env: "CAPYBARA_DEVICES__NETWORK__CEILING",
|
|
92
|
-
value: "allowlist",
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* The conversion message of every old permission key in ONE config source (the file / Nacos
|
|
96
|
-
* document, or the environment overrides), empty when it names none. The old key is refused even
|
|
97
|
-
* when it agrees with its replacement, so a source is converted once, never read under two names.
|
|
98
|
-
* The value is never echoed.
|
|
99
|
-
*/
|
|
100
|
-
function legacyPermissionKeyProblems(source, label) {
|
|
101
|
-
const problems = [];
|
|
102
|
-
for (const key of LEGACY_PERMISSION_KEYS) {
|
|
103
|
-
const [section, old] = key.path;
|
|
104
|
-
const parent = source[section];
|
|
105
|
-
if (!isPlainObject(parent) || !(old in parent))
|
|
106
|
-
continue;
|
|
107
|
-
problems.push(label === "env"
|
|
108
|
-
? ` - ${key.env} is no longer read: set ${key.replacementEnv} instead (the same values, allowed or off; with off, also set ${LEGACY_OFF_NETWORK_CEILING.env}=${LEGACY_OFF_NETWORK_CEILING.value} so no device widens)`
|
|
109
|
-
: ` - ${key.path.join(".")} is no longer read: rename it to ${key.replacement.join(".")} (the same values, allowed or off; with off, also set ${LEGACY_OFF_NETWORK_CEILING.path.join(".")}: ${LEGACY_OFF_NETWORK_CEILING.value} so no device widens); capybara config migrate-permissions --in <file> --out <file> converts a config file or Nacos document`);
|
|
110
|
-
}
|
|
111
|
-
return problems;
|
|
112
|
-
}
|
|
113
|
-
/** Refuses the old permission keys of the file / Nacos document and the environment. */
|
|
114
|
-
function refuseLegacyPermissionKeys(raw, env) {
|
|
115
|
-
const problems = [
|
|
116
|
-
...legacyPermissionKeyProblems(raw, "file"),
|
|
117
|
-
...legacyPermissionKeyProblems(env, "env"),
|
|
118
|
-
];
|
|
119
|
-
if (problems.length > 0)
|
|
120
|
-
throw new ConfigError(`invalid configuration:\n${problems.join("\n")}`);
|
|
121
|
-
}
|
|
122
66
|
const modeAt = (source, field) => {
|
|
123
67
|
const devices = source.devices;
|
|
124
68
|
const network = isPlainObject(devices) ? devices.network : undefined;
|
|
@@ -159,7 +103,6 @@ export function resolveConfig(raw, env, previous) {
|
|
|
159
103
|
if (!isPlainObject(raw))
|
|
160
104
|
throw new ConfigError("config file root must be a mapping");
|
|
161
105
|
const overrides = envOverrides(env);
|
|
162
|
-
refuseLegacyPermissionKeys(raw, overrides);
|
|
163
106
|
const merged = deepMerge(raw, overrides);
|
|
164
107
|
const result = KernelConfigSchema.safeParse(merged);
|
|
165
108
|
if (!result.success) {
|
package/dist/config/schema.js
CHANGED
|
@@ -1725,15 +1725,14 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
1725
1725
|
* deployment setting the super admin changes in the admin console (`devicesOutsideSandbox`);
|
|
1726
1726
|
* the startup config wins over it, so this field is optional with no schema default (the
|
|
1727
1727
|
* default `allowed` is applied by `readDeviceSandboxSettings`: a schema default would be
|
|
1728
|
-
* indistinguishable from a value the config source set).
|
|
1729
|
-
* and `devices.autoMode` are refused with the conversion message (`config/load.ts`).
|
|
1728
|
+
* indistinguishable from a value the config source set).
|
|
1730
1729
|
*/
|
|
1731
1730
|
outsideSandbox: z
|
|
1732
1731
|
.enum(["allowed", "off"])
|
|
1733
1732
|
.optional()
|
|
1734
1733
|
.meta(meta({
|
|
1735
1734
|
hot: true,
|
|
1736
|
-
description: "Whether a device may be granted running a call outside its sandbox (default allowed): a person, the review model or Auto then approves such an escalation per call, within the organization's and the device owner's settings; off refuses every escalation, and devices only run in their sandbox. An organization may turn it off and follow the platform. Set here, it is read-only in the admin console.
|
|
1735
|
+
description: "Whether a device may be granted running a call outside its sandbox (default allowed): a person, the review model or Auto then approves such an escalation per call, within the organization's and the device owner's settings; off refuses every escalation, and devices only run in their sandbox. An organization may turn it off and follow the platform. Set here, it is read-only in the admin console.",
|
|
1737
1736
|
})),
|
|
1738
1737
|
/**
|
|
1739
1738
|
* The device provider that makes a person's default device (several `device-provider@1`
|
|
@@ -81,15 +81,14 @@ export function attachmentContentMatches(recorded, head) {
|
|
|
81
81
|
const notFound = () => new ApiError("attachment.not_found", "Attachment not found");
|
|
82
82
|
/**
|
|
83
83
|
* The one purpose conversations read here: the `read` copies of the builtin Read and of tool
|
|
84
|
-
* result images.
|
|
85
|
-
* library (`ReferencedFiles`), never here.
|
|
84
|
+
* result images. ReferencedFiles reads uploads from the file library.
|
|
86
85
|
*/
|
|
87
86
|
const READ_PURPOSE = "read";
|
|
88
87
|
/** 去掉参数、转小写:`Text/Plain; charset=utf-8` → `text/plain`。 */
|
|
89
88
|
export const normalizeContentType = (ct) => (ct.split(";")[0] ?? "").trim().toLowerCase();
|
|
90
89
|
/**
|
|
91
90
|
* The object key: the attachment id only (the user's file name never goes into a key), under one
|
|
92
|
-
* prefix per purpose
|
|
91
|
+
* prefix per purpose.
|
|
93
92
|
*/
|
|
94
93
|
const objectKey = (id, purpose) => purpose === "agent-avatar"
|
|
95
94
|
? `agent-avatars/${id}`
|
|
@@ -961,8 +960,7 @@ let AttachmentsService = class AttachmentsService {
|
|
|
961
960
|
.selectFrom("attachments")
|
|
962
961
|
.select("id")
|
|
963
962
|
.where("conversation_id", "is", null)
|
|
964
|
-
|
|
965
|
-
.where("purpose", "<>", "chat")
|
|
963
|
+
.where("purpose", "in", ["skill-package", "agent-avatar", "read"])
|
|
966
964
|
.where("expires_at", "<", sql `now()`)
|
|
967
965
|
.$if(failed.length > 0, (q) => q.where("id", "not in", failed))
|
|
968
966
|
.orderBy("expires_at")
|
|
@@ -520,9 +520,9 @@ export declare class ConversationsService {
|
|
|
520
520
|
/**
|
|
521
521
|
* Soft-deletes a conversation (owner only; a sub-agent's conversation is `conversation.read_only`):
|
|
522
522
|
* stops an active run, hides the conversation everywhere for its owner and drops its channel
|
|
523
|
-
* bindings,
|
|
524
|
-
*
|
|
525
|
-
*
|
|
523
|
+
* bindings, requests cancellation of every running background task in its sandbox (its
|
|
524
|
+
* sub-agents' too) after commit, then stops every active run of its sub-agent tree (agent map
|
|
525
|
+
* spec §10). Task cancellations stay owed until the provider confirms them. The tasks
|
|
526
526
|
* are stopped after the conversation is marked deleted, so no finish
|
|
527
527
|
* (the stops' own, or one the poller writes meanwhile) can wake a run on it: `ensureRun` refuses a
|
|
528
528
|
* deleted conversation (the stops' finishes carry `stoppedBy: "deletion"` as well). The event
|