Skip to content

Commit 0cda12b

Browse files
committed
refactor(bun-run): load as packaged extension
1 parent c57a97c commit 0cda12b

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { bunRunner } from "../../../src/extensions/bun-runner.ts";
2+
3+
export default bunRunner;

runtime/src/agent-pool/session.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const EXTENSIONS_DIR = resolve(__dirname, "../../extensions");
4949
const OPTIONAL_EXTENSIONS: { path: string; envGate?: string }[] = [
5050
{ path: resolve(EXTENSIONS_DIR, "integrations", "azure-openai.ts"), envGate: "AOAI_BASE_URL" },
5151
{ path: resolve(EXTENSIONS_DIR, "integrations", "context-mode.ts") },
52+
{ path: resolve(EXTENSIONS_DIR, "integrations", "bun-runner", "index.ts") },
5253
{ path: resolve(EXTENSIONS_DIR, "browser", "cdp-browser", "index.ts") },
5354
{ path: resolve(EXTENSIONS_DIR, "platform", "windows", "win-ui", "index.ts") },
5455
{ path: resolve(EXTENSIONS_DIR, "viewers", "office-viewer", "index.ts") },

runtime/src/extensions/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
* - workspaceSearch: search_workspace tool for FTS over workspace files.
1717
* - sendAdaptiveCard: send_adaptive_card for agent-owned Adaptive Card posting.
1818
* - sendDashboardWidget: send_dashboard_widget for posting the built-in live dashboard widget.
19-
* - bunRunner: bun_run for direct Bun script execution without a shell.
19+
*
20+
* Note: bun_run now lives as a packaged runtime extension under
21+
* runtime/extensions/integrations/bun-runner and is loaded via the
22+
* additionalExtensionPaths wiring in agent-pool/session.ts.
2023
*
2124
* Consumers:
2225
* - agent-pool/session.ts passes builtinExtensionFactories to the resource loader.
@@ -34,7 +37,6 @@ import { uiThemeExtension } from "./ui-theme.js";
3437
import { smartCompaction } from "./smart-compaction.js";
3538
import { sendAdaptiveCard } from "./send-adaptive-card.js";
3639
import { sendDashboardWidget } from "./send-dashboard-widget.js";
37-
import { bunRunner } from "./bun-runner.js";
3840
import { exitProcess } from "./exit-process.js";
3941
import { autoresearchSupervisor } from "./autoresearch-supervisor.js";
4042

@@ -52,7 +54,6 @@ export const builtinExtensionFactories: ExtensionFactory[] = [
5254
smartCompaction,
5355
sendAdaptiveCard,
5456
sendDashboardWidget,
55-
bunRunner,
5657
exitProcess,
5758
autoresearchSupervisor,
5859
];

runtime/test/agent-pool/agent-pool-tools.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
*
44
* Verifies that builtinExtensionFactories register the expected tools
55
* (attach_file, messages, model control, tool discovery, keychain, SQL introspection, workspace search,
6-
* adaptive cards, dashboard widget posting, graceful exit, and autoresearch controls)
6+
* adaptive cards, dashboard widget posting, graceful exit, and autoresearch controls).
7+
* bun_run is now provided by a packaged runtime extension rather than a builtin factory.
78
* and slash commands (/tasks, /scheduled, /theme, /tint) on a mock ExtensionAPI.
89
*/
910

runtime/test/extensions/extensions-bun-runner.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { join } from "path";
55

66
import { WORKSPACE_DIR } from "../../src/core/config.js";
77
import { getToolOutput } from "../../src/tool-output.js";
8-
import { bunRunner } from "../../src/extensions/bun-runner.js";
8+
import bunRunnerExtension from "../../extensions/integrations/bun-runner/index.ts";
99
import { createFakeExtensionApi } from "./fake-extension-api.js";
1010

1111
const cleanupPaths: string[] = [];
@@ -28,14 +28,14 @@ afterEach(() => {
2828
describe("bun-runner extension", () => {
2929
test("registers bun_run and advertises its hint", async () => {
3030
const fake = createFakeExtensionApi();
31-
bunRunner(fake.api);
31+
bunRunnerExtension(fake.api);
3232

3333
expect(fake.tools.has("bun_run")).toBe(true);
3434
});
3535

3636
test("runs a workspace Bun script directly and discards stdout by default", async () => {
3737
const fake = createFakeExtensionApi();
38-
bunRunner(fake.api);
38+
bunRunnerExtension(fake.api);
3939
const tool = fake.tools.get("bun_run");
4040
if (!tool) throw new Error("bun_run not registered");
4141

@@ -69,7 +69,7 @@ describe("bun-runner extension", () => {
6969

7070
test("captures stdout when requested", async () => {
7171
const fake = createFakeExtensionApi();
72-
bunRunner(fake.api);
72+
bunRunnerExtension(fake.api);
7373
const tool = fake.tools.get("bun_run");
7474
if (!tool) throw new Error("bun_run not registered");
7575

@@ -99,7 +99,7 @@ describe("bun-runner extension", () => {
9999
db.initDatabase();
100100

101101
const fake = createFakeExtensionApi();
102-
bunRunner(fake.api);
102+
bunRunnerExtension(fake.api);
103103
const tool = fake.tools.get("bun_run");
104104
if (!tool) throw new Error("bun_run not registered");
105105

@@ -126,7 +126,7 @@ describe("bun-runner extension", () => {
126126

127127
test("rejects scripts outside the workspace", async () => {
128128
const fake = createFakeExtensionApi();
129-
bunRunner(fake.api);
129+
bunRunnerExtension(fake.api);
130130
const tool = fake.tools.get("bun_run");
131131
if (!tool) throw new Error("bun_run not registered");
132132

runtime/test/extensions/optional-bundled-extensions.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ function withRouteCapture<T>(state: FakeState, fn: () => Promise<T>): Promise<T>
6363
}
6464

6565
describe("bundled optional extensions", () => {
66+
test("bun-runner registers the bun_run tool", async () => {
67+
const { default: registerBunRunner } = await import("../../extensions/integrations/bun-runner/index.ts");
68+
const fake = createFakeApi();
69+
70+
registerBunRunner(fake.api);
71+
72+
expect(fake.state.tools.has("bun_run")).toBe(true);
73+
expect(fake.state.tools.get("bun_run")?.description).toContain("workspace Bun script");
74+
});
75+
6676
test("cdp-browser registers the cdp_browser tool and cdp-tabs command", async () => {
6777
const { default: registerCdpBrowser } = await import("../../extensions/browser/cdp-browser/index.ts");
6878
const fake = createFakeApi();

0 commit comments

Comments
 (0)