@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/admin.schemas.d.ts +3 -0
- package/dist/agents/agents.schemas.d.ts +9 -9
- package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
- package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
- package/dist/automations/automations.module.d.ts +16 -0
- package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
- package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
- package/dist/automations/automations.schemas.js +253 -0
- package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
- package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
- package/dist/{schedules → automations}/calendar.d.ts +8 -8
- package/dist/{schedules → automations}/calendar.js +2 -2
- package/dist/automations/effective-settings.d.ts +28 -0
- package/dist/automations/effective-settings.js +25 -0
- package/dist/automations/errors.d.ts +19 -0
- package/dist/automations/errors.js +19 -0
- package/dist/automations/events/coalesce.d.ts +28 -0
- package/dist/automations/events/coalesce.js +131 -0
- package/dist/automations/events/deadline.d.ts +10 -0
- package/dist/automations/events/deadline.js +24 -0
- package/dist/automations/events/dispatcher.d.ts +74 -0
- package/dist/automations/events/dispatcher.js +353 -0
- package/dist/automations/events/events.module.d.ts +7 -0
- package/dist/automations/events/events.module.js +26 -0
- package/dist/automations/events/guards.d.ts +32 -0
- package/dist/automations/events/guards.js +87 -0
- package/dist/automations/events/sweep.job.d.ts +49 -0
- package/dist/automations/events/sweep.job.js +202 -0
- package/dist/automations/events/token.d.ts +5 -0
- package/dist/automations/events/token.js +5 -0
- package/dist/automations/events/trigger-events.service.d.ts +47 -0
- package/dist/automations/events/trigger-events.service.js +254 -0
- package/dist/{schedules → automations}/fire.d.ts +57 -17
- package/dist/{schedules → automations}/fire.js +311 -79
- package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
- package/dist/{schedules → automations}/grant-rules.js +5 -5
- package/dist/automations/job-ids.d.ts +113 -0
- package/dist/automations/job-ids.js +117 -0
- package/dist/{schedules → automations}/pause.d.ts +3 -3
- package/dist/{schedules → automations}/pause.js +3 -3
- package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
- package/dist/{schedules → automations}/run-tracker.js +68 -56
- package/dist/{schedules → automations}/scan.job.d.ts +12 -8
- package/dist/{schedules → automations}/scan.job.js +39 -23
- package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
- package/dist/{schedules → automations}/schedule-math.js +17 -7
- package/dist/{schedules → automations}/store.d.ts +57 -27
- package/dist/{schedules → automations}/store.js +102 -52
- package/dist/automations/store.module.d.ts +6 -0
- package/dist/{schedules → automations}/store.module.js +9 -9
- package/dist/automations/types.d.ts +178 -0
- package/dist/{schedules → automations}/unattended.d.ts +22 -11
- package/dist/{schedules → automations}/unattended.js +53 -30
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +7 -6
- package/dist/channels/file-delivery.d.ts +26 -11
- package/dist/channels/file-delivery.js +32 -11
- package/dist/channels/outbound.d.ts +8 -8
- package/dist/channels/outbound.js +32 -30
- package/dist/channels/threads.d.ts +1 -1
- package/dist/channels/threads.js +1 -1
- package/dist/config/schema.d.ts +8 -1
- package/dist/config/schema.js +56 -6
- package/dist/conversations/approval-profile.d.ts +2 -2
- package/dist/conversations/approval-profile.js +3 -3
- 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.controller.d.ts +7 -1
- package/dist/conversations/conversations.controller.js +26 -10
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/conversations.service.d.ts +112 -35
- package/dist/conversations/conversations.service.js +160 -43
- package/dist/conversations/event-log.d.ts +1 -0
- package/dist/conversations/events.d.ts +95 -27
- package/dist/conversations/events.js +108 -10
- package/dist/conversations/files.d.ts +66 -64
- package/dist/conversations/files.js +127 -147
- package/dist/conversations/message-context.d.ts +2 -2
- package/dist/conversations/message-context.js +1 -1
- package/dist/conversations/permission-profile-store.d.ts +2 -1
- package/dist/conversations/permission-profiles.controller.d.ts +3 -0
- package/dist/conversations/permission-profiles.service.js +1 -1
- package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
- package/dist/conversations/prompt-suggestion-request.js +4 -2
- package/dist/conversations/prompt-suggestions.d.ts +3 -3
- package/dist/conversations/prompt-suggestions.js +11 -10
- package/dist/conversations/queue.d.ts +7 -4
- package/dist/conversations/queue.js +6 -2
- package/dist/conversations/queue.service.d.ts +5 -5
- package/dist/conversations/queue.service.js +27 -16
- package/dist/ctx/create-ctx.d.ts +23 -2
- package/dist/ctx/create-ctx.js +78 -3
- package/dist/db/kernel-schema.d.ts +184 -27
- package/dist/devices/device-project-files.service.d.ts +88 -0
- package/dist/devices/device-project-files.service.js +249 -0
- package/dist/devices/device-projects.service.d.ts +40 -0
- package/dist/devices/device-projects.service.js +16 -13
- package/dist/devices/devices.controller.d.ts +9 -3
- package/dist/devices/devices.controller.js +27 -5
- package/dist/devices/devices.module.js +9 -1
- package/dist/devices/devices.schemas.js +6 -1
- package/dist/devices/dto.d.ts +15 -0
- package/dist/devices/dto.js +11 -0
- package/dist/devices/project-paths.d.ts +29 -0
- package/dist/devices/project-paths.js +66 -0
- package/dist/devices/project-rules.d.ts +5 -1
- package/dist/devices/project-rules.js +5 -1
- package/dist/errors.d.ts +53 -13
- package/dist/errors.js +53 -13
- package/dist/evals/canonical-json.d.ts +7 -0
- package/dist/evals/canonical-json.js +21 -0
- package/dist/evals/reconstruct.d.ts +10 -1
- package/dist/evals/reconstruct.js +20 -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 +9 -2
- package/dist/extensions/host.js +12 -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/extensions/permission-set.d.ts +17 -1
- package/dist/extensions/permission-set.js +13 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +4 -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/git/gateway.js +2 -2
- 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 +10 -5
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- package/dist/identity/settings.d.ts +26 -0
- package/dist/identity/settings.js +33 -2
- package/dist/inbox/inbox.module.js +2 -2
- package/dist/inbox/inbox.service.d.ts +8 -8
- package/dist/inbox/inbox.service.js +7 -7
- package/dist/infra/config/kernel-config.service.js +10 -5
- package/dist/infra/outbox/registry.d.ts +111 -2
- package/dist/infra/outbox/registry.js +104 -9
- package/dist/infra/throttler/named-throttlers.d.ts +2 -0
- package/dist/infra/throttler/named-throttlers.js +14 -0
- package/dist/kernel.module.js +3 -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/roles.d.ts +1 -1
- package/dist/orgs/roles.js +3 -3
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +75 -13
- package/dist/orgs/settings.service.js +104 -26
- 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 +6 -2
- package/dist/platform/ops/admin.ops.js +5 -2
- package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
- package/dist/platform/ops/automations.ops.js +560 -0
- package/dist/platform/ops/devices.ops.d.ts +3 -1
- package/dist/platform/ops/devices.ops.js +77 -3
- package/dist/platform/ops/files.ops.d.ts +18 -0
- package/dist/platform/ops/files.ops.js +267 -0
- package/dist/platform/ops/inbox.ops.js +4 -4
- package/dist/platform/ops/org-settings.ops.js +6 -2
- package/dist/platform/ops/orgs.ops.js +2 -1
- package/dist/platform/ops/platform.ops.js +4 -4
- package/dist/platform/ops/shares.ops.js +2 -2
- package/dist/platform/platform-ops.module.d.ts +3 -2
- package/dist/platform/platform-ops.module.js +10 -5
- package/dist/platform/route-schemas.js +6 -3
- package/dist/push/jobs.d.ts +3 -3
- package/dist/push/jobs.js +2 -2
- package/dist/push/preferences.service.js +1 -1
- package/dist/push/push-owed.d.ts +3 -3
- package/dist/push/push-owed.js +6 -6
- package/dist/push/push.schemas.d.ts +4 -4
- package/dist/push/push.schemas.js +3 -3
- package/dist/push/recipients.d.ts +4 -4
- package/dist/push/recipients.js +23 -23
- package/dist/push/texts.d.ts +3 -3
- package/dist/push/texts.js +2 -2
- package/dist/push/triggers.d.ts +1 -1
- package/dist/roles/worker.module.js +18 -4
- 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 +24 -1
- package/dist/runtime/context/build.js +33 -11
- 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 +64 -21
- package/dist/runtime/context/in-context-compaction.d.ts +156 -0
- package/dist/runtime/context/in-context-compaction.js +310 -0
- package/dist/runtime/context/run-context.d.ts +38 -0
- package/dist/runtime/context/run-context.js +54 -0
- package/dist/runtime/hook-calls.d.ts +2 -1
- package/dist/runtime/hook-calls.js +5 -2
- package/dist/runtime/maintenance.d.ts +16 -4
- package/dist/runtime/maintenance.js +79 -18
- 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-finish.d.ts +4 -4
- package/dist/runtime/run-finish.js +3 -3
- package/dist/runtime/run-queue.js +12 -7
- package/dist/runtime/run-steps.d.ts +4 -2
- package/dist/runtime/run-steps.js +10 -5
- package/dist/runtime/run-worker.js +7 -1
- package/dist/runtime/runtime.module.js +6 -3
- package/dist/runtime/subagents/dispatch.js +11 -3
- package/dist/sandbox/browse-roots.d.ts +8 -0
- package/dist/sandbox/browse-roots.js +22 -0
- package/dist/sandbox/network-grants.d.ts +4 -4
- package/dist/sandbox/network-grants.js +7 -7
- package/dist/sandbox/operation-authority.d.ts +10 -3
- package/dist/sandbox/operation-authority.js +20 -10
- package/dist/sandbox/operation-intents.d.ts +3 -1
- package/dist/sandbox/operation-intents.js +11 -4
- package/dist/sandbox/permission-call-grants.js +2 -2
- package/dist/sandbox/permission-facts.js +1 -1
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +22 -11
- package/dist/sandbox/review/permission-candidate.d.ts +1 -1
- package/dist/sandbox/review/permission-candidate.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +15 -5
- package/dist/sandbox/sandbox.service.js +14 -8
- 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/storage/purge.d.ts +1 -1
- package/dist/storage/purge.js +2 -2
- package/dist/tools/approvals.service.d.ts +6 -6
- package/dist/tools/approvals.service.js +19 -19
- package/dist/tools/builtin-names.d.ts +12 -12
- package/dist/tools/builtin-names.js +29 -29
- package/dist/tools/builtins/artifacts.d.ts +21 -13
- package/dist/tools/builtins/artifacts.js +81 -51
- package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
- package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
- package/dist/tools/builtins/builtin-tools.d.ts +15 -9
- package/dist/tools/builtins/builtin-tools.js +33 -22
- 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/call-scope.d.ts +1 -1
- package/dist/tools/git-asks.js +1 -1
- package/dist/tools/git-push-policy.d.ts +3 -3
- package/dist/tools/git-push-policy.js +6 -6
- package/dist/tools/network-asks.d.ts +3 -3
- package/dist/tools/network-asks.js +3 -3
- package/dist/tools/pipeline.d.ts +4 -4
- package/dist/tools/pipeline.js +2 -2
- package/dist/tools/policy.d.ts +3 -3
- package/dist/tools/policy.js +3 -3
- package/dist/tools/tools.module.js +15 -9
- 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/0188_automations_rename.sql +309 -0
- package/src/migrations/0189_event_automations.sql +136 -0
- package/src/migrations/0190_file_library.sql +285 -0
- package/src/migrations/0191_file_library_copy.sql +4 -0
- package/dist/platform/ops/schedules.ops.js +0 -509
- package/dist/schedules/effective-settings.d.ts +0 -22
- package/dist/schedules/effective-settings.js +0 -18
- package/dist/schedules/errors.d.ts +0 -8
- package/dist/schedules/errors.js +0 -8
- package/dist/schedules/job-ids.d.ts +0 -81
- package/dist/schedules/job-ids.js +0 -95
- package/dist/schedules/schedules.module.d.ts +0 -16
- package/dist/schedules/schedules.schemas.js +0 -213
- package/dist/schedules/store.module.d.ts +0 -6
- package/dist/schedules/types.d.ts +0 -110
- /package/dist/{schedules → automations}/types.js +0 -0
package/dist/ui/ui.schemas.d.ts
CHANGED
|
@@ -33,6 +33,13 @@ export declare const ViewQuery: z.ZodObject<{
|
|
|
33
33
|
callId: z.ZodOptional<z.ZodString>;
|
|
34
34
|
key: z.ZodOptional<z.ZodString>;
|
|
35
35
|
}, z.core.$strip>;
|
|
36
|
+
/** The UTF-8 bytes of a value serialized as JSON (the measure of every UI payload limit). */
|
|
37
|
+
export declare const jsonBytes: (v: unknown) => number;
|
|
38
|
+
/**
|
|
39
|
+
* An action's body. `payload` is capped here at the component limit
|
|
40
|
+
* (`UI_LIMITS.componentActionPayloadBytes`); a view's action keeps `UI_LIMITS.payloadBytes`, which
|
|
41
|
+
* `UiViews.act` checks once it knows the contribution's kind.
|
|
42
|
+
*/
|
|
36
43
|
export declare const ActionBody: z.ZodObject<{
|
|
37
44
|
actionId: z.ZodString;
|
|
38
45
|
payload: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -44,6 +51,21 @@ export declare const ActionBody: z.ZodObject<{
|
|
|
44
51
|
zh: "zh";
|
|
45
52
|
}>>;
|
|
46
53
|
}, z.core.$strip>;
|
|
54
|
+
/**
|
|
55
|
+
* `POST query/:plugin/:id`: a component's named query. `params` is any JSON (default `null`), at
|
|
56
|
+
* most `UI_LIMITS.componentQueryParamsBytes` as JSON (checked by the service: 413
|
|
57
|
+
* `ui.query_params_too_large`); the context ids are those of the component's slot, as for an action.
|
|
58
|
+
*/
|
|
59
|
+
export declare const QueryBody: z.ZodObject<{
|
|
60
|
+
query: z.ZodString;
|
|
61
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
62
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
agentId: z.ZodOptional<z.ZodUUID>;
|
|
64
|
+
locale: z.ZodDefault<z.ZodEnum<{
|
|
65
|
+
en: "en";
|
|
66
|
+
zh: "zh";
|
|
67
|
+
}>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
47
69
|
export declare const EmbedTokenBody: z.ZodDefault<z.ZodObject<{
|
|
48
70
|
conversationId: z.ZodOptional<z.ZodString>;
|
|
49
71
|
agentId: z.ZodOptional<z.ZodUUID>;
|
package/dist/ui/ui.schemas.js
CHANGED
|
@@ -33,15 +33,20 @@ const FormAnswerSchema = z
|
|
|
33
33
|
.refine((a) => Object.keys(a).length <= UI_LIMITS.tableRows, {
|
|
34
34
|
message: `answer must have at most ${UI_LIMITS.tableRows} fields`,
|
|
35
35
|
});
|
|
36
|
-
/**
|
|
37
|
-
const
|
|
36
|
+
/** The UTF-8 bytes of a value serialized as JSON (the measure of every UI payload limit). */
|
|
37
|
+
export const jsonBytes = (v) => Buffer.byteLength(JSON.stringify(v) ?? "", "utf8");
|
|
38
|
+
/**
|
|
39
|
+
* An action's body. `payload` is capped here at the component limit
|
|
40
|
+
* (`UI_LIMITS.componentActionPayloadBytes`); a view's action keeps `UI_LIMITS.payloadBytes`, which
|
|
41
|
+
* `UiViews.act` checks once it knows the contribution's kind.
|
|
42
|
+
*/
|
|
38
43
|
export const ActionBody = z.object({
|
|
39
44
|
actionId: z.string().min(1).max(200),
|
|
40
45
|
payload: z
|
|
41
46
|
.unknown()
|
|
42
47
|
.optional()
|
|
43
|
-
.refine((v) => v === undefined ||
|
|
44
|
-
message: `payload must be at most ${UI_LIMITS.
|
|
48
|
+
.refine((v) => v === undefined || jsonBytes(v) <= UI_LIMITS.componentActionPayloadBytes, {
|
|
49
|
+
message: `payload must be at most ${UI_LIMITS.componentActionPayloadBytes} bytes as JSON`,
|
|
45
50
|
}),
|
|
46
51
|
answer: FormAnswerSchema.optional(),
|
|
47
52
|
conversationId: z.string().min(1).max(100).optional(),
|
|
@@ -49,6 +54,19 @@ export const ActionBody = z.object({
|
|
|
49
54
|
agentId: z.uuid().optional(),
|
|
50
55
|
locale: Locale,
|
|
51
56
|
});
|
|
57
|
+
/**
|
|
58
|
+
* `POST query/:plugin/:id`: a component's named query. `params` is any JSON (default `null`), at
|
|
59
|
+
* most `UI_LIMITS.componentQueryParamsBytes` as JSON (checked by the service: 413
|
|
60
|
+
* `ui.query_params_too_large`); the context ids are those of the component's slot, as for an action.
|
|
61
|
+
*/
|
|
62
|
+
export const QueryBody = z.object({
|
|
63
|
+
query: z.string().min(1).max(200),
|
|
64
|
+
params: z.unknown().optional(),
|
|
65
|
+
conversationId: z.string().min(1).max(100).optional(),
|
|
66
|
+
/** Only a component of `agent.detail.section`. */
|
|
67
|
+
agentId: z.uuid().optional(),
|
|
68
|
+
locale: Locale,
|
|
69
|
+
});
|
|
52
70
|
export const EmbedTokenBody = z
|
|
53
71
|
.object({
|
|
54
72
|
conversationId: z.string().min(1).max(100).optional(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UiActionResult, UiView } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import type { JsonValue, UiActionResult, UiView } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
3
3
|
import type { z } from "zod";
|
|
4
4
|
import { ApiTokenService } from "../identity/api-tokens.js";
|
|
@@ -6,7 +6,7 @@ import { type Principal } from "../identity/principal.js";
|
|
|
6
6
|
import { SessionService } from "../identity/sessions.js";
|
|
7
7
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
8
8
|
import { EmbedTokens } from "./embed-token.js";
|
|
9
|
-
import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, ViewQuery } from "./ui.schemas.js";
|
|
9
|
+
import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, QueryBody, ViewQuery } from "./ui.schemas.js";
|
|
10
10
|
import { OrgUiStreams } from "./ui-stream.js";
|
|
11
11
|
import { type UiArrangementSlot, type UiContributionItem, UiViews } from "./views.js";
|
|
12
12
|
export declare const BEARER_RE: RegExp;
|
|
@@ -27,10 +27,17 @@ export declare const embedSrc: (plugin: string, path: string) => string;
|
|
|
27
27
|
* → `{ view }`(`item`: the panel item to scroll to; `callId` / `key`: an inline card's tool call);
|
|
28
28
|
* - `POST /api/v1/orgs/:orgId/ui/actions/:plugin/:id`
|
|
29
29
|
* (`{ actionId, payload?, answer?, conversationId?, agentId?, locale? }`)→ `{ toast }` | `{ view }`;
|
|
30
|
+
* `payload` ≤ `UI_LIMITS.componentActionPayloadBytes` for a component, `payloadBytes` for a view;
|
|
31
|
+
* - `POST /api/v1/orgs/:orgId/ui/query/:plugin/:id` (`{ query, params?, conversationId?, agentId?,
|
|
32
|
+
* locale? }`) → `{ data }`: a component's named query (`ctx.ui.query`, plugin full pages spec
|
|
33
|
+
* §4.1), gated like the component's view; 404 `ui.query_not_found`, 413
|
|
34
|
+
* `ui.query_params_too_large`, 502 `ui.query_failed` / `ui.query_result_too_large`, 504
|
|
35
|
+
* `ui.query_timeout` (10 s);
|
|
30
36
|
* - `GET /api/v1/orgs/:orgId/ui/stream`:组织级刷新 SSE(`event: ui`,`data: {"plugin","contribution"}`),
|
|
31
37
|
* member and above;
|
|
32
38
|
* - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token` (`{ conversationId?, agentId?, fileId? }`,
|
|
33
|
-
*
|
|
39
|
+
* `{ fileId }` alone for a library file's previewer, or for a skill file's previewer
|
|
40
|
+
* `{ skillId, version?, path }`)
|
|
34
41
|
* → `{ token, src: "/plugin-ui/<plugin>/<path without /ui/>", expiresAt, expiresIn }`: an embed
|
|
35
42
|
* token (300 seconds, `expiresIn` in seconds, see `embed-token.ts`; `agentId` goes into the
|
|
36
43
|
* claims, a skill file as `skillFile` with its resolved version). The token is only for the
|
|
@@ -60,6 +67,9 @@ export declare class UiController {
|
|
|
60
67
|
view: UiView;
|
|
61
68
|
}>;
|
|
62
69
|
action(principal: Principal, org: OrgContext, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof ActionBody>): Promise<UiActionResult>;
|
|
70
|
+
query(principal: Principal, org: OrgContext, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof QueryBody>): Promise<{
|
|
71
|
+
data: JsonValue;
|
|
72
|
+
}>;
|
|
63
73
|
embedToken(principal: Principal, org: OrgContext, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof EmbedTokenBody>): Promise<{
|
|
64
74
|
token: string;
|
|
65
75
|
src: string;
|
|
@@ -17,7 +17,7 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
17
17
|
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
18
18
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
19
19
|
import { EMBED_TOKEN_TTL_SECONDS, EmbedTokens } from "./embed-token.js";
|
|
20
|
-
import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, ViewQuery, } from "./ui.schemas.js";
|
|
20
|
+
import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, QueryBody, ViewQuery, } from "./ui.schemas.js";
|
|
21
21
|
import { OrgUiStreams } from "./ui-stream.js";
|
|
22
22
|
import { UiViews } from "./views.js";
|
|
23
23
|
export const BEARER_RE = /^Bearer\s+(\S+)$/i;
|
|
@@ -31,6 +31,8 @@ class UiViewQueryDto extends createZodDto(ViewQuery, "UiViewQuery") {
|
|
|
31
31
|
}
|
|
32
32
|
class UiActionBodyDto extends createZodDto(ActionBody, "UiActionBody") {
|
|
33
33
|
}
|
|
34
|
+
class UiQueryBodyDto extends createZodDto(QueryBody, "UiQueryBody") {
|
|
35
|
+
}
|
|
34
36
|
class UiEmbedTokenBodyDto extends createZodDto(EmbedTokenBody, "UiEmbedTokenBody") {
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
@@ -48,10 +50,17 @@ class UiEmbedTokenBodyDto extends createZodDto(EmbedTokenBody, "UiEmbedTokenBody
|
|
|
48
50
|
* → `{ view }`(`item`: the panel item to scroll to; `callId` / `key`: an inline card's tool call);
|
|
49
51
|
* - `POST /api/v1/orgs/:orgId/ui/actions/:plugin/:id`
|
|
50
52
|
* (`{ actionId, payload?, answer?, conversationId?, agentId?, locale? }`)→ `{ toast }` | `{ view }`;
|
|
53
|
+
* `payload` ≤ `UI_LIMITS.componentActionPayloadBytes` for a component, `payloadBytes` for a view;
|
|
54
|
+
* - `POST /api/v1/orgs/:orgId/ui/query/:plugin/:id` (`{ query, params?, conversationId?, agentId?,
|
|
55
|
+
* locale? }`) → `{ data }`: a component's named query (`ctx.ui.query`, plugin full pages spec
|
|
56
|
+
* §4.1), gated like the component's view; 404 `ui.query_not_found`, 413
|
|
57
|
+
* `ui.query_params_too_large`, 502 `ui.query_failed` / `ui.query_result_too_large`, 504
|
|
58
|
+
* `ui.query_timeout` (10 s);
|
|
51
59
|
* - `GET /api/v1/orgs/:orgId/ui/stream`:组织级刷新 SSE(`event: ui`,`data: {"plugin","contribution"}`),
|
|
52
60
|
* member and above;
|
|
53
61
|
* - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token` (`{ conversationId?, agentId?, fileId? }`,
|
|
54
|
-
*
|
|
62
|
+
* `{ fileId }` alone for a library file's previewer, or for a skill file's previewer
|
|
63
|
+
* `{ skillId, version?, path }`)
|
|
55
64
|
* → `{ token, src: "/plugin-ui/<plugin>/<path without /ui/>", expiresAt, expiresIn }`: an embed
|
|
56
65
|
* token (300 seconds, `expiresIn` in seconds, see `embed-token.ts`; `agentId` goes into the
|
|
57
66
|
* claims, a skill file as `skillFile` with its resolved version). The token is only for the
|
|
@@ -120,6 +129,19 @@ let UiController = class UiController {
|
|
|
120
129
|
...(body.answer !== undefined && { answer: body.answer }),
|
|
121
130
|
});
|
|
122
131
|
}
|
|
132
|
+
async query(principal, org, { plugin, id }, body) {
|
|
133
|
+
const p = requireUser(principal);
|
|
134
|
+
return this.views.query({
|
|
135
|
+
orgId: org.orgId,
|
|
136
|
+
accountId: p.account.id,
|
|
137
|
+
role: org.role,
|
|
138
|
+
plugin,
|
|
139
|
+
id,
|
|
140
|
+
...(body.conversationId !== undefined && { conversationId: body.conversationId }),
|
|
141
|
+
...(body.agentId !== undefined && { agentId: body.agentId }),
|
|
142
|
+
locale: body.locale,
|
|
143
|
+
}, { query: body.query, ...(body.params !== undefined && { params: body.params }) });
|
|
144
|
+
}
|
|
123
145
|
async embedToken(principal, org, { plugin, id }, body) {
|
|
124
146
|
const p = requireUser(principal);
|
|
125
147
|
if ((body.skillId === undefined) !== (body.path === undefined)) {
|
|
@@ -236,6 +258,15 @@ __decorate([
|
|
|
236
258
|
__param(2, ZParam(UiContributionParamsDto)),
|
|
237
259
|
__param(3, ZBody(UiActionBodyDto))
|
|
238
260
|
], UiController.prototype, "action", null);
|
|
261
|
+
__decorate([
|
|
262
|
+
Post("query/:plugin/:id"),
|
|
263
|
+
HttpCode(200),
|
|
264
|
+
OrgAction("ui.use"),
|
|
265
|
+
__param(0, CurrentPrincipal()),
|
|
266
|
+
__param(1, CurrentOrg()),
|
|
267
|
+
__param(2, ZParam(UiContributionParamsDto)),
|
|
268
|
+
__param(3, ZBody(UiQueryBodyDto))
|
|
269
|
+
], UiController.prototype, "query", null);
|
|
239
270
|
__decorate([
|
|
240
271
|
Post("embeds/:plugin/:id/token"),
|
|
241
272
|
HttpCode(200),
|
package/dist/ui/views.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CompactForm, type FormAnswer, type Logger, type UiActionResult, type UiContribution, type UiIcon, type UiSlotId, type UiView } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type CompactForm, type FormAnswer, type JsonValue, type Logger, type UiActionResult, type UiContribution, type UiIcon, type UiPageFrame, type UiPageNav, type UiSlotId, type UiView } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { ConversationsService } from "../conversations/conversations.service.js";
|
|
3
3
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
4
4
|
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
@@ -9,6 +9,8 @@ import { type OrgRole } from "../orgs/roles.js";
|
|
|
9
9
|
export { callExtension } from "./call-extension.js";
|
|
10
10
|
/** 插件 render / action 的时限(spec §4.2:慢的插件只让那个标签失败)。 */
|
|
11
11
|
export declare const UI_CALL_TIMEOUT_MS = 5000;
|
|
12
|
+
/** The time limit of a component query (plugin full pages spec §4.1). */
|
|
13
|
+
export declare const UI_QUERY_TIMEOUT_MS = 10000;
|
|
12
14
|
/** 列出贡献接口的一项。 */
|
|
13
15
|
export interface UiContributionItem {
|
|
14
16
|
plugin: string;
|
|
@@ -25,6 +27,10 @@ export interface UiContributionItem {
|
|
|
25
27
|
icon: UiIcon;
|
|
26
28
|
/** The form on a compact screen: the slot's, narrowed by the contribution's (spec §5.6). */
|
|
27
29
|
compact: CompactForm;
|
|
30
|
+
/** `org.page` component only, when the manifest names it: who draws the page frame. */
|
|
31
|
+
frame?: UiPageFrame;
|
|
32
|
+
/** `org.page` component only, when the manifest names it: the suggested navigation section. */
|
|
33
|
+
nav?: UiPageNav;
|
|
28
34
|
}
|
|
29
35
|
/** A list slot of an arrangement listing: where its entry comes from and its items in order. */
|
|
30
36
|
export interface UiArrangementListSlot {
|
|
@@ -189,6 +195,14 @@ export declare class UiViews {
|
|
|
189
195
|
* else is 404.
|
|
190
196
|
*/
|
|
191
197
|
private skillFileEmbed;
|
|
198
|
+
/**
|
|
199
|
+
* A `file.preview` embed for one of the caller's own library files (file library spec §6; no
|
|
200
|
+
* conversation or agent): the caller's role may use agents (`agents.use`) and the slot, the
|
|
201
|
+
* contribution is a loaded `file.preview` embed of an extension enabled in the org, and an
|
|
202
|
+
* enabled previewer of that extension with `embed: <this contribution>` takes the file (another
|
|
203
|
+
* account's file throws 404 `file.not_found`); anything else is 404.
|
|
204
|
+
*/
|
|
205
|
+
private libraryFileEmbed;
|
|
192
206
|
/**
|
|
193
207
|
* The path of a loaded `file.preview` embed contribution (a share page's embed previewer, file
|
|
194
208
|
* sharing spec §7), else 404 `ui.not_found`. Whether the previewer takes the share's snapshot
|
|
@@ -203,6 +217,20 @@ export declare class UiViews {
|
|
|
203
217
|
payload?: unknown;
|
|
204
218
|
answer?: FormAnswer;
|
|
205
219
|
}): Promise<UiActionResult>;
|
|
220
|
+
/**
|
|
221
|
+
* Runs a component's named query (`ctx.ui.query`, plugin full pages spec §4.1): the same gate
|
|
222
|
+
* and args as the component's view, plus `{ query, params, signal }`. Not offered (or no
|
|
223
|
+
* handler) is 404 `ui.query_not_found`; params over `UI_LIMITS.componentQueryParamsBytes` 413
|
|
224
|
+
* `ui.query_params_too_large`; 10 s 504 `ui.query_timeout`; a throw 502 `ui.query_failed`; a
|
|
225
|
+
* result that is not JSON or over `UI_LIMITS.componentQueryBytes` 502
|
|
226
|
+
* `ui.query_result_too_large`.
|
|
227
|
+
*/
|
|
228
|
+
query(t: UiOrgTarget, input: {
|
|
229
|
+
query: string;
|
|
230
|
+
params?: unknown;
|
|
231
|
+
}): Promise<{
|
|
232
|
+
data: JsonValue;
|
|
233
|
+
}>;
|
|
206
234
|
/** Ids of the extension's live `panel` contributions. */
|
|
207
235
|
private panels;
|
|
208
236
|
/**
|
package/dist/ui/views.js
CHANGED
|
@@ -7,7 +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 { effectiveCompact, UI_ARRANGEABLE_SLOTS, validateUiView, } from "@capybara-hq/plugin-sdk";
|
|
10
|
+
import { effectiveCompact, UI_ARRANGEABLE_SLOTS, UI_LIMITS, validateUiView, } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { isAgentVisibleIn } from "../agents/agent-lookup.js";
|
|
@@ -24,9 +24,12 @@ import { readOrgSettings } from "../orgs/settings.service.js";
|
|
|
24
24
|
import { arrange, arrangeBySlot, effectiveEntry, isSingle, keyOf, ORG_ARRANGEABLE, orderItems, resolveSingleSlot, storedUse, } from "./arrangement.js";
|
|
25
25
|
import { callExtension } from "./call-extension.js";
|
|
26
26
|
import { canUseSlot, UUID_RE } from "./registry.js";
|
|
27
|
+
import { jsonBytes } from "./ui.schemas.js";
|
|
27
28
|
export { callExtension } from "./call-extension.js";
|
|
28
29
|
/** 插件 render / action 的时限(spec §4.2:慢的插件只让那个标签失败)。 */
|
|
29
30
|
export const UI_CALL_TIMEOUT_MS = 5_000;
|
|
31
|
+
/** The time limit of a component query (plugin full pages spec §4.1). */
|
|
32
|
+
export const UI_QUERY_TIMEOUT_MS = 10_000;
|
|
30
33
|
/** The log field naming where a target is: its org, or the platform scope. */
|
|
31
34
|
const whereOf = (t) => t.scope === "platform" ? { scope: "platform" } : { orgId: t.orgId };
|
|
32
35
|
/**
|
|
@@ -93,6 +96,8 @@ function listed(entries) {
|
|
|
93
96
|
...(c.kind === "embed" && c.path !== undefined && { path: c.path }),
|
|
94
97
|
icon: c.icon ?? "puzzle",
|
|
95
98
|
compact: effectiveCompact(s.compact, c.compact),
|
|
99
|
+
...(c.frame !== undefined && { frame: c.frame }),
|
|
100
|
+
...(c.nav !== undefined && { nav: c.nav }),
|
|
96
101
|
}));
|
|
97
102
|
}
|
|
98
103
|
/** The candidates of a single slot in an arrangement listing. */
|
|
@@ -112,13 +117,24 @@ const TOAST_MAX = 500;
|
|
|
112
117
|
const MAX_LOGGED_PROBLEMS = 10;
|
|
113
118
|
const notFound = () => new ApiError("ui.not_found", "UI contribution not found");
|
|
114
119
|
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
120
|
+
/** At most this many query names in an action result's `invalidate`. */
|
|
121
|
+
const INVALIDATE_MAX = 50;
|
|
115
122
|
/**
|
|
116
|
-
*
|
|
123
|
+
* Checks an action result and returns its problems (empty = valid). A new `view` may carry
|
|
124
|
+
* `data`, and `invalidate` (query names the host refetches) is read, only for a component
|
|
117
125
|
* (`component`).
|
|
118
126
|
*/
|
|
119
127
|
function actionResultProblems(r, component) {
|
|
120
128
|
if (!isObj(r))
|
|
121
129
|
return ["action result must be an object"];
|
|
130
|
+
if (component && r.invalidate !== undefined) {
|
|
131
|
+
const inv = r.invalidate;
|
|
132
|
+
if (!Array.isArray(inv) ||
|
|
133
|
+
inv.length > INVALIDATE_MAX ||
|
|
134
|
+
!inv.every((q) => typeof q === "string" && q !== "" && q.length <= 200)) {
|
|
135
|
+
return [`invalidate must be at most ${INVALIDATE_MAX} query names of 1-200 characters`];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
122
138
|
if (r.view !== undefined)
|
|
123
139
|
return validateUiView(r.view, { component }).map((p) => `view: ${p}`);
|
|
124
140
|
if (r.toast === undefined)
|
|
@@ -277,6 +293,12 @@ let UiViews = class UiViews {
|
|
|
277
293
|
const { fileId: f, skillFile, ...org } = t;
|
|
278
294
|
if (skillFile !== undefined)
|
|
279
295
|
return this.skillFileEmbed({ ...org, skillFile }, f);
|
|
296
|
+
if (f !== undefined && org.conversationId === undefined) {
|
|
297
|
+
if (org.agentId !== undefined) {
|
|
298
|
+
throw new ApiError("validation_failed", "fileId is not allowed with agentId");
|
|
299
|
+
}
|
|
300
|
+
return this.libraryFileEmbed(org, f);
|
|
301
|
+
}
|
|
280
302
|
fileId = f;
|
|
281
303
|
target = { ...org, locale: "en" };
|
|
282
304
|
}
|
|
@@ -354,6 +376,39 @@ let UiViews = class UiViews {
|
|
|
354
376
|
throw notFound();
|
|
355
377
|
return { plugin: t.plugin, contribution: t.id, path, skillFile: file };
|
|
356
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* A `file.preview` embed for one of the caller's own library files (file library spec §6; no
|
|
381
|
+
* conversation or agent): the caller's role may use agents (`agents.use`) and the slot, the
|
|
382
|
+
* contribution is a loaded `file.preview` embed of an extension enabled in the org, and an
|
|
383
|
+
* enabled previewer of that extension with `embed: <this contribution>` takes the file (another
|
|
384
|
+
* account's file throws 404 `file.not_found`); anything else is 404.
|
|
385
|
+
*/
|
|
386
|
+
async libraryFileEmbed(t, fileId) {
|
|
387
|
+
const entry = this.d.host
|
|
388
|
+
.uiContributions()
|
|
389
|
+
.find((c) => c.plugin === t.plugin &&
|
|
390
|
+
c.contribution.id === t.id &&
|
|
391
|
+
c.contribution.kind === "embed" &&
|
|
392
|
+
c.slot.id === "file.preview");
|
|
393
|
+
const path = entry?.contribution.path;
|
|
394
|
+
if (entry === undefined || path === undefined)
|
|
395
|
+
throw notFound();
|
|
396
|
+
if (!canUseSlot(entry.slot, t.role) || !can(t.role, "agents.use"))
|
|
397
|
+
throw notFound();
|
|
398
|
+
if (!(await this.d.enabledPlugins(t.orgId)).has(t.plugin))
|
|
399
|
+
throw notFound();
|
|
400
|
+
const allowed = this.d.previewEmbedAllowed !== undefined &&
|
|
401
|
+
(await this.d.previewEmbedAllowed({
|
|
402
|
+
orgId: t.orgId,
|
|
403
|
+
accountId: t.accountId,
|
|
404
|
+
fileId,
|
|
405
|
+
plugin: t.plugin,
|
|
406
|
+
contribution: t.id,
|
|
407
|
+
}));
|
|
408
|
+
if (!allowed)
|
|
409
|
+
throw notFound();
|
|
410
|
+
return { plugin: t.plugin, contribution: t.id, path, fileId };
|
|
411
|
+
}
|
|
357
412
|
/**
|
|
358
413
|
* The path of a loaded `file.preview` embed contribution (a share page's embed previewer, file
|
|
359
414
|
* sharing spec §7), else 404 `ui.not_found`. Whether the previewer takes the share's snapshot
|
|
@@ -383,6 +438,12 @@ let UiViews = class UiViews {
|
|
|
383
438
|
/** 执行动作:调用插件 `action`(视图里的按钮 / 表单提交),校验返回的提示或新视图。 */
|
|
384
439
|
async act(t, input) {
|
|
385
440
|
const { entry, args } = await this.resolve(t, "action");
|
|
441
|
+
// a component's action takes a form-sized payload; a view's button keeps the view limit
|
|
442
|
+
if (entry.contribution.kind !== "component" &&
|
|
443
|
+
input.payload !== undefined &&
|
|
444
|
+
jsonBytes(input.payload) > UI_LIMITS.payloadBytes) {
|
|
445
|
+
throw new ApiError("validation_failed", `payload must be at most ${UI_LIMITS.payloadBytes} bytes as JSON`);
|
|
446
|
+
}
|
|
386
447
|
const action = entry.action;
|
|
387
448
|
const r = await this.call(t, "action", (signal) => action({
|
|
388
449
|
...args,
|
|
@@ -391,11 +452,74 @@ let UiViews = class UiViews {
|
|
|
391
452
|
...(input.payload !== undefined && { payload: input.payload }),
|
|
392
453
|
...(input.answer !== undefined && { answer: input.answer }),
|
|
393
454
|
}));
|
|
394
|
-
|
|
455
|
+
const component = entry.contribution.kind === "component";
|
|
456
|
+
this.check(t, "action", actionResultProblems(r, component));
|
|
395
457
|
const res = r;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
458
|
+
// the query names to refetch: a component's only (plugin full pages spec §4.1)
|
|
459
|
+
const inv = component && res.invalidate !== undefined ? { invalidate: [...res.invalidate] } : {};
|
|
460
|
+
if (res.view !== undefined) {
|
|
461
|
+
return { view: dropForeignOpens(res.view, this.panels(t.plugin)), ...inv };
|
|
462
|
+
}
|
|
463
|
+
return res.toast !== undefined
|
|
464
|
+
? { toast: { zh: res.toast.zh, en: res.toast.en }, ...inv }
|
|
465
|
+
: inv;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Runs a component's named query (`ctx.ui.query`, plugin full pages spec §4.1): the same gate
|
|
469
|
+
* and args as the component's view, plus `{ query, params, signal }`. Not offered (or no
|
|
470
|
+
* handler) is 404 `ui.query_not_found`; params over `UI_LIMITS.componentQueryParamsBytes` 413
|
|
471
|
+
* `ui.query_params_too_large`; 10 s 504 `ui.query_timeout`; a throw 502 `ui.query_failed`; a
|
|
472
|
+
* result that is not JSON or over `UI_LIMITS.componentQueryBytes` 502
|
|
473
|
+
* `ui.query_result_too_large`.
|
|
474
|
+
*/
|
|
475
|
+
async query(t, input) {
|
|
476
|
+
let resolved;
|
|
477
|
+
try {
|
|
478
|
+
resolved = await this.resolve(t, "query");
|
|
479
|
+
}
|
|
480
|
+
catch (e) {
|
|
481
|
+
if (e instanceof ApiError && e.code === "ui.not_found") {
|
|
482
|
+
throw new ApiError("ui.query_not_found", "UI component query not found");
|
|
483
|
+
}
|
|
484
|
+
throw e;
|
|
485
|
+
}
|
|
486
|
+
const params = (input.params ?? null);
|
|
487
|
+
if (jsonBytes(params) > UI_LIMITS.componentQueryParamsBytes) {
|
|
488
|
+
throw new ApiError("ui.query_params_too_large", `params must be at most ${UI_LIMITS.componentQueryParamsBytes} bytes as JSON`);
|
|
489
|
+
}
|
|
490
|
+
const handler = resolved.entry.query;
|
|
491
|
+
// an org target always resolves to org args
|
|
492
|
+
const args = resolved.args;
|
|
493
|
+
const data = await callExtension({
|
|
494
|
+
log: this.d.log,
|
|
495
|
+
plugin: t.plugin,
|
|
496
|
+
what: "query",
|
|
497
|
+
fields: { plugin: t.plugin, contribution: t.id, query: input.query, orgId: t.orgId },
|
|
498
|
+
timeoutMs: UI_QUERY_TIMEOUT_MS,
|
|
499
|
+
failCode: "ui.query_failed",
|
|
500
|
+
timeoutCode: "ui.query_timeout",
|
|
501
|
+
failMessage: `Plugin ${t.plugin} failed to answer query ${input.query} of ${t.id}`,
|
|
502
|
+
fn: (signal) => handler({ ...args, query: input.query, params, signal }),
|
|
503
|
+
});
|
|
504
|
+
let json;
|
|
505
|
+
try {
|
|
506
|
+
json = JSON.stringify(data);
|
|
507
|
+
}
|
|
508
|
+
catch {
|
|
509
|
+
json = undefined;
|
|
510
|
+
}
|
|
511
|
+
const bytes = json === undefined ? undefined : Buffer.byteLength(json, "utf8");
|
|
512
|
+
if (bytes === undefined || bytes > UI_LIMITS.componentQueryBytes) {
|
|
513
|
+
this.d.log.warn("plugin ui query returned a result that is not JSON or too large", {
|
|
514
|
+
plugin: t.plugin,
|
|
515
|
+
contribution: t.id,
|
|
516
|
+
query: input.query,
|
|
517
|
+
orgId: t.orgId,
|
|
518
|
+
...(bytes !== undefined && { bytes }),
|
|
519
|
+
});
|
|
520
|
+
throw new ApiError("ui.query_result_too_large", `Plugin ${t.plugin} returned a query result that is not JSON of at most ${UI_LIMITS.componentQueryBytes} bytes`);
|
|
521
|
+
}
|
|
522
|
+
return { data };
|
|
399
523
|
}
|
|
400
524
|
/** Ids of the extension's live `panel` contributions. */
|
|
401
525
|
panels(plugin) {
|
|
@@ -421,7 +545,7 @@ let UiViews = class UiViews {
|
|
|
421
545
|
c.contribution.id === t.id &&
|
|
422
546
|
(need === "embed"
|
|
423
547
|
? c.contribution.kind === "embed"
|
|
424
|
-
: // a view, or a component's server view (served like a view of its slot)
|
|
548
|
+
: // a view, or a component's server view or query (served like a view of its slot)
|
|
425
549
|
(c.contribution.kind === "view" || c.contribution.kind === "component") &&
|
|
426
550
|
c[need] !== undefined));
|
|
427
551
|
if (t.scope === "platform") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.107",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "^2.9.1",
|
|
67
67
|
"yauzl": "3.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
69
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.86"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/ws": "^8.18.2",
|
|
76
76
|
"@types/yauzl": "3.4.0",
|
|
77
77
|
"ws": "^8.22.0",
|
|
78
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
78
|
+
"@capybara-hq/testing": "0.1.0-rc.48"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsc -b"
|