@gt-fe/eap-runtime 0.0.12 → 0.0.14
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/README.md +3 -1
- package/dist/api/handlers/invoke.handler.d.ts +1 -1
- package/dist/api/handlers/invoke.handler.js +3 -0
- package/dist/api/handlers/stream.handler.d.ts +1 -1
- package/dist/api/handlers/stream.handler.js +4 -1
- package/dist/api/routes/agent.routes.d.ts +2 -2
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +1 -0
- package/dist/common/logger.d.ts +16 -4
- package/dist/common/logger.js +82 -16
- package/dist/common/runtime-package-version.d.ts +2 -0
- package/dist/common/runtime-package-version.js +5 -0
- package/dist/common/types.d.ts +5 -5
- package/dist/common/types.js +2 -2
- package/dist/contracts/permission-checker.d.ts +1 -1
- package/dist/debug/llm-turn-log.d.ts +12 -0
- package/dist/debug/llm-turn-log.js +1 -0
- package/dist/governance/governance-client.d.ts +1 -1
- package/dist/governance/index.d.ts +1 -1
- package/dist/governance/permission-guard.d.ts +1 -1
- package/dist/graph/adapters/langgraph.adapter.d.ts +3 -1
- package/dist/graph/adapters/langgraph.adapter.js +67 -14
- package/dist/graph/adapters/subgraph-compiler.js +5 -2
- package/dist/graph/contracts/executable-graph.d.ts +19 -8
- package/dist/graph/contracts/executable-graph.js +1 -1
- package/dist/graph/nodes/llm-node.d.ts +3 -0
- package/dist/graph/nodes/llm-node.js +8 -0
- package/dist/graph/nodes/skill-bind-node.d.ts +3 -4
- package/dist/graph/nodes/skill-bind-node.js +1 -20
- package/dist/graph/nodes/tool-node.d.ts +2 -0
- package/dist/graph/nodes/tool-node.js +20 -14
- package/dist/index.d.ts +1 -1
- package/dist/memory/compression/index.d.ts +1 -1
- package/dist/memory/compression/index.js +1 -1
- package/dist/memory/compression/sliding-window.compression.js +7 -7
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/memory/message-compression.service.d.ts +12 -1
- package/dist/memory/message-compression.service.js +29 -1
- package/dist/providers/http-llm-provider.d.ts +1 -0
- package/dist/providers/http-llm-provider.js +4 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/local-llm-provider.d.ts +4 -1
- package/dist/providers/local-llm-provider.js +15 -3
- package/dist/providers/routing-llm-provider.js +13 -4
- package/dist/registry/agent-models.d.ts +1 -1
- package/dist/registry/agent-models.js +1 -1
- package/dist/registry/agent-registry-client.d.ts +1 -1
- package/dist/registry/deployment-snapshot.js +19 -17
- package/dist/registry/graph-loader.d.ts +11 -1
- package/dist/registry/graph-loader.js +115 -56
- package/dist/registry/preload-errors.d.ts +1 -1
- package/dist/registry/preload-errors.js +1 -1
- package/dist/registry/skill-io-guard.js +1 -1
- package/dist/registry/skill-tree.js +1 -1
- package/dist/runtime/agent-runtime.d.ts +3 -3
- package/dist/runtime/agent-runtime.js +14 -4
- package/dist/runtime/dev-runtime.d.ts +2 -0
- package/dist/runtime/dev-runtime.js +2 -0
- package/dist/runtime/types.d.ts +4 -4
- package/dist/server.js +1 -1
- package/dist/session/compression-middleware.d.ts +2 -1
- package/dist/session/compression-middleware.js +7 -4
- package/dist/sse/events/skill-events.d.ts +1 -1
- package/dist/sse/events/skill-events.js +1 -1
- package/dist/sse/events/stats-events.d.ts +9 -0
- package/dist/token/compression-budget-integration.d.ts +1 -1
- package/dist/token/compression-budget-integration.js +18 -10
- package/dist/token/context-window.d.ts +42 -0
- package/dist/token/context-window.js +73 -0
- package/dist/token/index.d.ts +1 -0
- package/dist/token/index.js +1 -0
- package/dist/tool/create-tool-executor.d.ts +1 -1
- package/dist/tool/dev-http-executor.d.ts +2 -1
- package/dist/tool/dev-http-executor.js +14 -2
- package/dist/tool/dev-mcp-executor.d.ts +11 -1
- package/dist/tool/dev-mcp-executor.js +27 -1
- package/dist/tool/dev-tool-executor.d.ts +2 -1
- package/dist/tool/dev-tool-executor.js +6 -0
- package/dist/tool/harness-command.js +1 -1
- package/dist/tool/harness-primitives.d.ts +7 -0
- package/dist/tool/harness-primitives.js +57 -6
- package/dist/tool/http-tool-executor.js +1 -1
- package/dist/tool/index.d.ts +2 -1
- package/dist/tool/index.js +1 -0
- package/dist/tool/local-mcp-client.d.ts +5 -2
- package/dist/tool/local-mcp-client.js +130 -3
- package/dist/tool/local-tool-executor.d.ts +3 -2
- package/dist/tool/local-tool-executor.js +16 -1
- package/dist/tool/mcp-list.d.ts +53 -0
- package/dist/tool/mcp-list.js +199 -0
- package/dist/tool/mcp-tool-executor.d.ts +6 -1
- package/dist/tool/mcp-tool-executor.js +53 -1
- package/dist/tool/skill-dir-infer.d.ts +17 -0
- package/dist/tool/skill-dir-infer.js +81 -0
- package/dist/tool/skill-script-refs.d.ts +1 -8
- package/dist/tool/skill-script-refs.js +32 -20
- package/dist/tool/system-prompt-builder.d.ts +35 -16
- package/dist/tool/system-prompt-builder.js +30 -58
- package/dist/tool/timeout.d.ts +2 -2
- package/dist/tool/timeout.js +6 -3
- package/dist/tool/tool-execution-router.d.ts +3 -2
- package/dist/tool/tool-execution-router.js +8 -1
- package/dist/tool/tool-executor.interface.d.ts +11 -0
- package/dist/tool/tool-orchestrator.d.ts +1 -1
- package/dist/tool/tool-orchestrator.js +1 -1
- package/dist/utils/format-error.d.ts +2 -2
- package/dist/utils/format-error.js +2 -2
- package/dist/utils/http-error.d.ts +2 -2
- package/dist/utils/http-error.js +2 -2
- package/package.json +6 -33
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ Enterprise Agent Platform **执行引擎**(LangGraph.js):Agent Graph 编
|
|
|
8
8
|
|
|
9
9
|
| 日期 | 摘要 |
|
|
10
10
|
|------|------|
|
|
11
|
+
| 2026-08-29 | 待办收口:[`docs/TODO.md`](./docs/TODO.md)。压缩主路径未接;窗口展示不在 Runtime;Gateway 须 `tools/list` |
|
|
11
12
|
| 2026-08-24 | 0.0.10:官方 Skill / Harness、`ForkParams`、对话详情、存储两档。依赖 `@eap/contracts@0.0.9`。详见 [CHANGELOG.md](./CHANGELOG.md) |
|
|
12
13
|
| 2026-08-21 | 0.0.9:Gateway `/mcp` JSON-RPC 补 `Accept`;`tools/call` 透传工具版本。详见 [CHANGELOG.md](./CHANGELOG.md) |
|
|
13
14
|
| 2026-08-19 | 0.0.8:Skill 子图 SSE 闭环;`ExecuteParams.traceId`;`tool.called` 改为 Tool 节点开始执行。依赖 `@eap/contracts@0.0.8`。详见 [CHANGELOG.md](./CHANGELOG.md) |
|
|
@@ -28,6 +29,7 @@ Enterprise Agent Platform **执行引擎**(LangGraph.js):Agent Graph 编
|
|
|
28
29
|
| 环境变量总表 | [`docs/governance/governance-env-config.md`](../docs/governance/governance-env-config.md) |
|
|
29
30
|
| 预装联调契约 | [`docs/contracts/preload-hosting-runtime-contract.md`](../docs/contracts/preload-hosting-runtime-contract.md) |
|
|
30
31
|
| 预装加载与请求流转 | [`docs/contracts/runtime-preinstall-load-flow.md`](../docs/contracts/runtime-preinstall-load-flow.md) |
|
|
32
|
+
| Runtime 待办 | [`docs/TODO.md`](./docs/TODO.md) | 压缩主路径、窗口展示、Gateway `tools/list` |
|
|
31
33
|
| 技能 FS 待办 | [`docs/TODO-skill-fs.md`](./docs/TODO-skill-fs.md) |
|
|
32
34
|
| 本地 Agent 闭环 | [`docs/workflows/local-agent-dev-loop.md`](../docs/workflows/local-agent-dev-loop.md) |
|
|
33
35
|
|
|
@@ -131,7 +133,7 @@ dev-tools (eap chat / eap dev)
|
|
|
131
133
|
|
|
132
134
|
- **引擎**:`LangGraphAdapter`(`IStateGraphEngine`)将平台 Graph DSL 编成 LangGraph StateGraph
|
|
133
135
|
- **节点**:`llm`、`tool`、`subgraph`(Skill)、并行/条件边、HITL 等待
|
|
134
|
-
- **Skill 子图**:节点可带内嵌 `subgraphDsl`;或仅 `skillId`,从 state.`skillDefinitions` 取 `workflow`
|
|
136
|
+
- **Skill 子图**:节点可带内嵌 `subgraphDsl`;或仅 `skillId`,从 state.`skillDefinitions` 取 `workflow` 执行。技能正文用短目录 + `read_file`,不灌 system
|
|
135
137
|
- **权限**:子图执行前 `skill:{skillId}:use`(Governance)
|
|
136
138
|
- **流式**:`stream()` 产出 RuntimeEvent,再映射为 SSE(`response.chunk`、`tool.*`、`task.*` 等)
|
|
137
139
|
|
|
@@ -22,7 +22,7 @@ import type { TokenStatsService } from '../../token/token-stats.service.js';
|
|
|
22
22
|
import type { TokenBudgetGuard } from '../../token/token-budget-guard.js';
|
|
23
23
|
import type { SessionBudgetChecker } from '../../token/session-budget-checker.js';
|
|
24
24
|
import type { InvokeRequest, InvokeResponse } from '../routes/agent.routes.js';
|
|
25
|
-
import type
|
|
25
|
+
import { type GraphLoader } from '../../registry/graph-loader.js';
|
|
26
26
|
import type { ICheckpointSaver } from '../../checkpoint/contracts/checkpoint-saver.contract.js';
|
|
27
27
|
import type { ITraceCollector } from '../../contracts/trace-collector.js';
|
|
28
28
|
/**
|
|
@@ -20,6 +20,7 @@ import { SessionBudgetExhaustedError } from '../../token/session-budget-checker.
|
|
|
20
20
|
import { TokenBudgetExhaustedError } from '../../token/token-budget-guard.js';
|
|
21
21
|
import { resolveExecutionContext } from '../../governance/governance-client.js';
|
|
22
22
|
import { resolveSkillInputFromInvokeInput } from '../../registry/skill-io-guard.js';
|
|
23
|
+
import { resolveAgentSystemPromptFromLoader } from '../../registry/graph-loader.js';
|
|
23
24
|
import { toLoadedToolMap } from '../../tool/loaded-tool-definition.js';
|
|
24
25
|
import { toLoadedSkillMap } from '../../tool/system-prompt-builder.js';
|
|
25
26
|
import { assembleLoadedTools } from '../../tool/harness-primitives.js';
|
|
@@ -181,6 +182,7 @@ export class InvokeOrchestrator {
|
|
|
181
182
|
const agentDir = this.graphLoader
|
|
182
183
|
? (await this.graphLoader.resolveAgentDir(agentCode, req.agentVersion)) ?? undefined
|
|
183
184
|
: undefined;
|
|
185
|
+
const agentSystemPrompt = await resolveAgentSystemPromptFromLoader(this.graphLoader, agentCode, req.agentVersion);
|
|
184
186
|
// 组装 GraphState:有 Checkpoint 历史则只追加本轮 user,避免双重 append
|
|
185
187
|
const history = messageRecordsToGraphMessages(sessionContext.messages);
|
|
186
188
|
const messages = await buildTurnGraphMessages({
|
|
@@ -208,6 +210,7 @@ export class InvokeOrchestrator {
|
|
|
208
210
|
skillInput,
|
|
209
211
|
promptRoots,
|
|
210
212
|
agentDir,
|
|
213
|
+
agentSystemPrompt,
|
|
211
214
|
traceId: resolveTraceId(req),
|
|
212
215
|
traceCollector: this.traceCollector,
|
|
213
216
|
});
|
|
@@ -28,7 +28,7 @@ import type { TokenStatsService } from '../../token/token-stats.service.js';
|
|
|
28
28
|
import type { TokenBudgetGuard } from '../../token/token-budget-guard.js';
|
|
29
29
|
import type { SessionBudgetChecker } from '../../token/session-budget-checker.js';
|
|
30
30
|
import type { StreamRequest } from '../routes/agent.routes.js';
|
|
31
|
-
import type
|
|
31
|
+
import { type GraphLoader } from '../../registry/graph-loader.js';
|
|
32
32
|
import type { ICheckpointSaver } from '../../checkpoint/contracts/checkpoint-saver.contract.js';
|
|
33
33
|
import type { ITraceCollector } from '../../contracts/trace-collector.js';
|
|
34
34
|
/**
|
|
@@ -25,7 +25,8 @@ import { TokenBudgetExhaustedError } from '../../token/token-budget-guard.js';
|
|
|
25
25
|
import { SSEEmitter } from '../../sse/sse-emitter.js';
|
|
26
26
|
import { resolveExecutionContext } from '../../governance/governance-client.js';
|
|
27
27
|
import { resolveSkillInputFromInvokeInput } from '../../registry/skill-io-guard.js';
|
|
28
|
-
import { ErrorCodes } from '@
|
|
28
|
+
import { ErrorCodes } from '@eap/contracts';
|
|
29
|
+
import { resolveAgentSystemPromptFromLoader } from '../../registry/graph-loader.js';
|
|
29
30
|
import { classifyRuntimeError } from '../../utils/http-error.js';
|
|
30
31
|
import { toLoadedToolMap } from '../../tool/loaded-tool-definition.js';
|
|
31
32
|
import { toLoadedSkillMap } from '../../tool/system-prompt-builder.js';
|
|
@@ -203,6 +204,7 @@ export class StreamOrchestrator {
|
|
|
203
204
|
const agentDir = this.graphLoader
|
|
204
205
|
? (await this.graphLoader.resolveAgentDir(agentCode, req.agentVersion)) ?? undefined
|
|
205
206
|
: undefined;
|
|
207
|
+
const agentSystemPrompt = await resolveAgentSystemPromptFromLoader(this.graphLoader, agentCode, req.agentVersion);
|
|
206
208
|
// 组装 GraphState:有 Checkpoint 历史则只追加本轮 user,避免双重 append
|
|
207
209
|
const history = messageRecordsToGraphMessages(sessionContext.messages);
|
|
208
210
|
const messages = await buildTurnGraphMessages({
|
|
@@ -236,6 +238,7 @@ export class StreamOrchestrator {
|
|
|
236
238
|
skillInput,
|
|
237
239
|
promptRoots,
|
|
238
240
|
agentDir,
|
|
241
|
+
agentSystemPrompt,
|
|
239
242
|
traceId: resolveTraceId(req),
|
|
240
243
|
traceCollector: this.traceCollector,
|
|
241
244
|
});
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* 生产环境由 Hosting 提供对外 HTTP;本模块供 `EAP_DEV_HTTP=1` 本地调试。
|
|
5
5
|
*/
|
|
6
6
|
import type { ServerResponse } from 'node:http';
|
|
7
|
-
import type { InvokeRequest as ContractInvokeRequest, InvokeResponse as ContractInvokeResponse } from '@
|
|
7
|
+
import type { InvokeRequest as ContractInvokeRequest, InvokeResponse as ContractInvokeResponse } from '@eap/contracts';
|
|
8
8
|
import type { ITaskManager } from '../../task/task.service.js';
|
|
9
9
|
import type { SessionService } from '../../session/session.service.js';
|
|
10
10
|
import type { IStateGraphEngine } from '../../graph/contracts/executable-graph.js';
|
|
11
11
|
import type { SSEEmitter } from '../../sse/sse-emitter.js';
|
|
12
|
-
export type { InvokeConfig, InvokeResponseData } from '@
|
|
12
|
+
export type { InvokeConfig, InvokeResponseData } from '@eap/contracts';
|
|
13
13
|
/**
|
|
14
14
|
* dev HTTP 层 Invoke 请求(扩展 userId,Hosting 从 auth 注入)
|
|
15
15
|
*/
|
package/dist/common/index.d.ts
CHANGED
package/dist/common/index.js
CHANGED
package/dist/common/logger.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 结构化 stdout JSON 日志。
|
|
3
|
+
*
|
|
4
|
+
* EAP_LOG_LEVEL=debug|info|warn|error,默认 info。
|
|
5
|
+
* info 不写 prompt / messages / systemPrompt;正文在 llm_turns。
|
|
6
|
+
* 关联字段:correlationId、taskId、sessionId、agentCode。
|
|
3
7
|
*/
|
|
4
8
|
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
5
9
|
export interface LogEntry {
|
|
@@ -7,8 +11,13 @@ export interface LogEntry {
|
|
|
7
11
|
timestamp: string;
|
|
8
12
|
module: string;
|
|
9
13
|
message: string;
|
|
14
|
+
correlationId?: string;
|
|
15
|
+
taskId?: string;
|
|
16
|
+
sessionId?: string;
|
|
17
|
+
agentCode?: string;
|
|
18
|
+
userId?: string;
|
|
19
|
+
event?: string;
|
|
10
20
|
context?: Record<string, unknown>;
|
|
11
|
-
error?: Error;
|
|
12
21
|
}
|
|
13
22
|
export interface ILogger {
|
|
14
23
|
debug(message: string, context?: Record<string, unknown>): void;
|
|
@@ -16,6 +25,10 @@ export interface ILogger {
|
|
|
16
25
|
warn(message: string, context?: Record<string, unknown>): void;
|
|
17
26
|
error(message: string, context?: Record<string, unknown>): void;
|
|
18
27
|
}
|
|
28
|
+
export declare function resolveLogLevel(env?: NodeJS.ProcessEnv): LogLevel;
|
|
29
|
+
export declare function shouldLog(level: LogLevel, min?: LogLevel): boolean;
|
|
30
|
+
export declare function formatLogEntry(level: LogLevel, module: string, message: string, context?: Record<string, unknown>): LogEntry;
|
|
31
|
+
export declare function emitRuntimeLog(level: LogLevel, module: string, message: string, context?: Record<string, unknown>): void;
|
|
19
32
|
export declare class ConsoleLogger implements ILogger {
|
|
20
33
|
private readonly module;
|
|
21
34
|
constructor(module: string);
|
|
@@ -23,9 +36,8 @@ export declare class ConsoleLogger implements ILogger {
|
|
|
23
36
|
info(message: string, context?: Record<string, unknown>): void;
|
|
24
37
|
warn(message: string, context?: Record<string, unknown>): void;
|
|
25
38
|
error(message: string, context?: Record<string, unknown>): void;
|
|
26
|
-
private log;
|
|
27
39
|
}
|
|
28
|
-
/**
|
|
40
|
+
/** 测试用空实现 */
|
|
29
41
|
export declare class NoopLogger implements ILogger {
|
|
30
42
|
debug(): void;
|
|
31
43
|
info(): void;
|
package/dist/common/logger.js
CHANGED
|
@@ -1,35 +1,101 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 结构化 stdout JSON 日志。
|
|
3
|
+
*
|
|
4
|
+
* EAP_LOG_LEVEL=debug|info|warn|error,默认 info。
|
|
5
|
+
* info 不写 prompt / messages / systemPrompt;正文在 llm_turns。
|
|
6
|
+
* 关联字段:correlationId、taskId、sessionId、agentCode。
|
|
3
7
|
*/
|
|
8
|
+
const LEVEL_RANK = {
|
|
9
|
+
debug: 10,
|
|
10
|
+
info: 20,
|
|
11
|
+
warn: 30,
|
|
12
|
+
error: 40,
|
|
13
|
+
};
|
|
14
|
+
const PROMPT_KEYS = new Set([
|
|
15
|
+
'systemPrompt',
|
|
16
|
+
'systemSections',
|
|
17
|
+
'messages',
|
|
18
|
+
'prompt',
|
|
19
|
+
'developerPrompt',
|
|
20
|
+
'agentPrompt',
|
|
21
|
+
'nodePrompt',
|
|
22
|
+
'agentSystemPrompt',
|
|
23
|
+
'apiKey',
|
|
24
|
+
'content',
|
|
25
|
+
'body',
|
|
26
|
+
]);
|
|
27
|
+
const ID_KEYS = ['correlationId', 'taskId', 'sessionId', 'agentCode', 'userId'];
|
|
28
|
+
export function resolveLogLevel(env = process.env) {
|
|
29
|
+
const raw = env.EAP_LOG_LEVEL?.trim().toLowerCase();
|
|
30
|
+
if (raw === 'debug' || raw === 'info' || raw === 'warn' || raw === 'error')
|
|
31
|
+
return raw;
|
|
32
|
+
return 'info';
|
|
33
|
+
}
|
|
34
|
+
export function shouldLog(level, min = resolveLogLevel()) {
|
|
35
|
+
return LEVEL_RANK[level] >= LEVEL_RANK[min];
|
|
36
|
+
}
|
|
37
|
+
function asId(value) {
|
|
38
|
+
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
39
|
+
}
|
|
40
|
+
function stripPromptFields(context, level) {
|
|
41
|
+
if (!context)
|
|
42
|
+
return undefined;
|
|
43
|
+
const out = {};
|
|
44
|
+
for (const [key, value] of Object.entries(context)) {
|
|
45
|
+
if (key === 'event' || ID_KEYS.includes(key))
|
|
46
|
+
continue;
|
|
47
|
+
if (level !== 'debug' && PROMPT_KEYS.has(key))
|
|
48
|
+
continue;
|
|
49
|
+
out[key] = value;
|
|
50
|
+
}
|
|
51
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
52
|
+
}
|
|
53
|
+
export function formatLogEntry(level, module, message, context) {
|
|
54
|
+
const safe = stripPromptFields(context, level);
|
|
55
|
+
const event = asId(context?.event) ?? asId(safe?.event);
|
|
56
|
+
const entry = {
|
|
57
|
+
level,
|
|
58
|
+
timestamp: new Date().toISOString(),
|
|
59
|
+
module,
|
|
60
|
+
message,
|
|
61
|
+
correlationId: asId(context?.correlationId),
|
|
62
|
+
taskId: asId(context?.taskId),
|
|
63
|
+
sessionId: asId(context?.sessionId),
|
|
64
|
+
agentCode: asId(context?.agentCode),
|
|
65
|
+
userId: asId(context?.userId),
|
|
66
|
+
...(event ? { event } : {}),
|
|
67
|
+
...(safe ? { context: safe } : {}),
|
|
68
|
+
};
|
|
69
|
+
return entry;
|
|
70
|
+
}
|
|
71
|
+
export function emitRuntimeLog(level, module, message, context) {
|
|
72
|
+
if (!shouldLog(level))
|
|
73
|
+
return;
|
|
74
|
+
const line = JSON.stringify(formatLogEntry(level, module, message, context));
|
|
75
|
+
if (level === 'error')
|
|
76
|
+
console.error(line);
|
|
77
|
+
else
|
|
78
|
+
console.log(line);
|
|
79
|
+
}
|
|
4
80
|
export class ConsoleLogger {
|
|
5
81
|
module;
|
|
6
82
|
constructor(module) {
|
|
7
83
|
this.module = module;
|
|
8
84
|
}
|
|
9
85
|
debug(message, context) {
|
|
10
|
-
|
|
86
|
+
emitRuntimeLog('debug', this.module, message, context);
|
|
11
87
|
}
|
|
12
88
|
info(message, context) {
|
|
13
|
-
|
|
89
|
+
emitRuntimeLog('info', this.module, message, context);
|
|
14
90
|
}
|
|
15
91
|
warn(message, context) {
|
|
16
|
-
|
|
92
|
+
emitRuntimeLog('warn', this.module, message, context);
|
|
17
93
|
}
|
|
18
94
|
error(message, context) {
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
log(level, message, context) {
|
|
22
|
-
const entry = {
|
|
23
|
-
level,
|
|
24
|
-
timestamp: new Date().toISOString(),
|
|
25
|
-
module: this.module,
|
|
26
|
-
message,
|
|
27
|
-
...(context && { context }),
|
|
28
|
-
};
|
|
29
|
-
console[level](JSON.stringify(entry));
|
|
95
|
+
emitRuntimeLog('error', this.module, message, context);
|
|
30
96
|
}
|
|
31
97
|
}
|
|
32
|
-
/**
|
|
98
|
+
/** 测试用空实现 */
|
|
33
99
|
export class NoopLogger {
|
|
34
100
|
debug() { }
|
|
35
101
|
info() { }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
const pkg = require('../../package.json');
|
|
4
|
+
/** 当前加载的 Runtime 包版本(`package.json`;overlay 为 `@gt-fe/eap-runtime` 的 version) */
|
|
5
|
+
export const RUNTIME_PACKAGE_VERSION = typeof pkg.version === 'string' && pkg.version.trim() ? pkg.version.trim() : 'unknown';
|
package/dist/common/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* eap-runtime 内部共享类型定义
|
|
3
3
|
*
|
|
4
|
-
* 本文件定义 Runtime 模块内部使用的类型,与 @
|
|
5
|
-
* - @
|
|
4
|
+
* 本文件定义 Runtime 模块内部使用的类型,与 @eap/contracts 中的公共协议类型互补但不重复。
|
|
5
|
+
* - @eap/contracts 定义跨模块的公共协议(如 Task 实体、Session 实体、Agent Manifest)
|
|
6
6
|
* - 本文件定义 Runtime 执行引擎内部流转的配置、上下文、枚举等
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
@@ -32,7 +32,7 @@ export declare const DEFAULT_RUNTIME_CONFIG: RuntimeConfig;
|
|
|
32
32
|
/**
|
|
33
33
|
* 执行上下文 — 贯穿 Graph 执行生命周期(Runtime 内部)
|
|
34
34
|
*
|
|
35
|
-
* 平台级 ExecutionContext(@
|
|
35
|
+
* 平台级 ExecutionContext(@eap/contracts)由 Hosting/eap dev 注入;
|
|
36
36
|
* 本类型在 Task 创建后组装,供引擎子服务使用。
|
|
37
37
|
*/
|
|
38
38
|
export interface RuntimeRunContext {
|
|
@@ -62,7 +62,7 @@ export type TaskStatus = 'pending' | 'running' | 'waiting_hitl' | 'success' | 'f
|
|
|
62
62
|
/**
|
|
63
63
|
* Runtime 执行上下文绑定状态(非平台 Session 生命周期)
|
|
64
64
|
*
|
|
65
|
-
* 平台 Session 三态(active/paused/closed)由 Hosting 管理,见 @
|
|
65
|
+
* 平台 Session 三态(active/paused/closed)由 Hosting 管理,见 @eap/contracts。
|
|
66
66
|
* Runtime 仅在引擎内标记执行上下文是否仍可绑定:`active` | `archived`。
|
|
67
67
|
*/
|
|
68
68
|
export type ExecutionSessionBindingStatus = 'active' | 'archived';
|
|
@@ -77,7 +77,7 @@ export type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
|
77
77
|
/**
|
|
78
78
|
* 单次 LLM/Tool 调用的 Token 消耗记录
|
|
79
79
|
*
|
|
80
|
-
* 与 @
|
|
80
|
+
* 与 @eap/contracts.TokenUsage 的区别:
|
|
81
81
|
* - contracts 版本是 Task 级聚合结果(含 byNode/byModel)
|
|
82
82
|
* - 本类型是单次调用粒度的原始记录,用于 Runtime 内部累计和 stats.node_token 事件
|
|
83
83
|
*/
|
package/dist/common/types.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* eap-runtime 内部共享类型定义
|
|
3
3
|
*
|
|
4
|
-
* 本文件定义 Runtime 模块内部使用的类型,与 @
|
|
5
|
-
* - @
|
|
4
|
+
* 本文件定义 Runtime 模块内部使用的类型,与 @eap/contracts 中的公共协议类型互补但不重复。
|
|
5
|
+
* - @eap/contracts 定义跨模块的公共协议(如 Task 实体、Session 实体、Agent Manifest)
|
|
6
6
|
* - 本文件定义 Runtime 执行引擎内部流转的配置、上下文、枚举等
|
|
7
7
|
*/
|
|
8
8
|
/** RuntimeConfig 默认值 */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 权限校验器接口(对齐 06-governance R16.8)
|
|
3
3
|
*/
|
|
4
|
-
import type { ExecutionContext, GovernancePermissionCheckParams, GovernancePermissionCheckResult } from '@
|
|
4
|
+
import type { ExecutionContext, GovernancePermissionCheckParams, GovernancePermissionCheckResult } from '@eap/contracts';
|
|
5
5
|
/**
|
|
6
6
|
* IPermissionChecker — Runtime 执行期权限校验
|
|
7
7
|
*/
|
|
@@ -41,6 +41,16 @@ export interface LlmTurnRecord extends LlmTurnContext {
|
|
|
41
41
|
error?: string;
|
|
42
42
|
};
|
|
43
43
|
latencyMs: number;
|
|
44
|
+
/** 本轮 prompt inputTokens / 模型上下文窗;parts 为字符比例拆分;缺 window 则省略 window */
|
|
45
|
+
context?: {
|
|
46
|
+
used: number;
|
|
47
|
+
window?: number;
|
|
48
|
+
parts?: {
|
|
49
|
+
system: number;
|
|
50
|
+
messages: number;
|
|
51
|
+
tools: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
44
54
|
}
|
|
45
55
|
export interface LlmTurnIndexEntry {
|
|
46
56
|
id: string;
|
|
@@ -53,6 +63,8 @@ export interface LlmTurnIndexEntry {
|
|
|
53
63
|
file: string;
|
|
54
64
|
inputTokens: number;
|
|
55
65
|
outputTokens: number;
|
|
66
|
+
used?: number;
|
|
67
|
+
window?: number;
|
|
56
68
|
}
|
|
57
69
|
export type LlmTurnLogKind = 'memory' | 'file' | 'postgres';
|
|
58
70
|
export interface ILlmTurnLog {
|
|
@@ -21,6 +21,7 @@ export function toLlmTurnIndexEntry(record, file) {
|
|
|
21
21
|
file: file ?? `${sanitize(record.id)}.json`,
|
|
22
22
|
inputTokens: record.response.inputTokens,
|
|
23
23
|
outputTokens: record.response.outputTokens,
|
|
24
|
+
...(record.context ?? {}),
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
export function maskApiKey(key) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 治理服务 HTTP 客户端(06-governance validateToken / checkPermission)
|
|
3
3
|
*/
|
|
4
|
-
import type { ExecutionContext, GovernancePermissionCheckParams, GovernancePermissionCheckResult } from '@
|
|
4
|
+
import type { ExecutionContext, GovernancePermissionCheckParams, GovernancePermissionCheckResult } from '@eap/contracts';
|
|
5
5
|
export interface HttpGovernanceClientOptions {
|
|
6
6
|
baseUrl: string;
|
|
7
7
|
timeout?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 权限校验 — 对齐 06-governance R16.8
|
|
3
3
|
*/
|
|
4
|
-
export type { CallerType, ExecutionContext, GovernancePermissionCheckParams, GovernancePermissionCheckResult, PermissionAction, PermissionDenyReason, PermissionResourceType, } from '@
|
|
4
|
+
export type { CallerType, ExecutionContext, GovernancePermissionCheckParams, GovernancePermissionCheckResult, PermissionAction, PermissionDenyReason, PermissionResourceType, } from '@eap/contracts';
|
|
5
5
|
export type { IGovernanceClient } from './governance-client.js';
|
|
6
6
|
export { HttpGovernanceClient, AllowAllGovernanceClient, resolveExecutionContext, } from './governance-client.js';
|
|
7
7
|
export { assertToolPermission, assertSkillPermission, permissionMessage, PermissionDeniedError, GovernanceUnavailableError, } from './permission-guard.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 执行期 Tool 权限守卫
|
|
3
3
|
*/
|
|
4
|
-
import type { ExecutionContext, PermissionDenyReason } from '@
|
|
4
|
+
import type { ExecutionContext, PermissionDenyReason } from '@eap/contracts';
|
|
5
5
|
import type { IGovernanceClient } from './governance-client.js';
|
|
6
6
|
export declare class GovernanceUnavailableError extends Error {
|
|
7
7
|
readonly reason: PermissionDenyReason;
|
|
@@ -15,6 +15,8 @@ import { type ILLMProvider } from '../nodes/llm-node.js';
|
|
|
15
15
|
import type { IToolExecutor } from '../../tool/tool-executor.interface.js';
|
|
16
16
|
import type { IGovernanceClient } from '../../governance/governance-client.js';
|
|
17
17
|
import { type ConditionEvaluatorFn } from '../condition-evaluator.js';
|
|
18
|
+
/** 图未写 `config.maxIterations` 时的 recursionLimit。`agent ⇄ tools` 一圈约 2,50 ≈ 24 次工具往返。 */
|
|
19
|
+
export declare const DEFAULT_GRAPH_RECURSION_LIMIT = 50;
|
|
18
20
|
/**
|
|
19
21
|
* LangGraphAdapter — 基于 @langchain/langgraph 的 IStateGraphEngine 实现
|
|
20
22
|
*
|
|
@@ -118,7 +120,7 @@ export declare class LangGraphAdapter implements IStateGraphEngine {
|
|
|
118
120
|
private createLLMNodeFunction;
|
|
119
121
|
/**
|
|
120
122
|
* 子图节点:优先 config.subgraphDsl;否则按 skillId 从 state.skillDefinitions.workflow 解析。
|
|
121
|
-
*
|
|
123
|
+
* 技能正文用短目录 + read_file,不灌 system。
|
|
122
124
|
*/
|
|
123
125
|
private createSubGraphNodeFunction;
|
|
124
126
|
/**
|