@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,6 +9,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { OnWorkerEvent, WorkerHost } from "@nestjs/bullmq";
|
|
11
11
|
import { Inject, Injectable, Module, Optional } from "@nestjs/common";
|
|
12
|
+
import { EventCoalescer } from "../automations/events/coalesce.js";
|
|
13
|
+
import { TriggerDispatcher, TriggerDispatchModule } from "../automations/events/dispatcher.js";
|
|
14
|
+
import { AutomationFireModule, AutomationFirer } from "../automations/fire.js";
|
|
15
|
+
import { AUTOMATION_COALESCE_JOB, AUTOMATION_FIRE_JOB, AUTOMATION_SETTLE_JOB, TRIGGER_DISPATCH_JOB, } from "../automations/job-ids.js";
|
|
12
16
|
import { BackgroundModule } from "../background/background.module.js";
|
|
13
17
|
import { BG_WAKE_JOB } from "../background/wake-rules.js";
|
|
14
18
|
import { OWNED_PLUGIN_CLEANUP_JOB } from "../catalog/job-ids.js";
|
|
@@ -32,8 +36,6 @@ import { SandboxOperationReconcileJob } from "../sandbox/operation-reconcile.job
|
|
|
32
36
|
import { PERMISSION_APPROVAL_RECHECK } from "../sandbox/permission-transitions.js";
|
|
33
37
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
34
38
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
35
|
-
import { ScheduledTaskFireModule, ScheduledTaskFirer } from "../schedules/fire.js";
|
|
36
|
-
import { SCHED_FIRE_JOB, SCHED_SETTLE_JOB, } from "../schedules/job-ids.js";
|
|
37
39
|
import { SHARE_OBJECT_DELETE_JOB, ShareObjects, ShareObjectsModule, } from "../shares/share-objects.js";
|
|
38
40
|
import { PLATFORM_ICON_DELETE_JOB, PlatformIconObjects, PlatformIconObjectsModule, } from "../themes/platform-icon-objects.js";
|
|
39
41
|
import { ToolDrift } from "../tools/drift.js";
|
|
@@ -56,7 +58,7 @@ export const MAINTENANCE_CONCURRENCY = 5;
|
|
|
56
58
|
* {@link DirectorySync}, `run-stop` → {@link Offboarding.stopRun}, `bg-wake` and `ensure-run` → {@link RunQueue.ensureRun}, `stop-tree` →
|
|
57
59
|
* {@link processStopTree} and `deliver-to-parent` → {@link processDeliverToParent} (both in
|
|
58
60
|
* runtime/subagents/tree-jobs.ts, over {@link Waits}), `owned-plugin-cleanup` →
|
|
59
|
-
* {@link OwnedPluginCleanup}, `
|
|
61
|
+
* {@link OwnedPluginCleanup}, `automation-fire` and `automation-settle` → {@link AutomationFirer}, `automation-coalesce` → {@link EventCoalescer}, `share-object-delete` → {@link ShareObjects}, `platform-icon-delete` →
|
|
60
62
|
* {@link PlatformIconObjects}, `device-conversation-notice` → {@link ConversationNoticeDelivery}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
61
63
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
62
64
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
@@ -73,15 +75,17 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
73
75
|
offboarding;
|
|
74
76
|
runs;
|
|
75
77
|
ownedCleanup;
|
|
76
|
-
|
|
78
|
+
automations;
|
|
77
79
|
scheduled;
|
|
78
80
|
log;
|
|
79
81
|
operations;
|
|
80
82
|
shareObjects;
|
|
81
83
|
platformIcons;
|
|
82
84
|
notices;
|
|
85
|
+
triggers;
|
|
86
|
+
coalescer;
|
|
83
87
|
snapshots;
|
|
84
|
-
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, ownedCleanup,
|
|
88
|
+
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, ownedCleanup, automations, scheduled, log, operations, shareObjects, platformIcons, notices, triggers, coalescer, snapshots) {
|
|
85
89
|
super();
|
|
86
90
|
this.permissionApprovals = permissionApprovals;
|
|
87
91
|
this.waits = waits;
|
|
@@ -92,13 +96,15 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
92
96
|
this.offboarding = offboarding;
|
|
93
97
|
this.runs = runs;
|
|
94
98
|
this.ownedCleanup = ownedCleanup;
|
|
95
|
-
this.
|
|
99
|
+
this.automations = automations;
|
|
96
100
|
this.scheduled = scheduled;
|
|
97
101
|
this.log = log;
|
|
98
102
|
this.operations = operations;
|
|
99
103
|
this.shareObjects = shareObjects;
|
|
100
104
|
this.platformIcons = platformIcons;
|
|
101
105
|
this.notices = notices;
|
|
106
|
+
this.triggers = triggers;
|
|
107
|
+
this.coalescer = coalescer;
|
|
102
108
|
this.snapshots = snapshots;
|
|
103
109
|
}
|
|
104
110
|
process(job, token) {
|
|
@@ -187,13 +193,24 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
187
193
|
case OWNED_PLUGIN_CLEANUP_JOB:
|
|
188
194
|
await this.ownedCleanup.run(job.data.itemId);
|
|
189
195
|
return;
|
|
190
|
-
// one task run of
|
|
191
|
-
case
|
|
192
|
-
await this.
|
|
196
|
+
// one task run of an automation (scheduled tasks spec §6)
|
|
197
|
+
case AUTOMATION_FIRE_JOB:
|
|
198
|
+
await this.automations.fire(job.data.taskRunId);
|
|
193
199
|
return;
|
|
194
200
|
// a task run's settle check, claimed or unfired (ruling R26)
|
|
195
|
-
case
|
|
196
|
-
await this.
|
|
201
|
+
case AUTOMATION_SETTLE_JOB:
|
|
202
|
+
await this.automations.settle(job.data);
|
|
203
|
+
return;
|
|
204
|
+
// one stored trigger event's routing to the automations it fires (collaboration spec §4.2)
|
|
205
|
+
case TRIGGER_DISPATCH_JOB:
|
|
206
|
+
await this.triggers.dispatch(job.data, {
|
|
207
|
+
// a source that never answers leaves the event undelivered on the last attempt
|
|
208
|
+
finalAttempt: job.attemptsMade + 1 >= (job.opts?.attempts ?? 1),
|
|
209
|
+
});
|
|
210
|
+
return;
|
|
211
|
+
// one coalescing window of an event automation's events for one subject (spec §4.7)
|
|
212
|
+
case AUTOMATION_COALESCE_JOB:
|
|
213
|
+
await this.coalescer.flush(job.data);
|
|
197
214
|
return;
|
|
198
215
|
// a share snapshot a refresh or revoke stopped using (file sharing spec §2)
|
|
199
216
|
case SHARE_OBJECT_DELETE_JOB:
|
|
@@ -243,15 +260,17 @@ MaintenanceProcessor = __decorate([
|
|
|
243
260
|
__param(6, Inject(Offboarding)),
|
|
244
261
|
__param(7, Inject(RunQueue)),
|
|
245
262
|
__param(8, Inject(OwnedPluginCleanup)),
|
|
246
|
-
__param(9, Inject(
|
|
263
|
+
__param(9, Inject(AutomationFirer)),
|
|
247
264
|
__param(10, Inject(ScheduledRuns)),
|
|
248
265
|
__param(11, Inject(KERNEL_LOGGER)),
|
|
249
266
|
__param(12, Inject(SandboxOperationReconcileJob)),
|
|
250
267
|
__param(13, Inject(ShareObjects)),
|
|
251
268
|
__param(14, Inject(PlatformIconObjects)),
|
|
252
269
|
__param(15, Inject(ConversationNoticeDelivery)),
|
|
253
|
-
__param(16,
|
|
254
|
-
__param(
|
|
270
|
+
__param(16, Inject(TriggerDispatcher)),
|
|
271
|
+
__param(17, Inject(EventCoalescer)),
|
|
272
|
+
__param(18, Optional()),
|
|
273
|
+
__param(18, Inject(CloudPermissionSnapshots))
|
|
255
274
|
], MaintenanceProcessor);
|
|
256
275
|
export { MaintenanceProcessor };
|
|
257
276
|
/**
|
|
@@ -276,8 +295,10 @@ MaintenanceModule = __decorate([
|
|
|
276
295
|
OrgsModule,
|
|
277
296
|
// the removed org plugins' cleanup job (worker-only through this module)
|
|
278
297
|
OwnedPluginCleanupModule,
|
|
279
|
-
// the
|
|
280
|
-
|
|
298
|
+
// the automation fire job and the scanner (worker-only through this module)
|
|
299
|
+
AutomationFireModule,
|
|
300
|
+
// the trigger event dispatch job (worker-only through this module)
|
|
301
|
+
TriggerDispatchModule,
|
|
281
302
|
// the share snapshot deletion
|
|
282
303
|
ShareObjectsModule,
|
|
283
304
|
// the platform icon object deletion
|
|
@@ -372,10 +372,12 @@ interface CompactOptions {
|
|
|
372
372
|
/** Whether `ref` is the fallback rung (its saved params are `fallbackParams`). */
|
|
373
373
|
fallback?: boolean;
|
|
374
374
|
/**
|
|
375
|
-
* A manual compact run (spec §4.7, with `force`):
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
375
|
+
* A manual compact run (spec §4.7, with `force`): it plans with the manual rule (every turn before
|
|
376
|
+
* the latest summarized, at most {@link manualTailBudget} of the latest turn kept; maintainer
|
|
377
|
+
* decision 2026-11-28), which the reactive path (`force` alone) does not. An outcome the automatic
|
|
378
|
+
* paths keep silent is recorded, so the person sees what their action did: nothing to summarize
|
|
379
|
+
* writes `compaction_skipped`, a model or storage that cannot be reached right now writes
|
|
380
|
+
* `compaction_failed`.
|
|
379
381
|
*/
|
|
380
382
|
manual?: boolean;
|
|
381
383
|
}
|
|
@@ -5,7 +5,7 @@ import { ApiError } from "../errors.js";
|
|
|
5
5
|
import { ExtensionUnloadedError } from "../extensions/inflight.js";
|
|
6
6
|
import { hasInvocation, skillLoadOffered } from "../skills/catalog.js";
|
|
7
7
|
import { buildModelRequest, latestSummary, mediaRefs, planMedia, } from "./context/build.js";
|
|
8
|
-
import { acceptSummary, buildCompactionRequest, chunkTranscript, compactionBackoff, compactionChunkSize, compactionInputBudget, compactionPlan, compactionRequestOverhead, extractSummary, MIN_COMPACTION_CHUNK_TOKENS, nextTranscriptChunk, openingSeqs, shouldCompact, summarySavedTokens, turnsSinceSummary, } from "./context/compaction.js";
|
|
8
|
+
import { acceptSummary, buildCompactionRequest, chunkTranscript, compactionBackoff, compactionChunkSize, compactionInputBudget, compactionPlan, compactionRequestOverhead, extractSummary, MIN_COMPACTION_CHUNK_TOKENS, manualOpeningSeqs, manualTailBudget, nextTranscriptChunk, openingSeqs, shouldCompact, summarySavedTokens, turnsSinceSummary, } from "./context/compaction.js";
|
|
9
9
|
import { applyFit, estimateAfterFit, planFit, planningBounds, planReactiveTrim, planSqueezedFit, sentOutputCap, } from "./context/fit.js";
|
|
10
10
|
import { guardToolPairs } from "./context/pairing.js";
|
|
11
11
|
import { hasProjectSkills, overlongProjectSkills } from "./context/project-root.js";
|
|
@@ -814,20 +814,27 @@ export async function runCompaction(deps, input, events, runtime, compaction, to
|
|
|
814
814
|
// the input room left for the kept tail: the planning target `W - O_p - R_p`, minus the system
|
|
815
815
|
// prompt and tool definitions every request carries
|
|
816
816
|
const tailBudget = bounds.target - estimateTokens([], built.system, built.tools);
|
|
817
|
-
|
|
817
|
+
// a manual compaction ignores keepRecentTurns and keeps at most about a fifth of the window of
|
|
818
|
+
// the latest turn (spec §4.7, maintainer decision 2026-11-28); the reactive path (`force`
|
|
819
|
+
// without `manual`) plans like the proactive one
|
|
820
|
+
const manual = opts.manual === true;
|
|
821
|
+
const plan = manual
|
|
822
|
+
? compactionPlan(events, compaction, manualTailBudget(info.contextWindow, tailBudget), {
|
|
823
|
+
manual: true,
|
|
824
|
+
})
|
|
825
|
+
: compactionPlan(events, compaction, tailBudget);
|
|
818
826
|
if (!plan) {
|
|
819
|
-
if (
|
|
827
|
+
if (!manual)
|
|
820
828
|
return skipped(events);
|
|
821
829
|
// a manual compaction that finds nothing to summarize says so (display only, never
|
|
822
|
-
// model-visible):
|
|
830
|
+
// model-visible): nothing precedes the kept tail
|
|
823
831
|
const written = await appendCounted(deps, input, [
|
|
824
832
|
{
|
|
825
833
|
type: "compaction_skipped",
|
|
826
834
|
runId: input.runId,
|
|
827
835
|
idemKey: idem.compactionSkipped(input.runId),
|
|
828
836
|
payload: {
|
|
829
|
-
reason: "
|
|
830
|
-
keepRecentTurns: compaction.keepRecentTurns,
|
|
837
|
+
reason: "nothing_to_summarize",
|
|
831
838
|
turns: turnsSinceSummary(events),
|
|
832
839
|
step: input.step,
|
|
833
840
|
},
|
|
@@ -840,7 +847,10 @@ export async function runCompaction(deps, input, events, runtime, compaction, to
|
|
|
840
847
|
};
|
|
841
848
|
}
|
|
842
849
|
// decided now and recorded in the summary (spec §4.2): the request never depends on later events
|
|
843
|
-
|
|
850
|
+
// a manual compact run is started by no message: the turn it cuts into is the latest message run's
|
|
851
|
+
const opening = manual
|
|
852
|
+
? manualOpeningSeqs(events, plan.coversUpToSeq, input.absorbedUpToSeq)
|
|
853
|
+
: openingSeqs(events, input.runId, plan.coversUpToSeq, input.absorbedUpToSeq);
|
|
844
854
|
const { runId, step, signal, conversationId } = input;
|
|
845
855
|
const ref = modelRef;
|
|
846
856
|
// §4.6 progress: from here the compaction is certain, so the conversation may show a row. It is
|
|
@@ -6,13 +6,22 @@ import { TransactionHost } from "../../infra/database/transaction-host.js";
|
|
|
6
6
|
import type { KernelLogger } from "../../log.js";
|
|
7
7
|
import { SandboxService } from "../../sandbox/sandbox.service.js";
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
10
|
-
*
|
|
9
|
+
* The time limits of a run start's project read. The device's start (a resume, or a recreate when
|
|
10
|
+
* its instance is gone) and the read itself are bounded apart, so a slow start never eats the
|
|
11
|
+
* read's time: past either the run goes on without a new snapshot, as when the device is
|
|
12
|
+
* unreachable.
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
14
|
+
export interface ProjectKnowledgeTimeouts {
|
|
15
|
+
/** Entering the device: from the read's start until the device runs. */
|
|
16
|
+
startMs: number;
|
|
17
|
+
/** Every device call of the read once the device runs, under one bound. */
|
|
18
|
+
readMs: number;
|
|
19
|
+
}
|
|
20
|
+
/** The default {@link ProjectKnowledgeTimeouts}. */
|
|
21
|
+
export declare const PROJECT_KNOWLEDGE_TIMEOUTS: ProjectKnowledgeTimeouts;
|
|
13
22
|
/**
|
|
14
|
-
* Test seam (`KernelSeams`): the read's time
|
|
15
|
-
* {@link
|
|
23
|
+
* Test seam (`KernelSeams`): the read's time limits, asked at every read; default
|
|
24
|
+
* {@link PROJECT_KNOWLEDGE_TIMEOUTS}.
|
|
16
25
|
*/
|
|
17
26
|
export declare const PROJECT_KNOWLEDGE_TIMEOUT: unique symbol;
|
|
18
27
|
/** What a run start tells {@link ProjectKnowledgeService.record}. */
|
|
@@ -62,8 +71,8 @@ export declare class ProjectKnowledgeService {
|
|
|
62
71
|
private readonly projects;
|
|
63
72
|
private readonly sandbox;
|
|
64
73
|
private readonly log;
|
|
65
|
-
private readonly
|
|
66
|
-
constructor(db: KernelDb, eventLog: Pick<EventLog, "appendIn" | "notify">, txHost: TransactionHost, devices: Pick<ConversationDevices, "forTool">, projects: Pick<DeviceProjectsService, "scopeFor" | "keeps">, sandbox: Pick<SandboxService, "withKernelRead">, log: KernelLogger,
|
|
74
|
+
private readonly timeouts;
|
|
75
|
+
constructor(db: KernelDb, eventLog: Pick<EventLog, "appendIn" | "notify">, txHost: TransactionHost, devices: Pick<ConversationDevices, "forTool">, projects: Pick<DeviceProjectsService, "scopeFor" | "keeps">, sandbox: Pick<SandboxService, "withKernelRead">, log: KernelLogger, timeouts?: () => ProjectKnowledgeTimeouts);
|
|
67
76
|
/**
|
|
68
77
|
* Reads and records (see the class); notifies after the commit. False: the run had ended under
|
|
69
78
|
* the locks (a stop landed while the device was read), so nothing was appended and the run must
|
|
@@ -27,16 +27,18 @@ import { providerConnectionFailure } from "../../sandbox/unreachable.js";
|
|
|
27
27
|
import { currentExecutionClaim } from "../run-execution.js";
|
|
28
28
|
import { runEndedIn } from "../run-status.js";
|
|
29
29
|
import { projectRootIdemKey, projectUnavailable, readProjectKnowledge, sameProjectRoot, unavailableProject, } from "./knowledge.js";
|
|
30
|
+
/** The default {@link ProjectKnowledgeTimeouts}. */
|
|
31
|
+
export const PROJECT_KNOWLEDGE_TIMEOUTS = {
|
|
32
|
+
startMs: 60_000,
|
|
33
|
+
readMs: 30_000,
|
|
34
|
+
};
|
|
30
35
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
export const PROJECT_KNOWLEDGE_TIMEOUT_MS = 30_000;
|
|
35
|
-
/**
|
|
36
|
-
* Test seam (`KernelSeams`): the read's time limit in ms, asked at every read; default
|
|
37
|
-
* {@link PROJECT_KNOWLEDGE_TIMEOUT_MS}.
|
|
36
|
+
* Test seam (`KernelSeams`): the read's time limits, asked at every read; default
|
|
37
|
+
* {@link PROJECT_KNOWLEDGE_TIMEOUTS}.
|
|
38
38
|
*/
|
|
39
39
|
export const PROJECT_KNOWLEDGE_TIMEOUT = Symbol("PROJECT_KNOWLEDGE_TIMEOUT");
|
|
40
|
+
/** The abort reason of a passed time limit (as `AbortSignal.timeout` gives). */
|
|
41
|
+
const timeoutReason = (what) => new DOMException(`The project read's ${what} time limit passed`, "TimeoutError");
|
|
40
42
|
/** The run start has no current execution claim of its own run: nothing is admitted. */
|
|
41
43
|
class KnowledgeClaimMissing extends Error {
|
|
42
44
|
constructor() {
|
|
@@ -91,8 +93,8 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
91
93
|
projects;
|
|
92
94
|
sandbox;
|
|
93
95
|
log;
|
|
94
|
-
|
|
95
|
-
constructor(db, eventLog, txHost, devices, projects, sandbox, log,
|
|
96
|
+
timeouts;
|
|
97
|
+
constructor(db, eventLog, txHost, devices, projects, sandbox, log, timeouts = () => PROJECT_KNOWLEDGE_TIMEOUTS) {
|
|
96
98
|
this.db = db;
|
|
97
99
|
this.eventLog = eventLog;
|
|
98
100
|
this.txHost = txHost;
|
|
@@ -100,7 +102,7 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
100
102
|
this.projects = projects;
|
|
101
103
|
this.sandbox = sandbox;
|
|
102
104
|
this.log = log;
|
|
103
|
-
this.
|
|
105
|
+
this.timeouts = timeouts;
|
|
104
106
|
}
|
|
105
107
|
/**
|
|
106
108
|
* Reads and records (see the class); notifies after the commit. False: the run had ended under
|
|
@@ -169,7 +171,12 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
169
171
|
runId: input.runId,
|
|
170
172
|
project: bound.project,
|
|
171
173
|
};
|
|
172
|
-
const
|
|
174
|
+
const limits = this.timeouts();
|
|
175
|
+
// the start's limit runs until the device runs; the read then has its own
|
|
176
|
+
const start = new AbortController();
|
|
177
|
+
const startTimer = setTimeout(() => start.abort(timeoutReason("start")), limits.startMs);
|
|
178
|
+
const signal = AbortSignal.any([input.signal, start.signal]);
|
|
179
|
+
let readSignal;
|
|
173
180
|
try {
|
|
174
181
|
// the device a tool call of this conversation would enter, checked for its owner now
|
|
175
182
|
const deviceId = await this.devices.forTool(input.orgId, input.conversationId);
|
|
@@ -202,7 +209,10 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
202
209
|
conversationId: input.conversationId,
|
|
203
210
|
runId: input.runId,
|
|
204
211
|
},
|
|
205
|
-
}, async (h, p, info,
|
|
212
|
+
}, async (h, p, info, held) => {
|
|
213
|
+
clearTimeout(startTimer);
|
|
214
|
+
const sig = AbortSignal.any([held, AbortSignal.timeout(limits.readMs)]);
|
|
215
|
+
readSignal = sig;
|
|
206
216
|
const target = { project: bound.project, root: bound.root, mode: scope.mode };
|
|
207
217
|
// the kernel's own check first: a root above the owner's home is refused as the working
|
|
208
218
|
// root's rule refuses it (`workingRootOf`, the same home: the reported one, else the
|
|
@@ -253,13 +263,21 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
253
263
|
}, signal);
|
|
254
264
|
}
|
|
255
265
|
catch (err) {
|
|
266
|
+
const stopped = input.signal.aborted;
|
|
267
|
+
const readTimedOut = !stopped && readSignal?.aborted === true;
|
|
268
|
+
const startTimedOut = !stopped && start.signal.aborted;
|
|
256
269
|
this.log.warn("project knowledge not read: the device could not be asked; the run goes on", {
|
|
257
270
|
...where,
|
|
258
|
-
timedOut:
|
|
271
|
+
timedOut: readTimedOut || startTimedOut,
|
|
272
|
+
...(startTimedOut && { timedOutIn: "start" }),
|
|
273
|
+
...(readTimedOut && { timedOutIn: "read" }),
|
|
259
274
|
err,
|
|
260
275
|
});
|
|
261
276
|
return null;
|
|
262
277
|
}
|
|
278
|
+
finally {
|
|
279
|
+
clearTimeout(startTimer);
|
|
280
|
+
}
|
|
263
281
|
}
|
|
264
282
|
/**
|
|
265
283
|
* How the read enters the device: `withKernelRead` under the run's current execution claim (the
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { AutomationRunTracker } from "../automations/run-tracker.js";
|
|
1
2
|
import { type AppendEvent, EventLog } from "../conversations/event-log.js";
|
|
2
3
|
import { GitRunEnd } from "../git/run-end.js";
|
|
3
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
6
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
6
|
-
import { ScheduledTaskRunTracker } from "../schedules/run-tracker.js";
|
|
7
7
|
import { ApprovalsService } from "../tools/approvals.service.js";
|
|
8
8
|
import { QuestionsService } from "../tools/questions.service.js";
|
|
9
9
|
import { type TerminalStatus } from "./run-jobs.js";
|
|
@@ -29,7 +29,7 @@ export declare class RunFinish {
|
|
|
29
29
|
private readonly kdb;
|
|
30
30
|
private readonly eventLog;
|
|
31
31
|
readonly txHost: TransactionHost;
|
|
32
|
-
/**
|
|
32
|
+
/** An automation's run follows its kernel run's end in the same transaction (spec §6). */
|
|
33
33
|
private readonly taskRuns;
|
|
34
34
|
/** The run's git tickets are revoked and its fetch summaries written after the commit. */
|
|
35
35
|
private readonly gitRunEnd;
|
|
@@ -40,8 +40,8 @@ export declare class RunFinish {
|
|
|
40
40
|
/** ... and its pending input requests. */
|
|
41
41
|
private readonly questions;
|
|
42
42
|
constructor(kdb: KernelDb, eventLog: EventLog, txHost: TransactionHost,
|
|
43
|
-
/**
|
|
44
|
-
taskRuns: Pick<
|
|
43
|
+
/** An automation's run follows its kernel run's end in the same transaction (spec §6). */
|
|
44
|
+
taskRuns: Pick<AutomationRunTracker, "onRunFinished">,
|
|
45
45
|
/** The run's git tickets are revoked and its fetch summaries written after the commit. */
|
|
46
46
|
gitRunEnd: Pick<GitRunEnd, "onRunFinished">,
|
|
47
47
|
/** The run's end owes the conversation's ensure-run backstop (transactional outbox spec §6). */
|
|
@@ -9,6 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { sql } from "kysely";
|
|
12
|
+
import { AutomationRunTracker } from "../automations/run-tracker.js";
|
|
12
13
|
import { EventLog } from "../conversations/event-log.js";
|
|
13
14
|
import { pauseQueueIn } from "../conversations/queue.js";
|
|
14
15
|
import { GitRunEnd } from "../git/run-end.js";
|
|
@@ -17,7 +18,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
17
18
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
18
19
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
19
20
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
20
|
-
import { ScheduledTaskRunTracker } from "../schedules/run-tracker.js";
|
|
21
21
|
import { ApprovalsService } from "../tools/approvals.service.js";
|
|
22
22
|
import { QuestionsService } from "../tools/questions.service.js";
|
|
23
23
|
import { ACTIVE_RUN_STATUSES, lockWaitRowsIn, oweEnsureRun, TERMINAL_STATUSES, } from "./run-jobs.js";
|
|
@@ -38,7 +38,7 @@ let RunFinish = class RunFinish {
|
|
|
38
38
|
approvals;
|
|
39
39
|
questions;
|
|
40
40
|
constructor(kdb, eventLog, txHost,
|
|
41
|
-
/**
|
|
41
|
+
/** An automation's run follows its kernel run's end in the same transaction (spec §6). */
|
|
42
42
|
taskRuns,
|
|
43
43
|
/** The run's git tickets are revoked and its fetch summaries written after the commit. */
|
|
44
44
|
gitRunEnd,
|
|
@@ -209,7 +209,7 @@ RunFinish = __decorate([
|
|
|
209
209
|
__param(0, Inject(KernelDb)),
|
|
210
210
|
__param(1, Inject(EventLog)),
|
|
211
211
|
__param(2, Inject(TransactionHost)),
|
|
212
|
-
__param(3, Inject(
|
|
212
|
+
__param(3, Inject(AutomationRunTracker)),
|
|
213
213
|
__param(4, Inject(GitRunEnd)),
|
|
214
214
|
__param(5, Inject(OutboxService)),
|
|
215
215
|
__param(6, Inject(ApprovalsService)),
|
|
@@ -11,6 +11,8 @@ import { randomUUID } from "node:crypto";
|
|
|
11
11
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { visibleTo } from "../agents/agent-lookup.js";
|
|
14
|
+
import { linkStartedRunIn } from "../automations/run-tracker.js";
|
|
15
|
+
import { automationRunAt } from "../automations/unattended.js";
|
|
14
16
|
import { wakeDecisionIn } from "../background/wake-rules.js";
|
|
15
17
|
import { EventLog } from "../conversations/event-log.js";
|
|
16
18
|
import { dispatchQueuedIn, pauseQueueWith } from "../conversations/queue.js";
|
|
@@ -21,8 +23,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
21
23
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
22
24
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
23
25
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
24
|
-
import { linkStartedRunIn } from "../schedules/run-tracker.js";
|
|
25
|
-
import { scheduledTaskRunAt } from "../schedules/unattended.js";
|
|
26
26
|
import { KyselyCheckpointSaver } from "./checkpointer.js";
|
|
27
27
|
import { ConversationLock } from "./conversation-lock.js";
|
|
28
28
|
import { notifyFinished, RunFinish } from "./run-finish.js";
|
|
@@ -337,8 +337,10 @@ let RunQueue = class RunQueue {
|
|
|
337
337
|
if (!(await this.oweJob(conversationId, runId, jobId.id, "chat", conv.org_id)))
|
|
338
338
|
return null;
|
|
339
339
|
// scheduled tasks spec §4: a task's message makes the run unattended; a wake inherits it
|
|
340
|
-
// from the run that produced its event; a person's message never does
|
|
341
|
-
|
|
340
|
+
// from the run that produced its event; a person's message never does. An event
|
|
341
|
+
// automation's message also records its last event (collaboration spec §4.7)
|
|
342
|
+
const lineage = await automationRunAt(t, conversationId, trigger.seq);
|
|
343
|
+
const taskRunId = lineage.automationRunId;
|
|
342
344
|
await t
|
|
343
345
|
.insertInto("runs")
|
|
344
346
|
.values({
|
|
@@ -352,7 +354,8 @@ let RunQueue = class RunQueue {
|
|
|
352
354
|
// a chat conversation always has its person-triggered run before any wake (a wake event
|
|
353
355
|
// comes from a run of it or of its tree); null would only make the wake run its own window
|
|
354
356
|
budget_run_id: isWake ? await budgetWindowOf(t, conversationId) : null,
|
|
355
|
-
|
|
357
|
+
automation_run_id: taskRunId,
|
|
358
|
+
trigger_event_id: lineage.triggerEventId,
|
|
356
359
|
})
|
|
357
360
|
.execute();
|
|
358
361
|
// the task run its message started follows this run from now on (spec §6)
|
|
@@ -473,6 +476,8 @@ let RunQueue = class RunQueue {
|
|
|
473
476
|
if (!(await this.oweJob(conversationId, runId, jobId.id, "subagent", conv.org_id))) {
|
|
474
477
|
return null;
|
|
475
478
|
}
|
|
479
|
+
// a parent's message or a wake: unattended when the run behind it was (automations §4)
|
|
480
|
+
const lineage = await automationRunAt(t, conversationId, wake.seq);
|
|
476
481
|
await t
|
|
477
482
|
.insertInto("runs")
|
|
478
483
|
.values({
|
|
@@ -484,8 +489,8 @@ let RunQueue = class RunQueue {
|
|
|
484
489
|
trigger_seq: wake.seq,
|
|
485
490
|
job_id: jobId.recorded,
|
|
486
491
|
budget_run_id: await budgetWindowOf(t, rootId),
|
|
487
|
-
|
|
488
|
-
|
|
492
|
+
automation_run_id: lineage.automationRunId,
|
|
493
|
+
trigger_event_id: lineage.triggerEventId,
|
|
489
494
|
})
|
|
490
495
|
.execute();
|
|
491
496
|
return runId;
|
|
@@ -1172,11 +1172,17 @@ let RunWorker = class RunWorker {
|
|
|
1172
1172
|
trigger: "subagent",
|
|
1173
1173
|
triggerSeq: Number(run.trigger_seq),
|
|
1174
1174
|
}),
|
|
1175
|
-
//
|
|
1175
|
+
// an automation's message (scheduled tasks spec §6), or an event automation's
|
|
1176
|
+
// (collaboration spec §4.6); display only
|
|
1176
1177
|
...(boundary?.type === "user_message" &&
|
|
1177
1178
|
boundary.payload.schedule !== undefined && {
|
|
1178
1179
|
trigger: "schedule",
|
|
1179
1180
|
}),
|
|
1181
|
+
...(boundary?.type === "user_message" &&
|
|
1182
|
+
boundary.payload.automationEvent !==
|
|
1183
|
+
undefined && {
|
|
1184
|
+
trigger: "automation_event",
|
|
1185
|
+
}),
|
|
1180
1186
|
}),
|
|
1181
1187
|
},
|
|
1182
1188
|
},
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
|
+
import { AutomationTrackerModule } from "../automations/run-tracker.js";
|
|
8
9
|
import { BackgroundModule } from "../background/background.module.js";
|
|
9
10
|
import { BackgroundWake } from "../background/wake.js";
|
|
10
11
|
import { ConversationAccessModule } from "../conversations/access.js";
|
|
@@ -24,7 +25,6 @@ import { OrgSettingsModule } from "../orgs/settings.service.js";
|
|
|
24
25
|
import { OperationAuthorityModule } from "../sandbox/operation-authority.module.js";
|
|
25
26
|
import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
|
|
26
27
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
27
|
-
import { ScheduledTaskTrackerModule } from "../schedules/run-tracker.js";
|
|
28
28
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
29
29
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
30
30
|
import { RunAbort } from "./abort.js";
|
|
@@ -93,8 +93,8 @@ RuntimeModule = __decorate([
|
|
|
93
93
|
OrgSettingsModule,
|
|
94
94
|
StepLogModule,
|
|
95
95
|
BackgroundModule,
|
|
96
|
-
//
|
|
97
|
-
|
|
96
|
+
// an automation's run follows its kernel run's end (`RunFinish`)
|
|
97
|
+
AutomationTrackerModule,
|
|
98
98
|
// the maintenance queue's handle: the outbox delivers the `wait-timeout` jobs the waits owe
|
|
99
99
|
// (`MaintenanceProcessor` consumes them)
|
|
100
100
|
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
@@ -282,7 +282,13 @@ export async function commitDispatchIn(d, a, plan, child) {
|
|
|
282
282
|
.executeTakeFirst();
|
|
283
283
|
const parent = await t
|
|
284
284
|
.selectFrom("runs")
|
|
285
|
-
.select([
|
|
285
|
+
.select([
|
|
286
|
+
"status",
|
|
287
|
+
"subagent_tokens_used",
|
|
288
|
+
"budget_run_id",
|
|
289
|
+
"automation_run_id",
|
|
290
|
+
"trigger_event_id",
|
|
291
|
+
])
|
|
286
292
|
.where("id", "=", ctx.runId)
|
|
287
293
|
.forUpdate()
|
|
288
294
|
.executeTakeFirst();
|
|
@@ -377,8 +383,10 @@ export async function commitDispatchIn(d, a, plan, child) {
|
|
|
377
383
|
trigger_account_id: ctx.accountId,
|
|
378
384
|
trigger_seq: task.seq,
|
|
379
385
|
budget_run_id: budgetRunId,
|
|
380
|
-
// an unattended parent's sub-agents are unattended too (scheduled tasks spec §4)
|
|
381
|
-
|
|
386
|
+
// an unattended parent's sub-agents are unattended too (scheduled tasks spec §4), and an
|
|
387
|
+
// event a sub-agent causes counts its chain from the parent's event (collaboration §4.7)
|
|
388
|
+
automation_run_id: parent.automation_run_id,
|
|
389
|
+
trigger_event_id: parent.trigger_event_id,
|
|
382
390
|
})
|
|
383
391
|
.execute();
|
|
384
392
|
await t
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The read roots of an owner browse narrowed to `narrow` (composer menus §5: a project's files are
|
|
3
|
+
* browsed in a scope rooted at the project path): each narrowing root that lies at or below one of
|
|
4
|
+
* the owner's ceiling roots, never wider than the ceiling. A narrowing root outside every ceiling
|
|
5
|
+
* root, or one that is not absolute and normalized, drops out. The result is deduplicated and may
|
|
6
|
+
* be empty (the caller refuses the browse then).
|
|
7
|
+
*/
|
|
8
|
+
export declare function narrowReadRoots(ceiling: readonly string[], narrow: readonly string[]): string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
/** `path` lies at or below `root` (both absolute and normalized). */
|
|
3
|
+
const within = (path, root) => path === root || root === "/" || path.startsWith(`${root}/`);
|
|
4
|
+
/** An absolute, normalized posix path without a trailing `/` (except `/` itself). */
|
|
5
|
+
const plainAbsolute = (p) => posix.isAbsolute(p) && posix.normalize(p) === p && (p === "/" || !p.endsWith("/"));
|
|
6
|
+
/**
|
|
7
|
+
* The read roots of an owner browse narrowed to `narrow` (composer menus §5: a project's files are
|
|
8
|
+
* browsed in a scope rooted at the project path): each narrowing root that lies at or below one of
|
|
9
|
+
* the owner's ceiling roots, never wider than the ceiling. A narrowing root outside every ceiling
|
|
10
|
+
* root, or one that is not absolute and normalized, drops out. The result is deduplicated and may
|
|
11
|
+
* be empty (the caller refuses the browse then).
|
|
12
|
+
*/
|
|
13
|
+
export function narrowReadRoots(ceiling, narrow) {
|
|
14
|
+
const out = new Set();
|
|
15
|
+
for (const n of narrow) {
|
|
16
|
+
if (!plainAbsolute(n))
|
|
17
|
+
continue;
|
|
18
|
+
if (ceiling.some((c) => within(n, c)))
|
|
19
|
+
out.add(n);
|
|
20
|
+
}
|
|
21
|
+
return [...out];
|
|
22
|
+
}
|
|
@@ -14,7 +14,7 @@ export interface NetworkRunState {
|
|
|
14
14
|
/** A network ask of the run tree is still pending (at most one at a time). */
|
|
15
15
|
pending: boolean;
|
|
16
16
|
/**
|
|
17
|
-
* Hosts the
|
|
17
|
+
* Hosts the automation the run serves approves on this device (spec §8.1; unattended runs
|
|
18
18
|
* only, read only with a `deviceId`): never asked about nor recorded as missing. Absent: none.
|
|
19
19
|
*/
|
|
20
20
|
taskGranted?: Set<string>;
|
|
@@ -26,7 +26,7 @@ export interface NetworkRunState {
|
|
|
26
26
|
* tree is the runs of one budget window (`runs.budget_run_id` lineage): a sub-agent's run sees the
|
|
27
27
|
* root's grants, another run tree never does. The hosts a decision allowed are its
|
|
28
28
|
* `detail.grantedHosts`; a decision without them grants nothing. In an unattended run of a
|
|
29
|
-
*
|
|
29
|
+
* automation, the task's `network:<host>` grants (spec §8.1) join them.
|
|
30
30
|
*/
|
|
31
31
|
export declare class NetworkGrants {
|
|
32
32
|
private readonly db;
|
|
@@ -35,7 +35,7 @@ export declare class NetworkGrants {
|
|
|
35
35
|
* Hosts allowed for this exec on `deviceId`: the run tree's once-approved network asks in
|
|
36
36
|
* `orgId` about that device, while the tree's root run has not ended (a grant ends with its run;
|
|
37
37
|
* a later run of the same budget window does not inherit it), with the root run as their source
|
|
38
|
-
* and the latest decider as its account; and in an unattended run of
|
|
38
|
+
* and the latest decider as its account; and in an unattended run of an automation, the
|
|
39
39
|
* task's network grants (spec §8.1) when the device is its creator's, with the task as their
|
|
40
40
|
* source and the creator as its account. Both together are one grant: the hosts of both, the
|
|
41
41
|
* task as the source. Undefined when none. The device applies them only when its owner allows
|
|
@@ -55,7 +55,7 @@ export declare class NetworkGrants {
|
|
|
55
55
|
/** The run tree's once-approved hosts as exec grants (source: the root run). */
|
|
56
56
|
private runGrants;
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* An automation's network grants for an unattended run (spec §8.1): the task's
|
|
59
59
|
* `network:<host>` grants when the run serves a task run that is no trial run and no person
|
|
60
60
|
* joined (`taskGrantsRunOf`, inherited by its sub-agents), the task is of `orgId` (when given)
|
|
61
61
|
* and `deviceId` is a live device of the task's org owned by the task's creator (a creator
|