@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
package/dist/devices/dto.d.ts
CHANGED
|
@@ -65,6 +65,15 @@ export declare const DeviceProjectParams: z.ZodObject<{
|
|
|
65
65
|
id: z.ZodString;
|
|
66
66
|
name: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
67
67
|
}, z.core.$strip>;
|
|
68
|
+
/**
|
|
69
|
+
* `GET /devices/:id/projects/:name/files` (composer menus §5): `path` is the directory to list,
|
|
70
|
+
* relative to the project root (absent or empty: the root; the service normalizes it and refuses
|
|
71
|
+
* one that leaves the project, `device.path_outside_project`); `q` filters the names in it.
|
|
72
|
+
*/
|
|
73
|
+
export declare const DeviceProjectFilesQuery: z.ZodObject<{
|
|
74
|
+
path: z.ZodOptional<z.ZodString>;
|
|
75
|
+
q: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>;
|
|
68
77
|
declare const DeviceCreateBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
69
78
|
name: z.ZodString;
|
|
70
79
|
provider: z.ZodOptional<z.ZodString>;
|
|
@@ -101,4 +110,10 @@ declare const DeviceProjectParamsDto_base: import("../infra/validation/create-zo
|
|
|
101
110
|
}, z.core.$strip>>;
|
|
102
111
|
export declare class DeviceProjectParamsDto extends DeviceProjectParamsDto_base {
|
|
103
112
|
}
|
|
113
|
+
declare const DeviceProjectFilesQueryDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
114
|
+
path: z.ZodOptional<z.ZodString>;
|
|
115
|
+
q: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
export declare class DeviceProjectFilesQueryDto extends DeviceProjectFilesQueryDto_base {
|
|
118
|
+
}
|
|
104
119
|
export {};
|
package/dist/devices/dto.js
CHANGED
|
@@ -89,6 +89,15 @@ export const DeviceProjectAddBody = z
|
|
|
89
89
|
.strict();
|
|
90
90
|
/** `DELETE /devices/:id/projects/:name`. */
|
|
91
91
|
export const DeviceProjectParams = DeviceParams.extend({ name: DeviceProjectName });
|
|
92
|
+
/**
|
|
93
|
+
* `GET /devices/:id/projects/:name/files` (composer menus §5): `path` is the directory to list,
|
|
94
|
+
* relative to the project root (absent or empty: the root; the service normalizes it and refuses
|
|
95
|
+
* one that leaves the project, `device.path_outside_project`); `q` filters the names in it.
|
|
96
|
+
*/
|
|
97
|
+
export const DeviceProjectFilesQuery = z.object({
|
|
98
|
+
path: z.string().max(4096).optional(),
|
|
99
|
+
q: z.string().max(200).optional(),
|
|
100
|
+
});
|
|
92
101
|
export class DeviceCreateBodyDto extends createZodDto(DeviceCreateBody, "DeviceCreateBody") {
|
|
93
102
|
}
|
|
94
103
|
export class DevicePatchBodyDto extends createZodDto(DevicePatchBody, "DevicePatchBody") {
|
|
@@ -99,3 +108,5 @@ export class DeviceProjectAddBodyDto extends createZodDto(DeviceProjectAddBody,
|
|
|
99
108
|
}
|
|
100
109
|
export class DeviceProjectParamsDto extends createZodDto(DeviceProjectParams, "DeviceProjectParams") {
|
|
101
110
|
}
|
|
111
|
+
export class DeviceProjectFilesQueryDto extends createZodDto(DeviceProjectFilesQuery, "DeviceProjectFilesQuery") {
|
|
112
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApiError } from "../errors.js";
|
|
2
|
+
/** The longest path relative to a project the kernel takes (the add route's bound). */
|
|
3
|
+
export declare const MAX_PROJECT_RELATIVE_PATH = 4096;
|
|
4
|
+
/**
|
|
5
|
+
* A path relative to a device project (composer menus §5) that is refused: absolute, escaping the
|
|
6
|
+
* project root with `..`, holding a backslash or a control character, or too long. 422
|
|
7
|
+
* `device.path_outside_project` with the path (clipped) in `details`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const pathOutsideProject: (rel: string) => ApiError;
|
|
10
|
+
/**
|
|
11
|
+
* `rel` normalized as a posix path relative to a project's root: `""` for the root itself, no
|
|
12
|
+
* `.` segments, no doubled or trailing `/`, `..` resolved. Refused ({@link pathOutsideProject})
|
|
13
|
+
* when it is absolute, climbs above the root, holds a backslash or a control character (NUL
|
|
14
|
+
* included), or is longer than {@link MAX_PROJECT_RELATIVE_PATH}. Pure string work: the device
|
|
15
|
+
* is never asked, so a symlink below the root is the provider's and its browse scope's to judge.
|
|
16
|
+
*/
|
|
17
|
+
export declare function projectRelativePath(rel: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* The absolute device path of `rel` (normalized through {@link projectRelativePath}, so refused
|
|
20
|
+
* the same way) inside the project rooted at `projectPath`, which must itself be absolute and
|
|
21
|
+
* normalized (no `.` / `..` segments, no doubled or trailing `/`): an internal error otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export declare function joinProjectPath(projectPath: string, rel: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* {@link projectRelativePath} for a path that must name a file below the root: one that
|
|
26
|
+
* normalizes to the root itself (`"."`, `"./"`, `"a/.."`) is refused with
|
|
27
|
+
* `device.path_outside_project` as well, its path in `details` as given (none when empty).
|
|
28
|
+
*/
|
|
29
|
+
export declare function projectFilePath(rel: string): string;
|
|
@@ -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
|
@@ -38,6 +38,19 @@ export declare const ERROR_CODES: {
|
|
|
38
38
|
readonly "app_auth.code_invalid": 400;
|
|
39
39
|
/** Native-app sign-in needs `http.publicUrl` (the issuer the app checks). */
|
|
40
40
|
readonly "app_auth.unavailable": 503;
|
|
41
|
+
/**
|
|
42
|
+
* A browser handoff start names a return scheme whose `<scheme>://auth/callback` is not in
|
|
43
|
+
* `auth.appRedirectUris` (exact match), or `http.publicUrl` is not set.
|
|
44
|
+
*/
|
|
45
|
+
readonly "handoff.scheme_not_allowed": 400;
|
|
46
|
+
/** The browser handoff ticket is unknown, expired or already used; start again in the app. */
|
|
47
|
+
readonly "handoff.invalid": 410;
|
|
48
|
+
/**
|
|
49
|
+
* The browser is signed in as another account than the one that started the handoff (the
|
|
50
|
+
* ticket is spent); details `[{ login, displayName, email }]` of the ticket's account (`login`
|
|
51
|
+
* its local login, null without one; `email` null when unset).
|
|
52
|
+
*/
|
|
53
|
+
readonly "handoff.account_mismatch": 403;
|
|
41
54
|
readonly "token.not_found": 404;
|
|
42
55
|
readonly "org.not_found": 404;
|
|
43
56
|
readonly "org.creation_disabled": 403;
|
|
@@ -368,6 +381,12 @@ export declare const ERROR_CODES: {
|
|
|
368
381
|
readonly "conversation.queue_item_not_found": 404;
|
|
369
382
|
/** A sub-agent's conversation takes no messages from people (sub-agents spec §6.1). */
|
|
370
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;
|
|
371
390
|
readonly "run.not_active": 409;
|
|
372
391
|
/** A run that is not one of the conversation's (the live draft route, spec 2026-11-07 §3.2). */
|
|
373
392
|
readonly "run.not_found": 404;
|
|
@@ -536,6 +555,13 @@ export declare const ERROR_CODES: {
|
|
|
536
555
|
readonly "device.project_path_unreadable": 422;
|
|
537
556
|
/** The device provider refused the project's directory (its reason is the message and details). */
|
|
538
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;
|
|
539
565
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
540
566
|
readonly "device_sign_in.authorization_pending": 400;
|
|
541
567
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -552,28 +578,36 @@ export declare const ERROR_CODES: {
|
|
|
552
578
|
readonly "device.credential_invalid": 401;
|
|
553
579
|
/** A device stream hop from another gateway replica without a valid MAC (or replayed). */
|
|
554
580
|
readonly "device.stream_hop_refused": 401;
|
|
555
|
-
/** The
|
|
556
|
-
readonly "
|
|
581
|
+
/** The automation is missing, deleted, in another org or not the caller's to see. */
|
|
582
|
+
readonly "automation.not_found": 404;
|
|
557
583
|
/** Not a 5-field cron expression (no seconds field). */
|
|
558
|
-
readonly "
|
|
584
|
+
readonly "automation.invalid_cron": 400;
|
|
559
585
|
/** Not an IANA time zone. */
|
|
560
|
-
readonly "
|
|
586
|
+
readonly "automation.invalid_time_zone": 400;
|
|
561
587
|
/** A `once` time that is not a local date-time `YYYY-MM-DDTHH:mm[:ss]`. */
|
|
562
|
-
readonly "
|
|
588
|
+
readonly "automation.invalid_once_time": 400;
|
|
563
589
|
/** A `once` time that is not in the future. */
|
|
564
|
-
readonly "
|
|
590
|
+
readonly "automation.once_in_past": 400;
|
|
565
591
|
/** Two fire times closer than the org's `minIntervalMinutes`. */
|
|
566
|
-
readonly "
|
|
592
|
+
readonly "automation.interval_too_short": 400;
|
|
567
593
|
/** The creator or the org has as many active and paused tasks as the org allows. */
|
|
568
|
-
readonly "
|
|
569
|
-
/** The org turned
|
|
570
|
-
readonly "
|
|
594
|
+
readonly "automation.limit_reached": 409;
|
|
595
|
+
/** The org turned automations off. */
|
|
596
|
+
readonly "automation.disabled": 409;
|
|
571
597
|
/** Where the task runs is inconsistent or not the creator's to use (conversation, chat, device). */
|
|
572
|
-
readonly "
|
|
598
|
+
readonly "automation.target_invalid": 400;
|
|
573
599
|
/** A tool the creator cannot pre-approve for the task (spec §7). */
|
|
574
|
-
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;
|
|
575
607
|
/** An org admin may pause, resume and delete another person's task, never edit it. */
|
|
576
|
-
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;
|
|
577
611
|
readonly "skill.not_found": 404;
|
|
578
612
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
579
613
|
readonly "skill.file_not_found": 404;
|
package/dist/errors.js
CHANGED
|
@@ -38,6 +38,19 @@ export const ERROR_CODES = {
|
|
|
38
38
|
"app_auth.code_invalid": 400,
|
|
39
39
|
/** Native-app sign-in needs `http.publicUrl` (the issuer the app checks). */
|
|
40
40
|
"app_auth.unavailable": 503,
|
|
41
|
+
/**
|
|
42
|
+
* A browser handoff start names a return scheme whose `<scheme>://auth/callback` is not in
|
|
43
|
+
* `auth.appRedirectUris` (exact match), or `http.publicUrl` is not set.
|
|
44
|
+
*/
|
|
45
|
+
"handoff.scheme_not_allowed": 400,
|
|
46
|
+
/** The browser handoff ticket is unknown, expired or already used; start again in the app. */
|
|
47
|
+
"handoff.invalid": 410,
|
|
48
|
+
/**
|
|
49
|
+
* The browser is signed in as another account than the one that started the handoff (the
|
|
50
|
+
* ticket is spent); details `[{ login, displayName, email }]` of the ticket's account (`login`
|
|
51
|
+
* its local login, null without one; `email` null when unset).
|
|
52
|
+
*/
|
|
53
|
+
"handoff.account_mismatch": 403,
|
|
41
54
|
"token.not_found": 404,
|
|
42
55
|
"org.not_found": 404,
|
|
43
56
|
"org.creation_disabled": 403,
|
|
@@ -368,6 +381,12 @@ export const ERROR_CODES = {
|
|
|
368
381
|
"conversation.queue_item_not_found": 404,
|
|
369
382
|
/** A sub-agent's conversation takes no messages from people (sub-agents spec §6.1). */
|
|
370
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,
|
|
371
390
|
"run.not_active": 409,
|
|
372
391
|
/** A run that is not one of the conversation's (the live draft route, spec 2026-11-07 §3.2). */
|
|
373
392
|
"run.not_found": 404,
|
|
@@ -536,6 +555,13 @@ export const ERROR_CODES = {
|
|
|
536
555
|
"device.project_path_unreadable": 422,
|
|
537
556
|
/** The device provider refused the project's directory (its reason is the message and details). */
|
|
538
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,
|
|
539
565
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
540
566
|
"device_sign_in.authorization_pending": 400,
|
|
541
567
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -552,28 +578,36 @@ export const ERROR_CODES = {
|
|
|
552
578
|
"device.credential_invalid": 401,
|
|
553
579
|
/** A device stream hop from another gateway replica without a valid MAC (or replayed). */
|
|
554
580
|
"device.stream_hop_refused": 401,
|
|
555
|
-
/** The
|
|
556
|
-
"
|
|
581
|
+
/** The automation is missing, deleted, in another org or not the caller's to see. */
|
|
582
|
+
"automation.not_found": 404,
|
|
557
583
|
/** Not a 5-field cron expression (no seconds field). */
|
|
558
|
-
"
|
|
584
|
+
"automation.invalid_cron": 400,
|
|
559
585
|
/** Not an IANA time zone. */
|
|
560
|
-
"
|
|
586
|
+
"automation.invalid_time_zone": 400,
|
|
561
587
|
/** A `once` time that is not a local date-time `YYYY-MM-DDTHH:mm[:ss]`. */
|
|
562
|
-
"
|
|
588
|
+
"automation.invalid_once_time": 400,
|
|
563
589
|
/** A `once` time that is not in the future. */
|
|
564
|
-
"
|
|
590
|
+
"automation.once_in_past": 400,
|
|
565
591
|
/** Two fire times closer than the org's `minIntervalMinutes`. */
|
|
566
|
-
"
|
|
592
|
+
"automation.interval_too_short": 400,
|
|
567
593
|
/** The creator or the org has as many active and paused tasks as the org allows. */
|
|
568
|
-
"
|
|
569
|
-
/** The org turned
|
|
570
|
-
"
|
|
594
|
+
"automation.limit_reached": 409,
|
|
595
|
+
/** The org turned automations off. */
|
|
596
|
+
"automation.disabled": 409,
|
|
571
597
|
/** Where the task runs is inconsistent or not the creator's to use (conversation, chat, device). */
|
|
572
|
-
"
|
|
598
|
+
"automation.target_invalid": 400,
|
|
573
599
|
/** A tool the creator cannot pre-approve for the task (spec §7). */
|
|
574
|
-
"
|
|
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,
|
|
575
607
|
/** An org admin may pause, resume and delete another person's task, never edit it. */
|
|
576
|
-
"
|
|
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,
|
|
577
611
|
"skill.not_found": 404,
|
|
578
612
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
579
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";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A plain URL scheme (RFC 3986 letters, lowercase only so the match stays exact). */
|
|
3
|
+
export declare const APP_SCHEME_RE: RegExp;
|
|
4
|
+
/** The config a scheme decision reads (`KernelConfig` fits). */
|
|
5
|
+
export type AppSchemesConfig = {
|
|
6
|
+
http: {
|
|
7
|
+
publicUrl?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
auth: {
|
|
10
|
+
appRedirectUris: readonly string[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The schemes `s` for which an entry of `auth.appRedirectUris` is exactly `${s}://auth/callback`,
|
|
15
|
+
* in list order; `[]` without `http.publicUrl` (no app sign-in, so no shell to return to).
|
|
16
|
+
*/
|
|
17
|
+
export declare function appSchemes(config: AppSchemesConfig): string[];
|
|
18
|
+
/** A handoff start's return scheme: none passes; otherwise it must be one of {@link appSchemes}. */
|
|
19
|
+
export declare function assertReturnSchemeAllowed(config: AppSchemesConfig, scheme: string | undefined): void;
|
|
20
|
+
/**
|
|
21
|
+
* The `handoff` field of the connector connect and the login-method link start: present when a
|
|
22
|
+
* native shell asks to finish the flow in the system browser. `returnScheme` is the shell's own
|
|
23
|
+
* URL scheme (for the done page's way back into the app).
|
|
24
|
+
*/
|
|
25
|
+
export declare const HandoffRequestSchema: z.ZodObject<{
|
|
26
|
+
returnScheme: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
export type HandoffRequest = z.infer<typeof HandoffRequestSchema>;
|