@capybara-hq/kernel 0.1.0-rc.12 → 0.1.0-rc.14

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 (267) hide show
  1. package/dist/admin/admin.schemas.d.ts +13 -0
  2. package/dist/agents/agent-lookup.d.ts +5 -0
  3. package/dist/agents/agent-lookup.js +15 -0
  4. package/dist/background/background.module.js +2 -2
  5. package/dist/background/launch-lock.d.ts +1 -1
  6. package/dist/background/launch-lock.js +1 -1
  7. package/dist/background/poll.job.d.ts +2 -2
  8. package/dist/background/poll.job.js +10 -10
  9. package/dist/background/stop.d.ts +1 -1
  10. package/dist/background/stop.js +3 -3
  11. package/dist/background/store.d.ts +5 -5
  12. package/dist/background/store.js +5 -5
  13. package/dist/background/tasks.service.d.ts +6 -6
  14. package/dist/background/tasks.service.js +13 -13
  15. package/dist/catalog/admin-catalog.controller.d.ts +13 -2
  16. package/dist/catalog/admin-catalog.controller.js +24 -3
  17. package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
  18. package/dist/catalog/admin-catalog.schemas.js +7 -0
  19. package/dist/catalog/catalog-content.d.ts +9 -1
  20. package/dist/catalog/catalog-content.js +2 -1
  21. package/dist/catalog/catalog-files.d.ts +3 -2
  22. package/dist/catalog/catalog-files.js +8 -5
  23. package/dist/catalog/component-scope.service.d.ts +14 -1
  24. package/dist/catalog/component-scope.service.js +12 -2
  25. package/dist/catalog/marketplaces.service.d.ts +1 -1
  26. package/dist/catalog/org-catalog.controller.d.ts +5 -4
  27. package/dist/catalog/org-catalog.controller.js +5 -4
  28. package/dist/catalog/org-catalog.schemas.d.ts +18 -2
  29. package/dist/catalog/org-catalog.schemas.js +16 -2
  30. package/dist/catalog/org-catalog.service.js +8 -2
  31. package/dist/catalog/plugin-import.js +1 -1
  32. package/dist/catalog/plugin-package.js +37 -9
  33. package/dist/catalog/plugin-upgrade.d.ts +15 -1
  34. package/dist/catalog/plugin-upgrade.js +18 -5
  35. package/dist/channels/channels.module.js +2 -2
  36. package/dist/channels/connections.controller.d.ts +1 -1
  37. package/dist/channels/connections.controller.js +1 -1
  38. package/dist/channels/connections.service.d.ts +22 -5
  39. package/dist/channels/connections.service.js +56 -10
  40. package/dist/channels/inbound.d.ts +8 -8
  41. package/dist/channels/inbound.js +31 -31
  42. package/dist/channels/phrases.d.ts +27 -27
  43. package/dist/channels/phrases.js +27 -27
  44. package/dist/channels/webhook.d.ts +21 -1
  45. package/dist/channels/webhook.js +39 -4
  46. package/dist/config/docs.js +1 -1
  47. package/dist/config/schema.d.ts +2 -2
  48. package/dist/config/schema.js +21 -21
  49. package/dist/conversations/conversations.controller.d.ts +11 -11
  50. package/dist/conversations/conversations.controller.js +15 -15
  51. package/dist/conversations/conversations.module.d.ts +1 -1
  52. package/dist/conversations/conversations.module.js +7 -7
  53. package/dist/conversations/conversations.schemas.js +1 -1
  54. package/dist/conversations/conversations.service.d.ts +14 -14
  55. package/dist/conversations/conversations.service.js +19 -19
  56. package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
  57. package/dist/conversations/{environment-status.js → device-status.js} +18 -18
  58. package/dist/conversations/event-log.d.ts +1 -1
  59. package/dist/conversations/event-log.js +1 -1
  60. package/dist/conversations/events.d.ts +1 -1
  61. package/dist/conversations/events.js +2 -2
  62. package/dist/ctx/create-ctx.d.ts +26 -3
  63. package/dist/ctx/create-ctx.js +134 -26
  64. package/dist/db/kernel-schema.d.ts +37 -25
  65. package/dist/{environments → devices}/access.d.ts +19 -19
  66. package/dist/{environments → devices}/access.js +28 -28
  67. package/dist/devices/conversation-devices.d.ts +75 -0
  68. package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
  69. package/dist/devices/devices.controller.d.ts +36 -0
  70. package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
  71. package/dist/devices/devices.module.d.ts +5 -13
  72. package/dist/devices/devices.module.js +16 -29
  73. package/dist/devices/devices.schemas.d.ts +3 -0
  74. package/dist/devices/devices.schemas.js +14 -0
  75. package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
  76. package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
  77. package/dist/devices/dto.d.ts +13 -54
  78. package/dist/devices/dto.js +7 -39
  79. package/dist/devices/label.d.ts +11 -0
  80. package/dist/{environments → devices}/label.js +7 -7
  81. package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
  82. package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
  83. package/dist/errors.d.ts +29 -25
  84. package/dist/errors.js +29 -25
  85. package/dist/evals/recorded-tools.d.ts +2 -2
  86. package/dist/evals/recorded-tools.js +6 -6
  87. package/dist/extensions/admin-ops.js +1 -0
  88. package/dist/extensions/admin-view.js +2 -0
  89. package/dist/extensions/effective-config.d.ts +6 -0
  90. package/dist/extensions/effective-config.js +18 -7
  91. package/dist/extensions/guide-places.d.ts +66 -0
  92. package/dist/extensions/guide-places.js +152 -0
  93. package/dist/extensions/host.d.ts +13 -2
  94. package/dist/extensions/host.js +27 -6
  95. package/dist/extensions/instance.d.ts +17 -2
  96. package/dist/extensions/instance.js +21 -0
  97. package/dist/extensions/ledger.d.ts +1 -1
  98. package/dist/extensions/permission-set.d.ts +16 -2
  99. package/dist/extensions/permission-set.js +17 -3
  100. package/dist/extensions/permission-view.d.ts +10 -1
  101. package/dist/extensions/plugin-guides.d.ts +207 -54
  102. package/dist/extensions/plugin-guides.js +436 -165
  103. package/dist/files/previewers.d.ts +1 -1
  104. package/dist/files/previewers.js +1 -1
  105. package/dist/http/api.module.js +16 -6
  106. package/dist/http/gateway-routes.d.ts +1 -1
  107. package/dist/http/gateway-routes.js +1 -1
  108. package/dist/identity/settings.d.ts +32 -0
  109. package/dist/identity/settings.js +26 -2
  110. package/dist/infra/config/kernel-config.service.js +4 -4
  111. package/dist/infra/lock/lock.service.d.ts +8 -0
  112. package/dist/infra/lock/lock.service.js +27 -0
  113. package/dist/infra/throttler/named-throttlers.d.ts +4 -1
  114. package/dist/infra/throttler/named-throttlers.js +16 -1
  115. package/dist/infra/throttler/throttler.guard.js +1 -1
  116. package/dist/kernel.module.js +3 -3
  117. package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
  118. package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
  119. package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
  120. package/dist/{devices → local-devices}/device-auth.js +51 -53
  121. package/dist/local-devices/device-auth.module.d.ts +7 -0
  122. package/dist/{devices → local-devices}/device-auth.module.js +5 -5
  123. package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
  124. package/dist/{devices → local-devices}/device-routes.js +2 -2
  125. package/dist/local-devices/dto.d.ts +66 -0
  126. package/dist/local-devices/dto.js +44 -0
  127. package/dist/{devices → local-devices}/keys.d.ts +11 -11
  128. package/dist/{devices → local-devices}/keys.js +11 -11
  129. package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
  130. package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
  131. package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
  132. package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
  133. package/dist/local-devices/local-devices.module.d.ts +16 -0
  134. package/dist/local-devices/local-devices.module.js +44 -0
  135. package/dist/{devices → local-devices}/machines.d.ts +26 -26
  136. package/dist/{devices → local-devices}/machines.js +71 -71
  137. package/dist/{devices → local-devices}/relay.d.ts +15 -15
  138. package/dist/{devices → local-devices}/relay.js +55 -55
  139. package/dist/{devices → local-devices}/targets.d.ts +8 -8
  140. package/dist/{devices → local-devices}/targets.js +14 -14
  141. package/dist/orgs/offboarding.d.ts +6 -6
  142. package/dist/orgs/offboarding.js +12 -12
  143. package/dist/orgs/settings.service.d.ts +28 -0
  144. package/dist/orgs/settings.service.js +20 -1
  145. package/dist/overrides.d.ts +3 -1
  146. package/dist/overrides.js +2 -0
  147. package/dist/platform/exclusions.js +48 -8
  148. package/dist/platform/operation.js +10 -2
  149. package/dist/platform/ops/admin.ops.js +8 -2
  150. package/dist/platform/ops/connectors.ops.js +2 -0
  151. package/dist/platform/ops/conversations.ops.d.ts +3 -3
  152. package/dist/platform/ops/conversations.ops.js +9 -9
  153. package/dist/platform/ops/devices.ops.d.ts +26 -0
  154. package/dist/platform/ops/devices.ops.js +311 -0
  155. package/dist/platform/ops/org-settings.ops.js +2 -2
  156. package/dist/platform/ops/orgs.ops.js +1 -0
  157. package/dist/platform/ops/setup.ops.d.ts +24 -0
  158. package/dist/platform/ops/setup.ops.js +212 -0
  159. package/dist/platform/ops/ui.ops.d.ts +8 -0
  160. package/dist/platform/ops/ui.ops.js +41 -0
  161. package/dist/platform/platform-ops.module.d.ts +4 -2
  162. package/dist/platform/platform-ops.module.js +13 -5
  163. package/dist/platform/route-schemas.js +11 -3
  164. package/dist/roles/gateway-role.d.ts +3 -3
  165. package/dist/roles/gateway-role.js +4 -4
  166. package/dist/roles/gateway.module.d.ts +1 -1
  167. package/dist/roles/gateway.module.js +5 -5
  168. package/dist/roles/worker.module.js +1 -1
  169. package/dist/runtime/context/build.d.ts +1 -1
  170. package/dist/runtime/context/build.js +6 -6
  171. package/dist/runtime/context/compaction.js +1 -1
  172. package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
  173. package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
  174. package/dist/runtime/maintenance.d.ts +1 -1
  175. package/dist/sandbox/jobs.d.ts +13 -13
  176. package/dist/sandbox/jobs.js +20 -20
  177. package/dist/sandbox/leases.d.ts +9 -9
  178. package/dist/sandbox/leases.js +14 -14
  179. package/dist/sandbox/providers.d.ts +8 -8
  180. package/dist/sandbox/providers.js +8 -8
  181. package/dist/sandbox/sandbox.module.d.ts +1 -1
  182. package/dist/sandbox/sandbox.module.js +1 -1
  183. package/dist/sandbox/sandbox.service.d.ts +76 -76
  184. package/dist/sandbox/sandbox.service.js +230 -230
  185. package/dist/setup/kernel-checks.d.ts +91 -0
  186. package/dist/setup/kernel-checks.js +295 -0
  187. package/dist/setup/oauth-token-probe.d.ts +47 -0
  188. package/dist/setup/oauth-token-probe.js +108 -0
  189. package/dist/setup/redact-check.d.ts +18 -0
  190. package/dist/setup/redact-check.js +46 -0
  191. package/dist/setup/setup-check-registry.d.ts +86 -0
  192. package/dist/setup/setup-check-registry.js +75 -0
  193. package/dist/setup/setup-checks.controller.d.ts +28 -0
  194. package/dist/setup/setup-checks.controller.js +78 -0
  195. package/dist/setup/setup-checks.schemas.d.ts +38 -0
  196. package/dist/setup/setup-checks.schemas.js +43 -0
  197. package/dist/setup/setup-checks.service.d.ts +144 -0
  198. package/dist/setup/setup-checks.service.js +683 -0
  199. package/dist/setup/setup-guides.controller.d.ts +18 -0
  200. package/dist/setup/setup-guides.controller.js +48 -0
  201. package/dist/setup/setup-guides.schemas.d.ts +10 -0
  202. package/dist/setup/setup-guides.schemas.js +6 -0
  203. package/dist/setup/setup-guides.service.d.ts +126 -0
  204. package/dist/setup/setup-guides.service.js +315 -0
  205. package/dist/setup/setup.module.d.ts +8 -0
  206. package/dist/setup/setup.module.js +31 -0
  207. package/dist/tools/builtins/builtin-tools.d.ts +2 -2
  208. package/dist/tools/builtins/builtin-tools.js +5 -5
  209. package/dist/tools/builtins/platform.js +1 -1
  210. package/dist/tools/builtins/sandbox/bash.js +6 -6
  211. package/dist/tools/builtins/sandbox/common.d.ts +25 -25
  212. package/dist/tools/builtins/sandbox/common.js +51 -51
  213. package/dist/tools/builtins/sandbox/edit.js +2 -2
  214. package/dist/tools/builtins/sandbox/index.d.ts +1 -1
  215. package/dist/tools/builtins/sandbox/index.js +1 -1
  216. package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
  217. package/dist/tools/builtins/sandbox/task-output.js +10 -10
  218. package/dist/tools/builtins/sandbox/task-stop.js +2 -2
  219. package/dist/tools/builtins/sandbox/write.js +2 -2
  220. package/dist/tools/builtins/skill-load.d.ts +1 -1
  221. package/dist/tools/builtins/skill-load.js +2 -2
  222. package/dist/tools/connectors.controller.d.ts +28 -11
  223. package/dist/tools/connectors.controller.js +49 -14
  224. package/dist/tools/connectors.schemas.d.ts +4 -0
  225. package/dist/tools/connectors.schemas.js +4 -0
  226. package/dist/tools/connectors.service.d.ts +30 -2
  227. package/dist/tools/connectors.service.js +98 -3
  228. package/dist/tools/credentials.d.ts +20 -0
  229. package/dist/tools/credentials.js +90 -1
  230. package/dist/tools/oauth/tokens.d.ts +20 -0
  231. package/dist/tools/oauth/tokens.js +49 -24
  232. package/dist/tools/pipeline.js +4 -3
  233. package/dist/tools/registry.d.ts +2 -2
  234. package/dist/tools/tools.module.js +3 -3
  235. package/dist/ui/admin-ui.controller.d.ts +56 -0
  236. package/dist/ui/admin-ui.controller.js +192 -0
  237. package/dist/ui/arrangement.d.ts +74 -0
  238. package/dist/ui/arrangement.js +98 -0
  239. package/dist/ui/embed-token.d.ts +2 -2
  240. package/dist/ui/embed-token.js +30 -5
  241. package/dist/ui/registry.d.ts +29 -14
  242. package/dist/ui/registry.js +31 -10
  243. package/dist/ui/slots.controller.d.ts +11 -0
  244. package/dist/ui/slots.controller.js +25 -0
  245. package/dist/ui/ui-stream.d.ts +20 -3
  246. package/dist/ui/ui-stream.js +25 -7
  247. package/dist/ui/ui.schemas.d.ts +66 -0
  248. package/dist/ui/ui.schemas.js +65 -0
  249. package/dist/ui/views.controller.d.ts +35 -49
  250. package/dist/ui/views.controller.js +48 -70
  251. package/dist/ui/views.d.ts +84 -18
  252. package/dist/ui/views.js +201 -38
  253. package/package.json +3 -3
  254. package/src/migrations/0105_devices_rename.sql +136 -0
  255. package/src/migrations/0106_setup_guides_v2.sql +10 -0
  256. package/dist/devices/device-auth.module.d.ts +0 -7
  257. package/dist/environments/conversation-environments.d.ts +0 -75
  258. package/dist/environments/dto.d.ts +0 -25
  259. package/dist/environments/dto.js +0 -12
  260. package/dist/environments/environments.controller.d.ts +0 -36
  261. package/dist/environments/environments.module.d.ts +0 -8
  262. package/dist/environments/environments.module.js +0 -31
  263. package/dist/environments/environments.schemas.d.ts +0 -3
  264. package/dist/environments/environments.schemas.js +0 -14
  265. package/dist/environments/label.d.ts +0 -11
  266. package/dist/platform/ops/environments.ops.d.ts +0 -26
  267. package/dist/platform/ops/environments.ops.js +0 -311
