oasis_test 0.1.27 → 0.1.29

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/index.js +38 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42998,6 +42998,18 @@ function classifyExit(result) {
42998
42998
  if (result.is_error === true || String(result.subtype ?? "").startsWith("error")) return "error";
42999
42999
  return void 0;
43000
43000
  }
43001
+ function conversationExists(sessionId) {
43002
+ const configDir = process.env["CLAUDE_CONFIG_DIR"] || path6.join(os2.homedir(), ".claude");
43003
+ const projectsDir = path6.join(configDir, "projects");
43004
+ const target = `${sessionId}.jsonl`;
43005
+ try {
43006
+ for (const proj of fs9.readdirSync(projectsDir)) {
43007
+ if (fs9.existsSync(path6.join(projectsDir, proj, target))) return true;
43008
+ }
43009
+ } catch {
43010
+ }
43011
+ return false;
43012
+ }
43001
43013
  var ClaudeCodeAdapter = class {
43002
43014
  constructor(opts = {}) {
43003
43015
  this.opts = opts;
@@ -43040,7 +43052,8 @@ var ClaudeCodeAdapter = class {
43040
43052
  }
43041
43053
  const prompt = job.bundle.files["TASK.md"];
43042
43054
  if (!prompt) throw new Error("bundle \u7F3A TASK.md\uFF08\u88C5\u914D\u5668\u5951\u7EA6\uFF09");
43043
- const runtimeSessionArgs = job.runtimeSessionId ? job.resumeRuntimeSession ? ["--resume", job.runtimeSessionId] : ["--session-id", job.runtimeSessionId] : [];
43055
+ const canResume = job.resumeRuntimeSession && conversationExists(job.runtimeSessionId ?? "");
43056
+ const runtimeSessionArgs = job.runtimeSessionId ? canResume ? ["--resume", job.runtimeSessionId] : ["--session-id", job.runtimeSessionId] : [];
43044
43057
  const args = [
43045
43058
  "-p",
43046
43059
  prompt,
@@ -49331,6 +49344,8 @@ var DaemonWsClient = class {
49331
49344
  ws = null;
49332
49345
  pingTimer = null;
49333
49346
  stopped = false;
49347
+ /** 收到 update 但有活跃会话时置真:延后到所有会话结束再自更新,避免打断执行中的 agent。 */
49348
+ pendingUpdate = false;
49334
49349
  start() {
49335
49350
  this.connect();
49336
49351
  }
@@ -49405,6 +49420,7 @@ var DaemonWsClient = class {
49405
49420
  log2("[node-cli]", ` \u25A0 session_exited id=${handle.id} code=${info.code ?? "killed"} total=${Date.now() - t0}ms`);
49406
49421
  if (info.transcriptRef) log2("[node-cli]", ` transcript: ${info.transcriptRef}`);
49407
49422
  this.send({ type: "session_exited", dispatchId, sessionId: handle.id, info });
49423
+ this.maybeRunPendingUpdate();
49408
49424
  });
49409
49425
  } catch (err) {
49410
49426
  log2("[node-cli]", ` spawn failed: ${err}`);
@@ -49424,9 +49440,18 @@ var DaemonWsClient = class {
49424
49440
  this.send({ type: "pong" });
49425
49441
  break;
49426
49442
  case "update": {
49427
- log2("[node-cli]", "\u2190 update\uFF1A\u62C9\u53D6\u6700\u65B0\u7248\u672C\u5E76\u91CD\u542F");
49428
- if (this.onUpdate) this.onUpdate();
49429
- else log2("[node-cli]", " update \u5FFD\u7565\uFF1A\u672C\u8FDB\u7A0B\u672A\u6CE8\u5165\u81EA\u66F4\u65B0\u903B\u8F91\uFF08\u975E node-daemon \u6258\u7BA1\uFF1F\uFF09");
49443
+ if (!this.onUpdate) {
49444
+ log2("[node-cli]", "\u2190 update \u5FFD\u7565\uFF1A\u672C\u8FDB\u7A0B\u672A\u6CE8\u5165\u81EA\u66F4\u65B0\u903B\u8F91\uFF08\u975E node-daemon \u6258\u7BA1\uFF1F\uFF09");
49445
+ break;
49446
+ }
49447
+ const active = this.sessions.activeCount();
49448
+ if (active > 0) {
49449
+ this.pendingUpdate = true;
49450
+ log2("[node-cli]", `\u2190 update\uFF1A\u5F53\u524D\u6709 ${active} \u4E2A\u6267\u884C\u4E2D\u4F1A\u8BDD,\u5EF6\u540E\u5230\u5168\u90E8\u7ED3\u675F\u540E\u518D\u66F4\u65B0`);
49451
+ } else {
49452
+ log2("[node-cli]", "\u2190 update\uFF1A\u7A7A\u95F2,\u7ACB\u5373\u62C9\u53D6\u6700\u65B0\u7248\u672C\u5E76\u91CD\u542F");
49453
+ this.onUpdate();
49454
+ }
49430
49455
  break;
49431
49456
  }
49432
49457
  }
@@ -49434,6 +49459,14 @@ var DaemonWsClient = class {
49434
49459
  send(msg) {
49435
49460
  if (this.ws?.readyState === import_websocket.default.OPEN) this.ws.send(JSON.stringify(msg));
49436
49461
  }
49462
+ /** 会话结束后调用:若之前收到过 update 但因忙延后了,且现已空闲,则触发自更新。 */
49463
+ maybeRunPendingUpdate() {
49464
+ if (this.pendingUpdate && this.sessions.activeCount() === 0) {
49465
+ this.pendingUpdate = false;
49466
+ log2("[node-cli]", "\u6240\u6709\u4F1A\u8BDD\u5DF2\u7ED3\u675F,\u6267\u884C\u5EF6\u540E\u7684\u66F4\u65B0\uFF1A\u62C9\u53D6\u6700\u65B0\u7248\u672C\u5E76\u91CD\u542F");
49467
+ this.onUpdate?.();
49468
+ }
49469
+ }
49437
49470
  buildMeta() {
49438
49471
  return { hostname: (0, import_node_os3.hostname)(), adapters: this.adapters, ...this.reportRuntimes ? { runtimes: this.runtimes } : {}, nodeVersion: process.version, ...this.daemonVersion ? { daemonVersion: this.daemonVersion } : {}, ...this.nodeName ? { nodeName: this.nodeName } : {} };
49439
49472
  }
@@ -50988,7 +51021,7 @@ async function runCli(argv, println = console.log) {
50988
51021
  }
50989
51022
 
50990
51023
  // src/index.ts
50991
- var PKG_VERSION = true ? "0.1.27" : "dev";
51024
+ var PKG_VERSION = true ? "0.1.29" : "dev";
50992
51025
  var OASIS_DIR = path13.join(os8.homedir(), ".oasis");
50993
51026
  var CONFIG_FILE = path13.join(OASIS_DIR, "node-config.json");
50994
51027
  var PID_FILE = path13.join(OASIS_DIR, "node.pid");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oasis_test",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Oasis node daemon + CLI — background daemon, auto-start, full server CLI",
5
5
  "bin": {
6
6
  "oasis": "./dist/index.js"