Skip to content

Commit 55b8fe1

Browse files
NubsCarsonShaw
authored andcommitted
fix(desktop): bundle runtime packages for Windows
1 parent b6f41f0 commit 55b8fe1

8 files changed

Lines changed: 587 additions & 25 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { describe, expect, it } from "vitest";
2+
3+
import {
4+
BASELINE_BUNDLED_RUNTIME_PACKAGES,
5+
classifyRegistryPluginRelease,
6+
getBundledRuntimePluginIds,
7+
getBundledRuntimePackages,
8+
} from "./release-plugin-policy.ts";
9+
10+
describe("release plugin policy", () => {
11+
it("ships runtime support packages without marking them as bundled registry plugins", () => {
12+
const availableDependencies = [
13+
"@elizaos/plugin-remote-manifest",
14+
"@elizaos/plugin-worker-runtime",
15+
"@elizaos/plugin-app-manager",
16+
"@elizaos/plugin-openai",
17+
];
18+
19+
expect(BASELINE_BUNDLED_RUNTIME_PACKAGES).toEqual(
20+
expect.arrayContaining([
21+
"@elizaos/plugin-remote-manifest",
22+
"@elizaos/plugin-worker-runtime",
23+
]),
24+
);
25+
expect(getBundledRuntimePackages(availableDependencies)).toEqual(
26+
expect.arrayContaining([
27+
"@elizaos/plugin-remote-manifest",
28+
"@elizaos/plugin-worker-runtime",
29+
"@elizaos/plugin-app-manager",
30+
"@elizaos/plugin-openai",
31+
]),
32+
);
33+
34+
const bundledPluginIds = new Set(
35+
getBundledRuntimePluginIds(availableDependencies),
36+
);
37+
38+
expect([...bundledPluginIds]).toEqual(["openai"]);
39+
expect(
40+
classifyRegistryPluginRelease({
41+
packageName: "@elizaos/plugin-openai",
42+
bundledPluginIds,
43+
}).releaseAvailability,
44+
).toBe("bundled");
45+
expect(
46+
classifyRegistryPluginRelease({
47+
packageName: "@elizaos/plugin-remote-manifest",
48+
bundledPluginIds: new Set(["remote-manifest"]),
49+
}).releaseAvailability,
50+
).toBe("post-release");
51+
});
52+
});

packages/agent/src/runtime/release-plugin-policy.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { CORE_PLUGINS, OPTIONAL_CORE_PLUGINS } from "./core-plugins.ts";
33
const BASELINE_RUNTIME_SUPPORT_PACKAGES = [
44
"@elizaos/core",
55
"@elizaos/prompts",
6+
"@elizaos/plugin-remote-manifest",
7+
"@elizaos/plugin-worker-runtime",
68
] as const;
79

