@capybara-hq/kernel 0.1.0-rc.36 → 0.1.0-rc.37

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 (309) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.d.ts +3 -3
  3. package/dist/admin/admin.module.js +6 -6
  4. package/dist/admin/audit-log.service.d.ts +51 -0
  5. package/dist/admin/{platform-audit.service.js → audit-log.service.js} +20 -12
  6. package/dist/admin/audit.controller.d.ts +18 -6
  7. package/dist/admin/audit.controller.js +36 -6
  8. package/dist/admin/audit.schemas.d.ts +9 -1
  9. package/dist/admin/audit.schemas.js +22 -2
  10. package/dist/admin/outbox-dead.controller.d.ts +4 -6
  11. package/dist/admin/outbox-dead.controller.js +9 -6
  12. package/dist/admin/outbox-dead.schemas.d.ts +16 -0
  13. package/dist/admin/outbox-dead.schemas.js +25 -1
  14. package/dist/admin/outbox-dead.service.d.ts +16 -7
  15. package/dist/admin/outbox-dead.service.js +34 -10
  16. package/dist/admin/overview.service.d.ts +3 -3
  17. package/dist/admin/overview.service.js +0 -1
  18. package/dist/agents/agent-lookup.js +2 -10
  19. package/dist/agents/agents.service.js +9 -20
  20. package/dist/agents/definition.d.ts +3 -51
  21. package/dist/agents/definition.js +4 -254
  22. package/dist/agents/org-templates.js +2 -6
  23. package/dist/agents/readiness.controller.d.ts +4 -12
  24. package/dist/agents/readiness.controller.js +4 -12
  25. package/dist/agents/readiness.service.d.ts +23 -11
  26. package/dist/agents/readiness.service.js +31 -14
  27. package/dist/agents/templates.d.ts +0 -6
  28. package/dist/agents/templates.js +8 -34
  29. package/dist/background/store.d.ts +2 -0
  30. package/dist/background/store.js +3 -1
  31. package/dist/background/wake-rules.js +2 -1
  32. package/dist/catalog/admin-catalog.controller.d.ts +1 -2
  33. package/dist/catalog/admin-catalog.controller.js +1 -2
  34. package/dist/catalog/appearance.service.js +1 -3
  35. package/dist/catalog/catalog-content.d.ts +1 -1
  36. package/dist/catalog/catalog-content.js +1 -4
  37. package/dist/catalog/catalog-items.js +3 -3
  38. package/dist/catalog/catalog-scope.service.d.ts +10 -28
  39. package/dist/catalog/catalog-scope.service.js +22 -73
  40. package/dist/catalog/cli.d.ts +0 -11
  41. package/dist/catalog/cli.js +0 -20
  42. package/dist/catalog/component-scope.service.js +0 -2
  43. package/dist/catalog/component-state.js +2 -2
  44. package/dist/catalog/install-status.d.ts +6 -0
  45. package/dist/catalog/install-status.js +6 -0
  46. package/dist/catalog/job-ids.d.ts +0 -4
  47. package/dist/catalog/job-ids.js +0 -4
  48. package/dist/catalog/marketplaces.service.d.ts +1 -1
  49. package/dist/catalog/org-catalog.service.d.ts +2 -0
  50. package/dist/catalog/org-catalog.service.js +8 -3
  51. package/dist/catalog/org-extension-switch.d.ts +7 -2
  52. package/dist/catalog/org-extension-switch.js +56 -9
  53. package/dist/catalog/org-plugin-uploads.d.ts +6 -15
  54. package/dist/catalog/org-plugin-uploads.js +9 -27
  55. package/dist/catalog/owned-items.js +1 -3
  56. package/dist/catalog/platform-import-update.js +1 -1
  57. package/dist/catalog/plugin-import.d.ts +15 -13
  58. package/dist/catalog/plugin-import.js +21 -30
  59. package/dist/catalog/plugin-install.d.ts +3 -43
  60. package/dist/catalog/plugin-install.js +8 -150
  61. package/dist/catalog/plugin-package.d.ts +5 -10
  62. package/dist/catalog/plugin-package.js +12 -33
  63. package/dist/catalog/plugin-upgrade.js +5 -4
  64. package/dist/catalog/scope-jobs.d.ts +34 -34
  65. package/dist/catalog/scope-jobs.js +50 -37
  66. package/dist/catalog/scope-orgs.d.ts +1 -1
  67. package/dist/catalog/scope-orgs.js +1 -2
  68. package/dist/catalog/scope-sync-workers.d.ts +4 -3
  69. package/dist/catalog/scope-sync-workers.js +18 -6
  70. package/dist/catalog/scope-sync.d.ts +56 -59
  71. package/dist/catalog/scope-sync.js +96 -166
  72. package/dist/catalog/unshare.d.ts +3 -4
  73. package/dist/catalog/unshare.js +5 -8
  74. package/dist/channels/job-ids.d.ts +2 -6
  75. package/dist/channels/job-ids.js +2 -6
  76. package/dist/channels/outbound.d.ts +1 -1
  77. package/dist/channels/outbound.js +1 -1
  78. package/dist/channels/supervisor.d.ts +2 -3
  79. package/dist/channels/supervisor.js +2 -3
  80. package/dist/client/client-access.service.js +1 -1
  81. package/dist/config/env.js +19 -1
  82. package/dist/config/load.d.ts +0 -6
  83. package/dist/config/load.js +8 -27
  84. package/dist/config/schema.d.ts +53 -47
  85. package/dist/config/schema.js +190 -40
  86. package/dist/conversations/attachments.service.d.ts +10 -3
  87. package/dist/conversations/attachments.service.js +49 -16
  88. package/dist/conversations/conversations.controller.d.ts +0 -39
  89. package/dist/conversations/conversations.controller.js +0 -39
  90. package/dist/conversations/events.d.ts +71 -46
  91. package/dist/conversations/events.js +124 -112
  92. package/dist/conversations/media-types.d.ts +25 -0
  93. package/dist/conversations/media-types.js +38 -0
  94. package/dist/conversations/queue.d.ts +3 -1
  95. package/dist/conversations/queue.service.js +9 -2
  96. package/dist/conversations/titles.js +6 -0
  97. package/dist/ctx/create-ctx.js +1 -2
  98. package/dist/ctx/secrets.d.ts +24 -7
  99. package/dist/ctx/secrets.js +97 -30
  100. package/dist/db/kernel-schema.d.ts +17 -6
  101. package/dist/errors.d.ts +5 -2
  102. package/dist/errors.js +5 -2
  103. package/dist/evals/reconstruct.d.ts +4 -17
  104. package/dist/evals/reconstruct.js +13 -53
  105. package/dist/evals/recorded-tools.d.ts +0 -27
  106. package/dist/evals/recorded-tools.js +2 -92
  107. package/dist/evals/run-replay.d.ts +1 -6
  108. package/dist/evals/run-replay.js +10 -17
  109. package/dist/evals/sets.service.d.ts +17 -5
  110. package/dist/evals/sets.service.js +33 -12
  111. package/dist/evals/snapshot.d.ts +1 -2
  112. package/dist/evals/snapshot.js +4 -17
  113. package/dist/extensions/admin-ops.d.ts +6 -1
  114. package/dist/extensions/admin-ops.js +17 -4
  115. package/dist/extensions/admin-view.d.ts +7 -4
  116. package/dist/extensions/admin-view.js +27 -21
  117. package/dist/extensions/bootstrap.js +0 -1
  118. package/dist/extensions/cli.js +0 -1
  119. package/dist/extensions/host.d.ts +2 -3
  120. package/dist/extensions/host.js +1 -5
  121. package/dist/extensions/installs.d.ts +1 -3
  122. package/dist/extensions/instance.d.ts +0 -2
  123. package/dist/extensions/instance.js +0 -3
  124. package/dist/extensions/org-config.d.ts +4 -4
  125. package/dist/extensions/org-config.js +13 -22
  126. package/dist/extensions/package.d.ts +6 -6
  127. package/dist/extensions/package.js +3 -7
  128. package/dist/extensions/permission-view.d.ts +2 -4
  129. package/dist/extensions/plugin-items.d.ts +21 -1
  130. package/dist/extensions/plugin-items.js +28 -0
  131. package/dist/extensions/sync.js +5 -10
  132. package/dist/extensions/unavailable.js +0 -1
  133. package/dist/http/api.module.js +2 -1
  134. package/dist/identity/audit.d.ts +0 -12
  135. package/dist/identity/audit.js +0 -27
  136. package/dist/identity/auth.controller.js +5 -9
  137. package/dist/identity/cookies.d.ts +4 -9
  138. package/dist/identity/cookies.js +8 -32
  139. package/dist/identity/initial-passwords.d.ts +1 -1
  140. package/dist/identity/initial-passwords.js +1 -2
  141. package/dist/identity/sessions.d.ts +0 -6
  142. package/dist/identity/sessions.js +0 -18
  143. package/dist/inbox/platform-inbox.service.d.ts +33 -1
  144. package/dist/inbox/platform-inbox.service.js +56 -6
  145. package/dist/index.d.ts +4 -2
  146. package/dist/index.js +4 -2
  147. package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
  148. package/dist/infra/cli/master-key-rewrap.js +24 -0
  149. package/dist/infra/config/kernel-config.service.js +0 -17
  150. package/dist/infra/health/health.controller.js +8 -0
  151. package/dist/infra/health/process-fault.d.ts +16 -0
  152. package/dist/infra/health/process-fault.js +49 -0
  153. package/dist/infra/lifecycle/process-guards.d.ts +8 -2
  154. package/dist/infra/lifecycle/process-guards.js +12 -3
  155. package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
  156. package/dist/infra/lifecycle/shutdown-signals.js +28 -13
  157. package/dist/infra/outbox/outbox.service.d.ts +12 -9
  158. package/dist/infra/outbox/outbox.service.js +22 -26
  159. package/dist/infra/outbox/registry.d.ts +15 -7
  160. package/dist/infra/outbox/registry.js +39 -23
  161. package/dist/lifecycle/kernel-lifecycle.js +1 -7
  162. package/dist/models/enablement.d.ts +5 -6
  163. package/dist/models/enablement.js +7 -14
  164. package/dist/orgs/orgs.module.d.ts +2 -2
  165. package/dist/orgs/orgs.module.js +2 -2
  166. package/dist/orgs/settings.controller.d.ts +3 -2
  167. package/dist/orgs/settings.service.d.ts +59 -14
  168. package/dist/orgs/settings.service.js +102 -20
  169. package/dist/overrides.d.ts +3 -7
  170. package/dist/overrides.js +2 -4
  171. package/dist/packages/tgz.d.ts +0 -2
  172. package/dist/packages/tgz.js +0 -2
  173. package/dist/platform/exclusions.js +0 -5
  174. package/dist/platform/operation.js +1 -1
  175. package/dist/platform/ops/admin.ops.d.ts +2 -2
  176. package/dist/platform/ops/admin.ops.js +9 -6
  177. package/dist/platform/ops/agents.ops.js +1 -1
  178. package/dist/platform/ops/connectors.ops.js +46 -1
  179. package/dist/platform/ops/evals.ops.js +1 -64
  180. package/dist/platform/ops/extensions-admin.ops.js +1 -1
  181. package/dist/platform/ops/inbox.ops.js +16 -3
  182. package/dist/platform/ops/org-plugins.ops.js +1 -1
  183. package/dist/platform/ops/orgs.ops.d.ts +5 -3
  184. package/dist/platform/ops/orgs.ops.js +19 -4
  185. package/dist/platform/ops/outbox.ops.js +5 -5
  186. package/dist/roles/worker-role.d.ts +2 -3
  187. package/dist/roles/worker-role.js +3 -13
  188. package/dist/runtime/context/build.d.ts +56 -18
  189. package/dist/runtime/context/build.js +143 -50
  190. package/dist/runtime/context/compaction.d.ts +1 -3
  191. package/dist/runtime/context/compaction.js +42 -8
  192. package/dist/runtime/context/run-context.js +1 -2
  193. package/dist/runtime/context/skills.d.ts +27 -56
  194. package/dist/runtime/context/skills.js +42 -114
  195. package/dist/runtime/context/tool-changes.d.ts +3 -3
  196. package/dist/runtime/context/tool-changes.js +6 -16
  197. package/dist/runtime/hook-calls.d.ts +6 -6
  198. package/dist/runtime/hook-calls.js +7 -7
  199. package/dist/runtime/langgraph-loop.js +1 -0
  200. package/dist/runtime/maintenance.d.ts +3 -11
  201. package/dist/runtime/maintenance.js +5 -20
  202. package/dist/runtime/model-call.d.ts +5 -0
  203. package/dist/runtime/model-call.js +48 -36
  204. package/dist/runtime/providers.d.ts +33 -35
  205. package/dist/runtime/providers.js +64 -109
  206. package/dist/runtime/run-context.service.js +7 -22
  207. package/dist/runtime/run-deletion.d.ts +6 -0
  208. package/dist/runtime/run-deletion.js +39 -16
  209. package/dist/runtime/run-execution.js +4 -3
  210. package/dist/runtime/run-finish.js +2 -1
  211. package/dist/runtime/run-liveness.d.ts +11 -0
  212. package/dist/runtime/run-liveness.js +19 -0
  213. package/dist/runtime/run-orphan-check.job.js +2 -1
  214. package/dist/runtime/run-queue.js +8 -16
  215. package/dist/runtime/run-worker.d.ts +2 -2
  216. package/dist/runtime/run-worker.js +8 -6
  217. package/dist/runtime/subagents/definition.d.ts +16 -20
  218. package/dist/runtime/subagents/definition.js +27 -27
  219. package/dist/runtime/subagents/dispatch.d.ts +6 -2
  220. package/dist/runtime/subagents/dispatch.js +17 -3
  221. package/dist/runtime/subagents/org-agents.js +1 -2
  222. package/dist/runtime/subagents/preamble.d.ts +3 -2
  223. package/dist/runtime/subagents/preamble.js +3 -2
  224. package/dist/runtime/subagents/render.d.ts +1 -2
  225. package/dist/runtime/subagents/render.js +1 -2
  226. package/dist/runtime/subagents/skill-fork.d.ts +2 -4
  227. package/dist/runtime/subagents/template-skills.d.ts +47 -0
  228. package/dist/runtime/subagents/template-skills.js +76 -0
  229. package/dist/schedules/effective-settings.d.ts +9 -3
  230. package/dist/schedules/effective-settings.js +5 -4
  231. package/dist/schedules/fire.js +11 -0
  232. package/dist/schedules/scheduled-tasks.service.js +5 -0
  233. package/dist/schedules/unattended.d.ts +2 -0
  234. package/dist/schedules/unattended.js +6 -1
  235. package/dist/skills/agent-skills.service.js +1 -2
  236. package/dist/skills/catalog.d.ts +1 -3
  237. package/dist/skills/catalog.js +1 -3
  238. package/dist/skills/conversation-catalog.d.ts +1 -2
  239. package/dist/skills/conversation-catalog.js +1 -2
  240. package/dist/skills/usable.js +2 -3
  241. package/dist/storage/storage.service.js +9 -1
  242. package/dist/tools/approvals.service.js +2 -4
  243. package/dist/tools/builtin-names.d.ts +2 -9
  244. package/dist/tools/builtin-names.js +4 -13
  245. package/dist/tools/builtins/sandbox/bash.js +3 -3
  246. package/dist/tools/builtins/sandbox/common.d.ts +7 -13
  247. package/dist/tools/builtins/sandbox/common.js +8 -115
  248. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
  249. package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
  250. package/dist/tools/builtins/sandbox/glob.js +1 -3
  251. package/dist/tools/builtins/sandbox/grep.js +3 -5
  252. package/dist/tools/builtins/sandbox/index.d.ts +8 -5
  253. package/dist/tools/builtins/sandbox/index.js +10 -5
  254. package/dist/tools/builtins/sandbox/read.js +3 -2
  255. package/dist/tools/builtins/tool-search.d.ts +4 -7
  256. package/dist/tools/builtins/tool-search.js +6 -10
  257. package/dist/tools/connector-account-policies.d.ts +30 -3
  258. package/dist/tools/connector-account-policies.js +54 -7
  259. package/dist/tools/connectors.controller.d.ts +24 -11
  260. package/dist/tools/connectors.controller.js +35 -6
  261. package/dist/tools/connectors.schemas.d.ts +14 -1
  262. package/dist/tools/connectors.schemas.js +14 -2
  263. package/dist/tools/connectors.service.d.ts +22 -0
  264. package/dist/tools/connectors.service.js +56 -0
  265. package/dist/tools/drift.d.ts +1 -1
  266. package/dist/tools/drift.js +1 -1
  267. package/dist/tools/git-push-policy.d.ts +4 -1
  268. package/dist/tools/git-push-policy.js +3 -1
  269. package/dist/tools/info.d.ts +1 -7
  270. package/dist/tools/info.js +5 -18
  271. package/dist/tools/job-ids.d.ts +0 -4
  272. package/dist/tools/job-ids.js +1 -6
  273. package/dist/tools/pipeline.d.ts +4 -10
  274. package/dist/tools/pipeline.js +16 -62
  275. package/dist/tools/policy.d.ts +6 -2
  276. package/dist/tools/policy.js +14 -12
  277. package/dist/tools/registry.js +1 -5
  278. package/dist/ui/views.d.ts +5 -5
  279. package/dist/ui/views.js +10 -16
  280. package/package.json +3 -3
  281. package/src/migrations/0137_audit_org_idx.sql +5 -0
  282. package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
  283. package/src/migrations/0139_retire_legacy_forms.sql +183 -0
  284. package/src/migrations/0140_retire_history_forms.sql +148 -0
  285. package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
  286. package/src/migrations/0142_backfill_event_fields.sql +74 -0
  287. package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
  288. package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
  289. package/dist/admin/platform-audit.service.d.ts +0 -41
  290. package/dist/conversations/job-ids.d.ts +0 -6
  291. package/dist/conversations/job-ids.js +0 -6
  292. package/dist/extensions/job-ids.d.ts +0 -6
  293. package/dist/extensions/job-ids.js +0 -6
  294. package/dist/infra/queue/retired-schedulers.d.ts +0 -7
  295. package/dist/infra/queue/retired-schedulers.js +0 -9
  296. package/dist/orgs/job-ids.d.ts +0 -8
  297. package/dist/orgs/job-ids.js +0 -8
  298. package/dist/runtime/context/legacy-text.d.ts +0 -22
  299. package/dist/runtime/context/legacy-text.js +0 -37
  300. package/dist/runtime/job-ids.d.ts +0 -10
  301. package/dist/runtime/job-ids.js +0 -10
  302. package/dist/runtime/retired-schedulers.d.ts +0 -7
  303. package/dist/runtime/retired-schedulers.js +0 -31
  304. package/dist/storage/job-ids.d.ts +0 -6
  305. package/dist/storage/job-ids.js +0 -6
  306. package/dist/tools/legacy-data.d.ts +0 -34
  307. package/dist/tools/legacy-data.js +0 -76
  308. package/dist/tools/legacy-keys.d.ts +0 -51
  309. package/dist/tools/legacy-keys.js +0 -114
