@epoch-agent/runtime 0.3.2 → 0.5.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/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { GoalRoundResult, Goal, GoalWrite, GoalClear, Workspace, TrustDecision,
2
2
  export { DEFAULT_GOAL_MAX_ROUNDS, MAX_GOAL_MAX_ROUNDS, MAX_OBJECTIVE_CHARS, MAX_REASON_CHARS, SANDBOX_COVERS, SANDBOX_EXCLUDES, SCHEDULE_DEFAULTS, SCHEDULE_DEFAULT_ALLOWLIST, nextRunAt, readRecording, skillIndexDescription } from '@epoch-agent/core';
3
3
  import { McpServerConfig, McpServerStatus, McpServerSource, McpTransport, McpAuthStatus } from '@epoch-agent/plugin-mcp';
4
4
  export { McpAuthState, McpAuthStatus, McpServerConfig } from '@epoch-agent/plugin-mcp';
5
- import { Lang, DiagnosticSink, EpochContentPart, EpochToolCall, EpochToolResult, EpochTurnFacts, TokenUsage, EpochMessage, ApprovalRequest, ApprovalReply, QuestionRequest, QuestionAnswer, EpochUserContent, AgentEvent, CustomCommandDef, ExpandedCommand, ToolProvider, ModelRef, SetSelectionResult, EpochTool, AgentRole, ProviderType, SecretStore, WireModelSource, WireModelProbeStatus, PermissionLevel, ModelSelection, SelectionContext, ScheduleRunStatus, ScheduleRun, ScheduleDefinition, ScheduleBackendKind, ScheduleRunnerSpec, LogFn, EpochConfig, ActiveAgentRole, ApprovalOutcome, PermissionManager as PermissionManager$1, TrustManager as TrustManager$1, ContextBreakdown, Diagnostic } from '@epoch-agent/protocol';
5
+ import { Lang, DiagnosticSink, EpochContentPart, EpochToolCall, EpochToolResult, EpochTurnFacts, FinishReason, TokenUsage, EpochMessage, ApprovalRequest, ApprovalReply, QuestionRequest, QuestionAnswer, EpochUserContent, AgentEvent, CustomCommandDef, ExpandedCommand, ToolProvider, ModelRef, SetSelectionResult, EpochTool, AgentRole, ProviderType, SecretStore, WireModelSource, WireModelProbeStatus, PermissionLevel, ModelSelection, SelectionContext, ScheduleRunStatus, ScheduleRun, ScheduleDefinition, ScheduleBackendKind, ScheduleRunnerSpec, LogFn, EpochConfig, ActiveAgentRole, ApprovalOutcome, PermissionManager as PermissionManager$1, TrustManager as TrustManager$1, ContextBreakdown, Diagnostic } from '@epoch-agent/protocol';
6
6
  export { BackgroundTaskInfo, BackgroundTaskStatus } from '@epoch-agent/protocol';
7
7
  export { t } from '@epoch-agent/infra';
8
8
  export { taskOutput as backgroundTaskOutput, listTasks as listBackgroundTasks } from '@epoch-agent/plugin-terminal';
@@ -720,6 +720,23 @@ interface TurnDetail {
720
720
  * 整个不画,而不是画一行 0。判据全文在 protocol 的 `EpochTurnFacts` 上。
721
721
  */
722
722
  facts?: EpochTurnFacts;
723
+ /**
724
+ * 这一轮为什么停(`finish` 事件的 `reason`,2026-09-04)。落在**最后一条
725
+ * assistant 行**的 `finish_reason` 列上,同 {@link facts}。
726
+ *
727
+ * ## 这一列以前是全 NULL
728
+ *
729
+ * 建表时就有(`core/src/session/db.ts` 的 `finish_reason TEXT`),
730
+ * `insertMessage` 也一直在写 `msg.finishReason ?? null` —— 缺的只是**没有任何
731
+ * 生产调用方往下传过它**。一台真机上量过:687 条消息,这一列 687 个 NULL。
732
+ *
733
+ * 后果是「这一轮为什么停」这个问题**事后无解**,而它是所有「模型半路停下」类
734
+ * 问题的第一个分诊问题:`'stop'`(自己收工)和 `'length'`(被 provider 按
735
+ * max output tokens 切了)在界面上长得一模一样,都是「这一轮没有工具调用」。
736
+ *
737
+ * 不给就照旧写 NULL —— 那一轮只是答不出这个问题,别的一切不变。
738
+ */
739
+ finishReason?: FinishReason;
723
740
  /**
724
741
  * 本轮模型请求过的全部工具调用,按事件到达顺序。
725
742
  *
@@ -1804,7 +1821,7 @@ interface HostAgentRole {
1804
1821
  * `echo > file` 绕开「没有 file_write」)。宿主别拿它当沙箱。
1805
1822
  */
1806
1823
  tools?: string[];
1807
- /** 轮次预算。不给则沿用 `max(4, floor(父 maxTurns / 2))` */
1824
+ /** 轮次预算。不给则沿用 `config.maxTurns`(2026-09-04 前是它的一半) */
1808
1825
  maxTurns?: number;
1809
1826
  }
1810
1827
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { loadCommandDefinitions, SLASH_COMMANDS_DIAG_MODULE, createToolScope, expandCommand, RecentWorkspaces, clearModelCache, discoverModels, substitutePluginRoot, ScheduleStore, isWithinWindow, acquireScheduleLock, triggerPeriodMs, ScheduleRecorder, pruneRecordings, suggestRuleFromApproval, needsAllowlist, isNonInteractive, loadPlugins, assertLevelAllowed, discoverProject, ProviderRouter, ProviderError, PROVIDER_NO_CREDENTIAL, SessionManager, GoalService, MemoryManager, MemoryReviewer, resolveSkillDirs, SkillSystem, SkillLearner, HookManager, loadHookSources, ApprovalCache, PermissionManager, resolvePolicyDirs, resolvePoliciesDir, loadPolicyFiles, checkShadowing, compileRuleLists, ContextCompressor, compressionOptions, TrackerDB, getConfigOrigins, resolveComplianceDirs, resolveComplianceDir, loadLexiconFiles, ComplianceEngine, DEFAULT_COMPLIANCE_SETTINGS, mapOperationType, affectedPaths, workspaceDisplayPath, persistParts, persistToolResults, ToolRegistry, createTodoTool, createGoalTool, createMemoryTool, createCodeExecTool, createRunCodeTool, createSkillViewTool, createSkillWriteTools, createToolSearchTool, createToolRevealState, createAskQuestionTool, resolveWorkspace, unloadedInstructionFiles, resolveProjectRoot, loadConfig, CodeSandbox, CheckpointManager, createDelegateTool, findRole, persistedUsage, systemOpenArgv, resolveInWorkspace, listWorkspaceFiles, loadRoleDefinitions, mergeRoles, AGENT_ROLE_DIAG_MODULE, builtinRoles, unknownRoleTools, BLOCKED_TOOLS, blockedRoleTools, unknownRoleSkills, BudgetStore, mergeHeadlessPolicy, describeHeadlessPolicy, importSkills, previewSkillImport, removeSessionArtifacts, gateForTool, managedSwitchNotes, originOf, EpochConfigSchema, defaultConfig, SettingsFileSchema, isWritableSettingKey, writeSettingValue, SETTING_WRITE_APPLY, resolveSettings, SETTING_WRITE_LAYERS, readProviderKeyEnv, validateSchedule, createAllowAllGate, setTrustGate, TrustManager, createTrustGate, createDenyAllGate, getImportGate, setImportGate, createAllowAllImportGate, ImportTrustStore, createDenyAllImportGate, createImportGate, getCapability, restoreParts, createSessionSearchTools, PlanModeState, createPlanModeTools, toolTableTokens, explainSetting, settingWriteTargets, settingValueKind, settingValueChoices, uninstallPlugin, removeMarketplace, addMarketplace, readMarketplaces, searchMarketplaces, resolveEntrySource, resolveSource, readPluginRecords, createRoleFile, AgentLoop, resolveArtifactRetention, roleScopedProvider, createRoleScope, revealScopedProvider, withGoalPrompt, withGoalCompression, ScheduleRegistrar, resolveScheduleBackend, updateMarketplace, SETTINGS_LAYER_ORDER, resolveMarketplaceRef, BudgetGuard, installPlugin, currentEpochVersion } from '@epoch-agent/core';
1
+ import { loadCommandDefinitions, SLASH_COMMANDS_DIAG_MODULE, createToolScope, expandCommand, RecentWorkspaces, clearModelCache, discoverModels, substitutePluginRoot, ScheduleStore, isWithinWindow, acquireScheduleLock, triggerPeriodMs, ScheduleRecorder, pruneRecordings, suggestRuleFromApproval, needsAllowlist, isNonInteractive, loadPlugins, assertLevelAllowed, discoverProject, ProviderRouter, ProviderError, PROVIDER_NO_CREDENTIAL, SessionManager, GoalService, MemoryManager, MemoryReviewer, resolveSkillDirs, SkillSystem, SkillLearner, HookManager, loadHookSources, ApprovalCache, PermissionManager, resolvePolicyDirs, resolvePoliciesDir, loadPolicyFiles, checkShadowing, compileRuleLists, ContextCompressor, compressionOptions, TrackerDB, getConfigOrigins, resolveComplianceDirs, resolveComplianceDir, loadLexiconFiles, ComplianceEngine, DEFAULT_COMPLIANCE_SETTINGS, mapOperationType, affectedPaths, workspaceDisplayPath, persistParts, persistToolResults, ToolRegistry, createTodoTool, createGoalTool, createMemoryTool, createCodeExecTool, createRunCodeTool, createSkillViewTool, createSkillWriteTools, createToolSearchTool, createToolRevealState, createAskQuestionTool, resolveWorkspace, unloadedInstructionFiles, resolveProjectRoot, loadConfig, CodeSandbox, CheckpointManager, createDelegateTool, findRole, persistedUsage, systemOpenArgv, resolveInWorkspace, listWorkspaceFiles, loadRoleDefinitions, mergeRoles, AGENT_ROLE_DIAG_MODULE, builtinRoles, unknownRoleTools, BLOCKED_TOOLS, blockedRoleTools, unknownRoleSkills, BudgetStore, mergeHeadlessPolicy, describeHeadlessPolicy, importSkills, previewSkillImport, removeSessionArtifacts, gateForTool, managedSwitchNotes, originOf, EpochConfigSchema, defaultConfig, SettingsFileSchema, isWritableSettingKey, writeSettingValue, SETTING_WRITE_APPLY, resolveSettings, SETTING_WRITE_LAYERS, readProviderKeyEnv, validateSchedule, SCHEDULE_DEFAULTS, createAllowAllGate, setTrustGate, TrustManager, createTrustGate, createDenyAllGate, getImportGate, setImportGate, createAllowAllImportGate, ImportTrustStore, createDenyAllImportGate, createImportGate, getCapability, restoreParts, createSessionSearchTools, PlanModeState, createPlanModeTools, toolTableTokens, explainSetting, settingWriteTargets, settingValueKind, settingValueChoices, uninstallPlugin, removeMarketplace, addMarketplace, readMarketplaces, searchMarketplaces, resolveEntrySource, resolveSource, readPluginRecords, createRoleFile, AgentLoop, resolveArtifactRetention, roleScopedProvider, createRoleScope, revealScopedProvider, withGoalPrompt, withGoalCompression, ScheduleRegistrar, resolveScheduleBackend, updateMarketplace, SETTINGS_LAYER_ORDER, resolveMarketplaceRef, BudgetGuard, installPlugin, currentEpochVersion } from '@epoch-agent/core';
2
2
  export { DEFAULT_GOAL_MAX_ROUNDS, MAX_GOAL_MAX_ROUNDS, MAX_OBJECTIVE_CHARS, MAX_REASON_CHARS, SANDBOX_COVERS, SANDBOX_EXCLUDES, SCHEDULE_DEFAULTS, SCHEDULE_DEFAULT_ALLOWLIST, nextRunAt, readRecording, skillIndexDescription } from '@epoch-agent/core';
3
3
  import { projectCommandsDir, commandsDir, t, issueDetails, resolveHomeDir, configPath, readKey, setScalar, setSectionField, mcpConfigPath, workspacesPath, writeProviderSecret, envPath, maskApiKey, dbPath, automationLogsDir, pluginsStatePath, safeInit, memoriesDir, skillsDir, claudeUserSettingsPath, hooksPath, artifactsDir, resolveRipgrep, withTimeout, createProcessTable, marketplacesPath, pluginsDir, agentsDir, budgetStatePath, createSecretStore, setSecretStore, prefetchProviderSecrets, setSecretValues, migrateEnvSecrets, setDataKey, parseDataKey, generateDataKey, i18nDiagnostics, automationWorkDir, trustPath, trustedImportsPath, setShell, probeShell } from '@epoch-agent/infra';
4
4
  export { t } from '@epoch-agent/infra';
@@ -1730,9 +1730,9 @@ function createScheduleControl(opts) {
1730
1730
  prompt: input.prompt,
1731
1731
  permission: input.permission,
1732
1732
  workDir,
1733
- maxTurns: input.maxTurns ?? 20,
1733
+ maxTurns: input.maxTurns ?? SCHEDULE_DEFAULTS.maxTurns,
1734
1734
  maxBudgetUsd: input.maxBudgetUsd,
1735
- timeoutMs: input.timeoutMs ?? 15 * 60 * 1e3,
1735
+ timeoutMs: input.timeoutMs ?? SCHEDULE_DEFAULTS.timeoutMs,
1736
1736
  trigger: input.trigger,
1737
1737
  ...input.startDate !== void 0 ? { startDate: input.startDate } : {},
1738
1738
  ...input.endDate !== void 0 ? { endDate: input.endDate } : {},
@@ -2411,6 +2411,7 @@ var init_agent_session = __esm({
2411
2411
  }
2412
2412
  async *run(userMessage, opts = {}) {
2413
2413
  let assistantText = "";
2414
+ let finishReason;
2414
2415
  const userText = contentToText(userMessage);
2415
2416
  const parts = typeof userMessage === "string" ? void 0 : userMessage;
2416
2417
  const turn = new TurnStepCollector(Date.now());
@@ -2453,6 +2454,7 @@ var init_agent_session = __esm({
2453
2454
  if (done2) break;
2454
2455
  pendingNext = iter.next();
2455
2456
  if (event.type === "text-delta") assistantText += event.text;
2457
+ if (event.type === "finish") finishReason = event.reason;
2456
2458
  turn.observe(event);
2457
2459
  publishAgentEvent(this.sessionId, event);
2458
2460
  yield event;
@@ -2474,7 +2476,8 @@ var init_agent_session = __esm({
2474
2476
  this.store?.record(this.sessionId, userText, assistantText, {
2475
2477
  ...parts ? { parts } : {},
2476
2478
  ...steps.length > 0 ? { steps } : {},
2477
- ...facts ? { facts } : {}
2479
+ ...facts ? { facts } : {},
2480
+ ...finishReason ? { finishReason } : {}
2478
2481
  });
2479
2482
  }
2480
2483
  markRoleHandoff() {
@@ -2725,7 +2728,8 @@ var init_session_store = __esm({
2725
2728
  content: step.text ?? "",
2726
2729
  ...toolCalls ? { toolCalls } : {},
2727
2730
  ...step.reasoning ? { reasoning: step.reasoning } : {},
2728
- ...last && detail.facts ? { turnFacts: detail.facts } : {}
2731
+ ...last && detail.facts ? { turnFacts: detail.facts } : {},
2732
+ ...last && detail.finishReason ? { finishReason: detail.finishReason } : {}
2729
2733
  });
2730
2734
  for (const result of persistToolResults(step.toolResults ?? [])) {
2731
2735
  this.sessions.appendMessage(sessionId, {
@@ -4020,7 +4024,7 @@ var init_session_factory = __esm({
4020
4024
  telemetry: this.opts.telemetry,
4021
4025
  workDir,
4022
4026
  projectContext,
4023
- maxTurns: role?.maxTurns ?? Math.max(4, Math.floor(config.maxTurns / 2)),
4027
+ maxTurns: role?.maxTurns ?? config.maxTurns,
4024
4028
  contextLength: services.contextLength,
4025
4029
  artifactRetention: resolveArtifactRetention(config.artifacts),
4026
4030
  sandboxTerminal: config.sandbox?.terminal !== false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-agent/runtime",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "description": "epoch-agent 组装层:把 core / plugins / MCP 装配成可运行的 agent",
6
6
  "repository": {
@@ -22,14 +22,14 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@epoch-agent/core": "0.3.2",
26
- "@epoch-agent/plugin-file": "^0.3.2",
27
- "@epoch-agent/plugin-lsp": "0.3.2",
28
- "@epoch-agent/infra": "0.3.2",
29
- "@epoch-agent/plugin-terminal": "^0.3.2",
30
- "@epoch-agent/plugin-web": "^0.3.2",
31
- "@epoch-agent/protocol": "0.3.2",
32
- "@epoch-agent/plugin-mcp": "0.3.2"
25
+ "@epoch-agent/core": "0.5.0",
26
+ "@epoch-agent/infra": "0.5.0",
27
+ "@epoch-agent/plugin-file": "^0.5.0",
28
+ "@epoch-agent/plugin-mcp": "0.5.0",
29
+ "@epoch-agent/plugin-terminal": "^0.5.0",
30
+ "@epoch-agent/protocol": "0.5.0",
31
+ "@epoch-agent/plugin-web": "^0.5.0",
32
+ "@epoch-agent/plugin-lsp": "0.5.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@opentelemetry/api": "^1.9.0",