@capybara-hq/kernel 0.1.0-rc.66 → 0.1.0-rc.67
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 +0 -8
- package/dist/admin/admin.schemas.d.ts +3 -0
- package/dist/agents/admin-agents.d.ts +2 -2
- package/dist/agents/admin-agents.js +2 -1
- package/dist/agents/agent-lookup.js +2 -1
- package/dist/agents/agent-profile.service.d.ts +5 -2
- package/dist/agents/agent-profile.service.js +13 -2
- package/dist/agents/agents.controller.d.ts +4 -3
- package/dist/agents/agents.controller.js +7 -3
- package/dist/agents/agents.module.js +3 -0
- package/dist/agents/agents.schemas.d.ts +6 -6
- package/dist/agents/agents.service.d.ts +23 -2
- package/dist/agents/agents.service.js +61 -6
- package/dist/agents/avatar-view.d.ts +8 -0
- package/dist/agents/avatar-view.js +12 -0
- package/dist/agents/profile.d.ts +38 -13
- package/dist/agents/profile.js +31 -20
- package/dist/background/poll.job.d.ts +1 -1
- package/dist/background/poll.job.js +8 -6
- package/dist/background/tasks.service.js +1 -1
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/inbound.d.ts +2 -3
- package/dist/channels/inbound.js +2 -3
- package/dist/channels/phrases.d.ts +3 -3
- package/dist/channels/phrases.js +3 -3
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.js +14 -1
- package/dist/conversations/conversations.service.d.ts +4 -3
- package/dist/conversations/conversations.service.js +4 -2
- package/dist/ctx/create-ctx.js +5 -2
- package/dist/ctx/device-provider-check.d.ts +7 -0
- package/dist/ctx/device-provider-check.js +21 -0
- package/dist/db/kernel-schema.d.ts +7 -0
- package/dist/devices/access.d.ts +16 -46
- package/dist/devices/access.js +26 -62
- package/dist/devices/access.module.js +2 -2
- package/dist/devices/conversation-devices.d.ts +38 -18
- package/dist/devices/conversation-devices.js +69 -51
- package/dist/devices/default-provider-setting.d.ts +45 -0
- package/dist/devices/default-provider-setting.js +59 -0
- package/dist/devices/device-projects.service.js +7 -2
- package/dist/devices/device-provider-selection.d.ts +37 -0
- package/dist/devices/device-provider-selection.js +86 -0
- package/dist/devices/device-provider-selection.module.d.ts +3 -0
- package/dist/devices/device-provider-selection.module.js +22 -0
- package/dist/devices/devices.controller.d.ts +8 -5
- package/dist/devices/devices.controller.js +7 -4
- package/dist/devices/devices.module.js +3 -1
- package/dist/devices/devices.schemas.js +2 -2
- package/dist/devices/devices.service.d.ts +72 -83
- package/dist/devices/devices.service.js +139 -248
- package/dist/devices/dto.d.ts +9 -0
- package/dist/devices/dto.js +15 -2
- package/dist/devices/label.d.ts +3 -5
- package/dist/devices/label.js +3 -14
- package/dist/devices/legacy-cleanup.job.d.ts +2 -2
- package/dist/devices/legacy-cleanup.job.js +6 -6
- package/dist/errors.d.ts +15 -1
- package/dist/errors.js +15 -1
- package/dist/extensions/guide-places.d.ts +2 -1
- package/dist/extensions/guide-places.js +8 -2
- package/dist/extensions/locks.d.ts +1 -1
- package/dist/extensions/locks.js +1 -1
- package/dist/extensions/org-config.d.ts +20 -4
- package/dist/extensions/org-config.js +23 -6
- package/dist/extensions/permission-view.d.ts +2 -2
- package/dist/extensions/permission-view.js +2 -2
- package/dist/extensions/plugin-guides.d.ts +1 -1
- package/dist/extensions/plugin-guides.js +11 -3
- package/dist/extensions/point-defaults.d.ts +14 -0
- package/dist/extensions/point-defaults.js +70 -47
- package/dist/extensions/resolve.js +7 -2
- package/dist/identity/settings.d.ts +8 -0
- package/dist/identity/settings.js +24 -1
- package/dist/infra/config/kernel-config.service.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.js +7 -6
- package/dist/local-devices/device-routes.d.ts +1 -1
- package/dist/local-devices/device-routes.js +1 -1
- package/dist/local-devices/local-device-provider.d.ts +14 -11
- package/dist/local-devices/local-device-provider.js +14 -0
- package/dist/local-devices/local-devices.module.d.ts +4 -4
- package/dist/local-devices/local-devices.module.js +5 -3
- package/dist/local-devices/owner-report.js +2 -1
- package/dist/local-devices/targets.d.ts +2 -0
- package/dist/local-devices/targets.js +10 -0
- package/dist/orgs/settings.service.d.ts +26 -1
- package/dist/orgs/settings.service.js +44 -3
- package/dist/platform/ops/admin.ops.js +8 -3
- package/dist/platform/ops/agents.ops.d.ts +6 -1
- package/dist/platform/ops/agents.ops.js +38 -11
- package/dist/platform/ops/devices.ops.js +25 -20
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/themes.ops.js +1 -1
- package/dist/runtime/plugin-context.service.js +1 -12
- package/dist/sandbox/cloud-permission-snapshot.d.ts +2 -2
- package/dist/sandbox/cloud-permission-snapshot.js +3 -3
- package/dist/sandbox/device-reports.d.ts +50 -0
- package/dist/sandbox/device-reports.js +157 -0
- package/dist/sandbox/held-operations.d.ts +8 -8
- package/dist/sandbox/leases.d.ts +1 -1
- package/dist/sandbox/leases.js +1 -1
- package/dist/sandbox/operation-authority.d.ts +5 -2
- package/dist/sandbox/operation-authority.js +12 -11
- package/dist/sandbox/operation-reconcile.job.d.ts +2 -2
- package/dist/sandbox/operation-reconcile.job.js +5 -5
- package/dist/sandbox/permission-availability.d.ts +2 -2
- package/dist/sandbox/permission-call-types.d.ts +5 -0
- package/dist/sandbox/permission-facts.d.ts +2 -2
- package/dist/sandbox/permission-facts.js +5 -5
- package/dist/sandbox/providers.d.ts +23 -24
- package/dist/sandbox/providers.js +38 -46
- package/dist/sandbox/providers.module.js +3 -3
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +7 -2
- package/dist/sandbox/sandbox.service.d.ts +95 -68
- package/dist/sandbox/sandbox.service.js +212 -208
- package/dist/setup/setup-guides.service.d.ts +4 -1
- package/dist/setup/setup-guides.service.js +6 -1
- package/dist/themes/avatar-preset-key.d.ts +6 -0
- package/dist/themes/avatar-preset-key.js +9 -0
- package/dist/themes/theme-state.d.ts +29 -1
- package/dist/themes/theme-state.js +40 -1
- package/dist/themes/themes.service.d.ts +28 -1
- package/dist/themes/themes.service.js +36 -2
- package/dist/tools/builtins/image/generate.d.ts +3 -0
- package/dist/tools/builtins/image/generate.js +21 -11
- package/dist/tools/builtins/image/index.d.ts +1 -1
- package/dist/tools/builtins/image/index.js +1 -1
- package/dist/tools/builtins/sandbox/common.d.ts +36 -12
- package/dist/tools/builtins/sandbox/common.js +62 -18
- package/dist/tools/builtins/sandbox/read.d.ts +5 -2
- package/dist/tools/builtins/sandbox/read.js +9 -6
- package/dist/tools/builtins/sandbox/task-output.d.ts +2 -2
- package/dist/tools/builtins/sandbox/task-output.js +6 -5
- package/dist/tools/builtins/skill-load.js +13 -4
- package/dist/until-aborted.d.ts +5 -0
- package/dist/until-aborted.js +16 -0
- package/package.json +4 -4
- package/src/migrations/0176_device_report.sql +6 -0
|
@@ -8,8 +8,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable, Module, Optional } from "@nestjs/common";
|
|
11
|
+
import { ModuleRef } from "@nestjs/core";
|
|
11
12
|
import { z } from "zod";
|
|
12
13
|
import { readPlatformAttribution, } from "../attribution/platform-attribution.js";
|
|
14
|
+
import { DeviceProviderName } from "../devices/default-provider-setting.js";
|
|
13
15
|
import { ApiError } from "../errors.js";
|
|
14
16
|
import { audit } from "../identity/audit.js";
|
|
15
17
|
import { COMPACTION_SETTINGS_PARTIAL, COMPACTION_SETTINGS_PATCH, readPlatformCompactionSettings, readPromptSuggestions, readSandboxLimitOverride, } from "../identity/settings.js";
|
|
@@ -52,6 +54,10 @@ import { OrgLock, OrgLockModule } from "./org-lock.js";
|
|
|
52
54
|
* a default or ceiling above the platform's ceiling is refused.
|
|
53
55
|
* Old keys are read and kept in step until the permission configuration publication converts
|
|
54
56
|
* them ({@link orgDeviceSandboxOf}).
|
|
57
|
+
* - `deviceDefaultProvider`: the org's override of the platform's default device provider (the
|
|
58
|
+
* `device-provider@1` extension that makes a member's default device); absent follows the
|
|
59
|
+
* platform, an invalid stored value reads as absent. Only a provider that is on in the org may
|
|
60
|
+
* be set (400 `org.device_provider_not_available`).
|
|
55
61
|
* - `platformTool`: the `Platform` builtin for the whole org (Platform tool spec §3): `on`,
|
|
56
62
|
* `read-only` (writes listed as unavailable) or `off` (default `on`).
|
|
57
63
|
* - `timeZone`: the org's default time zone (IANA; absent = UTC) for senders without one of their
|
|
@@ -157,6 +163,8 @@ export const OrgSettingsSchema = z.object({
|
|
|
157
163
|
outsideSandbox: OutsideSandboxSetting.optional().catch("off"),
|
|
158
164
|
/** The org's device sandbox network; absent follows the platform. */
|
|
159
165
|
deviceNetwork: DeviceNetworkSettingSchema.optional().catch(invalidDeviceNetwork),
|
|
166
|
+
/** The org's default device provider; absent follows the platform. */
|
|
167
|
+
deviceDefaultProvider: DeviceProviderName.optional().catch(undefined),
|
|
160
168
|
/** Overrides `runtime.wakeOnBackgroundTask`; absent follows the deployment. */
|
|
161
169
|
wakeOnBackgroundTask: z.boolean().optional().catch(undefined),
|
|
162
170
|
/** The org's default time zone (run context spec §3.3); absent = UTC. */
|
|
@@ -199,6 +207,11 @@ export const OrgSettingsPatchSchema = z
|
|
|
199
207
|
locale: z.enum(["zh", "en"]).optional(),
|
|
200
208
|
sandboxToolPolicy: z.enum(["allow", "ask"]).optional(),
|
|
201
209
|
platformTool: z.enum(["on", "read-only", "off"]).optional(),
|
|
210
|
+
/**
|
|
211
|
+
* The org's default device provider; null clears it (follow the platform). A provider that is
|
|
212
|
+
* not on in the org -> 400 `org.device_provider_not_available`.
|
|
213
|
+
*/
|
|
214
|
+
deviceDefaultProvider: DeviceProviderName.nullable().optional(),
|
|
202
215
|
/** null clears (follow the deployment again). */
|
|
203
216
|
wakeOnBackgroundTask: z.boolean().nullable().optional(),
|
|
204
217
|
/**
|
|
@@ -417,18 +430,26 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
417
430
|
config;
|
|
418
431
|
ceilings;
|
|
419
432
|
log;
|
|
433
|
+
modules;
|
|
420
434
|
constructor(db, txHost, orgLock,
|
|
421
435
|
/**
|
|
422
436
|
* The deployment config: `sandbox.limits` and the platform's device sandbox settings
|
|
423
437
|
* (`devices.outsideSandbox`, `devices.network`; the org may follow them, never exceed them).
|
|
424
438
|
*/
|
|
425
|
-
config, ceilings, log
|
|
439
|
+
config, ceilings, log,
|
|
440
|
+
/**
|
|
441
|
+
* Finds {@link ExtensionPointDefaults} (`deviceDefaultProvider` is checked against the
|
|
442
|
+
* providers on in the org) at the time of use: the extensions module cannot be imported here
|
|
443
|
+
* without a module cycle.
|
|
444
|
+
*/
|
|
445
|
+
modules) {
|
|
426
446
|
this.db = db;
|
|
427
447
|
this.txHost = txHost;
|
|
428
448
|
this.orgLock = orgLock;
|
|
429
449
|
this.config = config;
|
|
430
450
|
this.ceilings = ceilings;
|
|
431
451
|
this.log = log;
|
|
452
|
+
this.modules = modules;
|
|
432
453
|
}
|
|
433
454
|
/** Parses stored settings, warning when an invalid `outsideSandbox` narrows to `off`, an
|
|
434
455
|
* invalid `deviceNetwork` to an empty allowlist, or a security setting reads narrower
|
|
@@ -585,11 +606,27 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
585
606
|
*/
|
|
586
607
|
opts) {
|
|
587
608
|
await this.check(patch);
|
|
609
|
+
await this.assertDeviceProviderOn(orgId, patch);
|
|
588
610
|
// the org row, then (for a device sandbox change) the org's permission authority lock:
|
|
589
611
|
// the ordered prelude, so inside a run's fence (the Platform tool's `org-settings.update`) they
|
|
590
612
|
// precede the conversation rows; the patch decides the lock, so nothing can change it
|
|
591
613
|
return withOrderedLocks(() => this.lockFor(orgId, patch, actorAccountId), () => this.updateIn(orgId, patch, actorAccountId, actorTokenId, auditDetail, opts));
|
|
592
614
|
}
|
|
615
|
+
/** Refuses a `deviceDefaultProvider` that is not a `device-provider@1` extension on in the org. */
|
|
616
|
+
async assertDeviceProviderOn(orgId, patch) {
|
|
617
|
+
const name = patch.deviceDefaultProvider;
|
|
618
|
+
if (name === undefined || name === null)
|
|
619
|
+
return;
|
|
620
|
+
// loaded here, not at the top: the extension host imports this file's settings readers
|
|
621
|
+
const { ExtensionPointDefaults } = await import("../extensions/point-defaults.js");
|
|
622
|
+
const points = this.modules?.get(ExtensionPointDefaults, { strict: false });
|
|
623
|
+
const { providers } = (await points?.providersFor(orgId, "device-provider")) ?? {
|
|
624
|
+
providers: [],
|
|
625
|
+
};
|
|
626
|
+
if (providers.some((p) => p.extension === name))
|
|
627
|
+
return;
|
|
628
|
+
throw new ApiError("org.device_provider_not_available", `The device provider ${name} is not on in this organization; switch it on first or choose another`, [{ path: "deviceDefaultProvider", providers: providers.map((p) => p.extension) }]);
|
|
629
|
+
}
|
|
593
630
|
async lockFor(orgId, patch, actorAccountId) {
|
|
594
631
|
await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "org.update");
|
|
595
632
|
if (patch.outsideSandbox !== undefined || patch.deviceNetwork !== undefined)
|
|
@@ -687,6 +724,8 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
687
724
|
delete after.outsideSandbox;
|
|
688
725
|
if (after.deviceNetwork === undefined)
|
|
689
726
|
delete after.deviceNetwork;
|
|
727
|
+
if (after.deviceDefaultProvider === undefined)
|
|
728
|
+
delete after.deviceDefaultProvider;
|
|
690
729
|
if (after.wakeOnBackgroundTask === undefined)
|
|
691
730
|
delete after.wakeOnBackgroundTask;
|
|
692
731
|
if (after.timeZone === undefined)
|
|
@@ -719,7 +758,7 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
719
758
|
}
|
|
720
759
|
// Merge with the stored value: keep the keys this version does not know (a cleared
|
|
721
760
|
// outsideSandbox / deviceNetwork is not kept; the old keys are rewritten in step)
|
|
722
|
-
const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
|
|
761
|
+
const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, deviceDefaultProvider: _oldDeviceProvider, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
|
|
723
762
|
const written = { ...rest, ...after };
|
|
724
763
|
keepOrgLegacyKeysInStep(written, stored);
|
|
725
764
|
// An unreadable forbiddenTools reads as [] for display only: a write that does not replace the
|
|
@@ -800,7 +839,9 @@ OrgSettingsService = __decorate([
|
|
|
800
839
|
__param(3, Inject(KernelConfigService)),
|
|
801
840
|
__param(4, Inject(PermissionCeilingWrites)),
|
|
802
841
|
__param(5, Optional()),
|
|
803
|
-
__param(5, Inject(KERNEL_LOGGER))
|
|
842
|
+
__param(5, Inject(KERNEL_LOGGER)),
|
|
843
|
+
__param(6, Optional()),
|
|
844
|
+
__param(6, Inject(ModuleRef))
|
|
804
845
|
], OrgSettingsService);
|
|
805
846
|
export { OrgSettingsService };
|
|
806
847
|
/**
|
|
@@ -45,6 +45,7 @@ const SettingsInput = DEPLOYMENT_SETTINGS_PATCH.pick({
|
|
|
45
45
|
clientExtensions: true,
|
|
46
46
|
devicesOutsideSandbox: true,
|
|
47
47
|
devicesNetwork: true,
|
|
48
|
+
devicesDefaultProvider: true,
|
|
48
49
|
attribution: true,
|
|
49
50
|
externalSharing: true,
|
|
50
51
|
shareMaxExpiryDays: true,
|
|
@@ -208,7 +209,7 @@ let AdminOperations = class AdminOperations {
|
|
|
208
209
|
}),
|
|
209
210
|
defineOperation({
|
|
210
211
|
id: "admin.settings",
|
|
211
|
-
description: "Read the deployment settings (super admin): who may create orgs (orgCreation), the price currency, whether orgs may create their own connectors and skills, whether org admins may browse the marketplaces, the per-org limit overrides keyed by org id (orgs.get reads one org's), the platform's device sandbox settings in effect (devicesOutsideSandbox: permission allowed or off, whether a device may be granted running a call outside its sandbox; devicesNetwork: default and ceiling, open for the public internet with private addresses closed or allowlist, the network a device gets and the widest an org or device may choose), the platform's attribution defaults for agent-created git commits and pull requests (attribution: commit, pr, sessionUrl), file sharing (externalSharing: value allow or deny, whether orgs may turn on public links to conversation files; shareMaxExpiryDays: value, the longest expiry a share may take in days), htmlRenderCdnAllowlist (the https origins a rendered HTML file may load libraries, styles, fonts and images from) and promptSuggestions (on or off, absent meaning on: whether the composer suggests the person's next message after a completed run; an org's own promptSuggestions must be on too); the switches each with sources: env, file or nacos are set in the startup config and read-only, db chosen in the admin console, default.",
|
|
212
|
+
description: "Read the deployment settings (super admin): who may create orgs (orgCreation), the price currency, whether orgs may create their own connectors and skills, whether org admins may browse the marketplaces, the per-org limit overrides keyed by org id (orgs.get reads one org's), the platform's device sandbox settings in effect (devicesOutsideSandbox: permission allowed or off, whether a device may be granted running a call outside its sandbox; devicesNetwork: default and ceiling, open for the public internet with private addresses closed or allowlist, the network a device gets and the widest an org or device may choose), devicesDefaultProvider (provider: the device provider extension that makes a person's default device, null for none), the platform's attribution defaults for agent-created git commits and pull requests (attribution: commit, pr, sessionUrl), file sharing (externalSharing: value allow or deny, whether orgs may turn on public links to conversation files; shareMaxExpiryDays: value, the longest expiry a share may take in days), htmlRenderCdnAllowlist (the https origins a rendered HTML file may load libraries, styles, fonts and images from) and promptSuggestions (on or off, absent meaning on: whether the composer suggests the person's next message after a completed run; an org's own promptSuggestions must be on too); the switches each with sources: env, file or nacos are set in the startup config and read-only, db chosen in the admin console, default.",
|
|
212
213
|
input: z.object({}).strict(),
|
|
213
214
|
example: {},
|
|
214
215
|
authz: { superAdmin: true },
|
|
@@ -218,7 +219,7 @@ let AdminOperations = class AdminOperations {
|
|
|
218
219
|
}),
|
|
219
220
|
defineOperation({
|
|
220
221
|
id: "admin.update-settings",
|
|
221
|
-
description: "Change deployment settings (super admin); give only the keys to change: orgCreation (anyone or super_admin), priceCurrency (ISO 4217 code), customConnectors / customSkills (allow or deny: whether orgs may create their own instead of installing from the catalog), orgMarketplaceBrowse (true or false), uiTheme ({ id }: the platform default theme, a platform theme whose scope is all, or null for the built-in theme; it is what every org falls back to and what the sign-in pages show), uiArrangement ({ <slot>: { hidden, order } } for a list slot, { <slot>: { use } } for a single slot: the platform default arrangement of UI slots, with contribution keys <extension>/<contribution>; hidden ones are not listed but still open by URL; use names the contribution that replaces the built-in, null for the built-in; null for a slot removes its entry), clientExtensions ({ enabled?, disabled? }: the kill switch of plugin client code; enabled false stops every plugin's interface code in every browser, disabled is the whole list of plugins whose interface code alone is stopped while their tools keep working; read the current list from admin.settings first), devicesOutsideSandbox ({ permission }: whether a device may be granted running a call outside its sandbox, allowed or off; null clears it back to the default, allowed; through this tool it may only be turned off, never allowed, and a value set in the startup config is read-only), devicesNetwork ({ default?, ceiling? }: the device sandbox network, open or allowlist; null clears a field back to the default, open; the default may not be above the ceiling; through this tool either may only be narrowed to allowlist, never opened, and a field set in the startup config is read-only), attribution ({ commit?, pr?, sessionUrl? }: the platform's defaults for agent-created git commits and pull requests; null clears a field back to its default, an empty string turns that line off, and fields set in the startup config are read-only), externalSharing (allow or deny: whether orgs may turn on public links to conversation files; null clears it back to the default, deny; externalSharing may only be turned off through this tool, and a value set in the startup config is read-only), shareMaxExpiryDays (1 to 365: the longest expiry a share may take, in days; null clears it back to 30; through this tool it may only be lowered, never raised, and it is read-only when set in the startup config), htmlRenderCdnAllowlist (the whole list of https origins, scheme and host with an optional port and nothing else, that a rendered HTML file may load from; at most 50; through this tool origins may only be removed, never added, so read the current list from admin.settings first and send it without the ones to drop). promptSuggestions (on or off; null clears it, absent meaning on: whether the composer suggests the person's next message after a completed run; an org's own promptSuggestions must be on too) may be set either way. Per-org limits are orgs.set-limits.",
|
|
222
|
+
description: "Change deployment settings (super admin); give only the keys to change: orgCreation (anyone or super_admin), priceCurrency (ISO 4217 code), customConnectors / customSkills (allow or deny: whether orgs may create their own instead of installing from the catalog), orgMarketplaceBrowse (true or false), uiTheme ({ id }: the platform default theme, a platform theme whose scope is all, or null for the built-in theme; it is what every org falls back to and what the sign-in pages show), uiArrangement ({ <slot>: { hidden, order } } for a list slot, { <slot>: { use } } for a single slot: the platform default arrangement of UI slots, with contribution keys <extension>/<contribution>; hidden ones are not listed but still open by URL; use names the contribution that replaces the built-in, null for the built-in; null for a slot removes its entry), clientExtensions ({ enabled?, disabled? }: the kill switch of plugin client code; enabled false stops every plugin's interface code in every browser, disabled is the whole list of plugins whose interface code alone is stopped while their tools keep working; read the current list from admin.settings first), devicesOutsideSandbox ({ permission }: whether a device may be granted running a call outside its sandbox, allowed or off; null clears it back to the default, allowed; through this tool it may only be turned off, never allowed, and a value set in the startup config is read-only), devicesNetwork ({ default?, ceiling? }: the device sandbox network, open or allowlist; null clears a field back to the default, open; the default may not be above the ceiling; through this tool either may only be narrowed to allowlist, never opened, and a field set in the startup config is read-only), devicesDefaultProvider ({ provider }: the device provider extension that makes a person's default device; null clears it back to none; read-only when set in the startup config), attribution ({ commit?, pr?, sessionUrl? }: the platform's defaults for agent-created git commits and pull requests; null clears a field back to its default, an empty string turns that line off, and fields set in the startup config are read-only), externalSharing (allow or deny: whether orgs may turn on public links to conversation files; null clears it back to the default, deny; externalSharing may only be turned off through this tool, and a value set in the startup config is read-only), shareMaxExpiryDays (1 to 365: the longest expiry a share may take, in days; null clears it back to 30; through this tool it may only be lowered, never raised, and it is read-only when set in the startup config), htmlRenderCdnAllowlist (the whole list of https origins, scheme and host with an optional port and nothing else, that a rendered HTML file may load from; at most 50; through this tool origins may only be removed, never added, so read the current list from admin.settings first and send it without the ones to drop). promptSuggestions (on or off; null clears it, absent meaning on: whether the composer suggests the person's next message after a completed run; an org's own promptSuggestions must be on too) may be set either way. Per-org limits are orgs.set-limits.",
|
|
222
223
|
input: SettingsInput.refine((b) => Object.keys(b).length > 0, {
|
|
223
224
|
message: "at least one setting is required",
|
|
224
225
|
}),
|
|
@@ -276,11 +277,13 @@ let AdminOperations = class AdminOperations {
|
|
|
276
277
|
return precheckBy(async () => {
|
|
277
278
|
if (i.devicesOutsideSandbox !== undefined || i.devicesNetwork !== undefined)
|
|
278
279
|
await this.settings.checkDeviceSandbox(i, { onlyNarrows: true });
|
|
280
|
+
if (i.devicesDefaultProvider !== undefined)
|
|
281
|
+
this.settings.checkDefaultProvider(i.devicesDefaultProvider);
|
|
279
282
|
await this.settings.checkSharing(i, { onlyNarrows: true });
|
|
280
283
|
});
|
|
281
284
|
},
|
|
282
285
|
summary: async (i) => {
|
|
283
|
-
const { uiTheme, uiArrangement, clientExtensions, devicesOutsideSandbox, devicesNetwork, attribution, htmlRenderCdnAllowlist, ...rest } = i;
|
|
286
|
+
const { uiTheme, uiArrangement, clientExtensions, devicesOutsideSandbox, devicesNetwork, devicesDefaultProvider, attribution, htmlRenderCdnAllowlist, ...rest } = i;
|
|
284
287
|
const parts = Object.entries(rest).map(([k, v]) => `${k}=${String(v)}`);
|
|
285
288
|
if (htmlRenderCdnAllowlist !== undefined) {
|
|
286
289
|
parts.push(`htmlRenderCdnAllowlist=[${htmlRenderCdnAllowlist.join(", ")}]`);
|
|
@@ -293,6 +296,8 @@ let AdminOperations = class AdminOperations {
|
|
|
293
296
|
if (devicesNetwork[field] !== undefined)
|
|
294
297
|
parts.push(`devicesNetwork.${field}=${String(devicesNetwork[field])}`);
|
|
295
298
|
}
|
|
299
|
+
if (devicesDefaultProvider !== undefined)
|
|
300
|
+
parts.push(`devicesDefaultProvider=${String(devicesDefaultProvider.provider)}`);
|
|
296
301
|
const zh = [...parts];
|
|
297
302
|
const en = [...parts];
|
|
298
303
|
if (attribution !== undefined) {
|
|
@@ -8,6 +8,7 @@ import { ReadinessService } from "../../agents/readiness.service.js";
|
|
|
8
8
|
import { CatalogRequestsService } from "../../catalog/requests.service.js";
|
|
9
9
|
import { AttachmentsService } from "../../conversations/attachments.service.js";
|
|
10
10
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
11
|
+
import { ThemesService } from "../../themes/themes.service.js";
|
|
11
12
|
import { ConnectorsService } from "../../tools/connectors.service.js";
|
|
12
13
|
import { PlatformOperations } from "../registry.js";
|
|
13
14
|
/** Agent operations of the `Platform` tool (spec §7); visibility is the person's own agents. */
|
|
@@ -23,7 +24,11 @@ export declare class AgentsOperations implements OnModuleInit {
|
|
|
23
24
|
private readonly readiness;
|
|
24
25
|
private readonly kdb;
|
|
25
26
|
private readonly attachments;
|
|
26
|
-
|
|
27
|
+
/** The org's theme avatar presets: the card names a theme preset by its name. */
|
|
28
|
+
private readonly themes;
|
|
29
|
+
constructor(registry: PlatformOperations, agents: AgentsService, profiles: AgentProfileService, fromTemplate: AgentsFromTemplate, orgTemplates: OrgAgentTemplates, pending: PendingConnectorsService, requests: CatalogRequestsService, connectors: ConnectorsService, readiness: ReadinessService, kdb: KernelDb, attachments: AttachmentsService,
|
|
30
|
+
/** The org's theme avatar presets: the card names a theme preset by its name. */
|
|
31
|
+
themes: Pick<ThemesService, "avatarPresets">);
|
|
27
32
|
/**
|
|
28
33
|
* The edit rule the service enforces, read before the card: the agent is visible, and the actor
|
|
29
34
|
* owns it or is an org admin. Returns the agent too for the checks that follow.
|
|
@@ -17,20 +17,21 @@ import { AgentDefinitionSchema } from "../../agents/definition.js";
|
|
|
17
17
|
import { AgentsFromTemplate } from "../../agents/from-template.service.js";
|
|
18
18
|
import { OrgAgentTemplates } from "../../agents/org-templates.js";
|
|
19
19
|
import { PendingConnectorsService } from "../../agents/pending-connectors.service.js";
|
|
20
|
-
import { PresetAvatarSchema } from "../../agents/profile.js";
|
|
20
|
+
import { isBuiltinPresetId, PresetAvatarSchema } from "../../agents/profile.js";
|
|
21
21
|
import { ReadinessService } from "../../agents/readiness.service.js";
|
|
22
22
|
import { CatalogRequestsService } from "../../catalog/requests.service.js";
|
|
23
23
|
import { AGENT_AVATAR_CONTENT_TYPES, AGENT_AVATAR_MAX_BYTES, AttachmentsService, } from "../../conversations/attachments.service.js";
|
|
24
24
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
25
25
|
import { roleAtLeast } from "../../orgs/roles.js";
|
|
26
26
|
import { rootConversationOf } from "../../runtime/subagents/child.js";
|
|
27
|
+
import { ThemesService } from "../../themes/themes.service.js";
|
|
27
28
|
import { ConnectorsService } from "../../tools/connectors.service.js";
|
|
28
29
|
import { FileRefSchema } from "../file-ref.js";
|
|
29
30
|
import { defineOperation, } from "../operation.js";
|
|
30
31
|
import { PlatformOperations } from "../registry.js";
|
|
31
32
|
import { precheckBy, viaAgent } from "./errors.js";
|
|
32
33
|
import { roleOf } from "./role.js";
|
|
33
|
-
import { named, orElse } from "./summary.js";
|
|
34
|
+
import { localized, named, orElse } from "./summary.js";
|
|
34
35
|
const AgentId = AgentPathParams.shape.agentId.max(100);
|
|
35
36
|
/** The request's definition (create form): the operations tighten its fields, never redeclare them. */
|
|
36
37
|
const Def = AgentCreateDefinition.shape;
|
|
@@ -74,8 +75,11 @@ const PresetAvatar = PresetAvatarSchema;
|
|
|
74
75
|
* route's `upload` kind, the kernel stores the file as an avatar upload and saves that.
|
|
75
76
|
*/
|
|
76
77
|
const FileAvatar = z.object({ kind: z.literal("file"), file: FileRefSchema }).strict();
|
|
77
|
-
/**
|
|
78
|
-
|
|
78
|
+
/**
|
|
79
|
+
* One change of `agents.update-profile` as the card says it. `presetName`: a theme preset's name
|
|
80
|
+
* (the card names it rather than its key); a built-in or unknown preset shows its id.
|
|
81
|
+
*/
|
|
82
|
+
function profileChanges(i, fileName, presetName) {
|
|
79
83
|
const zh = [];
|
|
80
84
|
const en = [];
|
|
81
85
|
if (i.avatar === null) {
|
|
@@ -89,8 +93,8 @@ function profileChanges(i, fileName) {
|
|
|
89
93
|
en.push(`set the avatar to the image "${n}"`);
|
|
90
94
|
}
|
|
91
95
|
else if (i.avatar !== undefined) {
|
|
92
|
-
zh.push(`头像设为预设「${i.avatar.id}」`);
|
|
93
|
-
en.push(`set the avatar to preset "${i.avatar.id}"`);
|
|
96
|
+
zh.push(`头像设为预设「${presetName?.zh ?? i.avatar.id}」`);
|
|
97
|
+
en.push(`set the avatar to preset "${presetName?.en ?? i.avatar.id}"`);
|
|
94
98
|
}
|
|
95
99
|
if (i.quickActions !== undefined && i.quickActions.length === 0) {
|
|
96
100
|
zh.push("清空快捷操作");
|
|
@@ -129,7 +133,10 @@ let AgentsOperations = class AgentsOperations {
|
|
|
129
133
|
readiness;
|
|
130
134
|
kdb;
|
|
131
135
|
attachments;
|
|
132
|
-
|
|
136
|
+
themes;
|
|
137
|
+
constructor(registry, agents, profiles, fromTemplate, orgTemplates, pending, requests, connectors, readiness, kdb, attachments,
|
|
138
|
+
/** The org's theme avatar presets: the card names a theme preset by its name. */
|
|
139
|
+
themes) {
|
|
133
140
|
this.registry = registry;
|
|
134
141
|
this.agents = agents;
|
|
135
142
|
this.profiles = profiles;
|
|
@@ -141,6 +148,7 @@ let AgentsOperations = class AgentsOperations {
|
|
|
141
148
|
this.readiness = readiness;
|
|
142
149
|
this.kdb = kdb;
|
|
143
150
|
this.attachments = attachments;
|
|
151
|
+
this.themes = themes;
|
|
144
152
|
}
|
|
145
153
|
/**
|
|
146
154
|
* The edit rule the service enforces, read before the card: the agent is visible, and the actor
|
|
@@ -351,7 +359,7 @@ let AgentsOperations = class AgentsOperations {
|
|
|
351
359
|
}),
|
|
352
360
|
defineOperation({
|
|
353
361
|
id: "agents.update-profile",
|
|
354
|
-
description: 'Change how an agent you may edit looks to people: its avatar (one of the preset
|
|
362
|
+
description: 'Change how an agent you may edit looks to people: its avatar (a preset: one of the built-in animals by id, or a theme preset by the key that themes.list returns under avatars.presets[].key, offered only while that theme is the default theme of the org; an image of this conversation as { kind: "file", file: { fileId } }, e.g. a generated image, an attachment or a delivered file, PNG, JPEG or WebP up to 2 MiB, which the person sees on the card; or null for none) and its quick actions (the prompts offered when a conversation starts; the list you send replaces the current one, [] clears it). Send at least one of the two. The current profile is in agents.get. The description is part of the definition: change it with agents.update. A change to your own private agent may be remembered by the person (never one that takes an image); a change to a shared agent is confirmed every time.',
|
|
355
363
|
input: z
|
|
356
364
|
.object({
|
|
357
365
|
agentId: AgentId,
|
|
@@ -399,6 +407,10 @@ let AgentsOperations = class AgentsOperations {
|
|
|
399
407
|
code: "agent.profile_conflict",
|
|
400
408
|
next: "Someone changed the profile while you were waiting: read it again with agents.get, then call again.",
|
|
401
409
|
},
|
|
410
|
+
{
|
|
411
|
+
code: "agent.avatar_unavailable",
|
|
412
|
+
next: "Choose one of the presets the picker shows: a built-in animal id, or a key from themes.list avatars.presets[].key of the org's current default theme.",
|
|
413
|
+
},
|
|
402
414
|
{
|
|
403
415
|
code: "attachment.too_many_pending",
|
|
404
416
|
next: "Too many avatar images are stored and not used yet; wait a day for them to expire, or save one of them.",
|
|
@@ -410,7 +422,11 @@ let AgentsOperations = class AgentsOperations {
|
|
|
410
422
|
],
|
|
411
423
|
precheck: async (i, ctx) => {
|
|
412
424
|
const { agent: _a, ...check } = await this.editCheck(i.agentId, ctx);
|
|
413
|
-
|
|
425
|
+
if (!check.ok || i.avatar?.kind !== "preset")
|
|
426
|
+
return check;
|
|
427
|
+
// a theme preset key the org's default theme does not offer: refused before the card
|
|
428
|
+
const avatar = i.avatar;
|
|
429
|
+
return precheckBy(() => this.agents.resolveAvatarInput(ctx.orgId, avatar));
|
|
414
430
|
},
|
|
415
431
|
fileRef: (i) => i.avatar?.kind === "file"
|
|
416
432
|
? {
|
|
@@ -424,7 +440,17 @@ let AgentsOperations = class AgentsOperations {
|
|
|
424
440
|
summary: async (i, ctx) => {
|
|
425
441
|
const a = await orElse(() => this.agents.get(ctx.orgId, i.agentId, ctx.actorAccountId), null);
|
|
426
442
|
const n = named(a?.definition.name ?? i.agentId);
|
|
427
|
-
|
|
443
|
+
let presetName;
|
|
444
|
+
if (i.avatar?.kind === "preset" && !isBuiltinPresetId(i.avatar.id)) {
|
|
445
|
+
const key = i.avatar.id;
|
|
446
|
+
// a summary never fails on a name: a read failure shows the key
|
|
447
|
+
const offered = await orElse(() => this.themes.avatarPresets(ctx.orgId), null);
|
|
448
|
+
const p = offered?.presets.find((x) => x.key === key);
|
|
449
|
+
// the name in both languages (a missing zh already reads as en), else the key
|
|
450
|
+
if (p !== undefined)
|
|
451
|
+
presetName = localized(p.name, key);
|
|
452
|
+
}
|
|
453
|
+
const c = profileChanges(i, ctx.file?.name, presetName);
|
|
428
454
|
return a?.visibility === "private"
|
|
429
455
|
? {
|
|
430
456
|
zh: `修改私有智能体「${n}」的资料:${c.zh.join(";")}`,
|
|
@@ -776,6 +802,7 @@ AgentsOperations = __decorate([
|
|
|
776
802
|
__param(7, Inject(ConnectorsService)),
|
|
777
803
|
__param(8, Inject(ReadinessService)),
|
|
778
804
|
__param(9, Inject(KernelDb)),
|
|
779
|
-
__param(10, Inject(AttachmentsService))
|
|
805
|
+
__param(10, Inject(AttachmentsService)),
|
|
806
|
+
__param(11, Inject(ThemesService))
|
|
780
807
|
], AgentsOperations);
|
|
781
808
|
export { AgentsOperations };
|
|
@@ -11,7 +11,7 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { DeviceProjectsService } from "../../devices/device-projects.service.js";
|
|
13
13
|
import { DevicesService } from "../../devices/devices.service.js";
|
|
14
|
-
import { DeviceNameBody, DeviceNetworkBody, DeviceParams, DeviceProjectAddBody, DeviceProjectParams, } from "../../devices/dto.js";
|
|
14
|
+
import { DeviceCreateBody, DeviceNameBody, DeviceNetworkBody, DeviceParams, DeviceProjectAddBody, DeviceProjectParams, } from "../../devices/dto.js";
|
|
15
15
|
import { deviceLabel } from "../../devices/label.js";
|
|
16
16
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
17
17
|
import { rootConversationOf } from "../../runtime/subagents/child.js";
|
|
@@ -20,19 +20,15 @@ import { PlatformOperations } from "../registry.js";
|
|
|
20
20
|
import { precheckBy, viaAgent } from "./errors.js";
|
|
21
21
|
import { named, orElse } from "./summary.js";
|
|
22
22
|
const DeviceId = z.object({ deviceId: DeviceParams.shape.id }).strict();
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Model-facing names are English: the default is "Personal", a default demoted by a provider
|
|
26
|
-
* switch "Personal (Docker sandbox)" (the web shows 「个人设备」 / 「个人设备(Docker 沙箱)」).
|
|
27
|
-
*/
|
|
23
|
+
/** Model-facing names are English: the default is "Personal" (the web shows its localized label). */
|
|
28
24
|
const labelOf = (e) => deviceLabel(e, "en");
|
|
29
25
|
/** A row's state: why it cannot be used now, else whether its instance runs. */
|
|
30
26
|
function stateOf(e) {
|
|
31
27
|
if (!e.available) {
|
|
32
28
|
return {
|
|
33
29
|
state: "unavailable",
|
|
34
|
-
reason: "Its
|
|
35
|
-
next: "Ask an org admin; use another device meanwhile.",
|
|
30
|
+
reason: "Its device provider is off in this org or not installed; its files are kept until it is back.",
|
|
31
|
+
next: "Ask an org admin to switch its provider back on; use another device meanwhile.",
|
|
36
32
|
};
|
|
37
33
|
}
|
|
38
34
|
if (e.filesLost && e.source === "local") {
|
|
@@ -123,7 +119,7 @@ let DevicesOperations = class DevicesOperations {
|
|
|
123
119
|
this.registry.register([
|
|
124
120
|
defineOperation({
|
|
125
121
|
id: "devices.list",
|
|
126
|
-
description: "List your own devices in this org: one compact row each (name, state, whether it is the default, source: cloud or local, provider, whether a local one is online and its machine, last use), plus the default and last used ids
|
|
122
|
+
description: "List your own devices in this org: one compact row each (name, state, whether it is the default, source: cloud or local, provider, whether a local one is online and its machine, last use), plus the default and last used ids, the device providers on in this org (a new device may name one) and the default provider (null: a new device must name one). The default device is shown as Personal. A device stays on the provider it was created on; while that provider is off it is unavailable.",
|
|
127
123
|
input: z.object({}).strict(),
|
|
128
124
|
example: {},
|
|
129
125
|
authz: { orgAction: "agents.use" },
|
|
@@ -135,7 +131,8 @@ let DevicesOperations = class DevicesOperations {
|
|
|
135
131
|
items: l.items.map(row),
|
|
136
132
|
defaultId: l.defaultId,
|
|
137
133
|
lastUsedId: l.lastUsedId,
|
|
138
|
-
|
|
134
|
+
providers: l.providers,
|
|
135
|
+
defaultProvider: l.defaultProvider,
|
|
139
136
|
};
|
|
140
137
|
},
|
|
141
138
|
}),
|
|
@@ -166,8 +163,8 @@ let DevicesOperations = class DevicesOperations {
|
|
|
166
163
|
}),
|
|
167
164
|
defineOperation({
|
|
168
165
|
id: "devices.create",
|
|
169
|
-
description: "Create a personal cloud device with a name (1-64 characters, unique among yours, case-insensitive). It is ready at once; its instance and files are made on first use.
|
|
170
|
-
input:
|
|
166
|
+
description: "Create a personal cloud device with a name (1-64 characters, unique among yours, case-insensitive) on a device provider: provider is one of the providers devices.list returns; omit it for the org's default provider. The device stays on that provider for life. It is ready at once; its instance and files are made on first use. Devices are limited per person.",
|
|
167
|
+
input: DeviceCreateBody,
|
|
171
168
|
example: { name: "Data analysis" },
|
|
172
169
|
authz: { orgAction: "agents.use" },
|
|
173
170
|
mirrors: ["POST /api/v1/orgs/:orgId/devices"],
|
|
@@ -186,21 +183,25 @@ let DevicesOperations = class DevicesOperations {
|
|
|
186
183
|
next: "This conversation works in it: ask the person to wipe it on the web, or wipe a different one.",
|
|
187
184
|
},
|
|
188
185
|
{
|
|
189
|
-
code: "device.
|
|
186
|
+
code: "device.provider_required",
|
|
190
187
|
next: {
|
|
191
|
-
superAdmin: "
|
|
192
|
-
orgAdmin: "
|
|
193
|
-
member: "
|
|
188
|
+
superAdmin: "Call again naming one of the providers in the message as provider, or set a default device provider in the admin console; with none on, install and switch one on under extensions.",
|
|
189
|
+
orgAdmin: "Call again naming one of the providers in the message as provider, or choose the org's default device provider in the org settings.",
|
|
190
|
+
member: "Call again naming one of the providers in the message as provider; with none listed, ask an org admin to switch one on.",
|
|
194
191
|
},
|
|
195
192
|
},
|
|
193
|
+
{
|
|
194
|
+
code: "validation_failed",
|
|
195
|
+
next: "Name a provider devices.list returns under providers, or omit provider for the default one.",
|
|
196
|
+
},
|
|
196
197
|
],
|
|
197
|
-
precheck: (i, ctx) => precheckBy(() => this.devices.checkCreate(ctx.orgId, ctx.actorAccountId, i.name)),
|
|
198
|
+
precheck: (i, ctx) => precheckBy(() => this.devices.checkCreate(ctx.orgId, ctx.actorAccountId, i.name, i.provider)),
|
|
198
199
|
summary: (i) => ({
|
|
199
|
-
zh: `新建个人云端设备「${named(i.name)}
|
|
200
|
-
en: `Create personal cloud device "${named(i.name)}"`,
|
|
200
|
+
zh: `新建个人云端设备「${named(i.name)}」${i.provider === undefined ? "" : `(${i.provider})`}`,
|
|
201
|
+
en: `Create personal cloud device "${named(i.name)}"${i.provider === undefined ? "" : ` on ${i.provider}`}`,
|
|
201
202
|
}),
|
|
202
203
|
run: async (input, ctx) => {
|
|
203
|
-
const e = await this.devices.create(ctx.orgId, ctx.actorAccountId, { name: input.name }, undefined, viaAgent("devices.create", ctx));
|
|
204
|
+
const e = await this.devices.create(ctx.orgId, ctx.actorAccountId, { name: input.name, ...(input.provider !== undefined && { provider: input.provider }) }, undefined, viaAgent("devices.create", ctx));
|
|
204
205
|
return { device: row(e) };
|
|
205
206
|
},
|
|
206
207
|
}),
|
|
@@ -462,6 +463,10 @@ let DevicesOperations = class DevicesOperations {
|
|
|
462
463
|
code: "device.project_path_unreadable",
|
|
463
464
|
next: "Pass a directory the device can read (not a file).",
|
|
464
465
|
},
|
|
466
|
+
{
|
|
467
|
+
code: "device.project_refused",
|
|
468
|
+
next: "The device's provider refused this directory (its reason is in the message): pick another directory.",
|
|
469
|
+
},
|
|
465
470
|
{
|
|
466
471
|
code: "device.projects_unsupported",
|
|
467
472
|
next: "This device offers no projects: work without one, or ask the person to update capybara-device.",
|
|
@@ -28,7 +28,7 @@ let ThemesOperations = class ThemesOperations {
|
|
|
28
28
|
this.registry.register([
|
|
29
29
|
defineOperation({
|
|
30
30
|
id: "themes.list",
|
|
31
|
-
description: "List the themes on in this org (id, version, name, schemes, logo, decoration (the sign-in page background pattern: dither or none), background (the page background color per scheme) and the bg / panel / ink / accent swatches per scheme), the theme in effect for you here (resolved; null is the built-in theme) and the org's setting (its default theme id, null following the platform, and whether personal picks are allowed or locked). Use a theme id with platform.set-preferences to change your own theme, or with org-settings.update to change the org's default.",
|
|
31
|
+
description: "List the themes on in this org (id, version, name, schemes, logo, decoration (the sign-in page background pattern: dither or none), background (the page background color per scheme) and the bg / panel / ink / accent swatches per scheme), the theme in effect for you here (resolved; null is the built-in theme) and the org's setting (its default theme id, null following the platform, and whether personal picks are allowed or locked), and avatars: the agent avatar presets of the org's default theme (hidden: the built-in preset ids it does not offer; presets: its own presets, each with a key, a name and a url). Use a preset key as the avatar id with agents.update-profile. Use a theme id with platform.set-preferences to change your own theme, or with org-settings.update to change the org's default.",
|
|
32
32
|
input: z.object({}).strict(),
|
|
33
33
|
example: {},
|
|
34
34
|
authz: { orgAction: "org.read" },
|
|
@@ -17,6 +17,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
17
17
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
18
18
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
19
19
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
20
|
+
import { untilAborted } from "../until-aborted.js";
|
|
20
21
|
import { latestPluginContexts, pluginContextIdemKey } from "./context/plugin-context.js";
|
|
21
22
|
import { runEndedIn } from "./run-status.js";
|
|
22
23
|
const sha256 = (text) => createHash("sha256").update(text).digest("hex");
|
|
@@ -206,15 +207,3 @@ PluginContextService = __decorate([
|
|
|
206
207
|
__param(5, Inject(KERNEL_LOGGER))
|
|
207
208
|
], PluginContextService);
|
|
208
209
|
export { PluginContextService };
|
|
209
|
-
/** `p`, or a rejection once `signal` aborts (a provider that ignores its signal never holds a run). */
|
|
210
|
-
function untilAborted(p, signal) {
|
|
211
|
-
return new Promise((resolve, reject) => {
|
|
212
|
-
const onAbort = () => reject(signal.reason);
|
|
213
|
-
if (signal.aborted) {
|
|
214
|
-
onAbort();
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
218
|
-
p.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
|
|
219
|
-
});
|
|
220
|
-
}
|
|
@@ -8,7 +8,7 @@ import { PermissionAuthorityLock } from "./permission-authority-lock.js";
|
|
|
8
8
|
import { PermissionCeilingWrites } from "./permission-ceiling-writes.js";
|
|
9
9
|
import { PermissionConfigPublication } from "./permission-config-publication.js";
|
|
10
10
|
import { PermissionFacts } from "./permission-facts.js";
|
|
11
|
-
import {
|
|
11
|
+
import { DeviceProviders } from "./providers.js";
|
|
12
12
|
/**
|
|
13
13
|
* What a snapshot or reconciliation found: `unprobed` (no instance or file system yet: the next
|
|
14
14
|
* create applies the desired limits exactly), `bound` (the recorded applied limits are exactly
|
|
@@ -91,7 +91,7 @@ export declare class CloudPermissionSnapshots {
|
|
|
91
91
|
private readonly providers;
|
|
92
92
|
constructor(db: KernelDb, txHost: TransactionHost, leases: SandboxLeases, locks: PermissionAuthorityLock, config: Pick<KernelConfigService, "get" | "fieldSource">, facts: PermissionFacts, publication: Pick<PermissionConfigPublication, "assertCurrent">, ceilings: Pick<PermissionCeilingWrites, "publishLocked">, retirement: Pick<LegacyRetirementStore, "assertCutoverBarrier">,
|
|
93
93
|
/** Whether a device's provider fixes limits at its file system (B-12 intersection). */
|
|
94
|
-
providers: Pick<
|
|
94
|
+
providers: Pick<DeviceProviders, "forDevice">);
|
|
95
95
|
/**
|
|
96
96
|
* The production driver (B-10, `capybara permissions cutover snapshot`): snapshots every live
|
|
97
97
|
* cloud device that has none yet, one device at a time, each under its exclusive lifecycle
|
|
@@ -23,7 +23,7 @@ import { PermissionAuthorityLock } from "./permission-authority-lock.js";
|
|
|
23
23
|
import { needsFullCeiling, PermissionCeilingWrites } from "./permission-ceiling-writes.js";
|
|
24
24
|
import { PermissionConfigPublication } from "./permission-config-publication.js";
|
|
25
25
|
import { PermissionFacts } from "./permission-facts.js";
|
|
26
|
-
import {
|
|
26
|
+
import { DeviceProviders } from "./providers.js";
|
|
27
27
|
/** How long the writer waits for the device's exclusive lifecycle lease (running commands). */
|
|
28
28
|
const LEASE_WAIT_MS = 120_000;
|
|
29
29
|
/** Devices the driver reads per page. */
|
|
@@ -295,7 +295,7 @@ let CloudPermissionSnapshots = class CloudPermissionSnapshots {
|
|
|
295
295
|
// the desired limits)
|
|
296
296
|
const inForce = (instance.handle !== null &&
|
|
297
297
|
(instance.status === "running" || instance.status === "suspended")) ||
|
|
298
|
-
|
|
298
|
+
this.providers.forDevice(device.provider)?.impl.limitsApplyAt === "fileSystem";
|
|
299
299
|
if (inForce && rec.applied !== null && device.owner_full_access !== null) {
|
|
300
300
|
const outer = device.outer_network ?? { kind: "open-public", hosts: [] };
|
|
301
301
|
const narrowed = cloudSnapshotOf({ mode: device.owner_full_access ? "auto" : "sandbox", network: outer }, rec.applied);
|
|
@@ -409,7 +409,7 @@ CloudPermissionSnapshots = __decorate([
|
|
|
409
409
|
__param(6, Inject(PermissionConfigPublication)),
|
|
410
410
|
__param(7, Inject(PermissionCeilingWrites)),
|
|
411
411
|
__param(8, Inject(LegacyRetirementStore)),
|
|
412
|
-
__param(9, Inject(
|
|
412
|
+
__param(9, Inject(DeviceProviders))
|
|
413
413
|
], CloudPermissionSnapshots);
|
|
414
414
|
export { CloudPermissionSnapshots };
|
|
415
415
|
/**
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type DeviceRef, type DeviceReport } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
|
+
import { LockService } from "../infra/lock/lock.service.js";
|
|
5
|
+
import type { KernelLogger } from "../log.js";
|
|
6
|
+
import type { DeviceProviderEntry } from "./providers.js";
|
|
7
|
+
/** How long a provider's `report` may take before the refresh gives up (keeps the stored one). */
|
|
8
|
+
export declare const DEVICE_REPORT_TIMEOUT_MS = 10000;
|
|
9
|
+
/** Overrides {@link DEVICE_REPORT_TIMEOUT_MS} (ms; tests only). */
|
|
10
|
+
export declare const DEVICE_REPORT_TIMEOUT: unique symbol;
|
|
11
|
+
/**
|
|
12
|
+
* The stored device report (`devices.report`, `report_at`; device-provider spec §6.1): what a
|
|
13
|
+
* device's provider last told about it (`device-provider@1` `report()`), shown to people and never
|
|
14
|
+
* used for enforcement. {@link refresh} asks the provider and stores the answer; request paths
|
|
15
|
+
* {@link read} the stored copy from PG and never call the provider.
|
|
16
|
+
*/
|
|
17
|
+
export declare class DeviceReports {
|
|
18
|
+
private readonly db;
|
|
19
|
+
readonly txHost: TransactionHost;
|
|
20
|
+
private readonly locks;
|
|
21
|
+
private readonly log;
|
|
22
|
+
private readonly timeoutMs;
|
|
23
|
+
constructor(db: KernelDb, txHost: TransactionHost, locks: Pick<LockService, "lease">, log: Pick<KernelLogger, "warn">, timeoutMs?: number);
|
|
24
|
+
/**
|
|
25
|
+
* Asks `entry` for the report of `ref`'s device (given up after {@link DEVICE_REPORT_TIMEOUT_MS}
|
|
26
|
+
* or on `signal`, even when the provider ignores its signal), checks it ({@link parseDeviceReport}) and stores it with `report_at`, only
|
|
27
|
+
* while the device is live and still bound to `entry` (`devices.provider = entry.plugin`).
|
|
28
|
+
* `changed`: the stored revision differs from the one before (true for a first report). Never
|
|
29
|
+
* throws: a failing or invalid answer leaves the stored report as it was and is logged at most
|
|
30
|
+
* once per device per hour; an abort of `signal` is not logged. Call it outside any transaction
|
|
31
|
+
* (the provider call must not hold one open).
|
|
32
|
+
*/
|
|
33
|
+
refresh(entry: DeviceProviderEntry, ref: DeviceRef, signal: AbortSignal): Promise<{
|
|
34
|
+
changed: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* The stored report of a live device of `orgId`, checked again ({@link parseDeviceReport});
|
|
38
|
+
* null when none is stored, the stored one no longer passes, or there is no such device.
|
|
39
|
+
* Reads PG only.
|
|
40
|
+
*/
|
|
41
|
+
read(orgId: string, deviceId: string): Promise<DeviceReport | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Writes `report` on the device if it is live and bound to `plugin`; whether its revision
|
|
44
|
+
* differs from the stored one. The row is locked first, so two refreshes of one device compare
|
|
45
|
+
* against each other's writes, never against the same old value.
|
|
46
|
+
*/
|
|
47
|
+
private store;
|
|
48
|
+
/** Logs a refresh failure, at most once per device per hour (a Redis key with a TTL). */
|
|
49
|
+
private noteFailure;
|
|
50
|
+
}
|