@@ -1,92 +1,225 @@
1
- import { type PluginSetupGuide, type SetupGuideLanguage, type SetupGuidePlace, type SetupGuideText } from "@capybara-hq/plugin-sdk";
1
+ import { type PluginSetupGuide, type SetupGuideAudience, type SetupGuideBlock, type SetupGuidePlace } from "@capybara-hq/plugin-sdk";
2
2
  import type { GuideAckJson } from "../db/kernel-schema.js";
3
3
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
4
4
  import { KernelDb } from "../infra/database/kernel-db.js";
5
+ import type { KernelLogger } from "../log.js";
5
6
  import { type OrgRole } from "../orgs/roles.js";
6
- /** The setup guide a channel connection was set up with (`channel_connections.guide_ack`). */
7
+ import { type GuideTarget, type GuideTargetQuery, type UnresolvedReason } from "./guide-places.js";
8
+ export { PLACE_ACTIONS, type UnresolvedReason } from "./guide-places.js";
9
+ /**
10
+ * The setup guide a target was set up with (`channel_connections.guide_ack`,
11
+ * `connectors.guide_ack`): the guide, the plugin version, the drift hash of the admin audience and
12
+ * the mode (null for a place without modes).
13
+ */
7
14
  export type GuideAck = GuideAckJson;
