@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
|
@@ -9,9 +9,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
|
+
import { DeviceProjectFilesService } from "../../devices/device-project-files.service.js";
|
|
12
13
|
import { DeviceProjectsService } from "../../devices/device-projects.service.js";
|
|
13
14
|
import { DevicesService } from "../../devices/devices.service.js";
|
|
14
|
-
import { DeviceCreateBody, DeviceNameBody, DeviceNetworkBody, DeviceParams, DeviceProjectAddBody, DeviceProjectParams, } from "../../devices/dto.js";
|
|
15
|
+
import { DeviceCreateBody, DeviceNameBody, DeviceNetworkBody, DeviceParams, DeviceProjectAddBody, DeviceProjectFilesQuery, DeviceProjectParams, } from "../../devices/dto.js";
|
|
15
16
|
import { deviceLabel } from "../../devices/label.js";
|
|
16
17
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
17
18
|
import { rootConversationOf } from "../../runtime/subagents/child.js";
|
|
@@ -74,11 +75,13 @@ let DevicesOperations = class DevicesOperations {
|
|
|
74
75
|
registry;
|
|
75
76
|
devices;
|
|
76
77
|
projects;
|
|
78
|
+
projectFiles;
|
|
77
79
|
kdb;
|
|
78
|
-
constructor(registry, devices, projects, kdb) {
|
|
80
|
+
constructor(registry, devices, projects, projectFiles, kdb) {
|
|
79
81
|
this.registry = registry;
|
|
80
82
|
this.devices = devices;
|
|
81
83
|
this.projects = projects;
|
|
84
|
+
this.projectFiles = projectFiles;
|
|
82
85
|
this.kdb = kdb;
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
@@ -416,6 +419,76 @@ let DevicesOperations = class DevicesOperations {
|
|
|
416
419
|
],
|
|
417
420
|
run: (input, ctx) => this.projects.candidates(ctx.orgId, ctx.actorAccountId, input.deviceId),
|
|
418
421
|
}),
|
|
422
|
+
defineOperation({
|
|
423
|
+
id: "devices.list-project-files",
|
|
424
|
+
description: "List one directory of a project on one of your devices: its folders, then its files, by name (at most 200; truncated says more exist). path is relative to the project root (empty or absent for the root), never absolute and never above the root; q keeps the names containing it. Names only, never file contents. Takes the id from devices.list and the name from devices.list-projects.",
|
|
425
|
+
input: DeviceId.extend({ name: DeviceProjectParams.shape.name })
|
|
426
|
+
.extend(DeviceProjectFilesQuery.shape)
|
|
427
|
+
.strict(),
|
|
428
|
+
example: {
|
|
429
|
+
deviceId: "4e8a0c1d-6b2f-4a37-8d19-3c5e7f9a1b20",
|
|
430
|
+
name: "capybara",
|
|
431
|
+
path: "src",
|
|
432
|
+
},
|
|
433
|
+
authz: { orgAction: "agents.use" },
|
|
434
|
+
mirrors: ["GET /api/v1/orgs/:orgId/devices/:id/projects/:name/files"],
|
|
435
|
+
renames: { deviceId: "id" },
|
|
436
|
+
confirm: "read",
|
|
437
|
+
errors: [
|
|
438
|
+
{
|
|
439
|
+
code: "device.not_found",
|
|
440
|
+
next: "Check the id with devices.list: you only see your own devices.",
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
code: "device.project_not_found",
|
|
444
|
+
next: "Check the project name with devices.list-projects.",
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
code: "device.path_outside_project",
|
|
448
|
+
next: "Pass a path relative to the project root that stays inside it (no leading /, no .. above the root).",
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
code: "device.project_path_missing",
|
|
452
|
+
next: "List the parent directory to find the right path.",
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
code: "device.list_unsupported",
|
|
456
|
+
next: "This device's provider cannot list files: ask the person for the path instead.",
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
code: "device.project_path_unreadable",
|
|
460
|
+
next: "The path is a file or a folder the device cannot read: list its parent folder instead.",
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
code: "device.project_outside_mode",
|
|
464
|
+
next: "The device does not let its owner browse there: pick another path in the project, or ask the person to remove the project and add it again from a directory under the device's base.",
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
code: "device.project_refused",
|
|
468
|
+
next: "The device refused that directory and said why: tell the person its reason, then list another path.",
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
code: "device.project_path_too_broad",
|
|
472
|
+
next: "The project lies above the owner's home now: ask the person to re-add the project's own directory.",
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
code: "device.not_running",
|
|
476
|
+
next: "The device stopped before it could be read: call again, it is started first.",
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
code: "device.projects_unavailable",
|
|
480
|
+
next: "The device could not be asked now: try again shortly.",
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
code: "device.offline",
|
|
484
|
+
next: "The machine serving it is offline: ask the person to connect that machine again, then call again.",
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
run: (input, ctx) => this.projectFiles.list(ctx.orgId, ctx.actorAccountId, input.deviceId, input.name, {
|
|
488
|
+
...(input.path !== undefined && { path: input.path }),
|
|
489
|
+
...(input.q !== undefined && { q: input.q }),
|
|
490
|
+
}),
|
|
491
|
+
}),
|
|
419
492
|
defineOperation({
|
|
420
493
|
id: "devices.add-project",
|
|
421
494
|
description: "Add a project to one of your devices: path is relative to the device's base (see devices.list-projects; empty for the base itself), never absolute, and never above the owner's home; name defaults to the directory's name (1-64 characters, no /, unique on the device). The device is asked first, so a missing directory, a file, an unreadable path or one the device refuses (with its reason) is refused. At most 100 projects per device. Takes the id from devices.list.",
|
|
@@ -515,6 +588,7 @@ DevicesOperations = __decorate([
|
|
|
515
588
|
__param(0, Inject(PlatformOperations)),
|
|
516
589
|
__param(1, Inject(DevicesService)),
|
|
517
590
|
__param(2, Inject(DeviceProjectsService)),
|
|
518
|
-
__param(3, Inject(
|
|
591
|
+
__param(3, Inject(DeviceProjectFilesService)),
|
|
592
|
+
__param(4, Inject(KernelDb))
|
|
519
593
|
], DevicesOperations);
|
|
520
594
|
export { DevicesOperations };
|
|
@@ -108,13 +108,13 @@ function orgRow(i) {
|
|
|
108
108
|
summary: `Your ${r.kind} request was ${r.status}${r.reason ? `: ${r.reason}` : ""}.`,
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
case "
|
|
111
|
+
case "automation_attention": {
|
|
112
112
|
const a = i.attention;
|
|
113
113
|
const summary = a.reason === "missing_grants"
|
|
114
|
-
? `
|
|
114
|
+
? `Automation "${a.name}" ran without: ${a.missing.join(", ")}.${a.needsRole.length > 0 ? ` Needing a higher role than the owner has (cannot be pre-approved): ${a.needsRole.join(", ")}.` : ""}${a.needsAdmin.length > 0 ? ` Outside the organization's network allowlist (only an org admin can add them): ${a.needsAdmin.join(", ")}.` : ""}`
|
|
115
115
|
: a.reason === "failed"
|
|
116
|
-
? `
|
|
117
|
-
: `
|
|
116
|
+
? `Automation "${a.name}"'s latest run failed${a.error ? `: ${a.error}` : ""}.`
|
|
117
|
+
: `Automation "${a.name}" is paused (${a.reason}${a.pausedBy ? ` by ${a.pausedBy.name || a.pausedBy.id}` : ""}).`;
|
|
118
118
|
return {
|
|
119
119
|
...base,
|
|
120
120
|
name: a.name,
|
|
@@ -693,7 +693,7 @@ let OrgsOperations = class OrgsOperations {
|
|
|
693
693
|
}),
|
|
694
694
|
defineOperation({
|
|
695
695
|
id: "orgs.audit",
|
|
696
|
-
description: "The audit log of this conversation's org (org admins), newest first: members and invitations, settings, agents, connectors, skills, plugins and extensions in the org, channels,
|
|
696
|
+
description: "The audit log of this conversation's org (org admins), newest first: members and invitations, settings, agents, connectors, skills, plugins and extensions in the org, channels, automations. Each event has its id, time, actor (id, name, email; null for the kernel itself), viaToken (done with a personal access token), viaAgent (done through the Platform tool), action and target; never the event's details. action filters by an action name or its prefix (e.g. org.member.). limit is 1 to 100 (default 20); pages by keyset: pass the returned next as params.after (null: no more).",
|
|
697
697
|
input: OrgAuditListQuery.strict(),
|
|
698
698
|
example: { limit: 20 },
|
|
699
699
|
authz: { orgAction: "org.update" },
|
|
@@ -50,7 +50,7 @@ const PUSH_CATEGORY_NAMES = {
|
|
|
50
50
|
waiting: { zh: "等你处理", en: "Waiting for you" },
|
|
51
51
|
replies: { zh: "智能体回复", en: "Agent replies" },
|
|
52
52
|
tasks: { zh: "任务状态", en: "Task status" },
|
|
53
|
-
|
|
53
|
+
automations: { zh: "自动化", en: "Automations" },
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
56
|
* The `platform` domain: orientation and what this agent is (spec §7, synthetic), and the
|
|
@@ -257,7 +257,7 @@ let PlatformOperationsProvider = class PlatformOperationsProvider {
|
|
|
257
257
|
}),
|
|
258
258
|
defineOperation({
|
|
259
259
|
id: "platform.push-preferences",
|
|
260
|
-
description: "Read your own push notification switches for your mobile app: waiting (approvals, questions and connect requests waiting for you), replies (an agent's run in your conversation finished or failed), tasks (background tasks and sub-agents finished) and
|
|
260
|
+
description: "Read your own push notification switches for your mobile app: waiting (approvals, questions and connect requests waiting for you), replies (an agent's run in your conversation finished or failed), tasks (background tasks and sub-agents finished) and automations (your automation ran or failed). Each is true unless you switched it off; they apply in every org.",
|
|
261
261
|
input: EMPTY,
|
|
262
262
|
example: {},
|
|
263
263
|
// any signed-in person may call the route; every run's actor is a member of this org
|
|
@@ -268,7 +268,7 @@ let PlatformOperationsProvider = class PlatformOperationsProvider {
|
|
|
268
268
|
}),
|
|
269
269
|
defineOperation({
|
|
270
270
|
id: "platform.set-push-preferences",
|
|
271
|
-
description: "Switch your own push notification categories on or off; give only the ones to change (waiting, replies, tasks,
|
|
271
|
+
description: "Switch your own push notification categories on or off; give only the ones to change (waiting, replies, tasks, automations: true or false), the others keep their values. They apply to every device of yours that receives push, in every org.",
|
|
272
272
|
input: PushPreferencesPatchSchema,
|
|
273
273
|
example: { replies: false },
|
|
274
274
|
authz: { orgAction: "agents.use" },
|
|
@@ -277,7 +277,7 @@ let PlatformOperationsProvider = class PlatformOperationsProvider {
|
|
|
277
277
|
errors: [
|
|
278
278
|
{
|
|
279
279
|
code: "validation_failed",
|
|
280
|
-
next: "Give at least one of waiting, replies, tasks,
|
|
280
|
+
next: "Give at least one of waiting, replies, tasks, automations, each true or false.",
|
|
281
281
|
},
|
|
282
282
|
],
|
|
283
283
|
summary: async (input) => {
|
|
@@ -5,6 +5,7 @@ import { AgentSkillsOperations } from "./ops/agent-skills.ops.js";
|
|
|
5
5
|
import { AgentTemplatesOperations } from "./ops/agent-templates.ops.js";
|
|
6
6
|
import { AgentsOperations } from "./ops/agents.ops.js";
|
|
7
7
|
import { ApprovalsOperations } from "./ops/approvals.ops.js";
|
|
8
|
+
import { AutomationsOperations } from "./ops/automations.ops.js";
|
|
8
9
|
import { BackgroundOperations } from "./ops/background.ops.js";
|
|
9
10
|
import { CatalogAdminOperations } from "./ops/catalog-admin.ops.js";
|
|
10
11
|
import { ChannelsOperations } from "./ops/channels.ops.js";
|
|
@@ -27,7 +28,6 @@ import { PlatformIconsOperations } from "./ops/platform-icons.ops.js";
|
|
|
27
28
|
import { PluginsOperations } from "./ops/plugins.ops.js";
|
|
28
29
|
import { PreviewersOperations } from "./ops/previewers.ops.js";
|
|
29
30
|
import { RequestsOperations } from "./ops/requests.ops.js";
|
|
30
|
-
import { SchedulesOperations } from "./ops/schedules.ops.js";
|
|
31
31
|
import { SetupOperations } from "./ops/setup.ops.js";
|
|
32
32
|
import { SharesOperations } from "./ops/shares.ops.js";
|
|
33
33
|
import { SkillsOperations } from "./ops/skills.ops.js";
|
|
@@ -37,7 +37,7 @@ import { UiOperations } from "./ops/ui.ops.js";
|
|
|
37
37
|
* One provider per domain, each taking `PlatformOperations` as its first constructor argument:
|
|
38
38
|
* the parity test in `tools/checks` builds the operations from it without a Nest app.
|
|
39
39
|
*/
|
|
40
|
-
export declare const PLATFORM_OPERATION_PROVIDERS: readonly [typeof PlatformOperationsProvider, typeof SkillsOperations, typeof AgentsOperations, typeof AgentTemplatesOperations, typeof PluginsOperations, typeof MarketplacesOperations, typeof RequestsOperations, typeof ConnectorsOperations, typeof ExtensionsOperations, typeof ConversationsOperations, typeof ComponentsOperations, typeof AccountsOperations, typeof OrgsOperations, typeof AdminOperations, typeof CatalogAdminOperations, typeof OrgPluginsOperations, typeof ExtensionsAdminOperations, typeof ModelsOperations, typeof InboxOperations, typeof ApprovalsOperations, typeof ChannelsOperations, typeof OrgSettingsOperations, typeof EvalsOperations, typeof BackgroundOperations, typeof PreviewersOperations, typeof DevicesOperations, typeof AgentSkillsOperations, typeof ThemesOperations, typeof SetupOperations, typeof UiOperations, typeof AdminItemsOperations, typeof
|
|
40
|
+
export declare const PLATFORM_OPERATION_PROVIDERS: readonly [typeof PlatformOperationsProvider, typeof SkillsOperations, typeof AgentsOperations, typeof AgentTemplatesOperations, typeof PluginsOperations, typeof MarketplacesOperations, typeof RequestsOperations, typeof ConnectorsOperations, typeof ExtensionsOperations, typeof ConversationsOperations, typeof ComponentsOperations, typeof AccountsOperations, typeof OrgsOperations, typeof AdminOperations, typeof CatalogAdminOperations, typeof OrgPluginsOperations, typeof ExtensionsAdminOperations, typeof ModelsOperations, typeof InboxOperations, typeof ApprovalsOperations, typeof ChannelsOperations, typeof OrgSettingsOperations, typeof EvalsOperations, typeof BackgroundOperations, typeof PreviewersOperations, typeof DevicesOperations, typeof AgentSkillsOperations, typeof ThemesOperations, typeof SetupOperations, typeof UiOperations, typeof AdminItemsOperations, typeof AutomationsOperations, typeof OutboxOperations, typeof SharesOperations, typeof PlatformIconsOperations];
|
|
41
41
|
/**
|
|
42
42
|
* The `Platform` tool's operations (ruling P2): one provider per domain, each registering its
|
|
43
43
|
* operations into `PlatformOperations` from `onModuleInit`. It imports the domain modules, which
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
8
|
import { AdminModule } from "../admin/admin.module.js";
|
|
9
9
|
import { AgentsModule } from "../agents/agents.module.js";
|
|
10
|
+
import { AutomationsModule } from "../automations/automations.module.js";
|
|
10
11
|
import { BackgroundModule } from "../background/background.module.js";
|
|
11
12
|
import { AppearanceModule } from "../catalog/appearance.service.js";
|
|
12
13
|
import { CatalogModule } from "../catalog/catalog.module.js";
|
|
@@ -22,7 +23,6 @@ import { ModelsModule } from "../models/models.module.js";
|
|
|
22
23
|
import { OrgsModule } from "../orgs/orgs.module.js";
|
|
23
24
|
import { PushModule } from "../push/push.module.js";
|
|
24
25
|
import { ProvidersModule } from "../runtime/providers.js";
|
|
25
|
-
import { SchedulesModule } from "../schedules/schedules.module.js";
|
|
26
26
|
import { SetupModule } from "../setup/setup.module.js";
|
|
27
27
|
import { SharesModule } from "../shares/shares.module.js";
|
|
28
28
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
@@ -35,6 +35,7 @@ import { AgentSkillsOperations } from "./ops/agent-skills.ops.js";
|
|
|
35
35
|
import { AgentTemplatesOperations } from "./ops/agent-templates.ops.js";
|
|
36
36
|
import { AgentsOperations } from "./ops/agents.ops.js";
|
|
37
37
|
import { ApprovalsOperations } from "./ops/approvals.ops.js";
|
|
38
|
+
import { AutomationsOperations } from "./ops/automations.ops.js";
|
|
38
39
|
import { BackgroundOperations } from "./ops/background.ops.js";
|
|
39
40
|
import { CatalogAdminOperations } from "./ops/catalog-admin.ops.js";
|
|
40
41
|
import { ChannelsOperations } from "./ops/channels.ops.js";
|
|
@@ -57,7 +58,6 @@ import { PlatformIconsOperations } from "./ops/platform-icons.ops.js";
|
|
|
57
58
|
import { PluginsOperations } from "./ops/plugins.ops.js";
|
|
58
59
|
import { PreviewersOperations } from "./ops/previewers.ops.js";
|
|
59
60
|
import { RequestsOperations } from "./ops/requests.ops.js";
|
|
60
|
-
import { SchedulesOperations } from "./ops/schedules.ops.js";
|
|
61
61
|
import { SetupOperations } from "./ops/setup.ops.js";
|
|
62
62
|
import { SharesOperations } from "./ops/shares.ops.js";
|
|
63
63
|
import { SkillsOperations } from "./ops/skills.ops.js";
|
|
@@ -110,8 +110,8 @@ export const PLATFORM_OPERATION_PROVIDERS = [
|
|
|
110
110
|
UiOperations,
|
|
111
111
|
// every org's agents and connectors, the conversation org's through the tool (spec §4.5)
|
|
112
112
|
AdminItemsOperations,
|
|
113
|
-
//
|
|
114
|
-
|
|
113
|
+
// automations (scheduled tasks spec §10)
|
|
114
|
+
AutomationsOperations,
|
|
115
115
|
// dead outbox rows (transactional outbox spec §3.4)
|
|
116
116
|
OutboxOperations,
|
|
117
117
|
// shared file links (file sharing spec §10)
|
|
@@ -150,7 +150,7 @@ PlatformOpsModule = __decorate([
|
|
|
150
150
|
FilesModule,
|
|
151
151
|
ThemesModule,
|
|
152
152
|
SetupModule,
|
|
153
|
-
|
|
153
|
+
AutomationsModule,
|
|
154
154
|
SharesModule,
|
|
155
155
|
PushModule,
|
|
156
156
|
],
|
|
@@ -8,6 +8,7 @@ import { OUTBOX_DEAD_ROUTES } from "../admin/outbox-dead.schemas.js";
|
|
|
8
8
|
import { OVERVIEW_ROUTES } from "../admin/overview.schemas.js";
|
|
9
9
|
import { AGENT_ROUTES } from "../agents/agents.schemas.js";
|
|
10
10
|
import { AGENT_TEMPLATE_ROUTES } from "../agents/templates.schemas.js";
|
|
11
|
+
import { AUTOMATION_ROUTES } from "../automations/automations.schemas.js";
|
|
11
12
|
import { BACKGROUND_ROUTES } from "../background/background.schemas.js";
|
|
12
13
|
import { ADMIN_CATALOG_ROUTES } from "../catalog/admin-catalog.schemas.js";
|
|
13
14
|
import { APPEARANCE_ROUTES } from "../catalog/appearance.schemas.js";
|
|
@@ -27,7 +28,6 @@ import { INBOX_ROUTES } from "../inbox/inbox.schemas.js";
|
|
|
27
28
|
import { ORG_MODEL_ROUTES } from "../models/org-models.schemas.js";
|
|
28
29
|
import { ORG_ROUTES, ORG_SETTINGS_ROUTES } from "../orgs/orgs.schemas.js";
|
|
29
30
|
import { PUSH_ROUTES } from "../push/push.schemas.js";
|
|
30
|
-
import { SCHEDULE_ROUTES } from "../schedules/schedules.schemas.js";
|
|
31
31
|
import { SETUP_CHECK_ROUTES } from "../setup/setup-checks.schemas.js";
|
|
32
32
|
import { SETUP_GUIDE_ROUTES } from "../setup/setup-guides.schemas.js";
|
|
33
33
|
import { SHARE_ROUTES } from "../shares/shares.schemas.js";
|
|
@@ -92,8 +92,8 @@ export const ROUTE_SCHEMAS = [
|
|
|
92
92
|
...UI_ROUTES,
|
|
93
93
|
// every org's agents and connectors (admin agents and connectors spec §4)
|
|
94
94
|
...ADMIN_ITEM_ROUTES,
|
|
95
|
-
//
|
|
96
|
-
...
|
|
95
|
+
// automations (scheduled tasks spec §10)
|
|
96
|
+
...AUTOMATION_ROUTES,
|
|
97
97
|
// the admin overview and the platform-level audit log (admin overview spec §5.2)
|
|
98
98
|
...OVERVIEW_ROUTES,
|
|
99
99
|
...AUDIT_ROUTES,
|
package/dist/push/jobs.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare const PUSH_FANOUT_JOB = "push-fanout";
|
|
|
12
12
|
export declare const PUSH_DELIVER_JOB = "push-deliver";
|
|
13
13
|
/** The event id of a conversation event (`conv-<conversationId>-<seq>`). */
|
|
14
14
|
export declare const conversationEventId: (conversationId: string, seq: number) => string;
|
|
15
|
-
/** The event id of
|
|
16
|
-
export declare const
|
|
15
|
+
/** The event id of an automation run's settle (`automation-<taskRunId>`). */
|
|
16
|
+
export declare const automationRunEventId: (taskRunId: string) => string;
|
|
17
17
|
/** One fanout per event: `push-fanout-<eventId>`. */
|
|
18
18
|
export declare const pushFanoutJobId: (eventId: string) => string;
|
|
19
19
|
/** One delivery per event and registration: `push-<eventId>-<registrationId>`. */
|
|
@@ -26,7 +26,7 @@ export type PushFanoutData = {
|
|
|
26
26
|
conversationId: string;
|
|
27
27
|
seq: number;
|
|
28
28
|
} | {
|
|
29
|
-
kind: "
|
|
29
|
+
kind: "automation";
|
|
30
30
|
taskRunId: string;
|
|
31
31
|
};
|
|
32
32
|
};
|
package/dist/push/jobs.js
CHANGED
|
@@ -11,8 +11,8 @@ export const PUSH_FANOUT_JOB = "push-fanout";
|
|
|
11
11
|
export const PUSH_DELIVER_JOB = "push-deliver";
|
|
12
12
|
/** The event id of a conversation event (`conv-<conversationId>-<seq>`). */
|
|
13
13
|
export const conversationEventId = (conversationId, seq) => `conv-${conversationId}-${seq}`;
|
|
14
|
-
/** The event id of
|
|
15
|
-
export const
|
|
14
|
+
/** The event id of an automation run's settle (`automation-<taskRunId>`). */
|
|
15
|
+
export const automationRunEventId = (taskRunId) => `automation-${taskRunId}`;
|
|
16
16
|
/** One fanout per event: `push-fanout-<eventId>`. */
|
|
17
17
|
export const pushFanoutJobId = (eventId) => `push-fanout-${eventId}`;
|
|
18
18
|
/** One delivery per event and registration: `push-<eventId>-<registrationId>`. */
|
|
@@ -31,7 +31,7 @@ let PushPreferencesService = class PushPreferencesService {
|
|
|
31
31
|
.select(["category", "enabled"])
|
|
32
32
|
.where("account_id", "=", accountId)
|
|
33
33
|
.execute();
|
|
34
|
-
const out = { waiting: true, replies: true, tasks: true,
|
|
34
|
+
const out = { waiting: true, replies: true, tasks: true, automations: true };
|
|
35
35
|
for (const r of rows)
|
|
36
36
|
out[r.category] = r.enabled;
|
|
37
37
|
return out;
|
package/dist/push/push-owed.d.ts
CHANGED
|
@@ -20,13 +20,13 @@ export declare class PushOwed {
|
|
|
20
20
|
*/
|
|
21
21
|
oweIn(conversationId: string, orgId: string, kind: string, events: readonly ConversationEvent[]): Promise<void>;
|
|
22
22
|
/**
|
|
23
|
-
* The fanout of
|
|
23
|
+
* The fanout of an automation run's settle (completed or failed), in the caller's
|
|
24
24
|
* transaction.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
oweAutomationRun(taskRunId: string, orgId: string): Promise<void>;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* {@link PushOwed}: infra and the extension registry only, so the event log and the
|
|
29
|
+
* {@link PushOwed}: infra and the extension registry only, so the event log and the automation
|
|
30
30
|
* run tracker import it without a cycle.
|
|
31
31
|
*/
|
|
32
32
|
export declare class PushOwedModule {
|
package/dist/push/push-owed.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Inject, Injectable, Module } from "@nestjs/common";
|
|
|
11
11
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
12
12
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
13
13
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
14
|
-
import { conversationEventId, PUSH_FANOUT_JOB, PUSH_QUEUE, pushFanoutJobId,
|
|
14
|
+
import { automationRunEventId, conversationEventId, PUSH_FANOUT_JOB, PUSH_QUEUE, pushFanoutJobId, } from "./jobs.js";
|
|
15
15
|
import { PushHostModule, PushProviderHost } from "./provider-host.js";
|
|
16
16
|
import { pushTriggerOf } from "./triggers.js";
|
|
17
17
|
/**
|
|
@@ -50,13 +50,13 @@ let PushOwed = class PushOwed {
|
|
|
50
50
|
})));
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* The fanout of
|
|
53
|
+
* The fanout of an automation run's settle (completed or failed), in the caller's
|
|
54
54
|
* transaction.
|
|
55
55
|
*/
|
|
56
|
-
async
|
|
56
|
+
async oweAutomationRun(taskRunId, orgId) {
|
|
57
57
|
if (!this.host.any())
|
|
58
58
|
return;
|
|
59
|
-
await this.outbox.add(fanoutJob(
|
|
59
|
+
await this.outbox.add(fanoutJob(automationRunEventId(taskRunId), orgId, { kind: "automation", taskRunId }));
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
__decorate([
|
|
@@ -64,7 +64,7 @@ __decorate([
|
|
|
64
64
|
], PushOwed.prototype, "oweIn", null);
|
|
65
65
|
__decorate([
|
|
66
66
|
Transactional({ propagation: "mandatory" })
|
|
67
|
-
], PushOwed.prototype, "
|
|
67
|
+
], PushOwed.prototype, "oweAutomationRun", null);
|
|
68
68
|
PushOwed = __decorate([
|
|
69
69
|
Injectable(),
|
|
70
70
|
__param(0, Inject(OutboxService)),
|
|
@@ -82,7 +82,7 @@ function fanoutJob(eventId, orgId, source) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* {@link PushOwed}: infra and the extension registry only, so the event log and the
|
|
85
|
+
* {@link PushOwed}: infra and the extension registry only, so the event log and the automation
|
|
86
86
|
* run tracker import it without a cycle.
|
|
87
87
|
*/
|
|
88
88
|
let PushOwedModule = class PushOwedModule {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
3
|
/** The push categories a person switches (mobile app spec §9.4); an absent preference is on. */
|
|
4
|
-
export declare const PUSH_CATEGORIES: readonly ["waiting", "replies", "tasks", "
|
|
4
|
+
export declare const PUSH_CATEGORIES: readonly ["waiting", "replies", "tasks", "automations"];
|
|
5
5
|
export type PushCategory = (typeof PUSH_CATEGORIES)[number];
|
|
6
6
|
/**
|
|
7
7
|
* `POST /me/push-registrations`: what the app's shell returns from `push@1.register()`, plus the
|
|
@@ -64,7 +64,7 @@ export declare const PushPreferencesSchema: z.ZodObject<{
|
|
|
64
64
|
waiting: z.ZodBoolean;
|
|
65
65
|
replies: z.ZodBoolean;
|
|
66
66
|
tasks: z.ZodBoolean;
|
|
67
|
-
|
|
67
|
+
automations: z.ZodBoolean;
|
|
68
68
|
}, z.core.$strict>;
|
|
69
69
|
export type PushPreferences = z.infer<typeof PushPreferencesSchema>;
|
|
70
70
|
/** `PUT /me/push-preferences`: the switches to change, at least one. */
|
|
@@ -72,14 +72,14 @@ export declare const PushPreferencesPatchSchema: z.ZodObject<{
|
|
|
72
72
|
waiting: z.ZodOptional<z.ZodBoolean>;
|
|
73
73
|
replies: z.ZodOptional<z.ZodBoolean>;
|
|
74
74
|
tasks: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
-
|
|
75
|
+
automations: z.ZodOptional<z.ZodBoolean>;
|
|
76
76
|
}, z.core.$strict>;
|
|
77
77
|
export type PushPreferencesPatch = z.infer<typeof PushPreferencesPatchSchema>;
|
|
78
78
|
declare const PushPreferencesPatchDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
79
79
|
waiting: z.ZodOptional<z.ZodBoolean>;
|
|
80
80
|
replies: z.ZodOptional<z.ZodBoolean>;
|
|
81
81
|
tasks: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
-
|
|
82
|
+
automations: z.ZodOptional<z.ZodBoolean>;
|
|
83
83
|
}, z.core.$strict>>;
|
|
84
84
|
export declare class PushPreferencesPatchDto extends PushPreferencesPatchDto_base {
|
|
85
85
|
}
|
|
@@ -2,7 +2,7 @@ import { PUSH_LIMITS } from "@capybara-hq/plugin-sdk";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
4
4
|
/** The push categories a person switches (mobile app spec §9.4); an absent preference is on. */
|
|
5
|
-
export const PUSH_CATEGORIES = ["waiting", "replies", "tasks", "
|
|
5
|
+
export const PUSH_CATEGORIES = ["waiting", "replies", "tasks", "automations"];
|
|
6
6
|
/**
|
|
7
7
|
* `POST /me/push-registrations`: what the app's shell returns from `push@1.register()`, plus the
|
|
8
8
|
* person's locale and a device name. The token is sealed at rest and never echoed.
|
|
@@ -39,11 +39,11 @@ export const PushPreferencesSchema = z
|
|
|
39
39
|
waiting: z.boolean(),
|
|
40
40
|
replies: z.boolean(),
|
|
41
41
|
tasks: z.boolean(),
|
|
42
|
-
|
|
42
|
+
automations: z.boolean(),
|
|
43
43
|
})
|
|
44
44
|
.strict();
|
|
45
45
|
/** `PUT /me/push-preferences`: the switches to change, at least one. */
|
|
46
|
-
export const PushPreferencesPatchSchema = PushPreferencesSchema.partial().refine((p) => Object.values(p).some((v) => v !== undefined), { message: "give at least one of waiting, replies, tasks,
|
|
46
|
+
export const PushPreferencesPatchSchema = PushPreferencesSchema.partial().refine((p) => Object.values(p).some((v) => v !== undefined), { message: "give at least one of waiting, replies, tasks, automations" });
|
|
47
47
|
export class PushPreferencesPatchDto extends createZodDto(PushPreferencesPatchSchema, "PushPreferencesPatch") {
|
|
48
48
|
}
|
|
49
49
|
/** The push routes the Platform operations mirror (`check:platform-ops` keys). */
|
|
@@ -15,15 +15,15 @@ export type ResolvedRecipients = Omit<ResolvedPush, "eventId">;
|
|
|
15
15
|
* while it is still `pending`; a question only while pending; both, and a connect request, go to
|
|
16
16
|
* the run's trigger account (an approval assigned to someone goes to that person);
|
|
17
17
|
* - `replies`: chat conversations only, to the conversation's owner, never for a run serving a
|
|
18
|
-
*
|
|
18
|
+
* automation (that pushes as `automations`);
|
|
19
19
|
* - `tasks`: the root conversation's owner;
|
|
20
|
-
* - `
|
|
20
|
+
* - `automations`: the task's owner, for a task run `completed` or `failed` of a task not deleted;
|
|
21
21
|
* - eval conversations (a sub-agent under an eval root too) and deleted conversations never push;
|
|
22
22
|
* - an escalated approval whose run is gone pushes nothing (its initiator is unknown).
|
|
23
23
|
*
|
|
24
24
|
* The path carries the org (`/chat/<root>?org=<orgId>`, `&subagent=<child>` for an event of a
|
|
25
|
-
* sub-agent's log;
|
|
26
|
-
* is the root conversation (`
|
|
25
|
+
* sub-agent's log; an automation run without a conversation opens `/inbox?org=<orgId>`), the thread
|
|
26
|
+
* is the root conversation (`automation-<taskId>` for an automation), the title the root's agent name
|
|
27
27
|
* (the task's name).
|
|
28
28
|
*/
|
|
29
29
|
export declare function resolveRecipients(db: KernelSchemaDb, source: PushFanoutData["source"]): Promise<ResolvedRecipients | null>;
|
package/dist/push/recipients.js
CHANGED
|
@@ -13,20 +13,20 @@ import { pushTriggerOf } from "./triggers.js";
|
|
|
13
13
|
* while it is still `pending`; a question only while pending; both, and a connect request, go to
|
|
14
14
|
* the run's trigger account (an approval assigned to someone goes to that person);
|
|
15
15
|
* - `replies`: chat conversations only, to the conversation's owner, never for a run serving a
|
|
16
|
-
*
|
|
16
|
+
* automation (that pushes as `automations`);
|
|
17
17
|
* - `tasks`: the root conversation's owner;
|
|
18
|
-
* - `
|
|
18
|
+
* - `automations`: the task's owner, for a task run `completed` or `failed` of a task not deleted;
|
|
19
19
|
* - eval conversations (a sub-agent under an eval root too) and deleted conversations never push;
|
|
20
20
|
* - an escalated approval whose run is gone pushes nothing (its initiator is unknown).
|
|
21
21
|
*
|
|
22
22
|
* The path carries the org (`/chat/<root>?org=<orgId>`, `&subagent=<child>` for an event of a
|
|
23
|
-
* sub-agent's log;
|
|
24
|
-
* is the root conversation (`
|
|
23
|
+
* sub-agent's log; an automation run without a conversation opens `/inbox?org=<orgId>`), the thread
|
|
24
|
+
* is the root conversation (`automation-<taskId>` for an automation), the title the root's agent name
|
|
25
25
|
* (the task's name).
|
|
26
26
|
*/
|
|
27
27
|
export async function resolveRecipients(db, source) {
|
|
28
|
-
return source.kind === "
|
|
29
|
-
?
|
|
28
|
+
return source.kind === "automation"
|
|
29
|
+
? resolveAutomation(db, source.taskRunId)
|
|
30
30
|
: resolveConversation(db, source.conversationId, source.seq);
|
|
31
31
|
}
|
|
32
32
|
async function resolveConversation(db, conversationId, seq) {
|
|
@@ -132,11 +132,11 @@ async function resolveConversation(db, conversationId, seq) {
|
|
|
132
132
|
return null;
|
|
133
133
|
const run = await db
|
|
134
134
|
.selectFrom("runs")
|
|
135
|
-
.select("
|
|
135
|
+
.select("automation_run_id")
|
|
136
136
|
.where("id", "=", event.run_id)
|
|
137
137
|
.where("conversation_id", "=", conversationId)
|
|
138
138
|
.executeTakeFirst();
|
|
139
|
-
if (!run || run.
|
|
139
|
+
if (!run || run.automation_run_id !== null)
|
|
140
140
|
return null;
|
|
141
141
|
candidates = [owner];
|
|
142
142
|
break;
|
|
@@ -168,24 +168,24 @@ async function resolveConversation(db, conversationId, seq) {
|
|
|
168
168
|
text: trigger.text,
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
async function
|
|
171
|
+
async function resolveAutomation(db, taskRunId) {
|
|
172
172
|
// org-filter: taskRunId comes from the kernel-written push fan-out job; this read learns the
|
|
173
173
|
// run's org (checked against its task's below), which every later read filters by
|
|
174
174
|
const row = await db
|
|
175
|
-
.selectFrom("
|
|
176
|
-
.innerJoin("
|
|
175
|
+
.selectFrom("automation_runs")
|
|
176
|
+
.innerJoin("automations", "automations.id", "automation_runs.automation_id")
|
|
177
177
|
.select([
|
|
178
|
-
"
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
184
|
-
"
|
|
178
|
+
"automation_runs.org_id",
|
|
179
|
+
"automation_runs.status",
|
|
180
|
+
"automation_runs.conversation_id",
|
|
181
|
+
"automations.id as automation_id",
|
|
182
|
+
"automations.org_id as task_org_id",
|
|
183
|
+
"automations.account_id",
|
|
184
|
+
"automations.name",
|
|
185
185
|
])
|
|
186
|
-
.where("
|
|
186
|
+
.where("automation_runs.id", "=", taskRunId)
|
|
187
187
|
// a deleted task pushes nothing
|
|
188
|
-
.where("
|
|
188
|
+
.where("automations.deleted_at", "is", null)
|
|
189
189
|
.executeTakeFirst();
|
|
190
190
|
if (!row || row.org_id !== row.task_org_id)
|
|
191
191
|
return null;
|
|
@@ -210,12 +210,12 @@ async function resolveSchedule(db, taskRunId) {
|
|
|
210
210
|
return {
|
|
211
211
|
orgId,
|
|
212
212
|
accountIds,
|
|
213
|
-
category: "
|
|
213
|
+
category: "automations",
|
|
214
214
|
path: conv === undefined ? `/inbox?org=${org}` : `/chat/${row.conversation_id}?org=${org}`,
|
|
215
|
-
threadId: `
|
|
215
|
+
threadId: `automation-${row.automation_id}`,
|
|
216
216
|
title: row.name,
|
|
217
217
|
conversationTitle: conv?.title ?? null,
|
|
218
|
-
text: row.status === "completed" ? "
|
|
218
|
+
text: row.status === "completed" ? "automationRan" : "automationFailed",
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
const optional = (id) => (id === null ? [] : [id]);
|
package/dist/push/texts.d.ts
CHANGED
|
@@ -6,16 +6,16 @@ export declare const PUSH_TEXT_KEYS: readonly PushTextKey[];
|
|
|
6
6
|
export declare function pushText(key: PushTextKey, locale: "zh" | "en"): string;
|
|
7
7
|
/** An event's push as the fanout resolved it (`recipients.ts`), with the event id. */
|
|
8
8
|
export interface ResolvedPush {
|
|
9
|
-
/** `conv-<conversationId>-<seq>` or `
|
|
9
|
+
/** `conv-<conversationId>-<seq>` or `automation-<taskRunId>`: the message's collapse id. */
|
|
10
10
|
eventId: string;
|
|
11
11
|
orgId: string;
|
|
12
12
|
accountIds: string[];
|
|
13
13
|
category: PushCategory;
|
|
14
14
|
/** In-app path with `?org=` (plan decision 8). */
|
|
15
15
|
path: string;
|
|
16
|
-
/** The root conversation id, or `
|
|
16
|
+
/** The root conversation id, or `automation-<taskId>`. */
|
|
17
17
|
threadId: string;
|
|
18
|
-
/** The agent's display name (the task's name for
|
|
18
|
+
/** The agent's display name (the task's name for an automation). */
|
|
19
19
|
title: string;
|
|
20
20
|
/** Shown only with `push.previews: "titles"`. */
|
|
21
21
|
conversationTitle: string | null;
|
package/dist/push/texts.js
CHANGED
|
@@ -8,8 +8,8 @@ const PUSH_TEXTS = {
|
|
|
8
8
|
runFailed: { en: "failed", zh: "运行失败" },
|
|
9
9
|
backgroundFinished: { en: "a background task ended", zh: "后台任务已结束" },
|
|
10
10
|
subagentFinished: { en: "a sub-agent finished", zh: "子智能体已完成" },
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
automationRan: { en: "your automation ran", zh: "你的自动化已运行" },
|
|
12
|
+
automationFailed: { en: "your automation failed", zh: "你的自动化运行失败" },
|
|
13
13
|
};
|
|
14
14
|
/** Every push text key. */
|
|
15
15
|
export const PUSH_TEXT_KEYS = Object.keys(PUSH_TEXTS);
|
package/dist/push/triggers.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ConversationEvent } from "../conversations/events.js";
|
|
|
2
2
|
import type { PushCategory } from "./push.schemas.js";
|
|
3
3
|
export type { PushCategory } from "./push.schemas.js";
|
|
4
4
|
/** The fixed sentences of a push body (`texts.ts` holds the copy). */
|
|
5
|
-
export type PushTextKey = "approval" | "question" | "connect" | "runFinished" | "runFailed" | "backgroundFinished" | "subagentFinished" | "
|
|
5
|
+
export type PushTextKey = "approval" | "question" | "connect" | "runFinished" | "runFailed" | "backgroundFinished" | "subagentFinished" | "automationRan" | "automationFailed";
|
|
6
6
|
/** What one event pushes: its category (the person's switch) and its sentence. */
|
|
7
7
|
export interface PushTrigger {
|
|
8
8
|
category: PushCategory;
|