@shuind/dsh-codex-harness 0.1.33 → 0.1.35

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
@@ -1,141 +1,141 @@
1
- # @shuind/dsh-codex-harness
2
-
3
- 使用精简版 Codex 提示词和工具,以及改善体验的功能。
4
-
5
- ## 功能
6
-
7
- - **精简 Codex coding-agent 提示词**:使用精简版系统提示词;身份、模型和工作目录由 `dsh-persona` 提供,避免重复的 Harness 身份说明,同时保留必要的工具契约和编码工作流。
8
- - **Codex 工具**:`exec_command`、`write_stdin`、`apply_patch`、`update_plan`;`apply_patch` 匹配失败时会显示文件、hunk、行号、可见空白和附近文件内容,便于修正上下文。
9
- - **后台任务**:`exec_command` 支持 `run_in_background: true`,立即返回 DSH `job_id`;使用 `job_output` 读取输出、`job_kill` 停止任务。任务完成时,忙碌中的 agent 会在下一步收到 inbox 注入;空闲 agent 默认保持安静,等下一次唤醒时再处理完成消息。
10
- - **GPT 能力补全**:为 GPT 系列模型补充图片输入和思考强度选项;不会覆盖用户已有的显式配置。
11
- - **Fast**:仅在 Codex preset 的模型选择菜单中显示,开启后向 Responses 请求发送 `service_tier: "priority"`。
12
- - **Legacy Web compatibility**: The plugin uses only slots present in the legacy host. The context-size control is appended to the host context-usage popup, and the activity line is appended beside `Deep diving...`; no host upgrade is required.
13
- - **Responses 原生 apply_patch**:在 GPT Responses 请求的插件传输边界,把普通 JSON function tool 改写为 `type: "custom"` + OpenAI `lark` grammar;下一轮历史同步改写为 `custom_tool_call`。如果中转站拒绝 custom tool,则自动回退到普通 function tool,不改变 DSH 工具执行器。
14
- - **远程搜索与压缩**:OpenAI Responses 请求默认优先使用 hosted `web_search` 和 `/responses/compact`;失败时回退到 DSH 的本地实现。
15
- - **远程压缩用量**:`/responses/compact` 返回标准 `usage` 时,插件会把 `input_tokens`、缓存读写和 `output_tokens` 原样拆分为 DSH 的用量字段;不再把远程压缩伪造成 `0`。中转站缺失或返回不一致的 usage 时,插件不会编造数字。
16
- - **上下文容量**:在 Web 中设置 `1K`–`1000K` tokens,设置值作用于下一次请求。
17
- - **自动压缩阈值**:Codex preset 的自动压缩会读取最新请求持久化的有效上下文容量;例如设置 `400K` 时,默认 `80%` pressure threshold 是 `320K`,不会错误地按适配器默认 `262,144` 在约 `210K` 提前触发。
18
- - **活动状态**:Codex 请求模型、接收模型回复或进行上下文压缩时,在 `Deep diving...` 右侧显示对应阶段和耗时,让长时间 Deep Diving 不再像卡住。
19
-
20
- ## 安装
21
-
22
- ```sh
23
- dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.33
24
- ```
25
-
26
- 重启 Web,创建新会话,在模式菜单中选择 **Codex 模式**。
27
-
28
- ## 配置
29
-
30
- 在 DSH 的 Models / `llm-pi-ai` 中配置 Responses provider、endpoint、API key 和模型。例如:
31
-
32
- ```yaml
33
- api: openai-responses
34
- baseURL: https://your-responses-endpoint.example.com
35
- apiKeyEnv: OPENAI_API_KEY
36
- ```
37
-
38
- 模型列表中填写中转站实际支持的 GPT 模型。
39
-
40
- ## 请求设置
41
-
42
- ### Fast
43
-
44
- Fast 与 `reasoning_effort` 独立。开启 Fast 后,GPT Responses 请求会携带:
45
-
46
- ```json
47
- {
48
- "service_tier": "priority"
49
- }
50
- ```
51
-
52
- Fast 设置保存在 `codex` 命名空间,只对 Codex preset 生效。
53
-
54
- ### 上下文容量
55
-
56
- 点击 Web 顶部的上下文使用量指示器,可以设置下一次请求的上下文容量。上方 meter 显示当前请求的实际容量;修改设置后,需要发送下一次请求才会更新。Codex preset 的自动压缩也使用这个已经持久化的有效容量。
57
-
58
- 上下文容量使用整数 K tokens,范围为 `1K` 到 `1000K`。实际可用上限仍取决于模型和中转站支持情况。
59
-
60
- ### 活动状态
61
-
62
- Codex 发起模型请求时,Web 会在 `Deep diving...` 右侧显示 `请求中... · Ns`;收到首个非空模型 token(非流式适配器则收到 `assistant/message`)后切换为 `回复中... · Ns`。模型回复结束、进入工具调用、压缩结束或下一轮开始后自动隐藏。该状态由 Host 的 `sessionProjections` 投影驱动,因此本地压缩和远程 `/responses/compact` 都会显示同一种状态。
63
-
64
- 如果当前 DSH 组合没有加载 projection 服务,插件会跳过注册,客户端也会自动隐藏这行,不影响普通会话。
65
-
66
- ## 随包提供的 Codex preset
67
-
68
- 安装插件后,首次启动对应的 DSH profile 时,插件会安装两套随包提供的 preset:
69
-
70
- - **Codex 模式**:使用精简版 Codex 提示词和工具,以及改善体验的功能。
71
- - **Codex 协作模式**:额外加入协作提示词,预期获得更好的体验。
72
-
73
- 它们分别位于 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/codex/` 和 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/codex-collaboration/`。如果对应目录已经存在,插件会保留你的文件,不会覆盖自定义内容。
74
-
75
- 在 Web 的 **Agent 预设** 中选择 **Codex 模式** 或 **Codex 协作模式**,再新建会话即可使用随包提供的 Codex 工具、网页搜索、远程压缩和 Skills 组合。两套 preset 共用 Fast、思考强度、GPT 图片输入和上下文容量设置;只有系统提示词是否包含协作指导不同。
76
-
77
- ## 自定义 preset
78
-
79
- 只有在想自己组合工具、提示词,或修改插件配置时才需要自定义 preset。自定义 preset 放在 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/<id>/` 目录中。
80
-
81
- ### 示例:创建一个带协作提示词的 Codex preset
82
-
83
- 例如创建目录 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/my-codex/`,并写入 `agent.cordis.yml`:
84
-
85
- ```yaml
86
- - id: persona
87
- name: '@deepseek-ai/dsh-persona'
88
- config:
89
- text: 你是一个使用 DSH 工具工作的 Codex 编程助手。
90
-
91
- - id: codex-tools
92
- name: '@shuind/dsh-codex-harness'
93
- config:
94
- collaborationPrompt: true
95
-
96
- - id: codex-jobs
97
- name: '@deepseek-ai/dsh-tool-jobs'
98
- config:
99
- completionDelivery: quiet
100
- ```
101
-
102
- 再写入 `preset.yml`,让 Web 中显示更清晰的名称:
103
-
104
- ```yaml
105
- name: My Codex
106
- description: 使用 Codex 工具并开启可选协作提示词。
107
- order: 10
108
- ```
109
-
110
- 然后在 Web 的 **Agent 预设** 中选择 `My Codex`,再新建会话。这个 preset 会加载 Codex 工具,并开启协作提示词;网页搜索、远程压缩、后台任务控制和 Skills 等其他功能需要在同一个 `agent.cordis.yml` 中按需添加。若希望自定义 preset 也修正自动压缩阈值,请在 compaction 隔离组中使用 `@shuind/dsh-codex-harness/compaction` 替代 `@deepseek-ai/dsh-compaction-basic`。
111
-
112
- ### 可选协作提示词(私货)
113
-
114
- 这段提示词默认关闭,不会注入系统提示词。需要时,在自定义 `agent.cordis.yml` 中开启:
115
-
116
- ```yaml
117
- - id: codex-tools
118
- name: '@shuind/dsh-codex-harness'
119
- config:
120
- collaborationPrompt: true
121
- ```
122
-
123
- 开启后,Codex preset 会在系统提示词中注入以下协作要求:
124
-
125
- ```text
126
- Ask, align, and clarify first. Gather enough context from the user then achieve the user's goal through the clearest, most effective path.
127
- Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
128
- Convey enough valuable information with as few words as possible. Stay focused on the end goal.
129
- Solve problems by thinking from first principles and at a higher level.
130
- ```
131
-
132
- ## 注意事项
133
-
134
- - preset 在创建会话时确定;已有会话不会自动切换到 Codex 模式。
135
- - GPT 模型的图片输入和思考强度属于能力补全;用户已明确配置的字段会被保留。
136
- - hosted search、远程压缩以及 reasoning 参数的可用性取决于实际 Responses 中转站和模型。
137
- - `apply_patch` 的 custom grammar 改写只作用于 GPT Responses 请求;中转站必须接受 OpenAI custom tools 和 Lark grammar。拒绝时插件会自动发送原始 JSON function-call 请求。
138
-
139
- ## License
140
-
141
- MIT
1
+ # @shuind/dsh-codex-harness
2
+
3
+ 使用精简版 Codex 提示词和工具,以及改善体验的功能。
4
+
5
+ ## 功能
6
+
7
+ - **精简 Codex coding-agent 提示词**:使用精简版系统提示词;身份、模型和工作目录由 `dsh-persona` 提供,避免重复的 Harness 身份说明,同时保留必要的工具契约和编码工作流。
8
+ - **Codex 工具**:`exec_command`、`write_stdin`、`apply_patch`、`update_plan`;`apply_patch` 匹配失败时会显示文件、hunk、行号、可见空白和附近文件内容,便于修正上下文。
9
+ - **后台任务**:`exec_command` 支持 `run_in_background: true`,立即返回 DSH `job_id`;使用 `job_output` 读取输出、`job_kill` 停止任务。任务完成时,忙碌中的 agent 会在下一步收到 inbox 注入;空闲 agent 默认保持安静,等下一次唤醒时再处理完成消息。
10
+ - **GPT 能力补全**:为 GPT 系列模型补充图片输入和思考强度选项;不会覆盖用户已有的显式配置。
11
+ - **Fast**:仅在 Codex preset 的模型选择菜单中显示,开启后向 Responses 请求发送 `service_tier: "priority"`。
12
+ - **Legacy Web compatibility**: The plugin uses only slots present in the legacy host. The context-size control is appended to the host context-usage popup, and the activity line is appended beside `Deep diving...`; no host upgrade is required.
13
+ - **Responses 原生 apply_patch**:在 GPT Responses 请求的插件传输边界,把普通 JSON function tool 改写为 `type: "custom"` + OpenAI `lark` grammar;下一轮历史同步改写为 `custom_tool_call`。如果中转站拒绝 custom tool,则自动回退到普通 function tool,不改变 DSH 工具执行器。
14
+ - **远程搜索与压缩**:OpenAI Responses 请求默认优先使用 hosted `web_search` 和 `/responses/compact`;失败时回退到 DSH 的本地实现。
15
+ - **远程压缩用量**:`/responses/compact` 返回标准 `usage` 时,插件会把 `input_tokens`、缓存读写和 `output_tokens` 原样拆分为 DSH 的用量字段;不再把远程压缩伪造成 `0`。中转站缺失或返回不一致的 usage 时,插件不会编造数字。
16
+ - **上下文容量**:在 Web 中设置 `1K`–`1000K` tokens,设置值作用于下一次请求。
17
+ - **自动压缩阈值**:Codex preset 的自动压缩会读取最新请求持久化的有效上下文容量;例如设置 `400K` 时,默认 `80%` pressure threshold 是 `320K`,不会错误地按适配器默认 `262,144` 在约 `210K` 提前触发。
18
+ - **活动状态**:Codex 请求模型、接收模型回复或进行上下文压缩时,在 `Deep diving...` 右侧显示对应阶段和耗时,让长时间 Deep Diving 不再像卡住。
19
+
20
+ ## 安装
21
+
22
+ ```sh
23
+ dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.35
24
+ ```
25
+
26
+ 重启 Web,创建新会话,在模式菜单中选择 **Codex 模式**。
27
+
28
+ ## 配置
29
+
30
+ 在 DSH 的 Models / `llm-pi-ai` 中配置 Responses provider、endpoint、API key 和模型。例如:
31
+
32
+ ```yaml
33
+ api: openai-responses
34
+ baseURL: https://your-responses-endpoint.example.com
35
+ apiKeyEnv: OPENAI_API_KEY
36
+ ```
37
+
38
+ 模型列表中填写中转站实际支持的 GPT 模型。
39
+
40
+ ## 请求设置
41
+
42
+ ### Fast
43
+
44
+ Fast 与 `reasoning_effort` 独立。开启 Fast 后,GPT Responses 请求会携带:
45
+
46
+ ```json
47
+ {
48
+ "service_tier": "priority"
49
+ }
50
+ ```
51
+
52
+ Fast 设置保存在 `codex` 命名空间,只对 Codex preset 生效。
53
+
54
+ ### 上下文容量
55
+
56
+ 点击 Web 顶部的上下文使用量指示器,可以设置下一次请求的上下文容量。上方 meter 显示当前请求的实际容量;修改设置后,需要发送下一次请求才会更新。Codex preset 的自动压缩也使用这个已经持久化的有效容量。
57
+
58
+ 上下文容量使用整数 K tokens,范围为 `1K` 到 `1000K`。实际可用上限仍取决于模型和中转站支持情况。
59
+
60
+ ### 活动状态
61
+
62
+ Codex 发起模型请求时,Web 会在 `Deep diving...` 右侧显示 `请求中... · Ns`;收到首个非空模型 token(非流式适配器则收到 `assistant/message`)后切换为 `回复中... · Ns`。模型回复结束、进入工具调用、压缩结束或下一轮开始后自动隐藏。该状态由 Host 的 `sessionProjections` 投影驱动,因此本地压缩和远程 `/responses/compact` 都会显示同一种状态。
63
+
64
+ 如果当前 DSH 组合没有加载 projection 服务,插件会跳过注册,客户端也会自动隐藏这行,不影响普通会话。
65
+
66
+ ## 随包提供的 Codex preset
67
+
68
+ 安装插件后,首次启动对应的 DSH profile 时,插件会安装两套随包提供的 preset:
69
+
70
+ - **Codex 模式**:使用精简版 Codex 提示词和工具,以及改善体验的功能。
71
+ - **Codex 协作模式**:额外加入协作提示词,预期获得更好的体验。
72
+
73
+ 它们分别位于 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/codex/` 和 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/codex-collaboration/`。如果对应目录已经存在,插件会保留你的文件,不会覆盖自定义内容。
74
+
75
+ 在 Web 的 **Agent 预设** 中选择 **Codex 模式** 或 **Codex 协作模式**,再新建会话即可使用随包提供的 Codex 工具、网页搜索、远程压缩和 Skills 组合。两套 preset 共用 Fast、思考强度、GPT 图片输入和上下文容量设置;只有系统提示词是否包含协作指导不同。
76
+
77
+ ## 自定义 preset
78
+
79
+ 只有在想自己组合工具、提示词,或修改插件配置时才需要自定义 preset。自定义 preset 放在 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/<id>/` 目录中。
80
+
81
+ ### 示例:创建一个带协作提示词的 Codex preset
82
+
83
+ 例如创建目录 `${DSH_HOME:-$HOME/.dsh}/.agent-presets/my-codex/`,并写入 `agent.cordis.yml`:
84
+
85
+ ```yaml
86
+ - id: persona
87
+ name: '@deepseek-ai/dsh-persona'
88
+ config:
89
+ text: 你是一个使用 DSH 工具工作的 Codex 编程助手。
90
+
91
+ - id: codex-tools
92
+ name: '@shuind/dsh-codex-harness'
93
+ config:
94
+ collaborationPrompt: true
95
+
96
+ - id: codex-jobs
97
+ name: '@deepseek-ai/dsh-tool-jobs'
98
+ config:
99
+ completionDelivery: quiet
100
+ ```
101
+
102
+ 再写入 `preset.yml`,让 Web 中显示更清晰的名称:
103
+
104
+ ```yaml
105
+ name: My Codex
106
+ description: 使用 Codex 工具并开启可选协作提示词。
107
+ order: 10
108
+ ```
109
+
110
+ 然后在 Web 的 **Agent 预设** 中选择 `My Codex`,再新建会话。这个 preset 会加载 Codex 工具,并开启协作提示词;网页搜索、远程压缩、后台任务控制和 Skills 等其他功能需要在同一个 `agent.cordis.yml` 中按需添加。若希望自定义 preset 也修正自动压缩阈值,请在 compaction 隔离组中使用 `@shuind/dsh-codex-harness/compaction` 替代 `@deepseek-ai/dsh-compaction-basic`。
111
+
112
+ ### 可选协作提示词(私货)
113
+
114
+ 这段提示词默认关闭,不会注入系统提示词。需要时,在自定义 `agent.cordis.yml` 中开启:
115
+
116
+ ```yaml
117
+ - id: codex-tools
118
+ name: '@shuind/dsh-codex-harness'
119
+ config:
120
+ collaborationPrompt: true
121
+ ```
122
+
123
+ 开启后,Codex preset 会在系统提示词中注入以下协作要求:
124
+
125
+ ```text
126
+ Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
127
+ Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
128
+ Convey enough valuable information with as few words as possible. Stay focused on the end goal.
129
+ Solve problems by thinking from first principles and at a higher level.
130
+ ```
131
+
132
+ ## 注意事项
133
+
134
+ - preset 在创建会话时确定;已有会话不会自动切换到 Codex 模式。
135
+ - GPT 模型的图片输入和思考强度属于能力补全;用户已明确配置的字段会被保留。
136
+ - hosted search、远程压缩以及 reasoning 参数的可用性取决于实际 Responses 中转站和模型。
137
+ - `apply_patch` 的 custom grammar 改写只作用于 GPT Responses 请求;中转站必须接受 OpenAI custom tools 和 Lark grammar。拒绝时插件会自动发送原始 JSON function-call 请求。
138
+
139
+ ## License
140
+
141
+ MIT
package/lib/client.js CHANGED
@@ -284,15 +284,19 @@ window.__ModuleLoader__.load({
284
284
  function elapsedSeconds(startedAt, now) {
285
285
  return Math.max(0, Math.floor((now - startedAt) / 1e3));
286
286
  }
287
- function ActivityLine({ sessionId, useSession, useSessions, useProjection, t }) {
288
- const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
289
- const projectedActivity = useProjection("codexActivity");
290
- const fallbackActivity = useSession(modelActivity, sameModelActivity);
291
- const normalizedProjectedActivity = projectedActivity?.activity === "awaiting-model" ? {
287
+ /** Prefer the session snapshot when an older projection host only exposes null. */
288
+ function resolveActivity(agentPreset, projectedActivity, fallbackActivity) {
289
+ if (!isCodexPresetId(agentPreset)) return null;
290
+ if (projectedActivity?.activity === "awaiting-model") return {
292
291
  activity: fallbackActivity?.activity ?? "requesting-model",
293
292
  startedAt: fallbackActivity?.startedAt ?? projectedActivity.startedAt
294
- } : projectedActivity;
295
- const activity = projectedActivity !== void 0 ? normalizedProjectedActivity : isCodexPresetId(agentPreset) && fallbackActivity !== void 0 ? fallbackActivity : null;
293
+ };
294
+ if (projectedActivity === null) return fallbackActivity ?? null;
295
+ return projectedActivity ?? fallbackActivity ?? null;
296
+ }
297
+ function ActivityLine({ sessionId, useSession, useSessions, useProjection, t, position }) {
298
+ const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
299
+ const activity = resolveActivity(agentPreset, useProjection("codexActivity"), useSession(modelActivity, sameModelActivity));
296
300
  const [now, setNow] = (0, react.useState)(() => Date.now());
297
301
  (0, react.useEffect)(() => {
298
302
  if (!isCodexPresetId(agentPreset) || activity === void 0 || activity === null) return void 0;
@@ -316,12 +320,19 @@ window.__ModuleLoader__.load({
316
320
  alignItems: "center",
317
321
  gap: 7,
318
322
  minHeight: 26,
319
- marginLeft: 10,
323
+ marginLeft: position === void 0 ? 10 : 0,
320
324
  color: "var(--dsw-alias-label-secondary)",
321
325
  fontSize: 12,
322
326
  lineHeight: "20px",
323
327
  whiteSpace: "nowrap",
324
- WebkitTextFillColor: "currentColor"
328
+ WebkitTextFillColor: "currentColor",
329
+ ...position === void 0 ? {} : {
330
+ position: "fixed",
331
+ left: position.left,
332
+ top: position.top,
333
+ zIndex: 100,
334
+ pointerEvents: "none"
335
+ }
325
336
  },
326
337
  children: [
327
338
  (0, react_jsx_runtime.jsx)("span", {
@@ -361,8 +372,48 @@ window.__ModuleLoader__.load({
361
372
  return null;
362
373
  }
363
374
  function findTurnStatus() {
364
- for (const status of document.querySelectorAll("[role=\"status\"]")) if (status.textContent?.includes("Deep diving...") === true && status.closest("[data-chat-flow]") !== null) return status;
365
- return null;
375
+ let fallback = null;
376
+ for (const status of document.querySelectorAll("[role=\"status\"]")) {
377
+ if (status.closest("[data-chat-flow]") === null) continue;
378
+ fallback ??= status;
379
+ if (status.textContent?.includes("Deep diving...") === true || status.className.toString().includes("turnStatus")) return status;
380
+ }
381
+ return fallback;
382
+ }
383
+ function useTurnStatusPosition(target) {
384
+ const [position, setPosition] = (0, react.useState)(null);
385
+ (0, react.useLayoutEffect)(() => {
386
+ if (target === null) {
387
+ setPosition(null);
388
+ return;
389
+ }
390
+ const update = () => {
391
+ if (!target.isConnected) {
392
+ setPosition(null);
393
+ return;
394
+ }
395
+ const rect = target.getBoundingClientRect();
396
+ if (rect.width === 0 && rect.height === 0) {
397
+ setPosition(null);
398
+ return;
399
+ }
400
+ setPosition({
401
+ left: Math.round(rect.right + 10),
402
+ top: Math.round(rect.top + (rect.height - 26) / 2)
403
+ });
404
+ };
405
+ update();
406
+ window.addEventListener("resize", update);
407
+ window.addEventListener("scroll", update, true);
408
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(update);
409
+ observer?.observe(target);
410
+ return () => {
411
+ window.removeEventListener("resize", update);
412
+ window.removeEventListener("scroll", update, true);
413
+ observer?.disconnect();
414
+ };
415
+ }, [target]);
416
+ return position;
366
417
  }
367
418
  function useLegacyHostTargets() {
368
419
  const [targets, setTargets] = (0, react.useState)({
@@ -394,6 +445,7 @@ window.__ModuleLoader__.load({
394
445
  function LegacyOverlay(props) {
395
446
  const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t } = props;
396
447
  const { contextDialog, turnStatus } = useLegacyHostTargets();
448
+ const turnStatusPosition = useTurnStatusPosition(turnStatus);
397
449
  const contextWindow = contextWindowFromProjection(useProjection);
398
450
  if (!isCodexPresetId(useSessions((state) => state.byId[sessionId]?.agentPreset))) return null;
399
451
  return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [contextDialog !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ContextSizeControl, {
@@ -404,13 +456,14 @@ window.__ModuleLoader__.load({
404
456
  setSetting,
405
457
  unsetSetting,
406
458
  t
407
- }), contextDialog, "codex-context-size"), turnStatus !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ActivityLine, {
459
+ }), contextDialog, "codex-context-size"), turnStatusPosition !== null && typeof document !== "undefined" && document.body !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ActivityLine, {
408
460
  sessionId,
409
461
  useSession,
410
462
  useSessions,
411
463
  useProjection,
412
- t
413
- }), turnStatus, "codex-activity")] });
464
+ t,
465
+ position: turnStatusPosition
466
+ }), document.body, "codex-activity")] });
414
467
  }
415
468
  const inject = [
416
469
  "slots",
@@ -453,6 +506,7 @@ window.__ModuleLoader__.load({
453
506
  exports.apply = apply;
454
507
  exports.default = client_default;
455
508
  exports.inject = inject;
509
+ exports.resolveActivity = resolveActivity;
456
510
  return module.exports;
457
511
  }
458
512
  });
package/lib/index.js CHANGED
@@ -1284,7 +1284,7 @@ const CODEX_BASE_PROMPT = String.raw`## General
1284
1284
  `;
1285
1285
  const CODEX_COLLABORATION_PROMPT = String.raw`## Collaboration
