@capybara-hq/kernel 0.1.0-rc.20 → 0.1.0-rc.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +10 -1
- package/dist/agents/admin-agents.d.ts +16 -3
- package/dist/agents/admin-agents.js +65 -7
- package/dist/agents/agents.schemas.d.ts +24 -6
- package/dist/agents/agents.service.d.ts +4 -3
- package/dist/agents/agents.service.js +39 -26
- package/dist/agents/definition.d.ts +44 -6
- package/dist/agents/definition.js +86 -18
- package/dist/agents/from-template.d.ts +6 -3
- package/dist/agents/from-template.js +57 -44
- package/dist/agents/org-templates.js +97 -41
- package/dist/agents/templates.d.ts +6 -0
- package/dist/agents/templates.js +15 -1
- package/dist/catalog/admin-catalog.controller.d.ts +2 -4
- package/dist/catalog/admin-catalog.controller.js +2 -6
- package/dist/catalog/catalog.module.js +3 -0
- package/dist/catalog/claude/report.d.ts +9 -2
- package/dist/catalog/claude/report.js +1 -0
- package/dist/catalog/claude/translate.js +1 -1
- package/dist/catalog/component-promotion.js +1 -2
- package/dist/catalog/component-state.d.ts +13 -1
- package/dist/catalog/component-state.js +14 -5
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/marketplaces.service.js +2 -1
- package/dist/catalog/org-catalog.controller.d.ts +13 -3
- package/dist/catalog/org-catalog.controller.js +26 -4
- package/dist/catalog/org-catalog.schemas.d.ts +13 -0
- package/dist/catalog/org-catalog.schemas.js +34 -0
- package/dist/catalog/org-plugin-uploads.controller.js +0 -1
- package/dist/catalog/org-plugin-uploads.d.ts +0 -1
- package/dist/catalog/org-plugin-uploads.js +0 -3
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +0 -1
- package/dist/catalog/org-plugin-uploads.schemas.js +0 -2
- package/dist/catalog/platform-components.d.ts +0 -1
- package/dist/catalog/platform-components.js +3 -8
- package/dist/catalog/plugin-import.d.ts +0 -8
- package/dist/catalog/plugin-import.js +4 -35
- package/dist/catalog/plugin-install.d.ts +2 -2
- package/dist/catalog/plugin-install.js +2 -2
- package/dist/catalog/plugin-package.d.ts +7 -0
- package/dist/catalog/plugin-package.js +27 -1
- package/dist/catalog/plugin-upgrade.d.ts +5 -6
- package/dist/catalog/plugin-upgrade.js +5 -23
- package/dist/catalog/requests.service.d.ts +66 -10
- package/dist/catalog/requests.service.js +196 -15
- package/dist/channels/actions.d.ts +2 -0
- package/dist/channels/actions.js +19 -4
- package/dist/channels/cards.d.ts +16 -2
- package/dist/channels/cards.js +40 -7
- package/dist/channels/channels.module.js +3 -0
- package/dist/channels/outbound.d.ts +22 -1
- package/dist/channels/outbound.js +116 -7
- package/dist/channels/phrases.d.ts +25 -0
- package/dist/channels/phrases.js +19 -0
- package/dist/channels/threads.d.ts +12 -0
- package/dist/channels/threads.js +34 -0
- package/dist/config/schema.d.ts +23 -1
- package/dist/config/schema.js +105 -5
- package/dist/conversations/conversations.service.d.ts +42 -9
- package/dist/conversations/conversations.service.js +57 -25
- package/dist/conversations/events.d.ts +106 -11
- package/dist/conversations/events.js +121 -18
- package/dist/conversations/message-context.d.ts +6 -3
- package/dist/conversations/message-context.js +14 -10
- package/dist/conversations/queue.d.ts +15 -2
- package/dist/conversations/queue.js +22 -3
- package/dist/conversations/queue.service.d.ts +12 -6
- package/dist/conversations/queue.service.js +36 -13
- package/dist/db/kernel-schema.d.ts +105 -3
- package/dist/devices/conversation-devices.d.ts +8 -1
- package/dist/devices/conversation-devices.js +8 -0
- package/dist/devices/devices.controller.d.ts +21 -4
- package/dist/devices/devices.controller.js +46 -8
- package/dist/devices/devices.schemas.d.ts +9 -1
- package/dist/devices/devices.schemas.js +11 -3
- package/dist/devices/devices.service.d.ts +176 -4
- package/dist/devices/devices.service.js +341 -6
- package/dist/devices/dto.d.ts +56 -3
- package/dist/devices/dto.js +51 -1
- package/dist/devices/public-suffix.d.ts +6 -0
- package/dist/devices/public-suffix.js +79 -0
- package/dist/errors.d.ts +46 -5
- package/dist/errors.js +46 -5
- package/dist/evals/reconstruct.d.ts +18 -13
- package/dist/evals/reconstruct.js +50 -36
- package/dist/evals/recorded-tools.d.ts +7 -7
- package/dist/evals/recorded-tools.js +4 -3
- package/dist/evals/trajectory.d.ts +6 -1
- package/dist/evals/trajectory.js +7 -0
- package/dist/extensions/bootstrap.d.ts +49 -10
- package/dist/extensions/bootstrap.js +104 -27
- package/dist/extensions/package.js +2 -2
- package/dist/http/api.module.js +5 -0
- package/dist/inbox/inbox.module.js +2 -1
- package/dist/inbox/inbox.service.d.ts +19 -4
- package/dist/inbox/inbox.service.js +14 -3
- package/dist/infra/config/kernel-config.service.js +11 -0
- package/dist/infra/events/kernel-events.d.ts +2 -1
- package/dist/lifecycle/kernel-lifecycle.d.ts +5 -1
- package/dist/lifecycle/kernel-lifecycle.js +16 -4
- package/dist/local-devices/device-policy.service.d.ts +65 -0
- package/dist/local-devices/device-policy.service.js +217 -0
- package/dist/local-devices/local-device-gateway.js +4 -1
- package/dist/local-devices/local-device-provider.d.ts +40 -3
- package/dist/local-devices/local-device-provider.js +109 -7
- package/dist/local-devices/local-devices.module.d.ts +2 -1
- package/dist/local-devices/local-devices.module.js +19 -3
- package/dist/local-devices/machines.d.ts +14 -3
- package/dist/local-devices/machines.js +41 -3
- package/dist/local-devices/network-grants.d.ts +104 -0
- package/dist/local-devices/network-grants.js +288 -0
- package/dist/local-devices/policy-summary.d.ts +20 -0
- package/dist/local-devices/policy-summary.js +63 -0
- package/dist/orgs/orgs.module.js +4 -10
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +4 -0
- package/dist/orgs/settings.controller.js +2 -1
- package/dist/orgs/settings.service.d.ts +164 -12
- package/dist/orgs/settings.service.js +212 -24
- package/dist/platform/exclusions.js +11 -1
- package/dist/platform/operation.js +4 -0
- package/dist/platform/ops/admin-items.ops.js +1 -1
- package/dist/platform/ops/agent-skills.ops.js +2 -2
- package/dist/platform/ops/agent-templates.ops.js +2 -2
- package/dist/platform/ops/agents.ops.js +11 -15
- package/dist/platform/ops/devices.ops.js +3 -1
- package/dist/platform/ops/inbox.ops.js +19 -0
- package/dist/platform/ops/org-settings.ops.js +14 -5
- package/dist/platform/ops/platform.ops.d.ts +9 -1
- package/dist/platform/ops/platform.ops.js +34 -12
- package/dist/platform/ops/requests.ops.js +3 -2
- package/dist/platform/ops/schedules.ops.d.ts +21 -0
- package/dist/platform/ops/schedules.ops.js +470 -0
- package/dist/platform/ops/skills.ops.js +3 -3
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +5 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/context/build.js +13 -4
- package/dist/runtime/context/compaction.js +6 -3
- package/dist/runtime/context/device-paths.d.ts +43 -21
- package/dist/runtime/context/device-paths.js +104 -21
- package/dist/runtime/context/run-context.d.ts +9 -0
- package/dist/runtime/context/run-context.js +8 -0
- package/dist/runtime/context/skills.d.ts +14 -1
- package/dist/runtime/context/skills.js +36 -5
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -5
- package/dist/runtime/run-finish.d.ts +6 -1
- package/dist/runtime/run-finish.js +16 -2
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +14 -33
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/runtime/subagents/definition.d.ts +32 -14
- package/dist/runtime/subagents/definition.js +106 -109
- package/dist/runtime/subagents/dispatch.js +4 -3
- package/dist/runtime/subagents/preamble.d.ts +2 -1
- package/dist/runtime/subagents/preamble.js +2 -1
- package/dist/runtime/waits.js +14 -4
- package/dist/sandbox/sandbox.service.d.ts +120 -10
- package/dist/sandbox/sandbox.service.js +335 -28
- package/dist/sandbox/tiers.d.ts +86 -0
- package/dist/sandbox/tiers.js +96 -0
- package/dist/schedules/effective-settings.d.ts +16 -0
- package/dist/schedules/effective-settings.js +17 -0
- package/dist/schedules/errors.d.ts +8 -0
- package/dist/schedules/errors.js +8 -0
- package/dist/schedules/fire.d.ts +118 -0
- package/dist/schedules/fire.js +625 -0
- package/dist/schedules/grant-rules.d.ts +94 -0
- package/dist/schedules/grant-rules.js +126 -0
- package/dist/schedules/job-ids.d.ts +32 -0
- package/dist/schedules/job-ids.js +27 -0
- package/dist/schedules/pause.d.ts +9 -0
- package/dist/schedules/pause.js +33 -0
- package/dist/schedules/run-tracker.d.ts +81 -0
- package/dist/schedules/run-tracker.js +333 -0
- package/dist/schedules/scan.job.d.ts +64 -0
- package/dist/schedules/scan.job.js +303 -0
- package/dist/schedules/schedule-math.d.ts +31 -0
- package/dist/schedules/schedule-math.js +223 -0
- package/dist/schedules/scheduled-tasks.service.d.ts +351 -0
- package/dist/schedules/scheduled-tasks.service.js +1193 -0
- package/dist/schedules/schedules.controller.d.ts +68 -0
- package/dist/schedules/schedules.controller.js +242 -0
- package/dist/schedules/schedules.module.d.ts +16 -0
- package/dist/schedules/schedules.module.js +65 -0
- package/dist/schedules/schedules.schemas.d.ts +316 -0
- package/dist/schedules/schedules.schemas.js +186 -0
- package/dist/schedules/store.d.ts +81 -0
- package/dist/schedules/store.js +390 -0
- package/dist/schedules/store.module.d.ts +6 -0
- package/dist/schedules/store.module.js +21 -0
- package/dist/schedules/types.d.ts +108 -0
- package/dist/schedules/types.js +1 -0
- package/dist/schedules/unattended.d.ts +117 -0
- package/dist/schedules/unattended.js +228 -0
- package/dist/setup/oauth-token-probe.js +8 -4
- package/dist/skills/agent-skills.service.d.ts +4 -8
- package/dist/skills/agent-skills.service.js +18 -53
- package/dist/skills/catalog.d.ts +65 -62
- package/dist/skills/catalog.js +109 -206
- package/dist/skills/conversation-catalog.d.ts +3 -3
- package/dist/skills/conversation-catalog.js +5 -12
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/skills.controller.d.ts +3 -1
- package/dist/skills/skills.service.d.ts +38 -37
- package/dist/skills/skills.service.js +168 -107
- package/dist/skills/usable.d.ts +57 -8
- package/dist/skills/usable.js +172 -38
- package/dist/tools/approvals.controller.d.ts +4 -2
- package/dist/tools/approvals.controller.js +17 -2
- package/dist/tools/approvals.schemas.d.ts +1 -0
- package/dist/tools/approvals.schemas.js +3 -1
- package/dist/tools/approvals.service.d.ts +182 -7
- package/dist/tools/approvals.service.js +597 -13
- package/dist/tools/builtin-names.d.ts +25 -4
- package/dist/tools/builtin-names.js +45 -4
- package/dist/tools/builtins/builtin-tools.d.ts +8 -0
- package/dist/tools/builtins/builtin-tools.js +23 -2
- package/dist/tools/builtins/sandbox/bash.js +16 -7
- package/dist/tools/builtins/sandbox/common.d.ts +1 -1
- package/dist/tools/builtins/sandbox/common.js +33 -10
- package/dist/tools/builtins/sandbox/edit.js +7 -3
- package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
- package/dist/tools/builtins/sandbox/file-state.js +33 -3
- package/dist/tools/builtins/sandbox/write.js +8 -4
- package/dist/tools/builtins/schedules.d.ts +107 -0
- package/dist/tools/builtins/schedules.js +789 -0
- package/dist/tools/elicitation.d.ts +2 -0
- package/dist/tools/elicitation.js +1 -1
- package/dist/tools/fixed-ask.d.ts +7 -0
- package/dist/tools/fixed-ask.js +9 -0
- package/dist/tools/network-asks.d.ts +109 -0
- package/dist/tools/network-asks.js +221 -0
- package/dist/tools/pipeline.d.ts +53 -6
- package/dist/tools/pipeline.js +202 -13
- package/dist/tools/policy.d.ts +21 -8
- package/dist/tools/policy.js +63 -9
- package/dist/tools/registry.d.ts +10 -1
- package/dist/tools/tools.module.js +12 -0
- package/package.json +2 -2
- package/src/migrations/0113_scheduled_tasks.sql +108 -0
- package/src/migrations/0114_network_asks.sql +23 -0
- package/src/migrations/0115_network_requests.sql +28 -0
- package/src/migrations/0116_skills_default_on.sql +37 -0
- package/src/migrations/0117_sandbox_tiers.sql +11 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
import type { CreateTaskInput, GrantInput, UpdateTaskInput } from "./scheduled-tasks.service.js";
|
|
4
|
+
/** Longest task name and prompt, in characters (the same bounds as the service). */
|
|
5
|
+
export declare const SCHEDULE_NAME_MAX = 200;
|
|
6
|
+
export declare const SCHEDULE_PROMPT_MAX = 20000;
|
|
7
|
+
/**
|
|
8
|
+
* When a task fires, before the zone is fixed: a 5-field cron, or a local date-time
|
|
9
|
+
* (`2026-12-01T09:00`, no offset) for a one-off run.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ScheduleTriggerInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
|
+
kind: z.ZodLiteral<"cron">;
|
|
13
|
+
expr: z.ZodString;
|
|
14
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
15
|
+
kind: z.ZodLiteral<"once">;
|
|
16
|
+
at: z.ZodString;
|
|
17
|
+
}, z.core.$strict>], "kind">;
|
|
18
|
+
/** The IM chat a `chat`-mode task posts into. */
|
|
19
|
+
export declare const ScheduleChatInput: z.ZodObject<{
|
|
20
|
+
connectionId: z.ZodString;
|
|
21
|
+
chatId: z.ZodString;
|
|
22
|
+
chatType: z.ZodEnum<{
|
|
23
|
+
dm: "dm";
|
|
24
|
+
group: "group";
|
|
25
|
+
}>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
/**
|
|
28
|
+
* A model pick: the same `{ provider, model }` an agent's definition uses, its strings bounded on
|
|
29
|
+
* the fields (so the JSON schema shows the bounds). `new` mode only.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ScheduleModel: z.ZodObject<{
|
|
32
|
+
provider: z.ZodString;
|
|
33
|
+
model: z.ZodString;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
export declare const ScheduleEffort: z.ZodEnum<{
|
|
36
|
+
high: "high";
|
|
37
|
+
low: "low";
|
|
38
|
+
max: "max";
|
|
39
|
+
medium: "medium";
|
|
40
|
+
xhigh: "xhigh";
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* A tool the creator pre-approves for the task, or a domain as `network:<host>` (network
|
|
44
|
+
* ask-to-allow spec §8.1: one exact host; a host name is at most 253 characters).
|
|
45
|
+
*/
|
|
46
|
+
export declare const ScheduleGrantInput: z.ZodObject<{
|
|
47
|
+
toolKey: z.ZodString;
|
|
48
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
export declare const ScheduleCreateBody: z.ZodObject<{
|
|
51
|
+
agentId: z.ZodString;
|
|
52
|
+
name: z.ZodString;
|
|
53
|
+
prompt: z.ZodString;
|
|
54
|
+
trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
55
|
+
kind: z.ZodLiteral<"cron">;
|
|
56
|
+
expr: z.ZodString;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
kind: z.ZodLiteral<"once">;
|
|
59
|
+
at: z.ZodString;
|
|
60
|
+
}, z.core.$strict>], "kind">;
|
|
61
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
62
|
+
mode: z.ZodEnum<{
|
|
63
|
+
chat: "chat";
|
|
64
|
+
conversation: "conversation";
|
|
65
|
+
new: "new";
|
|
66
|
+
}>;
|
|
67
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
chat: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
connectionId: z.ZodString;
|
|
70
|
+
chatId: z.ZodString;
|
|
71
|
+
chatType: z.ZodEnum<{
|
|
72
|
+
dm: "dm";
|
|
73
|
+
group: "group";
|
|
74
|
+
}>;
|
|
75
|
+
}, z.core.$strict>>;
|
|
76
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
77
|
+
provider: z.ZodString;
|
|
78
|
+
model: z.ZodString;
|
|
79
|
+
}, z.core.$strict>>;
|
|
80
|
+
effort: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
high: "high";
|
|
82
|
+
low: "low";
|
|
83
|
+
max: "max";
|
|
84
|
+
medium: "medium";
|
|
85
|
+
xhigh: "xhigh";
|
|
86
|
+
}>>;
|
|
87
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
89
|
+
grants: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
+
toolKey: z.ZodString;
|
|
91
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>>>;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
export declare const ScheduleUpdateBody: z.ZodObject<{
|
|
95
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
96
|
+
name: z.ZodOptional<z.ZodString>;
|
|
97
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
98
|
+
trigger: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
99
|
+
kind: z.ZodLiteral<"cron">;
|
|
100
|
+
expr: z.ZodString;
|
|
101
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
102
|
+
kind: z.ZodLiteral<"once">;
|
|
103
|
+
at: z.ZodString;
|
|
104
|
+
}, z.core.$strict>], "kind">>;
|
|
105
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
106
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
107
|
+
chat: "chat";
|
|
108
|
+
conversation: "conversation";
|
|
109
|
+
new: "new";
|
|
110
|
+
}>>;
|
|
111
|
+
conversationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
chat: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
113
|
+
connectionId: z.ZodString;
|
|
114
|
+
chatId: z.ZodString;
|
|
115
|
+
chatType: z.ZodEnum<{
|
|
116
|
+
dm: "dm";
|
|
117
|
+
group: "group";
|
|
118
|
+
}>;
|
|
119
|
+
}, z.core.$strict>>>;
|
|
120
|
+
model: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
121
|
+
provider: z.ZodString;
|
|
122
|
+
model: z.ZodString;
|
|
123
|
+
}, z.core.$strict>>>;
|
|
124
|
+
effort: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
125
|
+
high: "high";
|
|
126
|
+
low: "low";
|
|
127
|
+
max: "max";
|
|
128
|
+
medium: "medium";
|
|
129
|
+
xhigh: "xhigh";
|
|
130
|
+
}>>>;
|
|
131
|
+
deviceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
132
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
}, z.core.$strict>;
|
|
134
|
+
export declare const ScheduleListQuery: z.ZodObject<{
|
|
135
|
+
all: z.ZodOptional<z.ZodEnum<{
|
|
136
|
+
false: "false";
|
|
137
|
+
true: "true";
|
|
138
|
+
}>>;
|
|
139
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.core.$strict>;
|
|
141
|
+
export declare const ScheduleChatTargetsQuery: z.ZodObject<{}, z.core.$strict>;
|
|
142
|
+
export declare const ScheduleGrantableQuery: z.ZodObject<{
|
|
143
|
+
agentId: z.ZodString;
|
|
144
|
+
}, z.core.$strict>;
|
|
145
|
+
export declare const ScheduleParams: z.ZodObject<{
|
|
146
|
+
id: z.ZodString;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
export declare const ScheduleRunBody: z.ZodObject<{
|
|
149
|
+
trial: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
+
}, z.core.$strict>;
|
|
151
|
+
export declare const ScheduleRunsQuery: z.ZodObject<{
|
|
152
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
153
|
+
}, z.core.$strict>;
|
|
154
|
+
export declare const ScheduleGrantsBody: z.ZodObject<{
|
|
155
|
+
grants: z.ZodArray<z.ZodObject<{
|
|
156
|
+
toolKey: z.ZodString;
|
|
157
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
158
|
+
}, z.core.$strict>>;
|
|
159
|
+
}, z.core.$strict>;
|
|
160
|
+
export declare const ScheduleGrantParams: z.ZodObject<{
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
toolKey: z.ZodString;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
declare const ScheduleCreateBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
165
|
+
agentId: z.ZodString;
|
|
166
|
+
name: z.ZodString;
|
|
167
|
+
prompt: z.ZodString;
|
|
168
|
+
trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
169
|
+
kind: z.ZodLiteral<"cron">;
|
|
170
|
+
expr: z.ZodString;
|
|
171
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
172
|
+
kind: z.ZodLiteral<"once">;
|
|
173
|
+
at: z.ZodString;
|
|
174
|
+
}, z.core.$strict>], "kind">;
|
|
175
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
176
|
+
mode: z.ZodEnum<{
|
|
177
|
+
chat: "chat";
|
|
178
|
+
conversation: "conversation";
|
|
179
|
+
new: "new";
|
|
180
|
+
}>;
|
|
181
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
182
|
+
chat: z.ZodOptional<z.ZodObject<{
|
|
183
|
+
connectionId: z.ZodString;
|
|
184
|
+
chatId: z.ZodString;
|
|
185
|
+
chatType: z.ZodEnum<{
|
|
186
|
+
dm: "dm";
|
|
187
|
+
group: "group";
|
|
188
|
+
}>;
|
|
189
|
+
}, z.core.$strict>>;
|
|
190
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
191
|
+
provider: z.ZodString;
|
|
192
|
+
model: z.ZodString;
|
|
193
|
+
}, z.core.$strict>>;
|
|
194
|
+
effort: z.ZodOptional<z.ZodEnum<{
|
|
195
|
+
high: "high";
|
|
196
|
+
low: "low";
|
|
197
|
+
max: "max";
|
|
198
|
+
medium: "medium";
|
|
199
|
+
xhigh: "xhigh";
|
|
200
|
+
}>>;
|
|
201
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
202
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
203
|
+
grants: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
204
|
+
toolKey: z.ZodString;
|
|
205
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
206
|
+
}, z.core.$strict>>>;
|
|
207
|
+
}, z.core.$strict>>;
|
|
208
|
+
export declare class ScheduleCreateBodyDto extends ScheduleCreateBodyDto_base {
|
|
209
|
+
}
|
|
210
|
+
declare const ScheduleUpdateBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
211
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
212
|
+
name: z.ZodOptional<z.ZodString>;
|
|
213
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
214
|
+
trigger: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
215
|
+
kind: z.ZodLiteral<"cron">;
|
|
216
|
+
expr: z.ZodString;
|
|
217
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
218
|
+
kind: z.ZodLiteral<"once">;
|
|
219
|
+
at: z.ZodString;
|
|
220
|
+
}, z.core.$strict>], "kind">>;
|
|
221
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
222
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
223
|
+
chat: "chat";
|
|
224
|
+
conversation: "conversation";
|
|
225
|
+
new: "new";
|
|
226
|
+
}>>;
|
|
227
|
+
conversationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
228
|
+
chat: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
229
|
+
connectionId: z.ZodString;
|
|
230
|
+
chatId: z.ZodString;
|
|
231
|
+
chatType: z.ZodEnum<{
|
|
232
|
+
dm: "dm";
|
|
233
|
+
group: "group";
|
|
234
|
+
}>;
|
|
235
|
+
}, z.core.$strict>>>;
|
|
236
|
+
model: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
237
|
+
provider: z.ZodString;
|
|
238
|
+
model: z.ZodString;
|
|
239
|
+
}, z.core.$strict>>>;
|
|
240
|
+
effort: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
241
|
+
high: "high";
|
|
242
|
+
low: "low";
|
|
243
|
+
max: "max";
|
|
244
|
+
medium: "medium";
|
|
245
|
+
xhigh: "xhigh";
|
|
246
|
+
}>>>;
|
|
247
|
+
deviceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
248
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
249
|
+
}, z.core.$strict>>;
|
|
250
|
+
export declare class ScheduleUpdateBodyDto extends ScheduleUpdateBodyDto_base {
|
|
251
|
+
}
|
|
252
|
+
declare const ScheduleListQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
253
|
+
all: z.ZodOptional<z.ZodEnum<{
|
|
254
|
+
false: "false";
|
|
255
|
+
true: "true";
|
|
256
|
+
}>>;
|
|
257
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
258
|
+
}, z.core.$strict>>;
|
|
259
|
+
export declare class ScheduleListQueryDto extends ScheduleListQueryDto_base {
|
|
260
|
+
}
|
|
261
|
+
declare const ScheduleChatTargetsQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{}, z.core.$strict>>;
|
|
262
|
+
export declare class ScheduleChatTargetsQueryDto extends ScheduleChatTargetsQueryDto_base {
|
|
263
|
+
}
|
|
264
|
+
declare const ScheduleGrantableQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
265
|
+
agentId: z.ZodString;
|
|
266
|
+
}, z.core.$strict>>;
|
|
267
|
+
export declare class ScheduleGrantableQueryDto extends ScheduleGrantableQueryDto_base {
|
|
268
|
+
}
|
|
269
|
+
declare const ScheduleParamsDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
270
|
+
id: z.ZodString;
|
|
271
|
+
}, z.core.$strip>>;
|
|
272
|
+
export declare class ScheduleParamsDto extends ScheduleParamsDto_base {
|
|
273
|
+
}
|
|
274
|
+
declare const ScheduleRunBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
275
|
+
trial: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
}, z.core.$strict>>;
|
|
277
|
+
export declare class ScheduleRunBodyDto extends ScheduleRunBodyDto_base {
|
|
278
|
+
}
|
|
279
|
+
declare const ScheduleRunsQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
280
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
281
|
+
}, z.core.$strict>>;
|
|
282
|
+
export declare class ScheduleRunsQueryDto extends ScheduleRunsQueryDto_base {
|
|
283
|
+
}
|
|
284
|
+
declare const ScheduleGrantsBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
285
|
+
grants: z.ZodArray<z.ZodObject<{
|
|
286
|
+
toolKey: z.ZodString;
|
|
287
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
288
|
+
}, z.core.$strict>>;
|
|
289
|
+
}, z.core.$strict>>;
|
|
290
|
+
export declare class ScheduleGrantsBodyDto extends ScheduleGrantsBodyDto_base {
|
|
291
|
+
}
|
|
292
|
+
declare const ScheduleGrantParamsDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
293
|
+
id: z.ZodString;
|
|
294
|
+
toolKey: z.ZodString;
|
|
295
|
+
}, z.core.$strip>>;
|
|
296
|
+
export declare class ScheduleGrantParamsDto extends ScheduleGrantParamsDto_base {
|
|
297
|
+
}
|
|
298
|
+
/** The schedule routes the Platform operations mirror (`check:platform-ops` keys). */
|
|
299
|
+
export declare const SCHEDULE_ROUTES: readonly RouteSchemas[];
|
|
300
|
+
/** The object without its undefined properties (the service's inputs take absent, not undefined). */
|
|
301
|
+
export declare function defined<T extends object>(o: T): {
|
|
302
|
+
[K in keyof T]: Exclude<T[K], undefined>;
|
|
303
|
+
};
|
|
304
|
+
/** A grant list as the service's input. */
|
|
305
|
+
export declare const grantsOf: (grants: z.infer<typeof ScheduleGrantsBody>["grants"]) => GrantInput[];
|
|
306
|
+
/**
|
|
307
|
+
* A create body as the service's input. `timeZone` is the browser zone and is not part of it: the
|
|
308
|
+
* service uses it only when the account has no zone (spec §5), so it is returned separately.
|
|
309
|
+
*/
|
|
310
|
+
export declare function createInputOf(body: z.infer<typeof ScheduleCreateBody>): {
|
|
311
|
+
input: CreateTaskInput;
|
|
312
|
+
browserTimeZone: string | undefined;
|
|
313
|
+
};
|
|
314
|
+
/** A patch body as the service's input (an explicit `timeZone` changes the task's zone). */
|
|
315
|
+
export declare function updateInputOf(body: z.infer<typeof ScheduleUpdateBody>): UpdateTaskInput;
|
|
316
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
3
|
+
import { IanaTimeZone } from "../time-zone.js";
|
|
4
|
+
/** Longest task name and prompt, in characters (the same bounds as the service). */
|
|
5
|
+
export const SCHEDULE_NAME_MAX = 200;
|
|
6
|
+
export const SCHEDULE_PROMPT_MAX = 20_000;
|
|
7
|
+
const Id = z.string().min(1).max(100);
|
|
8
|
+
/**
|
|
9
|
+
* When a task fires, before the zone is fixed: a 5-field cron, or a local date-time
|
|
10
|
+
* (`2026-12-01T09:00`, no offset) for a one-off run.
|
|
11
|
+
*/
|
|
12
|
+
export const ScheduleTriggerInput = z.discriminatedUnion("kind", [
|
|
13
|
+
z.object({ kind: z.literal("cron"), expr: z.string().trim().min(1).max(200) }).strict(),
|
|
14
|
+
z.object({ kind: z.literal("once"), at: z.string().trim().min(1).max(40) }).strict(),
|
|
15
|
+
]);
|
|
16
|
+
/** The IM chat a `chat`-mode task posts into. */
|
|
17
|
+
export const ScheduleChatInput = z
|
|
18
|
+
.object({
|
|
19
|
+
connectionId: Id,
|
|
20
|
+
chatId: z.string().min(1).max(500),
|
|
21
|
+
chatType: z.enum(["dm", "group"]),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
/**
|
|
25
|
+
* A model pick: the same `{ provider, model }` an agent's definition uses, its strings bounded on
|
|
26
|
+
* the fields (so the JSON schema shows the bounds). `new` mode only.
|
|
27
|
+
*/
|
|
28
|
+
export const ScheduleModel = z
|
|
29
|
+
.object({ provider: z.string().min(1).max(100), model: z.string().min(1).max(200) })
|
|
30
|
+
.strict();
|
|
31
|
+
export const ScheduleEffort = z.enum(["low", "medium", "high", "xhigh", "max"]);
|
|
32
|
+
/** An end time as an ISO 8601 timestamp with an offset (`2026-12-31T00:00:00Z`). */
|
|
33
|
+
const ExpiresAt = z.string().datetime({ offset: true });
|
|
34
|
+
/**
|
|
35
|
+
* A tool the creator pre-approves for the task, or a domain as `network:<host>` (network
|
|
36
|
+
* ask-to-allow spec §8.1: one exact host; a host name is at most 253 characters).
|
|
37
|
+
*/
|
|
38
|
+
export const ScheduleGrantInput = z
|
|
39
|
+
.object({ toolKey: z.string().trim().min(1).max(270), connectorId: Id.optional() })
|
|
40
|
+
.strict();
|
|
41
|
+
const Name = z.string().trim().min(1).max(SCHEDULE_NAME_MAX);
|
|
42
|
+
const Prompt = z.string().trim().min(1).max(SCHEDULE_PROMPT_MAX);
|
|
43
|
+
const Mode = z.enum(["new", "conversation", "chat"]);
|
|
44
|
+
export const ScheduleCreateBody = z
|
|
45
|
+
.object({
|
|
46
|
+
agentId: Id,
|
|
47
|
+
name: Name,
|
|
48
|
+
prompt: Prompt,
|
|
49
|
+
trigger: ScheduleTriggerInput,
|
|
50
|
+
/** The browser's zone: used only when the account has no zone of its own. */
|
|
51
|
+
timeZone: IanaTimeZone.optional(),
|
|
52
|
+
mode: Mode,
|
|
53
|
+
conversationId: Id.optional(),
|
|
54
|
+
chat: ScheduleChatInput.optional(),
|
|
55
|
+
/** `new` mode only, as `effort` and `deviceId` (a conversation or chat task uses its own). */
|
|
56
|
+
model: ScheduleModel.optional(),
|
|
57
|
+
effort: ScheduleEffort.optional(),
|
|
58
|
+
deviceId: Id.optional(),
|
|
59
|
+
expiresAt: ExpiresAt.nullable().optional(),
|
|
60
|
+
grants: z.array(ScheduleGrantInput).max(50).optional(),
|
|
61
|
+
})
|
|
62
|
+
.strict();
|
|
63
|
+
export const ScheduleUpdateBody = z
|
|
64
|
+
.object({
|
|
65
|
+
agentId: Id.optional(),
|
|
66
|
+
name: Name.optional(),
|
|
67
|
+
prompt: Prompt.optional(),
|
|
68
|
+
trigger: ScheduleTriggerInput.optional(),
|
|
69
|
+
/** The task's own zone (an explicit change). */
|
|
70
|
+
timeZone: IanaTimeZone.optional(),
|
|
71
|
+
mode: Mode.optional(),
|
|
72
|
+
conversationId: Id.nullable().optional(),
|
|
73
|
+
chat: ScheduleChatInput.nullable().optional(),
|
|
74
|
+
/** `new` mode only; switching to another mode clears them. */
|
|
75
|
+
model: ScheduleModel.nullable().optional(),
|
|
76
|
+
effort: ScheduleEffort.nullable().optional(),
|
|
77
|
+
deviceId: Id.nullable().optional(),
|
|
78
|
+
/** Null: the org's default expiry for a cron task (as on create), else never. */
|
|
79
|
+
expiresAt: ExpiresAt.nullable().optional(),
|
|
80
|
+
})
|
|
81
|
+
.strict();
|
|
82
|
+
export const ScheduleListQuery = z
|
|
83
|
+
.object({
|
|
84
|
+
all: z.enum(["true", "false"]).optional(),
|
|
85
|
+
/** Only the tasks that post into this conversation (the conversation's side panel). */
|
|
86
|
+
conversationId: Id.optional(),
|
|
87
|
+
})
|
|
88
|
+
.strict();
|
|
89
|
+
export const ScheduleChatTargetsQuery = z.object({}).strict();
|
|
90
|
+
export const ScheduleGrantableQuery = z.object({ agentId: Id }).strict();
|
|
91
|
+
export const ScheduleParams = z.object({ id: Id });
|
|
92
|
+
export const ScheduleRunBody = z.object({ trial: z.boolean().optional() }).strict();
|
|
93
|
+
export const ScheduleRunsQuery = z
|
|
94
|
+
.object({ limit: z.coerce.number().int().min(1).max(200).optional() })
|
|
95
|
+
.strict();
|
|
96
|
+
export const ScheduleGrantsBody = z
|
|
97
|
+
.object({ grants: z.array(ScheduleGrantInput).min(1).max(50) })
|
|
98
|
+
.strict();
|
|
99
|
+
export const ScheduleGrantParams = z.object({ id: Id, toolKey: z.string().min(1).max(270) });
|
|
100
|
+
export class ScheduleCreateBodyDto extends createZodDto(ScheduleCreateBody, "ScheduleCreateBody") {
|
|
101
|
+
}
|
|
102
|
+
export class ScheduleUpdateBodyDto extends createZodDto(ScheduleUpdateBody, "ScheduleUpdateBody") {
|
|
103
|
+
}
|
|
104
|
+
export class ScheduleListQueryDto extends createZodDto(ScheduleListQuery, "ScheduleListQuery") {
|
|
105
|
+
}
|
|
106
|
+
export class ScheduleChatTargetsQueryDto extends createZodDto(ScheduleChatTargetsQuery, "ScheduleChatTargetsQuery") {
|
|
107
|
+
}
|
|
108
|
+
export class ScheduleGrantableQueryDto extends createZodDto(ScheduleGrantableQuery, "ScheduleGrantableQuery") {
|
|
109
|
+
}
|
|
110
|
+
export class ScheduleParamsDto extends createZodDto(ScheduleParams, "ScheduleParams") {
|
|
111
|
+
}
|
|
112
|
+
export class ScheduleRunBodyDto extends createZodDto(ScheduleRunBody, "ScheduleRunBody") {
|
|
113
|
+
}
|
|
114
|
+
export class ScheduleRunsQueryDto extends createZodDto(ScheduleRunsQuery, "ScheduleRunsQuery") {
|
|
115
|
+
}
|
|
116
|
+
export class ScheduleGrantsBodyDto extends createZodDto(ScheduleGrantsBody, "ScheduleGrantsBody") {
|
|
117
|
+
}
|
|
118
|
+
export class ScheduleGrantParamsDto extends createZodDto(ScheduleGrantParams, "ScheduleGrantParams") {
|
|
119
|
+
}
|
|
120
|
+
/** The schedule routes the Platform operations mirror (`check:platform-ops` keys). */
|
|
121
|
+
export const SCHEDULE_ROUTES = [
|
|
122
|
+
{ route: "GET /api/v1/orgs/:orgId/schedules", query: ScheduleListQuery },
|
|
123
|
+
{ route: "GET /api/v1/orgs/:orgId/schedules/chat-targets", query: ScheduleChatTargetsQuery },
|
|
124
|
+
{ route: "GET /api/v1/orgs/:orgId/schedules/grantable-tools", query: ScheduleGrantableQuery },
|
|
125
|
+
{ route: "POST /api/v1/orgs/:orgId/schedules", body: ScheduleCreateBody },
|
|
126
|
+
{ route: "GET /api/v1/orgs/:orgId/schedules/:id", params: ScheduleParams },
|
|
127
|
+
{
|
|
128
|
+
route: "PATCH /api/v1/orgs/:orgId/schedules/:id",
|
|
129
|
+
params: ScheduleParams,
|
|
130
|
+
body: ScheduleUpdateBody,
|
|
131
|
+
},
|
|
132
|
+
{ route: "DELETE /api/v1/orgs/:orgId/schedules/:id", params: ScheduleParams },
|
|
133
|
+
{ route: "POST /api/v1/orgs/:orgId/schedules/:id/pause", params: ScheduleParams },
|
|
134
|
+
{ route: "POST /api/v1/orgs/:orgId/schedules/:id/resume", params: ScheduleParams },
|
|
135
|
+
{
|
|
136
|
+
route: "POST /api/v1/orgs/:orgId/schedules/:id/run",
|
|
137
|
+
params: ScheduleParams,
|
|
138
|
+
body: ScheduleRunBody,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
route: "GET /api/v1/orgs/:orgId/schedules/:id/runs",
|
|
142
|
+
params: ScheduleParams,
|
|
143
|
+
query: ScheduleRunsQuery,
|
|
144
|
+
},
|
|
145
|
+
{ route: "GET /api/v1/orgs/:orgId/schedules/:id/grants", params: ScheduleParams },
|
|
146
|
+
{
|
|
147
|
+
route: "POST /api/v1/orgs/:orgId/schedules/:id/grants",
|
|
148
|
+
params: ScheduleParams,
|
|
149
|
+
body: ScheduleGrantsBody,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
route: "DELETE /api/v1/orgs/:orgId/schedules/:id/grants/:toolKey",
|
|
153
|
+
params: ScheduleGrantParams,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
/** The object without its undefined properties (the service's inputs take absent, not undefined). */
|
|
157
|
+
export function defined(o) {
|
|
158
|
+
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
|
|
159
|
+
}
|
|
160
|
+
/** A grant list as the service's input. */
|
|
161
|
+
export const grantsOf = (grants) => grants.map((g) => defined(g));
|
|
162
|
+
/**
|
|
163
|
+
* A create body as the service's input. `timeZone` is the browser zone and is not part of it: the
|
|
164
|
+
* service uses it only when the account has no zone (spec §5), so it is returned separately.
|
|
165
|
+
*/
|
|
166
|
+
export function createInputOf(body) {
|
|
167
|
+
const { timeZone, expiresAt, grants, ...rest } = body;
|
|
168
|
+
return {
|
|
169
|
+
input: {
|
|
170
|
+
...defined(rest),
|
|
171
|
+
...(expiresAt !== undefined && {
|
|
172
|
+
expiresAt: expiresAt === null ? null : new Date(expiresAt),
|
|
173
|
+
}),
|
|
174
|
+
...(grants !== undefined && { grants: grantsOf(grants) }),
|
|
175
|
+
},
|
|
176
|
+
browserTimeZone: timeZone,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** A patch body as the service's input (an explicit `timeZone` changes the task's zone). */
|
|
180
|
+
export function updateInputOf(body) {
|
|
181
|
+
const { expiresAt, ...rest } = body;
|
|
182
|
+
return {
|
|
183
|
+
...defined(rest),
|
|
184
|
+
...(expiresAt !== undefined && { expiresAt: expiresAt === null ? null : new Date(expiresAt) }),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
import type { ScheduledTask, ScheduledTaskGrant, TaskRun, TaskRunStatus } from "./types.js";
|
|
3
|
+
/** What a caller supplies to create a task; the counters, pause fields and timestamps default. */
|
|
4
|
+
export type ScheduledTaskInsert = Omit<ScheduledTask, "pauseReason" | "pausedBy" | "consecutiveFailures" | "createdAt" | "updatedAt">;
|
|
5
|
+
/** The fields a task update may change (`updated_at` is always refreshed). */
|
|
6
|
+
export type ScheduledTaskPatch = Partial<Omit<ScheduledTask, "id" | "orgId" | "accountId" | "createdAt" | "updatedAt">>;
|
|
7
|
+
/** What a caller supplies to create a task run; it starts `pending`. */
|
|
8
|
+
export interface TaskRunInsert {
|
|
9
|
+
id: string;
|
|
10
|
+
taskId: string;
|
|
11
|
+
orgId: string;
|
|
12
|
+
scheduledFor: Date;
|
|
13
|
+
trial: boolean;
|
|
14
|
+
/** A person's "run now" (default false: a tick of the schedule). */
|
|
15
|
+
manual?: boolean;
|
|
16
|
+
status?: TaskRunStatus;
|
|
17
|
+
skipReason?: TaskRun["skipReason"];
|
|
18
|
+
firedAt?: Date | null;
|
|
19
|
+
conversationId?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export type TaskRunPatch = Partial<Omit<TaskRun, "id" | "taskId" | "orgId" | "trial" | "manual">>;
|
|
22
|
+
/**
|
|
23
|
+
* Scheduled tasks, their runs and grants (spec §4): reads and writes rows only. Every method takes
|
|
24
|
+
* the database handle first so the caller decides the transaction (the scanner's `lockDue` and
|
|
25
|
+
* `insertRun` run in one, under the rows' locks).
|
|
26
|
+
*/
|
|
27
|
+
export declare class ScheduledTaskStore {
|
|
28
|
+
insertTask(t: KernelSchemaDb, task: ScheduledTaskInsert): Promise<ScheduledTask>;
|
|
29
|
+
/** A live (not deleted) task of the org; null when missing, deleted or in another org. */
|
|
30
|
+
getTask(t: KernelSchemaDb, orgId: string, id: string): Promise<ScheduledTask | null>;
|
|
31
|
+
/**
|
|
32
|
+
* {@link getTask} under `FOR UPDATE` (call it inside a transaction): a person's write holds the
|
|
33
|
+
* row, so the scanner's `lockDue` skips it until the write commits.
|
|
34
|
+
*/
|
|
35
|
+
lockTask(t: KernelSchemaDb, orgId: string, id: string): Promise<ScheduledTask | null>;
|
|
36
|
+
/** Patches a live task; null when it is missing or deleted. */
|
|
37
|
+
updateTask(t: KernelSchemaDb, id: string, patch: ScheduledTaskPatch): Promise<ScheduledTask | null>;
|
|
38
|
+
/** Deletes a task softly: hidden from every read and never due again. */
|
|
39
|
+
softDelete(t: KernelSchemaDb, id: string): Promise<boolean>;
|
|
40
|
+
/** A creator's live tasks, newest first. */
|
|
41
|
+
listForAccount(t: KernelSchemaDb, orgId: string, accountId: string): Promise<ScheduledTask[]>;
|
|
42
|
+
/** Every live task of the org, newest first. */
|
|
43
|
+
listForOrg(t: KernelSchemaDb, orgId: string): Promise<ScheduledTask[]>;
|
|
44
|
+
/** Live tasks that count against the caps (`active` and `paused`), of the org or one creator. */
|
|
45
|
+
countActive(t: KernelSchemaDb, orgId: string, accountId?: string): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Locks up to `limit` due tasks (active, live, `next_run_at <= now`), oldest first, skipping
|
|
48
|
+
* rows another transaction holds (`FOR UPDATE SKIP LOCKED`). Call it inside a transaction: the
|
|
49
|
+
* locks last until it ends.
|
|
50
|
+
*/
|
|
51
|
+
lockDue(t: KernelSchemaDb, now: Date, limit: number): Promise<ScheduledTask[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Inserts a task run; null when a non-trial run for the same tick already exists (the
|
|
54
|
+
* exactly-once guard, `UNIQUE (task_id, scheduled_for) WHERE NOT trial`).
|
|
55
|
+
*/
|
|
56
|
+
insertRun(t: KernelSchemaDb, run: TaskRunInsert): Promise<TaskRun | null>;
|
|
57
|
+
/** Patches a task run; null when it does not exist. */
|
|
58
|
+
updateRun(t: KernelSchemaDb, id: string, patch: TaskRunPatch): Promise<TaskRun | null>;
|
|
59
|
+
/**
|
|
60
|
+
* The task's latest run still `pending` or `running` (the overlap check), other than `exceptId`
|
|
61
|
+
* (the run being fired); null when none.
|
|
62
|
+
*/
|
|
63
|
+
latestNonTerminalRun(t: KernelSchemaDb, taskId: string, exceptId?: string): Promise<TaskRun | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Runs of the org fired at or after `since` (the `maxRunsPerHour` count; trial runs included,
|
|
66
|
+
* skipped runs not: a run whose queued message a person removed was never run).
|
|
67
|
+
*/
|
|
68
|
+
countFiredSince(t: KernelSchemaDb, orgId: string, since: Date): Promise<number>;
|
|
69
|
+
/** A task's runs, latest tick first. */
|
|
70
|
+
listRuns(t: KernelSchemaDb, taskId: string, limit: number): Promise<TaskRun[]>;
|
|
71
|
+
listGrants(t: KernelSchemaDb, taskId: string): Promise<ScheduledTaskGrant[]>;
|
|
72
|
+
/** Adds a grant, replacing the task's grant of the same tool key. */
|
|
73
|
+
addGrant(t: KernelSchemaDb, taskId: string, grant: ScheduledTaskGrant): Promise<void>;
|
|
74
|
+
removeGrant(t: KernelSchemaDb, taskId: string, toolKey: string): Promise<boolean>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Whether the task holds a grant for this tool as defined now: same key, same spec hash, same
|
|
78
|
+
* connector (null for plugin and builtin tools). A grant of an older definition does not count.
|
|
79
|
+
* A plain function too, for the tool policy (`createDecidePolicy`), which is not a provider.
|
|
80
|
+
*/
|
|
81
|
+
export declare function findTaskGrant(t: KernelSchemaDb, taskId: string, toolKey: string, specHash: string, connectorId: string | null): Promise<boolean>;
|