@daluo/cli 0.1.3 → 0.1.4
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/dist/BUILD-STAMP +1 -1
- package/dist/run.js +1025 -798
- package/package.json +6 -4
package/dist/run.js
CHANGED
|
@@ -2206,8 +2206,71 @@ var init_schema_telemetry = __esm({
|
|
|
2206
2206
|
}
|
|
2207
2207
|
});
|
|
2208
2208
|
|
|
2209
|
-
// packages/core/src/session/event/schema.ts
|
|
2209
|
+
// packages/core/src/session/event/schema-assistant.ts
|
|
2210
2210
|
import { z as z4 } from "zod";
|
|
2211
|
+
var TextPartSchema, ToolCallPartSchema, ReasoningPartSchema, ContentPartSchema, LlmUsageSchema, MessageAssistantSchema;
|
|
2212
|
+
var init_schema_assistant = __esm({
|
|
2213
|
+
"packages/core/src/session/event/schema-assistant.ts"() {
|
|
2214
|
+
"use strict";
|
|
2215
|
+
init_schema_base();
|
|
2216
|
+
TextPartSchema = z4.object({
|
|
2217
|
+
type: z4.literal("text"),
|
|
2218
|
+
text: z4.string()
|
|
2219
|
+
});
|
|
2220
|
+
ToolCallPartSchema = z4.object({
|
|
2221
|
+
type: z4.literal("tool-call"),
|
|
2222
|
+
toolCallId: z4.string(),
|
|
2223
|
+
toolName: z4.string(),
|
|
2224
|
+
input: z4.unknown()
|
|
2225
|
+
});
|
|
2226
|
+
ReasoningPartSchema = z4.object({
|
|
2227
|
+
type: z4.literal("reasoning"),
|
|
2228
|
+
text: z4.string()
|
|
2229
|
+
});
|
|
2230
|
+
ContentPartSchema = z4.discriminatedUnion("type", [
|
|
2231
|
+
TextPartSchema,
|
|
2232
|
+
ToolCallPartSchema,
|
|
2233
|
+
ReasoningPartSchema
|
|
2234
|
+
]);
|
|
2235
|
+
LlmUsageSchema = z4.object({
|
|
2236
|
+
promptTokens: z4.number().int().nonnegative(),
|
|
2237
|
+
completionTokens: z4.number().int().nonnegative(),
|
|
2238
|
+
/** 缓存命中 token(`prompt_tokens_details.cached_tokens`):provider 未回则不写。 */
|
|
2239
|
+
cachedTokens: z4.number().int().nonnegative().optional(),
|
|
2240
|
+
/** 思维链占用的输出 token(`completion_tokens_details.reasoning_tokens`):含在 completionTokens 内。 */
|
|
2241
|
+
reasoningTokens: z4.number().int().nonnegative().optional()
|
|
2242
|
+
});
|
|
2243
|
+
MessageAssistantSchema = BaseEventSchema.extend({
|
|
2244
|
+
type: z4.literal("message/assistant"),
|
|
2245
|
+
content: z4.array(ContentPartSchema),
|
|
2246
|
+
usage: LlmUsageSchema.optional(),
|
|
2247
|
+
model: z4.string().min(1).optional(),
|
|
2248
|
+
/**
|
|
2249
|
+
* **这一轮请求的墙钟耗时**(GitHub issue #9):从「开始发请求」到「拿到完整响应」的毫秒数,
|
|
2250
|
+
* **含**进程内重试与流式聚合,**不含**工具执行与压缩/指纹那些本地步骤。
|
|
2251
|
+
*
|
|
2252
|
+
* 宿主此前只能拿相邻事件的 `ts` 相减猜「慢在模型还是慢在工具」——跨一次工具往返就误差很大
|
|
2253
|
+
* (工具的耗时不在模型账上,但会被算进去)。这个字段让「哪一轮慢」可测。
|
|
2254
|
+
*
|
|
2255
|
+
* 可选:旧日志没有它照读(与 `model` 同款演进方式);纯描述,不参与 fold、不进回传。
|
|
2256
|
+
*/
|
|
2257
|
+
durationMs: z4.number().int().nonnegative().optional(),
|
|
2258
|
+
/**
|
|
2259
|
+
* 上游的 `choices[0].finish_reason` **原样**(`stop` / `tool_calls` / `length` / `content_filter` …)。
|
|
2260
|
+
*
|
|
2261
|
+
* 为什么值得落日志:`length` 是「输出被截断」的**唯一直接信号**。真机踩过(issue #5 那次)
|
|
2262
|
+
* 模型吐的 tool-call 参数是坏 JSON,当时分不清「采样手抖」还是「被 max_tokens 截断」——
|
|
2263
|
+
* 前者重采样大概率就好,后者重采样还会截断,处置完全不同。
|
|
2264
|
+
*
|
|
2265
|
+
* 原样存而不是归一成枚举:各家取值不统一(`stop`/`end_turn`/`stop_sequence`…),本仓不猜。
|
|
2266
|
+
*/
|
|
2267
|
+
finishReason: z4.string().min(1).optional()
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
});
|
|
2271
|
+
|
|
2272
|
+
// packages/core/src/session/event/schema.ts
|
|
2273
|
+
import { z as z5 } from "zod";
|
|
2211
2274
|
function isTextPart(part) {
|
|
2212
2275
|
return part.type === "text";
|
|
2213
2276
|
}
|
|
@@ -2217,143 +2280,112 @@ function isReasoningPart(part) {
|
|
|
2217
2280
|
function isToolCallPart(part) {
|
|
2218
2281
|
return part.type === "tool-call";
|
|
2219
2282
|
}
|
|
2220
|
-
var SessionCreatedSchema, SessionImportedSchema,
|
|
2283
|
+
var SessionCreatedSchema, SessionImportedSchema, UserImageSchema, MessageUserSchema, ContextInjectedSchema, DeltaTextSchema, DeltaToolCallSchema, DeltaSchema, AssistantDeltaSchema, ToolResultImageSchema, ToolBatchSchema, ToolResultSchema, CompactionSummarySchema, PromptSystemSchema, MemoryExtractSchema, CompactionReclaimSchema, SubagentStartSchema, SubagentReportSchema, VerifyVerdictSchema, TodoSchema, TodoUpdateSchema, PlanModeSchema, PolicyProfileSchema, GoalSchema, GoalSetSchema, WorkflowNodeSchema, WorkflowStartSchema, WorkflowEndSchema, TeamMemberSchema, TeamMemberCreateSchema, TeamMessageSchema, TeamMessageQueuedSchema, TeamMessageDeliveredSchema, TeamTaskSchema, TeamTaskUpdateSchema, TaskEvidenceSchema, TeamTaskResultSchema, TeamTaskResultEventSchema, SessionRenamedSchema, SessionModelChangedSchema, WorkingDirectoryChangedSchema, SessionArchivedSchema, MAX_LABELS, MAX_LABEL_KEY_CHARS, MAX_LABEL_VALUE_CHARS, SessionLabelsSchema, CommandRunSchema, CommandDoneSchema, InboxQueuedSchema, InboxEditedSchema, InboxRemovedSchema, InboxRequeuedSchema, AskOriginSchema, AskRequestedSchema, AskAnsweredSchema, GoalClearedSchema, FeedbackRecordedSchema, FeedbackRetractedSchema, SessionBranchSummarySchema, SessionEvent, SESSION_EVENT_TYPES;
|
|
2221
2284
|
var init_schema = __esm({
|
|
2222
2285
|
"packages/core/src/session/event/schema.ts"() {
|
|
2223
2286
|
"use strict";
|
|
2224
2287
|
init_permission_schema();
|
|
2225
2288
|
init_schema_base();
|
|
2226
2289
|
init_schema_telemetry();
|
|
2290
|
+
init_schema_assistant();
|
|
2227
2291
|
init_permission_schema();
|
|
2228
2292
|
init_schema_telemetry();
|
|
2293
|
+
init_schema_assistant();
|
|
2229
2294
|
SessionCreatedSchema = BaseEventSchema.extend({
|
|
2230
|
-
type:
|
|
2231
|
-
forkedFrom:
|
|
2295
|
+
type: z5.literal("session/created"),
|
|
2296
|
+
forkedFrom: z5.object({
|
|
2232
2297
|
/** 源会话 sessionId(稳定身份;文件名只作人类可读的指路)。 */
|
|
2233
|
-
sessionId:
|
|
2298
|
+
sessionId: z5.string(),
|
|
2234
2299
|
/** 源日志文件名(basename)——供 CLI/呈现直接指路。 */
|
|
2235
|
-
file:
|
|
2300
|
+
file: z5.string(),
|
|
2236
2301
|
/** 切割点:新会话继承了源的 `[1..seq]` 前缀(seq 必须落在**回合边界**上)。 */
|
|
2237
|
-
seq:
|
|
2302
|
+
seq: z5.number().int().positive()
|
|
2238
2303
|
}).optional()
|
|
2239
2304
|
});
|
|
2240
2305
|
SessionImportedSchema = BaseEventSchema.extend({
|
|
2241
|
-
type:
|
|
2306
|
+
type: z5.literal("session/imported"),
|
|
2242
2307
|
/** 源文件 basename(人类可读指路;导入是「这一份源 → 这一份目标」)。 */
|
|
2243
|
-
file:
|
|
2308
|
+
file: z5.string().min(1),
|
|
2244
2309
|
/** 源格式(闭集:本仓支持的两家)。 */
|
|
2245
|
-
format:
|
|
2310
|
+
format: z5.enum(["claude", "codex"]),
|
|
2246
2311
|
/** 源会话 id(拿得到就给)。 */
|
|
2247
|
-
sourceSessionId:
|
|
2312
|
+
sourceSessionId: z5.string().min(1).optional(),
|
|
2248
2313
|
/** 已导入的**条目数**(游标)。 */
|
|
2249
|
-
entries:
|
|
2314
|
+
entries: z5.number().int().nonnegative(),
|
|
2250
2315
|
/** 已导入条目的 digest(sha256 前 16)——resync 时校验「已导入的那一段没被改过」。 */
|
|
2251
|
-
digest:
|
|
2252
|
-
});
|
|
2253
|
-
TextPartSchema = z4.object({
|
|
2254
|
-
type: z4.literal("text"),
|
|
2255
|
-
text: z4.string()
|
|
2256
|
-
});
|
|
2257
|
-
ToolCallPartSchema = z4.object({
|
|
2258
|
-
type: z4.literal("tool-call"),
|
|
2259
|
-
toolCallId: z4.string(),
|
|
2260
|
-
toolName: z4.string(),
|
|
2261
|
-
input: z4.unknown()
|
|
2262
|
-
});
|
|
2263
|
-
ReasoningPartSchema = z4.object({
|
|
2264
|
-
type: z4.literal("reasoning"),
|
|
2265
|
-
text: z4.string()
|
|
2316
|
+
digest: z5.string().min(1)
|
|
2266
2317
|
});
|
|
2267
|
-
|
|
2268
|
-
TextPartSchema,
|
|
2269
|
-
ToolCallPartSchema,
|
|
2270
|
-
ReasoningPartSchema
|
|
2271
|
-
]);
|
|
2272
|
-
UserImageSchema = z4.object({
|
|
2318
|
+
UserImageSchema = z5.object({
|
|
2273
2319
|
/** 落盘后的**绝对路径**(字节在 `.daluo/tool-results/user-images/`;文件被清掉时那次请求退回纯文本)。 */
|
|
2274
|
-
path:
|
|
2275
|
-
mediaType:
|
|
2276
|
-
bytes:
|
|
2320
|
+
path: z5.string(),
|
|
2321
|
+
mediaType: z5.string(),
|
|
2322
|
+
bytes: z5.number().int().nonnegative(),
|
|
2277
2323
|
/** 像素宽高(能读到才写:PNG/JPEG/GIF/WebP 四种头;读不出就省字段,**不编**)。 */
|
|
2278
|
-
width:
|
|
2279
|
-
height:
|
|
2324
|
+
width: z5.number().int().positive().optional(),
|
|
2325
|
+
height: z5.number().int().positive().optional()
|
|
2280
2326
|
});
|
|
2281
2327
|
MessageUserSchema = BaseEventSchema.extend({
|
|
2282
|
-
type:
|
|
2283
|
-
content:
|
|
2328
|
+
type: z5.literal("message/user"),
|
|
2329
|
+
content: z5.string(),
|
|
2284
2330
|
/** 用户随这条消息附上的图(刀72):**可选**(老日志照常解析);附不附由请求侧按视觉能力与上限定。 */
|
|
2285
|
-
images:
|
|
2331
|
+
images: z5.array(UserImageSchema).optional(),
|
|
2286
2332
|
/**
|
|
2287
2333
|
* 投递回执(spec/input-queue.md 决策 1):这条 user 消息来自哪条待发项(`inbox/queued` 的 id)。
|
|
2288
2334
|
* 它就是「**已投递**」这件事本身——`fold` 的 `pending = queued − removed − delivered` 据此收敛。
|
|
2289
2335
|
* 对齐 dsh 的 `rpcId`(客户端据此把本地提交回声退休),也与团队消息 queued/delivered 同构。
|
|
2290
2336
|
*/
|
|
2291
|
-
inboxId:
|
|
2337
|
+
inboxId: z5.string().optional()
|
|
2292
2338
|
});
|
|
2293
2339
|
ContextInjectedSchema = BaseEventSchema.extend({
|
|
2294
|
-
type:
|
|
2340
|
+
type: z5.literal("context/injected"),
|
|
2295
2341
|
/** 渲染后的块文本(含 `[context:<kind>]` 头)——**就是模型看到的那一段**,逐字存。 */
|
|
2296
|
-
content:
|
|
2297
|
-
});
|
|
2298
|
-
LlmUsageSchema = z4.object({
|
|
2299
|
-
promptTokens: z4.number().int().nonnegative(),
|
|
2300
|
-
completionTokens: z4.number().int().nonnegative(),
|
|
2301
|
-
/** 缓存命中 token(`prompt_tokens_details.cached_tokens`):provider 未回则不写。 */
|
|
2302
|
-
cachedTokens: z4.number().int().nonnegative().optional(),
|
|
2303
|
-
/** 思维链占用的输出 token(`completion_tokens_details.reasoning_tokens`):含在 completionTokens 内。 */
|
|
2304
|
-
reasoningTokens: z4.number().int().nonnegative().optional()
|
|
2305
|
-
});
|
|
2306
|
-
MessageAssistantSchema = BaseEventSchema.extend({
|
|
2307
|
-
type: z4.literal("message/assistant"),
|
|
2308
|
-
content: z4.array(ContentPartSchema),
|
|
2309
|
-
usage: LlmUsageSchema.optional(),
|
|
2310
|
-
model: z4.string().min(1).optional()
|
|
2342
|
+
content: z5.string()
|
|
2311
2343
|
});
|
|
2312
|
-
DeltaTextSchema =
|
|
2313
|
-
kind:
|
|
2314
|
-
text:
|
|
2344
|
+
DeltaTextSchema = z5.object({
|
|
2345
|
+
kind: z5.literal("text"),
|
|
2346
|
+
text: z5.string()
|
|
2315
2347
|
});
|
|
2316
|
-
DeltaToolCallSchema =
|
|
2317
|
-
kind:
|
|
2318
|
-
toolCallId:
|
|
2319
|
-
name:
|
|
2320
|
-
arguments:
|
|
2348
|
+
DeltaToolCallSchema = z5.object({
|
|
2349
|
+
kind: z5.literal("tool-call"),
|
|
2350
|
+
toolCallId: z5.string(),
|
|
2351
|
+
name: z5.string().optional(),
|
|
2352
|
+
arguments: z5.unknown().optional()
|
|
2321
2353
|
});
|
|
2322
|
-
DeltaSchema =
|
|
2354
|
+
DeltaSchema = z5.discriminatedUnion("kind", [DeltaTextSchema, DeltaToolCallSchema]);
|
|
2323
2355
|
AssistantDeltaSchema = BaseEventSchema.extend({
|
|
2324
|
-
type:
|
|
2356
|
+
type: z5.literal("assistant/delta"),
|
|
2325
2357
|
delta: DeltaSchema
|
|
2326
2358
|
});
|
|
2327
|
-
ToolResultImageSchema =
|
|
2359
|
+
ToolResultImageSchema = z5.object({
|
|
2328
2360
|
/** 图落盘的绝对路径(文件被清掉时那次请求退回纯文本,见演进节记的边界)。 */
|
|
2329
|
-
path:
|
|
2361
|
+
path: z5.string(),
|
|
2330
2362
|
/** 落盘时的 MIME(`image/png` 等)。 */
|
|
2331
|
-
mediaType:
|
|
2332
|
-
bytes:
|
|
2363
|
+
mediaType: z5.string(),
|
|
2364
|
+
bytes: z5.number().int().nonnegative()
|
|
2333
2365
|
});
|
|
2334
2366
|
ToolBatchSchema = BaseEventSchema.extend({
|
|
2335
|
-
type:
|
|
2367
|
+
type: z5.literal("tool/batch"),
|
|
2336
2368
|
/** 本批的调用 id(**顺序 = calls 顺序**;并发执行,不表示先后)。 */
|
|
2337
|
-
toolCallIds:
|
|
2369
|
+
toolCallIds: z5.array(z5.string()),
|
|
2338
2370
|
/** 批开跑的时刻(与各 `tool/result` 的 `ts` 一起看,就能分辨「真并发」与「排着跑」)。 */
|
|
2339
|
-
startedAt:
|
|
2340
|
-
ok:
|
|
2341
|
-
failed:
|
|
2371
|
+
startedAt: z5.string(),
|
|
2372
|
+
ok: z5.number().int().nonnegative(),
|
|
2373
|
+
failed: z5.number().int().nonnegative()
|
|
2342
2374
|
});
|
|
2343
2375
|
ToolResultSchema = BaseEventSchema.extend({
|
|
2344
|
-
type:
|
|
2345
|
-
toolCallId:
|
|
2346
|
-
output:
|
|
2376
|
+
type: z5.literal("tool/result"),
|
|
2377
|
+
toolCallId: z5.string(),
|
|
2378
|
+
output: z5.unknown(),
|
|
2347
2379
|
/**
|
|
2348
2380
|
* 这次结果带回的图像(可选)。**与 `output` 分开**:`output` 会过预算那一步(超限换 stub/省略),
|
|
2349
2381
|
* 图引用不该被预算改写——它是「图在哪」的事实。
|
|
2350
2382
|
*/
|
|
2351
|
-
images:
|
|
2383
|
+
images: z5.array(ToolResultImageSchema).optional(),
|
|
2352
2384
|
/**
|
|
2353
2385
|
* 呈现元数据(spec/session-event.md 演进节 + tool-registry.md):**工具自己**给出的人话标题
|
|
2354
2386
|
* (`present(input)` 的结果;纯函数 ⇒ 重放一致)。**可选**:没给就由呈现层从参数猜(老行为不破)。
|
|
2355
2387
|
*/
|
|
2356
|
-
present:
|
|
2388
|
+
present: z5.object({ title: z5.string(), kind: z5.string().optional() }).optional(),
|
|
2357
2389
|
/**
|
|
2358
2390
|
* **退出码语义**(演进 2026-09-21,spec/tools.md「退出码不是布尔」/ G2-20,bash 产出)。
|
|
2359
2391
|
*
|
|
@@ -2364,7 +2396,7 @@ var init_schema = __esm({
|
|
|
2364
2396
|
* `isGenuinePass`)。**存在即「否定退出码」**(真故障走 `{error}` 结果,不需要它)。
|
|
2365
2397
|
* 可选 ⇒ 既有事件零迁移;不喂 LLM(模型读的是 output 正文里的人话)。
|
|
2366
2398
|
*/
|
|
2367
|
-
exitSemantics:
|
|
2399
|
+
exitSemantics: z5.object({ code: z5.number().int(), label: z5.string() }).optional(),
|
|
2368
2400
|
/**
|
|
2369
2401
|
* **假绿证据**(演进 2026-09-22,spec/a2-plan-goal.md A2b-7 / G5-48,bash 产出)。
|
|
2370
2402
|
*
|
|
@@ -2374,13 +2406,13 @@ var init_schema = __esm({
|
|
|
2374
2406
|
* 而「这条命令自称零用例」是**判定事实**,挂在正文形状上会被冲掉。**存在即「没验到东西」**。
|
|
2375
2407
|
* 可选 ⇒ 既有事件零迁移;不喂 LLM。`unchanged` 同款分工,见 spec/repeat-reminder.md 决策 10。
|
|
2376
2408
|
*/
|
|
2377
|
-
falseGreen:
|
|
2378
|
-
unchanged:
|
|
2409
|
+
falseGreen: z5.object({ declaration: z5.string(), sample: z5.string() }).optional(),
|
|
2410
|
+
unchanged: z5.literal(true).optional()
|
|
2379
2411
|
// 等待自报(2026-10-22):工具说「世界没变,我在等」⇒ 重复门豁免
|
|
2380
2412
|
});
|
|
2381
2413
|
CompactionSummarySchema = BaseEventSchema.extend({
|
|
2382
|
-
type:
|
|
2383
|
-
summary:
|
|
2414
|
+
type: z5.literal("compaction/summary"),
|
|
2415
|
+
summary: z5.string(),
|
|
2384
2416
|
/**
|
|
2385
2417
|
* 这次摘要**是谁产的**(演进,`G1-43` 降级路径主动披露):
|
|
2386
2418
|
* `explicit`(调用方给的)· `llm`(LLM 产出)· `rule`(**没给** LLM 摘要,规则兜底——正常路径)
|
|
@@ -2390,9 +2422,9 @@ var init_schema = __esm({
|
|
|
2390
2422
|
* 复盘)就分不出「这次是坏掉了」还是「这次本来就没用 LLM」——那正是 `G10-25` 那条纪律
|
|
2391
2423
|
* (边界要用**可表达的类型**写出来,别靠旁路信号猜)。可选 ⇒ 既有日志零迁移。
|
|
2392
2424
|
*/
|
|
2393
|
-
summarySource:
|
|
2394
|
-
keepMessages:
|
|
2395
|
-
shadowedToolCallIds:
|
|
2425
|
+
summarySource: z5.enum(["explicit", "llm", "rule", "rule-degraded"]).optional(),
|
|
2426
|
+
keepMessages: z5.number().int().nonnegative(),
|
|
2427
|
+
shadowedToolCallIds: z5.array(z5.string()),
|
|
2396
2428
|
/**
|
|
2397
2429
|
* 压缩后**重注的文件**(演进,`spec/compaction.md` 演进:P0-2「谁重新注入」的显式清单)。
|
|
2398
2430
|
*
|
|
@@ -2402,161 +2434,161 @@ var init_schema = __esm({
|
|
|
2402
2434
|
* **本仓不照抄它的数值**且换成字符口径,理由见 `compaction.ts` 的预算常量注释。
|
|
2403
2435
|
* 可选 ⇒ 既有事件零迁移。
|
|
2404
2436
|
*/
|
|
2405
|
-
attachments:
|
|
2437
|
+
attachments: z5.array(z5.object({ path: z5.string(), content: z5.string(), truncated: z5.boolean() })).optional(),
|
|
2406
2438
|
/** 想重注但没重注的文件 + 原因(**如实记账**:模型看不到就得知道为什么,对齐本仓「不静默降级」)。 */
|
|
2407
|
-
attachmentsSkipped:
|
|
2439
|
+
attachmentsSkipped: z5.array(z5.object({ path: z5.string(), reason: z5.string() })).optional(),
|
|
2408
2440
|
/**
|
|
2409
2441
|
* 这次压缩**摘的是哪份源的哪一段**(演进,`spec/session-tree.md` 演进:`G3-15` 摘要到此的出处)。
|
|
2410
2442
|
*
|
|
2411
2443
|
* 「摘要到此」是在**新会话**里写一条压缩事件(前缀被摘要替代、之后原文照抄)——不留出处的话,
|
|
2412
2444
|
* 那份新会话说不清「这段摘要是从哪来的」,审计与人对账都无从下手。**可选** ⇒ 既有压缩零迁移。
|
|
2413
2445
|
*/
|
|
2414
|
-
summarizedSource:
|
|
2415
|
-
sessionId:
|
|
2416
|
-
file:
|
|
2446
|
+
summarizedSource: z5.object({
|
|
2447
|
+
sessionId: z5.string(),
|
|
2448
|
+
file: z5.string(),
|
|
2417
2449
|
/** 摘要覆盖源的 `[1..upToSeq]`。 */
|
|
2418
|
-
upToSeq:
|
|
2450
|
+
upToSeq: z5.number().int().positive()
|
|
2419
2451
|
}).optional()
|
|
2420
2452
|
});
|
|
2421
2453
|
PromptSystemSchema = BaseEventSchema.extend({
|
|
2422
|
-
type:
|
|
2423
|
-
content:
|
|
2454
|
+
type: z5.literal("prompt/system"),
|
|
2455
|
+
content: z5.string(),
|
|
2424
2456
|
/**
|
|
2425
2457
|
* 这次请求**真发出去的工具名清单**(顺序 = 发送顺序;2026-09-21 加,对齐 dsh 的 `EpochHeader`)。
|
|
2426
2458
|
* 补的是一处审计缺口:从前日志只能看出发了哪份 system,看不出**这次用了哪套工具 schema**
|
|
2427
2459
|
* ——"为什么这轮它没调 X"查不出来;缓存侧也没法归因(schema 在 token 流前部,一变就从那里起全失效)。
|
|
2428
2460
|
* 可选(老日志没有这份字段,读到 undefined 即"未记录",不伪造)。
|
|
2429
2461
|
*/
|
|
2430
|
-
tools:
|
|
2462
|
+
tools: z5.array(z5.string()).optional(),
|
|
2431
2463
|
/** 工具 schema 全文的指纹(`fileHash(JSON.stringify(tools))`)——**逐字节**判断"这套 schema 换没换"。 */
|
|
2432
|
-
toolsFingerprint:
|
|
2464
|
+
toolsFingerprint: z5.string().optional(),
|
|
2433
2465
|
/** 工具定义 JSON 的**字符数**(读侧分项账用;只记长度不记全文;老日志无此字段 = 未记录,别当 0。由来见 `spec/token-meter.md` 演进「静态开销有了分项」)。 */
|
|
2434
|
-
toolsChars:
|
|
2466
|
+
toolsChars: z5.number().int().nonnegative().optional()
|
|
2435
2467
|
});
|
|
2436
2468
|
MemoryExtractSchema = BaseEventSchema.extend({
|
|
2437
|
-
type:
|
|
2469
|
+
type: z5.literal("memory/extract"),
|
|
2438
2470
|
/** 过闸并入账的 key。 */
|
|
2439
|
-
admitted:
|
|
2471
|
+
admitted: z5.array(z5.string()),
|
|
2440
2472
|
/** 被拒的候选与理由(**理由要能被人看见**,不是丢掉)。 */
|
|
2441
|
-
rejected:
|
|
2473
|
+
rejected: z5.array(z5.object({ key: z5.string(), reason: z5.string() })),
|
|
2442
2474
|
/** 走取代链的 key(可选)。 */
|
|
2443
|
-
superseded:
|
|
2475
|
+
superseded: z5.array(z5.string()).optional(),
|
|
2444
2476
|
/** true = LLM 输出不可解析 ⇒ **fail-closed 一条没写**(与「判完都拒了」区分开);`error` 是另一种失败:
|
|
2445
2477
|
* 提取那次 LLM 调用**自己抛错**(网络/HTTP/超时)——「解析不出来」与「没拿到输出」日志里要分得开。 */
|
|
2446
|
-
failedClosed:
|
|
2447
|
-
error:
|
|
2478
|
+
failedClosed: z5.boolean().optional(),
|
|
2479
|
+
error: z5.string().optional(),
|
|
2448
2480
|
/** 提取那次 LLM 调用的账(`P1-39` 步一):旁路调用此前完全没账 ⇒ `daluo usage` 系统性少算它;缺省 = provider 未回(不写 `{0,0}`:「没拿到」≠「用了 0」)。 */
|
|
2449
2481
|
usage: LlmUsageSchema.optional(),
|
|
2450
2482
|
/** 这次提取实际用的模型(与 `message/assistant.model` 同源命名)——它可以是独立的 `autoExtract.llm`。 */
|
|
2451
|
-
model:
|
|
2483
|
+
model: z5.string().min(1).optional()
|
|
2452
2484
|
});
|
|
2453
2485
|
CompactionReclaimSchema = BaseEventSchema.extend({
|
|
2454
|
-
type:
|
|
2486
|
+
type: z5.literal("compaction/reclaim"),
|
|
2455
2487
|
/** 候选是否替换了历史(false = 原样保留、等下个边界)。 */
|
|
2456
|
-
committed:
|
|
2488
|
+
committed: z5.boolean(),
|
|
2457
2489
|
/**
|
|
2458
2490
|
* 裁决原因(与 `reclaim-gate.ts` 的词表**同源**:3 个 skip + 2 个 commit + 1 个「冷却中没试」)。
|
|
2459
2491
|
* `cooling-down` = **连试都没试**(拒绝后要等历史又长了一层绝对地板才值得再付一次摘要调用)——
|
|
2460
2492
|
* 那一档没有候选,故下面的数字字段记的是**当时的历史规模**(`beforeTokens === afterTokens`)。
|
|
2461
2493
|
*/
|
|
2462
2494
|
// `reclaim-cache-cold`(G1-57):前缀缓存已冷 ⇒ 只守绝对地板就提交(相对地板是给「热前缀」设的)
|
|
2463
|
-
reason:
|
|
2464
|
-
beforeTokens:
|
|
2465
|
-
afterTokens:
|
|
2495
|
+
reason: z5.enum(["unchanged", "no-reclaim", "below-reclaim-floor", "cooling-down", "reclaim-above-floor", "reclaim-cache-cold", "forced"]),
|
|
2496
|
+
beforeTokens: z5.number().int().nonnegative(),
|
|
2497
|
+
afterTokens: z5.number().int().nonnegative(),
|
|
2466
2498
|
/** 原量 − 新量(**可以为负**:候选可能让输入变长)。 */
|
|
2467
|
-
reclaimedTokens:
|
|
2499
|
+
reclaimedTokens: z5.number().int(),
|
|
2468
2500
|
/** 回收 / 原量(没有回收时为 0)。 */
|
|
2469
|
-
reclaimRatio:
|
|
2501
|
+
reclaimRatio: z5.number().nonnegative(),
|
|
2470
2502
|
/** 候选与原文是否有实质差异(无差异的候选永远不该提交)。 */
|
|
2471
|
-
changed:
|
|
2503
|
+
changed: z5.boolean(),
|
|
2472
2504
|
/** 冷却门槛(只在 `reason: 'cooling-down'` 时有)——「长到这个规模才值得再试」。 */
|
|
2473
|
-
coolingUntilTokens:
|
|
2505
|
+
coolingUntilTokens: z5.number().int().nonnegative().optional()
|
|
2474
2506
|
});
|
|
2475
2507
|
SubagentStartSchema = BaseEventSchema.extend({
|
|
2476
|
-
type:
|
|
2477
|
-
subagentId:
|
|
2478
|
-
task:
|
|
2508
|
+
type: z5.literal("subagent/start"),
|
|
2509
|
+
subagentId: z5.string(),
|
|
2510
|
+
task: z5.string()
|
|
2479
2511
|
});
|
|
2480
2512
|
SubagentReportSchema = BaseEventSchema.extend({
|
|
2481
|
-
type:
|
|
2482
|
-
subagentId:
|
|
2483
|
-
result:
|
|
2513
|
+
type: z5.literal("subagent/report"),
|
|
2514
|
+
subagentId: z5.string(),
|
|
2515
|
+
result: z5.string()
|
|
2484
2516
|
});
|
|
2485
2517
|
VerifyVerdictSchema = BaseEventSchema.extend({
|
|
2486
|
-
type:
|
|
2518
|
+
type: z5.literal("verify/verdict"),
|
|
2487
2519
|
/** 验证者会话 id(`verify-<uuid>`)——与它的独立日志一一对应,可审计。 */
|
|
2488
|
-
verifierId:
|
|
2520
|
+
verifierId: z5.string(),
|
|
2489
2521
|
/** 被验证的主张原文(重放时能看到「当时验的到底是什么」)。 */
|
|
2490
|
-
claim:
|
|
2491
|
-
verdict:
|
|
2522
|
+
claim: z5.string(),
|
|
2523
|
+
verdict: z5.enum(["verified", "falsified", "inconclusive"]),
|
|
2492
2524
|
/** 验证主体:本次覆盖的产物(显式 `artifacts` ∪ 会话中最后改动的非文档文件)。 */
|
|
2493
|
-
artifacts:
|
|
2525
|
+
artifacts: z5.array(z5.string()),
|
|
2494
2526
|
/** 主体内容指纹(16 位十六进制)。**取不到就不写**——不伪造。 */
|
|
2495
|
-
subjectHash:
|
|
2527
|
+
subjectHash: z5.string().optional(),
|
|
2496
2528
|
/** true = 复用既有结论(主体指纹未变,本次**没有**重跑验证者)。 */
|
|
2497
|
-
reused:
|
|
2529
|
+
reused: z5.boolean().optional(),
|
|
2498
2530
|
/** 验证者实际跑了几轮(复用时不写——那次没跑)。 */
|
|
2499
|
-
turns:
|
|
2531
|
+
turns: z5.number().int().nonnegative().optional(),
|
|
2500
2532
|
usage: LlmUsageSchema.optional(),
|
|
2501
2533
|
/** 非正常结束的原因(如 `budget-turns` / `budget-time`);缺失 = 正常跑完。 */
|
|
2502
|
-
stopReason:
|
|
2534
|
+
stopReason: z5.string().optional(),
|
|
2503
2535
|
/** 验证者独立会话日志路径。 */
|
|
2504
|
-
logFile:
|
|
2536
|
+
logFile: z5.string()
|
|
2505
2537
|
});
|
|
2506
|
-
TodoSchema =
|
|
2507
|
-
id:
|
|
2508
|
-
content:
|
|
2509
|
-
status:
|
|
2538
|
+
TodoSchema = z5.object({
|
|
2539
|
+
id: z5.string(),
|
|
2540
|
+
content: z5.string(),
|
|
2541
|
+
status: z5.enum(["pending", "in_progress", "completed"])
|
|
2510
2542
|
});
|
|
2511
2543
|
TodoUpdateSchema = BaseEventSchema.extend({
|
|
2512
|
-
type:
|
|
2513
|
-
todos:
|
|
2544
|
+
type: z5.literal("todo/update"),
|
|
2545
|
+
todos: z5.array(TodoSchema)
|
|
2514
2546
|
});
|
|
2515
2547
|
PlanModeSchema = BaseEventSchema.extend({
|
|
2516
|
-
type:
|
|
2517
|
-
active:
|
|
2548
|
+
type: z5.literal("plan/mode"),
|
|
2549
|
+
active: z5.boolean()
|
|
2518
2550
|
});
|
|
2519
2551
|
PolicyProfileSchema = BaseEventSchema.extend({
|
|
2520
|
-
type:
|
|
2521
|
-
profile:
|
|
2552
|
+
type: z5.literal("policy/profile"),
|
|
2553
|
+
profile: z5.enum(["read-only", "workspace", "danger-full"]),
|
|
2522
2554
|
/** 谁改的(审计用;缺省 'user'——老日志/CLI 内部改动不必标注)。 */
|
|
2523
|
-
by:
|
|
2555
|
+
by: z5.enum(["user", "agent"]).optional()
|
|
2524
2556
|
});
|
|
2525
|
-
GoalSchema =
|
|
2526
|
-
goalId:
|
|
2527
|
-
objective:
|
|
2528
|
-
status:
|
|
2529
|
-
criteria:
|
|
2557
|
+
GoalSchema = z5.object({
|
|
2558
|
+
goalId: z5.string(),
|
|
2559
|
+
objective: z5.string(),
|
|
2560
|
+
status: z5.enum(["active", "completed", "blocked"]),
|
|
2561
|
+
criteria: z5.string().optional()
|
|
2530
2562
|
});
|
|
2531
2563
|
GoalSetSchema = BaseEventSchema.extend({
|
|
2532
|
-
type:
|
|
2533
|
-
goalId:
|
|
2534
|
-
objective:
|
|
2535
|
-
status:
|
|
2536
|
-
criteria:
|
|
2564
|
+
type: z5.literal("goal/set"),
|
|
2565
|
+
goalId: z5.string(),
|
|
2566
|
+
objective: z5.string(),
|
|
2567
|
+
status: z5.enum(["active", "completed", "blocked"]),
|
|
2568
|
+
criteria: z5.string().optional()
|
|
2537
2569
|
});
|
|
2538
|
-
WorkflowNodeSchema =
|
|
2539
|
-
id:
|
|
2540
|
-
task:
|
|
2541
|
-
tools:
|
|
2542
|
-
verify:
|
|
2570
|
+
WorkflowNodeSchema = z5.object({
|
|
2571
|
+
id: z5.string(),
|
|
2572
|
+
task: z5.string(),
|
|
2573
|
+
tools: z5.array(z5.string()).optional(),
|
|
2574
|
+
verify: z5.string().optional()
|
|
2543
2575
|
});
|
|
2544
2576
|
WorkflowStartSchema = BaseEventSchema.extend({
|
|
2545
|
-
type:
|
|
2546
|
-
workflowId:
|
|
2547
|
-
nodes:
|
|
2548
|
-
dependsOn:
|
|
2577
|
+
type: z5.literal("workflow/start"),
|
|
2578
|
+
workflowId: z5.string(),
|
|
2579
|
+
nodes: z5.array(WorkflowNodeSchema),
|
|
2580
|
+
dependsOn: z5.record(z5.string(), z5.array(z5.string()))
|
|
2549
2581
|
});
|
|
2550
2582
|
WorkflowEndSchema = BaseEventSchema.extend({
|
|
2551
|
-
type:
|
|
2552
|
-
workflowId:
|
|
2553
|
-
results:
|
|
2554
|
-
nodeId:
|
|
2555
|
-
status:
|
|
2556
|
-
result:
|
|
2583
|
+
type: z5.literal("workflow/end"),
|
|
2584
|
+
workflowId: z5.string(),
|
|
2585
|
+
results: z5.array(z5.object({
|
|
2586
|
+
nodeId: z5.string(),
|
|
2587
|
+
status: z5.enum(["completed", "failed", "skipped"]),
|
|
2588
|
+
result: z5.string().optional()
|
|
2557
2589
|
}))
|
|
2558
2590
|
});
|
|
2559
|
-
TeamMemberSchema =
|
|
2591
|
+
TeamMemberSchema = z5.object({
|
|
2560
2592
|
/**
|
|
2561
2593
|
* 成员**身份 id**(spec/agent-team.md 决策 20,对齐 dsh 的 live `Agent` 身份 + `senderId/targetId`)。
|
|
2562
2594
|
*
|
|
@@ -2565,227 +2597,227 @@ var init_schema = __esm({
|
|
|
2565
2597
|
* 故身份用单调不回收的 `mem-<n>`,名字退化为**可复用的显示标签**(仅活跃期唯一)。
|
|
2566
2598
|
* Lead 的保留 id 是 `lead`(`mem-` 前缀保证不撞)。
|
|
2567
2599
|
*/
|
|
2568
|
-
id:
|
|
2569
|
-
name:
|
|
2600
|
+
id: z5.string().min(1),
|
|
2601
|
+
name: z5.string().min(1),
|
|
2570
2602
|
/**
|
|
2571
2603
|
* 成员的**职责简述**(对齐 dsh `roster.ts:258` 的 `requiredText(description, 200)`)。
|
|
2572
2604
|
* 与任务一样是「标签 + 完整说明」两段式的成员侧:`name` 是短标识,`description` 说明它被派什么责。
|
|
2573
2605
|
* 契约给缺省 `''` 以兼容加字段前的旧事件;必填性在工具层强制(同 daluo 的输入校验约定)。
|
|
2574
2606
|
*/
|
|
2575
|
-
description:
|
|
2607
|
+
description: z5.string().default(""),
|
|
2576
2608
|
/**
|
|
2577
2609
|
* 成员会话的**上下文来源**(**不是模型供应商**——该字段曾名 `provider`,借用上游
|
|
2578
2610
|
* subagent 术语,与「模型 provider」撞义,2026-09-11 改名)。
|
|
2579
2611
|
* `fresh` = 全新上下文(当前唯一已实现行为)/ `fork` = 继承 Root 已完成轮次(未实现,暂等价 fresh)。
|
|
2580
2612
|
*/
|
|
2581
|
-
context:
|
|
2613
|
+
context: z5.enum(["fresh", "fork"]),
|
|
2582
2614
|
/**
|
|
2583
2615
|
* 成员种类(配额归属):`temp` = 临时员工(占 `maxMembers`)/ `seat` = 议会席位
|
|
2584
2616
|
* (占 `councilSeats` 独立配额)。两套配额互不挤占(用户定 A 方案)。
|
|
2585
2617
|
*/
|
|
2586
|
-
kind:
|
|
2587
|
-
phase:
|
|
2618
|
+
kind: z5.enum(["temp", "seat"]),
|
|
2619
|
+
phase: z5.enum(["provisioning", "active", "failed", "released"]),
|
|
2588
2620
|
/**
|
|
2589
2621
|
* 失败原因(仅 `phase: 'failed'` 有意义)——对齐 dsh `roster.ts:297,425`:
|
|
2590
2622
|
* 快照带 `error`,`list_agents` 的 diagnostics 据此可归因(否则只有「失败了」,
|
|
2591
2623
|
* 不知道是启动炸了还是 prompt 没落盘)。可选,故旧事件 parse 不受影响。
|
|
2592
2624
|
*/
|
|
2593
|
-
error:
|
|
2625
|
+
error: z5.string().optional()
|
|
2594
2626
|
});
|
|
2595
2627
|
TeamMemberCreateSchema = BaseEventSchema.extend({
|
|
2596
|
-
type:
|
|
2597
|
-
teamId:
|
|
2628
|
+
type: z5.literal("team/member"),
|
|
2629
|
+
teamId: z5.string(),
|
|
2598
2630
|
member: TeamMemberSchema
|
|
2599
2631
|
});
|
|
2600
|
-
TeamMessageSchema =
|
|
2601
|
-
id:
|
|
2602
|
-
senderId:
|
|
2603
|
-
senderName:
|
|
2604
|
-
targetId:
|
|
2605
|
-
targetName:
|
|
2606
|
-
content:
|
|
2632
|
+
TeamMessageSchema = z5.object({
|
|
2633
|
+
id: z5.string().min(1),
|
|
2634
|
+
senderId: z5.string().min(1),
|
|
2635
|
+
senderName: z5.string().min(1),
|
|
2636
|
+
targetId: z5.string().min(1),
|
|
2637
|
+
targetName: z5.string().min(1),
|
|
2638
|
+
content: z5.string()
|
|
2607
2639
|
});
|
|
2608
2640
|
TeamMessageQueuedSchema = BaseEventSchema.extend({
|
|
2609
|
-
type:
|
|
2610
|
-
teamId:
|
|
2641
|
+
type: z5.literal("team/message/queued"),
|
|
2642
|
+
teamId: z5.string(),
|
|
2611
2643
|
message: TeamMessageSchema
|
|
2612
2644
|
});
|
|
2613
2645
|
TeamMessageDeliveredSchema = BaseEventSchema.extend({
|
|
2614
|
-
type:
|
|
2615
|
-
teamId:
|
|
2616
|
-
messageId:
|
|
2617
|
-
targetId:
|
|
2646
|
+
type: z5.literal("team/message/delivered"),
|
|
2647
|
+
teamId: z5.string(),
|
|
2648
|
+
messageId: z5.string().min(1),
|
|
2649
|
+
targetId: z5.string().min(1)
|
|
2618
2650
|
});
|
|
2619
|
-
TeamTaskSchema =
|
|
2620
|
-
id:
|
|
2651
|
+
TeamTaskSchema = z5.object({
|
|
2652
|
+
id: z5.string().min(1),
|
|
2621
2653
|
/** 简短标题(dsh `requiredText(subject, 200)`)。 */
|
|
2622
|
-
subject:
|
|
2654
|
+
subject: z5.string(),
|
|
2623
2655
|
/**
|
|
2624
2656
|
* 完整细节 / 验收标准(dsh `requiredText(description, 16384)`)。
|
|
2625
2657
|
* daluo 与 dsh 的差别:**必填性在工具层强制**(daluo 的输入校验统一在工具层,如 subject);
|
|
2626
2658
|
* 契约给缺省 `''` 以兼容加字段前的旧事件。
|
|
2627
2659
|
*/
|
|
2628
|
-
description:
|
|
2629
|
-
status:
|
|
2660
|
+
description: z5.string().default(""),
|
|
2661
|
+
status: z5.enum(["pending", "in_progress", "completed", "deleted"]),
|
|
2630
2662
|
/** 认领者名字(未认领缺省)。 */
|
|
2631
|
-
ownerName:
|
|
2663
|
+
ownerName: z5.string().optional(),
|
|
2632
2664
|
/** 依赖的任务 id:全部 completed 才可 claim(DAG 边)。 */
|
|
2633
|
-
blockedBy:
|
|
2665
|
+
blockedBy: z5.array(z5.string()),
|
|
2634
2666
|
/**
|
|
2635
2667
|
* 任务级**写作用域**(spec/agent-team.md 决策 16,对齐 dsh `writeScope`):
|
|
2636
2668
|
* 该任务计划修改的文件/目录(**规范化相对路径**:无前导 `/`、无双斜杠、无 `.`/`..` 段)。
|
|
2637
2669
|
* 用于并行成员改同一片文件时的**重叠告警**(按路径段前缀判定,advisory 不阻塞)。
|
|
2638
2670
|
* 演进加入:缺省 `[]`(旧事件不带该字段 → parse 后视为未声明)。
|
|
2639
2671
|
*/
|
|
2640
|
-
writeScopes:
|
|
2672
|
+
writeScopes: z5.array(z5.string()).default([]),
|
|
2641
2673
|
/**
|
|
2642
2674
|
* 任务**义务**(spec/council.md 决策 13):本任务声称「完成后必须能通过」的核验命令
|
|
2643
2675
|
* (如 `npm run check`)。完成时服务会拿**回执里的证据**逐条比对(跑过且 exitCode=0),
|
|
2644
2676
|
* 比对不齐 → 拒绝完成。声明在**任务上**(而非议会条目上)——它要可核验、要跟任务同生命周期。
|
|
2645
2677
|
*/
|
|
2646
|
-
obligations:
|
|
2678
|
+
obligations: z5.array(z5.string()).default([]),
|
|
2647
2679
|
/**
|
|
2648
2680
|
* CAS 版本,**从 1 起**(对齐 dsh `task-board.ts:62` 的 `revision: 1` 与
|
|
2649
2681
|
* `projection.ts:265` 的「must begin at revision 1」)——0 是「还不存在」的味道,
|
|
2650
2682
|
* 与「已建」区分开。
|
|
2651
2683
|
*/
|
|
2652
|
-
revision:
|
|
2684
|
+
revision: z5.number().int().positive()
|
|
2653
2685
|
});
|
|
2654
2686
|
TeamTaskUpdateSchema = BaseEventSchema.extend({
|
|
2655
|
-
type:
|
|
2656
|
-
teamId:
|
|
2687
|
+
type: z5.literal("team/task"),
|
|
2688
|
+
teamId: z5.string(),
|
|
2657
2689
|
task: TeamTaskSchema
|
|
2658
2690
|
});
|
|
2659
|
-
TaskEvidenceSchema =
|
|
2691
|
+
TaskEvidenceSchema = z5.object({
|
|
2660
2692
|
/** 跑过的核验命令(与任务 obligations 逐条比对)。 */
|
|
2661
|
-
command:
|
|
2662
|
-
exitCode:
|
|
2693
|
+
command: z5.string().min(1),
|
|
2694
|
+
exitCode: z5.number().int(),
|
|
2663
2695
|
/** 输出摘要(可选;大输出留成员会话,不灌进事件)。 */
|
|
2664
|
-
output:
|
|
2696
|
+
output: z5.string().optional()
|
|
2665
2697
|
});
|
|
2666
|
-
TeamTaskResultSchema =
|
|
2667
|
-
taskId:
|
|
2668
|
-
status:
|
|
2698
|
+
TeamTaskResultSchema = z5.object({
|
|
2699
|
+
taskId: z5.string().min(1),
|
|
2700
|
+
status: z5.enum(["completed", "failed", "interrupted"]),
|
|
2669
2701
|
/** 结论文本(交付面——给 Lead/下一环读,不是全文)。 */
|
|
2670
|
-
summary:
|
|
2671
|
-
evidence:
|
|
2702
|
+
summary: z5.string(),
|
|
2703
|
+
evidence: z5.array(TaskEvidenceSchema).default([]),
|
|
2672
2704
|
/** 度量(对齐 claudecode:工具次数 / 耗时 / token)。 */
|
|
2673
|
-
metrics:
|
|
2674
|
-
toolUses:
|
|
2675
|
-
durationMs:
|
|
2676
|
-
tokens:
|
|
2705
|
+
metrics: z5.object({
|
|
2706
|
+
toolUses: z5.number().int().nonnegative(),
|
|
2707
|
+
durationMs: z5.number().int().nonnegative(),
|
|
2708
|
+
tokens: z5.number().int().nonnegative().optional()
|
|
2677
2709
|
}).optional(),
|
|
2678
2710
|
/** 失败原因(status='failed' 时有值)。 */
|
|
2679
|
-
error:
|
|
2711
|
+
error: z5.string().optional(),
|
|
2680
2712
|
/** 谁报的(成员身份 id,决策 20;Lead 为 `lead`)。 */
|
|
2681
|
-
by:
|
|
2713
|
+
by: z5.string().min(1)
|
|
2682
2714
|
});
|
|
2683
2715
|
TeamTaskResultEventSchema = BaseEventSchema.extend({
|
|
2684
|
-
type:
|
|
2685
|
-
teamId:
|
|
2716
|
+
type: z5.literal("team/task/result"),
|
|
2717
|
+
teamId: z5.string(),
|
|
2686
2718
|
result: TeamTaskResultSchema
|
|
2687
2719
|
});
|
|
2688
2720
|
SessionRenamedSchema = BaseEventSchema.extend({
|
|
2689
|
-
type:
|
|
2690
|
-
title:
|
|
2721
|
+
type: z5.literal("session/renamed"),
|
|
2722
|
+
title: z5.string().min(1),
|
|
2691
2723
|
/**
|
|
2692
2724
|
* 这个名字**谁起的**(`G3-41`)。缺省 = `'user'`(旧日志零迁移)——这一点很要紧:
|
|
2693
2725
|
* 「用户起的名字**永不被覆盖**」靠它判;把自动标题也写成不带标识的一条,日后就没法区分,
|
|
2694
2726
|
* 自动生成会把用户亲手改的名字覆盖掉。
|
|
2695
2727
|
*/
|
|
2696
|
-
source:
|
|
2728
|
+
source: z5.enum(["user", "auto"]).optional()
|
|
2697
2729
|
});
|
|
2698
2730
|
SessionModelChangedSchema = BaseEventSchema.extend({
|
|
2699
|
-
type:
|
|
2700
|
-
model:
|
|
2731
|
+
type: z5.literal("session/model-changed"),
|
|
2732
|
+
model: z5.string().min(1),
|
|
2701
2733
|
/** 提供方 id(`user-config` 的 `ProviderEntry.id`):**只存引用,不存 baseUrl/密钥**(会话日志可被分享/导入)。缺省 = 沿用当前提供方(老日志原样可读)。 */
|
|
2702
|
-
provider:
|
|
2734
|
+
provider: z5.string().min(1).optional()
|
|
2703
2735
|
});
|
|
2704
2736
|
WorkingDirectoryChangedSchema = BaseEventSchema.extend({
|
|
2705
|
-
type:
|
|
2706
|
-
cwd:
|
|
2737
|
+
type: z5.literal("working-directory/change"),
|
|
2738
|
+
cwd: z5.string().min(1)
|
|
2707
2739
|
});
|
|
2708
2740
|
SessionArchivedSchema = BaseEventSchema.extend({
|
|
2709
|
-
type:
|
|
2710
|
-
archived:
|
|
2741
|
+
type: z5.literal("session/archived"),
|
|
2742
|
+
archived: z5.boolean()
|
|
2711
2743
|
});
|
|
2712
2744
|
MAX_LABELS = 32;
|
|
2713
2745
|
MAX_LABEL_KEY_CHARS = 64;
|
|
2714
2746
|
MAX_LABEL_VALUE_CHARS = 256;
|
|
2715
2747
|
SessionLabelsSchema = BaseEventSchema.extend({
|
|
2716
|
-
type:
|
|
2748
|
+
type: z5.literal("session/labels"),
|
|
2717
2749
|
/** 关联标签(如 `{ record: 'ZHBD-0001' }`)。**整体替换**(last-wins);空对象 = 清空。 */
|
|
2718
|
-
labels:
|
|
2750
|
+
labels: z5.record(z5.string().max(MAX_LABEL_KEY_CHARS), z5.string().max(MAX_LABEL_VALUE_CHARS)).refine((l) => Object.keys(l).length <= MAX_LABELS, { message: `\u6807\u7B7E\u6700\u591A ${MAX_LABELS} \u6761` })
|
|
2719
2751
|
});
|
|
2720
2752
|
CommandRunSchema = BaseEventSchema.extend({
|
|
2721
|
-
type:
|
|
2753
|
+
type: z5.literal("command/run"),
|
|
2722
2754
|
/** 配对 id(`c-<uuid>`)——与 command/done 一一对应。 */
|
|
2723
|
-
commandId:
|
|
2724
|
-
name:
|
|
2755
|
+
commandId: z5.string(),
|
|
2756
|
+
name: z5.string(),
|
|
2725
2757
|
/** recordArgs:false 的命令不落此字段(敏感命令的面:不落日志 ≠ 执行时看不到)。 */
|
|
2726
|
-
args:
|
|
2758
|
+
args: z5.string().optional(),
|
|
2727
2759
|
/** 发起方(v1 只有用户输入行——模型侧发起是未来扩展位)。 */
|
|
2728
|
-
source:
|
|
2760
|
+
source: z5.literal("user")
|
|
2729
2761
|
});
|
|
2730
2762
|
CommandDoneSchema = BaseEventSchema.extend({
|
|
2731
|
-
type:
|
|
2732
|
-
commandId:
|
|
2733
|
-
outcome:
|
|
2734
|
-
kind:
|
|
2735
|
-
message:
|
|
2763
|
+
type: z5.literal("command/done"),
|
|
2764
|
+
commandId: z5.string(),
|
|
2765
|
+
outcome: z5.object({
|
|
2766
|
+
kind: z5.enum(["ok", "error"]),
|
|
2767
|
+
message: z5.string().optional()
|
|
2736
2768
|
})
|
|
2737
2769
|
});
|
|
2738
2770
|
InboxQueuedSchema = BaseEventSchema.extend({
|
|
2739
|
-
type:
|
|
2740
|
-
id:
|
|
2741
|
-
content:
|
|
2771
|
+
type: z5.literal("inbox/queued"),
|
|
2772
|
+
id: z5.string(),
|
|
2773
|
+
content: z5.string(),
|
|
2742
2774
|
/** `steering` = 下一轮 request 就带上(mid-turn steer);`queued` = 这一轮跑完当下一回合的输入。 */
|
|
2743
|
-
placement:
|
|
2775
|
+
placement: z5.enum(["queued", "steering"])
|
|
2744
2776
|
});
|
|
2745
2777
|
InboxEditedSchema = BaseEventSchema.extend({
|
|
2746
|
-
type:
|
|
2747
|
-
id:
|
|
2748
|
-
content:
|
|
2778
|
+
type: z5.literal("inbox/edited"),
|
|
2779
|
+
id: z5.string(),
|
|
2780
|
+
content: z5.string()
|
|
2749
2781
|
});
|
|
2750
2782
|
InboxRemovedSchema = BaseEventSchema.extend({
|
|
2751
|
-
type:
|
|
2752
|
-
id:
|
|
2783
|
+
type: z5.literal("inbox/removed"),
|
|
2784
|
+
id: z5.string()
|
|
2753
2785
|
});
|
|
2754
2786
|
InboxRequeuedSchema = BaseEventSchema.extend({
|
|
2755
|
-
type:
|
|
2756
|
-
id:
|
|
2757
|
-
placement:
|
|
2787
|
+
type: z5.literal("inbox/requeued"),
|
|
2788
|
+
id: z5.string(),
|
|
2789
|
+
placement: z5.enum(["queued", "steering"])
|
|
2758
2790
|
});
|
|
2759
|
-
AskOriginSchema =
|
|
2760
|
-
kind:
|
|
2791
|
+
AskOriginSchema = z5.object({
|
|
2792
|
+
kind: z5.enum(["subagent", "workflow-node", "teammate"]),
|
|
2761
2793
|
/** 子运行的身份:subagentId / `${workflowId}/${nodeId}` / 成员名。 */
|
|
2762
|
-
agentId:
|
|
2794
|
+
agentId: z5.string(),
|
|
2763
2795
|
/** 角色名(R9);角色没声明就不带。 */
|
|
2764
|
-
agentType:
|
|
2796
|
+
agentType: z5.string().optional(),
|
|
2765
2797
|
/** 派它干的那句话(子代理 task / workflow node task)。 */
|
|
2766
|
-
description:
|
|
2798
|
+
description: z5.string().optional(),
|
|
2767
2799
|
/** 子运行自己的 sessionId(通常等于 `agentId`;仍显式写,让消费方读它而不必反推)。 */
|
|
2768
|
-
childSessionId:
|
|
2769
|
-
parentSessionId:
|
|
2800
|
+
childSessionId: z5.string(),
|
|
2801
|
+
parentSessionId: z5.string(),
|
|
2770
2802
|
/** **哪一次调用**派的(dispatch 注入的 `input.toolCallId`);拿不到就不带。 */
|
|
2771
|
-
parentToolCallId:
|
|
2803
|
+
parentToolCallId: z5.string().optional()
|
|
2772
2804
|
});
|
|
2773
2805
|
AskRequestedSchema = BaseEventSchema.extend({
|
|
2774
|
-
type:
|
|
2775
|
-
id:
|
|
2776
|
-
kind:
|
|
2777
|
-
question:
|
|
2806
|
+
type: z5.literal("ask/requested"),
|
|
2807
|
+
id: z5.string(),
|
|
2808
|
+
kind: z5.enum(["permission", "question"]),
|
|
2809
|
+
question: z5.string(),
|
|
2778
2810
|
/** 结构化提问的候选(kind=question 时有意义)。 */
|
|
2779
|
-
options:
|
|
2811
|
+
options: z5.array(z5.object({ label: z5.string(), description: z5.string().optional() })).optional(),
|
|
2780
2812
|
/**
|
|
2781
2813
|
* 权限确认的选项(kind=permission 时有意义;`spec/permission-response.md` 决策 1)。
|
|
2782
2814
|
* **与上面的 `options` 是两个字段**(不是同一个字段的两种形状):旧 `options` 的语义与判据一字不动,
|
|
2783
2815
|
* 而两档的选项形状确实不同(提问是候选文案,确认是**带效果的按钮**)——
|
|
2784
2816
|
* 挤进一个 union 会让 permission 的选项以 question 的形状 parse 成功、静默丢掉 `effect`。
|
|
2785
2817
|
*/
|
|
2786
|
-
permissionOptions:
|
|
2818
|
+
permissionOptions: z5.array(PermissionOptionSchema).optional(),
|
|
2787
2819
|
/** 这次确认是否允许「改后批准」(应答带改写后的输入,且必须重过 policy)。 */
|
|
2788
|
-
allowModify:
|
|
2820
|
+
allowModify: z5.boolean().optional(),
|
|
2789
2821
|
/**
|
|
2790
2822
|
* 被确认的**工具输入**(kind=permission 时有意义;`spec/permission-response.md`)。
|
|
2791
2823
|
*
|
|
@@ -2793,14 +2825,14 @@ var init_schema = __esm({
|
|
|
2793
2825
|
* **早就把同一份 input 落在同一个日志文件里**了。而没有它,呈现方**没法预填「要改什么」**,
|
|
2794
2826
|
* 「改后批准」在 UI 上就只剩一个让人手写 JSON 的输入框。
|
|
2795
2827
|
*/
|
|
2796
|
-
input:
|
|
2797
|
-
multiSelect:
|
|
2828
|
+
input: z5.unknown().optional(),
|
|
2829
|
+
multiSelect: z5.boolean().optional(),
|
|
2798
2830
|
/**
|
|
2799
2831
|
* 这次确认的风险档(kind=permission 时有意义;`spec/permission-response.md` 演进 S-03)——
|
|
2800
2832
|
* **请求方声明**(闭集逐字对齐参考 `zcode-protocol/index.ts:930`)。呈现方按它分层、
|
|
2801
2833
|
* 审计按它检索;旧事件没有它 = 「请求方没声明」,按无档呈现(**不猜**)。
|
|
2802
2834
|
*/
|
|
2803
|
-
riskLevel:
|
|
2835
|
+
riskLevel: z5.enum(["low", "medium", "high", "critical"]).optional(),
|
|
2804
2836
|
/**
|
|
2805
2837
|
* 这次确认的**来源**(`spec/permission-provenance.md`):子代理 / workflow node / 团队成员发起的
|
|
2806
2838
|
* 请求带它。旧事件没有它 = 主代理自己的询问(**不猜**——「没声明来源」与「来源非法」是两种失败,
|
|
@@ -2808,64 +2840,64 @@ var init_schema = __esm({
|
|
|
2808
2840
|
*/
|
|
2809
2841
|
origin: AskOriginSchema.optional(),
|
|
2810
2842
|
/** 触发它的工具名(呈现时用来标「批准什么」)。 */
|
|
2811
|
-
toolName:
|
|
2843
|
+
toolName: z5.string().optional(),
|
|
2812
2844
|
/** 等待截止(ISO);超时即按拒绝收尾(fail-safe 不破)。 */
|
|
2813
|
-
expiresAt:
|
|
2845
|
+
expiresAt: z5.string().optional()
|
|
2814
2846
|
});
|
|
2815
2847
|
AskAnsweredSchema = BaseEventSchema.extend({
|
|
2816
|
-
type:
|
|
2817
|
-
id:
|
|
2848
|
+
type: z5.literal("ask/answered"),
|
|
2849
|
+
id: z5.string(),
|
|
2818
2850
|
/** kind=permission:是否放行。 */
|
|
2819
|
-
allow:
|
|
2851
|
+
allow: z5.boolean().optional(),
|
|
2820
2852
|
/**
|
|
2821
2853
|
* 回了**哪个按钮**(`ask/requested.permissionOptions` 里的 `optionId`;`spec/permission-response.md`)。
|
|
2822
2854
|
* 刻意用 `z.string()` 而不是同一份 enum:**认不出的 id 要在解析那一层拒**,
|
|
2823
2855
|
* 让 schema 拒会把整条已落盘事件判成违规(`asks.failures`),把「客户端答错了」记成「日志坏了」。
|
|
2824
2856
|
*/
|
|
2825
|
-
optionId:
|
|
2857
|
+
optionId: z5.string().optional(),
|
|
2826
2858
|
/**
|
|
2827
2859
|
* 改后批准:**改写后的输入**——审计要的就是它(「这次批准到底批了什么」)。
|
|
2828
2860
|
* 冲突命令的批准记录里能读到真跑的那条命令,靠的就是这个字段。
|
|
2829
2861
|
*/
|
|
2830
|
-
modifiedInput:
|
|
2862
|
+
modifiedInput: z5.unknown().optional(),
|
|
2831
2863
|
/** kind=question:自由文本答案 + 选中的 label。 */
|
|
2832
|
-
answer:
|
|
2833
|
-
selected:
|
|
2864
|
+
answer: z5.string().optional(),
|
|
2865
|
+
selected: z5.array(z5.string()).optional(),
|
|
2834
2866
|
/** 为什么结束:用户答 / `timeout`(有人等、等超了)/ `abandoned`(等的人已经没了,见 `session/stale-asks.ts`)/ 无通道。 */
|
|
2835
|
-
reason:
|
|
2867
|
+
reason: z5.enum(["user", "timeout", "abandoned"]).optional()
|
|
2836
2868
|
});
|
|
2837
2869
|
GoalClearedSchema = BaseEventSchema.extend({
|
|
2838
|
-
type:
|
|
2870
|
+
type: z5.literal("goal/cleared"),
|
|
2839
2871
|
/** 被清掉的那个目标 id(防「清错了目标」——fold 只在与当前目标一致时生效)。 */
|
|
2840
|
-
goalId:
|
|
2872
|
+
goalId: z5.string()
|
|
2841
2873
|
});
|
|
2842
2874
|
FeedbackRecordedSchema = BaseEventSchema.extend({
|
|
2843
|
-
type:
|
|
2844
|
-
id:
|
|
2875
|
+
type: z5.literal("feedback/recorded"),
|
|
2876
|
+
id: z5.string(),
|
|
2845
2877
|
/** message = 针对某一条消息(要 messageSeq + rating);session = 针对整会话(要 note 或 category)。 */
|
|
2846
|
-
kind:
|
|
2847
|
-
rating:
|
|
2878
|
+
kind: z5.enum(["message", "session"]),
|
|
2879
|
+
rating: z5.enum(["positive", "negative"]).optional(),
|
|
2848
2880
|
/** 指向 `message/user|assistant` 的 seq(kind=message 时必填——值校验在 fold/助手层)。 */
|
|
2849
|
-
messageSeq:
|
|
2850
|
-
category:
|
|
2851
|
-
note:
|
|
2881
|
+
messageSeq: z5.number().int().optional(),
|
|
2882
|
+
category: z5.string().optional(),
|
|
2883
|
+
note: z5.string().optional()
|
|
2852
2884
|
});
|
|
2853
2885
|
FeedbackRetractedSchema = BaseEventSchema.extend({
|
|
2854
|
-
type:
|
|
2855
|
-
id:
|
|
2886
|
+
type: z5.literal("feedback/retracted"),
|
|
2887
|
+
id: z5.string()
|
|
2856
2888
|
});
|
|
2857
2889
|
SessionBranchSummarySchema = BaseEventSchema.extend({
|
|
2858
|
-
type:
|
|
2890
|
+
type: z5.literal("session/branch-summary"),
|
|
2859
2891
|
/** 摘要正文。空是写入方 bug —— schema 层 fail loud(同 `session/renamed` 的 title 非空)。 */
|
|
2860
|
-
summary:
|
|
2892
|
+
summary: z5.string().min(1),
|
|
2861
2893
|
/** 被放弃路径的出处:源会话 id / 源日志文件名 / **从哪个 seq 之后开始**(= fork 的切割点)。 */
|
|
2862
|
-
abandoned:
|
|
2863
|
-
sessionId:
|
|
2864
|
-
file:
|
|
2865
|
-
fromSeq:
|
|
2894
|
+
abandoned: z5.object({
|
|
2895
|
+
sessionId: z5.string(),
|
|
2896
|
+
file: z5.string(),
|
|
2897
|
+
fromSeq: z5.number().int().positive()
|
|
2866
2898
|
})
|
|
2867
2899
|
});
|
|
2868
|
-
SessionEvent =
|
|
2900
|
+
SessionEvent = z5.discriminatedUnion("type", [
|
|
2869
2901
|
SessionCreatedSchema,
|
|
2870
2902
|
SessionImportedSchema,
|
|
2871
2903
|
/** 分支摘要(演进,spec/session-tree.md 决策 2):fork 时带过来的「被放弃路径」摘要。 */
|
|
@@ -4177,7 +4209,7 @@ var init_scrub = __esm({
|
|
|
4177
4209
|
// packages/core/src/memory/memory.ts
|
|
4178
4210
|
import { mkdir as mkdir3, open as open3, stat as stat3, unlink as unlink3 } from "node:fs/promises";
|
|
4179
4211
|
import { dirname as dirname3 } from "node:path";
|
|
4180
|
-
import { z as
|
|
4212
|
+
import { z as z6 } from "zod";
|
|
4181
4213
|
function describeOrigin(origin) {
|
|
4182
4214
|
if (origin === void 0) return "\u65E0\u6765\u6E90";
|
|
4183
4215
|
if (origin.kind === "user") return "\u7528\u6237\u5F53\u9762\u8981\u6C42";
|
|
@@ -4345,41 +4377,41 @@ var init_memory = __esm({
|
|
|
4345
4377
|
DEFAULT_MEMORY_SOURCE = "manual";
|
|
4346
4378
|
USER_ORIGIN = { kind: "user" };
|
|
4347
4379
|
EXTERNAL_ORIGIN = { kind: "external" };
|
|
4348
|
-
MemoryOriginSchema =
|
|
4349
|
-
|
|
4350
|
-
|
|
4380
|
+
MemoryOriginSchema = z6.discriminatedUnion("kind", [
|
|
4381
|
+
z6.object({ kind: z6.literal("session"), sessionId: z6.string().min(1), seq: z6.number().int().positive() }),
|
|
4382
|
+
z6.object({ kind: z6.literal("user") }),
|
|
4351
4383
|
// 外部客户端转达(无会话上下文,如 MCP 入口):**不是**「用户当面要求」,单独一种来源(自审修正)
|
|
4352
|
-
|
|
4384
|
+
z6.object({ kind: z6.literal("external") })
|
|
4353
4385
|
]);
|
|
4354
4386
|
\u673A\u5668\u6E20\u9053 = ["auto", "dream", "consolidation"];
|
|
4355
|
-
MemoryWriteSchema =
|
|
4356
|
-
seq:
|
|
4357
|
-
ts:
|
|
4358
|
-
type:
|
|
4359
|
-
key:
|
|
4360
|
-
content:
|
|
4361
|
-
memoryType:
|
|
4362
|
-
confidence:
|
|
4363
|
-
source:
|
|
4364
|
-
validFrom:
|
|
4365
|
-
validTo:
|
|
4366
|
-
supersededBy:
|
|
4367
|
-
invalidatedAt:
|
|
4368
|
-
invalidatedReason:
|
|
4387
|
+
MemoryWriteSchema = z6.object({
|
|
4388
|
+
seq: z6.number().int().positive(),
|
|
4389
|
+
ts: z6.string(),
|
|
4390
|
+
type: z6.literal("memory/write"),
|
|
4391
|
+
key: z6.string().min(1, "memory/write key \u4E0D\u80FD\u4E3A\u7A7A"),
|
|
4392
|
+
content: z6.string().min(1, "memory/write content \u4E0D\u80FD\u4E3A\u7A7A"),
|
|
4393
|
+
memoryType: z6.enum(MEMORY_TYPES).optional(),
|
|
4394
|
+
confidence: z6.number().min(0).max(1).optional(),
|
|
4395
|
+
source: z6.enum(MEMORY_SOURCES).optional(),
|
|
4396
|
+
validFrom: z6.number().optional(),
|
|
4397
|
+
validTo: z6.number().optional(),
|
|
4398
|
+
supersededBy: z6.string().optional(),
|
|
4399
|
+
invalidatedAt: z6.number().optional(),
|
|
4400
|
+
invalidatedReason: z6.enum(["resolved", "forgotten"]).optional(),
|
|
4369
4401
|
/** 来源(G4-19):可选 ⇒ 既有事件零迁移;**写入 API 必填**(闸在 `remember` 里)。 */
|
|
4370
4402
|
origin: MemoryOriginSchema.optional()
|
|
4371
4403
|
});
|
|
4372
|
-
MemoryInvalidateSchema =
|
|
4373
|
-
seq:
|
|
4374
|
-
ts:
|
|
4375
|
-
type:
|
|
4376
|
-
key:
|
|
4377
|
-
reason:
|
|
4404
|
+
MemoryInvalidateSchema = z6.object({
|
|
4405
|
+
seq: z6.number().int().positive(),
|
|
4406
|
+
ts: z6.string(),
|
|
4407
|
+
type: z6.literal("memory/invalidate"),
|
|
4408
|
+
key: z6.string().min(1, "memory/invalidate key \u4E0D\u80FD\u4E3A\u7A7A"),
|
|
4409
|
+
reason: z6.enum(["resolved", "forgotten"]),
|
|
4378
4410
|
/** 取代链(可选):这条记忆被哪个 key 取代——`isCurrentFact` 据此把旧叶子判非 current。 */
|
|
4379
|
-
supersededBy:
|
|
4380
|
-
invalidatedAt:
|
|
4411
|
+
supersededBy: z6.string().min(1).optional(),
|
|
4412
|
+
invalidatedAt: z6.number()
|
|
4381
4413
|
});
|
|
4382
|
-
MemoryEvent =
|
|
4414
|
+
MemoryEvent = z6.discriminatedUnion("type", [MemoryWriteSchema, MemoryInvalidateSchema]);
|
|
4383
4415
|
MAX_MEMORY_CONTENT_CHARS = 2e3;
|
|
4384
4416
|
\u9501\u540E\u7F00 = ".lock";
|
|
4385
4417
|
\u9648\u65E7\u9501Ms = 1e4;
|
|
@@ -5029,8 +5061,9 @@ var init_search_index = __esm({
|
|
|
5029
5061
|
});
|
|
5030
5062
|
|
|
5031
5063
|
// packages/core/src/session/project-paths.ts
|
|
5064
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
5032
5065
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2 } from "node:fs";
|
|
5033
|
-
import { join as join5 } from "node:path";
|
|
5066
|
+
import { basename as basename4, isAbsolute, join as join5 } from "node:path";
|
|
5034
5067
|
function daluoDirOf(cwd, opts = {}) {
|
|
5035
5068
|
const dir = join5(cwd, ".daluo");
|
|
5036
5069
|
if (opts.create !== false) mkdirSync(dir, { recursive: true });
|
|
@@ -5101,8 +5134,19 @@ function toolResultsDirOf(cwd, opts = {}) {
|
|
|
5101
5134
|
if (opts.create !== false) mkdirSync(dir, { recursive: true });
|
|
5102
5135
|
return dir;
|
|
5103
5136
|
}
|
|
5104
|
-
function
|
|
5105
|
-
|
|
5137
|
+
function resolveSnapshotDir(env) {
|
|
5138
|
+
const raw = (env[SNAPSHOT_DIR_ENV] ?? "").trim();
|
|
5139
|
+
return raw === "" ? void 0 : raw;
|
|
5140
|
+
}
|
|
5141
|
+
function workspaceKeyOf(cwd) {
|
|
5142
|
+
const \u7EDD\u5BF9 = isAbsolute(cwd) ? cwd : join5(process.cwd(), cwd);
|
|
5143
|
+
const \u540D = basename4(\u7EDD\u5BF9).replace(/[^\w.-]+/g, "-") || "workspace";
|
|
5144
|
+
return `${\u540D}-${createHash2("sha1").update(\u7EDD\u5BF9).digest("hex").slice(0, 8)}`;
|
|
5145
|
+
}
|
|
5146
|
+
function shadowGitDirOf(cwd, snapshotDir) {
|
|
5147
|
+
if (snapshotDir === void 0 || snapshotDir === "") return join5(cwd, ".daluo", "snapshots", "shadow.git");
|
|
5148
|
+
const \u6839 = isAbsolute(snapshotDir) ? snapshotDir : join5(cwd, snapshotDir);
|
|
5149
|
+
return join5(\u6839, workspaceKeyOf(cwd), "shadow.git");
|
|
5106
5150
|
}
|
|
5107
5151
|
function worktreesDirOf(cwd) {
|
|
5108
5152
|
return join5(cwd, ".daluo", "worktrees");
|
|
@@ -5115,6 +5159,7 @@ function resolveSessionIndex(cwd, env) {
|
|
|
5115
5159
|
}
|
|
5116
5160
|
return new SessionIndex(sessionIndexFileOf(cwd));
|
|
5117
5161
|
}
|
|
5162
|
+
var SNAPSHOT_DIR_ENV;
|
|
5118
5163
|
var init_project_paths = __esm({
|
|
5119
5164
|
"packages/core/src/session/project-paths.ts"() {
|
|
5120
5165
|
"use strict";
|
|
@@ -5123,6 +5168,7 @@ var init_project_paths = __esm({
|
|
|
5123
5168
|
init_authorization();
|
|
5124
5169
|
init_memory();
|
|
5125
5170
|
init_search_index();
|
|
5171
|
+
SNAPSHOT_DIR_ENV = "DALUO_SNAPSHOT_DIR";
|
|
5126
5172
|
}
|
|
5127
5173
|
});
|
|
5128
5174
|
|
|
@@ -5395,7 +5441,15 @@ function \u9879\u76EE\u7EA7\u5FFD\u7565\u63D0\u793A(\u88AB\u5FFD\u75652) {
|
|
|
5395
5441
|
const \u952E = \u88AB\u5FFD\u75652.join(" / ");
|
|
5396
5442
|
return `\u672C\u4ED3 .daluo/settings.json \u91CC\u6709 ${\u88AB\u5FFD\u75652.length} \u4E2A\u952E\u4E0D\u8BA9\u9879\u76EE\u7EA7\u751F\u6548\uFF0C\u5DF2\u5FFD\u7565\uFF1A${\u952E}\uFF08\u53EA\u6709\u538B\u7F29\u9884\u7B97\u4E0E\u5916\u89C2\u7C7B\u8BBE\u7F6E\u80FD\u6309\u9879\u76EE\u8986\u76D6\u2014\u2014\u9879\u76EE\u7EA7\u6587\u4EF6\u968F\u4ED3\u5E93\u5206\u53D1\uFF0C\u653E\u5F00\u6743\u9650/\u7AEF\u70B9\u7C7B\u7B49\u4E8E\u8BA9\u4ED3\u5E93\u6539\u4F60\u7684\u5B89\u5168\u9762\uFF1B\u5168\u8868\u89C1 spec/settings.md\uFF09`;
|
|
5397
5443
|
}
|
|
5398
|
-
|
|
5444
|
+
function \u9876\u5C42\u9519\u4F4D\u952E(settings) {
|
|
5445
|
+
return Object.keys(settings.extra).filter((\u952E) => \u8BBE\u7F6E\u767B\u8BB0\u952E\u96C6.has(\u952E)).sort();
|
|
5446
|
+
}
|
|
5447
|
+
function \u9876\u5C42\u9519\u4F4D\u63D0\u793A(settings) {
|
|
5448
|
+
const \u952Es = \u9876\u5C42\u9519\u4F4D\u952E(settings);
|
|
5449
|
+
if (\u952Es.length === 0) return void 0;
|
|
5450
|
+
return `settings.json \u91CC\u6709 ${\u952Es.length} \u4E2A\u952E\u5199\u5728\u4E86\u9876\u5C42\u3001\u4E0D\u4F1A\u751F\u6548\uFF1A${\u952Es.join(" / ")}\uFF08\u9876\u5C42\u53EA\u8BA4 version \u4E0E values\uFF0C\u8BBE\u7F6E\u8981\u5199\u8FDB values \u4E0B\uFF1A{"version": 1, "values": {"permission.rules": [...]}}\u2014\u2014\u5168\u8868\u89C1 spec/settings.md\uFF09`;
|
|
5451
|
+
}
|
|
5452
|
+
var SETTINGS_VERSION, SETTING_ACTIVE_WORKSPACE_ROOT, SETTING_MODEL_DEFAULT, SETTING_MODELS_KNOWN, SETTING_PRICING_MODELS, SETTING_PRICING_CURRENCY, SETTING_PICKER_ROOTS, SETTING_PERMISSION_READ_ROOTS, SETTING_PERMISSION_RULES, SETTING_PERMISSION_READ_ONLY_PROGRAMS, SETTING_UI_THEME, SETTING_UI_FONT_SIZE, SETTING_UI_SEND_WHILE_BUSY, SETTING_UI_PROCESS_DISPLAY, SETTING_UI_SESSION_ORDER, SETTING_UI_GOAL_MODE, SETTING_UI_VIM, SETTING_UI_SCALE, UI_SCALE_STEPS, SETTING_COMPACTION_KEEP_MESSAGES, SETTING_COMPACTION_KEEP_TOKENS, SETTING_COMPACTION_RESERVE_OUTPUT_TOKENS, SETTING_COMPACTION_BUFFER_TOKENS, SETTING_COMPACTION_LLM_SUMMARY, SETTING_LLM_RESPONSE_FORMAT, COMPACTION_KEEP_MESSAGES_MIN, COMPACTION_TOKENS_MIN, UI_FONT_SIZE_MIN, UI_FONT_SIZE_MAX, UI_FONT_SIZE_DEFAULT, \u8BBE\u7F6E\u767B\u8BB0\u952E\u96C6;
|
|
5399
5453
|
var init_settings = __esm({
|
|
5400
5454
|
"packages/core/src/settings/settings.ts"() {
|
|
5401
5455
|
"use strict";
|
|
@@ -5432,6 +5486,7 @@ var init_settings = __esm({
|
|
|
5432
5486
|
UI_FONT_SIZE_MIN = 12;
|
|
5433
5487
|
UI_FONT_SIZE_MAX = 18;
|
|
5434
5488
|
UI_FONT_SIZE_DEFAULT = 14;
|
|
5489
|
+
\u8BBE\u7F6E\u767B\u8BB0\u952E\u96C6 = new Set(\u8BBE\u7F6E\u9879\u4EEC.map((\u9879) => \u9879.\u952E));
|
|
5435
5490
|
}
|
|
5436
5491
|
});
|
|
5437
5492
|
|
|
@@ -6655,7 +6710,7 @@ var init_sanitize = __esm({
|
|
|
6655
6710
|
// packages/core/src/terminal/rc.ts
|
|
6656
6711
|
import { mkdtemp, writeFile as writeFile2 } from "node:fs/promises";
|
|
6657
6712
|
import { homedir as homedir2, tmpdir as tmpdir2 } from "node:os";
|
|
6658
|
-
import { basename as
|
|
6713
|
+
import { basename as basename5, join as join7 } from "node:path";
|
|
6659
6714
|
function markerSnippet(dialect, pty = false) {
|
|
6660
6715
|
const printf = `printf '\\033]${PROMPT_MARKER_PREFIX}\\007'`;
|
|
6661
6716
|
if (dialect === "zsh") {
|
|
@@ -6693,7 +6748,7 @@ function rcContent(input) {
|
|
|
6693
6748
|
async function prepareShellLaunch(input) {
|
|
6694
6749
|
const platform = input.platform ?? process.platform;
|
|
6695
6750
|
const \u58F0\u660E = (input.shell ?? (typeof input.env.SHELL === "string" ? input.env.SHELL : "")).replace(/\/+$/, "");
|
|
6696
|
-
const \u58F0\u660E\u7684 =
|
|
6751
|
+
const \u58F0\u660E\u7684 = basename5(\u58F0\u660E);
|
|
6697
6752
|
const dialect = \u58F0\u660E\u7684 === "zsh" ? "zsh" : "bash";
|
|
6698
6753
|
const shell = platform === "win32" ? "bash.exe" : \u58F0\u660E.startsWith("/") ? \u58F0\u660E : \u58F0\u660E\u7684 === "zsh" || \u58F0\u660E\u7684 === "bash" ? `/bin/${\u58F0\u660E\u7684}` : "/bin/bash";
|
|
6699
6754
|
const home = input.env.HOME ?? homedir2();
|
|
@@ -7423,9 +7478,9 @@ var init_team_write_scope = __esm({
|
|
|
7423
7478
|
});
|
|
7424
7479
|
|
|
7425
7480
|
// packages/core/src/agent/content-hash.ts
|
|
7426
|
-
import { createHash as
|
|
7481
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
7427
7482
|
function fileHash(content) {
|
|
7428
|
-
return
|
|
7483
|
+
return createHash3("sha256").update(content).digest("hex").slice(0, 16);
|
|
7429
7484
|
}
|
|
7430
7485
|
var init_content_hash = __esm({
|
|
7431
7486
|
"packages/core/src/agent/content-hash.ts"() {
|
|
@@ -9192,7 +9247,7 @@ var init_branch_summary = __esm({
|
|
|
9192
9247
|
});
|
|
9193
9248
|
|
|
9194
9249
|
// packages/core/src/session/lifecycle.ts
|
|
9195
|
-
import { basename as
|
|
9250
|
+
import { basename as basename6 } from "node:path";
|
|
9196
9251
|
function nextSeq(log) {
|
|
9197
9252
|
return log.nextSeq();
|
|
9198
9253
|
}
|
|
@@ -9289,7 +9344,7 @@ async function summarizeUpToSession(opts) {
|
|
|
9289
9344
|
if (await fileIdentity(opts.newFile) !== void 0) {
|
|
9290
9345
|
throw new LifecycleUserError(`summarizeUpToSession: \u76EE\u6807\u6587\u4EF6 "${opts.newFile}" \u5DF2\u5B58\u5728\uFF08\u4E0D\u8986\u76D6\u65E2\u6709\u4F1A\u8BDD\uFF09`);
|
|
9291
9346
|
}
|
|
9292
|
-
const sessionId =
|
|
9347
|
+
const sessionId = basename6(opts.newFile).replace(/\.jsonl$/, "");
|
|
9293
9348
|
if (sessionId === "") throw new LifecycleUserError(`summarizeUpToSession: \u76EE\u6807\u6587\u4EF6\u540D\u65E0\u6CD5\u4F5C\u4E3A\u4F1A\u8BDD id\uFF1A${opts.newFile}`);
|
|
9294
9349
|
const shadowed = [];
|
|
9295
9350
|
for (const e of events) {
|
|
@@ -9309,7 +9364,7 @@ async function summarizeUpToSession(opts) {
|
|
|
9309
9364
|
summary,
|
|
9310
9365
|
keepMessages: 0,
|
|
9311
9366
|
shadowedToolCallIds: shadowed,
|
|
9312
|
-
summarizedSource: { sessionId: first.sessionId, file:
|
|
9367
|
+
summarizedSource: { sessionId: first.sessionId, file: basename6(opts.sourceFile), upToSeq: opts.upToSeq }
|
|
9313
9368
|
},
|
|
9314
9369
|
...tail
|
|
9315
9370
|
]);
|
|
@@ -9345,7 +9400,7 @@ async function forkSession(opts) {
|
|
|
9345
9400
|
if (await fileIdentity(opts.newFile) !== void 0) {
|
|
9346
9401
|
throw new LifecycleUserError(`forkSession: \u76EE\u6807\u6587\u4EF6 "${opts.newFile}" \u5DF2\u5B58\u5728\uFF08fork \u4E0D\u8986\u76D6\u65E2\u6709\u4F1A\u8BDD\uFF09`);
|
|
9347
9402
|
}
|
|
9348
|
-
const sessionId =
|
|
9403
|
+
const sessionId = basename6(opts.newFile).replace(/\.jsonl$/, "");
|
|
9349
9404
|
if (sessionId === "") {
|
|
9350
9405
|
throw new LifecycleUserError(`forkSession: \u76EE\u6807\u6587\u4EF6\u540D\u65E0\u6CD5\u4F5C\u4E3A\u4F1A\u8BDD id\uFF1A${opts.newFile}`);
|
|
9351
9406
|
}
|
|
@@ -9354,7 +9409,7 @@ async function forkSession(opts) {
|
|
|
9354
9409
|
seq: 1,
|
|
9355
9410
|
ts: opts.now ? opts.now() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
9356
9411
|
type: "session/created",
|
|
9357
|
-
forkedFrom: { file:
|
|
9412
|
+
forkedFrom: { file: basename6(opts.sourceFile), seq: atSeq, sessionId: first.sessionId }
|
|
9358
9413
|
};
|
|
9359
9414
|
const records = await loadRawRecords(opts.sourceFile);
|
|
9360
9415
|
const copied = records.filter((record) => {
|
|
@@ -9371,7 +9426,7 @@ async function forkSession(opts) {
|
|
|
9371
9426
|
ts: opts.now ? opts.now() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
9372
9427
|
type: "session/branch-summary",
|
|
9373
9428
|
summary,
|
|
9374
|
-
abandoned: { sessionId: first.sessionId, file:
|
|
9429
|
+
abandoned: { sessionId: first.sessionId, file: basename6(opts.sourceFile), fromSeq: atSeq }
|
|
9375
9430
|
}] : [];
|
|
9376
9431
|
await appendEvents(opts.newFile, [created, ...copied, ...trailing]);
|
|
9377
9432
|
return EventLog.restore(opts.newFile);
|
|
@@ -9430,6 +9485,250 @@ var init_builtin_commands = __esm({
|
|
|
9430
9485
|
}
|
|
9431
9486
|
});
|
|
9432
9487
|
|
|
9488
|
+
// packages/core/src/workspace/keyed-serial.ts
|
|
9489
|
+
function byKey(key, \u4EFB\u52A1) {
|
|
9490
|
+
const \u524D\u4E00\u4E2A = \u94FE.get(key) ?? Promise.resolve();
|
|
9491
|
+
const \u672C\u6B21 = \u524D\u4E00\u4E2A.then(\u4EFB\u52A1, \u4EFB\u52A1);
|
|
9492
|
+
const \u5C3E\u5DF4 = \u672C\u6B21.then(
|
|
9493
|
+
() => void 0,
|
|
9494
|
+
() => void 0
|
|
9495
|
+
);
|
|
9496
|
+
\u94FE.set(key, \u5C3E\u5DF4);
|
|
9497
|
+
const \u56DE\u6536 = () => {
|
|
9498
|
+
if (\u94FE.get(key) === \u5C3E\u5DF4) \u94FE.delete(key);
|
|
9499
|
+
};
|
|
9500
|
+
void \u672C\u6B21.then(\u56DE\u6536, \u56DE\u6536);
|
|
9501
|
+
return \u672C\u6B21;
|
|
9502
|
+
}
|
|
9503
|
+
var \u94FE;
|
|
9504
|
+
var init_keyed_serial = __esm({
|
|
9505
|
+
"packages/core/src/workspace/keyed-serial.ts"() {
|
|
9506
|
+
"use strict";
|
|
9507
|
+
\u94FE = /* @__PURE__ */ new Map();
|
|
9508
|
+
}
|
|
9509
|
+
});
|
|
9510
|
+
|
|
9511
|
+
// packages/core/src/workspace/dir-size.ts
|
|
9512
|
+
import { readdir as readdir4, stat as stat6 } from "node:fs/promises";
|
|
9513
|
+
import { join as join9 } from "node:path";
|
|
9514
|
+
async function directoryBytes(dir) {
|
|
9515
|
+
let entries;
|
|
9516
|
+
try {
|
|
9517
|
+
entries = await readdir4(dir, { withFileTypes: true });
|
|
9518
|
+
} catch {
|
|
9519
|
+
return 0;
|
|
9520
|
+
}
|
|
9521
|
+
let total = 0;
|
|
9522
|
+
for (const entry of entries) {
|
|
9523
|
+
const path = join9(dir, entry.name);
|
|
9524
|
+
if (entry.isDirectory()) total += await directoryBytes(path);
|
|
9525
|
+
else if (entry.isFile()) {
|
|
9526
|
+
try {
|
|
9527
|
+
total += (await stat6(path)).size;
|
|
9528
|
+
} catch {
|
|
9529
|
+
}
|
|
9530
|
+
}
|
|
9531
|
+
}
|
|
9532
|
+
return total;
|
|
9533
|
+
}
|
|
9534
|
+
function formatBytes(n) {
|
|
9535
|
+
if (n < 1024) return `${n} B`;
|
|
9536
|
+
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
|
|
9537
|
+
if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
9538
|
+
return `${(n / 1024 / 1024 / 1024).toFixed(1)} GB`;
|
|
9539
|
+
}
|
|
9540
|
+
var init_dir_size = __esm({
|
|
9541
|
+
"packages/core/src/workspace/dir-size.ts"() {
|
|
9542
|
+
"use strict";
|
|
9543
|
+
}
|
|
9544
|
+
});
|
|
9545
|
+
|
|
9546
|
+
// packages/core/src/workspace/snapshot.ts
|
|
9547
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
9548
|
+
import { mkdir as mkdir6, stat as stat7 } from "node:fs/promises";
|
|
9549
|
+
import { join as join10 } from "node:path";
|
|
9550
|
+
function checkpointLabelWithSeq(label, seq) {
|
|
9551
|
+
return `${label} #seq=${seq}`;
|
|
9552
|
+
}
|
|
9553
|
+
function checkpointSeqOf(label) {
|
|
9554
|
+
const m = /(?:^|\s)#seq=(\d+)\s*$/.exec(label);
|
|
9555
|
+
return m === null ? void 0 : Number(m[1]);
|
|
9556
|
+
}
|
|
9557
|
+
function checkpointLabelOf(label) {
|
|
9558
|
+
return label.replace(/\s+#seq=\d+\s*$/, "");
|
|
9559
|
+
}
|
|
9560
|
+
async function runGit(args, opts) {
|
|
9561
|
+
return new Promise((resolve16) => {
|
|
9562
|
+
execFile2(
|
|
9563
|
+
"git",
|
|
9564
|
+
[...args],
|
|
9565
|
+
{ cwd: opts.cwd, timeout: SNAPSHOT_GIT_TIMEOUT_MS, maxBuffer: 8 * 1024 * 1024, ...opts.env ? { env: opts.env } : {} },
|
|
9566
|
+
(error, stdout, stderr) => {
|
|
9567
|
+
try {
|
|
9568
|
+
resolve16({
|
|
9569
|
+
ok: error === null,
|
|
9570
|
+
stdout: String(stdout ?? ""),
|
|
9571
|
+
stderr: String(stderr ?? "") || (error === null ? "" : error.message)
|
|
9572
|
+
});
|
|
9573
|
+
} catch (unexpected) {
|
|
9574
|
+
resolve16({ ok: false, stdout: "", stderr: `git \u8C03\u7528\u5F02\u5E38\uFF1A${unexpected instanceof Error ? unexpected.message : String(unexpected)}` });
|
|
9575
|
+
}
|
|
9576
|
+
}
|
|
9577
|
+
);
|
|
9578
|
+
});
|
|
9579
|
+
}
|
|
9580
|
+
function \u5F71\u5B50\u76EE\u5F55(cwd, env) {
|
|
9581
|
+
return shadowGitDirOf(cwd, resolveSnapshotDir(env ?? process.env));
|
|
9582
|
+
}
|
|
9583
|
+
function shadowArgs(cwd, env, rest) {
|
|
9584
|
+
return [
|
|
9585
|
+
`--git-dir=${\u5F71\u5B50\u76EE\u5F55(cwd, env)}`,
|
|
9586
|
+
`--work-tree=${cwd}`,
|
|
9587
|
+
// 身份与环境隔离:不读用户 git config 的 hook/签名,也不因缺 user.name 而失败
|
|
9588
|
+
"-c",
|
|
9589
|
+
"user.name=daluo",
|
|
9590
|
+
"-c",
|
|
9591
|
+
"user.email=daluo@localhost",
|
|
9592
|
+
"-c",
|
|
9593
|
+
"commit.gpgsign=false",
|
|
9594
|
+
"-c",
|
|
9595
|
+
"core.hooksPath=/dev/null",
|
|
9596
|
+
...rest
|
|
9597
|
+
];
|
|
9598
|
+
}
|
|
9599
|
+
async function ensureShadowRepo(cwd, env) {
|
|
9600
|
+
try {
|
|
9601
|
+
await mkdir6(\u5F71\u5B50\u76EE\u5F55(cwd, env), { recursive: true });
|
|
9602
|
+
} catch (error) {
|
|
9603
|
+
return `\u65E0\u6CD5\u521B\u5EFA\u5F71\u5B50\u4ED3\u5E93\u76EE\u5F55\uFF1A${error instanceof Error ? error.message : String(error)}`;
|
|
9604
|
+
}
|
|
9605
|
+
const init = await runGit([`--git-dir=${\u5F71\u5B50\u76EE\u5F55(cwd, env)}`, "init", "--quiet"], { cwd, ...env ? { env } : {} });
|
|
9606
|
+
return init.ok ? void 0 : `git init \u5931\u8D25\uFF1A${init.stderr.trim()}`;
|
|
9607
|
+
}
|
|
9608
|
+
async function createCheckpointLocked(input) {
|
|
9609
|
+
const { cwd } = input;
|
|
9610
|
+
const label = input.seq === void 0 ? input.label : checkpointLabelWithSeq(input.label, input.seq);
|
|
9611
|
+
const env = input.env;
|
|
9612
|
+
const cap = input.maxFileBytes ?? SNAPSHOT_MAX_FILE_BYTES;
|
|
9613
|
+
if (input.paths !== void 0 && input.paths.length === 0) {
|
|
9614
|
+
return { ok: true, unchanged: true, files: 0 };
|
|
9615
|
+
}
|
|
9616
|
+
const repoProblem = await ensureShadowRepo(cwd, env);
|
|
9617
|
+
if (repoProblem !== void 0) return { ok: false, reason: repoProblem };
|
|
9618
|
+
const skipped = [];
|
|
9619
|
+
const scope = input.paths === void 0 || input.paths.length === 0 ? ["."] : [...input.paths];
|
|
9620
|
+
const listed = await runGit(
|
|
9621
|
+
shadowArgs(cwd, env, ["ls-files", "-o", "-m", "-z", "--exclude-standard", "--", ...scope, ":(exclude).daluo"]),
|
|
9622
|
+
{ cwd, ...env ? { env } : {} }
|
|
9623
|
+
);
|
|
9624
|
+
if (!listed.ok) return { ok: false, reason: `\u904D\u5386\u6587\u4EF6\u5931\u8D25\uFF1A${listed.stderr.trim()}` };
|
|
9625
|
+
const candidates = listed.stdout.split("\0").filter((p) => p !== "");
|
|
9626
|
+
const oversize = [];
|
|
9627
|
+
for (const path of candidates) {
|
|
9628
|
+
const size = await fileSizeBytes(join10(cwd, path));
|
|
9629
|
+
if (size !== void 0 && size > cap) {
|
|
9630
|
+
oversize.push(path);
|
|
9631
|
+
skipped.push({ path, reason: `${(size / 1024 / 1024).toFixed(1)} MB \u8D85\u8FC7\u4E0A\u9650 ${(cap / 1024 / 1024).toFixed(1)} MB` });
|
|
9632
|
+
}
|
|
9633
|
+
}
|
|
9634
|
+
const excludes = [...oversize.map((p) => `:(exclude)${p}`), ":(exclude).daluo"];
|
|
9635
|
+
const add = await runGit(shadowArgs(cwd, env, ["add", "-A", "--", ...scope, ...excludes]), { cwd, ...env ? { env } : {} });
|
|
9636
|
+
if (!add.ok) return { ok: false, reason: `git add \u5931\u8D25\uFF1A${add.stderr.trim()}`, ...skipped.length ? { skipped } : {} };
|
|
9637
|
+
const staged = await runGit(shadowArgs(cwd, env, ["diff", "--cached", "--name-only", "-z"]), { cwd, ...env ? { env } : {} });
|
|
9638
|
+
if (!staged.ok) return { ok: false, reason: `git diff \u5931\u8D25\uFF1A${staged.stderr.trim()}`, ...skipped.length ? { skipped } : {} };
|
|
9639
|
+
const stagedFiles = staged.stdout.split("\0").filter((p) => p !== "");
|
|
9640
|
+
if (stagedFiles.length === 0) {
|
|
9641
|
+
return { ok: true, unchanged: true, files: 0, ...skipped.length ? { skipped } : {} };
|
|
9642
|
+
}
|
|
9643
|
+
const commit2 = await runGit(shadowArgs(cwd, env, ["commit", "--quiet", "-m", label]), { cwd, ...env ? { env } : {} });
|
|
9644
|
+
if (!commit2.ok) return { ok: false, reason: `git commit \u5931\u8D25\uFF1A${commit2.stderr.trim()}`, ...skipped.length ? { skipped } : {} };
|
|
9645
|
+
const hash = await runGit(shadowArgs(cwd, env, ["rev-parse", "HEAD"]), { cwd, ...env ? { env } : {} });
|
|
9646
|
+
return {
|
|
9647
|
+
ok: true,
|
|
9648
|
+
...hash.ok ? { checkpoint: hash.stdout.trim() } : {},
|
|
9649
|
+
files: stagedFiles.length,
|
|
9650
|
+
...skipped.length ? { skipped } : {}
|
|
9651
|
+
};
|
|
9652
|
+
}
|
|
9653
|
+
async function snapshotCost(input) {
|
|
9654
|
+
const { cwd } = input;
|
|
9655
|
+
const env = input.env;
|
|
9656
|
+
const shadow = \u5F71\u5B50\u76EE\u5F55(cwd, env);
|
|
9657
|
+
const count = await runGit(
|
|
9658
|
+
[`--git-dir=${shadow}`, "rev-list", "--count", "HEAD"],
|
|
9659
|
+
{ cwd, ...env ? { env } : {} }
|
|
9660
|
+
);
|
|
9661
|
+
const bytes = await directoryBytes(shadow);
|
|
9662
|
+
if (!count.ok) {
|
|
9663
|
+
return { ok: false, checkpoints: 0, bytes, reason: count.stderr.trim() || "\u8FD8\u6CA1\u6709\u5FEB\u7167\uFF08\u5F71\u5B50\u4ED3\u5E93\u4E0D\u5B58\u5728\u6216\u6CA1\u6709\u63D0\u4EA4\uFF09" };
|
|
9664
|
+
}
|
|
9665
|
+
const checkpoints = Number.parseInt(count.stdout.trim(), 10);
|
|
9666
|
+
return { ok: true, checkpoints: Number.isInteger(checkpoints) ? checkpoints : 0, bytes };
|
|
9667
|
+
}
|
|
9668
|
+
async function fileSizeBytes(path) {
|
|
9669
|
+
try {
|
|
9670
|
+
return (await stat7(path)).size;
|
|
9671
|
+
} catch {
|
|
9672
|
+
return void 0;
|
|
9673
|
+
}
|
|
9674
|
+
}
|
|
9675
|
+
async function listCheckpoints(input) {
|
|
9676
|
+
const { cwd, env } = input;
|
|
9677
|
+
const dir = \u5F71\u5B50\u76EE\u5F55(cwd, env);
|
|
9678
|
+
const limit = input.limit ?? 50;
|
|
9679
|
+
const withFiles = input.withFiles === true;
|
|
9680
|
+
const log = await runGit(
|
|
9681
|
+
shadowArgs(cwd, env, [
|
|
9682
|
+
"log",
|
|
9683
|
+
`-n${limit}`,
|
|
9684
|
+
...withFiles ? ["--numstat"] : [],
|
|
9685
|
+
"--format=%x01%H%x09%cI%x09%s"
|
|
9686
|
+
]),
|
|
9687
|
+
{ cwd, ...env ? { env } : {} }
|
|
9688
|
+
);
|
|
9689
|
+
if (!log.ok) return { ok: false, checkpoints: [], dir, reason: log.stderr.trim() || "\u65E0\u5FEB\u7167\u6216 git \u4E0D\u53EF\u7528" };
|
|
9690
|
+
const checkpoints = [];
|
|
9691
|
+
for (const line of log.stdout.split("\n")) {
|
|
9692
|
+
if (line.trim() === "") continue;
|
|
9693
|
+
if (line.startsWith("")) {
|
|
9694
|
+
const [hash = "", ts = "", ...rest] = line.slice(1).split(" ");
|
|
9695
|
+
const label = rest.join(" ");
|
|
9696
|
+
const seq = checkpointSeqOf(label);
|
|
9697
|
+
checkpoints.push({ hash, ts, label, ...seq !== void 0 ? { seq } : {}, ...withFiles ? { files: 0 } : {} });
|
|
9698
|
+
continue;
|
|
9699
|
+
}
|
|
9700
|
+
const \u5F53\u524D = checkpoints[checkpoints.length - 1];
|
|
9701
|
+
if (withFiles && \u5F53\u524D !== void 0) \u5F53\u524D.files = (\u5F53\u524D.files ?? 0) + 1;
|
|
9702
|
+
}
|
|
9703
|
+
return { ok: true, checkpoints, dir };
|
|
9704
|
+
}
|
|
9705
|
+
async function restoreCheckpointLocked(input) {
|
|
9706
|
+
const { cwd, checkpoint, env } = input;
|
|
9707
|
+
const target = input.path === void 0 || input.path === "" ? "." : input.path;
|
|
9708
|
+
const out = await runGit(
|
|
9709
|
+
shadowArgs(cwd, env, ["checkout", checkpoint, "--", target]),
|
|
9710
|
+
{ cwd, ...env ? { env } : {} }
|
|
9711
|
+
);
|
|
9712
|
+
return out.ok ? { ok: true, restored: target } : { ok: false, reason: `\u6062\u590D\u5931\u8D25\uFF1A${out.stderr.trim()}` };
|
|
9713
|
+
}
|
|
9714
|
+
function createCheckpoint(input) {
|
|
9715
|
+
return byKey(\u5F71\u5B50\u76EE\u5F55(input.cwd, input.env), () => createCheckpointLocked(input));
|
|
9716
|
+
}
|
|
9717
|
+
function restoreCheckpoint(input) {
|
|
9718
|
+
return byKey(\u5F71\u5B50\u76EE\u5F55(input.cwd, input.env), () => restoreCheckpointLocked(input));
|
|
9719
|
+
}
|
|
9720
|
+
var SNAPSHOT_MAX_FILE_BYTES, SNAPSHOT_GIT_TIMEOUT_MS;
|
|
9721
|
+
var init_snapshot = __esm({
|
|
9722
|
+
"packages/core/src/workspace/snapshot.ts"() {
|
|
9723
|
+
"use strict";
|
|
9724
|
+
init_project_paths();
|
|
9725
|
+
init_keyed_serial();
|
|
9726
|
+
init_dir_size();
|
|
9727
|
+
SNAPSHOT_MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
9728
|
+
SNAPSHOT_GIT_TIMEOUT_MS = 2e4;
|
|
9729
|
+
}
|
|
9730
|
+
});
|
|
9731
|
+
|
|
9433
9732
|
// packages/core/src/session/scheduler/scheduler.ts
|
|
9434
9733
|
var MAX_STEPS, Scheduler;
|
|
9435
9734
|
var init_scheduler = __esm({
|
|
@@ -9686,9 +9985,9 @@ var init_token_estimator = __esm({
|
|
|
9686
9985
|
});
|
|
9687
9986
|
|
|
9688
9987
|
// packages/core/src/session/working-directory.ts
|
|
9689
|
-
import { realpath, stat as
|
|
9988
|
+
import { realpath, stat as stat8 } from "node:fs/promises";
|
|
9690
9989
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
9691
|
-
import { isAbsolute, resolve, sep } from "node:path";
|
|
9990
|
+
import { isAbsolute as isAbsolute2, resolve, sep } from "node:path";
|
|
9692
9991
|
function \u5728\u754C\u5185(\u6839, \u7EDD\u5BF9) {
|
|
9693
9992
|
const \u754C = resolve(\u6839);
|
|
9694
9993
|
const p = resolve(\u7EDD\u5BF9);
|
|
@@ -9704,7 +10003,7 @@ function \u771F\u8EAB\u5728\u754C\u5185(\u6839, \u7EDD\u5BF9) {
|
|
|
9704
10003
|
function \u6267\u884C\u57FA\u70B9(\u5019\u9009, \u8FB9\u754C\u6839) {
|
|
9705
10004
|
const \u754C = resolve(\u8FB9\u754C\u6839);
|
|
9706
10005
|
if (\u5019\u9009 === void 0 || \u5019\u9009 === "") return \u754C;
|
|
9707
|
-
const \u7EDD\u5BF9 =
|
|
10006
|
+
const \u7EDD\u5BF9 = isAbsolute2(\u5019\u9009) ? resolve(\u5019\u9009) : resolve(\u754C, \u5019\u9009);
|
|
9708
10007
|
if (\u5728\u754C\u5185(\u754C, \u7EDD\u5BF9)) return \u7EDD\u5BF9;
|
|
9709
10008
|
return \u771F\u8EAB\u5728\u754C\u5185(\u754C, \u7EDD\u5BF9) ? \u7EDD\u5BF9 : \u754C;
|
|
9710
10009
|
}
|
|
@@ -9715,7 +10014,7 @@ function \u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55(state, \u8D77\u70B9\u68392) {
|
|
|
9715
10014
|
}
|
|
9716
10015
|
async function \u76EE\u5F55\u8FD8\u5728(\u8DEF\u5F84) {
|
|
9717
10016
|
try {
|
|
9718
|
-
return (await
|
|
10017
|
+
return (await stat8(\u8DEF\u5F84)).isDirectory();
|
|
9719
10018
|
} catch {
|
|
9720
10019
|
return false;
|
|
9721
10020
|
}
|
|
@@ -9723,7 +10022,7 @@ async function \u76EE\u5F55\u8FD8\u5728(\u8DEF\u5F84) {
|
|
|
9723
10022
|
async function \u6821\u9A8C\u5F85\u5207\u76EE\u5F55(\u76EE\u6807, \u8FB9\u754C\u6839, \u57FA\u51C6) {
|
|
9724
10023
|
const \u6E90 = typeof \u76EE\u6807 === "string" ? \u76EE\u6807.trim() : "";
|
|
9725
10024
|
if (\u6E90 === "") return { kind: "error", message: "working_directory: set \u9700\u8981 path\uFF08\u8981\u5207\u5230\u7684\u76EE\u5F55\uFF09" };
|
|
9726
|
-
const \u5019\u9009 =
|
|
10025
|
+
const \u5019\u9009 = isAbsolute2(\u6E90) ? resolve(\u6E90) : resolve(\u57FA\u51C6, \u6E90);
|
|
9727
10026
|
if (\u5728\u754C\u5185(\u8FB9\u754C\u6839, \u5019\u9009) === false && \u771F\u8EAB\u5728\u754C\u5185(\u8FB9\u754C\u6839, \u5019\u9009) === false) {
|
|
9728
10027
|
return {
|
|
9729
10028
|
kind: "error",
|
|
@@ -9732,7 +10031,7 @@ async function \u6821\u9A8C\u5F85\u5207\u76EE\u5F55(\u76EE\u6807, \u8FB9\u754C\u
|
|
|
9732
10031
|
}
|
|
9733
10032
|
let \u771F\u8EAB;
|
|
9734
10033
|
try {
|
|
9735
|
-
const st = await
|
|
10034
|
+
const st = await stat8(\u5019\u9009);
|
|
9736
10035
|
if (st.isDirectory() === false) {
|
|
9737
10036
|
return { kind: "error", message: `working_directory: \u4E0D\u662F\u76EE\u5F55\uFF08${\u5019\u9009}\uFF09\u2014\u2014\u5207\u76EE\u5F55\u7684\u76EE\u6807\u5FC5\u987B\u662F\u76EE\u5F55` };
|
|
9738
10037
|
}
|
|
@@ -9803,7 +10102,7 @@ var init_essence_gate = __esm({
|
|
|
9803
10102
|
});
|
|
9804
10103
|
|
|
9805
10104
|
// packages/core/src/agent/file-gate.ts
|
|
9806
|
-
import { stat as
|
|
10105
|
+
import { stat as stat9 } from "node:fs/promises";
|
|
9807
10106
|
function \u65B0\u5EFA\u4F1A\u8BDD\u6587\u4EF6\u6001() {
|
|
9808
10107
|
return { readSet: /* @__PURE__ */ new Set(), fileState: /* @__PURE__ */ new Map() };
|
|
9809
10108
|
}
|
|
@@ -9824,7 +10123,7 @@ function \u53D6\u4F1A\u8BDD\u6587\u4EF6\u6001(\u4F1A\u8BDD\u952E) {
|
|
|
9824
10123
|
}
|
|
9825
10124
|
async function statMtimeMs(path) {
|
|
9826
10125
|
try {
|
|
9827
|
-
return (await
|
|
10126
|
+
return (await stat9(path)).mtimeMs;
|
|
9828
10127
|
} catch (error) {
|
|
9829
10128
|
const code = error.code;
|
|
9830
10129
|
if (code === "ENOENT") return null;
|
|
@@ -9833,7 +10132,7 @@ async function statMtimeMs(path) {
|
|
|
9833
10132
|
}
|
|
9834
10133
|
async function statPath(path) {
|
|
9835
10134
|
try {
|
|
9836
|
-
const st = await
|
|
10135
|
+
const st = await stat9(path);
|
|
9837
10136
|
return { mtimeMs: st.mtimeMs, isFile: st.isFile() };
|
|
9838
10137
|
} catch (error) {
|
|
9839
10138
|
const code = error.code;
|
|
@@ -11183,7 +11482,10 @@ function isContextOverflowError(err) {
|
|
|
11183
11482
|
function classifyLlmError(err) {
|
|
11184
11483
|
if (err instanceof LlmTimeoutError) return { category: "timeout", retryable: false, capacity: false };
|
|
11185
11484
|
if (err instanceof LlmStreamError) return { category: "stream-error", retryable: false, capacity: false };
|
|
11186
|
-
if (err instanceof LlmToolArgsError)
|
|
11485
|
+
if (err instanceof LlmToolArgsError) {
|
|
11486
|
+
if (err.finishReason === "length") return { category: "truncated", retryable: false, capacity: false };
|
|
11487
|
+
return { category: "model-output", retryable: true, capacity: false };
|
|
11488
|
+
}
|
|
11187
11489
|
if (err instanceof LlmResponseFormatError) return { category: "fatal", retryable: false, capacity: false };
|
|
11188
11490
|
if (isAbortError(err)) return { category: "aborted", retryable: false, capacity: false };
|
|
11189
11491
|
if (err instanceof LlmHttpError) {
|
|
@@ -11225,10 +11527,17 @@ var init_error_classify = __esm({
|
|
|
11225
11527
|
LlmToolArgsError = class extends Error {
|
|
11226
11528
|
/** 出问题的工具名(可读提示要用;**不带参数原文**——它可能几百字,别让它进日志/终端)。 */
|
|
11227
11529
|
toolName;
|
|
11228
|
-
|
|
11530
|
+
/**
|
|
11531
|
+
* 上游给的 `finish_reason`(GitHub issue #9)。**`length` 是分水岭**:它说明这次输出是被
|
|
11532
|
+
* `max_tokens` 截断的 —— 同样的配置重采样还会再截断,而 `stop`/`tool_calls` 下的坏 JSON
|
|
11533
|
+
* 才是「采样手抖、重采样大概率就好」。不带它就只能把两种混成同一档。
|
|
11534
|
+
*/
|
|
11535
|
+
finishReason;
|
|
11536
|
+
constructor(message, toolName, finishReason) {
|
|
11229
11537
|
super(message);
|
|
11230
11538
|
this.name = "LlmToolArgsError";
|
|
11231
11539
|
this.toolName = toolName;
|
|
11540
|
+
this.finishReason = finishReason;
|
|
11232
11541
|
}
|
|
11233
11542
|
};
|
|
11234
11543
|
LlmResponseFormatError = class extends Error {
|
|
@@ -11318,13 +11627,13 @@ var init_cache_breakpoint = __esm({
|
|
|
11318
11627
|
// packages/core/src/agent/project-docs.ts
|
|
11319
11628
|
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
|
|
11320
11629
|
import { homedir as homedir3 } from "node:os";
|
|
11321
|
-
import { join as
|
|
11630
|
+
import { join as join11 } from "node:path";
|
|
11322
11631
|
function projectDocCandidates(input) {
|
|
11323
11632
|
const home = input.home ?? homedir3();
|
|
11324
11633
|
return [
|
|
11325
|
-
{ path:
|
|
11326
|
-
{ path:
|
|
11327
|
-
{ path:
|
|
11634
|
+
{ path: join11(home, ".claude", "CLAUDE.md"), source: "user" },
|
|
11635
|
+
{ path: join11(input.cwd, "AGENTS.md"), source: "project-agents" },
|
|
11636
|
+
{ path: join11(input.cwd, "CLAUDE.md"), source: "project-claude" }
|
|
11328
11637
|
];
|
|
11329
11638
|
}
|
|
11330
11639
|
function projectDocsDisabled(env) {
|
|
@@ -11634,7 +11943,7 @@ var init_auto_recall_query = __esm({
|
|
|
11634
11943
|
});
|
|
11635
11944
|
|
|
11636
11945
|
// packages/core/src/agent/request-step.ts
|
|
11637
|
-
import { join as
|
|
11946
|
+
import { join as join12 } from "node:path";
|
|
11638
11947
|
function \u8D77\u70B9\u6839(ctx) {
|
|
11639
11948
|
return ctx.workspace?.cwd;
|
|
11640
11949
|
}
|
|
@@ -11790,7 +12099,7 @@ function createRequestStep(config = {}) {
|
|
|
11790
12099
|
if (ctx.extraSystem && ctx.extraSystem.trim() !== "") parts.push(contextNotePart(ctx.extraSystem));
|
|
11791
12100
|
if (log.state.planMode) {
|
|
11792
12101
|
const planTurns = planTurnsSinceEnter(log.snapshot(), true);
|
|
11793
|
-
const planFile = ctx.workspace?.cwd ?
|
|
12102
|
+
const planFile = ctx.workspace?.cwd ? join12(\u8D77\u70B9\u6839(ctx) ?? ctx.workspace.cwd, ".daluo", "plans", `${log.state.sessionId ?? "session"}.md`).replaceAll("\\", "/") : void 0;
|
|
11794
12103
|
parts.push({
|
|
11795
12104
|
kind: "plan-mode",
|
|
11796
12105
|
text: `\u5F53\u524D\u5904\u4E8E\u8BA1\u5212\u6A21\u5F0F\uFF1A\u53EA\u8BFB\u63A2\u7D22\uFF08${READ_FILE}/${GREP}/${GLOB}/${LSP}\uFF09\uFF0C\u4E0D\u5199\u6587\u4EF6\u4E0D\u6539\u4EE3\u7801\u3002` + (planFile ? `
|
|
@@ -11911,6 +12220,8 @@ function createRequestStep(config = {}) {
|
|
|
11911
12220
|
const \u534F\u8BAE\u8FDD\u89C4 = \u8BF7\u6C42\u534F\u8BAE\u8FDD\u89C4(chatMessages);
|
|
11912
12221
|
if (\u534F\u8BAE\u8FDD\u89C4 !== void 0) throw new Error(`\u8BF7\u6C42\u534F\u8BAE\u81EA\u8BC1\u5931\u8D25\uFF08\u5F62\u72B6\u8FDD\u53CD provider \u534F\u8BAE\uFF09\uFF1A${\u534F\u8BAE\u8FDD\u89C4}`);
|
|
11913
12222
|
const \u53D1\u9001\u6D88\u606F = \u5E26\u65AD\u70B9 ? withCacheBreakpoint(chatMessages) : chatMessages;
|
|
12223
|
+
const \u8BF7\u6C42\u8D77 = Date.now();
|
|
12224
|
+
let \u8BF7\u6C42\u8017\u65F6Ms = 0;
|
|
11914
12225
|
let response;
|
|
11915
12226
|
try {
|
|
11916
12227
|
if (ctx.useStream && typeof llm.completeStream === "function") {
|
|
@@ -11929,6 +12240,7 @@ function createRequestStep(config = {}) {
|
|
|
11929
12240
|
...ctx.signal ? { signal: ctx.signal } : {}
|
|
11930
12241
|
});
|
|
11931
12242
|
}
|
|
12243
|
+
\u8BF7\u6C42\u8017\u65F6Ms = Date.now() - \u8BF7\u6C42\u8D77;
|
|
11932
12244
|
if (ctx.budgetState && response.usage) {
|
|
11933
12245
|
ctx.budgetState.tokens += response.usage.promptTokens + response.usage.completionTokens;
|
|
11934
12246
|
ctx.budgetState.promptTokens = (ctx.budgetState.promptTokens ?? 0) + response.usage.promptTokens;
|
|
@@ -12002,7 +12314,11 @@ function createRequestStep(config = {}) {
|
|
|
12002
12314
|
input = JSON.parse(tc.arguments);
|
|
12003
12315
|
} catch {
|
|
12004
12316
|
const \u539F\u6587 = tc.arguments.length > 200 ? `${tc.arguments.slice(0, 200)}\u2026\uFF08\u5171 ${tc.arguments.length} \u5B57\u7B26\uFF09` : tc.arguments;
|
|
12005
|
-
throw new LlmToolArgsError(
|
|
12317
|
+
throw new LlmToolArgsError(
|
|
12318
|
+
`request step: tool_calls arguments \u975E JSON\uFF08name=${tc.name}\uFF09\uFF1A${\u539F\u6587}`,
|
|
12319
|
+
tc.name,
|
|
12320
|
+
response.finishReason === "" ? void 0 : response.finishReason
|
|
12321
|
+
);
|
|
12006
12322
|
}
|
|
12007
12323
|
return { type: "tool-call", toolCallId: tc.id, toolName: tc.name, input };
|
|
12008
12324
|
});
|
|
@@ -12021,7 +12337,10 @@ function createRequestStep(config = {}) {
|
|
|
12021
12337
|
// 模型身份进日志(G8-30 第 1 段):记**当轮实际发的 model**(含 before/request 改写)。
|
|
12022
12338
|
model: request.model,
|
|
12023
12339
|
// 真实 usage 落日志(spec/session-event.md 演进节):provider 未回则缺省不写
|
|
12024
|
-
...response.usage ? { usage: { ...response.usage } } : {}
|
|
12340
|
+
...response.usage ? { usage: { ...response.usage } } : {},
|
|
12341
|
+
// 耗时与上游 finish_reason(issue #9):空串 = provider 没回,**不写**(不编 'stop')
|
|
12342
|
+
durationMs: \u8BF7\u6C42\u8017\u65F6Ms,
|
|
12343
|
+
...response.finishReason !== "" ? { finishReason: response.finishReason } : {}
|
|
12025
12344
|
});
|
|
12026
12345
|
return { next: "tool-dispatch" };
|
|
12027
12346
|
}
|
|
@@ -12037,7 +12356,11 @@ function createRequestStep(config = {}) {
|
|
|
12037
12356
|
],
|
|
12038
12357
|
// 模型身份进日志(G8-30 第 1 段):同工具轮,记当轮实际用的 model。
|
|
12039
12358
|
model: request.model,
|
|
12040
|
-
...response.usage ? { usage: { ...response.usage } } : {}
|
|
12359
|
+
...response.usage ? { usage: { ...response.usage } } : {},
|
|
12360
|
+
// 耗时与 finish_reason(issue #9):与工具轮同口径。`length` 在这里意味着**正文被截断**
|
|
12361
|
+
// (此前这条是静默成功:宿主只看到「答完了」,看不出答案是半截)。
|
|
12362
|
+
durationMs: \u8BF7\u6C42\u8017\u65F6Ms,
|
|
12363
|
+
...response.finishReason !== "" ? { finishReason: response.finishReason } : {}
|
|
12041
12364
|
});
|
|
12042
12365
|
return { next: textNext };
|
|
12043
12366
|
}
|
|
@@ -12176,11 +12499,11 @@ var init_inbox = __esm({
|
|
|
12176
12499
|
});
|
|
12177
12500
|
|
|
12178
12501
|
// packages/core/src/agent/bash-escape.ts
|
|
12179
|
-
import { basename as
|
|
12502
|
+
import { basename as basename7, dirname as dirname6, isAbsolute as isAbsolute3, join as join13, relative, resolve as resolve2, sep as sep2 } from "node:path";
|
|
12180
12503
|
import { realpathSync as realpathSync3 } from "node:fs";
|
|
12181
12504
|
function withinByString(base, abs) {
|
|
12182
12505
|
const rel = relative(base, abs);
|
|
12183
|
-
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep2}`) && !
|
|
12506
|
+
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep2}`) && !isAbsolute3(rel);
|
|
12184
12507
|
}
|
|
12185
12508
|
function canonicalize2(path) {
|
|
12186
12509
|
let head = resolve2(path);
|
|
@@ -12188,18 +12511,18 @@ function canonicalize2(path) {
|
|
|
12188
12511
|
for (; ; ) {
|
|
12189
12512
|
try {
|
|
12190
12513
|
const real = realpathSync3(head);
|
|
12191
|
-
return tail.length === 0 ? real :
|
|
12514
|
+
return tail.length === 0 ? real : join13(real, ...tail.reverse());
|
|
12192
12515
|
} catch {
|
|
12193
12516
|
const parent = dirname6(head);
|
|
12194
12517
|
if (parent === head) return void 0;
|
|
12195
|
-
tail.push(
|
|
12518
|
+
tail.push(basename7(head));
|
|
12196
12519
|
head = parent;
|
|
12197
12520
|
}
|
|
12198
12521
|
}
|
|
12199
12522
|
}
|
|
12200
12523
|
function isWithinDir(dir, target) {
|
|
12201
12524
|
const base = resolve2(dir);
|
|
12202
|
-
const abs =
|
|
12525
|
+
const abs = isAbsolute3(target) ? resolve2(target) : resolve2(base, target);
|
|
12203
12526
|
const realBase = canonicalize2(base);
|
|
12204
12527
|
const realAbs = canonicalize2(abs);
|
|
12205
12528
|
if (realBase !== void 0 && realAbs !== void 0) return withinByString(realBase, realAbs);
|
|
@@ -12311,7 +12634,7 @@ function inspectBashEscape(command, cwd, allowedRoots) {
|
|
|
12311
12634
|
if (DYNAMIC.test(rawTarget)) return { kind: "ambiguous", detail: `${program} \u76EE\u6807\u542B\u53D8\u91CF/\u547D\u4EE4\u66FF\u6362\uFF1A${rawTarget}` };
|
|
12312
12635
|
if (rawTarget.startsWith("~")) return { kind: "escape", detail: `${program} \u76EE\u6807\u4E3A\u5BB6\u76EE\u5F55\uFF1A${rawTarget}` };
|
|
12313
12636
|
const target = normalizeBashPath(rawTarget);
|
|
12314
|
-
if (
|
|
12637
|
+
if (isAbsolute3(target) || target.split(/[/\\]/).includes("..")) {
|
|
12315
12638
|
if (!\u5728\u5185(target)) {
|
|
12316
12639
|
return { kind: "escape", detail: `${program} \u76EE\u6807\u5728 cwd \u5916\uFF1A${rawTarget}\uFF08\u89E3\u6790\u4E3A ${resolve2(cwd, target)}\uFF09` };
|
|
12317
12640
|
}
|
|
@@ -12319,7 +12642,7 @@ function inspectBashEscape(command, cwd, allowedRoots) {
|
|
|
12319
12642
|
continue;
|
|
12320
12643
|
}
|
|
12321
12644
|
const programPath = normalizeBashPath(program);
|
|
12322
|
-
if (
|
|
12645
|
+
if (isAbsolute3(programPath) || programPath.startsWith("~")) {
|
|
12323
12646
|
if (!\u5728\u5185(programPath)) {
|
|
12324
12647
|
return { kind: "escape", detail: `\u7A0B\u5E8F\u5728 cwd \u5916\uFF1A${program}\uFF08\u89E3\u6790\u4E3A ${resolve2(cwd, programPath)}\uFF09` };
|
|
12325
12648
|
}
|
|
@@ -12414,7 +12737,7 @@ var init_bash_rules = __esm({
|
|
|
12414
12737
|
});
|
|
12415
12738
|
|
|
12416
12739
|
// packages/core/src/agent/permission-rules.ts
|
|
12417
|
-
import { isAbsolute as
|
|
12740
|
+
import { isAbsolute as isAbsolute4, resolve as resolve3 } from "node:path";
|
|
12418
12741
|
function \u89E3\u6790\u6743\u9650\u89C4\u5219(\u503C) {
|
|
12419
12742
|
if (!Array.isArray(\u503C)) return [];
|
|
12420
12743
|
const out = [];
|
|
@@ -12477,8 +12800,8 @@ function \u5355\u6761\u547D\u4E2D(rule, \u4E8B\u5B9E) {
|
|
|
12477
12800
|
if (\u4E8B\u5B9E.meta?.pathScoped === true) {
|
|
12478
12801
|
const \u8DEF\u5F84s = \u63D0\u53D6\u8DEF\u5F84(\u4E8B\u5B9E.input);
|
|
12479
12802
|
if (\u8DEF\u5F84s.length === 0) return false;
|
|
12480
|
-
const \u6839 =
|
|
12481
|
-
return \u8DEF\u5F84s.every((p) => isWithinDir(\u6839,
|
|
12803
|
+
const \u6839 = isAbsolute4(rule.prefix) ? rule.prefix : resolve3(\u4E8B\u5B9E.\u57FA\u70B9, rule.prefix);
|
|
12804
|
+
return \u8DEF\u5F84s.every((p) => isWithinDir(\u6839, isAbsolute4(p) ? p : resolve3(\u4E8B\u5B9E.\u57FA\u70B9, p)));
|
|
12482
12805
|
}
|
|
12483
12806
|
return false;
|
|
12484
12807
|
}
|
|
@@ -12687,21 +13010,21 @@ var init_session_files = __esm({
|
|
|
12687
13010
|
});
|
|
12688
13011
|
|
|
12689
13012
|
// packages/core/src/agent/tool-schema.ts
|
|
12690
|
-
import { z as
|
|
13013
|
+
import { z as z7 } from "zod";
|
|
12691
13014
|
function propertyToZod(prop) {
|
|
12692
13015
|
switch (prop.type) {
|
|
12693
13016
|
case "string":
|
|
12694
|
-
return
|
|
13017
|
+
return z7.string();
|
|
12695
13018
|
case "number": {
|
|
12696
|
-
let schema =
|
|
13019
|
+
let schema = z7.number();
|
|
12697
13020
|
if (typeof prop.minimum === "number") schema = schema.min(prop.minimum);
|
|
12698
13021
|
if (typeof prop.maximum === "number") schema = schema.max(prop.maximum);
|
|
12699
13022
|
return schema;
|
|
12700
13023
|
}
|
|
12701
13024
|
case "boolean":
|
|
12702
|
-
return
|
|
13025
|
+
return z7.boolean();
|
|
12703
13026
|
default:
|
|
12704
|
-
return
|
|
13027
|
+
return z7.unknown();
|
|
12705
13028
|
}
|
|
12706
13029
|
}
|
|
12707
13030
|
function parametersToZod(parameters) {
|
|
@@ -12711,7 +13034,7 @@ function parametersToZod(parameters) {
|
|
|
12711
13034
|
for (const [key, prop] of Object.entries(properties)) {
|
|
12712
13035
|
shape[key] = required.includes(key) ? propertyToZod(prop) : propertyToZod(prop).optional();
|
|
12713
13036
|
}
|
|
12714
|
-
return
|
|
13037
|
+
return z7.object(shape).passthrough();
|
|
12715
13038
|
}
|
|
12716
13039
|
var init_tool_schema = __esm({
|
|
12717
13040
|
"packages/core/src/agent/tool-schema.ts"() {
|
|
@@ -12719,230 +13042,6 @@ var init_tool_schema = __esm({
|
|
|
12719
13042
|
}
|
|
12720
13043
|
});
|
|
12721
13044
|
|
|
12722
|
-
// packages/core/src/workspace/keyed-serial.ts
|
|
12723
|
-
function byKey(key, \u4EFB\u52A1) {
|
|
12724
|
-
const \u524D\u4E00\u4E2A = \u94FE.get(key) ?? Promise.resolve();
|
|
12725
|
-
const \u672C\u6B21 = \u524D\u4E00\u4E2A.then(\u4EFB\u52A1, \u4EFB\u52A1);
|
|
12726
|
-
const \u5C3E\u5DF4 = \u672C\u6B21.then(
|
|
12727
|
-
() => void 0,
|
|
12728
|
-
() => void 0
|
|
12729
|
-
);
|
|
12730
|
-
\u94FE.set(key, \u5C3E\u5DF4);
|
|
12731
|
-
const \u56DE\u6536 = () => {
|
|
12732
|
-
if (\u94FE.get(key) === \u5C3E\u5DF4) \u94FE.delete(key);
|
|
12733
|
-
};
|
|
12734
|
-
void \u672C\u6B21.then(\u56DE\u6536, \u56DE\u6536);
|
|
12735
|
-
return \u672C\u6B21;
|
|
12736
|
-
}
|
|
12737
|
-
var \u94FE;
|
|
12738
|
-
var init_keyed_serial = __esm({
|
|
12739
|
-
"packages/core/src/workspace/keyed-serial.ts"() {
|
|
12740
|
-
"use strict";
|
|
12741
|
-
\u94FE = /* @__PURE__ */ new Map();
|
|
12742
|
-
}
|
|
12743
|
-
});
|
|
12744
|
-
|
|
12745
|
-
// packages/core/src/workspace/dir-size.ts
|
|
12746
|
-
import { readdir as readdir4, stat as stat8 } from "node:fs/promises";
|
|
12747
|
-
import { join as join12 } from "node:path";
|
|
12748
|
-
async function directoryBytes(dir) {
|
|
12749
|
-
let entries;
|
|
12750
|
-
try {
|
|
12751
|
-
entries = await readdir4(dir, { withFileTypes: true });
|
|
12752
|
-
} catch {
|
|
12753
|
-
return 0;
|
|
12754
|
-
}
|
|
12755
|
-
let total = 0;
|
|
12756
|
-
for (const entry of entries) {
|
|
12757
|
-
const path = join12(dir, entry.name);
|
|
12758
|
-
if (entry.isDirectory()) total += await directoryBytes(path);
|
|
12759
|
-
else if (entry.isFile()) {
|
|
12760
|
-
try {
|
|
12761
|
-
total += (await stat8(path)).size;
|
|
12762
|
-
} catch {
|
|
12763
|
-
}
|
|
12764
|
-
}
|
|
12765
|
-
}
|
|
12766
|
-
return total;
|
|
12767
|
-
}
|
|
12768
|
-
function formatBytes(n) {
|
|
12769
|
-
if (n < 1024) return `${n} B`;
|
|
12770
|
-
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
|
|
12771
|
-
if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
12772
|
-
return `${(n / 1024 / 1024 / 1024).toFixed(1)} GB`;
|
|
12773
|
-
}
|
|
12774
|
-
var init_dir_size = __esm({
|
|
12775
|
-
"packages/core/src/workspace/dir-size.ts"() {
|
|
12776
|
-
"use strict";
|
|
12777
|
-
}
|
|
12778
|
-
});
|
|
12779
|
-
|
|
12780
|
-
// packages/core/src/workspace/snapshot.ts
|
|
12781
|
-
import { execFile as execFile2 } from "node:child_process";
|
|
12782
|
-
import { mkdir as mkdir6, stat as stat9 } from "node:fs/promises";
|
|
12783
|
-
import { join as join13 } from "node:path";
|
|
12784
|
-
function checkpointLabelWithSeq(label, seq) {
|
|
12785
|
-
return `${label} #seq=${seq}`;
|
|
12786
|
-
}
|
|
12787
|
-
function checkpointSeqOf(label) {
|
|
12788
|
-
const m = /(?:^|\s)#seq=(\d+)\s*$/.exec(label);
|
|
12789
|
-
return m === null ? void 0 : Number(m[1]);
|
|
12790
|
-
}
|
|
12791
|
-
async function runGit(args, opts) {
|
|
12792
|
-
return new Promise((resolve16) => {
|
|
12793
|
-
execFile2(
|
|
12794
|
-
"git",
|
|
12795
|
-
[...args],
|
|
12796
|
-
{ cwd: opts.cwd, timeout: SNAPSHOT_GIT_TIMEOUT_MS, maxBuffer: 8 * 1024 * 1024, ...opts.env ? { env: opts.env } : {} },
|
|
12797
|
-
(error, stdout, stderr) => {
|
|
12798
|
-
try {
|
|
12799
|
-
resolve16({
|
|
12800
|
-
ok: error === null,
|
|
12801
|
-
stdout: String(stdout ?? ""),
|
|
12802
|
-
stderr: String(stderr ?? "") || (error === null ? "" : error.message)
|
|
12803
|
-
});
|
|
12804
|
-
} catch (unexpected) {
|
|
12805
|
-
resolve16({ ok: false, stdout: "", stderr: `git \u8C03\u7528\u5F02\u5E38\uFF1A${unexpected instanceof Error ? unexpected.message : String(unexpected)}` });
|
|
12806
|
-
}
|
|
12807
|
-
}
|
|
12808
|
-
);
|
|
12809
|
-
});
|
|
12810
|
-
}
|
|
12811
|
-
function shadowArgs(cwd, rest) {
|
|
12812
|
-
return [
|
|
12813
|
-
`--git-dir=${shadowGitDirOf(cwd)}`,
|
|
12814
|
-
`--work-tree=${cwd}`,
|
|
12815
|
-
// 身份与环境隔离:不读用户 git config 的 hook/签名,也不因缺 user.name 而失败
|
|
12816
|
-
"-c",
|
|
12817
|
-
"user.name=daluo",
|
|
12818
|
-
"-c",
|
|
12819
|
-
"user.email=daluo@localhost",
|
|
12820
|
-
"-c",
|
|
12821
|
-
"commit.gpgsign=false",
|
|
12822
|
-
"-c",
|
|
12823
|
-
"core.hooksPath=/dev/null",
|
|
12824
|
-
...rest
|
|
12825
|
-
];
|
|
12826
|
-
}
|
|
12827
|
-
async function ensureShadowRepo(cwd, env) {
|
|
12828
|
-
try {
|
|
12829
|
-
await mkdir6(shadowGitDirOf(cwd), { recursive: true });
|
|
12830
|
-
} catch (error) {
|
|
12831
|
-
return `\u65E0\u6CD5\u521B\u5EFA\u5F71\u5B50\u4ED3\u5E93\u76EE\u5F55\uFF1A${error instanceof Error ? error.message : String(error)}`;
|
|
12832
|
-
}
|
|
12833
|
-
const init = await runGit([`--git-dir=${shadowGitDirOf(cwd)}`, "init", "--quiet"], { cwd, ...env ? { env } : {} });
|
|
12834
|
-
return init.ok ? void 0 : `git init \u5931\u8D25\uFF1A${init.stderr.trim()}`;
|
|
12835
|
-
}
|
|
12836
|
-
async function createCheckpointLocked(input) {
|
|
12837
|
-
const { cwd } = input;
|
|
12838
|
-
const label = input.seq === void 0 ? input.label : checkpointLabelWithSeq(input.label, input.seq);
|
|
12839
|
-
const env = input.env;
|
|
12840
|
-
const cap = input.maxFileBytes ?? SNAPSHOT_MAX_FILE_BYTES;
|
|
12841
|
-
if (input.paths !== void 0 && input.paths.length === 0) {
|
|
12842
|
-
return { ok: true, unchanged: true, files: 0 };
|
|
12843
|
-
}
|
|
12844
|
-
const repoProblem = await ensureShadowRepo(cwd, env);
|
|
12845
|
-
if (repoProblem !== void 0) return { ok: false, reason: repoProblem };
|
|
12846
|
-
const skipped = [];
|
|
12847
|
-
const scope = input.paths === void 0 || input.paths.length === 0 ? ["."] : [...input.paths];
|
|
12848
|
-
const listed = await runGit(
|
|
12849
|
-
shadowArgs(cwd, ["ls-files", "-o", "-m", "-z", "--exclude-standard", "--", ...scope, ":(exclude).daluo"]),
|
|
12850
|
-
{ cwd, ...env ? { env } : {} }
|
|
12851
|
-
);
|
|
12852
|
-
if (!listed.ok) return { ok: false, reason: `\u904D\u5386\u6587\u4EF6\u5931\u8D25\uFF1A${listed.stderr.trim()}` };
|
|
12853
|
-
const candidates = listed.stdout.split("\0").filter((p) => p !== "");
|
|
12854
|
-
const oversize = [];
|
|
12855
|
-
for (const path of candidates) {
|
|
12856
|
-
const size = await fileSizeBytes(join13(cwd, path));
|
|
12857
|
-
if (size !== void 0 && size > cap) {
|
|
12858
|
-
oversize.push(path);
|
|
12859
|
-
skipped.push({ path, reason: `${(size / 1024 / 1024).toFixed(1)} MB \u8D85\u8FC7\u4E0A\u9650 ${(cap / 1024 / 1024).toFixed(1)} MB` });
|
|
12860
|
-
}
|
|
12861
|
-
}
|
|
12862
|
-
const excludes = [...oversize.map((p) => `:(exclude)${p}`), ":(exclude).daluo"];
|
|
12863
|
-
const add = await runGit(shadowArgs(cwd, ["add", "-A", "--", ...scope, ...excludes]), { cwd, ...env ? { env } : {} });
|
|
12864
|
-
if (!add.ok) return { ok: false, reason: `git add \u5931\u8D25\uFF1A${add.stderr.trim()}`, ...skipped.length ? { skipped } : {} };
|
|
12865
|
-
const staged = await runGit(shadowArgs(cwd, ["diff", "--cached", "--name-only", "-z"]), { cwd, ...env ? { env } : {} });
|
|
12866
|
-
if (!staged.ok) return { ok: false, reason: `git diff \u5931\u8D25\uFF1A${staged.stderr.trim()}`, ...skipped.length ? { skipped } : {} };
|
|
12867
|
-
const stagedFiles = staged.stdout.split("\0").filter((p) => p !== "");
|
|
12868
|
-
if (stagedFiles.length === 0) {
|
|
12869
|
-
return { ok: true, unchanged: true, files: 0, ...skipped.length ? { skipped } : {} };
|
|
12870
|
-
}
|
|
12871
|
-
const commit2 = await runGit(shadowArgs(cwd, ["commit", "--quiet", "-m", label]), { cwd, ...env ? { env } : {} });
|
|
12872
|
-
if (!commit2.ok) return { ok: false, reason: `git commit \u5931\u8D25\uFF1A${commit2.stderr.trim()}`, ...skipped.length ? { skipped } : {} };
|
|
12873
|
-
const hash = await runGit(shadowArgs(cwd, ["rev-parse", "HEAD"]), { cwd, ...env ? { env } : {} });
|
|
12874
|
-
return {
|
|
12875
|
-
ok: true,
|
|
12876
|
-
...hash.ok ? { checkpoint: hash.stdout.trim() } : {},
|
|
12877
|
-
files: stagedFiles.length,
|
|
12878
|
-
...skipped.length ? { skipped } : {}
|
|
12879
|
-
};
|
|
12880
|
-
}
|
|
12881
|
-
async function snapshotCost(input) {
|
|
12882
|
-
const { cwd } = input;
|
|
12883
|
-
const env = input.env;
|
|
12884
|
-
const shadow = shadowGitDirOf(cwd);
|
|
12885
|
-
const count = await runGit(
|
|
12886
|
-
[`--git-dir=${shadow}`, "rev-list", "--count", "HEAD"],
|
|
12887
|
-
{ cwd, ...env ? { env } : {} }
|
|
12888
|
-
);
|
|
12889
|
-
const bytes = await directoryBytes(shadow);
|
|
12890
|
-
if (!count.ok) {
|
|
12891
|
-
return { ok: false, checkpoints: 0, bytes, reason: count.stderr.trim() || "\u8FD8\u6CA1\u6709\u5FEB\u7167\uFF08\u5F71\u5B50\u4ED3\u5E93\u4E0D\u5B58\u5728\u6216\u6CA1\u6709\u63D0\u4EA4\uFF09" };
|
|
12892
|
-
}
|
|
12893
|
-
const checkpoints = Number.parseInt(count.stdout.trim(), 10);
|
|
12894
|
-
return { ok: true, checkpoints: Number.isInteger(checkpoints) ? checkpoints : 0, bytes };
|
|
12895
|
-
}
|
|
12896
|
-
async function fileSizeBytes(path) {
|
|
12897
|
-
try {
|
|
12898
|
-
return (await stat9(path)).size;
|
|
12899
|
-
} catch {
|
|
12900
|
-
return void 0;
|
|
12901
|
-
}
|
|
12902
|
-
}
|
|
12903
|
-
async function listCheckpoints(input) {
|
|
12904
|
-
const { cwd, env } = input;
|
|
12905
|
-
const limit = input.limit ?? 50;
|
|
12906
|
-
const log = await runGit(
|
|
12907
|
-
shadowArgs(cwd, ["log", `-n${limit}`, "--format=%H%x09%cI%x09%s"]),
|
|
12908
|
-
{ cwd, ...env ? { env } : {} }
|
|
12909
|
-
);
|
|
12910
|
-
if (!log.ok) return { ok: false, checkpoints: [], reason: log.stderr.trim() || "\u65E0\u5FEB\u7167\u6216 git \u4E0D\u53EF\u7528" };
|
|
12911
|
-
const checkpoints = log.stdout.split("\n").filter((l) => l.trim() !== "").map((line) => {
|
|
12912
|
-
const [hash = "", ts = "", ...rest] = line.split(" ");
|
|
12913
|
-
const label = rest.join(" ");
|
|
12914
|
-
const seq = checkpointSeqOf(label);
|
|
12915
|
-
return { hash, ts, label, ...seq !== void 0 ? { seq } : {} };
|
|
12916
|
-
});
|
|
12917
|
-
return { ok: true, checkpoints };
|
|
12918
|
-
}
|
|
12919
|
-
async function restoreCheckpointLocked(input) {
|
|
12920
|
-
const { cwd, checkpoint, env } = input;
|
|
12921
|
-
const target = input.path === void 0 || input.path === "" ? "." : input.path;
|
|
12922
|
-
const out = await runGit(
|
|
12923
|
-
shadowArgs(cwd, ["checkout", checkpoint, "--", target]),
|
|
12924
|
-
{ cwd, ...env ? { env } : {} }
|
|
12925
|
-
);
|
|
12926
|
-
return out.ok ? { ok: true, restored: target } : { ok: false, reason: `\u6062\u590D\u5931\u8D25\uFF1A${out.stderr.trim()}` };
|
|
12927
|
-
}
|
|
12928
|
-
function createCheckpoint(input) {
|
|
12929
|
-
return byKey(shadowGitDirOf(input.cwd), () => createCheckpointLocked(input));
|
|
12930
|
-
}
|
|
12931
|
-
function restoreCheckpoint(input) {
|
|
12932
|
-
return byKey(shadowGitDirOf(input.cwd), () => restoreCheckpointLocked(input));
|
|
12933
|
-
}
|
|
12934
|
-
var SNAPSHOT_MAX_FILE_BYTES, SNAPSHOT_GIT_TIMEOUT_MS;
|
|
12935
|
-
var init_snapshot = __esm({
|
|
12936
|
-
"packages/core/src/workspace/snapshot.ts"() {
|
|
12937
|
-
"use strict";
|
|
12938
|
-
init_project_paths();
|
|
12939
|
-
init_keyed_serial();
|
|
12940
|
-
init_dir_size();
|
|
12941
|
-
SNAPSHOT_MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
12942
|
-
SNAPSHOT_GIT_TIMEOUT_MS = 2e4;
|
|
12943
|
-
}
|
|
12944
|
-
});
|
|
12945
|
-
|
|
12946
13045
|
// packages/core/src/workspace/mutation-checkpoint.ts
|
|
12947
13046
|
function snapshotEnabled(env) {
|
|
12948
13047
|
return (env["DALUO_SNAPSHOT"] ?? "").trim().toLowerCase() !== SNAPSHOT_OFF;
|
|
@@ -14504,7 +14603,7 @@ var init_async_agent = __esm({
|
|
|
14504
14603
|
// packages/core/src/workspace/worktree.ts
|
|
14505
14604
|
import { execFile as execFile3 } from "node:child_process";
|
|
14506
14605
|
import { existsSync as existsSync9, mkdirSync as mkdirSync3, realpathSync as realpathSync4 } from "node:fs";
|
|
14507
|
-
import { basename as
|
|
14606
|
+
import { basename as basename8, dirname as dirname7, join as join16 } from "node:path";
|
|
14508
14607
|
import { promisify as promisify2 } from "node:util";
|
|
14509
14608
|
async function git2(cwd, args, timeoutMs) {
|
|
14510
14609
|
try {
|
|
@@ -14549,7 +14648,7 @@ function canonical(path) {
|
|
|
14549
14648
|
return realpathSync4(path);
|
|
14550
14649
|
} catch {
|
|
14551
14650
|
const parent = dirname7(path);
|
|
14552
|
-
return parent === path ? path : join16(canonical(parent),
|
|
14651
|
+
return parent === path ? path : join16(canonical(parent), basename8(path));
|
|
14553
14652
|
}
|
|
14554
14653
|
}
|
|
14555
14654
|
async function registeredPaths(cwd, timeoutMs) {
|
|
@@ -14606,7 +14705,7 @@ async function listWorktrees(input) {
|
|
|
14606
14705
|
if (path === void 0) return;
|
|
14607
14706
|
const here = canonical(path);
|
|
14608
14707
|
if (here === root || here.startsWith(root + "/")) {
|
|
14609
|
-
worktrees.push({ name:
|
|
14708
|
+
worktrees.push({ name: basename8(here), path: join16(worktreesDirOf(input.cwd), basename8(here)), head });
|
|
14610
14709
|
}
|
|
14611
14710
|
path = void 0;
|
|
14612
14711
|
head = "";
|
|
@@ -17646,7 +17745,7 @@ var init_structured = __esm({
|
|
|
17646
17745
|
});
|
|
17647
17746
|
|
|
17648
17747
|
// packages/core/src/agent/auto-memory.ts
|
|
17649
|
-
import { z as
|
|
17748
|
+
import { z as z8 } from "zod";
|
|
17650
17749
|
function messagesToText(messages) {
|
|
17651
17750
|
const lines = [];
|
|
17652
17751
|
for (const m of messages) {
|
|
@@ -17696,7 +17795,7 @@ function buildExtractPrompt(messages, existingFacts) {
|
|
|
17696
17795
|
].join("\n");
|
|
17697
17796
|
}
|
|
17698
17797
|
function parseExtracted(text2) {
|
|
17699
|
-
const \u6570\u7EC4 = parseStructured(text2,
|
|
17798
|
+
const \u6570\u7EC4 = parseStructured(text2, z8.array(z8.unknown()));
|
|
17700
17799
|
if (!\u6570\u7EC4.ok) return [];
|
|
17701
17800
|
const out = [];
|
|
17702
17801
|
for (const item of \u6570\u7EC4.value) {
|
|
@@ -17748,17 +17847,17 @@ var init_auto_memory = __esm({
|
|
|
17748
17847
|
"use strict";
|
|
17749
17848
|
init_structured();
|
|
17750
17849
|
init_memory();
|
|
17751
|
-
MEMORY_ITEM =
|
|
17752
|
-
key:
|
|
17753
|
-
content:
|
|
17754
|
-
memoryType:
|
|
17755
|
-
confidence:
|
|
17850
|
+
MEMORY_ITEM = z8.object({
|
|
17851
|
+
key: z8.string().trim().min(1),
|
|
17852
|
+
content: z8.string().trim().min(1),
|
|
17853
|
+
memoryType: z8.enum(MEMORY_TYPES).optional(),
|
|
17854
|
+
confidence: z8.number().min(0).max(1).catch(0.5).optional(),
|
|
17756
17855
|
// 准入闸要的裁决字段(G4-01):坏值逐项兜底(`.catch`)而不是一票否决整条——
|
|
17757
17856
|
// 缺 `action` 按 `admit` 处理(宁可交给结构性硬闸判,也不在这里静默丢)。
|
|
17758
|
-
action:
|
|
17759
|
-
transferableTo:
|
|
17760
|
-
supersedesKey:
|
|
17761
|
-
reason:
|
|
17857
|
+
action: z8.enum(["admit", "reject", "supersede"]).catch("admit").optional(),
|
|
17858
|
+
transferableTo: z8.array(z8.string()).catch([]).optional(),
|
|
17859
|
+
supersedesKey: z8.string().optional(),
|
|
17860
|
+
reason: z8.string().optional()
|
|
17762
17861
|
});
|
|
17763
17862
|
}
|
|
17764
17863
|
});
|
|
@@ -18916,7 +19015,7 @@ ${unread.map((x) => `- \u6765\u81EA ${x.senderName}\uFF1A${x.content}`).join("\n
|
|
|
18916
19015
|
});
|
|
18917
19016
|
|
|
18918
19017
|
// packages/core/src/agent/team/peer.ts
|
|
18919
|
-
import { createHash as
|
|
19018
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
18920
19019
|
import { mkdirSync as mkdirSync6 } from "node:fs";
|
|
18921
19020
|
import { dirname as dirname9, join as join21, resolve as resolve6 } from "node:path";
|
|
18922
19021
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
@@ -18931,7 +19030,7 @@ function peersBaseDir() {
|
|
|
18931
19030
|
return peersDirOverride ?? PEERS_DIR;
|
|
18932
19031
|
}
|
|
18933
19032
|
function projectKeyOf(projectDir) {
|
|
18934
|
-
return
|
|
19033
|
+
return createHash4("sha1").update(resolve6(projectDir)).digest("hex").slice(0, 12);
|
|
18935
19034
|
}
|
|
18936
19035
|
function tempPeersDirIn(projectDir) {
|
|
18937
19036
|
return join21(peersBaseDir(), projectKeyOf(projectDir));
|
|
@@ -19801,7 +19900,7 @@ var init_limits = __esm({
|
|
|
19801
19900
|
});
|
|
19802
19901
|
|
|
19803
19902
|
// packages/core/src/agent/council/plan.ts
|
|
19804
|
-
import { z as
|
|
19903
|
+
import { z as z9 } from "zod";
|
|
19805
19904
|
function stableConflictKey(left, right) {
|
|
19806
19905
|
const [a, b] = [left, right].slice().sort();
|
|
19807
19906
|
let h4 = 2166136261;
|
|
@@ -19946,46 +20045,46 @@ var PlanItemSchema, SeatRiskSchema, SeatChallengeSchema, SeatAlternativeSchema,
|
|
|
19946
20045
|
var init_plan2 = __esm({
|
|
19947
20046
|
"packages/core/src/agent/council/plan.ts"() {
|
|
19948
20047
|
"use strict";
|
|
19949
|
-
PlanItemSchema =
|
|
19950
|
-
id:
|
|
19951
|
-
title:
|
|
19952
|
-
detail:
|
|
20048
|
+
PlanItemSchema = z9.object({
|
|
20049
|
+
id: z9.string(),
|
|
20050
|
+
title: z9.string(),
|
|
20051
|
+
detail: z9.string(),
|
|
19953
20052
|
/** 涉及文件(席位用只读工具定位后结构化输出)。 */
|
|
19954
|
-
files:
|
|
20053
|
+
files: z9.array(z9.string()).optional()
|
|
19955
20054
|
});
|
|
19956
|
-
SeatRiskSchema =
|
|
19957
|
-
claim:
|
|
19958
|
-
severity:
|
|
19959
|
-
mitigation:
|
|
20055
|
+
SeatRiskSchema = z9.object({
|
|
20056
|
+
claim: z9.string(),
|
|
20057
|
+
severity: z9.enum(["low", "medium", "high"]),
|
|
20058
|
+
mitigation: z9.string(),
|
|
19960
20059
|
/** 关联条目 id;缺省 = 泛化风险(不参与 id 相关性匹配)。 */
|
|
19961
|
-
itemId:
|
|
20060
|
+
itemId: z9.string().optional()
|
|
19962
20061
|
});
|
|
19963
|
-
SeatChallengeSchema =
|
|
19964
|
-
text:
|
|
20062
|
+
SeatChallengeSchema = z9.object({
|
|
20063
|
+
text: z9.string(),
|
|
19965
20064
|
/** blocking = 否决级:未化解前拒绝产出可执行计划。缺省 advisory。 */
|
|
19966
|
-
severity:
|
|
20065
|
+
severity: z9.enum(["advisory", "blocking"]).optional(),
|
|
19967
20066
|
/** 针对的条目 id;缺省 = 全局质疑。 */
|
|
19968
|
-
itemId:
|
|
20067
|
+
itemId: z9.string().optional()
|
|
19969
20068
|
});
|
|
19970
|
-
SeatAlternativeSchema =
|
|
19971
|
-
proposal:
|
|
19972
|
-
recommend:
|
|
19973
|
-
rationale:
|
|
19974
|
-
targetItemId:
|
|
20069
|
+
SeatAlternativeSchema = z9.object({
|
|
20070
|
+
proposal: z9.string(),
|
|
20071
|
+
recommend: z9.boolean(),
|
|
20072
|
+
rationale: z9.string(),
|
|
20073
|
+
targetItemId: z9.string().optional()
|
|
19975
20074
|
});
|
|
19976
|
-
SeatContributionSchema =
|
|
19977
|
-
authority:
|
|
19978
|
-
summary:
|
|
19979
|
-
additions:
|
|
19980
|
-
risks:
|
|
19981
|
-
challenges:
|
|
19982
|
-
alternatives:
|
|
20075
|
+
SeatContributionSchema = z9.object({
|
|
20076
|
+
authority: z9.string().min(1),
|
|
20077
|
+
summary: z9.string(),
|
|
20078
|
+
additions: z9.array(PlanItemSchema).default([]),
|
|
20079
|
+
risks: z9.array(SeatRiskSchema).default([]),
|
|
20080
|
+
challenges: z9.array(SeatChallengeSchema).default([]),
|
|
20081
|
+
alternatives: z9.array(SeatAlternativeSchema).default([])
|
|
19983
20082
|
});
|
|
19984
20083
|
}
|
|
19985
20084
|
});
|
|
19986
20085
|
|
|
19987
20086
|
// packages/core/src/agent/council/tools.ts
|
|
19988
|
-
import { z as
|
|
20087
|
+
import { z as z10 } from "zod";
|
|
19989
20088
|
async function runCouncil(service, opts, compact) {
|
|
19990
20089
|
const { objective, draft, seats, maxRounds, timeoutMs, caller } = opts;
|
|
19991
20090
|
const isSeatEstablished = (authority) => service.listMemberViews().some((m) => m.name === authority);
|
|
@@ -20468,12 +20567,12 @@ var init_tools2 = __esm({
|
|
|
20468
20567
|
}
|
|
20469
20568
|
};
|
|
20470
20569
|
COMPILE_SUBJECT_MAX = 200;
|
|
20471
|
-
RebuttalsSchema =
|
|
20472
|
-
rebuttals:
|
|
20473
|
-
|
|
20474
|
-
conflictKey:
|
|
20475
|
-
stance:
|
|
20476
|
-
argument:
|
|
20570
|
+
RebuttalsSchema = z10.object({
|
|
20571
|
+
rebuttals: z10.array(
|
|
20572
|
+
z10.object({
|
|
20573
|
+
conflictKey: z10.string(),
|
|
20574
|
+
stance: z10.enum(["concede", "hold", "revise"]),
|
|
20575
|
+
argument: z10.string()
|
|
20477
20576
|
})
|
|
20478
20577
|
)
|
|
20479
20578
|
});
|
|
@@ -21365,7 +21464,7 @@ var init_run_registry = __esm({
|
|
|
21365
21464
|
});
|
|
21366
21465
|
|
|
21367
21466
|
// packages/core/src/llm/env.ts
|
|
21368
|
-
import { z as
|
|
21467
|
+
import { z as z11 } from "zod";
|
|
21369
21468
|
function parseVisionModels(raw) {
|
|
21370
21469
|
const out = {};
|
|
21371
21470
|
if (raw.trim() === "") return out;
|
|
@@ -21401,22 +21500,22 @@ var EnvSchema, MAX_CHARS_PER_TOKEN, DEFAULT_CHARS_PER_TOKEN;
|
|
|
21401
21500
|
var init_env = __esm({
|
|
21402
21501
|
"packages/core/src/llm/env.ts"() {
|
|
21403
21502
|
"use strict";
|
|
21404
|
-
EnvSchema =
|
|
21405
|
-
DALUO_LLM_BASE_URL:
|
|
21406
|
-
DALUO_LLM_API_KEY:
|
|
21407
|
-
DALUO_LLM_MODEL:
|
|
21503
|
+
EnvSchema = z11.object({
|
|
21504
|
+
DALUO_LLM_BASE_URL: z11.string().url(),
|
|
21505
|
+
DALUO_LLM_API_KEY: z11.string().min(1),
|
|
21506
|
+
DALUO_LLM_MODEL: z11.string().min(1),
|
|
21408
21507
|
// 可选旋钮:单请求最大重试次数(0=只试 1 次);模型 fallback 链(逗号分隔)
|
|
21409
|
-
DALUO_LLM_MAX_RETRIES:
|
|
21410
|
-
DALUO_LLM_FALLBACK_MODELS:
|
|
21508
|
+
DALUO_LLM_MAX_RETRIES: z11.coerce.number().int().min(0).max(20).optional(),
|
|
21509
|
+
DALUO_LLM_FALLBACK_MODELS: z11.string().optional(),
|
|
21411
21510
|
// 可选旋钮:单请求**首字节**超时 ms(spec/llm-transport.md 明写「默认如 120s,可配」——
|
|
21412
21511
|
// 此前只有构造函数入参,产品入口从不传,于是 env 根本配不了)。慢端点 / 超大上下文下
|
|
21413
21512
|
// 120s 首字节不够:实测 20 万 token 级上下文写产物的那次请求被 120s 掐死(前面读了 16 分钟全白烧)。
|
|
21414
|
-
DALUO_LLM_TIMEOUT_MS:
|
|
21513
|
+
DALUO_LLM_TIMEOUT_MS: z11.coerce.number().int().min(1e3).optional(),
|
|
21415
21514
|
// **模型的上下文窗口**(token)——**由客户在配置 provider 时声明**(2026-09-15 用户裁定)。
|
|
21416
21515
|
// 为什么不下一个产品默认值:窗口是「模型/提供商」的属性,随 provider 而变;替客户猜(无论猜 64k 还是 1M)
|
|
21417
21516
|
// 都会在某个组合上错——猜小则每轮压缩(实测活锁:阈值仅 31k → 200 轮零产出),猜大则撞窗口 400。
|
|
21418
21517
|
// 未声明时按仓库既有保守默认(`DEFAULT_CONTEXT_WINDOW_TOKENS = 128k`)压缩,见 session/context-budget.ts。
|
|
21419
|
-
DALUO_LLM_CONTEXT_WINDOW_TOKENS:
|
|
21518
|
+
DALUO_LLM_CONTEXT_WINDOW_TOKENS: z11.coerce.number().int().min(1e3).optional(),
|
|
21420
21519
|
/**
|
|
21421
21520
|
* **模型支持图像输入吗(兜底层)**——同 `DALUO_LLM_CONTEXT_WINDOW_TOKENS`:由客户在配置 provider 时声明。
|
|
21422
21521
|
* 为什么不下一个「大概支持」的默认值:视觉是模型/提供商的属性,替客户猜会在某个组合上错
|
|
@@ -21425,24 +21524,24 @@ var init_env = __esm({
|
|
|
21425
21524
|
* 语义(2026-09-20 演进):这是**兜底**;**模型级声明走 `DALUO_LLM_VISION_MODELS`**(解析点在
|
|
21426
21525
|
* `LlmClient.supportsVision`:模型条目 ?? 这里兜底——换模型即换能力位,不用重解析 env)。
|
|
21427
21526
|
*/
|
|
21428
|
-
DALUO_LLM_VISION:
|
|
21527
|
+
DALUO_LLM_VISION: z11.enum(["1", "0", "true", "false", "on", "off"]).optional(),
|
|
21429
21528
|
/**
|
|
21430
21529
|
* **每模型视觉能力表**:`模型=1|0` 逗号分隔(cli 由提供方条目的 `models[].vision` 生成)。
|
|
21431
21530
|
* 坏格式 fail loud(loadLlmConfig 抛)——能力位是权限级声明,宽容解析会把「写错了」悄悄变成「没声明」。
|
|
21432
21531
|
*/
|
|
21433
|
-
DALUO_LLM_VISION_MODELS:
|
|
21532
|
+
DALUO_LLM_VISION_MODELS: z11.string().optional(),
|
|
21434
21533
|
/**
|
|
21435
21534
|
* **每模型 token 密度表**:`模型=值` 逗号分隔(cli 由提供方条目的 `models[].charsPerToken` 生成)。
|
|
21436
21535
|
* 坏格式 fail loud(`loadLlmConfig` 抛)——密度影响压缩阈值,宽容解析会把「写错了」悄悄变成「没声明」。
|
|
21437
21536
|
*/
|
|
21438
|
-
DALUO_LLM_CHARS_PER_TOKEN_MODELS:
|
|
21537
|
+
DALUO_LLM_CHARS_PER_TOKEN_MODELS: z11.string().optional(),
|
|
21439
21538
|
/**
|
|
21440
21539
|
* **token 密度兜底**:1 个 token 约等于多少字符(`spec/token-meter.md`,`P1-28`)。
|
|
21441
21540
|
* 为什么要有它:仓库缺省是 4 字符/token,对中文**低估** ⇒ 中文长会话压缩触发偏晚。
|
|
21442
21541
|
* 中文密集的模型可以在这里(或提供方/模型条目里)声明真实密度。
|
|
21443
21542
|
* 区间 (0, 64]:0 / 负 / 荒谬大值 fail loud,不给「悄悄夹到合法区间」的魔法。
|
|
21444
21543
|
*/
|
|
21445
|
-
DALUO_LLM_CHARS_PER_TOKEN:
|
|
21544
|
+
DALUO_LLM_CHARS_PER_TOKEN: z11.coerce.number().gt(0).max(64).optional(),
|
|
21446
21545
|
/**
|
|
21447
21546
|
* **流式请求要不要 `stream_options.include_usage`**(缺省要)——`DALUO_LLM_STREAM_USAGE=0` 关。
|
|
21448
21547
|
*
|
|
@@ -21451,7 +21550,7 @@ var init_env = __esm({
|
|
|
21451
21550
|
* 为什么留这个关:有的自建网关对未知字段直接 400——**端点脾气不该由代码猜**(不做「400 就自动不写」
|
|
21452
21551
|
* 那种魔法:它会让「字段被拒」与「端点坏了」表现为同一种故障),给一个显式开关。
|
|
21453
21552
|
*/
|
|
21454
|
-
DALUO_LLM_STREAM_USAGE:
|
|
21553
|
+
DALUO_LLM_STREAM_USAGE: z11.enum(["0", "1", "false", "true", "off", "on"]).optional(),
|
|
21455
21554
|
/**
|
|
21456
21555
|
* **生成参数**(spec/llm-transport.md「请求体生成参数」演进节,`G7-03`):输出长度上限与温度。
|
|
21457
21556
|
*
|
|
@@ -21460,8 +21559,8 @@ var init_env = __esm({
|
|
|
21460
21559
|
* 非法值 fail loud(zod 直接拒)——不给「悄悄夹到合法区间」的魔法:那会把「配置写错了」
|
|
21461
21560
|
* 变成「行为莫名其妙」。
|
|
21462
21561
|
*/
|
|
21463
|
-
DALUO_LLM_MAX_TOKENS:
|
|
21464
|
-
DALUO_LLM_TEMPERATURE:
|
|
21562
|
+
DALUO_LLM_MAX_TOKENS: z11.coerce.number().int().min(1).optional(),
|
|
21563
|
+
DALUO_LLM_TEMPERATURE: z11.coerce.number().min(0).max(2).optional(),
|
|
21465
21564
|
/**
|
|
21466
21565
|
* **结构化输出开关**(`response_format`,`spec/llm-transport.md` 演进「`response_format` 开关」,2026-10-22)。
|
|
21467
21566
|
*
|
|
@@ -21478,7 +21577,7 @@ var init_env = __esm({
|
|
|
21478
21577
|
* 没有基线失败可修 ⇒ 默认开等于为一个测不出收益的东西改所有会话的请求体;
|
|
21479
21578
|
* ③它有已知副作用(空 `content` 概率、正文变 JSON),必须由知道代价的人开。
|
|
21480
21579
|
*/
|
|
21481
|
-
DALUO_LLM_RESPONSE_FORMAT:
|
|
21580
|
+
DALUO_LLM_RESPONSE_FORMAT: z11.enum(["off", "structured", "always"]).optional()
|
|
21482
21581
|
}).transform((env) => {
|
|
21483
21582
|
const out = {
|
|
21484
21583
|
baseUrl: env.DALUO_LLM_BASE_URL,
|
|
@@ -21890,7 +21989,7 @@ var init_read_file = __esm({
|
|
|
21890
21989
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
21891
21990
|
import { realpathSync as realpathSync6 } from "node:fs";
|
|
21892
21991
|
import { mkdir as mkdir8, readdir as readdir6, rename as rename3, stat as stat12, unlink as unlink6, writeFile as writeFile5 } from "node:fs/promises";
|
|
21893
|
-
import { basename as
|
|
21992
|
+
import { basename as basename9, dirname as dirname10, join as join23, resolve as resolve7 } from "node:path";
|
|
21894
21993
|
function \u662F\u81EA\u5BB6tmp(\u540D\u5B57, \u76EE\u6807\u540D) {
|
|
21895
21994
|
const \u524D\u7F00 = `${\u76EE\u6807\u540D}.`;
|
|
21896
21995
|
if (!\u540D\u5B57.startsWith(\u524D\u7F00)) return false;
|
|
@@ -21902,7 +22001,7 @@ function \u89C4\u8303\u6027\u8DEF\u5F84(path) {
|
|
|
21902
22001
|
return realpathSync6(\u7EDD\u5BF9);
|
|
21903
22002
|
} catch {
|
|
21904
22003
|
try {
|
|
21905
|
-
return join23(realpathSync6(dirname10(\u7EDD\u5BF9)),
|
|
22004
|
+
return join23(realpathSync6(dirname10(\u7EDD\u5BF9)), basename9(\u7EDD\u5BF9));
|
|
21906
22005
|
} catch {
|
|
21907
22006
|
return \u7EDD\u5BF9;
|
|
21908
22007
|
}
|
|
@@ -21910,7 +22009,7 @@ function \u89C4\u8303\u6027\u8DEF\u5F84(path) {
|
|
|
21910
22009
|
}
|
|
21911
22010
|
async function \u6E05\u8001tmp(path) {
|
|
21912
22011
|
const \u76EE\u5F55 = dirname10(path);
|
|
21913
|
-
const \u76EE\u6807\u540D =
|
|
22012
|
+
const \u76EE\u6807\u540D = basename9(path);
|
|
21914
22013
|
let \u540D\u5B57s;
|
|
21915
22014
|
try {
|
|
21916
22015
|
\u540D\u5B57s = await readdir6(\u76EE\u5F55);
|
|
@@ -22314,7 +22413,7 @@ var init_multiedit = __esm({
|
|
|
22314
22413
|
// packages/core/src/agent/tools/grep-glob.ts
|
|
22315
22414
|
import { execFile as execFile5 } from "node:child_process";
|
|
22316
22415
|
import { promisify as promisify4 } from "node:util";
|
|
22317
|
-
import { basename as
|
|
22416
|
+
import { basename as basename10, join as join24, relative as relative2, resolve as resolve8, isAbsolute as isAbsolute5 } from "node:path";
|
|
22318
22417
|
import { readdir as readdir7, readFile as readFile10, stat as stat13 } from "node:fs/promises";
|
|
22319
22418
|
async function hasRg() {
|
|
22320
22419
|
if (rgProbe !== void 0) return !!await rgProbe();
|
|
@@ -22418,7 +22517,7 @@ function matchGlob(relPosix, pattern) {
|
|
|
22418
22517
|
compiled = { re: new RegExp("^" + globBody(pat) + "$"), basenameOnly };
|
|
22419
22518
|
globReCache.set(key, compiled);
|
|
22420
22519
|
}
|
|
22421
|
-
return compiled.re.test(compiled.basenameOnly ?
|
|
22520
|
+
return compiled.re.test(compiled.basenameOnly ? basename10(relPosix) : relPosix);
|
|
22422
22521
|
}
|
|
22423
22522
|
async function nodeGlob(root, pattern, excludes) {
|
|
22424
22523
|
const deadline = Date.now() + SEARCH_TIMEOUT_MS;
|
|
@@ -22668,7 +22767,7 @@ var init_grep_glob = __esm({
|
|
|
22668
22767
|
sandbox
|
|
22669
22768
|
);
|
|
22670
22769
|
all = stdout.split("\n").filter((l) => l.trim()).map((l) => {
|
|
22671
|
-
const abs =
|
|
22770
|
+
const abs = isAbsolute5(l) ? l : resolve8(searchPath, l);
|
|
22672
22771
|
return relative2(searchPath, abs).replaceAll("\\", "/");
|
|
22673
22772
|
}).reverse();
|
|
22674
22773
|
} else {
|
|
@@ -23184,7 +23283,7 @@ var init_memory2 = __esm({
|
|
|
23184
23283
|
|
|
23185
23284
|
// packages/core/src/lsp/client.ts
|
|
23186
23285
|
import { spawn as spawn4 } from "node:child_process";
|
|
23187
|
-
import { basename as
|
|
23286
|
+
import { basename as basename11 } from "node:path";
|
|
23188
23287
|
import { pathToFileURL } from "node:url";
|
|
23189
23288
|
function \u5934\u5C3E\u5206\u9694(buf) {
|
|
23190
23289
|
const \u53CC = buf.indexOf("\r\n\r\n");
|
|
@@ -23240,7 +23339,7 @@ var init_client2 = __esm({
|
|
|
23240
23339
|
get workspaceFolders() {
|
|
23241
23340
|
const dir = this.cfg.cwd;
|
|
23242
23341
|
if (!dir) return [];
|
|
23243
|
-
return [{ uri: pathToFileURL(dir).href, name:
|
|
23342
|
+
return [{ uri: pathToFileURL(dir).href, name: basename11(dir) || dir }];
|
|
23244
23343
|
}
|
|
23245
23344
|
/**
|
|
23246
23345
|
* 应答 server→client 的**请求**(带 id 且带 method)。
|
|
@@ -23929,7 +24028,7 @@ var init_manager = __esm({
|
|
|
23929
24028
|
});
|
|
23930
24029
|
|
|
23931
24030
|
// packages/core/src/lsp/env.ts
|
|
23932
|
-
import { z as
|
|
24031
|
+
import { z as z12 } from "zod";
|
|
23933
24032
|
function parseLspServersEnv(env) {
|
|
23934
24033
|
const raw = env.DALUO_LSP_SERVERS;
|
|
23935
24034
|
if (raw === void 0 || raw.trim() === "") return void 0;
|
|
@@ -23955,18 +24054,18 @@ var LspServerConfigSchema;
|
|
|
23955
24054
|
var init_env2 = __esm({
|
|
23956
24055
|
"packages/core/src/lsp/env.ts"() {
|
|
23957
24056
|
"use strict";
|
|
23958
|
-
LspServerConfigSchema =
|
|
23959
|
-
command:
|
|
23960
|
-
args:
|
|
23961
|
-
extensions:
|
|
24057
|
+
LspServerConfigSchema = z12.object({
|
|
24058
|
+
command: z12.string().min(1),
|
|
24059
|
+
args: z12.array(z12.string()).optional(),
|
|
24060
|
+
extensions: z12.array(z12.string()).optional(),
|
|
23962
24061
|
/**
|
|
23963
24062
|
* `G2-60`:这三个字段 `LspServerConfig` **一直声明着**(client 也一直用:spawn 的 cwd/env、
|
|
23964
24063
|
* 单请求超时缺省),但**解析器不认** —— zod 的缺省行为是丢掉未知键,于是用户写进
|
|
23965
24064
|
* `DALUO_LSP_SERVERS` 的 `cwd` / `env` / `timeoutMs` 被**静默丢弃**(配置写着不生效,最难查)。
|
|
23966
24065
|
*/
|
|
23967
|
-
cwd:
|
|
23968
|
-
env:
|
|
23969
|
-
timeoutMs:
|
|
24066
|
+
cwd: z12.string().min(1).optional(),
|
|
24067
|
+
env: z12.record(z12.string(), z12.string()).optional(),
|
|
24068
|
+
timeoutMs: z12.number().int().positive().optional()
|
|
23970
24069
|
});
|
|
23971
24070
|
}
|
|
23972
24071
|
});
|
|
@@ -24753,7 +24852,12 @@ function createTerminalTool(config) {
|
|
|
24753
24852
|
}
|
|
24754
24853
|
if (action === "open") {
|
|
24755
24854
|
if (loadPty() === null) {
|
|
24756
|
-
return {
|
|
24855
|
+
return {
|
|
24856
|
+
kind: "error",
|
|
24857
|
+
// 「没装」最常见的原因是**瘦安装**(`--omit=optional`):那是有意为之、不是故障,
|
|
24858
|
+
// 所以把话说到「怎么拿回来」,而不是让用户去猜原生依赖为什么缺。
|
|
24859
|
+
message: "\u672C\u673A\u62FF\u4E0D\u5230 node-pty\uFF08\u539F\u751F\u4F9D\u8D56\u6CA1\u88C5\u6216\u5B89\u88C5\u811A\u672C\u88AB\u62E6\uFF09\u21D2 \u7EC8\u7AEF\u5DE5\u5177\u4E0D\u53EF\u7528\uFF1B\u6709\u754C\u547D\u4EE4\u8BF7\u7528 bash\u3002\u82E5\u5B89\u88C5\u65F6\u7528\u4E86 --omit=optional\uFF08\u7626\u5B89\u88C5\uFF09\uFF0C\u91CD\u88C5\u65F6\u4E0D\u5E26\u5B83\u5373\u53EF\uFF08npm i -g @daluo/cli\uFF09\u3002"
|
|
24860
|
+
};
|
|
24757
24861
|
}
|
|
24758
24862
|
if (owned.size >= 8) return { kind: "error", message: `\u5DF2\u7ECF\u5F00\u7740 ${owned.size} \u4E2A\u4F1A\u8BDD\uFF08\u4E0A\u9650 8\uFF09\uFF1A\u5148 close \u6389\u4E0D\u7528\u7684` };
|
|
24759
24863
|
const sandboxWs = typeof injected.sandbox?.workspace === "string" ? injected.sandbox.workspace : injected.cwd ?? config.cwd;
|
|
@@ -24947,7 +25051,7 @@ var init_git_commit = __esm({
|
|
|
24947
25051
|
|
|
24948
25052
|
// packages/core/src/computer-use/cua-driver.ts
|
|
24949
25053
|
import { execFile as execFile7 } from "node:child_process";
|
|
24950
|
-
import { createHash as
|
|
25054
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
24951
25055
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
24952
25056
|
import { promisify as promisify6 } from "node:util";
|
|
24953
25057
|
function parseAllowedApps(env) {
|
|
@@ -24965,7 +25069,7 @@ function parseCodesignOutput(stderr) {
|
|
|
24965
25069
|
if (identifier === void 0 || identifier === "" || cdhash === void 0 || cdhash === "") return void 0;
|
|
24966
25070
|
const teamRaw = field("TeamIdentifier");
|
|
24967
25071
|
const team = teamRaw === void 0 || teamRaw === "not set" ? "" : teamRaw;
|
|
24968
|
-
return
|
|
25072
|
+
return createHash5("sha256").update(`${identifier}
|
|
24969
25073
|
${team}
|
|
24970
25074
|
${cdhash}`).digest("hex");
|
|
24971
25075
|
}
|
|
@@ -25264,7 +25368,9 @@ async function createComputerUseAssembly(input) {
|
|
|
25264
25368
|
}
|
|
25265
25369
|
const handle = await loadCuaDriver();
|
|
25266
25370
|
if (handle === null) {
|
|
25267
|
-
throw new Error(
|
|
25371
|
+
throw new Error(
|
|
25372
|
+
`${COMPUTER_USE_ENV}=cua-driver \u4F46\u539F\u751F\u4F9D\u8D56 @trycua/cua-driver \u52A0\u8F7D\u5931\u8D25\uFF08\u6CA1\u88C5\uFF1F\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\uFF1F\uFF09\u2014\u2014\u82E5\u5B89\u88C5\u65F6\u7528\u4E86 --omit=optional\uFF08\u7626\u5B89\u88C5\uFF09\u5C31\u4F1A\u8FD9\u6837\uFF1A\u91CD\u88C5\u65F6\u4E0D\u5E26\u5B83\u5373\u53EF\uFF08npm i -g @daluo/cli\uFF09\u3002`
|
|
25373
|
+
);
|
|
25268
25374
|
}
|
|
25269
25375
|
const decls = await listCuaTools(handle.driver);
|
|
25270
25376
|
const allowedAppsFile = input.allowedAppsFile;
|
|
@@ -26000,7 +26106,7 @@ var init_bash_command_scan = __esm({
|
|
|
26000
26106
|
});
|
|
26001
26107
|
|
|
26002
26108
|
// packages/core/src/agent/policy.ts
|
|
26003
|
-
import { resolve as resolve9, isAbsolute as
|
|
26109
|
+
import { resolve as resolve9, isAbsolute as isAbsolute6, join as join29, sep as sep3, dirname as dirname11 } from "node:path";
|
|
26004
26110
|
function \u53EA\u8BFB\u767D\u540D\u5355(config) {
|
|
26005
26111
|
const extra = config.extraReadOnlyPrograms;
|
|
26006
26112
|
if (extra === void 0 || extra.length === 0) return SAFE_READONLY_PROGRAMS;
|
|
@@ -26237,7 +26343,7 @@ function createPolicy(config) {
|
|
|
26237
26343
|
const \u53EA\u8BFB\u5DE5\u5177 = exec2.meta?.readOnly === true;
|
|
26238
26344
|
const \u53EF\u53CA\u6839 = \u53EA\u8BFB\u5DE5\u5177 ? [config.cwd, ...config.readOnlyRoots ?? []] : [config.cwd];
|
|
26239
26345
|
for (const path of paths) {
|
|
26240
|
-
const \u7EDD\u5BF9 = path === void 0 || path === "" ||
|
|
26346
|
+
const \u7EDD\u5BF9 = path === void 0 || path === "" || isAbsolute6(path) ? path : resolve9(\u57FA\u70B9, path);
|
|
26241
26347
|
if (\u7EDD\u5BF9 !== void 0 && \u7EDD\u5BF9 !== "" && !\u53EF\u53CA\u6839.some((\u6839) => isWithinDir(\u6839, \u7EDD\u5BF9))) {
|
|
26242
26348
|
const \u8BF4\u660E = \u53EA\u8BFB\u5DE5\u5177 && (config.readOnlyRoots?.length ?? 0) > 0 ? "\uFF08\u53EA\u8BFB\u767D\u540D\u5355\u91CC\u4E5F\u6CA1\u6709\u5B83\uFF09" : "";
|
|
26243
26349
|
if (!\u53EA\u8BFB\u5DE5\u5177) return { kind: "deny", reason: `\u8DEF\u5F84\u5728\u5141\u8BB8\u7684\u5DE5\u4F5C\u76EE\u5F55\u4E4B\u5916\uFF1A${\u7EDD\u5BF9}${\u8BF4\u660E}` };
|
|
@@ -26266,7 +26372,7 @@ function createPolicy(config) {
|
|
|
26266
26372
|
}
|
|
26267
26373
|
}
|
|
26268
26374
|
for (const path of paths) {
|
|
26269
|
-
const abs =
|
|
26375
|
+
const abs = isAbsolute6(path) ? path : resolve9(\u57FA\u70B9, path);
|
|
26270
26376
|
for (const ap of askPaths) {
|
|
26271
26377
|
if (abs === resolve9(config.cwd, ap) || abs.startsWith(resolve9(config.cwd, ap) + sep3)) {
|
|
26272
26378
|
return \u95EE(`${exec2.toolName} ${ap} \u9700\u7528\u6237\u786E\u8BA4\uFF08\u8DEF\u5F84 ${abs}\uFF09`, input, { \u53EF\u4F1A\u8BDD\u8BB0\u5FC6: true, \u98CE\u9669\u6863: "medium" });
|
|
@@ -26274,7 +26380,7 @@ function createPolicy(config) {
|
|
|
26274
26380
|
}
|
|
26275
26381
|
}
|
|
26276
26382
|
const singlePath = typeof input.path === "string" ? input.path : "";
|
|
26277
|
-
if (singlePath && !
|
|
26383
|
+
if (singlePath && !isAbsolute6(singlePath)) {
|
|
26278
26384
|
return {
|
|
26279
26385
|
kind: "allow",
|
|
26280
26386
|
input: {
|
|
@@ -26341,7 +26447,7 @@ var init_policy = __esm({
|
|
|
26341
26447
|
// packages/core/src/skill/fs-provider.ts
|
|
26342
26448
|
import { readdir as readdir8, readFile as readFile13 } from "node:fs/promises";
|
|
26343
26449
|
import { homedir as homedir4 } from "node:os";
|
|
26344
|
-
import { join as join30, delimiter as delimiter2, isAbsolute as
|
|
26450
|
+
import { join as join30, delimiter as delimiter2, isAbsolute as isAbsolute7 } from "node:path";
|
|
26345
26451
|
function unquote(v) {
|
|
26346
26452
|
const t = v.trim();
|
|
26347
26453
|
if (t.length >= 2 && (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'"))) {
|
|
@@ -26443,7 +26549,7 @@ function parseSkillMd(content, dirName) {
|
|
|
26443
26549
|
function skillRootsFromEnv(env) {
|
|
26444
26550
|
const raw = env[SKILL_ROOTS_ENV];
|
|
26445
26551
|
if (raw === void 0 || raw.trim() === "") return [];
|
|
26446
|
-
return raw.split(delimiter2).map((s) => s.trim()).filter((s) => s !== "" &&
|
|
26552
|
+
return raw.split(delimiter2).map((s) => s.trim()).filter((s) => s !== "" && isAbsolute7(s)).map((dir) => ({ dir, source: "env" }));
|
|
26447
26553
|
}
|
|
26448
26554
|
var FRONTMATTER_RE, BLOCK_SCALAR_RE, SKILL_ROOTS_ENV, FileSystemSkillProvider;
|
|
26449
26555
|
var init_fs_provider = __esm({
|
|
@@ -26757,7 +26863,7 @@ var init_goal_mode = __esm({
|
|
|
26757
26863
|
});
|
|
26758
26864
|
|
|
26759
26865
|
// packages/core/src/plugin/loader.ts
|
|
26760
|
-
import { isAbsolute as
|
|
26866
|
+
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
26761
26867
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
26762
26868
|
function describeRow(row) {
|
|
26763
26869
|
if (row.state === "active") return `${row.id} (${row.source})\uFF1A\u5DF2\u88C5\u8F7D`;
|
|
@@ -26779,7 +26885,7 @@ function entryProblem(entry) {
|
|
|
26779
26885
|
}
|
|
26780
26886
|
function resolveEntrySpecifier(name, baseUrl) {
|
|
26781
26887
|
if (name.startsWith(".")) return new URL(name, baseUrl).href;
|
|
26782
|
-
if (
|
|
26888
|
+
if (isAbsolute8(name)) return pathToFileURL2(name).href;
|
|
26783
26889
|
return name;
|
|
26784
26890
|
}
|
|
26785
26891
|
async function \u7B49\u5019\u843D\u5B9A(p, deadlineMs) {
|
|
@@ -26897,7 +27003,7 @@ ${lines.join("\n")}`);
|
|
|
26897
27003
|
// packages/core/src/plugin/config.ts
|
|
26898
27004
|
import { existsSync as existsSync11 } from "node:fs";
|
|
26899
27005
|
import { homedir as homedir5 } from "node:os";
|
|
26900
|
-
import { dirname as dirname12, isAbsolute as
|
|
27006
|
+
import { dirname as dirname12, isAbsolute as isAbsolute9, join as join31, resolve as resolve10 } from "node:path";
|
|
26901
27007
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
26902
27008
|
async function resolvePluginConfig(input) {
|
|
26903
27009
|
const { cwd, env } = input;
|
|
@@ -26906,7 +27012,7 @@ async function resolvePluginConfig(input) {
|
|
|
26906
27012
|
const explicit = env[PLUGINS_FILE_ENV]?.trim();
|
|
26907
27013
|
let filePath;
|
|
26908
27014
|
if (explicit !== void 0 && explicit !== "") {
|
|
26909
|
-
filePath =
|
|
27015
|
+
filePath = isAbsolute9(explicit) ? explicit : resolve10(cwd, explicit);
|
|
26910
27016
|
if (!existsSync11(filePath)) throw new Error(`\u63D2\u4EF6\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${filePath}\uFF08\u6765\u81EA ${PLUGINS_FILE_ENV}\uFF09`);
|
|
26911
27017
|
} else {
|
|
26912
27018
|
const candidates = [
|
|
@@ -26964,7 +27070,7 @@ var init_config = __esm({
|
|
|
26964
27070
|
// packages/core/src/agent/guardian.ts
|
|
26965
27071
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
26966
27072
|
import { resolve as resolve11 } from "node:path";
|
|
26967
|
-
import { z as
|
|
27073
|
+
import { z as z13 } from "zod";
|
|
26968
27074
|
function isHighRiskTool(toolName) {
|
|
26969
27075
|
return toolName === EDIT || toolName === WRITE_FILE || toolName === MULTIEDIT || toolName === BASH;
|
|
26970
27076
|
}
|
|
@@ -27078,9 +27184,9 @@ var init_guardian = __esm({
|
|
|
27078
27184
|
"use strict";
|
|
27079
27185
|
init_structured();
|
|
27080
27186
|
init_names2();
|
|
27081
|
-
GUARDIAN_VERDICT =
|
|
27082
|
-
outcome:
|
|
27083
|
-
reason:
|
|
27187
|
+
GUARDIAN_VERDICT = z13.object({
|
|
27188
|
+
outcome: z13.enum(["approve", "deny", "review"]),
|
|
27189
|
+
reason: z13.string().optional()
|
|
27084
27190
|
});
|
|
27085
27191
|
CircuitBreaker = class {
|
|
27086
27192
|
failures = 0;
|
|
@@ -27413,6 +27519,7 @@ var init_src3 = __esm({
|
|
|
27413
27519
|
init_event_log();
|
|
27414
27520
|
init_jsonl();
|
|
27415
27521
|
init_project_paths();
|
|
27522
|
+
init_snapshot();
|
|
27416
27523
|
init_runner();
|
|
27417
27524
|
init_system_prompt();
|
|
27418
27525
|
init_subagent();
|
|
@@ -27564,9 +27671,9 @@ var init_ports = __esm({
|
|
|
27564
27671
|
});
|
|
27565
27672
|
|
|
27566
27673
|
// packages/core/src/session/external-import.ts
|
|
27567
|
-
import { createHash as
|
|
27674
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
27568
27675
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
27569
|
-
import { basename as
|
|
27676
|
+
import { basename as basename12 } from "node:path";
|
|
27570
27677
|
function textOf(part) {
|
|
27571
27678
|
const t = part["type"];
|
|
27572
27679
|
if (t !== "text" && t !== "input_text" && t !== "output_text") return void 0;
|
|
@@ -27776,7 +27883,7 @@ function parseExternalSession(text2, format) {
|
|
|
27776
27883
|
return \u7528 === "claude" ? parseClaudeSession(text2) : parseCodexSession(text2);
|
|
27777
27884
|
}
|
|
27778
27885
|
function externalEntriesDigest(entries) {
|
|
27779
|
-
return
|
|
27886
|
+
return createHash6("sha256").update(JSON.stringify(entries), "utf8").digest("hex").slice(0, 16);
|
|
27780
27887
|
}
|
|
27781
27888
|
async function importExternalSession(opts) {
|
|
27782
27889
|
let text2;
|
|
@@ -27796,9 +27903,9 @@ async function importExternalSession(opts) {
|
|
|
27796
27903
|
}
|
|
27797
27904
|
const digest = externalEntriesDigest(parsed.entries);
|
|
27798
27905
|
const now = opts.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
27799
|
-
const \u6E90basename =
|
|
27906
|
+
const \u6E90basename = basename12(opts.sourceFile);
|
|
27800
27907
|
if (await fileIdentity(opts.targetFile) === void 0) {
|
|
27801
|
-
const sessionId2 = opts.sessionId ??
|
|
27908
|
+
const sessionId2 = opts.sessionId ?? basename12(opts.targetFile).replace(/\.jsonl$/, "");
|
|
27802
27909
|
if (sessionId2 === "") throw new LifecycleUserError(`importExternalSession: \u76EE\u6807\u6587\u4EF6\u540D\u65E0\u6CD5\u4F5C\u4E3A\u4F1A\u8BDD id\uFF1A${opts.targetFile}`);
|
|
27803
27910
|
const ts2 = now();
|
|
27804
27911
|
const events = [
|
|
@@ -27833,7 +27940,7 @@ async function importExternalSession(opts) {
|
|
|
27833
27940
|
const prev = log.state.importedFrom;
|
|
27834
27941
|
if (prev === void 0) {
|
|
27835
27942
|
throw new LifecycleUserError(
|
|
27836
|
-
`importExternalSession: \u76EE\u6807\u4F1A\u8BDD "${
|
|
27943
|
+
`importExternalSession: \u76EE\u6807\u4F1A\u8BDD "${basename12(opts.targetFile)}" \u4E0D\u662F\u5BFC\u5165\u6765\u7684\uFF08\u6CA1\u6709 session/imported\uFF09\u2014\u2014\u8981\u5BFC\u5165\u5230\u5B83\u8BF7\u53E6\u7ED9\u4E00\u4E2A\u76EE\u6807\u6587\u4EF6\u540D\uFF08\u672C\u4ED3\u4E0D\u5F80\u81EA\u5DF1\u7684\u4F1A\u8BDD\u91CC\u585E\u5916\u90E8\u5386\u53F2\uFF09`
|
|
27837
27944
|
);
|
|
27838
27945
|
}
|
|
27839
27946
|
if (prev.file !== \u6E90basename) {
|
|
@@ -28533,7 +28640,7 @@ var init_shared_snapshot = __esm({
|
|
|
28533
28640
|
|
|
28534
28641
|
// packages/core/src/session/lessons.ts
|
|
28535
28642
|
import { readdir as readdir10, stat as stat15 } from "node:fs/promises";
|
|
28536
|
-
import { basename as
|
|
28643
|
+
import { basename as basename13, join as join34 } from "node:path";
|
|
28537
28644
|
function \u5931\u8D25\u7B7E\u540D(error) {
|
|
28538
28645
|
const \u9996\u884C = error.split("\n")[0] ?? "";
|
|
28539
28646
|
return \u9996\u884C.trim().replace(/(?:\/[\w.\-+@%]+){2,}\/?/g, "<path>").replace(/[0-9a-f]{6,}/gi, "<hash>").replace(/\d+/g, "<n>").slice(0, 80);
|
|
@@ -28625,7 +28732,7 @@ async function mineLessons(dir, opts = {}) {
|
|
|
28625
28732
|
for (const { file } of entries) {
|
|
28626
28733
|
try {
|
|
28627
28734
|
const events = await loadEvents(file);
|
|
28628
|
-
\u5168\u90E8.push(...\u626B\u4E00\u4E2A\u4F1A\u8BDD(events,
|
|
28735
|
+
\u5168\u90E8.push(...\u626B\u4E00\u4E2A\u4F1A\u8BDD(events, basename13(file)));
|
|
28629
28736
|
} catch {
|
|
28630
28737
|
skipped += 1;
|
|
28631
28738
|
}
|
|
@@ -28664,8 +28771,8 @@ var init_lessons = __esm({
|
|
|
28664
28771
|
// packages/core/src/workspace/workspace.ts
|
|
28665
28772
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
28666
28773
|
import { realpath as realpath2, stat as stat16 } from "node:fs/promises";
|
|
28667
|
-
import { basename as
|
|
28668
|
-
import { z as
|
|
28774
|
+
import { basename as basename14 } from "node:path";
|
|
28775
|
+
import { z as z14 } from "zod";
|
|
28669
28776
|
function emptyRegistry() {
|
|
28670
28777
|
return { workspaces: [], unregistered: [], failures: [] };
|
|
28671
28778
|
}
|
|
@@ -28769,34 +28876,34 @@ var init_workspace = __esm({
|
|
|
28769
28876
|
"use strict";
|
|
28770
28877
|
init_log_io();
|
|
28771
28878
|
BaseSchema = {
|
|
28772
|
-
seq:
|
|
28773
|
-
ts:
|
|
28879
|
+
seq: z14.number().int().positive(),
|
|
28880
|
+
ts: z14.string()
|
|
28774
28881
|
};
|
|
28775
|
-
CreatedSchema =
|
|
28882
|
+
CreatedSchema = z14.object({
|
|
28776
28883
|
...BaseSchema,
|
|
28777
|
-
type:
|
|
28778
|
-
workspaceId:
|
|
28779
|
-
root:
|
|
28780
|
-
title:
|
|
28884
|
+
type: z14.literal("workspace/created"),
|
|
28885
|
+
workspaceId: z14.string(),
|
|
28886
|
+
root: z14.string(),
|
|
28887
|
+
title: z14.string()
|
|
28781
28888
|
});
|
|
28782
|
-
RenamedSchema =
|
|
28889
|
+
RenamedSchema = z14.object({
|
|
28783
28890
|
...BaseSchema,
|
|
28784
|
-
type:
|
|
28785
|
-
workspaceId:
|
|
28786
|
-
title:
|
|
28891
|
+
type: z14.literal("workspace/renamed"),
|
|
28892
|
+
workspaceId: z14.string(),
|
|
28893
|
+
title: z14.string()
|
|
28787
28894
|
});
|
|
28788
|
-
UnregisteredSchema =
|
|
28895
|
+
UnregisteredSchema = z14.object({
|
|
28789
28896
|
...BaseSchema,
|
|
28790
|
-
type:
|
|
28791
|
-
workspaceId:
|
|
28897
|
+
type: z14.literal("workspace/unregistered"),
|
|
28898
|
+
workspaceId: z14.string()
|
|
28792
28899
|
});
|
|
28793
|
-
ReorderedSchema =
|
|
28900
|
+
ReorderedSchema = z14.object({
|
|
28794
28901
|
...BaseSchema,
|
|
28795
|
-
type:
|
|
28796
|
-
workspaceId:
|
|
28797
|
-
before:
|
|
28902
|
+
type: z14.literal("workspace/reordered"),
|
|
28903
|
+
workspaceId: z14.string(),
|
|
28904
|
+
before: z14.string().optional()
|
|
28798
28905
|
});
|
|
28799
|
-
WorkspaceEvent =
|
|
28906
|
+
WorkspaceEvent = z14.discriminatedUnion("type", [
|
|
28800
28907
|
CreatedSchema,
|
|
28801
28908
|
RenamedSchema,
|
|
28802
28909
|
UnregisteredSchema,
|
|
@@ -28839,7 +28946,7 @@ var init_workspace = __esm({
|
|
|
28839
28946
|
const root = await resolveExistingDir(input.root);
|
|
28840
28947
|
const existing = findWorkspaceByRoot(this.current, root);
|
|
28841
28948
|
if (existing) return { workspaceId: existing.workspaceId, root, title: existing.title, created: false };
|
|
28842
|
-
const title = (input.title ??
|
|
28949
|
+
const title = (input.title ?? basename14(root)).trim();
|
|
28843
28950
|
const workspaceId = newWorkspaceId((id) => findWorkspaceById(this.current, id) !== void 0);
|
|
28844
28951
|
await this.append(this.nextEvent({ type: "workspace/created", workspaceId, root, title }));
|
|
28845
28952
|
return { workspaceId, root, title, created: true };
|
|
@@ -28899,7 +29006,7 @@ var init_workspace = __esm({
|
|
|
28899
29006
|
|
|
28900
29007
|
// packages/core/src/workspace/watch.ts
|
|
28901
29008
|
import { readdirSync, statSync as statSync3, watch as fsWatch } from "node:fs";
|
|
28902
|
-
import { basename as
|
|
29009
|
+
import { basename as basename15, join as join35, sep as sep4 } from "node:path";
|
|
28903
29010
|
function \u88AB\u5FFD\u7565(\u76F8\u5BF9\u8DEF\u5F84, \u5FFD\u7565\u6E05\u5355) {
|
|
28904
29011
|
if (\u76F8\u5BF9\u8DEF\u5F84 === "") return false;
|
|
28905
29012
|
const \u6BB5\u4EEC = \u76F8\u5BF9\u8DEF\u5F84.split("/");
|
|
@@ -28915,7 +29022,7 @@ function \u8F6Cposix(\u8DEF\u5F84) {
|
|
|
28915
29022
|
}
|
|
28916
29023
|
function \u771F\u5B9E\u76D1\u542C(\u6839, \u6536\u5230, \u5FFD\u7565) {
|
|
28917
29024
|
try {
|
|
28918
|
-
const \u6839\u540D =
|
|
29025
|
+
const \u6839\u540D = basename15(\u6839);
|
|
28919
29026
|
const w = fsWatch(\u6839, { recursive: true, persistent: false }, (_\u4E8B\u4EF6, \u540D) => {
|
|
28920
29027
|
const \u76F8\u5BF9 = \u540D === null || \u540D === void 0 ? "" : \u8F6Cposix(String(\u540D));
|
|
28921
29028
|
if (\u76F8\u5BF9 === \u6839\u540D) return;
|
|
@@ -30402,6 +30509,7 @@ __export(internal_exports, {
|
|
|
30402
30509
|
SKILL_ROOTS_ENV: () => SKILL_ROOTS_ENV,
|
|
30403
30510
|
SKILL_TOOL_NAME: () => SKILL_TOOL_NAME,
|
|
30404
30511
|
SLOW_OP_DEFAULT_THRESHOLD_MS: () => SLOW_OP_DEFAULT_THRESHOLD_MS,
|
|
30512
|
+
SNAPSHOT_DIR_ENV: () => SNAPSHOT_DIR_ENV,
|
|
30405
30513
|
SNAPSHOT_GIT_TIMEOUT_MS: () => SNAPSHOT_GIT_TIMEOUT_MS,
|
|
30406
30514
|
SNAPSHOT_MAX_FILE_BYTES: () => SNAPSHOT_MAX_FILE_BYTES,
|
|
30407
30515
|
SPAWN_TEAMMATE: () => SPAWN_TEAMMATE,
|
|
@@ -30550,6 +30658,7 @@ __export(internal_exports, {
|
|
|
30550
30658
|
charsPerTokenForModel: () => charsPerTokenForModel,
|
|
30551
30659
|
charsPerTokenOf: () => charsPerTokenOf,
|
|
30552
30660
|
chatMessageChars: () => chatMessageChars,
|
|
30661
|
+
checkpointLabelOf: () => checkpointLabelOf,
|
|
30553
30662
|
checkpointLabelWithSeq: () => checkpointLabelWithSeq,
|
|
30554
30663
|
checkpointSeqOf: () => checkpointSeqOf,
|
|
30555
30664
|
childCompactBudget: () => childCompactBudget,
|
|
@@ -30896,6 +31005,7 @@ __export(internal_exports, {
|
|
|
30896
31005
|
resolvePublicHost: () => resolvePublicHost,
|
|
30897
31006
|
resolveResponseFormat: () => resolveResponseFormat,
|
|
30898
31007
|
resolveSessionIndex: () => resolveSessionIndex,
|
|
31008
|
+
resolveSnapshotDir: () => resolveSnapshotDir,
|
|
30899
31009
|
resolveSubagentRoles: () => resolveSubagentRoles,
|
|
30900
31010
|
restoreCheckpoint: () => restoreCheckpoint,
|
|
30901
31011
|
restoreMemoryStores: () => restoreMemoryStores,
|
|
@@ -30982,6 +31092,7 @@ __export(internal_exports, {
|
|
|
30982
31092
|
versionHeaderLine: () => versionHeaderLine,
|
|
30983
31093
|
warnSummaryDegraded: () => warnSummaryDegraded,
|
|
30984
31094
|
windowTokensForModel: () => windowTokensForModel,
|
|
31095
|
+
workspaceKeyOf: () => workspaceKeyOf,
|
|
30985
31096
|
worktreeDiskUsage: () => worktreeDiskUsage,
|
|
30986
31097
|
worktreesDirOf: () => worktreesDirOf,
|
|
30987
31098
|
writeFileTool: () => writeFileTool,
|
|
@@ -31056,6 +31167,8 @@ __export(internal_exports, {
|
|
|
31056
31167
|
\u8F6Cposix: () => \u8F6Cposix,
|
|
31057
31168
|
\u8FDB\u7A0B\u72B6\u6001: () => \u8FDB\u7A0B\u72B6\u6001,
|
|
31058
31169
|
\u906E\u853D\u68C0\u6D4B: () => \u906E\u853D\u68C0\u6D4B,
|
|
31170
|
+
\u9876\u5C42\u9519\u4F4D\u63D0\u793A: () => \u9876\u5C42\u9519\u4F4D\u63D0\u793A,
|
|
31171
|
+
\u9876\u5C42\u9519\u4F4D\u952E: () => \u9876\u5C42\u9519\u4F4D\u952E,
|
|
31059
31172
|
\u9879\u76EE\u7EA7\u5FFD\u7565\u63D0\u793A: () => \u9879\u76EE\u7EA7\u5FFD\u7565\u63D0\u793A
|
|
31060
31173
|
});
|
|
31061
31174
|
var init_internal = __esm({
|
|
@@ -31411,7 +31524,7 @@ var init_usage2 = __esm({
|
|
|
31411
31524
|
// packages/cli/src/cli-shared.ts
|
|
31412
31525
|
import { existsSync as existsSync15, readFileSync as readFileSync11, statSync as statSync4 } from "node:fs";
|
|
31413
31526
|
import "node:os";
|
|
31414
|
-
import { isAbsolute as
|
|
31527
|
+
import { isAbsolute as isAbsolute10, join as join38, resolve as resolve12 } from "node:path";
|
|
31415
31528
|
import { createInterface } from "node:readline/promises";
|
|
31416
31529
|
function loadDotEnv(file) {
|
|
31417
31530
|
const out = {};
|
|
@@ -31634,7 +31747,7 @@ async function setupSession(input) {
|
|
|
31634
31747
|
readRoots: () => [...\u53EF\u8BFB\u6839],
|
|
31635
31748
|
readRootsWithSource: () => \u53EF\u8BFB\u6839.map((dir) => ({ dir, from: [...\u6839\u6765\u6E90.get(dir) ?? []] })),
|
|
31636
31749
|
allowReadRoot: async (dir, opts) => {
|
|
31637
|
-
if (!
|
|
31750
|
+
if (!isAbsolute10(dir)) throw new Error(`\u8981\u7EDD\u5BF9\u8DEF\u5F84\uFF1A${dir}\uFF08\u5148 pwd \u62FF\u5230\u5B8C\u6574\u8DEF\u5F84\u518D\u7C98\u8FC7\u6765\uFF09`);
|
|
31638
31751
|
const \u7EDD\u5BF9 = resolve12(dir);
|
|
31639
31752
|
if (!existsSync15(\u7EDD\u5BF9)) throw new Error(`\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${\u7EDD\u5BF9}`);
|
|
31640
31753
|
if (!statSync4(\u7EDD\u5BF9).isDirectory()) throw new Error(`\u4E0D\u662F\u76EE\u5F55\uFF1A${\u7EDD\u5BF9}`);
|
|
@@ -31708,6 +31821,11 @@ async function setupSession(input) {
|
|
|
31708
31821
|
autoTitle: env.DALUO_SESSION_AUTO_TITLE === "1"
|
|
31709
31822
|
};
|
|
31710
31823
|
}
|
|
31824
|
+
function \u8BBE\u7F6E\u9519\u4F4D\u51FA\u58F0(err, configHome) {
|
|
31825
|
+
const \u6587\u4EF6 = globalSettingsFile(configHome, { create: false });
|
|
31826
|
+
const \u63D0\u793A = \u9876\u5C42\u9519\u4F4D\u63D0\u793A(loadSettingsSync2(\u6587\u4EF6));
|
|
31827
|
+
if (\u63D0\u793A !== void 0) err(`daluo: ${\u63D0\u793A}`);
|
|
31828
|
+
}
|
|
31711
31829
|
var init_cli_shared = __esm({
|
|
31712
31830
|
"packages/cli/src/cli-shared.ts"() {
|
|
31713
31831
|
"use strict";
|
|
@@ -31722,7 +31840,7 @@ var init_cli_shared = __esm({
|
|
|
31722
31840
|
});
|
|
31723
31841
|
|
|
31724
31842
|
// packages/cli/src/args.ts
|
|
31725
|
-
import { isAbsolute as
|
|
31843
|
+
import { isAbsolute as isAbsolute11, join as join39 } from "node:path";
|
|
31726
31844
|
function parseCliArgs(argv, opts = {}) {
|
|
31727
31845
|
const valueOptions = opts.valueOptions === void 0 ? VALUE_OPTIONS : new Set(opts.valueOptions);
|
|
31728
31846
|
const [command, ...rest] = argv;
|
|
@@ -31757,7 +31875,7 @@ function missingValueError(parsed, flag) {
|
|
|
31757
31875
|
return `--${flag} \u7F3A\u503C\uFF08\u8981\u7701\u7565\u5C31\u6574\u4E2A\u53BB\u6389 --${flag}\uFF09`;
|
|
31758
31876
|
}
|
|
31759
31877
|
function resolveResumeTarget(target, cwd) {
|
|
31760
|
-
if (
|
|
31878
|
+
if (isAbsolute11(target) || target.includes("/") || target.includes("\\")) return target;
|
|
31761
31879
|
return join39(sessionsDirOf(cwd), target);
|
|
31762
31880
|
}
|
|
31763
31881
|
var VALUE_OPTIONS;
|
|
@@ -31806,8 +31924,10 @@ function enableSlowProbe(env = process.env) {
|
|
|
31806
31924
|
function debugLine(event) {
|
|
31807
31925
|
switch (event.type) {
|
|
31808
31926
|
case "message/assistant": {
|
|
31809
|
-
const { usage, model } = event;
|
|
31810
|
-
if (usage === void 0 && model === void 0
|
|
31927
|
+
const { usage, model, durationMs, finishReason } = event;
|
|
31928
|
+
if (usage === void 0 && model === void 0 && durationMs === void 0 && finishReason === void 0) {
|
|
31929
|
+
return void 0;
|
|
31930
|
+
}
|
|
31811
31931
|
const bits = [`#${event.seq}`];
|
|
31812
31932
|
if (model !== void 0) bits.push(`model ${model}`);
|
|
31813
31933
|
if (usage !== void 0) {
|
|
@@ -31815,6 +31935,8 @@ function debugLine(event) {
|
|
|
31815
31935
|
bits.push(`prompt ${usage.promptTokens}${\u7F13\u5B58}`, `completion ${usage.completionTokens}`);
|
|
31816
31936
|
if (usage.reasoningTokens !== void 0) bits.push(`reasoning ${usage.reasoningTokens}`);
|
|
31817
31937
|
}
|
|
31938
|
+
if (durationMs !== void 0) bits.push(`duration ${durationMs}ms`);
|
|
31939
|
+
if (finishReason !== void 0) bits.push(`finish ${finishReason}`);
|
|
31818
31940
|
return bits.join(" \xB7 ");
|
|
31819
31941
|
}
|
|
31820
31942
|
case "session/model-changed":
|
|
@@ -31840,7 +31962,7 @@ var init_debug_channel = __esm({
|
|
|
31840
31962
|
// packages/cli/src/resume.ts
|
|
31841
31963
|
import { execFile as execFile8 } from "node:child_process";
|
|
31842
31964
|
import { existsSync as existsSync16 } from "node:fs";
|
|
31843
|
-
import { isAbsolute as
|
|
31965
|
+
import { isAbsolute as isAbsolute12, join as join40 } from "node:path";
|
|
31844
31966
|
import { promisify as promisify7 } from "node:util";
|
|
31845
31967
|
async function sameRepoWorktrees(cwd) {
|
|
31846
31968
|
try {
|
|
@@ -31859,7 +31981,7 @@ async function registeredProjectRoots() {
|
|
|
31859
31981
|
}
|
|
31860
31982
|
}
|
|
31861
31983
|
async function resolveResumeAcrossWorktrees(raw, cwd) {
|
|
31862
|
-
const explicit =
|
|
31984
|
+
const explicit = isAbsolute12(raw) || raw.includes("/") || raw.includes("\\");
|
|
31863
31985
|
const base = resolveResumeTarget(raw, cwd);
|
|
31864
31986
|
if (explicit) return { file: raw };
|
|
31865
31987
|
if (existsSync16(base)) return { file: base };
|
|
@@ -32174,7 +32296,7 @@ __export(log_exports, {
|
|
|
32174
32296
|
\u8F7D\u8377\u6458\u8981: () => \u8F7D\u8377\u6458\u8981
|
|
32175
32297
|
});
|
|
32176
32298
|
import { stat as stat18, readdir as readdir13, readFile as readFile17 } from "node:fs/promises";
|
|
32177
|
-
import { basename as
|
|
32299
|
+
import { basename as basename16, join as join42 } from "node:path";
|
|
32178
32300
|
function logUsage() {
|
|
32179
32301
|
return `\u7528\u6CD5: daluo log [<\u4F1A\u8BDD\u6587\u4EF6>] [--lines <N>]
|
|
32180
32302
|
\u4ECE\u4F1A\u8BDD\u65E5\u5FD7**\u5C3E\u90E8**\u8BFB\u6700\u8FD1 N \u6761\u4E8B\u4EF6\uFF08\u7F3A\u7701 ${DEFAULT_LOG_LINES} \u6761\u3001\u7F3A\u7701\u53D6\u5F53\u524D\u76EE\u5F55\u6700\u8FD1\u7684\u4F1A\u8BDD\uFF09\u3002
|
|
@@ -32283,10 +32405,10 @@ async function runLogCommand(argv, io) {
|
|
|
32283
32405
|
return EXIT.corrupt;
|
|
32284
32406
|
}
|
|
32285
32407
|
if (notes.length === 0) {
|
|
32286
|
-
io.out(`${
|
|
32408
|
+
io.out(`${basename16(file)} \xB7 \u65E0\u4FEE\u590D\u8BB0\u5F55`);
|
|
32287
32409
|
return EXIT.ok;
|
|
32288
32410
|
}
|
|
32289
|
-
io.out(`${
|
|
32411
|
+
io.out(`${basename16(file)} \xB7 \u4FEE\u590D\u8D26 ${notes.length} \u6761`);
|
|
32290
32412
|
for (const n of notes) io.out(`${n.at} ${n.kind} \u7B2C ${n.line} \u884C \u4E22\u6389 ${n.droppedBytes} \u5B57\u8282 ${n.reason}`);
|
|
32291
32413
|
return EXIT.ok;
|
|
32292
32414
|
}
|
|
@@ -32314,7 +32436,7 @@ async function runLogCommand(argv, io) {
|
|
|
32314
32436
|
io.err(`daluo log: ${error instanceof Error ? error.message : String(error)}`);
|
|
32315
32437
|
return EXIT.corrupt;
|
|
32316
32438
|
}
|
|
32317
|
-
io.out(`${
|
|
32439
|
+
io.out(`${basename16(file)} \xB7 \u6700\u8FD1 ${events.length} \u6761`);
|
|
32318
32440
|
if (events.length === 0) {
|
|
32319
32441
|
io.out("\uFF08\u8BE5\u7A97\u53E3\u5185\u6CA1\u6709\u4E8B\u4EF6\uFF09");
|
|
32320
32442
|
return EXIT.ok;
|
|
@@ -32346,9 +32468,12 @@ __export(doctor_exports, {
|
|
|
32346
32468
|
compareSemver: () => compareSemver,
|
|
32347
32469
|
doctorUsage: () => doctorUsage,
|
|
32348
32470
|
resolveDoctorContext: () => resolveDoctorContext,
|
|
32349
|
-
runDoctorCommand: () => runDoctorCommand
|
|
32471
|
+
runDoctorCommand: () => runDoctorCommand,
|
|
32472
|
+
\u68C0\u67E5\u53EF\u9009\u4F9D\u8D56: () => \u68C0\u67E5\u53EF\u9009\u4F9D\u8D56
|
|
32350
32473
|
});
|
|
32351
32474
|
import { existsSync as existsSync17, readdirSync as readdirSync2, readFileSync as readFileSync12, statSync as statSync5 } from "node:fs";
|
|
32475
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
32476
|
+
import { fileURLToPath } from "node:url";
|
|
32352
32477
|
function resolveDoctorContext(io) {
|
|
32353
32478
|
const processEnv = io.processEnv ?? process.env;
|
|
32354
32479
|
return {
|
|
@@ -32443,8 +32568,48 @@ async function collectChecks(ctx) {
|
|
|
32443
32568
|
status: \u5168\u90E8.length === 0 ? "ok" : \u7F3A\u7684.length > 0 ? "warn" : "ok",
|
|
32444
32569
|
detail: \u5168\u90E8.length === 0 ? `\u6CA1\u6709\u53EF\u7528\u7684\u8BED\u8A00\u670D\u52A1\u5668\uFF08\u663E\u5F0F\u914D\u7F6E 0 \u6761\u3001\u81EA\u52A8\u63A2\u6D4B 0 \u6761${lspDetectEnabled(ctx.processEnv) ? "" : "\uFF1BDALUO_LSP_DETECT=0 \u5DF2\u5173\u6389\u63A2\u6D4B"}\uFF09` : `${\u5168\u90E8.length} \u6761\uFF08\u663E\u5F0F ${\u663E\u5F0F?.length ?? 0} + \u63A2\u6D4B ${\u63A2\u6D4B.length}\uFF09\uFF1A` + \u5168\u90E8.map((c) => `${c.command}${\u547D\u4EE4\u5728\u8DEF\u5F84(c.command, ctx.processEnv) === void 0 ? "\uFF08**\u4E0D\u5728 PATH \u4E0A**\uFF09" : ""}`).join("\u3001")
|
|
32445
32570
|
});
|
|
32571
|
+
checks.push(\u68C0\u67E5\u53EF\u9009\u4F9D\u8D56());
|
|
32446
32572
|
return checks;
|
|
32447
32573
|
}
|
|
32574
|
+
function \u53EF\u9009\u4F9D\u8D56\u540D() {
|
|
32575
|
+
try {
|
|
32576
|
+
const \u6587\u4EF6 = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
32577
|
+
const j = JSON.parse(readFileSync12(\u6587\u4EF6, "utf8"));
|
|
32578
|
+
return Object.keys(j.optionalDependencies ?? {});
|
|
32579
|
+
} catch {
|
|
32580
|
+
return void 0;
|
|
32581
|
+
}
|
|
32582
|
+
}
|
|
32583
|
+
function \u68C0\u67E5\u53EF\u9009\u4F9D\u8D56(input = {}) {
|
|
32584
|
+
const \u540D\u4EEC = input.\u540D === null ? void 0 : input.\u540D ?? \u53EF\u9009\u4F9D\u8D56\u540D();
|
|
32585
|
+
if (\u540D\u4EEC === void 0) {
|
|
32586
|
+
return { id: "optional-deps", status: "warn", detail: "\u8BFB\u4E0D\u5230\u5305\u6E05\u5355\uFF08package.json \u4E0D\u5728\u9884\u671F\u4F4D\u7F6E\uFF09\u21D2 \u65E0\u4ECE\u5224\u65AD\u53EF\u9009\u4F9D\u8D56\u88C5\u6CA1\u88C5" };
|
|
32587
|
+
}
|
|
32588
|
+
if (\u540D\u4EEC.length === 0) return { id: "optional-deps", status: "ok", detail: "\u8FD9\u4E2A\u5305\u6CA1\u6709\u53EF\u9009\u4F9D\u8D56" };
|
|
32589
|
+
const \u63A2 = input.\u63A2 ?? \u80FD\u89E3\u6790;
|
|
32590
|
+
const require2 = createRequire2(import.meta.url);
|
|
32591
|
+
const \u7F3A = \u540D\u4EEC.filter((\u540D) => !\u63A2(\u540D));
|
|
32592
|
+
if (\u7F3A.length === 0) return { id: "optional-deps", status: "ok", detail: `${\u540D\u4EEC.join(" / ")} \u90FD\u5728` };
|
|
32593
|
+
return {
|
|
32594
|
+
id: "optional-deps",
|
|
32595
|
+
status: "warn",
|
|
32596
|
+
detail: `\u672A\u5B89\u88C5\uFF1A${\u7F3A.join("\u3001")}\uFF08headless \u7528 --omit=optional \u88C5\u5C31\u662F\u8FD9\u6837\uFF1APTY \u9000\u5316\u6210\u7BA1\u9053\u6863\u3001computer-use \u4E0D\u53EF\u7528\uFF1B\u8981\u8FD9\u4E24\u9879\u5C31\u91CD\u88C5\u4E0D\u5E26 --omit=optional\uFF09`
|
|
32597
|
+
};
|
|
32598
|
+
}
|
|
32599
|
+
function \u80FD\u89E3\u6790(\u540D) {
|
|
32600
|
+
const require2 = createRequire2(import.meta.url);
|
|
32601
|
+
try {
|
|
32602
|
+
require2.resolve(\u540D);
|
|
32603
|
+
return true;
|
|
32604
|
+
} catch {
|
|
32605
|
+
}
|
|
32606
|
+
try {
|
|
32607
|
+
import.meta.resolve(\u540D);
|
|
32608
|
+
return true;
|
|
32609
|
+
} catch {
|
|
32610
|
+
return false;
|
|
32611
|
+
}
|
|
32612
|
+
}
|
|
32448
32613
|
function collectLogLocations(ctx) {
|
|
32449
32614
|
const \u8868 = [
|
|
32450
32615
|
{ kind: "session", label: "session", path: sessionsDirOf(ctx.cwd) },
|
|
@@ -32456,7 +32621,7 @@ function collectLogLocations(ctx) {
|
|
|
32456
32621
|
return \u8868.map((l) => ({ ...l, exists: existsSync17(l.path) }));
|
|
32457
32622
|
}
|
|
32458
32623
|
function doctorUsage() {
|
|
32459
|
-
return "\u7528\u6CD5: daluo doctor\n \u73AF\u5883\u5065\u5EB7\u68C0\u67E5 + \u65E5\u5FD7\u843D\u70B9\uFF08**\u53EA\u8BFB**\uFF1A\u4E0D\u5EFA\u76EE\u5F55\u3001\u4E0D\u5199\u6587\u4EF6\uFF1B**\u65E0\u53C2\u6570**\uFF09\u3002\n \u68C0\u67E5 node / config-dir / sessions-dir / settings / llm-credentials / sandbox / lsp \
|
|
32624
|
+
return "\u7528\u6CD5: daluo doctor\n \u73AF\u5883\u5065\u5EB7\u68C0\u67E5 + \u65E5\u5FD7\u843D\u70B9\uFF08**\u53EA\u8BFB**\uFF1A\u4E0D\u5EFA\u76EE\u5F55\u3001\u4E0D\u5199\u6587\u4EF6\uFF1B**\u65E0\u53C2\u6570**\uFF09\u3002\n \u68C0\u67E5 node / config-dir / sessions-dir / settings / llm-credentials / sandbox / lsp / optional-deps \u516B\u9879\uFF0C\u5E76\u5217\u5168\u90E8\u65E5\u5FD7\u843D\u70B9\u3002\n \u4EFB\u4E00 `fail` \u21D2 \u9000\u51FA\u7801 1\uFF1B`warn`\uFF08\u672A\u914D\u51ED\u8BC1 / \u65E0\u6C99\u7BB1\u540E\u7AEF\uFF09\u4E0D\u5F71\u54CD\u9000\u51FA\u7801\u3002\n";
|
|
32460
32625
|
}
|
|
32461
32626
|
async function runDoctorCommand(argv, io) {
|
|
32462
32627
|
const parsed = parseCliArgs(argv);
|
|
@@ -33222,7 +33387,7 @@ __export(session_exports, {
|
|
|
33222
33387
|
sessionUsage: () => sessionUsage
|
|
33223
33388
|
});
|
|
33224
33389
|
import { existsSync as existsSync18 } from "node:fs";
|
|
33225
|
-
import { basename as
|
|
33390
|
+
import { basename as basename17 } from "node:path";
|
|
33226
33391
|
function originSuffix(node) {
|
|
33227
33392
|
return node.forkedFrom === void 0 ? "" : ` \u2190 ${node.forkedFrom.file}@${node.forkedFrom.seq}`;
|
|
33228
33393
|
}
|
|
@@ -33314,7 +33479,7 @@ async function runSessionCommand(argv, io) {
|
|
|
33314
33479
|
newFile,
|
|
33315
33480
|
...branchSummary !== void 0 ? { branchSummary } : {}
|
|
33316
33481
|
});
|
|
33317
|
-
const name =
|
|
33482
|
+
const name = basename17(newFile);
|
|
33318
33483
|
io.out(`\u5DF2\u5206\u53C9\uFF1A${target}${atSeq !== void 0 ? `\uFF08\u622A\u81F3 seq ${atSeq}\uFF09` : "\uFF08\u6574\u4E2A\u4F1A\u8BDD\uFF09"} \u2192 ${name}`);
|
|
33319
33484
|
if (branchSummary !== void 0) io.out(`\u5DF2\u6CE8\u5165\u88AB\u653E\u5F03\u8DEF\u5F84\u6458\u8981\uFF08${branchSummary.length} \u5B57\u7B26\uFF09`);
|
|
33320
33485
|
io.out(`\u7EED\u8DD1\uFF1Adaluo chat --resume ${name}`);
|
|
@@ -33350,7 +33515,7 @@ async function runSessionCommand(argv, io) {
|
|
|
33350
33515
|
while (existsSync18(newFile)) newFile = makeNewSessionLogFile(io.cwd, ts += 1);
|
|
33351
33516
|
const r = await summarizeUpToSession({ sourceFile, upToSeq: toSeq, newFile });
|
|
33352
33517
|
io.out(`\u5DF2\u6458\u8981\u5230\u6B64\uFF1A\u6E90 seq 1..${toSeq} \u6458\u6210 ${r.summaryChars} \u5B57\u7B26\uFF1B\u4E4B\u540E\u7684\u539F\u6587\u7167\u6284\uFF08${r.keptMessages} \u6761\u6D88\u606F\uFF09`);
|
|
33353
|
-
const name =
|
|
33518
|
+
const name = basename17(newFile);
|
|
33354
33519
|
io.out(`\u65B0\u4F1A\u8BDD\uFF1A${name}`);
|
|
33355
33520
|
io.out(`\u7EED\u8DD1\uFF1Adaluo chat --resume ${name}`);
|
|
33356
33521
|
io.out(`\u6E90\u4F1A\u8BDD\u672A\u52A8\uFF08\u60F3\u63A5\u7740\u539F\u6765\u7684\u8DEF\u8D70\uFF1Adaluo chat --resume ${target}\uFF09`);
|
|
@@ -33400,7 +33565,7 @@ async function runSessionCommand(argv, io) {
|
|
|
33400
33565
|
if (r.skipped.length > 0) {
|
|
33401
33566
|
io.out(`\u8DF3\u8FC7 ${r.skipped.reduce((n, s) => n + s.count, 0)} \u6761\uFF08\u5916\u90E8\u683C\u5F0F\u91CC\u672C\u4ED3\u4E0D\u6620\u5C04\u7684\u4E1C\u897F\uFF09\uFF1A` + r.skipped.map((s) => `${s.kind}\xD7${s.count}`).join("\u3001"));
|
|
33402
33567
|
}
|
|
33403
|
-
const name =
|
|
33568
|
+
const name = basename17(targetFile);
|
|
33404
33569
|
io.out(`\u76EE\u6807\u4F1A\u8BDD\uFF1A${name}`);
|
|
33405
33570
|
io.out(`\u7EED\u8DD1\uFF1Adaluo chat --resume ${name}`);
|
|
33406
33571
|
return 0;
|
|
@@ -33423,7 +33588,7 @@ async function runSessionCommand(argv, io) {
|
|
|
33423
33588
|
io.err(`daluo session decompress: ${r2.reason}`);
|
|
33424
33589
|
return EXIT.input;
|
|
33425
33590
|
}
|
|
33426
|
-
io.out(`\u5DF2\u89E3\u538B\uFF1A${
|
|
33591
|
+
io.out(`\u5DF2\u89E3\u538B\uFF1A${basename17(r2.out)}\uFF08${r2.bytesBefore} \u2192 ${r2.bytesAfter} \u5B57\u8282\uFF1B\u73B0\u5728\u53EF\u4EE5 --resume \u7EED\u8DD1\uFF09`);
|
|
33427
33592
|
return 0;
|
|
33428
33593
|
}
|
|
33429
33594
|
const log = await EventLog.restore(sourceFile);
|
|
@@ -33437,8 +33602,8 @@ async function runSessionCommand(argv, io) {
|
|
|
33437
33602
|
return EXIT.input;
|
|
33438
33603
|
}
|
|
33439
33604
|
const \u7701 = r.bytesBefore === 0 ? 0 : Math.round((1 - r.bytesAfter / r.bytesBefore) * 100);
|
|
33440
|
-
io.out(`\u5DF2\u538B\u7F29\uFF1A${
|
|
33441
|
-
io.out(`\u8BFB\u4FA7\u6309\u540E\u7F00\u81EA\u52A8\u89E3\u7801\uFF08\`daluo log\` / \`ls\` / \`usage\` \u7167\u65E7\uFF09\uFF1B\u8981\u7EED\u8DD1\u5148 \`daluo session decompress ${
|
|
33605
|
+
io.out(`\u5DF2\u538B\u7F29\uFF1A${basename17(r.out)}\uFF08${r.bytesBefore} \u2192 ${r.bytesAfter} \u5B57\u8282\uFF0C\u7701 ${\u7701}%\uFF09`);
|
|
33606
|
+
io.out(`\u8BFB\u4FA7\u6309\u540E\u7F00\u81EA\u52A8\u89E3\u7801\uFF08\`daluo log\` / \`ls\` / \`usage\` \u7167\u65E7\uFF09\uFF1B\u8981\u7EED\u8DD1\u5148 \`daluo session decompress ${basename17(r.out)}\``);
|
|
33442
33607
|
return 0;
|
|
33443
33608
|
}
|
|
33444
33609
|
case "revert": {
|
|
@@ -33501,7 +33666,7 @@ async function runSessionCommand(argv, io) {
|
|
|
33501
33666
|
} else {
|
|
33502
33667
|
io.out(`\u6587\u4EF6\u672A\u52A8\uFF1A${r.fileRestoreSkipped ?? "\u6CA1\u6709\u53EF\u7528\u7684\u5FEB\u7167"}`);
|
|
33503
33668
|
}
|
|
33504
|
-
const name =
|
|
33669
|
+
const name = basename17(newFile);
|
|
33505
33670
|
io.out(`\u5BF9\u8BDD\u5DF2\u56DE\u5230 seq ${toSeq}\uFF1A${target} \u2192 ${name}`);
|
|
33506
33671
|
io.out(`\u7EED\u8DD1\uFF1Adaluo chat --resume ${name}`);
|
|
33507
33672
|
if (r.reproposed.length > 0) {
|
|
@@ -33550,11 +33715,11 @@ async function runSessionCommand(argv, io) {
|
|
|
33550
33715
|
return EXIT.input;
|
|
33551
33716
|
}
|
|
33552
33717
|
const metas = await listSessions(sessionsDirOf(io.cwd), { includeArchived: true, indexFile: sessionIndexFileOf(io.cwd) });
|
|
33553
|
-
const self = metas.find((m) => m.file ===
|
|
33718
|
+
const self = metas.find((m) => m.file === basename17(file));
|
|
33554
33719
|
const forest = sessionTree(metas);
|
|
33555
33720
|
const node = self?.sessionId !== void 0 ? findNode(forest, self.sessionId) : void 0;
|
|
33556
33721
|
if (node === void 0) {
|
|
33557
|
-
io.out(`${
|
|
33722
|
+
io.out(`${basename17(file)}\uFF08\u672A\u80FD\u5728\u4F1A\u8BDD\u96C6\u5408\u91CC\u5B9A\u4F4D\uFF0C\u65E0\u6CD5\u7ED9\u51FA\u8840\u7F18\uFF09`);
|
|
33558
33723
|
return 0;
|
|
33559
33724
|
}
|
|
33560
33725
|
if (sub === "children") {
|
|
@@ -33610,11 +33775,21 @@ __export(rewind_exports, {
|
|
|
33610
33775
|
rewindUsage: () => rewindUsage,
|
|
33611
33776
|
runRewindCommand: () => runRewindCommand
|
|
33612
33777
|
});
|
|
33778
|
+
import { relative as relative3 } from "node:path";
|
|
33613
33779
|
function rewindUsage() {
|
|
33614
|
-
return "\u7528\u6CD5: daluo rewind <\u5B50\u547D\u4EE4>\n daluo rewind ls \u5217\u51FA\u672C\u5DE5\u4F5C\u533A\u7684\u6587\u4EF6\u5FEB\u7167\uFF08\u65B0 \u2192 \u65E7\uFF09\n daluo rewind to <hash> \u56DE\u5230\u67D0\u4E2A\u5FEB\u7167\uFF08\u6574\u6811\uFF09\n daluo rewind to <hash> --path <p> \u53EA\u6062\u590D\u90A3\u4E00\u4E2A\u8DEF\u5F84\uFF08\u5176\u4F59\u6539\u52A8\u4FDD\u7559\uFF09\n\n\uFF08\u4E0D\u5E26\u5B50\u547D\u4EE4 = ls\uFF0C\u6700\u5E38\u7528\u7684\u90A3\u4E2A\u3002\uFF09\n\u5FEB\u7167\u662F**\u5F71\u5B50 git \u4ED3\u5E93**\uFF08`.daluo/snapshots/`\uFF09\u2014\u2014\u4E0D\u78B0\u4F60\u7684 `.git`\u3002\nagent \u6BCF\u6B21\u6539\u6587\u4EF6**\u4E4B\u524D**\u90FD\u4F1A\u81EA\u52A8\u6253\u4E00\u4E2A\u70B9\uFF08`DALUO_SNAPSHOT=off` \u53EF\u5173\uFF09\u3002\n**\u4EE3\u4EF7**\uFF1A\u6BCF\u6B21\u6253\u70B9\u90FD\u5728\u5F71\u5B50\u4ED3\u5E93\u91CC\u63D0\u4EA4\u4E00\u6B21 \u2014\u2014 \u5927\u4ED3\u91CC\u4F1A\u5360\u78C1\u76D8\u3001\u4E5F\u53EF\u80FD\u62D6\u6162\uFF1B`ls` \u4F1A\u62A5\u51FA\u5F53\u524D\u6761\u6570\u4E0E\u4F53\u79EF\u3002\n";
|
|
33780
|
+
return "\u7528\u6CD5: daluo rewind <\u5B50\u547D\u4EE4>\n daluo rewind ls \u5217\u51FA\u672C\u5DE5\u4F5C\u533A\u7684\u6587\u4EF6\u5FEB\u7167\uFF08\u65B0 \u2192 \u65E7\uFF09\n daluo rewind to <hash> \u56DE\u5230\u67D0\u4E2A\u5FEB\u7167\uFF08\u6574\u6811\uFF09\n daluo rewind to <hash> --path <p> \u53EA\u6062\u590D\u90A3\u4E00\u4E2A\u8DEF\u5F84\uFF08\u5176\u4F59\u6539\u52A8\u4FDD\u7559\uFF09\n\n\uFF08\u4E0D\u5E26\u5B50\u547D\u4EE4 = ls\uFF0C\u6700\u5E38\u7528\u7684\u90A3\u4E2A\u3002\uFF09\n \u9009\u9879\uFF1A--json \u673A\u5668\u53EF\u8BFB\u8F93\u51FA\uFF08\u5355\u884C JSON\uFF1B\u7ED9\u9762\u677F/\u811A\u672C\u7528\uFF09\n --snapshot-dir <dir> \u7528\u8FD9\u4E2A\u5F71\u5B50\u4ED3\u5E93\u76EE\u5F55\uFF08\u7F3A\u7701 `.daluo/snapshots/`\uFF1B\n \u76F8\u5BF9\u8DEF\u5F84\u6309\u5F53\u524D\u76EE\u5F55\u89E3\u6790\uFF09\n\u5FEB\u7167\u662F**\u5F71\u5B50 git \u4ED3\u5E93**\uFF08`.daluo/snapshots/`\uFF09\u2014\u2014\u4E0D\u78B0\u4F60\u7684 `.git`\u3002\nagent \u6BCF\u6B21\u6539\u6587\u4EF6**\u4E4B\u524D**\u90FD\u4F1A\u81EA\u52A8\u6253\u4E00\u4E2A\u70B9\uFF08`DALUO_SNAPSHOT=off` \u53EF\u5173\uFF09\u3002\n**\u4EE3\u4EF7**\uFF1A\u6BCF\u6B21\u6253\u70B9\u90FD\u5728\u5F71\u5B50\u4ED3\u5E93\u91CC\u63D0\u4EA4\u4E00\u6B21 \u2014\u2014 \u5927\u4ED3\u91CC\u4F1A\u5360\u78C1\u76D8\u3001\u4E5F\u53EF\u80FD\u62D6\u6162\uFF1B`ls` \u4F1A\u62A5\u51FA\u5F53\u524D\u6761\u6570\u4E0E\u4F53\u79EF\u3002\n";
|
|
33781
|
+
}
|
|
33782
|
+
function \u5FEB\u7167env(snapshotDir) {
|
|
33783
|
+
return snapshotDir === void 0 ? void 0 : { ...process.env, DALUO_SNAPSHOT_DIR: snapshotDir };
|
|
33784
|
+
}
|
|
33785
|
+
function \u663E\u793A\u8DEF\u5F84(cwd, dir) {
|
|
33786
|
+
const \u76F8\u5BF9 = relative3(cwd, dir);
|
|
33787
|
+
return \u76F8\u5BF9 === "" || \u76F8\u5BF9.startsWith("..") ? dir : \u76F8\u5BF9;
|
|
33615
33788
|
}
|
|
33616
33789
|
async function runRewindCommand(argv, io) {
|
|
33617
|
-
const { command, positional, options, missingValues } = parseCliArgs(argv, {
|
|
33790
|
+
const { command, positional, options, flags, missingValues } = parseCliArgs(argv, {
|
|
33791
|
+
valueOptions: ["path", "snapshot-dir"]
|
|
33792
|
+
});
|
|
33618
33793
|
if (missingValues.size > 0) {
|
|
33619
33794
|
io.err(`daluo rewind: --${[...missingValues][0]} \u540E\u9762\u7F3A\u5C11\u503C`);
|
|
33620
33795
|
io.err(rewindUsage());
|
|
@@ -33642,33 +33817,66 @@ async function runRewindCommand(argv, io) {
|
|
|
33642
33817
|
io.err(rewindUsage());
|
|
33643
33818
|
return EXIT.input;
|
|
33644
33819
|
}
|
|
33820
|
+
const json3 = flags.has("json");
|
|
33821
|
+
if (json3 && to !== void 0) {
|
|
33822
|
+
io.err("daluo rewind: --json \u53EA\u7528\u4E8E\u5217\u8868\uFF08`daluo rewind ls --json`\uFF09\uFF1B`to` \u7684\u8F93\u51FA\u662F\u7ED9\u4EBA\u770B\u7684\u4E00\u53E5\u8BDD");
|
|
33823
|
+
return EXIT.input;
|
|
33824
|
+
}
|
|
33645
33825
|
if (path !== void 0 && to === void 0) {
|
|
33646
33826
|
io.err("daluo rewind: --path \u53EA\u80FD\u8DDF\u7740 `to <hash>` \u7528\uFF08\u5B83\u6307\u7684\u662F\u300C\u90A3\u4E2A\u5FEB\u7167\u91CC\u7684\u54EA\u4E2A\u6587\u4EF6\u300D\uFF09");
|
|
33647
33827
|
io.err(rewindUsage());
|
|
33648
33828
|
return EXIT.input;
|
|
33649
33829
|
}
|
|
33650
33830
|
if (to === void 0) {
|
|
33651
|
-
const
|
|
33831
|
+
const env2 = \u5FEB\u7167env(options.get("snapshot-dir"));
|
|
33832
|
+
const listed = await listCheckpoints({ cwd: io.cwd, withFiles: json3, ...env2 !== void 0 ? { env: env2 } : {} });
|
|
33652
33833
|
if (!listed.ok) {
|
|
33834
|
+
if (json3) {
|
|
33835
|
+
io.out(JSON.stringify({ ok: false, reason: listed.reason ?? "\u5F71\u5B50\u4ED3\u5E93\u4E0D\u5B58\u5728", dir: listed.dir, snapshots: [] }));
|
|
33836
|
+
return EXIT.input;
|
|
33837
|
+
}
|
|
33653
33838
|
io.err(`daluo rewind: \u8FD8\u6CA1\u6709\u5FEB\u7167\uFF08${listed.reason ?? "\u5F71\u5B50\u4ED3\u5E93\u4E0D\u5B58\u5728"}\uFF09`);
|
|
33654
33839
|
return EXIT.input;
|
|
33655
33840
|
}
|
|
33841
|
+
if (json3) {
|
|
33842
|
+
const cost2 = await snapshotCost({ cwd: io.cwd, ...env2 !== void 0 ? { env: env2 } : {} });
|
|
33843
|
+
io.out(JSON.stringify({
|
|
33844
|
+
ok: true,
|
|
33845
|
+
dir: listed.dir,
|
|
33846
|
+
total: { checkpoints: cost2.checkpoints, bytes: cost2.bytes },
|
|
33847
|
+
snapshots: listed.checkpoints.map((c) => ({
|
|
33848
|
+
hash: c.hash,
|
|
33849
|
+
at: c.ts,
|
|
33850
|
+
// 干净标签(位置在下面的 seq 字段里,不重复打)
|
|
33851
|
+
label: checkpointLabelOf(c.label),
|
|
33852
|
+
...c.seq !== void 0 ? { seq: c.seq } : {},
|
|
33853
|
+
...c.files !== void 0 ? { files: c.files } : {}
|
|
33854
|
+
}))
|
|
33855
|
+
}));
|
|
33856
|
+
return 0;
|
|
33857
|
+
}
|
|
33656
33858
|
if (listed.checkpoints.length === 0) {
|
|
33657
33859
|
io.out("\uFF08\u8FD8\u6CA1\u6709\u5FEB\u7167\uFF09");
|
|
33658
33860
|
return 0;
|
|
33659
33861
|
}
|
|
33660
33862
|
for (const c of listed.checkpoints) {
|
|
33661
|
-
io.out(`${short(c.hash)} ${c.ts} ${c.label}${c.seq !== void 0 ? ` \u2190 \u4F1A\u8BDD seq ${c.seq}` : ""}`);
|
|
33863
|
+
io.out(`${short(c.hash)} ${c.ts} ${checkpointLabelOf(c.label)}${c.seq !== void 0 ? ` \u2190 \u4F1A\u8BDD seq ${c.seq}` : ""}`);
|
|
33662
33864
|
}
|
|
33663
33865
|
io.out("");
|
|
33664
33866
|
io.out("\u56DE\u5230\u67D0\u4E2A\u5FEB\u7167\uFF1Adaluo rewind to <hash> \uFF08\u53EA\u56DE\u67D0\u4E00\u4E2A\u6587\u4EF6\uFF1A\u518D\u52A0 --path <\u8DEF\u5F84>\uFF09");
|
|
33665
33867
|
io.out("\u8FDE\u540C\u5BF9\u8BDD\u4E00\u8D77\u56DE\u5230\u90A3\u6761\u6D88\u606F\uFF1Adaluo session revert <\u4F1A\u8BDD\u6587\u4EF6> --to <seq>");
|
|
33666
|
-
const cost = await snapshotCost({ cwd: io.cwd });
|
|
33667
|
-
io.out(`\u5F71\u5B50\u4ED3\u5E93\uFF1A${cost.checkpoints} \u4E2A\u5FEB\u7167 / ${formatBytes(cost.bytes)}\uFF08.
|
|
33868
|
+
const cost = await snapshotCost({ cwd: io.cwd, ...env2 !== void 0 ? { env: env2 } : {} });
|
|
33869
|
+
io.out(`\u5F71\u5B50\u4ED3\u5E93\uFF1A${cost.checkpoints} \u4E2A\u5FEB\u7167 / ${formatBytes(cost.bytes)}\uFF08${\u663E\u793A\u8DEF\u5F84(io.cwd, listed.dir)}\uFF09`);
|
|
33668
33870
|
io.out("\uFF08\u5927\u4ED3\u91CC agent \u6BCF\u6539\u4E00\u6B21\u6587\u4EF6\u90FD\u4F1A\u6253\u70B9\uFF1A\u5360\u78C1\u76D8\u3001\u4E5F\u53EF\u80FD\u62D6\u6162\uFF1B\u4E0D\u8981\u5C31\u628A\u73AF\u5883\u53D8\u91CF DALUO_SNAPSHOT \u8BBE\u6210 off\uFF09");
|
|
33669
33871
|
return 0;
|
|
33670
33872
|
}
|
|
33671
|
-
const
|
|
33873
|
+
const env = \u5FEB\u7167env(options.get("snapshot-dir"));
|
|
33874
|
+
const back = await restoreCheckpoint({
|
|
33875
|
+
cwd: io.cwd,
|
|
33876
|
+
checkpoint: to,
|
|
33877
|
+
...path !== void 0 ? { path } : {},
|
|
33878
|
+
...env !== void 0 ? { env } : {}
|
|
33879
|
+
});
|
|
33672
33880
|
if (!back.ok) {
|
|
33673
33881
|
io.err(`daluo rewind: \u56DE\u9000\u5931\u8D25\uFF08${back.reason ?? "\u672A\u77E5\u539F\u56E0"}\uFF09`);
|
|
33674
33882
|
io.err("\uFF08\u5148 `daluo rewind ls` \u770B\u4E00\u773C\u53EF\u7528\u7684\u5FEB\u7167 hash\uFF1Bhash \u6253\u9519\u4E5F\u4F1A\u8D70\u8FD9\u6761\uFF09");
|
|
@@ -33873,7 +34081,7 @@ var init_gc2 = __esm({
|
|
|
33873
34081
|
});
|
|
33874
34082
|
|
|
33875
34083
|
// packages/cli/src/mcp-agent.ts
|
|
33876
|
-
import { basename as
|
|
34084
|
+
import { basename as basename18, resolve as resolve14 } from "node:path";
|
|
33877
34085
|
function runAgentCompactBudget(env) {
|
|
33878
34086
|
return sessionCompactBudget(loadLlmConfig(env).contextWindowTokens, env);
|
|
33879
34087
|
}
|
|
@@ -33930,7 +34138,7 @@ function createRunAgentTool(deps) {
|
|
|
33930
34138
|
const mcp = deps.ctx;
|
|
33931
34139
|
const result = await new AgentRunner().run({
|
|
33932
34140
|
prompt,
|
|
33933
|
-
sessionId:
|
|
34141
|
+
sessionId: basename18(logFile, ".jsonl"),
|
|
33934
34142
|
logFile,
|
|
33935
34143
|
llm,
|
|
33936
34144
|
decision: deps.decision,
|
|
@@ -34433,6 +34641,8 @@ async function chatMain(argv) {
|
|
|
34433
34641
|
const ts = Date.now();
|
|
34434
34642
|
const isNew = !resume;
|
|
34435
34643
|
const sessionId = isNew ? `s-${ts}` : resume;
|
|
34644
|
+
\u8BBE\u7F6E\u9519\u4F4D\u51FA\u58F0((line) => process.stderr.write(`${line}
|
|
34645
|
+
`));
|
|
34436
34646
|
const s = await setupSession({ cwd, sessionId, confirm: ask.confirm, cuaAsk: ask.askQuestion });
|
|
34437
34647
|
const { llm, decision, memory, assembly } = s;
|
|
34438
34648
|
const memorySession = { injected: /* @__PURE__ */ new Set(), used: 0 };
|
|
@@ -34528,7 +34738,7 @@ var init_chat = __esm({
|
|
|
34528
34738
|
import { spawn as spawn6 } from "node:child_process";
|
|
34529
34739
|
import { readdir as readdir14 } from "node:fs/promises";
|
|
34530
34740
|
import { homedir as homedir8 } from "node:os";
|
|
34531
|
-
import { basename as
|
|
34741
|
+
import { basename as basename19, join as join45 } from "node:path";
|
|
34532
34742
|
function scrubbedEnv(parent = process.env) {
|
|
34533
34743
|
const env = {};
|
|
34534
34744
|
for (const [key, value] of Object.entries(parent)) {
|
|
@@ -34565,7 +34775,7 @@ async function listApplications(roots) {
|
|
|
34565
34775
|
} catch {
|
|
34566
34776
|
continue;
|
|
34567
34777
|
}
|
|
34568
|
-
for (const entry of entries) names.add(
|
|
34778
|
+
for (const entry of entries) names.add(basename19(entry, ".app"));
|
|
34569
34779
|
const dirs = [];
|
|
34570
34780
|
try {
|
|
34571
34781
|
for (const child of await readdir14(root, { withFileTypes: true })) {
|
|
@@ -34576,7 +34786,7 @@ async function listApplications(roots) {
|
|
|
34576
34786
|
}
|
|
34577
34787
|
for (const dir of dirs) {
|
|
34578
34788
|
try {
|
|
34579
|
-
for (const entry of (await readdir14(dir)).filter((n) => n.endsWith(".app"))) names.add(
|
|
34789
|
+
for (const entry of (await readdir14(dir)).filter((n) => n.endsWith(".app"))) names.add(basename19(entry, ".app"));
|
|
34580
34790
|
} catch {
|
|
34581
34791
|
continue;
|
|
34582
34792
|
}
|
|
@@ -34793,7 +35003,7 @@ var init_error_codes = __esm({
|
|
|
34793
35003
|
|
|
34794
35004
|
// packages/server/src/static.ts
|
|
34795
35005
|
import { open as open4, realpath as realpath4, stat as stat20 } from "node:fs/promises";
|
|
34796
|
-
import { extname as extname3, isAbsolute as
|
|
35006
|
+
import { extname as extname3, isAbsolute as isAbsolute13, join as join46, sep as sep5 } from "node:path";
|
|
34797
35007
|
function mimeOf(fileName) {
|
|
34798
35008
|
return MIME_BY_EXT[extname3(fileName).toLowerCase()] ?? DEFAULT_STATIC_MIME;
|
|
34799
35009
|
}
|
|
@@ -34868,7 +35078,7 @@ async function tryRealpath(path) {
|
|
|
34868
35078
|
}
|
|
34869
35079
|
}
|
|
34870
35080
|
async function resolveStaticTarget(mount, subPath) {
|
|
34871
|
-
if (!
|
|
35081
|
+
if (!isAbsolute13(mount.dir)) return { ok: false, status: 500, \u539F\u56E0: `\u6302\u8F7D\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF1A${mount.dir}` };
|
|
34872
35082
|
const \u95E8 = staticSubPath(subPath);
|
|
34873
35083
|
if (!\u95E8.ok) return { ok: false, status: 400, \u539F\u56E0: \u95E8.\u539F\u56E0 };
|
|
34874
35084
|
const \u6839 = mount.dir;
|
|
@@ -35339,10 +35549,10 @@ var init_theme = __esm({
|
|
|
35339
35549
|
|
|
35340
35550
|
// packages/server/src/events.ts
|
|
35341
35551
|
import { closeSync, existsSync as existsSync22, openSync, readSync, realpathSync as realpathSync7, statSync as statSync6 } from "node:fs";
|
|
35342
|
-
import { basename as
|
|
35552
|
+
import { basename as basename20, join as join48, sep as sep6 } from "node:path";
|
|
35343
35553
|
function resolveSessionFile2(sessionsDir, name) {
|
|
35344
35554
|
if (name.trim() === "") throw new Error("session \u5FC5\u586B\uFF08\u4F1A\u8BDD\u6587\u4EF6\u540D\uFF0C\u5F62\u5982 s-123.jsonl\uFF09");
|
|
35345
|
-
if (name !==
|
|
35555
|
+
if (name !== basename20(name)) throw new Error(`session \u53EA\u80FD\u662F\u6587\u4EF6\u540D\uFF08\u4E0D\u542B\u8DEF\u5F84\u5206\u9694\u7B26\uFF09\uFF1A${name}`);
|
|
35346
35556
|
if (!\u662F\u4F1A\u8BDD\u65E5\u5FD7\u540D(name)) throw new Error(`session \u5FC5\u987B\u662F .jsonl\uFF1A${name}`);
|
|
35347
35557
|
const file = join48(sessionsDir, name);
|
|
35348
35558
|
if (!isWithinDir(sessionsDir, file)) throw new Error(`session \u8D8A\u754C\uFF1A${name}`);
|
|
@@ -35691,7 +35901,7 @@ var init_files = __esm({
|
|
|
35691
35901
|
// packages/server/src/project.ts
|
|
35692
35902
|
import { readdir as readdir16, realpath as realpath6, stat as stat22 } from "node:fs/promises";
|
|
35693
35903
|
import { homedir as homedir9 } from "node:os";
|
|
35694
|
-
import { basename as
|
|
35904
|
+
import { basename as basename21, dirname as dirname16, join as join50, sep as sep8 } from "node:path";
|
|
35695
35905
|
async function realpathOrUndefined(path) {
|
|
35696
35906
|
try {
|
|
35697
35907
|
return await realpath6(path);
|
|
@@ -35769,7 +35979,7 @@ async function listChildDirs(roots, path) {
|
|
|
35769
35979
|
};
|
|
35770
35980
|
}
|
|
35771
35981
|
function projectNameOf(root) {
|
|
35772
|
-
return
|
|
35982
|
+
return basename21(root) || root;
|
|
35773
35983
|
}
|
|
35774
35984
|
var MAX_DIRS;
|
|
35775
35985
|
var init_project = __esm({
|
|
@@ -36143,7 +36353,7 @@ import { Readable } from "node:stream";
|
|
|
36143
36353
|
import { createReadStream, existsSync as existsSync23, mkdirSync as mkdirSync12, readdirSync as readdirSync3 } from "node:fs";
|
|
36144
36354
|
import { rm as rm3 } from "node:fs/promises";
|
|
36145
36355
|
import { stat as stat23, writeFile as writeFile7 } from "node:fs/promises";
|
|
36146
|
-
import { join as join52, basename as
|
|
36356
|
+
import { join as join52, basename as basename22, sep as sep9 } from "node:path";
|
|
36147
36357
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
36148
36358
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
36149
36359
|
import { homedir as homedir10 } from "node:os";
|
|
@@ -36155,7 +36365,7 @@ function json(status, body, headers = {}) {
|
|
|
36155
36365
|
}
|
|
36156
36366
|
function safeUploadName(raw) {
|
|
36157
36367
|
const flat = raw.replace(/\\/gu, "/");
|
|
36158
|
-
const name =
|
|
36368
|
+
const name = basename22(flat).replace(/[\u0000-\u001f\u007f]/gu, "").trim();
|
|
36159
36369
|
if (name === "" || name === "." || name === "..") {
|
|
36160
36370
|
throw new Error(`\u6587\u4EF6\u540D\u4E0D\u53EF\u7528\uFF1A${JSON.stringify(raw)}`);
|
|
36161
36371
|
}
|
|
@@ -36751,7 +36961,7 @@ function createDaluoFetch(opts) {
|
|
|
36751
36961
|
});
|
|
36752
36962
|
return json(200, {
|
|
36753
36963
|
reply: result.reply,
|
|
36754
|
-
logFile:
|
|
36964
|
+
logFile: basename22(result.logFile),
|
|
36755
36965
|
...abort.signal.aborted ? { interrupted: true } : {}
|
|
36756
36966
|
});
|
|
36757
36967
|
} catch (error) {
|
|
@@ -36889,15 +37099,15 @@ function createDaluoFetch(opts) {
|
|
|
36889
37099
|
const ext = dot > 0 ? uploadName.slice(dot) : "";
|
|
36890
37100
|
target = join52(dir, `${stem}-${suffix}${ext}`);
|
|
36891
37101
|
}
|
|
36892
|
-
const
|
|
37102
|
+
const relative4 = `.daluo/${UPLOADS_SUBDIR}/${basename22(target)}`;
|
|
36893
37103
|
if (!isWithinDir(activeRoot, target)) {
|
|
36894
37104
|
return json(400, { error: "\u4E0A\u4F20\u76EE\u6807\u8D8A\u754C", code: "outside-workspace" }, NOSNIFF);
|
|
36895
37105
|
}
|
|
36896
37106
|
await writeFile7(target, bytes);
|
|
36897
37107
|
const textLike = looksLikeText(bytes);
|
|
36898
37108
|
return json(200, {
|
|
36899
|
-
name:
|
|
36900
|
-
path:
|
|
37109
|
+
name: basename22(target),
|
|
37110
|
+
path: relative4,
|
|
36901
37111
|
bytes: bytes.length,
|
|
36902
37112
|
textLike,
|
|
36903
37113
|
// 如实说清两种结局:非文本落盘了但**模型拿不到内容**(读面只回文本)
|
|
@@ -37666,7 +37876,7 @@ function createDaluoFetch(opts) {
|
|
|
37666
37876
|
const { url } = ctx;
|
|
37667
37877
|
let \u4F1A\u8BDD\u540D;
|
|
37668
37878
|
try {
|
|
37669
|
-
\u4F1A\u8BDD\u540D =
|
|
37879
|
+
\u4F1A\u8BDD\u540D = basename22(resolveSessionFile2(sessionsDirOf2(activeRoot), url.searchParams.get("session") ?? ""));
|
|
37670
37880
|
} catch (error) {
|
|
37671
37881
|
return json(400, { error: error instanceof Error ? error.message : String(error), code: "bad-request" });
|
|
37672
37882
|
}
|
|
@@ -38744,7 +38954,7 @@ data: ${JSON.stringify({ kind: "change", event: e })}
|
|
|
38744
38954
|
const nextFrom = lastSeq !== null && lastSeq < total ? lastSeq + 1 : null;
|
|
38745
38955
|
const prevFrom = firstSeq !== null && firstSeq > 1 ? firstSeq : null;
|
|
38746
38956
|
return json(200, {
|
|
38747
|
-
session:
|
|
38957
|
+
session: basename22(file),
|
|
38748
38958
|
events: window,
|
|
38749
38959
|
firstSeq,
|
|
38750
38960
|
lastSeq,
|
|
@@ -39028,7 +39238,7 @@ data: ${JSON.stringify({ kind: "change", event: e })}
|
|
|
39028
39238
|
newFile: makeNewSessionLogFile(activeRoot, Date.now()),
|
|
39029
39239
|
...req.at === void 0 ? {} : { atSeq: req.at }
|
|
39030
39240
|
});
|
|
39031
|
-
return json(200, { session:
|
|
39241
|
+
return json(200, { session: basename22(forked.file), forkedFrom: req.session, ...req.at === void 0 ? {} : { at: req.at } }, NOSNIFF);
|
|
39032
39242
|
} catch (error) {
|
|
39033
39243
|
if (error instanceof LifecycleUserError) return json(400, { error: error.message, code: "bad-request" });
|
|
39034
39244
|
return json(500, { error: error instanceof Error ? error.message : String(error), code: "internal" });
|
|
@@ -39289,7 +39499,7 @@ data: ${JSON.stringify({ kind: "change", event: e })}
|
|
|
39289
39499
|
headers: {
|
|
39290
39500
|
"content-type": "application/x-ndjson; charset=utf-8",
|
|
39291
39501
|
// 浏览器有了它才会当下载而不是当页面渲染
|
|
39292
|
-
"content-disposition": `attachment; filename="${
|
|
39502
|
+
"content-disposition": `attachment; filename="${basename22(exportFile)}"`,
|
|
39293
39503
|
"content-length": String(\u4F53\u79EF),
|
|
39294
39504
|
// 这两条在**成功**的时候也要有(脚本两端读同一组头,不必分叉)
|
|
39295
39505
|
"x-daluo-bytes": String(\u4F53\u79EF),
|
|
@@ -41231,7 +41441,7 @@ var init_editor = __esm({
|
|
|
41231
41441
|
// packages/cli/src/tui/paste-image.ts
|
|
41232
41442
|
import { execFile as execFile9 } from "node:child_process";
|
|
41233
41443
|
import { mkdir as mkdir10, readFile as readFile19, stat as stat24, writeFile as writeFile8 } from "node:fs/promises";
|
|
41234
|
-
import { extname as extname4, isAbsolute as
|
|
41444
|
+
import { extname as extname4, isAbsolute as isAbsolute14, join as join53, resolve as resolve15 } from "node:path";
|
|
41235
41445
|
import { promisify as promisify8 } from "node:util";
|
|
41236
41446
|
function \u8BA4\u56FE\u7247\u7C7B\u578B(bytes) {
|
|
41237
41447
|
const b = bytes;
|
|
@@ -41316,7 +41526,7 @@ function \u56FE\u7247\u63CF\u8FF0(\u56FE) {
|
|
|
41316
41526
|
async function \u8BA4\u7C98\u8D34\u7684\u56FE\u7247\u8DEF\u5F84(text2) {
|
|
41317
41527
|
const t = text2.trim().replace(/^file:\/\//, "");
|
|
41318
41528
|
if (t === "" || /\s/.test(t)) return void 0;
|
|
41319
|
-
if (!
|
|
41529
|
+
if (!isAbsolute14(t)) return void 0;
|
|
41320
41530
|
const path = resolve15(t);
|
|
41321
41531
|
try {
|
|
41322
41532
|
if (!(await stat24(path)).isFile()) return void 0;
|
|
@@ -41817,7 +42027,7 @@ function mentionAt(text2, col) {
|
|
|
41817
42027
|
if (before && /[A-Za-z0-9_]/.test(before)) return null;
|
|
41818
42028
|
return { start, query: text2.slice(start + 1, at) };
|
|
41819
42029
|
}
|
|
41820
|
-
function
|
|
42030
|
+
function basename23(p) {
|
|
41821
42031
|
const i = p.lastIndexOf("/");
|
|
41822
42032
|
return i < 0 ? p : p.slice(i + 1);
|
|
41823
42033
|
}
|
|
@@ -41828,7 +42038,7 @@ function rankPaths(paths, query, limit) {
|
|
|
41828
42038
|
const lower = p.toLowerCase();
|
|
41829
42039
|
let tier;
|
|
41830
42040
|
if (!q) tier = 0;
|
|
41831
|
-
else if (
|
|
42041
|
+
else if (basename23(lower).startsWith(q)) tier = 0;
|
|
41832
42042
|
else if (lower.startsWith(q)) tier = 1;
|
|
41833
42043
|
else if (lower.includes(q)) tier = 2;
|
|
41834
42044
|
else continue;
|
|
@@ -45379,10 +45589,10 @@ var init_resume2 = __esm({
|
|
|
45379
45589
|
|
|
45380
45590
|
// packages/cli/src/tui/export.ts
|
|
45381
45591
|
import { mkdir as mkdir11, writeFile as writeFile10 } from "node:fs/promises";
|
|
45382
|
-
import { basename as
|
|
45592
|
+
import { basename as basename24, dirname as dirname18, isAbsolute as isAbsolute15, join as join56 } from "node:path";
|
|
45383
45593
|
function \u5BFC\u51FA\u6587\u4EF6\u540D(\u65E5\u5FD7, now) {
|
|
45384
45594
|
const \u65F6\u523B = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
45385
|
-
return `${
|
|
45595
|
+
return `${basename24(\u65E5\u5FD7).replace(/\.jsonl$/, "")}-${\u65F6\u523B}.md`;
|
|
45386
45596
|
}
|
|
45387
45597
|
function \u6709\u5BF9\u8BDD(\u4E8B\u4EF6) {
|
|
45388
45598
|
return \u4E8B\u4EF6.some((e) => e.type === "message/user" || e.type === "message/assistant");
|
|
@@ -45520,7 +45730,7 @@ async function \u843D\u5BFC\u51FA(\u7D20\u67502, \u9009\u9879) {
|
|
|
45520
45730
|
return { ok: false, error: "\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684\u5185\u5BB9\uFF08\u4E00\u53E5\u5BF9\u8BDD\u90FD\u6CA1\u6709\uFF09\u2014\u2014\u5148\u8BF4\u4E00\u53E5\uFF0C\u518D\u6765\u5BFC\u51FA\uFF08\u7A7A\u58F3\u6587\u4EF6\u4E0D\u7B97\u5BFC\u51FA\u6210\u529F\uFF09" };
|
|
45521
45731
|
}
|
|
45522
45732
|
const \u7ED9\u7684 = \u9009\u9879.\u8DEF\u5F84?.trim() ?? "";
|
|
45523
|
-
const \u8DEF\u5F84 = \u7ED9\u7684 === "" ? join56(\u7D20\u67502.cwd, ".daluo", "exports", \u5BFC\u51FA\u6587\u4EF6\u540D(\u7D20\u67502.\u65E5\u5FD7, \u9009\u9879.now)) :
|
|
45733
|
+
const \u8DEF\u5F84 = \u7ED9\u7684 === "" ? join56(\u7D20\u67502.cwd, ".daluo", "exports", \u5BFC\u51FA\u6587\u4EF6\u540D(\u7D20\u67502.\u65E5\u5FD7, \u9009\u9879.now)) : isAbsolute15(\u7ED9\u7684) ? \u7ED9\u7684 : join56(\u7D20\u67502.cwd, \u7ED9\u7684);
|
|
45524
45734
|
const \u6587\u672C = \u8F6C\u5199\u4F1A\u8BDD(\u7D20\u67502, \u9009\u9879.now);
|
|
45525
45735
|
const r = await \u5199(\u8DEF\u5F84, \u6587\u672C);
|
|
45526
45736
|
if (!r.ok) return { ok: false, error: r.error };
|
|
@@ -46484,12 +46694,15 @@ async function tuiChat(argv) {
|
|
|
46484
46694
|
const { unmount } = render(
|
|
46485
46695
|
createTuiApp({
|
|
46486
46696
|
meta: { model: \u4F1A\u8BDD\u9009\u62E9, plan: s.planMode, compact: s.compact, version: cliVersion() },
|
|
46487
|
-
//
|
|
46488
|
-
// ①
|
|
46489
|
-
//
|
|
46697
|
+
// 起手要说出口的话(三条,判据都是「**你写的东西没生效**」):
|
|
46698
|
+
// ① 设置**写错层级**(`spec/settings.md` 演进「顶层错位」):写在顶层的 permission.rules
|
|
46699
|
+
// 文件在、规则一条不生效,症状(配了却被拒)离原因隔着整条策略链——比②更彻底,故排第一;
|
|
46700
|
+
// ② 项目级设置里被忽略的键(`spec/settings.md` 作用域缺口段前置②)——不静默;
|
|
46701
|
+
// ③ 被别的规则整个覆盖的权限规则(`P1-08`)——「你写的这条 allow 永远不会生效」,
|
|
46490
46702
|
// 此前屏上任何地方都不说(用户以为写好了、实际还在被问)。只报**完全遮蔽**那条:
|
|
46491
46703
|
// 部分遮蔽是「这个工具没全免问」,进面板看得到就行,不该每次启动都拦一句。
|
|
46492
46704
|
bootNotices: [
|
|
46705
|
+
\u9876\u5C42\u9519\u4F4D\u63D0\u793A(loadSettingsSync2(settingsFile)),
|
|
46493
46706
|
\u9879\u76EE\u7EA7\u5FFD\u7565\u63D0\u793A(s.projectSettings.\u88AB\u5FFD\u7565),
|
|
46494
46707
|
\u906E\u853D\u63D0\u793A(s.permissionShadows())
|
|
46495
46708
|
].filter((x) => x !== void 0),
|
|
@@ -46618,6 +46831,9 @@ var HOST_RETRYABLE = {
|
|
|
46618
46831
|
// 模型吐坏 JSON:重新采样(同一 prompt 再跑一次)大概率正常 ⇒ 与 network/timeout 同侧。
|
|
46619
46832
|
// 注意它**不是** `unknown`:unknown 保守取 false(不知道就不敢自动重试),这条是知道该怎么办。
|
|
46620
46833
|
"model-output": true,
|
|
46834
|
+
// 输出被截断(finish_reason=length):换个时刻重跑**同样配置**会在同一个位置再断一次
|
|
46835
|
+
// —— 要改的是输出上限(maxTokens)或让它分段,不是重试。所以与 model-output 相反。
|
|
46836
|
+
truncated: false,
|
|
46621
46837
|
auth: false
|
|
46622
46838
|
};
|
|
46623
46839
|
function zodIssuesToUserMessage(error) {
|
|
@@ -46700,6 +46916,15 @@ function classifyKind(error) {
|
|
|
46700
46916
|
hint: "\u8BF7\u6C42\u8D85\u65F6\uFF0C\u53EF\u91CD\u8BD5\u3002\u82E5\u6301\u7EED\u8D85\u65F6\uFF0C\u68C0\u67E5\u7F51\u7EDC\u5230 DALUO_LLM_BASE_URL \u7684\u8FDE\u901A\u6027\u3002"
|
|
46701
46917
|
};
|
|
46702
46918
|
}
|
|
46919
|
+
if (\u5224\u51B3?.category === "truncated") {
|
|
46920
|
+
const \u5DE5\u5177 = error instanceof LlmToolArgsError && error.toolName !== void 0 ? `\uFF08\u5DE5\u5177 ${error.toolName} \u7684\u53C2\u6570\u4E0D\u5B8C\u6574\uFF09` : "";
|
|
46921
|
+
return {
|
|
46922
|
+
kind: "truncated",
|
|
46923
|
+
exitCode: EXIT.error,
|
|
46924
|
+
message: `\u6A21\u578B\u8F93\u51FA\u88AB max_tokens \u622A\u65AD${\u5DE5\u5177}`,
|
|
46925
|
+
hint: "\u8F93\u51FA\u5230\u4E0A\u9650\u5C31\u65AD\u4E86\uFF1A\u8C03\u5927\u8F93\u51FA\u4E0A\u9650\uFF08\u8BBE\u7F6E llm.maxTokens \u6216 DALUO_LLM_MAX_TOKENS\uFF09\uFF0C\u6216\u8BA9\u5B83\u5206\u6BB5\u8F93\u51FA\uFF1B\u540C\u914D\u7F6E\u91CD\u8DD1\u5927\u6982\u7387\u8FD8\u4F1A\u5728\u540C\u4E00\u4E2A\u4F4D\u7F6E\u622A\u65AD\u3002"
|
|
46926
|
+
};
|
|
46927
|
+
}
|
|
46703
46928
|
if (error instanceof LlmToolArgsError) {
|
|
46704
46929
|
return {
|
|
46705
46930
|
kind: "model-output",
|
|
@@ -47049,6 +47274,8 @@ async function main() {
|
|
|
47049
47274
|
if (resumeLog && !existsSync26(resumeLog)) {
|
|
47050
47275
|
throw new Error(`daluo run: --resume \u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${resumeLog}`);
|
|
47051
47276
|
}
|
|
47277
|
+
\u8BBE\u7F6E\u9519\u4F4D\u51FA\u58F0((line) => process.stderr.write(`${line}
|
|
47278
|
+
`));
|
|
47052
47279
|
const s = await setupSession({
|
|
47053
47280
|
cwd: process.cwd(),
|
|
47054
47281
|
sessionId: `s-${Date.now()}`,
|