@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
|
@@ -12,6 +12,10 @@ import { connectorToolKey, parseToolKey, validateAllowHost, } from "@capybara-hq
|
|
|
12
12
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
14
|
import { normalizeStoredDefinition } from "../agents/definition.js";
|
|
15
|
+
import { readAutomationSettings } from "../automations/effective-settings.js";
|
|
16
|
+
import { GIT_GRANT_SPEC_HASH, gitGrantRefusal, gitPushGrantKey, grantRefusalOf, NETWORK_GRANT_PREFIX, NETWORK_GRANT_SPEC_HASH, networkGrantRefusal, normalizeGitRepo, } from "../automations/grant-rules.js";
|
|
17
|
+
import { AutomationStore } from "../automations/store.js";
|
|
18
|
+
import { unattendedTaskRunOf } from "../automations/unattended.js";
|
|
15
19
|
import { EventLog } from "../conversations/event-log.js";
|
|
16
20
|
import { COMMAND_ASK_TEXT_MAX_CHARS, GIT_ASK_MAX_REFS, GIT_REF_MAX_CHARS, NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS, SECURE_INPUT_MAX_FIELDS, } from "../conversations/events.js";
|
|
17
21
|
import { ConversationLeakCheck } from "../conversations/leak-check.js";
|
|
@@ -38,10 +42,6 @@ import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js
|
|
|
38
42
|
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
39
43
|
import { isSessionGrantableRule } from "../sandbox/review/types.js";
|
|
40
44
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
41
|
-
import { readScheduleSettings } from "../schedules/effective-settings.js";
|
|
42
|
-
import { GIT_GRANT_SPEC_HASH, gitGrantRefusal, gitPushGrantKey, grantRefusalOf, NETWORK_GRANT_PREFIX, NETWORK_GRANT_SPEC_HASH, networkGrantRefusal, normalizeGitRepo, } from "../schedules/grant-rules.js";
|
|
43
|
-
import { ScheduledTaskStore } from "../schedules/store.js";
|
|
44
|
-
import { unattendedTaskRunOf } from "../schedules/unattended.js";
|
|
45
45
|
import { gitPushPolicyName, personalAuth } from "./connector-account-policies.js";
|
|
46
46
|
import { pluginDisplayNames } from "./display-names.js";
|
|
47
47
|
import { ToolRegistry } from "./registry.js";
|
|
@@ -218,7 +218,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
218
218
|
eventLog;
|
|
219
219
|
events;
|
|
220
220
|
txHost;
|
|
221
|
-
|
|
221
|
+
automations;
|
|
222
222
|
registry;
|
|
223
223
|
lockService;
|
|
224
224
|
sandbox;
|
|
@@ -228,7 +228,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
228
228
|
devices;
|
|
229
229
|
permissionLocks;
|
|
230
230
|
permissionGrants;
|
|
231
|
-
constructor(db, config, eventLog, events, txHost,
|
|
231
|
+
constructor(db, config, eventLog, events, txHost, automations,
|
|
232
232
|
/** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
|
|
233
233
|
registry,
|
|
234
234
|
/** One decision of a network ask at a time, across replicas. */
|
|
@@ -248,7 +248,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
248
248
|
this.eventLog = eventLog;
|
|
249
249
|
this.events = events;
|
|
250
250
|
this.txHost = txHost;
|
|
251
|
-
this.
|
|
251
|
+
this.automations = automations;
|
|
252
252
|
this.registry = registry;
|
|
253
253
|
this.lockService = lockService;
|
|
254
254
|
this.sandbox = sandbox;
|
|
@@ -1481,7 +1481,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1481
1481
|
return { record: toRecord(updated), toSeq: Math.max(...written.map((e) => e.seq)) };
|
|
1482
1482
|
}
|
|
1483
1483
|
/**
|
|
1484
|
-
* A trial run of
|
|
1484
|
+
* A trial run of an automation (scheduled tasks spec §7): an approval its creator granted, in
|
|
1485
1485
|
* any scope, is also added to the task's grants with the approved definition's hash, so its
|
|
1486
1486
|
* unattended runs do not ask again. Kept only by the rule `addGrants` applies
|
|
1487
1487
|
* (`grantRefusalOf`, against the task agent's tools now): never a role-escalated approval
|
|
@@ -1500,7 +1500,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1500
1500
|
if (served === null || !served.trial)
|
|
1501
1501
|
return;
|
|
1502
1502
|
const task = await t
|
|
1503
|
-
.selectFrom("
|
|
1503
|
+
.selectFrom("automations as s")
|
|
1504
1504
|
.innerJoin("agents as ag", "ag.id", "s.agent_id")
|
|
1505
1505
|
.leftJoin("agent_versions as v", (j) => j.onRef("v.agent_id", "=", "ag.id").onRef("v.version", "=", "ag.current_version"))
|
|
1506
1506
|
.select(["s.account_id", "v.definition"])
|
|
@@ -1527,21 +1527,21 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1527
1527
|
source: await conversationSourceOf(t, a.conversationId),
|
|
1528
1528
|
});
|
|
1529
1529
|
const tool = tools.find((x) => x.key === a.toolKey);
|
|
1530
|
-
const { forbiddenTools } = await
|
|
1530
|
+
const { forbiddenTools } = await readAutomationSettings(t, this.config, a.orgId);
|
|
1531
1531
|
const why = grantRefusalOf(a.toolKey, tool, {
|
|
1532
1532
|
role: member.role,
|
|
1533
1533
|
forbiddenTools,
|
|
1534
1534
|
});
|
|
1535
1535
|
if (why !== null)
|
|
1536
1536
|
return;
|
|
1537
|
-
await this.
|
|
1537
|
+
await this.automations.addGrant(t, served.taskId, {
|
|
1538
1538
|
toolKey: a.toolKey,
|
|
1539
1539
|
specHash: a.specHash,
|
|
1540
1540
|
connectorId: a.connectorId,
|
|
1541
1541
|
});
|
|
1542
1542
|
}
|
|
1543
1543
|
/**
|
|
1544
|
-
* A trial run of
|
|
1544
|
+
* A trial run of an automation (network ask-to-allow spec §8.1): the hosts its creator allowed
|
|
1545
1545
|
* for this run (「这次允许」) on a network ask about one of their devices become the task's
|
|
1546
1546
|
* `network:<host>` grants, each only when `networkGrantRefusal` allows it (exact host, within the
|
|
1547
1547
|
* org's effective egress, the device takes remote grants). Never for an ask another account
|
|
@@ -1557,7 +1557,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1557
1557
|
if (served === null || !served.trial)
|
|
1558
1558
|
return;
|
|
1559
1559
|
const task = await t
|
|
1560
|
-
.selectFrom("
|
|
1560
|
+
.selectFrom("automations")
|
|
1561
1561
|
.select("account_id")
|
|
1562
1562
|
.where("id", "=", served.taskId)
|
|
1563
1563
|
.where("org_id", "=", a.orgId)
|
|
@@ -1570,7 +1570,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1570
1570
|
if (networkGrantRefusal(host, { limits }) !== null) {
|
|
1571
1571
|
continue;
|
|
1572
1572
|
}
|
|
1573
|
-
await this.
|
|
1573
|
+
await this.automations.addGrant(t, served.taskId, {
|
|
1574
1574
|
toolKey: `${NETWORK_GRANT_PREFIX}${host}`,
|
|
1575
1575
|
specHash: NETWORK_GRANT_SPEC_HASH,
|
|
1576
1576
|
connectorId: null,
|
|
@@ -1598,7 +1598,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1598
1598
|
.execute();
|
|
1599
1599
|
}
|
|
1600
1600
|
/**
|
|
1601
|
-
* A trial run of
|
|
1601
|
+
* A trial run of an automation (sandbox git credentials spec §7): a push its creator allowed
|
|
1602
1602
|
* for this run (「这次允许」) becomes the task's `git:push:<owner>/<repo>` grant, when
|
|
1603
1603
|
* `gitGrantRefusal` allows it (the org does not forbid it). Never for an ask another account
|
|
1604
1604
|
* decided or one asked of someone else. In the decision's transaction.
|
|
@@ -1613,7 +1613,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1613
1613
|
if (served === null || !served.trial)
|
|
1614
1614
|
return;
|
|
1615
1615
|
const task = await t
|
|
1616
|
-
.selectFrom("
|
|
1616
|
+
.selectFrom("automations")
|
|
1617
1617
|
.select("account_id")
|
|
1618
1618
|
.where("id", "=", served.taskId)
|
|
1619
1619
|
.where("org_id", "=", a.orgId)
|
|
@@ -1622,10 +1622,10 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1622
1622
|
if (task?.account_id !== decidedBy)
|
|
1623
1623
|
return;
|
|
1624
1624
|
const key = gitPushGrantKey(a.git.repo);
|
|
1625
|
-
const { forbiddenTools } = await
|
|
1625
|
+
const { forbiddenTools } = await readAutomationSettings(t, this.config, a.orgId);
|
|
1626
1626
|
if (gitGrantRefusal(key, { forbiddenTools }) !== null)
|
|
1627
1627
|
return;
|
|
1628
|
-
await this.
|
|
1628
|
+
await this.automations.addGrant(t, served.taskId, {
|
|
1629
1629
|
toolKey: key,
|
|
1630
1630
|
specHash: GIT_GRANT_SPEC_HASH,
|
|
1631
1631
|
connectorId: null,
|
|
@@ -2189,7 +2189,7 @@ ApprovalsService = __decorate([
|
|
|
2189
2189
|
__param(2, Inject(EventLog)),
|
|
2190
2190
|
__param(3, Inject(KernelEvents)),
|
|
2191
2191
|
__param(4, Inject(TransactionHost)),
|
|
2192
|
-
__param(5, Inject(
|
|
2192
|
+
__param(5, Inject(AutomationStore)),
|
|
2193
2193
|
__param(6, Inject(ToolRegistry)),
|
|
2194
2194
|
__param(7, Inject(LockService)),
|
|
2195
2195
|
__param(8, Inject(SandboxService)),
|
|
@@ -29,11 +29,11 @@ export declare const BUILTIN: {
|
|
|
29
29
|
readonly GenerateImage: "GenerateImage";
|
|
30
30
|
readonly Platform: "Platform";
|
|
31
31
|
readonly CurrentTime: "CurrentTime";
|
|
32
|
-
readonly
|
|
33
|
-
readonly
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
32
|
+
readonly AutomationCreate: "AutomationCreate";
|
|
33
|
+
readonly AutomationUpdate: "AutomationUpdate";
|
|
34
|
+
readonly AutomationList: "AutomationList";
|
|
35
|
+
readonly AutomationTargets: "AutomationTargets";
|
|
36
|
+
readonly AutomationDelete: "AutomationDelete";
|
|
37
37
|
};
|
|
38
38
|
export type BuiltinName = (typeof BUILTIN)[keyof typeof BUILTIN];
|
|
39
39
|
/**
|
|
@@ -56,11 +56,11 @@ export declare const BASH_COMPANION_TOOLS: readonly BuiltinName[];
|
|
|
56
56
|
*/
|
|
57
57
|
export declare const SANDBOX_ASK_TOOL_NAMES: ReadonlySet<string>;
|
|
58
58
|
/**
|
|
59
|
-
* The builtins that manage the person's
|
|
59
|
+
* The builtins that manage the person's automations (scheduled tasks spec §11): create and
|
|
60
60
|
* update are fixed asks ({@link R3_FIXED_ASK_TOOL_KEYS}), list, targets and delete only read or
|
|
61
61
|
* narrow.
|
|
62
62
|
*/
|
|
63
|
-
export declare const
|
|
63
|
+
export declare const AUTOMATION_TOOL_NAMES: readonly BuiltinName[];
|
|
64
64
|
/**
|
|
65
65
|
* Every builtin name. Saving an agent checks turned-off builtins against this list, not against
|
|
66
66
|
* what is registered now, so the order the implementations land in never affects a saved
|
|
@@ -69,8 +69,8 @@ export declare const SCHEDULE_TOOL_NAMES: readonly BuiltinName[];
|
|
|
69
69
|
* `SendMessage` and `SubagentHandback` are added by the registry ({@link SUBAGENT_MESSAGE_TOOLS}).
|
|
70
70
|
* `Platform` calls the platform's own operations as the run's person (Platform tool spec).
|
|
71
71
|
* `CurrentTime` reads the clock (the run context carries only the date). `GenerateImage` makes
|
|
72
|
-
* images with the org's `image` purpose model (image generation spec §5.3). The
|
|
73
|
-
* manage the person's
|
|
72
|
+
* images with the org's `image` purpose model (image generation spec §5.3). The automation tools
|
|
73
|
+
* manage the person's automations ({@link AUTOMATION_TOOL_NAMES}).
|
|
74
74
|
*/
|
|
75
75
|
export declare const BUILTIN_TOOL_NAMES: readonly BuiltinName[];
|
|
76
76
|
/** The builtin that loads a skill (added by the registry when the log has a skills catalog). */
|
|
@@ -92,7 +92,7 @@ export declare const SUBAGENT_MESSAGE_TOOLS: ReadonlySet<string>;
|
|
|
92
92
|
/**
|
|
93
93
|
/**
|
|
94
94
|
* Tool keys on the spec 3.6 R3 fixed list ("allowed is not confirmed"): their policy is at least
|
|
95
|
-
* `ask` and remembered grants never let them through. `
|
|
95
|
+
* `ask` and remembered grants never let them through. `AutomationCreate` and `AutomationUpdate` set
|
|
96
96
|
* what a task runs unattended, so a person approves every task an agent creates or widens
|
|
97
97
|
* (scheduled tasks spec §11), never covered by a task grant and refused in an unattended run in
|
|
98
98
|
* `fail` mode. Connector and extension tools express the same rule with
|
|
@@ -101,11 +101,11 @@ export declare const SUBAGENT_MESSAGE_TOOLS: ReadonlySet<string>;
|
|
|
101
101
|
export declare const R3_FIXED_ASK_TOOL_KEYS: ReadonlySet<string>;
|
|
102
102
|
/**
|
|
103
103
|
* Tools a sub-agent never gets (sub-agents spec §5.3, §5.5): `AskUserQuestion` (the person does
|
|
104
|
-
* not see the child), `Deliver` (delivering files is the parent's job) and the
|
|
104
|
+
* not see the child), `Deliver` (delivering files is the parent's job) and the automation tools (a
|
|
105
105
|
* person manages tasks from the conversation they see, never from a child). `Agent` is removed
|
|
106
106
|
* only from a child at `subagents.maxDepth` (agent map spec §4.1, `effectiveDefinition`).
|
|
107
107
|
*/
|
|
108
|
-
export declare const CHILD_REMOVED_TOOLS: readonly ["AskUserQuestion", "Deliver", "
|
|
108
|
+
export declare const CHILD_REMOVED_TOOLS: readonly ["AskUserQuestion", "Deliver", "AutomationCreate", "AutomationUpdate", "AutomationList", "AutomationTargets", "AutomationDelete"];
|
|
109
109
|
/**
|
|
110
110
|
* The builtins every agent has unless it turns them off (tools default-on spec §4), in this
|
|
111
111
|
* order: {@link BUILTIN_TOOL_NAMES} without the ones the registry manages by rule (`ToolSearch`,
|
|
@@ -28,11 +28,11 @@ export const BUILTIN = {
|
|
|
28
28
|
GenerateImage: "GenerateImage",
|
|
29
29
|
Platform: "Platform",
|
|
30
30
|
CurrentTime: "CurrentTime",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
AutomationCreate: "AutomationCreate",
|
|
32
|
+
AutomationUpdate: "AutomationUpdate",
|
|
33
|
+
AutomationList: "AutomationList",
|
|
34
|
+
AutomationTargets: "AutomationTargets",
|
|
35
|
+
AutomationDelete: "AutomationDelete",
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* The builtin tools that run in the conversation's sandbox. `TaskOutput` and `TaskStop` read and
|
|
@@ -75,16 +75,16 @@ export const SANDBOX_ASK_TOOL_NAMES = new Set([
|
|
|
75
75
|
BUILTIN.Deliver,
|
|
76
76
|
]);
|
|
77
77
|
/**
|
|
78
|
-
* The builtins that manage the person's
|
|
78
|
+
* The builtins that manage the person's automations (scheduled tasks spec §11): create and
|
|
79
79
|
* update are fixed asks ({@link R3_FIXED_ASK_TOOL_KEYS}), list, targets and delete only read or
|
|
80
80
|
* narrow.
|
|
81
81
|
*/
|
|
82
|
-
export const
|
|
83
|
-
BUILTIN.
|
|
84
|
-
BUILTIN.
|
|
85
|
-
BUILTIN.
|
|
86
|
-
BUILTIN.
|
|
87
|
-
BUILTIN.
|
|
82
|
+
export const AUTOMATION_TOOL_NAMES = [
|
|
83
|
+
BUILTIN.AutomationCreate,
|
|
84
|
+
BUILTIN.AutomationUpdate,
|
|
85
|
+
BUILTIN.AutomationList,
|
|
86
|
+
BUILTIN.AutomationTargets,
|
|
87
|
+
BUILTIN.AutomationDelete,
|
|
88
88
|
];
|
|
89
89
|
/**
|
|
90
90
|
* Every builtin name. Saving an agent checks turned-off builtins against this list, not against
|
|
@@ -94,8 +94,8 @@ export const SCHEDULE_TOOL_NAMES = [
|
|
|
94
94
|
* `SendMessage` and `SubagentHandback` are added by the registry ({@link SUBAGENT_MESSAGE_TOOLS}).
|
|
95
95
|
* `Platform` calls the platform's own operations as the run's person (Platform tool spec).
|
|
96
96
|
* `CurrentTime` reads the clock (the run context carries only the date). `GenerateImage` makes
|
|
97
|
-
* images with the org's `image` purpose model (image generation spec §5.3). The
|
|
98
|
-
* manage the person's
|
|
97
|
+
* images with the org's `image` purpose model (image generation spec §5.3). The automation tools
|
|
98
|
+
* manage the person's automations ({@link AUTOMATION_TOOL_NAMES}).
|
|
99
99
|
*/
|
|
100
100
|
export const BUILTIN_TOOL_NAMES = [
|
|
101
101
|
BUILTIN.AskUserQuestion,
|
|
@@ -110,7 +110,7 @@ export const BUILTIN_TOOL_NAMES = [
|
|
|
110
110
|
BUILTIN.GenerateImage,
|
|
111
111
|
BUILTIN.Platform,
|
|
112
112
|
BUILTIN.CurrentTime,
|
|
113
|
-
...
|
|
113
|
+
...AUTOMATION_TOOL_NAMES,
|
|
114
114
|
];
|
|
115
115
|
/** The builtin that loads a skill (added by the registry when the log has a skills catalog). */
|
|
116
116
|
export const SKILL_LOAD = BUILTIN.Skill;
|
|
@@ -134,30 +134,30 @@ export const SUBAGENT_MESSAGE_TOOLS = new Set([
|
|
|
134
134
|
/**
|
|
135
135
|
/**
|
|
136
136
|
* Tool keys on the spec 3.6 R3 fixed list ("allowed is not confirmed"): their policy is at least
|
|
137
|
-
* `ask` and remembered grants never let them through. `
|
|
137
|
+
* `ask` and remembered grants never let them through. `AutomationCreate` and `AutomationUpdate` set
|
|
138
138
|
* what a task runs unattended, so a person approves every task an agent creates or widens
|
|
139
139
|
* (scheduled tasks spec §11), never covered by a task grant and refused in an unattended run in
|
|
140
140
|
* `fail` mode. Connector and extension tools express the same rule with
|
|
141
141
|
* `annotations.requiresUserInteraction`.
|
|
142
142
|
*/
|
|
143
143
|
export const R3_FIXED_ASK_TOOL_KEYS = new Set([
|
|
144
|
-
BUILTIN.
|
|
145
|
-
BUILTIN.
|
|
144
|
+
BUILTIN.AutomationCreate,
|
|
145
|
+
BUILTIN.AutomationUpdate,
|
|
146
146
|
]);
|
|
147
147
|
/**
|
|
148
148
|
* Tools a sub-agent never gets (sub-agents spec §5.3, §5.5): `AskUserQuestion` (the person does
|
|
149
|
-
* not see the child), `Deliver` (delivering files is the parent's job) and the
|
|
149
|
+
* not see the child), `Deliver` (delivering files is the parent's job) and the automation tools (a
|
|
150
150
|
* person manages tasks from the conversation they see, never from a child). `Agent` is removed
|
|
151
151
|
* only from a child at `subagents.maxDepth` (agent map spec §4.1, `effectiveDefinition`).
|
|
152
152
|
*/
|
|
153
153
|
export const CHILD_REMOVED_TOOLS = [
|
|
154
154
|
BUILTIN.AskUserQuestion,
|
|
155
155
|
BUILTIN.Deliver,
|
|
156
|
-
BUILTIN.
|
|
157
|
-
BUILTIN.
|
|
158
|
-
BUILTIN.
|
|
159
|
-
BUILTIN.
|
|
160
|
-
BUILTIN.
|
|
156
|
+
BUILTIN.AutomationCreate,
|
|
157
|
+
BUILTIN.AutomationUpdate,
|
|
158
|
+
BUILTIN.AutomationList,
|
|
159
|
+
BUILTIN.AutomationTargets,
|
|
160
|
+
BUILTIN.AutomationDelete,
|
|
161
161
|
];
|
|
162
162
|
/**
|
|
163
163
|
* The builtins every agent has unless it turns them off (tools default-on spec §4), in this
|
|
@@ -194,11 +194,11 @@ export const BUILTIN_TOOL_KINDS = {
|
|
|
194
194
|
[BUILTIN.GenerateImage]: "tool",
|
|
195
195
|
[BUILTIN.Platform]: "tool",
|
|
196
196
|
[BUILTIN.CurrentTime]: "tool",
|
|
197
|
-
[BUILTIN.
|
|
198
|
-
[BUILTIN.
|
|
199
|
-
[BUILTIN.
|
|
200
|
-
[BUILTIN.
|
|
201
|
-
[BUILTIN.
|
|
197
|
+
[BUILTIN.AutomationCreate]: "tool",
|
|
198
|
+
[BUILTIN.AutomationUpdate]: "tool",
|
|
199
|
+
[BUILTIN.AutomationList]: "tool",
|
|
200
|
+
[BUILTIN.AutomationTargets]: "tool",
|
|
201
|
+
[BUILTIN.AutomationDelete]: "tool",
|
|
202
202
|
};
|
|
203
203
|
/**
|
|
204
204
|
* Input fields left out when matching a replayed call with a recorded one (full-run replay), per
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import type { AutomationsService, UpdateTaskInput } from "../../automations/automations.service.js";
|
|
2
|
+
import { AutomationStore } from "../../automations/store.js";
|
|
3
|
+
import type { Automation, AutomationChat, AutomationTrigger } from "../../automations/types.js";
|
|
1
4
|
import type { KernelSchemaDb } from "../../db/kernel-schema.js";
|
|
2
5
|
import { ApiError } from "../../errors.js";
|
|
3
6
|
import type { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
4
7
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
5
8
|
import { TransactionHost } from "../../infra/database/transaction-host.js";
|
|
6
|
-
import type { ScheduledTasksService, UpdateTaskInput } from "../../schedules/scheduled-tasks.service.js";
|
|
7
|
-
import { ScheduledTaskStore } from "../../schedules/store.js";
|
|
8
|
-
import type { ScheduleChat, ScheduledTask, ScheduleTrigger } from "../../schedules/types.js";
|
|
9
9
|
import type { BuiltinTool } from "../registry.js";
|
|
10
10
|
/**
|
|
11
|
-
* The
|
|
12
|
-
* `
|
|
13
|
-
* trigger account through the same service as the HTTP routes (`
|
|
11
|
+
* The automation builtins (scheduled tasks spec §11): `AutomationCreate`, `AutomationUpdate`,
|
|
12
|
+
* `AutomationList`, `AutomationTargets` and `AutomationDelete` manage the automations of the run's
|
|
13
|
+
* trigger account through the same service as the HTTP routes (`AutomationsService`), so the
|
|
14
14
|
* org's limits and the grant rules apply unchanged.
|
|
15
15
|
*
|
|
16
|
-
* - `
|
|
16
|
+
* - `AutomationCreate` / `AutomationUpdate` are fixed asks (R3, `R3_FIXED_ASK_TOOL_KEYS`) with a
|
|
17
17
|
* per-call policy that never remembers: every call asks, no grant (conversation, always or task)
|
|
18
18
|
* covers it, and an unattended run in `fail` mode is refused. The approval card's summary is
|
|
19
19
|
* rendered here, by the kernel, from the input and the stored task: name, schedule in words with
|
|
@@ -21,9 +21,9 @@ import type { BuiltinTool } from "../registry.js";
|
|
|
21
21
|
* - The approved tools of a task are exactly the `approvedTools` of the approved input: create
|
|
22
22
|
* grants that list, and an update that passes it replaces the task's grants with it (the card
|
|
23
23
|
* lists the full new set), so nothing beyond what the person saw is ever granted.
|
|
24
|
-
* - `
|
|
24
|
+
* - `AutomationList` (allow) lists the person's own tasks; `AutomationTargets` (allow) lists the IM
|
|
25
25
|
* chats they can deliver to (the service's `chatTargets`, the same data as the route);
|
|
26
|
-
* `
|
|
26
|
+
* `AutomationDelete` (allow; deleting only narrows) deletes only the person's own task, even when
|
|
27
27
|
* they are an org admin.
|
|
28
28
|
* - `mode: "here"`: a `chat` task for this conversation's IM direct chat when the conversation is
|
|
29
29
|
* delivered to one (`channel_deliveries`) and is the live DM thread of the person
|
|
@@ -31,42 +31,42 @@ import type { BuiltinTool } from "../registry.js";
|
|
|
31
31
|
* the IM chat named by `chat`. The zone is the run's (`run_context`, else the org's, else UTC).
|
|
32
32
|
*/
|
|
33
33
|
/** The task service as the tools use it (bound at start; null when not loaded here). */
|
|
34
|
-
export type
|
|
34
|
+
export type AutomationService = Pick<AutomationsService, "create" | "update" | "list" | "remove" | "addGrants" | "removeGrant" | "chatTargets">;
|
|
35
35
|
/**
|
|
36
|
-
* Where the
|
|
36
|
+
* Where the automation tools find the task service: a registration port. `AutomationsModule` imports
|
|
37
37
|
* `ToolsModule` (its grants resolve the agent's tools through `ToolRegistry`, which lists these
|
|
38
|
-
* builtins), so the service cannot be injected into the builtins; `
|
|
38
|
+
* builtins), so the service cannot be injected into the builtins; `AutomationsModule` binds it here
|
|
39
39
|
* from `onModuleInit` instead, as the domain operations register into `PlatformOperations`. Null
|
|
40
|
-
* until bound (an application without `
|
|
40
|
+
* until bound (an application without `AutomationsModule`).
|
|
41
41
|
*/
|
|
42
|
-
export declare class
|
|
42
|
+
export declare class AutomationToolsPort {
|
|
43
43
|
private service;
|
|
44
|
-
bind(service:
|
|
45
|
-
get():
|
|
44
|
+
bind(service: AutomationService): void;
|
|
45
|
+
get(): AutomationService | null;
|
|
46
46
|
}
|
|
47
|
-
export interface
|
|
47
|
+
export interface AutomationToolsDeps {
|
|
48
48
|
/** The kernel-schema handle of the current context. */
|
|
49
49
|
db: () => KernelSchemaDb;
|
|
50
50
|
config: Pick<KernelConfigService, "get">;
|
|
51
|
-
store: Pick<
|
|
51
|
+
store: Pick<AutomationStore, "getTask" | "listGrants">;
|
|
52
52
|
/** The task service, or null when this application does not load it. */
|
|
53
|
-
service: () =>
|
|
54
|
-
/** `
|
|
55
|
-
updates: Pick<
|
|
53
|
+
service: () => AutomationService | null;
|
|
54
|
+
/** `AutomationUpdate`'s write (its field change and grant changes commit together). */
|
|
55
|
+
updates: Pick<AutomationUpdates, "apply">;
|
|
56
56
|
/** The conversation's zone: its latest `run_context`, else the org's, else UTC. */
|
|
57
57
|
timeZoneOf: (orgId: string, conversationId: string) => Promise<string>;
|
|
58
58
|
/** The clock (epoch ms), for the next run shown on cards and lists. */
|
|
59
59
|
now: () => number;
|
|
60
60
|
}
|
|
61
|
-
export declare const
|
|
62
|
-
export declare const
|
|
61
|
+
export declare const AUTOMATIONS_UNAVAILABLE_TEXT = "Automations are not available on this server; ask the user to manage the task on the automations page instead.";
|
|
62
|
+
export declare const AUTOMATIONS_OFF_TEXT = "Automations are turned off in this organization; ask an org admin to turn them on.";
|
|
63
63
|
/** The card recomputed at run time differs from the one the person approved. */
|
|
64
64
|
export declare const cardChangedText: (tool: string) => string;
|
|
65
|
-
export declare const NOT_A_MEMBER_TEXT = "The user is no longer a member of this organization, so their
|
|
65
|
+
export declare const NOT_A_MEMBER_TEXT = "The user is no longer a member of this organization, so their automations cannot be managed here; ask them to check their membership.";
|
|
66
66
|
/** No task with that id is the person's own (missing, deleted, or another member's). */
|
|
67
67
|
export declare const notYoursText: (id: string) => string;
|
|
68
68
|
/** The service's refusal as an actionable English tool error. */
|
|
69
|
-
export declare function
|
|
69
|
+
export declare function automationErrorText(e: ApiError, ctx: {
|
|
70
70
|
id?: string;
|
|
71
71
|
zone?: string;
|
|
72
72
|
}): string;
|
|
@@ -75,7 +75,7 @@ type Words = {
|
|
|
75
75
|
en: string;
|
|
76
76
|
};
|
|
77
77
|
/** A trigger in words, its zone included; an unusual cron reads as the expression itself. */
|
|
78
|
-
export declare function scheduleWords(t:
|
|
78
|
+
export declare function scheduleWords(t: AutomationTrigger): Words;
|
|
79
79
|
/** Where a task's runs go, resolved for a card or a result. */
|
|
80
80
|
export type Target = {
|
|
81
81
|
mode: "new";
|
|
@@ -84,8 +84,10 @@ export type Target = {
|
|
|
84
84
|
conversationId: string;
|
|
85
85
|
} | {
|
|
86
86
|
mode: "chat";
|
|
87
|
-
chat:
|
|
87
|
+
chat: AutomationChat;
|
|
88
88
|
connectionName: string;
|
|
89
|
+
} | {
|
|
90
|
+
mode: "subject";
|
|
89
91
|
};
|
|
90
92
|
/**
|
|
91
93
|
* `mode: "here"` (spec §8): the conversation's IM direct chat when the conversation is delivered
|
|
@@ -93,17 +95,17 @@ export type Target = {
|
|
|
93
95
|
*/
|
|
94
96
|
export declare function hereTarget(db: KernelSchemaDb, orgId: string, accountId: string, conversationId: string): Promise<Target>;
|
|
95
97
|
/**
|
|
96
|
-
* `
|
|
98
|
+
* `AutomationUpdate`'s write in one transaction: the field change, then (with `approvedTools`) the
|
|
97
99
|
* task's grants replaced by exactly that list. Each service call is `@Transactional` and joins
|
|
98
100
|
* this one, so a refused grant rolls the field change back too.
|
|
99
101
|
*/
|
|
100
|
-
export declare class
|
|
102
|
+
export declare class AutomationUpdates {
|
|
101
103
|
readonly txHost: TransactionHost;
|
|
102
104
|
private readonly db;
|
|
103
105
|
private readonly store;
|
|
104
|
-
constructor(txHost: TransactionHost, db: KernelDb, store:
|
|
105
|
-
apply(svc: Pick<
|
|
106
|
+
constructor(txHost: TransactionHost, db: KernelDb, store: AutomationStore);
|
|
107
|
+
apply(svc: Pick<AutomationService, "update" | "addGrants" | "removeGrant">, orgId: string, accountId: string, task: Automation, patch: UpdateTaskInput, approvedTools: readonly string[] | undefined): Promise<Automation>;
|
|
106
108
|
}
|
|
107
|
-
/** The five
|
|
108
|
-
export declare function
|
|
109
|
+
/** The five automation builtins. */
|
|
110
|
+
export declare function automationTools(deps: AutomationToolsDeps): BuiltinTool[];
|
|
109
111
|
export {};
|