@clawos-dev/clawd 0.2.677 → 0.2.679

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.
@@ -31135,6 +31135,7 @@ var CloudWorkspaceResultSchema = external_exports.object({
31135
31135
  repositories: external_exports.array(WorkspaceRepoSchema).optional(),
31136
31136
  branches: external_exports.array(external_exports.string()).optional(),
31137
31137
  hasMore: external_exports.boolean().optional(),
31138
+ cache: external_exports.enum(["warm", "cold"]).optional(),
31138
31139
  diff: external_exports.object({
31139
31140
  path: FilePath,
31140
31141
  patch: external_exports.string(),
package/dist/cli.cjs CHANGED
@@ -4253,6 +4253,7 @@ var init_cloud_workspace_schemas = __esm({
4253
4253
  repositories: external_exports.array(WorkspaceRepoSchema).optional(),
4254
4254
  branches: external_exports.array(external_exports.string()).optional(),
4255
4255
  hasMore: external_exports.boolean().optional(),
4256
+ cache: external_exports.enum(["warm", "cold"]).optional(),
4256
4257
  diff: external_exports.object({
4257
4258
  path: FilePath,
4258
4259
  patch: external_exports.string(),
@@ -48359,7 +48360,7 @@ function pushEventToBufferInPlace(next, event, deps) {
48359
48360
  }
48360
48361
  next.turnOpen = false;
48361
48362
  next.turnStartedAt = null;
48362
- } else if (!isBackgroundEvent && !(isSessionInit && next.status === "running-idle") && !next.turnOpen) {
48363
+ } else if (!isBackgroundEvent && !isSessionInit && !next.turnOpen) {
48363
48364
  next.turnOpen = true;
48364
48365
  next.turnStartedAt = deps.now();
48365
48366
  next.turnSelfWoke = next.status === "running-idle";
@@ -49198,6 +49199,9 @@ var SessionRunner = class {
49198
49199
  return this.state;
49199
49200
  }
49200
49201
  input(inputMsg) {
49202
+ if (inputMsg.kind === "proc-exit") {
49203
+ this.hooks.logger?.info("session.process.exited", { ...this.lifecycleMetadata(), exitCode: inputMsg.code });
49204
+ }
49201
49205
  const adapter = this.hooks.adapter;
49202
49206
  const deps = {
49203
49207
  parseLine: (l2) => {
@@ -49225,7 +49229,7 @@ var SessionRunner = class {
49225
49229
  };
49226
49230
  const { state, effects } = reduceSession(this.state, inputMsg, deps);
49227
49231
  this.state = state;
49228
- for (const e of effects) this.applyEffect(e);
49232
+ for (const e of effects) this.applyEffect(e, inputMsg);
49229
49233
  if (!this.state.procAlive && this.stopWaiters.length > 0) {
49230
49234
  const waiters = this.stopWaiters;
49231
49235
  this.stopWaiters = [];
@@ -49289,6 +49293,10 @@ var SessionRunner = class {
49289
49293
  // session:interrupt 的 SDK 通道分流:codex → AgentSession.interrupt();claude → control_request('interrupt')。
49290
49294
  // TUI(pty) 路径在 manager.interrupt() 里先走 stop() SIGKILL,不进这里。
49291
49295
  async interrupt() {
49296
+ this.hooks.logger?.info("session.interrupt.requested", {
49297
+ ...this.lifecycleMetadata(),
49298
+ mechanism: this.session ? "agent-session" : "control-request"
49299
+ });
49292
49300
  if (this.session) {
49293
49301
  this.session.interrupt();
49294
49302
  return;
@@ -49411,12 +49419,42 @@ var SessionRunner = class {
49411
49419
  }
49412
49420
  this.pendingControlRequests.clear();
49413
49421
  }
49414
- applyEffect(effect) {
49422
+ lifecycleMetadata() {
49423
+ const state = this.state;
49424
+ let turnId;
49425
+ for (let index = state.buffer.length - 1; index >= 0; index--) {
49426
+ const event = state.buffer[index].event;
49427
+ if (event.turnId) {
49428
+ turnId = event.turnId;
49429
+ break;
49430
+ }
49431
+ if (event.kind === "user_text") break;
49432
+ }
49433
+ return {
49434
+ sessionId: state.file.sessionId,
49435
+ tool: state.file.tool,
49436
+ toolSessionId: state.file.toolSessionId,
49437
+ turnId,
49438
+ status: state.status,
49439
+ turnOpen: state.turnOpen,
49440
+ procAlive: state.procAlive
49441
+ };
49442
+ }
49443
+ applyEffect(effect, input) {
49415
49444
  switch (effect.kind) {
49416
49445
  case "spawn":
49417
49446
  this.doSpawn(effect.ctx);
49418
49447
  break;
49419
49448
  case "kill":
49449
+ this.hooks.logger?.warn("session.process.kill", {
49450
+ ...this.lifecycleMetadata(),
49451
+ signal: effect.signal,
49452
+ inputKind: input.kind,
49453
+ ...input.kind === "command" ? {
49454
+ commandKind: input.command.kind,
49455
+ ...input.command.kind === "update" ? { patchKeys: Object.keys(input.command.patch) } : {}
49456
+ } : {}
49457
+ });
49420
49458
  if (this.session) {
49421
49459
  void this.session.stop(effect.signal);
49422
49460
  break;
@@ -49482,9 +49520,20 @@ var SessionRunner = class {
49482
49520
  this.hooks.logger?.warn("delete-file failed", { err: err.message });
49483
49521
  }
49484
49522
  break;
49485
- case "emit-frame":
49523
+ case "emit-frame": {
49524
+ const event = effect.frame.type === "session:event" ? effect.frame.event : void 0;
49525
+ if (event?.kind === "turn_end" && event.reason === "interrupted") {
49526
+ this.hooks.logger?.warn("session.turn.interrupted", {
49527
+ ...this.lifecycleMetadata(),
49528
+ inputKind: input.kind,
49529
+ ...event.turnId ? { turnId: event.turnId } : {},
49530
+ durationMs: event.durationMs,
49531
+ ...input.kind === "command" ? { commandKind: input.command.kind } : {}
49532
+ });
49533
+ }
49486
49534
  this.hooks.broadcastFrame(effect.frame, effect.target ?? "broadcast");
49487
49535
  break;
49536
+ }
49488
49537
  case "schedule-tick": {
49489
49538
  const now = this.hooks.now ?? Date.now;
49490
49539
  setTimeout(() => this.input({ kind: "tick", nowMs: now() }), effect.delayMs).unref();
@@ -54550,7 +54599,10 @@ function driveCodexThread(opts) {
54550
54599
  });
54551
54600
  if (threadId !== void 0 && ownerThreadId === threadId && method === "turn/started") {
54552
54601
  const id = params?.turn?.id;
54553
- if (id) turnId = id;
54602
+ if (id) {
54603
+ turnId = id;
54604
+ sink.pushEvents([{ kind: "session_init", toolSessionId: threadId, turnId }]);
54605
+ }
54554
54606
  activeTrace?.("native.turn.started", { threadId, turnId });
54555
54607
  }
54556
54608
  const events = route === "subagent" && ownerThreadId ? subagents.handleChildNotification(ownerThreadId, method, params) : route === "foreground" ? [
@@ -72774,6 +72826,17 @@ function canReadSearchHit(ctx, file) {
72774
72826
  var DEFAULT_SEARCH_LIMIT = 9;
72775
72827
  function buildSessionHandlers(deps) {
72776
72828
  const { manager, observer, getAdapter: getAdapter2, store, ownerPrincipalId } = deps;
72829
+ const logControlRequest = (method, sessionId, client, ctx, patchKeys) => {
72830
+ deps.logger?.info("session.control.requested", {
72831
+ sessionId,
72832
+ method,
72833
+ clientId: client.id,
72834
+ transport: client.transport,
72835
+ principalKind: ctx?.principal?.kind,
72836
+ principalId: ctx?.principal?.id,
72837
+ ...patchKeys ? { patchKeys } : {}
72838
+ });
72839
+ };
72777
72840
  const ensureSessionAccess = (ctx, sessionId, action) => {
72778
72841
  if (!ctx) return;
72779
72842
  const ok = canAccessSession(ctx, sessionId, action, {
@@ -72936,12 +72999,14 @@ function buildSessionHandlers(deps) {
72936
72999
  `${MASTER_PERSONA_ID} \u7684\u5FEB\u901F\u95EE\u7B54\u4F1A\u8BDD\u4E0D\u80FD\u8F6C\u6B63\uFF1A\u8F6C\u6B63\u540E\u5C31\u662F\u4E00\u6761\u6CA1\u6709\u8BDD\u9898\u5F52\u5C5E\u3001\u4E5F\u56DE\u6536\u4E0D\u6389\u7684\u4F1A\u8BDD`
72937
73000
  );
72938
73001
  }
73002
+ logControlRequest("session:update", args.sessionId, _client, ctx, Object.keys(args.patch));
72939
73003
  const { response, broadcast } = manager.update(args);
72940
73004
  return { response: { type: "session:info", ...response }, broadcast };
72941
73005
  };
72942
73006
  const del = async (frame, _client, ctx) => {
72943
73007
  const args = SessionIdArgs.parse(frame);
72944
73008
  ensureSessionAccess(ctx, args.sessionId, "send");
73009
+ logControlRequest("session:delete", args.sessionId, _client, ctx);
72945
73010
  const { broadcast } = await manager.deleteWithCloudCancel(args);
72946
73011
  return {
72947
73012
  response: { type: "session:deleted", sessionId: args.sessionId },
@@ -72983,12 +73048,14 @@ ${attribution}` } : args;
72983
73048
  const stop = async (frame, _client, ctx) => {
72984
73049
  const args = SessionIdArgs.parse(frame);
72985
73050
  ensureSessionAccess(ctx, args.sessionId, "send");
73051
+ logControlRequest("session:stop", args.sessionId, _client, ctx);
72986
73052
  const { broadcast } = await manager.stop(args);
72987
73053
  return { response: { type: "session:stop", ok: true }, broadcast };
72988
73054
  };
72989
73055
  const interrupt = async (frame, _client, ctx) => {
72990
73056
  const args = SessionIdArgs.parse(frame);
72991
73057
  ensureSessionAccess(ctx, args.sessionId, "send");
73058
+ logControlRequest("session:interrupt", args.sessionId, _client, ctx);
72992
73059
  const { response, broadcast } = await manager.interrupt(args);
72993
73060
  const queued = response.queued ?? [];
72994
73061
  return { response: { type: "session:interrupt", ok: true, queued }, broadcast };
@@ -73085,6 +73152,7 @@ ${attribution}` } : args;
73085
73152
  const newSession = async (frame, _client, ctx) => {
73086
73153
  const args = SessionIdArgs.parse(frame);
73087
73154
  ensureSessionAccess(ctx, args.sessionId, "send");
73155
+ logControlRequest("session:new", args.sessionId, _client, ctx);
73088
73156
  observer.stop(args.sessionId);
73089
73157
  const { response, broadcast } = await manager.newSessionWithCloudCancel(args);
73090
73158
  return { response: { type: "session:info", ...response }, broadcast };
@@ -73092,6 +73160,7 @@ ${attribution}` } : args;
73092
73160
  const resume = async (frame, _client, ctx) => {
73093
73161
  const args = SessionResumeArgs.parse(frame);
73094
73162
  ensureSessionAccess(ctx, args.sessionId, "send");
73163
+ logControlRequest("session:resume", args.sessionId, _client, ctx);
73095
73164
  const { response, broadcast } = manager.resume(args);
73096
73165
  return { response: { type: "session:info", ...response }, broadcast };
73097
73166
  };
@@ -75266,7 +75335,7 @@ function computeMethodAccess(args) {
75266
75335
  }
75267
75336
 
75268
75337
  // src/version.ts
75269
- var version = "0.2.677".length > 0 ? "0.2.677" : "dev";
75338
+ var version = "0.2.679".length > 0 ? "0.2.679" : "dev";
75270
75339
 
75271
75340
  // src/cli-probe/probe.ts
75272
75341
  var fs86 = __toESM(require("fs"), 1);