qlogicagent 2.23.1 → 2.23.3

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 (32) hide show
  1. package/dist/agent.js +43 -45
  2. package/dist/cli.js +7 -7
  3. package/dist/default-project-knowledge/INSTRUCTIONS.md +7 -7
  4. package/dist/default-project-knowledge/rules/project-workflow.md +6 -6
  5. package/dist/host-contract.js +1 -1
  6. package/dist/index.js +337 -341
  7. package/dist/protocol.js +1 -1
  8. package/dist/skills/builtin/desktop-screenshot/SKILL.md +3 -1
  9. package/dist/types/agent/agent.d.ts +0 -1
  10. package/dist/types/agent/tool-loop/artifact-final-contract.d.ts +2 -0
  11. package/dist/types/agent/tool-loop/loop-helpers.d.ts +1 -2
  12. package/dist/types/agent/tool-loop.d.ts +2 -4
  13. package/dist/types/agent/types.d.ts +2 -5
  14. package/dist/types/cli/handlers/turn-handler.d.ts +12 -11
  15. package/dist/types/contracts/turn-event.d.ts +6 -8
  16. package/dist/types/host-contract/index.d.ts +37 -87
  17. package/dist/types/orchestration/solo-evaluator.d.ts +2 -2
  18. package/dist/types/protocol/wire/acp-protocol.d.ts +1 -1
  19. package/dist/types/protocol/wire/index.d.ts +1 -1
  20. package/dist/types/protocol/wire/notification-payloads.d.ts +1 -13
  21. package/dist/types/runtime/config/tunable-defaults.d.ts +14 -6
  22. package/dist/types/runtime/infra/turn-telemetry-store.d.ts +1 -2
  23. package/dist/types/runtime/prompt/host-skill-directory.d.ts +16 -0
  24. package/dist/types/skills/mcp/mcp-manager.d.ts +12 -4
  25. package/dist/types/skills/memory/host-memory-provider.d.ts +2 -2
  26. package/dist/types/skills/memory/task-distillation.d.ts +1 -1
  27. package/dist/types/skills/tools/shell/command-classification.d.ts +0 -36
  28. package/dist/types/transport/acp-server.d.ts +3 -3
  29. package/dist/types/transport/delegate-client.d.ts +2 -2
  30. package/package.json +3 -3
  31. package/dist/types/agent/tool-loop/tool-budget-continuation-policy.d.ts +0 -45
  32. package/dist/types/runtime/prompt/capability-routing-policy.d.ts +0 -9
@@ -1,15 +1,7 @@
1
1
  /**
2
- * Gateway Host 接口冻结稿(契约包)—— 单一事实源:docs/agent-supervision-interfaces-freeze.md
3
- *
4
- * 本文件是 freeze §0-§4/§3.5 TypeScript 落型(2026-07-09 冻结,G3′/A1-A3 已闭环;
5
- * 2026-07-10 Route B 补遗 X1-X7 入约:§13 通知 sink + host-state wire、ProfileConfigService keyId
6
- * 正名 + revealKey、MemoryProfileService 库面收口——单一事实源 agent-supervision-authority-migration-spec.md)。
7
- * 消费方:xiaozhiclaw-runtime gateway(实现方)+ qlogicagent agent 侧(GatewayDelegateRelay client)。
8
- * 冻结纪律:接口不随实现漂移;任何字段/签名改动必须回评审(review-gate-checklist),
9
- * S2 施工 lane 不得自行修改本文件。
10
- *
11
- * 标注 [S1 补定] 的辅助类型是 freeze 引用但未给定义的最小结构,属 S1 评审点,
12
- * 其字段以 freeze 正文/recon 注释为据;实现 lane 负责与现状 store 形状做映射。
2
+ * Public Gateway Host contract consumed by xiaozhiclaw-runtime and qlogicagent.
3
+ * This file is the executable contract authority; current composition roots and tests are the
4
+ * implementation evidence. Historical migration drafts are not compatibility contracts.
13
5
  */
14
6
  import { type ModelPurpose } from "@xiaozhiclaw/module-sdk/model-access";
15
7
  import type { CapabilityRequirementV1 } from "@xiaozhiclaw/module-sdk";
@@ -23,14 +15,14 @@ export * from "./memory-category.js";
23
15
  export type { AcpContentBlock, AcpResourceContents } from "./acp-content.js";
24
16
  /** agent 逻辑身份(小智自身也是一个 agentId="qlogicagent")。自身 vs 第三方仅由此值决定(F2)。 */
25
17
  export type AgentId = string;
26
- /** 确定性派生的项目主键(freeze §11.4#2,抄 VSCode getWorkspaceId)。绝不随机、绝不裸路径。 */
18
+ /** 确定性派生的项目主键(current contract,抄 VSCode getWorkspaceId)。绝不随机、绝不裸路径。 */
27
19
  export type ProjectId = string;
28
20
  /** 会话稳定身份(创建即恒定,session-identity-alignment-spec)。 */
29
21
  export type CanonicalSessionId = string;
30
22
  /** 能力实例种类。 */
31
23
  export type MemberKind = "chat" | "product-leader" | "product-worker" | "goal-leader" | "solo-racer" | "workflow-node";
32
24
  /**
33
- * 能力实例的结构化 handle(freeze §11.4#3,抄 VSCode ExtensionRunningLocation)。可判等、可字符串化。
25
+ * 能力实例的结构化 handle(current contract,抄 VSCode ExtensionRunningLocation)。可判等、可字符串化。
34
26
  * 取代今天各特性自造的 memberId 串(chat-* / product-*:*:* / goal-*:leader / solo-* / workflow-agent-*)。
35
27
  */
