@agentdeck/shared 0.1.0 → 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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapter.d.ts +16 -3
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/adapter.js +38 -0
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/command-builders.d.ts +30 -0
  7. package/dist/command-builders.d.ts.map +1 -0
  8. package/dist/command-builders.js +60 -0
  9. package/dist/command-builders.js.map +1 -0
  10. package/dist/eval-schema.d.ts +211 -0
  11. package/dist/eval-schema.d.ts.map +1 -0
  12. package/dist/eval-schema.js +23 -0
  13. package/dist/eval-schema.js.map +1 -0
  14. package/dist/format-utils.d.ts +27 -0
  15. package/dist/format-utils.d.ts.map +1 -0
  16. package/dist/format-utils.js +120 -0
  17. package/dist/format-utils.js.map +1 -0
  18. package/dist/gateway-protocol.d.ts +391 -0
  19. package/dist/gateway-protocol.d.ts.map +1 -0
  20. package/dist/gateway-protocol.js +19 -0
  21. package/dist/gateway-protocol.js.map +1 -0
  22. package/dist/index.d.ts +11 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +11 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/llm-settings.d.ts +52 -0
  27. package/dist/llm-settings.d.ts.map +1 -0
  28. package/dist/llm-settings.js +118 -0
  29. package/dist/llm-settings.js.map +1 -0
  30. package/dist/protocol.d.ts +326 -2
  31. package/dist/protocol.d.ts.map +1 -1
  32. package/dist/protocol.js +19 -0
  33. package/dist/protocol.js.map +1 -1
  34. package/dist/session-utils.d.ts +62 -0
  35. package/dist/session-utils.d.ts.map +1 -0
  36. package/dist/session-utils.js +109 -0
  37. package/dist/session-utils.js.map +1 -0
  38. package/dist/state-colors.d.ts +16 -0
  39. package/dist/state-colors.d.ts.map +1 -0
  40. package/dist/state-colors.js +46 -0
  41. package/dist/state-colors.js.map +1 -0
  42. package/dist/states.d.ts +1 -0
  43. package/dist/states.d.ts.map +1 -1
  44. package/dist/svg-renderers/agent-logos.d.ts +33 -0
  45. package/dist/svg-renderers/agent-logos.d.ts.map +1 -0
  46. package/dist/svg-renderers/agent-logos.js +100 -0
  47. package/dist/svg-renderers/agent-logos.js.map +1 -0
  48. package/dist/svg-renderers/index.d.ts +4 -0
  49. package/dist/svg-renderers/index.d.ts.map +1 -0
  50. package/dist/svg-renderers/index.js +4 -0
  51. package/dist/svg-renderers/index.js.map +1 -0
  52. package/dist/svg-renderers/session-slot-renderer.d.ts +25 -0
  53. package/dist/svg-renderers/session-slot-renderer.d.ts.map +1 -0
  54. package/dist/svg-renderers/session-slot-renderer.js +317 -0
  55. package/dist/svg-renderers/session-slot-renderer.js.map +1 -0
  56. package/dist/svg-renderers/text-utils.d.ts +15 -0
  57. package/dist/svg-renderers/text-utils.d.ts.map +1 -0
  58. package/dist/svg-renderers/text-utils.js +88 -0
  59. package/dist/svg-renderers/text-utils.js.map +1 -0
  60. package/dist/telemetry-envelope.d.ts +108 -0
  61. package/dist/telemetry-envelope.d.ts.map +1 -0
  62. package/dist/telemetry-envelope.js +34 -0
  63. package/dist/telemetry-envelope.js.map +1 -0
  64. package/dist/timeline-summarizer.d.ts +13 -0
  65. package/dist/timeline-summarizer.d.ts.map +1 -0
  66. package/dist/timeline-summarizer.js +83 -0
  67. package/dist/timeline-summarizer.js.map +1 -0
  68. package/dist/timeline.d.ts +65 -0
  69. package/dist/timeline.d.ts.map +1 -0
  70. package/dist/timeline.js +456 -0
  71. package/dist/timeline.js.map +1 -0
  72. package/dist/voice-paths.d.ts +4 -0
  73. package/dist/voice-paths.d.ts.map +1 -1
  74. package/dist/voice-paths.js +5 -0
  75. package/dist/voice-paths.js.map +1 -1
  76. package/package.json +9 -3