810
const BASELINE_PROVIDER_PLUGINS = [
@@ -12,12 +14,31 @@ const BASELINE_PROVIDER_PLUGINS = [
1214
"@elizaos/plugin-ollama",
1315
] as const;
1416

17+
// Desktop loads this through the legacy "agent-orchestrator" compatibility id,
18+
// but the implementation ships as the scoped package below.
19+
const BASELINE_DESKTOP_RUNTIME_PLUGINS = [
20+
"@elizaos/plugin-agent-orchestrator",
21+
] as const;
22+
23+
// These are implementation dependencies of bundled core plugins. They need
24+
// to ship in the runtime bundle, but are not auto-loaded by collectPluginNames.
25+
const BASELINE_PLUGIN_SUPPORT_PACKAGES = [
26+
"@elizaos/plugin-calendly",
27+
"@elizaos/plugin-health",
28+
"@elizaos/plugin-app-manager",
29+
"@elizaos/plugin-registry",
30+
"@elizaos/plugin-wallet-ui",
31+
"@elizaos/plugin-wallet",
32+
] as const;
33+
1534
const DESKTOP_RUNTIME_ONLY_PLUGINS = new Set<string>([
35+
"@elizaos/plugin-agent-orchestrator",
1636
"@elizaos/plugin-browser",
1737
"@elizaos/plugin-computeruse",
1838
]);
1939

2040
const LOCAL_RUNTIME_ONLY_PLUGINS = new Set<string>([
41+
"@elizaos/plugin-agent-orchestrator",
2142
"@elizaos/plugin-browser",
2243
"@elizaos/plugin-computeruse",
2344
]);
@@ -36,6 +57,15 @@ export interface RegistryPluginReleaseCompatibility {
3657

3758
export const BASELINE_BUNDLED_RUNTIME_PACKAGES: readonly string[] = [
3859
...BASELINE_RUNTIME_SUPPORT_PACKAGES,
60+
...BASELINE_DESKTOP_RUNTIME_PLUGINS,
61+
...CORE_PLUGINS,
62+
...OPTIONAL_CORE_PLUGINS,
63+
...BASELINE_PLUGIN_SUPPORT_PACKAGES,
64+
...BASELINE_PROVIDER_PLUGINS,
65+
];
66+
67+
const BASELINE_REGISTRY_BUNDLED_PLUGIN_PACKAGES: readonly string[] = [
68+
...BASELINE_DESKTOP_RUNTIME_PLUGINS,
3969
...CORE_PLUGINS,
4070
...OPTIONAL_CORE_PLUGINS,
4171
...BASELINE_PROVIDER_PLUGINS,
@@ -48,6 +78,10 @@ export function derivePluginIdFromPackageName(packageName: string): string {
4878
.replace(/^plugin-/, "");
4979
}
5080

81+
const BASELINE_REGISTRY_BUNDLED_PLUGIN_IDS = new Set(
82+
BASELINE_REGISTRY_BUNDLED_PLUGIN_PACKAGES.map(derivePluginIdFromPackageName),
83+
);
84+
5185
export function getBundledRuntimePackages(
5286
availableDependencies: Iterable<string>,
5387
): string[] {
@@ -60,7 +94,10 @@ export function getBundledRuntimePackages(
6094
export function getBundledRuntimePluginIds(
6195
availableDependencies: Iterable<string>,
6296
): string[] {
63-
return getBundledRuntimePackages(availableDependencies)
97+
const available = new Set(availableDependencies);
98+
return BASELINE_REGISTRY_BUNDLED_PLUGIN_PACKAGES.filter((packageName) =>
99+
available.has(packageName),
100+
)
64101
.map(derivePluginIdFromPackageName)
65102
.filter((pluginId) => pluginId.length > 0)
66103
.sort();
@@ -85,7 +122,9 @@ export function classifyRegistryPluginRelease(params: {
85122
}
86123

87124
const pluginId = derivePluginIdFromPackageName(packageName);
88-
const bundled = bundledPluginIds.has(pluginId);
125+
const bundled =
126+
BASELINE_REGISTRY_BUNDLED_PLUGIN_IDS.has(pluginId) &&
127+
bundledPluginIds.has(pluginId);
89128
const requiresDesktopRuntime = DESKTOP_RUNTIME_ONLY_PLUGINS.has(packageName);
90129
const requiresLocalRuntime = LOCAL_RUNTIME_ONLY_PLUGINS.has(packageName);
91130

packages/app-core/platforms/electrobun/electrobun.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ export function resolveElectrobunCopyMap({
342342
if (fs.existsSync(path.join(repoRoot, "plugins.json"))) {
343343
copy[repoPluginsJsonPath] = `${runtimeDistDir}/plugins.json`;
344344
}
345+
if (fs.existsSync(path.join(electrobunDir, "remotes"))) {
346+
copy["remotes"] = "remotes";
347+
}
345348
copy[repoPackageJsonPath] = `${runtimeDistDir}/package.json`;
346349
}
347350

packages/app-core/platforms/electrobun/src/electrobun-config.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe("Electrobun Store packaging", () => {
1515
expect(
1616
Object.values(copy).some((target) => target.startsWith("eliza-dist/")),
1717
).toBe(false);
18+
expect(Object.values(copy)).not.toContain("remotes");
1819
});
1920

2021
it("keeps the embedded runtime tree for direct desktop builds", () => {
@@ -25,6 +26,7 @@ describe("Electrobun Store packaging", () => {
2526

2627
expect(Object.values(copy)).toContain("eliza-dist");
2728
expect(Object.values(copy)).toContain("eliza-dist/package.json");
29+
expect(copy.remotes).toBe("remotes");
2830
});
2931

3032
it("omits the embedded runtime tree for external API desktop builds", () => {
@@ -38,6 +40,7 @@ describe("Electrobun Store packaging", () => {
3840

3941
expect(Object.values(copy)).not.toContain("eliza-dist");
4042
expect(Object.values(copy)).not.toContain("eliza-dist/package.json");
43+
expect(Object.values(copy)).not.toContain("remotes");
4144
});
4245

4346
it("keeps the embedded runtime tree when external API env is invalid", () => {

0 commit comments

Comments
 (0)