@gt-fe/eap-runtime 0.0.10 → 0.0.11

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 (87) hide show
  1. package/README.md +3 -3
  2. package/dist/api/handlers/invoke.handler.js +4 -0
  3. package/dist/api/handlers/stream.handler.js +5 -1
  4. package/dist/api/routes/agent.routes.d.ts +2 -2
  5. package/dist/common/types.d.ts +5 -5
  6. package/dist/common/types.js +2 -2
  7. package/dist/contracts/permission-checker.d.ts +1 -1
  8. package/dist/contracts/trace-collector.d.ts +1 -1
  9. package/dist/governance/governance-client.d.ts +1 -1
  10. package/dist/governance/governance-client.js +40 -16
  11. package/dist/governance/index.d.ts +2 -2
  12. package/dist/governance/index.js +1 -1
  13. package/dist/governance/permission-guard.d.ts +2 -1
  14. package/dist/governance/permission-guard.js +13 -4
  15. package/dist/graph/adapters/langgraph.adapter.js +12 -7
  16. package/dist/graph/contracts/executable-graph.d.ts +8 -6
  17. package/dist/graph/contracts/executable-graph.js +1 -1
  18. package/dist/graph/hitl/hitl-handler.d.ts +3 -0
  19. package/dist/graph/hitl/hitl-handler.js +4 -1
  20. package/dist/graph/nodes/tool-node.js +27 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +1 -1
  23. package/dist/providers/echo-llm-provider.js +2 -2
  24. package/dist/providers/local-llm-provider.d.ts +1 -1
  25. package/dist/providers/local-llm-provider.js +1 -1
  26. package/dist/providers/routing-llm-provider.js +1 -1
  27. package/dist/registry/agent-models.d.ts +1 -1
  28. package/dist/registry/agent-models.js +1 -1
  29. package/dist/registry/agent-registry-client.d.ts +1 -1
  30. package/dist/registry/deployment-snapshot.d.ts +14 -2
  31. package/dist/registry/deployment-snapshot.js +57 -31
  32. package/dist/registry/graph-loader.d.ts +1 -1
  33. package/dist/registry/graph-loader.js +4 -4
  34. package/dist/registry/index.d.ts +1 -1
  35. package/dist/registry/index.js +1 -1
  36. package/dist/registry/preload-errors.d.ts +1 -1
  37. package/dist/registry/preload-errors.js +1 -1
  38. package/dist/registry/skill-io-guard.js +1 -1
  39. package/dist/registry/skill-tree.js +1 -1
  40. package/dist/runtime/agent-runtime.js +19 -5
  41. package/dist/runtime/dev-runtime.d.ts +1 -1
  42. package/dist/runtime/dev-runtime.js +6 -10
  43. package/dist/runtime/types.d.ts +2 -2
  44. package/dist/server.js +1 -1
  45. package/dist/sse/events/skill-events.d.ts +1 -1
  46. package/dist/sse/events/skill-events.js +1 -1
  47. package/dist/tool/create-tool-executor.d.ts +1 -1
  48. package/dist/tool/dev-http-executor.d.ts +1 -1
  49. package/dist/tool/dev-http-executor.js +10 -7
  50. package/dist/tool/dev-mcp-executor.js +5 -3
  51. package/dist/tool/dev-tool-executor.d.ts +1 -1
  52. package/dist/tool/dev-tool-executor.js +2 -2
  53. package/dist/tool/harness-command.d.ts +32 -0
  54. package/dist/tool/harness-command.js +276 -0
  55. package/dist/tool/harness-primitives.d.ts +25 -3
  56. package/dist/tool/harness-primitives.js +157 -50
  57. package/dist/tool/http-tool-executor.js +15 -20
  58. package/dist/tool/index.d.ts +3 -2
  59. package/dist/tool/index.js +3 -2
  60. package/dist/tool/local-mcp-client.d.ts +1 -1
  61. package/dist/tool/local-mcp-client.js +54 -23
  62. package/dist/tool/local-tool-executor.d.ts +1 -1
  63. package/dist/tool/local-tool-executor.js +13 -9
  64. package/dist/tool/mcp-tool-executor.js +14 -6
  65. package/dist/tool/skill-script-refs.d.ts +20 -0
  66. package/dist/tool/skill-script-refs.js +62 -0
  67. package/dist/tool/system-prompt-builder.d.ts +2 -2
  68. package/dist/tool/system-prompt-builder.js +8 -5
  69. package/dist/tool/timeout.d.ts +14 -0
  70. package/dist/tool/timeout.js +36 -0
  71. package/dist/tool/tool-confirmation.js +2 -1
  72. package/dist/tool/tool-execution-router.d.ts +1 -1
  73. package/dist/tool/tool-execution-router.js +1 -1
  74. package/dist/tool/tool-executor.interface.d.ts +13 -3
  75. package/dist/tool/tool-orchestrator.d.ts +1 -1
  76. package/dist/tool/tool-orchestrator.js +6 -3
  77. package/dist/utils/format-error.d.ts +2 -2
  78. package/dist/utils/format-error.js +2 -2
  79. package/dist/utils/http-error.d.ts +2 -2
  80. package/dist/utils/http-error.js +2 -2
  81. package/package.json +2 -2
  82. package/dist/common/concurrency.d.ts +0 -79
  83. package/dist/common/concurrency.js +0 -121
  84. package/dist/common/queue-consumer.d.ts +0 -125
  85. package/dist/common/queue-consumer.js +0 -159
  86. package/dist/tool/mock-tool-executor.d.ts +0 -28
  87. package/dist/tool/mock-tool-executor.js +0 -65
@@ -73,13 +73,25 @@ export interface IDeploymentSnapshot {
73
73
  }
