@capybara-hq/kernel 0.1.0-rc.135 → 0.1.0-rc.137

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 (242) hide show
  1. package/dist/admin/admin.module.js +3 -0
  2. package/dist/admin/audit-log.service.d.ts +96 -12
  3. package/dist/admin/audit-log.service.js +508 -44
  4. package/dist/admin/audit-targets.d.ts +17 -0
  5. package/dist/admin/audit-targets.js +84 -0
  6. package/dist/admin/audit.controller.d.ts +12 -9
  7. package/dist/admin/audit.controller.js +29 -8
  8. package/dist/admin/audit.schemas.d.ts +20 -4
  9. package/dist/admin/audit.schemas.js +42 -17
  10. package/dist/admin/health.service.d.ts +2 -2
  11. package/dist/admin/health.service.js +6 -2
  12. package/dist/agents/templates.js +3 -10
  13. package/dist/app.d.ts +3 -1
  14. package/dist/app.js +1 -0
  15. package/dist/automations/automations.service.js +4 -5
  16. package/dist/catalog/catalog-content.d.ts +1 -1
  17. package/dist/catalog/catalog-content.js +17 -22
  18. package/dist/catalog/catalog-items.d.ts +5 -10
  19. package/dist/catalog/catalog-items.js +27 -51
  20. package/dist/catalog/catalog-scope.service.d.ts +4 -2
  21. package/dist/catalog/catalog-scope.service.js +105 -141
  22. package/dist/catalog/catalog.module.js +2 -0
  23. package/dist/catalog/catalog.service.d.ts +3 -3
  24. package/dist/catalog/catalog.service.js +33 -8
  25. package/dist/catalog/cli.js +17 -0
  26. package/dist/catalog/component-promotion.js +8 -4
  27. package/dist/catalog/component-scope.service.d.ts +3 -1
  28. package/dist/catalog/component-scope.service.js +101 -140
  29. package/dist/catalog/component-state.d.ts +10 -8
  30. package/dist/catalog/component-state.js +42 -30
  31. package/dist/catalog/dependency-edges.d.ts +25 -0
  32. package/dist/catalog/dependency-edges.js +125 -0
  33. package/dist/catalog/install-status.d.ts +2 -3
  34. package/dist/catalog/install-status.js +2 -3
  35. package/dist/catalog/marketplaces.service.d.ts +1 -1
  36. package/dist/catalog/org-catalog.service.d.ts +3 -1
  37. package/dist/catalog/org-catalog.service.js +33 -94
  38. package/dist/catalog/org-intent.d.ts +43 -0
  39. package/dist/catalog/org-intent.js +184 -0
  40. package/dist/catalog/owned-items.d.ts +1 -1
  41. package/dist/catalog/owned-items.js +9 -29
  42. package/dist/catalog/ownership.d.ts +2 -3
  43. package/dist/catalog/ownership.js +10 -28
  44. package/dist/catalog/platform-components.d.ts +3 -1
  45. package/dist/catalog/platform-components.js +9 -1
  46. package/dist/catalog/plugin-import.js +12 -16
  47. package/dist/catalog/plugin-install.d.ts +3 -4
  48. package/dist/catalog/plugin-install.js +25 -49
  49. package/dist/catalog/plugin-upgrade.d.ts +2 -2
  50. package/dist/catalog/plugin-upgrade.js +18 -34
  51. package/dist/catalog/request-rules.js +20 -8
  52. package/dist/catalog/scope-orgs.js +2 -7
  53. package/dist/catalog/scope-state.d.ts +6 -6
  54. package/dist/catalog/scope-state.js +24 -43
  55. package/dist/catalog/scope-sync.d.ts +0 -2
  56. package/dist/catalog/scope-sync.js +11 -39
  57. package/dist/catalog/scope-writer.d.ts +78 -0
  58. package/dist/catalog/scope-writer.js +181 -0
  59. package/dist/catalog/unshare.js +8 -41
  60. package/dist/channels/connections.service.js +6 -6
  61. package/dist/channels/supervisor.js +3 -7
  62. package/dist/client/client-access.service.js +2 -12
  63. package/dist/config/schema.d.ts +6 -0
  64. package/dist/config/schema.js +29 -1
  65. package/dist/conversations/access.d.ts +15 -7
  66. package/dist/conversations/access.js +59 -10
  67. package/dist/conversations/conversation-agent.d.ts +18 -0
  68. package/dist/conversations/conversation-agent.js +23 -0
  69. package/dist/conversations/conversation-ref.d.ts +3 -2
  70. package/dist/conversations/conversation-ref.js +6 -1
  71. package/dist/conversations/conversations.controller.d.ts +28 -5
  72. package/dist/conversations/conversations.controller.js +99 -10
  73. package/dist/conversations/conversations.module.js +10 -0
  74. package/dist/conversations/conversations.schemas.d.ts +6 -0
  75. package/dist/conversations/conversations.schemas.js +15 -0
  76. package/dist/conversations/conversations.service.d.ts +125 -21
  77. package/dist/conversations/conversations.service.js +260 -90
  78. package/dist/conversations/event-log.d.ts +9 -1
  79. package/dist/conversations/event-log.js +2 -0
  80. package/dist/conversations/events.d.ts +57 -0
  81. package/dist/conversations/events.js +73 -1
  82. package/dist/conversations/external/external-calls.d.ts +75 -0
  83. package/dist/conversations/external/external-calls.js +91 -0
  84. package/dist/conversations/external/external-calls.processor.d.ts +45 -0
  85. package/dist/conversations/external/external-calls.processor.js +144 -0
  86. package/dist/conversations/external/external-conversations.service.d.ts +266 -0
  87. package/dist/conversations/external/external-conversations.service.js +1138 -0
  88. package/dist/conversations/external/external.schemas.d.ts +63 -0
  89. package/dist/conversations/external/external.schemas.js +52 -0
  90. package/dist/conversations/external/token.d.ts +6 -0
  91. package/dist/conversations/external/token.js +6 -0
  92. package/dist/conversations/permission-profile-store.d.ts +4 -1
  93. package/dist/conversations/permission-profiles.controller.d.ts +33 -9
  94. package/dist/conversations/permission-profiles.controller.js +86 -6
  95. package/dist/conversations/prompt-suggestions.js +2 -1
  96. package/dist/conversations/queue.js +2 -1
  97. package/dist/conversations/titles.js +4 -3
  98. package/dist/ctx/create-ctx.d.ts +9 -2
  99. package/dist/ctx/create-ctx.js +47 -62
  100. package/dist/ctx/guard-db.d.ts +6 -0
  101. package/dist/ctx/guard-db.js +55 -0
  102. package/dist/db/extension-handoff-schema.d.ts +1 -1
  103. package/dist/db/extension-handoff-schema.js +48 -10
  104. package/dist/db/extension-schema-transfer.js +5 -2
  105. package/dist/db/kernel-schema.d.ts +42 -5
  106. package/dist/device-access/host-services.d.ts +2 -2
  107. package/dist/device-access/host-services.js +8 -8
  108. package/dist/device-access/person-handles.d.ts +16 -7
  109. package/dist/device-access/person-handles.js +14 -9
  110. package/dist/devices/conversation-devices.d.ts +5 -0
  111. package/dist/devices/conversation-devices.js +16 -0
  112. package/dist/erasure/org-catalog.js +2 -2
  113. package/dist/erasure/org-rules.js +5 -0
  114. package/dist/errors.d.ts +34 -0
  115. package/dist/errors.js +34 -0
  116. package/dist/evals/snapshot.js +3 -1
  117. package/dist/evals/trajectory.service.d.ts +2 -2
  118. package/dist/evals/trajectory.service.js +11 -7
  119. package/dist/extensions/admin-ops.d.ts +9 -5
  120. package/dist/extensions/admin-ops.js +52 -8
  121. package/dist/extensions/admin-view.js +1 -4
  122. package/dist/extensions/bootstrap.js +4 -1
  123. package/dist/extensions/cli.js +1 -0
  124. package/dist/extensions/effective-config.js +1 -4
  125. package/dist/extensions/enabled.d.ts +23 -29
  126. package/dist/extensions/enabled.js +141 -62
  127. package/dist/extensions/extensions.module.js +3 -0
  128. package/dist/extensions/host.d.ts +71 -45
  129. package/dist/extensions/host.js +454 -128
  130. package/dist/extensions/installs.d.ts +9 -0
  131. package/dist/extensions/installs.js +23 -0
  132. package/dist/extensions/isolated/admission.d.ts +10 -0
  133. package/dist/extensions/isolated/admission.js +206 -0
  134. package/dist/extensions/isolated/authorization.d.ts +37 -0
  135. package/dist/extensions/isolated/authorization.js +146 -0
  136. package/dist/extensions/isolated/broker.d.ts +15 -0
  137. package/dist/extensions/isolated/broker.js +452 -0
  138. package/dist/extensions/isolated/child-protocol.d.ts +84 -0
  139. package/dist/extensions/isolated/child-protocol.js +21 -0
  140. package/dist/extensions/isolated/child-registration.d.ts +22 -0
  141. package/dist/extensions/isolated/child-registration.js +152 -0
  142. package/dist/extensions/isolated/child-session.d.ts +6 -0
  143. package/dist/extensions/isolated/child-session.js +343 -0
  144. package/dist/extensions/isolated/child-streams.d.ts +4 -0
  145. package/dist/extensions/isolated/child-streams.js +142 -0
  146. package/dist/extensions/isolated/child.d.ts +1 -0
  147. package/dist/extensions/isolated/child.js +10 -0
  148. package/dist/extensions/isolated/configured-package.d.ts +15 -0
  149. package/dist/extensions/isolated/configured-package.js +73 -0
  150. package/dist/extensions/isolated/lanes.d.ts +100 -0
  151. package/dist/extensions/isolated/lanes.js +699 -0
  152. package/dist/extensions/isolated/postgres-gate.d.ts +14 -0
  153. package/dist/extensions/isolated/postgres-gate.js +255 -0
  154. package/dist/extensions/isolated/revision.d.ts +32 -0
  155. package/dist/extensions/isolated/revision.js +358 -0
  156. package/dist/extensions/isolated/rpc-frame.d.ts +50 -0
  157. package/dist/extensions/isolated/rpc-frame.js +193 -0
  158. package/dist/extensions/isolated/rpc.d.ts +66 -0
  159. package/dist/extensions/isolated/rpc.js +314 -0
  160. package/dist/extensions/isolated/sandbox.d.ts +35 -0
  161. package/dist/extensions/isolated/sandbox.js +372 -0
  162. package/dist/extensions/isolated/tier.d.ts +6 -0
  163. package/dist/extensions/isolated/tier.js +45 -0
  164. package/dist/extensions/ledger.d.ts +1 -1
  165. package/dist/extensions/lifecycle-topics.d.ts +1 -0
  166. package/dist/extensions/lifecycle-topics.js +1 -0
  167. package/dist/extensions/lifecycle.d.ts +3 -1
  168. package/dist/extensions/lifecycle.js +32 -5
  169. package/dist/extensions/locks.d.ts +2 -0
  170. package/dist/extensions/locks.js +7 -0
  171. package/dist/extensions/org-config.d.ts +17 -27
  172. package/dist/extensions/org-config.js +114 -129
  173. package/dist/extensions/permission-view.d.ts +3 -1
  174. package/dist/extensions/permission-view.js +4 -1
  175. package/dist/extensions/plugin-guides.d.ts +5 -10
  176. package/dist/extensions/plugin-guides.js +18 -37
  177. package/dist/extensions/plugin-icons.d.ts +3 -21
  178. package/dist/extensions/plugin-icons.js +9 -44
  179. package/dist/extensions/plugin-items.d.ts +10 -30
  180. package/dist/extensions/plugin-items.js +32 -73
  181. package/dist/extensions/point-defaults.d.ts +13 -21
  182. package/dist/extensions/point-defaults.js +32 -72
  183. package/dist/extensions/point-serving.d.ts +56 -0
  184. package/dist/extensions/point-serving.js +120 -0
  185. package/dist/extensions/source-intent.d.ts +14 -0
  186. package/dist/extensions/source-intent.js +77 -0
  187. package/dist/inbox/inbox-items.service.d.ts +11 -0
  188. package/dist/inbox/inbox-items.service.js +39 -0
  189. package/dist/index.d.ts +2 -1
  190. package/dist/index.js +2 -1
  191. package/dist/infra/database/database.module.js +6 -1
  192. package/dist/infra/database/kernel-db.d.ts +3 -1
  193. package/dist/infra/database/kernel-db.js +4 -0
  194. package/dist/infra/outbox/registry.d.ts +70 -0
  195. package/dist/infra/outbox/registry.js +44 -0
  196. package/dist/infra/paging/paged-read.d.ts +56 -0
  197. package/dist/infra/paging/paged-read.js +78 -0
  198. package/dist/infra/queue/queue-names.d.ts +1 -1
  199. package/dist/infra/queue/queue-names.js +1 -0
  200. package/dist/kernel.d.ts +3 -2
  201. package/dist/kernel.js +21 -2
  202. package/dist/kernel.module.js +4 -0
  203. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  204. package/dist/lifecycle/kernel-lifecycle.js +22 -12
  205. package/dist/lifecycle/tokens.d.ts +8 -0
  206. package/dist/lifecycle/tokens.js +2 -0
  207. package/dist/orgs/directory-sync.js +1 -4
  208. package/dist/platform/exclusions.js +10 -0
  209. package/dist/platform/ops/admin.ops.js +14 -3
  210. package/dist/platform/ops/conversations.ops.d.ts +8 -1
  211. package/dist/platform/ops/conversations.ops.js +52 -14
  212. package/dist/platform/ops/orgs.ops.js +13 -3
  213. package/dist/plugin-reads/plugin-reads.service.js +4 -1
  214. package/dist/push/recipients.js +5 -2
  215. package/dist/retention/worker.js +2 -1
  216. package/dist/roles/worker-role.d.ts +3 -1
  217. package/dist/roles/worker-role.js +8 -2
  218. package/dist/roles/worker.module.js +3 -0
  219. package/dist/runtime/context/build.js +8 -0
  220. package/dist/runtime/context/compaction.js +7 -0
  221. package/dist/runtime/idle-arm.js +3 -1
  222. package/dist/runtime/idle-compaction.js +2 -1
  223. package/dist/runtime/run-finish.js +2 -1
  224. package/dist/runtime/run-jobs.js +2 -1
  225. package/dist/runtime/run-queue.js +4 -2
  226. package/dist/runtime/run-worker.js +5 -2
  227. package/dist/runtime/stream.js +10 -0
  228. package/dist/runtime/usage-report.js +2 -1
  229. package/dist/runtime/waits.js +2 -1
  230. package/dist/setup/setup-checks.service.js +3 -2
  231. package/dist/skills/usable.js +41 -30
  232. package/dist/themes/theme-state.js +3 -3
  233. package/dist/tools/approvals.service.js +6 -2
  234. package/dist/tools/builtins/skill-load.js +3 -2
  235. package/dist/tools/registry.d.ts +1 -1
  236. package/dist/tools/registry.js +1 -1
  237. package/dist/tools/tool-watch.service.js +3 -1
  238. package/package.json +3 -3
  239. package/src/migrations/0227_external_conversations.sql +33 -0
  240. package/src/migrations/0228_extension_org_switches.sql +56 -0
  241. package/src/migrations/0229_catalog_dependency_edges.sql +17 -0
  242. package/src/migrations/0230_audit_filter_idx.sql +18 -0
