-
Notifications
You must be signed in to change notification settings - Fork 189
fix: accept legacy ACP optionIds for backward compatibility #436
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
Changes from all commits
1955dd9
0bbf492
9bba513
8eb1847
416f9b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@moonshot-ai/acp-adapter": patch | ||
| "@moonshot-ai/kimi-code": patch | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The repo's changeset rules require source changes that affect a package's output to list that package, and to additionally list the CLI when an internal package change enters the CLI bundle. This commit changes Useful? React with 👍 / 👎. |
||
| --- | ||
|
|
||
| Fix ACP custom client tools being auto-rejected when using legacy Python ACP SDK optionId values (`approve`, `approve_for_session`) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,17 @@ export const APPROVE_ONCE_OPTION_ID = 'approve_once'; | |
| export const APPROVE_ALWAYS_OPTION_ID = 'approve_always'; | ||
| export const REJECT_OPTION_ID = 'reject'; | ||
|
|
||
| /** | ||
| * Legacy option ids sent by older ACP clients (e.g. Python ACP SDK 0.8.x). | ||
| * Mapped to the canonical ids so that clients built against the older SDK | ||
| * continue to work without modification. | ||
| */ | ||
| const LEGACY_OPTION_ID_MAP: Record<string, string> = { | ||
| approve: APPROVE_ONCE_OPTION_ID, | ||
| approve_for_session: APPROVE_ALWAYS_OPTION_ID, | ||
| reject: REJECT_OPTION_ID, | ||
| }; | ||
|
|
||
| /** | ||
| * Phase 13.2 plan_review optionId namespace. Picked deliberately so the | ||
| * `plan_*` prefix never collides with the canonical `approve_*` / | ||
|
|
@@ -151,10 +162,11 @@ export function permissionResponseToApprovalResponse( | |
| if (response.outcome.outcome === 'cancelled') { | ||
| return { decision: 'cancelled' }; | ||
| } | ||
| const optionId = response.outcome.optionId; | ||
| const rawOptionId = response.outcome.optionId; | ||
| if (req?.display.kind === 'plan_review') { | ||
| return mapPlanReviewOptionId(req.display, optionId); | ||
| return mapPlanReviewOptionId(req.display, rawOptionId); | ||
| } | ||
| const optionId = LEGACY_OPTION_ID_MAP[rawOptionId] ?? rawOptionId; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a legacy client returns Useful? React with 👍 / 👎. |
||
| switch (optionId) { | ||
| case APPROVE_ONCE_OPTION_ID: | ||
| return { decision: 'approved' }; | ||
|
|
@@ -310,7 +322,14 @@ export function attachSelectedLabel( | |
| ) { | ||
| return approval; | ||
| } | ||
| const matched = options.find((o) => o.optionId === outcome.optionId); | ||
| // Normalize legacy ids (Python ACP SDK 0.8.x sends `approve` / | ||
| // `approve_for_session` / `reject`) to their canonical equivalents | ||
| // before the lookup. Without this, legacy approvals are correctly | ||
| // routed by `permissionResponseToApprovalResponse` but drop the | ||
| // human-readable `selectedLabel` (e.g. "Approve for this session"), | ||
| // so PermissionResult hooks and approval records lose context. | ||
| const normalizedOptionId = LEGACY_OPTION_ID_MAP[outcome.optionId] ?? outcome.optionId; | ||
| const matched = options.find((o) => o.optionId === normalizedOptionId); | ||
| if (!matched) return approval; | ||
| return { ...approval, selectedLabel: matched.name }; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changeset selects
@moonshot-ai/acp-adapter, but that workspace is markedprivateinpackages/acp-adapter/package.jsonand the repository release guidance says not to add release changesets for private internal packages, only the publishable surface packages. Leaving this entry causes the release PR to version/report an internal adapter package instead of only bumping the user-visible package affected by the fix.Useful? React with 👍 / 👎.