@capybara-hq/kernel 0.1.0-rc.65 → 0.1.0-rc.67

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 (177) hide show
  1. package/bootstrap.json +0 -8
  2. package/dist/admin/admin.schemas.d.ts +3 -0
  3. package/dist/agents/admin-agents.d.ts +2 -2
  4. package/dist/agents/admin-agents.js +2 -1
  5. package/dist/agents/agent-lookup.js +2 -1
  6. package/dist/agents/agent-profile.service.d.ts +5 -2
  7. package/dist/agents/agent-profile.service.js +13 -2
  8. package/dist/agents/agents.controller.d.ts +4 -3
  9. package/dist/agents/agents.controller.js +7 -3
  10. package/dist/agents/agents.module.js +3 -0
  11. package/dist/agents/agents.schemas.d.ts +6 -6
  12. package/dist/agents/agents.service.d.ts +23 -2
  13. package/dist/agents/agents.service.js +61 -6
  14. package/dist/agents/avatar-view.d.ts +8 -0
  15. package/dist/agents/avatar-view.js +12 -0
  16. package/dist/agents/profile.d.ts +38 -13
  17. package/dist/agents/profile.js +31 -20
  18. package/dist/attribution/platform-attribution.d.ts +15 -6
  19. package/dist/attribution/platform-attribution.js +31 -14
  20. package/dist/background/poll.job.d.ts +1 -1
  21. package/dist/background/poll.job.js +8 -6
  22. package/dist/background/tasks.service.js +1 -1
  23. package/dist/catalog/catalog-content.d.ts +6 -3
  24. package/dist/catalog/catalog-content.js +7 -8
  25. package/dist/catalog/claude/translate.js +1 -1
  26. package/dist/catalog/marketplaces.service.d.ts +1 -1
  27. package/dist/catalog/marketplaces.service.js +2 -1
  28. package/dist/catalog/plugin-package.d.ts +3 -2
  29. package/dist/channels/file-delivery.d.ts +2 -0
  30. package/dist/channels/file-delivery.js +1 -1
  31. package/dist/channels/inbound.d.ts +8 -4
  32. package/dist/channels/inbound.js +14 -7
  33. package/dist/channels/outbound.js +11 -5
  34. package/dist/channels/phrases.d.ts +21 -13
  35. package/dist/channels/phrases.js +21 -14
  36. package/dist/client/client-files.js +1 -1
  37. package/dist/config/product-name.d.ts +8 -0
  38. package/dist/config/product-name.js +9 -0
  39. package/dist/config/schema.d.ts +1 -0
  40. package/dist/config/schema.js +17 -4
  41. package/dist/conversations/conversations.service.d.ts +4 -3
  42. package/dist/conversations/conversations.service.js +15 -2
  43. package/dist/ctx/create-ctx.js +5 -2
  44. package/dist/ctx/device-provider-check.d.ts +7 -0
  45. package/dist/ctx/device-provider-check.js +21 -0
  46. package/dist/db/kernel-schema.d.ts +7 -0
  47. package/dist/devices/access.d.ts +16 -46
  48. package/dist/devices/access.js +26 -62
  49. package/dist/devices/access.module.js +2 -2
  50. package/dist/devices/conversation-devices.d.ts +38 -18
  51. package/dist/devices/conversation-devices.js +69 -51
  52. package/dist/devices/default-provider-setting.d.ts +45 -0
  53. package/dist/devices/default-provider-setting.js +59 -0
  54. package/dist/devices/device-projects.service.js +7 -2
  55. package/dist/devices/device-provider-selection.d.ts +37 -0
  56. package/dist/devices/device-provider-selection.js +86 -0
  57. package/dist/devices/device-provider-selection.module.d.ts +3 -0
  58. package/dist/devices/device-provider-selection.module.js +22 -0
  59. package/dist/devices/devices.controller.d.ts +8 -5
  60. package/dist/devices/devices.controller.js +7 -4
  61. package/dist/devices/devices.module.js +3 -1
  62. package/dist/devices/devices.schemas.js +2 -2
  63. package/dist/devices/devices.service.d.ts +72 -83
  64. package/dist/devices/devices.service.js +139 -248
  65. package/dist/devices/dto.d.ts +9 -0
  66. package/dist/devices/dto.js +15 -2
  67. package/dist/devices/label.d.ts +3 -5
  68. package/dist/devices/label.js +3 -14
  69. package/dist/devices/legacy-cleanup.job.d.ts +2 -2
  70. package/dist/devices/legacy-cleanup.job.js +6 -6
  71. package/dist/errors.d.ts +15 -1
  72. package/dist/errors.js +15 -1
  73. package/dist/extensions/guide-places.d.ts +2 -1
  74. package/dist/extensions/guide-places.js +8 -2
  75. package/dist/extensions/locks.d.ts +1 -1
  76. package/dist/extensions/locks.js +1 -1
  77. package/dist/extensions/org-config.d.ts +20 -4
  78. package/dist/extensions/org-config.js +23 -6
  79. package/dist/extensions/permission-view.d.ts +2 -2
  80. package/dist/extensions/permission-view.js +2 -2
  81. package/dist/extensions/plugin-guides.d.ts +1 -1
  82. package/dist/extensions/plugin-guides.js +11 -3
  83. package/dist/extensions/point-defaults.d.ts +14 -0
  84. package/dist/extensions/point-defaults.js +70 -47
  85. package/dist/extensions/resolve.js +7 -2
  86. package/dist/git/gateway.d.ts +9 -0
  87. package/dist/git/gateway.js +36 -17
  88. package/dist/git/gateway.route.d.ts +1 -1
  89. package/dist/git/gateway.route.js +1 -3
  90. package/dist/http/app.d.ts +1 -1
  91. package/dist/identity/app-auth.d.ts +4 -3
  92. package/dist/identity/app-auth.js +7 -8
  93. package/dist/identity/settings.d.ts +8 -0
  94. package/dist/identity/settings.js +30 -3
  95. package/dist/identity/sso.d.ts +13 -7
  96. package/dist/identity/sso.js +21 -7
  97. package/dist/infra/config/kernel-config.service.js +3 -1
  98. package/dist/lifecycle/kernel-lifecycle.js +7 -6
  99. package/dist/local-devices/device-routes.d.ts +1 -1
  100. package/dist/local-devices/device-routes.js +2 -2
  101. package/dist/local-devices/local-device-provider.d.ts +14 -11
  102. package/dist/local-devices/local-device-provider.js +14 -0
  103. package/dist/local-devices/local-devices.module.d.ts +4 -4
  104. package/dist/local-devices/local-devices.module.js +5 -3
  105. package/dist/local-devices/owner-report.js +2 -1
  106. package/dist/local-devices/targets.d.ts +2 -0
  107. package/dist/local-devices/targets.js +10 -0
  108. package/dist/orgs/offboarding.js +9 -0
  109. package/dist/orgs/settings.service.d.ts +26 -1
  110. package/dist/orgs/settings.service.js +44 -3
  111. package/dist/platform/ops/admin.ops.js +8 -3
  112. package/dist/platform/ops/agents.ops.d.ts +6 -1
  113. package/dist/platform/ops/agents.ops.js +38 -11
  114. package/dist/platform/ops/devices.ops.js +25 -20
  115. package/dist/platform/ops/orgs.ops.js +1 -0
  116. package/dist/platform/ops/platform-icons.ops.js +4 -4
  117. package/dist/platform/ops/platform.ops.js +2 -1
  118. package/dist/platform/ops/themes.ops.js +1 -1
  119. package/dist/runtime/plugin-context.service.js +1 -12
  120. package/dist/sandbox/cloud-permission-snapshot.d.ts +2 -2
  121. package/dist/sandbox/cloud-permission-snapshot.js +3 -3
  122. package/dist/sandbox/device-reports.d.ts +50 -0
  123. package/dist/sandbox/device-reports.js +157 -0
  124. package/dist/sandbox/held-operations.d.ts +8 -8
  125. package/dist/sandbox/leases.d.ts +1 -1
  126. package/dist/sandbox/leases.js +1 -1
  127. package/dist/sandbox/operation-authority.d.ts +5 -2
  128. package/dist/sandbox/operation-authority.js +12 -11
  129. package/dist/sandbox/operation-reconcile.job.d.ts +2 -2
  130. package/dist/sandbox/operation-reconcile.job.js +5 -5
  131. package/dist/sandbox/permission-availability.d.ts +2 -2
  132. package/dist/sandbox/permission-call-types.d.ts +5 -0
  133. package/dist/sandbox/permission-facts.d.ts +2 -2
  134. package/dist/sandbox/permission-facts.js +5 -5
  135. package/dist/sandbox/providers.d.ts +23 -24
  136. package/dist/sandbox/providers.js +38 -46
  137. package/dist/sandbox/providers.module.js +3 -3
  138. package/dist/sandbox/review/classifier.d.ts +6 -0
  139. package/dist/sandbox/review/classifier.js +12 -1
  140. package/dist/sandbox/review/index.d.ts +1 -1
  141. package/dist/sandbox/review/index.js +1 -1
  142. package/dist/sandbox/sandbox.module.d.ts +1 -1
  143. package/dist/sandbox/sandbox.module.js +7 -2
  144. package/dist/sandbox/sandbox.service.d.ts +95 -68
  145. package/dist/sandbox/sandbox.service.js +212 -208
  146. package/dist/setup/setup-guides.service.d.ts +4 -1
  147. package/dist/setup/setup-guides.service.js +6 -1
  148. package/dist/themes/avatar-preset-key.d.ts +6 -0
  149. package/dist/themes/avatar-preset-key.js +9 -0
  150. package/dist/themes/platform-icon.service.js +1 -1
  151. package/dist/themes/theme-delivery.service.d.ts +10 -2
  152. package/dist/themes/theme-delivery.service.js +26 -11
  153. package/dist/themes/theme-state.d.ts +43 -2
  154. package/dist/themes/theme-state.js +61 -4
  155. package/dist/themes/themes-public.controller.d.ts +3 -3
  156. package/dist/themes/themes-public.controller.js +3 -3
  157. package/dist/themes/themes.service.d.ts +28 -1
  158. package/dist/themes/themes.service.js +36 -2
  159. package/dist/tools/builtins/image/generate.d.ts +3 -0
  160. package/dist/tools/builtins/image/generate.js +21 -11
  161. package/dist/tools/builtins/image/index.d.ts +1 -1
  162. package/dist/tools/builtins/image/index.js +1 -1
  163. package/dist/tools/builtins/platform.js +25 -17
  164. package/dist/tools/builtins/sandbox/common.d.ts +37 -13
  165. package/dist/tools/builtins/sandbox/common.js +63 -19
  166. package/dist/tools/builtins/sandbox/read.d.ts +5 -2
  167. package/dist/tools/builtins/sandbox/read.js +9 -6
  168. package/dist/tools/builtins/sandbox/task-output.d.ts +2 -2
  169. package/dist/tools/builtins/sandbox/task-output.js +6 -5
  170. package/dist/tools/builtins/skill-load.js +13 -4
  171. package/dist/tools/connectors.service.js +2 -1
  172. package/dist/tools/oauth/discovery.d.ts +2 -0
  173. package/dist/tools/oauth/discovery.js +3 -1
  174. package/dist/until-aborted.d.ts +5 -0
  175. package/dist/until-aborted.js +16 -0
  176. package/package.json +4 -4
  177. package/src/migrations/0176_device_report.sql +6 -0
