-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(cli): fail headless subagent permission asks instead of hanging #11923
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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@kilocode/cli": patch | ||
| --- | ||
|
|
||
| Fail subagent permission prompts in headless `kilo run` immediately instead of hanging forever, and approve subagent permission prompts under `--dangerously-skip-permissions` |
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,45 @@ | ||
| import { Database, eq } from "@/storage/db" | ||
| import { SessionTable } from "@/session/session.sql" | ||
| import type { SessionID } from "@/session/schema" | ||
|
|
||
| /** | ||
| * Headless roots (#11903). | ||
| * | ||
| * Root sessions driven by a client that cannot answer subagent permission | ||
| * prompts (plain `kilo run`). Permission asks originating from their child | ||
| * sessions must fail with DeniedError instead of blocking forever on a reply | ||
| * that never comes. Interactive clients (TUI, extension) never mark sessions | ||
| * here, so their subagent prompts stay answerable. | ||
| */ | ||
| export namespace KiloHeadless { | ||
| const roots = new Set<string>() | ||
|
|
||
| export function mark(id: string) { | ||
| roots.add(id) | ||
| } | ||
|
|
||
| export function clear(id: string) { | ||
| roots.delete(id) | ||
| } | ||
|
|
||
| /** True when `id` is a subagent session whose root run has no attached human. */ | ||
| export function denies(id: string): boolean { | ||
| if (roots.size === 0) return false | ||
| if (roots.has(id)) return false | ||
| for (let parent = lookup(id); parent; parent = lookup(parent)) { | ||
| if (roots.has(parent)) return true | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| function lookup(id: string) { | ||
| const row = Database.use((db) => | ||
| db | ||
| .select({ parent: SessionTable.parent_id }) | ||
| .from(SessionTable) | ||
| .where(eq(SessionTable.id, id as SessionID)) | ||
| .get(), | ||
| ) | ||
| return row?.parent ?? undefined | ||
| } | ||
| } |
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.
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.