@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/agents/agents.schemas.d.ts +9 -9
  2. package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
  3. package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
  4. package/dist/automations/automations.module.d.ts +16 -0
  5. package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
  6. package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
  7. package/dist/automations/automations.schemas.js +253 -0
  8. package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
  9. package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
  10. package/dist/{schedules → automations}/calendar.d.ts +8 -8
  11. package/dist/{schedules → automations}/calendar.js +2 -2
  12. package/dist/automations/effective-settings.d.ts +28 -0
  13. package/dist/automations/effective-settings.js +25 -0
  14. package/dist/automations/errors.d.ts +19 -0
  15. package/dist/automations/errors.js +19 -0
  16. package/dist/automations/events/coalesce.d.ts +28 -0
  17. package/dist/automations/events/coalesce.js +131 -0
  18. package/dist/automations/events/deadline.d.ts +10 -0
  19. package/dist/automations/events/deadline.js +24 -0
  20. package/dist/automations/events/dispatcher.d.ts +74 -0
  21. package/dist/automations/events/dispatcher.js +353 -0
  22. package/dist/automations/events/events.module.d.ts +7 -0
  23. package/dist/automations/events/events.module.js +26 -0
  24. package/dist/automations/events/guards.d.ts +32 -0
  25. package/dist/automations/events/guards.js +87 -0
  26. package/dist/automations/events/sweep.job.d.ts +49 -0
  27. package/dist/automations/events/sweep.job.js +202 -0
  28. package/dist/automations/events/token.d.ts +5 -0
  29. package/dist/automations/events/token.js +5 -0
  30. package/dist/automations/events/trigger-events.service.d.ts +47 -0
  31. package/dist/automations/events/trigger-events.service.js +254 -0
  32. package/dist/{schedules → automations}/fire.d.ts +57 -17
  33. package/dist/{schedules → automations}/fire.js +311 -79
  34. package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
  35. package/dist/{schedules → automations}/grant-rules.js +5 -5
  36. package/dist/automations/job-ids.d.ts +113 -0
  37. package/dist/automations/job-ids.js +117 -0
  38. package/dist/{schedules → automations}/pause.d.ts +3 -3
  39. package/dist/{schedules → automations}/pause.js +3 -3
  40. package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
  41. package/dist/{schedules → automations}/run-tracker.js +68 -56
  42. package/dist/{schedules → automations}/scan.job.d.ts +12 -8
  43. package/dist/{schedules → automations}/scan.job.js +39 -23
  44. package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
  45. package/dist/{schedules → automations}/schedule-math.js +17 -7
  46. package/dist/{schedules → automations}/store.d.ts +57 -27
  47. package/dist/{schedules → automations}/store.js +102 -52
  48. package/dist/automations/store.module.d.ts +6 -0
  49. package/dist/{schedules → automations}/store.module.js +9 -9
  50. package/dist/automations/types.d.ts +178 -0
  51. package/dist/{schedules → automations}/unattended.d.ts +22 -11
  52. package/dist/{schedules → automations}/unattended.js +53 -30
  53. package/dist/catalog/marketplaces.service.d.ts +1 -1
  54. package/dist/channels/channels.module.js +3 -3
  55. package/dist/channels/outbound.d.ts +5 -5
  56. package/dist/channels/outbound.js +17 -17
  57. package/dist/channels/threads.d.ts +1 -1
  58. package/dist/channels/threads.js +1 -1
  59. package/dist/config/schema.d.ts +5 -1
  60. package/dist/config/schema.js +44 -6
  61. package/dist/conversations/approval-profile.d.ts +2 -2
  62. package/dist/conversations/approval-profile.js +3 -3
  63. package/dist/conversations/conversations.controller.d.ts +7 -1
  64. package/dist/conversations/conversations.controller.js +26 -10
  65. package/dist/conversations/conversations.service.d.ts +101 -25
  66. package/dist/conversations/conversations.service.js +132 -32
  67. package/dist/conversations/events.d.ts +46 -0
  68. package/dist/conversations/events.js +54 -3
  69. package/dist/conversations/message-context.d.ts +2 -2
  70. package/dist/conversations/message-context.js +1 -1
  71. package/dist/conversations/permission-profile-store.d.ts +2 -1
  72. package/dist/conversations/permission-profiles.controller.d.ts +3 -0
  73. package/dist/conversations/permission-profiles.service.js +1 -1
  74. package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
  75. package/dist/conversations/prompt-suggestion-request.js +2 -1
  76. package/dist/conversations/queue.d.ts +7 -4
  77. package/dist/conversations/queue.js +6 -2
  78. package/dist/conversations/queue.service.d.ts +5 -5
  79. package/dist/conversations/queue.service.js +20 -14
  80. package/dist/ctx/create-ctx.d.ts +20 -1
  81. package/dist/ctx/create-ctx.js +59 -2
  82. package/dist/db/kernel-schema.d.ts +104 -25
  83. package/dist/devices/device-project-files.service.d.ts +88 -0
  84. package/dist/devices/device-project-files.service.js +249 -0
  85. package/dist/devices/device-projects.service.d.ts +40 -0
  86. package/dist/devices/device-projects.service.js +16 -13
  87. package/dist/devices/devices.controller.d.ts +9 -3
  88. package/dist/devices/devices.controller.js +27 -5
  89. package/dist/devices/devices.module.js +9 -1
  90. package/dist/devices/devices.schemas.js +6 -1
  91. package/dist/devices/dto.d.ts +15 -0
  92. package/dist/devices/dto.js +11 -0
  93. package/dist/devices/project-paths.d.ts +29 -0
  94. package/dist/devices/project-paths.js +66 -0
  95. package/dist/devices/project-rules.d.ts +5 -1
  96. package/dist/devices/project-rules.js +5 -1
  97. package/dist/errors.d.ts +34 -13
  98. package/dist/errors.js +34 -13
  99. package/dist/evals/reconstruct.d.ts +10 -1
  100. package/dist/evals/reconstruct.js +7 -0
  101. package/dist/extensions/host.d.ts +6 -1
  102. package/dist/extensions/host.js +10 -0
  103. package/dist/extensions/permission-set.d.ts +17 -1
  104. package/dist/extensions/permission-set.js +13 -1
  105. package/dist/extensions/permission-view.d.ts +1 -1
  106. package/dist/extensions/permission-view.js +4 -1
  107. package/dist/git/gateway.js +2 -2
  108. package/dist/http/api.module.js +5 -5
  109. package/dist/http/request-signal.d.ts +8 -0
  110. package/dist/http/request-signal.js +14 -0
  111. package/dist/inbox/inbox.module.js +2 -2
  112. package/dist/inbox/inbox.service.d.ts +8 -8
  113. package/dist/inbox/inbox.service.js +7 -7
  114. package/dist/infra/config/kernel-config.service.js +10 -5
  115. package/dist/infra/outbox/registry.d.ts +29 -2
  116. package/dist/infra/outbox/registry.js +30 -7
  117. package/dist/kernel.module.js +3 -0
  118. package/dist/orgs/roles.d.ts +1 -1
  119. package/dist/orgs/roles.js +3 -3
  120. package/dist/orgs/settings.controller.d.ts +1 -1
  121. package/dist/orgs/settings.service.d.ts +27 -11
  122. package/dist/orgs/settings.service.js +42 -24
  123. package/dist/platform/operation.js +2 -2
  124. package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
  125. package/dist/platform/ops/automations.ops.js +560 -0
  126. package/dist/platform/ops/devices.ops.d.ts +3 -1
  127. package/dist/platform/ops/devices.ops.js +77 -3
  128. package/dist/platform/ops/inbox.ops.js +4 -4
  129. package/dist/platform/ops/orgs.ops.js +1 -1
  130. package/dist/platform/ops/platform.ops.js +4 -4
  131. package/dist/platform/platform-ops.module.d.ts +2 -2
  132. package/dist/platform/platform-ops.module.js +5 -5
  133. package/dist/platform/route-schemas.js +3 -3
  134. package/dist/push/jobs.d.ts +3 -3
  135. package/dist/push/jobs.js +2 -2
  136. package/dist/push/preferences.service.js +1 -1
  137. package/dist/push/push-owed.d.ts +3 -3
  138. package/dist/push/push-owed.js +6 -6
  139. package/dist/push/push.schemas.d.ts +4 -4
  140. package/dist/push/push.schemas.js +3 -3
  141. package/dist/push/recipients.d.ts +4 -4
  142. package/dist/push/recipients.js +23 -23
  143. package/dist/push/texts.d.ts +3 -3
  144. package/dist/push/texts.js +2 -2
  145. package/dist/push/triggers.d.ts +1 -1
  146. package/dist/roles/worker.module.js +3 -3
  147. package/dist/runtime/context/build.d.ts +6 -0
  148. package/dist/runtime/context/build.js +14 -3
  149. package/dist/runtime/context/compaction.js +15 -5
  150. package/dist/runtime/context/run-context.d.ts +38 -0
  151. package/dist/runtime/context/run-context.js +54 -0
  152. package/dist/runtime/maintenance.d.ts +8 -4
  153. package/dist/runtime/maintenance.js +37 -16
  154. package/dist/runtime/run-finish.d.ts +4 -4
  155. package/dist/runtime/run-finish.js +3 -3
  156. package/dist/runtime/run-queue.js +12 -7
  157. package/dist/runtime/run-worker.js +7 -1
  158. package/dist/runtime/runtime.module.js +3 -3
  159. package/dist/runtime/subagents/dispatch.js +11 -3
  160. package/dist/sandbox/browse-roots.d.ts +8 -0
  161. package/dist/sandbox/browse-roots.js +22 -0
  162. package/dist/sandbox/network-grants.d.ts +4 -4
  163. package/dist/sandbox/network-grants.js +7 -7
  164. package/dist/sandbox/operation-authority.d.ts +10 -3
  165. package/dist/sandbox/operation-authority.js +20 -10
  166. package/dist/sandbox/operation-intents.d.ts +3 -1
  167. package/dist/sandbox/operation-intents.js +11 -4
  168. package/dist/sandbox/permission-call-grants.js +2 -2
  169. package/dist/sandbox/permission-facts.js +1 -1
  170. package/dist/sandbox/review/classifier.d.ts +2 -2
  171. package/dist/sandbox/review/classifier.js +22 -11
  172. package/dist/sandbox/review/permission-candidate.d.ts +1 -1
  173. package/dist/sandbox/review/permission-candidate.js +1 -1
  174. package/dist/sandbox/sandbox.service.d.ts +15 -5
  175. package/dist/sandbox/sandbox.service.js +14 -8
  176. package/dist/storage/purge.d.ts +1 -1
  177. package/dist/storage/purge.js +2 -2
  178. package/dist/tools/approvals.service.d.ts +6 -6
  179. package/dist/tools/approvals.service.js +19 -19
  180. package/dist/tools/builtin-names.d.ts +12 -12
  181. package/dist/tools/builtin-names.js +29 -29
  182. package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
  183. package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
  184. package/dist/tools/builtins/builtin-tools.d.ts +8 -8
  185. package/dist/tools/builtins/builtin-tools.js +16 -16
  186. package/dist/tools/call-scope.d.ts +1 -1
  187. package/dist/tools/git-asks.js +1 -1
  188. package/dist/tools/git-push-policy.d.ts +3 -3
  189. package/dist/tools/git-push-policy.js +6 -6
  190. package/dist/tools/network-asks.d.ts +3 -3
  191. package/dist/tools/network-asks.js +3 -3
  192. package/dist/tools/pipeline.d.ts +4 -4
  193. package/dist/tools/pipeline.js +2 -2
  194. package/dist/tools/policy.d.ts +3 -3
  195. package/dist/tools/policy.js +3 -3
  196. package/dist/tools/tools.module.js +9 -9
  197. package/package.json +3 -3
  198. package/src/migrations/0188_automations_rename.sql +309 -0
  199. package/src/migrations/0189_event_automations.sql +136 -0
  200. package/dist/platform/ops/schedules.ops.js +0 -509
  201. package/dist/schedules/effective-settings.d.ts +0 -22
  202. package/dist/schedules/effective-settings.js +0 -18
  203. package/dist/schedules/errors.d.ts +0 -8
  204. package/dist/schedules/errors.js +0 -8
  205. package/dist/schedules/job-ids.d.ts +0 -81
  206. package/dist/schedules/job-ids.js +0 -95
  207. package/dist/schedules/schedules.module.d.ts +0 -16
  208. package/dist/schedules/schedules.schemas.js +0 -213
  209. package/dist/schedules/store.module.d.ts +0 -6
  210. package/dist/schedules/types.d.ts +0 -110
  211. /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
