@autopilot-agent/cli 0.2.0 → 0.4.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 (110) hide show
  1. package/README.md +15 -6
  2. package/dist/activity-animation.d.ts +5 -0
  3. package/dist/activity-animation.js +13 -17
  4. package/dist/browser-client.d.ts +14 -0
  5. package/dist/browser-client.js +156 -0
  6. package/dist/composition-root.d.ts +41 -1
  7. package/dist/composition-root.js +141 -14
  8. package/dist/context-report.d.ts +9 -4
  9. package/dist/context-report.js +15 -3
  10. package/dist/controller.d.ts +81 -4
  11. package/dist/controller.js +468 -98
  12. package/dist/design-tokens.d.ts +7 -2
  13. package/dist/design-tokens.js +11 -3
  14. package/dist/desktop-status.d.ts +35 -0
  15. package/dist/desktop-status.js +304 -0
  16. package/dist/error-diagnostics.d.ts +2 -0
  17. package/dist/error-diagnostics.js +3 -1
  18. package/dist/event-projector.d.ts +16 -2
  19. package/dist/event-projector.js +74 -5
  20. package/dist/file-mention-budget.d.ts +16 -0
  21. package/dist/file-mention-budget.js +82 -0
  22. package/dist/file-mention-context.d.ts +26 -1
  23. package/dist/file-mention-context.js +70 -22
  24. package/dist/index.d.ts +1 -1
  25. package/dist/main.d.ts +3 -0
  26. package/dist/main.js +213 -12
  27. package/dist/managed-attach.d.ts +3 -0
  28. package/dist/managed-attach.js +132 -0
  29. package/dist/managed-controller.d.ts +49 -0
  30. package/dist/managed-controller.js +171 -0
  31. package/dist/orchestration-templates.d.ts +27 -0
  32. package/dist/orchestration-templates.js +20 -0
  33. package/dist/parser.d.ts +1 -1
  34. package/dist/parser.js +510 -2
  35. package/dist/renderer.js +3 -1
  36. package/dist/session-summary.d.ts +7 -0
  37. package/dist/session-summary.js +25 -0
  38. package/dist/session-title.d.ts +5 -0
  39. package/dist/session-title.js +10 -0
  40. package/dist/thread-commands.d.ts +37 -0
  41. package/dist/thread-commands.js +233 -0
  42. package/dist/thread-host.d.ts +36 -0
  43. package/dist/thread-host.js +79 -0
  44. package/dist/timeline-lines.js +36 -28
  45. package/dist/tui/app.d.ts +22 -0
  46. package/dist/tui/app.js +179 -43
  47. package/dist/tui/approval.d.ts +4 -0
  48. package/dist/tui/approval.js +13 -4
  49. package/dist/tui/brand/brand-header.d.ts +1 -3
  50. package/dist/tui/brand/brand-header.js +6 -8
  51. package/dist/tui/brand/logo.d.ts +3 -0
  52. package/dist/tui/brand/logo.js +89 -0
  53. package/dist/tui/brand/startup.d.ts +18 -0
  54. package/dist/tui/brand/startup.js +136 -0
  55. package/dist/tui/constants.d.ts +1 -1
  56. package/dist/tui/constants.js +1 -1
  57. package/dist/tui/context.js +1 -3
  58. package/dist/tui/desktop-resize.d.ts +9 -0
  59. package/dist/tui/desktop-resize.js +95 -0
  60. package/dist/tui/format.d.ts +1 -1
  61. package/dist/tui/format.js +19 -9
  62. package/dist/tui/hooks/use-file-mention-index.js +9 -4
  63. package/dist/tui/hooks/use-prompt-input.d.ts +54 -1
  64. package/dist/tui/hooks/use-prompt-input.js +159 -26
  65. package/dist/tui/hooks/use-status-view.d.ts +2 -2
  66. package/dist/tui/hooks/use-status-view.js +38 -11
  67. package/dist/tui/hooks/use-viewport.d.ts +2 -1
  68. package/dist/tui/hooks/use-viewport.js +15 -8
  69. package/dist/tui/inline-output.d.ts +17 -0
  70. package/dist/tui/inline-output.js +31 -0
  71. package/dist/tui/input/clipboard-image.d.ts +17 -0
  72. package/dist/tui/input/clipboard-image.js +117 -0
  73. package/dist/tui/input-area.d.ts +12 -1
  74. package/dist/tui/input-area.js +28 -8
  75. package/dist/tui/lifecycle.d.ts +1 -1
  76. package/dist/tui/lifecycle.js +84 -16
  77. package/dist/tui/markdown/diff.d.ts +1 -1
  78. package/dist/tui/markdown/diff.js +28 -1
  79. package/dist/tui/performance-diagnostics.js +2 -0
  80. package/dist/tui/pickers/permission.js +1 -1
  81. package/dist/tui/pickers/slash.d.ts +11 -2
  82. package/dist/tui/pickers/slash.js +21 -7
  83. package/dist/tui/prompt-input.d.ts +2 -0
  84. package/dist/tui/prompt-input.js +6 -4
  85. package/dist/tui/render-mode.d.ts +8 -4
  86. package/dist/tui/render-mode.js +17 -11
  87. package/dist/tui/run.js +53 -55
  88. package/dist/tui/session-manager.d.ts +116 -0
  89. package/dist/tui/session-manager.js +384 -0
  90. package/dist/tui/session-workspace.d.ts +9 -0
  91. package/dist/tui/session-workspace.js +383 -0
  92. package/dist/tui/status-line.d.ts +4 -0
  93. package/dist/tui/status-line.js +34 -13
  94. package/dist/tui/store.d.ts +3 -1
  95. package/dist/tui/store.js +60 -14
  96. package/dist/tui/timeline/live.js +2 -3
  97. package/dist/tui/timeline/progress.js +3 -2
  98. package/dist/tui/timeline/static-timeline.js +1 -2
  99. package/dist/tui/timeline/turn.js +3 -2
  100. package/dist/tui/transcript.d.ts +2 -1
  101. package/dist/tui/transcript.js +43 -5
  102. package/dist/tui/trust-dialog.d.ts +3 -0
  103. package/dist/tui/trust-dialog.js +23 -2
  104. package/dist/tui/types.d.ts +18 -1
  105. package/dist/tui/types.js +4 -1
  106. package/dist/tui/viewport/selection.d.ts +2 -2
  107. package/dist/tui/viewport/selection.js +13 -6
  108. package/dist/tui/viewport/sources.js +13 -14
  109. package/dist/types.d.ts +160 -3
  110. package/package.json +4 -4
