@shuind/dsh-codex-harness 0.1.32 → 0.1.33
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 +141 -141
- package/lib/client.js +79 -150
- package/lib/types/client/index.d.ts +4 -13
- package/lib/types/client/index.js +84 -113
- package/lib/types/index.d.ts +1 -1
- package/package.json +3 -1
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
|
-
-
|
|
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.
|
|
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.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
|
package/lib/client.js
CHANGED
|
@@ -9,6 +9,7 @@ window.__ModuleLoader__.load({
|
|
|
9
9
|
});
|
|
10
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
11
|
let react = require("react");
|
|
12
|
+
let react_dom = require("react-dom");
|
|
12
13
|
//#region lib/types/context.js
|
|
13
14
|
/** User-selectable Codex context controls use whole K-token units. */
|
|
14
15
|
const CODEX_CONTEXT_UNIT = 1e3;
|
|
@@ -72,10 +73,8 @@ window.__ModuleLoader__.load({
|
|
|
72
73
|
/** Browser controls for the Codex request settings mounted by the Host plugin. */
|
|
73
74
|
const NS = "codex";
|
|
74
75
|
const SETTINGS_NAMESPACE = "codex";
|
|
75
|
-
const ACTIVITY_SLOT = "conversation.chat.status";
|
|
76
|
-
const ACTIVITY_FALLBACK_SLOT = "conversation.composer.dock";
|
|
77
|
-
const CONTEXT_SETTINGS_SLOT = "conversation.input.context.settings";
|
|
78
76
|
const FAST_FALLBACK_SLOT = "conversation.input.right";
|
|
77
|
+
const LEGACY_OVERLAY_SLOT = "conversation.input.overlay";
|
|
79
78
|
const DEFAULT_CONTEXT_WINDOW = 262144;
|
|
80
79
|
const en = {
|
|
81
80
|
fast: "Fast mode",
|
|
@@ -151,7 +150,7 @@ window.__ModuleLoader__.load({
|
|
|
151
150
|
const pressure = useProjection("contextPressure");
|
|
152
151
|
return pressure?.contextWindow !== void 0 && pressure.contextWindow > 0 ? pressure.contextWindow : DEFAULT_CONTEXT_WINDOW;
|
|
153
152
|
}
|
|
154
|
-
/** Settings form
|
|
153
|
+
/** Settings form appended to the old host's context meter panel. */
|
|
155
154
|
function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings, setSetting, unsetSetting, t }) {
|
|
156
155
|
const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
|
|
157
156
|
const snapshot = useSettings((state) => state);
|
|
@@ -167,9 +166,11 @@ window.__ModuleLoader__.load({
|
|
|
167
166
|
};
|
|
168
167
|
return (0, react_jsx_runtime.jsxs)("div", {
|
|
169
168
|
style: {
|
|
170
|
-
marginTop: 0,
|
|
171
169
|
display: "grid",
|
|
172
|
-
gap: 8
|
|
170
|
+
gap: 8,
|
|
171
|
+
marginTop: 10,
|
|
172
|
+
paddingTop: 10,
|
|
173
|
+
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
173
174
|
},
|
|
174
175
|
children: [
|
|
175
176
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -280,114 +281,6 @@ window.__ModuleLoader__.load({
|
|
|
280
281
|
]
|
|
281
282
|
});
|
|
282
283
|
}
|
|
283
|
-
/** Compact context-capacity trigger shown beside the bottom activity line. */
|
|
284
|
-
function ContextSizeDock({ sessionId, useSessions, useProjection, useSettings, setSetting, unsetSetting, t }) {
|
|
285
|
-
const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
|
|
286
|
-
const contextWindow = contextWindowFromProjection(useProjection);
|
|
287
|
-
const snapshot = useSettings((state) => state);
|
|
288
|
-
const configured = snapshot.value?.contextWindow;
|
|
289
|
-
const valueK = Math.min(CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
|
|
290
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
291
|
-
const rootRef = (0, react.useRef)(null);
|
|
292
|
-
(0, react.useEffect)(() => {
|
|
293
|
-
if (!open) return void 0;
|
|
294
|
-
const onPointerDown = (event) => {
|
|
295
|
-
if (event.target instanceof Node && rootRef.current?.contains(event.target) === true) return;
|
|
296
|
-
setOpen(false);
|
|
297
|
-
};
|
|
298
|
-
const onKeyDown = (event) => {
|
|
299
|
-
if (event.key === "Escape") setOpen(false);
|
|
300
|
-
};
|
|
301
|
-
document.addEventListener("pointerdown", onPointerDown);
|
|
302
|
-
document.addEventListener("keydown", onKeyDown);
|
|
303
|
-
return () => {
|
|
304
|
-
document.removeEventListener("pointerdown", onPointerDown);
|
|
305
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
306
|
-
};
|
|
307
|
-
}, [open]);
|
|
308
|
-
if (!isCodexPresetId(agentPreset)) return null;
|
|
309
|
-
return (0, react_jsx_runtime.jsxs)("span", {
|
|
310
|
-
ref: rootRef,
|
|
311
|
-
style: {
|
|
312
|
-
position: "relative",
|
|
313
|
-
display: "inline-flex",
|
|
314
|
-
alignItems: "center"
|
|
315
|
-
},
|
|
316
|
-
children: [(0, react_jsx_runtime.jsxs)("button", {
|
|
317
|
-
type: "button",
|
|
318
|
-
"aria-label": `${t("contextSize")}: ${valueK}K`,
|
|
319
|
-
"aria-haspopup": "dialog",
|
|
320
|
-
"aria-expanded": open,
|
|
321
|
-
disabled: snapshot.writable === false,
|
|
322
|
-
title: t("contextSize"),
|
|
323
|
-
onMouseDown: (event) => {
|
|
324
|
-
event.preventDefault();
|
|
325
|
-
},
|
|
326
|
-
onClick: () => {
|
|
327
|
-
setOpen((value) => !value);
|
|
328
|
-
},
|
|
329
|
-
style: {
|
|
330
|
-
boxSizing: "border-box",
|
|
331
|
-
display: "inline-flex",
|
|
332
|
-
alignItems: "center",
|
|
333
|
-
gap: 3,
|
|
334
|
-
height: 28,
|
|
335
|
-
border: 0,
|
|
336
|
-
borderRadius: 7,
|
|
337
|
-
padding: "0 6px",
|
|
338
|
-
color: configured === void 0 ? "var(--dsw-alias-label-secondary)" : "var(--dsw-static-blue-500)",
|
|
339
|
-
background: open ? "var(--dsw-alias-interactive-bg-hover)" : "transparent",
|
|
340
|
-
cursor: snapshot.writable === false ? "default" : "pointer",
|
|
341
|
-
font: "inherit",
|
|
342
|
-
fontSize: 12,
|
|
343
|
-
lineHeight: "20px",
|
|
344
|
-
fontWeight: configured === void 0 ? 400 : 600,
|
|
345
|
-
whiteSpace: "nowrap"
|
|
346
|
-
},
|
|
347
|
-
children: [(0, react_jsx_runtime.jsxs)("span", { children: [valueK, "K"] }), (0, react_jsx_runtime.jsx)("svg", {
|
|
348
|
-
viewBox: "0 0 12 12",
|
|
349
|
-
width: "12",
|
|
350
|
-
height: "12",
|
|
351
|
-
"aria-hidden": true,
|
|
352
|
-
children: (0, react_jsx_runtime.jsx)("path", {
|
|
353
|
-
d: "M3 4.5 6 7.5 9 4.5",
|
|
354
|
-
fill: "none",
|
|
355
|
-
stroke: "currentColor",
|
|
356
|
-
strokeWidth: "1.25",
|
|
357
|
-
strokeLinecap: "round",
|
|
358
|
-
strokeLinejoin: "round"
|
|
359
|
-
})
|
|
360
|
-
})]
|
|
361
|
-
}), open && (0, react_jsx_runtime.jsx)("div", {
|
|
362
|
-
role: "dialog",
|
|
363
|
-
"aria-label": t("contextSize"),
|
|
364
|
-
style: {
|
|
365
|
-
position: "absolute",
|
|
366
|
-
right: 0,
|
|
367
|
-
bottom: "calc(100% + 8px)",
|
|
368
|
-
zIndex: 20,
|
|
369
|
-
boxSizing: "border-box",
|
|
370
|
-
width: 300,
|
|
371
|
-
maxWidth: "calc(100vw - 24px)",
|
|
372
|
-
padding: "10px 12px 12px",
|
|
373
|
-
border: "1px solid var(--dsw-alias-border-l2)",
|
|
374
|
-
borderRadius: 10,
|
|
375
|
-
color: "var(--dsw-alias-label-primary)",
|
|
376
|
-
background: "var(--dsw-alias-bg-base)",
|
|
377
|
-
boxShadow: "var(--dsw-shadow-lv2)"
|
|
378
|
-
},
|
|
379
|
-
children: (0, react_jsx_runtime.jsx)(ContextSizeControl, {
|
|
380
|
-
contextWindow,
|
|
381
|
-
sessionId,
|
|
382
|
-
useSessions,
|
|
383
|
-
useSettings,
|
|
384
|
-
setSetting,
|
|
385
|
-
unsetSetting,
|
|
386
|
-
t
|
|
387
|
-
})
|
|
388
|
-
})]
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
284
|
function elapsedSeconds(startedAt, now) {
|
|
392
285
|
return Math.max(0, Math.floor((now - startedAt) / 1e3));
|
|
393
286
|
}
|
|
@@ -416,18 +309,19 @@ window.__ModuleLoader__.load({
|
|
|
416
309
|
if (!isCodexPresetId(agentPreset) || activity === void 0 || activity === null) return null;
|
|
417
310
|
const label = activity.activity === "compaction" ? t("activityCompacting") : activity.activity === "model-reply" ? t("activityModelReply") : t("activityRequestingModel");
|
|
418
311
|
return (0, react_jsx_runtime.jsxs)("span", {
|
|
419
|
-
|
|
420
|
-
role: "status",
|
|
312
|
+
"data-codex-activity": true,
|
|
421
313
|
"aria-live": "polite",
|
|
422
314
|
style: {
|
|
423
315
|
display: "inline-flex",
|
|
424
316
|
alignItems: "center",
|
|
425
317
|
gap: 7,
|
|
426
318
|
minHeight: 26,
|
|
319
|
+
marginLeft: 10,
|
|
427
320
|
color: "var(--dsw-alias-label-secondary)",
|
|
428
321
|
fontSize: 12,
|
|
429
322
|
lineHeight: "20px",
|
|
430
|
-
whiteSpace: "nowrap"
|
|
323
|
+
whiteSpace: "nowrap",
|
|
324
|
+
WebkitTextFillColor: "currentColor"
|
|
431
325
|
},
|
|
432
326
|
children: [
|
|
433
327
|
(0, react_jsx_runtime.jsx)("span", {
|
|
@@ -445,7 +339,8 @@ window.__ModuleLoader__.load({
|
|
|
445
339
|
(0, react_jsx_runtime.jsxs)("span", {
|
|
446
340
|
style: { color: "var(--dsw-alias-label-tertiary)" },
|
|
447
341
|
children: [
|
|
448
|
-
"·
|
|
342
|
+
"·",
|
|
343
|
+
" ",
|
|
449
344
|
elapsedSeconds(activity.startedAt, now),
|
|
450
345
|
"s"
|
|
451
346
|
]
|
|
@@ -453,18 +348,69 @@ window.__ModuleLoader__.load({
|
|
|
453
348
|
]
|
|
454
349
|
});
|
|
455
350
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
351
|
+
function findContextMeterDialog() {
|
|
352
|
+
const buttons = document.querySelectorAll("button[aria-haspopup=\"dialog\"][aria-expanded=\"true\"]");
|
|
353
|
+
for (const button of buttons) {
|
|
354
|
+
if (button.querySelectorAll("circle").length < 2) continue;
|
|
355
|
+
let ancestor = button;
|
|
356
|
+
for (let depth = 0; ancestor !== null && depth < 5; depth += 1, ancestor = ancestor.parentElement) {
|
|
357
|
+
const dialog = ancestor.querySelector("[role=\"dialog\"]");
|
|
358
|
+
if (dialog !== null) return dialog;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
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;
|
|
366
|
+
}
|
|
367
|
+
function useLegacyHostTargets() {
|
|
368
|
+
const [targets, setTargets] = (0, react.useState)({
|
|
369
|
+
contextDialog: null,
|
|
370
|
+
turnStatus: null
|
|
467
371
|
});
|
|
372
|
+
(0, react.useEffect)(() => {
|
|
373
|
+
if (typeof document === "undefined" || document.body === null) return void 0;
|
|
374
|
+
const refresh = () => {
|
|
375
|
+
const next = {
|
|
376
|
+
contextDialog: findContextMeterDialog(),
|
|
377
|
+
turnStatus: findTurnStatus()
|
|
378
|
+
};
|
|
379
|
+
setTargets((current) => current.contextDialog === next.contextDialog && current.turnStatus === next.turnStatus ? current : next);
|
|
380
|
+
};
|
|
381
|
+
refresh();
|
|
382
|
+
const observer = new MutationObserver(refresh);
|
|
383
|
+
observer.observe(document.body, {
|
|
384
|
+
subtree: true,
|
|
385
|
+
childList: true,
|
|
386
|
+
attributes: true,
|
|
387
|
+
attributeFilter: ["aria-expanded"]
|
|
388
|
+
});
|
|
389
|
+
return () => observer.disconnect();
|
|
390
|
+
}, []);
|
|
391
|
+
return targets;
|
|
392
|
+
}
|
|
393
|
+
/** Bridges plugin UI into DOM sites rendered by the legacy conversation host. */
|
|
394
|
+
function LegacyOverlay(props) {
|
|
395
|
+
const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t } = props;
|
|
396
|
+
const { contextDialog, turnStatus } = useLegacyHostTargets();
|
|
397
|
+
const contextWindow = contextWindowFromProjection(useProjection);
|
|
398
|
+
if (!isCodexPresetId(useSessions((state) => state.byId[sessionId]?.agentPreset))) return null;
|
|
399
|
+
return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [contextDialog !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ContextSizeControl, {
|
|
400
|
+
contextWindow,
|
|
401
|
+
sessionId,
|
|
402
|
+
useSessions,
|
|
403
|
+
useSettings,
|
|
404
|
+
setSetting,
|
|
405
|
+
unsetSetting,
|
|
406
|
+
t
|
|
407
|
+
}), contextDialog, "codex-context-size"), turnStatus !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ActivityLine, {
|
|
408
|
+
sessionId,
|
|
409
|
+
useSession,
|
|
410
|
+
useSessions,
|
|
411
|
+
useProjection,
|
|
412
|
+
t
|
|
413
|
+
}), turnStatus, "codex-activity")] });
|
|
468
414
|
}
|
|
469
415
|
const inject = [
|
|
470
416
|
"slots",
|
|
@@ -490,30 +436,13 @@ window.__ModuleLoader__.load({
|
|
|
490
436
|
locale: NS,
|
|
491
437
|
inject: injected
|
|
492
438
|
}, FastModeFallback));
|
|
493
|
-
ctx.slots.inject(
|
|
494
|
-
name:
|
|
495
|
-
id: "codex-
|
|
439
|
+
ctx.slots.inject(LEGACY_OVERLAY_SLOT, () => ctx.slots.register({
|
|
440
|
+
name: LEGACY_OVERLAY_SLOT,
|
|
441
|
+
id: "codex-legacy-overlay",
|
|
496
442
|
order: 0,
|
|
497
443
|
locale: NS,
|
|
498
444
|
inject: injected
|
|
499
|
-
},
|
|
500
|
-
ctx.slots.inject(ACTIVITY_SLOT, () => ctx.slots.register({
|
|
501
|
-
name: ACTIVITY_SLOT,
|
|
502
|
-
id: "codex-activity",
|
|
503
|
-
order: 0,
|
|
504
|
-
locale: NS,
|
|
505
|
-
inject: injected
|
|
506
|
-
}, ActivityLine));
|
|
507
|
-
ctx.slots.inject(ACTIVITY_FALLBACK_SLOT, () => {
|
|
508
|
-
if (ctx.slots.spec(ACTIVITY_SLOT) !== void 0) return () => {};
|
|
509
|
-
return ctx.slots.register({
|
|
510
|
-
name: ACTIVITY_FALLBACK_SLOT,
|
|
511
|
-
id: "codex-activity",
|
|
512
|
-
order: 5,
|
|
513
|
-
locale: NS,
|
|
514
|
-
inject: injected
|
|
515
|
-
}, ActivityDock);
|
|
516
|
-
});
|
|
445
|
+
}, LegacyOverlay));
|
|
517
446
|
}
|
|
518
447
|
var client_default = {
|
|
519
448
|
inject,
|
|
@@ -2,7 +2,7 @@
|
|
|
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
|
-
declare const
|
|
5
|
+
declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
|
|
6
6
|
interface CodexSettings {
|
|
7
7
|
fast: boolean;
|
|
8
8
|
contextWindow?: number;
|
|
@@ -27,18 +27,11 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
27
27
|
codex: CodexKey;
|
|
28
28
|
}
|
|
29
29
|
interface SlotMap {
|
|
30
|
-
'conversation.
|
|
30
|
+
'conversation.input.overlay': {
|
|
31
31
|
kind: 'list';
|
|
32
32
|
scope: 'session';
|
|
33
33
|
owner: Record<never, never>;
|
|
34
34
|
};
|
|
35
|
-
'conversation.input.context.settings': {
|
|
36
|
-
kind: 'list';
|
|
37
|
-
scope: 'session';
|
|
38
|
-
owner: {
|
|
39
|
-
contextWindow: number;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
37
|
interface InputSettingsControlInjected {
|
|
@@ -48,10 +41,8 @@ interface InputSettingsControlInjected {
|
|
|
48
41
|
setSetting: (field: string, value: unknown) => Promise<void>;
|
|
49
42
|
unsetSetting: (field: string) => Promise<void>;
|
|
50
43
|
}
|
|
51
|
-
type
|
|
52
|
-
type
|
|
53
|
-
type ActivityStatusProps = PropsRuntime<typeof ACTIVITY_SLOT> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
|
|
54
|
-
type ActivityProps = ActivityStatusProps | ActivityDockProps;
|
|
44
|
+
type LegacyOverlayProps = PropsRuntime<typeof LEGACY_OVERLAY_SLOT> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
|
|
45
|
+
type ActivityProps = Pick<LegacyOverlayProps, 'sessionId' | 'useSession' | 'useSessions' | 'useProjection' | 't'>;
|
|
55
46
|
export declare function ActivityLine({ sessionId, useSession, useSessions, useProjection, t }: ActivityProps): import("react").JSX.Element | null;
|
|
56
47
|
export declare const inject: string[];
|
|
57
48
|
/** Mount all controls through the official composer seats shared by every DSH release. */
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
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,
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
4
5
|
import { CODEX_CONTEXT_MAX, CODEX_CONTEXT_UNIT, isCodexPresetId } from "../context.js";
|
|
5
6
|
import { modelActivity, sameModelActivity } from "./activity.js";
|
|
6
7
|
const NS = 'codex';
|
|
7
8
|
const SETTINGS_NAMESPACE = 'codex';
|
|
8
|
-
const ACTIVITY_SLOT = 'conversation.chat.status';
|
|
9
|
-
const ACTIVITY_FALLBACK_SLOT = 'conversation.composer.dock';
|
|
10
|
-
const CONTEXT_SETTINGS_SLOT = 'conversation.input.context.settings';
|
|
11
9
|
const FAST_FALLBACK_SLOT = 'conversation.input.right';
|
|
10
|
+
const LEGACY_OVERLAY_SLOT = 'conversation.input.overlay';
|
|
12
11
|
const DEFAULT_CONTEXT_WINDOW = 262_144;
|
|
13
12
|
const en = {
|
|
14
13
|
fast: 'Fast mode',
|
|
@@ -27,14 +26,14 @@ const zh = {
|
|
|
27
26
|
fast: 'Fast',
|
|
28
27
|
fastOn: 'Fast mode on (priority tier)',
|
|
29
28
|
fastOff: 'Fast mode off',
|
|
30
|
-
fastStateOn: '
|
|
31
|
-
fastStateOff: '
|
|
32
|
-
contextSize: '
|
|
33
|
-
contextSizeDescription: '
|
|
34
|
-
contextRestore: '
|
|
35
|
-
activityCompacting: '
|
|
36
|
-
activityRequestingModel: '
|
|
37
|
-
activityModelReply: '
|
|
29
|
+
fastStateOn: '\u5f00',
|
|
30
|
+
fastStateOff: '\u5173',
|
|
31
|
+
contextSize: '\u4e0a\u4e0b\u6587\u5927\u5c0f',
|
|
32
|
+
contextSizeDescription: '\u8bbe\u7f6e\u4e0b\u6b21\u8bf7\u6c42\u7684\u4e0a\u4e0b\u6587\u5bb9\u91cf\uff0c\u5355\u4f4d\u4e3a K tokens\u3002',
|
|
33
|
+
contextRestore: '\u6062\u590d\u6a21\u578b\u9ed8\u8ba4\u503c',
|
|
34
|
+
activityCompacting: '\u6b63\u5728\u538b\u7f29\u4e0a\u4e0b\u6587...',
|
|
35
|
+
activityRequestingModel: '\u8bf7\u6c42\u4e2d...',
|
|
36
|
+
activityModelReply: '\u56de\u590d\u4e2d...',
|
|
38
37
|
};
|
|
39
38
|
/** The legacy composer seat is a compact inline row, not a menu panel. */
|
|
40
39
|
function FastModeFallback(props) {
|
|
@@ -69,7 +68,7 @@ function contextWindowFromProjection(useProjection) {
|
|
|
69
68
|
? pressure.contextWindow
|
|
70
69
|
: DEFAULT_CONTEXT_WINDOW;
|
|
71
70
|
}
|
|
72
|
-
/** Settings form
|
|
71
|
+
/** Settings form appended to the old host's context meter panel. */
|
|
73
72
|
function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings, setSetting, unsetSetting, t, }) {
|
|
74
73
|
const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
|
|
75
74
|
const snapshot = useSettings(state => state);
|
|
@@ -88,7 +87,13 @@ function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings
|
|
|
88
87
|
else
|
|
89
88
|
void setSetting('contextWindow', normalized);
|
|
90
89
|
};
|
|
91
|
-
return (_jsxs("div", { style: {
|
|
90
|
+
return (_jsxs("div", { style: {
|
|
91
|
+
display: 'grid',
|
|
92
|
+
gap: 8,
|
|
93
|
+
marginTop: 10,
|
|
94
|
+
paddingTop: 10,
|
|
95
|
+
borderTop: '1px solid var(--dsw-alias-border-l2)',
|
|
96
|
+
}, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [_jsx("strong", { style: { color: 'var(--dsw-alias-label-primary)', fontSize: 13 }, children: t('contextSize') }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 12, fontVariantNumeric: 'tabular-nums' }, children: [valueK, "K"] })] }), _jsx("input", { type: "range", min: 1, max: maxK, step: 1, value: valueK, disabled: snapshot.writable === false, "aria-label": t('contextSize'), onChange: event => { setValueK(Number(event.target.value)); }, style: {
|
|
92
97
|
display: 'block',
|
|
93
98
|
width: '100%',
|
|
94
99
|
accentColor: 'var(--dsw-static-blue-500)',
|
|
@@ -113,71 +118,6 @@ function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings
|
|
|
113
118
|
fontSize: 11,
|
|
114
119
|
}, children: t('contextRestore') }))] }));
|
|
115
120
|
}
|
|
116
|
-
/** Compact context-capacity trigger shown beside the bottom activity line. */
|
|
117
|
-
function ContextSizeDock({ sessionId, useSessions, useProjection, useSettings, setSetting, unsetSetting, t }) {
|
|
118
|
-
const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
|
|
119
|
-
const contextWindow = contextWindowFromProjection(useProjection);
|
|
120
|
-
const snapshot = useSettings(state => state);
|
|
121
|
-
const configured = snapshot.value?.contextWindow;
|
|
122
|
-
const valueK = Math.min(CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
|
|
123
|
-
const [open, setOpen] = useState(false);
|
|
124
|
-
const rootRef = useRef(null);
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
if (!open)
|
|
127
|
-
return undefined;
|
|
128
|
-
const onPointerDown = (event) => {
|
|
129
|
-
if (event.target instanceof Node && rootRef.current?.contains(event.target) === true)
|
|
130
|
-
return;
|
|
131
|
-
setOpen(false);
|
|
132
|
-
};
|
|
133
|
-
const onKeyDown = (event) => {
|
|
134
|
-
if (event.key === 'Escape')
|
|
135
|
-
setOpen(false);
|
|
136
|
-
};
|
|
137
|
-
document.addEventListener('pointerdown', onPointerDown);
|
|
138
|
-
document.addEventListener('keydown', onKeyDown);
|
|
139
|
-
return () => {
|
|
140
|
-
document.removeEventListener('pointerdown', onPointerDown);
|
|
141
|
-
document.removeEventListener('keydown', onKeyDown);
|
|
142
|
-
};
|
|
143
|
-
}, [open]);
|
|
144
|
-
if (!isCodexPresetId(agentPreset))
|
|
145
|
-
return null;
|
|
146
|
-
return (_jsxs("span", { ref: rootRef, style: { position: 'relative', display: 'inline-flex', alignItems: 'center' }, children: [_jsxs("button", { type: "button", "aria-label": `${t('contextSize')}: ${valueK}K`, "aria-haspopup": "dialog", "aria-expanded": open, disabled: snapshot.writable === false, title: t('contextSize'), onMouseDown: event => { event.preventDefault(); }, onClick: () => { setOpen(value => !value); }, style: {
|
|
147
|
-
boxSizing: 'border-box',
|
|
148
|
-
display: 'inline-flex',
|
|
149
|
-
alignItems: 'center',
|
|
150
|
-
gap: 3,
|
|
151
|
-
height: 28,
|
|
152
|
-
border: 0,
|
|
153
|
-
borderRadius: 7,
|
|
154
|
-
padding: '0 6px',
|
|
155
|
-
color: configured === undefined
|
|
156
|
-
? 'var(--dsw-alias-label-secondary)'
|
|
157
|
-
: 'var(--dsw-static-blue-500)',
|
|
158
|
-
background: open ? 'var(--dsw-alias-interactive-bg-hover)' : 'transparent',
|
|
159
|
-
cursor: snapshot.writable === false ? 'default' : 'pointer',
|
|
160
|
-
font: 'inherit',
|
|
161
|
-
fontSize: 12,
|
|
162
|
-
lineHeight: '20px',
|
|
163
|
-
fontWeight: configured === undefined ? 400 : 600,
|
|
164
|
-
whiteSpace: 'nowrap',
|
|
165
|
-
}, children: [_jsxs("span", { children: [valueK, "K"] }), _jsx("svg", { viewBox: "0 0 12 12", width: "12", height: "12", "aria-hidden": true, children: _jsx("path", { d: "M3 4.5 6 7.5 9 4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), open && (_jsx("div", { role: "dialog", "aria-label": t('contextSize'), style: {
|
|
166
|
-
position: 'absolute',
|
|
167
|
-
right: 0,
|
|
168
|
-
bottom: 'calc(100% + 8px)',
|
|
169
|
-
zIndex: 20,
|
|
170
|
-
boxSizing: 'border-box',
|
|
171
|
-
width: 300,
|
|
172
|
-
maxWidth: 'calc(100vw - 24px)',
|
|
173
|
-
padding: '10px 12px 12px',
|
|
174
|
-
border: '1px solid var(--dsw-alias-border-l2)',
|
|
175
|
-
borderRadius: 10,
|
|
176
|
-
color: 'var(--dsw-alias-label-primary)',
|
|
177
|
-
background: 'var(--dsw-alias-bg-base)',
|
|
178
|
-
boxShadow: 'var(--dsw-shadow-lv2)',
|
|
179
|
-
}, children: _jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }) }))] }));
|
|
180
|
-
}
|
|
181
121
|
function elapsedSeconds(startedAt, now) {
|
|
182
122
|
return Math.max(0, Math.floor((now - startedAt) / 1_000));
|
|
183
123
|
}
|
|
@@ -216,15 +156,17 @@ export function ActivityLine({ sessionId, useSession, useSessions, useProjection
|
|
|
216
156
|
: activity.activity === 'model-reply'
|
|
217
157
|
? t('activityModelReply')
|
|
218
158
|
: t('activityRequestingModel');
|
|
219
|
-
return (_jsxs("span", {
|
|
159
|
+
return (_jsxs("span", { "data-codex-activity": true, "aria-live": "polite", style: {
|
|
220
160
|
display: 'inline-flex',
|
|
221
161
|
alignItems: 'center',
|
|
222
162
|
gap: 7,
|
|
223
163
|
minHeight: 26,
|
|
164
|
+
marginLeft: 10,
|
|
224
165
|
color: 'var(--dsw-alias-label-secondary)',
|
|
225
166
|
fontSize: 12,
|
|
226
167
|
lineHeight: '20px',
|
|
227
168
|
whiteSpace: 'nowrap',
|
|
169
|
+
WebkitTextFillColor: 'currentColor',
|
|
228
170
|
}, children: [_jsx("span", { "aria-hidden": "true", style: {
|
|
229
171
|
width: 5,
|
|
230
172
|
height: 5,
|
|
@@ -232,17 +174,64 @@ export function ActivityLine({ sessionId, useSession, useSessions, useProjection
|
|
|
232
174
|
borderRadius: '50%',
|
|
233
175
|
background: 'var(--dsw-static-blue-500)',
|
|
234
176
|
opacity: 0.55,
|
|
235
|
-
} }), _jsx("span", { children: label }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-tertiary)' }, children: [
|
|
177
|
+
} }), _jsx("span", { children: label }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-tertiary)' }, children: ['\u00b7', " ", elapsedSeconds(activity.startedAt, now), "s"] })] }));
|
|
236
178
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
179
|
+
function findContextMeterDialog() {
|
|
180
|
+
const buttons = document.querySelectorAll('button[aria-haspopup="dialog"][aria-expanded="true"]');
|
|
181
|
+
for (const button of buttons) {
|
|
182
|
+
if (button.querySelectorAll('circle').length < 2)
|
|
183
|
+
continue;
|
|
184
|
+
let ancestor = button;
|
|
185
|
+
for (let depth = 0; ancestor !== null && depth < 5; depth += 1, ancestor = ancestor.parentElement) {
|
|
186
|
+
const dialog = ancestor.querySelector('[role="dialog"]');
|
|
187
|
+
if (dialog !== null)
|
|
188
|
+
return dialog;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
function findTurnStatus() {
|
|
194
|
+
for (const status of document.querySelectorAll('[role="status"]')) {
|
|
195
|
+
if (status.textContent?.includes('Deep diving...') === true
|
|
196
|
+
&& status.closest('[data-chat-flow]') !== null)
|
|
197
|
+
return status;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
function useLegacyHostTargets() {
|
|
202
|
+
const [targets, setTargets] = useState({ contextDialog: null, turnStatus: null });
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (typeof document === 'undefined' || document.body === null)
|
|
205
|
+
return undefined;
|
|
206
|
+
const refresh = () => {
|
|
207
|
+
const next = {
|
|
208
|
+
contextDialog: findContextMeterDialog(),
|
|
209
|
+
turnStatus: findTurnStatus(),
|
|
210
|
+
};
|
|
211
|
+
setTargets(current => current.contextDialog === next.contextDialog
|
|
212
|
+
&& current.turnStatus === next.turnStatus ? current : next);
|
|
213
|
+
};
|
|
214
|
+
refresh();
|
|
215
|
+
const observer = new MutationObserver(refresh);
|
|
216
|
+
observer.observe(document.body, {
|
|
217
|
+
subtree: true,
|
|
218
|
+
childList: true,
|
|
219
|
+
attributes: true,
|
|
220
|
+
attributeFilter: ['aria-expanded'],
|
|
221
|
+
});
|
|
222
|
+
return () => observer.disconnect();
|
|
223
|
+
}, []);
|
|
224
|
+
return targets;
|
|
225
|
+
}
|
|
226
|
+
/** Bridges plugin UI into DOM sites rendered by the legacy conversation host. */
|
|
227
|
+
function LegacyOverlay(props) {
|
|
228
|
+
const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t, } = props;
|
|
229
|
+
const { contextDialog, turnStatus } = useLegacyHostTargets();
|
|
230
|
+
const contextWindow = contextWindowFromProjection(useProjection);
|
|
231
|
+
const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
|
|
232
|
+
if (!isCodexPresetId(agentPreset))
|
|
233
|
+
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')] }));
|
|
246
235
|
}
|
|
247
236
|
export const inject = ['slots', 'locale', 'settingsScope'];
|
|
248
237
|
/** Mount all controls through the official composer seats shared by every DSH release. */
|
|
@@ -261,31 +250,13 @@ export function apply(ctx) {
|
|
|
261
250
|
locale: NS,
|
|
262
251
|
inject: injected,
|
|
263
252
|
}, FastModeFallback));
|
|
264
|
-
ctx.slots.inject(
|
|
265
|
-
name:
|
|
266
|
-
id: 'codex-
|
|
253
|
+
ctx.slots.inject(LEGACY_OVERLAY_SLOT, () => ctx.slots.register({
|
|
254
|
+
name: LEGACY_OVERLAY_SLOT,
|
|
255
|
+
id: 'codex-legacy-overlay',
|
|
267
256
|
order: 0,
|
|
268
257
|
locale: NS,
|
|
269
258
|
inject: injected,
|
|
270
|
-
},
|
|
271
|
-
ctx.slots.inject(ACTIVITY_SLOT, () => ctx.slots.register({
|
|
272
|
-
name: ACTIVITY_SLOT,
|
|
273
|
-
id: 'codex-activity',
|
|
274
|
-
order: 0,
|
|
275
|
-
locale: NS,
|
|
276
|
-
inject: injected,
|
|
277
|
-
}, ActivityLine));
|
|
278
|
-
ctx.slots.inject(ACTIVITY_FALLBACK_SLOT, () => {
|
|
279
|
-
if (ctx.slots.spec(ACTIVITY_SLOT) !== undefined)
|
|
280
|
-
return () => { };
|
|
281
|
-
return ctx.slots.register({
|
|
282
|
-
name: ACTIVITY_FALLBACK_SLOT,
|
|
283
|
-
id: 'codex-activity',
|
|
284
|
-
order: 5,
|
|
285
|
-
locale: NS,
|
|
286
|
-
inject: injected,
|
|
287
|
-
}, ActivityDock);
|
|
288
|
-
});
|
|
259
|
+
}, LegacyOverlay));
|
|
289
260
|
}
|
|
290
261
|
export default { inject, apply };
|
|
291
262
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface Config {
|
|
|
26
26
|
/** Runtime configuration schema for the Codex tool bridge. */
|
|
27
27
|
export declare const Config: z<Config>;
|
|
28
28
|
/** Live Codex-only request controls shared by the Web controls and agent layer. */
|
|
29
|
-
export declare const CODEX_SETTINGS_NAMESPACE:
|
|
29
|
+
export declare const CODEX_SETTINGS_NAMESPACE: Branded<"SettingsNamespace">;
|
|
30
30
|
export interface CodexSettings {
|
|
31
31
|
/** Use the Responses priority service tier for GPT requests. */
|
|
32
32
|
fast: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuind/dsh-codex-harness",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
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",
|
|
@@ -225,7 +225,9 @@
|
|
|
225
225
|
"@deepseek-ai/dsh-tools": "0.1.0-rc.6",
|
|
226
226
|
"@types/node": "^22.20.0",
|
|
227
227
|
"@types/react": "~18.3.1",
|
|
228
|
+
"@types/react-dom": "~18.3.0",
|
|
228
229
|
"react": "^18.3.1",
|
|
230
|
+
"react-dom": "^18.3.1",
|
|
229
231
|
"tsdown": "^0.22.2",
|
|
230
232
|
"typescript": "^6.0.3",
|
|
231
233
|
"unrun": "^0.3.1",
|