@capybara-hq/kernel 0.1.0-rc.112 → 0.1.0-rc.113

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.
@@ -28,6 +28,7 @@ import { TransactionHost, withTransactionFencePrelude, } from "../infra/database
28
28
  import { Transactional } from "../infra/database/transactional.decorator.js";
29
29
  import { KernelEvents } from "../infra/events/kernel-events.js";
30
30
  import { OutboxService } from "../infra/outbox/outbox.service.js";
31
+ import { projectSkillOf } from "../runtime/context/project-root.js";
31
32
  import { ProviderRegistry } from "../runtime/providers.js";
32
33
  import { RunControl as RunControlService } from "../runtime/run-control.js";
33
34
  import { RunDeletion } from "../runtime/run-deletion.js";
@@ -326,8 +327,10 @@ let ConversationsService = class ConversationsService {
326
327
  return prior;
327
328
  const deviceId = await this.devices.forNew(orgId, accountId, pick);
328
329
  const next = await this.planSwitch(orgId, agent.definition, NO_SELECTION, input);
329
- // the project its files are checked in, read before the write (the binding inside it decides)
330
- const project = (input.projectFiles?.length ?? 0) > 0
330
+ // the project its files are checked in, or its project skill is rendered from, read before the
331
+ // write (the binding inside it decides)
332
+ const project = (input.projectFiles?.length ?? 0) > 0 ||
333
+ (input.skill !== undefined && projectSkillOf(input.skill.name) !== undefined)
331
334
  ? await this.bindingFor(orgId, accountId, deviceId, pick.project)
332
335
  : undefined;
333
336
  const extra = await this.resolveExtra(orgId, accountId, input, {
@@ -335,7 +338,7 @@ let ConversationsService = class ConversationsService {
335
338
  project,
336
339
  signal: internal.signal,
337
340
  });
338
- const invoked = await this.prepareSkill(orgId, accountId, agentId, { conversationId: undefined, deviceId }, agent.definition, input);
341
+ const invoked = await this.prepareSkill(orgId, accountId, agentId, { conversationId: undefined, deviceId, ...(project !== undefined && { project }) }, agent.definition, input);
339
342
  const id = randomUUID();
340
343
  let all;
341
344
  try {
@@ -1264,16 +1267,20 @@ let ConversationsService = class ConversationsService {
1264
1267
  * against the agent's current version and, for an existing conversation, its trial drafts.
1265
1268
  */
1266
1269
  async prepareSkill(orgId, accountId, agentId,
1267
- /** The conversation (absent before it is created) and its device (its skills root). */
1270
+ /**
1271
+ * The conversation (absent before it is created), its device (its skills root) and, before it
1272
+ * is created, the project it is created bound to.
1273
+ */
1268
1274
  where, agent, input) {
1269
1275
  if (input.skill === undefined)
1270
1276
  return undefined;
1271
- const { conversationId, deviceId } = where;
1277
+ const { conversationId, deviceId, project } = where;
1272
1278
  return this.invoker.prepare({
1273
1279
  orgId,
1274
1280
  agentId,
1275
1281
  accountId,
1276
1282
  ...(conversationId !== undefined && { conversationId }),
1283
+ ...(project !== undefined && { project }),
1277
1284
  deviceId,
1278
1285
  agent,
1279
1286
  name: input.skill.name,
@@ -205,11 +205,13 @@ let AgentSkillsOperations = class AgentSkillsOperations {
205
205
  }),
206
206
  defineOperation({
207
207
  id: "agents.invocable-skills",
208
- description: "List the skills a person can invoke with / on an agent (its effective skills: org, platform and its own), by name: id, name, source (platform, plugin, agent or project), state (manual for manual-only), description, version and the plugin. Optionally pass a conversation of yours with that agent to include its trial drafts and, for a conversation bound to a project, the project's skills as project:<name>.",
208
+ description: "List the skills a person can invoke with / on an agent (its effective skills: org, platform and its own), by name: id, name, source (platform, plugin, agent or project), state (manual for manual-only), description, version and the plugin. Optionally pass a conversation of yours with that agent to include its trial drafts and, for a conversation bound to a project, the project's skills as project:<name>; without a conversation, pass deviceId and project (a project of that device) to include that project's skills as last read in one of your conversations.",
209
209
  input: z
210
210
  .object({
211
211
  agentId: AgentId,
212
212
  conversationId: InvocableSkillsQuerySchema.shape.conversationId,
213
+ deviceId: InvocableSkillsQuerySchema.shape.deviceId,
214
+ project: InvocableSkillsQuerySchema.shape.project,
213
215
  })
214
216
  .strict(),
215
217
  example: { agentId: "7c1a5b0e-9a53-4c6b-8d64-2f5a1b0c3e77" },
@@ -227,7 +229,9 @@ let AgentSkillsOperations = class AgentSkillsOperations {
227
229
  },
228
230
  ],
229
231
  run: async (input, ctx) => ({
230
- items: (await this.invoker.listFor(ctx.orgId, input.agentId, ctx.actorAccountId, input.conversationId)).map((s) => ({
232
+ items: (await this.invoker.listFor(ctx.orgId, input.agentId, ctx.actorAccountId, input.conversationId, input.deviceId !== undefined && input.project !== undefined
233
+ ? { deviceId: input.deviceId, project: input.project }
234
+ : undefined)).map((s) => ({
231
235
  id: s.id,
232
236
  name: s.name,
233
237
  source: s.source,
@@ -4,6 +4,8 @@ import { type OrgContext } from "../orgs/org.guard.js";
4
4
  import { type InvocableSkill, SkillInvoker } from "./invoke.js";
5
5
  declare const ListQuery: z.ZodObject<{
6
6
  conversationId: z.ZodOptional<z.ZodString>;
7
+ deviceId: z.ZodOptional<z.ZodString>;
8
+ project: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
7
9
  }, z.core.$strict>;
8
10
  /**
9
11
  * The composer's `/` menu (phase D spec §4.5): `GET /api/v1/orgs/:orgId/agents/:agentId/
@@ -12,6 +14,8 @@ declare const ListQuery: z.ZodObject<{
12
14
  * (`agents.use`, human principals: invocations are sent from a conversation); an agent the caller
13
15
  * cannot use → 404 `agent.not_found`; a `conversationId` that is not the caller's conversation with
14
16
  * this agent → 404 `conversation.not_found` (with it, that conversation's trial drafts apply).
17
+ * Without a conversation, `deviceId` and `project` add the picked project's skills from its last
18
+ * known snapshot among the caller's own conversations.
15
19
  */
16
20
  export declare class InvocableSkillsController {
17
21
  private readonly invoker;
@@ -24,6 +24,8 @@ class InvocableSkillsQuery extends createZodDto(ListQuery, "InvocableSkillsQuery
24
24
  * (`agents.use`, human principals: invocations are sent from a conversation); an agent the caller
25
25
  * cannot use → 404 `agent.not_found`; a `conversationId` that is not the caller's conversation with
26
26
  * this agent → 404 `conversation.not_found` (with it, that conversation's trial drafts apply).
27
+ * Without a conversation, `deviceId` and `project` add the picked project's skills from its last
28
+ * known snapshot among the caller's own conversations.
27
29
  */
28
30
  let InvocableSkillsController = class InvocableSkillsController {
29
31
  invoker;
@@ -33,7 +35,9 @@ let InvocableSkillsController = class InvocableSkillsController {
33
35
  async list(principal, org, agentId, q) {
34
36
  const p = requireUser(principal);
35
37
  return {
36
- skills: await this.invoker.listFor(org.orgId, agentId, p.account.id, q.conversationId),
38
+ skills: await this.invoker.listFor(org.orgId, agentId, p.account.id, q.conversationId, q.deviceId !== undefined && q.project !== undefined
39
+ ? { deviceId: q.deviceId, project: q.project }
40
+ : undefined),
37
41
  };
38
42
  }
39
43
  };
@@ -94,6 +94,37 @@ export declare function projectInvocables(p: ProjectRootPayload | undefined): In
94
94
  * `project_root`'s skills; null when it is.
95
95
  */
96
96
  export declare function projectSkillBlocked(p: ProjectRootPayload | undefined, name: string): NotInvocableReason | null;
97
+ /** A conversation's project binding: the device and the project's name and root. */
98
+ export interface ProjectBinding {
99
+ deviceId: string;
100
+ name: string;
101
+ path: string;
102
+ }
103
+ /**
104
+ * The last known snapshot of a project (project skills before the first run, design §3.1): the
105
+ * newest usable `project_root` among the caller's own chat conversations bound to the same device,
106
+ * project name and root (each conversation's latest one). What a run of the same person read from
107
+ * that project; the device is never asked. Undefined when none is known.
108
+ */
109
+ export declare function latestKnownProjectRoot(db: KernelSchemaDb, a: {
110
+ orgId: string;
111
+ accountId: string;
112
+ binding: ProjectBinding;
113
+ }): Promise<ProjectRootPayload | undefined>;
114
+ /**
115
+ * The snapshot a conversation's project skills come from: its own latest `project_root`, or, when
116
+ * its runs never recorded one, the last known snapshot of its binding among its owner's
117
+ * conversations ({@link latestKnownProjectRoot}). `own` says which. Undefined when neither exists.
118
+ */
119
+ export declare function projectSnapshotOf(db: KernelSchemaDb, a: {
120
+ orgId: string;
121
+ conversationId: string;
122
+ },
123
+ /** The conversation's own latest `project_root` (default: read with `db`). */
124
+ ownLatest?: () => Promise<ProjectRootPayload | undefined>): Promise<{
125
+ payload: ProjectRootPayload;
126
+ own: boolean;
127
+ } | undefined>;
97
128
  /**
98
129
  * Whether the skill a queued invocation recorded is still one a person can invoke in this
99
130
  * conversation (phase D Task 9, checked again at dispatch): the same skill (by id) among the
@@ -120,7 +151,12 @@ export declare const forkLeadText: (name: string, agentType: string, args: strin
120
151
  export declare function projectSkillStub(a: {
121
152
  name: string;
122
153
  args: string;
123
- }, latest: ProjectRootPayload, bare: string): RenderedInvocation;
154
+ }, latest: ProjectRootPayload, bare: string,
155
+ /**
156
+ * Where `latest` comes from: `run`, this conversation's run start; `known`, the last known
157
+ * snapshot of the project from another conversation (no run of this one read it yet).
158
+ */
159
+ from?: "run" | "known"): RenderedInvocation;
124
160
  /** The warning recorded when a forked skill's `agent` does not resolve (spec §6.2). */
125
161
  export declare const forkAgentUnknownText: (name: string, agent: string) => string;
126
162
  /**
@@ -144,7 +180,21 @@ export declare class SkillInvoker {
144
180
  * then its trial drafts apply, and its latest usable `project_root` adds the project's skills
145
181
  * after the agent's ({@link projectInvocables}).
146
182
  */
147
- listFor(orgId: string, agentId: string, accountId: string, conversationId?: string): Promise<InvocableSkill[]>;
183
+ listFor(orgId: string, agentId: string, accountId: string, conversationId?: string,
184
+ /**
185
+ * Without `conversationId`: the new conversation's picked device project (design §3.2), whose
186
+ * last known snapshot adds the project's skills.
187
+ */
188
+ pick?: {
189
+ deviceId: string;
190
+ project: string;
191
+ }): Promise<InvocableSkill[]>;
192
+ /**
193
+ * The device project a new conversation picked, by device and name, or undefined when the device
194
+ * has no project of that name. Only its last known snapshot among the caller's own conversations
195
+ * is used, so nothing of someone else's device can be read through it.
196
+ */
197
+ private pickedBinding;
148
198
  /**
149
199
  * The agent's effective skills a person can invoke (`user` not false), sorted by name (code
150
200
  * point order), model-invocable and manual-only alike (spec §3.1).
@@ -174,6 +224,14 @@ export declare class SkillInvoker {
174
224
  * names the skill's directory ({@link knownSkillsRoot}). Null or absent: `/skills`.
175
225
  */
176
226
  deviceId?: string | null;
227
+ /**
228
+ * The first message of a conversation not created yet: the project it is created bound to, as
229
+ * the creation resolves it (its last known snapshot renders a project skill, design §3.3).
230
+ */
231
+ project?: {
232
+ name: string;
233
+ path: string;
234
+ };
177
235
  agent: AgentDefinition;
178
236
  name: string;
179
237
  args: string;
@@ -188,6 +246,14 @@ export declare class SkillInvoker {
188
246
  * the `Skill` tool.
189
247
  */
190
248
  private prepareProject;
249
+ /** {@link projectSnapshotOf}, the conversation's own latest read through the event log. */
250
+ private conversationSnapshot;
251
+ /**
252
+ * Where a send's project skill is rendered from (design §3.3): the conversation's own latest
253
+ * `project_root`, else the last known snapshot of its binding; for a conversation not created
254
+ * yet, the last known snapshot of the project it is created bound to.
255
+ */
256
+ private projectSnapshot;
191
257
  /**
192
258
  * The task of a fork invocation's sub-agent (spec §6.2), rendered at dispatch from the version
193
259
  * the person's message recorded (`skill.{id, source, version, arguments}`), never by name, so a
@@ -119,6 +119,70 @@ async function latestProjectRoot(db, conversationId) {
119
119
  .executeTakeFirst();
120
120
  return row?.payload;
121
121
  }
122
+ /** How many of the caller's bound conversations {@link latestKnownProjectRoot} looks through. */
123
+ const KNOWN_SNAPSHOT_CONVERSATIONS = 20;
124
+ /**
125
+ * The last known snapshot of a project (project skills before the first run, design §3.1): the
126
+ * newest usable `project_root` among the caller's own chat conversations bound to the same device,
127
+ * project name and root (each conversation's latest one). What a run of the same person read from
128
+ * that project; the device is never asked. Undefined when none is known.
129
+ */
130
+ export async function latestKnownProjectRoot(db, a) {
131
+ const rows = await db
132
+ .selectFrom("conversations as c")
133
+ .innerJoinLateral((eb) => eb
134
+ .selectFrom("conversation_events as e")
135
+ .select(["e.payload", "e.created_at"])
136
+ .whereRef("e.conversation_id", "=", "c.id")
137
+ .where("e.type", "=", "project_root")
138
+ .orderBy("e.seq", "desc")
139
+ .limit(1)
140
+ .as("p"), (join) => join.onTrue())
141
+ .select("p.payload")
142
+ .where("c.org_id", "=", a.orgId)
143
+ .where("c.account_id", "=", a.accountId)
144
+ .where("c.kind", "=", "chat")
145
+ .where("c.deleted_at", "is", null)
146
+ .where("c.device_id", "=", a.binding.deviceId)
147
+ .where("c.project_name", "=", a.binding.name)
148
+ .where("c.project_path", "=", a.binding.path)
149
+ .orderBy("p.created_at", "desc")
150
+ .limit(KNOWN_SNAPSHOT_CONVERSATIONS)
151
+ .execute();
152
+ return rows.map((r) => r.payload).find((p) => p.unavailable === undefined);
153
+ }
154
+ /**
155
+ * The snapshot a conversation's project skills come from: its own latest `project_root`, or, when
156
+ * its runs never recorded one, the last known snapshot of its binding among its owner's
157
+ * conversations ({@link latestKnownProjectRoot}). `own` says which. Undefined when neither exists.
158
+ */
159
+ export async function projectSnapshotOf(db, a,
160
+ /** The conversation's own latest `project_root` (default: read with `db`). */
161
+ ownLatest = () => latestProjectRoot(db, a.conversationId)) {
162
+ const own = await ownLatest();
163
+ if (own !== undefined)
164
+ return { payload: own, own: true };
165
+ const bound = await bindingOf(db, a);
166
+ if (bound === undefined)
167
+ return undefined;
168
+ const known = await latestKnownProjectRoot(db, { orgId: a.orgId, ...bound });
169
+ return known === undefined ? undefined : { payload: known, own: false };
170
+ }
171
+ /** The conversation's owner and project binding, or undefined for a free conversation. */
172
+ async function bindingOf(db, a) {
173
+ const row = await db
174
+ .selectFrom("conversations")
175
+ .select(["account_id", "device_id", "project_name", "project_path"])
176
+ .where("id", "=", a.conversationId)
177
+ .where("org_id", "=", a.orgId)
178
+ .executeTakeFirst();
179
+ if (!row || row.device_id === null || row.project_name === null || row.project_path === null)
180
+ return undefined;
181
+ return {
182
+ accountId: row.account_id,
183
+ binding: { deviceId: row.device_id, name: row.project_name, path: row.project_path },
184
+ };
185
+ }
122
186
  /**
123
187
  * Whether the skill a queued invocation recorded is still one a person can invoke in this
124
188
  * conversation (phase D Task 9, checked again at dispatch): the same skill (by id) among the
@@ -127,7 +191,8 @@ async function latestProjectRoot(db, conversationId) {
127
191
  */
128
192
  export async function recordedSkillBlocked(db, a) {
129
193
  if (projectSkillOf(a.skillId) !== undefined) {
130
- return projectSkillBlocked(await latestProjectRoot(db, a.conversationId), a.skillId);
194
+ const snapshot = await projectSnapshotOf(db, a);
195
+ return projectSkillBlocked(snapshot?.payload, a.skillId);
131
196
  }
132
197
  const found = (await resolveSkills(db, a)).find((r) => r.skill.id === a.skillId);
133
198
  if (!found)
@@ -144,7 +209,12 @@ export const forkLeadText = (name, agentType, args) => escapeSkillInvocationTags
144
209
  * `project:<name>` with its `Skill` tool, which reads it under the run's admission. Model-visible,
145
210
  * so English; tags in the arguments stay inert. Always inline, as before.
146
211
  */
147
- export function projectSkillStub(a, latest, bare) {
212
+ export function projectSkillStub(a, latest, bare,
213
+ /**
214
+ * Where `latest` comes from: `run`, this conversation's run start; `known`, the last known
215
+ * snapshot of the project from another conversation (no run of this one read it yet).
216
+ */
217
+ from = "run") {
148
218
  const skill = latest.skills.find((s) => s.name === bare);
149
219
  if (skill === undefined)
150
220
  throw notInvocable("not_found", a.name);
@@ -161,7 +231,7 @@ export function projectSkillStub(a, latest, bare) {
161
231
  const dir = `${root === "/" ? "" : root}/${PROJECT_SKILLS_DIR}/${bare}`;
162
232
  const text = escapeSkillInvocationTags([
163
233
  `The user invoked the project skill "${a.name}" with /${a.name}${args === "" ? "" : ` ${args}`}.`,
164
- `Its instructions are not included in this message: call ${BUILTIN.Skill} with the name "${a.name}" to load them from the project (its directory is ${dir}; the SKILL.md recorded at the run start has the digest ${skill.digest}), then follow them${args === "" ? "." : " with the user's arguments:"}`,
234
+ `Its instructions are not included in this message: call ${BUILTIN.Skill} with the name "${a.name}" to load them from the project (its directory is ${dir}; the SKILL.md ${from === "run" ? "recorded at the run start" : "last recorded for this project"} has the digest ${skill.digest}), then follow them${args === "" ? "." : " with the user's arguments:"}`,
165
235
  ...(args === "" ? [] : [args]),
166
236
  ].join("\n\n"));
167
237
  return {
@@ -204,7 +274,12 @@ let SkillInvoker = class SkillInvoker {
204
274
  * then its trial drafts apply, and its latest usable `project_root` adds the project's skills
205
275
  * after the agent's ({@link projectInvocables}).
206
276
  */
207
- async listFor(orgId, agentId, accountId, conversationId) {
277
+ async listFor(orgId, agentId, accountId, conversationId,
278
+ /**
279
+ * Without `conversationId`: the new conversation's picked device project (design §3.2), whose
280
+ * last known snapshot adds the project's skills.
281
+ */
282
+ pick) {
208
283
  const agent = await this.agents.get(orgId, agentId, accountId);
209
284
  if (conversationId !== undefined) {
210
285
  const row = await this.db
@@ -225,13 +300,34 @@ let SkillInvoker = class SkillInvoker {
225
300
  agent: agent.definition,
226
301
  ...(conversationId !== undefined && { conversationId }),
227
302
  });
228
- if (conversationId === undefined)
229
- return skills;
230
303
  // a project skill is loaded by the agent's Skill tool: none without it
231
304
  if (!hasBuiltin(agent.definition, BUILTIN.Skill))
232
305
  return skills;
233
- const latest = await this.eventLog.latestOfType(conversationId, "project_root");
234
- return [...skills, ...projectInvocables(latest?.payload)];
306
+ if (conversationId !== undefined) {
307
+ const snapshot = await this.conversationSnapshot(orgId, conversationId);
308
+ return [...skills, ...projectInvocables(snapshot?.payload)];
309
+ }
310
+ if (pick === undefined)
311
+ return skills;
312
+ const binding = await this.pickedBinding(pick.deviceId, pick.project);
313
+ if (binding === undefined)
314
+ return skills;
315
+ const known = await latestKnownProjectRoot(this.db.db, { orgId, accountId, binding });
316
+ return [...skills, ...projectInvocables(known)];
317
+ }
318
+ /**
319
+ * The device project a new conversation picked, by device and name, or undefined when the device
320
+ * has no project of that name. Only its last known snapshot among the caller's own conversations
321
+ * is used, so nothing of someone else's device can be read through it.
322
+ */
323
+ async pickedBinding(deviceId, name) {
324
+ const row = await this.db.db
325
+ .selectFrom("device_projects")
326
+ .select("path")
327
+ .where("device_id", "=", deviceId)
328
+ .where("name", "=", name)
329
+ .executeTakeFirst();
330
+ return row === undefined ? undefined : { deviceId, name, path: row.path };
235
331
  }
236
332
  /**
237
333
  * The agent's effective skills a person can invoke (`user` not false), sorted by name (code
@@ -333,10 +429,8 @@ let SkillInvoker = class SkillInvoker {
333
429
  * the `Skill` tool.
334
430
  */
335
431
  async prepareProject(a, bare) {
336
- const { conversationId } = a;
337
- if (conversationId === undefined)
338
- throw notInvocable("not_found", a.name);
339
- const latest = (await this.eventLog.latestOfType(conversationId, "project_root"))?.payload;
432
+ const snapshot = await this.projectSnapshot(a);
433
+ const latest = snapshot?.payload;
340
434
  if (latest?.unavailable !== undefined) {
341
435
  throw projectUnavailable(latest.unavailable.reason, `Skill "${a.name}" cannot be invoked: the project "${latest.project}" is not available (${latest.unavailable.message})`);
342
436
  }
@@ -346,7 +440,28 @@ let SkillInvoker = class SkillInvoker {
346
440
  // no device read at send time: the agent loads the skill with Skill
347
441
  if (!hasBuiltin(a.agent, BUILTIN.Skill))
348
442
  throw projectUnavailable("skill_tool_off", `Skill "${a.name}" cannot be invoked: this agent cannot load project skills; turn on its ${BUILTIN.Skill} tool`);
349
- return projectSkillStub(a, latest, bare);
443
+ return projectSkillStub(a, latest, bare, snapshot?.own === false ? "known" : "run");
444
+ }
445
+ /** {@link projectSnapshotOf}, the conversation's own latest read through the event log. */
446
+ conversationSnapshot(orgId, conversationId) {
447
+ return projectSnapshotOf(this.db.db, { orgId, conversationId }, async () => (await this.eventLog.latestOfType(conversationId, "project_root"))?.payload);
448
+ }
449
+ /**
450
+ * Where a send's project skill is rendered from (design §3.3): the conversation's own latest
451
+ * `project_root`, else the last known snapshot of its binding; for a conversation not created
452
+ * yet, the last known snapshot of the project it is created bound to.
453
+ */
454
+ async projectSnapshot(a) {
455
+ if (a.conversationId !== undefined)
456
+ return this.conversationSnapshot(a.orgId, a.conversationId);
457
+ if (a.project === undefined || a.deviceId === undefined || a.deviceId === null)
458
+ return undefined;
459
+ const known = await latestKnownProjectRoot(this.db.db, {
460
+ orgId: a.orgId,
461
+ accountId: a.accountId,
462
+ binding: { deviceId: a.deviceId, ...a.project },
463
+ });
464
+ return known === undefined ? undefined : { payload: known, own: false };
350
465
  }
351
466
  /**
352
467
  * The task of a fork invocation's sub-agent (spec §6.2), rendered at dispatch from the version
@@ -89,8 +89,14 @@ export declare const AgentSkillUploadBody: z.ZodObject<{
89
89
  export declare const AgentSkillRegisterBody: z.ZodObject<{
90
90
  uploadId: z.ZodString;
91
91
  }, z.core.$strict>;
92
- /** `?conversationId=` of `GET /agents/:agentId/invocable-skills`. */
92
+ /**
93
+ * `?conversationId=` of `GET /agents/:agentId/invocable-skills`; without it, `deviceId` and
94
+ * `project` name a new conversation's picked device project, whose last known snapshot lists the
95
+ * project's skills (project skills before the first run, design §3.2).
96
+ */
93
97
  export declare const InvocableSkillsQuerySchema: z.ZodObject<{
94
98
  conversationId: z.ZodOptional<z.ZodString>;
99
+ deviceId: z.ZodOptional<z.ZodString>;
100
+ project: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
95
101
  }, z.core.$strict>;
96
102
  export declare const SKILL_ROUTES: readonly RouteSchemas[];
@@ -2,6 +2,7 @@ import { hasControlChars, MEDIA_NAME_MAX_CHARS, SKILL_LIMITS } from "@capybara-h
2
2
  import { z } from "zod";
3
3
  import { SKILL_PACKAGE_UPLOAD_MAX_BYTES } from "../conversations/attachments.service.js";
4
4
  import { DOWNLOAD_AS } from "../conversations/conversations.schemas.js";
5
+ import { DeviceProjectName } from "../devices/dto.js";
5
6
  /** `POST /skills/uploads`: registers a skill package upload (a presigned form). */
6
7
  export const SkillUploadBody = z
7
8
  .object({
@@ -87,9 +88,17 @@ export const AgentSkillUploadBody = z
87
88
  .strict();
88
89
  /** `POST /agents/:agentId/skills`: an uploaded package registered as one of the agent's skills. */
89
90
  export const AgentSkillRegisterBody = z.object({ uploadId: z.string().min(1).max(100) }).strict();
90
- /** `?conversationId=` of `GET /agents/:agentId/invocable-skills`. */
91
+ /**
92
+ * `?conversationId=` of `GET /agents/:agentId/invocable-skills`; without it, `deviceId` and
93
+ * `project` name a new conversation's picked device project, whose last known snapshot lists the
94
+ * project's skills (project skills before the first run, design §3.2).
95
+ */
91
96
  export const InvocableSkillsQuerySchema = z
92
- .object({ conversationId: z.string().min(1).max(100).optional() })
97
+ .object({
98
+ conversationId: z.string().min(1).max(100).optional(),
99
+ deviceId: z.string().min(1).max(100).optional(),
100
+ project: DeviceProjectName.optional(),
101
+ })
93
102
  .strict();
94
103
  export const SKILL_ROUTES = [
95
104
  { route: "GET /api/v1/orgs/:orgId/skill-changes/:id", params: SkillChangePathParams },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.112",
3
+ "version": "0.1.0-rc.113",
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": {