@tunnelbox/dsh-tunnelbox 0.1.30 → 0.1.32

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.mjs +41 -11
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -3954,8 +3954,19 @@ import { join as join2 } from "node:path";
3954
3954
  function dshHome() {
3955
3955
  return process.env.DSH_HOME || join2(homedir2(), ".dsh");
3956
3956
  }
3957
- function release(prep) {
3958
- const p = prep;
3957
+ function headerOf(s) {
3958
+ if (s.header && typeof s.header.id === "string") return s.header;
3959
+ return { id: s.id ?? "", createdAt: s.createdAt ?? 0, cwd: s.cwd };
3960
+ }
3961
+ async function release(h) {
3962
+ const p = h;
3963
+ if (typeof p?.close === "function") {
3964
+ try {
3965
+ await p.close();
3966
+ } catch {
3967
+ }
3968
+ return;
3969
+ }
3959
3970
  const d = typeof p?.dispose === "function" ? p.dispose : typeof p?.[Symbol.dispose] === "function" ? p[Symbol.dispose] : void 0;
3960
3971
  if (typeof d === "function") {
3961
3972
  try {
@@ -3976,20 +3987,36 @@ function titleOf(events) {
3976
3987
  return sessionTitle(msgs) || "";
3977
3988
  }
3978
3989
  async function readSessionEvents(sp, sessionId) {
3990
+ if (typeof sp.open === "function") {
3991
+ const handle = await sp.open(sessionId, "read");
3992
+ try {
3993
+ const result = await handle.read();
3994
+ return [...result.events];
3995
+ } finally {
3996
+ await release(handle);
3997
+ }
3998
+ }
3979
3999
  if (typeof sp.inspect === "function") {
3980
4000
  const view = await sp.inspect(sessionId);
3981
4001
  return [...view.events ?? []];
3982
4002
  }
3983
- const prep = await sp.prepare(sessionId);
3984
- try {
3985
- return [...prep.session.events];
3986
- } finally {
3987
- release(prep);
4003
+ if (typeof sp.prepare === "function") {
4004
+ const prep = await sp.prepare(sessionId);
4005
+ try {
4006
+ return [...prep.session.events];
4007
+ } finally {
4008
+ await release(prep);
4009
+ }
3988
4010
  }
4011
+ return [];
3989
4012
  }
3990
4013
  async function sessionExists(sp, sessionId) {
4014
+ if (typeof sp.stat === "function") {
4015
+ const snap = await sp.stat(sessionId).catch(() => void 0);
4016
+ return !!snap;
4017
+ }
3991
4018
  const headers = await sp.list().catch(() => []);
3992
- return headers.some((h) => h.id === sessionId);
4019
+ return headers.some((h) => headerOf(h).id === sessionId);
3993
4020
  }
3994
4021
  async function sessionInfo(sp, h, t2) {
3995
4022
  let events = [];
@@ -4012,7 +4039,9 @@ async function sessionInfo(sp, h, t2) {
4012
4039
  async function listSessions(sp, workspace, t2) {
4013
4040
  const headers = await sp.list().catch(() => []);
4014
4041
  const out = [];
4015
- for (const h of headers) {
4042
+ for (const raw of headers) {
4043
+ const h = headerOf(raw);
4044
+ if (!h.id) continue;
4016
4045
  if (workspace && h.cwd !== workspace) continue;
4017
4046
  const s = await sessionInfo(sp, h, t2);
4018
4047
  if (s) out.push(s);
@@ -4022,7 +4051,8 @@ async function listSessions(sp, workspace, t2) {
4022
4051
  async function listWorkspaces(sp, current) {
4023
4052
  const headers = await sp.list().catch(() => []);
4024
4053
  const byPath = /* @__PURE__ */ new Map();
4025
- for (const h of headers) {
4054
+ for (const raw of headers) {
4055
+ const h = headerOf(raw);
4026
4056
  const p = h.cwd;
4027
4057
  if (!p) continue;
4028
4058
  const e = byPath.get(p) ?? { count: 0, updated: 0 };
@@ -4072,7 +4102,7 @@ function findDir(dir, name2) {
4072
4102
  }
4073
4103
 
4074
4104
  // src/bridge.ts
4075
- var VERSION = true ? "0.1.30" : "0.0.0-dev";
4105
+ var VERSION = true ? "0.1.32" : "0.0.0-dev";
4076
4106
  var AGENT_TYPE = "dsh";
4077
4107
  var APPROVAL_TIMEOUT_MS = 12e4;
4078
4108
  var ADAPTER_COMMANDS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tunnelbox/dsh-tunnelbox",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "tunnelbox 的 dsh 原生 Cordis 插件:手机远程驱动 DeepSeek Harness(agent/session/tools/审批/中止)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -36,7 +36,7 @@
36
36
  "@deepseek-ai/schemastery": "^3.18.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@tunnelbox/core": "0.1.30",
39
+ "@tunnelbox/core": "0.1.32",
40
40
  "@types/node": "^22.0.0",
41
41
  "esbuild": "^0.24.0",
42
42
  "typescript": "^5.4.5"