@frockbot/kernel-composition 0.3.2 → 0.3.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frockbot/kernel-composition",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "cordis": "4.0.0-rc.8",
22
22
  "semver": "7.8.5",
23
- "@frockbot/kernel-contracts": "0.3.2"
23
+ "@frockbot/kernel-contracts": "0.3.3"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/bun": "1.4.0",
@@ -10,6 +10,7 @@ import type {
10
10
  IsolateToolInvocationV1,
11
11
  ToolDefinition,
12
12
  ToolExecutionContext,
13
+ ToolNamespaceRegistration,
13
14
  } from "@frockbot/kernel-contracts";
14
15
  import type { PackageDescriptor } from "./index.ts";
15
16
  import {
@@ -119,6 +120,7 @@ function host(
119
120
  ) {
120
121
  const loads: RecordedLoad[] = [];
121
122
  const registered: ToolDefinition[] = [];
123
+ const namespaces: ToolNamespaceRegistration[] = [];
122
124
  const ceilings: (readonly TurnTypeV1[] | undefined)[] = [];
123
125
  const { entrypoint, ...rest } = overrides;
124
126
  const options: BotIsolateHostOptions = {
@@ -130,6 +132,13 @@ function host(
130
132
  loadPackageArtifact: () => Promise.resolve("export const tools = [];"),
131
133
  },
132
134
  tools: {
135
+ registerNamespace: (namespace) => {
136
+ namespaces.push(namespace);
137
+ return () => {
138
+ const index = namespaces.indexOf(namespace);
139
+ if (index >= 0) namespaces.splice(index, 1);
140
+ };
141
+ },
133
142
  register: (definition, registration) => {
134
143
  registered.push(definition);
135
144
  ceilings.push(registration?.admissionCeiling);
@@ -157,6 +166,7 @@ function host(
157
166
  host: new BotIsolateContributionHost(options),
158
167
  loads,
159
168
  registered,
169
+ namespaces,
160
170
  ceilings,
161
171
  };
162
172
  }
@@ -562,7 +572,11 @@ describe("Bot isolate contribution host", () => {
562
572
 
563
573
  test("registers one tool per health entry and executes it over RPC", async () => {
564
574
  let seen: IsolateToolInvocationV1 | undefined;
565
- const { host: subject, registered } = host({
575
+ const {
576
+ host: subject,
577
+ registered,
578
+ namespaces,
579
+ } = host({
566
580
  entrypoint: {
567
581
  health: () => Promise.resolve(healthy()),
568
582
  execute: (invocation) => {
@@ -579,7 +593,15 @@ describe("Bot isolate contribution host", () => {
579
593
  const active = await prepared!.commit();
580
594
  expect(registered).toHaveLength(1);
581
595
  expect(registered[0]!.name).toBe("reverse_text");
596
+ expect(registered[0]!.namespace).toBe("bot-authored");
582
597
  expect(registered[0]!.idempotent).toBe(true);
598
+ expect(namespaces).toEqual([
599
+ {
600
+ name: "bot-authored",
601
+ external: true,
602
+ status: "ready",
603
+ },
604
+ ]);
583
605
 
584
606
  const result = await registered[0]!.execute(
585
607
  { text: "ab" },
@@ -591,6 +613,7 @@ describe("Bot isolate contribution host", () => {
591
613
 
592
614
  await active.dispose();
593
615
  expect(registered).toHaveLength(0);
616
+ expect(namespaces).toHaveLength(0);
594
617
  });
595
618
 
596
619
  test("an undecodable isolate result is a tool error, not a throw", async () => {
@@ -91,7 +91,7 @@ export interface BotIsolateHostOptions {
91
91
  loader: BotIsolateLoader;
92
92
  artifacts: BotIsolateArtifactStore;
93
93
  /** Where the isolate's tools are registered — the kernel's tool surface. */
94
- tools: Pick<ToolRegistration, "register">;
94
+ tools: Pick<ToolRegistration, "register" | "registerNamespace">;
95
95
  /** The mounted Bot/generation root. Isolate hook listeners live only here. */
96
96
  loop: Context;
97
97
  userId: string;
@@ -370,6 +370,13 @@ export class BotIsolateContributionHost implements ContributionHost {
370
370
  ...(subagentRoleCeiling ? { subagentRoleCeiling } : {}),
371
371
  }
372
372
  : undefined;
373
+ registered.push(
374
+ this.options.tools.registerNamespace({
375
+ name: packageId,
376
+ external: true,
377
+ status: "ready",
378
+ }),
379
+ );
373
380
  for (const descriptor of health.tools) {
374
381
  registered.push(
375
382
  this.options.tools.register(
@@ -663,6 +670,7 @@ export class BotIsolateContributionHost implements ContributionHost {
663
670
  const options = this.options;
664
671
  return {
665
672
  ...isolateToolSchemaV1(descriptor),
673
+ namespace: packageId,
666
674
  idempotent: descriptor.idempotent,
667
675
  // A contract v1 isolate declares none, and its tools stay on every turn.
668
676
  ...(descriptor.admission ? { admission: descriptor.admission } : {}),