@young1lin/dsh-gpt-sub 0.1.0
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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +268 -0
- package/client.js +908 -0
- package/cordis.patch.yml +44 -0
- package/lib/index.d.ts +52 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +581 -0
- package/lib/index.js.map +1 -0
- package/lib/jwt.d.ts +15 -0
- package/lib/jwt.d.ts.map +1 -0
- package/lib/jwt.js +29 -0
- package/lib/jwt.js.map +1 -0
- package/lib/proxy-config.d.ts +91 -0
- package/lib/proxy-config.d.ts.map +1 -0
- package/lib/proxy-config.js +213 -0
- package/lib/proxy-config.js.map +1 -0
- package/lib/proxy-probe.d.ts +47 -0
- package/lib/proxy-probe.d.ts.map +1 -0
- package/lib/proxy-probe.js +51 -0
- package/lib/proxy-probe.js.map +1 -0
- package/lib/proxy-routing.d.ts +111 -0
- package/lib/proxy-routing.d.ts.map +1 -0
- package/lib/proxy-routing.js +171 -0
- package/lib/proxy-routing.js.map +1 -0
- package/lib/quota-route.d.ts +85 -0
- package/lib/quota-route.d.ts.map +1 -0
- package/lib/quota-route.js +105 -0
- package/lib/quota-route.js.map +1 -0
- package/lib/reset-credits.d.ts +64 -0
- package/lib/reset-credits.d.ts.map +1 -0
- package/lib/reset-credits.js +84 -0
- package/lib/reset-credits.js.map +1 -0
- package/lib/token-store.d.ts +107 -0
- package/lib/token-store.d.ts.map +1 -0
- package/lib/token-store.js +228 -0
- package/lib/token-store.js.map +1 -0
- package/lib/types.d.ts +18 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/usage.d.ts +92 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +106 -0
- package/lib/usage.js.map +1 -0
- package/package.json +82 -0
- package/src/index.ts +685 -0
- package/src/jwt.ts +26 -0
- package/src/proxy-config.ts +217 -0
- package/src/proxy-probe.ts +81 -0
- package/src/proxy-routing.ts +205 -0
- package/src/quota-route.ts +163 -0
- package/src/reset-credits.ts +128 -0
- package/src/token-store.ts +309 -0
- package/src/types.ts +17 -0
- package/src/usage.ts +154 -0
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# dsh-gpt-sub bundle patch, two rows over the profile root.
|
|
2
|
+
#
|
|
3
|
+
# Row 1 (insert): the plugin itself -- token sync, host-scoped proxy routing,
|
|
4
|
+
# and the quota panel. Later user patch layers address this row by id and
|
|
5
|
+
# replace its whole config.
|
|
6
|
+
#
|
|
7
|
+
# Row 2 (edit, no insert:): seeds the llm-pi-ai route that turns the token
|
|
8
|
+
# this plugin publishes into selectable models with zero user configuration.
|
|
9
|
+
# It edits the dormant llm-pi-ai row @deepseek-ai/dsh-base inserts, so that
|
|
10
|
+
# bundle must come earlier in dsh.profile.bundles; a missing row is warned
|
|
11
|
+
# and skipped by the loader, not an error. A user `llm-pi-ai:` settings
|
|
12
|
+
# section merges per provider on top of this, so providers declared there are
|
|
13
|
+
# additive and field edits win.
|
|
14
|
+
- insert:
|
|
15
|
+
- id: gpt-sub
|
|
16
|
+
name: '@young1lin/dsh-gpt-sub'
|
|
17
|
+
config:
|
|
18
|
+
# Proxy for reaching the Codex hosts. Empty means direct.
|
|
19
|
+
proxyUrl: 'http://127.0.0.1:7890'
|
|
20
|
+
# Codex CLI credential file, shared with the codex command.
|
|
21
|
+
authFile: '~/.codex/auth.json'
|
|
22
|
+
# Refresh the access token when less than this many minutes remain.
|
|
23
|
+
refreshMarginMinutes: 30
|
|
24
|
+
# Credential the seeded openai-codex route reads as its api-key auth.
|
|
25
|
+
# Must match the apiKeyEnv in the llm-pi-ai row below; the regression
|
|
26
|
+
# test in tests/cordis-patch.spec.ts holds them together.
|
|
27
|
+
tokenRef: 'CODEX_NATIVE_TOKEN'
|
|
28
|
+
# How often to re-read auth.json and republish the token.
|
|
29
|
+
syncIntervalMinutes: 10
|
|
30
|
+
# Edit row against the dsh-base row: a patch replaces the whole config block,
|
|
31
|
+
# and dsh-base ships the row with no config, so this only adds the route.
|
|
32
|
+
- id: llm-pi-ai
|
|
33
|
+
name: '@deepseek-ai/dsh-llm-pi-ai'
|
|
34
|
+
config:
|
|
35
|
+
providers:
|
|
36
|
+
openai-codex:
|
|
37
|
+
# The live Codex access token dsh-gpt-sub republishes. Naming it
|
|
38
|
+
# grafts an api-key method beside the catalog provider's OAuth one --
|
|
39
|
+
# exactly the seam the plugin fills.
|
|
40
|
+
apiKeyEnv: 'CODEX_NATIVE_TOKEN'
|
|
41
|
+
displayName: 'Codex Subscription'
|
|
42
|
+
# models omitted on purpose: the installed pi-ai catalog serves
|
|
43
|
+
# gpt-5.6-sol/terra/luna unchanged -- context windows, input
|
|
44
|
+
# modalities, and thinking levels (minimal -> low, xhigh, max).
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct ChatGPT/Codex subscription access for DeepSeek Harness.
|
|
3
|
+
*
|
|
4
|
+
* This plugin owns no transport. pi-ai already ships an `openai-codex`
|
|
5
|
+
* provider that knows the Codex wire format -- it sets `store`, derives
|
|
6
|
+
* `chatgpt-account-id` from the access token's own JWT claim, and speaks the
|
|
7
|
+
* codex-responses protocol -- but it authenticates only through OAuth, and
|
|
8
|
+
* `dsh-llm-pi-ai` runs no login flow and holds no OAuth store. Naming a
|
|
9
|
+
* credential on the route grafts an api-key method beside the provider's own,
|
|
10
|
+
* which is the seam this plugin fills: it keeps a live Codex access token in
|
|
11
|
+
* the harness credential store, refreshing it from `~/.codex/auth.json` before
|
|
12
|
+
* it expires.
|
|
13
|
+
*
|
|
14
|
+
* The result needs no loopback port, no shared local key, and no external
|
|
15
|
+
* proxy binary. The `codex` CLI still owns the login.
|
|
16
|
+
*
|
|
17
|
+
* @module dsh-gpt-sub
|
|
18
|
+
*/
|
|
19
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
20
|
+
import z from '@deepseek-ai/schemastery';
|
|
21
|
+
import type { Config as ConfigShape } from './types.ts';
|
|
22
|
+
export type Config = ConfigShape;
|
|
23
|
+
/** Cordis plugin name. */
|
|
24
|
+
export declare const name = "gpt-sub";
|
|
25
|
+
/**
|
|
26
|
+
* Required services. Without this declaration cordis's context proxy throws
|
|
27
|
+
* `cannot get property "credentials" without inject` the moment the plugin
|
|
28
|
+
* reads `ctx.credentials`, and the plugin sits dead with no retry.
|
|
29
|
+
*/
|
|
30
|
+
export declare const inject: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Plugin config schema.
|
|
33
|
+
*
|
|
34
|
+
* Typed input-then-output: every field has a default, so a config document may
|
|
35
|
+
* supply any subset, and what comes back out is a fully resolved `ConfigShape`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const Config: z<Partial<ConfigShape>, ConfigShape>;
|
|
38
|
+
/**
|
|
39
|
+
* Publish the current Codex access token into the credential store, and keep
|
|
40
|
+
* publishing it for as long as the plugin is loaded.
|
|
41
|
+
*
|
|
42
|
+
* Async on purpose: cordis awaits a thenable returned from plugin startup and
|
|
43
|
+
* collects the function it resolves to as the fiber's disposer. A missing or
|
|
44
|
+
* unreadable `auth.json` therefore fails the fiber visibly at start instead of
|
|
45
|
+
* leaving a route configured against a credential nothing maintains.
|
|
46
|
+
*
|
|
47
|
+
* @param ctx - the cordis context.
|
|
48
|
+
* @param config - validated plugin configuration.
|
|
49
|
+
* @returns the teardown that stops the sync timer and closes the dispatcher.
|
|
50
|
+
*/
|
|
51
|
+
export declare function apply(ctx: Context, config: ConfigShape): Promise<() => Promise<void>>;
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAsBxC,OAAO,KAAK,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,YAAY,CAAA;AAKvD,MAAM,MAAM,MAAM,GAAG,WAAW,CAAA;AAEhC,0BAA0B;AAC1B,eAAO,MAAM,IAAI,YAAY,CAAA;AAE7B;;;;GAIG;AACH,eAAO,MAAM,MAAM,UAA+B,CAAA;AA2ClD;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,WAAW,CAqBtD,CAAA;AAOF;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAwhB3F"}
|