@@ -0,0 +1,391 @@
1
+ /**
2
+ * OpenClaw Gateway WebSocket protocol — single source of truth.
3
+ *
4
+ * Wire shape: JSON-encoded frames with a `type` discriminator (`req`/`res`/`event`).
5
+ * Auth: Ed25519 device signature over
6
+ * `v3|deviceId|clientId|clientMode|role|scopes|signedAtMs|token|nonce|platform|deviceFamily`.
7
+ * Bridge implementation: `bridge/src/adapters/openclaw.ts` (Node) / `apple/AgentDeck/Daemon/Modules/OpenClawAdapter.swift` (Swift).
8
+ *
9
+ * This file is used by `scripts/generate-protocol.sh` to emit Swift/Kotlin bindings
10
+ * under `generated/protocol/`, ensuring protocol parity across the three implementations.
11
+ */
12
+ /** Protocol major version. Bridge rejects mismatched Gateway versions. */
13
+ export declare const GATEWAY_PROTOCOL_VERSION = 3;
14
+ /** Default Gateway port (OpenClaw backend). */
15
+ export declare const GATEWAY_DEFAULT_PORT = 18789;
16
+ /** Ed25519 SPKI DER prefix length (bytes before the raw 32-byte key). */
17
+ export declare const ED25519_SPKI_PREFIX_LEN = 12;
18
+ /** Client → Gateway: RPC request. */
19
+ export interface GatewayRequestFrame {
20
+ type: 'req';
21
+ id: string;
22
+ method: GatewayMethodName;
23
+ params: GatewayMethodParams;
24
+ }
25
+ /** Gateway → Client: RPC response (ok=true) or error (ok=false). */
26
+ export interface GatewayResponseFrame {
27
+ type: 'res';
28
+ id: string;
29
+ ok: boolean;
30
+ payload?: GatewayMethodResult;
31
+ error?: GatewayError;
32
+ }
33
+ /** Gateway → Client: unsolicited event. */
34
+ export interface GatewayEventFrame {
35
+ type: 'event';
36
+ event: GatewayEventName;
37
+ payload: GatewayEventPayload;
38
+ /** Monotonic sequence number (optional, used for ordering on reconnect). */
39
+ seq?: string;
40
+ /** Server-side state version for dedup on replay. */
41
+ stateVersion?: string;
42
+ }
43
+ export type GatewayFrame = GatewayRequestFrame | GatewayResponseFrame | GatewayEventFrame;
44
+ export interface GatewayError {
45
+ code: string;
46
+ message: string;
47
+ details?: unknown;
48
+ }
49
+ export type GatewayMethodName = 'connect' | 'health' | 'models.list' | 'logs.tail' | 'chat.send' | 'chat.abort' | 'exec.approval.resolve' | 'sessions.list' | 'sessions.subscribe' | 'sessions.messages.subscribe' | 'system-presence';
50
+ export type GatewayMethodParams = ConnectParams | HealthParams | ModelsListParams | LogsTailParams | ChatSendParams | ChatAbortParams | ExecApprovalResolveParams | SessionsListParams | SessionsSubscribeParams | SessionsMessagesSubscribeParams | SystemPresenceParams;
51
+ export type GatewayMethodResult = ConnectResult | HealthResult | ModelsListResult | LogsTailResult | ChatSendResult | ChatAbortResult | ExecApprovalResolveResult | SessionsListResult | SessionsSubscribeResult | SessionsMessagesSubscribeResult | SystemPresenceResult;
52
+ export interface ConnectParams {
53
+ /** Lower bound of protocol versions this client supports. */
54
+ minProtocol: number;
55
+ /** Upper bound of protocol versions this client supports. */
56
+ maxProtocol: number;
57
+ client: {
58
+ id: string;
59
+ displayName: string;
60
+ version: string;
61
+ platform: string;
62
+ deviceFamily?: string;
63
+ mode: 'backend' | 'frontend' | 'operator' | 'node';
64
+ instanceId?: string;
65
+ };
66
+ role: string;
67
+ scopes: string[];
68
+ caps: string[];
69
+ commands?: string[];
70
+ permissions?: Record<string, boolean>;
71
+ locale?: string;
72
+ userAgent?: string;
73
+ /** Ed25519 device signature over `v3|deviceId|clientId|clientMode|role|scopes|signedAtMs|token|nonce|platform|deviceFamily`. */
74
+ device?: DeviceAuth;
75
+ /** Bearer token issued during device pairing. */
76
+ auth?: {
77
+ token?: string;
78
+ bootstrapToken?: string;
79
+ deviceToken?: string;
80
+ password?: string;
81
+ };
82
+ }
83
+ export interface ConnectResult {
84
+ type?: 'hello-ok';
85
+ accepted?: boolean;
86
+ protocol?: number;
87
+ server?: {
88
+ version: string;
89
+ connId: string;
90
+ };
91
+ features?: {
92
+ methods: string[];
93
+ events: string[];
94
+ };
95
+ auth?: {
96
+ deviceToken: string;
97
+ role: string;
98
+ scopes: string[];
99
+ issuedAtMs?: number;
100
+ deviceTokens?: Array<{
101
+ deviceToken: string;
102
+ role: string;
103
+ scopes: string[];
104
+ issuedAtMs?: number;
105
+ }>;
106
+ };
107
+ policy?: {
108
+ tickIntervalMs?: number;
109
+ maxPayload?: number;
110
+ };
111
+ sessionToken?: string;
112
+ expiresAt?: number;
113
+ }
114
+ export interface DeviceAuth {
115
+ id: string;
116
+ publicKey: string;
117
+ signature: string;
118
+ signedAt: number;
119
+ nonce: string;
120
+ }
121
+ export interface HealthParams {
122
+ probe?: boolean;
123
+ }
124
+ export interface HealthResult {
125
+ ok?: boolean;
126
+ ts?: number;
127
+ durationMs?: number;
128
+ status?: string;
129
+ checks?: Array<{
130
+ id?: string;
131
+ name?: string;
132
+ status?: string;
133
+ message?: string;
134
+ }>;
135
+ [key: string]: unknown;
136
+ }
137
+ export interface ModelsListParams {
138
+ }
139
+ export interface ModelsListResult {
140
+ models: OpenClawModel[];
141
+ }
142
+ export interface OpenClawModel {
143
+ key?: string;
144
+ id?: string;
145
+ name?: string;
146
+ provider?: string;
147
+ title?: string;
148
+ available?: boolean;
149
+ missing?: boolean;
150
+ tags?: string[];
151
+ [key: string]: unknown;
152
+ }
153
+ export interface LogsTailParams {
154
+ cursor?: number;
155
+ limit?: number;
156
+ maxBytes?: number;
157
+ }
158
+ export interface LogsTailResult {
159
+ file?: string;
160
+ cursor?: number;
161
+ size?: number;
162
+ lines: string[];
163
+ truncated?: boolean;
164
+ reset?: boolean;
165
+ }
166
+ export interface ChatSendParams {
167
+ sessionKey: string;
168
+ message: string;
169
+ idempotencyKey: string;
170
+ }
171
+ export interface ChatSendResult {
172
+ runId?: string;
173
+ accepted: boolean;
174
+ }
175
+ export interface ChatAbortParams {
176
+ sessionKey: string;
177
+ runId?: string;
178
+ }
179
+ export interface ChatAbortResult {
180
+ aborted: boolean;
181
+ }
182
+ export interface ExecApprovalResolveParams {
183
+ id: string;
184
+ decision: 'allow' | 'deny';
185
+ }
186
+ export interface ExecApprovalResolveResult {
187
+ resolved: boolean;
188
+ }
189
+ export interface SessionsListParams {
190
+ kind?: string;
191
+ }
192
+ export interface SessionsListResult {
193
+ sessions: GatewaySession[];
194
+ }
195
+ export interface SessionsSubscribeParams {
196
+ }
197
+ export interface SessionsSubscribeResult {
198
+ subscribed: boolean;
199
+ }
200
+ export interface SessionsMessagesSubscribeParams {
201
+ key: string;
202
+ }
203
+ export interface SessionsMessagesSubscribeResult {
204
+ subscribed: boolean;
205
+ key: string;
206
+ }
207
+ export interface SystemPresenceParams {
208
+ }
209
+ export interface SystemPresenceResult {
210
+ entries?: GatewayPresenceEntry[];
211
+ devices?: GatewayPresenceEntry[];
212
+ [key: string]: unknown;
213
+ }
214
+ export interface GatewaySession {
215
+ key: string;
216
+ kind?: string;
217
+ label?: string;
218
+ displayName?: string;
219
+ updatedAt?: number;
220
+ sessionId?: string;
221
+ }
222
+ /**
223
+ * Method-name → params/result correlation. `rpcCall` in the Node adapter uses
224
+ * this to enforce that callers pass the correct params shape for each method
225
+ * and to infer the result type from the method name.
226
+ *
227
+ * When adding a new method: declare its ParamsType and ResultType above,
228
+ * extend `GatewayMethodName`, and add the entry here. Build-time errors
229
+ * pinpoint every call site that needs an update.
230
+ */
231
+ export interface GatewayMethodMap {
232
+ connect: {
233
+ params: ConnectParams;
234
+ result: ConnectResult;
235
+ };
236
+ health: {
237
+ params: HealthParams;
238
+ result: HealthResult;
239
+ };
240
+ 'models.list': {
241
+ params: ModelsListParams;
242
+ result: ModelsListResult;
243
+ };
244
+ 'logs.tail': {
245
+ params: LogsTailParams;
246
+ result: LogsTailResult;
247
+ };
248
+ 'chat.send': {
249
+ params: ChatSendParams;
250
+ result: ChatSendResult;
251
+ };
252
+ 'chat.abort': {
253
+ params: ChatAbortParams;
254
+ result: ChatAbortResult;
255
+ };
256
+ 'exec.approval.resolve': {
257
+ params: ExecApprovalResolveParams;
258
+ result: ExecApprovalResolveResult;
259
+ };
260
+ 'sessions.list': {
261
+ params: SessionsListParams;
262
+ result: SessionsListResult;
263
+ };
264
+ 'sessions.subscribe': {
265
+ params: SessionsSubscribeParams;
266
+ result: SessionsSubscribeResult;
267
+ };
268
+ 'sessions.messages.subscribe': {
269
+ params: SessionsMessagesSubscribeParams;
270
+ result: SessionsMessagesSubscribeResult;
271
+ };
272
+ 'system-presence': {
273
+ params: SystemPresenceParams;
274
+ result: SystemPresenceResult;
275
+ };
276
+ }
277
+ export type GatewayEventName = 'connect.challenge' | 'chat' | 'health' | 'session.message' | 'session.tool' | 'sessions.changed' | 'exec.approval.requested' | 'exec.approval.resolved' | 'presence' | 'system-presence' | 'tick' | 'shutdown';
278
+ export type GatewayEventPayload = ConnectChallengePayload | ChatEventPayload | HealthResult | SessionMessagePayload | SessionToolPayload | SessionsChangedPayload | ExecApprovalRequestedPayload | ExecApprovalResolvedPayload | PresencePayload | SystemPresenceResult | TickPayload | ShutdownPayload;
279
+ export interface ConnectChallengePayload {
280
+ nonce: string;
281
+ expiresAt?: number;
282
+ }
283
+ export interface ChatEventPayload {
284
+ state: 'delta' | 'final' | 'aborted' | 'error';
285
+ runId?: string;
286
+ sessionKey?: string;
287
+ /** Incremental text chunk (delta state). */
288
+ delta?: string;
289
+ /** Full assembled response (final state). */
290
+ response?: string;
291
+ /** Tool invocations observed in this turn. */
292
+ tools?: ChatToolInvocation[];
293
+ /** User prompt text, as echoed by Gateway on first delta. */
294
+ prompt?: string;
295
+ /** Error message (error state). */
296
+ error?: string;
297
+ /** Model identifier used for this turn. */
298
+ modelId?: string;
299
+ /** Token accounting (final state). */
300
+ inputTokens?: number;
301
+ outputTokens?: number;
302
+ /** Session identifier when Gateway creates a new session mid-chat. */
303
+ newSessionId?: string;
304
+ }
305
+ export interface ChatToolInvocation {
306
+ name: string;
307
+ input?: unknown;
308
+ output?: unknown;
309
+ status?: 'pending' | 'success' | 'error';
310
+ }
311
+ export interface ExecApprovalRequestedPayload {
312
+ id: string;
313
+ sessionKey?: string;
314
+ tool: string;
315
+ command?: string;
316
+ reason?: string;
317
+ /** Options surfaced to the user (default: allow/deny). */
318
+ options?: Array<{
319
+ key: string;
320
+ label: string;
321
+ }>;
322
+ }
323
+ export interface ExecApprovalResolvedPayload {
324
+ id: string;
325
+ decision: 'allow' | 'deny' | 'timeout';
326
+ sessionKey?: string;
327
+ }
328
+ export interface GatewayPresenceEntry {
329
+ connected: boolean;
330
+ clientId?: string;
331
+ deviceId?: string;
332
+ roles?: string[];
333
+ scopes?: string[];
334
+ displayName?: string;
335
+ [key: string]: unknown;
336
+ }
337
+ export interface PresencePayload {
338
+ connected?: boolean;
339
+ clientId?: string;
340
+ deviceId?: string;
341
+ entries?: GatewayPresenceEntry[];
342
+ devices?: GatewayPresenceEntry[];
343
+ [key: string]: unknown;
344
+ }
345
+ export interface SessionsChangedPayload {
346
+ sessions?: GatewaySession[];
347
+ key?: string;
348
+ sessionKey?: string;
349
+ reason?: string;
350
+ }
351
+ export interface SessionMessagePayload {
352
+ key?: string;
353
+ sessionKey?: string;
354
+ role?: string;
355
+ text?: string;
356
+ content?: string;
357
+ message?: unknown;
358
+ ts?: number;
359
+ [key: string]: unknown;
360
+ }
361
+ export interface SessionToolPayload {
362
+ key?: string;
363
+ sessionKey?: string;
364
+ name?: string;
365
+ tool?: string;
366
+ input?: unknown;
367
+ output?: unknown;
368
+ status?: string;
369
+ ts?: number;
370
+ [key: string]: unknown;
371
+ }
372
+ export interface TickPayload {
373
+ serverTime: number;
374
+ }
375
+ export interface ShutdownPayload {
376
+ reason?: string;
377
+ restartAt?: number;
378
+ }
379
+ /** On-disk identity, loaded from `~/.openclaw/identity/device.json`. */
380
+ export interface DeviceIdentity {
381
+ deviceId: string;
382
+ publicKeyPem: string;
383
+ privateKeyPem: string;
384
+ }
385
+ /** Loaded from `~/.openclaw/identity/device-auth.json` → `tokens.operator`. */
386
+ export interface DeviceAuthToken {
387
+ token: string;
388
+ role: string;
389
+ scopes: string[];
390
+ }
391
+ //# sourceMappingURL=gateway-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-protocol.d.ts","sourceRoot":"","sources":["../src/gateway-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,IAAI,CAAC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ACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,+EAA+E;AAC/E,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * OpenClaw Gateway WebSocket protocol — single source of truth.
3
+ *
4
+ * Wire shape: JSON-encoded frames with a `type` discriminator (`req`/`res`/`event`).
5
+ * Auth: Ed25519 device signature over
6
+ * `v3|deviceId|clientId|clientMode|role|scopes|signedAtMs|token|nonce|platform|deviceFamily`.
7
+ * Bridge implementation: `bridge/src/adapters/openclaw.ts` (Node) / `apple/AgentDeck/Daemon/Modules/OpenClawAdapter.swift` (Swift).
8
+ *
9
+ * This file is used by `scripts/generate-protocol.sh` to emit Swift/Kotlin bindings
10
+ * under `generated/protocol/`, ensuring protocol parity across the three implementations.
11
+ */
12
+ // ===== Protocol version =====
13
+ /** Protocol major version. Bridge rejects mismatched Gateway versions. */
14
+ export const GATEWAY_PROTOCOL_VERSION = 3;
15
+ /** Default Gateway port (OpenClaw backend). */
16
+ export const GATEWAY_DEFAULT_PORT = 18789;
17
+ /** Ed25519 SPKI DER prefix length (bytes before the raw 32-byte key). */
18
+ export const ED25519_SPKI_PREFIX_LEN = 12;
19
+ //# sourceMappingURL=gateway-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-protocol.js","sourceRoot":"","sources":["../src/gateway-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,+BAA+B;AAE/B,0EAA0E;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,yEAAyE;AACzE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,17 @@
1
1
  export * from './states.js';
