Skip to content
This repository was archived by the owner on Oct 21, 2026. It is now read-only.

Commit 972a40c

Browse files
authored
feat(client): consume brand identity agents/services allowlists (#479)
* feat(schema): accept optional agents/services on the config build bundle CODE-618: the client-side schema and brand-identity mirror must accept the publisher's optional per-brand agents/services fields (subset of known agent kinds / kebab-case service ids) before any restricted-brand bundle can be consumed. Absent stays absent so unrestricted builds are byte-identical. * feat(desktop): render and surface the build-time agent/service allowlist CODE-618: mirrors brand.ts's MAIN_VITE_BRAND_IDENTITY precedent for a new MAIN_VITE_AGENT_RESTRICTIONS define, parsed once at boot into AGENT_RESTRICTIONS (fail-closed on a present-but-invalid snapshot, same as the brand identity). Exposes it to the renderer via a new synchronous systemBridge.identity.restrictions() IPC channel (sendSync, like settings.snapshot) so the composer's harness picker never flashes the full agent set on a restricted build. Absent bundle agents/services is a no-op end to end. * feat(daemon): gate new agent adapters by the restricted-brand allowlist CODE-618: apps/daemon/src/config.ts#daemonAllowedAgents() parses LINKCODE_ALLOWED_AGENTS (set by the desktop supervisor from AGENT_RESTRICTIONS, next commit); restrictedAdapterFactory() wraps createAdapter to reject any kind outside it via the existing EngineDeps.factory injection seam — no change to @linkcode/agent-adapter itself. Only gates new adapter construction: a session started before a restriction landed keeps replaying on its existing adapter, and history reads never call this. Also skips background-refreshing a disallowed agent's managed install at boot. `null` (unrestricted) is an exact no-op. * feat(desktop): exclude restricted agents' SDKs from packaged builds CODE-618 acceptance (a): agentFilesExcludes() maps each disallowed agent kind to its staged node_modules SDK package (claude-agent-sdk / codex / opencode-ai sdk -- pi's SDK is a hosted download and grok-build has no SDK, so neither needs an entry). package-app.mts wraps the resolved electron-builder config in a temporary `extends` overlay adding these as `files` excludes only when the rendered bundle declares `agents`; verify-artifacts.mts asserts their absence post-pack by exact asar path segment (never a prefix match, so e.g. @openai/codex-darwin-* can't false-positive). Both are no-ops when the bundle carries no `agents`, keeping the standard build's packaging and verification unchanged. * feat(mobile): thread the build-time agent allowlist into the config bootstrap CODE-618: BundledConfigBootstrap gains allowedAgents/allowedServices (bundle.agents/.services ?? null); the dev sentinel and every existing platform fixture stay null (unrestricted), so today's builds are unaffected. new-thread-sheet.tsx's kind picker narrows to BUNDLED_CONFIG_BOOTSTRAP .allowedAgents ?? every known kind, and hides its whole Section outright (never just disables) once at most one kind remains selectable -- mobile is single-process, so this needs no IPC. * feat(workbench,ui): filter the harness picker and add-account catalog by brand CODE-618 acceptance (c, d): selectableHarnessKinds(providers, allowedAgents?) intersects the enabled set with the brand allowlist; workbench.tsx threads it in from a new Workbench allowedAgents prop (desktop's app.tsx supplies systemBridge.identity.restrictions().allowedAgents, keeping this package IPC-free). composer-controls.tsx's ModelSelectorMenu now hides the harness submenu at <=1 selectable harness instead of 0, so a single remaining harness disappears everywhere the picker is rendered. add-flow.tsx's ServiceCatalogView filters two axes: oauth entries by their bound agent against allowedAgents, everything else (including custom, which needs no special case since it is excluded by the same id-set intersection as any other service) by allowedServices. serviceById, the account list/detail, and account resolution stay unfiltered everywhere, so an account bound to a since-hidden service keeps rendering and resolving. agents-settings.tsx's row list gets the same allowedAgents narrowing (hides the row rather than disabling its switch); view.ts's account-binding resolution is untouched. All of the above default to null (unrestricted) and are no-ops for the standard/unbranded build. * fix(engine,daemon): fix CI ESM load, history-read regression, and review findings CODE-618 PR review fixups: - schema/brand-identity: config-bundle.mts loads unbundled under plain Node (CI's Desktop App Entry / e2e:unpackaged), and its import chain reached brand-identity.ts's `import { AgentKindSchema } from '@linkcode/schema'` -- a barrel re-exporting a directory, which the bare Node ESM loader cannot resolve (ERR_UNSUPPORTED_DIR_IMPORT). remote-config.ts's own `./model/primitives` import hit the same loader via the `@linkcode/schema/remote-config` subpath. Both now duplicate the known agent-kind list locally instead of importing it as a value, matching this codebase's CONFIG_PLATFORMS/CONFIG_CHANNELS precedent; `AgentKind` stays a type-only import (erased before it reaches the runtime loader). - engine/daemon gating: the previous `EngineDeps.factory` wrapper threw for any excluded kind, but `SessionOrchestrator.list()` and `HistoryService` call the bare factory for every *persisted* record's `historyCapabilities` -- one history session of an excluded kind broke the whole `session.list`. Moved enforcement to the one place that actually constructs a *live* adapter to start/resume/relaunch a run (`SessionOrchestrator.startLive`), gated by a new `EngineDeps.allowedAgents` threaded in from the daemon; history reads and `list()` are never touched. Renamed apps/daemon/src/agent-factory.ts to agent-restrictions.ts and replaced the removed `restrictedAdapterFactory` with `filterAgentRuntimes` (masks a disallowed agent as `missing` in the boot-probe snapshot regardless of how it was actually detected) and `restrictedAssetService` (refuses `asset.ensure` for an excluded agent's managed download, reusing ManagedAssetService's existing "cannot be installed here" path -- tool assets are never agent-gated). `services` stays catalog-only filtering, as planned; daemon-side enforcement was never in scope for it. - composer-controls.tsx: reverted the harness AgentIcon's visibility back to `harnesses.length > 0` (only the submenu itself hides at <=1) -- a single remaining harness, restricted build or a user manually disabling every other one from Settings, still needs the icon since it is the only harness signal once the picker disappears. - electron-renderer.ts: `identity.restrictions()` now throws when the main process's sendSync snapshot is missing instead of defaulting to unrestricted -- this gates which agents/services render, so a missing snapshot must fail closed like every other security boundary here, not silently widen access. Kept the guard manual (no foxts/guard import): apps/desktop's preload externalizes every non-workspace dependency it doesn't explicitly bundle, the same reason this file already stays zod-free. - small cleanups: dropped an unreachable branch in daemonAllowedAgents() (split always yields >=1 element for a non-empty string); config-bundle.mts's ambient MAIN_VITE_AGENT_RESTRICTIONS guard now matches its neighboring `!== undefined` checks; package-app.mts's files-exclude overlay now writes into a fresh mkdtempSync directory instead of a fixed filename, so two concurrent (or one interrupted) packaging runs can't collide. * fix(desktop): import agent-package-excludes with an explicit extension package-app.mts and verify-artifacts.mts run under bare node, whose ESM loader rejects extensionless relative imports; tsx-run scripts were unaffected. * fix(engine,daemon): close review gaps in the restricted-brand allowlist - gate agent.catalog in AgentRequestHandler: startCatalog spawns real agent processes for codex/opencode, and the old factory wrapper's coverage of this path was lost when enforcement moved to startLive - hide excluded agents' managed assets from asset statuses/subscribe so the wrapper agrees with filterAgentRuntimes and the ensure refusal - pin both hand-duplicated agent-kind lists to AgentKindSchema with drift tests
1 parent 41087da commit 972a40c

50 files changed

Lines changed: 1273 additions & 42 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import type { AssetService } from '@linkcode/engine';
2+
import type { AgentRuntimes, InstalledAsset, ManagedAssetId } from '@linkcode/schema';
3+
import { noop } from 'foxts/noop';
4+
import { describe, expect, it, vi } from 'vitest';
5+
import { filterAgentRuntimes, restrictedAssetService } from '../agent-restrictions';
6+
7+
describe('filterAgentRuntimes', () => {
8+
const runtimes: AgentRuntimes = {
9+
'claude-code': { status: 'available', source: 'detected', path: '/usr/bin/claude' },
10+
codex: { status: 'available', source: 'sdk' },
11+
pi: { status: 'missing' },
12+
};
13+
14+
it('returns the runtimes unchanged when unrestricted', () => {
15+
expect(filterAgentRuntimes(runtimes, null)).toBe(runtimes);
16+
});
17+
18+
it('reports a disallowed kind as missing regardless of how it was actually probed', () => {
19+
const filtered = filterAgentRuntimes(runtimes, ['pi']);
20+
expect(filtered['claude-code']).toEqual({ status: 'missing' });
21+
expect(filtered.codex).toEqual({ status: 'missing' });
22+
expect(filtered.pi).toEqual({ status: 'missing' });
23+
});
24+
25+
it('leaves an allowed kind exactly as probed', () => {
26+
const filtered = filterAgentRuntimes(runtimes, ['claude-code']);
27+
expect(filtered['claude-code']).toBe(runtimes['claude-code']);
28+
});
29+
});
30+
31+
describe('restrictedAssetService', () => {
32+
// Mocks kept as loose locals rather than read back off the typed `AssetService` — asserting via
33+
// `assets.ensure` would reference an interface method (unbound-method lint) for no benefit here.
34+
function fakeAssets(): {
35+
assets: AssetService;
36+
ensure: ReturnType<typeof vi.fn>;
37+
statuses: ReturnType<typeof vi.fn>;
38+
subscribe: ReturnType<typeof vi.fn>;
39+
} {
40+
const ensure = vi.fn(
41+
(id: ManagedAssetId): Promise<InstalledAsset> =>
42+
Promise.resolve({ id, version: '1.0.0', path: '/tmp/asset' }),
43+
);
44+
const statuses = vi.fn(() => []);
45+
const subscribe = vi.fn(() => noop);
46+
return { assets: { statuses, subscribe, ensure }, ensure, statuses, subscribe };
47+
}
48+
49+
it('returns the asset service unchanged when unrestricted', () => {
50+
const { assets } = fakeAssets();
51+
expect(restrictedAssetService(assets, null)).toBe(assets);
52+
});
53+
54+
it('refuses to ensure a disallowed agent asset without touching the underlying store', async () => {
55+
const { assets, ensure } = fakeAssets();
56+
const restricted = restrictedAssetService(assets, ['pi']);
57+
58+
const installed = await restricted.ensure({ kind: 'agent', name: 'codex' });
59+
60+
expect(installed).toBeUndefined();
61+
expect(ensure).not.toHaveBeenCalled();
62+
});
63+
64+
it('passes an allowed agent asset through to the underlying store', async () => {
65+
const { assets, ensure } = fakeAssets();
66+
const restricted = restrictedAssetService(assets, ['pi']);
67+
68+
await restricted.ensure({ kind: 'agent', name: 'pi' });
69+
70+
expect(ensure).toHaveBeenCalledWith({ kind: 'agent', name: 'pi' });
71+
});
72+
73+
it('never agent-gates a tool asset', async () => {
74+
const { assets, ensure } = fakeAssets();
75+
const restricted = restrictedAssetService(assets, ['pi']);
76+
77+
await restricted.ensure({ kind: 'tool', name: 'aigateway' });
78+
79+
expect(ensure).toHaveBeenCalledWith({ kind: 'tool', name: 'aigateway' });
80+
});
81+
82+
it('hides a disallowed agent asset from statuses()', () => {
83+
const { assets, statuses } = fakeAssets();
84+
statuses.mockReturnValue([
85+
{ id: { kind: 'agent', name: 'codex' } },
86+
{ id: { kind: 'agent', name: 'pi' } },
87+
{ id: { kind: 'tool', name: 'aigateway' } },
88+
]);
89+
const restricted = restrictedAssetService(assets, ['pi']);
90+
91+
expect(restricted.statuses().map(({ id }) => id)).toEqual([
92+
{ kind: 'agent', name: 'pi' },
93+
{ kind: 'tool', name: 'aigateway' },
94+
]);
95+
});
96+
97+
it('drops a disallowed agent asset from subscribe() events', () => {
98+
const { assets, subscribe } = fakeAssets();
99+
let emit: ((event: unknown) => void) | undefined;
100+
subscribe.mockImplementation((listener: (event: unknown) => void) => {
101+
emit = listener;
102+
return noop;
103+
});
104+
const restricted = restrictedAssetService(assets, ['pi']);
105+
const listener = vi.fn();
106+
restricted.subscribe(listener);
107+
108+
emit?.({ kind: 'failed', id: { kind: 'agent', name: 'codex' }, error: 'x' });
109+
emit?.({ kind: 'failed', id: { kind: 'agent', name: 'pi' }, error: 'x' });
110+
emit?.({ kind: 'failed', id: { kind: 'tool', name: 'aigateway' }, error: 'x' });
111+
112+
expect(listener.mock.calls.map(([event]) => (event as { id: ManagedAssetId }).id)).toEqual([
113+
{ kind: 'agent', name: 'pi' },
114+
{ kind: 'tool', name: 'aigateway' },
115+
]);
116+
});
117+
});

‎apps/daemon/src/__tests__/config.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
88

99
import {
1010
cloudCredentialsPath,
11+
daemonAllowedAgents,
1112
daemonProfile,
1213
databasePath,
1314
loadConfig,
@@ -39,6 +40,7 @@ afterEach(() => {
3940
process.env.HOME = savedHome;
4041
delete process.env.LINKCODE_PROFILE;
4142
delete process.env.LINKCODE_CHANNEL;
43+
delete process.env.LINKCODE_ALLOWED_AGENTS;
4244
vi.restoreAllMocks();
4345
});
4446

@@ -634,3 +636,27 @@ describe('credential storage', () => {
634636
expect(loadConfig(vault).accounts).toEqual([oauth]);
635637
});
636638
});
639+
640+
describe('daemonAllowedAgents', () => {
641+
it('is unrestricted when the env var is unset or empty', () => {
642+
delete process.env.LINKCODE_ALLOWED_AGENTS;
643+
expect(daemonAllowedAgents()).toBeNull();
644+
process.env.LINKCODE_ALLOWED_AGENTS = '';
645+
expect(daemonAllowedAgents()).toBeNull();
646+
});
647+
648+
it('parses a single allowed agent', () => {
649+
process.env.LINKCODE_ALLOWED_AGENTS = 'pi';
650+
expect(daemonAllowedAgents()).toEqual(['pi']);
651+
});
652+
653+
it('parses and trims a comma-separated list', () => {
654+
process.env.LINKCODE_ALLOWED_AGENTS = 'pi, claude-code';
655+
expect(daemonAllowedAgents()).toEqual(['pi', 'claude-code']);
656+
});
657+
658+
it('fails closed on an unknown agent kind', () => {
659+
process.env.LINKCODE_ALLOWED_AGENTS = 'not-a-kind';
660+
expect(() => daemonAllowedAgents()).toThrow();
661+
});
662+
});
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import type { AssetService } from '@linkcode/engine';
2+
import type { AgentKind, AgentRuntimes, ManagedAssetId } from '@linkcode/schema';
3+
4+
/**
5+
* Restricted-brand runtime-probe filter (CODE-618): a disallowed agent must never read as
6+
* `available` on a restricted build, however the boot probe actually found it (detected CLI,
7+
* managed install, or SDK-resolved) — the settings page and onboarding cards read straight off
8+
* this map. `null` (unrestricted, the default build) returns `runtimes` unchanged.
9+
*/
10+
export function filterAgentRuntimes(
11+
runtimes: AgentRuntimes,
12+
allowedAgents: readonly AgentKind[] | null,
13+
): AgentRuntimes {
14+
if (allowedAgents === null) return runtimes;
15+
const filtered: AgentRuntimes = { ...runtimes };
16+
const kinds = Object.keys(filtered) as AgentKind[];
17+
for (let i = 0, len = kinds.length; i < len; i++) {
18+
const kind = kinds[i];
19+
if (!allowedAgents.includes(kind)) filtered[kind] = { status: 'missing' };
20+
}
21+
return filtered;
22+
}
23+
24+
/**
25+
* Restricted-brand managed-download gate (CODE-618): wraps the daemon's `AssetService` so an
26+
* excluded agent's managed asset disappears from every surface — `statuses`/`subscribe` never
27+
* mention it (keeping this wrapper consistent with `filterAgentRuntimes`'s `missing`), and a
28+
* client's `asset.ensure` for it gets the same "cannot be installed here" refusal
29+
* `ManagedAssetService` already gives an unpinnable asset — no new failure path to learn.
30+
* Tool assets (`kind: 'tool'`, e.g. aigateway) are never agent-gated. `null` (unrestricted) returns
31+
* `assets` unchanged.
32+
*/
33+
export function restrictedAssetService(
34+
assets: AssetService,
35+
allowedAgents: readonly AgentKind[] | null,
36+
): AssetService {
37+
if (allowedAgents === null) return assets;
38+
const excluded = (id: ManagedAssetId): boolean =>
39+
id.kind === 'agent' && !allowedAgents.includes(id.name);
40+
return {
41+
statuses: () => assets.statuses().filter(({ id }) => !excluded(id)),
42+
subscribe: (listener) =>
43+
assets.subscribe((event) => {
44+
if (!excluded(event.id)) listener(event);
45+
}),
46+
ensure: (id: ManagedAssetId) => (excluded(id) ? Promise.resolve(undefined) : assets.ensure(id)),
47+
};
48+
}

