@tnnevol/dsh-codex-auth 0.1.1-rc.3.1 → 0.1.2-rc.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.
@@ -4,7 +4,7 @@
4
4
  "node": "^22.19.0 || >=24.0.0"
5
5
  },
6
6
  "dshPluginApi": {
7
- "version": "0.1.1-rc.2",
7
+ "version": "0.1.2-rc.1",
8
8
  "packages": [
9
9
  "@deepseek-ai/dsh-atomic-write",
10
10
  "@deepseek-ai/dsh-attachment",
@@ -21,6 +21,6 @@
21
21
  },
22
22
  "piAi": {
23
23
  "package": "@earendil-works/pi-ai",
24
- "version": "0.82.1"
24
+ "version": "0.84.2"
25
25
  }
26
26
  }
@@ -4,7 +4,7 @@ import { mkdir, readFile, rm, stat } from "node:fs/promises";
4
4
  import { dirname, join, resolve } from "node:path";
5
5
  import { withFileLock, writeFileAtomic } from "@deepseek-ai/dsh-atomic-write";
6
6
  import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
7
- //#region src/store.ts
7
+ //#region src/host/store.ts
8
8
  /** Owner-only persistent storage for the shared OpenAI Codex OAuth document. */
9
9
  /** pi-ai provider id used by ChatGPT Codex OAuth. */
10
10
  const CODEX_PROVIDER = "openai-codex";
@@ -118,7 +118,7 @@ var CodexCredentialStore = class {
118
118
  }
119
119
  };
120
120
  //#endregion
121
- //#region src/auth.ts
121
+ //#region src/host/auth.ts
122
122
  /** ChatGPT OAuth orchestration used by the Host routes and CLI consumers. */
123
123
  /** Start provider-native ChatGPT OAuth and persist its credential. */
124
124
  async function loginCodex(interaction, store = new CodexCredentialStore()) {
@@ -1,5 +1,5 @@
1
1
  import { AuthInteraction, Credential, CredentialInfo, CredentialStore } from "@earendil-works/pi-ai";
2
- //#region src/store.d.ts
2
+ //#region src/host/store.d.ts
3
3
  /** pi-ai provider id used by ChatGPT Codex OAuth. */
4
4
  declare const CODEX_PROVIDER = "openai-codex";
5
5
  /** Kept compatible with dsh-codex-connect so a login can be reused. */
@@ -16,7 +16,7 @@ declare class CodexCredentialStore implements CredentialStore {
16
16
  delete(providerId: string): Promise<void>;
17
17
  }
18
18
  //#endregion
19
- //#region src/auth.d.ts
19
+ //#region src/host/auth.d.ts
20
20
  interface CodexAuthStatus {
21
21
  authenticated: boolean;
22
22
  expiresAt?: Date;
@@ -1,4 +1,4 @@
1
- //#region src/auth-paths.d.ts
1
+ //#region src/contracts/auth-paths.d.ts
2
2
  /** Browser-facing paths owned by the standalone Codex authentication plugin. */
3
3
  /** Host settings namespace used to dispatch the browser settings card. */
4
4
  declare const CODEX_AUTH_SETTINGS_NAMESPACE = "dsh-codex-auth";
package/lib/auth-paths.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/auth-paths.ts
1
+ //#region src/contracts/auth-paths.ts
2
2
  /** Browser-facing paths owned by the standalone Codex authentication plugin. */
3
3
  /** Host settings namespace used to dispatch the browser settings card. */
4
4
  const CODEX_AUTH_SETTINGS_NAMESPACE = "dsh-codex-auth";
package/lib/auth.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as logoutCodex, n as codexAuthStatus, r as loginCodex, t as CodexAuthStatus } from "./auth-BBBeI24-.js";
1
+ import { i as logoutCodex, n as codexAuthStatus, r as loginCodex, t as CodexAuthStatus } from "./auth-DyHxRsSd.js";
2
2
  export { CodexAuthStatus, codexAuthStatus, loginCodex, logoutCodex };
package/lib/auth.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as loginCodex, r as logoutCodex, t as codexAuthStatus } from "./auth-DQ2F4vc6.js";
1
+ import { n as loginCodex, r as logoutCodex, t as codexAuthStatus } from "./auth-BdEwtK4R.js";
2
2
  export { codexAuthStatus, loginCodex, logoutCodex };
package/lib/client.js CHANGED
@@ -47108,7 +47108,12 @@ window.__ModuleLoader__.load({
47108
47108
  };
47109
47109
  }
47110
47110
  //#endregion
47111
- //#region src/client/CodexCapabilities.tsx
47111
+ //#region src/client/services/image-capability-message.ts
47112
+ function formatImageGenerationHelp(t, dshVersion) {
47113
+ return t("imageGenerationUnavailableHelp").replace("{version}", dshVersion ?? "unknown");
47114
+ }
47115
+ //#endregion
47116
+ //#region src/components/CodexCapabilities.tsx
47112
47117
  /** Live optional-capability settings for the Codex Auth plugin. */
