@autopilot-agent/cli 0.0.0-stage → 0.2.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.
Files changed (144) hide show
  1. package/README.md +52 -2
  2. package/dist/activity-animation.d.ts +59 -0
  3. package/dist/activity-animation.js +148 -0
  4. package/dist/animation-clock.d.ts +22 -0
  5. package/dist/animation-clock.js +76 -0
  6. package/dist/composition-root.d.ts +105 -0
  7. package/dist/composition-root.js +600 -0
  8. package/dist/context-report.d.ts +20 -0
  9. package/dist/context-report.js +173 -0
  10. package/dist/controller.d.ts +79 -0
  11. package/dist/controller.js +741 -0
  12. package/dist/design-tokens.d.ts +38 -0
  13. package/dist/design-tokens.js +38 -0
  14. package/dist/error-diagnostics.d.ts +8 -0
  15. package/dist/error-diagnostics.js +62 -0
  16. package/dist/event-projector.d.ts +26 -0
  17. package/dist/event-projector.js +335 -0
  18. package/dist/file-mention-context.d.ts +34 -0
  19. package/dist/file-mention-context.js +173 -0
  20. package/dist/index.d.ts +19 -0
  21. package/dist/index.js +14 -0
  22. package/dist/main.d.ts +40 -0
  23. package/dist/main.js +543 -0
  24. package/dist/parser.d.ts +17 -0
  25. package/dist/parser.js +400 -0
  26. package/dist/renderer.d.ts +9 -0
  27. package/dist/renderer.js +62 -0
  28. package/dist/scroll-viewport.d.ts +22 -0
  29. package/dist/scroll-viewport.js +62 -0
  30. package/dist/termination-format.d.ts +4 -0
  31. package/dist/termination-format.js +18 -0
  32. package/dist/timeline-lines.d.ts +38 -0
  33. package/dist/timeline-lines.js +104 -0
  34. package/dist/tui/app.d.ts +30 -0
  35. package/dist/tui/app.js +413 -0
  36. package/dist/tui/approval.d.ts +19 -0
  37. package/dist/tui/approval.js +41 -0
  38. package/dist/tui/brand/brand-header.d.ts +20 -0
  39. package/dist/tui/brand/brand-header.js +22 -0
  40. package/dist/tui/brand/intro.d.ts +12 -0
  41. package/dist/tui/brand/intro.js +88 -0
  42. package/dist/tui/brand/pixel.d.ts +8 -0
  43. package/dist/tui/brand/pixel.js +50 -0
  44. package/dist/tui/constants.d.ts +56 -0
  45. package/dist/tui/constants.js +57 -0
  46. package/dist/tui/context.d.ts +11 -0
  47. package/dist/tui/context.js +12 -0
  48. package/dist/tui/diff-stats.d.ts +8 -0
  49. package/dist/tui/diff-stats.js +7 -0
  50. package/dist/tui/format.d.ts +75 -0
  51. package/dist/tui/format.js +178 -0
  52. package/dist/tui/hooks/use-file-mention-index.d.ts +15 -0
  53. package/dist/tui/hooks/use-file-mention-index.js +59 -0
  54. package/dist/tui/hooks/use-pickers.d.ts +47 -0
  55. package/dist/tui/hooks/use-pickers.js +288 -0
  56. package/dist/tui/hooks/use-prompt-input.d.ts +54 -0
  57. package/dist/tui/hooks/use-prompt-input.js +258 -0
  58. package/dist/tui/hooks/use-status-view.d.ts +8 -0
  59. package/dist/tui/hooks/use-status-view.js +13 -0
  60. package/dist/tui/hooks/use-viewport.d.ts +22 -0
  61. package/dist/tui/hooks/use-viewport.js +117 -0
  62. package/dist/tui/input/file-mention.d.ts +33 -0
  63. package/dist/tui/input/file-mention.js +112 -0
  64. package/dist/tui/input/graphemes.d.ts +5 -0
  65. package/dist/tui/input/graphemes.js +10 -0
  66. package/dist/tui/input/keys.d.ts +16 -0
  67. package/dist/tui/input/keys.js +58 -0
  68. package/dist/tui/input/prompt-layout.d.ts +27 -0
  69. package/dist/tui/input/prompt-layout.js +84 -0
  70. package/dist/tui/input-area.d.ts +53 -0
  71. package/dist/tui/input-area.js +89 -0
  72. package/dist/tui/jobs.d.ts +10 -0
  73. package/dist/tui/jobs.js +24 -0
  74. package/dist/tui/lifecycle.d.ts +23 -0
  75. package/dist/tui/lifecycle.js +114 -0
  76. package/dist/tui/markdown/diff.d.ts +8 -0
  77. package/dist/tui/markdown/diff.js +19 -0
  78. package/dist/tui/markdown/inline.d.ts +4 -0
  79. package/dist/tui/markdown/inline.js +32 -0
  80. package/dist/tui/markdown/markdown.d.ts +17 -0
  81. package/dist/tui/markdown/markdown.js +117 -0
  82. package/dist/tui/markdown/table.d.ts +19 -0
  83. package/dist/tui/markdown/table.js +74 -0
  84. package/dist/tui/performance-diagnostics.d.ts +7 -0
  85. package/dist/tui/performance-diagnostics.js +57 -0
  86. package/dist/tui/pickers/effort.d.ts +10 -0
  87. package/dist/tui/pickers/effort.js +12 -0
  88. package/dist/tui/pickers/file-mention.d.ts +11 -0
  89. package/dist/tui/pickers/file-mention.js +22 -0
  90. package/dist/tui/pickers/model.d.ts +10 -0
  91. package/dist/tui/pickers/model.js +12 -0
  92. package/dist/tui/pickers/permission.d.ts +10 -0
  93. package/dist/tui/pickers/permission.js +13 -0
  94. package/dist/tui/pickers/skill.d.ts +13 -0
  95. package/dist/tui/pickers/skill.js +25 -0
  96. package/dist/tui/pickers/slash.d.ts +10 -0
  97. package/dist/tui/pickers/slash.js +11 -0
  98. package/dist/tui/prompt-input.d.ts +11 -0
  99. package/dist/tui/prompt-input.js +73 -0
  100. package/dist/tui/render-mode.d.ts +20 -0
  101. package/dist/tui/render-mode.js +31 -0
  102. package/dist/tui/run.d.ts +6 -0
  103. package/dist/tui/run.js +237 -0
  104. package/dist/tui/status-line.d.ts +16 -0
  105. package/dist/tui/status-line.js +37 -0
  106. package/dist/tui/store.d.ts +4 -0
  107. package/dist/tui/store.js +380 -0
  108. package/dist/tui/timeline/live.d.ts +16 -0
  109. package/dist/tui/timeline/live.js +153 -0
  110. package/dist/tui/timeline/presentation-timeline.d.ts +15 -0
  111. package/dist/tui/timeline/presentation-timeline.js +128 -0
  112. package/dist/tui/timeline/progress.d.ts +12 -0
  113. package/dist/tui/timeline/progress.js +43 -0
  114. package/dist/tui/timeline/static-timeline.d.ts +13 -0
  115. package/dist/tui/timeline/static-timeline.js +131 -0
  116. package/dist/tui/timeline/tool-tree.d.ts +7 -0
  117. package/dist/tui/timeline/tool-tree.js +25 -0
  118. package/dist/tui/timeline/turn-items.d.ts +12 -0
  119. package/dist/tui/timeline/turn-items.js +28 -0
  120. package/dist/tui/timeline/turn.d.ts +19 -0
  121. package/dist/tui/timeline/turn.js +21 -0
  122. package/dist/tui/todo-list.d.ts +50 -0
  123. package/dist/tui/todo-list.js +120 -0
  124. package/dist/tui/transcript.d.ts +24 -0
  125. package/dist/tui/transcript.js +34 -0
  126. package/dist/tui/trust-dialog.d.ts +51 -0
  127. package/dist/tui/trust-dialog.js +127 -0
  128. package/dist/tui/types.d.ts +189 -0
  129. package/dist/tui/types.js +5 -0
  130. package/dist/tui/viewport/selection.d.ts +27 -0
  131. package/dist/tui/viewport/selection.js +79 -0
  132. package/dist/tui/viewport/sources.d.ts +29 -0
  133. package/dist/tui/viewport/sources.js +592 -0
  134. package/dist/tui/viewport/viewport.d.ts +12 -0
  135. package/dist/tui/viewport/viewport.js +91 -0
  136. package/dist/tui-input-history.d.ts +23 -0
  137. package/dist/tui-input-history.js +42 -0
  138. package/dist/tui-input-router.d.ts +24 -0
  139. package/dist/tui-input-router.js +115 -0
  140. package/dist/tui.d.ts +15 -0
  141. package/dist/tui.js +13 -0
  142. package/dist/types.d.ts +467 -0
  143. package/dist/types.js +7 -0
  144. package/package.json +58 -4
