@autopilot-agent/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -2
- package/dist/activity-animation.d.ts +57 -0
- package/dist/activity-animation.js +145 -0
- package/dist/animation-clock.d.ts +22 -0
- package/dist/animation-clock.js +76 -0
- package/dist/composition-root.d.ts +105 -0
- package/dist/composition-root.js +588 -0
- package/dist/context-report.d.ts +20 -0
- package/dist/context-report.js +174 -0
- package/dist/controller.d.ts +79 -0
- package/dist/controller.js +681 -0
- package/dist/design-tokens.d.ts +34 -0
- package/dist/design-tokens.js +34 -0
- package/dist/error-diagnostics.d.ts +8 -0
- package/dist/error-diagnostics.js +62 -0
- package/dist/event-projector.d.ts +26 -0
- package/dist/event-projector.js +333 -0
- package/dist/file-mention-context.d.ts +34 -0
- package/dist/file-mention-context.js +173 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +14 -0
- package/dist/main.d.ts +40 -0
- package/dist/main.js +543 -0
- package/dist/parser.d.ts +17 -0
- package/dist/parser.js +391 -0
- package/dist/renderer.d.ts +9 -0
- package/dist/renderer.js +48 -0
- package/dist/scroll-viewport.d.ts +22 -0
- package/dist/scroll-viewport.js +62 -0
- package/dist/termination-format.d.ts +4 -0
- package/dist/termination-format.js +17 -0
- package/dist/timeline-lines.d.ts +38 -0
- package/dist/timeline-lines.js +104 -0
- package/dist/tui/app.d.ts +30 -0
- package/dist/tui/app.js +410 -0
- package/dist/tui/approval.d.ts +19 -0
- package/dist/tui/approval.js +37 -0
- package/dist/tui/brand/brand-header.d.ts +20 -0
- package/dist/tui/brand/brand-header.js +22 -0
- package/dist/tui/brand/intro.d.ts +12 -0
- package/dist/tui/brand/intro.js +88 -0
- package/dist/tui/brand/pixel.d.ts +8 -0
- package/dist/tui/brand/pixel.js +50 -0
- package/dist/tui/constants.d.ts +56 -0
- package/dist/tui/constants.js +57 -0
- package/dist/tui/context.d.ts +11 -0
- package/dist/tui/context.js +12 -0
- package/dist/tui/diff-stats.d.ts +8 -0
- package/dist/tui/diff-stats.js +7 -0
- package/dist/tui/format.d.ts +75 -0
- package/dist/tui/format.js +176 -0
- package/dist/tui/hooks/use-file-mention-index.d.ts +15 -0
- package/dist/tui/hooks/use-file-mention-index.js +59 -0
- package/dist/tui/hooks/use-pickers.d.ts +47 -0
- package/dist/tui/hooks/use-pickers.js +288 -0
- package/dist/tui/hooks/use-prompt-input.d.ts +54 -0
- package/dist/tui/hooks/use-prompt-input.js +258 -0
- package/dist/tui/hooks/use-status-view.d.ts +8 -0
- package/dist/tui/hooks/use-status-view.js +13 -0
- package/dist/tui/hooks/use-viewport.d.ts +22 -0
- package/dist/tui/hooks/use-viewport.js +117 -0
- package/dist/tui/input/file-mention.d.ts +33 -0
- package/dist/tui/input/file-mention.js +112 -0
- package/dist/tui/input/graphemes.d.ts +5 -0
- package/dist/tui/input/graphemes.js +10 -0
- package/dist/tui/input/keys.d.ts +16 -0
- package/dist/tui/input/keys.js +58 -0
- package/dist/tui/input/prompt-layout.d.ts +27 -0
- package/dist/tui/input/prompt-layout.js +84 -0
- package/dist/tui/input-area.d.ts +53 -0
- package/dist/tui/input-area.js +89 -0
- package/dist/tui/jobs.d.ts +10 -0
- package/dist/tui/jobs.js +24 -0
- package/dist/tui/lifecycle.d.ts +23 -0
- package/dist/tui/lifecycle.js +114 -0
- package/dist/tui/markdown/diff.d.ts +8 -0
- package/dist/tui/markdown/diff.js +19 -0
- package/dist/tui/markdown/inline.d.ts +4 -0
- package/dist/tui/markdown/inline.js +32 -0
- package/dist/tui/markdown/markdown.d.ts +17 -0
- package/dist/tui/markdown/markdown.js +117 -0
- package/dist/tui/markdown/table.d.ts +19 -0
- package/dist/tui/markdown/table.js +74 -0
- package/dist/tui/performance-diagnostics.d.ts +7 -0
- package/dist/tui/performance-diagnostics.js +57 -0
- package/dist/tui/pickers/effort.d.ts +10 -0
- package/dist/tui/pickers/effort.js +12 -0
- package/dist/tui/pickers/file-mention.d.ts +11 -0
- package/dist/tui/pickers/file-mention.js +22 -0
- package/dist/tui/pickers/model.d.ts +10 -0
- package/dist/tui/pickers/model.js +12 -0
- package/dist/tui/pickers/permission.d.ts +10 -0
- package/dist/tui/pickers/permission.js +13 -0
- package/dist/tui/pickers/skill.d.ts +13 -0
- package/dist/tui/pickers/skill.js +25 -0
- package/dist/tui/pickers/slash.d.ts +10 -0
- package/dist/tui/pickers/slash.js +11 -0
- package/dist/tui/prompt-input.d.ts +11 -0
- package/dist/tui/prompt-input.js +73 -0
- package/dist/tui/render-mode.d.ts +20 -0
- package/dist/tui/render-mode.js +31 -0
- package/dist/tui/run.d.ts +6 -0
- package/dist/tui/run.js +237 -0
- package/dist/tui/status-line.d.ts +16 -0
- package/dist/tui/status-line.js +37 -0
- package/dist/tui/store.d.ts +4 -0
- package/dist/tui/store.js +344 -0
- package/dist/tui/timeline/live.d.ts +16 -0
- package/dist/tui/timeline/live.js +151 -0
- package/dist/tui/timeline/presentation-timeline.d.ts +14 -0
- package/dist/tui/timeline/presentation-timeline.js +109 -0
- package/dist/tui/timeline/progress.d.ts +12 -0
- package/dist/tui/timeline/progress.js +43 -0
- package/dist/tui/timeline/static-timeline.d.ts +13 -0
- package/dist/tui/timeline/static-timeline.js +121 -0
- package/dist/tui/timeline/tool-tree.d.ts +7 -0
- package/dist/tui/timeline/tool-tree.js +25 -0
- package/dist/tui/timeline/turn.d.ts +19 -0
- package/dist/tui/timeline/turn.js +21 -0
- package/dist/tui/todo-list.d.ts +50 -0
- package/dist/tui/todo-list.js +120 -0
- package/dist/tui/transcript.d.ts +24 -0
- package/dist/tui/transcript.js +34 -0
- package/dist/tui/trust-dialog.d.ts +51 -0
- package/dist/tui/trust-dialog.js +127 -0
- package/dist/tui/types.d.ts +175 -0
- package/dist/tui/types.js +5 -0
- package/dist/tui/viewport/selection.d.ts +27 -0
- package/dist/tui/viewport/selection.js +79 -0
- package/dist/tui/viewport/sources.d.ts +29 -0
- package/dist/tui/viewport/sources.js +585 -0
- package/dist/tui/viewport/viewport.d.ts +12 -0
- package/dist/tui/viewport/viewport.js +87 -0
- package/dist/tui-input-history.d.ts +23 -0
- package/dist/tui-input-history.js +42 -0
- package/dist/tui-input-router.d.ts +24 -0
- package/dist/tui-input-router.js +115 -0
- package/dist/tui.d.ts +15 -0
- package/dist/tui.js +13 -0
- package/dist/types.d.ts +454 -0
- package/dist/types.js +7 -0
- package/package.json +58 -4
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Usage 安全报告格式化。
|
|
3
|
+
*
|
|
4
|
+
* 所有输入只来自 Core 白名单 ContextUsageView DTO;宿主只做展示转换,
|
|
5
|
+
* 不重算 token、不猜测窗口、不为非零分类强塞至少一格。
|
|
6
|
+
*/
|
|
7
|
+
/** Core 固定枚举到 CLI 稳定中文标签的映射;不携带动态名称。 */
|
|
8
|
+
const CONTEXT_CATEGORY_LABELS = {
|
|
9
|
+
system: "系统",
|
|
10
|
+
instructions: "项目指令",
|
|
11
|
+
memory: "Memory",
|
|
12
|
+
skills: "Skills",
|
|
13
|
+
tools: "工具",
|
|
14
|
+
conversation: "对话",
|
|
15
|
+
other: "其他",
|
|
16
|
+
output_reserve: "输出预留",
|
|
17
|
+
};
|
|
18
|
+
/** Memory/Skills 以聚合行展示,不再出现在固定分类列表。 */
|
|
19
|
+
const AGGREGATED_CATEGORY_KINDS = new Set(["memory", "skills"]);
|
|
20
|
+
/** 1M 及以上窗口在相同列数下提供更细的网格分辨率。 */
|
|
21
|
+
const HIGH_RESOLUTION_WINDOW_TOKENS = 1_000_000;
|
|
22
|
+
/** 千分位数字格式;固定 locale 保证 Plain/JSONL/TUI 输出稳定。 */
|
|
23
|
+
function formatTokens(tokens) {
|
|
24
|
+
return tokens.toLocaleString("en-US");
|
|
25
|
+
}
|
|
26
|
+
/** 百分比格式;usageRatio 不在 Core clamp,允许显示超过 100% 的真实值。 */
|
|
27
|
+
function formatPercent(ratio) {
|
|
28
|
+
return `${(ratio * 100).toFixed(1)}%`;
|
|
29
|
+
}
|
|
30
|
+
/** 单条分类的稳定文本行;expanded 追加 projected 比例。 */
|
|
31
|
+
function formatCategoryLine(category, expanded) {
|
|
32
|
+
const label = CONTEXT_CATEGORY_LABELS[category.kind];
|
|
33
|
+
const items = category.itemCount !== undefined ? ` · ${formatTokens(category.itemCount)} items` : "";
|
|
34
|
+
const reserved = category.measurement === "reserved" ? " (reserved)" : "";
|
|
35
|
+
const base = `${label}: ${formatTokens(category.tokens)} tokens${items} (${formatPercent(category.windowRatio)} window)${reserved}`;
|
|
36
|
+
return expanded ? `${base} · ${formatPercent(category.projectedRatio)} projected` : base;
|
|
37
|
+
}
|
|
38
|
+
/** Memory/Skills 聚合行;expanded 时补充 Core 已提供的窗口占比与 projected 占比。 */
|
|
39
|
+
function formatAggregatedCategoryLine(category, expanded) {
|
|
40
|
+
const label = category.kind === "memory" ? "Memory files" : "Skills";
|
|
41
|
+
const items = category.itemCount !== undefined ? `${formatTokens(category.itemCount)} items · ` : "";
|
|
42
|
+
const base = `${label}: ${items}${formatTokens(category.tokens)} tokens`;
|
|
43
|
+
return expanded ? `${base} (${formatPercent(category.windowRatio)} window) · ${formatPercent(category.projectedRatio)} projected` : base;
|
|
44
|
+
}
|
|
45
|
+
/** 右侧信息区的稳定文本行;字段顺序固定,供 Plain/TUI/视口共用。 */
|
|
46
|
+
function formatContextSummaryLines(usage, expanded) {
|
|
47
|
+
const lines = [
|
|
48
|
+
`model: ${usage.modelRef}`,
|
|
49
|
+
`projected: ${formatTokens(usage.projectedTokens)} / ${formatTokens(usage.contextWindowTokens)} tokens (${formatPercent(usage.usageRatio)} projected) · ${usage.measurement}`,
|
|
50
|
+
"usage by category (estimated):",
|
|
51
|
+
];
|
|
52
|
+
for (const category of usage.breakdown.categories) {
|
|
53
|
+
if (AGGREGATED_CATEGORY_KINDS.has(category.kind))
|
|
54
|
+
continue;
|
|
55
|
+
lines.push(` ${formatCategoryLine(category, expanded)}`);
|
|
56
|
+
}
|
|
57
|
+
lines.push(`Free space: ${formatTokens(usage.breakdown.freeTokens)} tokens (${formatPercent(usage.breakdown.freeRatio)})`, `Autocompact buffer: ${formatTokens(usage.breakdown.compactBufferTokens)} tokens (${formatPercent(usage.breakdown.compactBufferRatio)})`);
|
|
58
|
+
for (const category of usage.breakdown.categories) {
|
|
59
|
+
if (!AGGREGATED_CATEGORY_KINDS.has(category.kind))
|
|
60
|
+
continue;
|
|
61
|
+
const aggregated = formatAggregatedCategoryLine(category, expanded);
|
|
62
|
+
if (aggregated)
|
|
63
|
+
lines.push(aggregated);
|
|
64
|
+
}
|
|
65
|
+
return lines;
|
|
66
|
+
}
|
|
67
|
+
/** /context all 的安全展开块;只补充 DTO 已有字段,不生成派生结论。 */
|
|
68
|
+
function formatContextDetailLines(usage) {
|
|
69
|
+
const lines = [
|
|
70
|
+
"Context usage details (all):",
|
|
71
|
+
`overall measurement: ${usage.measurement}`,
|
|
72
|
+
`breakdown measurement: ${usage.breakdown.measurement}`,
|
|
73
|
+
`provider measured: ${usage.providerMeasuredTokens !== undefined ? `${formatTokens(usage.providerMeasuredTokens)} tokens` : "not available"}`,
|
|
74
|
+
`estimated added: ${formatTokens(usage.estimatedAddedTokens)} tokens`,
|
|
75
|
+
`current context: ${formatTokens(usage.currentContextTokens)} tokens`,
|
|
76
|
+
`output reserve: ${formatTokens(usage.outputReserveTokens)} tokens`,
|
|
77
|
+
`compact trigger: ${formatTokens(usage.compactTriggerTokens)} tokens`,
|
|
78
|
+
`compact needed: ${usage.compactNeeded ? "yes" : "no"}`,
|
|
79
|
+
`free: ${formatTokens(usage.breakdown.freeTokens)} tokens (${formatPercent(usage.breakdown.freeRatio)})`,
|
|
80
|
+
`compact buffer: ${formatTokens(usage.breakdown.compactBufferTokens)} tokens (${formatPercent(usage.breakdown.compactBufferRatio)})`,
|
|
81
|
+
`over limit: ${formatTokens(usage.breakdown.overLimitTokens)} tokens (${formatPercent(usage.breakdown.overLimitRatio)})`,
|
|
82
|
+
];
|
|
83
|
+
return lines;
|
|
84
|
+
}
|
|
85
|
+
/** 网格尺寸:窄屏降列数,>=1M 窗口提升行数(Plan 9.5)。 */
|
|
86
|
+
function resolveGridShape(usage, columns) {
|
|
87
|
+
const highResolution = usage.contextWindowTokens >= HIGH_RESOLUTION_WINDOW_TOKENS;
|
|
88
|
+
if (columns < 80)
|
|
89
|
+
return { cols: 5, rows: highResolution ? 10 : 5 };
|
|
90
|
+
return { cols: highResolution ? 20 : 10, rows: 10 };
|
|
91
|
+
}
|
|
92
|
+
/** 用最大余数法把 window 分配到固定格子;零份额分类不保留格子。 */
|
|
93
|
+
function allocateGridCells(shares, totalCells, windowTokens) {
|
|
94
|
+
const raw = shares.map(function toFraction(tokens) { return tokens / windowTokens * totalCells; });
|
|
95
|
+
const base = raw.map(function floorShare(value) { return Math.floor(value); });
|
|
96
|
+
let remaining = totalCells - base.reduce(function sumCells(total, cells) { return total + cells; }, 0);
|
|
97
|
+
const order = raw
|
|
98
|
+
.map(function toRemainder(value, index) { return { index, remainder: value - Math.floor(value) }; })
|
|
99
|
+
.sort(function byRemainderDesc(left, right) { return right.remainder - left.remainder || left.index - right.index; });
|
|
100
|
+
for (const item of order) {
|
|
101
|
+
if (remaining <= 0)
|
|
102
|
+
break;
|
|
103
|
+
base[item.index] += 1;
|
|
104
|
+
remaining -= 1;
|
|
105
|
+
}
|
|
106
|
+
return base;
|
|
107
|
+
}
|
|
108
|
+
/** 渲染网格行:已用/侵入 buffer/free/剩余 buffer 使用不同单格宽字符。 */
|
|
109
|
+
function renderGridLines(usage, columns) {
|
|
110
|
+
const { cols, rows } = resolveGridShape(usage, columns);
|
|
111
|
+
const projected = Math.min(usage.projectedTokens, usage.contextWindowTokens);
|
|
112
|
+
const usedMain = Math.min(projected, usage.compactTriggerTokens);
|
|
113
|
+
const usedBuffer = Math.max(projected - usage.compactTriggerTokens, 0);
|
|
114
|
+
const free = Math.max(usage.breakdown.freeTokens, 0);
|
|
115
|
+
const bufferRemaining = Math.max(usage.breakdown.compactBufferTokens - usedBuffer, 0);
|
|
116
|
+
const counts = allocateGridCells([usedMain, usedBuffer, free, bufferRemaining], cols * rows, usage.contextWindowTokens);
|
|
117
|
+
const glyphs = ["█", "▓", "░", "▒"];
|
|
118
|
+
// 按份额顺序展开为每格字符;未分配格子保持空白。
|
|
119
|
+
const cellGlyphs = [];
|
|
120
|
+
counts.forEach(function expandCells(count, shareIndex) {
|
|
121
|
+
for (let index = 0; index < count; index += 1)
|
|
122
|
+
cellGlyphs.push(glyphs[shareIndex] ?? " ");
|
|
123
|
+
});
|
|
124
|
+
// Array.from 回调首参是 element,行号在第二参;用错会把行号算成 NaN 并全部回退空格。
|
|
125
|
+
return Array.from({ length: rows }, function buildRow(_element, rowIndex) {
|
|
126
|
+
let line = "";
|
|
127
|
+
for (let colIndex = 0; colIndex < cols; colIndex += 1) {
|
|
128
|
+
line += cellGlyphs[rowIndex * cols + colIndex] ?? " ";
|
|
129
|
+
}
|
|
130
|
+
return line;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 生成 Context 报告文本行。
|
|
135
|
+
* grid=false(Plain/screen reader/NO_COLOR)跳过装饰网格但保留完整文本;
|
|
136
|
+
* 列数不足以并排时整体改为上下堆叠。
|
|
137
|
+
*/
|
|
138
|
+
export function formatContextReportLines(usage, expanded, options) {
|
|
139
|
+
if (!usage)
|
|
140
|
+
return ["Context: unknown"];
|
|
141
|
+
const rightLines = formatContextSummaryLines(usage, expanded);
|
|
142
|
+
if (expanded)
|
|
143
|
+
rightLines.push(...formatContextDetailLines(usage));
|
|
144
|
+
if (!options.grid) {
|
|
145
|
+
return ["Context Usage", ...rightLines, "", "/context all to expand"];
|
|
146
|
+
}
|
|
147
|
+
const gridLines = renderGridLines(usage, options.columns);
|
|
148
|
+
const gridWidth = gridLines.reduce(function maxGridWidth(width, line) { return Math.max(width, line.length); }, 0);
|
|
149
|
+
const stackVertically = gridWidth + 2 + 30 > options.columns;
|
|
150
|
+
const rows = ["Context Usage"];
|
|
151
|
+
if (stackVertically) {
|
|
152
|
+
rows.push(...gridLines, ...rightLines);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const height = Math.max(gridLines.length, rightLines.length);
|
|
156
|
+
for (let index = 0; index < height; index += 1) {
|
|
157
|
+
const gridLine = (gridLines[index] ?? "").padEnd(gridWidth, " ");
|
|
158
|
+
rows.push(`${gridLine} ${rightLines[index] ?? ""}`.trimEnd());
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
rows.push("", "/context all to expand");
|
|
162
|
+
return rows;
|
|
163
|
+
}
|
|
164
|
+
/** Plain/非 TTY 的稳定文本报告;始终跳过装饰网格。 */
|
|
165
|
+
export function formatPlainContextReport(usage, expanded) {
|
|
166
|
+
return formatContextReportLines(usage, expanded, { grid: false, columns: Number.MAX_SAFE_INTEGER });
|
|
167
|
+
}
|
|
168
|
+
/** 状态栏 Context 行的紧凑文本:`12.3% · measured` / `≈1.2% · estimated` / `unknown`。 */
|
|
169
|
+
export function formatTuiContextStatus(usage) {
|
|
170
|
+
if (!usage)
|
|
171
|
+
return "unknown";
|
|
172
|
+
const percent = formatPercent(usage.usageRatio);
|
|
173
|
+
return `${usage.measurement === "measured" ? "" : "≈"}${percent} · ${usage.measurement}`;
|
|
174
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Controller。
|
|
3
|
+
*
|
|
4
|
+
* Controller 是 Action 到 Core Runtime Public API 的唯一映射层;它不实现
|
|
5
|
+
* Session/Turn 状态机,审批只从当前安全 projection 取得 approvalId,绝不
|
|
6
|
+
* 生成 callId、toolName、normalizedInputHash 或冻结工具输入。
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentEvent, ApprovalDecision, ContextUsageView } from "@autopilot-agent/core";
|
|
9
|
+
import type { CliAction, CliCommand, CliEffortOption, CliExitCode, CliEventListener, CliJobView, CliQueuedInputStartedListener, CliModelOption, CliPermissionOption, CliProjection, CliRenderer, CliRuntimeStatusDefaults, CliSkillCatalogLister, CliSkillResolver, CliSkillSummary, CliStatusView, CliRuntime } from "./types.js";
|
|
10
|
+
/** 为当前 Controller 注入的审批提交回调;四字段之外不允许宿主提供凭证。 */
|
|
11
|
+
export type CliApprovalSubmit = (input: {
|
|
12
|
+
sessionId: string;
|
|
13
|
+
turnId: string;
|
|
14
|
+
approvalId: string;
|
|
15
|
+
decision: "allow_once" | "allow_session" | "allow_workspace" | "deny";
|
|
16
|
+
}) => Promise<ApprovalDecision>;
|
|
17
|
+
/** Controller 输出结果;lines 由 Main 统一写入 stdout/stderr。 */
|
|
18
|
+
export interface CliControllerResult {
|
|
19
|
+
kind: "ok" | "exit" | "error" | "unavailable";
|
|
20
|
+
exitCode: CliExitCode;
|
|
21
|
+
lines: string[];
|
|
22
|
+
message?: string;
|
|
23
|
+
skillOptions?: CliSkillSummary[];
|
|
24
|
+
/** 交互 TTY 用于打开权限 picker;Plain 模式使用同一结果中的稳定 lines。 */
|
|
25
|
+
permissionOptions?: CliPermissionOption[];
|
|
26
|
+
/** 交互 TTY 用于打开模型 picker;Plain 模式使用同一结果中的稳定 lines。 */
|
|
27
|
+
modelOptions?: CliModelOption[];
|
|
28
|
+
/** 交互 TTY 用于打开推理强度 picker;Plain 模式使用同一结果中的稳定 lines。 */
|
|
29
|
+
effortOptions?: CliEffortOption[];
|
|
30
|
+
/** 当前 Session 的后台任务列表或详情;TUI 直接消费安全 DTO。 */
|
|
31
|
+
jobView?: CliJobView;
|
|
32
|
+
/** 状态栏使用的安全配置视图。 */
|
|
33
|
+
statusView?: CliStatusView;
|
|
34
|
+
/** /context 的专用安全报告;TUI 渲染为静态 transcript item,Plain/JSONL 消费 lines。 */
|
|
35
|
+
contextView?: {
|
|
36
|
+
usage: ContextUsageView | null;
|
|
37
|
+
expanded: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** 运行中输入成功写入 durable inbox 后,供 TUI 标识等待中的引导或排队消息。 */
|
|
40
|
+
submittedInput?: {
|
|
41
|
+
inputId: string;
|
|
42
|
+
delivery: "steer" | "queue";
|
|
43
|
+
};
|
|
44
|
+
projection: CliProjection;
|
|
45
|
+
}
|
|
46
|
+
/** Controller 创建参数。 */
|
|
47
|
+
export interface CreateCliControllerOptions {
|
|
48
|
+
runtime?: CliRuntime;
|
|
49
|
+
renderer: CliRenderer;
|
|
50
|
+
sessionId?: string;
|
|
51
|
+
approvalSubmit?: CliApprovalSubmit;
|
|
52
|
+
listSkills?: CliSkillCatalogLister;
|
|
53
|
+
resolveSkill?: CliSkillResolver;
|
|
54
|
+
/** Composition Root 传入的 canonical workspaceRoot,只用于安全状态栏展示。 */
|
|
55
|
+
workspaceRoot?: string;
|
|
56
|
+
/** 读取已热更新的安全 Runtime 默认值;仅用于 idle/Completed 状态栏,不参与 Turn 冻结。 */
|
|
57
|
+
getRuntimeStatusDefaults?: () => CliRuntimeStatusDefaults;
|
|
58
|
+
onEvent?: CliEventListener;
|
|
59
|
+
/** 自动启动 queue Turn 前通知交互 TUI,避免等待 prompt 残留在底部。 */
|
|
60
|
+
onQueuedInputStarted?: CliQueuedInputStartedListener;
|
|
61
|
+
now?: () => Date;
|
|
62
|
+
}
|
|
63
|
+
/** CLI Controller 对外接口。 */
|
|
64
|
+
export interface CliController {
|
|
65
|
+
dispatch(action: CliAction): Promise<CliControllerResult>;
|
|
66
|
+
consume(events: AsyncIterable<AgentEvent>): Promise<CliControllerResult>;
|
|
67
|
+
resume(): Promise<CliControllerResult>;
|
|
68
|
+
getProjection(): CliProjection;
|
|
69
|
+
/** 读取当前 Session 默认或活动 Turn frozen 的脱敏状态栏视图。 */
|
|
70
|
+
getStatusView?(): Promise<CliStatusView>;
|
|
71
|
+
setSession(sessionId: string): void;
|
|
72
|
+
setEventListener(listener?: import("./types.js").CliEventListener): void;
|
|
73
|
+
/** 绑定 queue Turn 启动通知;Plain 宿主不需要注册。 */
|
|
74
|
+
setQueuedInputListener?(listener?: CliQueuedInputStartedListener): void;
|
|
75
|
+
}
|
|
76
|
+
/** 创建无 React 依赖的 Controller;Renderer 和 Runtime 均通过参数注入。 */
|
|
77
|
+
export declare function createCliController(options: CreateCliControllerOptions): CliController;
|
|
78
|
+
/** 将 argv 命令转换为 Step 5.2 可执行范围内的 Controller Action。 */
|
|
79
|
+
export declare function commandToAction(command: CliCommand): CliAction | undefined;
|