@clawos-dev/clawd 0.2.43 → 0.2.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.cjs +29 -14
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -16325,20 +16325,25 @@ function injectPersonaMentions(rawText, store) {
16325
16325
  const meta = store.read(id);
16326
16326
  const personality = store.readPersonality(id);
16327
16327
  if (meta && personality !== null) {
16328
- resolved.push({ id, label: meta.label, personality });
16328
+ resolved.push({ label: meta.label, personality });
16329
16329
  return "";
16330
16330
  }
16331
16331
  return match;
16332
16332
  });
16333
- if (resolved.length === 0) return rawText;
16334
- const blocks = resolved.map(
16335
- (r) => `[Acting as persona "${r.label}" for this message]
16336
- ${r.personality}`
16337
- );
16338
- return `${blocks.join("\n\n")}
16339
-
16340
- [User says]:
16341
- ${body.trim()}`;
16333
+ if (resolved.length === 0) {
16334
+ return { systemReminder: null, userText: rawText };
16335
+ }
16336
+ const blocks = resolved.map((r) => {
16337
+ const safe = r.personality.replace(/<\/system-reminder>/gi, "</ system-reminder>");
16338
+ return `[Acting as persona "${r.label}" for this message]
16339
+ ${safe}`;
16340
+ });
16341
+ return {
16342
+ systemReminder: `<system-reminder>
16343
+ ${blocks.join("\n\n")}
16344
+ </system-reminder>`,
16345
+ userText: body.trim()
16346
+ };
16342
16347
  }
16343
16348
 
16344
16349
  // src/session/runner.ts
@@ -16382,12 +16387,22 @@ var SessionRunner = class {
16382
16387
  // 外部推送 input 到 reducer,然后执行产出的 effects
16383
16388
  input(inputMsg) {
16384
16389
  const personaStore = this.hooks.personaStore;
16390
+ const adapter = this.hooks.adapter;
16385
16391
  const deps = {
16386
- parseLine: (l) => this.hooks.adapter.parseLine(l),
16387
- // persona mention injection 在 deps 装配处包一层,对 reducer 完全透明
16392
+ parseLine: (l) => adapter.parseLine(l),
16393
+ // persona mention injection 在 deps 装配处包一层,对 reducer 完全透明。
16394
+ // 命中 mention 时拆成两条 stdin 帧(先 system-reminder 块、后 user 原文):
16395
+ // - CC stream-json 按行处理,落盘是两条独立 user message;
16396
+ // - 第一条文本起头 `<system-reminder>` → classifyUserMessage 命中 → UI 折叠;
16397
+ // - 第二条正常用户气泡,刷新页面不再暴露 personality 文本。
16388
16398
  encodeStdin: (t, ctx) => {
16389
- const injected = personaStore ? injectPersonaMentions(t, personaStore) : t;
16390
- return this.hooks.adapter.encodeStdin(injected, ctx) ?? "";
16399
+ if (!personaStore) return adapter.encodeStdin(t, ctx) ?? "";
16400
+ const { systemReminder, userText } = injectPersonaMentions(t, personaStore);
16401
+ if (systemReminder === null) return adapter.encodeStdin(userText, ctx) ?? "";
16402
+ const metaFrame = adapter.encodeStdin(systemReminder, ctx) ?? "";
16403
+ if (userText === "") return metaFrame;
16404
+ const userFrame = adapter.encodeStdin(userText, ctx) ?? "";
16405
+ return metaFrame + userFrame;
16391
16406
  },
16392
16407
  bufferCap: this.hooks.bufferCap ?? 500,
16393
16408
  now: this.hooks.now ?? Date.now,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",