‎apps/daemon/src/config.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { dirname, join } from 'node:path';
1515
import { daemonRuntimeFilePath } from '@linkcode/common/node';
1616
import type {
1717
Accounts,
18+
AgentKind,
1819
CustomMcpServer,
1920
ProvidersConfig,
2021
SimulatorConsentState,
@@ -88,6 +89,18 @@ export function worktreeRoot(): string {
8889
return join(daemonStateDir(), 'worktrees');
8990
}
9091

92+
/**
93+
* Restricted-brand agent allowlist (CODE-618): `LINKCODE_ALLOWED_AGENTS` — injected by the desktop
94+
* supervisor from the build's identity, comma-separated — gates which adapter kinds this daemon
95+
* will spawn. Absent (the default, unbranded build) means unrestricted: `null`, never an empty
96+
* array, so every downstream check can treat "no restriction" as "skip the check".
97+
*/
98+
export function daemonAllowedAgents(): readonly AgentKind[] | null {
99+
const raw = process.env.LINKCODE_ALLOWED_AGENTS;
100+
if (raw === undefined || raw === '') return null;
101+
return raw.split(',').map((entry) => AgentKindSchema.parse(entry.trim()));
102+
}
103+
91104
/** Runtime discovery file advertising the running daemon's bound endpoints, next to config.json. */
92105
export function runtimeFilePath(): string {
93106
return daemonRuntimeFilePath(daemonChannel(), daemonProfile());

‎apps/daemon/src/index.ts‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import * as Sentry from '@sentry/node';
2626
import type { Runtime } from 'effect';
2727
import { Cause, Context, Effect, Exit, Layer, Option } from 'effect';
2828
import { extractErrorMessage } from 'foxts/extract-error-message';
29+
import { filterAgentRuntimes, restrictedAssetService } from './agent-restrictions';
2930
import { createAiGatewaySidecar } from './ai-gateway';
3031
import { installAsarSpawnFix } from './asar-spawn';
3132
import { adoptLegacyDeviceKeyFile } from './cloud/device-key';
@@ -34,6 +35,7 @@ import { startCloudUplink } from './cloud/uplink';
3435
import type { DaemonConfig } from './config';
3536
import {
3637
chatWorkspaceRoot,
38+
daemonAllowedAgents,
3739
daemonChannel,
3840
daemonProfile,
3941
databasePath,
@@ -187,7 +189,10 @@ async function main(): Promise<void> {
187189
config.customMcpServers ?? [],
188190
);
189191
const assets = new AssetManager();
190-
const consentedAgents = consentedManagedAgents(assets);
192+
const allowedAgents = daemonAllowedAgents();
193+
const consentedAgents = consentedManagedAgents(assets).filter(
194+
(kind) => allowedAgents === null || allowedAgents.includes(kind),
195+
);
191196
const refreshAgentRuntime = (kind: ManagedAgentKind): Promise<void> =>
192197
assets
193198
.ensure(managedAgentAssetId(kind))
@@ -228,8 +233,12 @@ async function main(): Promise<void> {
228233
const version = assets.wantedVersionOf(id);
229234
return path && version ? { path, version } : undefined;
230235
});
231-
// Not awaited: CLI probes are slow; listeners must bind without waiting.
232-
const agentRuntimesReady = agentRuntimeProber.collect();
236+
// Not awaited: CLI probes are slow; listeners must bind without waiting. Filtered so a
237+
// restricted build never reports an excluded agent as available, however the probe actually
238+
// found it (CODE-618).
239+
const agentRuntimesReady = agentRuntimeProber
240+
.collect()
241+
.then((runtimes) => filterAgentRuntimes(runtimes, allowedAgents));
233242
const simSidecarPath = resolveSimSidecarPath();
234243
const simulators = simSidecarPath
235244
? new SimulatorService(new SimSidecarClient(simSidecarPath))
@@ -267,6 +276,7 @@ async function main(): Promise<void> {
267276
yield* Effect.addFinalizer(() => finalize(() => simulatorMcp.close()));
268277
}
269278
const EngineInfrastructureLive = makeEngineInfrastructureLayer(hub, {
279+
allowedAgents: allowedAgents ?? undefined,
270280
providerStore: store,
271281
ptyBackend: new SidecarPtyBackend(resolveSidecarPath()),
272282
simulators,
@@ -284,9 +294,14 @@ async function main(): Promise<void> {
284294
previewRoutes,
285295
browserToolsEnabled: process.env.LINKCODE_BROWSER_TOOLS === '1',
286296
agentRuntimesReady,
287-
assets,
297+
// The wire path for a client-initiated `asset.ensure`; the daemon's own boot refresh below
298+
// uses the unwrapped `assets` (it already filters its candidate kinds via `consentedAgents`).
299+
assets: restrictedAssetService(assets, allowedAgents),
288300
// Lets the engine refresh (and push) the runtime snapshot after a managed install lands.
289-
collectAgentRuntimes: () => agentRuntimeProber.collect(),
301+
collectAgentRuntimes: () =>
302+
agentRuntimeProber
303+
.collect()
304+
.then((runtimes) => filterAgentRuntimes(runtimes, allowedAgents)),
290305
// Spawn path for an interactive claude-code/codex login (managed/detected/SDK binary).
291306
resolveLoginBinary: (agent) =>
292307
agent === 'claude-code' || agent === 'codex'

‎apps/desktop/scripts/config-bundle.mts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
} from '../src/build/electron-builder-brand';
2121

2222
interface GeneratedConfigBundleBase {
23+
/** Agent/service allowlist snapshot (CODE-618), undefined when the brand declares neither. */
24+
readonly agentRestrictionsJson?: string;
2325
readonly bootstrapJson: string;
2426
readonly bundleText: string;
2527
}
@@ -107,6 +109,12 @@ export function loadGeneratedConfigBundle(
107109
'the generated bootstrap is immutable',
108110
);
109111
}
112+
if (env.MAIN_VITE_AGENT_RESTRICTIONS !== undefined) {
113+
throw new Error(
114+
'MAIN_VITE_AGENT_RESTRICTIONS must not be set when a generated config bundle exists; ' +
115+
'the generated restriction snapshot is immutable',
116+
);
117+
}
110118
const bundleText = readFileSync(bundlePath, 'utf8');
111119
const bundle = parseConfigBuildBundle(JSON.parse(bundleText));
112120
if (bundle.platform !== 'desktop') {
@@ -180,7 +188,17 @@ export function loadGeneratedConfigBundle(
180188
publicKeys: bundle.keyrings.normal,
181189
telemetryEndpoint: bundle.endpoints.telemetry,
182190
};
191+
// Absent on the bundle (the common case) omits the field entirely, so an unrestricted build's
192+
// vite.main.config.mts define step never inlines MAIN_VITE_AGENT_RESTRICTIONS.
193+
const agentRestrictionsJson =
194+
bundle.agents === undefined && bundle.services === undefined
195+
? undefined
196+
: JSON.stringify({
197+
...(bundle.agents !== undefined && { agents: bundle.agents }),
198+
...(bundle.services !== undefined && { services: bundle.services }),
199+
});
183200
const generatedBase = {
201+
...(agentRestrictionsJson !== undefined && { agentRestrictionsJson }),
184202
bootstrapJson: JSON.stringify(bootstrap),
185203
bundleText,
186204
};

0 commit comments

Comments
 (0)