@x-otto/runtime 0.0.1-alpha.9 → 0.1.0-alpha.9
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 +366 -278
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -10
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { CostSummary, Message, Model, ModelResolution, ProviderRegistry, ThinkingLevel } from "@x-otto/ai";
|
|
1
|
+
import { CostSummary, Message, Model, ModelResolution, ProviderRegistry, StreamFunction, ThinkingLevel } from "@x-otto/ai";
|
|
2
2
|
import { HookRegistry, HookSpec, SystemPromptTransformInput, ToolExecuteAfterInput } from "@x-otto/hooks";
|
|
3
3
|
import { EventBus, Events, Logger, TypedEventEmitter } from "@x-otto/shared";
|
|
4
4
|
import { AppendLog, PanelStateDraftEntry, PanelStateEditedFile, PanelStatePersistence, PanelStateSnapshot, PanelStateSubagentEntry, PanelStateTodoItem, PanelStateTurnSummary, PasteStatePersistence, PasteStateSnapshot } from "@x-otto/persistence";
|
|
5
|
-
import {
|
|
5
|
+
import { EVENT_DOMAIN, EventDomain, SYSTEM_PROMPT_SECTIONS, SystemPromptSectionSpec, applySectionBudget, getEventDomain } from "@x-otto/interchange";
|
|
6
|
+
import * as _$_x_otto_session0 from "@x-otto/session";
|
|
7
|
+
import { InMemorySession, LeaseInspection, Session, SessionEntry, SessionPanelState, SessionPersistence, SessionSnapshot } from "@x-otto/session";
|
|
6
8
|
import { OttoProcessInfo } from "@x-otto/env";
|
|
7
|
-
import { Agent, AgentEvent, AgentMessage, AgentSessionEvent, AgentSessionEventMap, AgentSessionEventType, AgentSessionSubscriber, AgentTool, ApprovalRisk, AskUserQuestion, ClockPort, DescribeImagesPort, GrillAnswer, GrillQuestion, GrillRequest, IdPort, MemoryPort, MemoryPort as MemoryPort$1, RandomPort, StreamFunction, StreamRetryConfig, ToolHookExecutor, ToolResult, TraceEvent, TraceRecorder, applyMemoryTransform } from "@x-otto/agent";
|
|
9
|
+
import { Agent, AgentEvent, AgentMessage, AgentSessionEvent, AgentSessionEventMap, AgentSessionEventType, AgentSessionSubscriber, AgentTool, ApprovalRisk, AskUserQuestion, ClockPort, DescribeImagesPort, GrillAnswer, GrillQuestion, GrillRequest, IdPort, MemoryPort, MemoryPort as MemoryPort$1, RandomPort, StreamFunction as StreamFunction$1, StreamRetryConfig, ToolHookExecutor, ToolResult, TraceEvent, TraceRecorder, applyMemoryTransform } from "@x-otto/agent";
|
|
8
10
|
import * as _$_x_otto_session_contract0 from "@x-otto/session-contract";
|
|
9
11
|
import { ResidencyBudgetConfig, TurnRecord, TurnRecord as TurnRecord$1 } from "@x-otto/session-contract";
|
|
10
12
|
import { ChildProcess, SpawnOptions } from "node:child_process";
|
|
@@ -205,6 +207,14 @@ declare class HostRegistry {
|
|
|
205
207
|
dispose(): void;
|
|
206
208
|
}
|
|
207
209
|
//#endregion
|
|
210
|
+
//#region src/session/semantic-reviewer.d.ts
|
|
211
|
+
type SemanticReviewerVerdict = 'allow' | 'deny' | 'abstain';
|
|
212
|
+
type SemanticReviewer = (toolName: string, args: Record<string, unknown>, description: string, risk?: ApprovalRisk) => Promise<SemanticReviewerVerdict>;
|
|
213
|
+
/** 升级审批哨兵(与 T2 的 escalation reason 同源;此处不 import agent 常量避免反向依赖,测试锁定同值)。 */
|
|
214
|
+
declare const ESCALATION_MARKER = "[sandbox-escalation]";
|
|
215
|
+
/** 仅「升级审批」请求可进语义裁决(普通 ask 仍走用户审批——范围克制,RFC §2 D3)。 */
|
|
216
|
+
declare function isEscalationApproval(description: string): boolean;
|
|
217
|
+
//#endregion
|
|
208
218
|
//#region src/context-source.d.ts
|
|
209
219
|
interface ContextSource {
|
|
210
220
|
/** 本源的唯一标识。重复注册→覆盖前一次同 id 源。 */
|
|
@@ -252,10 +262,6 @@ declare class ContextSourceRegistry {
|
|
|
252
262
|
sealAndBuildHooks(workspaceDir?: string, memory?: ContextBuildInput['memory']): HookSpec[];
|
|
253
263
|
}
|
|
254
264
|
//#endregion
|
|
255
|
-
//#region src/session/semantic-reviewer.d.ts
|
|
256
|
-
type SemanticReviewerVerdict = 'allow' | 'deny' | 'abstain';
|
|
257
|
-
type SemanticReviewer = (toolName: string, args: Record<string, unknown>, description: string, risk?: ApprovalRisk) => Promise<SemanticReviewerVerdict>;
|
|
258
|
-
//#endregion
|
|
259
265
|
//#region src/context-sources/memory-delta.d.ts
|
|
260
266
|
/**
|
|
261
267
|
* memory-delta(#3 volatile memory delta)
|
|
@@ -332,6 +338,11 @@ interface MemorySubsystem extends MemoryPort$1, ContextInjectionPort, MemoryDelt
|
|
|
332
338
|
* 经过宿主完整解析后的 session 配置。
|
|
333
339
|
* 所有业务字段均已确定,无需再做 merge。
|
|
334
340
|
* Manager 层只接受此类型来创建 session,不持有业务默认值。
|
|
341
|
+
*
|
|
342
|
+
* RFC-394 D2/R1:这是配置链的**唯一真源**。AgentSessionOptions 从本类型派生
|
|
343
|
+
* (`SessionConfigSubset`),AgentConfig 从 Options 映射,PersistedSessionConfig
|
|
344
|
+
* 从字段元数据(`PERSISTABLE_CONFIG_FIELDS`)生成——新增字段只改此处,编译器
|
|
345
|
+
* 自动传播,消灭手抄映射清单(此前 4 次漏传事故的根因)。
|
|
335
346
|
*/
|
|
336
347
|
interface ResolvedSessionConfig {
|
|
337
348
|
model: Model;
|
|
@@ -369,6 +380,11 @@ interface ResolvedSessionConfig {
|
|
|
369
380
|
stallDetection?: {
|
|
370
381
|
windowTurns?: number;
|
|
371
382
|
repeatThreshold?: number;
|
|
383
|
+
emptyTurnThreshold?: number;
|
|
384
|
+
} | false;
|
|
385
|
+
/** RFC-385 D1:首轮空转检测。缺省启用(走 ENGINE_DEFAULTS.idleTurnMaxTextChars);`false` 显式关闭。 */
|
|
386
|
+
idleTurnDetection?: {
|
|
387
|
+
maxTextChars?: number;
|
|
372
388
|
} | false;
|
|
373
389
|
/** RFC-204 D1/D2:会话累计成本软预算(美元)。缺省 = 不启用检测。 */
|
|
374
390
|
sessionCostBudgetUSD?: number;
|
|
@@ -418,7 +434,27 @@ interface ResolvedSessionConfig {
|
|
|
418
434
|
*/
|
|
419
435
|
describeImages?: DescribeImagesPort;
|
|
420
436
|
}
|
|
421
|
-
|
|
437
|
+
/**
|
|
438
|
+
* RFC-394 D2/R1:从 ResolvedSessionConfig 派生到 AgentSessionOptions 的会话配置子集。
|
|
439
|
+
*
|
|
440
|
+
* 这 27 个字段是 ResolvedSessionConfig 中**同时出现在 AgentSessionOptions 里**的字段——
|
|
441
|
+
* 此前逐字段手抄(buildAgentSession:461+),现用 Pick 派生,增删只改 ResolvedSessionConfig
|
|
442
|
+
* 一处,编译器自动传播到 Options。AgentSessionOptions = SessionConfigSubset & InfrastructurePorts。
|
|
443
|
+
*
|
|
444
|
+
* 不在此子集的字段(permissionAlwaysAllow / availableModels)是会话级权限/模型集合,
|
|
445
|
+
* 不传给 AgentSession 构造(由 SessionPool 直接读写 configs Map)。
|
|
446
|
+
*/
|
|
447
|
+
type SessionConfigSubset = Pick<ResolvedSessionConfig, 'model' | 'titleModel' | 'modelResolution' | 'agentName' | 'systemPrompt' | 'systemTail' | 'tools' | 'thinkingLevel' | 'maxToolTurns' | 'maxToolTurnExtensions' | 'promptOutputTokenBudget' | 'promptWallClockBudgetMs' | 'stallDetection' | 'idleTurnDetection' | 'sessionCostBudgetUSD' | 'todoContinuation' | 'promptRefresh' | 'workspaceDir' | 'workspaceId' | 'transient' | 'depth' | 'interactive' | 'listable' | 'retryAccelerate' | 'streamRetry' | 'networkDisconnectRetry' | 'lifecycleAsyncTimeoutMs' | 'describeImages'>;
|
|
448
|
+
/**
|
|
449
|
+
* RFC-394 D2/R1:AgentSessionOptions = SessionConfigSubset(从 ResolvedSessionConfig 派生)
|
|
450
|
+
* + InfrastructurePorts(运行时注入的基础设施端口)。
|
|
451
|
+
*
|
|
452
|
+
* 此前 AgentSessionOptions 是 42 字段的独立 interface,27 个字段与 ResolvedSessionConfig
|
|
453
|
+
* 逐字段手抄重复——现用 Pick 派生消灭手抄。新增 ResolvedSessionConfig 字段时,
|
|
454
|
+
* SessionConfigSubset 自动跟随(如需传入 AgentSession),编译器报错提示遗漏。
|
|
455
|
+
*/
|
|
456
|
+
interface AgentSessionOptions extends SessionConfigSubset {
|
|
457
|
+
/** 会话 id(仅 createSession 路径可选注入)。 */
|
|
422
458
|
id?: string;
|
|
423
459
|
/**
|
|
424
460
|
* RFC-324 D1/R5:turn-gated 压缩的超时兜底(毫秒)惰性读数。
|
|
@@ -428,98 +464,29 @@ interface AgentSessionOptions {
|
|
|
428
464
|
* 未注入时回退 `SESSION_COMPACTION_TIMEOUT_MS`(其本身已含 env 覆盖)。
|
|
429
465
|
*/
|
|
430
466
|
getCompactionTimeoutMs?: () => number | undefined;
|
|
431
|
-
model: Model;
|
|
432
|
-
/** 模型决策溯源(为何选中此 model)——透传给观测层供 inspector 显示。 */
|
|
433
|
-
modelResolution?: ModelResolution;
|
|
434
|
-
agentName?: string;
|
|
435
|
-
systemPrompt?: string;
|
|
436
|
-
/** 会话恒定的 volatile system 尾段种子(append 子代理角色块等);透传至 PromptParams.systemTail。 */
|
|
437
|
-
systemTail?: string[];
|
|
438
|
-
tools?: AgentTool[];
|
|
439
|
-
thinkingLevel?: ThinkingLevel;
|
|
440
|
-
maxToolTurns?: number;
|
|
441
|
-
maxToolTurnExtensions?: number;
|
|
442
|
-
/** RFC-104 D3:per-prompt output-token 预算(AgentSessionOptions 透传面)。 */
|
|
443
|
-
promptOutputTokenBudget?: number;
|
|
444
|
-
/** RFC-104 D3:per-prompt 墙钟预算(ms)。 */
|
|
445
|
-
promptWallClockBudgetMs?: number;
|
|
446
467
|
/** RFC-104 D2 缺省:顶层默认开、子 agent 默认关;OTTO_BUDGET_STEER_WRAPUP=1/0 覆盖。 */
|
|
447
468
|
budgetSteerWrapUp?: boolean;
|
|
448
|
-
/**
|
|
449
|
-
* RFC-203/RFC-204 D4:早期停滞检测配置透传(第三层,此前 AgentConfig/agent.ts 两层
|
|
450
|
-
* 断链已在 RFC-204 M2 修复)。缺省启用(走 ENGINE_DEFAULTS);`false` 显式关闭。
|
|
451
|
-
*/
|
|
452
|
-
stallDetection?: {
|
|
453
|
-
windowTurns?: number;
|
|
454
|
-
repeatThreshold?: number;
|
|
455
|
-
} | false;
|
|
456
|
-
/**
|
|
457
|
-
* RFC-204 D1/D2:会话累计成本软预算(美元)。超过阈值时一次性 emit
|
|
458
|
-
* `session.cost-budget-exceeded`(不阻断)。缺省 = 不启用预算检测。
|
|
459
|
-
*/
|
|
460
|
-
sessionCostBudgetUSD?: number;
|
|
461
|
-
/**
|
|
462
|
-
* RFC-094:todo 停机闭环硬闸——prompt 结束后若 todoList 仍有未完成项,自动续跑(cap 轮内)。
|
|
463
|
-
* 缺省从 OTTO_TODO_CONTINUE / OTTO_TODO_CONTINUE_MAX 解析(默认开、cap=3);depth>0 恒不启闸。
|
|
464
|
-
*/
|
|
465
|
-
todoContinuation?: {
|
|
466
|
-
enabled: boolean;
|
|
467
|
-
max: number;
|
|
468
|
-
};
|
|
469
|
-
workspaceDir?: string;
|
|
470
|
-
/** workspace 逻辑标识(`workspaceRef.id`),按 workspace 过滤会话列表时使用。 */
|
|
471
|
-
workspaceId?: string;
|
|
472
|
-
transient?: boolean;
|
|
473
469
|
hookRegistry: HookRegistry;
|
|
474
|
-
stream: StreamFunction;
|
|
475
|
-
/**
|
|
476
|
-
* RFC-078 M134:标题生成用的便宜模型(app 层经 RFC-061 `category:'search'` + usability gate 解析)。
|
|
477
|
-
* 缺省 → 不启用 LLM 标题生成(仅保留 derived 启发式占位)。禁用对话模型/claude-OAuth(R3)。
|
|
478
|
-
*/
|
|
479
|
-
titleModel?: Model;
|
|
470
|
+
stream: StreamFunction$1;
|
|
480
471
|
logger: Logger;
|
|
481
472
|
devtools?: Devtools;
|
|
482
|
-
promptRefresh?: PromptRefresh;
|
|
483
473
|
memory?: MemoryPort;
|
|
484
474
|
recorder?: TraceRecorder;
|
|
485
475
|
/** RFC-145 D3:nondet batch 冲洗回调(透传给 Agent → work-loop)。缺省 = 不聚合。 */
|
|
486
476
|
nondetFlush?: () => void;
|
|
487
477
|
clock?: ClockPort;
|
|
488
|
-
depth?: number;
|
|
489
478
|
/**
|
|
490
479
|
* RFC-371 M-A:父任务锚点(任务树语义)。orchestrator 委派子会话时注入
|
|
491
480
|
* `RunSessionOptions.parentTaskId`,透传 Agent → ToolExecutor → 工具上下文 →
|
|
492
481
|
* task_delegate/agent_call → orchestrator per-parent fan-out 闸。undefined = root 层。
|
|
493
482
|
*/
|
|
494
483
|
parentTaskId?: string;
|
|
495
|
-
interactive?: boolean;
|
|
496
484
|
/**
|
|
497
485
|
* RFC-380 T4:LLM 语义审批层(opt-in)。仅升级审批(sandbox-denied escalate ask)
|
|
498
486
|
* 且配置时生效;allow/deny 自动裁决(宿主侧需消费 approval.required 的
|
|
499
487
|
* semanticVerdict 记命令 bypass),abstain/未配置 → 既有用户弹窗流程。
|
|
500
488
|
*/
|
|
501
489
|
semanticReviewer?: SemanticReviewer;
|
|
502
|
-
/**
|
|
503
|
-
* 是否在 `/resume` 列表中可见(缺省 = 可见)。`false` 用于 headless 一次性内部会话
|
|
504
|
-
* (`otto --print/--json`)——照常落盘(sessionId/trace 有外部契约消费方),但不进列表。
|
|
505
|
-
* 详见 `PersistedSessionConfig.listable`。
|
|
506
|
-
*/
|
|
507
|
-
listable?: boolean;
|
|
508
|
-
retryAccelerate?: {
|
|
509
|
-
skip: boolean;
|
|
510
|
-
};
|
|
511
|
-
/** RFC-230:流式重试策略投影,见 `ResolvedSessionConfig.streamRetry` 同名字段注释。 */
|
|
512
|
-
streamRetry?: StreamRetryConfig;
|
|
513
|
-
/** RFC-230:网络断连重试策略投影,见 `ResolvedSessionConfig.networkDisconnectRetry` 同名字段注释。 */
|
|
514
|
-
networkDisconnectRetry?: StreamRetryConfig;
|
|
515
|
-
/** RFC-366:lifecycleAsync 挂死兜底超时(毫秒),见 `ResolvedSessionConfig.lifecycleAsyncTimeoutMs` 同名字段注释。 */
|
|
516
|
-
lifecycleAsyncTimeoutMs?: number;
|
|
517
|
-
/**
|
|
518
|
-
* RFC-181 D3/M3:图像委托描述端口(宿主 VisionDelegateService 实现,coding 层在会话
|
|
519
|
-
* 装配时注入)。缺省 = 主模型不支持视觉时,image block 降级为占位文本(见
|
|
520
|
-
* @x-otto/agent 的 vision-gate.ts 完整设计说明)。
|
|
521
|
-
*/
|
|
522
|
-
describeImages?: DescribeImagesPort;
|
|
523
490
|
}
|
|
524
491
|
interface AgentSessionInfo {
|
|
525
492
|
id: string;
|
|
@@ -583,7 +550,7 @@ declare function resolveTodoContinuationConfig(env: {
|
|
|
583
550
|
max: number;
|
|
584
551
|
};
|
|
585
552
|
declare class AgentSession extends EventBus<AgentSessionEventMap> {
|
|
586
|
-
readonly session: Session<AgentMessage
|
|
553
|
+
readonly session: Session<AgentMessage> & SessionPanelState;
|
|
587
554
|
readonly workspaceDir: string;
|
|
588
555
|
readonly workspaceId?: string;
|
|
589
556
|
private agent;
|
|
@@ -614,13 +581,67 @@ declare class AgentSession extends EventBus<AgentSessionEventMap> {
|
|
|
614
581
|
}> | undefined;
|
|
615
582
|
/** RFC-324 D1/R5:turn-gate 超时兜底的惰性读数(见 AgentSessionOptions 同名字段)。 */
|
|
616
583
|
private readonly getCompactionTimeoutMs?;
|
|
617
|
-
|
|
584
|
+
private _model;
|
|
618
585
|
/** 模型决策溯源(哪层选中 + 拒了谁)——供 task-runner 透传观测层。 */
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
586
|
+
private _modelResolution?;
|
|
587
|
+
private _tools;
|
|
588
|
+
private _systemPrompt;
|
|
622
589
|
/** 会话恒定的 volatile system 尾段种子(append 子代理角色块等);透传至每轮 PromptParams.systemTail。 */
|
|
623
|
-
|
|
590
|
+
private _systemTail?;
|
|
591
|
+
private _maxToolTurns;
|
|
592
|
+
private _maxToolTurnExtensions;
|
|
593
|
+
/** RFC-104 D3:per-prompt 预算(fork 拷贝面;depth>0 构造时已被剥除)。 */
|
|
594
|
+
private _promptOutputTokenBudget?;
|
|
595
|
+
private _promptWallClockBudgetMs?;
|
|
596
|
+
private _thinkingLevel;
|
|
597
|
+
private _promptRefresh?;
|
|
598
|
+
/** 公开只读——模型。写操作走 applyModel()。 */
|
|
599
|
+
get model(): Model;
|
|
600
|
+
get modelResolution(): ModelResolution | undefined;
|
|
601
|
+
get tools(): AgentTool[];
|
|
602
|
+
get systemPrompt(): string;
|
|
603
|
+
get systemTail(): string[] | undefined;
|
|
604
|
+
get maxToolTurns(): number;
|
|
605
|
+
get maxToolTurnExtensions(): number;
|
|
606
|
+
get promptOutputTokenBudget(): number | undefined;
|
|
607
|
+
get promptWallClockBudgetMs(): number | undefined;
|
|
608
|
+
get thinkingLevel(): ThinkingLevel;
|
|
609
|
+
get promptRefresh(): PromptRefresh | undefined;
|
|
610
|
+
/** RFC-394 D4/R4:显式 apply 方法——外部写运行时状态的唯一入口。 */
|
|
611
|
+
applyModel(model: Model, resolution?: ModelResolution): void;
|
|
612
|
+
/**
|
|
613
|
+
* RFC-446 M3(D3):模型切换 + 上下文窗口适配的统一语义入口。
|
|
614
|
+
*
|
|
615
|
+
* 背景:模型切换在 CLI /model、engine 子进程、FrontendPort(web-ui/远端)、HTTP API、
|
|
616
|
+
* 启动期初始化五条路径上行为不一致——只有 CLI 做了窗口适配(reconfigure + ensureFitsWindow
|
|
617
|
+
* 主动压缩),其余只写模型字段,超量历史留到下一轮请求才被反应式压缩救回。
|
|
618
|
+
*
|
|
619
|
+
* 本方法把「切换 + 适配」下沉到 AgentSession 自身(this.memory 与 app.storage.memory 同源,
|
|
620
|
+
* 由 session-pool-factory 构造注入),各路径调用后行为自动一致,新增入口自动继承。
|
|
621
|
+
* 同步 applyModel 保持不动(14 处纯设置调用点,含同步上下文)。
|
|
622
|
+
*
|
|
623
|
+
* 返回值:compacted=true 表示触发压缩(调用方应 toast 告知用户),false 表示无需压缩。
|
|
624
|
+
* compacted 时携带 summary/replacement(调用方可能需要跨进程转发——CLI 侧向 engine
|
|
625
|
+
* 子进程转发真实压缩数据,engine 只写回不重复压缩,避免双进程压缩竞态)。
|
|
626
|
+
* 压缩结果已写回本 session 树(recordCompaction),后续 buildContext 直接读到压缩后的消息。
|
|
627
|
+
*
|
|
628
|
+
* 设计取舍(RFC §D3):不 fire-and-forget——压缩是 async 且可能调 LLM,调用方必须
|
|
629
|
+
* await 完成才能保证"切换后上下文一致",失败时抛错由调用方决定是否阻断切换。
|
|
630
|
+
*/
|
|
631
|
+
applyModelWithContextFit(model: Model, resolution?: ModelResolution): Promise<{
|
|
632
|
+
compacted: boolean;
|
|
633
|
+
summary?: string;
|
|
634
|
+
replacement?: unknown[];
|
|
635
|
+
}>;
|
|
636
|
+
applyThinkingLevel(level: ThinkingLevel): void;
|
|
637
|
+
applyTools(tools: AgentTool[]): void;
|
|
638
|
+
applySystemPrompt(prompt: string): void;
|
|
639
|
+
applyBudgets(opts: {
|
|
640
|
+
maxToolTurns?: number;
|
|
641
|
+
maxToolTurnExtensions?: number;
|
|
642
|
+
promptOutputTokenBudget?: number;
|
|
643
|
+
promptWallClockBudgetMs?: number;
|
|
644
|
+
}): void;
|
|
624
645
|
agentName: string;
|
|
625
646
|
depth: number;
|
|
626
647
|
/**
|
|
@@ -643,13 +664,6 @@ declare class AgentSession extends EventBus<AgentSessionEventMap> {
|
|
|
643
664
|
* 置 false —— 照常落盘但不进列表。详见 `PersistedSessionConfig.listable`。
|
|
644
665
|
*/
|
|
645
666
|
readonly listable: boolean;
|
|
646
|
-
maxToolTurns: number;
|
|
647
|
-
maxToolTurnExtensions: number;
|
|
648
|
-
/** RFC-104 D3:per-prompt 预算(fork 拷贝面;depth>0 构造时已被剥除)。 */
|
|
649
|
-
promptOutputTokenBudget?: number;
|
|
650
|
-
promptWallClockBudgetMs?: number;
|
|
651
|
-
thinkingLevel: ThinkingLevel;
|
|
652
|
-
promptRefresh?: PromptRefresh;
|
|
653
667
|
private logger;
|
|
654
668
|
private hookRegistry;
|
|
655
669
|
private devtools?;
|
|
@@ -731,7 +745,7 @@ declare class AgentSession extends EventBus<AgentSessionEventMap> {
|
|
|
731
745
|
systemPromptLength: number;
|
|
732
746
|
tools: string[];
|
|
733
747
|
};
|
|
734
|
-
constructor(session: Session<AgentMessage
|
|
748
|
+
constructor(session: Session<AgentMessage> & SessionPanelState, options: AgentSessionOptions);
|
|
735
749
|
/**
|
|
736
750
|
* 由 SessionPool / 宿主类在 session.created hook 执行完毕后调用。
|
|
737
751
|
* 此时 EventBridge 已完成订阅,session.start 事件可被正确接收。
|
|
@@ -848,6 +862,25 @@ declare class AgentSession extends EventBus<AgentSessionEventMap> {
|
|
|
848
862
|
renameSession(title: string): void;
|
|
849
863
|
/** H5-20:本会话累计用量 + 成本汇总(供 /cost 命令 / TUI 状态栏消费)。 */
|
|
850
864
|
getCostSummary(): CostSummary;
|
|
865
|
+
/**
|
|
866
|
+
* RFC-390 D2:最近一轮的 uncached input token(RFC-411 修正口径标注)。
|
|
867
|
+
* **口径事实(RFC-411)**:`usage.inputTokens` 是 provider 分桶中的 uncached 部分,
|
|
868
|
+
* **不含 cacheRead/cacheWrite 前缀**(三分桶铁证 packages/ai/src/cache-hit-rate.ts:75
|
|
869
|
+
* totalInput = cacheRead + cacheWrite + inputTokens)——它不是"当前上下文占用"。
|
|
870
|
+
* RFC-390 D2 原注释"total 口径含 cache 前缀"是错误标签,已废止(见 RFC-411 执行摘要)。
|
|
871
|
+
* 供 memory-manager 的 `getRealInputTokens` 惰性端口消费——空响应轮 `record()` 跳过时
|
|
872
|
+
* 值停留在上一轮。undefined = 本会话尚无 usage(首次请求前)。
|
|
873
|
+
* (RealInputPolicy 因该口径低估从"补漏"退化为近乎恒不触发,坐标换算修正 defer 至
|
|
874
|
+
* memory 包独立 RFC——TokenPressurePolicy 真实估算仍是主力防线。)
|
|
875
|
+
*/
|
|
876
|
+
getLastInputTokens(): number | undefined;
|
|
877
|
+
/**
|
|
878
|
+
* RFC-434 D2:上一轮请求的 **total 口径** input(`cacheRead + cacheWrite + inputTokens`)
|
|
879
|
+
* ——"上下文实际有多大"的 provider 权威读数。供 memory-manager 的 `getRealInputTokens`
|
|
880
|
+
* 端口消费,取代原先错用的 `getLastInputTokens`(uncached-only,见 RFC-411 口径定性)。
|
|
881
|
+
* `undefined` = 本会话尚无 usage。
|
|
882
|
+
*/
|
|
883
|
+
getLastTotalInputTokens(): number | undefined;
|
|
851
884
|
/**
|
|
852
885
|
* RFC-019 M1:最近一回合的缓存命中率(R1)。`null` = 供应商无缓存 API 或本回合无 usage 数据
|
|
853
886
|
* ——消费方应据此隐藏该字段,而非展示误导性的 0。供 `/cache-stats`、summary 行消费。
|
|
@@ -1107,6 +1140,9 @@ declare class PanelStateStore {
|
|
|
1107
1140
|
/**
|
|
1108
1141
|
* 批量加载——直接返回 `PanelStateSnapshot`,供 persistence-sync 恢复/迁移路径使用。
|
|
1109
1142
|
* 比分别调用 4 次 get 方法更高效(一次 load 而非四次)。
|
|
1143
|
+
*
|
|
1144
|
+
* RFC-393 M4:版本门——读出的 `ver` 不匹配 `PANEL_STATE_VER` 时废弃旧 checkpoint
|
|
1145
|
+
* (返回 null,触发全量重读/迁移兜底)。缺省(旧数据无 ver)= 0,自动废弃。
|
|
1110
1146
|
*/
|
|
1111
1147
|
loadAll(sessionId: string): Promise<PanelStateSnapshot | null>;
|
|
1112
1148
|
/**
|
|
@@ -1157,6 +1193,42 @@ declare class ResidencyGovernor {
|
|
|
1157
1193
|
}
|
|
1158
1194
|
//#endregion
|
|
1159
1195
|
//#region src/session/session-manager.d.ts
|
|
1196
|
+
/**
|
|
1197
|
+
* RFC-394 D3/R2:后端能力 seam——收敛此前散装旋钮为结构化能力接口。
|
|
1198
|
+
*
|
|
1199
|
+
* 此前 SessionPoolOptions 有 5 个后端能力旋钮(isSessionWriteLocked /
|
|
1200
|
+
* inspectSessionWriteLease / forceReleaseSessionWriteLease / listColdSessionsOverride /
|
|
1201
|
+
* panelStateStore),每个都是"未注入即降级"的独立可选字段。现在收敛为 2 个
|
|
1202
|
+
* 能力接口对象,由持久化后端自声明(复用 supportsArchive 式能力探测惯例)。
|
|
1203
|
+
*
|
|
1204
|
+
* residencyGovernor / getResidencyConfig / planeRegistry 不是后端能力旋钮
|
|
1205
|
+
* (它们是跨模块基础设施注入——内存治理信号源/双平面注册表),保留为显式注入。
|
|
1206
|
+
*/
|
|
1207
|
+
/**
|
|
1208
|
+
* 写租约管理能力——合并此前 3 个散装旋钮(isSessionWriteLocked /
|
|
1209
|
+
* inspectSessionWriteLease / forceReleaseSessionWriteLease)。
|
|
1210
|
+
*
|
|
1211
|
+
* 由本地 SQLite 后端注入(SessionWriteLeaseManager 的薄封装);
|
|
1212
|
+
* 远端/内存后端无租约机制,不注入(行为与迁移前一致)。
|
|
1213
|
+
*/
|
|
1214
|
+
interface WriteLeaseManager {
|
|
1215
|
+
/** 某会话当前是否被**另一存活进程**持有写租约(无副作用,不 acquire)。 */
|
|
1216
|
+
isLockedByOther(sessionId: string): boolean;
|
|
1217
|
+
/** 写租约只读诊断(持有者 pid/hostname/存活性/mtime 距今)。 */
|
|
1218
|
+
inspect(sessionId: string): _$_x_otto_session0.LeaseInspection;
|
|
1219
|
+
/** 强制释放写租约(跳过 token 实核,仅供用户主动 /session unlock --force)。 */
|
|
1220
|
+
forceRelease(sessionId: string): void;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* 冷会话枚举能力——收敛此前 listColdSessionsOverride 散装旋钮。
|
|
1224
|
+
*
|
|
1225
|
+
* 由本地 SQLite 后端注入(SqliteSessionRepository 单次 SQL 查询);
|
|
1226
|
+
* 远端后端不注入,缺省走 listPaginated+load 兜底路径。
|
|
1227
|
+
*/
|
|
1228
|
+
interface ColdSessionLister {
|
|
1229
|
+
/** 枚举持久化后端已知但未必已加载进内存的冷会话(本地高效 SQL / 远端兜底分页)。 */
|
|
1230
|
+
listColdSessions(workspaceKey: string): Promise<AgentSessionInfo[]>;
|
|
1231
|
+
}
|
|
1160
1232
|
/**
|
|
1161
1233
|
* Manager 只持有基础设施配置(持久化、网络、日志)。
|
|
1162
1234
|
* 业务配置(model、systemPrompt、tools 等)由宿主(coding/第二宿主)解析后
|
|
@@ -1233,37 +1305,20 @@ interface SessionPoolOptions {
|
|
|
1233
1305
|
*/
|
|
1234
1306
|
planeRegistry?: HostRegistry;
|
|
1235
1307
|
/**
|
|
1236
|
-
* RFC-
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
* `SessionPool` 只判断"策略是否已注入",不感知底层是什么仓储实现——
|
|
1242
|
-
* 消灭对具体仓储类型的依赖(见 RFC-146 §6b「sessionRepoRef 迁移策略」)。
|
|
1243
|
-
*/
|
|
1244
|
-
listColdSessionsOverride?: (workspaceKey: string) => Promise<AgentSessionInfo[]>;
|
|
1245
|
-
/**
|
|
1246
|
-
* 只读探测(可选注入):某会话当前是否被**另一存活进程**持有写租约(RFC-159 D3
|
|
1247
|
-
* SessionWriteLeaseManager.peekLockedByOther 的薄封装,无副作用)。仅本地 SQLite 后端
|
|
1248
|
-
* 注入(`session-pool-factory.ts`);未注入时 `listSessions`/`listAllPersistedSessions`
|
|
1249
|
-
* 恒不标注只读(远端/内存后端无租约机制,行为与迁移前一致)。用于 `/resume` 列表
|
|
1250
|
-
* 提前展示"切进去会是只读",而非等到真正 save 被拒才事后感知。
|
|
1308
|
+
* RFC-394 D3/R2:后端能力 seam——收敛此前 5 个散装旋钮(listColdSessionsOverride /
|
|
1309
|
+
* isSessionWriteLocked / inspectSessionWriteLease / forceReleaseSessionWriteLease /
|
|
1310
|
+
* panelStateStore 的后端注入面)为 2 个能力接口。由持久化后端自声明注入;
|
|
1311
|
+
* 未注入时各方法走降级路径(行为与迁移前一致)。新后端能力走"能力接口 + 自声明"
|
|
1312
|
+
* 模式,禁止在 SessionPoolOptions 新增散装旋钮(R2)。
|
|
1251
1313
|
*/
|
|
1252
|
-
|
|
1314
|
+
writeLeaseManager?: WriteLeaseManager;
|
|
1315
|
+
coldSessionLister?: ColdSessionLister;
|
|
1253
1316
|
/**
|
|
1254
|
-
* RFC-
|
|
1255
|
-
*
|
|
1256
|
-
*
|
|
1317
|
+
* RFC-380 T4:LLM 语义审批层(opt-in)——app 级共享,透传给每个 AgentSession。
|
|
1318
|
+
* 仅升级审批(description 含 [sandbox-escalation])触发;allow/deny 自动裁决,
|
|
1319
|
+
* abstain/未注入 → 既有用户弹窗流程(行为不变)。fail-closed 语义见 semantic-reviewer.ts。
|
|
1257
1320
|
*/
|
|
1258
|
-
|
|
1259
|
-
/**
|
|
1260
|
-
* RFC-171 D4:强制释放写租约(可选注入)——`SessionWriteLeaseManager.forceRelease` 的
|
|
1261
|
-
* 薄封装。跳过 token 实核,仅供用户主动触发的 `/session unlock --force` 使用。
|
|
1262
|
-
*/
|
|
1263
|
-
forceReleaseSessionWriteLease?: (sessionId: string) => void;
|
|
1264
|
-
}
|
|
1265
|
-
interface DiskSessionPoolOptions extends SessionPoolOptions {
|
|
1266
|
-
sessionDir: string;
|
|
1321
|
+
semanticReviewer?: SemanticReviewer;
|
|
1267
1322
|
}
|
|
1268
1323
|
interface RemoteSessionPoolOptions extends SessionPoolOptions {
|
|
1269
1324
|
sessionUrl: string;
|
|
@@ -1286,7 +1341,7 @@ interface SessionPorts {
|
|
|
1286
1341
|
recorder?: TraceRecorder;
|
|
1287
1342
|
/** RFC-145 D3:nondet batch 冲洗回调(RecordingPorts.flushNondetBatch)。缺省 = 不聚合。 */
|
|
1288
1343
|
nondetFlush?: () => void;
|
|
1289
|
-
stream?: StreamFunction;
|
|
1344
|
+
stream?: StreamFunction$1;
|
|
1290
1345
|
tools?: AgentTool[];
|
|
1291
1346
|
disableMemory?: boolean;
|
|
1292
1347
|
}
|
|
@@ -1320,7 +1375,7 @@ declare class SessionPool {
|
|
|
1320
1375
|
private readonly idleTimeoutMs;
|
|
1321
1376
|
private readonly threshold;
|
|
1322
1377
|
private activeSessionId?;
|
|
1323
|
-
readonly stream: StreamFunction;
|
|
1378
|
+
readonly stream: StreamFunction$1;
|
|
1324
1379
|
private readonly hookRegistry;
|
|
1325
1380
|
private readonly logger;
|
|
1326
1381
|
private readonly devtools?;
|
|
@@ -1335,13 +1390,11 @@ declare class SessionPool {
|
|
|
1335
1390
|
/** RFC-327 修订 D2(M2):双平面注册边界——会话格派生/清理的宿主注册表(可选)。 */
|
|
1336
1391
|
private readonly planeRegistry?;
|
|
1337
1392
|
private readonly configProvider?;
|
|
1338
|
-
/** RFC-
|
|
1339
|
-
private readonly
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
private readonly inspectSessionWriteLeaseFn?;
|
|
1344
|
-
private readonly forceReleaseSessionWriteLeaseFn?;
|
|
1393
|
+
/** RFC-394 D3:后端能力 seam(收敛此前 5 个散装旋钮)。 */
|
|
1394
|
+
private readonly writeLeaseManager?;
|
|
1395
|
+
private readonly coldSessionLister?;
|
|
1396
|
+
/** RFC-380 T4:LLM 语义审批层(opt-in)——透传给每个 buildAgentSession。 */
|
|
1397
|
+
private readonly semanticReviewer?;
|
|
1345
1398
|
/**
|
|
1346
1399
|
* 持久化是否为「自动行为」。disk/remote 后端 = true(prompt 终态增量落盘 +
|
|
1347
1400
|
* 宿主 start/stop 自动 restoreAll/saveAll);in-memory 缺省 = false(行为与历史一致,
|
|
@@ -1539,16 +1592,12 @@ declare class SessionPool {
|
|
|
1539
1592
|
private canAccommodate;
|
|
1540
1593
|
dispose(): void;
|
|
1541
1594
|
}
|
|
1542
|
-
declare function createDiskSessionPool(options: DiskSessionPoolOptions): SessionPool;
|
|
1543
1595
|
declare function createRemoteSessionPool(options: RemoteSessionPoolOptions): SessionPool;
|
|
1544
1596
|
declare function createInMemorySessionPool(options: SessionPoolOptions): SessionPool;
|
|
1545
1597
|
//#endregion
|
|
1546
1598
|
//#region src/create-agent-runtime.d.ts
|
|
1547
1599
|
type SessionStorageConfig = {
|
|
1548
1600
|
kind: 'in-memory';
|
|
1549
|
-
} | {
|
|
1550
|
-
kind: 'disk';
|
|
1551
|
-
sessionDir: string;
|
|
1552
1601
|
} | {
|
|
1553
1602
|
kind: 'remote';
|
|
1554
1603
|
sessionUrl: string;
|
|
@@ -1573,22 +1622,12 @@ type SessionStorageConfig = {
|
|
|
1573
1622
|
autoPersist?: boolean; /** 后端专属资源释放(如 SqliteSessionRepository.close());dispose 时在 sessions.dispose 后调用。 */
|
|
1574
1623
|
onDispose?: () => void | Promise<void>;
|
|
1575
1624
|
/**
|
|
1576
|
-
* RFC-
|
|
1577
|
-
*
|
|
1578
|
-
*
|
|
1625
|
+
* RFC-394 D3/R2:后端能力 seam——收敛此前 4 个散装透传字段
|
|
1626
|
+
* (listColdSessionsOverride / isSessionWriteLocked / inspectSessionWriteLease /
|
|
1627
|
+
* forceReleaseSessionWriteLease)为 2 个能力接口。由后端自声明注入。
|
|
1579
1628
|
*/
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
* 只读探测策略透传(见 SessionPoolOptions.isSessionWriteLocked)。关系化 SQLite 分支
|
|
1583
|
-
* 经此注入 SessionWriteLeaseManager.peekLockedByOther 的薄封装。
|
|
1584
|
-
*/
|
|
1585
|
-
isSessionWriteLocked?: (sessionId: string) => boolean;
|
|
1586
|
-
/**
|
|
1587
|
-
* RFC-171 D4:写租约诊断/强制释放策略透传(见 SessionPoolOptions 对应字段)。
|
|
1588
|
-
* 关系化 SQLite 分支经此注入 SessionWriteLeaseManager.inspect/forceRelease 的薄封装。
|
|
1589
|
-
*/
|
|
1590
|
-
inspectSessionWriteLease?: (sessionId: string) => LeaseInspection;
|
|
1591
|
-
forceReleaseSessionWriteLease?: (sessionId: string) => void;
|
|
1629
|
+
writeLeaseManager?: WriteLeaseManager;
|
|
1630
|
+
coldSessionLister?: ColdSessionLister;
|
|
1592
1631
|
/**
|
|
1593
1632
|
* RFC-108 D3 面板态(todoList/editedFiles/subagents/drafts)独立持久化的落盘目录。
|
|
1594
1633
|
* 2026-07-21 修复:`kind:'custom'`(coding 默认的关系化 SQLite 后端)此前不构造
|
|
@@ -1644,6 +1683,11 @@ interface RuntimeOptions {
|
|
|
1644
1683
|
* 未注入 = 会话格不派生(行为不变,宿主不接双平面即零影响)。
|
|
1645
1684
|
*/
|
|
1646
1685
|
planeRegistry?: HostRegistry;
|
|
1686
|
+
/**
|
|
1687
|
+
* RFC-380 T4:LLM 语义审批层(opt-in)。注入后仅升级审批(sandbox-denied escalate ask)
|
|
1688
|
+
* 触发;allow/deny 自动裁决,abstain/未注入 → 既有用户弹窗流程(行为不变)。
|
|
1689
|
+
*/
|
|
1690
|
+
semanticReviewer?: SemanticReviewer;
|
|
1647
1691
|
}
|
|
1648
1692
|
interface AgentRuntime {
|
|
1649
1693
|
/** 统一派生入口:子 runtime / 宿主 / swarm / task-runner 皆经此(§4-11)。 */
|
|
@@ -1654,7 +1698,7 @@ interface AgentRuntime {
|
|
|
1654
1698
|
readonly sessions: SessionPool;
|
|
1655
1699
|
readonly hookRegistry: HookRegistry;
|
|
1656
1700
|
/** 引擎 stream(从 providerRegistry 派生,§4-11:子 runtime 用之而非各自 createStreamFunction)。 */
|
|
1657
|
-
readonly stream: StreamFunction;
|
|
1701
|
+
readonly stream: StreamFunction$1;
|
|
1658
1702
|
/** ContextSource 有序注册表(D33):通用源已内置注册,coding 策略源由宿主追加。 */
|
|
1659
1703
|
readonly contextSources: ContextSourceRegistry;
|
|
1660
1704
|
readonly traceStore: AppendLog<TraceEvent>;
|
|
@@ -1667,7 +1711,7 @@ interface AgentRuntime {
|
|
|
1667
1711
|
* createAgentRuntime 内置调用之;宿主的离线装配路径(不经 createAgentRuntime)亦复用,
|
|
1668
1712
|
* 确保「App 经 rt.contextSources 构建注入 hooks」对所有后端一致——消灭 App 端的二次造表。
|
|
1669
1713
|
*/
|
|
1670
|
-
declare function createDefaultContextSourceRegistry(
|
|
1714
|
+
declare function createDefaultContextSourceRegistry(_workspaceDir: string, _memory?: MemorySubsystem): ContextSourceRegistry;
|
|
1671
1715
|
declare function createAgentRuntime(options?: RuntimeOptions): AgentRuntime;
|
|
1672
1716
|
//#endregion
|
|
1673
1717
|
//#region src/engine-stores.d.ts
|
|
@@ -2162,6 +2206,11 @@ interface ProcessSpawnConfig {
|
|
|
2162
2206
|
*/
|
|
2163
2207
|
env?: Record<string, string>;
|
|
2164
2208
|
cwd?: string;
|
|
2209
|
+
/** RFC-394 M5:从 ProcessRegistry RegisterInput 收敛——输出落临时文件路径(bash 工具填)。 */
|
|
2210
|
+
logPath?: string;
|
|
2211
|
+
/** RFC-394 M5:从 ProcessRegistry RegisterInput 收敛——best-effort 嗅探端口/URL。 */
|
|
2212
|
+
port?: number;
|
|
2213
|
+
url?: string;
|
|
2165
2214
|
}
|
|
2166
2215
|
interface KillOptions {
|
|
2167
2216
|
graceMs?: number;
|
|
@@ -2185,6 +2234,22 @@ interface ManagedProcess {
|
|
|
2185
2234
|
readonly pgid: number | undefined;
|
|
2186
2235
|
readonly status: ProcessStatus;
|
|
2187
2236
|
readonly config: ProcessSpawnConfig;
|
|
2237
|
+
/** RFC-394 M5:便捷 getter(从 config 投影,消费方不用深挖 config.xxx)。 */
|
|
2238
|
+
readonly command: string;
|
|
2239
|
+
readonly cwd: string | undefined;
|
|
2240
|
+
readonly logPath: string | undefined;
|
|
2241
|
+
readonly port: number | undefined;
|
|
2242
|
+
readonly url: string | undefined;
|
|
2243
|
+
/** 进程启动时刻(spawn/register 时戳,注入时钟)。 */
|
|
2244
|
+
readonly startedAt: number;
|
|
2245
|
+
/** 退出码(未退出或被信号杀死为 undefined)。 */
|
|
2246
|
+
readonly exitCode: number | undefined;
|
|
2247
|
+
/**
|
|
2248
|
+
* RFC-223:运行时输出识别到的服务信息(url/port/protocol)。
|
|
2249
|
+
* 由 `ProcessRuntime.updateDetectedService` 按 D2 去重规则写入,供状态栏
|
|
2250
|
+
* 「服务」指示器与 ServicesDialog 消费。未识别到时为 undefined。
|
|
2251
|
+
*/
|
|
2252
|
+
readonly detectedService: DetectedService | undefined;
|
|
2188
2253
|
/** 原始字节流 stdin/stdout/stderr(规则 5/H2:非行缓冲,帧解析由消费者负责) */
|
|
2189
2254
|
readonly stdin: NodeJS.WritableStream | null;
|
|
2190
2255
|
readonly stdout: NodeJS.ReadableStream | null;
|
|
@@ -2227,6 +2292,18 @@ declare class ProcessRuntime {
|
|
|
2227
2292
|
get(id: string): ManagedProcess | undefined;
|
|
2228
2293
|
list(filter?: ProcessFilter): ManagedProcess[];
|
|
2229
2294
|
listForSession(sessionId: string): ManagedProcess[];
|
|
2295
|
+
/** RFC-394 M5:从 ProcessRegistry 收敛——按 sessionId+id 精确查找。 */
|
|
2296
|
+
getForSession(sessionId: string, id: string): ManagedProcess | undefined;
|
|
2297
|
+
/**
|
|
2298
|
+
* RFC-394 M5:从 ProcessRegistry 收敛——registry 级 kill(id)。
|
|
2299
|
+
* ProcessRuntime 的 kill 是实例方法(proc.kill()),此方法提供 registry 级入口。
|
|
2300
|
+
*/
|
|
2301
|
+
kill(id: string, opts?: KillOptions): Promise<void>;
|
|
2302
|
+
/**
|
|
2303
|
+
* RFC-394 M5:从 ProcessRegistry 收敛——更新已检测到的服务信息。
|
|
2304
|
+
* 用于 background bash 运行时输出识别到端口/URL 的场景(RFC-223)。
|
|
2305
|
+
*/
|
|
2306
|
+
updateDetectedService(id: string, service: DetectedService): void;
|
|
2230
2307
|
listForOwner(owner: ProcessOwner): ManagedProcess[];
|
|
2231
2308
|
touch(id: string): void;
|
|
2232
2309
|
remove(id: string): void;
|
|
@@ -2337,6 +2414,15 @@ declare function revertDiff(repoRoot: string, diff: string): ApplyDiffResult;
|
|
|
2337
2414
|
* 真实失败无声吞掉,运维完全无感知)。`onError` 缺省不传时行为与修复前一致(纯静默)。
|
|
2338
2415
|
*/
|
|
2339
2416
|
declare function removeWorktree(wt: Worktree, onError?: (op: 'worktree remove' | 'branch delete' | 'worktree prune', err: unknown) => void): void;
|
|
2417
|
+
/**
|
|
2418
|
+
* RFC-435 R8:扫描磁盘上存在的全部 job worktree id(跨进程 rehydrate 源)。
|
|
2419
|
+
*
|
|
2420
|
+
* 用与 pruneOrphanWorktrees 相同的筛选逻辑(tmpdir `otto-wt-*` 前缀 + `otto/job-*` branch),
|
|
2421
|
+
* 但**不删除任何东西**——只返回 jobId 集合。调用方(如 installAgentJobReaper)把本进程
|
|
2422
|
+
* 活跃集与此集合并后传给 pruneOrphanWorktrees,使"他进程(daemon/另一会话)创建的 job
|
|
2423
|
+
* worktree"不会被误判为孤儿销毁(R8:剪枝必须基于 rehydrate 后活跃集合)。
|
|
2424
|
+
*/
|
|
2425
|
+
declare function listWorktreeJobIds(repoRoot: string): string[];
|
|
2340
2426
|
/**
|
|
2341
2427
|
* 扫描并清理孤儿 worktree(SIGKILL/OOM 未走 exit reaper 留下的残留)。
|
|
2342
2428
|
* 用 `git -C repoRoot worktree list --porcelain` 列出该仓的全部已注册 worktree,
|
|
@@ -2459,6 +2545,45 @@ declare const DEFAULT_MAX_AUTO_APPLY_LINES = 200;
|
|
|
2459
2545
|
*/
|
|
2460
2546
|
declare function decideApply(signals: ApplySignals, policy: ApplyPolicy): Verdict;
|
|
2461
2547
|
//#endregion
|
|
2548
|
+
//#region src/job-state-store.d.ts
|
|
2549
|
+
/** 落盘条目(registry 内 job 的可序列化投影——不含 abort/worktree 活句柄)。 */
|
|
2550
|
+
interface JobStateEntry {
|
|
2551
|
+
id: string;
|
|
2552
|
+
sessionId: string;
|
|
2553
|
+
title: string;
|
|
2554
|
+
origin: string;
|
|
2555
|
+
status: AgentJobStatus;
|
|
2556
|
+
/** worktree 的 repoRoot(分区键 + rehydrate 过滤)。 */
|
|
2557
|
+
repoRoot: string;
|
|
2558
|
+
/** worktree 分支(rehydrate 后按此找 worktree 路径)。 */
|
|
2559
|
+
branch: string;
|
|
2560
|
+
/** worktree 的 tmpdir 路径(rehydrate 后 diff 惰性读靠它)。 */
|
|
2561
|
+
worktreePath: string;
|
|
2562
|
+
outputPath: string;
|
|
2563
|
+
startedAt: number;
|
|
2564
|
+
/** ready 后填(**不进 jsonl**——diff 惰性从 worktree 读,评审 R3)。 */
|
|
2565
|
+
diff?: string;
|
|
2566
|
+
error?: string;
|
|
2567
|
+
}
|
|
2568
|
+
/** 从 AgentSessionJob 投影为可序列化条目(不含 diff——R3)。 */
|
|
2569
|
+
declare function toJobStateEntry(job: AgentSessionJob): JobStateEntry;
|
|
2570
|
+
/** 构造分区文件路径(`${stateDir}/${repoRootHash}.jsonl`)。 */
|
|
2571
|
+
declare function jobStateFilePath(stateDir: string, repoRoot: string): string;
|
|
2572
|
+
/**
|
|
2573
|
+
* JobStateStore:append(同步单行)+ load(读全部 + 截断)。
|
|
2574
|
+
* 生命周期:app build 期创建一次,reaper 读与 registry 写共享同一实例(评审 P2-7)。
|
|
2575
|
+
*/
|
|
2576
|
+
declare class JobStateStore {
|
|
2577
|
+
private readonly stateDir;
|
|
2578
|
+
constructor(stateDir: string);
|
|
2579
|
+
/** 同步 append 单行(O_APPEND 单次 write 原子;与 update 同一 tick、notify 之前——R1)。 */
|
|
2580
|
+
append(entry: JobStateEntry): void;
|
|
2581
|
+
/** 读全部条目(按文件)。调用方按 repoRoot 过滤。 */
|
|
2582
|
+
load(): JobStateEntry[];
|
|
2583
|
+
/** remove/驱逐墓碑(评审 P1-5):从文件移除该 id 的行(重写;条目数小,可接受)。 */
|
|
2584
|
+
remove(id: string, repoRoot: string): void;
|
|
2585
|
+
}
|
|
2586
|
+
//#endregion
|
|
2462
2587
|
//#region src/agent-job-registry.d.ts
|
|
2463
2588
|
type AgentJobStatus = 'running' | 'needs_input' | 'ready' | 'applied' | 'failed' | 'canceled';
|
|
2464
2589
|
/**
|
|
@@ -2516,6 +2641,8 @@ declare class AgentJobRegistry {
|
|
|
2516
2641
|
private readonly maxJobs;
|
|
2517
2642
|
private readonly clock;
|
|
2518
2643
|
private onWorktreeCleanupError?;
|
|
2644
|
+
/** RFC-444:jsonl 影子 store(post-hoc setter 注入,模块级单例无构造注入先例)。 */
|
|
2645
|
+
private stateStore;
|
|
2519
2646
|
private readonly spawnListeners;
|
|
2520
2647
|
private readonly updateListeners;
|
|
2521
2648
|
private readonly exitListeners;
|
|
@@ -2527,6 +2654,11 @@ declare class AgentJobRegistry {
|
|
|
2527
2654
|
* 无法从 app 层注入 logger——app 装配阶段调用本方法一次即可后接。
|
|
2528
2655
|
*/
|
|
2529
2656
|
setWorktreeCleanupErrorHandler(handler: AgentJobRegistryOptions['onWorktreeCleanupError']): void;
|
|
2657
|
+
/**
|
|
2658
|
+
* RFC-444:接 jsonl 影子 store(app build 期调用一次;reaper 读与写共享同一实例,
|
|
2659
|
+
* 评审 P2-7)。未设置 = 不落盘(影子模式)。
|
|
2660
|
+
*/
|
|
2661
|
+
setStateStore(store: JobStateStore | undefined): void;
|
|
2530
2662
|
onSpawn(listener: AgentJobListener): () => void;
|
|
2531
2663
|
/** 状态/diff 变更(running→ready/needs_input 等)。 */
|
|
2532
2664
|
onUpdate(listener: AgentJobListener): () => void;
|
|
@@ -2545,6 +2677,14 @@ declare class AgentJobRegistry {
|
|
|
2545
2677
|
* 不是数据条目驱逐宽限)。
|
|
2546
2678
|
*/
|
|
2547
2679
|
retain(id: string, on: boolean): void;
|
|
2680
|
+
/**
|
|
2681
|
+
* RFC-444:静默恢复(rehydrate 用)——直接插 entries,**不触发 onSpawn/onUpdate/onExit**
|
|
2682
|
+
* (评审 P0-1:否则 InProcessEventTrigger 对恢复的终态记录虚假触发 schedule 事件)、
|
|
2683
|
+
* **不重放 append**(评审 P2-7:否则每次重启 jsonl 无限膨胀)。
|
|
2684
|
+
* 只恢复 ready/终态(R2:running/needs_input 进程死即失效,由 reaper 决策表跳过)。
|
|
2685
|
+
*/
|
|
2686
|
+
restore(entry: JobStateEntry): AgentSessionJob | undefined;
|
|
2687
|
+
private appendState;
|
|
2548
2688
|
private notify;
|
|
2549
2689
|
/**
|
|
2550
2690
|
* 登记作业。撞满上限时先驱逐已终态的;若全在跑则抛错(提示先 cancel)。
|
|
@@ -2587,8 +2727,22 @@ declare class AgentJobRegistry {
|
|
|
2587
2727
|
}
|
|
2588
2728
|
/** 进程级单例:宿主与作业服务共享。 */
|
|
2589
2729
|
declare const globalAgentJobRegistry: AgentJobRegistry;
|
|
2590
|
-
/**
|
|
2591
|
-
|
|
2730
|
+
/**
|
|
2731
|
+
* 安装宿主退出兜底:process.on('exit') → cleanupAll(清 worktree)。幂等。
|
|
2732
|
+
*
|
|
2733
|
+
* RFC-444:新增 rehydrate(跨进程可见的底座):
|
|
2734
|
+
* 1. **rehydrate**:读 jsonl 影子 → 按 repoRoot 过滤 → `registry.restore()` 静默恢复
|
|
2735
|
+
* ready/终态(不触发事件、不重放 append——评审 P0-1/P2-7)。
|
|
2736
|
+
* 2. **adopt-or-delete 五分支**(评审 P0-2/R7,取代 R8 的磁盘并集永久 no-op):
|
|
2737
|
+
* 对磁盘上每个 job worktree:
|
|
2738
|
+
* ① 有记录+ready+worktree 在 → adopt(restore 后自然在 registry)
|
|
2739
|
+
* ② 有记录+ready+worktree 不在 → adopt 但标 stale(diff 惰性读失败降级)
|
|
2740
|
+
* ③ 有记录+running/needs_input → 跳过(daemon 可能还活着,保 R8 并集保护)
|
|
2741
|
+
* ④ 有记录+terminal+worktree 在 → **删 worktree 留记录**(终态残留清理——diff 已应用)
|
|
2742
|
+
* ⑤ 无记录+worktree 在 → 校验有无产出后删/adopt(防盲删跨仓丢 diff,评审 P0-2)
|
|
2743
|
+
* 3. 剪枝活跃集 = registry(已含 rehydrate 的 ready/终态)∪ 磁盘(R8 保护层)。
|
|
2744
|
+
*/
|
|
2745
|
+
declare function installAgentJobReaper(registry?: AgentJobRegistry, repoRoot?: string, stateStore?: JobStateStore): void;
|
|
2592
2746
|
//#endregion
|
|
2593
2747
|
//#region src/agent-observability.d.ts
|
|
2594
2748
|
/**
|
|
@@ -2768,6 +2922,11 @@ declare function attachAgentObserver(agent: Agent, meta: AgentObservationMeta, r
|
|
|
2768
2922
|
declare function createEnvironmentContextSource(workspaceDir: string): ContextSource;
|
|
2769
2923
|
//#endregion
|
|
2770
2924
|
//#region src/context-sources/memory-index.d.ts
|
|
2925
|
+
/**
|
|
2926
|
+
* RFC-390 D4:标准组合根不再注册此 source(memory 内容由 coding 侧 lesson-injection hook
|
|
2927
|
+
* 合并进 <agent_knowledge> 信封)。保留供 V 形态/无 coding 组合使用——priority 复用
|
|
2928
|
+
* agentKnowledge 的 35(同位替代)。
|
|
2929
|
+
*/
|
|
2771
2930
|
declare function createMemoryIndexContextSource(_workspaceDir: string, memory?: ContextBuildInput['memory']): ContextSource;
|
|
2772
2931
|
//#endregion
|
|
2773
2932
|
//#region src/context-sources/todo-reminder.d.ts
|
|
@@ -2836,131 +2995,6 @@ interface DocSyncPort {
|
|
|
2836
2995
|
declare function formatDocSyncReminder(toolName: string): string;
|
|
2837
2996
|
declare function createDocSyncReminderHooks(port: DocSyncPort, priority?: 64): HookSpec[];
|
|
2838
2997
|
//#endregion
|
|
2839
|
-
//#region src/context-sources/section-order.d.ts
|
|
2840
|
-
/**
|
|
2841
|
-
* RFC-020 Phase 3(M54)P3-04:system-prompt 注入 section 的**唯一有序声明**。
|
|
2842
|
-
*
|
|
2843
|
-
* 治病灶——此前各 section 的 priority 数字(20/25/35/38/40/60)散在 coding hooks 与 runtime
|
|
2844
|
-
* context-sources 两包里,"system prompt 各段什么顺序"得捞齐多处数字才能拼出。现收敛为此处一张表:
|
|
2845
|
-
* - 数组/字段顺序即 priority 升序 = 实际 `system.prompt.transform` hook 的执行/拼接顺序;
|
|
2846
|
-
* - `lane` 标明该段落 **stable 前缀**(systemPrompt,进 prompt cache)还是 **volatile 尾段**
|
|
2847
|
-
* (systemTail,落在 cache 断点之后,逐轮可变不击穿缓存);
|
|
2848
|
-
* - runtime context-sources(environment/memory-index/memory-delta)与 coding hooks
|
|
2849
|
-
* (tool-guidance/lesson/skill-catalog)均从此处取 priority —— 单一真相源,改序只此一处。
|
|
2850
|
-
*
|
|
2851
|
-
* 放在 @x-otto/runtime(coding 依赖 runtime、反向不依赖):coding 侧 hook 经 `@x-otto/runtime` import。
|
|
2852
|
-
* 注:本表是**排序权威**(方案 H:section 仍由各自 hook 自注册,priority 数字降级为对本表的引用);
|
|
2853
|
-
* 不强行把 `SYSTEM_PROMPT_SECTIONS` 各 section 物理并入单一 registry(那超出外科尺度、非目标)。
|
|
2854
|
-
* section 数量以该常量的字段数为准,不在本段注释里重复写死具体数字(history: 建表时 7 个,
|
|
2855
|
-
* 后追加 docSyncReminder 成 8 个,又补 skillLoopGuidance 成 9 个——写死数字会重犯本次发现的漂移)。
|
|
2856
|
-
*/
|
|
2857
|
-
type SystemPromptLane = 'stable' | 'volatile';
|
|
2858
|
-
interface SystemPromptSectionSpec {
|
|
2859
|
-
/** 对应 hook / ContextSource 的 name/id(与注册名一致,供 drift guard 比对)。 */
|
|
2860
|
-
readonly name: string;
|
|
2861
|
-
readonly priority: number;
|
|
2862
|
-
readonly lane: SystemPromptLane;
|
|
2863
|
-
/**
|
|
2864
|
-
* RFC-374 M3:本 section 的注入字节硬顶(UTF-8)。注入点经
|
|
2865
|
-
* `applySectionBudget` 统一裁剪——预算只此一处声明,各注入点不持局部常量。
|
|
2866
|
-
* 取值原则:明显高于常态内容(防御失控注入而非改变正常行为),
|
|
2867
|
-
* 需要收紧时只改本表。
|
|
2868
|
-
*/
|
|
2869
|
-
readonly budgetBytes: number;
|
|
2870
|
-
}
|
|
2871
|
-
declare const SYSTEM_PROMPT_SECTIONS: {
|
|
2872
|
-
readonly toolGuidance: {
|
|
2873
|
-
readonly name: "tool-guidance-injection";
|
|
2874
|
-
readonly priority: 20;
|
|
2875
|
-
readonly lane: "stable";
|
|
2876
|
-
readonly budgetBytes: 20000;
|
|
2877
|
-
};
|
|
2878
|
-
/**
|
|
2879
|
-
* RFC-318 D7:三分流判别(缺工具 / 流程重复 / 其余)。紧跟 toolGuidance——它是对
|
|
2880
|
-
* "现有工具够不够用"的元判断,语义上属工具指引的延伸;内容恒定故走 stable lane。
|
|
2881
|
-
*/
|
|
2882
|
-
readonly skillLoopGuidance: {
|
|
2883
|
-
readonly name: "skill-loop-guidance-injection";
|
|
2884
|
-
readonly priority: 21;
|
|
2885
|
-
readonly lane: "stable";
|
|
2886
|
-
readonly budgetBytes: 2000;
|
|
2887
|
-
};
|
|
2888
|
-
readonly environment: {
|
|
2889
|
-
readonly name: "runtime:environment";
|
|
2890
|
-
readonly priority: 25;
|
|
2891
|
-
readonly lane: "stable";
|
|
2892
|
-
readonly budgetBytes: 8000;
|
|
2893
|
-
};
|
|
2894
|
-
readonly memoryIndex: {
|
|
2895
|
-
readonly name: "runtime:memory-index";
|
|
2896
|
-
readonly priority: 35;
|
|
2897
|
-
readonly lane: "stable";
|
|
2898
|
-
readonly budgetBytes: 24000;
|
|
2899
|
-
};
|
|
2900
|
-
readonly skillCatalog: {
|
|
2901
|
-
readonly name: "skill-catalog-injection";
|
|
2902
|
-
readonly priority: 38;
|
|
2903
|
-
readonly lane: "stable";
|
|
2904
|
-
readonly budgetBytes: 12000;
|
|
2905
|
-
};
|
|
2906
|
-
/** RFC-374 M3 初始 8KB 低于 RFC-382 T5/T6 重建后的常态内容(8.5KB 实测,2026-08-14)——
|
|
2907
|
-
* 字节顶须 > 常态内容(防御失控注入而非改变正常行为),否则每次构建静默截掉 pack 尾部。
|
|
2908
|
-
* 10KB 维持 ~1.2x 防御余量;token 侧仍受 RFC-284 8k soft/12k hard 预算约束。 */
|
|
2909
|
-
readonly lesson: {
|
|
2910
|
-
readonly name: "lesson-injection";
|
|
2911
|
-
readonly priority: 40;
|
|
2912
|
-
readonly lane: "stable";
|
|
2913
|
-
readonly budgetBytes: 10000;
|
|
2914
|
-
}; /** RFC-318 R7 治理补全:lesson-relevant-hints 原为表外 hook,现纳入统一预算面(volatile 尾段)。 */
|
|
2915
|
-
readonly lessonRelevantHints: {
|
|
2916
|
-
readonly name: "lesson-relevant-hints";
|
|
2917
|
-
readonly priority: 41;
|
|
2918
|
-
readonly lane: "volatile";
|
|
2919
|
-
readonly budgetBytes: 4000;
|
|
2920
|
-
};
|
|
2921
|
-
/**
|
|
2922
|
-
* RFC-383 M2(§9 修订 6):高频 skill 内化指令核心——引擎内部 hook
|
|
2923
|
-
* `internalize-skill-injection` 的 volatile 尾段预算面。**必须注册**:不注册则
|
|
2924
|
-
* applySectionBudget 原样放行、4KB 硬顶失效(决策器提炼不受控)。priority 42 排在
|
|
2925
|
-
* lessonRelevantHints(41) 之后、memoryDelta(60) 之前。
|
|
2926
|
-
*/
|
|
2927
|
-
readonly internalize: {
|
|
2928
|
-
readonly name: "internalize-skill-injection";
|
|
2929
|
-
readonly priority: 42;
|
|
2930
|
-
readonly lane: "volatile";
|
|
2931
|
-
readonly budgetBytes: 4000;
|
|
2932
|
-
};
|
|
2933
|
-
readonly memoryDelta: {
|
|
2934
|
-
readonly name: "memory-delta-injection";
|
|
2935
|
-
readonly priority: 60;
|
|
2936
|
-
readonly lane: "volatile";
|
|
2937
|
-
readonly budgetBytes: 8000;
|
|
2938
|
-
};
|
|
2939
|
-
readonly todoReminder: {
|
|
2940
|
-
readonly name: "todo-reminder-injection";
|
|
2941
|
-
readonly priority: 62;
|
|
2942
|
-
readonly lane: "volatile";
|
|
2943
|
-
readonly budgetBytes: 4000;
|
|
2944
|
-
};
|
|
2945
|
-
readonly docSyncReminder: {
|
|
2946
|
-
readonly name: "doc-sync-reminder-injection";
|
|
2947
|
-
readonly priority: 64;
|
|
2948
|
-
readonly lane: "volatile";
|
|
2949
|
-
readonly budgetBytes: 4000;
|
|
2950
|
-
};
|
|
2951
|
-
};
|
|
2952
|
-
/**
|
|
2953
|
-
* RFC-374 M3:按 section name 应用注入预算。内容超预算时裁剪(boundFragment,
|
|
2954
|
-
* 纯文本截断后缀,RFC-142 红线兼容);name 不在表中时原样返回(插件自定义
|
|
2955
|
-
* context source 不受本表预算约束——它不进表就不进预算面,是显式而非默认)。
|
|
2956
|
-
*
|
|
2957
|
-
* 截断诊断(08-14 lesson 字节顶事故跟进):超预算裁剪是静默丢信息——内容里的
|
|
2958
|
-
* 截断后缀模型能看见但宿主日志看不见,预算配置漂移(如 pack 内容长大超过
|
|
2959
|
-
* budgetBytes)只表现为「注入内容莫名缺尾」。此处 warn(每进程每 section 一次)
|
|
2960
|
-
* 把截断升级为可诊断事件,触发即提示检查 budgetBytes 与内容常态体积是否匹配。
|
|
2961
|
-
*/
|
|
2962
|
-
declare function applySectionBudget(name: string, content: string): string;
|
|
2963
|
-
//#endregion
|
|
2964
2998
|
//#region src/session-stable.d.ts
|
|
2965
2999
|
interface SessionStableInjectionOptions {
|
|
2966
3000
|
name: string;
|
|
@@ -2970,6 +3004,35 @@ interface SessionStableInjectionOptions {
|
|
|
2970
3004
|
}
|
|
2971
3005
|
declare function createSessionStableInjectionHooks(options: SessionStableInjectionOptions): HookSpec[];
|
|
2972
3006
|
//#endregion
|
|
3007
|
+
//#region src/define-prompt-section.d.ts
|
|
3008
|
+
interface PromptSectionDefinition {
|
|
3009
|
+
/**
|
|
3010
|
+
* section 名称——必须在 SYSTEM_PROMPT_SECTIONS 表中已登记且 lane 为 'stable'。
|
|
3011
|
+
* priority / budgetBytes 从表查取,调用方不可覆盖。
|
|
3012
|
+
*/
|
|
3013
|
+
readonly name: string;
|
|
3014
|
+
/**
|
|
3015
|
+
* 计算注入内容。返回空/undefined 表示本会话无注入(首轮计算后会话内冻结,不再重算)。
|
|
3016
|
+
* 产物自动过 applySectionBudget(调用方不需手动套预算)。
|
|
3017
|
+
*/
|
|
3018
|
+
compute: (input: SystemPromptTransformInput) => Promise<string | undefined> | string | undefined;
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* 定义一个 stable prompt section 注入 hook。
|
|
3022
|
+
*
|
|
3023
|
+
* 自动从 SYSTEM_PROMPT_SECTIONS 表查 priority / budgetBytes,走 session 冻结的 stable
|
|
3024
|
+
* lane,产物统一过 applySectionBudget。
|
|
3025
|
+
*
|
|
3026
|
+
* @example
|
|
3027
|
+
* ```ts
|
|
3028
|
+
* const hooks = definePromptSection({
|
|
3029
|
+
* name: SYSTEM_PROMPT_SECTIONS.skillLoopGuidance.name,
|
|
3030
|
+
* compute: async () => isEnabled() ? await loadGuidance() : undefined,
|
|
3031
|
+
* })
|
|
3032
|
+
* ```
|
|
3033
|
+
*/
|
|
3034
|
+
declare function definePromptSection(definition: PromptSectionDefinition): HookSpec[];
|
|
3035
|
+
//#endregion
|
|
2973
3036
|
//#region src/session/tool-result-store-global.d.ts
|
|
2974
3037
|
/**
|
|
2975
3038
|
* tool-result-store-global.ts — RFC-093:ToolResultStore 全局单例
|
|
@@ -3005,6 +3068,31 @@ declare function deriveSessionTitle(messages: readonly AgentMessage[]): string |
|
|
|
3005
3068
|
*/
|
|
3006
3069
|
declare function resolveSessionTitle(persistedTitle: string | undefined, messages: readonly AgentMessage[], id: string): string;
|
|
3007
3070
|
//#endregion
|
|
3071
|
+
//#region src/session/llm-escalation-reviewer.d.ts
|
|
3072
|
+
interface LlmEscalationReviewerDeps {
|
|
3073
|
+
/** 会话注入的流函数(与对话同一条,按 model.api 路由 provider)。 */
|
|
3074
|
+
stream: StreamFunction;
|
|
3075
|
+
/** 便宜判定模型(由 app 层解析,同 generateTitle 的 category:'search' 口径)。 */
|
|
3076
|
+
model: Model;
|
|
3077
|
+
/** 上限超时(ms),默认 10s;超时 → abstain。 */
|
|
3078
|
+
timeoutMs?: number;
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3081
|
+
* 解析 `{"verdict":"allow|deny|abstain"}`。
|
|
3082
|
+
*
|
|
3083
|
+
* **fail-closed 解析**:只有明确抽到 `allow`/`deny` 才返回之,其余(畸形 JSON、截断、
|
|
3084
|
+
* 散文、未知枚举值、空)一律 'abstain'。特别地,绝不因为文本里**出现** "allow" 字样
|
|
3085
|
+
* 就放行——必须是结构化 verdict 字段。
|
|
3086
|
+
*/
|
|
3087
|
+
declare function parseVerdict(raw: string): SemanticReviewerVerdict;
|
|
3088
|
+
/**
|
|
3089
|
+
* 构造 LLM 语义审批器。返回的函数签名即 `SemanticReviewer`。
|
|
3090
|
+
*
|
|
3091
|
+
* 注意:本函数**不做**「是否为升级审批」的判断——那由 gates 的 `isEscalationApproval`
|
|
3092
|
+
* 门负责(单一真源)。
|
|
3093
|
+
*/
|
|
3094
|
+
declare function createLlmEscalationReviewer(deps: LlmEscalationReviewerDeps): SemanticReviewer;
|
|
3095
|
+
//#endregion
|
|
3008
3096
|
//#region src/session/hooks.d.ts
|
|
3009
3097
|
interface ToolHookOptions {
|
|
3010
3098
|
hookRegistry: HookRegistry;
|
|
@@ -3381,5 +3469,5 @@ interface ResidencyDecision {
|
|
|
3381
3469
|
*/
|
|
3382
3470
|
declare function decide(snapshot: EngineSnapshot): ResidencyDecision;
|
|
3383
3471
|
//#endregion
|
|
3384
|
-
export { type AgentJobListener, AgentJobRegistry, type AgentJobRegistryOptions, type AgentJobStatus, type AgentObsStatus, type AgentObservabilityOptions, AgentObservabilityRegistry, type AgentObservation, type AgentObservationMeta, type AgentObservationSnapshot, type AgentRuntime, AgentSession, type AgentSessionEvent, type AgentSessionEventMap, type AgentSessionEventType, type AgentSessionInfo, type AgentSessionJob, type AgentSessionOptions, type AgentSessionSubscriber, type ApplyDiffResult, type ApplyPolicy, type ApplySignals, type ArchiveRecallPort, type AskUserQuestion, type AutonomyLevel, type BackgroundProcess, type BackgroundProcessStatus, type BasePlaneEntry, CAPABILITY_SURFACE_PATTERNS, type Checkpoint, type CheckpointData, type ContextBuildInput, type ContextInjectionPort, type ContextSource, ContextSourceRegistry, DEFAULT_COMPACTION_LOCK_ORPHAN_TIMEOUT_MS, DEFAULT_MAX_AUTO_APPLY_LINES, type
|
|
3472
|
+
export { type AgentJobListener, AgentJobRegistry, type AgentJobRegistryOptions, type AgentJobStatus, type AgentObsStatus, type AgentObservabilityOptions, AgentObservabilityRegistry, type AgentObservation, type AgentObservationMeta, type AgentObservationSnapshot, type AgentRuntime, AgentSession, type AgentSessionEvent, type AgentSessionEventMap, type AgentSessionEventType, type AgentSessionInfo, type AgentSessionJob, type AgentSessionOptions, type AgentSessionSubscriber, type ApplyDiffResult, type ApplyPolicy, type ApplySignals, type ArchiveRecallPort, type AskUserQuestion, type AutonomyLevel, type BackgroundProcess, type BackgroundProcessStatus, type BasePlaneEntry, CAPABILITY_SURFACE_PATTERNS, type Checkpoint, type CheckpointData, type ColdSessionLister, type ContextBuildInput, type ContextInjectionPort, type ContextSource, ContextSourceRegistry, DEFAULT_COMPACTION_LOCK_ORPHAN_TIMEOUT_MS, DEFAULT_MAX_AUTO_APPLY_LINES, type DocSyncPort, ESCALATION_MARKER, EVENT_DOMAIN, type EmitContext, type EngineStoreLocation, type EngineStoreOverrides, type EventDomain, type ExitResult, FORBIDDEN_ZONE_PATTERNS, type FileEntrySnapshot, type FileSnapshot, FleetMonitor, type FleetMonitorOptions, type FleetSample, type GrillAnswer, type GrillQuestion, type GrillRequest, type HostPlaneDraft, type HostPlaneEntry, HostRegistry, type JobStateEntry, JobStateStore, type KillOptions, LEVEL_DIVISOR, type LlmEscalationReviewerDeps, type ManagedProcess, type MemoryDeltaPort, MemoryGovernor, type MemoryGovernorOptions, type MemoryPort, type MemoryPressureLevel, type MemorySample, type MemorySubsystem, PanelStateStore, PersistenceSync, type PersistenceSyncDeps, type PlaneEntry, type ProcessCategory, type ProcessFilter, type ProcessLifecycle, type ProcessListener, type ProcessOwner, ProcessRegistry, type ProcessRegistryOptions, ProcessRuntime, type ProcessRuntimeOptions, type ProcessSpawnConfig, type ProcessStatus, type PromptOptions, type PromptRefresh, type PromptSectionDefinition, RUNTIME_DEFAULTS, type RegisterAgentJobInput, type RegisterInput, type RegistrationPlane, type RemoteSessionPoolOptions, type ReplayLevel, type ResidencyDiagnostics, ResidencyGovernor, type ResidencyPressureLevel, type ResolvedSessionConfig, type RestoreMode, type RuntimeOptions, SYSTEM_PROMPT_SECTIONS, type SandboxRunner, type SandboxToolCall, type SandboxToolResult, SandboxUnavailableError, type SemanticReviewer, type SemanticReviewerVerdict, type SessionCompactionLockPort, SessionPool, type SessionPoolOptions, type SessionPorts, type SessionPresetDraft, type SessionPresetEntry, type SessionStableInjectionOptions, type SessionStorageConfig, type StalePlaneEntry, type SystemPromptSectionSpec, TimeTravelController, type TimeTravelDeps, type TodoReminderPort, type TracebackView, type TurnRecord, type Verdict, type WorkspacePresetDraft, type WorkspacePresetEntry, type Worktree, type WriteLeaseManager, applyDiff, applyMemoryTransform, applySectionBudget, attachAgentObserver, buildEngineStores, captureFiles, checkApply, createAgentRuntime, createDefaultContextSourceRegistry, createDocSyncReminderHooks, createEnvironmentContextSource, createInMemorySessionPool, createLlmEscalationReviewer, createMemoryDeltaHooks, createMemoryIndexContextSource, createRemoteSessionPool, createSessionCompactionLock, createSessionStableInjectionHooks, createTodoReminderHooks, createToolHookExecutor, createWorktree, decideApply, decide as decideResidency, defaultMaxToolTurnExtensions, definePromptSection, deriveSessionTitle, diffTouchedPaths, effectiveResidencyBudget, formatDocSyncReminder, getEventDomain, globalAgentJobRegistry, globalAgentObservability, globalProcessRegistry, globalProcessRuntime, globalToolResultStore, hasRepoDrifted, installAgentJobReaper, installExitReaper, installProcessReaper, isEscalationApproval, jobStateFilePath, listWorktreeJobIds, messagesFromSnapshot, parseVerdict, pruneOrphanWorktrees, reconstructMessages, removeWorktree, resolveSessionTitle, resolveTodoContinuationConfig, restoreFiles, revertDiff, toJobStateEntry, touchesCapabilitySurface, touchesForbiddenZone, worktreeDiff };
|
|
3385
3473
|
//# sourceMappingURL=index.d.ts.map
|