capacitor-mobile-claw 1.5.7 → 1.6.1
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/dist/esm/agent/agent-runner.d.ts +76 -0
- package/dist/esm/agent/agent-runner.d.ts.map +1 -0
- package/dist/esm/agent/agent-runner.js +284 -0
- package/dist/esm/agent/agent-runner.js.map +1 -0
- package/dist/esm/agent/session-store.d.ts +31 -0
- package/dist/esm/agent/session-store.d.ts.map +1 -0
- package/dist/esm/agent/session-store.js +162 -0
- package/dist/esm/agent/session-store.js.map +1 -0
- package/dist/esm/agent/tool-proxy.d.ts +45 -0
- package/dist/esm/agent/tool-proxy.d.ts.map +1 -0
- package/dist/esm/agent/tool-proxy.js +156 -0
- package/dist/esm/agent/tool-proxy.js.map +1 -0
- package/dist/esm/agent/tool-schemas.d.ts +16 -0
- package/dist/esm/agent/tool-schemas.d.ts.map +1 -0
- package/dist/esm/agent/tool-schemas.js +129 -0
- package/dist/esm/agent/tool-schemas.js.map +1 -0
- package/dist/esm/definitions.d.ts +7 -0
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/engine.d.ts +21 -0
- package/dist/esm/engine.d.ts.map +1 -1
- package/dist/esm/engine.js +166 -0
- package/dist/esm/engine.js.map +1 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mcp/transport/stomp-server-transport.js +1 -1
- package/dist/esm/mcp/transport/stomp-server-transport.js.map +1 -1
- package/dist/esm/services/bridge-protocol.d.ts +46 -2
- package/dist/esm/services/bridge-protocol.d.ts.map +1 -1
- package/nodejs-assets/nodejs-project/main.js +95 -277
- package/package.json +6 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRunner — WebView-side agent orchestration.
|
|
3
|
+
*
|
|
4
|
+
* Runs the AI agent loop directly in the WebView using pi-agent-core and pi-ai.
|
|
5
|
+
* No Node.js worker cold start needed — available immediately on app launch.
|
|
6
|
+
*
|
|
7
|
+
* Tools that need Node.js (file I/O, git, VM) are proxied to the worker via
|
|
8
|
+
* ToolProxy. MCP device tools and session persistence are handled directly
|
|
9
|
+
* in the WebView.
|
|
10
|
+
*/
|
|
11
|
+
import { Agent, type AgentMessage, type AgentTool } from '@mariozechner/pi-agent-core';
|
|
12
|
+
import type { ToolProxy } from './tool-proxy';
|
|
13
|
+
export interface AgentRunnerConfig {
|
|
14
|
+
/** Function to dispatch agent events directly to the engine's listener system */
|
|
15
|
+
dispatch: (msg: Record<string, unknown>) => void;
|
|
16
|
+
/** Tool proxy for bridging tool calls to the worker */
|
|
17
|
+
toolProxy: ToolProxy;
|
|
18
|
+
/** Pre-execute hook — fires before each tool call, returns approved/denied result */
|
|
19
|
+
preExecuteHook?: (toolCallId: string, toolName: string, args: Record<string, unknown>, signal?: AbortSignal) => Promise<PreExecuteResult>;
|
|
20
|
+
}
|
|
21
|
+
export interface PreExecuteResult {
|
|
22
|
+
deny?: boolean;
|
|
23
|
+
denyReason?: string;
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface AgentRunParams {
|
|
27
|
+
prompt: string;
|
|
28
|
+
agentId: string;
|
|
29
|
+
sessionKey: string;
|
|
30
|
+
model?: string;
|
|
31
|
+
provider?: string;
|
|
32
|
+
apiKey: string;
|
|
33
|
+
systemPrompt: string;
|
|
34
|
+
/** Additional tools (MCP device tools) to merge with proxied worker tools */
|
|
35
|
+
extraTools?: AgentTool<any>[];
|
|
36
|
+
}
|
|
37
|
+
export declare class AgentRunner {
|
|
38
|
+
private agent;
|
|
39
|
+
private currentSessionKey;
|
|
40
|
+
private dispatch;
|
|
41
|
+
private toolProxy;
|
|
42
|
+
private preExecuteHook?;
|
|
43
|
+
constructor(config: AgentRunnerConfig);
|
|
44
|
+
/** Whether the agent is currently streaming / executing tools */
|
|
45
|
+
get isRunning(): boolean;
|
|
46
|
+
get sessionKey(): string | null;
|
|
47
|
+
get currentAgent(): Agent | null;
|
|
48
|
+
run(params: AgentRunParams): Promise<void>;
|
|
49
|
+
/** Continue an existing conversation with a new prompt */
|
|
50
|
+
followUp(prompt: string): Promise<void>;
|
|
51
|
+
/** Abort the current agent turn */
|
|
52
|
+
abort(): void;
|
|
53
|
+
/** Send a steering message to the agent mid-turn */
|
|
54
|
+
steer(text: string): void;
|
|
55
|
+
/** Clear the current session (keep transcripts) */
|
|
56
|
+
clear(): void;
|
|
57
|
+
/** Resume a session by hydrating with saved messages */
|
|
58
|
+
resume(params: {
|
|
59
|
+
sessionKey: string;
|
|
60
|
+
messages: AgentMessage[];
|
|
61
|
+
systemPrompt: string;
|
|
62
|
+
apiKey: string;
|
|
63
|
+
model?: string;
|
|
64
|
+
provider?: string;
|
|
65
|
+
extraTools?: AgentTool<any>[];
|
|
66
|
+
}): void;
|
|
67
|
+
/** Map pi-agent-core AgentEvent to bridge protocol messages */
|
|
68
|
+
private _dispatchAgentEvent;
|
|
69
|
+
/** Wrap tools with the pre-execute hook (approval gate) */
|
|
70
|
+
private _wrapWithPreExecuteHook;
|
|
71
|
+
/** Extract cumulative token usage from agent messages */
|
|
72
|
+
private _extractUsage;
|
|
73
|
+
/** Check if an error is transient (worth retrying) */
|
|
74
|
+
private _isTransientError;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=agent-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../../src/agent/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAmB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAEvG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,QAAQ,EAAE,CAAC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CAAC,IAAI,CAAC;IAkFhD,0DAA0D;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoD7C,mCAAmC;IACnC,KAAK,IAAI,IAAI;IAIb,oDAAoD;IACpD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKzB,mDAAmD;IACnD,KAAK,IAAI,IAAI;IAKb,wDAAwD;IACxD,MAAM,CAAC,MAAM,EAAE;QACb,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,YAAY,EAAE,CAAA;QACxB,YAAY,EAAE,MAAM,CAAA;QACpB,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAA;KAC9B,GAAG,IAAI;IAgCR,+DAA+D;IAC/D,OAAO,CAAC,mBAAmB;IAqC3B,2DAA2D;IAC3D,OAAO,CAAC,uBAAuB;IAwB/B,yDAAyD;IACzD,OAAO,CAAC,aAAa;IAerB,sDAAsD;IACtD,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRunner — WebView-side agent orchestration.
|
|
3
|
+
*
|
|
4
|
+
* Runs the AI agent loop directly in the WebView using pi-agent-core and pi-ai.
|
|
5
|
+
* No Node.js worker cold start needed — available immediately on app launch.
|
|
6
|
+
*
|
|
7
|
+
* Tools that need Node.js (file I/O, git, VM) are proxied to the worker via
|
|
8
|
+
* ToolProxy. MCP device tools and session persistence are handled directly
|
|
9
|
+
* in the WebView.
|
|
10
|
+
*/
|
|
11
|
+
import { Agent } from '@mariozechner/pi-agent-core';
|
|
12
|
+
import { getModel } from '@mariozechner/pi-ai';
|
|
13
|
+
export class AgentRunner {
|
|
14
|
+
agent = null;
|
|
15
|
+
currentSessionKey = null;
|
|
16
|
+
dispatch;
|
|
17
|
+
toolProxy;
|
|
18
|
+
preExecuteHook;
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.dispatch = config.dispatch;
|
|
21
|
+
this.toolProxy = config.toolProxy;
|
|
22
|
+
this.preExecuteHook = config.preExecuteHook;
|
|
23
|
+
}
|
|
24
|
+
/** Whether the agent is currently streaming / executing tools */
|
|
25
|
+
get isRunning() {
|
|
26
|
+
return this.agent?.state.isStreaming ?? false;
|
|
27
|
+
}
|
|
28
|
+
get sessionKey() {
|
|
29
|
+
return this.currentSessionKey;
|
|
30
|
+
}
|
|
31
|
+
get currentAgent() {
|
|
32
|
+
return this.agent;
|
|
33
|
+
}
|
|
34
|
+
// ── Agent lifecycle ──────────────────────────────────────────────────────
|
|
35
|
+
async run(params) {
|
|
36
|
+
const provider = params.provider || 'anthropic';
|
|
37
|
+
const defaultModel = provider === 'anthropic' ? 'claude-sonnet-4-5' : null;
|
|
38
|
+
const modelId = params.model || defaultModel;
|
|
39
|
+
if (!modelId) {
|
|
40
|
+
this.dispatch({
|
|
41
|
+
type: 'agent.error',
|
|
42
|
+
error: `No model specified for provider "${provider}". Select a model in Settings.`,
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const model = getModel(provider, modelId);
|
|
47
|
+
if (!model) {
|
|
48
|
+
this.dispatch({
|
|
49
|
+
type: 'agent.error',
|
|
50
|
+
error: `Model "${modelId}" not found for provider "${provider}".`,
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Build tools: proxied worker tools + optional MCP/memory tools
|
|
55
|
+
const workerTools = this._wrapWithPreExecuteHook(this.toolProxy.buildTools());
|
|
56
|
+
const extraTools = params.extraTools ? this._wrapWithPreExecuteHook(params.extraTools) : [];
|
|
57
|
+
const tools = [...workerTools, ...extraTools];
|
|
58
|
+
this.agent = new Agent({
|
|
59
|
+
initialState: {
|
|
60
|
+
systemPrompt: params.systemPrompt,
|
|
61
|
+
model,
|
|
62
|
+
tools,
|
|
63
|
+
thinkingLevel: 'off',
|
|
64
|
+
},
|
|
65
|
+
convertToLlm: (messages) => messages.filter((m) => m.role === 'user' || m.role === 'assistant' || m.role === 'toolResult'),
|
|
66
|
+
getApiKey: () => params.apiKey,
|
|
67
|
+
});
|
|
68
|
+
this.currentSessionKey = params.sessionKey;
|
|
69
|
+
// Subscribe to events — dispatch DIRECTLY to the engine (no bridge hop)
|
|
70
|
+
this.agent.subscribe((event) => {
|
|
71
|
+
this._dispatchAgentEvent(event);
|
|
72
|
+
});
|
|
73
|
+
// Echo user prompt to UI
|
|
74
|
+
this.dispatch({
|
|
75
|
+
type: 'agent.event',
|
|
76
|
+
eventType: 'user_message',
|
|
77
|
+
data: { text: params.prompt, sessionKey: params.sessionKey },
|
|
78
|
+
});
|
|
79
|
+
// Run the agent loop
|
|
80
|
+
const startTime = Date.now();
|
|
81
|
+
try {
|
|
82
|
+
await this.agent.prompt(params.prompt);
|
|
83
|
+
await this.agent.waitForIdle();
|
|
84
|
+
const usage = this._extractUsage();
|
|
85
|
+
this.dispatch({
|
|
86
|
+
type: 'agent.completed',
|
|
87
|
+
sessionKey: params.sessionKey,
|
|
88
|
+
usage,
|
|
89
|
+
cumulativeUsage: usage,
|
|
90
|
+
durationMs: Date.now() - startTime,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
const retryable = this._isTransientError(err);
|
|
95
|
+
this.dispatch({
|
|
96
|
+
type: 'agent.error',
|
|
97
|
+
error: err.message || 'Unknown error during agent execution',
|
|
98
|
+
code: err.status ? String(err.status) : undefined,
|
|
99
|
+
retryable,
|
|
100
|
+
});
|
|
101
|
+
if (!retryable) {
|
|
102
|
+
this.agent = null;
|
|
103
|
+
this.currentSessionKey = null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Continue an existing conversation with a new prompt */
|
|
108
|
+
async followUp(prompt) {
|
|
109
|
+
if (!this.agent || this.agent.state.messages.length === 0) {
|
|
110
|
+
this.dispatch({ type: 'agent.error', error: 'No active session to follow up on' });
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Auto-abort in-flight turn
|
|
114
|
+
if (this.agent.state.isStreaming) {
|
|
115
|
+
this.agent.abort();
|
|
116
|
+
await this.agent.waitForIdle();
|
|
117
|
+
this.dispatch({
|
|
118
|
+
type: 'agent.event',
|
|
119
|
+
eventType: 'interrupted',
|
|
120
|
+
data: { reason: 'New message sent while streaming' },
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Echo user prompt
|
|
124
|
+
this.dispatch({
|
|
125
|
+
type: 'agent.event',
|
|
126
|
+
eventType: 'user_message',
|
|
127
|
+
data: { text: prompt, sessionKey: this.currentSessionKey },
|
|
128
|
+
});
|
|
129
|
+
const startTime = Date.now();
|
|
130
|
+
try {
|
|
131
|
+
await this.agent.prompt(prompt);
|
|
132
|
+
await this.agent.waitForIdle();
|
|
133
|
+
const usage = this._extractUsage();
|
|
134
|
+
this.dispatch({
|
|
135
|
+
type: 'agent.completed',
|
|
136
|
+
sessionKey: this.currentSessionKey,
|
|
137
|
+
usage,
|
|
138
|
+
cumulativeUsage: usage,
|
|
139
|
+
durationMs: Date.now() - startTime,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
const retryable = this._isTransientError(err);
|
|
144
|
+
this.dispatch({
|
|
145
|
+
type: 'agent.error',
|
|
146
|
+
error: err.message || 'Follow-up error',
|
|
147
|
+
code: err.status ? String(err.status) : undefined,
|
|
148
|
+
retryable,
|
|
149
|
+
});
|
|
150
|
+
if (!retryable) {
|
|
151
|
+
this.agent = null;
|
|
152
|
+
this.currentSessionKey = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Abort the current agent turn */
|
|
157
|
+
abort() {
|
|
158
|
+
this.agent?.abort();
|
|
159
|
+
}
|
|
160
|
+
/** Send a steering message to the agent mid-turn */
|
|
161
|
+
steer(text) {
|
|
162
|
+
if (!this.agent)
|
|
163
|
+
return;
|
|
164
|
+
this.agent.steer({ role: 'user', content: text, timestamp: Date.now() });
|
|
165
|
+
}
|
|
166
|
+
/** Clear the current session (keep transcripts) */
|
|
167
|
+
clear() {
|
|
168
|
+
this.agent = null;
|
|
169
|
+
this.currentSessionKey = null;
|
|
170
|
+
}
|
|
171
|
+
/** Resume a session by hydrating with saved messages */
|
|
172
|
+
resume(params) {
|
|
173
|
+
const provider = params.provider || 'anthropic';
|
|
174
|
+
const modelId = params.model || 'claude-sonnet-4-5';
|
|
175
|
+
const model = getModel(provider, modelId);
|
|
176
|
+
if (!model)
|
|
177
|
+
return;
|
|
178
|
+
const workerTools = this._wrapWithPreExecuteHook(this.toolProxy.buildTools());
|
|
179
|
+
const extraTools = params.extraTools ? this._wrapWithPreExecuteHook(params.extraTools) : [];
|
|
180
|
+
const tools = [...workerTools, ...extraTools];
|
|
181
|
+
this.agent = new Agent({
|
|
182
|
+
initialState: {
|
|
183
|
+
systemPrompt: params.systemPrompt,
|
|
184
|
+
model,
|
|
185
|
+
tools,
|
|
186
|
+
thinkingLevel: 'off',
|
|
187
|
+
},
|
|
188
|
+
convertToLlm: (messages) => messages.filter((m) => m.role === 'user' || m.role === 'assistant' || m.role === 'toolResult'),
|
|
189
|
+
getApiKey: () => params.apiKey,
|
|
190
|
+
});
|
|
191
|
+
this.agent.replaceMessages(params.messages);
|
|
192
|
+
this.agent.subscribe((event) => {
|
|
193
|
+
this._dispatchAgentEvent(event);
|
|
194
|
+
});
|
|
195
|
+
this.currentSessionKey = params.sessionKey;
|
|
196
|
+
}
|
|
197
|
+
// ── Private ──────────────────────────────────────────────────────────────
|
|
198
|
+
/** Map pi-agent-core AgentEvent to bridge protocol messages */
|
|
199
|
+
_dispatchAgentEvent(event) {
|
|
200
|
+
switch (event.type) {
|
|
201
|
+
case 'message_update': {
|
|
202
|
+
const e = event.assistantMessageEvent;
|
|
203
|
+
if (e?.type === 'text_delta') {
|
|
204
|
+
this.dispatch({ type: 'agent.event', eventType: 'text_delta', data: { text: e.delta } });
|
|
205
|
+
}
|
|
206
|
+
if (e?.type === 'thinking_delta') {
|
|
207
|
+
this.dispatch({ type: 'agent.event', eventType: 'thinking', data: { text: e.delta } });
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case 'tool_execution_start':
|
|
212
|
+
this.dispatch({
|
|
213
|
+
type: 'agent.event',
|
|
214
|
+
eventType: 'tool_use',
|
|
215
|
+
data: {
|
|
216
|
+
toolName: event.toolName,
|
|
217
|
+
toolCallId: event.toolCallId,
|
|
218
|
+
args: event.args,
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
break;
|
|
222
|
+
case 'tool_execution_end':
|
|
223
|
+
this.dispatch({
|
|
224
|
+
type: 'agent.event',
|
|
225
|
+
eventType: 'tool_result',
|
|
226
|
+
data: {
|
|
227
|
+
toolName: event.toolName,
|
|
228
|
+
toolCallId: event.toolCallId,
|
|
229
|
+
result: event.result,
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/** Wrap tools with the pre-execute hook (approval gate) */
|
|
236
|
+
_wrapWithPreExecuteHook(tools) {
|
|
237
|
+
if (!this.preExecuteHook)
|
|
238
|
+
return tools;
|
|
239
|
+
const hook = this.preExecuteHook;
|
|
240
|
+
return tools.map((tool) => ({
|
|
241
|
+
...tool,
|
|
242
|
+
execute: async (toolCallId, params, signal, onUpdate) => {
|
|
243
|
+
// Fire pre-execute hook directly in WebView — instant UI, no bridge hop
|
|
244
|
+
const result = await hook(toolCallId, tool.name, params, signal);
|
|
245
|
+
if (result.deny) {
|
|
246
|
+
return {
|
|
247
|
+
content: [
|
|
248
|
+
{ type: 'text', text: result.denyReason || `Tool "${tool.name}" execution was denied.` },
|
|
249
|
+
],
|
|
250
|
+
details: { denied: true, reason: result.denyReason || 'client_denied' },
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// Execute with (possibly transformed) args
|
|
254
|
+
return tool.execute(toolCallId, result.args, signal, onUpdate);
|
|
255
|
+
},
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
/** Extract cumulative token usage from agent messages */
|
|
259
|
+
_extractUsage() {
|
|
260
|
+
let input = 0;
|
|
261
|
+
let output = 0;
|
|
262
|
+
if (this.agent) {
|
|
263
|
+
for (const msg of this.agent.state.messages) {
|
|
264
|
+
const m = msg;
|
|
265
|
+
if (m.role === 'assistant' && m.usage) {
|
|
266
|
+
input += m.usage.input || 0;
|
|
267
|
+
output += m.usage.output || 0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return { inputTokens: input, outputTokens: output, totalTokens: input + output };
|
|
272
|
+
}
|
|
273
|
+
/** Check if an error is transient (worth retrying) */
|
|
274
|
+
_isTransientError(err) {
|
|
275
|
+
const status = err.status || err.statusCode;
|
|
276
|
+
if (status === 429 || status === 503 || status === 502)
|
|
277
|
+
return true;
|
|
278
|
+
const msg = (err.message || '').toLowerCase();
|
|
279
|
+
if (msg.includes('rate limit') || msg.includes('overloaded') || msg.includes('timeout'))
|
|
280
|
+
return true;
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=agent-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/agent/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAsD,MAAM,6BAA6B,CAAA;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAmC9C,MAAM,OAAO,WAAW;IACd,KAAK,GAAiB,IAAI,CAAA;IAC1B,iBAAiB,GAAkB,IAAI,CAAA;IACvC,QAAQ,CAAwC;IAChD,SAAS,CAAW;IACp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C,MAAM,IAAI,GAAG,CAAC,UAAU,CAAA;QAC3C,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAA;QACnE,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;QAC7C,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAA;QACpG,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionStore — Direct SQLite session persistence from the WebView.
|
|
3
|
+
*
|
|
4
|
+
* Accesses the same `mobile-claw` database used by DbBridgeHandler,
|
|
5
|
+
* eliminating the worker→bridge→WebView→SQLite round-trip for session
|
|
6
|
+
* save/load operations.
|
|
7
|
+
*
|
|
8
|
+
* Uses @capacitor-community/sqlite directly (same as DbBridgeHandler).
|
|
9
|
+
*/
|
|
10
|
+
export declare class SessionStore {
|
|
11
|
+
private sqlite;
|
|
12
|
+
private db;
|
|
13
|
+
private initPromise;
|
|
14
|
+
/**
|
|
15
|
+
* Ensure the DB connection is open. Idempotent — safe to call multiple times.
|
|
16
|
+
* Reuses the existing connection created by DbBridgeHandler.
|
|
17
|
+
*/
|
|
18
|
+
ensureReady(): Promise<void>;
|
|
19
|
+
private _init;
|
|
20
|
+
saveSession(params: {
|
|
21
|
+
sessionKey: string;
|
|
22
|
+
agentId: string;
|
|
23
|
+
messages: any[];
|
|
24
|
+
model?: string;
|
|
25
|
+
startTime: number;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
loadMessages(sessionKey: string): Promise<any[]>;
|
|
28
|
+
listSessions(agentId?: string): Promise<any[]>;
|
|
29
|
+
getLatestSession(agentId?: string): Promise<any | null>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../../src/agent/session-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,WAAW,CAA6B;IAEhD;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;YAUpB,KAAK;IA6Bb,WAAW,CAAC,MAAM,EAAE;QACxB,UAAU,EAAE,MAAM,CAAA;QAClB,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,GAAG,EAAE,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmEX,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAgBhD,YAAY,CAAC,OAAO,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAgB9C,gBAAgB,CAAC,OAAO,SAAS,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;CAiB9D"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionStore — Direct SQLite session persistence from the WebView.
|
|
3
|
+
*
|
|
4
|
+
* Accesses the same `mobile-claw` database used by DbBridgeHandler,
|
|
5
|
+
* eliminating the worker→bridge→WebView→SQLite round-trip for session
|
|
6
|
+
* save/load operations.
|
|
7
|
+
*
|
|
8
|
+
* Uses @capacitor-community/sqlite directly (same as DbBridgeHandler).
|
|
9
|
+
*/
|
|
10
|
+
import { Capacitor } from '@capacitor/core';
|
|
11
|
+
import { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite';
|
|
12
|
+
const DB_NAME = 'mobile-claw';
|
|
13
|
+
export class SessionStore {
|
|
14
|
+
sqlite = null;
|
|
15
|
+
db = null;
|
|
16
|
+
initPromise = null;
|
|
17
|
+
/**
|
|
18
|
+
* Ensure the DB connection is open. Idempotent — safe to call multiple times.
|
|
19
|
+
* Reuses the existing connection created by DbBridgeHandler.
|
|
20
|
+
*/
|
|
21
|
+
async ensureReady() {
|
|
22
|
+
if (this.db)
|
|
23
|
+
return;
|
|
24
|
+
if (this.initPromise) {
|
|
25
|
+
await this.initPromise;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.initPromise = this._init();
|
|
29
|
+
await this.initPromise;
|
|
30
|
+
}
|
|
31
|
+
async _init() {
|
|
32
|
+
this.sqlite = new SQLiteConnection(CapacitorSQLite);
|
|
33
|
+
const isWeb = Capacitor.getPlatform() === 'web';
|
|
34
|
+
if (isWeb) {
|
|
35
|
+
if (!document.querySelector('jeep-sqlite')) {
|
|
36
|
+
const el = document.createElement('jeep-sqlite');
|
|
37
|
+
document.body.appendChild(el);
|
|
38
|
+
}
|
|
39
|
+
await customElements.whenDefined('jeep-sqlite');
|
|
40
|
+
await this.sqlite.initWebStore();
|
|
41
|
+
}
|
|
42
|
+
await this.sqlite.checkConnectionsConsistency();
|
|
43
|
+
const isConn = await this.sqlite.isConnection(DB_NAME, false);
|
|
44
|
+
if (isConn.result) {
|
|
45
|
+
this.db = await this.sqlite.retrieveConnection(DB_NAME, false);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// DbBridgeHandler should have already created the connection.
|
|
49
|
+
// If not, create one (migrations are handled by DbBridgeHandler).
|
|
50
|
+
this.db = await this.sqlite.createConnection(DB_NAME, false, 'no-encryption', 2, false);
|
|
51
|
+
}
|
|
52
|
+
await this.db.open();
|
|
53
|
+
}
|
|
54
|
+
// ── Save ─────────────────────────────────────────────────────────────────
|
|
55
|
+
async saveSession(params) {
|
|
56
|
+
await this.ensureReady();
|
|
57
|
+
const now = Date.now();
|
|
58
|
+
// Compute usage totals
|
|
59
|
+
let inputTokens = 0;
|
|
60
|
+
let outputTokens = 0;
|
|
61
|
+
for (const msg of params.messages) {
|
|
62
|
+
if (msg.role === 'assistant' && msg.usage) {
|
|
63
|
+
inputTokens += msg.usage.input || 0;
|
|
64
|
+
outputTokens += msg.usage.output || 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const totalTokens = inputTokens + outputTokens;
|
|
68
|
+
// Upsert session row
|
|
69
|
+
await this.db.run(`INSERT INTO sessions (session_key, agent_id, created_at, updated_at, model, total_tokens, input_tokens, output_tokens)
|
|
70
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
71
|
+
ON CONFLICT(session_key) DO UPDATE SET
|
|
72
|
+
updated_at = excluded.updated_at,
|
|
73
|
+
model = excluded.model,
|
|
74
|
+
total_tokens = excluded.total_tokens,
|
|
75
|
+
input_tokens = excluded.input_tokens,
|
|
76
|
+
output_tokens = excluded.output_tokens`, [
|
|
77
|
+
params.sessionKey,
|
|
78
|
+
params.agentId,
|
|
79
|
+
params.startTime,
|
|
80
|
+
now,
|
|
81
|
+
params.model || null,
|
|
82
|
+
totalTokens,
|
|
83
|
+
inputTokens,
|
|
84
|
+
outputTokens,
|
|
85
|
+
], true);
|
|
86
|
+
// Insert messages (skip already-persisted ones)
|
|
87
|
+
const existingResult = await this.db.query('SELECT COUNT(*) as cnt FROM messages WHERE session_key = ?', [
|
|
88
|
+
params.sessionKey,
|
|
89
|
+
]);
|
|
90
|
+
const existingCount = existingResult.values?.[0]?.cnt || 0;
|
|
91
|
+
const newMessages = params.messages.slice(existingCount);
|
|
92
|
+
if (newMessages.length > 0) {
|
|
93
|
+
const stmts = newMessages.map((msg, i) => ({
|
|
94
|
+
statement: `INSERT OR IGNORE INTO messages (session_key, sequence, role, content, timestamp, model, tool_call_id, usage_input, usage_output)
|
|
95
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
96
|
+
values: [
|
|
97
|
+
params.sessionKey,
|
|
98
|
+
existingCount + i,
|
|
99
|
+
msg.role,
|
|
100
|
+
typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content),
|
|
101
|
+
msg.timestamp || now,
|
|
102
|
+
msg.model || params.model || null,
|
|
103
|
+
msg.toolCallId || null,
|
|
104
|
+
msg.usage?.input || null,
|
|
105
|
+
msg.usage?.output || null,
|
|
106
|
+
],
|
|
107
|
+
}));
|
|
108
|
+
await this.db.executeSet(stmts, true);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// ── Load ─────────────────────────────────────────────────────────────────
|
|
112
|
+
async loadMessages(sessionKey) {
|
|
113
|
+
await this.ensureReady();
|
|
114
|
+
const result = await this.db.query('SELECT role, content, timestamp, model, tool_call_id, usage_input, usage_output FROM messages WHERE session_key = ? ORDER BY sequence', [sessionKey]);
|
|
115
|
+
return (result.values || []).map((r) => ({
|
|
116
|
+
role: r.role,
|
|
117
|
+
content: _parseJsonSafe(r.content),
|
|
118
|
+
timestamp: r.timestamp,
|
|
119
|
+
model: r.model,
|
|
120
|
+
toolCallId: r.tool_call_id,
|
|
121
|
+
usage: r.usage_input || r.usage_output ? { input: r.usage_input, output: r.usage_output } : undefined,
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
async listSessions(agentId = 'main') {
|
|
125
|
+
await this.ensureReady();
|
|
126
|
+
const result = await this.db.query('SELECT session_key, created_at, updated_at, model, total_tokens FROM sessions WHERE agent_id = ? ORDER BY updated_at DESC', [agentId]);
|
|
127
|
+
return (result.values || []).map((r) => ({
|
|
128
|
+
sessionKey: r.session_key,
|
|
129
|
+
sessionId: r.session_key,
|
|
130
|
+
createdAt: r.created_at,
|
|
131
|
+
updatedAt: r.updated_at,
|
|
132
|
+
model: r.model,
|
|
133
|
+
totalTokens: r.total_tokens,
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
async getLatestSession(agentId = 'main') {
|
|
137
|
+
await this.ensureReady();
|
|
138
|
+
const result = await this.db.query('SELECT session_key, created_at, updated_at, model, total_tokens FROM sessions WHERE agent_id = ? ORDER BY updated_at DESC LIMIT 1', [agentId]);
|
|
139
|
+
const row = result.values?.[0];
|
|
140
|
+
if (!row)
|
|
141
|
+
return null;
|
|
142
|
+
return {
|
|
143
|
+
sessionKey: row.session_key,
|
|
144
|
+
sessionId: row.session_key,
|
|
145
|
+
createdAt: row.created_at,
|
|
146
|
+
updatedAt: row.updated_at,
|
|
147
|
+
model: row.model,
|
|
148
|
+
totalTokens: row.total_tokens,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function _parseJsonSafe(s) {
|
|
153
|
+
if (typeof s !== 'string')
|
|
154
|
+
return s;
|
|
155
|
+
try {
|
|
156
|
+
return JSON.parse(s);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return s;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=session-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-store.js","sourceRoot":"","sources":["../../../src/agent/session-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE/E,MAAM,OAAO,GAAG,aAAa,CAAA;AAE7B,MAAM,OAAO,YAAY;IACf,MAAM,GAA4B,IAAI,CAAA;IACtC,EAAE,GAAQ,IAAI,CAAA;IACd,WAAW,GAAyB,IAAI,CAAA;IAEhD;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,IAAI,IAAI,CAAC,EAAE;YAAE,OAAM;QACnB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,IAAI,CAAC,WAAW,CAAA;YACtB,OAAM;QACR,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,K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AC,YAAY;SAC9B,CAAA;IACH,CAAC;CACF;AAED,SAAS,cAAc,CAAC,CAAS;IAC/B,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAA;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAA;IACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolProxy — Optimistic worker tool bridge.
|
|
3
|
+
*
|
|
4
|
+
* Wraps each Node.js-dependent tool (file I/O, git, VM) as an AgentTool
|
|
5
|
+
* whose execute() sends a `tool.execute` message to the worker and awaits
|
|
6
|
+
* `tool.execute.result`.
|
|
7
|
+
*
|
|
8
|
+
* Uses optimistic enqueue: tool calls are queued immediately. If the worker
|
|
9
|
+
* isn't ready yet, they sit in a pending queue and flush automatically when
|
|
10
|
+
* `worker.ready` arrives. The Capacitor-NodeJS bridge rejects send() before
|
|
11
|
+
* ready, so we manage our own queue.
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentTool } from '@mariozechner/pi-agent-core';
|
|
14
|
+
export declare class ToolProxy {
|
|
15
|
+
private workerReady;
|
|
16
|
+
private pendingQueue;
|
|
17
|
+
private inflightCalls;
|
|
18
|
+
private sendFn;
|
|
19
|
+
/**
|
|
20
|
+
* Set the bridge send function. Called by MobileClawEngine once the
|
|
21
|
+
* nodePlugin is available (which happens before the worker is ready).
|
|
22
|
+
*/
|
|
23
|
+
setBridge(sendFn: (msg: Record<string, unknown>) => Promise<void>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Called when `worker.ready` is received. Flushes the pending queue.
|
|
26
|
+
*/
|
|
27
|
+
setWorkerReady(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Handle a `tool.execute.result` message from the worker.
|
|
30
|
+
*/
|
|
31
|
+
handleResult(msg: {
|
|
32
|
+
toolCallId: string;
|
|
33
|
+
toolName: string;
|
|
34
|
+
result?: unknown;
|
|
35
|
+
error?: string;
|
|
36
|
+
}): void;
|
|
37
|
+
/**
|
|
38
|
+
* Build AgentTool[] from the shared schemas. Each tool's execute()
|
|
39
|
+
* proxies to the worker via the bridge.
|
|
40
|
+
*/
|
|
41
|
+
buildTools(): AgentTool<any>[];
|
|
42
|
+
private _executeViaWorker;
|
|
43
|
+
private _flushQueue;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=tool-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-proxy.d.ts","sourceRoot":"","sources":["../../../src/agent/tool-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,6BAA6B,CAAA;AAY7E,qBAAa,SAAS;IACpB,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,aAAa,CAGlB;IACH,OAAO,CAAC,MAAM,CAAiE;IAE/E;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIxE;;OAEG;IACH,cAAc,IAAI,IAAI;IAKtB;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAwBnG;;;OAGG;IACH,UAAU,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE;IAc9B,OAAO,CAAC,iBAAiB;IAqEzB,OAAO,CAAC,WAAW;CAepB"}
|