@clawos-dev/clawd 0.2.766 → 0.2.768

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
@@ -50900,6 +50900,12 @@ var SessionManager = class {
50900
50900
  broadcast: [{ frame: { type: "session:info", ...updated }, target: "all" }]
50901
50901
  };
50902
50902
  }
50903
+ /** A mounted cloud worker has no thread id until its turn ends; once the ledger reports it, history becomes readable. No-op if already attached. */
50904
+ attachCloudWorkerThread(sessionId, toolSessionId) {
50905
+ const file = this.findOwnedSession(sessionId);
50906
+ if (!file || !file.cloudConversationId || file.toolSessionId) return null;
50907
+ return this.applyUpdate({ sessionId, patch: { toolSessionId } });
50908
+ }
50903
50909
  bindCloudWorkspace(sessionId, binding, conversationId) {
50904
50910
  const file = this.getFile(sessionId);
50905
50911
  if (!isCloudTool(file.tool) || file.cloudPendingTurns?.length)
@@ -57808,13 +57814,26 @@ function createA2aHost(deps) {
57808
57814
  if (v3.initiator.host === "cloud") return deps.listSessions().find((s2) => s2.cloudConversationId === ref) ?? null;
57809
57815
  return null;
57810
57816
  }
57817
+ function mountCloudChildren(conversationRef) {
57818
+ for (const child of [...cache2.values()]) {
57819
+ if (child.initiator.host === "cloud" && child.initiator.sessionRef === conversationRef) onInitiatorTask(child, 0);
57820
+ }
57821
+ }
57811
57822
  function onInitiatorTask(v3, changeSeq) {
57812
57823
  remember(v3);
57813
57824
  const session = initiatorSession(v3);
57814
57825
  if (!session) return;
57815
- if (v3.targetDeviceId === null && v3.executorSessionRef && v3.executorThreadId && !v3.workerSessionId && deps.mountCloudWorker) {
57816
- const mounted = deps.mountCloudWorker(v3, session);
57817
- if (mounted) cache2.set(v3.taskId, { ...v3, workerSessionId: mounted });
57826
+ if (v3.targetDeviceId === null && v3.executorSessionRef && deps.mountCloudWorker) {
57827
+ let worker = v3.workerSessionId ?? deps.listSessions().find((s2) => s2.cloudConversationId === v3.executorSessionRef)?.sessionId;
57828
+ const ran = v3.state === "working" || v3.state === "input_required" || v3.executorThreadId !== null;
57829
+ if (!worker && ran) {
57830
+ worker = deps.mountCloudWorker(v3, session) ?? void 0;
57831
+ if (worker) {
57832
+ cache2.set(v3.taskId, { ...v3, workerSessionId: worker });
57833
+ mountCloudChildren(v3.executorSessionRef);
57834
+ }
57835
+ }
57836
+ if (worker && v3.executorThreadId) deps.attachCloudWorkerThread?.(worker, v3.executorThreadId);
57818
57837
  }
57819
57838
  if (v3.initiator.host === "cloud") return;
57820
57839
  if (!isDeliverable(v3) || v3.deliveredAt) return;
@@ -76677,7 +76696,7 @@ function computeMethodAccess(args) {
76677
76696
  }
76678
76697
 
76679
76698
  // src/version.ts
76680
- var version = "0.2.766".length > 0 ? "0.2.766" : "dev";
76699
+ var version = "0.2.768".length > 0 ? "0.2.768" : "dev";
76681
76700
 
76682
76701
  // src/cli-probe/probe.ts
76683
76702
  var fs87 = __toESM(require("fs"), 1);
@@ -80536,13 +80555,13 @@ async function startDaemon(config) {
80536
80555
  // 云 worker 会话挂到发起会话下面:本机要有这个云 persona 的镜像(会话 cwd / 引擎从它来),没有就只留在台账里
80537
80556
  mountCloudWorker: (view, initiator) => {
80538
80557
  const mirror = personaRegistry.list().find((p3) => p3.cloud?.personaId === view.targetPersonaId);
80539
- if (!mirror || !view.executorSessionRef || !view.executorThreadId) return null;
80558
+ if (!mirror || !view.executorSessionRef) return null;
80540
80559
  try {
80541
80560
  const { response, broadcast } = manager.create(
80542
80561
  {
80543
80562
  ownerPersonaId: mirror.personaId,
80544
80563
  label: (view.sessionLabel ?? view.taskText.split("\n")[0]).slice(0, 40),
80545
- cloudFork: { sessionId: newSessionId(), toolSessionId: view.executorThreadId, cloudConversationId: view.executorSessionRef },
80564
+ cloudFork: { sessionId: newSessionId(), ...view.executorThreadId ? { toolSessionId: view.executorThreadId } : {}, cloudConversationId: view.executorSessionRef },
80546
80565
  a2aWorker: { contextId: view.contextId, sourceSessionId: initiator.sessionId }
80547
80566
  },
80548
80567
  ownerPrincipalId,
@@ -80557,6 +80576,14 @@ async function startDaemon(config) {
80557
80576
  return null;
80558
80577
  }
80559
80578
  },
80579
+ attachCloudWorkerThread: (sessionId, threadId) => {
80580
+ try {
80581
+ const attached = manager.attachCloudWorkerThread(sessionId, threadId);
80582
+ for (const b3 of attached?.broadcast ?? []) broadcastManagerFrame(b3.frame, b3.target);
80583
+ } catch (err) {
80584
+ logger.warn("a2a.attach-cloud-worker-thread-failed", { sessionId, error: err instanceof Error ? err.message : String(err) });
80585
+ }
80586
+ },
80560
80587
  every: (ms, fn) => {
80561
80588
  const timer = setInterval(fn, ms);
80562
80589
  timer.unref();