dsh-codex-share 0.2.0 → 0.3.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/README.md CHANGED
@@ -4,7 +4,7 @@ A DeepSeek Harness LLM adapter that uses the same ChatGPT subscription login as
4
4
 
5
5
  ## Requirements
6
6
 
7
- - DeepSeek Harness `0.1.5-rc.3` or a compatible later release, with Node.js `^22.19.0 || >=24`.
7
+ - DeepSeek Harness `0.1.7-rc.2` or a compatible later release (0.1.5 releases are no longer supported), with Node.js `^22.19.0 || >=24`.
8
8
  - Codex CLI signed in with a ChatGPT account and configured for **file credential storage**. Run `codex login` and check `codex login status`. Codex must be able to read and update `$CODEX_HOME/auth.json` (default `~/.codex/auth.json`).
9
9
  - The harness process must run as the same OS user, or have read access to that same credential file. A keyring-only Codex login is not supported.
10
10
 
@@ -16,13 +16,15 @@ Install the bundle into a harness profile:
16
16
  dsh plugin --profile web add dsh-codex-share
17
17
  ```
18
18
 
19
- For this checkout before publication, from its directory:
19
+ On a fresh profile, pnpm may stop with `ERR_PNPM_IGNORED_BUILDS` for the pi-ai dependency tree. In `$DSH_HOME/profiles/web/pnpm-workspace.yaml` (default `~/.dsh/profiles/web/pnpm-workspace.yaml`), set the generated `allowBuilds` entries for `@google/genai` and `protobufjs` to `false`, as the harness source workspace does. Then run `dsh plugin --profile web remove dsh-codex-share` followed by the add command again; a failed add can leave the package installed without activating its bundle layer.
20
+
21
+ For development from this checkout, from its directory:
20
22
 
21
23
  ```sh
22
24
  dsh plugin --profile web add .
23
25
  ```
24
26
 
25
- Restart the profile after installation or update. The bundle mounts one provider route, `openai-codex-local`, with the model catalog supplied by pi-ai. This route replaces the plugin's earlier `openai-codex` route, which collides with pi-ai's configurable provider directory; update any saved model selection to `openai-codex-local`. The plugin appears in **Settings → Plugins → Plugin list**. Open **Settings → Models** and use **Edit model IDs** in the OpenAI Codex row to add subscription model IDs (one per line). The installed catalog remains available; clearing the additional IDs restores it. For example, enter `gpt-6-sol` and `gpt-6-luna` if your account can use them. An unrecognized ID can be listed, but requests to it will fail if the Codex endpoint rejects it. Select a listed model in the model picker or agent preset. For a local Codex home outside the default location, set the absolute `CODEX_HOME` path in the environment that launches the harness. Direct Cordis composition can configure `codexHome` on the `dsh-codex-share` plugin instead.
27
+ Restart the profile after installation or update. The bundle mounts one provider route, `openai-codex-local`, with the model catalog supplied by pi-ai plus GPT-6 Sol (`gpt-6-sol`) and GPT-6 Luna (`gpt-6-luna`), whose metadata is taken from pi-ai 0.87 because the harness's pi-ai adapter still runs on pi-ai 0.85. This route replaces the plugin's earlier `openai-codex` route, which collides with pi-ai's configurable provider directory; update any saved model selection to `openai-codex-local`. The plugin appears in **Settings → Plugins → Plugin list**. Open **Settings → Models** and use **Edit model IDs** in the OpenAI Codex row to add subscription model IDs (one per line). The IDs are saved as `additionalModelIds` on the `llm-codex-share` entry in the profile's `cordis.patch.yml` and take effect without a restart. The installed catalog remains available; clearing the additional IDs restores it. For example, enter a model ID that your account can use but the catalog does not list yet. An unrecognized ID can be listed, but requests to it will fail if the Codex endpoint rejects it. Select a listed model in the model picker or agent preset. For a local Codex home outside the default location, set the absolute `CODEX_HOME` path in the environment that launches the harness. Direct Cordis composition can configure `codexHome` on the `dsh-codex-share` plugin instead.
26
28
 
27
29
  The plugin intentionally does not refresh a stale token. When Codex writes a replacement, the next harness request reads it. When Codex's current access token has expired, harness calls fail until Codex refreshes its own login. An API-key-only Codex login is rejected; this route never falls back to `OPENAI_API_KEY`.
28
30
 
@@ -36,4 +38,4 @@ pnpm build
36
38
  pnpm pack
37
39
  ```
