@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/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts}
RENAMED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type EventFilter, type LocalizedName, type TriggerEventDeclaration } from "@capybara-hq/plugin-sdk";
|
|
1
2
|
import { AgentLookup } from "../agents/agent-lookup.js";
|
|
2
3
|
import type { ModelRef } from "../agents/definition.js";
|
|
3
4
|
import { ConversationAccess } from "../conversations/access.js";
|
|
4
5
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
6
|
+
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
7
|
+
import { ExtensionPointDefaults } from "../extensions/point-defaults.js";
|
|
5
8
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
6
9
|
import { type PersonRef } from "../identity/account-avatar.js";
|
|
7
10
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -15,26 +18,40 @@ import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
|
15
18
|
import { ToolRegistry } from "../tools/registry.js";
|
|
16
19
|
import { type CalendarAnswer, type CalendarLimits } from "./calendar.js";
|
|
17
20
|
import { type GrantContext, type GrantRefusalCode, grantRefusal, grantRefusalOf, networkGrantRefusal } from "./grant-rules.js";
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
21
|
+
import { AutomationStore } from "./store.js";
|
|
22
|
+
import type { Automation, AutomationChat, AutomationGrant, AutomationMode, AutomationPauseReason, AutomationUnattendedAsk, TaskRun } from "./types.js";
|
|
20
23
|
export { type GrantContext, type GrantRefusalCode, grantRefusal, grantRefusalOf, networkGrantRefusal, };
|
|
21
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* When a task fires, before the zone is fixed (spec §5); or on events of `types` from the
|
|
26
|
+
* extension `source` that match `filter` (absent: every event of the types).
|
|
27
|
+
*/
|
|
22
28
|
export type TriggerInput = {
|
|
23
29
|
kind: "cron";
|
|
24
30
|
expr: string;
|
|
25
31
|
} | {
|
|
26
32
|
kind: "once";
|
|
27
33
|
at: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "event";
|
|
36
|
+
source: string;
|
|
37
|
+
types: string[];
|
|
38
|
+
filter?: EventFilter;
|
|
28
39
|
};
|
|
29
|
-
/**
|
|
30
|
-
export interface
|
|
40
|
+
/** One trigger source that serves an org, as the automation form offers it. */
|
|
41
|
+
export interface EventSourceView {
|
|
42
|
+
source: string;
|
|
43
|
+
name: LocalizedName;
|
|
44
|
+
events: TriggerEventDeclaration[];
|
|
45
|
+
}
|
|
46
|
+
/** An automation that needs its creator's attention (spec §8): the inbox item's payload. */
|
|
47
|
+
export interface AutomationAttention {
|
|
31
48
|
taskId: string;
|
|
32
49
|
name: string;
|
|
33
50
|
/**
|
|
34
51
|
* `missing_grants`: the latest run was refused tools or connections the task lacks; `failed`:
|
|
35
52
|
* the latest settled run of an active task failed (its start included); else the pause reason.
|
|
36
53
|
*/
|
|
37
|
-
reason:
|
|
54
|
+
reason: AutomationPauseReason | "missing_grants" | "failed";
|
|
38
55
|
/** The person who paused the task (`reason: "admin"` names the admin); else null. */
|
|
39
56
|
pausedBy: PersonRef | null;
|
|
40
57
|
/**
|
|
@@ -72,11 +89,11 @@ export interface CreateTaskInput {
|
|
|
72
89
|
trigger: TriggerInput;
|
|
73
90
|
/** Absent: the creator's effective zone (account, browser, org, UTC). */
|
|
74
91
|
timeZone?: string;
|
|
75
|
-
mode:
|
|
92
|
+
mode: AutomationMode;
|
|
76
93
|
/** `conversation` mode only. */
|
|
77
94
|
conversationId?: string;
|
|
78
95
|
/** `chat` mode only. */
|
|
79
|
-
chat?:
|
|
96
|
+
chat?: AutomationChat;
|
|
80
97
|
/**
|
|
81
98
|
* `new` mode only (a conversation or chat task runs with that conversation's selection and
|
|
82
99
|
* device): the model, which must resolve for the org, and an effort it declares.
|
|
@@ -85,15 +102,17 @@ export interface CreateTaskInput {
|
|
|
85
102
|
effort?: string;
|
|
86
103
|
deviceId?: string;
|
|
87
104
|
/**
|
|
88
|
-
* When the task ends; it must lie in the future. Absent or null: for a cron task, now +
|
|
89
|
-
* org's `defaultExpiryDays` when set; otherwise never.
|
|
105
|
+
* When the task ends; it must lie in the future. Absent or null: for a cron or event task, now +
|
|
106
|
+
* the org's `defaultExpiryDays` when set; otherwise never.
|
|
90
107
|
*/
|
|
91
108
|
expiresAt?: Date | null;
|
|
92
109
|
grants?: GrantInput[];
|
|
110
|
+
/** What a question in an unattended run does; absent or null: the org's default. */
|
|
111
|
+
unattendedAsk?: AutomationUnattendedAsk | null;
|
|
93
112
|
}
|
|
94
113
|
/**
|
|
95
114
|
* Fields to change; `null` clears an optional one (`expiresAt: null` is the org's default expiry
|
|
96
|
-
* for a cron task, as on create). Grants change through their own methods.
|
|
115
|
+
* for a cron or event task, as on create). Grants change through their own methods.
|
|
97
116
|
*/
|
|
98
117
|
export interface UpdateTaskInput {
|
|
99
118
|
agentId?: string;
|
|
@@ -101,27 +120,28 @@ export interface UpdateTaskInput {
|
|
|
101
120
|
prompt?: string;
|
|
102
121
|
trigger?: TriggerInput;
|
|
103
122
|
timeZone?: string;
|
|
104
|
-
mode?:
|
|
123
|
+
mode?: AutomationMode;
|
|
105
124
|
conversationId?: string | null;
|
|
106
|
-
chat?:
|
|
125
|
+
chat?: AutomationChat | null;
|
|
107
126
|
model?: ModelRef | null;
|
|
108
127
|
effort?: string | null;
|
|
109
128
|
deviceId?: string | null;
|
|
110
129
|
expiresAt?: Date | null;
|
|
130
|
+
unattendedAsk?: AutomationUnattendedAsk | null;
|
|
111
131
|
}
|
|
112
132
|
/**
|
|
113
133
|
* Where a grant write comes from: `fromSession` only for a person in a signed-in web session (not a
|
|
114
|
-
* personal access token, the Platform tool or the
|
|
134
|
+
* personal access token, the Platform tool or the automation tools). Network domains are approved
|
|
115
135
|
* only there (network ask-to-allow spec §8.1): an agent must never pre-approve a domain for itself.
|
|
116
136
|
*/
|
|
117
137
|
export interface GrantWriteSource {
|
|
118
138
|
fromSession?: boolean;
|
|
119
139
|
}
|
|
120
140
|
/** Who acts on a task: the service reads their live role itself and decides by that one. */
|
|
121
|
-
export interface
|
|
141
|
+
export interface AutomationActor {
|
|
122
142
|
accountId: string;
|
|
123
143
|
}
|
|
124
|
-
/** One of the agent's tools as the task form offers it (`GET …/
|
|
144
|
+
/** One of the agent's tools as the task form offers it (`GET …/automations/grantable-tools`). */
|
|
125
145
|
export interface GrantableTool {
|
|
126
146
|
key: string;
|
|
127
147
|
/** The tool's display title, when it declares one. */
|
|
@@ -136,7 +156,7 @@ export interface GrantableTool {
|
|
|
136
156
|
* A grant as the task page shows it: `stale` when the tool's definition changed or the tool left
|
|
137
157
|
* (spec §7); null when the agent's tools cannot be read now.
|
|
138
158
|
*/
|
|
139
|
-
export interface
|
|
159
|
+
export interface AutomationGrantView extends AutomationGrant {
|
|
140
160
|
stale: boolean | null;
|
|
141
161
|
}
|
|
142
162
|
/** The latest settled (completed, failed or skipped) non-trial run of a task. */
|
|
@@ -147,11 +167,11 @@ export interface TaskLastRun {
|
|
|
147
167
|
at: Date;
|
|
148
168
|
}
|
|
149
169
|
/** A task in a list, with its latest settled run. */
|
|
150
|
-
export type
|
|
170
|
+
export type AutomationListItem = AutomationView & {
|
|
151
171
|
lastRun: TaskLastRun | null;
|
|
152
172
|
};
|
|
153
173
|
/** A task with its creator as a person (null when the account is gone). */
|
|
154
|
-
export type
|
|
174
|
+
export type AutomationView = Automation & {
|
|
155
175
|
account: PersonRef | null;
|
|
156
176
|
};
|
|
157
177
|
/**
|
|
@@ -171,16 +191,16 @@ export interface ChatTarget {
|
|
|
171
191
|
label: string;
|
|
172
192
|
}
|
|
173
193
|
/**
|
|
174
|
-
*
|
|
194
|
+
* Automations for people (spec §5, §7–§10): create, edit, pause, resume, delete, their runs
|
|
175
195
|
* and grants. Every write runs in one transaction under the org row lock (`OrgLock`), which also
|
|
176
196
|
* serializes the per-member and per-org caps, re-reads the actor's role there, and holds the task
|
|
177
197
|
* row (`FOR UPDATE`) so the scanner skips it until the write commits.
|
|
178
198
|
*
|
|
179
|
-
* Roles: `
|
|
199
|
+
* Roles: `automations.use` (member) creates and edits one's own tasks; `automations.manage` (admin)
|
|
180
200
|
* lists, pauses, resumes and deletes any task of the org, never edits another person's (the task
|
|
181
|
-
* runs as its creator). A task the caller may not see is `
|
|
201
|
+
* runs as its creator). A task the caller may not see is `automation.not_found`.
|
|
182
202
|
*/
|
|
183
|
-
export declare class
|
|
203
|
+
export declare class AutomationsService {
|
|
184
204
|
private readonly db;
|
|
185
205
|
readonly txHost: TransactionHost;
|
|
186
206
|
private readonly config;
|
|
@@ -197,43 +217,48 @@ export declare class ScheduledTasksService {
|
|
|
197
217
|
private readonly outbox;
|
|
198
218
|
/** Network grants: the org's sandbox-mode network (network ask-to-allow spec §8.1). */
|
|
199
219
|
private readonly sandbox;
|
|
200
|
-
|
|
220
|
+
/** Event automations: the trigger sources that serve an org (`trigger-source@1`). */
|
|
221
|
+
private readonly points;
|
|
222
|
+
private readonly displayNames;
|
|
223
|
+
constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, store: AutomationStore, orgLock: Pick<OrgLock, "lockAndAuthorize">, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">, tools: Pick<ToolRegistry, "forAgent">, extensions: Pick<ExtensionRegistry, "list">,
|
|
201
224
|
/** A task's model must resolve for the org and declare its effort (as a message's switch). */
|
|
202
225
|
providers: Pick<ProviderRegistry, "resolve">, log: Pick<KernelLogger, "warn">,
|
|
203
226
|
/** "Run now" owes the fire job (consumed by the worker role). */
|
|
204
227
|
outbox: Pick<OutboxService, "add">,
|
|
205
228
|
/** Network grants: the org's sandbox-mode network (network ask-to-allow spec §8.1). */
|
|
206
|
-
sandbox: Pick<SandboxService, "ceilingLimits" | "devicePolicy"
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
|
|
229
|
+
sandbox: Pick<SandboxService, "ceilingLimits" | "devicePolicy">,
|
|
230
|
+
/** Event automations: the trigger sources that serve an org (`trigger-source@1`). */
|
|
231
|
+
points: Pick<ExtensionPointDefaults, "providersFor">, displayNames: Pick<ExtensionDisplayNames, "many">);
|
|
232
|
+
create(orgId: string, accountId: string, input: CreateTaskInput, browserTimeZone?: string, source?: GrantWriteSource): Promise<Automation>;
|
|
233
|
+
/** Creator only: an org admin gets `automation.forbidden`, anyone else `automation.not_found`. */
|
|
234
|
+
update(orgId: string, accountId: string, id: string, patch: UpdateTaskInput): Promise<Automation>;
|
|
235
|
+
/** The creator, or an org admin (`automations.manage`); a task not active is returned as is. */
|
|
236
|
+
pause(orgId: string, actor: AutomationActor, id: string): Promise<Automation>;
|
|
212
237
|
/**
|
|
213
|
-
* The creator (`
|
|
238
|
+
* The creator (`automations.use`), or an org admin. The next run is computed from now (missed ticks
|
|
214
239
|
* are not caught up) and the failure count starts over. An ended task cannot be resumed.
|
|
215
240
|
*/
|
|
216
|
-
resume(orgId: string, actor:
|
|
241
|
+
resume(orgId: string, actor: AutomationActor, id: string): Promise<Automation>;
|
|
217
242
|
/** The creator, or an org admin. */
|
|
218
|
-
remove(orgId: string, actor:
|
|
243
|
+
remove(orgId: string, actor: AutomationActor, id: string): Promise<void>;
|
|
219
244
|
/** The creator, or an org admin. */
|
|
220
|
-
get(orgId: string, actor:
|
|
245
|
+
get(orgId: string, actor: AutomationActor, id: string): Promise<AutomationView>;
|
|
221
246
|
/** Each task with its creator as a person, in one query. */
|
|
222
247
|
private withAccounts;
|
|
223
248
|
/** The actor's own tasks; `all` (org admins only, else `forbidden`): every task of the org. */
|
|
224
|
-
list(orgId: string, actor:
|
|
249
|
+
list(orgId: string, actor: AutomationActor, opts?: {
|
|
225
250
|
all?: boolean;
|
|
226
251
|
conversationId?: string;
|
|
227
|
-
}): Promise<
|
|
252
|
+
}): Promise<AutomationListItem[]>;
|
|
228
253
|
/**
|
|
229
254
|
* The calendar between two instants (calendar spec §5): the runs and planned occurrences of the
|
|
230
255
|
* actor's own tasks, or with `all` (org admins only, else `forbidden`) every task of the org; with
|
|
231
|
-
* `taskId` only that task (one the actor may see, else `
|
|
256
|
+
* `taskId` only that task (one the actor may see, else `automation.not_found`), never collapsed.
|
|
232
257
|
* Another creator's runs come without `conversationId`, `error` and `missingGrants` (§15 Q3).
|
|
233
258
|
* A range longer than 43 days (2 with `taskId`), or not forward, is `validation_failed`. `now`
|
|
234
259
|
* is for tests.
|
|
235
260
|
*/
|
|
236
|
-
calendar(orgId: string, actor:
|
|
261
|
+
calendar(orgId: string, actor: AutomationActor, q: {
|
|
237
262
|
from: Date;
|
|
238
263
|
to: Date;
|
|
239
264
|
timeZone: string;
|
|
@@ -247,10 +272,29 @@ export declare class ScheduledTasksService {
|
|
|
247
272
|
private postingInto;
|
|
248
273
|
/** Each task with its latest settled non-trial run, in one query. */
|
|
249
274
|
private withLastRuns;
|
|
275
|
+
/**
|
|
276
|
+
* The trigger sources that serve the org now (`trigger-source@1` providers enabled in it with a
|
|
277
|
+
* valid config) and the org has not switched off (`eventSourcesOff`), each with its extension's
|
|
278
|
+
* display name and event declarations: what the automation form builds its event picker and
|
|
279
|
+
* filter rows from. A source whose `events()` fails or does not answer within `tools.timeoutMs`
|
|
280
|
+
* is left out (logged), so one broken source does not take the others' list down.
|
|
281
|
+
*/
|
|
282
|
+
eventSources(orgId: string): Promise<EventSourceView[]>;
|
|
283
|
+
/** A trigger source's declarations, within `tools.timeoutMs` (as the dispatcher asks it). */
|
|
284
|
+
private declaredEvents;
|
|
285
|
+
/**
|
|
286
|
+
* An event trigger as stored: the source must serve the org and not be switched off
|
|
287
|
+
* (`automation.event_source_unavailable`), every type must be declared by it and not directed
|
|
288
|
+
* (`automation.event_type_unknown`: a directed event wakes one agent through acceptance, never
|
|
289
|
+
* through an automation), and the filter must fit the selected types' facts
|
|
290
|
+
* (`automation.filter_invalid`). Whether an owner may see a subject is not checked here: dispatch
|
|
291
|
+
* enforces it through the source's `visible()` for the automation's owner.
|
|
292
|
+
*/
|
|
293
|
+
private checkEventTrigger;
|
|
250
294
|
/**
|
|
251
295
|
* The chats the caller can point a `chat` task at (spec §8): per active connection of the org
|
|
252
296
|
* whose extension is enabled in it, their DM threads (archived included) and, on a channel with
|
|
253
|
-
* threads, the groups they have a thread in. Members up (`
|
|
297
|
+
* threads, the groups they have a thread in. Members up (`automations.use`, the route's).
|
|
254
298
|
*/
|
|
255
299
|
chatTargets(orgId: string, accountId: string): Promise<ChatTarget[]>;
|
|
256
300
|
/**
|
|
@@ -260,24 +304,24 @@ export declare class ScheduledTasksService {
|
|
|
260
304
|
*/
|
|
261
305
|
grantableTools(orgId: string, accountId: string, agentId: string): Promise<GrantableTool[]>;
|
|
262
306
|
/** The task's runs, latest first (default 50, at most 200); visible as {@link get}. */
|
|
263
|
-
runs(orgId: string, actor:
|
|
307
|
+
runs(orgId: string, actor: AutomationActor, id: string, limit?: number): Promise<TaskRun[]>;
|
|
264
308
|
/** The task's grants; visible as {@link get}. */
|
|
265
|
-
grants(orgId: string, actor:
|
|
309
|
+
grants(orgId: string, actor: AutomationActor, id: string): Promise<AutomationGrantView[]>;
|
|
266
310
|
/**
|
|
267
311
|
* Creator only; each grant is checked as at create (spec §7); network domains only from a web
|
|
268
312
|
* session (`source.fromSession`).
|
|
269
313
|
*/
|
|
270
|
-
addGrants(orgId: string, accountId: string, id: string, grants: GrantInput[], source?: GrantWriteSource): Promise<
|
|
314
|
+
addGrants(orgId: string, accountId: string, id: string, grants: GrantInput[], source?: GrantWriteSource): Promise<AutomationGrant[]>;
|
|
271
315
|
/** Creator only; removing a grant the task does not have is a no-op. */
|
|
272
316
|
removeGrant(orgId: string, accountId: string, id: string, toolKey: string): Promise<void>;
|
|
273
317
|
/**
|
|
274
|
-
* The creator's
|
|
318
|
+
* The creator's automations that need attention (spec §8), derived live: a paused task whose
|
|
275
319
|
* reason is not `creator` (resuming clears it), an active task whose latest settled non-trial
|
|
276
320
|
* run failed (the next good run clears it), and a task whose latest settled non-trial run was
|
|
277
321
|
* refused tools, connections or domains (a tool granted since drops out, a domain too while the
|
|
278
322
|
* org's network allowlist admits it; the next clean run clears the rest). Newest first.
|
|
279
323
|
*/
|
|
280
|
-
attentionFor(orgId: string, accountId: string): Promise<
|
|
324
|
+
attentionFor(orgId: string, accountId: string): Promise<AutomationAttention[]>;
|
|
281
325
|
private roleOrNull;
|
|
282
326
|
/**
|
|
283
327
|
* The agent's tools by key (their `requiredRole` and definition hash) as the creator sees them;
|
|
@@ -290,24 +334,26 @@ export declare class ScheduledTasksService {
|
|
|
290
334
|
* delivery path); `by` is the account that caused it, null for the kernel. A task already
|
|
291
335
|
* paused or ended keeps its state and reason.
|
|
292
336
|
*/
|
|
293
|
-
pauseFor(t: KernelSchemaDb, taskId: string, reason:
|
|
337
|
+
pauseFor(t: KernelSchemaDb, taskId: string, reason: AutomationPauseReason, by: string | null): Promise<void>;
|
|
294
338
|
/**
|
|
295
339
|
* "Run now" (spec §6), creator only: a task run for the request time, outside the schedule (no
|
|
296
340
|
* unique-key conflict with a tick, and `next_run_at` does not move), fired at once through the
|
|
297
341
|
* fire job its transaction owes. `trial`: an attended trial run whose approvals become the task's
|
|
298
342
|
* grants (§7). Counted in the rate limit like any run. An ended task cannot run; a paused one
|
|
299
343
|
* can (only its creator gets here: the run is `manual`, which the fire's paused check lets by).
|
|
344
|
+
* An event automation has neither (`automation.run_now_unsupported`): its runs are made from its
|
|
345
|
+
* events (collaboration spec §4.1).
|
|
300
346
|
*/
|
|
301
347
|
runNow(orgId: string, accountId: string, id: string, opts: {
|
|
302
348
|
trial: boolean;
|
|
303
349
|
}): Promise<TaskRun>;
|
|
304
|
-
/** The live role of a member of the org; not a member → `
|
|
350
|
+
/** The live role of a member of the org; not a member → `automation.not_found`. */
|
|
305
351
|
private liveRole;
|
|
306
|
-
/** The actor's own task, row-locked; another's: `
|
|
352
|
+
/** The actor's own task, row-locked; another's: `automation.forbidden` for an admin, else 404. */
|
|
307
353
|
private lockOwn;
|
|
308
354
|
/**
|
|
309
355
|
* A task the actor may pause, resume or delete, row-locked under the org lock: their own (with
|
|
310
|
-
* `creatorAction`), or any as an org admin (`
|
|
356
|
+
* `creatorAction`), or any as an org admin (`automations.manage`); otherwise `automation.not_found`.
|
|
311
357
|
*/
|
|
312
358
|
private lockManaged;
|
|
313
359
|
/**
|
|
@@ -323,9 +369,10 @@ export declare class ScheduledTasksService {
|
|
|
323
369
|
/** The channel's declared features; undefined when its extension is not loaded here. */
|
|
324
370
|
private channelFeatures;
|
|
325
371
|
/**
|
|
326
|
-
* A task's model, effort and device (spec §4): `new` mode
|
|
327
|
-
*
|
|
328
|
-
* conversation for their later turns),
|
|
372
|
+
* A task's model, effort and device (spec §4): `new` mode takes all three and `subject` mode a
|
|
373
|
+
* model and effort (not a device). A conversation or chat task runs with that conversation's
|
|
374
|
+
* selection and device (a task must not switch a person's conversation for their later turns),
|
|
375
|
+
* so those modes refuse them (`validation_failed`).
|
|
329
376
|
* The model must resolve for the org (`agent.model_unavailable`, as a message's switch) and
|
|
330
377
|
* declare the effort (`validation_failed`); the device must be one of the creator's
|
|
331
378
|
* (`checkDevice`, when `deviceChanged`).
|
|
@@ -340,7 +387,7 @@ export declare class ScheduledTasksService {
|
|
|
340
387
|
* `deviceId`, the task's device (null: none can be determined, the device rule is skipped),
|
|
341
388
|
* stored with `spec_hash` `network` and no connector (plan P-D7), and only when
|
|
342
389
|
* `source.fromSession` (a person on the task page; never a token, the Platform tool or the
|
|
343
|
-
*
|
|
390
|
+
* automation tools). Each git push key (`git:push`, `git:push:<owner>/<repo>`, the repository
|
|
344
391
|
* lower-cased) is refused by {@link gitGrantRefusal} and stored with `spec_hash` `git` and no
|
|
345
392
|
* connector, also only when `source.fromSession`. Duplicates keep the last.
|
|
346
393
|
*/
|