@shuind/dsh-codex-connect 0.2.0 → 0.2.1
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.
- package/INSTALL.md +349 -349
- package/LICENSE +202 -202
- package/MIGRATION.md +101 -101
- package/NOTICE +26 -26
- package/README.md +2 -2
- package/VERSIONING.md +69 -69
- package/docs/design.md +61 -61
- package/docs/design.zh.md +39 -39
- package/docs/licenses/pi-ai-oauth.txt +21 -21
- package/docs/licenses/standalone-cli.txt +115 -115
- package/docs/preflight-activity.md +42 -42
- package/docs/preflight-activity.zh.md +42 -42
- package/docs/quota-tool.md +46 -46
- package/docs/reference.md +240 -240
- package/docs/reference.zh.md +240 -240
- package/docs/skills/codex-quota-awareness/SKILL.md +12 -12
- package/lib/bin.js +12 -12
- package/lib/client.js +17 -69
- package/lib/index.js +84 -13
- package/lib/{models-Brnw-PH4.js → models-DUIoH1lI.js} +15 -15
- package/lib/{openai-codex-responses-DfZMR6a9.js → openai-codex-responses-CzSuDkhU.js} +17 -17
- package/package.json +1 -1
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
Standalone CLI third-party notices
|
|
2
|
-
|
|
3
|
-
The generated lib/bin.js and its helper chunks include portions of the
|
|
4
|
-
packages listed below, except where marked as retained notices. The retained
|
|
5
|
-
notices cover dependencies bundled by earlier Alpha 4.43 candidates but
|
|
6
|
-
removed from the final standalone CLI. They do not change package licenses.
|
|
7
|
-
|
|
8
|
-
MIT-licensed packages:
|
|
9
|
-
- @deepseek-ai/dsh-atomic-write, dsh-home-paths, dsh-typert-protocol,
|
|
10
|
-
dsh-util-values, dsh-timeout, dsh-llm, and dsh-web: Copyright (c) 2026 DeepSeek.
|
|
11
|
-
- @deepseek-ai/cosmokit, @deepseek-ai/cordis, and
|
|
12
|
-
@deepseek-ai/schemastery: Copyright (c) 2021-present Shigma.
|
|
13
|
-
- @earendil-works/pi-ai: Copyright (c) 2025 Mario Zechner. Its OAuth
|
|
14
|
-
source notice is also retained in docs/licenses/pi-ai-oauth.txt.
|
|
15
|
-
- partial-json: Copyright (c) 2023 Promplate Dev Team.
|
|
16
|
-
|
|
17
|
-
Retained notices for packages no longer included in this CLI build:
|
|
18
|
-
- @deepseek-ai/dsh-attachment, dsh-llm-pi-ai, and dsh-compaction:
|
|
19
|
-
Copyright (c) 2026 DeepSeek (MIT).
|
|
20
|
-
- @anthropic-ai/sdk: Copyright 2023 Anthropic, PBC (MIT).
|
|
21
|
-
- @stablelib/base64: Copyright (C) 2016 Dmitry Chestnykh (MIT).
|
|
22
|
-
- standardwebhooks: Copyright Standard Webhooks (MIT).
|
|
23
|
-
- openai: Copyright OpenAI (Apache-2.0).
|
|
24
|
-
- neoqs: Copyright (c) 2014 Nathan LaFreniere and other contributors (BSD-3-Clause).
|
|
25
|
-
- zod-to-json-schema: Copyright (c) 2020 Stefan Terdell (ISC).
|
|
26
|
-
- fast-sha256: Unlicense.
|
|
27
|
-
|
|
28
|
-
MIT License
|
|
29
|
-
|
|
30
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
31
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
32
|
-
in the Software without restriction, including without limitation the rights
|
|
33
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
34
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
35
|
-
furnished to do so, subject to the following conditions:
|
|
36
|
-
|
|
37
|
-
The above copyright notice and this permission notice shall be included in all
|
|
38
|
-
copies or substantial portions of the Software.
|
|
39
|
-
|
|
40
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
41
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
42
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
43
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
44
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
45
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
46
|
-
SOFTWARE.
|
|
47
|
-
|
|
48
|
-
openai is Copyright OpenAI and is licensed under Apache-2.0; the full license
|
|
49
|
-
is included in this package's root LICENSE file.
|
|
50
|
-
|
|
51
|
-
The OpenAI and Anthropic SDKs include portions of neoqs, Copyright (c) 2014
|
|
52
|
-
Nathan LaFreniere and other contributors, under the BSD 3-Clause License:
|
|
53
|
-
|
|
54
|
-
Redistribution and use in source and binary forms, with or without
|
|
55
|
-
modification, are permitted provided that the following conditions are met:
|
|
56
|
-
|
|
57
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
58
|
-
this list of conditions and the following disclaimer.
|
|
59
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
60
|
-
this list of conditions and the following disclaimer in the documentation
|
|
61
|
-
and/or other materials provided with the distribution.
|
|
62
|
-
3. Neither the name of the copyright holder nor the names of its contributors
|
|
63
|
-
may be used to endorse or promote products derived from this software
|
|
64
|
-
without specific prior written permission.
|
|
65
|
-
|
|
66
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
67
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
68
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
69
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
70
|
-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
71
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
72
|
-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
73
|
-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
74
|
-
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
75
|
-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
76
|
-
POSSIBILITY OF SUCH DAMAGE.
|
|
77
|
-
|
|
78
|
-
The OpenAI SDK includes portions of zod-to-json-schema, Copyright (c) 2020
|
|
79
|
-
Stefan Terdell, under the ISC License:
|
|
80
|
-
|
|
81
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
82
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
83
|
-
copyright notice and this permission notice appear in all copies.
|
|
84
|
-
|
|
85
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
86
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
87
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
88
|
-
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
89
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
90
|
-
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
91
|
-
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
92
|
-
|
|
93
|
-
fast-sha256 1.3.0 is released under the Unlicense:
|
|
94
|
-
|
|
95
|
-
This is free and unencumbered software released into the public domain.
|
|
96
|
-
|
|
97
|
-
Anyone is free to copy, modify, publish, use, compile, sell, or distribute
|
|
98
|
-
this software, either in source code form or as a compiled binary, for any
|
|
99
|
-
purpose, commercial or non-commercial, and by any means.
|
|
100
|
-
|
|
101
|
-
In jurisdictions that recognize copyright laws, the author or authors of
|
|
102
|
-
this software dedicate any and all copyright interest in the software to the
|
|
103
|
-
public domain. We make this dedication for the benefit of the public at large
|
|
104
|
-
and to the detriment of our heirs and successors. We intend this dedication
|
|
105
|
-
to be an overt act of relinquishment in perpetuity of all present and future
|
|
106
|
-
rights to this software under copyright law.
|
|
107
|
-
|
|
108
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
109
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
110
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
111
|
-
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
112
|
-
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
113
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
114
|
-
|
|
115
|
-
For more information, please refer to <https://unlicense.org>.
|
|
1
|
+
Standalone CLI third-party notices
|
|
2
|
+
|
|
3
|
+
The generated lib/bin.js and its helper chunks include portions of the
|
|
4
|
+
packages listed below, except where marked as retained notices. The retained
|
|
5
|
+
notices cover dependencies bundled by earlier Alpha 4.43 candidates but
|
|
6
|
+
removed from the final standalone CLI. They do not change package licenses.
|
|
7
|
+
|
|
8
|
+
MIT-licensed packages:
|
|
9
|
+
- @deepseek-ai/dsh-atomic-write, dsh-home-paths, dsh-typert-protocol,
|
|
10
|
+
dsh-util-values, dsh-timeout, dsh-llm, and dsh-web: Copyright (c) 2026 DeepSeek.
|
|
11
|
+
- @deepseek-ai/cosmokit, @deepseek-ai/cordis, and
|
|
12
|
+
@deepseek-ai/schemastery: Copyright (c) 2021-present Shigma.
|
|
13
|
+
- @earendil-works/pi-ai: Copyright (c) 2025 Mario Zechner. Its OAuth
|
|
14
|
+
source notice is also retained in docs/licenses/pi-ai-oauth.txt.
|
|
15
|
+
- partial-json: Copyright (c) 2023 Promplate Dev Team.
|
|
16
|
+
|
|
17
|
+
Retained notices for packages no longer included in this CLI build:
|
|
18
|
+
- @deepseek-ai/dsh-attachment, dsh-llm-pi-ai, and dsh-compaction:
|
|
19
|
+
Copyright (c) 2026 DeepSeek (MIT).
|
|
20
|
+
- @anthropic-ai/sdk: Copyright 2023 Anthropic, PBC (MIT).
|
|
21
|
+
- @stablelib/base64: Copyright (C) 2016 Dmitry Chestnykh (MIT).
|
|
22
|
+
- standardwebhooks: Copyright Standard Webhooks (MIT).
|
|
23
|
+
- openai: Copyright OpenAI (Apache-2.0).
|
|
24
|
+
- neoqs: Copyright (c) 2014 Nathan LaFreniere and other contributors (BSD-3-Clause).
|
|
25
|
+
- zod-to-json-schema: Copyright (c) 2020 Stefan Terdell (ISC).
|
|
26
|
+
- fast-sha256: Unlicense.
|
|
27
|
+
|
|
28
|
+
MIT License
|
|
29
|
+
|
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
31
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
32
|
+
in the Software without restriction, including without limitation the rights
|
|
33
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
34
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
35
|
+
furnished to do so, subject to the following conditions:
|
|
36
|
+
|
|
37
|
+
The above copyright notice and this permission notice shall be included in all
|
|
38
|
+
copies or substantial portions of the Software.
|
|
39
|
+
|
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
41
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
42
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
43
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
44
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
45
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
46
|
+
SOFTWARE.
|
|
47
|
+
|
|
48
|
+
openai is Copyright OpenAI and is licensed under Apache-2.0; the full license
|
|
49
|
+
is included in this package's root LICENSE file.
|
|
50
|
+
|
|
51
|
+
The OpenAI and Anthropic SDKs include portions of neoqs, Copyright (c) 2014
|
|
52
|
+
Nathan LaFreniere and other contributors, under the BSD 3-Clause License:
|
|
53
|
+
|
|
54
|
+
Redistribution and use in source and binary forms, with or without
|
|
55
|
+
modification, are permitted provided that the following conditions are met:
|
|
56
|
+
|
|
57
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
58
|
+
this list of conditions and the following disclaimer.
|
|
59
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
60
|
+
this list of conditions and the following disclaimer in the documentation
|
|
61
|
+
and/or other materials provided with the distribution.
|
|
62
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
63
|
+
may be used to endorse or promote products derived from this software
|
|
64
|
+
without specific prior written permission.
|
|
65
|
+
|
|
66
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
67
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
68
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
69
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
70
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
71
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
72
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
73
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
74
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
75
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
76
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
77
|
+
|
|
78
|
+
The OpenAI SDK includes portions of zod-to-json-schema, Copyright (c) 2020
|
|
79
|
+
Stefan Terdell, under the ISC License:
|
|
80
|
+
|
|
81
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
82
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
83
|
+
copyright notice and this permission notice appear in all copies.
|
|
84
|
+
|
|
85
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
86
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
88
|
+
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
89
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
90
|
+
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
91
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
92
|
+
|
|
93
|
+
fast-sha256 1.3.0 is released under the Unlicense:
|
|
94
|
+
|
|
95
|
+
This is free and unencumbered software released into the public domain.
|
|
96
|
+
|
|
97
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or distribute
|
|
98
|
+
this software, either in source code form or as a compiled binary, for any
|
|
99
|
+
purpose, commercial or non-commercial, and by any means.
|
|
100
|
+
|
|
101
|
+
In jurisdictions that recognize copyright laws, the author or authors of
|
|
102
|
+
this software dedicate any and all copyright interest in the software to the
|
|
103
|
+
public domain. We make this dedication for the benefit of the public at large
|
|
104
|
+
and to the detriment of our heirs and successors. We intend this dedication
|
|
105
|
+
to be an overt act of relinquishment in perpetuity of all present and future
|
|
106
|
+
rights to this software under copyright law.
|
|
107
|
+
|
|
108
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
109
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
110
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
111
|
+
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
112
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
113
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
114
|
+
|
|
115
|
+
For more information, please refer to <https://unlicense.org>.
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# Bounded bili preflight activity
|
|
2
|
-
|
|
3
|
-
English | [中文](preflight-activity.zh.md)
|
|
4
|
-
|
|
5
|
-
This source change addresses [#340](https://github.com/franksong2702/dsh-codex-connect/issues/340): a bili proxy may spend longer than the ordinary five-minute stream idle interval compressing a request while sending `: bili-preflight` SSE comments. Comments are not model output. The integration remains disabled unless the operator explicitly trusts one proxy origin and supplies a finite total budget. Published Alpha 5 is immutable and does not contain this change.
|
|
6
|
-
|
|
7
|
-
## Configuration
|
|
8
|
-
|
|
9
|
-
Add startup configuration to the existing plugin entry in the effective profile. Replace the example origin with the credential-free HTTP(S) proxy actually used by this plugin. `preflightActivity` is not a browser setting; it is validated when the plugin loads.
|
|
10
|
-
|
|
11
|
-
```yaml
|
|
12
|
-
- id: llm-openai-codex
|
|
13
|
-
config:
|
|
14
|
-
enableProxy: true
|
|
15
|
-
proxyUrl: http://127.0.0.1:7890
|
|
16
|
-
preflightActivity:
|
|
17
|
-
protocol: bili-v1
|
|
18
|
-
trustedProxyOrigin: http://127.0.0.1:7890
|
|
19
|
-
maxDurationMs: 450000
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
`maxDurationMs` is required: a positive safe integer no greater than `2147183647`. The upper bound reserves 300000 milliseconds for the Host's finite inner safety timer; it is not a recommended wait duration. Omit `preflightActivity` to retain the original behavior. Changes take effect on a subsequent operator-controlled plugin load; installing this patch does not change or restart any service automatically.
|
|
23
|
-
|
|
24
|
-
## Timing and trust
|
|
25
|
-
|
|
26
|
-
Activity requires explicit `preflightActivity` configuration and a successful SSE response with `x-bili-preflight: compressing`. The invocation must either acquire the configured proxy origin, or, when no plugin proxy was acquired, prove that the installed billion-context native fetch chain routed this response through that same configured origin. Native proof requires the installed flag, an own fetch-chain marker, a current native state object with an explicit-port numeric-loopback HTTP origin, and the exact nonredirected response URL produced by rewriting this request as `<origin>/bili/<input URL>`. Headers or the mere presence of billion-context do not authorize a route.
|
|
27
|
-
|
|
28
|
-
For native interception, configure `trustedProxyOrigin` to the active native proxy's exact origin, including its port; `enableProxy` is not required for this independently installed route. A dynamically assigned native port must match startup authorization. If the native proxy is reloaded or replaced, old responses lose heartbeat authority; a different port requires a subsequent operator-controlled plugin load with updated configuration. Omitting `preflightActivity` still disables the integration, even when the native interceptor is installed. A different acquired plugin proxy is never rescued by the native fallback.
|
|
29
|
-
|
|
30
|
-
Once admitted, the response header renews the outstanding idle read once. Subsequent activity requires a complete frame containing exactly `: bili-preflight` followed by an empty line. Fragmented LF, CRLF and CR line endings are accepted. Untrusted direct routes, another proxy, ordinary comments, partial frames and comments with extra fields do not renew idle time. Proxy trust does not change endpoint validation, redirect policy, TLS validation, credentials or direct-fallback policy; these headers are not proof of proxy identity on an untrusted route.
|
|
31
|
-
|
|
32
|
-
The ordinary idle interval remains 300000 milliseconds while an output read is outstanding. An accepted heartbeat renews only that idle interval. A separate absolute preflight budget starts at the first eligible response header and cannot be reset by retries or further heartbeats. A `data:` line or an oversized frame stops heartbeat recognition but does not erase the budget. The first converted Host chunk, EOF or iterator cleanup ends preflight timing. Consumer pauses between chunks are not provider idle time.
|
|
33
|
-
|
|
34
|
-
The plugin uses existing public provider authentication and stream-profile APIs, together with `dsh-timeout`; no Host fork or new upstream interface is required. Its timer starts after Host credential and attachment preparation. Only an opted-in profile gets an inner safety interval of `300000 + maxDurationMs`; the plugin wrapper still enforces the ordinary five-minute idle limit, including direct and noneligible responses. Each iterator has independent authority and timers, including repeated invocations of a prepared call.
|
|
35
|
-
|
|
36
|
-
Caller cancellation retains already-produced Host usage and aborted-finish chunks. A read that does not settle after cancellation is abandoned after one event-loop turn. Plugin-owned expiry remains `TIMEOUT`, even if the underlying provider later reports an aborted finish. Cleanup aborts the request, clears owned timers and detaches a nonsettling inner return. It cannot force arbitrary third-party callbacks to terminate. Response bytes and stream demand are preserved; no synthetic heartbeat is added to model output or conversation history.
|
|
37
|
-
|
|
38
|
-
## Verification and limits
|
|
39
|
-
|
|
40
|
-
`tests/preflight-*.spec.ts` exercises the unchanged oldest development Host with synthetic credentials, real SDK parsing, virtual time, fragmented frames, slow preparation, cancellation, total/idle limits and response demand. `tests/native-preflight.spec.ts` verifies the narrow installed-native authority contract, including exact real local-fetch response metadata, redirect rejection and authority replacement; the adapter tests cover configured native routing, default-off behavior, origin mismatch, stale authority, bounded heartbeats, cancellation and semantic idle restoration. `pnpm run check:dsh-matrix` installs the same packed plugin against every exact declared Host and runs six enabled/default-off cases per Host, including a response header at 299 seconds followed by the full 450-second budget and an enabled/disabled cancellation comparison. Only HTTP and proxy transport are replaced in those installed fixtures; no real provider request occurs.
|
|
41
|
-
|
|
42
|
-
These checks do not establish real bili, HTTPS CONNECT/TLS topology, Windows Desktop or account/model acceptance. The issue's separate post-cancellation HTTP 413 is not changed by this patch. Track native compatibility in #405; the separate HTTP 413 requires an upstream bili fix and live acceptance. Source merge and green CI are not a publication or a successful live conversation.
|
|
1
|
+
# Bounded bili preflight activity
|
|
2
|
+
|
|
3
|
+
English | [中文](preflight-activity.zh.md)
|
|
4
|
+
|
|
5
|
+
This source change addresses [#340](https://github.com/franksong2702/dsh-codex-connect/issues/340): a bili proxy may spend longer than the ordinary five-minute stream idle interval compressing a request while sending `: bili-preflight` SSE comments. Comments are not model output. The integration remains disabled unless the operator explicitly trusts one proxy origin and supplies a finite total budget. Published Alpha 5 is immutable and does not contain this change.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
Add startup configuration to the existing plugin entry in the effective profile. Replace the example origin with the credential-free HTTP(S) proxy actually used by this plugin. `preflightActivity` is not a browser setting; it is validated when the plugin loads.
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
- id: llm-openai-codex
|
|
13
|
+
config:
|
|
14
|
+
enableProxy: true
|
|
15
|
+
proxyUrl: http://127.0.0.1:7890
|
|
16
|
+
preflightActivity:
|
|
17
|
+
protocol: bili-v1
|
|
18
|
+
trustedProxyOrigin: http://127.0.0.1:7890
|
|
19
|
+
maxDurationMs: 450000
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`maxDurationMs` is required: a positive safe integer no greater than `2147183647`. The upper bound reserves 300000 milliseconds for the Host's finite inner safety timer; it is not a recommended wait duration. Omit `preflightActivity` to retain the original behavior. Changes take effect on a subsequent operator-controlled plugin load; installing this patch does not change or restart any service automatically.
|
|
23
|
+
|
|
24
|
+
## Timing and trust
|
|
25
|
+
|
|
26
|
+
Activity requires explicit `preflightActivity` configuration and a successful SSE response with `x-bili-preflight: compressing`. The invocation must either acquire the configured proxy origin, or, when no plugin proxy was acquired, prove that the installed billion-context native fetch chain routed this response through that same configured origin. Native proof requires the installed flag, an own fetch-chain marker, a current native state object with an explicit-port numeric-loopback HTTP origin, and the exact nonredirected response URL produced by rewriting this request as `<origin>/bili/<input URL>`. Headers or the mere presence of billion-context do not authorize a route.
|
|
27
|
+
|
|
28
|
+
For native interception, configure `trustedProxyOrigin` to the active native proxy's exact origin, including its port; `enableProxy` is not required for this independently installed route. A dynamically assigned native port must match startup authorization. If the native proxy is reloaded or replaced, old responses lose heartbeat authority; a different port requires a subsequent operator-controlled plugin load with updated configuration. Omitting `preflightActivity` still disables the integration, even when the native interceptor is installed. A different acquired plugin proxy is never rescued by the native fallback.
|
|
29
|
+
|
|
30
|
+
Once admitted, the response header renews the outstanding idle read once. Subsequent activity requires a complete frame containing exactly `: bili-preflight` followed by an empty line. Fragmented LF, CRLF and CR line endings are accepted. Untrusted direct routes, another proxy, ordinary comments, partial frames and comments with extra fields do not renew idle time. Proxy trust does not change endpoint validation, redirect policy, TLS validation, credentials or direct-fallback policy; these headers are not proof of proxy identity on an untrusted route.
|
|
31
|
+
|
|
32
|
+
The ordinary idle interval remains 300000 milliseconds while an output read is outstanding. An accepted heartbeat renews only that idle interval. A separate absolute preflight budget starts at the first eligible response header and cannot be reset by retries or further heartbeats. A `data:` line or an oversized frame stops heartbeat recognition but does not erase the budget. The first converted Host chunk, EOF or iterator cleanup ends preflight timing. Consumer pauses between chunks are not provider idle time.
|
|
33
|
+
|
|
34
|
+
The plugin uses existing public provider authentication and stream-profile APIs, together with `dsh-timeout`; no Host fork or new upstream interface is required. Its timer starts after Host credential and attachment preparation. Only an opted-in profile gets an inner safety interval of `300000 + maxDurationMs`; the plugin wrapper still enforces the ordinary five-minute idle limit, including direct and noneligible responses. Each iterator has independent authority and timers, including repeated invocations of a prepared call.
|
|
35
|
+
|
|
36
|
+
Caller cancellation retains already-produced Host usage and aborted-finish chunks. A read that does not settle after cancellation is abandoned after one event-loop turn. Plugin-owned expiry remains `TIMEOUT`, even if the underlying provider later reports an aborted finish. Cleanup aborts the request, clears owned timers and detaches a nonsettling inner return. It cannot force arbitrary third-party callbacks to terminate. Response bytes and stream demand are preserved; no synthetic heartbeat is added to model output or conversation history.
|
|
37
|
+
|
|
38
|
+
## Verification and limits
|
|
39
|
+
|
|
40
|
+
`tests/preflight-*.spec.ts` exercises the unchanged oldest development Host with synthetic credentials, real SDK parsing, virtual time, fragmented frames, slow preparation, cancellation, total/idle limits and response demand. `tests/native-preflight.spec.ts` verifies the narrow installed-native authority contract, including exact real local-fetch response metadata, redirect rejection and authority replacement; the adapter tests cover configured native routing, default-off behavior, origin mismatch, stale authority, bounded heartbeats, cancellation and semantic idle restoration. `pnpm run check:dsh-matrix` installs the same packed plugin against every exact declared Host and runs six enabled/default-off cases per Host, including a response header at 299 seconds followed by the full 450-second budget and an enabled/disabled cancellation comparison. Only HTTP and proxy transport are replaced in those installed fixtures; no real provider request occurs.
|
|
41
|
+
|
|
42
|
+
These checks do not establish real bili, HTTPS CONNECT/TLS topology, Windows Desktop or account/model acceptance. The issue's separate post-cancellation HTTP 413 is not changed by this patch. Track native compatibility in #405; the separate HTTP 413 requires an upstream bili fix and live acceptance. Source merge and green CI are not a publication or a successful live conversation.
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# 有界的 bili 预处理活动
|
|
2
|
-
|
|
3
|
-
[English](preflight-activity.md) | 中文
|
|
4
|
-
|
|
5
|
-
这项源码改动处理 [#340](https://github.com/franksong2702/dsh-codex-connect/issues/340):bili 代理压缩请求时可能超过普通流的五分钟空闲期限,同时持续发送 `: bili-preflight` SSE 注释。注释不是模型输出。只有运维者明确指定一个可信代理 origin 和有限总预算,才会启用此适配。已发布的 Alpha 5 保持不可变,不包含本次改动。
|
|
6
|
-
|
|
7
|
-
## 配置
|
|
8
|
-
|
|
9
|
-
在实际生效的 profile 中给已有插件条目添加启动配置。把示例地址换成插件实际使用、不带凭据的 HTTP(S) 代理 origin。`preflightActivity` 不是浏览器设置;插件加载时会校验它。
|
|
10
|
-
|
|
11
|
-
```yaml
|
|
12
|
-
- id: llm-openai-codex
|
|
13
|
-
config:
|
|
14
|
-
enableProxy: true
|
|
15
|
-
proxyUrl: http://127.0.0.1:7890
|
|
16
|
-
preflightActivity:
|
|
17
|
-
protocol: bili-v1
|
|
18
|
-
trustedProxyOrigin: http://127.0.0.1:7890
|
|
19
|
-
maxDurationMs: 450000
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
`maxDurationMs` 必填,必须是大于零且不超过 `2147183647` 的安全整数。上限为宿主内部的有限保险计时器预留 300000 毫秒,并不是建议的等待时长。省略 `preflightActivity` 即保留原有行为。修改会在之后由运维者控制的插件加载中生效;安装补丁不会自动修改或重启服务。
|
|
23
|
-
|
|
24
|
-
## 计时与信任
|
|
25
|
-
|
|
26
|
-
认可活动必须明确配置 `preflightActivity`,且成功的 SSE 响应带有 `x-bili-preflight: compressing`。本次调用必须取得配置中的代理 origin;若未取得插件代理,则必须证明已安装的 billion-context 原生 fetch 链确实将本次响应路由到同一配置 origin。原生证明要求安装标记、fetch 自身的链标记、当前原生状态对象中带显式端口的数字回环 HTTP origin,以及将本次请求改写为 `<origin>/bili/<input URL>` 后的精确未重定向响应 URL。只有响应头或仅安装了 billion-context 均不能授权路由。
|
|
27
|
-
|
|
28
|
-
使用原生拦截时,`trustedProxyOrigin` 必须填写当前原生代理的精确 origin(包括端口);这一独立安装的路由不要求 `enableProxy`。动态分配的端口必须匹配启动授权。原生代理重新加载或替换后,旧响应失去心跳授权;不同端口需要运维者在后续插件加载时更新配置。即使原生拦截已安装,省略 `preflightActivity` 仍会关闭适配。已经取得另一个插件代理时,不会通过原生回退绕过不匹配。
|
|
29
|
-
|
|
30
|
-
通过验证的响应头只续期当前空闲读取一次。随后必须是恰好由 `: bili-preflight` 和空行组成的完整帧才认可活动。允许分片的 LF、CRLF 和 CR 换行。不可信直连、其他代理、普通注释、不完整帧或包含其他字段的注释均不会续期。代理信任不会改变目标地址校验、重定向策略、TLS 校验、凭据或禁止静默直连回退的策略;不可信路由中的这些响应头不能证明代理身份。
|
|
31
|
-
|
|
32
|
-
等待输出读取时,普通空闲期限仍为 300000 毫秒。认可的心跳只续期这一空闲期限。另一个不可续期的预处理总预算从第一个符合条件的响应头开始,重试和后续心跳都不能重置。出现 `data:` 行或超长帧后停止识别心跳,但不会抹除总预算。宿主转换出的第一个数据块、EOF 或迭代器清理结束预处理计时。消费者在两次读取之间暂停,不算提供方空闲。
|
|
33
|
-
|
|
34
|
-
插件复用现有的公开提供方认证、流配置接口与 `dsh-timeout`,不需要 fork 宿主或新增上游接口。计时从宿主凭据与附件准备完成后开始。只有明确启用的 profile 才将内部保险期限设为 `300000 + maxDurationMs`;外层插件仍对普通请求强制执行五分钟空闲限制,包括直连与不符合条件的响应。每个迭代器的授权与计时独立,同一 prepared call 的重复调用也不共享。
|
|
35
|
-
|
|
36
|
-
用户取消时保留宿主已经产生的 usage 与 aborted-finish 数据块。取消后仍不结束的读取,最多等待一个事件循环轮次便停止等待。插件自己的期限先到时始终报告 `TIMEOUT`,不会被提供方随后产生的 aborted finish 改写。清理会取消请求、移除自身计时器,并停止等待卡住的内部 return;不能强迫任意第三方回调结束。响应字节和读取需求保持不变,不向模型输出或会话历史注入虚构心跳。
|
|
37
|
-
|
|
38
|
-
## 验证与限制
|
|
39
|
-
|
|
40
|
-
`tests/preflight-*.spec.ts` 在未修改的最旧开发宿主上使用虚构凭据、实际 SDK 解析和虚拟时间,覆盖分片帧、缓慢准备、取消、总预算/空闲期限与响应读取。`tests/native-preflight.spec.ts` 验证严格的原生安装授权契约,包括真实本地 fetch 的精确响应元数据、重定向拒绝与授权替换;适配器测试覆盖已配置原生路由、默认关闭、origin 不匹配、旧授权、有界心跳、取消以及模型输出后的空闲期限恢复。`pnpm run check:dsh-matrix` 对每个精确声明的宿主安装同一个插件包,每个宿主执行六项启用/默认关闭检查,包括第 299 秒到达的响应头之后仍有完整 450 秒预算,以及启用/关闭时的取消结果对照。已安装包检查只替换 HTTP 和代理传输,不调用真实提供方。
|
|
41
|
-
|
|
42
|
-
这些检查不代表真实 bili、HTTPS CONNECT/TLS 拓扑、Windows Desktop 或账户/模型验收。此补丁不处理 issue 中取消后另行发生的 HTTP 413。原生兼容性跟进 #405;独立的 HTTP 413 需要 bili 上游修复及真实场景验收。源码合并和绿色 CI 都不等于发布或真实对话成功。
|
|
1
|
+
# 有界的 bili 预处理活动
|
|
2
|
+
|
|
3
|
+
[English](preflight-activity.md) | 中文
|
|
4
|
+
|
|
5
|
+
这项源码改动处理 [#340](https://github.com/franksong2702/dsh-codex-connect/issues/340):bili 代理压缩请求时可能超过普通流的五分钟空闲期限,同时持续发送 `: bili-preflight` SSE 注释。注释不是模型输出。只有运维者明确指定一个可信代理 origin 和有限总预算,才会启用此适配。已发布的 Alpha 5 保持不可变,不包含本次改动。
|
|
6
|
+
|
|
7
|
+
## 配置
|
|
8
|
+
|
|
9
|
+
在实际生效的 profile 中给已有插件条目添加启动配置。把示例地址换成插件实际使用、不带凭据的 HTTP(S) 代理 origin。`preflightActivity` 不是浏览器设置;插件加载时会校验它。
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
- id: llm-openai-codex
|
|
13
|
+
config:
|
|
14
|
+
enableProxy: true
|
|
15
|
+
proxyUrl: http://127.0.0.1:7890
|
|
16
|
+
preflightActivity:
|
|
17
|
+
protocol: bili-v1
|
|
18
|
+
trustedProxyOrigin: http://127.0.0.1:7890
|
|
19
|
+
maxDurationMs: 450000
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`maxDurationMs` 必填,必须是大于零且不超过 `2147183647` 的安全整数。上限为宿主内部的有限保险计时器预留 300000 毫秒,并不是建议的等待时长。省略 `preflightActivity` 即保留原有行为。修改会在之后由运维者控制的插件加载中生效;安装补丁不会自动修改或重启服务。
|
|
23
|
+
|
|
24
|
+
## 计时与信任
|
|
25
|
+
|
|
26
|
+
认可活动必须明确配置 `preflightActivity`,且成功的 SSE 响应带有 `x-bili-preflight: compressing`。本次调用必须取得配置中的代理 origin;若未取得插件代理,则必须证明已安装的 billion-context 原生 fetch 链确实将本次响应路由到同一配置 origin。原生证明要求安装标记、fetch 自身的链标记、当前原生状态对象中带显式端口的数字回环 HTTP origin,以及将本次请求改写为 `<origin>/bili/<input URL>` 后的精确未重定向响应 URL。只有响应头或仅安装了 billion-context 均不能授权路由。
|
|
27
|
+
|
|
28
|
+
使用原生拦截时,`trustedProxyOrigin` 必须填写当前原生代理的精确 origin(包括端口);这一独立安装的路由不要求 `enableProxy`。动态分配的端口必须匹配启动授权。原生代理重新加载或替换后,旧响应失去心跳授权;不同端口需要运维者在后续插件加载时更新配置。即使原生拦截已安装,省略 `preflightActivity` 仍会关闭适配。已经取得另一个插件代理时,不会通过原生回退绕过不匹配。
|
|
29
|
+
|
|
30
|
+
通过验证的响应头只续期当前空闲读取一次。随后必须是恰好由 `: bili-preflight` 和空行组成的完整帧才认可活动。允许分片的 LF、CRLF 和 CR 换行。不可信直连、其他代理、普通注释、不完整帧或包含其他字段的注释均不会续期。代理信任不会改变目标地址校验、重定向策略、TLS 校验、凭据或禁止静默直连回退的策略;不可信路由中的这些响应头不能证明代理身份。
|
|
31
|
+
|
|
32
|
+
等待输出读取时,普通空闲期限仍为 300000 毫秒。认可的心跳只续期这一空闲期限。另一个不可续期的预处理总预算从第一个符合条件的响应头开始,重试和后续心跳都不能重置。出现 `data:` 行或超长帧后停止识别心跳,但不会抹除总预算。宿主转换出的第一个数据块、EOF 或迭代器清理结束预处理计时。消费者在两次读取之间暂停,不算提供方空闲。
|
|
33
|
+
|
|
34
|
+
插件复用现有的公开提供方认证、流配置接口与 `dsh-timeout`,不需要 fork 宿主或新增上游接口。计时从宿主凭据与附件准备完成后开始。只有明确启用的 profile 才将内部保险期限设为 `300000 + maxDurationMs`;外层插件仍对普通请求强制执行五分钟空闲限制,包括直连与不符合条件的响应。每个迭代器的授权与计时独立,同一 prepared call 的重复调用也不共享。
|
|
35
|
+
|
|
36
|
+
用户取消时保留宿主已经产生的 usage 与 aborted-finish 数据块。取消后仍不结束的读取,最多等待一个事件循环轮次便停止等待。插件自己的期限先到时始终报告 `TIMEOUT`,不会被提供方随后产生的 aborted finish 改写。清理会取消请求、移除自身计时器,并停止等待卡住的内部 return;不能强迫任意第三方回调结束。响应字节和读取需求保持不变,不向模型输出或会话历史注入虚构心跳。
|
|
37
|
+
|
|
38
|
+
## 验证与限制
|
|
39
|
+
|
|
40
|
+
`tests/preflight-*.spec.ts` 在未修改的最旧开发宿主上使用虚构凭据、实际 SDK 解析和虚拟时间,覆盖分片帧、缓慢准备、取消、总预算/空闲期限与响应读取。`tests/native-preflight.spec.ts` 验证严格的原生安装授权契约,包括真实本地 fetch 的精确响应元数据、重定向拒绝与授权替换;适配器测试覆盖已配置原生路由、默认关闭、origin 不匹配、旧授权、有界心跳、取消以及模型输出后的空闲期限恢复。`pnpm run check:dsh-matrix` 对每个精确声明的宿主安装同一个插件包,每个宿主执行六项启用/默认关闭检查,包括第 299 秒到达的响应头之后仍有完整 450 秒预算,以及启用/关闭时的取消结果对照。已安装包检查只替换 HTTP 和代理传输,不调用真实提供方。
|
|
41
|
+
|
|
42
|
+
这些检查不代表真实 bili、HTTPS CONNECT/TLS 拓扑、Windows Desktop 或账户/模型验收。此补丁不处理 issue 中取消后另行发生的 HTTP 413。原生兼容性跟进 #405;独立的 HTTP 413 需要 bili 上游修复及真实场景验收。源码合并和绿色 CI 都不等于发布或真实对话成功。
|
package/docs/quota-tool.md
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
# Model quota observation
|
|
2
|
-
|
|
3
|
-
`codex_connect_quota` lets a model inspect the shared Codex allowance without issuing a model request. It is disabled by default. This source capability requires a package containing it; older installed releases do not gain it automatically.
|
|
4
|
-
|
|
5
|
-
## Enable explicitly
|
|
6
|
-
|
|
7
|
-
Add the following inside the existing Codex Connect plugin row's `config` in your profile composition, then reload the plugin through the Host:
|
|
8
|
-
|
|
9
|
-
```yaml
|
|
10
|
-
enableQuotaTool: true
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Omit the key or set it to `false` and reload to remove the tool. There is no custom settings-card toggle. Installation does not rewrite existing profiles or install a skill. Normal Host permission and cancellation rules still apply. The tool accepts only `{}`; it cannot select accounts/models or force a refresh.
|
|
14
|
-
|
|
15
|
-
## Read the result
|
|
16
|
-
|
|
17
|
-
An illustrative successful result is:
|
|
18
|
-
|
|
19
|
-
```json
|
|
20
|
-
{"status":"available","updatedAt":1792674000000,"windows":[{"remainingPercent":25,"windowSeconds":18000,"resetAt":1792680000}]}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
| Field | Meaning |
|
|
24
|
-
| --- | --- |
|
|
25
|
-
| `status` | `available`: common windows were observed; `unknown`: no usable observation; `stale`: an observation expired or was invalidated. |
|
|
26
|
-
| `updatedAt` | Local successful-response observation time, Unix **milliseconds**, preserved on cache hits. Omitted when no reliable time is available. This is not the upstream data-generation time. |
|
|
27
|
-
| `windows` | Shared `codex` windows only. Empty for `unknown` and `stale`; an empty list is not zero or unlimited allowance. |
|
|
28
|
-
| `remainingPercent` | Observed percentage remaining, including a real `0` when reported. Not a token count, precise task budget or guarantee that a task can finish. |
|
|
29
|
-
| `windowSeconds` | Server-reported window duration in seconds. |
|
|
30
|
-
| `resetAt` | Optional server-reported reset time, Unix **seconds**. Omitted when unavailable. A reset time does not guarantee restored access. |
|
|
31
|
-
|
|
32
|
-
Separately metered models/features, spend limits, prepaid balances, account identifiers, labels, credentials, raw upstream responses and error details are excluded. Shared quota can coexist with a separate model limit or service restriction, so `available` does not establish model entitlement or sufficient capacity.
|
|
33
|
-
|
|
34
|
-
## Freshness, isolation and failure
|
|
35
|
-
|
|
36
|
-
Each call uses the account captured by existing authentication at call start. A concurrent account switch affects later calls; an in-flight result still describes the captured account. Conversations are not account-bound. Calls expose no account selector or identifier, so do not compare results across account changes as if they were one history.
|
|
37
|
-
|
|
38
|
-
The tool shares the existing bounded cache keyed by account and credential fingerprint, coalesces concurrent reads, and preserves its failure cooldowns. Successful observations are cached for 60 seconds with no background poller. An observation at least 60 seconds old, a window whose supplied reset time has passed, or revoked snapshot authority produces `stale` with no percentages. A failed refresh removes the old usable snapshot and returns `unknown`; it does not relabel old quota as fresh. Legacy Reserve settings cannot enable negotiation or polling.
|
|
39
|
-
|
|
40
|
-
Quota GETs use the existing proxy, bounded response parsing, 15-second request deadline and shared backend governor. Transient errors retain the existing jittered exponential cooldown (starting at 60 seconds, capped at 15 minutes); a longer `Retry-After` takes precedence. Reauthorization and non-retryable client failures require existing cache invalidation or renewed credentials. Repeated calls cannot bypass those cooldowns. Caller cancellation detaches the tool wait without cancelling a shared surviving consumer; plugin disposal cancels shared work.
|
|
41
|
-
|
|
42
|
-
Call at a resource checkpoint requested by the user or required by an already authorized workflow, rather than before every step. On `unknown`/`stale`, do not assume sufficient or exhausted quota or loop to force freshness. If quota actually blocks required work, preserve the user's goal and quality bar, report the blocker and incomplete validation, and leave a resumable checkpoint where appropriate. Do not skip tests, security checks or required work, silently lower quality, switch models/accounts or create schedules because of a percentage. Any such action needs its own authority.
|
|
43
|
-
|
|
44
|
-
An optional [quota-awareness skill example](skills/codex-quota-awareness/SKILL.md) can be copied deliberately into the user's Host-supported skills location or adapted into an authorized automation's instructions. It is documentation, not automatically registered repository guidance. No scheduler, automatic recovery or frozen Adaptive Task activation is included.
|
|
45
|
-
|
|
46
|
-
Verification uses temporary synthetic accounts and mocked upstream responses. It does not establish live-account behavior, Desktop native acceptance or quota accuracy at the service.
|
|
1
|
+
# Model quota observation
|
|
2
|
+
|
|
3
|
+
`codex_connect_quota` lets a model inspect the shared Codex allowance without issuing a model request. It is disabled by default. This source capability requires a package containing it; older installed releases do not gain it automatically.
|
|
4
|
+
|
|
5
|
+
## Enable explicitly
|
|
6
|
+
|
|
7
|
+
Add the following inside the existing Codex Connect plugin row's `config` in your profile composition, then reload the plugin through the Host:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
enableQuotaTool: true
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Omit the key or set it to `false` and reload to remove the tool. There is no custom settings-card toggle. Installation does not rewrite existing profiles or install a skill. Normal Host permission and cancellation rules still apply. The tool accepts only `{}`; it cannot select accounts/models or force a refresh.
|
|
14
|
+
|
|
15
|
+
## Read the result
|
|
16
|
+
|
|
17
|
+
An illustrative successful result is:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{"status":"available","updatedAt":1792674000000,"windows":[{"remainingPercent":25,"windowSeconds":18000,"resetAt":1792680000}]}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Field | Meaning |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `status` | `available`: common windows were observed; `unknown`: no usable observation; `stale`: an observation expired or was invalidated. |
|
|
26
|
+
| `updatedAt` | Local successful-response observation time, Unix **milliseconds**, preserved on cache hits. Omitted when no reliable time is available. This is not the upstream data-generation time. |
|
|
27
|
+
| `windows` | Shared `codex` windows only. Empty for `unknown` and `stale`; an empty list is not zero or unlimited allowance. |
|
|
28
|
+
| `remainingPercent` | Observed percentage remaining, including a real `0` when reported. Not a token count, precise task budget or guarantee that a task can finish. |
|
|
29
|
+
| `windowSeconds` | Server-reported window duration in seconds. |
|
|
30
|
+
| `resetAt` | Optional server-reported reset time, Unix **seconds**. Omitted when unavailable. A reset time does not guarantee restored access. |
|
|
31
|
+
|
|
32
|
+
Separately metered models/features, spend limits, prepaid balances, account identifiers, labels, credentials, raw upstream responses and error details are excluded. Shared quota can coexist with a separate model limit or service restriction, so `available` does not establish model entitlement or sufficient capacity.
|
|
33
|
+
|
|
34
|
+
## Freshness, isolation and failure
|
|
35
|
+
|
|
36
|
+
Each call uses the account captured by existing authentication at call start. A concurrent account switch affects later calls; an in-flight result still describes the captured account. Conversations are not account-bound. Calls expose no account selector or identifier, so do not compare results across account changes as if they were one history.
|
|
37
|
+
|
|
38
|
+
The tool shares the existing bounded cache keyed by account and credential fingerprint, coalesces concurrent reads, and preserves its failure cooldowns. Successful observations are cached for 60 seconds with no background poller. An observation at least 60 seconds old, a window whose supplied reset time has passed, or revoked snapshot authority produces `stale` with no percentages. A failed refresh removes the old usable snapshot and returns `unknown`; it does not relabel old quota as fresh. Legacy Reserve settings cannot enable negotiation or polling.
|
|
39
|
+
|
|
40
|
+
Quota GETs use the existing proxy, bounded response parsing, 15-second request deadline and shared backend governor. Transient errors retain the existing jittered exponential cooldown (starting at 60 seconds, capped at 15 minutes); a longer `Retry-After` takes precedence. Reauthorization and non-retryable client failures require existing cache invalidation or renewed credentials. Repeated calls cannot bypass those cooldowns. Caller cancellation detaches the tool wait without cancelling a shared surviving consumer; plugin disposal cancels shared work.
|
|
41
|
+
|
|
42
|
+
Call at a resource checkpoint requested by the user or required by an already authorized workflow, rather than before every step. On `unknown`/`stale`, do not assume sufficient or exhausted quota or loop to force freshness. If quota actually blocks required work, preserve the user's goal and quality bar, report the blocker and incomplete validation, and leave a resumable checkpoint where appropriate. Do not skip tests, security checks or required work, silently lower quality, switch models/accounts or create schedules because of a percentage. Any such action needs its own authority.
|
|
43
|
+
|
|
44
|
+
An optional [quota-awareness skill example](skills/codex-quota-awareness/SKILL.md) can be copied deliberately into the user's Host-supported skills location or adapted into an authorized automation's instructions. It is documentation, not automatically registered repository guidance. No scheduler, automatic recovery or frozen Adaptive Task activation is included.
|
|
45
|
+
|
|
46
|
+
Verification uses temporary synthetic accounts and mocked upstream responses. It does not establish live-account behavior, Desktop native acceptance or quota accuracy at the service.
|