dsh-codex-community 0.0.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/CONTRIBUTING.en.md +54 -0
  3. package/CONTRIBUTING.md +54 -0
  4. package/LICENSE +201 -0
  5. package/NOTICE +12 -0
  6. package/README.en.md +98 -0
  7. package/README.md +98 -0
  8. package/SECURITY.md +41 -0
  9. package/SUPPORT.md +17 -0
  10. package/THIRD_PARTY_NOTICES.md +25 -0
  11. package/codex-community.patch.yml +13 -0
  12. package/dist/client/index.js +1037 -0
  13. package/dist/host/index.mjs +98 -0
  14. package/dist/internal/authorization-bridge.mjs +662 -0
  15. package/dist/internal/authorization-commit-tracker.mjs +49 -0
  16. package/dist/internal/codex-authorization.mjs +202 -0
  17. package/dist/internal/codex-credential-store.mjs +164 -0
  18. package/dist/internal/codex-identifiers.mjs +4 -0
  19. package/dist/internal/codex-pi-provider.mjs +137 -0
  20. package/dist/internal/codex-provider-runtime.mjs +256 -0
  21. package/dist/internal/codex-route-adapter.mjs +133 -0
  22. package/dist/internal/codex-session-resources.mjs +64 -0
  23. package/dist/internal/failure-normalizer.mjs +456 -0
  24. package/dist/internal/image-policy.mjs +45 -0
  25. package/dist/internal/quota-observer.mjs +142 -0
  26. package/dist/internal/reliability.mjs +12 -0
  27. package/dist/internal/remote-image-input.mjs +801 -0
  28. package/dist/internal/session-preference-command.mjs +52 -0
  29. package/dist/internal/session-preferences.mjs +93 -0
  30. package/dist/internal/stream-resilience.mjs +273 -0
  31. package/docs/README.en.md +15 -0
  32. package/docs/README.md +15 -0
  33. package/docs/architecture.en.md +106 -0
  34. package/docs/architecture.md +106 -0
  35. package/docs/compatibility.en.md +53 -0
  36. package/docs/compatibility.md +53 -0
  37. package/docs/configuration.en.md +61 -0
  38. package/docs/configuration.md +61 -0
  39. package/docs/contribution-sources.en.md +35 -0
  40. package/docs/contribution-sources.md +35 -0
  41. package/docs/github-about.md +15 -0
  42. package/docs/releases/v0.0.1.acceptance.json +160 -0
  43. package/docs/releases/v0.0.1.md +174 -0
  44. package/docs/releasing.en.md +290 -0
  45. package/docs/releasing.md +290 -0
  46. package/docs/testing.en.md +85 -0
  47. package/docs/testing.md +85 -0
  48. package/docs/troubleshooting.en.md +47 -0
  49. package/docs/troubleshooting.md +47 -0
  50. package/package.json +144 -0
  51. package/types/client.d.ts +160 -0
  52. package/types/index.d.ts +22 -0
  53. package/types/reliability.d.ts +78 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,90 @@
