@liangjie559567/ultrapower 5.6.8 → 5.6.10
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.mcp.json +4 -2
- package/README.md +55 -149
- package/bridge/codex-server.cjs +180 -3
- package/bridge/gemini-server.cjs +179 -3
- package/bridge/mcp-server.cjs +153 -12
- package/bridge/team-bridge.cjs +1 -1
- package/dist/features/prompt-optimizer/index.d.ts +38 -0
- package/dist/features/prompt-optimizer/index.d.ts.map +1 -0
- package/dist/features/prompt-optimizer/index.js +89 -0
- package/dist/features/prompt-optimizer/index.js.map +1 -0
- package/dist/mcp/adapters/memory-adapter.d.ts +3 -3
- package/dist/mcp/adapters/state-adapter.d.ts +2 -2
- package/dist/mcp/adapters/trace-adapter.d.ts +1 -1
- package/dist/mcp/codex-core.d.ts.map +1 -1
- package/dist/mcp/codex-core.js +1 -1
- package/dist/mcp/codex-core.js.map +1 -1
- package/dist/mcp/gemini-core.d.ts.map +1 -1
- package/dist/mcp/gemini-core.js +1 -1
- package/dist/mcp/gemini-core.js.map +1 -1
- package/dist/mcp/prompt-injection.d.ts.map +1 -1
- package/dist/mcp/prompt-injection.js +4 -1
- package/dist/mcp/prompt-injection.js.map +1 -1
- package/dist/tools/ast-tools.js +12 -12
- package/dist/tools/ast-tools.js.map +1 -1
- package/docs/CLAUDE.md +1 -1
- package/docs/INSTALL.md +2 -2
- package/docs/MCP-USAGE-GUIDE.md +48 -0
- package/docs/PROMPT-OPTIMIZATION.md +182 -0
- package/docs/REFERENCE.md +1 -1
- package/docs/RELEASE_GUIDE.md +23 -71
- package/docs/RELEASE_RECOVERY.md +8 -24
- package/docs/getting-started/quickstart.md +24 -84
- package/docs/reference/AGENTS.md +129 -0
- package/docs/reference/SKILLS.md +197 -0
- package/docs/standards/README.md +1 -1
- package/package.json +8 -7
- package/scripts/sync-marketplace.mjs +3 -0
- package/scripts/sync-version.mjs +6 -1
- package/scripts/test-mcp-optimization.mjs +71 -0
- package/scripts/validate-prompt-optimization.mjs +81 -0
- package/skills/omc-doctor/SKILL.md +1 -1
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
{
|
|
9
9
|
"name": "ultrapower",
|
|
10
10
|
"description": "Disciplined multi-agent orchestration: workflow enforcement + parallel execution",
|
|
11
|
-
"version": "5.6.
|
|
11
|
+
"version": "5.6.10",
|
|
12
12
|
"source": {
|
|
13
13
|
"source": "npm",
|
|
14
14
|
"package": "@liangjie559567/ultrapower",
|
|
15
|
-
"version": "5.6.
|
|
15
|
+
"version": "5.6.10"
|
|
16
16
|
},
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "liangjie559567"
|
package/.mcp.json
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"args": ["${CLAUDE_PLUGIN_ROOT}/bridge/codex-server.cjs"],
|
|
13
13
|
"env": {
|
|
14
14
|
"CLAUDE_PLUGIN_ROOT": "C:\\Users\\ljyih\\Desktop\\ultrapower",
|
|
15
|
-
"PATH": "C:\\Users\\ljyih\\AppData\\Roaming\\npm;${PATH}"
|
|
15
|
+
"PATH": "C:\\Users\\ljyih\\AppData\\Roaming\\npm;${PATH}",
|
|
16
|
+
"OMC_CODEX_TIMEOUT": "25000"
|
|
16
17
|
}
|
|
17
18
|
},
|
|
18
19
|
"g": {
|
|
@@ -20,7 +21,8 @@
|
|
|
20
21
|
"args": ["${CLAUDE_PLUGIN_ROOT}/bridge/gemini-server.cjs"],
|
|
21
22
|
"env": {
|
|
22
23
|
"CLAUDE_PLUGIN_ROOT": "C:\\Users\\ljyih\\Desktop\\ultrapower",
|
|
23
|
-
"PATH": "C:\\Users\\ljyih\\AppData\\Roaming\\npm;${PATH}"
|
|
24
|
+
"PATH": "C:\\Users\\ljyih\\AppData\\Roaming\\npm;${PATH}",
|
|
25
|
+
"OMC_GEMINI_TIMEOUT": "25000"
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
}
|
package/README.md
CHANGED
|
@@ -12,9 +12,25 @@ ultrapower 是 Claude Code 的智能多 Agent 编排层(OMC),在 superpowe
|
|
|
12
12
|
|
|
13
13
|
* **自动触发**:Skills 根据上下文自动激活,无需手动调用
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## 架构概览
|
|
16
|
+
|
|
17
|
+
```mermaid
|
|
18
|
+
graph TB
|
|
19
|
+
A[Claude Code CLI] --> B[ultrapower OMC]
|
|
20
|
+
B --> C[Skills Layer<br/>71 个工作流自动化]
|
|
21
|
+
B --> D[Agents Layer<br/>49 个专业 AI agents]
|
|
22
|
+
B --> E[Tools Layer<br/>LSP/AST/Python REPL]
|
|
23
|
+
B --> F[Hooks Layer<br/>43 个事件驱动钩子]
|
|
24
|
+
C --> G[执行模式<br/>autopilot/team/ralph/ultrawork]
|
|
25
|
+
D --> H[模型路由<br/>Haiku/Sonnet/Opus]
|
|
26
|
+
E --> I[代码智能<br/>类型检查/重构/分析]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**核心理念**:Superpowers 的严格工作流纪律 + OMC 的并行执行能力
|
|
30
|
+
|
|
31
|
+
## 快速开始(3 分钟上手)
|
|
16
32
|
|
|
17
|
-
**新用户?** 查看 [📖
|
|
33
|
+
**新用户?** 查看 [📖 3 分钟快速入门指南](docs/getting-started/QUICKSTART.md)
|
|
18
34
|
|
|
19
35
|
### 前置条件
|
|
20
36
|
|
|
@@ -26,28 +42,17 @@ ultrapower 是 Claude Code 的智能多 Agent 编排层(OMC),在 superpowe
|
|
|
26
42
|
|
|
27
43
|
### 安装步骤
|
|
28
44
|
|
|
29
|
-
**方式 1:通过 Claude Code 插件(推荐)**
|
|
30
|
-
|
|
31
45
|
在 Claude Code 会话中运行:
|
|
32
46
|
|
|
33
47
|
```bash
|
|
34
|
-
|
|
35
48
|
# 1. 添加 marketplace 并安装
|
|
36
|
-
|
|
37
|
-
/plugin marketplace add <<https://github.com/liangjie559567/ultrapower>>
|
|
49
|
+
/plugin marketplace add https://github.com/liangjie559567/ultrapower
|
|
38
50
|
/plugin install omc@ultrapower
|
|
39
51
|
|
|
40
52
|
# 2. 运行安装向导
|
|
41
|
-
|
|
42
53
|
/ultrapower:omc-setup
|
|
43
54
|
```
|
|
44
55
|
|
|
45
|
-
**方式 2:通过 npm 全局安装**
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm install -g @liangjie559567/ultrapower
|
|
49
|
-
```
|
|
50
|
-
|
|
51
56
|
### 验证安装
|
|
52
57
|
|
|
53
58
|
```bash
|
|
@@ -90,112 +95,29 @@ autopilot "创建一个 hello world 函数"
|
|
|
90
95
|
|
|
91
96
|
---
|
|
92
97
|
|
|
93
|
-
## Agents(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
| `architect` | opus | 系统设计、接口、长期权衡 |
|
|
103
|
-
| `debugger` | sonnet | 根因分析、回归隔离 |
|
|
104
|
-
| `executor` | sonnet | 代码实现、重构、功能开发 |
|
|
105
|
-
| `deep-executor` | opus | 复杂自主目标导向任务 |
|
|
106
|
-
| `verifier` | sonnet | 完成证据、声明验证 |
|
|
107
|
-
|
|
108
|
-
### 审查通道
|
|
109
|
-
|
|
110
|
-
| Agent | 模型 | 用途 |
|
|
111
|
-
| ------- | ------ | ------ |
|
|
112
|
-
| `style-reviewer` | haiku | 格式、命名、惯用法 |
|
|
113
|
-
| `quality-reviewer` | sonnet | 逻辑缺陷、可维护性 |
|
|
114
|
-
| `api-reviewer` | sonnet | API 契约、版本控制 |
|
|
115
|
-
| `security-reviewer` | sonnet | 漏洞、信任边界 |
|
|
116
|
-
| `performance-reviewer` | sonnet | 热点、复杂度优化 |
|
|
117
|
-
| `code-reviewer` | opus | 跨关注点综合审查 |
|
|
118
|
-
|
|
119
|
-
### 领域专家
|
|
120
|
-
|
|
121
|
-
| Agent | 模型 | 用途 |
|
|
122
|
-
| ------- | ------ | ------ |
|
|
123
|
-
| `dependency-expert` | sonnet | 外部 SDK/API/包评估 |
|
|
124
|
-
| `test-engineer` | sonnet | 测试策略、覆盖率 |
|
|
125
|
-
| `quality-strategist` | sonnet | 质量策略、发布就绪性 |
|
|
126
|
-
| `build-fixer` | sonnet | 构建/工具链/类型失败 |
|
|
127
|
-
| `designer` | sonnet | UX/UI 架构、交互设计 |
|
|
128
|
-
| `writer` | haiku | 文档、迁移说明 |
|
|
129
|
-
| `qa-tester` | sonnet | 交互式 CLI/服务验证 |
|
|
130
|
-
| `scientist` | sonnet | 数据/统计分析 |
|
|
131
|
-
| `document-specialist` | sonnet | 外部文档查找 |
|
|
132
|
-
| `git-master` | sonnet | 提交策略、历史整洁 |
|
|
133
|
-
| `database-expert` | sonnet | 数据库设计、查询优化和迁移 |
|
|
134
|
-
| `devops-engineer` | sonnet | CI/CD、容器化、基础设施即代码 |
|
|
135
|
-
| `i18n-specialist` | sonnet | 国际化、本地化和多语言支持 |
|
|
136
|
-
| `accessibility-auditor` | sonnet | Web 无障碍审查和 WCAG 合规 |
|
|
137
|
-
| `api-designer` | sonnet | REST/GraphQL API 设计和契约定义 |
|
|
138
|
-
|
|
139
|
-
### 产品通道
|
|
140
|
-
|
|
141
|
-
| Agent | 模型 | 用途 |
|
|
142
|
-
| ------- | ------ | ------ |
|
|
143
|
-
| `product-manager` | sonnet | 问题定义、PRD |
|
|
144
|
-
| `ux-researcher` | sonnet | 启发式审计、可用性 |
|
|
145
|
-
| `information-architect` | sonnet | 分类、导航 |
|
|
146
|
-
| `product-analyst` | sonnet | 产品指标、漏斗分析 |
|
|
147
|
-
|
|
148
|
-
### 协调
|
|
149
|
-
|
|
150
|
-
| Agent | 模型 | 用途 |
|
|
151
|
-
| ------- | ------ | ------ |
|
|
152
|
-
| `critic` | opus | 计划/设计批判性挑战 |
|
|
153
|
-
| `vision` | sonnet | 图片/截图/图表分析 |
|
|
154
|
-
|
|
155
|
-
### Axiom Agents
|
|
156
|
-
|
|
157
|
-
| Agent | 模型 | 用途 |
|
|
158
|
-
| ------- | ------ | ------ |
|
|
159
|
-
| `axiom-requirement-analyst` | sonnet | 需求分析三态门(PASS/CLARIFY/REJECT) |
|
|
160
|
-
| `axiom-product-designer` | sonnet | Draft PRD 生成,含 Mermaid 流程图 |
|
|
161
|
-
| `axiom-review-aggregator` | sonnet | 5 专家并行审查聚合与冲突仲裁 |
|
|
162
|
-
| `axiom-prd-crafter` | sonnet | 工程级 PRD,含门控验证 |
|
|
163
|
-
| `axiom-system-architect` | sonnet | 原子任务 DAG 与 Manifest 生成 |
|
|
164
|
-
| `axiom-evolution-engine` | sonnet | 知识收割、模式检测、工作流优化 |
|
|
165
|
-
| `axiom-context-manager` | sonnet | 7 操作记忆系统(读/写/状态/检查点) |
|
|
166
|
-
| `axiom-worker` | sonnet | PM→Worker 协议,三态输出 |
|
|
167
|
-
| `axiom-ux-director` | sonnet | UX/体验专家评审 |
|
|
168
|
-
| `axiom-product-director` | sonnet | 产品战略专家评审 |
|
|
169
|
-
| `axiom-domain-expert` | sonnet | 领域知识专家评审 |
|
|
170
|
-
| `axiom-tech-lead` | sonnet | 技术可行性评审 |
|
|
171
|
-
| `axiom-critic` | sonnet | 安全/质量/逻辑评审 |
|
|
172
|
-
| `axiom-sub-prd-writer` | sonnet | 将 Manifest 任务拆解为可执行 Sub-PRD |
|
|
98
|
+
## Agents(49 个)
|
|
99
|
+
|
|
100
|
+
完整列表请查看 [Agent 参考手册](docs/reference/AGENTS.md)
|
|
101
|
+
|
|
102
|
+
**核心 Agents**:
|
|
103
|
+
|
|
104
|
+
* **构建通道**:`explore` (haiku)、`planner` (opus)、`executor` (sonnet)、`architect` (opus)
|
|
105
|
+
* **审查通道**:`code-reviewer` (opus)、`security-reviewer` (sonnet)、`quality-reviewer` (sonnet)
|
|
106
|
+
* **领域专家**:`designer` (sonnet)、`test-engineer` (sonnet)、`debugger` (sonnet)
|
|
173
107
|
|
|
174
108
|
---
|
|
175
109
|
|
|
176
|
-
## Skills(
|
|
110
|
+
## Skills(71 个)
|
|
177
111
|
|
|
178
|
-
|
|
112
|
+
完整列表请查看 [Skills 参考手册](docs/reference/SKILLS.md)
|
|
179
113
|
|
|
180
|
-
|
|
181
|
-
| ------- | -------- | ------ |
|
|
182
|
-
| `autopilot` | "autopilot", "build me" | 从想法到可运行代码的全自主执行 |
|
|
183
|
-
| `ralph` | "ralph", "don't stop" | 带 verifier 验证的自引用循环 |
|
|
184
|
-
| `ultrawork` | "ulw", "ultrawork" | 并行 agent 编排最大并行度 |
|
|
185
|
-
| `team` | "team", "coordinated team" | N 个协调 agents,阶段感知路由 |
|
|
186
|
-
| `ultrapilot` | "ultrapilot", "parallel build" | 带文件所有权分区的并行 autopilot |
|
|
187
|
-
| `pipeline` | "pipeline", "chain agents" | 带数据传递的顺序 agent 链 |
|
|
188
|
-
| `ultraqa` | 由 autopilot 激活 | QA 循环:测试、验证、修复、重复 |
|
|
189
|
-
| `plan` | "plan this", "plan the" | 战略规划,支持 `--consensus`/`--review` |
|
|
190
|
-
| `ralplan` | "ralplan", "consensus plan" | 与 Planner/Architect/Critic 迭代规划 |
|
|
191
|
-
| `swarm` | "swarm" | Team 的兼容性外观 |
|
|
114
|
+
**核心 Skills**:
|
|
192
115
|
|
|
193
|
-
|
|
116
|
+
* **工作流**:`autopilot`、`team`、`ralph`、`ultrawork`、`plan`
|
|
117
|
+
* **开发**:`brainstorming`、`writing-plans`、`test-driven-development`
|
|
118
|
+
* **Axiom**:`ax-draft`、`ax-review`、`ax-decompose`、`ax-implement`
|
|
194
119
|
|
|
195
|
-
|
|
196
|
-
| ------- | ------ |
|
|
197
|
-
| `brainstorming` | 设计对话,代码前必须先设计 |
|
|
198
|
-
| `writing-plans` | 详细实现计划,原子任务 |
|
|
120
|
+
---
|
|
199
121
|
| `executing-plans` | 带检查点的批量执行 |
|
|
200
122
|
| `subagent-driven-development` | 每任务独立 subagent + 两阶段审查 |
|
|
201
123
|
| `test-driven-development` | RED-GREEN-REFACTOR 循环 |
|
|
@@ -276,18 +198,20 @@ autopilot "创建一个 hello world 函数"
|
|
|
276
198
|
|
|
277
199
|
### Team 流水线(默认多 Agent 编排器)
|
|
278
200
|
|
|
279
|
-
```
|
|
280
|
-
|
|
201
|
+
```mermaid
|
|
202
|
+
graph LR
|
|
203
|
+
A[team-plan<br/>探索与规划] --> B[team-prd<br/>需求确认]
|
|
204
|
+
B --> C[team-exec<br/>代码实现]
|
|
205
|
+
C --> D[team-verify<br/>验证与测试]
|
|
206
|
+
D -->|发现缺陷| E[team-fix<br/>修复]
|
|
207
|
+
E --> C
|
|
208
|
+
D -->|通过| F((完成))
|
|
281
209
|
```
|
|
282
210
|
|
|
283
211
|
* **team-plan**:`explore` + `planner`,可选 `analyst`/`architect`
|
|
284
|
-
|
|
285
212
|
* **team-prd**:`analyst`,可选 `product-manager`/`critic`
|
|
286
|
-
|
|
287
213
|
* **team-exec**:`executor` + 任务适配专家
|
|
288
|
-
|
|
289
214
|
* **team-verify**:`verifier` + 按需审查 agents
|
|
290
|
-
|
|
291
215
|
* **team-fix**:根据缺陷类型路由到 `executor`/`build-fixer`/`debugger`
|
|
292
216
|
|
|
293
217
|
### MCP 路由
|
|
@@ -321,36 +245,18 @@ ultrapower 内置 Axiom 自我进化引擎,让 AI 工作流随使用不断优
|
|
|
321
245
|
| 工作流优化 | 分析执行指标,发现瓶颈并生成优化建议 |
|
|
322
246
|
| 跨会话记忆 | 知识库和模式库跨会话持久化,越用越聪明 |
|
|
323
247
|
|
|
324
|
-
###
|
|
325
|
-
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
# 3. 查看系统状态
|
|
338
|
-
|
|
339
|
-
/ax-status
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
### 进化工作流
|
|
343
|
-
|
|
344
|
-
```
|
|
345
|
-
需求 → /ax-draft → /ax-review → /ax-decompose → /ax-implement
|
|
346
|
-
↓
|
|
347
|
-
任务完成
|
|
348
|
-
↓
|
|
349
|
-
/ax-reflect(反思)
|
|
350
|
-
↓
|
|
351
|
-
/ax-evolve(进化)
|
|
352
|
-
↓
|
|
353
|
-
知识库更新 + 模式库更新
|
|
248
|
+
### Axiom 进化工作流
|
|
249
|
+
|
|
250
|
+
```mermaid
|
|
251
|
+
graph TB
|
|
252
|
+
A[需求] --> B[/ax-draft<br/>需求起草/]
|
|
253
|
+
B --> C[/ax-review<br/>专家评审/]
|
|
254
|
+
C --> D[/ax-decompose<br/>任务拆解/]
|
|
255
|
+
D --> E[/ax-implement<br/>实施交付/]
|
|
256
|
+
E --> F[任务完成]
|
|
257
|
+
F --> G[/ax-reflect<br/>反思/]
|
|
258
|
+
G --> H[/ax-evolve<br/>进化/]
|
|
259
|
+
H --> I[知识库更新<br/>模式库更新]
|
|
354
260
|
```
|
|
355
261
|
|
|
356
262
|
详细文档请参阅 [docs/EVOLUTION.md](docs/EVOLUTION.md)。
|
package/bridge/codex-server.cjs
CHANGED
|
@@ -13723,6 +13723,147 @@ var ExperimentalServerTasks = class {
|
|
|
13723
13723
|
requestStream(request, resultSchema, options) {
|
|
13724
13724
|
return this._server.requestStream(request, resultSchema, options);
|
|
13725
13725
|
}
|
|
13726
|
+
/**
|
|
13727
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
13728
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
13729
|
+
*
|
|
13730
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
13731
|
+
* before the final result.
|
|
13732
|
+
*
|
|
13733
|
+
* @example
|
|
13734
|
+
* ```typescript
|
|
13735
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
13736
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
13737
|
+
* maxTokens: 100
|
|
13738
|
+
* }, {
|
|
13739
|
+
* onprogress: (progress) => {
|
|
13740
|
+
* // Handle streaming tokens via progress notifications
|
|
13741
|
+
* console.log('Progress:', progress.message);
|
|
13742
|
+
* }
|
|
13743
|
+
* });
|
|
13744
|
+
*
|
|
13745
|
+
* for await (const message of stream) {
|
|
13746
|
+
* switch (message.type) {
|
|
13747
|
+
* case 'taskCreated':
|
|
13748
|
+
* console.log('Task created:', message.task.taskId);
|
|
13749
|
+
* break;
|
|
13750
|
+
* case 'taskStatus':
|
|
13751
|
+
* console.log('Task status:', message.task.status);
|
|
13752
|
+
* break;
|
|
13753
|
+
* case 'result':
|
|
13754
|
+
* console.log('Final result:', message.result);
|
|
13755
|
+
* break;
|
|
13756
|
+
* case 'error':
|
|
13757
|
+
* console.error('Error:', message.error);
|
|
13758
|
+
* break;
|
|
13759
|
+
* }
|
|
13760
|
+
* }
|
|
13761
|
+
* ```
|
|
13762
|
+
*
|
|
13763
|
+
* @param params - The sampling request parameters
|
|
13764
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
13765
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
13766
|
+
*
|
|
13767
|
+
* @experimental
|
|
13768
|
+
*/
|
|
13769
|
+
createMessageStream(params, options) {
|
|
13770
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
13771
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
13772
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
13773
|
+
}
|
|
13774
|
+
if (params.messages.length > 0) {
|
|
13775
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
13776
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
13777
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
13778
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
13779
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
13780
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
13781
|
+
if (hasToolResults) {
|
|
13782
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
13783
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
13784
|
+
}
|
|
13785
|
+
if (!hasPreviousToolUse) {
|
|
13786
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
13787
|
+
}
|
|
13788
|
+
}
|
|
13789
|
+
if (hasPreviousToolUse) {
|
|
13790
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
13791
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
13792
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
13793
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
13794
|
+
}
|
|
13795
|
+
}
|
|
13796
|
+
}
|
|
13797
|
+
return this.requestStream({
|
|
13798
|
+
method: "sampling/createMessage",
|
|
13799
|
+
params
|
|
13800
|
+
}, CreateMessageResultSchema, options);
|
|
13801
|
+
}
|
|
13802
|
+
/**
|
|
13803
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
13804
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
13805
|
+
*
|
|
13806
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
13807
|
+
* and 'taskStatus' messages before the final result.
|
|
13808
|
+
*
|
|
13809
|
+
* @example
|
|
13810
|
+
* ```typescript
|
|
13811
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
13812
|
+
* mode: 'url',
|
|
13813
|
+
* message: 'Please authenticate',
|
|
13814
|
+
* elicitationId: 'auth-123',
|
|
13815
|
+
* url: 'https://example.com/auth'
|
|
13816
|
+
* }, {
|
|
13817
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
13818
|
+
* });
|
|
13819
|
+
*
|
|
13820
|
+
* for await (const message of stream) {
|
|
13821
|
+
* switch (message.type) {
|
|
13822
|
+
* case 'taskCreated':
|
|
13823
|
+
* console.log('Task created:', message.task.taskId);
|
|
13824
|
+
* break;
|
|
13825
|
+
* case 'taskStatus':
|
|
13826
|
+
* console.log('Task status:', message.task.status);
|
|
13827
|
+
* break;
|
|
13828
|
+
* case 'result':
|
|
13829
|
+
* console.log('User action:', message.result.action);
|
|
13830
|
+
* break;
|
|
13831
|
+
* case 'error':
|
|
13832
|
+
* console.error('Error:', message.error);
|
|
13833
|
+
* break;
|
|
13834
|
+
* }
|
|
13835
|
+
* }
|
|
13836
|
+
* ```
|
|
13837
|
+
*
|
|
13838
|
+
* @param params - The elicitation request parameters
|
|
13839
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
13840
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
13841
|
+
*
|
|
13842
|
+
* @experimental
|
|
13843
|
+
*/
|
|
13844
|
+
elicitInputStream(params, options) {
|
|
13845
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
13846
|
+
const mode = params.mode ?? "form";
|
|
13847
|
+
switch (mode) {
|
|
13848
|
+
case "url": {
|
|
13849
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
13850
|
+
throw new Error("Client does not support url elicitation.");
|
|
13851
|
+
}
|
|
13852
|
+
break;
|
|
13853
|
+
}
|
|
13854
|
+
case "form": {
|
|
13855
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
13856
|
+
throw new Error("Client does not support form elicitation.");
|
|
13857
|
+
}
|
|
13858
|
+
break;
|
|
13859
|
+
}
|
|
13860
|
+
}
|
|
13861
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
13862
|
+
return this.requestStream({
|
|
13863
|
+
method: "elicitation/create",
|
|
13864
|
+
params: normalizedParams
|
|
13865
|
+
}, ElicitResultSchema, options);
|
|
13866
|
+
}
|
|
13726
13867
|
/**
|
|
13727
13868
|
* Gets the current status of a task.
|
|
13728
13869
|
*
|
|
@@ -14707,6 +14848,41 @@ Prompt unavailable.`;
|
|
|
14707
14848
|
}
|
|
14708
14849
|
}
|
|
14709
14850
|
|
|
14851
|
+
// src/features/prompt-optimizer/index.ts
|
|
14852
|
+
init_define_AGENT_PROMPTS_CODEX();
|
|
14853
|
+
init_define_AGENT_PROMPTS();
|
|
14854
|
+
init_define_AGENT_ROLES();
|
|
14855
|
+
var REDUNDANT_PHRASES = [
|
|
14856
|
+
/could you please /gi,
|
|
14857
|
+
/I would like you to /gi,
|
|
14858
|
+
/can you help me /gi,
|
|
14859
|
+
/ and help me understand it$/gi,
|
|
14860
|
+
/help me /gi
|
|
14861
|
+
];
|
|
14862
|
+
var INSTRUCTION_SIMPLIFIERS = [
|
|
14863
|
+
{ pattern: /Please summarize the following/gi, replacement: "Summarize" },
|
|
14864
|
+
{ pattern: /Could you analyze/gi, replacement: "Analyze" },
|
|
14865
|
+
{ pattern: /^please /gi, replacement: "" }
|
|
14866
|
+
];
|
|
14867
|
+
function optimizePromptText(prompt) {
|
|
14868
|
+
const changes = [];
|
|
14869
|
+
let optimized = prompt;
|
|
14870
|
+
REDUNDANT_PHRASES.forEach((pattern) => {
|
|
14871
|
+
if (pattern.test(optimized)) {
|
|
14872
|
+
optimized = optimized.replace(pattern, "");
|
|
14873
|
+
changes.push("\u79FB\u9664\u5197\u4F59\u77ED\u8BED");
|
|
14874
|
+
}
|
|
14875
|
+
});
|
|
14876
|
+
const originalOptimized = optimized;
|
|
14877
|
+
INSTRUCTION_SIMPLIFIERS.forEach(({ pattern, replacement }) => {
|
|
14878
|
+
optimized = optimized.replace(pattern, replacement);
|
|
14879
|
+
});
|
|
14880
|
+
if (optimized !== originalOptimized) {
|
|
14881
|
+
changes.push("\u7B80\u5316\u6307\u4EE4\u52A8\u8BCD");
|
|
14882
|
+
}
|
|
14883
|
+
return { text: optimized.trim(), changes };
|
|
14884
|
+
}
|
|
14885
|
+
|
|
14710
14886
|
// src/mcp/prompt-injection.ts
|
|
14711
14887
|
var import_meta2 = {};
|
|
14712
14888
|
function getPackageDir2() {
|
|
@@ -14801,7 +14977,8 @@ ${systemPrompt}
|
|
|
14801
14977
|
|
|
14802
14978
|
${fileContext}`);
|
|
14803
14979
|
}
|
|
14804
|
-
|
|
14980
|
+
const { text: optimizedPrompt } = optimizePromptText(userPrompt);
|
|
14981
|
+
parts.push(optimizedPrompt);
|
|
14805
14982
|
return parts.join("\n\n");
|
|
14806
14983
|
}
|
|
14807
14984
|
|
|
@@ -16691,7 +16868,7 @@ function parseEnvInt(envVal, fallback) {
|
|
|
16691
16868
|
return isNaN(n) ? fallback : n;
|
|
16692
16869
|
}
|
|
16693
16870
|
var CODEX_DEFAULT_MODEL = process.env.OMC_CODEX_DEFAULT_MODEL || "gpt-5.3-codex";
|
|
16694
|
-
var CODEX_TIMEOUT = Math.min(Math.max(5e3, parseEnvInt(process.env.OMC_CODEX_TIMEOUT,
|
|
16871
|
+
var CODEX_TIMEOUT = Math.min(Math.max(5e3, parseEnvInt(process.env.OMC_CODEX_TIMEOUT, 3e5)), 36e5);
|
|
16695
16872
|
var RATE_LIMIT_RETRY_COUNT = Math.min(10, Math.max(1, parseEnvInt(process.env.OMC_CODEX_RATE_LIMIT_RETRY_COUNT, 3)));
|
|
16696
16873
|
var RATE_LIMIT_INITIAL_DELAY = Math.max(1e3, parseEnvInt(process.env.OMC_CODEX_RATE_LIMIT_INITIAL_DELAY, 5e3));
|
|
16697
16874
|
var RATE_LIMIT_MAX_DELAY = Math.max(5e3, parseEnvInt(process.env.OMC_CODEX_RATE_LIMIT_MAX_DELAY, 6e4));
|
|
@@ -17477,7 +17654,7 @@ function parseEnvInt2(envVal, fallback) {
|
|
|
17477
17654
|
return isNaN(n) ? fallback : n;
|
|
17478
17655
|
}
|
|
17479
17656
|
var GEMINI_DEFAULT_MODEL = process.env.OMC_GEMINI_DEFAULT_MODEL || "gemini-3-pro-preview";
|
|
17480
|
-
var GEMINI_TIMEOUT = Math.min(Math.max(5e3, parseEnvInt2(process.env.OMC_GEMINI_TIMEOUT,
|
|
17657
|
+
var GEMINI_TIMEOUT = Math.min(Math.max(5e3, parseEnvInt2(process.env.OMC_GEMINI_TIMEOUT, 3e5)), 36e5);
|
|
17481
17658
|
var _yoloEnv = process.env.OMC_GEMINI_YOLO;
|
|
17482
17659
|
var MAX_FILE_SIZE2 = 5 * 1024 * 1024;
|
|
17483
17660
|
var MAX_STDOUT_BYTES2 = 10 * 1024 * 1024;
|