-
Notifications
You must be signed in to change notification settings - Fork 197
feat: agent swarm #424
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
Open
kermanx
wants to merge
79
commits into
main
Choose a base branch
from
xtr/agent-swarm-progress-ui
base: main
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.
Open
feat: agent swarm #424
Changes from 65 commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
27dded5
feat: add agent swarm tui support
kermanx d711cf0
fix: redraw agent swarm progress updates
kermanx 45a74b1
fix: refine agent swarm progress rendering
kermanx 1cd720a
upd
kermanx 6f89819
fix
kermanx 9e58f5c
update
kermanx d3f92ef
fix
kermanx 8bc6b5f
update
kermanx 329238b
upd
kermanx 0c7d35f
Merge remote-tracking branch 'origin/main' into xtr/agent-swarm-progr…
kermanx 9db2cd2
fix
kermanx 4d76bf0
update
kermanx c1b5ba7
Merge remote-tracking branch 'origin/main' into xtr/agent-swarm-progr…
kermanx 4797e90
fix
kermanx 0a93675
fix
kermanx c0bfa73
fix: emit suspended subagent events
kermanx 5729fbc
fix: show suspended swarm progress
kermanx 42ff90b
fix: normalize suspended swarm status
kermanx a116227
fix
kermanx 68ec665
fix
kermanx f5841ae
fix
kermanx ce6a471
Merge remote-tracking branch 'origin/main' into xtr/agent-swarm-progr…
kermanx 99adec6
fix
kermanx b418a04
fix
kermanx 765f108
fix
kermanx 75e00b8
update
kermanx b922dbe
Merge remote-tracking branch 'origin/main' into xtr/agent-swarm-progr…
kermanx 108f635
fix
kermanx 263c968
fix
kermanx 206183e
fix
kermanx 65454eb
fix
kermanx ef7521a
fix
kermanx a952c70
Merge remote-tracking branch 'origin/main' into xtr/agent-swarm-progr…
kermanx 96a081a
fix
kermanx ef4a584
fix
kermanx 95936ff
Merge remote-tracking branch 'origin/main' into xtr/agent-swarm-progr…
kermanx 61c3a03
fix
kermanx 7122b52
fix
kermanx e175ddf
swarmItem
kermanx 71d85df
fix
kermanx 43c708f
fix: restore export markdown internal filtering
kermanx fe4aa16
upd
kermanx dbc99be
Merge remote-tracking branch 'origin/main' into xtr/agent-swarm-progr…
kermanx 2c471c8
fix
kermanx e7a07aa
wip
kermanx d72e279
wip
kermanx 82d3831
remove swarm demo
kermanx 615256d
fix
kermanx bc82e59
wip
kermanx 2f965c0
wip
kermanx 3e79efa
wip
kermanx 0991872
wip
kermanx fa64e52
upd
kermanx a0cd20c
wip
kermanx e8f24eb
fix
kermanx 896dfde
update
kermanx d529b75
fix
kermanx 5cf861b
fix
kermanx dc029d5
fix
kermanx 6e87a7b
update
kermanx 536d27c
fix
kermanx f52f253
fix
kermanx 29de45b
fix exit
kermanx 06d452f
fix
kermanx b9dc203
fix
kermanx 4a2eede
timeout
kermanx 42b1fb9
fix
kermanx 548ada8
fix
kermanx 0d50b54
refactor merge panels
kermanx 7c9e5dd
fix
kermanx 1dc2a84
fix
kermanx c5b416c
chore: update agent swarm changeset
kermanx 67b8d35
update
kermanx 4a64533
update
kermanx 0da717c
fix
kermanx 5c22fa9
fix
kermanx a42e6a7
fix
kermanx b380ceb
ok
kermanx 31fa83d
gated under flag
kermanx 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
Some comments aren't visible on the classic Files Changed page.
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,7 @@ | ||
| --- | ||
| "@moonshot-ai/agent-core": minor | ||
| "@moonshot-ai/kimi-code-sdk": minor | ||
| "@moonshot-ai/kimi-code": minor | ||
| --- | ||
|
|
||
| Add template-based AgentSwarm launches with live TUI progress. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| import type { PermissionMode } from '@moonshot-ai/kimi-code-sdk'; | ||
|
|
||
| import { | ||
| SwarmStartPermissionPromptComponent, | ||
| type SwarmStartPermissionChoice, | ||
| } from '../components/dialogs/swarm-start-permission-prompt'; | ||
| import { SwarmModeMarkerComponent } from '../components/messages/swarm-markers'; | ||
| import { LLM_NOT_SET_MESSAGE, NO_ACTIVE_SESSION_MESSAGE } from '../constant/kimi-tui'; | ||
| import { formatErrorMessage } from '../utils/event-payload'; | ||
| import type { SlashCommandHost } from './dispatch'; | ||
|
|
||
| export async function handleSwarmCommand(host: SlashCommandHost, args: string): Promise<void> { | ||
| if (host.session === undefined) { | ||
| host.showError(NO_ACTIVE_SESSION_MESSAGE); | ||
| return; | ||
| } | ||
|
|
||
| const prompt = args.trim(); | ||
| const mode = swarmModeSubcommand(prompt); | ||
| if (mode !== undefined) { | ||
| await applySwarmMode(host, mode); | ||
| return; | ||
| } | ||
|
|
||
| if (prompt.length === 0) { | ||
| await applySwarmMode(host, !host.state.appState.swarmMode); | ||
| return; | ||
| } | ||
|
|
||
| if (host.state.appState.model.trim().length === 0) { | ||
| host.showError(LLM_NOT_SET_MESSAGE); | ||
| return; | ||
| } | ||
|
|
||
| if (host.state.appState.permissionMode === 'manual') { | ||
| if (!(await activateSwarmForTask(host))) return; | ||
| showSwarmStartPermissionPrompt(host, prompt); | ||
|
kermanx marked this conversation as resolved.
Outdated
|
||
| return; | ||
| } | ||
|
|
||
| await startSwarmTask(host, prompt); | ||
| } | ||
|
|
||
| function showSwarmStartPermissionPrompt(host: SlashCommandHost, prompt: string): void { | ||
| const commandText = `/swarm ${prompt}`; | ||
| const cancelStart = (): void => { | ||
| host.restoreInputText(commandText); | ||
| host.showStatus('Swarm task not started.'); | ||
| }; | ||
| host.mountEditorReplacement( | ||
| new SwarmStartPermissionPromptComponent({ | ||
| colors: host.state.theme.colors, | ||
| onSelect: (choice) => { | ||
| if (choice === 'cancel') { | ||
| cancelStart(); | ||
| return; | ||
| } | ||
| host.restoreEditor(); | ||
| void startSwarmWithPermission(host, prompt, choice); | ||
| }, | ||
| onCancel: cancelStart, | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| async function startSwarmWithPermission( | ||
| host: SlashCommandHost, | ||
| prompt: string, | ||
| choice: SwarmStartPermissionChoice, | ||
| ): Promise<void> { | ||
| if (choice === 'auto' || choice === 'yolo') { | ||
| if (!(await setPermissionForSwarm(host, choice))) return; | ||
| } | ||
| host.sendNormalUserInput(prompt); | ||
| } | ||
|
|
||
| async function setPermissionForSwarm(host: SlashCommandHost, mode: PermissionMode): Promise<boolean> { | ||
| try { | ||
| await host.requireSession().setPermission(mode); | ||
| } catch (error) { | ||
| host.showError(`Failed to set permission mode: ${formatErrorMessage(error)}`); | ||
| return false; | ||
| } | ||
| host.setAppState({ permissionMode: mode }); | ||
| return true; | ||
| } | ||
|
|
||
| async function startSwarmTask(host: SlashCommandHost, prompt: string): Promise<void> { | ||
| if (!(await activateSwarmForTask(host))) return; | ||
| host.sendNormalUserInput(prompt); | ||
| } | ||
|
|
||
| async function activateSwarmForTask(host: SlashCommandHost): Promise<boolean> { | ||
| if (!host.state.appState.swarmMode && !(await setSwarmMode(host, true, 'task'))) { | ||
| return false; | ||
| } | ||
| renderSwarmModeMarker(host, true); | ||
| return true; | ||
| } | ||
|
|
||
| async function applySwarmMode(host: SlashCommandHost, enabled: boolean): Promise<void> { | ||
| if (enabled && host.state.appState.swarmMode) { | ||
| host.showStatus('Swarm mode is already on.'); | ||
| return; | ||
| } | ||
| if (!enabled && !host.state.appState.swarmMode) { | ||
| host.showStatus('Swarm mode is already off.'); | ||
| return; | ||
| } | ||
| if (!(await setSwarmMode(host, enabled, 'manual'))) return; | ||
| renderSwarmModeMarker(host, enabled); | ||
| } | ||
|
|
||
| async function setSwarmMode( | ||
| host: SlashCommandHost, | ||
| enabled: boolean, | ||
| trigger: 'manual' | 'task', | ||
| ): Promise<boolean> { | ||
| try { | ||
| await host.requireSession().setSwarmMode(enabled, trigger); | ||
| } catch (error) { | ||
| host.showError( | ||
| `Failed to ${enabled ? 'enable' : 'disable'} swarm mode: ${formatErrorMessage(error)}`, | ||
| ); | ||
| return false; | ||
| } | ||
| host.setAppState({ swarmMode: enabled }); | ||
| return true; | ||
| } | ||
|
|
||
| function swarmModeSubcommand(input: string): boolean | undefined { | ||
| const command = input.toLowerCase(); | ||
| if (command === 'on') return true; | ||
| if (command === 'off') return false; | ||
| return undefined; | ||
| } | ||
|
|
||
| function renderSwarmModeMarker(host: SlashCommandHost, active: boolean): void { | ||
| host.state.transcriptContainer.addChild( | ||
| new SwarmModeMarkerComponent(active, host.state.theme.colors), | ||
| ); | ||
| host.state.ui.requestRender(); | ||
| } | ||
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
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.