@agentdeck/shared 0.1.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,127 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { Server } from 'http';
3
+ import type { PluginCommand } from './protocol.js';
4
+ export type AgentType = 'claude-code' | 'openclaw';
5
+ export interface AgentCapabilities {
6
+ type: AgentType;
7
+ displayName: string;
8
+ /** PTY terminal attachment (stdin/stdout proxy) */
9
+ hasTerminal: boolean;
10
+ /** Plan/AcceptEdits/Default mode switching */
11
+ hasModeSwitching: boolean;
12
+ /** Diff review UI (view/apply/deny) */
13
+ hasDiffReview: boolean;
14
+ /** Numbered option lists with arrow navigation */
15
+ hasOptionLists: boolean;
16
+ /** Arrow-key navigable prompts */
17
+ hasNavigablePrompts: boolean;
18
+ /** Ghost text suggested prompts */
19
+ hasSuggestedPrompts: boolean;
20
+ /** OAuth-based API usage tracking */
21
+ hasApiUsage: boolean;
22
+ /** CLI-based model catalog (openclaw models list) */
23
+ hasModelCatalog: boolean;
24
+ }
25
+ export interface AdapterStartOptions {
26
+ /** Bridge port (injected as env var for hook scripts) */
27
+ port: number;
28
+ /** Command to spawn (e.g. 'claude') — only relevant for PTY-based agents */
29
+ command?: string;
30
+ /** Gateway WebSocket URL — only relevant for gateway-based agents (OpenClaw) */
31
+ gatewayUrl?: string;
32
+ }
33
+ /** Hook-sourced event (Claude Code HTTP hooks / OpenClaw WS events) */
34
+ export interface AdapterHookEvent {
35
+ source: 'hook';
36
+ event: string;
37
+ data: Record<string, unknown>;
38
+ }
39
+ /** Parser-sourced event (PTY regex parsing / OpenClaw structured events) */
40
+ export interface AdapterParserEvent {
41
+ source: 'parser';
42
+ event: string;
43
+ data?: Record<string, unknown>;
44
+ }
45
+ /** Metadata update (cursor, usage, user prompt, model catalog — no state transition) */
46
+ export interface AdapterMetadataEvent {
47
+ source: 'metadata';
48
+ event: 'cursor_update' | 'usage_info' | 'user_prompt' | 'model_catalog';
49
+ data: Record<string, unknown>;
50
+ }
51
+ /** Activity signal — resets stuck timer */
52
+ export interface AdapterActivityEvent {
53
+ source: 'activity';
54
+ }
55
+ /** Connection status change */
56
+ export interface AdapterConnectionEvent {
57
+ source: 'connection';
58
+ status: 'connected' | 'disconnected';
59
+ }
60
+ export type AdapterEvent = AdapterHookEvent | AdapterParserEvent | AdapterMetadataEvent | AdapterActivityEvent | AdapterConnectionEvent;
61
+ /**
62
+ * Agent adapter interface.
63
+ *
64
+ * **Command handling split**:
65
+ * - `handleCommand()` handles transport-only commands (interrupt, escape, switch_mode, respond)
66
+ * where the adapter owns the full logic.
67
+ * - Commands needing StateMachine context (select_option, navigate_option, send_prompt)
68
+ * are handled by the bridge, which calls `writeInput()` for the transport layer.
69
+ * - Bridge-only commands (voice, query_usage) are never passed to the adapter.
70
+ *
71
+ * **Phase 2 note**: For non-PTY agents (OpenClaw), `select_option` and `navigate_option`
72
+ * will move into `handleCommand()` since they map to RPC calls, not PTY escape sequences.
73
+ * The bridge will check `capabilities.hasNavigablePrompts` to decide the routing.
74
+ */
75
+ export interface AgentAdapter extends EventEmitter {
76
+ readonly capabilities: AgentCapabilities;
77
+ /**
78
+ * Start the agent process/connection.
79
+ * Emits 'event' with AdapterEvent payloads.
80
+ */
81
+ start(options: AdapterStartOptions): Promise<void>;
82
+ /**
83
+ * Handle a command from the plugin.
84
+ * Returns true if the command was handled, false if not applicable.
85
+ */
86
+ handleCommand(cmd: PluginCommand): boolean;
87
+ /**
88
+ * Send raw text/keystrokes to the agent's input stream.
89
+ *
90
+ * For PTY agents (Claude Code): writes directly to PTY (may include escape sequences).
91
+ * For non-PTY agents: this is a low-level fallback. Prefer handleCommand() for
92
+ * structured commands; Phase 2 adapters should handle select_option/navigate_option
93
+ * in handleCommand() via RPC rather than relying on writeInput() escape sequences.
94
+ */
95
+ writeInput(data: string): void;
96
+ /** Whether the agent process/connection is alive */
97
+ isAlive(): boolean;
98
+ /** Attach user terminal to agent process (no-op for non-PTY agents) */
99
+ attachTerminal(stdin: NodeJS.ReadableStream, stdout: NodeJS.WritableStream): void;
100
+ /** Get the PTY tty path (undefined for non-PTY agents) */
101
+ getTtyPath(): string | undefined;
102
+ /** Get project name detected by the adapter */
103
+ getProjectName(): string | null;
104
+ /**
105
+ * Get the underlying HTTP server.
106
+ * Every adapter provides an HTTP server for WebSocket (plugin) attachment.
107
+ * PTY adapters reuse the hook server; non-PTY adapters create a bare server.
108
+ */
109
+ getHttpServer(): Server;
110
+ /** Prepare parser for navigation — suppress false idle from PTY cursor-move echo */
111
+ prepareForNavigation?(): void;
112
+ /** Register a diagnostic dump handler */
113
+ onDiag(handler: (tail?: number) => unknown): void;
114
+ /** Register a callback for raw agent output data (for ring buffer / journal diagnostics) */
115
+ onRawData(callback: (data: string) => void): void;
116
+ /** Graceful shutdown */
117
+ shutdown(): Promise<void>;
118
+ }
119
+ export interface AgentAdapterEvents {
120
+ event: (evt: AdapterEvent) => void;
121
+ exit: (code: number, signal: number) => void;
122
+ }
123
+ export declare const CLAUDE_CODE_CAPABILITIES: AgentCapabilities;
124
+ export declare const OPENCLAW_CAPABILITIES: AgentCapabilities;
125
+ /** Default OpenClaw Gateway port */
126
+ export declare const OPENCLAW_GATEWAY_PORT = 18789;
127
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,WAAW,EAA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AAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAID,eAAO,MAAM,wBAAwB,EAAE,iBAWtC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,iBAWnC,CAAC;AAEF,oCAAoC;AACpC,eAAO,MAAM,qBAAqB,QAAQ,CAAC"}
@@ -0,0 +1,28 @@
1
+ // ===== Agent Capabilities (constants) =====
2
+ export const CLAUDE_CODE_CAPABILITIES = {
3
+ type: 'claude-code',
4
+ displayName: 'Claude Code',
5
+ hasTerminal: true,
6
+ hasModeSwitching: true,
7
+ hasDiffReview: true,
8
+ hasOptionLists: true,
9
+ hasNavigablePrompts: true,
10
+ hasSuggestedPrompts: true,
11
+ hasApiUsage: true,
12
+ hasModelCatalog: false,
13
+ };
14
+ export const OPENCLAW_CAPABILITIES = {
15
+ type: 'openclaw',
16
+ displayName: 'OpenClaw',
17
+ hasTerminal: false,
18
+ hasModeSwitching: false,
19
+ hasDiffReview: false,
20
+ hasOptionLists: true,
21
+ hasNavigablePrompts: false,
22
+ hasSuggestedPrompts: false,
23
+ hasApiUsage: false,
24
+ hasModelCatalog: true,
25
+ };
26
+ /** Default OpenClaw Gateway port */
27
+ export const OPENCLAW_GATEWAY_PORT = 18789;
28
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAiKA,6CAA6C;AAE7C,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACzD,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,IAAI;IACtB,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,IAAI;IACzB,mBAAmB,EAAE,IAAI;IACzB,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,KAAK;IACvB,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,KAAK;IAC1B,mBAAmB,EAAE,KAAK;IAC1B,WAAW,EAAE,KAAK;IAClB,eAAe,EAAE,IAAI;CACtB,CAAC;AAEF,oCAAoC;AACpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './states.js';
2
+ export * from './protocol.js';
3
+ export * from './adapter.js';
4
+ export * from './voice-paths.js';
5
+ export * from './net-utils.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from './states.js';
2
+ export * from './protocol.js';
3
+ export * from './adapter.js';
4
+ export * from './voice-paths.js';
5
+ export * from './net-utils.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ /** Return the first non-internal IPv4 LAN address, or '127.0.0.1' as fallback. */
2
+ export declare function getLanIp(): string;
3
+ //# sourceMappingURL=net-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net-utils.d.ts","sourceRoot":"","sources":["../src/net-utils.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,wBAAgB,QAAQ,IAAI,MAAM,CAQjC"}
@@ -0,0 +1,13 @@
1
+ import { networkInterfaces } from 'os';
2
+ /** Return the first non-internal IPv4 LAN address, or '127.0.0.1' as fallback. */
3
+ export function getLanIp() {
4
+ const nets = networkInterfaces();
5
+ for (const name of Object.keys(nets)) {
6
+ for (const net of nets[name] ?? []) {
7
+ if (net.family === 'IPv4' && !net.internal)
8
+ return net.address;
9
+ }
10
+ }
11
+ return '127.0.0.1';
12
+ }
13
+ //# sourceMappingURL=net-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net-utils.js","sourceRoot":"","sources":["../src/net-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAEvC,kFAAkF;AAClF,MAAM,UAAU,QAAQ;IACtB,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACnC,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ;gBAAE,OAAO,GAAG,CAAC,OAAO,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,130 @@
1
+ import { State, PermissionMode, PromptOption } from './states.js';
2
+ import type { AgentType, AgentCapabilities } from './adapter.js';
3
+ export type BillingType = 'subscription' | 'api' | 'unknown';
4
+ export interface ModelCatalogEntry {
5
+ name: string;
6
+ role: 'default' | `fallback-${number}` | 'configured';
7
+ available: boolean;
8
+ }
9
+ export interface OcSessionStatus {
10
+ model?: string;
11
+ contextTokens?: number;
12
+ messageCount?: number;
13
+ uptime?: string;
14
+ sessionId?: string;
15
+ [key: string]: unknown;
16
+ }
17
+ export interface StateUpdateEvent {
18
+ type: 'state_update';
19
+ state: State;
20
+ permissionMode: PermissionMode;
21
+ agentType?: AgentType;
22
+ agentCapabilities?: AgentCapabilities;
23
+ currentTool?: string;
24
+ toolInput?: string;
25
+ toolProgress?: string;
26
+ projectName?: string;
27
+ modelName?: string;
28
+ billingType?: BillingType;
29
+ options?: PromptOption[];
30
+ promptType?: 'yes_no' | 'yes_no_always' | 'multi_select' | 'diff_review';
31
+ question?: string;
32
+ navigable?: boolean;
33
+ cursorIndex?: number;
34
+ suggestedPrompt?: string;
35
+ modelCatalog?: ModelCatalogEntry[];
36
+ sessionStatus?: OcSessionStatus;
37
+ remoteUrl?: string;
38
+ /** Authenticated WS URL for remote pairing (ws://ip:port?token=hex) */
39
+ pairingUrl?: string;
40
+ }
41
+ export interface PromptOptionsEvent {
42
+ type: 'prompt_options';
43
+ promptType: 'yes_no' | 'yes_no_always' | 'multi_select' | 'diff_review';
44
+ question?: string;
45
+ options: PromptOption[];
46
+ }
47
+ export interface UsageEvent {
48
+ type: 'usage_update';
49
+ sessionDurationSec: number;
50
+ inputTokens: number;
51
+ outputTokens: number;
52
+ toolCalls: number;
53
+ estimatedCostUsd?: number;
54
+ sessionPercent?: number;
55
+ costSpent?: number;
56
+ costLimit?: number;
57
+ resetTime?: string;
58
+ resetDate?: string;
59
+ fiveHourPercent?: number;
60
+ fiveHourResetsAt?: string;
61
+ sevenDayPercent?: number;
62
+ sevenDayResetsAt?: string;
63
+ extraUsageEnabled?: boolean;
64
+ extraUsageMonthlyLimit?: number;
65
+ extraUsageUsedCredits?: number;
66
+ extraUsageUtilization?: number;
67
+ }
68
+ export interface ConnectionEvent {
69
+ type: 'connection';
70
+ status: 'connected' | 'reconnecting' | 'disconnected';
71
+ sessionId?: string;
72
+ }
73
+ export interface UserPromptEvent {
74
+ type: 'user_prompt';
75
+ text: string;
76
+ }
77
+ export interface VoiceStateEvent {
78
+ type: 'voice_state';
79
+ state: 'idle' | 'recording' | 'transcribing' | 'error';
80
+ text?: string;
81
+ error?: string;
82
+ }
83
+ export type BridgeEvent = StateUpdateEvent | PromptOptionsEvent | UsageEvent | ConnectionEvent | UserPromptEvent | VoiceStateEvent;
84
+ export interface ResponseCommand {
85
+ type: 'respond';
86
+ value: string;
87
+ }
88
+ export interface SelectOptionCommand {
89
+ type: 'select_option';
90
+ index: number;
91
+ }
92
+ export interface NavigateOptionCommand {
93
+ type: 'navigate_option';
94
+ direction: 'up' | 'down';
95
+ }
96
+ export interface SendPromptCommand {
97
+ type: 'send_prompt';
98
+ text: string;
99
+ }
100
+ export interface SwitchModeCommand {
101
+ type: 'switch_mode';
102
+ mode?: 'plan' | 'acceptEdits' | 'default';
103
+ }
104
+ export interface InterruptCommand {
105
+ type: 'interrupt';
106
+ }
107
+ export interface EscapeCommand {
108
+ type: 'escape';
109
+ }
110
+ export interface VoiceCommand {
111
+ type: 'voice';
112
+ action: 'start' | 'stop' | 'cancel';
113
+ }
114
+ export interface QueryUsageCommand {
115
+ type: 'query_usage';
116
+ }
117
+ export interface DiagCommand {
118
+ type: 'diag';
119
+ action: 'dump' | 'analyze';
120
+ }
121
+ export type PluginCommand = ResponseCommand | SelectOptionCommand | NavigateOptionCommand | SendPromptCommand | SwitchModeCommand | InterruptCommand | EscapeCommand | VoiceCommand | QueryUsageCommand | DiagCommand;
122
+ export interface HookEvent {
123
+ event: string;
124
+ data: Record<string, unknown>;
125
+ }
126
+ export declare const BRIDGE_WS_PORT = 9120;
127
+ export declare const BRIDGE_HTTP_PORT = 9120;
128
+ export declare const RECONNECT_INTERVAL_MS = 3000;
129
+ export declare const STUCK_TIMEOUT_MS: number;
130
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAA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W;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,mBAAmB,GACnB,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,GACjB,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,WAAW,CAAC;AAIhB,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAID,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,gBAAgB,QAAgB,CAAC"}
@@ -0,0 +1,6 @@
1
+ // ===== Constants =====
2
+ export const BRIDGE_WS_PORT = 9120;
3
+ export const BRIDGE_HTTP_PORT = 9120; // Same port, different path
4
+ export const RECONNECT_INTERVAL_MS = 3000;
5
+ export const STUCK_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
6
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAmLA,wBAAwB;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,CAAC,4BAA4B;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY"}
@@ -0,0 +1,57 @@
1
+ export declare enum State {
2
+ DISCONNECTED = "disconnected",
3
+ IDLE = "idle",
4
+ PROCESSING = "processing",
5
+ AWAITING_PERMISSION = "awaiting_permission",
6
+ AWAITING_OPTION = "awaiting_option",
7
+ AWAITING_DIFF = "awaiting_diff"
8
+ }
9
+ export declare enum PermissionMode {
10
+ DEFAULT = "default",
11
+ PLAN = "plan",
12
+ ACCEPT_EDITS = "acceptEdits",
13
+ DONT_ASK = "dontAsk",
14
+ BYPASS_PERMISSIONS = "bypassPermissions"
15
+ }
16
+ export type TransitionSource = 'hook' | 'pty' | 'user' | 'internal';
17
+ export interface StateTransition {
18
+ from: State | '*';
19
+ to: State;
20
+ trigger: string;
21
+ source: TransitionSource;
22
+ }
23
+ export declare const transitions: StateTransition[];
24
+ export interface PromptOption {
25
+ index: number;
26
+ label: string;
27
+ shortcut?: string;
28
+ recommended?: boolean;
29
+ selected?: boolean;
30
+ }
31
+ export interface StateSnapshot {
32
+ state: State;
33
+ permissionMode: PermissionMode;
34
+ currentTool: string | null;
35
+ toolInput: string | null;
36
+ toolProgress: string | null;
37
+ options: PromptOption[];
38
+ question: string | null;
39
+ navigable: boolean;
40
+ cursorIndex: number;
41
+ projectName: string | null;
42
+ modelName: string | null;
43
+ billingType: import('./protocol.js').BillingType;
44
+ sessionDurationSec: number;
45
+ inputTokens: number;
46
+ outputTokens: number;
47
+ toolCalls: number;
48
+ estimatedCostUsd: number | null;
49
+ sessionPercent: number | null;
50
+ costSpent: number | null;
51
+ costLimit: number | null;
52
+ resetTime: string | null;
53
+ resetDate: string | null;
54
+ suggestedPrompt: string | null;
55
+ remoteUrl: string | null;
56
+ }
57
+ //# sourceMappingURL=states.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"states.d.ts","sourceRoot":"","sources":["../src/states.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,UAAU,eAAe;IACzB,mBAAmB,wBAAwB;IAC3C,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;CAChC;AAED,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,YAAY,gBAAgB;IAC5B,QA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IAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
package/dist/states.js ADDED
@@ -0,0 +1,47 @@
1
+ export var State;
2
+ (function (State) {
3
+ State["DISCONNECTED"] = "disconnected";
4
+ State["IDLE"] = "idle";
5
+ State["PROCESSING"] = "processing";
6
+ State["AWAITING_PERMISSION"] = "awaiting_permission";
7
+ State["AWAITING_OPTION"] = "awaiting_option";
8
+ State["AWAITING_DIFF"] = "awaiting_diff";
9
+ })(State || (State = {}));
10
+ export var PermissionMode;
11
+ (function (PermissionMode) {
12
+ PermissionMode["DEFAULT"] = "default";
13
+ PermissionMode["PLAN"] = "plan";
14
+ PermissionMode["ACCEPT_EDITS"] = "acceptEdits";
15
+ PermissionMode["DONT_ASK"] = "dontAsk";
16
+ PermissionMode["BYPASS_PERMISSIONS"] = "bypassPermissions";
17
+ })(PermissionMode || (PermissionMode = {}));
18
+ export const transitions = [
19
+ { from: State.DISCONNECTED, to: State.IDLE, trigger: 'session_start', source: 'hook' },
20
+ { from: State.IDLE, to: State.PROCESSING, trigger: 'user_prompt_submit', source: 'hook' },
21
+ { from: State.IDLE, to: State.PROCESSING, trigger: 'spinner_start', source: 'pty' },
22
+ { from: State.PROCESSING, to: State.IDLE, trigger: 'stop', source: 'hook' },
23
+ { from: State.PROCESSING, to: State.IDLE, trigger: 'idle_detected', source: 'pty' },
24
+ { from: State.AWAITING_PERMISSION, to: State.IDLE, trigger: 'idle_detected', source: 'pty' },
25
+ { from: State.AWAITING_OPTION, to: State.IDLE, trigger: 'idle_detected', source: 'pty' },
26
+ { from: State.AWAITING_DIFF, to: State.IDLE, trigger: 'idle_detected', source: 'pty' },
27
+ { from: State.PROCESSING, to: State.AWAITING_PERMISSION, trigger: 'permission_prompt', source: 'pty' },
28
+ { from: State.IDLE, to: State.AWAITING_PERMISSION, trigger: 'permission_prompt', source: 'pty' },
29
+ { from: State.PROCESSING, to: State.AWAITING_OPTION, trigger: 'option_ui_detected', source: 'pty' },
30
+ { from: State.IDLE, to: State.AWAITING_OPTION, trigger: 'option_ui_detected', source: 'pty' },
31
+ { from: State.PROCESSING, to: State.AWAITING_DIFF, trigger: 'diff_ui_detected', source: 'pty' },
32
+ { from: State.IDLE, to: State.AWAITING_DIFF, trigger: 'diff_ui_detected', source: 'pty' },
33
+ { from: State.AWAITING_PERMISSION, to: State.PROCESSING, trigger: 'user_response', source: 'user' },
34
+ { from: State.AWAITING_PERMISSION, to: State.PROCESSING, trigger: 'user_selection', source: 'user' },
35
+ { from: State.AWAITING_OPTION, to: State.PROCESSING, trigger: 'user_selection', source: 'user' },
36
+ { from: State.AWAITING_DIFF, to: State.PROCESSING, trigger: 'user_response', source: 'user' },
37
+ { from: State.AWAITING_DIFF, to: State.PROCESSING, trigger: 'user_selection', source: 'user' },
38
+ // Recovery: spinner_start from awaiting states (user responded via keyboard, not Stream Deck)
39
+ { from: State.AWAITING_PERMISSION, to: State.PROCESSING, trigger: 'spinner_start', source: 'pty' },
40
+ { from: State.AWAITING_OPTION, to: State.PROCESSING, trigger: 'spinner_start', source: 'pty' },
41
+ { from: State.AWAITING_DIFF, to: State.PROCESSING, trigger: 'spinner_start', source: 'pty' },
42
+ // stuck_timeout only for PROCESSING — AWAITING_* wait indefinitely for user response
43
+ { from: State.PROCESSING, to: State.IDLE, trigger: 'stuck_timeout', source: 'internal' },
44
+ { from: '*', to: State.DISCONNECTED, trigger: 'session_end', source: 'hook' },
45
+ { from: '*', to: State.IDLE, trigger: 'interrupt', source: 'user' },
46
+ ];
47
+ //# sourceMappingURL=states.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"states.js","sourceRoot":"","sources":["../src/states.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EAAE;IAC7E,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE;CACpE,CAAC"}
@@ -0,0 +1,20 @@
1
+ export declare const MODEL_SEARCH_DIRS: string[];
2
+ export declare const MODELS_WITH_METAL: string[];
3
+ export declare const MODELS_WITHOUT_METAL: string[];
4
+ export declare const WHISPER_CANDIDATES: string[];
5
+ export declare const REC_CANDIDATES: string[];
6
+ export declare const SOX_CANDIDATES: string[];
7
+ export declare const WHISPER_SERVER_CANDIDATES: string[];
8
+ /** Whisper-server discovery info file path */
9
+ export declare const WHISPER_SERVER_INFO_FILE: string;
10
+ /** OpenClaw binary candidates */
11
+ export declare const OPENCLAW_CANDIDATES: string[];
12
+ /** Resolve `openclaw` binary: try known candidate paths, fallback to bare name on PATH. */
13
+ export declare function resolveOpenClawBin(): string;
14
+ /**
15
+ * Augmented PATH for CLI child processes — ensures binaries installed via
16
+ * Homebrew, pip --user, etc. are discoverable even when the parent process
17
+ * (e.g. Stream Deck SDK) has a minimal PATH.
18
+ */
19
+ export declare function augmentedPath(): string;
20
+ //# sourceMappingURL=voice-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-paths.d.ts","sourceRoot":"","sources":["../src/voice-paths.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,UAK7B,CAAC;AAGF,eAAO,MAAM,iBAAiB,UAI7B,CAAC;AACF,eAAO,MAAM,oBAAoB,UAGhC,CAAC;AAGF,eAAO,MAAM,kBAAkB,UAG9B,CAAC;AACF,eAAO,MAAM,cAAc,UAG1B,CAAC;AACF,eAAO,MAAM,cAAc,UAG1B,CAAC;AACF,eAAO,MAAM,yBAAyB,UAGrC,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,QAAuD,CAAC;AAE7F,iCAAiC;AACjC,eAAO,MAAM,mBAAmB,UAU/B,CAAC;AAEF,2FAA2F;AAC3F,wBAAgB,kBAAkB,IAAI,MAAM,CAK3C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAatC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Voice binary/model path constants shared between bridge and plugin.
3
+ */
4
+ import { join } from 'path';
5
+ import { homedir } from 'os';
6
+ import { existsSync } from 'fs';
7
+ export const MODEL_SEARCH_DIRS = [
8
+ join(homedir(), '.local/share/whisper-cpp'),
9
+ '/opt/homebrew/share/whisper-cpp', // arm64 Homebrew
10
+ '/usr/local/share/whisper-cpp', // x86 Homebrew
11
+ join(homedir(), 'models'),
12
+ ];
13
+ // Model tiers: Metal-accelerated GPU can handle large models; CPU/Rosetta cannot
14
+ export const MODELS_WITH_METAL = [
15
+ 'ggml-large-v3-turbo.bin',
16
+ 'ggml-small.bin',
17
+ 'ggml-base.bin',
18
+ ];
19
+ export const MODELS_WITHOUT_METAL = [
20
+ 'ggml-base.bin',
21
+ 'ggml-small.bin',
22
+ ];
23
+ // Preferred binary paths: arm64 Homebrew first, then system PATH
24
+ export const WHISPER_CANDIDATES = [
25
+ '/opt/homebrew/bin/whisper-cli',
26
+ '/usr/local/bin/whisper-cli',
27
+ ];
28
+ export const REC_CANDIDATES = [
29
+ '/opt/homebrew/bin/rec',
30
+ '/usr/local/bin/rec',
31
+ ];
32
+ export const SOX_CANDIDATES = [
33
+ '/opt/homebrew/bin/sox',
34
+ '/usr/local/bin/sox',
35
+ ];
36
+ export const WHISPER_SERVER_CANDIDATES = [
37
+ '/opt/homebrew/bin/whisper-server',
38
+ '/usr/local/bin/whisper-server',
39
+ ];
40
+ /** Whisper-server discovery info file path */
41
+ export const WHISPER_SERVER_INFO_FILE = join(homedir(), '.agentdeck', 'whisper-server.json');
42
+ /** OpenClaw binary candidates */
43
+ export const OPENCLAW_CANDIDATES = [
44
+ '/opt/homebrew/bin/openclaw',
45
+ '/usr/local/bin/openclaw',
46
+ join(homedir(), 'Library', 'pnpm', 'openclaw'), // macOS pnpm global bin
47
+ join(homedir(), 'Library', 'pnpm', 'nodejs_current', 'bin', 'openclaw'), // pnpm node bin
48
+ join(homedir(), '.local/bin/openclaw'),
49
+ join(homedir(), '.cargo/bin/openclaw'),
50
+ join(homedir(), 'go/bin/openclaw'),
51
+ join(homedir(), '.openclaw/bin/openclaw'),
52
+ join(homedir(), '.bun/bin/openclaw'),
53
+ ];
54
+ /** Resolve `openclaw` binary: try known candidate paths, fallback to bare name on PATH. */
55
+ export function resolveOpenClawBin() {
56
+ for (const candidate of OPENCLAW_CANDIDATES) {
57
+ if (existsSync(candidate))
58
+ return candidate;
59
+ }
60
+ return 'openclaw';
61
+ }
62
+ /**
63
+ * Augmented PATH for CLI child processes — ensures binaries installed via
64
+ * Homebrew, pip --user, etc. are discoverable even when the parent process
65
+ * (e.g. Stream Deck SDK) has a minimal PATH.
66
+ */
67
+ export function augmentedPath() {
68
+ const extra = [
69
+ '/opt/homebrew/bin',
70
+ '/usr/local/bin',
71
+ join(homedir(), 'Library', 'pnpm'), // macOS pnpm global bin
72
+ join(homedir(), '.local/bin'),
73
+ join(homedir(), '.cargo/bin'),
74
+ join(homedir(), 'go/bin'),
75
+ join(homedir(), '.openclaw/bin'),
76
+ join(homedir(), '.bun/bin'),
77
+ ];
78
+ const existing = process.env.PATH ?? '/usr/bin:/bin';
79
+ return [...extra, existing].join(':');
80
+ }
81
+ //# sourceMappingURL=voice-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-paths.js","sourceRoot":"","sources":["../src/voice-paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,CAAC,OAAO,EAAE,EAAE,0BAA0B,CAAC;IAC3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zC,IAAI,CAAC,OAAO,EAAE,EAAE,mBAAmB,CAAC;CACrC,CAAC;AAEF,2FAA2F;AAC3F,MAAM,UAAU,kBAAkB;IAChC,KAAK,MAAM,SAAS,IAAI,mBAAmB,EAAE,CAAC;QAC5C,IAAI,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IAC9C,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,KAAK,GAAG;QACZ,mBAAmB;QACnB,gBAAgB;QAChB,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAG,wBAAwB;QAC7D,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC;QAC7B,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC;QAC7B,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC;KAC5B,CAAC;IACF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,eAAe,CAAC;IACrD,OAAO,CAAC,GAAG,KAAK,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@agentdeck/shared",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/puritysb/AgentDeck.git",
9
+ "directory": "shared"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ },
21
+ "./protocol": {
22
+ "types": "./dist/protocol.d.ts",
23
+ "import": "./dist/protocol.js"
24
+ },
25
+ "./states": {
26
+ "types": "./dist/states.d.ts",
27
+ "import": "./dist/states.js"
28
+ }
29
+ },
30
+ "devDependencies": {
31
+ "typescript": "^5.5.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "dev": "tsc --watch",
36
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
37
+ "typecheck": "tsc --noEmit"
38
+ }
39
+ }