8
- /** Where a channel page finds its plugin's guide (`GET /orgs/:orgId/catalog/:itemId/guides/:guideId`). */
15
+ /** Where a page finds its plugin's guide (`GET /orgs/:orgId/catalog/:itemId/guides/:guideId`). */
9
16
  export interface SetupGuideRef {
10
17
  itemId: string;
11
18
  guideId: string;
12
19
  /** The item's latest version (the guide's). */
13
20
  version: string;
14
21
  }
15
- /** The guide fields of a channel connection page. */
22
+ /** The guide fields of a channel connection or connector page. */
16
23
  export interface ConnectionGuideState {
17
- /** The plugin's channel-connection guide the org may see, null without one. */
24
+ /**
25
+ * The plugin's channel-connection guide (or the connector's template guide) the org may see,
26
+ * null without one.
27
+ */
18
28
  setupGuide: SetupGuideRef | null;
19
29
  /**
20
- * The plugin changed the guide's templates since the connection was set up (its ack): the
21
- * version acked and the current one; null otherwise (or without an ack).
30
+ * The plugin changed the guide's code blocks or checks for the ack's mode since the connection
31
+ * was set up (its ack): the version acked and the current one; null otherwise (or without an
32
+ * ack).
22
33
  */
23
34
  guideDrift: {
24
35
  from: string;
25
36
  to: string;
26
37
  } | null;
27
38
  }