38
40
 
39
- The development links in `package.json` point to the adjacent `../deepseek-harness` checkout. Replace those dev links when developing elsewhere; they are not installed by consumers of the published package.
41
+ The development links in `package.json` and local overrides in `pnpm-workspace.yaml` point to the adjacent `../deepseek-harness` checkout. Replace those paths when developing elsewhere; consumers of the published package use the versioned runtime dependencies instead.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
- import { Context } from "@deepseek-ai/cordis";
2
+ import { Context, Volatile } from "@deepseek-ai/cordis";
3
3
  //#region src/auth.d.ts
4
4
  /** Resolve Codex's current auth.json path without retaining a token. */
5
5
  declare function codexAuthPath(codexHome?: string): string;
@@ -15,14 +15,15 @@ declare function readCodexAccessToken(codexHome?: string): Promise<string>;
15
15
  declare const PROVIDER = "openai-codex-local";
16
16
  declare const name = "llm-codex-share";
17
17
  declare const inject: string[];
18
+ /** Settings namespace: the Loader entry id this bundle's patch inserts. */
18
19
  declare const SETTINGS_NS = "llm-codex-share";
19
20
  /** Plugin configuration. Omit codexHome to follow CODEX_HOME or ~/.codex. */
20
21
  interface Config {
21
22
  codexHome?: string;
22
- /** Extra subscription model IDs alongside the installed pi-ai catalog. */
23
- additionalModelIds?: string[];
23
+ /** Extra subscription model IDs alongside the installed pi-ai catalog; edits apply without a restart. */
24
+ additionalModelIds: Volatile<string[]>;
24
25
  }
25
- declare const Config: z<Config>;
26
+ declare const Config: z<Partial<Record<keyof Config, unknown>>, Config>;
26
27
  /** Register the Codex subscription model catalog and stream adapter. */
27
28
  declare function apply(ctx: Context, config?: Config): void;
28
29
  //#endregion
