workbuddy2api 2.0.5__tar.gz → 2.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/PKG-INFO +60 -1
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/README.md +59 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/pyproject.toml +1 -1
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/__main__.py +612 -395
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/anthropic_adapter.py +5 -0
- workbuddy2api-2.0.7/src/codebuddy_proxy/billing_proxy.py +99 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/codebuddy_client_demo.py +33 -0
- workbuddy2api-2.0.7/src/codebuddy_proxy/process_diagnostics.py +445 -0
- workbuddy2api-2.0.7/src/codebuddy_proxy/protocol_response.py +132 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/responses_adapter.py +25 -3
- workbuddy2api-2.0.7/src/codebuddy_proxy/role_compat.py +49 -0
- workbuddy2api-2.0.7/src/codebuddy_proxy/tool_pairing.py +136 -0
- workbuddy2api-2.0.7/src/codebuddy_proxy/upstream_request.py +147 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/workbuddy2api.egg-info/PKG-INFO +60 -1
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/workbuddy2api.egg-info/SOURCES.txt +6 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/LICENSE +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/setup.cfg +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/backend_profile.py +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/desensitize.py +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/dsml_parser.py +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/models_config.domestic.json +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/models_config.global.json +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/projection_metadata.py +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/codebuddy_proxy/responses_projection.py +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/workbuddy2api.egg-info/dependency_links.txt +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/workbuddy2api.egg-info/entry_points.txt +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/workbuddy2api.egg-info/requires.txt +0 -0
- {workbuddy2api-2.0.5 → workbuddy2api-2.0.7}/src/workbuddy2api.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: workbuddy2api
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.7
|
|
4
4
|
Summary: Local OpenAI/Responses/Anthropic compatible proxy for CodeBuddy
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -19,6 +19,8 @@ Dynamic: license-file
|
|
|
19
19
|
|
|
20
20
|
> **中文版文档见 [README_zh.md](README_zh.md).**
|
|
21
21
|
|
|
22
|
+
For unexplained Windows process exits, use the [independent process monitor](docs/external-process-monitor.md) to collect uv/Python exit codes, lifecycle, memory, health, and available Windows events without restarting the proxy.
|
|
23
|
+
|
|
22
24
|
## ✨ Core Features
|
|
23
25
|
|
|
24
26
|
- **Protocol conversion** - Supports three standard formats: OpenAI Chat Completions, Anthropic Messages API, and Responses
|
|
@@ -140,6 +142,21 @@ Endpoint precedence is: explicit `--endpoint` > the `--global` profile default
|
|
|
140
142
|
Therefore `--global` without `--endpoint` cannot be redirected to the domestic
|
|
141
143
|
host by `CODEBUDDY_ENDPOINT`.
|
|
142
144
|
|
|
145
|
+
### Domestic gateway: developer-role compatibility
|
|
146
|
+
|
|
147
|
+
The domestic default upstream (`https://copilot.tencent.com`) may reject
|
|
148
|
+
Chat Completions requests containing a `developer` message with HTTP 400 /
|
|
149
|
+
code 11128. Before forwarding to **that upstream only**, the proxy maps
|
|
150
|
+
`developer` to `system` without changing message order, content, tool-call
|
|
151
|
+
history, or the original client request. If enabled, `--desensitize` runs
|
|
152
|
+
after this role adaptation. No client-side configuration is needed.
|
|
153
|
+
|
|
154
|
+
This compatibility mapping does not apply to the international backend or
|
|
155
|
+
custom endpoints. Because the legacy upstream does not represent the separate
|
|
156
|
+
`system` and `developer` instruction priorities, it is an approximation,
|
|
157
|
+
not exact semantic equivalence. The `upstream_role_compat` log event reports
|
|
158
|
+
only the number of mapped messages, not prompt contents.
|
|
159
|
+
|
|
143
160
|
Runtime model catalogs are loaded from the packaged profile resources
|
|
144
161
|
`src/codebuddy_proxy/models_config.domestic.json` and
|
|
145
162
|
`src/codebuddy_proxy/models_config.global.json`. The root
|
|
@@ -704,6 +721,16 @@ Example output:
|
|
|
704
721
|
|
|
705
722
|
---
|
|
706
723
|
|
|
724
|
+
### Process diagnostics (2.0.7)
|
|
725
|
+
|
|
726
|
+
In addition to the existing business logs, `console.log` mirrors Python stdout/stderr
|
|
727
|
+
(including Uvicorn errors and tracebacks), `process-events.jsonl` records process
|
|
728
|
+
startup, exit codes, signals and unhandled exceptions, and `crash.log` captures
|
|
729
|
+
Python fatal fault stacks. These files are written alongside `--log-file`.
|
|
730
|
+
The console and process-event files rotate by size; see
|
|
731
|
+
[process diagnostics](docs/process-diagnostics-2.0.7.md) for details.
|
|
732
|
+
**Console logs may contain sensitive data: review before sharing.**
|
|
733
|
+
|
|
707
734
|
### Logging
|
|
708
735
|
|
|
709
736
|
Logs include:
|
|
@@ -712,6 +739,20 @@ Logs include:
|
|
|
712
739
|
|
|
713
740
|
Each JSONL record contains `app_version`, `system_version`, `python_version`, and `machine` fields; a `startup` event is also recorded at launch.
|
|
714
741
|
|
|
742
|
+
Upstream connection errors/timeouts are retried at most twice (0.5s / 1s backoff,
|
|
743
|
+
three attempts total). HTTP errors and read/write failures are not retried;
|
|
744
|
+
once response headers arrive, the request is never replayed. Each attempt keeps
|
|
745
|
+
the existing 30s connection timeout, so a persistent outage can take up to about
|
|
746
|
+
91.5s before the final error. This applies to streaming and aggregated responses.
|
|
747
|
+
|
|
748
|
+
`upstream_connect_retry` / `upstream_connect_failed` record the attempt number,
|
|
749
|
+
target host/port, and bounded `exception_chain` with exception types and native
|
|
750
|
+
`errno` / `winerror` values when available. `request_id` links these to stream
|
|
751
|
+
start, error, and terminal records. `stream_completed` is reserved for streams
|
|
752
|
+
that received upstream `[DONE]` and finished forwarding; other terminal events
|
|
753
|
+
are `stream_failed`, `stream_incomplete` (EOF/guard limit without `[DONE]`), and
|
|
754
|
+
`stream_cancelled`. `status: null` means no upstream HTTP response was received.
|
|
755
|
+
|
|
715
756
|
You can also specify an absolute path for the log file:
|
|
716
757
|
|
|
717
758
|
```bash
|
|
@@ -797,6 +838,24 @@ uv run --with workbuddy2api python -m codebuddy_proxy --desensitize --optimize-c
|
|
|
797
838
|
--log-file "$HOME/.workbuddy2api/codebuddy-proxy.jsonl"
|
|
798
839
|
```
|
|
799
840
|
|
|
841
|
+
### Upstream error 11148 "tool calls and tool results do not match"
|
|
842
|
+
|
|
843
|
+
Some agent clients produce nonconforming Anthropic / Responses tool histories.
|
|
844
|
+
The CodeBuddy backend requires Chat tool results to directly follow the
|
|
845
|
+
declaring assistant `tool_calls`. The proxy now repairs recoverable converted
|
|
846
|
+
histories in `/v1/messages` and `/v1/responses`: interleaved non-tool messages
|
|
847
|
+
are deferred, and orphan or identical duplicate results are dropped with
|
|
848
|
+
diagnostic warnings (no tool output is logged).
|
|
849
|
+
|
|
850
|
+
Ambiguous histories are **not silently truncated**. If a call has no result, a
|
|
851
|
+
tool-call ID is reused, or duplicate results disagree, the proxy returns HTTP
|
|
852
|
+
**422**, with `detail.code=invalid_tool_history` and a specific `reason`.
|
|
853
|
+
No request is sent upstream in that case. Verify the side effects of any
|
|
854
|
+
unfinished tools before retrying or starting a fresh conversation.
|
|
855
|
+
|
|
856
|
+
This repair does not apply to direct `/v1/chat/completions` requests and cannot
|
|
857
|
+
guarantee the absence of unrelated upstream 11148 errors.
|
|
858
|
+
|
|
800
859
|
### Port already in use
|
|
801
860
|
|
|
802
861
|
```bash
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
> **中文版文档见 [README_zh.md](README_zh.md).**
|
|
6
6
|
|
|
7
|
+
For unexplained Windows process exits, use the [independent process monitor](docs/external-process-monitor.md) to collect uv/Python exit codes, lifecycle, memory, health, and available Windows events without restarting the proxy.
|
|
8
|
+
|
|
7
9
|
## ✨ Core Features
|
|
8
10
|
|
|
9
11
|
- **Protocol conversion** - Supports three standard formats: OpenAI Chat Completions, Anthropic Messages API, and Responses
|
|
@@ -125,6 +127,21 @@ Endpoint precedence is: explicit `--endpoint` > the `--global` profile default
|
|
|
125
127
|
Therefore `--global` without `--endpoint` cannot be redirected to the domestic
|
|
126
128
|
host by `CODEBUDDY_ENDPOINT`.
|
|
127
129
|
|
|
130
|
+
### Domestic gateway: developer-role compatibility
|
|
131
|
+
|
|
132
|
+
The domestic default upstream (`https://copilot.tencent.com`) may reject
|
|
133
|
+
Chat Completions requests containing a `developer` message with HTTP 400 /
|
|
134
|
+
code 11128. Before forwarding to **that upstream only**, the proxy maps
|
|
135
|
+
`developer` to `system` without changing message order, content, tool-call
|
|
136
|
+
history, or the original client request. If enabled, `--desensitize` runs
|
|
137
|
+
after this role adaptation. No client-side configuration is needed.
|
|
138
|
+
|
|
139
|
+
This compatibility mapping does not apply to the international backend or
|
|
140
|
+
custom endpoints. Because the legacy upstream does not represent the separate
|
|
141
|
+
`system` and `developer` instruction priorities, it is an approximation,
|
|
142
|
+
not exact semantic equivalence. The `upstream_role_compat` log event reports
|
|
143
|
+
only the number of mapped messages, not prompt contents.
|
|
144
|
+
|
|
128
145
|
Runtime model catalogs are loaded from the packaged profile resources
|
|
129
146
|
`src/codebuddy_proxy/models_config.domestic.json` and
|
|
130
147
|
`src/codebuddy_proxy/models_config.global.json`. The root
|
|
@@ -689,6 +706,16 @@ Example output:
|
|
|
689
706
|
|
|
690
707
|
---
|
|
691
708
|
|
|
709
|
+
### Process diagnostics (2.0.7)
|
|
710
|
+
|
|
711
|
+
In addition to the existing business logs, `console.log` mirrors Python stdout/stderr
|
|
712
|
+
(including Uvicorn errors and tracebacks), `process-events.jsonl` records process
|
|
713
|
+
startup, exit codes, signals and unhandled exceptions, and `crash.log` captures
|
|
714
|
+
Python fatal fault stacks. These files are written alongside `--log-file`.
|
|
715
|
+
The console and process-event files rotate by size; see
|
|
716
|
+
[process diagnostics](docs/process-diagnostics-2.0.7.md) for details.
|
|
717
|
+
**Console logs may contain sensitive data: review before sharing.**
|
|
718
|
+
|
|
692
719
|
### Logging
|
|
693
720
|
|
|
694
721
|
Logs include:
|
|
@@ -697,6 +724,20 @@ Logs include:
|
|
|
697
724
|
|
|
698
725
|
Each JSONL record contains `app_version`, `system_version`, `python_version`, and `machine` fields; a `startup` event is also recorded at launch.
|
|
699
726
|
|
|
727
|
+
Upstream connection errors/timeouts are retried at most twice (0.5s / 1s backoff,
|
|
728
|
+
three attempts total). HTTP errors and read/write failures are not retried;
|
|
729
|
+
once response headers arrive, the request is never replayed. Each attempt keeps
|
|
730
|
+
the existing 30s connection timeout, so a persistent outage can take up to about
|
|
731
|
+
91.5s before the final error. This applies to streaming and aggregated responses.
|
|
732
|
+
|
|
733
|
+
`upstream_connect_retry` / `upstream_connect_failed` record the attempt number,
|
|
734
|
+
target host/port, and bounded `exception_chain` with exception types and native
|
|
735
|
+
`errno` / `winerror` values when available. `request_id` links these to stream
|
|
736
|
+
start, error, and terminal records. `stream_completed` is reserved for streams
|
|
737
|
+
that received upstream `[DONE]` and finished forwarding; other terminal events
|
|
738
|
+
are `stream_failed`, `stream_incomplete` (EOF/guard limit without `[DONE]`), and
|
|
739
|
+
`stream_cancelled`. `status: null` means no upstream HTTP response was received.
|
|
740
|
+
|
|
700
741
|
You can also specify an absolute path for the log file:
|
|
701
742
|
|
|
702
743
|
```bash
|
|
@@ -782,6 +823,24 @@ uv run --with workbuddy2api python -m codebuddy_proxy --desensitize --optimize-c
|
|
|
782
823
|
--log-file "$HOME/.workbuddy2api/codebuddy-proxy.jsonl"
|
|
783
824
|
```
|
|
784
825
|
|
|
826
|
+
### Upstream error 11148 "tool calls and tool results do not match"
|
|
827
|
+
|
|
828
|
+
Some agent clients produce nonconforming Anthropic / Responses tool histories.
|
|
829
|
+
The CodeBuddy backend requires Chat tool results to directly follow the
|
|
830
|
+
declaring assistant `tool_calls`. The proxy now repairs recoverable converted
|
|
831
|
+
histories in `/v1/messages` and `/v1/responses`: interleaved non-tool messages
|
|
832
|
+
are deferred, and orphan or identical duplicate results are dropped with
|
|
833
|
+
diagnostic warnings (no tool output is logged).
|
|
834
|
+
|
|
835
|
+
Ambiguous histories are **not silently truncated**. If a call has no result, a
|
|
836
|
+
tool-call ID is reused, or duplicate results disagree, the proxy returns HTTP
|
|
837
|
+
**422**, with `detail.code=invalid_tool_history` and a specific `reason`.
|
|
838
|
+
No request is sent upstream in that case. Verify the side effects of any
|
|
839
|
+
unfinished tools before retrying or starting a fresh conversation.
|
|
840
|
+
|
|
841
|
+
This repair does not apply to direct `/v1/chat/completions` requests and cannot
|
|
842
|
+
guarantee the absence of unrelated upstream 11148 errors.
|
|
843
|
+
|
|
785
844
|
### Port already in use
|
|
786
845
|
|
|
787
846
|
```bash
|