-
Notifications
You must be signed in to change notification settings - Fork 10
feat(client): consume brand identity agents/services allowlists #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
db03912
feat(schema): accept optional agents/services on the config build bundle
lucas77778 dfd090d
feat(desktop): render and surface the build-time agent/service allowlist
lucas77778 28eb599
feat(daemon): gate new agent adapters by the restricted-brand allowlist
lucas77778 46648dd
feat(desktop): exclude restricted agents' SDKs from packaged builds
lucas77778 bd62ef1
feat(mobile): thread the build-time agent allowlist into the config b…
lucas77778 ccac9af
feat(workbench,ui): filter the harness picker and add-account catalog…
lucas77778 8d577b9
fix(engine,daemon): fix CI ESM load, history-read regression, and rev…
lucas77778 068c291
fix(desktop): import agent-package-excludes with an explicit extension
lucas77778 5671d2a
fix(engine,daemon): close review gaps in the restricted-brand allowlist
lucas77778 baa0f7b
merge(client): resolve master conflicts for brand restrictions
lucas77778 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { restrictedAdapterFactory } from '../agent-factory'; | ||
|
|
||
| describe('restrictedAdapterFactory', () => { | ||
| it('returns undefined when unrestricted, so the engine falls back to the bare createAdapter', () => { | ||
| expect(restrictedAdapterFactory(null)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('constructs an allowed kind', () => { | ||
| const factory = restrictedAdapterFactory(['pi']); | ||
| expect(factory).toBeDefined(); | ||
| expect(factory?.('pi').kind).toBe('pi'); | ||
| }); | ||
|
|
||
| it('rejects a kind outside the allowlist', () => { | ||
| const factory = restrictedAdapterFactory(['pi']); | ||
| expect(() => factory?.('codex')).toThrow('codex'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { AdapterFactory } from '@linkcode/agent-adapter'; | ||
| import { createAdapter } from '@linkcode/agent-adapter'; | ||
| import type { AgentKind } from '@linkcode/schema'; | ||
|
|
||
| /** | ||
| * Restricted-brand adapter gate (CODE-618): wraps `createAdapter` to reject any kind outside the | ||
| * allowlist. Only guards new adapter construction — a session started before a restriction landed | ||
| * keeps running on its existing adapter instance, and history reads never call this at all. | ||
| * `null` (unrestricted, the default build) returns `undefined` so the engine falls back to the | ||
| * bare `createAdapter`, an exact no-op. | ||
| */ | ||
| export function restrictedAdapterFactory( | ||
| allowedAgents: readonly AgentKind[] | null, | ||
| ): AdapterFactory | undefined { | ||
| if (allowedAgents === null) return undefined; | ||
| return (kind) => { | ||
| if (!allowedAgents.includes(kind)) { | ||
| throw new Error(`agent kind ${kind} is not available in this build`); | ||
| } | ||
| return createAdapter(kind); | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
apps/desktop/src/build/__tests__/agent-package-excludes.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { agentFilesExcludes } from '../agent-package-excludes'; | ||
|
|
||
| describe('agentFilesExcludes', () => { | ||
| it('is an exact no-op when unrestricted', () => { | ||
| expect(agentFilesExcludes(null)).toEqual([]); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ['pi', ['!node_modules/@anthropic-ai/claude-agent-sdk/**', '!node_modules/@openai/codex/**', '!node_modules/@opencode-ai/sdk/**']], | ||
| ['grok-build', ['!node_modules/@anthropic-ai/claude-agent-sdk/**', '!node_modules/@openai/codex/**', '!node_modules/@opencode-ai/sdk/**']], | ||
| ['claude-code', ['!node_modules/@openai/codex/**', '!node_modules/@opencode-ai/sdk/**']], | ||
| ['codex', ['!node_modules/@anthropic-ai/claude-agent-sdk/**', '!node_modules/@opencode-ai/sdk/**']], | ||
| ['opencode', ['!node_modules/@anthropic-ai/claude-agent-sdk/**', '!node_modules/@openai/codex/**']], | ||
| ] as const)('excludes every SDK except the ones the sole allowed kind %s needs', (kind, expected) => { | ||
| expect(agentFilesExcludes([kind])).toEqual(expected); | ||
| }); | ||
|
|
||
| it('excludes nothing when every SDK-carrying kind is allowed', () => { | ||
| expect(agentFilesExcludes(['claude-code', 'codex', 'opencode'])).toEqual([]); | ||
| }); | ||
|
|
||
| it('never excludes pi or grok-build (neither carries a staged SDK package)', () => { | ||
| const excludes = agentFilesExcludes(['pi']); | ||
| expect(excludes).toHaveLength(3); | ||
| expect(excludes.join(' ')).not.toMatch(/grok|[/@]pi[/@-]/); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.