@@ -3,11 +3,11 @@ import type { KernelConfig } from "../config/schema.js";
3
3
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
4
4
  import type { KernelLogger } from "../log.js";
5
5
  /**
6
- * The Capybara attribution of agent-created git commits and pull requests (spec
6
+ * The attribution of agent-created git commits and pull requests (spec
7
7
  * 2026-11-14-agent-attribution): the platform defaults, and the merge of an agent's own override
8
8
  * over them. Each field is read env > config file (or Nacos) > the super admin's choice in the
9
9
  * admin console (deployment setting {@link PLATFORM_ATTRIBUTION_SETTING}) > {@link
10
- * ATTRIBUTION_DEFAULTS}; a field set in the startup config is read-only in the admin console.
10
+ * attributionDefaults} for the platform name; a field set in the startup config is read-only in the admin console.
11
11
  * Nothing here is enforcement: the run records the effective values in its log and the model is
12
12
  * instructed to use them.
13
13
  */
@@ -54,7 +54,13 @@ export interface PlatformAttribution {
54
54
  /** Whether agent-created pull requests also carry the conversation link. */
55
55
  sessionUrl: boolean;
56
56
  }
57
- /** What a field falls back to when neither the startup config nor the admin console sets it. */
57
+ /**
58
+ * What a field falls back to when neither the startup config nor the admin console sets it, for
59
+ * the platform name `product` (`platform.name`): the trailer names the platform (the address stays
60
+ * the no-reply one), and the pull-request line links the upstream project only under its own name.
61
+ */
62
+ export declare function attributionDefaults(product: string): Readonly<PlatformAttribution>;
63
+ /** The defaults of a deployment that sets no `platform.name`. */
58
64
  export declare const ATTRIBUTION_DEFAULTS: Readonly<PlatformAttribution>;
