@capybara-hq/kernel 0.1.0-rc.115 → 0.1.0-rc.116

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 (51) hide show
  1. package/bootstrap.json +3 -3
  2. package/dist/agents/agents.controller.d.ts +13 -1
  3. package/dist/agents/agents.controller.js +24 -2
  4. package/dist/catalog/catalog.service.d.ts +11 -1
  5. package/dist/catalog/catalog.service.js +36 -2
  6. package/dist/catalog/marketplaces.service.d.ts +1 -1
  7. package/dist/catalog/platform-components.js +13 -0
  8. package/dist/catalog/plugin-connectors.d.ts +35 -0
  9. package/dist/catalog/plugin-connectors.js +81 -0
  10. package/dist/channels/supervisor.d.ts +5 -1
  11. package/dist/channels/supervisor.js +17 -1
  12. package/dist/conversations/conversations.controller.d.ts +46 -14
  13. package/dist/conversations/conversations.controller.js +82 -47
  14. package/dist/conversations/conversations.service.d.ts +93 -59
  15. package/dist/conversations/conversations.service.js +255 -72
  16. package/dist/conversations/events.d.ts +31 -0
  17. package/dist/conversations/events.js +41 -2
  18. package/dist/conversations/inline-tokens.d.ts +87 -0
  19. package/dist/conversations/inline-tokens.js +154 -0
  20. package/dist/conversations/permission-profiles.controller.d.ts +14 -7
  21. package/dist/conversations/permission-profiles.controller.js +1 -5
  22. package/dist/conversations/prompt-suggestions.js +2 -4
  23. package/dist/conversations/queue.d.ts +0 -2
  24. package/dist/conversations/queue.service.js +9 -13
  25. package/dist/db/kernel-schema.d.ts +2 -0
  26. package/dist/errors.d.ts +12 -0
  27. package/dist/errors.js +12 -0
  28. package/dist/evals/snapshot.js +4 -2
  29. package/dist/files/library-files.service.d.ts +13 -0
  30. package/dist/files/library-files.service.js +33 -6
  31. package/dist/net/safe-fetch.js +1 -1
  32. package/dist/platform/exclusions.js +6 -1
  33. package/dist/runtime/context/build.d.ts +7 -2
  34. package/dist/runtime/context/build.js +17 -6
  35. package/dist/runtime/context/compaction.d.ts +3 -3
  36. package/dist/runtime/context/compaction.js +12 -13
  37. package/dist/sandbox/review/classifier.js +5 -1
  38. package/dist/tools/connector-content.controller.d.ts +6 -2
  39. package/dist/tools/connector-content.controller.js +13 -3
  40. package/dist/tools/connector-content.d.ts +55 -15
  41. package/dist/tools/connector-content.js +112 -54
  42. package/dist/tools/connectors.service.d.ts +3 -2
  43. package/dist/tools/connectors.service.js +6 -20
  44. package/dist/tools/mentionable-connectors.d.ts +88 -0
  45. package/dist/tools/mentionable-connectors.js +218 -0
  46. package/dist/tools/pipeline.js +43 -6
  47. package/dist/tools/specs.d.ts +13 -4
  48. package/dist/tools/specs.js +22 -8
  49. package/dist/tools/tools.module.js +7 -0
  50. package/package.json +3 -3
  51. package/src/migrations/0201_tool_specs_text.sql +8 -0
