From 8cbb19eb76ffa197673f33c7e1bbc8ddcb078850 Mon Sep 17 00:00:00 2001 From: William XIAO <12486824+weixshaw@users.noreply.github.com> Date: Fri, 16 Oct 2026 22:46:54 +0800 Subject: [PATCH] feat(chatgpt-bridge): add macOS ChatGPT plan bridge commands --- .../chatgpt-bridge/.zcode-plugin/plugin.json | 22 ++++++++++ external_plugins/chatgpt-bridge/LICENSE | 21 +++++++++ external_plugins/chatgpt-bridge/README.md | 44 +++++++++++++++++++ external_plugins/chatgpt-bridge/README_CN.md | 44 +++++++++++++++++++ .../commands/chatgpt-connect.md | 10 +++++ .../chatgpt-bridge/commands/chatgpt-doctor.md | 4 ++ .../chatgpt-bridge/commands/chatgpt-models.md | 4 ++ .../chatgpt-bridge/commands/chatgpt-status.md | 4 ++ marketplace.json | 21 +++++++++ 9 files changed, 174 insertions(+) create mode 100644 external_plugins/chatgpt-bridge/.zcode-plugin/plugin.json create mode 100644 external_plugins/chatgpt-bridge/LICENSE create mode 100644 external_plugins/chatgpt-bridge/README.md create mode 100644 external_plugins/chatgpt-bridge/README_CN.md create mode 100644 external_plugins/chatgpt-bridge/commands/chatgpt-connect.md create mode 100644 external_plugins/chatgpt-bridge/commands/chatgpt-doctor.md create mode 100644 external_plugins/chatgpt-bridge/commands/chatgpt-models.md create mode 100644 external_plugins/chatgpt-bridge/commands/chatgpt-status.md diff --git a/external_plugins/chatgpt-bridge/.zcode-plugin/plugin.json b/external_plugins/chatgpt-bridge/.zcode-plugin/plugin.json new file mode 100644 index 0000000..353ec2a --- /dev/null +++ b/external_plugins/chatgpt-bridge/.zcode-plugin/plugin.json @@ -0,0 +1,22 @@ +{ + "name": "chatgpt-bridge", + "version": "0.1.1", + "description": "Manage the local ChatGPT plan bridge", + "description_i18n": { + "en": "Manage the local ChatGPT plan bridge", + "zh-CN": "管理本机 ChatGPT 订阅桥接的连接、模型和诊断" + }, + "author": { + "name": "weixshaw", + "url": "https://github.com/weixshaw" + }, + "license": "MIT", + "keywords": [ + "chatgpt", + "openai", + "macos" + ], + "commands": "./commands", + "homepage": "https://github.com/weixshaw/zcode-chatgpt-bridge", + "repository": "https://github.com/weixshaw/zcode-chatgpt-bridge" +} diff --git a/external_plugins/chatgpt-bridge/LICENSE b/external_plugins/chatgpt-bridge/LICENSE new file mode 100644 index 0000000..c7fc0c4 --- /dev/null +++ b/external_plugins/chatgpt-bridge/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 weixshaw and ZCode ChatGPT Bridge contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/external_plugins/chatgpt-bridge/README.md b/external_plugins/chatgpt-bridge/README.md new file mode 100644 index 0000000..35e1e2b --- /dev/null +++ b/external_plugins/chatgpt-bridge/README.md @@ -0,0 +1,44 @@ +# ChatGPT Bridge + +[中文说明](README_CN.md) + +Manage a local ChatGPT plan bridge from ZCode using four standard slash commands. The companion macOS service handles independent OpenAI authorization and exposes a local **OpenAI Responses** provider. This command plugin adds no MCP Apps page, Hook, MCP server, native provider-registration API or application-bundle patch. + +## Install and use + +1. Install Node.js 22+ and ZCode on macOS. This release was exercised on Apple Silicon with ZCode 3.15.3; Intel Macs have not been tested. +2. Download the companion ZIP from [weixshaw/zcode-chatgpt-bridge releases](https://github.com/weixshaw/zcode-chatgpt-bridge/releases). Extract it, review the source and `SHA256SUMS.txt`, then run `安装.command` (the macOS installer). The bridge is a separate prerequisite; installing this command plugin alone does not install the service. +3. In its local dashboard, select **Continue with ChatGPT** and finish authorization on the official OpenAI page. The account must grant ChatGPT plan usage. Model access and limits depend on the account/workspace; a catalog entry alone does not establish inference access. +4. Select **应用到 ZCode** to add the local provider and account model catalog, or copy the dashboard's Base URL/local key into a custom **OpenAI Responses** provider. Start a new ZCode conversation and select a bridge model. +5. Install and enable this plugin from the community marketplace. Before community inclusion, add `https://github.com/weixshaw/zcode-chatgpt-bridge` as a personal plugin market (the repository has a root `marketplace.json`). + +| Command | Behavior | +| --- | --- | +| `/chatgpt-connect` | Open the local account and provider setup dashboard | +| `/chatgpt-status` | Read service state, saved-account labels and current-run inference counters | +| `/chatgpt-models` | Refresh the active account's model catalog | +| `/chatgpt-doctor` | Diagnose local service, sign-in and model discovery; does not run inference | + +Commands invoke `node` and the companion CLI under the current user's macOS Application Support directory. Node must be on the Agent PATH. Commands run through the current Agent's normal tool permission flow. Opening the dashboard does not change the current conversation's model. If the service is missing, install it from the linked repository first. + +## Network, permissions and side effects + +- The plugin's commands run a local Node.js process. `connect` opens the system browser; `models` / `doctor` can cause the companion to contact OpenAI. There are no automatic Hooks, background actions or model calls in this plugin itself. +- The companion installs its program and protected data under `~/Library/Application Support/ZCode ChatGPT Bridge/` and a current-user LaunchAgent under `~/Library/LaunchAgents/`. It binds to `127.0.0.1` (default port 19781) and keeps running independently of plugin enablement. +- It contacts `auth.openai.com` for registration, sign-in, signed-key discovery, refresh and revocation; `api.openai.com` for models and Responses inference. GitHub supplies the source/releases. Source installations fetch pinned runtime packages from npm. Optional configured HTTP proxies can carry these requests. +- Only **应用到 ZCode** writes the bridge's provider/model rules to `~/.zcode/v2/provider_config.json`, after creating an owner-only backup in bridge data. Other providers and the existing default are retained. Manual provider setup is also available. +- OAuth credentials remain in protected local storage (`0700` data directory, `0600` files). They are not read from Codex, committed, printed by these commands, or written into ZCode provider settings. The local connection key is separate. `/status` may display the account email/label; avoid posting its output publicly. +- ZCode prompts, files and tool results selected for a model request are sent to OpenAI. The bridge stores conversation continuation only in bounded memory and does not write prompt/reply logs. Restarting it, switching accounts or cache eviction requires a new conversation or complete-history resubmission. +- Real model use consumes the authorized ChatGPT plan limits. No API key is required for the subscription route. The service does not promise eligibility or extra quota. + +This integration targets local macOS workspaces. Remote SSH/container Agents need a separately deployed and authorized bridge on that host; their `127.0.0.1` is not the Mac's loopback. Do not copy local credentials into remote workspaces. + +## Disable and remove + +Disabling/uninstalling this plugin removes only its commands. Sign out in the dashboard to revoke the renewable session, then run the companion's `卸载.command` to stop/remove the LaunchAgent and program. Its data is retained for explicit user removal. Remove the bridge provider in ZCode settings separately. If remote revocation is not confirmed, disconnect the app in [ChatGPT settings](https://chatgpt.com/settings/usage). + +## Verification and provenance + +The companion has 19 automated tests. Its 0.1.0 implementation completed real GPT-6.1-Sol text, local function-call and tool-result continuation checks, plus a ZCode 3.15.3 write/read task returning `NATIVE_OK`. The four commands were discovered by the installed ZCode runtime. These checks do not establish compatibility with every model, tool or future release. See the companion repository's `VERIFICATION.md` for limits. + +Plugin and companion source: [weixshaw/zcode-chatgpt-bridge](https://github.com/weixshaw/zcode-chatgpt-bridge), MIT. The companion depends on `jose` and `undici` (MIT); notices and pinned versions are in that repository. No third-party code is embedded in this command plugin. OpenAI and ZCode are external service/product dependencies. This is an independent community project with no affiliation with OpenAI or Z.ai. diff --git a/external_plugins/chatgpt-bridge/README_CN.md b/external_plugins/chatgpt-bridge/README_CN.md new file mode 100644 index 0000000..6c8d09c --- /dev/null +++ b/external_plugins/chatgpt-bridge/README_CN.md @@ -0,0 +1,44 @@ +# ChatGPT Bridge + +[English](README.md) + +通过四个标准斜杠命令,在 ZCode 内管理本机 ChatGPT 订阅桥接。配套 macOS 服务负责独立 OpenAI 授权,并提供本地 **OpenAI Responses** 供应商。此命令插件不含 MCP Apps 页面、Hook、MCP 服务器、原生供应商注册接口或应用包补丁。 + +## 安装与使用 + +1. 在 macOS 安装 Node.js 22+ 和 ZCode。本版已在 Apple Silicon / ZCode 3.15.3 实测;尚无 Intel Mac 实机结果。 +2. 从 [weixshaw/zcode-chatgpt-bridge Releases](https://github.com/weixshaw/zcode-chatgpt-bridge/releases) 下载配套 ZIP。解压、检查源码与 `SHA256SUMS.txt` 后,运行 `安装.command`。桥接服务是独立前置依赖;仅安装此命令插件不会安装服务。 +3. 在本地控制台点击 **Continue with ChatGPT**,在 OpenAI 官方页面完成授权,允许使用 ChatGPT 套餐。模型和额度取决于账号/工作区权限;目录可见不等于推理访问已验证。 +4. 点击 **应用到 ZCode** 写入本地连接及账号模型目录,或将控制页的 Base URL、本地密钥手动填写到 **OpenAI Responses** 自定义供应商中。新建 ZCode 会话并选择桥接模型。 +5. 从社区市场安装并启用本插件。官方尚未收录时,可将 `https://github.com/weixshaw/zcode-chatgpt-bridge` 添加为个人插件市场(仓库根目录含 `marketplace.json`)。 + +| 命令 | 行为 | +| --- | --- | +| `/chatgpt-connect` | 打开本机账号及供应商配置控制台 | +| `/chatgpt-status` | 查看服务状态、已保存账号标签和本次运行的推理计数 | +| `/chatgpt-models` | 刷新当前账号模型目录 | +| `/chatgpt-doctor` | 诊断服务、登录和模型目录,不发起推理 | + +命令通过 `node` 调用当前用户 macOS Application Support 目录下的配套 CLI,要求 Agent 的 PATH 中有 Node.js,并遵循当前 Agent 的正常工具权限流程。打开控制台不会切换当前会话的模型。服务缺失时,先从上述仓库安装。 + +## 网络、权限与副作用 + +- 插件命令执行本地 Node.js 进程。`connect` 打开系统浏览器,`models` / `doctor` 可能通过配套服务访问 OpenAI。插件本身没有自动 Hook、后台动作或模型请求。 +- 配套服务将程序和受保护数据写入 `~/Library/Application Support/ZCode ChatGPT Bridge/`,并在 `~/Library/LaunchAgents/` 创建当前用户的后台服务。它绑定 `127.0.0.1`(默认端口 19781),其运行独立于插件启停。 +- 服务访问 `auth.openai.com` 完成注册、登录、签名密钥发现、刷新及撤销,访问 `api.openai.com` 获取模型目录并推理。源码/安装包来自 GitHub,从源码安装会从 npm 获取锁定依赖。配置的 HTTP 代理可承载相应网络请求。 +- 仅点击 **应用到 ZCode** 时,才会在创建用户专属备份后向 `~/.zcode/v2/provider_config.json` 写入桥接供应商和模型规则,保留其他供应商与默认模型。也可手动配置。 +- OAuth 凭据按账号保存在本机(数据目录 `0700`,文件 `0600`),不读取 Codex 凭据,不提交、不通过这些命令输出,也不写入 ZCode 供应商配置。本地连接密钥与 OAuth 凭据分离。`status` 可能显示账号邮箱/标签,请勿公开粘贴其输出。 +- ZCode 为模型请求选取的提示词、文件和工具结果会发送给 OpenAI。桥接仅在有限内存中缓存续接历史,不记录提示词/回复日志。服务重启、账号切换或缓存淘汰后需新建会话或重发完整历史。 +- 实际模型使用会消耗已授权的 ChatGPT 套餐额度;订阅通道无需 OpenAI API Key,不保证账号资格或额外额度。 + +本集成面向本机 macOS 工作区。SSH/容器 Agent 的 `127.0.0.1` 指向其执行环境,需要在远端独立部署并授权;不要复制本机凭据到远端。 + +## 停用与移除 + +停用/卸载此插件仅移除命令。先在控制台退出以撤销可续期会话,再运行配套 `卸载.command`,停止并移除后台服务和程序;数据会保留,供用户明确删除。ZCode 供应商需在设置中单独移除。远端撤销未确认时,可在 [ChatGPT 设置](https://chatgpt.com/settings/usage)断开应用。 + +## 验证与来源 + +配套服务有 19 项自动测试。其 0.1.0 实现已完成 GPT-6.1-Sol 的真实文本、本地函数调用和工具结果续接验证,并通过 ZCode 3.15.3 写入/读取文件、返回 `NATIVE_OK` 的实测;四个命令可被已安装 ZCode 发现。这不代表所有模型、工具或未来版本均通过验证,详见配套仓库 `VERIFICATION.md`。 + +插件及配套源码:[weixshaw/zcode-chatgpt-bridge](https://github.com/weixshaw/zcode-chatgpt-bridge),MIT 许可。配套服务依赖 `jose` 和 `undici`(均为 MIT),版本和声明在该仓库中。本命令插件没有嵌入第三方代码。OpenAI 与 ZCode 为外部服务/产品依赖。本项目为独立社区项目,与 OpenAI、Z.ai 无隶属关系。 diff --git a/external_plugins/chatgpt-bridge/commands/chatgpt-connect.md b/external_plugins/chatgpt-bridge/commands/chatgpt-connect.md new file mode 100644 index 0000000..05eec4f --- /dev/null +++ b/external_plugins/chatgpt-bridge/commands/chatgpt-connect.md @@ -0,0 +1,10 @@ +--- +description: 打开本机 ChatGPT 订阅桥接控制台,完成授权或查看连接配置 +--- +使用终端执行下面的命令,打开独立的本地控制台。登录由用户在 OpenAI 官方浏览器页面完成,不要代填账号密码,不读取或输出 state.json、OAuth token、本地 API Key 或管理密钥。 + +```sh +node "$HOME/Library/Application Support/ZCode ChatGPT Bridge/app/bin/bridge.mjs" open +``` + +向用户说明:控制台可登录 ChatGPT、刷新账号模型目录,并提供添加 ZCode 自定义供应商所需的信息;接口格式选 OpenAI Responses。若服务没有安装,指出需要先运行发行包中的“安装.command”。不要把本插件描述为已替换当前会话主模型。 diff --git a/external_plugins/chatgpt-bridge/commands/chatgpt-doctor.md b/external_plugins/chatgpt-bridge/commands/chatgpt-doctor.md new file mode 100644 index 0000000..3735e22 --- /dev/null +++ b/external_plugins/chatgpt-bridge/commands/chatgpt-doctor.md @@ -0,0 +1,4 @@ +--- +description: 诊断 ChatGPT 桥接服务、登录授权与模型目录 +--- +执行 `node "$HOME/Library/Application Support/ZCode ChatGPT Bridge/app/bin/bridge.mjs" doctor`。区分本地服务、账号授权、模型目录和真实推理状态。doctor 不会发起付费推理,也不能证明工具调用已验证。需要完整推理验证时,由用户在 ZCode 选择桥接模型并发送任务。不要输出凭据或读取 state.json。 diff --git a/external_plugins/chatgpt-bridge/commands/chatgpt-models.md b/external_plugins/chatgpt-bridge/commands/chatgpt-models.md new file mode 100644 index 0000000..103dd36 --- /dev/null +++ b/external_plugins/chatgpt-bridge/commands/chatgpt-models.md @@ -0,0 +1,4 @@ +--- +description: 从当前已授权 ChatGPT 账号刷新可选模型目录 +--- +执行 `node "$HOME/Library/Application Support/ZCode ChatGPT Bridge/app/bin/bridge.mjs" models`。使用返回的真实模型 ID,不推测可用模型或额度;如未登录,引导用户使用 /chatgpt-connect。不要读取凭据文件。 diff --git a/external_plugins/chatgpt-bridge/commands/chatgpt-status.md b/external_plugins/chatgpt-bridge/commands/chatgpt-status.md new file mode 100644 index 0000000..1427017 --- /dev/null +++ b/external_plugins/chatgpt-bridge/commands/chatgpt-status.md @@ -0,0 +1,4 @@ +--- +description: 查看本机 ChatGPT 桥接服务与账号连接状态 +--- +执行 `node "$HOME/Library/Application Support/ZCode ChatGPT Bridge/app/bin/bridge.mjs" status`,用中文简要报告服务状态、当前账号与完整推理次数。不要读取或输出凭据文件。连接成功不等于推理已验证。 diff --git a/marketplace.json b/marketplace.json index 185ac4d..395df17 100644 --- a/marketplace.json +++ b/marketplace.json @@ -1253,6 +1253,27 @@ "mcp", "game-development" ] + }, + { + "name": "chatgpt-bridge", + "source": "./external_plugins/chatgpt-bridge", + "version": "0.1.1", + "description": "Manage the local ChatGPT plan bridge", + "description_i18n": { + "en": "Manage the local ChatGPT plan bridge", + "zh-CN": "管理本机 ChatGPT 订阅桥接的连接、模型和诊断" + }, + "category": "developer-tools", + "author": { + "name": "weixshaw", + "url": "https://github.com/weixshaw" + }, + "homepage": "https://github.com/weixshaw/zcode-chatgpt-bridge", + "keywords": [ + "chatgpt", + "openai", + "macos" + ] } ] }