@ktkid/kmh-codex-cli 0.1.1 → 0.1.2

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
@@ -2,9 +2,7 @@
2
2
  description: 在 KMH 使用本机官方 Codex CLI 登录的模型:挂载配置、隔离开关、原生工具审批与逐项选择、生图展示、token 用量与会话连接状态小球,以及差分续聊与故障排查入口。
3
3
  ---
4
4
 
5
- # @ktkid/kmh-codex-cli
6
-
7
- 本 npm 包使用 macOS arm64 的官方 Codex CLI 固定版依赖。插件沿用本机现有的 Codex 登录。
5
+ # @kmh/codex-cli
8
6
 
9
7
  ## 概述
10
8
 
@@ -46,7 +44,7 @@ description: 在 KMH 使用本机官方 Codex CLI 登录的模型:挂载配置
46
44
 
47
45
  ```yaml
48
46
  - id: kmh-codex-cli
49
- name: "@ktkid/kmh-codex-cli"
47
+ name: "@kmh/codex-cli"
50
48
  config:
51
49
  # 默认使用插件自带启动器;显式 command 可指定其他经过验证的程序。
52
50
  cwd: !!js process.cwd()
@@ -124,12 +122,13 @@ token 用量:`turn/completed` 的 turn 不携带用量(0.162 wire 实测)
124
122
 
125
123
  图片生成结果的展示:Codex 原生 `image_gen.imagegen` 工具在默认隔离下即对模型可用(托管 API 调用,无本地执行与审批)。生成产物由 Codex 落盘到 `~/.codex/generated_images/<threadId>/`;桥在收到对应 `item/completed` 通知时读取落盘文件、经宿主附件服务(`ctx.attachments.saveImages`)落成 `ImageAttachmentRef`,并以 image 内容块送回 KMH,会话内直接展示该图片(2026-10-08 真机闭环:叙述块、image 块与尺寸附注并存渲染)。投影是展示增强:读取或入库失败时跳过并告警(落盘路径即恢复入口),生成与续推链路不受影响;同一生图项按 id 去重,一回合多张图片逐项展示。注意:image 块使用独立流块索引(`<id>:image`)——与叙述块共用 item id 的索引会让组装器按先关先赢丢弃 image 块。
126
124
 
127
- 独立服务通过公开子路径 `@ktkid/kmh-codex-cli/imagegen` 导入 `Config`、`ImageRequest` 和 `generateImage`,复用本包的进程连接与隔离。执行器依赖调用方提供的 subprocess 服务,确认 ChatGPT 登录后创建一次性原生会话,返回 PNG 字节与实际尺寸,并在返回前等待进程回收。HTTP 服务、任务保存与中继配置由孔明主仓的图片生成服务维护。
125
+ 独立服务通过公开子路径 `@kmh/codex-cli/imagegen` 导入 `Config`、`ImageRequest` 和 `generateImage`,复用本包的进程连接与隔离。执行器依赖调用方提供的 subprocess 服务,确认 ChatGPT 登录后创建一次性原生会话,返回 PNG 字节与实际尺寸,并在返回前等待进程回收。HTTP 服务、任务保存与中继配置由孔明主仓的图片生成服务维护。
128
126
 
129
127
  | 模块 | 职责 |
130
128
  | --------------------------------------------------- | ------------------------------------------------ |
131
129
  | `src/connection.ts` | 行协议连接:进程、握手、双向请求分发、回收 |
132
130
  | `src/cursor.ts` | 差分游标:前缀对齐与增量切分 |
131
+ | `src/session-history.ts` | 从 DSH 会话事件核对系统提示替换和首步未投递输入 |
133
132
  | `src/turn.ts` | 回合状态机:挂起回执、续推、interrupt、原生 fork |
134
133
  | `src/isolation.ts` | 工具/技能/钩子隔离的参数生成与核对 |
135
134
  | `src/adapter.ts` | LlmAdapter:模型映射、流投影、会话驱动 |
@@ -173,7 +172,7 @@ pnpm test
173
172
 
174
173
  使用 Node.js 24.9+ 和 pnpm 11.7.0。独立仓使用 npm 发布的 DSH `0.2.2-rc.1` 开发依赖。GitHub CI 在 macOS arm64 执行完整回归,覆盖默认启动器和原生文件修改。测试默认使用[插件固定的官方 CLI](bin/README.md);`KMH_CODEX_BINARY` 可以指定经过版本验证的官方程序绝对路径。
175
174
 
176
- 独立仓提供 `cordis.patch.yml`。DSH profile 可以在 `dsh.profile.bundles` 中引用 `@ktkid/kmh-codex-cli`,按需使用插件行 `kmh-codex-cli` 覆盖配置。
175
+ 独立仓提供 `cordis.patch.yml`。DSH profile 可以在 `dsh.profile.bundles` 中引用 `@kmh/codex-cli`,按需使用插件行 `kmh-codex-cli` 覆盖配置。
177
176
 
178
177
  ```sh