@@ -0,0 +1,218 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Inject, Injectable } from "@nestjs/common";
11
+ import { AgentLookup } from "../agents/agent-lookup.js";
12
+ import { ApiError } from "../errors.js";
13
+ import { orgIconScope, PluginIcons } from "../extensions/plugin-icons.js";
14
+ import { KernelDb } from "../infra/database/kernel-db.js";
15
+ import { connectorSetups } from "./connector-setup.js";
16
+ import { Credentials } from "./credentials.js";
17
+ import { ToolRegistry } from "./registry.js";
18
+ import { READ_RESOURCE } from "./resources.js";
19
+ /** The tools of `tools` that come from connector `connectorId` (in their order). */
20
+ export function connectorToolsFor(tools, connectorId) {
21
+ return tools.filter((t) => t.source.kind === "connector" && t.source.connectorId === connectorId);
22
+ }
23
+ /**
24
+ * The connectors an agent can be told to use from the web input box: the org's live, active
25
+ * connectors of which the agent is offered at least one tool (`ToolRegistry.forAgent`, source
26
+ * `web`), plus the `needs_config` ones the agent does not switch off as a whole (shown disabled).
27
+ * Reads only the database and the credential store's key presence: no connector session is opened.
28
+ */
29
+ let MentionableConnectorsService = class MentionableConnectorsService {
30
+ db;
31
+ agents;
32
+ registry;
33
+ credentials;
34
+ icons;
35
+ constructor(db, agents, registry, credentials, icons) {
36
+ this.db = db;
37
+ this.agents = agents;
38
+ this.registry = registry;
39
+ this.credentials = credentials;
40
+ this.icons = icons;
41
+ }
42
+ /**
43
+ * The rows for `agentId` as `accountId` sees them in `org` (the org guard's context: its role
44
+ * decides which icons the reader may see); an agent the account may not see (or another org's)
45
+ * -> `agent.not_found`.
46
+ */
47
+ async list(org, accountId, agentId) {
48
+ const { orgId } = org;
49
+ const agent = await this.agents.get(orgId, agentId, accountId);
50
+ const disabled = agent.definition.disabledTools ?? [];
51
+ // no conversation yet: the listing names no sandbox conversation, which only decides the
52
+ // device-bound builtins, never a connector's tools
53
+ const { tools } = await this.registry.forAgent(orgId, {
54
+ disabledTools: disabled,
55
+ source: "web",
56
+ });
57
+ const rows = await this.db
58
+ .selectFrom("connectors")
59
+ .select([
60
+ "id",
61
+ "slug",
62
+ "name",
63
+ "description",
64
+ "connector",
65
+ "auth",
66
+ "platform_template_id",
67
+ "catalog_item_id",
68
+ ])
69
+ .where("org_id", "=", orgId)
70
+ .where("deleted_at", "is", null)
71
+ .where("status", "=", "active")
72
+ .orderBy("slug")
73
+ .orderBy("id")
74
+ .execute();
75
+ if (rows.length === 0)
76
+ return { connectors: [] };
77
+ const setups = await connectorSetups(this.credentials, orgId, rows.map((r) => ({ id: r.id, auth: r.auth })));
78
+ const shown = rows.flatMap((r) => {
79
+ const state = setups.get(r.id) ?? "needs_config";
80
+ const offered = connectorToolsFor(tools, r.id);
81
+ if (state === "ready" && offered.length === 0)
82
+ return [];
83
+ // a needs_config one is shown unless the agent switches it off as a whole or its connector
84
+ // extension is not loaded (forAgent would not offer it once configured either)
85
+ if (state === "needs_config" &&
86
+ (disabled.some((d) => d.kind === "connector" && d.connectorId === r.id && d.tools === "all") ||
87
+ !this.registry.findConnector(r.connector))) {
88
+ return [];
89
+ }
90
+ return [{ row: r, state, offered }];
91
+ });
92
+ if (shown.length === 0)
93
+ return { connectors: [] };
94
+ const scope = orgIconScope(org);
95
+ const templateIds = shown.flatMap((s) => s.row.platform_template_id ? [s.row.platform_template_id] : []);
96
+ const [urls, descriptions, credentials] = await Promise.all([
97
+ this.icons.ofConnectors(shown.map((s) => ({
98
+ id: s.row.id,
99
+ templateId: s.row.platform_template_id ?? null,
100
+ itemId: s.row.catalog_item_id ?? null,
101
+ })), scope),
102
+ this.icons.templateDescriptions(templateIds, scope),
103
+ Promise.all(shown.map(async ({ row }) => {
104
+ const auth = row.auth;
105
+ if (auth.type === "none" || auth.ownership !== "personal")
106
+ return "none";
107
+ return this.credentials.status(orgId, row.id, auth, accountId);
108
+ })),
109
+ ]);
110
+ return {
111
+ connectors: shown.map(({ row, state, offered }, i) => {
112
+ // its own description first, else its platform template's (as the connector pages)
113
+ const template = row.platform_template_id
114
+ ? descriptions.get(row.platform_template_id)
115
+ : undefined;
116
+ const own = row.description?.trim() ? row.description : null;
117
+ const description = own ?? template?.description ?? null;
118
+ const descriptionZh = own === null ? (template?.descriptionZh ?? null) : null;
119
+ const ready = state === "ready";
120
+ return {
121
+ id: row.id,
122
+ slug: row.slug,
123
+ name: row.name,
124
+ ...(description !== null && { description }),
125
+ ...(descriptionZh !== null && { descriptionZh }),
126
+ icon: urls[i] ?? null,
127
+ state,
128
+ credential: credentials[i] ?? "none",
129
+ toolCount: ready ? offered.length : 0,
130
+ resources: ready &&
131
+ offered.some((t) => t.source.kind === "connector" &&
132
+ t.source.resources === true &&
133
+ t.source.name === READ_RESOURCE),
134
+ };
135
+ }),
136
+ };
137
+ }
138
+ /**
139
+ * The agent's tools for a message that names connectors or their resources (composer inline
140
+ * tokens spec §3.4), resolved once as the conversation's next step would resolve them
141
+ * (`ToolRegistry.forAgent` with the definition's disabled tools and roster, the conversation's
142
+ * source and its sandbox conversation), and each of `mentioned` with its offered tools. A
143
+ * connector of which the agent is offered no tool refuses the message: 422
144
+ * `conversation.connector_unavailable`, `details: [{ connectorId, reason }]`, every refused
145
+ * connector in `mentioned` order: `not_found` (deleted, disabled, another org's), `needs_config`
146
+ * (an org admin must configure it, and nothing else keeps it from the agent), `not_offered` (the
147
+ * agent switches it off, none of its tools is enabled, or its connector extension is not
148
+ * loaded). A personal credential the sender has not connected is no refusal: the tool call
149
+ * answers with the connection card. Opens no connector session.
150
+ */
151
+ async resolveForMessage(orgId, agent, where, mentioned) {
152
+ const disabled = agent.disabledTools ?? [];
153
+ const resolved = await this.registry.forAgent(orgId, {
154
+ disabledTools: disabled,
155
+ subagents: agent.subagents,
156
+ ...(where.sandboxConversationId !== undefined && {
157
+ sandboxConversationId: where.sandboxConversationId,
158
+ }),
159
+ source: where.source,
160
+ });
161
+ const tools = resolved.tools;
162
+ const toolSearch = resolved.toolSearch === true;
163
+ if (mentioned.length === 0)
164
+ return { tools, toolSearch, connectors: [] };
165
+ const rows = await this.db
166
+ .selectFrom("connectors")
167
+ .select(["id", "slug", "name", "connector", "auth"])
168
+ .where("org_id", "=", orgId)
169
+ .where("id", "in", [...mentioned])
170
+ .where("deleted_at", "is", null)
171
+ .where("status", "=", "active")
172
+ .execute();
173
+ const byId = new Map(rows.map((r) => [r.id, r]));
174
+ const connectors = [];
175
+ const unoffered = [];
176
+ const refused = new Map();
177
+ for (const id of mentioned) {
178
+ const row = byId.get(id);
179
+ if (!row) {
180
+ refused.set(id, "not_found");
181
+ continue;
182
+ }
183
+ const offered = connectorToolsFor(tools, id);
184
+ if (offered.length > 0) {
185
+ connectors.push({ id, slug: row.slug, name: row.name, tools: offered });
186
+ }
187
+ else {
188
+ unoffered.push(row);
189
+ }
190
+ }
191
+ if (unoffered.length > 0) {
192
+ const setups = await connectorSetups(this.credentials, orgId, unoffered.map((r) => ({ id: r.id, auth: r.auth })));
193
+ for (const r of unoffered) {
194
+ const switchedOff = disabled.some((d) => d.kind === "connector" && d.connectorId === r.id && d.tools === "all");
195
+ refused.set(r.id, setups.get(r.id) !== "ready" && !switchedOff && this.registry.findConnector(r.connector)
196
+ ? "needs_config"
197
+ : "not_offered");
198
+ }
199
+ }
200
+ if (refused.size > 0) {
201
+ const details = mentioned.flatMap((connectorId) => {
202
+ const reason = refused.get(connectorId);
203
+ return reason === undefined ? [] : [{ connectorId, reason }];
204
+ });
205
+ throw new ApiError("conversation.connector_unavailable", "A connector this message names cannot be used by this agent now; remove it and send again", details);
206
+ }
207
+ return { tools, toolSearch, connectors };
208
+ }
209
+ };
210
+ MentionableConnectorsService = __decorate([
211
+ Injectable(),
212
+ __param(0, Inject(KernelDb)),
213
+ __param(1, Inject(AgentLookup)),
214
+ __param(2, Inject(ToolRegistry)),
215
+ __param(3, Inject(Credentials)),
216
+ __param(4, Inject(PluginIcons))
217
+ ], MentionableConnectorsService);
218
+ export { MentionableConnectorsService };
@@ -1598,9 +1598,10 @@ let ToolPipeline = class ToolPipeline {
1598
1598
  let loopbackNotes = [];
1599
1599
  if (scoped?.loopback !== undefined) {
1600
1600
  const lb = scoped.loopback;
1601
- const handled = await this.loopbackBlocked(ctx, call, tool, input, outKey, { deviceId: scoped.deviceId, loopback: lb, url: scoped.url }, attempt, keptResult, rerun.loopbackRerun === true, pre, callAudit);
1601
+ const otherHosts = scoped.hosts.filter((h) => serviceHostKey(h.host) !== serviceHostKey(lb.host));
1602
+ const handled = await this.loopbackBlocked(ctx, call, tool, input, outKey, { deviceId: scoped.deviceId, loopback: lb, url: scoped.url, otherHosts }, attempt, keptResult, rerun.loopbackRerun === true, pre, callAudit);
1602
1603
  if (handled.kind !== "none") {
1603
- serviceHosts = scoped.hosts.filter((h) => serviceHostKey(h.host) !== serviceHostKey(lb.host));
1604
+ serviceHosts = otherHosts;
1604
1605
  if (handled.kind === "wait") {
1605
1606
  if (hooks && hookBase) {
1606
1607
  fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content: handled.content, durationMs }, ctx.signal, this.deps.log);
@@ -2453,7 +2454,12 @@ let ToolPipeline = class ToolPipeline {
2453
2454
  * A device service's refusals (browser use spec §7.1): the extension whose service asked and
2454
2455
  * the call's attempt. Only "always" is offered; once approved the call runs again.
2455
2456
  */
2456
- service) {
2457
+ service,
2458
+ /**
2459
+ * Plan-only pass: compute the `network_blocked` event and every refused host's note without
2460
+ * opening a second network ask (used when a loopback ask already takes this call's ask slot).
2461
+ */
2462
+ planOnly) {
2457
2463
  const hosts = blockedEventHosts(report.blocked);
2458
2464
  if (hosts.length === 0)
2459
2465
  return { kind: "write", event: null, notes: [] };
@@ -2500,6 +2506,16 @@ let ToolPipeline = class ToolPipeline {
2500
2506
  const addressNote = plan.addressNote;
2501
2507
  if (plan.ask.length === 0 || offer === undefined)
2502
2508
  return { kind: "write", event, notes: plan.notes, addressNote };
2509
+ // plan-only pass (loopback ask takes this call's ask slot): keep every other refused host's
2510
+ // note without opening a second ask
2511
+ if (planOnly === true) {
2512
+ return {
2513
+ kind: "write",
2514
+ event,
2515
+ notes: [...plan.notes, serviceAskedNote(plan.ask.map((h) => h.host))],
2516
+ addressNote,
2517
+ };
2518
+ }
2503
2519
  // one ask per call: a service call that ran again after its ask is not asked again; only a
2504
2520
  // would-be ask is replaced, the plan's other notes (a host on the list, not yet applied) stay
2505
2521
  if (service !== undefined &&
@@ -2755,8 +2771,29 @@ let ToolPipeline = class ToolPipeline {
2755
2771
  return { kind: "write", notes: [otherAskPendingNote([hp])] };
2756
2772
  if ((run?.asks ?? 0) >= MAX_NETWORK_ASKS_PER_RUN)
2757
2773
  return { kind: "write", notes: [tooManyNote([hp])] };
2758
- const { content, outputId } = await this.keptContent(ctx, call.id, kept);
2759
- const { text: _text, denialHint: _hint, ...rest } = kept;
2774
+ // plan-only pass for other refused hosts reported alongside the loopback port, so their notes
2775
+ // and `network_blocked` event are kept when the loopback ask settles
2776
+ let otherEvent = null;
2777
+ let otherNotes = [];
2778
+ if (report.otherHosts.length > 0) {
2779
+ const other = await this.networkBlocked(ctx, call.id, toolKey, input, {
2780
+ deviceId: report.deviceId,
2781
+ blocked: report.otherHosts.map(({ host, layer }) => ({ host, port: 443, layer })),
2782
+ }, pre, callAudit, kept, undefined, undefined, {
2783
+ name: tool.source.kind === "plugin" ? tool.source.plugin : tool.key,
2784
+ attempt,
2785
+ url: report.url,
2786
+ }, true);
2787
+ if (other.kind === "write") {
2788
+ otherEvent = other.event;
2789
+ otherNotes = other.notes;
2790
+ }
2791
+ }
2792
+ const keptWithOther = otherNotes.length === 0
2793
+ ? kept
2794
+ : { ...kept, content: withNetworkNotes(kept.content, otherNotes) };
2795
+ const { content, outputId } = await this.keptContent(ctx, call.id, keptWithOther);
2796
+ const { text: _text, denialHint: _hint, ...rest } = keptWithOther;
2760
2797
  const result = {
2761
2798
  ...rest,
2762
2799
  content: clipKept(content),
@@ -2764,7 +2801,7 @@ let ToolPipeline = class ToolPipeline {
2764
2801
  };
2765
2802
  // the service's call ran: its display-only events and tool.called now, the result once the
2766
2803
  // ask settles
2767
- const written = await this.writeResultIn(ctx, call.id, toolKey, kept, [...pre], callAudit, []);
2804
+ const written = await this.writeResultIn(ctx, call.id, toolKey, keptWithOther, otherEvent !== null ? [...pre, otherEvent] : [...pre], callAudit, []);
2768
2805
  if (written.length > 0)
2769
2806
  await this.deps.eventLog.notify(ctx.conversationId, Math.max(...written.map((e) => e.seq)));
2770
2807
  const ask = await this.deps.approvals.requestLoopback({
@@ -1,9 +1,13 @@
1
1
  import type { ToolSpec } from "@capybara-hq/plugin-sdk";
2
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
3
  /**
4
- * 把工具定义按指纹存进 `capybara.tool_specs`(内容寻址:同一指纹只存一次,已存在不改)。
5
- * `model_call` 只记 `{key, specHash}`,定义本身存这里——连接器刷新 / 插件升级改了定义之后,早先请求用过的定义
6
- * 仍可按指纹取回,模型请求可由日志还原。
4
+ * Stores tool definitions by fingerprint in `capybara.tool_specs` (content-addressed: one row per
5
+ * fingerprint, never changed, except that a row written before `spec_text` existed gets it on the
6
+ * next write). `model_call` records only `{key, specHash}`; the definition lives here, so after a
7
+ * connector refresh or a plugin upgrade the definitions an earlier request used can still be read
8
+ * back and the request rebuilt from the log. `spec_text` keeps the JSON text as sent: `spec` is
9
+ * jsonb, which reorders keys, and a rebuilt request must serialize byte for byte like the original
10
+ * (a provider renders its tools from that JSON; a reordered schema misses the prompt cache).
7
11
  */
8
12
  export declare function recordToolSpecs(
9
13
  /** The pool or a transaction (a transaction is a Kysely handle too). */
@@ -11,5 +15,10 @@ db: KernelSchemaDb, specs: readonly {
11
15
  specHash: string;
12
16
  spec: ToolSpec;
13
17
  }[]): Promise<void>;
14
- /** 按指纹取回工具定义;没有记录 → null。 */
18
+ /** A stored definition: its JSON text as sent when recorded, else the jsonb value. */
19
+ export declare function storedToolSpec(row: {
20
+ spec: unknown;
21
+ spec_text: string | null;
22
+ }): ToolSpec;
23
+ /** The tool definition stored under a fingerprint ({@link storedToolSpec}); null when none. */
15
24
  export declare function loadToolSpec(db: KernelSchemaDb, specHash: string): Promise<ToolSpec | null>;
@@ -1,7 +1,11 @@
1
1
  /**
2
- * 把工具定义按指纹存进 `capybara.tool_specs`(内容寻址:同一指纹只存一次,已存在不改)。
3
- * `model_call` 只记 `{key, specHash}`,定义本身存这里——连接器刷新 / 插件升级改了定义之后,早先请求用过的定义
4
- * 仍可按指纹取回,模型请求可由日志还原。
2
+ * Stores tool definitions by fingerprint in `capybara.tool_specs` (content-addressed: one row per
3
+ * fingerprint, never changed, except that a row written before `spec_text` existed gets it on the
4
+ * next write). `model_call` records only `{key, specHash}`; the definition lives here, so after a
5
+ * connector refresh or a plugin upgrade the definitions an earlier request used can still be read
6
+ * back and the request rebuilt from the log. `spec_text` keeps the JSON text as sent: `spec` is
7
+ * jsonb, which reorders keys, and a rebuilt request must serialize byte for byte like the original
8
+ * (a provider renders its tools from that JSON; a reordered schema misses the prompt cache).
5
9
  */
6
10
  export async function recordToolSpecs(
7
11
  /** The pool or a transaction (a transaction is a Kysely handle too). */
@@ -15,19 +19,29 @@ db, specs) {
15
19
  // 按指纹排序插入:并发事务插入同一批指纹时加锁顺序一致,不会互相死锁
16
20
  const rows = [...unique]
17
21
  .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
18
- .map(([hash, spec]) => ({ spec_hash: hash, spec: JSON.stringify(spec) }));
22
+ .map(([hash, spec]) => {
23
+ const text = JSON.stringify(spec);
24
+ return { spec_hash: hash, spec: text, spec_text: text };
25
+ });
19
26
  await db
20
27
  .insertInto("tool_specs")
21
28
  .values(rows)
22
- .onConflict((oc) => oc.column("spec_hash").doNothing())
29
+ .onConflict((oc) => oc
30
+ .column("spec_hash")
31
+ .doUpdateSet((eb) => ({ spec_text: eb.ref("excluded.spec_text") }))
32
+ .where("tool_specs.spec_text", "is", null))
23
33
  .execute();
24
34
  }
25
- /** 按指纹取回工具定义;没有记录 → null。 */
35
+ /** A stored definition: its JSON text as sent when recorded, else the jsonb value. */
36
+ export function storedToolSpec(row) {
37
+ return (row.spec_text !== null ? JSON.parse(row.spec_text) : row.spec);
38
+ }
39
+ /** The tool definition stored under a fingerprint ({@link storedToolSpec}); null when none. */
26
40
  export async function loadToolSpec(db, specHash) {
27
41
  const row = await db
28
42
  .selectFrom("tool_specs")
29
- .select("spec")
43
+ .select(["spec", "spec_text"])
30
44
  .where("spec_hash", "=", specHash)
31
45
  .executeTakeFirst();
32
- return row ? row.spec : null;
46
+ return row ? storedToolSpec(row) : null;
33
47
  }
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { Module } from "@nestjs/common";
8
+ import { AgentLookupModule } from "../agents/agent-lookup.js";
8
9
  import { AutomationStoreModule } from "../automations/store.module.js";
9
10
  import { BackgroundModule } from "../background/background.module.js";
10
11
  import { ConversationAccessModule } from "../conversations/access.js";
@@ -48,6 +49,7 @@ import { ConnectorsService } from "./connectors.service.js";
48
49
  import { CredentialsModule } from "./credentials.module.js";
49
50
  import { ToolDrift } from "./drift.js";
50
51
  import { ConversationToolInfo, OrgExtensionTools } from "./info.js";
52
+ import { MentionableConnectorsService } from "./mentionable-connectors.js";
51
53
  import { OAuthFlow } from "./oauth/flow.js";
52
54
  import { OrgToolSwitches } from "./org-tool-switches.js";
53
55
  import { ToolOutputs } from "./outputs.js";
@@ -121,6 +123,8 @@ ToolsModule = __decorate([
121
123
  AutomationStoreModule,
122
124
  // connector credentials (also the git gateway's, without importing this module)
123
125
  CredentialsModule,
126
+ // the agent the mentionable connectors are listed for, as the viewer may see it
127
+ AgentLookupModule,
124
128
  ],
125
129
  providers: [
126
130
  PermissionApprovalJobs,
@@ -150,6 +154,8 @@ ToolsModule = __decorate([
150
154
  ConversationToolInfo,
151
155
  OrgExtensionTools,
152
156
  OrgToolSwitches,
157
+ // the composer's `@` menu: the connectors an agent can be pointed at
158
+ MentionableConnectorsService,
153
159
  ],
154
160
  exports: [
155
161
  PermissionApprovalJobs,
@@ -171,6 +177,7 @@ ToolsModule = __decorate([
171
177
  ConversationToolInfo,
172
178
  OrgExtensionTools,
173
179
  OrgToolSwitches,
180
+ MentionableConnectorsService,
174
181
  ],
175
182
  })
176
183
  ], ToolsModule);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.115",
3
+ "version": "0.1.0-rc.116",
4
4
  "description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yaml": "^2.9.1",
67
67
  "yauzl": "3.4.0",
68
68
  "zod": "^4.6.7",
69
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.90"
69
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.91"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@langchain/langgraph-checkpoint-validation": "^1.2.0",
@@ -75,7 +75,7 @@
75
75
  "@types/ws": "^8.18.2",
76
76
  "@types/yauzl": "3.4.0",
77
77
  "ws": "^8.22.0",
78
- "@capybara-hq/testing": "0.1.0-rc.49"
78
+ "@capybara-hq/testing": "0.1.0-rc.50"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsc -b"
@@ -0,0 +1,8 @@
1
+ -- The exact JSON text of a tool definition as the runtime sent it. `spec` is jsonb, which reorders
2
+ -- object keys (shorter keys first), so a request rebuilt from it (an eval replay, the prompt
3
+ -- suggestion's side request) serialized its input schemas in another key order than the original
4
+ -- request: a provider renders the tools from that JSON, so the rebuilt prompt differed and missed
5
+ -- the prompt cache from the tools on. Readers prefer `spec_text`; null on rows written before it
6
+ -- (filled by the next write of the same fingerprint).
7
+
8
+ ALTER TABLE tool_specs ADD COLUMN IF NOT EXISTS spec_text text;