@@ -0,0 +1,82 @@
1
+ /** CLI 共用的 @ 文件预算,始终先为已核验的路径预留空间。 */
2
+ /** 交互提交的原文和文件上下文共用软预算,原文可以超出并保持原样。 */
3
+ const FILE_MENTION_CONTEXT_BYTES = 32 * 1024;
4
+ /** 生成普通 CLI 的模型输入,也是两种交互入口计算共同预算的格式。 */
5
+ export function formatFileMentionContent(content, sections) {
6
+ if (!sections?.length)
7
+ return content;
8
+ const partial = sections.some(function incomplete(section) { return section.excerpt === undefined || section.truncated === true; });
9
+ const block = [
10
+ "<system-reminder>",
11
+ partial ? "用户通过 @ 引用了以下工作区文件,缺少的内容可按路径读取,预览可直接使用路径:" : "用户通过 @ 引用了以下工作区文件,内容已直接附加:",
12
+ ...sections.map(function renderSection(section) {
13
+ if (section.excerpt === undefined)
14
+ return `--- @${section.path} (仅路径) ---`;
15
+ const label = section.truncated ? "摘录已截断" : section.label;
16
+ return `--- @${section.path} (${label}) ---\n${section.excerpt}`;
17
+ }),
18
+ "</system-reminder>",
19
+ ].join("\n");
20
+ return `${content}\n\n${block}`;
21
+ }
22
+ /** 对原文和引用应用共同软预算,原文始终保留。 */
23
+ export function fitFileMentionContext(content, sections) {
24
+ if (!sections?.length)
25
+ return undefined;
26
+ /** 普通交互按实际发送的 UTF-8 文本计算。 */
27
+ function fits([candidate]) {
28
+ return Buffer.byteLength(formatFileMentionContent(content, candidate), "utf8") <= FILE_MENTION_CONTEXT_BYTES;
29
+ }
30
+ return fits([sections]) ? sections : fitFileMentionReferences([sections], fits)[0];
31
+ }
32
+ /** 先装入各组路径,再按顺序给摘录分配剩余空间,预算由实际输出格式计算。 */
33
+ export function fitFileMentionReferences(groups, fits) {
34
+ const references = groups.map(function empty() { return undefined; });
35
+ const excerpts = [];
36
+ for (const [index, group] of groups.entries()) {
37
+ if (!group?.length)
38
+ continue;
39
+ const selected = [];
40
+ references[index] = selected;
41
+ for (const source of group) {
42
+ const reference = { path: source.path };
43
+ selected.push(reference);
44
+ if (fits(references))
45
+ excerpts.push({ reference, source });
46
+ else
47
+ selected.pop();
48
+ }
49
+ if (!selected.length)
50
+ references[index] = undefined;
51
+ }
52
+ for (const { reference, source } of excerpts) {
53
+ if (source.excerpt === undefined)
54
+ continue;
55
+ reference.excerpt = source.excerpt;
56
+ reference.label = source.label;
57
+ reference.truncated = source.truncated;
58
+ if (fits(references))
59
+ continue;
60
+ delete reference.label;
61
+ reference.truncated = true;
62
+ // 按 Unicode 码点查找能装入实际输出的最长前缀。
63
+ const characters = Array.from(source.excerpt);
64
+ let start = 0;
65
+ let end = characters.length;
66
+ while (start < end) {
67
+ const length = Math.ceil((start + end) / 2);
68
+ reference.excerpt = characters.slice(0, length).join("");
69
+ if (fits(references))
70
+ start = length;
71
+ else
72
+ end = length - 1;
73
+ }
74
+ if (start)
75
+ reference.excerpt = characters.slice(0, start).join("");
76
+ else {
77
+ delete reference.excerpt;
78
+ delete reference.truncated;
79
+ }
80
+ }
81
+ return references;
82
+ }
@@ -3,8 +3,11 @@
3
3
  * 列目录一层,把有界内容以 `<system-reminder>` 附加块按出现顺序拼回 content;
