@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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { ApiError } from "../errors.js";
|
|
3
|
+
import { clipped } from "./project-rules.js";
|
|
4
|
+
/** The longest path relative to a project the kernel takes (the add route's bound). */
|
|
5
|
+
export const MAX_PROJECT_RELATIVE_PATH = 4096;
|
|
6
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses
|
|
7
|
+
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
8
|
+
/**
|
|
9
|
+
* A path relative to a device project (composer menus §5) that is refused: absolute, escaping the
|
|
10
|
+
* project root with `..`, holding a backslash or a control character, or too long. 422
|
|
11
|
+
* `device.path_outside_project` with the path (clipped) in `details`.
|
|
12
|
+
*/
|
|
13
|
+
export const pathOutsideProject = (rel) => new ApiError("device.path_outside_project", "Give a path relative to the project root that stays inside it: no absolute path, no .. above the root, no backslashes or control characters", [{ path: clipped(rel) }]);
|
|
14
|
+
/**
|
|
15
|
+
* `rel` normalized as a posix path relative to a project's root: `""` for the root itself, no
|
|
16
|
+
* `.` segments, no doubled or trailing `/`, `..` resolved. Refused ({@link pathOutsideProject})
|
|
17
|
+
* when it is absolute, climbs above the root, holds a backslash or a control character (NUL
|
|
18
|
+
* included), or is longer than {@link MAX_PROJECT_RELATIVE_PATH}. Pure string work: the device
|
|
19
|
+
* is never asked, so a symlink below the root is the provider's and its browse scope's to judge.
|
|
20
|
+
*/
|
|
21
|
+
export function projectRelativePath(rel) {
|
|
22
|
+
if (rel.length > MAX_PROJECT_RELATIVE_PATH ||
|
|
23
|
+
rel.startsWith("/") ||
|
|
24
|
+
rel.includes("\\") ||
|
|
25
|
+
CONTROL.test(rel)) {
|
|
26
|
+
throw pathOutsideProject(rel);
|
|
27
|
+
}
|
|
28
|
+
if (rel === "")
|
|
29
|
+
return "";
|
|
30
|
+
const n = posix.normalize(rel);
|
|
31
|
+
if (n === ".." || n.startsWith("../") || posix.isAbsolute(n))
|
|
32
|
+
throw pathOutsideProject(rel);
|
|
33
|
+
const trimmed = n.endsWith("/") ? n.slice(0, -1) : n;
|
|
34
|
+
return trimmed === "." ? "" : trimmed;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The absolute device path of `rel` (normalized through {@link projectRelativePath}, so refused
|
|
38
|
+
* the same way) inside the project rooted at `projectPath`, which must itself be absolute and
|
|
39
|
+
* normalized (no `.` / `..` segments, no doubled or trailing `/`): an internal error otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export function joinProjectPath(projectPath, rel) {
|
|
42
|
+
// the project path is the kernel's own (a stored project): one that is not absolute and
|
|
43
|
+
// normalized is a kernel bug, never the person's path
|
|
44
|
+
if (!posix.isAbsolute(projectPath) ||
|
|
45
|
+
posix.normalize(projectPath) !== projectPath ||
|
|
46
|
+
(projectPath !== "/" && projectPath.endsWith("/"))) {
|
|
47
|
+
throw new Error(`joinProjectPath: the project path ${JSON.stringify(clipped(projectPath))} is not absolute and normalized`);
|
|
48
|
+
}
|
|
49
|
+
const r = projectRelativePath(rel);
|
|
50
|
+
const root = projectPath;
|
|
51
|
+
if (r === "")
|
|
52
|
+
return root;
|
|
53
|
+
return root === "/" ? `/${r}` : `${root}/${r}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* {@link projectRelativePath} for a path that must name a file below the root: one that
|
|
57
|
+
* normalizes to the root itself (`"."`, `"./"`, `"a/.."`) is refused with
|
|
58
|
+
* `device.path_outside_project` as well, its path in `details` as given (none when empty).
|
|
59
|
+
*/
|
|
60
|
+
export function projectFilePath(rel) {
|
|
61
|
+
const r = projectRelativePath(rel);
|
|
62
|
+
if (r === "") {
|
|
63
|
+
throw new ApiError("device.path_outside_project", "The project root is not a file; give the path of a file inside the project", rel === "" ? undefined : [{ path: clipped(rel) }]);
|
|
64
|
+
}
|
|
65
|
+
return r;
|
|
66
|
+
}
|
|
@@ -24,7 +24,11 @@ export declare const projectNotFound: (name: string) => ApiError;
|
|
|
24
24
|
* the resolved path is not one a device can hold.
|
|
25
25
|
*/
|
|
26
26
|
export declare const outsideMode: (path: string) => ApiError;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A project directory above the owner's home: named by the project (`name`, when there is one),
|
|
29
|
+
* never by its absolute path, which stays out of the message.
|
|
30
|
+
*/
|
|
31
|
+
export declare const tooBroad: (name?: string) => ApiError;
|
|
28
32
|
/** A device-supplied or person-supplied string inside a message, bounded. */
|
|
29
33
|
export declare function clipped(s: string, max?: number): string;
|
|
30
34
|
export {};
|
|
@@ -9,7 +9,11 @@ export const projectNotFound = (name) => new ApiError("device.project_not_found"
|
|
|
9
9
|
* the resolved path is not one a device can hold.
|
|
10
10
|
*/
|
|
11
11
|
export const outsideMode = (path) => new ApiError("device.project_outside_mode", `${clipped(path)} is outside what the device lets a project reach; pick a directory inside its base`);
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A project directory above the owner's home: named by the project (`name`, when there is one),
|
|
14
|
+
* never by its absolute path, which stays out of the message.
|
|
15
|
+
*/
|
|
16
|
+
export const tooBroad = (name) => new ApiError("device.project_path_too_broad", `${name === undefined ? "This directory" : `The project "${clipped(name)}"`} holds the owner's home directory (or other people's): pick the project's own directory, the home or below it`);
|
|
13
17
|
/** A device-supplied or person-supplied string inside a message, bounded. */
|
|
14
18
|
export function clipped(s, max = 200) {
|
|
15
19
|
return s.length <= max ? s : `${s.slice(0, max)}…`;
|
package/dist/errors.d.ts
CHANGED
|
@@ -381,6 +381,12 @@ export declare const ERROR_CODES: {
|
|
|
381
381
|
readonly "conversation.queue_item_not_found": 404;
|
|
382
382
|
/** A sub-agent's conversation takes no messages from people (sub-agents spec §6.1). */
|
|
383
383
|
readonly "conversation.read_only": 409;
|
|
384
|
+
/**
|
|
385
|
+
* A referenced project file is not there to reference (composer menus §5): the conversation has
|
|
386
|
+
* no device project, the path leaves it, or the device reports no file there;
|
|
387
|
+
* `details: [{ path?, reason? }]`.
|
|
388
|
+
*/
|
|
389
|
+
readonly "conversation.project_file_unavailable": 422;
|
|
384
390
|
readonly "run.not_active": 409;
|
|
385
391
|
/** A run that is not one of the conversation's (the live draft route, spec 2026-11-07 §3.2). */
|
|
386
392
|
readonly "run.not_found": 404;
|
|
@@ -549,6 +555,13 @@ export declare const ERROR_CODES: {
|
|
|
549
555
|
readonly "device.project_path_unreadable": 422;
|
|
550
556
|
/** The device provider refused the project's directory (its reason is the message and details). */
|
|
551
557
|
readonly "device.project_refused": 422;
|
|
558
|
+
/**
|
|
559
|
+
* A path relative to a device project that leaves it (composer menus §5): absolute, `..` above
|
|
560
|
+
* the root, a backslash or a control character; `details: [{ path }]`.
|
|
561
|
+
*/
|
|
562
|
+
readonly "device.path_outside_project": 422;
|
|
563
|
+
/** The device's provider cannot list its directories for its owner (no `list` / owner browse). */
|
|
564
|
+
readonly "device.list_unsupported": 409;
|
|
552
565
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
553
566
|
readonly "device_sign_in.authorization_pending": 400;
|
|
554
567
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -565,28 +578,36 @@ export declare const ERROR_CODES: {
|
|
|
565
578
|
readonly "device.credential_invalid": 401;
|
|
566
579
|
/** A device stream hop from another gateway replica without a valid MAC (or replayed). */
|
|
567
580
|
readonly "device.stream_hop_refused": 401;
|
|
568
|
-
/** The
|
|
569
|
-
readonly "
|
|
581
|
+
/** The automation is missing, deleted, in another org or not the caller's to see. */
|
|
582
|
+
readonly "automation.not_found": 404;
|
|
570
583
|
/** Not a 5-field cron expression (no seconds field). */
|
|
571
|
-
readonly "
|
|
584
|
+
readonly "automation.invalid_cron": 400;
|
|
572
585
|
/** Not an IANA time zone. */
|
|
573
|
-
readonly "
|
|
586
|
+
readonly "automation.invalid_time_zone": 400;
|
|
574
587
|
/** A `once` time that is not a local date-time `YYYY-MM-DDTHH:mm[:ss]`. */
|
|
575
|
-
readonly "
|
|
588
|
+
readonly "automation.invalid_once_time": 400;
|
|
576
589
|
/** A `once` time that is not in the future. */
|
|
577
|
-
readonly "
|
|
590
|
+
readonly "automation.once_in_past": 400;
|
|
578
591
|
/** Two fire times closer than the org's `minIntervalMinutes`. */
|
|
579
|
-
readonly "
|
|
592
|
+
readonly "automation.interval_too_short": 400;
|
|
580
593
|
/** The creator or the org has as many active and paused tasks as the org allows. */
|
|
581
|
-
readonly "
|
|
582
|
-
/** The org turned
|
|
583
|
-
readonly "
|
|
594
|
+
readonly "automation.limit_reached": 409;
|
|
595
|
+
/** The org turned automations off. */
|
|
596
|
+
readonly "automation.disabled": 409;
|
|
584
597
|
/** Where the task runs is inconsistent or not the creator's to use (conversation, chat, device). */
|
|
585
|
-
readonly "
|
|
598
|
+
readonly "automation.target_invalid": 400;
|
|
586
599
|
/** A tool the creator cannot pre-approve for the task (spec §7). */
|
|
587
|
-
readonly "
|
|
600
|
+
readonly "automation.grant_not_allowed": 400;
|
|
601
|
+
/** An event trigger names a source that is not an enabled trigger source of the org. */
|
|
602
|
+
readonly "automation.event_source_unavailable": 400;
|
|
603
|
+
/** An event trigger names an event type its source does not declare (or a directed one). */
|
|
604
|
+
readonly "automation.event_type_unknown": 400;
|
|
605
|
+
/** An event trigger's filter names a missing or unfilterable fact, or mistypes a value. */
|
|
606
|
+
readonly "automation.filter_invalid": 400;
|
|
588
607
|
/** An org admin may pause, resume and delete another person's task, never edit it. */
|
|
589
|
-
readonly "
|
|
608
|
+
readonly "automation.forbidden": 403;
|
|
609
|
+
/** "Run now" and trial runs: an event automation runs only on its events (no run now, no trial). */
|
|
610
|
+
readonly "automation.run_now_unsupported": 409;
|
|
590
611
|
readonly "skill.not_found": 404;
|
|
591
612
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
592
613
|
readonly "skill.file_not_found": 404;
|
package/dist/errors.js
CHANGED
|
@@ -381,6 +381,12 @@ export const ERROR_CODES = {
|
|
|
381
381
|
"conversation.queue_item_not_found": 404,
|
|
382
382
|
/** A sub-agent's conversation takes no messages from people (sub-agents spec §6.1). */
|
|
383
383
|
"conversation.read_only": 409,
|
|
384
|
+
/**
|
|
385
|
+
* A referenced project file is not there to reference (composer menus §5): the conversation has
|
|
386
|
+
* no device project, the path leaves it, or the device reports no file there;
|
|
387
|
+
* `details: [{ path?, reason? }]`.
|
|
388
|
+
*/
|
|
389
|
+
"conversation.project_file_unavailable": 422,
|
|
384
390
|
"run.not_active": 409,
|
|
385
391
|
/** A run that is not one of the conversation's (the live draft route, spec 2026-11-07 §3.2). */
|
|
386
392
|
"run.not_found": 404,
|
|
@@ -549,6 +555,13 @@ export const ERROR_CODES = {
|
|
|
549
555
|
"device.project_path_unreadable": 422,
|
|
550
556
|
/** The device provider refused the project's directory (its reason is the message and details). */
|
|
551
557
|
"device.project_refused": 422,
|
|
558
|
+
/**
|
|
559
|
+
* A path relative to a device project that leaves it (composer menus §5): absolute, `..` above
|
|
560
|
+
* the root, a backslash or a control character; `details: [{ path }]`.
|
|
561
|
+
*/
|
|
562
|
+
"device.path_outside_project": 422,
|
|
563
|
+
/** The device's provider cannot list its directories for its owner (no `list` / owner browse). */
|
|
564
|
+
"device.list_unsupported": 409,
|
|
552
565
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
553
566
|
"device_sign_in.authorization_pending": 400,
|
|
554
567
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -565,28 +578,36 @@ export const ERROR_CODES = {
|
|
|
565
578
|
"device.credential_invalid": 401,
|
|
566
579
|
/** A device stream hop from another gateway replica without a valid MAC (or replayed). */
|
|
567
580
|
"device.stream_hop_refused": 401,
|
|
568
|
-
/** The
|
|
569
|
-
"
|
|
581
|
+
/** The automation is missing, deleted, in another org or not the caller's to see. */
|
|
582
|
+
"automation.not_found": 404,
|
|
570
583
|
/** Not a 5-field cron expression (no seconds field). */
|
|
571
|
-
"
|
|
584
|
+
"automation.invalid_cron": 400,
|
|
572
585
|
/** Not an IANA time zone. */
|
|
573
|
-
"
|
|
586
|
+
"automation.invalid_time_zone": 400,
|
|
574
587
|
/** A `once` time that is not a local date-time `YYYY-MM-DDTHH:mm[:ss]`. */
|
|
575
|
-
"
|
|
588
|
+
"automation.invalid_once_time": 400,
|
|
576
589
|
/** A `once` time that is not in the future. */
|
|
577
|
-
"
|
|
590
|
+
"automation.once_in_past": 400,
|
|
578
591
|
/** Two fire times closer than the org's `minIntervalMinutes`. */
|
|
579
|
-
"
|
|
592
|
+
"automation.interval_too_short": 400,
|
|
580
593
|
/** The creator or the org has as many active and paused tasks as the org allows. */
|
|
581
|
-
"
|
|
582
|
-
/** The org turned
|
|
583
|
-
"
|
|
594
|
+
"automation.limit_reached": 409,
|
|
595
|
+
/** The org turned automations off. */
|
|
596
|
+
"automation.disabled": 409,
|
|
584
597
|
/** Where the task runs is inconsistent or not the creator's to use (conversation, chat, device). */
|
|
585
|
-
"
|
|
598
|
+
"automation.target_invalid": 400,
|
|
586
599
|
/** A tool the creator cannot pre-approve for the task (spec §7). */
|
|
587
|
-
"
|
|
600
|
+
"automation.grant_not_allowed": 400,
|
|
601
|
+
/** An event trigger names a source that is not an enabled trigger source of the org. */
|
|
602
|
+
"automation.event_source_unavailable": 400,
|
|
603
|
+
/** An event trigger names an event type its source does not declare (or a directed one). */
|
|
604
|
+
"automation.event_type_unknown": 400,
|
|
605
|
+
/** An event trigger's filter names a missing or unfilterable fact, or mistypes a value. */
|
|
606
|
+
"automation.filter_invalid": 400,
|
|
588
607
|
/** An org admin may pause, resume and delete another person's task, never edit it. */
|
|
589
|
-
"
|
|
608
|
+
"automation.forbidden": 403,
|
|
609
|
+
/** "Run now" and trial runs: an event automation runs only on its events (no run now, no trial). */
|
|
610
|
+
"automation.run_now_unsupported": 409,
|
|
590
611
|
"skill.not_found": 404,
|
|
591
612
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
592
613
|
"skill.file_not_found": 404,
|
|
@@ -27,7 +27,9 @@ import { type CaseSnapshot } from "./snapshot.js";
|
|
|
27
27
|
* - `context_fit` (context compaction spec §4.9, never for a baseline): the candidate model's window
|
|
28
28
|
* makes the hard fit guard plan a different trim than the recorded `model_call.request.fit` (the
|
|
29
29
|
* recorded plan is replayed for a baseline; a candidate applies its recomputed plan);
|
|
30
|
-
* - `run_outcome_note`: the rebuilt run outcome notes differ from the recorded `runOutcomeSeqs
|
|
30
|
+
* - `run_outcome_note`: the rebuilt run outcome notes differ from the recorded `runOutcomeSeqs`;
|
|
31
|
+
* - `automation_event_block`: the rebuilt event automation blocks differ from the recorded
|
|
32
|
+
* `automationEventSeqs`.
|
|
31
33
|
*/
|
|
32
34
|
/** 还原结果与原请求不一致的原因。 */
|
|
33
35
|
export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing" | "definition_missing"
|
|
@@ -59,6 +61,13 @@ export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing"
|
|
|
59
61
|
* the log alone, so a candidate cannot change them.
|
|
60
62
|
*/
|
|
61
63
|
| "run_outcome_note"
|
|
64
|
+
/**
|
|
65
|
+
* Collaboration spec §4.6: the rebuild renders the event automation block
|
|
66
|
+
* (`automationEventBlock`) for another set of messages than the request recorded in
|
|
67
|
+
* `model_call.request.automationEventSeqs`: a request sent before the block was rendered.
|
|
68
|
+
* Judged for every reconstruction: the block comes from the log alone.
|
|
69
|
+
*/
|
|
70
|
+
| "automation_event_block"
|
|
62
71
|
/** 整轮回放(T5):有工具调用没有匹配到记录(模型收到 REPLAY_NO_RECORDING)。 */
|
|
63
72
|
| "tool_unmatched";
|
|
64
73
|
export interface ReconstructOptions {
|
|
@@ -47,6 +47,7 @@ const DRIFT_ORDER = [
|
|
|
47
47
|
"media_changed",
|
|
48
48
|
"context_fit",
|
|
49
49
|
"run_outcome_note",
|
|
50
|
+
"automation_event_block",
|
|
50
51
|
"tool_unmatched",
|
|
51
52
|
];
|
|
52
53
|
function findCall(events, seq) {
|
|
@@ -283,6 +284,12 @@ export function reconstructFromInputs(s, gathered, opts) {
|
|
|
283
284
|
if (notes.length !== recordedNotes.length || notes.some((x, i) => x !== recordedNotes[i])) {
|
|
284
285
|
drift.add("run_outcome_note");
|
|
285
286
|
}
|
|
287
|
+
// event automation blocks: from the log alone, so only a request sent before they existed differs
|
|
288
|
+
const blocks = meta.automationEventSeqs ?? [];
|
|
289
|
+
const recordedBlocks = rec.automationEventSeqs ?? [];
|
|
290
|
+
if (blocks.length !== recordedBlocks.length || blocks.some((x, i) => x !== recordedBlocks[i])) {
|
|
291
|
+
drift.add("automation_event_block");
|
|
292
|
+
}
|
|
286
293
|
// 媒体:按附件 id 与记录比较
|
|
287
294
|
const recordedMedia = new Map((rec.media ?? []).map((m) => [m.attachmentId, m]));
|
|
288
295
|
for (const m of meta.media ?? []) {
|
|
@@ -2,8 +2,9 @@ import { type DroppedUiContribution, type ExtensionManifest, type ExtensionPoint
|
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
3
|
import type { core } from "zod";
|
|
4
4
|
import type { KernelAppOptions } from "../app.js";
|
|
5
|
+
import { TRIGGER_EVENTS_BACKEND } from "../automations/events/token.js";
|
|
5
6
|
import type { BusSubscriber } from "../ctx/bus.js";
|
|
6
|
-
import { type DeviceAccessBackend, type Route } from "../ctx/create-ctx.js";
|
|
7
|
+
import { type DeviceAccessBackend, type Route, type TriggersBackend } from "../ctx/create-ctx.js";
|
|
7
8
|
import { type ExtensionNetSeams } from "../ctx/net.js";
|
|
8
9
|
import type { Keyring } from "../ctx/secrets.js";
|
|
9
10
|
import { DEVICE_ACCESS_BACKEND } from "../device-access/token.js";
|
|
@@ -288,11 +289,15 @@ export declare class ExtensionHost {
|
|
|
288
289
|
* of use: its module imports the sandbox, devices and tools modules, which import this one (a
|
|
289
290
|
* module cycle otherwise).
|
|
290
291
|
* Absent (a hand-built host) or not found (the CLI): `ctx.deviceAccess` calls are refused.
|
|
292
|
+
* `TriggerEventsService` (`ctx.triggers`, {@link TRIGGER_EVENTS_BACKEND}) likewise.
|
|
291
293
|
*/
|
|
292
294
|
modules?: {
|
|
293
295
|
get(token: typeof DEVICE_ACCESS_BACKEND, opts: {
|
|
294
296
|
strict: false;
|
|
295
297
|
}): DeviceAccessBackend;
|
|
298
|
+
get(token: typeof TRIGGER_EVENTS_BACKEND, opts: {
|
|
299
|
+
strict: false;
|
|
300
|
+
}): TriggersBackend;
|
|
296
301
|
},
|
|
297
302
|
/** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
|
|
298
303
|
netSeams?: ExtensionNetSeams);
|
package/dist/extensions/host.js
CHANGED
|
@@ -14,6 +14,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
14
14
|
import { EXTENSION_POINT_CARDINALITY, parseExtensionPoint, SDK_VERSION, } from "@capybara-hq/plugin-sdk";
|
|
15
15
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
16
16
|
import { ModuleRef } from "@nestjs/core";
|
|
17
|
+
import { TRIGGER_EVENTS_BACKEND } from "../automations/events/token.js";
|
|
17
18
|
import { changedPaths, configFields, secretValues, unreachableSecrets } from "../config/fields.js";
|
|
18
19
|
import { pluginSchemaName, queryEnabledPlugins, } from "../ctx/create-ctx.js";
|
|
19
20
|
import { EXTENSION_NET_SEAMS } from "../ctx/net.js";
|
|
@@ -434,6 +435,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
434
435
|
* of use: its module imports the sandbox, devices and tools modules, which import this one (a
|
|
435
436
|
* module cycle otherwise).
|
|
436
437
|
* Absent (a hand-built host) or not found (the CLI): `ctx.deviceAccess` calls are refused.
|
|
438
|
+
* `TriggerEventsService` (`ctx.triggers`, {@link TRIGGER_EVENTS_BACKEND}) likewise.
|
|
437
439
|
*/
|
|
438
440
|
modules,
|
|
439
441
|
/** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
|
|
@@ -480,6 +482,14 @@ let ExtensionHost = class ExtensionHost {
|
|
|
480
482
|
return undefined;
|
|
481
483
|
}
|
|
482
484
|
},
|
|
485
|
+
triggers: () => {
|
|
486
|
+
try {
|
|
487
|
+
return modules?.get(TRIGGER_EVENTS_BACKEND, { strict: false });
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
return undefined;
|
|
491
|
+
}
|
|
492
|
+
},
|
|
483
493
|
locks,
|
|
484
494
|
runWorkers: c.roles.includes("worker"),
|
|
485
495
|
log,
|
|
@@ -78,6 +78,14 @@ export interface PermissionSet {
|
|
|
78
78
|
deviceAccess?: {
|
|
79
79
|
services: string[];
|
|
80
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* The event types the extension may emit (`permissions.triggers.emit`, collaboration spec
|
|
83
|
+
* §4.2): one blocking key per type, so an upgrade adding a type waits for approval. Absent
|
|
84
|
+
* when not declared.
|
|
85
|
+
*/
|
|
86
|
+
triggers?: {
|
|
87
|
+
emit: string[];
|
|
88
|
+
};
|
|
81
89
|
};
|
|
82
90
|
/**
|
|
83
91
|
* 安装记录包迁移警告的摘要(`warningsDigest`,Ruling P4);没有警告或不是安装记录时省略。
|
|
@@ -125,7 +133,8 @@ export declare function buildPermissionSet(input: {
|
|
|
125
133
|
* `config.deployment.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
126
134
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
127
135
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
128
|
-
* `permissions.dialin:capybara-device/6`, `permissions.deviceaccess:browser
|
|
136
|
+
* `permissions.dialin:capybara-device/6`, `permissions.deviceaccess:browser`,
|
|
137
|
+
* `permissions.triggers:item.created`.
|
|
129
138
|
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
130
139
|
*/
|
|
131
140
|
export declare function permissionKeys(set: PermissionSet): string[];
|
|
@@ -150,6 +159,13 @@ export declare const DIAL_IN_KEY_PREFIX = "permissions.dialin:";
|
|
|
150
159
|
* catalog permission keys require (`PERMISSION_KEY_RE`).
|
|
151
160
|
*/
|
|
152
161
|
export declare const DEVICE_ACCESS_KEY_PREFIX = "permissions.deviceaccess:";
|
|
162
|
+
/**
|
|
163
|
+
* Key prefix of an event type the extension emits (`permissions.triggers.emit`): blocking, not
|
|
164
|
+
* sensitive (an event only reaches automations an org built on it, collaboration spec §4.2).
|
|
165
|
+
* Lower-case letters and dots before the colon, as catalog permission keys require
|
|
166
|
+
* (`PERMISSION_KEY_RE`).
|
|
167
|
+
*/
|
|
168
|
+
export declare const TRIGGERS_KEY_PREFIX = "permissions.triggers:";
|
|
153
169
|
/** Key prefix of a client component (`ui.component:<id>`): sensitive and blocking. */
|
|
154
170
|
export declare const UI_COMPONENT_KEY_PREFIX = "ui.component:";
|
|
155
171
|
/** 渲染 schema 视图的权限键前缀:记入快照但不卡加载(见 {@link blockingKeys})。 */
|
|
@@ -121,6 +121,8 @@ export function buildPermissionSet(input) {
|
|
|
121
121
|
...(p.deviceAccess
|
|
122
122
|
? { deviceAccess: { services: sortedUnique(p.deviceAccess.services) } }
|
|
123
123
|
: {}),
|
|
124
|
+
// only when declared, likewise
|
|
125
|
+
...(p.triggers ? { triggers: { emit: sortedUnique(p.triggers.emit) } } : {}),
|
|
124
126
|
},
|
|
125
127
|
...(input.warningsDigest ? { warningsDigest: input.warningsDigest } : {}),
|
|
126
128
|
};
|
|
@@ -130,7 +132,8 @@ export function buildPermissionSet(input) {
|
|
|
130
132
|
* `config.deployment.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
131
133
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
132
134
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
133
|
-
* `permissions.dialin:capybara-device/6`, `permissions.deviceaccess:browser
|
|
135
|
+
* `permissions.dialin:capybara-device/6`, `permissions.deviceaccess:browser`,
|
|
136
|
+
* `permissions.triggers:item.created`.
|
|
134
137
|
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
135
138
|
*/
|
|
136
139
|
export function permissionKeys(set) {
|
|
@@ -181,6 +184,8 @@ export function permissionKeys(set) {
|
|
|
181
184
|
keys.push(`${DIAL_IN_KEY_PREFIX}${p.dialIn.protocol}`);
|
|
182
185
|
for (const svc of p.deviceAccess?.services ?? [])
|
|
183
186
|
keys.push(`${DEVICE_ACCESS_KEY_PREFIX}${svc}`);
|
|
187
|
+
for (const t of p.triggers?.emit ?? [])
|
|
188
|
+
keys.push(`${TRIGGERS_KEY_PREFIX}${t}`);
|
|
184
189
|
if (s.warningsDigest)
|
|
185
190
|
keys.push(`${WARNINGS_KEY_PREFIX}${s.warningsDigest}`);
|
|
186
191
|
return sortedUnique(keys);
|
|
@@ -206,6 +211,13 @@ export const DIAL_IN_KEY_PREFIX = "permissions.dialin:";
|
|
|
206
211
|
* catalog permission keys require (`PERMISSION_KEY_RE`).
|
|
207
212
|
*/
|
|
208
213
|
export const DEVICE_ACCESS_KEY_PREFIX = "permissions.deviceaccess:";
|
|
214
|
+
/**
|
|
215
|
+
* Key prefix of an event type the extension emits (`permissions.triggers.emit`): blocking, not
|
|
216
|
+
* sensitive (an event only reaches automations an org built on it, collaboration spec §4.2).
|
|
217
|
+
* Lower-case letters and dots before the colon, as catalog permission keys require
|
|
218
|
+
* (`PERMISSION_KEY_RE`).
|
|
219
|
+
*/
|
|
220
|
+
export const TRIGGERS_KEY_PREFIX = "permissions.triggers:";
|
|
209
221
|
/** Key prefix of a client component (`ui.component:<id>`): sensitive and blocking. */
|
|
210
222
|
export const UI_COMPONENT_KEY_PREFIX = "ui.component:";
|
|
211
223
|
/** 渲染 schema 视图的权限键前缀:记入快照但不卡加载(见 {@link blockingKeys})。 */
|
|
@@ -13,7 +13,7 @@ import type { ExtensionSource } from "./sources.js";
|
|
|
13
13
|
export declare function reviewHash(set: PermissionSet, warnings?: readonly PackageWarning[]): string;
|
|
14
14
|
/** 权限清单展示用的一组:按类别分组,`sensitive` 标出需要管理员特别留意的类别。 */
|
|
15
15
|
export interface PermissionGroup {
|
|
16
|
-
category: "provides" | "requires" | "optional" | "config" | "tables" | "secrets" | "storage" | "http" | "publicRoutes" | "embedRoutes" | "tools" | "hooks" | "models" | "network" | "ui" | "components" | "client" | "dialIn" | "deviceAccess";
|
|
16
|
+
category: "provides" | "requires" | "optional" | "config" | "tables" | "secrets" | "storage" | "http" | "publicRoutes" | "embedRoutes" | "tools" | "hooks" | "models" | "network" | "ui" | "components" | "client" | "dialIn" | "deviceAccess" | "triggers";
|
|
17
17
|
/**
|
|
18
18
|
* Sensitive category: secrets, public routes, tools, hooks, client components, client code,
|
|
19
19
|
* device services; also
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { pluginSchemaName } from "../ctx/create-ctx.js";
|
|
3
3
|
import { isDestructiveSql, splitSqlStatements } from "../db/sql-statements.js";
|
|
4
|
-
import { CLIENT_KEY, DEVICE_ACCESS_KEY_PREFIX, DIAL_IN_KEY_PREFIX, permissionKeys, UI_COMPONENT_KEY_PREFIX, WARNINGS_KEY_PREFIX, } from "./permission-set.js";
|
|
4
|
+
import { CLIENT_KEY, DEVICE_ACCESS_KEY_PREFIX, DIAL_IN_KEY_PREFIX, permissionKeys, TRIGGERS_KEY_PREFIX, UI_COMPONENT_KEY_PREFIX, WARNINGS_KEY_PREFIX, } from "./permission-set.js";
|
|
5
5
|
/**
|
|
6
6
|
* Review digest: the first 16 hex digits of `sha256(permissionKeys(set).join("\n"))`; with migration
|
|
7
7
|
* warnings their digest (kind, file, line and statement) is folded in, without warnings it equals the
|
|
@@ -109,6 +109,7 @@ function keyItem(key) {
|
|
|
109
109
|
["ui.view:", "ui", "view:"],
|
|
110
110
|
[DIAL_IN_KEY_PREFIX, "dialIn", ""],
|
|
111
111
|
[DEVICE_ACCESS_KEY_PREFIX, "deviceAccess", ""],
|
|
112
|
+
[TRIGGERS_KEY_PREFIX, "triggers", ""],
|
|
112
113
|
];
|
|
113
114
|
for (const [prefix, category, itemPrefix] of table) {
|
|
114
115
|
const rest = after(prefix);
|
|
@@ -188,6 +189,8 @@ export function permissionGroups(set) {
|
|
|
188
189
|
{ category: "dialIn", items: p.dialIn ? [p.dialIn.protocol] : [] },
|
|
189
190
|
// long-lived services the extension runs in conversations' devices
|
|
190
191
|
{ category: "deviceAccess", items: p.deviceAccess?.services ?? [] },
|
|
192
|
+
// the event types it emits for the orgs' event automations (not sensitive)
|
|
193
|
+
{ category: "triggers", items: p.triggers?.emit ?? [] },
|
|
191
194
|
];
|
|
192
195
|
return groups
|
|
193
196
|
.filter((g) => g.items.length > 0)
|
package/dist/git/gateway.js
CHANGED
|
@@ -10,6 +10,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Readable, Transform } from "node:stream";
|
|
11
11
|
import { pipeline } from "node:stream/promises";
|
|
12
12
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
13
|
+
import { normalizeGitRepo } from "../automations/grant-rules.js";
|
|
14
|
+
import { appendMissingGrant } from "../automations/unattended.js";
|
|
13
15
|
import { productName } from "../config/product-name.js";
|
|
14
16
|
import { audit } from "../identity/audit.js";
|
|
15
17
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -17,8 +19,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
17
19
|
import { KERNEL_LOGGER, REDIS } from "../infra/tokens.js";
|
|
18
20
|
import { NetDeniedError } from "../net/public-address.js";
|
|
19
21
|
import { safeFetch } from "../net/safe-fetch.js";
|
|
20
|
-
import { normalizeGitRepo } from "../schedules/grant-rules.js";
|
|
21
|
-
import { appendMissingGrant } from "../schedules/unattended.js";
|
|
22
22
|
import { CredentialMissing, Credentials } from "../tools/credentials.js";
|
|
23
23
|
import { gitAskedNote, gitNotConnectedNote, gitPolicyDeniedNote, gitUnattendedNote, recordGitAsk, } from "../tools/git-asks.js";
|
|
24
24
|
import { decideGitPush } from "../tools/git-push-policy.js";
|
package/dist/http/api.module.js
CHANGED
|
@@ -23,6 +23,8 @@ import { ModelsController } from "../agents/models.controller.js";
|
|
|
23
23
|
import { PendingConnectorsController } from "../agents/pending-connectors.controller.js";
|
|
24
24
|
import { ReadinessController } from "../agents/readiness.controller.js";
|
|
25
25
|
import { AgentSaveAsTemplateController, AgentTemplatesController, } from "../agents/templates.controller.js";
|
|
26
|
+
import { AutomationsController } from "../automations/automations.controller.js";
|
|
27
|
+
import { AutomationsModule } from "../automations/automations.module.js";
|
|
26
28
|
import { BackgroundController } from "../background/background.controller.js";
|
|
27
29
|
import { BackgroundModule } from "../background/background.module.js";
|
|
28
30
|
import { AdminCatalogController } from "../catalog/admin-catalog.controller.js";
|
|
@@ -86,8 +88,6 @@ import { PushController } from "../push/push.controller.js";
|
|
|
86
88
|
import { PushModule } from "../push/push.module.js";
|
|
87
89
|
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
88
90
|
import { ConversationStreamController } from "../runtime/stream.controller.js";
|
|
89
|
-
import { SchedulesController } from "../schedules/schedules.controller.js";
|
|
90
|
-
import { SchedulesModule } from "../schedules/schedules.module.js";
|
|
91
91
|
import { SetupModule } from "../setup/setup.module.js";
|
|
92
92
|
import { SetupChecksController } from "../setup/setup-checks.controller.js";
|
|
93
93
|
import { SetupGuidesController } from "../setup/setup-guides.controller.js";
|
|
@@ -161,7 +161,7 @@ const CONTROLLERS = [
|
|
|
161
161
|
PermissionProfilesController,
|
|
162
162
|
BackgroundController,
|
|
163
163
|
DevicesController,
|
|
164
|
-
|
|
164
|
+
AutomationsController,
|
|
165
165
|
AttachmentsController,
|
|
166
166
|
SkillsController,
|
|
167
167
|
SkillChangesController,
|
|
@@ -258,8 +258,8 @@ ApiModule = __decorate([
|
|
|
258
258
|
ThemesModule,
|
|
259
259
|
ClientModule,
|
|
260
260
|
SetupModule,
|
|
261
|
-
//
|
|
262
|
-
|
|
261
|
+
// automations (the controller comes with the HTTP routes)
|
|
262
|
+
AutomationsModule,
|
|
263
263
|
// the git gateway (run tickets; the gateway route comes with it)
|
|
264
264
|
GitModule,
|
|
265
265
|
// file sharing (shares of conversation files)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FastifyReply } from "fastify";
|
|
2
|
+
/**
|
|
3
|
+
* An `AbortSignal` tied to one HTTP request: aborted when the connection closes before the
|
|
4
|
+
* response is written (the client hung up), never by a close after a finished response. The same
|
|
5
|
+
* rule as the plugin routes' `req.signal` and the channel webhooks. For a route whose handler asks
|
|
6
|
+
* a device (or another remote) on the request's behalf, so the call stops when nobody waits.
|
|
7
|
+
*/
|
|
8
|
+
export declare function requestSignal(reply: FastifyReply): AbortSignal;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An `AbortSignal` tied to one HTTP request: aborted when the connection closes before the
|
|
3
|
+
* response is written (the client hung up), never by a close after a finished response. The same
|
|
4
|
+
* rule as the plugin routes' `req.signal` and the channel webhooks. For a route whose handler asks
|
|
5
|
+
* a device (or another remote) on the request's behalf, so the call stops when nobody waits.
|
|
6
|
+
*/
|
|
7
|
+
export function requestSignal(reply) {
|
|
8
|
+
const ac = new AbortController();
|
|
9
|
+
reply.raw.once("close", () => {
|
|
10
|
+
if (!reply.raw.writableFinished)
|
|
11
|
+
ac.abort();
|
|
12
|
+
});
|
|
13
|
+
return ac.signal;
|
|
14
|
+
}
|
|
@@ -5,8 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
|
+
import { AutomationsModule } from "../automations/automations.module.js";
|
|
8
9
|
import { CatalogModule } from "../catalog/catalog.module.js";
|
|
9
|
-
import { SchedulesModule } from "../schedules/schedules.module.js";
|
|
10
10
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
11
11
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
12
12
|
import { InboxService } from "./inbox.service.js";
|
|
@@ -19,7 +19,7 @@ let InboxModule = class InboxModule {
|
|
|
19
19
|
};
|
|
20
20
|
InboxModule = __decorate([
|
|
21
21
|
Module({
|
|
22
|
-
imports: [ToolsModule, SkillsModule, CatalogModule,
|
|
22
|
+
imports: [ToolsModule, SkillsModule, CatalogModule, AutomationsModule],
|
|
23
23
|
providers: [InboxService, PlatformInboxService],
|
|
24
24
|
exports: [InboxService, PlatformInboxService],
|
|
25
25
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type AutomationAttention, AutomationsService } from "../automations/automations.service.js";
|
|
1
2
|
import { CatalogRequestsService, type CatalogRequestView } from "../catalog/requests.service.js";
|
|
2
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
-
import { type ScheduleAttention, ScheduledTasksService } from "../schedules/scheduled-tasks.service.js";
|
|
4
4
|
import { SkillChangesService, type SkillChangeView } from "../skills/changes.service.js";
|
|
5
5
|
import { ApprovalsService, type ApprovalView } from "../tools/approvals.service.js";
|
|
6
6
|
import type { OrgNoticeDetails } from "./org-notices.js";
|
|
@@ -34,7 +34,7 @@ export declare const INBOX_MAX_ITEMS = 100;
|
|
|
34
34
|
* (M6 T26, C22; plugin scope spec §5.1);
|
|
35
35
|
* - `catalog_request_decided`: the current user's own requests in this org that were approved or
|
|
36
36
|
* rejected (with the reason), until dismissed (`POST catalog-requests/:id/dismiss`);
|
|
37
|
-
* - `
|
|
37
|
+
* - `automation_attention`: the current user's own automation that needs them (spec §8): paused
|
|
38
38
|
* for any reason but their own pause, its latest run failed, or its latest run was refused tools
|
|
39
39
|
* or connections; derived live, gone once the task is resumed or runs clean;
|
|
40
40
|
* - the org notices (`item_shared`, `shared_item_updated`, `upload_confirmed`,
|
|
@@ -63,19 +63,19 @@ export type InboxItem = {
|
|
|
63
63
|
createdAt: string;
|
|
64
64
|
request: CatalogRequestView;
|
|
65
65
|
} | {
|
|
66
|
-
type: "
|
|
66
|
+
type: "automation_attention";
|
|
67
67
|
/** `<taskId>:paused`, `<taskId>:failed` or `<taskId>:grants`. */
|
|
68
68
|
id: string;
|
|
69
69
|
createdAt: string;
|
|
70
|
-
attention:
|
|
70
|
+
attention: AutomationAttentionView;
|
|
71
71
|
} | {
|
|
72
72
|
type: OrgNoticeView["kind"];
|
|
73
73
|
id: string;
|
|
74
74
|
createdAt: string;
|
|
75
75
|
notice: OrgNoticeView;
|
|
76
76
|
};
|
|
77
|
-
/**
|
|
78
|
-
export type
|
|
77
|
+
/** An automation that needs its creator ({@link AutomationAttention}, dates as ISO strings). */
|
|
78
|
+
export type AutomationAttentionView = Omit<AutomationAttention, "at">;
|
|
79
79
|
/** `GET /inbox` 的结果:新的在前,最多 {@link INBOX_MAX_ITEMS} 项;`truncated` 为 true 表示还有更多。 */
|
|
80
80
|
export interface InboxView {
|
|
81
81
|
items: InboxItem[];
|
|
@@ -87,8 +87,8 @@ export declare class InboxService {
|
|
|
87
87
|
private readonly skillChanges;
|
|
88
88
|
private readonly kdb;
|
|
89
89
|
private readonly catalogRequests;
|
|
90
|
-
private readonly
|
|
91
|
-
constructor(approvals: Pick<ApprovalsService, "list">, skillChanges: Pick<SkillChangesService, "listPending">, kdb: KernelDb, catalogRequests: Pick<CatalogRequestsService, "listForOrgAdmin" | "listDecidedForRequester">,
|
|
90
|
+
private readonly automations;
|
|
91
|
+
constructor(approvals: Pick<ApprovalsService, "list">, skillChanges: Pick<SkillChangesService, "listPending">, kdb: KernelDb, catalogRequests: Pick<CatalogRequestsService, "listForOrgAdmin" | "listDecidedForRequester">, automations: Pick<AutomationsService, "attentionFor">);
|
|
92
92
|
list(orgId: string, accountId: string): Promise<InboxView>;
|
|
93
93
|
/** The org's open notices when the account is an org admin (else none), newest first. */
|
|
94
94
|
private notices;
|