74
74
  /** 规范化摘要:去 sha256: 前缀、空白,转小写 hex */
75
75
  export declare function normalizeDigest(value: unknown): string | null;
76
+ /**
77
+ * Agent 清单装配读取:现行 `skills`,兼容 CLI `skillRefs`。
78
+ * 项身份:`code` / `skill` / `skillId`。两边都有时现行字段先写入;同名只补 version/name 等空位。
79
+ */
80
+ export declare function skillRefsFromManifest(manifest: Record<string, unknown>): SnapshotSkillRef[];
76
81
  /**
77
82
  * 装配引用 vs 内联完整 ToolManifest。
78
- * 含 type/execution 的视为内联定义;仅 toolset/name/version/enabledTools 等视为引用。
83
+ * 含 type/execution 的视为内联定义;仅 code/toolset/version/enabled 等视为引用。
79
84
  */
80
85
  export declare function isInlineToolDeclaration(item: unknown): boolean;
81
86
  /**
82
- * 将 agent.manifest.toolsets 上的 enabled/autoApprove 叠到 snapshot.tools[](snapshot 未带时)。
87
+ * 从 Agent 清单收集工具集装配引用。
88
+ * 现行 `toolsets`;兼容 CLI `toolRefs` 与更旧的 `tools`(内联完整 manifest 会跳过)。
89
+ * 项身份:`code` / `toolset`(字符串项即 code)。不用展示名 `name`。白名单:`enabled` / `enabledTools`。
90
+ * 两边都有时现行字段先写入;同名条目的 enabled/autoApprove 以先写入为准。
91
+ */
92
+ export declare function toolsetsFromManifest(manifest: Record<string, unknown>): SnapshotToolRef[];
93
+ /**
94
+ * 将 agent.manifest 装配项上的 enabled/autoApprove 叠到 snapshot.tools[](snapshot 未带时)。
83
95
  */
84
96
  export declare function overlayToolRefPolicies(snapTools: SnapshotToolRef[], manifest?: Record<string, unknown>): SnapshotToolRef[];
