@gt-fe/eap-runtime 0.0.32 → 0.0.34

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.
Files changed (45) hide show
  1. package/dist/api/handlers/invoke.handler.d.ts +0 -1
  2. package/dist/api/handlers/invoke.handler.js +25 -6
  3. package/dist/api/handlers/stream.handler.d.ts +0 -1
  4. package/dist/api/handlers/stream.handler.js +22 -18
  5. package/dist/common/types.d.ts +4 -3
  6. package/dist/graph/adapters/langgraph.adapter.d.ts +0 -1
  7. package/dist/graph/adapters/langgraph.adapter.js +117 -82
  8. package/dist/graph/adapters/skill-entry-span.js +4 -1
  9. package/dist/graph/adapters/subgraph-compiler.js +11 -9
  10. package/dist/graph/contracts/executable-graph.d.ts +2 -0
  11. package/dist/graph/execution-trace-context.d.ts +3 -0
  12. package/dist/graph/nodes/llm-node.d.ts +7 -2
  13. package/dist/graph/nodes/llm-node.js +8 -3
  14. package/dist/graph/nodes/skill-bind-node.d.ts +1 -1
  15. package/dist/graph/nodes/skill-bind-node.js +6 -1
  16. package/dist/graph/nodes/tool-node.js +1 -0
  17. package/dist/providers/http-llm-provider.js +27 -10
  18. package/dist/registry/graph-loader.d.ts +11 -0
  19. package/dist/registry/graph-loader.js +28 -4
  20. package/dist/runtime/agent-runtime.d.ts +7 -0
  21. package/dist/runtime/agent-runtime.js +69 -38
  22. package/dist/runtime/types.d.ts +1 -1
  23. package/dist/session/persist-turn-messages.d.ts +10 -2
  24. package/dist/session/persist-turn-messages.js +35 -10
  25. package/dist/sse/events/index.d.ts +6 -4
  26. package/dist/sse/events/index.js +3 -1
  27. package/dist/sse/events/reasoning-events.d.ts +24 -2
  28. package/dist/sse/events/reasoning-events.js +3 -1
  29. package/dist/sse/events/skill-events.d.ts +2 -0
  30. package/dist/task/contracts/task-manager.contract.d.ts +2 -2
  31. package/dist/task/contracts/task-manager.contract.js +1 -1
  32. package/dist/task/index.d.ts +2 -0
  33. package/dist/task/index.js +1 -0
  34. package/dist/task/task-abort.d.ts +14 -0
  35. package/dist/task/task-abort.js +33 -0
  36. package/dist/task/task-timeout.d.ts +11 -0
  37. package/dist/task/task-timeout.js +40 -4
  38. package/dist/task/task.service.js +11 -5
  39. package/dist/tool/index.d.ts +1 -1
  40. package/dist/tool/index.js +1 -1
  41. package/dist/tool/mcp-list.d.ts +3 -1
  42. package/dist/tool/mcp-list.js +4 -1
  43. package/dist/tool/system-prompt-builder.d.ts +10 -8
  44. package/dist/tool/system-prompt-builder.js +36 -26
  45. package/package.json +1 -1
@@ -7,8 +7,8 @@
7
7
  * ```
8
8
  * [平台规则常量] ← 代码内置,安全约束 + 行为准则(最高优先级)
9
9
  * [当前时间] ← 运行时动态注入(自然周等时间规则的判定基准)
10
- * [Agent 身份] ← agentName / agentCode(目录身份,不是 prompts.system)
11
- * [可用工具短目录] ← 名称 + 一句话用途;完整 schema 仍走 API tools
10
+ * [Agent 身份] ← 展示名 agentName,缺省 agentCode(对用户说话,不是路由键)
11
+ * [可用技能短目录] ← 展示名 + skillId + SKILL.md 路径(技能不是 function)
12
12
  * [Agent 基线] ← agent.manifest.json prompts.system;非 silent LLM
13
13
  * [节点提示词] ← Graph LLM 节点 config.systemPrompt / systemPromptFile
14
14
  * ```
@@ -16,7 +16,7 @@
16
16
  * 基线只走 GraphState.agentSystemPrompt,不写进节点 config。无图时节点无增量。
17
17
  * silent 节点不带基线。技能正文不灌 system。
18
18
  *
19
- * 工具 schema 走 API 的 tools 参数(见 loadedToolsToApiTools);system 短目录给模型发现用,不是对用户报菜名。
19
+ * 工具只走 API 的 tools 参数(见 loadedToolsToApiTools),不写入 system。
20
20
  *
21
21
  * @see docs/status/module-status-and-backlog.md RT-5
22
22
  */
@@ -86,6 +86,22 @@ function trimPrompt(value) {
86
86
  const trimmed = value.trim();
87
87
  return trimmed ? trimmed : undefined;
88
88
  }