47113
47118
  const UNAVAILABLE_SNAPSHOT = {
47114
47119
  status: "unavailable",
@@ -47120,7 +47125,7 @@ window.__ModuleLoader__.load({
47120
47125
  mode: "memory"
47121
47126
  };
47122
47127
  /** Render the capability controls with the same Save/Discard contract as DSH settings. */
47123
- function CodexCapabilities({ scope, t }) {
47128
+ function CodexCapabilities({ scope, t, dshVersion }) {
47124
47129
  const subscribe = (0, react.useCallback)((listener) => scope?.subscribe(listener) ?? (() => void 0), [scope]);
47125
47130
  const getSnapshot = (0, react.useCallback)(() => scope?.getSnapshot() ?? UNAVAILABLE_SNAPSHOT, [scope]);
47126
47131
  const snapshot = (0, react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
@@ -47179,6 +47184,7 @@ window.__ModuleLoader__.load({
47179
47184
  };
47180
47185
  const loading = snapshot.status === "loading";
47181
47186
  const editable = snapshot.status === "ready" && snapshot.writable && !busy;
47187
+ const imageGenerationHelp = formatImageGenerationHelp(t, dshVersion);
47182
47188
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
47183
47189
  className: "dsh-codex-capabilities",
47184
47190
  "aria-labelledby": "dsh-codex-capabilities-title",
@@ -47250,7 +47256,7 @@ window.__ModuleLoader__.load({
47250
47256
  }),
47251
47257
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
47252
47258
  className: "dsh-codex-capability-row dsh-codex-capability-row--disabled",
47253
- title: t("imageGenerationUnavailableHelp"),
47259
+ title: imageGenerationHelp,
47254
47260
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckboxWithGroup, {
47255
47261
  checked: false,
47256
47262
  disabled: true,
@@ -47262,7 +47268,7 @@ window.__ModuleLoader__.load({
47262
47268
  children: t("enableImageGeneration")
47263
47269
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
47264
47270
  className: "dsh-codex-body",
47265
- children: t("imageGenerationUnavailableHelp")
47271
+ children: imageGenerationHelp
47266
47272
  })]
47267
47273
  })
47268
47274
  })
@@ -47308,7 +47314,7 @@ window.__ModuleLoader__.load({
47308
47314
  });
47309
47315
  }
47310
47316
  //#endregion
47311
- //#region src/auth-paths.ts
47317
+ //#region src/contracts/auth-paths.ts
47312
47318
  /** Browser-facing paths owned by the standalone Codex authentication plugin. */
47313
47319
  /** Host settings namespace used to dispatch the browser settings card. */
47314
47320
  const CODEX_AUTH_SETTINGS_NAMESPACE = "dsh-codex-auth";
@@ -47321,7 +47327,30 @@ window.__ModuleLoader__.load({
47321
47327
  /** Same-origin endpoint for the DSH-wide Codex default model selection. */
47322
47328
  const CODEX_GLOBAL_MODEL_PATH = "/plugins/dsh-codex-auth-plugin/auth/global-model";
47323
47329
  //#endregion
47324
- //#region src/client/CodexGlobalModel.tsx
47330
+ //#region src/client/services/model-catalog.ts
47331
+ function errorMessage(error, fallback) {
47332
+ return error?.message || fallback;
47333
+ }
47334
+ /**
47335
+ * Read the host model catalog from the alpha.4 Remote API, with a guarded
47336
+ * legacy fallback for mixed deployments that still expose the old connection
47337
+ * API.
47338
+ */
47339
+ async function loadCodexModelCatalog(connection, remote) {
47340
+ const modern = remote?.session?.modelCatalog;
47341
+ if (typeof modern === "function") {
47342
+ const result = await modern();
47343
+ if (!result.ok) throw new Error(errorMessage(result.error, "DSH model catalog request failed"));
47344
+ return result.value;
47345
+ }
47346
+ const legacy = connection.api?.llm?.models;
47347
+ if (typeof legacy !== "function") throw new Error("DSH model catalog API is unavailable");
47348
+ const response = await legacy({});
47349
+ if (!response.result.ok) throw new Error(errorMessage(response.result.error, "DSH model catalog request failed"));
47350
+ return response.result.value;
47351
+ }
47352
+ //#endregion
47353
+ //#region src/components/CodexGlobalModel.tsx
47325
47354
  /** DSH-wide Codex default model controls. */
47326
47355
  async function request(method, body) {
47327
47356
  const response = await fetch(CODEX_GLOBAL_MODEL_PATH, {
@@ -47410,7 +47439,7 @@ window.__ModuleLoader__.load({
47410
47439
  });
47411
47440
  }
47412
47441
  /** Set the model used by new DSH sessions and the host-backed agent entry point. */
47413
- function CodexGlobalModel({ connection, t }) {
47442
+ function CodexGlobalModel({ connection, remote, t }) {
47414
47443
  const [models, setModels] = (0, react.useState)([]);
47415
47444
  const [current, setCurrent] = (0, react.useState)();
47416
47445
  const [draftModel, setDraftModel] = (0, react.useState)("");
@@ -47421,9 +47450,8 @@ window.__ModuleLoader__.load({
47421
47450
  const load = (0, react.useCallback)(async () => {
47422
47451
  setStatus("loading");
47423
47452
  try {
47424
- const [global, catalog] = await Promise.all([request("GET"), connection.api.llm.models({})]);
47425
- if (!catalog.result.ok) throw new Error(catalog.result.error.message);
47426
- const available = codexModels(catalog.result.value.groups);
47453
+ const [global, catalog] = await Promise.all([request("GET"), loadCodexModelCatalog(connection, remote)]);
47454
+ const available = codexModels(catalog.groups);
47427
47455
  setModels(available);
47428
47456
  setCurrent(global.globalModel);
47429
47457
  setDraftModel(global.globalModel?.model ?? "");
@@ -47432,7 +47460,7 @@ window.__ModuleLoader__.load({
47432
47460
  } catch {
47433
47461
  setStatus("error");
47434
47462
  }
47435
- }, [connection]);
47463
+ }, [connection, remote]);
47436
47464
  (0, react.useEffect)(() => {
47437
47465
  load();
47438
47466
  }, [load]);
@@ -47572,7 +47600,7 @@ window.__ModuleLoader__.load({
47572
47600
  });
47573
47601
  }
47574
47602
  //#endregion
47575
- //#region src/client/copy-to-clipboard.ts
47603
+ //#region src/client/services/copy-to-clipboard.ts
47576
47604
  async function copyTextToClipboard(text, environment = {}) {
47577
47605
  const navigatorRef = environment.navigator ?? globalThis.navigator;
47578
47606
  const documentRef = environment.document ?? globalThis.document;
@@ -47600,7 +47628,7 @@ window.__ModuleLoader__.load({
47600
47628
  }
47601
47629
  }
47602
47630
  //#endregion
47603
- //#region src/client/usage-windows.ts
47631
+ //#region src/client/services/usage-windows.ts
47604
47632
  /** Shared Codex usage-window selection for settings and composer status. */
47605
47633
  const FIVE_HOUR_WINDOW_SECONDS = 18e3;
47606
47634
  const WEEKLY_WINDOW_SECONDS = 604800;
@@ -47620,7 +47648,7 @@ window.__ModuleLoader__.load({
47620
47648
  return fiveHourWindow(usage) ?? weeklyWindow(usage);
47621
47649
  }
47622
47650
  //#endregion
47623
- //#region src/client/CodexAuthCard.tsx
47651
+ //#region src/components/CodexAuthCard.tsx
47624
47652
  /** Expandable account card for the DSH Plugins settings section. */
47625
47653
  function Chevron({ open }) {
47626
47654
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -47724,8 +47752,8 @@ window.__ModuleLoader__.load({
47724
47752
  })
47725
47753
  });
47726
47754
  }
47727
- /** Render a standalone login/logout card in the rc.8 keyed Plugin slot. */
47728
- function CodexAuthCard({ t, configScope, connection }) {
47755
+ /** Render a standalone login/logout card in the alpha.4 keyed Plugin slot. */
47756
+ function CodexAuthCard({ t, configScope, connection, remote }) {
47729
47757
  if (t === void 0) throw new Error("Codex auth card requires its translation function");
47730
47758
  if (connection === void 0) throw new Error("Codex auth card requires the DSH connection");
47731
47759
  const [open, setOpen] = (0, react.useState)(false);
@@ -47996,18 +48024,20 @@ window.__ModuleLoader__.load({
47996
48024
  }) : null,
47997
48025
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodexGlobalModel, {
47998
48026
  connection,
48027
+ remote,
47999
48028
  t
48000
48029
  }),
48001
48030
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodexCapabilities, {
48002
48031
  scope: configScope,
48003
- t
48032
+ t,
48033
+ dshVersion: status.dshVersion
48004
48034
  })
48005
48035
  ]
48006
48036
  }) : null]
48007
48037
  });
48008
48038
  }
48009
48039
  //#endregion
48010
- //#region src/client/usage-status-data.ts
48040
+ //#region src/client/services/usage-status-data.ts
48011
48041
  async function readJson(path) {
48012
48042
  const response = await fetch(path, {
48013
48043
  method: "GET",
@@ -48027,7 +48057,7 @@ window.__ModuleLoader__.load({
48027
48057
  return usage;
48028
48058
  }
48029
48059
  //#endregion
48030
- //#region src/client/CodexUsageStatus.tsx
48060
+ //#region src/components/CodexUsageStatus.tsx
48031
48061
  /** Compact Codex quota readout for the conversation composer dock. */
48032
48062
  function percent(value) {
48033
48063
  if (value === void 0 || !Number.isFinite(value)) return void 0;
@@ -48233,7 +48263,7 @@ window.__ModuleLoader__.load({
48233
48263
  });
48234
48264
  }
48235
48265
  //#endregion
48236
- //#region src/settings-contract.ts
48266
+ //#region src/contracts/settings-contract.ts
48237
48267
  const DEFAULT_CODEX_AUTH_SETTINGS = Object.freeze({
48238
48268
  enableImageTool: false,
48239
48269
  enableImageUpload: false
@@ -48250,7 +48280,7 @@ window.__ModuleLoader__.load({
48250
48280
  };
48251
48281
  }
48252
48282
  //#endregion
48253
- //#region src/client/model-editor-presentation.ts
48283
+ //#region src/client/services/model-editor-presentation.ts
48254
48284
  /** Keep Codex-specific fields out of the generic pi-ai editor. */
48255
48285
  const CODEX_EDITOR_ATTRIBUTE = "data-dsh-codex-auth-editor";
48256
48286
  const CODEX_ROUTE = "openai-codex";
@@ -48765,7 +48795,7 @@ window.__ModuleLoader__.load({
48765
48795
  };
48766
48796
  }
48767
48797
  //#endregion
48768
- //#region src/client/remote-settings-scope.ts
48798
+ //#region src/client/services/remote-settings-scope.ts
48769
48799
  const INITIAL_SNAPSHOT = {
48770
48800
  status: "loading",
48771
48801
  value: void 0,
@@ -48853,6 +48883,28 @@ window.__ModuleLoader__.load({
48853
48883
  });
48854
48884
  });
48855
48885
  }
48886
+ mutate(ops, _expectedRevision) {
48887
+ return this.enqueue(async () => {
48888
+ const current = this.getSnapshot().value;
48889
+ if (current === void 0) throw new Error("Codex settings are not loaded");
48890
+ const next = { ...current };
48891
+ for (const op of ops) {
48892
+ if (op.path.length !== 1 || op.path[0] !== "enableImageTool" && op.path[0] !== "enableImageUpload") throw new Error(`Unsupported Codex settings path: ${op.path.join(".")}`);
48893
+ const field = op.path[0];
48894
+ if (op.op === "unset") next[field] = false;
48895
+ else if (typeof op.value !== "boolean") throw new TypeError(`Codex setting ${field} must be boolean`);
48896
+ else next[field] = op.value;
48897
+ }
48898
+ const accepted = await requestSettings("PUT", next);
48899
+ if (this.disposed) return;
48900
+ this.publish({
48901
+ ...this.snapshot,
48902
+ status: "ready",
48903
+ value: accepted,
48904
+ writable: true
48905
+ });
48906
+ });
48907
+ }
48856
48908
  unset(field) {
48857
48909
  return this.set(field, false);
48858
48910
  }
@@ -48926,7 +48978,7 @@ window.__ModuleLoader__.load({
48926
48978
  enableImageUpload: "Enable image upload",
48927
48979
  enableImageUploadHelp: "Allow image-capable Codex models to receive images pasted or dropped into the conversation.",
48928
48980
  enableImageGeneration: "Enable image generation",
48929
- imageGenerationUnavailableHelp: "Not supported by the Codex provider and DSH rc.8 model adapter.",
48981
+ imageGenerationUnavailableHelp: "Not supported by the Codex provider and DSH {version} model adapter.",
48930
48982
  settingsLoading: "Loading plugin settings…",
48931
48983
  settingsUnavailable: "Plugin settings are unavailable in this dsh profile.",
48932
48984
  settingsReadOnly: "This profile exposes plugin settings as read-only.",
@@ -48995,7 +49047,7 @@ window.__ModuleLoader__.load({
48995
49047
  enableImageUpload: "启用图片上传",
48996
49048
  enableImageUploadHelp: "允许具备图片输入能力的 Codex 模型接收粘贴或拖入对话的图片。",
48997
49049
  enableImageGeneration: "启用图像生成",
48998
- imageGenerationUnavailableHelp: "当前 Codex 提供方和 DSH rc.8 模型适配器暂不支持图像输出。",
49050
+ imageGenerationUnavailableHelp: "当前 Codex 提供方和 DSH {version} 模型适配器暂不支持图像输出。",
48999
49051
  settingsLoading: "正在加载插件设置…",
49000
49052
  settingsUnavailable: "此 dsh profile 无法使用插件设置。",
49001
49053
  settingsReadOnly: "此 profile 的插件设置为只读。",
@@ -49023,6 +49075,7 @@ window.__ModuleLoader__.load({
49023
49075
  "locale",
49024
49076
  "connection",
49025
49077
  "remote",
49078
+ "remote.session",
49026
49079
  "settingsScope",
49027
49080
  "timer"
49028
49081
  ];
@@ -49036,6 +49089,7 @@ window.__ModuleLoader__.load({
49036
49089
  }), "dsh-codex-auth-plugin: locale");
49037
49090
  const t = ctx.locale.bind(namespace);
49038
49091
  const connection = ctx.get("connection");
49092
+ const remote = ctx.remote;
49039
49093
  const timer = ctx.get("timer");
49040
49094
  const remoteScope = connection.isLoopback ? void 0 : new CodexAuthRemoteSettingsScope();
49041
49095
  const configScope = remoteScope ?? ctx.settingsScope.bind({
@@ -49054,7 +49108,8 @@ window.__ModuleLoader__.load({
49054
49108
  inject: () => ({
49055
49109
  t,
49056
49110
  configScope,
49057
- connection
49111
+ connection,
49112
+ remote
49058
49113
  })
49059
49114
  }, CodexAuthCard));
49060
49115
  ctx.slots.inject("conversation.input.right", () => ctx.slots.register({
package/lib/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { CODEX_AUTH_LOGIN_PATH, CODEX_AUTH_LOGOUT_PATH, CODEX_AUTH_SETTINGS_NAMESPACE, CODEX_AUTH_STATUS_PATH, CODEX_GLOBAL_MODEL_PATH } from "./auth-paths.js";
2
- import { a as CODEX_AUTH_FILENAME, c as codexAuthPath, i as logoutCodex, n as codexAuthStatus, o as CODEX_PROVIDER, r as loginCodex, s as CodexCredentialStore, t as CodexAuthStatus } from "./auth-BBBeI24-.js";
2
+ import { a as CODEX_AUTH_FILENAME, c as codexAuthPath, i as logoutCodex, n as codexAuthStatus, o as CODEX_PROVIDER, r as loginCodex, s as CodexCredentialStore, t as CodexAuthStatus } from "./auth-DyHxRsSd.js";
3
3
  import { CredentialProvider } from "@deepseek-ai/dsh-credentials";
4
- import "@deepseek-ai/dsh-settings";
5
4
  import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
6
5
  import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
7
6
  import { Context } from "@deepseek-ai/cordis";
8
7
  import { IncomingMessage } from "node:http";
9
- //#region src/credential-mirror.d.ts
8
+ import "@deepseek-ai/dsh-settings";
9
+ //#region src/host/credential-mirror.d.ts
10
10
  /** Credential reference exposed to the official `llm-pi-ai` model settings UI. */
11
11
  declare const CODEX_API_KEY_ENV = "OPENAI_CODEX_AUTH_TOKEN";
12
12
  declare const CODEX_API_KEY_REF: import("@deepseek-ai/dsh-credentials").CredentialRef;
@@ -31,13 +31,13 @@ declare class CodexCredentialMirror {
31
31
  private syncNow;
32
32
  }
33
33
  //#endregion
34
- //#region src/adapter.d.ts
34
+ //#region src/host/adapter.d.ts
35
35
  /** Keep the Codex stream open while the provider is still producing output. */
36
36
  declare const CODEX_STREAM_IDLE_TIMEOUT_MS = 300000;
37
37
  /** Create the dsh LLM adapter for the provider-native OpenAI Codex catalog. */
38
38
  declare function createCodexAdapter(credentials: CodexCredentialStore, resolveAttachments: () => AttachmentStore | undefined): PiAiAdapter;
39
39
  //#endregion
40
- //#region src/usage.d.ts
40
+ //#region src/host/usage.d.ts
41
41
  interface CodexUsageWindow {
42
42
  remainingPercent?: number;
43
43
  limitWindowSeconds?: number;
@@ -70,7 +70,7 @@ declare class CodexUsageService {
70
70
  private readNow;
71
71
  }
72
72
  //#endregion
73
- //#region src/auth-routes.d.ts
73
+ //#region src/host/auth-routes.d.ts
74
74
  type CodexWebAuthStatus = {
75
75
  status: 'signed-out';
76
76
  } | {
package/lib/index.js CHANGED
@@ -1,16 +1,15 @@
1
- import { a as CODEX_PROVIDER, i as CODEX_AUTH_FILENAME, n as loginCodex, o as CodexCredentialStore, r as logoutCodex, s as codexAuthPath, t as codexAuthStatus } from "./auth-DQ2F4vc6.js";
1
+ import { a as CODEX_PROVIDER, i as CODEX_AUTH_FILENAME, n as loginCodex, o as CodexCredentialStore, r as logoutCodex, s as codexAuthPath, t as codexAuthStatus } from "./auth-BdEwtK4R.js";
2
2
  import { CODEX_AUTH_LOGIN_PATH, CODEX_AUTH_LOGOUT_PATH, CODEX_AUTH_SETTINGS_NAMESPACE, CODEX_AUTH_SETTINGS_PATH, CODEX_AUTH_STATUS_PATH, CODEX_GLOBAL_MODEL_PATH, CODEX_USAGE_PATH } from "./auth-paths.js";
3
+ import { APP_IDENTITY, createUserMessage, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
3
4
  import { createModels, defaultProviderAuthContext } from "@earendil-works/pi-ai";
4
5
  import { openaiCodexProvider } from "@earendil-works/pi-ai/providers/openai-codex";
5
6
  import { basename } from "node:path";
6
7
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
7
8
  import z from "@deepseek-ai/schemastery";
8
- import { settingsNamespace } from "@deepseek-ai/dsh-settings";
9
9
  import { AttachmentId } from "@deepseek-ai/dsh-attachment";
10
- import { createUserMessage, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
11
10
  import { defineTool } from "@deepseek-ai/dsh-tools";
12
11
  import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
13
- //#region src/usage.ts
12
+ //#region src/host/usage.ts
14
13
  /** Read-only Codex account quota information for the local settings card. */
15
14
  const CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
16
15
  const CODEX_USAGE_TIMEOUT_MS = 1e4;
@@ -136,7 +135,7 @@ var CodexUsageService = class {
136
135
  }
137
136
  };
138
137
  //#endregion
139
- //#region src/settings-contract.ts
138
+ //#region src/contracts/settings-contract.ts
140
139
  const DEFAULT_CODEX_AUTH_SETTINGS = Object.freeze({
141
140
  enableImageTool: false,
142
141
  enableImageUpload: false
@@ -153,13 +152,19 @@ function decodeCodexAuthSettings(value) {
153
152
  };
154
153
  }
155
154
  //#endregion
156
- //#region src/auth-routes.ts
155
+ //#region src/host/auth-routes.ts
157
156
  const CODEX_AUTH_URL_TIMEOUT_MS = 3e4;
158
157
  const REMOTE_WEB_ORIGIN_NOT_TRUSTED = "remote-web-origin-not-trusted";
159
158
  const CODEX_USAGE_UNAVAILABLE = "codex-usage-unavailable";
160
159
  const CODEX_SETTINGS_INVALID = "codex-settings-invalid";
161
160
  const CODEX_GLOBAL_MODEL_INVALID = "codex-global-model-invalid";
162
161
  const CODEX_SETTINGS_BODY_LIMIT = 8192;
162
+ function withDshVersion(status) {
163
+ return {
164
+ ...status,
165
+ dshVersion: APP_IDENTITY.version
166
+ };
167
+ }
163
168
  function signedInStatus(expiresAt) {
164
169
  return expiresAt === void 0 ? { status: "signed-in" } : {
165
170
  status: "signed-in",
@@ -411,7 +416,7 @@ function decodeGlobalModelWrite(value) {
411
416
  ...typeof record.reasoningEffort === "string" ? { reasoningEffort: record.reasoningEffort } : {}
412
417
  };
413
418
  }
414
- /** Register the plugin-owned bridge to DSH rc.8's shared Agent default model. */
419
+ /** Register the plugin-owned bridge to DSH alpha.4's shared Agent default model. */
415
420
  function registerCodexGlobalModelRoute(ctx, defaultModel, llm) {
416
421
  ctx.effect(() => {
417
422
  const authorize = (req, res) => {
@@ -489,7 +494,7 @@ function registerCodexAuthRoutes(ctx, store, mirror) {
489
494
  if (req.method !== "GET") return json(res, 405, { error: "method not allowed" });
490
495
  if (!authorize(req, res)) return;
491
496
  try {
492
- json(res, 200, await auth.status());
497
+ json(res, 200, withDshVersion(await auth.status()));
493
498
  } catch (error) {
494
499
  json(res, 500, { error: safeMessage(error) });
495
500
  }
@@ -545,7 +550,7 @@ function registerCodexAuthRoutes(ctx, store, mirror) {
545
550
  }, "dsh-codex-auth-plugin: Web OAuth routes");
546
551
  }
547
552
  //#endregion
548
- //#region src/credential-mirror.ts
553
+ //#region src/host/credential-mirror.ts
549
554
  /** Bridge the plugin-owned OAuth credential into dsh's generic LLM seam. */
550
555
  /** Credential reference exposed to the official `llm-pi-ai` model settings UI. */
551
556
  const CODEX_API_KEY_ENV = "OPENAI_CODEX_AUTH_TOKEN";
@@ -595,17 +600,17 @@ var CodexCredentialMirror = class {
595
600
  }
596
601
  };
597
602
  //#endregion
598
- //#region src/settings.ts
603
+ //#region src/host/settings.ts
599
604
  /** Host settings registration that makes the standalone auth card discoverable. */
600
605
  /** Branded namespace used by the Host settings service. */
601
- const CODEX_AUTH_SETTINGS_NS = settingsNamespace(CODEX_AUTH_SETTINGS_NAMESPACE);
606
+ const CODEX_AUTH_SETTINGS_NS = CODEX_AUTH_SETTINGS_NAMESPACE;
602
607
  /** Settings schema for the plugin card and its optional image capability. */
603
608
  const CodexAuthSettingsSchema = z.object({
604
609
  enableImageTool: z.boolean().default(DEFAULT_CODEX_AUTH_SETTINGS.enableImageTool),
605
610
  enableImageUpload: z.boolean().default(DEFAULT_CODEX_AUTH_SETTINGS.enableImageUpload)
606
611
  });
607
612
  //#endregion
608
- //#region src/view-image.ts
613
+ //#region src/host/view-image.ts
609
614
  /** Optional Codex image-reading tool, modeled on DSH's durable attachment seam. */
610
615
  /** Stable name of the optional image-recognition tool. */
611
616
  const VIEW_IMAGE_TOOL_NAME = "view_image";
@@ -762,15 +767,15 @@ function viewImageTool(ctx) {
762
767
  });
763
768
  }
764
769
  //#endregion
765
- //#region src/adapter.ts
770
+ //#region src/host/adapter.ts
766
771
  /** OpenAI Codex adapter assembled from dsh's public pi-ai extension seam. */
767
772
  /** Keep the Codex stream open while the provider is still producing output. */
768
773
  const CODEX_STREAM_IDLE_TIMEOUT_MS = 3e5;
769
- /** Match DSH rc.2's default request-level image payload bound. */
774
+ /** Match DSH alpha.4's default request-level image payload bound. */
770
775
  const CODEX_MAX_REQUEST_IMAGE_BYTES = 20971520;
771
- /** Match DSH rc.2's default per-image total-pixel budget. */
776
+ /** Match DSH alpha.4's default per-image total-pixel budget. */
772
777
  const CODEX_REQUEST_IMAGE_PIXEL_BUDGET = 4194304;
773
- /** Match DSH rc.2's default raw per-image byte budget. */
778
+ /** Match DSH alpha.4's default raw per-image byte budget. */
774
779
  const CODEX_REQUEST_IMAGE_MAX_BYTES = 1048576;
775
780
  /**
776
781
  * Give dsh's generic adapter the bearer token resolved by the plugin-owned
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tnnevol/dsh-codex-auth",
3
3
  "displayName": "Codex Auth",
4
4
  "description": "Standalone ChatGPT OAuth account management for DeepSeek Harness.",
5
- "version": "0.1.1-rc.3.1",
5
+ "version": "0.1.2-rc.1",
6
6
  "author": "tnnevol",
7
7
  "repository": {
8
8
  "type": "git",
@@ -52,11 +52,12 @@
52
52
  "client": {
53
53
  "inject": [
54
54
  "@deepseek-ai/dsh-api-remotes",
55
+ "@deepseek-ai/dsh-api-session-controller",
55
56
  "@deepseek-ai/dsh-client-connection",
56
- "@deepseek-ai/dsh-client-runtime",
57
57
  "@deepseek-ai/dsh-client-ui-conversation",
58
58
  "@deepseek-ai/dsh-client-ui-model-selection",
59
59
  "@deepseek-ai/dsh-client-ui-primitives",
60
+ "@deepseek-ai/dsh-client-ui-renderer",
60
61
  "@deepseek-ai/dsh-client-ui-settings",
61
62
  "@deepseek-ai/dsh-client-ui-settings-plugins",
62
63
  "@deepseek-ai/dsh-client-locale"
@@ -65,66 +66,71 @@
65
66
  }
66
67
  },
67
68
  "peerDependencies": {
68
- "@earendil-works/pi-ai": "0.82.1",
69
- "@deepseek-ai/cordis": "^4.0.1-rc.1",
70
- "@deepseek-ai/dsh-attachment": "0.1.1-rc.2",
71
- "@deepseek-ai/dsh-agent-default-model": "0.1.1-rc.2",
72
- "@deepseek-ai/dsh-atomic-write": "0.1.1-rc.2",
73
- "@deepseek-ai/dsh-home-paths": "0.1.1-rc.2",
74
- "@deepseek-ai/dsh-host-webserver": "0.1.1-rc.2",
75
- "@deepseek-ai/dsh-invariants": "0.1.1-rc.2",
76
- "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
77
- "@deepseek-ai/dsh-llm-pi-ai": "0.1.1-rc.2",
78
- "@deepseek-ai/dsh-settings": "0.1.1-rc.2",
79
- "@deepseek-ai/dsh-tools": "0.1.1-rc.2",
80
- "@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
81
- "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
82
- "@deepseek-ai/dsh-client-ui-primitives": "0.1.1-rc.2",
83
- "@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.2",
84
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.1-rc.2",
85
- "@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.2",
86
- "@deepseek-ai/dsh-credentials": "0.1.1-rc.2",
87
- "@deepseek-ai/dsh-fs": "0.1.1-rc.2",
88
- "@deepseek-ai/dsh-launch-environment": "0.1.1-rc.2",
89
- "@deepseek-ai/dsh-timeout": "0.1.1-rc.2",
90
- "@deepseek-ai/schemastery": "3.18.1",
69
+ "@earendil-works/pi-ai": "^0.84.2",
70
+ "@deepseek-ai/cordis": "^4.0.2",
71
+ "@deepseek-ai/dsh-api-remotes": "0.1.2-rc.1",
72
+ "@deepseek-ai/dsh-api-session-controller": "0.1.2-rc.1",
73
+ "@deepseek-ai/dsh-scope": "0.1.2-rc.1",
74
+ "@deepseek-ai/dsh-attachment": "0.1.2-rc.1",
75
+ "@deepseek-ai/dsh-agent-default-model": "0.1.2-rc.1",
76
+ "@deepseek-ai/dsh-atomic-write": "0.1.2-rc.1",
77
+ "@deepseek-ai/dsh-home-paths": "0.1.2-rc.1",
78
+ "@deepseek-ai/dsh-host-webserver": "0.1.2-rc.1",
79
+ "@deepseek-ai/dsh-invariants": "0.1.2-rc.1",
80
+ "@deepseek-ai/dsh-llm": "0.1.2-rc.1",
81
+ "@deepseek-ai/dsh-llm-pi-ai": "0.1.2-rc.1",
82
+ "@deepseek-ai/dsh-settings": "0.1.2-rc.1",
83
+ "@deepseek-ai/dsh-tools": "0.1.2-rc.1",
84
+ "@deepseek-ai/dsh-client-locale": "0.1.2-rc.1",
85
+ "@deepseek-ai/dsh-client-ui-primitives": "0.1.2-rc.1",
86
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.2-rc.1",
87
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.2-rc.1",
88
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.2-rc.1",
89
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.2-rc.1",
90
+ "@deepseek-ai/dsh-credentials": "0.1.2-rc.1",
91
+ "@deepseek-ai/dsh-fs": "0.1.2-rc.1",
92
+ "@deepseek-ai/dsh-launch-environment": "0.1.2-rc.1",
93
+ "@deepseek-ai/dsh-timeout": "0.1.2-rc.1",
94
+ "@deepseek-ai/schemastery": "3.18.2",
91
95
  "react": "^18.2.0"
92
96
  },
93
97
  "devDependencies": {
94
- "@earendil-works/pi-ai": "0.82.1",
95
- "@deepseek-ai/cordis": "^4.0.1",
96
- "@deepseek-ai/dsh-api-remotes": "0.1.1-rc.2",
97
- "@deepseek-ai/dsh-agent-default-model": "0.1.1-rc.2",
98
- "@deepseek-ai/dsh-attachment": "0.1.1-rc.2",
99
- "@deepseek-ai/dsh-atomic-write": "0.1.1-rc.2",
100
- "@deepseek-ai/dsh-client-connection": "0.1.1-rc.2",
101
- "@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
102
- "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
103
- "@deepseek-ai/dsh-client-ui-conversation": "0.1.1-rc.2",
104
- "@deepseek-ai/dsh-client-ui-model-selection": "0.1.1-rc.2",
105
- "@deepseek-ai/dsh-client-ui-primitives": "0.1.1-rc.2",
106
- "@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.2",
107
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.1-rc.2",
108
- "@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.2",
109
- "@deepseek-ai/dsh-credentials": "0.1.1-rc.2",
110
- "@deepseek-ai/dsh-home-paths": "0.1.1-rc.2",
111
- "@deepseek-ai/dsh-fs": "0.1.1-rc.2",
112
- "@deepseek-ai/dsh-host-webserver": "0.1.1-rc.2",
113
- "@deepseek-ai/dsh-invariants": "0.1.1-rc.2",
114
- "@deepseek-ai/dsh-launch-environment": "0.1.1-rc.2",
115
- "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
116
- "@deepseek-ai/dsh-llm-pi-ai": "0.1.1-rc.2",
117
- "@deepseek-ai/dsh-settings": "0.1.1-rc.2",
118
- "@deepseek-ai/dsh-tools": "0.1.1-rc.2",
119
- "@deepseek-ai/dsh-timeout": "0.1.1-rc.2",
120
- "@deepseek-ai/schemastery": "3.18.1",
98
+ "@earendil-works/pi-ai": "^0.84.2",
99
+ "@deepseek-ai/cordis": "^4.0.2",
100
+ "@deepseek-ai/dsh-api-remotes": "0.1.2-rc.1",
101
+ "@deepseek-ai/dsh-api-session-controller": "0.1.2-rc.1",
102
+ "@deepseek-ai/dsh-scope": "0.1.2-rc.1",
103
+ "@deepseek-ai/dsh-agent-default-model": "0.1.2-rc.1",
104
+ "@deepseek-ai/dsh-attachment": "0.1.2-rc.1",
105
+ "@deepseek-ai/dsh-atomic-write": "0.1.2-rc.1",
106
+ "@deepseek-ai/dsh-client-connection": "0.1.2-rc.1",
107
+ "@deepseek-ai/dsh-client-locale": "0.1.2-rc.1",
108
+ "@deepseek-ai/dsh-client-ui-conversation": "0.1.2-rc.1",
109
+ "@deepseek-ai/dsh-client-ui-model-selection": "0.1.2-rc.1",
110
+ "@deepseek-ai/dsh-client-ui-primitives": "0.1.2-rc.1",
111
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.2-rc.1",
112
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.2-rc.1",
113
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.2-rc.1",
114
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.2-rc.1",
115
+ "@deepseek-ai/dsh-credentials": "0.1.2-rc.1",
116
+ "@deepseek-ai/dsh-home-paths": "0.1.2-rc.1",
117
+ "@deepseek-ai/dsh-fs": "0.1.2-rc.1",
118
+ "@deepseek-ai/dsh-host-webserver": "0.1.2-rc.1",
119
+ "@deepseek-ai/dsh-invariants": "0.1.2-rc.1",
120
+ "@deepseek-ai/dsh-launch-environment": "0.1.2-rc.1",
121
+ "@deepseek-ai/dsh-llm": "0.1.2-rc.1",
122
+ "@deepseek-ai/dsh-llm-pi-ai": "0.1.2-rc.1",
123
+ "@deepseek-ai/dsh-settings": "0.1.2-rc.1",
124
+ "@deepseek-ai/dsh-tools": "0.1.2-rc.1",
125
+ "@deepseek-ai/dsh-timeout": "0.1.2-rc.1",
126
+ "@deepseek-ai/schemastery": "3.18.2",
121
127
  "@types/node": "^22.20.0",
122
128
  "@types/react": "~18.3.1",
123
129
  "react": "^18.3.1",
124
130
  "tsdown": "^0.22.2",
125
131
  "typescript": "^5.9.3",
126
132
  "vitest": "^4.1.8",
127
- "@tnnevol/dsh-semi-ui": "5.2.0"
133
+ "@tnnevol/dsh-semi-ui": "5.2.1"
128
134
  },
129
135
  "scripts": {
130
136
  "pretypecheck": "pnpm --filter @tnnevol/dsh-semi-ui run build",