@@ -8,6 +8,7 @@ import { Module } from "@nestjs/common";
8
8
  import { CatalogModule } from "../catalog/catalog.module.js";
9
9
  import { TemplateConnectorsQueueModule } from "../catalog/template-connector-jobs.js";
10
10
  import { ChannelsModule } from "../channels/channels.module.js";
11
+ import { ExternalConversationsModule } from "../conversations/external/external-conversations.service.js";
11
12
  import { PromptSuggestionsModule } from "../conversations/prompt-suggestions.js";
12
13
  import { TitlesModule } from "../conversations/titles.js";
13
14
  import { DeviceServiceEventsModule } from "../device-access/service-events.js";
@@ -75,6 +76,8 @@ AdminModule = __decorate([
75
76
  TemplateConnectorsQueueModule,
76
77
  // the device service events queue the overview counts
77
78
  DeviceServiceEventsModule,
79
+ // the external conversation calls queue the overview counts
80
+ ExternalConversationsModule,
78
81
  // the price table of the usage aggregate
79
82
  ModelsModule,
80
83
  ],
@@ -1,11 +1,12 @@
1
1
  import { KernelDb } from "../infra/database/kernel-db.js";
2
+ import { type Paged } from "../infra/paging/paged-read.js";
2
3
  /**
3
4
  * One audit event (admin overview spec §5.2, §9): who, what, on what and when, and two flags.
4
5
  * Never the event's `detail` (it may carry config field names, ids or values); a deleted actor
5
6
  * account reads as its id with a null name and email; `actor` is null for the kernel itself.
6
7
  */
7
8
  export interface AuditEvent {
8
- /** The event id (a bigserial, as a decimal string); also the keyset cursor. */
9
+ /** The event id (a bigserial, as a decimal string); also the snapshot key (`asOf`). */
9
10
  id: string;
10
11
  at: string;
11
12
  actor: {
@@ -14,19 +15,23 @@ export interface AuditEvent {
14
15
  email: string | null;
15
16
  avatarUrl: string | null;
16
17
  } | null;
17
- /** Done with a personal access token. */
18
+ /** Done with an access token (a personal one, or an org's service token when `actor` is null). */
18
19
  viaToken: boolean;
19
20
  /** Done through the Platform tool by the actor's own agent (`detail.via === "agent"`). */
20
21
  viaAgent: boolean;
21
22
  /** The action. */
22
23
  action: string;
23
24
  target: string | null;
25
+ /**
26
+ * The target's name when the kernel knows the kind of object and finds it in this log's scope
27
+ * (table pagination spec §3.1); null otherwise. A soft-deleted object keeps its name.
28
+ */
29
+ targetLabel: string | null;
30
+ /** The target is an object of a known kind that no longer exists (or is soft-deleted). */
31
+ targetDeleted: boolean;
24
32
  }
25
- /** A page of {@link AuditEvent}s; `next` is the `after` of the next page, null at the end. */
26
- export interface AuditPage {
27
- events: AuditEvent[];
28
- next: string | null;
29
- }
33
+ /** A page of {@link AuditEvent}s (spec §2.3). */
34
+ export type AuditPage = Paged<AuditEvent>;
30
35
  /** Whose events: the platform's (`org_id IS NULL`, decision D3) or one org's. */
31
36
  export type AuditScope = {
32
37
  platform: true;
@@ -34,19 +39,98 @@ export type AuditScope = {
34
39
  orgId: string;
35
40
  };
36
41
  export interface AuditListQuery {
37
- after?: string | undefined;
38
- limit: number;
42
+ page: number;
43
+ size: number;
44
+ /** The snapshot: the newest event id the first page saw. */
45
+ asOf?: string | undefined;
46
+ /** Events at or after this time (ISO). */
47
+ from?: string | undefined;
48
+ /** Events before this time (ISO). */
49
+ to?: string | undefined;
50
+ /** An account id, `system` or `token:<token id>`. */
51
+ actor?: string | undefined;
39
52
  /** Only actions starting with this prefix. */
40
53
  action?: string | undefined;
54
+ /** The target id, or a part of the target's name. */
55
+ q?: string | undefined;
56
+ }
57
+ /** An account that acted in a log (the actor filter's options). */
58
+ export interface AuditActorAccount {
59
+ id: string;
60
+ /** Null when the account no longer exists. */
61
+ name: string | null;
62
+ email: string | null;
63
+ avatarUrl: string | null;
64
+ }
65
+ /** An access token that acted in a log, by name (`actor=token:<id>`). */
66
+ export interface AuditActorToken {
67
+ id: string;
68
+ name: string;
69
+ /** The owner of a personal token; null for an org's service token. */
70
+ accountId: string | null;
71
+ }
72
+ /** Who acted in a log: at most {@link ACTORS_CAP} accounts and tokens each. */
73
+ export interface AuditActors {
74
+ accounts: AuditActorAccount[];
75
+ tokens: AuditActorToken[];
76
+ /** More accounts or tokens acted than listed. */
77
+ truncated: boolean;
41
78
  }
79
+ /** The most accounts (and tokens) the actor options list. */
80
+ export declare const ACTORS_CAP = 200;
42
81
  /**
43
82
  * Reads the audit log of one scope: the platform's (the admin console's Audit log) or one org's (the
44
- * org settings' Audit log, and the super admin's view of an org), newest first by id, keyset paged
45
- * (`audit_events_platform_idx` / `audit_events_org_id_idx`). Read-only and not audited (D5).
83
+ * org settings' Audit log, and the super admin's view of an org), newest first by id, by page
84
+ * number on a snapshot of ids (table pagination spec §2.3), with the filters of §3 and the
85
+ * targets' names (§3.1). Read-only and not audited (D5). Every query names the scope's `org_id`:
86
+ * an org's log never reads, counts or names another org's rows. The queries of one read run one
87
+ * after another (a read holds one pool connection at a time).
46
88
  */
47
89
  export declare class AuditLogService {
48
90
  private readonly kdb;
49
91
  constructor(kdb: KernelDb);
50
- /** `limit` events with an id below `after` (from the newest without it); one extra row tells `next`. */
92
+ /** The scope's events (`audit_events_platform_idx` / `audit_events_org_id_idx`). */
93
+ private events;
94
+ /**
95
+ * One page. Without `asOf` the snapshot is the newest event id of the scope (whatever the
96
+ * filters; "0" for an empty log), so a later read with it sees the same rows and counts the
97
+ * newer ones.
98
+ *
99
+ * Known caveat (accepted): ids are taken when an event's transaction inserts it, not when it
100
+ * commits, so an event whose transaction commits after the snapshot was taken may carry an id
101
+ * at or below `asOf` and appear inside an older snapshot, shifting later rows of that snapshot
102
+ * by one page position.
103
+ */
51
104
  list(scope: AuditScope, q: AuditListQuery): Promise<AuditPage>;
105
+ /** The newest event id of the scope, "0" when it has none. */
106
+ private newestId;
107
+ /**
108
+ * The filters of `q` as one condition (the scope and the snapshot are added by the caller). `q`
109
+ * matches the target exactly, or by name through one semi-join per kind the scope can name
110
+ * (`audit_events_target_idx` serves the exact match and the `IN (…)` probes).
111
+ */
112
+ private matcher;
113
+ /** The event's key names an object of `kind` in the scope whose name is LIKE `like`. */
114
+ private nameMatch;
115
+ /** The catalog items an org may see: the platform's, its own, and shared ones (the share gate). */
116
+ private catalogShareGate;
117
+ /**
118
+ * The label of each event's target: one query per kind the page holds, one after another (spec
119
+ * §3.1). A known kind whose object is gone is deleted with a null label; an unknown kind has
120
+ * neither.
121
+ */
122
+ private labels;
123
+ /**
124
+ * Objects of one kind by id, within the scope: an org's objects only (its own org, the catalog
125
+ * items it may see); the platform's log names accounts, catalog items and marketplaces.
126
+ */
127
+ private readKind;
128
+ /**
129
+ * The accounts and access tokens that acted in the scope's log (the actor filter's options), by
130
+ * name; at most {@link ACTORS_CAP} of each. Distinct actors are read by a skip scan over
131
+ * `audit_events_actor_idx` / `audit_events_token_idx` (one index probe per actor, not one row
132
+ * per event). Token names come from the scope's own tokens: an org's service tokens, the
133
+ * platform's personal tokens.
134
+ */
135
+ actors(scope: AuditScope): Promise<AuditActors>;
52
136
  }