@clawos-dev/clawd 0.2.203-beta.406.d63010a → 0.2.203-beta.407.bb42013

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/cli.cjs +83 -39
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -40324,6 +40324,49 @@ var require_lib3 = __commonJS({
40324
40324
  }
40325
40325
  });
40326
40326
 
40327
+ // src/sshd/contact-ssh-log.ts
40328
+ function createContactSshLog(dataDir) {
40329
+ const file = import_node_path40.default.join(dataDir, "contact-ssh.log");
40330
+ function append(level, tag, message, meta) {
40331
+ const time = (/* @__PURE__ */ new Date()).toISOString();
40332
+ let line = `[${time}] [${level}] [${tag}] ${message}`;
40333
+ if (meta && Object.keys(meta).length > 0) {
40334
+ try {
40335
+ line += " " + JSON.stringify(meta);
40336
+ } catch {
40337
+ line += " [meta-serialize-failed]";
40338
+ }
40339
+ }
40340
+ line += "\n";
40341
+ try {
40342
+ import_node_fs39.default.mkdirSync(import_node_path40.default.dirname(file), { recursive: true });
40343
+ import_node_fs39.default.appendFileSync(file, line, { mode: 384 });
40344
+ } catch {
40345
+ }
40346
+ }
40347
+ return {
40348
+ info: (tag, message, meta) => append("INFO", tag, message, meta),
40349
+ warn: (tag, message, meta) => append("WARN", tag, message, meta),
40350
+ error: (tag, message, meta) => append("ERROR", tag, message, meta)
40351
+ };
40352
+ }
40353
+ var import_node_fs39, import_node_path40, nullContactSshLog;
40354
+ var init_contact_ssh_log = __esm({
40355
+ "src/sshd/contact-ssh-log.ts"() {
40356
+ "use strict";
40357
+ import_node_fs39 = __toESM(require("fs"), 1);
40358
+ import_node_path40 = __toESM(require("path"), 1);
40359
+ nullContactSshLog = {
40360
+ info: () => {
40361
+ },
40362
+ warn: () => {
40363
+ },
40364
+ error: () => {
40365
+ }
40366
+ };
40367
+ }
40368
+ });
40369
+
40327
40370
  // src/run-case/recorder.ts