28
- /** A guide rendered for an org (spec 2026-11-08-plugin-setup-guides-design.md §4). */
39
+ /** Where a connector template's page finds its guide (`guide` of the template entries). */
40
+ export interface TemplateGuideRef {
41
+ itemId: string;
42
+ guideId: string;
43
+ }
44
+ /**
45
+ * A template whose guide an update changes (the platform update preview, spec §11): the admin
46
+ * hash differs between the platform's current version and the target. `orgs` counts the orgs with
47
+ * a connector set up with that guide (an ack of it) whose ack the target leaves behind: org admins
48
+ * asked to update their app. Counts only, never org names.
49
+ */
50
+ export interface TemplateGuideChange {
51
+ templateId: string;
52
+ guideId: string;
53
+ /** The platform's current version (null: never synced). */
54
+ from: string | null;
55
+ to: string;
56
+ orgs: number;
57
+ }
58
+ /** A guide rendered for an org or the platform (spec 2026-11-09-setup-guides-v2-design.md §7.2). */
29
59
  export interface RenderedSetupGuide {
30
60
  itemId: string;
31
61
  plugin: string;
32
62
  version: string;
33
63
  id: string;
34
64
  place: SetupGuidePlace;
35
- title: SetupGuideText;
36
- /** The modes the guide's steps and files use; empty = no mode switch. */
65
+ /** The connector template a `connector-template` guide is for; null for other places. */
66
+ template: string | null;
67
+ /** The document rendered (zh falls back to en). */
68
+ locale: "en" | "zh";
69
+ title: string;
70
+ /** The modes the document's sections use; empty = no mode switch. */
37
71
  modes: string[];
38
- /** The mode rendered (null for a guide without modes and no connection). */
72
+ /** The mode rendered; null for a place without modes. */
39
73
  mode: string | null;
40
- steps: SetupGuideText[];
41
- files: {
42
- title: SetupGuideText;
43
- language: SetupGuideLanguage;
44
- fileName: string;
45
- content: string;
74
+ /** The audiences the document has sections for. */
75
+ audiences: SetupGuideAudience[];
76
+ audience: SetupGuideAudience;
77
+ blocks: SetupGuideBlock[];
78
+ /** The check rows, in document order. */
79
+ checks: {
80
+ id: string;
81
+ label: string;
82
+ source: "plugin" | "kernel";
83
+ }[];
84
+ /** Known variables the rendered text uses without a value (left as written), with why. */
85
+ unresolved: {
86
+ name: string;
87
+ reason: UnresolvedReason;
46
88
  }[];
47
- /** Known variables without a value here (left as written, e.g. webhookUrl before saving). */
48
- unresolved: string[];
49
- /** The template hash of this mode (what an ack records). */
89
+ /** The drift hash of this mode and audience (what an ack records). */
50
90
  hash: string;
91
+ target: GuideTarget | null;
92
+ }
93
+ /** The query of the guide route. */
94
+ export interface GuideQuery extends GuideTargetQuery {
95
+ mode?: string | undefined;
96
+ audience?: SetupGuideAudience | undefined;
97
+ locale?: "en" | "zh" | undefined;
51
98
  }
52
99
  type VersionFile = {
53
100
  path: string;
54
101
  size: number;
55
102
  sha256: string;
56
103
  };
104
+ /** The live items (with their latest version) by name or id. */
105
+ declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[]): Promise<{
106
+ awaiting_confirmation: boolean;
107
+ builtin: boolean;
108
+ disabled: boolean;
109
+ files: {
110
+ path: string;
111
+ size: number;
112
+ sha256: string;
113
+ }[];
114
+ id: string;
115
+ latest_version: string;
116
+ manifest: unknown;
117
+ name: string;
118
+ owner_org_id: string | null;
119
+ scope: "all" | "named" | "optional";
120
+ shareable: boolean;
121
+ shown_to_others: boolean;
122
+ }[]>;
123
+ /** A live item with its latest version, as {@link PluginGuides} reads it. */
124
+ export type ItemRow = Awaited<ReturnType<typeof latestItems>>[number];
57
125
  /**
58
- * The template hash of a guide for a mode (spec §6): sha256 over `path NUL sha256 LF` of the files
59
- * that apply to it, from the version's file list (no storage read). Equal hashes = the same
60
- * rendered files for the same variables.
126
+ * A connector template's guide in a version's manifest (v2 entries only), for callers that already
127
+ * hold the manifest (the org catalog detail).
61
128
  */
