oasis_test 0.1.47 → 0.1.48

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 +83 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -322,7 +322,7 @@ function fold(model, op) {
322
322
  case "escalate": {
323
323
  const p2 = op.payload;
324
324
  const list = model.escalations.get(op.artifactId) ?? [];
325
- list.push({ part: p2.part ?? null, reason: p2.reason, by: op.actor, at: op.timestamp, resolved: false });
325
+ list.push({ part: p2.part ?? null, reason: p2.reason, by: op.actor, ...op.hand !== void 0 ? { hand: op.hand } : {}, at: op.timestamp, resolved: false });
326
326
  model.escalations.set(op.artifactId, list);
327
327
  break;
328
328
  }
@@ -565,7 +565,7 @@ function findGap(model, gapId) {
565
565
  return null;
566
566
  }
567
567
  function unresolvedEscalationsOf(model, id) {
568
- return (model.escalations.get(id) ?? []).filter((e) => !e.resolved).map((e) => ({ part: e.part, reason: e.reason, by: e.by, at: e.at }));
568
+ return (model.escalations.get(id) ?? []).filter((e) => !e.resolved).map((e) => ({ part: e.part, reason: e.reason, by: e.by, ...e.hand !== void 0 ? { hand: e.hand } : {}, at: e.at }));
569
569
  }
570
570
  function listPendingReviews(model, workspace) {
571
571
  const all = [...model.pendingReviews.values()];
@@ -23082,7 +23082,8 @@ function resolveDiscussContext(model, input) {
23082
23082
  if (!a) throw new Error(`\u8282\u70B9\u4E0D\u5B58\u5728\uFF1A${input.artifactId}`);
23083
23083
  workspace = a.workspace;
23084
23084
  const escs = unresolvedEscalationsOf(model, input.artifactId);
23085
- initiator = escs.at(-1)?.by;
23085
+ const lastEsc = escs.at(-1);
23086
+ initiator = lastEsc?.by.startsWith("actor:agent:") ? lastEsc.by : lastEsc?.hand;
23086
23087
  seed = escs.length ? `\u53D1\u8D77\u4EBA\u5C31\u4F60\u4E0A\u62A5\u7684\u95EE\u9898\u6765\u627E\u4F60\u4E86\uFF1A${escs.at(-1).reason}\u3002\u8BF7\u8BCA\u65AD\u6839\u56E0\u3001\u7ED9 1\u20132 \u4E2A\u65B9\u6848\u3001\u95EE ta \u91C7\u7528\u54EA\u4E2A\u3002` : `\u53D1\u8D77\u4EBA\u60F3\u548C\u4F60\u8BA8\u8BBA\u300C${input.artifactId}\u300D\u5F53\u524D\u7684\u5361\u70B9\u3002\u8BF7\u8BFB\u56FE\u8BCA\u65AD\u3001\u7ED9\u65B9\u6848\u518D\u95EE ta\u3002`;
23087
23088
  } else {
23088
23089
  throw new Error("discuss \u9700\u8981 artifactId \u6216 draftId");
@@ -37513,6 +37514,9 @@ var init_claude_code = __esm({
37513
37514
  const telemetryCbs = [];
37514
37515
  let eventSeq = 0;
37515
37516
  let lastResult;
37517
+ const stderrTail = [];
37518
+ const STDERR_MAX_LINES = 40;
37519
+ const STDERR_MAX_BYTES = 4e3;
37516
37520
  const usageAcc = newClaudeUsageAcc();
37517
37521
  let sessionModel;
37518
37522
  const outputCbs = [];
@@ -37552,7 +37556,19 @@ var init_claude_code = __esm({
37552
37556
  for (const cb of outputCbs) cb(text);
37553
37557
  });
37554
37558
  }
37555
- child.stderr.pipe(out);
37559
+ const stderrRl = readline.createInterface({ input: child.stderr });
37560
+ stderrRl.on("line", (line) => {
37561
+ try {
37562
+ out.write(line + "\n");
37563
+ } catch {
37564
+ }
37565
+ stderrTail.push(line);
37566
+ while (stderrTail.length > STDERR_MAX_LINES) stderrTail.shift();
37567
+ let total = stderrTail.reduce((n, l) => n + l.length + 1, 0);
37568
+ while (total > STDERR_MAX_BYTES && stderrTail.length > 1) {
37569
+ total -= stderrTail.shift().length + 1;
37570
+ }
37571
+ });
37556
37572
  const callbacks = [];
37557
37573
  let exited;
37558
37574
  let killedByUs = false;
@@ -37563,14 +37579,15 @@ var init_claude_code = __esm({
37563
37579
  child.on("error", (err) => {
37564
37580
  if (exited) return;
37565
37581
  clearTimeout(timer);
37582
+ const spawnErr = err instanceof Error ? err.message : String(err);
37566
37583
  try {
37567
37584
  out.write(`
37568
- [adapter] spawn \u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
37585
+ [adapter] spawn \u5931\u8D25\uFF1A${spawnErr}
37569
37586
  `);
37570
37587
  out.end();
37571
37588
  } catch {
37572
37589
  }
37573
- exited = { code: null, reason: "error", transcriptRef };
37590
+ exited = { code: null, reason: "error", transcriptRef, errorMessage: spawnErr };
37574
37591
  for (const cb of callbacks.splice(0)) cb(exited);
37575
37592
  });
37576
37593
  child.on("exit", (code) => {
@@ -37595,7 +37612,24 @@ var init_claude_code = __esm({
37595
37612
  }
37596
37613
  }
37597
37614
  const usage = buildClaudeUsage(usageAcc);
37598
- exited = { code: killedByUs ? null : code, ...reason ? { reason } : {}, transcriptRef, ...usage ? { usage } : {}, ...sessionModel ? { model: sessionModel } : {} };
37615
+ const isError = !killedByUs && (typeof code === "number" && code !== 0 || reason === "error" || reason === "output-limit" || reason === "rate-limit");
37616
+ const errorParts = [];
37617
+ if (lastResult?.is_error === true) {
37618
+ const subtype = typeof lastResult.subtype === "string" ? lastResult.subtype : "";
37619
+ const body = typeof lastResult.result === "string" ? lastResult.result : "";
37620
+ const composed = [subtype && `[${subtype}]`, body].filter(Boolean).join(" ").trim();
37621
+ if (composed) errorParts.push(composed);
37622
+ }
37623
+ if (stderrTail.length) errorParts.push(stderrTail.join("\n").trim());
37624
+ const errorMessage = isError ? errorParts.filter(Boolean).join("\n---\n").slice(-4e3).trim() || void 0 : void 0;
37625
+ exited = {
37626
+ code: killedByUs ? null : code,
37627
+ ...reason ? { reason } : {},
37628
+ transcriptRef,
37629
+ ...usage ? { usage } : {},
37630
+ ...sessionModel ? { model: sessionModel } : {},
37631
+ ...errorMessage ? { errorMessage } : {}
37632
+ };
37599
37633
  for (const cb of callbacks.splice(0)) cb(exited);
37600
37634
  });
37601
37635
  return {
@@ -39962,7 +39996,18 @@ function runStreamJson(job, cfg) {
39962
39996
  const { finish, exited } = makeFinish(id, cfg, transcriptRefPtr, transcriptOut, dir, exitCbs);
39963
39997
  let killedByUs = false;
39964
39998
  let seq = 0;
39965
- child.stderr.pipe(transcriptOut);
39999
+ const stderrTail = [];
40000
+ const stderrRl = readline4.createInterface({ input: child.stderr });
40001
+ stderrRl.on("line", (line) => {
40002
+ try {
40003
+ transcriptOut.write(line + "\n");
40004
+ } catch {
40005
+ }
40006
+ stderrTail.push(line);
40007
+ while (stderrTail.length > 40) stderrTail.shift();
40008
+ let total = stderrTail.reduce((n, l) => n + l.length + 1, 0);
40009
+ while (total > 4e3 && stderrTail.length > 1) total -= stderrTail.shift().length + 1;
40010
+ });
39966
40011
  const state = cfg.createState();
39967
40012
  const rl = readline4.createInterface({ input: child.stdout });
39968
40013
  rl.on("line", (line) => {
@@ -39983,7 +40028,14 @@ function runStreamJson(job, cfg) {
39983
40028
  });
39984
40029
  child.on("exit", (code) => {
39985
40030
  clearTimeout(timer);
39986
- finish({ code: killedByUs ? null : code, reason: killedByUs ? "timeout" : code === 0 ? "clean" : "error", transcriptRef: transcriptRefPtr.value });
40031
+ const isError = !killedByUs && typeof code === "number" && code !== 0;
40032
+ const errorMessage = isError ? stderrTail.join("\n").trim().slice(-4e3) || void 0 : void 0;
40033
+ finish({
40034
+ code: killedByUs ? null : code,
40035
+ reason: killedByUs ? "timeout" : code === 0 ? "clean" : "error",
40036
+ transcriptRef: transcriptRefPtr.value,
40037
+ ...errorMessage ? { errorMessage } : {}
40038
+ });
39987
40039
  });
39988
40040
  const current = exited();
39989
40041
  return Promise.resolve({
@@ -40023,7 +40075,18 @@ function runOneShotText(job, cfg) {
40023
40075
  const text = chunk.toString("utf8");
40024
40076
  for (const cb of outputCbs) cb(text);
40025
40077
  });
40026
- child.stderr.pipe(transcriptOut);
40078
+ const stderrTail = [];
40079
+ const stderrRl = readline4.createInterface({ input: child.stderr });
40080
+ stderrRl.on("line", (line) => {
40081
+ try {
40082
+ transcriptOut.write(line + "\n");
40083
+ } catch {
40084
+ }
40085
+ stderrTail.push(line);
40086
+ while (stderrTail.length > 40) stderrTail.shift();
40087
+ let total = stderrTail.reduce((n, l) => n + l.length + 1, 0);
40088
+ while (total > 4e3 && stderrTail.length > 1) total -= stderrTail.shift().length + 1;
40089
+ });
40027
40090
  const timer = setTimeout(() => {
40028
40091
  killedByUs = true;
40029
40092
  child.kill("SIGKILL");
@@ -40034,7 +40097,14 @@ function runOneShotText(job, cfg) {
40034
40097
  });
40035
40098
  child.on("exit", (code) => {
40036
40099
  clearTimeout(timer);
40037
- finish({ code: killedByUs ? null : code, reason: killedByUs ? "timeout" : code === 0 ? "clean" : "error", transcriptRef: transcriptRefPtr.value });
40100
+ const isError = !killedByUs && typeof code === "number" && code !== 0;
40101
+ const errorMessage = isError ? stderrTail.join("\n").trim().slice(-4e3) || void 0 : void 0;
40102
+ finish({
40103
+ code: killedByUs ? null : code,
40104
+ reason: killedByUs ? "timeout" : code === 0 ? "clean" : "error",
40105
+ transcriptRef: transcriptRefPtr.value,
40106
+ ...errorMessage ? { errorMessage } : {}
40107
+ });
40038
40108
  });
40039
40109
  const current = exited();
40040
40110
  return Promise.resolve({
@@ -40790,7 +40860,7 @@ Write-Host " Remove : Unregister-ScheduledTask -TaskName 'OasisNode' -Confirm:$
40790
40860
  }
40791
40861
  function buildNpxCmd(p2) {
40792
40862
  const namePart = p2.nodeName ? ` --name ${p2.nodeName}` : "";
40793
- return `npm install -g --prefer-online --prefix ~/.oasis/npm-global oasis_test@latest && ~/.oasis/npm-global/bin/oasis start --server-ws ${p2.gatewayUrl}${namePart} --enroll-token ${p2.token}`;
40863
+ return `npx -y oasis_test@latest start --server-ws ${p2.gatewayUrl}${namePart} --enroll-token ${p2.token}`;
40794
40864
  }
40795
40865
  var init_connect_script = __esm({
40796
40866
  "../server/src/domains/nodes/connect-script.ts"() {
@@ -58701,7 +58771,7 @@ ${res.warning}`);
58701
58771
  }
58702
58772
 
58703
58773
  // src/index.ts
58704
- var PKG_VERSION = true ? "0.1.47" : "dev";
58774
+ var PKG_VERSION = true ? "0.1.48" : "dev";
58705
58775
  var OASIS_DIR = path19.join(os11.homedir(), ".oasis");
58706
58776
  var CONFIG_FILE = path19.join(OASIS_DIR, "node-config.json");
58707
58777
  var PID_FILE = path19.join(OASIS_DIR, "node.pid");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oasis_test",
3
- "version": "0.1.47",
3
+ "version": "0.1.48",
4
4
  "description": "Oasis node daemon + CLI — background daemon, auto-start, full server CLI",
5
5
  "bin": {
6
6
  "oasis": "./dist/index.js"