@@ -0,0 +1,467 @@
1
+ /**
2
+ * CLI 宿主层的本地协议类型。
3
+ *
4
+ * 这些类型只描述 argv、slash action、事件投影和输出格式,不能替代 Core
5
+ * Runtime 的领域类型,也不携带审批冻结凭证或完整 checkpoint。
6
+ */
7
+ import type { AgentEvent, AgentRuntime, AgentTerminationView, ApprovalDisplayFacts, ContextUsageView, JobListView, JobReadView, JobView, RecoverableTurnView, TodoCounts, TodoItem, ToolDisplayFacts } from "@autopilot-agent/core";
8
+ import type { AgentPresentationState } from "@autopilot-agent/presentation";
9
+ /** CLI 当前支持的 Session 工具权限模式;与 Core 的公共枚举保持同值域。 */
10
+ export type CliPermissionMode = "ask" | "auto_approve" | "full_access";
11
+ /** CLI 输出模式;interactive 在 Step 5.4 才接入 Ink。 */
12
+ export type CliOutputFormat = "interactive" | "text" | "jsonl";
13
+ /** CLI 命令语法树;命令本身不包含宿主状态根或 Runtime 实例。 */
14
+ export type CliCommand = {
15
+ type: "project_open";
16
+ path?: string;
17
+ } | {
18
+ type: "project_list";
19
+ } | {
20
+ type: "project_current";
21
+ } | {
22
+ type: "project_remove";
23
+ workspaceId: string;
24
+ } | {
25
+ type: "trust_status";
26
+ } | {
27
+ type: "trust_revoke";
28
+ } | {
29
+ type: "session_list";
30
+ } | {
31
+ type: "session_rename";
32
+ sessionId: string;
33
+ title: string;
34
+ } | {
35
+ type: "session_delete";
36
+ sessionId: string;
37
+ yes: boolean;
38
+ } | {
39
+ type: "config_show";
40
+ scope: "user" | "project" | "local";
41
+ } | {
42
+ type: "config_get";
43
+ scope: "user" | "project" | "local";
44
+ key: string;
45
+ } | {
46
+ type: "config_set";
47
+ scope: "user" | "project" | "local";
48
+ key: string;
49
+ value: string;
50
+ } | {
51
+ type: "mcp_list";
52
+ } | {
53
+ type: "mcp_approve";
54
+ serverName: string;
55
+ yes: boolean;
56
+ } | {
57
+ type: "mcp_revoke";
58
+ serverName: string;
59
+ } | {
60
+ type: "job_list";
61
+ } | {
62
+ type: "job_show";
63
+ jobId: string;
64
+ } | {
65
+ type: "job_output";
66
+ jobId: string;
67
+ } | {
68
+ type: "job_kill";
69
+ jobId: string;
70
+ } | {
71
+ type: "undo";
72
+ sessionId: string;
73
+ yes: boolean;
74
+ } | {
75
+ type: "doctor";
76
+ connectivity: boolean;
77
+ } | {
78
+ type: "sandbox_status";
79
+ } | {
80
+ type: "sandbox_setup";
81
+ yes: boolean;
82
+ } | {
83
+ type: "chat";
84
+ prompt?: string;
85
+ sessionId?: string;
86
+ output: CliOutputFormat;
87
+ } | {
88
+ type: "resume";
89
+ sessionId?: string;
90
+ output: CliOutputFormat;
91
+ };
92
+ /** CLI Action;审批 Action 只携带宿主决定,不携带冻结调用字段。 */
93
+ export type CliAction =
94
+ /** delivery 只在已有活动 Turn 时生效;省略时与 Web 一致,默认 steer。 */
95
+ {
96
+ type: "submit_prompt";
97
+ content: string;
98
+ delivery?: "steer" | "queue";
99
+ } | {
100
+ type: "approve";
101
+ decision: "allow_once" | "allow_session" | "allow_workspace" | "deny";
102
+ } | {
103
+ type: "compact";
104
+ } | {
105
+ type: "show_context";
106
+ all: boolean;
107
+ } | {
108
+ type: "select_skill";
109
+ skill: string;
110
+ } | {
111
+ type: "toggle_skill";
112
+ skill: string;
113
+ } | {
114
+ type: "list_skills";
115
+ } | {
116
+ type: "open_permissions";
117
+ } | {
118
+ type: "set_permission_mode";
119
+ mode: CliPermissionMode;
120
+ }
121
+ /** 查看当前 Session/Workspace 可见的持久授权(Talk-Plan1013 Stage 4)。 */
122
+ | {
123
+ type: "list_permission_grants";
124
+ }
125
+ /** 按 toolName+constraint 精确撤销一条持久授权;constraint 由用户从列表复制,不做模糊匹配。 */
126
+ | {
127
+ type: "revoke_permission_grant";
128
+ constraint: string;
129
+ } | {
130
+ type: "open_model_picker";
131
+ } | {
132
+ type: "set_model";
133
+ provider?: string;
134
+ modelId: string;
135
+ } | {
136
+ type: "open_effort_picker";
137
+ } | {
138
+ type: "set_effort";
139
+ effort: string;
140
+ } | {
141
+ type: "list_jobs";
142
+ } | {
143
+ type: "show_job";
144
+ jobId: string;
145
+ } | {
146
+ type: "read_job_output";
147
+ jobId: string;
148
+ } | {
149
+ type: "stop_job";
150
+ jobId: string;
151
+ } | {
152
+ type: "cancel_turn";
153
+ } | {
154
+ type: "undo_preview";
155
+ } | {
156
+ type: "undo_confirm";
157
+ } | {
158
+ type: "exit";
159
+ };
160
+ /** argv 中属于 Composition Root 的宿主配置;不进入 Core 领域输入。 */
161
+ export interface CliHostOptions {
162
+ stateRoot?: string;
163
+ trustRoot?: string;
164
+ workspaceRoot?: string;
165
+ }
166
+ /** parser 的完整结果;host 配置与命令树分开,避免把状态根当作 prompt。 */
167
+ export interface CliInvocation {
168
+ command: CliCommand;
169
+ host: CliHostOptions;
170
+ }
171
+ /** argv parser 的确定性结果。 */
172
+ export type CliParseResult = {
173
+ kind: "help";
174
+ text: string;
175
+ } | {
176
+ kind: "command";
177
+ invocation: CliInvocation;
178
+ } | {
179
+ kind: "error";
180
+ message: string;
181
+ };
182
+ /** slash action parser 的确定性结果。 */
183
+ export type CliActionParseResult = {
184
+ kind: "action";
185
+ action: CliAction;
186
+ } | {
187
+ kind: "error";
188
+ message: string;
189
+ };
190
+ /** 交互 TTY 中用于 slash 补全的安全命令摘要。 */
191
+ export interface CliSlashCommand {
192
+ name: string;
193
+ usage: string;
194
+ description: string;
195
+ }
196
+ /** CLI 固定退出码。 */
197
+ export type CliExitCode = 0 | 1 | 2 | 130 | 143;
198
+ /** Controller 在宿主边界创建的本地事件信封。 */
199
+ export interface CliEventEnvelope {
200
+ seq: number;
201
+ sessionId?: string;
202
+ turnId: string;
203
+ timestamp: string;
204
+ event: AgentEvent;
205
+ }
206
+ /** Controller 使用的最小 Core Runtime 依赖;不包含 Web 或 Core private 类型。inbox 用于 Turn 终态后领取遗留排队输入。 */
207
+ export type CliRuntime = Pick<AgentRuntime, "turns" | "projects" | "sessions" | "approvals" | "inbox" | "jobs" | "undo">;
208
+ /** TUI/Plain 共用的当前 Session Job 安全视图;不携带命令、路径、PID 或 owner。 */
209
+ export type CliJobView = {
210
+ mode: "list";
211
+ list: JobListView;
212
+ } | {
213
+ mode: "detail";
214
+ job: JobView;
215
+ output?: JobReadView["output"];
216
+ };
217
+ /** CLI Controller 可注入的宿主 Skill 解析器;只返回身份和内容哈希。 */
218
+ export type CliSkillResolver = (skill: string) => Promise<{
219
+ skillId: string;
220
+ contentHash: string;
221
+ }>;
222
+ /** CLI 可展示的 Skill 安全摘要;正文和 allowedTools 不进入宿主视图。 */
223
+ export interface CliSkillSummary {
224
+ qualifiedName: string;
225
+ displayName: string;
226
+ description: string;
227
+ selected?: boolean;
228
+ }
229
+ /** CLI 权限 picker 的安全展示项;不携带工具调用或审批凭证。 */
230
+ export interface CliPermissionOption {
231
+ mode: CliPermissionMode;
232
+ label: string;
233
+ description: string;
234
+ selected: boolean;
235
+ }
236
+ /** CLI 模型 picker 的安全展示项;由已解析的 CC settings allowlist 生成。 */
237
+ export interface CliModelOption {
238
+ provider: string;
239
+ modelId: string;
240
+ selected: boolean;
241
+ }
242
+ /** CLI 推理强度 picker 的安全展示项;只包含可向 firstParty 端点明确请求的 CC 值。 */
243
+ export interface CliEffortOption {
244
+ effort: string;
245
+ selected: boolean;
246
+ }
247
+ /** CLI 状态栏使用的脱敏 Session/Turn 配置视图。 */
248
+ export interface CliStatusView {
249
+ model: string;
250
+ effort: string;
251
+ permissionMode: CliPermissionMode;
252
+ workspaceRoot?: string;
253
+ source: "runtime_default" | "session_default" | "turn_frozen";
254
+ /** 活动 Turn 存在时,Session 默认权限若不同则提示下轮值。 */
255
+ nextPermissionMode?: CliPermissionMode;
256
+ /** 活动 Turn 存在时显示已保存、但尚未冻结到当前 Turn 的下一轮模型。 */
257
+ nextModel?: string;
258
+ /** 活动 Turn 存在时显示已保存、但尚未冻结到当前 Turn 的下一轮推理强度。 */
259
+ nextEffort?: string;
260
+ /** 当前 Session 的上下文用量安全 DTO;null 表示无数据(unknown),省略表示无法查询(无 Runtime/Session)。 */
261
+ contextUsage?: ContextUsageView | null;
262
+ }
263
+ /** Composition Root 提供给 Controller 的热更新安全默认值;不携带 Provider 部署或凭据字段。 */
264
+ export interface CliRuntimeStatusDefaults {
265
+ modelRef?: {
266
+ provider: string;
267
+ modelId: string;
268
+ };
269
+ reasoningProfile?: {
270
+ effort: string;
271
+ };
272
+ permissionMode?: CliPermissionMode;
273
+ modelCapabilities?: ReadonlyArray<{
274
+ provider: string;
275
+ modelId: string;
276
+ requestableEfforts: readonly string[];
277
+ }>;
278
+ }
279
+ /** CLI Composition Root 提供的 Skill catalog 只读查询。 */
280
+ export type CliSkillCatalogLister = () => Promise<CliSkillSummary[]>;
281
+ /** Controller 将安全公开事件通知给 TUI 等宿主视图;回调只接收投影后的字段。 */
282
+ export type CliEventListener = (event: CliPublicEvent, projection: CliProjection) => void;
283
+ /** Controller 在自动启动 queue Turn 前通知 TUI;只携带可见 prompt 和新 Turn 身份。 */
284
+ export interface CliQueuedInputStarted {
285
+ inputId: string;
286
+ turnId: string;
287
+ content: string;
288
+ delivery: "queue";
289
+ }
290
+ /** 接收 queue 输入已被消费并将进入新 Turn 的宿主回调。 */
291
+ export type CliQueuedInputStartedListener = (input: CliQueuedInputStarted) => void;
292
+ /** CLI 恢复入口使用的 Core 脱敏 DTO 别名。 */
293
+ export type CliRecoverableTurnView = RecoverableTurnView;
294
+ /** Renderer 的纯输出接口;实现不能读取 Store、checkpoint 或 Runtime。 */
295
+ export interface CliRenderer {
296
+ readonly format: "text" | "jsonl";
297
+ render(event: CliPublicEvent): string;
298
+ }
299
+ /** Renderer 可见的安全事件联合类型。 */
300
+ export type CliPublicEvent = {
301
+ type: "turn_started";
302
+ seq: number;
303
+ turnId: string;
304
+ stepCount: number;
305
+ } | {
306
+ type: "reasoning_summary";
307
+ seq: number;
308
+ turnId: string;
309
+ summary: string;
310
+ } | {
311
+ type: "reasoning_hidden";
312
+ seq: number;
313
+ turnId: string;
314
+ } | {
315
+ type: "answer_delta";
316
+ seq: number;
317
+ turnId: string;
318
+ delta: string;
319
+ } | {
320
+ type: "answer_reset";
321
+ seq: number;
322
+ turnId: string;
323
+ } | {
324
+ type: "tool_started";
325
+ seq: number;
326
+ turnId: string;
327
+ callId?: string;
328
+ toolName: string;
329
+ summary: string;
330
+ display?: ToolDisplayFacts;
331
+ } | {
332
+ type: "tool_progress";
333
+ seq: number;
334
+ turnId: string;
335
+ callId?: string;
336
+ toolName: string;
337
+ tail: string;
338
+ } | {
339
+ type: "tool_result";
340
+ seq: number;
341
+ turnId: string;
342
+ callId?: string;
343
+ toolName: string;
344
+ status: "success" | "approval_required" | "question_required" | "denied" | "error" | "cancelled" | "timeout";
345
+ summary: string;
346
+ errorCode?: string;
347
+ /** 仅成功 edit_file 的最终 unified diff;来自 Core 已限长的公开事件。 */
348
+ diff?: string;
349
+ /** Core 生成的安全展示事实;Plain/JSONL 保留既有扁平字段。 */
350
+ display?: ToolDisplayFacts;
351
+ } | {
352
+ type: "approval_required";
353
+ seq: number;
354
+ turnId: string;
355
+ approvalId: string;
356
+ callId?: string;
357
+ toolName: string;
358
+ reason: string;
359
+ risk?: string;
360
+ /** 冻结审批约束;Plain/JSONL 与历史行据此区分普通批准与无沙箱批准。 */
361
+ constraint?: string;
362
+ allowedDecisions?: Array<Extract<CliAction, {
363
+ type: "approve";
364
+ }>["decision"]>;
365
+ display?: ApprovalDisplayFacts;
366
+ } | {
367
+ type: "input_queued";
368
+ seq: number;
369
+ turnId: string;
370
+ inputId: string;
371
+ delivery: "steer" | "queue";
372
+ } | {
373
+ type: "todo_updated";
374
+ seq: number;
375
+ turnId: string;
376
+ todos: TodoItem[];
377
+ counts: TodoCounts;
378
+ } | {
379
+ type: "input_joined" | "input_consumed";
380
+ seq: number;
381
+ turnId: string;
382
+ inputId: string;
383
+ } | {
384
+ type: "model_recovery";
385
+ seq: number;
386
+ turnId: string;
387
+ reason: string;
388
+ attempt: number;
389
+ maxAttempts: number;
390
+ } | {
391
+ type: "context_overflow";
392
+ seq: number;
393
+ turnId: string;
394
+ } | {
395
+ type: "context_compact_started";
396
+ seq: number;
397
+ turnId: string;
398
+ } | {
399
+ type: "context_compacted";
400
+ seq: number;
401
+ turnId: string;
402
+ preTokens: number;
403
+ postTokens: number;
404
+ } | {
405
+ type: "context_compact_failed";
406
+ seq: number;
407
+ turnId: string;
408
+ } | {
409
+ type: "context_compact_circuit_open";
410
+ seq: number;
411
+ turnId: string;
412
+ } | {
413
+ type: "context_usage";
414
+ seq: number;
415
+ turnId: string;
416
+ usage: ContextUsageView | null;
417
+ } | {
418
+ type: "active_skills";
419
+ seq: number;
420
+ turnId: string;
421
+ skills: Array<{
422
+ skillId: string;
423
+ contentHash: string;
424
+ }>;
425
+ } | {
426
+ type: "status";
427
+ seq: number;
428
+ turnId: string;
429
+ status: "running" | "waiting_approval" | "waiting_user_input" | "interrupted" | "interrupted_recoverable" | "completed" | "failed" | "limit_reached";
430
+ code?: string;
431
+ reason?: string;
432
+ termination?: AgentTerminationView;
433
+ };
434
+ /** CLI 投影中的安全生命周期状态。 */
435
+ export type CliTurnStatus = "idle" | "running" | "waiting_approval" | "waiting_user_input" | "interrupted" | "interrupted_recoverable" | "completed" | "failed" | "limit_reached";
436
+ /** 投影器的状态;seenKeys 仅供本地去重,不会交给 Renderer。 */
437
+ export interface CliProjection {
438
+ turnId?: string;
439
+ status: CliTurnStatus;
440
+ /** 只复制 Core RecoverableTurnView/终态投影确认的恢复布尔值。 */
441
+ recoverable: boolean;
442
+ answer: string;
443
+ lastSeq?: number;
444
+ pendingApproval?: {
445
+ approvalId: string;
446
+ callId?: string;
447
+ toolName: string;
448
+ reason: string;
449
+ risk?: string;
450
+ /** 冻结审批约束;沙箱降级卡(no-sandbox-exec:v1)据此展示无隔离警告。 */
451
+ constraint?: string;
452
+ allowedDecisions?: Array<Extract<CliAction, {
453
+ type: "approve";
454
+ }>["decision"]>;
455
+ display?: ApprovalDisplayFacts;
456
+ };
457
+ activeSkills: Array<{
458
+ skillId: string;
459
+ contentHash: string;
460
+ }>;
461
+ events: CliPublicEvent[];
462
+ /** 最近一次 context_usage_updated 的安全 DTO;只作为状态栏刷新事实,不进入时间线。 */
463
+ contextUsage?: ContextUsageView | null;
464
+ /** 交互 TUI 的唯一 Runtime 事实来源;Plain/JSONL 继续消费 events。 */
465
+ presentation: AgentPresentationState;
466
+ seenKeys: Set<string>;
467
+ }
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * CLI 宿主层的本地协议类型。
3
+ *
4
+ * 这些类型只描述 argv、slash action、事件投影和输出格式,不能替代 Core
5
+ * Runtime 的领域类型,也不携带审批冻结凭证或完整 checkpoint。
6
+ */
7
+ export {};
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@autopilot-agent/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "publishConfig": {
5
+ "access": "public",
6
+ "registry": "https://registry.npmjs.org/"
7
+ },
8
+ "type": "module",
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "bin": {
12
+ "ap": "./dist/main.js",
13
+ "autopilot": "./dist/main.js"
14
+ },
15
+ "files": [
16
+ "dist/**/*.js",
17
+ "dist/**/*.mjs",
18
+ "dist/**/*.d.ts",
19
+ "!**/*.map",
20
+ "!**/*.{test,spec,bench}.*",
21
+ "!**/*-fixture*.*",
22
+ "!**/{test,tests,test-*,__tests__,__mocks__,contract-test,fixtures,coverage,playwright-report,test-results}/**",
23
+ "!**/{agent,agents,.agent-tests,.agents,.codex,.cursor,.idea,.vscode}/**",
24
+ "!**/{.git,.hg,.svn,.github,.gitlab}/**",
25
+ "!**/{.local,.autopilot,.cache,.npm-cache,.turbo,.next,.vite,__pycache__,node_modules,src,dist-types}/**",
26
+ "!**/*.{log,tsbuildinfo,tmp,temp,bak,orig,rej,swp,swo,pyc,pyo,tgz,tar,zip,7z,rar,db,sqlite,sqlite3,wal,shm}",
27
+ "!**/*.{pem,key,p12,pfx,crt,cer}",
28
+ "!**/{.env*,.npmrc*,.yarnrc*,.pnp.*,AGENTS.md,CLAUDE.md,.DS_Store,Thumbs.db}",
29
+ "!**/{settings.json,settings.local.json,mcp.json,credentials.json,credentials.local.json,package-lock.json,npm-shrinkwrap.json,yarn.lock,pnpm-lock.yaml,bun.lockb}",
30
+ "!**/{tsconfig*,vitest.config.*,vite.config.*,playwright.config.*,eslint.config.*,jest.config.*,turbo.json}"
31
+ ],
32
+ "engines": {
33
+ "node": ">=20.11.0 <22"
34
+ },
35
+ "scripts": {
36
+ "prepack": "npm run build && node ../../scripts/check-npm-pack.mjs apps/cli",
37
+ "build": "tsc -p tsconfig.json",
38
+ "typecheck": "tsc --noEmit -p tsconfig.json",
39
+ "lint": "eslint src test --ext .ts,.tsx",
40
+ "test": "vitest run --config vitest.config.ts",
41
+ "test:watch": "vitest --config vitest.config.ts"
42
+ },
43
+ "dependencies": {
44
+ "@autopilot-agent/adapters": "0.2.0",
45
+ "@autopilot-agent/core": "0.2.0",
46
+ "@autopilot-agent/presentation": "0.2.0",
47
+ "ink": "6.8.0",
48
+ "react": "19.2.4",
49
+ "string-width": "^8.1.1",
50
+ "wrap-ansi": "^9.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^20",
54
+ "@types/react": "19.2.0",
55
+ "ink-testing-library": "4.0.0",
56
+ "typescript": "^5",
57
+ "vitest": "^3.2.4"
58
+ },
59
+ "description": "Autopilot Agent 终端客户端;推荐安装 autopilot-agent。"
60
+ }