@gt-fe/eap-runtime 0.0.33 → 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.
- package/dist/api/handlers/invoke.handler.d.ts +0 -1
- package/dist/api/handlers/invoke.handler.js +22 -5
- package/dist/api/handlers/stream.handler.d.ts +0 -1
- package/dist/api/handlers/stream.handler.js +19 -17
- package/dist/common/types.d.ts +4 -3
- package/dist/graph/adapters/langgraph.adapter.js +109 -64
- package/dist/graph/execution-trace-context.d.ts +3 -0
- package/dist/graph/nodes/llm-node.d.ts +7 -2
- package/dist/graph/nodes/llm-node.js +8 -3
- package/dist/providers/http-llm-provider.js +27 -10
- package/dist/runtime/agent-runtime.d.ts +7 -0
- package/dist/runtime/agent-runtime.js +59 -37
- package/dist/runtime/types.d.ts +1 -1
- package/dist/session/persist-turn-messages.d.ts +10 -2
- package/dist/session/persist-turn-messages.js +35 -10
- package/dist/sse/events/index.d.ts +6 -4
- package/dist/sse/events/index.js +3 -1
- package/dist/sse/events/reasoning-events.d.ts +24 -2
- package/dist/sse/events/reasoning-events.js +3 -1
- package/dist/sse/events/skill-events.d.ts +2 -0
- package/dist/task/contracts/task-manager.contract.d.ts +2 -2
- package/dist/task/contracts/task-manager.contract.js +1 -1
- package/dist/task/index.d.ts +2 -0
- package/dist/task/index.js +1 -0
- package/dist/task/task-abort.d.ts +14 -0
- package/dist/task/task-abort.js +33 -0
- package/dist/task/task-timeout.d.ts +11 -0
- package/dist/task/task-timeout.js +40 -4
- package/dist/task/task.service.js +11 -5
- package/dist/tool/index.d.ts +1 -1
- package/dist/tool/index.js +1 -1
- package/dist/tool/system-prompt-builder.d.ts +5 -9
- package/dist/tool/system-prompt-builder.js +13 -31
- package/package.json +1 -1
|
@@ -16,16 +16,17 @@ import { TaskProgressTracker } from './task-progress-tracker.js';
|
|
|
16
16
|
* 合法状态流转映射
|
|
17
17
|
*
|
|
18
18
|
* pending → running
|
|
19
|
-
* running → success | failed | timeout | token_exhausted
|
|
19
|
+
* running → success | failed | timeout | token_exhausted | cancelled | waiting_hitl
|
|
20
20
|
*/
|
|
21
21
|
const VALID_TRANSITIONS = {
|
|
22
|
-
pending: ['running'],
|
|
23
|
-
running: ['success', 'failed', 'timeout', 'token_exhausted', 'waiting_hitl'],
|
|
24
|
-
waiting_hitl: ['running', 'timeout', 'failed'],
|
|
22
|
+
pending: ['running', 'cancelled'],
|
|
23
|
+
running: ['success', 'failed', 'timeout', 'token_exhausted', 'cancelled', 'waiting_hitl'],
|
|
24
|
+
waiting_hitl: ['running', 'timeout', 'failed', 'cancelled'],
|
|
25
25
|
success: [],
|
|
26
26
|
failed: [],
|
|
27
27
|
timeout: [],
|
|
28
28
|
token_exhausted: [],
|
|
29
|
+
cancelled: [],
|
|
29
30
|
};
|
|
30
31
|
// ─────────────────────────────────────────────
|
|
31
32
|
// In-Memory Repository (Default)
|
|
@@ -128,7 +129,11 @@ export class TaskService {
|
|
|
128
129
|
if (status === 'waiting_hitl' && output !== undefined) {
|
|
129
130
|
task.output = output;
|
|
130
131
|
}
|
|
131
|
-
if (status === 'success' ||
|
|
132
|
+
if (status === 'success' ||
|
|
133
|
+
status === 'failed' ||
|
|
134
|
+
status === 'timeout' ||
|
|
135
|
+
status === 'token_exhausted' ||
|
|
136
|
+
status === 'cancelled') {
|
|
132
137
|
task.completedAt = now;
|
|
133
138
|
if (output !== undefined) {
|
|
134
139
|
task.output = output;
|
|
@@ -215,6 +220,7 @@ export class TaskService {
|
|
|
215
220
|
case 'failed':
|
|
216
221
|
case 'timeout':
|
|
217
222
|
case 'token_exhausted':
|
|
223
|
+
case 'cancelled':
|
|
218
224
|
return 100;
|
|
219
225
|
default:
|
|
220
226
|
return 0;
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -22,4 +22,4 @@ export { expandSkillScriptRefs, isSkillEntryFile, EAP_SKILL_DIR_ENV, } from './s
|
|
|
22
22
|
export { ToolResultInjector, type ToolMessage, } from './tool-result-injector.js';
|
|
23
23
|
export { ToolEventEmitter } from './tool-event-emitter.js';
|
|
24
24
|
export { ToolConfirmationInterceptor } from './tool-confirmation.js';
|
|
25
|
-
export { SystemPromptBuilder, naturalTimeWindows, buildSkillCatalog,
|
|
25
|
+
export { SystemPromptBuilder, naturalTimeWindows, buildSkillCatalog, catalogEntryTitle, spokenName, loadedToolsToApiTools, toLoadedSkillMap, filterLoadedToolsForSkill, type PromptBuildContext, type PromptSection, type AssembledSystemPrompt, type ApiToolDefinition, type LoadedSkillInfo, type LoadedSkillMap, } from './system-prompt-builder.js';
|
package/dist/tool/index.js
CHANGED
|
@@ -21,4 +21,4 @@ export { expandSkillScriptRefs, isSkillEntryFile, EAP_SKILL_DIR_ENV, } from './s
|
|
|
21
21
|
export { ToolResultInjector, } from './tool-result-injector.js';
|
|
22
22
|
export { ToolEventEmitter } from './tool-event-emitter.js';
|
|
23
23
|
export { ToolConfirmationInterceptor } from './tool-confirmation.js';
|
|
24
|
-
export { SystemPromptBuilder, naturalTimeWindows, buildSkillCatalog,
|
|
24
|
+
export { SystemPromptBuilder, naturalTimeWindows, buildSkillCatalog, catalogEntryTitle, spokenName, loadedToolsToApiTools, toLoadedSkillMap, filterLoadedToolsForSkill, } from './system-prompt-builder.js';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* [平台规则常量] ← 代码内置,安全约束 + 行为准则(最高优先级)
|
|
9
9
|
* [当前时间] ← 运行时动态注入(自然周等时间规则的判定基准)
|
|
10
10
|
* [Agent 身份] ← 展示名 agentName,缺省 agentCode(对用户说话,不是路由键)
|
|
11
|
-
* [
|
|
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
|
-
*
|
|
19
|
+
* 工具只走 API 的 tools 参数(见 loadedToolsToApiTools),不写入 system。
|
|
20
20
|
*
|
|
21
21
|
* @see docs/status/module-status-and-backlog.md RT-5
|
|
22
22
|
*/
|
|
@@ -97,8 +97,6 @@ export interface PromptBuildContext {
|
|
|
97
97
|
}>;
|
|
98
98
|
/** 已装配 Skill 短目录;单独成段,不并进 Agent 基线 / 节点提示词 */
|
|
99
99
|
skillCatalog?: string;
|
|
100
|
-
/** 已装配工具短目录(名称 + 用途);schema 仍走 API tools */
|
|
101
|
-
toolCatalog?: string;
|
|
102
100
|
}
|
|
103
101
|
export interface PromptSection {
|
|
104
102
|
id: string;
|
|
@@ -129,7 +127,7 @@ export declare function resolveLlmPromptInputs(input: {
|
|
|
129
127
|
* SystemPromptBuilder — 系统提示词拼接
|
|
130
128
|
*
|
|
131
129
|
* 具名段拼接(无模板引擎)。顺序固定,段标题用于排查。
|
|
132
|
-
*
|
|
130
|
+
* 工具只走 API tools 参数,不进 system。技能短目录进 system(技能不是 function)。
|
|
133
131
|
* Agent 基线与节点提示词整段透传,不做 {{ }} 替换。
|
|
134
132
|
*/
|
|
135
133
|
export declare class SystemPromptBuilder {
|
|
@@ -158,6 +156,8 @@ export declare function naturalTimeWindows(now?: Date): {
|
|
|
158
156
|
* 方便 tool 模块的使用者按领域引用。
|
|
159
157
|
*/
|
|
160
158
|
export type ApiToolDefinition = LLMToolDefinition;
|
|
159
|
+
/** 展示名 + skillId,供 system「可用技能」段。read_file 仍用 skillId。 */
|
|
160
|
+
export declare function buildSkillCatalog(defs: LoadedSkillMap | undefined): string | undefined;
|
|
161
161
|
/**
|
|
162
162
|
* 将平台的 LoadedToolMap 转为 OpenAI API 的 tools 参数
|
|
163
163
|
*
|
|
@@ -168,8 +168,4 @@ export type ApiToolDefinition = LLMToolDefinition;
|
|
|
168
168
|
* @param skillTools - 可选,当前 Skill 所需的工具名称列表(过滤子集)
|
|
169
169
|
* @returns OpenAI API tools 参数数组
|
|
170
170
|
*/
|
|
171
|
-
/** 名称 + 一句话用途,供 system「可用工具」段。schema 仍走 loadedToolsToApiTools。 */
|
|
172
|
-
export declare function buildToolCatalog(loadedTools: LoadedToolMap | undefined): string | undefined;
|
|
173
|
-
/** 展示名 + skillId,供 system「可用技能」段。read_file 仍用 skillId。 */
|
|
174
|
-
export declare function buildSkillCatalog(defs: LoadedSkillMap | undefined): string | undefined;
|
|
175
171
|
export declare function loadedToolsToApiTools(loadedTools: LoadedToolMap | undefined, skillTools?: string[]): ApiToolDefinition[];
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* [平台规则常量] ← 代码内置,安全约束 + 行为准则(最高优先级)
|
|
9
9
|
* [当前时间] ← 运行时动态注入(自然周等时间规则的判定基准)
|
|
10
10
|
* [Agent 身份] ← 展示名 agentName,缺省 agentCode(对用户说话,不是路由键)
|
|
11
|
-
* [
|
|
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
|
-
*
|
|
19
|
+
* 工具只走 API 的 tools 参数(见 loadedToolsToApiTools),不写入 system。
|
|
20
20
|
*
|
|
21
21
|
* @see docs/status/module-status-and-backlog.md RT-5
|
|
22
22
|
*/
|
|
@@ -119,7 +119,7 @@ export function resolveLlmPromptInputs(input) {
|
|
|
119
119
|
* SystemPromptBuilder — 系统提示词拼接
|
|
120
120
|
*
|
|
121
121
|
* 具名段拼接(无模板引擎)。顺序固定,段标题用于排查。
|
|
122
|
-
*
|
|
122
|
+
* 工具只走 API tools 参数,不进 system。技能短目录进 system(技能不是 function)。
|
|
123
123
|
* Agent 基线与节点提示词整段透传,不做 {{ }} 替换。
|
|
124
124
|
*/
|
|
125
125
|
export class SystemPromptBuilder {
|
|
@@ -141,7 +141,6 @@ export class SystemPromptBuilder {
|
|
|
141
141
|
add('user', '当前用户', `## 当前用户\n用户标识:${context.userId.trim()}。用户说「我 / 我的」时使用此标识,不要向用户再要一遍。`);
|
|
142
142
|
}
|
|
143
143
|
add('jail', '文件与命令权限', this.buildJail(context));
|
|
144
|
-
add('tools-catalog', '可用工具', context.toolCatalog);
|
|
145
144
|
add('skills-catalog', '可用技能', context.skillCatalog);
|
|
146
145
|
add('agent', 'Agent 基线', context.agentPrompt);
|
|
147
146
|
add('node', '节点提示词', context.nodePrompt);
|
|
@@ -262,33 +261,6 @@ export function naturalTimeWindows(now = new Date()) {
|
|
|
262
261
|
lastMonth: `${formatDay(lastMonthStart)} ~ ${formatDay(lastMonthEnd)}`,
|
|
263
262
|
};
|
|
264
263
|
}
|
|
265
|
-
/**
|
|
266
|
-
* 将平台的 LoadedToolMap 转为 OpenAI API 的 tools 参数
|
|
267
|
-
*
|
|
268
|
-
* 工具通过 API 的 tools 参数传入 LLM,不嵌入 system prompt。
|
|
269
|
-
* 可按需传入 skillTools 过滤子集(只暴露当前 Skill 需要的工具)。
|
|
270
|
-
*
|
|
271
|
-
* @param loadedTools - 已装配的工具映射
|
|
272
|
-
* @param skillTools - 可选,当前 Skill 所需的工具名称列表(过滤子集)
|
|
273
|
-
* @returns OpenAI API tools 参数数组
|
|
274
|
-
*/
|
|
275
|
-
/** 名称 + 一句话用途,供 system「可用工具」段。schema 仍走 loadedToolsToApiTools。 */
|
|
276
|
-
export function buildToolCatalog(loadedTools) {
|
|
277
|
-
if (!loadedTools)
|
|
278
|
-
return undefined;
|
|
279
|
-
const rows = Object.values(loadedTools).map((tool) => {
|
|
280
|
-
const desc = (tool.manifest.description ?? '').replace(/\s+/g, ' ').trim();
|
|
281
|
-
const title = catalogEntryTitle(tool.name, tool.manifest.name, `调用名 ${tool.name}`);
|
|
282
|
-
return `- ${title}${desc ? `:${desc}` : ''}`;
|
|
283
|
-
});
|
|
284
|
-
if (rows.length === 0)
|
|
285
|
-
return undefined;
|
|
286
|
-
return [
|
|
287
|
-
'# 可用工具',
|
|
288
|
-
'调用时使用 function calling,不要假装没有这些工具。这是给你发现用的短目录,不是对用户报菜名。',
|
|
289
|
-
rows.join('\n'),
|
|
290
|
-
].join('\n');
|
|
291
|
-
}
|
|
292
264
|
/** 展示名 + skillId,供 system「可用技能」段。read_file 仍用 skillId。 */
|
|
293
265
|
export function buildSkillCatalog(defs) {
|
|
294
266
|
if (!defs)
|
|
@@ -304,6 +276,16 @@ export function buildSkillCatalog(defs) {
|
|
|
304
276
|
return undefined;
|
|
305
277
|
return `# 可用技能\n要用某个技能时,调用 read_file 读取其 SKILL.md。脚本和参考文档默认在同一目录。\n${rows.join('\n')}`;
|
|
306
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* 将平台的 LoadedToolMap 转为 OpenAI API 的 tools 参数
|
|
281
|
+
*
|
|
282
|
+
* 工具通过 API 的 tools 参数传入 LLM,不嵌入 system prompt。
|
|
283
|
+
* 可按需传入 skillTools 过滤子集(只暴露当前 Skill 需要的工具)。
|
|
284
|
+
*
|
|
285
|
+
* @param loadedTools - 已装配的工具映射
|
|
286
|
+
* @param skillTools - 可选,当前 Skill 所需的工具名称列表(过滤子集)
|
|
287
|
+
* @returns OpenAI API tools 参数数组
|
|
288
|
+
*/
|
|
307
289
|
export function loadedToolsToApiTools(loadedTools, skillTools) {
|
|
308
290
|
if (!loadedTools)
|
|
309
291
|
return [];
|