@capybara-hq/kernel 0.1.0-rc.106 → 0.1.0-rc.108
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 +13 -13
- package/dist/admin/admin.schemas.d.ts +3 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +4 -3
- package/dist/channels/file-delivery.d.ts +26 -11
- package/dist/channels/file-delivery.js +32 -11
- package/dist/channels/outbound.d.ts +3 -3
- package/dist/channels/outbound.js +15 -13
- package/dist/config/schema.d.ts +3 -0
- package/dist/config/schema.js +12 -0
- package/dist/conversations/artifacts.d.ts +20 -17
- package/dist/conversations/artifacts.js +30 -37
- package/dist/conversations/attachments.controller.d.ts +6 -19
- package/dist/conversations/attachments.controller.js +8 -59
- package/dist/conversations/attachments.service.d.ts +30 -74
- package/dist/conversations/attachments.service.js +51 -193
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/conversations.service.d.ts +10 -9
- package/dist/conversations/conversations.service.js +28 -11
- package/dist/conversations/event-log.d.ts +1 -0
- package/dist/conversations/events.d.ts +49 -27
- package/dist/conversations/events.js +54 -7
- package/dist/conversations/files.d.ts +66 -64
- package/dist/conversations/files.js +127 -147
- package/dist/conversations/prompt-suggestion-request.js +2 -1
- package/dist/conversations/prompt-suggestions.d.ts +3 -3
- package/dist/conversations/prompt-suggestions.js +11 -10
- package/dist/conversations/queue.service.js +7 -2
- package/dist/ctx/create-ctx.d.ts +3 -1
- package/dist/ctx/create-ctx.js +19 -1
- package/dist/db/kernel-schema.d.ts +80 -2
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +19 -0
- package/dist/evals/canonical-json.d.ts +7 -0
- package/dist/evals/canonical-json.js +21 -0
- package/dist/evals/reconstruct.js +13 -1
- package/dist/evals/recorded-tools.d.ts +0 -2
- package/dist/evals/recorded-tools.js +1 -16
- package/dist/evals/snapshot.d.ts +26 -3
- package/dist/evals/snapshot.js +110 -57
- package/dist/evals/worker.d.ts +4 -3
- package/dist/evals/worker.js +8 -4
- package/dist/extensions/host.d.ts +3 -1
- package/dist/extensions/host.js +2 -0
- package/dist/extensions/instance.d.ts +3 -1
- package/dist/extensions/instance.js +4 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/files/blob-objects.d.ts +124 -0
- package/dist/files/blob-objects.js +341 -0
- package/dist/files/blob-sweep.job.d.ts +122 -0
- package/dist/files/blob-sweep.job.js +389 -0
- package/dist/files/blobs.service.d.ts +135 -0
- package/dist/files/blobs.service.js +300 -0
- package/dist/files/conversation-media.d.ts +41 -0
- package/dist/files/conversation-media.js +124 -0
- package/dist/files/deliveries.d.ts +64 -0
- package/dist/files/deliveries.js +156 -0
- package/dist/files/deliveries.module.d.ts +6 -0
- package/dist/files/deliveries.module.js +24 -0
- package/dist/files/draft-cleanup.job.d.ts +26 -0
- package/dist/files/draft-cleanup.job.js +93 -0
- package/dist/files/files.module.d.ts +1 -1
- package/dist/files/files.module.js +3 -2
- package/dist/files/hash-job.d.ts +127 -0
- package/dist/files/hash-job.js +447 -0
- package/dist/files/library-backfill.d.ts +63 -0
- package/dist/files/library-backfill.js +143 -0
- package/dist/files/library-files.service.d.ts +255 -0
- package/dist/files/library-files.service.js +883 -0
- package/dist/files/library-jobs.module.d.ts +8 -0
- package/dist/files/library-jobs.module.js +27 -0
- package/dist/files/library-query.d.ts +127 -0
- package/dist/files/library-query.js +322 -0
- package/dist/files/library-read.module.d.ts +9 -0
- package/dist/files/library-read.module.js +30 -0
- package/dist/files/library.controller.d.ts +77 -0
- package/dist/files/library.controller.js +235 -0
- package/dist/files/library.module.d.ts +9 -0
- package/dist/files/library.module.js +29 -0
- package/dist/files/library.schemas.d.ts +46 -0
- package/dist/files/library.schemas.js +49 -0
- package/dist/files/previewers.controller.d.ts +20 -0
- package/dist/files/previewers.controller.js +47 -0
- package/dist/files/previewers.d.ts +25 -11
- package/dist/files/previewers.js +43 -27
- package/dist/files/referenced-files.d.ts +150 -0
- package/dist/files/referenced-files.js +234 -0
- package/dist/html/html-document.controller.d.ts +8 -1
- package/dist/html/html-document.controller.js +19 -1
- package/dist/html/html-document.service.d.ts +19 -4
- package/dist/html/html-document.service.js +43 -22
- package/dist/html/html-token.d.ts +10 -1
- package/dist/html/html-token.js +14 -0
- package/dist/html/html.module.js +8 -1
- package/dist/http/api.module.js +5 -0
- package/dist/identity/settings.d.ts +26 -0
- package/dist/identity/settings.js +33 -2
- package/dist/infra/outbox/registry.d.ts +82 -0
- package/dist/infra/outbox/registry.js +74 -2
- package/dist/infra/throttler/named-throttlers.d.ts +2 -0
- package/dist/infra/throttler/named-throttlers.js +14 -0
- package/dist/lifecycle/kernel-lifecycle.js +6 -0
- package/dist/models/purposes.js +1 -1
- package/dist/orgs/offboarding.js +1 -1
- package/dist/orgs/settings.service.d.ts +48 -2
- package/dist/orgs/settings.service.js +63 -3
- package/dist/platform/exclusions.js +45 -8
- package/dist/platform/file-ref.d.ts +18 -3
- package/dist/platform/file-ref.js +22 -11
- package/dist/platform/operation.js +4 -0
- package/dist/platform/ops/admin.ops.js +5 -2
- package/dist/platform/ops/files.ops.d.ts +18 -0
- package/dist/platform/ops/files.ops.js +267 -0
- package/dist/platform/ops/org-settings.ops.js +6 -2
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/shares.ops.js +2 -2
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +5 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker.module.js +15 -1
- package/dist/runtime/compaction-settings.service.d.ts +13 -1
- package/dist/runtime/compaction-settings.service.js +16 -1
- package/dist/runtime/compaction.service.d.ts +3 -1
- package/dist/runtime/compaction.service.js +3 -1
- package/dist/runtime/context/build.d.ts +18 -1
- package/dist/runtime/context/build.js +19 -8
- package/dist/runtime/context/cache-expiry.d.ts +31 -0
- package/dist/runtime/context/cache-expiry.js +60 -0
- package/dist/runtime/context/cache-ttl.d.ts +18 -0
- package/dist/runtime/context/cache-ttl.js +30 -0
- package/dist/runtime/context/compaction.d.ts +9 -2
- package/dist/runtime/context/compaction.js +50 -17
- package/dist/runtime/context/in-context-compaction.d.ts +156 -0
- package/dist/runtime/context/in-context-compaction.js +310 -0
- package/dist/runtime/hook-calls.d.ts +2 -1
- package/dist/runtime/hook-calls.js +5 -2
- package/dist/runtime/maintenance.d.ts +10 -2
- package/dist/runtime/maintenance.js +48 -8
- package/dist/runtime/model-call.d.ts +34 -5
- package/dist/runtime/model-call.js +207 -22
- package/dist/runtime/providers.js +11 -1
- package/dist/runtime/run-steps.d.ts +4 -2
- package/dist/runtime/run-steps.js +10 -5
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/shares/liveness.d.ts +26 -12
- package/dist/shares/liveness.js +79 -20
- package/dist/shares/revoke.d.ts +16 -11
- package/dist/shares/revoke.js +18 -14
- package/dist/shares/share-objects.d.ts +16 -21
- package/dist/shares/share-objects.js +25 -55
- package/dist/shares/share-open.service.d.ts +8 -4
- package/dist/shares/share-open.service.js +14 -11
- package/dist/shares/shares.controller.d.ts +16 -5
- package/dist/shares/shares.controller.js +39 -5
- package/dist/shares/shares.module.d.ts +4 -4
- package/dist/shares/shares.module.js +7 -6
- package/dist/shares/shares.schemas.d.ts +4 -0
- package/dist/shares/shares.schemas.js +2 -0
- package/dist/shares/shares.service.d.ts +93 -54
- package/dist/shares/shares.service.js +292 -131
- package/dist/shares/sweep.job.d.ts +18 -39
- package/dist/shares/sweep.job.js +47 -206
- package/dist/tools/builtins/artifacts.d.ts +21 -13
- package/dist/tools/builtins/artifacts.js +81 -51
- package/dist/tools/builtins/builtin-tools.d.ts +7 -1
- package/dist/tools/builtins/builtin-tools.js +17 -6
- package/dist/tools/builtins/conversation-files.d.ts +23 -13
- package/dist/tools/builtins/conversation-files.js +62 -83
- package/dist/tools/builtins/image/generate.d.ts +7 -1
- package/dist/tools/builtins/image/generate.js +1 -1
- package/dist/tools/builtins/platform.js +1 -0
- package/dist/tools/builtins/sandbox/common.d.ts +6 -2
- package/dist/tools/builtins/sandbox/deliver.js +6 -7
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +6 -5
- package/dist/tools/builtins/sandbox/fetch-attachment.js +19 -12
- package/dist/tools/tools.module.js +6 -0
- package/dist/ui/call-extension.d.ts +6 -4
- package/dist/ui/call-extension.js +5 -4
- package/dist/ui/embed-token.js +6 -3
- package/dist/ui/registry.d.ts +21 -5
- package/dist/ui/registry.js +24 -6
- package/dist/ui/ui.schemas.d.ts +22 -0
- package/dist/ui/ui.schemas.js +22 -4
- package/dist/ui/views.controller.d.ts +13 -3
- package/dist/ui/views.controller.js +33 -2
- package/dist/ui/views.d.ts +29 -1
- package/dist/ui/views.js +131 -7
- package/package.json +3 -3
- package/src/migrations/0190_file_library.sql +285 -0
- package/src/migrations/0191_file_library_copy.sql +4 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SandboxLimits } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { type PlatformAttribution } from "../attribution/platform-attribution.js";
|
|
4
4
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
5
5
|
import type { ExtensionPointDefaults } from "../extensions/point-defaults.js";
|
|
6
|
-
import { type CompactionSettings } from "../identity/settings.js";
|
|
6
|
+
import { type CompactionSettings, type PromptCacheSettings } from "../identity/settings.js";
|
|
7
7
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
8
8
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
9
9
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -49,6 +49,8 @@ import { OrgLock } from "./org-lock.js";
|
|
|
49
49
|
* absent (or an invalid stored value) = follow the platform, personal picks allowed.
|
|
50
50
|
* - `uiArrangement`: per slot, the extension contributions the org hides and their order (UI slots
|
|
51
51
|
* spec §5); a slot with no entry follows the platform's; an invalid stored value reads as absent.
|
|
52
|
+
* - `navigation`: where the org's plugin pages sit in the navigation (`pluginPages`: per contribution
|
|
53
|
+
* key the section an admin chose, at most 3 primary); absent follows each page's `nav` suggestion.
|
|
52
54
|
* - `gitGateway`: the org's git gateway switch and host sources (sandbox git credentials spec §9);
|
|
53
55
|
* not in the PATCH yet; an invalid stored value reads as `{ enabled: false }` (fails closed).
|
|
54
56
|
*/
|
|
@@ -140,6 +142,24 @@ export declare const GIT_GATEWAY_INVALID: {
|
|
|
140
142
|
readonly enabled: false;
|
|
141
143
|
};
|
|
142
144
|
export type GitGatewaySetting = z.infer<typeof GitGatewaySettingSchema>;
|
|
145
|
+
/** At most this many plugin pages in the primary navigation (plugin full pages spec §9). */
|
|
146
|
+
export declare const NAV_PRIMARY_MAX = 3;
|
|
147
|
+
/**
|
|
148
|
+
* The org's placement of plugin pages in the navigation (plugin full pages spec §9): per
|
|
149
|
+
* contribution key `<plugin>/<id>` the section an org admin chose. A page with no entry follows
|
|
150
|
+
* the contribution's `nav` suggestion (default `more`). Replaced whole by the PATCH; at most
|
|
151
|
+
* {@link NAV_PRIMARY_MAX} entries with section `primary`.
|
|
152
|
+
*/
|
|
153
|
+
export declare const NavigationSettingSchema: z.ZodObject<{
|
|
154
|
+
pluginPages: z.ZodArray<z.ZodObject<{
|
|
155
|
+
contribution: z.ZodString;
|
|
156
|
+
section: z.ZodEnum<{
|
|
157
|
+
more: "more";
|
|
158
|
+
primary: "primary";
|
|
159
|
+
}>;
|
|
160
|
+
}, z.core.$strict>>;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
export type NavigationSetting = z.infer<typeof NavigationSettingSchema>;
|
|
143
163
|
/** Whether prompt suggestions run for an org: the platform is on and the org has not turned it off. */
|
|
144
164
|
export declare function effectivePromptSuggestions(platform: "on" | "off", org: "on" | "off" | undefined): boolean;
|
|
145
165
|
export declare const OrgSettingsSchema: z.ZodObject<{
|
|
@@ -191,6 +211,15 @@ export declare const OrgSettingsSchema: z.ZodObject<{
|
|
|
191
211
|
}>;
|
|
192
212
|
}, z.core.$strict>>>;
|
|
193
213
|
uiArrangement: z.ZodCatch<z.ZodOptional<z.ZodType<Partial<Record<"agent.detail.section" | "conversation.composer.frame" | "conversation.empty" | "conversation.panel" | "conversation.properties.section" | "conversation.tool-result.card" | "file.preview" | "org.page" | "org.settings.section" | "platform.page" | "shell.brand" | "shell.overlay", import("../ui/arrangement.js").UiArrangementEntry>>, unknown, z.core.$ZodTypeInternals<Partial<Record<"agent.detail.section" | "conversation.composer.frame" | "conversation.empty" | "conversation.panel" | "conversation.properties.section" | "conversation.tool-result.card" | "file.preview" | "org.page" | "org.settings.section" | "platform.page" | "shell.brand" | "shell.overlay", import("../ui/arrangement.js").UiArrangementEntry>>, unknown>>>>;
|
|
214
|
+
navigation: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
215
|
+
pluginPages: z.ZodArray<z.ZodObject<{
|
|
216
|
+
contribution: z.ZodString;
|
|
217
|
+
section: z.ZodEnum<{
|
|
218
|
+
more: "more";
|
|
219
|
+
primary: "primary";
|
|
220
|
+
}>;
|
|
221
|
+
}, z.core.$strict>>;
|
|
222
|
+
}, z.core.$strict>>>;
|
|
194
223
|
gitGateway: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
195
224
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
196
225
|
hostSources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -221,6 +250,9 @@ export declare const OrgSettingsSchema: z.ZodObject<{
|
|
|
221
250
|
reserveTokens: z.ZodOptional<z.ZodNumber>;
|
|
222
251
|
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
223
252
|
}, z.core.$strip>>>;
|
|
253
|
+
promptCache: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
254
|
+
longTtl: z.ZodOptional<z.ZodBoolean>;
|
|
255
|
+
}, z.core.$strip>>>;
|
|
224
256
|
externalSharing: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
225
257
|
off: "off";
|
|
226
258
|
on: "on";
|
|
@@ -292,6 +324,15 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
|
|
|
292
324
|
}>;
|
|
293
325
|
}, z.core.$strict>>>;
|
|
294
326
|
uiArrangement: z.ZodOptional<z.ZodType<Partial<Record<"agent.detail.section" | "conversation.composer.frame" | "conversation.empty" | "conversation.panel" | "conversation.properties.section" | "conversation.tool-result.card" | "file.preview" | "org.page" | "org.settings.section" | "platform.page" | "shell.brand" | "shell.overlay", import("../ui/arrangement.js").UiArrangementEntry | null>>, unknown, z.core.$ZodTypeInternals<Partial<Record<"agent.detail.section" | "conversation.composer.frame" | "conversation.empty" | "conversation.panel" | "conversation.properties.section" | "conversation.tool-result.card" | "file.preview" | "org.page" | "org.settings.section" | "platform.page" | "shell.brand" | "shell.overlay", import("../ui/arrangement.js").UiArrangementEntry | null>>, unknown>>>;
|
|
327
|
+
navigation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
328
|
+
pluginPages: z.ZodArray<z.ZodObject<{
|
|
329
|
+
contribution: z.ZodString;
|
|
330
|
+
section: z.ZodEnum<{
|
|
331
|
+
more: "more";
|
|
332
|
+
primary: "primary";
|
|
333
|
+
}>;
|
|
334
|
+
}, z.core.$strict>>;
|
|
335
|
+
}, z.core.$strict>>>;
|
|
295
336
|
automations: z.ZodOptional<z.ZodObject<{
|
|
296
337
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
297
338
|
minIntervalMinutes: z.ZodOptional<z.ZodNumber>;
|
|
@@ -318,6 +359,9 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
|
|
|
318
359
|
reserveTokens: z.ZodOptional<z.ZodNumber>;
|
|
319
360
|
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
320
361
|
}, z.core.$strict>>>;
|
|
362
|
+
promptCache: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
363
|
+
longTtl: z.ZodOptional<z.ZodBoolean>;
|
|
364
|
+
}, z.core.$strict>>>;
|
|
321
365
|
externalSharing: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
322
366
|
off: "off";
|
|
323
367
|
on: "on";
|
|
@@ -373,6 +417,8 @@ export interface OrgSettingsDeployment {
|
|
|
373
417
|
publicUrl: boolean;
|
|
374
418
|
/** The platform's conversation compaction settings (what "follow the platform" means). */
|
|
375
419
|
compaction: CompactionSettings;
|
|
420
|
+
/** The platform's prompt cache settings (what "follow the platform" means). */
|
|
421
|
+
promptCache: PromptCacheSettings;
|
|
376
422
|
/** The platform's external sharing switch and its source (deny: the org cannot turn it on). */
|
|
377
423
|
externalSharing: ExternalSharingView;
|
|
378
424
|
/** The longest expiry a share may take, in days. */
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
+
import { UI_CONTRIBUTION_KEY_RE } from "@capybara-hq/plugin-sdk";
|
|
10
11
|
import { Inject, Injectable, Module, Optional } from "@nestjs/common";
|
|
11
12
|
import { ModuleRef } from "@nestjs/core";
|
|
12
13
|
import { z } from "zod";
|
|
@@ -14,7 +15,7 @@ import { readPlatformAttribution, } from "../attribution/platform-attribution.js
|
|
|
14
15
|
import { DeviceProviderName } from "../devices/default-provider-setting.js";
|
|
15
16
|
import { ApiError } from "../errors.js";
|
|
16
17
|
import { audit } from "../identity/audit.js";
|
|
17
|
-
import { COMPACTION_SETTINGS_PARTIAL, COMPACTION_SETTINGS_PATCH, readPlatformCompactionSettings, readPromptSuggestions, readSandboxLimitOverride, } from "../identity/settings.js";
|
|
18
|
+
import { COMPACTION_SETTINGS_PARTIAL, COMPACTION_SETTINGS_PATCH, PROMPT_CACHE_SETTINGS_PARTIAL, PROMPT_CACHE_SETTINGS_PATCH, readPlatformCompactionSettings, readPlatformPromptCacheSettings, readPromptSuggestions, readSandboxLimitOverride, } from "../identity/settings.js";
|
|
18
19
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
19
20
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
20
21
|
import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
|
|
@@ -66,6 +67,8 @@ import { OrgLock, OrgLockModule } from "./org-lock.js";
|
|
|
66
67
|
* absent (or an invalid stored value) = follow the platform, personal picks allowed.
|
|
67
68
|
* - `uiArrangement`: per slot, the extension contributions the org hides and their order (UI slots
|
|
68
69
|
* spec §5); a slot with no entry follows the platform's; an invalid stored value reads as absent.
|
|
70
|
+
* - `navigation`: where the org's plugin pages sit in the navigation (`pluginPages`: per contribution
|
|
71
|
+
* key the section an admin chose, at most 3 primary); absent follows each page's `nav` suggestion.
|
|
69
72
|
* - `gitGateway`: the org's git gateway switch and host sources (sandbox git credentials spec §9);
|
|
70
73
|
* not in the PATCH yet; an invalid stored value reads as `{ enabled: false }` (fails closed).
|
|
71
74
|
*/
|
|
@@ -165,6 +168,31 @@ export const GitGatewaySettingSchema = z.object({
|
|
|
165
168
|
});
|
|
166
169
|
/** What an invalid stored `gitGateway` reads as: the gateway off for the org. */
|
|
167
170
|
export const GIT_GATEWAY_INVALID = { enabled: false };
|
|
171
|
+
/** At most this many plugin pages in the primary navigation (plugin full pages spec §9). */
|
|
172
|
+
export const NAV_PRIMARY_MAX = 3;
|
|
173
|
+
/**
|
|
174
|
+
* The org's placement of plugin pages in the navigation (plugin full pages spec §9): per
|
|
175
|
+
* contribution key `<plugin>/<id>` the section an org admin chose. A page with no entry follows
|
|
176
|
+
* the contribution's `nav` suggestion (default `more`). Replaced whole by the PATCH; at most
|
|
177
|
+
* {@link NAV_PRIMARY_MAX} entries with section `primary`.
|
|
178
|
+
*/
|
|
179
|
+
export const NavigationSettingSchema = z
|
|
180
|
+
.object({
|
|
181
|
+
pluginPages: z
|
|
182
|
+
.array(z
|
|
183
|
+
.object({
|
|
184
|
+
contribution: z
|
|
185
|
+
.string()
|
|
186
|
+
.regex(UI_CONTRIBUTION_KEY_RE, "must be a contribution key <plugin>/<id>"),
|
|
187
|
+
section: z.enum(["primary", "more"]),
|
|
188
|
+
})
|
|
189
|
+
.strict())
|
|
190
|
+
.max(200)
|
|
191
|
+
.refine((l) => new Set(l.map((e) => e.contribution)).size === l.length, {
|
|
192
|
+
message: "a contribution is listed once",
|
|
193
|
+
}),
|
|
194
|
+
})
|
|
195
|
+
.strict();
|
|
168
196
|
const ExternalSharingSetting = z.enum(["on", "off"]);
|
|
169
197
|
const PromptSuggestionsSetting = z.enum(["on", "off"]);
|
|
170
198
|
/** Whether prompt suggestions run for an org: the platform is on and the org has not turned it off. */
|
|
@@ -191,6 +219,8 @@ export const OrgSettingsSchema = z.object({
|
|
|
191
219
|
theme: OrgThemeSettingSchema.optional().catch(undefined),
|
|
192
220
|
/** Hidden and ordered extension contributions per slot; absent = follow the platform. */
|
|
193
221
|
uiArrangement: UiArrangementSchema.optional().catch(undefined),
|
|
222
|
+
/** Where the org's plugin pages sit in the navigation; absent = follow the suggestions. */
|
|
223
|
+
navigation: NavigationSettingSchema.optional().catch(undefined),
|
|
194
224
|
/** The org's git gateway switch and host sources; absent = on, sources chosen by default. */
|
|
195
225
|
gitGateway: GitGatewaySettingSchema.optional().catch({ ...GIT_GATEWAY_INVALID }),
|
|
196
226
|
/** Automations (spec §9); the platform bounds clamp it, see `effectiveAutomationSettings`. */
|
|
@@ -200,6 +230,8 @@ export const OrgSettingsSchema = z.object({
|
|
|
200
230
|
* rest follow the platform; absent (or an invalid stored value) follows the platform entirely.
|
|
201
231
|
*/
|
|
202
232
|
compaction: COMPACTION_SETTINGS_PARTIAL.optional().catch(undefined),
|
|
233
|
+
/** Prompt cache override (idle compaction spec): absent or invalid follows the platform. */
|
|
234
|
+
promptCache: PROMPT_CACHE_SETTINGS_PARTIAL.optional().catch(undefined),
|
|
203
235
|
/**
|
|
204
236
|
* The org's external sharing switch (file sharing spec §8); absent = off. An invalid stored
|
|
205
237
|
* value reads as `off` (never wider). The platform's switch must allow it too.
|
|
@@ -255,6 +287,11 @@ export const OrgSettingsPatchSchema = z
|
|
|
255
287
|
* null removes a slot's entry (it follows the platform again). `platform.page` is refused.
|
|
256
288
|
*/
|
|
257
289
|
uiArrangement: OrgUiArrangementPatchSchema.optional(),
|
|
290
|
+
/**
|
|
291
|
+
* Where the org's plugin pages sit in the navigation, replaced whole; null clears it (every
|
|
292
|
+
* page follows its suggestion). More than 3 primary -> 400 `org_settings.nav_primary_limit`.
|
|
293
|
+
*/
|
|
294
|
+
navigation: NavigationSettingSchema.nullable().optional(),
|
|
258
295
|
/** Fields to change in the automations group; the rest keep their value. */
|
|
259
296
|
automations: AutomationsPatchSchema.optional(),
|
|
260
297
|
/**
|
|
@@ -263,6 +300,8 @@ export const OrgSettingsPatchSchema = z
|
|
|
263
300
|
* (follow the platform again). Strict: a misspelled field is a 400, not a silent no-op.
|
|
264
301
|
*/
|
|
265
302
|
compaction: COMPACTION_SETTINGS_PATCH.nullable().optional(),
|
|
303
|
+
/** Prompt cache override: a partial object merges; null clears it (follow the platform). */
|
|
304
|
+
promptCache: PROMPT_CACHE_SETTINGS_PATCH.nullable().optional(),
|
|
266
305
|
/**
|
|
267
306
|
* The org's external sharing switch; null clears it (off). `on` while the platform denies it
|
|
268
307
|
* -> 400 `org.external_sharing_not_allowed`; through the Platform tool or an API token it may
|
|
@@ -497,10 +536,11 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
497
536
|
/** The deployment defaults (what "follow the platform" means on the settings page). */
|
|
498
537
|
async deployment() {
|
|
499
538
|
const lim = this.config.get().sandbox.limits;
|
|
500
|
-
const [deviceSandbox, attribution, compaction, externalSharing, shareMaxExpiry, promptSuggestions,] = await Promise.all([
|
|
539
|
+
const [deviceSandbox, attribution, compaction, promptCache, externalSharing, shareMaxExpiry, promptSuggestions,] = await Promise.all([
|
|
501
540
|
readDeviceSandboxSettingsView(this.db.db, this.config, this.log),
|
|
502
541
|
readPlatformAttribution(this.db.db, this.config, this.log),
|
|
503
542
|
readPlatformCompactionSettings(this.db.db),
|
|
543
|
+
readPlatformPromptCacheSettings(this.db.db),
|
|
504
544
|
readExternalSharing(this.db.db, this.config, this.log),
|
|
505
545
|
readShareMaxExpiry(this.db.db, this.config, this.log),
|
|
506
546
|
readPromptSuggestions(this.db.db, this.log),
|
|
@@ -516,6 +556,7 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
516
556
|
attribution,
|
|
517
557
|
publicUrl: this.config.get().http.publicUrl !== undefined,
|
|
518
558
|
compaction,
|
|
559
|
+
promptCache,
|
|
519
560
|
externalSharing,
|
|
520
561
|
shareMaxExpiryDays: shareMaxExpiry.value,
|
|
521
562
|
promptSuggestions,
|
|
@@ -587,6 +628,10 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
587
628
|
throw networkNotAllowed(`The platform limits device networks to the allowlist, so the organization's network ${field} cannot be open; a super admin sets devices.network.ceiling`, field);
|
|
588
629
|
}
|
|
589
630
|
}
|
|
631
|
+
const primary = patch.navigation?.pluginPages.filter((e) => e.section === "primary").length;
|
|
632
|
+
if (primary !== undefined && primary > NAV_PRIMARY_MAX) {
|
|
633
|
+
throw new ApiError("org_settings.nav_primary_limit", `At most ${NAV_PRIMARY_MAX} plugin pages can be in the primary navigation`, [{ path: "navigation.pluginPages" }]);
|
|
634
|
+
}
|
|
590
635
|
if (patch.externalSharing === "on") {
|
|
591
636
|
const platform = await readExternalSharing(this.db.db, this.config, this.log);
|
|
592
637
|
if (platform.value !== "allow") {
|
|
@@ -711,6 +756,8 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
711
756
|
.map(([k, v]) => [k, v === null ? undefined : v]));
|
|
712
757
|
const arrangementPatch = patch.uiArrangement;
|
|
713
758
|
const compactionPatch = patch.compaction;
|
|
759
|
+
const promptCachePatch = patch.promptCache;
|
|
760
|
+
delete changes.promptCache;
|
|
714
761
|
delete changes.uiArrangement;
|
|
715
762
|
delete changes.automations;
|
|
716
763
|
delete changes.compaction;
|
|
@@ -728,6 +775,12 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
728
775
|
else
|
|
729
776
|
after.compaction = { ...before.compaction, ...compactionPatch };
|
|
730
777
|
}
|
|
778
|
+
if (promptCachePatch !== undefined) {
|
|
779
|
+
if (promptCachePatch === null)
|
|
780
|
+
delete after.promptCache;
|
|
781
|
+
else
|
|
782
|
+
after.promptCache = { ...before.promptCache, ...promptCachePatch };
|
|
783
|
+
}
|
|
731
784
|
if (arrangementPatch !== undefined) {
|
|
732
785
|
after.uiArrangement = mergeArrangement(before.uiArrangement, arrangementPatch);
|
|
733
786
|
if (Object.keys(after.uiArrangement).length === 0)
|
|
@@ -752,6 +805,8 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
752
805
|
delete after.theme;
|
|
753
806
|
if (after.uiArrangement === undefined)
|
|
754
807
|
delete after.uiArrangement;
|
|
808
|
+
if (after.navigation === undefined)
|
|
809
|
+
delete after.navigation;
|
|
755
810
|
if (after.gitGateway === undefined)
|
|
756
811
|
delete after.gitGateway;
|
|
757
812
|
// an empty compaction override is the same as none: follow the platform
|
|
@@ -760,6 +815,11 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
760
815
|
}
|
|
761
816
|
if (after.compaction === undefined)
|
|
762
817
|
delete after.compaction;
|
|
818
|
+
if (after.promptCache !== undefined && Object.keys(after.promptCache).length === 0) {
|
|
819
|
+
delete after.promptCache;
|
|
820
|
+
}
|
|
821
|
+
if (after.promptCache === undefined)
|
|
822
|
+
delete after.promptCache;
|
|
763
823
|
if (after.externalSharing === undefined)
|
|
764
824
|
delete after.externalSharing;
|
|
765
825
|
if (after.promptSuggestions === undefined)
|
|
@@ -776,7 +836,7 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
776
836
|
}
|
|
777
837
|
// Merge with the stored value: keep the keys this version does not know (a cleared
|
|
778
838
|
// outsideSandbox / deviceNetwork is not kept; the old keys are rewritten in step)
|
|
779
|
-
const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, deviceDefaultProvider: _oldDeviceProvider, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, automations: _oldAutomations, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
|
|
839
|
+
const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, deviceDefaultProvider: _oldDeviceProvider, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, navigation: _oldNavigation, automations: _oldAutomations, compaction: _oldCompaction, promptCache: _oldPromptCache, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
|
|
780
840
|
const written = { ...rest, ...after };
|
|
781
841
|
keepOrgLegacyKeysInStep(written, stored);
|
|
782
842
|
// An unreadable forbiddenTools reads as [] for display only: a write that does not replace the
|
|
@@ -193,22 +193,43 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
193
193
|
reason: "Confirms a staged plugin review (reached by the link card of the staged plugin), a trust decision by the person",
|
|
194
194
|
},
|
|
195
195
|
// channels
|
|
196
|
-
//
|
|
196
|
+
// files (the composer's upload helpers; list, details, usage, add and delete are operations)
|
|
197
197
|
{
|
|
198
|
-
route: "GET /api/v1/orgs/:orgId/
|
|
198
|
+
route: "GET /api/v1/orgs/:orgId/files/limits",
|
|
199
199
|
category: "internal",
|
|
200
|
-
reason: "The composer's size check for a person's file into a conversation; an agent gets files by file reference, not by
|
|
200
|
+
reason: "The composer's size check for a person's file into a conversation; an agent gets files by file reference, not by uploading",
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
|
-
route: "
|
|
203
|
+
route: "DELETE /api/v1/orgs/:orgId/files/:id/draft",
|
|
204
204
|
category: "internal",
|
|
205
|
-
reason: "
|
|
205
|
+
reason: "Composer housekeeping: drops a draft the person removed before sending; an agent never holds a draft",
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
|
-
route: "
|
|
209
|
-
category: "
|
|
210
|
-
reason: "
|
|
208
|
+
route: "GET /api/v1/orgs/:orgId/files/:id/content",
|
|
209
|
+
category: "transport",
|
|
210
|
+
reason: "Serves a library file's text bytes for the Files page's preview",
|
|
211
211
|
},
|
|
212
|
+
{
|
|
213
|
+
route: "GET /api/v1/orgs/:orgId/files/:id/download",
|
|
214
|
+
category: "transport",
|
|
215
|
+
reason: "Serves a library file's bytes",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
route: "GET /api/v1/orgs/:orgId/files/:id/previewers",
|
|
219
|
+
category: "transport",
|
|
220
|
+
reason: "Previewer lookup feeding the Files page's viewer",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
route: "GET /api/v1/orgs/:orgId/files/:id/previews/:plugin/:previewerId",
|
|
224
|
+
category: "transport",
|
|
225
|
+
reason: "Serves a rendered library file preview",
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
route: "POST /api/v1/orgs/:orgId/files/:id/html-token",
|
|
229
|
+
category: "transport",
|
|
230
|
+
reason: "Mints the HTML document's load token for the Files page",
|
|
231
|
+
},
|
|
232
|
+
// attachments
|
|
212
233
|
{
|
|
213
234
|
route: "GET /api/v1/orgs/:orgId/attachments/:id/download",
|
|
214
235
|
category: "transport",
|
|
@@ -356,6 +377,17 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
356
377
|
category: "internal",
|
|
357
378
|
reason: "The right panel's per-file view; conversations.list-shares lists the same shares",
|
|
358
379
|
},
|
|
380
|
+
// shares of library files (file library spec §6)
|
|
381
|
+
{
|
|
382
|
+
route: "POST /api/v1/orgs/:orgId/files/:fileId/shares",
|
|
383
|
+
category: "human-only",
|
|
384
|
+
reason: "Publishing a file outside the library is a person's act",
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
route: "GET /api/v1/orgs/:orgId/files/:fileId/shares",
|
|
388
|
+
category: "internal",
|
|
389
|
+
reason: "The Files page's share dialog; conversations.list-shares lists the same shares",
|
|
390
|
+
},
|
|
359
391
|
// the HTML document (file sharing spec §4, §10)
|
|
360
392
|
{
|
|
361
393
|
route: "POST /api/v1/orgs/:orgId/conversations/:id/files/:fileId/html-token",
|
|
@@ -703,6 +735,11 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
703
735
|
category: "transport",
|
|
704
736
|
reason: "Runs an extension UI action from the web app",
|
|
705
737
|
},
|
|
738
|
+
{
|
|
739
|
+
route: "POST /api/v1/orgs/:orgId/ui/query/:plugin/:id",
|
|
740
|
+
category: "transport",
|
|
741
|
+
reason: "the web's channel for plugin components; agents use the plugin's tools",
|
|
742
|
+
},
|
|
706
743
|
{
|
|
707
744
|
route: "POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token",
|
|
708
745
|
category: "transport",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AttachmentsService } from "../conversations/attachments.service.js";
|
|
3
|
+
import { ReferencedFiles } from "../files/referenced-files.js";
|
|
3
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
|
-
import { StorageService } from "../storage/storage.service.js";
|
|
5
5
|
/**
|
|
6
6
|
* File references (platform web parity spec §5): a `Platform` write the web does with an upload
|
|
7
7
|
* takes a file the agent already has instead, a conversation file (`fileId`: an attachment, a
|
|
@@ -22,6 +22,14 @@ export declare const FileRefSchema: z.ZodType<FileRef>;
|
|
|
22
22
|
export interface FileLimits {
|
|
23
23
|
maxBytes: number;
|
|
24
24
|
contentTypes?: readonly string[];
|
|
25
|
+
/** A lower byte limit per content type (normalized), e.g. images smaller than documents. */
|
|
26
|
+
typeMaxBytes?: Readonly<Record<string, number>>;
|
|
27
|
+
/**
|
|
28
|
+
* `true`: a library file of an account other than the context's `actorAccountId` is refused
|
|
29
|
+
* ({@link OTHERS_FILE_TEXT}): a file has one owner (file library spec §2). A `read` copy is no
|
|
30
|
+
* library file and stays allowed.
|
|
31
|
+
*/
|
|
32
|
+
ownFilesOnly?: boolean;
|
|
25
33
|
}
|
|
26
34
|
/** A resolved reference: the bytes and what the card shows of them. */
|
|
27
35
|
export interface ResolvedFile {
|
|
@@ -48,6 +56,8 @@ export interface FileRefContext {
|
|
|
48
56
|
conversationId: string;
|
|
49
57
|
/** The root of the conversation tree, from the call's context. */
|
|
50
58
|
rootConversationId: string;
|
|
59
|
+
/** The account the call acts as (checked by {@link FileLimits.ownFilesOnly}). */
|
|
60
|
+
actorAccountId?: string;
|
|
51
61
|
signal: AbortSignal;
|
|
52
62
|
}
|
|
53
63
|
/** Ruling R9: the thumbnail's longest edge, quality and the most the data URL may take. */
|
|
@@ -63,6 +73,8 @@ export declare const THUMBNAIL_MAX_INPUT_PIXELS = 40000000;
|
|
|
63
73
|
export declare const fileTooLargeText: (size: number, max: number) => string;
|
|
64
74
|
/** Model-visible: the referenced file's type is not one the operation takes. */
|
|
65
75
|
export declare const fileTypeText: (contentType: string, types: readonly string[]) => string;
|
|
76
|
+
/** Model-visible: the referenced library file is another account's ({@link FileLimits.ownFilesOnly}). */
|
|
77
|
+
export declare const OTHERS_FILE_TEXT = "This file belongs to another person; ask them to add it to their files.";
|
|
66
78
|
/** Model-visible: the bytes at run time differ from the ones the person confirmed. */
|
|
67
79
|
export declare const FILE_CHANGED_TEXT = "The file changed after the person confirmed it; call the operation again.";
|
|
68
80
|
/** The card's view of a resolved file, with a thumbnail for an image (R9). */
|
|
@@ -83,8 +95,11 @@ export declare function thumbnailOf(file: Pick<ResolvedFile, "contentType" | "by
|
|
|
83
95
|
export declare class FileRefs {
|
|
84
96
|
private readonly db;
|
|
85
97
|
private readonly attachments;
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
/** The library files the conversation set refers to (file library spec §2). */
|
|
99
|
+
private readonly files;
|
|
100
|
+
constructor(db: KernelDb, attachments: AttachmentsService,
|
|
101
|
+
/** The library files the conversation set refers to (file library spec §2). */
|
|
102
|
+
files: ReferencedFiles);
|
|
88
103
|
resolve(ref: FileRef, limits: FileLimits, ctx: FileRefContext): Promise<ResolvedFile>;
|
|
89
104
|
private conversationFile;
|
|
90
105
|
}
|
|
@@ -13,8 +13,8 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
13
13
|
import sharp from "sharp";
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
import { AttachmentsService, normalizeContentType, sniffMatches, } from "../conversations/attachments.service.js";
|
|
16
|
+
import { ReferencedFiles } from "../files/referenced-files.js";
|
|
16
17
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
17
|
-
import { StorageService } from "../storage/storage.service.js";
|
|
18
18
|
import { findConversationFile } from "../tools/builtins/conversation-files.js";
|
|
19
19
|
/** Model-visible: a device path where a file reference is expected. */
|
|
20
20
|
export const FILE_REF_PATH_TEXT = "Deliver the file first, then pass its fileId.";
|
|
@@ -44,6 +44,8 @@ const THUMBNAIL_TYPES = new Set(["image/png", "image/jpeg", "image/webp", "image
|
|
|
44
44
|
export const fileTooLargeText = (size, max) => `The file is ${size} bytes; this operation takes at most ${max}.`;
|
|
45
45
|
/** Model-visible: the referenced file's type is not one the operation takes. */
|
|
46
46
|
export const fileTypeText = (contentType, types) => `The file is ${contentType}; this operation takes ${types.join(", ")}.`;
|
|
47
|
+
/** Model-visible: the referenced library file is another account's ({@link FileLimits.ownFilesOnly}). */
|
|
48
|
+
export const OTHERS_FILE_TEXT = "This file belongs to another person; ask them to add it to their files.";
|
|
47
49
|
/** Model-visible: the bytes at run time differ from the ones the person confirmed. */
|
|
48
50
|
export const FILE_CHANGED_TEXT = "The file changed after the person confirmed it; call the operation again.";
|
|
49
51
|
const notFoundText = (id) => `File ${id} is not a file of this conversation. Pass the id of an attachment, a generated image or a delivered file of this conversation, or Deliver a device file first and pass its fileId.`;
|
|
@@ -100,11 +102,13 @@ export async function thumbnailOf(file) {
|
|
|
100
102
|
let FileRefs = class FileRefs {
|
|
101
103
|
db;
|
|
102
104
|
attachments;
|
|
103
|
-
|
|
104
|
-
constructor(db, attachments,
|
|
105
|
+
files;
|
|
106
|
+
constructor(db, attachments,
|
|
107
|
+
/** The library files the conversation set refers to (file library spec §2). */
|
|
108
|
+
files) {
|
|
105
109
|
this.db = db;
|
|
106
110
|
this.attachments = attachments;
|
|
107
|
-
this.
|
|
111
|
+
this.files = files;
|
|
108
112
|
}
|
|
109
113
|
async resolve(ref, limits, ctx) {
|
|
110
114
|
const got = await this.conversationFile(ref.fileId, limits, ctx);
|
|
@@ -119,7 +123,7 @@ let FileRefs = class FileRefs {
|
|
|
119
123
|
}
|
|
120
124
|
async conversationFile(id, limits, ctx) {
|
|
121
125
|
const db = this.db.db;
|
|
122
|
-
const file = await findConversationFile({ db, attachments: this.attachments,
|
|
126
|
+
const file = await findConversationFile({ db, attachments: this.attachments, files: this.files }, {
|
|
123
127
|
orgId: ctx.orgId,
|
|
124
128
|
conversationId: ctx.conversationId,
|
|
125
129
|
rootConversationId: ctx.rootConversationId,
|
|
@@ -130,20 +134,27 @@ let FileRefs = class FileRefs {
|
|
|
130
134
|
});
|
|
131
135
|
if (file === null)
|
|
132
136
|
throw new ToolError(notFoundText(id));
|
|
133
|
-
if (
|
|
137
|
+
if (limits.ownFilesOnly === true &&
|
|
138
|
+
file.accountId !== undefined &&
|
|
139
|
+
file.accountId !== ctx.actorAccountId) {
|
|
134
140
|
await file.discard();
|
|
135
|
-
throw new ToolError(
|
|
141
|
+
throw new ToolError(OTHERS_FILE_TEXT);
|
|
136
142
|
}
|
|
137
143
|
const types = limits.contentTypes;
|
|
138
144
|
const declared = normalizeContentType(file.contentType);
|
|
145
|
+
const max = Math.min(limits.maxBytes, limits.typeMaxBytes?.[declared] ?? limits.maxBytes);
|
|
146
|
+
if (file.size > max) {
|
|
147
|
+
await file.discard();
|
|
148
|
+
throw new ToolError(fileTooLargeText(file.size, max));
|
|
149
|
+
}
|
|
139
150
|
if (types !== undefined && !types.includes(declared)) {
|
|
140
151
|
await file.discard();
|
|
141
152
|
throw new ToolError(fileTypeText(declared, types));
|
|
142
153
|
}
|
|
143
|
-
const bytes = await file.open({ maxBytes:
|
|
144
|
-
if (bytes.byteLength >
|
|
154
|
+
const bytes = await file.open({ maxBytes: max + 1 });
|
|
155
|
+
if (bytes.byteLength > max) {
|
|
145
156
|
await file.discard();
|
|
146
|
-
throw new ToolError(fileTooLargeText(bytes.byteLength,
|
|
157
|
+
throw new ToolError(fileTooLargeText(bytes.byteLength, max));
|
|
147
158
|
}
|
|
148
159
|
// the bytes must be what the type says (the upload routes sniff the same way)
|
|
149
160
|
if (types !== undefined && !sniffMatches(declared, bytes.subarray(0, 4096))) {
|
|
@@ -157,6 +168,6 @@ FileRefs = __decorate([
|
|
|
157
168
|
Injectable(),
|
|
158
169
|
__param(0, Inject(KernelDb)),
|
|
159
170
|
__param(1, Inject(AttachmentsService)),
|
|
160
|
-
__param(2, Inject(
|
|
171
|
+
__param(2, Inject(ReferencedFiles))
|
|
161
172
|
], FileRefs);
|
|
162
173
|
export { FileRefs };
|
|
@@ -47,6 +47,10 @@ export const PLATFORM_DOMAINS = [
|
|
|
47
47
|
id: "conversations",
|
|
48
48
|
description: "Your own conversations: list, read, rename, archive, delete, read their events, list and stop their background tasks, list and revoke shared file links.",
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
id: "files",
|
|
52
|
+
description: "Your file library (uploads and the files agents delivered to you): list, read, storage usage, adding a file of this conversation, and asking to delete one (the person confirms on the Files page).",
|
|
53
|
+
},
|
|
50
54
|
{
|
|
51
55
|
id: "orgs",
|
|
52
56
|
description: "This org (read, rename, members and invitations, its audit log) and, for the super admin, every org and its limits.",
|
|
@@ -52,6 +52,7 @@ const SettingsInput = DEPLOYMENT_SETTINGS_PATCH.pick({
|
|
|
52
52
|
externalSharing: true,
|
|
53
53
|
shareMaxExpiryDays: true,
|
|
54
54
|
promptSuggestions: true,
|
|
55
|
+
promptCache: true,
|
|
55
56
|
htmlRenderCdnAllowlist: true,
|
|
56
57
|
}).strict();
|
|
57
58
|
/** `login-sources.update`: the source and the fields to change. */
|
|
@@ -251,7 +252,7 @@ let AdminOperations = class AdminOperations {
|
|
|
251
252
|
}),
|
|
252
253
|
defineOperation({
|
|
253
254
|
id: "admin.update-settings",
|
|
254
|
-
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.",
|
|
255
|
+
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. promptCache ({ longTtl }: true or false; whether requests use the model's prompt cache tier of at least 30 minutes, such as 1 hour, where cache writes cost more; an org may override it) may be set either way. Per-org limits are orgs.set-limits.",
|
|
255
256
|
input: SettingsInput.refine((b) => Object.keys(b).length > 0, {
|
|
256
257
|
message: "at least one setting is required",
|
|
257
258
|
}),
|
|
@@ -315,7 +316,7 @@ let AdminOperations = class AdminOperations {
|
|
|
315
316
|
});
|
|
316
317
|
},
|
|
317
318
|
summary: async (i) => {
|
|
318
|
-
const { uiTheme, uiArrangement, clientExtensions, devicesOutsideSandbox, devicesNetwork, devicesDefaultProvider, attribution, htmlRenderCdnAllowlist, ...rest } = i;
|
|
319
|
+
const { uiTheme, uiArrangement, clientExtensions, devicesOutsideSandbox, devicesNetwork, devicesDefaultProvider, attribution, htmlRenderCdnAllowlist, promptCache, ...rest } = i;
|
|
319
320
|
const parts = Object.entries(rest).map(([k, v]) => `${k}=${String(v)}`);
|
|
320
321
|
if (htmlRenderCdnAllowlist !== undefined) {
|
|
321
322
|
parts.push(`htmlRenderCdnAllowlist=[${htmlRenderCdnAllowlist.join(", ")}]`);
|
|
@@ -330,6 +331,8 @@ let AdminOperations = class AdminOperations {
|
|
|
330
331
|
}
|
|
331
332
|
if (devicesDefaultProvider !== undefined)
|
|
332
333
|
parts.push(`devicesDefaultProvider=${String(devicesDefaultProvider.provider)}`);
|
|
334
|
+
if (promptCache?.longTtl !== undefined)
|
|
335
|
+
parts.push(`promptCache.longTtl=${String(promptCache.longTtl)}`);
|
|
333
336
|
const zh = [...parts];
|
|
334
337
|
const en = [...parts];
|
|
335
338
|
if (attribution !== undefined) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { LibraryFilesService } from "../../files/library-files.service.js";
|
|
3
|
+
import { LibraryQuery } from "../../files/library-query.js";
|
|
4
|
+
import { PlatformOperations } from "../registry.js";
|
|
5
|
+
/**
|
|
6
|
+
* File library operations of the `Platform` tool (file library spec §6, §8): the person's own
|
|
7
|
+
* files, as the Files page shows them. Bytes, previews and the HTML document stay with the web
|
|
8
|
+
* (`transport` exclusions); deleting a file is confirmed by the person on the Files page, so
|
|
9
|
+
* `files.delete` only checks the file and hands them the link. `files.add` is the upload routes
|
|
10
|
+
* with a file reference in place of the bytes (platform web parity spec §5).
|
|
11
|
+
*/
|
|
12
|
+
export declare class FilesOperations implements OnModuleInit {
|
|
13
|
+
private readonly registry;
|
|
14
|
+
private readonly library;
|
|
15
|
+
private readonly files;
|
|
16
|
+
constructor(registry: PlatformOperations, library: LibraryQuery, files: LibraryFilesService);
|
|
17
|
+
onModuleInit(): void;
|
|
18
|
+
}
|