agent-phonon 0.2.0

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.
@@ -0,0 +1,96 @@
1
+ /**
2
+ * daemon 配置(bug-bash B4)。
3
+ *
4
+ * 一个 daemon 进程:一个设备 id、一个共享 sqlite、一个 HookBridge,
5
+ * 注册若干 adapter,连接若干 server(每个 server = 一个 tenant 连接)。
6
+ */
7
+ interface ServerConfig {
8
+ /** 服务端 ws/http URL。 */
9
+ url: string;
10
+ /** 本地自用放宽 policy(默认 false)。 */
11
+ trustLocal?: boolean;
12
+ /** 该连接的可选 device key(鉴权由 server 做,phonon 仅携带)。 */
13
+ deviceKey?: string;
14
+ }
15
+ interface AdapterConfig {
16
+ /** adapter 类型:openclaw-gateway | openclaw-cli。 */
17
+ type: "openclaw-gateway" | "openclaw-cli" | "claude-code" | "codex" | "hermes" | "opencode";
18
+ /** OpenClaw Gateway WS URL(openclaw-gateway 用)。 */
19
+ gatewayUrl?: string;
20
+ /** Gateway token(openclaw-gateway 用;缺省从 ~/.openclaw/openclaw.json 读)。 */
21
+ gatewayToken?: string;
22
+ /** 默认 OpenClaw sub-agent。 */
23
+ defaultAgent?: string;
24
+ /** claude-code:网关 baseUrl/token/默认模型。 */
25
+ claudeBaseUrl?: string;
26
+ claudeAuthToken?: string;
27
+ claudeDefaultModel?: string;
28
+ /** codex:网关 baseUrl(/v1)/key/默认模型/wireApi。 */
29
+ codexBaseUrl?: string;
30
+ codexApiKey?: string;
31
+ codexDefaultModel?: string;
32
+ codexWireApi?: "responses" | "chat";
33
+ /** hermes:默认模型/provider(用现有 hermes config)。 */
34
+ hermesModel?: string;
35
+ hermesProvider?: string;
36
+ /** opencode:binary 路径/默认模型。 */
37
+ opencodeBinPath?: string;
38
+ opencodeModel?: string;
39
+ }
40
+ interface DaemonConfig {
41
+ deviceId: string;
42
+ /** sqlite 文件路径。 */
43
+ dbPath: string;
44
+ /** 受控项目根。 */
45
+ workspaceRoot: string;
46
+ /** 结构化日志级别。 */
47
+ logLevel?: "debug" | "info" | "warn" | "error";
48
+ hookBridge?: {
49
+ port?: number;
50
+ token?: string;
51
+ };
52
+ /** 可观测 HTTP 服务。 */
53
+ obs?: {
54
+ enabled?: boolean;
55
+ port?: number;
56
+ token?: string;
57
+ };
58
+ adapters: AdapterConfig[];
59
+ servers: ServerConfig[];
60
+ }
61
+
62
+ /**
63
+ * PhononDaemon(bug-bash B4):设备侧常驻服务。
64
+ *
65
+ * 一个进程管理:共享 sqlite store、adapter registry、HookBridge,
66
+ * 以及到多个 server 的多条 PhononClient 连接(每个 server = 一个 tenant)。
67
+ *
68
+ * HookBridge 跨所有连接路由:sessionKey → 找到 owns 该 session 的连接。
69
+ */
70
+ declare class PhononDaemon {
71
+ private cfg;
72
+ private store;
73
+ private registry;
74
+ private clients;
75
+ private bridge?;
76
+ private gatewayAdapters;
77
+ private obs;
78
+ private metrics;
79
+ private obsServer?;
80
+ private startedAt;
81
+ constructor(cfg: DaemonConfig);
82
+ private registerAdapters;
83
+ /** 启动:起 HookBridge + 连所有 server(带自动重连)。 */
84
+ start(): Promise<void>;
85
+ /** 健康快照(/health)。 */
86
+ private health;
87
+ /** 所有连接的 session 快照(/sessions)。 */
88
+ private allSessions;
89
+ /** 可观测 HTTP 服务实际端口(测试/外部查询)。 */
90
+ get obsPort(): number;
91
+ /** HookBridge 路由:找到 owns 该 session 的连接。sessionKey 形如 agent:<sub>:phonon-<sessionId>。 */
92
+ private routeHook;
93
+ stop(): Promise<void>;
94
+ }
95
+
96
+ export { PhononDaemon };