36
28
  export interface MemberHandle {
@@ -54,10 +46,10 @@ export interface SessionContext {
54
46
  projectId: ProjectId;
55
47
  /** 项目/worktree 工作目录 */
56
48
  cwd: string;
57
- /** 仅 native-cwd agent(codex/claude)有意义(freeze §11.4#5:传输层重连令牌,不承担状态恢复) */
49
+ /** 仅 native-cwd agent(codex/claude)有意义(current contract:传输层重连令牌,不承担状态恢复) */
58
50
  resumeNativeId?: string;
59
51
  }
60
- /** sendTurn 的统一返回(freeze §11.1:消灭"外部对象 / 内部字符串"双形态)。 */
52
+ /** sendTurn 的统一返回(current contract:消灭"外部对象 / 内部字符串"双形态)。 */
61
53
  export interface TurnResult {
62
54
  content: string;
63
55
  stopReason?: string;
@@ -68,10 +60,10 @@ export interface TurnResult {
68
60
  /** 仅诊断,永不进入下游解析输入 */
69
61
  diagnostics?: unknown;
70
62
  }
71
- /** agent 实例存活/失败状态(freeze §5.1 判活 + §5.3 fail-loud)。 */
63
+ /** agent 实例存活/失败状态(current contract 判活 + §5.3 fail-loud)。 */
72
64
  export type AgentInstanceState = "starting" | "ready" | "busy" | "unresponsive" | "exited";
73
65
  /**
74
- * 结构化失败归类(freeze §4 E3:失败一律结构化明示,不得降级成裸 error 串)。
66
+ * 结构化失败归类(current contract E3:失败一律结构化明示,不得降级成裸 error 串)。
75
67
  * UNKNOWN = 无法归类时的显式兜底:禁止硬塞错误 code,也禁止因归不了类降级成裸串。
76
68
  */
77
69
  export declare const LIFECYCLE_CODES: readonly ["CANCELLED", "PROCESS_EXIT", "HEARTBEAT_TIMEOUT", "TURN_TIMEOUT", "PROTOCOL_MISMATCH", "UNKNOWN"];
@@ -95,7 +87,7 @@ export interface AgentSpec {
95
87
  systemPrompt?: string;
96
88
  /** Gateway materialized, session-scoped non-secret model/permission profile. */
97
89
  profile?: ResolvedSpawnProfile;
98
- /** 三态鉴权由 CredentialResolver 按 agentId 解析后显式传入(freeze §6.2);不糊在 envOverrides,明文不进事件/日志 */
90
+ /** 三态鉴权由 CredentialResolver 按 agentId 解析后显式传入(current contract);不糊在 envOverrides,明文不进事件/日志 */
99
91
  credentials?: ResolvedCredentials;
100
92
  /** 仅非密的运行覆盖(如 solo 自身分支 QLOGICAGENT_WORKTREE_WORKDIR/SOLO_LEAN) */
101
93
  envOverrides?: Record<string, string>;
@@ -124,7 +116,7 @@ export interface TurnInput {
124
116
  }
125
117
  /**
126
118
  * 中立监督每个 agent 进程(小智自身 + 第三方对等),不嵌套。
127
- * 判活=ACK 响应性(freeze §5.1,内部实现,不暴露方法名清单)。失败=结构化事件(§5.3),不静默杀。
119
+ * 判活=ACK 响应性(current contract,内部实现,不暴露方法名清单)。失败=结构化事件(§5.3),不静默杀。
128
120
  *
129
121
  * 不变式(冻结):
130
122
  * - F1 单注册:一个 memberKey(handle) 至多一个实例(池化种类按 key 复用)。
@@ -135,7 +127,7 @@ export interface TurnInput {
135
127
  * - F6 判活地板 = "任意协议消息计活"(§6.3);我方 agent 可另加 ping 作补充、不作地板。
136
128
  */
137
129
  export interface AgentSupervisor {
138
- /** 确保 handle 对应实例在跑(不在则 spawn,池化种类复用)。能力 endpointCapabilityService 统一注入(C2)。 */
130
+ /** 确保 handle 对应实例在跑(不在则 spawn,池化种类复用)。Host capabilitiessession-bound projection 注入。 */
139
131
  ensure(handle: MemberHandle, spec: AgentSpec): Promise<void>;
140
132
  /**
141
133
  * 向实例发一个回合,流式事件经 subscribe 回流,最终 resolve 统一 TurnResult。取代 processManager.sendTask。
@@ -224,7 +216,7 @@ export type ProjectAgentSessionEntry = {
224
216
  };
225
217
  /**
226
218
  * 拥有会话存储 + 项目作用域 + agentId 绑定 + canonical↔native 映射 + 生命周期状态。
227
- * 唯一权威(不与 qlogicagent 并存)。崩溃恢复靠网关持有并重放(freeze §11.4#5)。
219
+ * 唯一权威(不与 qlogicagent 并存)。崩溃恢复靠网关持有并重放(current contract)。
228
220
  *
229
221
  * 不变式(冻结):
230
222
  * - S1 绑定权威唯一在网关;canonical id 创建即恒定。
@@ -269,75 +261,13 @@ export interface SessionProjectService {
269
261
  recordLifecycle(sessionId: CanonicalSessionId, ev: LifecycleEvent): void;
270
262
  replayStateTo(handle: MemberHandle, sessionId: CanonicalSessionId): Promise<void>;
271
263
  }
272
- export interface CapabilityEndpoint {
273
- /** 唯一规范名(astraclaw;不再双别名,C1) */
274
- serverName: string;
275
- transport: "stdio" | "ipc";
276
- /** 网关稳定 endpoint */
277
- address: string;
278
- /** 演进用 */
279
- version?: string;
280
- /** token 放 ref、不放明文;由 gateway/CredentialResolver 解析。qlogicagent 只消费、不维护 registry。 */
281
- auth?: {
282
- kind: "none";
283
- } | {
284
- kind: "bearerRef";
285
- ref: string;
286
- };
287
- }
288
- /** [S1 补定] 已装技能引用(host 注册表成员)。 */
289
- export interface SkillRef {
290
- name: string;
291
- description?: string;
292
- version?: string;
293
- enabled: boolean;
294
- /** provenance(catalog 安装 / 本地创建 / 晋升产物等) */
295
- source?: string;
296
- }
297
- /** [S1 补定] MCP 连接器引用。 */
298
- export interface ConnectorRef {
299
- serverName: string;
300
- tools: string[];
301
- transport?: string;
302
- }
303
- /** [S1 补定] host 管理的安装请求(装一次,全员共享;VSCode 扩展模型)。 */
304
- export interface InstallRequest {
305
- kind: "skill" | "mcp";
306
- id: string;
307
- version?: string;
308
- source?: string;
309
- }
310
- /**
311
- * 拥有已装技能 + MCP 连接器的注册表 + 内容;对网关监督的每个 agent(含小智)统一注入一个能力 endpoint。
312
- *
313
- * 不变式(冻结):
314
- * - C1 单注册:能力 server 唯一规范名,绝不注册第二别名。
315
- * - C2 注入点唯一:能力注入只在 Supervisor spawn 处经本服务一处发生。
316
- * - C3 内容 host 持有、使用 agent 侧:技能内容/连接器 config 归网关注册表;执行仍在 agent、经此 endpoint。
317
- */
318
- export interface CapabilityService {
319
- /** 供 Supervisor 在 spawn 每个 agent 时统一注入的能力接入点(对小智自己也走同一 endpoint)。 */
320
- getEndpoint(forAgent: AgentId, session: SessionContext): CapabilityEndpoint;
321
- /** MCP 连接器:发现 + 调用(mcp_connectors_list / mcp_tool_call 的后端)。 */
322
- listConnectors(session: SessionContext): ConnectorRef[];
323
- callConnector(toolName: string, args: unknown): Promise<{
324
- content: unknown;
325
- structuredContent?: unknown;
326
- _meta?: unknown;
327
- isError?: boolean;
328
- imageUrls?: string[];
329
- }>;
330
- /** host 管理的安装(装一次,全员共享)。 */
331
- install(ref: InstallRequest): Promise<void>;
332
- uninstall(id: string): Promise<void>;
333
- }
334
264
  /** CredentialResolver —— 三态鉴权解析(G1)。token 传 ref,明文不进事件/日志。 */
335
265
  export interface CredentialResolver {
336
266
  resolve(agentId: AgentId, ownerId: string): ResolvedCredentials;
337
267
  /** bearerRef → 实际 token,仅在注入 spawn env 的边界解引用 */
338
268
  deref(ref: string): string;
339
269
  }
340
- /** [Route B X5] 单把 key 的 wire 视图(keyId 寻址;key 材料只给掩码,明文走 revealKey)。 */
270
+ /** 单把 key 的 wire 视图(keyId 寻址;key 材料只给掩码,明文走 revealKey)。 */
341
271
  export interface ProviderKeyInfo {
342
272
  keyId: string;
343
273
  /** 掩码展示(maskApiKey 语义);明文绝不进列表面 */
@@ -351,7 +281,7 @@ export interface ProviderInfo {
351
281
  name?: string;
352
282
  hasKey: boolean;
353
283
  enabled: boolean;
354
- /** [Route B X5] keyId 级子清单(一 provider key);B2 profile lane 按 wire 真实形状收紧(X3) */
284
+ /** keyId 级子清单;一个 provider 可以配置多把 key */
355
285
  keys?: ProviderKeyInfo[];
356
286
  }
357
287
  /** settings.addKey 的原子提交选项;只承载非密元数据/替换策略。 */
@@ -422,7 +352,7 @@ export interface ProfileConfigService {
422
352
  };
423
353
  listProviders(ownerId: string): ProviderInfo[];
424
354
  /**
425
- * [Route B X5 正名] keyId 粒度(wire 真实粒度;一 provider key,原 provider 级签名是 S1 臆造面)
355
+ * keyId 粒度;一个 provider 可以配置多把 key。
426
356
  * 返回新铸 keyId。prepare 阶段完成目录解析/候选探针,commit 阶段重读最新 settings 后只做一次
427
357
  * 原子替换;失败不改变旧文件/旧 key enabled 状态。[X4 过渡] 本刀仍按 legacy 形态把材料直存
428
358
  * settings.json,ref 化另批完成。明文绝不进入日志、事件或通知。
@@ -435,7 +365,7 @@ export interface ProfileConfigService {
435
365
  /** [X5] 按 keyId 启停单把 key。false=未找到(不写盘)。 */
436
366
  toggleKey(ownerId: string, keyId: string, on: boolean): boolean;
437
367
  /**
438
- * [Route B X4] UI 显式索取明文(wire settings.getKey/copyKey 的唯一后端;剪贴板副作用移前端)。
368
+ * UI 显式索取明文;剪贴板副作用由前端负责。
439
369
  * 红线:返回值绝不经 HostNotificationSink 广播、绝不落日志/事件;ref 期在此边界 deref(VSCode
440
370
  * ISecretStorageService 同构:main 持密文,显式 API 解密返回调用方)。未找到 throw(fail-loud)。
441
371
  */
@@ -1125,6 +1055,10 @@ export interface HostSkillLifecycleRecord {
1125
1055
  registryRiskTier?: "R0" | "R1" | "R2" | "R3";
1126
1056
  registryEffectiveRiskTier?: "R0" | "R1" | "R2" | "R3";
1127
1057
  registryKeptSignalAt?: string;
1058
+ /** Short, verified model-routing metadata. It describes when the Skill is useful, not how to run it. */
1059
+ routingSummary?: string;
1060
+ /** Optional catalog grouping metadata; it never triggers invocation. */
1061
+ capabilityClass?: string;
1128
1062
  [extra: string]: unknown;
1129
1063
  }
1130
1064
  /** Gateway 对同一技能 store 的只读快照条目。active 只叠加全局/项目禁用,不叠 turn 工具条件。 */
@@ -1705,6 +1639,14 @@ export interface HostApplyCuratorPlanResult {
1705
1639
  }
1706
1640
  export type HostSkillInstallRiskTier = "R0" | "R1" | "R2" | "R3";
1707
1641
  export type HostSkillReplacementPolicy = "managed-unmodified" | "user-confirmed";
1642
+ export interface HostSkillCredentialDescriptor {
1643
+ key: string;
1644
+ label: string;
1645
+ envKey: string;
1646
+ placeholder?: string;
1647
+ secret?: boolean;
1648
+ helpUrl?: string;
1649
+ }
1708
1650
  export interface HostPrepareSkillInstallParams {
1709
1651
  name: string;
1710
1652
  version: string;
@@ -1721,6 +1663,14 @@ export interface HostPrepareSkillInstallParams {
1721
1663
  manifestSchemaVersion: 18;
1722
1664
  manifestDigest: `sha256:${string}`;
1723
1665
  requiredCapabilities: CapabilityRequirementV1[];
1666
+ /** Optional in the wire contract for compatibility with schema-18 callers predating secure setup. */
1667
+ credentials?: HostSkillCredentialDescriptor[];
1668
+ /** Verified catalog terms used only for installed Skill recall. */
1669
+ searchTerms?: string[];
1670
+ /** Verified, single-line routing summary projected in the complete Skill directory. */
1671
+ routingSummary?: string;
1672
+ /** Optional catalog grouping metadata; it is never an invocation rule. */
1673
+ capabilityClass?: string;
1724
1674
  }
1725
1675
  export interface HostPrepareSkillInstallResult {
1726
1676
  installationId: string;
@@ -105,11 +105,11 @@ export declare class SoloEvaluator {
105
105
  */
106
106
  start(params: SoloStartParams): Promise<string>;
107
107
  /**
108
- * 激活层(S3c §1.5):gateway-routed delegate 路径 —— 竞速者回合经网关代派(x/delegate),不本地
108
+ * 激活层(active Host path §1.5):gateway-routed delegate 路径 —— 竞速者回合经网关代派(x/delegate),不本地
109
109
  * spawn。同 handle(solo-racer/soloId/agentId/seq)⇒ supervisor 按 memberKey 复用同一竞速者进程与
110
110
  * ACP 会话:初赛 → follow-up → 评比全程上下文连续(取代旧「watchdog reap + 按需 re-spawn」循环,
111
111
  * worktree 文件仍是 durable state)。cwd=worktree;self 竞速者的 QLOGICAGENT_WORKTREE_WORKDIR /
112
- * QLOGICAGENT_SOLO_LEAN 由 gateway 按 kind=solo-racer 派生注入(AgentSpec.envOverrides,freeze §1
112
+ * QLOGICAGENT_SOLO_LEAN 由 gateway 按 kind=solo-racer 派生注入(AgentSpec.envOverrides,current contract
113
113
  * —— descriptor/env 注入在 qla 侧退场,env 是监督者按成员种类决定的启动器不变量,非调用方入参)。
114
114
  * usage 由 TurnResult.usage 承(不再读共享 PM 的 usage tracker)。
115
115
  */
@@ -73,7 +73,7 @@ export interface AcpQlogicagentCapability {
73
73
  /** Multi-agent orchestration (solo / product / team). */
74
74
  orchestration?: boolean;
75
75
  /**
76
- * T9 capability 握手 gate(S3a 跨进程 delegate 传输;host→agent 声明位)。
76
+ * T9 capability 握手 gate(delegate transport 跨进程 delegate 传输;host→agent 声明位)。
77
77
  * host(gateway)声明「我服务 gateway-routed delegate」——即由 GatewayDelegateServer 认
78
78
  * `x/delegate` 请求、下行 `x/delegate.update` 回流帧。qlogicagent(leader)【仅当】收到此位才走
79
79
  * DelegateClient sends x/delegate only when this bit is present. If omitted, orchestration is
@@ -5,7 +5,7 @@ export { type ChatMessage, type ChatMessageRole, type ContextAnchor, type Contex
5
5
  export { type AgentRpcMethodMap, type ProductInstanceDef, type ProductPhase, type ProductStatus, type ProductSummary, type ProductTaskDef, type ProductTaskStatus, type SoloAgentResult, type SoloAgentState, type SoloState, type SoloStatus, } from "./agent-methods.js";
6
6
  export type * from "./acp-agent-management.js";
7
7
  export { AGENT_TEAM_WS_EVENT_NAMES, AGENT_WS_EVENT_NAMES, ALL_AGENT_WS_EVENT_NAMES, type AgentTeamWsEventName, type AgentWsEventName, type AllAgentWsEventName, } from "./agent-events.js";
8
- export { type AgentSource, type ArtifactType, type CapabilityRoutingEvidence, type MediaResultType, type MemoryDecayCompletedNotification, type MemoryUpdatedNotification, type NotificationMethod, type NotificationMethodMap, type NotificationThreadItem, type ThreadItemNotification, type PermissionRuleUpdatedNotification, type PlanInterruptedNotification, type PongNotification, type ProductBudgetUpdateNotification, type ProductBudgetWarningNotification, type ProductCheckpointedNotification, type ProductCompletedNotification, type ProductDagTopologyNotification, type ProductTaskCompletedNotification, type ProductTaskFailedNotification, type ProductTaskOutputDeltaNotification, type ProductMembersNotification, type ProductAgentActivityNotification, type ProductTaskStartedNotification, type ProjectArchivedNotification, type ProjectCreatedNotification, type ProjectDeletedNotification, type ProjectDetachedNotification, type ProjectAttachedNotification, type ProjectRenamedNotification, type ProjectSwitchedNotification, type ProjectUnarchivedNotification, type SessionInfoNotification, type SessionRecoveryPendingNotification, type SoloAgentDeltaNotification, type SoloAgentUsageNotification, type SoloEvaluationNotification, type SoloProgressNotification, type TeamMemberNotification, type ToolApprovalRequestNotification, type TurnAnnotationsNotification, type TurnArtifactContractNotification, type TurnArtifactNotification, type TurnAskUserNotification, type TurnDeltaNotification, type TurnEndNotification, type TurnErrorNotification, type TurnExecProgressNotification, type TurnHeartbeatNotification, type TurnMediaResultNotification, type TurnPlanUpdateNotification, type TurnProgressNotification, type TurnReasoningDeltaNotification, type TurnRecoveryNotification, type TurnSidechainCompletedNotification, type TurnSidechainStartedNotification, type TurnSkillAcquisitionNeededNotification, type TurnStartNotification, type TurnSubagentActivityNotification, type TurnSubagentActivityStatus, type TurnSubagentCompletedNotification, type TurnSubagentDecisionNotification, type TurnSubagentDeltaNotification, type TurnSubagentEndedNotification, type TurnSubagentEvidenceItem, type TurnSubagentStartedNotification, type TurnSubagentTokenUsage, type TurnSuggestionsNotification, type TurnTaskUpdatedNotification, type TurnTodosUpdatedNotification, type TurnToolBlockedNotification, type TurnToolCallNotification, type TurnToolResultNotification, type TurnToolSelectionPolicyNotification, type ToolCallExecutionEvidence, type FinalAnswerEvidence, type TurnToolUseSummaryNotification, type TurnUsageUpdateNotification, type WireTokenUsage, type ProductPlanReadyNotification, type ProductPlanFailedNotification, type ProductPlanningDeltaNotification, type ProductLeaderMessageNotification, type ProductPlanningAskNotification, type MentionDelegateStartedNotification, type MentionDelegateActivityNotification, type MentionDelegateSettledNotification, type WorkflowDeletedNotification, type WorkflowRecordNotification, type WorkflowRunCompletedNotification, type WorkflowRunFailedNotification, type WorkflowRunStartedNotification, } from "./notification-payloads.js";
8
+ export { type AgentSource, type ArtifactType, type MediaResultType, type MemoryDecayCompletedNotification, type MemoryUpdatedNotification, type NotificationMethod, type NotificationMethodMap, type NotificationThreadItem, type ThreadItemNotification, type PermissionRuleUpdatedNotification, type PlanInterruptedNotification, type PongNotification, type ProductBudgetUpdateNotification, type ProductBudgetWarningNotification, type ProductCheckpointedNotification, type ProductCompletedNotification, type ProductDagTopologyNotification, type ProductTaskCompletedNotification, type ProductTaskFailedNotification, type ProductTaskOutputDeltaNotification, type ProductMembersNotification, type ProductAgentActivityNotification, type ProductTaskStartedNotification, type ProjectArchivedNotification, type ProjectCreatedNotification, type ProjectDeletedNotification, type ProjectDetachedNotification, type ProjectAttachedNotification, type ProjectRenamedNotification, type ProjectSwitchedNotification, type ProjectUnarchivedNotification, type SessionInfoNotification, type SessionRecoveryPendingNotification, type SoloAgentDeltaNotification, type SoloAgentUsageNotification, type SoloEvaluationNotification, type SoloProgressNotification, type TeamMemberNotification, type ToolApprovalRequestNotification, type TurnAnnotationsNotification, type TurnArtifactContractNotification, type TurnArtifactNotification, type TurnAskUserNotification, type TurnDeltaNotification, type TurnEndNotification, type TurnErrorNotification, type TurnExecProgressNotification, type TurnHeartbeatNotification, type TurnMediaResultNotification, type TurnPlanUpdateNotification, type TurnProgressNotification, type TurnReasoningDeltaNotification, type TurnRecoveryNotification, type TurnSidechainCompletedNotification, type TurnSidechainStartedNotification, type TurnSkillAcquisitionNeededNotification, type TurnStartNotification, type TurnSubagentActivityNotification, type TurnSubagentActivityStatus, type TurnSubagentCompletedNotification, type TurnSubagentDecisionNotification, type TurnSubagentDeltaNotification, type TurnSubagentEndedNotification, type TurnSubagentEvidenceItem, type TurnSubagentStartedNotification, type TurnSubagentTokenUsage, type TurnSuggestionsNotification, type TurnTaskUpdatedNotification, type TurnTodosUpdatedNotification, type TurnToolBlockedNotification, type TurnToolCallNotification, type TurnToolResultNotification, type TurnToolSelectionPolicyNotification, type ToolCallExecutionEvidence, type FinalAnswerEvidence, type TurnToolUseSummaryNotification, type TurnUsageUpdateNotification, type WireTokenUsage, type ProductPlanReadyNotification, type ProductPlanFailedNotification, type ProductPlanningDeltaNotification, type ProductLeaderMessageNotification, type ProductPlanningAskNotification, type MentionDelegateStartedNotification, type MentionDelegateActivityNotification, type MentionDelegateSettledNotification, type WorkflowDeletedNotification, type WorkflowRecordNotification, type WorkflowRunCompletedNotification, type WorkflowRunFailedNotification, type WorkflowRunStartedNotification, } from "./notification-payloads.js";
9
9
  export { ACP_EXTENDED_METHODS, ACP_EXTENDED_SESSION_UPDATE_TYPES, ACP_METHODS, ACP_PROTOCOL_VERSION, ACP_SESSION_UPDATE_TYPES, isAcpJsonRpcNotification, isAcpJsonRpcRequest, isAcpJsonRpcResponse, isExtendedSessionUpdateType, isStandardSessionUpdateType, parseAcpMessage, type AcpAgentCapabilities, type AcpAgentMessageChunkPayload, type AcpAgentThoughtChunkPayload, type AcpConfigOptionDescriptor, type AcpConfigOptionUpdatePayload, type AcpContentBlock, type AcpEndTurnPayload, type AcpExtendedMethod, type AcpExtendedSessionUpdateType, type AcpFsReadTextFileParams, type AcpFsReadTextFileResult, type AcpFsWriteTextFileParams, type AcpFsWriteTextFileResult, type AcpHostCapabilities, type AcpInitializeParams, type AcpInitializeResult, type AcpJsonRpcError, type AcpJsonRpcMessage, type AcpJsonRpcNotification, type AcpJsonRpcRequest, type AcpJsonRpcResponse, type AcpMode, type AcpPermissionOption, type AcpPermissionRequestParams, type AcpPermissionRequestResult, type AcpPlanPayload, type AcpSessionCancelParams, type AcpSessionCloseParams, type AcpSessionMeta, type AcpSessionLoadParams, type AcpSessionModeState, type AcpSessionNewParams, type AcpSessionNewResult, type AcpSessionPromptParams, type AcpSessionPromptResult, type AcpSessionSetConfigParams, type AcpSessionUpdateNotification, type AcpSessionUpdateType, type AcpStandardMethod, type AcpStandardSessionUpdateType, type AcpStopReason, type AcpToolCallPayload, type AcpToolCallUpdatePayload, type AcpUsage, type AcpUsageUpdatePayload, type AcpXSessionInfoPayload, type AcpXSkillInstructionPayload, } from "./acp-protocol.js";
10
10
  export { type ApprovalRequiredToolContract, type ModelSelectionReason, type PendingPromptContract, type RuntimeCapabilitySummaryContract, type RuntimeSessionContract, type SessionIdentityContract, } from "./session.js";
11
11
  export { CAPABILITY_MANIFEST_DIFF_SECTIONS, cloneCapabilityManifestSnapshot, createCapabilityManifestDiffPayload, deriveCapabilityToolNamespaces, deriveCapabilityWorkspaceIds, mergeCapabilityManifestSnapshot, type CapabilityManifestApprovalMode, type CapabilityManifestApprovalPolicyContract, type CapabilityManifestDiffSection, type CapabilityMcpManifestContract, type CapabilityManifestSnapshotContract, type HostCapabilitySnapshotContract, type CapabilityPluginManifestContract, type RuntimeCapabilityViewContract, type RuntimeToolEligibilityContract, type CapabilitySkillManifestContract, type CapabilityToolManifestContract, type CapabilityWorkspaceSummaryContract, type ToolEligibilityResolvedSource, type ToolEligibilityReasonCode, type ToolEligibilityStatus, } from "./capability-manifest.js";
@@ -328,7 +328,6 @@ export interface TurnToolUseSummaryNotification {
328
328
  telemetrySource?: "agent";
329
329
  ledgerSchemaVersion: 4;
330
330
  toolCalls: ToolCallExecutionEvidence[];
331
- routingEvidence?: CapabilityRoutingEvidence;
332
331
  finalAnswerEvidence: FinalAnswerEvidence;
333
332
  availableToolNames: string[];
334
333
  enabledToolNames: string[];
@@ -338,27 +337,16 @@ export interface TurnToolUseSummaryNotification {
338
337
  reason: string;
339
338
  }>;
340
339
  }
341
- /** Typed turn ownership and authorized tool-surface telemetry. */
342
- export interface CapabilityRoutingEvidence {
343
- schemaVersion: 2;
344
- owner: "structured-planner" | "direct-response" | "typed-builtin";
345
- source: "structured-planner" | "direct-response" | "typed-builtin";
346
- routingStatus: "selected";
347
- routingReason: string;
348
- availableToolCount: number;
349
- exposedToolCount: number;
350
- }
351
340
  export interface TurnToolSelectionPolicyNotification {
352
341
  turnId: string;
353
342
  policyId: string;
354
- intent: "capability_routing" | "benchmark_state_maintenance" | "fresh_evidence" | "verification" | "final_answer" | "tool_recovery" | "lifecycle_reconciliation";
343
+ intent: "benchmark_state_maintenance" | "fresh_evidence" | "verification" | "final_answer" | "tool_recovery" | "lifecycle_reconciliation";
355
344
  reason: string;
356
345
  availableToolNames: string[];
357
346
  enabledToolNamesBefore: string[];
358
347
  enabledToolNamesAfter: string[];
359
348
  suppressedToolNames: string[];
360
349
  nextAction: string;
361
- routingEvidence?: CapabilityRoutingEvidence;
362
350
  }
363
351
  /** Queryable long-horizon turn lifecycle telemetry. */
364
352
  export interface TurnLifecycleNotification {
@@ -13,9 +13,15 @@
13
13
  *
14
14
  * Grouping follows subsystem boundaries.
15
15
  */
16
- /** Absolute max rounds any agent can run (hard cap). */
16
+ /**
17
+ * @deprecated Compatibility value exposed through the legacy tunables profile.
18
+ * Turn execution is unbounded unless the caller explicitly supplies maxRounds.
19
+ */
17
20
  export declare const MAX_ROUNDS_LIMIT = 100;
18
- /** Default rounds for a top-level agent turn. */
21
+ /**
22
+ * @deprecated Compatibility value exposed through the legacy tunables profile.
23
+ * It is not applied as an implicit top-level turn limit.
24
+ */
19
25
  export declare const DEFAULT_MAX_ROUNDS = 25;
20
26
  /** Default temperature for LLM calls (0 = deterministic). */
21
27
  export declare const DEFAULT_TEMPERATURE = 0;
@@ -29,10 +35,10 @@ export declare const DEFAULT_TOOL_EXECUTION_TIMEOUT_MS: number;
29
35
  export declare const MAX_CONSECUTIVE_FAILURES = 3;
30
36
  /** Max times the exact same (tool_name, arguments) pair can repeat. */
31
37
  export declare const MAX_IDENTICAL_CALL_REPEATS = 2;
32
- /** Max times the same tool can fail with different args before blocking (variant-loop detection).
33
- * Includes both hard failures (ok=false) and soft empty results (e.g. "No matches found").
34
- * Note: blocked calls still emit tool_call events, so effective max attempts visible to
35
- * client = MAX + 1 (the blocked attempt) + possible 1 alternative tool = MAX + 2. */
38
+ /** Max hard failures for the same normalized target before blocking.
39
+ * Generic typed tools use their full canonical arguments, so a corrected schema or payload is a
40
+ * different invocation. Search and exec retain their domain-specific normalized target keys.
41
+ * Soft-empty results and rejected proposals are not executions and do not consume this budget. */
36
42
  export declare const MAX_TOOL_VARIANT_FAILURES = 2;
37
43
  /** Default context window size (tokens). */
38
44
  export declare const DEFAULT_CONTEXT_WINDOW_TOKENS = 128000;
@@ -160,7 +166,9 @@ export declare const DREAM_MAX_DURATION_MS = 300000;
160
166
  * Used by private X7 host profile tooling and local runtime consumers.
161
167
  */
162
168
  export interface TunableDefaults {
169
+ /** @deprecated Compatibility-only; not an implicit execution limit. */
163
170
  maxRoundsLimit: number;
171
+ /** @deprecated Compatibility-only; callers must explicitly set maxRounds. */
164
172
  defaultMaxRounds: number;
165
173
  defaultTemperature: number;
166
174
  maxToolBudgetCap: number;
@@ -1,5 +1,5 @@
1
1
  import type { HostDelegationTelemetrySummary } from "../../host-contract/index.js";
2
- import type { CapabilityRoutingEvidence, FinalAnswerEvidence, ToolCallExecutionEvidence } from "../../protocol/wire/notification-payloads.js";
2
+ import type { FinalAnswerEvidence, ToolCallExecutionEvidence } from "../../protocol/wire/notification-payloads.js";
3
3
  export type AgentMode = "chat" | "solo" | "product" | "workflow" | "unknown";
4
4
  export interface TurnTelemetryUsage {
5
5
  inputTokens?: number;
@@ -18,7 +18,6 @@ export interface TurnTelemetryFileContext {
18
18
  }
19
19
  export interface TurnTelemetryExecutionEvidence {
20
20
  ledgerSchemaVersion: 4;
21
- routingEvidence?: CapabilityRoutingEvidence;
22
21
  toolCalls: ToolCallExecutionEvidence[];
23
22
  finalAnswerEvidence: FinalAnswerEvidence;
24
23
  availableToolNames: string[];
@@ -0,0 +1,16 @@
1
+ import type { ToolDefinition } from "../../agent/types.js";
2
+ export type HostSkillDirectoryProjection = {
3
+ tools: ToolDefinition[];
4
+ prompt?: undefined;
5
+ revision?: undefined;
6
+ } | {
7
+ tools: ToolDefinition[];
8
+ prompt: string;
9
+ revision: string;
10
+ };
11
+ /**
12
+ * Promote the Host's standard MCP Skill directory metadata into first-class model context.
13
+ * The Host remains the catalog authority and the model remains the selector; this adapter
14
+ * only prevents a large directory from being buried inside one generic tool description.
15
+ */
16
+ export declare function projectHostSkillDirectory(tools: readonly ToolDefinition[]): HostSkillDirectoryProjection;
@@ -42,7 +42,7 @@ export interface McpServerEntry {
42
42
  include?: string[];
43
43
  exclude?: string[];
44
44
  };
45
- /** Per-tool invocation budget for this server (1s..10min). */
45
+ /** Per-tool invocation budget for this server (1s..30min). */
46
46
  callTimeoutMs?: number;
47
47
  }
48
48
  export interface McpSecurityIssue {
@@ -51,8 +51,8 @@ export interface McpSecurityIssue {
51
51
  }
52
52
  /**
53
53
  * A configured server that is not currently serving tools. Surfaced (not just logged)
54
- * so capability queries (e.g. mcp_connectors_list) can disclose "configured but unavailable"
55
- * instead of the server silently vanishing from the tool pool.
54
+ * so inventory diagnostics can disclose "configured but unavailable" instead of the
55
+ * server silently vanishing from the projected tool pool.
56
56
  */
57
57
  export interface McpServerFailure {
58
58
  name: string;
@@ -73,6 +73,14 @@ export interface McpManagerConfig {
73
73
  }
74
74
  export declare function resolveMcpCallTimeoutMs(value: number | undefined): number;
75
75
  export declare function withMcpDeadline<T>(operation: Promise<T>, timeoutMs: number, label: string): Promise<T>;
76
+ /**
77
+ * Propagate the agent turn's cancellation into mcporter. Runtime.callTool does
78
+ * not accept an AbortSignal, so closing the affected server is the public
79
+ * transport boundary that terminates the in-flight request and its stdio
80
+ * process tree. The next invocation reconnects through the normal mcporter
81
+ * runtime path.
82
+ */
83
+ export declare function callMcpToolWithAbort(runtime: Runtime, serverName: string, toolName: string, options: Parameters<Runtime["callTool"]>[2], signal?: AbortSignal): Promise<Awaited<ReturnType<Runtime["callTool"]>>>;
76
84
  /**
77
85
  * Read the authoritative MCP tools/list payload from mcporter's public
78
86
  * connection boundary. mcporter's convenience listTools() intentionally
@@ -173,7 +181,7 @@ export declare function toPortableResult(result: unknown, _source?: {
173
181
  args?: Record<string, unknown>;
174
182
  }): PortableToolResult;
175
183
  export declare function validateMcpToolWorkspaceBoundary(toolName: string, args: unknown, workspaceRoot: string | undefined): string | null;
176
- export declare function parseMcpConfig(json: unknown): McpServerEntry[];
184
+ export declare function parseMcpServerMap(json: unknown): McpServerEntry[];
177
185
  export declare function filterMcpTools<T extends {
178
186
  name: string;
179
187
  }>(tools: readonly T[], filter?: McpServerEntry["tools"]): T[];
@@ -1,11 +1,11 @@
1
1
  /**
2
- * HostMemoryProvider —— qlogicagent 大脑对 memories.db 的存取反转(Route B B3;X7 brain proxy)
2
+ * HostMemoryProvider —— qlogicagent 通过 Host request 访问 Host-owned memories.db
3
3
  *
4
4
  * Gateway Memory 权威公开面的 **proxy 实现**:大脑逻辑(dream/distill/晋升/consolidation/召回 hook)
5
5
  * 零改动,底下的存取经 `x/host.request`(HostRequestClient)打到 gateway 四权威 host 服务(memory 域),
6
6
  * store(memories.db)只有 gateway 进程打开。
7
7
  *
8
- * 单一事实源:docs/agent-supervision-authority-migration-spec.md §3.1;契约 host-contract §13
8
+ * 契约权威:host-contract §13
9
9
  * (HostRequestParams;wire 形态 = { service:"memory", method, params:<位置参数数组> })。
10
10
  *
11
11
  * 【PROXY 共享面(以 host-contract 常量为准;两仓照此表,一字不差)】
@@ -12,7 +12,7 @@
12
12
  * (task-distill-candidates / promotion-proposals / procedure-usage,均 A 域)的读写权威
13
13
  * 已全部归 gateway MemoryProfileService(唯一写者);qlogicagent 大脑经 HostMemoryProvider
14
14
  * proxy 的 read/write{DistillCandidates,PromotionProposals,ProcedureUsage} 存取,本文件只提供
15
- * 采集/聚类/晋升的确定性算法。单一事实源 docs/agent-supervision-authority-migration-spec.md。
15
+ * 采集/聚类/晋升的确定性算法由本模块及其测试锁定。
16
16
  */
17
17
  import { type HubSkillCategory } from "../skill-system/skill-category.js";
18
18
  import type { ProcedureVerificationEvidence } from "../../host-contract/index.js";
@@ -1,53 +1,17 @@
1
- /** Commands that search/find content (collapsible in UI). */
2
1
  export declare const SEARCH_COMMANDS: Set<string>;
3
- /** Commands that read/display file content (collapsible in UI). */
4
2
  export declare const READ_COMMANDS: Set<string>;
5
- /** Commands that list directory contents. */
6
3
  export declare const LIST_COMMANDS: Set<string>;
7
- /**
8
- * Commands that are semantically neutral — they don't interact
9
- * with the file system in a meaningful way. Skipped when
10
- * classifying piped commands.
11
- */
12
4
  export declare const SEMANTIC_NEUTRAL_COMMANDS: Set<string>;
13
- /**
14
- * Commands that produce no stdout on success.
15
- * For these, the tool shows "Done" instead of "(No output)".
16
- */
17
5
  export declare const SILENT_COMMANDS: Set<string>;
18
6
  export interface CommandClassification {
19
- /** First "real" command word (after env vars / wrappers). */
20
7
  firstCommand: string | null;
21
- /** Whether the command is search-like (find, grep, etc.). */
22
8
  isSearch: boolean;
23
- /** Whether the command only reads (cat, head, stat, etc.). */
24
9
  isRead: boolean;
25
- /** Whether the command lists files (ls, tree, du). */
26
10
  isList: boolean;
27
- /** Whether the command is expected to produce no stdout. */
28
11
  isSilent: boolean;
29
- /** Whether the command is safe to run in parallel with others. */
30
12
  isConcurrencySafe: boolean;
31
- /** Whether the command only reads state (never mutates). */
32
13
  isReadOnly: boolean;
33
14
  }
34
- /**
35
- * Check whether a command has any `cd` or pushd/popd that changes CWD.
36
- * Ported from cc's `commandHasAnyCd()`.
37
- */
38
15
  export declare function commandHasAnyCd(command: string): boolean;
39
- /**
40
- * Classify a shell command.
41
- *
42
- * Mirrors cc's `isSearchOrReadBashCommand()` + `isSilentBashCommand()`.
43
- */
44
16
  export declare function classifyCommand(command: string): CommandClassification;
45
- export declare function requiresDedicatedReadSearchTool(classification: CommandClassification): boolean;
46
- /**
47
- * Actionable, command-type-specific redirect for a blocked exec command. Spelling out the
48
- * exact dedicated tool (read for file contents, search for content lookup) lets the model
49
- * self-correct instead of retrying the same blocked command into a recovery stop. Only
50
- * called for reads/searches now (directory listing is allowed via exec — see above).
51
- */
52
- export declare function dedicatedToolRedirectMessage(classification: CommandClassification): string;
53
17
  export declare function commandTargetsBinaryFile(command: string | null): boolean;
@@ -131,7 +131,7 @@ export declare class AcpServer {
131
131
  private hostSupportsExtendedEvents;
132
132
  /** Whether the host supports x/ extended RPC methods */
133
133
  private hostSupportsExtendedMethods;
134
- /** T9(S3a):host 是否在 initialize 声明服务 gateway-routed delegate(x/delegate 族;设计 §2.4)。 */
134
+ /** T9(delegate transport):host 是否在 initialize 声明服务 gateway-routed delegate(x/delegate 族;设计 §2.4)。 */
135
135
  private hostSupportsDelegate;
136
136
  /** Exact host-request capability negotiated during initialize. */
137
137
  private negotiatedHostRequestCapability;
@@ -142,7 +142,7 @@ export declare class AcpServer {
142
142
  /** Map from outbound JSON-RPC request id -> permissionId for response matching */
143
143
  private outboundRequestMap;
144
144
  /**
145
- * S3a 跨进程 delegate 客户端(泛化本类的 outbound-request 底座;设计 §5.1)。与审批 outboundRequestMap
145
+ * delegate transport 跨进程 delegate 客户端(泛化本类的 outbound-request 底座;设计 §5.1)。与审批 outboundRequestMap
146
146
  * 并存:x/delegate 用 `del-*` rpc id,审批用 `perm-*`,handleResponse 先问 delegate 再落审批,互不干扰。
147
147
  * All orchestration stations call this client through the authority-neutral DelegateBridge.
148
148
  */
@@ -177,7 +177,7 @@ export declare class AcpServer {
177
177
  get supportsExtendedEvents(): boolean;
178
178
  /** Whether the host supports extended methods */
179
179
  get supportsExtendedMethods(): boolean;
180
- /** T9(S3a):host 是否声明服务 gateway-routed delegate(gate;设计 §2.4)。 */
180
+ /** T9(delegate transport):host 是否声明服务 gateway-routed delegate(gate;设计 §2.4)。 */
181
181
  get supportsDelegate(): boolean;
182
182
  /** Exact service check over the initialize capability; no boolean/prefix fallback. */
183
183
  supportsHostRequestService(service: HostRequestService): boolean;
@@ -1,8 +1,8 @@
1
1
  /**
2
- * DelegateClient —— qlogicagent(leader)侧的跨进程 delegate 传输客户端(S3a lane impl-transport-qla)。
2
+ * DelegateClient —— qlogicagent(leader)侧的跨进程 delegate 传输客户端(delegate transport lane impl-transport-qla)。
3
3
  *
4
4
  * 契约单一事实源:host-contract §12 DelegateWire(冻结,严禁本文件自改契约)。
5
- * 设计单一事实源:docs/agent-supervision-s3a-transport-design.md(§3 帧 / §4 保序背压取消失败 / §5.1 两端职责)。
5
+ * Wire authority:host-contract §12 DelegateWire;行为由本文件及其 contract tests 锁定。
6
6
  *
7
7
  * 方向倒置(设计 §1):今天 qlogicagent→gateway 唯一 outbound 请求 = session/request_permission
8
8
  * (acp-server.ts:247 requestPermission)。本客户端泛化该 outbound-request 底座,新增:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlogicagent",
3
- "version": "2.23.1",
3
+ "version": "2.23.3",
4
4
  "packageManager": "pnpm@10.23.0",
5
5
  "description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
6
6
  "type": "module",
@@ -170,8 +170,8 @@
170
170
  "dependencies": {
171
171
  "@agentclientprotocol/sdk": "^0.25.0",
172
172
  "@napi-rs/canvas": "0.1.100",
173
- "@xiaozhiclaw/module-sdk": "0.3.1",
174
- "@xiaozhiclaw/provider-core": "0.1.33",
173
+ "@xiaozhiclaw/module-sdk": "0.4.0",
174
+ "@xiaozhiclaw/provider-core": "0.1.34",
175
175
  "ajv": "8.20.0",
176
176
  "better-sqlite3": "^12.10.0",
177
177
  "dotenv": "^17.3.1",
@@ -1,45 +0,0 @@
1
- /**
2
- * 工具/轮数预算的「进度门控续跑」策略(A)。
3
- *
4
- * 默认工具预算(DEFAULT_TOOL_BUDGET)和轮数预算(DEFAULT_MAX_ROUNDS)对「建一个完整 app/游戏」这类
5
- * 任务偏低,撞上就被迫收尾、任务半成品。本策略把预算从「写死的硬停」改成「软检查点 + 可续跑」:
6
- * 预算耗尽时,若本轮窗口**确有进度**(产出了新的成功工具结果)且**没卡在循环里**(AP5 同款:同一文件
7
- * 反复读),就再续一个窗口;否则停。续跑次数和绝对硬顶(MAX_*_CAP)双重封顶,杜绝失控。
8
- *
9
- * 与既有 token 预算续跑(budget-continuation-policy.ts)同构,只是进度信号换成「成功工具调用增量」、
10
- * 失控信号换成「读循环」。纯函数,便于单测。
11
- */
12
- /** 一轮 turn 内最多续跑次数 —— 与 token 续跑的 MAX_BUDGET_CONTINUATIONS 对齐。 */
13
- export declare const MAX_TOOL_BUDGET_CONTINUATIONS = 5;
14
- export interface ToolBudgetContinuationInput {
15
- /** 当前工具调用预算(可能已被前几次续跑抬高过)。 */
16
- currentToolBudget: number;
17
- /** 当前轮数预算。 */
18
- currentRoundBudget: number;
19
- /** 工具调用绝对硬顶(失控兜底)。 */
20
- toolHardCap: number;
21
- /** 轮数绝对硬顶。 */
22
- roundHardCap: number;
23
- /** 已续跑次数。 */
24
- continuationCount: number;
25
- /** 上个检查点以来新增的「成功且非空」工具结果数 —— 进度信号。 */
26
- successfulSinceLastCheck: number;
27
- /** 文件读取计数(AP5 读循环检测,失控信号)。 */
28
- fileReadCounts: ReadonlyMap<string, number>;
29
- /** 每次续跑给工具预算加的窗口(= DEFAULT_TOOL_BUDGET)。 */
30
- windowTools: number;
31
- /** 每次续跑给轮数预算加的窗口(= DEFAULT_MAX_ROUNDS)。 */
32
- windowRounds: number;
33
- }
34
- export interface ToolBudgetContinuationDecision {
35
- nextToolBudget: number;
36
- nextRoundBudget: number;
37
- continuationCount: number;
38
- }
39
- /**
40
- * 决定是否续跑。返回 null = 不续(应停下并诚实收尾);返回 decision = 续跑(把预算抬到 next*)。
41
- *
42
- * 停的条件(任一):①续跑次数用满;②两个预算都已到硬顶;③本窗口零进度(没新增成功结果);
43
- * ④卡在读循环。其余情况续跑,但每个预算都不超过各自硬顶。
44
- */
45
- export declare function resolveToolBudgetContinuation(input: ToolBudgetContinuationInput): ToolBudgetContinuationDecision | null;