59
65
  /** Where a field's effective value comes from. */
60
66
  export type PlatformAttributionSource = "env" | "file" | "nacos" | "db" | "default";
@@ -70,15 +76,18 @@ export type ConfigAttribution = KernelConfig["attribution"];
70
76
  * attribution line on a commit or a pull request.
71
77
  */
72
78
  export declare function parseStoredPlatformAttribution(value: unknown, log?: Pick<KernelLogger, "warn">): PlatformAttributionStored;
73
- /** The effective defaults of the startup config over the stored choice. */
74
- export declare function resolvePlatformAttribution(config: ConfigAttribution, stored: PlatformAttributionStored): PlatformAttribution;
79
+ /**
80
+ * The effective defaults of the startup config over the stored choice, else the built-in ones for
81
+ * the platform name `product`.
82
+ */
83
+ export declare function resolvePlatformAttribution(config: ConfigAttribution, stored: PlatformAttributionStored, product: string): PlatformAttribution;
75
84
  /** The stored choice with `patch` applied (null clears a field). */
76
85
  export declare function applyPlatformAttributionPatch(stored: PlatformAttributionStored, patch: PlatformAttributionPatch): PlatformAttributionStored;
77
86
  /** The stored choice, read live (in the caller's transaction when there is one). */
78
87
  export declare function readStoredPlatformAttribution(db: KernelSchemaDb, log?: Pick<KernelLogger, "warn">): Promise<PlatformAttributionStored>;
79
88
  /** The platform's effective defaults, read live: see {@link resolvePlatformAttribution}. */
80
89
  export declare function readPlatformAttribution(db: KernelSchemaDb, config: {
81
- get(): Pick<KernelConfig, "attribution">;
90
+ get(): Pick<KernelConfig, "attribution" | "platform">;
82
91
  }, log?: Pick<KernelLogger, "warn">): Promise<PlatformAttribution>;
83
92
  /**
84
93
  * The link that ends an agent-created pull request when the deployment set `http.publicUrl` (a
@@ -1,10 +1,11 @@
1
1
  import { z } from "zod";
2
+ import { DEFAULT_PRODUCT_NAME, productName } from "../config/product-name.js";
2
3
  /**
3
- * The Capybara attribution of agent-created git commits and pull requests (spec
4
+ * The attribution of agent-created git commits and pull requests (spec
4
5
  * 2026-11-14-agent-attribution): the platform defaults, and the merge of an agent's own override
5
6
  * over them. Each field is read env > config file (or Nacos) > the super admin's choice in the
6
7
  * admin console (deployment setting {@link PLATFORM_ATTRIBUTION_SETTING}) > {@link
7
- * ATTRIBUTION_DEFAULTS}; a field set in the startup config is read-only in the admin console.
8
+ * attributionDefaults} for the platform name; a field set in the startup config is read-only in the admin console.
8
9
  * Nothing here is enforcement: the run records the effective values in its log and the model is
9
10
  * instructed to use them.
10
11
  */
@@ -55,12 +56,22 @@ export const PLATFORM_ATTRIBUTION_PATCH = z
55
56
  .refine((o) => Object.values(o).some((v) => v !== undefined), {
56
57
  message: "give commit, pr, sessionUrl or several",
57
58
  });