- schedules;
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, schedules,
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.schedules = schedules;
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 a scheduled task (scheduled tasks spec §7): an approval its creator granted, in
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("scheduled_tasks as s")
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 readScheduleSettings(t, this.config, a.orgId);
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.schedules.addGrant(t, served.taskId, {
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 a scheduled task (network ask-to-allow spec §8.1): the hosts its creator allowed
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("scheduled_tasks")
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.schedules.addGrant(t, served.taskId, {
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 a scheduled task (sandbox git credentials spec §7): a push its creator allowed
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("scheduled_tasks")
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 readScheduleSettings(t, this.config, a.orgId);
1625
+ const { forbiddenTools } = await readAutomationSettings(t, this.config, a.orgId);
1626
1626
  if (gitGrantRefusal(key, { forbiddenTools }) !== null)
1627
1627
  return;
1628
- await this.schedules.addGrant(t, served.taskId, {
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(ScheduledTaskStore)),
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 ScheduleCreate: "ScheduleCreate";
33
- readonly ScheduleUpdate: "ScheduleUpdate";
34
- readonly ScheduleList: "ScheduleList";
35
- readonly ScheduleTargets: "ScheduleTargets";
36
- readonly ScheduleDelete: "ScheduleDelete";
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 scheduled tasks (scheduled tasks spec §11): create and
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 SCHEDULE_TOOL_NAMES: readonly BuiltinName[];
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 schedule tools
73
- * manage the person's scheduled tasks ({@link SCHEDULE_TOOL_NAMES}).
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. `ScheduleCreate` and `ScheduleUpdate` set
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 schedule tools (a
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", "ScheduleCreate", "ScheduleUpdate", "ScheduleList", "ScheduleTargets", "ScheduleDelete"];
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
- ScheduleCreate: "ScheduleCreate",
32
- ScheduleUpdate: "ScheduleUpdate",
33
- ScheduleList: "ScheduleList",
34
- ScheduleTargets: "ScheduleTargets",
35
- ScheduleDelete: "ScheduleDelete",
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 scheduled tasks (scheduled tasks spec §11): create and
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 SCHEDULE_TOOL_NAMES = [
83
- BUILTIN.ScheduleCreate,
84
- BUILTIN.ScheduleUpdate,
85
- BUILTIN.ScheduleList,
86
- BUILTIN.ScheduleTargets,
87
- BUILTIN.ScheduleDelete,
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 schedule tools
98
- * manage the person's scheduled tasks ({@link SCHEDULE_TOOL_NAMES}).
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
- ...SCHEDULE_TOOL_NAMES,
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. `ScheduleCreate` and `ScheduleUpdate` set
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.ScheduleCreate,
145
- BUILTIN.ScheduleUpdate,
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 schedule tools (a
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.ScheduleCreate,
157
- BUILTIN.ScheduleUpdate,
158
- BUILTIN.ScheduleList,
159
- BUILTIN.ScheduleTargets,
160
- BUILTIN.ScheduleDelete,
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.ScheduleCreate]: "tool",
198
- [BUILTIN.ScheduleUpdate]: "tool",
199
- [BUILTIN.ScheduleList]: "tool",
200
- [BUILTIN.ScheduleTargets]: "tool",
201
- [BUILTIN.ScheduleDelete]: "tool",
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 schedule builtins (scheduled tasks spec §11): `ScheduleCreate`, `ScheduleUpdate`,
12
- * `ScheduleList`, `ScheduleTargets` and `ScheduleDelete` manage the scheduled tasks of the run's
13
- * trigger account through the same service as the HTTP routes (`ScheduledTasksService`), so the
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
- * - `ScheduleCreate` / `ScheduleUpdate` are fixed asks (R3, `R3_FIXED_ASK_TOOL_KEYS`) with a
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
- * - `ScheduleList` (allow) lists the person's own tasks; `ScheduleTargets` (allow) lists the IM
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
- * `ScheduleDelete` (allow; deleting only narrows) deletes only the person's own task, even when
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 ScheduleService = Pick<ScheduledTasksService, "create" | "update" | "list" | "remove" | "addGrants" | "removeGrant" | "chatTargets">;
34
+ export type AutomationService = Pick<AutomationsService, "create" | "update" | "list" | "remove" | "addGrants" | "removeGrant" | "chatTargets">;
35
35
  /**
36
- * Where the schedule tools find the task service: a registration port. `SchedulesModule` imports
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; `SchedulesModule` binds it here
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 `SchedulesModule`).
40
+ * until bound (an application without `AutomationsModule`).
41
41
  */
42
- export declare class ScheduleToolsPort {
42
+ export declare class AutomationToolsPort {
43
43
  private service;
44
- bind(service: ScheduleService): void;
45
- get(): ScheduleService | null;
44
+ bind(service: AutomationService): void;
45
+ get(): AutomationService | null;
46
46
  }
47
- export interface ScheduleToolsDeps {
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<ScheduledTaskStore, "getTask" | "listGrants">;
51
+ store: Pick<AutomationStore, "getTask" | "listGrants">;
52
52
  /** The task service, or null when this application does not load it. */
53
- service: () => ScheduleService | null;
54
- /** `ScheduleUpdate`'s write (its field change and grant changes commit together). */
55
- updates: Pick<ScheduleUpdates, "apply">;
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 SCHEDULES_UNAVAILABLE_TEXT = "Scheduled tasks are not available on this server; ask the user to manage the task on the scheduled tasks page instead.";
62
- export declare const SCHEDULES_OFF_TEXT = "Scheduled tasks are turned off in this organization; ask an org admin to turn them on.";
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 scheduled tasks cannot be managed here; ask them to check their membership.";
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 scheduleErrorText(e: ApiError, ctx: {
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: ScheduleTrigger): Words;
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: ScheduleChat;
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
- * `ScheduleUpdate`'s write in one transaction: the field change, then (with `approvedTools`) the
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 ScheduleUpdates {
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: ScheduledTaskStore);
105
- apply(svc: Pick<ScheduleService, "update" | "addGrants" | "removeGrant">, orgId: string, accountId: string, task: ScheduledTask, patch: UpdateTaskInput, approvedTools: readonly string[] | undefined): Promise<ScheduledTask>;
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 schedule builtins. */
108
- export declare function scheduleTools(deps: ScheduleToolsDeps): BuiltinTool[];
109
+ /** The five automation builtins. */
110
+ export declare function automationTools(deps: AutomationToolsDeps): BuiltinTool[];
109
111
  export {};