89
+ /** 对人展示的名称。有展示名用展示名,否则用编码。 */
90
+ export function spokenName(displayName, code) {
91
+ const name = displayName?.trim();
92
+ if (name)
93
+ return name;
94
+ const id = code?.trim();
95
+ return id || undefined;
96
+ }
97
+ /** 短目录标题:展示名在前,调用键在行内。名称与编码相同则只写编码。 */
98
+ export function catalogEntryTitle(code, displayName, codePhrase) {
99
+ const id = code.trim();
100
+ const name = displayName?.trim();
101
+ if (name && name !== id)
102
+ return `**${name}**(${codePhrase})`;
103
+ return `**${id}**`;
104
+ }
89
105
  /**
90
106
  * 非 silent LLM 才带 Agent 基线;节点提示词空则省略。
91
107
  * silent 只保留节点增量(选技能 / JSON)。
@@ -103,7 +119,7 @@ export function resolveLlmPromptInputs(input) {
103
119
  * SystemPromptBuilder — 系统提示词拼接
104
120
  *
105
121
  * 具名段拼接(无模板引擎)。顺序固定,段标题用于排查。
106
- * 工具短目录进 system;完整 schema 走 API tools 参数。
122
+ * 工具只走 API tools 参数,不进 system。技能短目录进 system(技能不是 function)。
107
123
  * Agent 基线与节点提示词整段透传,不做 {{ }} 替换。
108
124
  */
109
125
  export class SystemPromptBuilder {
@@ -125,7 +141,6 @@ export class SystemPromptBuilder {
125
141
  add('user', '当前用户', `## 当前用户\n用户标识:${context.userId.trim()}。用户说「我 / 我的」时使用此标识,不要向用户再要一遍。`);
126
142
  }
127
143
  add('jail', '文件与命令权限', this.buildJail(context));
128
- add('tools-catalog', '可用工具', context.toolCatalog);
129
144
  add('skills-catalog', '可用技能', context.skillCatalog);
130
145
  add('agent', 'Agent 基线', context.agentPrompt);
131
146
  add('node', '节点提示词', context.nodePrompt);
@@ -154,7 +169,7 @@ export class SystemPromptBuilder {
154
169
  return lines.join('\n');
155
170
  }
156
171
  buildAgentIdentity(context) {
157
- const name = context.agentName ?? context.agentCode;
172
+ const name = spokenName(context.agentName, context.agentCode);
158
173
  return name ? `## Agent 身份\n你的名称是「${name}」。` : '';
159
174
  }
160
175
  buildJail(context) {
@@ -246,6 +261,21 @@ export function naturalTimeWindows(now = new Date()) {
246
261
  lastMonth: `${formatDay(lastMonthStart)} ~ ${formatDay(lastMonthEnd)}`,
247
262
  };
248
263
  }
264
+ /** 展示名 + skillId,供 system「可用技能」段。read_file 仍用 skillId。 */
265
+ export function buildSkillCatalog(defs) {
266
+ if (!defs)
267
+ return undefined;
268
+ const rows = Object.values(defs).map((skill) => {
269
+ const desc = (skill.description ?? '').replace(/\s+/g, ' ').trim();
270
+ const entry = skill.entryFile ?? (skill.bundlePath ? `${skill.bundlePath}/SKILL.md` : '');
271
+ const title = catalogEntryTitle(skill.skillId, skill.name, `skillId ${skill.skillId}`);
272
+ const pathLine = entry ? `\n SKILL.md: ${entry}` : '';
273
+ return `- ${title}${desc ? `:${desc}` : ''}${pathLine}`;
274
+ });
275
+ if (rows.length === 0)
276
+ return undefined;
277
+ return `# 可用技能\n要用某个技能时,调用 read_file 读取其 SKILL.md。脚本和参考文档默认在同一目录。\n${rows.join('\n')}`;
278
+ }
249
279
  /**
250
280
  * 将平台的 LoadedToolMap 转为 OpenAI API 的 tools 参数
251
281
  *
@@ -256,26 +286,6 @@ export function naturalTimeWindows(now = new Date()) {
256
286
  * @param skillTools - 可选,当前 Skill 所需的工具名称列表(过滤子集)
257
287
  * @returns OpenAI API tools 参数数组
258
288
  */
259
- /** 名称 + 一句话用途,供 system「可用工具」段。schema 仍走 loadedToolsToApiTools。 */
260
- export function buildToolCatalog(loadedTools) {
261
- if (!loadedTools)
262
- return undefined;
263
- const rows = Object.values(loadedTools).map((tool) => {
264
- const desc = (tool.manifest.description ?? '').replace(/\s+/g, ' ').trim();
265
- const displayName = tool.manifest.name?.trim();
266
- const title = displayName && displayName !== tool.name
267
- ? `${tool.name}(${displayName})`
268
- : tool.name;
269
- return `- **${title}**${desc ? `:${desc}` : ''}`;
270
- });
271
- if (rows.length === 0)
272
- return undefined;
273
- return [
274
- '# 可用工具',
275
- '调用时使用 function calling,不要假装没有这些工具。这是给你发现用的短目录,不是对用户报菜名。',
276
- rows.join('\n'),
277
- ].join('\n');
278
- }
279
289
  export function loadedToolsToApiTools(loadedTools, skillTools) {
280
290
  if (!loadedTools)
281
291
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gt-fe/eap-runtime",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Enterprise Agent Platform — Runtime核心:Graph执行引擎、Task生命周期、Session管理、Checkpoint持久化",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",