package/dist/index.mjs CHANGED
@@ -42,23 +42,85 @@ async function readCodexAccessToken(codexHome) {
42
42
  const PROVIDER = "openai-codex-local";
43
43
  const name = "llm-codex-share";
44
44
  const inject = ["llm"];
45
+ /** Settings namespace: the Loader entry id this bundle's patch inserts. */
45
46
  const SETTINGS_NS = "llm-codex-share";
46
47
  const Config = z.object({
47
48
  codexHome: z.string(),
48
- additionalModelIds: z.array(z.string().min(1))
49
+ additionalModelIds: z.array(z.string().min(1)).default([]).volatile()
49
50
  });
50
- function validateModelIds(config) {
51
- const ids = config.additionalModelIds;
52
- if (ids !== void 0 && (new Set(ids).size !== ids.length || ids.some((id) => id.trim() !== id))) throw new TypeError("Additional Codex model IDs must be unique, non-empty, and trimmed");
51
+ /**
52
+ * GPT-6 Sol and Luna as pi-ai 0.87 catalogs them. pi-ai 0.87 providers take a
53
+ * different stream context than the dsh 0.1.7 adapter (built on 0.85) sends,
54
+ * so the dependency stays on 0.85 and these entries are added on top of its
55
+ * GPT-6 Astra entry. An installed catalog that already lists an ID wins.
56
+ */
57
+ const GPT6_MODELS = [{
58
+ id: "gpt-6-sol",
59
+ name: "GPT-6 Sol",
60
+ cost: {
61
+ input: 2,
62
+ output: 10,
63
+ cacheRead: .2,
64
+ cacheWrite: 2.5,
65
+ tiers: [{
66
+ inputTokensAbove: 272e3,
67
+ input: 4,
68
+ output: 15,
69
+ cacheRead: .4,
70
+ cacheWrite: 5
71
+ }]
72
+ }
73
+ }, {
74
+ id: "gpt-6-luna",
75
+ name: "GPT-6 Luna",
76
+ cost: {
77
+ input: .1,
78
+ output: .5,
79
+ cacheRead: .01,
80
+ cacheWrite: .125,
81
+ tiers: [{
82
+ inputTokensAbove: 272e3,
83
+ input: .2,
84
+ output: .75,
85
+ cacheRead: .02,
86
+ cacheWrite: .25
87
+ }]
88
+ }
89
+ }];
90
+ const GPT6_THINKING = {
91
+ off: "none",
92
+ minimal: "low",
93
+ low: "low",
94
+ medium: "medium",
95
+ high: "high",
96
+ xhigh: "xhigh",
97
+ max: "max"
98
+ };
99
+ function validateModelIds(ids) {
100
+ if (new Set(ids).size !== ids.length || ids.some((id) => id.trim() !== id)) throw new TypeError("Additional Codex model IDs must be unique, non-empty, and trimmed");
53
101
  }
54
102
  /** Register the Codex subscription model catalog and stream adapter. */
55
- function apply(ctx, config = {}) {
56
- validateModelIds(config);
57
- let current = () => config;
58
- let lastConfig;
103
+ function apply(ctx, config = Config({})) {
104
+ validateModelIds(config.additionalModelIds.get());
105
+ ctx.on("internal/config", function(_raw, next) {
106
+ const raw = next();
107
+ if (this === ctx.fiber) validateModelIds(Config(raw).additionalModelIds.get());
108
+ return raw;
109
+ });
110
+ let lastIds;
59
111
  let profiles;
60
112
  const upstream = openaiCodexProvider();
61
- const catalog = upstream.getModels();
113
+ const installed = upstream.getModels();
114
+ const astra = installed.find((model) => model.id === "gpt-6-astra");
115
+ const catalog = astra === void 0 ? installed : [...installed, ...GPT6_MODELS.filter((extra) => !installed.some((model) => model.id === extra.id)).map((extra) => ({
116
+ ...astra,
117
+ ...extra,
118
+ thinkingLevelMap: GPT6_THINKING,
119
+ cost: {
120
+ ...extra.cost,
121
+ tiers: [...extra.cost.tiers]
122
+ }
123
+ }))];
62
124
  const profileBase = {
63
125
  provider: PROVIDER,
64
126
  displayName: "OpenAI Codex (local login)",
@@ -79,9 +141,9 @@ function apply(ctx, config = {}) {
79
141
  }
80
142
  };
81
143
  const resolveProfiles = () => {
82
- const active = current();
83
- if (active === lastConfig && profiles !== void 0) return profiles;
84
- const ids = active.additionalModelIds?.filter((id) => !catalog.some((model) => model.id === id)) ?? [];
144
+ const configured = config.additionalModelIds.get();
145
+ if (configured === lastIds && profiles !== void 0) return profiles;
146
+ const ids = configured.filter((id) => !catalog.some((model) => model.id === id));
85
147
  const models = [...catalog, ...ids.map((id) => {
86
148
  const family = id.endsWith("-luna") ? "gpt-5.6-luna" : id.endsWith("-sol") ? "gpt-5.6-sol" : "gpt-6-astra";
87
149
  return {
@@ -103,12 +165,12 @@ function apply(ctx, config = {}) {
103
165
  ...profileBase,
104
166
  piProvider: provider
105
167
  }]]);
106
- lastConfig = active;
168
+ lastIds = configured;
107
169
  return profiles;
108
170
  };
109
171
  const adapter = new PiAiAdapter({
110
172
  profiles: resolveProfiles,
111
- resolveApiKey: async () => readCodexAccessToken(current().codexHome),
173
+ resolveApiKey: async () => readCodexAccessToken(config.codexHome),
112
174
  resolveAttachments: () => ctx.get("attachments"),
113
175
  resolveImageAccess: (attachments, ref) => resolveImageAttachmentAccess(attachments, (hostPath) => ctx.get("fs")?.processPathFromHostPath(hostPath), ref),
114
176
  auth: {
@@ -135,15 +197,6 @@ function apply(ctx, config = {}) {
135
197
  settingsPath: []
136
198
  }]);
137
199
  ctx.llm.registerAdapter([PROVIDER], adapter);
138
- ctx.inject(["settings"], (settingsCtx) => {
139
- settingsCtx.settings.installSection(ctx, SETTINGS_NS, Config, config, {
140
- validate: validateModelIds,
141
- setSource: (source) => {
142
- current = source;
143
- },
144
- onChange: () => {}
145
- });
146
- });
147
200
  }
148
201
  //#endregion
149
202
  export { Config, PROVIDER, SETTINGS_NS, apply, codexAuthPath, inject, name, readCodexAccessToken };
package/lib/client.js CHANGED
@@ -3,6 +3,7 @@ const module = { exports: {} }; const exports = module.exports;
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  let react = require("react");
5
5
  //#region src/client/index.ts
6
+ const SETTINGS_NS = "llm-codex-share";
6
7
  function CodexModelsCard(props) {
7
8
  const settings = props.useSettings((snapshot) => snapshot);
8
9
  const configured = settings.value?.additionalModelIds ?? [];
@@ -23,11 +24,12 @@ function CodexModelsCard(props) {
23
24
  setBusy(true);
24
25
  setMessage(void 0);
25
26
  try {
26
- const error = await props.save(ids, settings.revision);
27
- if (error === void 0) {
27
+ if (await props.save(ids, settings.revision)) {
28
28
  setEditing(false);
29
29
  setMessage("Codex model IDs saved.");
30
- } else setMessage(error);
30
+ } else setMessage("The harness refused these model IDs; the saved list is unchanged.");
31
+ } catch (error) {
32
+ setMessage(error instanceof Error ? error.message : String(error));
31
33
  } finally {
32
34
  setBusy(false);
33
35
  }
@@ -84,30 +86,22 @@ function CodexModelsCard(props) {
84
86
  }, "Edit model IDs")];
85
87
  return (0, react.createElement)("div", { style: { padding: "8px 0" } }, ...children, message === void 0 ? null : (0, react.createElement)("p", { role: "status" }, message));
86
88
  }
87
- const inject = [
88
- "slots",
89
- "settingsScope",
90
- "remote",
91
- "remote.settings"
92
- ];
89
+ const inject = ["slots", "configForms"];
93
90
  function apply(ctx) {
94
- const scope = ctx.settingsScope.bind({ namespace: "llm-codex-share" });
91
+ const form = ctx.configForms.get(SETTINGS_NS);
95
92
  ctx.slots.inject("settings.models.provider-card", () => ctx.slots.register({
96
93
  name: "settings.models.provider-card",
97
- key: "llm-codex-share",
94
+ key: SETTINGS_NS,
98
95
  inject: () => ({
99
- hooks: { settings: scope },
100
- save: async (ids, revision) => {
101
- const response = await ctx.remote.settings.mutate("llm-codex-share", [ids.length === 0 ? {
102
- op: "unset",
103
- path: ["additionalModelIds"]
104
- } : {
105
- op: "set",
106
- path: ["additionalModelIds"],
107
- value: ids
108
- }], revision);
109
- return response.ok ? void 0 : response.error.message;
110
- }
96
+ hooks: { settings: form },
97
+ save: (ids, revision) => form.mutate([ids.length === 0 ? {
98
+ op: "unset",
99
+ path: ["additionalModelIds"]
100
+ } : {
101
+ op: "set",
102
+ path: ["additionalModelIds"],
103
+ value: ids
104
+ }], revision)
111
105
  })
112
106
  }, CodexModelsCard));
113
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-codex-share",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Use the local Codex CLI ChatGPT subscription login as a DeepSeek Harness LLM provider",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -35,14 +35,20 @@
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@deepseek-ai/cordis": "^4.0.2",
38
- "@deepseek-ai/dsh-attachment": "^0.1.5-rc.3",
39
- "@deepseek-ai/dsh-fs": "^0.1.5-rc.3",
40
- "@deepseek-ai/dsh-llm": "^0.1.5-rc.3",
41
- "@deepseek-ai/dsh-llm-pi-ai": "^0.1.5-rc.3",
42
- "@deepseek-ai/dsh-settings": "^0.1.5-rc.3",
38
+ "@deepseek-ai/dsh-attachment": "^0.1.7-rc.2",
39
+ "@deepseek-ai/dsh-fs": "^0.1.7-rc.2",
40
+ "@deepseek-ai/dsh-llm": "^0.1.7-rc.2",
41
+ "@deepseek-ai/dsh-llm-pi-ai": "^0.1.7-rc.2",
43
42
  "@deepseek-ai/schemastery": "^3.18.2"
44
43
  },
45
44
  "dependencies": {
45
+ "@deepseek-ai/cordis": "^4.0.2",
46
+ "@deepseek-ai/dsh-attachment": "^0.1.7-rc.2",
47
+ "@deepseek-ai/dsh-credentials": "^0.1.7-rc.2",
48
+ "@deepseek-ai/dsh-launch-environment": "^0.1.7-rc.2",
49
+ "@deepseek-ai/dsh-llm": "^0.1.7-rc.2",
50
+ "@deepseek-ai/dsh-llm-pi-ai": "^0.1.7-rc.2",
51
+ "@deepseek-ai/schemastery": "^3.18.2",
46
52
  "@earendil-works/pi-ai": "^0.85.1"
47
53
  },
48
54
  "devDependencies": {