nolo-cli 0.1.39 → 0.1.40
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 +4 -4
- package/agent-runtime/dialogWritePlan.ts +39 -0
- package/agent-runtime/hostAdapter.ts +4 -0
- package/agent-runtime/hybridRecordStore.ts +1 -1
- package/agent-runtime/index.ts +15 -0
- package/agent-runtime/localLoop.ts +87 -7
- package/agent-runtime/localToolPolicy.ts +2 -13
- package/agent-runtime/localWorkspaceTools.ts +42 -110
- package/agent-runtime/runtimeToolPolicy.ts +2 -11
- package/agent-runtime/runtimeToolSurface.ts +198 -0
- package/agent-runtime/types.ts +1 -0
- package/agentAliases.ts +2 -1
- package/agentRunCommand.ts +10 -32
- package/agentRuntimeLocal.ts +1 -0
- package/ai/agent/cliExecutor.ts +249 -34
- package/cli/agentAliases.ts +2 -1
- package/cli/agentRunCommand.ts +10 -32
- package/cli/agentRuntimeLocal.ts +1 -0
- package/cli/client/agentRun.ts +40 -87
- package/cli/client/localRuntimeAdapter.ts +179 -26
- package/cli/commandRegistry.ts +2 -2
- package/cli/machineWsRunDispatch.ts +51 -6
- package/cli/offlineMarxistsAgentCommand.ts +6 -4
- package/client/agentConfigResolver.test.ts +2 -2
- package/client/agentRun.test.ts +123 -57
- package/client/agentRun.ts +40 -87
- package/client/localRuntimeAdapter.test.ts +245 -31
- package/client/localRuntimeAdapter.ts +179 -26
- package/client/localRuntimeDryRun.test.ts +23 -9
- package/client/localToolPolicy.test.ts +4 -4
- package/commandRegistry.ts +2 -2
- package/database/server/levelAuthorityStore.ts +20 -1
- package/machineWsRunDispatch.ts +51 -6
- package/offlineMarxistsAgentCommand.ts +6 -4
- package/package.json +2 -1
package/ai/agent/cliExecutor.ts
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
import { exec, execSync, spawn } from "child_process";
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
|
-
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
19
|
-
import { join } from "node:path";
|
|
18
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
19
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
20
20
|
import { tmpdir } from "node:os";
|
|
21
21
|
import { resolveLaunchableCodexCommand } from "../../connector-experimental/codexBinary";
|
|
22
22
|
import { buildCliPrompt } from "./cliPrompt";
|
|
@@ -26,6 +26,19 @@ import { buildCliPrompt } from "./cliPrompt";
|
|
|
26
26
|
/** 已支持的 CLI 工具。新增时在此联合类型追加,并在 EXECUTORS 里注册实现 */
|
|
27
27
|
export type CliProvider = "copilot" | "gemini" | "codex" | "claude" | "agy";
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* CLI provider 图片输入。
|
|
31
|
+
*
|
|
32
|
+
* - `source` 是原始输入(本地路径 / data URL / http URL / file URL)
|
|
33
|
+
* - `materializedPath` 是 materialize 后写入磁盘的绝对路径
|
|
34
|
+
* (本地路径保持不变,data URL 写入临时文件,file URL 转换为本地路径)
|
|
35
|
+
* - HTTP/HTTPS URL 目前无法原生传给 CLI,只作为 prompt 引用保留
|
|
36
|
+
*/
|
|
37
|
+
export interface CliImageInput {
|
|
38
|
+
source: string;
|
|
39
|
+
materializedPath?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
29
42
|
export interface CliExecuteOptions {
|
|
30
43
|
model?: string;
|
|
31
44
|
timeout?: number; // ms,默认 120_000
|
|
@@ -41,6 +54,8 @@ export interface CliExecuteOptions {
|
|
|
41
54
|
maxTokens?: number;
|
|
42
55
|
enableThinking?: boolean;
|
|
43
56
|
thinkingBudget?: number;
|
|
57
|
+
/** 图片输入(本地路径 / data URL / file URL)。materialize 由内部处理。 */
|
|
58
|
+
imageInputs?: CliImageInput[];
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
export interface CliExecuteResult {
|
|
@@ -184,6 +199,138 @@ function shouldPassClaudeModel(options: CliExecuteOptions): boolean {
|
|
|
184
199
|
return (options.env?.NOLO_CLAUDE_CLI_ALLOW_MODEL ?? process.env.NOLO_CLAUDE_CLI_ALLOW_MODEL) === "1";
|
|
185
200
|
}
|
|
186
201
|
|
|
202
|
+
// ── CLI 图片 materialize ─────────────────────────────────────────────────────
|
|
203
|
+
|
|
204
|
+
const DATA_URL_RE = /^data:image\/([\w.+-]+);base64,([A-Za-z0-9+/=]+)$/;
|
|
205
|
+
|
|
206
|
+
/** data URL extension (without prefix) → 完整扩展名 */
|
|
207
|
+
const MIME_EXT: Record<string, string> = {
|
|
208
|
+
"png": ".png",
|
|
209
|
+
"jpeg": ".jpg",
|
|
210
|
+
"jpg": ".jpg",
|
|
211
|
+
"gif": ".gif",
|
|
212
|
+
"webp": ".webp",
|
|
213
|
+
"svg+xml": ".svg",
|
|
214
|
+
"bmp": ".bmp",
|
|
215
|
+
"tiff": ".tiff",
|
|
216
|
+
"avif": ".avif",
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
function inferExtFromMime(extPart: string): string {
|
|
220
|
+
return MIME_EXT[extPart.toLowerCase().trim()] ?? ".bin";
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const FILE_URL_RE = /^file:\/\/(.+)$/;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 将单个 data URL 图片写入临时文件,返回绝对路径。
|
|
227
|
+
* caller 负责在执行完后清理 tempDir。
|
|
228
|
+
*/
|
|
229
|
+
function writeDataUrlToTempImage(dataUrl: string, tempDir: string, index: number): string {
|
|
230
|
+
const match = dataUrl.match(DATA_URL_RE);
|
|
231
|
+
if (!match) {
|
|
232
|
+
throw new Error(`Invalid data URL format for image #${index + 1}; expected data:image/<type>;base64,<data>`);
|
|
233
|
+
}
|
|
234
|
+
const [, mimeExt, b64] = match;
|
|
235
|
+
const ext = inferExtFromMime(mimeExt);
|
|
236
|
+
const filePath = join(tempDir, `image-${index + 1}${ext}`);
|
|
237
|
+
writeFileSync(filePath, Buffer.from(b64, "base64"));
|
|
238
|
+
return filePath;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Materialize image input sources into on-disk paths where possible.
|
|
243
|
+
*
|
|
244
|
+
* - 本地 path / file URL → 解析为绝对路径,无需写临时文件
|
|
245
|
+
* - data:image/...;base64,... → 写入 tempDir 内临时文件
|
|
246
|
+
* - http(s) URL → 不做下载,保留 source 引用;materializedPath 为空
|
|
247
|
+
*
|
|
248
|
+
* 返回 `{ materialized, tempDir }`,caller 需在执行完成后 `rmSync(tempDir, { recursive: true, force: true })`。
|
|
249
|
+
* 当没有任何 data URL 时 tempDir 不会被创建,返回 null。
|
|
250
|
+
*/
|
|
251
|
+
export function materializeCliImageInputs(
|
|
252
|
+
imageInputs: CliImageInput[],
|
|
253
|
+
cwd: string,
|
|
254
|
+
): { materialized: CliImageInput[]; tempDir: string | null } {
|
|
255
|
+
let tempDir: string | null = null;
|
|
256
|
+
const materialized = imageInputs.map((input, index) => {
|
|
257
|
+
const src = input.source.trim();
|
|
258
|
+
|
|
259
|
+
if (src.startsWith("http://") || src.startsWith("https://")) {
|
|
260
|
+
return { ...input, materializedPath: undefined };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const fileUrlMatch = src.match(FILE_URL_RE);
|
|
264
|
+
if (fileUrlMatch) {
|
|
265
|
+
const localPath = fileUrlMatch[1];
|
|
266
|
+
return {
|
|
267
|
+
...input,
|
|
268
|
+
materializedPath: isAbsolute(localPath) ? localPath : resolve(cwd, localPath),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (src.startsWith("data:")) {
|
|
273
|
+
if (!tempDir) {
|
|
274
|
+
tempDir = mkdtempSync(join(tmpdir(), "nolo-cli-assets-"));
|
|
275
|
+
}
|
|
276
|
+
const filePath = writeDataUrlToTempImage(src, tempDir, index);
|
|
277
|
+
return { ...input, materializedPath: filePath };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// 本地路径
|
|
281
|
+
return {
|
|
282
|
+
...input,
|
|
283
|
+
materializedPath: isAbsolute(src) ? src : resolve(cwd, src),
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
return { materialized, tempDir };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 根据 provider 构建图片降级 prompt 块。
|
|
292
|
+
* Codex 使用原生 `-i` 标志,无需注入 prompt。
|
|
293
|
+
* 其他 provider 使用此函数将图片路径列表注入到 prompt 前面。
|
|
294
|
+
*/
|
|
295
|
+
function buildImageReferencePromptBlock(
|
|
296
|
+
provider: CliProvider,
|
|
297
|
+
materialized: CliImageInput[],
|
|
298
|
+
): { promptSuffix: string; warning: string | null } {
|
|
299
|
+
const label = getCliProviderLabel(provider);
|
|
300
|
+
const localPaths = materialized
|
|
301
|
+
.filter((img) => img.materializedPath)
|
|
302
|
+
.map((img) => img.materializedPath!);
|
|
303
|
+
const httpUrls = materialized
|
|
304
|
+
.filter((img) => !img.materializedPath)
|
|
305
|
+
.map((img) => img.source);
|
|
306
|
+
|
|
307
|
+
const lines: string[] = [];
|
|
308
|
+
if (localPaths.length > 0) {
|
|
309
|
+
lines.push(
|
|
310
|
+
`[User attached image(s) - local file references (accessible at these paths):]`,
|
|
311
|
+
...localPaths.map((p) => ` - ${p}`),
|
|
312
|
+
`Please read and analyze these image files as part of the user's request.`,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
if (httpUrls.length > 0) {
|
|
316
|
+
lines.push(
|
|
317
|
+
`[User attached image(s) - remote URLs (content not available locally):]`,
|
|
318
|
+
...httpUrls.map((u) => ` - ${u}`),
|
|
319
|
+
`These remote URLs could not be downloaded automatically. If you cannot access them, describe what you can infer from context.`,
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const warning =
|
|
324
|
+
materialized.length > 0
|
|
325
|
+
? `${label} image input is passed as local file references; native image flags are not available in this wrapper.`
|
|
326
|
+
: null;
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
promptSuffix: lines.length > 0 ? lines.join("\n") + "\n\n" : "",
|
|
330
|
+
warning,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
187
334
|
function collectCliCapabilityWarnings(
|
|
188
335
|
provider: CliProvider,
|
|
189
336
|
options: CliExecuteOptions
|
|
@@ -226,18 +373,51 @@ function resolveCliExecution(
|
|
|
226
373
|
provider: CliProvider,
|
|
227
374
|
prompt: string,
|
|
228
375
|
options: CliExecuteOptions
|
|
229
|
-
): { prompt: string; options: CliExecuteOptions; warnings: string[] } {
|
|
376
|
+
): { prompt: string; options: CliExecuteOptions; warnings: string[]; imageTempDir?: string } {
|
|
230
377
|
const warnings = collectCliCapabilityWarnings(provider, options);
|
|
378
|
+
|
|
379
|
+
// Handle image inputs
|
|
380
|
+
const imageInputs = options.imageInputs ?? [];
|
|
381
|
+
let resolvedPrompt = prompt;
|
|
382
|
+
let resolvedOptions = options;
|
|
383
|
+
let imageTempDir: string | undefined;
|
|
384
|
+
|
|
385
|
+
if (imageInputs.length > 0) {
|
|
386
|
+
const { materialized, tempDir } = materializeCliImageInputs(
|
|
387
|
+
imageInputs,
|
|
388
|
+
options.cwd ?? process.cwd(),
|
|
389
|
+
);
|
|
390
|
+
imageTempDir = tempDir ?? undefined;
|
|
391
|
+
|
|
392
|
+
if (provider === "codex") {
|
|
393
|
+
// Codex uses native -i flags; update options with materialized imageInputs
|
|
394
|
+
resolvedOptions = {
|
|
395
|
+
...resolvedOptions,
|
|
396
|
+
imageInputs: materialized,
|
|
397
|
+
};
|
|
398
|
+
} else {
|
|
399
|
+
// Non-codex providers: inject image references into prompt
|
|
400
|
+
const block = buildImageReferencePromptBlock(provider, materialized);
|
|
401
|
+
if (block.promptSuffix) {
|
|
402
|
+
resolvedPrompt = block.promptSuffix + resolvedPrompt;
|
|
403
|
+
}
|
|
404
|
+
if (block.warning) {
|
|
405
|
+
warnings.push(block.warning);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
231
410
|
if (supportsNativeSystemPrompt(provider) || !options.systemPrompt?.trim()) {
|
|
232
|
-
return { prompt, options, warnings };
|
|
411
|
+
return { prompt: resolvedPrompt, options: resolvedOptions, warnings, imageTempDir };
|
|
233
412
|
}
|
|
234
413
|
return {
|
|
235
|
-
prompt: buildCliPrompt(options.systemPrompt,
|
|
414
|
+
prompt: buildCliPrompt(options.systemPrompt, resolvedPrompt),
|
|
236
415
|
options: {
|
|
237
|
-
...
|
|
416
|
+
...resolvedOptions,
|
|
238
417
|
systemPrompt: undefined,
|
|
239
418
|
},
|
|
240
419
|
warnings,
|
|
420
|
+
imageTempDir,
|
|
241
421
|
};
|
|
242
422
|
}
|
|
243
423
|
|
|
@@ -410,6 +590,11 @@ function executeCodex(
|
|
|
410
590
|
yolo = true,
|
|
411
591
|
} = options;
|
|
412
592
|
|
|
593
|
+
// Collect materialized image paths from imageInputs
|
|
594
|
+
const imagePaths = (options.imageInputs ?? [])
|
|
595
|
+
.map((img) => img.materializedPath)
|
|
596
|
+
.filter((p): p is string => Boolean(p));
|
|
597
|
+
|
|
413
598
|
return new Promise((resolve, reject) => {
|
|
414
599
|
const tempDir = mkdtempSync(join(tmpdir(), "codex-exec-"));
|
|
415
600
|
const outputFile = join(tempDir, "last-message.txt");
|
|
@@ -429,6 +614,10 @@ function executeCodex(
|
|
|
429
614
|
args.push("--sandbox");
|
|
430
615
|
args.push("danger-full-access");
|
|
431
616
|
}
|
|
617
|
+
// Add image flags for Codex CLI native image support
|
|
618
|
+
for (const imgPath of imagePaths) {
|
|
619
|
+
args.push("-i", imgPath);
|
|
620
|
+
}
|
|
432
621
|
const start = Date.now();
|
|
433
622
|
const proc = spawn(executable, [...args, prompt], {
|
|
434
623
|
cwd,
|
|
@@ -699,11 +888,17 @@ export async function executeCli(
|
|
|
699
888
|
throw new Error(`Unknown CLI provider: "${provider}". Supported: ${Object.keys(EXECUTORS).join(", ")}`);
|
|
700
889
|
}
|
|
701
890
|
const resolved = resolveCliExecution(provider, prompt, options);
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
891
|
+
try {
|
|
892
|
+
const result = await executor(resolved.prompt, resolved.options);
|
|
893
|
+
return {
|
|
894
|
+
...result,
|
|
895
|
+
warnings: [...resolved.warnings, ...(result.warnings ?? [])],
|
|
896
|
+
};
|
|
897
|
+
} finally {
|
|
898
|
+
if (resolved.imageTempDir) {
|
|
899
|
+
rmSync(resolved.imageTempDir, { recursive: true, force: true });
|
|
900
|
+
}
|
|
901
|
+
}
|
|
707
902
|
}
|
|
708
903
|
|
|
709
904
|
export { buildCliPrompt };
|
|
@@ -831,36 +1026,56 @@ export function executeCliStreaming(
|
|
|
831
1026
|
): Promise<CliExecuteResult> {
|
|
832
1027
|
const resolved = resolveCliExecution(provider, prompt, options);
|
|
833
1028
|
const executor = EXECUTORS[provider];
|
|
1029
|
+
|
|
1030
|
+
const cleanupImageTempDir = () => {
|
|
1031
|
+
if (resolved.imageTempDir) {
|
|
1032
|
+
rmSync(resolved.imageTempDir, { recursive: true, force: true });
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
const withCleanup = <T>(promise: Promise<T>): Promise<T> =>
|
|
1037
|
+
promise.finally(cleanupImageTempDir);
|
|
1038
|
+
|
|
834
1039
|
if (provider === "gemini") {
|
|
835
|
-
return
|
|
836
|
-
.
|
|
1040
|
+
return withCleanup(
|
|
1041
|
+
executeGeminiStreaming(resolved.prompt, resolved.options as CliExecuteOptions & { onChunk: (chunk: string) => void })
|
|
1042
|
+
.then((result) => ({ ...result, warnings: [...resolved.warnings, ...(result.warnings ?? [])] }))
|
|
1043
|
+
);
|
|
837
1044
|
}
|
|
838
1045
|
if (provider === "codex") {
|
|
839
|
-
return
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
1046
|
+
return withCleanup(
|
|
1047
|
+
executor(resolved.prompt, resolved.options).then((result) => {
|
|
1048
|
+
const merged = { ...result, warnings: [...resolved.warnings, ...(result.warnings ?? [])] };
|
|
1049
|
+
if (merged.text) options.onChunk(merged.text);
|
|
1050
|
+
return merged;
|
|
1051
|
+
})
|
|
1052
|
+
);
|
|
844
1053
|
}
|
|
845
1054
|
if (provider === "claude") {
|
|
846
|
-
return
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
1055
|
+
return withCleanup(
|
|
1056
|
+
executor(resolved.prompt, resolved.options).then((result) => {
|
|
1057
|
+
const merged = { ...result, warnings: [...resolved.warnings, ...(result.warnings ?? [])] };
|
|
1058
|
+
if (merged.text) options.onChunk(merged.text);
|
|
1059
|
+
return merged;
|
|
1060
|
+
})
|
|
1061
|
+
);
|
|
851
1062
|
}
|
|
852
1063
|
if (provider === "agy") {
|
|
853
|
-
return
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1064
|
+
return withCleanup(
|
|
1065
|
+
executor(resolved.prompt, resolved.options).then((result) => {
|
|
1066
|
+
const merged = { ...result, warnings: [...resolved.warnings, ...(result.warnings ?? [])] };
|
|
1067
|
+
if (merged.text) options.onChunk(merged.text);
|
|
1068
|
+
return merged;
|
|
1069
|
+
})
|
|
1070
|
+
);
|
|
858
1071
|
}
|
|
859
1072
|
if (provider !== "copilot") {
|
|
860
|
-
return
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
1073
|
+
return withCleanup(
|
|
1074
|
+
executor(resolved.prompt, resolved.options).then((result) => ({
|
|
1075
|
+
...result,
|
|
1076
|
+
warnings: [...resolved.warnings, ...(result.warnings ?? [])],
|
|
1077
|
+
}))
|
|
1078
|
+
);
|
|
864
1079
|
}
|
|
865
1080
|
|
|
866
1081
|
const {
|
|
@@ -871,7 +1086,7 @@ export function executeCliStreaming(
|
|
|
871
1086
|
onChunk,
|
|
872
1087
|
} = resolved.options as CliExecuteOptions & { onChunk: (chunk: string) => void };
|
|
873
1088
|
|
|
874
|
-
return new Promise((resolve, reject) => {
|
|
1089
|
+
return withCleanup(new Promise<CliExecuteResult>((resolve, reject) => {
|
|
875
1090
|
const args = [
|
|
876
1091
|
"copilot", "--",
|
|
877
1092
|
"-p", resolved.prompt,
|
|
@@ -931,7 +1146,7 @@ export function executeCliStreaming(
|
|
|
931
1146
|
if (timer) clearTimeout(timer);
|
|
932
1147
|
reject(err);
|
|
933
1148
|
});
|
|
934
|
-
});
|
|
1149
|
+
}));
|
|
935
1150
|
}
|
|
936
1151
|
|
|
937
1152
|
function executeGeminiStreaming(
|
package/cli/agentAliases.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const PLATFORM_DEMO_USER_ID = "b2e06f801f";
|
|
2
|
+
export const CURRENT_OPERATOR_USER_ID = "0e95801d90";
|
|
2
3
|
export const NOLO_DEFAULT_AGENT_ID = "01NOLOAPPBLD000000019KCKT0";
|
|
3
4
|
export const NOLO_DEFAULT_AGENT_KEY = `agent-pub-${NOLO_DEFAULT_AGENT_ID}`;
|
|
4
5
|
export const NOLO_PROJECT_MANAGER_AGENT_ID = "01NOLOPROJMGR00000000MSVGG";
|
|
@@ -9,7 +10,7 @@ export const NOLO_SENIOR_FULLSTACK_AGENT_KEY =
|
|
|
9
10
|
`agent-${PLATFORM_DEMO_USER_ID}-${NOLO_SENIOR_FULLSTACK_AGENT_ID}`;
|
|
10
11
|
export const NOLO_FRONTEND_AGENT_ID = "01FRONTENDAG0000000115N4E1";
|
|
11
12
|
export const NOLO_FRONTEND_AGENT_KEY =
|
|
12
|
-
`agent-${
|
|
13
|
+
`agent-${CURRENT_OPERATOR_USER_ID}-${NOLO_FRONTEND_AGENT_ID}`;
|
|
13
14
|
export const WIN_CODEX_AGENT_ID = "WINCODEX00000000FQ0LK0";
|
|
14
15
|
export const WIN_CODEX_AGENT_KEY =
|
|
15
16
|
`agent-0e95801d90-${WIN_CODEX_AGENT_ID}`;
|
package/cli/agentRunCommand.ts
CHANGED
|
@@ -50,11 +50,10 @@ type ParsedAgentRunArgs = {
|
|
|
50
50
|
parentDialogId?: string;
|
|
51
51
|
background: boolean;
|
|
52
52
|
noStream: boolean;
|
|
53
|
-
noDefaultTestRoot: boolean;
|
|
54
53
|
cwd?: string;
|
|
55
|
-
maxToolRounds?: number;
|
|
56
54
|
timeoutMs?: number;
|
|
57
55
|
traceTools: boolean;
|
|
56
|
+
eventsMode?: "jsonl";
|
|
58
57
|
injectFeatureWorktreeInstruction: boolean;
|
|
59
58
|
taskRunContext?: TaskRunPromptContext;
|
|
60
59
|
workflowRef?: string;
|
|
@@ -66,10 +65,6 @@ type ResolvedWorkflowReference = {
|
|
|
66
65
|
config?: Partial<WorkflowReferenceConfig>;
|
|
67
66
|
};
|
|
68
67
|
|
|
69
|
-
const DEFAULT_TEST_ROOT_DIALOG_ID = "01KN6V3MVEQA4Q1PNKVM2W7YY8";
|
|
70
|
-
const DEFAULT_TEST_ROOT_DIALOG_KEY = `dialog-b2e06f801f-${DEFAULT_TEST_ROOT_DIALOG_ID}`;
|
|
71
|
-
const DEFAULT_TEST_DIALOG_CATEGORY_ID = "test-dialogs";
|
|
72
|
-
|
|
73
68
|
function readFlagValue(args: string[], flag: string) {
|
|
74
69
|
const index = args.indexOf(flag);
|
|
75
70
|
if (index < 0) return undefined;
|
|
@@ -109,13 +104,6 @@ function isMonthlyMimoAgentRef(raw: string | undefined, resolved: string) {
|
|
|
109
104
|
);
|
|
110
105
|
}
|
|
111
106
|
|
|
112
|
-
function parseNonNegativeInteger(value: string | undefined) {
|
|
113
|
-
if (!value) return undefined;
|
|
114
|
-
const parsed = Number(value);
|
|
115
|
-
if (!Number.isFinite(parsed) || parsed < 0) return undefined;
|
|
116
|
-
return Math.floor(parsed);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
107
|
function parsePositiveInteger(value: string | undefined) {
|
|
120
108
|
if (!value) return undefined;
|
|
121
109
|
const parsed = Number(value);
|
|
@@ -134,7 +122,6 @@ function positionalArgs(args: string[]) {
|
|
|
134
122
|
"--bg",
|
|
135
123
|
"--no-stream",
|
|
136
124
|
"--debug",
|
|
137
|
-
"--no-default-test-root",
|
|
138
125
|
]);
|
|
139
126
|
for (let index = 0; index < args.length; index += 1) {
|
|
140
127
|
const arg = args[index];
|
|
@@ -167,20 +154,13 @@ export function parseAgentRunArgs(
|
|
|
167
154
|
const spaceId = readFlagValue(args, "--space");
|
|
168
155
|
const category = readFlagValue(args, "--category");
|
|
169
156
|
const inheritedFromDialog = readFlagValue(args, "--inherit-from-dialog");
|
|
170
|
-
const noDefaultTestRoot = args.includes("--no-default-test-root");
|
|
171
157
|
const cwd = readFlagValue(args, "--cwd");
|
|
172
|
-
const maxToolRounds = parseNonNegativeInteger(
|
|
173
|
-
readFlagValue(args, "--max-tool-rounds") ?? readFlagValue(args, "--rounds")
|
|
174
|
-
);
|
|
175
158
|
const timeoutMs = parsePositiveInteger(readFlagValue(args, "--timeout-ms"));
|
|
159
|
+
const rawEventsMode = readFlagValue(args, "--events");
|
|
160
|
+
const eventsMode = rawEventsMode === "jsonl" ? "jsonl" : undefined;
|
|
176
161
|
const inheritedRef = inheritedFromDialog
|
|
177
162
|
? parseDialogReference(inheritedFromDialog)
|
|
178
|
-
:
|
|
179
|
-
? {
|
|
180
|
-
dialogKey: DEFAULT_TEST_ROOT_DIALOG_KEY,
|
|
181
|
-
dialogId: DEFAULT_TEST_ROOT_DIALOG_ID,
|
|
182
|
-
}
|
|
183
|
-
: undefined;
|
|
163
|
+
: undefined;
|
|
184
164
|
const imageUrls = [
|
|
185
165
|
...readRepeatedFlagValues(args, "--image"),
|
|
186
166
|
...readRepeatedFlagValues(args, "--image-url"),
|
|
@@ -199,6 +179,7 @@ export function parseAgentRunArgs(
|
|
|
199
179
|
imageUrls,
|
|
200
180
|
allowShell: args.includes("--dangerously-allow-shell") || mimoLocalWorkspaceDefault,
|
|
201
181
|
traceTools: args.includes("--trace-tools"),
|
|
182
|
+
...(eventsMode ? { eventsMode } : {}),
|
|
202
183
|
injectFeatureWorktreeInstruction: mimoLocalWorkspaceDefault,
|
|
203
184
|
...(workflowRef ? { workflowRef } : {}),
|
|
204
185
|
...(taskRowDbKey
|
|
@@ -218,14 +199,12 @@ export function parseAgentRunArgs(
|
|
|
218
199
|
: {}),
|
|
219
200
|
background: args.includes("--bg"),
|
|
220
201
|
noStream: args.includes("--no-stream"),
|
|
221
|
-
noDefaultTestRoot,
|
|
222
202
|
...(continueDialogId ? { continueDialogId } : {}),
|
|
223
203
|
...(!continueDialogId && spaceId ? { spaceId } : {}),
|
|
224
|
-
...(category ? { category } :
|
|
204
|
+
...(category ? { category } : {}),
|
|
225
205
|
...(inheritedRef?.dialogKey ? { inheritedFromDialogKey: inheritedRef.dialogKey } : {}),
|
|
226
206
|
...(inheritedRef?.dialogId ? { parentDialogId: inheritedRef.dialogId } : {}),
|
|
227
207
|
...(cwd ? { cwd } : {}),
|
|
228
|
-
...(typeof maxToolRounds === "number" ? { maxToolRounds } : {}),
|
|
229
208
|
...(typeof timeoutMs === "number" ? { timeoutMs } : {}),
|
|
230
209
|
};
|
|
231
210
|
}
|
|
@@ -411,16 +390,16 @@ function buildLocalRunEnv(args: {
|
|
|
411
390
|
env: EnvLike;
|
|
412
391
|
allowShell: boolean;
|
|
413
392
|
}) {
|
|
393
|
+
void args.allowShell;
|
|
414
394
|
return {
|
|
415
395
|
...args.env,
|
|
416
|
-
...(args.allowShell ? { NOLO_LOCAL_SHELL_MODE: "worktree" } : {}),
|
|
417
396
|
};
|
|
418
397
|
}
|
|
419
398
|
|
|
420
399
|
function writeUsage(output: OutputLike) {
|
|
421
400
|
output.write(
|
|
422
|
-
"Usage: nolo agent run <agent> <message> [--local|--server|--auto] [--continue <dialogId>] [--cwd <path>]
|
|
423
|
-
" nolo agent run --agent <agent> (--msg <message>|--msg-file <path>) [--image <url-or-path>] [--space <spaceId>] [--category <name>] [--inherit-from-dialog <dialog>] [--task-row-dbkey <key>] [--bg] [--timeout-ms <n>] [--no-stream]\n"
|
|
401
|
+
"Usage: nolo agent run <agent> <message> [--local|--server|--auto] [--continue <dialogId>] [--cwd <path>]\n" +
|
|
402
|
+
" nolo agent run --agent <agent> (--msg <message>|--msg-file <path>) [--image <url-or-path>] [--space <spaceId>] [--category <name>] [--inherit-from-dialog <dialog>] [--task-row-dbkey <key>] [--bg] [--timeout-ms <n>] [--events jsonl] [--no-stream]\n"
|
|
424
403
|
);
|
|
425
404
|
}
|
|
426
405
|
|
|
@@ -480,10 +459,9 @@ export async function runAgentRunCommand(args: string[], deps: AgentRunCommandDe
|
|
|
480
459
|
...(parsed.parentDialogId ? { parentDialogId: parsed.parentDialogId } : {}),
|
|
481
460
|
background: parsed.background,
|
|
482
461
|
noStream: parsed.noStream,
|
|
483
|
-
noDefaultTestRoot: parsed.noDefaultTestRoot,
|
|
484
|
-
...(typeof parsed.maxToolRounds === "number" ? { maxToolRounds: parsed.maxToolRounds } : {}),
|
|
485
462
|
...(typeof parsed.timeoutMs === "number" ? { timeoutMs: parsed.timeoutMs } : {}),
|
|
486
463
|
traceTools: parsed.traceTools,
|
|
464
|
+
...(parsed.eventsMode ? { eventsMode: parsed.eventsMode } : {}),
|
|
487
465
|
...(parsed.taskRunContext ? { taskRunContext: parsed.taskRunContext } : {}),
|
|
488
466
|
});
|
|
489
467
|
|
package/cli/agentRuntimeLocal.ts
CHANGED