@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.106
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/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 +3 -3
- package/dist/channels/outbound.d.ts +5 -5
- package/dist/channels/outbound.js +17 -17
- package/dist/channels/threads.d.ts +1 -1
- package/dist/channels/threads.js +1 -1
- package/dist/config/schema.d.ts +5 -1
- package/dist/config/schema.js +44 -6
- package/dist/conversations/approval-profile.d.ts +2 -2
- package/dist/conversations/approval-profile.js +3 -3
- package/dist/conversations/conversations.controller.d.ts +7 -1
- package/dist/conversations/conversations.controller.js +26 -10
- package/dist/conversations/conversations.service.d.ts +101 -25
- package/dist/conversations/conversations.service.js +132 -32
- package/dist/conversations/events.d.ts +46 -0
- package/dist/conversations/events.js +54 -3
- 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 +2 -1
- 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 +20 -14
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +59 -2
- package/dist/db/kernel-schema.d.ts +104 -25
- 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 +34 -13
- package/dist/errors.js +34 -13
- package/dist/evals/reconstruct.d.ts +10 -1
- package/dist/evals/reconstruct.js +7 -0
- package/dist/extensions/host.d.ts +6 -1
- package/dist/extensions/host.js +10 -0
- 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/git/gateway.js +2 -2
- package/dist/http/api.module.js +5 -5
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- 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 +29 -2
- package/dist/infra/outbox/registry.js +30 -7
- package/dist/kernel.module.js +3 -0
- 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 +27 -11
- package/dist/orgs/settings.service.js +42 -24
- package/dist/platform/operation.js +2 -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/inbox.ops.js +4 -4
- package/dist/platform/ops/orgs.ops.js +1 -1
- package/dist/platform/ops/platform.ops.js +4 -4
- package/dist/platform/platform-ops.module.d.ts +2 -2
- package/dist/platform/platform-ops.module.js +5 -5
- package/dist/platform/route-schemas.js +3 -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 +3 -3
- package/dist/runtime/context/build.d.ts +6 -0
- package/dist/runtime/context/build.js +14 -3
- package/dist/runtime/context/compaction.js +15 -5
- package/dist/runtime/context/run-context.d.ts +38 -0
- package/dist/runtime/context/run-context.js +54 -0
- package/dist/runtime/maintenance.d.ts +8 -4
- package/dist/runtime/maintenance.js +37 -16
- 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-worker.js +7 -1
- package/dist/runtime/runtime.module.js +3 -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/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/{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 +8 -8
- package/dist/tools/builtins/builtin-tools.js +16 -16
- 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 +9 -9
- package/package.json +3 -3
- package/src/migrations/0188_automations_rename.sql +309 -0
- package/src/migrations/0189_event_automations.sql +136 -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
|
@@ -1,22 +1,47 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
-
import type { CreateTaskInput, GrantInput, UpdateTaskInput } from "./
|
|
3
|
+
import type { CreateTaskInput, GrantInput, UpdateTaskInput } from "./automations.service.js";
|
|
4
4
|
/** Longest task name and prompt, in characters (the same bounds as the service). */
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const AUTOMATION_NAME_MAX = 200;
|
|
6
|
+
export declare const AUTOMATION_PROMPT_MAX = 20000;
|
|
7
|
+
/** One clause of an event trigger's filter: a filterable fact, an operator and a value. */
|
|
8
|
+
export declare const AutomationFilterClause: z.ZodObject<{
|
|
9
|
+
fact: z.ZodString;
|
|
10
|
+
op: z.ZodEnum<{
|
|
11
|
+
contains: "contains";
|
|
12
|
+
eq: "eq";
|
|
13
|
+
in: "in";
|
|
14
|
+
}>;
|
|
15
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
16
|
+
}, z.core.$strict>;
|
|
7
17
|
/**
|
|
8
|
-
* When
|
|
9
|
-
* (`2026-12-01T09:00`, no offset) for a one-off run.
|
|
18
|
+
* When an automation fires, before the zone is fixed: a 5-field cron, or a local date-time
|
|
19
|
+
* (`2026-12-01T09:00`, no offset) for a one-off run; or events (collaboration spec §4.1): the
|
|
20
|
+
* `types` the extension `source` declares, kept when every clause of `filter` matches the event's
|
|
21
|
+
* facts (a missing filter keeps every event of the types).
|
|
10
22
|
*/
|
|
11
|
-
export declare const
|
|
23
|
+
export declare const AutomationTriggerInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
24
|
kind: z.ZodLiteral<"cron">;
|
|
13
25
|
expr: z.ZodString;
|
|
14
26
|
}, z.core.$strict>, z.ZodObject<{
|
|
15
27
|
kind: z.ZodLiteral<"once">;
|
|
16
28
|
at: z.ZodString;
|
|
29
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
30
|
+
kind: z.ZodLiteral<"event">;
|
|
31
|
+
source: z.ZodString;
|
|
32
|
+
types: z.ZodArray<z.ZodString>;
|
|
33
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
|
+
fact: z.ZodString;
|
|
35
|
+
op: z.ZodEnum<{
|
|
36
|
+
contains: "contains";
|
|
37
|
+
eq: "eq";
|
|
38
|
+
in: "in";
|
|
39
|
+
}>;
|
|
40
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
41
|
+
}, z.core.$strict>>>;
|
|
17
42
|
}, z.core.$strict>], "kind">;
|
|
18
43
|
/** The IM chat a `chat`-mode task posts into. */
|
|
19
|
-
export declare const
|
|
44
|
+
export declare const AutomationChatInput: z.ZodObject<{
|
|
20
45
|
connectionId: z.ZodString;
|
|
21
46
|
chatId: z.ZodString;
|
|
22
47
|
chatType: z.ZodEnum<{
|
|
@@ -26,13 +51,13 @@ export declare const ScheduleChatInput: z.ZodObject<{
|
|
|
26
51
|
}, z.core.$strict>;
|
|
27
52
|
/**
|
|
28
53
|
* 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`
|
|
54
|
+
* the fields (so the JSON schema shows the bounds). `new` and `subject` modes.
|
|
30
55
|
*/
|
|
31
|
-
export declare const
|
|
56
|
+
export declare const AutomationModel: z.ZodObject<{
|
|
32
57
|
provider: z.ZodString;
|
|
33
58
|
model: z.ZodString;
|
|
34
59
|
}, z.core.$strict>;
|
|
35
|
-
export declare const
|
|
60
|
+
export declare const AutomationEffort: z.ZodEnum<{
|
|
36
61
|
high: "high";
|
|
37
62
|
low: "low";
|
|
38
63
|
max: "max";
|
|
@@ -43,11 +68,11 @@ export declare const ScheduleEffort: z.ZodEnum<{
|
|
|
43
68
|
* A tool the creator pre-approves for the task, or a domain as `network:<host>` (network
|
|
44
69
|
* ask-to-allow spec §8.1: one exact host; a host name is at most 253 characters).
|
|
45
70
|
*/
|
|
46
|
-
export declare const
|
|
71
|
+
export declare const AutomationGrantInput: z.ZodObject<{
|
|
47
72
|
toolKey: z.ZodString;
|
|
48
73
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
49
74
|
}, z.core.$strict>;
|
|
50
|
-
export declare const
|
|
75
|
+
export declare const AutomationCreateBody: z.ZodObject<{
|
|
51
76
|
agentId: z.ZodString;
|
|
52
77
|
name: z.ZodString;
|
|
53
78
|
prompt: z.ZodString;
|
|
@@ -57,12 +82,26 @@ export declare const ScheduleCreateBody: z.ZodObject<{
|
|
|
57
82
|
}, z.core.$strict>, z.ZodObject<{
|
|
58
83
|
kind: z.ZodLiteral<"once">;
|
|
59
84
|
at: z.ZodString;
|
|
85
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
86
|
+
kind: z.ZodLiteral<"event">;
|
|
87
|
+
source: z.ZodString;
|
|
88
|
+
types: z.ZodArray<z.ZodString>;
|
|
89
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
+
fact: z.ZodString;
|
|
91
|
+
op: z.ZodEnum<{
|
|
92
|
+
contains: "contains";
|
|
93
|
+
eq: "eq";
|
|
94
|
+
in: "in";
|
|
95
|
+
}>;
|
|
96
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
97
|
+
}, z.core.$strict>>>;
|
|
60
98
|
}, z.core.$strict>], "kind">;
|
|
61
99
|
timeZone: z.ZodOptional<z.ZodString>;
|
|
62
100
|
mode: z.ZodEnum<{
|
|
63
101
|
chat: "chat";
|
|
64
102
|
conversation: "conversation";
|
|
65
103
|
new: "new";
|
|
104
|
+
subject: "subject";
|
|
66
105
|
}>;
|
|
67
106
|
conversationId: z.ZodOptional<z.ZodString>;
|
|
68
107
|
chat: z.ZodOptional<z.ZodObject<{
|
|
@@ -90,8 +129,12 @@ export declare const ScheduleCreateBody: z.ZodObject<{
|
|
|
90
129
|
toolKey: z.ZodString;
|
|
91
130
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
92
131
|
}, z.core.$strict>>>;
|
|
132
|
+
unattendedAsk: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
133
|
+
fail: "fail";
|
|
134
|
+
wait: "wait";
|
|
135
|
+
}>>>;
|
|
93
136
|
}, z.core.$strict>;
|
|
94
|
-
export declare const
|
|
137
|
+
export declare const AutomationUpdateBody: z.ZodObject<{
|
|
95
138
|
agentId: z.ZodOptional<z.ZodString>;
|
|
96
139
|
name: z.ZodOptional<z.ZodString>;
|
|
97
140
|
prompt: z.ZodOptional<z.ZodString>;
|
|
@@ -101,12 +144,26 @@ export declare const ScheduleUpdateBody: z.ZodObject<{
|
|
|
101
144
|
}, z.core.$strict>, z.ZodObject<{
|
|
102
145
|
kind: z.ZodLiteral<"once">;
|
|
103
146
|
at: z.ZodString;
|
|
147
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
148
|
+
kind: z.ZodLiteral<"event">;
|
|
149
|
+
source: z.ZodString;
|
|
150
|
+
types: z.ZodArray<z.ZodString>;
|
|
151
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
152
|
+
fact: z.ZodString;
|
|
153
|
+
op: z.ZodEnum<{
|
|
154
|
+
contains: "contains";
|
|
155
|
+
eq: "eq";
|
|
156
|
+
in: "in";
|
|
157
|
+
}>;
|
|
158
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
159
|
+
}, z.core.$strict>>>;
|
|
104
160
|
}, z.core.$strict>], "kind">>;
|
|
105
161
|
timeZone: z.ZodOptional<z.ZodString>;
|
|
106
162
|
mode: z.ZodOptional<z.ZodEnum<{
|
|
107
163
|
chat: "chat";
|
|
108
164
|
conversation: "conversation";
|
|
109
165
|
new: "new";
|
|
166
|
+
subject: "subject";
|
|
110
167
|
}>>;
|
|
111
168
|
conversationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
169
|
chat: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
@@ -130,8 +187,12 @@ export declare const ScheduleUpdateBody: z.ZodObject<{
|
|
|
130
187
|
}>>>;
|
|
131
188
|
deviceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
132
189
|
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
190
|
+
unattendedAsk: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
191
|
+
fail: "fail";
|
|
192
|
+
wait: "wait";
|
|
193
|
+
}>>>;
|
|
133
194
|
}, z.core.$strict>;
|
|
134
|
-
export declare const
|
|
195
|
+
export declare const AutomationListQuery: z.ZodObject<{
|
|
135
196
|
all: z.ZodOptional<z.ZodEnum<{
|
|
136
197
|
false: "false";
|
|
137
198
|
true: "true";
|
|
@@ -143,7 +204,7 @@ export declare const ScheduleListQuery: z.ZodObject<{
|
|
|
143
204
|
* the viewer's zone (local days for the collapse and the cut), `all` (org admins) and `taskId`
|
|
144
205
|
* (one task, never collapsed).
|
|
145
206
|
*/
|
|
146
|
-
export declare const
|
|
207
|
+
export declare const AutomationCalendarQuery: z.ZodObject<{
|
|
147
208
|
from: z.ZodString;
|
|
148
209
|
to: z.ZodString;
|
|
149
210
|
timeZone: z.ZodString;
|
|
@@ -153,30 +214,31 @@ export declare const ScheduleCalendarQuery: z.ZodObject<{
|
|
|
153
214
|
}>>;
|
|
154
215
|
taskId: z.ZodOptional<z.ZodString>;
|
|
155
216
|
}, z.core.$strict>;
|
|
156
|
-
export declare const
|
|
157
|
-
export declare const
|
|
217
|
+
export declare const AutomationChatTargetsQuery: z.ZodObject<{}, z.core.$strict>;
|
|
218
|
+
export declare const AutomationEventSourcesQuery: z.ZodObject<{}, z.core.$strict>;
|
|
219
|
+
export declare const AutomationGrantableQuery: z.ZodObject<{
|
|
158
220
|
agentId: z.ZodString;
|
|
159
221
|
}, z.core.$strict>;
|
|
160
|
-
export declare const
|
|
222
|
+
export declare const AutomationParams: z.ZodObject<{
|
|
161
223
|
id: z.ZodString;
|
|
162
224
|
}, z.core.$strip>;
|
|
163
|
-
export declare const
|
|
225
|
+
export declare const AutomationRunBody: z.ZodObject<{
|
|
164
226
|
trial: z.ZodOptional<z.ZodBoolean>;
|
|
165
227
|
}, z.core.$strict>;
|
|
166
|
-
export declare const
|
|
228
|
+
export declare const AutomationRunsQuery: z.ZodObject<{
|
|
167
229
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
168
230
|
}, z.core.$strict>;
|
|
169
|
-
export declare const
|
|
231
|
+
export declare const AutomationGrantsBody: z.ZodObject<{
|
|
170
232
|
grants: z.ZodArray<z.ZodObject<{
|
|
171
233
|
toolKey: z.ZodString;
|
|
172
234
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
173
235
|
}, z.core.$strict>>;
|
|
174
236
|
}, z.core.$strict>;
|
|
175
|
-
export declare const
|
|
237
|
+
export declare const AutomationGrantParams: z.ZodObject<{
|
|
176
238
|
id: z.ZodString;
|
|
177
239
|
toolKey: z.ZodString;
|
|
178
240
|
}, z.core.$strip>;
|
|
179
|
-
declare const
|
|
241
|
+
declare const AutomationCreateBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
180
242
|
agentId: z.ZodString;
|
|
181
243
|
name: z.ZodString;
|
|
182
244
|
prompt: z.ZodString;
|
|
@@ -186,12 +248,26 @@ declare const ScheduleCreateBodyDto_base: import("../infra/validation/create-zod
|
|
|
186
248
|
}, z.core.$strict>, z.ZodObject<{
|
|
187
249
|
kind: z.ZodLiteral<"once">;
|
|
188
250
|
at: z.ZodString;
|
|
251
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
252
|
+
kind: z.ZodLiteral<"event">;
|
|
253
|
+
source: z.ZodString;
|
|
254
|
+
types: z.ZodArray<z.ZodString>;
|
|
255
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
256
|
+
fact: z.ZodString;
|
|
257
|
+
op: z.ZodEnum<{
|
|
258
|
+
contains: "contains";
|
|
259
|
+
eq: "eq";
|
|
260
|
+
in: "in";
|
|
261
|
+
}>;
|
|
262
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
263
|
+
}, z.core.$strict>>>;
|
|
189
264
|
}, z.core.$strict>], "kind">;
|
|
190
265
|
timeZone: z.ZodOptional<z.ZodString>;
|
|
191
266
|
mode: z.ZodEnum<{
|
|
192
267
|
chat: "chat";
|
|
193
268
|
conversation: "conversation";
|
|
194
269
|
new: "new";
|
|
270
|
+
subject: "subject";
|
|
195
271
|
}>;
|
|
196
272
|
conversationId: z.ZodOptional<z.ZodString>;
|
|
197
273
|
chat: z.ZodOptional<z.ZodObject<{
|
|
@@ -219,10 +295,14 @@ declare const ScheduleCreateBodyDto_base: import("../infra/validation/create-zod
|
|
|
219
295
|
toolKey: z.ZodString;
|
|
220
296
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
221
297
|
}, z.core.$strict>>>;
|
|
298
|
+
unattendedAsk: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
299
|
+
fail: "fail";
|
|
300
|
+
wait: "wait";
|
|
301
|
+
}>>>;
|
|
222
302
|
}, z.core.$strict>>;
|
|
223
|
-
export declare class
|
|
303
|
+
export declare class AutomationCreateBodyDto extends AutomationCreateBodyDto_base {
|
|
224
304
|
}
|
|
225
|
-
declare const
|
|
305
|
+
declare const AutomationUpdateBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
226
306
|
agentId: z.ZodOptional<z.ZodString>;
|
|
227
307
|
name: z.ZodOptional<z.ZodString>;
|
|
228
308
|
prompt: z.ZodOptional<z.ZodString>;
|
|
@@ -232,12 +312,26 @@ declare const ScheduleUpdateBodyDto_base: import("../infra/validation/create-zod
|
|
|
232
312
|
}, z.core.$strict>, z.ZodObject<{
|
|
233
313
|
kind: z.ZodLiteral<"once">;
|
|
234
314
|
at: z.ZodString;
|
|
315
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
316
|
+
kind: z.ZodLiteral<"event">;
|
|
317
|
+
source: z.ZodString;
|
|
318
|
+
types: z.ZodArray<z.ZodString>;
|
|
319
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
320
|
+
fact: z.ZodString;
|
|
321
|
+
op: z.ZodEnum<{
|
|
322
|
+
contains: "contains";
|
|
323
|
+
eq: "eq";
|
|
324
|
+
in: "in";
|
|
325
|
+
}>;
|
|
326
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
327
|
+
}, z.core.$strict>>>;
|
|
235
328
|
}, z.core.$strict>], "kind">>;
|
|
236
329
|
timeZone: z.ZodOptional<z.ZodString>;
|
|
237
330
|
mode: z.ZodOptional<z.ZodEnum<{
|
|
238
331
|
chat: "chat";
|
|
239
332
|
conversation: "conversation";
|
|
240
333
|
new: "new";
|
|
334
|
+
subject: "subject";
|
|
241
335
|
}>>;
|
|
242
336
|
conversationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
243
337
|
chat: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
@@ -261,19 +355,23 @@ declare const ScheduleUpdateBodyDto_base: import("../infra/validation/create-zod
|
|
|
261
355
|
}>>>;
|
|
262
356
|
deviceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
263
357
|
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
358
|
+
unattendedAsk: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
359
|
+
fail: "fail";
|
|
360
|
+
wait: "wait";
|
|
361
|
+
}>>>;
|
|
264
362
|
}, z.core.$strict>>;
|
|
265
|
-
export declare class
|
|
363
|
+
export declare class AutomationUpdateBodyDto extends AutomationUpdateBodyDto_base {
|
|
266
364
|
}
|
|
267
|
-
declare const
|
|
365
|
+
declare const AutomationListQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
268
366
|
all: z.ZodOptional<z.ZodEnum<{
|
|
269
367
|
false: "false";
|
|
270
368
|
true: "true";
|
|
271
369
|
}>>;
|
|
272
370
|
conversationId: z.ZodOptional<z.ZodString>;
|
|
273
371
|
}, z.core.$strict>>;
|
|
274
|
-
export declare class
|
|
372
|
+
export declare class AutomationListQueryDto extends AutomationListQueryDto_base {
|
|
275
373
|
}
|
|
276
|
-
declare const
|
|
374
|
+
declare const AutomationCalendarQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
277
375
|
from: z.ZodString;
|
|
278
376
|
to: z.ZodString;
|
|
279
377
|
timeZone: z.ZodString;
|
|
@@ -283,65 +381,68 @@ declare const ScheduleCalendarQueryDto_base: import("../infra/validation/create-
|
|
|
283
381
|
}>>;
|
|
284
382
|
taskId: z.ZodOptional<z.ZodString>;
|
|
285
383
|
}, z.core.$strict>>;
|
|
286
|
-
export declare class
|
|
384
|
+
export declare class AutomationCalendarQueryDto extends AutomationCalendarQueryDto_base {
|
|
385
|
+
}
|
|
386
|
+
declare const AutomationChatTargetsQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{}, z.core.$strict>>;
|
|
387
|
+
export declare class AutomationChatTargetsQueryDto extends AutomationChatTargetsQueryDto_base {
|
|
287
388
|
}
|
|
288
|
-
declare const
|
|
289
|
-
export declare class
|
|
389
|
+
declare const AutomationEventSourcesQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{}, z.core.$strict>>;
|
|
390
|
+
export declare class AutomationEventSourcesQueryDto extends AutomationEventSourcesQueryDto_base {
|
|
290
391
|
}
|
|
291
|
-
declare const
|
|
392
|
+
declare const AutomationGrantableQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
292
393
|
agentId: z.ZodString;
|
|
293
394
|
}, z.core.$strict>>;
|
|
294
|
-
export declare class
|
|
395
|
+
export declare class AutomationGrantableQueryDto extends AutomationGrantableQueryDto_base {
|
|
295
396
|
}
|
|
296
|
-
declare const
|
|
397
|
+
declare const AutomationParamsDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
297
398
|
id: z.ZodString;
|
|
298
399
|
}, z.core.$strip>>;
|
|
299
|
-
export declare class
|
|
400
|
+
export declare class AutomationParamsDto extends AutomationParamsDto_base {
|
|
300
401
|
}
|
|
301
|
-
declare const
|
|
402
|
+
declare const AutomationRunBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
302
403
|
trial: z.ZodOptional<z.ZodBoolean>;
|
|
303
404
|
}, z.core.$strict>>;
|
|
304
|
-
export declare class
|
|
405
|
+
export declare class AutomationRunBodyDto extends AutomationRunBodyDto_base {
|
|
305
406
|
}
|
|
306
|
-
declare const
|
|
407
|
+
declare const AutomationRunsQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
307
408
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
308
409
|
}, z.core.$strict>>;
|
|
309
|
-
export declare class
|
|
410
|
+
export declare class AutomationRunsQueryDto extends AutomationRunsQueryDto_base {
|
|
310
411
|
}
|
|
311
|
-
declare const
|
|
412
|
+
declare const AutomationGrantsBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
312
413
|
grants: z.ZodArray<z.ZodObject<{
|
|
313
414
|
toolKey: z.ZodString;
|
|
314
415
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
315
416
|
}, z.core.$strict>>;
|
|
316
417
|
}, z.core.$strict>>;
|
|
317
|
-
export declare class
|
|
418
|
+
export declare class AutomationGrantsBodyDto extends AutomationGrantsBodyDto_base {
|
|
318
419
|
}
|
|
319
|
-
declare const
|
|
420
|
+
declare const AutomationGrantParamsDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
320
421
|
id: z.ZodString;
|
|
321
422
|
toolKey: z.ZodString;
|
|
322
423
|
}, z.core.$strip>>;
|
|
323
|
-
export declare class
|
|
424
|
+
export declare class AutomationGrantParamsDto extends AutomationGrantParamsDto_base {
|
|
324
425
|
}
|
|
325
|
-
/** The
|
|
326
|
-
export declare const
|
|
426
|
+
/** The automation routes the Platform operations mirror (`check:platform-ops` keys). */
|
|
427
|
+
export declare const AUTOMATION_ROUTES: readonly RouteSchemas[];
|
|
327
428
|
/** The object without its undefined properties (the service's inputs take absent, not undefined). */
|
|
328
429
|
export declare function defined<T extends object>(o: T): {
|
|
329
430
|
[K in keyof T]: Exclude<T[K], undefined>;
|
|
330
431
|
};
|
|
331
432
|
/** A grant list as the service's input. */
|
|
332
|
-
export declare const grantsOf: (grants: z.infer<typeof
|
|
433
|
+
export declare const grantsOf: (grants: z.infer<typeof AutomationGrantsBody>["grants"]) => GrantInput[];
|
|
333
434
|
/**
|
|
334
435
|
* A create body as the service's input. `timeZone` is the browser zone and is not part of it: the
|
|
335
436
|
* service uses it only when the account has no zone (spec §5), so it is returned separately.
|
|
336
437
|
*/
|
|
337
|
-
export declare function createInputOf(body: z.infer<typeof
|
|
438
|
+
export declare function createInputOf(body: z.infer<typeof AutomationCreateBody>): {
|
|
338
439
|
input: CreateTaskInput;
|
|
339
440
|
browserTimeZone: string | undefined;
|
|
340
441
|
};
|
|
341
442
|
/** A patch body as the service's input (an explicit `timeZone` changes the task's zone). */
|
|
342
|
-
export declare function updateInputOf(body: z.infer<typeof
|
|
443
|
+
export declare function updateInputOf(body: z.infer<typeof AutomationUpdateBody>): UpdateTaskInput;
|
|
343
444
|
/** A calendar query as the service's input. */
|
|
344
|
-
export declare const calendarInputOf: (q: z.infer<typeof
|
|
445
|
+
export declare const calendarInputOf: (q: z.infer<typeof AutomationCalendarQuery>) => {
|
|
345
446
|
from: Date;
|
|
346
447
|
to: Date;
|
|
347
448
|
timeZone: string;
|
|
@@ -0,0 +1,253 @@
|
|
|
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 AUTOMATION_NAME_MAX = 200;
|
|
6
|
+
export const AUTOMATION_PROMPT_MAX = 20_000;
|
|
7
|
+
const Id = z.string().min(1).max(100);
|
|
8
|
+
/** One clause of an event trigger's filter: a filterable fact, an operator and a value. */
|
|
9
|
+
export const AutomationFilterClause = z
|
|
10
|
+
.object({
|
|
11
|
+
fact: z.string().trim().min(1).max(100),
|
|
12
|
+
op: z.enum(["eq", "in", "contains"]),
|
|
13
|
+
value: z.union([
|
|
14
|
+
z.string().max(500),
|
|
15
|
+
z.number(),
|
|
16
|
+
z.boolean(),
|
|
17
|
+
z.array(z.string().max(500)).max(100),
|
|
18
|
+
]),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
/**
|
|
22
|
+
* When an automation fires, before the zone is fixed: a 5-field cron, or a local date-time
|
|
23
|
+
* (`2026-12-01T09:00`, no offset) for a one-off run; or events (collaboration spec §4.1): the
|
|
24
|
+
* `types` the extension `source` declares, kept when every clause of `filter` matches the event's
|
|
25
|
+
* facts (a missing filter keeps every event of the types).
|
|
26
|
+
*/
|
|
27
|
+
export const AutomationTriggerInput = z.discriminatedUnion("kind", [
|
|
28
|
+
z.object({ kind: z.literal("cron"), expr: z.string().trim().min(1).max(200) }).strict(),
|
|
29
|
+
z.object({ kind: z.literal("once"), at: z.string().trim().min(1).max(40) }).strict(),
|
|
30
|
+
z
|
|
31
|
+
.object({
|
|
32
|
+
kind: z.literal("event"),
|
|
33
|
+
source: z.string().trim().min(1).max(214),
|
|
34
|
+
types: z.array(z.string().trim().min(1).max(100)).min(1).max(64),
|
|
35
|
+
filter: z.array(AutomationFilterClause).max(20).optional(),
|
|
36
|
+
})
|
|
37
|
+
.strict(),
|
|
38
|
+
]);
|
|
39
|
+
/** The IM chat a `chat`-mode task posts into. */
|
|
40
|
+
export const AutomationChatInput = z
|
|
41
|
+
.object({
|
|
42
|
+
connectionId: Id,
|
|
43
|
+
chatId: z.string().min(1).max(500),
|
|
44
|
+
chatType: z.enum(["dm", "group"]),
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
47
|
+
/**
|
|
48
|
+
* A model pick: the same `{ provider, model }` an agent's definition uses, its strings bounded on
|
|
49
|
+
* the fields (so the JSON schema shows the bounds). `new` and `subject` modes.
|
|
50
|
+
*/
|
|
51
|
+
export const AutomationModel = z
|
|
52
|
+
.object({ provider: z.string().min(1).max(100), model: z.string().min(1).max(200) })
|
|
53
|
+
.strict();
|
|
54
|
+
export const AutomationEffort = z.enum(["low", "medium", "high", "xhigh", "max"]);
|
|
55
|
+
/** An end time as an ISO 8601 timestamp with an offset (`2026-12-31T00:00:00Z`). */
|
|
56
|
+
const ExpiresAt = z.string().datetime({ offset: true });
|
|
57
|
+
/**
|
|
58
|
+
* A tool the creator pre-approves for the task, or a domain as `network:<host>` (network
|
|
59
|
+
* ask-to-allow spec §8.1: one exact host; a host name is at most 253 characters).
|
|
60
|
+
*/
|
|
61
|
+
export const AutomationGrantInput = z
|
|
62
|
+
.object({ toolKey: z.string().trim().min(1).max(270), connectorId: Id.optional() })
|
|
63
|
+
.strict();
|
|
64
|
+
const Name = z.string().trim().min(1).max(AUTOMATION_NAME_MAX);
|
|
65
|
+
const Prompt = z.string().trim().min(1).max(AUTOMATION_PROMPT_MAX);
|
|
66
|
+
/**
|
|
67
|
+
* Where a run posts. `subject` (one conversation per event subject) needs an event trigger and
|
|
68
|
+
* takes a model and effort but no device (only `new` does); `chat` needs a time trigger.
|
|
69
|
+
*/
|
|
70
|
+
const Mode = z.enum(["new", "conversation", "chat", "subject"]);
|
|
71
|
+
/** What an unattended run does with a question: `null` follows the org's default. */
|
|
72
|
+
const UnattendedAsk = z.enum(["fail", "wait"]);
|
|
73
|
+
export const AutomationCreateBody = z
|
|
74
|
+
.object({
|
|
75
|
+
agentId: Id,
|
|
76
|
+
name: Name,
|
|
77
|
+
prompt: Prompt,
|
|
78
|
+
trigger: AutomationTriggerInput,
|
|
79
|
+
/** The browser's zone: used only when the account has no zone of its own. */
|
|
80
|
+
timeZone: IanaTimeZone.optional(),
|
|
81
|
+
mode: Mode,
|
|
82
|
+
conversationId: Id.optional(),
|
|
83
|
+
chat: AutomationChatInput.optional(),
|
|
84
|
+
/** `new` and `subject` modes, as `effort` (`deviceId`: `new` only); a conversation or chat task uses its own. */
|
|
85
|
+
model: AutomationModel.optional(),
|
|
86
|
+
effort: AutomationEffort.optional(),
|
|
87
|
+
deviceId: Id.optional(),
|
|
88
|
+
expiresAt: ExpiresAt.nullable().optional(),
|
|
89
|
+
grants: z.array(AutomationGrantInput).max(50).optional(),
|
|
90
|
+
/** What a question in an unattended run does; absent or null: the org's default. */
|
|
91
|
+
unattendedAsk: UnattendedAsk.nullable().optional(),
|
|
92
|
+
})
|
|
93
|
+
.strict();
|
|
94
|
+
export const AutomationUpdateBody = z
|
|
95
|
+
.object({
|
|
96
|
+
agentId: Id.optional(),
|
|
97
|
+
name: Name.optional(),
|
|
98
|
+
prompt: Prompt.optional(),
|
|
99
|
+
trigger: AutomationTriggerInput.optional(),
|
|
100
|
+
/** The task's own zone (an explicit change). */
|
|
101
|
+
timeZone: IanaTimeZone.optional(),
|
|
102
|
+
mode: Mode.optional(),
|
|
103
|
+
conversationId: Id.nullable().optional(),
|
|
104
|
+
chat: AutomationChatInput.nullable().optional(),
|
|
105
|
+
/** `new` and `subject` modes (`deviceId`: `new` only); switching to another mode clears them. */
|
|
106
|
+
model: AutomationModel.nullable().optional(),
|
|
107
|
+
effort: AutomationEffort.nullable().optional(),
|
|
108
|
+
deviceId: Id.nullable().optional(),
|
|
109
|
+
/** Null: the org's default expiry for a cron or event task (as on create), else never. */
|
|
110
|
+
expiresAt: ExpiresAt.nullable().optional(),
|
|
111
|
+
/** Null: the org's default. */
|
|
112
|
+
unattendedAsk: UnattendedAsk.nullable().optional(),
|
|
113
|
+
})
|
|
114
|
+
.strict();
|
|
115
|
+
export const AutomationListQuery = z
|
|
116
|
+
.object({
|
|
117
|
+
all: z.enum(["true", "false"]).optional(),
|
|
118
|
+
/** Only the tasks that post into this conversation (the conversation's side panel). */
|
|
119
|
+
conversationId: Id.optional(),
|
|
120
|
+
})
|
|
121
|
+
.strict();
|
|
122
|
+
/** An instant with an offset (`2026-11-09T00:00:00+08:00`). */
|
|
123
|
+
const Instant = z.string().datetime({ offset: true });
|
|
124
|
+
/**
|
|
125
|
+
* The calendar's range (`from < to`, at most 43 days, 2 with `taskId`: checked by the service),
|
|
126
|
+
* the viewer's zone (local days for the collapse and the cut), `all` (org admins) and `taskId`
|
|
127
|
+
* (one task, never collapsed).
|
|
128
|
+
*/
|
|
129
|
+
export const AutomationCalendarQuery = z
|
|
130
|
+
.object({
|
|
131
|
+
from: Instant,
|
|
132
|
+
to: Instant,
|
|
133
|
+
timeZone: IanaTimeZone,
|
|
134
|
+
all: z.enum(["true", "false"]).optional(),
|
|
135
|
+
taskId: Id.optional(),
|
|
136
|
+
})
|
|
137
|
+
.strict();
|
|
138
|
+
export const AutomationChatTargetsQuery = z.object({}).strict();
|
|
139
|
+
export const AutomationEventSourcesQuery = z.object({}).strict();
|
|
140
|
+
export const AutomationGrantableQuery = z.object({ agentId: Id }).strict();
|
|
141
|
+
export const AutomationParams = z.object({ id: Id });
|
|
142
|
+
export const AutomationRunBody = z.object({ trial: z.boolean().optional() }).strict();
|
|
143
|
+
export const AutomationRunsQuery = z
|
|
144
|
+
.object({ limit: z.coerce.number().int().min(1).max(200).optional() })
|
|
145
|
+
.strict();
|
|
146
|
+
export const AutomationGrantsBody = z
|
|
147
|
+
.object({ grants: z.array(AutomationGrantInput).min(1).max(50) })
|
|
148
|
+
.strict();
|
|
149
|
+
export const AutomationGrantParams = z.object({ id: Id, toolKey: z.string().min(1).max(270) });
|
|
150
|
+
export class AutomationCreateBodyDto extends createZodDto(AutomationCreateBody, "AutomationCreateBody") {
|
|
151
|
+
}
|
|
152
|
+
export class AutomationUpdateBodyDto extends createZodDto(AutomationUpdateBody, "AutomationUpdateBody") {
|
|
153
|
+
}
|
|
154
|
+
export class AutomationListQueryDto extends createZodDto(AutomationListQuery, "AutomationListQuery") {
|
|
155
|
+
}
|
|
156
|
+
export class AutomationCalendarQueryDto extends createZodDto(AutomationCalendarQuery, "AutomationCalendarQuery") {
|
|
157
|
+
}
|
|
158
|
+
export class AutomationChatTargetsQueryDto extends createZodDto(AutomationChatTargetsQuery, "AutomationChatTargetsQuery") {
|
|
159
|
+
}
|
|
160
|
+
export class AutomationEventSourcesQueryDto extends createZodDto(AutomationEventSourcesQuery, "AutomationEventSourcesQuery") {
|
|
161
|
+
}
|
|
162
|
+
export class AutomationGrantableQueryDto extends createZodDto(AutomationGrantableQuery, "AutomationGrantableQuery") {
|
|
163
|
+
}
|
|
164
|
+
export class AutomationParamsDto extends createZodDto(AutomationParams, "AutomationParams") {
|
|
165
|
+
}
|
|
166
|
+
export class AutomationRunBodyDto extends createZodDto(AutomationRunBody, "AutomationRunBody") {
|
|
167
|
+
}
|
|
168
|
+
export class AutomationRunsQueryDto extends createZodDto(AutomationRunsQuery, "AutomationRunsQuery") {
|
|
169
|
+
}
|
|
170
|
+
export class AutomationGrantsBodyDto extends createZodDto(AutomationGrantsBody, "AutomationGrantsBody") {
|
|
171
|
+
}
|
|
172
|
+
export class AutomationGrantParamsDto extends createZodDto(AutomationGrantParams, "AutomationGrantParams") {
|
|
173
|
+
}
|
|
174
|
+
/** The automation routes the Platform operations mirror (`check:platform-ops` keys). */
|
|
175
|
+
export const AUTOMATION_ROUTES = [
|
|
176
|
+
{ route: "GET /api/v1/orgs/:orgId/automations", query: AutomationListQuery },
|
|
177
|
+
{ route: "GET /api/v1/orgs/:orgId/automations/calendar", query: AutomationCalendarQuery },
|
|
178
|
+
{ route: "GET /api/v1/orgs/:orgId/automations/chat-targets", query: AutomationChatTargetsQuery },
|
|
179
|
+
{ route: "GET /api/v1/orgs/:orgId/automations/grantable-tools", query: AutomationGrantableQuery },
|
|
180
|
+
{
|
|
181
|
+
route: "GET /api/v1/orgs/:orgId/automations/event-sources",
|
|
182
|
+
query: AutomationEventSourcesQuery,
|
|
183
|
+
},
|
|
184
|
+
{ route: "POST /api/v1/orgs/:orgId/automations", body: AutomationCreateBody },
|
|
185
|
+
{ route: "GET /api/v1/orgs/:orgId/automations/:id", params: AutomationParams },
|
|
186
|
+
{
|
|
187
|
+
route: "PATCH /api/v1/orgs/:orgId/automations/:id",
|
|
188
|
+
params: AutomationParams,
|
|
189
|
+
body: AutomationUpdateBody,
|
|
190
|
+
},
|
|
191
|
+
{ route: "DELETE /api/v1/orgs/:orgId/automations/:id", params: AutomationParams },
|
|
192
|
+
{ route: "POST /api/v1/orgs/:orgId/automations/:id/pause", params: AutomationParams },
|
|
193
|
+
{ route: "POST /api/v1/orgs/:orgId/automations/:id/resume", params: AutomationParams },
|
|
194
|
+
{
|
|
195
|
+
route: "POST /api/v1/orgs/:orgId/automations/:id/run",
|
|
196
|
+
params: AutomationParams,
|
|
197
|
+
body: AutomationRunBody,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
route: "GET /api/v1/orgs/:orgId/automations/:id/runs",
|
|
201
|
+
params: AutomationParams,
|
|
202
|
+
query: AutomationRunsQuery,
|
|
203
|
+
},
|
|
204
|
+
{ route: "GET /api/v1/orgs/:orgId/automations/:id/grants", params: AutomationParams },
|
|
205
|
+
{
|
|
206
|
+
route: "POST /api/v1/orgs/:orgId/automations/:id/grants",
|
|
207
|
+
params: AutomationParams,
|
|
208
|
+
body: AutomationGrantsBody,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
route: "DELETE /api/v1/orgs/:orgId/automations/:id/grants/:toolKey",
|
|
212
|
+
params: AutomationGrantParams,
|
|
213
|
+
},
|
|
214
|
+
];
|
|
215
|
+
/** The object without its undefined properties (the service's inputs take absent, not undefined). */
|
|
216
|
+
export function defined(o) {
|
|
217
|
+
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
|
|
218
|
+
}
|
|
219
|
+
/** A grant list as the service's input. */
|
|
220
|
+
export const grantsOf = (grants) => grants.map((g) => defined(g));
|
|
221
|
+
/**
|
|
222
|
+
* A create body as the service's input. `timeZone` is the browser zone and is not part of it: the
|
|
223
|
+
* service uses it only when the account has no zone (spec §5), so it is returned separately.
|
|
224
|
+
*/
|
|
225
|
+
export function createInputOf(body) {
|
|
226
|
+
const { timeZone, expiresAt, grants, ...rest } = body;
|
|
227
|
+
return {
|
|
228
|
+
input: {
|
|
229
|
+
...defined(rest),
|
|
230
|
+
...(expiresAt !== undefined && {
|
|
231
|
+
expiresAt: expiresAt === null ? null : new Date(expiresAt),
|
|
232
|
+
}),
|
|
233
|
+
...(grants !== undefined && { grants: grantsOf(grants) }),
|
|
234
|
+
},
|
|
235
|
+
browserTimeZone: timeZone,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/** A patch body as the service's input (an explicit `timeZone` changes the task's zone). */
|
|
239
|
+
export function updateInputOf(body) {
|
|
240
|
+
const { expiresAt, ...rest } = body;
|
|
241
|
+
return {
|
|
242
|
+
...defined(rest),
|
|
243
|
+
...(expiresAt !== undefined && { expiresAt: expiresAt === null ? null : new Date(expiresAt) }),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/** A calendar query as the service's input. */
|
|
247
|
+
export const calendarInputOf = (q) => ({
|
|
248
|
+
from: new Date(q.from),
|
|
249
|
+
to: new Date(q.to),
|
|
250
|
+
timeZone: q.timeZone,
|
|
251
|
+
all: q.all === "true",
|
|
252
|
+
...(q.taskId !== undefined && { taskId: q.taskId }),
|
|
253
|
+
});
|