@tunnelbox/core 0.1.18 → 0.1.21

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.
package/src/state.ts CHANGED
@@ -9,7 +9,7 @@ import { randomBytes } from "node:crypto";
9
9
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
10
10
  import { homedir } from "node:os";
11
11
  import { dirname, join } from "node:path";
12
- import { normalizeLang, type Lang } from "./i18n";
12
+ import { normalizeLang, resolveLang, t, type Lang } from "./i18n";
13
13
 
14
14
  export interface State {
15
15
  agentId: string;
@@ -39,7 +39,7 @@ export function saveState(st: State, type?: string): void {
39
39
  mkdirSync(dirname(p), { recursive: true });
40
40
  writeFileSync(p, JSON.stringify(st, null, 2), "utf8");
41
41
  } catch (e) {
42
- console.error("[tunnelbox] 保存状态失败", e);
42
+ console.error(`[tunnelbox] ${t(st.lang ?? resolveLang(), "state.errSaveState")}`, e);
43
43
  }
44
44
  }
45
45
 
@@ -70,12 +70,13 @@ export function loadState(type?: string): State {
70
70
  }
71
71
  }
72
72
 
73
- /** 把配对码写入本地文件,作为终端日志被吞时的兜底。 */
74
- export function writePairingFile(code: string, type?: string): string {
73
+ /** 把配对码写入本地文件,作为终端日志被吞时的兜底。文案走 i18n(lang 缺省按系统解析)。 */
74
+ export function writePairingFile(code: string, type?: string, lang?: Lang): string {
75
75
  const p = join(baseName(), `remote-pairing${suffix(type)}.txt`);
76
76
  try {
77
77
  mkdirSync(dirname(p), { recursive: true });
78
- writeFileSync(p, `配对码: ${code}\n`, "utf8");
78
+ const label = t(lang ?? resolveLang(), "qr.codeLabel");
79
+ writeFileSync(p, `${label}: ${code}\n`, "utf8");
79
80
  } catch {
80
81
  /* ignore */
81
82
  }
package/src/types.ts CHANGED
@@ -34,6 +34,8 @@ export interface AgentInfo {
34
34
  permission?: boolean;
35
35
  commands?: boolean;
36
36
  abort?: boolean;
37
+ /** 支持结构化提问(question.request / question.reply) */
38
+ questions?: boolean;
37
39
  };
38
40
  }
39
41