Commit ceec900
committed
fix(acpx-provider): surface stopReason as typed error codes
Read acpx's terminal JSON-RPC result envelope
(`{id, result: {stopReason, ...}}`) inside `extractAcpxJson` and map
non-`end_turn` reasons to typed `ClawpatchError` codes:
cancelled -> agent-cancelled (exit 6)
refusal -> agent-refused (exit 7)
max_tokens -> agent-truncated (exit 8)
max_turns_exceeded -> agent-truncated (exit 8)
unknown reason -> agent-cancelled (exit 8) defensively
Previously, prompts that ended in `cancelled` / `refusal` / `max_tokens`
emitted no `agent_message_chunk`, so they fell into the same
`code: "malformed-output"` bucket as a real envelope-shape regression
(see 20260517T184420-d52a72: four parser errors of three different
shapes, all opaque `malformed-output`). On-call had to read raw NDJSON
to triage.
Now `malformed-output` keeps its narrow meaning: clawpatch could not
parse a payload acpx claims is `end_turn`. The `end_turn`-with-no-chunks
path also gets a clearer diagnostic noting the parser bug vs envelope
break.
Verified live against acpx 0.8.0 + claude-agent-acp 0.31.4. Terminal
envelope shape:
{"jsonrpc":"2.0","id":2,"result":{"stopReason":"end_turn","usage":{...}}}
`ACPX_TESTED_VERSIONS` stays at `^0.8.0`; the stopReason envelope is
present in this version.1 parent 398b752 commit ceec900
3 files changed
Lines changed: 152 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
63 | 87 | | |
64 | 88 | | |
65 | 89 | | |
| |||
398 | 422 | | |
399 | 423 | | |
400 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
401 | 490 | | |
402 | 491 | | |
403 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
787 | 810 | | |
788 | 811 | | |
789 | 812 | | |
790 | 813 | | |
791 | 814 | | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
792 | 821 | | |
793 | 822 | | |
794 | 823 | | |
795 | 824 | | |
796 | 825 | | |
797 | 826 | | |
798 | 827 | | |
| 828 | + | |
| 829 | + | |
799 | 830 | | |
800 | 831 | | |
801 | 832 | | |
| |||
809 | 840 | | |
810 | 841 | | |
811 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
812 | 854 | | |
813 | 855 | | |
814 | 856 | | |
| |||
833 | 875 | | |
834 | 876 | | |
835 | 877 | | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
836 | 891 | | |
837 | 892 | | |
838 | 893 | | |
839 | 894 | | |
840 | 895 | | |
841 | 896 | | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
842 | 902 | | |
843 | | - | |
844 | | - | |
| 903 | + | |
| 904 | + | |
845 | 905 | | |
846 | 906 | | |
847 | 907 | | |
| |||
0 commit comments