@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
|
@@ -59,7 +59,7 @@ export type MessageContext = Pick<EventPayload<"user_message">, "sender" | "time
|
|
|
59
59
|
* - `sender`: the account's display name and org role at send time; the org's anonymous guest
|
|
60
60
|
* account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
|
|
61
61
|
* "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
|
|
62
|
-
* - `timeZone`: the override (`timeZoneOverride`, when valid:
|
|
62
|
+
* - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
|
|
63
63
|
* tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
|
|
64
64
|
* account's setting, else the browser's (when valid), else the org default, else UTC. The
|
|
65
65
|
* anonymous guest account has no setting of its own, so it gets the IM value or the org default.
|
|
@@ -77,6 +77,6 @@ export declare function readMessageContext(t: KernelSchemaDb, input: {
|
|
|
77
77
|
browser?: BrowserContext | undefined;
|
|
78
78
|
/** An IM message: what the platform gave for the sender (maintainer decision 2026-11-08). */
|
|
79
79
|
im?: ImSenderContext | undefined;
|
|
80
|
-
/** A zone that beats every other source (
|
|
80
|
+
/** A zone that beats every other source (an automation's zone); internal callers only. */
|
|
81
81
|
timeZoneOverride?: string | undefined;
|
|
82
82
|
}): Promise<MessageContext>;
|
|
@@ -84,7 +84,7 @@ export async function recipientLocale(t, input) {
|
|
|
84
84
|
* - `sender`: the account's display name and org role at send time; the org's anonymous guest
|
|
85
85
|
* account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
|
|
86
86
|
* "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
|
|
87
|
-
* - `timeZone`: the override (`timeZoneOverride`, when valid:
|
|
87
|
+
* - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
|
|
88
88
|
* tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
|
|
89
89
|
* account's setting, else the browser's (when valid), else the org default, else UTC. The
|
|
90
90
|
* anonymous guest account has no setting of its own, so it gets the IM value or the org default.
|
|
@@ -12,6 +12,7 @@ export declare class PermissionProfileStore {
|
|
|
12
12
|
account_id: string;
|
|
13
13
|
agent_id: string;
|
|
14
14
|
archived_at: Date | null;
|
|
15
|
+
automation_id: string | null;
|
|
15
16
|
consumed_seq: string;
|
|
16
17
|
create_request_hash: string | null;
|
|
17
18
|
create_request_id: string | null;
|
|
@@ -31,11 +32,11 @@ export declare class PermissionProfileStore {
|
|
|
31
32
|
project_path: string | null;
|
|
32
33
|
queue_pause_reason: string | null;
|
|
33
34
|
queue_paused: boolean;
|
|
34
|
-
scheduled_task_id: string | null;
|
|
35
35
|
selection: unknown;
|
|
36
36
|
source: "channel_dm" | "channel_group" | "subagent" | "web";
|
|
37
37
|
subagent_depth: number;
|
|
38
38
|
subagent_type: string | null;
|
|
39
|
+
subject: import("../db/kernel-schema.js").ConversationSubject | null;
|
|
39
40
|
title: string | null;
|
|
40
41
|
title_attempts: number;
|
|
41
42
|
title_source: import("../db/kernel-schema.js").TitleSource | null;
|
|
@@ -16,6 +16,9 @@ export declare const FirstMessageBody: z.ZodObject<{
|
|
|
16
16
|
uri: z.ZodString;
|
|
17
17
|
}, z.core.$strict>>>;
|
|
18
18
|
files: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
19
|
+
projectFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
path: z.ZodString;
|
|
21
|
+
}, z.core.$strict>>>;
|
|
19
22
|
model: z.ZodOptional<z.ZodObject<{
|
|
20
23
|
provider: z.ZodString;
|
|
21
24
|
model: z.ZodString;
|
|
@@ -123,7 +123,7 @@ let PermissionProfilesService = class PermissionProfilesService {
|
|
|
123
123
|
}
|
|
124
124
|
async setLocked(orgId, id, accountId, body, binding) {
|
|
125
125
|
let row = await this.store.own(orgId, id, accountId);
|
|
126
|
-
if (row.parent_conversation_id || row.kind !== "chat" || row.
|
|
126
|
+
if (row.parent_conversation_id || row.kind !== "chat" || row.automation_id)
|
|
127
127
|
throw new ApiError("forbidden", "Only interactive root conversations have editable permissions");
|
|
128
128
|
const subject = {
|
|
129
129
|
orgId,
|
|
@@ -78,7 +78,7 @@ export interface SuggestionEligibilityInput {
|
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Whether a finished run may get a suggestion by its outcome, conversation and trigger (spec §2):
|
|
81
|
-
* `completed` or `max_steps`, a `chat` conversation from `web`, not
|
|
81
|
+
* `completed` or `max_steps`, a `chat` conversation from `web`, not an automation's or compact run.
|
|
82
82
|
* The final reply, freshness and the switches are checked elsewhere.
|
|
83
83
|
*/
|
|
84
84
|
export declare function suggestionEligible(i: SuggestionEligibilityInput): boolean;
|
|
@@ -107,7 +107,8 @@ export function buildSuggestionRequest(input) {
|
|
|
107
107
|
reference = ref.request;
|
|
108
108
|
// every event of the snapshot (it ends at the run's terminal event): absorbable events past
|
|
109
109
|
// the recorded absorbedUpToSeq stay out, anything else model-visible after the final reply
|
|
110
|
-
// breaks the check below
|
|
110
|
+
// breaks the check below. It keeps the baseline's recorded cacheTtl: the same tier as the
|
|
111
|
+
// last call keeps its cache entry whole (idle compaction spec §9.4)
|
|
111
112
|
extended = assembleModelRequest({ ...gathered.input, events });
|
|
112
113
|
}
|
|
113
114
|
catch (err) {
|
|
@@ -147,7 +148,7 @@ export function buildSuggestionRequest(input) {
|
|
|
147
148
|
}
|
|
148
149
|
/**
|
|
149
150
|
* Whether a finished run may get a suggestion by its outcome, conversation and trigger (spec §2):
|
|
150
|
-
* `completed` or `max_steps`, a `chat` conversation from `web`, not
|
|
151
|
+
* `completed` or `max_steps`, a `chat` conversation from `web`, not an automation's or compact run.
|
|
151
152
|
* The final reply, freshness and the switches are checked elsewhere.
|
|
152
153
|
*/
|
|
153
154
|
export function suggestionEligible(i) {
|
|
@@ -155,6 +156,7 @@ export function suggestionEligible(i) {
|
|
|
155
156
|
i.kind === "chat" &&
|
|
156
157
|
i.source === "web" &&
|
|
157
158
|
i.trigger !== "schedule" &&
|
|
159
|
+
i.trigger !== "automation_event" &&
|
|
158
160
|
i.trigger !== "compact");
|
|
159
161
|
}
|
|
160
162
|
// C0 and C1 controls (newlines are split on first; a tab becomes a space)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ModelUsage } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { Job, Queue, Worker } from "bullmq";
|
|
3
|
+
import { ConversationMedia } from "../files/conversation-media.js";
|
|
3
4
|
import { SettingsService } from "../identity/settings.js";
|
|
4
5
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
5
6
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -9,7 +10,6 @@ import { OrgSettingsService } from "../orgs/settings.service.js";
|
|
|
9
10
|
import { type AuditEntry, type HookRunner } from "../runtime/hook-calls.js";
|
|
10
11
|
import { ProviderRegistry } from "../runtime/providers.js";
|
|
11
12
|
import { UsageReportJobs } from "../runtime/usage-report-jobs.js";
|
|
12
|
-
import { AttachmentsService } from "./attachments.service.js";
|
|
13
13
|
import { EventLog } from "./event-log.js";
|
|
14
14
|
import type { ConversationEvent, EventPayload } from "./events.js";
|
|
15
15
|
import { PromptSuggestionStore } from "./prompt-suggestion-store.js";
|
|
@@ -58,7 +58,7 @@ export declare class PromptSuggestionGenerator {
|
|
|
58
58
|
/** The platform's compaction settings (the org's reserve for the fit guard). */
|
|
59
59
|
private readonly settings;
|
|
60
60
|
/** The run's media, as the run's steps load it. */
|
|
61
|
-
private readonly
|
|
61
|
+
private readonly media;
|
|
62
62
|
private readonly store;
|
|
63
63
|
private readonly config;
|
|
64
64
|
private readonly log;
|
|
@@ -74,7 +74,7 @@ export declare class PromptSuggestionGenerator {
|
|
|
74
74
|
/** The platform's compaction settings (the org's reserve for the fit guard). */
|
|
75
75
|
settings: Pick<SettingsService, "get">,
|
|
76
76
|
/** The run's media, as the run's steps load it. */
|
|
77
|
-
|
|
77
|
+
media: Pick<ConversationMedia, "mediaInfo" | "fetchMedia">, store: Pick<PromptSuggestionStore, "isFresh" | "put">, config: KernelConfigService, log: Pick<KernelLogger, "debug" | "warn">, txHost: TransactionHost, timeoutMs?: () => number);
|
|
78
78
|
private get db();
|
|
79
79
|
/**
|
|
80
80
|
* One suggestion for the run (spec §1–§4); `shutdown` aborts the call (the worker stopping).
|
|
@@ -16,6 +16,8 @@ import { loadSnapshotMedia } from "../evals/reconstruct.js";
|
|
|
16
16
|
import { takeSnapshot, toEvents } from "../evals/snapshot.js";
|
|
17
17
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
18
18
|
import { ExtensionHost } from "../extensions/host.js";
|
|
19
|
+
import { ConversationMedia } from "../files/conversation-media.js";
|
|
20
|
+
import { LibraryReadModule } from "../files/library-read.module.js";
|
|
19
21
|
import { audit } from "../identity/audit.js";
|
|
20
22
|
import { IdentityModule } from "../identity/identity.module.js";
|
|
21
23
|
import { SettingsService } from "../identity/settings.js";
|
|
@@ -31,8 +33,6 @@ import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookRequestOf, } from ".
|
|
|
31
33
|
import { consumeModelStream, deltaChars } from "../runtime/model-call.js";
|
|
32
34
|
import { ProviderRegistry, ProvidersModule } from "../runtime/providers.js";
|
|
33
35
|
import { UsageReportJobs, UsageReportJobsModule } from "../runtime/usage-report-jobs.js";
|
|
34
|
-
import { AttachmentsModule } from "./attachments.module.js";
|
|
35
|
-
import { AttachmentsService } from "./attachments.service.js";
|
|
36
36
|
import { EventLog, EventLogModule } from "./event-log.js";
|
|
37
37
|
import { buildSuggestionRequest, cleanSuggestion, lastModelCallOf, PROMPT_SUGGESTION_TIMEOUT_MS, suggestionEligible, suggestionStale, } from "./prompt-suggestion-request.js";
|
|
38
38
|
import { PromptSuggestionStore } from "./prompt-suggestion-store.js";
|
|
@@ -98,7 +98,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
|
|
|
98
98
|
usage;
|
|
99
99
|
orgSettings;
|
|
100
100
|
settings;
|
|
101
|
-
|
|
101
|
+
media;
|
|
102
102
|
store;
|
|
103
103
|
config;
|
|
104
104
|
log;
|
|
@@ -112,7 +112,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
|
|
|
112
112
|
/** The platform's compaction settings (the org's reserve for the fit guard). */
|
|
113
113
|
settings,
|
|
114
114
|
/** The run's media, as the run's steps load it. */
|
|
115
|
-
|
|
115
|
+
media, store, config, log, txHost, timeoutMs = () => PROMPT_SUGGESTION_TIMEOUT_MS) {
|
|
116
116
|
this.kdb = kdb;
|
|
117
117
|
this.eventLog = eventLog;
|
|
118
118
|
this.registry = registry;
|
|
@@ -120,7 +120,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
|
|
|
120
120
|
this.usage = usage;
|
|
121
121
|
this.orgSettings = orgSettings;
|
|
122
122
|
this.settings = settings;
|
|
123
|
-
this.
|
|
123
|
+
this.media = media;
|
|
124
124
|
this.store = store;
|
|
125
125
|
this.config = config;
|
|
126
126
|
this.log = log;
|
|
@@ -177,8 +177,8 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
|
|
|
177
177
|
let media;
|
|
178
178
|
try {
|
|
179
179
|
media = await loadSnapshotMedia(snapshot, last.seq, info, {
|
|
180
|
-
info: (orgId, convId, ids) => this.
|
|
181
|
-
fetch: (orgId, convId, ids, caps) => this.
|
|
180
|
+
info: (orgId, convId, ids) => this.media.mediaInfo(orgId, convId, ids),
|
|
181
|
+
fetch: (orgId, convId, ids, caps) => this.media.fetchMedia(orgId, convId, ids, caps),
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
catch {
|
|
@@ -214,7 +214,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
|
|
|
214
214
|
try {
|
|
215
215
|
out = await consumeModelStream(provider, request, info.streamIdleTimeoutMs ?? this.config.get().runtime.streamIdleMs, signal, (ev) => {
|
|
216
216
|
streamedChars += deltaChars(ev);
|
|
217
|
-
});
|
|
217
|
+
}, this.log);
|
|
218
218
|
}
|
|
219
219
|
catch (err) {
|
|
220
220
|
if (shutdown.aborted) {
|
|
@@ -447,7 +447,7 @@ PromptSuggestionGenerator = __decorate([
|
|
|
447
447
|
__param(4, Inject(UsageReportJobs)),
|
|
448
448
|
__param(5, Inject(OrgSettingsService)),
|
|
449
449
|
__param(6, Inject(SettingsService)),
|
|
450
|
-
__param(7, Inject(
|
|
450
|
+
__param(7, Inject(ConversationMedia)),
|
|
451
451
|
__param(8, Inject(PromptSuggestionStore)),
|
|
452
452
|
__param(9, Inject(KernelConfigService)),
|
|
453
453
|
__param(10, Inject(KERNEL_LOGGER)),
|
|
@@ -555,7 +555,8 @@ PromptSuggestionsModule = __decorate([
|
|
|
555
555
|
UsageReportJobsModule,
|
|
556
556
|
OrgSettingsModule,
|
|
557
557
|
IdentityModule,
|
|
558
|
-
|
|
558
|
+
// the run's media: library files the conversation refers to, and `read` copies
|
|
559
|
+
LibraryReadModule,
|
|
559
560
|
PROMPT_SUGGESTION_QUEUE_MODULE,
|
|
560
561
|
],
|
|
561
562
|
providers: [PromptSuggestionStore, PromptSuggestionGenerator, PromptSuggestionQueue],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ModelRef } from "../agents/definition.js";
|
|
2
|
+
import type { ScheduleMarker } from "../automations/types.js";
|
|
2
3
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
3
4
|
import { ApiError } from "../errors.js";
|
|
4
|
-
import type { ScheduleMarker } from "../schedules/types.js";
|
|
5
5
|
import { type InvocationRecord, type RenderedInvocation } from "../skills/invoke.js";
|
|
6
6
|
import type { AttachmentRef } from "./conversations.service.js";
|
|
7
7
|
import { type AppendEvent, type EventLog } from "./event-log.js";
|
|
@@ -30,7 +30,7 @@ export interface QueuedSkill {
|
|
|
30
30
|
record: InvocationRecord;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* An automation's queued message (scheduled tasks spec §6), stored in
|
|
34
34
|
* `conversation_queue.schedule`: the marker the `user_message` carries and the task's zone, which
|
|
35
35
|
* becomes the message's `timeZone` (the top-priority override of `readMessageContext`).
|
|
36
36
|
*/
|
|
@@ -104,9 +104,11 @@ export interface QueueRow {
|
|
|
104
104
|
effort: string | null;
|
|
105
105
|
skill: unknown;
|
|
106
106
|
schedule: unknown;
|
|
107
|
+
/** An event automation's marker (collaboration spec §4.6); null for any other message. */
|
|
108
|
+
automation_event: unknown;
|
|
107
109
|
created_at: Date;
|
|
108
110
|
}
|
|
109
|
-
export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "schedule", "created_at"];
|
|
111
|
+
export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "schedule", "automation_event", "created_at"];
|
|
110
112
|
/**
|
|
111
113
|
* Queued text as the event log will store it: NUL becomes U+FFFD (PG rejects NUL in text and
|
|
112
114
|
* jsonb), the mapping `payloadJson` applies to a direct send (final review m1).
|
|
@@ -127,7 +129,8 @@ export declare function storedSkill(invokedAs: string, invoked: RenderedInvocati
|
|
|
127
129
|
};
|
|
128
130
|
/**
|
|
129
131
|
* The `user_message` a queued item becomes, as `postUserMessage` would have written it; a scheduled
|
|
130
|
-
* task's item carries its marker (without the stored zone, which is in `context`)
|
|
132
|
+
* task's item carries its marker (without the stored zone, which is in `context`), an event
|
|
133
|
+
* automation's item its event marker.
|
|
131
134
|
*/
|
|
132
135
|
export declare function queuedUserMessage(r: QueueRow, context?: MessageContext): AppendEvent;
|
|
133
136
|
/**
|
|
@@ -29,6 +29,7 @@ export const COLUMNS = [
|
|
|
29
29
|
"effort",
|
|
30
30
|
"skill",
|
|
31
31
|
"schedule",
|
|
32
|
+
"automation_event",
|
|
32
33
|
"created_at",
|
|
33
34
|
];
|
|
34
35
|
/**
|
|
@@ -80,12 +81,14 @@ export function storedSkill(invokedAs, invoked) {
|
|
|
80
81
|
}
|
|
81
82
|
/**
|
|
82
83
|
* The `user_message` a queued item becomes, as `postUserMessage` would have written it; a scheduled
|
|
83
|
-
* task's item carries its marker (without the stored zone, which is in `context`)
|
|
84
|
+
* task's item carries its marker (without the stored zone, which is in `context`), an event
|
|
85
|
+
* automation's item its event marker.
|
|
84
86
|
*/
|
|
85
87
|
export function queuedUserMessage(r, context = {}) {
|
|
86
88
|
const attachments = r.attachments;
|
|
87
89
|
const skill = r.skill;
|
|
88
90
|
const marker = queuedMarker(r);
|
|
91
|
+
const event = r.automation_event;
|
|
89
92
|
return {
|
|
90
93
|
type: "user_message",
|
|
91
94
|
idemKey: userMessageIdemKey(r.client_message_id),
|
|
@@ -101,6 +104,7 @@ export function queuedUserMessage(r, context = {}) {
|
|
|
101
104
|
clientMessageId: r.client_message_id,
|
|
102
105
|
...(skill !== null && { skill: skill.record }),
|
|
103
106
|
...(marker !== undefined && { schedule: marker }),
|
|
107
|
+
...(event !== null && event !== undefined && { automationEvent: event }),
|
|
104
108
|
},
|
|
105
109
|
};
|
|
106
110
|
}
|
|
@@ -136,7 +140,7 @@ export async function appendQueuedIn(t, eventLog, conversationId, r) {
|
|
|
136
140
|
payload: { ...next, byAccountId: r.account_id, reason: "user" },
|
|
137
141
|
});
|
|
138
142
|
}
|
|
139
|
-
// run context spec §3.4: no browser values were stored with a leftover row;
|
|
143
|
+
// run context spec §3.4: no browser values were stored with a leftover row; an automation's
|
|
140
144
|
// item stored its task's zone, which wins (scheduled tasks spec §6)
|
|
141
145
|
// org-filter: reads the org of the conversation the caller holds the row lock of
|
|
142
146
|
const org = await t
|
|
@@ -30,7 +30,7 @@ export declare class ConversationQueue {
|
|
|
30
30
|
* credentials. The same `clientMessageId` again returns the queued item (`created: false`), or,
|
|
31
31
|
* when it was already sent, the sent `user_message` with `item: null`. Then `ensureRun`: on an
|
|
32
32
|
* idle conversation the item goes out at once. `internal` (kernel callers only, never HTTP): a
|
|
33
|
-
*
|
|
33
|
+
* automation's marker and zone, stored with the item and written with its `user_message`
|
|
34
34
|
* (scheduled tasks spec §6).
|
|
35
35
|
*/
|
|
36
36
|
add(orgId: string, conversationId: string, accountId: string, input: QueueInput, internal?: InternalMessageOptions): Promise<{
|
|
@@ -41,9 +41,9 @@ export declare class ConversationQueue {
|
|
|
41
41
|
private addIn;
|
|
42
42
|
/**
|
|
43
43
|
* Changes a queued item's text (its resources and files stay as queued). A skill invocation's
|
|
44
|
-
* text is its arguments: the skill is rendered again with them now.
|
|
45
|
-
* becomes the person's message: its schedule marker (and the task's zone) is dropped,
|
|
46
|
-
* it triggers is attended (scheduled tasks spec §7).
|
|
44
|
+
* text is its arguments: the skill is rendered again with them now. An automation's item
|
|
45
|
+
* becomes the person's message: its schedule or event marker (and the task's zone) is dropped,
|
|
46
|
+
* so the run it triggers is attended (scheduled tasks spec §7).
|
|
47
47
|
*/
|
|
48
48
|
edit(orgId: string, conversationId: string, accountId: string, itemId: string, text: string): Promise<QueueItem>;
|
|
49
49
|
private editIn;
|
|
@@ -53,7 +53,7 @@ export declare class ConversationQueue {
|
|
|
53
53
|
* Sends a queued item now: it leaves the queue and is posted as a user message in the same
|
|
54
54
|
* transaction (an interjection when a run is active; the items before it keep their place).
|
|
55
55
|
* Racing the dispatcher, exactly one of them takes the item; the loser sees it gone (404). A
|
|
56
|
-
*
|
|
56
|
+
* automation's item is sent as the person's message, without its schedule marker
|
|
57
57
|
* (scheduled tasks spec §7).
|
|
58
58
|
*/
|
|
59
59
|
sendNow(orgId: string, conversationId: string, accountId: string, itemId: string): Promise<ConversationEvent>;
|
|
@@ -10,11 +10,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
|
+
import { releaseQueuedTaskRunIn } from "../automations/run-tracker.js";
|
|
14
|
+
import { ApiError } from "../errors.js";
|
|
13
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
16
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
15
17
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
16
18
|
import { RunControl as RunControlService } from "../runtime/run-control.js";
|
|
17
|
-
import { releaseQueuedTaskRunIn } from "../schedules/run-tracker.js";
|
|
18
19
|
import { notInvocable } from "../skills/invoke.js";
|
|
19
20
|
import { ConversationsService, NO_REPLY_SKIPS, } from "./conversations.service.js";
|
|
20
21
|
import { EventLog, payloadJson } from "./event-log.js";
|
|
@@ -70,7 +71,7 @@ let ConversationQueue = class ConversationQueue {
|
|
|
70
71
|
* credentials. The same `clientMessageId` again returns the queued item (`created: false`), or,
|
|
71
72
|
* when it was already sent, the sent `user_message` with `item: null`. Then `ensureRun`: on an
|
|
72
73
|
* idle conversation the item goes out at once. `internal` (kernel callers only, never HTTP): a
|
|
73
|
-
*
|
|
74
|
+
* automation's marker and zone, stored with the item and written with its `user_message`
|
|
74
75
|
* (scheduled tasks spec §6).
|
|
75
76
|
*/
|
|
76
77
|
async add(orgId, conversationId, accountId, input, internal = {}) {
|
|
@@ -114,8 +115,12 @@ let ConversationQueue = class ConversationQueue {
|
|
|
114
115
|
.select("last_seq")
|
|
115
116
|
.where("id", "=", conversationId)
|
|
116
117
|
.where("org_id", "=", orgId)
|
|
118
|
+
// deleted after the caller's check: no files are attached to it
|
|
119
|
+
.where("deleted_at", "is", null)
|
|
117
120
|
.forUpdate()
|
|
118
|
-
.
|
|
121
|
+
.executeTakeFirst();
|
|
122
|
+
if (!conv)
|
|
123
|
+
throw new ApiError("conversation.not_found", "Conversation not found");
|
|
119
124
|
const existing = await t
|
|
120
125
|
.selectFrom("conversation_queue")
|
|
121
126
|
.select(COLUMNS)
|
|
@@ -140,7 +145,7 @@ let ConversationQueue = class ConversationQueue {
|
|
|
140
145
|
const fileMeta = blocks.flatMap((b) => (b.type === "image" || b.type === "document" || b.type === "file") && b.source.kind === "ref"
|
|
141
146
|
? [
|
|
142
147
|
{
|
|
143
|
-
attachmentId: b.source.
|
|
148
|
+
attachmentId: b.source.fileId,
|
|
144
149
|
name: b.name ?? "",
|
|
145
150
|
mediaType: b.mediaType,
|
|
146
151
|
...(b.size !== undefined && { size: b.size }),
|
|
@@ -174,6 +179,7 @@ let ConversationQueue = class ConversationQueue {
|
|
|
174
179
|
timeZone: internal.timeZoneOverride,
|
|
175
180
|
}),
|
|
176
181
|
}),
|
|
182
|
+
automation_event: internal.automationEvent === undefined ? null : JSON.stringify(internal.automationEvent),
|
|
177
183
|
})
|
|
178
184
|
.returning(COLUMNS)
|
|
179
185
|
.executeTakeFirstOrThrow();
|
|
@@ -184,9 +190,9 @@ let ConversationQueue = class ConversationQueue {
|
|
|
184
190
|
}
|
|
185
191
|
/**
|
|
186
192
|
* Changes a queued item's text (its resources and files stay as queued). A skill invocation's
|
|
187
|
-
* text is its arguments: the skill is rendered again with them now.
|
|
188
|
-
* becomes the person's message: its schedule marker (and the task's zone) is dropped,
|
|
189
|
-
* it triggers is attended (scheduled tasks spec §7).
|
|
193
|
+
* text is its arguments: the skill is rendered again with them now. An automation's item
|
|
194
|
+
* becomes the person's message: its schedule or event marker (and the task's zone) is dropped,
|
|
195
|
+
* so the run it triggers is attended (scheduled tasks spec §7).
|
|
190
196
|
*/
|
|
191
197
|
async edit(orgId, conversationId, accountId, itemId, text) {
|
|
192
198
|
const conv = await this.conversations.writable(orgId, conversationId, accountId);
|
|
@@ -214,15 +220,15 @@ let ConversationQueue = class ConversationQueue {
|
|
|
214
220
|
const t = this.db.db;
|
|
215
221
|
const cur = await t
|
|
216
222
|
.selectFrom("conversation_queue")
|
|
217
|
-
.select(["attachments", "files", "content", "skill", "schedule"])
|
|
223
|
+
.select(["attachments", "files", "content", "skill", "schedule", "automation_event"])
|
|
218
224
|
.where("id", "=", itemId)
|
|
219
225
|
.where("conversation_id", "=", conversationId)
|
|
220
226
|
.forUpdate()
|
|
221
227
|
.executeTakeFirst();
|
|
222
228
|
if (!cur)
|
|
223
229
|
throw itemNotFound();
|
|
224
|
-
// a person's words now: the task's run for this item will not happen (
|
|
225
|
-
await releaseQueuedTaskRunIn(t, cur
|
|
230
|
+
// a person's words now: the task's run for this item will not happen (automations §6)
|
|
231
|
+
await releaseQueuedTaskRunIn(t, cur);
|
|
226
232
|
const skill = cur.skill;
|
|
227
233
|
checkText(text, cur.files.length, cur.attachments.length, skill !== null);
|
|
228
234
|
// an invocation's first block is its rendered text: replace it and the record
|
|
@@ -233,6 +239,7 @@ let ConversationQueue = class ConversationQueue {
|
|
|
233
239
|
text: noNul(text),
|
|
234
240
|
// edited by a person: no longer the task's message
|
|
235
241
|
schedule: null,
|
|
242
|
+
automation_event: null,
|
|
236
243
|
updated_at: sql `now()`,
|
|
237
244
|
...(stored !== undefined && {
|
|
238
245
|
skill: stored.skill,
|
|
@@ -258,12 +265,12 @@ let ConversationQueue = class ConversationQueue {
|
|
|
258
265
|
.deleteFrom("conversation_queue")
|
|
259
266
|
.where("id", "=", itemId)
|
|
260
267
|
.where("conversation_id", "=", conversationId)
|
|
261
|
-
.returning(["id", "schedule"])
|
|
268
|
+
.returning(["id", "schedule", "automation_event"])
|
|
262
269
|
.executeTakeFirst();
|
|
263
270
|
if (!gone)
|
|
264
271
|
throw itemNotFound();
|
|
265
|
-
// a task's queued message deleted by a person: its run is skipped (
|
|
266
|
-
await releaseQueuedTaskRunIn(t, gone
|
|
272
|
+
// a task's queued message deleted by a person: its run is skipped (automations §6)
|
|
273
|
+
await releaseQueuedTaskRunIn(t, gone);
|
|
267
274
|
await unpauseIfEmpty(t, conversationId);
|
|
268
275
|
// the wakes an unpause releases for the tree are owed with it (transactional outbox spec §6)
|
|
269
276
|
await this.runs.oweHeldTreeIn(conversationId);
|
|
@@ -272,7 +279,7 @@ let ConversationQueue = class ConversationQueue {
|
|
|
272
279
|
* Sends a queued item now: it leaves the queue and is posted as a user message in the same
|
|
273
280
|
* transaction (an interjection when a run is active; the items before it keep their place).
|
|
274
281
|
* Racing the dispatcher, exactly one of them takes the item; the loser sees it gone (404). A
|
|
275
|
-
*
|
|
282
|
+
* automation's item is sent as the person's message, without its schedule marker
|
|
276
283
|
* (scheduled tasks spec §7).
|
|
277
284
|
*/
|
|
278
285
|
async sendNow(orgId, conversationId, accountId, itemId) {
|
|
@@ -319,8 +326,12 @@ let ConversationQueue = class ConversationQueue {
|
|
|
319
326
|
throw itemNotFound();
|
|
320
327
|
const sent = await alreadySent(t, conversationId, row.client_message_id);
|
|
321
328
|
// sent by a person: their message, not the task's, whose run is skipped
|
|
322
|
-
await releaseQueuedTaskRunIn(t, row
|
|
323
|
-
const out = await appendQueuedIn(t, this.eventLog, conversationId, {
|
|
329
|
+
await releaseQueuedTaskRunIn(t, row);
|
|
330
|
+
const out = await appendQueuedIn(t, this.eventLog, conversationId, {
|
|
331
|
+
...row,
|
|
332
|
+
schedule: null,
|
|
333
|
+
automation_event: null,
|
|
334
|
+
});
|
|
324
335
|
await unpauseIfEmpty(t, conversationId);
|
|
325
336
|
// sent during the run, the item is the author's message like a direct send: it skips the
|
|
326
337
|
// pending questions they may answer (reply-while-question spec §4.2)
|
package/dist/ctx/create-ctx.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type EmbedClaims, type ExtensionContext, type ExtensionManifest, type ExtensionPointRef, type HttpAccess, type Logger, type RouteCaller, resolveUiSlots, type SetupCheckArgs, type SetupGuidePlace, type ToolHandler, type ToolSpec, type ToolWatcher } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type EmbedClaims, type ExtensionContext, type ExtensionManifest, type ExtensionPointRef, type HttpAccess, type Logger, type RouteCaller, resolveUiSlots, type SetupCheckArgs, type SetupGuidePlace, type ToolHandler, type ToolSpec, type ToolWatcher, type TriggerEvent } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
3
|
import { Kysely } from "kysely";
|
|
4
|
+
import type { TriggerEventsService } from "../automations/events/trigger-events.service.js";
|
|
4
5
|
import type { DeviceAccessService } from "../device-access/device-access.service.js";
|
|
5
6
|
import type { DialInAccess } from "../dial-in/access.js";
|
|
6
7
|
import { type RegisteredHook } from "../extensions/hooks.js";
|
|
@@ -13,7 +14,7 @@ import type { HookRunner } from "../runtime/hook-calls.js";
|
|
|
13
14
|
import type { DeviceReports } from "../sandbox/device-reports.js";
|
|
14
15
|
import type { ShareLiveness } from "../shares/liveness.js";
|
|
15
16
|
import type { EmbedTokens } from "../ui/embed-token.js";
|
|
16
|
-
import { type UiActionHandler, type UiRender } from "../ui/registry.js";
|
|
17
|
+
import { type UiActionHandler, type UiQueryHandler, type UiRender } from "../ui/registry.js";
|
|
17
18
|
import { type BusSubscriber } from "./bus.js";
|
|
18
19
|
import { type ExtensionNetServices } from "./net.js";
|
|
19
20
|
import { type Keyring } from "./secrets.js";
|
|
@@ -76,6 +77,12 @@ export interface KernelDeps {
|
|
|
76
77
|
* a test, the CLI): `ctx.deviceAccess` calls are refused.
|
|
77
78
|
*/
|
|
78
79
|
deviceAccess?: () => DeviceAccessBackend | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* What `ctx.triggers` calls through (`TriggerEventsService`), found at the time of use like
|
|
82
|
+
* `deviceAccess`. Absent, or resolving to undefined (a ctx built alone in a test, the CLI):
|
|
83
|
+
* `ctx.triggers.emit` rejects.
|
|
84
|
+
*/
|
|
85
|
+
triggers?: () => TriggersBackend | undefined;
|
|
79
86
|
runWorkers: boolean;
|
|
80
87
|
/** 内核 logger(`debug` 可选:插件 Logger 没有它,测试可不给)。 */
|
|
81
88
|
log: Logger & {
|
|
@@ -84,6 +91,16 @@ export interface KernelDeps {
|
|
|
84
91
|
}
|
|
85
92
|
/** What `ctx.deviceAccess` calls through (`DeviceAccessService`). */
|
|
86
93
|
export type DeviceAccessBackend = Pick<DeviceAccessService, "ensureService" | "request" | "reportBlockedHosts" | "streamTicket" | "addNetworkHosts" | "answerHandoff">;
|
|
94
|
+
/** What `ctx.triggers` calls through (`TriggerEventsService`). */
|
|
95
|
+
export type TriggersBackend = Pick<TriggerEventsService, "emit">;
|
|
96
|
+
/**
|
|
97
|
+
* A plain-data copy of an emitted event, taken once at the ctx boundary (check-then-use): every
|
|
98
|
+
* own enumerable field is read once (a getter cannot change a value after it was validated),
|
|
99
|
+
* prototypes and accessors are dropped. `cause.call` keeps its original reference, since the
|
|
100
|
+
* pipeline's call scope is a symbol-keyed field and the context holds an `AbortSignal`, neither of
|
|
101
|
+
* which a clone keeps; only its scope is read. Data that cannot be cloned is `invalid_event`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function snapshotTriggerEvent(event: TriggerEvent): TriggerEvent;
|
|
87
104
|
/**
|
|
88
105
|
* What `ctx.ui.verifyEmbedToken` returns for a valid token: the signed claims, with an org
|
|
89
106
|
* token's `role` replaced by the caller's role at verification time.
|
|
@@ -178,6 +195,8 @@ export type KernelExtensionContext = ExtensionContext & {
|
|
|
178
195
|
uiViews: ReadonlyMap<string, UiRender>;
|
|
179
196
|
/** 经 `ctx.ui.action` 注册的动作处理函数(按贡献 id)。 */
|
|
180
197
|
uiActions: ReadonlyMap<string, UiActionHandler>;
|
|
198
|
+
/** Query handlers registered through `ctx.ui.query`, by component id. */
|
|
199
|
+
uiQueries: ReadonlyMap<string, UiQueryHandler>;
|
|
181
200
|
/** Setup checks registered through `ctx.setup.check`, by id. */
|
|
182
201
|
setupChecks: ReadonlyMap<string, RegisteredSetupCheck>;
|
|
183
202
|
/**
|
|
@@ -209,6 +228,8 @@ export declare class LiveConfig {
|
|
|
209
228
|
* (through `deps.dialIn`; another device throws `ExtensionPermissionError`); `devices` only for
|
|
210
229
|
* an extension that provides `device-provider@1`, `reportChanged` only for a live device bound to
|
|
211
230
|
* this extension (through `deps.devices`; another device throws `ExtensionPermissionError`);
|
|
231
|
+
* `triggers` only with `permissions.triggers`, each emit only of a declared event type, stored
|
|
232
|
+
* in the event's org scope (through `deps.triggers`);
|
|
212
233
|
* `http.route`
|
|
213
234
|
* only the method + path declared in `permissions.http` (the record carries the declared access and
|
|
214
235
|
* its mount, see {@link Route}); `tools.register` only names declared in
|