4
4
  * 失败路径(未找到/越界/过大/读取失败)降级为 notice,不阻断提交。
5
5
  */
6
+ import { type FileMentionReference } from "./file-mention-budget.js";
6
7
  /** resolveFileMentionContext 依赖的最小文件系统接缝;测试可注入受控实现。 */
7
8
  export interface FileMentionFs {
9
+ /** 返回现存路径的真实绝对路径,解析失败时抛错。 */
10
+ realpath(absolutePath: string): Promise<string>;
8
11
  /** 返回目标的存在性形态与字节大小;目标不存在时抛错。 */
9
12
  stat(absolutePath: string): Promise<{
10
13
  isFile: boolean;
@@ -26,9 +29,31 @@ export interface ResolvedFileMentionContext {
26
29
  /** 面向用户的失败提示,按 mention 出现顺序。 */
27
30
  notices: string[];
28
31
  }
32
+ /** 分开记录核验后的相对路径和摘录,供受管宿主按传输预算选用。 */
33
+ export interface FileMentionSection {
34
+ path: string;
35
+ label: string;
36
+ excerpt: string;
37
+ }
29
38
  /** 从 prompt 原文提取 @ 引用的相对路径;`@` 必须位于行首或空白后,去重保序,`\` 归一为 `/`。 */
30
39
  export declare function extractFileMentions(content: string): string[];
31
- /** 解析 prompt 中的全部 @ 引用并构造增强 content;至少一个引用成功时在原文后追加附加块。 */
40
+ /** 宿主传入已受信的真实根;拒绝随后将该路径改指其他目录的链接。 */
41
+ export declare function resolveTrustedFileMentionRoot(workspaceRoot: string, fs?: FileMentionFs): Promise<string>;
42
+ /** 解析并核验 prompt 中的 @ 引用,保留它们的出现顺序。 */
43
+ export declare function resolveFileMentionSections(content: string, workspaceRoot: string, options?: {
44
+ fs?: FileMentionFs;
45
+ }): Promise<{
46
+ sections: FileMentionSection[];
47
+ notices: string[];
48
+ }>;
49
+ /** 在共同预算内准备核验过的引用,供本地 CLI 或编排 Worker 使用。 */
50
+ export declare function prepareFileMentionContext(content: string, workspaceRoot: string, options?: {
51
+ fs?: FileMentionFs;
52
+ }): Promise<{
53
+ references: readonly FileMentionReference[] | undefined;
54
+ notices: string[];
55
+ }>;
56
+ /** 普通交互 CLI 在提交前将共同预算内的引用附加到用户原文。 */
32
57
  export declare function resolveFileMentionContext(content: string, workspaceRoot: string, options?: {
33
58
  fs?: FileMentionFs;
34
59
  }): Promise<ResolvedFileMentionContext>;
@@ -3,8 +3,9 @@
3
3
  * 列目录一层,把有界内容以 `<system-reminder>` 附加块按出现顺序拼回 content;
4
4
  * 失败路径(未找到/越界/过大/读取失败)降级为 notice,不阻断提交。
5
5
  */
6
- import { readFile as nodeReadFile, readdir as nodeReaddir, stat as nodeStat } from "node:fs/promises";
6
+ import { readFile as nodeReadFile, readdir as nodeReaddir, realpath as nodeRealpath, stat as nodeStat } from "node:fs/promises";
7
7
  import path from "node:path";
8
+ import { fitFileMentionContext, formatFileMentionContent } from "./file-mention-budget.js";
8
9
  import { FILE_MENTION_TOKEN_CHARACTER } from "./tui/input/file-mention.js";
9
10
  /** 单文件扫描上限(对齐 core read_file 的 8MiB 扫描上限),超出直接拒绝。 */
10
11
  const FILE_MENTION_SIZE_LIMIT = 8 * 1024 * 1024;
@@ -16,13 +17,17 @@ const FILE_MENTION_BYTES_LIMIT = 256 * 1024;
16
17
  const FILE_MENTION_DIRECTORY_LIMIT = 100;
17
18
  /** 默认接缝实现:直接使用 node:fs/promises。 */
18
19
  const nodeFileMentionFs = {
20
+ realpath: nodeRealpath,
21
+ /** 获取目标类型及文件大小供读取限额检查。 */
19
22
  async stat(absolutePath) {
20
23
  const stats = await nodeStat(absolutePath);
21
24
  return { isFile: stats.isFile(), isDirectory: stats.isDirectory(), size: stats.size };
22
25
  },
26
+ /** 读取已校验路径的 UTF-8 正文。 */
23
27
  readFile(absolutePath) {
24
28
  return nodeReadFile(absolutePath, "utf8");
25
29
  },
30
+ /** 枚举已校验目录的一层条目。 */
26
31
  async listDirectory(absolutePath) {
27
32
  const entries = await nodeReaddir(absolutePath, { withFileTypes: true });
28
33
  return entries.map(function toEntry(entry) {
@@ -56,6 +61,22 @@ function isInsideWorkspace(workspaceRoot, mentionPath) {
56
61
  const relative = path.relative(workspaceRoot, path.resolve(workspaceRoot, mentionPath));
57
62
  return relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
58
63
  }
64
+ /** 宿主传入已受信的真实根;拒绝随后将该路径改指其他目录的链接。 */
65
+ export async function resolveTrustedFileMentionRoot(workspaceRoot, fs = nodeFileMentionFs) {
66
+ const root = await fs.realpath(workspaceRoot);
67
+ if (!path.isAbsolute(workspaceRoot) || path.relative(workspaceRoot, root) !== "")
68
+ throw new Error("FILE_MENTION_ROOT_CHANGED");
69
+ return root;
70
+ }
71
+ /** 用解析后的路径读取,发现路径在异步读取前后变动时丢弃结果。 */
72
+ async function readVerifiedTarget(fs, target, read) {
73
+ if (await fs.realpath(target) !== target)
74
+ throw new Error("FILE_MENTION_PATH_CHANGED");
75
+ const result = await read.call(fs, target);
76
+ if (await fs.realpath(target) !== target)
77
+ throw new Error("FILE_MENTION_PATH_CHANGED");
78
+ return result;
79
+ }
59
80
  /** 按 UTF-8 字节边界截断单行文本,回退扫描避免切断多字节字符。 */
60
81
  function truncateUtf8ByBytes(text, maxBytes) {
61
82
  const buffer = Buffer.from(text, "utf8");
@@ -98,12 +119,28 @@ async function resolveSingleMention(mentionPath, workspaceRoot, fs, notices) {
98
119
  return undefined;
99
120
  }
100
121
  const absolutePath = path.resolve(workspaceRoot, mentionPath);
122
+ let target;
123
+ try {
124
+ target = await fs.realpath(absolutePath);
125
+ }
126
+ catch (error) {
127
+ const code = error?.code;
128
+ notices.push(code === "ENOENT" || code === "ENOTDIR"
129
+ ? `@${mentionPath} 未找到`
130
+ : `@${mentionPath} 无法核实路径,已拒绝读取`);
131
+ return undefined;
132
+ }
133
+ const prefix = workspaceRoot.endsWith(path.sep) ? workspaceRoot : workspaceRoot + path.sep;
134
+ if (target === workspaceRoot || !target.startsWith(prefix)) {
135
+ notices.push(`@${mentionPath} 超出工作区边界,已拒绝读取`);
136
+ return undefined;
137
+ }
101
138
  let stats;
102
139
  try {
103
- stats = await fs.stat(absolutePath);
140
+ stats = await fs.stat(target);
104
141
  }
105
142
  catch {
106
- notices.push(`@${mentionPath} 未找到`);
143
+ notices.push(`@${mentionPath} 无法核实路径,已拒绝读取`);
107
144
  return undefined;
108
145
  }
109
146
  if (stats.isFile) {
@@ -113,22 +150,22 @@ async function resolveSingleMention(mentionPath, workspaceRoot, fs, notices) {
113
150
  }
114
151
  let text;
115
152
  try {
116
- text = await fs.readFile(absolutePath);
153
+ text = await readVerifiedTarget(fs, target, fs.readFile);
117
154
  }
118
155
  catch {
119
- notices.push(`@${mentionPath} 读取失败`);
156
+ notices.push(`@${mentionPath} 读取失败或路径无法核实`);
120
157
  return undefined;
121
158
  }
122
159
  const bounded = boundedFileText(text);
123
- return `--- @${mentionPath} (${bounded.label}) ---\n${bounded.content}`;
160
+ return { path: mentionPath, label: bounded.label, excerpt: bounded.content };
124
161
  }
125
162
  if (stats.isDirectory) {
126
163
  let entries;
127
164
  try {
128
- entries = await fs.listDirectory(absolutePath);
165
+ entries = await readVerifiedTarget(fs, target, fs.listDirectory);
129
166
  }
130
167
  catch {
131
- notices.push(`@${mentionPath} 读取失败`);
168
+ notices.push(`@${mentionPath} 读取失败或路径无法核实`);
132
169
  return undefined;
133
170
  }
134
171
  const sorted = entries.slice().sort(function compareEntries(left, right) {
@@ -143,31 +180,42 @@ async function resolveSingleMention(mentionPath, workspaceRoot, fs, notices) {
143
180
  return entry.isDirectory ? `${entry.name}/` : entry.name;
144
181
  })
145
182
  .join("\n");
146
- return `--- @${mentionPath} (${label}) ---\n${content}`;
183
+ return { path: mentionPath, label, excerpt: content };
147
184
  }
148
185
  notices.push(`@${mentionPath} 未找到`);
149
186
  return undefined;
150
187
  }
151
- /** 解析 prompt 中的全部 @ 引用并构造增强 content;至少一个引用成功时在原文后追加附加块。 */
152
- export async function resolveFileMentionContext(content, workspaceRoot, options = {}) {
188
+ /** 解析并核验 prompt 中的 @ 引用,保留它们的出现顺序。 */
189
+ export async function resolveFileMentionSections(content, workspaceRoot, options = {}) {
153
190
  const mentions = extractFileMentions(content);
154
191
  if (mentions.length === 0)
155
- return { content, notices: [] };
192
+ return { sections: [], notices: [] };
156
193
  const fs = options.fs ?? nodeFileMentionFs;
194
+ let root;
195
+ try {
196
+ root = await resolveTrustedFileMentionRoot(workspaceRoot, fs);
197
+ }
198
+ catch {
199
+ return { sections: [], notices: mentions.map(function reportUnverifiedRoot(mentionPath) {
200
+ return `@${mentionPath} 无法核实工作区,已拒绝读取`;
201
+ }) };
202
+ }
157
203
  const sections = [];
158
204
  const notices = [];
159
205
  for (const mentionPath of mentions) {
160
- const section = await resolveSingleMention(mentionPath, workspaceRoot, fs, notices);
206
+ const section = await resolveSingleMention(mentionPath, root, fs, notices);
161
207
  if (section !== undefined)
162
208
  sections.push(section);
163
209
  }
164
- if (sections.length === 0)
165
- return { content, notices };
166
- const block = [
167
- "<system-reminder>",
168
- "用户通过 @ 引用了以下工作区文件,内容已直接附加:",
169
- ...sections,
170
- "</system-reminder>",
171
- ].join("\n");
172
- return { content: `${content}\n\n${block}`, notices };
210
+ return { sections, notices };
211
+ }
212
+ /** 在共同预算内准备核验过的引用,供本地 CLI 或编排 Worker 使用。 */
213
+ export async function prepareFileMentionContext(content, workspaceRoot, options = {}) {
214
+ const { sections, notices } = await resolveFileMentionSections(content, workspaceRoot, options);
215
+ return { references: fitFileMentionContext(content, sections), notices };
216
+ }
217
+ /** 普通交互 CLI 在提交前将共同预算内的引用附加到用户原文。 */
218
+ export async function resolveFileMentionContext(content, workspaceRoot, options = {}) {
219
+ const { references, notices } = await prepareFileMentionContext(content, workspaceRoot, options);
220
+ return { content: formatFileMentionContent(content, references), notices };
173
221
  }
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export type { CliApprovalSubmit, CliController, CliControllerResult, CreateCliCo
13
13
  export { createCliEventProjector, createInitialCliProjection, reduceCliEvent } from "./event-projector.js";
14
14
  export { createPlainRenderer } from "./renderer.js";
15
15
  export { parseArgv, parseSlashAction, renderHelp } from "./parser.js";
16
- export type { CliAction, CliActionParseResult, CliCommand, CliEventEnvelope, CliEventListener, CliQueuedInputStarted, CliQueuedInputStartedListener, CliExitCode, CliHostOptions, CliInvocation, CliOutputFormat, CliPermissionMode, CliPermissionOption, CliParseResult, CliProjection, CliPublicEvent, CliRenderer, CliStatusView, CliRuntime, CliTurnStatus, } from "./types.js";
16
+ export type { CliAction, CliActionParseResult, CliCommand, CliEventEnvelope, CliEventListener, CliQueuedInputStarted, CliQueuedInputStartedListener, CliExitCode, CliHostOptions, CliInvocation, CliOutputFormat, CliPermissionMode, CliPermissionOption, CliParseResult, CliProjection, CliPublicEvent, CliRenderer, CliStatusView, CliRuntime, CliThreadCommand, CliThreadMode, CliTurnStatus, } from "./types.js";
17
17
  export { createCliTuiStore, runCliTui } from "./tui.js";
18
18
  export type { CliTuiInitialOperation, CliTuiRecap, CliTuiSnapshot, CliTuiStore, CliTuiTranscriptItem, RunCliTuiOptions, RunCliTuiResult, } from "./tui.js";
19
19
  export { formatCliTuiRecap } from "./tui.js";
package/dist/main.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * 入口只负责 argv、Composition Root、Plain Controller 和进程生命周期的编排;
6
6
  * Session、Turn、审批、恢复和持久化规则全部委托给 Core Runtime。
7
7
  */
8
+ import { type AgentRuntime, type Project, type Session } from "@autopilot-agent/core";
8
9
  import { type CliCompositionRoot, type CreateCliCompositionRootOptions } from "./composition-root.js";
9
10
  import type { CliExitCode } from "./types.js";
10
11
  /** CLI 主入口使用的最小输出/输入流接口。 */
@@ -36,5 +37,7 @@ export interface CliMainDependencies {
36
37
  }
37
38
  /** 将宿主信号映射为固定 CLI 退出码。 */
38
39
  export declare function exitCodeForSignal(signal: "SIGINT" | "SIGTERM"): 130 | 143;
40
+ /** 读取指定 Session 或创建当前 Project 下的新 Session。 */
41
+ export declare function ensureChatSession(runtime: AgentRuntime, project: Project, sessionId: string | undefined, environment?: NodeJS.ProcessEnv): Promise<Session>;
39
42
  /** 执行 Step 5.3 CLI 入口并返回固定退出码。 */
40
43
  export declare function main(argv?: readonly string[], streams?: CliMainStreams, dependencies?: CliMainDependencies): Promise<CliExitCode>;