@clawos-dev/clawd 0.2.42 → 0.2.43-beta.64.8ecc6a7
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 +36 -69
- 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",
|
|
@@ -8658,7 +8655,7 @@ var init_persona_schemas = __esm({
|
|
|
8658
8655
|
});
|
|
8659
8656
|
|
|
8660
8657
|
// ../protocol/src/schemas.ts
|
|
8661
|
-
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;
|
|
8662
8659
|
var init_schemas = __esm({
|
|
8663
8660
|
"../protocol/src/schemas.ts"() {
|
|
8664
8661
|
"use strict";
|
|
@@ -9180,11 +9177,6 @@ var init_schemas = __esm({
|
|
|
9180
9177
|
answers: external_exports.record(external_exports.string(), external_exports.string())
|
|
9181
9178
|
});
|
|
9182
9179
|
AnswerQuestionResponseSchema = external_exports.object({ ok: external_exports.literal(true) });
|
|
9183
|
-
CancelQuestionArgs = external_exports.object({
|
|
9184
|
-
sessionId: external_exports.string().min(1),
|
|
9185
|
-
toolUseId: external_exports.string().min(1)
|
|
9186
|
-
});
|
|
9187
|
-
CancelQuestionResponseSchema = external_exports.object({ ok: external_exports.literal(true) });
|
|
9188
9180
|
AuthRequestFrameSchema = external_exports.object({
|
|
9189
9181
|
type: external_exports.literal("auth"),
|
|
9190
9182
|
token: external_exports.string().min(1),
|
|
@@ -16196,31 +16188,6 @@ function reduceSession(state, input, deps) {
|
|
|
16196
16188
|
]
|
|
16197
16189
|
};
|
|
16198
16190
|
}
|
|
16199
|
-
case "cancel-question": {
|
|
16200
|
-
const pending = state.pendingQuestions?.[input.toolUseId];
|
|
16201
|
-
if (!pending) {
|
|
16202
|
-
return { state, effects: [] };
|
|
16203
|
-
}
|
|
16204
|
-
const next = cloneState(state);
|
|
16205
|
-
const nextPending = { ...next.pendingQuestions };
|
|
16206
|
-
delete nextPending[input.toolUseId];
|
|
16207
|
-
next.pendingQuestions = nextPending;
|
|
16208
|
-
const sessionId = next.file.sessionId;
|
|
16209
|
-
return {
|
|
16210
|
-
state: next,
|
|
16211
|
-
effects: [
|
|
16212
|
-
// cleared(no answers) broadcast:UI dispatch session:question:clear → 卡片转 Ended。
|
|
16213
|
-
{
|
|
16214
|
-
kind: "emit-frame",
|
|
16215
|
-
frame: {
|
|
16216
|
-
type: "session:question:cleared",
|
|
16217
|
-
sessionId,
|
|
16218
|
-
toolUseId: input.toolUseId
|
|
16219
|
-
}
|
|
16220
|
-
}
|
|
16221
|
-
]
|
|
16222
|
-
};
|
|
16223
|
-
}
|
|
16224
16191
|
case "idle-kill-fired": {
|
|
16225
16192
|
if (state.status !== "running-idle") {
|
|
16226
16193
|
return { state, effects: [] };
|
|
@@ -16317,6 +16284,30 @@ function startRecorder(opts) {
|
|
|
16317
16284
|
};
|
|
16318
16285
|
}
|
|
16319
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
|
+
|
|
16320
16311
|
// src/session/runner.ts
|
|
16321
16312
|
var DEFAULT_CONTROL_REQUEST_TIMEOUT_MS = 1e4;
|
|
16322
16313
|
function encodeAllowWithInputControlResponse(requestId, updatedInput) {
|
|
@@ -16357,9 +16348,14 @@ var SessionRunner = class {
|
|
|
16357
16348
|
}
|
|
16358
16349
|
// 外部推送 input 到 reducer,然后执行产出的 effects
|
|
16359
16350
|
input(inputMsg) {
|
|
16351
|
+
const personaStore = this.hooks.personaStore;
|
|
16360
16352
|
const deps = {
|
|
16361
16353
|
parseLine: (l) => this.hooks.adapter.parseLine(l),
|
|
16362
|
-
|
|
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
|
+
},
|
|
16363
16359
|
bufferCap: this.hooks.bufferCap ?? 500,
|
|
16364
16360
|
now: this.hooks.now ?? Date.now,
|
|
16365
16361
|
resolveContextWindow: this.hooks.resolveContextWindow,
|
|
@@ -16758,7 +16754,8 @@ var SessionManager = class {
|
|
|
16758
16754
|
bufferCap: this.deps.bufferCap,
|
|
16759
16755
|
// adapter 自己持有模型表 + 兜底逻辑(contains / opus-1M / [1m] 等),manager 不再 cache 转发
|
|
16760
16756
|
resolveContextWindow: (tool, modelId) => this.deps.getAdapter(tool).resolveContextWindow(modelId),
|
|
16761
|
-
dataDir: this.deps.dataDir
|
|
16757
|
+
dataDir: this.deps.dataDir,
|
|
16758
|
+
personaStore: this.deps.personaStore
|
|
16762
16759
|
});
|
|
16763
16760
|
return runner;
|
|
16764
16761
|
}
|
|
@@ -17494,31 +17491,6 @@ var SessionManager = class {
|
|
|
17494
17491
|
});
|
|
17495
17492
|
return { response: { ok: true }, broadcast };
|
|
17496
17493
|
}
|
|
17497
|
-
// AskUserQuestion 用户跳过:与官方 CC CLI Esc 行为对齐——**不向 CC 发 tool 结果**,而是发
|
|
17498
|
-
// control_request.subtype='interrupt'(与 session:interrupt 同一条路径)中断整个 turn,
|
|
17499
|
-
// tool call 在 CC 端不返回任何 result。Reducer 同步清 pendingQuestions[toolUseId] + 发
|
|
17500
|
-
// cleared 帧(answers 缺省)让 UI 转 Ended 只读态。
|
|
17501
|
-
//
|
|
17502
|
-
// - session 不存在 / 无 runner / procAlive=false → noop 幂等返回(与 answerQuestion 同语义)
|
|
17503
|
-
// - sendControlRequest 失败(CC 退出 / 超时)→ 不抛:cleared 帧已发,UI 状态已收敛
|
|
17504
|
-
async cancelQuestion(args) {
|
|
17505
|
-
const runner = this.runners.get(args.sessionId);
|
|
17506
|
-
if (!runner) {
|
|
17507
|
-
return { response: { ok: true }, broadcast: [] };
|
|
17508
|
-
}
|
|
17509
|
-
const hit = Boolean(runner.getState().pendingQuestions?.[args.toolUseId]);
|
|
17510
|
-
if (!hit) {
|
|
17511
|
-
return { response: { ok: true }, broadcast: [] };
|
|
17512
|
-
}
|
|
17513
|
-
const { broadcast } = this.withCollector(() => {
|
|
17514
|
-
runner.input({ kind: "cancel-question", toolUseId: args.toolUseId });
|
|
17515
|
-
});
|
|
17516
|
-
if (runner.getState().procAlive) {
|
|
17517
|
-
void runner.sendControlRequest("interrupt").catch(() => {
|
|
17518
|
-
});
|
|
17519
|
-
}
|
|
17520
|
-
return { response: { ok: true }, broadcast };
|
|
17521
|
-
}
|
|
17522
17494
|
// 权限决定:dispatcher 收到 permission:respond 时调用
|
|
17523
17495
|
// 先查 state.pendingPermissions:不存在 → 抛 PERMISSION_REQUEST_STALE
|
|
17524
17496
|
respondPermission(args) {
|
|
@@ -19918,11 +19890,6 @@ function buildSessionHandlers(deps) {
|
|
|
19918
19890
|
const { response, broadcast } = manager.answerQuestion(args);
|
|
19919
19891
|
return { response: { type: "session:answerQuestion", ...response }, broadcast };
|
|
19920
19892
|
};
|
|
19921
|
-
const cancelQuestion = async (frame) => {
|
|
19922
|
-
const args = CancelQuestionArgs.parse(frame);
|
|
19923
|
-
const { response, broadcast } = await manager.cancelQuestion(args);
|
|
19924
|
-
return { response: { type: "session:cancelQuestion", ...response }, broadcast };
|
|
19925
|
-
};
|
|
19926
19893
|
return {
|
|
19927
19894
|
"session:create": create,
|
|
19928
19895
|
"session:list": list,
|
|
@@ -19944,8 +19911,7 @@ function buildSessionHandlers(deps) {
|
|
|
19944
19911
|
"session:unsubscribe": unsubscribe,
|
|
19945
19912
|
"session:pin": pin,
|
|
19946
19913
|
"session:reorderPins": reorderPins,
|
|
19947
|
-
"session:answerQuestion": answerQuestion
|
|
19948
|
-
"session:cancelQuestion": cancelQuestion
|
|
19914
|
+
"session:answerQuestion": answerQuestion
|
|
19949
19915
|
};
|
|
19950
19916
|
}
|
|
19951
19917
|
|
|
@@ -20556,6 +20522,7 @@ async function startDaemon(config) {
|
|
|
20556
20522
|
const agents = new AgentsScanner();
|
|
20557
20523
|
const history = new ClaudeHistoryReader();
|
|
20558
20524
|
let transport = null;
|
|
20525
|
+
const personaStore = new PersonaStore(import_node_path19.default.join(config.dataDir, "personas"));
|
|
20559
20526
|
const manager = new SessionManager({
|
|
20560
20527
|
store,
|
|
20561
20528
|
logger,
|
|
@@ -20563,6 +20530,7 @@ async function startDaemon(config) {
|
|
|
20563
20530
|
historyReader: history,
|
|
20564
20531
|
dataDir: config.dataDir,
|
|
20565
20532
|
personaRoot: import_node_path19.default.join(config.dataDir, "personas"),
|
|
20533
|
+
personaStore,
|
|
20566
20534
|
broadcastFrame: (frame, target) => {
|
|
20567
20535
|
if (target === "all") {
|
|
20568
20536
|
transport?.broadcastAll(frame);
|
|
@@ -20602,7 +20570,6 @@ async function startDaemon(config) {
|
|
|
20602
20570
|
manager.recordRealUserUuid({ sessionId, realUuid, text });
|
|
20603
20571
|
}
|
|
20604
20572
|
});
|
|
20605
|
-
const personaStore = new PersonaStore(import_node_path19.default.join(config.dataDir, "personas"));
|
|
20606
20573
|
const personaRegistry = new PersonaRegistry(personaStore);
|
|
20607
20574
|
const personaManager = new PersonaManager({
|
|
20608
20575
|
store: personaStore,
|
package/package.json
CHANGED