179
178
  pnpm install --frozen-lockfile
@@ -236,6 +235,8 @@ pnpm format:check
236
235
 
237
236
  工具声明只在首次 `thread/start` 传入;后续 `thread/resume` 保持原编号、原工具及原生历史。详细原始执行事件受 CLI 恢复能力限制,界面按普通通知显示可提供的进度与结果。跨回合缓存命中由提供方决定。声明指纹包含来源、名称、完整参数、原生版本与所选控制。
238
237
 
238
+ 客户端恢复会话时,DSH 可以替换宿主生成的系统提示。插件通过 DSH 会话投影校验同一条提示的替换记录,并继续核对聊天历史,保持原生绑定。DSH 的工具目录通知保留在会话日志中,原生请求继续沿用已保存的工具选择。首步因分叉位置校验失败且尚未投递的手工输入,随下次续聊按原顺序提交,原生接纳后推进游标。
239
+
239
240
  ---
240
241
 
241
242
  <a id="known-limitations-and-deferred-work"></a>
@@ -3,8 +3,8 @@ import { z } from "zod";
3
3
  /** CLI 连接状态;重试期间 streaming 保持 true。 */
4
4
  export declare const SessionLiveState: z.ZodObject<{
5
5
  color: z.ZodEnum<{
6
- green: "green";
7
6
  gray: "gray";
7
+ green: "green";
8
8
  red: "red";
9
9
  }>;
10
10
  streaming: z.ZodBoolean;
@@ -18,8 +18,8 @@ export type SessionLiveState = z.infer<typeof SessionLiveState>;
18
18
  export declare const LiveSnapshot: z.ZodObject<{
19
19
  sessions: z.ZodArray<z.ZodObject<{
20
20
  color: z.ZodEnum<{
21
- green: "green";
22
21
  gray: "gray";
22
+ green: "green";
23
23
  red: "red";
24
24
  }>;
25
25
  streaming: z.ZodBoolean;
@@ -56,15 +56,15 @@ export type QuotaGroup = z.infer<typeof QuotaGroup>;
56
56
  export declare const QuotaError: z.ZodObject<{
57
57
  area: z.ZodEnum<{
58
58
  windows: "windows";
59
- account: "account";
60
59
  credits: "credits";
61
60
  spend: "spend";
62
61
  resets: "resets";
62
+ account: "account";
63
63
  }>;
64
64
  code: z.ZodEnum<{
65
+ unsupported: "unsupported";
65
66
  "read-failed": "read-failed";
66
67
  "invalid-data": "invalid-data";
67
- unsupported: "unsupported";
68
68
  }>;
69
69
  message: z.ZodString;
70
70
  }, z.core.$strip>;
@@ -72,11 +72,11 @@ export type QuotaError = z.infer<typeof QuotaError>;
72
72
  export declare const QuotaView: z.ZodObject<{
73
73
  accountEpoch: z.ZodNumber;
74
74
  state: z.ZodEnum<{
75
- error: "error";
76
- unsupported: "unsupported";
77
75
  loading: "loading";
76
+ error: "error";
78
77
  ready: "ready";
79
78
  "signed-out": "signed-out";
79
+ unsupported: "unsupported";
80
80
  }>;
81
81
  fetchedAtMs: z.ZodNullable<z.ZodNumber>;
82
82
  nextRefreshAtMs: z.ZodNumber;
@@ -117,15 +117,15 @@ export declare const QuotaView: z.ZodObject<{
117
117
  errors: z.ZodArray<z.ZodObject<{
118
118
  area: z.ZodEnum<{
119
119
  windows: "windows";
120
- account: "account";
121
120
  credits: "credits";
122
121
  spend: "spend";
123
122
  resets: "resets";
123
+ account: "account";
124
124
  }>;
125
125
  code: z.ZodEnum<{
126
+ unsupported: "unsupported";
126
127
  "read-failed": "read-failed";
127
128
  "invalid-data": "invalid-data";
128
- unsupported: "unsupported";
129
129
  }>;
130
130
  message: z.ZodString;
131
131
  }, z.core.$strip>>;