58
- /** What a field falls back to when neither the startup config nor the admin console sets it. */
59
- export const ATTRIBUTION_DEFAULTS = Object.freeze({
60
- commit: "Co-Authored-By: Capybara <noreply@capybarahq.com>",
61
- pr: "🤖 Generated with [Capybara](https://github.com/capybara-hq/core)",
62
- sessionUrl: false,
63
- });
59
+ /**
60
+ * What a field falls back to when neither the startup config nor the admin console sets it, for
61
+ * the platform name `product` (`platform.name`): the trailer names the platform (the address stays
62
+ * the no-reply one), and the pull-request line links the upstream project only under its own name.
63
+ */
64
+ export function attributionDefaults(product) {
65
+ return Object.freeze({
66
+ commit: `Co-Authored-By: ${product} <noreply@capybarahq.com>`,
67
+ pr: product === DEFAULT_PRODUCT_NAME
68
+ ? `🤖 Generated with [${DEFAULT_PRODUCT_NAME}](https://github.com/capybara-hq/core)`
69
+ : `🤖 Generated with ${product}`,
70
+ sessionUrl: false,
71
+ });
72
+ }
73
+ /** The defaults of a deployment that sets no `platform.name`. */
74
+ export const ATTRIBUTION_DEFAULTS = attributionDefaults(DEFAULT_PRODUCT_NAME);
64
75
  /**
65
76
  * Parses the stored choice: missing -> `{}`; invalid -> `{}` (the defaults), with a warning on
66
77
  * `log`. Unlike the sandbox tiers there is no narrower reading: the worst case is a visible
@@ -77,12 +88,16 @@ export function parseStoredPlatformAttribution(value, log) {
77
88
  });
78
89
  return {};
79
90
  }
80
- /** The effective defaults of the startup config over the stored choice. */
81
- export function resolvePlatformAttribution(config, stored) {
91
+ /**
92
+ * The effective defaults of the startup config over the stored choice, else the built-in ones for
93
+ * the platform name `product`.
94
+ */
95
+ export function resolvePlatformAttribution(config, stored, product) {
96
+ const defaults = attributionDefaults(product);
82
97
  return {
83
- commit: config.commit ?? stored.commit ?? ATTRIBUTION_DEFAULTS.commit,
84
- pr: config.pr ?? stored.pr ?? ATTRIBUTION_DEFAULTS.pr,
85
- sessionUrl: config.sessionUrl ?? stored.sessionUrl ?? ATTRIBUTION_DEFAULTS.sessionUrl,
98
+ commit: config.commit ?? stored.commit ?? defaults.commit,
99
+ pr: config.pr ?? stored.pr ?? defaults.pr,
100
+ sessionUrl: config.sessionUrl ?? stored.sessionUrl ?? defaults.sessionUrl,
86
101
  };
87
102
  }
88
103
  /** The stored choice with `patch` applied (null clears a field). */
@@ -108,7 +123,9 @@ export async function readStoredPlatformAttribution(db, log) {
108
123
  }
109
124
  /** The platform's effective defaults, read live: see {@link resolvePlatformAttribution}. */
110
125
  export async function readPlatformAttribution(db, config, log) {
111
- return resolvePlatformAttribution(config.get().attribution, await readStoredPlatformAttribution(db, log));
126
+ const stored = await readStoredPlatformAttribution(db, log);
127
+ const current = config.get();
128
+ return resolvePlatformAttribution(current.attribution, stored, productName(current));
112
129
  }
113
130
  /**
114
131
  * The link that ends an agent-created pull request when the deployment set `http.publicUrl` (a
@@ -46,7 +46,7 @@ export declare class BackgroundTaskPollJob {
46
46
  private readonly stopper;
47
47
  /** The marker that logs a left-alone legacy instance once across the replicas. */
48
48
  private readonly redis?;
49
- constructor(store: Pick<BackgroundTaskStore, "runningLegacy" | "runningManaged" | "owedCancels" | "pruneFinished" | "failAbandonedLaunches">, finisher: BackgroundTaskFinisher, eventLog: Pick<EventLog, "publishChanged">, sandbox: Pick<SandboxService, "cloudAvailable" | "availableFor" | "ifRunning">, config: KernelConfigService, lockService: LockService, log: KernelLogger, stopper: Pick<BackgroundTaskStopper, "stop">,
49
+ constructor(store: Pick<BackgroundTaskStore, "runningLegacy" | "runningManaged" | "owedCancels" | "pruneFinished" | "failAbandonedLaunches">, finisher: BackgroundTaskFinisher, eventLog: Pick<EventLog, "publishChanged">, sandbox: Pick<SandboxService, "availableFor" | "providerLoaded" | "ifRunning">, config: KernelConfigService, lockService: LockService, log: KernelLogger, stopper: Pick<BackgroundTaskStopper, "stop">,
50
50
  /** The marker that logs a left-alone legacy instance once across the replicas. */
51
51
  redis?: Pick<Redis, "set"> | undefined);
52
52
  poll(signal?: AbortSignal): Promise<void>;
@@ -106,10 +106,11 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
106
106
  if (signal.aborted)
107
107
  break;
108
108
  try {
109
- // the device's provider is not there (no cloud provider, `@local` not served):
110
- // its tasks stay as they are until it is
111
- const env = tasks[0]?.deviceId ?? null;
112
- if (env === null ? !this.sandbox.cloudAvailable : !(await this.sandbox.availableFor(env))) {
109
+ // the device's provider does not serve its org now (off in the org, not loaded, `@local`
110
+ // not registered): its tasks stay as they are until it does. A task without a device
111
+ // needs no provider: pollLegacy finishes it as gone.
112
+ const first = tasks[0];
113
+ if (first?.deviceId && !(await this.sandbox.availableFor(first.deviceId, first.orgId))) {
113
114
  continue;
114
115
  }
115
116
  finished += await this.pollLegacy(tasks, signal);
@@ -162,7 +163,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
162
163
  break;
163
164
  const [first] = tasks;
164
165
  try {
165
- if (!(await this.sandbox.availableFor(first.deviceId)))
166
+ if (!(await this.sandbox.availableFor(first.deviceId, first.orgId)))
166
167
  continue;
167
168
  n += await this.pollManagedInstance(tasks, signal);
168
169
  }
@@ -183,7 +184,8 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
183
184
  if (signal.aborted || attempts >= MANAGED_STOPS_PER_TICK)
184
185
  break;
185
186
  try {
186
- if (!(await this.sandbox.availableFor(t.deviceId)))
187
+ // revocation delivery needs the provider loaded only (not on in the org)
188
+ if (!(await this.sandbox.providerLoaded(t.deviceId)))
187
189
  continue;
188
190
  attempts++;
189
191
  const after = await this.stopper.stop(t, "revoked", signal);
@@ -205,7 +205,7 @@ let BackgroundTasks = class BackgroundTasks {
205
205
  reason: task.status === "running" ? "starting" : "not_started",
206
206
  };
207
207
  }
208
- if (!(await this.sandbox.availableFor(task.deviceId))) {
208
+ if (!(await this.sandbox.availableFor(task.deviceId, orgId))) {
209
209
  return { kind: "unavailable", reason: "unavailable" };
210
210
  }
211
211
  if (!(await this.deviceUsable(orgId, task.conversationId))) {
@@ -267,16 +267,19 @@ export interface CatalogTheme {
267
267
  /** Relative to the plugin root. */
268
268
  path: string;
269
269
  theme: ParsedTheme;
270
- /** The theme's fonts and logo files (paths relative to the plugin root), sanitized. */
270
+ /** The theme's fonts, logo and avatar files (paths relative to the plugin root), sanitized. */
271
271
  assets: SkillPackageFile[];
272
272
  /** {@link themeAssetsDigest} of the version's records of those files. */
273
273
  assetsDigest: string;
274
274
  }
275
- /** The asset paths a parsed theme references (fonts, logo mark and favicon), without `./`. */
275
+ /**
276
+ * The asset paths a parsed theme references ({@link themeAssetRefs}: fonts, logo files, avatar
277
+ * files), without `./`.
278
+ */
276
279
  export declare function themeAssetPaths(theme: ParsedTheme): string[];
277
280
  /**
278
281
  * The digest of a theme's assets as recorded on a catalog version (`files`): equal digests = the
279
- * same fonts and logo. With the canonical definition it decides whether a theme changed.
282
+ * same fonts, logo and avatar files. With the canonical definition it decides whether a theme changed.
280
283
  */
281
284
  export declare function themeAssetsDigest(files: {
282
285
  path: string;
@@ -3,7 +3,7 @@
3
3
  // OrgCatalogService: kept out of org-catalog.service.ts so the installer's module never imports a
4
4
  // module whose provider injects PluginInstaller (an ESM import cycle would run decorators early).
5
5
  import { createHash } from "node:crypto";
6
- import { parseAgentTemplate, parseConnectorTemplateFile, parseThemeFile, themeIdOf, validateThemeAssets, } from "@capybara-hq/plugin-sdk";
6
+ import { parseAgentTemplate, parseConnectorTemplateFile, parseThemeFile, themeAssetRefs, themeIdOf, validateThemeAssets, } from "@capybara-hq/plugin-sdk";
7
7
  import { ApiError } from "../errors.js";
8
8
  import { can } from "../orgs/roles.js";
9
9
  import { packagePath } from "../packages/tgz.js";
@@ -367,17 +367,16 @@ export async function readCatalogAgentTemplates(storage, v) {
367
367
  return { path, template: parsed.template };
368
368
  });
369
369
  }
370
- /** The asset paths a parsed theme references (fonts, logo mark and favicon), without `./`. */
370
+ /**
371
+ * The asset paths a parsed theme references ({@link themeAssetRefs}: fonts, logo files, avatar
372
+ * files), without `./`.
373
+ */
371
374
  export function themeAssetPaths(theme) {
372
- const refs = (theme.fonts ?? []).map((f) => f.file);
373
- for (const ref of [theme.logo?.mark, theme.logo?.favicon])
374
- if (ref !== undefined)
375
- refs.push(ref);
376
- return [...new Set(refs.map((r) => packagePath(r)))];
375
+ return [...new Set(themeAssetRefs(theme).map((r) => packagePath(r.ref)))];
377
376
  }
378
377
  /**
379
378
  * The digest of a theme's assets as recorded on a catalog version (`files`): equal digests = the
380
- * same fonts and logo. With the canonical definition it decides whether a theme changed.
379
+ * same fonts, logo and avatar files. With the canonical definition it decides whether a theme changed.
381
380
  */
382
381
  export function themeAssetsDigest(files, theme) {
383
382
  const paths = new Set(themeAssetPaths(theme));
@@ -809,7 +809,7 @@ export function translateClaudePlugin(files, o) {
809
809
  for (const h of harness)
810
810
  add(item("other_harness", "file", h, { path: h }));
811
811
  if (imported.length === 0 && mcp.files.size === 0 && agents.agents.length === 0) {
812
- invalidManifest("the Claude Code plugin has no skill Capybara can import, no agent and no remote MCP server (see the translation report)");
812
+ invalidManifest("the Claude Code plugin has no skill this platform can import, no agent and no remote MCP server (see the translation report)");
813
813
  }
814
814
  // The synthesized manifest lists every skill and template, so the reader never scans.
815
815
  const templatePaths = [];
@@ -203,7 +203,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
203
203
  /** The host versions (an entry's `minKernel` is judged against them). */
204
204
  export declare const HOST_VERSIONS: {
205
205
  readonly kernel: string;
206
- readonly sdk: "0.1.0-rc.49";
206
+ readonly sdk: "0.1.0-rc.51";
207
207
  };
208
208
  /** Whether this deployment satisfies the entry's `minKernel`. */
209
209
  export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
@@ -35,7 +35,8 @@ import { withoutRemovedManifestFields } from "./plugin-package.js";
35
35
  import { compareVersions, newestFirst, sameRelease } from "./versions.js";
36
36
  /** 官方清单来源的 id。 */
37
37
  export const OFFICIAL_MARKETPLACE_ID = "official";
38
- const OFFICIAL_MARKETPLACE_NAME = "Capybara official marketplace";
38
+ /** Neutral: the official marketplace lists the upstream project's plugins under any platform name. */
39
+ const OFFICIAL_MARKETPLACE_NAME = "Official marketplace";
39
40
  /** 企业清单的可选令牌:secrets 的 namespace `kernel`、org `_deployment`、键 `catalog-token:<id>`(preflight #65)。 */
40
41
  const SECRETS_NAMESPACE = "kernel";
41
42
  const tokenKey = (id) => `catalog-token:${id}`;
@@ -59,8 +59,9 @@ export interface PluginPackageTheme {
59
59
  path: string;
60
60
  theme: ParsedTheme;
61
61
  /**
62
- * The theme's fonts and logo files after `validateThemeAssets` (the SVGs sanitized, the rest
63
- * unchanged), keyed by their path relative to the package root (no leading `./`).
62
+ * The theme's fonts, logo files (mark, favicon, illustration, app icons) and avatar files after
63
+ * `validateThemeAssets` (the SVGs sanitized, the rest unchanged), keyed by their path relative
64
+ * to the package root (no leading `./`).
64
65
  */
65
66
  assets: Map<string, Uint8Array>;
66
67
  }
@@ -43,6 +43,8 @@ export declare function fileLinkText(input: {
43
43
  conversationId: string;
44
44
  base: string | undefined;
45
45
  locale: ChannelLocale;
46
+ /** The platform name (`platform.name`) the line without a link names. */
47
+ product: string;
46
48
  }): string;
47
49
  /** The root message text of a native file delivery. */
48
50
  export declare function fileRootText(name: string, locale: ChannelLocale): string;
@@ -77,7 +77,7 @@ export function fileLinkText(input) {
77
77
  const name = asCode(input.name);
78
78
  const size = formatFileSize(input.size);
79
79
  if (input.base === undefined) {
80
- return fill(phrase("fileOnWebNoLink", input.locale), { name, size, url: "" });
80
+ return fill(phrase("fileOnWebNoLink", input.locale, input.product), { name, size, url: "" });
81
81
  }
82
82
  const url = `${conversationUrl(input.base, input.conversationId)}#file=${input.artifactId}`;
83
83
  return fill(phrase("fileOnWeb", input.locale), { name, size, url });
@@ -4,6 +4,7 @@ import { ConversationsService } from "../conversations/conversations.service.js"
4
4
  import { DevicesService } from "../devices/devices.service.js";
5
5
  import { IdentityBinding } from "../identity/binding.js";
6
6
  import { ExternalIdentities } from "../identity/external.js";
7
+ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
7
8
  import { KernelDb } from "../infra/database/kernel-db.js";
8
9
  import { LockService } from "../infra/lock/lock.service.js";
9
10
  import { DirectorySync } from "../orgs/directory-sync.js";
@@ -39,6 +40,8 @@ export declare class ChannelInbound {
39
40
  private readonly jobs;
40
41
  private readonly guests;
41
42
  private readonly devices;
43
+ /** `platform.name`, which the bind phrases name (read at each reply: the field is hot). */
44
+ private readonly config;
42
45
  private readonly log;
43
46
  private readonly actions;
44
47
  constructor(kdb: KernelDb, redis: Pick<Redis, "set">,
@@ -49,7 +52,9 @@ export declare class ChannelInbound {
49
52
  /** The channel queue: inbound jobs (`onEvent` only dedupes and enqueues) and deliveries. */
50
53
  jobs: Pick<ChannelJobs, "enqueue" | "enqueueInbound" | "bind">,
51
54
  /** 卡片操作:审批决定与提问回答(授权由这两个服务按点击者映射到的账号判定)。 */
52
- approvals: Pick<ApprovalsService, "decide">, questions: Pick<QuestionsService, "answer">, guests: Pick<AnonymousGuests, "ensure">, devices: Pick<DevicesService, "list" | "imDefault" | "setImDefault">, log: Pick<Logger, "warn" | "info">);
55
+ approvals: Pick<ApprovalsService, "decide">, questions: Pick<QuestionsService, "answer">, guests: Pick<AnonymousGuests, "ensure">, devices: Pick<DevicesService, "list" | "imDefault" | "setImDefault">,
56
+ /** `platform.name`, which the bind phrases name (read at each reply: the field is hot). */
57
+ config: Pick<KernelConfigService, "get">, log: Pick<Logger, "warn" | "info">);
53
58
  /**
54
59
  * 插件 `onEvent`:去重并入队后返回(见类注释)。返回后插件才向平台确认;抛错时插件不确认。
55
60
  */
@@ -72,9 +77,8 @@ export declare class ChannelInbound {
72
77
  /**
73
78
  * Direct-message `/device` (environments spec §4.2 item 8): lists the person's usable devices,
74
79
  * or with a name sets the IM default their next new conversation is bound to. The name matches
75
- * case-insensitively against each label (`deviceLabel`: a former default demoted by a
76
- * provider switch answers to e.g. "Personal (Docker sandbox)"); the default device also
77
- * answers to 个人设备 / Personal.
80
+ * case-insensitively against each label (`deviceLabel`); the default device also answers to
81
+ * its zh or en "Personal" label (`PERSONAL` in devices/label.ts).
78
82
  */
79
83
  private deviceCommand;
80
84
  /**
@@ -9,6 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { randomUUID } from "node:crypto";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
+ import { productName } from "../config/product-name.js";
12
13
  import { ConversationsService } from "../conversations/conversations.service.js";
13
14
  import { imSenderContext, recipientLocale, } from "../conversations/message-context.js";
14
15
  import { channelSource } from "../conversations/source.js";
@@ -17,6 +18,7 @@ import { DEFAULT_DEVICE_ALIASES, deviceLabel } from "../devices/label.js";
17
18
  import { ApiError } from "../errors.js";
18
19
  import { IdentityBinding } from "../identity/binding.js";
19
20
  import { ExternalIdentities } from "../identity/external.js";
21
+ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
20
22
  import { KernelDb } from "../infra/database/kernel-db.js";
21
23
  import { LockService } from "../infra/lock/lock.service.js";
22
24
  import { KERNEL_LOGGER, REDIS } from "../infra/tokens.js";
@@ -99,6 +101,7 @@ let ChannelInbound = class ChannelInbound {
99
101
  jobs;
100
102
  guests;
101
103
  devices;
104
+ config;
102
105
  log;
103
106
  actions;
104
107
  constructor(kdb, redis,
@@ -109,7 +112,9 @@ let ChannelInbound = class ChannelInbound {
109
112
  /** The channel queue: inbound jobs (`onEvent` only dedupes and enqueues) and deliveries. */
110
113
  jobs,
111
114
  /** 卡片操作:审批决定与提问回答(授权由这两个服务按点击者映射到的账号判定)。 */
112
- approvals, questions, guests, devices, log) {
115
+ approvals, questions, guests, devices,
116
+ /** `platform.name`, which the bind phrases name (read at each reply: the field is hot). */
117
+ config, log) {
113
118
  this.kdb = kdb;
114
119
  this.redis = redis;
115
120
  this.locks = locks;
@@ -121,6 +126,7 @@ let ChannelInbound = class ChannelInbound {
121
126
  this.jobs = jobs;
122
127
  this.guests = guests;
123
128
  this.devices = devices;
129
+ this.config = config;
124
130
  this.log = log;
125
131
  this.actions = new ChannelCardActions({
126
132
  get db() {
@@ -219,7 +225,7 @@ let ChannelInbound = class ChannelInbound {
219
225
  const replyText = async (text, cards) => {
220
226
  await connections.send(connectionId, replyTarget, { text, ...(cards !== undefined && { cards }) }, replyKey, locale);
221
227
  };
222
- const reply = (key, cards) => replyText(phrase(key, locale), cards);
228
+ const reply = (key, cards) => replyText(phrase(key, locale, productName(this.config.get())), cards);
223
229
  const speaker = await this.resolveSpeaker(connectionId, row, e.sender, isGroup, locale, reply);
224
230
  if (speaker === undefined)
225
231
  return;
@@ -310,9 +316,8 @@ let ChannelInbound = class ChannelInbound {
310
316
  /**
311
317
  * Direct-message `/device` (environments spec §4.2 item 8): lists the person's usable devices,
312
318
  * or with a name sets the IM default their next new conversation is bound to. The name matches
313
- * case-insensitively against each label (`deviceLabel`: a former default demoted by a
314
- * provider switch answers to e.g. "Personal (Docker sandbox)"); the default device also
315
- * answers to 个人设备 / Personal.
319
+ * case-insensitively against each label (`deviceLabel`); the default device also answers to
320
+ * its zh or en "Personal" label (`PERSONAL` in devices/label.ts).
316
321
  */
317
322
  async deviceCommand(orgId, accountId, name, locale, replyText) {
318
323
  const { items, defaultId } = await this.devices.list(orgId, accountId);
@@ -436,7 +441,8 @@ let ChannelInbound = class ChannelInbound {
436
441
  await reply("bindUnavailable");
437
442
  return undefined;
438
443
  }
439
- await reply("bindPrompt", [{ kind: "bind", url, text: phrase("bindPrompt", locale) }]);
444
+ const bindText = phrase("bindPrompt", locale, productName(this.config.get()));
445
+ await reply("bindPrompt", [{ kind: "bind", url, text: bindText }]);
440
446
  return undefined;
441
447
  }
442
448
  /** 账号是该组织成员且账号未停用。 */
@@ -479,7 +485,8 @@ ChannelInbound = __decorate([
479
485
  __param(10, Inject(QuestionsService)),
480
486
  __param(11, Inject(AnonymousGuests)),
481
487
  __param(12, Inject(DevicesService)),
482
- __param(13, Inject(KERNEL_LOGGER))
488
+ __param(13, Inject(KernelConfigService)),
489
+ __param(14, Inject(KERNEL_LOGGER))
483
490
  ], ChannelInbound);
484
491
  export { ChannelInbound };
485
492
  /** `/device` or `/device <name>` (the exact command word, case-insensitive); anything else is null. */
@@ -12,6 +12,7 @@ import { isChannelSendError, } from "@capybara-hq/plugin-sdk";
12
12
  import { Inject, Injectable } from "@nestjs/common";
13
13
  import { DelayedError, UnrecoverableError } from "bullmq";
14
14
  import { sql } from "kysely";
15
+ import { productName } from "../config/product-name.js";
15
16
  import { conversationTopic, EventLog, } from "../conversations/event-log.js";
16
17
  import { recipientLocale } from "../conversations/message-context.js";
17
18
  import { ApiError } from "../errors.js";
@@ -574,6 +575,10 @@ class Delivery {
574
575
  return this.session;
575
576
  }
576
577
  /** 普通消息的幂等键(Ruling A15):`<会话>-<seq>[后缀]` 的稳定哈希。 */
578
+ /** The platform name the web hints name (`platform.name`, read at each use: the field is hot). */
579
+ product() {
580
+ return productName(this.d.config.get());
581
+ }
577
582
  key(seq, suffix = "") {
578
583
  return idempotencyKey(`${this.conversationId}-${seq}${suffix}`);
579
584
  }
@@ -697,7 +702,7 @@ class Delivery {
697
702
  this.d.log.warn("cannot close channel draft before skipping", { err: errMsg(err) });
698
703
  }
699
704
  try {
700
- await this.send({ text: phrase("handleOnWeb", this.locale) }, this.key(seq, "-skipped"));
705
+ await this.send({ text: phrase("handleOnWeb", this.locale, this.product()) }, this.key(seq, "-skipped"));
701
706
  }
702
707
  catch (err) {
703
708
  this.d.log.warn("cannot send channel skip notice", { err: errMsg(err) });
@@ -954,7 +959,7 @@ class Delivery {
954
959
  case "connection_required": {
955
960
  const text = phrase("connectTitle", this.locale);
956
961
  await this.send(this.base === undefined
957
- ? { text: phrase("handleOnWeb", this.locale) }
962
+ ? { text: phrase("handleOnWeb", this.locale, this.product()) }
958
963
  : cardMessage(text, {
959
964
  kind: "connect",
960
965
  appName: e.payload.appName,
@@ -969,7 +974,7 @@ class Delivery {
969
974
  if (v?.kind !== "handoff")
970
975
  return;
971
976
  await this.send(this.base === undefined
972
- ? { text: phrase("handleOnWeb", this.locale) }
977
+ ? { text: phrase("handleOnWeb", this.locale, this.product()) }
973
978
  : cardMessage(v.title[this.locale], {
974
979
  kind: "bind",
975
980
  text: v.title[this.locale],
@@ -1023,7 +1028,7 @@ class Delivery {
1023
1028
  /** Sends the approval card of `approvalId` for the event at `seq` (or the web hint). */
1024
1029
  async approvalCardAt(seq, approvalId) {
1025
1030
  if (this.base === undefined) {
1026
- await this.send({ text: phrase("handleOnWeb", this.locale) }, this.key(seq));
1031
+ await this.send({ text: phrase("handleOnWeb", this.locale, this.product()) }, this.key(seq));
1027
1032
  return this.advance(seq);
1028
1033
  }
1029
1034
  // secrets are typed on the web only (a secure input request, or a tool ask with person
@@ -1173,6 +1178,7 @@ class Delivery {
1173
1178
  conversationId: this.conversationId,
1174
1179
  base: this.base,
1175
1180
  locale: this.locale,
1181
+ product: this.product(),
1176
1182
  });
1177
1183
  await this.send({ text }, this.key(seq, "-link"));
1178
1184
  return this.advance(seq);
@@ -1184,7 +1190,7 @@ class Delivery {
1184
1190
  */
1185
1191
  async questionCardAt(seq, questionId, form, child) {
1186
1192
  if (this.base === undefined) {
1187
- await this.send({ text: phrase("handleOnWeb", this.locale) }, this.key(seq));
1193
+ await this.send({ text: phrase("handleOnWeb", this.locale, this.product()) }, this.key(seq));
1188
1194
  return this.advance(seq);
1189
1195
  }
1190
1196
  // the person can skip the conversation's own question by replying; a sub-agent's question
@@ -4,6 +4,7 @@ export type ChannelLocale = "zh" | "en";
4
4
  * 机器人在 IM 里说的固定话术(全部集中在这里,zh / en 同步). Chosen per recipient (run context spec
5
5
  * §3.4): the sender's platform language, else their latest web language, else the org's.
6
6
  * 模型回复不经过这里,原样转换为 IM 富文本、不翻译。
7
+ * `{product}` is the platform name (`platform.name`): {@link phrase} requires it for those phrases.
7
8
  */
8
9
  export declare const CHANNEL_PHRASES: {
9
10
  /** 私聊 `/new` 之后。 */
@@ -28,10 +29,10 @@ export declare const CHANNEL_PHRASES: {
28
29
  };
29
30
  /** `/device <name>` names an existing device that is unavailable now (`{list}` as in deviceList). */
30
31
  readonly deviceUnavailable: {
31
- readonly zh: "设备「{name}」当前不可用(它的文件由未启用的沙箱提供方保存)。你的设备:\n{list}";
32
- readonly en: "The device “{name}” is unavailable: its files are kept by a sandbox provider that is not active. Your devices:\n{list}";
32
+ readonly zh: "设备「{name}」当前不可用(它的设备提供方在该组织未启用或未安装,文件仍保留)。你的设备:\n{list}";
33
+ readonly en: "The device “{name}” is unavailable: its device provider is off in this organization or not installed (its files are kept). Your devices:\n{list}";
33
34
  };
34
- /** Direct message `/device` when the person has no usable device (no cloud sandbox in the deployment). */
35
+ /** Direct message `/device` when the person has no usable device (no device provider on in the org). */
35
36
  readonly deviceNone: {
36
37
  readonly zh: "你目前没有可用的设备。";
37
38
  readonly en: "You have no usable devices.";
@@ -43,13 +44,13 @@ export declare const CHANNEL_PHRASES: {
43
44
  };
44
45
  /** 未绑定的人在私聊里发消息:附绑定卡片。 */
45
46
  readonly bindPrompt: {
46
- readonly zh: "请先绑定你的 Capybara 账号,再与我对话。";
47
- readonly en: "Please link your Capybara account before chatting with me.";
47
+ readonly zh: "请先绑定你的 {product} 账号,再与我对话。";
48
+ readonly en: "Please link your {product} account before chatting with me.";
48
49
  };
49
50
  /** 未绑定的人在群里 @ 机器人:绑定链接只在私聊里发(群里谁都能点)。 */
50
51
  readonly bindInDm: {
51
- readonly zh: "请先私聊我,绑定你的 Capybara 账号。";
52
- readonly en: "Please send me a direct message to link your Capybara account first.";
52
+ readonly zh: "请先私聊我,绑定你的 {product} 账号。";
53
+ readonly en: "Please send me a direct message to link your {product} account first.";
53
54
  };
54
55
  /** 无法生成绑定链接(部署未配置 http.publicUrl)。 */
55
56
  readonly bindUnavailable: {
@@ -224,8 +225,8 @@ export declare const CHANNEL_PHRASES: {
224
225
  };
225
226
  /** 部署未配置 http.publicUrl,无法给出网页链接与卡片时的退回文本。 */
226
227
  readonly handleOnWeb: {
227
- readonly zh: "有一条请求需要你到 Capybara 网页上处理。";
228
- readonly en: "A request is waiting for you in Capybara on the web.";
228
+ readonly zh: "有一条请求需要你到 {product} 网页上处理。";
229
+ readonly en: "A request is waiting for you in {product} on the web.";
229
230
  };
230
231
  /**
231
232
  * Phase D: `/name args` named an invocable skill, but the kernel refused to render it
@@ -275,8 +276,8 @@ export declare const CHANNEL_PHRASES: {
275
276
  };
276
277
  /** The same without a web link (no public base URL configured). */
277
278
  readonly fileOnWebNoLink: {
278
- readonly zh: "{name}({size})已交付,请在网页上打开 Capybara 中的这个会话获取。";
279
- readonly en: "{name} ({size}) was delivered; open the conversation in Capybara on the web to get it.";
279
+ readonly zh: "{name}({size})已交付,请在网页上打开 {product} 中的这个会话获取。";
280
+ readonly en: "{name} ({size}) was delivered; open the conversation in {product} on the web to get it.";
280
281
  };
281
282
  /**
282
283
  * The root message of a native file delivery (a scheduled group run's first post); `{name}` is
@@ -299,5 +300,12 @@ export declare const CHANNEL_PHRASES: {
299
300
  };
300
301
  };
301
302
  export type ChannelPhrase = keyof typeof CHANNEL_PHRASES;
302
- /** 取一条话术。 */
303
- export declare function phrase(key: ChannelPhrase, locale: ChannelLocale): string;
303
+ /** The phrases that name the platform (`{product}`): {@link phrase} takes the name for them. */
304
+ export type ProductPhrase = {
305
+ [K in ChannelPhrase]: (typeof CHANNEL_PHRASES)[K]["en"] extends `${string}{product}${string}` ? K : never;
306
+ }[ChannelPhrase];
307
+ /**
308
+ * One phrase in `locale`. A phrase that names the platform takes its name (`productName(config)`,
309
+ * read at each use: `platform.name` is hot), which replaces `{product}`.
310
+ */
311
+ export declare function phrase<K extends ChannelPhrase>(key: K, locale: ChannelLocale, ...product: K extends ProductPhrase ? [product: string] : []): string;