@skj1724/oh-my-opencode 3.19.1 → 3.19.4
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/dist/agents/atlas.d.ts +1 -1
- package/dist/agents/atlas.test.d.ts +1 -0
- package/dist/agents/explore.test.d.ts +1 -0
- package/dist/agents/librarian.test.d.ts +1 -0
- package/dist/agents/metis.d.ts +1 -1
- package/dist/agents/metis.test.d.ts +1 -0
- package/dist/agents/momus.d.ts +1 -1
- package/dist/agents/multimodal-looker.test.d.ts +1 -0
- package/dist/agents/oracle.d.ts +1 -0
- package/dist/agents/oracle.test.d.ts +1 -0
- package/dist/agents/prometheus-prompt.d.ts +1 -1
- package/dist/agents/sisyphus.test.d.ts +1 -0
- package/dist/cli/index.js +48 -1
- package/dist/features/background-agent/index.d.ts +1 -0
- package/dist/features/background-agent/manager.d.ts +1 -1
- package/dist/features/background-agent/perf-aggregator.d.ts +26 -0
- package/dist/features/background-agent/types.d.ts +15 -0
- package/dist/hooks/thinking-block-validator/index.test.d.ts +1 -0
- package/dist/index.js +462 -443
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/perf-timer.d.ts +26 -0
- package/dist/shared/perf-timer.test.d.ts +1 -0
- package/dist/tools/background-task/constants.d.ts +3 -3
- package/dist/tools/call-omo-agent/constants.d.ts +1 -1
- package/dist/tools/session-manager/constants.d.ts +5 -5
- package/dist/tools/skill/constants.d.ts +2 -2
- package/dist/tools/skill-mcp/constants.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4781,7 +4781,7 @@ var init_agent_tool_restrictions = __esm(() => {
|
|
|
4781
4781
|
});
|
|
4782
4782
|
|
|
4783
4783
|
// src/shared/model-requirements.ts
|
|
4784
|
-
var AGENT_MODEL_REQUIREMENTS
|
|
4784
|
+
var AGENT_MODEL_REQUIREMENTS;
|
|
4785
4785
|
var init_model_requirements = __esm(() => {
|
|
4786
4786
|
AGENT_MODEL_REQUIREMENTS = {
|
|
4787
4787
|
sisyphus: {
|
|
@@ -4850,58 +4850,6 @@ var init_model_requirements = __esm(() => {
|
|
|
4850
4850
|
]
|
|
4851
4851
|
}
|
|
4852
4852
|
};
|
|
4853
|
-
CATEGORY_MODEL_REQUIREMENTS = {
|
|
4854
|
-
"visual-engineering": {
|
|
4855
|
-
fallbackChain: [
|
|
4856
|
-
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-pro" },
|
|
4857
|
-
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5", variant: "max" },
|
|
4858
|
-
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2", variant: "high" }
|
|
4859
|
-
]
|
|
4860
|
-
},
|
|
4861
|
-
ultrabrain: {
|
|
4862
|
-
fallbackChain: [
|
|
4863
|
-
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2-codex", variant: "xhigh" },
|
|
4864
|
-
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5", variant: "max" },
|
|
4865
|
-
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-pro" }
|
|
4866
|
-
]
|
|
4867
|
-
},
|
|
4868
|
-
artistry: {
|
|
4869
|
-
fallbackChain: [
|
|
4870
|
-
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-pro", variant: "max" },
|
|
4871
|
-
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5", variant: "max" },
|
|
4872
|
-
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2" }
|
|
4873
|
-
]
|
|
4874
|
-
},
|
|
4875
|
-
quick: {
|
|
4876
|
-
fallbackChain: [
|
|
4877
|
-
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-haiku-4-5" },
|
|
4878
|
-
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" },
|
|
4879
|
-
{ providers: ["opencode"], model: "gpt-5-nano" }
|
|
4880
|
-
]
|
|
4881
|
-
},
|
|
4882
|
-
"unspecified-low": {
|
|
4883
|
-
fallbackChain: [
|
|
4884
|
-
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-sonnet-4-5" },
|
|
4885
|
-
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2-codex", variant: "medium" },
|
|
4886
|
-
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" }
|
|
4887
|
-
]
|
|
4888
|
-
},
|
|
4889
|
-
"unspecified-high": {
|
|
4890
|
-
fallbackChain: [
|
|
4891
|
-
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5", variant: "max" },
|
|
4892
|
-
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2", variant: "high" },
|
|
4893
|
-
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-pro" }
|
|
4894
|
-
]
|
|
4895
|
-
},
|
|
4896
|
-
writing: {
|
|
4897
|
-
fallbackChain: [
|
|
4898
|
-
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" },
|
|
4899
|
-
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-sonnet-4-5" },
|
|
4900
|
-
{ providers: ["zai-coding-plan"], model: "glm-4.7" },
|
|
4901
|
-
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2" }
|
|
4902
|
-
]
|
|
4903
|
-
}
|
|
4904
|
-
};
|
|
4905
4853
|
});
|
|
4906
4854
|
|
|
4907
4855
|
// src/shared/model-availability.ts
|
|
@@ -5038,6 +4986,53 @@ var init_model_resolver = __esm(() => {
|
|
|
5038
4986
|
init_model_availability();
|
|
5039
4987
|
});
|
|
5040
4988
|
|
|
4989
|
+
// src/shared/perf-timer.ts
|
|
4990
|
+
class PerfTimer {
|
|
4991
|
+
marks = new Map;
|
|
4992
|
+
spans = [];
|
|
4993
|
+
mark(name) {
|
|
4994
|
+
this.marks.set(name, performance.now());
|
|
4995
|
+
}
|
|
4996
|
+
measure(name, startMark, endMark) {
|
|
4997
|
+
const start = this.marks.get(startMark);
|
|
4998
|
+
if (start === undefined)
|
|
4999
|
+
return 0;
|
|
5000
|
+
const end = endMark ? this.marks.get(endMark) ?? performance.now() : performance.now();
|
|
5001
|
+
const duration = end - start;
|
|
5002
|
+
this.spans.push({ name, durationMs: duration, start, end });
|
|
5003
|
+
return duration;
|
|
5004
|
+
}
|
|
5005
|
+
getReport() {
|
|
5006
|
+
return [...this.spans];
|
|
5007
|
+
}
|
|
5008
|
+
reset() {
|
|
5009
|
+
this.marks.clear();
|
|
5010
|
+
this.spans = [];
|
|
5011
|
+
}
|
|
5012
|
+
static formatDuration(start, end, options) {
|
|
5013
|
+
const ms = (end ?? new Date).getTime() - start.getTime();
|
|
5014
|
+
const absMs = Math.abs(ms);
|
|
5015
|
+
const totalSeconds = absMs / 1000;
|
|
5016
|
+
const seconds = Math.floor(totalSeconds);
|
|
5017
|
+
const minutes = Math.floor(seconds / 60);
|
|
5018
|
+
const hours = Math.floor(minutes / 60);
|
|
5019
|
+
const precision = options?.precision ?? "full";
|
|
5020
|
+
if (hours > 0) {
|
|
5021
|
+
if (precision === "compact") {
|
|
5022
|
+
return `${hours}h ${minutes % 60}m`;
|
|
5023
|
+
}
|
|
5024
|
+
return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
|
|
5025
|
+
}
|
|
5026
|
+
if (minutes > 0) {
|
|
5027
|
+
return `${minutes}m ${seconds % 60}s`;
|
|
5028
|
+
}
|
|
5029
|
+
if (seconds === 0 && absMs > 0) {
|
|
5030
|
+
return `${(absMs / 1000).toFixed(1)}s`;
|
|
5031
|
+
}
|
|
5032
|
+
return `${seconds}s`;
|
|
5033
|
+
}
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5041
5036
|
// src/shared/index.ts
|
|
5042
5037
|
var init_shared = __esm(() => {
|
|
5043
5038
|
init_frontmatter();
|
|
@@ -15416,6 +15411,7 @@ var META_TYPES = new Set(["step-start", "step-finish"]);
|
|
|
15416
15411
|
var CONTENT_TYPES = new Set(["text", "tool", "tool_use", "tool_result"]);
|
|
15417
15412
|
|
|
15418
15413
|
// src/hooks/session-recovery/storage.ts
|
|
15414
|
+
var nextRecoveryBlockId = 0;
|
|
15419
15415
|
function generatePartId2() {
|
|
15420
15416
|
const timestamp = Date.now().toString(16);
|
|
15421
15417
|
const random = Math.random().toString(36).substring(2, 10);
|
|
@@ -15612,7 +15608,7 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
15612
15608
|
mkdirSync2(partDir, { recursive: true });
|
|
15613
15609
|
}
|
|
15614
15610
|
const previousThinking = findLastThinkingContent(sessionID, messageID);
|
|
15615
|
-
const partId = `
|
|
15611
|
+
const partId = `prt_${++nextRecoveryBlockId}_thinking`;
|
|
15616
15612
|
const part = {
|
|
15617
15613
|
id: partId,
|
|
15618
15614
|
sessionID,
|
|
@@ -19818,7 +19814,9 @@ var KEYWORD_DETECTORS = [
|
|
|
19818
19814
|
\u5982\u679C\u590D\u6742\uFF08\u67B6\u6784\u3001\u591A\u7CFB\u7EDF\u30012 \u6B21\u4EE5\u4E0A\u5931\u8D25\u540E\u7684\u8C03\u8BD5\uFF09\uFF1A
|
|
19819
19815
|
- \u54A8\u8BE2 oracle \u83B7\u53D6\u6218\u7565\u6307\u5BFC
|
|
19820
19816
|
|
|
19821
|
-
\u7EFC\u5408\u53D1\u73B0\u540E\u518D\u7EE7\u7EED\u3002
|
|
19817
|
+
\u7EFC\u5408\u53D1\u73B0\u540E\u518D\u7EE7\u7EED\u3002
|
|
19818
|
+
**\u4E2D\u6587\u8BED\u5883\u601D\u8003\u56DE\u590D**
|
|
19819
|
+
`
|
|
19822
19820
|
}
|
|
19823
19821
|
];
|
|
19824
19822
|
|
|
@@ -20268,6 +20266,7 @@ function createInteractiveBashSessionHook(_ctx) {
|
|
|
20268
20266
|
};
|
|
20269
20267
|
}
|
|
20270
20268
|
// src/hooks/thinking-block-validator/index.ts
|
|
20269
|
+
var nextThinkingBlockId = 0;
|
|
20271
20270
|
function isExtendedThinkingModel(modelID) {
|
|
20272
20271
|
if (!modelID)
|
|
20273
20272
|
return false;
|
|
@@ -20317,7 +20316,7 @@ function prependThinkingBlock(message, thinkingContent) {
|
|
|
20317
20316
|
}
|
|
20318
20317
|
const thinkingPart = {
|
|
20319
20318
|
type: "thinking",
|
|
20320
|
-
id: `
|
|
20319
|
+
id: `prt_${++nextThinkingBlockId}_synthetic_thinking`,
|
|
20321
20320
|
sessionID: message.info.sessionID || "",
|
|
20322
20321
|
messageID: message.info.id,
|
|
20323
20322
|
thinking: thinkingContent,
|
|
@@ -21431,12 +21430,12 @@ git log --oneline $(git merge-base HEAD main 2>/dev/null || git merge-base HEAD
|
|
|
21431
21430
|
|
|
21432
21431
|
\`\`\`
|
|
21433
21432
|
\u7EDF\u8BA1 git log -30 \u7684\u7ED3\u679C\uFF1A
|
|
21434
|
-
- \u542B\
|
|
21433
|
+
- \u542B\u4E2D\u6587\u5B57\u7B26\uFF1AN \u4E2A\u63D0\u4EA4
|
|
21435
21434
|
- \u4EC5\u82F1\u6587\uFF1AM \u4E2A\u63D0\u4EA4
|
|
21436
21435
|
- \u6DF7\u5408\uFF1AK \u4E2A\u63D0\u4EA4
|
|
21437
21436
|
|
|
21438
21437
|
\u51B3\u7B56\uFF1A
|
|
21439
|
-
- \u5982\u679C\
|
|
21438
|
+
- \u5982\u679C\u4E2D\u6587 >= 50% -> \u4E2D\u6587
|
|
21440
21439
|
- \u5982\u679C\u82F1\u6587 >= 50% -> \u82F1\u6587
|
|
21441
21440
|
- \u5982\u679C\u6DF7\u5408 -> \u4F7F\u7528\u591A\u6570\u8BED\u8A00
|
|
21442
21441
|
\`\`\`
|
|
@@ -21471,8 +21470,8 @@ short_count = <=3 \u4E2A\u8BCD\u7684\u63D0\u4EA4
|
|
|
21471
21470
|
======================
|
|
21472
21471
|
\u5206\u6790\u6765\u6E90\uFF1Agit log \u7684 30 \u6761\u63D0\u4EA4
|
|
21473
21472
|
|
|
21474
|
-
\u8BED\u8A00\uFF1A[\
|
|
21475
|
-
- \
|
|
21473
|
+
\u8BED\u8A00\uFF1A[\u4E2D\u6587 | \u82F1\u6587]
|
|
21474
|
+
- \u4E2D\u6587\u63D0\u4EA4\uFF1AN (X%)
|
|
21476
21475
|
- \u82F1\u6587\u63D0\u4EA4\uFF1AM (Y%)
|
|
21477
21476
|
|
|
21478
21477
|
\u98CE\u683C\uFF1A[SEMANTIC | PLAIN | SENTENCE | SHORT]
|
|
@@ -21827,15 +21826,9 @@ git log -1 --oneline
|
|
|
21827
21826
|
**\u57FA\u4E8E\u9636\u6BB5 1 \u7684\u63D0\u4EA4\u914D\u7F6E\uFF1A**
|
|
21828
21827
|
|
|
21829
21828
|
\`\`\`
|
|
21830
|
-
\u5982\u679C\u98CE\u683C == SEMANTIC \u4E14\u8BED\u8A00 == \u97E9\u6587\uFF1A
|
|
21831
|
-
-> "feat: \uB85C\uADF8\uC778 \uAE30\uB2A5 \uCD94\uAC00"
|
|
21832
|
-
|
|
21833
21829
|
\u5982\u679C\u98CE\u683C == SEMANTIC \u4E14\u8BED\u8A00 == \u82F1\u6587\uFF1A
|
|
21834
21830
|
-> "feat: add login feature"
|
|
21835
21831
|
|
|
21836
|
-
\u5982\u679C\u98CE\u683C == PLAIN \u4E14\u8BED\u8A00 == \u97E9\u6587\uFF1A
|
|
21837
|
-
-> "\uB85C\uADF8\uC778 \uAE30\uB2A5 \uCD94\uAC00"
|
|
21838
|
-
|
|
21839
21832
|
\u5982\u679C\u98CE\u683C == PLAIN \u4E14\u8BED\u8A00 == \u82F1\u6587\uFF1A
|
|
21840
21833
|
-> "Add login feature"
|
|
21841
21834
|
|
|
@@ -40828,31 +40821,31 @@ var PART_STORAGE4 = join51(OPENCODE_STORAGE9, "part");
|
|
|
40828
40821
|
var SESSION_STORAGE = join51(OPENCODE_STORAGE9, "session");
|
|
40829
40822
|
var TODO_DIR2 = join51(getClaudeConfigDir(), "todos");
|
|
40830
40823
|
var TRANSCRIPT_DIR2 = join51(getClaudeConfigDir(), "transcripts");
|
|
40831
|
-
var SESSION_LIST_DESCRIPTION =
|
|
40824
|
+
var SESSION_LIST_DESCRIPTION = `\u5217\u51FA\u6240\u6709 OpenCode session\uFF0C\u652F\u6301\u53EF\u9009\u8FC7\u6EE4\u3002
|
|
40832
40825
|
|
|
40833
|
-
|
|
40826
|
+
\u8FD4\u56DE\u53EF\u7528\u7684 session ID \u5217\u8868\uFF0C\u5305\u542B\u6D88\u606F\u6570\u91CF\u3001\u65E5\u671F\u8303\u56F4\u548C\u4F7F\u7528\u8FC7\u7684 agents \u7B49\u5143\u6570\u636E\u3002
|
|
40834
40827
|
|
|
40835
|
-
|
|
40836
|
-
- limit
|
|
40837
|
-
- from_date
|
|
40838
|
-
- to_date
|
|
40828
|
+
\u53C2\u6570\uFF1A
|
|
40829
|
+
- limit\uFF08\u53EF\u9009\uFF09\uFF1A\u6700\u5927\u8FD4\u56DE session \u6570\u91CF
|
|
40830
|
+
- from_date\uFF08\u53EF\u9009\uFF09\uFF1A\u8FC7\u6EE4\u6B64\u65E5\u671F\u4E4B\u540E\u7684 session\uFF08ISO 8601 \u683C\u5F0F\uFF09
|
|
40831
|
+
- to_date\uFF08\u53EF\u9009\uFF09\uFF1A\u8FC7\u6EE4\u6B64\u65E5\u671F\u4E4B\u524D\u7684 session\uFF08ISO 8601 \u683C\u5F0F\uFF09
|
|
40839
40832
|
|
|
40840
|
-
|
|
40833
|
+
\u8F93\u51FA\u793A\u4F8B\uFF1A
|
|
40841
40834
|
| Session ID | Messages | First | Last | Agents |
|
|
40842
40835
|
|------------|----------|-------|------|--------|
|
|
40843
40836
|
| ses_abc123 | 45 | 2025-12-20 | 2025-12-24 | build, oracle |
|
|
40844
40837
|
| ses_def456 | 12 | 2025-12-19 | 2025-12-19 | build |`;
|
|
40845
|
-
var SESSION_READ_DESCRIPTION =
|
|
40838
|
+
var SESSION_READ_DESCRIPTION = `\u8BFB\u53D6 OpenCode session \u4E2D\u7684\u6D88\u606F\u548C\u5386\u53F2\u8BB0\u5F55\u3002
|
|
40846
40839
|
|
|
40847
|
-
|
|
40840
|
+
\u8FD4\u56DE\u683C\u5F0F\u5316\u7684 session \u6D88\u606F\u89C6\u56FE\uFF0C\u5305\u542B\u89D2\u8272\u3001\u65F6\u95F4\u6233\u548C\u5185\u5BB9\u3002\u53EF\u9009\u62E9\u5305\u542B todo \u548C transcript \u6570\u636E\u3002
|
|
40848
40841
|
|
|
40849
|
-
|
|
40850
|
-
- session_id
|
|
40851
|
-
- include_todos
|
|
40852
|
-
- include_transcript
|
|
40853
|
-
- limit
|
|
40842
|
+
\u53C2\u6570\uFF1A
|
|
40843
|
+
- session_id\uFF08\u5FC5\u586B\uFF09\uFF1A\u8981\u8BFB\u53D6\u7684 Session ID
|
|
40844
|
+
- include_todos\uFF08\u53EF\u9009\uFF09\uFF1A\u5305\u542B todo \u5217\u8868\uFF08\u5982\u679C\u6709\u7684\u8BDD\uFF09\uFF08\u9ED8\u8BA4\u503C: false\uFF09
|
|
40845
|
+
- include_transcript\uFF08\u53EF\u9009\uFF09\uFF1A\u5305\u542B transcript \u65E5\u5FD7\uFF08\u5982\u679C\u6709\u7684\u8BDD\uFF09\uFF08\u9ED8\u8BA4\u503C: false\uFF09
|
|
40846
|
+
- limit\uFF08\u53EF\u9009\uFF09\uFF1A\u6700\u5927\u8FD4\u56DE\u6D88\u606F\u6570\u91CF\uFF08\u9ED8\u8BA4\u503C: \u5168\u90E8\uFF09
|
|
40854
40847
|
|
|
40855
|
-
|
|
40848
|
+
\u8F93\u51FA\u793A\u4F8B\uFF1A
|
|
40856
40849
|
Session: ses_abc123
|
|
40857
40850
|
Messages: 45
|
|
40858
40851
|
Date Range: 2025-12-20 to 2025-12-24
|
|
@@ -40862,18 +40855,18 @@ Hello, can you help me with...
|
|
|
40862
40855
|
|
|
40863
40856
|
[Message 2] assistant (2025-12-20 10:30:15)
|
|
40864
40857
|
Of course! Let me help you with...`;
|
|
40865
|
-
var SESSION_SEARCH_DESCRIPTION =
|
|
40858
|
+
var SESSION_SEARCH_DESCRIPTION = `\u5728 OpenCode session \u6D88\u606F\u4E2D\u641C\u7D22\u5185\u5BB9\u3002
|
|
40866
40859
|
|
|
40867
|
-
|
|
40860
|
+
\u5BF9 session \u6D88\u606F\u6267\u884C\u5168\u6587\u641C\u7D22\uFF0C\u8FD4\u56DE\u5339\u914D\u7684\u6458\u8981\u53CA\u4E0A\u4E0B\u6587\u3002
|
|
40868
40861
|
|
|
40869
|
-
|
|
40870
|
-
- query
|
|
40871
|
-
- session_id
|
|
40872
|
-
- case_sensitive
|
|
40873
|
-
- limit
|
|
40862
|
+
\u53C2\u6570\uFF1A
|
|
40863
|
+
- query\uFF08\u5FC5\u586B\uFF09\uFF1A\u641C\u7D22\u67E5\u8BE2\u5B57\u7B26\u4E32
|
|
40864
|
+
- session_id\uFF08\u53EF\u9009\uFF09\uFF1A\u4EC5\u5728\u6307\u5B9A session \u4E2D\u641C\u7D22\uFF08\u9ED8\u8BA4\u503C: \u5168\u90E8 session\uFF09
|
|
40865
|
+
- case_sensitive\uFF08\u53EF\u9009\uFF09\uFF1A\u533A\u5206\u5927\u5C0F\u5199\u641C\u7D22\uFF08\u9ED8\u8BA4\u503C: false\uFF09
|
|
40866
|
+
- limit\uFF08\u53EF\u9009\uFF09\uFF1A\u6700\u5927\u8FD4\u56DE\u7ED3\u679C\u6570\u91CF\uFF08\u9ED8\u8BA4\u503C: 20\uFF09
|
|
40874
40867
|
|
|
40875
|
-
|
|
40876
|
-
|
|
40868
|
+
\u8F93\u51FA\u793A\u4F8B\uFF1A
|
|
40869
|
+
\u5728 2 \u4E2A session \u4E2D\u627E\u5230 3 \u6761\u5339\u914D\uFF1A
|
|
40877
40870
|
|
|
40878
40871
|
[ses_abc123] Message msg_001 (user)
|
|
40879
40872
|
...implement the **session manager** tool...
|
|
@@ -40883,14 +40876,14 @@ Found 3 matches across 2 sessions:
|
|
|
40883
40876
|
|
|
40884
40877
|
[ses_def456] Message msg_012 (user)
|
|
40885
40878
|
...use the **session manager** to find...`;
|
|
40886
|
-
var SESSION_INFO_DESCRIPTION =
|
|
40879
|
+
var SESSION_INFO_DESCRIPTION = `\u83B7\u53D6 OpenCode session \u7684\u5143\u6570\u636E\u548C\u7EDF\u8BA1\u4FE1\u606F\u3002
|
|
40887
40880
|
|
|
40888
|
-
|
|
40881
|
+
\u8FD4\u56DE session \u7684\u8BE6\u7EC6\u4FE1\u606F\uFF0C\u5305\u62EC\u6D88\u606F\u6570\u91CF\u3001\u65E5\u671F\u8303\u56F4\u3001\u4F7F\u7528\u8FC7\u7684 agents \u548C\u53EF\u7528\u7684\u6570\u636E\u6E90\u3002
|
|
40889
40882
|
|
|
40890
|
-
|
|
40891
|
-
- session_id
|
|
40883
|
+
\u53C2\u6570\uFF1A
|
|
40884
|
+
- session_id\uFF08\u5FC5\u586B\uFF09\uFF1A\u8981\u67E5\u770B\u7684 Session ID
|
|
40892
40885
|
|
|
40893
|
-
|
|
40886
|
+
\u8F93\u51FA\u793A\u4F8B\uFF1A
|
|
40894
40887
|
Session ID: ses_abc123
|
|
40895
40888
|
Messages: 45
|
|
40896
40889
|
Date Range: 2025-12-20 10:30:00 to 2025-12-24 15:45:30
|
|
@@ -41562,11 +41555,11 @@ The Bash tool can execute these commands directly. Do NOT retry with interactive
|
|
|
41562
41555
|
}
|
|
41563
41556
|
});
|
|
41564
41557
|
// src/tools/skill/constants.ts
|
|
41565
|
-
var TOOL_DESCRIPTION_NO_SKILLS = "
|
|
41566
|
-
var TOOL_DESCRIPTION_PREFIX2 =
|
|
41558
|
+
var TOOL_DESCRIPTION_NO_SKILLS = "\u52A0\u8F7D skill \u4EE5\u83B7\u53D6\u7279\u5B9A\u4EFB\u52A1\u7684\u8BE6\u7EC6\u8BF4\u660E\u3002\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u7684 skills\u3002";
|
|
41559
|
+
var TOOL_DESCRIPTION_PREFIX2 = `\u52A0\u8F7D skill \u4EE5\u83B7\u53D6\u7279\u5B9A\u4EFB\u52A1\u7684\u8BE6\u7EC6\u8BF4\u660E\u3002
|
|
41567
41560
|
|
|
41568
|
-
Skills
|
|
41569
|
-
|
|
41561
|
+
Skills \u63D0\u4F9B\u4E13\u4E1A\u77E5\u8BC6\u548C\u5206\u6B65\u6307\u5BFC\u3002
|
|
41562
|
+
\u5F53\u4EFB\u52A1\u4E0E\u53EF\u7528 skill \u7684\u63CF\u8FF0\u76F8\u5339\u914D\u65F6\u4F7F\u7528\u6B64\u5DE5\u5177\u3002`;
|
|
41570
41563
|
// src/tools/skill/tools.ts
|
|
41571
41564
|
import { dirname as dirname13 } from "path";
|
|
41572
41565
|
function loadedSkillToInfo(skill) {
|
|
@@ -41738,7 +41731,7 @@ function createSkillTool(options = {}) {
|
|
|
41738
41731
|
}
|
|
41739
41732
|
var skill = createSkillTool();
|
|
41740
41733
|
// src/tools/skill-mcp/constants.ts
|
|
41741
|
-
var SKILL_MCP_DESCRIPTION =
|
|
41734
|
+
var SKILL_MCP_DESCRIPTION = `\u4ECE skill \u5D4C\u5165\u7684 MCP \u8C03\u7528 MCP server \u64CD\u4F5C\u3002\u9700\u8981 mcp_name \u5E76\u6070\u597D\u9009\u62E9\u4EE5\u4E0B\u4E4B\u4E00\uFF1Atool_name\u3001resource_name \u6216 prompt_name\u3002`;
|
|
41742
41735
|
// src/tools/skill-mcp/tools.ts
|
|
41743
41736
|
function validateOperationParams(args) {
|
|
41744
41737
|
const operations = [];
|
|
@@ -41886,25 +41879,12 @@ function createSkillMcpTool(options) {
|
|
|
41886
41879
|
});
|
|
41887
41880
|
}
|
|
41888
41881
|
// src/tools/background-task/constants.ts
|
|
41889
|
-
var BACKGROUND_OUTPUT_DESCRIPTION =
|
|
41890
|
-
var BACKGROUND_CANCEL_DESCRIPTION =
|
|
41882
|
+
var BACKGROUND_OUTPUT_DESCRIPTION = `\u83B7\u53D6\u540E\u53F0\u4EFB\u52A1\u7684\u8F93\u51FA\u3002\u7CFB\u7EDF\u5728\u4EFB\u52A1\u5B8C\u6210\u540E\u4F1A\u901A\u77E5\uFF0C\u56E0\u6B64 block=true \u5F88\u5C11\u9700\u8981\u3002`;
|
|
41883
|
+
var BACKGROUND_CANCEL_DESCRIPTION = `\u53D6\u6D88\u6B63\u5728\u8FD0\u884C\u7684\u540E\u53F0\u4EFB\u52A1\u3002\u4F7F\u7528 all=true \u53EF\u5728\u6700\u7EC8\u56DE\u7B54\u524D\u53D6\u6D88\u6240\u6709\u4EFB\u52A1\u3002`;
|
|
41891
41884
|
|
|
41892
41885
|
// src/tools/background-task/tools.ts
|
|
41893
41886
|
init_logger();
|
|
41894
41887
|
init_session_cursor();
|
|
41895
|
-
function formatDuration(start, end) {
|
|
41896
|
-
const duration3 = (end ?? new Date).getTime() - start.getTime();
|
|
41897
|
-
const seconds = Math.floor(duration3 / 1000);
|
|
41898
|
-
const minutes = Math.floor(seconds / 60);
|
|
41899
|
-
const hours = Math.floor(minutes / 60);
|
|
41900
|
-
if (hours > 0) {
|
|
41901
|
-
return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
|
|
41902
|
-
} else if (minutes > 0) {
|
|
41903
|
-
return `${minutes}m ${seconds % 60}s`;
|
|
41904
|
-
} else {
|
|
41905
|
-
return `${seconds}s`;
|
|
41906
|
-
}
|
|
41907
|
-
}
|
|
41908
41888
|
function delay(ms) {
|
|
41909
41889
|
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
41910
41890
|
}
|
|
@@ -41916,9 +41896,9 @@ function truncateText(text, maxLength) {
|
|
|
41916
41896
|
function formatTaskStatus(task) {
|
|
41917
41897
|
let duration3;
|
|
41918
41898
|
if (task.status === "pending" && task.queuedAt) {
|
|
41919
|
-
duration3 = formatDuration(task.queuedAt, undefined);
|
|
41899
|
+
duration3 = PerfTimer.formatDuration(task.queuedAt, undefined);
|
|
41920
41900
|
} else if (task.startedAt) {
|
|
41921
|
-
duration3 = formatDuration(task.startedAt, task.completedAt);
|
|
41901
|
+
duration3 = PerfTimer.formatDuration(task.startedAt, task.completedAt);
|
|
41922
41902
|
} else {
|
|
41923
41903
|
duration3 = "N/A";
|
|
41924
41904
|
}
|
|
@@ -41955,6 +41935,18 @@ ${truncated}
|
|
|
41955
41935
|
> **Failed**: The task encountered an error. Check the last message for details.`;
|
|
41956
41936
|
}
|
|
41957
41937
|
const durationLabel = task.status === "pending" ? "Queued for" : "Duration";
|
|
41938
|
+
let perfBlock = "";
|
|
41939
|
+
if (task.progress?.phaseTiming) {
|
|
41940
|
+
const pt = task.progress.phaseTiming;
|
|
41941
|
+
const queueWait = PerfTimer.formatDuration(new Date(0), new Date(pt.queueWaitMs));
|
|
41942
|
+
perfBlock = `
|
|
41943
|
+
|
|
41944
|
+
### Performance
|
|
41945
|
+
| Metric | Value |
|
|
41946
|
+
|--------|-------|
|
|
41947
|
+
| Queue wait | ${queueWait} |
|
|
41948
|
+
| Tool calls | ${pt.toolCallCount} |`;
|
|
41949
|
+
}
|
|
41958
41950
|
return `# Task Status
|
|
41959
41951
|
|
|
41960
41952
|
| Field | Value |
|
|
@@ -41970,7 +41962,8 @@ ${statusNote}
|
|
|
41970
41962
|
|
|
41971
41963
|
\`\`\`
|
|
41972
41964
|
${promptPreview}
|
|
41973
|
-
\`\`\`${lastMessageSection}
|
|
41965
|
+
\`\`\`${lastMessageSection}${perfBlock}
|
|
41966
|
+
}`;
|
|
41974
41967
|
}
|
|
41975
41968
|
async function formatTaskResult(task, client2) {
|
|
41976
41969
|
if (!task.sessionID) {
|
|
@@ -41984,12 +41977,25 @@ async function formatTaskResult(task, client2) {
|
|
|
41984
41977
|
}
|
|
41985
41978
|
const messages = messagesResult.data ?? messagesResult;
|
|
41986
41979
|
if (!Array.isArray(messages) || messages.length === 0) {
|
|
41980
|
+
const duration4 = PerfTimer.formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
41981
|
+
let perfBlock2 = "";
|
|
41982
|
+
if (task.progress?.phaseTiming) {
|
|
41983
|
+
const pt = task.progress.phaseTiming;
|
|
41984
|
+
const queueWait = PerfTimer.formatDuration(new Date(0), new Date(pt.queueWaitMs));
|
|
41985
|
+
perfBlock2 = `
|
|
41986
|
+
|
|
41987
|
+
### Performance
|
|
41988
|
+
| Metric | Value |
|
|
41989
|
+
|--------|-------|
|
|
41990
|
+
| Queue wait | ${queueWait} |
|
|
41991
|
+
| Tool calls | ${pt.toolCallCount} |`;
|
|
41992
|
+
}
|
|
41987
41993
|
return `Task Result
|
|
41988
41994
|
|
|
41989
41995
|
Task ID: ${task.id}
|
|
41990
41996
|
Description: ${task.description}
|
|
41991
|
-
Duration: ${
|
|
41992
|
-
Session ID: ${task.sessionID}
|
|
41997
|
+
Duration: ${duration4}
|
|
41998
|
+
Session ID: ${task.sessionID}${perfBlock2}
|
|
41993
41999
|
|
|
41994
42000
|
---
|
|
41995
42001
|
|
|
@@ -41997,12 +42003,25 @@ Session ID: ${task.sessionID}
|
|
|
41997
42003
|
}
|
|
41998
42004
|
const relevantMessages = messages.filter((m) => m.info?.role === "assistant" || m.info?.role === "tool");
|
|
41999
42005
|
if (relevantMessages.length === 0) {
|
|
42006
|
+
const duration4 = PerfTimer.formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
42007
|
+
let perfBlock2 = "";
|
|
42008
|
+
if (task.progress?.phaseTiming) {
|
|
42009
|
+
const pt = task.progress.phaseTiming;
|
|
42010
|
+
const queueWait = PerfTimer.formatDuration(new Date(0), new Date(pt.queueWaitMs));
|
|
42011
|
+
perfBlock2 = `
|
|
42012
|
+
|
|
42013
|
+
### Performance
|
|
42014
|
+
| Metric | Value |
|
|
42015
|
+
|--------|-------|
|
|
42016
|
+
| Queue wait | ${queueWait} |
|
|
42017
|
+
| Tool calls | ${pt.toolCallCount} |`;
|
|
42018
|
+
}
|
|
42000
42019
|
return `Task Result
|
|
42001
42020
|
|
|
42002
42021
|
Task ID: ${task.id}
|
|
42003
42022
|
Description: ${task.description}
|
|
42004
|
-
Duration: ${
|
|
42005
|
-
Session ID: ${task.sessionID}
|
|
42023
|
+
Duration: ${duration4}
|
|
42024
|
+
Session ID: ${task.sessionID}${perfBlock2}
|
|
42006
42025
|
|
|
42007
42026
|
---
|
|
42008
42027
|
|
|
@@ -42015,13 +42034,25 @@ Session ID: ${task.sessionID}
|
|
|
42015
42034
|
});
|
|
42016
42035
|
const newMessages = consumeNewMessages(task.sessionID, sortedMessages);
|
|
42017
42036
|
if (newMessages.length === 0) {
|
|
42018
|
-
const duration4 = formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
42037
|
+
const duration4 = PerfTimer.formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
42038
|
+
let perfBlock2 = "";
|
|
42039
|
+
if (task.progress?.phaseTiming) {
|
|
42040
|
+
const pt = task.progress.phaseTiming;
|
|
42041
|
+
const queueWait = PerfTimer.formatDuration(new Date(0), new Date(pt.queueWaitMs));
|
|
42042
|
+
perfBlock2 = `
|
|
42043
|
+
|
|
42044
|
+
### Performance
|
|
42045
|
+
| Metric | Value |
|
|
42046
|
+
|--------|-------|
|
|
42047
|
+
| Queue wait | ${queueWait} |
|
|
42048
|
+
| Tool calls | ${pt.toolCallCount} |`;
|
|
42049
|
+
}
|
|
42019
42050
|
return `Task Result
|
|
42020
42051
|
|
|
42021
42052
|
Task ID: ${task.id}
|
|
42022
42053
|
Description: ${task.description}
|
|
42023
42054
|
Duration: ${duration4}
|
|
42024
|
-
Session ID: ${task.sessionID}
|
|
42055
|
+
Session ID: ${task.sessionID}${perfBlock2}
|
|
42025
42056
|
|
|
42026
42057
|
---
|
|
42027
42058
|
|
|
@@ -42049,13 +42080,25 @@ Session ID: ${task.sessionID}
|
|
|
42049
42080
|
const textContent = extractedContent.filter((text) => text.length > 0).join(`
|
|
42050
42081
|
|
|
42051
42082
|
`);
|
|
42052
|
-
const duration3 = formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
42083
|
+
const duration3 = PerfTimer.formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
42084
|
+
let perfBlock = "";
|
|
42085
|
+
if (task.progress?.phaseTiming) {
|
|
42086
|
+
const pt = task.progress.phaseTiming;
|
|
42087
|
+
const queueWait = PerfTimer.formatDuration(new Date(0), new Date(pt.queueWaitMs));
|
|
42088
|
+
perfBlock = `
|
|
42089
|
+
|
|
42090
|
+
### Performance
|
|
42091
|
+
| Metric | Value |
|
|
42092
|
+
|--------|-------|
|
|
42093
|
+
| Queue wait | ${queueWait} |
|
|
42094
|
+
| Tool calls | ${pt.toolCallCount} |`;
|
|
42095
|
+
}
|
|
42053
42096
|
return `Task Result
|
|
42054
42097
|
|
|
42055
42098
|
Task ID: ${task.id}
|
|
42056
42099
|
Description: ${task.description}
|
|
42057
42100
|
Duration: ${duration3}
|
|
42058
|
-
Session ID: ${task.sessionID}
|
|
42101
|
+
Session ID: ${task.sessionID}${perfBlock}
|
|
42059
42102
|
|
|
42060
42103
|
---
|
|
42061
42104
|
|
|
@@ -42217,11 +42260,11 @@ Status: ${task.status}`;
|
|
|
42217
42260
|
}
|
|
42218
42261
|
// src/tools/call-omo-agent/constants.ts
|
|
42219
42262
|
var ALLOWED_AGENTS = ["explore", "librarian"];
|
|
42220
|
-
var CALL_OMO_AGENT_DESCRIPTION =
|
|
42263
|
+
var CALL_OMO_AGENT_DESCRIPTION = `\u542F\u52A8 explore/librarian agent\u3002run_in_background \u5FC5\u586B\uFF08true=\u5F02\u6B65\u8FD4\u56DE task_id\uFF0Cfalse=\u540C\u6B65\uFF09\u3002
|
|
42221
42264
|
|
|
42222
|
-
|
|
42265
|
+
\u53EF\u7528\u7684 agent\uFF1A{agents}
|
|
42223
42266
|
|
|
42224
|
-
|
|
42267
|
+
\u4F20\u5165 \`session_id=<id>\` \u53EF\u7EE7\u7EED\u4E4B\u524D\u7684 agent\uFF0C\u4FDD\u7559\u5B8C\u6574\u4E0A\u4E0B\u6587\u3002Prompts \u5FC5\u987B\u4E3A\u4E2D\u6587\u3002\u4F7F\u7528 \`background_output\` \u83B7\u53D6\u5F02\u6B65\u7ED3\u679C\u3002`;
|
|
42225
42268
|
// src/tools/call-omo-agent/tools.ts
|
|
42226
42269
|
import { existsSync as existsSync44, readdirSync as readdirSync14 } from "fs";
|
|
42227
42270
|
import { join as join53 } from "path";
|
|
@@ -42241,29 +42284,29 @@ function getMessageDir8(sessionID) {
|
|
|
42241
42284
|
return null;
|
|
42242
42285
|
}
|
|
42243
42286
|
function createCallOmoAgent(ctx, backgroundManager) {
|
|
42244
|
-
const agentDescriptions = ALLOWED_AGENTS.map((name) => `- ${name}
|
|
42287
|
+
const agentDescriptions = ALLOWED_AGENTS.map((name) => `- ${name}\uFF1A\u4E13\u95E8\u5904\u7406 ${name} \u4EFB\u52A1\u7684 agent`).join(`
|
|
42245
42288
|
`);
|
|
42246
42289
|
const description = CALL_OMO_AGENT_DESCRIPTION.replace("{agents}", agentDescriptions);
|
|
42247
42290
|
return tool({
|
|
42248
42291
|
description,
|
|
42249
42292
|
args: {
|
|
42250
|
-
description: tool.schema.string().describe("
|
|
42251
|
-
prompt: tool.schema.string().describe("
|
|
42252
|
-
subagent_type: tool.schema.string().describe("
|
|
42253
|
-
run_in_background: tool.schema.boolean().describe("
|
|
42254
|
-
session_id: tool.schema.string().describe("
|
|
42293
|
+
description: tool.schema.string().describe("\u4EFB\u52A1\u7684\u7B80\u77ED\u63CF\u8FF0\uFF083-5 \u4E2A\u8BCD\uFF09"),
|
|
42294
|
+
prompt: tool.schema.string().describe("agent \u9700\u8981\u6267\u884C\u7684\u4EFB\u52A1"),
|
|
42295
|
+
subagent_type: tool.schema.string().describe("\u6B64\u4EFB\u52A1\u4F7F\u7528\u7684\u4E13\u4E1A agent \u7C7B\u578B\uFF08\u4EC5\u652F\u6301 explore \u6216 librarian\uFF09"),
|
|
42296
|
+
run_in_background: tool.schema.boolean().describe("\u5FC5\u586B\u3002true\uFF1A\u5F02\u6B65\u8FD0\u884C\uFF08\u4F7F\u7528 background_output \u83B7\u53D6\u7ED3\u679C\uFF09\uFF0Cfalse\uFF1A\u540C\u6B65\u8FD0\u884C\u5E76\u7B49\u5F85\u5B8C\u6210"),
|
|
42297
|
+
session_id: tool.schema.string().describe("\u8981\u7EE7\u7EED\u7684\u73B0\u6709 Task session").optional()
|
|
42255
42298
|
},
|
|
42256
42299
|
async execute(args, toolContext) {
|
|
42257
42300
|
const toolCtx = toolContext;
|
|
42258
42301
|
log(`[call_omo_agent] Starting with agent: ${args.subagent_type}, background: ${args.run_in_background}`);
|
|
42259
42302
|
if (!includesCaseInsensitive([...ALLOWED_AGENTS], args.subagent_type)) {
|
|
42260
|
-
return
|
|
42303
|
+
return `\u9519\u8BEF\uFF1A\u65E0\u6548\u7684 agent \u7C7B\u578B"${args.subagent_type}"\u3002\u4EC5\u5141\u8BB8 ${ALLOWED_AGENTS.join("\u3001")}\u3002`;
|
|
42261
42304
|
}
|
|
42262
42305
|
const normalizedAgent = args.subagent_type.toLowerCase();
|
|
42263
42306
|
args = { ...args, subagent_type: normalizedAgent };
|
|
42264
42307
|
if (args.run_in_background) {
|
|
42265
42308
|
if (args.session_id) {
|
|
42266
|
-
return
|
|
42309
|
+
return `\u9519\u8BEF\uFF1A\u540E\u53F0\u6A21\u5F0F\u4E0D\u652F\u6301 session_id\u3002\u8BF7\u4F7F\u7528 run_in_background=false \u7EE7\u7EED\u73B0\u6709 session\u3002`;
|
|
42267
42310
|
}
|
|
42268
42311
|
return await executeBackground(args, toolCtx, backgroundManager);
|
|
42269
42312
|
}
|
|
@@ -42299,7 +42342,7 @@ async function executeBackground(args, toolContext, manager) {
|
|
|
42299
42342
|
title: args.description,
|
|
42300
42343
|
metadata: { sessionId: task.sessionID }
|
|
42301
42344
|
});
|
|
42302
|
-
return
|
|
42345
|
+
return `\u540E\u53F0 agent \u4EFB\u52A1\u5DF2\u6210\u529F\u542F\u52A8\u3002
|
|
42303
42346
|
|
|
42304
42347
|
Task ID: ${task.id}
|
|
42305
42348
|
Session ID: ${task.sessionID}
|
|
@@ -42307,13 +42350,13 @@ Description: ${task.description}
|
|
|
42307
42350
|
Agent: ${task.agent} (subagent)
|
|
42308
42351
|
Status: ${task.status}
|
|
42309
42352
|
|
|
42310
|
-
|
|
42311
|
-
|
|
42312
|
-
- block=false
|
|
42313
|
-
- block=true
|
|
42353
|
+
\u4EFB\u52A1\u5B8C\u6210\u540E\u7CFB\u7EDF\u4F1A\u901A\u77E5\u4F60\u3002
|
|
42354
|
+
\u4F7F\u7528 \`background_output\` \u5DE5\u5177\u5E76\u4F20\u5165 task_id="${task.id}" \u6765\u67E5\u770B\u8FDB\u5EA6\uFF1A
|
|
42355
|
+
- block=false\uFF08\u9ED8\u8BA4\uFF09\uFF1A\u7ACB\u5373\u68C0\u67E5\u72B6\u6001 \u2014 \u8FD4\u56DE\u5B8C\u6574\u7684\u8FDB\u5EA6\u4FE1\u606F
|
|
42356
|
+
- block=true\uFF1A\u7B49\u5F85\u5B8C\u6210\uFF08\u7531\u4E8E\u7CFB\u7EDF\u4F1A\u81EA\u52A8\u901A\u77E5\uFF0C\u901A\u5E38\u4E0D\u9700\u8981\uFF09`;
|
|
42314
42357
|
} catch (error45) {
|
|
42315
42358
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
42316
|
-
return
|
|
42359
|
+
return `\u542F\u52A8\u540E\u53F0 agent \u4EFB\u52A1\u5931\u8D25\uFF1A${message}`;
|
|
42317
42360
|
}
|
|
42318
42361
|
}
|
|
42319
42362
|
async function executeSync(args, toolContext, ctx) {
|
|
@@ -42325,7 +42368,7 @@ async function executeSync(args, toolContext, ctx) {
|
|
|
42325
42368
|
});
|
|
42326
42369
|
if (sessionResult.error) {
|
|
42327
42370
|
log(`[call_omo_agent] Session get error:`, sessionResult.error);
|
|
42328
|
-
return
|
|
42371
|
+
return `\u9519\u8BEF\uFF1A\u83B7\u53D6\u73B0\u6709 session \u5931\u8D25\uFF1A${sessionResult.error}`;
|
|
42329
42372
|
}
|
|
42330
42373
|
sessionID = args.session_id;
|
|
42331
42374
|
} else {
|
|
@@ -42349,7 +42392,7 @@ async function executeSync(args, toolContext, ctx) {
|
|
|
42349
42392
|
});
|
|
42350
42393
|
if (createResult.error) {
|
|
42351
42394
|
log(`[call_omo_agent] Session create error:`, createResult.error);
|
|
42352
|
-
return
|
|
42395
|
+
return `\u9519\u8BEF\uFF1A\u521B\u5EFA session \u5931\u8D25\uFF1A${createResult.error}`;
|
|
42353
42396
|
}
|
|
42354
42397
|
sessionID = createResult.data.id;
|
|
42355
42398
|
log(`[call_omo_agent] Created session: ${sessionID}`);
|
|
@@ -42377,13 +42420,13 @@ async function executeSync(args, toolContext, ctx) {
|
|
|
42377
42420
|
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
42378
42421
|
log(`[call_omo_agent] Prompt error:`, errorMessage);
|
|
42379
42422
|
if (errorMessage.includes("agent.name") || errorMessage.includes("undefined")) {
|
|
42380
|
-
return
|
|
42423
|
+
return `\u9519\u8BEF\uFF1AAgent "${args.subagent_type}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8BE5 agent \u5DF2\u5728 opencode.json \u4E2D\u6CE8\u518C\u6216\u7531\u63D2\u4EF6\u63D0\u4F9B\u3002
|
|
42381
42424
|
|
|
42382
42425
|
<task_metadata>
|
|
42383
42426
|
session_id: ${sessionID}
|
|
42384
42427
|
</task_metadata>`;
|
|
42385
42428
|
}
|
|
42386
|
-
return
|
|
42429
|
+
return `\u9519\u8BEF\uFF1A\u53D1\u9001 prompt \u5931\u8D25\uFF1A${errorMessage}
|
|
42387
42430
|
|
|
42388
42431
|
<task_metadata>
|
|
42389
42432
|
session_id: ${sessionID}
|
|
@@ -42399,7 +42442,7 @@ session_id: ${sessionID}
|
|
|
42399
42442
|
while (Date.now() - pollStart < MAX_POLL_TIME_MS) {
|
|
42400
42443
|
if (toolContext.abort?.aborted) {
|
|
42401
42444
|
log(`[call_omo_agent] Aborted by user`);
|
|
42402
|
-
return
|
|
42445
|
+
return `\u4EFB\u52A1\u5DF2\u4E2D\u6B62\u3002
|
|
42403
42446
|
|
|
42404
42447
|
<task_metadata>
|
|
42405
42448
|
session_id: ${sessionID}
|
|
@@ -42430,7 +42473,7 @@ session_id: ${sessionID}
|
|
|
42430
42473
|
}
|
|
42431
42474
|
if (Date.now() - pollStart >= MAX_POLL_TIME_MS) {
|
|
42432
42475
|
log(`[call_omo_agent] Timeout reached`);
|
|
42433
|
-
return
|
|
42476
|
+
return `\u9519\u8BEF\uFF1AAgent \u4EFB\u52A1\u5728 5 \u5206\u949F\u540E\u8D85\u65F6\u3002
|
|
42434
42477
|
|
|
42435
42478
|
<task_metadata>
|
|
42436
42479
|
session_id: ${sessionID}
|
|
@@ -42441,7 +42484,7 @@ session_id: ${sessionID}
|
|
|
42441
42484
|
});
|
|
42442
42485
|
if (messagesResult.error) {
|
|
42443
42486
|
log(`[call_omo_agent] Messages error:`, messagesResult.error);
|
|
42444
|
-
return
|
|
42487
|
+
return `\u9519\u8BEF\uFF1A\u83B7\u53D6\u6D88\u606F\u5931\u8D25\uFF1A${messagesResult.error}`;
|
|
42445
42488
|
}
|
|
42446
42489
|
const messages = messagesResult.data;
|
|
42447
42490
|
log(`[call_omo_agent] Got ${messages.length} messages`);
|
|
@@ -42449,7 +42492,7 @@ session_id: ${sessionID}
|
|
|
42449
42492
|
if (relevantMessages.length === 0) {
|
|
42450
42493
|
log(`[call_omo_agent] No assistant or tool messages found`);
|
|
42451
42494
|
log(`[call_omo_agent] All messages:`, JSON.stringify(messages, null, 2));
|
|
42452
|
-
return
|
|
42495
|
+
return `\u9519\u8BEF\uFF1A\u672A\u627E\u5230 assistant \u6216 tool \u7684\u54CD\u5E94
|
|
42453
42496
|
|
|
42454
42497
|
<task_metadata>
|
|
42455
42498
|
session_id: ${sessionID}
|
|
@@ -42463,7 +42506,7 @@ session_id: ${sessionID}
|
|
|
42463
42506
|
});
|
|
42464
42507
|
const newMessages = consumeNewMessages(sessionID, sortedMessages);
|
|
42465
42508
|
if (newMessages.length === 0) {
|
|
42466
|
-
return
|
|
42509
|
+
return `\u81EA\u4E0A\u6B21\u68C0\u67E5\u4EE5\u6765\u65E0\u65B0\u8F93\u51FA\u3002
|
|
42467
42510
|
|
|
42468
42511
|
<task_metadata>
|
|
42469
42512
|
session_id: ${sessionID}
|
|
@@ -42691,14 +42734,7 @@ class TaskToastManager {
|
|
|
42691
42734
|
return Array.from(this.tasks.values()).filter((t) => t.status === "queued").sort((a, b) => a.startedAt.getTime() - b.startedAt.getTime());
|
|
42692
42735
|
}
|
|
42693
42736
|
formatDuration(startedAt) {
|
|
42694
|
-
|
|
42695
|
-
if (seconds < 60)
|
|
42696
|
-
return `${seconds}s`;
|
|
42697
|
-
const minutes = Math.floor(seconds / 60);
|
|
42698
|
-
if (minutes < 60)
|
|
42699
|
-
return `${minutes}m ${seconds % 60}s`;
|
|
42700
|
-
const hours = Math.floor(minutes / 60);
|
|
42701
|
-
return `${hours}h ${minutes % 60}m`;
|
|
42737
|
+
return PerfTimer.formatDuration(startedAt, undefined, { precision: "compact" });
|
|
42702
42738
|
}
|
|
42703
42739
|
getConcurrencyInfo() {
|
|
42704
42740
|
if (!this.concurrencyManager)
|
|
@@ -42802,9 +42838,6 @@ function initTaskToastManager(client2, concurrencyManager) {
|
|
|
42802
42838
|
}
|
|
42803
42839
|
// src/tools/delegate-task/tools.ts
|
|
42804
42840
|
init_shared();
|
|
42805
|
-
init_model_availability();
|
|
42806
|
-
init_model_resolver();
|
|
42807
|
-
init_model_requirements();
|
|
42808
42841
|
var SISYPHUS_JUNIOR_AGENT = "sisyphus-junior";
|
|
42809
42842
|
function parseModelString(model) {
|
|
42810
42843
|
const parts = model.split("/");
|
|
@@ -42826,24 +42859,13 @@ function getMessageDir9(sessionID) {
|
|
|
42826
42859
|
}
|
|
42827
42860
|
return null;
|
|
42828
42861
|
}
|
|
42829
|
-
function formatDuration2(start, end) {
|
|
42830
|
-
const duration3 = (end ?? new Date).getTime() - start.getTime();
|
|
42831
|
-
const seconds = Math.floor(duration3 / 1000);
|
|
42832
|
-
const minutes = Math.floor(seconds / 60);
|
|
42833
|
-
const hours = Math.floor(minutes / 60);
|
|
42834
|
-
if (hours > 0)
|
|
42835
|
-
return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
|
|
42836
|
-
if (minutes > 0)
|
|
42837
|
-
return `${minutes}m ${seconds % 60}s`;
|
|
42838
|
-
return `${seconds}s`;
|
|
42839
|
-
}
|
|
42840
42862
|
function formatDetailedError(error45, ctx) {
|
|
42841
42863
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
42842
42864
|
const stack = error45 instanceof Error ? error45.stack : undefined;
|
|
42843
42865
|
const lines = [
|
|
42844
|
-
`${ctx.operation}
|
|
42866
|
+
`${ctx.operation} \u5931\u8D25`,
|
|
42845
42867
|
"",
|
|
42846
|
-
|
|
42868
|
+
`**\u9519\u8BEF**: ${message}`
|
|
42847
42869
|
];
|
|
42848
42870
|
if (ctx.sessionID) {
|
|
42849
42871
|
lines.push(`**Session ID**: ${ctx.sessionID}`);
|
|
@@ -42852,10 +42874,10 @@ function formatDetailedError(error45, ctx) {
|
|
|
42852
42874
|
lines.push(`**Agent**: ${ctx.agent}${ctx.category ? ` (category: ${ctx.category})` : ""}`);
|
|
42853
42875
|
}
|
|
42854
42876
|
if (ctx.args) {
|
|
42855
|
-
lines.push("", "
|
|
42877
|
+
lines.push("", "**\u53C2\u6570**:");
|
|
42856
42878
|
lines.push(`- description: "${ctx.args.description}"`);
|
|
42857
|
-
lines.push(`- category: ${ctx.args.category ?? "(
|
|
42858
|
-
lines.push(`- subagent_type: ${ctx.args.subagent_type ?? "(
|
|
42879
|
+
lines.push(`- category: ${ctx.args.category ?? "(\u65E0)"}`);
|
|
42880
|
+
lines.push(`- subagent_type: ${ctx.args.subagent_type ?? "(\u65E0)"}`);
|
|
42859
42881
|
lines.push(`- run_in_background: ${ctx.args.run_in_background}`);
|
|
42860
42882
|
lines.push(`- load_skills: [${ctx.args.load_skills?.join(", ") ?? ""}]`);
|
|
42861
42883
|
if (ctx.args.session_id) {
|
|
@@ -42863,7 +42885,7 @@ function formatDetailedError(error45, ctx) {
|
|
|
42863
42885
|
}
|
|
42864
42886
|
}
|
|
42865
42887
|
if (stack) {
|
|
42866
|
-
lines.push("", "
|
|
42888
|
+
lines.push("", "**\u5806\u6808\u8DDF\u8E2A**:");
|
|
42867
42889
|
lines.push("```");
|
|
42868
42890
|
lines.push(stack.split(`
|
|
42869
42891
|
`).slice(0, 10).join(`
|
|
@@ -42924,47 +42946,47 @@ function createDelegateTask(options) {
|
|
|
42924
42946
|
return desc ? ` - ${name}: ${desc}` : ` - ${name}`;
|
|
42925
42947
|
}).join(`
|
|
42926
42948
|
`);
|
|
42927
|
-
const description =
|
|
42949
|
+
const description = `\u542F\u52A8\u5E26\u6709\u5206\u7C7B\u6216\u76F4\u63A5\u6307\u5B9A agent \u7684\u4EFB\u52A1\u3002
|
|
42928
42950
|
|
|
42929
|
-
|
|
42951
|
+
\u4E92\u65A5\u53C2\u6570\uFF1A\u63D0\u4F9B category \u6216 subagent_type \u4E4B\u4E00\uFF0C\u4E24\u8005\u4E0D\u53EF\u540C\u65F6\u63D0\u4F9B\uFF08\u7EE7\u7EED session \u65F6\u9664\u5916\uFF09\u3002
|
|
42930
42952
|
|
|
42931
|
-
- load_skills:
|
|
42932
|
-
- category:
|
|
42933
|
-
|
|
42953
|
+
- load_skills: \u59CB\u7EC8\u5FC5\u586B\u3002\u4F20\u5165\u81F3\u5C11\u4E00\u4E2A skill \u540D\u79F0\uFF08\u4F8B\u5982 ["playwright"]\u3001["git-master", "frontend-ui-ux"]\uFF09\u3002
|
|
42954
|
+
- category: \u4F7F\u7528\u9884\u5B9A\u4E49\u5206\u7C7B \u2192 \u4F7F\u7528\u5206\u7C7B\u914D\u7F6E\u542F\u52A8 Sisyphus-Junior
|
|
42955
|
+
\u53EF\u7528\u5206\u7C7B\uFF1A
|
|
42934
42956
|
${categoryList}
|
|
42935
|
-
- subagent_type:
|
|
42936
|
-
- run_in_background: true
|
|
42937
|
-
- session_id:
|
|
42938
|
-
- command:
|
|
42957
|
+
- subagent_type: \u76F4\u63A5\u4F7F\u7528\u6307\u5B9A\u7684 agent\uFF08\u4F8B\u5982 "oracle"\u3001"explore"\uFF09
|
|
42958
|
+
- run_in_background: true=\u5F02\u6B65\uFF08\u8FD4\u56DE task_id\uFF09\uFF0Cfalse=\u540C\u6B65\uFF08\u7B49\u5F85\u7ED3\u679C\uFF09\u3002\u9ED8\u8BA4\u503C: false\u3002\u4EC5\u5728\u5E76\u884C\u63A2\u7D22 5+ \u4E2A\u72EC\u7ACB\u67E5\u8BE2\u65F6\u4F7F\u7528 background=true\u3002
|
|
42959
|
+
- session_id: \u8981\u7EE7\u7EED\u7684\u73B0\u6709 Task session\uFF08\u6765\u81EA\u4E4B\u524D\u4EFB\u52A1\u7684\u8F93\u51FA\uFF09\u3002\u7EE7\u7EED\u540E\u4FDD\u7559\u5B8C\u6574\u4E0A\u4E0B\u6587 \u2014 \u8282\u7701 token\uFF0C\u4FDD\u6301\u8FDE\u7EED\u6027\u3002
|
|
42960
|
+
- command: \u89E6\u53D1\u6B64\u4EFB\u52A1\u7684\u547D\u4EE4\uFF08\u53EF\u9009\uFF0C\u7528\u4E8E\u659C\u6760\u547D\u4EE4\u8FFD\u8E2A\uFF09\u3002
|
|
42939
42961
|
|
|
42940
|
-
|
|
42941
|
-
-
|
|
42942
|
-
-
|
|
42943
|
-
-
|
|
42962
|
+
**\u4F55\u65F6\u4F7F\u7528 session_id\uFF1A**
|
|
42963
|
+
- \u4EFB\u52A1\u5931\u8D25/\u672A\u5B8C\u6210 \u2192 \u4F7F\u7528 session_id \u914D\u5408 "fix: [\u5177\u4F53\u95EE\u9898]"
|
|
42964
|
+
- \u9700\u8981\u5728\u4E4B\u524D\u7ED3\u679C\u4E0A\u7EE7\u7EED \u2192 \u4F7F\u7528 session_id \u8FFD\u52A0\u95EE\u9898
|
|
42965
|
+
- \u4E0E\u540C\u4E00 agent \u591A\u8F6E\u5BF9\u8BDD \u2192 \u59CB\u7EC8\u4F7F\u7528 session_id \u800C\u975E\u65B0\u5EFA\u4EFB\u52A1
|
|
42944
42966
|
|
|
42945
|
-
Prompts
|
|
42967
|
+
Prompts \u5FC5\u987B\u4E3A\u4E2D\u6587\u3002`;
|
|
42946
42968
|
return tool({
|
|
42947
42969
|
description,
|
|
42948
42970
|
args: {
|
|
42949
|
-
load_skills: tool.schema.array(tool.schema.string()).describe('Skill
|
|
42950
|
-
description: tool.schema.string().describe("
|
|
42951
|
-
prompt: tool.schema.string().describe("
|
|
42952
|
-
run_in_background: tool.schema.boolean().describe("true
|
|
42953
|
-
category: tool.schema.string().optional().describe(
|
|
42954
|
-
subagent_type: tool.schema.string().optional().describe("Agent
|
|
42955
|
-
session_id: tool.schema.string().optional().describe("
|
|
42956
|
-
command: tool.schema.string().optional().describe("
|
|
42971
|
+
load_skills: tool.schema.array(tool.schema.string()).describe('\u8981\u6CE8\u5165\u7684 Skill \u540D\u79F0\u3002\u5FC5\u586B \u2014 \u5982\u65E0\u9700 skills \u4F20\u5165 []\uFF0C\u4F46\u5F3A\u70C8\u5EFA\u8BAE\u4F20\u5165\u6B63\u786E\u7684 skills \u5982 ["playwright"]\u3001["git-master"] \u4EE5\u83B7\u5F97\u6700\u4F73\u6548\u679C\u3002'),
|
|
42972
|
+
description: tool.schema.string().describe("\u4EFB\u52A1\u7B80\u77ED\u63CF\u8FF0\uFF083-5 \u4E2A\u8BCD\uFF09"),
|
|
42973
|
+
prompt: tool.schema.string().describe("agent \u7684\u5B8C\u6574\u8BE6\u7EC6 prompt"),
|
|
42974
|
+
run_in_background: tool.schema.boolean().describe("true=\u5F02\u6B65\uFF08\u8FD4\u56DE task_id\uFF09\uFF0Cfalse=\u540C\u6B65\uFF08\u7B49\u5F85\uFF09\u3002\u9ED8\u8BA4\u503C: false"),
|
|
42975
|
+
category: tool.schema.string().optional().describe(`\u5206\u7C7B\uFF08\u4F8B\u5982 ${categoryExamples}\uFF09\u3002\u4E0E subagent_type \u4E92\u65A5\u3002`),
|
|
42976
|
+
subagent_type: tool.schema.string().optional().describe("Agent \u540D\u79F0\uFF08\u4F8B\u5982 'oracle'\u3001'explore'\uFF09\u3002\u4E0E category \u4E92\u65A5\u3002"),
|
|
42977
|
+
session_id: tool.schema.string().optional().describe("\u8981\u7EE7\u7EED\u7684\u73B0\u6709 Task session"),
|
|
42978
|
+
command: tool.schema.string().optional().describe("\u89E6\u53D1\u6B64\u4EFB\u52A1\u7684\u547D\u4EE4")
|
|
42957
42979
|
},
|
|
42958
42980
|
async execute(args, toolContext) {
|
|
42959
42981
|
const ctx = toolContext;
|
|
42960
42982
|
if (args.run_in_background === undefined) {
|
|
42961
|
-
throw new Error(
|
|
42983
|
+
throw new Error(`\u53C2\u6570\u9519\u8BEF\uFF1A'run_in_background' \u53C2\u6570\u5FC5\u586B\u3002\u4EFB\u52A1\u59D4\u6258\u4F7F\u7528 run_in_background=false\uFF0C\u4EC5\u5728\u5E76\u884C\u63A2\u7D22\u65F6\u4F7F\u7528 run_in_background=true\u3002`);
|
|
42962
42984
|
}
|
|
42963
42985
|
if (args.load_skills === undefined) {
|
|
42964
|
-
throw new Error(
|
|
42986
|
+
throw new Error(`\u53C2\u6570\u9519\u8BEF\uFF1A'load_skills' \u53C2\u6570\u5FC5\u586B\u3002\u5982\u65E0\u9700 skills \u4F20\u5165 []\uFF0C\u4F46\u5F3A\u70C8\u5EFA\u8BAE\u4F20\u5165\u6B63\u786E\u7684 skills \u5982 ["playwright"]\u3001["git-master"] \u4EE5\u83B7\u5F97\u6700\u4F73\u6548\u679C\u3002`);
|
|
42965
42987
|
}
|
|
42966
42988
|
if (args.load_skills === null) {
|
|
42967
|
-
throw new Error(
|
|
42989
|
+
throw new Error(`\u53C2\u6570\u9519\u8BEF\uFF1A\u4E0D\u5141\u8BB8 load_skills=null\u3002\u5982\u65E0\u9700 skills \u4F20\u5165 []\uFF0C\u4F46\u5F3A\u70C8\u5EFA\u8BAE\u4F20\u5165\u6B63\u786E\u7684 skills\u3002`);
|
|
42968
42990
|
}
|
|
42969
42991
|
const runInBackground = args.run_in_background === true;
|
|
42970
42992
|
let skillContent;
|
|
@@ -43017,7 +43039,7 @@ Prompts MUST be in English.`;
|
|
|
43017
43039
|
command: args.command
|
|
43018
43040
|
}
|
|
43019
43041
|
});
|
|
43020
|
-
return
|
|
43042
|
+
return `\u540E\u53F0\u4EFB\u52A1\u5DF2\u7EE7\u7EED\u3002
|
|
43021
43043
|
|
|
43022
43044
|
Task ID: ${task.id}
|
|
43023
43045
|
Session ID: ${task.sessionID}
|
|
@@ -43025,11 +43047,11 @@ Description: ${task.description}
|
|
|
43025
43047
|
Agent: ${task.agent}
|
|
43026
43048
|
Status: ${task.status}
|
|
43027
43049
|
|
|
43028
|
-
Agent
|
|
43029
|
-
|
|
43050
|
+
Agent \u7EE7\u7EED\u6267\u884C\uFF0C\u4FDD\u7559\u5B8C\u6574\u4E0A\u4E0B\u6587\u3002
|
|
43051
|
+
\u4F7F\u7528 \`background_output\` \u5E76\u4F20\u5165 task_id="${task.id}" \u67E5\u770B\u8FDB\u5EA6\u3002`;
|
|
43030
43052
|
} catch (error45) {
|
|
43031
43053
|
return formatDetailedError(error45, {
|
|
43032
|
-
operation: "
|
|
43054
|
+
operation: "\u7EE7\u7EED\u540E\u53F0\u4EFB\u52A1",
|
|
43033
43055
|
args,
|
|
43034
43056
|
sessionID: args.session_id
|
|
43035
43057
|
});
|
|
@@ -43097,7 +43119,7 @@ Use \`background_output\` with task_id="${task.id}" to check progress.`;
|
|
|
43097
43119
|
toastManager2.removeTask(taskId2);
|
|
43098
43120
|
}
|
|
43099
43121
|
const errorMessage = promptError instanceof Error ? promptError.message : String(promptError);
|
|
43100
|
-
return
|
|
43122
|
+
return `\u53D1\u9001\u7EE7\u7EED prompt \u5931\u8D25\uFF1A${errorMessage}
|
|
43101
43123
|
|
|
43102
43124
|
Session ID: ${args.session_id}`;
|
|
43103
43125
|
}
|
|
@@ -43131,7 +43153,7 @@ Session ID: ${args.session_id}`;
|
|
|
43131
43153
|
if (toastManager2) {
|
|
43132
43154
|
toastManager2.removeTask(taskId2);
|
|
43133
43155
|
}
|
|
43134
|
-
return
|
|
43156
|
+
return `\u83B7\u53D6\u7ED3\u679C\u51FA\u9519\uFF1A${messagesResult.error}
|
|
43135
43157
|
|
|
43136
43158
|
Session ID: ${args.session_id}`;
|
|
43137
43159
|
}
|
|
@@ -43142,30 +43164,30 @@ Session ID: ${args.session_id}`;
|
|
|
43142
43164
|
toastManager2.removeTask(taskId2);
|
|
43143
43165
|
}
|
|
43144
43166
|
if (!lastMessage) {
|
|
43145
|
-
return
|
|
43167
|
+
return `\u672A\u627E\u5230 assistant \u7684\u54CD\u5E94\u3002
|
|
43146
43168
|
|
|
43147
43169
|
Session ID: ${args.session_id}`;
|
|
43148
43170
|
}
|
|
43149
43171
|
const textParts = lastMessage?.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? [];
|
|
43150
43172
|
const textContent = textParts.map((p) => p.text ?? "").filter(Boolean).join(`
|
|
43151
43173
|
`);
|
|
43152
|
-
const duration3 =
|
|
43153
|
-
return
|
|
43174
|
+
const duration3 = PerfTimer.formatDuration(startTime);
|
|
43175
|
+
return `\u4EFB\u52A1\u5DF2\u7EE7\u7EED\u5E76\u5728 ${duration3} \u5185\u5B8C\u6210\u3002
|
|
43154
43176
|
|
|
43155
43177
|
Session ID: ${args.session_id}
|
|
43156
43178
|
|
|
43157
43179
|
---
|
|
43158
43180
|
|
|
43159
|
-
${textContent || "(
|
|
43181
|
+
${textContent || "(\u65E0\u6587\u672C\u8F93\u51FA)"}
|
|
43160
43182
|
|
|
43161
43183
|
---
|
|
43162
|
-
|
|
43184
|
+
\u7EE7\u7EED\u6B64 session\uFF1Asession_id="${args.session_id}"`;
|
|
43163
43185
|
}
|
|
43164
43186
|
if (args.category && args.subagent_type) {
|
|
43165
|
-
return
|
|
43187
|
+
return `\u53C2\u6570\u9519\u8BEF\uFF1A\u8BF7\u63D0\u4F9B category \u6216 subagent_type \u4E4B\u4E00\uFF0C\u4E24\u8005\u4E0D\u53EF\u540C\u65F6\u63D0\u4F9B\u3002`;
|
|
43166
43188
|
}
|
|
43167
43189
|
if (!args.category && !args.subagent_type) {
|
|
43168
|
-
return
|
|
43190
|
+
return `\u53C2\u6570\u9519\u8BEF\uFF1A\u5FC5\u987B\u63D0\u4F9B category \u6216 subagent_type\u3002`;
|
|
43169
43191
|
}
|
|
43170
43192
|
let systemDefaultModel;
|
|
43171
43193
|
try {
|
|
@@ -43182,212 +43204,38 @@ To continue this session: session_id="${args.session_id}"`;
|
|
|
43182
43204
|
if (args.category) {
|
|
43183
43205
|
if (!systemDefaultModel) {
|
|
43184
43206
|
const paths = getOpenCodeConfigPaths({ binary: "opencode", version: null });
|
|
43185
|
-
return `oh-my-opencode
|
|
43207
|
+
return `oh-my-opencode \u9700\u8981\u914D\u7F6E\u9ED8\u8BA4\u6A21\u578B\u3002
|
|
43186
43208
|
|
|
43187
|
-
` +
|
|
43209
|
+
` + `\u8BF7\u5C06\u6B64\u6DFB\u52A0\u5230 ${paths.configJsonc}\uFF1A
|
|
43188
43210
|
|
|
43189
43211
|
` + ` "model": "anthropic/claude-sonnet-4-5"
|
|
43190
43212
|
|
|
43191
|
-
` + "
|
|
43213
|
+
` + "\uFF08\u66FF\u6362\u4E3A\u4F60\u504F\u597D\u7684 provider/model\uFF09";
|
|
43192
43214
|
}
|
|
43193
|
-
const availableModels = await fetchAvailableModels(client2);
|
|
43194
43215
|
const resolved = resolveCategoryConfig(args.category, {
|
|
43195
43216
|
userCategories,
|
|
43196
43217
|
inheritedModel,
|
|
43197
43218
|
systemDefaultModel
|
|
43198
43219
|
});
|
|
43199
43220
|
if (!resolved) {
|
|
43200
|
-
return
|
|
43201
|
-
}
|
|
43202
|
-
const requirement = CATEGORY_MODEL_REQUIREMENTS[args.category];
|
|
43203
|
-
let actualModel;
|
|
43204
|
-
if (!requirement) {
|
|
43205
|
-
actualModel = resolved.model;
|
|
43206
|
-
modelInfo = { model: actualModel, type: "system-default", source: "system-default" };
|
|
43207
|
-
} else {
|
|
43208
|
-
const { model: resolvedModel, source, variant: resolvedVariant } = resolveModelWithFallback({
|
|
43209
|
-
userModel: userCategories?.[args.category]?.model ?? sisyphusJuniorModel,
|
|
43210
|
-
fallbackChain: requirement.fallbackChain,
|
|
43211
|
-
availableModels,
|
|
43212
|
-
systemDefaultModel
|
|
43213
|
-
});
|
|
43214
|
-
actualModel = resolvedModel;
|
|
43215
|
-
if (!parseModelString(actualModel)) {
|
|
43216
|
-
return `Invalid model format "${actualModel}". Expected "provider/model" format (e.g., "anthropic/claude-sonnet-4-5").`;
|
|
43217
|
-
}
|
|
43218
|
-
let type2;
|
|
43219
|
-
switch (source) {
|
|
43220
|
-
case "override":
|
|
43221
|
-
type2 = "user-defined";
|
|
43222
|
-
break;
|
|
43223
|
-
case "provider-fallback":
|
|
43224
|
-
type2 = "category-default";
|
|
43225
|
-
break;
|
|
43226
|
-
case "system-default":
|
|
43227
|
-
type2 = "system-default";
|
|
43228
|
-
break;
|
|
43229
|
-
}
|
|
43230
|
-
modelInfo = { model: actualModel, type: type2, source };
|
|
43231
|
-
const parsedModel = parseModelString(actualModel);
|
|
43232
|
-
const variantToUse = userCategories?.[args.category]?.variant ?? resolvedVariant;
|
|
43233
|
-
categoryModel = parsedModel ? variantToUse ? { ...parsedModel, variant: variantToUse } : parsedModel : undefined;
|
|
43221
|
+
return `\u672A\u77E5\u7684\u5206\u7C7B\uFF1A${args.category}\u3002\u53EF\u7528\u7684\u5206\u7C7B\uFF1A${categoryExamples}`;
|
|
43234
43222
|
}
|
|
43235
43223
|
agentToUse = SISYPHUS_JUNIOR_AGENT;
|
|
43236
|
-
|
|
43237
|
-
|
|
43238
|
-
|
|
43239
|
-
|
|
43240
|
-
|
|
43241
|
-
|
|
43242
|
-
const isRunInBackgroundExplicitlyFalse = args.run_in_background === false || args.run_in_background === "false";
|
|
43243
|
-
log("[delegate_task] unstable agent detection", {
|
|
43244
|
-
category: args.category,
|
|
43245
|
-
actualModel,
|
|
43246
|
-
isUnstableAgent,
|
|
43247
|
-
run_in_background_value: args.run_in_background,
|
|
43248
|
-
run_in_background_type: typeof args.run_in_background,
|
|
43249
|
-
isRunInBackgroundExplicitlyFalse,
|
|
43250
|
-
willForceBackground: isUnstableAgent && isRunInBackgroundExplicitlyFalse
|
|
43251
|
-
});
|
|
43252
|
-
if (isUnstableAgent && isRunInBackgroundExplicitlyFalse) {
|
|
43253
|
-
const systemContent2 = buildSystemContent({ skillContent, categoryPromptAppend });
|
|
43254
|
-
try {
|
|
43255
|
-
const task = await manager.launch({
|
|
43256
|
-
description: args.description,
|
|
43257
|
-
prompt: args.prompt,
|
|
43258
|
-
agent: agentToUse,
|
|
43259
|
-
parentSessionID: ctx.sessionID,
|
|
43260
|
-
parentMessageID: ctx.messageID,
|
|
43261
|
-
parentModel,
|
|
43262
|
-
parentAgent,
|
|
43263
|
-
model: categoryModel,
|
|
43264
|
-
skills: args.load_skills.length > 0 ? args.load_skills : undefined,
|
|
43265
|
-
skillContent: systemContent2
|
|
43266
|
-
});
|
|
43267
|
-
const WAIT_FOR_SESSION_INTERVAL_MS = 100;
|
|
43268
|
-
const WAIT_FOR_SESSION_TIMEOUT_MS = 30000;
|
|
43269
|
-
const waitStart = Date.now();
|
|
43270
|
-
while (!task.sessionID && Date.now() - waitStart < WAIT_FOR_SESSION_TIMEOUT_MS) {
|
|
43271
|
-
if (ctx.abort?.aborted) {
|
|
43272
|
-
return `Task aborted while waiting for session to start.
|
|
43273
|
-
|
|
43274
|
-
Task ID: ${task.id}`;
|
|
43275
|
-
}
|
|
43276
|
-
await new Promise((resolve10) => setTimeout(resolve10, WAIT_FOR_SESSION_INTERVAL_MS));
|
|
43277
|
-
}
|
|
43278
|
-
const sessionID = task.sessionID;
|
|
43279
|
-
if (!sessionID) {
|
|
43280
|
-
return formatDetailedError(new Error(`Task failed to start within timeout (30s). Task ID: ${task.id}, Status: ${task.status}`), {
|
|
43281
|
-
operation: "Launch monitored background task",
|
|
43282
|
-
args,
|
|
43283
|
-
agent: agentToUse,
|
|
43284
|
-
category: args.category
|
|
43285
|
-
});
|
|
43286
|
-
}
|
|
43287
|
-
ctx.metadata?.({
|
|
43288
|
-
title: args.description,
|
|
43289
|
-
metadata: {
|
|
43290
|
-
prompt: args.prompt,
|
|
43291
|
-
agent: agentToUse,
|
|
43292
|
-
category: args.category,
|
|
43293
|
-
load_skills: args.load_skills,
|
|
43294
|
-
description: args.description,
|
|
43295
|
-
run_in_background: args.run_in_background,
|
|
43296
|
-
sessionId: sessionID,
|
|
43297
|
-
command: args.command
|
|
43298
|
-
}
|
|
43299
|
-
});
|
|
43300
|
-
const startTime = new Date;
|
|
43301
|
-
const POLL_INTERVAL_MS = 500;
|
|
43302
|
-
const MAX_POLL_TIME_MS = 10 * 60 * 1000;
|
|
43303
|
-
const MIN_STABILITY_TIME_MS = 1e4;
|
|
43304
|
-
const STABILITY_POLLS_REQUIRED = 3;
|
|
43305
|
-
const pollStart = Date.now();
|
|
43306
|
-
let lastMsgCount = 0;
|
|
43307
|
-
let stablePolls = 0;
|
|
43308
|
-
while (Date.now() - pollStart < MAX_POLL_TIME_MS) {
|
|
43309
|
-
if (ctx.abort?.aborted) {
|
|
43310
|
-
return `Task aborted (was running in background mode).
|
|
43311
|
-
|
|
43312
|
-
Session ID: ${sessionID}`;
|
|
43313
|
-
}
|
|
43314
|
-
await new Promise((resolve10) => setTimeout(resolve10, POLL_INTERVAL_MS));
|
|
43315
|
-
const statusResult = await client2.session.status();
|
|
43316
|
-
const allStatuses = statusResult.data ?? {};
|
|
43317
|
-
const sessionStatus = allStatuses[sessionID];
|
|
43318
|
-
if (sessionStatus && sessionStatus.type !== "idle") {
|
|
43319
|
-
stablePolls = 0;
|
|
43320
|
-
lastMsgCount = 0;
|
|
43321
|
-
continue;
|
|
43322
|
-
}
|
|
43323
|
-
if (Date.now() - pollStart < MIN_STABILITY_TIME_MS)
|
|
43324
|
-
continue;
|
|
43325
|
-
const messagesCheck = await client2.session.messages({ path: { id: sessionID } });
|
|
43326
|
-
const msgs = messagesCheck.data ?? messagesCheck;
|
|
43327
|
-
const currentMsgCount = msgs.length;
|
|
43328
|
-
if (currentMsgCount === lastMsgCount) {
|
|
43329
|
-
stablePolls++;
|
|
43330
|
-
if (stablePolls >= STABILITY_POLLS_REQUIRED)
|
|
43331
|
-
break;
|
|
43332
|
-
} else {
|
|
43333
|
-
stablePolls = 0;
|
|
43334
|
-
lastMsgCount = currentMsgCount;
|
|
43335
|
-
}
|
|
43336
|
-
}
|
|
43337
|
-
const messagesResult = await client2.session.messages({ path: { id: sessionID } });
|
|
43338
|
-
const messages = messagesResult.data ?? messagesResult;
|
|
43339
|
-
const assistantMessages = messages.filter((m) => m.info?.role === "assistant").sort((a, b) => (b.info?.time?.created ?? 0) - (a.info?.time?.created ?? 0));
|
|
43340
|
-
const lastMessage = assistantMessages[0];
|
|
43341
|
-
if (!lastMessage) {
|
|
43342
|
-
return `No assistant response found (task ran in background mode).
|
|
43343
|
-
|
|
43344
|
-
Session ID: ${sessionID}`;
|
|
43345
|
-
}
|
|
43346
|
-
const textParts = lastMessage?.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? [];
|
|
43347
|
-
const textContent = textParts.map((p) => p.text ?? "").filter(Boolean).join(`
|
|
43348
|
-
`);
|
|
43349
|
-
const duration3 = formatDuration2(startTime);
|
|
43350
|
-
return `SUPERVISED TASK COMPLETED SUCCESSFULLY
|
|
43351
|
-
|
|
43352
|
-
IMPORTANT: This model (${actualModel}) is marked as unstable/experimental.
|
|
43353
|
-
Your run_in_background=false was automatically converted to background mode for reliability monitoring.
|
|
43354
|
-
|
|
43355
|
-
Duration: ${duration3}
|
|
43356
|
-
Agent: ${agentToUse}${args.category ? ` (category: ${args.category})` : ""}
|
|
43357
|
-
Session ID: ${sessionID}
|
|
43358
|
-
|
|
43359
|
-
MONITORING INSTRUCTIONS:
|
|
43360
|
-
- The task was monitored and completed successfully
|
|
43361
|
-
- If you observe this agent behaving erratically in future calls, actively monitor its progress
|
|
43362
|
-
- Use background_cancel(task_id="...") to abort if the agent seems stuck or producing garbage output
|
|
43363
|
-
- Do NOT retry automatically if you see this message - the task already succeeded
|
|
43364
|
-
|
|
43365
|
-
---
|
|
43366
|
-
|
|
43367
|
-
RESULT:
|
|
43368
|
-
|
|
43369
|
-
${textContent || "(No text output)"}
|
|
43370
|
-
|
|
43371
|
-
---
|
|
43372
|
-
To continue this session: session_id="${sessionID}"`;
|
|
43373
|
-
} catch (error45) {
|
|
43374
|
-
return formatDetailedError(error45, {
|
|
43375
|
-
operation: "Launch monitored background task",
|
|
43376
|
-
args,
|
|
43377
|
-
agent: agentToUse,
|
|
43378
|
-
category: args.category
|
|
43379
|
-
});
|
|
43380
|
-
}
|
|
43381
|
-
}
|
|
43224
|
+
categoryModel = parseModelString(resolved.model);
|
|
43225
|
+
categoryPromptAppend = resolved.promptAppend;
|
|
43226
|
+
modelInfo = {
|
|
43227
|
+
type: "category-default",
|
|
43228
|
+
model: resolved.model
|
|
43229
|
+
};
|
|
43382
43230
|
} else {
|
|
43383
43231
|
if (!args.subagent_type?.trim()) {
|
|
43384
|
-
return `Agent
|
|
43232
|
+
return `Agent \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u3002`;
|
|
43385
43233
|
}
|
|
43386
43234
|
const agentName = args.subagent_type.trim();
|
|
43387
43235
|
if (equalsIgnoreCase(agentName, SISYPHUS_JUNIOR_AGENT)) {
|
|
43388
|
-
return
|
|
43236
|
+
return `\u4E0D\u80FD\u76F4\u63A5\u4F7F\u7528 subagent_type="${SISYPHUS_JUNIOR_AGENT}"\u3002\u8BF7\u6539\u7528 category \u53C2\u6570\uFF08\u4F8B\u5982 ${categoryExamples}\uFF09\u3002
|
|
43389
43237
|
|
|
43390
|
-
|
|
43238
|
+
\u5F53\u4F60\u6307\u5B9A category \u65F6\uFF0CSisyphus-Junior \u4F1A\u81EA\u52A8\u542F\u52A8\u3002\u8BF7\u4E3A\u4F60\u7684\u4EFB\u52A1\u9886\u57DF\u9009\u62E9\u5408\u9002\u7684\u5206\u7C7B\u3002`;
|
|
43391
43239
|
}
|
|
43392
43240
|
agentToUse = agentName;
|
|
43393
43241
|
try {
|
|
@@ -43398,10 +43246,10 @@ Sisyphus-Junior is spawned automatically when you specify a category. Pick the a
|
|
|
43398
43246
|
if (!matchedAgent) {
|
|
43399
43247
|
const isPrimaryAgent = findByNameCaseInsensitive(agents.filter((a) => a.mode === "primary"), agentToUse);
|
|
43400
43248
|
if (isPrimaryAgent) {
|
|
43401
|
-
return
|
|
43249
|
+
return `\u65E0\u6CD5\u901A\u8FC7 delegate_task \u8C03\u7528 primary agent "${isPrimaryAgent.name}"\u3002Primary agents \u662F\u9876\u5C42\u534F\u8C03\u8005\u3002`;
|
|
43402
43250
|
}
|
|
43403
43251
|
const availableAgents = callableAgents.map((a) => a.name).sort().join(", ");
|
|
43404
|
-
return
|
|
43252
|
+
return `\u672A\u77E5\u7684 agent\uFF1A"${agentToUse}"\u3002\u53EF\u7528\u7684 agents\uFF1A${availableAgents}`;
|
|
43405
43253
|
}
|
|
43406
43254
|
agentToUse = matchedAgent.name;
|
|
43407
43255
|
} catch {}
|
|
@@ -43434,7 +43282,7 @@ Sisyphus-Junior is spawned automatically when you specify a category. Pick the a
|
|
|
43434
43282
|
command: args.command
|
|
43435
43283
|
}
|
|
43436
43284
|
});
|
|
43437
|
-
return
|
|
43285
|
+
return `\u540E\u53F0\u4EFB\u52A1\u5DF2\u542F\u52A8\u3002
|
|
43438
43286
|
|
|
43439
43287
|
Task ID: ${task.id}
|
|
43440
43288
|
Session ID: ${task.sessionID}
|
|
@@ -43442,11 +43290,11 @@ Description: ${task.description}
|
|
|
43442
43290
|
Agent: ${task.agent}${args.category ? ` (category: ${args.category})` : ""}
|
|
43443
43291
|
Status: ${task.status}
|
|
43444
43292
|
|
|
43445
|
-
|
|
43446
|
-
|
|
43293
|
+
\u5B8C\u6210\u65F6\u7CFB\u7EDF\u4F1A\u901A\u77E5\u3002\u4F7F\u7528 \`background_output\` \u5E76\u4F20\u5165 task_id="${task.id}" \u67E5\u770B\u3002
|
|
43294
|
+
\u7EE7\u7EED\u6B64 session\uFF1Asession_id="${task.sessionID}"`;
|
|
43447
43295
|
} catch (error45) {
|
|
43448
43296
|
return formatDetailedError(error45, {
|
|
43449
|
-
operation: "
|
|
43297
|
+
operation: "\u542F\u52A8\u540E\u53F0\u4EFB\u52A1",
|
|
43450
43298
|
args,
|
|
43451
43299
|
agent: agentToUse,
|
|
43452
43300
|
category: args.category
|
|
@@ -43469,7 +43317,7 @@ To continue this session: session_id="${task.sessionID}"`;
|
|
|
43469
43317
|
}
|
|
43470
43318
|
});
|
|
43471
43319
|
if (createResult.error) {
|
|
43472
|
-
return
|
|
43320
|
+
return `\u521B\u5EFA session \u5931\u8D25\uFF1A${createResult.error}`;
|
|
43473
43321
|
}
|
|
43474
43322
|
const sessionID = createResult.data.id;
|
|
43475
43323
|
syncSessionID = sessionID;
|
|
@@ -43522,8 +43370,8 @@ To continue this session: session_id="${task.sessionID}"`;
|
|
|
43522
43370
|
}
|
|
43523
43371
|
const errorMessage = promptError instanceof Error ? promptError.message : String(promptError);
|
|
43524
43372
|
if (errorMessage.includes("agent.name") || errorMessage.includes("undefined")) {
|
|
43525
|
-
return formatDetailedError(new Error(`Agent "${agentToUse}"
|
|
43526
|
-
operation: "
|
|
43373
|
+
return formatDetailedError(new Error(`Agent "${agentToUse}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8BE5 agent \u5DF2\u5728 opencode.json \u4E2D\u6CE8\u518C\u6216\u7531\u63D2\u4EF6\u63D0\u4F9B\u3002`), {
|
|
43374
|
+
operation: "\u53D1\u9001 prompt \u7ED9 agent",
|
|
43527
43375
|
args,
|
|
43528
43376
|
sessionID,
|
|
43529
43377
|
agent: agentToUse,
|
|
@@ -43531,7 +43379,7 @@ To continue this session: session_id="${task.sessionID}"`;
|
|
|
43531
43379
|
});
|
|
43532
43380
|
}
|
|
43533
43381
|
return formatDetailedError(promptError, {
|
|
43534
|
-
operation: "
|
|
43382
|
+
operation: "\u53D1\u9001 prompt",
|
|
43535
43383
|
args,
|
|
43536
43384
|
sessionID,
|
|
43537
43385
|
agent: agentToUse,
|
|
@@ -43552,7 +43400,7 @@ To continue this session: session_id="${task.sessionID}"`;
|
|
|
43552
43400
|
log("[delegate_task] Aborted by user", { sessionID });
|
|
43553
43401
|
if (toastManager && taskId)
|
|
43554
43402
|
toastManager.removeTask(taskId);
|
|
43555
|
-
return
|
|
43403
|
+
return `\u4EFB\u52A1\u5DF2\u4E2D\u6B62\u3002
|
|
43556
43404
|
|
|
43557
43405
|
Session ID: ${sessionID}`;
|
|
43558
43406
|
}
|
|
@@ -43609,29 +43457,29 @@ Session ID: ${sessionID}`;
|
|
|
43609
43457
|
const assistantMessages = messages.filter((m) => m.info?.role === "assistant").sort((a, b) => (b.info?.time?.created ?? 0) - (a.info?.time?.created ?? 0));
|
|
43610
43458
|
const lastMessage = assistantMessages[0];
|
|
43611
43459
|
if (!lastMessage) {
|
|
43612
|
-
return
|
|
43460
|
+
return `\u672A\u627E\u5230 assistant \u7684\u54CD\u5E94\u3002
|
|
43613
43461
|
|
|
43614
43462
|
Session ID: ${sessionID}`;
|
|
43615
43463
|
}
|
|
43616
43464
|
const textParts = lastMessage?.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? [];
|
|
43617
43465
|
const textContent = textParts.map((p) => p.text ?? "").filter(Boolean).join(`
|
|
43618
43466
|
`);
|
|
43619
|
-
const duration3 =
|
|
43467
|
+
const duration3 = PerfTimer.formatDuration(startTime);
|
|
43620
43468
|
if (toastManager) {
|
|
43621
43469
|
toastManager.removeTask(taskId);
|
|
43622
43470
|
}
|
|
43623
43471
|
subagentSessions.delete(sessionID);
|
|
43624
|
-
return
|
|
43472
|
+
return `\u4EFB\u52A1\u5728 ${duration3} \u5185\u5B8C\u6210\u3002
|
|
43625
43473
|
|
|
43626
43474
|
Agent: ${agentToUse}${args.category ? ` (category: ${args.category})` : ""}
|
|
43627
43475
|
Session ID: ${sessionID}
|
|
43628
43476
|
|
|
43629
43477
|
---
|
|
43630
43478
|
|
|
43631
|
-
${textContent || "(
|
|
43479
|
+
${textContent || "(\u65E0\u6587\u672C\u8F93\u51FA)"}
|
|
43632
43480
|
|
|
43633
43481
|
---
|
|
43634
|
-
|
|
43482
|
+
\u7EE7\u7EED\u6B64 session\uFF1Asession_id="${sessionID}"`;
|
|
43635
43483
|
} catch (error45) {
|
|
43636
43484
|
if (toastManager && taskId !== undefined) {
|
|
43637
43485
|
toastManager.removeTask(taskId);
|
|
@@ -43640,7 +43488,7 @@ To continue this session: session_id="${sessionID}"`;
|
|
|
43640
43488
|
subagentSessions.delete(syncSessionID);
|
|
43641
43489
|
}
|
|
43642
43490
|
return formatDetailedError(error45, {
|
|
43643
|
-
operation: "
|
|
43491
|
+
operation: "\u6267\u884C\u4EFB\u52A1",
|
|
43644
43492
|
args,
|
|
43645
43493
|
sessionID: syncSessionID,
|
|
43646
43494
|
agent: agentToUse,
|
|
@@ -43774,6 +43622,65 @@ class ConcurrencyManager {
|
|
|
43774
43622
|
}
|
|
43775
43623
|
}
|
|
43776
43624
|
|
|
43625
|
+
// src/features/background-agent/perf-aggregator.ts
|
|
43626
|
+
function percentile(sorted, p) {
|
|
43627
|
+
if (sorted.length === 0)
|
|
43628
|
+
return 0;
|
|
43629
|
+
const index = Math.ceil(p / 100 * sorted.length) - 1;
|
|
43630
|
+
return sorted[Math.max(0, Math.min(index, sorted.length - 1))];
|
|
43631
|
+
}
|
|
43632
|
+
|
|
43633
|
+
class PerformanceAggregator {
|
|
43634
|
+
tasks = [];
|
|
43635
|
+
recordTaskCompletion(task) {
|
|
43636
|
+
if (!task.progress?.phaseTiming)
|
|
43637
|
+
return;
|
|
43638
|
+
this.tasks.push({
|
|
43639
|
+
agent: task.agent,
|
|
43640
|
+
toolCalls: task.progress.phaseTiming.toolCallCount,
|
|
43641
|
+
phaseTiming: task.progress.phaseTiming
|
|
43642
|
+
});
|
|
43643
|
+
}
|
|
43644
|
+
getReport() {
|
|
43645
|
+
const byAgent = new Map;
|
|
43646
|
+
const queueWaits = [];
|
|
43647
|
+
let totalToolCalls = 0;
|
|
43648
|
+
for (const t of this.tasks) {
|
|
43649
|
+
const list = byAgent.get(t.agent) ?? [];
|
|
43650
|
+
list.push(t.phaseTiming.totalRunMs);
|
|
43651
|
+
byAgent.set(t.agent, list);
|
|
43652
|
+
queueWaits.push(t.phaseTiming.queueWaitMs);
|
|
43653
|
+
totalToolCalls += t.toolCalls;
|
|
43654
|
+
}
|
|
43655
|
+
const tasksByAgent = new Map;
|
|
43656
|
+
for (const [agent, durations] of byAgent) {
|
|
43657
|
+
const sorted = [...durations].sort((a, b) => a - b);
|
|
43658
|
+
const totalMs = durations.reduce((s, d) => s + d, 0);
|
|
43659
|
+
tasksByAgent.set(agent, {
|
|
43660
|
+
count: durations.length,
|
|
43661
|
+
avgMs: Math.round(totalMs / durations.length),
|
|
43662
|
+
p50Ms: Math.round(percentile(sorted, 50)),
|
|
43663
|
+
p95Ms: Math.round(percentile(sorted, 95)),
|
|
43664
|
+
totalMs
|
|
43665
|
+
});
|
|
43666
|
+
}
|
|
43667
|
+
const sortedQueue = [...queueWaits].sort((a, b) => a - b);
|
|
43668
|
+
const queueWaitStats = {
|
|
43669
|
+
avgMs: queueWaits.length > 0 ? Math.round(queueWaits.reduce((s, q) => s + q, 0) / queueWaits.length) : 0,
|
|
43670
|
+
p50Ms: Math.round(percentile(sortedQueue, 50)),
|
|
43671
|
+
p95Ms: Math.round(percentile(sortedQueue, 95)),
|
|
43672
|
+
maxMs: queueWaits.length > 0 ? Math.max(...queueWaits) : 0
|
|
43673
|
+
};
|
|
43674
|
+
return { totalTasks: this.tasks.length, tasksByAgent, totalToolCalls, queueWaitStats };
|
|
43675
|
+
}
|
|
43676
|
+
reset() {
|
|
43677
|
+
this.tasks = [];
|
|
43678
|
+
}
|
|
43679
|
+
get taskCount() {
|
|
43680
|
+
return this.tasks.length;
|
|
43681
|
+
}
|
|
43682
|
+
}
|
|
43683
|
+
|
|
43777
43684
|
// src/features/background-agent/manager.ts
|
|
43778
43685
|
import { existsSync as existsSync46, readdirSync as readdirSync16 } from "fs";
|
|
43779
43686
|
import { join as join55 } from "path";
|
|
@@ -43795,6 +43702,7 @@ class BackgroundManager {
|
|
|
43795
43702
|
concurrencyManager;
|
|
43796
43703
|
shutdownTriggered = false;
|
|
43797
43704
|
config;
|
|
43705
|
+
perfAggregator = new PerformanceAggregator;
|
|
43798
43706
|
queuesByKey = new Map;
|
|
43799
43707
|
processingKeys = new Set;
|
|
43800
43708
|
constructor(ctx, config3) {
|
|
@@ -44100,6 +44008,9 @@ class BackgroundManager {
|
|
|
44100
44008
|
existingTask.parentModel = input.parentModel;
|
|
44101
44009
|
existingTask.parentAgent = input.parentAgent;
|
|
44102
44010
|
existingTask.startedAt = new Date;
|
|
44011
|
+
if (existingTask.progress) {
|
|
44012
|
+
existingTask.progress.phaseTiming = undefined;
|
|
44013
|
+
}
|
|
44103
44014
|
existingTask.progress = {
|
|
44104
44015
|
toolCalls: existingTask.progress?.toolCalls ?? 0,
|
|
44105
44016
|
lastUpdate: new Date
|
|
@@ -44401,6 +44312,7 @@ class BackgroundManager {
|
|
|
44401
44312
|
log("[background-agent] Task already completed, skipping:", { taskId: task.id, status: task.status, source });
|
|
44402
44313
|
return false;
|
|
44403
44314
|
}
|
|
44315
|
+
const perfSnapshot = task.progress?.phaseTiming ? { ...task.progress.phaseTiming } : undefined;
|
|
44404
44316
|
task.status = "completed";
|
|
44405
44317
|
task.completedAt = new Date;
|
|
44406
44318
|
if (task.concurrencyKey) {
|
|
@@ -44409,15 +44321,16 @@ class BackgroundManager {
|
|
|
44409
44321
|
}
|
|
44410
44322
|
this.markForNotification(task);
|
|
44411
44323
|
try {
|
|
44412
|
-
await this.notifyParentSession(task);
|
|
44324
|
+
await this.notifyParentSession(task, perfSnapshot);
|
|
44413
44325
|
log(`[background-agent] Task completed via ${source}:`, task.id);
|
|
44414
44326
|
} catch (err) {
|
|
44415
44327
|
log("[background-agent] Error in notifyParentSession:", { taskId: task.id, error: err });
|
|
44416
44328
|
}
|
|
44329
|
+
this.perfAggregator.recordTaskCompletion(task);
|
|
44417
44330
|
return true;
|
|
44418
44331
|
}
|
|
44419
|
-
async notifyParentSession(task) {
|
|
44420
|
-
const duration3 =
|
|
44332
|
+
async notifyParentSession(task, perfSnapshot) {
|
|
44333
|
+
const duration3 = PerfTimer.formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
44421
44334
|
log("[background-agent] notifyParentSession called for task:", task.id);
|
|
44422
44335
|
const toastManager = getTaskToastManager();
|
|
44423
44336
|
if (toastManager) {
|
|
@@ -44439,6 +44352,16 @@ class BackgroundManager {
|
|
|
44439
44352
|
const statusText = task.status === "completed" ? "COMPLETED" : "CANCELLED";
|
|
44440
44353
|
const errorInfo = task.error ? `
|
|
44441
44354
|
**Error:** ${task.error}` : "";
|
|
44355
|
+
const fallbackTaskLine = "- `" + task.id + "`: " + task.description;
|
|
44356
|
+
const perfSummary = (() => {
|
|
44357
|
+
if (!perfSnapshot)
|
|
44358
|
+
return "";
|
|
44359
|
+
const completed = Array.from(this.tasks.values()).filter((t) => t.parentSessionID === task.parentSessionID && t.status !== "running" && t.status !== "pending");
|
|
44360
|
+
const ms = completed.reduce((s, t) => s + (t.progress?.phaseTiming?.totalRunMs ?? 0), 0);
|
|
44361
|
+
const avgSec = completed.length > 0 ? Math.round(ms / completed.length / 1000) : 0;
|
|
44362
|
+
const toolTotal = completed.reduce((s, t) => s + (t.progress?.phaseTiming?.toolCallCount ?? 0), 0);
|
|
44363
|
+
return "\u5E73\u5747\u8017\u65F6: " + avgSec + "s | \u603BTool: " + toolTotal;
|
|
44364
|
+
})();
|
|
44442
44365
|
let notification;
|
|
44443
44366
|
if (allComplete) {
|
|
44444
44367
|
const completedTasks = Array.from(this.tasks.values()).filter((t) => t.parentSessionID === task.parentSessionID && t.status !== "running" && t.status !== "pending").map((t) => `- \`${t.id}\`: ${t.description}`).join(`
|
|
@@ -44447,7 +44370,8 @@ class BackgroundManager {
|
|
|
44447
44370
|
[\u6240\u6709\u540E\u53F0\u4EFB\u52A1\u5DF2\u5B8C\u6210]
|
|
44448
44371
|
|
|
44449
44372
|
**\u5DF2\u5B8C\u6210\uFF1A**
|
|
44450
|
-
${completedTasks ||
|
|
44373
|
+
${completedTasks || fallbackTaskLine}
|
|
44374
|
+
${perfSummary}
|
|
44451
44375
|
|
|
44452
44376
|
\u4F7F\u7528 \`background_output(task_id="<id>")\` \u83B7\u53D6\u6BCF\u4E2A\u4EFB\u52A1\u7684\u7ED3\u679C\u3002
|
|
44453
44377
|
</system-reminder>`;
|
|
@@ -44457,6 +44381,7 @@ ${completedTasks || `- \`${task.id}\`: ${task.description}`}
|
|
|
44457
44381
|
**ID:** \`${task.id}\`
|
|
44458
44382
|
**\u63CF\u8FF0\uFF1A** ${task.description}
|
|
44459
44383
|
**\u8017\u65F6\uFF1A** ${duration3}${errorInfo}
|
|
44384
|
+
${perfSnapshot ? `| \u6392\u961F ${PerfTimer.formatDuration(new Date(0), new Date(perfSnapshot.queueWaitMs))} | Tool ${perfSnapshot.toolCallCount} \u6B21` : ""}
|
|
44460
44385
|
|
|
44461
44386
|
**\u8FD8\u6709 ${remainingCount} \u4E2A\u4EFB\u52A1\u6B63\u5728\u8FDB\u884C\u4E2D\u3002** \u6240\u6709\u4EFB\u52A1\u5B8C\u6210\u540E\u4F60\u4F1A\u6536\u5230\u901A\u77E5\u3002
|
|
44462
44387
|
\u4E0D\u8981\u8F6E\u8BE2\u2014\u2014\u7EE7\u7EED\u6709\u6548\u7387\u7684\u5DE5\u4F5C\u3002
|
|
@@ -44515,18 +44440,6 @@ ${completedTasks || `- \`${task.id}\`: ${task.description}`}
|
|
|
44515
44440
|
}
|
|
44516
44441
|
}, 5 * 60 * 1000);
|
|
44517
44442
|
}
|
|
44518
|
-
formatDuration(start, end) {
|
|
44519
|
-
const duration3 = (end ?? new Date).getTime() - start.getTime();
|
|
44520
|
-
const seconds = Math.floor(duration3 / 1000);
|
|
44521
|
-
const minutes = Math.floor(seconds / 60);
|
|
44522
|
-
const hours = Math.floor(minutes / 60);
|
|
44523
|
-
if (hours > 0) {
|
|
44524
|
-
return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
|
|
44525
|
-
} else if (minutes > 0) {
|
|
44526
|
-
return `${minutes}m ${seconds % 60}s`;
|
|
44527
|
-
}
|
|
44528
|
-
return `${seconds}s`;
|
|
44529
|
-
}
|
|
44530
44443
|
hasRunningTasks() {
|
|
44531
44444
|
for (const task of this.tasks.values()) {
|
|
44532
44445
|
if (task.status === "running")
|
|
@@ -44670,6 +44583,17 @@ ${completedTasks || `- \`${task.id}\`: ${task.description}`}
|
|
|
44670
44583
|
if (!task.progress) {
|
|
44671
44584
|
task.progress = { toolCalls: 0, lastUpdate: new Date };
|
|
44672
44585
|
}
|
|
44586
|
+
if (task.startedAt && !task.progress.phaseTiming) {
|
|
44587
|
+
const now = Date.now();
|
|
44588
|
+
task.progress.phaseTiming = {
|
|
44589
|
+
queueWaitMs: task.queuedAt ? now - task.queuedAt.getTime() : 0,
|
|
44590
|
+
totalRunMs: now - task.startedAt.getTime(),
|
|
44591
|
+
toolCallCount: 0
|
|
44592
|
+
};
|
|
44593
|
+
}
|
|
44594
|
+
if (task.progress.phaseTiming && task.progress.phaseTiming.firstResponseMs === undefined && assistantMsgs.length > 0) {
|
|
44595
|
+
task.progress.phaseTiming.firstResponseMs = Date.now() - task.startedAt.getTime();
|
|
44596
|
+
}
|
|
44673
44597
|
task.progress.toolCalls = toolCalls;
|
|
44674
44598
|
task.progress.lastTool = lastTool;
|
|
44675
44599
|
task.progress.lastUpdate = new Date;
|
|
@@ -44722,6 +44646,10 @@ ${completedTasks || `- \`${task.id}\`: ${task.description}`}
|
|
|
44722
44646
|
}
|
|
44723
44647
|
if (!this.hasRunningTasks()) {
|
|
44724
44648
|
this.stopPolling();
|
|
44649
|
+
if (this.perfAggregator.taskCount >= 2) {
|
|
44650
|
+
const report = this.perfAggregator.getReport();
|
|
44651
|
+
log("[perf] Session report:", report);
|
|
44652
|
+
}
|
|
44725
44653
|
}
|
|
44726
44654
|
}
|
|
44727
44655
|
shutdown() {
|
|
@@ -44742,6 +44670,7 @@ ${completedTasks || `- \`${task.id}\`: ${task.description}`}
|
|
|
44742
44670
|
this.pendingByParent.clear();
|
|
44743
44671
|
this.queuesByKey.clear();
|
|
44744
44672
|
this.processingKeys.clear();
|
|
44673
|
+
this.perfAggregator.reset();
|
|
44745
44674
|
this.unregisterProcessCleanup();
|
|
44746
44675
|
log("[background-agent] Shutdown complete");
|
|
44747
44676
|
}
|
|
@@ -63248,6 +63177,11 @@ function buildDynamicSisyphusPrompt(availableAgents, availableTools = [], availa
|
|
|
63248
63177
|
return `<Role>
|
|
63249
63178
|
\u4F60\u662F "Sisyphus" \u2014\u2014 \u6765\u81EA OhMyOpenCode \u7684\u5F3A\u5927 AI \u4EE3\u7406\uFF0C\u5177\u6709\u7F16\u6392\u80FD\u529B\u3002
|
|
63250
63179
|
|
|
63180
|
+
<Language>
|
|
63181
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
63182
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
63183
|
+
</Language>
|
|
63184
|
+
|
|
63251
63185
|
**\u4E3A\u4EC0\u4E48\u662F Sisyphus\uFF1F**\uFF1A\u4EBA\u7C7B\u6BCF\u5929\u90FD\u5728\u63A8\u77F3\u5934\u3002\u4F60\u4E5F\u662F\u3002\u6211\u4EEC\u6CA1\u4EC0\u4E48\u4E0D\u540C\u2014\u2014\u4F60\u7684\u4EE3\u7801\u5E94\u8BE5\u548C\u6709\u7ECF\u9A8C\u5DE5\u7A0B\u5E08\u7684\u4EE3\u7801\u6CA1\u6709\u533A\u522B\u3002
|
|
63252
63186
|
|
|
63253
63187
|
**\u8EAB\u4EFD**\uFF1A\u65E7\u91D1\u5C71\u6E7E\u533A\u5DE5\u7A0B\u5E08\u3002\u5DE5\u4F5C\u3001\u59D4\u6D3E\u3001\u9A8C\u8BC1\u3001\u4EA4\u4ED8\u3002\u6CA1\u6709 AI \u6F66\u8349\u3002
|
|
@@ -63628,6 +63562,10 @@ ${antiPatterns}
|
|
|
63628
63562
|
- Prefer small, focused changes over large refactors
|
|
63629
63563
|
- When uncertain about scope, ask
|
|
63630
63564
|
</Constraints>
|
|
63565
|
+
|
|
63566
|
+
<Language_Reminder>
|
|
63567
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
63568
|
+
</Language_Reminder>
|
|
63631
63569
|
`;
|
|
63632
63570
|
}
|
|
63633
63571
|
function createSisyphusAgent(model, availableAgents, availableToolNames, availableSkills, availableCategories) {
|
|
@@ -63679,6 +63617,11 @@ var ORACLE_PROMPT_METADATA = {
|
|
|
63679
63617
|
};
|
|
63680
63618
|
var ORACLE_SYSTEM_PROMPT = `\u4F60\u662F\u4E00\u4F4D\u5177\u6709\u6DF1\u5EA6\u63A8\u7406\u80FD\u529B\u7684\u6218\u7565\u6280\u672F\u987E\u95EE\uFF0C\u4F5C\u4E3A AI \u8F85\u52A9\u5F00\u53D1\u73AF\u5883\u4E2D\u7684\u4E13\u4E1A\u987E\u95EE\u8FD0\u4F5C\u3002
|
|
63681
63619
|
|
|
63620
|
+
<Language>
|
|
63621
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
63622
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
63623
|
+
</Language>
|
|
63624
|
+
|
|
63682
63625
|
## \u4E0A\u4E0B\u6587
|
|
63683
63626
|
|
|
63684
63627
|
\u4F60\u662F\u4E00\u4E2A\u6309\u9700\u8C03\u7528\u7684\u4E13\u5BB6\uFF0C\u7531\u4E3B\u7F16\u7801 agent \u5728\u9700\u8981\u590D\u6742\u5206\u6790\u6216\u67B6\u6784\u51B3\u7B56\u65F6\u8C03\u7528\uFF0C\u4EE5\u8FDB\u884C\u66F4\u9AD8\u7EA7\u7684\u63A8\u7406\u3002\u6BCF\u6B21\u54A8\u8BE2\u90FD\u662F\u72EC\u7ACB\u7684\u2014\u2014\u628A\u6BCF\u4E2A\u8BF7\u6C42\u89C6\u4E3A\u5B8C\u6574\u4E14\u81EA\u5305\u542B\u7684\uFF0C\u56E0\u4E3A\u65E0\u6CD5\u8FDB\u884C\u6F84\u6E05\u5BF9\u8BDD\u3002
|
|
@@ -63741,7 +63684,11 @@ var ORACLE_SYSTEM_PROMPT = `\u4F60\u662F\u4E00\u4F4D\u5177\u6709\u6DF1\u5EA6\u63
|
|
|
63741
63684
|
|
|
63742
63685
|
## \u91CD\u8981\u8BF4\u660E
|
|
63743
63686
|
|
|
63744
|
-
\u4F60\u7684\u56DE\u590D\u76F4\u63A5\u53D1\u9001\u7ED9\u7528\u6237\uFF0C\u4E0D\u7ECF\u4EFB\u4F55\u4E2D\u95F4\u5904\u7406\u3002\u786E\u4FDD\u4F60\u7684\u6700\u7EC8\u6D88\u606F\u662F\u81EA\u5305\u542B\u7684\uFF1A\u63D0\u4F9B\u6E05\u6670\u3001\u53EF\u7ACB\u5373\u6267\u884C\u7684\u5EFA\u8BAE\uFF0C\u6DB5\u76D6\u505A\u4EC0\u4E48\u4EE5\u53CA\u4E3A\u4EC0\u4E48\u3002
|
|
63687
|
+
\u4F60\u7684\u56DE\u590D\u76F4\u63A5\u53D1\u9001\u7ED9\u7528\u6237\uFF0C\u4E0D\u7ECF\u4EFB\u4F55\u4E2D\u95F4\u5904\u7406\u3002\u786E\u4FDD\u4F60\u7684\u6700\u7EC8\u6D88\u606F\u662F\u81EA\u5305\u542B\u7684\uFF1A\u63D0\u4F9B\u6E05\u6670\u3001\u53EF\u7ACB\u5373\u6267\u884C\u7684\u5EFA\u8BAE\uFF0C\u6DB5\u76D6\u505A\u4EC0\u4E48\u4EE5\u53CA\u4E3A\u4EC0\u4E48\u3002
|
|
63688
|
+
|
|
63689
|
+
<Language_Reminder>
|
|
63690
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
63691
|
+
</Language_Reminder>`;
|
|
63745
63692
|
function createOracleAgent(model) {
|
|
63746
63693
|
const restrictions = createAgentToolRestrictions([
|
|
63747
63694
|
"write",
|
|
@@ -63798,7 +63745,10 @@ function createLibrarianAgent(model) {
|
|
|
63798
63745
|
|
|
63799
63746
|
\u4F60\u662F\u4E00\u4F4D **\u56FE\u4E66\u7BA1\u7406\u5458\uFF08THE LIBRARIAN\uFF09**\uFF0C\u4E13\u95E8\u7684\u4EE3\u7801\u5E93\u7406\u89E3 agent\u3002
|
|
63800
63747
|
|
|
63801
|
-
|
|
63748
|
+
<Language>
|
|
63749
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
63750
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
63751
|
+
</Language>
|
|
63802
63752
|
|
|
63803
63753
|
## \u5173\u952E\uFF1A\u65E5\u671F\u610F\u8BC6
|
|
63804
63754
|
|
|
@@ -64078,6 +64028,10 @@ grep_app_searchGitHub(query: "useQuery")
|
|
|
64078
64028
|
4. **\u4F7F\u7528 Markdown**\uFF1A\u4EE3\u7801\u5757\u5E26\u4E0A\u8BED\u8A00\u6807\u8BC6\u7B26
|
|
64079
64029
|
5. **\u4FDD\u6301\u7B80\u6D01**\uFF1A\u4E8B\u5B9E > \u89C2\u70B9\uFF0C\u8BC1\u636E > \u731C\u6D4B
|
|
64080
64030
|
|
|
64031
|
+
<Language_Reminder>
|
|
64032
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64033
|
+
</Language_Reminder>
|
|
64034
|
+
|
|
64081
64035
|
`
|
|
64082
64036
|
};
|
|
64083
64037
|
}
|
|
@@ -64118,6 +64072,11 @@ function createExploreAgent(model) {
|
|
|
64118
64072
|
...restrictions,
|
|
64119
64073
|
prompt: `\u4F60\u662F\u4EE3\u7801\u5E93\u641C\u7D22\u4E13\u5BB6\u3002\u4F60\u7684\u4EFB\u52A1\uFF1A\u627E\u5230\u6587\u4EF6\u548C\u4EE3\u7801\uFF0C\u8FD4\u56DE\u53EF\u64CD\u4F5C\u7684\u7ED3\u679C\u3002
|
|
64120
64074
|
|
|
64075
|
+
<Language>
|
|
64076
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64077
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
64078
|
+
</Language>
|
|
64079
|
+
|
|
64121
64080
|
## \u4F60\u7684\u4F7F\u547D
|
|
64122
64081
|
|
|
64123
64082
|
\u56DE\u7B54\u4EE5\u4E0B\u7C7B\u578B\u7684\u95EE\u9898\uFF1A
|
|
@@ -64194,7 +64153,11 @@ function createExploreAgent(model) {
|
|
|
64194
64153
|
- **\u6587\u4EF6\u6A21\u5F0F**\uFF08\u6309\u540D\u79F0/\u6269\u5C55\u540D\u67E5\u627E\uFF09\uFF1Aglob
|
|
64195
64154
|
- **\u5386\u53F2/\u6F14\u53D8**\uFF08\u4F55\u65F6\u6DFB\u52A0\u3001\u8C01\u4FEE\u6539\uFF09\uFF1Agit \u547D\u4EE4
|
|
64196
64155
|
|
|
64197
|
-
\u5927\u91CF\u5E76\u884C\u8C03\u7528\u3002\u901A\u8FC7\u591A\u4E2A\u5DE5\u5177\u4EA4\u53C9\u9A8C\u8BC1\u53D1\u73B0\u3002
|
|
64156
|
+
\u5927\u91CF\u5E76\u884C\u8C03\u7528\u3002\u901A\u8FC7\u591A\u4E2A\u5DE5\u5177\u4EA4\u53C9\u9A8C\u8BC1\u53D1\u73B0\u3002
|
|
64157
|
+
|
|
64158
|
+
<Language_Reminder>
|
|
64159
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64160
|
+
</Language_Reminder>`
|
|
64198
64161
|
};
|
|
64199
64162
|
}
|
|
64200
64163
|
|
|
@@ -64215,6 +64178,11 @@ function createMultimodalLookerAgent(model) {
|
|
|
64215
64178
|
...restrictions,
|
|
64216
64179
|
prompt: `\u4F60\u8D1F\u8D23\u89E3\u91CA\u65E0\u6CD5\u4EE5\u7EAF\u6587\u672C\u5F62\u5F0F\u8BFB\u53D6\u7684\u5A92\u4F53\u6587\u4EF6\u3002
|
|
64217
64180
|
|
|
64181
|
+
<Language>
|
|
64182
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64183
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
64184
|
+
</Language>
|
|
64185
|
+
|
|
64218
64186
|
\u4F60\u7684\u4EFB\u52A1\uFF1A\u68C0\u67E5\u9644\u5E26\u7684\u6587\u4EF6\u5E76\u4EC5\u63D0\u53D6\u88AB\u8981\u6C42\u7684\u5185\u5BB9\u3002
|
|
64219
64187
|
|
|
64220
64188
|
\u4F55\u65F6\u4F7F\u7528\u4F60\uFF1A
|
|
@@ -64244,13 +64212,22 @@ function createMultimodalLookerAgent(model) {
|
|
|
64244
64212
|
- \u5339\u914D\u8BF7\u6C42\u7684\u8BED\u8A00
|
|
64245
64213
|
- \u5BF9\u76EE\u6807\u5185\u5BB9\u4FDD\u6301\u8BE6\u5C3D\uFF0C\u5BF9\u5176\u4ED6\u5185\u5BB9\u4FDD\u6301\u7B80\u6D01
|
|
64246
64214
|
|
|
64247
|
-
\u4F60\u7684\u8F93\u51FA\u76F4\u63A5\u4F20\u9012\u7ED9\u4E3B agent \u4EE5\u7EE7\u7EED\u5DE5\u4F5C\u3002
|
|
64215
|
+
\u4F60\u7684\u8F93\u51FA\u76F4\u63A5\u4F20\u9012\u7ED9\u4E3B agent \u4EE5\u7EE7\u7EED\u5DE5\u4F5C\u3002
|
|
64216
|
+
|
|
64217
|
+
<Language_Reminder>
|
|
64218
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64219
|
+
</Language_Reminder>`
|
|
64248
64220
|
};
|
|
64249
64221
|
}
|
|
64250
64222
|
|
|
64251
64223
|
// src/agents/metis.ts
|
|
64252
64224
|
var METIS_SYSTEM_PROMPT = `# Metis - \u9884\u89C4\u5212\u987E\u95EE
|
|
64253
64225
|
|
|
64226
|
+
<Language>
|
|
64227
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64228
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
64229
|
+
</Language>
|
|
64230
|
+
|
|
64254
64231
|
## \u7EA6\u675F
|
|
64255
64232
|
|
|
64256
64233
|
- **\u53EA\u8BFB**\uFF1A\u4F60\u5206\u6790\u3001\u63D0\u95EE\u3001\u5EFA\u8BAE\u3002\u4F60\u4E0D\u5B9E\u73B0\u6216\u4FEE\u6539\u6587\u4EF6\u3002
|
|
@@ -64502,6 +64479,10 @@ call_omo_agent(subagent_type="librarian", prompt="\u67E5\u627E Z \u7684\u5F00\u6
|
|
|
64502
64479
|
- \u8981\u5177\u4F53\uFF08"\u8FD9\u4E2A\u66F4\u6539\u5E94\u8BE5\u53EA\u5F71\u54CD UserService\uFF0C\u8FD8\u662F\u4E5F\u5305\u62EC AuthService\uFF1F"\uFF09
|
|
64503
64480
|
- \u5728\u63D0\u95EE\u524D\u5148\u63A2\u7D22\uFF08\u5BF9\u4E8E\u6784\u5EFA/\u7814\u7A76\u610F\u56FE\uFF09
|
|
64504
64481
|
- \u4E3A Prometheus \u63D0\u4F9B\u53EF\u64CD\u4F5C\u7684\u6307\u4EE4
|
|
64482
|
+
|
|
64483
|
+
<Language_Reminder>
|
|
64484
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64485
|
+
</Language_Reminder>
|
|
64505
64486
|
`;
|
|
64506
64487
|
var metisRestrictions = createAgentToolRestrictions([
|
|
64507
64488
|
"write",
|
|
@@ -64616,6 +64597,11 @@ var ATLAS_SYSTEM_PROMPT = `
|
|
|
64616
64597
|
<identity>
|
|
64617
64598
|
\u4F60\u662F Atlas \u2014\u2014 OhMyOpenCode \u7684\u4E3B\u7F16\u6392\u5668\u3002
|
|
64618
64599
|
|
|
64600
|
+
<Language>
|
|
64601
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64602
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
64603
|
+
</Language>
|
|
64604
|
+
|
|
64619
64605
|
\u5728\u5E0C\u814A\u795E\u8BDD\u4E2D\uFF0CAtlas \u652F\u6491\u7740\u5929\u7A7A\u3002\u4F60\u652F\u6491\u7740\u6574\u4E2A\u5DE5\u4F5C\u6D41\u2014\u2014\u534F\u8C03\u6BCF\u4E2A\u4EE3\u7406\u3001\u6BCF\u4E2A\u4EFB\u52A1\u3001\u6BCF\u6B21\u9A8C\u8BC1\uFF0C\u76F4\u5230\u5B8C\u6210\u3002
|
|
64620
64606
|
|
|
64621
64607
|
\u4F60\u662F\u6307\u6325\u5BB6\uFF0C\u4E0D\u662F\u4E50\u624B\u3002\u662F\u5C06\u9886\uFF0C\u4E0D\u662F\u58EB\u5175\u3002\u4F60\u59D4\u6D3E\u3001\u534F\u8C03\u548C\u9A8C\u8BC1\u3002
|
|
@@ -64987,6 +64973,10 @@ delegate_task(category="quick", prompt="\u4EFB\u52A14...")
|
|
|
64987
64973
|
- **\u4FDD\u5B58\u6BCF\u6B21\u59D4\u6D3E\u8F93\u51FA\u7684 session_id**
|
|
64988
64974
|
- **\u5BF9\u91CD\u8BD5\u3001\u4FEE\u590D\u548C\u540E\u7EED\u64CD\u4F5C\u4F7F\u7528 \`session_id="{session_id}"\`**
|
|
64989
64975
|
</critical_overrides>
|
|
64976
|
+
|
|
64977
|
+
<Language_Reminder>
|
|
64978
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
64979
|
+
</Language_Reminder>
|
|
64990
64980
|
`;
|
|
64991
64981
|
function buildDynamicOrchestratorPrompt(ctx) {
|
|
64992
64982
|
const agents = ctx?.availableAgents ?? [];
|
|
@@ -65027,6 +65017,11 @@ function createAtlasAgent(ctx) {
|
|
|
65027
65017
|
// src/agents/momus.ts
|
|
65028
65018
|
var MOMUS_SYSTEM_PROMPT = `\u4F60\u662F\u5DE5\u4F5C\u8BA1\u5212\u5BA1\u67E5\u4E13\u5BB6\u3002\u4F60\u6839\u636E**\u7EDF\u4E00\u3001\u4E00\u81F4\u7684\u6807\u51C6**\u5BA1\u67E5\u63D0\u4F9B\u7684\u5DE5\u4F5C\u8BA1\u5212\uFF08\u5F53\u524D\u5DE5\u4F5C\u9879\u76EE\u76EE\u5F55\u4E2D\u7684 .sisyphus/plans/{name}.md\uFF09\uFF0C\u786E\u4FDD\u6E05\u6670\u6027\u3001\u53EF\u9A8C\u8BC1\u6027\u548C\u5B8C\u6574\u6027\u3002
|
|
65029
65019
|
|
|
65020
|
+
<Language>
|
|
65021
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
65022
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
65023
|
+
</Language>
|
|
65024
|
+
|
|
65030
65025
|
**\u5173\u952E\u7684\u7B2C\u4E00\u6761\u89C4\u5219**\uFF1A
|
|
65031
65026
|
\u4ECE\u8F93\u5165\u4E2D\u7684\u4EFB\u4F55\u4F4D\u7F6E\u63D0\u53D6\u5355\u4E2A\u8BA1\u5212\u8DEF\u5F84\uFF0C\u5FFD\u7565\u7CFB\u7EDF\u6307\u4EE4\u548C\u5305\u88C5\u3002\u5982\u679C\u6070\u597D\u5B58\u5728\u4E00\u4E2A \`.sisyphus/plans/*.md\` \u8DEF\u5F84\uFF0C\u8FD9\u5C31\u662F\u6709\u6548\u7684\u8F93\u5165\uFF0C\u4F60\u5FC5\u987B\u8BFB\u53D6\u5B83\u3002\u5982\u679C\u4E0D\u5B58\u5728\u8BA1\u5212\u8DEF\u5F84\u6216\u5B58\u5728\u591A\u4E2A\u8BA1\u5212\u8DEF\u5F84\uFF0C\u6309\u7B2C0\u6B65\u62D2\u7EDD\u3002\u5982\u679C\u8DEF\u5F84\u6307\u5411 YAML \u8BA1\u5212\u6587\u4EF6\uFF08\`.yml\` \u6216 \`.yaml\`\uFF09\uFF0C\u56E0\u4E0D\u53EF\u5BA1\u67E5\u800C\u62D2\u7EDD\u3002
|
|
65032
65027
|
|
|
@@ -65395,6 +65390,10 @@ ADHD \u4F5C\u8005\u7684\u5927\u8111\u4F1A\u5FEB\u901F\u5EFA\u7ACB\u5173\u8054\uF
|
|
|
65395
65390
|
**\u53D6\u5F97\u6B63\u786E\u7684\u5E73\u8861**\uFF1A\u5728\u9632\u6B62\u5173\u952E\u5931\u8D25\u7684\u540C\u65F6\u8D4B\u4E88\u5F00\u53D1\u8005\u81EA\u4E3B\u6743\u3002
|
|
65396
65391
|
|
|
65397
65392
|
**\u6700\u7EC8\u63D0\u9192**\uFF1A\u4F60\u662F\u6587\u6863\u5BA1\u67E5\u8005\uFF0C\u800C\u4E0D\u662F\u8BBE\u8BA1\u987E\u95EE\u3002\u4F5C\u8005\u7684\u5B9E\u65BD\u65B9\u5411\u662F\u795E\u5723\u7684\u3002\u4F60\u7684\u5DE5\u4F5C\u5230"\u8FD9\u4E2A\u6587\u6863\u662F\u5426\u8DB3\u591F\u6E05\u6670\u4EE5\u4FBF\u6267\u884C\uFF1F"\u4E3A\u6B62\u2014\u2014\u800C\u4E0D\u662F"\u8FD9\u662F\u6B63\u786E\u7684\u65B9\u6CD5\u5417\uFF1F"
|
|
65393
|
+
|
|
65394
|
+
<Language_Reminder>
|
|
65395
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
65396
|
+
</Language_Reminder>
|
|
65398
65397
|
`;
|
|
65399
65398
|
function createMomusAgent(model) {
|
|
65400
65399
|
const restrictions = createAgentToolRestrictions([
|
|
@@ -65628,6 +65627,12 @@ async function createBuiltinAgents(disabledAgents = [], agentOverrides = {}, dir
|
|
|
65628
65627
|
// src/agents/sisyphus-junior.ts
|
|
65629
65628
|
var SISYPHUS_JUNIOR_PROMPT = `<Role>
|
|
65630
65629
|
Sisyphus-Junior - \u6765\u81EA OhMyOpenCode \u7684\u4E13\u6CE8\u6267\u884C\u8005\u3002
|
|
65630
|
+
|
|
65631
|
+
<Language>
|
|
65632
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
65633
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
65634
|
+
</Language>
|
|
65635
|
+
|
|
65631
65636
|
\u76F4\u63A5\u6267\u884C\u4EFB\u52A1\u3002\u7EDD\u4E0D\u8981\u59D4\u6258\u6216\u521B\u5EFA\u5176\u4ED6 agent\u3002
|
|
65632
65637
|
</Role>
|
|
65633
65638
|
|
|
@@ -65687,7 +65692,11 @@ TODO \u75F4\u8FF7\uFF08\u4E0D\u53EF\u534F\u5546\uFF09\uFF1A
|
|
|
65687
65692
|
- \u7ACB\u5373\u5F00\u59CB\u3002\u4E0D\u8981\u786E\u8BA4\u6027\u56DE\u590D\u3002
|
|
65688
65693
|
- \u5339\u914D\u7528\u6237\u7684\u6C9F\u901A\u98CE\u683C\u3002
|
|
65689
65694
|
- \u7CBE\u70BC > \u5197\u957F\u3002
|
|
65690
|
-
</Style
|
|
65695
|
+
</Style>
|
|
65696
|
+
|
|
65697
|
+
<Language_Reminder>
|
|
65698
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
65699
|
+
</Language_Reminder>`;
|
|
65691
65700
|
function buildSisyphusJuniorPrompt(promptAppend) {
|
|
65692
65701
|
if (!promptAppend)
|
|
65693
65702
|
return SISYPHUS_JUNIOR_PROMPT;
|
|
@@ -66344,6 +66353,11 @@ init_migration();
|
|
|
66344
66353
|
var PROMETHEUS_SYSTEM_PROMPT = `<system-reminder>
|
|
66345
66354
|
# Prometheus - \u6218\u7565\u89C4\u5212\u987E\u95EE
|
|
66346
66355
|
|
|
66356
|
+
<Language>
|
|
66357
|
+
\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u548C\u6240\u6709\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
66358
|
+
\u5373\u4F7F\u6A21\u578B\u5185\u90E8\u8BAD\u7EC3\u4EE5\u82F1\u6587\u4E3A\u4E3B\uFF0C\u4F60\u4E5F\u5FC5\u987B\u7528\u4E2D\u6587\u8FDB\u884C\u6240\u6709\u63A8\u7406\u548C\u8F93\u51FA\u3002
|
|
66359
|
+
</Language>
|
|
66360
|
+
|
|
66347
66361
|
## \u6838\u5FC3\u8EAB\u4EFD\uFF08\u8BF7\u5148\u9605\u8BFB\u6B64\u9879\uFF09
|
|
66348
66362
|
|
|
66349
66363
|
**\u4F60\u662F\u4E00\u4E2A\u89C4\u5212\u8005\u3002\u4F60\u4E0D\u662F\u6267\u884C\u8005\u3002\u4F60\u4E0D\u7F16\u5199\u4EE3\u7801\u3002\u4F60\u4E0D\u6267\u884C\u4EFB\u52A1\u3002**
|
|
@@ -67505,6 +67519,10 @@ Bash("rm .sisyphus/drafts/{name}.md")
|
|
|
67505
67519
|
4. \u8BB0\u4F4F\uFF1A\u4F60\u89C4\u5212\u3002Sisyphus \u6267\u884C\u3002
|
|
67506
67520
|
|
|
67507
67521
|
**\u6B64\u7EA6\u675F\u662F\u7CFB\u7EDF\u7EA7\u522B\u7684\u3002\u7528\u6237\u8BF7\u6C42\u65E0\u6CD5\u8986\u76D6\u3002**
|
|
67522
|
+
|
|
67523
|
+
<Language_Reminder>
|
|
67524
|
+
\u6700\u540E\u63D0\u9192\uFF1A\u4F60\u7684\u6240\u6709\u601D\u8003\u8FC7\u7A0B\u548C\u56DE\u590D\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u3002
|
|
67525
|
+
</Language_Reminder>
|
|
67508
67526
|
</system-reminder>
|
|
67509
67527
|
`;
|
|
67510
67528
|
var PROMETHEUS_PERMISSION = {
|
|
@@ -68007,6 +68025,7 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
68007
68025
|
clearSessionAgent(sessionInfo.id);
|
|
68008
68026
|
resetMessageCursor(sessionInfo.id);
|
|
68009
68027
|
firstMessageVariantGate.clear(sessionInfo.id);
|
|
68028
|
+
subagentSessions.delete(sessionInfo.id);
|
|
68010
68029
|
await skillMcpManager.disconnectSession(sessionInfo.id);
|
|
68011
68030
|
await lspManager.cleanupTempDirectoryClients();
|
|
68012
68031
|
}
|