40328
40371
  function startRunCaseRecorder(opts) {
40329
40372
  const now = opts.now ?? Date.now;
@@ -40700,13 +40743,22 @@ async function sshRelay(argv) {
40700
40743
  return 2;
40701
40744
  }
40702
40745
  const dataDir = args.dataDir ?? import_node_path66.default.join(import_node_os23.default.homedir(), ".clawd");
40746
+ const sshLog = createContactSshLog(dataDir);
40703
40747
  const contact = findContact(dataDir, args.peerDeviceId);
40704
40748
  if (!contact) {
40749
+ sshLog.error("relay.contact-not-found", "ssh-relay \u627E\u4E0D\u5230 peer contact", {
40750
+ peerDeviceId: args.peerDeviceId,
40751
+ contactsPath: import_node_path66.default.join(dataDir, "contacts.json")
40752
+ });
40705
40753
  process.stderr.write(`clawd ssh-relay: contact ${args.peerDeviceId} not found in ${dataDir}/contacts.json
40706
40754
  `);
40707
40755
  return 2;
40708
40756
  }
40709
40757
  if (!contact.connectToken) {
40758
+ sshLog.error("relay.token-missing", "contact \u6709\u8BB0\u5F55\u4F46\u7F3A connectToken\uFF08auto-reverse \u672A\u6362\u7968\uFF09", {
40759
+ peerDeviceId: args.peerDeviceId,
40760
+ peerDisplayName: contact.displayName
40761
+ });
40710
40762
  process.stderr.write(
40711
40763
  `clawd ssh-relay: contact ${args.peerDeviceId} has no connectToken (auto-reverse \u672A\u6362\u7968)
40712
40764
  `
@@ -40716,6 +40768,11 @@ async function sshRelay(argv) {
40716
40768
  const baseHttp = wsUrlToHttp(contact.remoteUrl).replace(/\/+$/, "");
40717
40769
  const wsBase = baseHttp.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
40718
40770
  const url = `${wsBase}/rpc/ssh-tunnel`;
40771
+ sshLog.info("relay.dial", "\u5F00\u59CB\u62E8 A \u4FA7 /rpc/ssh-tunnel", {
40772
+ peerDeviceId: args.peerDeviceId,
40773
+ peerDisplayName: contact.displayName,
40774
+ url
40775
+ });
40719
40776
  return new Promise((resolve6) => {
40720
40777
  const ws = new import_websocket.default(url, {
40721
40778
  headers: {
@@ -40735,6 +40792,9 @@ async function sshRelay(argv) {
40735
40792
  resolve6(exitCode);
40736
40793
  };
40737
40794
  ws.on("open", () => {
40795
+ sshLog.info("relay.dial-open", "ws open\uFF0C\u8FDB\u5165 stdio \u2194 ws \u4E2D\u7EE7", {
40796
+ peerDeviceId: args.peerDeviceId
40797
+ });
40738
40798
  process.stdin.on("data", (chunk) => {
40739
40799
  if (ws.readyState === ws.OPEN) {
40740
40800
  ws.send(chunk, { binary: true });
@@ -40759,9 +40819,25 @@ async function sshRelay(argv) {
40759
40819
  }
40760
40820
  });
40761
40821
  ws.on("close", (code) => {
40822
+ if (code === 1e3) {
40823
+ sshLog.info("relay.dial-close", "ws \u6B63\u5E38\u5173\u95ED", {
40824
+ peerDeviceId: args.peerDeviceId,
40825
+ code
40826
+ });
40827
+ } else {
40828
+ sshLog.warn("relay.dial-close-abnormal", "ws \u975E\u6B63\u5E38\u5173\u95ED\uFF08A \u4FA7\u62D2 auth / \u7F51\u7EDC\u65AD / peer \u5D29\uFF09", {
40829
+ peerDeviceId: args.peerDeviceId,
40830
+ code
40831
+ });
40832
+ }
40762
40833
  settle(code === 1e3 ? 0 : 1);
40763
40834
  });
40764
40835
  ws.on("error", (err) => {
40836
+ sshLog.error("relay.dial-error", "ws \u8FDE\u63A5\u9519\u8BEF\uFF08peer \u4E0D\u53EF\u8FBE / \u7AEF\u53E3\u4E0D\u901A / TLS \u5931\u8D25\uFF09", {
40837
+ peerDeviceId: args.peerDeviceId,
40838
+ url,
40839
+ message: err.message
40840
+ });
40765
40841
  process.stderr.write(`clawd ssh-relay: ws error ${err.message}
40766
40842
  `);
40767
40843
  settle(1);
@@ -40824,6 +40900,7 @@ var init_sshd_cli_relay = __esm({
40824
40900
  init_wrapper();
40825
40901
  init_src();
40826
40902
  init_peer_forward();
40903
+ init_contact_ssh_log();
40827
40904
  SSH_RELAY_HELP = `clawd ssh-relay <peer-device-id> [options]
40828
40905
 
40829
40906
  WebSocket relay to a peer daemon's /rpc/ssh-tunnel, exposing raw SSH bytes on
@@ -53528,45 +53605,7 @@ function readIssuedPubkey(sshdDir, deviceId) {
53528
53605
  var import_node_fs40 = __toESM(require("fs"), 1);
53529
53606
  var import_node_path41 = __toESM(require("path"), 1);
53530
53607
  init_peer_forward();
53531
-
53532
- // src/sshd/contact-ssh-log.ts
53533
- var import_node_fs39 = __toESM(require("fs"), 1);
53534
- var import_node_path40 = __toESM(require("path"), 1);
53535
- function createContactSshLog(dataDir) {
53536
- const file = import_node_path40.default.join(dataDir, "contact-ssh.log");
53537
- function append(level, tag, message, meta) {
53538
- const time = (/* @__PURE__ */ new Date()).toISOString();
53539
- let line = `[${time}] [${level}] [${tag}] ${message}`;
53540
- if (meta && Object.keys(meta).length > 0) {
53541
- try {
53542
- line += " " + JSON.stringify(meta);
53543
- } catch {
53544
- line += " [meta-serialize-failed]";
53545
- }
53546
- }
53547
- line += "\n";
53548
- try {
53549
- import_node_fs39.default.mkdirSync(import_node_path40.default.dirname(file), { recursive: true });
53550
- import_node_fs39.default.appendFileSync(file, line, { mode: 384 });
53551
- } catch {
53552
- }
53553
- }
53554
- return {
53555
- info: (tag, message, meta) => append("INFO", tag, message, meta),
53556
- warn: (tag, message, meta) => append("WARN", tag, message, meta),
53557
- error: (tag, message, meta) => append("ERROR", tag, message, meta)
53558
- };
53559
- }
53560
- var nullContactSshLog = {
53561
- info: () => {
53562
- },
53563
- warn: () => {
53564
- },
53565
- error: () => {
53566
- }
53567
- };
53568
-
53569
- // src/sshd/contact-key-puller.ts
53608
+ init_contact_ssh_log();
53570
53609
  var CONTACT_KEYS_DIR = "contact-ssh-keys";
53571
53610
  function safeContactKeyPath(dataDir, deviceId) {
53572
53611
  const safeId = deviceId.replace(/[\/\\]/g, "_");
@@ -53678,6 +53717,7 @@ var ContactKeyPuller = class {
53678
53717
 
53679
53718
  // src/sshd/ssh-tunnel-relay.ts
53680
53719
  var import_node_net2 = __toESM(require("net"), 1);
53720
+ init_contact_ssh_log();
53681
53721
  async function handleSshTunnelUpgrade(req, socket, head, deps) {
53682
53722
  const sshLog = deps.sshLog ?? nullContactSshLog;
53683
53723
  const clientAddr = (req.socket && "remoteAddress" in req.socket ? req.socket.remoteAddress : null) ?? "unknown";
@@ -53785,6 +53825,9 @@ function pumpWsToSshd(ws, deps, clientAddr) {
53785
53825
  });
53786
53826
  }
53787
53827
 
53828
+ // src/index.ts
53829
+ init_contact_ssh_log();
53830
+
53788
53831
  // src/tunnel/device-key.ts
53789
53832
  var import_node_os14 = __toESM(require("os"), 1);
53790
53833
  var import_node_path42 = __toESM(require("path"), 1);
@@ -55399,6 +55442,7 @@ async function issueContactSshKey(deviceId, sshdDir, opts = {}) {
55399
55442
  }
55400
55443
 
55401
55444
  // src/handlers/contact-ssh.ts
55445
+ init_contact_ssh_log();
55402
55446
  function ensureOwner2(ctx) {
55403
55447
  if (!ctx || ctx.principal.kind !== "owner") {
55404
55448
  throw new ClawdError(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.203-beta.406.d63010a",
3
+ "version": "0.2.203-beta.407.bb42013",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",