@autopilot-agent/cli 0.1.0 → 0.3.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 +30 -153
- package/dist/activity-animation.d.ts +6 -0
- package/dist/activity-animation.js +15 -18
- package/dist/composition-root.d.ts +31 -1
- package/dist/composition-root.js +124 -3
- package/dist/context-report.d.ts +9 -4
- package/dist/context-report.js +16 -5
- package/dist/controller.d.ts +34 -4
- package/dist/controller.js +494 -90
- package/dist/design-tokens.d.ts +4 -0
- package/dist/design-tokens.js +4 -0
- package/dist/error-diagnostics.d.ts +2 -0
- package/dist/error-diagnostics.js +3 -1
- package/dist/event-projector.d.ts +16 -2
- package/dist/event-projector.js +78 -7
- package/dist/index.d.ts +1 -1
- package/dist/main.js +142 -7
- package/dist/parser.js +511 -4
- package/dist/renderer.js +19 -3
- package/dist/session-summary.d.ts +7 -0
- package/dist/session-summary.js +25 -0
- package/dist/session-title.d.ts +5 -0
- package/dist/session-title.js +10 -0
- package/dist/termination-format.js +1 -0
- package/dist/thread-commands.d.ts +37 -0
- package/dist/thread-commands.js +233 -0
- package/dist/thread-host.d.ts +31 -0
- package/dist/thread-host.js +76 -0
- package/dist/timeline-lines.js +36 -28
- package/dist/tui/app.d.ts +22 -0
- package/dist/tui/app.js +119 -44
- package/dist/tui/approval.d.ts +5 -1
- package/dist/tui/approval.js +20 -7
- package/dist/tui/constants.d.ts +1 -1
- package/dist/tui/constants.js +1 -1
- package/dist/tui/format.d.ts +1 -1
- package/dist/tui/format.js +23 -11
- package/dist/tui/hooks/use-prompt-input.d.ts +52 -0
- package/dist/tui/hooks/use-prompt-input.js +148 -20
- package/dist/tui/hooks/use-status-view.d.ts +2 -2
- package/dist/tui/hooks/use-status-view.js +38 -11
- package/dist/tui/inline-output.d.ts +17 -0
- package/dist/tui/inline-output.js +31 -0
- package/dist/tui/input/clipboard-image.d.ts +17 -0
- package/dist/tui/input/clipboard-image.js +117 -0
- package/dist/tui/input-area.d.ts +8 -0
- package/dist/tui/input-area.js +18 -3
- package/dist/tui/lifecycle.js +2 -5
- package/dist/tui/markdown/diff.d.ts +1 -1
- package/dist/tui/markdown/diff.js +28 -1
- package/dist/tui/performance-diagnostics.js +2 -0
- package/dist/tui/prompt-input.d.ts +1 -0
- package/dist/tui/prompt-input.js +5 -3
- package/dist/tui/render-mode.d.ts +4 -4
- package/dist/tui/render-mode.js +5 -11
- package/dist/tui/run.js +37 -49
- package/dist/tui/session-manager.d.ts +115 -0
- package/dist/tui/session-manager.js +383 -0
- package/dist/tui/session-workspace.d.ts +9 -0
- package/dist/tui/session-workspace.js +383 -0
- package/dist/tui/status-line.d.ts +3 -0
- package/dist/tui/status-line.js +12 -6
- package/dist/tui/store.js +111 -53
- package/dist/tui/timeline/live.js +9 -8
- package/dist/tui/timeline/presentation-timeline.d.ts +2 -1
- package/dist/tui/timeline/presentation-timeline.js +34 -15
- package/dist/tui/timeline/progress.js +3 -2
- package/dist/tui/timeline/static-timeline.js +17 -8
- package/dist/tui/timeline/turn-items.d.ts +12 -0
- package/dist/tui/timeline/turn-items.js +28 -0
- package/dist/tui/timeline/turn.js +8 -7
- package/dist/tui/transcript.d.ts +2 -2
- package/dist/tui/transcript.js +21 -3
- package/dist/tui/trust-dialog.d.ts +3 -0
- package/dist/tui/trust-dialog.js +23 -2
- package/dist/tui/types.d.ts +23 -1
- package/dist/tui/types.js +4 -1
- package/dist/tui/viewport/sources.d.ts +2 -2
- package/dist/tui/viewport/sources.js +75 -75
- package/dist/tui/viewport/viewport.js +5 -1
- package/dist/types.d.ts +165 -2
- package/package.json +4 -4
package/dist/types.d.ts
CHANGED
|
@@ -4,12 +4,126 @@
|
|
|
4
4
|
* 这些类型只描述 argv、slash action、事件投影和输出格式,不能替代 Core
|
|
5
5
|
* Runtime 的领域类型,也不携带审批冻结凭证或完整 checkpoint。
|
|
6
6
|
*/
|
|
7
|
-
import type { AgentEvent, AgentRuntime, AgentTerminationView, ApprovalDisplayFacts, ContextUsageView, JobListView, JobReadView, JobView, RecoverableTurnView, TodoCounts, TodoItem, ToolDisplayFacts } from "@autopilot-agent/core";
|
|
7
|
+
import type { AgentEvent, AgentRuntime, AgentTerminationView, ApprovalDisplayFacts, ContextUsageView, JobListView, JobReadView, JobView, RecoverableTurnView, TodoCounts, TodoItem, ToolDisplayFacts, TurnUsageSummaryView } from "@autopilot-agent/core";
|
|
8
8
|
import type { AgentPresentationState } from "@autopilot-agent/presentation";
|
|
9
9
|
/** CLI 当前支持的 Session 工具权限模式;与 Core 的公共枚举保持同值域。 */
|
|
10
10
|
export type CliPermissionMode = "ask" | "auto_approve" | "full_access";
|
|
11
11
|
/** CLI 输出模式;interactive 在 Step 5.4 才接入 Ink。 */
|
|
12
12
|
export type CliOutputFormat = "interactive" | "text" | "jsonl";
|
|
13
|
+
/** 协作投递模式;与 Core 冻结的三种模式同值域,必须显式声明。 */
|
|
14
|
+
export type CliThreadMode = "notify" | "run" | "steer";
|
|
15
|
+
/**
|
|
16
|
+
* 协作命令语法树。
|
|
17
|
+
*
|
|
18
|
+
* 只保存不透明身份、模式与正文来源;正文、交接文档和共享板值在宿主边界读取,
|
|
19
|
+
* 组归属、幂等、容量和交付事实都由 Core 判定。
|
|
20
|
+
*/
|
|
21
|
+
export type CliThreadCommand = {
|
|
22
|
+
type: "bind_host";
|
|
23
|
+
groupId: string;
|
|
24
|
+
threadId: string;
|
|
25
|
+
expectedRevision: number;
|
|
26
|
+
executionHost: "cli-work-v1" | "web-work-v1";
|
|
27
|
+
} | {
|
|
28
|
+
type: "group_of";
|
|
29
|
+
threadId: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "group_enable";
|
|
32
|
+
requestId: string;
|
|
33
|
+
rootThreadId: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "group_disable";
|
|
36
|
+
requestId: string;
|
|
37
|
+
groupId: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "create";
|
|
40
|
+
requestId: string;
|
|
41
|
+
groupId: string;
|
|
42
|
+
parentThreadId: string;
|
|
43
|
+
title?: string;
|
|
44
|
+
roleLabel?: string;
|
|
45
|
+
modelRef?: {
|
|
46
|
+
provider: string;
|
|
47
|
+
modelId: string;
|
|
48
|
+
};
|
|
49
|
+
reasoningEffort?: "none" | "low" | "medium" | "high" | "max";
|
|
50
|
+
} | {
|
|
51
|
+
type: "associate";
|
|
52
|
+
groupId: string;
|
|
53
|
+
threadId: string;
|
|
54
|
+
requestId: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: "list";
|
|
57
|
+
groupId: string;
|
|
58
|
+
cursor?: string;
|
|
59
|
+
limit?: number;
|
|
60
|
+
} | {
|
|
61
|
+
type: "read";
|
|
62
|
+
groupId: string;
|
|
63
|
+
threadId: string;
|
|
64
|
+
cursor?: string;
|
|
65
|
+
limit?: number;
|
|
66
|
+
} | {
|
|
67
|
+
type: "send";
|
|
68
|
+
requestId: string;
|
|
69
|
+
groupId: string;
|
|
70
|
+
threadId: string;
|
|
71
|
+
mode: CliThreadMode;
|
|
72
|
+
contentSource: {
|
|
73
|
+
kind: "file";
|
|
74
|
+
path: string;
|
|
75
|
+
} | {
|
|
76
|
+
kind: "stdin";
|
|
77
|
+
};
|
|
78
|
+
replyTo?: string;
|
|
79
|
+
expectedTurnId?: string;
|
|
80
|
+
handoff?: {
|
|
81
|
+
title: string;
|
|
82
|
+
markdownFile: string;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
type: "wait";
|
|
86
|
+
groupId: string;
|
|
87
|
+
targets: Array<{
|
|
88
|
+
threadId: string;
|
|
89
|
+
taskId?: string;
|
|
90
|
+
cursor?: string;
|
|
91
|
+
}>;
|
|
92
|
+
timeoutMs: number;
|
|
93
|
+
} | {
|
|
94
|
+
type: "state_read";
|
|
95
|
+
groupId: string;
|
|
96
|
+
} | {
|
|
97
|
+
type: "state_set";
|
|
98
|
+
requestId: string;
|
|
99
|
+
groupId: string;
|
|
100
|
+
expectedRevision: number;
|
|
101
|
+
key: string;
|
|
102
|
+
value: {
|
|
103
|
+
kind: "inline";
|
|
104
|
+
json: string;
|
|
105
|
+
} | {
|
|
106
|
+
kind: "file";
|
|
107
|
+
path: string;
|
|
108
|
+
};
|
|
109
|
+
} | {
|
|
110
|
+
type: "state_remove";
|
|
111
|
+
requestId: string;
|
|
112
|
+
groupId: string;
|
|
113
|
+
expectedRevision: number;
|
|
114
|
+
key: string;
|
|
115
|
+
} | {
|
|
116
|
+
type: "interrupt";
|
|
117
|
+
requestId: string;
|
|
118
|
+
groupId: string;
|
|
119
|
+
threadId: string;
|
|
120
|
+
expectedTurnId: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: "watch";
|
|
123
|
+
groupId: string;
|
|
124
|
+
cursor?: string;
|
|
125
|
+
limit?: number;
|
|
126
|
+
};
|
|
13
127
|
/** CLI 命令语法树;命令本身不包含宿主状态根或 Runtime 实例。 */
|
|
14
128
|
export type CliCommand = {
|
|
15
129
|
type: "project_open";
|
|
@@ -79,6 +193,9 @@ export type CliCommand = {
|
|
|
79
193
|
} | {
|
|
80
194
|
type: "sandbox_setup";
|
|
81
195
|
yes: boolean;
|
|
196
|
+
} | {
|
|
197
|
+
type: "thread";
|
|
198
|
+
command: CliThreadCommand;
|
|
82
199
|
} | {
|
|
83
200
|
type: "chat";
|
|
84
201
|
prompt?: string;
|
|
@@ -96,8 +213,18 @@ export type CliAction =
|
|
|
96
213
|
type: "submit_prompt";
|
|
97
214
|
content: string;
|
|
98
215
|
delivery?: "steer" | "queue";
|
|
216
|
+
images?: Array<{
|
|
217
|
+
name: string;
|
|
218
|
+
mimeType: string;
|
|
219
|
+
bytes: Uint8Array;
|
|
220
|
+
}>;
|
|
99
221
|
} | {
|
|
100
222
|
type: "approve";
|
|
223
|
+
expected?: {
|
|
224
|
+
sessionId: string;
|
|
225
|
+
turnId: string;
|
|
226
|
+
approvalId: string;
|
|
227
|
+
};
|
|
101
228
|
decision: "allow_once" | "allow_session" | "allow_workspace" | "deny";
|
|
102
229
|
} | {
|
|
103
230
|
type: "compact";
|
|
@@ -117,6 +244,15 @@ export type CliAction =
|
|
|
117
244
|
} | {
|
|
118
245
|
type: "set_permission_mode";
|
|
119
246
|
mode: CliPermissionMode;
|
|
247
|
+
}
|
|
248
|
+
/** 查看当前 Session/Workspace 可见的持久授权(Talk-Plan1013 Stage 4)。 */
|
|
249
|
+
| {
|
|
250
|
+
type: "list_permission_grants";
|
|
251
|
+
}
|
|
252
|
+
/** 按 toolName+constraint 精确撤销一条持久授权;constraint 由用户从列表复制,不做模糊匹配。 */
|
|
253
|
+
| {
|
|
254
|
+
type: "revoke_permission_grant";
|
|
255
|
+
constraint: string;
|
|
120
256
|
} | {
|
|
121
257
|
type: "open_model_picker";
|
|
122
258
|
} | {
|
|
@@ -139,6 +275,8 @@ export type CliAction =
|
|
|
139
275
|
} | {
|
|
140
276
|
type: "stop_job";
|
|
141
277
|
jobId: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: "resume";
|
|
142
280
|
} | {
|
|
143
281
|
type: "cancel_turn";
|
|
144
282
|
} | {
|
|
@@ -195,7 +333,7 @@ export interface CliEventEnvelope {
|
|
|
195
333
|
event: AgentEvent;
|
|
196
334
|
}
|
|
197
335
|
/** Controller 使用的最小 Core Runtime 依赖;不包含 Web 或 Core private 类型。inbox 用于 Turn 终态后领取遗留排队输入。 */
|
|
198
|
-
export type CliRuntime = Pick<AgentRuntime, "turns" | "projects" | "sessions" | "approvals" | "inbox" | "jobs" | "undo"
|
|
336
|
+
export type CliRuntime = Pick<AgentRuntime, "turns" | "projects" | "sessions" | "approvals" | "inbox" | "jobs" | "undo"> & Partial<Pick<AgentRuntime, "questions">>;
|
|
199
337
|
/** TUI/Plain 共用的当前 Session Job 安全视图;不携带命令、路径、PID 或 owner。 */
|
|
200
338
|
export type CliJobView = {
|
|
201
339
|
mode: "list";
|
|
@@ -250,6 +388,8 @@ export interface CliStatusView {
|
|
|
250
388
|
nextEffort?: string;
|
|
251
389
|
/** 当前 Session 的上下文用量安全 DTO;null 表示无数据(unknown),省略表示无法查询(无 Runtime/Session)。 */
|
|
252
390
|
contextUsage?: ContextUsageView | null;
|
|
391
|
+
/** 最近 Turn 的累计用量安全 DTO(输入/输出/总量与执行段耗时);null 表示无数据(unknown),省略表示无法查询。 */
|
|
392
|
+
turnUsage?: TurnUsageSummaryView | null;
|
|
253
393
|
}
|
|
254
394
|
/** Composition Root 提供给 Controller 的热更新安全默认值;不携带 Provider 部署或凭据字段。 */
|
|
255
395
|
export interface CliRuntimeStatusDefaults {
|
|
@@ -289,6 +429,14 @@ export interface CliRenderer {
|
|
|
289
429
|
}
|
|
290
430
|
/** Renderer 可见的安全事件联合类型。 */
|
|
291
431
|
export type CliPublicEvent = {
|
|
432
|
+
type: "thread_wait";
|
|
433
|
+
seq: number;
|
|
434
|
+
turnId: string;
|
|
435
|
+
phase: "waiting" | "processing" | "none";
|
|
436
|
+
pending: number;
|
|
437
|
+
running: number;
|
|
438
|
+
approvals: number;
|
|
439
|
+
} | {
|
|
292
440
|
type: "turn_started";
|
|
293
441
|
seq: number;
|
|
294
442
|
turnId: string;
|
|
@@ -348,6 +496,8 @@ export type CliPublicEvent = {
|
|
|
348
496
|
toolName: string;
|
|
349
497
|
reason: string;
|
|
350
498
|
risk?: string;
|
|
499
|
+
/** 冻结审批约束;Plain/JSONL 与历史行据此区分普通批准与无沙箱批准。 */
|
|
500
|
+
constraint?: string;
|
|
351
501
|
allowedDecisions?: Array<Extract<CliAction, {
|
|
352
502
|
type: "approve";
|
|
353
503
|
}>["decision"]>;
|
|
@@ -418,6 +568,9 @@ export type CliPublicEvent = {
|
|
|
418
568
|
status: "running" | "waiting_approval" | "waiting_user_input" | "interrupted" | "interrupted_recoverable" | "completed" | "failed" | "limit_reached";
|
|
419
569
|
code?: string;
|
|
420
570
|
reason?: string;
|
|
571
|
+
feedbackId?: string;
|
|
572
|
+
providerHttpStatus?: number;
|
|
573
|
+
providerFailureDetail?: string;
|
|
421
574
|
termination?: AgentTerminationView;
|
|
422
575
|
};
|
|
423
576
|
/** CLI 投影中的安全生命周期状态。 */
|
|
@@ -425,7 +578,15 @@ export type CliTurnStatus = "idle" | "running" | "waiting_approval" | "waiting_u
|
|
|
425
578
|
/** 投影器的状态;seenKeys 仅供本地去重,不会交给 Renderer。 */
|
|
426
579
|
export interface CliProjection {
|
|
427
580
|
turnId?: string;
|
|
581
|
+
/** 当前历史问题的受信请求身份,输入在异步校验前冻结此值。 */
|
|
582
|
+
questionRequestId?: string;
|
|
428
583
|
status: CliTurnStatus;
|
|
584
|
+
threadWait?: {
|
|
585
|
+
phase: "waiting" | "processing";
|
|
586
|
+
pending: number;
|
|
587
|
+
running: number;
|
|
588
|
+
approvals: number;
|
|
589
|
+
};
|
|
429
590
|
/** 只复制 Core RecoverableTurnView/终态投影确认的恢复布尔值。 */
|
|
430
591
|
recoverable: boolean;
|
|
431
592
|
answer: string;
|
|
@@ -436,6 +597,8 @@ export interface CliProjection {
|
|
|
436
597
|
toolName: string;
|
|
437
598
|
reason: string;
|
|
438
599
|
risk?: string;
|
|
600
|
+
/** 冻结审批约束;沙箱降级卡(no-sandbox-exec:v1)据此展示无隔离警告。 */
|
|
601
|
+
constraint?: string;
|
|
439
602
|
allowedDecisions?: Array<Extract<CliAction, {
|
|
440
603
|
type: "approve";
|
|
441
604
|
}>["decision"]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autopilot-agent/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"test:watch": "vitest --config vitest.config.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@autopilot-agent/adapters": "0.
|
|
45
|
-
"@autopilot-agent/core": "0.
|
|
46
|
-
"@autopilot-agent/presentation": "0.
|
|
44
|
+
"@autopilot-agent/adapters": "0.3.0",
|
|
45
|
+
"@autopilot-agent/core": "0.3.0",
|
|
46
|
+
"@autopilot-agent/presentation": "0.3.0",
|
|
47
47
|
"ink": "6.8.0",
|
|
48
48
|
"react": "19.2.4",
|
|
49
49
|
"string-width": "^8.1.1",
|