85
97
  export declare class FileSystemDeploymentSnapshot implements IDeploymentSnapshot {
@@ -13,7 +13,7 @@ import { readdir, readFile, access } from 'node:fs/promises';
13
13
  import { createHash } from 'node:crypto';
14
14
  import path from 'node:path';
15
15
  import { constants as fsConstants } from 'node:fs';
16
- import { parseSkillMd } from '@gt-fe/eap-contracts';
16
+ import { parseSkillMd } from '@eap/contracts';
17
17
  import { findSkillEntryFile } from './skill-tree.js';
18
18
  import { preloadMissing, preloadPackageCorrupt, } from './preload-errors.js';
19
19
  import { isRequireChecksum, resolvePreloadBehaviorFlags, } from './preload-flags.js';
@@ -140,29 +140,51 @@ async function pickLatestVersionDir(parent) {
140
140
  dirs.sort();
141
141
  return path.join(parent, dirs[dirs.length - 1]);
142
142
  }
143
- function skillRefsFromManifest(manifest) {
144
- const raw = manifest.skills;
145
- if (!Array.isArray(raw))
146
- return [];
143
+ function asArray(value) {
144
+ return Array.isArray(value) ? value : [];
145
+ }
146
+ /**
147
+ * Agent 清单装配读取:现行 `skills`,兼容 CLI `skillRefs`。
148
+ * 项身份:`code` / `skill` / `skillId`。两边都有时现行字段先写入;同名只补 version/name 等空位。
149
+ */
150
+ export function skillRefsFromManifest(manifest) {
147
151
  const out = [];
148
- for (const item of raw) {
152
+ const byId = new Map();
153
+ const upsert = (ref) => {
154
+ const prev = byId.get(ref.skillId);
155
+ if (!prev) {
156
+ byId.set(ref.skillId, ref);
157
+ out.push(ref);
158
+ return;
159
+ }
160
+ if (!prev.version && ref.version)
161
+ prev.version = ref.version;
162
+ if (!prev.name && ref.name)
163
+ prev.name = ref.name;
164
+ if (!prev.description && ref.description)
165
+ prev.description = ref.description;
166
+ if (!prev.sha256 && ref.sha256)
167
+ prev.sha256 = ref.sha256;
168
+ };
169
+ for (const item of [...asArray(manifest.skills), ...asArray(manifest.skillRefs)]) {
149
170
  if (typeof item === 'string') {
150
- out.push({ skillId: item });
171
+ if (item)
172
+ upsert({ skillId: item });
151
173
  continue;
152
174
  }
153
- if (item && typeof item === 'object') {
154
- const o = item;
155
- const skillId = String(o.code ?? '');
156
- if (!skillId)
157
- continue;
158
- out.push({
159
- skillId,
160
- name: o.name != null ? String(o.name) : undefined,
161
- version: o.version != null ? String(o.version) : undefined,
162
- description: o.description != null ? String(o.description) : undefined,
163
- sha256: typeof o.sha256 === 'string' ? o.sha256 : undefined,
164
- });
165
- }
175
+ if (!item || typeof item !== 'object')
176
+ continue;
177
+ const o = item;
178
+ const skillId = String(o.code ?? o.skill ?? o.skillId ?? '');
179
+ if (!skillId)
180
+ continue;
181
+ upsert({
182
+ skillId,
183
+ name: o.name != null ? String(o.name) : undefined,
184
+ version: o.version != null ? String(o.version) : undefined,
185
+ description: o.description != null ? String(o.description) : undefined,
186
+ sha256: typeof o.sha256 === 'string' ? o.sha256 : undefined,
187
+ });
166
188
  }
167
189
  return out;
168
190
  }
@@ -174,7 +196,7 @@ function parseStringList(value) {
174
196
  }
175
197
  /**
176
198
  * 装配引用 vs 内联完整 ToolManifest。
177
- * 含 type/execution 的视为内联定义;仅 toolset/name/version/enabledTools 等视为引用。
199
+ * 含 type/execution 的视为内联定义;仅 code/toolset/version/enabled 等视为引用。
178
200
  */
179
201
  export function isInlineToolDeclaration(item) {
180
202
  if (!item || typeof item !== 'object' || Array.isArray(item))
@@ -191,7 +213,7 @@ function parseToolAssemblyRef(item) {
191
213
  if (isInlineToolDeclaration(item))
192
214
  return null;
193
215
  const o = item;
194
- const name = String(o.code ?? o.name ?? '');
216
+ const name = String(o.code ?? o.toolset ?? '');
195
217
  if (!name)
196
218
  return null;
197
219
  return {
@@ -199,13 +221,17 @@ function parseToolAssemblyRef(item) {
199
221
  toolId: o.toolId != null ? String(o.toolId) : undefined,
200
222
  version: o.version != null ? String(o.version) : undefined,
201
223
  sha256: typeof o.sha256 === 'string' ? o.sha256 : undefined,
202
- enabledTools: parseStringList(o.enabled),
224
+ enabledTools: parseStringList(o.enabled) ?? parseStringList(o.enabledTools),
203
225
  autoApprove: parseStringList(o.autoApprove),
204
226
  };
205
227
  }
206
228
  /**
207
- /** 从 agent.manifest.toolsets 收集工具集装配引用。 */
208
- function toolsetsFromManifest(manifest) {
229
+ * 从 Agent 清单收集工具集装配引用。
230
+ * 现行 `toolsets`;兼容 CLI `toolRefs` 与更旧的 `tools`(内联完整 manifest 会跳过)。
231
+ * 项身份:`code` / `toolset`(字符串项即 code)。不用展示名 `name`。白名单:`enabled` / `enabledTools`。
232
+ * 两边都有时现行字段先写入;同名条目的 enabled/autoApprove 以先写入为准。
233
+ */
234
+ export function toolsetsFromManifest(manifest) {
209
235
  const out = [];
210
236
  const byName = new Map();
211
237
  const upsert = (ref) => {
@@ -215,10 +241,6 @@ function toolsetsFromManifest(manifest) {
215
241
  out.push(ref);
216
242
  return;
217
243
  }
218
- if (!prev.enabledTools && ref.enabledTools)
219
- prev.enabledTools = ref.enabledTools;
220
- if (!prev.autoApprove && ref.autoApprove)
221
- prev.autoApprove = ref.autoApprove;
222
244
  if (!prev.version && ref.version)
223
245
  prev.version = ref.version;
224
246
  if (!prev.sha256 && ref.sha256)
@@ -226,7 +248,11 @@ function toolsetsFromManifest(manifest) {
226
248
  if (!prev.toolId && ref.toolId)
227
249
  prev.toolId = ref.toolId;
228
250
  };
229
- for (const item of Array.isArray(manifest.toolsets) ? manifest.toolsets : []) {
251
+ for (const item of [
252
+ ...asArray(manifest.toolsets),
253
+ ...asArray(manifest.toolRefs),
254
+ ...asArray(manifest.tools),
255
+ ]) {
230
256
  const ref = parseToolAssemblyRef(item);
231
257
  if (ref)
232
258
  upsert(ref);
@@ -234,7 +260,7 @@ function toolsetsFromManifest(manifest) {
234
260
  return out;
235
261
  }
236
262
  /**
237
- * 将 agent.manifest.toolsets 上的 enabled/autoApprove 叠到 snapshot.tools[](snapshot 未带时)。
263
+ * 将 agent.manifest 装配项上的 enabled/autoApprove 叠到 snapshot.tools[](snapshot 未带时)。
238
264
  */
239
265
  export function overlayToolRefPolicies(snapTools, manifest) {
240
266
  if (!manifest)
@@ -7,7 +7,7 @@
7
7
  import type { GraphDSL } from '../graph/contracts/executable-graph.js';
8
8
  import type { AgentRegistryClient } from './agent-registry-client.js';
9
9
  import type { DeploymentContext } from '../tool/tool-execution-router.js';
10
- import type { ILocalToolInstallStore } from '@gt-fe/eap-contracts';
10
+ import type { ILocalToolInstallStore } from '@eap/contracts';
11
11
  import { type LoadedToolDefinition } from '../tool/loaded-tool-definition.js';
12
12
  import type { LoadedSkillInfo } from '../tool/system-prompt-builder.js';
13
13
  import { type IDeploymentSnapshot } from './deployment-snapshot.js';
@@ -7,6 +7,7 @@
7
7
  import { readFile } from 'node:fs/promises';
8
8
  import path from 'node:path';
9
9
  import { resolveAgentModelAllowlist, resolveAgentDefaultModel } from './agent-models.js';
10
+ import { DEFAULT_HTTP_TOOL_TIMEOUT_SEC, DEFAULT_TOOL_TIMEOUT_SEC } from '../tool/timeout.js';
10
11
  import { createDeploymentSnapshotFromEnv, isInlineToolDeclaration, overlayToolRefPolicies, } from './deployment-snapshot.js';
11
12
  import { preloadGraphNotFound, preloadManifestNotFound, preloadSkillNotFound, preloadToolNotFound, } from './preload-errors.js';
12
13
  import { PreinstallDefinitionCache, resolveDefinitionCacheEnabled, } from './definition-cache.js';
@@ -300,7 +301,7 @@ function expandPreinstallToolset(pre, options) {
300
301
  baseUrl: st.baseUrl ?? gateway.baseUrl,
301
302
  pathTemplate: st.pathTemplate,
302
303
  allowedHosts: gateway.allowedHosts,
303
- timeout: st.timeout ?? gateway.timeout ?? 10000,
304
+ timeout: st.timeout ?? gateway.timeout ?? DEFAULT_HTTP_TOOL_TIMEOUT_SEC,
304
305
  };
305
306
  }
306
307
  else if (setType === 'mcp') {
@@ -310,7 +311,7 @@ function expandPreinstallToolset(pre, options) {
310
311
  transport: server?.transport ?? (server?.url ? 'streamable_http' : 'stdio'),
311
312
  server,
312
313
  toolName: name,
313
- timeout: st.timeout ?? server?.timeout ?? 30000,
314
+ timeout: st.timeout ?? server?.timeout ?? DEFAULT_TOOL_TIMEOUT_SEC,
314
315
  };
315
316
  }
316
317
  else {
@@ -319,7 +320,7 @@ function expandPreinstallToolset(pre, options) {
319
320
  runtime: st.runtime ?? 'node',
320
321
  handler: st.handler,
321
322
  args: st.args,
322
- timeout: st.timeout ?? 30000,
323
+ timeout: st.timeout ?? DEFAULT_TOOL_TIMEOUT_SEC,
323
324
  sandbox: st.sandbox ?? pkg?.sandbox ?? false,
324
325
  bundlePath: pre.bundlePath,
325
326
  };
@@ -839,7 +840,6 @@ export class GraphLoader {
839
840
  const workflow = asGraphDsl(pre.manifest.workflow) ??
840
841
  asGraphDsl(pre.manifest.graph) ??
841
842
  asGraphDsl(pre.manifest.definitionSnapshot);
842
- // 解析 prompt:支持文件路径引用(./ 开头)
843
843
  const prompt = await resolveSkillPrompt(pre.manifest, pre.bundlePath);
844
844
  const entryFile = typeof pre.manifest.skillEntryFile === 'string' ? pre.manifest.skillEntryFile : undefined;
845
845
  skills.push({
@@ -3,7 +3,7 @@ export { createAgentRegistryClient, type AgentRegistryClient, type AgentRegistry
3
3
  export { GraphLoader, type GraphLoaderConfig, type LoadToolDefinitionsOptions, type LoadAgentOptions } from './graph-loader.js';
4
4
  export { PreinstallDefinitionCache, resolveDefinitionCacheEnabled, type CachedAgentDefinitions, } from './definition-cache.js';
5
5
  export { inspectAgentSkillTree, readSkillAssembly, resolveSkillHotReload, skillAssemblyStamp, watchAgentSkillDirs, watchPreinstallSkillRoot, watchSkillRoots, } from './skill-tree.js';
6
- export { FileSystemDeploymentSnapshot, createDeploymentSnapshotFromEnv, normalizeDigest, isInlineToolDeclaration, overlayToolRefPolicies, type IDeploymentSnapshot, type AgentSnapshotMeta, type SnapshotToolRef, type SnapshotSkillRef, type PreinstallToolManifest, type PreinstallSkillManifest, type DeploymentSnapshotOptions, } from './deployment-snapshot.js';
6
+ export { FileSystemDeploymentSnapshot, createDeploymentSnapshotFromEnv, normalizeDigest, isInlineToolDeclaration, overlayToolRefPolicies, toolsetsFromManifest, skillRefsFromManifest, type IDeploymentSnapshot, type AgentSnapshotMeta, type SnapshotToolRef, type SnapshotSkillRef, type PreinstallToolManifest, type PreinstallSkillManifest, type DeploymentSnapshotOptions, } from './deployment-snapshot.js';
7
7
  export { preloadError, preloadMissing, preloadManifestNotFound, preloadGraphNotFound, preloadToolNotFound, preloadSkillNotFound, preloadPackageCorrupt, isRequireReady, } from './preload-errors.js';
8
8
  export { resolvePreloadBehaviorFlags, isValidateSkillIo, isRequireChecksum, type PreloadBehaviorFlags, } from './preload-flags.js';
9
9
  export { assertSkillIoIfEnabled, coerceSkillInputFromMessages, resolveSkillInputFromInvokeInput, } from './skill-io-guard.js';
@@ -3,7 +3,7 @@ export { createAgentRegistryClient } from './agent-registry-client.js';
3
3
  export { GraphLoader } from './graph-loader.js';
4
4
  export { PreinstallDefinitionCache, resolveDefinitionCacheEnabled, } from './definition-cache.js';
5
5
  export { inspectAgentSkillTree, readSkillAssembly, resolveSkillHotReload, skillAssemblyStamp, watchAgentSkillDirs, watchPreinstallSkillRoot, watchSkillRoots, } from './skill-tree.js';
6
- export { FileSystemDeploymentSnapshot, createDeploymentSnapshotFromEnv, normalizeDigest, isInlineToolDeclaration, overlayToolRefPolicies, } from './deployment-snapshot.js';
6
+ export { FileSystemDeploymentSnapshot, createDeploymentSnapshotFromEnv, normalizeDigest, isInlineToolDeclaration, overlayToolRefPolicies, toolsetsFromManifest, skillRefsFromManifest, } from './deployment-snapshot.js';
7
7
  export { preloadError, preloadMissing, preloadManifestNotFound, preloadGraphNotFound, preloadToolNotFound, preloadSkillNotFound, preloadPackageCorrupt, isRequireReady, } from './preload-errors.js';
8
8
  export { resolvePreloadBehaviorFlags, isValidateSkillIo, isRequireChecksum, } from './preload-flags.js';
9
9
  export { assertSkillIoIfEnabled, coerceSkillInputFromMessages, resolveSkillInputFromInvokeInput, } from './skill-io-guard.js';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 预装加载错误 — 对齐 runtime.preload.* / 联调契约
3
3
  */
4
- import { AppError, type ErrorCode } from '@gt-fe/eap-contracts';
4
+ import { AppError, type ErrorCode } from '@eap/contracts';
5
5
  export declare function preloadError(code: ErrorCode, message: string, details?: unknown): AppError;
6
6
  export declare function preloadMissing(message: string, details?: unknown): AppError;
7
7
  export declare function preloadManifestNotFound(message: string, details?: unknown): AppError;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 预装加载错误 — 对齐 runtime.preload.* / 联调契约
3
3
  */
4
- import { AppError, ErrorCodes } from '@gt-fe/eap-contracts';
4
+ import { AppError, ErrorCodes } from '@eap/contracts';
5
5
  export function preloadError(code, message, details) {
6
6
  return new AppError(code, message, {
7
7
  exposeMessage: true,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Skill inputDef / outputDef 轻量校验(默认开启;EAP_PRELOAD_VALIDATE_SKILL_IO=0 关闭)
3
3
  */
4
- import { AppError, ErrorCodes } from '@gt-fe/eap-contracts';
4
+ import { AppError, ErrorCodes } from '@eap/contracts';
5
5
  import { isValidateSkillIo } from './preload-flags.js';
6
6
  function asRecord(value) {
7
7
  if (value && typeof value === 'object' && !Array.isArray(value)) {
@@ -10,7 +10,7 @@ import { readdir, stat, access, readFile } from 'node:fs/promises';
10
10
  import { watch } from 'node:fs';
11
11
  import { constants as fsConstants } from 'node:fs';
12
12
  import path from 'node:path';
13
- import { SKILL_ENTRY_CANDIDATES } from '@gt-fe/eap-contracts';
13
+ import { SKILL_ENTRY_CANDIDATES } from '@eap/contracts';
14
14
  const SKILL_CODE = /^[a-z0-9][a-z0-9-]*$/;
15
15
  async function exists(p) {
16
16
  try {
@@ -7,12 +7,12 @@
7
7
  * @see 04-runtime-core/design.md §1.5 / §1.7
8
8
  */
9
9
  import { randomUUID } from 'node:crypto';
10
- import { HitlAlreadyTimedOutError, HitlNotWaitingError, buildHitlWaitedPayload, isHitlDeadlinePassed, readPersistedHitlWaiting, unwrapHitlPaused, } from '../graph/hitl/hitl-handler.js';
10
+ import { HITL_TIMEOUT_ERROR_CODE, HITL_TIMEOUT_MESSAGE, HitlAlreadyTimedOutError, HitlNotWaitingError, buildHitlWaitedPayload, isHitlDeadlinePassed, readPersistedHitlWaiting, unwrapHitlPaused, } from '../graph/hitl/hitl-handler.js';
11
11
  import { toLoadedSkillMap } from '../tool/system-prompt-builder.js';
12
12
  import { assembleLoadedTools } from '../tool/harness-primitives.js';
13
13
  import { createFileLlmTurnLogFromEnv, } from '../debug/llm-turn-log.js';
14
14
  import { buildHitlWaitingTaskOutput, buildTurnGraphMessages, buildTurnTranscriptFromStreamEvents, extractHitlThreadId, extractStreamReasoning, extractStreamTextDelta, messageRecordsToGraphMessages, persistHitlWaitingPlaceholder, persistTurnTranscript, persistUserTurnMessage, } from '../session/persist-turn-messages.js';
15
- import { AppError, ErrorCodes } from '@gt-fe/eap-contracts';
15
+ import { AppError, ErrorCodes } from '@eap/contracts';
16
16
  import { resolveExecutionContext } from '../governance/governance-client.js';
17
17
  import { resolveAgentCode } from '../common/agent-code.js';
18
18
  import { resolveTraceId } from '../common/trace-id.js';
@@ -268,6 +268,9 @@ export class AgentRuntime {
268
268
  const promptRoots = this.deps.graphLoader
269
269
  ? await this.deps.graphLoader.resolvePromptRoots(agentCode, params.agentVersion)
270
270
  : [];
271
+ const agentDir = this.deps.graphLoader
272
+ ? (await this.deps.graphLoader.resolveAgentDir(agentCode, params.agentVersion)) ?? undefined
273
+ : undefined;
271
274
  const history = messageRecordsToGraphMessages(sessionContext.messages);
272
275
  const messages = await buildTurnGraphMessages({
273
276
  history,
@@ -297,6 +300,7 @@ export class AgentRuntime {
297
300
  loadedSkills,
298
301
  skillDefinitions,
299
302
  promptRoots,
303
+ agentDir,
300
304
  skillInput: resolveSkillInputFromInvokeInput(params.input),
301
305
  traceId: resolveTraceId(params),
302
306
  traceCollector: this.deps.traceCollector,
@@ -442,7 +446,7 @@ export class AgentRuntime {
442
446
  }
443
447
  catch (err) {
444
448
  if (err instanceof HitlAlreadyTimedOutError) {
445
- throw new AppError(ErrorCodes.TASK_HITL_TIMEOUT, `Task ${taskId} HITL wait exceeded deadline`, { exposeMessage: true });
449
+ throw new AppError(ErrorCodes.TASK_HITL_TIMEOUT, HITL_TIMEOUT_MESSAGE, { exposeMessage: true });
446
450
  }
447
451
  if (err instanceof HitlNotWaitingError) {
448
452
  throw new AppError(ErrorCodes.TASK_HITL_INVALID_STATE, `Task ${taskId} is not waiting for HITL`, { exposeMessage: true });
@@ -482,6 +486,10 @@ export class AgentRuntime {
482
486
  taskId,
483
487
  correlationId: resumedState.correlationId ?? correlationId,
484
488
  agentVersion: agentVersion ?? resumedState.agentVersion,
489
+ agentDir: (typeof resumedState.agentDir === 'string' && resumedState.agentDir) ||
490
+ (this.deps.graphLoader
491
+ ? (await this.deps.graphLoader.resolveAgentDir(agentCode, agentVersion)) ?? undefined
492
+ : undefined),
485
493
  activatedSkill: resumedState.activatedSkill,
486
494
  skillRoute: resumedState.skillRoute ??
487
495
  (typeof resumedState.activatedSkill === 'string' && resumedState.activatedSkill
@@ -640,10 +648,15 @@ export class AgentRuntime {
640
648
  const loadedToolsBase = await this.resolveLoadedTools(agentCode, agentVersion);
641
649
  const skillBundle = await this.resolveLoadedSkills(agentCode, userId, agentVersion);
642
650
  const loadedTools = assembleLoadedTools(loadedToolsBase);
651
+ const agentDir = (typeof forkedCheckpoint.state.agentDir === 'string' && forkedCheckpoint.state.agentDir) ||
652
+ (this.deps.graphLoader
653
+ ? (await this.deps.graphLoader.resolveAgentDir(agentCode, agentVersion)) ?? undefined
654
+ : undefined);
643
655
  try {
644
656
  const result = await this.deps.graphEngine.invoke(graph, {
645
657
  ...forkedCheckpoint.state,
646
658
  agentVersion,
659
+ agentDir,
647
660
  userId,
648
661
  delegationToken: overrides.executionContext?.delegationToken,
649
662
  executionContext: overrides.executionContext,
@@ -740,7 +753,7 @@ export class AgentRuntime {
740
753
  toolSpanId: persisted.toolSpanId,
741
754
  skillSpanId: persisted.skillSpanId,
742
755
  });
743
- throw new AppError(ErrorCodes.TASK_HITL_TIMEOUT, `Task ${taskId} HITL wait exceeded deadline`, { exposeMessage: true });
756
+ throw new AppError(ErrorCodes.TASK_HITL_TIMEOUT, HITL_TIMEOUT_MESSAGE, { exposeMessage: true });
744
757
  }
745
758
  return {
746
759
  task,
@@ -780,7 +793,7 @@ export class AgentRuntime {
780
793
  return;
781
794
  }
782
795
  const collector = this.deps.traceCollector;
783
- const error = event.behavior === 'cancel' ? 'HITL cancelled by timeout' : 'HITL wait timed out';
796
+ const error = HITL_TIMEOUT_MESSAGE;
784
797
  if (collector) {
785
798
  if (event.toolSpanId) {
786
799
  try {
@@ -807,6 +820,7 @@ export class AgentRuntime {
807
820
  toolCallId: event.toolCallId,
808
821
  toolName: event.toolName,
809
822
  error,
823
+ errorCode: HITL_TIMEOUT_ERROR_CODE,
810
824
  });
811
825
  }
812
826
  catch {
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * 装配策略(与 server.ts 一致):
20
20
  * - LLM Provider: Routing > HttpLLMProvider(OpenAI) > Echo 兜底
21
- * - Tool Executor: mock(显式)/ DevToolExecutor(dev+mcp,缺配置失败)/ 通用路由
21
+ * - Tool Executor: DevToolExecutor(dev+mcp,缺配置失败)/ 通用路由
22
22
  * - Governance: AllowAll(本地闭环默认) / HttpGovernance(显式 GOVERNANCE_DISABLED=0)
23
23
  * - 存储: EAP_RUNTIME_STORAGE_PROFILE(默认 dev = File Session/Message/Checkpoint)
24
24
  * - Registry: 本地闭环不装配,由 GraphLoader.deploymentSnapshot 兜底
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * 装配策略(与 server.ts 一致):
20
20
  * - LLM Provider: Routing > HttpLLMProvider(OpenAI) > Echo 兜底
21
- * - Tool Executor: mock(显式)/ DevToolExecutor(dev+mcp,缺配置失败)/ 通用路由
21
+ * - Tool Executor: DevToolExecutor(dev+mcp,缺配置失败)/ 通用路由
22
22
  * - Governance: AllowAll(本地闭环默认) / HttpGovernance(显式 GOVERNANCE_DISABLED=0)
23
23
  * - 存储: EAP_RUNTIME_STORAGE_PROFILE(默认 dev = File Session/Message/Checkpoint)
24
24
  * - Registry: 本地闭环不装配,由 GraphLoader.deploymentSnapshot 兜底
@@ -28,7 +28,6 @@ import { HttpLLMProvider } from '../providers/http-llm-provider.js';
28
28
  import { createLocalLlmProvider, requireLocalLlmConnections } from '../providers/local-llm-provider.js';
29
29
  import { RoutingLLMProvider } from '../providers/routing-llm-provider.js';
30
30
  import { createToolExecutor } from '../tool/create-tool-executor.js';
31
- import { MockToolExecutor } from '../tool/mock-tool-executor.js';
32
31
  import { DevToolExecutor } from '../tool/dev-tool-executor.js';
33
32
  import { withHarnessPrimitives } from '../tool/harness-primitives.js';
34
33
  import { AllowAllGovernanceClient, HttpGovernanceClient, } from '../governance/index.js';
@@ -75,14 +74,11 @@ export function createDevRuntime() {
75
74
  llmProvider = createDefaultLLMProvider(turnLog);
76
75
  llmProviderKind = 'echo';
77
76
  }
78
- // ── Tool Executor(显式 mock → dev+mcp 直连,缺配置失败 → 通用路由)──
79
- const needsHarnessWrap = toolExecutionMode === 'mock' ||
80
- (toolExecutionMode === 'mcp' && deploymentContext === 'dev');
81
- const innerExecutor = toolExecutionMode === 'mock'
82
- ? new MockToolExecutor({ toolsDir: process.env.EAP_LOCAL_TOOLS_DIR })
83
- : toolExecutionMode === 'mcp' && deploymentContext === 'dev'
84
- ? new DevToolExecutor()
85
- : createToolExecutor({ foundationUrl, deploymentContext });
77
+ // ── Tool Executor(dev+mcp 直连,缺配置失败 → 通用路由)──
78
+ const needsHarnessWrap = toolExecutionMode === 'mcp' && deploymentContext === 'dev';
79
+ const innerExecutor = toolExecutionMode === 'mcp' && deploymentContext === 'dev'
80
+ ? new DevToolExecutor()
81
+ : createToolExecutor({ foundationUrl, deploymentContext });
86
82
  const toolExecutor = needsHarnessWrap
87
83
  ? withHarnessPrimitives(innerExecutor)
88
84
  : innerExecutor;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @see 04-runtime-core/design.md §1.5
8
8
  */
9
- import type { ExecutionContext, InvokeConfig, ResumeHitlResult } from '@gt-fe/eap-contracts';
9
+ import type { ExecutionContext, InvokeConfig, ResumeHitlResult } from '@eap/contracts';
10
10
  import type { InvokeResponseData } from '../api/routes/agent.routes.js';
11
11
  import type { GraphMessage } from '../graph/contracts/executable-graph.js';
12
12
  import type { SSEEvent } from '../sse/contracts/sse-emitter.contract.js';
@@ -31,7 +31,7 @@ export interface ExecuteParams {
31
31
  }
32
32
  /** 同步执行结果 */
33
33
  export type ExecuteResult = InvokeResponseData;
34
- /** HITL 恢复结果(与 @gt-fe/eap-contracts ResumeHitlResult 对齐) */
34
+ /** HITL 恢复结果(与 @eap/contracts ResumeHitlResult 对齐) */
35
35
  export type { ResumeHitlResult };
36
36
  /** HITL 用户响应 */
37
37
  export interface HitlResponse {
package/dist/server.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * TODO: Phase 2 将本文件迁移至 dev-tools/cli(作为 `eap dev` 命令实现),
8
8
  * runtime 包不再包含 HTTP 服务代码,仅作为纯库导出。
9
9
  */
10
- import { ErrorCodes } from '@gt-fe/eap-contracts';
10
+ import { ErrorCodes } from '@eap/contracts';
11
11
  import { createServer } from 'node:http';
12
12
  import { URL } from 'node:url';
13
13
  import { resolveExecutionContext } from './governance/index.js';
@@ -6,7 +6,7 @@
6
6
  * - skill.started / skill.completed / skill.failed(子图执行生命周期)
7
7
  *
8
8
  * @see design.md §1.6 SSE事件协议定义
9
- * @see @gt-fe/eap-contracts OPTIONAL_SSE_EVENTS
9
+ * @see @eap/contracts OPTIONAL_SSE_EVENTS
10
10
  */
11
11
  /** 技能匹配成功 */
12
12
  export interface SkillMatchedPayload {
@@ -6,6 +6,6 @@
6
6
  * - skill.started / skill.completed / skill.failed(子图执行生命周期)
7
7
  *
8
8
  * @see design.md §1.6 SSE事件协议定义
9
- * @see @gt-fe/eap-contracts OPTIONAL_SSE_EVENTS
9
+ * @see @eap/contracts OPTIONAL_SSE_EVENTS
10
10
  */
11
11
  export {};
@@ -5,7 +5,7 @@
5
5
  * `EAP_TOOL_GATEWAY_TRANSPORT=http` 时用 HttpToolExecutor(仅调试)。
6
6
  * desktop 经 ToolExecutionRouter 分流 Local / Gateway。
7
7
  */
8
- import type { ILocalToolInstallStore, LocalToolInstallRecord } from '@gt-fe/eap-contracts';
8
+ import type { ILocalToolInstallStore, LocalToolInstallRecord } from '@eap/contracts';
9
9
  import { type DeploymentContext } from './tool-execution-router.js';
10
10
  import type { IToolExecutor } from './tool-executor.interface.js';
11
11
  export declare class EmptyInstallStore implements ILocalToolInstallStore {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Dev 下按 type:http 清单直连出站(gateway.baseUrl + pathTemplate)。
3
- * URL 拼接与 host 白名单与 Tool Gateway 共用 @gt-fe/eap-contracts http-outbound。
3
+ * URL 拼接与 host 白名单与 Tool Gateway 共用 @eap/contracts http-outbound。
4
4
  */
5
5
  import type { IToolExecutor, ToolCallRequest, ToolCallResult } from './tool-executor.interface.js';
6
6
  export interface DevHttpExecution {
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Dev 下按 type:http 清单直连出站(gateway.baseUrl + pathTemplate)。
3
- * URL 拼接与 host 白名单与 Tool Gateway 共用 @gt-fe/eap-contracts http-outbound。
3
+ * URL 拼接与 host 白名单与 Tool Gateway 共用 @eap/contracts http-outbound。
4
4
  */
5
- import { assertHttpHostAllowlisted, buildHttpToolUrl as buildSharedHttpToolUrl } from '@gt-fe/eap-contracts';
5
+ import { assertHttpHostAllowlisted, buildHttpToolUrl as buildSharedHttpToolUrl, ErrorCodes } from '@eap/contracts';
6
+ import { abortOrTimeoutMessage, DEFAULT_HTTP_TOOL_TIMEOUT_SEC, isAbortError, resolveToolTimeoutSec, toToolTimeoutMs, } from './timeout.js';
6
7
  export function resolveHttpExecutionFromRequest(request) {
7
8
  const raw = request.execution;
8
9
  if (!raw || typeof raw !== 'object')
@@ -22,7 +23,7 @@ export function resolveHttpExecutionFromRequest(request) {
22
23
  allowedHosts: Array.isArray(e.allowedHosts)
23
24
  ? e.allowedHosts.filter((item) => typeof item === 'string')
24
25
  : [],
25
- timeout: typeof e.timeout === 'number' ? e.timeout : 10000,
26
+ timeout: resolveToolTimeoutSec(e.timeout, DEFAULT_HTTP_TOOL_TIMEOUT_SEC),
26
27
  };
27
28
  }
28
29
  export function buildHttpToolUrl(spec, args) {
@@ -48,8 +49,9 @@ export class DevHttpExecutor {
48
49
  const args = request.arguments ?? {};
49
50
  const url = buildHttpToolUrl(spec, args);
50
51
  const method = (spec.method ?? 'GET').toUpperCase();
52
+ const timeoutSec = resolveToolTimeoutSec(spec.timeout, DEFAULT_HTTP_TOOL_TIMEOUT_SEC);
51
53
  const controller = new AbortController();
52
- const timer = setTimeout(() => controller.abort(), spec.timeout ?? 10000);
54
+ const timer = setTimeout(() => controller.abort(), toToolTimeoutMs(timeoutSec, DEFAULT_HTTP_TOOL_TIMEOUT_SEC));
53
55
  const headers = {
54
56
  Accept: 'application/json, text/plain;q=0.9',
55
57
  };
@@ -81,14 +83,15 @@ export class DevHttpExecutor {
81
83
  };
82
84
  }
83
85
  catch (err) {
84
- const message = err instanceof Error ? err.message : String(err);
86
+ const timeoutSec = resolveToolTimeoutSec(spec?.timeout, DEFAULT_HTTP_TOOL_TIMEOUT_SEC);
87
+ const aborted = isAbortError(err);
85
88
  return {
86
89
  toolCallId: request.toolCallId,
87
90
  toolName: request.toolName,
88
91
  content: '',
89
92
  success: false,
90
- error: message,
91
- errorCode: 'EXECUTION_FAILED',
93
+ error: abortOrTimeoutMessage(err, timeoutSec),
94
+ errorCode: aborted ? ErrorCodes.TOOL_TIMEOUT : 'EXECUTION_FAILED',
92
95
  runtime: 'local',
93
96
  };
94
97
  }
@@ -17,6 +17,8 @@
17
17
  * @see docs/workflows/local-agent-dev-loop.md
18
18
  * @see runtime/src/tool/local-mcp-client.ts
19
19
  */
20
+ import { ErrorCodes } from '@eap/contracts';
21
+ import { isAbortError } from './timeout.js';
20
22
  import { LocalMcpClient } from './local-mcp-client.js';
21
23
  export class DevMcpExecutor {
22
24
  client;
@@ -50,14 +52,14 @@ export class DevMcpExecutor {
50
52
  };
51
53
  }
52
54
  catch (err) {
53
- const message = err instanceof Error ? err.message : String(err);
55
+ const aborted = isAbortError(err);
54
56
  return {
55
57
  toolCallId: request.toolCallId,
56
58
  toolName: request.toolName,
57
59
  content: '',
58
60
  success: false,
59
- error: message,
60
- errorCode: 'EXECUTION_FAILED',
61
+ error: err instanceof Error ? err.message : String(err),
62
+ errorCode: aborted ? ErrorCodes.TOOL_TIMEOUT : 'EXECUTION_FAILED',
61
63
  runtime: 'local',
62
64
  };
63
65
  }
@@ -7,7 +7,7 @@
7
7
  * - execution.protocol=mcp → DevMcpExecutor
8
8
  * - execution.protocol=http → DevHttpExecutor
9
9
  * - 能解析出 code handler → LocalToolExecutor
10
- * - 其余 → NOT_CONFIGURED(mock 只走显式 `--tool-mode mock`)
10
+ * - 其余 → NOT_CONFIGURED
11
11
  */
12
12
  import { DevMcpExecutor } from './dev-mcp-executor.js';
13
13
  import type { IToolExecutor, ToolCallRequest, ToolCallResult } from './tool-executor.interface.js';
@@ -7,7 +7,7 @@
7
7
  * - execution.protocol=mcp → DevMcpExecutor
8
8
  * - execution.protocol=http → DevHttpExecutor
9
9
  * - 能解析出 code handler → LocalToolExecutor
10
- * - 其余 → NOT_CONFIGURED(mock 只走显式 `--tool-mode mock`)
10
+ * - 其余 → NOT_CONFIGURED
11
11
  */
12
12
  import { EmptyInstallStore } from './create-tool-executor.js';
13
13
  import { DevMcpExecutor } from './dev-mcp-executor.js';
@@ -42,7 +42,7 @@ export class DevToolExecutor {
42
42
  content: '',
43
43
  success: false,
44
44
  error: `Dev tool "${request.toolName}" is not executable: no MCP server, ` +
45
- 'HTTP gateway+pathTemplate, or code handler. Use --tool-mode mock for MockToolExecutor.',
45
+ 'HTTP gateway+pathTemplate, or code handler.',
46
46
  errorCode: 'NOT_CONFIGURED',
47
47
  runtime: 'local',
48
48
  };