capacitor-mobile-claw 2.0.0 → 2.0.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/package.json +1 -1
- package/dist/esm/agent/agent-runner.d.ts +0 -93
- package/dist/esm/agent/agent-runner.d.ts.map +0 -1
- package/dist/esm/agent/agent-runner.js +0 -352
- package/dist/esm/agent/agent-runner.js.map +0 -1
- package/dist/esm/agent/auth-store.d.ts +0 -31
- package/dist/esm/agent/auth-store.d.ts.map +0 -1
- package/dist/esm/agent/auth-store.js +0 -121
- package/dist/esm/agent/auth-store.js.map +0 -1
- package/dist/esm/agent/capacitor-fs-adapter.d.ts +0 -65
- package/dist/esm/agent/capacitor-fs-adapter.d.ts.map +0 -1
- package/dist/esm/agent/capacitor-fs-adapter.js +0 -186
- package/dist/esm/agent/capacitor-fs-adapter.js.map +0 -1
- package/dist/esm/agent/cron-db-access.d.ts +0 -116
- package/dist/esm/agent/cron-db-access.d.ts.map +0 -1
- package/dist/esm/agent/cron-db-access.js +0 -741
- package/dist/esm/agent/cron-db-access.js.map +0 -1
- package/dist/esm/agent/fetch-proxy.d.ts +0 -2
- package/dist/esm/agent/fetch-proxy.d.ts.map +0 -1
- package/dist/esm/agent/fetch-proxy.js +0 -171
- package/dist/esm/agent/fetch-proxy.js.map +0 -1
- package/dist/esm/agent/file-tools.d.ts +0 -17
- package/dist/esm/agent/file-tools.d.ts.map +0 -1
- package/dist/esm/agent/file-tools.js +0 -295
- package/dist/esm/agent/file-tools.js.map +0 -1
- package/dist/esm/agent/git-tools.d.ts +0 -17
- package/dist/esm/agent/git-tools.d.ts.map +0 -1
- package/dist/esm/agent/git-tools.js +0 -184
- package/dist/esm/agent/git-tools.js.map +0 -1
- package/dist/esm/agent/heartbeat-manager.d.ts +0 -63
- package/dist/esm/agent/heartbeat-manager.d.ts.map +0 -1
- package/dist/esm/agent/heartbeat-manager.js +0 -711
- package/dist/esm/agent/heartbeat-manager.js.map +0 -1
- package/dist/esm/agent/retry-logic.d.ts +0 -9
- package/dist/esm/agent/retry-logic.d.ts.map +0 -1
- package/dist/esm/agent/retry-logic.js +0 -30
- package/dist/esm/agent/retry-logic.js.map +0 -1
- package/dist/esm/agent/session-store.d.ts +0 -31
- package/dist/esm/agent/session-store.d.ts.map +0 -1
- package/dist/esm/agent/session-store.js +0 -223
- package/dist/esm/agent/session-store.js.map +0 -1
- package/dist/esm/agent/tool-proxy.d.ts +0 -25
- package/dist/esm/agent/tool-proxy.d.ts.map +0 -1
- package/dist/esm/agent/tool-proxy.js +0 -58
- package/dist/esm/agent/tool-proxy.js.map +0 -1
- package/dist/esm/agent/tool-schemas.d.ts +0 -16
- package/dist/esm/agent/tool-schemas.d.ts.map +0 -1
- package/dist/esm/agent/tool-schemas.js +0 -129
- package/dist/esm/agent/tool-schemas.js.map +0 -1
- package/dist/esm/agent/wasm-tools.d.ts +0 -11
- package/dist/esm/agent/wasm-tools.d.ts.map +0 -1
- package/dist/esm/agent/wasm-tools.js +0 -70
- package/dist/esm/agent/wasm-tools.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capacitor-mobile-claw",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "On-device AI agent engine for Capacitor apps — thin WebView bridge to a native Rust agent with LLM, tool execution, cron, and MCP support",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
* Tool policy is consumer-owned. Consumers can supply a generic tool
|
|
12
|
-
* middleware to wrap tool execution, or use the legacy pre-execute hook
|
|
13
|
-
* for simple approval gates.
|
|
14
|
-
*
|
|
15
|
-
* Retry logic remains built in for transient API errors.
|
|
16
|
-
*/
|
|
17
|
-
import type { ToolMiddleware } from '../definitions';
|
|
18
|
-
import type { ToolProxy } from './tool-proxy';
|
|
19
|
-
type Agent = import('@mariozechner/pi-agent-core').Agent;
|
|
20
|
-
type AgentMessage = import('@mariozechner/pi-agent-core').AgentMessage;
|
|
21
|
-
type AgentTool<TParameters extends import('@sinclair/typebox').TSchema = import('@sinclair/typebox').TSchema, TDetails = any> = import('@mariozechner/pi-agent-core').AgentTool<TParameters, TDetails>;
|
|
22
|
-
export interface AgentRunnerConfig {
|
|
23
|
-
/** Function to dispatch agent events directly to the engine's listener system */
|
|
24
|
-
dispatch: (msg: Record<string, unknown>) => void;
|
|
25
|
-
/** Tool proxy for bridging tool calls to the worker */
|
|
26
|
-
toolProxy: ToolProxy;
|
|
27
|
-
/** Optional middleware that wraps tool execution. */
|
|
28
|
-
toolMiddleware?: ToolMiddleware;
|
|
29
|
-
/** Pre-execute hook — fires before each tool call, returns approved/denied result */
|
|
30
|
-
preExecuteHook?: (toolCallId: string, toolName: string, args: Record<string, unknown>, signal?: AbortSignal) => Promise<PreExecuteResult>;
|
|
31
|
-
}
|
|
32
|
-
export interface PreExecuteResult {
|
|
33
|
-
deny?: boolean;
|
|
34
|
-
denyReason?: string;
|
|
35
|
-
args: Record<string, unknown>;
|
|
36
|
-
}
|
|
37
|
-
export interface AgentRunParams {
|
|
38
|
-
prompt: string;
|
|
39
|
-
agentId: string;
|
|
40
|
-
sessionKey: string;
|
|
41
|
-
model?: string;
|
|
42
|
-
provider?: string;
|
|
43
|
-
apiKey: string;
|
|
44
|
-
systemPrompt: string;
|
|
45
|
-
maxTurns?: number;
|
|
46
|
-
allowedTools?: string[];
|
|
47
|
-
/** Additional tools (MCP device tools) to merge with proxied worker tools */
|
|
48
|
-
extraTools?: AgentTool<any>[];
|
|
49
|
-
}
|
|
50
|
-
export declare class AgentRunner {
|
|
51
|
-
private agent;
|
|
52
|
-
private currentSessionKey;
|
|
53
|
-
private dispatch;
|
|
54
|
-
private toolProxy;
|
|
55
|
-
private toolMiddleware?;
|
|
56
|
-
private preExecuteHook?;
|
|
57
|
-
constructor(config: AgentRunnerConfig);
|
|
58
|
-
/** Whether the agent is currently streaming / executing tools */
|
|
59
|
-
get isRunning(): boolean;
|
|
60
|
-
get sessionKey(): string | null;
|
|
61
|
-
get currentAgent(): Agent | null;
|
|
62
|
-
run(params: AgentRunParams): Promise<void>;
|
|
63
|
-
/** Continue an existing conversation with a new prompt */
|
|
64
|
-
followUp(prompt: string): Promise<void>;
|
|
65
|
-
/** Abort the current agent turn */
|
|
66
|
-
abort(): void;
|
|
67
|
-
/** Send a steering message to the agent mid-turn */
|
|
68
|
-
steer(text: string): void;
|
|
69
|
-
/** Clear the current session (keep transcripts) */
|
|
70
|
-
clear(): void;
|
|
71
|
-
/** Resume a session by hydrating with saved messages */
|
|
72
|
-
resume(params: {
|
|
73
|
-
sessionKey: string;
|
|
74
|
-
messages: AgentMessage[];
|
|
75
|
-
systemPrompt: string;
|
|
76
|
-
apiKey: string;
|
|
77
|
-
model?: string;
|
|
78
|
-
provider?: string;
|
|
79
|
-
extraTools?: AgentTool<any>[];
|
|
80
|
-
}): Promise<void>;
|
|
81
|
-
/** Map pi-agent-core AgentEvent to bridge protocol messages */
|
|
82
|
-
private _dispatchAgentEvent;
|
|
83
|
-
/**
|
|
84
|
-
* Wrap tools with optional consumer middleware or the legacy pre-execute hook.
|
|
85
|
-
*/
|
|
86
|
-
private _wrapTools;
|
|
87
|
-
/** Extract cumulative token usage from agent messages */
|
|
88
|
-
private _extractUsage;
|
|
89
|
-
/** Check if an error is transient (worth retrying) */
|
|
90
|
-
private _isTransientError;
|
|
91
|
-
}
|
|
92
|
-
export {};
|
|
93
|
-
//# sourceMappingURL=agent-runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../../src/agent/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAK7C,KAAK,KAAK,GAAG,OAAO,6BAA6B,EAAE,KAAK,CAAA;AAExD,KAAK,YAAY,GAAG,OAAO,6BAA6B,EAAE,YAAY,CAAA;AACtE,KAAK,SAAS,CACZ,WAAW,SAAS,OAAO,mBAAmB,EAAE,OAAO,GAAG,OAAO,mBAAmB,EAAE,OAAO,EAC7F,QAAQ,GAAG,GAAG,IACZ,OAAO,6BAA6B,EAAE,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;AAE1E,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IAChD,uDAAuD;IACvD,SAAS,EAAE,SAAS,CAAA;IACpB,qDAAqD;IACrD,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,qFAAqF;IACrF,cAAc,CAAC,EAAE,CACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;C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AE,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,OAAO,CAAC,IAAI,CAAC;IA2CjB,+DAA+D;IAC/D,OAAO,CAAC,mBAAmB;IAqC3B;;OAEG;IACH,OAAO,CAAC,UAAU;IA4ClB,yDAAyD;IACzD,OAAO,CAAC,aAAa;IAerB,sDAAsD;IACtD,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -1,352 +0,0 @@
|
|
|
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
|
-
* Tool policy is consumer-owned. Consumers can supply a generic tool
|
|
12
|
-
* middleware to wrap tool execution, or use the legacy pre-execute hook
|
|
13
|
-
* for simple approval gates.
|
|
14
|
-
*
|
|
15
|
-
* Retry logic remains built in for transient API errors.
|
|
16
|
-
*/
|
|
17
|
-
import { withRetry } from './retry-logic';
|
|
18
|
-
export class AgentRunner {
|
|
19
|
-
agent = null;
|
|
20
|
-
currentSessionKey = null;
|
|
21
|
-
dispatch;
|
|
22
|
-
toolProxy;
|
|
23
|
-
toolMiddleware;
|
|
24
|
-
preExecuteHook;
|
|
25
|
-
constructor(config) {
|
|
26
|
-
this.dispatch = config.dispatch;
|
|
27
|
-
this.toolProxy = config.toolProxy;
|
|
28
|
-
this.toolMiddleware = config.toolMiddleware;
|
|
29
|
-
this.preExecuteHook = config.preExecuteHook;
|
|
30
|
-
}
|
|
31
|
-
/** Whether the agent is currently streaming / executing tools */
|
|
32
|
-
get isRunning() {
|
|
33
|
-
return this.agent?.state.isStreaming ?? false;
|
|
34
|
-
}
|
|
35
|
-
get sessionKey() {
|
|
36
|
-
return this.currentSessionKey;
|
|
37
|
-
}
|
|
38
|
-
get currentAgent() {
|
|
39
|
-
return this.agent;
|
|
40
|
-
}
|
|
41
|
-
// ── Agent lifecycle ──────────────────────────────────────────────────────
|
|
42
|
-
async run(params) {
|
|
43
|
-
const provider = params.provider || 'anthropic';
|
|
44
|
-
const DEFAULT_MODELS = {
|
|
45
|
-
anthropic: 'claude-sonnet-4-5',
|
|
46
|
-
openrouter: 'anthropic/claude-sonnet-4.5',
|
|
47
|
-
openai: 'gpt-4o',
|
|
48
|
-
};
|
|
49
|
-
const modelId = params.model || DEFAULT_MODELS[provider] || null;
|
|
50
|
-
if (!modelId) {
|
|
51
|
-
this.dispatch({
|
|
52
|
-
type: 'agent.error',
|
|
53
|
-
error: `No model specified for provider "${provider}". Select a model in Settings.`,
|
|
54
|
-
});
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
// Lazy-load pi-ai and pi-agent-core — only pulled into the bundle when
|
|
58
|
-
// the agent is actually used (keeps the package tree-shakeable for
|
|
59
|
-
// consumers that don't use useWebViewAgent).
|
|
60
|
-
const [{ getModel }, { Agent }] = await Promise.all([
|
|
61
|
-
import('@mariozechner/pi-ai'),
|
|
62
|
-
import('@mariozechner/pi-agent-core'),
|
|
63
|
-
]);
|
|
64
|
-
const model = getModel(provider, modelId);
|
|
65
|
-
if (!model) {
|
|
66
|
-
this.dispatch({
|
|
67
|
-
type: 'agent.error',
|
|
68
|
-
error: `Model "${modelId}" not found for provider "${provider}".`,
|
|
69
|
-
});
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
// Build tools: proxied worker tools + optional MCP/memory tools
|
|
73
|
-
const workerTools = this._wrapTools(this.toolProxy.buildTools());
|
|
74
|
-
const extraTools = params.extraTools ? this._wrapTools(params.extraTools) : [];
|
|
75
|
-
let tools = [...workerTools, ...extraTools];
|
|
76
|
-
if (params.allowedTools?.length) {
|
|
77
|
-
tools = tools.filter((tool) => params.allowedTools?.includes(tool.name));
|
|
78
|
-
}
|
|
79
|
-
this.agent = new Agent({
|
|
80
|
-
initialState: {
|
|
81
|
-
systemPrompt: params.systemPrompt,
|
|
82
|
-
model,
|
|
83
|
-
tools,
|
|
84
|
-
thinkingLevel: 'off',
|
|
85
|
-
},
|
|
86
|
-
convertToLlm: (messages) => messages.filter((m) => m.role === 'user' || m.role === 'assistant' || m.role === 'toolResult'),
|
|
87
|
-
getApiKey: () => params.apiKey,
|
|
88
|
-
});
|
|
89
|
-
this.currentSessionKey = params.sessionKey;
|
|
90
|
-
// Subscribe to events — dispatch DIRECTLY to the engine (no bridge hop)
|
|
91
|
-
let turnCount = 0;
|
|
92
|
-
this.agent.subscribe((event) => {
|
|
93
|
-
if (event.type === 'turn_end' && params.maxTurns) {
|
|
94
|
-
turnCount += 1;
|
|
95
|
-
if (turnCount >= params.maxTurns) {
|
|
96
|
-
this.agent?.abort();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
this._dispatchAgentEvent(event);
|
|
100
|
-
});
|
|
101
|
-
// Echo user prompt to UI
|
|
102
|
-
this.dispatch({
|
|
103
|
-
type: 'agent.event',
|
|
104
|
-
eventType: 'user_message',
|
|
105
|
-
data: { text: params.prompt, sessionKey: params.sessionKey },
|
|
106
|
-
});
|
|
107
|
-
// Run the agent loop with retry logic for transient errors
|
|
108
|
-
const startTime = Date.now();
|
|
109
|
-
try {
|
|
110
|
-
await withRetry(async () => {
|
|
111
|
-
await this.agent?.prompt(params.prompt);
|
|
112
|
-
await this.agent?.waitForIdle();
|
|
113
|
-
}, { maxRetries: 2, baseDelayMs: 2000 }, (attempt, delayMs) => {
|
|
114
|
-
this.dispatch({
|
|
115
|
-
type: 'agent.event',
|
|
116
|
-
eventType: 'retry',
|
|
117
|
-
data: { attempt, delayMs, sessionKey: params.sessionKey },
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
const usage = this._extractUsage();
|
|
121
|
-
this.dispatch({
|
|
122
|
-
type: 'agent.completed',
|
|
123
|
-
sessionKey: params.sessionKey,
|
|
124
|
-
usage,
|
|
125
|
-
cumulativeUsage: usage,
|
|
126
|
-
model: modelId,
|
|
127
|
-
durationMs: Date.now() - startTime,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
const retryable = this._isTransientError(err);
|
|
132
|
-
this.dispatch({
|
|
133
|
-
type: 'agent.error',
|
|
134
|
-
error: err.message || 'Unknown error during agent execution',
|
|
135
|
-
code: err.status ? String(err.status) : undefined,
|
|
136
|
-
retryable,
|
|
137
|
-
});
|
|
138
|
-
if (!retryable) {
|
|
139
|
-
this.agent = null;
|
|
140
|
-
this.currentSessionKey = null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/** Continue an existing conversation with a new prompt */
|
|
145
|
-
async followUp(prompt) {
|
|
146
|
-
if (!this.agent || this.agent.state.messages.length === 0) {
|
|
147
|
-
this.dispatch({ type: 'agent.error', error: 'No active session to follow up on' });
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
// Auto-abort in-flight turn
|
|
151
|
-
if (this.agent.state.isStreaming) {
|
|
152
|
-
this.agent.abort();
|
|
153
|
-
await this.agent.waitForIdle();
|
|
154
|
-
this.dispatch({
|
|
155
|
-
type: 'agent.event',
|
|
156
|
-
eventType: 'interrupted',
|
|
157
|
-
data: { reason: 'New message sent while streaming' },
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
// Echo user prompt
|
|
161
|
-
this.dispatch({
|
|
162
|
-
type: 'agent.event',
|
|
163
|
-
eventType: 'user_message',
|
|
164
|
-
data: { text: prompt, sessionKey: this.currentSessionKey },
|
|
165
|
-
});
|
|
166
|
-
const startTime = Date.now();
|
|
167
|
-
try {
|
|
168
|
-
await withRetry(async () => {
|
|
169
|
-
await this.agent?.prompt(prompt);
|
|
170
|
-
await this.agent?.waitForIdle();
|
|
171
|
-
}, { maxRetries: 2, baseDelayMs: 2000 }, (attempt, delayMs) => {
|
|
172
|
-
this.dispatch({
|
|
173
|
-
type: 'agent.event',
|
|
174
|
-
eventType: 'retry',
|
|
175
|
-
data: { attempt, delayMs, sessionKey: this.currentSessionKey },
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
const usage = this._extractUsage();
|
|
179
|
-
this.dispatch({
|
|
180
|
-
type: 'agent.completed',
|
|
181
|
-
sessionKey: this.currentSessionKey,
|
|
182
|
-
usage,
|
|
183
|
-
cumulativeUsage: usage,
|
|
184
|
-
model: this.agent?.state?.model?.id ?? undefined,
|
|
185
|
-
durationMs: Date.now() - startTime,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
catch (err) {
|
|
189
|
-
const retryable = this._isTransientError(err);
|
|
190
|
-
this.dispatch({
|
|
191
|
-
type: 'agent.error',
|
|
192
|
-
error: err.message || 'Follow-up error',
|
|
193
|
-
code: err.status ? String(err.status) : undefined,
|
|
194
|
-
retryable,
|
|
195
|
-
});
|
|
196
|
-
if (!retryable) {
|
|
197
|
-
this.agent = null;
|
|
198
|
-
this.currentSessionKey = null;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/** Abort the current agent turn */
|
|
203
|
-
abort() {
|
|
204
|
-
this.agent?.abort();
|
|
205
|
-
}
|
|
206
|
-
/** Send a steering message to the agent mid-turn */
|
|
207
|
-
steer(text) {
|
|
208
|
-
if (!this.agent)
|
|
209
|
-
return;
|
|
210
|
-
this.agent.steer({ role: 'user', content: text, timestamp: Date.now() });
|
|
211
|
-
}
|
|
212
|
-
/** Clear the current session (keep transcripts) */
|
|
213
|
-
clear() {
|
|
214
|
-
this.agent = null;
|
|
215
|
-
this.currentSessionKey = null;
|
|
216
|
-
}
|
|
217
|
-
/** Resume a session by hydrating with saved messages */
|
|
218
|
-
async resume(params) {
|
|
219
|
-
const provider = params.provider || 'anthropic';
|
|
220
|
-
const DEFAULT_MODELS = {
|
|
221
|
-
anthropic: 'claude-sonnet-4-5',
|
|
222
|
-
openrouter: 'anthropic/claude-sonnet-4.5',
|
|
223
|
-
openai: 'gpt-4o',
|
|
224
|
-
};
|
|
225
|
-
const modelId = params.model || DEFAULT_MODELS[provider] || 'claude-sonnet-4-5';
|
|
226
|
-
const [{ getModel }, { Agent }] = await Promise.all([
|
|
227
|
-
import('@mariozechner/pi-ai'),
|
|
228
|
-
import('@mariozechner/pi-agent-core'),
|
|
229
|
-
]);
|
|
230
|
-
const model = getModel(provider, modelId);
|
|
231
|
-
if (!model)
|
|
232
|
-
return;
|
|
233
|
-
const workerTools = this._wrapTools(this.toolProxy.buildTools());
|
|
234
|
-
const extraTools = params.extraTools ? this._wrapTools(params.extraTools) : [];
|
|
235
|
-
const tools = [...workerTools, ...extraTools];
|
|
236
|
-
this.agent = new Agent({
|
|
237
|
-
initialState: {
|
|
238
|
-
systemPrompt: params.systemPrompt,
|
|
239
|
-
model,
|
|
240
|
-
tools,
|
|
241
|
-
thinkingLevel: 'off',
|
|
242
|
-
},
|
|
243
|
-
convertToLlm: (msgs) => msgs.filter((m) => m.role === 'user' || m.role === 'assistant' || m.role === 'toolResult'),
|
|
244
|
-
getApiKey: () => params.apiKey,
|
|
245
|
-
});
|
|
246
|
-
this.agent.replaceMessages(params.messages);
|
|
247
|
-
this.agent.subscribe((event) => {
|
|
248
|
-
this._dispatchAgentEvent(event);
|
|
249
|
-
});
|
|
250
|
-
this.currentSessionKey = params.sessionKey;
|
|
251
|
-
}
|
|
252
|
-
// ── Private ──────────────────────────────────────────────────────────────
|
|
253
|
-
/** Map pi-agent-core AgentEvent to bridge protocol messages */
|
|
254
|
-
_dispatchAgentEvent(event) {
|
|
255
|
-
switch (event.type) {
|
|
256
|
-
case 'message_update': {
|
|
257
|
-
const e = event.assistantMessageEvent;
|
|
258
|
-
if (e?.type === 'text_delta') {
|
|
259
|
-
this.dispatch({ type: 'agent.event', eventType: 'text_delta', data: { text: e.delta } });
|
|
260
|
-
}
|
|
261
|
-
if (e?.type === 'thinking_delta') {
|
|
262
|
-
this.dispatch({ type: 'agent.event', eventType: 'thinking', data: { text: e.delta } });
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
case 'tool_execution_start':
|
|
267
|
-
this.dispatch({
|
|
268
|
-
type: 'agent.event',
|
|
269
|
-
eventType: 'tool_use',
|
|
270
|
-
data: {
|
|
271
|
-
toolName: event.toolName,
|
|
272
|
-
toolCallId: event.toolCallId,
|
|
273
|
-
args: event.args,
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
break;
|
|
277
|
-
case 'tool_execution_end':
|
|
278
|
-
this.dispatch({
|
|
279
|
-
type: 'agent.event',
|
|
280
|
-
eventType: 'tool_result',
|
|
281
|
-
data: {
|
|
282
|
-
toolName: event.toolName,
|
|
283
|
-
toolCallId: event.toolCallId,
|
|
284
|
-
result: event.result,
|
|
285
|
-
},
|
|
286
|
-
});
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Wrap tools with optional consumer middleware or the legacy pre-execute hook.
|
|
292
|
-
*/
|
|
293
|
-
_wrapTools(tools) {
|
|
294
|
-
const middleware = this.toolMiddleware;
|
|
295
|
-
const hook = this.preExecuteHook;
|
|
296
|
-
if (!middleware && !hook) {
|
|
297
|
-
return tools;
|
|
298
|
-
}
|
|
299
|
-
return tools.map((tool) => ({
|
|
300
|
-
...tool,
|
|
301
|
-
execute: async (toolCallId, params, signal, onUpdate) => {
|
|
302
|
-
const execute = (nextArgs) => tool.execute(toolCallId, nextArgs ?? params, signal, onUpdate);
|
|
303
|
-
if (middleware) {
|
|
304
|
-
return middleware({
|
|
305
|
-
name: tool.name,
|
|
306
|
-
toolCallId,
|
|
307
|
-
args: params,
|
|
308
|
-
}, execute, signal);
|
|
309
|
-
}
|
|
310
|
-
if (!hook) {
|
|
311
|
-
return execute();
|
|
312
|
-
}
|
|
313
|
-
const result = await hook(toolCallId, tool.name, params, signal);
|
|
314
|
-
if (result.deny) {
|
|
315
|
-
return {
|
|
316
|
-
content: [
|
|
317
|
-
{ type: 'text', text: result.denyReason || `Tool "${tool.name}" execution was denied.` },
|
|
318
|
-
],
|
|
319
|
-
details: { denied: true, reason: result.denyReason || 'client_denied' },
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
return execute(result.args);
|
|
323
|
-
},
|
|
324
|
-
}));
|
|
325
|
-
}
|
|
326
|
-
/** Extract cumulative token usage from agent messages */
|
|
327
|
-
_extractUsage() {
|
|
328
|
-
let input = 0;
|
|
329
|
-
let output = 0;
|
|
330
|
-
if (this.agent) {
|
|
331
|
-
for (const msg of this.agent.state.messages) {
|
|
332
|
-
const m = msg;
|
|
333
|
-
if (m.role === 'assistant' && m.usage) {
|
|
334
|
-
input += m.usage.input || 0;
|
|
335
|
-
output += m.usage.output || 0;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return { inputTokens: input, outputTokens: output, totalTokens: input + output };
|
|
340
|
-
}
|
|
341
|
-
/** Check if an error is transient (worth retrying) */
|
|
342
|
-
_isTransientError(err) {
|
|
343
|
-
const status = err.status || err.statusCode;
|
|
344
|
-
if (status === 429 || status === 503 || status === 502)
|
|
345
|
-
return true;
|
|
346
|
-
const msg = (err.message || '').toLowerCase();
|
|
347
|
-
if (msg.includes('rate limit') || msg.includes('overloaded') || msg.includes('timeout'))
|
|
348
|
-
return true;
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
//# sourceMappingURL=agent-runner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/agent/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;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AAE,MAAM,EAAE,WAAW,EAAE,KAAK,GAAG,MAAM,EAAE,CAAA;IAClF,CAAC;IAED,sDAAsD;IAC9C,iBAAiB,CAAC,GAAQ;QAChC,MAAM,MAAM,GAAG,GAAG,CAAC,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"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth profile management via @capacitor/filesystem.
|
|
3
|
-
*
|
|
4
|
-
* Replaces the Node.js worker's auth-profiles.json file operations.
|
|
5
|
-
* Reads/writes auth profiles directly from the WebView.
|
|
6
|
-
*/
|
|
7
|
-
export declare function setAuthRoot(root: string): void;
|
|
8
|
-
/**
|
|
9
|
-
* Get the API key for a provider. Returns { apiKey, isOAuth }.
|
|
10
|
-
*/
|
|
11
|
-
export declare function getAuthToken(provider?: string, agentId?: string): Promise<{
|
|
12
|
-
apiKey: string | null;
|
|
13
|
-
isOAuth: boolean;
|
|
14
|
-
}>;
|
|
15
|
-
/**
|
|
16
|
-
* Set an API key or OAuth token for a provider.
|
|
17
|
-
*/
|
|
18
|
-
export declare function setAuthKey(key: string, provider?: string, agentId?: string, type?: 'api_key' | 'oauth'): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Delete auth for a provider.
|
|
21
|
-
*/
|
|
22
|
-
export declare function deleteAuth(provider?: string, agentId?: string): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Get auth status (has key, masked key) for a provider.
|
|
25
|
-
*/
|
|
26
|
-
export declare function getAuthStatus(provider?: string): Promise<{
|
|
27
|
-
hasKey: boolean;
|
|
28
|
-
masked: string;
|
|
29
|
-
provider: string;
|
|
30
|
-
}>;
|
|
31
|
-
//# sourceMappingURL=auth-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../src/agent/auth-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2BH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9C;AAmDD;;GAEG;AACH,wBAAsB,YAAY,CAChC,QAAQ,SAAc,EACtB,OAAO,SAAS,GACf,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAKtD;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,QAAQ,SAAc,EACtB,OAAO,SAAS,EAChB,IAAI,GAAE,SAAS,GAAG,OAAmB,GACpC,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,SAAc,EAAE,OAAO,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CASxF;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,QAAQ,SAAc,GACrB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAehE"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth profile management via @capacitor/filesystem.
|
|
3
|
-
*
|
|
4
|
-
* Replaces the Node.js worker's auth-profiles.json file operations.
|
|
5
|
-
* Reads/writes auth profiles directly from the WebView.
|
|
6
|
-
*/
|
|
7
|
-
import { Capacitor } from '@capacitor/core';
|
|
8
|
-
import { Directory, Encoding, Filesystem } from '@capacitor/filesystem';
|
|
9
|
-
function getDataDirectory() {
|
|
10
|
-
return Capacitor.getPlatform() === 'ios' ? Directory.Library : Directory.Data;
|
|
11
|
-
}
|
|
12
|
-
let _openclawRoot = 'nodejs/data';
|
|
13
|
-
export function setAuthRoot(root) {
|
|
14
|
-
_openclawRoot = root;
|
|
15
|
-
}
|
|
16
|
-
function authProfilesPath(agentId = 'main') {
|
|
17
|
-
return `${_openclawRoot}/agents/${agentId}/agent/auth-profiles.json`;
|
|
18
|
-
}
|
|
19
|
-
async function loadAuthProfiles(agentId = 'main') {
|
|
20
|
-
try {
|
|
21
|
-
const result = await Filesystem.readFile({
|
|
22
|
-
path: authProfilesPath(agentId),
|
|
23
|
-
directory: getDataDirectory(),
|
|
24
|
-
encoding: Encoding.UTF8,
|
|
25
|
-
});
|
|
26
|
-
return JSON.parse(result.data);
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return { version: 1, profiles: {}, lastGood: {}, usageStats: {} };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async function saveAuthProfiles(profiles, agentId = 'main') {
|
|
33
|
-
await Filesystem.writeFile({
|
|
34
|
-
path: authProfilesPath(agentId),
|
|
35
|
-
data: JSON.stringify(profiles, null, 2),
|
|
36
|
-
directory: getDataDirectory(),
|
|
37
|
-
encoding: Encoding.UTF8,
|
|
38
|
-
recursive: true,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function resolveApiKeyForProvider(authProfiles, provider) {
|
|
42
|
-
// Prefer lastGood profile for this provider
|
|
43
|
-
const lastGoodKey = authProfiles.lastGood?.[provider];
|
|
44
|
-
if (lastGoodKey && authProfiles.profiles[lastGoodKey]) {
|
|
45
|
-
const p = authProfiles.profiles[lastGoodKey];
|
|
46
|
-
if (p.provider === provider) {
|
|
47
|
-
if (p.type === 'oauth' && p.access)
|
|
48
|
-
return p.access;
|
|
49
|
-
if (p.type === 'api_key' && p.key)
|
|
50
|
-
return p.key;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// Fallback: scan profiles (prefer oauth over api_key for anthropic)
|
|
54
|
-
let fallbackApiKey = null;
|
|
55
|
-
for (const profile of Object.values(authProfiles.profiles)) {
|
|
56
|
-
if (profile.provider !== provider)
|
|
57
|
-
continue;
|
|
58
|
-
if (profile.type === 'oauth' && profile.access)
|
|
59
|
-
return profile.access;
|
|
60
|
-
if (profile.type === 'api_key' && profile.key && !fallbackApiKey) {
|
|
61
|
-
fallbackApiKey = profile.key;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return fallbackApiKey;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get the API key for a provider. Returns { apiKey, isOAuth }.
|
|
68
|
-
*/
|
|
69
|
-
export async function getAuthToken(provider = 'anthropic', agentId = 'main') {
|
|
70
|
-
const profiles = await loadAuthProfiles(agentId);
|
|
71
|
-
const apiKey = resolveApiKeyForProvider(profiles, provider);
|
|
72
|
-
const isOAuth = apiKey ? apiKey.startsWith('sk-ant-oat') : false;
|
|
73
|
-
return { apiKey, isOAuth };
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Set an API key or OAuth token for a provider.
|
|
77
|
-
*/
|
|
78
|
-
export async function setAuthKey(key, provider = 'anthropic', agentId = 'main', type = 'api_key') {
|
|
79
|
-
const profiles = await loadAuthProfiles(agentId);
|
|
80
|
-
const profileId = `${provider}-${type}`;
|
|
81
|
-
profiles.profiles[profileId] = {
|
|
82
|
-
provider,
|
|
83
|
-
type,
|
|
84
|
-
...(type === 'oauth' ? { access: key } : { key }),
|
|
85
|
-
};
|
|
86
|
-
profiles.lastGood[provider] = profileId;
|
|
87
|
-
await saveAuthProfiles(profiles, agentId);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Delete auth for a provider.
|
|
91
|
-
*/
|
|
92
|
-
export async function deleteAuth(provider = 'anthropic', agentId = 'main') {
|
|
93
|
-
const profiles = await loadAuthProfiles(agentId);
|
|
94
|
-
for (const [id, profile] of Object.entries(profiles.profiles)) {
|
|
95
|
-
if (profile.provider === provider) {
|
|
96
|
-
delete profiles.profiles[id];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
delete profiles.lastGood[provider];
|
|
100
|
-
await saveAuthProfiles(profiles, agentId);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get auth status (has key, masked key) for a provider.
|
|
104
|
-
*/
|
|
105
|
-
export async function getAuthStatus(provider = 'anthropic') {
|
|
106
|
-
const profiles = await loadAuthProfiles('main');
|
|
107
|
-
let hasKey = false;
|
|
108
|
-
let masked = '';
|
|
109
|
-
for (const profile of Object.values(profiles.profiles)) {
|
|
110
|
-
if (profile.provider === provider) {
|
|
111
|
-
const key = profile.key || profile.access || '';
|
|
112
|
-
if (key) {
|
|
113
|
-
hasKey = true;
|
|
114
|
-
masked = key.length > 11 ? `${key.substring(0, 7)}***${key.substring(key.length - 4)}` : '***';
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return { hasKey, masked, provider };
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=auth-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../../src/agent/auth-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvE,SAAS,gBAAgB;IACvB,OAAO,SAAS,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAA;AAC/E,CA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