@@ -1,4 +1,5 @@
1
1
  import { type OnModuleInit } from "@nestjs/common";
2
+ import { AuditLogService } from "../../admin/audit-log.service.js";
2
3
  import { AccountsService } from "../../identity/accounts.js";
3
4
  import { SettingsService } from "../../identity/settings.js";
4
5
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
@@ -9,8 +10,8 @@ import { PlatformOperations } from "../registry.js";
9
10
  /**
10
11
  * Org operations of the `Platform` tool (spec §14.2): the super admin's view of every org (list,
11
12
  * get, the per-org limits) through their own private agent, and the conversation's org for its
12
- * members (read, rename, member list). Creating, deleting and transferring an org, invitations,
13
- * member role changes and removal stay on the web (human-only).
13
+ * members (read, rename, member list, the org audit log for its admins). Creating, deleting and
14
+ * transferring an org, invitations, member role changes and removal stay on the web (human-only).
14
15
  */
15
16
  export declare class OrgsOperations implements OnModuleInit {
16
17
  private readonly registry;
@@ -20,7 +21,8 @@ export declare class OrgsOperations implements OnModuleInit {
20
21
  private readonly accounts;
21
22
  private readonly config;
22
23
  private readonly kdb;
23
- constructor(registry: PlatformOperations, orgs: OrgsService, members: MembersService, settings: SettingsService, accounts: AccountsService, config: KernelConfigService, kdb: KernelDb);
24
+ private readonly audit;
25
+ constructor(registry: PlatformOperations, orgs: OrgsService, members: MembersService, settings: SettingsService, accounts: AccountsService, config: KernelConfigService, kdb: KernelDb, audit: AuditLogService);
24
26
  private org;
25
27
  /** The actor as `OrgsService.update` takes it (it re-checks the role under the org lock). */
26
28
  private actor;
@@ -9,6 +9,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
11
  import { z } from "zod";
12
+ import { OrgAuditListQuery } from "../../admin/audit.schemas.js";
13
+ import { AuditLogService } from "../../admin/audit-log.service.js";
12
14
  import { limitDefaults } from "../../admin/limit-defaults.js";
13
15
  import { ApiError } from "../../errors.js";
14
16
  import { AccountsService } from "../../identity/accounts.js";
@@ -43,8 +45,8 @@ async function limitsOf(settings, orgId) {
43
45
  /**
44
46
  * Org operations of the `Platform` tool (spec §14.2): the super admin's view of every org (list,
45
47
  * get, the per-org limits) through their own private agent, and the conversation's org for its
46
- * members (read, rename, member list). Creating, deleting and transferring an org, invitations,
47
- * member role changes and removal stay on the web (human-only).
48
+ * members (read, rename, member list, the org audit log for its admins). Creating, deleting and
49
+ * transferring an org, invitations, member role changes and removal stay on the web (human-only).
48
50
  */
49
51
  let OrgsOperations = class OrgsOperations {
50
52
  registry;
@@ -54,7 +56,8 @@ let OrgsOperations = class OrgsOperations {
54
56
  accounts;
55
57
  config;
56
58
  kdb;
57
- constructor(registry, orgs, members, settings, accounts, config, kdb) {
59
+ audit;
60
+ constructor(registry, orgs, members, settings, accounts, config, kdb, audit) {
58
61
  this.registry = registry;
59
62
  this.orgs = orgs;
60
63
  this.members = members;
@@ -62,6 +65,7 @@ let OrgsOperations = class OrgsOperations {
62
65
  this.accounts = accounts;
63
66
  this.config = config;
64
67
  this.kdb = kdb;
68
+ this.audit = audit;
65
69
  }
66
70
  async org(orgId) {
67
71
  const o = await this.orgs.get(orgId);
@@ -285,6 +289,16 @@ let OrgsOperations = class OrgsOperations {
285
289
  ...(m.anonymous && { anonymous: true }),
286
290
  })), startOf(input.cursor), PAGE),
287
291
  }),
292
+ defineOperation({
293
+ id: "orgs.audit",
294
+ description: "The audit log of this conversation's org (org admins), newest first: members and invitations, settings, agents, connectors, skills, plugins and extensions in the org, channels, schedules. Each event has its id, time, actor (id, name, email; null for the kernel itself), viaToken (done with a personal access token), viaAgent (done through the Platform tool), action and target; never the event's details. action filters by an action name or its prefix (e.g. org.member.). limit is 1 to 100 (default 20); pages by keyset: pass the returned next as params.after (null: no more).",
295
+ input: OrgAuditListQuery.strict(),
296
+ example: { limit: 20 },
297
+ authz: { orgAction: "org.update" },
298
+ mirrors: ["GET /api/v1/orgs/:orgId/audit"],
299
+ confirm: "read",
300
+ run: (input, ctx) => this.audit.list({ orgId: ctx.orgId }, input),
301
+ }),
288
302
  ]);
289
303
  }
