@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,68 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { type Principal } from "../identity/principal.js";
|
|
3
|
+
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
|
+
import { type ChatTarget, type GrantableTool, type ScheduledTaskGrantView, type ScheduledTaskListItem, ScheduledTasksService } from "./scheduled-tasks.service.js";
|
|
5
|
+
import { type ScheduleChatTargetsQuery, type ScheduleCreateBody, type ScheduleGrantableQuery, type ScheduleGrantParams, type ScheduleGrantsBody, type ScheduleListQuery, type ScheduleParams, type ScheduleRunBody, type ScheduleRunsQuery, type ScheduleUpdateBody } from "./schedules.schemas.js";
|
|
6
|
+
import type { ScheduledTask, ScheduledTaskGrant, TaskRun } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Scheduled tasks (`/api/v1/orgs/:orgId/schedules`, spec 2026-11-11-scheduled-tasks §10); human
|
|
9
|
+
* users only (a service token gets 403).
|
|
10
|
+
* - `GET /` → `{ items }`: the caller's own tasks, each with its `lastRun`; `?all=true` every task
|
|
11
|
+
* of the org (org admins, `schedules.manage`, enforced by the service: 403 `forbidden`
|
|
12
|
+
* otherwise); `?conversationId=` only those posting into that conversation;
|
|
13
|
+
* - `GET /chat-targets` → `{ items }`: the chats the caller can point a `chat` task at;
|
|
14
|
+
* - `GET /grantable-tools?agentId=` → `{ items }`: the agent's tools, each grantable or why not;
|
|
15
|
+
* - `POST /` → 201 `{ task }` (`timeZone` is the browser zone, a fallback only);
|
|
16
|
+
* `GET /:id`, `PATCH /:id`, `POST /:id/pause`, `POST /:id/resume` → `{ task }`;
|
|
17
|
+
* - `DELETE /:id` → 204; `POST /:id/run { trial? }` → 202 `{ run }`;
|
|
18
|
+
* - `GET /:id/runs?limit` → `{ items }`; `GET /:id/grants` → `{ items }` (each with `stale`);
|
|
19
|
+
* `POST /:id/grants { grants }` → `{ items }`; `DELETE /:id/grants/:toolKey` → 204.
|
|
20
|
+
*
|
|
21
|
+
* Roles: create, edit, resume, run and the grants need `schedules.use` (member and up; a guest
|
|
22
|
+
* gets 403). Pause and delete are `org.read` (any member, a guest included) so a creator demoted
|
|
23
|
+
* to guest can still stop and remove their own tasks; the service decides by the live role and
|
|
24
|
+
* ownership (the creator, or an org admin), and a task the caller may not see is 404
|
|
25
|
+
* `schedule.not_found`.
|
|
26
|
+
*/
|
|
27
|
+
export declare class SchedulesController {
|
|
28
|
+
private readonly tasks;
|
|
29
|
+
constructor(tasks: ScheduledTasksService);
|
|
30
|
+
list(principal: Principal, org: OrgContext, q: z.infer<typeof ScheduleListQuery>): Promise<{
|
|
31
|
+
items: ScheduledTaskListItem[];
|
|
32
|
+
}>;
|
|
33
|
+
chatTargets(principal: Principal, org: OrgContext, _q: z.infer<typeof ScheduleChatTargetsQuery>): Promise<{
|
|
34
|
+
items: ChatTarget[];
|
|
35
|
+
}>;
|
|
36
|
+
grantableTools(principal: Principal, org: OrgContext, q: z.infer<typeof ScheduleGrantableQuery>): Promise<{
|
|
37
|
+
items: GrantableTool[];
|
|
38
|
+
}>;
|
|
39
|
+
create(principal: Principal, org: OrgContext, body: z.infer<typeof ScheduleCreateBody>): Promise<{
|
|
40
|
+
task: ScheduledTask;
|
|
41
|
+
}>;
|
|
42
|
+
get(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>): Promise<{
|
|
43
|
+
task: ScheduledTask;
|
|
44
|
+
}>;
|
|
45
|
+
update(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>, body: z.infer<typeof ScheduleUpdateBody>): Promise<{
|
|
46
|
+
task: ScheduledTask;
|
|
47
|
+
}>;
|
|
48
|
+
remove(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>): Promise<void>;
|
|
49
|
+
pause(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>): Promise<{
|
|
50
|
+
task: ScheduledTask;
|
|
51
|
+
}>;
|
|
52
|
+
resume(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>): Promise<{
|
|
53
|
+
task: ScheduledTask;
|
|
54
|
+
}>;
|
|
55
|
+
run(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>, body: z.infer<typeof ScheduleRunBody>): Promise<{
|
|
56
|
+
run: TaskRun;
|
|
57
|
+
}>;
|
|
58
|
+
runs(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>, q: z.infer<typeof ScheduleRunsQuery>): Promise<{
|
|
59
|
+
items: TaskRun[];
|
|
60
|
+
}>;
|
|
61
|
+
grants(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>): Promise<{
|
|
62
|
+
items: ScheduledTaskGrantView[];
|
|
63
|
+
}>;
|
|
64
|
+
addGrants(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleParams>, body: z.infer<typeof ScheduleGrantsBody>): Promise<{
|
|
65
|
+
items: ScheduledTaskGrant[];
|
|
66
|
+
}>;
|
|
67
|
+
removeGrant(principal: Principal, org: OrgContext, params: z.infer<typeof ScheduleGrantParams>): Promise<void>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Controller, Delete, Get, HttpCode, Inject, Patch, Post } from "@nestjs/common";
|
|
11
|
+
import { CurrentPrincipal, requireUser } from "../identity/principal.js";
|
|
12
|
+
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
13
|
+
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
14
|
+
import { ScheduledTasksService, } from "./scheduled-tasks.service.js";
|
|
15
|
+
import { createInputOf, grantsOf, ScheduleChatTargetsQueryDto, ScheduleCreateBodyDto, ScheduleGrantableQueryDto, ScheduleGrantParamsDto, ScheduleGrantsBodyDto, ScheduleListQueryDto, ScheduleParamsDto, ScheduleRunBodyDto, ScheduleRunsQueryDto, ScheduleUpdateBodyDto, updateInputOf, } from "./schedules.schemas.js";
|
|
16
|
+
/**
|
|
17
|
+
* Scheduled tasks (`/api/v1/orgs/:orgId/schedules`, spec 2026-11-11-scheduled-tasks §10); human
|
|
18
|
+
* users only (a service token gets 403).
|
|
19
|
+
* - `GET /` → `{ items }`: the caller's own tasks, each with its `lastRun`; `?all=true` every task
|
|
20
|
+
* of the org (org admins, `schedules.manage`, enforced by the service: 403 `forbidden`
|
|
21
|
+
* otherwise); `?conversationId=` only those posting into that conversation;
|
|
22
|
+
* - `GET /chat-targets` → `{ items }`: the chats the caller can point a `chat` task at;
|
|
23
|
+
* - `GET /grantable-tools?agentId=` → `{ items }`: the agent's tools, each grantable or why not;
|
|
24
|
+
* - `POST /` → 201 `{ task }` (`timeZone` is the browser zone, a fallback only);
|
|
25
|
+
* `GET /:id`, `PATCH /:id`, `POST /:id/pause`, `POST /:id/resume` → `{ task }`;
|
|
26
|
+
* - `DELETE /:id` → 204; `POST /:id/run { trial? }` → 202 `{ run }`;
|
|
27
|
+
* - `GET /:id/runs?limit` → `{ items }`; `GET /:id/grants` → `{ items }` (each with `stale`);
|
|
28
|
+
* `POST /:id/grants { grants }` → `{ items }`; `DELETE /:id/grants/:toolKey` → 204.
|
|
29
|
+
*
|
|
30
|
+
* Roles: create, edit, resume, run and the grants need `schedules.use` (member and up; a guest
|
|
31
|
+
* gets 403). Pause and delete are `org.read` (any member, a guest included) so a creator demoted
|
|
32
|
+
* to guest can still stop and remove their own tasks; the service decides by the live role and
|
|
33
|
+
* ownership (the creator, or an org admin), and a task the caller may not see is 404
|
|
34
|
+
* `schedule.not_found`.
|
|
35
|
+
*/
|
|
36
|
+
let SchedulesController = class SchedulesController {
|
|
37
|
+
tasks;
|
|
38
|
+
constructor(tasks) {
|
|
39
|
+
this.tasks = tasks;
|
|
40
|
+
}
|
|
41
|
+
// org.read: a creator demoted to guest still lists their own tasks (to pause or delete them);
|
|
42
|
+
// `all` is the service's admin check
|
|
43
|
+
async list(principal, org, q) {
|
|
44
|
+
const p = requireUser(principal);
|
|
45
|
+
const items = await this.tasks.list(org.orgId, { accountId: p.account.id }, {
|
|
46
|
+
all: q.all === "true",
|
|
47
|
+
...(q.conversationId !== undefined && { conversationId: q.conversationId }),
|
|
48
|
+
});
|
|
49
|
+
return { items };
|
|
50
|
+
}
|
|
51
|
+
async chatTargets(principal, org, _q) {
|
|
52
|
+
const p = requireUser(principal);
|
|
53
|
+
return { items: await this.tasks.chatTargets(org.orgId, p.account.id) };
|
|
54
|
+
}
|
|
55
|
+
async grantableTools(principal, org, q) {
|
|
56
|
+
const p = requireUser(principal);
|
|
57
|
+
return { items: await this.tasks.grantableTools(org.orgId, p.account.id, q.agentId) };
|
|
58
|
+
}
|
|
59
|
+
async create(principal, org, body) {
|
|
60
|
+
const p = requireUser(principal);
|
|
61
|
+
const { input, browserTimeZone } = createInputOf(body);
|
|
62
|
+
// network domains only from a person's web session (never a personal access token)
|
|
63
|
+
return {
|
|
64
|
+
task: await this.tasks.create(org.orgId, p.account.id, input, browserTimeZone, {
|
|
65
|
+
fromSession: p.via === "session",
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async get(principal, org, params) {
|
|
70
|
+
const p = requireUser(principal);
|
|
71
|
+
return {
|
|
72
|
+
task: await this.tasks.get(org.orgId, { accountId: p.account.id }, params.id),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async update(principal, org, params, body) {
|
|
76
|
+
const p = requireUser(principal);
|
|
77
|
+
return {
|
|
78
|
+
task: await this.tasks.update(org.orgId, p.account.id, params.id, updateInputOf(body)),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async remove(principal, org, params) {
|
|
82
|
+
const p = requireUser(principal);
|
|
83
|
+
await this.tasks.remove(org.orgId, { accountId: p.account.id }, params.id);
|
|
84
|
+
}
|
|
85
|
+
async pause(principal, org, params) {
|
|
86
|
+
const p = requireUser(principal);
|
|
87
|
+
return {
|
|
88
|
+
task: await this.tasks.pause(org.orgId, { accountId: p.account.id }, params.id),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async resume(principal, org, params) {
|
|
92
|
+
const p = requireUser(principal);
|
|
93
|
+
return {
|
|
94
|
+
task: await this.tasks.resume(org.orgId, { accountId: p.account.id }, params.id),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async run(principal, org, params, body) {
|
|
98
|
+
const p = requireUser(principal);
|
|
99
|
+
return {
|
|
100
|
+
run: await this.tasks.runNow(org.orgId, p.account.id, params.id, {
|
|
101
|
+
trial: body.trial === true,
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async runs(principal, org, params, q) {
|
|
106
|
+
const p = requireUser(principal);
|
|
107
|
+
return {
|
|
108
|
+
items: await this.tasks.runs(org.orgId, { accountId: p.account.id }, params.id, q.limit),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async grants(principal, org, params) {
|
|
112
|
+
const p = requireUser(principal);
|
|
113
|
+
return {
|
|
114
|
+
items: await this.tasks.grants(org.orgId, { accountId: p.account.id }, params.id),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async addGrants(principal, org, params, body) {
|
|
118
|
+
const p = requireUser(principal);
|
|
119
|
+
return {
|
|
120
|
+
items: await this.tasks.addGrants(org.orgId, p.account.id, params.id, grantsOf(body.grants), {
|
|
121
|
+
fromSession: p.via === "session",
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async removeGrant(principal, org, params) {
|
|
126
|
+
const p = requireUser(principal);
|
|
127
|
+
await this.tasks.removeGrant(org.orgId, p.account.id, params.id, params.toolKey);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
__decorate([
|
|
131
|
+
Get(),
|
|
132
|
+
OrgAction("org.read"),
|
|
133
|
+
__param(0, CurrentPrincipal()),
|
|
134
|
+
__param(1, CurrentOrg()),
|
|
135
|
+
__param(2, ZQuery(ScheduleListQueryDto))
|
|
136
|
+
], SchedulesController.prototype, "list", null);
|
|
137
|
+
__decorate([
|
|
138
|
+
Get("chat-targets"),
|
|
139
|
+
OrgAction("schedules.use"),
|
|
140
|
+
__param(0, CurrentPrincipal()),
|
|
141
|
+
__param(1, CurrentOrg()),
|
|
142
|
+
__param(2, ZQuery(ScheduleChatTargetsQueryDto))
|
|
143
|
+
], SchedulesController.prototype, "chatTargets", null);
|
|
144
|
+
__decorate([
|
|
145
|
+
Get("grantable-tools"),
|
|
146
|
+
OrgAction("schedules.use"),
|
|
147
|
+
__param(0, CurrentPrincipal()),
|
|
148
|
+
__param(1, CurrentOrg()),
|
|
149
|
+
__param(2, ZQuery(ScheduleGrantableQueryDto))
|
|
150
|
+
], SchedulesController.prototype, "grantableTools", null);
|
|
151
|
+
__decorate([
|
|
152
|
+
Post(),
|
|
153
|
+
OrgAction("schedules.use"),
|
|
154
|
+
__param(0, CurrentPrincipal()),
|
|
155
|
+
__param(1, CurrentOrg()),
|
|
156
|
+
__param(2, ZBody(ScheduleCreateBodyDto))
|
|
157
|
+
], SchedulesController.prototype, "create", null);
|
|
158
|
+
__decorate([
|
|
159
|
+
Get(":id"),
|
|
160
|
+
OrgAction("schedules.use"),
|
|
161
|
+
__param(0, CurrentPrincipal()),
|
|
162
|
+
__param(1, CurrentOrg()),
|
|
163
|
+
__param(2, ZParam(ScheduleParamsDto))
|
|
164
|
+
], SchedulesController.prototype, "get", null);
|
|
165
|
+
__decorate([
|
|
166
|
+
Patch(":id"),
|
|
167
|
+
OrgAction("schedules.use"),
|
|
168
|
+
__param(0, CurrentPrincipal()),
|
|
169
|
+
__param(1, CurrentOrg()),
|
|
170
|
+
__param(2, ZParam(ScheduleParamsDto)),
|
|
171
|
+
__param(3, ZBody(ScheduleUpdateBodyDto))
|
|
172
|
+
], SchedulesController.prototype, "update", null);
|
|
173
|
+
__decorate([
|
|
174
|
+
Delete(":id"),
|
|
175
|
+
HttpCode(204),
|
|
176
|
+
OrgAction("org.read"),
|
|
177
|
+
__param(0, CurrentPrincipal()),
|
|
178
|
+
__param(1, CurrentOrg()),
|
|
179
|
+
__param(2, ZParam(ScheduleParamsDto))
|
|
180
|
+
], SchedulesController.prototype, "remove", null);
|
|
181
|
+
__decorate([
|
|
182
|
+
Post(":id/pause"),
|
|
183
|
+
HttpCode(200),
|
|
184
|
+
OrgAction("org.read"),
|
|
185
|
+
__param(0, CurrentPrincipal()),
|
|
186
|
+
__param(1, CurrentOrg()),
|
|
187
|
+
__param(2, ZParam(ScheduleParamsDto))
|
|
188
|
+
], SchedulesController.prototype, "pause", null);
|
|
189
|
+
__decorate([
|
|
190
|
+
Post(":id/resume"),
|
|
191
|
+
HttpCode(200),
|
|
192
|
+
OrgAction("schedules.use"),
|
|
193
|
+
__param(0, CurrentPrincipal()),
|
|
194
|
+
__param(1, CurrentOrg()),
|
|
195
|
+
__param(2, ZParam(ScheduleParamsDto))
|
|
196
|
+
], SchedulesController.prototype, "resume", null);
|
|
197
|
+
__decorate([
|
|
198
|
+
Post(":id/run"),
|
|
199
|
+
HttpCode(202),
|
|
200
|
+
OrgAction("schedules.use"),
|
|
201
|
+
__param(0, CurrentPrincipal()),
|
|
202
|
+
__param(1, CurrentOrg()),
|
|
203
|
+
__param(2, ZParam(ScheduleParamsDto)),
|
|
204
|
+
__param(3, ZBody(ScheduleRunBodyDto))
|
|
205
|
+
], SchedulesController.prototype, "run", null);
|
|
206
|
+
__decorate([
|
|
207
|
+
Get(":id/runs"),
|
|
208
|
+
OrgAction("schedules.use"),
|
|
209
|
+
__param(0, CurrentPrincipal()),
|
|
210
|
+
__param(1, CurrentOrg()),
|
|
211
|
+
__param(2, ZParam(ScheduleParamsDto)),
|
|
212
|
+
__param(3, ZQuery(ScheduleRunsQueryDto))
|
|
213
|
+
], SchedulesController.prototype, "runs", null);
|
|
214
|
+
__decorate([
|
|
215
|
+
Get(":id/grants"),
|
|
216
|
+
OrgAction("schedules.use"),
|
|
217
|
+
__param(0, CurrentPrincipal()),
|
|
218
|
+
__param(1, CurrentOrg()),
|
|
219
|
+
__param(2, ZParam(ScheduleParamsDto))
|
|
220
|
+
], SchedulesController.prototype, "grants", null);
|
|
221
|
+
__decorate([
|
|
222
|
+
Post(":id/grants"),
|
|
223
|
+
HttpCode(200),
|
|
224
|
+
OrgAction("schedules.use"),
|
|
225
|
+
__param(0, CurrentPrincipal()),
|
|
226
|
+
__param(1, CurrentOrg()),
|
|
227
|
+
__param(2, ZParam(ScheduleParamsDto)),
|
|
228
|
+
__param(3, ZBody(ScheduleGrantsBodyDto))
|
|
229
|
+
], SchedulesController.prototype, "addGrants", null);
|
|
230
|
+
__decorate([
|
|
231
|
+
Delete(":id/grants/:toolKey"),
|
|
232
|
+
HttpCode(204),
|
|
233
|
+
OrgAction("schedules.use"),
|
|
234
|
+
__param(0, CurrentPrincipal()),
|
|
235
|
+
__param(1, CurrentOrg()),
|
|
236
|
+
__param(2, ZParam(ScheduleGrantParamsDto))
|
|
237
|
+
], SchedulesController.prototype, "removeGrant", null);
|
|
238
|
+
SchedulesController = __decorate([
|
|
239
|
+
Controller("api/v1/orgs/:orgId/schedules"),
|
|
240
|
+
__param(0, Inject(ScheduledTasksService))
|
|
241
|
+
], SchedulesController);
|
|
242
|
+
export { SchedulesController };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { ScheduleToolsPort } from "../tools/builtins/schedules.js";
|
|
3
|
+
import { ScheduledTasksService } from "./scheduled-tasks.service.js";
|
|
4
|
+
/**
|
|
5
|
+
* Scheduled tasks for people (spec 2026-11-11): the service the HTTP API, the Platform operations
|
|
6
|
+
* and the schedule 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 schedule tools' port (`ScheduleToolsPort`): the tools cannot
|
|
9
|
+
* inject it, since this module imports theirs.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SchedulesModule implements OnModuleInit {
|
|
12
|
+
private readonly port;
|
|
13
|
+
private readonly service;
|
|
14
|
+
constructor(port: ScheduleToolsPort, service: ScheduledTasksService);
|
|
15
|
+
onModuleInit(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Module } from "@nestjs/common";
|
|
11
|
+
import { AgentLookupModule } from "../agents/agent-lookup.js";
|
|
12
|
+
import { ConversationAccessModule } from "../conversations/access.js";
|
|
13
|
+
import { ExtensionRegistryModule } from "../extensions/registry.js";
|
|
14
|
+
import { QueueModule } from "../infra/queue/queue.module.js";
|
|
15
|
+
import { LocalDevicesModule } from "../local-devices/local-devices.module.js";
|
|
16
|
+
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
17
|
+
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
18
|
+
import { ProvidersModule } from "../runtime/providers.js";
|
|
19
|
+
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
20
|
+
import { ScheduleToolsPort } from "../tools/builtins/schedules.js";
|
|
21
|
+
import { ToolsModule } from "../tools/tools.module.js";
|
|
22
|
+
import { ScheduledTasksService } from "./scheduled-tasks.service.js";
|
|
23
|
+
import { ScheduledTaskStoreModule } from "./store.module.js";
|
|
24
|
+
/**
|
|
25
|
+
* Scheduled tasks for people (spec 2026-11-11): the service the HTTP API, the Platform operations
|
|
26
|
+
* and the schedule tools share. ToolsModule: grants resolve the agent's tools (`ToolRegistry`);
|
|
27
|
+
* ExtensionRegistryModule: a group chat target needs its channel's `features.threads`. At start
|
|
28
|
+
* it binds the service into the schedule tools' port (`ScheduleToolsPort`): the tools cannot
|
|
29
|
+
* inject it, since this module imports theirs.
|
|
30
|
+
*/
|
|
31
|
+
let SchedulesModule = class SchedulesModule {
|
|
32
|
+
port;
|
|
33
|
+
service;
|
|
34
|
+
constructor(port, service) {
|
|
35
|
+
this.port = port;
|
|
36
|
+
this.service = service;
|
|
37
|
+
}
|
|
38
|
+
onModuleInit() {
|
|
39
|
+
this.port.bind(this.service);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
SchedulesModule = __decorate([
|
|
43
|
+
Module({
|
|
44
|
+
imports: [
|
|
45
|
+
ScheduledTaskStoreModule,
|
|
46
|
+
OrgLockModule,
|
|
47
|
+
AgentLookupModule,
|
|
48
|
+
ConversationAccessModule,
|
|
49
|
+
ExtensionRegistryModule,
|
|
50
|
+
ToolsModule,
|
|
51
|
+
// a new-conversation task's model must resolve for the org
|
|
52
|
+
ProvidersModule,
|
|
53
|
+
// network grants: the org's effective egress and the task device's policy summary
|
|
54
|
+
SandboxModule,
|
|
55
|
+
LocalDevicesModule,
|
|
56
|
+
// "run now" enqueues the fire job
|
|
57
|
+
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
58
|
+
],
|
|
59
|
+
providers: [ScheduledTasksService],
|
|
60
|
+
exports: [ScheduledTasksService, ScheduledTaskStoreModule],
|
|
61
|
+
}),
|
|
62
|
+
__param(0, Inject(ScheduleToolsPort)),
|
|
63
|
+
__param(1, Inject(ScheduledTasksService))
|
|
64
|
+
], SchedulesModule);
|
|
65
|
+
export { SchedulesModule };
|