62
- export declare function setupGuideHash(guide: PluginSetupGuide, files: VersionFile[], mode: string | null): string;
129
+ export declare const templateGuideOf: (manifest: unknown, templateId: string) => PluginSetupGuide | undefined;
63
130
  /**
64
- * Plugin setup guides (spec `2026-11-08-plugin-setup-guides-design.md`): resolves an extension's
65
- * catalog item (the item of the same name, its latest version), renders a guide's steps and
66
- * template files with the place's fixed variables (public URLs, names, versions, the mode; never a
67
- * secret), and computes the template hashes channel connections record to tell when an upgrade
68
- * changed their setup. Org reads follow the catalog icon's visibility ({@link orgVisibleItems}).
69
- * Stateless: everything comes from PG (version rows, connection rows, the guide files in
70
- * `catalog_files`).
131
+ * Plugin setup guides v2 (spec `2026-11-09-setup-guides-v2-design.md`): resolves an extension's
132
+ * catalog item (the item of the same name, its latest version), renders a guide document for a
133
+ * place, audience, mode and target with the place's safe variables (`guide-places.ts`; never a
134
+ * secret), and computes the drift hashes targets record to tell when an upgrade changed their
135
+ * setup. Org reads follow the catalog icon's visibility ({@link orgVisibleItems}), the platform
136
+ * preview any live item. Stateless: everything comes from PG (version rows, target rows, the
137
+ * documents in `catalog_files`).
71
138
  */
