trusted-user-agent 0.0.0-stage → 0.4.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.
- package/LICENSE +21 -0
- package/README.md +232 -2
- package/dist/acp/agent.js +719 -0
- package/dist/acp/agents/connection.js +298 -0
- package/dist/acp/agents/manager.js +363 -0
- package/dist/acp/agents/registry.js +201 -0
- package/dist/acp/agents/relay-session.js +371 -0
- package/dist/acp/agents/session-index.js +102 -0
- package/dist/acp/backend.js +2 -0
- package/dist/acp/config-options.js +26 -0
- package/dist/acp/mock-backend.js +277 -0
- package/dist/acp/sdk-backend.js +495 -0
- package/dist/browser/mcp-acp-client.js +81 -0
- package/dist/browser/provider.js +1049 -0
- package/dist/browser/schemas.js +221 -0
- package/dist/capability-registry.js +92 -0
- package/dist/client-heartbeat.js +118 -0
- package/dist/compose/schemas.js +90 -0
- package/dist/contacts/schemas.js +26 -0
- package/dist/installer/cli.js +70 -0
- package/dist/installer/common.js +93 -0
- package/dist/installer/index.js +366 -0
- package/dist/installer/mcp-clients.js +555 -0
- package/dist/installer/mcp.js +166 -0
- package/dist/installer/platforms.js +277 -0
- package/dist/logger.js +54 -0
- package/dist/mail/schemas.js +98 -0
- package/dist/mutation/schemas.js +31 -0
- package/dist/native-host/broker-ipc.js +344 -0
- package/dist/native-host/framing.js +76 -0
- package/dist/native-host/main.js +545 -0
- package/dist/native-host/mcp-server.js +333 -0
- package/dist/native-host/mcp-stdio-bridge.js +184 -0
- package/dist/native-host/mcp-stdio-main.js +13 -0
- package/dist/native-host/relay.js +84 -0
- package/dist/native-host/skills-startup.js +167 -0
- package/dist/native-host/transport.js +248 -0
- package/dist/permission-store.js +207 -0
- package/dist/repl/fs-sandbox.js +187 -0
- package/dist/repl/provider.js +252 -0
- package/dist/repl/runtime.js +436 -0
- package/dist/repl/types.js +10 -0
- package/dist/repl/worker.js +731 -0
- package/dist/skills/extension.js +99 -0
- package/dist/skills/grants-file.js +145 -0
- package/dist/skills/isolated-runner.js +259 -0
- package/dist/skills/mock-session-factory.js +49 -0
- package/dist/skills/package-roots.js +25 -0
- package/dist/skills/pi-bridge.js +8 -0
- package/dist/skills/pi-integration.js +110 -0
- package/dist/skills/planner.js +128 -0
- package/dist/skills/registry.js +104 -0
- package/dist/skills/skills-protocol.js +253 -0
- package/dist/skills/skills-service.js +195 -0
- package/dist/tool-bridge.js +8 -0
- package/dist/workspace.js +70 -0
- package/extensions/pi-browser-tools.ts +65 -0
- package/extensions/pi-browser.ts +60 -0
- package/extensions/pi-skills.ts +14 -0
- package/native/pi-agent-host +2 -0
- package/native/pi-browser-host +5 -0
- package/native/pi-browser-host.cmd +3 -0
- package/node_modules/@pi-browser/protocol/.bundled-by-trusted-user-agent +0 -0
- package/node_modules/@pi-browser/protocol/dist/acp.d.ts +10 -0
- package/node_modules/@pi-browser/protocol/dist/acp.js +9 -0
- package/node_modules/@pi-browser/protocol/dist/agents.d.ts +51 -0
- package/node_modules/@pi-browser/protocol/dist/agents.js +44 -0
- package/node_modules/@pi-browser/protocol/dist/browser-tools.d.ts +33 -0
- package/node_modules/@pi-browser/protocol/dist/browser-tools.js +478 -0
- package/node_modules/@pi-browser/protocol/dist/callers.d.ts +123 -0
- package/node_modules/@pi-browser/protocol/dist/callers.js +58 -0
- package/node_modules/@pi-browser/protocol/dist/compose-tools.d.ts +30 -0
- package/node_modules/@pi-browser/protocol/dist/compose-tools.js +175 -0
- package/node_modules/@pi-browser/protocol/dist/contacts-tools.d.ts +23 -0
- package/node_modules/@pi-browser/protocol/dist/contacts-tools.js +63 -0
- package/node_modules/@pi-browser/protocol/dist/control-tools.d.ts +32 -0
- package/node_modules/@pi-browser/protocol/dist/control-tools.js +201 -0
- package/node_modules/@pi-browser/protocol/dist/errors.d.ts +63 -0
- package/node_modules/@pi-browser/protocol/dist/errors.js +109 -0
- package/node_modules/@pi-browser/protocol/dist/index.d.ts +17 -0
- package/node_modules/@pi-browser/protocol/dist/index.js +17 -0
- package/node_modules/@pi-browser/protocol/dist/integration.d.ts +414 -0
- package/node_modules/@pi-browser/protocol/dist/integration.js +270 -0
- package/node_modules/@pi-browser/protocol/dist/jsonrpc.d.ts +33 -0
- package/node_modules/@pi-browser/protocol/dist/jsonrpc.js +31 -0
- package/node_modules/@pi-browser/protocol/dist/mail-mutation-tools.d.ts +27 -0
- package/node_modules/@pi-browser/protocol/dist/mail-mutation-tools.js +88 -0
- package/node_modules/@pi-browser/protocol/dist/mail-tools.d.ts +133 -0
- package/node_modules/@pi-browser/protocol/dist/mail-tools.js +245 -0
- package/node_modules/@pi-browser/protocol/dist/permission.d.ts +113 -0
- package/node_modules/@pi-browser/protocol/dist/permission.js +257 -0
- package/node_modules/@pi-browser/protocol/dist/skills.d.ts +304 -0
- package/node_modules/@pi-browser/protocol/dist/skills.js +473 -0
- package/node_modules/@pi-browser/protocol/dist/tool-capabilities.d.ts +18 -0
- package/node_modules/@pi-browser/protocol/dist/tool-capabilities.js +52 -0
- package/node_modules/@pi-browser/protocol/dist/transport.d.ts +17 -0
- package/node_modules/@pi-browser/protocol/dist/transport.js +17 -0
- package/node_modules/@pi-browser/protocol/package.json +14 -0
- package/package.json +69 -4
- package/skills/browser-walk/SKILL.md +98 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative skills runtime v2.
|
|
3
|
+
*
|
|
4
|
+
* A skill package is ONE activation.json: the package declares the site it
|
|
5
|
+
* covers (hosts), how that site's DOM maps to site events (targets + events),
|
|
6
|
+
* and the skills that listen to those events. Subscriptions may only name
|
|
7
|
+
* events defined in the same file — there is no global event catalog and no
|
|
8
|
+
* cross-file reference to validate.
|
|
9
|
+
*
|
|
10
|
+
* `targets` carry a selector: a CSS selector string (isolated-world runtime,
|
|
11
|
+
* no eval) or a JS dialect with the strict `el =>` prefix (main-world runtime
|
|
12
|
+
* for rules that use it). Everything else is inert data.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SKILL_CAPABILITIES: readonly ["context.read", "suggestion.present", "draft.replace-on-accept", "memory.read", "memory.propose"];
|
|
15
|
+
export type SkillCapability = (typeof SKILL_CAPABILITIES)[number];
|
|
16
|
+
export type SkillApplication = "firefox" | "thunderbird";
|
|
17
|
+
export type SkillContextField = string;
|
|
18
|
+
/** DOM event types the page interpreter can observe. */
|
|
19
|
+
export declare const SKILL_DOM_TYPES: readonly ["input", "keydown", "click"];
|
|
20
|
+
export type SkillDomType = (typeof SKILL_DOM_TYPES)[number];
|
|
21
|
+
export declare const SKILL_KEY_MODIFIERS: readonly ["alt", "ctrl", "shift", "meta"];
|
|
22
|
+
export type SkillKeyModifier = (typeof SKILL_KEY_MODIFIERS)[number];
|
|
23
|
+
export type SkillTargetKind = "css" | "js";
|
|
24
|
+
/**
|
|
25
|
+
* A named DOM predicate. `selector` is either a CSS selector string
|
|
26
|
+
* (matched with el.matches in the isolated world) or the JS dialect with the
|
|
27
|
+
* strict `el =>` prefix (compiled in the main world at arm time; a rule using
|
|
28
|
+
* any JS target is placed in the main world by the planner).
|
|
29
|
+
*/
|
|
30
|
+
export interface SkillTarget {
|
|
31
|
+
selector: string;
|
|
32
|
+
kind: SkillTargetKind;
|
|
33
|
+
/** Optional label regex applied to the element's normalized text. */
|
|
34
|
+
text?: string;
|
|
35
|
+
textFlags?: "i";
|
|
36
|
+
/** Optional bound on textContent length (for context targets). */
|
|
37
|
+
maxTextLength?: number;
|
|
38
|
+
}
|
|
39
|
+
/** One matcher in a site-event sequence: a DOM event on an element matching a target. */
|
|
40
|
+
export interface SkillDomMatcher {
|
|
41
|
+
dom: SkillDomType;
|
|
42
|
+
target: string;
|
|
43
|
+
/** keydown only. */
|
|
44
|
+
key?: string;
|
|
45
|
+
/** keydown only. */
|
|
46
|
+
modifiers?: SkillKeyModifier[];
|
|
47
|
+
}
|
|
48
|
+
/** A payload field resolved from a target's element at fire time. */
|
|
49
|
+
export interface SkillPayloadField {
|
|
50
|
+
/** Target name whose last matched element provides the value. */
|
|
51
|
+
from: string;
|
|
52
|
+
field: "value" | "text";
|
|
53
|
+
/**
|
|
54
|
+
* Resolution mode: "matched" (default) uses the element the sequence last
|
|
55
|
+
* matched for this target; "document" runs a bounded document scan for
|
|
56
|
+
* the target at event FIRE time (rare — not per DOM event).
|
|
57
|
+
*/
|
|
58
|
+
resolve?: "matched" | "document";
|
|
59
|
+
/** Capture bound in characters (default 2048, hard cap 262144). */
|
|
60
|
+
maxChars?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A site event definition. `debounced` fires after `debounceMs` of silence
|
|
64
|
+
* following the final sequence match. `gate` fires synchronously when the
|
|
65
|
+
* LAST matcher of one of its alternatives completes; that final match IS the
|
|
66
|
+
* gesture the submission gate holds.
|
|
67
|
+
*/
|
|
68
|
+
export interface SkillEventDefinition {
|
|
69
|
+
kind: "debounced" | "gate";
|
|
70
|
+
/** debounced only; 0..60000. */
|
|
71
|
+
debounceMs?: number;
|
|
72
|
+
/** debounced only; suspend the pause timer while IME composition is active. */
|
|
73
|
+
suspendDuringComposition?: boolean;
|
|
74
|
+
/** debounced: 1..8 ordered matchers. */
|
|
75
|
+
sequence?: SkillDomMatcher[];
|
|
76
|
+
/** gate only; stable identity for chain dedup. */
|
|
77
|
+
chainId?: string;
|
|
78
|
+
/** gate: 1..16 ordered alternatives, each 1..8 matchers. */
|
|
79
|
+
alternatives?: SkillDomMatcher[][];
|
|
80
|
+
/**
|
|
81
|
+
* gate only. Whether the held gesture stops the page's default action
|
|
82
|
+
* (preventDefault + stopImmediatePropagation). Default true: the gate
|
|
83
|
+
* blocks the send until reviewed. Set false for an advisory gesture:
|
|
84
|
+
* the page proceeds with the user's own action and the skill only
|
|
85
|
+
* observes it. Declared by the skill package, not the runtime.
|
|
86
|
+
*/
|
|
87
|
+
stopDefaultAction?: boolean;
|
|
88
|
+
/** Payload fields, package-defined names (≤ 8, each name ≤ 64). */
|
|
89
|
+
payload?: Record<string, SkillPayloadField>;
|
|
90
|
+
}
|
|
91
|
+
export interface SkillSubscription {
|
|
92
|
+
/** Local event name: must be a key of the package's `events`. */
|
|
93
|
+
event: string;
|
|
94
|
+
conditions?: {
|
|
95
|
+
minCharacters?: number;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export interface SkillDefinition {
|
|
99
|
+
id: string;
|
|
100
|
+
type: "triggered" | "active" | "passive";
|
|
101
|
+
instructions: string;
|
|
102
|
+
subscriptions?: SkillSubscription[];
|
|
103
|
+
command?: string;
|
|
104
|
+
observations?: SkillSubscription[];
|
|
105
|
+
batch?: {
|
|
106
|
+
maxEvents: number;
|
|
107
|
+
maxWaitMs: number;
|
|
108
|
+
};
|
|
109
|
+
/** Payload field names the skill needs from event snapshots. */
|
|
110
|
+
context: {
|
|
111
|
+
required: string[];
|
|
112
|
+
optional: string[];
|
|
113
|
+
};
|
|
114
|
+
review?: {
|
|
115
|
+
defaultMode: "advisory" | "review-before-submit";
|
|
116
|
+
};
|
|
117
|
+
capabilities: SkillCapability[];
|
|
118
|
+
memory?: {
|
|
119
|
+
namespace: string;
|
|
120
|
+
scope: "account" | "profile";
|
|
121
|
+
};
|
|
122
|
+
execution: {
|
|
123
|
+
handler: "agent";
|
|
124
|
+
timeoutMs: number;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** The unified package manifest (activation.json, schemaVersion 2). */
|
|
128
|
+
export interface SkillPackageManifest {
|
|
129
|
+
schemaVersion: 2;
|
|
130
|
+
packageId: string;
|
|
131
|
+
application: SkillApplication;
|
|
132
|
+
/** Exact hosts; subdomains are permitted only through subdomainHosts. */
|
|
133
|
+
hosts: string[];
|
|
134
|
+
subdomainHosts?: string[];
|
|
135
|
+
pathPrefixes?: string[];
|
|
136
|
+
targets: Record<string, SkillTarget>;
|
|
137
|
+
events: Record<string, SkillEventDefinition>;
|
|
138
|
+
skills: SkillDefinition[];
|
|
139
|
+
}
|
|
140
|
+
export interface RegisteredSkill {
|
|
141
|
+
key: string;
|
|
142
|
+
revision: string;
|
|
143
|
+
packageId: string;
|
|
144
|
+
definition: SkillDefinition;
|
|
145
|
+
instructions: string;
|
|
146
|
+
/** Full package manifest; the planner reads hosts/targets/events from here. */
|
|
147
|
+
manifest: SkillPackageManifest;
|
|
148
|
+
}
|
|
149
|
+
/** Global event identity: `<packageId>:<local event name>`. */
|
|
150
|
+
export declare function skillEventName(packageId: string, local: string): string;
|
|
151
|
+
export interface SkillEvent {
|
|
152
|
+
version: 1;
|
|
153
|
+
eventId: string;
|
|
154
|
+
/** `<packageId>:<local event name>`. */
|
|
155
|
+
event: string;
|
|
156
|
+
source: {
|
|
157
|
+
application: SkillApplication;
|
|
158
|
+
connectionEpoch: string;
|
|
159
|
+
documentGeneration?: string;
|
|
160
|
+
tabId?: number;
|
|
161
|
+
frameId?: number;
|
|
162
|
+
accountId?: string;
|
|
163
|
+
};
|
|
164
|
+
interactionId: string;
|
|
165
|
+
draftRevision?: number;
|
|
166
|
+
contextRevision: number;
|
|
167
|
+
planVersion: number;
|
|
168
|
+
origin: "user" | "site" | "skill";
|
|
169
|
+
causedBy?: string;
|
|
170
|
+
contextRef: string;
|
|
171
|
+
}
|
|
172
|
+
export interface ReviewResult {
|
|
173
|
+
jobId: string;
|
|
174
|
+
eventId: string;
|
|
175
|
+
skillKey: string;
|
|
176
|
+
skillRevision: string;
|
|
177
|
+
decision: "clear" | "suggest" | "abstain";
|
|
178
|
+
explanation?: string;
|
|
179
|
+
replacementText?: string;
|
|
180
|
+
}
|
|
181
|
+
export declare function skillRelativePath(value: unknown): string;
|
|
182
|
+
export declare function normalizeSkillHost(value: unknown): string;
|
|
183
|
+
export declare function parseSkillPackage(value: unknown): SkillPackageManifest;
|
|
184
|
+
/** Shape validation is separate from coordinator verification of sender identity. */
|
|
185
|
+
export declare function parseSkillEvent(value: unknown): SkillEvent;
|
|
186
|
+
export type SkillEventSource = SkillEvent["source"];
|
|
187
|
+
/** One armed rule in a compiled page plan (host → client, display + arming). */
|
|
188
|
+
export interface SkillPlanRule {
|
|
189
|
+
skillKey: string;
|
|
190
|
+
skillRevision: string;
|
|
191
|
+
/** The package owns the site definition; the plan carries it to the page. */
|
|
192
|
+
packageId: string;
|
|
193
|
+
/**
|
|
194
|
+
* Runtime placement, derived from the manifest at compile time:
|
|
195
|
+
* "isolated" when every target is CSS (the default), "main" when any
|
|
196
|
+
* target uses the JS dialect (its predicate must run where string
|
|
197
|
+
* codegen is legal, and the gate consult is synchronous).
|
|
198
|
+
*/
|
|
199
|
+
world: "isolated" | "main";
|
|
200
|
+
targets: Record<string, SkillTarget>;
|
|
201
|
+
/** Definitions of the subscribed events (local names). */
|
|
202
|
+
events: Record<string, SkillEventDefinition>;
|
|
203
|
+
subscriptions: SkillSubscription[];
|
|
204
|
+
mode: "advisory" | "review-before-submit";
|
|
205
|
+
capabilities: SkillCapability[];
|
|
206
|
+
}
|
|
207
|
+
/** Compiled page plan delivered to the coordinator for one document. */
|
|
208
|
+
export interface PagePlan {
|
|
209
|
+
planId: string;
|
|
210
|
+
planVersion: number;
|
|
211
|
+
documentGeneration: string;
|
|
212
|
+
/** Plans expire; the coordinator re-plans before arming again. */
|
|
213
|
+
expiresAt: number;
|
|
214
|
+
rules: SkillPlanRule[];
|
|
215
|
+
unavailable: {
|
|
216
|
+
skillKey: string;
|
|
217
|
+
reason: string;
|
|
218
|
+
}[];
|
|
219
|
+
}
|
|
220
|
+
/** Client → host: compile a page plan for a verified source identity. */
|
|
221
|
+
export interface SkillsPlanParams {
|
|
222
|
+
source: SkillEventSource;
|
|
223
|
+
/** The frame's own URL, supplied by the addon, never a page payload. */
|
|
224
|
+
url: string;
|
|
225
|
+
}
|
|
226
|
+
export interface SkillsPlanResult {
|
|
227
|
+
status: "ok" | "unavailable";
|
|
228
|
+
reason?: string;
|
|
229
|
+
plan?: PagePlan;
|
|
230
|
+
}
|
|
231
|
+
/** Client → host: submit a verified skill event. */
|
|
232
|
+
export interface SkillsEventParams {
|
|
233
|
+
event: SkillEvent;
|
|
234
|
+
}
|
|
235
|
+
export interface SkillsEventJob {
|
|
236
|
+
jobId: string;
|
|
237
|
+
skillKey: string;
|
|
238
|
+
/** Scheduler key the coordinator can target with skills_cancel. */
|
|
239
|
+
key: string;
|
|
240
|
+
}
|
|
241
|
+
export interface SkillsEventResult {
|
|
242
|
+
status: "accepted" | "no-match" | "stale-plan" | "unavailable" | "duplicate";
|
|
243
|
+
reason?: string;
|
|
244
|
+
jobs?: SkillsEventJob[];
|
|
245
|
+
}
|
|
246
|
+
/** Client → host: cancel pending skill work for one interaction. */
|
|
247
|
+
export interface SkillsCancelParams {
|
|
248
|
+
interactionId: string;
|
|
249
|
+
}
|
|
250
|
+
export interface SkillsCancelResult {
|
|
251
|
+
cancelled: number;
|
|
252
|
+
}
|
|
253
|
+
/** Client → host: probe the skill runtime. */
|
|
254
|
+
export interface SkillsStatusResult {
|
|
255
|
+
available: boolean;
|
|
256
|
+
stats: {
|
|
257
|
+
running: number;
|
|
258
|
+
queued: number;
|
|
259
|
+
replacements: number;
|
|
260
|
+
closed: boolean;
|
|
261
|
+
outcomes: Record<string, number>;
|
|
262
|
+
};
|
|
263
|
+
plans: number;
|
|
264
|
+
armedRules: number;
|
|
265
|
+
}
|
|
266
|
+
/** Host → client: resolve a contextRef against the coordinator's bounded snapshot store. */
|
|
267
|
+
export interface SkillsContextRequestParams {
|
|
268
|
+
contextRef: string;
|
|
269
|
+
interactionId: string;
|
|
270
|
+
planVersion: number;
|
|
271
|
+
/** Only these snapshot fields are returned (privacy by request). */
|
|
272
|
+
fields: string[];
|
|
273
|
+
maxBytes: number;
|
|
274
|
+
}
|
|
275
|
+
export interface SkillsContextResult {
|
|
276
|
+
contextRef: string;
|
|
277
|
+
context: Record<string, unknown>;
|
|
278
|
+
bytes: number;
|
|
279
|
+
}
|
|
280
|
+
/** Host → client: deliver a job outcome; the coordinator acks delivery. */
|
|
281
|
+
export interface SkillsResultParams {
|
|
282
|
+
jobId: string;
|
|
283
|
+
eventId: string;
|
|
284
|
+
skillKey: string;
|
|
285
|
+
skillRevision: string;
|
|
286
|
+
status: "done" | "unavailable";
|
|
287
|
+
decision?: "clear" | "suggest" | "abstain";
|
|
288
|
+
reason?: string;
|
|
289
|
+
explanation?: string;
|
|
290
|
+
replacementText?: string;
|
|
291
|
+
}
|
|
292
|
+
export interface SkillsResultAck {
|
|
293
|
+
delivered: true;
|
|
294
|
+
}
|
|
295
|
+
export declare function parseSkillsPlanParams(value: unknown): SkillsPlanParams;
|
|
296
|
+
export declare function parseSkillsEventParams(value: unknown): SkillsEventParams;
|
|
297
|
+
export declare function parseSkillsCancelParams(value: unknown): SkillsCancelParams;
|
|
298
|
+
export declare function parseSkillsContextRequestParams(value: unknown): SkillsContextRequestParams;
|
|
299
|
+
/** The coordinator's snapshot payload; the host binds it to the job identity. */
|
|
300
|
+
export declare function parseSkillsContextResult(value: unknown, maxBytes: number): SkillsContextResult;
|
|
301
|
+
export declare function parseSkillsResultParams(value: unknown): SkillsResultParams;
|
|
302
|
+
/** Parse semantic output only. The caller must bind it to the immutable job identity. */
|
|
303
|
+
export declare function parseReviewResult(value: unknown): ReviewResult;
|
|
304
|
+
//# sourceMappingURL=skills.d.ts.map
|