1
+ # 更新日志 / Changelog
2
+
3
+ 本项目遵循 Keep a Changelog 的结构;`0.0.x` 为技术预览。
4
+ This project follows the Keep a Changelog structure; `0.0.x` is a technical preview.
5
+
6
+ ## [0.0.1] - 2026-08-29
7
+
8
+ ### 中文
9
+
10
+ #### 新增
11
+
12
+ - `dsh-codex` route、Host 插件和 Web 登录页。
13
+ - 与同一 profile 中其他 pi-ai provider 共存,不改写通用 `llm-pi-ai` 配置。
14
+ - 插件专用的设置命名空间与 OAuth 凭据范围,只接受 ChatGPT OAuth。
15
+ - Codex 模型启用管理、最近额度观测卡,以及 `/codex-login` 和 `/codex-usage` 命令。
16
+ - `/codex` 当前会话偏好:Fast 开关和 `auto`、SSE、WebSocket 传输选择。
17
+ - pi-ai Codex 模型目录、流式内容、reasoning、工具、图片和 replay 接线。
18
+ - 安全 HTTP(S) 图片读取、图片预算、2 个活动任务与 32 个排队任务的有界调度、账户配额规范化与半段回复恢复模块。
19
+ - 带 `dsh-codex:` 命名空间的 transport/cache session,以及 reset、agent dispose 和 runtime dispose 的精确资源清理。
20
+ - 中英文 Web 设置页的操作互斥、卸载安全、长文本换行与 320 像素窄屏布局。
21
+ - 覆盖单元、SDK 合同、真实 attachment seam、真实 DSH `LlmRuntime` waterfall、Web client 与 Host 加载的测试套件。
22
+ - 冻结的 DSH 兼容性 smoke 运行时夹具,提交独立 `pnpm-lock.yaml` 并在 CI、兼容性监测与发布候选中使用 `--frozen-lockfile --ignore-scripts` 安装。
23
+ - 发布候选在 Web/profile smoke 成功后记录 DSH 版本、夹具 lock SHA-256、Node、pnpm、平台、架构与生命周期脚本状态,并由严格门禁重新验证。
24
+ - 中英文文档、社区治理、Issue/PR、跨平台 CI,以及最小权限、SHA 固定、离线确定性 SBOM 和可恢复重跑的发布流程。
25
+ - 发布候选生成双语审批摘要,并在受保护环境审批前后各执行一次严格门禁;npm Trusted Publisher/OIDC 与 GitHub Release 写权限分属独立 job,Registry 回读证据通过不可变 Actions artifact 交接。
26
+ - `0.0.1` 使用 npm `latest` 与正式 GitHub Release;发布前三平台 CI/profile smoke 必须 `3/3` 通过,供应链证据必须完整且必须经维护者批准。真实账号验证允许以 `0/13` 如实发布并在发布后持续记录;发现的问题进入 `0.0.2` 迭代。
27
+ - 不发布、不读取凭据的 `pnpm run release:candidate -- 0.0.1` 本地/CI 候选复演:要求干净提交与 Node 24、pnpm `10.34.5`、npm `11.16.0`,精确执行 frozen install、完整检查、仅一次生成候选 tarball、dry-run、SBOM、DSH profile smoke、隔离导入和生产依赖 audit,写入 `release/`,已有输出时在写前失败。普通 CI 的独立只读 Ubuntu/Node 24 `candidate-replay` job 动态读取版本后调用该命令一次,并把完整证据上传为保留 14 天的 `dsh-codex-community-${{ github.sha }}-ci-replay` artifact;权威候选仍由 `main` 发布 workflow 生成,该复演不替代三平台 CI/profile smoke、真实账号验收或审批。
28
+ - 幂等且离线的 `release:prepare` 命令,用于生成下一版本的双语 CHANGELOG/Release 草稿和全新 schema v3 验收记录;它会保护人工内容、在冲突发生时写入前失败,并拒绝受管文件或父目录符号链接。
29
+ - 不联网、不读取凭据的 `release:acceptance` 离线证据记录器;新增 `pass-platform <linux|macos|windows>`,只记录维护者已核验的 CI/profile smoke,不检查提交是否存在;平台与真实网络证据必须绑定同一候选 SHA,已通过项只允许相同证据的幂等重放,不能覆盖不同证据;真实检查只有明确列齐固定断言才记录通过,`status` 不显示证据值,提交存在性/祖先关系仍由严格门禁验证,审批仍由维护者人工作出。
30
+ - draft 专用的离线 `pnpm run release:acceptance -- reset-candidate --from-commit=<旧SHA> --to-commit=<新SHA>`:源码变化后清空全部旧平台/live 证据与审批并绑定新候选,再运行新 CI/profile smoke 并用 `pass-platform` 记录;它不检查提交存在性,通过受管路径检查、写锁和原子替换安全写入,拒绝重置 approved 记录,并把 fresh 状态下同一命令的重放保持为 `unchanged`。
31
+
32
+ #### 修复
33
+
34
+ - `Image request maxPixels must be a positive integer.`
35
+ - `AccountQuotaExceeded` 被误判为可重试 `RATE_LIMIT`,直接抛出的配额错误绕过恢复层,DSH canonical `QUOTA` 绕过脱敏输出,无结构证据的通用 429 被误报为已确认账户配额,以及 request metadata/其他 JSON envelope 污染 provider 配额事实;只有 canonical `QUOTA`、顶层或一个自身匹配的 `error` envelope 可以确认账户配额和提供 reset/request ID/status,其他通用 429 使用非重试 `QUOTA_OR_RATE_LIMIT`。
36
+ - `STREAM_CLOSED`、WebSocket 中断、直接抛错或缺少终止 chunk 的 EOF 导致半段回复丢失,或在已产生可见输出/工具调用后整次重放造成重复内容和工具副作用;纯工具流现在也失败关闭,`onRecovery` 观察者异常被隔离,不再破坏恢复文本、提示与终态。
37
+ - OAuth 取消后的补偿删除可能误删另一 DSH 进程已排队的新登录;取消现在以串行 mutate 回调为线性化点,提交阶段由无凭据 generation tracker 阻止误报取消,退出仍通过同一记录锁保证最终状态;真实 Cordis flow owner 卸载会在提交选择前取消,或在提交选择后等待最终写入完成。
38
+ - 已结束的保留 attempt 误取消新登录、排队图片取消后仍开始持久化、插件卸载后仍启动排队图片、模型能力预检在限流器外绕过活动/排队上限,以及保存阶段取消仍向调用方返回成功。
39
+ - 不支持类型或结构损坏的已存 OAuth 记录被显示为已登录;现在会返回独立的 `invalid` 状态,且凭据 secret 不跨 RPC。
40
+ - Web 登录操作竞态、异步完成后更新已卸载组件、热重载后残留旧样式节点,以及窄屏设置页横向溢出。
41
+ - CI 与发布 smoke 直接通过 npm 解算 DSH peer 图可能产生不确定依赖结果和内存失控;现在只安装已提交的冻结 pnpm 运行时图,并要求依赖升级同步更新两套 lockfile 后重跑 CI 与验收。
42
+ - 跨平台维护门禁在 Linux 区分 PR 模板文件名大小写、在 Windows 误判 CRLF 工作流文本并无法可靠启动 `pnpm.cmd` 或 npm 打包检查;模板路径、换行读取与包管理器调用现已跨平台一致。
43
+ - Windows DSH profile smoke 结束后短暂的目录锁可能让临时目录清理报 `EBUSY`,并由 `finally` 覆盖真正的 smoke 失败;清理现在有限重试,若 smoke 与清理同时失败则保留两个错误。
44
+ - 模型可选字段的显式 `null` 与非有限流空闲超时可能穿过基础 Schema;配置现在会在适配器 profile 与设置保存边界拒绝这些不可服务值。
45
+ - 发布候选过早获得写权限、可变 Action 引用、未 smoke 精确候选、把参考 SBOM 当成实际安装树、缺少生产依赖高危审计、exact SRI 与签名/attestation 校验、GitHub Release 资产未回读、draft/tag 目标未在公开前验证和重复发布恢复不完整;直接依赖声明、贡献许可、双语隐私模板和协调依赖升级新增本地门禁,候选证据保留 90 天,并支持只重跑失败 job。
46
+ - 发布阶段曾在同一 job 同时持有 npm OIDC 与 GitHub contents 写权限、provenance 未绑定候选仓库/工作流/ref/源码提交,且 Release 转为公开后缺少最终全量回读;现已拆分权限,逐项绑定来源,并在公开动作后重新校验标题、正文、标签、资产与字节摘要。
47
+ - GitHub Actions 审核门禁现在逐条校验每个 `uses:` 是否属于明确审核的完整提交 allowlist,避免新增未审核 Action 借用其他位置的已审核 SHA 通过测试。
48
+ - 发布工作流从错误分支触发时不再静默跳过;首次 `0.0.1` 根据 Registry 状态自动进入受限引导,后续版本自动使用 OIDC。候选会用固定 npm 对 `./` 本地 tarball 做 dry-run,发布后按 npm 11 的 `attestationBundles` 结构验证 SLSA provenance,并绑定包摘要、仓库、发布工作流、`main` ref 与候选源码提交;所有 Actions 已更新到审核过的 Node 24 版本。
49
+
50
+ ### English
51
+
52
+ #### Added
53
+
54
+ - A `dsh-codex` route, Host plugin, and Web sign-in page.
55
+ - Coexistence with other pi-ai providers in the same profile without rewriting the general `llm-pi-ai` configuration.
56
+ - A plugin-scoped settings namespace and OAuth credential scope that accepts ChatGPT OAuth only.
57
+ - Codex model enablement, a recent quota-observation card, and `/codex-login` and `/codex-usage` commands.
58
+ - Per-session `/codex` preferences for Fast and `auto`, SSE, or WebSocket transport.
59
+ - pi-ai Codex catalog, streaming content, reasoning, tools, images, and replay wiring.
60
+ - Safe HTTP(S) image reading, image policy, bounded scheduling with two active and 32 queued jobs, account-quota normalization, and partial-response recovery modules.
61
+ - `dsh-codex:`-namespaced transport/cache sessions with exact cleanup on reset, agent disposal, and runtime disposal.
62
+ - Mutually exclusive actions, unmount safety, long-text wrapping, and a 320-pixel narrow-screen layout in the Chinese and English Web settings page.
63
+ - A test suite covering units, SDK contracts, the real attachment seam, the real DSH `LlmRuntime` waterfall, the Web client, and Host loading.
64
+ - A frozen DSH compatibility-smoke runtime fixture with its own committed `pnpm-lock.yaml`, installed through `--frozen-lockfile --ignore-scripts` in CI, compatibility monitoring, and release candidates.
65
+ - Release candidates record the DSH version, fixture-lock SHA-256, Node, pnpm, platform, architecture, and lifecycle-script state only after Web/profile smoke succeeds, and the strict gate re-verifies them.
66
+ - Chinese and English documentation, governance, issue/PR templates, cross-platform CI, and a least-privilege release flow with pinned Actions, an offline deterministic SBOM, and recoverable reruns.
67
+ - Release candidates produce a bilingual approval summary and run the strict gate both before and after protected-environment approval. npm Trusted Publisher/OIDC and GitHub Release write access live in separate jobs, with Registry readback evidence handed off through an immutable Actions artifact.
68
+ - `0.0.1` uses npm `latest` and a full GitHub Release. Before publication, all three CI/profile-smoke platform gates must pass, supply-chain evidence must be complete, and a maintainer must approve the release. Controlled-account validation may be disclosed at `0/13` and continue after release; findings are iterated in `0.0.2`.
69
+ - A non-publishing, credential-free `pnpm run release:candidate -- 0.0.1` local/CI replay requires a clean committed checkout plus Node 24, pnpm `10.34.5`, and npm `11.16.0`. It performs frozen installs, the complete checks, exactly one artifact-producing pack, dry-run, SBOM, DSH profile smoke, isolated import, and production-dependency audit into `release/`, failing before any write when output already exists. Regular CI's separate read-only Ubuntu/Node 24 `candidate-replay` job reads the version dynamically, invokes the command once, and uploads the complete evidence as the 14-day `dsh-codex-community-${{ github.sha }}-ci-replay` artifact. The authoritative candidate still comes from the release workflow on `main`; this replay does not replace three-platform CI/profile smoke, live-account acceptance, or approval.
70
+ - An idempotent offline `release:prepare` command that creates the next bilingual CHANGELOG/Release drafts and a fresh schema-v3 acceptance record, preserves human-authored content, fails before writing on conflicts, and rejects managed-file or parent-directory symlinks.
71
+ - An offline `release:acceptance` evidence recorder that neither accesses the network nor reads credentials, now with `pass-platform <linux|macos|windows>` to record only maintainer-verified CI/profile smoke without checking that the commit exists. Platform and live-network evidence must bind to one candidate SHA; a passed item permits only an idempotent replay of identical evidence and cannot be overwritten with different evidence. Live checks pass only when every fixed assertion is explicitly listed, `status` hides evidence values, the strict gate still checks commit existence/ancestry, and approval remains a maintainer decision.
72
+ - A draft-only offline `pnpm run release:acceptance -- reset-candidate --from-commit=<old-SHA> --to-commit=<new-SHA>` command that clears all old platform/live evidence and approval fields after source changes, binds the new candidate, and precedes new CI/profile smoke recorded with `pass-platform`. It does not check commit existence, writes safely through managed-path checks, a write lock, and atomic replacement, rejects approved records, and keeps a replay of the same command against fresh state `unchanged`.
73
+
74
+ #### Fixed
75
+
76
+ - `Image request maxPixels must be a positive integer.`
77
+ - `AccountQuotaExceeded` being mistaken for retryable `RATE_LIMIT`, directly thrown quota bypassing recovery, canonical DSH `QUOTA` bypassing sanitized output, generic 429 text without structured evidence being mislabeled as confirmed account quota, and request metadata/another JSON envelope contaminating provider quota facts. Only canonical `QUOTA`, the top level, or one independently matching `error` envelope can confirm quota and provide reset/request ID/status; other generic 429 failures use non-retryable `QUOTA_OR_RATE_LIMIT`.
78
+ - Lost partial responses after `STREAM_CLOSED`, WebSocket interruption, a direct throw, or EOF without a terminal chunk, plus full-request replay after visible output or a tool call that could duplicate content or tool side effects. Tool-only streams now fail closed, and exceptions from the `onRecovery` observer cannot break recovered text, the notice, or the terminal event.
79
+ - A compensating delete after OAuth cancellation could erase a newer sign-in already queued by another DSH process; cancellation now linearizes at the serialized mutate callback, a credential-free generation tracker prevents a commit from being misreported as cancelled, and sign-out still establishes its final state through the same record lock. Real Cordis flow-owner disposal now cancels before commit selection or waits for the final write after selection.
80
+ - A retained completed attempt cancelling a newer sign-in, a cancelled or post-disposal queued image starting persistence, model-capability preflight bypassing active/queued bounds outside the limiter, and persistence-stage cancellation still returning success.
81
+ - Unsupported or malformed stored OAuth records being presented as signed in; they now produce a distinct `invalid` state, and credential secrets never cross RPC.
82
+ - Web sign-in action races, state updates after unmount, stale style nodes after hot reload, and horizontal overflow in narrow settings dialogs.
83
+ - CI and release smoke resolving the DSH peer graph directly through npm, which could produce nondeterministic dependency results and uncontrolled memory use. They now install only the committed frozen pnpm runtime graph, and dependency upgrades must update both lockfiles before CI and acceptance are repeated.
84
+ - Cross-platform maintenance gates failing on Linux due to pull-request-template filename casing, and on Windows due to CRLF-sensitive workflow assertions or unreliable direct spawning of `pnpm.cmd` and the npm pack check. Template paths, text normalization, and package-manager invocation are now portable.
85
+ - A transient Windows directory lock after DSH profile smoke could make temporary cleanup fail with `EBUSY`, while `finally` masked the real smoke failure. Cleanup now retries within a fixed bound and preserves both errors when smoke and cleanup fail together.
86
+ - Explicit `null` model overrides and non-finite stream idle timeouts could pass the basic Schema. Configuration now rejects these unserviceable values at the adapter-profile and settings-save boundaries.
87
+ - Release candidates receiving write permission too early, mutable Action references, a missing exact-candidate smoke, reference SBOMs being treated as actual install trees, missing high-severity production-dependency audit, exact SRI and signature/attestation checks, missing GitHub asset readback, missing pre-publication draft/tag target verification, and incomplete recovery after a partial publication. Local gates now cover direct-dependency notices, contribution licensing, bilingual privacy templates, and coordinated dependency updates. Candidate evidence is retained for 90 days and supports rerunning only failed jobs.
88
+ - A publication job previously held npm OIDC and GitHub contents write access together, provenance was not bound to the candidate repository/workflow/ref/source commit, and a Release lacked a final full readback after becoming public. Permissions are now split, every source field is bound, and the public title, body, tag, assets, and byte digests are revalidated after publication.
89
+ - The GitHub Actions review gate now checks every `uses:` entry against an explicit allowlist of reviewed full commits, preventing an unreviewed Action from passing merely because a reviewed SHA appears elsewhere.
90
+ - A release dispatch from the wrong branch now fails instead of silently skipping. The first `0.0.1` automatically enters a Registry-state-gated bootstrap, while later versions automatically use OIDC. The candidate dry-runs the `./` local tarball with the pinned npm; post-publication checks use npm 11's `attestationBundles` shape for SLSA provenance and bind the package digest, repository, release workflow, `main` ref, and candidate source commit. Every Action is pinned to a reviewed Node 24 release.
@@ -0,0 +1,54 @@
1
+ # Contributing guide
2
+
3
+ [简体中文](CONTRIBUTING.md) | [English](CONTRIBUTING.en.md)
4
+
5
+ Thank you for helping maintain `dsh-codex-community`. Credential safety, protocol accuracy, recoverable failure, and cross-platform maintainability take priority.
6
+
7
+ ## Filing an issue
8
+
9
+ Include:
10
+
11
+ - exact plugin, DSH, and Node.js versions;
12
+ - operating system and architecture;
13
+ - a minimal reproduction, expected result, and actual result;
14
+ - a sanitized error code, reset/request ID, or necessary stack;
15
+ - whether image history, a tool call, partial output, or a profile override was involved.
16
+
17
+ Never submit a token, OAuth code, cookie, credential file, complete raw response, private prompt, tool arguments, source image, or unreviewed diagnostic bundle. Follow [SECURITY.md](SECURITY.md) for security issues.
18
+
19
+ ## Development flow
20
+
21
+ 1. Read [Contribution sources and licensing](docs/contribution-sources.en.md) plus the relevant architecture and compatibility documents.
22
+ 2. Create a clearly named, single-purpose branch from current `main`.
23
+ 3. Add a failing reproduction first, then the smallest implementation that fixes it.
24
+ 4. Keep Chinese and English documentation plus the changelog synchronized.
25
+ 5. Run:
26
+
27
+ ```sh
28
+ corepack enable
29
+ pnpm install --frozen-lockfile
30
+ pnpm --dir test/fixtures/dsh-runtime install --frozen-lockfile --ignore-scripts
31
+ pnpm run check
32
+ pnpm run verify:release
33
+ ```
34
+
35
+ The complete test suite loads the exact DSH runtime, AgentLoop, and Retry plugin from the frozen fixture. Install that fixture first; tests must not rely on a machine-wide DSH installation.
36
+
37
+ ## Contribution license
38
+
39
+ Contributions intentionally submitted for inclusion in this repository are provided under the project's Apache-2.0 license unless different terms are stated in writing with the submission and accepted by a maintainer. By submitting, you confirm that you have the right to submit the material and grant that license. This is not a copyright assignment, and no separate CLA is required.
40
+
41
+ ## Pull-request checklist
42
+
43
+ - [ ] The change is focused and contains no unrelated refactor or formatting churn.
44
+ - [ ] Behavior derives from public DSH/pi-ai/OpenAI contracts or reproducible black-box observation.
45
+ - [ ] The change is authored by the contributor or derived from clearly identified public interfaces and specifications.
46
+ - [ ] I have the right to submit every included item and agree to provide the contribution under Apache-2.0.
47
+ - [ ] No code, tests, documentation, or media with unclear origin or licensing are included.
48
+ - [ ] New behavior has regression coverage and failures are bounded or fail closed.
49
+ - [ ] No secret, account data, real private response, or machine-specific path appears in a fixture.
50
+ - [ ] Every dependency explains necessity, size, license, and supply-chain impact.
51
+ - [ ] Both languages of README/docs/CHANGELOG are synchronized.
52
+ - [ ] `pnpm run check` passes and real-network/platform evidence boundaries are stated.
53
+
54
+ Merge is not release authorization. Tags, npm publication, GitHub Releases, and community submissions are separate maintainer actions under the release document.
@@ -0,0 +1,54 @@
1
+ # 贡献指南
2
+
3
+ [简体中文](CONTRIBUTING.md) | [English](CONTRIBUTING.en.md)
4
+
5
+ 感谢你帮助维护 `dsh-codex-community`。项目优先保证凭据安全、协议准确、失败可恢复和跨平台可维护性。
6
+
7
+ ## 提交 Issue
8
+
9
+ Bug 报告请提供:
10
+
11
+ - 插件、DSH、Node.js 的精确版本;
12
+ - 操作系统与架构;
13
+ - 最小复现、预期与实际结果;
14
+ - 脱敏错误 code、reset/request ID 或必要 stack;
15
+ - 是否涉及图片历史、工具调用、部分回复或 profile 覆盖。
16
+
17
+ 不要提交 token、OAuth code、cookie、凭据文件、完整原始响应、私人提示词、工具参数、原图或未经检查的诊断包。安全问题遵循 [SECURITY.md](SECURITY.md)。
18
+
19
+ ## 开发流程
20
+
21
+ 1. 阅读 [贡献来源与许可](docs/contribution-sources.md) 和相关架构、兼容性文档;
22
+ 2. 从最新 `main` 创建名称清晰、范围单一的分支;
23
+ 3. 先加入能复现问题的失败测试,再实现最小修复;
24
+ 4. 同步维护中文、英文文档和 CHANGELOG;
25
+ 5. 运行:
26
+
27
+ ```sh
28
+ corepack enable
29
+ pnpm install --frozen-lockfile
30
+ pnpm --dir test/fixtures/dsh-runtime install --frozen-lockfile --ignore-scripts
31
+ pnpm run check
32
+ pnpm run verify:release
33
+ ```
34
+
35
+ 全量测试会从冻结夹具加载精确 DSH runtime、AgentLoop 与 Retry 插件,因此必须先安装夹具依赖;不要让测试隐式使用机器上已有的 DSH 安装。
36
+
37
+ ## 贡献许可
38
+
39
+ 有意提交到本仓库的贡献将按本项目的 Apache-2.0 许可证提供,除非提交时明确书面说明并由维护者接受其他条款。提交贡献即表示你有权提交该内容,并有权按上述许可授予使用权;这不构成版权转让,也不要求额外 CLA。
40
+
41
+ ## PR 检查表
42
+
43
+ - [ ] 变更范围单一,没有无关重构或格式噪音;
44
+ - [ ] 行为通过公开 DSH/pi-ai/OpenAI 合同或可复现黑盒观察推导;
45
+ - [ ] 变更由本人编写,或来自明确列出的公开接口与规范;
46
+ - [ ] 我有权提交全部内容,并同意该贡献按 Apache-2.0 许可提供;
47
+ - [ ] 没有提交来源不明或许可不清晰的代码、测试、文档或媒体;
48
+ - [ ] 新行为有回归,失败路径为有界或失败关闭;
49
+ - [ ] 没有秘密、账号数据、真实私有响应或机器专属路径 fixture;
50
+ - [ ] 新依赖说明了必要性、体积、license 与供应链影响;
51
+ - [ ] 中英文 README/docs/CHANGELOG 已同步;
52
+ - [ ] `pnpm run check` 通过,且说明真实网络/平台验收边界。
53
+
54
+ PR 合并不等于发布授权。tag、npm publish、GitHub Release 和社区收录由维护者按发布文档单独执行。
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 YukiRyou
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ dsh-codex-community
2
+ Copyright 2026 YukiRyou
3
+
4
+ This project is a community integration for interoperability
5
+ with DeepSeek Harness. It is not affiliated with or endorsed by OpenAI or
6
+ DeepSeek.
7
+
8
+ Project source, tests, documentation, and media are authored in this
9
+ repository or included from declared dependencies under their licenses.
10
+
11
+ OpenAI, ChatGPT, Codex, DeepSeek, and related marks belong to their respective
12
+ owners. Use of those names describes interoperability only.
package/README.en.md ADDED
@@ -0,0 +1,98 @@
1
+ # dsh-codex
2
+
3
+ [简体中文](README.md) | [English](README.en.md)
4
+
5
+ A Codex plugin for DeepSeek Harness with ChatGPT OAuth sign-in, Codex models, image input, and reliable streaming responses.
6
+
7
+ > Current version: `0.0.1` technical preview, published under npm `latest` with a full GitHub Release. npm package: `dsh-codex-community`.
8
+
9
+ ## Features
10
+
11
+ - Sign in, sign in again, or sign out of ChatGPT OAuth from DSH Web;
12
+ - select and enable Codex models with streaming text, reasoning, usage, tool calls, and session replay;
13
+ - use DSH Web's native image paste, drag-and-drop, and attachment flow;
14
+ - let `read_image` safely read HTTP(S) images with address, redirect, format, size, and timeout limits;
15
+ - provide valid pixel and byte budgets for request images, preventing invalid `maxPixels` values;
16
+ - classify `AccountQuotaExceeded` as non-retryable account quota and show a sanitized reset time;
17
+ - preserve safe partial text after a stream failure, while incomplete tool calls stop without replaying the request;
18
+ - use `/codex` to choose Fast and transport for the current session, with Fast off and transport automatic by default.
19
+
20
+ ## Requirements
21
+
22
+ - DeepSeek Harness `0.1.1-rc.2`
23
+ - Node.js `>=22.19.0 <25`
24
+
25
+ ## Installation
26
+
27
+ Install an exact version:
28
+
29
+ ```sh
30
+ dsh plugin --profile web add dsh-codex-community@0.0.1
31
+ dsh web
32
+ ```
33
+
34
+ ## Sign in and use
35
+
36
+ 1. Open **Settings → OpenAI Codex** and complete the ChatGPT OAuth prompts.
37
+ 2. Enable models on the same page.
38
+ 3. Choose a Codex model from the conversation model selector.
39
+
40
+ Available commands:
41
+
42
+ ```text
43
+ /codex-login status
44
+ /codex-login cancel
45
+ /codex-login logout
46
+ /codex-usage
47
+ /codex status
48
+ /codex reset
49
+ /codex set fast on|off
50
+ /codex set transport auto|sse|websocket|websocket-cached
51
+ ```
52
+
53
+ Fast and transport preferences are kept only for the current session in the current process; they are not persisted. Fast requests the priority service tier, whose availability depends on the account and service; a failure is not automatically replayed on a lower tier.
54
+
55
+ Update:
56
+
57
+ ```sh
58
+ dsh plugin --profile web update dsh-codex-community@0.0.1
59
+ dsh web
60
+ ```
61
+
62
+ Before removal, sign out under **Settings → OpenAI Codex**, then run:
63
+
64
+ ```sh
65
+ dsh plugin --profile web remove dsh-codex-community
66
+ dsh web
67
+ ```
68
+
69
+ ## Error handling
70
+
71
+ - `Image request maxPixels must be a positive integer.`: omitted or `null` image budgets receive safe defaults; zero, negative, fractional, and other explicitly invalid values are rejected while loading configuration.
72
+ - `AccountQuotaExceeded`: the plugin stops automatic retries and preserves safe visible text. A reset time is shown only when present and validated. It does not try to bypass account quota by changing transport.
73
+ - `QUOTA_OR_RATE_LIMIT`: when only generic 429 text remains and structured evidence is unavailable, the plugin neither reports confirmed account quota nor retries automatically. Retry manually later or check the account surface.
74
+ - A response stops halfway: plain text can be preserved safely; an incomplete tool call is not replayed, avoiding duplicate side effects.
75
+
76
+ See [Troubleshooting](docs/troubleshooting.en.md) for diagnostic steps.
77
+
78
+ ## Support boundaries
79
+
80
+ - The `0.0.x` line does not promise a stable API; pin the exact version.
81
+ - Before publication, `0.0.1` must pass the Linux, macOS, and Windows platform gates, the complete supply-chain verification, and maintainer approval. It may be formally published with controlled-account validation at `0/13`, provided every unverified capability remains clearly disclosed and validation continues after release.
82
+ - Problems found after publication are fixed and iterated in `0.0.2`; the published `0.0.1` is never overwritten.
83
+ - Quota state comes from recent requests; it is not a live balance or proactive account query.
84
+ - Fast is an explicitly enabled experimental capability; controlled post-release validation continues to confirm real-account entitlement.
85
+ - Image generation and editing are not provided.
86
+ - See [Compatibility](docs/compatibility.en.md) for Windows, Linux, real OAuth, and real Codex network acceptance status.
87
+
88
+ ## Documentation and contribution
89
+
90
+ - [Documentation index](docs/README.en.md)
91
+ - [Configuration reference](docs/configuration.en.md)
92
+ - [Contributing](CONTRIBUTING.en.md)
93
+ - [Security reports](SECURITY.md)
94
+ - [Support scope](SUPPORT.md)
95
+
96
+ Never attach a token, OAuth code, cookie, credential file, or complete private conversation to an issue.
97
+
98
+ Apache-2.0; see [LICENSE](LICENSE). This project is community-maintained and is not affiliated with or endorsed by OpenAI or DeepSeek.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # dsh-codex
2
+
3
+ [简体中文](README.md) | [English](README.en.md)
4
+
5
+ 面向 DeepSeek Harness 的 Codex 插件,提供 ChatGPT OAuth 登录、Codex 模型、图片输入和可靠的流式回复。
6
+
7
+ > 当前版本:`0.0.1` 技术预览,使用 npm `latest` 与正式 GitHub Release 发布。npm 包名:`dsh-codex-community`。
8
+
9
+ ## 功能
10
+
11
+ - 在 DSH Web 中完成 ChatGPT OAuth 登录、重新登录和退出;
12
+ - 选择并启用 Codex 模型,支持流式文本、reasoning、usage、工具调用和会话 replay;
13
+ - 使用 DSH Web 原生的图片粘贴、拖放和 attachment 流程;
14
+ - 让 `read_image` 安全读取 HTTP(S) 图片,并限制地址、重定向、格式、大小和超时;
15
+ - 为请求图片补全有效的像素与字节预算,避免无效 `maxPixels`;
16
+ - 将 `AccountQuotaExceeded` 识别为不可重试的账户配额错误,并显示脱敏后的重置时间;
17
+ - 流中断时保留安全的半段纯文本;涉及未完成工具调用时停止,不自动重放请求;
18
+ - 使用 `/codex` 为当前会话选择 Fast 和传输方式,默认关闭 Fast、自动选择传输。
19
+
20
+ ## 运行要求
21
+
22
+ - DeepSeek Harness `0.1.1-rc.2`
23
+ - Node.js `>=22.19.0 <25`
24
+
25
+ ## 安装
26
+
27
+ 请固定安装精确版本:
28
+
29
+ ```sh
30
+ dsh plugin --profile web add dsh-codex-community@0.0.1
31
+ dsh web
32
+ ```
33
+
34
+ ## 登录与使用
35
+
36
+ 1. 打开 **设置 → OpenAI Codex**,按页面提示完成 ChatGPT OAuth;
37
+ 2. 在同一页面启用模型;
38
+ 3. 从会话模型选择器中选择 Codex 模型开始使用。
39
+
40
+ 可用命令:
41
+
42
+ ```text
43
+ /codex-login status
44
+ /codex-login cancel
45
+ /codex-login logout
46
+ /codex-usage
47
+ /codex status
48
+ /codex reset
49
+ /codex set fast on|off
50
+ /codex set transport auto|sse|websocket|websocket-cached
51
+ ```
52
+
53
+ Fast 和传输偏好只保存在当前进程的当前会话中,不会持久化。Fast 请求 priority service tier,但是否可用取决于账号和服务端;失败后不会自动降级重放请求。
54
+
55
+ 更新:
56
+
57
+ ```sh
58
+ dsh plugin --profile web update dsh-codex-community@0.0.1
59
+ dsh web
60
+ ```
61
+
62
+ 卸载前请先在 **设置 → OpenAI Codex** 中退出,然后执行:
63
+
64
+ ```sh
65
+ dsh plugin --profile web remove dsh-codex-community
66
+ dsh web
67
+ ```
68
+
69
+ ## 错误处理
70
+
71
+ - `Image request maxPixels must be a positive integer.`:图片预算缺省或为 `null` 时会回填安全默认值;零、负数、浮点和其他显式非法值会在配置加载时被拒绝。
72
+ - `AccountQuotaExceeded`:插件会停止自动重试并保留安全的已显示文本;重置时间存在且通过校验时才会显示。它不会通过切换传输方式绕过账户配额。
73
+ - `QUOTA_OR_RATE_LIMIT`:服务只返回通用 429 文案、缺少结构化证据时,插件不会把它误报为已确认账户配额,也不会自动重试;请稍后手动重试或检查账户页面。
74
+ - 回复到一半中断:纯文本可安全保存;未完成工具调用不会自动重放,以免重复产生副作用。
75
+
76
+ 排查步骤见[故障排查](docs/troubleshooting.md)。
77
+
78
+ ## 支持边界
79
+
80
+ - `0.0.x` 不承诺稳定 API,请固定版本;
81
+ - `0.0.1` 发布前必须通过 Linux、macOS 和 Windows 三平台门禁、完整供应链校验与维护者批准;真实账号验证允许以 `0/13` 状态正式发布,未验证能力必须如实展示并在发布后持续补齐;
82
+ - 发布后发现的问题在 `0.0.2` 中修复和迭代,不覆盖已发布的 `0.0.1`;
83
+ - 额度状态来自最近请求,不是实时余额或主动账户查询;
84
+ - Fast 是显式开启的实验能力,真实账号权限会在发布后的受控验证中继续确认;
85
+ - 不提供图片生成或编辑;
86
+ - Windows、Linux、真实 OAuth 与真实 Codex 网络验收状态见[兼容性文档](docs/compatibility.md)。
87
+
88
+ ## 文档与贡献
89
+
90
+ - [文档索引](docs/README.md)
91
+ - [配置参考](docs/configuration.md)
92
+ - [参与贡献](CONTRIBUTING.md)
93
+ - [安全报告](SECURITY.md)
94
+ - [支持范围](SUPPORT.md)
95
+
96
+ 提交 Issue 时不要附带 token、OAuth code、cookie、凭据文件或完整私人会话。
97
+
98
+ Apache-2.0,详见 [LICENSE](LICENSE)。本项目由社区维护,与 OpenAI 或 DeepSeek 无隶属或背书关系。