@capybara-hq/kernel 0.1.0-rc.104 → 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 +103 -25
- package/dist/conversations/conversations.service.js +138 -33
- package/dist/conversations/events.d.ts +48 -1
- package/dist/conversations/events.js +61 -9
- 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 +47 -13
- package/dist/errors.js +47 -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/handoff/app-schemes.d.ts +28 -0
- package/dist/handoff/app-schemes.js +41 -0
- package/dist/handoff/handoff-paths.d.ts +26 -0
- package/dist/handoff/handoff-paths.js +25 -0
- package/dist/handoff/handoff-tickets.d.ts +28 -0
- package/dist/handoff/handoff-tickets.js +111 -0
- package/dist/handoff/handoff.controller.d.ts +24 -0
- package/dist/handoff/handoff.controller.js +74 -0
- package/dist/handoff/handoff.module.d.ts +7 -0
- package/dist/handoff/handoff.module.js +26 -0
- package/dist/handoff/handoff.schemas.d.ts +13 -0
- package/dist/handoff/handoff.schemas.js +3 -0
- package/dist/handoff/handoff.service.d.ts +49 -0
- package/dist/handoff/handoff.service.js +96 -0
- package/dist/http/api.module.js +13 -5
- package/dist/http/meta.controller.d.ts +1 -0
- package/dist/http/meta.controller.js +7 -0
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- package/dist/identity/sso.controller.d.ts +30 -6
- package/dist/identity/sso.controller.js +51 -17
- package/dist/identity/sso.d.ts +10 -2
- package/dist/identity/sso.js +15 -3
- 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/overrides.d.ts +4 -4
- package/dist/overrides.js +1 -1
- package/dist/platform/exclusions.js +5 -0
- 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/connectors.ops.js +4 -2
- 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/compaction.service.d.ts +3 -1
- package/dist/runtime/compaction.service.js +3 -1
- package/dist/runtime/context/build.d.ts +6 -0
- package/dist/runtime/context/build.js +14 -3
- package/dist/runtime/context/compaction.d.ts +27 -1
- package/dist/runtime/context/compaction.js +102 -37
- 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/model-call.d.ts +6 -4
- package/dist/runtime/model-call.js +17 -7
- package/dist/runtime/project/knowledge.service.d.ts +16 -7
- package/dist/runtime/project/knowledge.service.js +31 -13
- 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/connectors.service.d.ts +4 -13
- package/dist/tools/connectors.service.js +12 -21
- 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/oauth/flow.d.ts +16 -2
- package/dist/tools/oauth/flow.js +23 -4
- package/dist/tools/oauth/oauth.controller.d.ts +19 -7
- package/dist/tools/oauth/oauth.controller.js +42 -12
- package/dist/tools/oauth/oauth.schemas.d.ts +14 -1
- package/dist/tools/oauth/oauth.schemas.js +4 -1
- 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
|
@@ -3,6 +3,9 @@ import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
|
3
3
|
export declare const AgentMemberIds: z.ZodArray<z.ZodString>;
|
|
4
4
|
/** Pending connectors come only from a template (ruling P4-6): a create request's are dropped. */
|
|
5
5
|
export declare const AgentCreateDefinition: z.ZodObject<{
|
|
6
|
+
tools: z.ZodOptional<z.ZodUndefined>;
|
|
7
|
+
subagentTools: z.ZodOptional<z.ZodUndefined>;
|
|
8
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
6
9
|
name: z.ZodString;
|
|
7
10
|
description: z.ZodOptional<z.ZodString>;
|
|
8
11
|
avatarUrl: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
|
|
@@ -97,12 +100,12 @@ export declare const AgentCreateDefinition: z.ZodObject<{
|
|
|
97
100
|
pr: z.ZodOptional<z.ZodString>;
|
|
98
101
|
sessionUrl: z.ZodOptional<z.ZodBoolean>;
|
|
99
102
|
}, z.core.$strict>>;
|
|
100
|
-
tools: z.ZodOptional<z.ZodUndefined>;
|
|
101
|
-
subagentTools: z.ZodOptional<z.ZodUndefined>;
|
|
102
|
-
instructions: z.ZodOptional<z.ZodString>;
|
|
103
103
|
}, z.core.$strip>;
|
|
104
104
|
export declare const AgentCreateBody: z.ZodObject<{
|
|
105
105
|
definition: z.ZodObject<{
|
|
106
|
+
tools: z.ZodOptional<z.ZodUndefined>;
|
|
107
|
+
subagentTools: z.ZodOptional<z.ZodUndefined>;
|
|
108
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
106
109
|
name: z.ZodString;
|
|
107
110
|
description: z.ZodOptional<z.ZodString>;
|
|
108
111
|
avatarUrl: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
|
|
@@ -197,9 +200,6 @@ export declare const AgentCreateBody: z.ZodObject<{
|
|
|
197
200
|
pr: z.ZodOptional<z.ZodString>;
|
|
198
201
|
sessionUrl: z.ZodOptional<z.ZodBoolean>;
|
|
199
202
|
}, z.core.$strict>>;
|
|
200
|
-
tools: z.ZodOptional<z.ZodUndefined>;
|
|
201
|
-
subagentTools: z.ZodOptional<z.ZodUndefined>;
|
|
202
|
-
instructions: z.ZodOptional<z.ZodString>;
|
|
203
203
|
}, z.core.$strip>;
|
|
204
204
|
visibility: z.ZodEnum<{
|
|
205
205
|
members: "members";
|
|
@@ -235,6 +235,9 @@ export declare const AgentCreateBody: z.ZodObject<{
|
|
|
235
235
|
}, z.core.$strict>;
|
|
236
236
|
export declare const AgentUpdateBody: z.ZodObject<{
|
|
237
237
|
definition: z.ZodOptional<z.ZodObject<{
|
|
238
|
+
tools: z.ZodOptional<z.ZodUndefined>;
|
|
239
|
+
subagentTools: z.ZodOptional<z.ZodUndefined>;
|
|
240
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
238
241
|
name: z.ZodString;
|
|
239
242
|
description: z.ZodOptional<z.ZodString>;
|
|
240
243
|
avatarUrl: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
|
|
@@ -351,9 +354,6 @@ export declare const AgentUpdateBody: z.ZodObject<{
|
|
|
351
354
|
pr: z.ZodOptional<z.ZodString>;
|
|
352
355
|
sessionUrl: z.ZodOptional<z.ZodBoolean>;
|
|
353
356
|
}, z.core.$strict>>;
|
|
354
|
-
tools: z.ZodOptional<z.ZodUndefined>;
|
|
355
|
-
subagentTools: z.ZodOptional<z.ZodUndefined>;
|
|
356
|
-
instructions: z.ZodOptional<z.ZodString>;
|
|
357
357
|
}, z.core.$strip>>;
|
|
358
358
|
visibility: z.ZodOptional<z.ZodEnum<{
|
|
359
359
|
members: "members";
|
package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts}
RENAMED
|
@@ -1,72 +1,77 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import { type Principal } from "../identity/principal.js";
|
|
3
3
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
|
+
import { type AutomationCalendarQuery, type AutomationChatTargetsQuery, type AutomationCreateBody, type AutomationEventSourcesQuery, type AutomationGrantableQuery, type AutomationGrantParams, type AutomationGrantsBody, type AutomationListQuery, type AutomationParams, type AutomationRunBody, type AutomationRunsQuery, type AutomationUpdateBody } from "./automations.schemas.js";
|
|
5
|
+
import { type AutomationGrantView, type AutomationListItem, AutomationsService, type ChatTarget, type EventSourceView, type GrantableTool } from "./automations.service.js";
|
|
4
6
|
import type { CalendarAnswer } from "./calendar.js";
|
|
5
|
-
import
|
|
6
|
-
import { type ScheduleCalendarQuery, type ScheduleChatTargetsQuery, type ScheduleCreateBody, type ScheduleGrantableQuery, type ScheduleGrantParams, type ScheduleGrantsBody, type ScheduleListQuery, type ScheduleParams, type ScheduleRunBody, type ScheduleRunsQuery, type ScheduleUpdateBody } from "./schedules.schemas.js";
|
|
7
|
-
import type { ScheduledTask, ScheduledTaskGrant, TaskRun } from "./types.js";
|
|
7
|
+
import type { Automation, AutomationGrant, TaskRun } from "./types.js";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Automations (`/api/v1/orgs/:orgId/automations`, spec 2026-11-11-scheduled-tasks §10); human
|
|
10
10
|
* users only (a service token gets 403).
|
|
11
11
|
* - `GET /` → `{ items }`: the caller's own tasks, each with its `lastRun`; `?all=true` every task
|
|
12
|
-
* of the org (org admins, `
|
|
12
|
+
* of the org (org admins, `automations.manage`, enforced by the service: 403 `forbidden`
|
|
13
13
|
* otherwise); `?conversationId=` only those posting into that conversation;
|
|
14
14
|
* - `GET /calendar?from&to&timeZone[&all][&taskId]` → the calendar (runs, planned occurrences,
|
|
15
15
|
* collapsed task-days; calendar spec §5.1), `org.read` like the list, `all` as the list's;
|
|
16
16
|
* - `GET /chat-targets` → `{ items }`: the chats the caller can point a `chat` task at;
|
|
17
17
|
* - `GET /grantable-tools?agentId=` → `{ items }`: the agent's tools, each grantable or why not;
|
|
18
|
+
* - `GET /event-sources` → `{ items }`: the trigger sources that serve the org (not switched off),
|
|
19
|
+
* each `{ source, name, events }` with the event types and facts an event trigger can use;
|
|
18
20
|
* - `POST /` → 201 `{ task }` (`timeZone` is the browser zone, a fallback only);
|
|
19
21
|
* `GET /:id`, `PATCH /:id`, `POST /:id/pause`, `POST /:id/resume` → `{ task }`;
|
|
20
22
|
* - `DELETE /:id` → 204; `POST /:id/run { trial? }` → 202 `{ run }`;
|
|
21
23
|
* - `GET /:id/runs?limit` → `{ items }`; `GET /:id/grants` → `{ items }` (each with `stale`);
|
|
22
24
|
* `POST /:id/grants { grants }` → `{ items }`; `DELETE /:id/grants/:toolKey` → 204.
|
|
23
25
|
*
|
|
24
|
-
* Roles: create, edit, resume, run and the grants need `
|
|
26
|
+
* Roles: create, edit, resume, run and the grants need `automations.use` (member and up; a guest
|
|
25
27
|
* gets 403). Pause and delete are `org.read` (any member, a guest included) so a creator demoted
|
|
26
28
|
* to guest can still stop and remove their own tasks; the service decides by the live role and
|
|
27
29
|
* ownership (the creator, or an org admin), and a task the caller may not see is 404
|
|
28
|
-
* `
|
|
30
|
+
* `automation.not_found`.
|
|
29
31
|
*/
|
|
30
|
-
export declare class
|
|
32
|
+
export declare class AutomationsController {
|
|
31
33
|
private readonly tasks;
|
|
32
|
-
constructor(tasks:
|
|
33
|
-
list(principal: Principal, org: OrgContext, q: z.infer<typeof
|
|
34
|
-
items:
|
|
34
|
+
constructor(tasks: AutomationsService);
|
|
35
|
+
list(principal: Principal, org: OrgContext, q: z.infer<typeof AutomationListQuery>): Promise<{
|
|
36
|
+
items: AutomationListItem[];
|
|
35
37
|
}>;
|
|
36
|
-
calendar(principal: Principal, org: OrgContext, q: z.infer<typeof
|
|
37
|
-
chatTargets(principal: Principal, org: OrgContext, _q: z.infer<typeof
|
|
38
|
+
calendar(principal: Principal, org: OrgContext, q: z.infer<typeof AutomationCalendarQuery>): Promise<CalendarAnswer>;
|
|
39
|
+
chatTargets(principal: Principal, org: OrgContext, _q: z.infer<typeof AutomationChatTargetsQuery>): Promise<{
|
|
38
40
|
items: ChatTarget[];
|
|
39
41
|
}>;
|
|
40
|
-
grantableTools(principal: Principal, org: OrgContext, q: z.infer<typeof
|
|
42
|
+
grantableTools(principal: Principal, org: OrgContext, q: z.infer<typeof AutomationGrantableQuery>): Promise<{
|
|
41
43
|
items: GrantableTool[];
|
|
42
44
|
}>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
eventSources(org: OrgContext, _q: z.infer<typeof AutomationEventSourcesQuery>): Promise<{
|
|
46
|
+
items: EventSourceView[];
|
|
45
47
|
}>;
|
|
46
|
-
|
|
47
|
-
task:
|
|
48
|
+
create(principal: Principal, org: OrgContext, body: z.infer<typeof AutomationCreateBody>): Promise<{
|
|
49
|
+
task: Automation;
|
|
48
50
|
}>;
|
|
49
|
-
|
|
50
|
-
task:
|
|
51
|
+
get(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>): Promise<{
|
|
52
|
+
task: Automation;
|
|
51
53
|
}>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
task: ScheduledTask;
|
|
54
|
+
update(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>, body: z.infer<typeof AutomationUpdateBody>): Promise<{
|
|
55
|
+
task: Automation;
|
|
55
56
|
}>;
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
remove(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>): Promise<void>;
|
|
58
|
+
pause(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>): Promise<{
|
|
59
|
+
task: Automation;
|
|
58
60
|
}>;
|
|
59
|
-
|
|
61
|
+
resume(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>): Promise<{
|
|
62
|
+
task: Automation;
|
|
63
|
+
}>;
|
|
64
|
+
run(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>, body: z.infer<typeof AutomationRunBody>): Promise<{
|
|
60
65
|
run: TaskRun;
|
|
61
66
|
}>;
|
|
62
|
-
runs(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
67
|
+
runs(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>, q: z.infer<typeof AutomationRunsQuery>): Promise<{
|
|
63
68
|
items: TaskRun[];
|
|
64
69
|
}>;
|
|
65
|
-
grants(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
66
|
-
items:
|
|
70
|
+
grants(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>): Promise<{
|
|
71
|
+
items: AutomationGrantView[];
|
|
67
72
|
}>;
|
|
68
|
-
addGrants(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
69
|
-
items:
|
|
73
|
+
addGrants(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationParams>, body: z.infer<typeof AutomationGrantsBody>): Promise<{
|
|
74
|
+
items: AutomationGrant[];
|
|
70
75
|
}>;
|
|
71
|
-
removeGrant(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
76
|
+
removeGrant(principal: Principal, org: OrgContext, params: z.infer<typeof AutomationGrantParams>): Promise<void>;
|
|
72
77
|
}
|
|
@@ -11,31 +11,33 @@ import { Controller, Delete, Get, HttpCode, Inject, Patch, Post } from "@nestjs/
|
|
|
11
11
|
import { CurrentPrincipal, requireUser } from "../identity/principal.js";
|
|
12
12
|
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
13
13
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { AutomationCalendarQueryDto, AutomationChatTargetsQueryDto, AutomationCreateBodyDto, AutomationEventSourcesQueryDto, AutomationGrantableQueryDto, AutomationGrantParamsDto, AutomationGrantsBodyDto, AutomationListQueryDto, AutomationParamsDto, AutomationRunBodyDto, AutomationRunsQueryDto, AutomationUpdateBodyDto, calendarInputOf, createInputOf, grantsOf, updateInputOf, } from "./automations.schemas.js";
|
|
15
|
+
import { AutomationsService, } from "./automations.service.js";
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Automations (`/api/v1/orgs/:orgId/automations`, spec 2026-11-11-scheduled-tasks §10); human
|
|
18
18
|
* users only (a service token gets 403).
|
|
19
19
|
* - `GET /` → `{ items }`: the caller's own tasks, each with its `lastRun`; `?all=true` every task
|
|
20
|
-
* of the org (org admins, `
|
|
20
|
+
* of the org (org admins, `automations.manage`, enforced by the service: 403 `forbidden`
|
|
21
21
|
* otherwise); `?conversationId=` only those posting into that conversation;
|
|
22
22
|
* - `GET /calendar?from&to&timeZone[&all][&taskId]` → the calendar (runs, planned occurrences,
|
|
23
23
|
* collapsed task-days; calendar spec §5.1), `org.read` like the list, `all` as the list's;
|
|
24
24
|
* - `GET /chat-targets` → `{ items }`: the chats the caller can point a `chat` task at;
|
|
25
25
|
* - `GET /grantable-tools?agentId=` → `{ items }`: the agent's tools, each grantable or why not;
|
|
26
|
+
* - `GET /event-sources` → `{ items }`: the trigger sources that serve the org (not switched off),
|
|
27
|
+
* each `{ source, name, events }` with the event types and facts an event trigger can use;
|
|
26
28
|
* - `POST /` → 201 `{ task }` (`timeZone` is the browser zone, a fallback only);
|
|
27
29
|
* `GET /:id`, `PATCH /:id`, `POST /:id/pause`, `POST /:id/resume` → `{ task }`;
|
|
28
30
|
* - `DELETE /:id` → 204; `POST /:id/run { trial? }` → 202 `{ run }`;
|
|
29
31
|
* - `GET /:id/runs?limit` → `{ items }`; `GET /:id/grants` → `{ items }` (each with `stale`);
|
|
30
32
|
* `POST /:id/grants { grants }` → `{ items }`; `DELETE /:id/grants/:toolKey` → 204.
|
|
31
33
|
*
|
|
32
|
-
* Roles: create, edit, resume, run and the grants need `
|
|
34
|
+
* Roles: create, edit, resume, run and the grants need `automations.use` (member and up; a guest
|
|
33
35
|
* gets 403). Pause and delete are `org.read` (any member, a guest included) so a creator demoted
|
|
34
36
|
* to guest can still stop and remove their own tasks; the service decides by the live role and
|
|
35
37
|
* ownership (the creator, or an org admin), and a task the caller may not see is 404
|
|
36
|
-
* `
|
|
38
|
+
* `automation.not_found`.
|
|
37
39
|
*/
|
|
38
|
-
let
|
|
40
|
+
let AutomationsController = class AutomationsController {
|
|
39
41
|
tasks;
|
|
40
42
|
constructor(tasks) {
|
|
41
43
|
this.tasks = tasks;
|
|
@@ -63,6 +65,9 @@ let SchedulesController = class SchedulesController {
|
|
|
63
65
|
const p = requireUser(principal);
|
|
64
66
|
return { items: await this.tasks.grantableTools(org.orgId, p.account.id, q.agentId) };
|
|
65
67
|
}
|
|
68
|
+
async eventSources(org, _q) {
|
|
69
|
+
return { items: await this.tasks.eventSources(org.orgId) };
|
|
70
|
+
}
|
|
66
71
|
async create(principal, org, body) {
|
|
67
72
|
const p = requireUser(principal);
|
|
68
73
|
const { input, browserTimeZone } = createInputOf(body);
|
|
@@ -139,118 +144,124 @@ __decorate([
|
|
|
139
144
|
OrgAction("org.read"),
|
|
140
145
|
__param(0, CurrentPrincipal()),
|
|
141
146
|
__param(1, CurrentOrg()),
|
|
142
|
-
__param(2, ZQuery(
|
|
143
|
-
],
|
|
147
|
+
__param(2, ZQuery(AutomationListQueryDto))
|
|
148
|
+
], AutomationsController.prototype, "list", null);
|
|
144
149
|
__decorate([
|
|
145
150
|
Get("calendar"),
|
|
146
151
|
OrgAction("org.read"),
|
|
147
152
|
__param(0, CurrentPrincipal()),
|
|
148
153
|
__param(1, CurrentOrg()),
|
|
149
|
-
__param(2, ZQuery(
|
|
150
|
-
],
|
|
154
|
+
__param(2, ZQuery(AutomationCalendarQueryDto))
|
|
155
|
+
], AutomationsController.prototype, "calendar", null);
|
|
151
156
|
__decorate([
|
|
152
157
|
Get("chat-targets"),
|
|
153
|
-
OrgAction("
|
|
158
|
+
OrgAction("automations.use"),
|
|
154
159
|
__param(0, CurrentPrincipal()),
|
|
155
160
|
__param(1, CurrentOrg()),
|
|
156
|
-
__param(2, ZQuery(
|
|
157
|
-
],
|
|
161
|
+
__param(2, ZQuery(AutomationChatTargetsQueryDto))
|
|
162
|
+
], AutomationsController.prototype, "chatTargets", null);
|
|
158
163
|
__decorate([
|
|
159
164
|
Get("grantable-tools"),
|
|
160
|
-
OrgAction("
|
|
165
|
+
OrgAction("automations.use"),
|
|
161
166
|
__param(0, CurrentPrincipal()),
|
|
162
167
|
__param(1, CurrentOrg()),
|
|
163
|
-
__param(2, ZQuery(
|
|
164
|
-
],
|
|
168
|
+
__param(2, ZQuery(AutomationGrantableQueryDto))
|
|
169
|
+
], AutomationsController.prototype, "grantableTools", null);
|
|
170
|
+
__decorate([
|
|
171
|
+
Get("event-sources"),
|
|
172
|
+
OrgAction("automations.use"),
|
|
173
|
+
__param(0, CurrentOrg()),
|
|
174
|
+
__param(1, ZQuery(AutomationEventSourcesQueryDto))
|
|
175
|
+
], AutomationsController.prototype, "eventSources", null);
|
|
165
176
|
__decorate([
|
|
166
177
|
Post(),
|
|
167
|
-
OrgAction("
|
|
178
|
+
OrgAction("automations.use"),
|
|
168
179
|
__param(0, CurrentPrincipal()),
|
|
169
180
|
__param(1, CurrentOrg()),
|
|
170
|
-
__param(2, ZBody(
|
|
171
|
-
],
|
|
181
|
+
__param(2, ZBody(AutomationCreateBodyDto))
|
|
182
|
+
], AutomationsController.prototype, "create", null);
|
|
172
183
|
__decorate([
|
|
173
184
|
Get(":id"),
|
|
174
|
-
OrgAction("
|
|
185
|
+
OrgAction("automations.use"),
|
|
175
186
|
__param(0, CurrentPrincipal()),
|
|
176
187
|
__param(1, CurrentOrg()),
|
|
177
|
-
__param(2, ZParam(
|
|
178
|
-
],
|
|
188
|
+
__param(2, ZParam(AutomationParamsDto))
|
|
189
|
+
], AutomationsController.prototype, "get", null);
|
|
179
190
|
__decorate([
|
|
180
191
|
Patch(":id"),
|
|
181
|
-
OrgAction("
|
|
192
|
+
OrgAction("automations.use"),
|
|
182
193
|
__param(0, CurrentPrincipal()),
|
|
183
194
|
__param(1, CurrentOrg()),
|
|
184
|
-
__param(2, ZParam(
|
|
185
|
-
__param(3, ZBody(
|
|
186
|
-
],
|
|
195
|
+
__param(2, ZParam(AutomationParamsDto)),
|
|
196
|
+
__param(3, ZBody(AutomationUpdateBodyDto))
|
|
197
|
+
], AutomationsController.prototype, "update", null);
|
|
187
198
|
__decorate([
|
|
188
199
|
Delete(":id"),
|
|
189
200
|
HttpCode(204),
|
|
190
201
|
OrgAction("org.read"),
|
|
191
202
|
__param(0, CurrentPrincipal()),
|
|
192
203
|
__param(1, CurrentOrg()),
|
|
193
|
-
__param(2, ZParam(
|
|
194
|
-
],
|
|
204
|
+
__param(2, ZParam(AutomationParamsDto))
|
|
205
|
+
], AutomationsController.prototype, "remove", null);
|
|
195
206
|
__decorate([
|
|
196
207
|
Post(":id/pause"),
|
|
197
208
|
HttpCode(200),
|
|
198
209
|
OrgAction("org.read"),
|
|
199
210
|
__param(0, CurrentPrincipal()),
|
|
200
211
|
__param(1, CurrentOrg()),
|
|
201
|
-
__param(2, ZParam(
|
|
202
|
-
],
|
|
212
|
+
__param(2, ZParam(AutomationParamsDto))
|
|
213
|
+
], AutomationsController.prototype, "pause", null);
|
|
203
214
|
__decorate([
|
|
204
215
|
Post(":id/resume"),
|
|
205
216
|
HttpCode(200),
|
|
206
|
-
OrgAction("
|
|
217
|
+
OrgAction("automations.use"),
|
|
207
218
|
__param(0, CurrentPrincipal()),
|
|
208
219
|
__param(1, CurrentOrg()),
|
|
209
|
-
__param(2, ZParam(
|
|
210
|
-
],
|
|
220
|
+
__param(2, ZParam(AutomationParamsDto))
|
|
221
|
+
], AutomationsController.prototype, "resume", null);
|
|
211
222
|
__decorate([
|
|
212
223
|
Post(":id/run"),
|
|
213
224
|
HttpCode(202),
|
|
214
|
-
OrgAction("
|
|
225
|
+
OrgAction("automations.use"),
|
|
215
226
|
__param(0, CurrentPrincipal()),
|
|
216
227
|
__param(1, CurrentOrg()),
|
|
217
|
-
__param(2, ZParam(
|
|
218
|
-
__param(3, ZBody(
|
|
219
|
-
],
|
|
228
|
+
__param(2, ZParam(AutomationParamsDto)),
|
|
229
|
+
__param(3, ZBody(AutomationRunBodyDto))
|
|
230
|
+
], AutomationsController.prototype, "run", null);
|
|
220
231
|
__decorate([
|
|
221
232
|
Get(":id/runs"),
|
|
222
|
-
OrgAction("
|
|
233
|
+
OrgAction("automations.use"),
|
|
223
234
|
__param(0, CurrentPrincipal()),
|
|
224
235
|
__param(1, CurrentOrg()),
|
|
225
|
-
__param(2, ZParam(
|
|
226
|
-
__param(3, ZQuery(
|
|
227
|
-
],
|
|
236
|
+
__param(2, ZParam(AutomationParamsDto)),
|
|
237
|
+
__param(3, ZQuery(AutomationRunsQueryDto))
|
|
238
|
+
], AutomationsController.prototype, "runs", null);
|
|
228
239
|
__decorate([
|
|
229
240
|
Get(":id/grants"),
|
|
230
|
-
OrgAction("
|
|
241
|
+
OrgAction("automations.use"),
|
|
231
242
|
__param(0, CurrentPrincipal()),
|
|
232
243
|
__param(1, CurrentOrg()),
|
|
233
|
-
__param(2, ZParam(
|
|
234
|
-
],
|
|
244
|
+
__param(2, ZParam(AutomationParamsDto))
|
|
245
|
+
], AutomationsController.prototype, "grants", null);
|
|
235
246
|
__decorate([
|
|
236
247
|
Post(":id/grants"),
|
|
237
248
|
HttpCode(200),
|
|
238
|
-
OrgAction("
|
|
249
|
+
OrgAction("automations.use"),
|
|
239
250
|
__param(0, CurrentPrincipal()),
|
|
240
251
|
__param(1, CurrentOrg()),
|
|
241
|
-
__param(2, ZParam(
|
|
242
|
-
__param(3, ZBody(
|
|
243
|
-
],
|
|
252
|
+
__param(2, ZParam(AutomationParamsDto)),
|
|
253
|
+
__param(3, ZBody(AutomationGrantsBodyDto))
|
|
254
|
+
], AutomationsController.prototype, "addGrants", null);
|
|
244
255
|
__decorate([
|
|
245
256
|
Delete(":id/grants/:toolKey"),
|
|
246
257
|
HttpCode(204),
|
|
247
|
-
OrgAction("
|
|
258
|
+
OrgAction("automations.use"),
|
|
248
259
|
__param(0, CurrentPrincipal()),
|
|
249
260
|
__param(1, CurrentOrg()),
|
|
250
|
-
__param(2, ZParam(
|
|
251
|
-
],
|
|
252
|
-
|
|
253
|
-
Controller("api/v1/orgs/:orgId/
|
|
254
|
-
__param(0, Inject(
|
|
255
|
-
],
|
|
256
|
-
export {
|
|
261
|
+
__param(2, ZParam(AutomationGrantParamsDto))
|
|
262
|
+
], AutomationsController.prototype, "removeGrant", null);
|
|
263
|
+
AutomationsController = __decorate([
|
|
264
|
+
Controller("api/v1/orgs/:orgId/automations"),
|
|
265
|
+
__param(0, Inject(AutomationsService))
|
|
266
|
+
], AutomationsController);
|
|
267
|
+
export { AutomationsController };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { AutomationToolsPort } from "../tools/builtins/automations.js";
|
|
3
|
+
import { AutomationsService } from "./automations.service.js";
|
|
4
|
+
/**
|
|
5
|
+
* Automations for people (spec 2026-11-11): the service the HTTP API, the Platform operations
|
|
6
|
+
* and the automation tools share. ToolsModule: grants resolve the agent's tools (`ToolRegistry`);
|
|
7
|
+
* ExtensionRegistryModule: a group chat target needs its channel's `features.threads`. At start
|
|
8
|
+
* it binds the service into the automation tools' port (`AutomationToolsPort`): the tools cannot
|
|
9
|
+
* inject it, since this module imports theirs.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AutomationsModule implements OnModuleInit {
|
|
12
|
+
private readonly port;
|
|
13
|
+
private readonly service;
|
|
14
|
+
constructor(port: AutomationToolsPort, service: AutomationsService);
|
|
15
|
+
onModuleInit(): void;
|
|
16
|
+
}
|
|
@@ -11,23 +11,24 @@ import { Inject, Module } from "@nestjs/common";
|
|
|
11
11
|
import { AgentLookupModule } from "../agents/agent-lookup.js";
|
|
12
12
|
import { ConversationAccessModule } from "../conversations/access.js";
|
|
13
13
|
import { DialInModule } from "../dial-in/dial-in.module.js";
|
|
14
|
+
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
14
15
|
import { ExtensionRegistryModule } from "../extensions/registry.js";
|
|
15
16
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
16
17
|
import { ProvidersModule } from "../runtime/providers.js";
|
|
17
18
|
import { NetworkGrantsModule } from "../sandbox/network-grants.module.js";
|
|
18
19
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
19
|
-
import {
|
|
20
|
+
import { AutomationToolsPort } from "../tools/builtins/automations.js";
|
|
20
21
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
22
|
+
import { AutomationsService } from "./automations.service.js";
|
|
23
|
+
import { AutomationStoreModule } from "./store.module.js";
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
* and the
|
|
25
|
+
* Automations for people (spec 2026-11-11): the service the HTTP API, the Platform operations
|
|
26
|
+
* and the automation tools share. ToolsModule: grants resolve the agent's tools (`ToolRegistry`);
|
|
26
27
|
* ExtensionRegistryModule: a group chat target needs its channel's `features.threads`. At start
|
|
27
|
-
* it binds the service into the
|
|
28
|
+
* it binds the service into the automation tools' port (`AutomationToolsPort`): the tools cannot
|
|
28
29
|
* inject it, since this module imports theirs.
|
|
29
30
|
*/
|
|
30
|
-
let
|
|
31
|
+
let AutomationsModule = class AutomationsModule {
|
|
31
32
|
port;
|
|
32
33
|
service;
|
|
33
34
|
constructor(port, service) {
|
|
@@ -38,14 +39,16 @@ let SchedulesModule = class SchedulesModule {
|
|
|
38
39
|
this.port.bind(this.service);
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
+
AutomationsModule = __decorate([
|
|
42
43
|
Module({
|
|
43
44
|
imports: [
|
|
44
|
-
|
|
45
|
+
AutomationStoreModule,
|
|
45
46
|
OrgLockModule,
|
|
46
47
|
AgentLookupModule,
|
|
47
48
|
ConversationAccessModule,
|
|
48
49
|
ExtensionRegistryModule,
|
|
50
|
+
// event automations: the trigger sources of an org and their display names
|
|
51
|
+
ExtensionsModule,
|
|
49
52
|
ToolsModule,
|
|
50
53
|
// a new-conversation task's model must resolve for the org
|
|
51
54
|
ProvidersModule,
|
|
@@ -54,10 +57,10 @@ SchedulesModule = __decorate([
|
|
|
54
57
|
NetworkGrantsModule,
|
|
55
58
|
DialInModule,
|
|
56
59
|
],
|
|
57
|
-
providers: [
|
|
58
|
-
exports: [
|
|
60
|
+
providers: [AutomationsService],
|
|
61
|
+
exports: [AutomationsService, AutomationStoreModule],
|
|
59
62
|
}),
|
|
60
|
-
__param(0, Inject(
|
|
61
|
-
__param(1, Inject(
|
|
62
|
-
],
|
|
63
|
-
export {
|
|
63
|
+
__param(0, Inject(AutomationToolsPort)),
|
|
64
|
+
__param(1, Inject(AutomationsService))
|
|
65
|
+
], AutomationsModule);
|
|
66
|
+
export { AutomationsModule };
|