-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(agent): allow variable tool permission modes #7538
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
Draft
j15z
wants to merge
1
commit into
codex/fix-api-tool-canonical-remapping
Choose a base branch
from
codex/agent-tool-permission-mode
base: codex/fix-api-tool-canonical-remapping
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,134
−108
Draft
Changes from all commits
Commits
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
115 changes: 115 additions & 0 deletions
115
...ents/editor/components/sub-block/components/tool-input/components/tools/usage-control.tsx
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,115 @@ | ||
| import { Button, ChipCombobox, cn, Label, Tooltip } from '@sim/emcn' | ||
| import { ArrowLeftRight } from '@sim/emcn/icons' | ||
| import type { CanonicalMode } from '@/lib/workflows/subblocks/visibility' | ||
| import type { StoredTool } from '@/lib/workflows/tool-input/types' | ||
| import { ShortInput } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/short-input' | ||
|
|
||
| interface ToolUsageControlProps { | ||
| blockId: string | ||
| aggregateSubBlockId: string | ||
| toolIndex: number | ||
| tool: StoredTool | ||
| mode: CanonicalMode | ||
| supportsForce: boolean | ||
| disabled: boolean | ||
| onFixedChange: (value: NonNullable<StoredTool['usageControl']>) => void | ||
| onExpressionChange: (value: string) => void | ||
| onModeToggle: () => void | ||
| } | ||
|
|
||
| const MODE_OPTIONS = [ | ||
| { | ||
| value: 'auto', | ||
| label: 'Auto', | ||
| suffixElement: <span className='text-[var(--text-tertiary)]'>(model decides)</span>, | ||
| }, | ||
| { | ||
| value: 'force', | ||
| label: 'Force', | ||
| suffixElement: <span className='text-[var(--text-tertiary)]'>(always use)</span>, | ||
| }, | ||
| { | ||
| value: 'none', | ||
| label: 'None', | ||
| suffixElement: <span className='text-[var(--text-tertiary)]'>(disable tool)</span>, | ||
| }, | ||
| ] as const | ||
|
|
||
| export function ToolUsageControl({ | ||
| blockId, | ||
| aggregateSubBlockId, | ||
| toolIndex, | ||
| tool, | ||
| mode, | ||
| supportsForce, | ||
| disabled, | ||
| onFixedChange, | ||
| onExpressionChange, | ||
| onModeToggle, | ||
| }: ToolUsageControlProps) { | ||
| const toggleLabel = mode === 'advanced' ? 'Switch to selector' : 'Switch to variable' | ||
|
|
||
| return ( | ||
| <div className='subblock-content flex w-full min-w-0 flex-col gap-2.5'> | ||
| <div className='flex items-center justify-between gap-1.5 pl-0.5'> | ||
| <Label>Permission Mode</Label> | ||
| <Tooltip.Root> | ||
| <Tooltip.Trigger asChild> | ||
| <Button | ||
| type='button' | ||
| variant='ghost' | ||
| size='icon' | ||
| className='shrink-0' | ||
| onClick={onModeToggle} | ||
| disabled={disabled} | ||
| aria-label={toggleLabel} | ||
| > | ||
| <ArrowLeftRight | ||
| className={cn( | ||
| 'size-[12px]!', | ||
| mode === 'advanced' | ||
| ? 'text-[var(--text-primary)]' | ||
| : 'text-[var(--text-secondary)]' | ||
| )} | ||
|
j15z marked this conversation as resolved.
|
||
| /> | ||
| </Button> | ||
| </Tooltip.Trigger> | ||
| <Tooltip.Content side='top'>{toggleLabel}</Tooltip.Content> | ||
| </Tooltip.Root> | ||
| </div> | ||
| {mode === 'advanced' ? ( | ||
| <ShortInput | ||
| blockId={blockId} | ||
| subBlockId={aggregateSubBlockId} | ||
| config={{ | ||
| id: 'usageControlExpression', | ||
| title: 'Permission Mode', | ||
| type: 'short-input', | ||
| }} | ||
| value={tool.usageControlExpression ?? ''} | ||
| onChange={onExpressionChange} | ||
| placeholder='"auto", "force", or "none"' | ||
| disabled={disabled} | ||
| workflowSearchValuePath={[toolIndex, 'usageControlExpression']} | ||
| /> | ||
| ) : ( | ||
| <ChipCombobox | ||
| options={MODE_OPTIONS.map((option) => ({ | ||
| ...option, | ||
| disabled: option.value === 'force' && !supportsForce, | ||
| suffixElement: | ||
| option.value === 'force' && !supportsForce ? ( | ||
| <span className='text-[var(--text-tertiary)]'>(not supported by model)</span> | ||
| ) : ( | ||
| option.suffixElement | ||
| ), | ||
| onSelect: () => onFixedChange(option.value), | ||
| }))} | ||
| value={tool.usageControl ?? 'auto'} | ||
| disabled={disabled} | ||
| aria-label='Permission Mode' | ||
| /> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
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.