skill-creator 2.0.2 → 2.1.0
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/CHANGELOG.md +56 -0
- package/README-zh.md +298 -0
- package/README.md +108 -112
- package/dist/cli.js +723 -320
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +637 -147
- package/dist/daemon.js.map +4 -4
- package/dist/package.json +1 -1
- package/dist/webui/_app/immutable/assets/0.BfQ9GZ7H.css +2 -0
- package/dist/webui/_app/immutable/chunks/{Ce_bE79q.js → 9b6xLvUw.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{DUYTokm-.js → B0yogbIO.js} +1 -1
- package/dist/webui/_app/immutable/chunks/BDe0K-12.js +1 -0
- package/dist/webui/_app/immutable/chunks/{DFx4VmvA.js → BKjuWHgW.js} +4 -4
- package/dist/webui/_app/immutable/chunks/{BFnZD865.js → Bos6D7ir.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{D68T6slS.js → CY3MARMs.js} +1 -1
- package/dist/webui/_app/immutable/chunks/D-ihBChi.js +1 -0
- package/dist/webui/_app/immutable/chunks/{Ce6RiTD3.js → D7i1h2eW.js} +2 -2
- package/dist/webui/_app/immutable/chunks/DFDHkP9N.js +1 -0
- package/dist/webui/_app/immutable/chunks/{CQhmWGDZ.js → DFdxGYRu.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{CnsFCObb.js → Dbn_qXWm.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{CLM6PwBO.js → K56ab8zF.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{C36hgawG.js → NO3Cfsmo.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{DkjKuLZP.js → QU8DIUJz.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{CryWMAmp.js → UsOmL8ol.js} +1 -1
- package/dist/webui/_app/immutable/chunks/{BNZqT8Gb.js → hrRIAQd7.js} +1 -1
- package/dist/webui/_app/immutable/entry/{app.CEIXmsDN.js → app.CkIQoKd-.js} +2 -2
- package/dist/webui/_app/immutable/entry/start.DG-jtr9O.js +1 -0
- package/dist/webui/_app/immutable/nodes/0.DY8kli0K.js +234 -0
- package/dist/webui/_app/immutable/nodes/{1.sVOukQaO.js → 1.DxOotYUD.js} +1 -1
- package/dist/webui/_app/immutable/nodes/{2.Cpm2DXYr.js → 2.BhwY9m4H.js} +1 -1
- package/dist/webui/_app/version.json +1 -1
- package/dist/webui/index.html +15 -15
- package/package.json +26 -23
- package/dist/webui/_app/immutable/assets/0.0XN00VKF.css +0 -2
- package/dist/webui/_app/immutable/chunks/CLVPf5uP.js +0 -1
- package/dist/webui/_app/immutable/chunks/DbA0Nfjq.js +0 -1
- package/dist/webui/_app/immutable/chunks/DrGEPnFY.js +0 -1
- package/dist/webui/_app/immutable/entry/start.A-8tRY5f.js +0 -1
- package/dist/webui/_app/immutable/nodes/0.DtX11nez.js +0 -231
package/dist/daemon.js
CHANGED
|
@@ -1783,28 +1783,28 @@ var init_create_prompt_CIJV_96B = __esm({
|
|
|
1783
1783
|
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
1784
1784
|
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
1785
1785
|
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
1786
|
-
const
|
|
1786
|
+
const z27 = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
1787
1787
|
return [
|
|
1788
1788
|
x * 100,
|
|
1789
1789
|
y * 100,
|
|
1790
|
-
|
|
1790
|
+
z27 * 100
|
|
1791
1791
|
];
|
|
1792
1792
|
};
|
|
1793
1793
|
convert$1.rgb.lab = function(rgb) {
|
|
1794
1794
|
const xyz = convert$1.rgb.xyz(rgb);
|
|
1795
1795
|
let x = xyz[0];
|
|
1796
1796
|
let y = xyz[1];
|
|
1797
|
-
let
|
|
1797
|
+
let z27 = xyz[2];
|
|
1798
1798
|
x /= 95.047;
|
|
1799
1799
|
y /= 100;
|
|
1800
|
-
|
|
1800
|
+
z27 /= 108.883;
|
|
1801
1801
|
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
1802
1802
|
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
1803
|
-
|
|
1803
|
+
z27 = z27 > 8856e-6 ? z27 ** (1 / 3) : 7.787 * z27 + 16 / 116;
|
|
1804
1804
|
return [
|
|
1805
1805
|
116 * y - 16,
|
|
1806
1806
|
500 * (x - y),
|
|
1807
|
-
200 * (y -
|
|
1807
|
+
200 * (y - z27)
|
|
1808
1808
|
];
|
|
1809
1809
|
};
|
|
1810
1810
|
convert$1.hsl.rgb = function(hsl) {
|
|
@@ -2001,13 +2001,13 @@ var init_create_prompt_CIJV_96B = __esm({
|
|
|
2001
2001
|
convert$1.xyz.rgb = function(xyz) {
|
|
2002
2002
|
const x = xyz[0] / 100;
|
|
2003
2003
|
const y = xyz[1] / 100;
|
|
2004
|
-
const
|
|
2004
|
+
const z27 = xyz[2] / 100;
|
|
2005
2005
|
let r;
|
|
2006
2006
|
let g;
|
|
2007
2007
|
let b;
|
|
2008
|
-
r = x * 3.2406 + y * -1.5372 +
|
|
2009
|
-
g = x * -0.9689 + y * 1.8758 +
|
|
2010
|
-
b = x * 0.0557 + y * -0.204 +
|
|
2008
|
+
r = x * 3.2406 + y * -1.5372 + z27 * -0.4986;
|
|
2009
|
+
g = x * -0.9689 + y * 1.8758 + z27 * 0.0415;
|
|
2010
|
+
b = x * 0.0557 + y * -0.204 + z27 * 1.057;
|
|
2011
2011
|
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
2012
2012
|
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
2013
2013
|
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
@@ -2023,17 +2023,17 @@ var init_create_prompt_CIJV_96B = __esm({
|
|
|
2023
2023
|
convert$1.xyz.lab = function(xyz) {
|
|
2024
2024
|
let x = xyz[0];
|
|
2025
2025
|
let y = xyz[1];
|
|
2026
|
-
let
|
|
2026
|
+
let z27 = xyz[2];
|
|
2027
2027
|
x /= 95.047;
|
|
2028
2028
|
y /= 100;
|
|
2029
|
-
|
|
2029
|
+
z27 /= 108.883;
|
|
2030
2030
|
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
2031
2031
|
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
2032
|
-
|
|
2032
|
+
z27 = z27 > 8856e-6 ? z27 ** (1 / 3) : 7.787 * z27 + 16 / 116;
|
|
2033
2033
|
return [
|
|
2034
2034
|
116 * y - 16,
|
|
2035
2035
|
500 * (x - y),
|
|
2036
|
-
200 * (y -
|
|
2036
|
+
200 * (y - z27)
|
|
2037
2037
|
];
|
|
2038
2038
|
};
|
|
2039
2039
|
convert$1.lab.xyz = function(lab) {
|
|
@@ -2042,23 +2042,23 @@ var init_create_prompt_CIJV_96B = __esm({
|
|
|
2042
2042
|
const b = lab[2];
|
|
2043
2043
|
let x;
|
|
2044
2044
|
let y;
|
|
2045
|
-
let
|
|
2045
|
+
let z27;
|
|
2046
2046
|
y = (l + 16) / 116;
|
|
2047
2047
|
x = a / 500 + y;
|
|
2048
|
-
|
|
2048
|
+
z27 = y - b / 200;
|
|
2049
2049
|
const y2 = y ** 3;
|
|
2050
2050
|
const x2 = x ** 3;
|
|
2051
|
-
const
|
|
2051
|
+
const z28 = z27 ** 3;
|
|
2052
2052
|
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
2053
2053
|
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
2054
|
-
|
|
2054
|
+
z27 = z28 > 8856e-6 ? z28 : (z27 - 16 / 116) / 7.787;
|
|
2055
2055
|
x *= 95.047;
|
|
2056
2056
|
y *= 100;
|
|
2057
|
-
|
|
2057
|
+
z27 *= 108.883;
|
|
2058
2058
|
return [
|
|
2059
2059
|
x,
|
|
2060
2060
|
y,
|
|
2061
|
-
|
|
2061
|
+
z27
|
|
2062
2062
|
];
|
|
2063
2063
|
};
|
|
2064
2064
|
convert$1.lab.lch = function(lab) {
|
|
@@ -36840,6 +36840,154 @@ var init_dsh_profile_support = __esm({
|
|
|
36840
36840
|
}
|
|
36841
36841
|
});
|
|
36842
36842
|
|
|
36843
|
+
// src/shared/contracts/agent-roles.ts
|
|
36844
|
+
function agentRoleToolName(slug) {
|
|
36845
|
+
return `${AGENT_ROLE_TOOL_PREFIX}${slug}`;
|
|
36846
|
+
}
|
|
36847
|
+
function mcpCapabilityToolName(capabilityBase, authority) {
|
|
36848
|
+
return `mcp__skill-creator__${capabilityBase}${authority === "mutation" ? "_propose" : ""}`;
|
|
36849
|
+
}
|
|
36850
|
+
var AGENT_ROLE_PROMPT_VERSION, AGENT_ROLE_TOOL_PREFIX, AGENT_ROLES, AGENT_MODE_ROLES;
|
|
36851
|
+
var init_agent_roles = __esm({
|
|
36852
|
+
"src/shared/contracts/agent-roles.ts"() {
|
|
36853
|
+
"use strict";
|
|
36854
|
+
AGENT_ROLE_PROMPT_VERSION = "1";
|
|
36855
|
+
AGENT_ROLE_TOOL_PREFIX = "role_";
|
|
36856
|
+
AGENT_ROLES = {
|
|
36857
|
+
reviewer: {
|
|
36858
|
+
name: "Reviewer",
|
|
36859
|
+
description: "Reads local skills and reports concrete improvement findings (read-only).",
|
|
36860
|
+
capabilities: [
|
|
36861
|
+
{ base: "workspace_list", authority: "readonly" },
|
|
36862
|
+
{ base: "skills_list", authority: "readonly" },
|
|
36863
|
+
{ base: "skills_info", authority: "readonly" },
|
|
36864
|
+
{ base: "skills_validate", authority: "readonly" },
|
|
36865
|
+
{ base: "creator_load", authority: "readonly" }
|
|
36866
|
+
]
|
|
36867
|
+
},
|
|
36868
|
+
researcher: {
|
|
36869
|
+
name: "Researcher",
|
|
36870
|
+
description: "Scans Git skill sources and analyzes fit against requirements (read-only).",
|
|
36871
|
+
capabilities: [
|
|
36872
|
+
{ base: "workspace_list", authority: "readonly" },
|
|
36873
|
+
{ base: "skills_list", authority: "readonly" },
|
|
36874
|
+
{ base: "skills_info", authority: "readonly" },
|
|
36875
|
+
{ base: "skills_validate", authority: "readonly" },
|
|
36876
|
+
{ base: "repository_scan", authority: "readonly" },
|
|
36877
|
+
{ base: "repository_sources_list", authority: "readonly" }
|
|
36878
|
+
]
|
|
36879
|
+
},
|
|
36880
|
+
writer: {
|
|
36881
|
+
name: "Writer",
|
|
36882
|
+
description: "Drafts and edits SKILL.md content; every mutation lands as a proposal for human approval.",
|
|
36883
|
+
capabilities: [
|
|
36884
|
+
{ base: "workspace_list", authority: "readonly" },
|
|
36885
|
+
{ base: "skills_list", authority: "readonly" },
|
|
36886
|
+
{ base: "skills_info", authority: "readonly" },
|
|
36887
|
+
{ base: "skills_validate", authority: "readonly" },
|
|
36888
|
+
{ base: "creator_load", authority: "readonly" },
|
|
36889
|
+
{ base: "creator_revisions", authority: "readonly" },
|
|
36890
|
+
{ base: "creator_save", authority: "mutation" },
|
|
36891
|
+
{ base: "creator_remove", authority: "mutation" }
|
|
36892
|
+
]
|
|
36893
|
+
}
|
|
36894
|
+
};
|
|
36895
|
+
AGENT_MODE_ROLES = {
|
|
36896
|
+
create: ["reviewer", "writer"],
|
|
36897
|
+
manage: ["reviewer", "writer"],
|
|
36898
|
+
explore: ["researcher", "reviewer"],
|
|
36899
|
+
free: ["reviewer", "researcher", "writer"]
|
|
36900
|
+
};
|
|
36901
|
+
}
|
|
36902
|
+
});
|
|
36903
|
+
|
|
36904
|
+
// src/daemon/kernel/agent-roles.ts
|
|
36905
|
+
function agentRoleRowsYaml() {
|
|
36906
|
+
const lines = [];
|
|
36907
|
+
for (const slug of Object.keys(AGENT_ROLES)) {
|
|
36908
|
+
const role = AGENT_ROLES[slug];
|
|
36909
|
+
lines.push(
|
|
36910
|
+
`- id: tool-role-${slug}`,
|
|
36911
|
+
" name: '@deepseek-ai/dsh-tool-subagent'",
|
|
36912
|
+
" config:",
|
|
36913
|
+
" provider: spawn",
|
|
36914
|
+
` toolName: ${agentRoleToolName(slug)}`,
|
|
36915
|
+
" backgroundMode: continuable",
|
|
36916
|
+
" maxDepth: 1",
|
|
36917
|
+
" persona: |-"
|
|
36918
|
+
);
|
|
36919
|
+
for (const personaLine of AGENT_ROLE_PERSONAS[slug].split("\n")) {
|
|
36920
|
+
lines.push(` ${personaLine}`);
|
|
36921
|
+
}
|
|
36922
|
+
lines.push(" toolFilter:", " deny:");
|
|
36923
|
+
for (const denied2 of ROLE_TOOL_DENY) lines.push(` - ${denied2}`);
|
|
36924
|
+
lines.push(" allow:");
|
|
36925
|
+
for (const capability of role.capabilities) {
|
|
36926
|
+
lines.push(` - ${mcpCapabilityToolName(capability.base, capability.authority)}`);
|
|
36927
|
+
}
|
|
36928
|
+
lines.push("");
|
|
36929
|
+
}
|
|
36930
|
+
return lines.join("\n");
|
|
36931
|
+
}
|
|
36932
|
+
var ROLE_TOOL_DENY, REVIEWER_PERSONA, RESEARCHER_PERSONA, WRITER_PERSONA, AGENT_ROLE_PERSONAS;
|
|
36933
|
+
var init_agent_roles2 = __esm({
|
|
36934
|
+
"src/daemon/kernel/agent-roles.ts"() {
|
|
36935
|
+
"use strict";
|
|
36936
|
+
init_agent_roles();
|
|
36937
|
+
ROLE_TOOL_DENY = ["ask_user_question"];
|
|
36938
|
+
REVIEWER_PERSONA = `# Role: Reviewer (v${AGENT_ROLE_PROMPT_VERSION})
|
|
36939
|
+
|
|
36940
|
+
You review local skills and report concrete, actionable findings. You read through
|
|
36941
|
+
the skill-creator capability face (skills_list, skills_info, skills_validate,
|
|
36942
|
+
creator_load) and judge trigger contracts, scope discipline, and structure.
|
|
36943
|
+
|
|
36944
|
+
## Review law
|
|
36945
|
+
- Findings must cite the exact skill and the exact defect: vague advice is a failure.
|
|
36946
|
+
- Weigh the frontmatter description as the trigger contract: does it say what the
|
|
36947
|
+
skill does and when to use it, in the third person, optimized for retrieval?
|
|
36948
|
+
- Flag progressive-disclosure violations (kitchen-sink SKILL.md), secrets, and
|
|
36949
|
+
machine-specific absolute paths.
|
|
36950
|
+
- You propose nothing and write nothing: report findings; the parent decides.
|
|
36951
|
+
|
|
36952
|
+
## Report shape
|
|
36953
|
+
Return a ranked findings list (severity, skill, defect, suggested fix). If the
|
|
36954
|
+
library is clean, say so explicitly instead of inventing issues.`;
|
|
36955
|
+
RESEARCHER_PERSONA = `# Role: Researcher (v${AGENT_ROLE_PROMPT_VERSION})
|
|
36956
|
+
|
|
36957
|
+
You scan Git skill sources (repository_scan, repository_sources_list) and analyze
|
|
36958
|
+
whether candidate skills fit the stated requirements. You compare against what is
|
|
36959
|
+
already installed (skills_list, skills_info) to avoid duplicates.
|
|
36960
|
+
|
|
36961
|
+
## Research law
|
|
36962
|
+
- Turn the requirement into explicit criteria before scanning; state them back
|
|
36963
|
+
in one line.
|
|
36964
|
+
- A skill that matches the letter but not the intent is a rejection; say which
|
|
36965
|
+
criterion failed.
|
|
36966
|
+
- Red flags end a candidacy: secrets, machine-specific paths, vague triggers,
|
|
36967
|
+
kitchen-sink scope.
|
|
36968
|
+
- You install nothing: shortlist with evidence and hand the decision back.`;
|
|
36969
|
+
WRITER_PERSONA = `# Role: Writer (v${AGENT_ROLE_PROMPT_VERSION})
|
|
36970
|
+
|
|
36971
|
+
You draft and edit SKILL.md content in imported workspaces. Reads go through
|
|
36972
|
+
skills_list / skills_info / creator_load; every mutation goes through the
|
|
36973
|
+
propose variants (creator_save / creator_remove) \u2014 a human approves each change
|
|
36974
|
+
in the Skill Creator UI before it touches disk.
|
|
36975
|
+
|
|
36976
|
+
## Authoring law
|
|
36977
|
+
- The frontmatter description is the trigger contract: third person, what it does
|
|
36978
|
+
and when to use it, optimized for retrieval.
|
|
36979
|
+
- Progressive disclosure: lean procedural SKILL.md; reference detail goes to
|
|
36980
|
+
bundled files, not long prose.
|
|
36981
|
+
- Never claim a document is saved until its propose result says so.
|
|
36982
|
+
- Respect preferences the human states (language, style, structure).`;
|
|
36983
|
+
AGENT_ROLE_PERSONAS = {
|
|
36984
|
+
reviewer: REVIEWER_PERSONA,
|
|
36985
|
+
researcher: RESEARCHER_PERSONA,
|
|
36986
|
+
writer: WRITER_PERSONA
|
|
36987
|
+
};
|
|
36988
|
+
}
|
|
36989
|
+
});
|
|
36990
|
+
|
|
36843
36991
|
// src/daemon/kernel/dsh-kernel.ts
|
|
36844
36992
|
var dsh_kernel_exports = {};
|
|
36845
36993
|
__export(dsh_kernel_exports, {
|
|
@@ -36929,7 +37077,12 @@ async function bootDshKernel(options2) {
|
|
|
36929
37077
|
" includeShippedRoot: false\n",
|
|
36930
37078
|
"- id: workspace\n",
|
|
36931
37079
|
" name: '@deepseek-ai/dsh-workspace'\n",
|
|
36932
|
-
mcpRow
|
|
37080
|
+
mcpRow,
|
|
37081
|
+
// Roles(dsh-alpha-native-subagents task 2.3):per-role 官方 tool-subagent
|
|
37082
|
+
// 行。角色能力面全是 MCP capability 精确注册名——只在 MCP 桥在场时写入
|
|
37083
|
+
// (无桥时 allow 名不存在,restrict 的实名校验会让 boot 失败;且角色无
|
|
37084
|
+
// MCP 面本就无意义)。
|
|
37085
|
+
...options2.mcp ? [agentRoleRowsYaml()] : []
|
|
36933
37086
|
].join(""),
|
|
36934
37087
|
"utf8"
|
|
36935
37088
|
);
|
|
@@ -36943,13 +37096,7 @@ async function bootDshKernel(options2) {
|
|
|
36943
37096
|
constructed.push(entry);
|
|
36944
37097
|
});
|
|
36945
37098
|
};
|
|
36946
|
-
const ctx = await boot(
|
|
36947
|
-
"skill-creator",
|
|
36948
|
-
configPath,
|
|
36949
|
-
patches,
|
|
36950
|
-
prepare,
|
|
36951
|
-
new URL(".", import.meta.url).href
|
|
36952
|
-
);
|
|
37099
|
+
const ctx = await boot("skill-creator", configPath, patches, prepare);
|
|
36953
37100
|
const treeEntries = [];
|
|
36954
37101
|
for (const entry of ctx.loader?.entries() ?? []) {
|
|
36955
37102
|
treeEntries.push({ id: entry.id, name: entry.options.name });
|
|
@@ -37015,6 +37162,7 @@ var init_dsh_kernel = __esm({
|
|
|
37015
37162
|
"src/daemon/kernel/dsh-kernel.ts"() {
|
|
37016
37163
|
"use strict";
|
|
37017
37164
|
init_dsh_profile_support();
|
|
37165
|
+
init_agent_roles2();
|
|
37018
37166
|
modulePath = fileURLToPath2(import.meta.url);
|
|
37019
37167
|
sourceMode = path19.basename(modulePath) === "dsh-kernel.ts";
|
|
37020
37168
|
repoRoot = sourceMode ? path19.resolve(path19.dirname(modulePath), "../../..") : path19.resolve(path19.dirname(modulePath), "..");
|
|
@@ -37721,7 +37869,7 @@ function providerCatalogEntry(id) {
|
|
|
37721
37869
|
|
|
37722
37870
|
// src/shared/contracts/dsh-runtime.ts
|
|
37723
37871
|
import { z as z7 } from "zod";
|
|
37724
|
-
var DSH_AUDITED_COMMIT = "
|
|
37872
|
+
var DSH_AUDITED_COMMIT = "0a15e36e7f82b6ed45af6fa9759f29b40dcd965d";
|
|
37725
37873
|
var DshCompositionRowSchema = z7.object({
|
|
37726
37874
|
packageName: z7.string().min(1),
|
|
37727
37875
|
lockedVersion: z7.string().min(1),
|
|
@@ -38014,7 +38162,10 @@ var DshSessionStreamFrameKindSchema = z7.enum([
|
|
|
38014
38162
|
"todo-snapshot",
|
|
38015
38163
|
/** 自动压缩标记(daemon 在 turn-end 后按 inputTokens + maxOutputTokens ≥
|
|
38016
38164
|
* contextWindow 阈值自动执行 compact;text = 触发说明,UI 以居中注记渲染)。 */
|
|
38017
|
-
"auto-compact"
|
|
38165
|
+
"auto-compact",
|
|
38166
|
+
/** 子代理目录(父会话 subagent/catalog 事件投影;payload = {childId, mode,
|
|
38167
|
+
* label}——角色 spawn 的可见性帧,settlement 经 user-text 回流)。 */
|
|
38168
|
+
"subagent"
|
|
38018
38169
|
]);
|
|
38019
38170
|
var DshSessionStreamFrameSchema = z7.object({
|
|
38020
38171
|
/** 进程内单调序号(投影视角排序用,非持久协议)。 */
|
|
@@ -38137,11 +38288,38 @@ var AgentPromptFileSchema = z9.union([
|
|
|
38137
38288
|
path: z9.string().min(1)
|
|
38138
38289
|
})
|
|
38139
38290
|
]);
|
|
38291
|
+
var AgentPromptReferenceSchema = z9.discriminatedUnion("kind", [
|
|
38292
|
+
z9.strictObject({
|
|
38293
|
+
kind: z9.literal("file"),
|
|
38294
|
+
/** daemon 可读的绝对路径(realpath + regular file + ≤512KiB + 文本扩展名)。 */
|
|
38295
|
+
path: z9.string().min(1)
|
|
38296
|
+
}),
|
|
38297
|
+
z9.strictObject({
|
|
38298
|
+
kind: z9.literal("session"),
|
|
38299
|
+
/** 被引用的历史会话(排除语义由 UI 持有;daemon 不猜)。 */
|
|
38300
|
+
sessionId: z9.string().min(1)
|
|
38301
|
+
}),
|
|
38302
|
+
z9.strictObject({
|
|
38303
|
+
kind: z9.literal("skill"),
|
|
38304
|
+
/** 技能引用的 server-owned 作用域三元组(`$` 触发;registry 解析 containment)。 */
|
|
38305
|
+
workspaceId: WorkspaceIdSchema,
|
|
38306
|
+
providerId: ProviderIdSchema,
|
|
38307
|
+
skillId: SkillIdSchema
|
|
38308
|
+
})
|
|
38309
|
+
]);
|
|
38140
38310
|
var AgentSessionPromptInputSchema = z9.object({
|
|
38141
38311
|
sessionId: z9.string().min(1),
|
|
38142
38312
|
text: z9.string().max(2e4),
|
|
38143
38313
|
images: z9.array(AgentPromptImageSchema).max(4).default([]),
|
|
38144
|
-
files: z9.array(AgentPromptFileSchema).max(2).default([])
|
|
38314
|
+
files: z9.array(AgentPromptFileSchema).max(2).default([]),
|
|
38315
|
+
/**
|
|
38316
|
+
* 提交模式(W4,官方 submission-policy 语义):queue = next-turn(当前轮
|
|
38317
|
+
* 完成后运行,内核 inbox 排队);steer = next-step(在下一步骤边界转向
|
|
38318
|
+
* 当前轮)。缺省 queue。
|
|
38319
|
+
*/
|
|
38320
|
+
mode: z9.enum(["queue", "steer"]).default("queue"),
|
|
38321
|
+
/** `@` 引用(C1):daemon 展开为 [reference: …] 文本块;缺省无。 */
|
|
38322
|
+
references: z9.array(AgentPromptReferenceSchema).max(4).default([])
|
|
38145
38323
|
}).refine(
|
|
38146
38324
|
// R17 codex P1:files-only 也是合法 prompt(后端文件选择器的主路径)。
|
|
38147
38325
|
(input) => input.text.trim().length > 0 || input.images.length > 0 || input.files.length > 0,
|
|
@@ -38171,6 +38349,36 @@ var AgentSessionStreamResultSchema = z9.object({
|
|
|
38171
38349
|
frames: z9.array(DshSessionStreamFrameSchema),
|
|
38172
38350
|
status: AgentSessionStatusSchema
|
|
38173
38351
|
});
|
|
38352
|
+
var AgentQueueItemSchema = z9.object({
|
|
38353
|
+
/** 内核 UserMessage id(edit/remove/steer 的幂等寻址键)。 */
|
|
38354
|
+
messageId: z9.string().min(1),
|
|
38355
|
+
target: z9.enum(["next-turn", "next-step"]),
|
|
38356
|
+
/** content 文本块拼接(引用/附件块不展开——chip 已在正文 token 中)。 */
|
|
38357
|
+
text: z9.string(),
|
|
38358
|
+
/** image/file 附件块计数(行尾 chip 展示)。 */
|
|
38359
|
+
attachments: z9.number().int().nonnegative()
|
|
38360
|
+
});
|
|
38361
|
+
var AgentQueueListInputSchema = z9.object({ sessionId: z9.string().min(1) });
|
|
38362
|
+
var AgentQueueListResultSchema = z9.object({ items: z9.array(AgentQueueItemSchema) });
|
|
38363
|
+
var AgentQueueUpdateInputSchema = z9.discriminatedUnion("action", [
|
|
38364
|
+
z9.strictObject({
|
|
38365
|
+
sessionId: z9.string().min(1),
|
|
38366
|
+
messageId: z9.string().min(1),
|
|
38367
|
+
action: z9.literal("edit"),
|
|
38368
|
+
text: z9.string().min(1).max(2e4)
|
|
38369
|
+
}),
|
|
38370
|
+
z9.strictObject({
|
|
38371
|
+
sessionId: z9.string().min(1),
|
|
38372
|
+
messageId: z9.string().min(1),
|
|
38373
|
+
action: z9.literal("remove")
|
|
38374
|
+
}),
|
|
38375
|
+
z9.strictObject({
|
|
38376
|
+
sessionId: z9.string().min(1),
|
|
38377
|
+
messageId: z9.string().min(1),
|
|
38378
|
+
action: z9.literal("steer")
|
|
38379
|
+
})
|
|
38380
|
+
]);
|
|
38381
|
+
var AgentQueueUpdateResultSchema = z9.object({ updated: z9.literal(true) });
|
|
38174
38382
|
var AgentSessionsStreamsInputSchema = z9.object({
|
|
38175
38383
|
runId: z9.string().min(1).optional(),
|
|
38176
38384
|
/** 返回最新 N 帧(默认 50,上限 500)。 */
|
|
@@ -39661,6 +39869,16 @@ var rpcContract = oc.errors(RpcErrorDefinitions).router({
|
|
|
39661
39869
|
* 下一次 prompt 以新模式 setup 复活,历史由内核 session log 保留)。 */
|
|
39662
39870
|
setMode: oc.input(AgentSessionSetModeInputSchema).output(AgentSessionSetModeResultSchema)
|
|
39663
39871
|
},
|
|
39872
|
+
/**
|
|
39873
|
+
* 内核 inbox 队列面(C2):queue 真相在 ReactLoopInbox;list 投影待处理项,
|
|
39874
|
+
* update 执行行级 edit/remove/steer(官方 updateQueue 语义)。
|
|
39875
|
+
*/
|
|
39876
|
+
queue: {
|
|
39877
|
+
/** 待处理项(非 live 会话 = 空 items;live next-step + next-turn 有序)。 */
|
|
39878
|
+
list: oc.input(AgentQueueListInputSchema).output(AgentQueueListResultSchema),
|
|
39879
|
+
/** 行级操作;messageId 已消费 = typed NOT_FOUND(竞态可见)。 */
|
|
39880
|
+
update: oc.input(AgentQueueUpdateInputSchema).output(AgentQueueUpdateResultSchema)
|
|
39881
|
+
},
|
|
39664
39882
|
/**
|
|
39665
39883
|
* 后端文件选择器(R17-B):真实路径浏览 + 单文件预览。用户本机自由浏览是
|
|
39666
39884
|
* 功能目的(读面,无 Workspace containment);prompt 附件 path 通道在
|
|
@@ -40445,6 +40663,11 @@ var PREVIEW_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
40445
40663
|
var PREVIEW_TEXT_HEAD_BYTES = 4096;
|
|
40446
40664
|
var PROMPT_IMAGE_MAX_BYTES = 4 * 1024 * 1024;
|
|
40447
40665
|
var PROMPT_FILE_MAX_BYTES = 512 * 1024;
|
|
40666
|
+
function isTextualFileName(name) {
|
|
40667
|
+
return /\.(txt|md|markdown|json|ya?ml|toml|csv|tsv|log|patch|diff|ts|tsx|js|jsx|py|rs|go|java|c|h|cpp|sh|css|html|xml|ini|env)$/i.test(
|
|
40668
|
+
name
|
|
40669
|
+
);
|
|
40670
|
+
}
|
|
40448
40671
|
function toDomainError(error, what, target) {
|
|
40449
40672
|
const code = error?.code;
|
|
40450
40673
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -40728,7 +40951,29 @@ function createAgentFilesService(deps = {}) {
|
|
|
40728
40951
|
}
|
|
40729
40952
|
return { images, files };
|
|
40730
40953
|
}
|
|
40731
|
-
|
|
40954
|
+
async function resolvePromptReferences(input) {
|
|
40955
|
+
const blocks = [];
|
|
40956
|
+
for (const reference of input.references) {
|
|
40957
|
+
const { real, size } = await canonicalRegularFile(reference.path, "reference");
|
|
40958
|
+
if (size > PROMPT_FILE_MAX_BYTES) {
|
|
40959
|
+
throw new DomainError(
|
|
40960
|
+
"INVALID_OPERATION",
|
|
40961
|
+
`"${path5.basename(real)}" exceeds the 512KiB limit.`
|
|
40962
|
+
);
|
|
40963
|
+
}
|
|
40964
|
+
if (!isTextualFileName(path5.basename(real))) {
|
|
40965
|
+
throw new DomainError(
|
|
40966
|
+
"INVALID_OPERATION",
|
|
40967
|
+
`"${path5.basename(real)}" is not a textual file; attach it instead.`
|
|
40968
|
+
);
|
|
40969
|
+
}
|
|
40970
|
+
const text = await readFile2(real, "utf8");
|
|
40971
|
+
blocks.push(`[reference: ${real}]
|
|
40972
|
+
${text.slice(0, 2e5)}`);
|
|
40973
|
+
}
|
|
40974
|
+
return blocks;
|
|
40975
|
+
}
|
|
40976
|
+
return { pickFiles, list: list2, preview: preview2, resolvePromptAttachments, resolvePromptReferences };
|
|
40732
40977
|
}
|
|
40733
40978
|
|
|
40734
40979
|
// src/daemon/creator-service.ts
|
|
@@ -41583,7 +41828,7 @@ function createSkillsCliProbe(options2 = {}) {
|
|
|
41583
41828
|
}
|
|
41584
41829
|
|
|
41585
41830
|
// src/daemon/domain.ts
|
|
41586
|
-
import { join as
|
|
41831
|
+
import { join as join3 } from "node:path";
|
|
41587
41832
|
|
|
41588
41833
|
// src/daemon/skills-update-service.ts
|
|
41589
41834
|
import { createHash as createHash5 } from "node:crypto";
|
|
@@ -46629,10 +46874,11 @@ async function testDshRouteConnection(input, deps = {}) {
|
|
|
46629
46874
|
}
|
|
46630
46875
|
|
|
46631
46876
|
// src/daemon/dsh-host-lifecycle.ts
|
|
46877
|
+
import { join as join2 } from "node:path";
|
|
46632
46878
|
function resolveDefaultDshHome() {
|
|
46633
46879
|
const env2 = process.env.DSH_HOME;
|
|
46634
46880
|
if (env2 && env2.trim() !== "") return env2;
|
|
46635
|
-
return
|
|
46881
|
+
return join2(homeDir(), ".skill-creator", "dsh-home");
|
|
46636
46882
|
}
|
|
46637
46883
|
async function bootForProduction(home, mcp) {
|
|
46638
46884
|
const { bootDshKernel: bootDshKernel2 } = await Promise.resolve().then(() => (init_dsh_kernel(), dsh_kernel_exports));
|
|
@@ -47043,8 +47289,9 @@ function createDshSettingsService(options2 = {}) {
|
|
|
47043
47289
|
|
|
47044
47290
|
// src/daemon/kernel/agent-sessions.ts
|
|
47045
47291
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
47046
|
-
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
47047
|
-
import { z as
|
|
47292
|
+
import { createUserMessage as createUserMessage2 } from "@deepseek-ai/dsh-llm";
|
|
47293
|
+
import { z as z22 } from "zod";
|
|
47294
|
+
init_agent_roles();
|
|
47048
47295
|
init_dsh_kernel();
|
|
47049
47296
|
|
|
47050
47297
|
// src/daemon/kernel/agent-modes.ts
|
|
@@ -47338,6 +47585,53 @@ async function runBootSessionCleanup(deps) {
|
|
|
47338
47585
|
}
|
|
47339
47586
|
}
|
|
47340
47587
|
|
|
47588
|
+
// src/daemon/kernel/agent-queue.ts
|
|
47589
|
+
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
47590
|
+
import { z as z21 } from "zod";
|
|
47591
|
+
var InboxMessageSchema = z21.object({
|
|
47592
|
+
id: z21.string().min(1),
|
|
47593
|
+
source: z21.unknown().optional(),
|
|
47594
|
+
content: z21.array(z21.object({ type: z21.string().min(1), text: z21.string().optional() }).passthrough()).min(1)
|
|
47595
|
+
}).passthrough();
|
|
47596
|
+
function parseInboxMessage(raw) {
|
|
47597
|
+
const checked = InboxMessageSchema.safeParse(raw);
|
|
47598
|
+
return checked.success ? checked.data : null;
|
|
47599
|
+
}
|
|
47600
|
+
function queueItemOf(message, target) {
|
|
47601
|
+
const texts = [];
|
|
47602
|
+
let attachments = 0;
|
|
47603
|
+
for (const block of message.content) {
|
|
47604
|
+
if (block.type === "text" && typeof block.text === "string" && block.text.length > 0) {
|
|
47605
|
+
texts.push(block.text);
|
|
47606
|
+
}
|
|
47607
|
+
if (block.type === "image" || block.type === "file") attachments += 1;
|
|
47608
|
+
}
|
|
47609
|
+
return { messageId: message.id, target, text: texts.join("\n"), attachments };
|
|
47610
|
+
}
|
|
47611
|
+
function projectInbox(inbox) {
|
|
47612
|
+
const out = [];
|
|
47613
|
+
for (const [target, list2] of [
|
|
47614
|
+
["next-step", inbox.nextStep],
|
|
47615
|
+
["next-turn", inbox.nextTurn]
|
|
47616
|
+
]) {
|
|
47617
|
+
for (const original of list2) {
|
|
47618
|
+
const parsed = parseInboxMessage(original);
|
|
47619
|
+
if (parsed === null) continue;
|
|
47620
|
+
out.push({ item: queueItemOf(parsed, target), parsed, original });
|
|
47621
|
+
}
|
|
47622
|
+
}
|
|
47623
|
+
return out;
|
|
47624
|
+
}
|
|
47625
|
+
function rebuildEditedMessage(original, text) {
|
|
47626
|
+
const nonText = original.content.filter((block) => block.type !== "text");
|
|
47627
|
+
const maybeSource = original.source;
|
|
47628
|
+
const source = typeof maybeSource === "object" && maybeSource !== null && maybeSource.kind === "user" ? maybeSource : { kind: "user" };
|
|
47629
|
+
return createUserMessage({
|
|
47630
|
+
source,
|
|
47631
|
+
content: [{ type: "text", text }, ...nonText]
|
|
47632
|
+
});
|
|
47633
|
+
}
|
|
47634
|
+
|
|
47341
47635
|
// src/daemon/kernel/session-transcripts.ts
|
|
47342
47636
|
import fs18 from "node:fs";
|
|
47343
47637
|
import path21 from "node:path";
|
|
@@ -47569,35 +47863,35 @@ function summaryOfMeta(meta) {
|
|
|
47569
47863
|
}
|
|
47570
47864
|
|
|
47571
47865
|
// src/daemon/kernel/agent-sessions.ts
|
|
47572
|
-
var AgentChunkEventSchema =
|
|
47573
|
-
chunk:
|
|
47574
|
-
type:
|
|
47575
|
-
text:
|
|
47576
|
-
id:
|
|
47577
|
-
name:
|
|
47578
|
-
argumentsDelta:
|
|
47866
|
+
var AgentChunkEventSchema = z22.object({
|
|
47867
|
+
chunk: z22.object({
|
|
47868
|
+
type: z22.string().min(1),
|
|
47869
|
+
text: z22.string().optional(),
|
|
47870
|
+
id: z22.string().optional(),
|
|
47871
|
+
name: z22.string().optional(),
|
|
47872
|
+
argumentsDelta: z22.string().optional()
|
|
47579
47873
|
})
|
|
47580
47874
|
});
|
|
47581
|
-
var TodoWriteEventSchema =
|
|
47582
|
-
todos:
|
|
47583
|
-
|
|
47584
|
-
content:
|
|
47585
|
-
status:
|
|
47875
|
+
var TodoWriteEventSchema = z22.object({
|
|
47876
|
+
todos: z22.array(
|
|
47877
|
+
z22.object({
|
|
47878
|
+
content: z22.string(),
|
|
47879
|
+
status: z22.string().min(1)
|
|
47586
47880
|
})
|
|
47587
47881
|
)
|
|
47588
47882
|
});
|
|
47589
|
-
var MessageSourceSchema =
|
|
47590
|
-
kind:
|
|
47591
|
-
callId:
|
|
47883
|
+
var MessageSourceSchema = z22.object({
|
|
47884
|
+
kind: z22.string().optional(),
|
|
47885
|
+
callId: z22.string().optional()
|
|
47592
47886
|
}).passthrough();
|
|
47593
|
-
var MessageBlockSchema =
|
|
47594
|
-
type:
|
|
47595
|
-
text:
|
|
47596
|
-
name:
|
|
47887
|
+
var MessageBlockSchema = z22.object({
|
|
47888
|
+
type: z22.string().min(1),
|
|
47889
|
+
text: z22.string().optional(),
|
|
47890
|
+
name: z22.string().optional()
|
|
47597
47891
|
}).passthrough();
|
|
47598
|
-
var MessageShapeSchema =
|
|
47892
|
+
var MessageShapeSchema = z22.object({
|
|
47599
47893
|
source: MessageSourceSchema.optional(),
|
|
47600
|
-
content:
|
|
47894
|
+
content: z22.array(MessageBlockSchema).min(1)
|
|
47601
47895
|
}).passthrough();
|
|
47602
47896
|
function messageEnvelopeOf(raw) {
|
|
47603
47897
|
if (typeof raw === "object" && raw !== null && "message" in raw) {
|
|
@@ -47606,29 +47900,29 @@ function messageEnvelopeOf(raw) {
|
|
|
47606
47900
|
}
|
|
47607
47901
|
return raw;
|
|
47608
47902
|
}
|
|
47609
|
-
var MessageEventSchema =
|
|
47610
|
-
var TurnEndEventSchema =
|
|
47611
|
-
reason:
|
|
47903
|
+
var MessageEventSchema = z22.preprocess(messageEnvelopeOf, MessageShapeSchema);
|
|
47904
|
+
var TurnEndEventSchema = z22.object({
|
|
47905
|
+
reason: z22.object({ kind: z22.string().optional() }).passthrough().optional()
|
|
47612
47906
|
}).passthrough();
|
|
47613
|
-
var SessionTitleEventSchema =
|
|
47614
|
-
title:
|
|
47907
|
+
var SessionTitleEventSchema = z22.object({
|
|
47908
|
+
title: z22.string().optional()
|
|
47615
47909
|
}).passthrough();
|
|
47616
|
-
var ToolCallEventSchema =
|
|
47617
|
-
callId:
|
|
47618
|
-
name:
|
|
47619
|
-
arguments:
|
|
47910
|
+
var ToolCallEventSchema = z22.object({
|
|
47911
|
+
callId: z22.string().min(1),
|
|
47912
|
+
name: z22.string().min(1),
|
|
47913
|
+
arguments: z22.string()
|
|
47620
47914
|
}).passthrough();
|
|
47621
|
-
var ToolResultEventSchema =
|
|
47622
|
-
message:
|
|
47623
|
-
source:
|
|
47624
|
-
content:
|
|
47625
|
-
|
|
47626
|
-
type:
|
|
47627
|
-
toolCallId:
|
|
47628
|
-
content:
|
|
47629
|
-
|
|
47630
|
-
type:
|
|
47631
|
-
text:
|
|
47915
|
+
var ToolResultEventSchema = z22.object({
|
|
47916
|
+
message: z22.object({
|
|
47917
|
+
source: z22.object({ kind: z22.literal("tool"), callId: z22.string().min(1) }).passthrough(),
|
|
47918
|
+
content: z22.tuple([
|
|
47919
|
+
z22.object({
|
|
47920
|
+
type: z22.literal("tool-result"),
|
|
47921
|
+
toolCallId: z22.string().min(1),
|
|
47922
|
+
content: z22.array(
|
|
47923
|
+
z22.object({
|
|
47924
|
+
type: z22.string().min(1),
|
|
47925
|
+
text: z22.string().optional()
|
|
47632
47926
|
}).passthrough()
|
|
47633
47927
|
).min(1).refine(
|
|
47634
47928
|
(parts) => parts.some(
|
|
@@ -47640,9 +47934,15 @@ var ToolResultEventSchema = z21.object({
|
|
|
47640
47934
|
])
|
|
47641
47935
|
}).passthrough()
|
|
47642
47936
|
});
|
|
47643
|
-
var TurnStartEventSchema =
|
|
47644
|
-
var AgentStatusEventSchema =
|
|
47645
|
-
var
|
|
47937
|
+
var TurnStartEventSchema = z22.record(z22.string(), z22.unknown());
|
|
47938
|
+
var AgentStatusEventSchema = z22.record(z22.string(), z22.unknown());
|
|
47939
|
+
var SubagentCatalogEventSchema = z22.object({
|
|
47940
|
+
childId: z22.string().min(1),
|
|
47941
|
+
childCreatedAt: z22.number().optional(),
|
|
47942
|
+
mode: z22.enum(["one-shot", "continuable"]),
|
|
47943
|
+
label: z22.string().optional()
|
|
47944
|
+
});
|
|
47945
|
+
var UsageEnvelopeSchema = z22.object({ usage: z22.record(z22.string(), z22.unknown()).optional() }).passthrough();
|
|
47646
47946
|
var DROPPED_EVENT_LOG_MAX = 200;
|
|
47647
47947
|
function logDroppedEvent(sessionId, type, data) {
|
|
47648
47948
|
let detail;
|
|
@@ -47912,6 +48212,26 @@ function createAgentSessionsService(deps) {
|
|
|
47912
48212
|
}
|
|
47913
48213
|
];
|
|
47914
48214
|
}
|
|
48215
|
+
case "subagent/catalog": {
|
|
48216
|
+
const checked = SubagentCatalogEventSchema.safeParse(data);
|
|
48217
|
+
if (!checked.success) {
|
|
48218
|
+
logDroppedEvent(entry.agent.session.id, event.type, data);
|
|
48219
|
+
return [];
|
|
48220
|
+
}
|
|
48221
|
+
return [
|
|
48222
|
+
{
|
|
48223
|
+
...base,
|
|
48224
|
+
seq: entry.frameSeq++,
|
|
48225
|
+
kind: "subagent",
|
|
48226
|
+
text: checked.data.label ?? checked.data.childId,
|
|
48227
|
+
payload: redactDshPayload({
|
|
48228
|
+
childId: checked.data.childId,
|
|
48229
|
+
mode: checked.data.mode,
|
|
48230
|
+
...checked.data.label !== void 0 ? { label: checked.data.label } : {}
|
|
48231
|
+
})
|
|
48232
|
+
}
|
|
48233
|
+
];
|
|
48234
|
+
}
|
|
47915
48235
|
case "user/message": {
|
|
47916
48236
|
const checked = MessageEventSchema.safeParse(data);
|
|
47917
48237
|
if (!checked.success) {
|
|
@@ -48115,6 +48435,54 @@ function createAgentSessionsService(deps) {
|
|
|
48115
48435
|
return text;
|
|
48116
48436
|
}
|
|
48117
48437
|
}
|
|
48438
|
+
const SESSION_DIGEST_MAX_FRAMES = 30;
|
|
48439
|
+
const SESSION_DIGEST_MAX_CHARS = 24e3;
|
|
48440
|
+
function sessionReferenceDigest(sessionId) {
|
|
48441
|
+
const meta = deps.transcripts.listAll().find((item) => item.sessionId === sessionId);
|
|
48442
|
+
const frames = deps.transcripts.readFrames(sessionId);
|
|
48443
|
+
if (meta === void 0 && frames.length === 0) {
|
|
48444
|
+
throw new DomainError("NOT_FOUND", `referenced session not found: ${sessionId}`);
|
|
48445
|
+
}
|
|
48446
|
+
const lines = [];
|
|
48447
|
+
let total = 0;
|
|
48448
|
+
for (let i = frames.length - 1; i >= 0 && lines.length < SESSION_DIGEST_MAX_FRAMES; i -= 1) {
|
|
48449
|
+
const frame = frames[i];
|
|
48450
|
+
const role = frame.kind === "user-text" ? "user" : frame.kind === "assistant-text" ? "assistant" : null;
|
|
48451
|
+
if (role === null || typeof frame.text !== "string" || frame.text.length === 0) continue;
|
|
48452
|
+
const line = `${role}: ${frame.text}`;
|
|
48453
|
+
if (total + line.length > SESSION_DIGEST_MAX_CHARS && lines.length > 0) break;
|
|
48454
|
+
lines.unshift(line.slice(0, SESSION_DIGEST_MAX_CHARS));
|
|
48455
|
+
total += line.length;
|
|
48456
|
+
}
|
|
48457
|
+
const title = meta?.title !== void 0 && meta.title.length > 0 ? ` "${meta.title}"` : "";
|
|
48458
|
+
return `[reference: earlier session${title} (${sessionId})]
|
|
48459
|
+
${lines.join("\n")}`;
|
|
48460
|
+
}
|
|
48461
|
+
async function expandReferences(references) {
|
|
48462
|
+
const blocks = [];
|
|
48463
|
+
for (const reference of references) {
|
|
48464
|
+
if (reference.kind === "file") {
|
|
48465
|
+
if (deps.expandFileReferences === void 0) {
|
|
48466
|
+
throw new DomainError(
|
|
48467
|
+
"UNAVAILABLE",
|
|
48468
|
+
"file references require the agent-files service (not wired)"
|
|
48469
|
+
);
|
|
48470
|
+
}
|
|
48471
|
+
blocks.push(...await deps.expandFileReferences([reference]));
|
|
48472
|
+
} else if (reference.kind === "skill") {
|
|
48473
|
+
if (deps.expandSkillReferences === void 0) {
|
|
48474
|
+
throw new DomainError(
|
|
48475
|
+
"UNAVAILABLE",
|
|
48476
|
+
"skill references require the skills service (not wired)"
|
|
48477
|
+
);
|
|
48478
|
+
}
|
|
48479
|
+
blocks.push(...await deps.expandSkillReferences([reference]));
|
|
48480
|
+
} else {
|
|
48481
|
+
blocks.push(sessionReferenceDigest(reference.sessionId));
|
|
48482
|
+
}
|
|
48483
|
+
}
|
|
48484
|
+
return blocks;
|
|
48485
|
+
}
|
|
48118
48486
|
function textOf(message) {
|
|
48119
48487
|
const content = message?.content;
|
|
48120
48488
|
if (!Array.isArray(content)) return void 0;
|
|
@@ -48146,11 +48514,7 @@ function createAgentSessionsService(deps) {
|
|
|
48146
48514
|
}
|
|
48147
48515
|
return out;
|
|
48148
48516
|
}
|
|
48149
|
-
|
|
48150
|
-
return /\.(txt|md|markdown|json|ya?ml|toml|csv|tsv|log|patch|diff|ts|tsx|js|jsx|py|rs|go|java|c|h|cpp|sh|css|html|xml|ini|env)$/i.test(
|
|
48151
|
-
name
|
|
48152
|
-
);
|
|
48153
|
-
}
|
|
48517
|
+
const isTextualFile = isTextualFileName;
|
|
48154
48518
|
function usageSnapshotOf(data) {
|
|
48155
48519
|
const checked = UsageEnvelopeSchema.safeParse(data);
|
|
48156
48520
|
if (!checked.success) return void 0;
|
|
@@ -48284,6 +48648,7 @@ function createAgentSessionsService(deps) {
|
|
|
48284
48648
|
}
|
|
48285
48649
|
for (const session of sessions.list()) {
|
|
48286
48650
|
if (known.has(session.id)) continue;
|
|
48651
|
+
if (session.header.origin === "subagent") continue;
|
|
48287
48652
|
const entry = live.get(session.id);
|
|
48288
48653
|
if (entry) {
|
|
48289
48654
|
summaries.push(summaryOf(entry));
|
|
@@ -48352,7 +48717,7 @@ function createAgentSessionsService(deps) {
|
|
|
48352
48717
|
});
|
|
48353
48718
|
if (input.prompt) {
|
|
48354
48719
|
handle.agent.followup(
|
|
48355
|
-
|
|
48720
|
+
createUserMessage2({
|
|
48356
48721
|
source: { kind: "user" },
|
|
48357
48722
|
content: [{ type: "text", text: input.prompt }]
|
|
48358
48723
|
})
|
|
@@ -48361,19 +48726,23 @@ function createAgentSessionsService(deps) {
|
|
|
48361
48726
|
return summaryOf(entry);
|
|
48362
48727
|
},
|
|
48363
48728
|
/** 驱动一轮用户输入(长度硬上限与 RPC 契约一致——外部输入 runtime 收窄)。
|
|
48364
|
-
* 非live但有转录的会话先经内核 agents.resume 复活(跨 daemon 重启续聊)。
|
|
48365
|
-
|
|
48729
|
+
* 非live但有转录的会话先经内核 agents.resume 复活(跨 daemon 重启续聊)。
|
|
48730
|
+
* C1:references 由 daemon 展开(file 读盘 / session 转录摘要)为
|
|
48731
|
+
* [reference: …] 文本块,注入内核 content——与文件附件内联同构;目标缺失
|
|
48732
|
+
* typed NOT_FOUND 整体拒绝,不静默降级。 */
|
|
48733
|
+
async prompt(sessionId, text, images = [], files = [], mode = "queue", references = []) {
|
|
48366
48734
|
if (text.length > PROMPT_MAX_CHARS) {
|
|
48367
48735
|
throw new DomainError(
|
|
48368
48736
|
"INVALID_OPERATION",
|
|
48369
48737
|
`prompt too long: ${text.length} chars (max ${PROMPT_MAX_CHARS})`
|
|
48370
48738
|
);
|
|
48371
48739
|
}
|
|
48740
|
+
const referenceBlocks = references.length > 0 ? await expandReferences(references) : [];
|
|
48372
48741
|
let entry = live.get(sessionId);
|
|
48373
48742
|
if (!entry) {
|
|
48374
48743
|
entry = await reviveSession(sessionId);
|
|
48375
48744
|
}
|
|
48376
|
-
if (text.startsWith("/") && images.length === 0 && files.length === 0) {
|
|
48745
|
+
if (text.startsWith("/") && images.length === 0 && files.length === 0 && references.length === 0) {
|
|
48377
48746
|
const commands = requireKernel().ctx.commands;
|
|
48378
48747
|
if (commands) {
|
|
48379
48748
|
const executed = await commands.execute(
|
|
@@ -48396,6 +48765,9 @@ ${decoded.slice(0, 2e5)}`
|
|
|
48396
48765
|
});
|
|
48397
48766
|
return false;
|
|
48398
48767
|
});
|
|
48768
|
+
for (const block of referenceBlocks) {
|
|
48769
|
+
content.push({ type: "text", text: block });
|
|
48770
|
+
}
|
|
48399
48771
|
if (images.length > 0 || restFiles.length > 0) {
|
|
48400
48772
|
const kernel = requireKernel();
|
|
48401
48773
|
const attachments = kernel.ctx.attachments;
|
|
@@ -48426,18 +48798,22 @@ ${decoded.slice(0, 2e5)}`
|
|
|
48426
48798
|
content.push({ type: "file", attachment: ref });
|
|
48427
48799
|
}
|
|
48428
48800
|
}
|
|
48429
|
-
|
|
48430
|
-
|
|
48431
|
-
|
|
48432
|
-
|
|
48433
|
-
|
|
48434
|
-
|
|
48801
|
+
const message = createUserMessage2({
|
|
48802
|
+
source: { kind: "user" },
|
|
48803
|
+
content
|
|
48804
|
+
});
|
|
48805
|
+
if (mode === "steer" && typeof entry.agent.steer === "function") {
|
|
48806
|
+
entry.agent.steer(message);
|
|
48807
|
+
} else {
|
|
48808
|
+
entry.agent.followup(message);
|
|
48809
|
+
}
|
|
48435
48810
|
},
|
|
48436
|
-
/** 取消当前活动(幂等;无活动为 no-op)。
|
|
48811
|
+
/** 取消当前活动(幂等;无活动为 no-op)。W4:keepInbox——排队消息在停止后
|
|
48812
|
+
* 存活并按 FIFO 续跑(官方 Stop 语义;内核缺省会清 inbox)。 */
|
|
48437
48813
|
cancel(sessionId) {
|
|
48438
48814
|
const entry = live.get(sessionId);
|
|
48439
48815
|
if (!entry) throw new DomainError("NOT_FOUND", `agent session not found: ${sessionId}`);
|
|
48440
|
-
entry.agent.cancel("user");
|
|
48816
|
+
entry.agent.cancel("user", { keepInbox: true });
|
|
48441
48817
|
},
|
|
48442
48818
|
/**
|
|
48443
48819
|
* 切换会话模式(add-agent-settings-modes):meta 持久化 + live 句柄有界释放 +
|
|
@@ -48487,6 +48863,70 @@ ${decoded.slice(0, 2e5)}`
|
|
|
48487
48863
|
deps.transcripts.append(sessionId, frame);
|
|
48488
48864
|
return summary;
|
|
48489
48865
|
},
|
|
48866
|
+
/**
|
|
48867
|
+
* C2 queue 面薄委托(逻辑在 agent-queue):非 live 会话返回空 items——
|
|
48868
|
+
* 重启后未复活的挂起队列不可操作(记录边界,不伪装)。live 会话无 inbox
|
|
48869
|
+
* 面(内核面缺失)同样空 items。
|
|
48870
|
+
*/
|
|
48871
|
+
queueList(sessionId) {
|
|
48872
|
+
const entry = live.get(sessionId);
|
|
48873
|
+
if (!entry || entry.agent.inbox === void 0) return { items: [] };
|
|
48874
|
+
return { items: projectInbox(entry.agent.inbox).map(({ item }) => item) };
|
|
48875
|
+
},
|
|
48876
|
+
/**
|
|
48877
|
+
* C2 queue 行级操作:edit=replace(新文本 + 原附件块);remove=remove;
|
|
48878
|
+
* steer=next-turn → next-step(仅 running)。messageId 已被消费(轮次已
|
|
48879
|
+
* 开始)typed NOT_FOUND——竞态可见;目标不在 next-turn 时 steer 拒绝。
|
|
48880
|
+
*/
|
|
48881
|
+
queueUpdate(sessionId, input) {
|
|
48882
|
+
const entry = live.get(sessionId);
|
|
48883
|
+
if (!entry) {
|
|
48884
|
+
throw new DomainError("NOT_FOUND", `agent session not found: ${sessionId}`);
|
|
48885
|
+
}
|
|
48886
|
+
if (entry.agent.inbox === void 0) {
|
|
48887
|
+
throw new DomainError("UNAVAILABLE", "agent kernel inbox surface missing");
|
|
48888
|
+
}
|
|
48889
|
+
const inbox = entry.agent.inbox;
|
|
48890
|
+
if (input.action === "remove") {
|
|
48891
|
+
if (!inbox.remove(input.messageId)) {
|
|
48892
|
+
throw new DomainError(
|
|
48893
|
+
"NOT_FOUND",
|
|
48894
|
+
`queued message no longer pending: ${input.messageId}`
|
|
48895
|
+
);
|
|
48896
|
+
}
|
|
48897
|
+
return;
|
|
48898
|
+
}
|
|
48899
|
+
if (input.action === "edit") {
|
|
48900
|
+
const found = projectInbox(inbox).find(({ item }) => item.messageId === input.messageId);
|
|
48901
|
+
if (found === void 0) {
|
|
48902
|
+
throw new DomainError(
|
|
48903
|
+
"NOT_FOUND",
|
|
48904
|
+
`queued message no longer pending: ${input.messageId}`
|
|
48905
|
+
);
|
|
48906
|
+
}
|
|
48907
|
+
inbox.replace(input.messageId, rebuildEditedMessage(found.parsed, input.text ?? ""));
|
|
48908
|
+
return;
|
|
48909
|
+
}
|
|
48910
|
+
if (statusOf(entry) !== "running") {
|
|
48911
|
+
throw new DomainError(
|
|
48912
|
+
"INVALID_OPERATION",
|
|
48913
|
+
"steer needs a running turn; the session is idle"
|
|
48914
|
+
);
|
|
48915
|
+
}
|
|
48916
|
+
const queued = projectInbox(inbox).find(
|
|
48917
|
+
({ item }) => item.messageId === input.messageId && item.target === "next-turn"
|
|
48918
|
+
);
|
|
48919
|
+
if (queued === void 0) {
|
|
48920
|
+
throw new DomainError(
|
|
48921
|
+
"INVALID_OPERATION",
|
|
48922
|
+
`message is not a queued next-turn item: ${input.messageId}`
|
|
48923
|
+
);
|
|
48924
|
+
}
|
|
48925
|
+
if (!inbox.remove(input.messageId)) {
|
|
48926
|
+
throw new DomainError("NOT_FOUND", `queued message no longer pending: ${input.messageId}`);
|
|
48927
|
+
}
|
|
48928
|
+
inbox.append("next-step", queued.original);
|
|
48929
|
+
},
|
|
48490
48930
|
/** 增量帧读取(afterSeq 游标 + limit 窗口);非 live 会话由转录回放。 */
|
|
48491
48931
|
stream(sessionId, afterSeq, limit) {
|
|
48492
48932
|
const entry = live.get(sessionId);
|
|
@@ -48523,6 +48963,11 @@ ${decoded.slice(0, 2e5)}`
|
|
|
48523
48963
|
},
|
|
48524
48964
|
/** 有界销毁(daemon stop 时逐个回收 agent;待答请求以空答案释放)。 */
|
|
48525
48965
|
async dispose() {
|
|
48966
|
+
const kernel = deps.kernel();
|
|
48967
|
+
const drain = kernel?.ctx?.subagents?.drainContinuableDescendants;
|
|
48968
|
+
if (drain && live.size > 0) {
|
|
48969
|
+
await Promise.resolve(drain([...live.keys()])).catch(() => void 0);
|
|
48970
|
+
}
|
|
48526
48971
|
for (const entry of live.values()) {
|
|
48527
48972
|
for (const pending of entry.pending.values()) {
|
|
48528
48973
|
pending.resolve({ answers: [] });
|
|
@@ -48543,8 +48988,10 @@ function applyProductToolSurface(agentCtx, mode) {
|
|
|
48543
48988
|
}
|
|
48544
48989
|
function productToolDenyList(globalNames, mode) {
|
|
48545
48990
|
const nativeAllowed = mode === "free" ? [...KERNEL_AGENT_TOOL_ALLOWLIST, "bash"] : KERNEL_AGENT_TOOL_ALLOWLIST;
|
|
48991
|
+
const modeRoles = AGENT_MODE_ROLES[mode];
|
|
48992
|
+
const roleAllowed = modeRoles.map(agentRoleToolName);
|
|
48546
48993
|
return globalNames.filter(
|
|
48547
|
-
(name) => !nativeAllowed.includes(name) && !name.startsWith("mcp__skill-creator__")
|
|
48994
|
+
(name) => !nativeAllowed.includes(name) && !roleAllowed.includes(name) && !name.startsWith("mcp__skill-creator__")
|
|
48548
48995
|
);
|
|
48549
48996
|
}
|
|
48550
48997
|
|
|
@@ -48726,7 +49173,7 @@ function createModelCatalogService() {
|
|
|
48726
49173
|
}
|
|
48727
49174
|
|
|
48728
49175
|
// src/daemon/capability/domain-capabilities.ts
|
|
48729
|
-
import { z as
|
|
49176
|
+
import { z as z23 } from "zod";
|
|
48730
49177
|
function toResult(error) {
|
|
48731
49178
|
if (error instanceof DomainError) {
|
|
48732
49179
|
return { kind: "failed", code: error.code, message: error.message };
|
|
@@ -48747,7 +49194,7 @@ async function invoke(action) {
|
|
|
48747
49194
|
return toResult(error);
|
|
48748
49195
|
}
|
|
48749
49196
|
}
|
|
48750
|
-
var none =
|
|
49197
|
+
var none = z23.object({});
|
|
48751
49198
|
function createDomainCapabilities(domain) {
|
|
48752
49199
|
return [
|
|
48753
49200
|
{
|
|
@@ -49758,16 +50205,16 @@ import path25 from "node:path";
|
|
|
49758
50205
|
|
|
49759
50206
|
// src/daemon/workspace-registry/state.ts
|
|
49760
50207
|
import path24 from "node:path";
|
|
49761
|
-
import { z as
|
|
49762
|
-
var StoredWorkspaceSchema =
|
|
50208
|
+
import { z as z24 } from "zod";
|
|
50209
|
+
var StoredWorkspaceSchema = z24.object({
|
|
49763
50210
|
id: ImportedWorkspaceIdSchema,
|
|
49764
|
-
label:
|
|
49765
|
-
path:
|
|
50211
|
+
label: z24.string().trim().min(1),
|
|
50212
|
+
path: z24.string().min(1).refine(path24.isAbsolute, "Workspace path must be absolute.").refine((value) => path24.normalize(value) === value, "Workspace path must be normalized.")
|
|
49766
50213
|
}).strict();
|
|
49767
|
-
var WorkspaceRegistryStateSchema =
|
|
49768
|
-
schemaVersion:
|
|
50214
|
+
var WorkspaceRegistryStateSchema = z24.object({
|
|
50215
|
+
schemaVersion: z24.literal(2),
|
|
49769
50216
|
activeId: WorkspaceIdSchema,
|
|
49770
|
-
workspaces:
|
|
50217
|
+
workspaces: z24.array(StoredWorkspaceSchema)
|
|
49771
50218
|
}).strict().superRefine((state, context) => {
|
|
49772
50219
|
const ids = /* @__PURE__ */ new Set();
|
|
49773
50220
|
const paths = /* @__PURE__ */ new Set();
|
|
@@ -50141,8 +50588,11 @@ function defaultStewardAdapters() {
|
|
|
50141
50588
|
function createDaemonDomain(workspaces = createWorkspaceRegistry(), options2 = {}) {
|
|
50142
50589
|
const kernelHostRef = { handle: null };
|
|
50143
50590
|
const dshSettings = createDshSettingsService();
|
|
50144
|
-
const agentTranscripts = createSessionTranscripts(
|
|
50591
|
+
const agentTranscripts = createSessionTranscripts(join3(appDir(), "sessions"));
|
|
50145
50592
|
const modelCatalog = createModelCatalogService();
|
|
50593
|
+
const agentFiles = createAgentFilesService();
|
|
50594
|
+
const skillsCliProbe = options2.skillsCliProbe ?? createSkillsCliProbe();
|
|
50595
|
+
const skills = createSkillService(workspaces, { skillsCliProbe });
|
|
50146
50596
|
const agentSessions = createAgentSessionsService({
|
|
50147
50597
|
kernel: () => kernelHostRef.handle,
|
|
50148
50598
|
modelSelection: async () => (await dshSettings.getView()).settings.model,
|
|
@@ -50155,10 +50605,25 @@ function createDaemonDomain(workspaces = createWorkspaceRegistry(), options2 = {
|
|
|
50155
50605
|
if (entry === void 0) return null;
|
|
50156
50606
|
return { contextWindow: entry.contextWindow, maxOutputTokens: entry.maxOutputTokens };
|
|
50157
50607
|
},
|
|
50158
|
-
transcripts: agentTranscripts
|
|
50608
|
+
transcripts: agentTranscripts,
|
|
50609
|
+
expandFileReferences: (references) => agentFiles.resolvePromptReferences({ references }),
|
|
50610
|
+
// skill-refs C1:`$` 引用展开——registry 作用域解析 + 文档读取在 skills 服务
|
|
50611
|
+
//(NOT_FOUND 随 resolveSkill typed 抛出);内容截断对齐 file 引用(200k chars)。
|
|
50612
|
+
expandSkillReferences: async (references) => {
|
|
50613
|
+
const blocks = [];
|
|
50614
|
+
for (const reference of references) {
|
|
50615
|
+
const info3 = await skills.info(
|
|
50616
|
+
{ workspaceId: reference.workspaceId, providerId: reference.providerId },
|
|
50617
|
+
reference.skillId
|
|
50618
|
+
);
|
|
50619
|
+
blocks.push(
|
|
50620
|
+
`[reference: skill ${info3.name} \xB7 ${info3.provider}]
|
|
50621
|
+
${info3.content.slice(0, 2e5)}`
|
|
50622
|
+
);
|
|
50623
|
+
}
|
|
50624
|
+
return blocks;
|
|
50625
|
+
}
|
|
50159
50626
|
});
|
|
50160
|
-
const skillsCliProbe = options2.skillsCliProbe ?? createSkillsCliProbe();
|
|
50161
|
-
const skills = createSkillService(workspaces, { skillsCliProbe });
|
|
50162
50627
|
const repository = createRepositoryService(workspaces, skills);
|
|
50163
50628
|
const creator = createCreatorService(workspaces, skills);
|
|
50164
50629
|
const skillIntelligence = createSkillIntelligenceService(skills, creator);
|
|
@@ -50178,7 +50643,7 @@ function createDaemonDomain(workspaces = createWorkspaceRegistry(), options2 = {
|
|
|
50178
50643
|
skillSteward: createSkillStewardPipelineService({ workspaces, skills, creator }),
|
|
50179
50644
|
dshSettings,
|
|
50180
50645
|
agentSessions,
|
|
50181
|
-
agentFiles
|
|
50646
|
+
agentFiles,
|
|
50182
50647
|
modelCatalog,
|
|
50183
50648
|
setKernelHost: (handle) => {
|
|
50184
50649
|
kernelHostRef.handle = handle;
|
|
@@ -50585,7 +51050,9 @@ function createRpcRouter(deps) {
|
|
|
50585
51050
|
input.sessionId,
|
|
50586
51051
|
input.text,
|
|
50587
51052
|
resolved.images,
|
|
50588
|
-
resolved.files
|
|
51053
|
+
resolved.files,
|
|
51054
|
+
input.mode ?? "queue",
|
|
51055
|
+
input.references ?? []
|
|
50589
51056
|
);
|
|
50590
51057
|
return { accepted: true };
|
|
50591
51058
|
}),
|
|
@@ -50603,6 +51070,20 @@ function createRpcRouter(deps) {
|
|
|
50603
51070
|
session: await domain.agentSessions.setMode(input.sessionId, input.mode)
|
|
50604
51071
|
}))
|
|
50605
51072
|
},
|
|
51073
|
+
queue: {
|
|
51074
|
+
// C2:内核 inbox 队列面(非 live = 空 items;update 竞态 typed NOT_FOUND)。
|
|
51075
|
+
list: rpc.agent.queue.list.handler(
|
|
51076
|
+
({ input }) => domain.agentSessions.queueList(input.sessionId)
|
|
51077
|
+
),
|
|
51078
|
+
update: rpc.agent.queue.update.handler(({ input }) => {
|
|
51079
|
+
domain.agentSessions.queueUpdate(input.sessionId, {
|
|
51080
|
+
messageId: input.messageId,
|
|
51081
|
+
action: input.action,
|
|
51082
|
+
...input.action === "edit" ? { text: input.text } : {}
|
|
51083
|
+
});
|
|
51084
|
+
return { updated: true };
|
|
51085
|
+
})
|
|
51086
|
+
},
|
|
50606
51087
|
files: {
|
|
50607
51088
|
// R17-B 后端文件选择器:用户本机自由浏览(读面,无 containment)。
|
|
50608
51089
|
list: rpc.agent.files.list.handler(async ({ input }) => domain.agentFiles.list(input)),
|
|
@@ -50747,17 +51228,22 @@ var WebServer = class {
|
|
|
50747
51228
|
unsubscribeExited;
|
|
50748
51229
|
/**
|
|
50749
51230
|
* 挂载 skill-creator MCP 面(task 4.1 形态 A)。传 null 卸载(降级语义:
|
|
50750
|
-
* MCP 面缺席 → 404)。
|
|
50751
|
-
*
|
|
51231
|
+
* MCP 面缺席 → 404)。v2 双纪元(skill-refs-and-platform-fixes C3):
|
|
51232
|
+
* createMcpHandler 以 factory 每请求新建 server 实例——modern(2026-07-28
|
|
51233
|
+
* server/discover,dsh-mcp-client v2 线)与 legacy(2025 initialize)都由
|
|
51234
|
+
* 该入口服务;legacy 走 stateless(与 v1 逐请求 transport 语义同构)。
|
|
50752
51235
|
*/
|
|
50753
51236
|
mountMcp(factory) {
|
|
50754
51237
|
this.mcpFactory = factory;
|
|
51238
|
+
this.mcpNodeHandler = null;
|
|
50755
51239
|
log(
|
|
50756
51240
|
factory ? "skill-creator mcp endpoint mounted: /mcp" : "skill-creator mcp endpoint unmounted"
|
|
50757
51241
|
);
|
|
50758
51242
|
}
|
|
50759
51243
|
mcpFactory = null;
|
|
50760
|
-
/**
|
|
51244
|
+
/** Node 适配处理器缓存(按 factory 身份失效;mountMcp 变更即置空)。 */
|
|
51245
|
+
mcpNodeHandler = null;
|
|
51246
|
+
/** /mcp 请求处理:Bearer 鉴权(daemon 侧前置)→ 双纪元 MCP handler。 */
|
|
50761
51247
|
async handleMcp(request, response) {
|
|
50762
51248
|
if (!this.mcpFactory) {
|
|
50763
51249
|
response.writeHead(404, { "content-type": "application/json" });
|
|
@@ -50771,22 +51257,22 @@ var WebServer = class {
|
|
|
50771
51257
|
response.end(JSON.stringify({ error: "unauthorized" }));
|
|
50772
51258
|
return;
|
|
50773
51259
|
}
|
|
50774
|
-
|
|
50775
|
-
|
|
50776
|
-
|
|
50777
|
-
|
|
50778
|
-
|
|
50779
|
-
|
|
50780
|
-
|
|
50781
|
-
|
|
50782
|
-
|
|
50783
|
-
|
|
50784
|
-
|
|
50785
|
-
|
|
50786
|
-
|
|
50787
|
-
|
|
50788
|
-
}
|
|
50789
|
-
await
|
|
51260
|
+
if (this.mcpNodeHandler === null) {
|
|
51261
|
+
const [{ createMcpHandler }, { toNodeHandler }] = await Promise.all([
|
|
51262
|
+
import("@modelcontextprotocol/server"),
|
|
51263
|
+
import("@modelcontextprotocol/node")
|
|
51264
|
+
]);
|
|
51265
|
+
const factory = this.mcpFactory;
|
|
51266
|
+
const handler = createMcpHandler(() => factory(), {
|
|
51267
|
+
legacy: "stateless",
|
|
51268
|
+
onerror: (error) => {
|
|
51269
|
+
log(`mcp handler error: ${error instanceof Error ? error.message : String(error)}`);
|
|
51270
|
+
}
|
|
51271
|
+
});
|
|
51272
|
+
if (this.mcpFactory !== factory) return;
|
|
51273
|
+
this.mcpNodeHandler = toNodeHandler(handler);
|
|
51274
|
+
}
|
|
51275
|
+
await this.mcpNodeHandler(request, response);
|
|
50790
51276
|
}
|
|
50791
51277
|
/** 启动环回服务,并返回实际监听端口。 */
|
|
50792
51278
|
start(port) {
|
|
@@ -50979,7 +51465,7 @@ import fs26 from "node:fs/promises";
|
|
|
50979
51465
|
import {
|
|
50980
51466
|
createAssistantMessage,
|
|
50981
51467
|
createToolResultMessage,
|
|
50982
|
-
createUserMessage as
|
|
51468
|
+
createUserMessage as createUserMessage3
|
|
50983
51469
|
} from "@deepseek-ai/dsh-llm";
|
|
50984
51470
|
function isRecord3(value) {
|
|
50985
51471
|
return typeof value === "object" && value !== null;
|
|
@@ -51041,7 +51527,7 @@ function createDshSessionBinder(options2) {
|
|
|
51041
51527
|
session.append("step/start", { turn: 1, step: 1 });
|
|
51042
51528
|
session.append(
|
|
51043
51529
|
"user/message",
|
|
51044
|
-
|
|
51530
|
+
createUserMessage3({
|
|
51045
51531
|
source: { kind: "user" },
|
|
51046
51532
|
content: [{ type: "text", text: input.taskText }]
|
|
51047
51533
|
}),
|
|
@@ -51156,7 +51642,8 @@ function summarizeToolResult(call) {
|
|
|
51156
51642
|
}
|
|
51157
51643
|
|
|
51158
51644
|
// src/daemon/mcp/skill-creator-mcp.ts
|
|
51159
|
-
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/
|
|
51645
|
+
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/server";
|
|
51646
|
+
import { z as z25 } from "zod";
|
|
51160
51647
|
function mcpToolName(capabilityName) {
|
|
51161
51648
|
return capabilityName.replace(/\./g, "_");
|
|
51162
51649
|
}
|
|
@@ -51217,16 +51704,20 @@ function createSkillCreatorMcpServer(deps) {
|
|
|
51217
51704
|
]
|
|
51218
51705
|
});
|
|
51219
51706
|
if (shape2) {
|
|
51220
|
-
server.
|
|
51707
|
+
server.registerTool(
|
|
51221
51708
|
proposeName,
|
|
51222
|
-
|
|
51223
|
-
|
|
51709
|
+
{
|
|
51710
|
+
description: `Propose: ${descriptor.description} A human approves it in the Skill Creator UI before execution.`,
|
|
51711
|
+
inputSchema: z25.object(shape2)
|
|
51712
|
+
},
|
|
51224
51713
|
async (args) => proposeResult(deps.proposals.create(descriptor.name, args))
|
|
51225
51714
|
);
|
|
51226
51715
|
} else {
|
|
51227
|
-
server.
|
|
51716
|
+
server.registerTool(
|
|
51228
51717
|
proposeName,
|
|
51229
|
-
|
|
51718
|
+
{
|
|
51719
|
+
description: `Propose: ${descriptor.description} A human approves it in the Skill Creator UI before execution.`
|
|
51720
|
+
},
|
|
51230
51721
|
async () => proposeResult(deps.proposals.create(descriptor.name, void 0))
|
|
51231
51722
|
);
|
|
51232
51723
|
}
|
|
@@ -51237,10 +51728,9 @@ function createSkillCreatorMcpServer(deps) {
|
|
|
51237
51728
|
const shape = input && typeof input.shape === "object" ? input.shape : null;
|
|
51238
51729
|
const toolName = mcpToolName(descriptor.name);
|
|
51239
51730
|
if (shape) {
|
|
51240
|
-
server.
|
|
51731
|
+
server.registerTool(
|
|
51241
51732
|
toolName,
|
|
51242
|
-
descriptor.description,
|
|
51243
|
-
shape,
|
|
51733
|
+
{ description: descriptor.description, inputSchema: z25.object(shape) },
|
|
51244
51734
|
async (args) => withCard(
|
|
51245
51735
|
descriptor.name,
|
|
51246
51736
|
await deps.capabilities.call(descriptor.name, args, MCP_PRINCIPAL),
|
|
@@ -51248,9 +51738,9 @@ function createSkillCreatorMcpServer(deps) {
|
|
|
51248
51738
|
)
|
|
51249
51739
|
);
|
|
51250
51740
|
} else {
|
|
51251
|
-
server.
|
|
51741
|
+
server.registerTool(
|
|
51252
51742
|
toolName,
|
|
51253
|
-
descriptor.description,
|
|
51743
|
+
{ description: descriptor.description },
|
|
51254
51744
|
async () => withCard(
|
|
51255
51745
|
descriptor.name,
|
|
51256
51746
|
await deps.capabilities.call(descriptor.name, void 0, MCP_PRINCIPAL),
|
|
@@ -52124,8 +52614,8 @@ async function bootDaemon(opts) {
|
|
|
52124
52614
|
import fs30 from "node:fs";
|
|
52125
52615
|
import path32 from "node:path";
|
|
52126
52616
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
52127
|
-
import { z as
|
|
52128
|
-
var PackageVersionSchema =
|
|
52617
|
+
import { z as z26 } from "zod";
|
|
52618
|
+
var PackageVersionSchema = z26.object({ version: z26.string().min(1) });
|
|
52129
52619
|
function readNearestPackageVersion(moduleUrl) {
|
|
52130
52620
|
const here = path32.dirname(fileURLToPath6(moduleUrl));
|
|
52131
52621
|
const candidates = [
|