290
304
  };
@@ -296,6 +310,7 @@ OrgsOperations = __decorate([
296
310
  __param(3, Inject(SettingsService)),
297
311
  __param(4, Inject(AccountsService)),
298
312
  __param(5, Inject(KernelConfigService)),
299
- __param(6, Inject(KernelDb))
313
+ __param(6, Inject(KernelDb)),
314
+ __param(7, Inject(AuditLogService))
300
315
  ], OrgsOperations);
301
316
  export { OrgsOperations };
@@ -9,7 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
11
  import { z } from "zod";
12
- import { OutboxDeadParams } from "../../admin/outbox-dead.schemas.js";
12
+ import { OutboxDeadListQuery, OutboxDeadParams } from "../../admin/outbox-dead.schemas.js";
13
13
  import { OutboxDeadService } from "../../admin/outbox-dead.service.js";
14
14
  import { KernelDb } from "../../infra/database/kernel-db.js";
15
15
  import { defineOperation } from "../operation.js";
@@ -54,13 +54,13 @@ let OutboxOperations = class OutboxOperations {
54
54
  this.registry.register([
55
55
  defineOperation({
56
56
  id: "admin.outbox-list-dead",
57
- description: "List background work the kernel could not queue (super admin): outbox rows dead after their last delivery attempt, oldest first (at most 200), each with its id, queue, job name, job id, org (null for platform work), attempts, last error and when it died. Retry one with admin.outbox-retry or drop it with admin.outbox-discard.",
58
- input: z.object({}).strict(),
59
- example: {},
57
+ description: "List background work the kernel could not queue (super admin): outbox rows dead after their last delivery attempt, oldest first, a page of at most 200 (pass the returned next as after for the following page; next is null at the end), each with its id, queue, job name, job id, org (null for platform work), attempts, last error and when it died. Retry one with admin.outbox-retry or drop it with admin.outbox-discard.",
58
+ input: OutboxDeadListQuery.strict(),
59
+ example: { limit: 200 },
60
60
  authz: { superAdmin: true },
61
61
  mirrors: ["GET /api/v1/admin/outbox/dead"],
62
62
  confirm: "read",
63
- run: () => this.dead.list(),
63
+ run: (input) => this.dead.list(input),
64
64
  }),
65
65
  defineOperation({
66
66
  id: "admin.outbox-retry",
@@ -49,10 +49,9 @@ export declare class WorkerRole {
49
49
  * Starts the queue consumers (after the extension load), then opens the schedules' start gate:
50
50
  * the cron and interval timers were armed at application bootstrap, but every tick before this
51
51
  * point skipped (decision R21 of the Nest kernel spec); the `@LockedInterval({ runOnStart })`
52
- * jobs run now, in the background (once across replicas starting together). `checkpoint` throws
53
- * when a stop began meanwhile.
52
+ * jobs run now, in the background (once across replicas starting together).
54
53
  */
55
- start(checkpoint: () => void): Promise<void>;
54
+ start(): void;
56
55
  /**
57
56
  * Closes the start gate and stops the schedulers (no new tick; the runs in progress get the stop
58
57
  * signal) and returns the wait for those runs, at most `budgetMs`.
@@ -78,25 +78,15 @@ let WorkerRole = class WorkerRole {
78
78
  * Starts the queue consumers (after the extension load), then opens the schedules' start gate:
79
79
  * the cron and interval timers were armed at application bootstrap, but every tick before this
80
80
  * point skipped (decision R21 of the Nest kernel spec); the `@LockedInterval({ runOnStart })`
81
- * jobs run now, in the background (once across replicas starting together). `checkpoint` throws
82
- * when a stop began meanwhile.
81
+ * jobs run now, in the background (once across replicas starting together).
83
82
  */
84
- async start(checkpoint) {
83
+ start() {
85
84
  // both run queues' @Processor workers (built with the run config, never autorun)
86
85
  this.runWorker.start([this.runsProcessor.worker, this.subagentRunsProcessor.worker]);
87
86
  this.runsStarted = true;
88
87
  this.evalWorker.start(this.evalsProcessor.worker);
89
88
  this.evalsStarted = true;
90
- // The maintenance queue: remove the retired job schedulers (idempotent, harmless when several
91
- // replicas do it), then start its one consumer. A failure is only logged and does not stop the
92
- // start (like the workers' connection errors): any worker replica removes them on its next start.
93
- try {
94
- await this.maintenanceProcessor.removeRetiredSchedulers();
95
- }
96
- catch (err) {
97
- this.log.error("cannot register maintenance job schedulers", { err });
98
- }
99
- checkpoint();
89
+ // the maintenance queue's one consumer
100
90
  this.maintenanceProcessor.start();
101
91
  this.scopeProcessor.start();
102
92
  this.lifecycleProcessor.start();
@@ -36,6 +36,11 @@ export interface ModelCallMeta {
36
36
  key: string;
37
37
  specHash: string;
38
38
  }[];
39
+ /**
40
+ * The step's tools were left out because the model has no tool support (set by
41
+ * `assembleModelRequest`); absent when the request carried them.
42
+ */
43
+ toolsOmitted?: true;
39
44
  /** 请求的 `toolChoice`(收尾调用为 `"none"`);未设置则没有该字段。 */
40
45
  toolChoice?: "auto" | "none";
41
46
  /**
@@ -54,14 +59,18 @@ export interface BuildModelRequestInput {
54
59
  model: ModelInfo;
55
60
  step: number;
56
61
  /**
57
- * loop 已吸收到的位置(R31):the largest seq of the absorbable events (`user_message`,
58
- * `background_task_finished` and `subagent_delivery`, {@link isAbsorbable}) the loop took. 提供时:
59
- * - seq 大于它的可吸收事件不进请求(运行中途到达、尚未被吸收的插话或后台任务结束,由后续步骤吸收或触发下一轮);
60
- * - 每个可吸收事件放在**吸收它的那次模型调用**的位置:日志里第一个 `request.absorbedUpToSeq`
61
- * 不小于它的 `model_call` 之前(没有该字段的旧 model_call 视为吸收了它之前的全部消息),
62
- * 本次请求吸收的放在末尾。于是模型看到的历史只追加(插话不会插到已发送的回复之前),
63
- * 且请求可由日志 + `model_call` 精确还原。
64
- * 不提供时按 seq 原样回放全部可吸收事件。
62
+ * How far the loop has absorbed (R31): the largest seq of the absorbable events (`user_message`,
63
+ * `background_task_finished` and `subagent_delivery`, {@link isAbsorbable}) the loop took. When
64
+ * given:
65
+ * - absorbable events with a larger seq stay out of the request (an interjection or a finished
66
+ * background task that arrived mid-run and is not absorbed yet; a later step absorbs it or it
67
+ * starts the next run);
68
+ * - each absorbable event sits where **the model call that absorbed it** is: before the first
69
+ * `model_call` in the log whose `request.absorbedUpToSeq` is not smaller than its seq, and
70
+ * the ones this request absorbs go at the end. So the history the model sees is append-only
71
+ * (an interjection never lands before a reply already sent) and the request can be rebuilt
72
+ * exactly from the log + `model_call`.
73
+ * When absent, every absorbable event is replayed in seq order.
65
74
  */
66
75
  absorbedUpToSeq?: number;
67
76
  /**
@@ -113,12 +122,20 @@ export interface MediaInfo {
113
122
  pages: number | null;
114
123
  /** finalize 时记下的对象 etag(记进 `model_call` 的媒体结果,便于核对还原);提供方不给为 null / 缺省。 */
115
124
  etag?: string | null;
125
+ /**
126
+ * 对象在此存储里的无签名引用(`s3://<bucket>/<key>`,见 `ObjectStore.uri`):写进引用行,让模型能把
127
+ * 文件交给 `FetchAttachment`。存储没有 URI 概念时是 `capybara://attachments/<id>`。
128
+ */
129
+ uri: string;
116
130
  }
117
- /** `text/*` 附件(内联文本与 base64 文档两种方式都一样)的最大字符数(UTF-16 码元,超出截断并注明)。 */
118
- export declare const TEXT_INLINE_MAX_CHARS = 50000;
119
131
  /**
120
- * `text/*` 附件最多取的字节数:UTF-8 里一个 UTF-16 码元最多 3 字节,取这么多一定够凑满
121
- * {@link TEXT_INLINE_MAX_CHARS}。更后面的字节不取(按范围读),预算也只按封顶后的大小计。
132
+ * `text/*` 附件内联(或作为文本文档发出)的最大字符数(UTF-16 码元):再长就只给引用行,绝不截断
133
+ * (§5.2:要么整篇给,要么给引用、由设备里的文件提供)。
134
+ */
135
+ export declare const TEXT_INLINE_MAX_CHARS = 8000;
136
+ /**
137
+ * `text/*` 附件最多取的字节数:UTF-8 里一个 UTF-16 码元最多 3 字节,取这么多一定够判断
138
+ * {@link TEXT_INLINE_MAX_CHARS}。更长的文本不取(它是引用行),见 {@link planMedia}。
122
139
  */
123
140
  export declare const TEXT_FETCH_MAX_BYTES: number;
124
141
  /** 单次请求最多的图片数(常见供应商的上限):只保留最新的,更早的换成占位。 */
@@ -140,15 +157,19 @@ type LogBlock = EventPayload<"user_message">["content"][number];
140
157
  */
141
158
  export declare function excludedMedia(events: readonly ConversationEvent[]): Set<string>;
142
159
  /**
143
- * 该模型需要的附件 id(去重、按出现顺序),调用方据此查行信息({@link MediaInfo})。
160
+ * 该模型需要其附件行的附件 id(去重、按出现顺序),调用方据此查行信息({@link MediaInfo})。
144
161
  * 模型不支持的图片 / PDF、被 `media_excluded` 排除的不在其中——只发占位,行与字节都不取。
162
+ * `file` 块在结果里(引用行要行里的大小与 URI),但从不取字节。
145
163
  */
146
164
  export declare function mediaRefs(events: readonly ConversationEvent[], model: ModelInfo): string[];
147
165
  /** {@link planMedia} 的结果。 */
148
166
  export interface MediaPlan {
149
167
  /** 要取字节的附件 id(从新到旧)。 */
150
168
  fetch: string[];
151
- /** 只取开头若干字节的附件(`text/*` 超过 {@link TEXT_FETCH_MAX_BYTES}):id → 字节数。 */
169
+ /**
170
+ * 只取开头若干字节的附件(`text/*` 超过 {@link TEXT_FETCH_MAX_BYTES}):id → 字节数。
171
+ * 现在总是空:超过取字节上限的文本不再取(它是引用行,§5.2),上限之内的取整份。
172
+ */
152
173
  caps: Map<string, number>;
153
174
  /** 为控制请求大小而省略(预算)。 */
154
175
  dropped: Set<string>;
@@ -162,10 +183,12 @@ export interface MediaPlan {
162
183
  /**
163
184
  * 单次请求的媒体计划(Ruling M6 / M8),只取决于日志、模型能力与行信息,是确定的:
164
185
  * - 被 `media_excluded` 排除的:不取、不计;
186
+ * - `file` 块(模型只看到引用行):不取、不计(行信息照常查);
187
+ * - `text/*` 超过 {@link TEXT_FETCH_MAX_BYTES}:不取(它就是引用行,§5.2)——上限之内的取整份,
188
+ * 解码后超过 {@link TEXT_INLINE_MAX_CHARS} 的在 {@link resolveMedia} 里也变成引用行;
165
189
  * - PDF 页数超过 {@link MAX_PDF_PAGES}:不取、不计;
166
190
  * - 从最新的媒体往前:图片最多保留 {@link MAX_IMAGES_PER_REQUEST} 张,更早的图片省略(不影响其他媒体);
167
- * - 预算:按行里的**声明大小**(`text/*` 按封顶后的大小 `min(size, TEXT_FETCH_MAX_BYTES)`)累计,
168
- * 第一次超出 `budgetBytes` 起,该附件及更早的全部省略;
191
+ * - 预算:按行里的**声明大小**累计,第一次超出 `budgetBytes` 起,该附件及更早的全部省略;
169
192
  * - 同一附件只算一次(按最后一次出现的位置算新旧);没有行的不计(它们是「不再可用」)。
170
193
  *
171
194
  * 已知取舍(接受):新的媒体把较早的媒体挤成占位时,请求里**较早位置**的内容随之改变,这一处之后的提示词缓存
@@ -184,6 +207,20 @@ export declare const mediaTooManyImagesText: (name: string) => string;
184
207
  export declare const mediaTooManyPagesText: (name: string) => string;
185
208
  /** 被供应商拒绝、此后不再发送的附件(模型可见,英文)。 */
186
209
  export declare const mediaRejectedText: (name: string) => string;
210
+ /**
211
+ * A reference line (model-facing English, one text block, §5.2): the file's name and media type, its
212
+ * size, the unsigned object URI, and how to get the bytes — `FetchAttachment` copies the file into the
213
+ * device. A text attachment above the inline threshold says why it was not inlined, so the model does
214
+ * not wonder whether it was truncated. Never a presigned URL: `uri` is unsigned and stable.
215
+ */
216
+ export declare const attachmentReferenceText: (input: {
217
+ name: string;
218
+ mediaType: string;
219
+ size: number;
220
+ uri: string;
221
+ /** The content is text the model could read: it was not inlined because it is too long. */
222
+ text?: boolean;
223
+ }) => string;
187
224
  /** {@link resolveMedia} 的输入:行信息、字节与本次请求的媒体计划。 */
188
225
  export interface MediaContext {
189
226
  info: ReadonlyMap<string, MediaInfo> | undefined;
@@ -196,11 +233,12 @@ export type MediaOutcomeEntry = NonNullable<EventPayload<"model_call">["request"
196
233
  export type MediaOutcome = MediaOutcomeEntry["outcome"];
197
234
  /**
198
235
  * 把日志里的媒体引用换成发给模型的内容(不改日志,结果只取决于日志、模型能力、行信息与字节):
236
+ * - `file` 块(以及超过 {@link TEXT_INLINE_MAX_CHARS} 的文本):一行引用({@link attachmentReferenceText}),
237
+ * **绝不带字节**——要么整篇给,要么给引用、由设备里取来的文件提供(§5.2);
199
238
  * - 模型不支持(图片看 `vision`,文档看 `documents`):图片 / PDF 换成英文占位,**绝不带字节**;
200
239
  * - 被 `media_excluded` 排除 →「被供应商拒绝」占位;没有行 →「不再可用」;PDF 页数过多 →「页数太多」;
201
240
  * 图片太多或超出预算 →「省略」;取不到字节 →「不再可用」;字节超过 `MEDIA_LIMITS` →「太大」;
202
- * - `text/*`:两种方式都封顶为 {@link TEXT_INLINE_MAX_CHARS} 个字符并注明截断——不支持 documents 时内联为文本,
203
- * 支持时作为 base64 文档(截断时文档内容是截断后的文本加注明);
241
+ * - `text/*` 在上限之内:不支持 documents 时内联为文本,支持时作为 base64 文档;
204
242
  * - 其余 → `base64` 块。
205
243
  * 插件永远收不到 `ref`。返回块、发出的媒体块的估算 token 数(图片 {@link IMAGE_TOKENS},PDF 见 {@link pdfTokens},
206
244
  * 文本文档按发出的字节数 ÷ 3)与每个块的处理结果。