2
2
  export * from './protocol.js';
3
+ export * from './gateway-protocol.js';
4
+ export * from './command-builders.js';
3
5
  export * from './adapter.js';
4
6
  export * from './voice-paths.js';
5
7
  export * from './net-utils.js';
8
+ export * from './timeline.js';
9
+ export * from './format-utils.js';
10
+ export * from './timeline-summarizer.js';
11
+ export * from './session-utils.js';
12
+ export * from './state-colors.js';
13
+ export * from './svg-renderers/index.js';
14
+ export * from './llm-settings.js';
15
+ export * from './eval-schema.js';
16
+ export * from './telemetry-envelope.js';
6
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,17 @@
1
1
  export * from './states.js';
2
2
  export * from './protocol.js';
3
+ export * from './gateway-protocol.js';
4
+ export * from './command-builders.js';
3
5
  export * from './adapter.js';
4
6
  export * from './voice-paths.js';
5
7
  export * from './net-utils.js';
8
+ export * from './timeline.js';
9
+ export * from './format-utils.js';
10
+ export * from './timeline-summarizer.js';
11
+ export * from './session-utils.js';
12
+ export * from './state-colors.js';
13
+ export * from './svg-renderers/index.js';
14
+ export * from './llm-settings.js';
15
+ export * from './eval-schema.js';
16
+ export * from './telemetry-envelope.js';
6
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * MLX model pin loader — single source of truth for which MLX model
3
+ * AgentDeck uses across probe, timeline summarizer, label summarizer,
4
+ * and APME judge.
5
+ *
6
+ * Source: ~/.agentdeck/settings.json → `llm.mlx.{endpoint,model}`.
7
+ * Falls back to legacy `apme.judge.{endpoint,model}` for backward compat.
8
+ * Placeholder model ids ("qwen3-30b", "default", empty) are treated as unset.
9
+ *
10
+ * Mirrored in Swift by apple/AgentDeck/Daemon/Apme/ApmeSettings.swift
11
+ * (LlmMlxConfig). Keep the two in sync when fields change.
12
+ */
13
+ /** Final fallback when neither settings nor probe yield a model id. */
14
+ export declare const MLX_FALLBACK_MODEL = "mlx-community/Qwen3.6-35B-A3B-4bit";
15
+ export interface MlxSettings {
16
+ /** Base URL (no /chat/completions suffix). */
17
+ endpoint: string;
18
+ /** Pinned model id, or null when user hasn't chosen one. */
19
+ model: string | null;
20
+ }
21
+ export declare function loadMlxSettings(): MlxSettings;
22
+ /** Force a reload on next call — used by tests and after settings writes. */
23
+ export declare function clearMlxSettingsCache(): void;
24
+ /**
25
+ * Resolve the MLX model id for an actual inference call.
26
+ * Priority: pinned settings → caller-supplied probe result → hardcoded fallback.
27
+ */
28
+ export declare function resolveMlxModel(probeFirst?: string | null): string;
29
+ /**
30
+ * Pick one model id from a live probe catalog. Returns `null` when the
31
+ * server is unreachable or advertises no usable model — UI should render
32
+ * "MLX · Not detected" rather than silently masquerading the fallback as
33
+ * active (the fallback id won't exist on the user's disk and every
34
+ * summarize call would fail).
35
+ *
36
+ * Priority — mirrors the 4-layer policy documented in CLAUDE.md:
37
+ * 1. caller-supplied pin if present in catalog
38
+ * 2. `MLX_FALLBACK_MODEL` (3.6 family) if present in catalog — keeps the
39
+ * codebase's chosen default in sync with what the dashboard advertises
40
+ * 3. first catalog entry (preserves the `auto-pick first` behavior added
41
+ * in commit 2b7b38b3 for the many-models case)
42
+ * 4. null — no catalog
43
+ */
44
+ export declare function pickMlxModel(catalog: string[] | null | undefined, pin?: string | null): string | null;
45
+ /**
46
+ * Return a full chat-completions URL for the configured endpoint.
47
+ * MLX-VLM uses `/chat/completions`; MLX-LM historically also answers on
48
+ * `/v1/chat/completions`. We use the non-v1 path to match existing callers
49
+ * (timeline-summarizer, label-summarizer, apme runner all hit /chat/completions).
50
+ */
51
+ export declare function mlxChatUrl(): string;
52
+ //# sourceMappingURL=llm-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-settings.d.ts","sourceRoot":"","sources":["../src/llm-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,uCAAuC,CAAC;AAIvE,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAqBD,wBAAgB,eAAe,IAAI,WAAW,CAqC7C;AAED,6EAA6E;AAC7E,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAKlE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,EACpC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAClB,MAAM,GAAG,IAAI,CAKf;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * MLX model pin loader — single source of truth for which MLX model
3
+ * AgentDeck uses across probe, timeline summarizer, label summarizer,
4
+ * and APME judge.
5
+ *
6
+ * Source: ~/.agentdeck/settings.json → `llm.mlx.{endpoint,model}`.
7
+ * Falls back to legacy `apme.judge.{endpoint,model}` for backward compat.
8
+ * Placeholder model ids ("qwen3-30b", "default", empty) are treated as unset.
9
+ *
10
+ * Mirrored in Swift by apple/AgentDeck/Daemon/Apme/ApmeSettings.swift
11
+ * (LlmMlxConfig). Keep the two in sync when fields change.
12
+ */
13
+ import { readFileSync } from 'fs';
14
+ import { join } from 'path';
15
+ import { homedir } from 'os';
16
+ const DEFAULT_ENDPOINT = 'http://127.0.0.1:8800';
17
+ /** Final fallback when neither settings nor probe yield a model id. */
18
+ export const MLX_FALLBACK_MODEL = 'mlx-community/Qwen3.6-35B-A3B-4bit';
19
+ const PLACEHOLDER_MODEL_IDS = new Set(['', 'default', 'qwen3-30b']);
20
+ let cached = null;
21
+ const CACHE_TTL_MS = 30_000;
22
+ function settingsPath() {
23
+ const dir = process.env.AGENTDECK_DATA_DIR || join(homedir(), '.agentdeck');
24
+ return join(dir, 'settings.json');
25
+ }
26
+ function isPlaceholder(m) {
27
+ if (typeof m !== 'string')
28
+ return true;
29
+ return PLACEHOLDER_MODEL_IDS.has(m.trim());
30
+ }
31
+ function stripChatSuffix(url) {
32
+ return url
33
+ .replace(/\/v1\/chat\/completions$/, '')
34
+ .replace(/\/chat\/completions$/, '');
35
+ }
36
+ export function loadMlxSettings() {
37
+ if (cached && Date.now() - cached.at < CACHE_TTL_MS) {
38
+ return cached.value;
39
+ }
40
+ let endpoint = DEFAULT_ENDPOINT;
41
+ let model = null;
42
+ try {
43
+ const raw = JSON.parse(readFileSync(settingsPath(), 'utf-8'));
44
+ const llmMlx = (raw.llm?.mlx ?? {});
45
+ if (typeof llmMlx.endpoint === 'string' && llmMlx.endpoint.length > 0) {
46
+ endpoint = stripChatSuffix(llmMlx.endpoint);
47
+ }
48
+ if (!isPlaceholder(llmMlx.model)) {
49
+ model = llmMlx.model.trim();
50
+ }
51
+ // Legacy fallback: apme.judge.{endpoint,model}
52
+ if (model === null || endpoint === DEFAULT_ENDPOINT) {
53
+ const judge = (raw.apme?.judge ?? {});
54
+ if (model === null && !isPlaceholder(judge.model)) {
55
+ model = judge.model.trim();
56
+ }
57
+ if (endpoint === DEFAULT_ENDPOINT && typeof judge.endpoint === 'string' && judge.endpoint.length > 0) {
58
+ endpoint = stripChatSuffix(judge.endpoint);
59
+ }
60
+ }
61
+ }
62
+ catch {
63
+ // file missing or malformed — keep defaults
64
+ }
65
+ const value = { endpoint, model };
66
+ cached = { at: Date.now(), value };
67
+ return value;
68
+ }
69
+ /** Force a reload on next call — used by tests and after settings writes. */
70
+ export function clearMlxSettingsCache() {
71
+ cached = null;
72
+ }
73
+ /**
74
+ * Resolve the MLX model id for an actual inference call.
75
+ * Priority: pinned settings → caller-supplied probe result → hardcoded fallback.
76
+ */
77
+ export function resolveMlxModel(probeFirst) {
78
+ const { model } = loadMlxSettings();
79
+ if (model)
80
+ return model;
81
+ if (probeFirst && probeFirst.length > 0)
82
+ return probeFirst;
83
+ return MLX_FALLBACK_MODEL;
84
+ }
85
+ /**
86
+ * Pick one model id from a live probe catalog. Returns `null` when the
87
+ * server is unreachable or advertises no usable model — UI should render
88
+ * "MLX · Not detected" rather than silently masquerading the fallback as
89
+ * active (the fallback id won't exist on the user's disk and every
90
+ * summarize call would fail).
91
+ *
92
+ * Priority — mirrors the 4-layer policy documented in CLAUDE.md:
93
+ * 1. caller-supplied pin if present in catalog
94
+ * 2. `MLX_FALLBACK_MODEL` (3.6 family) if present in catalog — keeps the
95
+ * codebase's chosen default in sync with what the dashboard advertises
96
+ * 3. first catalog entry (preserves the `auto-pick first` behavior added
97
+ * in commit 2b7b38b3 for the many-models case)
98
+ * 4. null — no catalog
99
+ */
100
+ export function pickMlxModel(catalog, pin) {
101
+ if (!catalog || catalog.length === 0)
102
+ return null;
103
+ if (pin && pin.length > 0 && catalog.includes(pin))
104
+ return pin;
105
+ if (catalog.includes(MLX_FALLBACK_MODEL))
106
+ return MLX_FALLBACK_MODEL;
107
+ return catalog[0];
108
+ }
109
+ /**
110
+ * Return a full chat-completions URL for the configured endpoint.
111
+ * MLX-VLM uses `/chat/completions`; MLX-LM historically also answers on
112
+ * `/v1/chat/completions`. We use the non-v1 path to match existing callers
113
+ * (timeline-summarizer, label-summarizer, apme runner all hit /chat/completions).
114
+ */
115
+ export function mlxChatUrl() {
116
+ return `${loadMlxSettings().endpoint}/chat/completions`;
117
+ }
118
+ //# sourceMappingURL=llm-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-settings.js","sourceRoot":"","sources":["../src/llm-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAEjD,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,oCAAoC,CAAC;AAEvE,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AASpE,IAAI,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