1286
1286
 
1287
- - Ask, align, and clarify first. Gather enough context from the user then achieve the user's goal through the clearest, most effective path.
1287
+ - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
1288
1288
  - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
1289
1289
  - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
1290
1290
  - Solve problems by thinking from first principles and at a higher level.
@@ -2,6 +2,8 @@
2
2
  import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
3
3
  import type { Context } from '@deepseek-ai/cordis';
4
4
  import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client';
5
+ import type { CodexActivity } from '../activity-types.ts';
6
+ import { modelActivity } from './activity.ts';
5
7
  declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
6
8
  interface CodexSettings {
7
9
  fast: boolean;
@@ -43,7 +45,15 @@ interface InputSettingsControlInjected {
43
45
  }
44
46
  type LegacyOverlayProps = PropsRuntime<typeof LEGACY_OVERLAY_SLOT> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
45
47
  type ActivityProps = Pick<LegacyOverlayProps, 'sessionId' | 'useSession' | 'useSessions' | 'useProjection' | 't'>;
46
- export declare function ActivityLine({ sessionId, useSession, useSessions, useProjection, t }: ActivityProps): import("react").JSX.Element | null;
48
+ type ActivityFallback = ReturnType<typeof modelActivity>;
49
+ /** Prefer the session snapshot when an older projection host only exposes null. */
50
+ export declare function resolveActivity(agentPreset: string | undefined, projectedActivity: CodexActivity | null | undefined, fallbackActivity: ActivityFallback): CodexActivity | null;
51
+ export declare function ActivityLine({ sessionId, useSession, useSessions, useProjection, t, position, }: ActivityProps & {
52
+ position?: {
53
+ left: number;
54
+ top: number;
55
+ };
56
+ }): import("react").JSX.Element | null;
47
57
  export declare const inject: string[];
48
58
  /** Mount all controls through the official composer seats shared by every DSH release. */
49
59
  export declare function apply(ctx: Context): void;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /** Browser controls for the Codex request settings mounted by the Host plugin. */
3
- import { useEffect, useState } from 'react';
3
+ import { useEffect, useLayoutEffect, useState } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import { CODEX_CONTEXT_MAX, CODEX_CONTEXT_UNIT, isCodexPresetId } from "../context.js";
6
6
  import { modelActivity, sameModelActivity } from "./activity.js";
@@ -121,7 +121,21 @@ function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings
121
121
  function elapsedSeconds(startedAt, now) {
122
122
  return Math.max(0, Math.floor((now - startedAt) / 1_000));
123
123
  }
124
- export function ActivityLine({ sessionId, useSession, useSessions, useProjection, t }) {
124
+ /** Prefer the session snapshot when an older projection host only exposes null. */
125
+ export function resolveActivity(agentPreset, projectedActivity, fallbackActivity) {
126
+ if (!isCodexPresetId(agentPreset))
127
+ return null;
128
+ if (projectedActivity?.activity === 'awaiting-model') {
129
+ return {
130
+ activity: fallbackActivity?.activity ?? 'requesting-model',
131
+ startedAt: fallbackActivity?.startedAt ?? projectedActivity.startedAt,
132
+ };
133
+ }
134
+ if (projectedActivity === null)
135
+ return fallbackActivity ?? null;
136
+ return projectedActivity ?? fallbackActivity ?? null;
137
+ }
138
+ export function ActivityLine({ sessionId, useSession, useSessions, useProjection, t, position, }) {
125
139
  const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
126
140
  // Keep the projection seam optional: this package must still load when the
127
141
  // host has no session-projection registry or has not carried this key.
@@ -130,17 +144,7 @@ export function ActivityLine({ sessionId, useSession, useSessions, useProjection
130
144
  // fallback only covers the short wire gap before the next projection frame;
131
145
  // tool calls intentionally remain silent because their cards own the status.
132
146
  const fallbackActivity = useSession(modelActivity, sameModelActivity);
133
- // `undefined` means the key has not arrived yet; `null` is an authoritative
134
- // clear and must not be resurrected by the local snapshot fallback.
135
- const normalizedProjectedActivity = projectedActivity?.activity === 'awaiting-model'
136
- ? {
137
- activity: fallbackActivity?.activity ?? 'requesting-model',
138
- startedAt: fallbackActivity?.startedAt ?? projectedActivity.startedAt,
139
- }
140
- : projectedActivity;
141
- const activity = projectedActivity !== undefined ? normalizedProjectedActivity : (isCodexPresetId(agentPreset) && fallbackActivity !== undefined
142
- ? fallbackActivity
143
- : null);
147
+ const activity = resolveActivity(agentPreset, projectedActivity, fallbackActivity);
144
148
  const [now, setNow] = useState(() => Date.now());
145
149
  useEffect(() => {
146
150
  if (!isCodexPresetId(agentPreset) || activity === undefined || activity === null)
@@ -161,12 +165,19 @@ export function ActivityLine({ sessionId, useSession, useSessions, useProjection
161
165
  alignItems: 'center',
162
166
  gap: 7,
163
167
  minHeight: 26,
164
- marginLeft: 10,
168
+ marginLeft: position === undefined ? 10 : 0,
165
169
  color: 'var(--dsw-alias-label-secondary)',
166
170
  fontSize: 12,
167
171
  lineHeight: '20px',
168
172
  whiteSpace: 'nowrap',
169
173
  WebkitTextFillColor: 'currentColor',
174
+ ...(position === undefined ? {} : {
175
+ position: 'fixed',
176
+ left: position.left,
177
+ top: position.top,
178
+ zIndex: 100,
179
+ pointerEvents: 'none',
180
+ }),
170
181
  }, children: [_jsx("span", { "aria-hidden": "true", style: {
171
182
  width: 5,
172
183
  height: 5,
@@ -191,12 +202,51 @@ function findContextMeterDialog() {
191
202
  return null;
192
203
  }
193
204
  function findTurnStatus() {
205
+ let fallback = null;
194
206
  for (const status of document.querySelectorAll('[role="status"]')) {
207
+ if (status.closest('[data-chat-flow]') === null)
208
+ continue;
209
+ fallback ??= status;
195
210
  if (status.textContent?.includes('Deep diving...') === true
196
- && status.closest('[data-chat-flow]') !== null)
211
+ || status.className.toString().includes('turnStatus'))
197
212
  return status;
198
213
  }
199
- return null;
214
+ return fallback;
215
+ }
216
+ function useTurnStatusPosition(target) {
217
+ const [position, setPosition] = useState(null);
218
+ useLayoutEffect(() => {
219
+ if (target === null) {
220
+ setPosition(null);
221
+ return undefined;
222
+ }
223
+ const update = () => {
224
+ if (!target.isConnected) {
225
+ setPosition(null);
226
+ return;
227
+ }
228
+ const rect = target.getBoundingClientRect();
229
+ if (rect.width === 0 && rect.height === 0) {
230
+ setPosition(null);
231
+ return;
232
+ }
233
+ setPosition({
234
+ left: Math.round(rect.right + 10),
235
+ top: Math.round(rect.top + (rect.height - 26) / 2),
236
+ });
237
+ };
238
+ update();
239
+ window.addEventListener('resize', update);
240
+ window.addEventListener('scroll', update, true);
241
+ const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);
242
+ observer?.observe(target);
243
+ return () => {
244
+ window.removeEventListener('resize', update);
245
+ window.removeEventListener('scroll', update, true);
246
+ observer?.disconnect();
247
+ };
248
+ }, [target]);
249
+ return position;
200
250
  }
201
251
  function useLegacyHostTargets() {
202
252
  const [targets, setTargets] = useState({ contextDialog: null, turnStatus: null });
@@ -227,11 +277,12 @@ function useLegacyHostTargets() {
227
277
  function LegacyOverlay(props) {
228
278
  const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t, } = props;
229
279
  const { contextDialog, turnStatus } = useLegacyHostTargets();
280
+ const turnStatusPosition = useTurnStatusPosition(turnStatus);
230
281
  const contextWindow = contextWindowFromProjection(useProjection);
231
282
  const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
232
283
  if (!isCodexPresetId(agentPreset))
233
284
  return null;
234
- return (_jsxs(_Fragment, { children: [contextDialog !== null && createPortal(_jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }), contextDialog, 'codex-context-size'), turnStatus !== null && createPortal(_jsx(ActivityLine, { sessionId: sessionId, useSession: useSession, useSessions: useSessions, useProjection: useProjection, t: t }), turnStatus, 'codex-activity')] }));
285
+ return (_jsxs(_Fragment, { children: [contextDialog !== null && createPortal(_jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }), contextDialog, 'codex-context-size'), turnStatusPosition !== null && typeof document !== 'undefined' && document.body !== null && createPortal(_jsx(ActivityLine, { sessionId: sessionId, useSession: useSession, useSessions: useSessions, useProjection: useProjection, t: t, position: turnStatusPosition }), document.body, 'codex-activity')] }));
235
286
  }
236
287
  export const inject = ['slots', 'locale', 'settingsScope'];
237
288
  /** Mount all controls through the official composer seats shared by every DSH release. */
@@ -227,7 +227,7 @@ const CODEX_BASE_PROMPT = String.raw `## General
227
227
  `;
228
228
  const CODEX_COLLABORATION_PROMPT = String.raw `## Collaboration
229
229
 
230
- - Ask, align, and clarify first. Gather enough context from the user then achieve the user's goal through the clearest, most effective path.
230
+ - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
231
231
  - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
232
232
  - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
233
233
  - Solve problems by thinking from first principles and at a higher level.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "description": "A Codex harness with a streamlined system prompt for GPT models that do not fit DSH's native interface, while remaining compatible with the DSH plugin ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",