@clawos-dev/clawd 0.2.176-beta.354.c832bc0 → 0.2.177-beta.355.6443d50

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 CHANGED
@@ -253,7 +253,11 @@ var init_events = __esm({
253
253
  "skill-hint",
254
254
  "meta-text",
255
255
  "attachment-skills",
256
- "attachment-deferred-tools"
256
+ "attachment-deferred-tools",
257
+ // clawd shift v1:scheduler fire 时 daemon 给新 cc 的首条 user message 用
258
+ // <clawd-shift-fire> wrap 起头;classifyUserMessage 识别后路由到 UserMetaLine 折叠渲染,
259
+ // 不显示成 user 气泡(避免 instruction 文本被当 owner 实时对话)。
260
+ "clawd-shift-fire"
257
261
  ];
258
262
  SKILL_SOURCE_VALUES = ["builtin", "global", "project", "plugin"];
259
263
  AGENT_SOURCE_VALUES = [
@@ -4784,6 +4788,16 @@ var init_schemas = __esm({
4784
4788
  * 反查路径走错;按 #750 一族防线处理,跟 ownerPersonaId 同地点 strip)。
4785
4789
  */
4786
4790
  dispatchedFromSessionId: external_exports.string().min(1).optional(),
4791
+ /**
4792
+ * Shift fire 派生的 session 记录调 addShift 的 source cc session id(稳定 key);
4793
+ * sidebar 据此把 fire 出的 session 折叠在 source session 下,跟 dispatchedFromSessionId
4794
+ * 平行但渲染不同 icon(AlarmClock 区别于 dispatch 的 CornerDownRight),让 owner 一眼
4795
+ * 分清"派生于人为委派"还是"派生于定时唤起"。非 shift fire session 缺省。
4796
+ * 跟 dispatchedFromSessionId / forkedFromSessionId 三者互斥(同一 session 不会兼任)。
4797
+ * mirror SessionFile 同 dispatchedFromSessionId 处理(shift fire 本地概念,理论上不会
4798
+ * mirror,留 strip 防御)。
4799
+ */
4800
+ shiftFiredFromSessionId: external_exports.string().min(1).optional(),
4787
4801
  createdAt: external_exports.string().min(1),
4788
4802
  updatedAt: external_exports.string().min(1)
4789
4803
  });
@@ -11230,6 +11244,7 @@ function classifyUserMessage(input) {
11230
11244
  if (SYSTEM_REMINDER_RE.test(text) || OPENSPEC_BLOCK_RE.test(text)) {
11231
11245
  return { meta: "system-reminder" };
11232
11246
  }
11247
+ if (CLAWD_SHIFT_FIRE_RE.test(text)) return { meta: "clawd-shift-fire" };
11233
11248
  if (SKILL_HINT_RE.test(text)) return { meta: "skill-hint" };
11234
11249
  const flags = raw;
11235
11250
  if (flags.isMeta === true || flags.isSynthetic === true) return { meta: "meta-text" };
@@ -11444,7 +11459,7 @@ function readCurrentContent(filePath) {
11444
11459
  return null;
11445
11460
  }
11446
11461
  }
11447
- var import_node_fs10, import_node_os5, import_node_path9, TASK_NOTIFICATION_RE, TASK_ID_RE, TOOL_USE_ID_RE, SLASH_COMMAND_RE, LOCAL_COMMAND_RE, SYSTEM_REMINDER_RE, OPENSPEC_BLOCK_RE, SKILL_HINT_RE, ATTACHMENT_SILENT_SUBTYPES, ClaudeHistoryReader;
11462
+ var import_node_fs10, import_node_os5, import_node_path9, TASK_NOTIFICATION_RE, TASK_ID_RE, TOOL_USE_ID_RE, SLASH_COMMAND_RE, LOCAL_COMMAND_RE, SYSTEM_REMINDER_RE, OPENSPEC_BLOCK_RE, SKILL_HINT_RE, CLAWD_SHIFT_FIRE_RE, ATTACHMENT_SILENT_SUBTYPES, ClaudeHistoryReader;
11448
11463
  var init_claude_history = __esm({
11449
11464
  "src/tools/claude-history.ts"() {
11450
11465
  "use strict";
@@ -11461,6 +11476,7 @@ var init_claude_history = __esm({
11461
11476
  SYSTEM_REMINDER_RE = /^\s*<system-reminder\b/i;
11462
11477
  OPENSPEC_BLOCK_RE = /^\s*<!--\s*OPENSPEC\b/i;
11463
11478
  SKILL_HINT_RE = /^\s*Base directory for this skill:\s/;
11479
+ CLAWD_SHIFT_FIRE_RE = /^\s*<clawd-shift-fire\b/i;
11464
11480
  ATTACHMENT_SILENT_SUBTYPES = /* @__PURE__ */ new Set([
11465
11481
  "hook_additional_context",
11466
11482
  "hook_success",
@@ -41261,6 +41277,22 @@ function composeGuestSandbox(base, userWorkDir, spawnCwd) {
41261
41277
  return s;
41262
41278
  }
41263
41279
 
41280
+ // src/shift/wrap.ts
41281
+ function wrapShiftFirePrompt(args) {
41282
+ return [
41283
+ `<clawd-shift-fire target-persona="${escapeAttr(args.targetPersona)}">`,
41284
+ "This is a scheduled shift fire \u2014 not a live user message.",
41285
+ "Respond as an assistant turn (start your output directly).",
41286
+ "",
41287
+ "Instruction:",
41288
+ args.prompt,
41289
+ "</clawd-shift-fire>"
41290
+ ].join("\n");
41291
+ }
41292
+ function escapeAttr(v2) {
41293
+ return v2.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
41294
+ }
41295
+
41264
41296
  // src/session/reducer.ts
41265
41297
  init_runtime();
41266
41298
 
@@ -43242,10 +43274,14 @@ var SessionManager = class {
43242
43274
  // 强制走 deps.store(即 default scope),不走 scopeForFile:mirror 物理落 default 即可。
43243
43275
  // 远端 creator / origin 字段原值保留(不被本机 ctx 派生覆写)。
43244
43276
  //
43245
- // strip 远端 personaId / dispatchedFromSessionId:mirror SessionFile 上这两个字段都指向
43246
- // 朋友 daemon 上的本地 id,本机不持有对应 persona / 源 session。留着会让按这些字段反查的
43247
- // 本机消费者(MyPersonasSection 按 ownerPersonaId 反查 persona、sidebar 按
43248
- // dispatchedFromSessionId 折叠 sub-session)走错分支。写入前清掉。#750 一族防线。
43277
+ // strip 远端 personaId / dispatchedFromSessionId / shiftFiredFromSessionId:mirror
43278
+ // SessionFile 上这些字段都指向朋友 daemon 上的本地 id,本机不持有对应 persona /
43279
+ // 源 session。留着会让按这些字段反查的本机消费者(MyPersonasSection 按 ownerPersonaId
43280
+ // 反查 persona、sidebar 按 dispatchedFromSessionId / shiftFiredFromSessionId 折叠
43281
+ // sub-session)走错分支。写入前清掉。#750 一族防线。
43282
+ //
43283
+ // shift fire 是本地 daemon scheduler 行为,理论上不产生 mirror SessionFile,但留 strip
43284
+ // 防御(同 dispatchedFromSessionId 处理姿势对齐)。
43249
43285
  //
43250
43286
  // 与 manager.create / manager.update 区别:
43251
43287
  // - 不走 newRunner / attachObserver / cwd 校验(mirror 是纯 metadata 层)
@@ -43254,6 +43290,7 @@ var SessionManager = class {
43254
43290
  const {
43255
43291
  ownerPersonaId: _strippedPid,
43256
43292
  dispatchedFromSessionId: _strippedDsp,
43293
+ shiftFiredFromSessionId: _strippedSft,
43257
43294
  ...rest
43258
43295
  } = file;
43259
43296
  return this.deps.store.write(rest);
@@ -43956,6 +43993,7 @@ var SessionManager = class {
43956
43993
  cwd,
43957
43994
  tool: "claude",
43958
43995
  ownerPersonaId: args.targetPersona,
43996
+ ...args.sourceSessionId ? { shiftFiredFromSessionId: args.sourceSessionId } : {},
43959
43997
  createdAt: now,
43960
43998
  updatedAt: now
43961
43999
  };
@@ -43991,7 +44029,16 @@ var SessionManager = class {
43991
44029
  });
43992
44030
  const runner = this.ensureRunnerForScope(file, scope);
43993
44031
  this.deps.logger?.info("shift.createShiftSession.runner-ready", { sessionId });
43994
- runner.input({ kind: "command", command: { kind: "send", text: args.prompt } });
44032
+ runner.input({
44033
+ kind: "command",
44034
+ command: {
44035
+ kind: "send",
44036
+ text: wrapShiftFirePrompt({
44037
+ prompt: args.prompt,
44038
+ targetPersona: args.targetPersona
44039
+ })
44040
+ }
44041
+ });
43995
44042
  const kill = () => {
43996
44043
  const r = this.runners.get(sessionId);
43997
44044
  if (!r) return;
@@ -47513,7 +47560,8 @@ function createShiftScheduler(deps) {
47513
47560
  shiftId: shift.id,
47514
47561
  targetPersona: shift.targetPersona,
47515
47562
  prompt: shift.prompt,
47516
- timeoutMs
47563
+ timeoutMs,
47564
+ ...shift.createdBySessionId ? { sourceSessionId: shift.createdBySessionId } : {}
47517
47565
  });
47518
47566
  sessionId = spawned.sessionId;
47519
47567
  const startRun = {
@@ -47567,8 +47615,12 @@ function createShiftScheduler(deps) {
47567
47615
 
47568
47616
  // src/shift/spawn.ts
47569
47617
  function createShiftSpawnFn(deps) {
47570
- return async ({ targetPersona, prompt, timeoutMs }) => {
47571
- const created = deps.sessionManager.createShiftSession({ targetPersona, prompt });
47618
+ return async ({ targetPersona, prompt, timeoutMs, sourceSessionId }) => {
47619
+ const created = deps.sessionManager.createShiftSession({
47620
+ targetPersona,
47621
+ prompt,
47622
+ ...sourceSessionId ? { sourceSessionId } : {}
47623
+ });
47572
47624
  let resolveOuter = () => {
47573
47625
  };
47574
47626
  const ended = new Promise((r) => {
@@ -47622,12 +47674,14 @@ function validateSchedule(schedule) {
47622
47674
  function buildShiftInternalHandlers(deps) {
47623
47675
  const add = async (frame) => {
47624
47676
  const persona = readPersonaId(frame);
47677
+ const callerSessionId = typeof frame.sessionId === "string" ? frame.sessionId : void 0;
47625
47678
  const { type: _t, requestId: _r, personaId: _p, sessionId: _s, ...rest } = frame;
47626
47679
  const args = rest;
47627
47680
  validateSchedule(args.schedule);
47628
47681
  const shift = deps.store.add({
47629
47682
  ownerId: deps.ownerIdProvider(),
47630
47683
  createdByPersona: persona,
47684
+ ...callerSessionId ? { createdBySessionId: callerSessionId } : {},
47631
47685
  name: args.name,
47632
47686
  enabled: true,
47633
47687
  schedule: args.schedule,
@@ -21251,7 +21251,9 @@ async function main() {
21251
21251
  inputSchema: {
21252
21252
  name: external_exports.string().describe("short label shown in shift.json + future UI"),
21253
21253
  schedule: ScheduleSchema,
21254
- prompt: external_exports.string().describe("first user message injected when the new cc starts"),
21254
+ prompt: external_exports.string().describe(
21255
+ "instruction the spawned cc executes on startup (NOT a chat message from the owner). Write what you want the persona to DO or SAY at fire time, in instruction form \u2014 daemon wraps it in a <clawd-shift-fire> tag so the spawned cc treats it as a scheduled action and responds as an assistant turn (no user-bubble appears in the owner's UI)."
21256
+ ),
21255
21257
  targetPersona: external_exports.string().optional().describe("which persona to spawn; defaults to the calling persona"),
21256
21258
  timeoutMs: external_exports.number().optional().describe("hard timeout per fire; default 30 minutes")
21257
21259
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.176-beta.354.c832bc0",
3
+ "version": "0.2.177-beta.355.6443d50",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",