@clawos-dev/clawd 0.2.42-beta.62.2e07b2e → 0.2.43-beta.63.2e72abd
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/cli.cjs +50 -74
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -4375,9 +4375,6 @@ var init_methods = __esm({
|
|
|
4375
4375
|
// AskUserQuestion 表单回写:UI 答完所有 question 后调用,daemon 把答案合并进 updated_input
|
|
4376
4376
|
// 写一条 control_response 到 CC stdin(详见 events.ts session:question JSDoc)
|
|
4377
4377
|
"session:answerQuestion",
|
|
4378
|
-
// AskUserQuestion 用户跳过:daemon 向 CC 回 allow + answers={} 让 tool 走空答案路径,
|
|
4379
|
-
// 同时广播 cleared 帧(无 answers)让所有客户端 UI 卡片转 Ended
|
|
4380
|
-
"session:cancelQuestion",
|
|
4381
4378
|
"history:projects",
|
|
4382
4379
|
"history:list",
|
|
4383
4380
|
"history:read",
|
|
@@ -8595,7 +8592,7 @@ var init_zod = __esm({
|
|
|
8595
8592
|
});
|
|
8596
8593
|
|
|
8597
8594
|
// ../protocol/src/persona-schemas.ts
|
|
8598
|
-
var PersonaTokenEntrySchema, PersonaFileSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema, PersonaIssueTokenArgsSchema, PersonaRevokeTokenArgsSchema, PersonaAppendOwnerMessageArgsSchema;
|
|
8595
|
+
var PersonaTokenEntrySchema, PersonaFileSchema, PersonaInfoResponseSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema, PersonaIssueTokenArgsSchema, PersonaRevokeTokenArgsSchema, PersonaAppendOwnerMessageArgsSchema;
|
|
8599
8596
|
var init_persona_schemas = __esm({
|
|
8600
8597
|
"../protocol/src/persona-schemas.ts"() {
|
|
8601
8598
|
"use strict";
|
|
@@ -8617,6 +8614,9 @@ var init_persona_schemas = __esm({
|
|
|
8617
8614
|
createdAt: external_exports.number(),
|
|
8618
8615
|
updatedAt: external_exports.number()
|
|
8619
8616
|
}).strict();
|
|
8617
|
+
PersonaInfoResponseSchema = PersonaFileSchema.extend({
|
|
8618
|
+
personality: external_exports.string().optional()
|
|
8619
|
+
});
|
|
8620
8620
|
PersonaCreateArgsSchema = external_exports.object({
|
|
8621
8621
|
label: external_exports.string().min(1),
|
|
8622
8622
|
personality: external_exports.string(),
|
|
@@ -8655,7 +8655,7 @@ var init_persona_schemas = __esm({
|
|
|
8655
8655
|
});
|
|
8656
8656
|
|
|
8657
8657
|
// ../protocol/src/schemas.ts
|
|
8658
|
-
var SessionStatusSchema, UsageSchema, ContextUsageSchema, sessionMetaShape, SessionMetaSchema, ModelInfoSchema, ModeInfoSchema, ConfigFieldSchemaSchema, CapabilitiesGetArgs, CapabilitiesResponseSchema, AllowRuleSchema, SessionFileSchema, ParsedEventBase, HistoryUserMetaSchema, SubagentToolStatsSchema, StructuredPatchHunkSchema, ToolResultExtraSchema, MemoryEntrySchema, AskQuestionOptionSchema, AskQuestionItemSchema, ParsedEventSchema, SessionCreateArgs, SessionIdArgs, SessionUpdateArgs, SessionSendArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsArgs, SessionRewindableMessageIdsResponseSchema, SessionResumeArgs, SessionForkArgs, SessionForkResponseSchema, SessionObserveArgs, SessionEventsArgs, PermissionRespondArgs, HistoryListArgs, HistoryReadArgs, HistorySubagentsArgs, HistorySubagentReadArgs, WorkspaceListArgs, WorkspaceReadArgs, SkillsListArgs, SkillEntrySchema, AgentEntrySchema, AgentsListArgs, AgentsListResponseSchema, SessionSubscribeArgs, SessionPinArgs, SessionReorderPinsArgs, GitRootArgs, GitRootResponseSchema, GitBranchArgs, GitBranchResponseSchema, GitBranchesArgs, GitBranchesResponseSchema, GitWorktreePrefixArgs, GitWorktreePrefixResponseSchema, GitWorktreeCreateArgs, GitWorktreeCreateResponseSchema, GitWorktreeRemoveArgs, GitWorktreeRemoveResponseSchema, HistoryRecentDirsArgs, RecentDirEntrySchema, HistoryRecentDirsResponseSchema, SessionQuestionFrameSchema, SessionQuestionClearedFrameSchema, AnswerQuestionArgs, AnswerQuestionResponseSchema,
|
|
8658
|
+
var SessionStatusSchema, UsageSchema, ContextUsageSchema, sessionMetaShape, SessionMetaSchema, ModelInfoSchema, ModeInfoSchema, ConfigFieldSchemaSchema, CapabilitiesGetArgs, CapabilitiesResponseSchema, AllowRuleSchema, SessionFileSchema, ParsedEventBase, HistoryUserMetaSchema, SubagentToolStatsSchema, StructuredPatchHunkSchema, ToolResultExtraSchema, MemoryEntrySchema, AskQuestionOptionSchema, AskQuestionItemSchema, ParsedEventSchema, SessionCreateArgs, SessionIdArgs, SessionUpdateArgs, SessionSendArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsArgs, SessionRewindableMessageIdsResponseSchema, SessionResumeArgs, SessionForkArgs, SessionForkResponseSchema, SessionObserveArgs, SessionEventsArgs, PermissionRespondArgs, HistoryListArgs, HistoryReadArgs, HistorySubagentsArgs, HistorySubagentReadArgs, WorkspaceListArgs, WorkspaceReadArgs, SkillsListArgs, SkillEntrySchema, AgentEntrySchema, AgentsListArgs, AgentsListResponseSchema, SessionSubscribeArgs, SessionPinArgs, SessionReorderPinsArgs, GitRootArgs, GitRootResponseSchema, GitBranchArgs, GitBranchResponseSchema, GitBranchesArgs, GitBranchesResponseSchema, GitWorktreePrefixArgs, GitWorktreePrefixResponseSchema, GitWorktreeCreateArgs, GitWorktreeCreateResponseSchema, GitWorktreeRemoveArgs, GitWorktreeRemoveResponseSchema, HistoryRecentDirsArgs, RecentDirEntrySchema, HistoryRecentDirsResponseSchema, SessionQuestionFrameSchema, SessionQuestionClearedFrameSchema, AnswerQuestionArgs, AnswerQuestionResponseSchema, AuthRequestFrameSchema, AuthOkFrameSchema, TunnelExitedEventSchema, InfoRunningSessionSchema, InfoResponseSchema;
|
|
8659
8659
|
var init_schemas = __esm({
|
|
8660
8660
|
"../protocol/src/schemas.ts"() {
|
|
8661
8661
|
"use strict";
|
|
@@ -9177,11 +9177,6 @@ var init_schemas = __esm({
|
|
|
9177
9177
|
answers: external_exports.record(external_exports.string(), external_exports.string())
|
|
9178
9178
|
});
|
|
9179
9179
|
AnswerQuestionResponseSchema = external_exports.object({ ok: external_exports.literal(true) });
|
|
9180
|
-
CancelQuestionArgs = external_exports.object({
|
|
9181
|
-
sessionId: external_exports.string().min(1),
|
|
9182
|
-
toolUseId: external_exports.string().min(1)
|
|
9183
|
-
});
|
|
9184
|
-
CancelQuestionResponseSchema = external_exports.object({ ok: external_exports.literal(true) });
|
|
9185
9180
|
AuthRequestFrameSchema = external_exports.object({
|
|
9186
9181
|
type: external_exports.literal("auth"),
|
|
9187
9182
|
token: external_exports.string().min(1),
|
|
@@ -16193,31 +16188,6 @@ function reduceSession(state, input, deps) {
|
|
|
16193
16188
|
]
|
|
16194
16189
|
};
|
|
16195
16190
|
}
|
|
16196
|
-
case "cancel-question": {
|
|
16197
|
-
const pending = state.pendingQuestions?.[input.toolUseId];
|
|
16198
|
-
if (!pending) {
|
|
16199
|
-
return { state, effects: [] };
|
|
16200
|
-
}
|
|
16201
|
-
const next = cloneState(state);
|
|
16202
|
-
const nextPending = { ...next.pendingQuestions };
|
|
16203
|
-
delete nextPending[input.toolUseId];
|
|
16204
|
-
next.pendingQuestions = nextPending;
|
|
16205
|
-
const sessionId = next.file.sessionId;
|
|
16206
|
-
return {
|
|
16207
|
-
state: next,
|
|
16208
|
-
effects: [
|
|
16209
|
-
// cleared(no answers) broadcast:UI dispatch session:question:clear → 卡片转 Ended。
|
|
16210
|
-
{
|
|
16211
|
-
kind: "emit-frame",
|
|
16212
|
-
frame: {
|
|
16213
|
-
type: "session:question:cleared",
|
|
16214
|
-
sessionId,
|
|
16215
|
-
toolUseId: input.toolUseId
|
|
16216
|
-
}
|
|
16217
|
-
}
|
|
16218
|
-
]
|
|
16219
|
-
};
|
|
16220
|
-
}
|
|
16221
16191
|
case "idle-kill-fired": {
|
|
16222
16192
|
if (state.status !== "running-idle") {
|
|
16223
16193
|
return { state, effects: [] };
|
|
@@ -16314,6 +16284,30 @@ function startRecorder(opts) {
|
|
|
16314
16284
|
};
|
|
16315
16285
|
}
|
|
16316
16286
|
|
|
16287
|
+
// src/persona/mention-injection.ts
|
|
16288
|
+
var MENTION_RE = /@persona\/([A-Za-z0-9_-]+)(?=\s|$|[^A-Za-z0-9_-])/g;
|
|
16289
|
+
function injectPersonaMentions(rawText, store) {
|
|
16290
|
+
const resolved = [];
|
|
16291
|
+
const body = rawText.replace(MENTION_RE, (match, id) => {
|
|
16292
|
+
const meta = store.read(id);
|
|
16293
|
+
const personality = store.readPersonality(id);
|
|
16294
|
+
if (meta && personality !== null) {
|
|
16295
|
+
resolved.push({ id, label: meta.label, personality });
|
|
16296
|
+
return "";
|
|
16297
|
+
}
|
|
16298
|
+
return match;
|
|
16299
|
+
});
|
|
16300
|
+
if (resolved.length === 0) return rawText;
|
|
16301
|
+
const blocks = resolved.map(
|
|
16302
|
+
(r) => `[Acting as persona "${r.label}" for this message]
|
|
16303
|
+
${r.personality}`
|
|
16304
|
+
);
|
|
16305
|
+
return `${blocks.join("\n\n")}
|
|
16306
|
+
|
|
16307
|
+
[User says]:
|
|
16308
|
+
${body.trim()}`;
|
|
16309
|
+
}
|
|
16310
|
+
|
|
16317
16311
|
// src/session/runner.ts
|
|
16318
16312
|
var DEFAULT_CONTROL_REQUEST_TIMEOUT_MS = 1e4;
|
|
16319
16313
|
function encodeAllowWithInputControlResponse(requestId, updatedInput) {
|
|
@@ -16354,9 +16348,14 @@ var SessionRunner = class {
|
|
|
16354
16348
|
}
|
|
16355
16349
|
// 外部推送 input 到 reducer,然后执行产出的 effects
|
|
16356
16350
|
input(inputMsg) {
|
|
16351
|
+
const personaStore = this.hooks.personaStore;
|
|
16357
16352
|
const deps = {
|
|
16358
16353
|
parseLine: (l) => this.hooks.adapter.parseLine(l),
|
|
16359
|
-
|
|
16354
|
+
// persona mention injection 在 deps 装配处包一层,对 reducer 完全透明
|
|
16355
|
+
encodeStdin: (t, ctx) => {
|
|
16356
|
+
const injected = personaStore ? injectPersonaMentions(t, personaStore) : t;
|
|
16357
|
+
return this.hooks.adapter.encodeStdin(injected, ctx) ?? "";
|
|
16358
|
+
},
|
|
16360
16359
|
bufferCap: this.hooks.bufferCap ?? 500,
|
|
16361
16360
|
now: this.hooks.now ?? Date.now,
|
|
16362
16361
|
resolveContextWindow: this.hooks.resolveContextWindow,
|
|
@@ -16755,7 +16754,8 @@ var SessionManager = class {
|
|
|
16755
16754
|
bufferCap: this.deps.bufferCap,
|
|
16756
16755
|
// adapter 自己持有模型表 + 兜底逻辑(contains / opus-1M / [1m] 等),manager 不再 cache 转发
|
|
16757
16756
|
resolveContextWindow: (tool, modelId) => this.deps.getAdapter(tool).resolveContextWindow(modelId),
|
|
16758
|
-
dataDir: this.deps.dataDir
|
|
16757
|
+
dataDir: this.deps.dataDir,
|
|
16758
|
+
personaStore: this.deps.personaStore
|
|
16759
16759
|
});
|
|
16760
16760
|
return runner;
|
|
16761
16761
|
}
|
|
@@ -17491,31 +17491,6 @@ var SessionManager = class {
|
|
|
17491
17491
|
});
|
|
17492
17492
|
return { response: { ok: true }, broadcast };
|
|
17493
17493
|
}
|
|
17494
|
-
// AskUserQuestion 用户跳过:与官方 CC CLI Esc 行为对齐——**不向 CC 发 tool 结果**,而是发
|
|
17495
|
-
// control_request.subtype='interrupt'(与 session:interrupt 同一条路径)中断整个 turn,
|
|
17496
|
-
// tool call 在 CC 端不返回任何 result。Reducer 同步清 pendingQuestions[toolUseId] + 发
|
|
17497
|
-
// cleared 帧(answers 缺省)让 UI 转 Ended 只读态。
|
|
17498
|
-
//
|
|
17499
|
-
// - session 不存在 / 无 runner / procAlive=false → noop 幂等返回(与 answerQuestion 同语义)
|
|
17500
|
-
// - sendControlRequest 失败(CC 退出 / 超时)→ 不抛:cleared 帧已发,UI 状态已收敛
|
|
17501
|
-
async cancelQuestion(args) {
|
|
17502
|
-
const runner = this.runners.get(args.sessionId);
|
|
17503
|
-
if (!runner) {
|
|
17504
|
-
return { response: { ok: true }, broadcast: [] };
|
|
17505
|
-
}
|
|
17506
|
-
const hit = Boolean(runner.getState().pendingQuestions?.[args.toolUseId]);
|
|
17507
|
-
if (!hit) {
|
|
17508
|
-
return { response: { ok: true }, broadcast: [] };
|
|
17509
|
-
}
|
|
17510
|
-
const { broadcast } = this.withCollector(() => {
|
|
17511
|
-
runner.input({ kind: "cancel-question", toolUseId: args.toolUseId });
|
|
17512
|
-
});
|
|
17513
|
-
if (runner.getState().procAlive) {
|
|
17514
|
-
void runner.sendControlRequest("interrupt").catch(() => {
|
|
17515
|
-
});
|
|
17516
|
-
}
|
|
17517
|
-
return { response: { ok: true }, broadcast };
|
|
17518
|
-
}
|
|
17519
17494
|
// 权限决定:dispatcher 收到 permission:respond 时调用
|
|
17520
17495
|
// 先查 state.pendingPermissions:不存在 → 抛 PERMISSION_REQUEST_STALE
|
|
17521
17496
|
respondPermission(args) {
|
|
@@ -17713,13 +17688,16 @@ var PersonaManager = class {
|
|
|
17713
17688
|
updated.iconKey = iconKeyPatch;
|
|
17714
17689
|
}
|
|
17715
17690
|
if (personality !== void 0) {
|
|
17716
|
-
this.deps.store.
|
|
17717
|
-
} else {
|
|
17718
|
-
this.deps.store.writeMeta(updated);
|
|
17691
|
+
this.deps.store.writePersonality(personaId, personality);
|
|
17719
17692
|
}
|
|
17693
|
+
this.deps.store.writeMeta(updated);
|
|
17720
17694
|
this.deps.registry.set(updated);
|
|
17721
17695
|
return updated;
|
|
17722
17696
|
}
|
|
17697
|
+
/** 读取 CLAUDE.md 内容;persona 目录或文件不存在时返回 null。透传给 handler 拼响应。 */
|
|
17698
|
+
readPersonality(personaId) {
|
|
17699
|
+
return this.deps.store.readPersonality(personaId);
|
|
17700
|
+
}
|
|
17723
17701
|
/**
|
|
17724
17702
|
* 删除 persona。
|
|
17725
17703
|
* PersonaStore.remove(personaId) 已级联删除整个 <personaRoot>/<personaId>/ 目录,
|
|
@@ -19912,11 +19890,6 @@ function buildSessionHandlers(deps) {
|
|
|
19912
19890
|
const { response, broadcast } = manager.answerQuestion(args);
|
|
19913
19891
|
return { response: { type: "session:answerQuestion", ...response }, broadcast };
|
|
19914
19892
|
};
|
|
19915
|
-
const cancelQuestion = async (frame) => {
|
|
19916
|
-
const args = CancelQuestionArgs.parse(frame);
|
|
19917
|
-
const { response, broadcast } = await manager.cancelQuestion(args);
|
|
19918
|
-
return { response: { type: "session:cancelQuestion", ...response }, broadcast };
|
|
19919
|
-
};
|
|
19920
19893
|
return {
|
|
19921
19894
|
"session:create": create,
|
|
19922
19895
|
"session:list": list,
|
|
@@ -19938,8 +19911,7 @@ function buildSessionHandlers(deps) {
|
|
|
19938
19911
|
"session:unsubscribe": unsubscribe,
|
|
19939
19912
|
"session:pin": pin,
|
|
19940
19913
|
"session:reorderPins": reorderPins,
|
|
19941
|
-
"session:answerQuestion": answerQuestion
|
|
19942
|
-
"session:cancelQuestion": cancelQuestion
|
|
19914
|
+
"session:answerQuestion": answerQuestion
|
|
19943
19915
|
};
|
|
19944
19916
|
}
|
|
19945
19917
|
|
|
@@ -20434,7 +20406,10 @@ function buildPersonaHandlers(deps) {
|
|
|
20434
20406
|
if (!persona) {
|
|
20435
20407
|
return { response: { type: "persona:info", persona: null } };
|
|
20436
20408
|
}
|
|
20437
|
-
|
|
20409
|
+
const personality = personaManager.readPersonality(args.personaId) ?? "";
|
|
20410
|
+
return {
|
|
20411
|
+
response: { type: "persona:info", ...persona, personality }
|
|
20412
|
+
};
|
|
20438
20413
|
};
|
|
20439
20414
|
const update = async (frame) => {
|
|
20440
20415
|
const { type: _type, requestId: _requestId, ...rest } = frame;
|
|
@@ -20547,6 +20522,7 @@ async function startDaemon(config) {
|
|
|
20547
20522
|
const agents = new AgentsScanner();
|
|
20548
20523
|
const history = new ClaudeHistoryReader();
|
|
20549
20524
|
let transport = null;
|
|
20525
|
+
const personaStore = new PersonaStore(import_node_path19.default.join(config.dataDir, "personas"));
|
|
20550
20526
|
const manager = new SessionManager({
|
|
20551
20527
|
store,
|
|
20552
20528
|
logger,
|
|
@@ -20554,6 +20530,7 @@ async function startDaemon(config) {
|
|
|
20554
20530
|
historyReader: history,
|
|
20555
20531
|
dataDir: config.dataDir,
|
|
20556
20532
|
personaRoot: import_node_path19.default.join(config.dataDir, "personas"),
|
|
20533
|
+
personaStore,
|
|
20557
20534
|
broadcastFrame: (frame, target) => {
|
|
20558
20535
|
if (target === "all") {
|
|
20559
20536
|
transport?.broadcastAll(frame);
|
|
@@ -20593,7 +20570,6 @@ async function startDaemon(config) {
|
|
|
20593
20570
|
manager.recordRealUserUuid({ sessionId, realUuid, text });
|
|
20594
20571
|
}
|
|
20595
20572
|
});
|
|
20596
|
-
const personaStore = new PersonaStore(import_node_path19.default.join(config.dataDir, "personas"));
|
|
20597
20573
|
const personaRegistry = new PersonaRegistry(personaStore);
|
|
20598
20574
|
const personaManager = new PersonaManager({
|
|
20599
20575
|
store: personaStore,
|
package/package.json
CHANGED