72
139
  export declare class PluginGuides {
73
140
  private readonly db;
74
141
  private readonly config;
75
- constructor(db: KernelDb, config: Pick<KernelConfigService, "get">);
76
- /** The live items (with their latest version) by name or id. */
142
+ private readonly log;
143
+ constructor(db: KernelDb, config: Pick<KernelConfigService, "get">, log: Pick<KernelLogger, "warn">);
77
144
  private latest;
145
+ /** The rows the org's catalog shows ({@link orgVisibleItems}); all of them without an org. */
146
+ private visibleTo;
147
+ /** The English documents of guides, by `<itemId>/<guideId>` (one PG read); absent when not stored. */
148
+ private englishSources;
149
+ /** The admin drift hash of a guide for a mode. */
150
+ private static hashOf;
78
151
  /**
79
- * The ack of a plugin's current channel-connection guide for a mode (recorded on a connection
80
- * when it is created or switches mode); null when the plugin has no catalog item or no guide.
81
- * Kernel-internal: no org visibility (the connection belongs to the plugin either way).
152
+ * The ack of a plugin's current guide for a place (and template) and mode, admin audience:
153
+ * recorded on a target when it is created or switches mode. Null when the plugin has no catalog
154
+ * item, no such guide or no stored document. Without `org` kernel-internal (no org visibility:
155
+ * the target belongs to the plugin either way); with `org` (a person acking the guide) null
156
+ * also when the org's catalog does not show the item, the guide read's rule.
82
157
  */
83
- currentAck(plugin: string, mode: string): Promise<GuideAck | null>;
158
+ currentAck(plugin: string, place: SetupGuidePlace, o: {
159
+ mode: string | null;
160
+ templateId?: string;
161
+ org?: {
162
+ orgId: string;
163
+ role: OrgRole;
164
+ };
165
+ }): Promise<GuideAck | null>;
84
166
  /**
85
- * Whether an ack is behind the plugin's current guide (the drift rule of spec §6, as the
86
- * connection pages compute it): the same guide whose templates for the ack's mode changed. False
87
- * without an ack, a catalog item or the guide. Kernel-internal: no org visibility.
167
+ * Whether an ack is behind the plugin's current guide (spec §11): the same guide whose hash for
168
+ * the ack's mode changed. False without an ack, a catalog item or the guide. Kernel-internal: no
169
+ * org visibility.
88
170
  */
89
- ackDrifted(plugin: string, ack: GuideAck | null): Promise<boolean>;
171
+ ackDrifted(plugin: string, place: SetupGuidePlace, ack: GuideAck | null, o?: {
172
+ templateId?: string;
173
+ }): Promise<boolean>;
174
+ /**
175
+ * The ack of a connector template's current guide (admin audience, no mode): recorded on a
176
+ * connector when it is created from the template. Null when the item has no guide for the
177
+ * template or no stored document. Without `org` kernel-internal (no org visibility: the caller is
178
+ * creating or reading the org's own connector of that template); with `org` (a person acking the
179
+ * guide) null also when the org's catalog does not show the item.
180
+ */
181
+ templateAck(itemId: string, templateId: string, org?: {
182
+ orgId: string;
183
+ role: OrgRole;
184
+ }): Promise<GuideAck | null>;
185
+ /**
186
+ * `<itemId>/<templateId>` -> the template's guide in the item's latest version, for the template
187
+ * entries of the catalog detail and the components list; templates without one are absent.
188
+ * Kernel-internal: callers list only items and templates the org already sees.
189
+ */
190
+ templateGuides(pairs: {
191
+ itemId: string;
192
+ templateId: string;
193
+ }[]): Promise<Map<string, TemplateGuideRef>>;
194
+ /**
195
+ * The guide fields of connectors (spec §9.3, §11): a connector made from a template
196
+ * (`itemId` / `templateId` of its platform template) whose item the org's catalog shows gets the
197
+ * template's guide; drift = an ack of the same guide whose admin hash changed. Custom connectors
198
+ * (no template) get nulls. One query each for items and documents.
199
+ */
200
+ connectorStates(connectors: {
201
+ id: string;
202
+ itemId: string | null;
203
+ templateId: string | null;
204
+ guideAck: GuideAck | null;
205
+ }[], org: {
206
+ orgId: string;
207
+ role: OrgRole;
208
+ }): Promise<Map<string, ConnectionGuideState>>;
209
+ /**
210
+ * The connector template guides an update of an item changes (the platform update preview,
211
+ * {@link TemplateGuideChange}): per template guide of the target whose admin hash differs from
212
+ * the platform's current version's (a guide new in the target counts only when connectors hold
213
+ * an ack of it). Documents a version does not store are skipped. Kernel-internal (the super
214
+ * admin's or the owner's preview).
215
+ */
216
+ templateGuideChanges(itemId: string, from: string | null, to: {
217
+ version: string;
218
+ manifest: unknown;
219
+ files: VersionFile[];
220
+ }): Promise<TemplateGuideChange[]>;
221
+ /** The admin drift hash of a guide in a version (no mode), or undefined when not stored. */
222
+ private storedHash;
90
223
  /**
91
224
  * Plugin name -> its channel-connection guide, for plugins whose item the org's catalog shows
92
225
  * (`GET channels/schema/:plugin` and the connection pages); others are absent.
@@ -96,9 +229,9 @@ export declare class PluginGuides {
96
229
  role: OrgRole;
97
230
  }): Promise<Map<string, SetupGuideRef & {
98
231
  guide: PluginSetupGuide;
99
- files: VersionFile[];
232
+ row: ItemRow;
100
233
  }>>;
101
- /** The guide fields of channel connections (one query for all; spec §6 for the drift rule). */
234
+ /** The guide fields of channel connections (one query each for guides and documents; spec §11). */
102
235
  connectionStates(connections: {
103
236
  id: string;
104
237
  plugin: string;
@@ -107,23 +240,43 @@ export declare class PluginGuides {
107
240
  orgId: string;
108
241
  role: OrgRole;
109
242
  }): Promise<Map<string, ConnectionGuideState>>;
243
+ /**
244
+ * The documents of a guide of an item's latest version (no visibility check: callers check it):
245
+ * the source in `locale` (falling back to English), the English source (hashes, check lookup) and
246
+ * the locale actually read. 404 `catalog.item_not_found` / `catalog.guide_not_found`.
247
+ */
248
+ loadDocument(itemId: string, guideId: string, locale: "en" | "zh"): Promise<{
249
+ row: ItemRow;
250
+ guide: PluginSetupGuide;
251
+ source: string;
252
+ enSource: string;
253
+ locale: "en" | "zh";
254
+ }>;
255
+ /** Reads and checks a guide's stored documents (one PG read). */
256
+ private documents;
257
+ /** Logs the stored guide entries a version skips (once per render). */
258
+ private warnSkipped;
110
259
  /**
111
260
  * Renders a guide for an org (`GET /orgs/:orgId/catalog/:itemId/guides/:guideId`): the item must
112
261
  * be one the org's catalog shows (else `catalog.item_not_found`), the guide one its latest
113
- * version has (else `catalog.guide_not_found`), and the caller must hold the place's action
114
- * (`channels.manage` for `channel-connection`, else `forbidden`). `connectionId` (a live
115
- * connection of the org on this plugin, else `channel.not_found`) supplies the connection's name,
116
- * webhook URL and default mode; `name` stands in for the name on 新建渠道.
262
+ * version has (else `catalog.guide_not_found`), `mode` and `audience` the place's (else
263
+ * `validation_failed`), and the caller must hold the place and audience's action
264
+ * ({@link PLACE_ACTIONS}, else `forbidden`). The target parameters are the place's
265
+ * (`guide-places.ts`): a target must be a live object of the org on the plugin, else 404.
117
266
  */
118
267
  render(org: {
119
268
  orgId: string;
120
269
  role: OrgRole;
121
- }, itemId: string, guideId: string, q: {
122
- mode?: string | undefined;
123
- connectionId?: string | undefined;
124
- name?: string | undefined;
270
+ }, itemId: string, guideId: string, q: GuideQuery): Promise<RenderedSetupGuide>;
271
+ /**
272
+ * Renders a guide for the platform (the super admin's preview, `GET /admin/catalog/:itemId/guides/
273
+ * :guideId`): any live item, the admin audience, no org (`orgName` unresolved) and no target.
274
+ */
275
+ renderForPlatform(itemId: string, guideId: string, q: {
276
+ locale?: "en" | "zh" | undefined;
125
277
  }): Promise<RenderedSetupGuide>;
126
- /** A live connection of the org on the plugin; otherwise `channel.not_found`. */
127
- private connection;
278
+ /** The audience asked for, after checking `mode` and `audience` against the place. */
279
+ private checkQuery;
280
+ /** The rendered guide: the mode picked, the document rendered, the hash and the reasons. */
281
+ private renderDoc;
128
282
  }
129
- export {};